solace-agent-mesh 1.7.1__py3-none-any.whl → 1.13.2__py3-none-any.whl
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.
Potentially problematic release.
This version of solace-agent-mesh might be problematic. Click here for more details.
- solace_agent_mesh/agent/adk/alembic/README +74 -0
- solace_agent_mesh/agent/adk/alembic/env.py +77 -0
- solace_agent_mesh/agent/adk/alembic/script.py.mako +28 -0
- solace_agent_mesh/agent/adk/alembic/versions/e2902798564d_adk_session_db_upgrade.py +52 -0
- solace_agent_mesh/agent/adk/alembic.ini +112 -0
- solace_agent_mesh/agent/adk/artifacts/filesystem_artifact_service.py +164 -0
- solace_agent_mesh/agent/adk/artifacts/s3_artifact_service.py +163 -0
- solace_agent_mesh/agent/adk/callbacks.py +752 -127
- solace_agent_mesh/agent/adk/embed_resolving_mcp_toolset.py +99 -7
- solace_agent_mesh/agent/adk/intelligent_mcp_callbacks.py +52 -5
- solace_agent_mesh/agent/adk/mcp_content_processor.py +1 -1
- solace_agent_mesh/agent/adk/models/lite_llm.py +34 -16
- solace_agent_mesh/agent/adk/models/oauth2_token_manager.py +24 -137
- solace_agent_mesh/agent/adk/runner.py +66 -8
- solace_agent_mesh/agent/adk/schema_migration.py +88 -0
- solace_agent_mesh/agent/adk/services.py +41 -1
- solace_agent_mesh/agent/adk/setup.py +220 -32
- solace_agent_mesh/agent/adk/stream_parser.py +229 -40
- solace_agent_mesh/agent/protocol/event_handlers.py +219 -33
- solace_agent_mesh/agent/proxies/a2a/component.py +572 -75
- solace_agent_mesh/agent/proxies/a2a/config.py +80 -4
- solace_agent_mesh/agent/proxies/base/component.py +188 -22
- solace_agent_mesh/agent/proxies/base/proxy_task_context.py +3 -1
- solace_agent_mesh/agent/sac/app.py +37 -12
- solace_agent_mesh/agent/sac/component.py +322 -52
- solace_agent_mesh/agent/sac/patch_adk.py +8 -16
- solace_agent_mesh/agent/sac/task_execution_context.py +90 -0
- solace_agent_mesh/agent/tools/__init__.py +3 -0
- solace_agent_mesh/agent/tools/audio_tools.py +3 -3
- solace_agent_mesh/agent/tools/builtin_artifact_tools.py +698 -24
- solace_agent_mesh/agent/tools/deep_research_tools.py +2161 -0
- solace_agent_mesh/agent/tools/peer_agent_tool.py +82 -15
- solace_agent_mesh/agent/tools/time_tools.py +126 -0
- solace_agent_mesh/agent/tools/tool_config_types.py +54 -2
- solace_agent_mesh/agent/tools/web_search_tools.py +279 -0
- solace_agent_mesh/agent/tools/web_tools.py +125 -17
- solace_agent_mesh/agent/utils/artifact_helpers.py +243 -5
- solace_agent_mesh/agent/utils/context_helpers.py +17 -0
- solace_agent_mesh/assets/docs/404.html +6 -6
- solace_agent_mesh/assets/docs/assets/css/{styles.906a1503.css → styles.8162edfb.css} +1 -1
- solace_agent_mesh/assets/docs/assets/js/05749d90.19ac4f35.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/15ba94aa.e186750d.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/15e40e79.434bb30f.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/17896441.e612dfb4.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/2279.550aa580.js +2 -0
- solace_agent_mesh/assets/docs/assets/js/{17896441.a5e82f9b.js.LICENSE.txt → 2279.550aa580.js.LICENSE.txt} +6 -0
- solace_agent_mesh/assets/docs/assets/js/240a0364.83e37aa8.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/2e32b5e0.2f0db237.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/3a6c6137.7e61915d.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/3ac1795d.7f7ab1c1.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/3ff0015d.e53c9b78.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/41adc471.0e95b87c.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/4667dc50.bf2ad456.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/49eed117.493d6f99.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/{509e993c.4c7a1a6d.js → 509e993c.a1fbf45a.js} +1 -1
- solace_agent_mesh/assets/docs/assets/js/547e15cc.8e6da617.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/55b7b518.29d6e75d.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/5b8d9c11.d4eb37b8.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/5c2bd65f.1ee87753.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/60702c0e.a8bdd79b.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/64195356.09dbd087.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/66d4869e.30340bd3.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/6aaedf65.7253541d.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/6d84eae0.fd23ba4a.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/729898df.7249e9fd.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/7e294c01.7c5f6906.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/8024126c.e3467286.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/81a99df0.7ed65d45.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/82fbfb93.161823a5.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/924ffdeb.975e428a.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/94e8668d.16083b3f.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/9bb13469.4523ae20.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/a7d42657.a956689d.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/a94703ab.3e5fbcb3.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/ab9708a8.3e563275.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/c93cbaa0.0e0d8baf.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/cab03b5b.6a073091.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/cbe2e9ea.07e170dd.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/e04b235d.06d23db6.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/e1b6eeb4.deb2b62e.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/e3d9abda.1476f570.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/e6f9706b.acc800d3.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/e92d0134.c147a429.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/ee0c2fe7.94d0a351.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/f284c35a.cc97854c.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/main.d634009f.js +2 -0
- solace_agent_mesh/assets/docs/assets/js/runtime~main.27bb82a7.js +1 -0
- solace_agent_mesh/assets/docs/docs/documentation/components/agents/index.html +68 -68
- solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/artifact-management/index.html +50 -50
- solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/audio-tools/index.html +42 -42
- solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/data-analysis-tools/index.html +55 -55
- solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/embeds/index.html +75 -75
- solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/image-tools/index.html +81 -0
- solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/index.html +67 -50
- solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/research-tools/index.html +136 -0
- solace_agent_mesh/assets/docs/docs/documentation/components/cli/index.html +178 -144
- solace_agent_mesh/assets/docs/docs/documentation/components/gateways/index.html +43 -42
- solace_agent_mesh/assets/docs/docs/documentation/components/index.html +20 -18
- solace_agent_mesh/assets/docs/docs/documentation/components/orchestrator/index.html +23 -23
- solace_agent_mesh/assets/docs/docs/documentation/components/platform-service/index.html +33 -0
- solace_agent_mesh/assets/docs/docs/documentation/components/plugins/index.html +45 -45
- solace_agent_mesh/assets/docs/docs/documentation/components/projects/index.html +98 -112
- solace_agent_mesh/assets/docs/docs/documentation/components/prompts/index.html +147 -0
- solace_agent_mesh/assets/docs/docs/documentation/components/proxies/index.html +208 -125
- solace_agent_mesh/assets/docs/docs/documentation/components/speech/index.html +52 -0
- solace_agent_mesh/assets/docs/docs/documentation/deploying/debugging/index.html +28 -28
- solace_agent_mesh/assets/docs/docs/documentation/deploying/deployment-options/index.html +29 -29
- solace_agent_mesh/assets/docs/docs/documentation/deploying/index.html +14 -14
- solace_agent_mesh/assets/docs/docs/documentation/deploying/kubernetes/index.html +47 -0
- solace_agent_mesh/assets/docs/docs/documentation/deploying/kubernetes/kubernetes-deployment-guide/index.html +197 -0
- solace_agent_mesh/assets/docs/docs/documentation/deploying/logging/index.html +67 -53
- solace_agent_mesh/assets/docs/docs/documentation/deploying/observability/index.html +17 -17
- solace_agent_mesh/assets/docs/docs/documentation/deploying/proxy_configuration/index.html +49 -0
- solace_agent_mesh/assets/docs/docs/documentation/developing/create-agents/index.html +38 -38
- solace_agent_mesh/assets/docs/docs/documentation/developing/create-gateways/index.html +87 -87
- solace_agent_mesh/assets/docs/docs/documentation/developing/creating-python-tools/index.html +67 -49
- solace_agent_mesh/assets/docs/docs/documentation/developing/creating-service-providers/index.html +17 -17
- solace_agent_mesh/assets/docs/docs/documentation/developing/evaluations/index.html +51 -51
- solace_agent_mesh/assets/docs/docs/documentation/developing/index.html +22 -22
- solace_agent_mesh/assets/docs/docs/documentation/developing/structure/index.html +27 -27
- solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/bedrock-agents/index.html +135 -135
- solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/custom-agent/index.html +66 -66
- solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/event-mesh-gateway/index.html +51 -51
- solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/mcp-integration/index.html +50 -38
- solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/mongodb-integration/index.html +86 -86
- solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/rag-integration/index.html +51 -51
- solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/rest-gateway/index.html +24 -24
- solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/slack-integration/index.html +30 -30
- solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/sql-database/index.html +44 -44
- solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/teams-integration/index.html +115 -0
- solace_agent_mesh/assets/docs/docs/documentation/enterprise/agent-builder/index.html +50 -23
- solace_agent_mesh/assets/docs/docs/documentation/enterprise/connectors/index.html +29 -24
- solace_agent_mesh/assets/docs/docs/documentation/enterprise/index.html +21 -21
- solace_agent_mesh/assets/docs/docs/documentation/enterprise/installation/index.html +40 -37
- solace_agent_mesh/assets/docs/docs/documentation/enterprise/openapi-tools/index.html +324 -0
- solace_agent_mesh/assets/docs/docs/documentation/enterprise/rbac-setup-guide/index.html +96 -66
- solace_agent_mesh/assets/docs/docs/documentation/enterprise/secure-user-delegated-access/index.html +181 -181
- solace_agent_mesh/assets/docs/docs/documentation/enterprise/single-sign-on/index.html +75 -75
- solace_agent_mesh/assets/docs/docs/documentation/enterprise/wheel-installation/index.html +27 -27
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/architecture/index.html +44 -44
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/index.html +39 -38
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/introduction/index.html +30 -30
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/try-agent-mesh/index.html +18 -18
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/vibe_coding/index.html +62 -0
- solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/artifact-storage/index.html +135 -114
- solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/configurations/index.html +37 -37
- solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/index.html +14 -14
- solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/installation/index.html +27 -25
- solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/large_language_models/index.html +69 -69
- solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/run-project/index.html +72 -72
- solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/session-storage/index.html +112 -112
- solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/user-feedback/index.html +28 -28
- solace_agent_mesh/assets/docs/docs/documentation/migrations/a2a-upgrade/a2a-gateway-upgrade-to-0.3.0/index.html +42 -42
- solace_agent_mesh/assets/docs/docs/documentation/migrations/a2a-upgrade/a2a-technical-migration-map/index.html +20 -20
- solace_agent_mesh/assets/docs/docs/documentation/migrations/platform-service-split/index.html +85 -0
- solace_agent_mesh/assets/docs/lunr-index-1768329217460.json +1 -0
- solace_agent_mesh/assets/docs/lunr-index.json +1 -1
- solace_agent_mesh/assets/docs/search-doc-1768329217460.json +1 -0
- solace_agent_mesh/assets/docs/search-doc.json +1 -1
- solace_agent_mesh/assets/docs/sitemap.xml +1 -1
- solace_agent_mesh/cli/__init__.py +1 -1
- solace_agent_mesh/cli/commands/add_cmd/__init__.py +3 -1
- solace_agent_mesh/cli/commands/add_cmd/agent_cmd.py +6 -1
- solace_agent_mesh/cli/commands/add_cmd/proxy_cmd.py +100 -0
- solace_agent_mesh/cli/commands/eval_cmd.py +1 -1
- solace_agent_mesh/cli/commands/init_cmd/__init__.py +15 -0
- solace_agent_mesh/cli/commands/init_cmd/directory_step.py +1 -1
- solace_agent_mesh/cli/commands/init_cmd/env_step.py +30 -3
- solace_agent_mesh/cli/commands/init_cmd/orchestrator_step.py +3 -4
- solace_agent_mesh/cli/commands/init_cmd/platform_service_step.py +85 -0
- solace_agent_mesh/cli/commands/init_cmd/webui_gateway_step.py +16 -3
- solace_agent_mesh/cli/commands/plugin_cmd/add_cmd.py +2 -1
- solace_agent_mesh/cli/commands/plugin_cmd/catalog_cmd.py +1 -0
- solace_agent_mesh/cli/commands/plugin_cmd/create_cmd.py +3 -3
- solace_agent_mesh/cli/commands/run_cmd.py +64 -49
- solace_agent_mesh/cli/commands/tools_cmd.py +315 -0
- solace_agent_mesh/cli/main.py +15 -0
- solace_agent_mesh/client/webui/frontend/static/assets/{authCallback-tcIFZLis.js → authCallback-KnKMP_vb.js} +1 -1
- solace_agent_mesh/client/webui/frontend/static/assets/client-DpBL2stg.js +25 -0
- solace_agent_mesh/client/webui/frontend/static/assets/main-Cd498TV2.js +435 -0
- solace_agent_mesh/client/webui/frontend/static/assets/main-rSf8Vu29.css +1 -0
- solace_agent_mesh/client/webui/frontend/static/assets/{vendor-CINwxvwV.js → vendor-CGk8Suyh.js} +189 -94
- solace_agent_mesh/client/webui/frontend/static/auth-callback.html +3 -3
- solace_agent_mesh/client/webui/frontend/static/index.html +4 -4
- solace_agent_mesh/client/webui/frontend/static/mockServiceWorker.js +336 -0
- solace_agent_mesh/client/webui/frontend/static/ui-version.json +6 -0
- solace_agent_mesh/common/a2a/types.py +1 -1
- solace_agent_mesh/common/agent_registry.py +38 -11
- solace_agent_mesh/common/data_parts.py +124 -0
- solace_agent_mesh/common/error_handlers.py +83 -0
- solace_agent_mesh/common/exceptions.py +24 -0
- solace_agent_mesh/common/oauth/__init__.py +17 -0
- solace_agent_mesh/common/oauth/oauth_client.py +408 -0
- solace_agent_mesh/common/oauth/utils.py +50 -0
- solace_agent_mesh/common/rag_dto.py +156 -0
- solace_agent_mesh/common/sac/sam_component_base.py +73 -1
- solace_agent_mesh/common/sam_events/event_service.py +2 -2
- solace_agent_mesh/common/utils/embeds/converter.py +1 -8
- solace_agent_mesh/common/utils/embeds/modifiers.py +2 -27
- solace_agent_mesh/common/utils/embeds/resolver.py +94 -25
- solace_agent_mesh/common/utils/embeds/types.py +1 -0
- solace_agent_mesh/common/utils/log_formatters.py +20 -0
- solace_agent_mesh/common/utils/mime_helpers.py +12 -5
- solace_agent_mesh/common/utils/rbac_utils.py +69 -0
- solace_agent_mesh/common/utils/templates/__init__.py +8 -0
- solace_agent_mesh/common/utils/templates/liquid_renderer.py +210 -0
- solace_agent_mesh/common/utils/templates/template_resolver.py +161 -0
- solace_agent_mesh/config_portal/backend/common.py +12 -0
- solace_agent_mesh/config_portal/frontend/static/client/assets/_index-CljP4_mv.js +103 -0
- solace_agent_mesh/config_portal/frontend/static/client/assets/{components-Rk0n-9cK.js → components-CaC6hG8d.js} +22 -22
- solace_agent_mesh/config_portal/frontend/static/client/assets/{entry.client-mvZjNKiz.js → entry.client-H_TM0YBt.js} +3 -3
- solace_agent_mesh/config_portal/frontend/static/client/assets/{index-DzNKzXrc.js → index-CnFykb2v.js} +16 -16
- solace_agent_mesh/config_portal/frontend/static/client/assets/manifest-f8439d40.js +1 -0
- solace_agent_mesh/config_portal/frontend/static/client/assets/root-BIMqslJB.css +1 -0
- solace_agent_mesh/config_portal/frontend/static/client/assets/root-mJmTIdIk.js +10 -0
- solace_agent_mesh/config_portal/frontend/static/client/index.html +3 -3
- solace_agent_mesh/core_a2a/service.py +3 -2
- solace_agent_mesh/gateway/adapter/base.py +28 -1
- solace_agent_mesh/gateway/adapter/types.py +9 -0
- solace_agent_mesh/gateway/base/app.py +10 -0
- solace_agent_mesh/gateway/base/auth_interface.py +103 -0
- solace_agent_mesh/gateway/base/component.py +451 -10
- solace_agent_mesh/gateway/generic/component.py +274 -30
- solace_agent_mesh/gateway/http_sse/alembic/env.py +0 -7
- solace_agent_mesh/gateway/http_sse/alembic/versions/20251023_add_soft_delete_and_search.py +2 -43
- solace_agent_mesh/gateway/http_sse/alembic/versions/20251024_add_default_agent_to_projects.py +2 -2
- solace_agent_mesh/gateway/http_sse/alembic/versions/20251108_create_prompt_tables_with_sharing.py +154 -0
- solace_agent_mesh/gateway/http_sse/alembic/versions/20251115_add_parent_task_id.py +32 -0
- solace_agent_mesh/gateway/http_sse/alembic/versions/20251126_add_background_task_fields.py +47 -0
- solace_agent_mesh/gateway/http_sse/alembic/versions/20251202_add_versioned_fields_to_prompts.py +52 -0
- solace_agent_mesh/gateway/http_sse/alembic.ini +0 -36
- solace_agent_mesh/gateway/http_sse/app.py +23 -6
- solace_agent_mesh/gateway/http_sse/component.py +158 -73
- solace_agent_mesh/gateway/http_sse/dependencies.py +50 -57
- solace_agent_mesh/gateway/http_sse/main.py +58 -482
- solace_agent_mesh/gateway/http_sse/repository/chat_task_repository.py +2 -2
- solace_agent_mesh/gateway/http_sse/repository/entities/project.py +1 -1
- solace_agent_mesh/gateway/http_sse/repository/entities/project_user.py +1 -1
- solace_agent_mesh/gateway/http_sse/repository/entities/session.py +3 -2
- solace_agent_mesh/gateway/http_sse/repository/entities/task.py +7 -0
- solace_agent_mesh/gateway/http_sse/repository/feedback_repository.py +2 -2
- solace_agent_mesh/gateway/http_sse/repository/interfaces.py +2 -2
- solace_agent_mesh/gateway/http_sse/repository/models/__init__.py +5 -0
- solace_agent_mesh/gateway/http_sse/repository/models/prompt_model.py +159 -0
- solace_agent_mesh/gateway/http_sse/repository/models/session_model.py +1 -1
- solace_agent_mesh/gateway/http_sse/repository/models/task_model.py +8 -1
- solace_agent_mesh/gateway/http_sse/repository/project_repository.py +1 -1
- solace_agent_mesh/gateway/http_sse/repository/project_user_repository.py +1 -1
- solace_agent_mesh/gateway/http_sse/repository/session_repository.py +12 -107
- solace_agent_mesh/gateway/http_sse/repository/task_repository.py +86 -2
- solace_agent_mesh/gateway/http_sse/routers/agent_cards.py +38 -7
- solace_agent_mesh/gateway/http_sse/routers/artifacts.py +113 -7
- solace_agent_mesh/gateway/http_sse/routers/auth.py +69 -132
- solace_agent_mesh/gateway/http_sse/routers/config.py +235 -10
- solace_agent_mesh/gateway/http_sse/routers/dto/project_dto.py +69 -0
- solace_agent_mesh/gateway/http_sse/routers/dto/prompt_dto.py +255 -0
- solace_agent_mesh/gateway/http_sse/routers/dto/requests/session_requests.py +1 -1
- solace_agent_mesh/gateway/http_sse/routers/dto/responses/base_responses.py +1 -1
- solace_agent_mesh/gateway/http_sse/routers/dto/responses/project_responses.py +1 -0
- solace_agent_mesh/gateway/http_sse/routers/dto/responses/session_responses.py +3 -2
- solace_agent_mesh/gateway/http_sse/routers/dto/responses/version_responses.py +31 -0
- solace_agent_mesh/gateway/http_sse/routers/feedback.py +2 -2
- solace_agent_mesh/gateway/http_sse/routers/people.py +2 -2
- solace_agent_mesh/gateway/http_sse/routers/projects.py +250 -24
- solace_agent_mesh/gateway/http_sse/routers/prompts.py +1416 -0
- solace_agent_mesh/gateway/http_sse/routers/sessions.py +14 -5
- solace_agent_mesh/gateway/http_sse/routers/speech.py +355 -0
- solace_agent_mesh/gateway/http_sse/routers/sse.py +117 -4
- solace_agent_mesh/gateway/http_sse/routers/tasks.py +509 -149
- solace_agent_mesh/gateway/http_sse/routers/users.py +1 -1
- solace_agent_mesh/gateway/http_sse/routers/version.py +343 -0
- solace_agent_mesh/gateway/http_sse/routers/visualization.py +2 -1
- solace_agent_mesh/gateway/http_sse/services/audio_service.py +1227 -0
- solace_agent_mesh/gateway/http_sse/services/background_task_monitor.py +186 -0
- solace_agent_mesh/gateway/http_sse/services/data_retention_service.py +1 -1
- solace_agent_mesh/gateway/http_sse/services/feedback_service.py +1 -1
- solace_agent_mesh/gateway/http_sse/services/project_service.py +539 -12
- solace_agent_mesh/gateway/http_sse/services/prompt_builder_assistant.py +303 -0
- solace_agent_mesh/gateway/http_sse/services/session_service.py +198 -21
- solace_agent_mesh/gateway/http_sse/services/task_logger_service.py +354 -4
- solace_agent_mesh/gateway/http_sse/sse_manager.py +280 -169
- solace_agent_mesh/gateway/http_sse/utils/artifact_copy_utils.py +370 -0
- solace_agent_mesh/gateway/http_sse/utils/stim_utils.py +41 -1
- solace_agent_mesh/services/__init__.py +0 -0
- solace_agent_mesh/services/platform/__init__.py +29 -0
- solace_agent_mesh/services/platform/alembic/env.py +85 -0
- solace_agent_mesh/services/platform/alembic/script.py.mako +28 -0
- solace_agent_mesh/services/platform/alembic.ini +109 -0
- solace_agent_mesh/services/platform/api/__init__.py +3 -0
- solace_agent_mesh/services/platform/api/dependencies.py +154 -0
- solace_agent_mesh/services/platform/api/main.py +314 -0
- solace_agent_mesh/services/platform/api/middleware.py +51 -0
- solace_agent_mesh/services/platform/api/routers/__init__.py +33 -0
- solace_agent_mesh/services/platform/api/routers/health_router.py +31 -0
- solace_agent_mesh/services/platform/app.py +215 -0
- solace_agent_mesh/services/platform/component.py +777 -0
- solace_agent_mesh/shared/__init__.py +14 -0
- solace_agent_mesh/shared/api/__init__.py +42 -0
- solace_agent_mesh/shared/auth/__init__.py +26 -0
- solace_agent_mesh/shared/auth/dependencies.py +204 -0
- solace_agent_mesh/shared/auth/middleware.py +347 -0
- solace_agent_mesh/shared/database/__init__.py +20 -0
- solace_agent_mesh/{gateway/http_sse/shared → shared/database}/base_repository.py +1 -1
- solace_agent_mesh/{gateway/http_sse/shared → shared/database}/database_exceptions.py +1 -1
- solace_agent_mesh/{gateway/http_sse/shared → shared/database}/database_helpers.py +1 -1
- solace_agent_mesh/shared/exceptions/__init__.py +36 -0
- solace_agent_mesh/{gateway/http_sse/shared → shared/exceptions}/exception_handlers.py +1 -1
- solace_agent_mesh/shared/utils/__init__.py +21 -0
- solace_agent_mesh/templates/logging_config_template.yaml +48 -0
- solace_agent_mesh/templates/main_orchestrator.yaml +12 -1
- solace_agent_mesh/templates/platform.yaml +49 -0
- solace_agent_mesh/templates/plugin_readme_template.md +3 -25
- solace_agent_mesh/templates/plugin_tool_config_template.yaml +109 -0
- solace_agent_mesh/templates/proxy_template.yaml +62 -0
- solace_agent_mesh/templates/webui.yaml +148 -6
- solace_agent_mesh/tools/web_search/__init__.py +18 -0
- solace_agent_mesh/tools/web_search/base.py +84 -0
- solace_agent_mesh/tools/web_search/google_search.py +247 -0
- solace_agent_mesh/tools/web_search/models.py +99 -0
- {solace_agent_mesh-1.7.1.dist-info → solace_agent_mesh-1.13.2.dist-info}/METADATA +29 -8
- {solace_agent_mesh-1.7.1.dist-info → solace_agent_mesh-1.13.2.dist-info}/RECORD +334 -313
- {solace_agent_mesh-1.7.1.dist-info → solace_agent_mesh-1.13.2.dist-info}/WHEEL +1 -1
- solace_agent_mesh/agent/adk/adk_llm.txt +0 -226
- solace_agent_mesh/agent/adk/adk_llm_detail.txt +0 -566
- solace_agent_mesh/agent/adk/artifacts/artifacts_llm.txt +0 -171
- solace_agent_mesh/agent/adk/models/models_llm.txt +0 -189
- solace_agent_mesh/agent/agent_llm.txt +0 -369
- solace_agent_mesh/agent/agent_llm_detail.txt +0 -1702
- solace_agent_mesh/agent/protocol/protocol_llm.txt +0 -81
- solace_agent_mesh/agent/protocol/protocol_llm_detail.txt +0 -92
- solace_agent_mesh/agent/proxies/a2a/a2a_llm.txt +0 -190
- solace_agent_mesh/agent/proxies/base/base_llm.txt +0 -148
- solace_agent_mesh/agent/proxies/proxies_llm.txt +0 -283
- solace_agent_mesh/agent/sac/sac_llm.txt +0 -189
- solace_agent_mesh/agent/sac/sac_llm_detail.txt +0 -200
- solace_agent_mesh/agent/testing/testing_llm.txt +0 -58
- solace_agent_mesh/agent/testing/testing_llm_detail.txt +0 -68
- solace_agent_mesh/agent/tools/tools_llm.txt +0 -276
- solace_agent_mesh/agent/tools/tools_llm_detail.txt +0 -275
- solace_agent_mesh/agent/utils/utils_llm.txt +0 -152
- solace_agent_mesh/agent/utils/utils_llm_detail.txt +0 -149
- solace_agent_mesh/assets/docs/assets/js/05749d90.c70b2be9.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/15ba94aa.92fea363.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/15e40e79.36003774.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/17896441.a5e82f9b.js +0 -2
- solace_agent_mesh/assets/docs/assets/js/240a0364.c39f8388.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/2e32b5e0.33f5d75b.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/3a6c6137.f5940cfa.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/3ac1795d.e4870a49.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/3ff0015d.b63ee53a.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/547e15cc.2f7790c1.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/55b7b518.f2b1d1ba.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/5c2bd65f.45b32c2b.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/64195356.c498c4d0.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/66d4869e.830d443f.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/6d84eae0.4a5fbf39.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/8024126c.fa0e7186.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/81a99df0.07034dd9.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/82fbfb93.139a1a1f.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/924ffdeb.8095e148.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/94e8668d.09ed9234.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/9bb13469.dd1c9b54.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/a94703ab.0438dbc2.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/ab9708a8.245ae0ef.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/c93cbaa0.eaff365e.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/cbe2e9ea.f902fad8.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/db5d6442.3daf1696.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/e04b235d.c9c50c7b.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/e3d9abda.d11c67a7.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/e6f9706b.045d0fa1.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/e92d0134.3bda61dd.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/f284c35a.5099c51e.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/main.f213fe0c.js +0 -2
- solace_agent_mesh/assets/docs/assets/js/runtime~main.d9606d6a.js +0 -1
- solace_agent_mesh/assets/docs/docs/documentation/deploying/kubernetes-deployment/index.html +0 -47
- solace_agent_mesh/assets/docs/lunr-index-1762283454666.json +0 -1
- solace_agent_mesh/assets/docs/search-doc-1762283454666.json +0 -1
- solace_agent_mesh/cli/commands/add_cmd/add_cmd_llm.txt +0 -250
- solace_agent_mesh/cli/commands/init_cmd/init_cmd_llm.txt +0 -365
- solace_agent_mesh/cli/commands/plugin_cmd/plugin_cmd_llm.txt +0 -305
- solace_agent_mesh/client/webui/frontend/static/assets/client-CRYdKo2Q.js +0 -25
- solace_agent_mesh/client/webui/frontend/static/assets/main-CojeY_1w.css +0 -1
- solace_agent_mesh/client/webui/frontend/static/assets/main-ILja9MCG.js +0 -353
- solace_agent_mesh/common/a2a/a2a_llm.txt +0 -175
- solace_agent_mesh/common/a2a/a2a_llm_detail.txt +0 -193
- solace_agent_mesh/common/a2a_spec/a2a_spec_llm.txt +0 -445
- solace_agent_mesh/common/a2a_spec/a2a_spec_llm_detail.txt +0 -736
- solace_agent_mesh/common/a2a_spec/schemas/schemas_llm.txt +0 -330
- solace_agent_mesh/common/common_llm.txt +0 -230
- solace_agent_mesh/common/common_llm_detail.txt +0 -2562
- solace_agent_mesh/common/middleware/middleware_llm.txt +0 -174
- solace_agent_mesh/common/middleware/middleware_llm_detail.txt +0 -185
- solace_agent_mesh/common/sac/sac_llm.txt +0 -71
- solace_agent_mesh/common/sac/sac_llm_detail.txt +0 -82
- solace_agent_mesh/common/sam_events/sam_events_llm.txt +0 -104
- solace_agent_mesh/common/sam_events/sam_events_llm_detail.txt +0 -115
- solace_agent_mesh/common/services/providers/providers_llm.txt +0 -81
- solace_agent_mesh/common/services/services_llm.txt +0 -368
- solace_agent_mesh/common/services/services_llm_detail.txt +0 -459
- solace_agent_mesh/common/utils/embeds/embeds_llm.txt +0 -220
- solace_agent_mesh/common/utils/utils_llm.txt +0 -335
- solace_agent_mesh/common/utils/utils_llm_detail.txt +0 -572
- solace_agent_mesh/config_portal/frontend/static/client/assets/_index-ByU1X1HD.js +0 -98
- solace_agent_mesh/config_portal/frontend/static/client/assets/manifest-61038fc6.js +0 -1
- solace_agent_mesh/config_portal/frontend/static/client/assets/root-BWvk5-gF.js +0 -10
- solace_agent_mesh/config_portal/frontend/static/client/assets/root-DxRwaWiE.css +0 -1
- solace_agent_mesh/core_a2a/core_a2a_llm.txt +0 -90
- solace_agent_mesh/core_a2a/core_a2a_llm_detail.txt +0 -101
- solace_agent_mesh/gateway/base/base_llm.txt +0 -226
- solace_agent_mesh/gateway/base/base_llm_detail.txt +0 -235
- solace_agent_mesh/gateway/gateway_llm.txt +0 -369
- solace_agent_mesh/gateway/gateway_llm_detail.txt +0 -3885
- solace_agent_mesh/gateway/http_sse/alembic/alembic_llm.txt +0 -345
- solace_agent_mesh/gateway/http_sse/alembic/versions/20251023_add_fulltext_search_indexes.py +0 -92
- solace_agent_mesh/gateway/http_sse/alembic/versions/versions_llm.txt +0 -161
- solace_agent_mesh/gateway/http_sse/components/components_llm.txt +0 -105
- solace_agent_mesh/gateway/http_sse/http_sse_llm.txt +0 -299
- solace_agent_mesh/gateway/http_sse/http_sse_llm_detail.txt +0 -3278
- solace_agent_mesh/gateway/http_sse/repository/entities/entities_llm.txt +0 -221
- solace_agent_mesh/gateway/http_sse/repository/models/models_llm.txt +0 -257
- solace_agent_mesh/gateway/http_sse/repository/repository_llm.txt +0 -308
- solace_agent_mesh/gateway/http_sse/routers/dto/dto_llm.txt +0 -450
- solace_agent_mesh/gateway/http_sse/routers/dto/requests/requests_llm.txt +0 -133
- solace_agent_mesh/gateway/http_sse/routers/dto/responses/responses_llm.txt +0 -123
- solace_agent_mesh/gateway/http_sse/routers/routers_llm.txt +0 -312
- solace_agent_mesh/gateway/http_sse/services/services_llm.txt +0 -303
- solace_agent_mesh/gateway/http_sse/shared/__init__.py +0 -146
- solace_agent_mesh/gateway/http_sse/shared/shared_llm.txt +0 -319
- solace_agent_mesh/gateway/http_sse/utils/utils_llm.txt +0 -47
- solace_agent_mesh/llm.txt +0 -228
- solace_agent_mesh/llm_detail.txt +0 -2835
- solace_agent_mesh/solace_agent_mesh_llm.txt +0 -362
- solace_agent_mesh/solace_agent_mesh_llm_detail.txt +0 -8599
- solace_agent_mesh/templates/logging_config_template.ini +0 -45
- solace_agent_mesh/templates/templates_llm.txt +0 -147
- /solace_agent_mesh/assets/docs/assets/js/{main.f213fe0c.js.LICENSE.txt → main.d634009f.js.LICENSE.txt} +0 -0
- /solace_agent_mesh/{gateway/http_sse/shared → shared/api}/auth_utils.py +0 -0
- /solace_agent_mesh/{gateway/http_sse/shared → shared/api}/pagination.py +0 -0
- /solace_agent_mesh/{gateway/http_sse/shared → shared/api}/response_utils.py +0 -0
- /solace_agent_mesh/{gateway/http_sse/shared → shared/exceptions}/error_dto.py +0 -0
- /solace_agent_mesh/{gateway/http_sse/shared → shared/exceptions}/exceptions.py +0 -0
- /solace_agent_mesh/{gateway/http_sse/shared → shared/utils}/enums.py +0 -0
- /solace_agent_mesh/{gateway/http_sse/shared → shared/utils}/timestamp_utils.py +0 -0
- /solace_agent_mesh/{gateway/http_sse/shared → shared/utils}/types.py +0 -0
- /solace_agent_mesh/{gateway/http_sse/shared → shared/utils}/utils.py +0 -0
- {solace_agent_mesh-1.7.1.dist-info → solace_agent_mesh-1.13.2.dist-info}/entry_points.txt +0 -0
- {solace_agent_mesh-1.7.1.dist-info → solace_agent_mesh-1.13.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
var s_=Object.defineProperty;var Qm=e=>{throw TypeError(e)};var o_=(e,t,n)=>t in e?s_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var la=(e,t,n)=>o_(e,typeof t!="symbol"?t+"":t,n),sd=(e,t,n)=>t.has(e)||Qm("Cannot "+n);var pe=(e,t,n)=>(sd(e,t,"read from private field"),n?n.call(e):t.get(e)),Mt=(e,t,n)=>t.has(e)?Qm("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),pt=(e,t,n,r)=>(sd(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Ln=(e,t,n)=>(sd(e,t,"access private method"),n);var Ll=(e,t,n,r)=>({set _(s){pt(e,t,s,n)},get _(){return pe(e,t,r)}});import{c as a_}from"./client-DpBL2stg.js";import{r as d,R as iu,a as ti,j as o,b as i_,N as pc,S as co,c as xt,L as ur,X as Kr,E as l_,F as kc,d as bv,e as nf,f as Sr,g as Cv,h as rf,i as sf,C as Sv,k as Uo,l as ni,m as Ua,A as _v,T as mh,n as lu,M as kv,o as of,p as jv,q as Ev,s as jc,t as Nv,I as ll,u as io,v as Bo,P as Vo,w as Tv,B as c_,x as Av,y as af,G as lf,z as uo,D as Iv,H as ph,J as u_,K as Rv,O as yo,Q as ys,U as gh,V as ep,W as tp,Y as np,Z as $i,_ as Pv,$ as cu,a0 as rp,a1 as sp,a2 as d_,a3 as Mv,a4 as op,a5 as f_,a6 as h_,a7 as m_,a8 as Ec,a9 as p_,aa as g_,ab as Dv,ac as fo,ad as x_,ae as v_,af as Ho,ag as Nc,ah as uu,ai as w_,aj as cf,ak as y_,al as ap,am as b_,an as Ov,ao as C_,ap as Sn,aq as _n,ar as Lv,as as S_,at as ip,au as lp,av as od,aw as Tc,ax as __,ay as k_,az as j_,aA as E_,aB as N_,aC as T_,aD as A_,aE as I_,aF as R_,aG as P_,aH as Fv,aI as M_,aJ as zv,aK as D_,aL as $v,aM as Uv,aN as Ba,aO as Bv,aP as O_,aQ as L_,aR as Vv,aS as F_,aT as Fl,aU as z_}from"./vendor-CGk8Suyh.js";/**
|
|
2
|
+
* react-router v7.12.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/var Hv=e=>{throw TypeError(e)},$_=(e,t,n)=>t.has(e)||Hv("Cannot "+n),ad=(e,t,n)=>($_(e,t,"read from private field"),n?n.call(e):t.get(e)),U_=(e,t,n)=>t.has(e)?Hv("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),cp="popstate";function B_(e={}){function t(s,a){let{pathname:i="/",search:l="",hash:c=""}=Ls(s.location.hash.substring(1));return!i.startsWith("/")&&!i.startsWith(".")&&(i="/"+i),Ui("",{pathname:i,search:l,hash:c},a.state&&a.state.usr||null,a.state&&a.state.key||"default")}function n(s,a){let i=s.document.querySelector("base"),l="";if(i&&i.getAttribute("href")){let c=s.location.href,u=c.indexOf("#");l=u===-1?c:c.slice(0,u)}return l+"#"+(typeof a=="string"?a:xs(a))}function r(s,a){sn(s.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(a)})`)}return H_(t,n,r,e)}function Et(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function sn(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function V_(){return Math.random().toString(36).substring(2,10)}function up(e,t){return{usr:e.state,key:e.key,idx:t}}function Ui(e,t,n=null,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Ls(t):t,state:n,key:t&&t.key||r||V_()}}function xs({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function Ls(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function H_(e,t,n,r={}){let{window:s=document.defaultView,v5Compat:a=!1}=r,i=s.history,l="POP",c=null,u=h();u==null&&(u=0,i.replaceState({...i.state,idx:u},""));function h(){return(i.state||{idx:null}).idx}function f(){l="POP";let x=h(),w=x==null?null:x-u;u=x,c&&c({action:l,location:g.location,delta:w})}function p(x,w){l="PUSH";let y=Ui(g.location,x,w);n&&n(y,x),u=h()+1;let C=up(y,u),S=g.createHref(y);try{i.pushState(C,"",S)}catch(j){if(j instanceof DOMException&&j.name==="DataCloneError")throw j;s.location.assign(S)}a&&c&&c({action:l,location:g.location,delta:1})}function m(x,w){l="REPLACE";let y=Ui(g.location,x,w);n&&n(y,x),u=h();let C=up(y,u),S=g.createHref(y);i.replaceState(C,"",S),a&&c&&c({action:l,location:g.location,delta:0})}function v(x){return Wv(x)}let g={get action(){return l},get location(){return e(s,i)},listen(x){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(cp,f),c=x,()=>{s.removeEventListener(cp,f),c=null}},createHref(x){return t(s,x)},createURL:v,encodeLocation(x){let w=v(x);return{pathname:w.pathname,search:w.search,hash:w.hash}},push:p,replace:m,go(x){return i.go(x)}};return g}function Wv(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Et(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:xs(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}var ji,dp=class{constructor(e){if(U_(this,ji,new Map),e)for(let[t,n]of e)this.set(t,n)}get(e){if(ad(this,ji).has(e))return ad(this,ji).get(e);if(e.defaultValue!==void 0)return e.defaultValue;throw new Error("No value found for context")}set(e,t){ad(this,ji).set(e,t)}};ji=new WeakMap;var W_=new Set(["lazy","caseSensitive","path","id","index","children"]);function Z_(e){return W_.has(e)}var G_=new Set(["lazy","caseSensitive","path","id","index","middleware","children"]);function q_(e){return G_.has(e)}function Y_(e){return e.index===!0}function Bi(e,t,n=[],r={},s=!1){return e.map((a,i)=>{let l=[...n,String(i)],c=typeof a.id=="string"?a.id:l.join("-");if(Et(a.index!==!0||!a.children,"Cannot specify children on an index route"),Et(s||!r[c],`Found a route id collision on id "${c}". Route id's must be globally unique within Data Router usages`),Y_(a)){let u={...a,id:c};return r[c]=fp(u,t(u)),u}else{let u={...a,id:c,children:void 0};return r[c]=fp(u,t(u)),a.children&&(u.children=Bi(a.children,t,l,r,s)),u}})}function fp(e,t){return Object.assign(e,{...t,...typeof t.lazy=="object"&&t.lazy!=null?{lazy:{...e.lazy,...t.lazy}}:{}})}function Ys(e,t,n="/"){return Ei(e,t,n,!1)}function Ei(e,t,n,r){let s=typeof t=="string"?Ls(t):t,a=sr(s.pathname||"/",n);if(a==null)return null;let i=Zv(e);X_(i);let l=null;for(let c=0;l==null&&c<i.length;++c){let u=lk(a);l=ak(i[c],u,r)}return l}function K_(e,t){let{route:n,pathname:r,params:s}=e;return{id:n.id,pathname:r,params:s,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function Zv(e,t=[],n=[],r="",s=!1){let a=(i,l,c=s,u)=>{let h={relativePath:u===void 0?i.path||"":u,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};if(h.relativePath.startsWith("/")){if(!h.relativePath.startsWith(r)&&c)return;Et(h.relativePath.startsWith(r),`Absolute route path "${h.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),h.relativePath=h.relativePath.slice(r.length)}let f=ms([r,h.relativePath]),p=n.concat(h);i.children&&i.children.length>0&&(Et(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),Zv(i.children,t,p,f,c)),!(i.path==null&&!i.index)&&t.push({path:f,score:sk(f,i.index),routesMeta:p})};return e.forEach((i,l)=>{var c;if(i.path===""||!((c=i.path)!=null&&c.includes("?")))a(i,l);else for(let u of Gv(i.path))a(i,l,!0,u)}),t}function Gv(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return s?[a,""]:[a];let i=Gv(r.join("/")),l=[];return l.push(...i.map(c=>c===""?a:[a,c].join("/"))),s&&l.push(...i),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function X_(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:ok(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var J_=/^:[\w-]+$/,Q_=3,ek=2,tk=1,nk=10,rk=-2,hp=e=>e==="*";function sk(e,t){let n=e.split("/"),r=n.length;return n.some(hp)&&(r+=rk),t&&(r+=ek),n.filter(s=>!hp(s)).reduce((s,a)=>s+(J_.test(a)?Q_:a===""?tk:nk),r)}function ok(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function ak(e,t,n=!1){let{routesMeta:r}=e,s={},a="/",i=[];for(let l=0;l<r.length;++l){let c=r[l],u=l===r.length-1,h=a==="/"?t:t.slice(a.length)||"/",f=Ac({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},h),p=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=Ac({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},h)),!f)return null;Object.assign(s,f.params),i.push({params:s,pathname:ms([a,f.pathname]),pathnameBase:dk(ms([a,f.pathnameBase])),route:p}),f.pathnameBase!=="/"&&(a=ms([a,f.pathnameBase]))}return i}function Ac(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=ik(e.path,e.caseSensitive,e.end),s=t.match(n);if(!s)return null;let a=s[0],i=a.replace(/(.)\/+$/,"$1"),l=s.slice(1);return{params:r.reduce((u,{paramName:h,isOptional:f},p)=>{if(h==="*"){let v=l[p]||"";i=a.slice(0,a.length-v.length).replace(/(.)\/+$/,"$1")}const m=l[p];return f&&!m?u[h]=void 0:u[h]=(m||"").replace(/%2F/g,"/"),u},{}),pathname:a,pathnameBase:i,pattern:e}}function ik(e,t=!1,n=!0){sn(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,l,c)=>(r.push({paramName:l,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function lk(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return sn(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function sr(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}function ck({basename:e,pathname:t}){return t==="/"?e:ms([e,t])}var qv=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,du=e=>qv.test(e);function uk(e,t="/"){let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?Ls(e):e,a;if(n)if(du(n))a=n;else{if(n.includes("//")){let i=n;n=n.replace(/\/\/+/g,"/"),sn(!1,`Pathnames cannot have embedded double slashes - normalizing ${i} -> ${n}`)}n.startsWith("/")?a=mp(n.substring(1),"/"):a=mp(n,t)}else a=t;return{pathname:a,search:fk(r),hash:hk(s)}}function mp(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function id(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Yv(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function fu(e){let t=Yv(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function hu(e,t,n,r=!1){let s;typeof e=="string"?s=Ls(e):(s={...e},Et(!s.pathname||!s.pathname.includes("?"),id("?","pathname","search",s)),Et(!s.pathname||!s.pathname.includes("#"),id("#","pathname","hash",s)),Et(!s.search||!s.search.includes("#"),id("#","search","hash",s)));let a=e===""||s.pathname==="",i=a?"/":s.pathname,l;if(i==null)l=n;else{let f=t.length-1;if(!r&&i.startsWith("..")){let p=i.split("/");for(;p[0]==="..";)p.shift(),f-=1;s.pathname=p.join("/")}l=f>=0?t[f]:"/"}let c=uk(s,l),u=i&&i!=="/"&&i.endsWith("/"),h=(a||i===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||h)&&(c.pathname+="/"),c}var ms=e=>e.join("/").replace(/\/\/+/g,"/"),dk=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),fk=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,hk=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,cl=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Vi(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function ul(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Kv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Xv(e,t){let n=e;if(typeof n!="string"||!qv.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,s=!1;if(Kv)try{let a=new URL(window.location.href),i=n.startsWith("//")?new URL(a.protocol+n):new URL(n),l=sr(i.pathname,t);i.origin===a.origin&&l!=null?n=l+i.search+i.hash:s=!0}catch{sn(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:s,to:n}}var ao=Symbol("Uninstrumented");function mk(e,t){let n={lazy:[],"lazy.loader":[],"lazy.action":[],"lazy.middleware":[],middleware:[],loader:[],action:[]};e.forEach(s=>s({id:t.id,index:t.index,path:t.path,instrument(a){let i=Object.keys(n);for(let l of i)a[l]&&n[l].push(a[l])}}));let r={};if(typeof t.lazy=="function"&&n.lazy.length>0){let s=ba(n.lazy,t.lazy,()=>{});s&&(r.lazy=s)}if(typeof t.lazy=="object"){let s=t.lazy;["middleware","loader","action"].forEach(a=>{let i=s[a],l=n[`lazy.${a}`];if(typeof i=="function"&&l.length>0){let c=ba(l,i,()=>{});c&&(r.lazy=Object.assign(r.lazy||{},{[a]:c}))}})}return["loader","action"].forEach(s=>{let a=t[s];if(typeof a=="function"&&n[s].length>0){let i=a[ao]??a,l=ba(n[s],i,(...c)=>pp(c[0]));l&&(s==="loader"&&i.hydrate===!0&&(l.hydrate=!0),l[ao]=i,r[s]=l)}}),t.middleware&&t.middleware.length>0&&n.middleware.length>0&&(r.middleware=t.middleware.map(s=>{let a=s[ao]??s,i=ba(n.middleware,a,(...l)=>pp(l[0]));return i?(i[ao]=a,i):s})),r}function pk(e,t){let n={navigate:[],fetch:[]};if(t.forEach(r=>r({instrument(s){let a=Object.keys(s);for(let i of a)s[i]&&n[i].push(s[i])}})),n.navigate.length>0){let r=e.navigate[ao]??e.navigate,s=ba(n.navigate,r,(...a)=>{let[i,l]=a;return{to:typeof i=="number"||typeof i=="string"?i:i?xs(i):".",...gp(e,l??{})}});s&&(s[ao]=r,e.navigate=s)}if(n.fetch.length>0){let r=e.fetch[ao]??e.fetch,s=ba(n.fetch,r,(...a)=>{let[i,,l,c]=a;return{href:l??".",fetcherKey:i,...gp(e,c??{})}});s&&(s[ao]=r,e.fetch=s)}return e}function ba(e,t,n){return e.length===0?null:async(...r)=>{let s=await Jv(e,n(...r),()=>t(...r),e.length-1);if(s.type==="error")throw s.value;return s.value}}async function Jv(e,t,n,r){let s=e[r],a;if(s){let i,l=async()=>(i?console.error("You cannot call instrumented handlers more than once"):i=Jv(e,t,n,r-1),a=await i,Et(a,"Expected a result"),a.type==="error"&&a.value instanceof Error?{status:"error",error:a.value}:{status:"success",error:void 0});try{await s(l,t)}catch(c){console.error("An instrumentation function threw an error:",c)}i||await l(),await i}else try{a={type:"success",value:await n()}}catch(i){a={type:"error",value:i}}return a||{type:"error",value:new Error("No result assigned in instrumentation chain.")}}function pp(e){let{request:t,context:n,params:r,unstable_pattern:s}=e;return{request:gk(t),params:{...r},unstable_pattern:s,context:xk(n)}}function gp(e,t){return{currentUrl:xs(e.state.location),..."formMethod"in t?{formMethod:t.formMethod}:{},..."formEncType"in t?{formEncType:t.formEncType}:{},..."formData"in t?{formData:t.formData}:{},..."body"in t?{body:t.body}:{}}}function gk(e){return{method:e.method,url:e.url,headers:{get:(...t)=>e.headers.get(...t)}}}function xk(e){if(wk(e)){let t={...e};return Object.freeze(t),t}else return{get:t=>e.get(t)}}var vk=Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function wk(e){if(e===null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getOwnPropertyNames(t).sort().join("\0")===vk}var Qv=["POST","PUT","PATCH","DELETE"],yk=new Set(Qv),bk=["GET",...Qv],Ck=new Set(bk),ew=new Set([301,302,303,307,308]),Sk=new Set([307,308]),ld={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},_k={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},ga={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},kk=e=>({hasErrorBoundary:!!e.hasErrorBoundary}),tw="remix-router-transitions",nw=Symbol("ResetLoaderData");function jk(e){const t=e.window?e.window:typeof window<"u"?window:void 0,n=typeof t<"u"&&typeof t.document<"u"&&typeof t.document.createElement<"u";Et(e.routes.length>0,"You must provide a non-empty routes array to createRouter");let r=e.hydrationRouteProperties||[],s=e.mapRouteProperties||kk,a=s;if(e.unstable_instrumentations){let te=e.unstable_instrumentations;a=re=>({...s(re),...mk(te.map(ue=>ue.route).filter(Boolean),re)})}let i={},l=Bi(e.routes,a,void 0,i),c,u=e.basename||"/";u.startsWith("/")||(u=`/${u}`);let h=e.dataStrategy||Ik,f={...e.future},p=null,m=new Set,v=null,g=null,x=null,w=e.hydrationData!=null,y=Ys(l,e.history.location,u),C=!1,S=null,j;if(y==null&&!e.patchRoutesOnNavigation){let te=Cr(404,{pathname:e.history.location.pathname}),{matches:re,route:ue}=zl(l);j=!0,y=re,S={[ue.id]:te}}else if(y&&!e.hydrationData&&ln(y,l,e.history.location.pathname).active&&(y=null),y)if(y.some(te=>te.route.lazy))j=!1;else if(!y.some(te=>xh(te.route)))j=!0;else{let te=e.hydrationData?e.hydrationData.loaderData:null,re=e.hydrationData?e.hydrationData.errors:null;if(re){let ue=y.findIndex(Ce=>re[Ce.route.id]!==void 0);j=y.slice(0,ue+1).every(Ce=>!df(Ce.route,te,re))}else j=y.every(ue=>!df(ue.route,te,re))}else{j=!1,y=[];let te=ln(null,l,e.history.location.pathname);te.active&&te.matches&&(C=!0,y=te.matches)}let I,b={historyAction:e.history.action,location:e.history.location,matches:y,initialized:j,navigation:ld,restoreScrollPosition:e.hydrationData!=null?!1:null,preventScrollReset:!1,revalidation:"idle",loaderData:e.hydrationData&&e.hydrationData.loaderData||{},actionData:e.hydrationData&&e.hydrationData.actionData||null,errors:e.hydrationData&&e.hydrationData.errors||S,fetchers:new Map,blockers:new Map},k="POP",N=null,A=!1,P,E=!1,R=new Map,_=null,M=!1,L=!1,F=new Set,D=new Map,O=0,K=-1,$=new Map,W=new Set,V=new Map,X=new Map,H=new Set,Q=new Map,z,Z=null;function J(){if(p=e.history.listen(({action:te,location:re,delta:ue})=>{if(z){z(),z=void 0;return}sn(Q.size===0||ue!=null,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let Ce=ft({currentLocation:b.location,nextLocation:re,historyAction:te});if(Ce&&ue!=null){let je=new Promise(Be=>{z=Be});e.history.go(ue*-1),Fe(Ce,{state:"blocked",location:re,proceed(){Fe(Ce,{state:"proceeding",proceed:void 0,reset:void 0,location:re}),je.then(()=>e.history.go(ue))},reset(){let Be=new Map(b.blockers);Be.set(Ce,ga),fe({blockers:Be})}}),N==null||N.resolve(),N=null;return}return ie(te,re)}),n){Yk(t,R);let te=()=>Kk(t,R);t.addEventListener("pagehide",te),_=()=>t.removeEventListener("pagehide",te)}return b.initialized||ie("POP",b.location,{initialHydration:!0}),I}function ce(){p&&p(),_&&_(),m.clear(),P&&P.abort(),b.fetchers.forEach((te,re)=>Ot(re)),b.blockers.forEach((te,re)=>Me(re))}function de(te){return m.add(te),()=>m.delete(te)}function fe(te,re={}){te.matches&&(te.matches=te.matches.map(je=>{let Be=i[je.route.id],qe=je.route;return qe.element!==Be.element||qe.errorElement!==Be.errorElement||qe.hydrateFallbackElement!==Be.hydrateFallbackElement?{...je,route:Be}:je})),b={...b,...te};let ue=[],Ce=[];b.fetchers.forEach((je,Be)=>{je.state==="idle"&&(H.has(Be)?ue.push(Be):Ce.push(Be))}),H.forEach(je=>{!b.fetchers.has(je)&&!D.has(je)&&ue.push(je)}),[...m].forEach(je=>je(b,{deletedFetchers:ue,newErrors:te.errors??null,viewTransitionOpts:re.viewTransitionOpts,flushSync:re.flushSync===!0})),ue.forEach(je=>Ot(je)),Ce.forEach(je=>b.fetchers.delete(je))}function ge(te,re,{flushSync:ue}={}){var Le,_e;let Ce=b.actionData!=null&&b.navigation.formMethod!=null&&Fn(b.navigation.formMethod)&&b.navigation.state==="loading"&&((Le=te.state)==null?void 0:Le._isRedirect)!==!0,je;re.actionData?Object.keys(re.actionData).length>0?je=re.actionData:je=null:Ce?je=b.actionData:je=null;let Be=re.loaderData?jp(b.loaderData,re.loaderData,re.matches||[],re.errors):b.loaderData,qe=b.blockers;qe.size>0&&(qe=new Map(qe),qe.forEach((et,be)=>qe.set(be,ga)));let Te=M?!1:Lt(te,re.matches||b.matches),Se=A===!0||b.navigation.formMethod!=null&&Fn(b.navigation.formMethod)&&((_e=te.state)==null?void 0:_e._isRedirect)!==!0;c&&(l=c,c=void 0),M||k==="POP"||(k==="PUSH"?e.history.push(te,te.state):k==="REPLACE"&&e.history.replace(te,te.state));let Ee;if(k==="POP"){let et=R.get(b.location.pathname);et&&et.has(te.pathname)?Ee={currentLocation:b.location,nextLocation:te}:R.has(te.pathname)&&(Ee={currentLocation:te,nextLocation:b.location})}else if(E){let et=R.get(b.location.pathname);et?et.add(te.pathname):(et=new Set([te.pathname]),R.set(b.location.pathname,et)),Ee={currentLocation:b.location,nextLocation:te}}fe({...re,actionData:je,loaderData:Be,historyAction:k,location:te,initialized:!0,navigation:ld,revalidation:"idle",restoreScrollPosition:Te,preventScrollReset:Se,blockers:qe},{viewTransitionOpts:Ee,flushSync:ue===!0}),k="POP",A=!1,E=!1,M=!1,L=!1,N==null||N.resolve(),N=null,Z==null||Z.resolve(),Z=null}async function T(te,re){if(N==null||N.resolve(),N=null,typeof te=="number"){N||(N=Ap());let be=N.promise;return e.history.go(te),be}let ue=uf(b.location,b.matches,u,te,re==null?void 0:re.fromRouteId,re==null?void 0:re.relative),{path:Ce,submission:je,error:Be}=xp(!1,ue,re),qe=b.location,Te=Ui(b.location,Ce,re&&re.state);Te={...Te,...e.history.encodeLocation(Te)};let Se=re&&re.replace!=null?re.replace:void 0,Ee="PUSH";Se===!0?Ee="REPLACE":Se===!1||je!=null&&Fn(je.formMethod)&&je.formAction===b.location.pathname+b.location.search&&(Ee="REPLACE");let Le=re&&"preventScrollReset"in re?re.preventScrollReset===!0:void 0,_e=(re&&re.flushSync)===!0,et=ft({currentLocation:qe,nextLocation:Te,historyAction:Ee});if(et){Fe(et,{state:"blocked",location:Te,proceed(){Fe(et,{state:"proceeding",proceed:void 0,reset:void 0,location:Te}),T(te,re)},reset(){let be=new Map(b.blockers);be.set(et,ga),fe({blockers:be})}});return}await ie(Ee,Te,{submission:je,pendingError:Be,preventScrollReset:Le,replace:re&&re.replace,enableViewTransition:re&&re.viewTransition,flushSync:_e,callSiteDefaultShouldRevalidate:re&&re.unstable_defaultShouldRevalidate})}function le(){Z||(Z=Ap()),Pe(),fe({revalidation:"loading"});let te=Z.promise;return b.navigation.state==="submitting"?te:b.navigation.state==="idle"?(ie(b.historyAction,b.location,{startUninterruptedRevalidation:!0}),te):(ie(k||b.historyAction,b.navigation.location,{overrideNavigation:b.navigation,enableViewTransition:E===!0}),te)}async function ie(te,re,ue){P&&P.abort(),P=null,k=te,M=(ue&&ue.startUninterruptedRevalidation)===!0,St(b.location,b.matches),A=(ue&&ue.preventScrollReset)===!0,E=(ue&&ue.enableViewTransition)===!0;let Ce=c||l,je=ue&&ue.overrideNavigation,Be=ue!=null&&ue.initialHydration&&b.matches&&b.matches.length>0&&!C?b.matches:Ys(Ce,re,u),qe=(ue&&ue.flushSync)===!0;if(Be&&b.initialized&&!L&&zk(b.location,re)&&!(ue&&ue.submission&&Fn(ue.submission.formMethod))){ge(re,{matches:Be},{flushSync:qe});return}let Te=ln(Be,Ce,re.pathname);if(Te.active&&Te.matches&&(Be=Te.matches),!Be){let{error:he,notFoundMatches:we,route:Ve}=He(re.pathname);ge(re,{matches:we,loaderData:{},errors:{[Ve.id]:he}},{flushSync:qe});return}P=new AbortController;let Se=xa(e.history,re,P.signal,ue&&ue.submission),Ee=e.getContext?await e.getContext():new dp,Le;if(ue&&ue.pendingError)Le=[Ks(Be).route.id,{type:"error",error:ue.pendingError}];else if(ue&&ue.submission&&Fn(ue.submission.formMethod)){let he=await q(Se,re,ue.submission,Be,Ee,Te.active,ue&&ue.initialHydration===!0,{replace:ue.replace,flushSync:qe});if(he.shortCircuited)return;if(he.pendingActionResult){let[we,Ve]=he.pendingActionResult;if(ir(Ve)&&Vi(Ve.error)&&Ve.error.status===404){P=null,ge(re,{matches:he.matches,loaderData:{},errors:{[we]:Ve.error}});return}}Be=he.matches||Be,Le=he.pendingActionResult,je=cd(re,ue.submission),qe=!1,Te.active=!1,Se=xa(e.history,Se.url,Se.signal)}let{shortCircuited:_e,matches:et,loaderData:be,errors:ne}=await B(Se,re,Be,Ee,Te.active,je,ue&&ue.submission,ue&&ue.fetcherSubmission,ue&&ue.replace,ue&&ue.initialHydration===!0,qe,Le,ue&&ue.callSiteDefaultShouldRevalidate);_e||(P=null,ge(re,{matches:et||Be,...Ep(Le),loaderData:be,errors:ne}))}async function q(te,re,ue,Ce,je,Be,qe,Te={}){Pe();let Se=Gk(re,ue);if(fe({navigation:Se},{flushSync:Te.flushSync===!0}),Be){let _e=await nn(Ce,re.pathname,te.signal);if(_e.type==="aborted")return{shortCircuited:!0};if(_e.type==="error"){if(_e.partialMatches.length===0){let{matches:be,route:ne}=zl(l);return{matches:be,pendingActionResult:[ne.id,{type:"error",error:_e.error}]}}let et=Ks(_e.partialMatches).route.id;return{matches:_e.partialMatches,pendingActionResult:[et,{type:"error",error:_e.error}]}}else if(_e.matches)Ce=_e.matches;else{let{notFoundMatches:et,error:be,route:ne}=He(re.pathname);return{matches:et,pendingActionResult:[ne.id,{type:"error",error:be}]}}}let Ee,Le=gc(Ce,re);if(!Le.route.action&&!Le.route.lazy)Ee={type:"error",error:Cr(405,{method:te.method,pathname:re.pathname,routeId:Le.route.id})};else{let _e=ja(a,i,te,Ce,Le,qe?[]:r,je),et=await se(te,_e,je,null);if(Ee=et[Le.route.id],!Ee){for(let be of Ce)if(et[be.route.id]){Ee=et[be.route.id];break}}if(te.signal.aborted)return{shortCircuited:!0}}if(Io(Ee)){let _e;return Te&&Te.replace!=null?_e=Te.replace:_e=Sp(Ee.response.headers.get("Location"),new URL(te.url),u,e.history)===b.location.pathname+b.location.search,await oe(te,Ee,!0,{submission:ue,replace:_e}),{shortCircuited:!0}}if(ir(Ee)){let _e=Ks(Ce,Le.route.id);return(Te&&Te.replace)!==!0&&(k="PUSH"),{matches:Ce,pendingActionResult:[_e.route.id,Ee,Le.route.id]}}return{matches:Ce,pendingActionResult:[Le.route.id,Ee]}}async function B(te,re,ue,Ce,je,Be,qe,Te,Se,Ee,Le,_e,et){let be=Be||cd(re,qe),ne=qe||Te||Tp(be),he=!M&&!Ee;if(je){if(he){let kt=ee(_e);fe({navigation:be,...kt!==void 0?{actionData:kt}:{}},{flushSync:Le})}let Tt=await nn(ue,re.pathname,te.signal);if(Tt.type==="aborted")return{shortCircuited:!0};if(Tt.type==="error"){if(Tt.partialMatches.length===0){let{matches:In,route:Vn}=zl(l);return{matches:In,loaderData:{},errors:{[Vn.id]:Tt.error}}}let kt=Ks(Tt.partialMatches).route.id;return{matches:Tt.partialMatches,loaderData:{},errors:{[kt]:Tt.error}}}else if(Tt.matches)ue=Tt.matches;else{let{error:kt,notFoundMatches:In,route:Vn}=He(re.pathname);return{matches:In,loaderData:{},errors:{[Vn.id]:kt}}}}let we=c||l,{dsMatches:Ve,revalidatingFetchers:De}=vp(te,Ce,a,i,e.history,b,ue,ne,re,Ee?[]:r,Ee===!0,L,F,H,V,W,we,u,e.patchRoutesOnNavigation!=null,_e,et);if(K=++O,!e.dataStrategy&&!Ve.some(Tt=>Tt.shouldLoad)&&!Ve.some(Tt=>Tt.route.middleware&&Tt.route.middleware.length>0)&&De.length===0){let Tt=Wt();return ge(re,{matches:ue,loaderData:{},errors:_e&&ir(_e[1])?{[_e[0]]:_e[1].error}:null,...Ep(_e),...Tt?{fetchers:new Map(b.fetchers)}:{}},{flushSync:Le}),{shortCircuited:!0}}if(he){let Tt={};if(!je){Tt.navigation=be;let kt=ee(_e);kt!==void 0&&(Tt.actionData=kt)}De.length>0&&(Tt.fetchers=U(De)),fe(Tt,{flushSync:Le})}De.forEach(Tt=>{Nt(Tt.key),Tt.controller&&D.set(Tt.key,Tt.controller)});let ot=()=>De.forEach(Tt=>Nt(Tt.key));P&&P.signal.addEventListener("abort",ot);let{loaderResults:_t,fetcherResults:mt}=await me(Ve,De,te,Ce);if(te.signal.aborted)return{shortCircuited:!0};P&&P.signal.removeEventListener("abort",ot),De.forEach(Tt=>D.delete(Tt.key));let vt=$l(_t);if(vt)return await oe(te,vt.result,!0,{replace:Se}),{shortCircuited:!0};if(vt=$l(mt),vt)return W.add(vt.key),await oe(te,vt.result,!0,{replace:Se}),{shortCircuited:!0};let{loaderData:En,errors:Bt}=kp(b,ue,_t,_e,De,mt);Ee&&b.errors&&(Bt={...b.errors,...Bt});let Bn=Wt(),gr=xe(K),Vs=Bn||gr||De.length>0;return{matches:ue,loaderData:En,errors:Bt,...Vs?{fetchers:new Map(b.fetchers)}:{}}}function ee(te){if(te&&!ir(te[1]))return{[te[0]]:te[1].data};if(b.actionData)return Object.keys(b.actionData).length===0?null:b.actionData}function U(te){return te.forEach(re=>{let ue=b.fetchers.get(re.key),Ce=mi(void 0,ue?ue.data:void 0);b.fetchers.set(re.key,Ce)}),new Map(b.fetchers)}async function Y(te,re,ue,Ce){Nt(te);let je=(Ce&&Ce.flushSync)===!0,Be=c||l,qe=uf(b.location,b.matches,u,ue,re,Ce==null?void 0:Ce.relative),Te=Ys(Be,qe,u),Se=ln(Te,Be,qe);if(Se.active&&Se.matches&&(Te=Se.matches),!Te){dt(te,re,Cr(404,{pathname:qe}),{flushSync:je});return}let{path:Ee,submission:Le,error:_e}=xp(!0,qe,Ce);if(_e){dt(te,re,_e,{flushSync:je});return}let et=e.getContext?await e.getContext():new dp,be=(Ce&&Ce.preventScrollReset)===!0;if(Le&&Fn(Le.formMethod)){await G(te,re,Ee,Te,et,Se.active,je,be,Le,Ce&&Ce.unstable_defaultShouldRevalidate);return}V.set(te,{routeId:re,path:Ee}),await ae(te,re,Ee,Te,et,Se.active,je,be,Le)}async function G(te,re,ue,Ce,je,Be,qe,Te,Se,Ee){Pe(),V.delete(te);let Le=b.fetchers.get(te);Ne(te,qk(Se,Le),{flushSync:qe});let _e=new AbortController,et=xa(e.history,ue,_e.signal,Se);if(Be){let Dt=await nn(Ce,new URL(et.url).pathname,et.signal,te);if(Dt.type==="aborted")return;if(Dt.type==="error"){dt(te,re,Dt.error,{flushSync:qe});return}else if(Dt.matches)Ce=Dt.matches;else{dt(te,re,Cr(404,{pathname:ue}),{flushSync:qe});return}}let be=gc(Ce,ue);if(!be.route.action&&!be.route.lazy){let Dt=Cr(405,{method:Se.formMethod,pathname:ue,routeId:re});dt(te,re,Dt,{flushSync:qe});return}D.set(te,_e);let ne=O,he=ja(a,i,et,Ce,be,r,je),we=await se(et,he,je,te),Ve=we[be.route.id];if(!Ve){for(let Dt of he)if(we[Dt.route.id]){Ve=we[Dt.route.id];break}}if(et.signal.aborted){D.get(te)===_e&&D.delete(te);return}if(H.has(te)){if(Io(Ve)||ir(Ve)){Ne(te,js(void 0));return}}else{if(Io(Ve))if(D.delete(te),K>ne){Ne(te,js(void 0));return}else return W.add(te),Ne(te,mi(Se)),oe(et,Ve,!1,{fetcherSubmission:Se,preventScrollReset:Te});if(ir(Ve)){dt(te,re,Ve.error);return}}let De=b.navigation.location||b.location,ot=xa(e.history,De,_e.signal),_t=c||l,mt=b.navigation.state!=="idle"?Ys(_t,b.navigation.location,u):b.matches;Et(mt,"Didn't find any matches after fetcher action");let vt=++O;$.set(te,vt);let En=mi(Se,Ve.data);b.fetchers.set(te,En);let{dsMatches:Bt,revalidatingFetchers:Bn}=vp(ot,je,a,i,e.history,b,mt,Se,De,r,!1,L,F,H,V,W,_t,u,e.patchRoutesOnNavigation!=null,[be.route.id,Ve],Ee);Bn.filter(Dt=>Dt.key!==te).forEach(Dt=>{let Hs=Dt.key,Ss=b.fetchers.get(Hs),Mr=mi(void 0,Ss?Ss.data:void 0);b.fetchers.set(Hs,Mr),Nt(Hs),Dt.controller&&D.set(Hs,Dt.controller)}),fe({fetchers:new Map(b.fetchers)});let gr=()=>Bn.forEach(Dt=>Nt(Dt.key));_e.signal.addEventListener("abort",gr);let{loaderResults:Vs,fetcherResults:Tt}=await me(Bt,Bn,ot,je);if(_e.signal.aborted)return;if(_e.signal.removeEventListener("abort",gr),$.delete(te),D.delete(te),Bn.forEach(Dt=>D.delete(Dt.key)),b.fetchers.has(te)){let Dt=js(Ve.data);b.fetchers.set(te,Dt)}let kt=$l(Vs);if(kt)return oe(ot,kt.result,!1,{preventScrollReset:Te});if(kt=$l(Tt),kt)return W.add(kt.key),oe(ot,kt.result,!1,{preventScrollReset:Te});let{loaderData:In,errors:Vn}=kp(b,mt,Vs,void 0,Bn,Tt);xe(vt),b.navigation.state==="loading"&&vt>K?(Et(k,"Expected pending action"),P&&P.abort(),ge(b.navigation.location,{matches:mt,loaderData:In,errors:Vn,fetchers:new Map(b.fetchers)})):(fe({errors:Vn,loaderData:jp(b.loaderData,In,mt,Vn),fetchers:new Map(b.fetchers)}),L=!1)}async function ae(te,re,ue,Ce,je,Be,qe,Te,Se){let Ee=b.fetchers.get(te);Ne(te,mi(Se,Ee?Ee.data:void 0),{flushSync:qe});let Le=new AbortController,_e=xa(e.history,ue,Le.signal);if(Be){let Ve=await nn(Ce,new URL(_e.url).pathname,_e.signal,te);if(Ve.type==="aborted")return;if(Ve.type==="error"){dt(te,re,Ve.error,{flushSync:qe});return}else if(Ve.matches)Ce=Ve.matches;else{dt(te,re,Cr(404,{pathname:ue}),{flushSync:qe});return}}let et=gc(Ce,ue);D.set(te,Le);let be=O,ne=ja(a,i,_e,Ce,et,r,je),we=(await se(_e,ne,je,te))[et.route.id];if(D.get(te)===Le&&D.delete(te),!_e.signal.aborted){if(H.has(te)){Ne(te,js(void 0));return}if(Io(we))if(K>be){Ne(te,js(void 0));return}else{W.add(te),await oe(_e,we,!1,{preventScrollReset:Te});return}if(ir(we)){dt(te,re,we.error);return}Ne(te,js(we.data))}}async function oe(te,re,ue,{submission:Ce,fetcherSubmission:je,preventScrollReset:Be,replace:qe}={}){ue||(N==null||N.resolve(),N=null),re.response.headers.has("X-Remix-Revalidate")&&(L=!0);let Te=re.response.headers.get("Location");Et(Te,"Expected a Location header on the redirect Response"),Te=Sp(Te,new URL(te.url),u,e.history);let Se=Ui(b.location,Te,{_isRedirect:!0});if(n){let ne=!1;if(re.response.headers.has("X-Remix-Reload-Document"))ne=!0;else if(du(Te)){const he=Wv(Te,!0);ne=he.origin!==t.location.origin||sr(he.pathname,u)==null}if(ne){qe?t.location.replace(Te):t.location.assign(Te);return}}P=null;let Ee=qe===!0||re.response.headers.has("X-Remix-Replace")?"REPLACE":"PUSH",{formMethod:Le,formAction:_e,formEncType:et}=b.navigation;!Ce&&!je&&Le&&_e&&et&&(Ce=Tp(b.navigation));let be=Ce||je;if(Sk.has(re.response.status)&&be&&Fn(be.formMethod))await ie(Ee,Se,{submission:{...be,formAction:Te},preventScrollReset:Be||A,enableViewTransition:ue?E:void 0});else{let ne=cd(Se,Ce);await ie(Ee,Se,{overrideNavigation:ne,fetcherSubmission:je,preventScrollReset:Be||A,enableViewTransition:ue?E:void 0})}}async function se(te,re,ue,Ce){var qe;let je,Be={};try{je=await Pk(h,te,re,Ce,ue,!1)}catch(Te){return re.filter(Se=>Se.shouldLoad).forEach(Se=>{Be[Se.route.id]={type:"error",error:Te}}),Be}if(te.signal.aborted)return Be;if(!Fn(te.method))for(let Te of re){if(((qe=je[Te.route.id])==null?void 0:qe.type)==="error")break;!je.hasOwnProperty(Te.route.id)&&!b.loaderData.hasOwnProperty(Te.route.id)&&(!b.errors||!b.errors.hasOwnProperty(Te.route.id))&&Te.shouldCallHandler()&&(je[Te.route.id]={type:"error",result:new Error(`No result returned from dataStrategy for route ${Te.route.id}`)})}for(let[Te,Se]of Object.entries(je))if(Vk(Se)){let Ee=Se.result;Be[Te]={type:"redirect",response:Lk(Ee,te,Te,re,u)}}else Be[Te]=await Ok(Se);return Be}async function me(te,re,ue,Ce){let je=se(ue,te,Ce,null),Be=Promise.all(re.map(async Se=>{if(Se.matches&&Se.match&&Se.request&&Se.controller){let Le=(await se(Se.request,Se.matches,Ce,Se.key))[Se.match.route.id];return{[Se.key]:Le}}else return Promise.resolve({[Se.key]:{type:"error",error:Cr(404,{pathname:Se.path})}})})),qe=await je,Te=(await Be).reduce((Se,Ee)=>Object.assign(Se,Ee),{});return{loaderResults:qe,fetcherResults:Te}}function Pe(){L=!0,V.forEach((te,re)=>{D.has(re)&&F.add(re),Nt(re)})}function Ne(te,re,ue={}){b.fetchers.set(te,re),fe({fetchers:new Map(b.fetchers)},{flushSync:(ue&&ue.flushSync)===!0})}function dt(te,re,ue,Ce={}){let je=Ks(b.matches,re);Ot(te),fe({errors:{[je.route.id]:ue},fetchers:new Map(b.fetchers)},{flushSync:(Ce&&Ce.flushSync)===!0})}function Ht(te){return X.set(te,(X.get(te)||0)+1),H.has(te)&&H.delete(te),b.fetchers.get(te)||_k}function wt(te,re){Nt(te,re==null?void 0:re.reason),Ne(te,js(null))}function Ot(te){let re=b.fetchers.get(te);D.has(te)&&!(re&&re.state==="loading"&&$.has(te))&&Nt(te),V.delete(te),$.delete(te),W.delete(te),H.delete(te),F.delete(te),b.fetchers.delete(te)}function gt(te){let re=(X.get(te)||0)-1;re<=0?(X.delete(te),H.add(te)):X.set(te,re),fe({fetchers:new Map(b.fetchers)})}function Nt(te,re){let ue=D.get(te);ue&&(ue.abort(re),D.delete(te))}function Jt(te){for(let re of te){let ue=Ht(re),Ce=js(ue.data);b.fetchers.set(re,Ce)}}function Wt(){let te=[],re=!1;for(let ue of W){let Ce=b.fetchers.get(ue);Et(Ce,`Expected fetcher: ${ue}`),Ce.state==="loading"&&(W.delete(ue),te.push(ue),re=!0)}return Jt(te),re}function xe(te){let re=[];for(let[ue,Ce]of $)if(Ce<te){let je=b.fetchers.get(ue);Et(je,`Expected fetcher: ${ue}`),je.state==="loading"&&(Nt(ue),$.delete(ue),re.push(ue))}return Jt(re),re.length>0}function $e(te,re){let ue=b.blockers.get(te)||ga;return Q.get(te)!==re&&Q.set(te,re),ue}function Me(te){b.blockers.delete(te),Q.delete(te)}function Fe(te,re){let ue=b.blockers.get(te)||ga;Et(ue.state==="unblocked"&&re.state==="blocked"||ue.state==="blocked"&&re.state==="blocked"||ue.state==="blocked"&&re.state==="proceeding"||ue.state==="blocked"&&re.state==="unblocked"||ue.state==="proceeding"&&re.state==="unblocked",`Invalid blocker state transition: ${ue.state} -> ${re.state}`);let Ce=new Map(b.blockers);Ce.set(te,re),fe({blockers:Ce})}function ft({currentLocation:te,nextLocation:re,historyAction:ue}){if(Q.size===0)return;Q.size>1&&sn(!1,"A router only supports one blocker at a time");let Ce=Array.from(Q.entries()),[je,Be]=Ce[Ce.length-1],qe=b.blockers.get(je);if(!(qe&&qe.state==="proceeding")&&Be({currentLocation:te,nextLocation:re,historyAction:ue}))return je}function He(te){let re=Cr(404,{pathname:te}),ue=c||l,{matches:Ce,route:je}=zl(ue);return{notFoundMatches:Ce,route:je,error:re}}function Ut(te,re,ue){if(v=te,x=re,g=ue||null,!w&&b.navigation===ld){w=!0;let Ce=Lt(b.location,b.matches);Ce!=null&&fe({restoreScrollPosition:Ce})}return()=>{v=null,x=null,g=null}}function Qe(te,re){return g&&g(te,re.map(Ce=>K_(Ce,b.loaderData)))||te.key}function St(te,re){if(v&&x){let ue=Qe(te,re);v[ue]=x()}}function Lt(te,re){if(v){let ue=Qe(te,re),Ce=v[ue];if(typeof Ce=="number")return Ce}return null}function ln(te,re,ue){if(e.patchRoutesOnNavigation)if(te){if(Object.keys(te[0].params).length>0)return{active:!0,matches:Ei(re,ue,u,!0)}}else return{active:!0,matches:Ei(re,ue,u,!0)||[]};return{active:!1,matches:null}}async function nn(te,re,ue,Ce){if(!e.patchRoutesOnNavigation)return{type:"success",matches:te};let je=te;for(;;){let Be=c==null,qe=c||l,Te=i;try{await e.patchRoutesOnNavigation({signal:ue,path:re,matches:je,fetcherKey:Ce,patch:(Le,_e)=>{ue.aborted||wp(Le,_e,qe,Te,a,!1)}})}catch(Le){return{type:"error",error:Le,partialMatches:je}}finally{Be&&!ue.aborted&&(l=[...l])}if(ue.aborted)return{type:"aborted"};let Se=Ys(qe,re,u),Ee=null;if(Se){if(Object.keys(Se[0].params).length===0)return{type:"success",matches:Se};if(Ee=Ei(qe,re,u,!0),!(Ee&&je.length<Ee.length&&On(je,Ee.slice(0,je.length))))return{type:"success",matches:Se}}if(Ee||(Ee=Ei(qe,re,u,!0)),!Ee||On(je,Ee))return{type:"success",matches:null};je=Ee}}function On(te,re){return te.length===re.length&&te.every((ue,Ce)=>ue.route.id===re[Ce].route.id)}function Un(te){i={},c=Bi(te,a,void 0,i)}function Yt(te,re,ue=!1){let Ce=c==null;wp(te,re,c||l,i,a,ue),Ce&&(l=[...l],fe({}))}return I={get basename(){return u},get future(){return f},get state(){return b},get routes(){return l},get window(){return t},initialize:J,subscribe:de,enableScrollRestoration:Ut,navigate:T,fetch:Y,revalidate:le,createHref:te=>e.history.createHref(te),encodeLocation:te=>e.history.encodeLocation(te),getFetcher:Ht,resetFetcher:wt,deleteFetcher:gt,dispose:ce,getBlocker:$e,deleteBlocker:Me,patchRoutes:Yt,_internalFetchControllers:D,_internalSetRoutes:Un,_internalSetStateDoNotUseOrYouWillBreakYourApp(te){fe(te)}},e.unstable_instrumentations&&(I=pk(I,e.unstable_instrumentations.map(te=>te.router).filter(Boolean))),I}function Ek(e){return e!=null&&("formData"in e&&e.formData!=null||"body"in e&&e.body!==void 0)}function uf(e,t,n,r,s,a){let i,l;if(s){i=[];for(let u of t)if(i.push(u),u.route.id===s){l=u;break}}else i=t,l=t[t.length-1];let c=hu(r||".",fu(i),sr(e.pathname,n)||e.pathname,a==="path");if(r==null&&(c.search=e.search,c.hash=e.hash),(r==null||r===""||r===".")&&l){let u=wh(c.search);if(l.route.index&&!u)c.search=c.search?c.search.replace(/^\?/,"?index&"):"?index";else if(!l.route.index&&u){let h=new URLSearchParams(c.search),f=h.getAll("index");h.delete("index"),f.filter(m=>m).forEach(m=>h.append("index",m));let p=h.toString();c.search=p?`?${p}`:""}}return n!=="/"&&(c.pathname=ck({basename:n,pathname:c.pathname})),xs(c)}function xp(e,t,n){if(!n||!Ek(n))return{path:t};if(n.formMethod&&!Zk(n.formMethod))return{path:t,error:Cr(405,{method:n.formMethod})};let r=()=>({path:t,error:Cr(400,{type:"invalid-body"})}),a=(n.formMethod||"get").toUpperCase(),i=lw(t);if(n.body!==void 0){if(n.formEncType==="text/plain"){if(!Fn(a))return r();let f=typeof n.body=="string"?n.body:n.body instanceof FormData||n.body instanceof URLSearchParams?Array.from(n.body.entries()).reduce((p,[m,v])=>`${p}${m}=${v}
|
|
11
|
+
`,""):String(n.body);return{path:t,submission:{formMethod:a,formAction:i,formEncType:n.formEncType,formData:void 0,json:void 0,text:f}}}else if(n.formEncType==="application/json"){if(!Fn(a))return r();try{let f=typeof n.body=="string"?JSON.parse(n.body):n.body;return{path:t,submission:{formMethod:a,formAction:i,formEncType:n.formEncType,formData:void 0,json:f,text:void 0}}}catch{return r()}}}Et(typeof FormData=="function","FormData is not available in this environment");let l,c;if(n.formData)l=hf(n.formData),c=n.formData;else if(n.body instanceof FormData)l=hf(n.body),c=n.body;else if(n.body instanceof URLSearchParams)l=n.body,c=_p(l);else if(n.body==null)l=new URLSearchParams,c=new FormData;else try{l=new URLSearchParams(n.body),c=_p(l)}catch{return r()}let u={formMethod:a,formAction:i,formEncType:n&&n.formEncType||"application/x-www-form-urlencoded",formData:c,json:void 0,text:void 0};if(Fn(u.formMethod))return{path:t,submission:u};let h=Ls(t);return e&&h.search&&wh(h.search)&&l.append("index",""),h.search=`?${l}`,{path:xs(h),submission:u}}function vp(e,t,n,r,s,a,i,l,c,u,h,f,p,m,v,g,x,w,y,C,S){var M;let j=C?ir(C[1])?C[1].error:C[1].data:void 0,I=s.createURL(a.location),b=s.createURL(c),k;if(h&&a.errors){let L=Object.keys(a.errors)[0];k=i.findIndex(F=>F.route.id===L)}else if(C&&ir(C[1])){let L=C[0];k=i.findIndex(F=>F.route.id===L)-1}let N=C?C[1].statusCode:void 0,A=N&&N>=400,P={currentUrl:I,currentParams:((M=a.matches[0])==null?void 0:M.params)||{},nextUrl:b,nextParams:i[0].params,...l,actionResult:j,actionStatus:N},E=ul(i),R=i.map((L,F)=>{let{route:D}=L,O=null;if(k!=null&&F>k?O=!1:D.lazy?O=!0:xh(D)?h?O=df(D,a.loaderData,a.errors):Nk(a.loaderData,a.matches[F],L)&&(O=!0):O=!1,O!==null)return ff(n,r,e,E,L,u,t,O);let K=!1;typeof S=="boolean"?K=S:A?K=!1:(f||I.pathname+I.search===b.pathname+b.search||I.search!==b.search||Tk(a.matches[F],L))&&(K=!0);let $={...P,defaultShouldRevalidate:K},W=Mi(L,$);return ff(n,r,e,E,L,u,t,W,$,S)}),_=[];return v.forEach((L,F)=>{if(h||!i.some(H=>H.route.id===L.routeId)||m.has(F))return;let D=a.fetchers.get(F),O=D&&D.state!=="idle"&&D.data===void 0,K=Ys(x,L.path,w);if(!K){if(y&&O)return;_.push({key:F,routeId:L.routeId,path:L.path,matches:null,match:null,request:null,controller:null});return}if(g.has(F))return;let $=gc(K,L.path),W=new AbortController,V=xa(s,L.path,W.signal),X=null;if(p.has(F))p.delete(F),X=ja(n,r,V,K,$,u,t);else if(O)f&&(X=ja(n,r,V,K,$,u,t));else{let H;typeof S=="boolean"?H=S:A?H=!1:H=f;let Q={...P,defaultShouldRevalidate:H};Mi($,Q)&&(X=ja(n,r,V,K,$,u,t,Q))}X&&_.push({key:F,routeId:L.routeId,path:L.path,matches:X,match:$,request:V,controller:W})}),{dsMatches:R,revalidatingFetchers:_}}function xh(e){return e.loader!=null||e.middleware!=null&&e.middleware.length>0}function df(e,t,n){if(e.lazy)return!0;if(!xh(e))return!1;let r=t!=null&&e.id in t,s=n!=null&&n[e.id]!==void 0;return!r&&s?!1:typeof e.loader=="function"&&e.loader.hydrate===!0?!0:!r&&!s}function Nk(e,t,n){let r=!t||n.route.id!==t.route.id,s=!e.hasOwnProperty(n.route.id);return r||s}function Tk(e,t){let n=e.route.path;return e.pathname!==t.pathname||n!=null&&n.endsWith("*")&&e.params["*"]!==t.params["*"]}function Mi(e,t){if(e.route.shouldRevalidate){let n=e.route.shouldRevalidate(t);if(typeof n=="boolean")return n}return t.defaultShouldRevalidate}function wp(e,t,n,r,s,a){let i;if(e){let u=r[e];Et(u,`No route found to patch children into: routeId = ${e}`),u.children||(u.children=[]),i=u.children}else i=n;let l=[],c=[];if(t.forEach(u=>{let h=i.find(f=>rw(u,f));h?c.push({existingRoute:h,newRoute:u}):l.push(u)}),l.length>0){let u=Bi(l,s,[e||"_","patch",String((i==null?void 0:i.length)||"0")],r);i.push(...u)}if(a&&c.length>0)for(let u=0;u<c.length;u++){let{existingRoute:h,newRoute:f}=c[u],p=h,[m]=Bi([f],s,[],{},!0);Object.assign(p,{element:m.element?m.element:p.element,errorElement:m.errorElement?m.errorElement:p.errorElement,hydrateFallbackElement:m.hydrateFallbackElement?m.hydrateFallbackElement:p.hydrateFallbackElement})}}function rw(e,t){return"id"in e&&"id"in t&&e.id===t.id?!0:e.index===t.index&&e.path===t.path&&e.caseSensitive===t.caseSensitive?(!e.children||e.children.length===0)&&(!t.children||t.children.length===0)?!0:e.children.every((n,r)=>{var s;return(s=t.children)==null?void 0:s.some(a=>rw(n,a))}):!1}var yp=new WeakMap,sw=({key:e,route:t,manifest:n,mapRouteProperties:r})=>{let s=n[t.id];if(Et(s,"No route found in manifest"),!s.lazy||typeof s.lazy!="object")return;let a=s.lazy[e];if(!a)return;let i=yp.get(s);i||(i={},yp.set(s,i));let l=i[e];if(l)return l;let c=(async()=>{let u=Z_(e),f=s[e]!==void 0&&e!=="hasErrorBoundary";if(u)sn(!u,"Route property "+e+" is not a supported lazy route property. This property will be ignored."),i[e]=Promise.resolve();else if(f)sn(!1,`Route "${s.id}" has a static property "${e}" defined. The lazy property will be ignored.`);else{let p=await a();p!=null&&(Object.assign(s,{[e]:p}),Object.assign(s,r(s)))}typeof s.lazy=="object"&&(s.lazy[e]=void 0,Object.values(s.lazy).every(p=>p===void 0)&&(s.lazy=void 0))})();return i[e]=c,c},bp=new WeakMap;function Ak(e,t,n,r,s){let a=n[e.id];if(Et(a,"No route found in manifest"),!e.lazy)return{lazyRoutePromise:void 0,lazyHandlerPromise:void 0};if(typeof e.lazy=="function"){let h=bp.get(a);if(h)return{lazyRoutePromise:h,lazyHandlerPromise:h};let f=(async()=>{Et(typeof e.lazy=="function","No lazy route function found");let p=await e.lazy(),m={};for(let v in p){let g=p[v];if(g===void 0)continue;let x=q_(v),y=a[v]!==void 0&&v!=="hasErrorBoundary";x?sn(!x,"Route property "+v+" is not a supported property to be returned from a lazy route function. This property will be ignored."):y?sn(!y,`Route "${a.id}" has a static property "${v}" defined but its lazy function is also returning a value for this property. The lazy route property "${v}" will be ignored.`):m[v]=g}Object.assign(a,m),Object.assign(a,{...r(a),lazy:void 0})})();return bp.set(a,f),f.catch(()=>{}),{lazyRoutePromise:f,lazyHandlerPromise:f}}let i=Object.keys(e.lazy),l=[],c;for(let h of i){if(s&&s.includes(h))continue;let f=sw({key:h,route:e,manifest:n,mapRouteProperties:r});f&&(l.push(f),h===t&&(c=f))}let u=l.length>0?Promise.all(l).then(()=>{}):void 0;return u==null||u.catch(()=>{}),c==null||c.catch(()=>{}),{lazyRoutePromise:u,lazyHandlerPromise:c}}async function Cp(e){let t=e.matches.filter(s=>s.shouldLoad),n={};return(await Promise.all(t.map(s=>s.resolve()))).forEach((s,a)=>{n[t[a].route.id]=s}),n}async function Ik(e){return e.matches.some(t=>t.route.middleware)?ow(e,()=>Cp(e)):Cp(e)}function ow(e,t){return Rk(e,t,r=>{if(Wk(r))throw r;return r},Uk,n);function n(r,s,a){if(a)return Promise.resolve(Object.assign(a.value,{[s]:{type:"error",result:r}}));{let{matches:i}=e,l=Math.min(Math.max(i.findIndex(u=>u.route.id===s),0),Math.max(i.findIndex(u=>u.shouldCallHandler()),0)),c=Ks(i,i[l].route.id).route.id;return Promise.resolve({[c]:{type:"error",result:r}})}}}async function Rk(e,t,n,r,s){let{matches:a,request:i,params:l,context:c,unstable_pattern:u}=e,h=a.flatMap(p=>p.route.middleware?p.route.middleware.map(m=>[p.route.id,m]):[]);return await aw({request:i,params:l,context:c,unstable_pattern:u},h,t,n,r,s)}async function aw(e,t,n,r,s,a,i=0){let{request:l}=e;if(l.signal.aborted)throw l.signal.reason??new Error(`Request aborted: ${l.method} ${l.url}`);let c=t[i];if(!c)return await n();let[u,h]=c,f,p=async()=>{if(f)throw new Error("You may only call `next()` once per middleware");try{return f={value:await aw(e,t,n,r,s,a,i+1)},f.value}catch(m){return f={value:await a(m,u,f)},f.value}};try{let m=await h(e,p),v=m!=null?r(m):void 0;return s(v)?v:f?v??f.value:(f={value:await p()},f.value)}catch(m){return await a(m,u,f)}}function iw(e,t,n,r,s){let a=sw({key:"middleware",route:r.route,manifest:t,mapRouteProperties:e}),i=Ak(r.route,Fn(n.method)?"action":"loader",t,e,s);return{middleware:a,route:i.lazyRoutePromise,handler:i.lazyHandlerPromise}}function ff(e,t,n,r,s,a,i,l,c=null,u){let h=!1,f=iw(e,t,n,s,a);return{...s,_lazyPromises:f,shouldLoad:l,shouldRevalidateArgs:c,shouldCallHandler(p){return h=!0,c?typeof u=="boolean"?Mi(s,{...c,defaultShouldRevalidate:u}):typeof p=="boolean"?Mi(s,{...c,defaultShouldRevalidate:p}):Mi(s,c):l},resolve(p){let{lazy:m,loader:v,middleware:g}=s.route,x=h||l||p&&!Fn(n.method)&&(m||v),w=g&&g.length>0&&!v&&!m;return x&&(Fn(n.method)||!w)?Mk({request:n,unstable_pattern:r,match:s,lazyHandlerPromise:f==null?void 0:f.handler,lazyRoutePromise:f==null?void 0:f.route,handlerOverride:p,scopedContext:i}):Promise.resolve({type:"data",result:void 0})}}}function ja(e,t,n,r,s,a,i,l=null){return r.map(c=>c.route.id!==s.route.id?{...c,shouldLoad:!1,shouldRevalidateArgs:l,shouldCallHandler:()=>!1,_lazyPromises:iw(e,t,n,c,a),resolve:()=>Promise.resolve({type:"data",result:void 0})}:ff(e,t,n,ul(r),c,a,i,!0,l))}async function Pk(e,t,n,r,s,a){n.some(u=>{var h;return(h=u._lazyPromises)==null?void 0:h.middleware})&&await Promise.all(n.map(u=>{var h;return(h=u._lazyPromises)==null?void 0:h.middleware}));let i={request:t,unstable_pattern:ul(n),params:n[0].params,context:s,matches:n},c=await e({...i,fetcherKey:r,runClientMiddleware:u=>{let h=i;return ow(h,()=>u({...h,fetcherKey:r,runClientMiddleware:()=>{throw new Error("Cannot call `runClientMiddleware()` from within an `runClientMiddleware` handler")}}))}});try{await Promise.all(n.flatMap(u=>{var h,f;return[(h=u._lazyPromises)==null?void 0:h.handler,(f=u._lazyPromises)==null?void 0:f.route]}))}catch{}return c}async function Mk({request:e,unstable_pattern:t,match:n,lazyHandlerPromise:r,lazyRoutePromise:s,handlerOverride:a,scopedContext:i}){let l,c,u=Fn(e.method),h=u?"action":"loader",f=p=>{let m,v=new Promise((w,y)=>m=y);c=()=>m(),e.signal.addEventListener("abort",c);let g=w=>typeof p!="function"?Promise.reject(new Error(`You cannot call the handler for a route which defines a boolean "${h}" [routeId: ${n.route.id}]`)):p({request:e,unstable_pattern:t,params:n.params,context:i},...w!==void 0?[w]:[]),x=(async()=>{try{return{type:"data",result:await(a?a(y=>g(y)):g())}}catch(w){return{type:"error",result:w}}})();return Promise.race([x,v])};try{let p=u?n.route.action:n.route.loader;if(r||s)if(p){let m,[v]=await Promise.all([f(p).catch(g=>{m=g}),r,s]);if(m!==void 0)throw m;l=v}else{await r;let m=u?n.route.action:n.route.loader;if(m)[l]=await Promise.all([f(m),s]);else if(h==="action"){let v=new URL(e.url),g=v.pathname+v.search;throw Cr(405,{method:e.method,pathname:g,routeId:n.route.id})}else return{type:"data",result:void 0}}else if(p)l=await f(p);else{let m=new URL(e.url),v=m.pathname+m.search;throw Cr(404,{pathname:v})}}catch(p){return{type:"error",result:p}}finally{c&&e.signal.removeEventListener("abort",c)}return l}async function Dk(e){let t=e.headers.get("Content-Type");return t&&/\bapplication\/json\b/.test(t)?e.body==null?null:e.json():e.text()}async function Ok(e){var r,s,a,i,l;let{result:t,type:n}=e;if(vh(t)){let c;try{c=await Dk(t)}catch(u){return{type:"error",error:u}}return n==="error"?{type:"error",error:new cl(t.status,t.statusText,c),statusCode:t.status,headers:t.headers}:{type:"data",data:c,statusCode:t.status,headers:t.headers}}return n==="error"?Np(t)?t.data instanceof Error?{type:"error",error:t.data,statusCode:(r=t.init)==null?void 0:r.status,headers:(s=t.init)!=null&&s.headers?new Headers(t.init.headers):void 0}:{type:"error",error:$k(t),statusCode:Vi(t)?t.status:void 0,headers:(a=t.init)!=null&&a.headers?new Headers(t.init.headers):void 0}:{type:"error",error:t,statusCode:Vi(t)?t.status:void 0}:Np(t)?{type:"data",data:t.data,statusCode:(i=t.init)==null?void 0:i.status,headers:(l=t.init)!=null&&l.headers?new Headers(t.init.headers):void 0}:{type:"data",data:t}}function Lk(e,t,n,r,s){let a=e.headers.get("Location");if(Et(a,"Redirects returned/thrown from loaders/actions must have a Location header"),!du(a)){let i=r.slice(0,r.findIndex(l=>l.route.id===n)+1);a=uf(new URL(t.url),i,s,a),e.headers.set("Location",a)}return e}function Sp(e,t,n,r){let s=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];if(du(e)){let a=e,i=a.startsWith("//")?new URL(t.protocol+a):new URL(a);if(s.includes(i.protocol))throw new Error("Invalid redirect location");let l=sr(i.pathname,n)!=null;if(i.origin===t.origin&&l)return i.pathname+i.search+i.hash}try{let a=r.createURL(e);if(s.includes(a.protocol))throw new Error("Invalid redirect location")}catch{}return e}function xa(e,t,n,r){let s=e.createURL(lw(t)).toString(),a={signal:n};if(r&&Fn(r.formMethod)){let{formMethod:i,formEncType:l}=r;a.method=i.toUpperCase(),l==="application/json"?(a.headers=new Headers({"Content-Type":l}),a.body=JSON.stringify(r.json)):l==="text/plain"?a.body=r.text:l==="application/x-www-form-urlencoded"&&r.formData?a.body=hf(r.formData):a.body=r.formData}return new Request(s,a)}function hf(e){let t=new URLSearchParams;for(let[n,r]of e.entries())t.append(n,typeof r=="string"?r:r.name);return t}function _p(e){let t=new FormData;for(let[n,r]of e.entries())t.append(n,r);return t}function Fk(e,t,n,r=!1,s=!1){let a={},i=null,l,c=!1,u={},h=n&&ir(n[1])?n[1].error:void 0;return e.forEach(f=>{if(!(f.route.id in t))return;let p=f.route.id,m=t[p];if(Et(!Io(m),"Cannot handle redirect results in processLoaderData"),ir(m)){let v=m.error;if(h!==void 0&&(v=h,h=void 0),i=i||{},s)i[p]=v;else{let g=Ks(e,p);i[g.route.id]==null&&(i[g.route.id]=v)}r||(a[p]=nw),c||(c=!0,l=Vi(m.error)?m.error.status:500),m.headers&&(u[p]=m.headers)}else a[p]=m.data,m.statusCode&&m.statusCode!==200&&!c&&(l=m.statusCode),m.headers&&(u[p]=m.headers)}),h!==void 0&&n&&(i={[n[0]]:h},n[2]&&(a[n[2]]=void 0)),{loaderData:a,errors:i,statusCode:l||200,loaderHeaders:u}}function kp(e,t,n,r,s,a){let{loaderData:i,errors:l}=Fk(t,n,r);return s.filter(c=>!c.matches||c.matches.some(u=>u.shouldLoad)).forEach(c=>{let{key:u,match:h,controller:f}=c;if(f&&f.signal.aborted)return;let p=a[u];if(Et(p,"Did not find corresponding fetcher result"),ir(p)){let m=Ks(e.matches,h==null?void 0:h.route.id);l&&l[m.route.id]||(l={...l,[m.route.id]:p.error}),e.fetchers.delete(u)}else if(Io(p))Et(!1,"Unhandled fetcher revalidation redirect");else{let m=js(p.data);e.fetchers.set(u,m)}}),{loaderData:i,errors:l}}function jp(e,t,n,r){let s=Object.entries(t).filter(([,a])=>a!==nw).reduce((a,[i,l])=>(a[i]=l,a),{});for(let a of n){let i=a.route.id;if(!t.hasOwnProperty(i)&&e.hasOwnProperty(i)&&a.route.loader&&(s[i]=e[i]),r&&r.hasOwnProperty(i))break}return s}function Ep(e){return e?ir(e[1])?{actionData:{}}:{actionData:{[e[0]]:e[1].data}}:{}}function Ks(e,t){return(t?e.slice(0,e.findIndex(r=>r.route.id===t)+1):[...e]).reverse().find(r=>r.route.hasErrorBoundary===!0)||e[0]}function zl(e){let t=e.length===1?e[0]:e.find(n=>n.index||!n.path||n.path==="/")||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:t}],route:t}}function Cr(e,{pathname:t,routeId:n,method:r,type:s,message:a}={}){let i="Unknown Server Error",l="Unknown @remix-run/router error";return e===400?(i="Bad Request",r&&t&&n?l=`You made a ${r} request to "${t}" but did not provide a \`loader\` for route "${n}", so there is no way to handle the request.`:s==="invalid-body"&&(l="Unable to encode submission body")):e===403?(i="Forbidden",l=`Route "${n}" does not match URL "${t}"`):e===404?(i="Not Found",l=`No route matches URL "${t}"`):e===405&&(i="Method Not Allowed",r&&t&&n?l=`You made a ${r.toUpperCase()} request to "${t}" but did not provide an \`action\` for route "${n}", so there is no way to handle the request.`:r&&(l=`Invalid request method "${r.toUpperCase()}"`)),new cl(e||500,i,new Error(l),!0)}function $l(e){let t=Object.entries(e);for(let n=t.length-1;n>=0;n--){let[r,s]=t[n];if(Io(s))return{key:r,result:s}}}function lw(e){let t=typeof e=="string"?Ls(e):e;return xs({...t,hash:""})}function zk(e,t){return e.pathname!==t.pathname||e.search!==t.search?!1:e.hash===""?t.hash!=="":e.hash===t.hash?!0:t.hash!==""}function $k(e){var t,n;return new cl(((t=e.init)==null?void 0:t.status)??500,((n=e.init)==null?void 0:n.statusText)??"Internal Server Error",e.data)}function Uk(e){return e!=null&&typeof e=="object"&&Object.entries(e).every(([t,n])=>typeof t=="string"&&Bk(n))}function Bk(e){return e!=null&&typeof e=="object"&&"type"in e&&"result"in e&&(e.type==="data"||e.type==="error")}function Vk(e){return vh(e.result)&&ew.has(e.result.status)}function ir(e){return e.type==="error"}function Io(e){return(e&&e.type)==="redirect"}function Np(e){return typeof e=="object"&&e!=null&&"type"in e&&"data"in e&&"init"in e&&e.type==="DataWithResponseInit"}function vh(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.headers=="object"&&typeof e.body<"u"}function Hk(e){return ew.has(e)}function Wk(e){return vh(e)&&Hk(e.status)&&e.headers.has("Location")}function Zk(e){return Ck.has(e.toUpperCase())}function Fn(e){return yk.has(e.toUpperCase())}function wh(e){return new URLSearchParams(e).getAll("index").some(t=>t==="")}function gc(e,t){let n=typeof t=="string"?Ls(t).search:t.search;if(e[e.length-1].route.index&&wh(n||""))return e[e.length-1];let r=Yv(e);return r[r.length-1]}function Tp(e){let{formMethod:t,formAction:n,formEncType:r,text:s,formData:a,json:i}=e;if(!(!t||!n||!r)){if(s!=null)return{formMethod:t,formAction:n,formEncType:r,formData:void 0,json:void 0,text:s};if(a!=null)return{formMethod:t,formAction:n,formEncType:r,formData:a,json:void 0,text:void 0};if(i!==void 0)return{formMethod:t,formAction:n,formEncType:r,formData:void 0,json:i,text:void 0}}}function cd(e,t){return t?{state:"loading",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text}:{state:"loading",location:e,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function Gk(e,t){return{state:"submitting",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text}}function mi(e,t){return e?{state:"loading",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t}:{state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:t}}function qk(e,t){return{state:"submitting",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t?t.data:void 0}}function js(e){return{state:"idle",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e}}function Yk(e,t){try{let n=e.sessionStorage.getItem(tw);if(n){let r=JSON.parse(n);for(let[s,a]of Object.entries(r||{}))a&&Array.isArray(a)&&t.set(s,new Set(a||[]))}}catch{}}function Kk(e,t){if(t.size>0){let n={};for(let[r,s]of t)n[r]=[...s];try{e.sessionStorage.setItem(tw,JSON.stringify(n))}catch(r){sn(!1,`Failed to save applied view transitions in sessionStorage (${r}).`)}}}function Ap(){let e,t,n=new Promise((r,s)=>{e=async a=>{r(a);try{await n}catch{}},t=async a=>{s(a);try{await n}catch{}}});return{promise:n,resolve:e,reject:t}}var ta=d.createContext(null);ta.displayName="DataRouter";var dl=d.createContext(null);dl.displayName="DataRouterState";var cw=d.createContext(!1);function Xk(){return d.useContext(cw)}var yh=d.createContext({isTransitioning:!1});yh.displayName="ViewTransition";var uw=d.createContext(new Map);uw.displayName="Fetchers";var Jk=d.createContext(null);Jk.displayName="Await";var mr=d.createContext(null);mr.displayName="Navigation";var mu=d.createContext(null);mu.displayName="Location";var Qr=d.createContext({outlet:null,matches:[],isDataRoute:!1});Qr.displayName="Route";var bh=d.createContext(null);bh.displayName="RouteError";var dw="REACT_ROUTER_ERROR",Qk="REDIRECT",ej="ROUTE_ERROR_RESPONSE";function tj(e){if(e.startsWith(`${dw}:${Qk}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function nj(e){if(e.startsWith(`${dw}:${ej}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new cl(t.status,t.statusText,t.data)}catch{}}function rj(e,{relative:t}={}){Et(ri(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=d.useContext(mr),{hash:s,pathname:a,search:i}=fl(e,{relative:t}),l=a;return n!=="/"&&(l=a==="/"?n:ms([n,a])),r.createHref({pathname:l,search:i,hash:s})}function ri(){return d.useContext(mu)!=null}function es(){return Et(ri(),"useLocation() may be used only in the context of a <Router> component."),d.useContext(mu).location}var fw="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function hw(e){d.useContext(mr).static||d.useLayoutEffect(e)}function bo(){let{isDataRoute:e}=d.useContext(Qr);return e?vj():sj()}function sj(){Et(ri(),"useNavigate() may be used only in the context of a <Router> component.");let e=d.useContext(ta),{basename:t,navigator:n}=d.useContext(mr),{matches:r}=d.useContext(Qr),{pathname:s}=es(),a=JSON.stringify(fu(r)),i=d.useRef(!1);return hw(()=>{i.current=!0}),d.useCallback((c,u={})=>{if(sn(i.current,fw),!i.current)return;if(typeof c=="number"){n.go(c);return}let h=hu(c,JSON.parse(a),s,u.relative==="path");e==null&&t!=="/"&&(h.pathname=h.pathname==="/"?t:ms([t,h.pathname])),(u.replace?n.replace:n.push)(h,u.state,u)},[t,n,a,s,e])}var oj=d.createContext(null);function aj(e){let t=d.useContext(Qr).outlet;return d.useMemo(()=>t&&d.createElement(oj.Provider,{value:e},t),[t,e])}function fl(e,{relative:t}={}){let{matches:n}=d.useContext(Qr),{pathname:r}=es(),s=JSON.stringify(fu(n));return d.useMemo(()=>hu(e,JSON.parse(s),r,t==="path"),[e,s,r,t])}function ij(e,t,n,r,s){Et(ri(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=d.useContext(mr),{matches:i}=d.useContext(Qr),l=i[i.length-1],c=l?l.params:{},u=l?l.pathname:"/",h=l?l.pathnameBase:"/",f=l&&l.route;{let y=f&&f.path||"";xw(u,!f||y.endsWith("*")||y.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${y}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
12
|
+
|
|
13
|
+
Please change the parent <Route path="${y}"> to <Route path="${y==="/"?"*":`${y}/*`}">.`)}let p=es(),m;m=p;let v=m.pathname||"/",g=v;if(h!=="/"){let y=h.replace(/^\//,"").split("/");g="/"+v.replace(/^\//,"").split("/").slice(y.length).join("/")}let x=Ys(e,{pathname:g});return sn(f||x!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),sn(x==null||x[x.length-1].route.element!==void 0||x[x.length-1].route.Component!==void 0||x[x.length-1].route.lazy!==void 0,`Matched leaf route at location "${m.pathname}${m.search}${m.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`),fj(x&&x.map(y=>Object.assign({},y,{params:Object.assign({},c,y.params),pathname:ms([h,a.encodeLocation?a.encodeLocation(y.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:y.pathname]),pathnameBase:y.pathnameBase==="/"?h:ms([h,a.encodeLocation?a.encodeLocation(y.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:y.pathnameBase])})),i,n,r,s)}function lj(){let e=pj(),t=Vi(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",s={padding:"0.5rem",backgroundColor:r},a={padding:"2px 4px",backgroundColor:r},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=d.createElement(d.Fragment,null,d.createElement("p",null,"💿 Hey developer 👋"),d.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",d.createElement("code",{style:a},"ErrorBoundary")," or"," ",d.createElement("code",{style:a},"errorElement")," prop on your route.")),d.createElement(d.Fragment,null,d.createElement("h2",null,"Unexpected Application Error!"),d.createElement("h3",{style:{fontStyle:"italic"}},t),n?d.createElement("pre",{style:s},n):null,i)}var cj=d.createElement(lj,null),mw=class extends d.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const n=nj(e.digest);n&&(e=n)}let t=e!==void 0?d.createElement(Qr.Provider,{value:this.props.routeContext},d.createElement(bh.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?d.createElement(uj,{error:e},t):t}};mw.contextType=cw;var ud=new WeakMap;function uj({children:e,error:t}){let{basename:n}=d.useContext(mr);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=tj(t.digest);if(r){let s=ud.get(t);if(s)throw s;let a=Xv(r.location,n);if(Kv&&!ud.get(t))if(a.isExternal||r.reloadDocument)window.location.href=a.absoluteURL||a.to;else{const i=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:r.replace}));throw ud.set(t,i),i}return d.createElement("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return e}function dj({routeContext:e,match:t,children:n}){let r=d.useContext(ta);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),d.createElement(Qr.Provider,{value:e},n)}function fj(e,t=[],n=null,r=null,s=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let a=e,i=n==null?void 0:n.errors;if(i!=null){let h=a.findIndex(f=>f.route.id&&(i==null?void 0:i[f.route.id])!==void 0);Et(h>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),a=a.slice(0,Math.min(a.length,h+1))}let l=!1,c=-1;if(n)for(let h=0;h<a.length;h++){let f=a[h];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(c=h),f.route.id){let{loaderData:p,errors:m}=n,v=f.route.loader&&!p.hasOwnProperty(f.route.id)&&(!m||m[f.route.id]===void 0);if(f.route.lazy||v){l=!0,c>=0?a=a.slice(0,c+1):a=[a[0]];break}}}let u=n&&r?(h,f)=>{var p,m;r(h,{location:n.location,params:((m=(p=n.matches)==null?void 0:p[0])==null?void 0:m.params)??{},unstable_pattern:ul(n.matches),errorInfo:f})}:void 0;return a.reduceRight((h,f,p)=>{let m,v=!1,g=null,x=null;n&&(m=i&&f.route.id?i[f.route.id]:void 0,g=f.route.errorElement||cj,l&&(c<0&&p===0?(xw("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),v=!0,x=null):c===p&&(v=!0,x=f.route.hydrateFallbackElement||null)));let w=t.concat(a.slice(0,p+1)),y=()=>{let C;return m?C=g:v?C=x:f.route.Component?C=d.createElement(f.route.Component,null):f.route.element?C=f.route.element:C=h,d.createElement(dj,{match:f,routeContext:{outlet:h,matches:w,isDataRoute:n!=null},children:C})};return n&&(f.route.ErrorBoundary||f.route.errorElement||p===0)?d.createElement(mw,{location:n.location,revalidation:n.revalidation,component:g,error:m,children:y(),routeContext:{outlet:null,matches:w,isDataRoute:!0},onError:u}):y()},null)}function Ch(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function pw(e){let t=d.useContext(ta);return Et(t,Ch(e)),t}function Sh(e){let t=d.useContext(dl);return Et(t,Ch(e)),t}function hj(e){let t=d.useContext(Qr);return Et(t,Ch(e)),t}function pu(e){let t=hj(e),n=t.matches[t.matches.length-1];return Et(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function mj(){return pu("useRouteId")}function gw(){let e=Sh("useLoaderData"),t=pu("useLoaderData");return e.loaderData[t]}function pj(){var r;let e=d.useContext(bh),t=Sh("useRouteError"),n=pu("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}var gj=0;function xj(e){let{router:t,basename:n}=pw("useBlocker"),r=Sh("useBlocker"),[s,a]=d.useState(""),i=d.useCallback(l=>{if(typeof e!="function")return!!e;if(n==="/")return e(l);let{currentLocation:c,nextLocation:u,historyAction:h}=l;return e({currentLocation:{...c,pathname:sr(c.pathname,n)||c.pathname},nextLocation:{...u,pathname:sr(u.pathname,n)||u.pathname},historyAction:h})},[n,e]);return d.useEffect(()=>{let l=String(++gj);return a(l),()=>t.deleteBlocker(l)},[t]),d.useEffect(()=>{s!==""&&t.getBlocker(s,i)},[t,s,i]),s&&r.blockers.has(s)?r.blockers.get(s):ga}function vj(){let{router:e}=pw("useNavigate"),t=pu("useNavigate"),n=d.useRef(!1);return hw(()=>{n.current=!0}),d.useCallback(async(s,a={})=>{sn(n.current,fw),n.current&&(typeof s=="number"?await e.navigate(s):await e.navigate(s,{fromRouteId:t,...a}))},[e,t])}var Ip={};function xw(e,t,n){!t&&!Ip[e]&&(Ip[e]=!0,sn(!1,n))}var Rp={};function Pp(e,t){!e&&!Rp[t]&&(Rp[t]=!0,console.warn(t))}var wj="useOptimistic",Mp=iu[wj],yj=()=>{};function bj(e){return Mp?Mp(e):[e,yj]}function Cj(e){let t={hasErrorBoundary:e.hasErrorBoundary||e.ErrorBoundary!=null||e.errorElement!=null};return e.Component&&(e.element&&sn(!1,"You should not include both `Component` and `element` on your route - `Component` will be used."),Object.assign(t,{element:d.createElement(e.Component),Component:void 0})),e.HydrateFallback&&(e.hydrateFallbackElement&&sn(!1,"You should not include both `HydrateFallback` and `hydrateFallbackElement` on your route - `HydrateFallback` will be used."),Object.assign(t,{hydrateFallbackElement:d.createElement(e.HydrateFallback),HydrateFallback:void 0})),e.ErrorBoundary&&(e.errorElement&&sn(!1,"You should not include both `ErrorBoundary` and `errorElement` on your route - `ErrorBoundary` will be used."),Object.assign(t,{errorElement:d.createElement(e.ErrorBoundary),ErrorBoundary:void 0})),t}var Sj=["HydrateFallback","hydrateFallbackElement"],_j=class{constructor(){this.status="pending",this.promise=new Promise((e,t)=>{this.resolve=n=>{this.status==="pending"&&(this.status="resolved",e(n))},this.reject=n=>{this.status==="pending"&&(this.status="rejected",t(n))}})}};function kj({router:e,flushSync:t,onError:n,unstable_useTransitions:r}){r=Xk()||r;let[a,i]=d.useState(e.state),[l,c]=bj(a),[u,h]=d.useState(),[f,p]=d.useState({isTransitioning:!1}),[m,v]=d.useState(),[g,x]=d.useState(),[w,y]=d.useState(),C=d.useRef(new Map),S=d.useCallback((k,{deletedFetchers:N,newErrors:A,flushSync:P,viewTransitionOpts:E})=>{A&&n&&Object.values(A).forEach(_=>{var M;return n(_,{location:k.location,params:((M=k.matches[0])==null?void 0:M.params)??{},unstable_pattern:ul(k.matches)})}),k.fetchers.forEach((_,M)=>{_.data!==void 0&&C.current.set(M,_.data)}),N.forEach(_=>C.current.delete(_)),Pp(P===!1||t!=null,'You provided the `flushSync` option to a router update, but you are not using the `<RouterProvider>` from `react-router/dom` so `ReactDOM.flushSync()` is unavailable. Please update your app to `import { RouterProvider } from "react-router/dom"` and ensure you have `react-dom` installed as a dependency to use the `flushSync` option.');let R=e.window!=null&&e.window.document!=null&&typeof e.window.document.startViewTransition=="function";if(Pp(E==null||R,"You provided the `viewTransition` option to a router update, but you do not appear to be running in a DOM environment as `window.startViewTransition` is not available."),!E||!R){t&&P?t(()=>i(k)):r===!1?i(k):d.startTransition(()=>{r===!0&&c(_=>Dp(_,k)),i(k)});return}if(t&&P){t(()=>{g&&(m==null||m.resolve(),g.skipTransition()),p({isTransitioning:!0,flushSync:!0,currentLocation:E.currentLocation,nextLocation:E.nextLocation})});let _=e.window.document.startViewTransition(()=>{t(()=>i(k))});_.finished.finally(()=>{t(()=>{v(void 0),x(void 0),h(void 0),p({isTransitioning:!1})})}),t(()=>x(_));return}g?(m==null||m.resolve(),g.skipTransition(),y({state:k,currentLocation:E.currentLocation,nextLocation:E.nextLocation})):(h(k),p({isTransitioning:!0,flushSync:!1,currentLocation:E.currentLocation,nextLocation:E.nextLocation}))},[e.window,t,g,m,r,c,n]);d.useLayoutEffect(()=>e.subscribe(S),[e,S]),d.useEffect(()=>{f.isTransitioning&&!f.flushSync&&v(new _j)},[f]),d.useEffect(()=>{if(m&&u&&e.window){let k=u,N=m.promise,A=e.window.document.startViewTransition(async()=>{r===!1?i(k):d.startTransition(()=>{r===!0&&c(P=>Dp(P,k)),i(k)}),await N});A.finished.finally(()=>{v(void 0),x(void 0),h(void 0),p({isTransitioning:!1})}),x(A)}},[u,m,e.window,r,c]),d.useEffect(()=>{m&&u&&l.location.key===u.location.key&&m.resolve()},[m,g,l.location,u]),d.useEffect(()=>{!f.isTransitioning&&w&&(h(w.state),p({isTransitioning:!0,flushSync:!1,currentLocation:w.currentLocation,nextLocation:w.nextLocation}),y(void 0))},[f.isTransitioning,w]);let j=d.useMemo(()=>({createHref:e.createHref,encodeLocation:e.encodeLocation,go:k=>e.navigate(k),push:(k,N,A)=>e.navigate(k,{state:N,preventScrollReset:A==null?void 0:A.preventScrollReset}),replace:(k,N,A)=>e.navigate(k,{replace:!0,state:N,preventScrollReset:A==null?void 0:A.preventScrollReset})}),[e]),I=e.basename||"/",b=d.useMemo(()=>({router:e,navigator:j,static:!1,basename:I,onError:n}),[e,j,I,n]);return d.createElement(d.Fragment,null,d.createElement(ta.Provider,{value:b},d.createElement(dl.Provider,{value:l},d.createElement(uw.Provider,{value:C.current},d.createElement(yh.Provider,{value:f},d.createElement(Tj,{basename:I,location:l.location,navigationType:l.historyAction,navigator:j,unstable_useTransitions:r},d.createElement(jj,{routes:e.routes,future:e.future,state:l,onError:n})))))),null)}function Dp(e,t){return{...e,navigation:t.navigation.state!=="idle"?t.navigation:e.navigation,revalidation:t.revalidation!=="idle"?t.revalidation:e.revalidation,actionData:t.navigation.state!=="submitting"?t.actionData:e.actionData,fetchers:t.fetchers}}var jj=d.memo(Ej);function Ej({routes:e,future:t,state:n,onError:r}){return ij(e,void 0,n,r,t)}function Op({to:e,replace:t,state:n,relative:r}){Et(ri(),"<Navigate> may be used only in the context of a <Router> component.");let{static:s}=d.useContext(mr);sn(!s,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:a}=d.useContext(Qr),{pathname:i}=es(),l=bo(),c=hu(e,fu(a),i,r==="path"),u=JSON.stringify(c);return d.useEffect(()=>{l(JSON.parse(u),{replace:t,state:n,relative:r})},[l,u,r,t,n]),null}function Nj(e){return aj(e.context)}function Tj({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:s,static:a=!1,unstable_useTransitions:i}){Et(!ri(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),c=d.useMemo(()=>({basename:l,navigator:s,static:a,unstable_useTransitions:i,future:{}}),[l,s,a,i]);typeof n=="string"&&(n=Ls(n));let{pathname:u="/",search:h="",hash:f="",state:p=null,key:m="default"}=n,v=d.useMemo(()=>{let g=sr(u,l);return g==null?null:{location:{pathname:g,search:h,hash:f,state:p,key:m},navigationType:r}},[l,u,h,f,p,m,r]);return sn(v!=null,`<Router basename="${l}"> is not able to match the URL "${u}${h}${f}" because it does not start with the basename, so the <Router> won't render anything.`),v==null?null:d.createElement(mr.Provider,{value:c},d.createElement(mu.Provider,{children:t,value:v}))}var xc="get",vc="application/x-www-form-urlencoded";function gu(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Aj(e){return gu(e)&&e.tagName.toLowerCase()==="button"}function Ij(e){return gu(e)&&e.tagName.toLowerCase()==="form"}function Rj(e){return gu(e)&&e.tagName.toLowerCase()==="input"}function Pj(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Mj(e,t){return e.button===0&&(!t||t==="_self")&&!Pj(e)}var Ul=null;function Dj(){if(Ul===null)try{new FormData(document.createElement("form"),0),Ul=!1}catch{Ul=!0}return Ul}var Oj=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function dd(e){return e!=null&&!Oj.has(e)?(sn(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${vc}"`),null):e}function Lj(e,t){let n,r,s,a,i;if(Ij(e)){let l=e.getAttribute("action");r=l?sr(l,t):null,n=e.getAttribute("method")||xc,s=dd(e.getAttribute("enctype"))||vc,a=new FormData(e)}else if(Aj(e)||Rj(e)&&(e.type==="submit"||e.type==="image")){let l=e.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=e.getAttribute("formaction")||l.getAttribute("action");if(r=c?sr(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||xc,s=dd(e.getAttribute("formenctype"))||dd(l.getAttribute("enctype"))||vc,a=new FormData(l,e),!Dj()){let{name:u,type:h,value:f}=e;if(h==="image"){let p=u?`${u}.`:"";a.append(`${p}x`,"0"),a.append(`${p}y`,"0")}else u&&a.append(u,f)}}else{if(gu(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=xc,r=null,s=vc,i=e}return a&&s==="text/plain"&&(i=a,a=void 0),{action:r,method:n.toLowerCase(),encType:s,formData:a,body:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function _h(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Fj(e,t,n,r){let s=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?s.pathname.endsWith("/")?s.pathname=`${s.pathname}_.${r}`:s.pathname=`${s.pathname}.${r}`:s.pathname==="/"?s.pathname=`_root.${r}`:t&&sr(s.pathname,t)==="/"?s.pathname=`${t.replace(/\/$/,"")}/_root.${r}`:s.pathname=`${s.pathname.replace(/\/$/,"")}.${r}`,s}async function zj(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function $j(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function Uj(e,t,n){let r=await Promise.all(e.map(async s=>{let a=t.routes[s.route.id];if(a){let i=await zj(a,n);return i.links?i.links():[]}return[]}));return Wj(r.flat(1).filter($j).filter(s=>s.rel==="stylesheet"||s.rel==="preload").map(s=>s.rel==="stylesheet"?{...s,rel:"prefetch",as:"style"}:{...s,rel:"prefetch"}))}function Lp(e,t,n,r,s,a){let i=(c,u)=>n[u]?c.route.id!==n[u].route.id:!0,l=(c,u)=>{var h;return n[u].pathname!==c.pathname||((h=n[u].route.path)==null?void 0:h.endsWith("*"))&&n[u].params["*"]!==c.params["*"]};return a==="assets"?t.filter((c,u)=>i(c,u)||l(c,u)):a==="data"?t.filter((c,u)=>{var f;let h=r.routes[c.route.id];if(!h||!h.hasLoader)return!1;if(i(c,u)||l(c,u))return!0;if(c.route.shouldRevalidate){let p=c.route.shouldRevalidate({currentUrl:new URL(s.pathname+s.search+s.hash,window.origin),currentParams:((f=n[0])==null?void 0:f.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof p=="boolean")return p}return!0}):[]}function Bj(e,t,{includeHydrateFallback:n}={}){return Vj(e.map(r=>{let s=t.routes[r.route.id];if(!s)return[];let a=[s.module];return s.clientActionModule&&(a=a.concat(s.clientActionModule)),s.clientLoaderModule&&(a=a.concat(s.clientLoaderModule)),n&&s.hydrateFallbackModule&&(a=a.concat(s.hydrateFallbackModule)),s.imports&&(a=a.concat(s.imports)),a}).flat(1))}function Vj(e){return[...new Set(e)]}function Hj(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function Wj(e,t){let n=new Set;return new Set(t),e.reduce((r,s)=>{let a=JSON.stringify(Hj(s));return n.has(a)||(n.add(a),r.push({key:a,link:s})),r},[])}function vw(){let e=d.useContext(ta);return _h(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Zj(){let e=d.useContext(dl);return _h(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var kh=d.createContext(void 0);kh.displayName="FrameworkContext";function ww(){let e=d.useContext(kh);return _h(e,"You must render this element inside a <HydratedRouter> element"),e}function Gj(e,t){let n=d.useContext(kh),[r,s]=d.useState(!1),[a,i]=d.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:h,onTouchStart:f}=t,p=d.useRef(null);d.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let g=w=>{w.forEach(y=>{i(y.isIntersecting)})},x=new IntersectionObserver(g,{threshold:.5});return p.current&&x.observe(p.current),()=>{x.disconnect()}}},[e]),d.useEffect(()=>{if(r){let g=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(g)}}},[r]);let m=()=>{s(!0)},v=()=>{s(!1),i(!1)};return n?e!=="intent"?[a,p,{}]:[a,p,{onFocus:pi(l,m),onBlur:pi(c,v),onMouseEnter:pi(u,m),onMouseLeave:pi(h,v),onTouchStart:pi(f,m)}]:[!1,p,{}]}function pi(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function qj({page:e,...t}){let{router:n}=vw(),r=d.useMemo(()=>Ys(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?d.createElement(Kj,{page:e,matches:r,...t}):null}function Yj(e){let{manifest:t,routeModules:n}=ww(),[r,s]=d.useState([]);return d.useEffect(()=>{let a=!1;return Uj(e,t,n).then(i=>{a||s(i)}),()=>{a=!0}},[e,t,n]),r}function Kj({page:e,matches:t,...n}){let r=es(),{future:s,manifest:a,routeModules:i}=ww(),{basename:l}=vw(),{loaderData:c,matches:u}=Zj(),h=d.useMemo(()=>Lp(e,t,u,a,r,"data"),[e,t,u,a,r]),f=d.useMemo(()=>Lp(e,t,u,a,r,"assets"),[e,t,u,a,r]),p=d.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let g=new Set,x=!1;if(t.forEach(y=>{var S;let C=a.routes[y.route.id];!C||!C.hasLoader||(!h.some(j=>j.route.id===y.route.id)&&y.route.id in c&&((S=i[y.route.id])!=null&&S.shouldRevalidate)||C.hasClientLoader?x=!0:g.add(y.route.id))}),g.size===0)return[];let w=Fj(e,l,s.unstable_trailingSlashAwareDataRequests,"data");return x&&g.size>0&&w.searchParams.set("_routes",t.filter(y=>g.has(y.route.id)).map(y=>y.route.id).join(",")),[w.pathname+w.search]},[l,s.unstable_trailingSlashAwareDataRequests,c,r,a,h,t,e,i]),m=d.useMemo(()=>Bj(f,a),[f,a]),v=Yj(f);return d.createElement(d.Fragment,null,p.map(g=>d.createElement("link",{key:g,rel:"prefetch",as:"fetch",href:g,...n})),m.map(g=>d.createElement("link",{key:g,rel:"modulepreload",href:g,...n})),v.map(({key:g,link:x})=>d.createElement("link",{key:g,nonce:n.nonce,...x})))}function Xj(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var Jj=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Jj&&(window.__reactRouterVersion="7.12.0")}catch{}function Qj(e,t){return jk({basename:t==null?void 0:t.basename,getContext:t==null?void 0:t.getContext,future:t==null?void 0:t.future,history:B_({window:t==null?void 0:t.window}),hydrationData:eE(),routes:e,mapRouteProperties:Cj,hydrationRouteProperties:Sj,dataStrategy:t==null?void 0:t.dataStrategy,patchRoutesOnNavigation:t==null?void 0:t.patchRoutesOnNavigation,window:t==null?void 0:t.window,unstable_instrumentations:t==null?void 0:t.unstable_instrumentations}).initialize()}function eE(){let e=window==null?void 0:window.__staticRouterHydrationData;return e&&e.errors&&(e={...e,errors:tE(e.errors)}),e}function tE(e){if(!e)return null;let t=Object.entries(e),n={};for(let[r,s]of t)if(s&&s.__type==="RouteErrorResponse")n[r]=new cl(s.status,s.statusText,s.data,s.internal===!0);else if(s&&s.__type==="Error"){if(s.__subType){let a=window[s.__subType];if(typeof a=="function")try{let i=new a(s.message);i.stack="",n[r]=i}catch{}}if(n[r]==null){let a=new Error(s.message);a.stack="",n[r]=a}}else n[r]=s;return n}var yw=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,bw=d.forwardRef(function({onClick:t,discover:n="render",prefetch:r="none",relative:s,reloadDocument:a,replace:i,state:l,target:c,to:u,preventScrollReset:h,viewTransition:f,unstable_defaultShouldRevalidate:p,...m},v){let{basename:g,unstable_useTransitions:x}=d.useContext(mr),w=typeof u=="string"&&yw.test(u),y=Xv(u,g);u=y.to;let C=rj(u,{relative:s}),[S,j,I]=Gj(r,m),b=oE(u,{replace:i,state:l,target:c,preventScrollReset:h,relative:s,viewTransition:f,unstable_defaultShouldRevalidate:p,unstable_useTransitions:x});function k(A){t&&t(A),A.defaultPrevented||b(A)}let N=d.createElement("a",{...m,...I,href:y.absoluteURL||C,onClick:y.isExternal||a?t:k,ref:Xj(v,j),target:c,"data-discover":!w&&n==="render"?"true":void 0});return S&&!w?d.createElement(d.Fragment,null,N,d.createElement(qj,{page:C})):N});bw.displayName="Link";var nE=d.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:r="",end:s=!1,style:a,to:i,viewTransition:l,children:c,...u},h){let f=fl(i,{relative:u.relative}),p=es(),m=d.useContext(dl),{navigator:v,basename:g}=d.useContext(mr),x=m!=null&&uE(f)&&l===!0,w=v.encodeLocation?v.encodeLocation(f).pathname:f.pathname,y=p.pathname,C=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;n||(y=y.toLowerCase(),C=C?C.toLowerCase():null,w=w.toLowerCase()),C&&g&&(C=sr(C,g)||C);const S=w!=="/"&&w.endsWith("/")?w.length-1:w.length;let j=y===w||!s&&y.startsWith(w)&&y.charAt(S)==="/",I=C!=null&&(C===w||!s&&C.startsWith(w)&&C.charAt(w.length)==="/"),b={isActive:j,isPending:I,isTransitioning:x},k=j?t:void 0,N;typeof r=="function"?N=r(b):N=[r,j?"active":null,I?"pending":null,x?"transitioning":null].filter(Boolean).join(" ");let A=typeof a=="function"?a(b):a;return d.createElement(bw,{...u,"aria-current":k,className:N,ref:h,style:A,to:i,viewTransition:l},typeof c=="function"?c(b):c)});nE.displayName="NavLink";var rE=d.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:s,state:a,method:i=xc,action:l,onSubmit:c,relative:u,preventScrollReset:h,viewTransition:f,unstable_defaultShouldRevalidate:p,...m},v)=>{let{unstable_useTransitions:g}=d.useContext(mr),x=lE(),w=cE(l,{relative:u}),y=i.toLowerCase()==="get"?"get":"post",C=typeof l=="string"&&yw.test(l),S=j=>{if(c&&c(j),j.defaultPrevented)return;j.preventDefault();let I=j.nativeEvent.submitter,b=(I==null?void 0:I.getAttribute("formmethod"))||i,k=()=>x(I||j.currentTarget,{fetcherKey:t,method:b,navigate:n,replace:s,state:a,relative:u,preventScrollReset:h,viewTransition:f,unstable_defaultShouldRevalidate:p});g&&n!==!1?d.startTransition(()=>k()):k()};return d.createElement("form",{ref:v,method:y,action:w,onSubmit:r?c:S,...m,"data-discover":!C&&e==="render"?"true":void 0})});rE.displayName="Form";function sE(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Cw(e){let t=d.useContext(ta);return Et(t,sE(e)),t}function oE(e,{target:t,replace:n,state:r,preventScrollReset:s,relative:a,viewTransition:i,unstable_defaultShouldRevalidate:l,unstable_useTransitions:c}={}){let u=bo(),h=es(),f=fl(e,{relative:a});return d.useCallback(p=>{if(Mj(p,t)){p.preventDefault();let m=n!==void 0?n:xs(h)===xs(f),v=()=>u(e,{replace:m,state:r,preventScrollReset:s,relative:a,viewTransition:i,unstable_defaultShouldRevalidate:l});c?d.startTransition(()=>v()):v()}},[h,u,f,n,r,t,e,s,a,i,l,c])}var aE=0,iE=()=>`__${String(++aE)}__`;function lE(){let{router:e}=Cw("useSubmit"),{basename:t}=d.useContext(mr),n=mj(),r=e.fetch,s=e.navigate;return d.useCallback(async(a,i={})=>{let{action:l,method:c,encType:u,formData:h,body:f}=Lj(a,t);if(i.navigate===!1){let p=i.fetcherKey||iE();await r(p,n,i.action||l,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:h,body:f,formMethod:i.method||c,formEncType:i.encType||u,flushSync:i.flushSync})}else await s(i.action||l,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:h,body:f,formMethod:i.method||c,formEncType:i.encType||u,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[r,s,t,n])}function cE(e,{relative:t}={}){let{basename:n}=d.useContext(mr),r=d.useContext(Qr);Et(r,"useFormAction must be used inside a RouteContext");let[s]=r.matches.slice(-1),a={...fl(e||".",{relative:t})},i=es();if(e==null){a.search=i.search;let l=new URLSearchParams(a.search),c=l.getAll("index");if(c.some(h=>h==="")){l.delete("index"),c.filter(f=>f).forEach(f=>l.append("index",f));let h=l.toString();a.search=h?`?${h}`:""}}return(!e||e===".")&&s.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:ms([n,a.pathname])),xs(a)}function uE(e,{relative:t}={}){let n=d.useContext(yh);Et(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Cw("useViewTransitionState"),s=fl(e,{relative:t});if(!n.isTransitioning)return!1;let a=sr(n.currentLocation.pathname,r)||n.currentLocation.pathname,i=sr(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Ac(s.pathname,i)!=null||Ac(s.pathname,a)!=null}function dE(e){return d.createElement(kj,{flushSync:ti.flushSync,...e})}const Sw=d.createContext(void 0),fE=({children:e})=>{const[t,n]=d.useState({selectedText:null,selectionRange:null,menuPosition:null,sourceMessageId:null,isMenuOpen:!1}),r=d.useCallback((l,c,u,h)=>{n({selectedText:l,selectionRange:c,menuPosition:h,sourceMessageId:u,isMenuOpen:!0})},[]),s=d.useCallback(()=>{n({selectedText:null,selectionRange:null,menuPosition:null,sourceMessageId:null,isMenuOpen:!1})},[]),a=d.useCallback(()=>{t.selectedText&&(window.dispatchEvent(new CustomEvent("follow-up-question",{detail:{text:t.selectedText}})),s())},[t.selectedText,s]),i={...t,setSelection:r,clearSelection:s,handleFollowUpQuestion:a};return o.jsx(Sw.Provider,{value:i,children:e})},_w=()=>{const e=d.useContext(Sw);if(!e)throw new Error("useTextSelection must be used within TextSelectionProvider");return e};function Fp(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function xu(...e){return t=>{let n=!1;const r=e.map(s=>{const a=Fp(s,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let s=0;s<r.length;s++){const a=r[s];typeof a=="function"?a():Fp(e[s],null)}}}}function yt(...e){return d.useCallback(xu(...e),e)}function ho(e){const t=hE(e),n=d.forwardRef((r,s)=>{const{children:a,...i}=r,l=d.Children.toArray(a),c=l.find(pE);if(c){const u=c.props.children,h=l.map(f=>f===c?d.Children.count(u)>1?d.Children.only(null):d.isValidElement(u)?u.props.children:null:f);return o.jsx(t,{...i,ref:s,children:d.isValidElement(u)?d.cloneElement(u,void 0,h):null})}return o.jsx(t,{...i,ref:s,children:a})});return n.displayName=`${e}.Slot`,n}var kw=ho("Slot");function hE(e){const t=d.forwardRef((n,r)=>{const{children:s,...a}=n;if(d.isValidElement(s)){const i=xE(s),l=gE(a,s.props);return s.type!==d.Fragment&&(l.ref=r?xu(r,i):i),d.cloneElement(s,l)}return d.Children.count(s)>1?d.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var jw=Symbol("radix.slottable");function mE(e){const t=({children:n})=>o.jsx(o.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=jw,t}function pE(e){return d.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===jw}function gE(e,t){const n={...t};for(const r in t){const s=e[r],a=t[r];/^on[A-Z]/.test(r)?s&&a?n[r]=(...l)=>{const c=a(...l);return s(...l),c}:s&&(n[r]=s):r==="style"?n[r]={...s,...a}:r==="className"&&(n[r]=[s,a].filter(Boolean).join(" "))}return{...e,...n}}function xE(e){var r,s;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Ew(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(n=Ew(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Nw(){for(var e,t,n=0,r="",s=arguments.length;n<s;n++)(e=arguments[n])&&(t=Ew(e))&&(r&&(r+=" "),r+=t);return r}const zp=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,$p=Nw,Co=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return $p(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:s,defaultVariants:a}=t,i=Object.keys(s).map(u=>{const h=n==null?void 0:n[u],f=a==null?void 0:a[u];if(h===null)return null;const p=zp(h)||zp(f);return s[u][p]}),l=n&&Object.entries(n).reduce((u,h)=>{let[f,p]=h;return p===void 0||(u[f]=p),u},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,h)=>{let{class:f,className:p,...m}=h;return Object.entries(m).every(v=>{let[g,x]=v;return Array.isArray(x)?x.includes({...a,...l}[g]):{...a,...l}[g]===x})?[...u,f,p]:u},[]);return $p(e,i,c,n==null?void 0:n.class,n==null?void 0:n.className)},jh=()=>localStorage.getItem("access_token"),Zt=(e,t="An unknown error occurred")=>e instanceof Error?e.message??t:t,Eh="-",vE=e=>{const t=yE(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{const l=i.split(Eh);return l[0]===""&&l.length!==1&&l.shift(),Tw(l,t)||wE(i)},getConflictingClassGroupIds:(i,l)=>{const c=n[i]||[];return l&&r[i]?[...c,...r[i]]:c}}},Tw=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),s=r?Tw(e.slice(1),r):void 0;if(s)return s;if(t.validators.length===0)return;const a=e.join(Eh);return(i=t.validators.find(({validator:l})=>l(a)))==null?void 0:i.classGroupId},Up=/^\[(.+)\]$/,wE=e=>{if(Up.test(e)){const t=Up.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},yE=e=>{const{theme:t,classGroups:n}=e,r={nextPart:new Map,validators:[]};for(const s in n)mf(n[s],r,s,t);return r},mf=(e,t,n,r)=>{e.forEach(s=>{if(typeof s=="string"){const a=s===""?t:Bp(t,s);a.classGroupId=n;return}if(typeof s=="function"){if(bE(s)){mf(s(r),t,n,r);return}t.validators.push({validator:s,classGroupId:n});return}Object.entries(s).forEach(([a,i])=>{mf(i,Bp(t,a),n,r)})})},Bp=(e,t)=>{let n=e;return t.split(Eh).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},bE=e=>e.isThemeGetter,CE=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const s=(a,i)=>{n.set(a,i),t++,t>e&&(t=0,r=n,n=new Map)};return{get(a){let i=n.get(a);if(i!==void 0)return i;if((i=r.get(a))!==void 0)return s(a,i),i},set(a,i){n.has(a)?n.set(a,i):s(a,i)}}},pf="!",gf=":",SE=gf.length,_E=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=s=>{const a=[];let i=0,l=0,c=0,u;for(let v=0;v<s.length;v++){let g=s[v];if(i===0&&l===0){if(g===gf){a.push(s.slice(c,v)),c=v+SE;continue}if(g==="/"){u=v;continue}}g==="["?i++:g==="]"?i--:g==="("?l++:g===")"&&l--}const h=a.length===0?s:s.substring(c),f=kE(h),p=f!==h,m=u&&u>c?u-c:void 0;return{modifiers:a,hasImportantModifier:p,baseClassName:f,maybePostfixModifierPosition:m}};if(t){const s=t+gf,a=r;r=i=>i.startsWith(s)?a(i.substring(s.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:i,maybePostfixModifierPosition:void 0}}if(n){const s=r;r=a=>n({className:a,parseClassName:s})}return r},kE=e=>e.endsWith(pf)?e.substring(0,e.length-1):e.startsWith(pf)?e.substring(1):e,jE=e=>{const t=Object.fromEntries(e.orderSensitiveModifiers.map(r=>[r,!0]));return r=>{if(r.length<=1)return r;const s=[];let a=[];return r.forEach(i=>{i[0]==="["||t[i]?(s.push(...a.sort(),i),a=[]):a.push(i)}),s.push(...a.sort()),s}},EE=e=>({cache:CE(e.cacheSize),parseClassName:_E(e),sortModifiers:jE(e),...vE(e)}),NE=/\s+/,TE=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:s,sortModifiers:a}=t,i=[],l=e.trim().split(NE);let c="";for(let u=l.length-1;u>=0;u-=1){const h=l[u],{isExternal:f,modifiers:p,hasImportantModifier:m,baseClassName:v,maybePostfixModifierPosition:g}=n(h);if(f){c=h+(c.length>0?" "+c:c);continue}let x=!!g,w=r(x?v.substring(0,g):v);if(!w){if(!x){c=h+(c.length>0?" "+c:c);continue}if(w=r(v),!w){c=h+(c.length>0?" "+c:c);continue}x=!1}const y=a(p).join(":"),C=m?y+pf:y,S=C+w;if(i.includes(S))continue;i.push(S);const j=s(w,x);for(let I=0;I<j.length;++I){const b=j[I];i.push(C+b)}c=h+(c.length>0?" "+c:c)}return c};function AE(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=Aw(t))&&(r&&(r+=" "),r+=n);return r}const Aw=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=Aw(e[r]))&&(n&&(n+=" "),n+=t);return n};function IE(e,...t){let n,r,s,a=i;function i(c){const u=t.reduce((h,f)=>f(h),e());return n=EE(u),r=n.cache.get,s=n.cache.set,a=l,l(c)}function l(c){const u=r(c);if(u)return u;const h=TE(c,n);return s(c,h),h}return function(){return a(AE.apply(null,arguments))}}const Cn=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},Iw=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Rw=/^\((?:(\w[\w-]*):)?(.+)\)$/i,RE=/^\d+\/\d+$/,PE=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ME=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,DE=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,OE=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,LE=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ca=e=>RE.test(e),jt=e=>!!e&&!Number.isNaN(Number(e)),Zs=e=>!!e&&Number.isInteger(Number(e)),fd=e=>e.endsWith("%")&&jt(e.slice(0,-1)),_s=e=>PE.test(e),FE=()=>!0,zE=e=>ME.test(e)&&!DE.test(e),Pw=()=>!1,$E=e=>OE.test(e),UE=e=>LE.test(e),BE=e=>!Ye(e)&&!Ke(e),VE=e=>si(e,Ow,Pw),Ye=e=>Iw.test(e),To=e=>si(e,Lw,zE),hd=e=>si(e,qE,jt),Vp=e=>si(e,Mw,Pw),HE=e=>si(e,Dw,UE),Bl=e=>si(e,Fw,$E),Ke=e=>Rw.test(e),gi=e=>oi(e,Lw),WE=e=>oi(e,YE),Hp=e=>oi(e,Mw),ZE=e=>oi(e,Ow),GE=e=>oi(e,Dw),Vl=e=>oi(e,Fw,!0),si=(e,t,n)=>{const r=Iw.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},oi=(e,t,n=!1)=>{const r=Rw.exec(e);return r?r[1]?t(r[1]):n:!1},Mw=e=>e==="position"||e==="percentage",Dw=e=>e==="image"||e==="url",Ow=e=>e==="length"||e==="size"||e==="bg-size",Lw=e=>e==="length",qE=e=>e==="number",YE=e=>e==="family-name",Fw=e=>e==="shadow",KE=()=>{const e=Cn("color"),t=Cn("font"),n=Cn("text"),r=Cn("font-weight"),s=Cn("tracking"),a=Cn("leading"),i=Cn("breakpoint"),l=Cn("container"),c=Cn("spacing"),u=Cn("radius"),h=Cn("shadow"),f=Cn("inset-shadow"),p=Cn("text-shadow"),m=Cn("drop-shadow"),v=Cn("blur"),g=Cn("perspective"),x=Cn("aspect"),w=Cn("ease"),y=Cn("animate"),C=()=>["auto","avoid","all","avoid-page","page","left","right","column"],S=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],j=()=>[...S(),Ke,Ye],I=()=>["auto","hidden","clip","visible","scroll"],b=()=>["auto","contain","none"],k=()=>[Ke,Ye,c],N=()=>[ca,"full","auto",...k()],A=()=>[Zs,"none","subgrid",Ke,Ye],P=()=>["auto",{span:["full",Zs,Ke,Ye]},Zs,Ke,Ye],E=()=>[Zs,"auto",Ke,Ye],R=()=>["auto","min","max","fr",Ke,Ye],_=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],M=()=>["start","end","center","stretch","center-safe","end-safe"],L=()=>["auto",...k()],F=()=>[ca,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...k()],D=()=>[e,Ke,Ye],O=()=>[...S(),Hp,Vp,{position:[Ke,Ye]}],K=()=>["no-repeat",{repeat:["","x","y","space","round"]}],$=()=>["auto","cover","contain",ZE,VE,{size:[Ke,Ye]}],W=()=>[fd,gi,To],V=()=>["","none","full",u,Ke,Ye],X=()=>["",jt,gi,To],H=()=>["solid","dashed","dotted","double"],Q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],z=()=>[jt,fd,Hp,Vp],Z=()=>["","none",v,Ke,Ye],J=()=>["none",jt,Ke,Ye],ce=()=>["none",jt,Ke,Ye],de=()=>[jt,Ke,Ye],fe=()=>[ca,"full",...k()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[_s],breakpoint:[_s],color:[FE],container:[_s],"drop-shadow":[_s],ease:["in","out","in-out"],font:[BE],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[_s],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[_s],shadow:[_s],spacing:["px",jt],text:[_s],"text-shadow":[_s],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",ca,Ye,Ke,x]}],container:["container"],columns:[{columns:[jt,Ye,Ke,l]}],"break-after":[{"break-after":C()}],"break-before":[{"break-before":C()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:j()}],overflow:[{overflow:I()}],"overflow-x":[{"overflow-x":I()}],"overflow-y":[{"overflow-y":I()}],overscroll:[{overscroll:b()}],"overscroll-x":[{"overscroll-x":b()}],"overscroll-y":[{"overscroll-y":b()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:N()}],"inset-x":[{"inset-x":N()}],"inset-y":[{"inset-y":N()}],start:[{start:N()}],end:[{end:N()}],top:[{top:N()}],right:[{right:N()}],bottom:[{bottom:N()}],left:[{left:N()}],visibility:["visible","invisible","collapse"],z:[{z:[Zs,"auto",Ke,Ye]}],basis:[{basis:[ca,"full","auto",l,...k()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[jt,ca,"auto","initial","none",Ye]}],grow:[{grow:["",jt,Ke,Ye]}],shrink:[{shrink:["",jt,Ke,Ye]}],order:[{order:[Zs,"first","last","none",Ke,Ye]}],"grid-cols":[{"grid-cols":A()}],"col-start-end":[{col:P()}],"col-start":[{"col-start":E()}],"col-end":[{"col-end":E()}],"grid-rows":[{"grid-rows":A()}],"row-start-end":[{row:P()}],"row-start":[{"row-start":E()}],"row-end":[{"row-end":E()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":R()}],"auto-rows":[{"auto-rows":R()}],gap:[{gap:k()}],"gap-x":[{"gap-x":k()}],"gap-y":[{"gap-y":k()}],"justify-content":[{justify:[..._(),"normal"]}],"justify-items":[{"justify-items":[...M(),"normal"]}],"justify-self":[{"justify-self":["auto",...M()]}],"align-content":[{content:["normal",..._()]}],"align-items":[{items:[...M(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...M(),{baseline:["","last"]}]}],"place-content":[{"place-content":_()}],"place-items":[{"place-items":[...M(),"baseline"]}],"place-self":[{"place-self":["auto",...M()]}],p:[{p:k()}],px:[{px:k()}],py:[{py:k()}],ps:[{ps:k()}],pe:[{pe:k()}],pt:[{pt:k()}],pr:[{pr:k()}],pb:[{pb:k()}],pl:[{pl:k()}],m:[{m:L()}],mx:[{mx:L()}],my:[{my:L()}],ms:[{ms:L()}],me:[{me:L()}],mt:[{mt:L()}],mr:[{mr:L()}],mb:[{mb:L()}],ml:[{ml:L()}],"space-x":[{"space-x":k()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":k()}],"space-y-reverse":["space-y-reverse"],size:[{size:F()}],w:[{w:[l,"screen",...F()]}],"min-w":[{"min-w":[l,"screen","none",...F()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...F()]}],h:[{h:["screen","lh",...F()]}],"min-h":[{"min-h":["screen","lh","none",...F()]}],"max-h":[{"max-h":["screen","lh",...F()]}],"font-size":[{text:["base",n,gi,To]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Ke,hd]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",fd,Ye]}],"font-family":[{font:[WE,Ye,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,Ke,Ye]}],"line-clamp":[{"line-clamp":[jt,"none",Ke,hd]}],leading:[{leading:[a,...k()]}],"list-image":[{"list-image":["none",Ke,Ye]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Ke,Ye]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:D()}],"text-color":[{text:D()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...H(),"wavy"]}],"text-decoration-thickness":[{decoration:[jt,"from-font","auto",Ke,To]}],"text-decoration-color":[{decoration:D()}],"underline-offset":[{"underline-offset":[jt,"auto",Ke,Ye]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:k()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ke,Ye]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Ke,Ye]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:O()}],"bg-repeat":[{bg:K()}],"bg-size":[{bg:$()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Zs,Ke,Ye],radial:["",Ke,Ye],conic:[Zs,Ke,Ye]},GE,HE]}],"bg-color":[{bg:D()}],"gradient-from-pos":[{from:W()}],"gradient-via-pos":[{via:W()}],"gradient-to-pos":[{to:W()}],"gradient-from":[{from:D()}],"gradient-via":[{via:D()}],"gradient-to":[{to:D()}],rounded:[{rounded:V()}],"rounded-s":[{"rounded-s":V()}],"rounded-e":[{"rounded-e":V()}],"rounded-t":[{"rounded-t":V()}],"rounded-r":[{"rounded-r":V()}],"rounded-b":[{"rounded-b":V()}],"rounded-l":[{"rounded-l":V()}],"rounded-ss":[{"rounded-ss":V()}],"rounded-se":[{"rounded-se":V()}],"rounded-ee":[{"rounded-ee":V()}],"rounded-es":[{"rounded-es":V()}],"rounded-tl":[{"rounded-tl":V()}],"rounded-tr":[{"rounded-tr":V()}],"rounded-br":[{"rounded-br":V()}],"rounded-bl":[{"rounded-bl":V()}],"border-w":[{border:X()}],"border-w-x":[{"border-x":X()}],"border-w-y":[{"border-y":X()}],"border-w-s":[{"border-s":X()}],"border-w-e":[{"border-e":X()}],"border-w-t":[{"border-t":X()}],"border-w-r":[{"border-r":X()}],"border-w-b":[{"border-b":X()}],"border-w-l":[{"border-l":X()}],"divide-x":[{"divide-x":X()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":X()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...H(),"hidden","none"]}],"divide-style":[{divide:[...H(),"hidden","none"]}],"border-color":[{border:D()}],"border-color-x":[{"border-x":D()}],"border-color-y":[{"border-y":D()}],"border-color-s":[{"border-s":D()}],"border-color-e":[{"border-e":D()}],"border-color-t":[{"border-t":D()}],"border-color-r":[{"border-r":D()}],"border-color-b":[{"border-b":D()}],"border-color-l":[{"border-l":D()}],"divide-color":[{divide:D()}],"outline-style":[{outline:[...H(),"none","hidden"]}],"outline-offset":[{"outline-offset":[jt,Ke,Ye]}],"outline-w":[{outline:["",jt,gi,To]}],"outline-color":[{outline:D()}],shadow:[{shadow:["","none",h,Vl,Bl]}],"shadow-color":[{shadow:D()}],"inset-shadow":[{"inset-shadow":["none",f,Vl,Bl]}],"inset-shadow-color":[{"inset-shadow":D()}],"ring-w":[{ring:X()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:D()}],"ring-offset-w":[{"ring-offset":[jt,To]}],"ring-offset-color":[{"ring-offset":D()}],"inset-ring-w":[{"inset-ring":X()}],"inset-ring-color":[{"inset-ring":D()}],"text-shadow":[{"text-shadow":["none",p,Vl,Bl]}],"text-shadow-color":[{"text-shadow":D()}],opacity:[{opacity:[jt,Ke,Ye]}],"mix-blend":[{"mix-blend":[...Q(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Q()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[jt]}],"mask-image-linear-from-pos":[{"mask-linear-from":z()}],"mask-image-linear-to-pos":[{"mask-linear-to":z()}],"mask-image-linear-from-color":[{"mask-linear-from":D()}],"mask-image-linear-to-color":[{"mask-linear-to":D()}],"mask-image-t-from-pos":[{"mask-t-from":z()}],"mask-image-t-to-pos":[{"mask-t-to":z()}],"mask-image-t-from-color":[{"mask-t-from":D()}],"mask-image-t-to-color":[{"mask-t-to":D()}],"mask-image-r-from-pos":[{"mask-r-from":z()}],"mask-image-r-to-pos":[{"mask-r-to":z()}],"mask-image-r-from-color":[{"mask-r-from":D()}],"mask-image-r-to-color":[{"mask-r-to":D()}],"mask-image-b-from-pos":[{"mask-b-from":z()}],"mask-image-b-to-pos":[{"mask-b-to":z()}],"mask-image-b-from-color":[{"mask-b-from":D()}],"mask-image-b-to-color":[{"mask-b-to":D()}],"mask-image-l-from-pos":[{"mask-l-from":z()}],"mask-image-l-to-pos":[{"mask-l-to":z()}],"mask-image-l-from-color":[{"mask-l-from":D()}],"mask-image-l-to-color":[{"mask-l-to":D()}],"mask-image-x-from-pos":[{"mask-x-from":z()}],"mask-image-x-to-pos":[{"mask-x-to":z()}],"mask-image-x-from-color":[{"mask-x-from":D()}],"mask-image-x-to-color":[{"mask-x-to":D()}],"mask-image-y-from-pos":[{"mask-y-from":z()}],"mask-image-y-to-pos":[{"mask-y-to":z()}],"mask-image-y-from-color":[{"mask-y-from":D()}],"mask-image-y-to-color":[{"mask-y-to":D()}],"mask-image-radial":[{"mask-radial":[Ke,Ye]}],"mask-image-radial-from-pos":[{"mask-radial-from":z()}],"mask-image-radial-to-pos":[{"mask-radial-to":z()}],"mask-image-radial-from-color":[{"mask-radial-from":D()}],"mask-image-radial-to-color":[{"mask-radial-to":D()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":S()}],"mask-image-conic-pos":[{"mask-conic":[jt]}],"mask-image-conic-from-pos":[{"mask-conic-from":z()}],"mask-image-conic-to-pos":[{"mask-conic-to":z()}],"mask-image-conic-from-color":[{"mask-conic-from":D()}],"mask-image-conic-to-color":[{"mask-conic-to":D()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:O()}],"mask-repeat":[{mask:K()}],"mask-size":[{mask:$()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Ke,Ye]}],filter:[{filter:["","none",Ke,Ye]}],blur:[{blur:Z()}],brightness:[{brightness:[jt,Ke,Ye]}],contrast:[{contrast:[jt,Ke,Ye]}],"drop-shadow":[{"drop-shadow":["","none",m,Vl,Bl]}],"drop-shadow-color":[{"drop-shadow":D()}],grayscale:[{grayscale:["",jt,Ke,Ye]}],"hue-rotate":[{"hue-rotate":[jt,Ke,Ye]}],invert:[{invert:["",jt,Ke,Ye]}],saturate:[{saturate:[jt,Ke,Ye]}],sepia:[{sepia:["",jt,Ke,Ye]}],"backdrop-filter":[{"backdrop-filter":["","none",Ke,Ye]}],"backdrop-blur":[{"backdrop-blur":Z()}],"backdrop-brightness":[{"backdrop-brightness":[jt,Ke,Ye]}],"backdrop-contrast":[{"backdrop-contrast":[jt,Ke,Ye]}],"backdrop-grayscale":[{"backdrop-grayscale":["",jt,Ke,Ye]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[jt,Ke,Ye]}],"backdrop-invert":[{"backdrop-invert":["",jt,Ke,Ye]}],"backdrop-opacity":[{"backdrop-opacity":[jt,Ke,Ye]}],"backdrop-saturate":[{"backdrop-saturate":[jt,Ke,Ye]}],"backdrop-sepia":[{"backdrop-sepia":["",jt,Ke,Ye]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":k()}],"border-spacing-x":[{"border-spacing-x":k()}],"border-spacing-y":[{"border-spacing-y":k()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Ke,Ye]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[jt,"initial",Ke,Ye]}],ease:[{ease:["linear","initial",w,Ke,Ye]}],delay:[{delay:[jt,Ke,Ye]}],animate:[{animate:["none",y,Ke,Ye]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[g,Ke,Ye]}],"perspective-origin":[{"perspective-origin":j()}],rotate:[{rotate:J()}],"rotate-x":[{"rotate-x":J()}],"rotate-y":[{"rotate-y":J()}],"rotate-z":[{"rotate-z":J()}],scale:[{scale:ce()}],"scale-x":[{"scale-x":ce()}],"scale-y":[{"scale-y":ce()}],"scale-z":[{"scale-z":ce()}],"scale-3d":["scale-3d"],skew:[{skew:de()}],"skew-x":[{"skew-x":de()}],"skew-y":[{"skew-y":de()}],transform:[{transform:[Ke,Ye,"","none","gpu","cpu"]}],"transform-origin":[{origin:j()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:fe()}],"translate-x":[{"translate-x":fe()}],"translate-y":[{"translate-y":fe()}],"translate-z":[{"translate-z":fe()}],"translate-none":["translate-none"],accent:[{accent:D()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:D()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Ke,Ye]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":k()}],"scroll-mx":[{"scroll-mx":k()}],"scroll-my":[{"scroll-my":k()}],"scroll-ms":[{"scroll-ms":k()}],"scroll-me":[{"scroll-me":k()}],"scroll-mt":[{"scroll-mt":k()}],"scroll-mr":[{"scroll-mr":k()}],"scroll-mb":[{"scroll-mb":k()}],"scroll-ml":[{"scroll-ml":k()}],"scroll-p":[{"scroll-p":k()}],"scroll-px":[{"scroll-px":k()}],"scroll-py":[{"scroll-py":k()}],"scroll-ps":[{"scroll-ps":k()}],"scroll-pe":[{"scroll-pe":k()}],"scroll-pt":[{"scroll-pt":k()}],"scroll-pr":[{"scroll-pr":k()}],"scroll-pb":[{"scroll-pb":k()}],"scroll-pl":[{"scroll-pl":k()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Ke,Ye]}],fill:[{fill:["none",...D()]}],"stroke-w":[{stroke:[jt,gi,To,hd]}],stroke:[{stroke:["none",...D()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},XE=IE(KE);function Ue(...e){return XE(Nw(e))}const JE=()=>localStorage.getItem("refresh_token"),QE=(e,t)=>{localStorage.setItem("access_token",e),localStorage.setItem("refresh_token",t)},e2=()=>{localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token")},t2=async()=>{const e=JE();if(!e)return null;const t=await fetch("/api/v1/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:e})});if(t.ok){const n=await t.json();return QE(n.access_token,n.refresh_token),n.access_token}return e2(),window.location.href="/api/v1/auth/login",null},n2=async e=>{const t=`Request failed: ${e.statusText||`HTTP ${e.status}`}`;try{const n=await e.text();if(!n)return t;try{const r=JSON.parse(n);return r.message||r.detail||t}catch{return n.length<500?n:t}}catch{return t}},zw=async(e,t={})=>{const n=jh();if(!n)return fetch(e,t);const r=await fetch(e,{...t,headers:{...t.headers,Authorization:`Bearer ${n}`}});if(r.status===401){const s=await t2();if(s)return fetch(e,{...t,headers:{...t.headers,Authorization:`Bearer ${s}`}})}return r},r2=async(e,t={})=>{const n=await zw(e,t);if(!n.ok)throw new Error(await n2(n));return n},s2=async(e,t={})=>{const n=await r2(e,t);if(n.status===204)return;const r=await n.text();return r?JSON.parse(r):void 0};class o2{constructor(){la(this,"webuiBaseUrl","");la(this,"platformBaseUrl","");la(this,"webui");la(this,"platform");this.webui=this.createHttpMethods(()=>this.webuiBaseUrl),this.platform=this.createHttpMethods(()=>this.platformBaseUrl)}configure(t,n){this.webuiBaseUrl=t,this.platformBaseUrl=n}async request(t,n,r){const s=`${t}${n}`,{fullResponse:a,...i}=r||{};return a?zw(s,i):s2(s,i)}buildRequestWithBody(t,n,r){return n instanceof FormData?{...r,method:t,body:n}:n==null?{...r,method:t}:{...r,method:t,headers:{"Content-Type":"application/json",...r==null?void 0:r.headers},body:JSON.stringify(n)}}createHttpMethods(t){return{get:(n,r)=>this.request(t(),n,r),post:(n,r,s)=>this.request(t(),n,this.buildRequestWithBody("POST",r,s)),put:(n,r,s)=>this.request(t(),n,this.buildRequestWithBody("PUT",r,s)),delete:(n,r)=>this.request(t(),n,{...r,method:"DELETE"}),patch:(n,r,s)=>this.request(t(),n,this.buildRequestWithBody("PATCH",r,s)),getFullUrl:n=>`${t()}${n}`}}}const Ie=new o2;var vu=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},a2={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},eo,hh,fv,i2=(fv=class{constructor(){Mt(this,eo,a2);Mt(this,hh,!1)}setTimeoutProvider(e){pt(this,eo,e)}setTimeout(e,t){return pe(this,eo).setTimeout(e,t)}clearTimeout(e){pe(this,eo).clearTimeout(e)}setInterval(e,t){return pe(this,eo).setInterval(e,t)}clearInterval(e){pe(this,eo).clearInterval(e)}},eo=new WeakMap,hh=new WeakMap,fv),xf=new i2;function l2(e){setTimeout(e,0)}var wu=typeof window>"u"||"Deno"in globalThis;function zr(){}function c2(e,t){return typeof e=="function"?e(t):e}function u2(e){return typeof e=="number"&&e>=0&&e!==1/0}function d2(e,t){return Math.max(e+(t||0)-Date.now(),0)}function vf(e,t){return typeof e=="function"?e(t):e}function f2(e,t){return typeof e=="function"?e(t):e}function Wp(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:a,queryKey:i,stale:l}=e;if(i){if(r){if(t.queryHash!==Nh(i,t.options))return!1}else if(!Wi(t.queryKey,i))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||s&&s!==t.state.fetchStatus||a&&!a(t))}function Zp(e,t){const{exact:n,status:r,predicate:s,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(Hi(t.options.mutationKey)!==Hi(a))return!1}else if(!Wi(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function Nh(e,t){return((t==null?void 0:t.queryKeyHashFn)||Hi)(e)}function Hi(e){return JSON.stringify(e,(t,n)=>wf(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function Wi(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Wi(e[n],t[n])):!1}var h2=Object.prototype.hasOwnProperty;function $w(e,t){if(e===t)return e;const n=Gp(e)&&Gp(t);if(!n&&!(wf(e)&&wf(t)))return t;const s=(n?e:Object.keys(e)).length,a=n?t:Object.keys(t),i=a.length,l=n?new Array(i):{};let c=0;for(let u=0;u<i;u++){const h=n?u:a[u],f=e[h],p=t[h];if(f===p){l[h]=f,(n?u<s:h2.call(e,h))&&c++;continue}if(f===null||p===null||typeof f!="object"||typeof p!="object"){l[h]=p;continue}const m=$w(f,p);l[h]=m,m===f&&c++}return s===i&&c===s?e:l}function Gp(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function wf(e){if(!qp(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!qp(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function qp(e){return Object.prototype.toString.call(e)==="[object Object]"}function m2(e){return new Promise(t=>{xf.setTimeout(t,e)})}function p2(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?$w(e,t):t}function g2(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function x2(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Th=Symbol();function Uw(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Th?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function v2(e,t,n){let r=!1,s;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(s??(s=t()),r||(r=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s)}),e}var Po,to,Pa,hv,w2=(hv=class extends vu{constructor(){super();Mt(this,Po);Mt(this,to);Mt(this,Pa);pt(this,Pa,t=>{if(!wu&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){pe(this,to)||this.setEventListener(pe(this,Pa))}onUnsubscribe(){var t;this.hasListeners()||((t=pe(this,to))==null||t.call(this),pt(this,to,void 0))}setEventListener(t){var n;pt(this,Pa,t),(n=pe(this,to))==null||n.call(this),pt(this,to,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){pe(this,Po)!==t&&(pt(this,Po,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof pe(this,Po)=="boolean"?pe(this,Po):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Po=new WeakMap,to=new WeakMap,Pa=new WeakMap,hv),Bw=new w2;function y2(){let e,t;const n=new Promise((s,a)=>{e=s,t=a});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}var b2=l2;function C2(){let e=[],t=0,n=l=>{l()},r=l=>{l()},s=b2;const a=l=>{t?e.push(l):s(()=>{n(l)})},i=()=>{const l=e;e=[],l.length&&s(()=>{r(()=>{l.forEach(c=>{n(c)})})})};return{batch:l=>{let c;t++;try{c=l()}finally{t--,t||i()}return c},batchCalls:l=>(...c)=>{a(()=>{l(...c)})},schedule:a,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{s=l}}}var Gn=C2(),Ma,no,Da,mv,S2=(mv=class extends vu{constructor(){super();Mt(this,Ma,!0);Mt(this,no);Mt(this,Da);pt(this,Da,t=>{if(!wu&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){pe(this,no)||this.setEventListener(pe(this,Da))}onUnsubscribe(){var t;this.hasListeners()||((t=pe(this,no))==null||t.call(this),pt(this,no,void 0))}setEventListener(t){var n;pt(this,Da,t),(n=pe(this,no))==null||n.call(this),pt(this,no,t(this.setOnline.bind(this)))}setOnline(t){pe(this,Ma)!==t&&(pt(this,Ma,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return pe(this,Ma)}},Ma=new WeakMap,no=new WeakMap,Da=new WeakMap,mv),Ic=new S2;function _2(e){return Math.min(1e3*2**e,3e4)}function Vw(e){return(e??"online")==="online"?Ic.isOnline():!0}var yf=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Hw(e){let t=!1,n=0,r;const s=y2(),a=()=>s.status!=="pending",i=g=>{var x;if(!a()){const w=new yf(g);p(w),(x=e.onCancel)==null||x.call(e,w)}},l=()=>{t=!0},c=()=>{t=!1},u=()=>Bw.isFocused()&&(e.networkMode==="always"||Ic.isOnline())&&e.canRun(),h=()=>Vw(e.networkMode)&&e.canRun(),f=g=>{a()||(r==null||r(),s.resolve(g))},p=g=>{a()||(r==null||r(),s.reject(g))},m=()=>new Promise(g=>{var x;r=w=>{(a()||u())&&g(w)},(x=e.onPause)==null||x.call(e)}).then(()=>{var g;r=void 0,a()||(g=e.onContinue)==null||g.call(e)}),v=()=>{if(a())return;let g;const x=n===0?e.initialPromise:void 0;try{g=x??e.fn()}catch(w){g=Promise.reject(w)}Promise.resolve(g).then(f).catch(w=>{var I;if(a())return;const y=e.retry??(wu?0:3),C=e.retryDelay??_2,S=typeof C=="function"?C(n,w):C,j=y===!0||typeof y=="number"&&n<y||typeof y=="function"&&y(n,w);if(t||!j){p(w);return}n++,(I=e.onFail)==null||I.call(e,n,w),m2(S).then(()=>u()?void 0:m()).then(()=>{t?p(w):v()})})};return{promise:s,status:()=>s.status,cancel:i,continue:()=>(r==null||r(),s),cancelRetry:l,continueRetry:c,canStart:h,start:()=>(h()?v():m().then(v),s)}}var Mo,pv,Ww=(pv=class{constructor(){Mt(this,Mo)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),u2(this.gcTime)&&pt(this,Mo,xf.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(wu?1/0:5*60*1e3))}clearGcTimeout(){pe(this,Mo)&&(xf.clearTimeout(pe(this,Mo)),pt(this,Mo,void 0))}},Mo=new WeakMap,pv),Do,Oa,br,Oo,Tn,ol,Lo,$r,Es,gv,k2=(gv=class extends Ww{constructor(t){super();Mt(this,$r);Mt(this,Do);Mt(this,Oa);Mt(this,br);Mt(this,Oo);Mt(this,Tn);Mt(this,ol);Mt(this,Lo);pt(this,Lo,!1),pt(this,ol,t.defaultOptions),this.setOptions(t.options),this.observers=[],pt(this,Oo,t.client),pt(this,br,pe(this,Oo).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,pt(this,Do,Kp(this.options)),this.state=t.state??pe(this,Do),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=pe(this,Tn))==null?void 0:t.promise}setOptions(t){if(this.options={...pe(this,ol),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=Kp(this.options);n.data!==void 0&&(this.setState(Yp(n.data,n.dataUpdatedAt)),pt(this,Do,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&pe(this,br).remove(this)}setData(t,n){const r=p2(this.state.data,t,this.options);return Ln(this,$r,Es).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){Ln(this,$r,Es).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,s;const n=(r=pe(this,Tn))==null?void 0:r.promise;return(s=pe(this,Tn))==null||s.cancel(t),n?n.then(zr).catch(zr):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(pe(this,Do))}isActive(){return this.observers.some(t=>f2(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Th||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>vf(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!d2(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=pe(this,Tn))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=pe(this,Tn))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),pe(this,br).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(pe(this,Tn)&&(pe(this,Lo)?pe(this,Tn).cancel({revert:!0}):pe(this,Tn).cancelRetry()),this.scheduleGc()),pe(this,br).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Ln(this,$r,Es).call(this,{type:"invalidate"})}async fetch(t,n){var c,u,h,f,p,m,v,g,x,w,y,C;if(this.state.fetchStatus!=="idle"&&((c=pe(this,Tn))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(pe(this,Tn))return pe(this,Tn).continueRetry(),pe(this,Tn).promise}if(t&&this.setOptions(t),!this.options.queryFn){const S=this.observers.find(j=>j.options.queryFn);S&&this.setOptions(S.options)}const r=new AbortController,s=S=>{Object.defineProperty(S,"signal",{enumerable:!0,get:()=>(pt(this,Lo,!0),r.signal)})},a=()=>{const S=Uw(this.options,n),I=(()=>{const b={client:pe(this,Oo),queryKey:this.queryKey,meta:this.meta};return s(b),b})();return pt(this,Lo,!1),this.options.persister?this.options.persister(S,I,this):S(I)},l=(()=>{const S={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:pe(this,Oo),state:this.state,fetchFn:a};return s(S),S})();(u=this.options.behavior)==null||u.onFetch(l,this),pt(this,Oa,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((h=l.fetchOptions)==null?void 0:h.meta))&&Ln(this,$r,Es).call(this,{type:"fetch",meta:(f=l.fetchOptions)==null?void 0:f.meta}),pt(this,Tn,Hw({initialPromise:n==null?void 0:n.initialPromise,fn:l.fetchFn,onCancel:S=>{S instanceof yf&&S.revert&&this.setState({...pe(this,Oa),fetchStatus:"idle"}),r.abort()},onFail:(S,j)=>{Ln(this,$r,Es).call(this,{type:"failed",failureCount:S,error:j})},onPause:()=>{Ln(this,$r,Es).call(this,{type:"pause"})},onContinue:()=>{Ln(this,$r,Es).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}));try{const S=await pe(this,Tn).start();if(S===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(S),(m=(p=pe(this,br).config).onSuccess)==null||m.call(p,S,this),(g=(v=pe(this,br).config).onSettled)==null||g.call(v,S,this.state.error,this),S}catch(S){if(S instanceof yf){if(S.silent)return pe(this,Tn).promise;if(S.revert){if(this.state.data===void 0)throw S;return this.state.data}}throw Ln(this,$r,Es).call(this,{type:"error",error:S}),(w=(x=pe(this,br).config).onError)==null||w.call(x,S,this),(C=(y=pe(this,br).config).onSettled)==null||C.call(y,this.state.data,S,this),S}finally{this.scheduleGc()}}},Do=new WeakMap,Oa=new WeakMap,br=new WeakMap,Oo=new WeakMap,Tn=new WeakMap,ol=new WeakMap,Lo=new WeakMap,$r=new WeakSet,Es=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...j2(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...Yp(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return pt(this,Oa,t.manual?s:void 0),s;case"error":const a=t.error;return{...r,error:a,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Gn.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),pe(this,br).notify({query:this,type:"updated",action:t})})},gv);function j2(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Vw(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Yp(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Kp(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}function Xp(e){return{onFetch:(t,n)=>{var h,f,p,m,v;const r=t.options,s=(p=(f=(h=t.fetchOptions)==null?void 0:h.meta)==null?void 0:f.fetchMore)==null?void 0:p.direction,a=((m=t.state.data)==null?void 0:m.pages)||[],i=((v=t.state.data)==null?void 0:v.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let g=!1;const x=C=>{v2(C,()=>t.signal,()=>g=!0)},w=Uw(t.options,t.fetchOptions),y=async(C,S,j)=>{if(g)return Promise.reject();if(S==null&&C.pages.length)return Promise.resolve(C);const b=(()=>{const P={client:t.client,queryKey:t.queryKey,pageParam:S,direction:j?"backward":"forward",meta:t.options.meta};return x(P),P})(),k=await w(b),{maxPages:N}=t.options,A=j?x2:g2;return{pages:A(C.pages,k,N),pageParams:A(C.pageParams,S,N)}};if(s&&a.length){const C=s==="backward",S=C?E2:Jp,j={pages:a,pageParams:i},I=S(r,j);l=await y(j,I,C)}else{const C=e??a.length;do{const S=c===0?i[0]??r.initialPageParam:Jp(r,l);if(c>0&&S==null)break;l=await y(l,S),c++}while(c<C)}return l};t.options.persister?t.fetchFn=()=>{var g,x;return(x=(g=t.options).persister)==null?void 0:x.call(g,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function Jp(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function E2(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var al,as,Zn,Fo,is,Gs,xv,N2=(xv=class extends Ww{constructor(t){super();Mt(this,is);Mt(this,al);Mt(this,as);Mt(this,Zn);Mt(this,Fo);pt(this,al,t.client),this.mutationId=t.mutationId,pt(this,Zn,t.mutationCache),pt(this,as,[]),this.state=t.state||T2(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){pe(this,as).includes(t)||(pe(this,as).push(t),this.clearGcTimeout(),pe(this,Zn).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){pt(this,as,pe(this,as).filter(n=>n!==t)),this.scheduleGc(),pe(this,Zn).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){pe(this,as).length||(this.state.status==="pending"?this.scheduleGc():pe(this,Zn).remove(this))}continue(){var t;return((t=pe(this,Fo))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var i,l,c,u,h,f,p,m,v,g,x,w,y,C,S,j,I,b,k,N;const n=()=>{Ln(this,is,Gs).call(this,{type:"continue"})},r={client:pe(this,al),meta:this.options.meta,mutationKey:this.options.mutationKey};pt(this,Fo,Hw({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(A,P)=>{Ln(this,is,Gs).call(this,{type:"failed",failureCount:A,error:P})},onPause:()=>{Ln(this,is,Gs).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>pe(this,Zn).canRun(this)}));const s=this.state.status==="pending",a=!pe(this,Fo).canStart();try{if(s)n();else{Ln(this,is,Gs).call(this,{type:"pending",variables:t,isPaused:a}),await((l=(i=pe(this,Zn).config).onMutate)==null?void 0:l.call(i,t,this,r));const P=await((u=(c=this.options).onMutate)==null?void 0:u.call(c,t,r));P!==this.state.context&&Ln(this,is,Gs).call(this,{type:"pending",context:P,variables:t,isPaused:a})}const A=await pe(this,Fo).start();return await((f=(h=pe(this,Zn).config).onSuccess)==null?void 0:f.call(h,A,t,this.state.context,this,r)),await((m=(p=this.options).onSuccess)==null?void 0:m.call(p,A,t,this.state.context,r)),await((g=(v=pe(this,Zn).config).onSettled)==null?void 0:g.call(v,A,null,this.state.variables,this.state.context,this,r)),await((w=(x=this.options).onSettled)==null?void 0:w.call(x,A,null,t,this.state.context,r)),Ln(this,is,Gs).call(this,{type:"success",data:A}),A}catch(A){try{await((C=(y=pe(this,Zn).config).onError)==null?void 0:C.call(y,A,t,this.state.context,this,r))}catch(P){Promise.reject(P)}try{await((j=(S=this.options).onError)==null?void 0:j.call(S,A,t,this.state.context,r))}catch(P){Promise.reject(P)}try{await((b=(I=pe(this,Zn).config).onSettled)==null?void 0:b.call(I,void 0,A,this.state.variables,this.state.context,this,r))}catch(P){Promise.reject(P)}try{await((N=(k=this.options).onSettled)==null?void 0:N.call(k,void 0,A,t,this.state.context,r))}catch(P){Promise.reject(P)}throw Ln(this,is,Gs).call(this,{type:"error",error:A}),A}finally{pe(this,Zn).runNext(this)}}},al=new WeakMap,as=new WeakMap,Zn=new WeakMap,Fo=new WeakMap,is=new WeakSet,Gs=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Gn.batch(()=>{pe(this,as).forEach(r=>{r.onMutationUpdate(t)}),pe(this,Zn).notify({mutation:this,type:"updated",action:t})})},xv);function T2(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var As,Ur,il,vv,A2=(vv=class extends vu{constructor(t={}){super();Mt(this,As);Mt(this,Ur);Mt(this,il);this.config=t,pt(this,As,new Set),pt(this,Ur,new Map),pt(this,il,0)}build(t,n,r){const s=new N2({client:t,mutationCache:this,mutationId:++Ll(this,il)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){pe(this,As).add(t);const n=Hl(t);if(typeof n=="string"){const r=pe(this,Ur).get(n);r?r.push(t):pe(this,Ur).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(pe(this,As).delete(t)){const n=Hl(t);if(typeof n=="string"){const r=pe(this,Ur).get(n);if(r)if(r.length>1){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&pe(this,Ur).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Hl(t);if(typeof n=="string"){const r=pe(this,Ur).get(n),s=r==null?void 0:r.find(a=>a.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const n=Hl(t);if(typeof n=="string"){const s=(r=pe(this,Ur).get(n))==null?void 0:r.find(a=>a!==t&&a.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Gn.batch(()=>{pe(this,As).forEach(t=>{this.notify({type:"removed",mutation:t})}),pe(this,As).clear(),pe(this,Ur).clear()})}getAll(){return Array.from(pe(this,As))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>Zp(n,r))}findAll(t={}){return this.getAll().filter(n=>Zp(t,n))}notify(t){Gn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Gn.batch(()=>Promise.all(t.map(n=>n.continue().catch(zr))))}},As=new WeakMap,Ur=new WeakMap,il=new WeakMap,vv);function Hl(e){var t;return(t=e.options.scope)==null?void 0:t.id}var ls,wv,I2=(wv=class extends vu{constructor(t={}){super();Mt(this,ls);this.config=t,pt(this,ls,new Map)}build(t,n,r){const s=n.queryKey,a=n.queryHash??Nh(s,n);let i=this.get(a);return i||(i=new k2({client:t,queryKey:s,queryHash:a,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(i)),i}add(t){pe(this,ls).has(t.queryHash)||(pe(this,ls).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=pe(this,ls).get(t.queryHash);n&&(t.destroy(),n===t&&pe(this,ls).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Gn.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return pe(this,ls).get(t)}getAll(){return[...pe(this,ls).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>Wp(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>Wp(t,r)):n}notify(t){Gn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Gn.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Gn.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},ls=new WeakMap,wv),cn,ro,so,La,Fa,oo,za,$a,yv,R2=(yv=class{constructor(e={}){Mt(this,cn);Mt(this,ro);Mt(this,so);Mt(this,La);Mt(this,Fa);Mt(this,oo);Mt(this,za);Mt(this,$a);pt(this,cn,e.queryCache||new I2),pt(this,ro,e.mutationCache||new A2),pt(this,so,e.defaultOptions||{}),pt(this,La,new Map),pt(this,Fa,new Map),pt(this,oo,0)}mount(){Ll(this,oo)._++,pe(this,oo)===1&&(pt(this,za,Bw.subscribe(async e=>{e&&(await this.resumePausedMutations(),pe(this,cn).onFocus())})),pt(this,$a,Ic.subscribe(async e=>{e&&(await this.resumePausedMutations(),pe(this,cn).onOnline())})))}unmount(){var e,t;Ll(this,oo)._--,pe(this,oo)===0&&((e=pe(this,za))==null||e.call(this),pt(this,za,void 0),(t=pe(this,$a))==null||t.call(this),pt(this,$a,void 0))}isFetching(e){return pe(this,cn).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return pe(this,ro).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=pe(this,cn).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=pe(this,cn).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(vf(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return pe(this,cn).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),s=pe(this,cn).get(r.queryHash),a=s==null?void 0:s.state.data,i=c2(t,a);if(i!==void 0)return pe(this,cn).build(this,r).setData(i,{...n,manual:!0})}setQueriesData(e,t,n){return Gn.batch(()=>pe(this,cn).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=pe(this,cn).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=pe(this,cn);Gn.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=pe(this,cn);return Gn.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Gn.batch(()=>pe(this,cn).findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(zr).catch(zr)}invalidateQueries(e,t={}){return Gn.batch(()=>(pe(this,cn).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=Gn.batch(()=>pe(this,cn).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let a=s.fetch(void 0,n);return n.throwOnError||(a=a.catch(zr)),s.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(zr)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=pe(this,cn).build(this,t);return n.isStaleByTime(vf(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(zr).catch(zr)}fetchInfiniteQuery(e){return e.behavior=Xp(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(zr).catch(zr)}ensureInfiniteQueryData(e){return e.behavior=Xp(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Ic.isOnline()?pe(this,ro).resumePausedMutations():Promise.resolve()}getQueryCache(){return pe(this,cn)}getMutationCache(){return pe(this,ro)}getDefaultOptions(){return pe(this,so)}setDefaultOptions(e){pt(this,so,e)}setQueryDefaults(e,t){pe(this,La).set(Hi(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...pe(this,La).values()],n={};return t.forEach(r=>{Wi(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){pe(this,Fa).set(Hi(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...pe(this,Fa).values()],n={};return t.forEach(r=>{Wi(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...pe(this,so).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Nh(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Th&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...pe(this,so).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){pe(this,cn).clear(),pe(this,ro).clear()}},cn=new WeakMap,ro=new WeakMap,so=new WeakMap,La=new WeakMap,Fa=new WeakMap,oo=new WeakMap,za=new WeakMap,$a=new WeakMap,yv),P2=d.createContext(void 0),M2=({client:e,children:t})=>(d.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),o.jsx(P2.Provider,{value:e,children:t}));const Rc=e=>{try{const t=new URL(e);if(t.protocol!=="artifact:")return null;const n=t.pathname.split("/").filter(i=>i);if(n.length<3){const i=t.hostname||null,l=n.length>0?n[n.length-1]:"";if(!l)return null;const c=t.searchParams.get("version");return{sessionId:i,filename:l,version:c}}const r=n[1],s=n[2],a=t.searchParams.get("version");return{sessionId:r,filename:s,version:a}}catch(t){return console.error("Invalid artifact URI:",t),null}},hl=(e,t)=>{try{const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t||"download",document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}catch(n){console.error("Error downloading blob:",n)}},Zw=async(e,t,n)=>{try{let r,s=e.name;if(e.content){const a=atob(e.content),i=new Array(a.length);for(let c=0;c<a.length;c++)i[c]=a.charCodeAt(c);const l=new Uint8Array(i);r=new Blob([l],{type:e.mime_type||"application/octet-stream"})}else if(e.uri){const a=Rc(e.uri);if(!a)throw new Error(`Invalid or unhandled URI format: ${e.uri}`);const{filename:i,version:l}=a;s=i;const c=l||"latest";let u;t&&t.trim()&&t!=="null"&&t!=="undefined"?u=`/api/v1/artifacts/${encodeURIComponent(t)}/${encodeURIComponent(s)}/versions/${c}`:n?u=`/api/v1/artifacts/null/${encodeURIComponent(s)}/versions/${c}?project_id=${n}`:u=`/api/v1/artifacts/null/${encodeURIComponent(s)}/versions/${c}`;const h=await Ie.webui.get(u,{fullResponse:!0});if(!h.ok)throw new Error(`Failed to download file: ${h.statusText}`);r=await h.blob()}else throw new Error("File has no content or URI to download.");hl(r,s)}catch(r){console.error("Error creating download link:",r)}},D2=e=>new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(r.result.split(",")[1]),r.onerror=s=>n(s),r.readAsDataURL(e)}),Gw=e=>new Promise((t,n)=>{const r=new FileReader;r.onloadend=()=>{var s;return t(((s=r.result)==null?void 0:s.toString().split(",")[1])||"")},r.onerror=n,r.readAsDataURL(e)}),qw=({filename:e,sessionId:t,projectId:n,version:r})=>{const s=t&&t.trim()&&t!=="null"&&t!=="undefined",a=encodeURIComponent(e),i=s?`/api/v1/artifacts/${t}/${a}/versions`:`/api/v1/artifacts/null/${a}/versions`,l=r!==void 0?`/${r}`:"",c=`${i}${l}`;if(!s&&n)return`${c}?project_id=${n}`;if(!s&&!n)throw new Error("No valid context for artifact: either sessionId or projectId must be provided");return c},Qp=async({filename:e,sessionId:t,projectId:n,version:r})=>{const s=qw({filename:e,sessionId:t,projectId:n,version:r}),a=await Ie.webui.get(s,{fullResponse:!0});if(!a.ok)throw new Error(`Failed to fetch artifact content: ${a.statusText}`);const l=(a.headers.get("Content-Type")||"application/octet-stream").split(";")[0].trim(),c=await a.blob();return{content:await Gw(c),mimeType:l}};function O2(e,t={}){const{maxSizeBytes:n,includeFileSizes:r=!0,maxFilesToList:s=3}=t;if(!n)return{valid:!0};const a=Array.from(e),i=[];for(const u of a)u.size>n&&i.push({name:u.name,size:u.size});if(i.length===0)return{valid:!0};const l=(n/(1024*1024)).toFixed(0);let c;if(i.length===1){const u=i[0];if(r){const h=(u.size/1048576).toFixed(2);c=`File "${u.name}" (${h} MB) exceeds the maximum size of ${l} MB.`}else c=`File "${u.name}" exceeds the maximum size of ${l} MB.`}else{const u=i.slice(0,s),h=r?u.map(m=>`${m.name} (${(m.size/(1024*1024)).toFixed(2)} MB)`):u.map(m=>m.name),f=i.length-s,p=f>0?` and ${f} more`:"";c=`${i.length} files exceed the maximum size of ${l} MB: ${h.join(", ")}${p}`}return{valid:!1,error:c,oversizedFiles:i}}function L2(e,t,n){const r=(t/1048576).toFixed(2),s=(n/(1024*1024)).toFixed(2);return`File "${e}" is too large: ${r} MB exceeds the maximum allowed size of ${s} MB.`}const ds=(e,t=2)=>{if(e===0)return"0 Bytes";if(e<0||!Number.isFinite(e))return"Invalid size";const n=1024,r=t<0?0:t,s=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],a=Math.floor(Math.log(e)/Math.log(n));return parseFloat((e/Math.pow(n,a)).toFixed(r))+" "+s[a]},Pc=e=>{if(!e)return"N/A";try{const t=new Date(e);if(isNaN(t.getTime()))return"N/A";const r=Math.floor((new Date().getTime()-t.getTime())/1e3),s=Math.floor(r/60),a=Math.floor(s/60),i=Math.floor(a/24);return r<60?`${r}s ago`:s<60?`${s}m ago`:a<24?`${a}h ago`:i===1?"Yesterday":i<7?`${i}d ago`:t.toLocaleDateString()}catch(t){return console.error("Error formatting date:",t),"Invalid date"}},Ah=e=>{if(!e)return"N/A";try{const t=new Date(e);return isNaN(t.getTime())?"N/A":t.toLocaleString()}catch{return"N/A"}};function Va(e){const t=/\{\{([^}]+)\}\}/g,n=e.matchAll(t),r=new Set;for(const s of n)r.add(s[1].trim());return Array.from(r)}function F2(e,t){let n=e;for(const[r,s]of Object.entries(t)){const a=new RegExp(`\\{\\{\\s*${r}\\s*\\}\\}`,"g");n=n.replace(a,s)}return n}function z2(e){return!e||e.trim().length===0?{valid:!1,error:"Prompt text cannot be empty"}:e.length>1e4?{valid:!1,error:"Prompt text exceeds maximum length of 10,000 characters"}:{valid:!0}}function bf(e){return new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}const Mc=1,$2=e=>({...e,taskMetadata:{...e.taskMetadata,schema_version:1}}),U2={0:$2},B2=e=>{var r;const t=((r=e.taskMetadata)==null?void 0:r.schema_version)??0;if(t>=Mc)return e;let n=e;for(let s=t;s<Mc;s++){const a=U2[s];a?(n=a(n),console.log(`[Migration] Migrated task ${e.taskId} from v${s} to v${s+1}`)):console.warn(`[Migration] No migration function found for version ${s}`)}return n},Dc=(e="")=>`
|
|
14
|
+
break-words
|
|
15
|
+
leading-[24px]
|
|
16
|
+
|
|
17
|
+
/* Typography */
|
|
18
|
+
[&_h1]:text-2xl [&_h1]:font-bold [&_h1]:mb-4 [&_h1]:mt-6 [&_h1]:text-foreground
|
|
19
|
+
[&_h2]:text-xl [&_h2]:font-bold [&_h2]:mb-3 [&_h2]:mt-5 [&_h2]:text-foreground
|
|
20
|
+
[&_h3]:text-lg [&_h3]:font-semibold [&_h3]:mb-2 [&_h3]:mt-4 [&_h3]:text-foreground
|
|
21
|
+
[&_h4]:text-base [&_h4]:font-semibold [&_h4]:mb-2 [&_h4]:mt-3 [&_h4]:text-foreground
|
|
22
|
+
[&_h5]:text-sm [&_h5]:font-semibold [&_h5]:mb-1 [&_h5]:mt-2 [&_h5]:text-foreground
|
|
23
|
+
[&_h6]:text-xs [&_h6]:font-semibold [&_h6]:mb-1 [&_h6]:mt-2 [&_h6]:text-foreground
|
|
24
|
+
|
|
25
|
+
/* Paragraphs */
|
|
26
|
+
[&_p]:leading-[24px] [&_p]:text-foreground [&_p]:whitespace-pre-wrap [&_p]:mb-6
|
|
27
|
+
[&_p:last-child]:mb-0
|
|
28
|
+
[&_li>p]:mb-0
|
|
29
|
+
|
|
30
|
+
/* Text formatting */
|
|
31
|
+
[&_strong]:font-semibold [&_strong]:text-foreground
|
|
32
|
+
[&_em]:italic
|
|
33
|
+
[&_del]:line-through [&_del]:text-foreground
|
|
34
|
+
|
|
35
|
+
/* Links */
|
|
36
|
+
[&_a]:text-[var(--color-primary-wMain)] [&_a]:underline [&_a]:decoration-[var(--color-primary-wMain)] dark:[&_a]:text-[var(--color-primary-w20)] dark:[&_a]:decoration-[var(--color-primary-w20)]
|
|
37
|
+
[&_a:hover]:text-[var(--color-primary-w100)] [&_a:hover]:decoration-[var(--color-primary-w100)] dark:[&_a:hover]:text-[var(--color-primary-w10)] dark:[&_a:hover]:decoration-[var(--color-primary-w10)]
|
|
38
|
+
|
|
39
|
+
/* Lists */
|
|
40
|
+
[&_ul]:mb-4 [&_ul]:pl-6 [&_ul]:list-disc [&_ul]:space-y-1
|
|
41
|
+
[&_ol]:mb-4 [&_ol]:pl-6 [&_ol]:list-decimal [&_ol]:space-y-1
|
|
42
|
+
[&_li]:text-foreground [&_li]:leading-[24px]
|
|
43
|
+
[&_ul_ul]:mt-1 [&_ul_ul]:mb-1
|
|
44
|
+
[&_ol_ol]:mt-1 [&_ol_ol]:mb-1
|
|
45
|
+
[&_ul:last-child]:mb-0
|
|
46
|
+
[&_ol:last-child]:mb-0
|
|
47
|
+
|
|
48
|
+
/* Code - inline code only (code blocks handled by CodeBlock component) */
|
|
49
|
+
[&_code]:bg-transparent [&_code]:py-0.5 [&_code]:rounded
|
|
50
|
+
[&_code]:text-sm [&_code]:font-mono [&_code]:font-semibold [&_code]:text-foreground [&_code]:break-words
|
|
51
|
+
|
|
52
|
+
/* Blockquotes */
|
|
53
|
+
[&_blockquote]:border-l-4 [&_blockquote]:border-border [&_blockquote]:pl-4
|
|
54
|
+
[&_blockquote]:py-2 [&_blockquote]:mb-4 [&_blockquote]:italic
|
|
55
|
+
[&_blockquote]:text-foreground [&_blockquote]:bg-transparent
|
|
56
|
+
[&_blockquote:last-child]:mb-0
|
|
57
|
+
|
|
58
|
+
/* Tables */
|
|
59
|
+
[&_table]:w-full [&_table]:mb-4 [&_table]:border-collapse [&_table]:table-fixed [&_table]:max-w-full
|
|
60
|
+
[&_th]:border [&_th]:border-border [&_th]:px-3 [&_th]:py-2 [&_th]:break-words
|
|
61
|
+
[&_th]:bg-transparent [&_th]:font-semibold [&_th]:text-left
|
|
62
|
+
[&_td]:border [&_td]:border-border [&_td]:px-3 [&_td]:py-2 [&_td]:break-words
|
|
63
|
+
[&_tr:nth-child(even)]:bg-transparent
|
|
64
|
+
[&_table:last-child]:mb-0
|
|
65
|
+
|
|
66
|
+
/* Horizontal rules */
|
|
67
|
+
[&_hr]:border-0 [&_hr]:border-t [&_hr]:border-border [&_hr]:my-6
|
|
68
|
+
[&_hr:last-child]:mb-0
|
|
69
|
+
|
|
70
|
+
/* Images */
|
|
71
|
+
[&_img]:max-w-full [&_img]:h-auto [&_img]:rounded [&_img]:my-2 [&_img]:object-contain
|
|
72
|
+
[&_img:last-child]:mb-0
|
|
73
|
+
|
|
74
|
+
${e}
|
|
75
|
+
`.trim().replace(/\s+/g," "),V2=(e="")=>`
|
|
76
|
+
/* Buttons - "important" overrides for flow controls */
|
|
77
|
+
[&>button]:bg-[var(--color-background-w10)]
|
|
78
|
+
[&>button]:dark:!bg-[var(--color-background-w100)]
|
|
79
|
+
[&>button]:hover:bg-[var(--color-background-w20)]
|
|
80
|
+
[&>button]:dark:hover:!bg-[var(--color-primary-w60)]
|
|
81
|
+
[&>button]:text-[var(--color-primary-text-wMain)]
|
|
82
|
+
[&>button]:dark:text-[var(--color-primary-text-w10)]
|
|
83
|
+
[&>button]:!border
|
|
84
|
+
[&>button]:!border-[var(--color-secondary-w40)]
|
|
85
|
+
[&>button]:dark:!border-[var(--color-secondary-w70)]
|
|
86
|
+
|
|
87
|
+
${e}
|
|
88
|
+
`.trim().replace(/\s+/g," ");function md(e){return typeof e=="string"}const H2=/^https?:\/\//;function W2(e){try{const t=e.replace(H2,"").split("/")[0];return t.startsWith("www.")?t.substring(4):t}catch{return e}}function Z2(e,t=32){return`https://www.google.com/s2/favicons?domain=${e}&sz=${t}`}function Oc(e){var r,s;if(!e)return{url:null,hasUrl:!1,sourceType:"web"};const t=e.sourceType||((r=e.metadata)==null?void 0:r.type)||"web",n=e.sourceUrl||e.url||((s=e.metadata)==null?void 0:s.link)||null;return{url:n,hasUrl:!!n,sourceType:t}}function G2(e){return e!=null&&e.length?e.some(t=>{var n;return((n=t.sources)==null?void 0:n.some(r=>Oc(r).hasUrl))??!1}):!1}function Gt(e,t,{checkForDefaultPrevented:n=!0}={}){return function(s){if(e==null||e(s),n===!1||!s.defaultPrevented)return t==null?void 0:t(s)}}function q2(e,t){const n=d.createContext(t),r=a=>{const{children:i,...l}=a,c=d.useMemo(()=>l,Object.values(l));return o.jsx(n.Provider,{value:c,children:i})};r.displayName=e+"Provider";function s(a){const i=d.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[r,s]}function pr(e,t=[]){let n=[];function r(a,i){const l=d.createContext(i),c=n.length;n=[...n,i];const u=f=>{var w;const{scope:p,children:m,...v}=f,g=((w=p==null?void 0:p[e])==null?void 0:w[c])||l,x=d.useMemo(()=>v,Object.values(v));return o.jsx(g.Provider,{value:x,children:m})};u.displayName=a+"Provider";function h(f,p){var g;const m=((g=p==null?void 0:p[e])==null?void 0:g[c])||l,v=d.useContext(m);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${a}\``)}return[u,h]}const s=()=>{const a=n.map(i=>d.createContext(i));return function(l){const c=(l==null?void 0:l[e])||a;return d.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return s.scopeName=e,[r,Y2(s,...t)]}function Y2(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const i=r.reduce((l,{useScope:c,scopeName:u})=>{const f=c(a)[`__scope${u}`];return{...l,...f}},{});return d.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var K2=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ct=K2.reduce((e,t)=>{const n=ho(`Primitive.${t}`),r=d.forwardRef((s,a)=>{const{asChild:i,...l}=s,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(c,{...l,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function yu(e,t){e&&ti.flushSync(()=>e.dispatchEvent(t))}function Dn(e){const t=d.useRef(e);return d.useEffect(()=>{t.current=e}),d.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Ih(e,t=globalThis==null?void 0:globalThis.document){const n=Dn(e);d.useEffect(()=>{const r=s=>{s.key==="Escape"&&n(s)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var X2="DismissableLayer",Cf="dismissableLayer.update",J2="dismissableLayer.pointerDownOutside",Q2="dismissableLayer.focusOutside",eg,Yw=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),bu=d.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:i,onDismiss:l,...c}=e,u=d.useContext(Yw),[h,f]=d.useState(null),p=(h==null?void 0:h.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=d.useState({}),v=yt(t,b=>f(b)),g=Array.from(u.layers),[x]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),w=g.indexOf(x),y=h?g.indexOf(h):-1,C=u.layersWithOutsidePointerEventsDisabled.size>0,S=y>=w,j=nN(b=>{const k=b.target,N=[...u.branches].some(A=>A.contains(k));!S||N||(s==null||s(b),i==null||i(b),b.defaultPrevented||l==null||l())},p),I=rN(b=>{const k=b.target;[...u.branches].some(A=>A.contains(k))||(a==null||a(b),i==null||i(b),b.defaultPrevented||l==null||l())},p);return Ih(b=>{y===u.layers.size-1&&(r==null||r(b),!b.defaultPrevented&&l&&(b.preventDefault(),l()))},p),d.useEffect(()=>{if(h)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(eg=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(h)),u.layers.add(h),tg(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=eg)}},[h,p,n,u]),d.useEffect(()=>()=>{h&&(u.layers.delete(h),u.layersWithOutsidePointerEventsDisabled.delete(h),tg())},[h,u]),d.useEffect(()=>{const b=()=>m({});return document.addEventListener(Cf,b),()=>document.removeEventListener(Cf,b)},[]),o.jsx(ct.div,{...c,ref:v,style:{pointerEvents:C?S?"auto":"none":void 0,...e.style},onFocusCapture:Gt(e.onFocusCapture,I.onFocusCapture),onBlurCapture:Gt(e.onBlurCapture,I.onBlurCapture),onPointerDownCapture:Gt(e.onPointerDownCapture,j.onPointerDownCapture)})});bu.displayName=X2;var eN="DismissableLayerBranch",tN=d.forwardRef((e,t)=>{const n=d.useContext(Yw),r=d.useRef(null),s=yt(t,r);return d.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),o.jsx(ct.div,{...e,ref:s})});tN.displayName=eN;function nN(e,t=globalThis==null?void 0:globalThis.document){const n=Dn(e),r=d.useRef(!1),s=d.useRef(()=>{});return d.useEffect(()=>{const a=l=>{if(l.target&&!r.current){let c=function(){Kw(J2,n,u,{discrete:!0})};const u={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",s.current),s.current=c,t.addEventListener("click",s.current,{once:!0})):c()}else t.removeEventListener("click",s.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",s.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function rN(e,t=globalThis==null?void 0:globalThis.document){const n=Dn(e),r=d.useRef(!1);return d.useEffect(()=>{const s=a=>{a.target&&!r.current&&Kw(Q2,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",s),()=>t.removeEventListener("focusin",s)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function tg(){const e=new CustomEvent(Cf);document.dispatchEvent(e)}function Kw(e,t,n,{discrete:r}){const s=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&s.addEventListener(e,t,{once:!0}),r?yu(s,a):s.dispatchEvent(a)}var dn=globalThis!=null&&globalThis.document?d.useLayoutEffect:()=>{},sN=iu[" useId ".trim().toString()]||(()=>{}),oN=0;function dr(e){const[t,n]=d.useState(sN());return dn(()=>{n(r=>r??String(oN++))},[e]),t?`radix-${t}`:""}const aN=["top","right","bottom","left"],mo=Math.min,lr=Math.max,Lc=Math.round,Wl=Math.floor,ps=e=>({x:e,y:e}),iN={left:"right",right:"left",bottom:"top",top:"bottom"},lN={start:"end",end:"start"};function Sf(e,t,n){return lr(e,mo(t,n))}function Ps(e,t){return typeof e=="function"?e(t):e}function Ms(e){return e.split("-")[0]}function ai(e){return e.split("-")[1]}function Rh(e){return e==="x"?"y":"x"}function Ph(e){return e==="y"?"height":"width"}const cN=new Set(["top","bottom"]);function fs(e){return cN.has(Ms(e))?"y":"x"}function Mh(e){return Rh(fs(e))}function uN(e,t,n){n===void 0&&(n=!1);const r=ai(e),s=Mh(e),a=Ph(s);let i=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=Fc(i)),[i,Fc(i)]}function dN(e){const t=Fc(e);return[_f(e),t,_f(t)]}function _f(e){return e.replace(/start|end/g,t=>lN[t])}const ng=["left","right"],rg=["right","left"],fN=["top","bottom"],hN=["bottom","top"];function mN(e,t,n){switch(e){case"top":case"bottom":return n?t?rg:ng:t?ng:rg;case"left":case"right":return t?fN:hN;default:return[]}}function pN(e,t,n,r){const s=ai(e);let a=mN(Ms(e),n==="start",r);return s&&(a=a.map(i=>i+"-"+s),t&&(a=a.concat(a.map(_f)))),a}function Fc(e){return e.replace(/left|right|bottom|top/g,t=>iN[t])}function gN(e){return{top:0,right:0,bottom:0,left:0,...e}}function Xw(e){return typeof e!="number"?gN(e):{top:e,right:e,bottom:e,left:e}}function zc(e){const{x:t,y:n,width:r,height:s}=e;return{width:r,height:s,top:n,left:t,right:t+r,bottom:n+s,x:t,y:n}}function sg(e,t,n){let{reference:r,floating:s}=e;const a=fs(t),i=Mh(t),l=Ph(i),c=Ms(t),u=a==="y",h=r.x+r.width/2-s.width/2,f=r.y+r.height/2-s.height/2,p=r[l]/2-s[l]/2;let m;switch(c){case"top":m={x:h,y:r.y-s.height};break;case"bottom":m={x:h,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-s.width,y:f};break;default:m={x:r.x,y:r.y}}switch(ai(t)){case"start":m[i]-=p*(n&&u?-1:1);break;case"end":m[i]+=p*(n&&u?-1:1);break}return m}const xN=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:a=[],platform:i}=n,l=a.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:s}),{x:h,y:f}=sg(u,r,c),p=r,m={},v=0;for(let g=0;g<l.length;g++){const{name:x,fn:w}=l[g],{x:y,y:C,data:S,reset:j}=await w({x:h,y:f,initialPlacement:r,placement:p,strategy:s,middlewareData:m,rects:u,platform:i,elements:{reference:e,floating:t}});h=y??h,f=C??f,m={...m,[x]:{...m[x],...S}},j&&v<=50&&(v++,typeof j=="object"&&(j.placement&&(p=j.placement),j.rects&&(u=j.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:s}):j.rects),{x:h,y:f}=sg(u,p,c)),g=-1)}return{x:h,y:f,placement:p,strategy:s,middlewareData:m}};async function Zi(e,t){var n;t===void 0&&(t={});const{x:r,y:s,platform:a,rects:i,elements:l,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:h="viewport",elementContext:f="floating",altBoundary:p=!1,padding:m=0}=Ps(t,e),v=Xw(m),x=l[p?f==="floating"?"reference":"floating":f],w=zc(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(x)))==null||n?x:x.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(l.floating)),boundary:u,rootBoundary:h,strategy:c})),y=f==="floating"?{x:r,y:s,width:i.floating.width,height:i.floating.height}:i.reference,C=await(a.getOffsetParent==null?void 0:a.getOffsetParent(l.floating)),S=await(a.isElement==null?void 0:a.isElement(C))?await(a.getScale==null?void 0:a.getScale(C))||{x:1,y:1}:{x:1,y:1},j=zc(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:y,offsetParent:C,strategy:c}):y);return{top:(w.top-j.top+v.top)/S.y,bottom:(j.bottom-w.bottom+v.bottom)/S.y,left:(w.left-j.left+v.left)/S.x,right:(j.right-w.right+v.right)/S.x}}const vN=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:s,rects:a,platform:i,elements:l,middlewareData:c}=t,{element:u,padding:h=0}=Ps(e,t)||{};if(u==null)return{};const f=Xw(h),p={x:n,y:r},m=Mh(s),v=Ph(m),g=await i.getDimensions(u),x=m==="y",w=x?"top":"left",y=x?"bottom":"right",C=x?"clientHeight":"clientWidth",S=a.reference[v]+a.reference[m]-p[m]-a.floating[v],j=p[m]-a.reference[m],I=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let b=I?I[C]:0;(!b||!await(i.isElement==null?void 0:i.isElement(I)))&&(b=l.floating[C]||a.floating[v]);const k=S/2-j/2,N=b/2-g[v]/2-1,A=mo(f[w],N),P=mo(f[y],N),E=A,R=b-g[v]-P,_=b/2-g[v]/2+k,M=Sf(E,_,R),L=!c.arrow&&ai(s)!=null&&_!==M&&a.reference[v]/2-(_<E?A:P)-g[v]/2<0,F=L?_<E?_-E:_-R:0;return{[m]:p[m]+F,data:{[m]:M,centerOffset:_-M-F,...L&&{alignmentOffset:F}},reset:L}}}),wN=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:s,middlewareData:a,rects:i,initialPlacement:l,platform:c,elements:u}=t,{mainAxis:h=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=Ps(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const w=Ms(s),y=fs(l),C=Ms(l)===l,S=await(c.isRTL==null?void 0:c.isRTL(u.floating)),j=p||(C||!g?[Fc(l)]:dN(l)),I=v!=="none";!p&&I&&j.push(...pN(l,g,v,S));const b=[l,...j],k=await Zi(t,x),N=[];let A=((r=a.flip)==null?void 0:r.overflows)||[];if(h&&N.push(k[w]),f){const _=uN(s,i,S);N.push(k[_[0]],k[_[1]])}if(A=[...A,{placement:s,overflows:N}],!N.every(_=>_<=0)){var P,E;const _=(((P=a.flip)==null?void 0:P.index)||0)+1,M=b[_];if(M&&(!(f==="alignment"?y!==fs(M):!1)||A.every(D=>fs(D.placement)===y?D.overflows[0]>0:!0)))return{data:{index:_,overflows:A},reset:{placement:M}};let L=(E=A.filter(F=>F.overflows[0]<=0).sort((F,D)=>F.overflows[1]-D.overflows[1])[0])==null?void 0:E.placement;if(!L)switch(m){case"bestFit":{var R;const F=(R=A.filter(D=>{if(I){const O=fs(D.placement);return O===y||O==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(O=>O>0).reduce((O,K)=>O+K,0)]).sort((D,O)=>D[1]-O[1])[0])==null?void 0:R[0];F&&(L=F);break}case"initialPlacement":L=l;break}if(s!==L)return{reset:{placement:L}}}return{}}}};function og(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ag(e){return aN.some(t=>e[t]>=0)}const yN=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...s}=Ps(e,t);switch(r){case"referenceHidden":{const a=await Zi(t,{...s,elementContext:"reference"}),i=og(a,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:ag(i)}}}case"escaped":{const a=await Zi(t,{...s,altBoundary:!0}),i=og(a,n.floating);return{data:{escapedOffsets:i,escaped:ag(i)}}}default:return{}}}}},Jw=new Set(["left","top"]);async function bN(e,t){const{placement:n,platform:r,elements:s}=e,a=await(r.isRTL==null?void 0:r.isRTL(s.floating)),i=Ms(n),l=ai(n),c=fs(n)==="y",u=Jw.has(i)?-1:1,h=a&&c?-1:1,f=Ps(t,e);let{mainAxis:p,crossAxis:m,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof v=="number"&&(m=l==="end"?v*-1:v),c?{x:m*h,y:p*u}:{x:p*u,y:m*h}}const CN=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:s,y:a,placement:i,middlewareData:l}=t,c=await bN(t,e);return i===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+c.x,y:a+c.y,data:{...c,placement:i}}}}},SN=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:s}=t,{mainAxis:a=!0,crossAxis:i=!1,limiter:l={fn:x=>{let{x:w,y}=x;return{x:w,y}}},...c}=Ps(e,t),u={x:n,y:r},h=await Zi(t,c),f=fs(Ms(s)),p=Rh(f);let m=u[p],v=u[f];if(a){const x=p==="y"?"top":"left",w=p==="y"?"bottom":"right",y=m+h[x],C=m-h[w];m=Sf(y,m,C)}if(i){const x=f==="y"?"top":"left",w=f==="y"?"bottom":"right",y=v+h[x],C=v-h[w];v=Sf(y,v,C)}const g=l.fn({...t,[p]:m,[f]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:a,[f]:i}}}}}},_N=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:s,rects:a,middlewareData:i}=t,{offset:l=0,mainAxis:c=!0,crossAxis:u=!0}=Ps(e,t),h={x:n,y:r},f=fs(s),p=Rh(f);let m=h[p],v=h[f];const g=Ps(l,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(c){const C=p==="y"?"height":"width",S=a.reference[p]-a.floating[C]+x.mainAxis,j=a.reference[p]+a.reference[C]-x.mainAxis;m<S?m=S:m>j&&(m=j)}if(u){var w,y;const C=p==="y"?"width":"height",S=Jw.has(Ms(s)),j=a.reference[f]-a.floating[C]+(S&&((w=i.offset)==null?void 0:w[f])||0)+(S?0:x.crossAxis),I=a.reference[f]+a.reference[C]+(S?0:((y=i.offset)==null?void 0:y[f])||0)-(S?x.crossAxis:0);v<j?v=j:v>I&&(v=I)}return{[p]:m,[f]:v}}}},kN=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:s,rects:a,platform:i,elements:l}=t,{apply:c=()=>{},...u}=Ps(e,t),h=await Zi(t,u),f=Ms(s),p=ai(s),m=fs(s)==="y",{width:v,height:g}=a.floating;let x,w;f==="top"||f==="bottom"?(x=f,w=p===(await(i.isRTL==null?void 0:i.isRTL(l.floating))?"start":"end")?"left":"right"):(w=f,x=p==="end"?"top":"bottom");const y=g-h.top-h.bottom,C=v-h.left-h.right,S=mo(g-h[x],y),j=mo(v-h[w],C),I=!t.middlewareData.shift;let b=S,k=j;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(k=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(b=y),I&&!p){const A=lr(h.left,0),P=lr(h.right,0),E=lr(h.top,0),R=lr(h.bottom,0);m?k=v-2*(A!==0||P!==0?A+P:lr(h.left,h.right)):b=g-2*(E!==0||R!==0?E+R:lr(h.top,h.bottom))}await c({...t,availableWidth:k,availableHeight:b});const N=await i.getDimensions(l.floating);return v!==N.width||g!==N.height?{reset:{rects:!0}}:{}}}};function Cu(){return typeof window<"u"}function ii(e){return Qw(e)?(e.nodeName||"").toLowerCase():"#document"}function fr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function bs(e){var t;return(t=(Qw(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Qw(e){return Cu()?e instanceof Node||e instanceof fr(e).Node:!1}function Xr(e){return Cu()?e instanceof Element||e instanceof fr(e).Element:!1}function vs(e){return Cu()?e instanceof HTMLElement||e instanceof fr(e).HTMLElement:!1}function ig(e){return!Cu()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof fr(e).ShadowRoot}const jN=new Set(["inline","contents"]);function ml(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=Jr(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!jN.has(s)}const EN=new Set(["table","td","th"]);function NN(e){return EN.has(ii(e))}const TN=[":popover-open",":modal"];function Su(e){return TN.some(t=>{try{return e.matches(t)}catch{return!1}})}const AN=["transform","translate","scale","rotate","perspective"],IN=["transform","translate","scale","rotate","perspective","filter"],RN=["paint","layout","strict","content"];function Dh(e){const t=Oh(),n=Xr(e)?Jr(e):e;return AN.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||IN.some(r=>(n.willChange||"").includes(r))||RN.some(r=>(n.contain||"").includes(r))}function PN(e){let t=po(e);for(;vs(t)&&!Ha(t);){if(Dh(t))return t;if(Su(t))return null;t=po(t)}return null}function Oh(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const MN=new Set(["html","body","#document"]);function Ha(e){return MN.has(ii(e))}function Jr(e){return fr(e).getComputedStyle(e)}function _u(e){return Xr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function po(e){if(ii(e)==="html")return e;const t=e.assignedSlot||e.parentNode||ig(e)&&e.host||bs(e);return ig(t)?t.host:t}function e0(e){const t=po(e);return Ha(t)?e.ownerDocument?e.ownerDocument.body:e.body:vs(t)&&ml(t)?t:e0(t)}function Gi(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=e0(e),a=s===((r=e.ownerDocument)==null?void 0:r.body),i=fr(s);if(a){const l=kf(i);return t.concat(i,i.visualViewport||[],ml(s)?s:[],l&&n?Gi(l):[])}return t.concat(s,Gi(s,[],n))}function kf(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function t0(e){const t=Jr(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=vs(e),a=s?e.offsetWidth:n,i=s?e.offsetHeight:r,l=Lc(n)!==a||Lc(r)!==i;return l&&(n=a,r=i),{width:n,height:r,$:l}}function Lh(e){return Xr(e)?e:e.contextElement}function Ea(e){const t=Lh(e);if(!vs(t))return ps(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:a}=t0(t);let i=(a?Lc(n.width):n.width)/r,l=(a?Lc(n.height):n.height)/s;return(!i||!Number.isFinite(i))&&(i=1),(!l||!Number.isFinite(l))&&(l=1),{x:i,y:l}}const DN=ps(0);function n0(e){const t=fr(e);return!Oh()||!t.visualViewport?DN:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function ON(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==fr(e)?!1:t}function Wo(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),a=Lh(e);let i=ps(1);t&&(r?Xr(r)&&(i=Ea(r)):i=Ea(e));const l=ON(a,n,r)?n0(a):ps(0);let c=(s.left+l.x)/i.x,u=(s.top+l.y)/i.y,h=s.width/i.x,f=s.height/i.y;if(a){const p=fr(a),m=r&&Xr(r)?fr(r):r;let v=p,g=kf(v);for(;g&&r&&m!==v;){const x=Ea(g),w=g.getBoundingClientRect(),y=Jr(g),C=w.left+(g.clientLeft+parseFloat(y.paddingLeft))*x.x,S=w.top+(g.clientTop+parseFloat(y.paddingTop))*x.y;c*=x.x,u*=x.y,h*=x.x,f*=x.y,c+=C,u+=S,v=fr(g),g=kf(v)}}return zc({width:h,height:f,x:c,y:u})}function ku(e,t){const n=_u(e).scrollLeft;return t?t.left+n:Wo(bs(e)).left+n}function r0(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ku(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function LN(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const a=s==="fixed",i=bs(r),l=t?Su(t.floating):!1;if(r===i||l&&a)return n;let c={scrollLeft:0,scrollTop:0},u=ps(1);const h=ps(0),f=vs(r);if((f||!f&&!a)&&((ii(r)!=="body"||ml(i))&&(c=_u(r)),vs(r))){const m=Wo(r);u=Ea(r),h.x=m.x+r.clientLeft,h.y=m.y+r.clientTop}const p=i&&!f&&!a?r0(i,c):ps(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+h.x+p.x,y:n.y*u.y-c.scrollTop*u.y+h.y+p.y}}function FN(e){return Array.from(e.getClientRects())}function zN(e){const t=bs(e),n=_u(e),r=e.ownerDocument.body,s=lr(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=lr(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ku(e);const l=-n.scrollTop;return Jr(r).direction==="rtl"&&(i+=lr(t.clientWidth,r.clientWidth)-s),{width:s,height:a,x:i,y:l}}const lg=25;function $N(e,t){const n=fr(e),r=bs(e),s=n.visualViewport;let a=r.clientWidth,i=r.clientHeight,l=0,c=0;if(s){a=s.width,i=s.height;const h=Oh();(!h||h&&t==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}const u=ku(r);if(u<=0){const h=r.ownerDocument,f=h.body,p=getComputedStyle(f),m=h.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-m);v<=lg&&(a-=v)}else u<=lg&&(a+=u);return{width:a,height:i,x:l,y:c}}const UN=new Set(["absolute","fixed"]);function BN(e,t){const n=Wo(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,a=vs(e)?Ea(e):ps(1),i=e.clientWidth*a.x,l=e.clientHeight*a.y,c=s*a.x,u=r*a.y;return{width:i,height:l,x:c,y:u}}function cg(e,t,n){let r;if(t==="viewport")r=$N(e,n);else if(t==="document")r=zN(bs(e));else if(Xr(t))r=BN(t,n);else{const s=n0(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return zc(r)}function s0(e,t){const n=po(e);return n===t||!Xr(n)||Ha(n)?!1:Jr(n).position==="fixed"||s0(n,t)}function VN(e,t){const n=t.get(e);if(n)return n;let r=Gi(e,[],!1).filter(l=>Xr(l)&&ii(l)!=="body"),s=null;const a=Jr(e).position==="fixed";let i=a?po(e):e;for(;Xr(i)&&!Ha(i);){const l=Jr(i),c=Dh(i);!c&&l.position==="fixed"&&(s=null),(a?!c&&!s:!c&&l.position==="static"&&!!s&&UN.has(s.position)||ml(i)&&!c&&s0(e,i))?r=r.filter(h=>h!==i):s=l,i=po(i)}return t.set(e,r),r}function HN(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const i=[...n==="clippingAncestors"?Su(t)?[]:VN(t,this._c):[].concat(n),r],l=i[0],c=i.reduce((u,h)=>{const f=cg(t,h,s);return u.top=lr(f.top,u.top),u.right=mo(f.right,u.right),u.bottom=mo(f.bottom,u.bottom),u.left=lr(f.left,u.left),u},cg(t,l,s));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function WN(e){const{width:t,height:n}=t0(e);return{width:t,height:n}}function ZN(e,t,n){const r=vs(t),s=bs(t),a=n==="fixed",i=Wo(e,!0,a,t);let l={scrollLeft:0,scrollTop:0};const c=ps(0);function u(){c.x=ku(s)}if(r||!r&&!a)if((ii(t)!=="body"||ml(s))&&(l=_u(t)),r){const m=Wo(t,!0,a,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else s&&u();a&&!r&&s&&u();const h=s&&!r&&!a?r0(s,l):ps(0),f=i.left+l.scrollLeft-c.x-h.x,p=i.top+l.scrollTop-c.y-h.y;return{x:f,y:p,width:i.width,height:i.height}}function pd(e){return Jr(e).position==="static"}function ug(e,t){if(!vs(e)||Jr(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return bs(e)===n&&(n=n.ownerDocument.body),n}function o0(e,t){const n=fr(e);if(Su(e))return n;if(!vs(e)){let s=po(e);for(;s&&!Ha(s);){if(Xr(s)&&!pd(s))return s;s=po(s)}return n}let r=ug(e,t);for(;r&&NN(r)&&pd(r);)r=ug(r,t);return r&&Ha(r)&&pd(r)&&!Dh(r)?n:r||PN(e)||n}const GN=async function(e){const t=this.getOffsetParent||o0,n=this.getDimensions,r=await n(e.floating);return{reference:ZN(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function qN(e){return Jr(e).direction==="rtl"}const YN={convertOffsetParentRelativeRectToViewportRelativeRect:LN,getDocumentElement:bs,getClippingRect:HN,getOffsetParent:o0,getElementRects:GN,getClientRects:FN,getDimensions:WN,getScale:Ea,isElement:Xr,isRTL:qN};function a0(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function KN(e,t){let n=null,r;const s=bs(e);function a(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function i(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),a();const u=e.getBoundingClientRect(),{left:h,top:f,width:p,height:m}=u;if(l||t(),!p||!m)return;const v=Wl(f),g=Wl(s.clientWidth-(h+p)),x=Wl(s.clientHeight-(f+m)),w=Wl(h),C={rootMargin:-v+"px "+-g+"px "+-x+"px "+-w+"px",threshold:lr(0,mo(1,c))||1};let S=!0;function j(I){const b=I[0].intersectionRatio;if(b!==c){if(!S)return i();b?i(!1,b):r=setTimeout(()=>{i(!1,1e-7)},1e3)}b===1&&!a0(u,e.getBoundingClientRect())&&i(),S=!1}try{n=new IntersectionObserver(j,{...C,root:s.ownerDocument})}catch{n=new IntersectionObserver(j,C)}n.observe(e)}return i(!0),a}function Fh(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=Lh(e),h=s||a?[...u?Gi(u):[],...Gi(t)]:[];h.forEach(w=>{s&&w.addEventListener("scroll",n,{passive:!0}),a&&w.addEventListener("resize",n)});const f=u&&l?KN(u,n):null;let p=-1,m=null;i&&(m=new ResizeObserver(w=>{let[y]=w;y&&y.target===u&&m&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var C;(C=m)==null||C.observe(t)})),n()}),u&&!c&&m.observe(u),m.observe(t));let v,g=c?Wo(e):null;c&&x();function x(){const w=Wo(e);g&&!a0(g,w)&&n(),g=w,v=requestAnimationFrame(x)}return n(),()=>{var w;h.forEach(y=>{s&&y.removeEventListener("scroll",n),a&&y.removeEventListener("resize",n)}),f==null||f(),(w=m)==null||w.disconnect(),m=null,c&&cancelAnimationFrame(v)}}const XN=CN,JN=SN,QN=wN,eT=kN,tT=yN,dg=vN,nT=_N,rT=(e,t,n)=>{const r=new Map,s={platform:YN,...n},a={...s.platform,_c:r};return xN(e,t,{...s,platform:a})};var sT=typeof document<"u",oT=function(){},wc=sT?d.useLayoutEffect:oT;function $c(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,s;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!$c(e[r],t[r]))return!1;return!0}if(s=Object.keys(e),n=s.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,s[r]))return!1;for(r=n;r--!==0;){const a=s[r];if(!(a==="_owner"&&e.$$typeof)&&!$c(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function i0(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function fg(e,t){const n=i0(e);return Math.round(t*n)/n}function gd(e){const t=d.useRef(e);return wc(()=>{t.current=e}),t}function zh(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:a,floating:i}={},transform:l=!0,whileElementsMounted:c,open:u}=e,[h,f]=d.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=d.useState(r);$c(p,r)||m(r);const[v,g]=d.useState(null),[x,w]=d.useState(null),y=d.useCallback(D=>{D!==I.current&&(I.current=D,g(D))},[]),C=d.useCallback(D=>{D!==b.current&&(b.current=D,w(D))},[]),S=a||v,j=i||x,I=d.useRef(null),b=d.useRef(null),k=d.useRef(h),N=c!=null,A=gd(c),P=gd(s),E=gd(u),R=d.useCallback(()=>{if(!I.current||!b.current)return;const D={placement:t,strategy:n,middleware:p};P.current&&(D.platform=P.current),rT(I.current,b.current,D).then(O=>{const K={...O,isPositioned:E.current!==!1};_.current&&!$c(k.current,K)&&(k.current=K,ti.flushSync(()=>{f(K)}))})},[p,t,n,P,E]);wc(()=>{u===!1&&k.current.isPositioned&&(k.current.isPositioned=!1,f(D=>({...D,isPositioned:!1})))},[u]);const _=d.useRef(!1);wc(()=>(_.current=!0,()=>{_.current=!1}),[]),wc(()=>{if(S&&(I.current=S),j&&(b.current=j),S&&j){if(A.current)return A.current(S,j,R);R()}},[S,j,R,A,N]);const M=d.useMemo(()=>({reference:I,floating:b,setReference:y,setFloating:C}),[y,C]),L=d.useMemo(()=>({reference:S,floating:j}),[S,j]),F=d.useMemo(()=>{const D={position:n,left:0,top:0};if(!L.floating)return D;const O=fg(L.floating,h.x),K=fg(L.floating,h.y);return l?{...D,transform:"translate("+O+"px, "+K+"px)",...i0(L.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:O,top:K}},[n,l,L.floating,h.x,h.y]);return d.useMemo(()=>({...h,update:R,refs:M,elements:L,floatingStyles:F}),[h,R,M,L,F])}const aT=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:s}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?dg({element:r.current,padding:s}).fn(n):{}:r?dg({element:r,padding:s}).fn(n):{}}}},$h=(e,t)=>({...XN(e),options:[e,t]}),Uh=(e,t)=>({...JN(e),options:[e,t]}),Bh=(e,t)=>({...nT(e),options:[e,t]}),Vh=(e,t)=>({...QN(e),options:[e,t]}),Hh=(e,t)=>({...eT(e),options:[e,t]}),Wh=(e,t)=>({...tT(e),options:[e,t]}),Zh=(e,t)=>({...aT(e),options:[e,t]});var iT="Arrow",l0=d.forwardRef((e,t)=>{const{children:n,width:r=10,height:s=5,...a}=e;return o.jsx(ct.svg,{...a,ref:t,width:r,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:o.jsx("polygon",{points:"0,0 30,0 15,10"})})});l0.displayName=iT;var Gh=l0;function qh(e){const[t,n]=d.useState(void 0);return dn(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const a=s[0];let i,l;if("borderBoxSize"in a){const c=a.borderBoxSize,u=Array.isArray(c)?c[0]:c;i=u.inlineSize,l=u.blockSize}else i=e.offsetWidth,l=e.offsetHeight;n({width:i,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Yh="Popper",[c0,u0]=pr(Yh),[lT,d0]=c0(Yh),f0=e=>{const{__scopePopper:t,children:n}=e,[r,s]=d.useState(null);return o.jsx(lT,{scope:t,anchor:r,onAnchorChange:s,children:n})};f0.displayName=Yh;var h0="PopperAnchor",m0=d.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...s}=e,a=d0(h0,n),i=d.useRef(null),l=yt(t,i);return d.useEffect(()=>{a.onAnchorChange((r==null?void 0:r.current)||i.current)}),r?null:o.jsx(ct.div,{...s,ref:l})});m0.displayName=h0;var Kh="PopperContent",[cT,uT]=c0(Kh),p0=d.forwardRef((e,t)=>{var z,Z,J,ce,de,fe;const{__scopePopper:n,side:r="bottom",sideOffset:s=0,align:a="center",alignOffset:i=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:h=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:v,...g}=e,x=d0(Kh,n),[w,y]=d.useState(null),C=yt(t,ge=>y(ge)),[S,j]=d.useState(null),I=qh(S),b=(I==null?void 0:I.width)??0,k=(I==null?void 0:I.height)??0,N=r+(a!=="center"?"-"+a:""),A=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},P=Array.isArray(u)?u:[u],E=P.length>0,R={padding:A,boundary:P.filter(fT),altBoundary:E},{refs:_,floatingStyles:M,placement:L,isPositioned:F,middlewareData:D}=zh({strategy:"fixed",placement:N,whileElementsMounted:(...ge)=>Fh(...ge,{animationFrame:m==="always"}),elements:{reference:x.anchor},middleware:[$h({mainAxis:s+k,alignmentAxis:i}),c&&Uh({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Bh():void 0,...R}),c&&Vh({...R}),Hh({...R,apply:({elements:ge,rects:T,availableWidth:le,availableHeight:ie})=>{const{width:q,height:B}=T.reference,ee=ge.floating.style;ee.setProperty("--radix-popper-available-width",`${le}px`),ee.setProperty("--radix-popper-available-height",`${ie}px`),ee.setProperty("--radix-popper-anchor-width",`${q}px`),ee.setProperty("--radix-popper-anchor-height",`${B}px`)}}),S&&Zh({element:S,padding:l}),hT({arrowWidth:b,arrowHeight:k}),p&&Wh({strategy:"referenceHidden",...R})]}),[O,K]=v0(L),$=Dn(v);dn(()=>{F&&($==null||$())},[F,$]);const W=(z=D.arrow)==null?void 0:z.x,V=(Z=D.arrow)==null?void 0:Z.y,X=((J=D.arrow)==null?void 0:J.centerOffset)!==0,[H,Q]=d.useState();return dn(()=>{w&&Q(window.getComputedStyle(w).zIndex)},[w]),o.jsx("div",{ref:_.setFloating,"data-radix-popper-content-wrapper":"",style:{...M,transform:F?M.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:H,"--radix-popper-transform-origin":[(ce=D.transformOrigin)==null?void 0:ce.x,(de=D.transformOrigin)==null?void 0:de.y].join(" "),...((fe=D.hide)==null?void 0:fe.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:o.jsx(cT,{scope:n,placedSide:O,onArrowChange:j,arrowX:W,arrowY:V,shouldHideArrow:X,children:o.jsx(ct.div,{"data-side":O,"data-align":K,...g,ref:C,style:{...g.style,animation:F?void 0:"none"}})})})});p0.displayName=Kh;var g0="PopperArrow",dT={top:"bottom",right:"left",bottom:"top",left:"right"},x0=d.forwardRef(function(t,n){const{__scopePopper:r,...s}=t,a=uT(g0,r),i=dT[a.placedSide];return o.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:o.jsx(Gh,{...s,ref:n,style:{...s.style,display:"block"}})})});x0.displayName=g0;function fT(e){return e!==null}var hT=e=>({name:"transformOrigin",options:e,fn(t){var x,w,y;const{placement:n,rects:r,middlewareData:s}=t,i=((x=s.arrow)==null?void 0:x.centerOffset)!==0,l=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,h]=v0(n),f={start:"0%",center:"50%",end:"100%"}[h],p=(((w=s.arrow)==null?void 0:w.x)??0)+l/2,m=(((y=s.arrow)==null?void 0:y.y)??0)+c/2;let v="",g="";return u==="bottom"?(v=i?f:`${p}px`,g=`${-c}px`):u==="top"?(v=i?f:`${p}px`,g=`${r.floating.height+c}px`):u==="right"?(v=`${-c}px`,g=i?f:`${m}px`):u==="left"&&(v=`${r.floating.width+c}px`,g=i?f:`${m}px`),{data:{x:v,y:g}}}});function v0(e){const[t,n="center"]=e.split("-");return[t,n]}var mT=f0,pT=m0,gT=p0,xT=x0,vT="Portal",li=d.forwardRef((e,t)=>{var l;const{container:n,...r}=e,[s,a]=d.useState(!1);dn(()=>a(!0),[]);const i=n||s&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return i?i_.createPortal(o.jsx(ct.div,{...r,ref:t}),i):null});li.displayName=vT;function wT(e,t){return d.useReducer((n,r)=>t[n][r]??n,e)}var Fs=e=>{const{present:t,children:n}=e,r=yT(t),s=typeof n=="function"?n({present:r.isPresent}):d.Children.only(n),a=yt(r.ref,bT(s));return typeof n=="function"||r.isPresent?d.cloneElement(s,{ref:a}):null};Fs.displayName="Presence";function yT(e){const[t,n]=d.useState(),r=d.useRef(null),s=d.useRef(e),a=d.useRef("none"),i=e?"mounted":"unmounted",[l,c]=wT(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{const u=Zl(r.current);a.current=l==="mounted"?u:"none"},[l]),dn(()=>{const u=r.current,h=s.current;if(h!==e){const p=a.current,m=Zl(u);e?c("MOUNT"):m==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(h&&p!==m?"ANIMATION_OUT":"UNMOUNT"),s.current=e}},[e,c]),dn(()=>{if(t){let u;const h=t.ownerDocument.defaultView??window,f=m=>{const g=Zl(r.current).includes(m.animationName);if(m.target===t&&g&&(c("ANIMATION_END"),!s.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",u=h.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},p=m=>{m.target===t&&(a.current=Zl(r.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{h.clearTimeout(u),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:d.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function Zl(e){return(e==null?void 0:e.animationName)||"none"}function bT(e){var r,s;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var CT=iu[" useInsertionEffect ".trim().toString()]||dn;function Ds({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[s,a,i]=ST({defaultProp:t,onChange:n}),l=e!==void 0,c=l?e:s;{const h=d.useRef(e!==void 0);d.useEffect(()=>{const f=h.current;f!==l&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),h.current=l},[l,r])}const u=d.useCallback(h=>{var f;if(l){const p=_T(h)?h(e):h;p!==e&&((f=i.current)==null||f.call(i,p))}else a(h)},[l,e,a,i]);return[c,u]}function ST({defaultProp:e,onChange:t}){const[n,r]=d.useState(e),s=d.useRef(n),a=d.useRef(t);return CT(()=>{a.current=t},[t]),d.useEffect(()=>{var i;s.current!==n&&((i=a.current)==null||i.call(a,n),s.current=n)},[n,s]),[n,r,a]}function _T(e){return typeof e=="function"}var w0=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),kT="VisuallyHidden",ju=d.forwardRef((e,t)=>o.jsx(ct.span,{...e,ref:t,style:{...w0,...e.style}}));ju.displayName=kT;var jT=ju,[Eu,CU]=pr("Tooltip",[u0]),Nu=u0(),y0="TooltipProvider",ET=700,jf="tooltip.open",[NT,Xh]=Eu(y0),b0=e=>{const{__scopeTooltip:t,delayDuration:n=ET,skipDelayDuration:r=300,disableHoverableContent:s=!1,children:a}=e,i=d.useRef(!0),l=d.useRef(!1),c=d.useRef(0);return d.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),o.jsx(NT,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:d.useCallback(()=>{window.clearTimeout(c.current),i.current=!1},[]),onClose:d.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:d.useCallback(u=>{l.current=u},[]),disableHoverableContent:s,children:a})};b0.displayName=y0;var qi="Tooltip",[TT,pl]=Eu(qi),C0=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:s,onOpenChange:a,disableHoverableContent:i,delayDuration:l}=e,c=Xh(qi,e.__scopeTooltip),u=Nu(t),[h,f]=d.useState(null),p=dr(),m=d.useRef(0),v=i??c.disableHoverableContent,g=l??c.delayDuration,x=d.useRef(!1),[w,y]=Ds({prop:r,defaultProp:s??!1,onChange:b=>{b?(c.onOpen(),document.dispatchEvent(new CustomEvent(jf))):c.onClose(),a==null||a(b)},caller:qi}),C=d.useMemo(()=>w?x.current?"delayed-open":"instant-open":"closed",[w]),S=d.useCallback(()=>{window.clearTimeout(m.current),m.current=0,x.current=!1,y(!0)},[y]),j=d.useCallback(()=>{window.clearTimeout(m.current),m.current=0,y(!1)},[y]),I=d.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{x.current=!0,y(!0),m.current=0},g)},[g,y]);return d.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),o.jsx(mT,{...u,children:o.jsx(TT,{scope:t,contentId:p,open:w,stateAttribute:C,trigger:h,onTriggerChange:f,onTriggerEnter:d.useCallback(()=>{c.isOpenDelayedRef.current?I():S()},[c.isOpenDelayedRef,I,S]),onTriggerLeave:d.useCallback(()=>{v?j():(window.clearTimeout(m.current),m.current=0)},[j,v]),onOpen:S,onClose:j,disableHoverableContent:v,children:n})})};C0.displayName=qi;var Ef="TooltipTrigger",S0=d.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,s=pl(Ef,n),a=Xh(Ef,n),i=Nu(n),l=d.useRef(null),c=yt(t,l,s.onTriggerChange),u=d.useRef(!1),h=d.useRef(!1),f=d.useCallback(()=>u.current=!1,[]);return d.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),o.jsx(pT,{asChild:!0,...i,children:o.jsx(ct.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...r,ref:c,onPointerMove:Gt(e.onPointerMove,p=>{p.pointerType!=="touch"&&!h.current&&!a.isPointerInTransitRef.current&&(s.onTriggerEnter(),h.current=!0)}),onPointerLeave:Gt(e.onPointerLeave,()=>{s.onTriggerLeave(),h.current=!1}),onPointerDown:Gt(e.onPointerDown,()=>{s.open&&s.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Gt(e.onFocus,()=>{u.current||s.onOpen()}),onBlur:Gt(e.onBlur,s.onClose),onClick:Gt(e.onClick,s.onClose)})})});S0.displayName=Ef;var Jh="TooltipPortal",[AT,IT]=Eu(Jh,{forceMount:void 0}),_0=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:s}=e,a=pl(Jh,t);return o.jsx(AT,{scope:t,forceMount:n,children:o.jsx(Fs,{present:n||a.open,children:o.jsx(li,{asChild:!0,container:s,children:r})})})};_0.displayName=Jh;var Wa="TooltipContent",k0=d.forwardRef((e,t)=>{const n=IT(Wa,e.__scopeTooltip),{forceMount:r=n.forceMount,side:s="top",...a}=e,i=pl(Wa,e.__scopeTooltip);return o.jsx(Fs,{present:r||i.open,children:i.disableHoverableContent?o.jsx(j0,{side:s,...a,ref:t}):o.jsx(RT,{side:s,...a,ref:t})})}),RT=d.forwardRef((e,t)=>{const n=pl(Wa,e.__scopeTooltip),r=Xh(Wa,e.__scopeTooltip),s=d.useRef(null),a=yt(t,s),[i,l]=d.useState(null),{trigger:c,onClose:u}=n,h=s.current,{onPointerInTransitChange:f}=r,p=d.useCallback(()=>{l(null),f(!1)},[f]),m=d.useCallback((v,g)=>{const x=v.currentTarget,w={x:v.clientX,y:v.clientY},y=OT(w,x.getBoundingClientRect()),C=LT(w,y),S=FT(g.getBoundingClientRect()),j=$T([...C,...S]);l(j),f(!0)},[f]);return d.useEffect(()=>()=>p(),[p]),d.useEffect(()=>{if(c&&h){const v=x=>m(x,h),g=x=>m(x,c);return c.addEventListener("pointerleave",v),h.addEventListener("pointerleave",g),()=>{c.removeEventListener("pointerleave",v),h.removeEventListener("pointerleave",g)}}},[c,h,m,p]),d.useEffect(()=>{if(i){const v=g=>{const x=g.target,w={x:g.clientX,y:g.clientY},y=(c==null?void 0:c.contains(x))||(h==null?void 0:h.contains(x)),C=!zT(w,i);y?p():C&&(p(),u())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[c,h,i,u,p]),o.jsx(j0,{...e,ref:a})}),[PT,MT]=Eu(qi,{isInside:!1}),DT=mE("TooltipContent"),j0=d.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":s,onEscapeKeyDown:a,onPointerDownOutside:i,...l}=e,c=pl(Wa,n),u=Nu(n),{onClose:h}=c;return d.useEffect(()=>(document.addEventListener(jf,h),()=>document.removeEventListener(jf,h)),[h]),d.useEffect(()=>{if(c.trigger){const f=p=>{const m=p.target;m!=null&&m.contains(c.trigger)&&h()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,h]),o.jsx(bu,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:f=>f.preventDefault(),onDismiss:h,children:o.jsxs(gT,{"data-state":c.stateAttribute,...u,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[o.jsx(DT,{children:r}),o.jsx(PT,{scope:n,isInside:!0,children:o.jsx(jT,{id:c.contentId,role:"tooltip",children:s||r})})]})})});k0.displayName=Wa;var E0="TooltipArrow",N0=d.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,s=Nu(n);return MT(E0,n).isInside?null:o.jsx(xT,{...s,...r,ref:t})});N0.displayName=E0;function OT(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),s=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,s,a)){case a:return"left";case s:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function LT(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function FT(e){const{top:t,right:n,bottom:r,left:s}=e;return[{x:s,y:t},{x:n,y:t},{x:n,y:r},{x:s,y:r}]}function zT(e,t){const{x:n,y:r}=e;let s=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const l=t[a],c=t[i],u=l.x,h=l.y,f=c.x,p=c.y;h>r!=p>r&&n<(f-u)*(r-h)/(p-h)+u&&(s=!s)}return s}function $T(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),UT(t)}function UT(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const s=e[r];for(;t.length>=2;){const a=t[t.length-1],i=t[t.length-2];if((a.x-i.x)*(s.y-i.y)>=(a.y-i.y)*(s.x-i.x))t.pop();else break}t.push(s)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const s=e[r];for(;n.length>=2;){const a=n[n.length-1],i=n[n.length-2];if((a.x-i.x)*(s.y-i.y)>=(a.y-i.y)*(s.x-i.x))n.pop();else break}n.push(s)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var BT=b0,VT=C0,HT=S0,WT=_0,ZT=k0,GT=N0;function qT({delayDuration:e=0,...t}){return o.jsx(BT,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function zs({...e}){return o.jsx(qT,{delayDuration:500,children:o.jsx(VT,{"data-slot":"tooltip",...e})})}function $s({...e}){return o.jsx(HT,{"data-slot":"tooltip-trigger",...e})}function Us({className:e,sideOffset:t=0,children:n,...r}){return o.jsx(WT,{children:o.jsxs(ZT,{"data-slot":"tooltip-content",sideOffset:t,className:Ue("bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...r,children:[n,o.jsx(GT,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const T0="text-[var(--color-primary-wMain)] enabled:hover:text-[var(--color-primary-w60)] dark:text-[var(--color-primary-w10)] dark:enabled:hover:text-[var(--color-white)]",xd=T0+" enabled:hover:bg-[var(--color-primary-w10)] dark:enabled:hover:bg-[var(--color-primary-w60)]",YT=Co("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-sm font-semibold transition-all disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 cursor-pointer disabled:cursor-not-allowed",{variants:{variant:{default:"text-[var(--color-primary-w10)] bg-[var(--color-primary-wMain)] enabled:hover:text-[var(--color-white)] enabled:hover:bg-[var(--color-primary-w100)] dark:enabled:hover:bg-[var(--color-primary-w60)]",destructive:"text-[var(--color-white)] bg-[var(--color-error-wMain)] enabled:hover:bg-[var(--color-error-w70)]",outline:xd+" border border-1 border-[var(--color-primary-wMain)]",secondary:xd,ghost:xd,link:T0+" underline-offset-4 enabled:hover:underline"},size:{default:"h-9 px-5 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function ye({className:e,variant:t,size:n,asChild:r=!1,tooltip:s="",tooltipSide:a,testid:i="",...l}){const c=r?kw:"button",u=s?{...l,"aria-label":s}:l,h=o.jsx(c,{"data-slot":"button","data-testid":i||s||l.title,className:Ue(YT({variant:t,size:n,className:e})),...u});return s?o.jsxs(zs,{children:[o.jsx($s,{asChild:!0,children:h}),o.jsx(Us,{side:a,children:s})]}):h}const A0=({onClick:e,text:t="View Agent Workflow"})=>o.jsx(ye,{"data-testid":"viewAgentWorkflow",variant:"ghost",size:"sm",onClick:e,tooltip:t,children:o.jsx(pc,{className:"h-4 w-4"})}),ts=d.forwardRef(({className:e,...t},n)=>o.jsx("textarea",{className:Ue("flex min-h-[80px] w-full rounded-xs border px-3 py-2 placeholder:opacity-75 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));ts.displayName="Textarea";const I0=d.forwardRef(({className:e,value:t,highlightPattern:n=/(\{\{[^}]+\}\})/g,highlightClassName:r="bg-primary/20 text-primary rounded px-0.5",...s},a)=>{const i=d.useRef(null),l=d.useRef(null);d.useImperativeHandle(a,()=>l.current);const c=d.useCallback(()=>{i.current&&l.current&&(i.current.scrollTop=l.current.scrollTop,i.current.scrollLeft=l.current.scrollLeft)},[]),u=d.useCallback(f=>f?f.split(n).map((m,v)=>m.match(n)?o.jsx("mark",{className:r,children:m},v):o.jsx("span",{children:m},v)):null,[n,r]),h=typeof t=="string"?t:"";return o.jsxs("div",{className:"relative",children:[o.jsxs("div",{ref:i,className:Ue("pointer-events-none absolute inset-0 overflow-hidden break-words whitespace-pre-wrap","rounded-md border border-transparent px-3 py-2","font-mono text-sm",e),style:{lineHeight:"1.5",wordWrap:"break-word",overflowWrap:"break-word"},"aria-hidden":"true",children:[u(h),o.jsx("br",{})]}),o.jsx("textarea",{ref:l,className:Ue("relative z-10 flex min-h-[80px] w-full rounded-md border bg-transparent px-3 py-2","placeholder:opacity-75 disabled:cursor-not-allowed disabled:opacity-50","caret-foreground font-mono text-sm","text-transparent",e),style:{lineHeight:"1.5",caretColor:"var(--foreground)",WebkitTextFillColor:"transparent"},value:t,onScroll:c,...s})]})});I0.displayName="HighlightedTextarea";function _r({className:e,type:t,...n}){return o.jsx("input",{type:t,"data-slot":"input",className:Ue("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-xs border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","outline-none focus-visible:border-[var(--color-brand-wMain)]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...n})}const Qh=({value:e,onChange:t,placeholder:n="Filter by name...",testid:r,className:s=""})=>o.jsxs("div",{className:`relative ${s}`,children:[o.jsx(co,{className:"text-muted-foreground absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2"}),o.jsx("input",{type:"text","data-testid":r,placeholder:n,value:e,onChange:a=>t(a.target.value),className:"bg-background w-xs rounded-md border py-2 pr-3 pl-9"})]});var KT="Label",R0=d.forwardRef((e,t)=>o.jsx(ct.label,{...e,ref:t,onMouseDown:n=>{var s;n.target.closest("button, input, select, textarea")||((s=e.onMouseDown)==null||s.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));R0.displayName=KT;var XT=R0;function zt({className:e,...t}){return o.jsx(XT,{"data-slot":"label",className:Ue("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}function JT({className:e,noPadding:t,...n}){return o.jsx("div",{"data-slot":"card",className:Ue("bg-card text-card-foreground flex flex-col gap-6 rounded-lg border shadow-[0_4px_6px_-1px_rgba(0,0,0,0.15)] dark:shadow-[0_4px_6px_-1px_rgba(255,255,255,0.1)]",!t&&"py-6",e),...n})}function QT({className:e,...t}){return o.jsx("div",{"data-slot":"card-header",className:Ue("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),...t})}function Na({className:e,...t}){return o.jsx("div",{"data-slot":"card-title",className:Ue("leading-none font-semibold",e),...t})}function eA({className:e,...t}){return o.jsx("div",{"data-slot":"card-description",className:Ue("text-muted-foreground text-sm",e),...t})}function P0({className:e,noPadding:t,...n}){return o.jsx("div",{"data-slot":"card-content",className:Ue(!t&&"px-6",e),...n})}var gl=e=>e.type==="checkbox",Ro=e=>e instanceof Date,er=e=>e==null;const M0=e=>typeof e=="object";var yn=e=>!er(e)&&!Array.isArray(e)&&M0(e)&&!Ro(e),tA=e=>yn(e)&&e.target?gl(e.target)?e.target.checked:e.target.value:e,nA=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,rA=(e,t)=>e.has(nA(t)),sA=e=>{const t=e.constructor&&e.constructor.prototype;return yn(t)&&t.hasOwnProperty("isPrototypeOf")},em=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Nn(e){let t;const n=Array.isArray(e),r=typeof FileList<"u"?e instanceof FileList:!1;if(e instanceof Date)t=new Date(e);else if(!(em&&(e instanceof Blob||r))&&(n||yn(e)))if(t=n?[]:Object.create(Object.getPrototypeOf(e)),!n&&!sA(e))t=e;else for(const s in e)e.hasOwnProperty(s)&&(t[s]=Nn(e[s]));else return e;return t}var Tu=e=>/^\w*$/.test(e),hn=e=>e===void 0,tm=e=>Array.isArray(e)?e.filter(Boolean):[],nm=e=>tm(e.replace(/["|']|\]/g,"").split(/\.|\[/)),Xe=(e,t,n)=>{if(!t||!yn(e))return n;const r=(Tu(t)?[t]:nm(t)).reduce((s,a)=>er(s)?s:s[a],e);return hn(r)||r===e?hn(e[t])?n:e[t]:r},os=e=>typeof e=="boolean",qt=(e,t,n)=>{let r=-1;const s=Tu(t)?[t]:nm(t),a=s.length,i=a-1;for(;++r<a;){const l=s[r];let c=n;if(r!==i){const u=e[l];c=yn(u)||Array.isArray(u)?u:isNaN(+s[r+1])?{}:[]}if(l==="__proto__"||l==="constructor"||l==="prototype")return;e[l]=c,e=e[l]}};const hg={BLUR:"blur",FOCUS_OUT:"focusout"},Br={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ks={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},oA=xt.createContext(null);oA.displayName="HookFormContext";var aA=(e,t,n,r=!0)=>{const s={defaultValues:t._defaultValues};for(const a in e)Object.defineProperty(s,a,{get:()=>{const i=a;return t._proxyFormState[i]!==Br.all&&(t._proxyFormState[i]=!r||Br.all),e[i]}});return s};const iA=typeof window<"u"?xt.useLayoutEffect:xt.useEffect;var cr=e=>typeof e=="string",lA=(e,t,n,r,s)=>cr(e)?(r&&t.watch.add(e),Xe(n,e,s)):Array.isArray(e)?e.map(a=>(r&&t.watch.add(a),Xe(n,a))):(r&&(t.watchAll=!0),n),Nf=e=>er(e)||!M0(e);function Xs(e,t,n=new WeakSet){if(Nf(e)||Nf(t))return e===t;if(Ro(e)&&Ro(t))return e.getTime()===t.getTime();const r=Object.keys(e),s=Object.keys(t);if(r.length!==s.length)return!1;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);for(const a of r){const i=e[a];if(!s.includes(a))return!1;if(a!=="ref"){const l=t[a];if(Ro(i)&&Ro(l)||yn(i)&&yn(l)||Array.isArray(i)&&Array.isArray(l)?!Xs(i,l,n):i!==l)return!1}}return!0}var rm=(e,t,n,r,s)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:s||!0}}:{},Di=e=>Array.isArray(e)?e:[e],mg=()=>{let e=[];return{get observers(){return e},next:s=>{for(const a of e)a.next&&a.next(s)},subscribe:s=>(e.push(s),{unsubscribe:()=>{e=e.filter(a=>a!==s)}}),unsubscribe:()=>{e=[]}}};function D0(e,t){const n={};for(const r in e)if(e.hasOwnProperty(r)){const s=e[r],a=t[r];if(s&&yn(s)&&a){const i=D0(s,a);yn(i)&&(n[r]=i)}else e[r]&&(n[r]=a)}return n}var Qn=e=>yn(e)&&!Object.keys(e).length,sm=e=>e.type==="file",Vr=e=>typeof e=="function",Uc=e=>{if(!em)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},O0=e=>e.type==="select-multiple",om=e=>e.type==="radio",cA=e=>om(e)||gl(e),vd=e=>Uc(e)&&e.isConnected;function uA(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=hn(e)?r++:e[t[r++]];return e}function dA(e){for(const t in e)if(e.hasOwnProperty(t)&&!hn(e[t]))return!1;return!0}function xn(e,t){const n=Array.isArray(t)?t:Tu(t)?[t]:nm(t),r=n.length===1?e:uA(e,n),s=n.length-1,a=n[s];return r&&delete r[a],s!==0&&(yn(r)&&Qn(r)||Array.isArray(r)&&dA(r))&&xn(e,n.slice(0,-1)),e}var fA=e=>{for(const t in e)if(Vr(e[t]))return!0;return!1};function L0(e){return Array.isArray(e)||yn(e)&&!fA(e)}function Tf(e,t={}){for(const n in e)L0(e[n])?(t[n]=Array.isArray(e[n])?[]:{},Tf(e[n],t[n])):hn(e[n])||(t[n]=!0);return t}function va(e,t,n){n||(n=Tf(t));for(const r in e)L0(e[r])?hn(t)||Nf(n[r])?n[r]=Tf(e[r],Array.isArray(e[r])?[]:{}):va(e[r],er(t)?{}:t[r],n[r]):n[r]=!Xs(e[r],t[r]);return n}const pg={value:!1,isValid:!1},gg={value:!0,isValid:!0};var F0=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!hn(e[0].attributes.value)?hn(e[0].value)||e[0].value===""?gg:{value:e[0].value,isValid:!0}:gg:pg}return pg},z0=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>hn(e)?e:t?e===""?NaN:e&&+e:n&&cr(e)?new Date(e):r?r(e):e;const xg={isValid:!1,value:null};var $0=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,xg):xg;function vg(e){const t=e.ref;return sm(t)?t.files:om(t)?$0(e.refs).value:O0(t)?[...t.selectedOptions].map(({value:n})=>n):gl(t)?F0(e.refs).value:z0(hn(t.value)?e.ref.value:t.value,e)}var hA=(e,t,n,r)=>{const s={};for(const a of e){const i=Xe(t,a);i&&qt(s,a,i._f)}return{criteriaMode:n,names:[...e],fields:s,shouldUseNativeValidation:r}},Bc=e=>e instanceof RegExp,xi=e=>hn(e)?e:Bc(e)?e.source:yn(e)?Bc(e.value)?e.value.source:e.value:e,wg=e=>({isOnSubmit:!e||e===Br.onSubmit,isOnBlur:e===Br.onBlur,isOnChange:e===Br.onChange,isOnAll:e===Br.all,isOnTouch:e===Br.onTouched});const yg="AsyncFunction";var mA=e=>!!e&&!!e.validate&&!!(Vr(e.validate)&&e.validate.constructor.name===yg||yn(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===yg)),pA=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),bg=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const Oi=(e,t,n,r)=>{for(const s of n||Object.keys(e)){const a=Xe(e,s);if(a){const{_f:i,...l}=a;if(i){if(i.refs&&i.refs[0]&&t(i.refs[0],s)&&!r)return!0;if(i.ref&&t(i.ref,i.name)&&!r)return!0;if(Oi(l,t))break}else if(yn(l)&&Oi(l,t))break}}};function Cg(e,t,n){const r=Xe(e,n);if(r||Tu(n))return{error:r,name:n};const s=n.split(".");for(;s.length;){const a=s.join("."),i=Xe(t,a),l=Xe(e,a);if(i&&!Array.isArray(i)&&n!==a)return{name:n};if(l&&l.type)return{name:a,error:l};if(l&&l.root&&l.root.type)return{name:`${a}.root`,error:l.root};s.pop()}return{name:n}}var gA=(e,t,n,r)=>{n(e);const{name:s,...a}=e;return Qn(a)||Object.keys(a).length>=Object.keys(t).length||Object.keys(a).find(i=>t[i]===(!r||Br.all))},xA=(e,t,n)=>!e||!t||e===t||Di(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r))),vA=(e,t,n,r,s)=>s.isOnAll?!1:!n&&s.isOnTouch?!(t||e):(n?r.isOnBlur:s.isOnBlur)?!e:(n?r.isOnChange:s.isOnChange)?e:!0,wA=(e,t)=>!tm(Xe(e,t)).length&&xn(e,t),yA=(e,t,n)=>{const r=Di(Xe(e,n));return qt(r,"root",t[n]),qt(e,n,r),e};function Sg(e,t,n="validate"){if(cr(e)||Array.isArray(e)&&e.every(cr)||os(e)&&!e)return{type:n,message:cr(e)?e:"",ref:t}}var ua=e=>yn(e)&&!Bc(e)?e:{value:e,message:""},_g=async(e,t,n,r,s,a)=>{const{ref:i,refs:l,required:c,maxLength:u,minLength:h,min:f,max:p,pattern:m,validate:v,name:g,valueAsNumber:x,mount:w}=e._f,y=Xe(n,g);if(!w||t.has(g))return{};const C=l?l[0]:i,S=E=>{s&&C.reportValidity&&(C.setCustomValidity(os(E)?"":E||""),C.reportValidity())},j={},I=om(i),b=gl(i),k=I||b,N=(x||sm(i))&&hn(i.value)&&hn(y)||Uc(i)&&i.value===""||y===""||Array.isArray(y)&&!y.length,A=rm.bind(null,g,r,j),P=(E,R,_,M=ks.maxLength,L=ks.minLength)=>{const F=E?R:_;j[g]={type:E?M:L,message:F,ref:i,...A(E?M:L,F)}};if(a?!Array.isArray(y)||!y.length:c&&(!k&&(N||er(y))||os(y)&&!y||b&&!F0(l).isValid||I&&!$0(l).isValid)){const{value:E,message:R}=cr(c)?{value:!!c,message:c}:ua(c);if(E&&(j[g]={type:ks.required,message:R,ref:C,...A(ks.required,R)},!r))return S(R),j}if(!N&&(!er(f)||!er(p))){let E,R;const _=ua(p),M=ua(f);if(!er(y)&&!isNaN(y)){const L=i.valueAsNumber||y&&+y;er(_.value)||(E=L>_.value),er(M.value)||(R=L<M.value)}else{const L=i.valueAsDate||new Date(y),F=K=>new Date(new Date().toDateString()+" "+K),D=i.type=="time",O=i.type=="week";cr(_.value)&&y&&(E=D?F(y)>F(_.value):O?y>_.value:L>new Date(_.value)),cr(M.value)&&y&&(R=D?F(y)<F(M.value):O?y<M.value:L<new Date(M.value))}if((E||R)&&(P(!!E,_.message,M.message,ks.max,ks.min),!r))return S(j[g].message),j}if((u||h)&&!N&&(cr(y)||a&&Array.isArray(y))){const E=ua(u),R=ua(h),_=!er(E.value)&&y.length>+E.value,M=!er(R.value)&&y.length<+R.value;if((_||M)&&(P(_,E.message,R.message),!r))return S(j[g].message),j}if(m&&!N&&cr(y)){const{value:E,message:R}=ua(m);if(Bc(E)&&!y.match(E)&&(j[g]={type:ks.pattern,message:R,ref:i,...A(ks.pattern,R)},!r))return S(R),j}if(v){if(Vr(v)){const E=await v(y,n),R=Sg(E,C);if(R&&(j[g]={...R,...A(ks.validate,R.message)},!r))return S(R.message),j}else if(yn(v)){let E={};for(const R in v){if(!Qn(E)&&!r)break;const _=Sg(await v[R](y,n),C,R);_&&(E={..._,...A(R,_.message)},S(_.message),r&&(j[g]=E))}if(!Qn(E)&&(j[g]={ref:C,...E},!r))return j}}return S(!0),j};const bA={mode:Br.onSubmit,reValidateMode:Br.onChange,shouldFocusError:!0};function CA(e={}){let t={...bA,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:Vr(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},s=yn(t.defaultValues)||yn(t.values)?Nn(t.defaultValues||t.values)||{}:{},a=t.shouldUnregister?{}:Nn(s),i={action:!1,mount:!1,watch:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,u=0;const h={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let f={...h};const p={array:mg(),state:mg()},m=t.criteriaMode===Br.all,v=U=>Y=>{clearTimeout(u),u=setTimeout(U,Y)},g=async U=>{if(!t.disabled&&(h.isValid||f.isValid||U)){const Y=t.resolver?Qn((await b()).errors):await N(r,!0);Y!==n.isValid&&p.state.next({isValid:Y})}},x=(U,Y)=>{!t.disabled&&(h.isValidating||h.validatingFields||f.isValidating||f.validatingFields)&&((U||Array.from(l.mount)).forEach(G=>{G&&(Y?qt(n.validatingFields,G,Y):xn(n.validatingFields,G))}),p.state.next({validatingFields:n.validatingFields,isValidating:!Qn(n.validatingFields)}))},w=(U,Y=[],G,ae,oe=!0,se=!0)=>{if(ae&&G&&!t.disabled){if(i.action=!0,se&&Array.isArray(Xe(r,U))){const me=G(Xe(r,U),ae.argA,ae.argB);oe&&qt(r,U,me)}if(se&&Array.isArray(Xe(n.errors,U))){const me=G(Xe(n.errors,U),ae.argA,ae.argB);oe&&qt(n.errors,U,me),wA(n.errors,U)}if((h.touchedFields||f.touchedFields)&&se&&Array.isArray(Xe(n.touchedFields,U))){const me=G(Xe(n.touchedFields,U),ae.argA,ae.argB);oe&&qt(n.touchedFields,U,me)}(h.dirtyFields||f.dirtyFields)&&(n.dirtyFields=va(s,a)),p.state.next({name:U,isDirty:P(U,Y),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else qt(a,U,Y)},y=(U,Y)=>{qt(n.errors,U,Y),p.state.next({errors:n.errors})},C=U=>{n.errors=U,p.state.next({errors:n.errors,isValid:!1})},S=(U,Y,G,ae)=>{const oe=Xe(r,U);if(oe){const se=Xe(a,U,hn(G)?Xe(s,U):G);hn(se)||ae&&ae.defaultChecked||Y?qt(a,U,Y?se:vg(oe._f)):_(U,se),i.mount&&g()}},j=(U,Y,G,ae,oe)=>{let se=!1,me=!1;const Pe={name:U};if(!t.disabled){if(!G||ae){(h.isDirty||f.isDirty)&&(me=n.isDirty,n.isDirty=Pe.isDirty=P(),se=me!==Pe.isDirty);const Ne=Xs(Xe(s,U),Y);me=!!Xe(n.dirtyFields,U),Ne?xn(n.dirtyFields,U):qt(n.dirtyFields,U,!0),Pe.dirtyFields=n.dirtyFields,se=se||(h.dirtyFields||f.dirtyFields)&&me!==!Ne}if(G){const Ne=Xe(n.touchedFields,U);Ne||(qt(n.touchedFields,U,G),Pe.touchedFields=n.touchedFields,se=se||(h.touchedFields||f.touchedFields)&&Ne!==G)}se&&oe&&p.state.next(Pe)}return se?Pe:{}},I=(U,Y,G,ae)=>{const oe=Xe(n.errors,U),se=(h.isValid||f.isValid)&&os(Y)&&n.isValid!==Y;if(t.delayError&&G?(c=v(()=>y(U,G)),c(t.delayError)):(clearTimeout(u),c=null,G?qt(n.errors,U,G):xn(n.errors,U)),(G?!Xs(oe,G):oe)||!Qn(ae)||se){const me={...ae,...se&&os(Y)?{isValid:Y}:{},errors:n.errors,name:U};n={...n,...me},p.state.next(me)}},b=async U=>{x(U,!0);const Y=await t.resolver(a,t.context,hA(U||l.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return x(U),Y},k=async U=>{const{errors:Y}=await b(U);if(U)for(const G of U){const ae=Xe(Y,G);ae?qt(n.errors,G,ae):xn(n.errors,G)}else n.errors=Y;return Y},N=async(U,Y,G={valid:!0})=>{for(const ae in U){const oe=U[ae];if(oe){const{_f:se,...me}=oe;if(se){const Pe=l.array.has(se.name),Ne=oe._f&&mA(oe._f);Ne&&h.validatingFields&&x([se.name],!0);const dt=await _g(oe,l.disabled,a,m,t.shouldUseNativeValidation&&!Y,Pe);if(Ne&&h.validatingFields&&x([se.name]),dt[se.name]&&(G.valid=!1,Y))break;!Y&&(Xe(dt,se.name)?Pe?yA(n.errors,dt,se.name):qt(n.errors,se.name,dt[se.name]):xn(n.errors,se.name))}!Qn(me)&&await N(me,Y,G)}}return G.valid},A=()=>{for(const U of l.unMount){const Y=Xe(r,U);Y&&(Y._f.refs?Y._f.refs.every(G=>!vd(G)):!vd(Y._f.ref))&&z(U)}l.unMount=new Set},P=(U,Y)=>!t.disabled&&(U&&Y&&qt(a,U,Y),!Xs(K(),s)),E=(U,Y,G)=>lA(U,l,{...i.mount?a:hn(Y)?s:cr(U)?{[U]:Y}:Y},G,Y),R=U=>tm(Xe(i.mount?a:s,U,t.shouldUnregister?Xe(s,U,[]):[])),_=(U,Y,G={})=>{const ae=Xe(r,U);let oe=Y;if(ae){const se=ae._f;se&&(!se.disabled&&qt(a,U,z0(Y,se)),oe=Uc(se.ref)&&er(Y)?"":Y,O0(se.ref)?[...se.ref.options].forEach(me=>me.selected=oe.includes(me.value)):se.refs?gl(se.ref)?se.refs.forEach(me=>{(!me.defaultChecked||!me.disabled)&&(Array.isArray(oe)?me.checked=!!oe.find(Pe=>Pe===me.value):me.checked=oe===me.value||!!oe)}):se.refs.forEach(me=>me.checked=me.value===oe):sm(se.ref)?se.ref.value="":(se.ref.value=oe,se.ref.type||p.state.next({name:U,values:Nn(a)})))}(G.shouldDirty||G.shouldTouch)&&j(U,oe,G.shouldTouch,G.shouldDirty,!0),G.shouldValidate&&O(U)},M=(U,Y,G)=>{for(const ae in Y){if(!Y.hasOwnProperty(ae))return;const oe=Y[ae],se=U+"."+ae,me=Xe(r,se);(l.array.has(U)||yn(oe)||me&&!me._f)&&!Ro(oe)?M(se,oe,G):_(se,oe,G)}},L=(U,Y,G={})=>{const ae=Xe(r,U),oe=l.array.has(U),se=Nn(Y);qt(a,U,se),oe?(p.array.next({name:U,values:Nn(a)}),(h.isDirty||h.dirtyFields||f.isDirty||f.dirtyFields)&&G.shouldDirty&&p.state.next({name:U,dirtyFields:va(s,a),isDirty:P(U,se)})):ae&&!ae._f&&!er(se)?M(U,se,G):_(U,se,G),bg(U,l)&&p.state.next({...n,name:U}),p.state.next({name:i.mount?U:void 0,values:Nn(a)})},F=async U=>{i.mount=!0;const Y=U.target;let G=Y.name,ae=!0;const oe=Xe(r,G),se=Ne=>{ae=Number.isNaN(Ne)||Ro(Ne)&&isNaN(Ne.getTime())||Xs(Ne,Xe(a,G,Ne))},me=wg(t.mode),Pe=wg(t.reValidateMode);if(oe){let Ne,dt;const Ht=Y.type?vg(oe._f):tA(U),wt=U.type===hg.BLUR||U.type===hg.FOCUS_OUT,Ot=!pA(oe._f)&&!t.resolver&&!Xe(n.errors,G)&&!oe._f.deps||vA(wt,Xe(n.touchedFields,G),n.isSubmitted,Pe,me),gt=bg(G,l,wt);qt(a,G,Ht),wt?(!Y||!Y.readOnly)&&(oe._f.onBlur&&oe._f.onBlur(U),c&&c(0)):oe._f.onChange&&oe._f.onChange(U);const Nt=j(G,Ht,wt),Jt=!Qn(Nt)||gt;if(!wt&&p.state.next({name:G,type:U.type,values:Nn(a)}),Ot)return(h.isValid||f.isValid)&&(t.mode==="onBlur"?wt&&g():wt||g()),Jt&&p.state.next({name:G,...gt?{}:Nt});if(!wt&>&&p.state.next({...n}),t.resolver){const{errors:Wt}=await b([G]);if(se(Ht),ae){const xe=Cg(n.errors,r,G),$e=Cg(Wt,r,xe.name||G);Ne=$e.error,G=$e.name,dt=Qn(Wt)}}else x([G],!0),Ne=(await _g(oe,l.disabled,a,m,t.shouldUseNativeValidation))[G],x([G]),se(Ht),ae&&(Ne?dt=!1:(h.isValid||f.isValid)&&(dt=await N(r,!0)));ae&&(oe._f.deps&&(!Array.isArray(oe._f.deps)||oe._f.deps.length>0)&&O(oe._f.deps),I(G,dt,Ne,Nt))}},D=(U,Y)=>{if(Xe(n.errors,Y)&&U.focus)return U.focus(),1},O=async(U,Y={})=>{let G,ae;const oe=Di(U);if(t.resolver){const se=await k(hn(U)?U:oe);G=Qn(se),ae=U?!oe.some(me=>Xe(se,me)):G}else U?(ae=(await Promise.all(oe.map(async se=>{const me=Xe(r,se);return await N(me&&me._f?{[se]:me}:me)}))).every(Boolean),!(!ae&&!n.isValid)&&g()):ae=G=await N(r);return p.state.next({...!cr(U)||(h.isValid||f.isValid)&&G!==n.isValid?{}:{name:U},...t.resolver||!U?{isValid:G}:{},errors:n.errors}),Y.shouldFocus&&!ae&&Oi(r,D,U?oe:l.mount),ae},K=(U,Y)=>{let G={...i.mount?a:s};return Y&&(G=D0(Y.dirtyFields?n.dirtyFields:n.touchedFields,G)),hn(U)?G:cr(U)?Xe(G,U):U.map(ae=>Xe(G,ae))},$=(U,Y)=>({invalid:!!Xe((Y||n).errors,U),isDirty:!!Xe((Y||n).dirtyFields,U),error:Xe((Y||n).errors,U),isValidating:!!Xe(n.validatingFields,U),isTouched:!!Xe((Y||n).touchedFields,U)}),W=U=>{U&&Di(U).forEach(Y=>xn(n.errors,Y)),p.state.next({errors:U?n.errors:{}})},V=(U,Y,G)=>{const ae=(Xe(r,U,{_f:{}})._f||{}).ref,oe=Xe(n.errors,U)||{},{ref:se,message:me,type:Pe,...Ne}=oe;qt(n.errors,U,{...Ne,...Y,ref:ae}),p.state.next({name:U,errors:n.errors,isValid:!1}),G&&G.shouldFocus&&ae&&ae.focus&&ae.focus()},X=(U,Y)=>Vr(U)?p.state.subscribe({next:G=>"values"in G&&U(E(void 0,Y),G)}):E(U,Y,!0),H=U=>p.state.subscribe({next:Y=>{xA(U.name,Y.name,U.exact)&&gA(Y,U.formState||h,q,U.reRenderRoot)&&U.callback({values:{...a},...n,...Y,defaultValues:s})}}).unsubscribe,Q=U=>(i.mount=!0,f={...f,...U.formState},H({...U,formState:f})),z=(U,Y={})=>{for(const G of U?Di(U):l.mount)l.mount.delete(G),l.array.delete(G),Y.keepValue||(xn(r,G),xn(a,G)),!Y.keepError&&xn(n.errors,G),!Y.keepDirty&&xn(n.dirtyFields,G),!Y.keepTouched&&xn(n.touchedFields,G),!Y.keepIsValidating&&xn(n.validatingFields,G),!t.shouldUnregister&&!Y.keepDefaultValue&&xn(s,G);p.state.next({values:Nn(a)}),p.state.next({...n,...Y.keepDirty?{isDirty:P()}:{}}),!Y.keepIsValid&&g()},Z=({disabled:U,name:Y})=>{(os(U)&&i.mount||U||l.disabled.has(Y))&&(U?l.disabled.add(Y):l.disabled.delete(Y))},J=(U,Y={})=>{let G=Xe(r,U);const ae=os(Y.disabled)||os(t.disabled);return qt(r,U,{...G||{},_f:{...G&&G._f?G._f:{ref:{name:U}},name:U,mount:!0,...Y}}),l.mount.add(U),G?Z({disabled:os(Y.disabled)?Y.disabled:t.disabled,name:U}):S(U,!0,Y.value),{...ae?{disabled:Y.disabled||t.disabled}:{},...t.progressive?{required:!!Y.required,min:xi(Y.min),max:xi(Y.max),minLength:xi(Y.minLength),maxLength:xi(Y.maxLength),pattern:xi(Y.pattern)}:{},name:U,onChange:F,onBlur:F,ref:oe=>{if(oe){J(U,Y),G=Xe(r,U);const se=hn(oe.value)&&oe.querySelectorAll&&oe.querySelectorAll("input,select,textarea")[0]||oe,me=cA(se),Pe=G._f.refs||[];if(me?Pe.find(Ne=>Ne===se):se===G._f.ref)return;qt(r,U,{_f:{...G._f,...me?{refs:[...Pe.filter(vd),se,...Array.isArray(Xe(s,U))?[{}]:[]],ref:{type:se.type,name:U}}:{ref:se}}}),S(U,!1,void 0,se)}else G=Xe(r,U,{}),G._f&&(G._f.mount=!1),(t.shouldUnregister||Y.shouldUnregister)&&!(rA(l.array,U)&&i.action)&&l.unMount.add(U)}}},ce=()=>t.shouldFocusError&&Oi(r,D,l.mount),de=U=>{os(U)&&(p.state.next({disabled:U}),Oi(r,(Y,G)=>{const ae=Xe(r,G);ae&&(Y.disabled=ae._f.disabled||U,Array.isArray(ae._f.refs)&&ae._f.refs.forEach(oe=>{oe.disabled=ae._f.disabled||U}))},0,!1))},fe=(U,Y)=>async G=>{let ae;G&&(G.preventDefault&&G.preventDefault(),G.persist&&G.persist());let oe=Nn(a);if(p.state.next({isSubmitting:!0}),t.resolver){const{errors:se,values:me}=await b();n.errors=se,oe=Nn(me)}else await N(r);if(l.disabled.size)for(const se of l.disabled)xn(oe,se);if(xn(n.errors,"root"),Qn(n.errors)){p.state.next({errors:{}});try{await U(oe,G)}catch(se){ae=se}}else Y&&await Y({...n.errors},G),ce(),setTimeout(ce);if(p.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Qn(n.errors)&&!ae,submitCount:n.submitCount+1,errors:n.errors}),ae)throw ae},ge=(U,Y={})=>{Xe(r,U)&&(hn(Y.defaultValue)?L(U,Nn(Xe(s,U))):(L(U,Y.defaultValue),qt(s,U,Nn(Y.defaultValue))),Y.keepTouched||xn(n.touchedFields,U),Y.keepDirty||(xn(n.dirtyFields,U),n.isDirty=Y.defaultValue?P(U,Nn(Xe(s,U))):P()),Y.keepError||(xn(n.errors,U),h.isValid&&g()),p.state.next({...n}))},T=(U,Y={})=>{const G=U?Nn(U):s,ae=Nn(G),oe=Qn(U),se=oe?s:ae;if(Y.keepDefaultValues||(s=G),!Y.keepValues){if(Y.keepDirtyValues){const me=new Set([...l.mount,...Object.keys(va(s,a))]);for(const Pe of Array.from(me))Xe(n.dirtyFields,Pe)?qt(se,Pe,Xe(a,Pe)):L(Pe,Xe(se,Pe))}else{if(em&&hn(U))for(const me of l.mount){const Pe=Xe(r,me);if(Pe&&Pe._f){const Ne=Array.isArray(Pe._f.refs)?Pe._f.refs[0]:Pe._f.ref;if(Uc(Ne)){const dt=Ne.closest("form");if(dt){dt.reset();break}}}}if(Y.keepFieldsRef)for(const me of l.mount)L(me,Xe(se,me));else r={}}a=t.shouldUnregister?Y.keepDefaultValues?Nn(s):{}:Nn(se),p.array.next({values:{...se}}),p.state.next({values:{...se}})}l={mount:Y.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},i.mount=!h.isValid||!!Y.keepIsValid||!!Y.keepDirtyValues,i.watch=!!t.shouldUnregister,p.state.next({submitCount:Y.keepSubmitCount?n.submitCount:0,isDirty:oe?!1:Y.keepDirty?n.isDirty:!!(Y.keepDefaultValues&&!Xs(U,s)),isSubmitted:Y.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:oe?{}:Y.keepDirtyValues?Y.keepDefaultValues&&a?va(s,a):n.dirtyFields:Y.keepDefaultValues&&U?va(s,U):Y.keepDirty?n.dirtyFields:{},touchedFields:Y.keepTouched?n.touchedFields:{},errors:Y.keepErrors?n.errors:{},isSubmitSuccessful:Y.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},le=(U,Y)=>T(Vr(U)?U(a):U,Y),ie=(U,Y={})=>{const G=Xe(r,U),ae=G&&G._f;if(ae){const oe=ae.refs?ae.refs[0]:ae.ref;oe.focus&&(oe.focus(),Y.shouldSelect&&Vr(oe.select)&&oe.select())}},q=U=>{n={...n,...U}},ee={control:{register:J,unregister:z,getFieldState:$,handleSubmit:fe,setError:V,_subscribe:H,_runSchema:b,_focusError:ce,_getWatch:E,_getDirty:P,_setValid:g,_setFieldArray:w,_setDisabledField:Z,_setErrors:C,_getFieldArray:R,_reset:T,_resetDefaultValues:()=>Vr(t.defaultValues)&&t.defaultValues().then(U=>{le(U,t.resetOptions),p.state.next({isLoading:!1})}),_removeUnmounted:A,_disableForm:de,_subjects:p,_proxyFormState:h,get _fields(){return r},get _formValues(){return a},get _state(){return i},set _state(U){i=U},get _defaultValues(){return s},get _names(){return l},set _names(U){l=U},get _formState(){return n},get _options(){return t},set _options(U){t={...t,...U}}},subscribe:Q,trigger:O,register:J,handleSubmit:fe,watch:X,setValue:L,getValues:K,reset:le,resetField:ge,clearErrors:W,unregister:z,setError:V,setFocus:ie,getFieldState:$};return{...ee,formControl:ee}}function SA(e={}){const t=xt.useRef(void 0),n=xt.useRef(void 0),[r,s]=xt.useState({isDirty:!1,isValidating:!1,isLoading:Vr(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:Vr(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!Vr(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:i,...l}=CA(e);t.current={...l,formState:r}}const a=t.current.control;return a._options=e,iA(()=>{const i=a._subscribe({formState:a._proxyFormState,callback:()=>s({...a._formState}),reRenderRoot:!0});return s(l=>({...l,isReady:!0})),a._formState.isReady=!0,i},[a]),xt.useEffect(()=>a._disableForm(e.disabled),[a,e.disabled]),xt.useEffect(()=>{e.mode&&(a._options.mode=e.mode),e.reValidateMode&&(a._options.reValidateMode=e.reValidateMode)},[a,e.mode,e.reValidateMode]),xt.useEffect(()=>{e.errors&&(a._setErrors(e.errors),a._focusError())},[a,e.errors]),xt.useEffect(()=>{e.shouldUnregister&&a._subjects.state.next({values:a._getWatch()})},[a,e.shouldUnregister]),xt.useEffect(()=>{if(a._proxyFormState.isDirty){const i=a._getDirty();i!==r.isDirty&&a._subjects.state.next({isDirty:i})}},[a,r.isDirty]),xt.useEffect(()=>{e.values&&!Xs(e.values,n.current)?(a._reset(e.values,{keepFieldsRef:!0,...a._options.resetOptions}),n.current=e.values,s(i=>({...i}))):a._resetDefaultValues()},[a,e.values]),xt.useEffect(()=>{a._state.mount||(a._setValid(),a._state.mount=!0),a._state.watch&&(a._state.watch=!1,a._subjects.state.next({...a._formState})),a._removeUnmounted()}),t.current.formState=aA(r,a),t.current}d.createContext({});d.createContext({});const _A=Co("flex-col items-center justify-center",{variants:{show:{true:"flex",false:"hidden"}},defaultVariants:{show:!0}}),kA=Co("animate-spin",{variants:{size:{small:"size-4",medium:"size-8",large:"size-12"},variant:{primary:"text-[var(--color-brand-wMain)]",secondary:"text-[var(--color-primary-wMain)]",muted:"text-[var(--color-secondary-text-wMain)] dark:text-[var(--color-secondary-text-w50)]",foreground:"text-foreground"}},defaultVariants:{size:"medium",variant:"primary"}});function ws({size:e,show:t,children:n,className:r,variant:s}){return o.jsxs("span",{className:_A({show:t}),children:[o.jsx(ur,{className:Ue(kA({size:e,variant:s}),r)}),n]})}var wd="focusScope.autoFocusOnMount",yd="focusScope.autoFocusOnUnmount",kg={bubbles:!1,cancelable:!0},jA="FocusScope",xl=d.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...i}=e,[l,c]=d.useState(null),u=Dn(s),h=Dn(a),f=d.useRef(null),p=yt(t,g=>c(g)),m=d.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;d.useEffect(()=>{if(r){let g=function(C){if(m.paused||!l)return;const S=C.target;l.contains(S)?f.current=S:qs(f.current,{select:!0})},x=function(C){if(m.paused||!l)return;const S=C.relatedTarget;S!==null&&(l.contains(S)||qs(f.current,{select:!0}))},w=function(C){if(document.activeElement===document.body)for(const j of C)j.removedNodes.length>0&&qs(l)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const y=new MutationObserver(w);return l&&y.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",x),y.disconnect()}}},[r,l,m.paused]),d.useEffect(()=>{if(l){Eg.add(m);const g=document.activeElement;if(!l.contains(g)){const w=new CustomEvent(wd,kg);l.addEventListener(wd,u),l.dispatchEvent(w),w.defaultPrevented||(EA(RA(U0(l)),{select:!0}),document.activeElement===g&&qs(l))}return()=>{l.removeEventListener(wd,u),setTimeout(()=>{const w=new CustomEvent(yd,kg);l.addEventListener(yd,h),l.dispatchEvent(w),w.defaultPrevented||qs(g??document.body,{select:!0}),l.removeEventListener(yd,h),Eg.remove(m)},0)}}},[l,u,h,m]);const v=d.useCallback(g=>{if(!n&&!r||m.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,w=document.activeElement;if(x&&w){const y=g.currentTarget,[C,S]=NA(y);C&&S?!g.shiftKey&&w===S?(g.preventDefault(),n&&qs(C,{select:!0})):g.shiftKey&&w===C&&(g.preventDefault(),n&&qs(S,{select:!0})):w===y&&g.preventDefault()}},[n,r,m.paused]);return o.jsx(ct.div,{tabIndex:-1,...i,ref:p,onKeyDown:v})});xl.displayName=jA;function EA(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(qs(r,{select:t}),document.activeElement!==n)return}function NA(e){const t=U0(e),n=jg(t,e),r=jg(t.reverse(),e);return[n,r]}function U0(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const s=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||s?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function jg(e,t){for(const n of e)if(!TA(n,{upTo:t}))return n}function TA(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function AA(e){return e instanceof HTMLInputElement&&"select"in e}function qs(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&AA(e)&&t&&e.select()}}var Eg=IA();function IA(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Ng(e,t),e.unshift(t)},remove(t){var n;e=Ng(e,t),(n=e[0])==null||n.resume()}}}function Ng(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function RA(e){return e.filter(t=>t.tagName!=="A")}var bd=0;function B0(){d.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Tg()),document.body.insertAdjacentElement("beforeend",e[1]??Tg()),bd++,()=>{bd===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),bd--}},[])}function Tg(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var us=function(){return us=Object.assign||function(t){for(var n,r=1,s=arguments.length;r<s;r++){n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},us.apply(this,arguments)};function V0(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]]);return n}function PA(e,t,n){if(n||arguments.length===2)for(var r=0,s=t.length,a;r<s;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var yc="right-scroll-bar-position",bc="width-before-scroll-bar",MA="with-scroll-bars-hidden",DA="--removed-body-scroll-bar-size";function Cd(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function OA(e,t){var n=d.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var s=n.value;s!==r&&(n.value=r,n.callback(r,s))}}}})[0];return n.callback=t,n.facade}var LA=typeof window<"u"?d.useLayoutEffect:d.useEffect,Ag=new WeakMap;function FA(e,t){var n=OA(null,function(r){return e.forEach(function(s){return Cd(s,r)})});return LA(function(){var r=Ag.get(n);if(r){var s=new Set(r),a=new Set(e),i=n.current;s.forEach(function(l){a.has(l)||Cd(l,null)}),a.forEach(function(l){s.has(l)||Cd(l,i)})}Ag.set(n,e)},[e]),n}function zA(e){return e}function $A(e,t){t===void 0&&(t=zA);var n=[],r=!1,s={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var i=t(a,r);return n.push(i),function(){n=n.filter(function(l){return l!==i})}},assignSyncMedium:function(a){for(r=!0;n.length;){var i=n;n=[],i.forEach(a)}n={push:function(l){return a(l)},filter:function(){return n}}},assignMedium:function(a){r=!0;var i=[];if(n.length){var l=n;n=[],l.forEach(a),i=n}var c=function(){var h=i;i=[],h.forEach(a)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(h){i.push(h),u()},filter:function(h){return i=i.filter(h),n}}}};return s}function UA(e){e===void 0&&(e={});var t=$A(null);return t.options=us({async:!0,ssr:!1},e),t}var H0=function(e){var t=e.sideCar,n=V0(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return d.createElement(r,us({},n))};H0.isSideCarExport=!0;function BA(e,t){return e.useMedium(t),H0}var W0=UA(),Sd=function(){},Au=d.forwardRef(function(e,t){var n=d.useRef(null),r=d.useState({onScrollCapture:Sd,onWheelCapture:Sd,onTouchMoveCapture:Sd}),s=r[0],a=r[1],i=e.forwardProps,l=e.children,c=e.className,u=e.removeScrollBar,h=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,w=e.as,y=w===void 0?"div":w,C=e.gapMode,S=V0(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),j=p,I=FA([n,t]),b=us(us({},S),s);return d.createElement(d.Fragment,null,h&&d.createElement(j,{sideCar:W0,removeScrollBar:u,shards:f,noRelative:m,noIsolation:v,inert:g,setCallbacks:a,allowPinchZoom:!!x,lockRef:n,gapMode:C}),i?d.cloneElement(d.Children.only(l),us(us({},b),{ref:I})):d.createElement(y,us({},b,{className:c,ref:I}),l))});Au.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Au.classNames={fullWidth:bc,zeroRight:yc};var VA=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function HA(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=VA();return t&&e.setAttribute("nonce",t),e}function WA(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function ZA(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var GA=function(){var e=0,t=null;return{add:function(n){e==0&&(t=HA())&&(WA(t,n),ZA(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},qA=function(){var e=GA();return function(t,n){d.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Z0=function(){var e=qA(),t=function(n){var r=n.styles,s=n.dynamic;return e(r,s),null};return t},YA={left:0,top:0,right:0,gap:0},_d=function(e){return parseInt(e||"",10)||0},KA=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],s=t[e==="padding"?"paddingRight":"marginRight"];return[_d(n),_d(r),_d(s)]},XA=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return YA;var t=KA(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},JA=Z0(),Ta="data-scroll-locked",QA=function(e,t,n,r){var s=e.left,a=e.top,i=e.right,l=e.gap;return n===void 0&&(n="margin"),`
|
|
89
|
+
.`.concat(MA,` {
|
|
90
|
+
overflow: hidden `).concat(r,`;
|
|
91
|
+
padding-right: `).concat(l,"px ").concat(r,`;
|
|
92
|
+
}
|
|
93
|
+
body[`).concat(Ta,`] {
|
|
94
|
+
overflow: hidden `).concat(r,`;
|
|
95
|
+
overscroll-behavior: contain;
|
|
96
|
+
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
97
|
+
padding-left: `.concat(s,`px;
|
|
98
|
+
padding-top: `).concat(a,`px;
|
|
99
|
+
padding-right: `).concat(i,`px;
|
|
100
|
+
margin-left:0;
|
|
101
|
+
margin-top:0;
|
|
102
|
+
margin-right: `).concat(l,"px ").concat(r,`;
|
|
103
|
+
`),n==="padding"&&"padding-right: ".concat(l,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.`).concat(yc,` {
|
|
107
|
+
right: `).concat(l,"px ").concat(r,`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.`).concat(bc,` {
|
|
111
|
+
margin-right: `).concat(l,"px ").concat(r,`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.`).concat(yc," .").concat(yc,` {
|
|
115
|
+
right: 0 `).concat(r,`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.`).concat(bc," .").concat(bc,` {
|
|
119
|
+
margin-right: 0 `).concat(r,`;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
body[`).concat(Ta,`] {
|
|
123
|
+
`).concat(DA,": ").concat(l,`px;
|
|
124
|
+
}
|
|
125
|
+
`)},Ig=function(){var e=parseInt(document.body.getAttribute(Ta)||"0",10);return isFinite(e)?e:0},eI=function(){d.useEffect(function(){return document.body.setAttribute(Ta,(Ig()+1).toString()),function(){var e=Ig()-1;e<=0?document.body.removeAttribute(Ta):document.body.setAttribute(Ta,e.toString())}},[])},tI=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,s=r===void 0?"margin":r;eI();var a=d.useMemo(function(){return XA(s)},[s]);return d.createElement(JA,{styles:QA(a,!t,s,n?"":"!important")})},Af=!1;if(typeof window<"u")try{var Gl=Object.defineProperty({},"passive",{get:function(){return Af=!0,!0}});window.addEventListener("test",Gl,Gl),window.removeEventListener("test",Gl,Gl)}catch{Af=!1}var da=Af?{passive:!1}:!1,nI=function(e){return e.tagName==="TEXTAREA"},G0=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!nI(e)&&n[t]==="visible")},rI=function(e){return G0(e,"overflowY")},sI=function(e){return G0(e,"overflowX")},Rg=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var s=q0(e,r);if(s){var a=Y0(e,r),i=a[1],l=a[2];if(i>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},oI=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},aI=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},q0=function(e,t){return e==="v"?rI(t):sI(t)},Y0=function(e,t){return e==="v"?oI(t):aI(t)},iI=function(e,t){return e==="h"&&t==="rtl"?-1:1},lI=function(e,t,n,r,s){var a=iI(e,window.getComputedStyle(t).direction),i=a*r,l=n.target,c=t.contains(l),u=!1,h=i>0,f=0,p=0;do{if(!l)break;var m=Y0(e,l),v=m[0],g=m[1],x=m[2],w=g-x-a*v;(v||w)&&q0(e,l)&&(f+=w,p+=v);var y=l.parentNode;l=y&&y.nodeType===Node.DOCUMENT_FRAGMENT_NODE?y.host:y}while(!c&&l!==document.body||c&&(t.contains(l)||t===l));return(h&&Math.abs(f)<1||!h&&Math.abs(p)<1)&&(u=!0),u},ql=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Pg=function(e){return[e.deltaX,e.deltaY]},Mg=function(e){return e&&"current"in e?e.current:e},cI=function(e,t){return e[0]===t[0]&&e[1]===t[1]},uI=function(e){return`
|
|
126
|
+
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
127
|
+
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
128
|
+
`)},dI=0,fa=[];function fI(e){var t=d.useRef([]),n=d.useRef([0,0]),r=d.useRef(),s=d.useState(dI++)[0],a=d.useState(Z0)[0],i=d.useRef(e);d.useEffect(function(){i.current=e},[e]),d.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(s));var g=PA([e.lockRef.current],(e.shards||[]).map(Mg),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(s))})}}},[e.inert,e.lockRef.current,e.shards]);var l=d.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var w=ql(g),y=n.current,C="deltaX"in g?g.deltaX:y[0]-w[0],S="deltaY"in g?g.deltaY:y[1]-w[1],j,I=g.target,b=Math.abs(C)>Math.abs(S)?"h":"v";if("touches"in g&&b==="h"&&I.type==="range")return!1;var k=Rg(b,I);if(!k)return!0;if(k?j=b:(j=b==="v"?"h":"v",k=Rg(b,I)),!k)return!1;if(!r.current&&"changedTouches"in g&&(C||S)&&(r.current=j),!j)return!0;var N=r.current||j;return lI(N,x,g,N==="h"?C:S)},[]),c=d.useCallback(function(g){var x=g;if(!(!fa.length||fa[fa.length-1]!==a)){var w="deltaY"in x?Pg(x):ql(x),y=t.current.filter(function(j){return j.name===x.type&&(j.target===x.target||x.target===j.shadowParent)&&cI(j.delta,w)})[0];if(y&&y.should){x.cancelable&&x.preventDefault();return}if(!y){var C=(i.current.shards||[]).map(Mg).filter(Boolean).filter(function(j){return j.contains(x.target)}),S=C.length>0?l(x,C[0]):!i.current.noIsolation;S&&x.cancelable&&x.preventDefault()}}},[]),u=d.useCallback(function(g,x,w,y){var C={name:g,delta:x,target:w,should:y,shadowParent:hI(w)};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(S){return S!==C})},1)},[]),h=d.useCallback(function(g){n.current=ql(g),r.current=void 0},[]),f=d.useCallback(function(g){u(g.type,Pg(g),g.target,l(g,e.lockRef.current))},[]),p=d.useCallback(function(g){u(g.type,ql(g),g.target,l(g,e.lockRef.current))},[]);d.useEffect(function(){return fa.push(a),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",c,da),document.addEventListener("touchmove",c,da),document.addEventListener("touchstart",h,da),function(){fa=fa.filter(function(g){return g!==a}),document.removeEventListener("wheel",c,da),document.removeEventListener("touchmove",c,da),document.removeEventListener("touchstart",h,da)}},[]);var m=e.removeScrollBar,v=e.inert;return d.createElement(d.Fragment,null,v?d.createElement(a,{styles:uI(s)}):null,m?d.createElement(tI,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function hI(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const mI=BA(W0,fI);var vl=d.forwardRef(function(e,t){return d.createElement(Au,us({},e,{ref:t,sideCar:mI}))});vl.classNames=Au.classNames;var pI=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},ha=new WeakMap,Yl=new WeakMap,Kl={},kd=0,K0=function(e){return e&&(e.host||K0(e.parentNode))},gI=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=K0(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},xI=function(e,t,n,r){var s=gI(t,Array.isArray(e)?e:[e]);Kl[n]||(Kl[n]=new WeakMap);var a=Kl[n],i=[],l=new Set,c=new Set(s),u=function(f){!f||l.has(f)||(l.add(f),u(f.parentNode))};s.forEach(u);var h=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(p){if(l.has(p))h(p);else try{var m=p.getAttribute(r),v=m!==null&&m!=="false",g=(ha.get(p)||0)+1,x=(a.get(p)||0)+1;ha.set(p,g),a.set(p,x),i.push(p),g===1&&v&&Yl.set(p,!0),x===1&&p.setAttribute(n,"true"),v||p.setAttribute(r,"true")}catch(w){console.error("aria-hidden: cannot operate on ",p,w)}})};return h(t),l.clear(),kd++,function(){i.forEach(function(f){var p=ha.get(f)-1,m=a.get(f)-1;ha.set(f,p),a.set(f,m),p||(Yl.has(f)||f.removeAttribute(r),Yl.delete(f)),m||f.removeAttribute(n)}),kd--,kd||(ha=new WeakMap,ha=new WeakMap,Yl=new WeakMap,Kl={})}},Iu=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),s=pI(e);return s?(r.push.apply(r,Array.from(s.querySelectorAll("[aria-live], script"))),xI(r,s,n,"aria-hidden")):function(){return null}},Ru="Dialog",[X0,SU]=pr(Ru),[vI,ns]=X0(Ru),J0=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:s,onOpenChange:a,modal:i=!0}=e,l=d.useRef(null),c=d.useRef(null),[u,h]=Ds({prop:r,defaultProp:s??!1,onChange:a,caller:Ru});return o.jsx(vI,{scope:t,triggerRef:l,contentRef:c,contentId:dr(),titleId:dr(),descriptionId:dr(),open:u,onOpenChange:h,onOpenToggle:d.useCallback(()=>h(f=>!f),[h]),modal:i,children:n})};J0.displayName=Ru;var Q0="DialogTrigger",ey=d.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=ns(Q0,n),a=yt(t,s.triggerRef);return o.jsx(ct.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":lm(s.open),...r,ref:a,onClick:Gt(e.onClick,s.onOpenToggle)})});ey.displayName=Q0;var am="DialogPortal",[wI,ty]=X0(am,{forceMount:void 0}),ny=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:s}=e,a=ns(am,t);return o.jsx(wI,{scope:t,forceMount:n,children:d.Children.map(r,i=>o.jsx(Fs,{present:n||a.open,children:o.jsx(li,{asChild:!0,container:s,children:i})}))})};ny.displayName=am;var Vc="DialogOverlay",ry=d.forwardRef((e,t)=>{const n=ty(Vc,e.__scopeDialog),{forceMount:r=n.forceMount,...s}=e,a=ns(Vc,e.__scopeDialog);return a.modal?o.jsx(Fs,{present:r||a.open,children:o.jsx(bI,{...s,ref:t})}):null});ry.displayName=Vc;var yI=ho("DialogOverlay.RemoveScroll"),bI=d.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=ns(Vc,n);return o.jsx(vl,{as:yI,allowPinchZoom:!0,shards:[s.contentRef],children:o.jsx(ct.div,{"data-state":lm(s.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Zo="DialogContent",sy=d.forwardRef((e,t)=>{const n=ty(Zo,e.__scopeDialog),{forceMount:r=n.forceMount,...s}=e,a=ns(Zo,e.__scopeDialog);return o.jsx(Fs,{present:r||a.open,children:a.modal?o.jsx(CI,{...s,ref:t}):o.jsx(SI,{...s,ref:t})})});sy.displayName=Zo;var CI=d.forwardRef((e,t)=>{const n=ns(Zo,e.__scopeDialog),r=d.useRef(null),s=yt(t,n.contentRef,r);return d.useEffect(()=>{const a=r.current;if(a)return Iu(a)},[]),o.jsx(oy,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Gt(e.onCloseAutoFocus,a=>{var i;a.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:Gt(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,l=i.button===0&&i.ctrlKey===!0;(i.button===2||l)&&a.preventDefault()}),onFocusOutside:Gt(e.onFocusOutside,a=>a.preventDefault())})}),SI=d.forwardRef((e,t)=>{const n=ns(Zo,e.__scopeDialog),r=d.useRef(!1),s=d.useRef(!1);return o.jsx(oy,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var i,l;(i=e.onCloseAutoFocus)==null||i.call(e,a),a.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),a.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:a=>{var c,u;(c=e.onInteractOutside)==null||c.call(e,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const i=a.target;((u=n.triggerRef.current)==null?void 0:u.contains(i))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&s.current&&a.preventDefault()}})}),oy=d.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:a,...i}=e,l=ns(Zo,n),c=d.useRef(null),u=yt(t,c);return B0(),o.jsxs(o.Fragment,{children:[o.jsx(xl,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:a,children:o.jsx(bu,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":lm(l.open),...i,ref:u,onDismiss:()=>l.onOpenChange(!1)})}),o.jsxs(o.Fragment,{children:[o.jsx(_I,{titleId:l.titleId}),o.jsx(jI,{contentRef:c,descriptionId:l.descriptionId})]})]})}),im="DialogTitle",ay=d.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=ns(im,n);return o.jsx(ct.h2,{id:s.titleId,...r,ref:t})});ay.displayName=im;var iy="DialogDescription",ly=d.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=ns(iy,n);return o.jsx(ct.p,{id:s.descriptionId,...r,ref:t})});ly.displayName=iy;var cy="DialogClose",uy=d.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=ns(cy,n);return o.jsx(ct.button,{type:"button",...r,ref:t,onClick:Gt(e.onClick,()=>s.onOpenChange(!1))})});uy.displayName=cy;function lm(e){return e?"open":"closed"}var dy="DialogTitleWarning",[_U,fy]=q2(dy,{contentName:Zo,titleName:im,docsSlug:"dialog"}),_I=({titleId:e})=>{const t=fy(dy),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
129
|
+
|
|
130
|
+
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
131
|
+
|
|
132
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return d.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},kI="DialogDescriptionWarning",jI=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${fy(kI).contentName}}.`;return d.useEffect(()=>{var a;const s=(a=e.current)==null?void 0:a.getAttribute("aria-describedby");t&&s&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},EI=J0,NI=ey,TI=ny,AI=ry,II=sy,RI=ay,PI=ly,hy=uy;function Nr({...e}){return o.jsx(EI,{"data-slot":"dialog",...e})}function If({...e}){return o.jsx(NI,{"data-slot":"dialog-trigger",...e})}function MI({...e}){return o.jsx(TI,{"data-slot":"dialog-portal",...e})}function my({...e}){return o.jsx(hy,{"data-slot":"dialog-close",...e})}function DI({className:e,...t}){return o.jsx(AI,{"data-slot":"dialog-overlay",className:Ue("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function Tr({className:e,children:t,showCloseButton:n=!1,...r}){return o.jsxs(MI,{"data-slot":"dialog-portal",children:[o.jsx(DI,{}),o.jsxs(II,{"data-slot":"dialog-content",className:Ue("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] rounded-sm border p-6 shadow-lg duration-200 sm:max-w-lg",e),...r,children:[t,n&&o.jsxs(hy,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[o.jsx(Kr,{}),o.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function rs({className:e,...t}){return o.jsx("div",{"data-slot":"dialog-header",className:Ue("flex flex-col gap-6 text-center sm:text-left",e),...t})}function Cs({className:e,...t}){return o.jsx("div",{"data-slot":"dialog-footer",className:Ue("mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function Ar({className:e,...t}){return o.jsx(RI,{"data-slot":"dialog-title",className:Ue("text-lg leading-none font-semibold",e),...t})}function Ir({className:e,...t}){return o.jsx(PI,{"data-slot":"dialog-description",className:Ue(e),...t})}const Pu=d.createContext(null);Pu.displayName="PanelGroupContext";const un={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},cm=10,zo=d.useLayoutEffect,Dg=iu.useId,OI=typeof Dg=="function"?Dg:()=>null;let LI=0;function um(e=null){const t=OI(),n=d.useRef(e||t||null);return n.current===null&&(n.current=""+LI++),e??n.current}function py({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:s,forwardedRef:a,id:i,maxSize:l,minSize:c,onCollapse:u,onExpand:h,onResize:f,order:p,style:m,tagName:v="div",...g}){const x=d.useContext(Pu);if(x===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:w,expandPanel:y,getPanelSize:C,getPanelStyle:S,groupId:j,isPanelCollapsed:I,reevaluatePanelConstraints:b,registerPanel:k,resizePanel:N,unregisterPanel:A}=x,P=um(i),E=d.useRef({callbacks:{onCollapse:u,onExpand:h,onResize:f},constraints:{collapsedSize:n,collapsible:r,defaultSize:s,maxSize:l,minSize:c},id:P,idIsFromProps:i!==void 0,order:p});d.useRef({didLogMissingDefaultSizeWarning:!1}),zo(()=>{const{callbacks:_,constraints:M}=E.current,L={...M};E.current.id=P,E.current.idIsFromProps=i!==void 0,E.current.order=p,_.onCollapse=u,_.onExpand=h,_.onResize=f,M.collapsedSize=n,M.collapsible=r,M.defaultSize=s,M.maxSize=l,M.minSize=c,(L.collapsedSize!==M.collapsedSize||L.collapsible!==M.collapsible||L.maxSize!==M.maxSize||L.minSize!==M.minSize)&&b(E.current,L)}),zo(()=>{const _=E.current;return k(_),()=>{A(_)}},[p,P,k,A]),d.useImperativeHandle(a,()=>({collapse:()=>{w(E.current)},expand:_=>{y(E.current,_)},getId(){return P},getSize(){return C(E.current)},isCollapsed(){return I(E.current)},isExpanded(){return!I(E.current)},resize:_=>{N(E.current,_)}}),[w,y,C,I,P,N]);const R=S(E.current,s);return d.createElement(v,{...g,children:e,className:t,id:P,style:{...R,...m},[un.groupId]:j,[un.panel]:"",[un.panelCollapsible]:r||void 0,[un.panelId]:P,[un.panelSize]:parseFloat(""+R.flexGrow).toFixed(1)})}const gy=d.forwardRef((e,t)=>d.createElement(py,{...e,forwardedRef:t}));py.displayName="Panel";gy.displayName="forwardRef(Panel)";let Rf=null,Cc=-1,Js=null;function FI(e,t){if(t){const n=(t&by)!==0,r=(t&Cy)!==0,s=(t&Sy)!==0,a=(t&_y)!==0;if(n)return s?"se-resize":a?"ne-resize":"e-resize";if(r)return s?"sw-resize":a?"nw-resize":"w-resize";if(s)return"s-resize";if(a)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function zI(){Js!==null&&(document.head.removeChild(Js),Rf=null,Js=null,Cc=-1)}function jd(e,t){var n,r;const s=FI(e,t);if(Rf!==s){if(Rf=s,Js===null&&(Js=document.createElement("style"),document.head.appendChild(Js)),Cc>=0){var a;(a=Js.sheet)===null||a===void 0||a.removeRule(Cc)}Cc=(n=(r=Js.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${s} !important;}`))!==null&&n!==void 0?n:-1}}function xy(e){return e.type==="keydown"}function vy(e){return e.type.startsWith("pointer")}function wy(e){return e.type.startsWith("mouse")}function Mu(e){if(vy(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(wy(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function $I(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function UI(e,t,n){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function BI(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:Fg(e),b:Fg(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;Ct(r,"Stacking order can only be calculated for elements with a common ancestor");const s={a:Lg(Og(n.a)),b:Lg(Og(n.b))};if(s.a===s.b){const a=r.childNodes,i={a:n.a.at(-1),b:n.b.at(-1)};let l=a.length;for(;l--;){const c=a[l];if(c===i.a)return 1;if(c===i.b)return-1}}return Math.sign(s.a-s.b)}const VI=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function HI(e){var t;const n=getComputedStyle((t=yy(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function WI(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||HI(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||VI.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function Og(e){let t=e.length;for(;t--;){const n=e[t];if(Ct(n,"Missing node"),WI(n))return n}return null}function Lg(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Fg(e){const t=[];for(;e;)t.push(e),e=yy(e);return t}function yy(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const by=1,Cy=2,Sy=4,_y=8,ZI=$I()==="coarse";let Yr=[],Aa=!1,Qs=new Map,Du=new Map;const Yi=new Set;function GI(e,t,n,r,s){var a;const{ownerDocument:i}=t,l={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:s},c=(a=Qs.get(i))!==null&&a!==void 0?a:0;return Qs.set(i,c+1),Yi.add(l),Hc(),function(){var h;Du.delete(e),Yi.delete(l);const f=(h=Qs.get(i))!==null&&h!==void 0?h:1;if(Qs.set(i,f-1),Hc(),f===1&&Qs.delete(i),Yr.includes(l)){const p=Yr.indexOf(l);p>=0&&Yr.splice(p,1),fm(),s("up",!0,null)}}}function qI(e){const{target:t}=e,{x:n,y:r}=Mu(e);Aa=!0,dm({target:t,x:n,y:r}),Hc(),Yr.length>0&&(Wc("down",e),e.preventDefault(),ky(t)||e.stopImmediatePropagation())}function Ed(e){const{x:t,y:n}=Mu(e);if(Aa&&e.buttons===0&&(Aa=!1,Wc("up",e)),!Aa){const{target:r}=e;dm({target:r,x:t,y:n})}Wc("move",e),fm(),Yr.length>0&&e.preventDefault()}function Nd(e){const{target:t}=e,{x:n,y:r}=Mu(e);Du.clear(),Aa=!1,Yr.length>0&&(e.preventDefault(),ky(t)||e.stopImmediatePropagation()),Wc("up",e),dm({target:t,x:n,y:r}),fm(),Hc()}function ky(e){let t=e;for(;t;){if(t.hasAttribute(un.resizeHandle))return!0;t=t.parentElement}return!1}function dm({target:e,x:t,y:n}){Yr.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),Yi.forEach(s=>{const{element:a,hitAreaMargins:i}=s,l=a.getBoundingClientRect(),{bottom:c,left:u,right:h,top:f}=l,p=ZI?i.coarse:i.fine;if(t>=u-p&&t<=h+p&&n>=f-p&&n<=c+p){if(r!==null&&document.contains(r)&&a!==r&&!a.contains(r)&&!r.contains(a)&&BI(r,a)>0){let v=r,g=!1;for(;v&&!v.contains(a);){if(UI(v.getBoundingClientRect(),l)){g=!0;break}v=v.parentElement}if(g)return}Yr.push(s)}})}function Td(e,t){Du.set(e,t)}function fm(){let e=!1,t=!1;Yr.forEach(r=>{const{direction:s}=r;s==="horizontal"?e=!0:t=!0});let n=0;Du.forEach(r=>{n|=r}),e&&t?jd("intersection",n):e?jd("horizontal",n):t?jd("vertical",n):zI()}let Ad;function Hc(){var e;(e=Ad)===null||e===void 0||e.abort(),Ad=new AbortController;const t={capture:!0,signal:Ad.signal};Yi.size&&(Aa?(Yr.length>0&&Qs.forEach((n,r)=>{const{body:s}=r;n>0&&(s.addEventListener("contextmenu",Nd,t),s.addEventListener("pointerleave",Ed,t),s.addEventListener("pointermove",Ed,t))}),Qs.forEach((n,r)=>{const{body:s}=r;s.addEventListener("pointerup",Nd,t),s.addEventListener("pointercancel",Nd,t)})):Qs.forEach((n,r)=>{const{body:s}=r;n>0&&(s.addEventListener("pointerdown",qI,t),s.addEventListener("pointermove",Ed,t))}))}function Wc(e,t){Yi.forEach(n=>{const{setResizeHandlerState:r}=n,s=Yr.includes(n);r(e,s,t)})}function YI(){const[e,t]=d.useState(0);return d.useCallback(()=>t(n=>n+1),[])}function Ct(e,t){if(!e)throw console.error(t),Error(t)}function Go(e,t,n=cm){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Is(e,t,n=cm){return Go(e,t,n)===0}function ar(e,t,n){return Go(e,t,n)===0}function KI(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const s=e[r],a=t[r];if(!ar(s,a,n))return!1}return!0}function Ca({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];Ct(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:s=0,collapsible:a,maxSize:i=100,minSize:l=0}=r;if(Go(n,l)<0)if(a){const c=(s+l)/2;Go(n,c)<0?n=s:n=l}else n=l;return n=Math.min(i,n),n=parseFloat(n.toFixed(cm)),n}function Ni({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:s,trigger:a}){if(ar(e,0))return t;const i=[...t],[l,c]=r;Ct(l!=null,"Invalid first pivot index"),Ct(c!=null,"Invalid second pivot index");let u=0;if(a==="keyboard"){{const f=e<0?c:l,p=n[f];Ct(p,`Panel constraints not found for index ${f}`);const{collapsedSize:m=0,collapsible:v,minSize:g=0}=p;if(v){const x=t[f];if(Ct(x!=null,`Previous layout not found for panel index ${f}`),ar(x,m)){const w=g-x;Go(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}{const f=e<0?l:c,p=n[f];Ct(p,`No panel constraints found for index ${f}`);const{collapsedSize:m=0,collapsible:v,minSize:g=0}=p;if(v){const x=t[f];if(Ct(x!=null,`Previous layout not found for panel index ${f}`),ar(x,g)){const w=x-m;Go(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}}{const f=e<0?1:-1;let p=e<0?c:l,m=0;for(;;){const g=t[p];Ct(g!=null,`Previous layout not found for panel index ${p}`);const w=Ca({panelConstraints:n,panelIndex:p,size:100})-g;if(m+=w,p+=f,p<0||p>=n.length)break}const v=Math.min(Math.abs(e),Math.abs(m));e=e<0?0-v:v}{let p=e<0?l:c;for(;p>=0&&p<n.length;){const m=Math.abs(e)-Math.abs(u),v=t[p];Ct(v!=null,`Previous layout not found for panel index ${p}`);const g=v-m,x=Ca({panelConstraints:n,panelIndex:p,size:g});if(!ar(v,x)&&(u+=v-x,i[p]=x,u.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?p--:p++}}if(KI(s,i))return s;{const f=e<0?c:l,p=t[f];Ct(p!=null,`Previous layout not found for panel index ${f}`);const m=p+u,v=Ca({panelConstraints:n,panelIndex:f,size:m});if(i[f]=v,!ar(v,m)){let g=m-v,w=e<0?c:l;for(;w>=0&&w<n.length;){const y=i[w];Ct(y!=null,`Previous layout not found for panel index ${w}`);const C=y+g,S=Ca({panelConstraints:n,panelIndex:w,size:C});if(ar(y,S)||(g-=S-y,i[w]=S),ar(g,0))break;e>0?w--:w++}}}const h=i.reduce((f,p)=>p+f,0);return ar(h,100)?i:s}function XI({layout:e,panelsArray:t,pivotIndices:n}){let r=0,s=100,a=0,i=0;const l=n[0];Ct(l!=null,"No pivot index found"),t.forEach((f,p)=>{const{constraints:m}=f,{maxSize:v=100,minSize:g=0}=m;p===l?(r=g,s=v):(a+=g,i+=v)});const c=Math.min(s,100-a),u=Math.max(r,100-i),h=e[l];return{valueMax:c,valueMin:u,valueNow:h}}function Ki(e,t=document){return Array.from(t.querySelectorAll(`[${un.resizeHandleId}][data-panel-group-id="${e}"]`))}function jy(e,t,n=document){const s=Ki(e,n).findIndex(a=>a.getAttribute(un.resizeHandleId)===t);return s??null}function Ey(e,t,n){const r=jy(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function JI(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function Ny(e,t=document){if(JI(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function Ou(e,t=document){const n=t.querySelector(`[${un.resizeHandleId}="${e}"]`);return n||null}function QI(e,t,n,r=document){var s,a,i,l;const c=Ou(t,r),u=Ki(e,r),h=c?u.indexOf(c):-1,f=(s=(a=n[h])===null||a===void 0?void 0:a.id)!==null&&s!==void 0?s:null,p=(i=(l=n[h+1])===null||l===void 0?void 0:l.id)!==null&&i!==void 0?i:null;return[f,p]}function eR({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:s,panelGroupElement:a,setLayout:i}){d.useRef({didWarnAboutMissingResizeHandle:!1}),zo(()=>{if(!a)return;const l=Ki(n,a);for(let c=0;c<s.length-1;c++){const{valueMax:u,valueMin:h,valueNow:f}=XI({layout:r,panelsArray:s,pivotIndices:[c,c+1]}),p=l[c];if(p!=null){const m=s[c];Ct(m,`No panel data found for index "${c}"`),p.setAttribute("aria-controls",m.id),p.setAttribute("aria-valuemax",""+Math.round(u)),p.setAttribute("aria-valuemin",""+Math.round(h)),p.setAttribute("aria-valuenow",f!=null?""+Math.round(f):"")}}return()=>{l.forEach((c,u)=>{c.removeAttribute("aria-controls"),c.removeAttribute("aria-valuemax"),c.removeAttribute("aria-valuemin"),c.removeAttribute("aria-valuenow")})}},[n,r,s,a]),d.useEffect(()=>{if(!a)return;const l=t.current;Ct(l,"Eager values not found");const{panelDataArray:c}=l,u=Ny(n,a);Ct(u!=null,`No group found for id "${n}"`);const h=Ki(n,a);Ct(h,`No resize handles found for group id "${n}"`);const f=h.map(p=>{const m=p.getAttribute(un.resizeHandleId);Ct(m,"Resize handle element has no handle id attribute");const[v,g]=QI(n,m,c,a);if(v==null||g==null)return()=>{};const x=w=>{if(!w.defaultPrevented)switch(w.key){case"Enter":{w.preventDefault();const y=c.findIndex(C=>C.id===v);if(y>=0){const C=c[y];Ct(C,`No panel data found for index ${y}`);const S=r[y],{collapsedSize:j=0,collapsible:I,minSize:b=0}=C.constraints;if(S!=null&&I){const k=Ni({delta:ar(S,j)?b-j:j-S,initialLayout:r,panelConstraints:c.map(N=>N.constraints),pivotIndices:Ey(n,m,a),prevLayout:r,trigger:"keyboard"});r!==k&&i(k)}}break}}};return p.addEventListener("keydown",x),()=>{p.removeEventListener("keydown",x)}});return()=>{f.forEach(p=>p())}},[a,e,t,n,r,s,i])}function zg(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Ty(e,t){const n=e==="horizontal",{x:r,y:s}=Mu(t);return n?r:s}function tR(e,t,n,r,s){const a=n==="horizontal",i=Ou(t,s);Ct(i,`No resize handle element found for id "${t}"`);const l=i.getAttribute(un.groupId);Ct(l,"Resize handle element has no group id attribute");let{initialCursorPosition:c}=r;const u=Ty(n,e),h=Ny(l,s);Ct(h,`No group element found for id "${l}"`);const f=h.getBoundingClientRect(),p=a?f.width:f.height;return(u-c)/p*100}function nR(e,t,n,r,s,a){if(xy(e)){const i=n==="horizontal";let l=0;e.shiftKey?l=100:s!=null?l=s:l=10;let c=0;switch(e.key){case"ArrowDown":c=i?0:l;break;case"ArrowLeft":c=i?-l:0;break;case"ArrowRight":c=i?l:0;break;case"ArrowUp":c=i?0:-l;break;case"End":c=100;break;case"Home":c=-100;break}return c}else return r==null?0:tR(e,t,n,r,a)}function rR({panelDataArray:e}){const t=Array(e.length),n=e.map(a=>a.constraints);let r=0,s=100;for(let a=0;a<e.length;a++){const i=n[a];Ct(i,`Panel constraints not found for index ${a}`);const{defaultSize:l}=i;l!=null&&(r++,t[a]=l,s-=l)}for(let a=0;a<e.length;a++){const i=n[a];Ct(i,`Panel constraints not found for index ${a}`);const{defaultSize:l}=i;if(l!=null)continue;const c=e.length-r,u=s/c;r++,t[a]=u,s-=u}return t}function ma(e,t,n){t.forEach((r,s)=>{const a=e[s];Ct(a,`Panel data not found for index ${s}`);const{callbacks:i,constraints:l,id:c}=a,{collapsedSize:u=0,collapsible:h}=l,f=n[c];if(f==null||r!==f){n[c]=r;const{onCollapse:p,onExpand:m,onResize:v}=i;v&&v(r,f),h&&(p||m)&&(m&&(f==null||Is(f,u))&&!Is(r,u)&&m(),p&&(f==null||!Is(f,u))&&Is(r,u)&&p())}})}function Xl(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function sR({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:s,precision:a=3}){const i=n[s];let l;return i==null?l=e!=null?e.toPrecision(a):"1":r.length===1?l="1":l=i.toPrecision(a),{flexBasis:0,flexGrow:l,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function oR(e,t=10){let n=null;return(...s)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...s)},t)}}function $g(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function Ay(e){return`react-resizable-panels:${e}`}function Iy(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:s,order:a}=t;return s?r:a?`${a}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function Ry(e,t){try{const n=Ay(e),r=t.getItem(n);if(r){const s=JSON.parse(r);if(typeof s=="object"&&s!=null)return s}}catch{}return null}function aR(e,t,n){var r,s;const a=(r=Ry(e,n))!==null&&r!==void 0?r:{},i=Iy(t);return(s=a[i])!==null&&s!==void 0?s:null}function iR(e,t,n,r,s){var a;const i=Ay(e),l=Iy(t),c=(a=Ry(e,s))!==null&&a!==void 0?a:{};c[l]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{s.setItem(i,JSON.stringify(c))}catch(u){console.error(u)}}function Ug({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((a,i)=>a+i,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(a=>`${a}%`).join(", ")}`);if(!ar(r,100)&&n.length>0)for(let a=0;a<t.length;a++){const i=n[a];Ct(i!=null,`No layout data found for index ${a}`);const l=100/r*i;n[a]=l}let s=0;for(let a=0;a<t.length;a++){const i=n[a];Ct(i!=null,`No layout data found for index ${a}`);const l=Ca({panelConstraints:t,panelIndex:a,size:i});i!=l&&(s+=i-l,n[a]=l)}if(!ar(s,0))for(let a=0;a<t.length;a++){const i=n[a];Ct(i!=null,`No layout data found for index ${a}`);const l=i+s,c=Ca({panelConstraints:t,panelIndex:a,size:l});if(i!==c&&(s-=c-i,n[a]=c,ar(s,0)))break}return n}const lR=100,Ti={getItem:e=>($g(Ti),Ti.getItem(e)),setItem:(e,t)=>{$g(Ti),Ti.setItem(e,t)}},Bg={};function Py({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:s,id:a=null,onLayout:i=null,keyboardResizeBy:l=null,storage:c=Ti,style:u,tagName:h="div",...f}){const p=um(a),m=d.useRef(null),[v,g]=d.useState(null),[x,w]=d.useState([]),y=YI(),C=d.useRef({}),S=d.useRef(new Map),j=d.useRef(0),I=d.useRef({autoSaveId:e,direction:r,dragState:v,id:p,keyboardResizeBy:l,onLayout:i,storage:c}),b=d.useRef({layout:x,panelDataArray:[],panelDataArrayChanged:!1});d.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),d.useImperativeHandle(s,()=>({getId:()=>I.current.id,getLayout:()=>{const{layout:V}=b.current;return V},setLayout:V=>{const{onLayout:X}=I.current,{layout:H,panelDataArray:Q}=b.current,z=Ug({layout:V,panelConstraints:Q.map(Z=>Z.constraints)});zg(H,z)||(w(z),b.current.layout=z,X&&X(z),ma(Q,z,C.current))}}),[]),zo(()=>{I.current.autoSaveId=e,I.current.direction=r,I.current.dragState=v,I.current.id=p,I.current.onLayout=i,I.current.storage=c}),eR({committedValuesRef:I,eagerValuesRef:b,groupId:p,layout:x,panelDataArray:b.current.panelDataArray,setLayout:w,panelGroupElement:m.current}),d.useEffect(()=>{const{panelDataArray:V}=b.current;if(e){if(x.length===0||x.length!==V.length)return;let X=Bg[e];X==null&&(X=oR(iR,lR),Bg[e]=X);const H=[...V],Q=new Map(S.current);X(e,H,Q,x,c)}},[e,x,c]),d.useEffect(()=>{});const k=d.useCallback(V=>{const{onLayout:X}=I.current,{layout:H,panelDataArray:Q}=b.current;if(V.constraints.collapsible){const z=Q.map(de=>de.constraints),{collapsedSize:Z=0,panelSize:J,pivotIndices:ce}=Ao(Q,V,H);if(Ct(J!=null,`Panel size not found for panel "${V.id}"`),!Is(J,Z)){S.current.set(V.id,J);const fe=wa(Q,V)===Q.length-1?J-Z:Z-J,ge=Ni({delta:fe,initialLayout:H,panelConstraints:z,pivotIndices:ce,prevLayout:H,trigger:"imperative-api"});Xl(H,ge)||(w(ge),b.current.layout=ge,X&&X(ge),ma(Q,ge,C.current))}}},[]),N=d.useCallback((V,X)=>{const{onLayout:H}=I.current,{layout:Q,panelDataArray:z}=b.current;if(V.constraints.collapsible){const Z=z.map(T=>T.constraints),{collapsedSize:J=0,panelSize:ce=0,minSize:de=0,pivotIndices:fe}=Ao(z,V,Q),ge=X??de;if(Is(ce,J)){const T=S.current.get(V.id),le=T!=null&&T>=ge?T:ge,q=wa(z,V)===z.length-1?ce-le:le-ce,B=Ni({delta:q,initialLayout:Q,panelConstraints:Z,pivotIndices:fe,prevLayout:Q,trigger:"imperative-api"});Xl(Q,B)||(w(B),b.current.layout=B,H&&H(B),ma(z,B,C.current))}}},[]),A=d.useCallback(V=>{const{layout:X,panelDataArray:H}=b.current,{panelSize:Q}=Ao(H,V,X);return Ct(Q!=null,`Panel size not found for panel "${V.id}"`),Q},[]),P=d.useCallback((V,X)=>{const{panelDataArray:H}=b.current,Q=wa(H,V);return sR({defaultSize:X,dragState:v,layout:x,panelData:H,panelIndex:Q})},[v,x]),E=d.useCallback(V=>{const{layout:X,panelDataArray:H}=b.current,{collapsedSize:Q=0,collapsible:z,panelSize:Z}=Ao(H,V,X);return Ct(Z!=null,`Panel size not found for panel "${V.id}"`),z===!0&&Is(Z,Q)},[]),R=d.useCallback(V=>{const{layout:X,panelDataArray:H}=b.current,{collapsedSize:Q=0,collapsible:z,panelSize:Z}=Ao(H,V,X);return Ct(Z!=null,`Panel size not found for panel "${V.id}"`),!z||Go(Z,Q)>0},[]),_=d.useCallback(V=>{const{panelDataArray:X}=b.current;X.push(V),X.sort((H,Q)=>{const z=H.order,Z=Q.order;return z==null&&Z==null?0:z==null?-1:Z==null?1:z-Z}),b.current.panelDataArrayChanged=!0,y()},[y]);zo(()=>{if(b.current.panelDataArrayChanged){b.current.panelDataArrayChanged=!1;const{autoSaveId:V,onLayout:X,storage:H}=I.current,{layout:Q,panelDataArray:z}=b.current;let Z=null;if(V){const ce=aR(V,z,H);ce&&(S.current=new Map(Object.entries(ce.expandToSizes)),Z=ce.layout)}Z==null&&(Z=rR({panelDataArray:z}));const J=Ug({layout:Z,panelConstraints:z.map(ce=>ce.constraints)});zg(Q,J)||(w(J),b.current.layout=J,X&&X(J),ma(z,J,C.current))}}),zo(()=>{const V=b.current;return()=>{V.layout=[]}},[]);const M=d.useCallback(V=>{let X=!1;const H=m.current;return H&&window.getComputedStyle(H,null).getPropertyValue("direction")==="rtl"&&(X=!0),function(z){z.preventDefault();const Z=m.current;if(!Z)return()=>null;const{direction:J,dragState:ce,id:de,keyboardResizeBy:fe,onLayout:ge}=I.current,{layout:T,panelDataArray:le}=b.current,{initialLayout:ie}=ce??{},q=Ey(de,V,Z);let B=nR(z,V,J,ce,fe,Z);const ee=J==="horizontal";ee&&X&&(B=-B);const U=le.map(ae=>ae.constraints),Y=Ni({delta:B,initialLayout:ie??T,panelConstraints:U,pivotIndices:q,prevLayout:T,trigger:xy(z)?"keyboard":"mouse-or-touch"}),G=!Xl(T,Y);(vy(z)||wy(z))&&j.current!=B&&(j.current=B,!G&&B!==0?ee?Td(V,B<0?by:Cy):Td(V,B<0?Sy:_y):Td(V,0)),G&&(w(Y),b.current.layout=Y,ge&&ge(Y),ma(le,Y,C.current))}},[]),L=d.useCallback((V,X)=>{const{onLayout:H}=I.current,{layout:Q,panelDataArray:z}=b.current,Z=z.map(T=>T.constraints),{panelSize:J,pivotIndices:ce}=Ao(z,V,Q);Ct(J!=null,`Panel size not found for panel "${V.id}"`);const fe=wa(z,V)===z.length-1?J-X:X-J,ge=Ni({delta:fe,initialLayout:Q,panelConstraints:Z,pivotIndices:ce,prevLayout:Q,trigger:"imperative-api"});Xl(Q,ge)||(w(ge),b.current.layout=ge,H&&H(ge),ma(z,ge,C.current))},[]),F=d.useCallback((V,X)=>{const{layout:H,panelDataArray:Q}=b.current,{collapsedSize:z=0,collapsible:Z}=X,{collapsedSize:J=0,collapsible:ce,maxSize:de=100,minSize:fe=0}=V.constraints,{panelSize:ge}=Ao(Q,V,H);ge!=null&&(Z&&ce&&Is(ge,z)?Is(z,J)||L(V,J):ge<fe?L(V,fe):ge>de&&L(V,de))},[L]),D=d.useCallback((V,X)=>{const{direction:H}=I.current,{layout:Q}=b.current;if(!m.current)return;const z=Ou(V,m.current);Ct(z,`Drag handle element not found for id "${V}"`);const Z=Ty(H,X);g({dragHandleId:V,dragHandleRect:z.getBoundingClientRect(),initialCursorPosition:Z,initialLayout:Q})},[]),O=d.useCallback(()=>{g(null)},[]),K=d.useCallback(V=>{const{panelDataArray:X}=b.current,H=wa(X,V);H>=0&&(X.splice(H,1),delete C.current[V.id],b.current.panelDataArrayChanged=!0,y())},[y]),$=d.useMemo(()=>({collapsePanel:k,direction:r,dragState:v,expandPanel:N,getPanelSize:A,getPanelStyle:P,groupId:p,isPanelCollapsed:E,isPanelExpanded:R,reevaluatePanelConstraints:F,registerPanel:_,registerResizeHandle:M,resizePanel:L,startDragging:D,stopDragging:O,unregisterPanel:K,panelGroupElement:m.current}),[k,v,r,N,A,P,p,E,R,F,_,M,L,D,O,K]),W={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return d.createElement(Pu.Provider,{value:$},d.createElement(h,{...f,children:t,className:n,id:a,ref:m,style:{...W,...u},[un.group]:"",[un.groupDirection]:r,[un.groupId]:p}))}const My=d.forwardRef((e,t)=>d.createElement(Py,{...e,forwardedRef:t}));Py.displayName="PanelGroup";My.displayName="forwardRef(PanelGroup)";function wa(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function Ao(e,t,n){const r=wa(e,t),a=r===e.length-1?[r-1,r]:[r,r+1],i=n[r];return{...t.constraints,panelSize:i,pivotIndices:a}}function cR({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){d.useEffect(()=>{if(e||n==null||r==null)return;const s=Ou(t,r);if(s==null)return;const a=i=>{if(!i.defaultPrevented)switch(i.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{i.preventDefault(),n(i);break}case"F6":{i.preventDefault();const l=s.getAttribute(un.groupId);Ct(l,`No group element found for id "${l}"`);const c=Ki(l,r),u=jy(l,t,r);Ct(u!==null,`No resize element found for id "${t}"`);const h=i.shiftKey?u>0?u-1:c.length-1:u+1<c.length?u+1:0;c[h].focus();break}}};return s.addEventListener("keydown",a),()=>{s.removeEventListener("keydown",a)}},[r,e,t,n])}function Dy({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:s,onBlur:a,onClick:i,onDragging:l,onFocus:c,onPointerDown:u,onPointerUp:h,style:f={},tabIndex:p=0,tagName:m="div",...v}){var g,x;const w=d.useRef(null),y=d.useRef({onClick:i,onDragging:l,onPointerDown:u,onPointerUp:h});d.useEffect(()=>{y.current.onClick=i,y.current.onDragging=l,y.current.onPointerDown=u,y.current.onPointerUp=h});const C=d.useContext(Pu);if(C===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:S,groupId:j,registerResizeHandle:I,startDragging:b,stopDragging:k,panelGroupElement:N}=C,A=um(s),[P,E]=d.useState("inactive"),[R,_]=d.useState(!1),[M,L]=d.useState(null),F=d.useRef({state:P});zo(()=>{F.current.state=P}),d.useEffect(()=>{if(n)L(null);else{const $=I(A);L(()=>$)}},[n,A,I]);const D=(g=r==null?void 0:r.coarse)!==null&&g!==void 0?g:15,O=(x=r==null?void 0:r.fine)!==null&&x!==void 0?x:5;d.useEffect(()=>{if(n||M==null)return;const $=w.current;Ct($,"Element ref not attached");let W=!1;return GI(A,$,S,{coarse:D,fine:O},(X,H,Q)=>{if(!H){E("inactive");return}switch(X){case"down":{E("drag"),W=!1,Ct(Q,'Expected event to be defined for "down" action'),b(A,Q);const{onDragging:z,onPointerDown:Z}=y.current;z==null||z(!0),Z==null||Z();break}case"move":{const{state:z}=F.current;W=!0,z!=="drag"&&E("hover"),Ct(Q,'Expected event to be defined for "move" action'),M(Q);break}case"up":{E("hover"),k();const{onClick:z,onDragging:Z,onPointerUp:J}=y.current;Z==null||Z(!1),J==null||J(),W||z==null||z();break}}})},[D,S,n,O,I,A,M,b,k]),cR({disabled:n,handleId:A,resizeHandler:M,panelGroupElement:N});const K={touchAction:"none",userSelect:"none"};return d.createElement(m,{...v,children:e,className:t,id:s,onBlur:()=>{_(!1),a==null||a()},onFocus:()=>{_(!0),c==null||c()},ref:w,role:"separator",style:{...K,...f},tabIndex:p,[un.groupDirection]:S,[un.groupId]:j,[un.resizeHandle]:"",[un.resizeHandleActive]:P==="drag"?"pointer":R?"keyboard":void 0,[un.resizeHandleEnabled]:!n,[un.resizeHandleId]:A,[un.resizeHandleState]:P})}Dy.displayName="PanelResizeHandle";function Oy({className:e,...t}){return o.jsx(My,{"data-slot":"resizable-panel-group",className:Ue("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function Zc({className:e,...t}){return o.jsx(gy,{"data-slot":"resizable-panel",className:Ue("bg-transparent",e),...t})}function Ly({withHandle:e,className:t,...n}){return o.jsx(Dy,{"data-slot":"resizable-handle",className:Ue("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&o.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:o.jsx(l_,{className:"size-2.5"})})})}function Pf({checked:e=!1,onCheckedChange:t,disabled:n=!1,className:r}){const s=()=>{!n&&t&&t(!e)};return o.jsx("button",{type:"button",role:"switch","aria-checked":e,disabled:n,onClick:s,className:Ue("peer focus-visible:ring-ring focus-visible:ring-offset-background inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",e?"bg-primary":"bg-primary/50",r),children:o.jsx("span",{className:Ue("bg-background pointer-events-none block h-5 w-5 rounded-full shadow-lg ring-0 transition-transform",e?"translate-x-5":"translate-x-0")})})}const uR=d.forwardRef(({className:e,...t},n)=>o.jsx("ul",{ref:n,className:Ue("flex flex-row items-center gap-1",e),...t}));uR.displayName="PaginationContent";const dR=d.forwardRef(({className:e,...t},n)=>o.jsx("li",{ref:n,className:Ue("",e),...t}));dR.displayName="PaginationItem";function fR({ref:e,anchorRef:t,onClickOutside:n,enabled:r=!0}){d.useEffect(()=>{if(!r)return;const s=a=>{const i=a.target,l=e.current&&!e.current.contains(i),c=t!=null&&t.current?!t.current.contains(i):!0;l&&c&&n()};return document.addEventListener("mousedown",s),()=>{document.removeEventListener("mousedown",s)}},[e,t,n,r])}function hR({onEscape:e,enabled:t=!0}){d.useEffect(()=>{if(!t)return;const n=r=>{r.key==="Escape"&&e()};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}},[e,t])}const mR={x:0,y:0},yr=16,pR=["top-start","bottom-end","top-end"];function gR({anchorRef:e,placement:t="top-start",offset:n=mR,fallbackPlacements:r=pR}){const s=d.useCallback((c,u,h)=>{let f=0,p=0;switch(h){case"top":f=c.top-u.height-n.y,p=c.left+(c.width-u.width)/2+n.x;break;case"top-start":f=c.top-u.height-n.y,p=c.left+n.x;break;case"top-end":f=c.top-u.height-n.y,p=c.right-u.width-n.x;break;case"bottom":f=c.bottom+n.y,p=c.left+(c.width-u.width)/2+n.x;break;case"bottom-start":f=c.bottom+n.y,p=c.left+n.x;break;case"bottom-end":f=c.bottom+n.y,p=c.right-u.width-n.x;break;case"left":f=c.top+(c.height-u.height)/2+n.y,p=c.left-u.width-n.x;break;case"left-start":f=c.top+n.y,p=c.left-u.width-n.x;break;case"left-end":f=c.bottom-u.height-n.y,p=c.left-u.width-n.x;break;case"right":f=c.top+(c.height-u.height)/2+n.y,p=c.right+n.x;break;case"right-start":f=c.top+n.y,p=c.right+n.x;break;case"right-end":f=c.bottom-u.height-n.y,p=c.right+n.x;break}return console.log(`Calculated position for ${h}:`,{top:f,left:p}),{top:f,left:p,placement:h}},[n.x,n.y]),a=d.useCallback((c,u)=>{const h={width:window.innerWidth,height:window.innerHeight};return c.left<yr||c.top<yr||c.left+u.width>h.width-yr||c.top+u.height>h.height-yr},[]),i=d.useCallback(c=>{if(!e.current){const v={width:window.innerWidth,height:window.innerHeight};return{top:v.height/2-100,left:v.width/2-100,placement:t}}const u=e.current.getBoundingClientRect(),h=c.getBoundingClientRect(),f=s(u,h,t);if(!a(f,h))return f;for(const v of r){const g=s(u,h,v);if(!a(g,h))return g}const p={width:window.innerWidth,height:window.innerHeight},m={...f};return m.left<yr?m.left=yr:m.left+h.width>p.width-yr&&(m.left=p.width-h.width-yr),m.top<yr?m.top=yr:m.top+h.height>p.height-yr&&(m.top=p.height-h.height-yr),m},[e,t,r,s,a]);return{getPositionStyle:d.useCallback(c=>{const u=i(c);return{position:"fixed",top:u.top,left:u.left,zIndex:1e3}},[i]),getOptimalPosition:i}}function xR({defaultWidth:e,minWidth:t,maxWidth:n,position:r="left",onWidthChange:s}){const[a,i]=d.useState(e),[l,c]=d.useState(!1),u=d.useRef(0),h=d.useRef(e),f=d.useCallback(w=>{w.preventDefault(),c(!0),u.current=w.clientX,h.current=a},[a]),p=d.useCallback(w=>{if(!l)return;const y=w.clientX-u.current,C=r==="right"?-y:y,S=Math.min(Math.max(h.current+C,t),n);i(S),s==null||s(S)},[l,t,n,r,s]),m=d.useCallback(()=>{c(!1)},[]),v=d.useCallback(w=>{w.preventDefault(),c(!0),u.current=w.touches[0].clientX,h.current=a},[a]),g=d.useCallback(w=>{if(!l)return;const y=w.touches[0].clientX-u.current,C=r==="right"?-y:y,S=Math.min(Math.max(h.current+C,t),n);i(S),s==null||s(S)},[l,t,n,r,s]),x=d.useCallback(()=>{c(!1)},[]);return d.useEffect(()=>{if(l)return document.addEventListener("mousemove",p),document.addEventListener("mouseup",m),document.addEventListener("touchmove",g),document.addEventListener("touchend",x),document.body.style.userSelect="none",document.body.style.cursor="col-resize",()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",m),document.removeEventListener("touchmove",g),document.removeEventListener("touchend",x),document.body.style.userSelect="",document.body.style.cursor=""}},[l,p,m,g,x]),{width:a,isResizing:l,handleMouseDown:f,handleTouchStart:v,setWidth:i}}const vR=d.forwardRef(({children:e,defaultWidth:t=300,minWidth:n=200,maxWidth:r=800,position:s="left",resizable:a=!0,className:i,onWidthChange:l,...c},u)=>{const{width:h,isResizing:f,handleMouseDown:p,handleTouchStart:m}=xR({defaultWidth:t,minWidth:n,maxWidth:r,position:s,onWidthChange:l}),v={width:`${h}px`},g=s==="left"?"right-0":"left-0";return o.jsxs("div",{ref:u,className:Ue("relative h-full flex-shrink-0 cursor-pointer",s==="left"?"border-r":"border-l",i),style:v,...c,children:[o.jsx("div",{className:Ue("h-full overflow-x-hidden overflow-y-auto"),children:e}),a&&o.jsx("div",{className:Ue("group absolute top-0 bottom-0 w-2",g,"cursor-col-resize","hover:bg-[var(--color-primary-wMain)]","transition-all duration-200",f&&"bg-[var(--color-primary-wMain)]"),onMouseDown:p,onTouchStart:m,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${s} panel`,tabIndex:0,onKeyDown:w=>{if(w.key==="ArrowLeft"||w.key==="ArrowRight"){w.preventDefault();const y=w.key==="ArrowRight"?10:-10,C=s==="right"?-y:y,S=Math.min(Math.max(h+C,n),r);l==null||l(S)}},children:o.jsx("div",{className:Ue("absolute inset-y-0 left-1/2 w-0.5 -translate-x-1/2 transform","bg-[var(--color-secondary-w40)] dark:bg-[var(--color-secondary-w70)]","group-hover:bg-[var(--color-primary-wMain)]","transition-colors duration-200",f&&"bg-[var(--color-primary-wMain)]")})})]})});vR.displayName="SidePanel";const wR="https://solace.com/a2a/extensions/display-name",yR="https://solace.com/a2a/extensions/peer-agent-topology",bR="https://solace.com/a2a/extensions/sam/tools",CR=e=>{var s,a,i,l;let t,n,r;if((s=e.capabilities)!=null&&s.extensions){const c=e.capabilities.extensions.find(f=>f.uri===wR);(a=c==null?void 0:c.params)!=null&&a.display_name&&(t=c.params.display_name);const u=e.capabilities.extensions.find(f=>f.uri===yR);(i=u==null?void 0:u.params)!=null&&i.peer_agent_names&&(n=u.params.peer_agent_names);const h=e.capabilities.extensions.find(f=>f.uri===bR);(l=h==null?void 0:h.params)!=null&&l.tools&&(r=h.params.tools)}return{...e,display_name:t,peer_agents:n||[],tools:r||[],displayName:t,peerAgents:n||[]}},SR=()=>{const[e,t]=d.useState([]),[n,r]=d.useState(!1),[s,a]=d.useState(null),i=d.useCallback(async()=>{r(!0),a(null);try{const u=(await Ie.webui.get("/api/v1/agentCards")).map(CR);t(u)}catch(c){console.error("Error fetching agents:",c),a(c instanceof Error?c.message:"Could not load agent information."),t([])}finally{r(!1)}},[]);d.useEffect(()=>{i()},[i]);const l=d.useMemo(()=>{const c={};return e.forEach(u=>{u.name&&(c[u.name]=u.displayName||u.name)}),c},[e]);return d.useMemo(()=>({agents:e,agentNameMap:l,isLoading:n,error:s,refetch:i}),[e,l,n,s,i])},_R=(e,t,n,r)=>{const s=e.find(a=>a.filename===t);return{name:t,mime_type:n,content:r,last_modified:(s==null?void 0:s.last_modified)||new Date().toISOString()}},kR=({sessionId:e,artifacts:t,setArtifacts:n,artifactsRefetch:r,addNotification:s,setError:a,previewArtifact:i,closePreview:l})=>{const[c,u]=d.useState(!1),[h,f]=d.useState(null),[p,m]=d.useState(!1),[v,g]=d.useState(!1),[x,w]=d.useState(new Set),y=d.useRef(new Set),C=d.useCallback(async(P,E,R,_=!1)=>{const M=E||e,L=new FormData;if(L.append("upload_file",P),L.append("filename",P.name),L.append("sessionId",M||""),R){const F={description:R};L.append("metadata_json",JSON.stringify(F))}try{const F=await Ie.webui.post("/api/v1/artifacts/upload",L,{fullResponse:!0});if(F.status===413){const O=await F.json().catch(()=>({message:`Failed to upload ${P.name}.`})),K=O.actual_size_bytes,$=O.max_size_bytes,W=K&&$?L2(P.name,K,$):O.message||`File "${P.name}" exceeds the maximum allowed size.`;return a({title:"File Upload Failed",error:W}),{error:W}}if(!F.ok)throw new Error(await F.json().then(O=>O.message).catch(()=>`Failed to upload ${P.name}.`));const D=await F.json();return _||s(`File "${P.name}" uploaded.`,"success"),await r(),D.uri&&D.sessionId?{uri:D.uri,sessionId:D.sessionId}:null}catch(F){const D=Zt(F,`Failed to upload "${P.name}".`);return a({title:"File Upload Failed",error:D}),{error:D}}},[e,s,r,a]),S=d.useCallback(async P=>{try{await Ie.webui.delete(`/api/v1/artifacts/${e}/${encodeURIComponent(P)}`),s(`File "${P}" deleted.`,"success"),r()}catch(E){a({title:"File Deletion Failed",error:Zt(E,`Failed to delete ${P}.`)})}},[e,s,r,a]),j=d.useCallback(P=>{f(P),u(!0)},[]),I=d.useCallback(()=>{f(null),u(!1)},[]),b=d.useCallback(async()=>{if(h){const P=(i==null?void 0:i.filename)===h.filename;await S(h.filename),P&&l()}I()},[h,S,I,i,l]),k=d.useCallback(()=>{x.size!==0&&m(!0)},[x]),N=d.useCallback(async()=>{m(!1);const P=Array.from(x);let E=0,R=0;for(const _ of P)try{await Ie.webui.delete(`/api/v1/artifacts/${e}/${encodeURIComponent(_)}`),E++}catch(M){console.error(M),R++}E>0&&s(`${E} files(s) deleted.`,"success"),R>0&&a({title:"File Deletion Failed",error:`${R} file(s) failed to delete.`}),r(),w(new Set),g(!1)},[x,s,r,e,a]),A=d.useCallback(async P=>{if(y.current.has(P))return console.log(`[useArtifactOperations] Skipping duplicate download for ${P} - already in progress`),null;y.current.add(P);try{const E=t.find(O=>O.filename===P);if(!E)return console.error(`Artifact ${P} not found in state`),null;const R=await Ie.webui.get(`/api/v1/artifacts/${e}/${encodeURIComponent(P)}/versions`);if(!R||R.length===0)throw new Error("No versions available");const _=Math.max(...R),M=await Ie.webui.get(`/api/v1/artifacts/${e}/${encodeURIComponent(P)}/versions/${_}`,{fullResponse:!0});if(!M.ok)throw new Error(`Failed to fetch artifact content: ${M.statusText}`);const L=await M.blob(),F=await Gw(L),D=_R(t,P,E.mime_type||"application/octet-stream",F);return n(O=>O.map(K=>K.filename===P?{...K,accumulatedContent:void 0,needsEmbedResolution:!1}:K)),D}catch(E){return a({title:"File Download Failed",error:Zt(E,`Failed to download ${P}.`)}),null}finally{y.current.delete(P)}},[e,t,n,a]);return{uploadArtifactFile:C,isDeleteModalOpen:c,artifactToDelete:h,openDeleteModal:j,closeDeleteModal:I,confirmDelete:b,isArtifactEditMode:v,setIsArtifactEditMode:g,selectedArtifactFilenames:x,setSelectedArtifactFilenames:w,isBatchDeleteModalOpen:p,setIsBatchDeleteModalOpen:m,handleDeleteSelectedArtifacts:k,confirmBatchDeleteArtifacts:N,downloadAndResolveArtifact:A}},jR=({sessionId:e,projectId:t,artifacts:n,setError:r})=>{const[s,a]=d.useState({filename:null,availableVersions:null,currentVersion:null,content:null}),[i,l]=d.useState(!1),c=d.useRef(new Set),u=d.useMemo(()=>s.filename&&n.find(g=>g.filename===s.filename)||null,[n,s.filename]),h=d.useCallback((g,x,w)=>{const y=n.find(C=>C.filename===g);return{name:g,mime_type:x,content:w,last_modified:(y==null?void 0:y.last_modified)||new Date().toISOString()}},[n]),f=d.useCallback(async g=>{if(c.current.has(g))return null;c.current.add(g),l(!0),s.filename!==g&&a({filename:g,availableVersions:null,currentVersion:null,content:null});try{const x=qw({filename:g,sessionId:e,projectId:t}),w=await Ie.webui.get(x);if(!w||w.length===0)throw new Error("No versions available");const y=w.sort((b,k)=>b-k),C=Math.max(...w),{content:S,mimeType:j}=await Qp({filename:g,sessionId:e,projectId:t,version:C}),I=h(g,j,S);return a({filename:g,availableVersions:y,currentVersion:C,content:I}),I}catch(x){const w=Zt(x,"Failed to load artifact preview.");return r==null||r({title:"Artifact Preview Failed",error:w}),null}finally{l(!1),c.current.delete(g)}},[e,t,s.filename,h,r]),p=d.useCallback(async(g,x)=>{if(!s.availableVersions||s.availableVersions.length===0)return null;if(!s.availableVersions.includes(x))return console.warn(`Requested version ${x} not available for ${g}`),null;l(!0),a(w=>({...w,content:null}));try{const{content:w,mimeType:y}=await Qp({filename:g,sessionId:e,projectId:t,version:x}),C=h(g,y,w);return a(S=>({...S,currentVersion:x,content:C})),C}catch(w){const y=Zt(w,"Failed to fetch artifact version.");return r==null||r({title:"Artifact Version Preview Failed",error:y}),null}finally{l(!1)}},[e,t,s.availableVersions,h,r]),m=d.useCallback(()=>{a({filename:null,availableVersions:null,currentVersion:null,content:null})},[]),v=d.useCallback(g=>{g?s.filename!==g.filename&&a({filename:g.filename,availableVersions:null,currentVersion:null,content:null}):m()},[s.filename,m]);return{preview:s,previewArtifact:u,isLoading:i,openPreview:f,navigateToVersion:p,closePreview:m,setPreviewByArtifact:v}};function ER(e,t){if(t&&t.toLowerCase().startsWith("text/"))return!0;if(!e)return!1;const n=e.toLowerCase();return!!(n.endsWith(".txt")||n.endsWith(".text")||n.endsWith(".sql")||n.endsWith(".xml")||n.endsWith(".toml")||n.endsWith(".ini")||n.endsWith(".conf")||n.endsWith(".config")||n.endsWith(".properties")||n.endsWith(".py")||n.endsWith(".js")||n.endsWith(".ts")||n.endsWith(".jsx")||n.endsWith(".tsx")||n.endsWith(".java")||n.endsWith(".c")||n.endsWith(".cpp")||n.endsWith(".h")||n.endsWith(".hpp")||n.endsWith(".cs")||n.endsWith(".go")||n.endsWith(".rs")||n.endsWith(".rb")||n.endsWith(".php")||n.endsWith(".swift")||n.endsWith(".kt")||n.endsWith(".scala")||n.endsWith(".sh")||n.endsWith(".bash")||n.endsWith(".zsh")||n.endsWith(".bat")||n.endsWith(".cmd")||n.endsWith(".ps1")||n.endsWith(".css")||n.endsWith(".scss")||n.endsWith(".sass")||n.endsWith(".less")||n.endsWith(".log")||n.endsWith(".env")||n.endsWith(".gitignore")||n.endsWith(".dockerignore")||n.endsWith(".editorconfig"))}function NR(e,t){if(t){const n=t.toLowerCase();if(n==="text/html"||n==="application/xhtml+xml")return!0}return e?e.toLowerCase().endsWith(".html")||e.toLowerCase().endsWith(".htm"):!1}function TR(e,t){if(t){const n=t.toLowerCase();if(n==="text/x-mermaid"||n==="application/x-mermaid")return!0}return e?e.toLowerCase().endsWith(".mermaid")||e.toLowerCase().endsWith(".mmd"):!1}function AR(e,t){if(t){const n=t.toLowerCase();if(n==="text/csv"||n==="application/csv")return!0}return e?e.toLowerCase().endsWith(".csv"):!1}function IR(e,t){if(t){const r=t.toLowerCase();if(r.startsWith("image/"))return!0;if(r.startsWith("text/")||r.startsWith("application/"))return!1}if(!e)return!1;const n=e.toLowerCase();return n.endsWith(".png")||n.endsWith(".jpg")||n.endsWith(".jpeg")||n.endsWith(".gif")||n.endsWith(".bmp")||n.endsWith(".webp")||n.endsWith(".svg")}function RR(e,t){if(t){const n=t.toLowerCase();if(n==="application/json"||n==="text/json")return!0}return e?e.toLowerCase().endsWith(".json"):!1}function PR(e,t){if(t){const r=t.toLowerCase();if(r==="application/yaml"||r==="text/yaml"||r==="application/x-yaml"||r==="text/x-yaml")return!0}if(!e)return!1;const n=e.toLowerCase();return n.endsWith(".yaml")||n.endsWith(".yml")}function MR(e,t){if(t){const r=t.toLowerCase();if(r==="text/markdown"||r==="application/markdown"||r==="text/x-markdown")return!0}if(!e)return!1;const n=e.toLowerCase();return n.endsWith(".md")||n.endsWith(".markdown")}function DR(e,t){if(t){const r=t.toLowerCase();if(r.startsWith("audio/"))return!0;if(r.startsWith("text/")||r.startsWith("application/")||r.startsWith("image/"))return!1}if(!e)return!1;const n=e.toLowerCase();return n.endsWith(".mp3")||n.endsWith(".wav")||n.endsWith(".ogg")||n.endsWith(".aac")||n.endsWith(".flac")||n.endsWith(".m4a")}function Hr(e,t){return NR(e,t)?"html":TR(e,t)?"mermaid":IR(e,t)?"image":MR(e,t)?"markdown":DR(e,t)?"audio":RR(e,t)?"json":PR(e,t)?"yaml":AR(e,t)?"csv":ER(e,t)?"text":null}function Fy(e){try{const t=Uint8Array.from(atob(e),n=>n.charCodeAt(0));return new TextDecoder("utf-8",{fatal:!1}).decode(t)}catch(t){console.warn("TextDecoder failed (potentially non-UTF8 data), falling back to simple atob:",t);try{return atob(e)}catch(n){return console.error("Failed to decode base64 content with atob fallback:",n),e}}}const zy=["csv","html","json","mermaid","image","markdown","audio","text","yaml"],OR=["image","audio"],$y=e=>{if(!e||!e.content)return"";const t=Hr(e.name,e.mime_type);if(!t||!zy.includes(t))return"";if(OR.includes(t)||e.isPlainText)return e.content;try{return Fy(e.content)}catch(n){return console.error("Failed to decode base64 content:",n),""}},Uy=5*1024*1024,LR=ds(Uy);function FR(e){if(!e||!e.size)return{canPreview:!1,reason:"No artifact or content available."};const t=Hr(e.filename,e.mime_type);return!t||!zy.includes(t)?{canPreview:!1,reason:"Preview not yet supported for this file type."}:e.size>Uy?{canPreview:!1,reason:`Preview not supported for files this large. Maximum size is: ${LR}.`}:{canPreview:!0}}const zR=(e,t="h-4 w-4")=>{if(!e)return o.jsx(kc,{className:t});switch(Hr(e.filename,e.mime_type)){case"image":case"mermaid":return o.jsx(sf,{className:t});case"audio":return o.jsx(rf,{className:t});case"html":return o.jsx(Cv,{className:t});case"text":return o.jsx(Sr,{className:t});case"csv":return o.jsx(nf,{className:t});case"json":return o.jsx(bv,{className:t});default:return o.jsx(kc,{className:t})}},$R=(e,t)=>{const n=Hr(e,t);return n==="image"||n==="audio"||n==="text"||n==="markdown"},UR=(e,t)=>{const n=Hr(e,t);return n?["text","markdown","json","yaml","csv","html","image","audio"].includes(n):!1},BR=({filename:e,mimeType:t,shouldAutoExpand:n})=>{const r=d.useMemo(()=>$R(e,t),[e,t]),[s,a]=d.useState(()=>n??r),i=d.useRef(!1);d.useEffect(()=>{n&&!s&&!i.current&&a(!0)},[n,s]);const l=d.useMemo(()=>UR(e,t),[e,t]),c=d.useMemo(()=>l?s:!1,[l,s]),u=d.useMemo(()=>l,[l]),h=d.useCallback(()=>{if(!e||!u){console.log(`[useArtifactRendering] Toggle blocked - filename: ${e}, isExpandable: ${u}`);return}i.current=!0,a(f=>{const p=!f;return console.log(`[useArtifactRendering] ${p?"Expanding":"Collapsing"} ${e}`),p})},[e,u]);return{shouldRender:c,isExpandable:u,isExpanded:s,toggleExpanded:h}},Id="lastViewedProjectId",By=d.createContext(void 0);let Mf=null;const VR=e=>{Mf=e},HR=({children:e})=>{const{projectsEnabled:t}=on(),[n,r]=d.useState([]),[s,a]=d.useState(!0),[i,l]=d.useState(null),[c,u]=d.useState(null),[h,f]=d.useState(null),[p,m]=d.useState(null),[v,g]=d.useState(""),x=d.useMemo(()=>{if(!v.trim())return n;const A=v.toLowerCase();return n.filter(P=>{var E;return P.name.toLowerCase().includes(A)||(((E=P.description)==null?void 0:E.toLowerCase().includes(A))??!1)})},[n,v]),w=d.useCallback(async()=>{if(!t){a(!1),r([]);return}a(!0),l(null);try{const P=[...(await Ie.webui.get("/api/v1/projects?include_artifact_count=true")).projects].sort((E,R)=>E.name.toLowerCase().localeCompare(R.name.toLowerCase()));r(P)}catch(A){console.error("Error fetching projects:",A),l(A instanceof Error?A.message:"Could not load projects."),r([])}finally{a(!1)}},[t]),y=d.useCallback(async A=>{if(!t)throw new Error("Projects feature is disabled");const P=await Ie.webui.post("/api/v1/projects",A);return r(E=>[P,...E].sort((_,M)=>_.name.toLowerCase().localeCompare(M.name.toLowerCase()))),P},[t]),C=d.useCallback(async(A,P)=>{if(!t)throw new Error("Projects feature is disabled");const E=await Ie.webui.post(`/api/v1/projects/${A}/artifacts`,P,{fullResponse:!0});if(!E.ok){const R=await E.text();let _=`Failed to add files: ${E.statusText}`;try{const M=JSON.parse(R);_=M.detail||M.message||_}catch{R&&R.length<500&&(_=R)}throw E.status===413&&!_.includes("exceeds maximum")&&!_.includes("too large")&&(_="One or more files exceed the maximum allowed size. Please try uploading smaller files."),new Error(_)}l(null),await w()},[t,w]),S=d.useCallback(async(A,P)=>{if(!t)throw new Error("Projects feature is disabled");await Ie.webui.delete(`/api/v1/projects/${A}/artifacts/${encodeURIComponent(P)}`),l(null),await w()},[t,w]),j=d.useCallback(async(A,P,E)=>{if(!t)throw new Error("Projects feature is disabled");const R=new FormData;R.append("description",E),await Ie.webui.patch(`/api/v1/projects/${A}/artifacts/${encodeURIComponent(P)}`,R),l(null)},[t]),I=d.useCallback(async(A,P)=>{if(!t)throw new Error("Projects feature is disabled");const E=await Ie.webui.put(`/api/v1/projects/${A}`,P,{fullResponse:!0});if(!E.ok){let _=`Failed to update project: ${E.statusText}`;try{const M=await E.json();E.status===422?M.detail&&(Array.isArray(M.detail)?_=`Validation error: ${M.detail.map(F=>{var O;return`${((O=F.loc)==null?void 0:O.join("."))||"field"}: ${F.msg}`}).join(", ")}`:typeof M.detail=="string"&&(_=M.detail)):_=M.detail||M.message||_}catch{}throw new Error(_)}const R=await E.json();return r(_=>_.map(L=>L.id===R.id?R:L).sort((L,F)=>L.name.toLowerCase().localeCompare(F.name.toLowerCase()))),u(_=>(_==null?void 0:_.id)===R.id?R:_),f(_=>(_==null?void 0:_.id)===R.id?R:_),m(_=>(_==null?void 0:_.id)===R.id?R:_),l(null),R},[t]),b=d.useCallback(async A=>{if(!t)throw new Error("Projects feature is disabled");await Ie.webui.delete(`/api/v1/projects/${A}`),r(P=>P.filter(E=>E.id!==A)),u(P=>(P==null?void 0:P.id)===A?null:P),f(P=>(P==null?void 0:P.id)===A?null:P),m(P=>(P==null?void 0:P.id)===A?null:P),l(null),Mf&&Mf(A)},[t]);d.useEffect(()=>{w()},[w]),d.useEffect(()=>{if(n.length>0&&!h){const A=localStorage.getItem(Id);if(A){const P=n.find(E=>E.id===A);P&&f(P)}}},[n,h]);const k=d.useCallback(A=>{f(A),A?localStorage.setItem(Id,A.id):localStorage.removeItem(Id)},[]),N={projects:n,isLoading:s,error:i,createProject:y,refetch:w,currentProject:c,setCurrentProject:u,selectedProject:h,setSelectedProject:k,activeProject:p,setActiveProject:m,addFilesToProject:C,removeFileFromProject:S,updateFileMetadata:j,updateProject:I,deleteProject:b,searchQuery:v,setSearchQuery:g,filteredProjects:x};return o.jsx(By.Provider,{value:N,children:e})},Bs=()=>{const e=d.useContext(By);if(e===void 0)throw new Error("useProjectContext must be used within a ProjectProvider");return e},WR=e=>e?e.startsWith("web_content_"):!1,ZR=e=>{const{activeProject:t}=Bs(),[n,r]=d.useState([]),[s,a]=d.useState(!0),[i,l]=d.useState(null),c=d.useCallback(async()=>{a(!0),l(null);try{let u;if(e&&e.trim()&&e!=="null"&&e!=="undefined")u=`/api/v1/artifacts/${e}`;else if(t!=null&&t.id)u=`/api/v1/artifacts/null?project_id=${t.id}`;else{r([]),a(!1);return}const p=(await Ie.webui.get(u)).filter(m=>!WR(m.filename)).map(m=>({...m,uri:m.uri||`artifact://${e}/${m.filename}`}));r(p)}catch(u){const h=u instanceof Error?u.message:"Failed to fetch artifacts.";l(h),r([])}finally{a(!1)}},[e,t==null?void 0:t.id]);return d.useEffect(()=>{c()},[c]),{artifacts:n,isLoading:s,error:i,refetch:c,setArtifacts:r}},Vy=d.createContext(void 0),Ns={speechToText:"speechToText",engineSTT:"engineSTT",sttProvider:"sttProvider",languageSTT:"languageSTT",autoSendText:"autoSendText",autoTranscribeAudio:"autoTranscribeAudio",decibelThreshold:"decibelThreshold",textToSpeech:"textToSpeech",engineTTS:"engineTTS",ttsProvider:"ttsProvider",voice:"voice",playbackRate:"playbackRate",automaticPlayback:"automaticPlayback",cacheTTS:"cacheTTS",cloudBrowserVoices:"cloudBrowserVoices",conversationMode:"conversationMode",advancedMode:"advancedMode"},Sc={speechToText:!1,engineSTT:"browser",sttProvider:"browser",languageSTT:"en-US",autoSendText:-1,autoTranscribeAudio:!0,decibelThreshold:-45,textToSpeech:!0,engineTTS:"browser",ttsProvider:"browser",voice:"Kore",playbackRate:1,automaticPlayback:!1,cacheTTS:!0,cloudBrowserVoices:!1,conversationMode:!1,advancedMode:!1};function GR(){const e={...Sc};try{Object.entries(Ns).forEach(([t,n])=>{const r=localStorage.getItem(n);if(r!==null){const s=t;typeof Sc[s]=="boolean"?e[s]=r==="true":typeof Sc[s]=="number"?e[s]=parseFloat(r):e[s]=r}})}catch(t){console.error("Error loading audio settings from storage:",t)}return e}const qR=({children:e})=>{const[t,n]=d.useState(GR),[r,s]=d.useState(!1),[a,i]=d.useState(!1);d.useEffect(()=>{(async()=>{try{const g=(await Ie.webui.get("/api/v1/config")).tts_settings||{};let x=!1,w=!1;try{const y=await Ie.webui.get("/api/v1/speech/config");x=y.sttExternal||!1,w=y.ttsExternal||!1}catch(y){console.error("Error fetching speech config:",y)}n(y=>{const C={...y};return Object.entries(g).forEach(([S,j])=>{const I=S,b=Ns[I];I in C&&b&&localStorage.getItem(b)===null&&(C[I]=j)}),C.engineSTT==="external"&&!x&&(console.warn("External STT not configured, falling back to browser mode"),C.engineSTT="browser",C.sttProvider="browser",localStorage.setItem(Ns.engineSTT,"browser"),localStorage.setItem(Ns.sttProvider,"browser")),C.engineTTS==="external"&&!w&&(console.warn("External TTS not configured, falling back to browser mode"),C.engineTTS="browser",C.ttsProvider="browser",localStorage.setItem(Ns.engineTTS,"browser"),localStorage.setItem(Ns.ttsProvider,"browser")),C})}catch(v){console.error("Error fetching TTS config from config endpoint:",v)}finally{s(!0)}})()},[]);const l=d.useCallback((m,v)=>{n(g=>{const x={...g,[m]:v},w=Ns[m];return w&&(localStorage.setItem(w,String(v)),console.log(`Saved ${m} = ${v} to localStorage as ${w}`)),x})},[]),c=d.useCallback(m=>{n(v=>{const g={...v,...m};return Object.entries(m).forEach(([x,w])=>{const y=Ns[x];y&&localStorage.setItem(y,String(w))}),g})},[]),u=d.useCallback(()=>{n(Sc),Object.values(Ns).forEach(m=>{localStorage.removeItem(m)})},[]),h=d.useCallback(()=>{i(!0)},[]),f=d.useCallback(()=>{i(!1)},[]),p={settings:t,isInitialized:r,updateSetting:l,updateSettings:c,resetSettings:u,speechToTextEndpoint:t.engineSTT,textToSpeechEndpoint:t.engineTTS,isTTSPlaying:a,setIsTTSPlaying:i,onTTSStart:h,onTTSEnd:f};return o.jsx(Vy.Provider,{value:p,children:e})};function So(){const e=d.useContext(Vy);if(!e)throw new Error("useAudioSettings must be used within AudioSettingsProvider");return e}const Hy=d.createContext(null),Wy=()=>{const e=d.useContext(Hy);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e},Jl="sam_background_tasks";function YR({userId:e,onTaskCompleted:t,onTaskFailed:n}){const[r,s]=d.useState([]),[a,i]=d.useState([]);d.useEffect(()=>{const x=localStorage.getItem(Jl);if(x)try{const w=JSON.parse(x);s(w)}catch(w){console.error("[BackgroundTaskMonitor] Failed to parse stored tasks:",w),localStorage.removeItem(Jl)}},[]),d.useEffect(()=>{r.length>0?localStorage.setItem(Jl,JSON.stringify(r)):localStorage.removeItem(Jl)},[r]);const l=d.useCallback((x,w,y)=>{const C={taskId:x,sessionId:w,lastEventTimestamp:Date.now(),isBackground:!0,startTime:Date.now(),agentName:y};s(S=>S.some(j=>j.taskId===x)?S:[...S,C])},[]),c=d.useCallback(x=>{s(w=>w.filter(C=>C.taskId!==x))},[]),u=d.useCallback((x,w)=>{s(y=>y.map(C=>C.taskId===x?{...C,lastEventTimestamp:w}:C))},[]),h=d.useCallback(async x=>{try{const w=await Ie.webui.get(`/api/v1/tasks/${x}/status`,{fullResponse:!0});return w.ok?await w.json():(w.status===404&&c(x),null)}catch(w){return console.error(`[BackgroundTaskMonitor] Failed to check status for task ${x}:`,w),null}},[c]),f=d.useCallback(async()=>{if(r.length!==0)for(const x of r){const w=await h(x.taskId);if(w&&!w.is_running){const y=w.task.status;let C="completed",S="Background task completed";y==="failed"||y==="error"?(C="failed",S="Background task failed"):y==="timeout"&&(C="timeout",S="Background task timed out");const j={taskId:x.taskId,type:C,message:S,timestamp:Date.now()};i(I=>[...I,j]),C==="completed"&&t?t(x.taskId):C!=="completed"&&n&&n(x.taskId,S),c(x.taskId)}}},[r,h,t,n,c]),p=d.useCallback(async()=>{try{return(await Ie.webui.get(`/api/v1/tasks/background/active?user_id=${encodeURIComponent(e)}`)).tasks.map(w=>({taskId:w.id,sessionId:"",lastEventTimestamp:w.last_activity_time||w.start_time,isBackground:!0,startTime:w.start_time}))}catch(x){return console.error("[BackgroundTaskMonitor] Failed to fetch active background tasks:",x),[]}},[e]);d.useEffect(()=>{(async()=>{const w=await p();s(y=>{const C=[...y];for(const S of w)C.some(j=>j.taskId===S.taskId)||C.push(S);return C})})()},[e,p]);const m=d.useCallback(x=>{i(w=>w.filter(y=>y.taskId!==x))},[]),v=d.useCallback(x=>r.filter(w=>w.sessionId===x),[r]),g=d.useCallback(x=>r.some(w=>w.taskId===x),[r]);return{backgroundTasks:r,notifications:a,registerBackgroundTask:l,unregisterBackgroundTask:c,updateTaskTimestamp:u,checkTaskStatus:h,checkAllBackgroundTasks:f,dismissNotification:m,getSessionBackgroundTasks:v,isTaskRunningInBackground:g,fetchActiveBackgroundTasks:p}}const Zy=d.createContext(void 0),$t=()=>{const e=d.useContext(Zy);if(e===void 0)throw new Error("useChatContext must be used within a ChatProvider");return e},Gy=d.createContext(null),qy=d.createContext(null),Yy=d.createContext(void 0),Ky=d.createContext(null);function on(){const e=d.useContext(Gy);if(e===null)throw new Error("useConfig must be used within a ConfigProvider");return e}function KR(){const{messages:e}=$t(),t=on(),n=d.useCallback(r=>{if((t==null?void 0:t.persistenceEnabled)===!1&&!(e.length<=1))return r.preventDefault(),"Are you sure you want to leave? Your chat history will be lost."},[e.length,t==null?void 0:t.persistenceEnabled]);d.useEffect(()=>(window.addEventListener("beforeunload",n),()=>{window.removeEventListener("beforeunload",n)}),[n])}function Xy(){const e=d.useContext(qy);if(!e)throw new Error("useCsrf must be used within a CsrfProvider");return e}function XR(e,t){const[n,r]=d.useState(e);return d.useEffect(()=>{const s=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(s)}},[e,t]),n}const JR=async(e,t,n)=>{const r=e&&e.trim()&&e!=="null"&&e!=="undefined";let s;if(r)s=`/api/v1/artifacts/${e.trim()}/${encodeURIComponent(n.filename)}`;else if(t)s=`/api/v1/artifacts/null/${encodeURIComponent(n.filename)}?project_id=${t}`;else throw new Error("No valid session or project context for downloading artifact.");const a=await Ie.webui.get(s,{fullResponse:!0});if(!a.ok)throw new Error(`Failed to download artifact: ${a.statusText}`);const i=await a.blob();hl(i,n.filename)},hm=e=>{const{addNotification:t,sessionId:n,displayError:r}=$t(),{activeProject:s}=Bs();return{onDownload:async i=>{try{const l=e||(s==null?void 0:s.id)||null;await JR(n,l,i),t(`Downloaded artifact: ${i.filename}.`,"success")}catch(l){r({title:"Failed to Download Artifact",error:Zt(l,"An unknown error occurred while downloading the artifact.")})}}}},QR=({onFilesDropped:e,fileFilter:t,disabled:n=!1})=>{const[r,s]=d.useState(!1),a=d.useRef(0),i=d.useCallback(h=>{n||(h.preventDefault(),h.stopPropagation(),a.current=(a.current||0)+1,h.dataTransfer.types.includes("Files")&&s(!0))},[n,a]),l=d.useCallback(h=>{n||(h.preventDefault(),h.stopPropagation(),h.dataTransfer.types.includes("Files")&&(h.dataTransfer.dropEffect="copy"))},[n]),c=d.useCallback(h=>{n||(h.preventDefault(),h.stopPropagation(),a.current=(a.current||0)-1,a.current===0&&s(!1))},[n,a]),u=d.useCallback(h=>{if(n||(h.preventDefault(),h.stopPropagation(),s(!1),a.current=0,!h.dataTransfer.files||h.dataTransfer.files.length===0))return;const f=Array.from(h.dataTransfer.files),p=t?f.filter(t):f;p.length!==0&&e(p)},[n,a,t,e]);return{isDragging:r,handleDragEnter:i,handleDragOver:l,handleDragLeave:c,handleDrop:u}},eP=e=>e?e.startsWith("web_content_"):!1,tP=e=>{const[t,n]=d.useState([]),[r,s]=d.useState(!0),[a,i]=d.useState(null),l=d.useCallback(async()=>{if(!e){n([]),s(!1);return}s(!0),i(null);try{const u=(await Ie.webui.get(`/api/v1/projects/${e}/artifacts`)).filter(h=>!eP(h.filename));n(u)}catch(c){const u=c instanceof Error?c.message:"Failed to fetch project artifacts.";i(u),n([])}finally{s(!1)}},[e]);return d.useEffect(()=>{l()},[l]),{artifacts:t,isLoading:r,error:a,refetch:l}};function nP(){const e=["audio/webm","audio/webm;codecs=opus","audio/mp4","audio/ogg;codecs=opus","audio/ogg","audio/wav"];for(const n of e)if(MediaRecorder.isTypeSupported(n))return n;const t=navigator.userAgent.toLowerCase();return t.indexOf("safari")!==-1&&t.indexOf("chrome")===-1?"audio/mp4":t.indexOf("firefox")!==-1?"audio/ogg":"audio/webm"}function rP(e){const t={"audio/webm":"webm","audio/mp4":"mp4","audio/ogg":"ogg","audio/wav":"wav"};for(const[n,r]of Object.entries(t))if(e.includes(n))return r;return"webm"}function sP(e={}){const{onTranscriptionComplete:t,onTranscriptionUpdate:n,onError:r}=e,{settings:s,updateSetting:a}=So(),[i,l]=d.useState(!1),[c,u]=d.useState(!1),[h,f]=d.useState(null),[p,m]=d.useState(""),v=d.useRef(null),g=d.useRef(null),x=d.useRef([]),w=d.useRef(null),y=s.engineSTT==="browser",C=d.useCallback(()=>{if(v.current){try{v.current.stop()}catch{}v.current=null}if(g.current&&g.current.state!=="inactive")try{g.current.stop()}catch{}w.current&&(w.current.getTracks().forEach(P=>P.stop()),w.current=null),x.current=[]},[]),S=d.useCallback(async()=>{const P=window.SpeechRecognition||window.webkitSpeechRecognition;if(!P){const E="Speech recognition is not supported in this browser. Please use Chrome, Edge, or Safari, or switch to External API mode in settings.";f(E),r==null||r(E),console.error("Browser STT not supported. Available:",{SpeechRecognition:!!window.SpeechRecognition,webkitSpeechRecognition:!!window.webkitSpeechRecognition,userAgent:navigator.userAgent});return}try{const E=new P;E.continuous=!0,E.interimResults=!0,E.lang=s.languageSTT||"en-US",E.onstart=()=>{l(!0),f(null)},E.onresult=R=>{let _="",M="";for(let F=R.resultIndex;F<R.results.length;F++){const D=R.results[F],O=D[0].transcript;D.isFinal?M+=O+" ":_+=O}const L=(M+_).trim();m(L),n==null||n(L),M&&(t==null||t(M.trim()))},E.onerror=R=>{const _=`Speech recognition error: ${R.error}`;f(_),r==null||r(_),l(!1)},E.onend=()=>{l(!1)},v.current=E,E.start()}catch(E){const R=`Failed to start speech recognition: ${E}`;f(R),r==null||r(R)}},[s.languageSTT,t,n,r]),j=d.useCallback(async()=>{v.current&&(v.current.stop(),v.current=null),l(!1)},[]),I=d.useCallback(async()=>{try{if(!(await Ie.webui.get("/api/v1/speech/config")).sttExternal){a("engineSTT","browser");const E="External STT is not configured. Switched to Browser mode. Please click the microphone button again.";f(E),r==null||r(E);return}}catch(P){const E=`Failed to check STT configuration: ${Zt(P,"Please try again.")}`;f(E),r==null||r(E);return}try{const P=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1});w.current=P,x.current=[];const E=nP(),R=new MediaRecorder(P,{mimeType:E});R.ondataavailable=_=>{_.data.size>0&&x.current.push(_.data)},R.onstop=async()=>{u(!0);try{if(x.current.length===0)throw new Error("No audio data recorded");const _=new Blob(x.current,{type:E}),M=rP(E),L=new FormData;L.append("audio",_,`audio.${M}`),s.sttProvider&&s.sttProvider!=="browser"&&L.append("provider",s.sttProvider),s.languageSTT&&L.append("language",s.languageSTT);const F=await Ie.webui.post("/api/v1/speech/stt",L,{fullResponse:!0});if(!F.ok){const K=await F.text();let $="";try{const W=JSON.parse(K);$=W.detail||W.message||W.error||""}catch{$=K}throw new Error($||`Transcription failed: ${F.statusText}`)}const O=(await F.json()).text||"";m(O),t==null||t(O)}catch(_){const M=`Transcription error: ${_}`;f(M),r==null||r(M)}finally{u(!1),C()}},g.current=R,R.start(100),l(!0),f(null)}catch(P){const E=`Failed to access microphone: ${P}`;f(E),r==null||r(E),C()}},[s.sttProvider,s.languageSTT,t,r,C,a]),b=d.useCallback(async()=>{g.current&&g.current.state!=="inactive"&&g.current.stop(),l(!1)},[]),k=d.useCallback(async()=>{f(null),m(""),y?await S():await I()},[y,S,I]),N=d.useCallback(async()=>{y?await j():await b()},[y,j,b]),A=d.useCallback(()=>{m(""),f(null)},[]);return d.useEffect(()=>()=>{C()},[C]),{isListening:i,isLoading:c,error:h,transcript:p,startRecording:k,stopRecording:N,resetTranscript:A}}function oP(e,t){const[n,r]=d.useState("");return d.useEffect(()=>{let s,a=Date.now();const i=()=>{const l=Date.now(),c=l-a;a=l;const u=e.current,h=t.current;h.length<u.cursor&&(u.cursor=h.length),h.length-u.cursor>0?(u.cursor+=u.speed*c,u.cursor>h.length&&(u.cursor=h.length),r(h.slice(0,Math.floor(u.cursor)))):h.length>0&&r(p=>p!==h?h:p),s=requestAnimationFrame(i)};return s=requestAnimationFrame(i),()=>{cancelAnimationFrame(s)}},[e,t]),n}const aP=.03,iP=500,lP=.05,cP=.2,uP=200,dP=20,fP=5e3,hP=1.5,mP=.5,pP=.8,gP=.005,xP=3;function vP(e){const t=d.useRef({cursor:0,speed:aP,lastArrivalTime:0,avgInterval:iP,lastLen:0}),n=d.useRef(e);return d.useEffect(()=>{n.current=e;const r=Date.now(),s=t.current;if(e.length-s.lastLen>0){if(s.lastArrivalTime===0)s.lastArrivalTime=r;else{let u=r-s.lastArrivalTime;u=Math.max(dP,Math.min(fP,u));const h=u<uP?lP:cP;s.avgInterval=s.avgInterval*(1-h)+u*h,s.lastArrivalTime=r}const l=(e.length-s.cursor)/(s.avgInterval*hP),c=l>s.speed?mP:pP;s.speed=s.speed*c+l*(1-c),s.speed=Math.max(gP,Math.min(xP,s.speed)),s.lastLen=e.length}},[e]),{state:t,contentRef:n}}function wP(e){const{messageId:t,onStart:n,onEnd:r,onError:s}=e,{settings:a,onTTSStart:i,onTTSEnd:l}=So(),[c,u]=d.useState(!1),[h,f]=d.useState(!1),[p,m]=d.useState(null),v=d.useRef(new Set),g=d.useRef([]),x=d.useRef(!1),w=d.useRef(null),y=d.useRef(""),C=d.useRef(0),S=d.useRef(!1),j=d.useRef(!1),I=d.useRef(!1),b=d.useRef(null),k=d.useRef(null),N=d.useRef(n),A=d.useRef(r),P=d.useRef(s),E=d.useRef(i),R=d.useRef(l);d.useEffect(()=>{N.current=n,A.current=r,P.current=s,E.current=i,R.current=l},[n,r,s,i,l]);const _=d.useCallback(K=>{const $=/[^.!?]+[.!?]+(?:\s|$)/g;return(K.match($)||[]).map(V=>V.trim()).filter(V=>V.length>0)},[]),M=d.useCallback(async K=>{var $;try{console.log(`[StreamingTTS] Requesting streaming TTS for text length: ${K.length}`);const W=await Ie.webui.post("/api/v1/speech/tts/stream",{input:K,voice:a.voice,runId:t},{fullResponse:!0});if(!W.ok)throw new Error(`TTS streaming failed: ${W.statusText}`);const V=($=W.body)==null?void 0:$.getReader();if(!V)throw new Error("No response body reader available");const X=[];let H=0;for(;;){const{done:de,value:fe}=await V.read();if(de)break;fe&&(X.push(fe),H+=fe.length)}console.log(`[StreamingTTS] Received ${X.length} chunks, total size: ${H} bytes`);const Q=new Uint8Array(H);let z=0;for(const de of X)Q.set(de,z),z+=de.length;const Z=new Blob([Q],{type:"audio/mpeg"});if(console.log(`[StreamingTTS] Created audio blob: size=${Z.size}, type=${Z.type}`),Z.size===0)throw new Error("Received empty audio stream");const J=URL.createObjectURL(Z),ce=new Audio;return ce.onerror=de=>{const fe=ce.error;console.error(`[StreamingTTS] Audio error: code=${fe==null?void 0:fe.code}, message=${fe==null?void 0:fe.message}`,de)},ce.src=J,ce.playbackRate=a.playbackRate||1,ce.load(),ce}catch(W){return console.error("[StreamingTTS] Error generating streamed audio:",W),null}},[a.voice,a.playbackRate,t]),L=d.useCallback(()=>{if(S.current){console.log("[StreamingTTS] Skipping playback - stopped");return}if(x.current||g.current.length===0)return;x.current=!0;const K=g.current.shift();if(!K){x.current=!1;return}const{audio:$,sentence:W}=K;w.current=$,console.log(`[StreamingTTS] Playing sentence: "${W.substring(0,50)}..."`),$.onplay=()=>{var V;console.log("[StreamingTTS] Audio onplay event fired"),u(!0),f(!1),j.current||(console.log("[StreamingTTS] First audio playing, notifying global state"),j.current=!0,(V=N.current)==null||V.call(N),E.current&&E.current())},$.onended=()=>{var V;if(console.log("[StreamingTTS] Audio onended event fired"),URL.revokeObjectURL($.src),w.current=null,x.current=!1,g.current.length>0)console.log("[StreamingTTS] More audio in queue, playing next"),L();else if(!I.current)console.log("[StreamingTTS] All audio played and generation complete, notifying global state"),u(!1),(V=A.current)==null||V.call(A),R.current&&R.current();else{console.log("[StreamingTTS] Queue empty but still generating, polling...");let X=0;const H=100,Q=setInterval(()=>{var z,Z;X++,g.current.length>0?(console.log("[StreamingTTS] New audio arrived during poll, playing"),clearInterval(Q),L()):!I.current&&!x.current?(console.log("[StreamingTTS] Generation finished and not playing, notifying global state"),clearInterval(Q),u(!1),(z=A.current)==null||z.call(A),R.current&&R.current()):X>=H&&(console.log("[StreamingTTS] Poll timeout after 10s, forcing end"),clearInterval(Q),I.current=!1,u(!1),(Z=A.current)==null||Z.call(A),R.current&&R.current())},100)}},$.onerror=()=>{var H,Q;const V=(H=$.error)==null?void 0:H.code;if(V===1){console.log("[StreamingTTS] Ignoring ABORTED error (expected during stop)");return}const X=`Failed to play audio (code: ${V})`;m(X),(Q=P.current)==null||Q.call(P,X),URL.revokeObjectURL($.src),w.current=null,x.current=!1,g.current.length>0?L():(u(!1),r==null||r(),l())},$.play().catch(V=>{if(V.name==="AbortError"){console.log("[StreamingTTS] Ignoring AbortError from play() (expected during stop)");return}console.error("[StreamingTTS] Error playing audio:",V),x.current=!1,L()})},[r,l]),F=d.useCallback(async(K,$)=>{if(console.log(`[StreamingTTS] doProcessing called: textLen=${K.length}, isComplete=${$}`),S.current){console.log("[StreamingTTS] Skipping - stopped");return}const W=_(K),V=W.join(" ");if($){const H=W[W.length-1]||"",Q=K.lastIndexOf(H)+H.length,z=K.substring(Q).trim();z&&console.log(`[StreamingTTS] Adding remaining text: "${z.substring(0,50)}..."`)}const X=$?K:V;if(v.current.has(X)||X.length<10){console.log("[StreamingTTS] Skipping - already processed or too short");return}v.current.add(X),y.current=K,C.current=K.length,console.log(`[StreamingTTS] Processing text (${X.length} chars)`),f(!0),S.current=!1,I.current=!0;try{const H=await M(X);H&&!S.current&&(g.current.push({audio:H,sentence:X.substring(0,50),index:g.current.length}),console.log(`[StreamingTTS] Added audio to queue (size: ${g.current.length})`),x.current||(console.log("[StreamingTTS] Starting playback"),L()))}catch(H){console.error("[StreamingTTS] Error processing:",H)}f(!1),$&&(I.current=!1,console.log("[StreamingTTS] Message complete"))},[_,M,L]),D=d.useCallback(async(K,$)=>{if(b.current){console.log("[StreamingTTS] Already processing, queuing update"),k.current={text:K,isComplete:$};return}b.current=F(K,$);try{await b.current}finally{if(b.current=null,k.current){const W=k.current;k.current=null,console.log("[StreamingTTS] Processing queued update"),await D(W.text,W.isComplete)}}},[F]),O=d.useCallback(()=>{if(!(!x.current&&g.current.length===0)){if(console.log("[StreamingTTS] Stopping playback"),S.current=!0,w.current){try{w.current.pause(),w.current.currentTime=0,URL.revokeObjectURL(w.current.src)}catch{}w.current=null}g.current.forEach(K=>{try{URL.revokeObjectURL(K.audio.src)}catch{}}),g.current=[],x.current=!1,u(!1),f(!1),c&&(r==null||r(),l())}},[c,r,l]);return d.useEffect(()=>(v.current.clear(),y.current="",C.current=0,S.current=!1,j.current=!1,I.current=!1,b.current=null,k.current=null,()=>{const $=v.current;if(x.current||g.current.length>0){if(console.log("[StreamingTTS] Cleanup: stopping playback for message change/unmount"),S.current=!0,w.current){try{w.current.pause(),URL.revokeObjectURL(w.current.src)}catch{}w.current=null}g.current.forEach(W=>{try{URL.revokeObjectURL(W.audio.src)}catch{}}),g.current=[],x.current=!1}$.clear(),y.current="",C.current=0,b.current=null,k.current=null}),[t]),{isPlaying:c,isLoading:h,error:p,processStreamingText:D,stop:O}}const mm=()=>{const e=d.useContext(Yy);if(e===void 0)throw new Error("useTaskContext must be used within a TaskProvider");return e};function yP(e={}){const{messageId:t,onStart:n,onEnd:r,onError:s}=e,{settings:a}=So(),[i,l]=d.useState(!1),[c,u]=d.useState(!1),[h,f]=d.useState(null),[p,m]=d.useState([]),v=d.useRef(null),g=d.useRef(null),x=d.useRef(null),w=d.useRef([]),y=d.useRef(!1),C=d.useRef(0),S=a.engineTTS==="browser";d.useEffect(()=>{if(!S)return;const R=()=>{const _=window.speechSynthesis;if(!_)return;const L=_.getVoices().filter(F=>a.cloudBrowserVoices?!0:F.localService).map(F=>({value:F.name,label:`${F.name} (${F.lang})`}));m(L)};return R(),window.speechSynthesis.onvoiceschanged!==void 0&&(window.speechSynthesis.onvoiceschanged=R),()=>{window.speechSynthesis.onvoiceschanged&&(window.speechSynthesis.onvoiceschanged=null)}},[S,a.cloudBrowserVoices]),d.useEffect(()=>{if(S)return;(async()=>{try{const _=a.ttsProvider||"gemini",L=((await Ie.webui.get(`/api/v1/speech/voices?provider=${_}`)).voices||[]).map(F=>({value:F,label:F}));m(L)}catch(_){console.error("Failed to load external voices:",_)}})()},[S,a.ttsProvider]);const j=d.useCallback(()=>{v.current&&(window.speechSynthesis.cancel(),v.current=null),g.current&&(g.current.pause(),g.current.src="",g.current=null),x.current&&(URL.revokeObjectURL(x.current),x.current=null),w.current.forEach(R=>{R.pause(),R.src&&URL.revokeObjectURL(R.src)}),w.current=[],y.current=!1,C.current=0},[]),I=d.useCallback(async R=>{const _=window.speechSynthesis;if(!_){const M="Speech synthesis is not supported in this browser";f(M),s==null||s(M);return}try{_.cancel();const M=new SpeechSynthesisUtterance(R);if(M.rate=a.playbackRate||1,M.lang=a.languageSTT||"en-US",a.voice){const F=_.getVoices().find(D=>D.name===a.voice);F&&(M.voice=F)}M.onstart=()=>{l(!0),f(null),n==null||n()},M.onend=()=>{l(!1),v.current=null,r==null||r()},M.onerror=L=>{const F=`Speech synthesis error: ${L.error}`;f(F),s==null||s(F),l(!1),v.current=null},v.current=M,_.speak(M)}catch(M){const L=`Failed to speak: ${M}`;f(L),s==null||s(L)}},[a.playbackRate,a.languageSTT,a.voice,n,r,s]),b=d.useCallback(()=>{if(!y.current||C.current>=w.current.length){l(!1),y.current=!1,C.current=0,w.current.forEach(M=>{M.src&&URL.revokeObjectURL(M.src)}),w.current=[],r==null||r();return}const R=C.current,_=w.current[R];C.current++,_.onended=()=>{b()},_.onerror=()=>{b()},_.play().catch(M=>{console.error(`[TTS] Failed to play chunk ${R+1}:`,M),b()})},[r]),k=d.useCallback(async R=>{var _;j(),u(!0);try{if(a.cacheTTS){const O=await caches.open("tts-responses"),K=`${R}-${a.voice}-${a.ttsProvider||"default"}`,$=await O.match(K);if($){const W=await $.blob(),V=URL.createObjectURL(W),X=new Audio(V);X.playbackRate=a.playbackRate||1,X.onplay=()=>{l(!0),u(!1),f(null),n==null||n()},X.onended=()=>{l(!1),URL.revokeObjectURL(V),g.current=null,r==null||r()},X.onerror=()=>{const H="Failed to play cached audio";f(H),s==null||s(H),l(!1),u(!1),URL.revokeObjectURL(V)},g.current=X,x.current=V,await X.play();return}}const M=await Ie.webui.post("/api/v1/speech/tts/stream",{input:R,voice:a.voice,runId:t||`tts-${Date.now()}`,provider:a.ttsProvider},{fullResponse:!0});if(!M.ok)throw new Error(`TTS request failed: ${M.statusText}`);const L=(_=M.body)==null?void 0:_.getReader();if(!L)throw new Error("No response body reader available");let F=!1;const D=[];for(w.current=[],C.current=0,y.current=!0;;){const{done:O,value:K}=await L.read();if(O){if(a.cacheTTS&&D.length>0){const $=D.reduce((Z,J)=>Z+J.length,0),W=new Uint8Array($);let V=0;for(const Z of D)W.set(Z,V),V+=Z.length;const X=new Blob([W],{type:"audio/mpeg"}),H=await caches.open("tts-responses"),Q=`${R}-${a.voice}-${a.ttsProvider||"default"}`,z=new Response(X,{headers:{"Content-Type":"audio/mpeg","Content-Length":X.size.toString()}});await H.put(Q,z)}break}if(K&&K.length>0){D.push(K);const $=new Blob([K],{type:"audio/mpeg"}),W=URL.createObjectURL($),V=new Audio(W);if(V.playbackRate=a.playbackRate||1,w.current.push(V),!F){F=!0,l(!0),u(!1),f(null),n==null||n(),V.onended=()=>{b()},V.onerror=()=>{b()};try{await V.play(),C.current=1}catch(X){throw X instanceof Error&&X.name==="NotAllowedError"?(y.current=!1,u(!1),new Error("Click the speaker button again to play audio (browser autoplay policy)")):X}}}}}catch(M){const L=`TTS error: ${M}`;f(L),s==null||s(L),u(!1),y.current=!1}},[a.cacheTTS,a.voice,a.playbackRate,a.ttsProvider,t,n,r,s,j,b]),N=d.useCallback(async R=>{!R||!R.trim()||(f(null),S?await I(R):await k(R))},[S,I,k]),A=d.useCallback(()=>{S?(window.speechSynthesis.cancel(),l(!1)):(y.current=!1,g.current&&(g.current.pause(),g.current.currentTime=0),w.current.forEach(R=>{R.pause()}),l(!1))},[S]),P=d.useCallback(()=>{if(S)window.speechSynthesis.pause();else{const R=C.current-1;R>=0&&R<w.current.length?w.current[R].pause():g.current&&g.current.pause()}l(!1)},[S]),E=d.useCallback(()=>{if(S)window.speechSynthesis.resume(),l(!0);else{const R=C.current-1;R>=0&&R<w.current.length?(w.current[R].play(),l(!0)):g.current&&(g.current.play(),l(!0))}},[S]);return d.useEffect(()=>()=>{j()},[j]),{isSpeaking:i,isLoading:c,error:h,voices:p,speak:N,stop:A,pause:P,resume:E}}function wl(){const e=d.useContext(Ky);if(e===null)throw new Error("useThemeContext must be used within a ThemeProvider");return e}const bP=e=>{const[t,n]=d.useState([]),[r,s]=d.useState(!0),[a,i]=d.useState(null),l=d.useCallback(async()=>{if(!e){n([]),s(!1);return}s(!0),i(null);try{const c=await Ie.webui.get(`/api/v1/sessions?project_id=${e}&pageNumber=1&pageSize=100`);n(c.data||[])}catch(c){const u=c instanceof Error?c.message:"Failed to fetch sessions.";i(u),n([])}finally{s(!1)}},[e]);return d.useEffect(()=>{l();const c=()=>{l()},u=()=>{l()};return window.addEventListener("session-moved",c),window.addEventListener("new-chat-session",u),()=>{window.removeEventListener("session-moved",c),window.removeEventListener("new-chat-session",u)}},[l]),{sessions:t,isLoading:r,error:a,refetch:l}},CP=()=>{const{agents:e,sessionId:t,setMessages:n,setSelectedAgentName:r,handleNewSession:s}=$t();return{handleAgentSelection:d.useCallback((i,l=!1)=>{if(i){const c=e.find(u=>u.name===i);if(c){l&&s(),r(i);const u=`Hi! I'm the ${c.displayName}. How can I help?`;n(h=>[...h,{parts:[{kind:"text",text:u}],isUser:!1,isComplete:!0,role:"agent",metadata:{sessionId:t||"",lastProcessedEventSequence:0}}])}else console.warn(`Selected agent not found: ${i}`)}},[e,t,n,r,s])}},Rr=({open:e,title:t,content:n,description:r,actionLabels:s,trigger:a,isLoading:i,isEnabled:l=!0,onOpenChange:c,onConfirm:u,onCancel:h})=>{const f=(s==null?void 0:s.cancel)??"Cancel",p=(s==null?void 0:s.confirm)??"Confirm";return o.jsxs(Nr,{open:e,onOpenChange:c,children:[a&&o.jsx(If,{asChild:!0,children:a}),o.jsxs(Tr,{className:"w-xl max-w-xl sm:max-w-xl",children:[o.jsxs(rs,{children:[o.jsx(Ar,{className:"flex max-w-[400px] flex-row gap-1",children:t}),o.jsx(Ir,{children:r})]}),o.jsx("div",{className:"min-w-0 break-words",children:n}),o.jsxs(Cs,{children:[o.jsx(my,{asChild:!0,children:o.jsx(ye,{variant:"ghost",title:f,onClick:m=>{m.stopPropagation(),h==null||h()},disabled:i,children:f})}),o.jsx(ye,{"data-testid":"dialogConfirmButton",variant:"outline",title:p,onClick:async m=>{m.stopPropagation(),await u(),c(!1)},disabled:i||!l,children:p})]}),i&&o.jsxs(o.Fragment,{children:[o.jsx("style",{children:`
|
|
133
|
+
@keyframes progressBarSlide {
|
|
134
|
+
0% { transform: translateX(-100%); }
|
|
135
|
+
100% { transform: translateX(400%); }
|
|
136
|
+
}
|
|
137
|
+
.progress-bar-animate {
|
|
138
|
+
animation: progressBarSlide 2s ease-in-out infinite;
|
|
139
|
+
width: 25%;
|
|
140
|
+
background: var(--color-brand-wMain);
|
|
141
|
+
}
|
|
142
|
+
`}),o.jsx("div",{className:"bg-muted absolute right-1 bottom-0 left-1 h-1 overflow-hidden rounded-full",children:o.jsx("div",{className:"progress-bar-animate h-full rounded-full"})})]})]})]})};function SP(){const[e,t]=d.useState(!1),[n,r]=d.useState(!1),[s,a]=d.useState(!1),i=xj(({currentLocation:f,nextLocation:p})=>s&&!n&&f.pathname!==p.pathname);d.useEffect(()=>{i.state==="blocked"&&t(!0)},[i]);const l=d.useCallback(()=>{t(!1),i.state==="blocked"&&i.proceed()},[i]),c=d.useCallback(()=>{t(!1),i.state==="blocked"&&i.reset()},[i]),u=d.useCallback(f=>{r(!0),setTimeout(()=>{f()},0)},[]);return{NavigationBlocker:d.useCallback(()=>o.jsx(Rr,{title:"Unsaved Changes Will Be Discarded",description:"Leaving the form will discard any unsaved changes. Are you sure you want to leave?",open:e,onConfirm:l,onCancel:c,onOpenChange:t}),[e,l,c]),allowNavigation:u,setBlockingEnabled:a}}const _P=({title:e,subtitle:t,error:n,errorDetails:r,open:s,onOpenChange:a})=>o.jsx(Nr,{open:s,onOpenChange:a,children:o.jsxs(Tr,{className:"w-xl max-w-xl sm:max-w-xl",children:[o.jsxs(rs,{children:[o.jsx(Ar,{className:"flex max-w-[400px] flex-row gap-1",children:e}),o.jsx(Ir,{children:t})]}),o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsxs("div",{className:"flex flex-row items-center gap-2",children:[o.jsx(Sv,{className:"h-6 w-6 shrink-0 self-start text-(--color-error-wMain)"}),o.jsx("div",{children:n})]}),r&&o.jsx("div",{children:r})]}),o.jsx(Cs,{children:o.jsx(my,{asChild:!0,children:o.jsx(ye,{variant:"outline",testid:"closeButton",title:"Close",children:"Close"})})})]})});function kP(){const[e,t]=d.useState(null),n=d.useCallback(s=>{s||t(null)},[]);return{ErrorDialog:d.useCallback(()=>o.jsx(_P,{title:(e==null?void 0:e.title)||"Error",error:(e==null?void 0:e.error)||"An error occurred.",open:e!==null,onOpenChange:n}),[e,n]),setError:t}}d.createContext(null);function Lu(e){const t=e+"CollectionProvider",[n,r]=pr(t),[s,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:w}=g,y=xt.useRef(null),C=xt.useRef(new Map).current;return o.jsx(s,{scope:x,itemMap:C,collectionRef:y,children:w})};i.displayName=t;const l=e+"CollectionSlot",c=ho(l),u=xt.forwardRef((g,x)=>{const{scope:w,children:y}=g,C=a(l,w),S=yt(x,C.collectionRef);return o.jsx(c,{ref:S,children:y})});u.displayName=l;const h=e+"CollectionItemSlot",f="data-radix-collection-item",p=ho(h),m=xt.forwardRef((g,x)=>{const{scope:w,children:y,...C}=g,S=xt.useRef(null),j=yt(x,S),I=a(h,w);return xt.useEffect(()=>(I.itemMap.set(S,{ref:S,...C}),()=>void I.itemMap.delete(S))),o.jsx(p,{[f]:"",ref:j,children:y})});m.displayName=h;function v(g){const x=a(e+"CollectionConsumer",g);return xt.useCallback(()=>{const y=x.collectionRef.current;if(!y)return[];const C=Array.from(y.querySelectorAll(`[${f}]`));return Array.from(x.itemMap.values()).sort((I,b)=>C.indexOf(I.ref.current)-C.indexOf(b.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:u,ItemSlot:m},v,r]}var jP=d.createContext(void 0);function yl(e){const t=d.useContext(jP);return e||t||"ltr"}const bl=d.forwardRef(({actions:e,className:t,...n},r)=>{const s=(i,l)=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),l.onClick())},a=(i,l)=>{var u,h,f,p,m;const c=(u=i.currentTarget.parentElement)==null?void 0:u.querySelectorAll('[role="menuitem"]');if(c)switch(i.key){case"ArrowDown":{i.preventDefault();const v=(l+1)%c.length;(h=c[v])==null||h.focus();break}case"ArrowUp":{i.preventDefault();const v=(l-1+c.length)%c.length;(f=c[v])==null||f.focus();break}case"Home":i.preventDefault(),(p=c[0])==null||p.focus();break;case"End":i.preventDefault(),(m=c[c.length-1])==null||m.focus();break;case"Escape":i.preventDefault(),i.currentTarget.blur();break}};return o.jsx("div",{ref:r,role:"menu",className:Ue("min-w-[8rem] overflow-hidden",t),...n,children:e.map((i,l)=>o.jsxs(d.Fragment,{children:[i.divider&&l>0&&o.jsx("div",{className:"my-1 h-px bg-[var(--color-secondary-w40)] dark:bg-[var(--color-secondary-w70)]"}),o.jsxs("div",{role:"menuitem",tabIndex:0,"data-disabled":i.disabled,className:Ue("relative my-1.5 flex cursor-pointer items-center gap-2 px-3 py-1.5 text-sm transition-colors select-none","data-[disabled]:pointer-events-none data-[disabled]:opacity-50","hover:bg-[var(--color-primary-w10)] hover:text-[var(--color-primary-text-w60)] dark:hover:bg-[var(--color-primary-w60)] dark:hover:text-[var(--color-primary-text-w10)]"),onClick:i.onClick,onKeyDown:c=>{s(c,i),a(c,l)},children:[i.icon&&i.iconPosition!=="right"&&o.jsx("span",{className:"flex h-4 w-4 items-center justify-center",children:i.icon}),o.jsx("span",{className:"flex-1",children:i.label}),i.icon&&i.iconPosition==="right"&&o.jsx("span",{className:"flex h-4 w-4 items-center justify-center",children:i.icon})]})]},i.id))})});bl.displayName="Menu";var pm="Popper",[Jy,Qy]=pr(pm),[EP,eb]=Jy(pm),tb=e=>{const{__scopePopper:t,children:n}=e,[r,s]=d.useState(null);return o.jsx(EP,{scope:t,anchor:r,onAnchorChange:s,children:n})};tb.displayName=pm;var nb="PopperAnchor",rb=d.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...s}=e,a=eb(nb,n),i=d.useRef(null),l=yt(t,i);return d.useEffect(()=>{a.onAnchorChange((r==null?void 0:r.current)||i.current)}),r?null:o.jsx(ct.div,{...s,ref:l})});rb.displayName=nb;var gm="PopperContent",[NP,TP]=Jy(gm),sb=d.forwardRef((e,t)=>{var z,Z,J,ce,de,fe;const{__scopePopper:n,side:r="bottom",sideOffset:s=0,align:a="center",alignOffset:i=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:h=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:v,...g}=e,x=eb(gm,n),[w,y]=d.useState(null),C=yt(t,ge=>y(ge)),[S,j]=d.useState(null),I=qh(S),b=(I==null?void 0:I.width)??0,k=(I==null?void 0:I.height)??0,N=r+(a!=="center"?"-"+a:""),A=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},P=Array.isArray(u)?u:[u],E=P.length>0,R={padding:A,boundary:P.filter(IP),altBoundary:E},{refs:_,floatingStyles:M,placement:L,isPositioned:F,middlewareData:D}=zh({strategy:"fixed",placement:N,whileElementsMounted:(...ge)=>Fh(...ge,{animationFrame:m==="always"}),elements:{reference:x.anchor},middleware:[$h({mainAxis:s+k,alignmentAxis:i}),c&&Uh({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Bh():void 0,...R}),c&&Vh({...R}),Hh({...R,apply:({elements:ge,rects:T,availableWidth:le,availableHeight:ie})=>{const{width:q,height:B}=T.reference,ee=ge.floating.style;ee.setProperty("--radix-popper-available-width",`${le}px`),ee.setProperty("--radix-popper-available-height",`${ie}px`),ee.setProperty("--radix-popper-anchor-width",`${q}px`),ee.setProperty("--radix-popper-anchor-height",`${B}px`)}}),S&&Zh({element:S,padding:l}),RP({arrowWidth:b,arrowHeight:k}),p&&Wh({strategy:"referenceHidden",...R})]}),[O,K]=ib(L),$=Dn(v);dn(()=>{F&&($==null||$())},[F,$]);const W=(z=D.arrow)==null?void 0:z.x,V=(Z=D.arrow)==null?void 0:Z.y,X=((J=D.arrow)==null?void 0:J.centerOffset)!==0,[H,Q]=d.useState();return dn(()=>{w&&Q(window.getComputedStyle(w).zIndex)},[w]),o.jsx("div",{ref:_.setFloating,"data-radix-popper-content-wrapper":"",style:{...M,transform:F?M.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:H,"--radix-popper-transform-origin":[(ce=D.transformOrigin)==null?void 0:ce.x,(de=D.transformOrigin)==null?void 0:de.y].join(" "),...((fe=D.hide)==null?void 0:fe.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:o.jsx(NP,{scope:n,placedSide:O,onArrowChange:j,arrowX:W,arrowY:V,shouldHideArrow:X,children:o.jsx(ct.div,{"data-side":O,"data-align":K,...g,ref:C,style:{...g.style,animation:F?void 0:"none"}})})})});sb.displayName=gm;var ob="PopperArrow",AP={top:"bottom",right:"left",bottom:"top",left:"right"},ab=d.forwardRef(function(t,n){const{__scopePopper:r,...s}=t,a=TP(ob,r),i=AP[a.placedSide];return o.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:o.jsx(Gh,{...s,ref:n,style:{...s.style,display:"block"}})})});ab.displayName=ob;function IP(e){return e!==null}var RP=e=>({name:"transformOrigin",options:e,fn(t){var x,w,y;const{placement:n,rects:r,middlewareData:s}=t,i=((x=s.arrow)==null?void 0:x.centerOffset)!==0,l=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,h]=ib(n),f={start:"0%",center:"50%",end:"100%"}[h],p=(((w=s.arrow)==null?void 0:w.x)??0)+l/2,m=(((y=s.arrow)==null?void 0:y.y)??0)+c/2;let v="",g="";return u==="bottom"?(v=i?f:`${p}px`,g=`${-c}px`):u==="top"?(v=i?f:`${p}px`,g=`${r.floating.height+c}px`):u==="right"?(v=`${-c}px`,g=i?f:`${m}px`):u==="left"&&(v=`${r.floating.width+c}px`,g=i?f:`${m}px`),{data:{x:v,y:g}}}});function ib(e){const[t,n="center"]=e.split("-");return[t,n]}var PP=tb,lb=rb,MP=sb,DP=ab,Fu="Popover",[cb,kU]=pr(Fu,[Qy]),Cl=Qy(),[OP,_o]=cb(Fu),ub=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:s,onOpenChange:a,modal:i=!1}=e,l=Cl(t),c=d.useRef(null),[u,h]=d.useState(!1),[f,p]=Ds({prop:r,defaultProp:s??!1,onChange:a,caller:Fu});return o.jsx(PP,{...l,children:o.jsx(OP,{scope:t,contentId:dr(),triggerRef:c,open:f,onOpenChange:p,onOpenToggle:d.useCallback(()=>p(m=>!m),[p]),hasCustomAnchor:u,onCustomAnchorAdd:d.useCallback(()=>h(!0),[]),onCustomAnchorRemove:d.useCallback(()=>h(!1),[]),modal:i,children:n})})};ub.displayName=Fu;var db="PopoverAnchor",LP=d.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=_o(db,n),a=Cl(n),{onCustomAnchorAdd:i,onCustomAnchorRemove:l}=s;return d.useEffect(()=>(i(),()=>l()),[i,l]),o.jsx(lb,{...a,...r,ref:t})});LP.displayName=db;var fb="PopoverTrigger",hb=d.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=_o(fb,n),a=Cl(n),i=yt(t,s.triggerRef),l=o.jsx(ct.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":vb(s.open),...r,ref:i,onClick:Gt(e.onClick,s.onOpenToggle)});return s.hasCustomAnchor?l:o.jsx(lb,{asChild:!0,...a,children:l})});hb.displayName=fb;var xm="PopoverPortal",[FP,zP]=cb(xm,{forceMount:void 0}),mb=e=>{const{__scopePopover:t,forceMount:n,children:r,container:s}=e,a=_o(xm,t);return o.jsx(FP,{scope:t,forceMount:n,children:o.jsx(Fs,{present:n||a.open,children:o.jsx(li,{asChild:!0,container:s,children:r})})})};mb.displayName=xm;var Za="PopoverContent",pb=d.forwardRef((e,t)=>{const n=zP(Za,e.__scopePopover),{forceMount:r=n.forceMount,...s}=e,a=_o(Za,e.__scopePopover);return o.jsx(Fs,{present:r||a.open,children:a.modal?o.jsx(UP,{...s,ref:t}):o.jsx(BP,{...s,ref:t})})});pb.displayName=Za;var $P=ho("PopoverContent.RemoveScroll"),UP=d.forwardRef((e,t)=>{const n=_o(Za,e.__scopePopover),r=d.useRef(null),s=yt(t,r),a=d.useRef(!1);return d.useEffect(()=>{const i=r.current;if(i)return Iu(i)},[]),o.jsx(vl,{as:$P,allowPinchZoom:!0,children:o.jsx(gb,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Gt(e.onCloseAutoFocus,i=>{var l;i.preventDefault(),a.current||(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Gt(e.onPointerDownOutside,i=>{const l=i.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;a.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Gt(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),BP=d.forwardRef((e,t)=>{const n=_o(Za,e.__scopePopover),r=d.useRef(!1),s=d.useRef(!1);return o.jsx(gb,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var i,l;(i=e.onCloseAutoFocus)==null||i.call(e,a),a.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),a.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:a=>{var c,u;(c=e.onInteractOutside)==null||c.call(e,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const i=a.target;((u=n.triggerRef.current)==null?void 0:u.contains(i))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&s.current&&a.preventDefault()}})}),gb=d.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:a,disableOutsidePointerEvents:i,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:h,...f}=e,p=_o(Za,n),m=Cl(n);return B0(),o.jsx(xl,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:a,children:o.jsx(bu,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:h,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>p.onOpenChange(!1),children:o.jsx(MP,{"data-state":vb(p.open),role:"dialog",id:p.contentId,...m,...f,ref:t,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),xb="PopoverClose",VP=d.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=_o(xb,n);return o.jsx(ct.button,{type:"button",...r,ref:t,onClick:Gt(e.onClick,()=>s.onOpenChange(!1))})});VP.displayName=xb;var HP="PopoverArrow",WP=d.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=Cl(n);return o.jsx(DP,{...s,...r,ref:t})});WP.displayName=HP;function vb(e){return e?"open":"closed"}var ZP=ub,GP=hb,qP=mb,YP=pb;function Sl({...e}){return o.jsx(ZP,{"data-slot":"popover",...e})}function _l({...e}){return o.jsx(GP,{"data-slot":"popover-trigger",...e})}function kl({className:e,align:t="center",sideOffset:n=4,...r}){return o.jsx(qP,{children:o.jsx(YP,{"data-slot":"popover-content",align:t,sideOffset:n,className:Ue("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 bg-background z-50 w-auto origin-(--radix-popover-content-transform-origin) rounded-sm border px-0 py-1 shadow-sm outline-hidden",e),...r})})}function KP({isOpen:e,onClose:t,anchorRef:n,children:r,placement:s="bottom-start",offset:a,className:i,closeOnClickOutside:l=!0,closeOnEscape:c=!0,portal:u=!0,animationDuration:h=150,fallbackPlacements:f}){const p=d.useRef(null),[m,v]=d.useState({}),[g,x]=d.useState(!1);fR({ref:p,anchorRef:n,onClickOutside:t,enabled:e&&l}),hR({onEscape:t,enabled:e&&c});const{getPositionStyle:w}=gR({anchorRef:n,placement:s,offset:a,fallbackPlacements:f});if(d.useEffect(()=>{e&&p.current?(x(!1),requestAnimationFrame(()=>{if(p.current){const C=w(p.current);v(C),x(!0)}})):x(!1)},[e,w]),!e)return null;const y=o.jsx("div",{ref:p,role:"dialog","aria-modal":"false",className:Ue("bg-background min-w-[8rem] overflow-hidden border shadow-md",i),style:{...m,opacity:e&&g?1:0,transform:`scale(${e&&g?1:.95})`,transition:`opacity ${h}ms ease-in-out, transform ${h}ms ease-in-out`,pointerEvents:e&&g?"auto":"none",visibility:g?"visible":"hidden"},children:r});return u?ti.createPortal(y,document.body):y}function Vg(e,[t,n]){return Math.min(n,Math.max(t,e))}function vn(e,t,{checkForDefaultPrevented:n=!0}={}){return function(s){if(e==null||e(s),n===!1||!s.defaultPrevented)return t==null?void 0:t(s)}}var XP="DismissableLayer",Df="dismissableLayer.update",JP="dismissableLayer.pointerDownOutside",QP="dismissableLayer.focusOutside",Hg,wb=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),yb=d.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:i,onDismiss:l,...c}=e,u=d.useContext(wb),[h,f]=d.useState(null),p=(h==null?void 0:h.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=d.useState({}),v=yt(t,b=>f(b)),g=Array.from(u.layers),[x]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),w=g.indexOf(x),y=h?g.indexOf(h):-1,C=u.layersWithOutsidePointerEventsDisabled.size>0,S=y>=w,j=nM(b=>{const k=b.target,N=[...u.branches].some(A=>A.contains(k));!S||N||(s==null||s(b),i==null||i(b),b.defaultPrevented||l==null||l())},p),I=rM(b=>{const k=b.target;[...u.branches].some(A=>A.contains(k))||(a==null||a(b),i==null||i(b),b.defaultPrevented||l==null||l())},p);return Ih(b=>{y===u.layers.size-1&&(r==null||r(b),!b.defaultPrevented&&l&&(b.preventDefault(),l()))},p),d.useEffect(()=>{if(h)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Hg=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(h)),u.layers.add(h),Wg(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=Hg)}},[h,p,n,u]),d.useEffect(()=>()=>{h&&(u.layers.delete(h),u.layersWithOutsidePointerEventsDisabled.delete(h),Wg())},[h,u]),d.useEffect(()=>{const b=()=>m({});return document.addEventListener(Df,b),()=>document.removeEventListener(Df,b)},[]),o.jsx(ct.div,{...c,ref:v,style:{pointerEvents:C?S?"auto":"none":void 0,...e.style},onFocusCapture:vn(e.onFocusCapture,I.onFocusCapture),onBlurCapture:vn(e.onBlurCapture,I.onBlurCapture),onPointerDownCapture:vn(e.onPointerDownCapture,j.onPointerDownCapture)})});yb.displayName=XP;var eM="DismissableLayerBranch",tM=d.forwardRef((e,t)=>{const n=d.useContext(wb),r=d.useRef(null),s=yt(t,r);return d.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),o.jsx(ct.div,{...e,ref:s})});tM.displayName=eM;function nM(e,t=globalThis==null?void 0:globalThis.document){const n=Dn(e),r=d.useRef(!1),s=d.useRef(()=>{});return d.useEffect(()=>{const a=l=>{if(l.target&&!r.current){let c=function(){bb(JP,n,u,{discrete:!0})};const u={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",s.current),s.current=c,t.addEventListener("click",s.current,{once:!0})):c()}else t.removeEventListener("click",s.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",s.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function rM(e,t=globalThis==null?void 0:globalThis.document){const n=Dn(e),r=d.useRef(!1);return d.useEffect(()=>{const s=a=>{a.target&&!r.current&&bb(QP,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",s),()=>t.removeEventListener("focusin",s)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Wg(){const e=new CustomEvent(Df);document.dispatchEvent(e)}function bb(e,t,n,{discrete:r}){const s=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&s.addEventListener(e,t,{once:!0}),r?yu(s,a):s.dispatchEvent(a)}var Rd=0;function sM(){d.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Zg()),document.body.insertAdjacentElement("beforeend",e[1]??Zg()),Rd++,()=>{Rd===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Rd--}},[])}function Zg(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var vm="Popper",[Cb,zu]=pr(vm),[oM,Sb]=Cb(vm),_b=e=>{const{__scopePopper:t,children:n}=e,[r,s]=d.useState(null);return o.jsx(oM,{scope:t,anchor:r,onAnchorChange:s,children:n})};_b.displayName=vm;var kb="PopperAnchor",jb=d.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...s}=e,a=Sb(kb,n),i=d.useRef(null),l=yt(t,i),c=d.useRef(null);return d.useEffect(()=>{const u=c.current;c.current=(r==null?void 0:r.current)||i.current,u!==c.current&&a.onAnchorChange(c.current)}),r?null:o.jsx(ct.div,{...s,ref:l})});jb.displayName=kb;var wm="PopperContent",[aM,iM]=Cb(wm),Eb=d.forwardRef((e,t)=>{var z,Z,J,ce,de,fe;const{__scopePopper:n,side:r="bottom",sideOffset:s=0,align:a="center",alignOffset:i=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:h=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:v,...g}=e,x=Sb(wm,n),[w,y]=d.useState(null),C=yt(t,ge=>y(ge)),[S,j]=d.useState(null),I=qh(S),b=(I==null?void 0:I.width)??0,k=(I==null?void 0:I.height)??0,N=r+(a!=="center"?"-"+a:""),A=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},P=Array.isArray(u)?u:[u],E=P.length>0,R={padding:A,boundary:P.filter(cM),altBoundary:E},{refs:_,floatingStyles:M,placement:L,isPositioned:F,middlewareData:D}=zh({strategy:"fixed",placement:N,whileElementsMounted:(...ge)=>Fh(...ge,{animationFrame:m==="always"}),elements:{reference:x.anchor},middleware:[$h({mainAxis:s+k,alignmentAxis:i}),c&&Uh({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Bh():void 0,...R}),c&&Vh({...R}),Hh({...R,apply:({elements:ge,rects:T,availableWidth:le,availableHeight:ie})=>{const{width:q,height:B}=T.reference,ee=ge.floating.style;ee.setProperty("--radix-popper-available-width",`${le}px`),ee.setProperty("--radix-popper-available-height",`${ie}px`),ee.setProperty("--radix-popper-anchor-width",`${q}px`),ee.setProperty("--radix-popper-anchor-height",`${B}px`)}}),S&&Zh({element:S,padding:l}),uM({arrowWidth:b,arrowHeight:k}),p&&Wh({strategy:"referenceHidden",...R})]}),[O,K]=Ab(L),$=Dn(v);dn(()=>{F&&($==null||$())},[F,$]);const W=(z=D.arrow)==null?void 0:z.x,V=(Z=D.arrow)==null?void 0:Z.y,X=((J=D.arrow)==null?void 0:J.centerOffset)!==0,[H,Q]=d.useState();return dn(()=>{w&&Q(window.getComputedStyle(w).zIndex)},[w]),o.jsx("div",{ref:_.setFloating,"data-radix-popper-content-wrapper":"",style:{...M,transform:F?M.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:H,"--radix-popper-transform-origin":[(ce=D.transformOrigin)==null?void 0:ce.x,(de=D.transformOrigin)==null?void 0:de.y].join(" "),...((fe=D.hide)==null?void 0:fe.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:o.jsx(aM,{scope:n,placedSide:O,onArrowChange:j,arrowX:W,arrowY:V,shouldHideArrow:X,children:o.jsx(ct.div,{"data-side":O,"data-align":K,...g,ref:C,style:{...g.style,animation:F?void 0:"none"}})})})});Eb.displayName=wm;var Nb="PopperArrow",lM={top:"bottom",right:"left",bottom:"top",left:"right"},Tb=d.forwardRef(function(t,n){const{__scopePopper:r,...s}=t,a=iM(Nb,r),i=lM[a.placedSide];return o.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:o.jsx(Gh,{...s,ref:n,style:{...s.style,display:"block"}})})});Tb.displayName=Nb;function cM(e){return e!==null}var uM=e=>({name:"transformOrigin",options:e,fn(t){var x,w,y;const{placement:n,rects:r,middlewareData:s}=t,i=((x=s.arrow)==null?void 0:x.centerOffset)!==0,l=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,h]=Ab(n),f={start:"0%",center:"50%",end:"100%"}[h],p=(((w=s.arrow)==null?void 0:w.x)??0)+l/2,m=(((y=s.arrow)==null?void 0:y.y)??0)+c/2;let v="",g="";return u==="bottom"?(v=i?f:`${p}px`,g=`${-c}px`):u==="top"?(v=i?f:`${p}px`,g=`${r.floating.height+c}px`):u==="right"?(v=`${-c}px`,g=i?f:`${m}px`):u==="left"&&(v=`${r.floating.width+c}px`,g=i?f:`${m}px`),{data:{x:v,y:g}}}});function Ab(e){const[t,n="center"]=e.split("-");return[t,n]}var Ib=_b,Rb=jb,Pb=Eb,Mb=Tb;function dM(e){const t=d.useRef({value:e,previous:e});return d.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var fM=[" ","Enter","ArrowUp","ArrowDown"],hM=[" ","Enter"],qo="Select",[$u,Uu,mM]=Lu(qo),[ci,jU]=pr(qo,[mM,zu]),Bu=zu(),[pM,ko]=ci(qo),[gM,xM]=ci(qo),Db=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:s,onOpenChange:a,value:i,defaultValue:l,onValueChange:c,dir:u,name:h,autoComplete:f,disabled:p,required:m,form:v}=e,g=Bu(t),[x,w]=d.useState(null),[y,C]=d.useState(null),[S,j]=d.useState(!1),I=yl(u),[b,k]=Ds({prop:r,defaultProp:s??!1,onChange:a,caller:qo}),[N,A]=Ds({prop:i,defaultProp:l,onChange:c,caller:qo}),P=d.useRef(null),E=x?v||!!x.closest("form"):!0,[R,_]=d.useState(new Set),M=Array.from(R).map(L=>L.props.value).join(";");return o.jsx(Ib,{...g,children:o.jsxs(pM,{required:m,scope:t,trigger:x,onTriggerChange:w,valueNode:y,onValueNodeChange:C,valueNodeHasChildren:S,onValueNodeHasChildrenChange:j,contentId:dr(),value:N,onValueChange:A,open:b,onOpenChange:k,dir:I,triggerPointerDownPosRef:P,disabled:p,children:[o.jsx($u.Provider,{scope:t,children:o.jsx(gM,{scope:e.__scopeSelect,onNativeOptionAdd:d.useCallback(L=>{_(F=>new Set(F).add(L))},[]),onNativeOptionRemove:d.useCallback(L=>{_(F=>{const D=new Set(F);return D.delete(L),D})},[]),children:n})}),E?o.jsxs(r1,{"aria-hidden":!0,required:m,tabIndex:-1,name:h,autoComplete:f,value:N,onChange:L=>A(L.target.value),disabled:p,form:v,children:[N===void 0?o.jsx("option",{value:""}):null,Array.from(R)]},M):null]})})};Db.displayName=qo;var Ob="SelectTrigger",Lb=d.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...s}=e,a=Bu(n),i=ko(Ob,n),l=i.disabled||r,c=yt(t,i.onTriggerChange),u=Uu(n),h=d.useRef("touch"),[f,p,m]=o1(g=>{const x=u().filter(C=>!C.disabled),w=x.find(C=>C.value===i.value),y=a1(x,g,w);y!==void 0&&i.onValueChange(y.value)}),v=g=>{l||(i.onOpenChange(!0),m()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return o.jsx(Rb,{asChild:!0,...a,children:o.jsx(ct.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":s1(i.value)?"":void 0,...s,ref:c,onClick:vn(s.onClick,g=>{g.currentTarget.focus(),h.current!=="mouse"&&v(g)}),onPointerDown:vn(s.onPointerDown,g=>{h.current=g.pointerType;const x=g.target;x.hasPointerCapture(g.pointerId)&&x.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(v(g),g.preventDefault())}),onKeyDown:vn(s.onKeyDown,g=>{const x=f.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&p(g.key),!(x&&g.key===" ")&&fM.includes(g.key)&&(v(),g.preventDefault())})})})});Lb.displayName=Ob;var Fb="SelectValue",zb=d.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:s,children:a,placeholder:i="",...l}=e,c=ko(Fb,n),{onValueNodeHasChildrenChange:u}=c,h=a!==void 0,f=yt(t,c.onValueNodeChange);return dn(()=>{u(h)},[u,h]),o.jsx(ct.span,{...l,ref:f,style:{pointerEvents:"none"},children:s1(c.value)?o.jsx(o.Fragment,{children:i}):a})});zb.displayName=Fb;var vM="SelectIcon",$b=d.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...s}=e;return o.jsx(ct.span,{"aria-hidden":!0,...s,ref:t,children:r||"▼"})});$b.displayName=vM;var wM="SelectPortal",Ub=e=>o.jsx(li,{asChild:!0,...e});Ub.displayName=wM;var Yo="SelectContent",Bb=d.forwardRef((e,t)=>{const n=ko(Yo,e.__scopeSelect),[r,s]=d.useState();if(dn(()=>{s(new DocumentFragment)},[]),!n.open){const a=r;return a?ti.createPortal(o.jsx(Vb,{scope:e.__scopeSelect,children:o.jsx($u.Slot,{scope:e.__scopeSelect,children:o.jsx("div",{children:e.children})})}),a):null}return o.jsx(Hb,{...e,ref:t})});Bb.displayName=Yo;var Lr=10,[Vb,jo]=ci(Yo),yM="SelectContentImpl",bM=ho("SelectContent.RemoveScroll"),Hb=d.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:s,onEscapeKeyDown:a,onPointerDownOutside:i,side:l,sideOffset:c,align:u,alignOffset:h,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:v,hideWhenDetached:g,avoidCollisions:x,...w}=e,y=ko(Yo,n),[C,S]=d.useState(null),[j,I]=d.useState(null),b=yt(t,z=>S(z)),[k,N]=d.useState(null),[A,P]=d.useState(null),E=Uu(n),[R,_]=d.useState(!1),M=d.useRef(!1);d.useEffect(()=>{if(C)return Iu(C)},[C]),sM();const L=d.useCallback(z=>{const[Z,...J]=E().map(fe=>fe.ref.current),[ce]=J.slice(-1),de=document.activeElement;for(const fe of z)if(fe===de||(fe==null||fe.scrollIntoView({block:"nearest"}),fe===Z&&j&&(j.scrollTop=0),fe===ce&&j&&(j.scrollTop=j.scrollHeight),fe==null||fe.focus(),document.activeElement!==de))return},[E,j]),F=d.useCallback(()=>L([k,C]),[L,k,C]);d.useEffect(()=>{R&&F()},[R,F]);const{onOpenChange:D,triggerPointerDownPosRef:O}=y;d.useEffect(()=>{if(C){let z={x:0,y:0};const Z=ce=>{var de,fe;z={x:Math.abs(Math.round(ce.pageX)-(((de=O.current)==null?void 0:de.x)??0)),y:Math.abs(Math.round(ce.pageY)-(((fe=O.current)==null?void 0:fe.y)??0))}},J=ce=>{z.x<=10&&z.y<=10?ce.preventDefault():C.contains(ce.target)||D(!1),document.removeEventListener("pointermove",Z),O.current=null};return O.current!==null&&(document.addEventListener("pointermove",Z),document.addEventListener("pointerup",J,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Z),document.removeEventListener("pointerup",J,{capture:!0})}}},[C,D,O]),d.useEffect(()=>{const z=()=>D(!1);return window.addEventListener("blur",z),window.addEventListener("resize",z),()=>{window.removeEventListener("blur",z),window.removeEventListener("resize",z)}},[D]);const[K,$]=o1(z=>{const Z=E().filter(de=>!de.disabled),J=Z.find(de=>de.ref.current===document.activeElement),ce=a1(Z,z,J);ce&&setTimeout(()=>ce.ref.current.focus())}),W=d.useCallback((z,Z,J)=>{const ce=!M.current&&!J;(y.value!==void 0&&y.value===Z||ce)&&(N(z),ce&&(M.current=!0))},[y.value]),V=d.useCallback(()=>C==null?void 0:C.focus(),[C]),X=d.useCallback((z,Z,J)=>{const ce=!M.current&&!J;(y.value!==void 0&&y.value===Z||ce)&&P(z)},[y.value]),H=r==="popper"?Of:Wb,Q=H===Of?{side:l,sideOffset:c,align:u,alignOffset:h,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return o.jsx(Vb,{scope:n,content:C,viewport:j,onViewportChange:I,itemRefCallback:W,selectedItem:k,onItemLeave:V,itemTextRefCallback:X,focusSelectedItem:F,selectedItemText:A,position:r,isPositioned:R,searchRef:K,children:o.jsx(vl,{as:bM,allowPinchZoom:!0,children:o.jsx(xl,{asChild:!0,trapped:y.open,onMountAutoFocus:z=>{z.preventDefault()},onUnmountAutoFocus:vn(s,z=>{var Z;(Z=y.trigger)==null||Z.focus({preventScroll:!0}),z.preventDefault()}),children:o.jsx(yb,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:z=>z.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:o.jsx(H,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:z=>z.preventDefault(),...w,...Q,onPlaced:()=>_(!0),ref:b,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:vn(w.onKeyDown,z=>{const Z=z.ctrlKey||z.altKey||z.metaKey;if(z.key==="Tab"&&z.preventDefault(),!Z&&z.key.length===1&&$(z.key),["ArrowUp","ArrowDown","Home","End"].includes(z.key)){let ce=E().filter(de=>!de.disabled).map(de=>de.ref.current);if(["ArrowUp","End"].includes(z.key)&&(ce=ce.slice().reverse()),["ArrowUp","ArrowDown"].includes(z.key)){const de=z.target,fe=ce.indexOf(de);ce=ce.slice(fe+1)}setTimeout(()=>L(ce)),z.preventDefault()}})})})})})})});Hb.displayName=yM;var CM="SelectItemAlignedPosition",Wb=d.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...s}=e,a=ko(Yo,n),i=jo(Yo,n),[l,c]=d.useState(null),[u,h]=d.useState(null),f=yt(t,b=>h(b)),p=Uu(n),m=d.useRef(!1),v=d.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:w,focusSelectedItem:y}=i,C=d.useCallback(()=>{if(a.trigger&&a.valueNode&&l&&u&&g&&x&&w){const b=a.trigger.getBoundingClientRect(),k=u.getBoundingClientRect(),N=a.valueNode.getBoundingClientRect(),A=w.getBoundingClientRect();if(a.dir!=="rtl"){const de=A.left-k.left,fe=N.left-de,ge=b.left-fe,T=b.width+ge,le=Math.max(T,k.width),ie=window.innerWidth-Lr,q=Vg(fe,[Lr,Math.max(Lr,ie-le)]);l.style.minWidth=T+"px",l.style.left=q+"px"}else{const de=k.right-A.right,fe=window.innerWidth-N.right-de,ge=window.innerWidth-b.right-fe,T=b.width+ge,le=Math.max(T,k.width),ie=window.innerWidth-Lr,q=Vg(fe,[Lr,Math.max(Lr,ie-le)]);l.style.minWidth=T+"px",l.style.right=q+"px"}const P=p(),E=window.innerHeight-Lr*2,R=g.scrollHeight,_=window.getComputedStyle(u),M=parseInt(_.borderTopWidth,10),L=parseInt(_.paddingTop,10),F=parseInt(_.borderBottomWidth,10),D=parseInt(_.paddingBottom,10),O=M+L+R+D+F,K=Math.min(x.offsetHeight*5,O),$=window.getComputedStyle(g),W=parseInt($.paddingTop,10),V=parseInt($.paddingBottom,10),X=b.top+b.height/2-Lr,H=E-X,Q=x.offsetHeight/2,z=x.offsetTop+Q,Z=M+L+z,J=O-Z;if(Z<=X){const de=P.length>0&&x===P[P.length-1].ref.current;l.style.bottom="0px";const fe=u.clientHeight-g.offsetTop-g.offsetHeight,ge=Math.max(H,Q+(de?V:0)+fe+F),T=Z+ge;l.style.height=T+"px"}else{const de=P.length>0&&x===P[0].ref.current;l.style.top="0px";const ge=Math.max(X,M+g.offsetTop+(de?W:0)+Q)+J;l.style.height=ge+"px",g.scrollTop=Z-X+g.offsetTop}l.style.margin=`${Lr}px 0`,l.style.minHeight=K+"px",l.style.maxHeight=E+"px",r==null||r(),requestAnimationFrame(()=>m.current=!0)}},[p,a.trigger,a.valueNode,l,u,g,x,w,a.dir,r]);dn(()=>C(),[C]);const[S,j]=d.useState();dn(()=>{u&&j(window.getComputedStyle(u).zIndex)},[u]);const I=d.useCallback(b=>{b&&v.current===!0&&(C(),y==null||y(),v.current=!1)},[C,y]);return o.jsx(_M,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:m,onScrollButtonChange:I,children:o.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:S},children:o.jsx(ct.div,{...s,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...s.style}})})})});Wb.displayName=CM;var SM="SelectPopperPosition",Of=d.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:s=Lr,...a}=e,i=Bu(n);return o.jsx(Pb,{...i,...a,ref:t,align:r,collisionPadding:s,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Of.displayName=SM;var[_M,ym]=ci(Yo,{}),Lf="SelectViewport",Zb=d.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...s}=e,a=jo(Lf,n),i=ym(Lf,n),l=yt(t,a.onViewportChange),c=d.useRef(0);return o.jsxs(o.Fragment,{children:[o.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),o.jsx($u.Slot,{scope:n,children:o.jsx(ct.div,{"data-radix-select-viewport":"",role:"presentation",...s,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...s.style},onScroll:vn(s.onScroll,u=>{const h=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:p}=i;if(p!=null&&p.current&&f){const m=Math.abs(c.current-h.scrollTop);if(m>0){const v=window.innerHeight-Lr*2,g=parseFloat(f.style.minHeight),x=parseFloat(f.style.height),w=Math.max(g,x);if(w<v){const y=w+m,C=Math.min(v,y),S=y-C;f.style.height=C+"px",f.style.bottom==="0px"&&(h.scrollTop=S>0?S:0,f.style.justifyContent="flex-end")}}}c.current=h.scrollTop})})})]})});Zb.displayName=Lf;var Gb="SelectGroup",[kM,jM]=ci(Gb),EM=d.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,s=dr();return o.jsx(kM,{scope:n,id:s,children:o.jsx(ct.div,{role:"group","aria-labelledby":s,...r,ref:t})})});EM.displayName=Gb;var qb="SelectLabel",NM=d.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,s=jM(qb,n);return o.jsx(ct.div,{id:s.id,...r,ref:t})});NM.displayName=qb;var Gc="SelectItem",[TM,Yb]=ci(Gc),Kb=d.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:s=!1,textValue:a,...i}=e,l=ko(Gc,n),c=jo(Gc,n),u=l.value===r,[h,f]=d.useState(a??""),[p,m]=d.useState(!1),v=yt(t,y=>{var C;return(C=c.itemRefCallback)==null?void 0:C.call(c,y,r,s)}),g=dr(),x=d.useRef("touch"),w=()=>{s||(l.onValueChange(r),l.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return o.jsx(TM,{scope:n,value:r,disabled:s,textId:g,isSelected:u,onItemTextChange:d.useCallback(y=>{f(C=>C||((y==null?void 0:y.textContent)??"").trim())},[]),children:o.jsx($u.ItemSlot,{scope:n,value:r,disabled:s,textValue:h,children:o.jsx(ct.div,{role:"option","aria-labelledby":g,"data-highlighted":p?"":void 0,"aria-selected":u&&p,"data-state":u?"checked":"unchecked","aria-disabled":s||void 0,"data-disabled":s?"":void 0,tabIndex:s?void 0:-1,...i,ref:v,onFocus:vn(i.onFocus,()=>m(!0)),onBlur:vn(i.onBlur,()=>m(!1)),onClick:vn(i.onClick,()=>{x.current!=="mouse"&&w()}),onPointerUp:vn(i.onPointerUp,()=>{x.current==="mouse"&&w()}),onPointerDown:vn(i.onPointerDown,y=>{x.current=y.pointerType}),onPointerMove:vn(i.onPointerMove,y=>{var C;x.current=y.pointerType,s?(C=c.onItemLeave)==null||C.call(c):x.current==="mouse"&&y.currentTarget.focus({preventScroll:!0})}),onPointerLeave:vn(i.onPointerLeave,y=>{var C;y.currentTarget===document.activeElement&&((C=c.onItemLeave)==null||C.call(c))}),onKeyDown:vn(i.onKeyDown,y=>{var S;((S=c.searchRef)==null?void 0:S.current)!==""&&y.key===" "||(hM.includes(y.key)&&w(),y.key===" "&&y.preventDefault())})})})})});Kb.displayName=Gc;var Ai="SelectItemText",Xb=d.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:s,...a}=e,i=ko(Ai,n),l=jo(Ai,n),c=Yb(Ai,n),u=xM(Ai,n),[h,f]=d.useState(null),p=yt(t,w=>f(w),c.onItemTextChange,w=>{var y;return(y=l.itemTextRefCallback)==null?void 0:y.call(l,w,c.value,c.disabled)}),m=h==null?void 0:h.textContent,v=d.useMemo(()=>o.jsx("option",{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=u;return dn(()=>(g(v),()=>x(v)),[g,x,v]),o.jsxs(o.Fragment,{children:[o.jsx(ct.span,{id:c.textId,...a,ref:p}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?ti.createPortal(a.children,i.valueNode):null]})});Xb.displayName=Ai;var Jb="SelectItemIndicator",Qb=d.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Yb(Jb,n).isSelected?o.jsx(ct.span,{"aria-hidden":!0,...r,ref:t}):null});Qb.displayName=Jb;var Ff="SelectScrollUpButton",e1=d.forwardRef((e,t)=>{const n=jo(Ff,e.__scopeSelect),r=ym(Ff,e.__scopeSelect),[s,a]=d.useState(!1),i=yt(t,r.onScrollButtonChange);return dn(()=>{if(n.viewport&&n.isPositioned){let l=function(){const u=c.scrollTop>0;a(u)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),s?o.jsx(n1,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop-c.offsetHeight)}}):null});e1.displayName=Ff;var zf="SelectScrollDownButton",t1=d.forwardRef((e,t)=>{const n=jo(zf,e.__scopeSelect),r=ym(zf,e.__scopeSelect),[s,a]=d.useState(!1),i=yt(t,r.onScrollButtonChange);return dn(()=>{if(n.viewport&&n.isPositioned){let l=function(){const u=c.scrollHeight-c.clientHeight,h=Math.ceil(c.scrollTop)<u;a(h)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),s?o.jsx(n1,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop+c.offsetHeight)}}):null});t1.displayName=zf;var n1=d.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...s}=e,a=jo("SelectScrollButton",n),i=d.useRef(null),l=Uu(n),c=d.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return d.useEffect(()=>()=>c(),[c]),dn(()=>{var h;const u=l().find(f=>f.ref.current===document.activeElement);(h=u==null?void 0:u.ref.current)==null||h.scrollIntoView({block:"nearest"})},[l]),o.jsx(ct.div,{"aria-hidden":!0,...s,ref:t,style:{flexShrink:0,...s.style},onPointerDown:vn(s.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:vn(s.onPointerMove,()=>{var u;(u=a.onItemLeave)==null||u.call(a),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:vn(s.onPointerLeave,()=>{c()})})}),AM="SelectSeparator",IM=d.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return o.jsx(ct.div,{"aria-hidden":!0,...r,ref:t})});IM.displayName=AM;var $f="SelectArrow",RM=d.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,s=Bu(n),a=ko($f,n),i=jo($f,n);return a.open&&i.position==="popper"?o.jsx(Mb,{...s,...r,ref:t}):null});RM.displayName=$f;var PM="SelectBubbleInput",r1=d.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const s=d.useRef(null),a=yt(r,s),i=dM(t);return d.useEffect(()=>{const l=s.current;if(!l)return;const c=window.HTMLSelectElement.prototype,h=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&h){const f=new Event("change",{bubbles:!0});h.call(l,t),l.dispatchEvent(f)}},[i,t]),o.jsx(ct.select,{...n,style:{...w0,...n.style},ref:a,defaultValue:t})});r1.displayName=PM;function s1(e){return e===""||e===void 0}function o1(e){const t=Dn(e),n=d.useRef(""),r=d.useRef(0),s=d.useCallback(i=>{const l=n.current+i;t(l),function c(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>c(""),1e3))}(l)},[t]),a=d.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return d.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,s,a]}function a1(e,t,n){const s=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let i=MM(e,Math.max(a,0));s.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.textValue.toLowerCase().startsWith(s.toLowerCase()));return c!==n?c:void 0}function MM(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var DM=Db,OM=Lb,LM=zb,FM=$b,zM=Ub,$M=Bb,UM=Zb,BM=Kb,VM=Xb,HM=Qb,WM=e1,ZM=t1;function Wr({...e}){return o.jsx(DM,{"data-slot":"select",...e})}function Zr({...e}){return o.jsx(LM,{"data-slot":"select-value",...e})}function Gr({className:e,size:t="default",children:n,...r}){return o.jsxs(OM,{"data-slot":"select-trigger","data-size":t,className:Ue("flex w-fit items-center justify-between gap-2 border px-3 py-2 text-sm whitespace-nowrap shadow-xs disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r,children:[n,o.jsx(FM,{asChild:!0,children:o.jsx(Uo,{className:"size-4 opacity-50"})})]})}function qr({className:e,children:t,position:n="popper",...r}){return o.jsx(zM,{children:o.jsxs($M,{"data-slot":"select-content",className:Ue("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 bg-background relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[o.jsx(GM,{}),o.jsx(UM,{className:Ue("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),o.jsx(qM,{})]})})}function Pt({className:e,children:t,...n}){return o.jsxs(BM,{"data-slot":"select-item",className:Ue("[&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 py-1.5 pr-8 pl-2 text-sm select-none hover:bg-[var(--color-primary-w10)] hover:text-[var(--color-primary-text-w60)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:hover:bg-[var(--color-primary-w60)] dark:hover:text-[var(--color-primary-text-w10)] [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...n,children:[o.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:o.jsx(HM,{children:o.jsx(ni,{className:"size-4"})})}),o.jsx(VM,{children:t})]})}function GM({className:e,...t}){return o.jsx(WM,{"data-slot":"select-scroll-up-button",className:Ue("flex cursor-default items-center justify-center py-1",e),...t,children:o.jsx(Ua,{className:"size-4"})})}function qM({className:e,...t}){return o.jsx(ZM,{"data-slot":"select-scroll-down-button",className:Ue("flex cursor-default items-center justify-center py-1",e),...t,children:o.jsx(Uo,{className:"size-4"})})}var Pd="rovingFocusGroup.onEntryFocus",YM={bubbles:!1,cancelable:!0},jl="RovingFocusGroup",[Uf,i1,KM]=Lu(jl),[XM,l1]=pr(jl,[KM]),[JM,QM]=XM(jl),c1=d.forwardRef((e,t)=>o.jsx(Uf.Provider,{scope:e.__scopeRovingFocusGroup,children:o.jsx(Uf.Slot,{scope:e.__scopeRovingFocusGroup,children:o.jsx(e3,{...e,ref:t})})}));c1.displayName=jl;var e3=d.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:s=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:h=!1,...f}=e,p=d.useRef(null),m=yt(t,p),v=yl(a),[g,x]=Ds({prop:i,defaultProp:l??null,onChange:c,caller:jl}),[w,y]=d.useState(!1),C=Dn(u),S=i1(n),j=d.useRef(!1),[I,b]=d.useState(0);return d.useEffect(()=>{const k=p.current;if(k)return k.addEventListener(Pd,C),()=>k.removeEventListener(Pd,C)},[C]),o.jsx(JM,{scope:n,orientation:r,dir:v,loop:s,currentTabStopId:g,onItemFocus:d.useCallback(k=>x(k),[x]),onItemShiftTab:d.useCallback(()=>y(!0),[]),onFocusableItemAdd:d.useCallback(()=>b(k=>k+1),[]),onFocusableItemRemove:d.useCallback(()=>b(k=>k-1),[]),children:o.jsx(ct.div,{tabIndex:w||I===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:Gt(e.onMouseDown,()=>{j.current=!0}),onFocus:Gt(e.onFocus,k=>{const N=!j.current;if(k.target===k.currentTarget&&N&&!w){const A=new CustomEvent(Pd,YM);if(k.currentTarget.dispatchEvent(A),!A.defaultPrevented){const P=S().filter(L=>L.focusable),E=P.find(L=>L.active),R=P.find(L=>L.id===g),M=[E,R,...P].filter(Boolean).map(L=>L.ref.current);f1(M,h)}}j.current=!1}),onBlur:Gt(e.onBlur,()=>y(!1))})})}),u1="RovingFocusGroupItem",d1=d.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:s=!1,tabStopId:a,children:i,...l}=e,c=dr(),u=a||c,h=QM(u1,n),f=h.currentTabStopId===u,p=i1(n),{onFocusableItemAdd:m,onFocusableItemRemove:v,currentTabStopId:g}=h;return d.useEffect(()=>{if(r)return m(),()=>v()},[r,m,v]),o.jsx(Uf.ItemSlot,{scope:n,id:u,focusable:r,active:s,children:o.jsx(ct.span,{tabIndex:f?0:-1,"data-orientation":h.orientation,...l,ref:t,onMouseDown:Gt(e.onMouseDown,x=>{r?h.onItemFocus(u):x.preventDefault()}),onFocus:Gt(e.onFocus,()=>h.onItemFocus(u)),onKeyDown:Gt(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){h.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const w=r3(x,h.orientation,h.dir);if(w!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let C=p().filter(S=>S.focusable).map(S=>S.ref.current);if(w==="last")C.reverse();else if(w==="prev"||w==="next"){w==="prev"&&C.reverse();const S=C.indexOf(x.currentTarget);C=h.loop?s3(C,S+1):C.slice(S+1)}setTimeout(()=>f1(C))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:g!=null}):i})})});d1.displayName=u1;var t3={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function n3(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function r3(e,t,n){const r=n3(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return t3[r]}function f1(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function s3(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var o3=c1,a3=d1,Vu="Tabs",[i3,EU]=pr(Vu,[l1]),h1=l1(),[l3,bm]=i3(Vu),m1=d.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:s,defaultValue:a,orientation:i="horizontal",dir:l,activationMode:c="automatic",...u}=e,h=yl(l),[f,p]=Ds({prop:r,onChange:s,defaultProp:a??"",caller:Vu});return o.jsx(l3,{scope:n,baseId:dr(),value:f,onValueChange:p,orientation:i,dir:h,activationMode:c,children:o.jsx(ct.div,{dir:h,"data-orientation":i,...u,ref:t})})});m1.displayName=Vu;var p1="TabsList",g1=d.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...s}=e,a=bm(p1,n),i=h1(n);return o.jsx(o3,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:r,children:o.jsx(ct.div,{role:"tablist","aria-orientation":a.orientation,...s,ref:t})})});g1.displayName=p1;var x1="TabsTrigger",v1=d.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:s=!1,...a}=e,i=bm(x1,n),l=h1(n),c=b1(i.baseId,r),u=C1(i.baseId,r),h=r===i.value;return o.jsx(a3,{asChild:!0,...l,focusable:!s,active:h,children:o.jsx(ct.button,{type:"button",role:"tab","aria-selected":h,"aria-controls":u,"data-state":h?"active":"inactive","data-disabled":s?"":void 0,disabled:s,id:c,...a,ref:t,onMouseDown:Gt(e.onMouseDown,f=>{!s&&f.button===0&&f.ctrlKey===!1?i.onValueChange(r):f.preventDefault()}),onKeyDown:Gt(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&i.onValueChange(r)}),onFocus:Gt(e.onFocus,()=>{const f=i.activationMode!=="manual";!h&&!s&&f&&i.onValueChange(r)})})})});v1.displayName=x1;var w1="TabsContent",y1=d.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:s,children:a,...i}=e,l=bm(w1,n),c=b1(l.baseId,r),u=C1(l.baseId,r),h=r===l.value,f=d.useRef(h);return d.useEffect(()=>{const p=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(p)},[]),o.jsx(Fs,{present:s||h,children:({present:p})=>o.jsx(ct.div,{"data-state":h?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!p,id:u,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:p&&a})})});y1.displayName=w1;function b1(e,t){return`${e}-trigger-${t}`}function C1(e,t){return`${e}-content-${t}`}var c3=m1,u3=g1,d3=v1,f3=y1;function S1({className:e,...t}){return o.jsx(c3,{"data-slot":"tabs",className:Ue("flex flex-col gap-2",e),...t})}function _1({className:e,...t}){return o.jsx(u3,{"data-slot":"tabs-list",className:Ue("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",e),...t})}function Li({className:e,...t}){return o.jsx(d3,{"data-slot":"tabs-trigger","data-testid":t.value,"aria-label":t.value,title:t.title,className:Ue("data-[state=active]:bg-background dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow,background-color] hover:bg-[var(--color-brand-w10)] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:text-[var(--color-brand-wMain)] data-[state=active]:shadow-sm dark:hover:bg-[var(--color-brand-wMain30)] dark:data-[state=active]:text-[var(--color-brand-wMain)] [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}function Fi({className:e,...t}){return o.jsx(f3,{"data-slot":"tabs-content",className:Ue("flex-1 outline-none",e),...t})}function qc(e,t,{checkForDefaultPrevented:n=!0}={}){return function(s){if(e==null||e(s),n===!1||!s.defaultPrevented)return t==null?void 0:t(s)}}function en(e,t,{checkForDefaultPrevented:n=!0}={}){return function(s){if(e==null||e(s),n===!1||!s.defaultPrevented)return t==null?void 0:t(s)}}var h3="DismissableLayer",Bf="dismissableLayer.update",m3="dismissableLayer.pointerDownOutside",p3="dismissableLayer.focusOutside",Gg,k1=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),j1=d.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:i,onDismiss:l,...c}=e,u=d.useContext(k1),[h,f]=d.useState(null),p=(h==null?void 0:h.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=d.useState({}),v=yt(t,b=>f(b)),g=Array.from(u.layers),[x]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),w=g.indexOf(x),y=h?g.indexOf(h):-1,C=u.layersWithOutsidePointerEventsDisabled.size>0,S=y>=w,j=v3(b=>{const k=b.target,N=[...u.branches].some(A=>A.contains(k));!S||N||(s==null||s(b),i==null||i(b),b.defaultPrevented||l==null||l())},p),I=w3(b=>{const k=b.target;[...u.branches].some(A=>A.contains(k))||(a==null||a(b),i==null||i(b),b.defaultPrevented||l==null||l())},p);return Ih(b=>{y===u.layers.size-1&&(r==null||r(b),!b.defaultPrevented&&l&&(b.preventDefault(),l()))},p),d.useEffect(()=>{if(h)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Gg=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(h)),u.layers.add(h),qg(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=Gg)}},[h,p,n,u]),d.useEffect(()=>()=>{h&&(u.layers.delete(h),u.layersWithOutsidePointerEventsDisabled.delete(h),qg())},[h,u]),d.useEffect(()=>{const b=()=>m({});return document.addEventListener(Bf,b),()=>document.removeEventListener(Bf,b)},[]),o.jsx(ct.div,{...c,ref:v,style:{pointerEvents:C?S?"auto":"none":void 0,...e.style},onFocusCapture:en(e.onFocusCapture,I.onFocusCapture),onBlurCapture:en(e.onBlurCapture,I.onBlurCapture),onPointerDownCapture:en(e.onPointerDownCapture,j.onPointerDownCapture)})});j1.displayName=h3;var g3="DismissableLayerBranch",x3=d.forwardRef((e,t)=>{const n=d.useContext(k1),r=d.useRef(null),s=yt(t,r);return d.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),o.jsx(ct.div,{...e,ref:s})});x3.displayName=g3;function v3(e,t=globalThis==null?void 0:globalThis.document){const n=Dn(e),r=d.useRef(!1),s=d.useRef(()=>{});return d.useEffect(()=>{const a=l=>{if(l.target&&!r.current){let c=function(){E1(m3,n,u,{discrete:!0})};const u={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",s.current),s.current=c,t.addEventListener("click",s.current,{once:!0})):c()}else t.removeEventListener("click",s.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",s.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function w3(e,t=globalThis==null?void 0:globalThis.document){const n=Dn(e),r=d.useRef(!1);return d.useEffect(()=>{const s=a=>{a.target&&!r.current&&E1(p3,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",s),()=>t.removeEventListener("focusin",s)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function qg(){const e=new CustomEvent(Bf);document.dispatchEvent(e)}function E1(e,t,n,{discrete:r}){const s=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&s.addEventListener(e,t,{once:!0}),r?yu(s,a):s.dispatchEvent(a)}var Md=0;function y3(){d.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Yg()),document.body.insertAdjacentElement("beforeend",e[1]??Yg()),Md++,()=>{Md===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Md--}},[])}function Yg(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}function b3(e,t){return d.useReducer((n,r)=>t[n][r]??n,e)}var El=e=>{const{present:t,children:n}=e,r=C3(t),s=typeof n=="function"?n({present:r.isPresent}):d.Children.only(n),a=yt(r.ref,S3(s));return typeof n=="function"||r.isPresent?d.cloneElement(s,{ref:a}):null};El.displayName="Presence";function C3(e){const[t,n]=d.useState(),r=d.useRef(null),s=d.useRef(e),a=d.useRef("none"),i=e?"mounted":"unmounted",[l,c]=b3(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{const u=Ql(r.current);a.current=l==="mounted"?u:"none"},[l]),dn(()=>{const u=r.current,h=s.current;if(h!==e){const p=a.current,m=Ql(u);e?c("MOUNT"):m==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(h&&p!==m?"ANIMATION_OUT":"UNMOUNT"),s.current=e}},[e,c]),dn(()=>{if(t){let u;const h=t.ownerDocument.defaultView??window,f=m=>{const g=Ql(r.current).includes(CSS.escape(m.animationName));if(m.target===t&&g&&(c("ANIMATION_END"),!s.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",u=h.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},p=m=>{m.target===t&&(a.current=Ql(r.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{h.clearTimeout(u),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:d.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function Ql(e){return(e==null?void 0:e.animationName)||"none"}function S3(e){var r,s;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Ia(e,t,{checkForDefaultPrevented:n=!0}={}){return function(s){if(e==null||e(s),n===!1||!s.defaultPrevented)return t==null?void 0:t(s)}}var Dd="rovingFocusGroup.onEntryFocus",_3={bubbles:!1,cancelable:!0},Nl="RovingFocusGroup",[Vf,N1,k3]=Lu(Nl),[j3,T1]=pr(Nl,[k3]),[E3,N3]=j3(Nl),A1=d.forwardRef((e,t)=>o.jsx(Vf.Provider,{scope:e.__scopeRovingFocusGroup,children:o.jsx(Vf.Slot,{scope:e.__scopeRovingFocusGroup,children:o.jsx(T3,{...e,ref:t})})}));A1.displayName=Nl;var T3=d.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:s=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:h=!1,...f}=e,p=d.useRef(null),m=yt(t,p),v=yl(a),[g,x]=Ds({prop:i,defaultProp:l??null,onChange:c,caller:Nl}),[w,y]=d.useState(!1),C=Dn(u),S=N1(n),j=d.useRef(!1),[I,b]=d.useState(0);return d.useEffect(()=>{const k=p.current;if(k)return k.addEventListener(Dd,C),()=>k.removeEventListener(Dd,C)},[C]),o.jsx(E3,{scope:n,orientation:r,dir:v,loop:s,currentTabStopId:g,onItemFocus:d.useCallback(k=>x(k),[x]),onItemShiftTab:d.useCallback(()=>y(!0),[]),onFocusableItemAdd:d.useCallback(()=>b(k=>k+1),[]),onFocusableItemRemove:d.useCallback(()=>b(k=>k-1),[]),children:o.jsx(ct.div,{tabIndex:w||I===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:Ia(e.onMouseDown,()=>{j.current=!0}),onFocus:Ia(e.onFocus,k=>{const N=!j.current;if(k.target===k.currentTarget&&N&&!w){const A=new CustomEvent(Dd,_3);if(k.currentTarget.dispatchEvent(A),!A.defaultPrevented){const P=S().filter(L=>L.focusable),E=P.find(L=>L.active),R=P.find(L=>L.id===g),M=[E,R,...P].filter(Boolean).map(L=>L.ref.current);P1(M,h)}}j.current=!1}),onBlur:Ia(e.onBlur,()=>y(!1))})})}),I1="RovingFocusGroupItem",R1=d.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:s=!1,tabStopId:a,children:i,...l}=e,c=dr(),u=a||c,h=N3(I1,n),f=h.currentTabStopId===u,p=N1(n),{onFocusableItemAdd:m,onFocusableItemRemove:v,currentTabStopId:g}=h;return d.useEffect(()=>{if(r)return m(),()=>v()},[r,m,v]),o.jsx(Vf.ItemSlot,{scope:n,id:u,focusable:r,active:s,children:o.jsx(ct.span,{tabIndex:f?0:-1,"data-orientation":h.orientation,...l,ref:t,onMouseDown:Ia(e.onMouseDown,x=>{r?h.onItemFocus(u):x.preventDefault()}),onFocus:Ia(e.onFocus,()=>h.onItemFocus(u)),onKeyDown:Ia(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){h.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const w=R3(x,h.orientation,h.dir);if(w!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let C=p().filter(S=>S.focusable).map(S=>S.ref.current);if(w==="last")C.reverse();else if(w==="prev"||w==="next"){w==="prev"&&C.reverse();const S=C.indexOf(x.currentTarget);C=h.loop?P3(C,S+1):C.slice(S+1)}setTimeout(()=>P1(C))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:g!=null}):i})})});R1.displayName=I1;var A3={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function I3(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function R3(e,t,n){const r=I3(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return A3[r]}function P1(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function P3(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var M3=A1,D3=R1,Hf=["Enter"," "],O3=["ArrowDown","PageUp","Home"],M1=["ArrowUp","PageDown","End"],L3=[...O3,...M1],F3={ltr:[...Hf,"ArrowRight"],rtl:[...Hf,"ArrowLeft"]},z3={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Tl="Menu",[Xi,$3,U3]=Lu(Tl),[na,D1]=pr(Tl,[U3,zu,T1]),Hu=zu(),O1=T1(),[B3,ra]=na(Tl),[V3,Al]=na(Tl),L1=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:s,onOpenChange:a,modal:i=!0}=e,l=Hu(t),[c,u]=d.useState(null),h=d.useRef(!1),f=Dn(a),p=yl(s);return d.useEffect(()=>{const m=()=>{h.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>h.current=!1;return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),o.jsx(Ib,{...l,children:o.jsx(B3,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:u,children:o.jsx(V3,{scope:t,onClose:d.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:h,dir:p,modal:i,children:r})})})};L1.displayName=Tl;var H3="MenuAnchor",Cm=d.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,s=Hu(n);return o.jsx(Rb,{...s,...r,ref:t})});Cm.displayName=H3;var Sm="MenuPortal",[W3,F1]=na(Sm,{forceMount:void 0}),z1=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:s}=e,a=ra(Sm,t);return o.jsx(W3,{scope:t,forceMount:n,children:o.jsx(El,{present:n||a.open,children:o.jsx(li,{asChild:!0,container:s,children:r})})})};z1.displayName=Sm;var kr="MenuContent",[Z3,_m]=na(kr),$1=d.forwardRef((e,t)=>{const n=F1(kr,e.__scopeMenu),{forceMount:r=n.forceMount,...s}=e,a=ra(kr,e.__scopeMenu),i=Al(kr,e.__scopeMenu);return o.jsx(Xi.Provider,{scope:e.__scopeMenu,children:o.jsx(El,{present:r||a.open,children:o.jsx(Xi.Slot,{scope:e.__scopeMenu,children:i.modal?o.jsx(G3,{...s,ref:t}):o.jsx(q3,{...s,ref:t})})})})}),G3=d.forwardRef((e,t)=>{const n=ra(kr,e.__scopeMenu),r=d.useRef(null),s=yt(t,r);return d.useEffect(()=>{const a=r.current;if(a)return Iu(a)},[]),o.jsx(km,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:en(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),q3=d.forwardRef((e,t)=>{const n=ra(kr,e.__scopeMenu);return o.jsx(km,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Y3=ho("MenuContent.ScrollLock"),km=d.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:l,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:h,onFocusOutside:f,onInteractOutside:p,onDismiss:m,disableOutsideScroll:v,...g}=e,x=ra(kr,n),w=Al(kr,n),y=Hu(n),C=O1(n),S=$3(n),[j,I]=d.useState(null),b=d.useRef(null),k=yt(t,b,x.onContentChange),N=d.useRef(0),A=d.useRef(""),P=d.useRef(0),E=d.useRef(null),R=d.useRef("right"),_=d.useRef(0),M=v?vl:d.Fragment,L=v?{as:Y3,allowPinchZoom:!0}:void 0,F=O=>{var z,Z;const K=A.current+O,$=S().filter(J=>!J.disabled),W=document.activeElement,V=(z=$.find(J=>J.ref.current===W))==null?void 0:z.textValue,X=$.map(J=>J.textValue),H=i4(X,K,V),Q=(Z=$.find(J=>J.textValue===H))==null?void 0:Z.ref.current;(function J(ce){A.current=ce,window.clearTimeout(N.current),ce!==""&&(N.current=window.setTimeout(()=>J(""),1e3))})(K),Q&&setTimeout(()=>Q.focus())};d.useEffect(()=>()=>window.clearTimeout(N.current),[]),y3();const D=d.useCallback(O=>{var $,W;return R.current===(($=E.current)==null?void 0:$.side)&&c4(O,(W=E.current)==null?void 0:W.area)},[]);return o.jsx(Z3,{scope:n,searchRef:A,onItemEnter:d.useCallback(O=>{D(O)&&O.preventDefault()},[D]),onItemLeave:d.useCallback(O=>{var K;D(O)||((K=b.current)==null||K.focus(),I(null))},[D]),onTriggerLeave:d.useCallback(O=>{D(O)&&O.preventDefault()},[D]),pointerGraceTimerRef:P,onPointerGraceIntentChange:d.useCallback(O=>{E.current=O},[]),children:o.jsx(M,{...L,children:o.jsx(xl,{asChild:!0,trapped:s,onMountAutoFocus:en(a,O=>{var K;O.preventDefault(),(K=b.current)==null||K.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:o.jsx(j1,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:u,onPointerDownOutside:h,onFocusOutside:f,onInteractOutside:p,onDismiss:m,children:o.jsx(M3,{asChild:!0,...C,dir:w.dir,orientation:"vertical",loop:r,currentTabStopId:j,onCurrentTabStopIdChange:I,onEntryFocus:en(c,O=>{w.isUsingKeyboardRef.current||O.preventDefault()}),preventScrollOnEntryFocus:!0,children:o.jsx(Pb,{role:"menu","aria-orientation":"vertical","data-state":nC(x.open),"data-radix-menu-content":"",dir:w.dir,...y,...g,ref:k,style:{outline:"none",...g.style},onKeyDown:en(g.onKeyDown,O=>{const $=O.target.closest("[data-radix-menu-content]")===O.currentTarget,W=O.ctrlKey||O.altKey||O.metaKey,V=O.key.length===1;$&&(O.key==="Tab"&&O.preventDefault(),!W&&V&&F(O.key));const X=b.current;if(O.target!==X||!L3.includes(O.key))return;O.preventDefault();const Q=S().filter(z=>!z.disabled).map(z=>z.ref.current);M1.includes(O.key)&&Q.reverse(),o4(Q)}),onBlur:en(e.onBlur,O=>{O.currentTarget.contains(O.target)||(window.clearTimeout(N.current),A.current="")}),onPointerMove:en(e.onPointerMove,Ji(O=>{const K=O.target,$=_.current!==O.clientX;if(O.currentTarget.contains(K)&&$){const W=O.clientX>_.current?"right":"left";R.current=W,_.current=O.clientX}}))})})})})})})});$1.displayName=kr;var K3="MenuGroup",jm=d.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return o.jsx(ct.div,{role:"group",...r,ref:t})});jm.displayName=K3;var X3="MenuLabel",U1=d.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return o.jsx(ct.div,{...r,ref:t})});U1.displayName=X3;var Yc="MenuItem",Kg="menu.itemSelect",Wu=d.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...s}=e,a=d.useRef(null),i=Al(Yc,e.__scopeMenu),l=_m(Yc,e.__scopeMenu),c=yt(t,a),u=d.useRef(!1),h=()=>{const f=a.current;if(!n&&f){const p=new CustomEvent(Kg,{bubbles:!0,cancelable:!0});f.addEventListener(Kg,m=>r==null?void 0:r(m),{once:!0}),yu(f,p),p.defaultPrevented?u.current=!1:i.onClose()}};return o.jsx(B1,{...s,ref:c,disabled:n,onClick:en(e.onClick,h),onPointerDown:f=>{var p;(p=e.onPointerDown)==null||p.call(e,f),u.current=!0},onPointerUp:en(e.onPointerUp,f=>{var p;u.current||(p=f.currentTarget)==null||p.click()}),onKeyDown:en(e.onKeyDown,f=>{const p=l.searchRef.current!=="";n||p&&f.key===" "||Hf.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Wu.displayName=Yc;var B1=d.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:s,...a}=e,i=_m(Yc,n),l=O1(n),c=d.useRef(null),u=yt(t,c),[h,f]=d.useState(!1),[p,m]=d.useState("");return d.useEffect(()=>{const v=c.current;v&&m((v.textContent??"").trim())},[a.children]),o.jsx(Xi.ItemSlot,{scope:n,disabled:r,textValue:s??p,children:o.jsx(D3,{asChild:!0,...l,focusable:!r,children:o.jsx(ct.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...a,ref:u,onPointerMove:en(e.onPointerMove,Ji(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:en(e.onPointerLeave,Ji(v=>i.onItemLeave(v))),onFocus:en(e.onFocus,()=>f(!0)),onBlur:en(e.onBlur,()=>f(!1))})})})}),J3="MenuCheckboxItem",V1=d.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...s}=e;return o.jsx(q1,{scope:e.__scopeMenu,checked:n,children:o.jsx(Wu,{role:"menuitemcheckbox","aria-checked":Kc(n)?"mixed":n,...s,ref:t,"data-state":Nm(n),onSelect:en(s.onSelect,()=>r==null?void 0:r(Kc(n)?!0:!n),{checkForDefaultPrevented:!1})})})});V1.displayName=J3;var H1="MenuRadioGroup",[Q3,e4]=na(H1,{value:void 0,onValueChange:()=>{}}),W1=d.forwardRef((e,t)=>{const{value:n,onValueChange:r,...s}=e,a=Dn(r);return o.jsx(Q3,{scope:e.__scopeMenu,value:n,onValueChange:a,children:o.jsx(jm,{...s,ref:t})})});W1.displayName=H1;var Z1="MenuRadioItem",G1=d.forwardRef((e,t)=>{const{value:n,...r}=e,s=e4(Z1,e.__scopeMenu),a=n===s.value;return o.jsx(q1,{scope:e.__scopeMenu,checked:a,children:o.jsx(Wu,{role:"menuitemradio","aria-checked":a,...r,ref:t,"data-state":Nm(a),onSelect:en(r.onSelect,()=>{var i;return(i=s.onValueChange)==null?void 0:i.call(s,n)},{checkForDefaultPrevented:!1})})})});G1.displayName=Z1;var Em="MenuItemIndicator",[q1,t4]=na(Em,{checked:!1}),Y1=d.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...s}=e,a=t4(Em,n);return o.jsx(El,{present:r||Kc(a.checked)||a.checked===!0,children:o.jsx(ct.span,{...s,ref:t,"data-state":Nm(a.checked)})})});Y1.displayName=Em;var n4="MenuSeparator",K1=d.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return o.jsx(ct.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});K1.displayName=n4;var r4="MenuArrow",X1=d.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,s=Hu(n);return o.jsx(Mb,{...s,...r,ref:t})});X1.displayName=r4;var s4="MenuSub",[NU,J1]=na(s4),Ii="MenuSubTrigger",Q1=d.forwardRef((e,t)=>{const n=ra(Ii,e.__scopeMenu),r=Al(Ii,e.__scopeMenu),s=J1(Ii,e.__scopeMenu),a=_m(Ii,e.__scopeMenu),i=d.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=a,u={__scopeMenu:e.__scopeMenu},h=d.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return d.useEffect(()=>h,[h]),d.useEffect(()=>{const f=l.current;return()=>{window.clearTimeout(f),c(null)}},[l,c]),o.jsx(Cm,{asChild:!0,...u,children:o.jsx(B1,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":s.contentId,"data-state":nC(n.open),...e,ref:xu(t,s.onTriggerChange),onClick:f=>{var p;(p=e.onClick)==null||p.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:en(e.onPointerMove,Ji(f=>{a.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(a.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),h()},100))})),onPointerLeave:en(e.onPointerLeave,Ji(f=>{var m,v;h();const p=(m=n.content)==null?void 0:m.getBoundingClientRect();if(p){const g=(v=n.content)==null?void 0:v.dataset.side,x=g==="right",w=x?-5:5,y=p[x?"left":"right"],C=p[x?"right":"left"];a.onPointerGraceIntentChange({area:[{x:f.clientX+w,y:f.clientY},{x:y,y:p.top},{x:C,y:p.top},{x:C,y:p.bottom},{x:y,y:p.bottom}],side:g}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(f),f.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:en(e.onKeyDown,f=>{var m;const p=a.searchRef.current!=="";e.disabled||p&&f.key===" "||F3[r.dir].includes(f.key)&&(n.onOpenChange(!0),(m=n.content)==null||m.focus(),f.preventDefault())})})})});Q1.displayName=Ii;var eC="MenuSubContent",tC=d.forwardRef((e,t)=>{const n=F1(kr,e.__scopeMenu),{forceMount:r=n.forceMount,...s}=e,a=ra(kr,e.__scopeMenu),i=Al(kr,e.__scopeMenu),l=J1(eC,e.__scopeMenu),c=d.useRef(null),u=yt(t,c);return o.jsx(Xi.Provider,{scope:e.__scopeMenu,children:o.jsx(El,{present:r||a.open,children:o.jsx(Xi.Slot,{scope:e.__scopeMenu,children:o.jsx(km,{id:l.contentId,"aria-labelledby":l.triggerId,...s,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:h=>{var f;i.isUsingKeyboardRef.current&&((f=c.current)==null||f.focus()),h.preventDefault()},onCloseAutoFocus:h=>h.preventDefault(),onFocusOutside:en(e.onFocusOutside,h=>{h.target!==l.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:en(e.onEscapeKeyDown,h=>{i.onClose(),h.preventDefault()}),onKeyDown:en(e.onKeyDown,h=>{var m;const f=h.currentTarget.contains(h.target),p=z3[i.dir].includes(h.key);f&&p&&(a.onOpenChange(!1),(m=l.trigger)==null||m.focus(),h.preventDefault())})})})})})});tC.displayName=eC;function nC(e){return e?"open":"closed"}function Kc(e){return e==="indeterminate"}function Nm(e){return Kc(e)?"indeterminate":e?"checked":"unchecked"}function o4(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function a4(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function i4(e,t,n){const s=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let i=a4(e,Math.max(a,0));s.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.toLowerCase().startsWith(s.toLowerCase()));return c!==n?c:void 0}function l4(e,t){const{x:n,y:r}=e;let s=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const l=t[a],c=t[i],u=l.x,h=l.y,f=c.x,p=c.y;h>r!=p>r&&n<(f-u)*(r-h)/(p-h)+u&&(s=!s)}return s}function c4(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return l4(n,t)}function Ji(e){return t=>t.pointerType==="mouse"?e(t):void 0}var u4=L1,d4=Cm,f4=z1,h4=$1,m4=jm,p4=U1,g4=Wu,x4=V1,v4=W1,w4=G1,y4=Y1,b4=K1,C4=X1,S4=Q1,_4=tC,Zu="DropdownMenu",[k4,TU]=pr(Zu,[D1]),Xn=D1(),[j4,rC]=k4(Zu),sC=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:s,defaultOpen:a,onOpenChange:i,modal:l=!0}=e,c=Xn(t),u=d.useRef(null),[h,f]=Ds({prop:s,defaultProp:a??!1,onChange:i,caller:Zu});return o.jsx(j4,{scope:t,triggerId:dr(),triggerRef:u,contentId:dr(),open:h,onOpenChange:f,onOpenToggle:d.useCallback(()=>f(p=>!p),[f]),modal:l,children:o.jsx(u4,{...c,open:h,onOpenChange:f,dir:r,modal:l,children:n})})};sC.displayName=Zu;var oC="DropdownMenuTrigger",aC=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...s}=e,a=rC(oC,n),i=Xn(n);return o.jsx(d4,{asChild:!0,...i,children:o.jsx(ct.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...s,ref:xu(t,a.triggerRef),onPointerDown:qc(e.onPointerDown,l=>{!r&&l.button===0&&l.ctrlKey===!1&&(a.onOpenToggle(),a.open||l.preventDefault())}),onKeyDown:qc(e.onKeyDown,l=>{r||(["Enter"," "].includes(l.key)&&a.onOpenToggle(),l.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});aC.displayName=oC;var E4="DropdownMenuPortal",iC=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Xn(t);return o.jsx(f4,{...r,...n})};iC.displayName=E4;var lC="DropdownMenuContent",cC=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=rC(lC,n),a=Xn(n),i=d.useRef(!1);return o.jsx(h4,{id:s.contentId,"aria-labelledby":s.triggerId,...a,...r,ref:t,onCloseAutoFocus:qc(e.onCloseAutoFocus,l=>{var c;i.current||(c=s.triggerRef.current)==null||c.focus(),i.current=!1,l.preventDefault()}),onInteractOutside:qc(e.onInteractOutside,l=>{const c=l.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,h=c.button===2||u;(!s.modal||h)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});cC.displayName=lC;var N4="DropdownMenuGroup",T4=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=Xn(n);return o.jsx(m4,{...s,...r,ref:t})});T4.displayName=N4;var A4="DropdownMenuLabel",I4=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=Xn(n);return o.jsx(p4,{...s,...r,ref:t})});I4.displayName=A4;var R4="DropdownMenuItem",uC=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=Xn(n);return o.jsx(g4,{...s,...r,ref:t})});uC.displayName=R4;var P4="DropdownMenuCheckboxItem",M4=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=Xn(n);return o.jsx(x4,{...s,...r,ref:t})});M4.displayName=P4;var D4="DropdownMenuRadioGroup",O4=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=Xn(n);return o.jsx(v4,{...s,...r,ref:t})});O4.displayName=D4;var L4="DropdownMenuRadioItem",F4=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=Xn(n);return o.jsx(w4,{...s,...r,ref:t})});F4.displayName=L4;var z4="DropdownMenuItemIndicator",$4=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=Xn(n);return o.jsx(y4,{...s,...r,ref:t})});$4.displayName=z4;var U4="DropdownMenuSeparator",dC=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=Xn(n);return o.jsx(b4,{...s,...r,ref:t})});dC.displayName=U4;var B4="DropdownMenuArrow",V4=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=Xn(n);return o.jsx(C4,{...s,...r,ref:t})});V4.displayName=B4;var H4="DropdownMenuSubTrigger",W4=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=Xn(n);return o.jsx(S4,{...s,...r,ref:t})});W4.displayName=H4;var Z4="DropdownMenuSubContent",G4=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=Xn(n);return o.jsx(_4,{...s,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});G4.displayName=Z4;var q4=sC,Y4=aC,K4=iC,X4=cC,J4=uC,Q4=dC;function Ga({...e}){return o.jsx(q4,{"data-slot":"dropdown-menu",...e})}function qa({...e}){return o.jsx(Y4,{"data-slot":"dropdown-menu-trigger",...e})}function Ya({className:e,sideOffset:t=4,...n}){return o.jsx(K4,{children:o.jsx(X4,{"data-slot":"dropdown-menu-content",sideOffset:t,className:Ue("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",e),...n})})}function An({className:e,inset:t,variant:n="default",...r}){return o.jsx(J4,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":n,className:Ue("data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 px-2 py-1.5 text-sm outline-hidden select-none focus:bg-[var(--color-primary-w10)] focus:text-[var(--color-primary-text-w60)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 dark:focus:bg-[var(--color-primary-w60)] dark:focus:text-[var(--color-primary-text-w10)] [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r})}function Xg({className:e,...t}){return o.jsx(Q4,{"data-slot":"dropdown-menu-separator",className:Ue("bg-border -mx-1 my-1 h-px",e),...t})}function e5({className:e,...t}){return o.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:o.jsx("table",{"data-slot":"table",className:Ue("w-full caption-bottom text-sm",e),...t})})}function t5({className:e,...t}){return o.jsx("tbody",{"data-slot":"table-body",className:Ue("[&_tr:last-child]:border-0",e),...t})}function n5({className:e,...t}){return o.jsx("tr",{"data-slot":"table-row",className:Ue("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",e),...t})}function Jg({className:e,...t}){return o.jsx("td",{"data-slot":"table-cell",className:Ue("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t})}d.createContext(null);const fC=d.forwardRef(({className:e,...t},n)=>o.jsx(ts,{autoComplete:"off",ref:n,name:"message","data-testid":"chat-input",className:Ue("bg-card flex w-full items-center rounded-md px-4 py-3 placeholder:text-[var(--color-secondary-wMain)] disabled:cursor-not-allowed disabled:opacity-50",e),...t}));fC.displayName="ChatInput";const r5=Co("flex gap-2 max-w-full items-end relative group",{variants:{variant:{received:"self-start",sent:"self-end flex-row-reverse"},layout:{default:"",ai:"max-w-full w-full items-center"}},defaultVariants:{variant:"received",layout:"default"}}),Tm=d.forwardRef(({className:e,variant:t,layout:n,children:r,...s},a)=>o.jsx("div",{className:Ue(r5({variant:t,layout:n,className:e}),"group relative"),ref:a,...s,children:d.Children.map(r,i=>d.isValidElement(i)&&typeof i.type!="string"?d.cloneElement(i,{variant:t,layout:n}):i)}));Tm.displayName="ChatBubble";const s5=Co("",{variants:{variant:{received:"rounded-r-lg rounded-tl-lg",sent:"rounded-l-lg rounded-tr-lg justify-end bg-[var(--message-background)] p-4"},layout:{default:"",ai:"border-t w-full rounded-none bg-transparent"}},defaultVariants:{variant:"received",layout:"default"}}),Am=d.forwardRef(({className:e,variant:t,layout:n,children:r,...s},a)=>o.jsx("div",{className:Ue(s5({variant:t,layout:n,className:e}),"relative max-w-full leading-[150%] break-words"),ref:a,...s,children:o.jsx(o.Fragment,{children:r})}));Am.displayName="ChatBubbleMessage";const o5=d.forwardRef(({variant:e,className:t,children:n,...r},s)=>o.jsx("div",{ref:s,className:Ue("absolute top-1/2 flex -translate-y-1/2 opacity-0 transition-opacity duration-200 group-hover:opacity-100",e==="sent"?"-left-1 -translate-x-full flex-row-reverse":"-right-1 translate-x-full",t),...r,children:n}));o5.displayName="ChatBubbleActionWrapper";const hC={padding:"0 16px",maxWidth:"1280px",minWidth:"400px",margin:"0 auto",width:"100%"},mC=xt.forwardRef(({className:e="",children:t,...n},r)=>{const s=xt.useRef(null),{scrollRef:a,isAtBottom:i,disableAutoScroll:l,scrollToBottom:c,userHasScrolled:u}=h5({smooth:!0,content:t,contentRef:s});return d.useImperativeHandle(r,()=>({scrollToBottom:c})),o.jsxs("div",{className:`fade-both-mask relative h-full min-h-0 w-full flex-1 py-3 ${e}`,children:[o.jsx("div",{className:"flex h-full w-full flex-col overflow-y-auto p-4",ref:a,onWheel:l,onTouchMove:l,...n,style:{scrollBehavior:"smooth"},children:o.jsx("div",{className:"flex flex-col gap-6",style:hC,ref:s,children:t})}),!i&&u&&o.jsx(ye,{onClick:()=>{c()},size:"icon",variant:"outline",className:"bg-background absolute bottom-2 left-1/2 z-20 inline-flex -translate-x-1/2 transform rounded-full shadow-md","aria-label":"Scroll to bottom",children:o.jsx(_v,{className:"h-4 w-4"})})]})});mC.displayName="ChatMessageList";function a5({className:e=""}){return o.jsx(ws,{size:"small",variant:"primary",className:e})}const ec={error:"bg-[var(--color-error-w10)] text-[var(--color-error-wMain)] border-[var(--color-error-wMain)] dark:bg-[var(--color-error-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-error-w10)]",warning:"bg-[var(--color-warning-w10)] text-[var(--color-warning-wMain)] border-[var(--color-warning-wMain)] dark:bg-[var(--color-warning-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-warning-w10)]",info:"bg-[var(--color-info-w10)] text-[var(--color-info-wMain)] border-[var(--color-info-w10)] dark:bg-[var(--color-info-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-info-w10)]",success:"bg-[var(--color-success-w10)] text-[var(--color-success-wMain)] border-[var(--color-success-w10)] dark:bg-[var(--color-success-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-success-wMain)]"},i5=Co("inline-flex items-center justify-center rounded-lg border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"bg-[var(--color-secondary-w20)] dark:bg-muted border-transparent [a&]:hover:bg-primary/90",secondary:"border-transparent [a&]:hover:bg-secondary/90",destructive:"border-transparent [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"},type:{error:ec.error,warning:ec.warning,info:ec.info,success:ec.success}},defaultVariants:{variant:"default"}});function go({className:e,variant:t,type:n,asChild:r=!1,...s}){const a=r?kw:"span";return o.jsx(a,{"data-slot":"badge",className:Ue(i5({variant:t,type:n}),e),...s})}const l5=Co("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}});function c5({className:e,variant:t,...n}){return o.jsx("div",{"data-slot":"alert",role:"alert",className:Ue(l5({variant:t}),e),...n})}function u5({className:e,...t}){return o.jsx("div",{"data-slot":"alert-title",className:Ue("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t})}function d5({id:e,message:t,type:n}){return o.jsx("div",{id:e,className:"transform transition-all duration-200 ease-in-out",children:o.jsx(c5,{className:"light:border-none dark:border-border max-w-80 min-w-58 rounded-sm bg-[var(--color-background-wMain)] px-4 py-0 text-white shadow-[0_4px_6px_-1px_rgba(0,0,0,0.15)] dark:shadow-[0_4px_6px_-1px_rgba(255,255,255,0.1)]",children:o.jsxs(u5,{className:"flex h-10 items-center",children:[n==="warning"&&o.jsx(mh,{className:"mr-2 text-[var(--color-warning-wMain)]"}),n==="success"&&o.jsx(lu,{className:"mr-2 text-[var(--color-success-wMain)]"}),o.jsx("div",{className:"truncate",children:t})]})})})}function f5(){const{notifications:e}=$t();return e.length===0?null:o.jsx("div",{className:"pointer-events-none fixed bottom-4 left-1/2 z-50 flex -translate-x-1/2 transform flex-col-reverse gap-2",children:e.map(t=>o.jsx("div",{className:"pointer-events-auto",children:o.jsx(d5,{id:t.id,message:t.message,type:t.type})},t.id))})}function h5(e={}){const{offset:t=20,smooth:n=!1,content:r,autoScrollOnNewContent:s=!1,contentRef:a}=e,i=d.useRef(null),l=d.useRef(0),c=d.useRef(!1),u=d.useRef(0),h=d.useRef(!1),f=d.useRef(!1),[p,m]=d.useState({isAtBottom:!0,autoScrollEnabled:!0}),v=d.useCallback(y=>{const{scrollTop:C,scrollHeight:S,clientHeight:j}=y;return Math.abs(S-C-j)<=t},[t]),g=d.useCallback(y=>{if(!i.current)return;f.current=!0;const C=i.current.scrollHeight-i.current.clientHeight;y?i.current.scrollTop=C:i.current.scrollTo({top:C,behavior:n?"smooth":"auto"}),h.current=!1,m({isAtBottom:!0,autoScrollEnabled:!0}),c.current=!1,setTimeout(()=>{i.current&&(u.current=i.current.scrollTop),f.current=!1},y?50:500)},[n]),x=d.useCallback(()=>{if(!i.current||f.current)return;const y=i.current.scrollTop,C=v(i.current);u.current>0&&y<u.current&&(h.current=!0),u.current=y,C?(h.current=!1,m(()=>({isAtBottom:!0,autoScrollEnabled:!0}))):h.current?m(()=>({isAtBottom:!1,autoScrollEnabled:!1})):m(j=>({...j,isAtBottom:!1}))},[v]);d.useEffect(()=>{const y=i.current;if(y)return y.addEventListener("scroll",x,{passive:!0}),()=>y.removeEventListener("scroll",x)},[x]),d.useEffect(()=>{const y=i.current;if(!y)return;const C=y.scrollHeight;C!==l.current&&((p.autoScrollEnabled||s)&&requestAnimationFrame(()=>{g(l.current===0)}),l.current=C)},[r,p.autoScrollEnabled,g,s]),d.useEffect(()=>{const y=(a==null?void 0:a.current)||i.current;if(!y)return;const C=new ResizeObserver(()=>{p.autoScrollEnabled&&g(!0)});return C.observe(y),()=>C.disconnect()},[p.autoScrollEnabled,g,a]);const w=d.useCallback(()=>{(i.current?v(i.current):!1)||(c.current=!0,m(C=>({...C,autoScrollEnabled:!1})))},[v]);return{scrollRef:i,isAtBottom:p.isAtBottom,autoScrollEnabled:p.autoScrollEnabled,scrollToBottom:()=>g(),disableAutoScroll:w,userHasScrolled:c.current}}const m5=({isOpen:e,position:t,selectedText:n,onClose:r})=>{const s=d.useRef(null);d.useEffect(()=>{if(!e)return;const i=u=>{s.current&&!s.current.contains(u.target)&&r()},l=u=>{u.key==="Escape"&&r()},c=()=>{r()};return setTimeout(()=>{document.addEventListener("mousedown",i),document.addEventListener("keydown",l),window.addEventListener("scroll",c,!0)},100),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",l),window.removeEventListener("scroll",c,!0)}},[e,r]);const a=()=>{window.dispatchEvent(new CustomEvent("follow-up-question",{detail:{text:n,prompt:"",autoSubmit:!1}})),r()};return!e||!t?null:o.jsx("div",{ref:s,className:"animate-in fade-in-0 zoom-in-95 fixed z-50 duration-200",style:{left:`${t.x}px`,top:`${t.y}px`},children:o.jsx("div",{className:"bg-background w-auto max-w-[160px] rounded-md border p-1 shadow-lg",children:o.jsxs(ye,{variant:"ghost",className:"h-auto w-full justify-start gap-1.5 px-2 py-1.5 text-xs font-normal",onClick:a,children:[o.jsx(kv,{className:"h-3.5 w-3.5 flex-shrink-0"}),o.jsx("span",{className:"truncate",children:"Ask Followup"})]})})})};function p5(){const e=window.getSelection();return!e||e.rangeCount===0?null:e.toString().trim()||null}function pC(){const e=window.getSelection();return!e||e.rangeCount===0?null:e.getRangeAt(0)}function g5(){const e=pC();return e?e.getBoundingClientRect():null}function x5(e){let s=e.left,a=e.top-40-8;return s+160>window.innerWidth&&(s=window.innerWidth-160-8),s<8&&(s=8),a<8&&(a=e.bottom+8),{x:s,y:a}}function v5(e){if(!e)return!1;const t=e.trim();return t.length>=3&&/\S/.test(t)}const gC=({messageId:e,children:t,isAIMessage:n})=>{const{setSelection:r,clearSelection:s}=_w(),a=d.useRef(null),i=d.useCallback(()=>{n&&setTimeout(()=>{const l=p5(),c=pC(),u=g5();if(!v5(l)||!c||!u||!l)return;const h=a.current;if(!h||!c.intersectsNode(h))return;const f=x5(u);r(l,c,e,f)},10)},[n,e,r]);return d.useEffect(()=>{if(!(!a.current||!n))return document.addEventListener("mouseup",i),()=>{document.removeEventListener("mouseup",i)}},[i,n]),d.useEffect(()=>()=>{s()},[s]),o.jsx("div",{ref:a,className:"selectable-message-content",children:t})},Im=d.forwardRef(({disabled:e=!1,onTranscriptionComplete:t,onError:n,onRecordingStateChange:r,className:s},a)=>{const{settings:i}=So(),l=d.useRef(""),c=d.useRef(!0),u=d.useCallback(S=>{console.log("Transcription update:",S)},[]),h=d.useCallback(S=>{if(c.current&&S&&S.trim()){const j=l.current?`${l.current} ${S}`.trim():S.trim();t(j),l.current=""}else c.current||(console.log("AudioRecorder: Transcription canceled, not sending"),l.current="");c.current=!0},[t]),f=d.useCallback(S=>{console.error("Speech-to-text error:",S),n&&n(S)},[n]),{isListening:p,isLoading:m,startRecording:v,stopRecording:g}=sP({onTranscriptionComplete:h,onTranscriptionUpdate:u,onError:f});d.useEffect(()=>{r==null||r(p)},[p,r]),d.useImperativeHandle(a,()=>({startRecording:async()=>{p||(l.current="",c.current=!0,await v())},stopRecording:async()=>{p&&(c.current=!0,await g())},cancelRecording:async()=>{p&&(console.log("AudioRecorder: Canceling recording"),c.current=!1,await g())}}),[p,v,g]);const x=d.useCallback(async()=>{p?(c.current=!0,await g()):(l.current="",c.current=!0,await v())},[p,v,g]),w=()=>m?o.jsx(ur,{className:"size-5 animate-spin"}):p?o.jsx(of,{className:"size-5 animate-pulse"}):o.jsx(of,{className:"size-5"}),y=()=>p?"Stop recording":m?"Processing...":i.speechToText?"Start voice recording":"Speech-to-text is disabled",C=()=>p?"Stop voice recording":"Start voice recording";return i.speechToText?o.jsx(ye,{variant:"ghost",size:"icon",onClick:x,disabled:e||m,className:Ue("transition-colors",p&&"bg-[var(--accent-background)] text-[var(--primary-wMain)] hover:bg-[var(--accent-background)]/80",s),tooltip:y(),"aria-label":C(),"aria-pressed":p,"aria-busy":m,children:w()}):null});Im.displayName="AudioRecorder";function w5({width:e=24,height:t=24}){const{currentTheme:n}=wl(),r=n==="dark"?"var(--color-background-wMain)":"var(--color-background-w10)",s=n==="dark"?"var(--color-error-w100)":"var(--color-error-w10)";return o.jsxs("svg",{width:e,height:t,focusable:"false","aria-hidden":"true",viewBox:"0 0 131 131",fill:"none",children:[o.jsx("path",{d:"M119.681 63.9952C119.681 94.0948 95.2807 118.495 65.1812 118.495C35.0816 118.495 10.6812 94.0948 10.6812 63.9952C10.6812 33.8957 35.0816 9.49524 65.1812 9.49524C95.2807 9.49524 119.681 33.8957 119.681 63.9952Z",fill:s}),o.jsx("path",{d:"M2.68115 119.495H128.681V120.495H2.68115V119.495Z",fill:"var(--color-secondary-wMain)"}),o.jsx("rect",{x:14,y:34,width:104.054,height:70.6982,rx:1,fill:r,stroke:"var(--color-secondary-wMain)",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M59.4929 105.314C59.6018 104.866 60.0032 104.55 60.4646 104.55H72.4448C72.9061 104.55 73.3076 104.866 73.4165 105.314L75.1457 112.433C75.2986 113.062 74.8218 113.669 74.174 113.669H58.7354C58.0876 113.669 57.6107 113.062 57.7637 112.433L59.4929 105.314Z",fill:r,stroke:"var(--color-secondary-wMain)",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M47.7852 114.103C47.7852 113.55 48.2329 113.103 48.7852 113.103H83.2724C83.8247 113.103 84.2724 113.55 84.2724 114.103V118.656C84.2724 119.208 83.8247 119.656 83.2724 119.656H48.7852C48.2329 119.656 47.7852 119.208 47.7852 118.656V114.103Z",fill:r,stroke:"var(--color-secondary-wMain)",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M15.1406 95.0068H117.773",stroke:"var(--color-secondary-wMain)",strokeWidth:2}),o.jsxs("g",{clipPath:"url(#clip0_1688:196070)",children:[o.jsx("rect",{opacity:.2,x:54.1126,y:45.1681,width:24.1,height:24.1,stroke:"var(--color-secondary-wMain)",strokeWidth:.1}),o.jsx("path",{d:"M65.6426 60.1142C65.5359 60.1142 65.4453 60.0769 65.3706 60.0022C65.2959 59.9275 65.2586 59.8369 65.2586 59.7302V52.4022C65.2586 52.2955 65.2959 52.2049 65.3706 52.1302C65.4453 52.0555 65.5359 52.0182 65.6426 52.0182H66.9386C67.0559 52.0182 67.1466 52.0555 67.2106 52.1302C67.2853 52.1942 67.3226 52.2849 67.3226 52.4022V59.7302C67.3226 59.8369 67.2853 59.9275 67.2106 60.0022C67.1466 60.0769 67.0559 60.1142 66.9386 60.1142H65.6426ZM65.5466 63.2182C65.4399 63.2182 65.3493 63.1809 65.2746 63.1062C65.1999 63.0315 65.1626 62.9409 65.1626 62.8342V61.3462C65.1626 61.2289 65.1999 61.1329 65.2746 61.0582C65.3493 60.9835 65.4399 60.9462 65.5466 60.9462H67.0346C67.1519 60.9462 67.2479 60.9835 67.3226 61.0582C67.3973 61.1329 67.4346 61.2289 67.4346 61.3462V62.8342C67.4346 62.9409 67.3973 63.0315 67.3226 63.1062C67.2479 63.1809 67.1519 63.2182 67.0346 63.2182H65.5466Z",fill:"var(--color-secondary-wMain)"})]}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M51.3433 73.2659C51.3433 72.9897 51.5671 72.7659 51.8433 72.7659H80.2102C80.4864 72.7659 80.7102 72.9897 80.7102 73.2659C80.7102 73.542 80.4864 73.7659 80.2102 73.7659H51.8433C51.5671 73.7659 51.3433 73.542 51.3433 73.2659Z",fill:"var(--color-secondary-wMain)"}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M55.1851 83.2659C55.1851 82.9897 55.3503 82.7659 55.5542 82.7659H76.4995C76.7034 82.7659 76.8687 82.9897 76.8687 83.2659C76.8687 83.542 76.7034 83.7659 76.4995 83.7659H55.5542C55.3503 83.7659 55.1851 83.542 55.1851 83.2659Z",fill:"var(--color-secondary-wMain)"}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M51.3433 78.2659C51.3433 77.9897 51.5671 77.7659 51.8433 77.7659H80.2102C80.4864 77.7659 80.7102 77.9897 80.7102 78.2659C80.7102 78.542 80.4864 78.7659 80.2102 78.7659H51.8433C51.5671 78.7659 51.3433 78.542 51.3433 78.2659Z",fill:"var(--color-secondary-wMain)"}),o.jsx("defs",{children:o.jsx("clipPath",{id:"clip0_1688:196070",children:o.jsx("rect",{width:24,height:24,fill:r,transform:"translate(54.1626 45.2181)"})})})]})}function y5({width:e=24,height:t=24}){const{currentTheme:n}=wl(),r=n==="dark"?"var(--color-background-wMain)":"var(--color-background-w10)";return o.jsxs("svg",{width:e,height:t,viewBox:"0 0 130 130",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsxs("g",{clipPath:"url(#clip0_483_284)",children:[o.jsx("path",{opacity:.1,d:"M130 61.4874C130 95.4459 102.471 122.975 68.5125 122.975C34.554 122.975 7.02515 95.4459 7.02515 61.4874C7.02515 27.5288 34.554 0 68.5125 0C102.471 0 130 27.5288 130 61.4874Z",fill:"var(--color-info-wMain)"}),o.jsx("path",{d:"M0 25.9979C0 24.1286 1.51535 22.6133 3.38463 22.6133H41.082C49.1822 22.6133 55.7487 29.1798 55.7487 37.28V116.273C55.7487 118.142 54.2333 119.657 52.3641 119.657H3.38463C1.51535 119.657 0 118.142 0 116.273V25.9979Z",fill:r}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M41.082 24.8697H3.38463C2.76154 24.8697 2.25642 25.3748 2.25642 25.9979V116.273C2.25642 116.896 2.76153 117.401 3.38463 117.401H52.3641C52.9871 117.401 53.4923 116.896 53.4923 116.273V37.28C53.4923 30.426 47.936 24.8697 41.082 24.8697ZM3.38463 22.6133C1.51535 22.6133 0 24.1286 0 25.9979V116.273C0 118.142 1.51535 119.657 3.38463 119.657H52.3641C54.2333 119.657 55.7487 118.142 55.7487 116.273V37.28C55.7487 29.1798 49.1822 22.6133 41.082 22.6133H3.38463Z",fill:"var(--color-secondary-wMain)"}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M53.0258 112.821H2.25642V116.206C2.25642 116.829 2.76153 117.334 3.38462 117.334H51.8976C52.5207 117.334 53.0258 116.829 53.0258 116.206V112.821ZM0 110.565V116.206C0 118.075 1.51535 119.59 3.38462 119.59H51.8976C53.7669 119.59 55.2822 118.075 55.2822 116.206V110.565H0Z",fill:"var(--color-secondary-wMain)"}),o.jsx("path",{d:"M51.8977 38.3591C51.8977 29.6358 58.9693 22.5642 67.6926 22.5642H107.18C109.049 22.5642 110.564 24.0796 110.564 25.9488V116.206C110.564 118.075 109.049 119.59 107.18 119.59H55.2823C53.413 119.59 51.8977 118.075 51.8977 116.206V38.3591Z",fill:r}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M107.18 24.8206H67.6926C60.2155 24.8206 54.1541 30.882 54.1541 38.3591V116.206C54.1541 116.829 54.6592 117.334 55.2823 117.334H107.18C107.803 117.334 108.308 116.829 108.308 116.206V25.9488C108.308 25.3257 107.803 24.8206 107.18 24.8206ZM67.6926 22.5642C58.9693 22.5642 51.8977 29.6358 51.8977 38.3591V116.206C51.8977 118.075 53.413 119.59 55.2823 119.59H107.18C109.049 119.59 110.564 118.075 110.564 116.206V25.9488C110.564 24.0796 109.049 22.5642 107.18 22.5642H67.6926Z",fill:"var(--color-secondary-wMain)"}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M108.308 112.821H54.1541V116.206C54.1541 116.829 54.6592 117.334 55.2823 117.334H107.18C107.803 117.334 108.308 116.829 108.308 116.206V112.821ZM51.8977 110.565V116.206C51.8977 118.075 53.413 119.59 55.2823 119.59H107.18C109.049 119.59 110.564 118.075 110.564 116.206V110.565H51.8977Z",fill:"var(--color-secondary-wMain)"}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M29.0351 36.0336C29.0351 35.722 29.2876 35.4695 29.5992 35.4695H43.0726C43.3842 35.4695 43.6367 35.722 43.6367 36.0336C43.6367 36.3451 43.3842 36.5977 43.0726 36.5977H29.5992C29.2876 36.5977 29.0351 36.3451 29.0351 36.0336ZM29.0351 42.7441C29.0351 42.4325 29.2876 42.1799 29.5992 42.1799H43.0726C43.3842 42.1799 43.6367 42.4325 43.6367 42.7441C43.6367 43.0556 43.3842 43.3082 43.0726 43.3082H29.5992C29.2876 43.3082 29.0351 43.0556 29.0351 42.7441ZM29.0351 49.4545C29.0351 49.143 29.2876 48.8904 29.5992 48.8904H43.0726C43.3842 48.8904 43.6367 49.143 43.6367 49.4545C43.6367 49.7661 43.3842 50.0186 43.0726 50.0186H29.5992C29.2876 50.0186 29.0351 49.7661 29.0351 49.4545ZM9.75977 60.2946C9.75977 59.983 10.0123 59.7305 10.3239 59.7305H23.7973C24.1089 59.7305 24.3614 59.983 24.3614 60.2946C24.3614 60.6061 24.1089 60.8587 23.7973 60.8587H10.3239C10.0123 60.8587 9.75977 60.6061 9.75977 60.2946ZM9.75977 67.0051C9.75977 66.6935 10.0123 66.4409 10.3239 66.4409H23.7973C24.1089 66.4409 24.3614 66.6935 24.3614 67.0051C24.3614 67.3166 24.1089 67.5692 23.7973 67.5692H10.3239C10.0123 67.5692 9.75977 67.3166 9.75977 67.0051ZM9.75977 73.7155C9.75977 73.404 10.0123 73.1514 10.3239 73.1514H23.7973C24.1089 73.1514 24.3614 73.404 24.3614 73.7155C24.3614 74.0271 24.1089 74.2796 23.7973 74.2796H10.3239C10.0123 74.2796 9.75977 74.0271 9.75977 73.7155Z",fill:"var(--color-secondary-wMain)"}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.75977 83.5231C9.75977 83.2116 10.0123 82.959 10.3239 82.959H42.3277C42.6393 82.959 42.8918 83.2116 42.8918 83.5231C42.8918 83.8347 42.6393 84.0872 42.3277 84.0872H10.3239C10.0123 84.0872 9.75977 83.8347 9.75977 83.5231Z",fill:"var(--color-secondary-wMain)"}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.75977 93.8473C9.75977 93.5357 10.0123 93.2832 10.3239 93.2832H42.3277C42.6393 93.2832 42.8918 93.5357 42.8918 93.8473C42.8918 94.1588 42.6393 94.4114 42.3277 94.4114H10.3239C10.0123 94.4114 9.75977 94.1588 9.75977 93.8473Z",fill:"var(--color-secondary-wMain)"}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.75977 88.6852C9.75977 88.3737 10.0123 88.1211 10.3239 88.1211H42.3277C42.6393 88.1211 42.8918 88.3737 42.8918 88.6852C42.8918 88.9967 42.6393 89.2493 42.3277 89.2493H10.3239C10.0123 89.2493 9.75977 88.9967 9.75977 88.6852Z",fill:"var(--color-secondary-wMain)"}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.75977 99.0089C9.75977 98.6974 10.0123 98.4448 10.3239 98.4448H42.3277C42.6393 98.4448 42.8918 98.6974 42.8918 99.0089C42.8918 99.3205 42.6393 99.573 42.3277 99.573H10.3239C10.0123 99.573 9.75977 99.3205 9.75977 99.0089Z",fill:"var(--color-secondary-wMain)"}),o.jsx("path",{d:"M22.9252 42.8986C22.9252 46.6372 19.8945 49.6679 16.156 49.6679C12.4174 49.6679 9.38672 46.6372 9.38672 42.8986C9.38672 39.1601 12.4174 36.1294 16.156 36.1294C19.8945 36.1294 22.9252 39.1601 22.9252 42.8986Z",fill:r}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.156 47.4115C18.6483 47.4115 20.6688 45.391 20.6688 42.8986C20.6688 40.4063 18.6483 38.3858 16.156 38.3858C13.6636 38.3858 11.6431 40.4063 11.6431 42.8986C11.6431 45.391 13.6636 47.4115 16.156 47.4115ZM16.156 49.6679C19.8945 49.6679 22.9252 46.6372 22.9252 42.8986C22.9252 39.1601 19.8945 36.1294 16.156 36.1294C12.4174 36.1294 9.38672 39.1601 9.38672 42.8986C9.38672 46.6372 12.4174 49.6679 16.156 49.6679Z",fill:"var(--color-secondary-wMain)"}),o.jsx("path",{d:"M31.5107 63.1795C31.5107 61.9333 32.521 60.9231 33.7672 60.9231H40.5364C41.7826 60.9231 42.7928 61.9334 42.7928 63.1795V68.9231C42.7928 70.1693 41.7826 71.1796 40.5364 71.1796H33.7672C32.521 71.1796 31.5107 70.1693 31.5107 68.9231V63.1795Z",fill:r}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M40.5364 63.1795H33.7672V68.9231H40.5364V63.1795ZM33.7672 60.9231C32.521 60.9231 31.5107 61.9333 31.5107 63.1795V68.9231C31.5107 70.1693 32.521 71.1796 33.7672 71.1796H40.5364C41.7826 71.1796 42.7928 70.1693 42.7928 68.9231V63.1795C42.7928 61.9334 41.7826 60.9231 40.5364 60.9231H33.7672Z",fill:"var(--color-secondary-wMain)"}),o.jsx("path",{d:"M102.325 102.029C101.702 100.949 102.072 99.5694 103.151 98.9463L107.108 96.6618C108.188 96.0387 109.568 96.4084 110.191 97.4877L123.409 120.382C124.032 121.461 123.662 122.841 122.583 123.464L118.626 125.749C117.547 126.372 116.167 126.002 115.543 124.923L102.325 102.029Z",fill:r}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M108.237 98.6159L104.28 100.9L117.498 123.795L121.455 121.51L108.237 98.6159ZM103.151 98.9463C102.072 99.5694 101.702 100.949 102.325 102.029L115.543 124.923C116.167 126.002 117.547 126.372 118.626 125.749L122.583 123.464C123.662 122.841 124.032 121.461 123.409 120.382L110.191 97.4877C109.568 96.4084 108.188 96.0387 107.108 96.6618L103.151 98.9463Z",fill:"var(--color-secondary-wMain)"}),o.jsx("path",{d:"M115.803 66.4824C115.803 82.3642 102.928 95.239 87.0466 95.239C71.1648 95.239 58.29 82.3642 58.29 66.4824C58.29 50.6006 71.1648 37.7258 87.0466 37.7258C102.928 37.7258 115.803 50.6006 115.803 66.4824Z",fill:r}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M87.0466 92.9825C101.682 92.9825 113.547 81.118 113.547 66.4824C113.547 51.8468 101.682 39.9822 87.0466 39.9822C72.411 39.9822 60.5465 51.8468 60.5465 66.4824C60.5465 81.118 72.411 92.9825 87.0466 92.9825ZM87.0466 95.239C102.928 95.239 115.803 82.3642 115.803 66.4824C115.803 50.6006 102.928 37.7258 87.0466 37.7258C71.1648 37.7258 58.29 50.6006 58.29 66.4824C58.29 82.3642 71.1648 95.239 87.0466 95.239Z",fill:"var(--color-secondary-wMain)"}),o.jsx("path",{d:"M109.771 66.4825C109.771 79.0329 99.5964 89.2071 87.0459 89.2071C74.4954 89.2071 64.3213 79.0329 64.3213 66.4825C64.3213 53.932 74.4954 43.7578 87.0459 43.7578C99.5964 43.7578 109.771 53.932 109.771 66.4825Z",fill:r}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M87.0459 86.9507C98.3502 86.9507 107.514 77.7868 107.514 66.4825C107.514 55.1782 98.3502 46.0142 87.0459 46.0142C75.7416 46.0142 66.5777 55.1782 66.5777 66.4825C66.5777 77.7868 75.7416 86.9507 87.0459 86.9507ZM87.0459 89.2071C99.5964 89.2071 109.771 79.0329 109.771 66.4825C109.771 53.932 99.5964 43.7578 87.0459 43.7578C74.4954 43.7578 64.3213 53.932 64.3213 66.4825C64.3213 79.0329 74.4954 89.2071 87.0459 89.2071Z",fill:"var(--color-secondary-wMain)"}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M86.4824 49.2829C86.4824 48.9713 86.735 48.7188 87.0465 48.7188C96.8572 48.7188 104.81 56.6717 104.81 66.4823C104.81 66.7939 104.558 67.0465 104.246 67.0465C103.935 67.0465 103.682 66.7939 103.682 66.4823C103.682 57.2948 96.2341 49.847 87.0465 49.847C86.735 49.847 86.4824 49.5944 86.4824 49.2829ZM72.0594 74.9461C72.3254 74.7838 72.6725 74.868 72.8348 75.134C73.8285 76.7627 75.0945 78.2075 76.5695 79.4049C77.4599 80.1277 78.4264 80.7603 79.4549 81.2888C81.7303 82.4579 84.3105 83.1178 87.0465 83.1178C87.3581 83.1178 87.6106 83.3704 87.6106 83.6819C87.6106 83.9935 87.3581 84.2461 87.0465 84.2461C84.127 84.2461 81.3705 83.5413 78.9393 82.2922C77.8408 81.7278 76.8089 81.0524 75.8584 80.2808C74.2841 79.0028 72.9327 77.4606 71.8717 75.7216C71.7094 75.4556 71.7935 75.1084 72.0594 74.9461Z",fill:"var(--color-secondary-wMain)"}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M104.511 99.0423L100.011 91.2478L101.965 90.1196L106.465 97.9141L104.511 99.0423Z",fill:"var(--color-secondary-wMain)"}),o.jsx("path",{d:"M86.2924 72.1957C86.1299 72.1957 85.9945 72.1505 85.8862 72.0603C85.7779 71.952 85.7238 71.8076 85.7238 71.6271C85.7238 71.4465 85.7238 71.266 85.7238 71.0855C85.7238 70.905 85.7238 70.7245 85.7238 70.544C85.7599 69.7678 85.9314 69.0818 86.2382 68.4861C86.5451 67.8904 86.9152 67.3489 87.3484 66.8615C87.7997 66.3741 88.251 65.9138 88.7023 65.4806C89.1535 65.0293 89.5326 64.578 89.8395 64.1267C90.1644 63.6754 90.363 63.1971 90.4352 62.6916C90.5074 62.0418 90.381 61.5003 90.0561 61.067C89.7312 60.6157 89.2889 60.2728 88.7293 60.0381C88.1697 59.8034 87.5921 59.6861 86.9964 59.6861C86.0397 59.6861 85.2183 59.9388 84.5324 60.4442C83.8645 60.9316 83.4222 61.762 83.2056 62.9353C83.1515 63.1519 83.0612 63.3054 82.9348 63.3956C82.8085 63.4859 82.6641 63.531 82.5016 63.531H81.2019C81.0395 63.531 80.895 63.4769 80.7687 63.3686C80.6604 63.2603 80.6062 63.1158 80.6062 62.9353C80.6243 62.1952 80.7867 61.4912 81.0936 60.8233C81.4005 60.1554 81.8337 59.5688 82.3933 59.0633C82.9709 58.5579 83.6479 58.1608 84.4241 57.8719C85.2183 57.5651 86.1029 57.4116 87.0776 57.4116C88.1788 57.4116 89.1174 57.5651 89.8936 57.8719C90.6879 58.1608 91.3197 58.5579 91.789 59.0633C92.2764 59.5507 92.6284 60.0922 92.845 60.6879C93.0616 61.2836 93.1519 61.8793 93.1158 62.475C93.0617 63.1971 92.8811 63.8469 92.5743 64.4246C92.2674 64.9842 91.8973 65.5076 91.4641 65.995C91.0309 66.4644 90.5886 66.9337 90.1373 67.403C89.7041 67.8543 89.325 68.3327 89.0001 68.8381C88.6932 69.3255 88.5217 69.858 88.4856 70.4357C88.4676 70.6342 88.4495 70.8328 88.4315 71.0314C88.4315 71.2119 88.4315 71.3924 88.4315 71.5729C88.3954 71.7715 88.3232 71.9249 88.2149 72.0332C88.1066 72.1415 87.9531 72.1957 87.7546 72.1957H86.2924ZM86.0758 76.6363C85.8953 76.6363 85.7418 76.5821 85.6155 76.4738C85.5072 76.3475 85.453 76.194 85.453 76.0135V74.3618C85.453 74.1813 85.5072 74.0369 85.6155 73.9286C85.7418 73.8022 85.8953 73.7391 86.0758 73.7391H87.8358C88.0344 73.7391 88.1878 73.8022 88.2961 73.9286C88.4225 74.0369 88.4856 74.1813 88.4856 74.3618V76.0135C88.4856 76.194 88.4225 76.3475 88.2961 76.4738C88.1878 76.5821 88.0344 76.6363 87.8358 76.6363H86.0758Z",fill:"var(--color-secondary-wMain)"})]}),o.jsx("defs",{children:o.jsx("clipPath",{id:"clip0_483_284",children:o.jsx("rect",{width:130,height:130,fill:r})})})]})}function rr({title:e,subtitle:t,image:n,variant:r="error",buttons:s,className:a}){const i={error:o.jsx(w5,{width:150,height:150}),notFound:o.jsx(y5,{width:150,height:150}),loading:o.jsx(ws,{size:"large"}),noImage:null};return o.jsxs("div",{className:Ue("flex h-full w-full flex-col items-center justify-center gap-3",a),children:[n||i[r]||null,o.jsx("p",{className:"mt-4 text-lg",children:e}),t?o.jsx("p",{className:"max-w-xl text-center text-sm",children:t}):null,o.jsx("div",{className:"mt-3 flex min-w-50 flex-col gap-2",children:s&&s.map(({icon:l,text:c,variant:u,onClick:h},f)=>o.jsxs(ye,{testid:c,title:c,variant:u,onClick:h,children:[l||null,c]},`button-${c}-${f}`))})]})}const tc=({message:e,className:t})=>e?o.jsx("div",{className:`text-xs text-(--color-error-wMain) ${t}`,children:e}):null,b5=(e,t)=>{if(!e)return null;const n=Array.from(e);if(n.splice(t,1),n.length===0)return null;const r=new DataTransfer;return n.forEach(s=>r.items.add(s)),r.files};function Rm({name:e,accept:t,multiple:n=!1,disabled:r=!1,testid:s="",value:a=null,onChange:i,onValidate:l}){const[c,u]=d.useState(a),[h,f]=d.useState(!1),[p,m]=d.useState(null),v=d.useRef(null);d.useEffect(()=>{u(a)},[a]);const g=k=>{if(k&&k.length>0){if(l){const N=l(k);if(!N.valid){m(N.error||"File validation failed."),v.current&&(v.current.value="");return}}m(null),u(k),i(k)}else m(null),u(null),i(null),v.current.value=""},x=k=>{k.preventDefault(),f(!0)},w=k=>{k.preventDefault(),f(!1)},y=k=>{k.preventDefault(),r?k.currentTarget.style.cursor="not-allowed":k.currentTarget.style.cursor="default"},C=k=>{if(k.preventDefault(),f(!1),!r){let N=k.dataTransfer.files;if(!n&&N.length>1){const A=new DataTransfer;A.items.add(N[0]),N=A.files}g(N)}},S=k=>{const N=k.target.files;g(N)},j=k=>{var N;k.preventDefault(),(N=v.current)==null||N.click()},I=()=>{m(null)},b=k=>{const N=b5(c,k);u(N),i(N),v.current&&(v.current.value="")};return o.jsxs("div",{children:[p&&o.jsx("div",{className:"mb-3",children:o.jsx(Xt,{variant:"error",message:p,dismissible:!0,onDismiss:I})}),o.jsx("input",{ref:v,name:e,type:"file",multiple:n,disabled:r,onChange:S,className:"hidden",accept:t,"data-testid":s}),c?Array.from(c).map((k,N)=>o.jsxs("div",{className:"var(--tw-border-style) flex h-[48px] flex-row items-center rounded-sm border-1 pr-2 pl-4 text-[var(--color-secondary-text-wMain)]",children:[o.jsx("div",{className:"flex-1 font-semibold",children:k.name}),o.jsx(ye,{variant:"ghost",size:"sm",onClick:()=>b(N),"aria-label":`Remove file ${k.name}`,children:o.jsx(Kr,{})})]},k.name)):o.jsx("div",{className:`flex h-[140px] flex-col justify-center rounded-sm border-1 border-dashed transition-colors ${h?"border-[var(--color-brand-wMain)] hover:border-solid":"border-[var(--color-secondary-w40)]"}`,onDragEnter:x,onDragLeave:w,onDragOver:y,onDrop:C,role:"dropzone",children:h&&!r?o.jsx("div",{className:"pointer-events-none text-center text-[var(--color-primary-text-wMain)]",children:"Drop file here"}):o.jsxs("div",{className:"pointer-events-none text-center text-[var(--color-secondary-text-wMain)]",children:[o.jsx("div",{children:"Drag and drop file here"}),o.jsxs("div",{className:"mt-2 mb-2 flex flex-row items-center justify-center",children:[o.jsx("div",{className:"mr-1 h-[1px] w-[125px] bg-[var(--color-secondary-w40)]"}),o.jsx("div",{children:"OR"}),o.jsx("div",{className:"ml-1 h-[1px] w-[125px] bg-[var(--color-secondary-w40)]"})]}),o.jsx("div",{children:o.jsx(ye,{className:"pointer-events-auto",variant:"ghost",disabled:r,onClick:j,children:"Upload File"})})]})})]})}const C5=({children:e,className:t=""})=>o.jsx("div",{className:`flex h-16 items-center justify-end gap-4 border-t px-8 ${t}`,children:e}),Gu=({children:e,className:t,isSelected:n,onClick:r,...s})=>o.jsx(JT,{className:Ue("flex h-[200px] w-[380px] flex-shrink-0 py-4 transition-all",r&&"cursor-pointer hover:bg-[var(--color-primary-w10)] dark:hover:bg-[var(--color-primary-wMain)]",r&&"focus-visible:border-[var(--color-brand-w100)] focus-visible:outline-none",n&&"border-[var(--color-brand-w100)]",t),onClick:r,onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),r==null||r())},...r&&{role:"button",tabIndex:0},noPadding:!0,...s,children:e});/*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */const{entries:xC,setPrototypeOf:Qg,isFrozen:S5,getPrototypeOf:_5,getOwnPropertyDescriptor:k5}=Object;let{freeze:Yn,seal:Er,create:vC}=Object,{apply:Wf,construct:Zf}=typeof Reflect<"u"&&Reflect;Yn||(Yn=function(t){return t});Er||(Er=function(t){return t});Wf||(Wf=function(t,n,r){return t.apply(n,r)});Zf||(Zf=function(t,n){return new t(...n)});const nc=Kn(Array.prototype.forEach),j5=Kn(Array.prototype.lastIndexOf),ex=Kn(Array.prototype.pop),vi=Kn(Array.prototype.push),E5=Kn(Array.prototype.splice),_c=Kn(String.prototype.toLowerCase),Od=Kn(String.prototype.toString),tx=Kn(String.prototype.match),wi=Kn(String.prototype.replace),N5=Kn(String.prototype.indexOf),T5=Kn(String.prototype.trim),Fr=Kn(Object.prototype.hasOwnProperty),Hn=Kn(RegExp.prototype.test),yi=A5(TypeError);function Kn(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return Wf(e,t,r)}}function A5(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Zf(e,n)}}function It(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:_c;Qg&&Qg(e,null);let r=t.length;for(;r--;){let s=t[r];if(typeof s=="string"){const a=n(s);a!==s&&(S5(t)||(t[r]=a),s=a)}e[s]=!0}return e}function I5(e){for(let t=0;t<e.length;t++)Fr(e,t)||(e[t]=null);return e}function Ts(e){const t=vC(null);for(const[n,r]of xC(e))Fr(e,n)&&(Array.isArray(r)?t[n]=I5(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=Ts(r):t[n]=r);return t}function bi(e,t){for(;e!==null;){const r=k5(e,t);if(r){if(r.get)return Kn(r.get);if(typeof r.value=="function")return Kn(r.value)}e=_5(e)}function n(){return null}return n}const nx=Yn(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ld=Yn(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Fd=Yn(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),R5=Yn(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),zd=Yn(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),P5=Yn(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),rx=Yn(["#text"]),sx=Yn(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),$d=Yn(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),ox=Yn(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),rc=Yn(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),M5=Er(/\{\{[\w\W]*|[\w\W]*\}\}/gm),D5=Er(/<%[\w\W]*|[\w\W]*%>/gm),O5=Er(/\$\{[\w\W]*/gm),L5=Er(/^data-[\-\w.\u00B7-\uFFFF]+$/),F5=Er(/^aria-[\-\w]+$/),wC=Er(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),z5=Er(/^(?:\w+script|data):/i),$5=Er(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),yC=Er(/^html$/i),U5=Er(/^[a-z][.\w]*(-[.\w]+)+$/i);var ax=Object.freeze({__proto__:null,ARIA_ATTR:F5,ATTR_WHITESPACE:$5,CUSTOM_ELEMENT:U5,DATA_ATTR:L5,DOCTYPE_NAME:yC,ERB_EXPR:D5,IS_ALLOWED_URI:wC,IS_SCRIPT_OR_DATA:z5,MUSTACHE_EXPR:M5,TMPLIT_EXPR:O5});const Ci={element:1,text:3,progressingInstruction:7,comment:8,document:9},B5=function(){return typeof window>"u"?null:window},V5=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(r=n.getAttribute(s));const a="dompurify"+(r?"#"+r:"");try{return t.createPolicy(a,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},ix=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function bC(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:B5();const t=be=>bC(be);if(t.version="3.2.6",t.removed=[],!e||!e.document||e.document.nodeType!==Ci.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const r=n,s=r.currentScript,{DocumentFragment:a,HTMLTemplateElement:i,Node:l,Element:c,NodeFilter:u,NamedNodeMap:h=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:f,DOMParser:p,trustedTypes:m}=e,v=c.prototype,g=bi(v,"cloneNode"),x=bi(v,"remove"),w=bi(v,"nextSibling"),y=bi(v,"childNodes"),C=bi(v,"parentNode");if(typeof i=="function"){const be=n.createElement("template");be.content&&be.content.ownerDocument&&(n=be.content.ownerDocument)}let S,j="";const{implementation:I,createNodeIterator:b,createDocumentFragment:k,getElementsByTagName:N}=n,{importNode:A}=r;let P=ix();t.isSupported=typeof xC=="function"&&typeof C=="function"&&I&&I.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:E,ERB_EXPR:R,TMPLIT_EXPR:_,DATA_ATTR:M,ARIA_ATTR:L,IS_SCRIPT_OR_DATA:F,ATTR_WHITESPACE:D,CUSTOM_ELEMENT:O}=ax;let{IS_ALLOWED_URI:K}=ax,$=null;const W=It({},[...nx,...Ld,...Fd,...zd,...rx]);let V=null;const X=It({},[...sx,...$d,...ox,...rc]);let H=Object.seal(vC(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Q=null,z=null,Z=!0,J=!0,ce=!1,de=!0,fe=!1,ge=!0,T=!1,le=!1,ie=!1,q=!1,B=!1,ee=!1,U=!0,Y=!1;const G="user-content-";let ae=!0,oe=!1,se={},me=null;const Pe=It({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Ne=null;const dt=It({},["audio","video","img","source","image","track"]);let Ht=null;const wt=It({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ot="http://www.w3.org/1998/Math/MathML",gt="http://www.w3.org/2000/svg",Nt="http://www.w3.org/1999/xhtml";let Jt=Nt,Wt=!1,xe=null;const $e=It({},[Ot,gt,Nt],Od);let Me=It({},["mi","mo","mn","ms","mtext"]),Fe=It({},["annotation-xml"]);const ft=It({},["title","style","font","a","script"]);let He=null;const Ut=["application/xhtml+xml","text/html"],Qe="text/html";let St=null,Lt=null;const ln=n.createElement("form"),nn=function(ne){return ne instanceof RegExp||ne instanceof Function},On=function(){let ne=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Lt&&Lt===ne)){if((!ne||typeof ne!="object")&&(ne={}),ne=Ts(ne),He=Ut.indexOf(ne.PARSER_MEDIA_TYPE)===-1?Qe:ne.PARSER_MEDIA_TYPE,St=He==="application/xhtml+xml"?Od:_c,$=Fr(ne,"ALLOWED_TAGS")?It({},ne.ALLOWED_TAGS,St):W,V=Fr(ne,"ALLOWED_ATTR")?It({},ne.ALLOWED_ATTR,St):X,xe=Fr(ne,"ALLOWED_NAMESPACES")?It({},ne.ALLOWED_NAMESPACES,Od):$e,Ht=Fr(ne,"ADD_URI_SAFE_ATTR")?It(Ts(wt),ne.ADD_URI_SAFE_ATTR,St):wt,Ne=Fr(ne,"ADD_DATA_URI_TAGS")?It(Ts(dt),ne.ADD_DATA_URI_TAGS,St):dt,me=Fr(ne,"FORBID_CONTENTS")?It({},ne.FORBID_CONTENTS,St):Pe,Q=Fr(ne,"FORBID_TAGS")?It({},ne.FORBID_TAGS,St):Ts({}),z=Fr(ne,"FORBID_ATTR")?It({},ne.FORBID_ATTR,St):Ts({}),se=Fr(ne,"USE_PROFILES")?ne.USE_PROFILES:!1,Z=ne.ALLOW_ARIA_ATTR!==!1,J=ne.ALLOW_DATA_ATTR!==!1,ce=ne.ALLOW_UNKNOWN_PROTOCOLS||!1,de=ne.ALLOW_SELF_CLOSE_IN_ATTR!==!1,fe=ne.SAFE_FOR_TEMPLATES||!1,ge=ne.SAFE_FOR_XML!==!1,T=ne.WHOLE_DOCUMENT||!1,q=ne.RETURN_DOM||!1,B=ne.RETURN_DOM_FRAGMENT||!1,ee=ne.RETURN_TRUSTED_TYPE||!1,ie=ne.FORCE_BODY||!1,U=ne.SANITIZE_DOM!==!1,Y=ne.SANITIZE_NAMED_PROPS||!1,ae=ne.KEEP_CONTENT!==!1,oe=ne.IN_PLACE||!1,K=ne.ALLOWED_URI_REGEXP||wC,Jt=ne.NAMESPACE||Nt,Me=ne.MATHML_TEXT_INTEGRATION_POINTS||Me,Fe=ne.HTML_INTEGRATION_POINTS||Fe,H=ne.CUSTOM_ELEMENT_HANDLING||{},ne.CUSTOM_ELEMENT_HANDLING&&nn(ne.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(H.tagNameCheck=ne.CUSTOM_ELEMENT_HANDLING.tagNameCheck),ne.CUSTOM_ELEMENT_HANDLING&&nn(ne.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(H.attributeNameCheck=ne.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),ne.CUSTOM_ELEMENT_HANDLING&&typeof ne.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(H.allowCustomizedBuiltInElements=ne.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),fe&&(J=!1),B&&(q=!0),se&&($=It({},rx),V=[],se.html===!0&&(It($,nx),It(V,sx)),se.svg===!0&&(It($,Ld),It(V,$d),It(V,rc)),se.svgFilters===!0&&(It($,Fd),It(V,$d),It(V,rc)),se.mathMl===!0&&(It($,zd),It(V,ox),It(V,rc))),ne.ADD_TAGS&&($===W&&($=Ts($)),It($,ne.ADD_TAGS,St)),ne.ADD_ATTR&&(V===X&&(V=Ts(V)),It(V,ne.ADD_ATTR,St)),ne.ADD_URI_SAFE_ATTR&&It(Ht,ne.ADD_URI_SAFE_ATTR,St),ne.FORBID_CONTENTS&&(me===Pe&&(me=Ts(me)),It(me,ne.FORBID_CONTENTS,St)),ae&&($["#text"]=!0),T&&It($,["html","head","body"]),$.table&&(It($,["tbody"]),delete Q.tbody),ne.TRUSTED_TYPES_POLICY){if(typeof ne.TRUSTED_TYPES_POLICY.createHTML!="function")throw yi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof ne.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw yi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');S=ne.TRUSTED_TYPES_POLICY,j=S.createHTML("")}else S===void 0&&(S=V5(m,s)),S!==null&&typeof j=="string"&&(j=S.createHTML(""));Yn&&Yn(ne),Lt=ne}},Un=It({},[...Ld,...Fd,...R5]),Yt=It({},[...zd,...P5]),te=function(ne){let he=C(ne);(!he||!he.tagName)&&(he={namespaceURI:Jt,tagName:"template"});const we=_c(ne.tagName),Ve=_c(he.tagName);return xe[ne.namespaceURI]?ne.namespaceURI===gt?he.namespaceURI===Nt?we==="svg":he.namespaceURI===Ot?we==="svg"&&(Ve==="annotation-xml"||Me[Ve]):!!Un[we]:ne.namespaceURI===Ot?he.namespaceURI===Nt?we==="math":he.namespaceURI===gt?we==="math"&&Fe[Ve]:!!Yt[we]:ne.namespaceURI===Nt?he.namespaceURI===gt&&!Fe[Ve]||he.namespaceURI===Ot&&!Me[Ve]?!1:!Yt[we]&&(ft[we]||!Un[we]):!!(He==="application/xhtml+xml"&&xe[ne.namespaceURI]):!1},re=function(ne){vi(t.removed,{element:ne});try{C(ne).removeChild(ne)}catch{x(ne)}},ue=function(ne,he){try{vi(t.removed,{attribute:he.getAttributeNode(ne),from:he})}catch{vi(t.removed,{attribute:null,from:he})}if(he.removeAttribute(ne),ne==="is")if(q||B)try{re(he)}catch{}else try{he.setAttribute(ne,"")}catch{}},Ce=function(ne){let he=null,we=null;if(ie)ne="<remove></remove>"+ne;else{const ot=tx(ne,/^[\r\n\t ]+/);we=ot&&ot[0]}He==="application/xhtml+xml"&&Jt===Nt&&(ne='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+ne+"</body></html>");const Ve=S?S.createHTML(ne):ne;if(Jt===Nt)try{he=new p().parseFromString(Ve,He)}catch{}if(!he||!he.documentElement){he=I.createDocument(Jt,"template",null);try{he.documentElement.innerHTML=Wt?j:Ve}catch{}}const De=he.body||he.documentElement;return ne&&we&&De.insertBefore(n.createTextNode(we),De.childNodes[0]||null),Jt===Nt?N.call(he,T?"html":"body")[0]:T?he.documentElement:De},je=function(ne){return b.call(ne.ownerDocument||ne,ne,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Be=function(ne){return ne instanceof f&&(typeof ne.nodeName!="string"||typeof ne.textContent!="string"||typeof ne.removeChild!="function"||!(ne.attributes instanceof h)||typeof ne.removeAttribute!="function"||typeof ne.setAttribute!="function"||typeof ne.namespaceURI!="string"||typeof ne.insertBefore!="function"||typeof ne.hasChildNodes!="function")},qe=function(ne){return typeof l=="function"&&ne instanceof l};function Te(be,ne,he){nc(be,we=>{we.call(t,ne,he,Lt)})}const Se=function(ne){let he=null;if(Te(P.beforeSanitizeElements,ne,null),Be(ne))return re(ne),!0;const we=St(ne.nodeName);if(Te(P.uponSanitizeElement,ne,{tagName:we,allowedTags:$}),ge&&ne.hasChildNodes()&&!qe(ne.firstElementChild)&&Hn(/<[/\w!]/g,ne.innerHTML)&&Hn(/<[/\w!]/g,ne.textContent)||ne.nodeType===Ci.progressingInstruction||ge&&ne.nodeType===Ci.comment&&Hn(/<[/\w]/g,ne.data))return re(ne),!0;if(!$[we]||Q[we]){if(!Q[we]&&Le(we)&&(H.tagNameCheck instanceof RegExp&&Hn(H.tagNameCheck,we)||H.tagNameCheck instanceof Function&&H.tagNameCheck(we)))return!1;if(ae&&!me[we]){const Ve=C(ne)||ne.parentNode,De=y(ne)||ne.childNodes;if(De&&Ve){const ot=De.length;for(let _t=ot-1;_t>=0;--_t){const mt=g(De[_t],!0);mt.__removalCount=(ne.__removalCount||0)+1,Ve.insertBefore(mt,w(ne))}}}return re(ne),!0}return ne instanceof c&&!te(ne)||(we==="noscript"||we==="noembed"||we==="noframes")&&Hn(/<\/no(script|embed|frames)/i,ne.innerHTML)?(re(ne),!0):(fe&&ne.nodeType===Ci.text&&(he=ne.textContent,nc([E,R,_],Ve=>{he=wi(he,Ve," ")}),ne.textContent!==he&&(vi(t.removed,{element:ne.cloneNode()}),ne.textContent=he)),Te(P.afterSanitizeElements,ne,null),!1)},Ee=function(ne,he,we){if(U&&(he==="id"||he==="name")&&(we in n||we in ln))return!1;if(!(J&&!z[he]&&Hn(M,he))){if(!(Z&&Hn(L,he))){if(!V[he]||z[he]){if(!(Le(ne)&&(H.tagNameCheck instanceof RegExp&&Hn(H.tagNameCheck,ne)||H.tagNameCheck instanceof Function&&H.tagNameCheck(ne))&&(H.attributeNameCheck instanceof RegExp&&Hn(H.attributeNameCheck,he)||H.attributeNameCheck instanceof Function&&H.attributeNameCheck(he))||he==="is"&&H.allowCustomizedBuiltInElements&&(H.tagNameCheck instanceof RegExp&&Hn(H.tagNameCheck,we)||H.tagNameCheck instanceof Function&&H.tagNameCheck(we))))return!1}else if(!Ht[he]){if(!Hn(K,wi(we,D,""))){if(!((he==="src"||he==="xlink:href"||he==="href")&&ne!=="script"&&N5(we,"data:")===0&&Ne[ne])){if(!(ce&&!Hn(F,wi(we,D,"")))){if(we)return!1}}}}}}return!0},Le=function(ne){return ne!=="annotation-xml"&&tx(ne,O)},_e=function(ne){Te(P.beforeSanitizeAttributes,ne,null);const{attributes:he}=ne;if(!he||Be(ne))return;const we={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:V,forceKeepAttr:void 0};let Ve=he.length;for(;Ve--;){const De=he[Ve],{name:ot,namespaceURI:_t,value:mt}=De,vt=St(ot),En=mt;let Bt=ot==="value"?En:T5(En);if(we.attrName=vt,we.attrValue=Bt,we.keepAttr=!0,we.forceKeepAttr=void 0,Te(P.uponSanitizeAttribute,ne,we),Bt=we.attrValue,Y&&(vt==="id"||vt==="name")&&(ue(ot,ne),Bt=G+Bt),ge&&Hn(/((--!?|])>)|<\/(style|title)/i,Bt)){ue(ot,ne);continue}if(we.forceKeepAttr)continue;if(!we.keepAttr){ue(ot,ne);continue}if(!de&&Hn(/\/>/i,Bt)){ue(ot,ne);continue}fe&&nc([E,R,_],gr=>{Bt=wi(Bt,gr," ")});const Bn=St(ne.nodeName);if(!Ee(Bn,vt,Bt)){ue(ot,ne);continue}if(S&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!_t)switch(m.getAttributeType(Bn,vt)){case"TrustedHTML":{Bt=S.createHTML(Bt);break}case"TrustedScriptURL":{Bt=S.createScriptURL(Bt);break}}if(Bt!==En)try{_t?ne.setAttributeNS(_t,ot,Bt):ne.setAttribute(ot,Bt),Be(ne)?re(ne):ex(t.removed)}catch{ue(ot,ne)}}Te(P.afterSanitizeAttributes,ne,null)},et=function be(ne){let he=null;const we=je(ne);for(Te(P.beforeSanitizeShadowDOM,ne,null);he=we.nextNode();)Te(P.uponSanitizeShadowNode,he,null),Se(he),_e(he),he.content instanceof a&&be(he.content);Te(P.afterSanitizeShadowDOM,ne,null)};return t.sanitize=function(be){let ne=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},he=null,we=null,Ve=null,De=null;if(Wt=!be,Wt&&(be="<!-->"),typeof be!="string"&&!qe(be))if(typeof be.toString=="function"){if(be=be.toString(),typeof be!="string")throw yi("dirty is not a string, aborting")}else throw yi("toString is not a function");if(!t.isSupported)return be;if(le||On(ne),t.removed=[],typeof be=="string"&&(oe=!1),oe){if(be.nodeName){const mt=St(be.nodeName);if(!$[mt]||Q[mt])throw yi("root node is forbidden and cannot be sanitized in-place")}}else if(be instanceof l)he=Ce("<!---->"),we=he.ownerDocument.importNode(be,!0),we.nodeType===Ci.element&&we.nodeName==="BODY"||we.nodeName==="HTML"?he=we:he.appendChild(we);else{if(!q&&!fe&&!T&&be.indexOf("<")===-1)return S&&ee?S.createHTML(be):be;if(he=Ce(be),!he)return q?null:ee?j:""}he&&ie&&re(he.firstChild);const ot=je(oe?be:he);for(;Ve=ot.nextNode();)Se(Ve),_e(Ve),Ve.content instanceof a&&et(Ve.content);if(oe)return be;if(q){if(B)for(De=k.call(he.ownerDocument);he.firstChild;)De.appendChild(he.firstChild);else De=he;return(V.shadowroot||V.shadowrootmode)&&(De=A.call(r,De,!0)),De}let _t=T?he.outerHTML:he.innerHTML;return T&&$["!doctype"]&&he.ownerDocument&&he.ownerDocument.doctype&&he.ownerDocument.doctype.name&&Hn(yC,he.ownerDocument.doctype.name)&&(_t="<!DOCTYPE "+he.ownerDocument.doctype.name+`>
|
|
143
|
+
`+_t),fe&&nc([E,R,_],mt=>{_t=wi(_t,mt," ")}),S&&ee?S.createHTML(_t):_t},t.setConfig=function(){let be=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};On(be),le=!0},t.clearConfig=function(){Lt=null,le=!1},t.isValidAttribute=function(be,ne,he){Lt||On({});const we=St(be),Ve=St(ne);return Ee(we,Ve,he)},t.addHook=function(be,ne){typeof ne=="function"&&vi(P[be],ne)},t.removeHook=function(be,ne){if(ne!==void 0){const he=j5(P[be],ne);return he===-1?void 0:E5(P[be],he,1)[0]}return ex(P[be])},t.removeHooks=function(be){P[be]=[]},t.removeAllHooks=function(){P=ix()},t}var Pm=bC();const H5=({code:e,language:t})=>{const[n,r]=d.useState(!1),s=d.useCallback(()=>{navigator.clipboard.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),2e3)}).catch(a=>{console.error("Failed to copy code:",a)})},[e]);return o.jsxs("div",{className:"group relative",children:[o.jsx("pre",{className:"border-border mb-4 max-w-full overflow-x-auto rounded-lg border bg-transparent p-4 whitespace-pre-wrap",children:o.jsx("code",{className:`bg-transparent p-0 text-sm break-words ${t?`language-${t}`:""}`,children:e})}),o.jsx(ye,{variant:"ghost",size:"icon",className:"bg-background/80 hover:bg-background absolute top-2 right-2 h-8 w-8 opacity-0 transition-opacity group-hover:opacity-100",onClick:s,tooltip:n?"Copied!":"Copy code",children:n?o.jsx(ni,{className:"h-4 w-4 text-[var(--color-success-wMain)]"}):o.jsx(Nv,{className:"h-4 w-4"})})]})};function Rs({children:e,className:t}){if(!e)return null;const n={replace:r=>{var s;if(r instanceof jc.Element&&r.attribs&&(r.name==="a"&&(r.attribs.target="_blank",r.attribs.rel="noopener noreferrer"),r.name==="pre")){const a=r.children.find(i=>i instanceof jc.Element&&i.name==="code");if(a){const i=a.children.map(h=>"data"in h?h.data:"").join(""),c=(((s=a.attribs)==null?void 0:s.class)||"").match(/language-(\w+)/),u=c?c[1]:void 0;return o.jsx(H5,{code:i,language:u})}}}};try{const r=jv.parse(e,{gfm:!0}),s=Pm.sanitize(r,{USE_PROFILES:{html:!0}}),a=Ev(s,n);return o.jsx("div",{className:Dc(t),children:a})}catch{return o.jsx("div",{className:Dc(t),children:e})}}const CC=({content:e,className:t})=>{const{state:n,contentRef:r}=vP(e),s=oP(n,r);return o.jsx(Rs,{className:t,children:s})},Gf=({content:e,isStreaming:t,className:n})=>t?o.jsx(CC,{content:e,className:n}):o.jsx(Rs,{className:n,children:e}),W5={error:"bg-[var(--color-error-w20)] text-[var(--color-error-wMain)] border-[var(--color-error-wMain)] dark:bg-[var(--color-error-w100)]/60 dark:text-[var(--color-white)] dark:border-[var(--color-error-wMain)]",warning:"bg-[var(--color-warning-w10)] text-[var(--color-warning-wMain)] border-[var(--color-warning-wMain)] dark:bg-[var(--color-warning-w100)]/60 dark:text-[var(--color-white)] dark:border-[var(--color-warning-wMain)]",info:"bg-[var(--color-info-w20)] text-[var(--color-info-wMain)] border-[var(--color-info-wMain)] dark:bg-[var(--color-info-w100)]/60 dark:text-[var(--color-white)] dark:border-[var(--color-info-wMain)]",success:"bg-[var(--color-success-w20)] text-[var(--color-success-wMain)] border-[var(--color-success-w40)] dark:bg-[var(--color-success-w100)]/60 dark:text-[var(--color-white)] dark:border-l-[var(--color-success-w70)]"},Z5=Co("flex items-center gap-3 px-4 py-3 text-sm font-medium transition-all border-l-4 border-solid ",{variants:{variant:W5},defaultVariants:{variant:"error"}}),G5={error:io,warning:mh,info:ll,success:lu};function Xt({className:e,variant:t="error",message:n,icon:r,dismissible:s=!1,onDismiss:a,...i}){const l=G5[t||"error"];return o.jsxs("div",{"data-testid":"messageBanner",className:Ue(Z5({variant:t,className:e}),"items-start"),role:"alert","aria-live":"polite",...i,children:[r||o.jsx(l,{className:"size-5 shrink-0"}),typeof n=="string"?o.jsx("span",{children:n}):n,o.jsx("div",{className:"ml-auto flex items-center gap-1",children:s&&a&&o.jsx(ye,{variant:"link",className:"h-min self-center p-0",onClick:a,"aria-label":"Dismiss",children:o.jsx(Kr,{className:"size-3"})})})]})}const q5=({fileName:e,onRemove:t})=>o.jsxs(go,{className:"bg-muted max-w-50 gap-1.5 rounded-full pr-1",children:[o.jsx("span",{className:"min-w-0 flex-1 truncate text-xs md:text-sm",title:e,children:e}),t&&o.jsx(ye,{variant:"ghost",size:"icon",onClick:t,className:"h-2 min-h-0 w-2 min-w-0 p-2",title:"Remove file",children:o.jsx(Kr,{})})]}),Mm=({group:e,onSubmit:t,onClose:n})=>{var f;const r=((f=e.productionPrompt)==null?void 0:f.promptText)||"",s=Va(r),[a,i]=d.useState(()=>{const p={};return s.forEach(m=>{p[m]=""}),p}),[l,c]=d.useState(!1),u=d.useRef(null),h=p=>{if(p.preventDefault(),!s.every(g=>{var x;return(x=a[g])==null?void 0:x.trim()})){c(!0),setTimeout(()=>c(!1),3e3);return}const v=F2(r,a);t(v)};return d.useEffect(()=>{u.current&&u.current.focus()},[]),d.useEffect(()=>{const p=m=>{m.key==="Escape"&&n()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[n]),o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",children:o.jsxs("div",{className:"flex max-h-[80vh] w-full max-w-lg flex-col rounded-lg border border-[var(--border)] bg-[var(--background)] shadow-lg",children:[o.jsxs("div",{className:"flex-shrink-0 p-6 pb-4",children:[o.jsxs("h2",{className:"text-lg font-semibold",children:["Insert ",e.name]}),o.jsx("p",{className:"mt-1 text-sm text-[var(--muted-foreground)]",children:"Variables represent placeholder information in the template. Enter a value for each placeholder below."})]}),l&&o.jsx("div",{className:"flex-shrink-0 px-6",children:o.jsx(Xt,{variant:"error",message:"Please fill in all variables before inserting the prompt"})}),o.jsxs("form",{onSubmit:h,className:"flex min-h-0 flex-1 flex-col",children:[o.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:o.jsx("div",{className:"space-y-4",children:s.map((p,m)=>o.jsxs("div",{children:[o.jsx("label",{htmlFor:`var-${p}`,className:"mb-1 block text-sm font-medium",children:p}),o.jsx("textarea",{id:`var-${p}`,ref:m===0?u:null,value:a[p],onChange:v=>i(g=>({...g,[p]:v.target.value})),className:"min-h-[80px] w-full rounded-md border border-[var(--border)] bg-[var(--background)] p-2 text-sm focus:ring-2 focus:ring-[var(--primary)] focus:outline-none",required:!0})]},p))})}),o.jsxs("div",{className:"flex flex-shrink-0 justify-end gap-2 border-t border-[var(--border)] p-6 pt-4",children:[o.jsx(ye,{type:"button",variant:"ghost",onClick:n,children:"Cancel"}),o.jsx(ye,{type:"submit",children:"Insert Prompt"})]})]})]})})},lx=[{command:"create-template",name:"Create Template from Session",description:"Create a reusable prompt template from this conversation",icon:Bo}],Y5=({isOpen:e,onClose:t,textAreaRef:n,onPromptSelect:r,messages:s=[],onReservedCommand:a})=>{const i=bo(),[l,c]=d.useState(""),[u,h]=d.useState(0),[f,p]=d.useState([]),[m,v]=d.useState(!1),[g,x]=d.useState(null),[w,y]=d.useState(!1),[C,S]=d.useState(!1),j=d.useRef(null),I=d.useRef(null),b=d.useRef(null);d.useEffect(()=>{if(!e)return;(async()=>{v(!0);try{const O=await Ie.webui.get("/api/v1/prompts/groups/all");p(O)}catch(O){console.error("Failed to fetch prompt groups:",O)}finally{v(!1)}})()},[e]);const k=d.useMemo(()=>{const D=s.some(O=>O.isUser&&!O.isStatusBubble);return lx.filter(O=>O.command==="create-template"?D:!0)},[s]),N=d.useMemo(()=>{if(!l)return f;const D=l.toLowerCase();return f.filter(O=>{var K,$,W;return O.name.toLowerCase().includes(D)||((K=O.description)==null?void 0:K.toLowerCase().includes(D))||(($=O.command)==null?void 0:$.toLowerCase().includes(D))||((W=O.category)==null?void 0:W.toLowerCase().includes(D))})},[f,l]),A=d.useMemo(()=>[...N,...k],[N,k]),P=d.useCallback(D=>D.filter(O=>!O.isStatusBubble&&!O.isError&&!O.authenticationLink).map(O=>{var W;const K=O.isUser?"User":"Assistant",$=((W=O.parts)==null?void 0:W.filter(V=>V.kind==="text").map(V=>V.text).join(""))||"";return`${K}: ${$}`}).join(`
|
|
144
|
+
|
|
145
|
+
`),[]),E=d.useCallback(D=>{if(D.command==="create-template"&&a){const O=P(s);a(D.command,O),t(),c("")}},[s,P,a,t]),R=d.useCallback(()=>{t(),c(""),i("/prompts/new?mode=ai-assisted")},[t,i]),_=d.useCallback(D=>{var W;const O=((W=D.productionPrompt)==null?void 0:W.promptText)||"";Va(O).length>0?(x(D),y(!0)):(r(O),t(),c(""))},[r,t]),M=d.useCallback(D=>{"command"in D&&lx.some(O=>O.command===D.command)?E(D):_(D)},[E,_]),L=d.useCallback(D=>{r(D),y(!1),x(null),t(),c("")},[r,t]),F=d.useCallback(D=>{var O,K;D.key==="Escape"?(D.preventDefault(),D.stopPropagation(),t(),c(""),(O=n.current)==null||O.focus()):D.key==="ArrowDown"?(D.preventDefault(),S(!0),h($=>Math.min($+1,A.length-1))):D.key==="ArrowUp"?(D.preventDefault(),S(!0),h($=>Math.max($-1,0))):D.key==="Enter"||D.key==="Tab"?(D.preventDefault(),A[u]&&M(A[u])):D.key==="Backspace"&&l===""&&(t(),(K=n.current)==null||K.focus())},[A,u,l,M,t,n]);return d.useEffect(()=>{e&&j.current&&j.current.focus()},[e]),d.useEffect(()=>{h(0)},[l]),d.useEffect(()=>{const D=document.getElementById(`prompt-item-${u}`);D&&D.scrollIntoView({behavior:"smooth",block:"nearest"})},[u]),e?o.jsxs(o.Fragment,{children:[o.jsx("div",{ref:b,className:"fixed inset-0 z-40 bg-black/20",onClick:t}),o.jsx("div",{"data-testid":"promptCommand",className:"fixed top-1/3 left-1/2 z-50 w-full max-w-[672px] -translate-x-1/2 px-4",children:o.jsxs("div",{ref:I,className:"flex flex-col rounded-lg border border-[var(--border)] bg-[var(--background)] shadow-lg",style:{maxHeight:"60vh"},children:[o.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--border)] p-3",children:[o.jsx(co,{className:"size-4 text-[var(--muted-foreground)]"}),o.jsx("input",{ref:j,type:"text",value:l,onChange:D=>c(D.target.value),onKeyDown:F,placeholder:"Search by shortcut or name...",className:"flex-1 bg-transparent text-sm outline-none placeholder:text-[var(--muted-foreground)]"})]}),o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:m?o.jsx("div",{className:"flex items-center justify-center p-8",children:o.jsx("div",{className:"size-6 animate-spin rounded-full border-2 border-[var(--primary)] border-t-transparent"})}):A.length===0?o.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-8 text-center",children:[o.jsx("p",{className:"text-sm text-[var(--muted-foreground)]",children:l?"No prompts found":"No prompts available."}),!l&&o.jsxs("button",{onClick:R,className:"inline-flex items-center gap-2 rounded-md bg-[var(--primary)] px-4 py-2 text-sm font-medium text-[var(--primary-foreground)] transition-colors hover:bg-[var(--primary)]/90",children:[o.jsx(Vo,{className:"size-4"}),"Create Prompt"]})]}):o.jsxs("div",{className:"flex flex-col p-2",children:[N.map((D,O)=>o.jsx("button",{id:`prompt-item-${O}`,onClick:()=>_(D),onMouseEnter:()=>{S(!1),h(O)},className:`w-full rounded-md p-3 text-left transition-colors ${O===u?"bg-[var(--accent)]":C?"":"hover:bg-[var(--accent)]"}`,children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(Bo,{className:"mt-0.5 size-4 flex-shrink-0 text-[var(--muted-foreground)]"}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[D.command&&o.jsxs("span",{className:"font-mono text-xs text-[var(--primary)]",children:["/",D.command]}),o.jsx("span",{className:"text-sm font-medium",children:D.name}),D.category&&o.jsx("span",{className:"rounded bg-[var(--muted)] px-1.5 py-0.5 text-xs text-[var(--muted-foreground)]",children:D.category})]}),D.description&&o.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--muted-foreground)]",children:D.description})]})]})},D.id)),k.length>0&&o.jsxs(o.Fragment,{children:[N.length>0&&o.jsx("div",{className:"my-2 border-t border-[var(--border)]"}),k.map((D,O)=>{const K=N.length+O,$=D.icon;return o.jsx("button",{id:`prompt-item-${K}`,onClick:()=>E(D),onMouseEnter:()=>{S(!1),h(K)},className:`w-full rounded-md p-3 text-left transition-colors ${K===u?"bg-[var(--accent)]":C?"":"hover:bg-[var(--accent)]"}`,children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx($,{className:"mt-0.5 size-4 flex-shrink-0 text-[var(--primary)]"}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsxs("span",{className:"font-mono text-xs text-[var(--primary)]",children:["/",D.command]}),o.jsx("span",{className:"text-sm font-medium",children:D.name}),o.jsx("span",{className:"rounded bg-[var(--primary)]/10 px-1.5 py-0.5 text-xs text-[var(--primary)]",children:"Reserved"})]}),o.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--muted-foreground)]",children:D.description})]})]})},`reserved-${D.command}`)})]})]})})]})}),w&&g&&o.jsx(Mm,{group:g,onSubmit:L,onClose:()=>{y(!1),x(null)}})]}):null},K5=({content:e,onClick:t,onRemove:n,isConfigured:r,filename:s,defaultFilename:a})=>{const l=(u=>u.split(`
|
|
146
|
+
`).slice(0,2).map(f=>{const p=f.trim();return p.length>40?p.substring(0,37)+"...":p}))(e),c=r?`Click to edit: ${s}`:"Click to customize file settings";return o.jsxs(zs,{children:[o.jsx($s,{asChild:!0,children:o.jsxs("div",{className:`bg-background relative inline-flex max-w-[200px] cursor-pointer flex-col rounded-lg border shadow-sm transition-colors ${r?"border-[var(--color-info-wMain)]/50 hover:border-[var(--color-info-wMain)]":"border-border hover:border-primary/50"}`,onClick:t,children:[o.jsx(ye,{variant:"ghost",size:"icon",onClick:u=>{u.stopPropagation(),n()},className:"bg-background border-border hover:bg-muted absolute -top-2 -left-2 h-5 w-5 rounded-full border p-0 shadow-sm",tooltip:"Remove pasted text",tooltipSide:"left",children:o.jsx(Kr,{className:"h-3 w-3"})}),o.jsxs("div",{className:"text-muted-foreground overflow-hidden px-3 pt-3 pb-2 font-mono text-xs leading-relaxed",children:[l.map((u,h)=>o.jsx("div",{className:"truncate",children:u||" "},h)),e.split(`
|
|
147
|
+
`).length>2&&o.jsx("div",{className:"text-muted-foreground/60",children:"..."})]}),o.jsx("div",{className:"flex items-center gap-1 px-2 pb-2",children:r?o.jsxs("span",{className:"inline-flex max-w-[170px] items-center gap-1.5 truncate rounded bg-[var(--color-info-w10)] px-2 py-0.5 text-[10px] font-semibold tracking-wider text-[var(--color-info-wMain)] dark:bg-[var(--color-info-wMain)] dark:text-[var(--color-primary-text-w10)]",children:[s||"CONFIGURED",o.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full bg-[var(--color-info-wMain)] dark:bg-[var(--color-primary-text-w10)]"})]}):o.jsx("span",{className:"bg-muted text-muted-foreground inline-block max-w-[170px] truncate rounded px-2 py-0.5 text-[10px] font-semibold tracking-wider",children:a||"snippet.txt"})})]})}),o.jsx(Us,{side:"top",children:o.jsx("p",{children:c})})]})},X5=e=>{const t=e.length,n=e.split(`
|
|
148
|
+
`).length;return t>=2e3||n>=50},J5=e=>{const t=e.length,n=e.split(`
|
|
149
|
+
`).length,r=e.substring(0,50).replace(/\n/g," ").trim(),s=r.length<e.length?`${r}...`:r;return`Pasted text (${t} chars, ${n} lines): ${s}`},Q5=e=>({id:`paste-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,content:e,timestamp:Date.now()}),eD=[{value:"text/plain",label:"Plain Text"},{value:"text/markdown",label:"Markdown"},{value:"text/csv",label:"CSV"},{value:"application/json",label:"JSON"},{value:"text/html",label:"HTML"},{value:"text/css",label:"CSS"},{value:"text/javascript",label:"JavaScript"},{value:"text/typescript",label:"TypeScript"},{value:"text/python",label:"Python"},{value:"text/yaml",label:"YAML"},{value:"text/xml",label:"XML"}],tD=e=>({"text/plain":"txt","text/markdown":"md","text/csv":"csv","application/json":"json","text/html":"html","text/css":"css","text/javascript":"js","text/typescript":"ts","text/python":"py","text/yaml":"yaml","text/xml":"xml"})[e]||"txt",nD=(e,t,n)=>{const r=`${e}.${t}`;if(!n.includes(r))return r;let s=2;for(;n.includes(`${e}-${s}.${t}`);)s++;return`${e}-${s}.${t}`},sc="text/plain",rD=({isOpen:e,content:t,onSaveMetadata:n,onCancel:r,existingArtifacts:s=[],initialFilename:a,initialMimeType:i,initialDescription:l,defaultFilename:c})=>{const[u,h]=d.useState("snippet.txt"),[f,p]=d.useState(""),[m,v]=d.useState(sc),[g,x]=d.useState(""),[w,y]=d.useState(null),S=s.includes(u)&&u!==a;d.useEffect(()=>{if(e&&t)if(x(t),a)h(a),v(i||sc),p(l||"");else{v(sc);const A=c||nD("snippet","txt",s);h(A);const P=J5(t);p(P)}},[e,t,s,a,i,l,c]),d.useEffect(()=>{const A=tD(m);if(u.match(/^snippet(-\d+)?\.[\w]+$/)){const P=u.match(/^(snippet(-\d+)?)\./),R=`${P?P[1]:"snippet"}.${A}`;R!==u&&h(R)}},[m,u]);const j=()=>{if(!g.trim()){y("Content cannot be empty. Please add some content before saving.");return}y(null),n({filename:u,mimeType:m,description:f.trim()||void 0,content:g}),b()},I=()=>{b(),r()},b=()=>{h("snippet.txt"),p(""),v(sc),x(""),y(null)},k=g.length,N=g.split(`
|
|
150
|
+
`).length;return o.jsx(Nr,{open:e,onOpenChange:I,children:o.jsxs(Tr,{className:"flex max-h-[80vh] flex-col sm:max-w-2xl",children:[o.jsxs(rs,{children:[o.jsx(Ar,{children:"Customize File"}),o.jsx(Ir,{children:"Customize the file settings before sending to the agent"})]}),o.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto py-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(zt,{htmlFor:"title",children:"Filename"}),o.jsx(_r,{id:"title",value:u,onChange:A=>h(A.target.value),placeholder:"snippet.txt",autoFocus:!1,onFocus:A=>{setTimeout(()=>{A.target.setSelectionRange(A.target.value.length,A.target.value.length)},0)}}),S&&o.jsx(Xt,{variant:"warning",message:"A file with this name already exists. Saving will create a new version."})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(zt,{htmlFor:"description",children:"Description (optional)"}),o.jsx(_r,{id:"description",value:f,onChange:A=>p(A.target.value),placeholder:"Brief description of this file"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(zt,{htmlFor:"type",children:"Type"}),o.jsxs(Wr,{value:m,onValueChange:v,children:[o.jsx(Gr,{id:"type",children:o.jsx(Zr,{})}),o.jsx(qr,{children:eD.map(A=>o.jsx(Pt,{value:A.value,children:A.label},A.value))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(zt,{htmlFor:"content",children:"Content"}),o.jsx(ts,{id:"content",value:g,onChange:A=>{x(A.target.value),A.target.value.trim()&&w&&y(null)},className:"min-h-[300px] resize-y font-mono text-sm",placeholder:"Paste content here..."}),o.jsxs("p",{className:"text-muted-foreground text-xs",children:[k," characters, ",N," lines"]}),w&&o.jsx(Xt,{variant:"error",message:w,dismissible:!0,onDismiss:()=>y(null)})]})]}),o.jsxs(Cs,{children:[o.jsx(ye,{variant:"ghost",onClick:I,children:"Cancel"}),o.jsx(ye,{onClick:j,disabled:!u.trim(),children:"Customize"})]})]})})},sD=(e,t)=>{switch(e){case"create-template":return t?["I want to create a reusable prompt template based on this conversation I just had:","","<conversation_history>",t,"</conversation_history>","","Please help me create a prompt template by:","","1. **Analyzing the Pattern**: Identify the core task/question pattern in this conversation","2. **Extracting Variables**: Determine which parts should be variables (use {{variable_name}} syntax)","3. **Generalizing**: Make it reusable for similar tasks","4. **Suggesting Metadata**: Recommend a name, description, category, and chat shortcut","","Focus on capturing what made this conversation successful so it can be reused with different inputs."].join(`
|
|
151
|
+
`):"Help me create a new prompt template.";default:return""}},oD=({agents:e=[],scrollToBottom:t})=>{const n=bo(),r=es(),{isResponding:s,isCancelling:a,selectedAgentName:i,sessionId:l,setSessionId:c,handleSubmit:u,handleCancel:h,uploadArtifactFile:f,displayError:p,artifacts:m,messages:v,startNewChatWithPrompt:g,pendingPrompt:x,clearPendingPrompt:w}=$t(),{handleAgentSelection:y}=CP(),{settings:C}=So(),{configFeatureEnablement:S}=on(),j=(S==null?void 0:S.speechToText)??!0,I=d.useRef(null),[b,k]=d.useState([]),[N,A]=d.useState([]),[P,E]=d.useState(null),[R,_]=d.useState(!1),[M,L]=d.useState(null),[F,D]=d.useState(!1),O=d.useRef(null),K=d.useRef(s),[$,W]=d.useState(""),[V,X]=d.useState(!1),[H,Q]=d.useState(!1),[z,Z]=d.useState(null),[J,ce]=d.useState(null),[de,fe]=d.useState(!1),ge=d.useRef(l),T=d.useRef(null);d.useEffect(()=>{var xe;if((xe=r.state)!=null&&xe.promptText&&T.current!==r.state.groupId){const{promptText:$e,groupId:Me,groupName:Fe}=r.state;T.current=Me,n(r.pathname,{replace:!0,state:{}}),g({promptText:$e,groupId:Me,groupName:Fe}),setTimeout(()=>{T.current=null},1e3)}},[r.state,r.pathname,n,g]),d.useEffect(()=>{if(x&&i){const{promptText:xe,groupId:$e,groupName:Me}=x;Va(xe).length>0?(Z({id:$e,name:Me,productionPrompt:{promptText:xe}}),Q(!0)):(W(xe),setTimeout(()=>{var ft;(ft=O.current)==null||ft.focus()},100)),w()}},[x,i,w]),d.useEffect(()=>{if(x){ge.current=l;return}ge.current&&ge.current!==l&&(W(""),X(!1),A([])),ge.current=l,L(null)},[x,l]),d.useEffect(()=>{K.current&&!s&&setTimeout(()=>{var xe;(xe=O.current)==null||xe.focus()},100),K.current=s},[s]),d.useEffect(()=>{const xe=()=>{setTimeout(()=>{var $e;($e=O.current)==null||$e.focus()},100)};return window.addEventListener("focus-chat-input",xe),()=>{window.removeEventListener("focus-chat-input",xe)}},[]),d.useEffect(()=>{const xe=async $e=>{const Me=$e,{text:Fe,prompt:ft,autoSubmit:He}=Me.detail;if(ft){if(L(Fe),W(ft+" "),He){setTimeout(async()=>{const Ut=`${ft}
|
|
152
|
+
|
|
153
|
+
Context: "${Fe}"`,Qe=new Event("submit");await u(Qe,[],Ut),L(null),D(!1),W(""),t==null||t()},50);return}}else L(Fe),D(!0);setTimeout(()=>{var Ut;(Ut=O.current)==null||Ut.focus()},100)};return window.addEventListener("follow-up-question",xe),()=>{window.removeEventListener("follow-up-question",xe)}},[u,t]);const le=()=>{var xe;s||(xe=I.current)==null||xe.click()},ie=xe=>{const $e=xe.target.files;if($e){const Me=Array.from($e).filter(Fe=>!b.some(ft=>ft.name===Fe.name&&ft.size===Fe.size&&ft.lastModified===Fe.lastModified));Me.length>0&&k(Fe=>[...Fe,...Me])}xe.target&&(xe.target.value=""),setTimeout(()=>{var Me;(Me=O.current)==null||Me.focus()},100)},q=async xe=>{if(s)return;const $e=xe.clipboardData;if(!$e)return;if($e.files&&$e.files.length>0){xe.preventDefault();const Fe=Array.from($e.files).filter(ft=>!b.some(He=>He.name===ft.name&&He.size===ft.size&&He.lastModified===ft.lastModified));Fe.length>0&&k(ft=>[...ft,...Fe]);return}const Me=$e.getData("text");if(Me&&X5(Me)){xe.preventDefault();const Fe=Q5(Me);A(ft=>[...ft,Fe])}},B=xe=>{P&&(A($e=>$e.map(Me=>Me.id===P?{...Me,content:xe.content,filename:xe.filename,mimeType:xe.mimeType,description:xe.description,isConfigured:!0}:Me)),E(null),_(!1))},ee=()=>{E(null),_(!1)},U=xe=>{E(xe),_(!0)},Y=xe=>{A($e=>$e.filter(Me=>Me.id!==xe))},G=xe=>{k($e=>$e.filter((Me,Fe)=>Fe!==xe))},ae=d.useMemo(()=>!s&&(($==null?void 0:$.trim())||b.length!==0||N.length!==0),[s,$,b,N]),oe=async xe=>{if(xe.preventDefault(),ae){let $e=$.trim();M&&F&&($e=`Context: "${M}"
|
|
154
|
+
|
|
155
|
+
${$e}`);const Me=[];let Fe=l;const ft=new Set(m.map(Qe=>Qe.filename));for(let Qe=0;Qe<N.length;Qe++){const St=N[Qe];try{let Lt,ln,nn;if(St.isConfigured&&St.filename&&St.mimeType)Lt=St.filename,ln=St.mimeType,nn=St.description;else{ln="text/plain";const te="txt";if(Lt=`snippet.${te}`,ft.has(Lt)){let re=2;for(;ft.has(`snippet-${re}.${te}`);)re++;Lt=`snippet-${re}.${te}`}}ft.add(Lt);const On=new Blob([St.content],{type:ln}),Un=new File([On],Lt,{type:ln}),Yt=await f(Un,Fe,nn,!0);if(Yt&&!("error"in Yt))Yt.sessionId&&Yt.sessionId!==Fe&&(Fe=Yt.sessionId,c(Yt.sessionId)),Me.push({uri:Yt.uri,filename:Lt,mimeType:ln});else{const te=Yt&&"error"in Yt?Yt.error:"An unknown upload error occurred.";throw new Error(te)}}catch(Lt){p({title:"Failed to Save Pasted Text",error:Zt(Lt)})}}const He=Me.map(Qe=>{const St=JSON.stringify({isArtifactReference:!0,uri:Qe.uri,filename:Qe.filename,mimeType:Qe.mimeType}),Lt=new Blob([St],{type:"application/x-artifact-reference"});return new File([Lt],Qe.filename,{type:"application/x-artifact-reference"})}),Ut=[...b,...He];await u(xe,Ut,$e,Fe||null),k([]),A([]),W(""),L(null),D(!1),t==null||t()}},se=xe=>{if(s)return;const $e=xe.filter(Me=>!b.some(Fe=>Fe.name===Me.name&&Fe.size===Me.size&&Fe.lastModified===Me.lastModified));$e.length>0&&k(Me=>[...Me,...$e])},{isDragging:me,handleDragEnter:Pe,handleDragOver:Ne,handleDragLeave:dt,handleDrop:Ht}=QR({onFilesDropped:se,disabled:s}),wt=xe=>{const $e=xe.target.value;W($e);const Me=xe.target.selectionStart,Fe=$e.substring(0,Me),ft=Fe[Fe.length-1],He=Fe[Fe.length-2];ft==="/"&&(!He||He===" "||He===`
|
|
156
|
+
`)?X(!0):V&&!Fe.includes("/")&&X(!1)},Ot=xe=>{var Ut;const $e=((Ut=O.current)==null?void 0:Ut.selectionStart)||0,Me=$.substring(0,$e),Fe=$.substring($e),ft=Me.lastIndexOf("/"),He=Me.substring(0,ft)+xe+Fe;W(He),X(!1),setTimeout(()=>{var Qe;(Qe=O.current)==null||Qe.focus()},100)},gt=(xe,$e)=>{const Me=sD(xe,$e);switch(xe){case"create-template":{n("/prompts/new?mode=ai-assisted",{state:{taskDescription:Me}}),W(""),X(!1);break}}},Nt=xe=>{W(xe),Q(!1),Z(null),setTimeout(()=>{var $e;($e=O.current)==null||$e.focus()},100)},Jt=d.useCallback(xe=>{const $e=$?`${$} ${xe}`:xe;W($e),setTimeout(()=>{var Me;(Me=O.current)==null||Me.focus()},100)},[$]),Wt=d.useCallback(xe=>{ce(xe)},[]);return o.jsxs("div",{className:`bg-card rounded-lg border p-4 shadow-sm ${me?"border-dotted border-[var(--primary-wMain)] bg-[var(--accent-background)]":""}`,onDragEnter:Pe,onDragOver:Ne,onDragLeave:dt,onDrop:Ht,children:[J&&o.jsx("div",{className:"mb-3",children:o.jsx(Xt,{variant:"error",message:J,dismissible:!0,onDismiss:()=>ce(null)})}),o.jsx("input",{type:"file",ref:I,className:"hidden",multiple:!0,onChange:ie,accept:"*/*",disabled:s}),b.length>0&&o.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:b.map((xe,$e)=>o.jsx(q5,{fileName:xe.name,onRemove:()=>G($e)},`${xe.name}-${xe.lastModified}-${$e}`))}),F&&M&&o.jsx("div",{className:"mb-2",children:o.jsxs("div",{className:"bg-muted/50 inline-flex max-w-full items-center gap-2 rounded-md border px-3 py-2 text-sm",children:[o.jsx(kv,{className:"text-muted-foreground h-4 w-4 flex-shrink-0"}),o.jsxs("span",{className:"text-muted-foreground truncate italic",children:['"',M,'"']}),o.jsx(ye,{variant:"ghost",className:"h-5 w-5 shrink-0",onClick:()=>{L(null),D(!1)},tooltip:"Remove context",children:o.jsx(Kr,{})})]})}),N.length>0&&o.jsx("div",{className:"mb-2 flex max-h-32 flex-wrap gap-2 overflow-y-auto pt-2 pl-2",children:N.map((xe,$e)=>{let Me="snippet.txt";if(!xe.isConfigured){const Fe=new Set(m.map(He=>He.filename));N.slice(0,$e).forEach(He=>{He.isConfigured&&He.filename&&Fe.add(He.filename)});let ft="snippet.txt";for(let He=0;He<$e;He++)if(!N[He].isConfigured&&(Fe.add(ft),Fe.has("snippet.txt"))){let Qe=2;for(;Fe.has(`snippet-${Qe}.txt`);)Qe++;ft=`snippet-${Qe}.txt`}if(Fe.has("snippet.txt")){let He=2;for(;Fe.has(`snippet-${He}.txt`);)He++;Me=`snippet-${He}.txt`}}return o.jsx(K5,{id:xe.id,content:xe.content,onClick:()=>U(xe.id),onRemove:()=>Y(xe.id),isConfigured:xe.isConfigured,filename:xe.filename,defaultFilename:Me},xe.id)})}),(()=>{const xe=N.find(He=>He.id===P),$e=N.findIndex(He=>He.id===P),Me=new Set(m.map(He=>He.filename));let Fe="snippet.txt";N.forEach((He,Ut)=>{if(He.id!==P)if(He.isConfigured&&He.filename)Me.add(He.filename);else if(Ut<$e||$e===-1){if(Me.has(Fe)){let Qe=2;for(;Me.has(`snippet-${Qe}.txt`);)Qe++;Fe=`snippet-${Qe}.txt`}if(Me.add(Fe),Me.has("snippet.txt")){let Qe=2;for(;Me.has(`snippet-${Qe}.txt`);)Qe++;Fe=`snippet-${Qe}.txt`}else Fe="snippet.txt"}else{if(Me.has(Fe)){let Qe=2;for(;Me.has(`snippet-${Qe}.txt`);)Qe++;Fe=`snippet-${Qe}.txt`}if(Me.add(Fe),Me.has("snippet.txt")){let Qe=2;for(;Me.has(`snippet-${Qe}.txt`);)Qe++;Fe=`snippet-${Qe}.txt`}else Fe="snippet.txt"}});let ft="snippet.txt";if(xe&&!xe.isConfigured&&$e>=0){const He=new Set(m.map(Qe=>Qe.filename));N.slice(0,$e).forEach(Qe=>{Qe.isConfigured&&Qe.filename&&He.add(Qe.filename)});let Ut="snippet.txt";for(let Qe=0;Qe<$e;Qe++)if(!N[Qe].isConfigured&&(He.add(Ut),He.has("snippet.txt"))){let Lt=2;for(;He.has(`snippet-${Lt}.txt`);)Lt++;Ut=`snippet-${Lt}.txt`}if(He.has("snippet.txt")){let Qe=2;for(;He.has(`snippet-${Qe}.txt`);)Qe++;ft=`snippet-${Qe}.txt`}}return o.jsx(rD,{isOpen:R,content:(xe==null?void 0:xe.content)||"",onSaveMetadata:B,onCancel:ee,existingArtifacts:Array.from(Me),initialFilename:xe==null?void 0:xe.filename,initialMimeType:xe==null?void 0:xe.mimeType,initialDescription:xe==null?void 0:xe.description,defaultFilename:ft})})(),o.jsx(Y5,{isOpen:V,onClose:()=>{X(!1)},textAreaRef:O,onPromptSelect:Ot,messages:v,onReservedCommand:gt}),H&&z&&o.jsx(Mm,{group:z,onSubmit:Nt,onClose:()=>{Q(!1),Z(null)}}),o.jsx(fC,{ref:O,value:$,onChange:wt,placeholder:de?"Recording...":"How can I help you today? (Type '/' to insert a prompt)",className:"field-sizing-content max-h-50 min-h-0 resize-none rounded-2xl border-none p-3 text-base/normal shadow-none transition-[height] duration-500 ease-in-out focus-visible:outline-none",rows:1,onPaste:q,disabled:de,onKeyDown:xe=>{xe.key==="Enter"&&!xe.shiftKey&&ae&&oe(xe)}}),o.jsxs("div",{className:"relative m-2 flex items-center gap-2",children:[o.jsx(ye,{variant:"ghost",onClick:le,disabled:s,tooltip:"Attach file",children:o.jsx(Tv,{className:"size-4"})}),o.jsx("div",{children:"Agent: "}),o.jsxs(Wr,{value:i,onValueChange:xe=>{y(xe)},disabled:s||e.length===0,children:[o.jsx(Gr,{className:"w-[250px]",children:o.jsx(Zr,{placeholder:"Select an agent..."})}),o.jsx(qr,{children:e.map(xe=>o.jsx(Pt,{value:xe.name,children:xe.displayName||xe.name},xe.name))})]}),o.jsx("div",{className:"flex-1"}),j&&C.speechToText&&o.jsx(Im,{disabled:s,onTranscriptionComplete:Jt,onError:Wt,onRecordingStateChange:fe}),s&&!a?o.jsxs(ye,{"data-testid":"cancel",className:"ml-auto gap-1.5",onClick:h,variant:"outline",disabled:a,tooltip:"Cancel",children:[o.jsx(c_,{className:"size-4"}),"Stop"]}):o.jsx(ye,{"data-testid":"sendMessage",variant:"ghost",className:"ml-auto gap-1.5",onClick:oe,disabled:!ae,tooltip:"Send message",children:o.jsx(Av,{className:"size-4"})})]})]})},aD=[{phase:"planning",icon:af,label:"Starting research",description:"Planning research strategy"},{phase:"searching",icon:co,label:"Exploring sources",description:"Searching for relevant information"},{phase:"analyzing",icon:af,label:"Analyzing content",description:"Processing and analyzing sources"},{phase:"writing",icon:Sr,label:"Generating report",description:"Compiling final research"}],iD=(e,t,n)=>{const r=["planning","searching","analyzing","writing"],s=r.indexOf(e),a=r.indexOf(t);return n&&e==="writing"||s<a?"complete":s===a?"active":"pending"},SC=({progress:e,isComplete:t=!1,ragData:n})=>{const r="research-timeline-expanded",[s,a]=d.useState(()=>{const w=localStorage.getItem(r);return w!==null?w==="true":!0}),[i,l]=d.useState(!1),[c,u]=d.useState(!1),[h,f]=d.useState(!0),p=xt.useRef(null),m=w=>{w.stopPropagation();const y=!s;a(y),localStorage.setItem(r,String(y)),y?f(!0):setTimeout(()=>f(!1),300)},v=w=>{const y=w.currentTarget,C=y.scrollHeight>y.clientHeight,S=Math.abs(y.scrollHeight-y.scrollTop-y.clientHeight)<1,j=y.scrollTop<1;l(C&&!S),u(C&&!j)},g=xt.useMemo(()=>{var I;const w=[];if(!t&&e.query_history&&e.query_history.length>0)return console.log("[InlineResearchProgress] Using query_history from progress:",{historyLength:e.query_history.length,queries:e.query_history.map(b=>b.query)}),e.query_history.forEach(b=>{w.push({type:"search",timestamp:b.timestamp,content:b.query}),b.urls.forEach(k=>{w.push({type:"read",timestamp:b.timestamp,content:k.title||k.url||"Unknown",url:k.url,favicon:k.favicon||(k.url?`https://www.google.com/s2/favicons?domain=${k.url}&sz=32`:""),title:k.title})})}),w;if(!n||n.length===0)return console.log("[InlineResearchProgress] No ragData available"),[];console.log("[InlineResearchProgress] Building timeline from ragData:",{ragDataCount:n.length,isComplete:t,firstSearchSample:n[0]?{query:n[0].query,sourcesCount:(I=n[0].sources)==null?void 0:I.length,metadata:n[0].metadata}:null});const y=n[0],C=y==null?void 0:y.metadata,S=(C==null?void 0:C.queries)&&Array.isArray(C.queries),j=n.length>1;if(S){const b=C.queries,k=y.sources,N=new Map;k.forEach(A=>{A.citationId&&N.set(A.citationId,A)}),b.forEach(A=>{w.push({type:"search",timestamp:A.timestamp,content:A.query}),A.sourceCitationIds.forEach(P=>{var R,_,M,L,F;const E=N.get(P);if(E&&(((R=E.metadata)==null?void 0:R.fetched)===!0||((_=E.metadata)==null?void 0:_.fetch_status)==="success"||E.content_preview&&E.content_preview.includes("[Full Content Fetched]"))&&(E.url||E.title||(M=E.metadata)!=null&&M.title)){const O=E.title||((L=E.metadata)==null?void 0:L.title);w.push({type:"read",timestamp:E.retrieved_at||A.timestamp,content:O||E.url||"Unknown",url:E.url,favicon:((F=E.metadata)==null?void 0:F.favicon)||(E.url?`https://www.google.com/s2/favicons?domain=${E.url}&sz=32`:""),title:O})}})})}else if(j)console.log("[InlineResearchProgress] Using multiple entries format",{totalEntries:n.length,sampleEntries:n.slice(0,3).map((b,k)=>{var N,A,P;return{index:k,query:b.query,sourcesCount:(N=b.sources)==null?void 0:N.length,timestamp:b.timestamp,firstSourceSample:(A=b.sources)!=null&&A[0]?{title:b.sources[0].title,url:b.sources[0].url,fetched:(P=b.sources[0].metadata)==null?void 0:P.fetched}:null}})}),n.forEach((b,k)=>{w.push({type:"search",timestamp:b.timestamp,content:b.query});const N=t?b.sources.filter(A=>{var E,R;return((E=A.metadata)==null?void 0:E.fetched)===!0||((R=A.metadata)==null?void 0:R.fetch_status)==="success"||A.contentPreview&&A.contentPreview.includes("[Full Content Fetched]")}):b.sources;console.log(`[InlineResearchProgress] Search ${k} sources:`,{query:b.query,totalSources:b.sources.length,shownSources:N.length}),N.forEach(A=>{var E,R;const P=A.title||((E=A.metadata)==null?void 0:E.title);(A.url||P)&&w.push({type:"read",timestamp:A.retrievedAt||b.timestamp,content:P||A.url||"Unknown",url:A.url,favicon:((R=A.metadata)==null?void 0:R.favicon)||(A.url?`https://www.google.com/s2/favicons?domain=${A.url}&sz=32`:""),title:P})})});else{console.log("[InlineResearchProgress] Using single entry format");const b=n[0];w.push({type:"search",timestamp:b.timestamp,content:b.query}),b.sources.forEach(k=>{var A,P;const N=k.title||((A=k.metadata)==null?void 0:A.title);(k.url||N)&&w.push({type:"read",timestamp:k.retrievedAt||b.timestamp,content:N||k.url||"Unknown",url:k.url,favicon:((P=k.metadata)==null?void 0:P.favicon)||(k.url?`https://www.google.com/s2/favicons?domain=${k.url}&sz=32`:""),title:N})})}return console.log("[InlineResearchProgress] Final timeline events:",{totalEvents:w.length,searchEvents:w.filter(b=>b.type==="search").length,readEvents:w.filter(b=>b.type==="read").length}),w},[n,t,e.query_history]),x=g.length>0;return xt.useEffect(()=>{if(s&&p.current){const w=p.current.scrollHeight>p.current.clientHeight;l(w),u(!1)}},[s,g]),xt.useEffect(()=>{!t&&s&&p.current&&g.length>0&&p.current.scrollTo({top:p.current.scrollHeight,behavior:"smooth"})},[g.length,t,s]),o.jsx("div",{className:"my-4 space-y-3",children:t?o.jsx("div",{children:o.jsxs("div",{className:"border-border bg-background rounded-lg border p-3",children:[o.jsxs("div",{className:"flex items-start justify-between gap-3",children:[o.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:[o.jsx("div",{className:"mt-0.5 flex-shrink-0 text-green-600 dark:text-green-400",children:o.jsx(lu,{className:"h-5 w-5"})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("h3",{className:"text-sm font-medium",children:"Research complete"}),o.jsx("div",{className:`mt-2 ${h?"mb-4":""}`,children:o.jsx("div",{className:"h-1 overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",children:o.jsx("div",{className:"h-full bg-green-600 transition-all duration-300 ease-out dark:bg-green-400",style:{width:"100%"}})})})]})]}),o.jsx(ye,{variant:"ghost",size:"icon",onClick:w=>{w.stopPropagation(),m(w)},tooltip:s?"Collapse":"Expand",children:s?o.jsx(Ua,{className:"h-4 w-4 transition-transform duration-200"}):o.jsx(Uo,{className:"h-4 w-4 transition-transform duration-200"})})]}),x&&o.jsx("div",{className:`grid transition-[grid-template-rows] duration-300 ease-in-out ${s?"grid-rows-[1fr]":"grid-rows-[0fr]"}`,children:o.jsxs("div",{className:"overflow-hidden",children:[o.jsx("div",{className:"-mx-3",children:o.jsx("hr",{className:"border-t"})}),o.jsx("div",{className:"p-3",children:o.jsxs("div",{className:"relative",children:[o.jsx("div",{ref:p,className:"max-h-[300px] space-y-2 overflow-y-auto",onScroll:v,children:(()=>{let w=null;return g.map((y,C)=>{const S=w!==y.type;return w=y.type,o.jsxs(xt.Fragment,{children:[S&&o.jsx("div",{className:"mt-4 text-xs font-medium text-[var(--color-secondary-text-wMain)] first:mt-0",children:y.type==="search"?"Searching":"Reviewing"}),o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsxs("div",{className:"mt-1 flex-shrink-0",children:[y.type==="search"&&o.jsx(co,{className:"text-muted-foreground h-3 w-3"}),y.type==="read"&&(y.favicon&&y.favicon.trim()!==""?o.jsx("img",{src:y.favicon,alt:"",className:"h-3 w-3 rounded",onError:j=>{j.target.style.display="none"}}):o.jsx(lf,{className:"text-muted-foreground h-3 w-3"}))]}),o.jsxs("div",{className:"min-w-0 flex-1 text-sm",children:[y.type==="search"&&o.jsx("div",{children:o.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:y.content})}),y.type==="read"&&o.jsx("div",{children:y.url?o.jsx("a",{href:y.url,target:"_blank",rel:"noopener noreferrer",className:"text-primary font-medium hover:underline",onClick:j=>j.stopPropagation(),children:y.title||y.url}):o.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:y.content})})]})]})]},C)})})()}),c&&o.jsx("div",{className:"pointer-events-none absolute top-0 right-0 left-0 h-10 bg-gradient-to-b from-white to-transparent dark:from-gray-900"}),i&&o.jsx("div",{className:"pointer-events-none absolute right-0 bottom-0 left-0 h-10 bg-gradient-to-t from-white to-transparent dark:from-gray-900"})]})})]})})]})}):aD.map(w=>{const y=iD(w.phase,e.phase,t),C=w.icon,S=e.phase===w.phase;return y!=="active"?null:o.jsx("div",{children:o.jsxs("div",{className:"border-border bg-background rounded-lg border p-3",children:[o.jsxs("div",{className:"flex items-start justify-between gap-3",children:[o.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:[o.jsx("div",{className:"text-primary mt-0.5 flex-shrink-0",children:o.jsx(C,{className:"h-5 w-5 animate-pulse"})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("h3",{className:"text-sm font-medium",children:[w.label,": ",o.jsx("span",{className:"text-sm font-normal text-gray-500 dark:text-gray-400",children:e.status_text})]}),S&&o.jsx("div",{className:`mt-2 ${h?"mb-4":""}`,children:o.jsx("div",{className:"h-1 overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",children:o.jsx("div",{className:"bg-primary h-full transition-all duration-300 ease-out",style:{width:`${Math.min(e.progress_percentage,100)}%`}})})})]})]}),o.jsx(ye,{variant:"ghost",size:"icon",onClick:j=>{j.stopPropagation(),m(j)},tooltip:s?"Collapse":"Expand",children:s?o.jsx(Ua,{className:"h-4 w-4 transition-transform duration-200"}):o.jsx(Uo,{className:"h-4 w-4 transition-transform duration-200"})})]}),x&&o.jsx("div",{className:`grid transition-[grid-template-rows] duration-300 ease-in-out ${s?"grid-rows-[1fr]":"grid-rows-[0fr]"}`,children:o.jsxs("div",{className:"overflow-hidden",children:[o.jsx("div",{className:"-mx-3",children:o.jsx("hr",{className:"border-t"})}),o.jsx("div",{className:"p-3",children:o.jsxs("div",{className:"relative",children:[o.jsx("div",{ref:p,className:"max-h-[300px] space-y-2 overflow-y-auto",onScroll:v,children:(()=>{let j=null;return g.map((I,b)=>{const k=j!==I.type;return j=I.type,o.jsxs(xt.Fragment,{children:[k&&o.jsx("div",{className:"mt-4 text-xs font-medium text-[var(--color-secondary-text-wMain)] first:mt-0",children:I.type==="search"?"Searching":"Reviewing"}),o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsxs("div",{className:"mt-1 flex-shrink-0",children:[I.type==="search"&&o.jsx(co,{className:"text-muted-foreground h-3 w-3"}),I.type==="read"&&(I.favicon&&I.favicon.trim()!==""?o.jsx("img",{src:I.favicon,alt:"",className:"h-3 w-3 rounded",onError:N=>{N.target.style.display="none"}}):o.jsx(lf,{className:"text-muted-foreground h-3 w-3"}))]}),o.jsxs("div",{className:"min-w-0 flex-1 text-sm",children:[I.type==="search"&&o.jsx("div",{children:o.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:I.content})}),I.type==="read"&&o.jsx("div",{children:I.url?o.jsx("a",{href:I.url,target:"_blank",rel:"noopener noreferrer",className:"text-primary font-medium hover:underline",onClick:N=>N.stopPropagation(),children:I.title||I.url}):o.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:I.content})})]})]})]},b)})})()}),c&&o.jsx("div",{className:"pointer-events-none absolute top-0 right-0 left-0 h-10 bg-gradient-to-b from-white to-transparent dark:from-gray-900"}),i&&o.jsx("div",{className:"pointer-events-none absolute right-0 bottom-0 left-0 h-10 bg-gradient-to-t from-white to-transparent dark:from-gray-900"})]})})]})})]})},w.phase)})})},lD=({content:e,mime_type:t,setRenderError:n})=>{const r=`data:${t||"audio/mpeg"};base64,${e}`;return o.jsx("div",{className:"flex h-auto max-w-[100vw] items-center justify-center p-4",children:o.jsxs("audio",{controls:!0,className:"w-full",onLoad:()=>n(null),onError:()=>n("Failed to load audio content."),children:[o.jsx("source",{src:r,type:t||"audio/mpeg"}),"Your browser does not support the audio element."]})})},cD=e=>{if(!e)return[];const t=[];let n=[],r="",s=!1;for(let a=0;a<e.length;a++){const i=e[a],l=a<e.length-1?e[a+1]:"";i==='"'?l==='"'?(r+='"',a++):s=!s:i===","&&!s?(n.push(r.trim()),r=""):(i===`
|
|
157
|
+
`||i==="\r"&&l===`
|
|
158
|
+
`)&&!s?(i==="\r"&&l===`
|
|
159
|
+
`&&a++,n.push(r.trim()),r="",n.some(c=>c.trim())?(t.push(n),n=[]):n=[]):r+=i}return(r||n.length>0)&&(n.push(r.trim()),n.some(a=>a.trim())&&t.push(n)),t},uD=({content:e,setRenderError:t})=>{d.useEffect(()=>{t(null)},[e,t]);const n=d.useMemo(()=>{try{return cD(e)}catch(r){return console.error("Error parsing CSV:",r),t("Failed to parse CSV content."),[]}},[e,t]);return n.length?o.jsx("div",{className:"block w-full overflow-x-scroll p-4",children:o.jsx("div",{style:{minWidth:"min(100%, max-content)"},children:o.jsxs("table",{className:"w-full border text-sm",children:[o.jsx("thead",{className:"sticky top-0 z-10 shadow-sm",children:n.length>0&&o.jsx("tr",{children:n[0].map((r,s)=>o.jsx("th",{className:"border-b p-2 text-left font-medium whitespace-nowrap",title:r,children:(r==null?void 0:r.trim())||""},`header-${s}`))})}),o.jsx("tbody",{children:n.slice(1).map((r,s)=>o.jsx("tr",{className:s%2===0?"bg-muted dark:bg-gray-700":"",children:r.map((a,i)=>o.jsx("td",{className:"min-w-0 border-b p-2 align-top break-words",title:a,children:(a==null?void 0:a.trim())||""},`cell-${s}-${i}`))},`row-${s}`))})]})})}):o.jsx("div",{children:"No valid CSV content found or failed to parse."})},dD=({content:e,setRenderError:t})=>{const n=d.useMemo(()=>e.replace(/<script(?:\s[^>]*)?>([\s\S]*?)<\/script>/gi,(a,i)=>{const l=a.match(/<script(\s[^>]*)?>/i);return`<script${l&&l[1]?l[1]:""}>(function() {
|
|
160
|
+
try {
|
|
161
|
+
${i}
|
|
162
|
+
} catch (e) { console.error('Error in sandboxed script:', e); }
|
|
163
|
+
})();<\/script>`}),[e]);return o.jsx("div",{className:"h-full w-full overflow-hidden border dark:bg-gray-400",children:o.jsx("iframe",{srcDoc:n,title:"HTML Preview",sandbox:"allow-scripts allow-same-origin allow-downloads allow-forms allow-popups",allow:"autoplay",className:"h-full w-full border-none",onError:()=>t("Failed to load HTML content."),onLoad:()=>t(null)})})},fD=({content:e,mime_type:t,setRenderError:n})=>{const r=`data:${t||"image/png"};base64,${e}`;return o.jsx("div",{className:"flex h-auto w-auto max-w-[100vw] items-center justify-center p-4",children:o.jsx("img",{src:r,onError:()=>n("Failed to load image"),onLoad:()=>n(null),alt:"Preview",className:"h-full w-full object-contain"})})};function _C(){const e=d.useRef(null),t=()=>{if(e.current){const r=document.createRange();r.selectNodeContents(e.current);const s=window.getSelection();s&&(s.removeAllRanges(),s.addRange(r))}};return{ref:e,handleKeyDown:r=>{(r.metaKey||r.ctrlKey)&&r.key==="a"&&(r.preventDefault(),t())},selectAllContent:t}}const cx=/\[?\[cite:(s\d+r\d+|research\d+)\]\]?/g,ux=/\[?\[cite:((?:s\d+r\d+|research\d+)(?:\s*,\s*(?:cite:)?(?:s\d+r\d+|research\d+))+)\]\]?/g,Xc=/(?:cite:)?(s\d+r\d+|research\d+)/g,hD=/^s(\d+)r(\d+)$/,mD=/^research(\d+)$/;function kC(e){const t=e.match(hD);if(t)return{type:"search",sourceId:parseInt(t[2],10)};const n=e.match(mD);return n?{type:"research",sourceId:parseInt(n[1],10)}:null}function pD(e,t,n,r){const s=[];let a;for(Xc.lastIndex=0;(a=Xc.exec(e))!==null;){const i=a[1],l=kC(i);if(l){const c={marker:n,type:l.type,sourceId:l.sourceId,position:t,citationId:i};r!=null&&r.sources&&(c.source=r.sources.find(u=>u.citationId===i)),s.push(c)}}return s}function qf(e,t){const n=[],r=new Set;let s;for(ux.lastIndex=0;(s=ux.exec(e))!==null;){const[a,i]=s,l=pD(i,s.index,a,t);n.push(...l),r.add(s.index)}for(cx.lastIndex=0;(s=cx.exec(e))!==null;){if(r.has(s.index))continue;const a=e.substring(s.index+s[0].length),i=e.substring(0,s.index);if(a.match(/^\s*,\s*(?:s\d+r\d+|research\d+)/)||i.match(/\[?\[cite:[^\]]*,\s*$/))continue;const[l,c]=s,u=kC(c);if(u){const h={marker:l,type:u.type,sourceId:u.sourceId,position:s.index,citationId:c};t!=null&&t.sources&&(h.source=t.sources.find(f=>f.citationId===c),!h.source&&t.sources.length>0&&console.log(`Citation ${c} not found in sources:`,t.sources.map(f=>f.citationId))),n.push(h)}}return n.sort((a,i)=>a.position-i.position),n}function gD(e){return e.sourceId+1}function jC(e){var a,i,l,c,u,h,f,p,m,v,g;const t=((i=(a=e.source)==null?void 0:a.metadata)==null?void 0:i.type)==="web_search"||e.type==="search",n=((c=(l=e.source)==null?void 0:l.metadata)==null?void 0:c.type)==="deep_research"||e.type==="research",r=((u=e.source)==null?void 0:u.sourceUrl)||((h=e.source)==null?void 0:h.url)||((p=(f=e.source)==null?void 0:f.metadata)==null?void 0:p.link);if((t||n)&&r){const x=((v=(m=e.source)==null?void 0:m.metadata)==null?void 0:v.title)||((g=e.source)==null?void 0:g.filename);return x&&x!==r?`${x}
|
|
164
|
+
${r}`:r}if(!e.source)return`Source ${gD(e)}`;const s=(e.source.relevanceScore*100).toFixed(1);return`${e.source.filename} (${s}% relevance)`}function Si(e,t){return e.length<=t?e:e.substring(0,t-3)+"..."}function xD(e){if(!(e.includes("web-session-")||e.startsWith("sam_dev_user_")))return e;let n=e.replace(/\.pdf$/,"");n=n.replace(/_v\d+$/,"");const r=/^.*web-session-[a-f0-9-]+_/;return n=n.replace(r,""),n+".pdf"}function Yf(e,t=30){var r,s,a,i,l;if((((s=(r=e.source)==null?void 0:r.metadata)==null?void 0:s.type)==="web_search"||e.type==="search")&&((a=e.source)!=null&&a.sourceUrl))try{const u=new URL(e.source.sourceUrl).hostname.replace(/^www\./,"");return Si(u,t)}catch{}if((l=(i=e.source)==null?void 0:i.metadata)!=null&&l.link)try{const u=new URL(e.source.metadata.link).hostname.replace(/^www\./,"");return Si(u,t)}catch{}if(!e.source&&e.type==="search")return`Web Source ${e.sourceId+1}`;if(!e.source)return`Source ${e.sourceId+1}`;if(e.source.filename){const u=e.source.filename.includes("web-session-")||e.source.filename.startsWith("sam_dev_user_")?xD(e.source.filename):e.source.filename;return Si(u,t)}if(e.source.sourceUrl)try{const u=new URL(e.source.sourceUrl).hostname.replace(/^www\./,"");return Si(u,t)}catch{const c=e.source.sourceUrl.split("/").pop()||e.source.sourceUrl;return Si(c,t)}return`Source ${e.sourceId+1}`}function vD({citation:e,onClick:t,maxLength:n=30}){const r=Yf(e,n),s=jC(e),{url:a,sourceType:i}=Oc(e.source),l=i==="web_search"||e.type==="search",c=i==="deep_research"||e.type==="research",u=(l||c)&&a,h=f=>{if(f.preventDefault(),f.stopPropagation(),u){window.open(a,"_blank","noopener,noreferrer");return}t&&t(e)};return o.jsxs("button",{onClick:h,className:"citation-badge mx-0.5 inline-flex cursor-pointer items-center gap-0.5 rounded-sm bg-gray-200 px-1.5 py-0 align-baseline text-[11px] font-normal whitespace-nowrap text-gray-800 transition-colors duration-150 hover:bg-gray-300 dark:bg-gray-700 dark:text-white dark:hover:bg-gray-600",title:s,"aria-label":`Citation: ${s}`,type:"button",children:[o.jsx("span",{className:"max-w-[200px] truncate",children:r}),u&&o.jsx(uo,{className:"h-2.5 w-2.5 flex-shrink-0"})]})}function Ud({citations:e,onCitationClick:t}){const[n,r]=d.useState(!1),[s,a]=d.useState(!1),i=d.useRef(null),l=150,c=150;xt.useEffect(()=>{const k=()=>{r(document.documentElement.classList.contains("dark"))};k();const N=new MutationObserver(k);return N.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>N.disconnect()},[]),xt.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]);const u=d.useCallback(()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{a(!0)},l)},[]),h=d.useCallback(()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{a(!1)},c)},[]),f=d.useCallback(()=>{i.current&&clearTimeout(i.current)},[]),p=d.useCallback(()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{a(!1)},c)},[]);if(e.length===0)return null;const m=e.filter((k,N,A)=>N===A.findIndex(P=>P.sourceId===k.sourceId&&P.type===k.type));if(m.length===1)return o.jsx(vD,{citation:m[0],onClick:t});const v=m[0],g=m.length-1,x=Yf(v,20),w=jC(v),{url:y,sourceType:C}=Oc(v.source),S=C==="web_search"||v.type==="search",j=C==="deep_research"||v.type==="research",I=(S||j)&&y,b=k=>{if(k.preventDefault(),k.stopPropagation(),I&&y){window.open(y,"_blank","noopener,noreferrer");return}t&&t(v)};return o.jsxs(Sl,{open:s,onOpenChange:a,children:[o.jsx(_l,{asChild:!0,children:o.jsxs("button",{onClick:b,onMouseEnter:u,onMouseLeave:h,className:"citation-badge mx-0.5 inline-flex cursor-pointer items-center gap-1 rounded-sm bg-gray-200 px-1.5 py-0 align-baseline text-[11px] font-normal whitespace-nowrap text-gray-800 transition-colors duration-150 hover:bg-gray-300 dark:bg-gray-700 dark:text-white dark:hover:bg-gray-600",title:w,"aria-label":`Citation: ${w}`,type:"button",children:[o.jsx("span",{className:"max-w-[200px] truncate",children:x}),I&&o.jsx(uo,{className:"h-2.5 w-2.5 flex-shrink-0"}),o.jsxs("span",{className:"text-[10px] opacity-70",children:["+",g]})]})}),o.jsx(kl,{sideOffset:8,onMouseEnter:f,onMouseLeave:p,className:"z-[999] max-h-[400px] w-[320px] max-w-[calc(100vw-2rem)] cursor-default overflow-y-auto rounded-lg border p-3 shadow-xl",style:{backgroundColor:n?"#1f2937":"#ffffff",borderColor:n?"#4b5563":"#d1d5db",color:n?"#f3f4f6":"#111827"},children:o.jsxs("div",{className:"cursor-default space-y-2",children:[o.jsx("div",{className:"mb-3 border-b pb-2",style:{borderColor:n?"#4b5563":"#e5e7eb"},children:o.jsxs("h3",{className:"text-sm font-semibold",children:["All Sources · ",m.length]})}),m.map((k,N)=>{var D,O;const A=Yf(k,50),{url:P,sourceType:E}=Oc(k.source),R=E==="web_search"||k.type==="search",_=E==="deep_research"||k.type==="research",M=(R||_)&&P;let L=null;if((R||_)&&P)try{L=`https://www.google.com/s2/favicons?domain=${new URL(P).hostname}&sz=32`}catch{}const F=K=>{K.preventDefault(),K.stopPropagation(),M&&P?window.open(P,"_blank","noopener,noreferrer"):t&&t(k)};return o.jsxs("button",{onClick:F,className:"group flex w-full cursor-pointer items-start gap-2 rounded-md p-2 text-left transition-colors hover:bg-gray-100 dark:hover:bg-gray-800",type:"button",children:[L&&o.jsxs("div",{className:"relative mt-0.5 h-4 w-4 flex-shrink-0 overflow-hidden rounded-full bg-white",children:[o.jsx("img",{src:L,alt:"",className:"h-full w-full"}),o.jsx("div",{className:"absolute inset-0 rounded-full border border-gray-200/10 dark:border-transparent"})]}),o.jsxs("div",{className:"flex-1 overflow-hidden",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("span",{className:"truncate text-sm font-medium text-[var(--color-primary-wMain)] group-hover:text-[var(--color-primary-w60)] dark:text-[var(--color-primary-w60)] dark:group-hover:text-[var(--color-white)]",children:A}),M&&o.jsx(uo,{className:"h-3 w-3 flex-shrink-0 text-[var(--color-primary-wMain)] group-hover:text-[var(--color-primary-w60)] dark:text-[var(--color-primary-w60)] dark:group-hover:text-[var(--color-white)]"})]}),((O=(D=k.source)==null?void 0:D.metadata)==null?void 0:O.title)&&o.jsx("div",{className:"mt-0.5 truncate text-xs text-gray-600 dark:text-gray-400",children:k.source.metadata.title})]})]},`bundled-citation-${N}`)})]})})]})}function wD(e){const t=e.match(/^s(\d+)r(\d+)$/);if(t)return{type:"search",sourceId:parseInt(t[2],10)};const n=e.match(/^research(\d+)$/);return n?{type:"research",sourceId:parseInt(n[1],10)}:null}function yD(e){const t=[];let n;for(Xc.lastIndex=0;(n=Xc.exec(e))!==null;){const r=n[1],s=wD(r);s&&t.push({type:s.type,sourceId:s.sourceId,citationId:r})}return t}const zi=/\[?\[cite:((?:s\d+r\d+|research\d+)(?:\s*,\s*(?:cite:)?(?:s\d+r\d+|research\d+))*)\]\]?/g;function bD(e,t,n){const r=[];let s=0,a,i=[];for(zi.lastIndex=0;(a=zi.exec(e))!==null;){a.index>s&&(i.length>0&&(r.push(o.jsx(Ud,{citations:i,onCitationClick:n},`cit-${s}`)),i=[]),r.push(e.substring(s,a.index)));const[,l]=a,c=yD(l);for(const{citationId:u}of c){const h=t.find(f=>f.citationId===u);h&&i.push(h)}s=a.index+a[0].length}return s<e.length?(i.length>0&&(r.push(o.jsx(Ud,{citations:i,onCitationClick:n},`cit-${s}`)),i=[]),r.push(e.substring(s))):i.length>0&&r.push(o.jsx(Ud,{citations:i,onCitationClick:n},"cit-end")),r}function Kf({text:e,citations:t,onCitationClick:n}){const r=d.useMemo(()=>({replace:s=>{if(s.type==="text"&&s instanceof jc.Text){const a=s.data;if(zi.lastIndex=0,zi.test(a)){zi.lastIndex=0;const i=bD(a,t,n);if(i.length>0)return o.jsx(o.Fragment,{children:i})}}s instanceof jc.Element&&s.name==="a"&&(s.attribs.target="_blank",s.attribs.rel="noopener noreferrer")}}),[t,n]);if(t.length===0)return o.jsx(Rs,{children:e});try{const s=jv.parse(e,{gfm:!0}),a=Pm.sanitize(s,{USE_PROFILES:{html:!0}}),i=Ev(a,r);return o.jsx("div",{className:Dc(),children:i})}catch{return o.jsx(Rs,{children:e})}}const EC=({content:e,ragData:t,isStreaming:n})=>{const{ref:r,handleKeyDown:s}=_C(),a=d.useMemo(()=>qf(e,t),[e,t]);return o.jsx("div",{className:"w-full p-4",children:o.jsx("div",{ref:r,className:"max-w-full overflow-hidden select-text focus-visible:outline-none",tabIndex:0,onKeyDown:s,children:n?o.jsx(Gf,{content:e,isStreaming:n,className:"max-w-full break-words"}):o.jsx("div",{className:Dc("max-w-full break-words"),children:o.jsx(Kf,{text:e,citations:a})})})})},CD=({content:e,setRenderError:t})=>{const[n,r]=d.useState(""),s=d.useMemo(()=>Pm.sanitize(e,{USE_PROFILES:{html:!1},ALLOWED_TAGS:["br","em","strong","b","i"],ALLOWED_ATTR:[]}),[e]);return d.useEffect(()=>{r(`<!DOCTYPE html>
|
|
165
|
+
<html>
|
|
166
|
+
<head>
|
|
167
|
+
<meta charset="utf-8">
|
|
168
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
169
|
+
<title>Mermaid Preview</title>
|
|
170
|
+
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"><\/script>
|
|
171
|
+
<script src="https://cdn.jsdelivr.net/npm/panzoom@9.4.0/dist/panzoom.min.js"><\/script>
|
|
172
|
+
<script>
|
|
173
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
174
|
+
try {
|
|
175
|
+
mermaid.initialize({
|
|
176
|
+
startOnLoad: true,
|
|
177
|
+
theme: 'default',
|
|
178
|
+
fontFamily: 'arial, sans-serif',
|
|
179
|
+
logLevel: 'error',
|
|
180
|
+
securityLevel: 'strict'
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// Initialize panzoom after Mermaid rendering
|
|
184
|
+
mermaid.run().then(() => {
|
|
185
|
+
const diagramContainer = document.getElementById('diagram-container');
|
|
186
|
+
if (diagramContainer) {
|
|
187
|
+
const pz = panzoom(diagramContainer, {
|
|
188
|
+
maxZoom: 10,
|
|
189
|
+
minZoom: 0.1,
|
|
190
|
+
smoothScroll: true,
|
|
191
|
+
bounds: true,
|
|
192
|
+
boundsPadding: 0.1
|
|
193
|
+
});
|
|
194
|
+
// Add zoom controls (old version had only reset)
|
|
195
|
+
const resetButton = document.getElementById('reset');
|
|
196
|
+
if (resetButton) {
|
|
197
|
+
resetButton.addEventListener('click', () => {
|
|
198
|
+
pz.moveTo(0, 0);
|
|
199
|
+
pz.zoomAbs(0, 0, 1);
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}).catch(err => {
|
|
204
|
+
console.error("Mermaid rendering failed inside iframe:", err);
|
|
205
|
+
const mermaidDiv = document.querySelector('.mermaid');
|
|
206
|
+
if (mermaidDiv) mermaidDiv.innerText = "Error rendering diagram: " + err.message;
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
window.addEventListener('message', function(event) {
|
|
210
|
+
if (event.data && event.data.action === 'getMermaidSvg') {
|
|
211
|
+
const svgElement = document.querySelector('.mermaid svg');
|
|
212
|
+
if (svgElement) {
|
|
213
|
+
if (!svgElement.getAttribute('xmlns')) { // Ensure xmlns for standalone SVG
|
|
214
|
+
svgElement.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
|
|
215
|
+
}
|
|
216
|
+
const svgData = new XMLSerializer().serializeToString(svgElement);
|
|
217
|
+
window.parent.postMessage({
|
|
218
|
+
action: 'downloadSvg',
|
|
219
|
+
svgData: svgData,
|
|
220
|
+
filename: event.data.filename || 'mermaid-diagram.svg'
|
|
221
|
+
}, '*');
|
|
222
|
+
} else {
|
|
223
|
+
console.error('SVG element not found for download inside iframe.');
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
} catch (e) {
|
|
228
|
+
console.error("Error initializing Mermaid or Panzoom inside iframe:", e);
|
|
229
|
+
const mermaidDiv = document.querySelector('.mermaid');
|
|
230
|
+
if (mermaidDiv) mermaidDiv.innerText = "Failed to initialize diagram viewer: " + e.message;
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
<\/script>
|
|
234
|
+
<style>
|
|
235
|
+
/* Styles from old code */
|
|
236
|
+
html, body {
|
|
237
|
+
height: 100%;
|
|
238
|
+
margin: 0;
|
|
239
|
+
padding: 0;
|
|
240
|
+
overflow: hidden;
|
|
241
|
+
font-family: Arial, sans-serif; /* Old font */
|
|
242
|
+
}
|
|
243
|
+
.container {
|
|
244
|
+
display: flex;
|
|
245
|
+
flex-direction: column;
|
|
246
|
+
height: 100vh;
|
|
247
|
+
overflow: hidden;
|
|
248
|
+
}
|
|
249
|
+
.diagram-wrapper {
|
|
250
|
+
flex: 1;
|
|
251
|
+
overflow: hidden;
|
|
252
|
+
position: relative;
|
|
253
|
+
display: flex;
|
|
254
|
+
justify-content: center;
|
|
255
|
+
align-items: center;
|
|
256
|
+
background-color: #f9f9f9;
|
|
257
|
+
}
|
|
258
|
+
#diagram-container {
|
|
259
|
+
transform-origin: 0 0;
|
|
260
|
+
cursor: grab;
|
|
261
|
+
box-shadow: 0 0 10px rgba(0,0,0,0.1);
|
|
262
|
+
background-color: white;
|
|
263
|
+
padding: 20px;
|
|
264
|
+
border-radius: 5px;
|
|
265
|
+
/* Ensure diagram container can hold the content */
|
|
266
|
+
width: auto; /* Adjust as needed, or let content define it */
|
|
267
|
+
height: auto;
|
|
268
|
+
max-width: 100%;
|
|
269
|
+
max-height: 100%;
|
|
270
|
+
}
|
|
271
|
+
#diagram-container:active {
|
|
272
|
+
cursor: grabbing;
|
|
273
|
+
}
|
|
274
|
+
.mermaid {
|
|
275
|
+
display: flex; /* Helps in centering if SVG is smaller */
|
|
276
|
+
justify-content: center;
|
|
277
|
+
align-items: center;
|
|
278
|
+
/* width: 100%; Ensures mermaid div takes space, SVG might scale within it */
|
|
279
|
+
/* height: 100%; */
|
|
280
|
+
}
|
|
281
|
+
.mermaid svg {
|
|
282
|
+
max-width: 100%; /* Ensure SVG scales down if too large */
|
|
283
|
+
max-height: 100%;
|
|
284
|
+
}
|
|
285
|
+
.controls{
|
|
286
|
+
position: fixed;
|
|
287
|
+
bottom: 20px;
|
|
288
|
+
right: 20px;
|
|
289
|
+
z-index: 1000;
|
|
290
|
+
display: flex;
|
|
291
|
+
gap: 5px;
|
|
292
|
+
}
|
|
293
|
+
.control-btn {
|
|
294
|
+
width: 40px;
|
|
295
|
+
height: 40px;
|
|
296
|
+
border-radius: 50%;
|
|
297
|
+
border: none;
|
|
298
|
+
background-color: white;
|
|
299
|
+
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
|
|
300
|
+
cursor: pointer;
|
|
301
|
+
font-size: 18px;
|
|
302
|
+
display: flex;
|
|
303
|
+
align-items: center;
|
|
304
|
+
justify-content: center;
|
|
305
|
+
}
|
|
306
|
+
.control-btn:hover {
|
|
307
|
+
background-color: #f0f0f0;
|
|
308
|
+
}
|
|
309
|
+
.instructions {
|
|
310
|
+
position: fixed;
|
|
311
|
+
top: 10px;
|
|
312
|
+
left: 10px;
|
|
313
|
+
background-color: rgba(255,255,255,0.8);
|
|
314
|
+
padding: 5px 10px;
|
|
315
|
+
border-radius: 4px;
|
|
316
|
+
font-size: 12px;
|
|
317
|
+
color: #666;
|
|
318
|
+
}
|
|
319
|
+
</style>
|
|
320
|
+
</head>
|
|
321
|
+
<body>
|
|
322
|
+
<div class="container">
|
|
323
|
+
<div class="diagram-wrapper">
|
|
324
|
+
<div id="diagram-container">
|
|
325
|
+
<div class="mermaid">
|
|
326
|
+
${s}
|
|
327
|
+
</div>
|
|
328
|
+
</div>
|
|
329
|
+
</div>
|
|
330
|
+
<div class="instructions">
|
|
331
|
+
Drag to pan and scroll to zoom
|
|
332
|
+
</div>
|
|
333
|
+
<div class="controls">
|
|
334
|
+
<button id="reset" class="control-btn" title="Reset View">↺</button>
|
|
335
|
+
</div>
|
|
336
|
+
</div>
|
|
337
|
+
</body>
|
|
338
|
+
</html>`)},[s]),o.jsx("div",{className:"bg-background h-full p-4",children:o.jsx("iframe",{srcDoc:n,title:"Mermaid Diagram Preview",sandbox:"allow-scripts allow-same-origin allow-downloads",className:"h-96 w-full resize border-none",onError:()=>t("Failed to load Mermaid content."),onLoad:()=>t(null)})})};/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */function NC(e){return typeof e>"u"||e===null}function SD(e){return typeof e=="object"&&e!==null}function _D(e){return Array.isArray(e)?e:NC(e)?[]:[e]}function kD(e,t){var n,r,s,a;if(t)for(a=Object.keys(t),n=0,r=a.length;n<r;n+=1)s=a[n],e[s]=t[s];return e}function jD(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function ED(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var ND=NC,TD=SD,AD=_D,ID=jD,RD=ED,PD=kD,kn={isNothing:ND,isObject:TD,toArray:AD,repeat:ID,isNegativeZero:RD,extend:PD};function TC(e,t){var n="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+=`
|
|
339
|
+
|
|
340
|
+
`+e.mark.snippet),r+" "+n):r}function Qi(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=TC(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Qi.prototype=Object.create(Error.prototype);Qi.prototype.constructor=Qi;Qi.prototype.toString=function(t){return this.name+": "+TC(this,t)};var qn=Qi;function Bd(e,t,n,r,s){var a="",i="",l=Math.floor(s/2)-1;return r-t>l&&(a=" ... ",t=r-l+a.length),n-r>l&&(i=" ...",n=r+l-i.length),{str:a+e.slice(t,n).replace(/\t/g,"→")+i,pos:r-t+a.length}}function Vd(e,t){return kn.repeat(" ",t-e.length)+e}function MD(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),typeof t.indent!="number"&&(t.indent=1),typeof t.linesBefore!="number"&&(t.linesBefore=3),typeof t.linesAfter!="number"&&(t.linesAfter=2);for(var n=/\r?\n|\r|\0/g,r=[0],s=[],a,i=-1;a=n.exec(e.buffer);)s.push(a.index),r.push(a.index+a[0].length),e.position<=a.index&&i<0&&(i=r.length-2);i<0&&(i=r.length-1);var l="",c,u,h=Math.min(e.line+t.linesAfter,s.length).toString().length,f=t.maxLength-(t.indent+h+3);for(c=1;c<=t.linesBefore&&!(i-c<0);c++)u=Bd(e.buffer,r[i-c],s[i-c],e.position-(r[i]-r[i-c]),f),l=kn.repeat(" ",t.indent)+Vd((e.line-c+1).toString(),h)+" | "+u.str+`
|
|
341
|
+
`+l;for(u=Bd(e.buffer,r[i],s[i],e.position,f),l+=kn.repeat(" ",t.indent)+Vd((e.line+1).toString(),h)+" | "+u.str+`
|
|
342
|
+
`,l+=kn.repeat("-",t.indent+h+3+u.pos)+`^
|
|
343
|
+
`,c=1;c<=t.linesAfter&&!(i+c>=s.length);c++)u=Bd(e.buffer,r[i+c],s[i+c],e.position-(r[i]-r[i+c]),f),l+=kn.repeat(" ",t.indent)+Vd((e.line+c+1).toString(),h)+" | "+u.str+`
|
|
344
|
+
`;return l.replace(/\n$/,"")}var DD=MD,OD=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],LD=["scalar","sequence","mapping"];function FD(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function zD(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(OD.indexOf(n)===-1)throw new qn('Unknown option "'+n+'" is met in definition of "'+e+'" YAML type.')}),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(n){return n},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=FD(t.styleAliases||null),LD.indexOf(this.kind)===-1)throw new qn('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var Mn=zD;function dx(e,t){var n=[];return e[t].forEach(function(r){var s=n.length;n.forEach(function(a,i){a.tag===r.tag&&a.kind===r.kind&&a.multi===r.multi&&(s=i)}),n[s]=r}),n}function $D(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},t,n;function r(s){s.multi?(e.multi[s.kind].push(s),e.multi.fallback.push(s)):e[s.kind][s.tag]=e.fallback[s.tag]=s}for(t=0,n=arguments.length;t<n;t+=1)arguments[t].forEach(r);return e}function Xf(e){return this.extend(e)}Xf.prototype.extend=function(t){var n=[],r=[];if(t instanceof Mn)r.push(t);else if(Array.isArray(t))r=r.concat(t);else if(t&&(Array.isArray(t.implicit)||Array.isArray(t.explicit)))t.implicit&&(n=n.concat(t.implicit)),t.explicit&&(r=r.concat(t.explicit));else throw new qn("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(a){if(!(a instanceof Mn))throw new qn("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(a.loadKind&&a.loadKind!=="scalar")throw new qn("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(a.multi)throw new qn("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),r.forEach(function(a){if(!(a instanceof Mn))throw new qn("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var s=Object.create(Xf.prototype);return s.implicit=(this.implicit||[]).concat(n),s.explicit=(this.explicit||[]).concat(r),s.compiledImplicit=dx(s,"implicit"),s.compiledExplicit=dx(s,"explicit"),s.compiledTypeMap=$D(s.compiledImplicit,s.compiledExplicit),s};var AC=Xf,IC=new Mn("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),RC=new Mn("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),PC=new Mn("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),MC=new AC({explicit:[IC,RC,PC]});function UD(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function BD(){return null}function VD(e){return e===null}var DC=new Mn("tag:yaml.org,2002:null",{kind:"scalar",resolve:UD,construct:BD,predicate:VD,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function HD(e){if(e===null)return!1;var t=e.length;return t===4&&(e==="true"||e==="True"||e==="TRUE")||t===5&&(e==="false"||e==="False"||e==="FALSE")}function WD(e){return e==="true"||e==="True"||e==="TRUE"}function ZD(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var OC=new Mn("tag:yaml.org,2002:bool",{kind:"scalar",resolve:HD,construct:WD,predicate:ZD,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function GD(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function qD(e){return 48<=e&&e<=55}function YD(e){return 48<=e&&e<=57}function KD(e){if(e===null)return!1;var t=e.length,n=0,r=!1,s;if(!t)return!1;if(s=e[n],(s==="-"||s==="+")&&(s=e[++n]),s==="0"){if(n+1===t)return!0;if(s=e[++n],s==="b"){for(n++;n<t;n++)if(s=e[n],s!=="_"){if(s!=="0"&&s!=="1")return!1;r=!0}return r&&s!=="_"}if(s==="x"){for(n++;n<t;n++)if(s=e[n],s!=="_"){if(!GD(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}if(s==="o"){for(n++;n<t;n++)if(s=e[n],s!=="_"){if(!qD(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}}if(s==="_")return!1;for(;n<t;n++)if(s=e[n],s!=="_"){if(!YD(e.charCodeAt(n)))return!1;r=!0}return!(!r||s==="_")}function XD(e){var t=e,n=1,r;if(t.indexOf("_")!==-1&&(t=t.replace(/_/g,"")),r=t[0],(r==="-"||r==="+")&&(r==="-"&&(n=-1),t=t.slice(1),r=t[0]),t==="0")return 0;if(r==="0"){if(t[1]==="b")return n*parseInt(t.slice(2),2);if(t[1]==="x")return n*parseInt(t.slice(2),16);if(t[1]==="o")return n*parseInt(t.slice(2),8)}return n*parseInt(t,10)}function JD(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!kn.isNegativeZero(e)}var LC=new Mn("tag:yaml.org,2002:int",{kind:"scalar",resolve:KD,construct:XD,predicate:JD,represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),QD=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function e6(e){return!(e===null||!QD.test(e)||e[e.length-1]==="_")}function t6(e){var t,n;return t=e.replace(/_/g,"").toLowerCase(),n=t[0]==="-"?-1:1,"+-".indexOf(t[0])>=0&&(t=t.slice(1)),t===".inf"?n===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:t===".nan"?NaN:n*parseFloat(t,10)}var n6=/^[-+]?[0-9]+e/;function r6(e,t){var n;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(kn.isNegativeZero(e))return"-0.0";return n=e.toString(10),n6.test(n)?n.replace("e",".e"):n}function s6(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||kn.isNegativeZero(e))}var FC=new Mn("tag:yaml.org,2002:float",{kind:"scalar",resolve:e6,construct:t6,predicate:s6,represent:r6,defaultStyle:"lowercase"}),zC=MC.extend({implicit:[DC,OC,LC,FC]}),$C=zC,UC=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),BC=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function o6(e){return e===null?!1:UC.exec(e)!==null||BC.exec(e)!==null}function a6(e){var t,n,r,s,a,i,l,c=0,u=null,h,f,p;if(t=UC.exec(e),t===null&&(t=BC.exec(e)),t===null)throw new Error("Date resolve error");if(n=+t[1],r=+t[2]-1,s=+t[3],!t[4])return new Date(Date.UTC(n,r,s));if(a=+t[4],i=+t[5],l=+t[6],t[7]){for(c=t[7].slice(0,3);c.length<3;)c+="0";c=+c}return t[9]&&(h=+t[10],f=+(t[11]||0),u=(h*60+f)*6e4,t[9]==="-"&&(u=-u)),p=new Date(Date.UTC(n,r,s,a,i,l,c)),u&&p.setTime(p.getTime()-u),p}function i6(e){return e.toISOString()}var VC=new Mn("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:o6,construct:a6,instanceOf:Date,represent:i6});function l6(e){return e==="<<"||e===null}var HC=new Mn("tag:yaml.org,2002:merge",{kind:"scalar",resolve:l6}),Dm=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
345
|
+
\r`;function c6(e){if(e===null)return!1;var t,n,r=0,s=e.length,a=Dm;for(n=0;n<s;n++)if(t=a.indexOf(e.charAt(n)),!(t>64)){if(t<0)return!1;r+=6}return r%8===0}function u6(e){var t,n,r=e.replace(/[\r\n=]/g,""),s=r.length,a=Dm,i=0,l=[];for(t=0;t<s;t++)t%4===0&&t&&(l.push(i>>16&255),l.push(i>>8&255),l.push(i&255)),i=i<<6|a.indexOf(r.charAt(t));return n=s%4*6,n===0?(l.push(i>>16&255),l.push(i>>8&255),l.push(i&255)):n===18?(l.push(i>>10&255),l.push(i>>2&255)):n===12&&l.push(i>>4&255),new Uint8Array(l)}function d6(e){var t="",n=0,r,s,a=e.length,i=Dm;for(r=0;r<a;r++)r%3===0&&r&&(t+=i[n>>18&63],t+=i[n>>12&63],t+=i[n>>6&63],t+=i[n&63]),n=(n<<8)+e[r];return s=a%3,s===0?(t+=i[n>>18&63],t+=i[n>>12&63],t+=i[n>>6&63],t+=i[n&63]):s===2?(t+=i[n>>10&63],t+=i[n>>4&63],t+=i[n<<2&63],t+=i[64]):s===1&&(t+=i[n>>2&63],t+=i[n<<4&63],t+=i[64],t+=i[64]),t}function f6(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var WC=new Mn("tag:yaml.org,2002:binary",{kind:"scalar",resolve:c6,construct:u6,predicate:f6,represent:d6}),h6=Object.prototype.hasOwnProperty,m6=Object.prototype.toString;function p6(e){if(e===null)return!0;var t=[],n,r,s,a,i,l=e;for(n=0,r=l.length;n<r;n+=1){if(s=l[n],i=!1,m6.call(s)!=="[object Object]")return!1;for(a in s)if(h6.call(s,a))if(!i)i=!0;else return!1;if(!i)return!1;if(t.indexOf(a)===-1)t.push(a);else return!1}return!0}function g6(e){return e!==null?e:[]}var ZC=new Mn("tag:yaml.org,2002:omap",{kind:"sequence",resolve:p6,construct:g6}),x6=Object.prototype.toString;function v6(e){if(e===null)return!0;var t,n,r,s,a,i=e;for(a=new Array(i.length),t=0,n=i.length;t<n;t+=1){if(r=i[t],x6.call(r)!=="[object Object]"||(s=Object.keys(r),s.length!==1))return!1;a[t]=[s[0],r[s[0]]]}return!0}function w6(e){if(e===null)return[];var t,n,r,s,a,i=e;for(a=new Array(i.length),t=0,n=i.length;t<n;t+=1)r=i[t],s=Object.keys(r),a[t]=[s[0],r[s[0]]];return a}var GC=new Mn("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:v6,construct:w6}),y6=Object.prototype.hasOwnProperty;function b6(e){if(e===null)return!0;var t,n=e;for(t in n)if(y6.call(n,t)&&n[t]!==null)return!1;return!0}function C6(e){return e!==null?e:{}}var qC=new Mn("tag:yaml.org,2002:set",{kind:"mapping",resolve:b6,construct:C6}),Om=$C.extend({implicit:[VC,HC],explicit:[WC,ZC,GC,qC]}),xo=Object.prototype.hasOwnProperty,Jc=1,YC=2,KC=3,Qc=4,Hd=1,S6=2,fx=3,_6=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,k6=/[\x85\u2028\u2029]/,j6=/[,\[\]\{\}]/,XC=/^(?:!|!!|![a-z\-]+!)$/i,JC=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function hx(e){return Object.prototype.toString.call(e)}function gs(e){return e===10||e===13}function $o(e){return e===9||e===32}function tr(e){return e===9||e===32||e===10||e===13}function Sa(e){return e===44||e===91||e===93||e===123||e===125}function E6(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function N6(e){return e===120?2:e===117?4:e===85?8:0}function T6(e){return 48<=e&&e<=57?e-48:-1}function mx(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
|
|
346
|
+
`:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"
":e===95?" ":e===76?"\u2028":e===80?"\u2029":""}function A6(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function QC(e,t,n){t==="__proto__"?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}var eS=new Array(256),tS=new Array(256);for(var pa=0;pa<256;pa++)eS[pa]=mx(pa)?1:0,tS[pa]=mx(pa);function I6(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||Om,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function nS(e,t){var n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=DD(n),new qn(t,n)}function st(e,t){throw nS(e,t)}function eu(e,t){e.onWarning&&e.onWarning.call(null,nS(e,t))}var px={YAML:function(t,n,r){var s,a,i;t.version!==null&&st(t,"duplication of %YAML directive"),r.length!==1&&st(t,"YAML directive accepts exactly one argument"),s=/^([0-9]+)\.([0-9]+)$/.exec(r[0]),s===null&&st(t,"ill-formed argument of the YAML directive"),a=parseInt(s[1],10),i=parseInt(s[2],10),a!==1&&st(t,"unacceptable YAML version of the document"),t.version=r[0],t.checkLineBreaks=i<2,i!==1&&i!==2&&eu(t,"unsupported YAML version of the document")},TAG:function(t,n,r){var s,a;r.length!==2&&st(t,"TAG directive accepts exactly two arguments"),s=r[0],a=r[1],XC.test(s)||st(t,"ill-formed tag handle (first argument) of the TAG directive"),xo.call(t.tagMap,s)&&st(t,'there is a previously declared suffix for "'+s+'" tag handle'),JC.test(a)||st(t,"ill-formed tag prefix (second argument) of the TAG directive");try{a=decodeURIComponent(a)}catch{st(t,"tag prefix is malformed: "+a)}t.tagMap[s]=a}};function lo(e,t,n,r){var s,a,i,l;if(t<n){if(l=e.input.slice(t,n),r)for(s=0,a=l.length;s<a;s+=1)i=l.charCodeAt(s),i===9||32<=i&&i<=1114111||st(e,"expected valid JSON character");else _6.test(l)&&st(e,"the stream contains non-printable characters");e.result+=l}}function gx(e,t,n,r){var s,a,i,l;for(kn.isObject(n)||st(e,"cannot merge mappings; the provided source object is unacceptable"),s=Object.keys(n),i=0,l=s.length;i<l;i+=1)a=s[i],xo.call(t,a)||(QC(t,a,n[a]),r[a]=!0)}function _a(e,t,n,r,s,a,i,l,c){var u,h;if(Array.isArray(s))for(s=Array.prototype.slice.call(s),u=0,h=s.length;u<h;u+=1)Array.isArray(s[u])&&st(e,"nested arrays are not supported inside keys"),typeof s=="object"&&hx(s[u])==="[object Object]"&&(s[u]="[object Object]");if(typeof s=="object"&&hx(s)==="[object Object]"&&(s="[object Object]"),s=String(s),t===null&&(t={}),r==="tag:yaml.org,2002:merge")if(Array.isArray(a))for(u=0,h=a.length;u<h;u+=1)gx(e,t,a[u],n);else gx(e,t,a,n);else!e.json&&!xo.call(n,s)&&xo.call(t,s)&&(e.line=i||e.line,e.lineStart=l||e.lineStart,e.position=c||e.position,st(e,"duplicated mapping key")),QC(t,s,a),delete n[s];return t}function Lm(e){var t;t=e.input.charCodeAt(e.position),t===10?e.position++:t===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):st(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function wn(e,t,n){for(var r=0,s=e.input.charCodeAt(e.position);s!==0;){for(;$o(s);)s===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),s=e.input.charCodeAt(++e.position);if(t&&s===35)do s=e.input.charCodeAt(++e.position);while(s!==10&&s!==13&&s!==0);if(gs(s))for(Lm(e),s=e.input.charCodeAt(e.position),r++,e.lineIndent=0;s===32;)e.lineIndent++,s=e.input.charCodeAt(++e.position);else break}return n!==-1&&r!==0&&e.lineIndent<n&&eu(e,"deficient indentation"),r}function qu(e){var t=e.position,n;return n=e.input.charCodeAt(t),!!((n===45||n===46)&&n===e.input.charCodeAt(t+1)&&n===e.input.charCodeAt(t+2)&&(t+=3,n=e.input.charCodeAt(t),n===0||tr(n)))}function Fm(e,t){t===1?e.result+=" ":t>1&&(e.result+=kn.repeat(`
|
|
347
|
+
`,t-1))}function R6(e,t,n){var r,s,a,i,l,c,u,h,f=e.kind,p=e.result,m;if(m=e.input.charCodeAt(e.position),tr(m)||Sa(m)||m===35||m===38||m===42||m===33||m===124||m===62||m===39||m===34||m===37||m===64||m===96||(m===63||m===45)&&(s=e.input.charCodeAt(e.position+1),tr(s)||n&&Sa(s)))return!1;for(e.kind="scalar",e.result="",a=i=e.position,l=!1;m!==0;){if(m===58){if(s=e.input.charCodeAt(e.position+1),tr(s)||n&&Sa(s))break}else if(m===35){if(r=e.input.charCodeAt(e.position-1),tr(r))break}else{if(e.position===e.lineStart&&qu(e)||n&&Sa(m))break;if(gs(m))if(c=e.line,u=e.lineStart,h=e.lineIndent,wn(e,!1,-1),e.lineIndent>=t){l=!0,m=e.input.charCodeAt(e.position);continue}else{e.position=i,e.line=c,e.lineStart=u,e.lineIndent=h;break}}l&&(lo(e,a,i,!1),Fm(e,e.line-c),a=i=e.position,l=!1),$o(m)||(i=e.position+1),m=e.input.charCodeAt(++e.position)}return lo(e,a,i,!1),e.result?!0:(e.kind=f,e.result=p,!1)}function P6(e,t){var n,r,s;if(n=e.input.charCodeAt(e.position),n!==39)return!1;for(e.kind="scalar",e.result="",e.position++,r=s=e.position;(n=e.input.charCodeAt(e.position))!==0;)if(n===39)if(lo(e,r,e.position,!0),n=e.input.charCodeAt(++e.position),n===39)r=e.position,e.position++,s=e.position;else return!0;else gs(n)?(lo(e,r,s,!0),Fm(e,wn(e,!1,t)),r=s=e.position):e.position===e.lineStart&&qu(e)?st(e,"unexpected end of the document within a single quoted scalar"):(e.position++,s=e.position);st(e,"unexpected end of the stream within a single quoted scalar")}function M6(e,t){var n,r,s,a,i,l;if(l=e.input.charCodeAt(e.position),l!==34)return!1;for(e.kind="scalar",e.result="",e.position++,n=r=e.position;(l=e.input.charCodeAt(e.position))!==0;){if(l===34)return lo(e,n,e.position,!0),e.position++,!0;if(l===92){if(lo(e,n,e.position,!0),l=e.input.charCodeAt(++e.position),gs(l))wn(e,!1,t);else if(l<256&&eS[l])e.result+=tS[l],e.position++;else if((i=N6(l))>0){for(s=i,a=0;s>0;s--)l=e.input.charCodeAt(++e.position),(i=E6(l))>=0?a=(a<<4)+i:st(e,"expected hexadecimal character");e.result+=A6(a),e.position++}else st(e,"unknown escape sequence");n=r=e.position}else gs(l)?(lo(e,n,r,!0),Fm(e,wn(e,!1,t)),n=r=e.position):e.position===e.lineStart&&qu(e)?st(e,"unexpected end of the document within a double quoted scalar"):(e.position++,r=e.position)}st(e,"unexpected end of the stream within a double quoted scalar")}function D6(e,t){var n=!0,r,s,a,i=e.tag,l,c=e.anchor,u,h,f,p,m,v=Object.create(null),g,x,w,y;if(y=e.input.charCodeAt(e.position),y===91)h=93,m=!1,l=[];else if(y===123)h=125,m=!0,l={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=l),y=e.input.charCodeAt(++e.position);y!==0;){if(wn(e,!0,t),y=e.input.charCodeAt(e.position),y===h)return e.position++,e.tag=i,e.anchor=c,e.kind=m?"mapping":"sequence",e.result=l,!0;n?y===44&&st(e,"expected the node content, but found ','"):st(e,"missed comma between flow collection entries"),x=g=w=null,f=p=!1,y===63&&(u=e.input.charCodeAt(e.position+1),tr(u)&&(f=p=!0,e.position++,wn(e,!0,t))),r=e.line,s=e.lineStart,a=e.position,Ka(e,t,Jc,!1,!0),x=e.tag,g=e.result,wn(e,!0,t),y=e.input.charCodeAt(e.position),(p||e.line===r)&&y===58&&(f=!0,y=e.input.charCodeAt(++e.position),wn(e,!0,t),Ka(e,t,Jc,!1,!0),w=e.result),m?_a(e,l,v,x,g,w,r,s,a):f?l.push(_a(e,null,v,x,g,w,r,s,a)):l.push(g),wn(e,!0,t),y=e.input.charCodeAt(e.position),y===44?(n=!0,y=e.input.charCodeAt(++e.position)):n=!1}st(e,"unexpected end of the stream within a flow collection")}function O6(e,t){var n,r,s=Hd,a=!1,i=!1,l=t,c=0,u=!1,h,f;if(f=e.input.charCodeAt(e.position),f===124)r=!1;else if(f===62)r=!0;else return!1;for(e.kind="scalar",e.result="";f!==0;)if(f=e.input.charCodeAt(++e.position),f===43||f===45)Hd===s?s=f===43?fx:S6:st(e,"repeat of a chomping mode identifier");else if((h=T6(f))>=0)h===0?st(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):i?st(e,"repeat of an indentation width identifier"):(l=t+h-1,i=!0);else break;if($o(f)){do f=e.input.charCodeAt(++e.position);while($o(f));if(f===35)do f=e.input.charCodeAt(++e.position);while(!gs(f)&&f!==0)}for(;f!==0;){for(Lm(e),e.lineIndent=0,f=e.input.charCodeAt(e.position);(!i||e.lineIndent<l)&&f===32;)e.lineIndent++,f=e.input.charCodeAt(++e.position);if(!i&&e.lineIndent>l&&(l=e.lineIndent),gs(f)){c++;continue}if(e.lineIndent<l){s===fx?e.result+=kn.repeat(`
|
|
348
|
+
`,a?1+c:c):s===Hd&&a&&(e.result+=`
|
|
349
|
+
`);break}for(r?$o(f)?(u=!0,e.result+=kn.repeat(`
|
|
350
|
+
`,a?1+c:c)):u?(u=!1,e.result+=kn.repeat(`
|
|
351
|
+
`,c+1)):c===0?a&&(e.result+=" "):e.result+=kn.repeat(`
|
|
352
|
+
`,c):e.result+=kn.repeat(`
|
|
353
|
+
`,a?1+c:c),a=!0,i=!0,c=0,n=e.position;!gs(f)&&f!==0;)f=e.input.charCodeAt(++e.position);lo(e,n,e.position,!1)}return!0}function xx(e,t){var n,r=e.tag,s=e.anchor,a=[],i,l=!1,c;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=a),c=e.input.charCodeAt(e.position);c!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,st(e,"tab characters must not be used in indentation")),!(c!==45||(i=e.input.charCodeAt(e.position+1),!tr(i))));){if(l=!0,e.position++,wn(e,!0,-1)&&e.lineIndent<=t){a.push(null),c=e.input.charCodeAt(e.position);continue}if(n=e.line,Ka(e,t,KC,!1,!0),a.push(e.result),wn(e,!0,-1),c=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&c!==0)st(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break}return l?(e.tag=r,e.anchor=s,e.kind="sequence",e.result=a,!0):!1}function L6(e,t,n){var r,s,a,i,l,c,u=e.tag,h=e.anchor,f={},p=Object.create(null),m=null,v=null,g=null,x=!1,w=!1,y;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=f),y=e.input.charCodeAt(e.position);y!==0;){if(!x&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,st(e,"tab characters must not be used in indentation")),r=e.input.charCodeAt(e.position+1),a=e.line,(y===63||y===58)&&tr(r))y===63?(x&&(_a(e,f,p,m,v,null,i,l,c),m=v=g=null),w=!0,x=!0,s=!0):x?(x=!1,s=!0):st(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,y=r;else{if(i=e.line,l=e.lineStart,c=e.position,!Ka(e,n,YC,!1,!0))break;if(e.line===a){for(y=e.input.charCodeAt(e.position);$o(y);)y=e.input.charCodeAt(++e.position);if(y===58)y=e.input.charCodeAt(++e.position),tr(y)||st(e,"a whitespace character is expected after the key-value separator within a block mapping"),x&&(_a(e,f,p,m,v,null,i,l,c),m=v=g=null),w=!0,x=!1,s=!1,m=e.tag,v=e.result;else if(w)st(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=u,e.anchor=h,!0}else if(w)st(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=u,e.anchor=h,!0}if((e.line===a||e.lineIndent>t)&&(x&&(i=e.line,l=e.lineStart,c=e.position),Ka(e,t,Qc,!0,s)&&(x?v=e.result:g=e.result),x||(_a(e,f,p,m,v,g,i,l,c),m=v=g=null),wn(e,!0,-1),y=e.input.charCodeAt(e.position)),(e.line===a||e.lineIndent>t)&&y!==0)st(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return x&&_a(e,f,p,m,v,null,i,l,c),w&&(e.tag=u,e.anchor=h,e.kind="mapping",e.result=f),w}function F6(e){var t,n=!1,r=!1,s,a,i;if(i=e.input.charCodeAt(e.position),i!==33)return!1;if(e.tag!==null&&st(e,"duplication of a tag property"),i=e.input.charCodeAt(++e.position),i===60?(n=!0,i=e.input.charCodeAt(++e.position)):i===33?(r=!0,s="!!",i=e.input.charCodeAt(++e.position)):s="!",t=e.position,n){do i=e.input.charCodeAt(++e.position);while(i!==0&&i!==62);e.position<e.length?(a=e.input.slice(t,e.position),i=e.input.charCodeAt(++e.position)):st(e,"unexpected end of the stream within a verbatim tag")}else{for(;i!==0&&!tr(i);)i===33&&(r?st(e,"tag suffix cannot contain exclamation marks"):(s=e.input.slice(t-1,e.position+1),XC.test(s)||st(e,"named tag handle cannot contain such characters"),r=!0,t=e.position+1)),i=e.input.charCodeAt(++e.position);a=e.input.slice(t,e.position),j6.test(a)&&st(e,"tag suffix cannot contain flow indicator characters")}a&&!JC.test(a)&&st(e,"tag name cannot contain such characters: "+a);try{a=decodeURIComponent(a)}catch{st(e,"tag name is malformed: "+a)}return n?e.tag=a:xo.call(e.tagMap,s)?e.tag=e.tagMap[s]+a:s==="!"?e.tag="!"+a:s==="!!"?e.tag="tag:yaml.org,2002:"+a:st(e,'undeclared tag handle "'+s+'"'),!0}function z6(e){var t,n;if(n=e.input.charCodeAt(e.position),n!==38)return!1;for(e.anchor!==null&&st(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;n!==0&&!tr(n)&&!Sa(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&st(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function $6(e){var t,n,r;if(r=e.input.charCodeAt(e.position),r!==42)return!1;for(r=e.input.charCodeAt(++e.position),t=e.position;r!==0&&!tr(r)&&!Sa(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&st(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),xo.call(e.anchorMap,n)||st(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],wn(e,!0,-1),!0}function Ka(e,t,n,r,s){var a,i,l,c=1,u=!1,h=!1,f,p,m,v,g,x;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,a=i=l=Qc===n||KC===n,r&&wn(e,!0,-1)&&(u=!0,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)),c===1)for(;F6(e)||z6(e);)wn(e,!0,-1)?(u=!0,l=a,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)):l=!1;if(l&&(l=u||s),(c===1||Qc===n)&&(Jc===n||YC===n?g=t:g=t+1,x=e.position-e.lineStart,c===1?l&&(xx(e,x)||L6(e,x,g))||D6(e,g)?h=!0:(i&&O6(e,g)||P6(e,g)||M6(e,g)?h=!0:$6(e)?(h=!0,(e.tag!==null||e.anchor!==null)&&st(e,"alias node should not have any properties")):R6(e,g,Jc===n)&&(h=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):c===0&&(h=l&&xx(e,x))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&st(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),f=0,p=e.implicitTypes.length;f<p;f+=1)if(v=e.implicitTypes[f],v.resolve(e.result)){e.result=v.construct(e.result),e.tag=v.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!=="!"){if(xo.call(e.typeMap[e.kind||"fallback"],e.tag))v=e.typeMap[e.kind||"fallback"][e.tag];else for(v=null,m=e.typeMap.multi[e.kind||"fallback"],f=0,p=m.length;f<p;f+=1)if(e.tag.slice(0,m[f].tag.length)===m[f].tag){v=m[f];break}v||st(e,"unknown tag !<"+e.tag+">"),e.result!==null&&v.kind!==e.kind&&st(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+v.kind+'", not "'+e.kind+'"'),v.resolve(e.result,e.tag)?(e.result=v.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):st(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||h}function U6(e){var t=e.position,n,r,s,a=!1,i;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(i=e.input.charCodeAt(e.position))!==0&&(wn(e,!0,-1),i=e.input.charCodeAt(e.position),!(e.lineIndent>0||i!==37));){for(a=!0,i=e.input.charCodeAt(++e.position),n=e.position;i!==0&&!tr(i);)i=e.input.charCodeAt(++e.position);for(r=e.input.slice(n,e.position),s=[],r.length<1&&st(e,"directive name must not be less than one character in length");i!==0;){for(;$o(i);)i=e.input.charCodeAt(++e.position);if(i===35){do i=e.input.charCodeAt(++e.position);while(i!==0&&!gs(i));break}if(gs(i))break;for(n=e.position;i!==0&&!tr(i);)i=e.input.charCodeAt(++e.position);s.push(e.input.slice(n,e.position))}i!==0&&Lm(e),xo.call(px,r)?px[r](e,r,s):eu(e,'unknown document directive "'+r+'"')}if(wn(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,wn(e,!0,-1)):a&&st(e,"directives end mark is expected"),Ka(e,e.lineIndent-1,Qc,!1,!0),wn(e,!0,-1),e.checkLineBreaks&&k6.test(e.input.slice(t,e.position))&&eu(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&qu(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,wn(e,!0,-1));return}if(e.position<e.length-1)st(e,"end of the stream or a document separator is expected");else return}function rS(e,t){e=String(e),t=t||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
|
|
354
|
+
`),e.charCodeAt(0)===65279&&(e=e.slice(1)));var n=new I6(e,t),r=e.indexOf("\0");for(r!==-1&&(n.position=r,st(n,"null byte is not allowed in input")),n.input+="\0";n.input.charCodeAt(n.position)===32;)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)U6(n);return n.documents}function B6(e,t,n){t!==null&&typeof t=="object"&&typeof n>"u"&&(n=t,t=null);var r=rS(e,n);if(typeof t!="function")return r;for(var s=0,a=r.length;s<a;s+=1)t(r[s])}function V6(e,t){var n=rS(e,t);if(n.length!==0){if(n.length===1)return n[0];throw new qn("expected a single document in the stream, but found more")}}var H6=B6,W6=V6,sS={loadAll:H6,load:W6},oS=Object.prototype.toString,aS=Object.prototype.hasOwnProperty,zm=65279,Z6=9,el=10,G6=13,q6=32,Y6=33,K6=34,Jf=35,X6=37,J6=38,Q6=39,eO=42,iS=44,tO=45,tu=58,nO=61,rO=62,sO=63,oO=64,lS=91,cS=93,aO=96,uS=123,iO=124,dS=125,zn={};zn[0]="\\0";zn[7]="\\a";zn[8]="\\b";zn[9]="\\t";zn[10]="\\n";zn[11]="\\v";zn[12]="\\f";zn[13]="\\r";zn[27]="\\e";zn[34]='\\"';zn[92]="\\\\";zn[133]="\\N";zn[160]="\\_";zn[8232]="\\L";zn[8233]="\\P";var lO=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],cO=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function uO(e,t){var n,r,s,a,i,l,c;if(t===null)return{};for(n={},r=Object.keys(t),s=0,a=r.length;s<a;s+=1)i=r[s],l=String(t[i]),i.slice(0,2)==="!!"&&(i="tag:yaml.org,2002:"+i.slice(2)),c=e.compiledTypeMap.fallback[i],c&&aS.call(c.styleAliases,l)&&(l=c.styleAliases[l]),n[i]=l;return n}function dO(e){var t,n,r;if(t=e.toString(16).toUpperCase(),e<=255)n="x",r=2;else if(e<=65535)n="u",r=4;else if(e<=4294967295)n="U",r=8;else throw new qn("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+n+kn.repeat("0",r-t.length)+t}var fO=1,tl=2;function hO(e){this.schema=e.schema||Om,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=kn.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=uO(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType==='"'?tl:fO,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer=="function"?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function vx(e,t){for(var n=kn.repeat(" ",t),r=0,s=-1,a="",i,l=e.length;r<l;)s=e.indexOf(`
|
|
355
|
+
`,r),s===-1?(i=e.slice(r),r=l):(i=e.slice(r,s+1),r=s+1),i.length&&i!==`
|
|
356
|
+
`&&(a+=n),a+=i;return a}function Qf(e,t){return`
|
|
357
|
+
`+kn.repeat(" ",e.indent*t)}function mO(e,t){var n,r,s;for(n=0,r=e.implicitTypes.length;n<r;n+=1)if(s=e.implicitTypes[n],s.resolve(t))return!0;return!1}function nu(e){return e===q6||e===Z6}function nl(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==zm||65536<=e&&e<=1114111}function wx(e){return nl(e)&&e!==zm&&e!==G6&&e!==el}function yx(e,t,n){var r=wx(e),s=r&&!nu(e);return(n?r:r&&e!==iS&&e!==lS&&e!==cS&&e!==uS&&e!==dS)&&e!==Jf&&!(t===tu&&!s)||wx(t)&&!nu(t)&&e===Jf||t===tu&&s}function pO(e){return nl(e)&&e!==zm&&!nu(e)&&e!==tO&&e!==sO&&e!==tu&&e!==iS&&e!==lS&&e!==cS&&e!==uS&&e!==dS&&e!==Jf&&e!==J6&&e!==eO&&e!==Y6&&e!==iO&&e!==nO&&e!==rO&&e!==Q6&&e!==K6&&e!==X6&&e!==oO&&e!==aO}function gO(e){return!nu(e)&&e!==tu}function Ri(e,t){var n=e.charCodeAt(t),r;return n>=55296&&n<=56319&&t+1<e.length&&(r=e.charCodeAt(t+1),r>=56320&&r<=57343)?(n-55296)*1024+r-56320+65536:n}function fS(e){var t=/^\n* /;return t.test(e)}var hS=1,eh=2,mS=3,pS=4,ya=5;function xO(e,t,n,r,s,a,i,l){var c,u=0,h=null,f=!1,p=!1,m=r!==-1,v=-1,g=pO(Ri(e,0))&&gO(Ri(e,e.length-1));if(t||i)for(c=0;c<e.length;u>=65536?c+=2:c++){if(u=Ri(e,c),!nl(u))return ya;g=g&&yx(u,h,l),h=u}else{for(c=0;c<e.length;u>=65536?c+=2:c++){if(u=Ri(e,c),u===el)f=!0,m&&(p=p||c-v-1>r&&e[v+1]!==" ",v=c);else if(!nl(u))return ya;g=g&&yx(u,h,l),h=u}p=p||m&&c-v-1>r&&e[v+1]!==" "}return!f&&!p?g&&!i&&!s(e)?hS:a===tl?ya:eh:n>9&&fS(e)?ya:i?a===tl?ya:eh:p?pS:mS}function vO(e,t,n,r,s){e.dump=function(){if(t.length===0)return e.quotingType===tl?'""':"''";if(!e.noCompatMode&&(lO.indexOf(t)!==-1||cO.test(t)))return e.quotingType===tl?'"'+t+'"':"'"+t+"'";var a=e.indent*Math.max(1,n),i=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-a),l=r||e.flowLevel>-1&&n>=e.flowLevel;function c(u){return mO(e,u)}switch(xO(t,l,e.indent,i,c,e.quotingType,e.forceQuotes&&!r,s)){case hS:return t;case eh:return"'"+t.replace(/'/g,"''")+"'";case mS:return"|"+bx(t,e.indent)+Cx(vx(t,a));case pS:return">"+bx(t,e.indent)+Cx(vx(wO(t,i),a));case ya:return'"'+yO(t)+'"';default:throw new qn("impossible error: invalid scalar style")}}()}function bx(e,t){var n=fS(e)?String(t):"",r=e[e.length-1]===`
|
|
358
|
+
`,s=r&&(e[e.length-2]===`
|
|
359
|
+
`||e===`
|
|
360
|
+
`),a=s?"+":r?"":"-";return n+a+`
|
|
361
|
+
`}function Cx(e){return e[e.length-1]===`
|
|
362
|
+
`?e.slice(0,-1):e}function wO(e,t){for(var n=/(\n+)([^\n]*)/g,r=function(){var u=e.indexOf(`
|
|
363
|
+
`);return u=u!==-1?u:e.length,n.lastIndex=u,Sx(e.slice(0,u),t)}(),s=e[0]===`
|
|
364
|
+
`||e[0]===" ",a,i;i=n.exec(e);){var l=i[1],c=i[2];a=c[0]===" ",r+=l+(!s&&!a&&c!==""?`
|
|
365
|
+
`:"")+Sx(c,t),s=a}return r}function Sx(e,t){if(e===""||e[0]===" ")return e;for(var n=/ [^ ]/g,r,s=0,a,i=0,l=0,c="";r=n.exec(e);)l=r.index,l-s>t&&(a=i>s?i:l,c+=`
|
|
366
|
+
`+e.slice(s,a),s=a+1),i=l;return c+=`
|
|
367
|
+
`,e.length-s>t&&i>s?c+=e.slice(s,i)+`
|
|
368
|
+
`+e.slice(i+1):c+=e.slice(s),c.slice(1)}function yO(e){for(var t="",n=0,r,s=0;s<e.length;n>=65536?s+=2:s++)n=Ri(e,s),r=zn[n],!r&&nl(n)?(t+=e[s],n>=65536&&(t+=e[s+1])):t+=r||dO(n);return t}function bO(e,t,n){var r="",s=e.tag,a,i,l;for(a=0,i=n.length;a<i;a+=1)l=n[a],e.replacer&&(l=e.replacer.call(n,String(a),l)),(Os(e,t,l,!1,!1)||typeof l>"u"&&Os(e,t,null,!1,!1))&&(r!==""&&(r+=","+(e.condenseFlow?"":" ")),r+=e.dump);e.tag=s,e.dump="["+r+"]"}function _x(e,t,n,r){var s="",a=e.tag,i,l,c;for(i=0,l=n.length;i<l;i+=1)c=n[i],e.replacer&&(c=e.replacer.call(n,String(i),c)),(Os(e,t+1,c,!0,!0,!1,!0)||typeof c>"u"&&Os(e,t+1,null,!0,!0,!1,!0))&&((!r||s!=="")&&(s+=Qf(e,t)),e.dump&&el===e.dump.charCodeAt(0)?s+="-":s+="- ",s+=e.dump);e.tag=a,e.dump=s||"[]"}function CO(e,t,n){var r="",s=e.tag,a=Object.keys(n),i,l,c,u,h;for(i=0,l=a.length;i<l;i+=1)h="",r!==""&&(h+=", "),e.condenseFlow&&(h+='"'),c=a[i],u=n[c],e.replacer&&(u=e.replacer.call(n,c,u)),Os(e,t,c,!1,!1)&&(e.dump.length>1024&&(h+="? "),h+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),Os(e,t,u,!1,!1)&&(h+=e.dump,r+=h));e.tag=s,e.dump="{"+r+"}"}function SO(e,t,n,r){var s="",a=e.tag,i=Object.keys(n),l,c,u,h,f,p;if(e.sortKeys===!0)i.sort();else if(typeof e.sortKeys=="function")i.sort(e.sortKeys);else if(e.sortKeys)throw new qn("sortKeys must be a boolean or a function");for(l=0,c=i.length;l<c;l+=1)p="",(!r||s!=="")&&(p+=Qf(e,t)),u=i[l],h=n[u],e.replacer&&(h=e.replacer.call(n,u,h)),Os(e,t+1,u,!0,!0,!0)&&(f=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,f&&(e.dump&&el===e.dump.charCodeAt(0)?p+="?":p+="? "),p+=e.dump,f&&(p+=Qf(e,t)),Os(e,t+1,h,!0,f)&&(e.dump&&el===e.dump.charCodeAt(0)?p+=":":p+=": ",p+=e.dump,s+=p));e.tag=a,e.dump=s||"{}"}function kx(e,t,n){var r,s,a,i,l,c;for(s=n?e.explicitTypes:e.implicitTypes,a=0,i=s.length;a<i;a+=1)if(l=s[a],(l.instanceOf||l.predicate)&&(!l.instanceOf||typeof t=="object"&&t instanceof l.instanceOf)&&(!l.predicate||l.predicate(t))){if(n?l.multi&&l.representName?e.tag=l.representName(t):e.tag=l.tag:e.tag="?",l.represent){if(c=e.styleMap[l.tag]||l.defaultStyle,oS.call(l.represent)==="[object Function]")r=l.represent(t,c);else if(aS.call(l.represent,c))r=l.represent[c](t,c);else throw new qn("!<"+l.tag+'> tag resolver accepts not "'+c+'" style');e.dump=r}return!0}return!1}function Os(e,t,n,r,s,a,i){e.tag=null,e.dump=n,kx(e,n,!1)||kx(e,n,!0);var l=oS.call(e.dump),c=r,u;r&&(r=e.flowLevel<0||e.flowLevel>t);var h=l==="[object Object]"||l==="[object Array]",f,p;if(h&&(f=e.duplicates.indexOf(n),p=f!==-1),(e.tag!==null&&e.tag!=="?"||p||e.indent!==2&&t>0)&&(s=!1),p&&e.usedDuplicates[f])e.dump="*ref_"+f;else{if(h&&p&&!e.usedDuplicates[f]&&(e.usedDuplicates[f]=!0),l==="[object Object]")r&&Object.keys(e.dump).length!==0?(SO(e,t,e.dump,s),p&&(e.dump="&ref_"+f+e.dump)):(CO(e,t,e.dump),p&&(e.dump="&ref_"+f+" "+e.dump));else if(l==="[object Array]")r&&e.dump.length!==0?(e.noArrayIndent&&!i&&t>0?_x(e,t-1,e.dump,s):_x(e,t,e.dump,s),p&&(e.dump="&ref_"+f+e.dump)):(bO(e,t,e.dump),p&&(e.dump="&ref_"+f+" "+e.dump));else if(l==="[object String]")e.tag!=="?"&&vO(e,e.dump,t,a,c);else{if(l==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new qn("unacceptable kind of an object to dump "+l)}e.tag!==null&&e.tag!=="?"&&(u=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?u="!"+u:u.slice(0,18)==="tag:yaml.org,2002:"?u="!!"+u.slice(18):u="!<"+u+">",e.dump=u+" "+e.dump)}return!0}function _O(e,t){var n=[],r=[],s,a;for(th(e,n,r),s=0,a=r.length;s<a;s+=1)t.duplicates.push(n[r[s]]);t.usedDuplicates=new Array(a)}function th(e,t,n){var r,s,a;if(e!==null&&typeof e=="object")if(s=t.indexOf(e),s!==-1)n.indexOf(s)===-1&&n.push(s);else if(t.push(e),Array.isArray(e))for(s=0,a=e.length;s<a;s+=1)th(e[s],t,n);else for(r=Object.keys(e),s=0,a=r.length;s<a;s+=1)th(e[r[s]],t,n)}function kO(e,t){t=t||{};var n=new hO(t);n.noRefs||_O(e,n);var r=e;return n.replacer&&(r=n.replacer.call({"":r},"",r)),Os(n,0,r,!0,!0)?n.dump+`
|
|
369
|
+
`:""}var jO=kO,EO={dump:jO};function $m(e,t){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+t+" instead, which is now safe by default.")}}var NO=Mn,TO=AC,AO=MC,IO=zC,RO=$C,PO=Om,MO=sS.load,DO=sS.loadAll,OO=EO.dump,LO=qn,FO={binary:WC,float:FC,map:PC,null:DC,pairs:GC,set:qC,timestamp:VC,bool:OC,int:LC,merge:HC,omap:ZC,seq:RC,str:IC},zO=$m("safeLoad","load"),$O=$m("safeLoadAll","loadAll"),UO=$m("safeDump","dump"),BO={Type:NO,Schema:TO,FAILSAFE_SCHEMA:AO,JSON_SCHEMA:IO,CORE_SCHEMA:RO,DEFAULT_SCHEMA:PO,load:MO,loadAll:DO,dump:OO,YAMLException:LO,types:FO,safeLoad:zO,safeLoadAll:$O,safeDump:UO};const VO=({content:e,rendererType:t,setRenderError:n})=>{const[r,s]=d.useState(!1);d.useEffect(()=>{n(null)},[e,n]);const[a,i]=d.useMemo(()=>{try{if(t==="yaml"){const l=BO.load(e);return[e,l]}else if(t==="json"){const l=JSON.parse(e);return[JSON.stringify(l,null,2),l]}throw new Error(`Unsupported renderer type: ${t}`)}catch(l){const c=t==="yaml"?"YAML":"JSON";console.error(`Error parsing ${c} for panel:`,l);const u={[`${c}_Parsing_Error`]:`The provided content is not valid ${c}.`,Details:l.message,Content_Snippet:e.substring(0,500)+(e.length>500?"...":"")};return n(`${c} parsing failed: ${l.message}`),[e,u]}},[e,t,n]);return o.jsxs("div",{className:"bg-background relative flex h-full flex-col overflow-hidden",children:[o.jsx("div",{className:"absolute top-4 right-4 z-10",children:o.jsx(ye,{onClick:()=>s(!r),title:r?"Show Structured View":"Show Raw Text",children:r?o.jsxs(o.Fragment,{children:[o.jsx(Iv,{})," Structured"]}):o.jsxs(o.Fragment,{children:[o.jsx(ph,{})," Raw Text"]})})}),o.jsx("div",{className:"flex min-h-0 flex-col",children:o.jsx("div",{className:"flex-1 overflow-auto",children:r?o.jsx(gS,{content:a,setRenderError:n}):o.jsx(fh,{data:i,maxDepth:4,className:"min-h-16 border-none p-2"})})})]})},gS=({content:e,className:t="",isStreaming:n})=>{const{ref:r,handleKeyDown:s}=_C();return n?o.jsx("div",{className:`overflow-auto p-4 ${t}`,children:o.jsx("div",{ref:r,className:"whitespace-pre-wrap select-text focus-visible:outline-none",tabIndex:0,onKeyDown:s,children:o.jsx(CC,{content:e})})}):o.jsx("div",{className:`overflow-auto p-4 ${t}`,children:o.jsx("pre",{ref:r,className:"whitespace-pre-wrap select-text focus-visible:outline-none",style:{overflowWrap:"anywhere"},tabIndex:0,onKeyDown:s,children:e})})};function HO(e){if(!e)return e;const t=/\n---\n\n## References\b/i,n=e.match(t);if(n&&n.index!==void 0)return e.substring(0,n.index).trim();const r=/\n## References\b/i,s=e.match(r);if(s&&s.index!==void 0)return e.substring(0,s.index).trim();const a=/\n## Research Methodology\b/i,i=e.match(a);return i&&i.index!==void 0?e.substring(0,i.index).trim():e}function Xa(e){return e?e.toLowerCase().endsWith("_report.md"):!1}const WO=({artifact:e,sessionId:t,ragData:n,onContentLoaded:r})=>{const[s,a]=d.useState(null),[i,l]=d.useState(null),[c,u]=d.useState(!1),[h,f]=d.useState(null),p=d.useMemo(()=>Xa(e.filename),[e.filename]);d.useEffect(()=>{i&&i!==e.filename&&(a(null),l(null),f(null))},[e.filename,i]),d.useEffect(()=>{(async()=>{if(!p||s&&i===e.filename)return;if(e.accumulatedContent){a(e.accumulatedContent),l(e.filename);return}const g=e.uri;if(g){u(!0),f(null);try{const x=Rc(g);if(!x)throw new Error("Invalid artifact URI.");const{sessionId:w,filename:y,version:C}=x,j=`/api/v1/artifacts/${w||t}/${encodeURIComponent(y)}/versions/${C||"latest"}`,I=await Ie.webui.get(j,{fullResponse:!0});if(!I.ok)throw new Error(`Failed to fetch artifact content: ${I.statusText}`);const b=await I.text();a(b),l(e.filename)}catch(x){console.error("Error fetching deep research report content:",x),f(x instanceof Error?x.message:"Unknown error fetching content.")}finally{u(!1)}}})()},[p,e,t,s,i]);const m=d.useMemo(()=>s?HO(s):null,[s]);return d.useEffect(()=>{m&&r&&r(m)},[m,r]),p?c?o.jsx("div",{className:"text-muted-foreground py-2 text-sm",children:"Loading report..."}):h?o.jsx("div",{className:"text-destructive py-2 text-sm",children:h}):m?o.jsx(EC,{content:m,setRenderError:()=>{},ragData:n}):null:null};function ZO({source:e,className:t="",size:n=16}){const r=W2(e.link);return o.jsx("div",{className:`relative box-content overflow-hidden rounded-full border border-[var(--color-secondary-w20)] bg-white ${t}`,style:{width:n,height:n},children:o.jsx("img",{src:Z2(r,n*2),alt:r,className:"relative h-full w-full",onError:s=>{const a=s.target;a.style.display="none";const i=a.parentElement;i&&(i.innerHTML=`<div class="flex items-center justify-center w-full h-full text-xs font-bold text-gray-600 bg-gray-200">${r[0].toUpperCase()}</div>`)}})})}function GO({sources:e,start:t=0,end:n=3,size:r=16}){const s=t<0?[t]:[t,n],a=e.slice(...s);return a.length===0?null:o.jsx("div",{className:"relative flex items-center",style:{height:r},children:a.map((i,l)=>o.jsx("div",{className:"relative",style:{marginLeft:l>0?-4:0,zIndex:l+1},children:o.jsx(ZO,{source:i,size:r})},`favicon-${l}`))})}function qO({ragMetadata:e,isDeepResearch:t=!1,onDeepResearchClick:n}){const r=d.useMemo(()=>{if(!(e!=null&&e.sources))return[];const s=[],a=new Set;return e.sources.forEach(i=>{var p,m,v,g;const l=i.sourceType||"web";let c,u;l==="image"?(c=i.sourceUrl||((p=i.metadata)==null?void 0:p.link)||"",u=((m=i.metadata)==null?void 0:m.title)||i.filename||"Image source"):(c=i.sourceUrl||((v=i.metadata)==null?void 0:v.link)||"",u=((g=i.metadata)==null?void 0:g.title)||i.filename||"");const h={link:c,title:u,snippet:i.contentPreview||"",attribution:i.filename||"",processed:!1,source_type:l},f=`${l}:${h.link}:${h.title}`;!h.link||a.has(f)||(a.add(f),s.push(h))}),s},[e]);return r.length===0?null:o.jsxs("div",{className:`flex items-center gap-2 rounded border border-gray-200 px-2 py-1 dark:border-gray-700 ${n?"cursor-pointer transition-colors hover:bg-gray-100 dark:hover:bg-gray-800/50":""}`,role:n?"button":void 0,"aria-label":t?"View deep research sources":"View web search sources",onClick:n,children:[o.jsx(GO,{sources:r,end:3,size:16}),o.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:[r.length," ",r.length===1?"source":"sources"]})]})}const xS=({images:e,maxVisible:t=6})=>{const[n,r]=d.useState(null),[s,a]=d.useState(new Set);if(!e||e.length===0)return null;const i=e.slice(0,t),l=e.length>t,c=g=>{a(x=>new Set(x).add(g))},u=g=>{r(g)},h=()=>{r(null)},f=g=>{g.stopPropagation(),n!==null&&n>0&&r(n-1)},p=g=>{g.stopPropagation(),n!==null&&n<e.length-1&&r(n+1)},m=n!==null?e[n]:null,v=()=>{const g=i.length;return g===1?"grid-cols-1":g===2?"grid-cols-2":"grid-cols-2 md:grid-cols-3"};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"mt-2",children:[o.jsx("div",{className:`grid ${v()} gap-2`,children:i.map((g,x)=>{const w=s.has(g.imageUrl);return o.jsx("div",{className:"group hover:border-primary dark:hover:border-primary relative aspect-video cursor-pointer overflow-hidden rounded-lg border border-gray-200 bg-gray-100 transition-all dark:border-gray-700 dark:bg-gray-800",onClick:()=>!w&&u(x),children:w?o.jsx("div",{className:"flex h-full w-full items-center justify-center text-gray-400 dark:text-gray-600",children:o.jsx("span",{className:"text-xs",children:"Failed to load"})}):o.jsxs(o.Fragment,{children:[o.jsx("img",{src:g.imageUrl,alt:g.title||`Image ${x+1}`,className:"h-full w-full object-cover transition-transform group-hover:scale-105",loading:"lazy",onError:()=>c(g.imageUrl)}),o.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/60 via-transparent to-transparent opacity-0 transition-opacity group-hover:opacity-100",children:o.jsx("div",{className:"absolute right-0 bottom-0 left-0 p-2",children:o.jsx("p",{className:"line-clamp-2 text-xs font-medium text-white",children:g.title||"View image"})})})]})},x)})}),l&&o.jsxs("p",{className:"mt-2 text-xs text-gray-500 italic dark:text-gray-400",children:["+",e.length-t," more images"]})]}),m&&n!==null&&o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/90 p-4",onClick:h,children:[n>0&&o.jsx("button",{onClick:f,className:"absolute left-4 z-10 text-white transition-colors hover:text-gray-300","aria-label":"Previous image",children:o.jsx(u_,{className:"h-12 w-12"})}),n<e.length-1&&o.jsx("button",{onClick:p,className:"absolute right-4 z-10 text-white transition-colors hover:text-gray-300","aria-label":"Next image",children:o.jsx(Rv,{className:"h-12 w-12"})}),o.jsxs("div",{className:"relative max-h-[90vh] max-w-[90vw] rounded-lg bg-white shadow-2xl dark:bg-gray-800",onClick:g=>g.stopPropagation(),children:[o.jsx("img",{src:m.imageUrl,alt:m.title||"Image",className:"max-h-[80vh] max-w-full rounded-t-lg object-contain"}),o.jsx("div",{className:"border-t border-gray-200 p-4 dark:border-gray-700",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("div",{className:"flex-1",children:m.title&&o.jsxs("a",{href:m.link,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm font-medium text-blue-600 hover:text-blue-700 hover:underline dark:text-blue-400 dark:hover:text-blue-300",children:[m.title,o.jsx(uo,{className:"h-3 w-3"})]})}),o.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[n+1," / ",e.length]})]})})]})]})]})},Um=({content:e,rendererType:t,mime_type:n,setRenderError:r,isStreaming:s,ragData:a})=>{switch(t){case"csv":return o.jsx(uD,{content:e,setRenderError:r});case"mermaid":return o.jsx(CD,{content:e,setRenderError:r});case"html":return o.jsx(dD,{content:e,setRenderError:r});case"json":case"yaml":return o.jsx(VO,{content:e,rendererType:t,setRenderError:r});case"image":return o.jsx(fD,{content:e,mime_type:n,setRenderError:r});case"markdown":return o.jsx(EC,{content:e,setRenderError:r,isStreaming:s,ragData:a});case"audio":return o.jsx(lD,{content:e,mime_type:n,setRenderError:r});default:return o.jsx(gS,{content:e,setRenderError:r,isStreaming:s})}},jx=({message:e})=>o.jsx("div",{className:"w-full rounded-lg border border-[var(--color-error-w100)] bg-[var(--color-error-wMain-50)] p-3",children:o.jsxs("div",{className:"text-sm text-[var(--color-error-wMain)]",children:["Error: ",e]})}),vS=({filename:e,description:t,mimeType:n,size:r,status:s,expandable:a=!1,expanded:i=!1,onToggleExpand:l,actions:c,bytesTransferred:u,error:h,expandedContent:f,context:p="chat",isDeleted:m=!1,version:v,source:g})=>{const[x,w]=d.useState(f),[y,C]=d.useState(()=>document.documentElement.classList.contains("dark"));if(d.useEffect(()=>{if(f)w(f);else{const M=setTimeout(()=>{w(void 0)},300);return()=>clearTimeout(M)}},[f]),d.useEffect(()=>{const M=new MutationObserver(()=>{C(document.documentElement.classList.contains("dark"))});return M.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>M.disconnect()},[]),!e||typeof e!="string")return console.error("ArtifactBar: filename is required and must be a string"),o.jsx(jx,{message:"Invalid artifact filename"});if(!s||!["in-progress","completed","failed"].includes(s))return console.error("ArtifactBar: status must be one of: in-progress, completed, failed"),o.jsx(jx,{message:"Invalid artifact status"});const j=(()=>{if(m)return{text:"Deleted",className:"text-[var(--color-secondary-foreground)]"};switch(s){case"in-progress":return{text:u?`Creating... ${ds(u)}`:"Creating...",className:"text-[var(--color-info-wMain)]"};case"failed":return{text:h||"Failed to create",className:"text-[var(--color-error-wMain)]"};case"completed":return{text:r?ds(r):""};default:return{text:"Unknown",className:"text-[var(--color-secondary-foreground)]"}}})(),b=((M,L=100)=>{if(!M||typeof M!="string")return"";const F=M.replace(/\s+/g," ").trim();if(F.length<=L)return F;const D=F.substring(0,L),O=D.lastIndexOf(" ");return O>L*.7?D.substring(0,O)+"...":D+"..."})(t),k=t&&t.trim(),N=()=>{if(s==="completed"&&(c!=null&&c.onPreview))try{c.onPreview()}catch(M){console.error("Preview failed:",M)}},A=y?"var(--color-background-wMain)":"var(--color-background-w10)",P=y?"0px 1px 4px 0px var(--color-primary-w90)":"0px 1px 4px 0px var(--color-secondary-w8040)",E=y?"0px 2px 8px 0px var(--color-primary-w90)":"0px 2px 8px 0px var(--color-secondary-w8040)",R=s==="completed"&&(c==null?void 0:c.onPreview)&&!m,_=p==="chat"&&!m;return o.jsxs("div",{className:`w-full ${R?"cursor-pointer":""} ${p==="list"?"border-b":""} ${m?"opacity-60":""} transition-shadow duration-200 ease-in-out`,style:{backgroundColor:A,boxShadow:_?P:void 0,borderRadius:p==="list"?void 0:"4px"},onMouseEnter:M=>{R&&(M.currentTarget.style.boxShadow=E)},onMouseLeave:M=>{R&&(M.currentTarget.style.boxShadow=P)},onClick:m?void 0:N,children:[o.jsxs("div",{className:"flex min-h-[60px] items-center gap-3 p-3",children:[o.jsx(XO,{filename:e,mimeType:n,size:r,className:"flex-shrink-0"}),o.jsxs("div",{className:"min-w-0 flex-1 py-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"truncate text-sm leading-tight font-semibold",title:k?t:e,children:k?b:e.length>50?`${e.substring(0,47)}...`:e}),g==="project"&&o.jsx(Yu,{})]}),o.jsx("div",{className:"text-secondary-foreground mt-1 flex items-center gap-2 text-xs leading-tight",title:k?e:j.text,children:k?o.jsxs("div",{className:"truncate",children:[e.length>60?`${e.substring(0,57)}...`:e,v!==void 0&&p==="chat"&&o.jsxs("span",{className:"ml-1.5",children:["(v",v,")"]})]}):o.jsxs(o.Fragment,{children:[s==="in-progress"&&o.jsx(ws,{size:"small",variant:"primary"}),o.jsx("span",{className:j.className,children:j.text})]})}),k&&o.jsxs("div",{className:Ue("mt-0.5 flex items-center gap-2 text-xs leading-tight",j.className),children:[s==="in-progress"&&o.jsx(ws,{size:"small",variant:"primary"}),o.jsx("span",{children:j.text})]})]}),o.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1",children:[s==="completed"&&(c==null?void 0:c.onInfo)&&!m&&o.jsx(ye,{variant:"ghost",size:"icon",onClick:M=>{var L;M.stopPropagation();try{(L=c.onInfo)==null||L.call(c)}catch(F){console.error("Info failed:",F)}},tooltip:"Info",children:o.jsx(ll,{className:"h-4 w-4"})}),s==="completed"&&(c==null?void 0:c.onDownload)&&!m&&o.jsx(ye,{variant:"ghost",size:"icon",onClick:M=>{var L;M.stopPropagation();try{(L=c.onDownload)==null||L.call(c)}catch(F){console.error("Download failed:",F)}},tooltip:"Download",children:o.jsx(yo,{className:"h-4 w-4"})}),s==="completed"&&(c==null?void 0:c.onExpand)&&!m&&o.jsx(ye,{variant:"ghost",size:"icon",onClick:M=>{var L;M.stopPropagation();try{(L=c.onExpand)==null||L.call(c)}catch(F){console.error("Expand failed:",F)}},tooltip:i?"Collapse":"Expand",children:i?o.jsx(Ua,{className:"h-4 w-4"}):o.jsx(Uo,{className:"h-4 w-4"})}),s==="completed"&&(c==null?void 0:c.onEdit)&&!m&&o.jsx(ye,{variant:"ghost",size:"icon",onClick:M=>{var L;M.stopPropagation();try{(L=c.onEdit)==null||L.call(c)}catch(F){console.error("Edit failed:",F)}},tooltip:"Edit Description",children:o.jsx(ys,{className:"h-4 w-4"})}),s==="completed"&&(c==null?void 0:c.onDelete)&&!m&&o.jsx(ye,{variant:"ghost",size:"icon",onClick:M=>{var L;M.stopPropagation();try{(L=c.onDelete)==null||L.call(c)}catch(F){console.error("Delete failed:",F)}},tooltip:"Delete",children:o.jsx(gh,{className:"h-4 w-4"})}),s==="failed"&&o.jsx("div",{className:"pr-4",title:"Artifact action failed",children:o.jsx(io,{className:"h-4 w-4 text-[var(--color-error-wMain)]"})})]}),a&&l&&!m&&o.jsx(ye,{variant:"ghost",size:"icon",onClick:M=>{M.stopPropagation();try{l()}catch(L){console.error("Toggle expand failed:",L)}},tooltip:i?"Collapse":"Expand",children:i?o.jsx(Ua,{className:"h-4 w-4 transition-transform duration-200"}):o.jsx(Uo,{className:"h-4 w-4 transition-transform duration-200"})})]}),o.jsx("div",{className:Ue("grid grid-rows-[0fr] transition-[grid-template-rows] duration-300 ease-in-out",i&&f&&"grid-rows-[1fr]"),children:o.jsx("div",{className:"overflow-hidden",children:x&&o.jsxs(o.Fragment,{children:[o.jsx("hr",{className:"border-t"}),o.jsx("div",{className:"p-3",children:x})]})})})]})},wS=({isVisible:e,message:t="Resolving embeds..."})=>e?o.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm transition-opacity duration-200",style:{opacity:e?1:0,pointerEvents:e?"auto":"none"},children:o.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-lg bg-card p-6 shadow-lg",children:[o.jsx(ur,{className:"h-6 w-6 animate-spin text-primary"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:t})]})}):null,yS=({description:e,size:t,lastModified:n,mimeType:r})=>o.jsxs("div",{className:"space-y-2 text-sm",children:[e&&o.jsxs("div",{children:[o.jsx("span",{className:"text-secondary-foreground",children:"Description:"}),o.jsx("div",{className:"mt-1",children:e})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{children:[o.jsx("span",{className:"text-secondary-foreground",children:"Size:"}),o.jsx("div",{children:ds(t)})]}),o.jsxs("div",{children:[o.jsx("span",{className:"text-secondary-foreground",children:"Modified:"}),o.jsx("div",{children:Pc(n)})]})]}),r&&o.jsxs("div",{children:[o.jsx("span",{className:"text-secondary-foreground",children:"Type:"}),o.jsx("div",{children:r})]})]}),Pi=e=>{var q;const{artifacts:t,setPreviewArtifact:n,openSidePanelTab:r,sessionId:s,openDeleteModal:a,markArtifactAsDisplayed:i,downloadAndResolveArtifact:l,navigateArtifactVersion:c,ragData:u}=$t(),{activeProject:h}=Bs(),[f,p]=d.useState(!1),[m,v]=d.useState(null),[g,x]=d.useState(null),[w,y]=d.useState(null),[C,S]=d.useState(!1),[j,I]=d.useState(!1),b=d.useMemo(()=>t.find(B=>B.filename===e.name),[t,e.name]),k=e.context||"chat",N=e.isStreaming,A=(b==null?void 0:b.source)==="project",P=d.useMemo(()=>{const B=e.status==="completed"?e.fileAttachment:void 0;if(B!=null&&B.uri){const ee=Rc(B.uri);return(ee==null?void 0:ee.version)!==null&&(ee==null?void 0:ee.version)!==void 0?parseInt(ee.version):void 0}},[e]),E=e.status==="completed"?e.fileAttachment:void 0,R=(E==null?void 0:E.name)||e.name,_=E==null?void 0:E.mime_type,M=d.useMemo(()=>e.status==="completed"&&!b,[e.status,b]),L=d.useMemo(()=>{if(M||Xa(R))return!1;const B=Hr(R,_),ee=B==="image"||B==="audio"||B==="markdown",U=R.toLowerCase().endsWith(".txt")||R.toLowerCase().endsWith(".text");return(ee||B==="text"&&U)&&k==="chat"},[R,_,k,M]),{shouldRender:F,isExpandable:D,isExpanded:O,toggleExpanded:K}=BR({filename:R,mimeType:_,shouldAutoExpand:L}),$=d.useCallback(async()=>{b&&(r("files"),n(b),P!==void 0&&setTimeout(async()=>{await c(b.filename,P)},100))},[b,r,n,P,c]),W=d.useCallback(()=>{let B=null;b?(B={name:b.filename,mime_type:b.mime_type,uri:b.uri,size:b.size,last_modified:b.last_modified},!B.uri&&(E!=null&&E.content)&&(B.content=E.content)):E&&(B=E),B?Zw(B,s,h==null?void 0:h.id):console.error(`No file to download for artifact: ${e.name}`)},[b,E,s,h==null?void 0:h.id,e.name]),V=d.useCallback(()=>{b&&a(b)},[b,a]),X=d.useCallback(()=>{S(!C)},[C]);d.useEffect(()=>{const B=b==null?void 0:b.filename;return F&&B&&i(B,!0),()=>{B&&i(B,!1)}},[F,b==null?void 0:b.filename,i]);const H=d.useMemo(()=>Hr(R,_)==="image",[R,_]),Q=d.useMemo(()=>{const B=Hr(R,_);return B==="text"||B==="markdown"},[R,_]);d.useEffect(()=>{e.status==="in-progress"&&(b!=null&&b.accumulatedContent)&&F&&x(b.accumulatedContent)},[b==null?void 0:b.accumulatedContent,e.status,R,F,O]),d.useEffect(()=>{(async()=>{if(b!=null&&b.needsEmbedResolution&&e.status==="completed"&&F&&!j){I(!0);try{const ee=await l(b.filename);ee!=null&&ee.content&&x(ee.content)}catch(ee){console.error(`Error downloading ${R}:`,ee)}finally{I(!1)}}})()},[b==null?void 0:b.needsEmbedResolution,e.status,F,R,b==null?void 0:b.filename,l,j]),d.useEffect(()=>{(async()=>{if(f||!F)return;if(e.status==="in-progress"){b!=null&&b.accumulatedContent&&x(b.accumulatedContent);return}if(e.status!=="completed")return;if(b!=null&&b.accumulatedContent){x(b.accumulatedContent);return}const ee=E==null?void 0:E.content;if(g||ee){ee&&!g&&x(ee);return}const U=E==null?void 0:E.uri;if(U){p(!0),v(null);try{const Y=Rc(U);if(!Y)throw new Error("Invalid artifact URI.");const{sessionId:G,filename:ae,version:oe}=Y;let se;const me=G||s;me&&me.trim()&&me!=="null"&&me!=="undefined"?se=`/api/v1/artifacts/${me}/${encodeURIComponent(ae)}/versions/${oe||"latest"}`:h!=null&&h.id?se=`/api/v1/artifacts/null/${encodeURIComponent(ae)}/versions/${oe||"latest"}?project_id=${h.id}`:se=`/api/v1/artifacts/null/${encodeURIComponent(ae)}/versions/${oe||"latest"}`;const Pe=await Ie.webui.get(se,{fullResponse:!0});if(!Pe.ok)throw new Error(`Failed to fetch artifact content: ${Pe.statusText}`);const Ne=await Pe.blob(),dt=await new Promise((Ht,wt)=>{const Ot=new FileReader;Ot.onloadend=()=>{typeof Ot.result=="string"?Ht(Ot.result.split(",")[1]):wt(new Error("Failed to read artifact content as a data URL."))},Ot.onerror=()=>{wt(Ot.error||new Error("An unknown error occurred while reading the file."))},Ot.readAsDataURL(Ne)});x(dt)}catch(Y){console.error("Error fetching inline content:",Y),v(Y instanceof Error?Y.message:"Unknown error fetching content.")}finally{p(!1)}}})()},[e.status,F,E,s,h==null?void 0:h.id,f,g,b==null?void 0:b.accumulatedContent,R,O,b]);const z=d.useMemo(()=>{var B;if(!(!((B=e.message)!=null&&B.taskId)||!u))return u.find(ee=>{var U;return ee.taskId===((U=e.message)==null?void 0:U.taskId)})},[(q=e.message)==null?void 0:q.taskId,u]),Z=d.useMemo(()=>{if(e.status!=="failed")return k==="list"?{onInfo:X,onDownload:e.status==="completed"?W:void 0,onDelete:b&&e.status==="completed"&&!A?V:void 0}:{onPreview:e.status==="completed"?$:void 0,onDownload:e.status==="completed"?W:void 0,onInfo:X}},[e.status,k,W,b,V,X,$,A]),J=d.useMemo(()=>t.find(B=>B.filename===e.name),[t,e.name]),ce=J==null?void 0:J.description,de=g||(E==null?void 0:E.content),fe=Hr(R,_);let ge=null;if(f)ge=o.jsx("div",{className:"bg-muted flex h-25 items-center justify-center",children:o.jsx(ws,{})});else if(m)ge=o.jsx(Xt,{variant:"error",message:m});else if(de&&fe)try{const ee=$y({...E||{name:R,mime_type:_},content:de,isPlainText:(b==null?void 0:b.isAccumulatedContentPlainText)&&g===(b==null?void 0:b.accumulatedContent)||e.status==="in-progress"&&!!g});if(ee){let U,Y,G;H?(U="none",G="visible"):Q?(U="6000px",G="auto"):fe==="audio"?(U="300px",G="auto"):fe==="html"?(Y="600px",U="600px",G="auto"):(U="600px",G="auto"),ge=o.jsxs("div",{className:"group relative max-w-full overflow-hidden",children:[w&&o.jsx(Xt,{variant:"error",message:w}),o.jsx("div",{style:{height:Y,maxHeight:U,overflowY:G},className:H?"drop-shadow-md":"",children:o.jsx(Um,{content:ee,rendererType:fe,mime_type:E==null?void 0:E.mime_type,setRenderError:y,isStreaming:N,ragData:z})}),o.jsx(wS,{isVisible:j,message:"Resolving embeds..."})]})}}catch(B){console.error("Failed to process file content:",B),ge=o.jsx(Xt,{variant:"error",message:"Failed to process file content for rendering"})}const T=F&&O,le=d.useMemo(()=>!C||!b?null:o.jsx(yS,{description:b.description??void 0,size:b.size,lastModified:b.last_modified,mimeType:b.mime_type}),[C,b]),ie=d.useMemo(()=>{const B=C&&le,ee=T&≥if(B&&ee)return o.jsxs("div",{className:"space-y-4",children:[le,o.jsx("hr",{className:"border-t"}),ge]});if(B)return le;if(ee)return ge},[C,le,T,ge]);return o.jsx(vS,{filename:R,description:ce||"",mimeType:_,size:E==null?void 0:E.size,status:e.status,expandable:D&&k==="chat"&&!Xa(R),expanded:O||C,onToggleExpand:D&&k==="chat"?K:void 0,actions:Z,bytesTransferred:e.status==="in-progress"?e.bytesTransferred:void 0,error:e.status==="failed"?e.error:void 0,expandedContent:ie,context:k,isDeleted:M,version:P,source:b==null?void 0:b.source})},Bm=e=>{const t=e.split(".");return t.length>1?t[t.length-1].toUpperCase():"FILE"},Or=e=>{switch(e){case"html":return"bg-[#e34c26]";case"json":return"bg-[#fbc02d] text-[#333]";case"yaml":return"bg-[#cb171e]";case"markdown":return"bg-[#6c757d]";case"text":return"bg-[#5c6bc0]";default:return"bg-gray-500"}},YO=(e,t)=>{const n={className:"text-secondary-foreground/60"};if(e){if(e.startsWith("image/"))return o.jsx(sf,{...n});if(e.startsWith("video/"))return o.jsx(ep,{...n});if(e.startsWith("audio/"))return o.jsx(rf,{...n});if(e==="application/pdf")return o.jsx(Sr,{...n});if(e==="application/zip"||e==="application/x-zip-compressed"||e==="application/x-rar-compressed"||e==="application/x-tar"||e==="application/gzip")return o.jsx(tp,{...n});if(e.includes("word")||e.includes("document"))return o.jsx(Sr,{...n});if(e.includes("excel")||e.includes("spreadsheet"))return o.jsx(nf,{...n});if(e.includes("powerpoint")||e.includes("presentation"))return o.jsx(np,{...n});if(e==="application/x-executable"||e==="application/x-msdownload")return o.jsx($i,{...n})}switch(t?Bm(t).toLowerCase():""){case"jpg":case"jpeg":case"png":case"gif":case"bmp":case"webp":case"svg":case"ico":return o.jsx(sf,{...n});case"mp4":case"avi":case"mov":case"wmv":case"flv":case"webm":case"mkv":return o.jsx(ep,{...n});case"mp3":case"wav":case"flac":case"aac":case"ogg":case"m4a":return o.jsx(rf,{...n});case"pdf":case"doc":case"docx":return o.jsx(Sr,{...n});case"xls":case"xlsx":case"csv":return o.jsx(nf,{...n});case"ppt":case"pptx":return o.jsx(np,{...n});case"zip":case"rar":case"7z":case"tar":case"gz":return o.jsx(tp,{...n});case"exe":case"msi":case"dmg":case"pkg":case"deb":case"rpm":return o.jsx($i,{...n});case"ttf":case"otf":case"woff":case"woff2":return o.jsx(Pv,{...n});case"htm":case"html":return o.jsx(Cv,{...n});default:return null}},KO=(e,t)=>{if(e){if(e.startsWith("text/html")||e==="application/xhtml+xml")return Or("html");if(e==="application/json"||e==="text/json")return Or("json");if(e==="application/yaml"||e==="text/yaml"||e==="application/x-yaml"||e==="text/x-yaml")return Or("yaml");if(e.startsWith("text/"))return Or("text");if(e.startsWith("text/markdown")||e==="application/markdown")return Or("markdown")}switch(t?Bm(t).toLowerCase():""){case"html":case"htm":return Or("html");case"json":return Or("json");case"yaml":case"yml":return Or("yaml");case"md":case"markdown":return Or("markdown");case"txt":return Or("text");default:return Or("default")}},XO=({filename:e,mimeType:t,className:n})=>{if(!e||typeof e!="string")return console.warn("FileIcon: filename is required and must be a string"),null;const r=Bm(e),s=KO(t,e),a=YO(t,e);return o.jsx("div",{className:Ue("relative flex-shrink-0",n),children:o.jsxs("div",{className:"bg-muted/50 relative h-[75px] w-[60px] border",children:[o.jsx("div",{className:"absolute top-[4px] right-[4px] bottom-[24px] left-[4px] overflow-hidden font-mono text-[3.5px] leading-[1.4]",children:a?o.jsx("div",{className:"flex h-full items-center justify-center",children:a}):o.jsx("div",{className:"text-secondary-foreground flex h-full text-[8px] select-none",children:o.jsx("div",{className:"flex h-full w-full items-center justify-center",children:o.jsx(kc,{className:"text-secondary-foreground/60"})})})}),o.jsx("div",{className:Ue("absolute right-[4px] bottom-[4px] z-[4] px-[4px] py-[2px] text-[10px] font-bold text-[var(--color-primary-text-w10)] select-none",s),children:r.length>4?r.substring(0,4):r})]})})},bS=({filename:e,mimeType:t,className:n,onDownload:r,isEmbedded:s=!1})=>{const{artifacts:a,setPreviewArtifact:i,openSidePanelTab:l}=$t(),c=d.useMemo(()=>a.find(p=>p.filename===e),[a,e]),u=d.useMemo(()=>zR(c||{filename:e,mime_type:t||""}),[c,e,t]),h=d.useCallback(p=>{p.stopPropagation(),c&&(l("files"),i(c))},[c,l,i]),f=d.useCallback(()=>{r&&r()},[r]);return o.jsxs("div",{className:`flex h-11 max-w-xs flex-shrink items-center gap-2 rounded-lg bg-[var(--message-background)] px-2 py-1 ${n||""}`,children:[u,o.jsx("span",{className:"min-w-0 flex-1 truncate text-sm leading-9",title:e,children:o.jsx("strong",{children:o.jsx("code",{children:e})})}),c&&!s&&o.jsx(ye,{variant:"ghost",onClick:h,tooltip:"Preview",children:o.jsx(Iv,{className:"h-4 w-4"})}),r&&o.jsx(ye,{variant:"ghost",onClick:f,tooltip:"Download file",children:o.jsx(yo,{className:"h-4 w-4"})})]})},JO={LAYOUT:"layout"},Wn=({label:e,value:t,icon:n,fullWidthValue:r=!1})=>t==null||typeof t=="string"&&!t.trim()?null:o.jsxs("div",{className:`mb-1.5 flex text-sm ${r?"flex-col items-start":"items-center"}`,children:[o.jsxs("div",{className:"flex w-36 flex-shrink-0 items-center text-sm font-semibold text-nowrap",children:[n&&o.jsx("span",{className:"mr-2",children:n}),e,":"]}),o.jsx("div",{className:`text-accent-foreground text-sm ${r?"mt-1 w-full":"truncate"}`,title:typeof t=="string"?t:void 0,children:t})]}),QO=({agent:e,isExpanded:t,onToggleExpand:n})=>{const r=l=>!l||Object.keys(l).length===0?o.jsx("span",{className:"text-sm",children:"N/A"}):o.jsx("ul",{className:"list-inside list-disc pl-1",children:Object.entries(l).map(([c,u])=>o.jsxs("li",{className:"text-sm",children:[o.jsxs("span",{className:"capitalize",children:[c.replace(/_/g," "),":"]})," ",u?"Yes":"No"]},c))}),s=(l,c="None")=>!l||l.length===0?o.jsx("span",{children:c}):l.map(u=>o.jsx("span",{className:"mr-1 mb-1 inline-block rounded-full px-2 py-0.5 text-xs font-medium",children:u},u)),a=l=>!l||l.length===0?o.jsx("span",{children:"No skills listed"}):o.jsx("div",{className:"space-y-1",children:l.map(c=>o.jsxs("div",{className:"rounded p-1.5 text-xs",children:[o.jsx("p",{className:"font-semibold",children:c.name}),o.jsx("p",{children:c.description})]},c.id||c.name))}),i=l=>!l||l.length===0?o.jsx("span",{children:"No tools listed"}):o.jsx("div",{className:"space-y-1",children:l.map(c=>o.jsxs("div",{className:"rounded p-1.5 text-xs",children:[o.jsx("p",{className:"text-foreground font-semibold",children:c.name}),o.jsx("p",{className:"mb-1",children:c.description})]},c.name))});return o.jsx("div",{className:"bg-card h-[400px] w-full flex-shrink-0 cursor-pointer rounded-lg sm:w-[380px]",onClick:n,role:"button",tabIndex:0,"aria-expanded":t,children:o.jsxs("div",{className:`transform-style-preserve-3d relative h-full w-full transition-transform duration-700 ${t?"rotate-y-180":""}`,style:{transformStyle:"preserve-3d"},children:[o.jsxs("div",{className:"absolute flex h-full w-full flex-col overflow-hidden rounded-lg border shadow-xl",style:{backfaceVisibility:"hidden",transform:"rotateY(0deg)"},children:[o.jsx("div",{className:"flex items-center p-4",children:o.jsxs("div",{className:"flex min-w-0 items-center",children:[o.jsx(cu,{className:"mr-3 h-8 w-8 flex-shrink-0 text-[var(--color-brand-wMain)]"}),o.jsx("div",{className:"min-w-0",children:o.jsx("h2",{className:"truncate text-xl font-semibold",title:e.name,children:e.displayName||e.name})})]})}),o.jsxs("div",{className:"scrollbar-themed flex-grow space-y-3 overflow-y-auto p-4",children:[o.jsx("div",{className:"mb-2 line-clamp-4 text-base",children:e.description||"No description provided."}),o.jsx(Wn,{label:"Version",value:e.version,icon:o.jsx(rp,{size:14})}),e.capabilities&&Object.keys(e.capabilities).length>0&&o.jsx(Wn,{label:"Key Capabilities",value:r(e.capabilities),icon:o.jsx(sp,{size:14}),fullWidthValue:!0})]}),o.jsx("div",{"data-testid":"clickForDetails",className:"text-accent-foreground border-t p-2 text-center text-sm",children:"Click for details"})]}),o.jsxs("div",{className:"absolute flex h-full w-full flex-col overflow-hidden rounded-lg border shadow-xl",style:{backfaceVisibility:"hidden",transform:"rotateY(180deg)"},children:[o.jsx("div",{className:"flex items-center p-3",children:o.jsxs("h3",{className:"text-md truncate font-semibold",title:e.name,children:["Details: ",e.displayName||e.name]})}),o.jsxs("div",{className:"scrollbar-themed flex-grow space-y-1.5 overflow-y-auto p-3 text-xs",children:[o.jsx(Wn,{label:"Name",value:e.name,icon:o.jsx(ll,{size:14})}),o.jsx(Wn,{label:"Description",value:e.description,icon:o.jsx(d_,{size:14}),fullWidthValue:!0}),o.jsx(Wn,{label:"Version",value:e.version,icon:o.jsx(rp,{size:14})}),o.jsx(Wn,{label:"Endpoint",value:e.url||"N/A",icon:o.jsx(Mv,{size:14})}),o.jsx(Wn,{label:"Docs",value:e.documentationUrl?o.jsx("a",{href:e.documentationUrl,target:"_blank",rel:"noopener noreferrer",className:"break-all",children:"View Docs"}):"N/A",icon:o.jsx(Tv,{size:14})}),e.provider&&o.jsxs("div",{className:"mt-1.5 border-t pt-1.5",children:[o.jsx("h4",{className:"mb-0.5 text-xs font-semibold",children:"Provider"}),o.jsx(Wn,{label:"Name",value:e.provider.organization}),o.jsx(Wn,{label:"URL",value:e.provider.url||"N/A"})]}),o.jsx(Wn,{label:"Capabilities",value:r(e.capabilities),icon:o.jsx(sp,{size:14}),fullWidthValue:!0}),o.jsx(Wn,{label:"Input Modes",value:s(e.defaultInputModes),icon:o.jsx(op,{size:14}),fullWidthValue:!0}),o.jsx(Wn,{label:"Output Modes",value:s(e.defaultOutputModes),icon:o.jsx(op,{size:14}),fullWidthValue:!0}),o.jsx(Wn,{label:"Skills",value:a(e.skills),icon:o.jsx(f_,{size:14}),fullWidthValue:!0}),o.jsx(Wn,{label:"Tools Info",value:i(e.tools),icon:o.jsx(ph,{size:14}),fullWidthValue:!0}),o.jsx("div",{className:"text-2xs mt-1.5 pt-1.5",children:o.jsx(Wn,{label:"A2A Protocol",value:e.protocolVersion})})]}),o.jsx("div",{className:"text-accent-foreground border-t p-2 text-center text-sm",children:"Click for summary"})]})]})})},eL=o.jsx(cu,{className:"text-muted-foreground",size:64}),CS=({agents:e})=>{const[t,n]=d.useState(null),[r,s]=d.useState(""),a=l=>{n(c=>c===l?null:l)},i=e.filter(l=>{var c;return(c=l.displayName||l.name)==null?void 0:c.toLowerCase().includes(r.toLowerCase())});return o.jsx(o.Fragment,{children:e.length===0?o.jsx(rr,{image:eL,title:"No agents found",subtitle:"No agents discovered in the current namespace."}):o.jsxs("div",{className:"bg-card-background h-full w-full pt-6 pl-6",children:[o.jsx(Qh,{value:r,onChange:s,placeholder:"Filter by name...",testid:"agentSearchInput",className:"mb-4 w-xs"}),i.length===0&&r?o.jsx(rr,{variant:"notFound",title:"No Agents Match Your Filter",subtitle:"Try adjusting your filter terms.",buttons:[{text:"Clear Filter",variant:"default",onClick:()=>s("")}]}):o.jsx("div",{className:"max-h-[calc(100vh-180px)] overflow-y-auto",children:o.jsx("div",{className:"flex flex-wrap gap-10",children:i.map(l=>o.jsx(QO,{agent:l,isExpanded:t===l.name,onToggleExpand:()=>a(l.name)},l.name))})})]})})};class tL{constructor(){la(this,"_plugins",{});this.registerDefaultPlugins()}get plugins(){return Object.values(this._plugins)}registerPlugin(t){this._plugins[t.id]&&console.warn(`Plugin with ID ${t.id} already exists. Overwriting.`),this._plugins[t.id]=t}getPluginById(t){return this._plugins[t]}getPluginsByType(t){return Object.values(this._plugins).filter(n=>n.type===t)}registerDefaultPlugins(){this.registerPlugin({type:JO.LAYOUT,id:"cards",label:"Cards",icon:h_,priority:100,render:t=>o.jsx(CS,{agents:t.agents||[]})})}renderPlugin(t,n){const r=this.getPluginById(t);if(r)return r.render(n)}}new tL;const Yu=({text:e="Project",className:t=""})=>o.jsxs(zs,{children:[o.jsx($s,{asChild:!0,children:o.jsx(go,{variant:"default",className:`max-w-[120px] ${t}`,children:o.jsx("span",{className:"block truncate font-semibold",children:e})})}),o.jsx(Us,{children:e})]}),nL=xt.memo(({isOpen:e,onClose:t,feedbackType:n,onSubmit:r})=>{const[s,a]=d.useState(""),[i,l]=d.useState(!1),c=d.useRef(null);d.useEffect(()=>{e&&(a(""),l(!1),setTimeout(()=>{var p;(p=c.current)==null||p.focus()},100))},[e]);const u=async()=>{l(!0);try{await r(s),t()}catch{l(!1)}},h=()=>{i||t()},f=n==="up"?"What did you like about the response?":"What did you dislike about the response?";return o.jsx(Nr,{open:e,onOpenChange:h,children:o.jsxs(Tr,{className:"sm:max-w-[750px]",showCloseButton:!1,children:[o.jsxs(rs,{children:[o.jsx(Ar,{children:"Provide Feedback"}),o.jsxs(Ir,{className:"flex flex-col gap-2",children:[o.jsx("span",{children:f}),o.jsx("span",{children:"Providing more details will help improve AI responses over time."})]})]}),o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsx(ts,{ref:c,value:s,onChange:p=>a(p.target.value),className:"min-h-[120px] text-sm",disabled:i}),o.jsx("p",{className:"text-muted-foreground text-xs",children:"Along with your feedback, details of the task will be recorded."})]}),o.jsxs(Cs,{children:[o.jsx(ye,{variant:"ghost",onClick:h,disabled:i,children:"Cancel"}),o.jsx(ye,{variant:"default",onClick:u,disabled:i,children:"Submit"})]})]})})}),rL={"application/pdf":"pdf","application/zip":"zip","application/msword":"doc","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"docx","application/vnd.ms-excel":"xls","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"xlsx","application/vnd.ms-powerpoint":"ppt","application/vnd.openxmlformats-officedocument.presentationml.presentation":"pptx","text/plain":"txt","text/csv":"csv","text/html":"html","text/markdown":"md","text/x-markdown":"md","application/json":"json","application/yaml":"yaml","text/yaml":"yaml","application/xml":"xml","text/xml":"xml","image/jpeg":"jpg","image/png":"png","image/gif":"gif","image/svg+xml":"svg","image/webp":"webp","image/bmp":"bmp","image/tiff":"tiff","audio/mpeg":"mp3","audio/wav":"wav","audio/ogg":"ogg","audio/aac":"aac","audio/flac":"flac","audio/x-m4a":"m4a","video/mp4":"mp4","video/webm":"webm","video/ogg":"ogv","application/javascript":"js","application/gzip":"gz","application/x-tar":"tar","application/rtf":"rtf"};function sL(e,t){const n=rL[e]||"bin";return`embedded_file_${t+1}.${n}`}function oL(e){if(!e||typeof e!="string")return[];const t=[],n=/data:([a-zA-Z0-9/.-]+);base64,([A-Za-z0-9+/=]+)/g;let r,s=0;for(;(r=n.exec(e))!==null;){const[a,i,l]=r,c=e[r.index-1],u=e[r.index+a.length];if(!(c==='"'&&u==='"'||c==="'"&&u==="'")&&l&&l.length>10){const h=Hr(void 0,i);h?t.push({type:h,content:l,mimeType:i,originalMatch:a}):t.push({type:"file",content:l,mimeType:i,originalMatch:a,filename:sL(i,s++)})}}return t}function aL(e){if(!e||typeof e!="string")return[];const t=[],n=/<html[\s\S]*?<\/html>/gi;let r;for(;(r=n.exec(e))!==null;)t.push({type:"html",content:r[0].trim(),originalMatch:r[0]});return t}function iL(e){if(!e||typeof e!="string")return[];const t=[],n=/```mermaid\s*\n([\s\S]*?)```/gi;let r;for(;(r=n.exec(e))!==null;){const[s,a]=r;t.push({type:"mermaid",content:a.trim(),originalMatch:s})}return t}function lL(e){return!e||typeof e!="string"?[]:[...oL(e),...aL(e),...iL(e)]}const cL=({message:e})=>{const{handleCancel:t,setMessages:n,isResponding:r,isCancelling:s}=$t();if(e.authenticationLink){const a=e.authenticationLink.authenticationAttempted||!1,i=e.authenticationLink.rejected||!1,l=()=>{if(a||i)return;n(f=>f.map(p=>{var m,v;return((m=p.metadata)==null?void 0:m.messageId)===((v=e.metadata)==null?void 0:v.messageId)&&p.authenticationLink?{...p,authenticationLink:{...p.authenticationLink,authenticationAttempted:!0}}:p}));const h=window.open(e.authenticationLink.url,"_blank","width=800,height=700,scrollbars=yes,resizable=yes");h&&h.focus()},c=async()=>{a||i||(n(h=>h.map(f=>{var p,m;return((p=f.metadata)==null?void 0:p.messageId)===((m=e.metadata)==null?void 0:m.messageId)&&f.authenticationLink?{...f,authenticationLink:{...f.authenticationLink,rejected:!0}}:f})),t())},u=e.authenticationLink.targetAgent||"Agent";return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"w-max rounded-lg border p-4",children:[o.jsx("div",{className:"font-semibold",children:"Action Needed"}),o.jsxs("div",{className:"py-4",children:['The "',u,'" agent requires authentication.']}),o.jsxs("div",{className:"flex flex-row flex-wrap justify-end gap-2",children:[o.jsx(ye,{variant:"ghost",onClick:c,disabled:a||i||!r||s,children:"Reject"}),o.jsx(ye,{onClick:l,disabled:a||i||!r||s,children:e.authenticationLink.text})]}),o.jsx("div",{className:"text-muted-foreground text-center text-xs",children:a&&o.jsx("div",{className:"mt-4",children:"Authentication window has been opened. Complete the process in the new window."})})]}),i&&o.jsx(Xt,{message:"Authentication request was rejected"})]})}return null},Ex=new Set;let Rn=null;function uL(e){return!e.parts||e.parts.length===0?"":e.parts.filter(n=>n.kind==="text").map(n=>n.text).join(" ").trim()}const dL=({message:e,className:t})=>{var P;const{settings:n,onTTSStart:r,onTTSEnd:s}=So(),{configFeatureEnablement:a}=on(),i=((P=e.metadata)==null?void 0:P.messageId)||"",l=d.useMemo(()=>uL(e),[e]),c=!e.isComplete,u=(a==null?void 0:a.textToSpeech)??!0,{isSpeaking:h,isLoading:f,speak:p,stop:m}=yP({messageId:i,onStart:()=>{r()},onEnd:()=>{Rn===i&&(Rn=null),s()},onError:E=>{console.error("TTS error:",E),Rn===i&&(Rn=null),s()}}),{isPlaying:v,isLoading:g,processStreamingText:x,stop:w}=wP({messageId:i,onStart:()=>{},onEnd:()=>{Rn===i&&(Rn=null)},onError:E=>{console.error("Streaming TTS error:",E),Rn===i&&(Rn=null)}}),y=c?v:h,C=c?g:f,S=d.useRef(!1),j=d.useRef(!1),[I,b]=d.useState(!1);d.useEffect(()=>{e.isComplete&&i&&(b(!0),Ex.add(i))},[]),d.useEffect(()=>{const E=n.conversationMode;if(E&&!e.isUser&&c&&l&&l.length>20&&!S.current){if(Rn&&Rn!==i)return;Rn=i,S.current=!0,x(l,!1)}else if(E&&!e.isUser&&c&&S.current)x(l,!1);else if(E&&!e.isUser&&e.isComplete&&S.current&&!j.current)j.current=!0,x(l,!0);else if(E&&!e.isUser&&e.isComplete&&!S.current&&!j.current&&l&&!I){if(Rn&&Rn!==i)return;Rn=i,S.current=!0,j.current=!0,x(l,!0)}},[n.conversationMode,n.automaticPlayback,e.isUser,c,e.isComplete,l,i,x,I]),d.useEffect(()=>{if(n.conversationMode&&!e.isUser&&e.isComplete&&l&&!y&&!C&&!j.current&&!S.current&&!I){if(Rn&&Rn!==i)return;Rn=i,j.current=!0;const R=setTimeout(()=>{p(l)},100);return()=>clearTimeout(R)}},[n.conversationMode,n.automaticPlayback,e.isUser,e.isComplete,l,y,C,i,p,I]),d.useEffect(()=>{j.current=!1,S.current=!1,e.isComplete&&i?(b(!0),Ex.add(i)):b(!1)},[i,e.isComplete]);const k=d.useCallback(async()=>{y?c?w():m():l&&(c?(S.current=!0,await x(l,!1)):await p(l))},[y,c,l,p,m,w,x]),N=()=>C?o.jsx(ur,{className:"size-4 animate-spin"}):y?o.jsx(m_,{className:"size-4"}):o.jsx(Ec,{className:"size-4"}),A=()=>y?"Stop reading":C?"Generating audio...":n.textToSpeech?"Read aloud":"Text-to-speech is disabled";return!u||!n.textToSpeech||!l?null:o.jsx(ye,{variant:"ghost",size:"icon",onClick:k,disabled:C||!l,className:Ue("size-8 transition-colors",y&&"bg-blue-50 hover:bg-blue-100 dark:bg-blue-950 dark:hover:bg-blue-900",t),tooltip:A(),"aria-label":y?"Stop reading aloud":"Read aloud","aria-pressed":y,"aria-busy":C,children:N()})},SS=({message:e,className:t,textContentOverride:n})=>{const{addNotification:r}=$t(),[s,a]=d.useState(!1),i=d.useRef(null),l=d.useCallback(()=>n||(!e.parts||e.parts.length===0?"":e.parts.filter(f=>f.kind==="text").map(f=>f.text).join("")),[e.parts,n]),c=d.useCallback(()=>{const h=l();h.trim()?navigator.clipboard.writeText(h.trim()).then(()=>{a(!0),r("Message copied to clipboard!","success")}).catch(f=>{console.error("Failed to copy text:",f)}):r("No text content to copy","info")},[l,r]);d.useEffect(()=>{if(s){const h=setTimeout(()=>a(!1),2e3);return()=>clearTimeout(h)}},[s]),d.useEffect(()=>{const h=f=>{f.ctrlKey&&f.shiftKey&&f.key.toLowerCase()==="c"&&(f.preventDefault(),c(),i.current&&(i.current.classList.add("bg-[var(--color-secondary-w20)]","dark:bg-[var(--color-secondary-w80)]"),setTimeout(()=>{var p;(p=i.current)==null||p.classList.remove("bg-[var(--color-secondary-w20)]","dark:bg-[var(--color-secondary-w80)]")},200)))};return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h)}},[c]);const u=d.useMemo(()=>n?{...e,parts:[{kind:"text",text:n}]}:e,[e,n]);return e.isStatusBubble||e.isStatusMessage?null:o.jsxs("div",{className:Ue("flex justify-start gap-1 text-gray-500",t),children:[!e.isUser&&o.jsx(dL,{message:u}),o.jsx(ye,{ref:i,variant:"ghost",size:"icon",className:"h-8 w-8",onClick:c,tooltip:s?"Copied!":"Copy to clipboard",children:s?o.jsx(ni,{className:"h-4 w-4 text-[var(--color-success-wMain)]"}):o.jsx(Nv,{className:"h-4 w-4"})})]})},fL=["image","audio"],Wd=({message:e,showWorkflowButton:t,showFeedbackActions:n,handleViewWorkflowClick:r,sourcesElement:s,textContentOverride:a})=>{var S;const{configCollectFeedback:i,submittedFeedback:l,handleFeedbackSubmit:c,addNotification:u}=$t(),[h,f]=d.useState(!1),[p,m]=d.useState(null),v=e.taskId,g=v?(S=l[v])==null?void 0:S.type:void 0,x=j=>{m(j),f(!0)},w=()=>{f(!1),m(null)},y=async j=>{!p||!v||(await c(v,p,j),u("Feedback submitted successfully","success"))},C=n&&i;return!t&&!C&&!s?null:o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"mt-3 space-y-2",children:o.jsxs("div",{className:"flex items-center justify-start",children:[t&&o.jsx(A0,{onClick:r}),C&&o.jsxs("div",{className:"flex items-center",children:[o.jsx(ye,{tooltip:"Like",variant:"ghost",size:"sm",className:`${g?"!opacity-100":""}`,onClick:()=>x("up"),disabled:!!g,children:o.jsx(p_,{className:`h-4 w-4 ${g==="up"?"fill-[var(--color-brand-wMain)] text-[var(--color-brand-wMain)] !opacity-100":""}`})}),o.jsx(ye,{tooltip:"Dislike",variant:"ghost",size:"sm",className:`${g?"!opacity-100":""}`,onClick:()=>x("down"),disabled:!!g,children:o.jsx(g_,{className:`h-4 w-4 ${g==="down"?"fill-[var(--color-brand-wMain)] text-[var(--color-brand-wMain)] opacity-100":""}`})})]}),o.jsx(SS,{message:e,textContentOverride:a}),s&&o.jsx("div",{className:"ml-2",children:s})]})}),p&&o.jsx(nL,{isOpen:h,onClose:w,feedbackType:p,onSubmit:y})]})},hL=xt.memo(({message:e,isStreaming:t})=>{var y,C;const[n,r]=d.useState(null),{sessionId:s,ragData:a,openSidePanelTab:i,setTaskIdInSidePanel:l}=$t(),c=((y=e.parts)==null?void 0:y.filter(S=>S.kind==="text").map(S=>S.text).join(""))||"",u=e.isUser?c.trim():c,h=d.useMemo(()=>{if(!e.taskId||!a)return;const S=a.filter(N=>N.taskId===e.taskId);if(S.length===0)return;if(S.length===1)return S[0];const j=S[S.length-1],I=S.flatMap(N=>N.sources||[]),b=new Set,k=I.filter(N=>{const A=N.citationId;return!A||b.has(A)?!1:(b.add(A),!0)});return{...j,sources:k}},[e.taskId,a]),f=d.useMemo(()=>e.isUser?[]:qf(u,h),[u,h,e.isUser]),p=()=>{e.taskId&&(l(e.taskId),i("rag"))},m=d.useMemo(()=>lL(u),[u]),{modifiedText:v,contentElements:g}=d.useMemo(()=>{if(m.length===0)return{modifiedText:u,contentElements:[]};let S=u;const j=[];return m.forEach((I,b)=>{if(S=S.replace(I.originalMatch,""),I.type==="file"){const k={name:I.filename||"downloaded_file",content:I.content,mime_type:I.mimeType};j.push(o.jsx("div",{className:"my-2",children:o.jsx(bS,{filename:k.name,mimeType:k.mime_type,onDownload:()=>Zw(k,s),isEmbedded:!0})},`embedded-file-${b}`))}else if(!fL.includes(I.type)){const k=Fy(I.content);k&&j.push(o.jsx("div",{className:"my-2 h-auto w-md max-w-md",children:o.jsx(Um,{content:k,rendererType:I.type,mime_type:I.mimeType,setRenderError:r,ragData:h})},`embedded-${b}`))}}),{modifiedText:S,contentElements:j}},[m,u,s,r,h]),x=d.useMemo(()=>e.isUser?[]:qf(v,h),[v,h,e.isUser]),w=()=>e.isError?o.jsxs("div",{className:"flex items-center",children:[o.jsx(io,{className:"mr-2 self-start text-[var(--color-error-wMain)]"}),o.jsx(Rs,{children:u})]}):m.length===0?t?o.jsx(Gf,{content:u,isStreaming:t}):f.length>0?o.jsx(Kf,{text:u,citations:f,onCitationClick:p}):o.jsx(Rs,{children:u}):o.jsxs("div",{children:[n&&o.jsx(Xt,{variant:"error",message:"Error rendering preview"}),t?o.jsx(Gf,{content:v,isStreaming:t}):x.length>0?o.jsx(Kf,{text:v,citations:x,onCitationClick:p}):o.jsx(Rs,{children:v}),g]});return e.isUser?w():o.jsx(gC,{messageId:((C=e.metadata)==null?void 0:C.messageId)||"",isAIMessage:!0,children:w()})}),mL=xt.memo(({message:e,children:t,className:n})=>o.jsx("div",{className:`mt-1 space-y-1 ${e.isUser?"ml-auto":"mr-auto"} ${n}`,children:t})),pL=e=>e.uploadedFiles&&e.uploadedFiles.length>0?o.jsx(mL,{message:e,className:"flex flex-wrap justify-end gap-2",children:e.uploadedFiles.map((t,n)=>{var r;return o.jsx(bS,{filename:t.name,mimeType:t.type},`uploaded-${(r=e.metadata)==null?void 0:r.messageId}-${n}`)})}):null,gL=({deepResearchReportInfo:e,message:t,onContentLoaded:n})=>{var r;return o.jsx(Tm,{variant:"received",children:o.jsx(Am,{variant:"received",children:o.jsx(gC,{messageId:((r=t.metadata)==null?void 0:r.messageId)||"",isAIMessage:!0,children:o.jsx(WO,{artifact:e.artifact,sessionId:e.sessionId,ragData:e.ragData,onContentLoaded:n})})})})},_S=(e,t,n,r,s,a,i,l)=>{var b,k,N,A,P,E;const{openSidePanelTab:c,setTaskIdInSidePanel:u,ragData:h}=t;if(e.isStatusBubble)return null;if(e.authenticationLink)return o.jsx(cL,{message:e});const f=(b=e.parts)==null?void 0:b.find(R=>R.kind==="data");if((f==null?void 0:f.data)&&f.data.type==="deep_research_progress"&&!e.isComplete){const R=f.data,_=h==null?void 0:h.filter(D=>D.taskId===e.taskId),M=(k=e.parts)==null?void 0:k.some(D=>D.kind==="text"&&D.text.trim()||D.kind==="artifact"||D.kind==="file"),L=o.jsx("div",{className:"my-2",children:o.jsx(SC,{progress:R,isComplete:!1,ragData:_})});if(!M)return L;const F={...e,parts:(N=e.parts)==null?void 0:N.filter(D=>D.kind!=="data")};return o.jsxs(o.Fragment,{children:[L,_S(F,t,n)]})}const m=[];let v="";if((A=e.parts)==null||A.forEach(R=>{R.kind==="text"?v+=R.text:(R.kind==="file"||R.kind==="artifact")&&(v&&(m.push({kind:"text",text:v}),v=""),m.push(R))}),v&&m.push({kind:"text",text:v}),!m.some(R=>R.kind==="text"&&R.text.trim()||R.kind==="file"||R.kind==="artifact"))return null;const x=e.isUser?"sent":"received",w=!e.isUser&&e.isComplete&&!!e.taskId&&!!n,y=!e.isUser&&e.isComplete&&!!e.taskId&&!!n,C=()=>{e.taskId&&(u(e.taskId),c("workflow"))},S=(R,_,M)=>{var F;const L=e.taskId?`${e.taskId}-${R.kind==="file"?R.file.name:R.name}`:(F=e.metadata)!=null&&F.messageId?`${e.metadata.messageId}-${R.kind==="file"?R.file.name:R.name}`:void 0;if(R.kind==="file"){const O=R.file,K={name:O.name||"untitled_file",mime_type:O.mimeType};return"bytes"in O&&O.bytes?K.content=O.bytes:"uri"in O&&O.uri&&(K.uri=O.uri),o.jsx(Pi,{status:"completed",name:K.name,fileAttachment:K,uniqueKey:L,message:e},`part-file-${_}`)}if(R.kind==="artifact"){const D=R;switch(D.status){case"completed":return o.jsx(Pi,{status:"completed",name:D.name,fileAttachment:D.file,uniqueKey:L,message:e},`part-artifact-${_}`);case"in-progress":return o.jsx(Pi,{status:"in-progress",name:D.name,bytesTransferred:D.bytesTransferred,uniqueKey:L,isStreaming:M,message:e},`part-artifact-${_}`);case"failed":return o.jsx(Pi,{status:"failed",name:D.name,error:D.error,uniqueKey:L,message:e},`part-artifact-${_}`);default:return null}}return null},j=m.length-1,I=(P=m[j])==null?void 0:P.kind;return o.jsxs("div",{className:"space-y-6",children:[m.map((R,_)=>{const M=_===j,L=r&&M;if(R.kind==="text"){const F=R.text;return!F||!F.trim()?M&&(w||y)?o.jsx("div",{className:`flex ${e.isUser?"justify-end pr-4":"justify-start pl-4"}`,children:o.jsx(Wd,{message:e,showWorkflowButton:!!w,showFeedbackActions:!!y,handleViewWorkflowClick:C,textContentOverride:l})},`part-${_}`):null:o.jsx(Tm,{variant:x,children:o.jsxs(Am,{variant:x,children:[o.jsx(hL,{message:{...e,parts:[{kind:"text",text:F}]},isStreaming:L}),M&&o.jsx(Wd,{message:e,showWorkflowButton:!!w,showFeedbackActions:!!y,handleViewWorkflowClick:C,sourcesElement:s,textContentOverride:l})]})},`part-${_}`)}else if(R.kind==="artifact"||R.kind==="file")return S(R,_,L);return null}),a&&o.jsx(gL,{deepResearchReportInfo:a,message:e,onContentLoaded:i}),I==="artifact"||I==="file"?o.jsx("div",{className:`flex ${e.isUser?"justify-end pr-4":"justify-start pl-4"}`,children:o.jsx(Wd,{message:e,showWorkflowButton:!!w,showFeedbackActions:!!y,handleViewWorkflowClick:C,sourcesElement:s,textContentOverride:l})}):null,e.isUser&&o.jsx("div",{className:"flex justify-end",children:o.jsx(SS,{message:e})})]},(E=e.metadata)==null?void 0:E.messageId)},xL=({message:e,isLastWithTaskId:t,isStreaming:n})=>{var S;const r=$t(),{ragData:s,openSidePanelTab:a,setTaskIdInSidePanel:i,artifacts:l,sessionId:c}=r,[u,h]=d.useState(null),f=d.useMemo(()=>{if(!(!(e!=null&&e.taskId)||!s))return s.filter(j=>j.taskId===e.taskId)},[e==null?void 0:e.taskId,s]),p=d.useMemo(()=>{var P,E,R;if(!e)return null;const j=(P=e.parts)==null?void 0:P.some(_=>{if(_.kind==="data"){const M=_.data;return(M==null?void 0:M.type)==="deep_research_progress"}return!1}),I=f&&f.length>0&&f.some(_=>_.sources&&_.sources.length>0),b=f==null?void 0:f.some(_=>_.searchType==="deep_research");if(!(e.isComplete&&(j||b)&&I)||!t)return null;const N=(E=e.parts)==null?void 0:E.filter(_=>_.kind==="artifact");if(N&&N.length>0){for(const _ of N)if(_.status==="completed"&&Xa(_.name)){const M=l.find(L=>L.filename===_.name);if(M)return M}}if(f&&f.length>0){const M=(R=f[f.length-1].metadata)==null?void 0:R.artifactFilename;if(M){const L=l.find(F=>F.filename===M);if(L)return L}}const A=l.filter(_=>Xa(_.filename));return A.length===1?A[0]:null},[e,t,l,f,c]),m=d.useMemo(()=>{if(!(!f||f.length===0))return f[f.length-1]},[f]);if(!e)return null;const v=(S=e.parts)==null?void 0:S.some(j=>{if(j.kind==="data"){const I=j.data;return(I==null?void 0:I.type)==="deep_research_progress"}return!1}),g=f&&f.length>0&&f.some(j=>j.sources&&j.sources.length>0),x=f==null?void 0:f.some(j=>j.searchType==="deep_research"),w=e.isComplete&&(v||x)&&g,y=e.isComplete&&!w&&g&&(f==null?void 0:f.some(j=>j.searchType==="web_search")),C=()=>{e.taskId&&(i(e.taskId),a("rag"))};return o.jsxs(o.Fragment,{children:[w&&g&&t&&(()=>{const I=f.flatMap(b=>b.sources).filter(b=>{var N,A;return((N=b.metadata)==null?void 0:N.fetched)===!0||((A=b.metadata)==null?void 0:A.fetch_status)==="success"||b.contentPreview&&b.contentPreview.includes("[Full Content Fetched]")});return o.jsx("div",{className:"mb-4",children:o.jsx(SC,{progress:{type:"deep_research_progress",phase:"writing",status_text:"Research complete",progress_percentage:100,current_iteration:0,total_iterations:0,sources_found:I.length,current_query:"",fetching_urls:[],elapsed_seconds:0,max_runtime_seconds:0},isComplete:!0,ragData:f})})})(),_S(e,r,t,n,!e.isUser&&(w||y)&&g?(()=>{const j=f.flatMap(b=>b.sources),I=w?j.filter(b=>{var A,P,E;return(b.sourceType||"web")==="image"?b.sourceUrl||((A=b.metadata)==null?void 0:A.link):((P=b.metadata)==null?void 0:P.fetched)===!0||((E=b.metadata)==null?void 0:E.fetch_status)==="success"||b.contentPreview&&b.contentPreview.includes("[Full Content Fetched]")}):j.filter(b=>{var N;return(b.sourceType||"web")==="image"?b.sourceUrl||((N=b.metadata)==null?void 0:N.link):!0});return I.length===0?null:o.jsx(qO,{ragMetadata:{sources:I},isDeepResearch:w,onDeepResearchClick:C})})():void 0,w&&t&&p&&c?{artifact:p,sessionId:c,ragData:m}:void 0,h,u||void 0),!e.isUser&&y&&g&&(()=>{const I=f.flatMap(b=>b.sources).filter(b=>{var N;return(b.sourceType||"web")==="image"&&((N=b.metadata)==null?void 0:N.imageUrl)}).map(b=>{var k,N;return{imageUrl:b.metadata.imageUrl,title:((k=b.metadata)==null?void 0:k.title)||b.filename,link:b.sourceUrl||((N=b.metadata)==null?void 0:N.link)||b.metadata.imageUrl}});return I.length>0?o.jsx("div",{className:"mt-4",children:o.jsx(xS,{images:I})}):null})(),pL(e)]})},vL=xt.memo(({open:e,onCancel:t,onConfirm:n,sessionName:r})=>o.jsx(Rr,{open:e,onOpenChange:s=>!s&&t(),title:"Delete Chat",content:o.jsxs(o.Fragment,{children:["This action cannot be undone. This chat session and any associated artifacts will be permanently deleted: ",o.jsx("strong",{children:r})]}),actionLabels:{confirm:"Delete"},onConfirm:n})),Nx=({text:e,onClick:t})=>o.jsxs(ye,{"data-testid":"startNewChat",variant:"ghost",onClick:t,tooltip:"Start New Chat Session",children:[o.jsx(Dv,{className:"size-5"}),e]}),kS=({buttonText:e})=>{const{handleNewSession:t}=$t(),{persistenceEnabled:n}=on(),[r,s]=d.useState(!1);return n?o.jsx(Nx,{text:e,onClick:()=>t()}):o.jsx(Rr,{open:r,onOpenChange:s,title:"Start New Chat Session",description:"Starting a new chat session will clear the current chat history and files. Are you sure you want to proceed?",actionLabels:{confirm:"Start New Chat"},onConfirm:t,trigger:o.jsx(Nx,{text:e})})};var nh=new Map,oc=new WeakMap,Tx=0,wL=void 0;function yL(e){return e?(oc.has(e)||(Tx+=1,oc.set(e,Tx.toString())),oc.get(e)):"0"}function bL(e){return Object.keys(e).sort().filter(t=>e[t]!==void 0).map(t=>`${t}_${t==="root"?yL(e.root):e[t]}`).toString()}function CL(e){const t=bL(e);let n=nh.get(t);if(!n){const r=new Map;let s;const a=new IntersectionObserver(i=>{i.forEach(l=>{var c;const u=l.isIntersecting&&s.some(h=>l.intersectionRatio>=h);e.trackVisibility&&typeof l.isVisible>"u"&&(l.isVisible=u),(c=r.get(l.target))==null||c.forEach(h=>{h(u,l)})})},e);s=a.thresholds||(Array.isArray(e.threshold)?e.threshold:[e.threshold||0]),n={id:t,observer:a,elements:r},nh.set(t,n)}return n}function SL(e,t,n={},r=wL){if(typeof window.IntersectionObserver>"u"&&r!==void 0){const c=e.getBoundingClientRect();return t(r,{isIntersecting:r,target:e,intersectionRatio:typeof n.threshold=="number"?n.threshold:0,time:0,boundingClientRect:c,intersectionRect:c,rootBounds:c}),()=>{}}const{id:s,observer:a,elements:i}=CL(n),l=i.get(e)||[];return i.has(e)||i.set(e,l),l.push(t),a.observe(e),function(){l.splice(l.indexOf(t),1),l.length===0&&(i.delete(e),a.unobserve(e)),i.size===0&&(a.disconnect(),nh.delete(s))}}function _L({threshold:e,delay:t,trackVisibility:n,rootMargin:r,root:s,triggerOnce:a,skip:i,initialInView:l,fallbackInView:c,onChange:u}={}){var h;const[f,p]=d.useState(null),m=d.useRef(u),[v,g]=d.useState({inView:!!l,entry:void 0});m.current=u,d.useEffect(()=>{if(i||!f)return;let C;return C=SL(f,(S,j)=>{g({inView:S,entry:j}),m.current&&m.current(S,j),j.isIntersecting&&a&&C&&(C(),C=void 0)},{root:s,rootMargin:r,threshold:e,trackVisibility:n,delay:t},c),()=>{C&&C()}},[Array.isArray(e)?e.toString():e,f,s,r,a,i,n,c,t]);const x=(h=v.entry)==null?void 0:h.target,w=d.useRef(void 0);!f&&x&&!a&&!i&&w.current!==x&&(w.current=x,g({inView:!!l,entry:void 0}));const y=[p,v.inView,v.entry];return y.ref=y[0],y.inView=y[1],y.entry=y[2],y}const kL=({projects:e=[]})=>{const t=bo(),{sessionId:n,handleSwitchSession:r,updateSessionName:s,openSessionDeleteModal:a,addNotification:i,displayError:l}=$t(),{persistenceEnabled:c}=on(),u=d.useRef(null),[h,f]=d.useState([]),[p,m]=d.useState(null),[v,g]=d.useState(""),[x,w]=d.useState(1),[y,C]=d.useState(!0),[S,j]=d.useState(!1),[I,b]=d.useState("all"),[k,N]=d.useState(!1),[A,P]=d.useState(null),{ref:E,inView:R}=_L({threshold:0,triggerOnce:!1}),_=d.useCallback(async(z=1,Z=!1)=>{j(!0);try{const J=await Ie.webui.get(`/api/v1/sessions?pageNumber=${z}&pageSize=20`);f(Z?ce=>[...ce,...J.data]:J.data),C(J.meta.pagination.nextPage!==null),w(z)}catch(J){console.error("An error occurred while fetching sessions:",J)}finally{j(!1)}},[]);d.useEffect(()=>{_(1,!1);const z=()=>{_(1,!1)},Z=ce=>{const{sessionId:de}=ce.detail;f(fe=>{const ge=fe.find(T=>T.id===de);if(ge){const T=fe.filter(le=>le.id!==de);return[ge,...T]}return fe})},J=()=>{_(1,!1)};return window.addEventListener("new-chat-session",z),window.addEventListener("session-updated",Z),window.addEventListener("background-task-completed",J),()=>{window.removeEventListener("new-chat-session",z),window.removeEventListener("session-updated",Z),window.removeEventListener("background-task-completed",J)}},[_]),d.useEffect(()=>{if(!h.some(J=>J.hasRunningBackgroundTask))return;const Z=setInterval(()=>{_(1,!1)},1e4);return()=>{clearInterval(Z)}},[h,_]),d.useEffect(()=>{R&&y&&!S&&_(x+1,!0)},[R,y,S,x,_]),d.useEffect(()=>{p&&u.current&&u.current.focus()},[p]);const M=async z=>{p!==z&&await r(z)},L=z=>{m(z.id),g(z.name||"")},F=async()=>{if(p){const z=p,Z=v;m(null),await s(z,Z)}},D=z=>{a(z)},O=z=>{P(z),N(!0)},K=z=>{z.projectId&&t(`/projects/${z.projectId}`)},$=async z=>{if(A)try{await Ie.webui.patch(`/api/v1/sessions/${A.id}/project`,{projectId:z}),f(Z=>Z.map(J=>{var ce;return J.id===A.id?{...J,projectId:z,projectName:z&&((ce=e.find(de=>de.id===z))==null?void 0:ce.name)||null}:J})),typeof window<"u"&&window.dispatchEvent(new CustomEvent("session-moved",{detail:{sessionId:A.id,projectId:z}})),i==null||i("Session moved successfully","success"),N(!1),P(null)}catch(Z){l({title:"Failed to Move Session",error:Zt(Z,"An unknown error occurred while moving the session.")})}},W=z=>Ah(z),V=z=>{if(z.name&&z.name.trim())return z.name;const Z=z.id;return Z.startsWith("web-session-")?`Chat ${Z.replace("web-session-","").substring(0,8)}`:`Session ${Z.substring(0,8)}`},X=d.useMemo(()=>{const z=new Set;let Z=!1;h.forEach(ce=>{ce.projectName?z.add(ce.projectName):Z=!0});const J=Array.from(z).sort((ce,de)=>ce.localeCompare(de));return Z&&J.unshift("(No Project)"),J},[h]),H=d.useMemo(()=>I==="all"?h:I==="(No Project)"?h.filter(z=>!z.projectName):h.filter(z=>z.projectName===I),[h,I]),Q=d.useMemo(()=>{if(I==="all")return null;const z=e.find(Z=>Z.name===I);return(z==null?void 0:z.id)||null},[I,e]);return o.jsxs("div",{className:"flex h-full flex-col gap-4 py-6 pl-6",children:[o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsx("div",{className:"pr-4",children:o.jsx(HL,{onSessionSelect:r,projectId:Q})}),c&&X.length>0&&o.jsxs("div",{className:"flex items-center gap-2 pr-4",children:[o.jsx("label",{className:"text-sm font-medium",children:"Project:"}),o.jsxs(Wr,{value:I,onValueChange:b,children:[o.jsx(Gr,{className:"flex-1 rounded-md",children:o.jsx(Zr,{})}),o.jsxs(qr,{children:[o.jsx(Pt,{value:"all",children:"All Chats"}),X.map(z=>o.jsx(Pt,{value:z,children:z},z))]})]})]})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto",children:[H.length>0&&o.jsx("ul",{children:H.map(z=>o.jsx("li",{className:"group my-2 pr-4",children:o.jsxs("div",{className:`flex items-center gap-2 rounded-sm px-2 py-2 ${z.id===n?"bg-muted dark:bg-muted/50":""}`,children:[p===z.id?o.jsx("input",{ref:u,type:"text",value:v,onChange:Z=>g(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),F())},className:"min-w-0 flex-1 bg-transparent focus:outline-none"}):o.jsx("button",{onClick:()=>M(z.id),className:"min-w-0 flex-1 cursor-pointer text-left",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"truncate font-semibold",children:V(z)}),z.hasRunningBackgroundTask&&o.jsxs(zs,{children:[o.jsx($s,{asChild:!0,children:o.jsx(ur,{className:"text-primary h-4 w-4 flex-shrink-0 animate-spin"})}),o.jsx(Us,{children:"Background task running"})]})]}),o.jsx("span",{className:"text-muted-foreground truncate text-xs",children:W(z.updatedTime)})]}),z.projectName&&o.jsx(Yu,{text:z.projectName})]})}),o.jsx("div",{className:"flex flex-shrink-0 items-center",children:p===z.id?o.jsxs(o.Fragment,{children:[o.jsx(ye,{variant:"ghost",size:"sm",onClick:F,className:"h-8 w-8 p-0",children:o.jsx(ni,{size:16})}),o.jsx(ye,{variant:"ghost",size:"sm",onClick:()=>m(null),className:"h-8 w-8 p-0",children:o.jsx(Kr,{size:16})})]}):o.jsxs(Ga,{children:[o.jsx(qa,{asChild:!0,children:o.jsx(ye,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:Z=>Z.stopPropagation(),children:o.jsx(fo,{size:16})})}),o.jsxs(Ya,{align:"end",className:"w-48",children:[z.projectId&&o.jsxs(o.Fragment,{children:[o.jsxs(An,{onClick:Z=>{Z.stopPropagation(),K(z)},children:[o.jsx(x_,{size:16,className:"mr-2"}),"Go to Project"]}),o.jsx(Xg,{})]}),o.jsxs(An,{onClick:Z=>{Z.stopPropagation(),L(z)},children:[o.jsx(ys,{size:16,className:"mr-2"}),"Rename"]}),o.jsxs(An,{onClick:Z=>{Z.stopPropagation(),O(z)},children:[o.jsx(v_,{size:16,className:"mr-2"}),"Move to Project"]}),o.jsx(Xg,{}),o.jsxs(An,{onClick:Z=>{Z.stopPropagation(),D(z)},children:[o.jsx(Ho,{size:16,className:"mr-2"}),"Delete"]})]})]})})]})},z.id))}),H.length===0&&h.length>0&&!S&&o.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center text-sm",children:[o.jsx(Nc,{className:"mx-auto mb-4 h-12 w-12"}),"No sessions found for this project"]}),h.length===0&&!S&&o.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center text-sm",children:[o.jsx(Nc,{className:"mx-auto mb-4 h-12 w-12"}),"No chat sessions available"]}),y&&o.jsx("div",{ref:E,className:"flex justify-center py-4",children:S&&o.jsx(ws,{size:"small",variant:"muted"})})]}),o.jsx(VL,{isOpen:k,onClose:()=>{N(!1),P(null)},onConfirm:$,session:A,projects:e,currentProjectId:A==null?void 0:A.projectId})]})},jL=()=>{const{persistenceEnabled:e}=on(),{sessionName:t}=$t(),{projects:n}=Bs();return e?o.jsx(kL,{projects:n}):o.jsx("div",{className:"flex h-full flex-col",children:o.jsxs("div",{className:"flex-1 overflow-y-auto px-4",children:[o.jsxs("div",{className:"bg-accent/50 hover:bg-accent mb-3 cursor-pointer rounded-md p-3",children:[o.jsx("div",{className:"text-foreground truncate text-sm font-medium text-nowrap",children:t||"New Chat"}),o.jsx("div",{className:"text-muted-foreground mt-1 text-xs",children:"Current session"})]}),o.jsx("div",{className:"text-muted-foreground mt-4 text-center text-xs",children:"Persistence is not enabled."})]})})},EL=({artifact:e,isPreview:t})=>{const{setPreviewArtifact:n}=$t(),r={name:e.filename,mime_type:e.mime_type,size:e.size,uri:e.uri},s=a=>{t||(a.stopPropagation(),n(e))};return o.jsx("div",{className:`${t?"":"cursor-pointer transition-all duration-150 hover:bg-[var(--accent-background)]"}`,onClick:s,children:o.jsx(Pi,{status:"completed",name:e.filename,fileAttachment:r,context:"list"})})},NL=()=>{const{isDeleteModalOpen:e,artifactToDelete:t,closeDeleteModal:n,confirmDelete:r}=$t();return t?o.jsx(Rr,{open:e,onOpenChange:s=>!s&&n(),title:"Delete File",content:t.source==="project"?`This action will remove the file, "${t.filename}", from this chat session. This file will remain in the project.`:o.jsxs(o.Fragment,{children:["This action cannot be undone. This file will be permanently deleted: ",o.jsx("strong",{children:t.filename}),"."]}),actionLabels:{confirm:"Delete"},onConfirm:r,onCancel:n}):null},TL=({artifact:e,message:t})=>{const{onDownload:n}=hm();return o.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 p-4",children:[o.jsx("div",{className:"mb-1 font-semibold",children:"Preview Unavailable"}),o.jsx("div",{children:t}),o.jsxs(ye,{onClick:()=>n(e),children:[o.jsx(yo,{className:"h-4 w-4"}),"Download"]})]})},Zd=({children:e})=>o.jsx("div",{className:"text-muted-foreground flex h-[50vh] items-center justify-center",children:e||"No preview available"}),AL=({artifact:e})=>{const{openArtifactForPreview:t,previewFileContent:n,markArtifactAsDisplayed:r,downloadAndResolveArtifact:s,ragData:a}=$t(),i=d.useMemo(()=>FR(e),[e]),l=d.useMemo(()=>{if(!Xa(e.filename)||!a||a.length===0)return;const b=a.find(k=>{var A;return((A=k.metadata)==null?void 0:A.artifactFilename)===e.filename});if(!b){const k=a.filter(N=>N.searchType==="deep_research");if(k.length===1)return k[0]}return b},[e.filename,a]),[c,u]=d.useState(!1),[h,f]=d.useState(null),[p,m]=d.useState(null),[v,g]=d.useState(!1),x=d.useRef(!1),w=d.useRef(null),y=d.useRef(!1);if(d.useEffect(()=>(r(e.filename,!0),()=>{r(e.filename,!1)}),[e.filename,r]),d.useEffect(()=>{u(!1),f(null),m(null),x.current=!1,w.current=null},[e.filename]),d.useEffect(()=>{if(e.accumulatedContent){const b={name:e.filename,mime_type:e.mime_type,content:e.accumulatedContent,last_modified:e.last_modified,isPlainText:e.isAccumulatedContentPlainText};m(b)}},[e.accumulatedContent,e.filename,e.mime_type,e.last_modified,e.isAccumulatedContentPlainText]),d.useEffect(()=>{async function b(){if(!(x.current&&w.current===e.filename)){x.current=!0,w.current=e.filename;try{u(!0),f(null),e.accumulatedContent?u(!1):await t(e.filename)}catch(k){console.error("Error fetching artifact content:",k),f(k instanceof Error?k.message:"Failed to load artifact content")}finally{u(!1)}}}i!=null&&i.canPreview&&b()},[e.filename,t,i,e.accumulatedContent]),d.useEffect(()=>{async function b(){if(e.needsEmbedResolution&&!v&&!y.current){y.current=!0,g(!0);try{const k=await s(e.filename);k&&m({...k,isPlainText:!1})}catch(k){console.error(`[ArtifactPreviewContent] Error downloading ${e.filename}:`,k)}finally{g(!1),y.current=!1}}}b()},[e.needsEmbedResolution,e.filename,s,v]),h)return o.jsxs("div",{className:"flex h-full w-full flex-col",children:[o.jsx(Xt,{variant:"error",message:"Error rendering preview"}),o.jsx(Zd,{children:"No preview available"})]});if(c)return o.jsx(Zd,{children:o.jsx(ur,{className:"text-muted-foreground h-6 w-6 animate-spin"})});if(!i.canPreview)return o.jsx(TL,{artifact:e,message:i.reason??""});const C=p||((n==null?void 0:n.name)===e.filename?n:null),S=(C==null?void 0:C.mime_type)||e.mime_type,j=Hr(e.filename,S),I=$y(C);return!j||!I?o.jsx(Zd,{children:"No preview available"}):o.jsxs("div",{className:"relative h-full w-full",children:[o.jsx(Um,{content:I,rendererType:j,mime_type:C==null?void 0:C.mime_type,setRenderError:f,ragData:l}),o.jsx(wS,{isVisible:v,message:"Resolving embeds..."})]})},hs={NameAsc:"name_asc",NameDesc:"name_desc",DateAsc:"date_asc",DateDesc:"date_desc"},IL=e=>{switch(e){case hs.NameAsc:return"Name (A-Z)";case hs.NameDesc:return"Name (Z-A)";case hs.DateAsc:return"Date (oldest first)";case hs.DateDesc:return"Date (newest first)"}},RL=({currentSortOption:e,onSortChange:t,children:n})=>{const r=Object.values(hs).map(s=>({id:s,label:IL(s),onClick:()=>t(s),icon:e===s?o.jsx(ni,{}):void 0,iconPosition:"right"}));return o.jsxs(Sl,{children:[o.jsx(_l,{asChild:!0,children:n}),o.jsx(kl,{align:"end",side:"bottom",className:"w-auto",sideOffset:0,children:o.jsx(bl,{actions:r})})]})},PL=({children:e,hideDeleteAll:t=!1})=>{const{artifactsRefetch:n,setIsBatchDeleteModalOpen:r}=$t(),s=[{id:"refreshAll",label:"Refresh",onClick:()=>{n()},icon:o.jsx(uu,{}),iconPosition:"left"}];return t||s.push({id:"deleteAll",label:"Delete All",onClick:()=>{r(!0)},icon:o.jsx(gh,{}),iconPosition:"left",divider:!0}),o.jsxs(Sl,{children:[o.jsx(_l,{asChild:!0,children:e}),o.jsx(kl,{align:"end",side:"bottom",className:"w-auto",sideOffset:0,children:o.jsx(bl,{actions:s})})]})},ML=()=>{const{artifacts:e,isBatchDeleteModalOpen:t,setIsBatchDeleteModalOpen:n,confirmBatchDeleteArtifacts:r,setSelectedArtifactFilenames:s}=$t();if(d.useEffect(()=>{t&&s(new Set(e.map(u=>u.filename)))},[e,t,s]),!t)return null;const a=e.some(u=>u.source==="project"),i=e.filter(u=>u.source==="project").length,l=e.length-i,c=()=>a&&l===0?`${e.length===1?"This file":`All ${e.length} files`} will be removed from this chat session. ${e.length===1?"The file":"These files"} will remain in ${e.length===1?"the":"their"} project${e.length===1?"":"s"}.`:a&&l>0?`${l} ${l===1?"file":"files"} will be permanently deleted. ${i} project ${i===1?"file":"files"} will be removed from this chat but will remain in ${i===1?"the":"their"} project${i===1?"":"s"}.`:`${e.length===1?"One file":`All ${e.length} files`} will be permanently deleted.`;return o.jsx(Rr,{title:"Delete All?",description:c(),actionLabels:{confirm:"Delete"},onCancel:()=>n(!1),onConfirm:r,open:t,onOpenChange:n})},DL=({artifactInfo:e,isPreview:t=!1,isExpanded:n=!1,onDelete:r,onDownload:s,setIsExpanded:a,badge:i})=>{const{previewedArtifactAvailableVersions:l,currentPreviewedVersionNumber:c,navigateArtifactVersion:u}=$t(),h=d.useMemo(()=>l??[],[l]);return o.jsxs("div",{className:"flex flex-row justify-between gap-1",children:[o.jsxs("div",{className:"flex min-w-0 items-center gap-4",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"truncate text-sm",title:e.filename,children:e.filename}),i&&i.badgeComponent]}),o.jsx("div",{className:"truncate text-xs",title:Pc(e.last_modified),children:Pc(e.last_modified)})]}),t&&h.length>1&&o.jsx("div",{className:"align-right",children:o.jsxs(Wr,{value:c==null?void 0:c.toString(),onValueChange:f=>{u(e.filename,parseInt(f))},children:[o.jsx(Gr,{className:"h-[16px] py-0 text-xs shadow-none",children:o.jsx(Zr,{placeholder:"Version"})}),o.jsx(qr,{children:h.map(f=>o.jsxs(Pt,{value:f.toString(),children:["Version ",f]},f))})]})})]}),o.jsxs("div",{className:`whitespace-nowrap ${t?"opacity-100":"opacity-0 transition-opacity duration-150 group-focus-within:opacity-100 group-hover:opacity-100"}`,children:[a&&o.jsx(ye,{variant:"ghost",size:"sm",onClick:f=>{f.stopPropagation(),f.preventDefault(),a(!n)},tooltip:n?"Collapse Details":"Expand Details",children:o.jsx(ll,{})}),s&&o.jsx(ye,{variant:"ghost",size:"sm",onClick:async f=>{f.stopPropagation(),f.preventDefault(),await s(e)},tooltip:"Download",children:o.jsx(yo,{})}),r&&o.jsx(ye,{variant:"ghost",size:"sm",onClick:f=>{f.preventDefault(),f.stopPropagation(),r()},tooltip:"Delete",children:o.jsx(gh,{})})]})]})},OL={[hs.NameAsc]:(e,t)=>e.filename.localeCompare(t.filename),[hs.NameDesc]:(e,t)=>t.filename.localeCompare(e.filename),[hs.DateAsc]:(e,t)=>e.last_modified>t.last_modified?1:-1,[hs.DateDesc]:(e,t)=>e.last_modified<t.last_modified?1:-1},LL=()=>{const{artifacts:e,artifactsLoading:t,previewArtifact:n,setPreviewArtifact:r,artifactsRefetch:s,openDeleteModal:a}=$t(),{onDownload:i}=hm(),[l,c]=d.useState(hs.DateDesc),[u,h]=d.useState(!1),f=d.useMemo(()=>t?[]:e?[...e].sort(OL[l]):[],[e,t,l]),p=d.useMemo(()=>f.some(v=>v.source!=="project"),[f]),m=d.useMemo(()=>n?o.jsxs("div",{className:"flex items-center gap-2 border-b p-2",children:[o.jsx(ye,{variant:"ghost",onClick:()=>r(null),children:o.jsx(w_,{})}),o.jsx("div",{className:"text-md font-semibold",children:"Preview"})]}):f.length>0&&o.jsxs("div",{className:"flex items-center justify-end border-b p-2",children:[o.jsx(RL,{currentSortOption:l,onSortChange:c,children:o.jsxs(ye,{variant:"ghost",title:"Sort By",children:[o.jsx(_v,{className:"h-5 w-5"}),o.jsx("div",{children:"Sort By"})]})},"sort-popover"),o.jsx(PL,{hideDeleteAll:!p,children:o.jsx(ye,{variant:"ghost",tooltip:"More",children:o.jsx(fo,{className:"h-5 w-5"})})},"more-popover")]}),[n,f.length,l,r,p]);return o.jsxs("div",{className:"flex h-full flex-col",children:[m,o.jsxs("div",{className:"flex min-h-0 flex-1",children:[!n&&o.jsxs("div",{className:"flex-1 overflow-y-auto",children:[f.map(v=>o.jsx(EL,{artifact:v},v.filename)),f.length===0&&o.jsx("div",{className:"flex h-full items-center justify-center p-4",children:o.jsxs("div",{className:"text-muted-foreground text-center",children:[t&&o.jsx(ur,{className:"size-6 animate-spin"}),!t&&o.jsxs(o.Fragment,{children:[o.jsx(Sr,{className:"mx-auto mb-4 h-12 w-12"}),o.jsx("div",{className:"text-lg font-medium",children:"Files"}),o.jsx("div",{className:"mt-2 text-sm",children:"No files available"}),o.jsx(ye,{className:"mt-4",variant:"default",onClick:s,"data-testid":"refreshFiles",title:"Refresh Files",children:"Refresh"})]})]})})]}),n&&o.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-2",children:[o.jsx("div",{className:"border-b px-4 py-3",children:o.jsx(DL,{artifactInfo:n,isPreview:!0,isExpanded:u,setIsExpanded:h,onDelete:n.source==="project"?void 0:()=>a(n),onDownload:()=>i(n)})}),u&&o.jsx("div",{className:"border-b px-4 py-3",children:o.jsxs("div",{className:"space-y-2 text-sm",children:[n.description&&o.jsxs("div",{children:[o.jsx("span",{className:"text-secondary-foreground",children:"Description:"}),o.jsx("div",{className:"mt-1",children:n.description})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{children:[o.jsx("span",{className:"text-secondary-foreground",children:"Size:"}),o.jsx("div",{children:ds(n.size)})]}),o.jsxs("div",{children:[o.jsx("span",{className:"text-secondary-foreground",children:"Type:"}),o.jsx("div",{children:n.mime_type||"Unknown"})]})]})]})}),o.jsx("div",{className:"min-h-0 min-w-0 flex-1 overflow-y-auto",children:o.jsx(AL,{artifact:n})})]})]}),o.jsx(NL,{}),o.jsx(ML,{})]})},FL=e=>{if(!e)return"Unknown";let t=e.replace(/\.pdf$/,"");t=t.replace(/_v\d+$/,"");const n=/^.*web-session-[a-f0-9-]+_/;return t=t.replace(n,""),t+".pdf"},zL=({source:e})=>{var f,p;const[t,n]=xt.useState(!1),r=e.contentPreview,s=e.sourceType||"web";let a,i;s==="image"?(a=e.sourceUrl||((f=e.metadata)==null?void 0:f.link)||"",i=((p=e.metadata)==null?void 0:p.title)||e.filename||"Image source"):(a=e.sourceUrl||e.url||"",i=e.title||e.filename||FL(e.fileId));const l=r&&r!=="Reading...",c=l&&r.length>200,u=c&&!t?r.substring(0,200)+"...":r,h=e.relevanceScore!==1;return o.jsxs("div",{className:"bg-muted/50 border-border/50 flex flex-col rounded border p-3",children:[o.jsxs("div",{className:"mb-2 flex flex-shrink-0 items-center justify-between",children:[o.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[o.jsx(Sr,{className:"text-muted-foreground h-3 w-3 flex-shrink-0"}),a?o.jsxs("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 truncate text-xs font-medium text-[var(--color-primary-wMain)] hover:text-[var(--color-primary-w60)] hover:underline dark:text-[var(--color-primary-w60)] dark:hover:text-[var(--color-white)]",title:i,children:[o.jsx("span",{className:"truncate",children:i}),o.jsx(uo,{className:"h-2.5 w-2.5 flex-shrink-0"})]}):o.jsx("span",{className:"truncate text-xs font-medium",title:i,children:i})]}),h&&o.jsxs("div",{className:"ml-2 flex flex-shrink-0 items-center gap-1 text-xs font-medium",children:[o.jsx(y_,{className:"h-3 w-3"}),o.jsxs("span",{children:["Score: ",e.relevanceScore.toFixed(2)]})]})]}),l&&o.jsx("div",{className:`text-muted-foreground overflow-hidden text-xs leading-relaxed break-words whitespace-pre-wrap ${t?"":"h-[72px]"}`,children:u}),c&&o.jsx("button",{onClick:()=>n(!t),className:"text-primary mt-2 flex flex-shrink-0 items-center gap-1 text-xs hover:underline",children:t?o.jsxs(o.Fragment,{children:[o.jsx(Ua,{className:"h-3 w-3"}),"Show less"]}):o.jsxs(o.Fragment,{children:[o.jsx(Uo,{className:"h-3 w-3"}),"Show more"]})}),e.metadata&&Object.keys(e.metadata).length>0&&o.jsx("div",{className:"border-border/50 mt-2 flex-shrink-0 border-t pt-2",children:o.jsxs("details",{className:"text-xs",children:[o.jsx("summary",{className:"text-muted-foreground hover:text-foreground cursor-pointer",children:"Metadata"}),o.jsx("div",{className:"mt-1 space-y-1 pl-2",children:Object.entries(e.metadata).map(([m,v])=>o.jsxs("div",{className:"flex gap-2",children:[o.jsxs("span",{className:"font-medium",children:[m,":"]}),o.jsx("span",{className:"text-muted-foreground",children:typeof v=="object"?JSON.stringify(v):String(v)})]},m))})]})})]})},$L=({ragData:e,enabled:t})=>{if(!t)return o.jsx("div",{className:"flex h-full items-center justify-center p-4",children:o.jsxs("div",{className:"text-muted-foreground text-center",children:[o.jsx(cf,{className:"mx-auto mb-4 h-12 w-12 opacity-50"}),o.jsx("div",{className:"text-lg font-medium",children:"RAG Sources"}),o.jsx("div",{className:"mt-2 text-sm",children:"RAG source visibility is disabled in settings"})]})});if(!e||e.length===0)return o.jsx("div",{className:"flex h-full items-center justify-center p-4",children:o.jsxs("div",{className:"text-muted-foreground text-center",children:[o.jsx(co,{className:"mx-auto mb-4 h-12 w-12 opacity-50"}),o.jsx("div",{className:"text-lg font-medium",children:"Sources"}),o.jsx("div",{className:"mt-2 text-sm",children:"No sources available yet"}),o.jsx("div",{className:"mt-1 text-xs",children:"Sources from web research will appear here after completion"})]})});const n=e.every(m=>m.searchType==="deep_research"||m.searchType==="web_search"),r=e.reduce((m,v)=>{const g=v.sources.filter(x=>{var y;return(x.sourceType||"web")==="image"?x.sourceUrl||((y=x.metadata)==null?void 0:y.link):!0});return m+g.length},0),s=({source:m})=>{var y,C,S;const v=m.sourceType||"web";let g,x;v==="image"?(g=m.sourceUrl||((y=m.metadata)==null?void 0:y.link)||"",x=((C=m.metadata)==null?void 0:C.title)||m.filename||"Image source"):(g=m.url||m.sourceUrl||"",x=m.title||m.filename||"Unknown");const w=((S=m.metadata)==null?void 0:S.favicon)||(g?`https://www.google.com/s2/favicons?domain=${g}&sz=32`:"");return o.jsxs("div",{className:"hover:bg-muted/50 -mx-2 flex items-center gap-2 rounded px-2 py-1.5",children:[w&&o.jsx("img",{src:w,alt:"",className:"h-4 w-4 flex-shrink-0 rounded",onError:j=>{j.target.style.display="none"}}),g?o.jsxs("a",{href:g,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 truncate text-sm text-[var(--color-primary-wMain)] hover:text-[var(--color-primary-w60)] hover:underline dark:text-[var(--color-primary-w60)] dark:hover:text-[var(--color-white)]",title:x,children:[o.jsx("span",{className:"truncate",children:x}),o.jsx(uo,{className:"h-3 w-3 flex-shrink-0"})]}):o.jsx("span",{className:"truncate text-sm",title:x,children:x})]})},a=m=>{var v,g;return((v=m.metadata)==null?void 0:v.fetched)===!0||((g=m.metadata)==null?void 0:g.fetch_status)==="success"||(m.contentPreview?m.contentPreview.includes("[Full Content Fetched]"):!1)},{fullyReadSources:i,snippetSources:l,allUniqueSources:c}=(()=>{if(!n)return{fullyReadSources:[],snippetSources:[],allUniqueSources:[]};const m=new Map,v=new Map,g=e.some(S=>S.searchType==="web_search"),x=e.some(S=>S.searchType==="deep_research");e.forEach(S=>{S.sources.forEach(j=>{var N;if((j.sourceType||"web")==="image"){const A=j.sourceUrl||((N=j.metadata)==null?void 0:N.link);if(!A)return;m.has(A)||m.set(A,j);return}const b=j.url||j.sourceUrl||j.title||"";if(!b)return;if(g&&!x){m.has(b)||m.set(b,j);return}a(j)?(m.has(b)||m.set(b,j),v.delete(b)):!m.has(b)&&!v.has(b)&&v.set(b,j)})});const w=Array.from(m.values()),y=Array.from(v.values()),C=[...w,...y];return console.log("[RAGInfoPanel] Source filtering:",{isWebSearch:g,isDeepResearch:x,totalSourcesBeforeFilter:e.reduce((S,j)=>S+j.sources.length,0),fullyReadSources:w.length,snippetSources:y.length,sampleFullyRead:w.slice(0,3).map(S=>{var j,I,b,k;return{url:S.url,title:S.title,fetched:(j=S.metadata)==null?void 0:j.fetched,fetch_status:(I=S.metadata)==null?void 0:I.fetch_status,contentPreview:(b=S.contentPreview)==null?void 0:b.substring(0,100),hasMarker:(k=S.contentPreview)==null?void 0:k.includes("[Full Content Fetched]")}}),sampleSnippets:y.slice(0,3).map(S=>{var j,I,b,k;return{url:S.url,title:S.title,fetched:(j=S.metadata)==null?void 0:j.fetched,fetch_status:(I=S.metadata)==null?void 0:I.fetch_status,contentPreview:(b=S.contentPreview)==null?void 0:b.substring(0,100),hasMarker:(k=S.contentPreview)==null?void 0:k.includes("[Full Content Fetched]")}})}),{fullyReadSources:w,snippetSources:y,allUniqueSources:C}})(),u=e.some(m=>m.searchType==="deep_research"),h=u&&(i.length>0||l.length>0),f=e&&e.length>0?e[0].title||e[0].query:"",p=u&&e.some(m=>m.sources.some(v=>{var g,x;return((g=v.metadata)==null?void 0:g.fetched)===!0||((x=v.metadata)==null?void 0:x.fetch_status)==="success"}));return o.jsx("div",{className:"flex h-full flex-col overflow-hidden",children:n?o.jsx("div",{className:"flex flex-1 flex-col overflow-hidden",children:o.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-4",children:[f&&o.jsx("div",{className:"border-border/50 mb-4 border-b pb-3",children:o.jsx("h2",{className:"text-foreground text-base leading-tight font-semibold",children:f})}),h&&p?o.jsxs(o.Fragment,{children:[i.length>0&&o.jsxs("div",{className:"mb-4",children:[o.jsx("div",{className:"mb-2",children:o.jsxs("h3",{className:"text-muted-foreground text-sm font-semibold",children:[i.length," Fully Read Source",i.length!==1?"s":""]})}),o.jsx("div",{className:"space-y-1",children:i.map((m,v)=>o.jsx(s,{source:m},`fully-read-${v}`))})]}),l.length>0&&o.jsxs("div",{children:[o.jsxs("div",{className:"mb-2",children:[o.jsxs("h3",{className:"text-muted-foreground text-sm font-semibold",children:[l.length," Partially Read Source",l.length!==1?"s":""]}),o.jsx("p",{className:"text-muted-foreground mt-0.5 text-xs",children:"Search result snippets"})]}),o.jsx("div",{className:"space-y-1",children:l.map((m,v)=>o.jsx(s,{source:m},`partially-read-${v}`))})]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"mb-3",children:[o.jsx("h3",{className:"text-muted-foreground text-sm font-semibold",children:u&&!p?"Sources Explored So Far":`${c.length} Sources`}),u&&!p&&o.jsx("p",{className:"text-muted-foreground mt-0.5 text-xs",children:"Research in progress..."})]}),o.jsx("div",{className:"space-y-1",children:c.map((m,v)=>o.jsx(s,{source:m},`source-${v}`))})]})]})}):o.jsxs(S1,{defaultValue:"activity",className:"flex flex-1 flex-col overflow-hidden",children:[o.jsx("div",{className:"flex-shrink-0 px-4 pt-4 pb-2",children:o.jsxs(_1,{className:"grid w-full grid-cols-2",children:[o.jsx(Li,{value:"activity",children:"Activity"}),o.jsxs(Li,{value:"sources",children:[r," Sources"]})]})}),o.jsxs(Fi,{value:"activity",className:"mt-0 min-h-0 flex-1 overflow-y-auto px-4 pb-4",children:[o.jsxs("div",{className:"mb-3",children:[o.jsx("h3",{className:"text-muted-foreground text-sm font-semibold tracking-wide uppercase",children:"Timeline of Research Activity"}),o.jsxs("p",{className:"text-muted-foreground mt-1 text-xs",children:[e.length," search",e.length!==1?"es":""," performed"]})]}),o.jsx("div",{className:"space-y-2",children:e.map((m,v)=>{const g=[];return g.push({type:"search",timestamp:m.timestamp,content:m.query}),m.sources.forEach(x=>{var w,y;if(x.url||x.title){const C=((w=x.metadata)==null?void 0:w.source_type)||"web";g.push({type:"read",timestamp:x.retrievedAt||m.timestamp,content:x.title||x.url||"Unknown",url:x.url,favicon:((y=x.metadata)==null?void 0:y.favicon)||(x.url?`https://www.google.com/s2/favicons?domain=${x.url}&sz=32`:""),title:x.title,source_type:C})}}),o.jsx(xt.Fragment,{children:g.map((x,w)=>o.jsxs("div",{className:"flex items-start gap-3 py-2",children:[o.jsxs("div",{className:"mt-0.5 flex-shrink-0",children:[x.type==="thinking"&&o.jsx(af,{className:"text-muted-foreground h-4 w-4"}),x.type==="search"&&o.jsx(co,{className:"text-muted-foreground h-4 w-4"}),x.type==="read"&&(x.favicon&&x.favicon.trim()!==""?o.jsx("img",{src:x.favicon,alt:"",className:"h-4 w-4 rounded",onError:y=>{y.target.style.display="none"}}):o.jsx(lf,{className:"text-muted-foreground h-4 w-4"}))]}),o.jsxs("div",{className:"min-w-0 flex-1",children:[x.type==="search"&&o.jsxs("div",{className:"text-sm",children:[o.jsx("span",{className:"text-muted-foreground",children:"Searched for "}),o.jsx("span",{className:"font-medium",children:x.content})]}),x.type==="read"&&o.jsxs("div",{className:"text-sm",children:[o.jsx("span",{className:"text-muted-foreground",children:"Read "}),x.url?o.jsxs("a",{href:x.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 font-medium text-[var(--color-primary-wMain)] hover:text-[var(--color-primary-w60)] hover:underline dark:text-[var(--color-primary-w60)] dark:hover:text-[var(--color-white)]",children:[o.jsx("span",{children:x.title||new URL(x.url).hostname}),o.jsx(uo,{className:"h-3 w-3 flex-shrink-0"})]}):o.jsx("span",{className:"font-medium",children:x.content})]}),x.type==="thinking"&&o.jsx("div",{className:"text-muted-foreground text-sm",children:x.content})]})]},`${v}-${w}`))},v)})})]}),o.jsxs(Fi,{value:"sources",className:"mt-0 min-h-0 flex-1 overflow-y-auto px-4 pb-4",children:[o.jsxs("div",{className:"mb-3",children:[o.jsx("h3",{className:"text-muted-foreground text-sm font-semibold",children:"All Sources"}),o.jsxs("p",{className:"text-muted-foreground mt-1 text-xs",children:[r," source",r!==1?"s":""," found across ",e.length," search",e.length!==1?"es":""]})]}),o.jsx("div",{className:"space-y-2",children:e.map((m,v)=>m.sources.filter(g=>{var w;return(g.sourceType||"web")==="image"?g.sourceUrl||((w=g.metadata)==null?void 0:w.link):!0}).map((g,x)=>o.jsx(zL,{source:g},`${v}-${x}`)))})]})]})})},UL=({onCollapsedToggle:e,isSidePanelCollapsed:t,setIsSidePanelCollapsed:n,isSidePanelTransitioning:r})=>{const{activeSidePanelTab:s,setActiveSidePanelTab:a,setPreviewArtifact:i,taskIdInSidePanel:l,ragData:c,ragEnabled:u}=$t(),{isReconnecting:h,isTaskMonitorConnecting:f,isTaskMonitorConnected:p,monitoredTasks:m,connectTaskMonitorStream:v,loadTaskFromBackend:g}=mm(),[x,w]=d.useState(null),[y,C]=d.useState(!1),S=xt.useRef(new Set),j=d.useMemo(()=>G2(c),[c]);d.useEffect(()=>{if(!l){w(null);return}const A=m[l];if(!S.current.has(l))S.current.add(l),C(!0),g(l).then(P=>{if(!P)if(A&&A.events&&A.events.length>0){const E=qd(A.events,m,A);w(E)}else w(null)}).catch(()=>{if(A&&A.events&&A.events.length>0){const P=qd(A.events,m,A);w(P)}else w(null)}).finally(()=>{C(!1)});else if(A&&A.events&&A.events.length>0){const P=qd(A.events,m,A);w(P),C(!1)}else w(null)},[l,m,g]),d.useEffect(()=>{if(l)return()=>{setTimeout(()=>{S.current.delete(l)},1e3)}},[l]);const I=()=>y?{message:"Loading workflow data...",showButton:!1}:h||f?{message:"Connecting to task monitor ...",showButton:!1}:p?l?x?null:{message:"No workflow data available for the selected task",showButton:!1}:{message:"No task selected to display",showButton:!1}:{message:"No connection to task monitor",showButton:!0,buttonText:"Reconnect",buttonIcon:b_,buttonAction:v},b=()=>{const A=!t;n(A),e(A)},k=A=>{A==="files"&&i(null),a(A)},N=A=>{t&&(n(!1),e==null||e(!1)),k(A)};return t?o.jsxs("div",{className:"bg-background flex h-full w-full flex-col items-center border-l py-4",children:[o.jsx(ye,{"data-testid":"expandPanel",variant:"ghost",size:"sm",onClick:b,className:"h-10 w-10 p-0",tooltip:"Expand Panel",children:o.jsx(ap,{className:"size-5"})}),o.jsx("div",{className:"bg-border my-4 h-px w-8"}),o.jsx(ye,{variant:"ghost",size:"sm",onClick:()=>N("files"),className:"mb-2 h-10 w-10 p-0",tooltip:"Files",children:o.jsx(Sr,{className:"size-5"})}),o.jsx(ye,{variant:"ghost",size:"sm",onClick:()=>N("workflow"),className:j?"mb-2 h-10 w-10 p-0":"h-10 w-10 p-0",tooltip:"Workflow",children:o.jsx(pc,{className:"size-5"})}),j&&o.jsx(ye,{variant:"ghost",size:"sm",onClick:()=>N("rag"),className:"h-10 w-10 p-0",tooltip:"Sources",children:o.jsx(cf,{className:"size-5"})})]}):o.jsx("div",{className:"bg-background flex h-full flex-col border-l",children:o.jsx("div",{className:"m-1 min-h-0 flex-1",children:o.jsxs(S1,{value:s,onValueChange:A=>k(A),className:"flex h-full flex-col",children:[o.jsxs("div",{className:"@container flex gap-2 p-2",children:[o.jsx(ye,{"data-testid":"collapsePanel",variant:"ghost",onClick:b,className:"shrink-0 p-1",tooltip:"Collapse Panel",children:o.jsx(ap,{className:"size-5"})}),o.jsxs(_1,{className:"flex min-w-0 flex-1 bg-transparent p-0",children:[o.jsxs(Li,{value:"files",title:"Files",className:"border-border bg-muted data-[state=active]:bg-background relative min-w-0 flex-1 cursor-pointer rounded-none rounded-l-md border border-r-0 px-2 data-[state=active]:z-10 data-[state=active]:border-r-0",onClick:()=>i(null),children:[o.jsx(Sr,{className:"h-4 w-4 shrink-0"}),o.jsx("span",{className:"ml-1.5 hidden truncate @[240px]:inline",children:"Files"})]}),o.jsxs(Li,{value:"workflow",title:"Workflow",className:`border-border bg-muted data-[state=active]:bg-background relative min-w-0 flex-1 cursor-pointer rounded-none border-x-0 border-y px-2 data-[state=active]:z-10 ${j?"":"rounded-r-md border-r"}`,children:[o.jsx(pc,{className:"h-4 w-4 shrink-0"}),o.jsx("span",{className:"ml-1.5 hidden truncate @[240px]:inline",children:"Workflow"})]}),j&&o.jsxs(Li,{value:"rag",title:"Sources",className:"border-border bg-muted data-[state=active]:bg-background relative min-w-0 flex-1 cursor-pointer rounded-none rounded-r-md border border-l-0 px-2 data-[state=active]:z-10",children:[o.jsx(cf,{className:"h-4 w-4 shrink-0"}),o.jsx("span",{className:"ml-1.5 hidden truncate @[240px]:inline",children:"Sources"})]})]})]}),o.jsxs("div",{className:"min-h-0 flex-1",children:[o.jsx(Fi,{value:"files",className:"m-0 h-full",children:o.jsx("div",{className:"h-full",children:o.jsx(LL,{})})}),o.jsx(Fi,{value:"workflow",className:"m-0 h-full",children:o.jsx("div",{className:"h-full",children:(()=>{const A=I();return!A&&x?o.jsxs("div",{className:"flex h-full flex-col",children:[o.jsx(ZL,{task:x}),o.jsx(kF,{processedSteps:x.steps||[],isRightPanelVisible:!1,isSidePanelTransitioning:r})]}):o.jsx("div",{className:"flex h-full items-center justify-center p-4",children:o.jsxs("div",{className:"text-muted-foreground text-center",children:[o.jsx(pc,{className:"mx-auto mb-4 h-12 w-12"}),o.jsx("div",{className:"text-lg font-medium",children:"Workflow"}),o.jsx("div",{className:"mt-2 text-sm",children:A==null?void 0:A.message}),(A==null?void 0:A.showButton)&&o.jsx("div",{className:"mt-4",children:o.jsxs(ye,{onClick:A.buttonAction,children:[A.buttonIcon&&(()=>{const P=A.buttonIcon;return o.jsx(P,{className:"h-4 w-4"})})(),A.buttonText]})})]})})})()})}),j&&o.jsx(Fi,{value:"rag",className:"m-0 h-full",children:o.jsx("div",{className:"h-full",children:o.jsx($L,{ragData:l?c.filter(A=>A.taskId===l):c,enabled:u})})})]})]})})})},rh=xt.memo(({statusText:e,onViewWorkflow:t})=>o.jsxs("div",{className:"flex h-8 items-center space-x-3 py-1",children:[t?o.jsx(A0,{onClick:t}):o.jsx(a5,{className:"mr-3 ml-2"}),o.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:e&&o.jsx("span",{className:"text-muted-foreground animate-pulse truncate text-sm",title:e,children:e})})]})),BL=({onToggle:e})=>o.jsxs("div",{className:"bg-background flex h-full w-100 flex-col border-r",children:[o.jsxs("div",{className:"flex h-20 justify-between border-b px-2 pt-[35px]",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ye,{variant:"ghost",onClick:e,"data-testid":"hideChatSessions",tooltip:"Hide Chat Sessions",children:o.jsx(Ov,{className:"size-5"})}),o.jsx("div",{className:"text-xl",children:"Chats"})]}),o.jsx("div",{className:"flex items-center",children:o.jsx(kS,{buttonText:"New Chat"})})]}),o.jsx("div",{className:"mt-1 min-h-0 flex-1",children:o.jsx(jL,{})})]}),VL=({isOpen:e,onClose:t,onConfirm:n,session:r,projects:s,currentProjectId:a})=>{const[i,l]=d.useState(null),[c,u]=d.useState(!1);if(d.useEffect(()=>{e&&l("")},[e]),!e||!r)return null;const h=async()=>{u(!0);try{await n(i),t()}catch(w){console.error("Failed to move session:",w)}finally{u(!1)}},f=s.filter(w=>w.id!==a),p=()=>a?`Move "${r.name||"Untitled Session"}" to a different project or remove it from the current project.`:`Move "${r.name||"Untitled Session"}" to a project.`,m=()=>a?"No Project (Remove from current)":"No Project",v=()=>a?"Select a project":"Select a project to move to",g=c||i===""||i===null&&!a,x=()=>{c||t()};return o.jsx(Nr,{open:e,onOpenChange:w=>!w&&x(),children:o.jsxs(Tr,{children:[o.jsxs(rs,{children:[o.jsx(Ar,{children:"Move Chat Session"}),o.jsx(Ir,{children:p()})]}),o.jsx("div",{className:"py-4",children:o.jsxs(Wr,{value:i===null?"none":i||"",onValueChange:w=>l(w==="none"?null:w),children:[o.jsx(Gr,{className:"w-full rounded-md",children:o.jsx(Zr,{placeholder:v()})}),o.jsxs(qr,{children:[a&&o.jsx(Pt,{value:"none",children:m()}),f.map(w=>o.jsx(Pt,{value:w.id,children:o.jsx("p",{className:"max-w-sm truncate",children:w.name})},w.id))]})]})}),o.jsxs(Cs,{children:[o.jsx(ye,{variant:"ghost",onClick:x,disabled:c,children:"Cancel"}),o.jsx(ye,{onClick:h,disabled:g,children:c?"Moving...":"Move"})]})]})})},HL=({onSessionSelect:e,projectId:t})=>{const[n,r]=d.useState(""),[s,a]=d.useState([]),[i,l]=d.useState(!1),[c,u]=d.useState(!1),h=XR(n,300),f=d.useCallback(async(g,x)=>{if(!g.trim()){a([]),u(!1);return}l(!0);try{const w=new URLSearchParams({query:g.trim(),pageNumber:"1",pageSize:"20"});x&&w.append("projectId",x);const y=await Ie.webui.get(`/api/v1/sessions/search?${w.toString()}`);a(y.data||[]),u(!0)}catch(w){console.error("Search error:",w),a([])}finally{l(!1)}},[]);d.useEffect(()=>{f(h,t)},[h,t,f]);const p=()=>{r(""),a([]),u(!1)},m=g=>{e(g),p()};return o.jsxs("div",{className:"relative w-full",children:[o.jsxs("div",{className:"relative",children:[o.jsx(co,{className:"text-muted-foreground absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2"}),o.jsx(_r,{type:"text",placeholder:"Search chats by title",value:n,onChange:g=>r(g.target.value),className:"pr-9 pl-9"}),n&&o.jsx(ye,{variant:"ghost",size:"sm",className:"absolute top-1/2 right-1 h-7 w-7 -translate-y-1/2 p-0",onClick:p,children:o.jsx(Kr,{className:"h-4 w-4"})})]}),c&&o.jsx("div",{className:"bg-popover absolute z-50 mt-2 w-full rounded-md border p-2 shadow-md",children:i?o.jsx("div",{className:"text-muted-foreground p-4 text-center text-sm",children:"Searching..."}):s.length>0?o.jsx("div",{className:"max-h-[300px] overflow-y-auto",children:s.map(g=>o.jsxs("button",{onClick:()=>m(g.id),className:"hover:bg-accent hover:text-accent-foreground w-full rounded-sm px-3 py-2 text-left text-sm",children:[o.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[o.jsx("div",{className:"flex-1 truncate font-medium",children:g.name||"Untitled Session"}),g.projectName&&o.jsx(Yu,{text:g.projectName})]}),o.jsx("div",{className:"text-muted-foreground text-xs",children:new Date(g.updatedTime).toLocaleDateString()})]},g.id))}):o.jsx("div",{className:"text-muted-foreground p-4 text-center text-sm",children:"No results found"})})]})},_i=(e,t)=>o.jsx(go,{type:t,className:"rounded-full border-none",children:o.jsx("span",{className:"text-xs font-semibold",title:e,children:e})}),WL=(e,t)=>{var r;if(e.currentStatusText)return o.jsx("div",{title:e.currentStatusText,children:o.jsx(rh,{statusText:e.currentStatusText})});const n=(r=t==null?void 0:t.parts)==null?void 0:r.filter(s=>s.kind==="text").map(s=>s.text).join("");switch(e.status){case"submitted":case"working":return o.jsx("div",{title:n||e.status,children:o.jsx(rh,{statusText:n||e.status})});case"input-required":return _i("Input Required","info");case"completed":return _i("Completed","success");case"canceled":return _i("Canceled","info");case"failed":return _i("Failed","error");default:return _i("Unknown","info")}},ZL=({task:e})=>{const{messages:t,addNotification:n,displayError:r}=$t(),{configFeatureEnablement:s}=on(),a=(s==null?void 0:s.taskLogging)??!1,i=d.useMemo(()=>{const c=t.find(u=>u.isStatusBubble);return e?WL(e,c):null},[t,e]),l=async()=>{try{const c=await Ie.webui.get(`/api/v1/tasks/${e.taskId}`,{fullResponse:!0});if(!c.ok)throw new Error(`Failed to download task log: ${c.statusText}`);const u=await c.blob();hl(u,`${e.taskId}.stim`),n("Task log downloaded","success")}catch(c){r({title:"Failed to Download Task Log",error:Zt(c,"An unknown error occurred while downloading the task log.")})}};return e?o.jsxs("div",{className:"grid grid-cols-[auto_1fr_auto] grid-rows-[32px_32px] items-center gap-x-8 border-b p-4",children:[o.jsx("div",{className:"text-muted-foreground",children:"User"}),o.jsx("div",{className:"truncate",title:e.initialRequestText,children:e.initialRequestText}),o.jsx("div",{}),o.jsx("div",{className:"text-muted-foreground",children:"Status"}),o.jsx("div",{className:"truncate",children:i}),o.jsx("div",{children:a&&o.jsx(ye,{variant:"ghost",size:"icon",onClick:l,tooltip:"Download Task Log (.stim)",disabled:!e.taskId,children:o.jsx(yo,{})})})]}):null};class jS{getEdgeAnimationState(t,n,r){const s=r.find(l=>l.id===t);if(!s)return{isAnimated:!1,animationType:"static"};if(!this.isAgentToToolRequest(s))return{isAnimated:!1,animationType:"static"};const a=r.slice(0,n+1);return this.hasMatchingResponse(s,a)?{isAnimated:!1,animationType:"static"}:{isAnimated:!0,animationType:"request"}}isAgentToToolRequest(t){var n,r;switch(t.type){case"AGENT_LLM_CALL":return!0;case"AGENT_TOOL_INVOCATION_START":return!(((n=t.data.toolDecision)==null?void 0:n.isPeerDelegation)||((r=t.data.toolInvocationStart)==null?void 0:r.isPeerInvocation)||t.target&&t.target.startsWith("peer_"));default:return!1}}hasMatchingResponse(t,n){switch(t.type){case"AGENT_LLM_CALL":return this.hasLLMResponse(t,n);case"AGENT_TOOL_INVOCATION_START":return this.hasToolResponse(t,n);default:return!1}}hasLLMResponse(t,n){const r=new Date(t.timestamp).getTime(),s=t.source;return n.some(a=>{var h;if(new Date(a.timestamp).getTime()<r)return!1;const l=(a.type==="AGENT_LLM_RESPONSE_TOOL_DECISION"||a.type==="AGENT_LLM_RESPONSE_TO_AGENT")&&a.target===s,c=a.source===s&&(a.type==="AGENT_TOOL_INVOCATION_START"||a.type==="TASK_COMPLETED"),u=a.type==="AGENT_TOOL_EXECUTION_RESULT"&&((h=a.data.toolResult)==null?void 0:h.isPeerResponse);return l||c||u})}hasToolResponse(t,n){const r=new Date(t.timestamp).getTime(),s=t.target,a=t.source;return n.some(i=>new Date(i.timestamp).getTime()<r?!1:i.type==="AGENT_TOOL_EXECUTION_RESULT"&&i.source===s&&i.target===a)}isRequestStep(t){return this.isAgentToToolRequest(t)}isResponseStep(t){return["AGENT_TOOL_EXECUTION_RESULT","AGENT_LLM_RESPONSE_TOOL_DECISION","AGENT_LLM_RESPONSE_TO_AGENT"].includes(t.type)}}function ES(e,t){return(t==null?void 0:t[e])||e}const jr={USER:50,MAIN_FLOW:300,TOOLS:600},GL=50,jn=50,hr=330,Ko=50,cs=20,Xo=10,Ax=jn+20,qL=90;function vo(e,t,n){return e.push(n),t.add(n.id),n}function YL(e,t){return e.push(t),t}function wo(e,t){return e.nodeIdCounter++,`${t.replace(/[^a-zA-Z0-9_]/g,"_")}_${e.nodeIdCounter}`}function $n(e){return e.currentPhaseIndex===-1||e.currentPhaseIndex>=e.phases.length?null:e.phases[e.currentPhaseIndex]}function Il(e){const t=$n(e);return!t||e.currentSubflowIndex===-1||e.currentSubflowIndex>=t.subflows.length?null:t.subflows[e.currentSubflowIndex]}function KL(e,t,n){var r;for(let s=e.length-1;s>=0;s--){const a=e[s],i=n.find(l=>l.id===a.id);if(((r=i==null?void 0:i.data)==null?void 0:r.toolName)===t)return a}return null}function XL(e,t){if(!t)return null;const n=$n(e);return n&&n.subflows.findLast(r=>r.functionCallId===t)||null}function JL(e,t){if(!t)return null;const n=$n(e);return n&&n.subflows.findLast(r=>r.id===t)||null}function Rl(e,t){var s;const n=$n(e);if(!n)return null;if(t.functionCallId){const a=XL(e,t.functionCallId);if(a)return a}if(t.owningTaskId&&t.isSubTaskStep){const a=JL(e,t.owningTaskId);if(a){const i=n.subflows||[];if(!(new Set(i.map(c=>c.id)).size!==i.length))return a}}const r=Il(e);if(r&&t.source){const a=t.source.replace(/[^a-zA-Z0-9_]/g,"_"),i=(s=t.target)==null?void 0:s.replace(/[^a-zA-Z0-9_]/g,"_"),l=r.peerAgent.id;if(l.includes(a)||i&&l.includes(i))return r}return r||null}function NS(e,t){var r,s,a;if(((r=e.data.toolDecision)==null?void 0:r.isParallel)===!0)return!0;const n=(a=(s=e.data)==null?void 0:s.toolInvocationStart)==null?void 0:a.functionCallId;return n?Array.from(t.parallelFlows.values()).some(i=>i.subflowFunctionCallIds.includes(n)):!1}function Vm(e,t,n,r){var s;if(r)for(let a=e.length-1;a>=0;a--){const i=e[a];if(i.functionCallId===r){const l=n.find(c=>c.id===i.id);if(((s=l==null?void 0:l.data)==null?void 0:s.toolName)===t||t==="LLM")return i}}return KL(e,t,n)}function QL(e,t,n){const r=$n(e);if(!r)return null;const s=t.replace(/[^a-zA-Z0-9_]/g,"_"),a=n==null?void 0:n.replace(/[^a-zA-Z0-9_]/g,"_");let i=null;for(const l of r.subflows)if(l.peerAgent.id.includes(s)||a&&l.peerAgent.id.includes(a)){i=l;break}if(!i)return null;if(i.isParallel)return i;if(i.parentSubflowId){const l=r.subflows.find(c=>c.id===i.parentSubflowId);if(l&&l.isParallel)return l;if(l)return TS(r,l)}return null}function TS(e,t){if(t.isParallel)return t;if(t.parentSubflowId){const n=e.subflows.find(r=>r.id===t.parentSubflowId);if(n)return TS(e,n)}return null}function Ja(e,t,n,r){const s=`phase_${e.phases.length}`,a=wo(e,`${t}_${s}`),i=e.nextAvailableGlobalY,l=ES(t,e.agentNameMap),c={id:a,type:"orchestratorNode",position:{x:jr.MAIN_FLOW,y:i},data:{label:l,visualizerStepId:n.id}};vo(r,e.allCreatedNodeIds,c),e.nodePositions.set(a,c.position);const u={id:a,yPosition:i,height:jn,width:hr},h={id:a,name:t,type:"orchestrator",phaseId:s,context:"main",nodeInstance:u};e.agentRegistry.registerAgent(h);const f={id:s,orchestratorAgent:u,userNodes:[],subflows:[],toolInstances:[],currentToolYOffset:0,maxY:i+jn};return e.phases.push(f),e.currentPhaseIndex=e.phases.length-1,e.currentSubflowIndex=-1,e.nextAvailableGlobalY=f.maxY+Ko,f}function sh(e,t,n,r,s){var A,P,E,R,_;const a=$n(e);if(!a)return null;const i=n.type==="AGENT_TOOL_EXECUTION_RESULT"&&((A=n.data.toolResult)==null?void 0:A.isPeerResponse)===!0,l=n.source||"",c=n.target||"",u=Qa(l);!i&&!u&&!s&&e.indentationLevel++;const h=((E=(P=n.delegationInfo)==null?void 0:P[0])==null?void 0:E.subTaskId)||n.owningTaskId,f=wo(e,`${t}_${h}`),p=wo(e,`group_${t}_${h}`),m=((_=(R=n.data)==null?void 0:R.toolInvocationStart)==null?void 0:_.functionCallId)||n.functionCallId||"";let v,g,x;const w=Array.from(e.parallelFlows.values()).find(M=>M.subflowFunctionCallIds.includes(m)),y=Il(e),C=QL(e,l,c);s&&w?(v=w.startX+w.currentXOffset,g=w.startY,x=g+cs,w.currentXOffset+=(hr+Xo)*2.2):C?(x=e.nextAvailableGlobalY,v=(C.groupNode.xPosition||jr.MAIN_FLOW-50)+e.indentationLevel*e.indentationStep,g=x-cs):(x=e.nextAvailableGlobalY,v=jr.MAIN_FLOW-50+e.indentationLevel*e.indentationStep,g=x-cs);const S=ES(t,e.agentNameMap),j={id:f,type:"genericAgentNode",position:{x:50,y:cs},data:{label:S,visualizerStepId:n.id},parentId:p},I={id:p,type:"group",position:{x:v,y:g},data:{label:`${S} Sub-flow`},style:{backgroundColor:"rgba(220, 220, 255, 0.1)",border:"1px solid #aac",borderRadius:"8px",minHeight:`${jn+2*cs}px`}};vo(r,e.allCreatedNodeIds,I),vo(r,e.allCreatedNodeIds,j),e.nodePositions.set(f,j.position),e.nodePositions.set(p,I.position);const b={id:f,xPosition:jr.MAIN_FLOW,yPosition:x,height:jn,width:hr},k={id:f,name:t,type:"peer",phaseId:a.id,subflowId:h,context:"subflow",nodeInstance:b};e.agentRegistry.registerAgent(k);const N={id:h,functionCallId:m,isParallel:s,peerAgent:b,groupNode:{id:p,xPosition:v,yPosition:g,height:jn+2*cs,width:0},toolInstances:[],currentToolYOffset:0,maxY:x+jn,maxContentXRelative:j.position.x+hr,callingPhaseId:a.id,parentSubflowId:y==null?void 0:y.id,inheritedXOffset:C==null?void 0:C.groupNode.xPosition};return a.subflows.push(N),C&&(C.lastSubflow=N),e.currentSubflowIndex=a.subflows.length-1,s&&w?(w.maxHeight=Math.max(w.maxHeight,N.groupNode.height),e.nextAvailableGlobalY=w.startY+w.maxHeight+Ko):e.nextAvailableGlobalY=N.groupNode.yPosition+N.groupNode.height+Ko,N}function AS(e,t,n,r,s,a,i=!1){const l=$n(e);if(!l)return null;const c=a?a.toolInstances:l.toolInstances,u=i?"LLM":`Tool: ${t}`,h=i?"LLM":t,f=a?a.groupNode.id:void 0;let p,m,v,g;if(a){if(p=a.peerAgent.yPosition+a.currentToolYOffset,a.currentToolYOffset+=Ax,v=50+300,a.groupNode.xPosition===void 0||a.groupNode.yPosition===void 0)return null;m=a.groupNode.xPosition+v,g=p-a.groupNode.yPosition}else m=jr.TOOLS,p=l.orchestratorAgent.yPosition+l.currentToolYOffset,l.currentToolYOffset+=Ax,v=m,g=p;const x=wo(e,`${h}_${r.id}`),w={id:x,type:n,position:{x:v,y:g},data:{label:u,visualizerStepId:r.id,toolName:t},parentId:f};vo(s,e.allCreatedNodeIds,w),e.nodePositions.set(x,{x:v,y:g});const y={id:x,xPosition:m,yPosition:p,height:jn,width:hr,functionCallId:r.functionCallId};c.push(y);const C=p+jn;if(a){a.maxY=Math.max(a.maxY,C),a.maxContentXRelative=Math.max(a.maxContentXRelative,v+hr);const S=a.maxY-a.groupNode.yPosition+cs;a.groupNode.height=Math.max(a.groupNode.height,S);const j=a.maxContentXRelative+Xo;a.groupNode.width=Math.max(a.groupNode.width||0,j);const I=s.find(b=>b.id===a.groupNode.id);I&&(I.style={...I.style,height:`${a.groupNode.height}px`,width:`${a.groupNode.width}px`}),e.nextAvailableGlobalY=Math.max(e.nextAvailableGlobalY,a.groupNode.yPosition+a.groupNode.height+Ko)}else l.maxY=Math.max(l.maxY,C),e.nextAvailableGlobalY=Math.max(e.nextAvailableGlobalY,l.maxY+Ko);return y}function Hm(e,t,n,r){e.userNodeCounter++;const s=wo(e,`User_response_${e.userNodeCounter}`),a=e.nextAvailableGlobalY+20,i={id:s,type:"userNode",position:{x:jr.USER,y:a},data:{label:"User",visualizerStepId:n.id,isBottomNode:!0}};vo(r,e.allCreatedNodeIds,i),e.nodePositions.set(s,i.position);const l={id:s,yPosition:a,height:jn,width:hr};t.userNodes.push(l),e.allUserNodes.push(l);const c=a+jn;return t.maxY=Math.max(t.maxY,c),l}function nr(e,t,n,r,s,a,i,l,c){if(!e||!t||e===t)return;const u=s.allCreatedNodeIds.has(e),h=s.allCreatedNodeIds.has(t);if(!u||!h)return;const f=`edge-${e}${l||""}-to-${t}${c||""}-${n.id}`;if(!r.some(m=>m.id===f)){const m=n.title&&n.title.length>30?n.type.replace(/_/g," ").toLowerCase():n.title||"",v=a.isRequestStep(n),g={id:f,source:e,target:t,label:m,type:"defaultFlowEdge",data:{visualizerStepId:n.id,isAnimated:v,animationType:v?"request":"static",duration:1}};l&&(g.sourceHandle=l),c&&(g.targetHandle=c),YL(r,g)}}function eF(){const e=new Map;return{agents:e,findAgentByName(t){const n=t.startsWith("peer_")?t.substring(5):t,r=[];for(const[,s]of e)(s.name===n||s.name===t)&&r.push(s);return r.length===0?null:r.reduce((s,a)=>{const i=parseInt(s.id.split("_").pop()||"0");return parseInt(a.id.split("_").pop()||"0")>i?a:s})},findAgentById(t){for(const[,n]of e)if(n.id===t)return n;return null},registerAgent(t){e.set(t.id,t)}}}function oh(e,t,n){return e==="orchestrator"?t==="output"?n==="bottom"?"orch-bottom-output":"orch-right-output-tools":n==="top"?"orch-top-input":"orch-right-input-tools":t==="output"?n==="bottom"?"peer-bottom-output":"peer-right-output-tools":n==="top"?"peer-top-input":"peer-right-input-tools"}function Qa(e){return e==="OrchestratorAgent"||e.toLowerCase().includes("orchestrator")}const tF=["USER_REQUEST","AGENT_LLM_CALL","AGENT_LLM_RESPONSE_TO_AGENT","AGENT_LLM_RESPONSE_TOOL_DECISION","AGENT_TOOL_INVOCATION_START","AGENT_TOOL_EXECUTION_RESULT","AGENT_RESPONSE_TEXT","AGENT_ARTIFACT_NOTIFICATION","TASK_COMPLETED","TASK_FAILED"];function nF(e,t,n,r,s,a){const i=e.target,l=i.replace(/[^a-zA-Z0-9_]/g,"_"),c=$n(t),u=Il(t);let h,f=!1;if(u?(h=u.peerAgent,h.id.startsWith(l+"_")&&(f=!0)):c&&(h=c.orchestratorAgent,h.id.startsWith(l+"_")&&(f=!0)),f&&h&&c){t.userNodeCounter++;const p=wo(t,`User_continue_${t.userNodeCounter}`),m=t.nextAvailableGlobalY,v={id:p,type:"userNode",position:{x:jr.USER,y:m},data:{label:"User",visualizerStepId:e.id}};vo(n,t.allCreatedNodeIds,v),t.nodePositions.set(p,v.position);const g={id:p,yPosition:m,height:jn,width:hr};c.userNodes.push(g),t.allUserNodes.push(g);const x=m+jn;h.yPosition=Math.max(h.yPosition,m),c.maxY=Math.max(c.maxY,x,h.yPosition+jn),t.nextAvailableGlobalY=c.maxY+Ko;const w=Qa(i)?"orch-left-input":"peer-left-input";nr(g.id,h.id,e,r,t,s,a,"user-right-output",w)}else{const p=Ja(t,i,e,n),m=wo(t,`User_${p.id}`),v={id:m,type:"userNode",position:{x:jr.USER,y:p.orchestratorAgent.yPosition-qL},data:{label:"User",visualizerStepId:e.id,isTopNode:!0}};vo(n,t.allCreatedNodeIds,v),t.nodePositions.set(m,v.position);const g={id:m,yPosition:v.position.y,height:jn,width:hr};p.userNodes.push(g),t.allUserNodes.push(g),t.userNodeCounter++,p.maxY=Math.max(p.maxY,v.position.y+jn),t.nextAvailableGlobalY=p.maxY+Ko,nr(m,p.orchestratorAgent.id,e,r,t,s,a,"user-bottom-output","orch-top-input")}}function rF(e,t,n,r,s,a){const i=$n(t);if(!i)return;const l=Rl(t,e),c=l?l.peerAgent.id:i.orchestratorAgent.id,u=AS(t,"LLM","llmNode",e,n,l,!0);u&&nr(c,u.id,e,r,t,s,a,l?"peer-right-output-tools":"orch-right-output-tools","llm-left-input")}function sF(e,t,n,r,s,a){var v;if(e.type==="AGENT_LLM_RESPONSE_TOOL_DECISION"&&((v=e.data.toolDecision)!=null&&v.isParallel)){const g=`parallel-${e.id}`;e.data.toolDecision.decisions.filter(x=>x.isPeerDelegation).length>1&&t.parallelFlows.set(g,{subflowFunctionCallIds:e.data.toolDecision.decisions.filter(x=>x.isPeerDelegation).map(x=>x.functionCallId),completedSubflows:new Set,startX:jr.MAIN_FLOW-50,startY:t.nextAvailableGlobalY,currentXOffset:0,maxHeight:0})}const i=$n(t);if(!i)return;const l=Rl(t,e);let c;const h=Vm((l||i).toolInstances,"LLM",n,e.functionCallId);if(h)c=h.id;else{console.error(`[Timeline] LLM node not found for step type ${e.type}: ${e.id}. Cannot create edge.`);return}const f=e.target||"UnknownAgent";let p,m;l?(p=l.peerAgent.id,m="peer-right-input-tools"):i.orchestratorAgent.id.startsWith(f.replace(/[^a-zA-Z0-9_]/g,"_")+"_")&&(p=i.orchestratorAgent.id,m="orch-right-input-tools"),c&&p&&m?nr(c,p,e,r,t,s,a,"llm-bottom-output",m):console.error(`[Timeline] Could not determine target agent node ID or handle for step type ${e.type}: ${e.id}. Target agent name: ${f}. Edge will be missing.`)}function oF(e,t,n,r,s,a){var h;const i=$n(t);if(!i)return;const l=e.source||"UnknownSource",c=e.target||"UnknownTool";if(((h=e.data.toolInvocationStart)==null?void 0:h.isPeerInvocation)||c.startsWith("peer_")){const f=c.startsWith("peer_")?c.substring(5):c,p=t.agentRegistry.findAgentByName(l);if(!p){console.error(`[Timeline] Could not find source agent in registry: ${l} for step ${e.id}`);return}const m=p.nodeInstance,v=oh(p.type,"output","bottom"),g=NS(e,t),x=sh(t,f,e,n,g);x&&nr(m.id,x.peerAgent.id,e,r,t,s,a,v,"peer-top-input")}else{const f=Rl(t,e);let p,m;if(f)p=f.peerAgent.id,m="peer-right-output-tools";else{const g=t.agentRegistry.findAgentByName(l);g?(p=g.id,m=oh(g.type,"output","right")):(p=i.orchestratorAgent.id,m="orch-right-output-tools")}const v=AS(t,c,"genericToolNode",e,n,f);v&&nr(p,v.id,e,r,t,s,a,m,`${v.id}-tool-left-input`)}}function aF(e,t,n,r,s,a){var u,h;const i=$n(t);if(!i)return;const l=e.source||"UnknownSource",c=e.target||"OrchestratorAgent";if((u=e.data.toolResult)!=null&&u.isPeerResponse){const f=(h=e.data.toolResult)==null?void 0:h.functionCallId,p=Array.from(t.parallelFlows.entries()).find(([v,g])=>g.subflowFunctionCallIds.includes(f||""));if(p){const[v,g]=p;if(g.completedSubflows.add(f||""),g.completedSubflows.size<g.subflowFunctionCallIds.length)return;const x=i.subflows.filter(S=>g.subflowFunctionCallIds.includes(S.functionCallId)),w=e.target||"OrchestratorAgent";let y,C;if(Qa(w))t.indentationLevel=0,y=Ja(t,w,e,n).orchestratorAgent,C="orch-top-input",t.currentSubflowIndex=-1;else{t.indentationLevel=Math.max(0,t.indentationLevel-1);const S=sh(t,w,e,n,!1);if(!S)return;y=S.peerAgent,C="peer-top-input"}x.forEach(S=>{var j;nr(((j=S.lastSubflow)==null?void 0:j.peerAgent.id)??S.peerAgent.id,y.id,e,r,t,s,a,"peer-bottom-output",C)}),t.parallelFlows.delete(v);return}const m=t.agentRegistry.findAgentByName(l.startsWith("peer_")?l.substring(5):l);if(!m){console.error(`[Timeline] Source peer agent not found for peer response: ${l}.`);return}if(Qa(c)){t.indentationLevel=0;const v=Ja(t,c,e,n);nr(m.id,v.orchestratorAgent.id,e,r,t,s,a,"peer-bottom-output","orch-top-input"),t.currentSubflowIndex=-1}else{t.indentationLevel=Math.max(0,t.indentationLevel-1);const v=NS(e,t)||Array.from(t.parallelFlows.values()).some(x=>x.subflowFunctionCallIds.some(w=>i.subflows.some(y=>y.functionCallId===w))),g=sh(t,c,e,n,v);g&&nr(m.id,g.peerAgent.id,e,r,t,s,a,"peer-bottom-output","peer-top-input")}}else{let f;const p=Rl(t,e),v=Vm((p||i).toolInstances,l,n,e.functionCallId);if(v&&(f=v.id),f){let g,x;if(p)g=p.peerAgent.id,x="peer-right-input-tools";else{const w=t.agentRegistry.findAgentByName(c);w?(g=w.id,x=oh(w.type,"input","right")):(g=i.orchestratorAgent.id,x="orch-right-input-tools")}nr(f,g,e,r,t,s,a,l==="LLM"?"llm-bottom-output":`${f}-tool-bottom-output`,x)}else console.error(`[Timeline] Could not find source tool node for regular tool result: ${e.id}. Step source (tool name): ${l}.`)}}function iF(e,t,n,r,s,a){const i=$n(t);if(!i)return;const l=e.data.artifactNotification,c=(l==null?void 0:l.artifactName)||"Unnamed Artifact",u=Rl(t,e),h=u||i;let f;e.functionCallId&&(f=Vm(h.toolInstances,"",n,e.functionCallId)??void 0),!f&&h.toolInstances.length>0&&(f=h.toolInstances[h.toolInstances.length-1]);let p,m;if(f)p=f.id,m=`${f.id}-tool-right-output-artifact`;else return;const v=wo(t,`Artifact_${c}_${e.id}`),g=u?u.groupNode.id:void 0;let x,w;const y=300,C=100;if(u){const k=n.find(P=>P.id===f.id);let N,A;if(k)N=k.position.x,A=k.position.y;else{const P=u.groupNode.xPosition??jr.TOOLS;N=(f.xPosition??jr.TOOLS)-P,A=(f.yPosition??t.nextAvailableGlobalY)-(u.groupNode.yPosition??t.nextAvailableGlobalY)}x=N+y,w=A}else x=(f.xPosition??jr.TOOLS)+y,w=f.yPosition??t.nextAvailableGlobalY;const S={id:v,type:"artifactNode",position:{x,y:w},data:{label:"Artifact",visualizerStepId:e.id},parentId:g};vo(n,t.allCreatedNodeIds,S),t.nodePositions.set(v,{x,y:w});const j={id:v};nr(p,j.id,e,r,t,s,a,m,`${j.id}-artifact-left-input`);const I=w+jn,b=x+hr;if(u){u.maxY=Math.max(u.maxY,I),u.maxContentXRelative=Math.max(u.maxContentXRelative,b-C);const k=u.maxContentXRelative+Xo;u.groupNode.width=Math.max(u.groupNode.width||0,k);const N=n.find(A=>A.id===u.groupNode.id);N&&N.style&&(N.style.width=`${u.groupNode.width}px`)}i.maxY=Math.max(i.maxY,I)}function lF(e,t,n,r,s,a){const i=$n(t);if(!i||e.isSubTaskStep)return;const l=i.orchestratorAgent.id,c=Hm(t,i,e,n);nr(l,c.id,e,r,t,s,a,"orch-bottom-output","user-top-input")}function cF(e,t,n,r,s,a){const i=$n(t);if(!i)return;const l=Array.from(t.parallelFlows.values()).find(m=>m.subflowFunctionCallIds.includes(e.functionCallId||""));if(l){if(l.completedSubflows.add(e.functionCallId||""),l.completedSubflows.size===l.subflowFunctionCallIds.length){t.indentationLevel=0;const m=Ja(t,"OrchestratorAgent",e,n);i.subflows.forEach(v=>{l.subflowFunctionCallIds.includes(v.functionCallId)&&nr(v.peerAgent.id,m.orchestratorAgent.id,e,r,t,s,a,"peer-bottom-output","orch-top-input")}),t.currentSubflowIndex=-1}return}if(!e.isSubTaskStep)return;const c=Il(t);if(!c){console.warn(`[Timeline] TASK_COMPLETED with isSubTaskStep=true but no active subflow. Step ID: ${e.id}`);return}if(!i){console.error(`[Timeline] No current phase found for TASK_COMPLETED. Step ID: ${e.id}`);return}const u=c.peerAgent,h=n.some(m=>typeof m.data.label=="string"&&Qa(m.data.label));let f,p;h?(t.indentationLevel=0,f=Ja(t,"OrchestratorAgent",e,n).orchestratorAgent.id,p="orch-top-input"):(f=Hm(t,i,e,n).id,p="user-top-input"),nr(u.id,f,e,r,t,s,a,"peer-bottom-output",p),t.currentSubflowIndex=-1}function uF(e,t,n,r){const s=$n(t);if(!s)return;const a=e.source||"UnknownSource",i=e.target||"User";let l,c="orch-bottom-output";const u=Il(t);if(u&&u.peerAgent.id.includes(a.replace(/[^a-zA-Z0-9_]/g,"_")))l=u.peerAgent,c="peer-bottom-output";else if(s.orchestratorAgent.id.includes(a.replace(/[^a-zA-Z0-9_]/g,"_")))l=s.orchestratorAgent,c="orch-bottom-output";else for(const p of s.subflows)if(p.peerAgent.id.includes(a.replace(/[^a-zA-Z0-9_]/g,"_"))){l=p.peerAgent,c="peer-bottom-output";break}if(!l){console.error(`[Timeline] Could not find source agent node for TASK_FAILED: ${a}`);return}let h,f;Qa(i)?(t.indentationLevel=0,h=Ja(t,i,e,n).orchestratorAgent.id,f="orch-top-input",t.currentSubflowIndex=-1):(h=Hm(t,s,e,n).id,f="user-top-input"),dF(l.id,h,e,r,t,c,f)}function dF(e,t,n,r,s,a,i){var f;if(!e||!t||e===t)return;const l=s.allCreatedNodeIds.has(e),c=s.allCreatedNodeIds.has(t);if(!l||!c)return;const u=`error-edge-${e}${a||""}-to-${t}${i||""}-${n.id}`;if(!r.some(p=>p.id===u)){const p=((f=n.data.errorDetails)==null?void 0:f.message)||"Task failed",m=p.length>30?"Error":p,v={id:u,source:e,target:t,label:m,type:"defaultFlowEdge",data:{visualizerStepId:n.id,isAnimated:!1,animationType:"static",isError:!0,errorMessage:p}};a&&(v.sourceHandle=a),i&&(v.targetHandle=i),r.push(v)}}const fF=(e,t={})=>{const n=[],r=[];if(!e||e.length===0)return{nodes:n,edges:r};const s=new jS,a={phases:[],currentPhaseIndex:-1,currentSubflowIndex:-1,parallelFlows:new Map,nextAvailableGlobalY:GL,nodeIdCounter:0,allCreatedNodeIds:new Set,nodePositions:new Map,allUserNodes:[],userNodeCounter:0,agentRegistry:eF(),indentationLevel:0,indentationStep:50,agentNameMap:t},i=e.filter(u=>tF.includes(u.type)),l=i.findIndex(u=>u.type==="USER_REQUEST");let c=i;l>0&&(c=[i[l],...i.slice(0,l),...i.slice(l+1)]);for(const u of c)switch(u.type){case"USER_REQUEST":nF(u,a,n,r,s,e);break;case"AGENT_LLM_CALL":rF(u,a,n,r,s,e);break;case"AGENT_LLM_RESPONSE_TO_AGENT":case"AGENT_LLM_RESPONSE_TOOL_DECISION":sF(u,a,n,r,s,e);break;case"AGENT_TOOL_INVOCATION_START":oF(u,a,n,r,s,e);break;case"AGENT_TOOL_EXECUTION_RESULT":aF(u,a,n,r,s,e);break;case"AGENT_RESPONSE_TEXT":lF(u,a,n,r,s,e);break;case"AGENT_ARTIFACT_NOTIFICATION":iF(u,a,n,r,s,e);break;case"TASK_COMPLETED":cF(u,a,n,r,s,e);break;case"TASK_FAILED":uF(u,a,n,r);break}return a.phases.forEach(u=>{u.subflows.forEach(h=>{const f=n.find(p=>p.id===h.groupNode.id);if(f&&f.style){const m=h.maxY-h.groupNode.yPosition+cs;f.style.height=`${Math.max(jn+2*cs,m)}px`;const v=h.maxContentXRelative+Xo,g=hr+2*Xo+a.indentationLevel*a.indentationStep;f.style.width=`${Math.max(v,g)}px`}})}),{nodes:n,edges:r}},hF=({id:e,sourceX:t,sourceY:n,targetX:r,targetY:s,sourcePosition:a,targetPosition:i,style:l={},markerEnd:c,data:u})=>{const[h,f]=d.useState(!1),[p]=C_({sourceX:t,sourceY:n,sourcePosition:a,targetX:r,targetY:s,targetPosition:i}),m=()=>{const x={strokeWidth:h?3:2,stroke:"var(--color-muted-foreground)",...l},w=u;return w!=null&&w.isError?{...x,stroke:h?"var(--color-error-wMain)":"var(--color-error-w70)",strokeWidth:h?3:2}:w!=null&&w.isSelected?{...x,stroke:"#3b82f6",strokeWidth:3}:w!=null&&w.isAnimated?{...x,stroke:h?"#1d4ed8":"#3b82f6",strokeWidth:h?4:3}:h?{...x,stroke:"var(--edge-hover-color)"}:x},v=()=>f(!0),g=()=>f(!1);return o.jsxs(o.Fragment,{children:[o.jsx("path",{id:`${e}-interaction`,style:{strokeWidth:16,stroke:"transparent",fill:"none",cursor:"pointer"},className:"react-flow__edge-interaction",d:p,onMouseEnter:v,onMouseLeave:g}),o.jsx("path",{id:e,style:{...m(),cursor:"pointer",transition:"all 0.2s ease-in-out"},className:"react-flow__edge-path",d:p,markerEnd:c,onMouseEnter:v,onMouseLeave:g})]})},mF=({data:e})=>o.jsxs("div",{className:"cursor-pointer rounded-md border-2 border-blue-700 bg-white px-5 py-3 text-gray-800 shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-blue-600 dark:bg-gray-800 dark:text-gray-200",style:{minWidth:"180px",textAlign:"center"},children:[o.jsx(Sn,{type:"target",position:_n.Top,id:"peer-top-input",className:"!bg-blue-700",isConnectable:!0}),o.jsx(Sn,{type:"source",position:_n.Right,id:"peer-right-output-tools",className:"!bg-blue-700",style:{top:"25%"},isConnectable:!0}),o.jsx(Sn,{type:"target",position:_n.Right,id:"peer-right-input-tools",className:"!bg-blue-700",style:{top:"75%"},isConnectable:!0}),o.jsx(Sn,{type:"source",position:_n.Bottom,id:"peer-bottom-output",className:"!bg-blue-700",isConnectable:!0}),o.jsx(Sn,{type:"target",position:_n.Left,id:"peer-left-input",className:"!bg-blue-700",isConnectable:!0}),o.jsx("div",{className:"flex items-center justify-center",children:o.jsx("div",{className:"text-md truncate font-semibold",style:{maxWidth:"200px"},children:e.label})})]}),pF=({data:e,id:t})=>{const n=()=>{switch(e.status){case"completed":return"bg-green-500";case"in-progress":return"bg-blue-500";case"error":return"bg-red-500";case"started":return"bg-yellow-400";case"idle":default:return"bg-cyan-500"}};return o.jsxs("div",{className:"cursor-pointer rounded-lg border-2 border-cyan-600 bg-white px-3 py-3 text-gray-800 shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-cyan-400 dark:bg-gray-800 dark:text-gray-200",style:{minWidth:"100px",textAlign:"center"},children:[o.jsx(Sn,{type:"target",position:_n.Left,id:`${t}-tool-left-input`,className:"!bg-cyan-500",isConnectable:!0,style:{top:"25%"}}),o.jsxs("div",{className:"flex items-center justify-center",children:[o.jsx("div",{className:`mr-2 h-2 w-2 rounded-full ${n()}`}),o.jsx("div",{className:"text-md truncate",style:{maxWidth:"200px"},children:e.label})]}),o.jsx(Sn,{type:"source",position:_n.Left,id:`${t}-tool-bottom-output`,className:"!bg-cyan-500",isConnectable:!0,style:{top:"75%"}}),o.jsx(Sn,{type:"source",position:_n.Right,id:`${t}-tool-right-output-artifact`,className:"!bg-cyan-500",isConnectable:!0,style:{top:"50%"}})]})},gF=({data:e})=>{const t=()=>{switch(e.status){case"completed":return"bg-green-500";case"in-progress":return"bg-blue-500";case"error":return"bg-red-500";case"started":return"bg-yellow-400";case"idle":default:return"bg-teal-500"}};return o.jsxs("div",{className:"cursor-pointer rounded-lg border-2 border-teal-600 bg-white px-3 py-3 text-gray-800 shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-teal-400 dark:bg-gray-800 dark:text-gray-200",style:{minWidth:"100px",textAlign:"center"},children:[o.jsx(Sn,{type:"target",position:_n.Left,id:"llm-left-input",className:"!bg-teal-500",isConnectable:!0,style:{top:"25%"}}),o.jsxs("div",{className:"flex items-center justify-center",children:[o.jsx("div",{className:`mr-2 h-2 w-2 rounded-full ${t()}`}),o.jsx("div",{className:"text-md",children:e.label})]}),o.jsx(Sn,{type:"source",position:_n.Left,id:"llm-bottom-output",className:"!bg-teal-500",isConnectable:!0,style:{top:"75%"}})]})},xF=({data:e})=>o.jsxs("div",{className:"cursor-pointer rounded-lg border-indigo-600 bg-gradient-to-r from-indigo-50 to-purple-50 px-5 py-3 text-gray-900 shadow-xl transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-2xl dark:border-indigo-400 dark:bg-gradient-to-r dark:from-indigo-900 dark:to-purple-900 dark:text-gray-100",style:{minWidth:"180px",textAlign:"center",borderWidth:"2px",borderStyle:"solid",boxShadow:"0 0 0 1px rgba(79, 70, 229, 0.3), 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)"},children:[o.jsx(Sn,{type:"source",position:_n.Right,id:"orch-right-output-tools",className:"!bg-indigo-500",style:{top:"25%"},isConnectable:!0}),o.jsx(Sn,{type:"target",position:_n.Right,id:"orch-right-input-tools",className:"!bg-indigo-500",style:{top:"75%"},isConnectable:!0}),o.jsx(Sn,{type:"target",position:_n.Top,id:"orch-top-input",className:"!bg-indigo-500",isConnectable:!0}),o.jsx(Sn,{type:"source",position:_n.Bottom,id:"orch-bottom-output",className:"!bg-indigo-500",isConnectable:!0}),o.jsx(Sn,{type:"target",position:_n.Left,id:"orch-left-input",className:"!bg-indigo-500",isConnectable:!0}),o.jsx("div",{className:"flex items-center justify-center",children:o.jsx("div",{className:"text-md truncate font-bold",style:{maxWidth:"200px"},children:e.label})})]}),vF=({data:e})=>{const t=()=>{switch(e.status){case"completed":return"bg-green-500";case"in-progress":return"bg-blue-500";case"error":return"bg-red-500";case"started":return"bg-yellow-400";case"idle":default:return"bg-purple-500"}};return o.jsxs("div",{className:"cursor-pointer rounded-md border-2 border-purple-600 bg-white px-4 py-3 text-gray-800 shadow-lg transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-purple-400 dark:bg-gray-700 dark:text-gray-200",style:{minWidth:"120px",textAlign:"center"},children:[e.isTopNode&&o.jsx(Sn,{type:"source",position:_n.Bottom,id:"user-bottom-output",className:"!bg-gray-500",isConnectable:!0}),e.isBottomNode&&o.jsx(Sn,{type:"target",position:_n.Top,id:"user-top-input",className:"!bg-gray-500",isConnectable:!0}),!e.isTopNode&&!e.isBottomNode&&o.jsx(Sn,{type:"source",position:_n.Right,id:"user-right-output",className:"!bg-gray-500",isConnectable:!0}),o.jsxs("div",{className:"flex items-center justify-center",children:[o.jsx("div",{className:`mr-2 h-3 w-3 rounded-full ${t()}`}),o.jsx("div",{className:"text-sm font-bold",children:e.label})]})]})},wF=({data:e,id:t})=>o.jsxs("div",{className:"cursor-pointer rounded-lg border-2 border-purple-600 bg-white px-3 py-3 text-gray-800 shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-purple-400 dark:bg-gray-800 dark:text-gray-200",style:{minWidth:"120px",textAlign:"center"},children:[o.jsx(Sn,{type:"target",position:_n.Left,id:`${t}-artifact-left-input`,className:"!bg-purple-500",isConnectable:!0}),o.jsx("div",{className:"flex flex-col items-center justify-center gap-1",children:o.jsxs("div",{className:"flex items-center justify-center",children:[o.jsx("div",{className:"mr-2 h-2 w-2 rounded-full bg-purple-500"}),o.jsx("div",{className:"text-md",children:e.label})]})})]}),yF=({step:e,isHighlighted:t,onClick:n,variant:r="list"})=>{const{artifacts:s,setPreviewArtifact:a,setActiveSidePanelTab:i,setIsSidePanelCollapsed:l,navigateArtifactVersion:c}=$t(),u=()=>{var b,k,N;switch(e.type){case"USER_REQUEST":return o.jsx(Tc,{className:"mr-2 text-blue-500 dark:text-blue-400",size:18});case"AGENT_RESPONSE_TEXT":return o.jsx(od,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"TASK_COMPLETED":return o.jsx(lu,{className:"mr-2 text-green-500 dark:text-green-400",size:18});case"TASK_FAILED":return o.jsx(Sv,{className:"mr-2 text-red-500 dark:text-red-400",size:18});case"AGENT_LLM_CALL":return o.jsx(od,{className:"mr-2 text-purple-500 dark:text-purple-400",size:18});case"AGENT_LLM_RESPONSE_TO_AGENT":return o.jsx(od,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"AGENT_LLM_RESPONSE_TOOL_DECISION":{const A=(k=(b=e.data.toolDecision)==null?void 0:b.decisions)==null?void 0:k[0];return(A==null?void 0:A.isPeerDelegation)?o.jsx(ip,{className:"mr-2 text-orange-500 dark:text-orange-400",size:18}):o.jsx(lp,{className:"mr-2 text-orange-500 dark:text-orange-400",size:18})}case"AGENT_TOOL_INVOCATION_START":return(N=e.data.toolInvocationStart)!=null&&N.isPeerInvocation?o.jsx(ip,{className:"mr-2 text-cyan-500 dark:text-cyan-400",size:18}):o.jsx(lp,{className:"mr-2 text-cyan-500 dark:text-cyan-400",size:18});case"AGENT_TOOL_EXECUTION_RESULT":return o.jsx(S_,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"AGENT_ARTIFACT_NOTIFICATION":return o.jsx(Sr,{className:"mr-2 text-indigo-500 dark:text-indigo-400",size:18});default:return o.jsx(Lv,{className:"mr-2 text-gray-500 dark:text-gray-400",size:18})}},h=new Date(e.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),f=String(new Date(e.timestamp).getMilliseconds()).padStart(3,"0"),p=`${h}.${f}`,m=b=>o.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[o.jsxs("p",{children:[o.jsx("strong",{children:"Model:"})," ",b.modelName]}),o.jsx("p",{className:"mt-1",children:o.jsx("strong",{children:"Prompt Preview:"})}),o.jsx("pre",{className:"max-h-28 overflow-y-auto rounded bg-gray-100 p-1.5 font-mono text-xs break-all whitespace-pre-wrap dark:bg-gray-700",children:b.promptPreview})]}),v=({data:b})=>{const[k,N]=xt.useState(!1),A=P=>{P.stopPropagation(),N(!k)};return k?o.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[o.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[o.jsx("strong",{children:"LLM Response Details:"}),o.jsx("button",{onClick:A,className:"text-xs text-blue-500 underline hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:"Hide details"})]}),b.modelName&&o.jsxs("p",{children:[o.jsx("strong",{children:"Model:"})," ",b.modelName]}),o.jsxs("div",{className:"mt-1",children:[o.jsx("p",{children:o.jsx("strong",{children:"Response Preview:"})}),o.jsx("pre",{className:"max-h-28 overflow-y-auto rounded bg-gray-100 p-1.5 font-mono text-xs break-all whitespace-pre-wrap dark:bg-gray-700",children:b.responsePreview})]}),b.isFinalResponse!==void 0&&o.jsxs("p",{className:"mt-1",children:[o.jsx("strong",{children:"Final Response:"})," ",b.isFinalResponse?"Yes":"No"]})]}):o.jsxs("div",{className:"mt-1.5 flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[o.jsx("span",{className:"italic",children:"Internal LLM response"}),o.jsx("button",{onClick:A,className:"text-xs text-blue-500 underline hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:"Show details"})]})},g=b=>o.jsxs("div",{className:"mt-1.5 rounded-md bg-blue-50 p-2 font-mono text-xs text-blue-700 dark:bg-blue-900 dark:text-blue-300",children:[o.jsx("p",{className:"mb-2",children:o.jsxs("strong",{children:["🔧 ",b.isParallel?"Parallel Tool Calls:":"Tool Call:"]})}),o.jsx("ul",{className:"space-y-1 pl-2",children:b.decisions.map(k=>o.jsxs("li",{className:"flex items-center",children:[o.jsx("span",{className:"mr-2",children:"•"}),o.jsx("code",{children:k.toolName})]},k.functionCallId))})]}),x=b=>o.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[o.jsxs("p",{children:[o.jsx("strong",{children:"Tool:"})," ",b.toolName]}),o.jsx("p",{className:"mt-1",children:o.jsx("strong",{children:"Arguments:"})}),o.jsx("div",{className:"max-h-40 overflow-y-auto rounded bg-gray-100 p-1.5 dark:bg-gray-700",children:o.jsx(fh,{data:b.toolArguments})})]}),w=b=>typeof b=="object"?o.jsx(fh,{data:b}):o.jsx("pre",{className:"font-mono text-xs break-all whitespace-pre-wrap",children:String(b)}),y=b=>{let k=null,N=!1;try{if(md(b.resultData)?k=JSON.parse(b.resultData):typeof b.resultData=="object"&&(k=b.resultData),k!=null&&k.result){const A=md(k.result)?JSON.parse(k.result):k.result;A!=null&&A.images&&Array.isArray(A.images)&&A.images.length>0&&(N=!0)}}catch{}return o.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[o.jsxs("p",{children:[o.jsx("strong",{children:"Tool:"})," ",b.toolName]}),N&&(k!=null&&k.result)?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"mt-1",children:o.jsx("strong",{children:"Image Results:"})}),o.jsx(xS,{images:md(k.result)?JSON.parse(k.result).images:k.result.images}),o.jsxs("details",{className:"mt-2",children:[o.jsx("summary",{className:"cursor-pointer text-xs text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:"Show full result data"}),o.jsx("div",{className:"mt-2 max-h-40 overflow-y-auto rounded bg-gray-100 p-1.5 dark:bg-gray-700",children:w(b.resultData)})]})]}):o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"mt-1",children:o.jsx("strong",{children:"Result:"})}),o.jsx("div",{className:"max-h-40 overflow-y-auto rounded bg-gray-100 p-1.5 dark:bg-gray-700",children:w(b.resultData)})]})]})},C=b=>{const k=async N=>{N.stopPropagation();const A=s.find(P=>P.filename===b.artifactName);A&&(i("files"),l(!1),a(A),b.version!==void 0&&b.version!==A.version&&setTimeout(()=>{c(A.filename,b.version)},100))};return o.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("p",{children:[o.jsx("strong",{children:"Artifact:"})," ",b.artifactName,b.version!==void 0&&o.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[" (v",b.version,")"]})]}),o.jsxs("button",{onClick:k,className:"flex items-center gap-1 text-blue-600 transition-colors hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-300",title:"View in Files tab",children:[o.jsx("span",{className:"text-xs",children:"View File"}),o.jsx(uo,{size:12})]})]}),b.mimeType&&o.jsxs("p",{children:[o.jsx("strong",{children:"Type:"})," ",b.mimeType]}),b.description&&o.jsxs("p",{className:"mt-1",children:[o.jsx("strong",{children:"Description:"})," ",b.description]})]})},S=r==="list"&&e.nestingLevel&&e.nestingLevel>0?{marginLeft:`${e.nestingLevel*24}px`}:{},j=r==="popover"?`
|
|
370
|
+
p-3 bg-transparent hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors duration-150
|
|
371
|
+
${n?"cursor-pointer":""}
|
|
372
|
+
`:`
|
|
373
|
+
mb-3 p-3 border rounded-lg shadow-sm
|
|
374
|
+
bg-white dark:bg-gray-800 hover:shadow-md transition-shadow duration-150
|
|
375
|
+
${t?"border-blue-500 dark:border-blue-400 ring-2 ring-blue-500 dark:ring-blue-400":"border-gray-200 dark:border-gray-700"}
|
|
376
|
+
${n?"cursor-pointer":""}
|
|
377
|
+
`,I=()=>e.type==="AGENT_LLM_RESPONSE_TOOL_DECISION"||e.type==="AGENT_TOOL_INVOCATION_START"?"Delegated to: ":e.type==="AGENT_TOOL_EXECUTION_RESULT"?"Response from: ":"Peer Interaction with: ";return o.jsxs("div",{className:j,style:S,onClick:n,children:[o.jsxs("div",{className:"mb-1.5 flex w-full items-center gap-1",children:[u(),o.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center justify-between gap-2",children:[o.jsx("h4",{className:"flex-1 truncate text-sm font-semibold",title:e.title,children:e.title}),o.jsx("span",{className:"text-muted-foreground shrink-0 font-mono text-xs",children:p})]})]}),e.delegationInfo&&e.delegationInfo.length>0&&o.jsx("div",{className:"mt-2 mb-1.5 space-y-2 rounded-r-md border-l-4 border-blue-500 bg-blue-50 p-2 text-sm dark:border-blue-400 dark:bg-gray-700/60",children:e.delegationInfo.map(b=>o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center font-semibold text-blue-700 dark:text-blue-300",children:[o.jsx(Mv,{className:"mr-2 h-4 w-4 flex-shrink-0"}),o.jsxs("span",{children:[I(),b.peerAgentName]})]}),b.subTaskId&&o.jsxs("div",{className:"mt-0.5 ml-[24px] text-xs text-blue-600 dark:text-blue-400",children:["Sub-Task:"," ",o.jsxs("span",{className:"font-mono",title:b.subTaskId,children:[b.subTaskId.substring(0,15),"..."]})]})]},b.functionCallId))}),e.data.text&&o.jsx("div",{className:"max-h-20 overflow-y-auto pl-1 text-sm text-gray-800 dark:text-gray-100",children:o.jsx(Rs,{children:e.data.text})}),e.data.finalMessage&&o.jsx("div",{className:"pl-1 text-sm text-gray-800 dark:text-gray-100",children:o.jsx(Rs,{children:e.data.finalMessage})}),e.type==="TASK_COMPLETED"&&!e.data.finalMessage&&o.jsx("div",{className:"pl-1 text-sm text-gray-600 italic dark:text-gray-300",children:"Task completed successfully."}),e.data.errorDetails&&o.jsxs("div",{className:"mt-1 rounded-md bg-red-50 p-2 pl-1 text-sm text-red-700 dark:bg-red-900/30 dark:text-red-400",children:[o.jsxs("p",{children:[o.jsx("strong",{children:"Error:"})," ",e.data.errorDetails.message]}),e.data.errorDetails.code&&o.jsxs("p",{className:"text-xs",children:["Code: ",e.data.errorDetails.code]})]}),e.data.llmCall&&m(e.data.llmCall),e.data.llmResponseToAgent&&o.jsx(v,{data:e.data.llmResponseToAgent}),e.data.toolDecision&&g(e.data.toolDecision),e.data.toolInvocationStart&&x(e.data.toolInvocationStart),e.data.toolResult&&y(e.data.toolResult),e.data.artifactNotification&&C(e.data.artifactNotification)]})},bF={genericAgentNode:mF,userNode:vF,llmNode:gF,orchestratorNode:xF,genericToolNode:pF,artifactNode:wF},CF={defaultFlowEdge:hF},SF={x:16,y:0},_F=({processedSteps:e,isRightPanelVisible:t=!1,isSidePanelTransitioning:n=!1})=>{const[r,s,a]=k_([]),[i,l,c]=j_([]),{fitView:u}=E_(),{highlightedStepId:h,setHighlightedStepId:f}=mm(),{taskIdInSidePanel:p,agentNameDisplayNameMap:m}=$t(),v=d.useRef([]),[g,x]=d.useState(!1),[w,y]=d.useState(null),[C,S]=d.useState(!1),j=d.useRef(null),[I,b]=d.useState(null),k=d.useRef(new jS),N=d.useMemo(()=>!e||e.length===0?{nodes:[],edges:[]}:fF(e,m),[e,m]),A=d.useMemo(()=>N.edges.length?N.edges.map(D=>{const O=D.data;let K={isAnimated:!1,animationType:"none"};if(O!=null&&O.visualizerStepId){const W=e.length-1;K=k.current.getEdgeAnimationState(O.visualizerStepId,W,e)}let $=D.id===I;return h&&(O==null?void 0:O.visualizerStepId)===h&&($=!0),{...D,animated:K.isAnimated,data:{...O,isAnimated:K.isAnimated,animationType:K.animationType,isSelected:$}}}):[],[N.edges,e,I,h]),P=d.useCallback(()=>{s(D=>D.map(O=>{var de,fe,ge,T;if(O.type!=="group")return O;const K=D.filter(le=>le.parentId===O.id);if(K.length===0)return O;let $=0,W=0;K.forEach(le=>{const ie=le.position.x+hr,q=le.position.y+jn;$=Math.max($,ie),W=Math.max(W,q)});const V=$+Xo,X=W+cs;let H=0;const Q=O.id.split("_");if(Q.length>2){const le=Q.find(ie=>ie.startsWith("subflow"));if(le){const ie=parseInt(le.replace("subflow",""));isNaN(ie)||(H=ie)}}const z=hr+2*Xo+H*50,Z=Math.max(V,z),J=parseInt(((fe=(de=O.style)==null?void 0:de.width)==null?void 0:fe.toString().replace("px",""))||"0"),ce=parseInt(((T=(ge=O.style)==null?void 0:ge.height)==null?void 0:T.toString().replace("px",""))||"0");return J!==Z||ce!==X?{...O,style:{...O.style,width:`${Z}px`,height:`${X}px`}}:O}))},[s]);d.useEffect(()=>{s(N.nodes),l(A),P()},[N.nodes,A,s,l,P]);const E=d.useCallback((D,O)=>i.find(K=>K.source===D&&(O?K.sourceHandle===O:!0))||null,[i]),R=d.useCallback((D,O)=>{var $;x(!0);const K=($=O.data)==null?void 0:$.visualizerStepId;if(K){const W=e.find(V=>V.id===K);W&&(b(O.id),t?f(K):(f(K),y(W),S(!0)))}},[e,t,f]),_=d.useCallback(D=>{switch(D.type){case"userNode":{const O=D.data;return O!=null&&O.isTopNode?["user-bottom-output"]:O!=null&&O.isBottomNode?["user-top-input"]:["user-right-output"]}case"orchestratorNode":return["orch-right-output-tools","orch-bottom-output"];case"genericAgentNode":return["peer-right-output-tools","peer-bottom-output"];case"llmNode":return["llm-bottom-output"];case"genericToolNode":return[`${D.id}-tool-bottom-output`];default:return[]}},[]),M=d.useCallback(()=>{S(!1),y(null)},[]),L=d.useCallback((D,O)=>{if(x(!0),O.type==="group"){f(null),b(null),M();return}const K=_(O);let $=null;for(const W of K)if($=E(O.id,W),$)break;if(!$&&O.type==="userNode"){const W=O.data;W!=null&&W.isBottomNode&&($=i.find(V=>V.target===O.id)||null)}!$&&O.type==="artifactNode"&&($=i.find(W=>W.target===O.id)||null),$&&R(D,$)},[_,f,M,E,i,R]),F=d.useCallback(D=>{D!=null&&D.isTrusted&&x(!0)},[]);return d.useEffect(()=>{x(!1)},[p]),d.useEffect(()=>{!n&&u&&r.length>0&&v.current!==e&&g===!1&&(u({duration:200,padding:.1,maxZoom:1.2}),v.current=e)},[r.length,u,e,n,g]),d.useEffect(()=>{if(s(D=>D.map(O=>{var V;const K=((V=O.data)==null?void 0:V.visualizerStepId)&&O.data.visualizerStepId===h,$=N.nodes.find(X=>X.id===O.id),W=($==null?void 0:$.style)||{};return{...O,style:{...W,boxShadow:K?"0px 4px 12px rgba(0, 0, 0, 0.2)":W.boxShadow||"none",transition:"box-shadow 0.2s ease-in-out"}}})),h){const D=A.find(O=>{const K=O.data;return(K==null?void 0:K.visualizerStepId)===h});D&&b(D.id)}else b(null)},[h,s,N.nodes,A]),!e||e.length===0?o.jsx("div",{className:"flex h-full items-center justify-center text-gray-500 dark:text-gray-400",children:Object.keys(e).length>0?"Processing flow data...":"No steps to display in flow chart."}):N.nodes.length===0&&e.length>0?o.jsx("div",{className:"flex h-full items-center justify-center text-gray-500 dark:text-gray-400",children:"Generating flow chart..."}):o.jsxs("div",{style:{height:"100%",width:"100%"},className:"relative",children:[o.jsxs(N_,{nodes:r,edges:i.map(D=>({...D,markerEnd:{type:R_.ArrowClosed,color:"#888"}})),onNodesChange:a,onEdgesChange:c,onEdgeClick:R,onNodeClick:L,onPaneClick:()=>{f(null),b(null),M()},onMoveStart:F,nodeTypes:bF,edgeTypes:CF,fitViewOptions:{padding:.1},className:"bg-gray-50 dark:bg-gray-900 [&>button]:dark:bg-gray-700",proOptions:{hideAttribution:!0},nodesDraggable:!1,elementsSelectable:!1,nodesConnectable:!1,minZoom:.2,children:[o.jsx(T_,{}),o.jsx(A_,{className:V2()}),o.jsx(I_,{position:"top-right",className:"flex items-center space-x-4",children:o.jsx("div",{ref:j})})]}),o.jsx(KP,{isOpen:C,onClose:M,anchorRef:j,offset:SF,placement:"right-start",className:"max-w-[500px] min-w-[400px] p-2",children:w&&o.jsx(yF,{step:w,variant:"popover"})})]})},kF=e=>o.jsx(__,{children:o.jsx(_F,{...e})}),Gd=e=>e?e.startsWith("web_content_"):!1,IS=e=>{var t,n,r,s;if(e.events&&e.events.length>0){const a=e.events[0];if((s=(r=(n=(t=a.full_payload)==null?void 0:t.params)==null?void 0:n.message)==null?void 0:r.metadata)!=null&&s.parentTaskId)return a.full_payload.params.message.metadata.parentTaskId}},ki=e=>{var t,n,r;return((r=(n=(t=e.full_payload)==null?void 0:t.result)==null?void 0:n.status)==null?void 0:r.timestamp)||e.timestamp},RS=(e,t,n,r)=>{const s=t[e];if(!s)return console.warn(`[collectAllDescendantEvents] Task not found in allMonitoredTasks: ${e}`),[];n.set(e,r);let a=[...s.events||[]];for(const i in t){const l=t[i];if(l.taskId===e)continue;IS(l)===e&&(a=a.concat(RS(l.taskId,t,n,r+1)))}return a},qd=(e,t,n)=>{var D,O,K,$,W;if(!n)return null;if(!((D=n.events)==null?void 0:D.some(V=>V.direction==="request"&&V.task_id===n.taskId))&&n.initialRequestText&&n.events&&n.events.length>0){const V=((O=n.events[0])==null?void 0:O.timestamp)||n.firstSeen.toISOString(),X=new Date(new Date(V).getTime()-1).toISOString();let H="Orchestrator";const Q=n.events[0];Q!=null&&Q.source_entity?H=Q.source_entity:(W=($=(K=Q==null?void 0:Q.full_payload)==null?void 0:K.result)==null?void 0:$.metadata)!=null&&W.agent_name&&(H=Q.full_payload.result.metadata.agent_name);const z={task_id:n.taskId,direction:"request",timestamp:X,source_entity:"User",target_entity:H,event_type:"a2a_message",solace_topic:`synthetic/request/${n.taskId}`,payload_summary:{method:"message/send"},full_payload:{method:"message/send",params:{message:{parts:[{kind:"text",text:n.initialRequestText}]}}}};n.events=[z,...n.events]}const s={overall:{totalTaskDurationMs:0},agents:{}},a=new Map,i=new Map,l=(V,X)=>(s.agents[V]||(s.agents[V]={agentName:X,instanceId:V,displayName:X,llmCalls:[],toolCalls:[],totalLlmTimeMs:0,totalToolTimeMs:0}),s.agents[V]),c=new Map,u=new Map,h=RS(n.taskId,t,c,0);if(h.length===0)return{taskId:n.taskId,initialRequestText:n.initialRequestText,status:"working",startTime:n.firstSeen.toISOString(),steps:[]};const f=h.sort((V,X)=>new Date(ki(V)).getTime()-new Date(ki(X)).getTime()),p=[];let m,v="",g,x,w=[],y=null,C;const S=new Map,j=new Map,I=new Map,b=V=>{if(v.trim()&&g&&x){const X=v.trim();let H=n.taskId;if(w.length>0){const Z=w[0].split("-");Z.length>2&&Z[1]!=="global"&&(H=Z.slice(1,Z.length-1).join("-"))}else V&&(H=V);const Q=c.get(H)??0,z=S.get(H)||I.get(H);p.push({id:`vstep-agenttext-${p.length}-${w[0]||"unknown"}`,type:"AGENT_RESPONSE_TEXT",timestamp:x,title:`${g}: Response`,source:g,target:"User",data:{text:X},rawEventIds:[...w],isSubTaskStep:Q>0,nestingLevel:Q,owningTaskId:H,functionCallId:z}),y=X}v="",g=void 0,x=void 0,w=[],C=void 0};f.forEach((V,X)=>{var le,ie,q,B,ee,U,Y,G,ae,oe,se,me,Pe,Ne,dt,Ht,wt,Ot,gt,Nt,Jt,Wt,xe,$e,Me,Fe,ft,He,Ut,Qe,St,Lt,ln,nn,On,Un,Yt,te,re,ue,Ce,je,Be,qe,Te;const H=ki(V),Q=`raw-${V.task_id||"global"}-${X}`,z=V.full_payload,Z=V.task_id||n.taskId,J=c.get(Z)??0;let ce=V.source_entity||"UnknownAgent";(q=(ie=(le=z==null?void 0:z.params)==null?void 0:le.message)==null?void 0:ie.metadata)!=null&&q.agent_name?ce=z.params.message.metadata.agent_name:(ee=(B=z==null?void 0:z.result)==null?void 0:B.metadata)!=null&&ee.agent_name?ce=z.result.metadata.agent_name:(ae=(G=(Y=(U=z==null?void 0:z.result)==null?void 0:U.status)==null?void 0:Y.message)==null?void 0:G.metadata)!=null&&ae.agent_name?ce=z.result.status.message.metadata.agent_name:(me=(se=(oe=z==null?void 0:z.result)==null?void 0:oe.artifact)==null?void 0:se.metadata)!=null&&me.agent_name&&(ce=z.result.artifact.metadata.agent_name);let de;if(J>0?de=S.get(Z):de=I.get(Z),V.direction==="request"&&J>0){const Se=(Pe=z.params)==null?void 0:Pe.metadata,Ee=Se==null?void 0:Se.function_call_id,Le=V.task_id;if(Le&&Ee){S.set(Le,Ee);return}}if(V.payload_summary.method&&V.payload_summary.method==="tasks/cancel")return;if(V.direction==="request"&&J===0&&V.task_id===n.taskId){b(Z),y=null;const Se=z.params;let Ee="User request";if((Ne=Se==null?void 0:Se.message)!=null&&Ne.parts){const Le=Se.message.parts.filter(_e=>_e.kind==="text"&&_e.text);Le.length>0&&(Ee=Le[Le.length-1].text)}p.push({id:`vstep-userreq-${p.length}-${Q}`,type:"USER_REQUEST",timestamp:H,title:"User Input",source:"User",target:V.target_entity||ce,data:{text:Ee},rawEventIds:[Q],isSubTaskStep:!1,nestingLevel:0,owningTaskId:Z});return}if(V.direction==="status-update"&&(z!=null&&z.result)){const Se=z.result,Ee=(dt=Se.status)==null?void 0:dt.message,Le=Ee==null?void 0:Ee.metadata;let _e;const et=!!(Le!=null&&Le.forwarded_from_peer);et?_e=Le.forwarded_from_peer:(Ht=Se.metadata)!=null&&Ht.agent_name?_e=Se.metadata.agent_name:Le!=null&&Le.agent_name?_e=Le.agent_name:_e=V.source_entity||"Agent";const be=`${_e}:${Z}`;if(!et&&(Ee!=null&&Ee.parts))for(const ne of Ee.parts){if(ne.kind==="data"){const he=ne.data;he.type==="agent_progress_update"?m=he.status_text:he.type==="artifact_creation_progress"&&(m=`Saving artifact: ${he.filename} (${he.bytes_saved} bytes)`)}if(ne.kind==="data"){b(Z);const we=ne.data;switch(we==null?void 0:we.type){case"agent_progress_update":{p.push({id:`vstep-progress-${p.length}-${Q}`,type:"AGENT_RESPONSE_TEXT",timestamp:H,title:`${_e}: Progress Update`,source:_e,target:"User",data:{text:we.status_text},rawEventIds:[Q],isSubTaskStep:J>0,nestingLevel:J,owningTaskId:Z,functionCallId:de});break}case"llm_invocation":{const De=we.request;let ot="System-initiated LLM call";if(De!=null&&De.contents&&Array.isArray(De.contents)&&De.contents.length>0){const mt=[...De.contents].reverse().find(vt=>vt.role==="user");mt&&mt.parts&&(ot=mt.parts.map(vt=>vt.text||"").join(`
|
|
378
|
+
`).trim())}const _t={modelName:(De==null?void 0:De.model)||"Unknown Model",promptPreview:ot||"No text in user prompt."};l(be,_e),a.set(be,{timestamp:H,modelName:_t.modelName}),p.push({id:`vstep-llmcall-${p.length}-${Q}`,type:"AGENT_LLM_CALL",timestamp:H,title:`${_e}: LLM Call`,source:_e,target:"LLM",data:{llmCall:_t},rawEventIds:[Q],isSubTaskStep:J>0,nestingLevel:J,owningTaskId:Z,functionCallId:de});break}case"llm_response":{const De=a.get(be);if(De){const vt=new Date(H).getTime()-new Date(De.timestamp).getTime();l(be,_e).llmCalls.push({modelName:De.modelName,durationMs:vt,timestamp:De.timestamp}),a.delete(be)}const ot=we.data,_t=(wt=ot.content)==null?void 0:wt.parts,mt=_t==null?void 0:_t.filter(vt=>vt.function_call);if(mt&&mt.length>0){b(Z),y=null,I.delete(Z);const vt=mt.map(kt=>{var In;return{functionCallId:kt.function_call.id,toolName:kt.function_call.name,toolArguments:kt.function_call.args||{},isPeerDelegation:(In=kt.function_call.name)==null?void 0:In.startsWith("peer_")}}),En={decisions:vt,isParallel:vt.length>1},Bt=[],Bn=new Set;vt.forEach(kt=>{if(kt.isPeerDelegation){const In=kt.toolName.substring(5);for(const Vn in t){const Dt=t[Vn];if(Bn.has(Dt.taskId))continue;if(IS(Dt)===Z&&Dt.events&&Dt.events.length>0){const Ss=Dt.events.find(Mr=>{var ui,di,fi,Dl;return Mr.direction==="request"&&((Dl=(fi=(di=(ui=Mr.full_payload)==null?void 0:ui.params)==null?void 0:di.message)==null?void 0:fi.metadata)==null?void 0:Dl.function_call_id)===kt.functionCallId});if(Ss&&new Date(ki(Ss)).getTime()>=new Date(H).getTime()){const Mr={functionCallId:kt.functionCallId,peerAgentName:In,subTaskId:Dt.taskId};Bt.push(Mr),j.set(kt.functionCallId,Mr),Dt.taskId&&(S.set(Dt.taskId,kt.functionCallId),Bn.add(Dt.taskId));break}}}}});const gr={id:`vstep-tooldecision-${p.length}-${Q}`,type:"AGENT_LLM_RESPONSE_TOOL_DECISION",timestamp:H,title:`LLM: Tool Decision${En.isParallel?" (Parallel)":""}`,source:"LLM",target:_e,data:{toolDecision:En},rawEventIds:[Q],delegationInfo:Bt.length>0?Bt:void 0,isSubTaskStep:J>0,nestingLevel:J,owningTaskId:Z,functionCallId:de};p.push(gr);const Vs=En.isParallel?gr.id:void 0,Tt=be;l(Tt,_e),vt.forEach(kt=>{var Vn;const In=kt.isPeerDelegation?(Vn=j.get(kt.functionCallId))==null?void 0:Vn.subTaskId:void 0;i.has(kt.functionCallId)||i.set(kt.functionCallId,{timestamp:H,toolName:kt.toolName,isPeer:kt.isPeerDelegation,invokingAgentInstanceId:Tt,subTaskId:In,parallelBlockId:Vs})})}else{const vt=(_t==null?void 0:_t.filter(Bt=>Bt.text).map(Bt=>Bt.text).join(`
|
|
379
|
+
`))||"",En={responsePreview:vt.substring(0,200)+(vt.length>200?"...":""),isFinalResponse:(ot==null?void 0:ot.partial)===!1};p.push({id:`vstep-llmrespagent-${p.length}-${Q}`,type:"AGENT_LLM_RESPONSE_TO_AGENT",timestamp:H,title:`${_e}: LLM Response`,source:"LLM",target:_e,data:{llmResponseToAgent:En},rawEventIds:[Q],isSubTaskStep:J>0,nestingLevel:J,owningTaskId:Z,functionCallId:de})}break}case"tool_invocation_start":{const De={functionCallId:we.function_call_id,toolName:we.tool_name,toolArguments:we.tool_args,isPeerInvocation:(Ot=we.tool_name)==null?void 0:Ot.startsWith("peer_")};p.push({id:`vstep-toolinvokestart-${p.length}-${Q}`,type:"AGENT_TOOL_INVOCATION_START",timestamp:H,title:`${_e}: Executing tool ${De.toolName}`,source:_e,target:De.toolName,data:{toolInvocationStart:De},rawEventIds:[Q],isSubTaskStep:J>0,nestingLevel:J,owningTaskId:Z,functionCallId:de});break}case"tool_result":{const De=we.function_call_id,ot=i.get(De);if(ot){const mt=new Date(H).getTime()-new Date(ot.timestamp).getTime(),vt=s.agents[ot.invokingAgentInstanceId];if(vt){const En={toolName:ot.toolName,durationMs:mt,isPeer:ot.isPeer,timestamp:ot.timestamp,peerAgentName:ot.isPeer?ot.toolName.substring(5):void 0,subTaskId:ot.subTaskId,parallelBlockId:ot.parallelBlockId};vt.toolCalls.push(En)}i.delete(De)}const _t={toolName:we.tool_name,functionCallId:De,resultData:we.result_data,isPeerResponse:(gt=we.tool_name)==null?void 0:gt.startsWith("peer_")};if(p.push({id:`vstep-toolresult-${p.length}-${Q}`,type:"AGENT_TOOL_EXECUTION_RESULT",timestamp:H,title:`${_e}: Tool Result - ${_t.toolName}`,source:_t.toolName,target:_e,data:{toolResult:_t},rawEventIds:[Q],isSubTaskStep:J>0,nestingLevel:J,owningTaskId:Z,functionCallId:de}),we.tool_name==="_notify_artifact_save"&&De){const mt=u.get(De);if(mt&&!Gd(mt.filename)){const vt={artifactName:mt.filename,version:mt.version,description:mt.description,mimeType:mt.mimeType};p.push({id:`vstep-artifactcreated-${p.length}-${mt.eventId}`,type:"AGENT_ARTIFACT_NOTIFICATION",timestamp:mt.timestamp,title:`${mt.agentName}: Created Artifact - ${vt.artifactName}`,source:mt.agentName,target:"User/System",data:{artifactNotification:vt},rawEventIds:[mt.eventId],isSubTaskStep:mt.nestingLevel>0,nestingLevel:mt.nestingLevel,owningTaskId:mt.taskId,functionCallId:De})}u.delete(De)}break}case"artifact_creation_progress":break;case"artifact_saved":{b(Z);const De=we.filename||"Unnamed Artifact";if(Gd(De))break;if(we.function_call_id&&we.function_call_id.startsWith("host-notify-"))u.set(we.function_call_id,{filename:De,version:we.version,description:we.description,mimeType:we.mime_type,timestamp:H,agentName:_e,taskId:Z,nestingLevel:J,eventId:Q});else{const _t={artifactName:De,version:we.version,description:we.description,mimeType:we.mime_type};p.push({id:`vstep-artifactsaved-${p.length}-${Q}`,type:"AGENT_ARTIFACT_NOTIFICATION",timestamp:H,title:`${_e}: Created Artifact - ${_t.artifactName}`,source:_e,target:"User/System",data:{artifactNotification:_t},rawEventIds:[Q],isSubTaskStep:J>0,nestingLevel:J,owningTaskId:Z,functionCallId:we.function_call_id||de})}break}}}else ne.kind==="text"&&ne.text&&(g&&g!==_e&&(b(Z),y=null),g||(g=_e,x=H,C=et),v+=ne.text,w.push(Q))}return}if(V.direction==="artifact_update"&&((Nt=z==null?void 0:z.result)!=null&&Nt.artifact)){b(Z);const Se=z.result.artifact,Ee=Se.name||"Unnamed Artifact";if(Gd(Ee))return;const Le=((Jt=Se.metadata)==null?void 0:Jt.agent_name)||V.source_entity||"Agent";let _e;if(Se.parts&&Se.parts.length>0){const be=Se.parts[0];be.kind==="file"?_e=be.file.mimeType||void 0:(Wt=be.metadata)!=null&&Wt.mime_type&&(_e=be.metadata.mime_type)}const et={artifactName:Ee,version:typeof((xe=Se.metadata)==null?void 0:xe.version)=="number"?Se.metadata.version:void 0,description:Se.description||void 0,mimeType:_e};p.push({id:`vstep-artifactnotify-${p.length}-${Q}`,type:"AGENT_ARTIFACT_NOTIFICATION",timestamp:H,title:`${Le}: Artifact Update - ${et.artifactName}`,source:Le,target:"User/System",data:{artifactNotification:et},rawEventIds:[Q],isSubTaskStep:J>0,nestingLevel:J,owningTaskId:Z,functionCallId:de});return}if(["response","task"].includes(V.direction)&&((Me=($e=z==null?void 0:z.result)==null?void 0:$e.status)!=null&&Me.state)){v.trim()&&b(Z);const Se=z.result,Ee=Se.status.state,Le=((Fe=Se.metadata)==null?void 0:Fe.agent_name)||((Ut=(He=(ft=Se.status)==null?void 0:ft.message)==null?void 0:He.metadata)==null?void 0:Ut.agent_name)||V.source_entity||"Agent";if(["completed","failed","canceled"].includes(Ee)&&J==0){const _e=Ee==="completed"?"TASK_COMPLETED":"TASK_FAILED",et=`${Le}: Task ${Ee.charAt(0).toUpperCase()+Ee.slice(1)}`;let be={},ne="";if((Qe=Se.status.message)!=null&&Qe.parts){const Ve=Se.status.message.parts.find(De=>De.kind==="text");Ve!=null&&Ve.text&&(ne=Ve.text.trim())}const he=Z===n.taskId,we=ne&&(!he||ne!==y);if(_e==="TASK_COMPLETED")be={finalMessage:we?ne:void 0};else{const De={message:we?ne:`Task ${Ee}.`},ot=z.error;ot&&(De.message=ot.message||De.message,De.code=ot.code,ot.data&&(De.details=ot.data)),Se.error&&(De.message=Se.error.message||De.message,De.code=Se.error.code||De.code,De.details=Se.error.data||De.details),be={errorDetails:De}}p.push({id:`vstep-${Ee}-${p.length}-${Q}`,type:_e,timestamp:H,title:et,source:Le,target:"User",data:be,rawEventIds:[Q],isSubTaskStep:J>0,nestingLevel:J,owningTaskId:Z,functionCallId:de}),he&&(y=null);return}}const ge=V.direction==="status-update"&&((nn=(ln=(Lt=(St=z==null?void 0:z.result)==null?void 0:St.status)==null?void 0:Lt.message)==null?void 0:ln.parts)==null?void 0:nn.some(Se=>Se.kind==="text"));let T=V.source_entity;(te=(Yt=(Un=(On=z==null?void 0:z.result)==null?void 0:On.status)==null?void 0:Un.message)==null?void 0:Yt.metadata)!=null&&te.forwarded_from_peer?T=z.result.status.message.metadata.forwarded_from_peer:(ue=(re=z==null?void 0:z.result)==null?void 0:re.metadata)!=null&&ue.agent_name?T=z.result.metadata.agent_name:(qe=(Be=(je=(Ce=z==null?void 0:z.result)==null?void 0:Ce.status)==null?void 0:je.message)==null?void 0:Be.metadata)!=null&&qe.agent_name&&(T=z.result.status.message.metadata.agent_name),v.trim()&&g&&(!ge||ge&&T!==g)&&(b(Z),c.get(((Te=w[0])==null?void 0:Te.split("-")[1])||n.taskId)===0&&!C&&(y=null))});const k=f.length>0&&f[f.length-1].task_id||n.taskId;b(k);const N=f[0]?ki(f[0]):n.firstSeen.toISOString();let A,P="working";const E=p.filter(V=>V.owningTaskId===n.taskId),R=E.length>0?E[E.length-1]:null;if(R&&(R.type==="TASK_COMPLETED"?(P="completed",A=R.timestamp):R.type==="TASK_FAILED"&&(P="failed",A=R.timestamp)),P==="working"&&f.length>0){const V=f[f.length-1];t[V.task_id||n.taskId]}let _;N&&A&&(_=new Date(A).getTime()-new Date(N).getTime()),["completed","failed","canceled","rejected"].includes(P)&&(m=void 0);const M={taskId:n.taskId,initialRequestText:n.initialRequestText,status:P,currentStatusText:m,startTime:N,endTime:A,durationMs:_,steps:p};M.steps.forEach((V,X)=>{if(V.type==="TASK_COMPLETED"){let H="";for(let Q=X-1;Q>=0;Q--){const z=M.steps[Q];if(z.type!=="AGENT_RESPONSE_TEXT"||z.source!==V.source)break;H=z.data.text+H}V.data.finalMessage&&(H+=V.data.finalMessage),V.data.finalMessage=H.trim()||void 0}}),Object.values(s.agents).forEach(V=>{V.totalLlmTimeMs=V.llmCalls.reduce((Z,J)=>Z+J.durationMs,0);const X=V.toolCalls.filter(Z=>!Z.parallelBlockId),H=new Map;V.toolCalls.forEach(Z=>{Z.parallelBlockId&&(H.has(Z.parallelBlockId)||H.set(Z.parallelBlockId,[]),H.get(Z.parallelBlockId).push(Z))});const Q=X.reduce((Z,J)=>Z+J.durationMs,0);let z=0;H.forEach(Z=>{if(Z.length>0){const J=Math.min(...Z.map(de=>new Date(de.timestamp).getTime())),ce=Math.max(...Z.map(de=>new Date(de.timestamp).getTime()+de.durationMs));z+=ce-J}}),V.totalToolTimeMs=Q+z});const L=new Map;Object.values(s.agents).forEach(V=>{L.has(V.agentName)||L.set(V.agentName,[]),L.get(V.agentName).push(V)}),L.forEach(V=>{V.length>1&&(V.sort((X,H)=>{const Q=z=>{const Z=[...z.llmCalls.map(J=>new Date(J.timestamp).getTime()),...z.toolCalls.map(J=>new Date(J.timestamp).getTime())];return Z.length>0?Math.min(...Z):1/0};return Q(X)-Q(H)}),V.forEach((X,H)=>{X.displayName=`${X.agentName} (${H+1})`}))});const F=new Map;return Object.values(s.agents).forEach(V=>{const X=V.instanceId.split(":").slice(1).join(":");X&&F.set(X,V.displayName)}),Object.values(s.agents).forEach(V=>{V.toolCalls.forEach(X=>{if(X.isPeer&&X.subTaskId){const H=F.get(X.subTaskId);H&&(X.peerAgentName=H)}})}),_!==void 0&&(s.overall.totalTaskDurationMs=_),M.performanceReport=s,M},jF=({items:e,bottomItems:t,activeItem:n,onItemChange:r,onHeaderClick:s})=>{const a=l=>{r(l)},i=t==null?void 0:t.filter(l=>l.id!=="theme-toggle");return o.jsxs("aside",{className:"flex h-screen w-[100px] flex-col border-r border-[var(--color-secondary-w70)] bg-[var(--color-primary-w100)]",children:[o.jsx(NF,{onClick:s}),o.jsx(IF,{items:e,bottomItems:i,activeItem:n,onItemClick:a})]})},Ix="webui_logo_url",EF=o.jsx("div",{className:"flex h-12 w-12 items-center justify-center overflow-hidden rounded-full",children:o.jsxs("svg",{id:"header-icon",xmlns:"http://www.w3.org/2000/svg",version:"1.1",viewBox:"0 0 500 150",width:"100%",height:"100%",children:[o.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M14.3,82.5c0-4.4,1-8.2,2.9-11.3,1.9-3.1,4.4-5.7,7.5-7.8,3.1-2,6.5-3.6,10.4-4.6,3.8-1,7.7-1.5,11.5-1.5s7.1.3,10.2.9c3.1.6,5.9,1.5,8.2,2.6,2.4,1.1,4.2,2.4,5.6,3.8,1.4,1.4,2,3,2,4.6,0,2.4,0,4.3-.2,5.7-.1,1.4-.3,2.4-.6,3.1-.3.7-.7,1.1-1.1,1.3-.4.2-.9.2-1.6.2-1.8,0-3.2-.7-4.3-2-1.1-1.3-2.3-2.8-3.7-4.4-1.4-1.6-3.1-3.1-5.3-4.4-2.1-1.3-5.3-2-9.3-2s-4.4.3-6,.9c-1.6.6-2.9,1.5-3.8,2.5-.9,1-1.6,2.2-2,3.4-.4,1.2-.6,2.4-.6,3.5,0,2.5,1,4.4,3.1,5.7,2.1,1.3,4.7,2.3,7.8,3.2,3.1.9,6.5,1.7,10.1,2.5,3.6.8,7,1.9,10.1,3.4,3.1,1.5,5.8,3.5,7.9,6.1,2.1,2.6,3.1,6.1,3.1,10.5s-.8,8-2.5,11.3c-1.7,3.4-4,6.2-7,8.5-3,2.3-6.6,4.1-10.8,5.3-4.2,1.3-8.9,1.9-13.9,1.9s-8.8-.6-12.5-1.9c-3.7-1.3-6.9-2.8-9.6-4.6-2.7-1.8-4.7-3.7-6.2-5.6-1.5-1.9-2.2-3.5-2.2-4.7,0-1.8.5-3.6,1.6-5.3,1-1.8,2.6-2.7,4.7-2.7s2.5.4,3.5,1.2c.9.8,1.8,1.7,2.7,2.8.8,1.1,1.7,2.3,2.6,3.7.9,1.4,2,2.6,3.3,3.7,1.3,1.1,2.9,2,4.7,2.8,1.8.8,4.1,1.2,6.8,1.2,4.1,0,7.5-1,10.3-3.1,2.8-2.1,4.2-4.8,4.2-8s-1-4.9-3.1-6.4c-2-1.4-4.6-2.6-7.7-3.5-3.1-.9-6.4-1.7-10-2.4-3.6-.7-7-1.8-10-3.2-3.1-1.4-5.7-3.4-7.7-6-2-2.6-3.1-6.3-3.1-11"}),o.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M124.6,66.8c-4,0-7.3.9-9.9,2.7-2.6,1.8-4.7,4.2-6.4,7.1-1.6,2.9-2.8,6.1-3.5,9.7-.7,3.5-1,6.9-1,10.1,0,4.9.5,9.2,1.6,13,1,3.7,2.5,6.8,4.4,9.3,1.9,2.5,4.1,4.3,6.7,5.6,2.6,1.3,5.3,1.9,8.2,1.9s5.7-.6,8.2-1.9c2.6-1.3,4.8-3.1,6.7-5.6,1.9-2.5,3.3-5.5,4.4-9.3,1-3.7,1.6-8,1.6-13,0-9.5-1.9-16.9-5.8-22-3.9-5.1-8.9-7.7-15.2-7.7M82.2,96.5c0-5.8,1.1-11,3.3-15.9,2.2-4.8,5.2-8.9,9.1-12.4,3.9-3.5,8.4-6.1,13.6-8,5.2-1.9,10.7-2.8,16.6-2.8s11.4.9,16.6,2.8c5.2,1.9,9.7,4.6,13.5,8,3.8,3.5,6.9,7.6,9.1,12.4,2.2,4.8,3.4,10.1,3.4,15.9s-1.1,11.2-3.4,15.9c-2.3,4.8-5.3,8.9-9.1,12.3-3.8,3.5-8.3,6.1-13.5,8-5.2,1.9-10.7,2.8-16.6,2.8s-11.4-.9-16.6-2.8c-5.2-1.9-9.7-4.6-13.6-8-3.9-3.5-6.9-7.6-9.1-12.3-2.2-4.8-3.3-10.1-3.3-15.9"}),o.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M172.3,23.3c0-.8.9-1.8,2.7-2.8,1.8-1,4-2,6.5-2.9,2.5-.9,5.1-1.6,7.7-2.3,2.6-.6,4.7-.9,6.3-.9s1.3,0,1.9.2c.6.2,1.2.5,1.8,1.2.6.6,1,1.6,1.4,2.9.4,1.3.5,3.1.5,5.4v94.7c0,2.4.4,4.1,1.2,4.9.8.9,1.6,1.5,2.5,2,.9.4,1.7.8,2.5,1.3.8.4,1.2,1.4,1.2,2.8s-.5,2.5-1.6,3.2c-1,.7-2.4,1-3.9,1h-24.2c-1.6,0-2.9-.3-3.9-1-1-.7-1.6-1.8-1.6-3.2s.4-2.3,1.2-2.7c.8-.5,1.6-.9,2.5-1.3.9-.4,1.7-1.1,2.5-2,.8-.9,1.2-2.5,1.2-4.9V34.5c0-2-.4-3.4-1.3-4.2-.9-.8-1.9-1.4-2.9-1.9-1-.5-2-1-2.9-1.6-.9-.6-1.3-1.8-1.3-3.5"}),o.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M254.4,93.3c-3.7,1.2-6.8,2.8-9.4,4.7-2.6,1.9-4.6,4.1-6,6.6-1.4,2.5-2.1,5-2.1,7.6s.3,3.6,1,5.3c.7,1.8,1.6,3.4,2.9,4.7,1.3,1.4,2.7,2.5,4.5,3.3,1.7.8,3.6,1.3,5.7,1.3s5.2-.7,7.2-2c2-1.3,3.6-2.9,4.9-4.7,1.3-1.8,2.2-3.7,2.7-5.7.6-1.9.9-3.6.9-4.9v-18.2c-4.5.1-8.6.8-12.2,2M220.5,69.7c0-1.9.9-3.6,2.6-5.1,1.7-1.5,4-2.8,6.8-3.8,2.8-1,6-1.9,9.5-2.4,3.5-.6,7-.9,10.4-.9,7,0,12.9.8,17.6,2.3,4.7,1.5,8.5,3.6,11.5,6.1,2.9,2.6,5,5.5,6.3,8.7,1.3,3.2,1.9,6.6,1.9,10v34.5c0,1.9.4,3.2,1.3,4.1.8.8,1.7,1.5,2.7,2,.9.5,1.8,1,2.7,1.5.8.5,1.3,1.4,1.3,2.7s-.4,2.5-1.2,3.4c-.8.9-2.7,1.3-5.7,1.3h-13.2c-2.4,0-4.1-.5-5.1-1.6-1-1-1.5-2.8-1.5-5.2v-1.7h-.6c-2.4,3.5-5.9,6-10.4,7.6-4.6,1.6-9.3,2.4-14.4,2.4s-8.5-.6-11.9-1.9c-3.4-1.3-6.3-3-8.6-5.1-2.4-2.1-4.1-4.6-5.3-7.5-1.2-2.8-1.8-5.8-1.8-8.8,0-5.2,1.6-9.7,4.8-13.5,3.2-3.8,7.3-6.8,12.2-9.2,5-2.4,10.5-4.1,16.6-5.2,6.1-1.1,12-1.6,17.9-1.6,0-4.7-1.3-8.6-4-11.5-2.7-3-6.6-4.5-11.7-4.5s-5.7.5-7.5,1.4c-1.9.9-3.6,2-5.1,3.1-1.5,1.2-3.1,2.2-4.7,3.1-1.6.9-3.7,1.4-6.2,1.4s-3.8-.5-5-1.6c-1.3-1.1-1.9-2.6-1.9-4.6"}),o.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M301.5,97.6c0-5.9,1-11.3,3.1-16.2,2.1-4.9,4.9-9.2,8.6-12.7,3.6-3.6,7.9-6.3,12.9-8.3,5-2,10.4-3,16.2-3s7.2.4,10.8,1.3c3.5.9,6.6,2.1,9.3,3.5,2.7,1.5,4.9,3.2,6.5,5.2,1.6,2,2.4,4.1,2.4,6.3s-.9,4.1-2.7,5.5c-1.8,1.4-4.2,2-7.2,2s-4.1-.8-5.3-2.4c-1.2-1.6-2.4-3.4-3.5-5.3-1.1-1.9-2.4-3.6-4-5.3-1.6-1.6-3.9-2.4-7.1-2.4s-5.2.8-7.5,2.3c-2.3,1.5-4.2,3.7-5.9,6.5-1.7,2.8-3,6.2-3.8,10-.9,3.9-1.3,8.2-1.3,12.9s.6,7.9,1.8,11.2c1.2,3.3,2.8,6.1,4.8,8.4,2,2.3,4.3,4.1,6.9,5.3,2.6,1.2,5.4,1.8,8.3,1.8s6.9-.6,9.4-1.9c2.5-1.3,4.7-2.6,6.4-4.2,1.8-1.5,3.3-2.9,4.6-4.2,1.3-1.3,2.6-1.9,4-1.9s2,.3,2.7,1c.8.7,1.2,1.6,1.2,2.7,0,1.7-.8,3.6-2.5,5.9-1.7,2.3-4,4.4-6.9,6.4-2.9,2-6.4,3.8-10.4,5.2-4,1.4-8.4,2.1-13.1,2.1s-10.7-.9-15.5-2.7c-4.8-1.8-8.9-4.4-12.3-7.8-3.5-3.3-6.2-7.4-8.2-12-2-4.7-3-9.8-3-15.5"}),o.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M423.2,65.9c-3.4,0-6.3.7-8.9,2.2-2.6,1.5-4.9,3.5-6.8,6.1-1.9,2.6-3.3,5.8-4.3,9.4-1,3.7-1.5,7.7-1.5,12.1v.9c3.5-.3,7.1-.9,11-1.7,3.9-.8,7.4-2,10.7-3.5,3.2-1.5,5.9-3.4,8.1-5.7,2.1-2.4,3.2-5.3,3.2-8.7s-.9-5.9-2.7-8c-1.8-2.1-4.7-3.1-8.7-3.1M380,98.4c0-5.7.9-11,2.7-15.9,1.8-5,4.5-9.3,8.2-13,3.7-3.7,8.3-6.6,13.9-8.8,5.6-2.1,12.2-3.2,19.9-3.2s6.8.4,10.4,1.2c3.6.8,6.8,2,9.8,3.8,3,1.7,5.4,4,7.4,6.8,1.9,2.8,2.9,6.1,2.9,10s-1.6,9-4.9,12.2c-3.3,3.2-7.5,5.8-12.6,7.7-5.1,1.9-10.8,3.4-16.9,4.3-6.1.9-12,1.6-17.7,1.9.5,3.1,1.5,5.9,2.9,8.3,1.4,2.4,3.1,4.4,5.2,6,2,1.6,4.2,2.8,6.6,3.6,2.4.8,4.7,1.2,7.1,1.2s5-.3,7.2-.9c2.2-.6,4.2-1.3,6-2.3,1.8-.9,3.5-2,4.9-3.1,1.5-1.1,2.8-2.2,3.9-3.2,1-1,2-1.9,2.8-2.4.8-.6,1.8-.9,3-.9,2.4,0,3.6,1.2,3.6,3.6s-1,4-3,6.4c-2,2.4-4.7,4.6-8,6.7-3.4,2-7.2,3.8-11.5,5.2-4.3,1.4-8.9,2.1-13.7,2.1s-10.9-.9-15.8-2.8c-4.9-1.9-9.1-4.5-12.7-7.8-3.6-3.3-6.4-7.2-8.5-11.8-2-4.6-3.1-9.5-3.1-14.8"}),o.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M464.7,123.7c0-6.5,5.3-11.8,11.8-11.8s11.8,5.3,11.8,11.8-5.3,11.8-11.8,11.8-11.8-5.3-11.8-11.8"})]})}),NF=({onClick:e})=>{const t=on(),[n,r]=d.useState(!1),[s,a]=d.useState("");d.useEffect(()=>{try{const l=localStorage.getItem(Ix);l&&a(l)}catch(l){console.warn("Failed to read cached logo URL from localStorage:",l)}},[]),d.useEffect(()=>{if(t.configLogoUrl!==void 0){a(t.configLogoUrl);try{localStorage.setItem(Ix,t.configLogoUrl)}catch(l){console.error("Failed to save logo URL to localStorage:",l)}r(!1)}},[t.configLogoUrl]);const i=s&&!n;return o.jsx("div",{className:"flex h-[80px] min-h-[80px] cursor-pointer items-center justify-center border-b",onClick:e,children:i?o.jsx("div",{className:"flex h-16 w-16 items-center justify-center overflow-hidden",children:o.jsx("img",{src:s,alt:"Logo",className:"h-full w-full object-contain",onError:()=>r(!0)})}):EF})},TF=()=>{const{settings:e,updateSetting:t}=So(),{configFeatureEnablement:n}=on(),[r,s]=d.useState([]),[a,i]=d.useState(!1),[l,c]=d.useState(null),[u,h]=d.useState(null),[f,p]=d.useState(null),[m,v]=d.useState(null),[g,x]=d.useState(!1),[w,y]=d.useState(!1),[C,S]=d.useState(null),j=(n==null?void 0:n.speechToText)??!0,I=(n==null?void 0:n.textToSpeech)??!0;d.useEffect(()=>{(async()=>{try{const N=await Ie.webui.get("/api/v1/speech/config"),A=N.sttExternal||!1,P=N.ttsExternal||!1;c(A),h(P),N.sttProviders&&p(N.sttProviders),N.ttsProviders&&v(N.ttsProviders),!A&&e.sttProvider!=="browser"&&(console.warn("External STT not configured, resetting provider to browser"),t("sttProvider","browser"),t("engineSTT","browser")),!P&&e.ttsProvider!=="browser"&&(console.warn("External TTS not configured, resetting provider to browser"),t("ttsProvider","browser"),t("engineTTS","browser"))}catch(N){console.error("Error checking speech config:",N)}})()},[e.sttProvider,e.ttsProvider,t]),d.useEffect(()=>{(async()=>{if(e.ttsProvider==="browser"){s([]);return}i(!0);try{const N=e.ttsProvider||"gemini",A=await Ie.webui.get(`/api/v1/speech/voices?provider=${N}`);s(A.voices||[])}catch(N){console.error("Error loading voices:",N)}finally{i(!1)}})()},[e.ttsProvider]),d.useEffect(()=>()=>{C&&(C.pause(),C.src="")},[C]);const b=async k=>{try{C&&(C.pause(),C.src="",C.onended=null,C.onerror=null,S(null)),y(!0),x(!1);const N=new FormData;N.append("voice",k),e.ttsProvider!=="browser"&&N.append("provider",e.ttsProvider);const A=await Ie.webui.post("/api/v1/speech/voice-sample",N,{fullResponse:!0});if(!A.ok)throw new Error(`Failed to load voice sample: ${A.statusText}`);const P=await A.blob(),E=URL.createObjectURL(P);y(!1),x(!0);const R=new Audio(E);R.onended=()=>{x(!1),S(null),URL.revokeObjectURL(E)},R.onerror=()=>{x(!1),S(null),URL.revokeObjectURL(E)},R.playbackRate=e.playbackRate||1,S(R),await R.play()}catch(N){console.error("Error playing voice sample:",N),y(!1),x(!1),S(null),alert("Failed to play voice sample. Please try again.")}};return o.jsxs("div",{className:"space-y-6",children:[j&&o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-2 border-b pb-2",children:[o.jsx(of,{className:"size-5"}),o.jsx("h3",{className:"text-lg font-semibold",children:"Speech-to-Text"})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(zt,{className:"font-medium",children:"Enable Speech-to-Text"}),o.jsx(Pf,{checked:e.speechToText,onCheckedChange:k=>t("speechToText",k)})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(zt,{className:"font-medium",children:"Speech-to-Text Provider"}),o.jsxs(Wr,{value:e.sttProvider,onValueChange:k=>{t("sttProvider",k),t("engineSTT",k==="browser"?"browser":"external")},disabled:!e.speechToText,children:[o.jsx(Gr,{className:"w-44",children:o.jsx(Zr,{})}),o.jsxs(qr,{children:[o.jsx(Pt,{value:"browser",children:"Browser (Free)"}),(f==null?void 0:f.openai)&&o.jsx(Pt,{value:"openai",children:"OpenAI Whisper"}),(f==null?void 0:f.azure)&&o.jsx(Pt,{value:"azure",children:"Azure Speech"})]})]})]}),e.speechToText&&e.sttProvider!=="browser"&&l===!1&&o.jsx("div",{className:"rounded-md border border-[var(--color-warning-w40)] bg-[var(--color-warning-w20)] p-3 dark:border-[var(--color-warning-w80)] dark:bg-[var(--color-warning-w95)]",children:o.jsxs("div",{className:"flex gap-2",children:[o.jsx(io,{className:"mt-0.5 size-5 flex-shrink-0 text-[var(--color-warning-wMain)]"}),o.jsxs("div",{className:"flex-1 text-sm",children:[o.jsx("p",{className:"mb-1 font-semibold text-[var(--color-warning-w80)] dark:text-[var(--color-warning-w30)]",children:"External STT Not Configured"}),o.jsxs("p",{className:"mb-2 text-[var(--color-warning-w70)] dark:text-[var(--color-warning-w40)]",children:["To use External API mode, add configuration to your ",o.jsx("code",{className:"rounded bg-[var(--color-warning-w30)] px-1 py-0.5 text-xs dark:bg-[var(--color-warning-w90)]",children:"webui.yaml"}),":"]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{children:[o.jsx("p",{className:"mb-1 text-xs font-semibold text-[var(--color-warning-w80)] dark:text-[var(--color-warning-w30)]",children:"OpenAI Whisper:"}),o.jsx("pre",{className:"overflow-x-auto rounded bg-[var(--color-warning-w30)] p-2 text-xs dark:bg-[var(--color-warning-w90)]",children:`speech:
|
|
380
|
+
stt:
|
|
381
|
+
provider: openai
|
|
382
|
+
openai:
|
|
383
|
+
url: https://api.openai.com/v1/audio/transcriptions
|
|
384
|
+
api_key: \${OPENAI_API_KEY}
|
|
385
|
+
model: whisper-1`})]}),o.jsxs("div",{children:[o.jsx("p",{className:"mb-1 text-xs font-semibold text-[var(--color-warning-w80)] dark:text-[var(--color-warning-w30)]",children:"Azure Speech:"}),o.jsx("pre",{className:"overflow-x-auto rounded bg-[var(--color-warning-w30)] p-2 text-xs dark:bg-[var(--color-warning-w90)]",children:`speech:
|
|
386
|
+
stt:
|
|
387
|
+
provider: azure
|
|
388
|
+
azure:
|
|
389
|
+
api_key: \${AZURE_SPEECH_KEY}
|
|
390
|
+
region: eastus
|
|
391
|
+
language: en-US`})]})]}),o.jsx("p",{className:"mt-2 text-xs text-[var(--color-warning-w70)] dark:text-[var(--color-warning-w40)]",children:"Or use Browser mode (free, no setup required)."})]})]})}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(zt,{className:"font-medium",children:"Language"}),o.jsxs(Wr,{value:e.languageSTT,onValueChange:k=>t("languageSTT",k),disabled:!e.speechToText,children:[o.jsx(Gr,{className:"w-44",children:o.jsx(Zr,{})}),o.jsxs(qr,{children:[o.jsx(Pt,{value:"en-US",children:"English (US)"}),o.jsx(Pt,{value:"en-GB",children:"English (UK)"}),o.jsx(Pt,{value:"es-ES",children:"Spanish"}),o.jsx(Pt,{value:"fr-FR",children:"French"}),o.jsx(Pt,{value:"de-DE",children:"German"}),o.jsx(Pt,{value:"it-IT",children:"Italian"}),o.jsx(Pt,{value:"ja-JP",children:"Japanese"}),o.jsx(Pt,{value:"ko-KR",children:"Korean"}),o.jsx(Pt,{value:"zh-CN",children:"Chinese (Simplified)"})]})]})]})]}),I&&o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-2 border-b pb-2",children:[o.jsx(Ec,{className:"size-5"}),o.jsx("h3",{className:"text-lg font-semibold",children:"Text-to-Speech"})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(zt,{className:"font-medium",children:"Enable Text-to-Speech"}),o.jsx(Pf,{checked:e.textToSpeech,onCheckedChange:k=>t("textToSpeech",k)})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(zt,{className:"font-medium",children:"Text-to-Speech Provider"}),o.jsxs(Wr,{value:e.ttsProvider,onValueChange:k=>{t("ttsProvider",k),t("engineTTS",k==="browser"?"browser":"external")},disabled:!e.textToSpeech,children:[o.jsx(Gr,{className:"w-44",children:o.jsx(Zr,{})}),o.jsxs(qr,{children:[o.jsx(Pt,{value:"browser",children:"Browser (Free)"}),(m==null?void 0:m.gemini)&&o.jsx(Pt,{value:"gemini",children:"Google Gemini"}),(m==null?void 0:m.azure)&&o.jsx(Pt,{value:"azure",children:"Azure Neural"}),(m==null?void 0:m.polly)&&o.jsx(Pt,{value:"polly",children:"AWS Polly"})]})]})]}),e.textToSpeech&&e.ttsProvider!=="browser"&&u===!1&&o.jsx("div",{className:"rounded-md border border-[var(--color-warning-w40)] bg-[var(--color-warning-w20)] p-3 dark:border-[var(--color-warning-w80)] dark:bg-[var(--color-warning-w95)]",children:o.jsxs("div",{className:"flex gap-2",children:[o.jsx(io,{className:"mt-0.5 size-5 flex-shrink-0 text-[var(--color-warning-wMain)]"}),o.jsxs("div",{className:"flex-1 text-sm",children:[o.jsx("p",{className:"mb-1 font-semibold text-[var(--color-warning-w80)] dark:text-[var(--color-warning-w30)]",children:"External TTS Not Configured"}),o.jsxs("p",{className:"mb-2 text-[var(--color-warning-w70)] dark:text-[var(--color-warning-w40)]",children:["To use External API mode, configure TTS in your ",o.jsx("code",{className:"rounded bg-[var(--color-warning-w30)] px-1 py-0.5 text-xs dark:bg-[var(--color-warning-w90)]",children:"webui.yaml"}),". Example for Gemini:"]}),o.jsx("pre",{className:"overflow-x-auto rounded bg-[var(--color-warning-w30)] p-2 text-xs dark:bg-[var(--color-warning-w90)]",children:`speech:
|
|
392
|
+
tts:
|
|
393
|
+
provider: gemini
|
|
394
|
+
api_key: \${GEMINI_API_KEY}
|
|
395
|
+
model: gemini-2.0-flash-exp`}),o.jsx("p",{className:"mt-2 text-xs text-[var(--color-warning-w70)] dark:text-[var(--color-warning-w40)]",children:"Or use Browser mode (free, no setup required)."})]})]})}),e.textToSpeech&&e.ttsProvider==="polly"&&u===!1&&o.jsx("div",{className:"rounded-md border border-[var(--color-warning-w40)] bg-[var(--color-warning-w20)] p-3 dark:border-[var(--color-warning-w80)] dark:bg-[var(--color-warning-w95)]",children:o.jsxs("div",{className:"flex gap-2",children:[o.jsx(io,{className:"mt-0.5 size-5 flex-shrink-0 text-[var(--color-warning-wMain)]"}),o.jsxs("div",{className:"flex-1 text-sm",children:[o.jsx("p",{className:"mb-1 font-semibold text-[var(--color-warning-w80)] dark:text-[var(--color-warning-w30)]",children:"External TTS Not Configured"}),o.jsxs("p",{className:"mb-2 text-[var(--color-warning-w70)] dark:text-[var(--color-warning-w40)]",children:["To use AWS Polly, configure TTS in your ",o.jsx("code",{className:"rounded bg-[var(--color-warning-w30)] px-1 py-0.5 text-xs dark:bg-[var(--color-warning-w90)]",children:"webui.yaml"}),":"]}),o.jsx("pre",{className:"overflow-x-auto rounded bg-[var(--color-warning-w30)] p-2 text-xs dark:bg-[var(--color-warning-w90)]",children:`speech:
|
|
396
|
+
tts:
|
|
397
|
+
provider: polly
|
|
398
|
+
polly:
|
|
399
|
+
aws_access_key_id: \${AWS_ACCESS_KEY_ID}
|
|
400
|
+
aws_secret_access_key: \${AWS_SECRET_ACCESS_KEY}
|
|
401
|
+
region: us-east-1
|
|
402
|
+
engine: neural # or 'standard'
|
|
403
|
+
default_voice: Joanna`}),o.jsx("p",{className:"mt-2 text-xs text-[var(--color-warning-w70)] dark:text-[var(--color-warning-w40)]",children:"Or use Browser mode (free, no setup required)."})]})]})}),e.ttsProvider!=="browser"&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(zt,{className:"font-medium",children:"Voice"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(Wr,{value:e.voice,onValueChange:k=>t("voice",k),disabled:!e.textToSpeech||a,children:[o.jsx(Gr,{className:"w-[112px]",children:o.jsx(Zr,{placeholder:a?"Loading...":"Select voice"})}),o.jsx(qr,{children:r.length>0?(()=>{if(r.some(N=>N.includes("DragonHD"))&&e.ttsProvider==="azure"){const N=r.filter(P=>P.includes("DragonHD")),A=r.filter(P=>!P.includes("DragonHD"));return o.jsxs(o.Fragment,{children:[N.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"text-muted-foreground px-2 py-1.5 text-xs font-semibold",children:"HD Voices (Premium)"}),N.map(P=>{const E=P.split("-"),_=(E[E.length-1]||P).replace("MultilingualNeural:DragonHDLatestNeural","").replace("Neural:DragonHDLatestNeural","").replace(":DragonHDLatestNeural","");return o.jsx(Pt,{value:P,children:_},P)})]}),A.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"text-muted-foreground mt-1 border-t px-2 py-1.5 pt-2 text-xs font-semibold",children:"Standard Voices"}),A.map(P=>{const E=P.split("-"),_=(E[E.length-1]||P).replace("MultilingualNeural","").replace("Neural","");return o.jsx(Pt,{value:P,children:_},P)})]})]})}else return r.map(N=>{let A=N;if(N.includes("-")){const P=N.split("-");A=P[P.length-1].replace("Neural","").replace("Multilingual","")||N}return o.jsx(Pt,{value:N,children:A},N)})})():o.jsx(Pt,{value:"loading",disabled:!0,children:a?"Loading...":"No voices available"})})]}),o.jsx(ye,{variant:g?"default":"outline",size:"sm",onClick:()=>{!g&&!w&&b(e.voice)},disabled:!e.textToSpeech||!e.voice||a||g||w,title:w?"Loading sample...":g?"Playing sample...":"Play voice sample",className:"w-10 px-3",children:w?o.jsx(ur,{className:"size-4 animate-spin"}):g?o.jsx(Ec,{className:"size-4"}):o.jsx(P_,{className:"size-4"})})]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(zt,{className:"font-medium",children:"Playback Speed"}),o.jsx(_r,{type:"number",min:.5,max:2,step:.1,value:e.playbackRate,onChange:k=>t("playbackRate",parseFloat(k.target.value)||1),disabled:!e.textToSpeech,className:"w-44"})]})]})]})},Rx=()=>{const{currentTheme:e,toggleTheme:t}=wl();return o.jsx("div",{className:"space-y-6",children:o.jsxs("div",{className:"space-y-4",children:[o.jsx("div",{className:"border-b pb-2",children:o.jsx("h3",{className:"text-lg font-semibold",children:"Display"})}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Fv,{className:"size-4"}),o.jsx(zt,{className:"font-medium",children:"Dark Mode"})]}),o.jsx(Pf,{checked:e==="dark",onCheckedChange:t})]})]})})},AF=()=>{const[e,t]=d.useState(null),[n,r]=d.useState(!0),[s,a]=d.useState(null),i=()=>n?o.jsx(ws,{className:"mt-8"}):s?o.jsx(Xt,{variant:"error",message:`Error loading application information. ${s}`}):e?o.jsx(e5,{children:o.jsx(t5,{children:e.products.toSorted((l,c)=>l.name.localeCompare(c.name)).map(l=>o.jsxs(n5,{className:"hover:bg-transparent",children:[o.jsx(Jg,{className:"font-medium",children:l.name}),o.jsx(Jg,{children:l.version})]},l.id))})}):null;return d.useEffect(()=>{(async()=>{try{const c=await Ie.webui.get("/api/v1/version");t(c)}catch(c){a(Zt(c))}finally{r(!1)}})()},[]),o.jsx("div",{className:"space-y-6",children:o.jsxs("div",{className:"space-y-4",children:[o.jsx("div",{className:"border-b pb-2",children:o.jsx("div",{className:"text-lg font-semibold",children:"Application Versions"})}),i()]})})},Yd=({icon:e,label:t,active:n,onClick:r})=>o.jsxs("button",{onClick:r,className:Ue("flex w-full cursor-pointer items-center gap-3 px-4 py-2.5 transition-colors",n?"dark:bg-accent bg-[var(--color-brand-w10)]":"text-muted-foreground hover:bg-accent/50"),children:[e,o.jsx("span",{children:t})]}),Px=({iconOnly:e=!1,open:t,onOpenChange:n})=>{const{configFeatureEnablement:r}=on(),[s,a]=d.useState(!1),[i,l]=d.useState("general"),c=t!==void 0,u=c?t:s,h=n||a,f=(r==null?void 0:r.speechToText)??!0,p=(r==null?void 0:r.textToSpeech)??!0,m=f||p,v=()=>{switch(i){case"about":return o.jsx(AF,{});case"general":return o.jsx(Rx,{});case"speech":return o.jsx(TF,{});default:return o.jsx(Rx,{})}},g=()=>{switch(i){case"about":return"About";case"general":return"General";case"speech":return"Speech";default:return"Settings"}};return o.jsxs(Nr,{open:u,onOpenChange:h,children:[!c&&(e?o.jsxs(zs,{children:[o.jsx($s,{asChild:!0,children:o.jsx(If,{asChild:!0,children:o.jsx("button",{type:"button",className:"relative mx-auto flex w-full cursor-pointer flex-col items-center bg-[var(--color-primary-w100)] px-3 py-5 text-xs text-[var(--color-primary-text-w10)] transition-colors hover:bg-[var(--color-primary-w90)] hover:text-[var(--color-primary-text-w10)]","aria-label":"Open Settings",children:o.jsx($i,{className:"h-6 w-6"})})})}),o.jsx(Us,{side:"right",children:"Settings"})]}):o.jsx(If,{asChild:!0,children:o.jsxs(ye,{variant:"outline",className:"w-full justify-start gap-2",children:[o.jsx($i,{className:"size-5"}),o.jsx("span",{children:"Settings"})]})})),o.jsxs(Tr,{className:"max-h-[90vh] w-[90vw] !max-w-[1200px] gap-0 p-0",showCloseButton:!0,children:[o.jsxs(ju,{children:[o.jsx(Ar,{children:"Settings"}),o.jsx(Ir,{children:"Configure application settings"})]}),o.jsxs("div",{className:"flex h-[80vh] overflow-hidden",children:[o.jsxs("div",{className:"bg-muted/30 flex w-64 flex-col border-r",children:[o.jsx("div",{className:"flex h-15 items-center px-4 text-lg font-semibold",children:"Settings"}),o.jsxs("nav",{className:"flex flex-1 flex-col",children:[o.jsxs("div",{className:"flex-1 space-y-1 overflow-y-auto",children:[o.jsx(Yd,{icon:o.jsx(Pv,{className:"size-4"}),label:"General",active:i==="general",onClick:()=>l("general")}),m&&o.jsx(Yd,{icon:o.jsx(Ec,{className:"size-4"}),label:"Speech",active:i==="speech",onClick:()=>l("speech")})]}),o.jsxs("div",{className:"space-y-1 pb-2",children:[o.jsx("div",{className:"mt-4 border-t pb-2"}),o.jsx(Yd,{icon:o.jsx(ll,{className:"size-4"}),label:"About",active:i==="about",onClick:()=>l("about")})]})]})]}),o.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[o.jsx("div",{className:"flex items-center border-b px-6 py-4",children:o.jsx("h3",{className:"text-xl font-semibold",children:g()})}),o.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:o.jsx("div",{className:"mx-auto max-w-2xl",children:v()})})]})]})]})]})},IF=({items:e,bottomItems:t,activeItem:n,onItemClick:r})=>{const[s,a]=d.useState(!1),[i,l]=d.useState(!1),{configUseAuthorization:c,configFeatureEnablement:u}=on(),h=!!(c&&(u!=null&&u.logout)),{userInfo:f,logout:p}=Wy(),m=typeof(f==null?void 0:f.username)=="string"?f.username:"Guest",v=()=>{a(!1),l(!0)},g=async()=>{a(!1),await p()};return o.jsxs("nav",{className:"flex flex-1 flex-col",role:"navigation","aria-label":"Main navigation",children:[o.jsx("ul",{className:"space-y-1",children:e.map(x=>o.jsxs("li",{children:[o.jsx(Mx,{item:x,isActive:n===x.id,onItemClick:r}),x.showDividerAfter&&o.jsx("div",{className:"mx-4 my-3 border-t border-[var(--color-secondary-w70)]"})]},x.id))}),o.jsx("div",{className:"flex-1"}),o.jsxs("ul",{className:"space-y-1",children:[t&&t.length>0&&t.map(x=>o.jsx("li",{className:"my-4",children:o.jsx(Mx,{item:x,isActive:n===x.id,onItemClick:r},x.id)},x.id)),h?o.jsx("li",{className:"my-4 flex justify-center",children:o.jsxs(Sl,{open:s,onOpenChange:a,children:[o.jsxs(zs,{children:[o.jsx($s,{asChild:!0,children:o.jsx(_l,{asChild:!0,children:o.jsx("button",{type:"button",className:"relative mx-auto flex w-full cursor-pointer flex-col items-center bg-[var(--color-primary-w100)] px-3 py-5 text-xs text-[var(--color-primary-text-w10)] transition-colors hover:bg-[var(--color-primary-w90)] hover:text-[var(--color-primary-text-w10)]","aria-label":"Open Menu",children:o.jsx(Tc,{className:"h-6 w-6"})})})}),o.jsx(Us,{side:"right",children:"User & Settings"})]}),o.jsxs(kl,{side:"right",align:"end",className:"w-60 p-0",children:[o.jsxs("div",{className:"flex items-center gap-2 border-b px-3 py-4",children:[o.jsx(Tc,{className:"size-4 shrink-0"}),o.jsx("div",{className:"min-w-0 truncate text-sm font-medium",title:m,children:m})]}),o.jsx(bl,{actions:[{id:"settings",label:"Settings",icon:o.jsx($i,{}),onClick:v},{id:"logout",label:"Log Out",icon:o.jsx(M_,{}),onClick:g,divider:!0}]})]})]})}):o.jsx("li",{className:"my-4 flex justify-center",children:o.jsx(Px,{iconOnly:!0})})]}),i&&o.jsx(Px,{iconOnly:!1,open:i,onOpenChange:l})]})},Mx=({item:e,isActive:t,onItemClick:n})=>{const{id:r,label:s,icon:a,disabled:i,badge:l}=e,c=()=>{!i&&n&&n(r)},u=h=>{(h.key==="Enter"||h.key===" ")&&c()};return o.jsxs(zs,{children:[o.jsx($s,{asChild:!0,children:o.jsxs("button",{type:"button",onClick:n?c:void 0,onKeyDown:n?u:void 0,disabled:i,className:Ue("relative mx-auto flex w-full cursor-pointer flex-col items-center px-3 py-5 text-xs transition-colors","bg-(--color-primary-w100) hover:bg-(--color-primary-w90)","text-(--color-primary-text-w10) hover:bg-(--color-primary-w90) hover:text-(--color-background-w10)","border-l-4 border-(--color-primary-w100)",t?"border-l-4 border-(--color-brand-wMain) bg-(--color-primary-w90)":""),"aria-label":s,"aria-current":t?"page":void 0,children:[o.jsx(a,{className:Ue("mb-1 h-6 w-6",t&&"text-(--color-brand-wMain)")}),o.jsx("span",{className:"text-center text-[13px] leading-tight",children:s}),l&&o.jsx(go,{variant:"outline",className:"mt-1 h-4 bg-(--color-secondary-w80) pt-1 text-[8px] leading-none text-(--color-secondary-text-w10) uppercase",children:l})]})}),o.jsx(Us,{side:"right",children:s})]})},RF=e=>{const t=[{id:"chat",label:"Chat",icon:Nc},{id:"agentMesh",label:"Agents",icon:cu}];return((e==null?void 0:e.projects)??!1)&&t.push({id:"projects",label:"Projects",icon:zv}),((e==null?void 0:e.promptLibrary)??!1)&&t.push({id:"prompts",label:"Prompts",icon:Bo,badge:"EXPERIMENTAL"}),t},Dx=[{id:"theme-toggle",label:"Theme",icon:Fv,onClick:()=>{}}],sa=({title:e,breadcrumbs:t,tabs:n,buttons:r,leadingAction:s})=>o.jsxs("div",{className:"relative flex max-h-[80px] min-h-[80px] w-full items-center border-b px-8",children:[t&&t.length>0&&o.jsx("div",{className:"absolute top-1 left-8 flex h-8 items-center",children:t.map((a,i)=>o.jsxs(xt.Fragment,{children:[i>0&&o.jsx("span",{className:"mx-1",children:o.jsx(Rv,{size:16})}),a.onClick?o.jsx(ye,{variant:"link",className:"m-0 p-0",onClick:a.onClick,children:a.label}):o.jsx("div",{className:"max-w-[150px] truncate",children:a.label})]},i))}),s&&o.jsx("div",{className:"mr-4 flex items-center pt-[35px]",children:s}),o.jsx("div",{className:"max-w-lg truncate pt-[35px] text-xl",children:e}),n&&n.length>0&&o.jsx("div",{className:"ml-8 flex items-center pt-[35px]",role:"tablist",children:n.map((a,i)=>o.jsxs("button",{role:"tab","aria-selected":a.isActive,onClick:a.onClick,className:`relative cursor-pointer px-4 py-3 font-medium transition-colors duration-200 ${a.isActive?"border-b-2 border-[var(--color-brand-wMain)] font-semibold":""} ${i>0?"ml-6":""}`,children:[a.label,a.isActive&&o.jsx("div",{className:"absolute right-0 bottom-0 left-0 h-0.5"})]},a.id))}),o.jsx("div",{className:"flex-1"}),r&&r.length>0&&o.jsx("div",{className:"flex items-center gap-2 pt-[35px]",children:r.map((a,i)=>o.jsx(xt.Fragment,{children:a},i))})]});function PF(){const{agents:e,agentsLoading:t,agentsError:n,agentsRefetch:r}=$t();return o.jsxs("div",{className:"flex h-full w-full flex-col",children:[o.jsx(sa,{title:"Agents",buttons:[o.jsxs(ye,{"data-testid":"refreshAgents",disabled:t,variant:"ghost",title:"Refresh Agents",onClick:()=>r(),children:[o.jsx(uu,{className:"size-4"}),"Refresh Agents"]})]}),t?o.jsx(rr,{title:"Loading agents...",variant:"loading"}):n?o.jsx(rr,{variant:"error",title:"Error loading agents",subtitle:n}):o.jsx("div",{className:"relative flex-1",children:o.jsx(CS,{agents:e})})]})}const ac=4,ah={chatPanelSizes:{default:50,min:30,max:96},sidePanelSizes:{default:50,min:20,max:70}},MF={chatPanelSizes:{...ah.chatPanelSizes,min:50},sidePanelSizes:{...ah.sidePanelSizes,max:50}};function DF(){var X;const{activeProject:e}=Bs(),{currentTheme:t}=wl(),{agents:n,sessionName:r,messages:s,isSidePanelCollapsed:a,setIsSidePanelCollapsed:i,openSidePanelTab:l,setTaskIdInSidePanel:c,isResponding:u,latestStatusText:h,isLoadingSession:f,sessionToDelete:p,closeSessionDeleteModal:m,confirmSessionDelete:v,currentTaskId:g}=$t(),{isTaskMonitorConnected:x,isTaskMonitorConnecting:w,taskMonitorSseError:y,connectTaskMonitorStream:C}=mm(),[S,j]=d.useState(!0),[I,b]=d.useState(!1),k=d.useRef(null),N=d.useRef(null),A=d.useRef(null),{chatPanelSizes:P,sidePanelSizes:E}=d.useMemo(()=>S?ah:MF,[S]),R=d.useCallback(H=>{if(b(!0),N.current)if(H)N.current.resize(ac);else{const Q=A.current||E.default;N.current.resize(Q)}setTimeout(()=>b(!1),300)},[E.default]),_=d.useCallback(()=>{i(!0)},[i]),M=d.useCallback(()=>{i(!1)},[i]),L=d.useCallback(H=>{H>ac+1&&(A.current=H)},[]),F=d.useCallback(()=>{j(!S)},[S]),D=void 0,O=d.useMemo(()=>r||"New Chat",[r]);d.useEffect(()=>{N.current&&a&&N.current.resize(ac);const H=()=>{if(N.current&&a){b(!0);const Q=A.current||E.default;N.current.resize(Q),i(!1),setTimeout(()=>b(!1),300)}};return window.addEventListener("expand-side-panel",H),()=>{window.removeEventListener("expand-side-panel",H)}},[a,i,E.default]);const K=d.useMemo(()=>{const H=new Map;return s.forEach((Q,z)=>{Q.taskId&&H.set(Q.taskId,z)}),H},[s]),$=d.useMemo(()=>s.find(H=>H.isStatusBubble),[s]),W=d.useMemo(()=>{if(!$||!$.parts)return null;const H=$.parts.find(Q=>Q.kind==="text");return(H==null?void 0:H.text)||null},[$]),V=d.useMemo(()=>{if(g)return()=>{c(g),l("workflow")}},[g,c,l]);return d.useEffect(()=>{const H=()=>{!x&&!w&&y&&(console.log("ChatPage: Window focused while disconnected, attempting reconnection..."),C())};return window.addEventListener("focus",H),()=>{window.removeEventListener("focus",H)}},[x,w,y,C]),o.jsxs("div",{className:"relative flex h-screen w-full flex-col overflow-hidden",children:[o.jsx("div",{className:`absolute top-0 left-0 z-20 h-screen transition-transform duration-300 ${S?"-translate-x-full":"translate-x-0"}`,children:o.jsx(BL,{onToggle:F})}),o.jsx("div",{className:`transition-all duration-300 ${S?"ml-0":"ml-100"}`,children:o.jsx(sa,{title:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs(zs,{delayDuration:300,children:[o.jsx($s,{className:"font-inherit max-w-[400px] cursor-default truncate border-0 bg-transparent p-0 text-left text-inherit hover:bg-transparent",children:O}),o.jsx(Us,{side:"bottom",children:o.jsx("p",{children:O})})]}),e&&o.jsx(Yu,{text:e.name,className:"max-w-[200px]"})]}),breadcrumbs:D,leadingAction:S?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ye,{"data-testid":"showSessionsPanel",variant:"ghost",onClick:F,className:"h-10 w-10 p-0",tooltip:"Show Chat Sessions",children:o.jsx(Ov,{className:"size-5"})}),o.jsx("div",{className:"h-6 border-r"}),o.jsx(kS,{})]}):null})}),o.jsx("div",{className:"flex min-h-0 flex-1",children:o.jsx("div",{className:`min-h-0 flex-1 overflow-x-auto transition-all duration-300 ${S?"ml-0":"ml-100"}`,children:o.jsxs(Oy,{direction:"horizontal",autoSaveId:"chat-side-panel",className:"h-full",children:[o.jsx(Zc,{defaultSize:P.default,minSize:P.min,maxSize:P.max,id:"chat-panel",style:{backgroundColor:t==="dark"?"var(--color-background-w100)":"var(--color-background-w20)"},children:o.jsx("div",{className:"flex h-full w-full flex-col",children:o.jsx("div",{className:"flex min-h-0 flex-1 flex-col py-6",children:f?o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(ws,{size:"medium",variant:"primary",children:o.jsx("p",{className:"text-muted-foreground mt-4 text-sm",children:"Loading session..."})})}):o.jsxs(o.Fragment,{children:[o.jsx(mC,{className:"text-base",ref:k,children:s.map((H,Q)=>{var de;const z=!!(H.taskId&&K.get(H.taskId)===Q),Z=((de=H.metadata)==null?void 0:de.messageId)||`temp-${Q}`,ce=Q===s.length-1&&u&&!H.isUser;return o.jsx(xL,{message:H,isLastWithTaskId:z,isStreaming:ce},Z)})}),o.jsxs("div",{style:hC,children:[u&&o.jsx(rh,{statusText:(W||h.current)??void 0,onViewWorkflow:V}),o.jsx(oD,{agents:n,scrollToBottom:(X=k.current)==null?void 0:X.scrollToBottom})]})]})})})}),o.jsx(Ly,{}),o.jsx(Zc,{ref:N,defaultSize:E.default,minSize:E.min,maxSize:E.max,collapsedSize:ac,collapsible:!0,onCollapse:_,onExpand:M,onResize:L,id:"chat-side-panel",className:I?"transition-all duration-300 ease-in-out":"",children:o.jsx("div",{className:"h-full",children:o.jsx(UL,{onCollapsedToggle:R,isSidePanelCollapsed:a,setIsSidePanelCollapsed:i,isSidePanelTransitioning:I})})})]})})}),o.jsx(vL,{open:!!p,onCancel:m,onConfirm:v,sessionName:(p==null?void 0:p.name)||""})]})}const OF=({prompt:e,isSelected:t,onPromptClick:n,onEdit:r,onDelete:s,onViewVersions:a,onUseInChat:i,onTogglePin:l,onExport:c})=>{const{configFeatureEnablement:u}=on(),h=(u==null?void 0:u.promptVersionHistory)??!0,[f,p]=d.useState(!1),m=h&&a,v=S=>{S.stopPropagation(),p(!1),r(e)},g=S=>{S.stopPropagation(),p(!1),s(e.id,e.name)},x=S=>{S.stopPropagation(),p(!1),a&&a(e)},w=S=>{S.stopPropagation(),p(!1),i&&i(e)},y=S=>{S.stopPropagation(),l&&l(e.id,e.isPinned)},C=S=>{S.stopPropagation(),p(!1),c&&c(e)};return o.jsx(Gu,{"data-testid":e.id,isSelected:t,onClick:n,children:o.jsxs("div",{className:"flex h-full w-full flex-col",children:[o.jsxs("div",{className:"flex items-center justify-between px-4",children:[o.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[o.jsx(Bo,{className:"h-6 w-6 flex-shrink-0 text-[var(--color-brand-wMain)]"}),o.jsx("div",{className:"min-w-0",children:o.jsx("h2",{className:"truncate text-lg font-semibold",title:e.name,children:e.name})})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[l&&o.jsx(ye,{variant:"ghost",size:"icon",onClick:y,className:e.isPinned?"text-primary":"text-muted-foreground",tooltip:e.isPinned?"Remove from favorites":"Add to favorites",children:o.jsx(D_,{size:16,fill:e.isPinned?"currentColor":"none"})}),o.jsxs(Ga,{open:f,onOpenChange:p,children:[o.jsx(qa,{asChild:!0,children:o.jsx(ye,{variant:"ghost",size:"icon",onClick:S=>{S.stopPropagation(),p(!f)},tooltip:"Actions",className:"cursor-pointer",children:o.jsx(fo,{size:16})})}),o.jsxs(Ya,{align:"end",onClick:S=>S.stopPropagation(),children:[i&&o.jsxs(An,{onClick:w,children:[o.jsx(Lv,{size:14,className:"mr-2"}),"Use in New Chat"]}),c&&o.jsxs(An,{onClick:C,children:[o.jsx(yo,{size:14,className:"mr-2"}),"Export Prompt"]}),o.jsxs(An,{onClick:v,children:[o.jsx(ys,{size:14,className:"mr-2"}),"Edit Prompt"]}),m&&o.jsxs(An,{onClick:x,children:[o.jsx($v,{size:14,className:"mr-2"}),"Open Version History"]}),o.jsxs(An,{onClick:g,children:[o.jsx(Ho,{size:14,className:"mr-2"}),"Delete All Versions"]})]})]})]})]}),o.jsxs("div",{className:"flex flex-grow flex-col overflow-hidden px-4",children:[o.jsxs("div",{className:"text-muted-foreground mb-2 text-xs",children:["By ",e.authorName||e.userId]}),o.jsx("div",{className:"mb-3 line-clamp-2 text-sm leading-5",children:e.description||"No description provided."}),o.jsx("div",{className:"mt-auto",children:o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.command&&o.jsxs("span",{className:"text-primary bg-primary/10 inline-block rounded px-2 py-0.5 font-mono text-xs",children:["/",e.command]}),e.category&&o.jsxs("span",{className:"bg-primary/10 text-primary inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium",children:[o.jsx(Uv,{size:12}),e.category]})]})})]})]})})},LF=({onManualCreate:e,onAIAssisted:t,isCentered:n=!1})=>{const{configFeatureEnablement:r}=on(),s=(r==null?void 0:r.promptAIAssisted)??!0;return n?o.jsx("div",{className:"w-full max-w-[480px] p-8",children:o.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-6",children:[o.jsxs("div",{className:"flex flex-col items-center gap-2",children:[o.jsx("h2",{className:"text-foreground text-2xl font-semibold",children:"Create New Prompt"}),o.jsx("p",{className:"text-muted-foreground text-sm",children:"Choose how you'd like to create your prompt"})]}),o.jsxs("div",{className:"flex w-full max-w-[320px] flex-col gap-3",children:[o.jsxs(ye,{"data-testid":"buildWithAIButton",onClick:t,disabled:!s,variant:"default",size:"lg",className:"w-full",children:[o.jsx(Ba,{className:"mr-2 h-4 w-4"}),"Build with AI",!s&&o.jsx("span",{className:"ml-1 text-xs",children:"(Disabled)"})]}),o.jsxs(ye,{onClick:e,variant:"outline",size:"lg",className:"w-full",children:[o.jsx(Vo,{className:"mr-2 h-4 w-4"}),"Create Manually"]})]})]})}):o.jsx(Gu,{className:"border border-dashed border-[var(--color-primary-wMain)]",children:o.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-4 p-6",children:[o.jsx("h3",{className:"text-center text-lg font-semibold",children:"Create New Prompt"}),o.jsxs("div",{className:"flex w-full max-w-[240px] flex-col gap-3",children:[o.jsxs(ye,{"data-testid":"buildWithAIButton",onClick:t,disabled:!s,variant:"outline",className:"w-full",children:[o.jsx(Ba,{}),"Build with AI",!s&&o.jsx("span",{className:"ml-1 text-xs",children:"(Disabled)"})]}),o.jsxs(ye,{onClick:e,variant:"ghost",className:"w-full",children:[o.jsx(Vo,{}),"Create Manually"]})]})]})})},FF=({prompt:e,onClose:t,onEdit:n,onDelete:r,onViewVersions:s,onUseInChat:a,onExport:i})=>{const{configFeatureEnablement:l}=on(),u=((l==null?void 0:l.promptVersionHistory)??!0)&&s;if(!e)return null;const h=()=>{n(e)},f=()=>{r(e.id,e.name)},p=()=>{s&&s(e)},m=()=>{a&&a(e)},v=()=>{i&&i(e)};return o.jsxs("div",{className:"bg-background flex h-full w-full flex-col border-l",children:[o.jsxs("div",{className:"border-b p-4",children:[o.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[o.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[o.jsx(Bo,{className:"text-muted-foreground h-5 w-5 flex-shrink-0"}),o.jsxs(zs,{delayDuration:300,children:[o.jsx($s,{asChild:!0,children:o.jsx("h2",{className:"cursor-default truncate text-lg font-semibold",children:e.name})}),o.jsx(Us,{side:"bottom",children:o.jsx("p",{children:e.name})})]})]}),o.jsxs("div",{className:"ml-2 flex flex-shrink-0 items-center gap-1",children:[o.jsxs(Ga,{children:[o.jsx(qa,{asChild:!0,children:o.jsx(ye,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",tooltip:"Actions",children:o.jsx(fo,{className:"h-4 w-4"})})}),o.jsxs(Ya,{align:"end",children:[i&&o.jsxs(An,{onClick:v,children:[o.jsx(yo,{size:14,className:"mr-2"}),"Export Prompt"]}),o.jsxs(An,{onClick:h,children:[o.jsx(ys,{size:14,className:"mr-2"}),"Edit Prompt"]}),u&&o.jsxs(An,{onClick:p,children:[o.jsx($v,{size:14,className:"mr-2"}),"Open Version History"]}),o.jsxs(An,{onClick:f,children:[o.jsx(Ho,{size:14,className:"mr-2"}),"Delete All Versions"]})]})]}),o.jsx(ye,{variant:"ghost",size:"sm",onClick:t,className:"h-8 w-8 p-0",tooltip:"Close",children:o.jsx(Kr,{className:"h-4 w-4"})})]})]}),e.category&&o.jsxs("span",{className:"bg-primary/10 text-primary inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium",children:[o.jsx(Uv,{size:12}),e.category]})]}),o.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[o.jsxs("div",{className:"bg-muted/50 space-y-6 rounded p-4",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-muted-foreground mb-2 text-xs font-semibold",children:"Description"}),o.jsx("div",{className:"text-sm leading-relaxed",children:e.description||"No description provided."})]}),e.command&&o.jsxs("div",{children:[o.jsx("h3",{className:"text-muted-foreground mb-2 text-xs font-semibold",children:"Chat Shortcut"}),o.jsx("div",{children:o.jsxs("span",{className:"text-primary bg-primary/10 inline-block rounded px-2 py-0.5 font-mono text-xs",children:["/",e.command]})})]})]}),a&&o.jsxs(ye,{"data-testid":"startNewChatButton",onClick:m,className:"w-full",children:[o.jsx(Dv,{className:"h-4 w-4"}),"Use in New Chat"]}),e.productionPrompt&&o.jsxs("div",{children:[o.jsx("h3",{className:"text-muted-foreground mb-2 text-xs font-semibold",children:"Content"}),o.jsx("div",{className:"font-mono text-xs break-words whitespace-pre-wrap",children:e.productionPrompt.promptText.split(/(\{\{[^}]+\}\})/g).map((g,x)=>g.match(/\{\{[^}]+\}\}/)?o.jsx("span",{className:"bg-primary/20 text-primary rounded px-1 font-medium",children:g},x):o.jsx("span",{children:g},x))})]})]}),o.jsxs("div",{className:"bg-background space-y-2 border-t p-4",children:[o.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-xs",children:[o.jsx(Tc,{size:12}),o.jsxs("span",{children:["Created by: ",e.authorName||e.userId]})]}),e.updatedAt&&o.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-xs",children:[o.jsx(Bv,{size:12}),o.jsxs("span",{children:["Last updated: ",bf(e.updatedAt)]})]})]})]})},zF=({prompts:e,onManualCreate:t,onAIAssisted:n,onEdit:r,onDelete:s,onViewVersions:a,onUseInChat:i,onTogglePin:l,onExport:c,newlyCreatedPromptId:u})=>{const[h,f]=d.useState(null),[p,m]=d.useState(""),[v,g]=d.useState([]),[x,w]=d.useState(!1),y=d.useRef(new Map),{configFeatureEnablement:C}=on(),S=(C==null?void 0:C.promptAIAssisted)??!0,j=M=>{f(L=>(L==null?void 0:L.id)===M.id?null:M)},I=()=>{f(null)},b=d.useMemo(()=>{const M=new Set;return e.forEach(L=>{L.category&&M.add(L.category)}),Array.from(M).sort()},[e]),k=d.useMemo(()=>e.filter(L=>{var O,K,$;const F=((O=L.name)==null?void 0:O.toLowerCase().includes(p.toLowerCase()))||((K=L.description)==null?void 0:K.toLowerCase().includes(p.toLowerCase()))||(($=L.command)==null?void 0:$.toLowerCase().includes(p.toLowerCase())),D=v.length===0||L.category&&v.includes(L.category);return F&&D}).sort((L,F)=>{if(L.isPinned!==F.isPinned)return L.isPinned?-1:1;const D=(L.name||"").toLowerCase(),O=(F.name||"").toLowerCase();return D.localeCompare(O)}),[e,p,v]),N=M=>{g(L=>L.includes(M)?L.filter(F=>F!==M):[...L,M])},A=()=>{g([])},P=()=>{m(""),g([])},E=p.length>0||v.length>0,R=e.length===0;d.useEffect(()=>{if(u&&e.length>0){const M=e.find(L=>L.id===u);M&&(f(M),setTimeout(()=>{const L=y.current.get(u);L&&L.scrollIntoView({behavior:"smooth",block:"center"})},100))}},[u,e]);const _=d.useMemo(()=>{const M=[];return S&&M.push({icon:o.jsx(Ba,{}),text:"Build with AI",variant:"default",onClick:n}),M.push({icon:o.jsx(Vo,{}),text:"Create Manually",variant:"outline",onClick:t}),M},[S,n,t]);return o.jsx("div",{className:"absolute inset-0 h-full w-full",children:o.jsxs(Oy,{id:"promptCardsPanelGroup",direction:"horizontal",className:"h-full",children:[o.jsx(Zc,{defaultSize:h?70:100,minSize:50,maxSize:100,id:"promptCardsMainPanel",children:o.jsxs("div",{className:"flex h-full flex-col pt-6 pb-6 pl-6",children:[!R&&o.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[o.jsx(Qh,{value:p,onChange:m,placeholder:"Filter by name...",testid:"promptSearchInput"}),b.length>0&&o.jsxs("div",{className:"relative",children:[o.jsxs(ye,{onClick:()=>w(!x),variant:"outline",testid:"promptTags",children:[o.jsx(O_,{size:16}),"Tags",v.length>0&&o.jsx("span",{className:"bg-primary text-primary-foreground rounded-full px-2 py-0.5 text-xs",children:v.length})]}),x&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>w(!1)}),o.jsxs("div",{className:"bg-background absolute top-full left-0 z-20 mt-1 max-h-[300px] min-w-[200px] overflow-y-auto rounded-md border shadow-lg",children:[v.length>0&&o.jsx("div",{className:"border-b",children:o.jsxs("button",{"data-testid":"clearFiltersButton",onClick:A,className:"text-muted-foreground hover:text-foreground hover:bg-muted flex min-h-[24px] w-full cursor-pointer items-center gap-1 px-3 py-2 text-left text-xs transition-colors",children:[o.jsx(Kr,{size:14}),v.length===1?"Clear Filter":"Clear Filters"]})}),o.jsx("div",{className:"p-1",children:b.map(M=>o.jsxs("label",{className:"hover:bg-muted flex cursor-pointer items-center gap-2 rounded px-2 py-1.5",children:[o.jsx("input",{"data-testid":`category-checkbox-${M}`,type:"checkbox",checked:v.includes(M),onChange:()=>N(M),className:"rounded"}),o.jsx("span",{className:"text-sm",children:M})]},M))})]})]})]}),E&&o.jsxs(ye,{variant:"ghost",onClick:P,"data-testid":"clearAllFiltersButton",children:[o.jsx(Kr,{size:16}),"Clear All"]})]}),k.length===0&&p?o.jsx(rr,{title:"No Prompts Match Your Filter",subtitle:"Try adjusting your filter terms.",variant:"notFound",buttons:[{text:"Clear Filter",variant:"default",onClick:()=>m("")}]}):R?o.jsx(rr,{title:"No Prompts Found",subtitle:"Create prompts to support reusable text structures for chat interactions.",variant:"noImage",buttons:_}):o.jsx("div",{className:"flex-1 overflow-y-auto",children:o.jsxs("div",{className:"flex flex-wrap gap-6",children:[o.jsx(LF,{onManualCreate:t,onAIAssisted:n}),k.map(M=>o.jsx("div",{ref:L=>{L?y.current.set(M.id,L):y.current.delete(M.id)},children:o.jsx(OF,{prompt:M,isSelected:(h==null?void 0:h.id)===M.id,onPromptClick:()=>j(M),onEdit:r,onDelete:s,onViewVersions:a,onUseInChat:i,onTogglePin:l,onExport:c})},M.id))]})})]})}),h&&o.jsxs(o.Fragment,{children:[o.jsx(Ly,{}),o.jsx(Zc,{defaultSize:30,minSize:20,maxSize:50,id:"promptDetailSidePanel",children:o.jsx(FF,{prompt:h,onClose:I,onEdit:r,onDelete:s,onViewVersions:a,onUseInChat:i,onTogglePin:l,onExport:c})})]})]})})},$F=["create-template"];function UF(e){return $F.includes(e)}function BF(e){const{addNotification:t}=$t(),[n,r]=d.useState(()=>{var g,x;return e?{name:e.name,description:e.description,category:e.category,command:e.command,promptText:((g=e.productionPrompt)==null?void 0:g.promptText)||"",detected_variables:Va(((x=e.productionPrompt)==null?void 0:x.promptText)||"")}:{}}),[s,a]=d.useState({}),[i,l]=d.useState(!1),[c,u]=d.useState("idle"),h=d.useCallback(g=>{r(x=>{const w={...x,...g};if(g.promptText!==void 0){const y=Va(g.promptText||"");w.detected_variables=y}return w}),a(x=>{const w={...x};return Object.keys(g).forEach(y=>{delete w[y]}),w})},[]),f=d.useCallback(async()=>{const g={};if(!n.name||n.name.trim().length===0?g.name="Template name is required":n.name.length>255&&(g.name="Template name must be less than 255 characters"),!n.command||n.command.trim().length===0?g.command="Chat shortcut is required":/^[a-zA-Z0-9_-]+$/.test(n.command)?n.command.length>50?g.command="Command must be less than 50 characters":UF(n.command)&&(g.command=`'${n.command}' is a reserved command and cannot be used`):g.command="Command can only contain letters, numbers, hyphens, and underscores",!n.promptText||n.promptText.trim().length===0)g.promptText="Prompt text is required";else{const w=z2(n.promptText);w.valid||(g.promptText=w.error||"Invalid prompt text")}a(g);const x=Object.keys(g).length===0;return x&&t("Template is valid and ready to save!","success"),x},[n,t]),p=d.useCallback(async()=>{l(!0),u("saving");try{if(!await f())return u("error"),l(!1),null;const x={name:n.name,description:n.description||null,category:n.category||null,command:n.command||null,initial_prompt:n.promptText},w=await Ie.webui.post("/api/v1/prompts/groups",x);return u("success"),t("Template saved","success"),l(!1),w.id}catch(g){console.error("Error saving template:",g),u("error"),l(!1);const x=Zt(g,"Failed to save template");return a(w=>({...w,_general:x})),null}},[n,f,t]),m=d.useCallback(async(g,x)=>{var w;l(!0),u("saving");try{if(!await f())return u("error"),l(!1),!1;const C=n.promptText!==((w=e==null?void 0:e.productionPrompt)==null?void 0:w.promptText),S=(e==null?void 0:e._isEditingActiveVersion)??!0,j=(e==null?void 0:e._editingPromptId)||(e==null?void 0:e.productionPromptId);if(x){const I={};return n.name!==(e==null?void 0:e.name)&&(I.name=n.name),n.description!==(e==null?void 0:e.description)&&(I.description=n.description),n.category!==(e==null?void 0:e.category)&&(I.category=n.category),n.command!==(e==null?void 0:e.command)&&(I.command=n.command),I.initial_prompt=n.promptText,await Ie.webui.patch(`/api/v1/prompts/groups/${g}`,I),u("success"),t(C?"New version created and activated":"Changes saved","success"),l(!1),!0}else{if(n.name!==(e==null?void 0:e.name)||n.description!==(e==null?void 0:e.description)||n.category!==(e==null?void 0:e.category)||n.command!==(e==null?void 0:e.command)){const k={};n.name!==(e==null?void 0:e.name)&&(k.name=n.name),n.description!==(e==null?void 0:e.description)&&(k.description=n.description),n.category!==(e==null?void 0:e.category)&&(k.category=n.category),n.command!==(e==null?void 0:e.command)&&(k.command=n.command),await Ie.webui.patch(`/api/v1/prompts/groups/${g}`,k)}return C&&j&&await Ie.webui.patch(`/api/v1/prompts/${j}`,{promptText:n.promptText}),u("success"),t(S?"Active version updated":"Version updated","success"),l(!1),!0}}catch(y){console.error("Error updating template:",y),u("error"),l(!1);const C=Zt(y,"Failed to update template");return a(S=>({...S,_general:C})),!1}},[n,e,f,t]),v=d.useCallback(()=>{r({}),a({}),u("idle")},[]);return{config:n,updateConfig:h,validateConfig:f,saveTemplate:p,updateTemplate:m,resetConfig:v,validationErrors:s,isLoading:i,saveStatus:c}}const VF=({onConfigUpdate:e,currentConfig:t,onReadyToSave:n,initialMessage:r,isEditing:s=!1})=>{const[a,i]=d.useState([]),[l,c]=d.useState(""),[u,h]=d.useState(!1),[f,p]=d.useState(!0),[m,v]=d.useState(!1),g=d.useRef(null),x=d.useRef(null),w=d.useRef(!1),{settings:y}=So(),{configFeatureEnablement:C}=on(),S=(C==null?void 0:C.speechToText)??!0,[j,I]=d.useState(null),[b,k]=d.useState(!1),N=()=>{var _;(_=g.current)==null||_.scrollIntoView({behavior:"smooth"})};d.useEffect(()=>{N()},[a]),d.useEffect(()=>{if(w.current)return;w.current=!0,(async()=>{try{const M=await Ie.webui.get("/api/v1/prompts/chat/init"),L=s?"Hi! I'll help you edit this prompt template. What changes would you like to make?":M.message;if(i([{role:"assistant",content:L,timestamp:new Date}]),r){v(!0);const F={role:"user",content:r,timestamp:new Date};i(D=>[...D,F]),setTimeout(()=>N(),100),h(!0);try{const D=await Ie.webui.post("/api/v1/prompts/chat",{message:r,conversation_history:[{role:"assistant",content:M.message}],current_template:t},{fullResponse:!0});if(D.ok){const O=await D.json(),K={role:"assistant",content:O.message,timestamp:new Date};i($=>[...$,K]),Object.keys(O.template_updates).length>0&&e(O.template_updates),n(O.ready_to_save),setTimeout(()=>N(),100)}else{const O=await D.json().catch(()=>({}));console.error("Prompt builder API error:",O);const K={role:"assistant",content:"The conversation history is too long for automatic processing. Please describe your task manually, and I'll help you create a template.",timestamp:new Date};i($=>[...$,K])}}catch(D){console.error("Error sending initial message:",D);const O={role:"assistant",content:"I encountered an error processing your request. Please try describing your task manually.",timestamp:new Date};i(K=>[...K,O])}finally{h(!1)}}}catch(M){console.error("Failed to initialize chat:",M),i([{role:"assistant",content:s?"Hi! I'll help you edit this prompt template. What changes would you like to make?":"Hi! I'll help you create a prompt template. What kind of recurring task would you like to template?",timestamp:new Date}])}finally{p(!1)}})()},[]),d.useEffect(()=>{!f&&!u&&x.current&&x.current.focus()},[f,u]),d.useEffect(()=>{const _=x.current;if(!_)return;(()=>{_.style.height="auto";const L=Math.min(_.scrollHeight,200);_.style.height=`${L}px`})()},[l]);const A=d.useCallback(_=>{const M=l?`${l} ${_}`:_;c(M),setTimeout(()=>{var L;(L=x.current)==null||L.focus()},100)},[l]),P=d.useCallback(_=>{I(_)},[]),E=async()=>{if(!l.trim()||u)return;const _={role:"user",content:l.trim(),timestamp:new Date};i(M=>[...M,_]),c(""),h(!0),v(!0);try{const M=await Ie.webui.post("/api/v1/prompts/chat",{message:_.content,conversation_history:a.filter(F=>F.content&&F.content.trim().length>0).map(F=>({role:F.role,content:F.content})),current_template:t}),L={role:"assistant",content:M.message,timestamp:new Date};i(F=>[...F,L]),Object.keys(M.template_updates).length>0&&e(M.template_updates),n(M.ready_to_save)}catch(M){console.error("Error sending message:",M);const L={role:"assistant",content:"I encountered an error. Could you please try again?",timestamp:new Date};i(F=>[...F,L])}finally{h(!1),setTimeout(()=>{var M;return(M=x.current)==null?void 0:M.focus()},100)}},R=_=>{_.preventDefault(),E()};return f?o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsxs("div",{className:"flex flex-col items-center gap-3",children:[o.jsx(ur,{className:"text-primary h-8 w-8 animate-spin"}),o.jsx("p",{className:"text-muted-foreground text-sm",children:"Initializing AI assistant..."})]})}):o.jsxs("div",{className:"flex h-full flex-col",children:[o.jsx("div",{className:"border-b px-4 py-3",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"bg-primary/10 flex h-8 w-8 items-center justify-center rounded-full",children:o.jsx(Ba,{className:"text-primary h-4 w-4"})}),o.jsx("h3",{className:"text-sm font-semibold",children:"AI Template Builder"})]})}),o.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto p-4",children:[a.map((_,M)=>o.jsx("div",{className:`flex ${_.role==="user"?"justify-end":"justify-start"}`,children:o.jsx("div",{className:`max-w-[80%] rounded-2xl px-4 py-3 ${_.role==="user"?"bg-[var(--message-background)]":""}`,children:o.jsx("div",{className:"text-sm leading-relaxed whitespace-pre-wrap",children:_.content})})},M)),u&&o.jsx("div",{className:"flex justify-start",children:o.jsxs("div",{className:"flex items-center gap-2 rounded-2xl px-4 py-3",children:[o.jsx(ur,{className:"h-4 w-4 animate-spin"}),o.jsx("span",{className:"text-muted-foreground text-sm",children:"Thinking..."})]})}),o.jsx("div",{ref:g})]}),o.jsxs("div",{className:"bg-background border-t p-4",children:[j&&o.jsx("div",{className:"mb-3",children:o.jsx(Xt,{variant:"error",message:j,dismissible:!0,onDismiss:()=>I(null)})}),o.jsxs("form",{onSubmit:R,className:"relative",children:[o.jsx(ts,{ref:x,value:l,onChange:_=>c(_.target.value),onKeyDown:_=>{_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),E())},placeholder:b?"Recording...":m?"Type your message...":"Describe your recurring task...",disabled:u||b,className:"max-h-[200px] min-h-[40px] resize-none overflow-y-auto pr-24",rows:1,style:{height:"40px"}}),o.jsxs("div",{className:"absolute top-1/2 right-2 flex -translate-y-1/2 items-center gap-1",children:[S&&y.speechToText&&o.jsx(Im,{disabled:u,onTranscriptionComplete:A,onError:P,onRecordingStateChange:k}),o.jsx(ye,{type:"submit",disabled:!l.trim()||u,variant:"ghost",size:"icon",tooltip:"Send message",children:u?o.jsx(ur,{className:"h-4 w-4 animate-spin"}):o.jsx(Av,{className:"h-4 w-4"})})]})]})]})]})},HF=({config:e,highlightedFields:t})=>{const n=e.promptText&&e.promptText.trim().length>0,r=d.useRef(0),s=d.useRef([]);t.length>0&&(t.length!==s.current.length||t.some((h,f)=>h!==s.current[f]))&&n&&(r.current+=1,s.current=[...t]);const i=r.current>=2&&t.length>0,l=(h,f,p,m=!1)=>{const v=t.includes(p),g=!f||f.trim().length===0;return o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(zt,{className:"text-muted-foreground text-sm font-medium",children:h}),v&&i&&o.jsx(go,{variant:"default",className:"bg-primary text-primary-foreground text-xs",children:"Updated"})]}),m?o.jsx("div",{className:"rounded p-3 text-sm",children:g?o.jsxs("span",{className:"text-muted-foreground italic",children:["No ",h.toLowerCase()," yet"]}):o.jsxs("span",{className:"text-primary font-mono",children:["/",f]})}):o.jsx("div",{className:"rounded p-3 text-sm",children:g?o.jsxs("span",{className:"text-muted-foreground italic",children:["No ",h.toLowerCase()," yet"]}):f})]})},c=()=>{const h=t.includes("promptText"),f=!e.promptText||e.promptText.trim().length===0,p=m=>m.split(/(\{\{[^}]+\}\})/g).map((g,x)=>g.match(/\{\{[^}]+\}\}/)?o.jsx("span",{className:"bg-primary/20 text-primary rounded px-1 font-medium",children:g},x):o.jsx("span",{children:g},x));return o.jsxs("div",{className:"space-y-2",children:[o.jsx("div",{className:"flex items-center gap-2",children:h&&i&&o.jsx(go,{variant:"default",className:"bg-primary text-primary-foreground text-xs",children:"Updated"})}),o.jsx("div",{className:"min-h-[288px] w-full rounded-md px-3 py-2 font-mono text-sm whitespace-pre-wrap",children:f?o.jsx("span",{className:"text-muted-foreground italic",children:"No prompt text yet"}):p(e.promptText)})]})},u=()=>{const h=e.detected_variables||[];return h.length===0?o.jsx("div",{className:"text-muted-foreground py-2 text-sm italic",children:"No variables detected yet"}):o.jsx("div",{className:"py-2",children:o.jsx("div",{className:"flex flex-wrap gap-2",children:h.map((f,p)=>o.jsx("span",{className:"bg-primary/10 text-primary rounded px-2 py-1 font-mono text-xs",children:`{{${f}}}`},p))})})};return o.jsxs("div",{className:"flex h-full flex-col",children:[o.jsx("div",{className:"border-b px-4 py-3",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"bg-muted flex h-8 w-8 items-center justify-center rounded-full",children:o.jsx(Bo,{className:"text-muted-foreground h-4 w-4"})}),o.jsx("div",{children:o.jsx("h3",{className:"text-sm font-semibold",children:"Template Preview"})})]})}),o.jsx("div",{className:"flex-1 space-y-4 overflow-y-auto px-4",style:{paddingTop:"24px"},children:n?o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx(Na,{className:"mb-4 text-base",children:"Basic Information"}),o.jsxs("div",{className:"space-y-6",children:[l("Name",e.name,"name"),l("Description",e.description,"description"),l("Tag",e.category,"category"),l("Chat Shortcut",e.command,"command",!0)]})]}),o.jsxs("div",{children:[o.jsx(Na,{className:"mb-4 text-base",children:"Content"}),c()]}),o.jsxs("div",{children:[o.jsx(Na,{className:"mb-4 text-base",children:"Variables"}),o.jsx("div",{className:"space-y-3",children:e.detected_variables&&e.detected_variables.length>0?o.jsxs(o.Fragment,{children:[o.jsxs("p",{className:"text-muted-foreground text-sm leading-relaxed",children:["Variables are placeholder values that make your prompt flexible and reusable. Variables are enclosed in double brackets like"," ",o.jsx("code",{className:"bg-muted rounded px-1.5 py-0.5 font-mono text-xs",children:"{{Variable Name}}"}),". You will be asked to fill in these variable values whenever you use this prompt. The prompt above has the following variables:"]}),u()]}):o.jsx("div",{className:"text-muted-foreground bg-muted/50 rounded-lg p-3 text-sm italic",children:"No variables detected yet"})})]})]}):o.jsxs("div",{className:"flex h-full flex-col items-center justify-center p-8 text-center",children:[o.jsx("div",{className:"bg-muted mb-4 flex h-16 w-16 items-center justify-center rounded-full",children:o.jsx(Bo,{className:"text-muted-foreground h-8 w-8"})}),o.jsx("h3",{className:"mb-2 text-lg font-semibold",children:"No Template Yet"}),o.jsx("p",{className:"text-muted-foreground max-w-sm text-sm",children:"Start chatting with the AI assistant to create your template. The preview will update in real-time as you describe your task."})]})})]})},WF=({onBack:e,onSuccess:t,initialMessage:n,editingGroup:r,isEditing:s=!1,initialMode:a})=>{const{config:i,updateConfig:l,saveTemplate:c,updateTemplate:u,resetConfig:h,validationErrors:f,isLoading:p}=BF(r),[m,v]=d.useState(a||"ai-assisted"),[g,x]=d.useState(!1),[w,y]=d.useState([]),[C,S]=d.useState(null),{allowNavigation:j,NavigationBlocker:I,setBlockingEnabled:b}=SP();d.useEffect(()=>{var L;if(r&&s){const F={name:r.name,description:r.description,category:r.category,command:r.command,promptText:((L=r.productionPrompt)==null?void 0:L.promptText)||""};l(F),S(F)}else S({name:"",description:"",category:void 0,command:"",promptText:""})},[r,s,l]),d.useEffect(()=>{var D,O,K,$;if(!C){b(!1);return}if(!!!((D=i.name)!=null&&D.trim()||(O=i.description)!=null&&O.trim()||i.category||(K=i.command)!=null&&K.trim()||($=i.promptText)!=null&&$.trim())){b(!1);return}const F=i.name!==C.name||i.description!==C.description||i.category!==C.category||i.command!==C.command||i.promptText!==C.promptText;b(F)},[i,C,b]);const k=(L=!1)=>{L?j(()=>{h(),v("ai-assisted"),x(!1),y([]),S(null),e()}):e()},N=Object.keys(f).length>0,A=Object.values(f).filter(Boolean),P=async()=>{if(s&&r)await u(r.id,!1)&&j(()=>{k(!0),t&&t(r.id)});else{const L=await c();L&&j(()=>{k(!0),t&&t(L)})}},E=async()=>{if(!s||!r)return;await u(r.id,!0)&&j(()=>{k(!0),t&&t(r.id)})},R=L=>{const F=Object.keys(L).filter(D=>{const O=i[D],K=L[D],$=O==null||O===""?"":O,W=K==null||K===""?"":K;return $!==W});l(L),y(F)},_=()=>{v("manual"),y([])},M=()=>{v("ai-assisted"),y([])};return o.jsx(o.Fragment,{children:o.jsxs("div",{className:"flex h-full flex-col",children:[o.jsx(sa,{title:s?"Edit Prompt":"Create Prompt",breadcrumbs:[{label:"Prompts",onClick:()=>k()},{label:s?"Edit Prompt":"Create Prompt"}],buttons:m==="ai-assisted"?[o.jsxs(ye,{"data-testid":"editManuallyButton",onClick:_,variant:"ghost",size:"sm",children:[o.jsx(ys,{className:"mr-1 h-3 w-3"}),"Edit Manually"]},"edit-manually")]:[o.jsxs(ye,{"data-testid":"buildWithAIButton",onClick:M,variant:"ghost",size:"sm",children:[o.jsx(Ba,{className:"mr-1 h-3 w-3"}),s?"Edit with AI":"Build with AI"]},"build-with-ai")]}),N&&o.jsx("div",{className:"px-8 py-3",children:o.jsx(Xt,{variant:"error",message:`Please fix the following errors: ${A.join(", ")}`})}),o.jsxs("div",{className:"flex min-h-0 flex-1",children:[o.jsx("div",{className:`w-[40%] overflow-hidden border-r ${m==="manual"?"hidden":""}`,children:o.jsx(VF,{onConfigUpdate:R,currentConfig:i,onReadyToSave:x,initialMessage:n,isEditing:s})}),m==="ai-assisted"&&o.jsx("div",{className:"w-[60%] overflow-hidden",children:o.jsx(HF,{config:i,highlightedFields:w,isReadyToSave:g})}),m==="manual"&&o.jsx("div",{className:"flex-1 overflow-y-auto px-8 py-6",children:o.jsxs("div",{className:"mx-auto max-w-4xl space-y-6",children:[o.jsxs("div",{children:[o.jsx(Na,{className:"mb-4 text-base",children:"Basic Information"}),o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsxs(zt,{htmlFor:"template-name",children:["Name ",o.jsx("span",{className:"text-[var(--color-primary-wMain)]",children:"*"})]}),o.jsx(_r,{id:"template-name",placeholder:"e.g., Code Review Template",value:i.name||"",onChange:L=>l({name:L.target.value}),className:`placeholder:text-muted-foreground/50 ${f.name?"border-red-500":""}`}),f.name&&o.jsxs("p",{className:"flex items-center gap-1 text-sm text-red-600",children:[o.jsx(io,{className:"h-3 w-3"}),f.name]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(zt,{htmlFor:"template-description",children:"Description"}),o.jsx(_r,{id:"template-description",placeholder:"e.g., Reviews code for best practices and potential issues",value:i.description||"",onChange:L=>l({description:L.target.value}),className:"placeholder:text-muted-foreground/50"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(zt,{htmlFor:"template-category",children:"Tag"}),o.jsxs(Wr,{value:i.category||"none",onValueChange:L=>l({category:L==="none"?void 0:L}),children:[o.jsx(Gr,{children:o.jsx(Zr,{placeholder:"Select tag"})}),o.jsxs(qr,{children:[o.jsx(Pt,{value:"none",children:"No Tag"}),o.jsx(Pt,{value:"Development",children:"Development"}),o.jsx(Pt,{value:"Analysis",children:"Analysis"}),o.jsx(Pt,{value:"Documentation",children:"Documentation"}),o.jsx(Pt,{value:"Communication",children:"Communication"}),o.jsx(Pt,{value:"Testing",children:"Testing"}),o.jsx(Pt,{value:"Other",children:"Other"})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(zt,{htmlFor:"template-command",children:["Chat Shortcut ",o.jsx("span",{className:"text-[var(--color-primary-wMain)]",children:"*"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-muted-foreground text-sm",children:"/"}),o.jsx(_r,{id:"template-command",placeholder:"e.g., code-review",value:i.command||"",onChange:L=>l({command:L.target.value}),className:`placeholder:text-muted-foreground/50 ${f.command?"border-red-500":""}`})]}),o.jsx("p",{className:"text-muted-foreground text-xs",children:"Quick access shortcut for chat (letters, numbers, hyphens, underscores only)"})]})]})]}),o.jsxs("div",{children:[o.jsxs(Na,{className:"mb-4 text-base",children:["Content",o.jsx("span",{className:"text-[var(--color-primary-wMain)]",children:"*"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(I0,{id:"template-prompt","data-testid":"prompt-text-input",placeholder:"Enter your prompt template here. Use {{Variable Name}} for placeholders.",value:i.promptText||"",onChange:L=>l({promptText:L.target.value}),rows:12,className:`placeholder:text-muted-foreground/50 ${f.promptText?"border-red-500":""}`}),f.promptText&&o.jsxs("p",{className:"flex items-center gap-1 text-sm text-red-600",children:[o.jsx(io,{className:"h-3 w-3"}),f.promptText]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("p",{className:"text-muted-foreground text-sm",children:["Variables are placeholder values that make your prompt flexible and reusable. You will be asked to fill in these variable values whenever you use this prompt. Use ","{{Variable Name}}"," for placeholders.",i.detected_variables&&i.detected_variables.length>0&&" Your prompt has the following variables:"]}),i.detected_variables&&i.detected_variables.length>0&&o.jsx("div",{className:"flex flex-wrap gap-2",children:i.detected_variables.map((L,F)=>o.jsx("span",{className:"bg-primary/10 text-primary rounded px-2 py-1 font-mono text-xs",children:`{{${L}}}`},F))})]})]})]})]})})]}),o.jsx(I,{}),o.jsxs("div",{className:"flex justify-end gap-2 border-t p-4",children:[o.jsx(ye,{variant:"ghost",onClick:()=>k(),disabled:p,children:s?"Discard Changes":"Cancel"}),s&&o.jsx(ye,{variant:"outline",onClick:E,disabled:p,children:p?o.jsxs(o.Fragment,{children:[o.jsx(ur,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save New Version"}),o.jsx(ye,{"data-testid":"createPromptButton",onClick:P,disabled:p,children:p?o.jsxs(o.Fragment,{children:[o.jsx(ur,{className:"mr-2 h-4 w-4 animate-spin"}),s?"Saving...":"Creating..."]}):s?"Save":"Create"})]})]})})},Kd=xt.memo(({isOpen:e,onClose:t,onConfirm:n,promptName:r})=>o.jsx(Rr,{title:"Delete Prompt",content:o.jsxs(o.Fragment,{children:["This action cannot be undone. This will permanently delete the prompt and all its versions: ",o.jsx("strong",{children:r}),"."]}),actionLabels:{confirm:"Delete"},open:e,onOpenChange:s=>!s&&t(),onConfirm:n,onCancel:t})),ZF=({group:e,onBack:t,onEdit:n,onDeleteAll:r,onRestoreVersion:s})=>{const{addNotification:a,displayError:i}=$t(),[l,c]=d.useState([]),[u,h]=d.useState(null),[f,p]=d.useState(!1),[m,v]=d.useState(e),[g,x]=d.useState(!1),w=d.useRef(!1);d.useEffect(()=>{v(e)},[e]);const y=d.useCallback(async(k=!1)=>{p(!0);try{const N=await Ie.webui.get(`/api/v1/prompts/groups/${e.id}/prompts`);c(N),h(A=>{if(e._selectedVersionId){const P=N.find(E=>E.id===e._selectedVersionId);if(P)return P}if(k&&A){const P=N.find(E=>E.id===A.id);return P||N.find(E=>E.id===e.productionPromptId)||N[0]}else if(N.length>0&&!w.current)return w.current=!0,N.find(P=>P.id===e.productionPromptId)||N[0];return A})}catch(N){console.error("Failed to fetch versions:",N)}finally{p(!1)}},[e.id,e.productionPromptId,e._selectedVersionId]),C=d.useCallback(async()=>{try{const k=await Ie.webui.get(`/api/v1/prompts/groups/${e.id}`);v(k)}catch(k){console.error("Failed to fetch group data:",k)}},[e.id]);d.useEffect(()=>{y(!0)},[y]);const S=()=>{const k={...m,name:(u==null?void 0:u.name)||m.name,description:(u==null?void 0:u.description)||m.description,category:(u==null?void 0:u.category)||m.category,command:(u==null?void 0:u.command)||m.command,productionPrompt:u?{id:u.id,promptText:u.promptText,groupId:u.groupId,userId:u.userId,version:u.version,name:u.name,description:u.description,category:u.category,command:u.command,createdAt:u.createdAt,updatedAt:u.updatedAt}:m.productionPrompt,_editingPromptId:u==null?void 0:u.id,_isEditingActiveVersion:(u==null?void 0:u.id)===m.productionPromptId,_selectedVersionId:u==null?void 0:u.id};n(k)},j=async()=>{if(u){if(u.id===m.productionPromptId){x(!0),setTimeout(()=>x(!1),5e3);return}try{await Ie.webui.delete(`/api/v1/prompts/${u.id}`),a("Version deleted successfully","success"),h(null),await y(!1)}catch(k){i({title:"Failed to Delete Version",error:Zt(k,"An unknown error occurred while deleting the version.")})}}},I=async()=>{u&&u.id!==m.productionPromptId&&(await s(u.id),await C(),await y(!0))},b=(u==null?void 0:u.id)===m.productionPromptId;return o.jsxs("div",{className:"flex h-full flex-col",children:[o.jsx(sa,{title:`Version History: ${m.name}`,breadcrumbs:[{label:"Prompts",onClick:t},{label:"Version History"}],buttons:[o.jsxs(Ga,{children:[o.jsx(qa,{asChild:!0,children:o.jsx(ye,{variant:"ghost",size:"sm",children:o.jsx(fo,{className:"h-4 w-4"})})}),o.jsx(Ya,{align:"end",children:o.jsxs(An,{onClick:()=>r(m.id,m.name),children:[o.jsx(Ho,{size:14,className:"mr-2"}),"Delete All Versions"]})})]},"actions-menu")]}),g&&o.jsx(Xt,{variant:"error",message:"Cannot delete the active version. Please make another version active first."}),o.jsxs("div",{className:"flex min-h-0 flex-1",children:[o.jsx("div",{className:"w-[300px] overflow-y-auto border-r",children:o.jsxs("div",{className:"p-4",children:[o.jsx("h3",{className:"text-muted-foreground mb-3 text-sm font-semibold",children:"Versions"}),f?o.jsx("div",{className:"flex items-center justify-center p-8",children:o.jsx("div",{className:"border-primary size-6 animate-spin rounded-full border-2 border-t-transparent"})}):o.jsx("div",{className:"space-y-2",children:l.map(k=>{const N=k.id===m.productionPromptId,A=(u==null?void 0:u.id)===k.id;return o.jsxs("button",{"data-testid":k.id,onClick:()=>h(k),className:`w-full p-3 text-left transition-colors ${A?"bg-primary/5":"hover:bg-muted/50"}`,children:[o.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[o.jsxs("span",{className:"text-sm font-medium",children:["Version ",k.version]}),N&&o.jsx("span",{className:"rounded-full bg-[var(--color-success-w20)] px-2 py-0.5 text-xs text-[var(--color-success-wMain)]",children:"Active"})]}),o.jsx("span",{className:"text-muted-foreground text-xs",children:bf(k.createdAt)})]},k.id)})})]})}),o.jsx("div",{className:"flex-1 overflow-y-auto",children:u?o.jsx("div",{className:"p-6",children:o.jsxs("div",{className:"mx-auto max-w-4xl space-y-6",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("h2",{className:"text-lg font-semibold",children:["Version ",u.version," Details"]}),o.jsxs(Ga,{children:[o.jsx(qa,{asChild:!0,children:o.jsx(ye,{variant:"ghost",size:"sm",children:o.jsx(fo,{className:"h-4 w-4"})})}),o.jsxs(Ya,{align:"end",children:[o.jsxs(An,{onClick:S,children:[o.jsx(ys,{size:14,className:"mr-2"}),"Edit Version"]}),!b&&o.jsxs(An,{onClick:I,children:[o.jsx(ni,{size:14,className:"mr-2"}),"Make Active Version"]}),o.jsxs(An,{onClick:j,children:[o.jsx(Ho,{size:14,className:"mr-2"}),"Delete Version"]})]})]})]}),o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(zt,{className:"text-[var(--color-secondaryText-wMain)]",children:"Name"}),o.jsx("div",{className:"rounded p-3 text-sm",children:u.name||m.name})]}),(u.description||m.description)&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(zt,{className:"text-[var(--color-secondaryText-wMain)]",children:"Description"}),o.jsx("div",{className:"rounded p-3 text-sm",children:u.description||m.description})]}),(u.command||m.command)&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(zt,{className:"text-[var(--color-secondaryText-wMain)]",children:"Chat Shortcut"}),o.jsx("div",{className:"rounded p-3 text-sm",children:o.jsxs("span",{className:"text-primary font-mono",children:["/",u.command||m.command]})})]}),(u.category||m.category)&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(zt,{className:"text-[var(--color-secondaryText-wMain)]",children:"Tag"}),o.jsx("div",{className:"rounded p-3 text-sm",children:u.category||m.category})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(zt,{className:"text-[var(--color-secondaryText-wMain)]",children:"Content"}),o.jsx("div",{className:"rounded p-3 font-mono text-sm break-words whitespace-pre-wrap",children:u.promptText.split(/(\{\{[^}]+\}\})/g).map((k,N)=>k.match(/\{\{[^}]+\}\}/)?o.jsx("span",{className:"bg-primary/20 text-primary rounded px-1 font-medium",children:k},N):o.jsx("span",{children:k},N))})]}),o.jsx("div",{className:"border-t pt-4",children:o.jsxs("div",{className:"text-muted-foreground text-xs",children:["Created: ",bf(u.createdAt)]})})]})]})}):o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx("p",{className:"text-muted-foreground",children:"Select a version to view details"})})})]})]})},GF=[{icon:Sr,label:"Summarize a document"},{icon:L_,label:"Write me an email"},{icon:ph,label:"Translate code"}],Ox=({isOpen:e,onClose:t,onGenerate:n})=>{const[r,s]=d.useState(""),[a,i]=d.useState(!1),l=()=>{if(!r.trim()){i(!0);return}i(!1),n(r.trim()),s("")},c=f=>{s(f)},u=()=>{s(""),i(!1),t()},h=f=>{s(f.target.value),a&&f.target.value.trim()&&i(!1)};return o.jsx(Nr,{open:e,onOpenChange:()=>{},children:o.jsxs(Tr,{className:"sm:max-w-[600px]",children:[o.jsxs(rs,{children:[o.jsx(Ar,{className:"text-xl",children:"Create Prompt"}),o.jsx(Ir,{className:"text-base",children:"You can generate a prompt by sharing basic details about your task. Alternatively, paste in an existing prompt and the AI will convert it into a re-usable prompt for you."})]}),a&&o.jsx(Xt,{variant:"error",message:"Please describe your task before generating a prompt.",dismissible:!0,onDismiss:()=>i(!1)}),o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsx(ts,{placeholder:"Describe your task...",value:r,onChange:h,rows:6,className:"resize-none",onKeyDown:f=>{f.key==="Enter"&&(f.metaKey||f.ctrlKey)&&l()}}),o.jsx("div",{className:"flex flex-wrap gap-2",children:GF.map((f,p)=>{const m=f.icon;return o.jsxs(go,{variant:"outline",className:"hover:bg-primary/10 cursor-pointer px-3 py-1.5 transition-colors",onClick:()=>c(f.label),children:[o.jsx(m,{className:"mr-1.5 h-3 w-3"}),f.label]},p)})})]}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(ye,{variant:"ghost",onClick:u,children:"Cancel"}),o.jsxs(ye,{"data-testid":"generatePromptButton",onClick:l,children:[o.jsx(Ba,{className:"mr-2 h-4 w-4"}),"Generate"]})]})]})})},Lx=(e,t,n)=>{if(e&&"reportValidity"in e){const r=Xe(n,t);e.setCustomValidity(r&&r.message||""),e.reportValidity()}},ih=(e,t)=>{for(const n in t.fields){const r=t.fields[n];r&&r.ref&&"reportValidity"in r.ref?Lx(r.ref,n,e):r&&r.refs&&r.refs.forEach(s=>Lx(s,n,e))}},Fx=(e,t)=>{t.shouldUseNativeValidation&&ih(e,t);const n={};for(const r in e){const s=Xe(t.fields,r),a=Object.assign(e[r]||{},{ref:s&&s.ref});if(qF(t.names||Object.keys(e),r)){const i=Object.assign({},Xe(n,r));qt(i,"root",a),qt(n,r,i)}else qt(n,r,a)}return n},qF=(e,t)=>{const n=zx(t);return e.some(r=>zx(r).match(`^${n}\\.\\d+`))};function zx(e){return e.replace(/\]|\[/g,"")}function ve(e,t,n){function r(l,c){var u;Object.defineProperty(l,"_zod",{value:l._zod??{},enumerable:!1}),(u=l._zod).traits??(u.traits=new Set),l._zod.traits.add(e),t(l,c);for(const h in i.prototype)h in l||Object.defineProperty(l,h,{value:i.prototype[h].bind(l)});l._zod.constr=i,l._zod.def=c}const s=(n==null?void 0:n.Parent)??Object;class a extends s{}Object.defineProperty(a,"name",{value:e});function i(l){var c;const u=n!=null&&n.Parent?new a:this;r(u,l),(c=u._zod).deferred??(c.deferred=[]);for(const h of u._zod.deferred)h();return u}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:l=>{var c,u;return n!=null&&n.Parent&&l instanceof n.Parent?!0:(u=(c=l==null?void 0:l._zod)==null?void 0:c.traits)==null?void 0:u.has(e)}}),Object.defineProperty(i,"name",{value:e}),i}class Ra extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class PS extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const MS={};function Jo(e){return MS}function YF(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,s])=>t.indexOf(+r)===-1).map(([r,s])=>s)}function lh(e,t){return typeof t=="bigint"?t.toString():t}function Wm(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Zm(e){return e==null}function Gm(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function KF(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let s=(r.split(".")[1]||"").length;if(s===0&&/\d?e-\d?/.test(r)){const c=r.match(/\d?e-(\d?)/);c!=null&&c[1]&&(s=Number.parseInt(c[1]))}const a=n>s?n:s,i=Number.parseInt(e.toFixed(a).replace(".","")),l=Number.parseInt(t.toFixed(a).replace(".",""));return i%l/10**a}const $x=Symbol("evaluating");function Kt(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==$x)return r===void 0&&(r=$x,r=n()),r},set(s){Object.defineProperty(e,t,{value:s})},configurable:!0})}function oa(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function aa(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Ux(e){return JSON.stringify(e)}const DS="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ru(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const XF=Wm(()=>{var e;if(typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function rl(e){if(ru(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(ru(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function OS(e){return rl(e)?{...e}:Array.isArray(e)?[...e]:e}const JF=new Set(["string","number","symbol"]);function ei(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Eo(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function it(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function QF(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const e8={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function t8(e,t){const n=e._zod.def,r=aa(e._zod.def,{get shape(){const s={};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(s[a]=n.shape[a])}return oa(this,"shape",s),s},checks:[]});return Eo(e,r)}function n8(e,t){const n=e._zod.def,r=aa(e._zod.def,{get shape(){const s={...e._zod.def.shape};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete s[a]}return oa(this,"shape",s),s},checks:[]});return Eo(e,r)}function r8(e,t){if(!rl(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const s=aa(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return oa(this,"shape",a),a},checks:[]});return Eo(e,s)}function s8(e,t){if(!rl(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return oa(this,"shape",r),r},checks:e._zod.def.checks};return Eo(e,n)}function o8(e,t){const n=aa(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return oa(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return Eo(e,n)}function a8(e,t,n){const r=aa(t._zod.def,{get shape(){const s=t._zod.def.shape,a={...s};if(n)for(const i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(a[i]=e?new e({type:"optional",innerType:s[i]}):s[i])}else for(const i in s)a[i]=e?new e({type:"optional",innerType:s[i]}):s[i];return oa(this,"shape",a),a},checks:[]});return Eo(t,r)}function i8(e,t,n){const r=aa(t._zod.def,{get shape(){const s=t._zod.def.shape,a={...s};if(n)for(const i in n){if(!(i in a))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(a[i]=new e({type:"nonoptional",innerType:s[i]}))}else for(const i in s)a[i]=new e({type:"nonoptional",innerType:s[i]});return oa(this,"shape",a),a},checks:[]});return Eo(t,r)}function ka(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function LS(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function ic(e){return typeof e=="string"?e:e==null?void 0:e.message}function Qo(e,t,n){var s,a,i,l,c,u;const r={...e,path:e.path??[]};if(!e.message){const h=ic((i=(a=(s=e.inst)==null?void 0:s._zod.def)==null?void 0:a.error)==null?void 0:i.call(a,e))??ic((l=t==null?void 0:t.error)==null?void 0:l.call(t,e))??ic((c=n.customError)==null?void 0:c.call(n,e))??ic((u=n.localeError)==null?void 0:u.call(n,e))??"Invalid input";r.message=h}return delete r.inst,delete r.continue,t!=null&&t.reportInput||delete r.input,r}function qm(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function sl(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const FS=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,lh,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ym=ve("$ZodError",FS),Ku=ve("$ZodError",FS,{Parent:Error});function l8(e,t=n=>n.message){const n={},r=[];for(const s of e.issues)s.path.length>0?(n[s.path[0]]=n[s.path[0]]||[],n[s.path[0]].push(t(s))):r.push(t(s));return{formErrors:r,fieldErrors:n}}function c8(e,t=n=>n.message){const n={_errors:[]},r=s=>{for(const a of s.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(i=>r({issues:i}));else if(a.code==="invalid_key")r({issues:a.issues});else if(a.code==="invalid_element")r({issues:a.issues});else if(a.path.length===0)n._errors.push(t(a));else{let i=n,l=0;for(;l<a.path.length;){const c=a.path[l];l===a.path.length-1?(i[c]=i[c]||{_errors:[]},i[c]._errors.push(t(a))):i[c]=i[c]||{_errors:[]},i=i[c],l++}}};return r(e),n}const Xu=e=>(t,n,r,s)=>{const a=r?Object.assign(r,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},a);if(i instanceof Promise)throw new Ra;if(i.issues.length){const l=new((s==null?void 0:s.Err)??e)(i.issues.map(c=>Qo(c,a,Jo())));throw DS(l,s==null?void 0:s.callee),l}return i.value},u8=Xu(Ku),Ju=e=>async(t,n,r,s)=>{const a=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},a);if(i instanceof Promise&&(i=await i),i.issues.length){const l=new((s==null?void 0:s.Err)??e)(i.issues.map(c=>Qo(c,a,Jo())));throw DS(l,s==null?void 0:s.callee),l}return i.value},d8=Ju(Ku),Qu=e=>(t,n,r)=>{const s=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},s);if(a instanceof Promise)throw new Ra;return a.issues.length?{success:!1,error:new(e??Ym)(a.issues.map(i=>Qo(i,s,Jo())))}:{success:!0,data:a.value}},f8=Qu(Ku),ed=e=>async(t,n,r)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let a=t._zod.run({value:n,issues:[]},s);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(i=>Qo(i,s,Jo())))}:{success:!0,data:a.value}},h8=ed(Ku),m8=e=>(t,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Xu(e)(t,n,s)},p8=e=>(t,n,r)=>Xu(e)(t,n,r),g8=e=>async(t,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ju(e)(t,n,s)},x8=e=>async(t,n,r)=>Ju(e)(t,n,r),v8=e=>(t,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Qu(e)(t,n,s)},w8=e=>(t,n,r)=>Qu(e)(t,n,r),y8=e=>async(t,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ed(e)(t,n,s)},b8=e=>async(t,n,r)=>ed(e)(t,n,r),C8=/^[cC][^\s-]{8,}$/,S8=/^[0-9a-z]+$/,_8=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,k8=/^[0-9a-vA-V]{20}$/,j8=/^[A-Za-z0-9]{27}$/,E8=/^[a-zA-Z0-9_-]{21}$/,N8=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,T8=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Bx=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,A8=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,I8="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function R8(){return new RegExp(I8,"u")}const P8=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,M8=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,D8=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,O8=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,L8=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,zS=/^[A-Za-z0-9_-]*$/,F8=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,z8=/^\+(?:[0-9]){6,14}[0-9]$/,$S="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",$8=new RegExp(`^${$S}$`);function US(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function U8(e){return new RegExp(`^${US(e)}$`)}function B8(e){const t=US({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${$S}T(?:${r})$`)}const V8=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},H8=/^-?\d+$/,W8=/^-?\d+(?:\.\d+)?/,Z8=/^null$/i,G8=/^[^A-Z]*$/,q8=/^[^a-z]*$/,or=ve("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),BS={number:"number",bigint:"bigint",object:"date"},VS=ve("$ZodCheckLessThan",(e,t)=>{or.init(e,t);const n=BS[typeof t.value];e._zod.onattach.push(r=>{const s=r._zod.bag,a=(t.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<a&&(t.inclusive?s.maximum=t.value:s.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),HS=ve("$ZodCheckGreaterThan",(e,t)=>{or.init(e,t);const n=BS[typeof t.value];e._zod.onattach.push(r=>{const s=r._zod.bag,a=(t.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>a&&(t.inclusive?s.minimum=t.value:s.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Y8=ve("$ZodCheckMultipleOf",(e,t)=>{or.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):KF(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),K8=ve("$ZodCheckNumberFormat",(e,t)=>{var i;or.init(e,t),t.format=t.format||"float64";const n=(i=t.format)==null?void 0:i.includes("int"),r=n?"int":"number",[s,a]=e8[t.format];e._zod.onattach.push(l=>{const c=l._zod.bag;c.format=t.format,c.minimum=s,c.maximum=a,n&&(c.pattern=H8)}),e._zod.check=l=>{const c=l.value;if(n){if(!Number.isInteger(c)){l.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?l.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort}):l.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort});return}}c<s&&l.issues.push({origin:"number",input:c,code:"too_small",minimum:s,inclusive:!0,inst:e,continue:!t.abort}),c>a&&l.issues.push({origin:"number",input:c,code:"too_big",maximum:a,inst:e})}}),X8=ve("$ZodCheckMaxLength",(e,t)=>{var n;or.init(e,t),(n=e._zod.def).when??(n.when=r=>{const s=r.value;return!Zm(s)&&s.length!==void 0}),e._zod.onattach.push(r=>{const s=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<s&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const s=r.value;if(s.length<=t.maximum)return;const i=qm(s);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),J8=ve("$ZodCheckMinLength",(e,t)=>{var n;or.init(e,t),(n=e._zod.def).when??(n.when=r=>{const s=r.value;return!Zm(s)&&s.length!==void 0}),e._zod.onattach.push(r=>{const s=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>s&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const s=r.value;if(s.length>=t.minimum)return;const i=qm(s);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Q8=ve("$ZodCheckLengthEquals",(e,t)=>{var n;or.init(e,t),(n=e._zod.def).when??(n.when=r=>{const s=r.value;return!Zm(s)&&s.length!==void 0}),e._zod.onattach.push(r=>{const s=r._zod.bag;s.minimum=t.length,s.maximum=t.length,s.length=t.length}),e._zod.check=r=>{const s=r.value,a=s.length;if(a===t.length)return;const i=qm(s),l=a>t.length;r.issues.push({origin:i,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),td=ve("$ZodCheckStringFormat",(e,t)=>{var n,r;or.init(e,t),e._zod.onattach.push(s=>{const a=s._zod.bag;a.format=t.format,t.pattern&&(a.patterns??(a.patterns=new Set),a.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=s=>{t.pattern.lastIndex=0,!t.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:t.format,input:s.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),ez=ve("$ZodCheckRegex",(e,t)=>{td.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),tz=ve("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=G8),td.init(e,t)}),nz=ve("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=q8),td.init(e,t)}),rz=ve("$ZodCheckIncludes",(e,t)=>{or.init(e,t);const n=ei(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(s=>{const a=s._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(r)}),e._zod.check=s=>{s.value.includes(t.includes,t.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:s.value,inst:e,continue:!t.abort})}}),sz=ve("$ZodCheckStartsWith",(e,t)=>{or.init(e,t);const n=new RegExp(`^${ei(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),oz=ve("$ZodCheckEndsWith",(e,t)=>{or.init(e,t);const n=new RegExp(`.*${ei(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),az=ve("$ZodCheckOverwrite",(e,t)=>{or.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class iz{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
404
|
+
`).filter(i=>i),s=Math.min(...r.map(i=>i.length-i.trimStart().length)),a=r.map(i=>i.slice(s)).map(i=>" ".repeat(this.indent*2)+i);for(const i of a)this.content.push(i)}compile(){const t=Function,n=this==null?void 0:this.args,s=[...((this==null?void 0:this.content)??[""]).map(a=>` ${a}`)];return new t(...n,s.join(`
|
|
405
|
+
`))}}const lz={major:4,minor:1,patch:12},fn=ve("$ZodType",(e,t)=>{var s;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=lz;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const a of r)for(const i of a._zod.onattach)i(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),(s=e._zod.deferred)==null||s.push(()=>{e._zod.run=e._zod.parse});else{const a=(l,c,u)=>{let h=ka(l),f;for(const p of c){if(p._zod.def.when){if(!p._zod.def.when(l))continue}else if(h)continue;const m=l.issues.length,v=p._zod.check(l);if(v instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Ra;if(f||v instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await v,l.issues.length!==m&&(h||(h=ka(l,m)))});else{if(l.issues.length===m)continue;h||(h=ka(l,m))}}return f?f.then(()=>l):l},i=(l,c,u)=>{if(ka(l))return l.aborted=!0,l;const h=a(c,r,u);if(h instanceof Promise){if(u.async===!1)throw new Ra;return h.then(f=>e._zod.parse(f,u))}return e._zod.parse(h,u)};e._zod.run=(l,c)=>{if(c.skipChecks)return e._zod.parse(l,c);if(c.direction==="backward"){const h=e._zod.parse({value:l.value,issues:[]},{...c,skipChecks:!0});return h instanceof Promise?h.then(f=>i(f,l,c)):i(h,l,c)}const u=e._zod.parse(l,c);if(u instanceof Promise){if(c.async===!1)throw new Ra;return u.then(h=>a(h,r,c))}return a(u,r,c)}}e["~standard"]={validate:a=>{var i;try{const l=f8(e,a);return l.success?{value:l.data}:{issues:(i=l.error)==null?void 0:i.issues}}catch{return h8(e,a).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}}),Km=ve("$ZodString",(e,t)=>{var n;fn.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??V8(e._zod.bag),e._zod.parse=(r,s)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),tn=ve("$ZodStringFormat",(e,t)=>{td.init(e,t),Km.init(e,t)}),cz=ve("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=T8),tn.init(e,t)}),uz=ve("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Bx(r))}else t.pattern??(t.pattern=Bx());tn.init(e,t)}),dz=ve("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=A8),tn.init(e,t)}),fz=ve("$ZodURL",(e,t)=>{tn.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),s=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(s.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:F8.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=s.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),hz=ve("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=R8()),tn.init(e,t)}),mz=ve("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=E8),tn.init(e,t)}),pz=ve("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=C8),tn.init(e,t)}),gz=ve("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=S8),tn.init(e,t)}),xz=ve("$ZodULID",(e,t)=>{t.pattern??(t.pattern=_8),tn.init(e,t)}),vz=ve("$ZodXID",(e,t)=>{t.pattern??(t.pattern=k8),tn.init(e,t)}),wz=ve("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=j8),tn.init(e,t)}),yz=ve("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=B8(t)),tn.init(e,t)}),bz=ve("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=$8),tn.init(e,t)}),Cz=ve("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=U8(t)),tn.init(e,t)}),Sz=ve("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=N8),tn.init(e,t)}),_z=ve("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=P8),tn.init(e,t),e._zod.onattach.push(n=>{const r=n._zod.bag;r.format="ipv4"})}),kz=ve("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=M8),tn.init(e,t),e._zod.onattach.push(n=>{const r=n._zod.bag;r.format="ipv6"}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),jz=ve("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=D8),tn.init(e,t)}),Ez=ve("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=O8),tn.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[s,a]=r;if(!a)throw new Error;const i=Number(a);if(`${i}`!==a)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${s}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function WS(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Nz=ve("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=L8),tn.init(e,t),e._zod.onattach.push(n=>{n._zod.bag.contentEncoding="base64"}),e._zod.check=n=>{WS(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Tz(e){if(!zS.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return WS(n)}const Az=ve("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=zS),tn.init(e,t),e._zod.onattach.push(n=>{n._zod.bag.contentEncoding="base64url"}),e._zod.check=n=>{Tz(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Iz=ve("$ZodE164",(e,t)=>{t.pattern??(t.pattern=z8),tn.init(e,t)});function Rz(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const s=JSON.parse(atob(r));return!("typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||t&&(!("alg"in s)||s.alg!==t))}catch{return!1}}const Pz=ve("$ZodJWT",(e,t)=>{tn.init(e,t),e._zod.check=n=>{Rz(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),ZS=ve("$ZodNumber",(e,t)=>{fn.init(e,t),e._zod.pattern=e._zod.bag.pattern??W8,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const s=n.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return n;const a=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:s,inst:e,...a?{received:a}:{}}),n}}),Mz=ve("$ZodNumber",(e,t)=>{K8.init(e,t),ZS.init(e,t)}),Dz=ve("$ZodNull",(e,t)=>{fn.init(e,t),e._zod.pattern=Z8,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const s=n.value;return s===null||n.issues.push({expected:"null",code:"invalid_type",input:s,inst:e}),n}}),Oz=ve("$ZodUnknown",(e,t)=>{fn.init(e,t),e._zod.parse=n=>n}),Lz=ve("$ZodNever",(e,t)=>{fn.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Vx(e,t,n){e.issues.length&&t.issues.push(...LS(n,e.issues)),t.value[n]=e.value}const Fz=ve("$ZodArray",(e,t)=>{fn.init(e,t),e._zod.parse=(n,r)=>{const s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=Array(s.length);const a=[];for(let i=0;i<s.length;i++){const l=s[i],c=t.element._zod.run({value:l,issues:[]},r);c instanceof Promise?a.push(c.then(u=>Vx(u,n,i))):Vx(c,n,i)}return a.length?Promise.all(a).then(()=>n):n}});function su(e,t,n,r){e.issues.length&&t.issues.push(...LS(n,e.issues)),e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function GS(e){var r,s,a,i;const t=Object.keys(e.shape);for(const l of t)if(!((i=(a=(s=(r=e.shape)==null?void 0:r[l])==null?void 0:s._zod)==null?void 0:a.traits)!=null&&i.has("$ZodType")))throw new Error(`Invalid element at key "${l}": expected a Zod schema`);const n=QF(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function qS(e,t,n,r,s,a){const i=[],l=s.keySet,c=s.catchall._zod,u=c.def.type;for(const h of Object.keys(t)){if(l.has(h))continue;if(u==="never"){i.push(h);continue}const f=c.run({value:t[h],issues:[]},r);f instanceof Promise?e.push(f.then(p=>su(p,n,h,t))):su(f,n,h,t)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}const zz=ve("$ZodObject",(e,t)=>{fn.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const l=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...l};return Object.defineProperty(t,"shape",{value:c}),c}})}const r=Wm(()=>GS(t));Kt(e._zod,"propValues",()=>{const l=t.shape,c={};for(const u in l){const h=l[u]._zod;if(h.values){c[u]??(c[u]=new Set);for(const f of h.values)c[u].add(f)}}return c});const s=ru,a=t.catchall;let i;e._zod.parse=(l,c)=>{i??(i=r.value);const u=l.value;if(!s(u))return l.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),l;l.value={};const h=[],f=i.shape;for(const p of i.keys){const v=f[p]._zod.run({value:u[p],issues:[]},c);v instanceof Promise?h.push(v.then(g=>su(g,l,p,u))):su(v,l,p,u)}return a?qS(h,u,l,c,r.value,e):h.length?Promise.all(h).then(()=>l):l}}),$z=ve("$ZodObjectJIT",(e,t)=>{zz.init(e,t);const n=e._zod.parse,r=Wm(()=>GS(t)),s=p=>{const m=new iz(["shape","payload","ctx"]),v=r.value,g=C=>{const S=Ux(C);return`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`};m.write("const input = payload.value;");const x=Object.create(null);let w=0;for(const C of v.keys)x[C]=`key_${w++}`;m.write("const newResult = {};");for(const C of v.keys){const S=x[C],j=Ux(C);m.write(`const ${S} = ${g(C)};`),m.write(`
|
|
406
|
+
if (${S}.issues.length) {
|
|
407
|
+
payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
|
|
408
|
+
...iss,
|
|
409
|
+
path: iss.path ? [${j}, ...iss.path] : [${j}]
|
|
410
|
+
})));
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
if (${S}.value === undefined) {
|
|
415
|
+
if (${j} in input) {
|
|
416
|
+
newResult[${j}] = undefined;
|
|
417
|
+
}
|
|
418
|
+
} else {
|
|
419
|
+
newResult[${j}] = ${S}.value;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
`)}m.write("payload.value = newResult;"),m.write("return payload;");const y=m.compile();return(C,S)=>y(p,C,S)};let a;const i=ru,l=!MS.jitless,u=l&&XF.value,h=t.catchall;let f;e._zod.parse=(p,m)=>{f??(f=r.value);const v=p.value;return i(v)?l&&u&&(m==null?void 0:m.async)===!1&&m.jitless!==!0?(a||(a=s(t.shape)),p=a(p,m),h?qS([],v,p,m,f,e):p):n(p,m):(p.issues.push({expected:"object",code:"invalid_type",input:v,inst:e}),p)}});function Hx(e,t,n,r){for(const a of e)if(a.issues.length===0)return t.value=a.value,t;const s=e.filter(a=>!ka(a));return s.length===1?(t.value=s[0].value,s[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(a=>a.issues.map(i=>Qo(i,r,Jo())))}),t)}const Uz=ve("$ZodUnion",(e,t)=>{fn.init(e,t),Kt(e._zod,"optin",()=>t.options.some(s=>s._zod.optin==="optional")?"optional":void 0),Kt(e._zod,"optout",()=>t.options.some(s=>s._zod.optout==="optional")?"optional":void 0),Kt(e._zod,"values",()=>{if(t.options.every(s=>s._zod.values))return new Set(t.options.flatMap(s=>Array.from(s._zod.values)))}),Kt(e._zod,"pattern",()=>{if(t.options.every(s=>s._zod.pattern)){const s=t.options.map(a=>a._zod.pattern);return new RegExp(`^(${s.map(a=>Gm(a.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(s,a)=>{if(n)return r(s,a);let i=!1;const l=[];for(const c of t.options){const u=c._zod.run({value:s.value,issues:[]},a);if(u instanceof Promise)l.push(u),i=!0;else{if(u.issues.length===0)return u;l.push(u)}}return i?Promise.all(l).then(c=>Hx(c,s,e,a)):Hx(l,s,e,a)}}),Bz=ve("$ZodIntersection",(e,t)=>{fn.init(e,t),e._zod.parse=(n,r)=>{const s=n.value,a=t.left._zod.run({value:s,issues:[]},r),i=t.right._zod.run({value:s,issues:[]},r);return a instanceof Promise||i instanceof Promise?Promise.all([a,i]).then(([c,u])=>Wx(n,c,u)):Wx(n,a,i)}});function ch(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(rl(e)&&rl(t)){const n=Object.keys(t),r=Object.keys(e).filter(a=>n.indexOf(a)!==-1),s={...e,...t};for(const a of r){const i=ch(e[a],t[a]);if(!i.valid)return{valid:!1,mergeErrorPath:[a,...i.mergeErrorPath]};s[a]=i.data}return{valid:!0,data:s}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const s=e[r],a=t[r],i=ch(s,a);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Wx(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),ka(e))return e;const r=ch(t.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const Vz=ve("$ZodEnum",(e,t)=>{fn.init(e,t);const n=YF(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(s=>JF.has(typeof s)).map(s=>typeof s=="string"?ei(s):s.toString()).join("|")})$`),e._zod.parse=(s,a)=>{const i=s.value;return r.has(i)||s.issues.push({code:"invalid_value",values:n,input:i,inst:e}),s}}),Hz=ve("$ZodLiteral",(e,t)=>{if(fn.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?ei(n):n?ei(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,r)=>{const s=n.value;return e._zod.values.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}}),Wz=ve("$ZodTransform",(e,t)=>{fn.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new PS(e.constructor.name);const s=t.transform(n.value,n);if(r.async)return(s instanceof Promise?s:Promise.resolve(s)).then(i=>(n.value=i,n));if(s instanceof Promise)throw new Ra;return n.value=s,n}});function Zx(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Zz=ve("$ZodOptional",(e,t)=>{fn.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Kt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Kt(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Gm(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(a=>Zx(a,n.value)):Zx(s,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),Gz=ve("$ZodNullable",(e,t)=>{fn.init(e,t),Kt(e._zod,"optin",()=>t.innerType._zod.optin),Kt(e._zod,"optout",()=>t.innerType._zod.optout),Kt(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Gm(n.source)}|null)$`):void 0}),Kt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),qz=ve("$ZodDefault",(e,t)=>{fn.init(e,t),e._zod.optin="optional",Kt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(a=>Gx(a,t)):Gx(s,t)}});function Gx(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Yz=ve("$ZodPrefault",(e,t)=>{fn.init(e,t),e._zod.optin="optional",Kt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),Kz=ve("$ZodNonOptional",(e,t)=>{fn.init(e,t),Kt(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(a=>qx(a,e)):qx(s,e)}});function qx(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Xz=ve("$ZodCatch",(e,t)=>{fn.init(e,t),Kt(e._zod,"optin",()=>t.innerType._zod.optin),Kt(e._zod,"optout",()=>t.innerType._zod.optout),Kt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(a=>(n.value=a.value,a.issues.length&&(n.value=t.catchValue({...n,error:{issues:a.issues.map(i=>Qo(i,r,Jo()))},input:n.value}),n.issues=[]),n)):(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(a=>Qo(a,r,Jo()))},input:n.value}),n.issues=[]),n)}}),Jz=ve("$ZodPipe",(e,t)=>{fn.init(e,t),Kt(e._zod,"values",()=>t.in._zod.values),Kt(e._zod,"optin",()=>t.in._zod.optin),Kt(e._zod,"optout",()=>t.out._zod.optout),Kt(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const a=t.out._zod.run(n,r);return a instanceof Promise?a.then(i=>lc(i,t.in,r)):lc(a,t.in,r)}const s=t.in._zod.run(n,r);return s instanceof Promise?s.then(a=>lc(a,t.out,r)):lc(s,t.out,r)}});function lc(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Qz=ve("$ZodReadonly",(e,t)=>{fn.init(e,t),Kt(e._zod,"propValues",()=>t.innerType._zod.propValues),Kt(e._zod,"values",()=>t.innerType._zod.values),Kt(e._zod,"optin",()=>t.innerType._zod.optin),Kt(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(Yx):Yx(s)}});function Yx(e){return e.value=Object.freeze(e.value),e}const e$=ve("$ZodCustom",(e,t)=>{or.init(e,t),fn.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,s=t.fn(r);if(s instanceof Promise)return s.then(a=>Kx(a,n,r,e));Kx(s,n,r,e)}});function Kx(e,t,n,r){if(!e){const s={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(s.params=r._zod.def.params),t.issues.push(sl(s))}}class t${constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];if(this._map.set(t,r),r&&typeof r=="object"&&"id"in r){if(this._idmap.has(r.id))throw new Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,t)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const s={...r,...this._map.get(t)};return Object.keys(s).length?s:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function n$(){return new t$}const cc=n$();function r$(e,t){return new e({type:"string",...it(t)})}function s$(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...it(t)})}function Xx(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...it(t)})}function o$(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...it(t)})}function a$(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...it(t)})}function i$(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...it(t)})}function l$(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...it(t)})}function c$(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...it(t)})}function u$(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...it(t)})}function d$(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...it(t)})}function f$(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...it(t)})}function h$(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...it(t)})}function m$(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...it(t)})}function p$(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...it(t)})}function g$(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...it(t)})}function x$(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...it(t)})}function v$(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...it(t)})}function w$(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...it(t)})}function y$(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...it(t)})}function b$(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...it(t)})}function C$(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...it(t)})}function S$(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...it(t)})}function _$(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...it(t)})}function k$(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...it(t)})}function j$(e,t){return new e({type:"string",format:"date",check:"string_format",...it(t)})}function E$(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...it(t)})}function N$(e,t){return new e({type:"string",format:"duration",check:"string_format",...it(t)})}function T$(e,t){return new e({type:"number",checks:[],...it(t)})}function A$(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...it(t)})}function I$(e,t){return new e({type:"null",...it(t)})}function R$(e){return new e({type:"unknown"})}function P$(e,t){return new e({type:"never",...it(t)})}function Jx(e,t){return new VS({check:"less_than",...it(t),value:e,inclusive:!1})}function Xd(e,t){return new VS({check:"less_than",...it(t),value:e,inclusive:!0})}function Qx(e,t){return new HS({check:"greater_than",...it(t),value:e,inclusive:!1})}function Jd(e,t){return new HS({check:"greater_than",...it(t),value:e,inclusive:!0})}function ev(e,t){return new Y8({check:"multiple_of",...it(t),value:e})}function YS(e,t){return new X8({check:"max_length",...it(t),maximum:e})}function ou(e,t){return new J8({check:"min_length",...it(t),minimum:e})}function KS(e,t){return new Q8({check:"length_equals",...it(t),length:e})}function M$(e,t){return new ez({check:"string_format",format:"regex",...it(t),pattern:e})}function D$(e){return new tz({check:"string_format",format:"lowercase",...it(e)})}function O$(e){return new nz({check:"string_format",format:"uppercase",...it(e)})}function L$(e,t){return new rz({check:"string_format",format:"includes",...it(t),includes:e})}function F$(e,t){return new sz({check:"string_format",format:"starts_with",...it(t),prefix:e})}function z$(e,t){return new oz({check:"string_format",format:"ends_with",...it(t),suffix:e})}function Pl(e){return new az({check:"overwrite",tx:e})}function $$(e){return Pl(t=>t.normalize(e))}function U$(){return Pl(e=>e.trim())}function B$(){return Pl(e=>e.toLowerCase())}function V$(){return Pl(e=>e.toUpperCase())}function H$(e,t,n){return new e({type:"array",element:t,...it(n)})}function W$(e,t,n){return new e({type:"custom",check:"custom",fn:t,...it(n)})}function Z$(e){const t=G$(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(sl(r,n.value,t._zod.def));else{const s=r;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=t),s.continue??(s.continue=!t._zod.def.abort),n.issues.push(sl(s))}},e(n.value,n)));return t}function G$(e,t){const n=new or({check:"custom",...it(t)});return n._zod.check=e,n}function tv(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}function q$(e,t){for(var n={};e.length;){var r=e[0],s=r.code,a=r.message,i=r.path.join(".");if(!n[i])if("unionErrors"in r){var l=r.unionErrors[0].errors[0];n[i]={message:l.message,type:l.code}}else n[i]={message:a,type:s};if("unionErrors"in r&&r.unionErrors.forEach(function(h){return h.errors.forEach(function(f){return e.push(f)})}),t){var c=n[i].types,u=c&&c[r.code];n[i]=rm(i,t,n,s,u?[].concat(u,r.message):r.message)}e.shift()}return n}function Y$(e,t){for(var n={};e.length;){var r=e[0],s=r.code,a=r.message,i=r.path.join(".");if(!n[i])if(r.code==="invalid_union"&&r.errors.length>0){var l=r.errors[0][0];n[i]={message:l.message,type:l.code}}else n[i]={message:a,type:s};if(r.code==="invalid_union"&&r.errors.forEach(function(h){return h.forEach(function(f){return e.push(f)})}),t){var c=n[i].types,u=c&&c[r.code];n[i]=rm(i,t,n,s,u?[].concat(u,r.message):r.message)}e.shift()}return n}function K$(e,t,n){if(n===void 0&&(n={}),function(r){return"_def"in r&&typeof r._def=="object"&&"typeName"in r._def}(e))return function(r,s,a){try{return Promise.resolve(tv(function(){return Promise.resolve(e[n.mode==="sync"?"parse":"parseAsync"](r,t)).then(function(i){return a.shouldUseNativeValidation&&ih({},a),{errors:{},values:n.raw?Object.assign({},r):i}})},function(i){if(function(l){return Array.isArray(l==null?void 0:l.issues)}(i))return{values:{},errors:Fx(q$(i.errors,!a.shouldUseNativeValidation&&a.criteriaMode==="all"),a)};throw i}))}catch(i){return Promise.reject(i)}};if(function(r){return"_zod"in r&&typeof r._zod=="object"}(e))return function(r,s,a){try{return Promise.resolve(tv(function(){return Promise.resolve((n.mode==="sync"?u8:d8)(e,r,t)).then(function(i){return a.shouldUseNativeValidation&&ih({},a),{errors:{},values:n.raw?Object.assign({},r):i}})},function(i){if(function(l){return l instanceof Ym}(i))return{values:{},errors:Fx(Y$(i.issues,!a.shouldUseNativeValidation&&a.criteriaMode==="all"),a)};throw i}))}catch(i){return Promise.reject(i)}};throw new Error("Invalid input: not a Zod schema")}const X$=ve("ZodISODateTime",(e,t)=>{yz.init(e,t),an.init(e,t)});function J$(e){return k$(X$,e)}const Q$=ve("ZodISODate",(e,t)=>{bz.init(e,t),an.init(e,t)});function e9(e){return j$(Q$,e)}const t9=ve("ZodISOTime",(e,t)=>{Cz.init(e,t),an.init(e,t)});function n9(e){return E$(t9,e)}const r9=ve("ZodISODuration",(e,t)=>{Sz.init(e,t),an.init(e,t)});function s9(e){return N$(r9,e)}const o9=(e,t)=>{Ym.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>c8(e,n)},flatten:{value:n=>l8(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,lh,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,lh,2)}},isEmpty:{get(){return e.issues.length===0}}})},Pr=ve("ZodError",o9,{Parent:Error}),a9=Xu(Pr),i9=Ju(Pr),l9=Qu(Pr),c9=ed(Pr),u9=m8(Pr),d9=p8(Pr),f9=g8(Pr),h9=x8(Pr),m9=v8(Pr),p9=w8(Pr),g9=y8(Pr),x9=b8(Pr),mn=ve("ZodType",(e,t)=>(fn.init(e,t),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(aa(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]})),e.clone=(n,r)=>Eo(e,n,r),e.brand=()=>e,e.register=(n,r)=>(n.add(e,r),e),e.parse=(n,r)=>a9(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>l9(e,n,r),e.parseAsync=async(n,r)=>i9(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>c9(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>u9(e,n,r),e.decode=(n,r)=>d9(e,n,r),e.encodeAsync=async(n,r)=>f9(e,n,r),e.decodeAsync=async(n,r)=>h9(e,n,r),e.safeEncode=(n,r)=>m9(e,n,r),e.safeDecode=(n,r)=>p9(e,n,r),e.safeEncodeAsync=async(n,r)=>g9(e,n,r),e.safeDecodeAsync=async(n,r)=>x9(e,n,r),e.refine=(n,r)=>e.check(c7(n,r)),e.superRefine=n=>e.check(u7(n)),e.overwrite=n=>e.check(Pl(n)),e.optional=()=>ov(e),e.nullable=()=>av(e),e.nullish=()=>ov(av(e)),e.nonoptional=n=>n7(e,n),e.array=()=>B9(e),e.or=n=>nd([e,n]),e.and=n=>Z9(e,n),e.transform=n=>iv(e,K9(n)),e.default=n=>Q9(e,n),e.prefault=n=>t7(e,n),e.catch=n=>s7(e,n),e.pipe=n=>iv(e,n),e.readonly=()=>i7(e),e.describe=n=>{const r=e.clone();return cc.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){var n;return(n=cc.get(e))==null?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return cc.get(e);const r=e.clone();return cc.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),XS=ve("_ZodString",(e,t)=>{Km.init(e,t),mn.init(e,t);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(M$(...r)),e.includes=(...r)=>e.check(L$(...r)),e.startsWith=(...r)=>e.check(F$(...r)),e.endsWith=(...r)=>e.check(z$(...r)),e.min=(...r)=>e.check(ou(...r)),e.max=(...r)=>e.check(YS(...r)),e.length=(...r)=>e.check(KS(...r)),e.nonempty=(...r)=>e.check(ou(1,...r)),e.lowercase=r=>e.check(D$(r)),e.uppercase=r=>e.check(O$(r)),e.trim=()=>e.check(U$()),e.normalize=(...r)=>e.check($$(...r)),e.toLowerCase=()=>e.check(B$()),e.toUpperCase=()=>e.check(V$())}),v9=ve("ZodString",(e,t)=>{Km.init(e,t),XS.init(e,t),e.email=n=>e.check(s$(w9,n)),e.url=n=>e.check(c$(y9,n)),e.jwt=n=>e.check(_$(D9,n)),e.emoji=n=>e.check(u$(b9,n)),e.guid=n=>e.check(Xx(nv,n)),e.uuid=n=>e.check(o$(uc,n)),e.uuidv4=n=>e.check(a$(uc,n)),e.uuidv6=n=>e.check(i$(uc,n)),e.uuidv7=n=>e.check(l$(uc,n)),e.nanoid=n=>e.check(d$(C9,n)),e.guid=n=>e.check(Xx(nv,n)),e.cuid=n=>e.check(f$(S9,n)),e.cuid2=n=>e.check(h$(_9,n)),e.ulid=n=>e.check(m$(k9,n)),e.base64=n=>e.check(b$(R9,n)),e.base64url=n=>e.check(C$(P9,n)),e.xid=n=>e.check(p$(j9,n)),e.ksuid=n=>e.check(g$(E9,n)),e.ipv4=n=>e.check(x$(N9,n)),e.ipv6=n=>e.check(v$(T9,n)),e.cidrv4=n=>e.check(w$(A9,n)),e.cidrv6=n=>e.check(y$(I9,n)),e.e164=n=>e.check(S$(M9,n)),e.datetime=n=>e.check(J$(n)),e.date=n=>e.check(e9(n)),e.time=n=>e.check(n9(n)),e.duration=n=>e.check(s9(n))});function ea(e){return r$(v9,e)}const an=ve("ZodStringFormat",(e,t)=>{tn.init(e,t),XS.init(e,t)}),w9=ve("ZodEmail",(e,t)=>{dz.init(e,t),an.init(e,t)}),nv=ve("ZodGUID",(e,t)=>{cz.init(e,t),an.init(e,t)}),uc=ve("ZodUUID",(e,t)=>{uz.init(e,t),an.init(e,t)}),y9=ve("ZodURL",(e,t)=>{fz.init(e,t),an.init(e,t)}),b9=ve("ZodEmoji",(e,t)=>{hz.init(e,t),an.init(e,t)}),C9=ve("ZodNanoID",(e,t)=>{mz.init(e,t),an.init(e,t)}),S9=ve("ZodCUID",(e,t)=>{pz.init(e,t),an.init(e,t)}),_9=ve("ZodCUID2",(e,t)=>{gz.init(e,t),an.init(e,t)}),k9=ve("ZodULID",(e,t)=>{xz.init(e,t),an.init(e,t)}),j9=ve("ZodXID",(e,t)=>{vz.init(e,t),an.init(e,t)}),E9=ve("ZodKSUID",(e,t)=>{wz.init(e,t),an.init(e,t)}),N9=ve("ZodIPv4",(e,t)=>{_z.init(e,t),an.init(e,t)}),T9=ve("ZodIPv6",(e,t)=>{kz.init(e,t),an.init(e,t)}),A9=ve("ZodCIDRv4",(e,t)=>{jz.init(e,t),an.init(e,t)}),I9=ve("ZodCIDRv6",(e,t)=>{Ez.init(e,t),an.init(e,t)}),R9=ve("ZodBase64",(e,t)=>{Nz.init(e,t),an.init(e,t)}),P9=ve("ZodBase64URL",(e,t)=>{Az.init(e,t),an.init(e,t)}),M9=ve("ZodE164",(e,t)=>{Iz.init(e,t),an.init(e,t)}),D9=ve("ZodJWT",(e,t)=>{Pz.init(e,t),an.init(e,t)}),JS=ve("ZodNumber",(e,t)=>{ZS.init(e,t),mn.init(e,t),e.gt=(r,s)=>e.check(Qx(r,s)),e.gte=(r,s)=>e.check(Jd(r,s)),e.min=(r,s)=>e.check(Jd(r,s)),e.lt=(r,s)=>e.check(Jx(r,s)),e.lte=(r,s)=>e.check(Xd(r,s)),e.max=(r,s)=>e.check(Xd(r,s)),e.int=r=>e.check(rv(r)),e.safe=r=>e.check(rv(r)),e.positive=r=>e.check(Qx(0,r)),e.nonnegative=r=>e.check(Jd(0,r)),e.negative=r=>e.check(Jx(0,r)),e.nonpositive=r=>e.check(Xd(0,r)),e.multipleOf=(r,s)=>e.check(ev(r,s)),e.step=(r,s)=>e.check(ev(r,s)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function uh(e){return T$(JS,e)}const O9=ve("ZodNumberFormat",(e,t)=>{Mz.init(e,t),JS.init(e,t)});function rv(e){return A$(O9,e)}const L9=ve("ZodNull",(e,t)=>{Dz.init(e,t),mn.init(e,t)});function Xm(e){return I$(L9,e)}const F9=ve("ZodUnknown",(e,t)=>{Oz.init(e,t),mn.init(e,t)});function sv(){return R$(F9)}const z9=ve("ZodNever",(e,t)=>{Lz.init(e,t),mn.init(e,t)});function $9(e){return P$(z9,e)}const U9=ve("ZodArray",(e,t)=>{Fz.init(e,t),mn.init(e,t),e.element=t.element,e.min=(n,r)=>e.check(ou(n,r)),e.nonempty=n=>e.check(ou(1,n)),e.max=(n,r)=>e.check(YS(n,r)),e.length=(n,r)=>e.check(KS(n,r)),e.unwrap=()=>e.element});function B9(e,t){return H$(U9,e,t)}const V9=ve("ZodObject",(e,t)=>{$z.init(e,t),mn.init(e,t),Kt(e,"shape",()=>t.shape),e.keyof=()=>G9(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:sv()}),e.loose=()=>e.clone({...e._zod.def,catchall:sv()}),e.strict=()=>e.clone({...e._zod.def,catchall:$9()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>r8(e,n),e.safeExtend=n=>s8(e,n),e.merge=n=>o8(e,n),e.pick=n=>t8(e,n),e.omit=n=>n8(e,n),e.partial=(...n)=>a8(QS,e,n[0]),e.required=(...n)=>i8(e_,e,n[0])});function Ml(e,t){const n={type:"object",shape:e??{},...it(t)};return new V9(n)}const H9=ve("ZodUnion",(e,t)=>{Uz.init(e,t),mn.init(e,t),e.options=t.options});function nd(e,t){return new H9({type:"union",options:e,...it(t)})}const W9=ve("ZodIntersection",(e,t)=>{Bz.init(e,t),mn.init(e,t)});function Z9(e,t){return new W9({type:"intersection",left:e,right:t})}const dh=ve("ZodEnum",(e,t)=>{Vz.init(e,t),mn.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,s)=>{const a={};for(const i of r)if(n.has(i))a[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new dh({...t,checks:[],...it(s),entries:a})},e.exclude=(r,s)=>{const a={...t.entries};for(const i of r)if(n.has(i))delete a[i];else throw new Error(`Key ${i} not found in enum`);return new dh({...t,checks:[],...it(s),entries:a})}});function G9(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new dh({type:"enum",entries:n,...it(t)})}const q9=ve("ZodLiteral",(e,t)=>{Hz.init(e,t),mn.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Jm(e,t){return new q9({type:"literal",values:Array.isArray(e)?e:[e],...it(t)})}const Y9=ve("ZodTransform",(e,t)=>{Wz.init(e,t),mn.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new PS(e.constructor.name);n.addIssue=a=>{if(typeof a=="string")n.issues.push(sl(a,n.value,t));else{const i=a;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(sl(i))}};const s=t.transform(n.value,n);return s instanceof Promise?s.then(a=>(n.value=a,n)):(n.value=s,n)}});function K9(e){return new Y9({type:"transform",transform:e})}const QS=ve("ZodOptional",(e,t)=>{Zz.init(e,t),mn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ov(e){return new QS({type:"optional",innerType:e})}const X9=ve("ZodNullable",(e,t)=>{Gz.init(e,t),mn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function av(e){return new X9({type:"nullable",innerType:e})}const J9=ve("ZodDefault",(e,t)=>{qz.init(e,t),mn.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Q9(e,t){return new J9({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():OS(t)}})}const e7=ve("ZodPrefault",(e,t)=>{Yz.init(e,t),mn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function t7(e,t){return new e7({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():OS(t)}})}const e_=ve("ZodNonOptional",(e,t)=>{Kz.init(e,t),mn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function n7(e,t){return new e_({type:"nonoptional",innerType:e,...it(t)})}const r7=ve("ZodCatch",(e,t)=>{Xz.init(e,t),mn.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function s7(e,t){return new r7({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const o7=ve("ZodPipe",(e,t)=>{Jz.init(e,t),mn.init(e,t),e.in=t.in,e.out=t.out});function iv(e,t){return new o7({type:"pipe",in:e,out:t})}const a7=ve("ZodReadonly",(e,t)=>{Qz.init(e,t),mn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function i7(e){return new a7({type:"readonly",innerType:e})}const l7=ve("ZodCustom",(e,t)=>{e$.init(e,t),mn.init(e,t)});function c7(e,t={}){return W$(l7,e,t)}function u7(e){return Z$(e)}const rn={NAME_MAX:255,DESCRIPTION_MAX:1e3,TAG_MAX:100,COMMAND_MAX:50,PROMPT_TEXT_MAX:1e4},d7=Ml({authorName:nd([ea(),Xm()]).optional(),originalVersion:uh().int().positive(),originalCreatedAt:uh().int().positive()}),Qd=()=>nd([ea(),Xm()]).optional(),f7=Ml({name:ea().min(1,"Name is required"),description:Qd(),category:Qd(),command:Qd(),promptText:ea().min(1,"Prompt text is required"),metadata:nd([d7,Xm()]).optional()}),h7=Ml({version:Jm("1.0",{message:"Unsupported export format version. Only version 1.0 is currently supported."}),exportedAt:uh().int().positive("Export timestamp must be a valid positive number"),prompt:f7});Ml({command:ea().max(rn.COMMAND_MAX,`Command must be ${rn.COMMAND_MAX} characters or less`).optional().or(Jm(""))});function m7(e){const t=[],n=e.prompt;return n.name&&n.name.length>rn.NAME_MAX&&t.push({field:"Name",currentLength:n.name.length,maxLength:rn.NAME_MAX,message:`Name will be truncated from ${n.name.length} to ${rn.NAME_MAX} characters`}),n.description&&n.description.length>rn.DESCRIPTION_MAX&&t.push({field:"Description",currentLength:n.description.length,maxLength:rn.DESCRIPTION_MAX,message:`Description will be truncated from ${n.description.length} to ${rn.DESCRIPTION_MAX} characters`}),n.category&&n.category.length>rn.TAG_MAX&&t.push({field:"Tag",currentLength:n.category.length,maxLength:rn.TAG_MAX,message:`Tag will be truncated from ${n.category.length} to ${rn.TAG_MAX} characters`}),n.command&&n.command.length>rn.COMMAND_MAX&&t.push({field:"Command",currentLength:n.command.length,maxLength:rn.COMMAND_MAX,message:`Command will be truncated from ${n.command.length} to ${rn.COMMAND_MAX} characters`}),n.promptText&&n.promptText.length>rn.PROMPT_TEXT_MAX&&t.push({field:"Prompt text",currentLength:n.promptText.length,maxLength:rn.PROMPT_TEXT_MAX,message:`Prompt text will be truncated from ${n.promptText.length.toLocaleString()} to ${rn.PROMPT_TEXT_MAX.toLocaleString()} characters`}),t}function p7(e){return e.issues.map(t=>{const n=t.path.join(".");return n?`${n}: ${t.message}`:t.message})}function g7(e,t){return e.issues.some(n=>n.path.includes(t))}function x7(e,t){const n=e.issues.find(r=>r.path.includes(t));return n==null?void 0:n.message}const v7=Ml({name:ea().min(1,"Name is required").max(rn.NAME_MAX,`Name must be ${rn.NAME_MAX} characters or less`),command:ea().max(rn.COMMAND_MAX,`Chat shortcut must be ${rn.COMMAND_MAX} characters or less`).optional().or(Jm(""))}),w7=({open:e,onOpenChange:t,onImport:n,existingPrompts:r})=>{var H;const[s,a]=d.useState(null),[i,l]=d.useState(null),[c,u]=d.useState(null),[h,f]=d.useState([]),[p,m]=d.useState([]),[v,g]=d.useState(!1),[x,w]=d.useState(!1),[y,C]=d.useState(!1),{register:S,handleSubmit:j,formState:{errors:I},reset:b,setValue:k,watch:N}=SA({resolver:K$(v7),defaultValues:{name:"",command:""},mode:"onChange"}),A=N("name"),P=N("command"),E=d.useCallback((Q,z)=>{var fe,ge;const Z=Q.trim().toLowerCase(),J=z.trim().toLowerCase();let ce=!1,de=!1;for(const T of r)Z&&((fe=T.name)==null?void 0:fe.toLowerCase())===Z&&(ce=!0),J&&((ge=T.command)==null?void 0:ge.toLowerCase())===J&&(de=!0);return{hasNameConflict:ce,hasCommandConflict:de}},[r]),R=d.useMemo(()=>i?E(A||"",P||""):{hasNameConflict:!1,hasCommandConflict:!1},[i,A,P,E]),_=R.hasNameConflict||R.hasCommandConflict,M=d.useCallback(async Q=>{if(u(null),f([]),m([]),l(null),!Q.name.endsWith(".json"))return u("Please select a JSON file"),null;if(Q.size>1024*1024)return u("File size must be less than 1MB"),null;try{const z=await Q.text();let Z;try{Z=JSON.parse(z)}catch{return u("Failed to parse JSON file. Please ensure it's a valid JSON format."),null}const J=h7.safeParse(Z);if(!J.success){const de=p7(J.error);if(g7(J.error,"version")){const fe=x7(J.error,"version");u(fe||"Invalid version format")}else de.length===1?u(de[0]):(u("The imported prompt has validation errors:"),f(de));return null}const ce=m7(J.data);return m(ce),J.data}catch{return u("Failed to read file. Please try again."),null}},[]),L=d.useCallback(Q=>{const z=Q.prompt.name||"",Z=Q.prompt.command||"",J=E(z,Z);w(J.hasNameConflict),C(J.hasCommandConflict)},[E]),F=async Q=>{if(a(Q),Q&&Q[0]){const z=await M(Q[0]);z&&(l(z),k("name",z.prompt.name||""),k("command",z.prompt.command||""),L(z))}else l(null),b()},D=Q=>{const z=Q[0];return z.name.endsWith(".json")?z.size>1024*1024?{valid:!1,error:"File size must be less than 1MB"}:{valid:!0}:{valid:!1,error:"Please select a JSON file"}},O=async Q=>{if(!i){u("Please select a JSON file to import");return}if(!_){g(!0),u(null);try{const z={...i,prompt:{...i.prompt,name:Q.name,command:Q.command||void 0}};await n(z,{preserveCommand:!!Q.command,preserveCategory:!0}),$()}catch(z){throw u(z instanceof Error?z.message:"Failed to import prompt"),z}finally{g(!1)}}},K=async()=>{await j(O)()},$=()=>{a(null),l(null),u(null),f([]),m([]),w(!1),C(!1),b()},W=()=>{v||($(),t(!1))},V=()=>{v||W()},X=o.jsxs("div",{className:"mt-2 py-2",children:[o.jsx(Rm,{name:"promptFile",accept:".json",multiple:!1,disabled:v,value:s,onChange:F,onValidate:D}),c&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(Xt,{variant:"error",message:c}),h.length>0&&o.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 p-3 dark:border-red-800 dark:bg-red-950/30",children:o.jsx("ul",{className:"list-inside list-disc space-y-1 text-sm text-red-800 dark:text-red-200",children:h.map((Q,z)=>o.jsx("li",{children:Q},z))})})]}),i&&!c&&o.jsxs("div",{className:"mt-2 py-2",children:[p.length>0&&!_&&o.jsx(Xt,{variant:"warning",message:o.jsxs("div",{className:"space-y-2",children:[o.jsx("p",{className:"font-medium",children:"Some fields exceed the maximum length and will be truncated:"}),o.jsx("ul",{className:"list-inside list-disc space-y-1 text-sm",children:p.map((Q,z)=>o.jsx("li",{children:Q.message},z))})]})}),o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsx("h3",{className:"text-sm font-semibold",children:"Review Prompt"}),o.jsxs("div",{className:"space-y-1",children:[o.jsxs(zt,{htmlFor:"import-name",className:"text-muted-foreground text-xs",children:["Name",R.hasNameConflict&&o.jsx("span",{className:"text-destructive",children:"*"})]}),x?o.jsxs("div",{className:"space-y-2",children:[o.jsx(_r,{id:"import-name",...S("name"),className:`${I.name||R.hasNameConflict?"border-(--color-error-w100)":""}`,maxLength:rn.NAME_MAX}),R.hasNameConflict&&!I.name&&o.jsx(tc,{message:"Conflict: Already exists. Change name."}),I.name&&o.jsx(tc,{message:I.name.message})]}):o.jsx("p",{className:"overflow-wrap-anywhere text-sm break-words",children:A})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(zt,{className:"text-muted-foreground text-xs",children:"Description"}),i.prompt.description?o.jsx("p",{className:"overflow-wrap-anywhere text-sm break-words",children:i.prompt.description}):o.jsx("p",{className:"text-muted-foreground text-sm italic",children:"No description"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(zt,{className:"text-muted-foreground text-xs",children:"Tag"}),i.prompt.category?o.jsx("p",{className:"overflow-wrap-anywhere text-sm break-words",children:i.prompt.category}):o.jsx("p",{className:"text-muted-foreground text-sm italic",children:"No tag"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsxs(zt,{htmlFor:"import-command",className:"text-muted-foreground text-xs",children:["Chat Shortcut",R.hasCommandConflict&&o.jsx("span",{className:"text-destructive",children:"*"})]}),y?o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-muted-foreground text-sm",children:"/"}),o.jsx(_r,{id:"import-command",...S("command"),placeholder:"e.g., code-review",className:`flex-1 ${I.command||R.hasCommandConflict?"border-(--color-error-w100)":""}`,maxLength:rn.COMMAND_MAX})]}),R.hasCommandConflict&&!I.command&&o.jsx(tc,{message:"Conflict: Already exists. Change chat shortcut."}),I.command&&o.jsx(tc,{message:I.command.message})]}):P?o.jsx("p",{className:"font-mono text-sm break-all",children:P}):o.jsx("p",{className:"text-muted-foreground text-sm italic",children:"No chat shortcut"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(zt,{className:"text-muted-foreground text-xs",children:"Original Author"}),(H=i.prompt.metadata)!=null&&H.authorName?o.jsx("p",{className:"overflow-wrap-anywhere text-sm break-words",children:i.prompt.metadata.authorName}):o.jsx("p",{className:"text-muted-foreground text-sm italic",children:"No author"})]})]})]})]});return o.jsx(Rr,{open:e,onOpenChange:Q=>!Q&&W(),title:"Import Prompt",description:"Import a prompt from an exported prompt JSON file.",content:X,actionLabels:{confirm:"Import",cancel:"Cancel"},onConfirm:K,onCancel:V,isLoading:v,isEnabled:!!i&&!_})},dc=()=>{var Z;const e=bo(),t=es(),n=gw(),{addNotification:r,displayError:s}=$t(),[a,i]=d.useState([]),[l,c]=d.useState(!1),[u,h]=d.useState(!1),[f,p]=d.useState(!1),[m,v]=d.useState(null),[g,x]=d.useState(null),[w,y]=d.useState("ai-assisted"),[C,S]=d.useState(0),[j,I]=d.useState(null),[b,k]=d.useState(null),[N,A]=d.useState(null),[P,E]=d.useState(!1),[R,_]=d.useState(null),[M,L]=d.useState(!1),F=d.useCallback(async()=>{c(!0);try{const J=await Ie.webui.get("/api/v1/prompts/groups/all");i(J)}catch(J){s({title:"Failed to Load Prompts",error:Zt(J,"An error occurred while fetching prompt groups.")})}finally{c(!1)}},[s]);d.useEffect(()=>{F()},[F]),d.useEffect(()=>{var J;if((n==null?void 0:n.view)==="builder")if(n.mode==="edit"&&n.promptId)(async()=>{try{const de=await Ie.webui.get(`/api/v1/prompts/groups/${n.promptId}`);x(de),y("ai-assisted"),h(!0)}catch(de){s({title:"Failed to Edit Prompt",error:Zt(de,"An error occurred while fetching prompt.")})}})();else{x(null);const ce=n.mode==="ai-assisted"?"ai-assisted":"manual";y(ce),ce==="ai-assisted"&&((J=t.state)!=null&&J.taskDescription)?v(t.state.taskDescription):v(null),S(de=>de+1),h(!0)}else(n==null?void 0:n.view)==="versions"&&n.promptId?(async()=>{try{const de=await Ie.webui.get(`/api/v1/prompts/groups/${n.promptId}`);I(de)}catch(de){s({title:"Failed to View Versions",error:Zt(de,"An error occurred while fetching versions.")})}})():(h(!1),I(null),x(null))},[n,(Z=t.state)==null?void 0:Z.taskDescription,s]);const D=(J,ce)=>{k({id:J,name:ce})},O=async()=>{if(b)try{await Ie.webui.delete(`/api/v1/prompts/groups/${b.id}`),(j==null?void 0:j.id)===b.id&&I(null),await F(),k(null),r("Prompt deleted","success")}catch(J){k(null),s({title:"Failed to Delete Prompt",error:Zt(J,"An error occurred while deleting the prompt.")})}},K=J=>{e(`/prompts/${J.id}/edit`)},$=async J=>{try{await Ie.webui.patch(`/api/v1/prompts/${J}/make-production`),F(),r("Version made active","success")}catch(ce){s({title:"Failed to Update Version",error:Zt(ce,"An error occurred while making the version active.")})}},W=J=>{p(!1),e("/prompts/new?mode=ai-assisted",{state:{taskDescription:J}})},V=J=>{var ge;const ce=((ge=J.productionPrompt)==null?void 0:ge.promptText)||"";Va(ce).length>0?(_(J),E(!0)):e("/chat",{state:{promptText:ce,groupId:J.id,groupName:J.name}})},X=J=>{R&&(e("/chat",{state:{promptText:J,groupId:R.id,groupName:R.name}}),E(!1),_(null))},H=async(J,ce)=>{try{i(de=>de.map(fe=>fe.id===J?{...fe,isPinned:!ce}:fe)),await Ie.webui.patch(`/api/v1/prompts/groups/${J}/pin`)}catch(de){i(fe=>fe.map(ge=>ge.id===J?{...ge,isPinned:ce}:ge)),s({title:"Failed to Update Pin Status",error:Zt(de,"An error occurred while updating the pin status.")})}},Q=async J=>{try{const ce=await Ie.webui.get(`/api/v1/prompts/groups/${J.id}/export`),de=new Blob([JSON.stringify(ce,null,2)],{type:"application/json"}),fe=`prompt-${J.name.replace(/[^a-z0-9]/gi,"-").toLowerCase()}-${Date.now()}.json`;hl(de,fe),r("Prompt exported successfully","success")}catch(ce){s({title:"Failed to Export Prompt",error:Zt(ce,"An error occurred while exporting the prompt.")})}},z=async(J,ce)=>{try{const de={prompt_data:{version:J.version,exported_at:J.exportedAt,prompt:{name:J.prompt.name,description:J.prompt.description,category:J.prompt.category,command:J.prompt.command,prompt_text:J.prompt.promptText,metadata:J.prompt.metadata?{author_name:J.prompt.metadata.authorName,original_version:J.prompt.metadata.originalVersion,original_created_at:J.prompt.metadata.originalCreatedAt}:void 0}},options:{preserve_command:ce.preserveCommand,preserve_category:ce.preserveCategory}},fe=await Ie.webui.post("/api/v1/prompts/import",de);h(!1),L(!1),v(null),x(null),await F(),A(fe.prompt_group_id);const ge=(fe.warnings||[]).filter(T=>!T.toLowerCase().includes("truncated"));if(ge.length>0){const T=ge.length===1?ge[0]:ge.join("; ");r(`Prompt imported with notes: ${T}`,"info")}else r("Prompt imported","success")}catch(de){throw console.error("Failed to import prompt:",de),de}};return u?o.jsxs(o.Fragment,{children:[o.jsx(WF,{onBack:()=>{e("/prompts")},onSuccess:async J=>{J&&A(J),await F(),e("/prompts")},initialMessage:m,editingGroup:g,isEditing:!!g,initialMode:w},`builder-${C}-${(g==null?void 0:g.id)||"new"}`),b&&o.jsx(Kd,{isOpen:!0,onClose:()=>k(null),onConfirm:O,promptName:b.name},`delete-${b.id}`),o.jsx(Ox,{isOpen:f,onClose:()=>p(!1),onGenerate:W})]}):j?o.jsxs(o.Fragment,{children:[o.jsx(ZF,{group:j,onBack:()=>e("/prompts"),onBackToPromptDetail:()=>e("/prompts"),onEdit:K,onDeleteAll:D,onRestoreVersion:$}),b&&o.jsx(Kd,{isOpen:!0,onClose:()=>k(null),onConfirm:O,promptName:b.name},`delete-${b.id}`)]}):o.jsxs("div",{className:"flex h-full w-full flex-col",children:[o.jsx(sa,{title:"Prompts",buttons:[o.jsxs(ye,{variant:"ghost",title:"Import Prompt",onClick:()=>L(!0),children:[o.jsx(Vv,{className:"size-4"}),"Import Prompt"]},"importPrompt"),o.jsxs(ye,{"data-testid":"refreshPrompts",disabled:l,variant:"ghost",title:"Refresh Prompts",onClick:()=>F(),children:[o.jsx(uu,{className:"size-4"}),"Refresh Prompts"]},"refreshPrompts")]}),l?o.jsx(rr,{title:"Loading prompts...",variant:"loading"}):o.jsx("div",{className:"bg-card-background relative flex-1 p-4",children:o.jsx(zF,{prompts:a,onManualCreate:()=>e("/prompts/new?mode=manual"),onAIAssisted:()=>p(!0),onEdit:K,onDelete:D,onViewVersions:J=>e(`/prompts/${J.id}/versions`),onUseInChat:V,onTogglePin:H,onExport:Q,newlyCreatedPromptId:N})}),b&&o.jsx(Kd,{isOpen:!0,onClose:()=>k(null),onConfirm:O,promptName:b.name},`delete-${b.id}`),o.jsx(Ox,{isOpen:f,onClose:()=>p(!1),onGenerate:W}),P&&R&&o.jsx(Mm,{group:R,onSubmit:X,onClose:()=>{E(!1),_(null)}}),o.jsx(w7,{open:M,onOpenChange:L,onImport:z,existingPrompts:a})]})},y7=e=>({displayName:e?"Solace Dark JER":"Solace Light JER",styles:{container:{backgroundColor:"transparent",fontFamily:"monospace",fontSize:"14px"},property:e?"var(--color-primary-text-w10)":"var(--color-primary-text-wMain)",bracket:"var(--color-secondary-text-w50)",itemCount:{color:"var(--color-secondary-text-w50)",fontStyle:"italic"},string:e?"var(--color-success-w70)":"var(--color-success-wMain)",number:"var(--color-accent-n0-wMain)",boolean:e?"var(--color-warning-w70)":"var(--color-warning-wMain)",null:{color:"var(--color-secondary-text-w50)",fontStyle:"italic"},iconCollection:"var(--color-secondary-text-w50)",iconCopy:"var(--color-secondary-text-w50)"}}),fh=({data:e,maxDepth:t=2,className:n=""})=>{const{currentTheme:r}=wl(),s=d.useMemo(()=>y7(r==="dark"),[r]),a=d.useMemo(()=>t===void 0||t<0?!1:t,[t]),i=d.useMemo(()=>e===null||typeof e!="object"?{value:e}:e,[e]),l=`rounded-lg border overflow-auto ${n}`.trim();return e===void 0?o.jsx("div",{className:l,children:o.jsx("span",{className:"italic",children:"No JSON data"})}):o.jsx("div",{className:l,children:o.jsx(F_,{data:i,theme:s,viewOnly:!0,collapse:a,showStringQuotes:!0,showCollectionCount:"when-closed"})})},b7=({isOpen:e,onClose:t,onSubmit:n,isSubmitting:r=!1})=>{const[s,a]=d.useState(""),[i,l]=d.useState(""),[c,u]=d.useState(null),[h,f]=d.useState(null),p=async v=>{v.preventDefault();const g=s.trim();if(g.length===0){f("Project name is required");return}else if(g.length>255){f("Project name must be less than 255 characters");return}else f(null);try{await n({name:g,description:i.trim()}),a(""),l(""),u(null)}catch(x){u(Zt(x,"Failed to create project"))}},m=()=>{r||(a(""),l(""),f(null),u(null),t())};return o.jsx(Nr,{open:e,onOpenChange:v=>!v&&m(),children:o.jsx(Tr,{className:"sm:max-w-[500px]",children:o.jsxs("form",{onSubmit:p,children:[o.jsxs(rs,{children:[o.jsx(Ar,{children:"Create New Project"}),o.jsx(Ir,{children:"Create a new project to organize your chats and files. You can add more details after creation."})]}),o.jsxs("div",{className:"flex flex-col gap-4 pt-4",children:[c&&o.jsx(Xt,{variant:"error",message:c}),o.jsxs("div",{children:[o.jsxs("label",{htmlFor:"project-name",className:"font-medium",children:["Project Name ",o.jsx("span",{className:"text-[var(--color-brand-wMain)]",children:"*"})]}),o.jsx(_r,{id:"project-name",value:s,onChange:v=>{a(v.target.value),f(null)},disabled:r,maxLength:256,className:h?"border-destructive":""}),h&&o.jsx("div",{className:"text-destructive text-xs",children:h})]}),o.jsxs("div",{children:[o.jsx("label",{htmlFor:"project-description",className:"font-medium",children:"Description"}),o.jsx(ts,{id:"project-description",value:i,onChange:v=>l(v.target.value),disabled:r,rows:3,maxLength:1e3}),o.jsxs("div",{className:"text-secondary-foreground text-right text-xs",children:[i.length,"/1000"]})]})]}),o.jsxs(Cs,{children:[o.jsx(ye,{type:"button",variant:"ghost",onClick:m,disabled:r,children:"Cancel"}),o.jsx(ye,{type:"submit",disabled:r,children:"Create Project"})]})]})})})},C7=({onClick:e})=>o.jsx(Gu,{className:"border border-dashed border-[var(--color-primary-wMain)]",onClick:e,children:o.jsx(P0,{className:"flex h-full items-center justify-center",children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"mb-4 flex justify-center",children:o.jsx("div",{className:"bg-primary/10 rounded-full p-4",children:o.jsx(Vo,{className:"text-primary h-8 w-8"})})}),o.jsx("h3",{className:"text-foreground text-lg font-semibold",children:"Create New Project"})]})})}),rd=({fileName:e,fileSize:t})=>o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(kc,{className:"text-muted-foreground size-5 shrink-0"}),o.jsxs("div",{className:"overflow-hidden",children:[o.jsx("div",{className:"truncate",title:e,children:e}),o.jsx("div",{className:"text-muted-foreground text-xs",children:ds(t)})]})]}),S7=({isOpen:e,files:t,onClose:n,onConfirm:r,isSubmitting:s=!1,error:a=null,onClearError:i})=>{const[l,c]=d.useState({});d.useEffect(()=>{e&&c({})},[e]);const u=d.useCallback(()=>{i==null||i(),n()},[n,i]),h=d.useCallback((v,g)=>{c(x=>({...x,[v]:g}))},[]),f=d.useCallback(async()=>{if(!t)return;const v=new FormData,g={};for(const x of Array.from(t))v.append("files",x),l[x.name]&&(g[x.name]=l[x.name]);Object.keys(g).length>0&&v.append("fileMetadata",JSON.stringify(g)),await r(v)},[t,l,r]),p=t?Array.from(t):[],m=o.jsxs(o.Fragment,{children:[a&&o.jsx(Xt,{variant:"error",message:a,dismissible:!0,onDismiss:i}),p.length>0?o.jsx("div",{className:"mt-4 flex max-h-[50vh] flex-col gap-4 overflow-y-auto p-1",children:p.map((v,g)=>o.jsxs("div",{children:[o.jsx(rd,{fileName:v.name,fileSize:v.size}),o.jsx(ts,{className:"mt-2",rows:2,disabled:s,value:l[v.name]||"",onChange:x=>h(v.name,x.target.value)})]},v.name+g))}):o.jsx("p",{className:"text-muted-foreground",children:"No files selected."})]});return o.jsx(Rr,{open:e,onOpenChange:v=>!v&&u(),title:"Upload Project Files",description:"Add descriptions to help Solace Agent Mesh understand each file's purpose.",content:m,actionLabels:{cancel:"Cancel",confirm:`Upload ${p.length} File(s)`},isLoading:s,onConfirm:f,onCancel:u})},_7=({project:e,onClick:t,onDelete:n,onExport:r})=>{const[s,a]=d.useState(!1),i=[...r?[{id:"export",label:"Export Project",icon:o.jsx(yo,{size:14}),onClick:()=>{a(!1),r(e)}}]:[],{id:"delete",label:"Delete",icon:o.jsx(Ho,{size:14}),onClick:()=>{a(!1),n&&n(e)}}];return o.jsxs(Gu,{onClick:t,children:[o.jsx(QT,{children:o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsxs(Na,{className:"flex min-w-0 flex-1 items-center gap-2",title:e.name,children:[o.jsx(zv,{className:"h-6 w-6 flex-shrink-0 text-[var(--color-brand-wMain)]"}),o.jsx("div",{className:"text-foreground max-w-[250px] min-w-0 truncate text-lg font-semibold",children:e.name})]}),o.jsx("div",{className:"flex shrink-0 items-center gap-1",children:n&&o.jsxs(Sl,{open:s,onOpenChange:a,children:[o.jsx(_l,{asChild:!0,children:o.jsx(ye,{variant:"ghost",size:"icon",className:"h-8 w-8",tooltip:"More options",onClick:l=>l.stopPropagation(),children:o.jsx(fo,{className:"h-4 w-4"})})}),o.jsx(kl,{align:"start",side:"bottom",className:"w-48 p-1",sideOffset:0,onClick:l=>l.stopPropagation(),children:o.jsx(bl,{actions:i})})]})})]})}),o.jsxs(P0,{className:"flex flex-1 flex-col justify-between",children:[o.jsx("div",{children:e.description?o.jsx(eA,{className:"line-clamp-3",title:e.description,children:e.description}):o.jsx("div",{})}),o.jsxs("div",{className:"text-muted-foreground mt-3 flex items-center justify-between text-xs",children:[o.jsxs("div",{className:"flex items-center gap-1",children:["Created: ",Ah(e.createdAt),o.jsx("div",{children:"|"}),o.jsx("div",{className:"max-w-[80px] truncate",title:e.userId,children:e.userId})]}),o.jsx("div",{children:e.artifactCount!==void 0&&e.artifactCount!==null&&o.jsxs(go,{variant:"secondary",className:"flex h-6 items-center gap-1",title:`${e.artifactCount} ${e.artifactCount===1?"file":"files"}`,children:[o.jsx(Sr,{className:"h-3.5 w-3.5"}),o.jsx("span",{children:e.artifactCount})]})})]})]})]})},t_=({isOpen:e,onClose:t,onConfirm:n,project:r,isDeleting:s=!1})=>r?o.jsx(Rr,{open:e,onOpenChange:a=>!a&&t(),title:"Delete Project",content:o.jsxs(o.Fragment,{children:["This action cannot be undone. This project and all its associated chat sessions and artifacts will be permanently deleted: ",o.jsx("strong",{children:r.name}),"."]}),actionLabels:{confirm:"Delete"},onConfirm:n,onCancel:t,isLoading:s}):null;function fc(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ef={exports:{}};/*!
|
|
423
|
+
|
|
424
|
+
JSZip v3.10.1 - A JavaScript class for generating and reading zip files
|
|
425
|
+
<http://stuartk.com/jszip>
|
|
426
|
+
|
|
427
|
+
(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
|
|
428
|
+
Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.
|
|
429
|
+
|
|
430
|
+
JSZip uses the library pako released under the MIT license :
|
|
431
|
+
https://github.com/nodeca/pako/blob/main/LICENSE
|
|
432
|
+
*/var lv;function k7(){return lv||(lv=1,function(e,t){(function(n){e.exports=n()})(function(){return function n(r,s,a){function i(u,h){if(!s[u]){if(!r[u]){var f=typeof fc=="function"&&fc;if(!h&&f)return f(u,!0);if(l)return l(u,!0);var p=new Error("Cannot find module '"+u+"'");throw p.code="MODULE_NOT_FOUND",p}var m=s[u]={exports:{}};r[u][0].call(m.exports,function(v){var g=r[u][1][v];return i(g||v)},m,m.exports,n,r,s,a)}return s[u].exports}for(var l=typeof fc=="function"&&fc,c=0;c<a.length;c++)i(a[c]);return i}({1:[function(n,r,s){var a=n("./utils"),i=n("./support"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";s.encode=function(c){for(var u,h,f,p,m,v,g,x=[],w=0,y=c.length,C=y,S=a.getTypeOf(c)!=="string";w<c.length;)C=y-w,f=S?(u=c[w++],h=w<y?c[w++]:0,w<y?c[w++]:0):(u=c.charCodeAt(w++),h=w<y?c.charCodeAt(w++):0,w<y?c.charCodeAt(w++):0),p=u>>2,m=(3&u)<<4|h>>4,v=1<C?(15&h)<<2|f>>6:64,g=2<C?63&f:64,x.push(l.charAt(p)+l.charAt(m)+l.charAt(v)+l.charAt(g));return x.join("")},s.decode=function(c){var u,h,f,p,m,v,g=0,x=0,w="data:";if(c.substr(0,w.length)===w)throw new Error("Invalid base64 input, it looks like a data url.");var y,C=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===l.charAt(64)&&C--,c.charAt(c.length-2)===l.charAt(64)&&C--,C%1!=0)throw new Error("Invalid base64 input, bad content length.");for(y=i.uint8array?new Uint8Array(0|C):new Array(0|C);g<c.length;)u=l.indexOf(c.charAt(g++))<<2|(p=l.indexOf(c.charAt(g++)))>>4,h=(15&p)<<4|(m=l.indexOf(c.charAt(g++)))>>2,f=(3&m)<<6|(v=l.indexOf(c.charAt(g++))),y[x++]=u,m!==64&&(y[x++]=h),v!==64&&(y[x++]=f);return y}},{"./support":30,"./utils":32}],2:[function(n,r,s){var a=n("./external"),i=n("./stream/DataWorker"),l=n("./stream/Crc32Probe"),c=n("./stream/DataLengthProbe");function u(h,f,p,m,v){this.compressedSize=h,this.uncompressedSize=f,this.crc32=p,this.compression=m,this.compressedContent=v}u.prototype={getContentWorker:function(){var h=new i(a.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),f=this;return h.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),h},getCompressedWorker:function(){return new i(a.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(h,f,p){return h.pipe(new l).pipe(new c("uncompressedSize")).pipe(f.compressWorker(p)).pipe(new c("compressedSize")).withStreamInfo("compression",f)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,s){var a=n("./stream/GenericWorker");s.STORE={magic:"\0\0",compressWorker:function(){return new a("STORE compression")},uncompressWorker:function(){return new a("STORE decompression")}},s.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,s){var a=n("./utils"),i=function(){for(var l,c=[],u=0;u<256;u++){l=u;for(var h=0;h<8;h++)l=1&l?3988292384^l>>>1:l>>>1;c[u]=l}return c}();r.exports=function(l,c){return l!==void 0&&l.length?a.getTypeOf(l)!=="string"?function(u,h,f,p){var m=i,v=p+f;u^=-1;for(var g=p;g<v;g++)u=u>>>8^m[255&(u^h[g])];return-1^u}(0|c,l,l.length,0):function(u,h,f,p){var m=i,v=p+f;u^=-1;for(var g=p;g<v;g++)u=u>>>8^m[255&(u^h.charCodeAt(g))];return-1^u}(0|c,l,l.length,0):0}},{"./utils":32}],5:[function(n,r,s){s.base64=!1,s.binary=!1,s.dir=!1,s.createFolders=!0,s.date=null,s.compression=null,s.compressionOptions=null,s.comment=null,s.unixPermissions=null,s.dosPermissions=null},{}],6:[function(n,r,s){var a=null;a=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:a}},{lie:37}],7:[function(n,r,s){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",i=n("pako"),l=n("./utils"),c=n("./stream/GenericWorker"),u=a?"uint8array":"array";function h(f,p){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=p,this.meta={}}s.magic="\b\0",l.inherits(h,c),h.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(l.transformTo(u,f.data),!1)},h.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},h.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},h.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(p){f.push({data:p,meta:f.meta})}},s.compressWorker=function(f){return new h("Deflate",f)},s.uncompressWorker=function(){return new h("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,s){function a(m,v){var g,x="";for(g=0;g<v;g++)x+=String.fromCharCode(255&m),m>>>=8;return x}function i(m,v,g,x,w,y){var C,S,j=m.file,I=m.compression,b=y!==u.utf8encode,k=l.transformTo("string",y(j.name)),N=l.transformTo("string",u.utf8encode(j.name)),A=j.comment,P=l.transformTo("string",y(A)),E=l.transformTo("string",u.utf8encode(A)),R=N.length!==j.name.length,_=E.length!==A.length,M="",L="",F="",D=j.dir,O=j.date,K={crc32:0,compressedSize:0,uncompressedSize:0};v&&!g||(K.crc32=m.crc32,K.compressedSize=m.compressedSize,K.uncompressedSize=m.uncompressedSize);var $=0;v&&($|=8),b||!R&&!_||($|=2048);var W=0,V=0;D&&(W|=16),w==="UNIX"?(V=798,W|=function(H,Q){var z=H;return H||(z=Q?16893:33204),(65535&z)<<16}(j.unixPermissions,D)):(V=20,W|=function(H){return 63&(H||0)}(j.dosPermissions)),C=O.getUTCHours(),C<<=6,C|=O.getUTCMinutes(),C<<=5,C|=O.getUTCSeconds()/2,S=O.getUTCFullYear()-1980,S<<=4,S|=O.getUTCMonth()+1,S<<=5,S|=O.getUTCDate(),R&&(L=a(1,1)+a(h(k),4)+N,M+="up"+a(L.length,2)+L),_&&(F=a(1,1)+a(h(P),4)+E,M+="uc"+a(F.length,2)+F);var X="";return X+=`
|
|
433
|
+
\0`,X+=a($,2),X+=I.magic,X+=a(C,2),X+=a(S,2),X+=a(K.crc32,4),X+=a(K.compressedSize,4),X+=a(K.uncompressedSize,4),X+=a(k.length,2),X+=a(M.length,2),{fileRecord:f.LOCAL_FILE_HEADER+X+k+M,dirRecord:f.CENTRAL_FILE_HEADER+a(V,2)+X+a(P.length,2)+"\0\0\0\0"+a(W,4)+a(x,4)+k+M+P}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),h=n("../crc32"),f=n("../signature");function p(m,v,g,x){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=v,this.zipPlatform=g,this.encodeFileName=x,this.streamFiles=m,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(p,c),p.prototype.push=function(m){var v=m.meta.percent||0,g=this.entriesCount,x=this._sources.length;this.accumulate?this.contentBuffer.push(m):(this.bytesWritten+=m.data.length,c.prototype.push.call(this,{data:m.data,meta:{currentFile:this.currentFile,percent:g?(v+100*(g-x-1))/g:100}}))},p.prototype.openedSource=function(m){this.currentSourceOffset=this.bytesWritten,this.currentFile=m.file.name;var v=this.streamFiles&&!m.file.dir;if(v){var g=i(m,v,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:g.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(m){this.accumulate=!1;var v=this.streamFiles&&!m.file.dir,g=i(m,v,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(g.dirRecord),v)this.push({data:function(x){return f.DATA_DESCRIPTOR+a(x.crc32,4)+a(x.compressedSize,4)+a(x.uncompressedSize,4)}(m),meta:{percent:100}});else for(this.push({data:g.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var m=this.bytesWritten,v=0;v<this.dirRecords.length;v++)this.push({data:this.dirRecords[v],meta:{percent:100}});var g=this.bytesWritten-m,x=function(w,y,C,S,j){var I=l.transformTo("string",j(S));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(w,2)+a(w,2)+a(y,4)+a(C,4)+a(I.length,2)+I}(this.dirRecords.length,g,m,this.zipComment,this.encodeFileName);this.push({data:x,meta:{percent:100}})},p.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},p.prototype.registerPrevious=function(m){this._sources.push(m);var v=this;return m.on("data",function(g){v.processChunk(g)}),m.on("end",function(){v.closedSource(v.previous.streamInfo),v._sources.length?v.prepareNextSource():v.end()}),m.on("error",function(g){v.error(g)}),this},p.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},p.prototype.error=function(m){var v=this._sources;if(!c.prototype.error.call(this,m))return!1;for(var g=0;g<v.length;g++)try{v[g].error(m)}catch{}return!0},p.prototype.lock=function(){c.prototype.lock.call(this);for(var m=this._sources,v=0;v<m.length;v++)m[v].lock()},r.exports=p},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,s){var a=n("../compressions"),i=n("./ZipFileWorker");s.generateWorker=function(l,c,u){var h=new i(c.streamFiles,u,c.platform,c.encodeFileName),f=0;try{l.forEach(function(p,m){f++;var v=function(y,C){var S=y||C,j=a[S];if(!j)throw new Error(S+" is not a valid compression method !");return j}(m.options.compression,c.compression),g=m.options.compressionOptions||c.compressionOptions||{},x=m.dir,w=m.date;m._compressWorker(v,g).withStreamInfo("file",{name:p,dir:x,date:w,comment:m.comment||"",unixPermissions:m.unixPermissions,dosPermissions:m.dosPermissions}).pipe(h)}),h.entriesCount=f}catch(p){h.error(p)}return h}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,s){function a(){if(!(this instanceof a))return new a;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var i=new a;for(var l in this)typeof this[l]!="function"&&(i[l]=this[l]);return i}}(a.prototype=n("./object")).loadAsync=n("./load"),a.support=n("./support"),a.defaults=n("./defaults"),a.version="3.10.1",a.loadAsync=function(i,l){return new a().loadAsync(i,l)},a.external=n("./external"),r.exports=a},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,s){var a=n("./utils"),i=n("./external"),l=n("./utf8"),c=n("./zipEntries"),u=n("./stream/Crc32Probe"),h=n("./nodejsUtils");function f(p){return new i.Promise(function(m,v){var g=p.decompressed.getContentWorker().pipe(new u);g.on("error",function(x){v(x)}).on("end",function(){g.streamInfo.crc32!==p.decompressed.crc32?v(new Error("Corrupted zip : CRC32 mismatch")):m()}).resume()})}r.exports=function(p,m){var v=this;return m=a.extend(m||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:l.utf8decode}),h.isNode&&h.isStream(p)?i.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):a.prepareContent("the loaded zip file",p,!0,m.optimizedBinaryString,m.base64).then(function(g){var x=new c(m);return x.load(g),x}).then(function(g){var x=[i.Promise.resolve(g)],w=g.files;if(m.checkCRC32)for(var y=0;y<w.length;y++)x.push(f(w[y]));return i.Promise.all(x)}).then(function(g){for(var x=g.shift(),w=x.files,y=0;y<w.length;y++){var C=w[y],S=C.fileNameStr,j=a.resolve(C.fileNameStr);v.file(j,C.decompressed,{binary:!0,optimizedBinaryString:!0,date:C.date,dir:C.dir,comment:C.fileCommentStr.length?C.fileCommentStr:null,unixPermissions:C.unixPermissions,dosPermissions:C.dosPermissions,createFolders:m.createFolders}),C.dir||(v.file(j).unsafeOriginalName=S)}return x.zipComment.length&&(v.comment=x.zipComment),v})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,s){var a=n("../utils"),i=n("../stream/GenericWorker");function l(c,u){i.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}a.inherits(l,i),l.prototype._bindStream=function(c){var u=this;(this._stream=c).pause(),c.on("data",function(h){u.push({data:h,meta:{percent:0}})}).on("error",function(h){u.isPaused?this.generatedError=h:u.error(h)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},l.prototype.pause=function(){return!!i.prototype.pause.call(this)&&(this._stream.pause(),!0)},l.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=l},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,s){var a=n("readable-stream").Readable;function i(l,c,u){a.call(this,c),this._helper=l;var h=this;l.on("data",function(f,p){h.push(f)||h._helper.pause(),u&&u(p)}).on("error",function(f){h.emit("error",f)}).on("end",function(){h.push(null)})}n("../utils").inherits(i,a),i.prototype._read=function(){this._helper.resume()},r.exports=i},{"../utils":32,"readable-stream":16}],14:[function(n,r,s){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(a,i){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(a,i);if(typeof a=="number")throw new Error('The "data" argument must not be a number');return new Buffer(a,i)},allocBuffer:function(a){if(Buffer.alloc)return Buffer.alloc(a);var i=new Buffer(a);return i.fill(0),i},isBuffer:function(a){return Buffer.isBuffer(a)},isStream:function(a){return a&&typeof a.on=="function"&&typeof a.pause=="function"&&typeof a.resume=="function"}}},{}],15:[function(n,r,s){function a(j,I,b){var k,N=l.getTypeOf(I),A=l.extend(b||{},h);A.date=A.date||new Date,A.compression!==null&&(A.compression=A.compression.toUpperCase()),typeof A.unixPermissions=="string"&&(A.unixPermissions=parseInt(A.unixPermissions,8)),A.unixPermissions&&16384&A.unixPermissions&&(A.dir=!0),A.dosPermissions&&16&A.dosPermissions&&(A.dir=!0),A.dir&&(j=w(j)),A.createFolders&&(k=x(j))&&y.call(this,k,!0);var P=N==="string"&&A.binary===!1&&A.base64===!1;b&&b.binary!==void 0||(A.binary=!P),(I instanceof f&&I.uncompressedSize===0||A.dir||!I||I.length===0)&&(A.base64=!1,A.binary=!0,I="",A.compression="STORE",N="string");var E=null;E=I instanceof f||I instanceof c?I:v.isNode&&v.isStream(I)?new g(j,I):l.prepareContent(j,I,A.binary,A.optimizedBinaryString,A.base64);var R=new p(j,E,A);this.files[j]=R}var i=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),h=n("./defaults"),f=n("./compressedObject"),p=n("./zipObject"),m=n("./generate"),v=n("./nodejsUtils"),g=n("./nodejs/NodejsStreamInputAdapter"),x=function(j){j.slice(-1)==="/"&&(j=j.substring(0,j.length-1));var I=j.lastIndexOf("/");return 0<I?j.substring(0,I):""},w=function(j){return j.slice(-1)!=="/"&&(j+="/"),j},y=function(j,I){return I=I!==void 0?I:h.createFolders,j=w(j),this.files[j]||a.call(this,j,null,{dir:!0,createFolders:I}),this.files[j]};function C(j){return Object.prototype.toString.call(j)==="[object RegExp]"}var S={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(j){var I,b,k;for(I in this.files)k=this.files[I],(b=I.slice(this.root.length,I.length))&&I.slice(0,this.root.length)===this.root&&j(b,k)},filter:function(j){var I=[];return this.forEach(function(b,k){j(b,k)&&I.push(k)}),I},file:function(j,I,b){if(arguments.length!==1)return j=this.root+j,a.call(this,j,I,b),this;if(C(j)){var k=j;return this.filter(function(A,P){return!P.dir&&k.test(A)})}var N=this.files[this.root+j];return N&&!N.dir?N:null},folder:function(j){if(!j)return this;if(C(j))return this.filter(function(N,A){return A.dir&&j.test(N)});var I=this.root+j,b=y.call(this,I),k=this.clone();return k.root=b.name,k},remove:function(j){j=this.root+j;var I=this.files[j];if(I||(j.slice(-1)!=="/"&&(j+="/"),I=this.files[j]),I&&!I.dir)delete this.files[j];else for(var b=this.filter(function(N,A){return A.name.slice(0,j.length)===j}),k=0;k<b.length;k++)delete this.files[b[k].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(j){var I,b={};try{if((b=l.extend(j||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:i.utf8encode})).type=b.type.toLowerCase(),b.compression=b.compression.toUpperCase(),b.type==="binarystring"&&(b.type="string"),!b.type)throw new Error("No output type specified.");l.checkSupport(b.type),b.platform!=="darwin"&&b.platform!=="freebsd"&&b.platform!=="linux"&&b.platform!=="sunos"||(b.platform="UNIX"),b.platform==="win32"&&(b.platform="DOS");var k=b.comment||this.comment||"";I=m.generateWorker(this,b,k)}catch(N){(I=new c("error")).error(N)}return new u(I,b.type||"string",b.mimeType)},generateAsync:function(j,I){return this.generateInternalStream(j).accumulate(I)},generateNodeStream:function(j,I){return(j=j||{}).type||(j.type="nodebuffer"),this.generateInternalStream(j).toNodejsStream(I)}};r.exports=S},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,s){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,s){var a=n("./DataReader");function i(l){a.call(this,l);for(var c=0;c<this.data.length;c++)l[c]=255&l[c]}n("../utils").inherits(i,a),i.prototype.byteAt=function(l){return this.data[this.zero+l]},i.prototype.lastIndexOfSignature=function(l){for(var c=l.charCodeAt(0),u=l.charCodeAt(1),h=l.charCodeAt(2),f=l.charCodeAt(3),p=this.length-4;0<=p;--p)if(this.data[p]===c&&this.data[p+1]===u&&this.data[p+2]===h&&this.data[p+3]===f)return p-this.zero;return-1},i.prototype.readAndCheckSignature=function(l){var c=l.charCodeAt(0),u=l.charCodeAt(1),h=l.charCodeAt(2),f=l.charCodeAt(3),p=this.readData(4);return c===p[0]&&u===p[1]&&h===p[2]&&f===p[3]},i.prototype.readData=function(l){if(this.checkOffset(l),l===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=i},{"../utils":32,"./DataReader":18}],18:[function(n,r,s){var a=n("../utils");function i(l){this.data=l,this.length=l.length,this.index=0,this.zero=0}i.prototype={checkOffset:function(l){this.checkIndex(this.index+l)},checkIndex:function(l){if(this.length<this.zero+l||l<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+l+"). Corrupted zip ?")},setIndex:function(l){this.checkIndex(l),this.index=l},skip:function(l){this.setIndex(this.index+l)},byteAt:function(){},readInt:function(l){var c,u=0;for(this.checkOffset(l),c=this.index+l-1;c>=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=l,u},readString:function(l){return a.transformTo("string",this.readData(l))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var l=this.readInt(4);return new Date(Date.UTC(1980+(l>>25&127),(l>>21&15)-1,l>>16&31,l>>11&31,l>>5&63,(31&l)<<1))}},r.exports=i},{"../utils":32}],19:[function(n,r,s){var a=n("./Uint8ArrayReader");function i(l){a.call(this,l)}n("../utils").inherits(i,a),i.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,s){var a=n("./DataReader");function i(l){a.call(this,l)}n("../utils").inherits(i,a),i.prototype.byteAt=function(l){return this.data.charCodeAt(this.zero+l)},i.prototype.lastIndexOfSignature=function(l){return this.data.lastIndexOf(l)-this.zero},i.prototype.readAndCheckSignature=function(l){return l===this.readData(4)},i.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=i},{"../utils":32,"./DataReader":18}],21:[function(n,r,s){var a=n("./ArrayReader");function i(l){a.call(this,l)}n("../utils").inherits(i,a),i.prototype.readData=function(l){if(this.checkOffset(l),l===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,s){var a=n("../utils"),i=n("../support"),l=n("./ArrayReader"),c=n("./StringReader"),u=n("./NodeBufferReader"),h=n("./Uint8ArrayReader");r.exports=function(f){var p=a.getTypeOf(f);return a.checkSupport(p),p!=="string"||i.uint8array?p==="nodebuffer"?new u(f):i.uint8array?new h(a.transformTo("uint8array",f)):new l(a.transformTo("array",f)):new c(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,s){s.LOCAL_FILE_HEADER="PK",s.CENTRAL_FILE_HEADER="PK",s.CENTRAL_DIRECTORY_END="PK",s.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",s.ZIP64_CENTRAL_DIRECTORY_END="PK",s.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,s){var a=n("./GenericWorker"),i=n("../utils");function l(c){a.call(this,"ConvertWorker to "+c),this.destType=c}i.inherits(l,a),l.prototype.processChunk=function(c){this.push({data:i.transformTo(this.destType,c.data),meta:c.meta})},r.exports=l},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,s){var a=n("./GenericWorker"),i=n("../crc32");function l(){a.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(l,a),l.prototype.processChunk=function(c){this.streamInfo.crc32=i(c.data,this.streamInfo.crc32||0),this.push(c)},r.exports=l},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,s){var a=n("../utils"),i=n("./GenericWorker");function l(c){i.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}a.inherits(l,i),l.prototype.processChunk=function(c){if(c){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+c.data.length}i.prototype.processChunk.call(this,c)},r.exports=l},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,s){var a=n("../utils"),i=n("./GenericWorker");function l(c){i.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(h){u.dataIsReady=!0,u.data=h,u.max=h&&h.length||0,u.type=a.getTypeOf(h),u.isPaused||u._tickAndRepeat()},function(h){u.error(h)})}a.inherits(l,i),l.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},l.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,a.delay(this._tickAndRepeat,[],this)),!0)},l.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(a.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},l.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,u);break;case"uint8array":c=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":c=this.data.slice(this.index,u)}return this.index=u,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=l},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,s){function a(i){this.name=i||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}a.prototype={push:function(i){this.emit("data",i)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(i){this.emit("error",i)}return!0},error:function(i){return!this.isFinished&&(this.isPaused?this.generatedError=i:(this.isFinished=!0,this.emit("error",i),this.previous&&this.previous.error(i),this.cleanUp()),!0)},on:function(i,l){return this._listeners[i].push(l),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(i,l){if(this._listeners[i])for(var c=0;c<this._listeners[i].length;c++)this._listeners[i][c].call(this,l)},pipe:function(i){return i.registerPrevious(this)},registerPrevious:function(i){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=i.streamInfo,this.mergeStreamInfo(),this.previous=i;var l=this;return i.on("data",function(c){l.processChunk(c)}),i.on("end",function(){l.end()}),i.on("error",function(c){l.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var i=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),i=!0),this.previous&&this.previous.resume(),!i},flush:function(){},processChunk:function(i){this.push(i)},withStreamInfo:function(i,l){return this.extraStreamInfo[i]=l,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var i in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,i)&&(this.streamInfo[i]=this.extraStreamInfo[i])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var i="Worker "+this.name;return this.previous?this.previous+" -> "+i:i}},r.exports=a},{}],29:[function(n,r,s){var a=n("../utils"),i=n("./ConvertWorker"),l=n("./GenericWorker"),c=n("../base64"),u=n("../support"),h=n("../external"),f=null;if(u.nodestream)try{f=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(v,g){return new h.Promise(function(x,w){var y=[],C=v._internalType,S=v._outputType,j=v._mimeType;v.on("data",function(I,b){y.push(I),g&&g(b)}).on("error",function(I){y=[],w(I)}).on("end",function(){try{var I=function(b,k,N){switch(b){case"blob":return a.newBlob(a.transformTo("arraybuffer",k),N);case"base64":return c.encode(k);default:return a.transformTo(b,k)}}(S,function(b,k){var N,A=0,P=null,E=0;for(N=0;N<k.length;N++)E+=k[N].length;switch(b){case"string":return k.join("");case"array":return Array.prototype.concat.apply([],k);case"uint8array":for(P=new Uint8Array(E),N=0;N<k.length;N++)P.set(k[N],A),A+=k[N].length;return P;case"nodebuffer":return Buffer.concat(k);default:throw new Error("concat : unsupported type '"+b+"'")}}(C,y),j);x(I)}catch(b){w(b)}y=[]}).resume()})}function m(v,g,x){var w=g;switch(g){case"blob":case"arraybuffer":w="uint8array";break;case"base64":w="string"}try{this._internalType=w,this._outputType=g,this._mimeType=x,a.checkSupport(w),this._worker=v.pipe(new i(w)),v.lock()}catch(y){this._worker=new l("error"),this._worker.error(y)}}m.prototype={accumulate:function(v){return p(this,v)},on:function(v,g){var x=this;return v==="data"?this._worker.on(v,function(w){g.call(x,w.data,w.meta)}):this._worker.on(v,function(){a.delay(g,arguments,x)}),this},resume:function(){return a.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(v){if(a.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},v)}},r.exports=m},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,s){if(s.base64=!0,s.array=!0,s.string=!0,s.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",s.nodebuffer=typeof Buffer<"u",s.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")s.blob=!1;else{var a=new ArrayBuffer(0);try{s.blob=new Blob([a],{type:"application/zip"}).size===0}catch{try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(a),s.blob=i.getBlob("application/zip").size===0}catch{s.blob=!1}}}try{s.nodestream=!!n("readable-stream").Readable}catch{s.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,s){for(var a=n("./utils"),i=n("./support"),l=n("./nodejsUtils"),c=n("./stream/GenericWorker"),u=new Array(256),h=0;h<256;h++)u[h]=252<=h?6:248<=h?5:240<=h?4:224<=h?3:192<=h?2:1;u[254]=u[254]=1;function f(){c.call(this,"utf-8 decode"),this.leftOver=null}function p(){c.call(this,"utf-8 encode")}s.utf8encode=function(m){return i.nodebuffer?l.newBufferFrom(m,"utf-8"):function(v){var g,x,w,y,C,S=v.length,j=0;for(y=0;y<S;y++)(64512&(x=v.charCodeAt(y)))==55296&&y+1<S&&(64512&(w=v.charCodeAt(y+1)))==56320&&(x=65536+(x-55296<<10)+(w-56320),y++),j+=x<128?1:x<2048?2:x<65536?3:4;for(g=i.uint8array?new Uint8Array(j):new Array(j),y=C=0;C<j;y++)(64512&(x=v.charCodeAt(y)))==55296&&y+1<S&&(64512&(w=v.charCodeAt(y+1)))==56320&&(x=65536+(x-55296<<10)+(w-56320),y++),x<128?g[C++]=x:(x<2048?g[C++]=192|x>>>6:(x<65536?g[C++]=224|x>>>12:(g[C++]=240|x>>>18,g[C++]=128|x>>>12&63),g[C++]=128|x>>>6&63),g[C++]=128|63&x);return g}(m)},s.utf8decode=function(m){return i.nodebuffer?a.transformTo("nodebuffer",m).toString("utf-8"):function(v){var g,x,w,y,C=v.length,S=new Array(2*C);for(g=x=0;g<C;)if((w=v[g++])<128)S[x++]=w;else if(4<(y=u[w]))S[x++]=65533,g+=y-1;else{for(w&=y===2?31:y===3?15:7;1<y&&g<C;)w=w<<6|63&v[g++],y--;1<y?S[x++]=65533:w<65536?S[x++]=w:(w-=65536,S[x++]=55296|w>>10&1023,S[x++]=56320|1023&w)}return S.length!==x&&(S.subarray?S=S.subarray(0,x):S.length=x),a.applyFromCharCode(S)}(m=a.transformTo(i.uint8array?"uint8array":"array",m))},a.inherits(f,c),f.prototype.processChunk=function(m){var v=a.transformTo(i.uint8array?"uint8array":"array",m.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var g=v;(v=new Uint8Array(g.length+this.leftOver.length)).set(this.leftOver,0),v.set(g,this.leftOver.length)}else v=this.leftOver.concat(v);this.leftOver=null}var x=function(y,C){var S;for((C=C||y.length)>y.length&&(C=y.length),S=C-1;0<=S&&(192&y[S])==128;)S--;return S<0||S===0?C:S+u[y[S]]>C?S:C}(v),w=v;x!==v.length&&(i.uint8array?(w=v.subarray(0,x),this.leftOver=v.subarray(x,v.length)):(w=v.slice(0,x),this.leftOver=v.slice(x,v.length))),this.push({data:s.utf8decode(w),meta:m.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:s.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},s.Utf8DecodeWorker=f,a.inherits(p,c),p.prototype.processChunk=function(m){this.push({data:s.utf8encode(m.data),meta:m.meta})},s.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,s){var a=n("./support"),i=n("./base64"),l=n("./nodejsUtils"),c=n("./external");function u(g){return g}function h(g,x){for(var w=0;w<g.length;++w)x[w]=255&g.charCodeAt(w);return x}n("setimmediate"),s.newBlob=function(g,x){s.checkSupport("blob");try{return new Blob([g],{type:x})}catch{try{var w=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return w.append(g),w.getBlob(x)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(g,x,w){var y=[],C=0,S=g.length;if(S<=w)return String.fromCharCode.apply(null,g);for(;C<S;)x==="array"||x==="nodebuffer"?y.push(String.fromCharCode.apply(null,g.slice(C,Math.min(C+w,S)))):y.push(String.fromCharCode.apply(null,g.subarray(C,Math.min(C+w,S)))),C+=w;return y.join("")},stringifyByChar:function(g){for(var x="",w=0;w<g.length;w++)x+=String.fromCharCode(g[w]);return x},applyCanBeUsed:{uint8array:function(){try{return a.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}}(),nodebuffer:function(){try{return a.nodebuffer&&String.fromCharCode.apply(null,l.allocBuffer(1)).length===1}catch{return!1}}()}};function p(g){var x=65536,w=s.getTypeOf(g),y=!0;if(w==="uint8array"?y=f.applyCanBeUsed.uint8array:w==="nodebuffer"&&(y=f.applyCanBeUsed.nodebuffer),y)for(;1<x;)try{return f.stringifyByChunk(g,w,x)}catch{x=Math.floor(x/2)}return f.stringifyByChar(g)}function m(g,x){for(var w=0;w<g.length;w++)x[w]=g[w];return x}s.applyFromCharCode=p;var v={};v.string={string:u,array:function(g){return h(g,new Array(g.length))},arraybuffer:function(g){return v.string.uint8array(g).buffer},uint8array:function(g){return h(g,new Uint8Array(g.length))},nodebuffer:function(g){return h(g,l.allocBuffer(g.length))}},v.array={string:p,array:u,arraybuffer:function(g){return new Uint8Array(g).buffer},uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return l.newBufferFrom(g)}},v.arraybuffer={string:function(g){return p(new Uint8Array(g))},array:function(g){return m(new Uint8Array(g),new Array(g.byteLength))},arraybuffer:u,uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return l.newBufferFrom(new Uint8Array(g))}},v.uint8array={string:p,array:function(g){return m(g,new Array(g.length))},arraybuffer:function(g){return g.buffer},uint8array:u,nodebuffer:function(g){return l.newBufferFrom(g)}},v.nodebuffer={string:p,array:function(g){return m(g,new Array(g.length))},arraybuffer:function(g){return v.nodebuffer.uint8array(g).buffer},uint8array:function(g){return m(g,new Uint8Array(g.length))},nodebuffer:u},s.transformTo=function(g,x){if(x=x||"",!g)return x;s.checkSupport(g);var w=s.getTypeOf(x);return v[w][g](x)},s.resolve=function(g){for(var x=g.split("/"),w=[],y=0;y<x.length;y++){var C=x[y];C==="."||C===""&&y!==0&&y!==x.length-1||(C===".."?w.pop():w.push(C))}return w.join("/")},s.getTypeOf=function(g){return typeof g=="string"?"string":Object.prototype.toString.call(g)==="[object Array]"?"array":a.nodebuffer&&l.isBuffer(g)?"nodebuffer":a.uint8array&&g instanceof Uint8Array?"uint8array":a.arraybuffer&&g instanceof ArrayBuffer?"arraybuffer":void 0},s.checkSupport=function(g){if(!a[g.toLowerCase()])throw new Error(g+" is not supported by this platform")},s.MAX_VALUE_16BITS=65535,s.MAX_VALUE_32BITS=-1,s.pretty=function(g){var x,w,y="";for(w=0;w<(g||"").length;w++)y+="\\x"+((x=g.charCodeAt(w))<16?"0":"")+x.toString(16).toUpperCase();return y},s.delay=function(g,x,w){setImmediate(function(){g.apply(w||null,x||[])})},s.inherits=function(g,x){function w(){}w.prototype=x.prototype,g.prototype=new w},s.extend=function(){var g,x,w={};for(g=0;g<arguments.length;g++)for(x in arguments[g])Object.prototype.hasOwnProperty.call(arguments[g],x)&&w[x]===void 0&&(w[x]=arguments[g][x]);return w},s.prepareContent=function(g,x,w,y,C){return c.Promise.resolve(x).then(function(S){return a.blob&&(S instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(S))!==-1)&&typeof FileReader<"u"?new c.Promise(function(j,I){var b=new FileReader;b.onload=function(k){j(k.target.result)},b.onerror=function(k){I(k.target.error)},b.readAsArrayBuffer(S)}):S}).then(function(S){var j=s.getTypeOf(S);return j?(j==="arraybuffer"?S=s.transformTo("uint8array",S):j==="string"&&(C?S=i.decode(S):w&&y!==!0&&(S=function(I){return h(I,a.uint8array?new Uint8Array(I.length):new Array(I.length))}(S))),S):c.Promise.reject(new Error("Can't read the data of '"+g+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,s){var a=n("./reader/readerFor"),i=n("./utils"),l=n("./signature"),c=n("./zipEntry"),u=n("./support");function h(f){this.files=[],this.loadOptions=f}h.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var p=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+i.pretty(p)+", expected "+i.pretty(f)+")")}},isSignature:function(f,p){var m=this.reader.index;this.reader.setIndex(f);var v=this.reader.readString(4)===p;return this.reader.setIndex(m),v},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),p=u.uint8array?"uint8array":"array",m=i.transformTo(p,f);this.zipComment=this.loadOptions.decodeFileName(m)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,p,m,v=this.zip64EndOfCentralSize-44;0<v;)f=this.reader.readInt(2),p=this.reader.readInt(4),m=this.reader.readData(p),this.zip64ExtensibleData[f]={id:f,length:p,value:m}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,p;for(f=0;f<this.files.length;f++)p=this.files[f],this.reader.setIndex(p.localHeaderOffset),this.checkSignature(l.LOCAL_FILE_HEADER),p.readLocalPart(this.reader),p.handleUTF8(),p.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(l.CENTRAL_FILE_HEADER);)(f=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var f=this.reader.lastIndexOfSignature(l.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,l.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var p=f;if(this.checkSignature(l.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===i.MAX_VALUE_16BITS||this.diskWithCentralDirStart===i.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===i.MAX_VALUE_16BITS||this.centralDirRecords===i.MAX_VALUE_16BITS||this.centralDirSize===i.MAX_VALUE_32BITS||this.centralDirOffset===i.MAX_VALUE_32BITS){if(this.zip64=!0,(f=this.reader.lastIndexOfSignature(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(f),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,l.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var m=this.centralDirOffset+this.centralDirSize;this.zip64&&(m+=20,m+=12+this.zip64EndOfCentralSize);var v=p-m;if(0<v)this.isSignature(p,l.CENTRAL_FILE_HEADER)||(this.reader.zero=v);else if(v<0)throw new Error("Corrupted zip: missing "+Math.abs(v)+" bytes.")},prepareReader:function(f){this.reader=a(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=h},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,s){var a=n("./reader/readerFor"),i=n("./utils"),l=n("./compressedObject"),c=n("./crc32"),u=n("./utf8"),h=n("./compressions"),f=n("./support");function p(m,v){this.options=m,this.loadOptions=v}p.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(m){var v,g;if(m.skip(22),this.fileNameLength=m.readInt(2),g=m.readInt(2),this.fileName=m.readData(this.fileNameLength),m.skip(g),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((v=function(x){for(var w in h)if(Object.prototype.hasOwnProperty.call(h,w)&&h[w].magic===x)return h[w];return null}(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+i.pretty(this.compressionMethod)+" unknown (inner file : "+i.transformTo("string",this.fileName)+")");this.decompressed=new l(this.compressedSize,this.uncompressedSize,this.crc32,v,m.readData(this.compressedSize))},readCentralPart:function(m){this.versionMadeBy=m.readInt(2),m.skip(2),this.bitFlag=m.readInt(2),this.compressionMethod=m.readString(2),this.date=m.readDate(),this.crc32=m.readInt(4),this.compressedSize=m.readInt(4),this.uncompressedSize=m.readInt(4);var v=m.readInt(2);if(this.extraFieldsLength=m.readInt(2),this.fileCommentLength=m.readInt(2),this.diskNumberStart=m.readInt(2),this.internalFileAttributes=m.readInt(2),this.externalFileAttributes=m.readInt(4),this.localHeaderOffset=m.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");m.skip(v),this.readExtraFields(m),this.parseZIP64ExtraField(m),this.fileComment=m.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var m=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),m==0&&(this.dosPermissions=63&this.externalFileAttributes),m==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var m=a(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=m.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=m.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=m.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=m.readInt(4))}},readExtraFields:function(m){var v,g,x,w=m.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});m.index+4<w;)v=m.readInt(2),g=m.readInt(2),x=m.readData(g),this.extraFields[v]={id:v,length:g,value:x};m.setIndex(w)},handleUTF8:function(){var m=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var v=this.findExtraFieldUnicodePath();if(v!==null)this.fileNameStr=v;else{var g=i.transformTo(m,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(g)}var x=this.findExtraFieldUnicodeComment();if(x!==null)this.fileCommentStr=x;else{var w=i.transformTo(m,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(w)}}},findExtraFieldUnicodePath:function(){var m=this.extraFields[28789];if(m){var v=a(m.value);return v.readInt(1)!==1||c(this.fileName)!==v.readInt(4)?null:u.utf8decode(v.readData(m.length-5))}return null},findExtraFieldUnicodeComment:function(){var m=this.extraFields[25461];if(m){var v=a(m.value);return v.readInt(1)!==1||c(this.fileComment)!==v.readInt(4)?null:u.utf8decode(v.readData(m.length-5))}return null}},r.exports=p},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,s){function a(v,g,x){this.name=v,this.dir=x.dir,this.date=x.date,this.comment=x.comment,this.unixPermissions=x.unixPermissions,this.dosPermissions=x.dosPermissions,this._data=g,this._dataBinary=x.binary,this.options={compression:x.compression,compressionOptions:x.compressionOptions}}var i=n("./stream/StreamHelper"),l=n("./stream/DataWorker"),c=n("./utf8"),u=n("./compressedObject"),h=n("./stream/GenericWorker");a.prototype={internalStream:function(v){var g=null,x="string";try{if(!v)throw new Error("No output type specified.");var w=(x=v.toLowerCase())==="string"||x==="text";x!=="binarystring"&&x!=="text"||(x="string"),g=this._decompressWorker();var y=!this._dataBinary;y&&!w&&(g=g.pipe(new c.Utf8EncodeWorker)),!y&&w&&(g=g.pipe(new c.Utf8DecodeWorker))}catch(C){(g=new h("error")).error(C)}return new i(g,x,"")},async:function(v,g){return this.internalStream(v).accumulate(g)},nodeStream:function(v,g){return this.internalStream(v||"nodebuffer").toNodejsStream(g)},_compressWorker:function(v,g){if(this._data instanceof u&&this._data.compression.magic===v.magic)return this._data.getCompressedWorker();var x=this._decompressWorker();return this._dataBinary||(x=x.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(x,v,g)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof h?this._data:new l(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],p=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},m=0;m<f.length;m++)a.prototype[f[m]]=p;r.exports=a},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,s){(function(a){var i,l,c=a.MutationObserver||a.WebKitMutationObserver;if(c){var u=0,h=new c(v),f=a.document.createTextNode("");h.observe(f,{characterData:!0}),i=function(){f.data=u=++u%2}}else if(a.setImmediate||a.MessageChannel===void 0)i="document"in a&&"onreadystatechange"in a.document.createElement("script")?function(){var g=a.document.createElement("script");g.onreadystatechange=function(){v(),g.onreadystatechange=null,g.parentNode.removeChild(g),g=null},a.document.documentElement.appendChild(g)}:function(){setTimeout(v,0)};else{var p=new a.MessageChannel;p.port1.onmessage=v,i=function(){p.port2.postMessage(0)}}var m=[];function v(){var g,x;l=!0;for(var w=m.length;w;){for(x=m,m=[],g=-1;++g<w;)x[g]();w=m.length}l=!1}r.exports=function(g){m.push(g)!==1||l||i()}}).call(this,typeof Fl<"u"?Fl:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,s){var a=n("immediate");function i(){}var l={},c=["REJECTED"],u=["FULFILLED"],h=["PENDING"];function f(w){if(typeof w!="function")throw new TypeError("resolver must be a function");this.state=h,this.queue=[],this.outcome=void 0,w!==i&&g(this,w)}function p(w,y,C){this.promise=w,typeof y=="function"&&(this.onFulfilled=y,this.callFulfilled=this.otherCallFulfilled),typeof C=="function"&&(this.onRejected=C,this.callRejected=this.otherCallRejected)}function m(w,y,C){a(function(){var S;try{S=y(C)}catch(j){return l.reject(w,j)}S===w?l.reject(w,new TypeError("Cannot resolve promise with itself")):l.resolve(w,S)})}function v(w){var y=w&&w.then;if(w&&(typeof w=="object"||typeof w=="function")&&typeof y=="function")return function(){y.apply(w,arguments)}}function g(w,y){var C=!1;function S(b){C||(C=!0,l.reject(w,b))}function j(b){C||(C=!0,l.resolve(w,b))}var I=x(function(){y(j,S)});I.status==="error"&&S(I.value)}function x(w,y){var C={};try{C.value=w(y),C.status="success"}catch(S){C.status="error",C.value=S}return C}(r.exports=f).prototype.finally=function(w){if(typeof w!="function")return this;var y=this.constructor;return this.then(function(C){return y.resolve(w()).then(function(){return C})},function(C){return y.resolve(w()).then(function(){throw C})})},f.prototype.catch=function(w){return this.then(null,w)},f.prototype.then=function(w,y){if(typeof w!="function"&&this.state===u||typeof y!="function"&&this.state===c)return this;var C=new this.constructor(i);return this.state!==h?m(C,this.state===u?w:y,this.outcome):this.queue.push(new p(C,w,y)),C},p.prototype.callFulfilled=function(w){l.resolve(this.promise,w)},p.prototype.otherCallFulfilled=function(w){m(this.promise,this.onFulfilled,w)},p.prototype.callRejected=function(w){l.reject(this.promise,w)},p.prototype.otherCallRejected=function(w){m(this.promise,this.onRejected,w)},l.resolve=function(w,y){var C=x(v,y);if(C.status==="error")return l.reject(w,C.value);var S=C.value;if(S)g(w,S);else{w.state=u,w.outcome=y;for(var j=-1,I=w.queue.length;++j<I;)w.queue[j].callFulfilled(y)}return w},l.reject=function(w,y){w.state=c,w.outcome=y;for(var C=-1,S=w.queue.length;++C<S;)w.queue[C].callRejected(y);return w},f.resolve=function(w){return w instanceof this?w:l.resolve(new this(i),w)},f.reject=function(w){var y=new this(i);return l.reject(y,w)},f.all=function(w){var y=this;if(Object.prototype.toString.call(w)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=w.length,S=!1;if(!C)return this.resolve([]);for(var j=new Array(C),I=0,b=-1,k=new this(i);++b<C;)N(w[b],b);return k;function N(A,P){y.resolve(A).then(function(E){j[P]=E,++I!==C||S||(S=!0,l.resolve(k,j))},function(E){S||(S=!0,l.reject(k,E))})}},f.race=function(w){var y=this;if(Object.prototype.toString.call(w)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=w.length,S=!1;if(!C)return this.resolve([]);for(var j=-1,I=new this(i);++j<C;)b=w[j],y.resolve(b).then(function(k){S||(S=!0,l.resolve(I,k))},function(k){S||(S=!0,l.reject(I,k))});var b;return I}},{immediate:36}],38:[function(n,r,s){var a={};(0,n("./lib/utils/common").assign)(a,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=a},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,s){var a=n("./zlib/deflate"),i=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/messages"),u=n("./zlib/zstream"),h=Object.prototype.toString,f=0,p=-1,m=0,v=8;function g(w){if(!(this instanceof g))return new g(w);this.options=i.assign({level:p,method:v,chunkSize:16384,windowBits:15,memLevel:8,strategy:m,to:""},w||{});var y=this.options;y.raw&&0<y.windowBits?y.windowBits=-y.windowBits:y.gzip&&0<y.windowBits&&y.windowBits<16&&(y.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var C=a.deflateInit2(this.strm,y.level,y.method,y.windowBits,y.memLevel,y.strategy);if(C!==f)throw new Error(c[C]);if(y.header&&a.deflateSetHeader(this.strm,y.header),y.dictionary){var S;if(S=typeof y.dictionary=="string"?l.string2buf(y.dictionary):h.call(y.dictionary)==="[object ArrayBuffer]"?new Uint8Array(y.dictionary):y.dictionary,(C=a.deflateSetDictionary(this.strm,S))!==f)throw new Error(c[C]);this._dict_set=!0}}function x(w,y){var C=new g(y);if(C.push(w,!0),C.err)throw C.msg||c[C.err];return C.result}g.prototype.push=function(w,y){var C,S,j=this.strm,I=this.options.chunkSize;if(this.ended)return!1;S=y===~~y?y:y===!0?4:0,typeof w=="string"?j.input=l.string2buf(w):h.call(w)==="[object ArrayBuffer]"?j.input=new Uint8Array(w):j.input=w,j.next_in=0,j.avail_in=j.input.length;do{if(j.avail_out===0&&(j.output=new i.Buf8(I),j.next_out=0,j.avail_out=I),(C=a.deflate(j,S))!==1&&C!==f)return this.onEnd(C),!(this.ended=!0);j.avail_out!==0&&(j.avail_in!==0||S!==4&&S!==2)||(this.options.to==="string"?this.onData(l.buf2binstring(i.shrinkBuf(j.output,j.next_out))):this.onData(i.shrinkBuf(j.output,j.next_out)))}while((0<j.avail_in||j.avail_out===0)&&C!==1);return S===4?(C=a.deflateEnd(this.strm),this.onEnd(C),this.ended=!0,C===f):S!==2||(this.onEnd(f),!(j.avail_out=0))},g.prototype.onData=function(w){this.chunks.push(w)},g.prototype.onEnd=function(w){w===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=w,this.msg=this.strm.msg},s.Deflate=g,s.deflate=x,s.deflateRaw=function(w,y){return(y=y||{}).raw=!0,x(w,y)},s.gzip=function(w,y){return(y=y||{}).gzip=!0,x(w,y)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,s){var a=n("./zlib/inflate"),i=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/constants"),u=n("./zlib/messages"),h=n("./zlib/zstream"),f=n("./zlib/gzheader"),p=Object.prototype.toString;function m(g){if(!(this instanceof m))return new m(g);this.options=i.assign({chunkSize:16384,windowBits:0,to:""},g||{});var x=this.options;x.raw&&0<=x.windowBits&&x.windowBits<16&&(x.windowBits=-x.windowBits,x.windowBits===0&&(x.windowBits=-15)),!(0<=x.windowBits&&x.windowBits<16)||g&&g.windowBits||(x.windowBits+=32),15<x.windowBits&&x.windowBits<48&&(15&x.windowBits)==0&&(x.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new h,this.strm.avail_out=0;var w=a.inflateInit2(this.strm,x.windowBits);if(w!==c.Z_OK)throw new Error(u[w]);this.header=new f,a.inflateGetHeader(this.strm,this.header)}function v(g,x){var w=new m(x);if(w.push(g,!0),w.err)throw w.msg||u[w.err];return w.result}m.prototype.push=function(g,x){var w,y,C,S,j,I,b=this.strm,k=this.options.chunkSize,N=this.options.dictionary,A=!1;if(this.ended)return!1;y=x===~~x?x:x===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof g=="string"?b.input=l.binstring2buf(g):p.call(g)==="[object ArrayBuffer]"?b.input=new Uint8Array(g):b.input=g,b.next_in=0,b.avail_in=b.input.length;do{if(b.avail_out===0&&(b.output=new i.Buf8(k),b.next_out=0,b.avail_out=k),(w=a.inflate(b,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&N&&(I=typeof N=="string"?l.string2buf(N):p.call(N)==="[object ArrayBuffer]"?new Uint8Array(N):N,w=a.inflateSetDictionary(this.strm,I)),w===c.Z_BUF_ERROR&&A===!0&&(w=c.Z_OK,A=!1),w!==c.Z_STREAM_END&&w!==c.Z_OK)return this.onEnd(w),!(this.ended=!0);b.next_out&&(b.avail_out!==0&&w!==c.Z_STREAM_END&&(b.avail_in!==0||y!==c.Z_FINISH&&y!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(C=l.utf8border(b.output,b.next_out),S=b.next_out-C,j=l.buf2string(b.output,C),b.next_out=S,b.avail_out=k-S,S&&i.arraySet(b.output,b.output,C,S,0),this.onData(j)):this.onData(i.shrinkBuf(b.output,b.next_out)))),b.avail_in===0&&b.avail_out===0&&(A=!0)}while((0<b.avail_in||b.avail_out===0)&&w!==c.Z_STREAM_END);return w===c.Z_STREAM_END&&(y=c.Z_FINISH),y===c.Z_FINISH?(w=a.inflateEnd(this.strm),this.onEnd(w),this.ended=!0,w===c.Z_OK):y!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(b.avail_out=0))},m.prototype.onData=function(g){this.chunks.push(g)},m.prototype.onEnd=function(g){g===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=g,this.msg=this.strm.msg},s.Inflate=m,s.inflate=v,s.inflateRaw=function(g,x){return(x=x||{}).raw=!0,v(g,x)},s.ungzip=v},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,s){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";s.assign=function(c){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var h=u.shift();if(h){if(typeof h!="object")throw new TypeError(h+"must be non-object");for(var f in h)h.hasOwnProperty(f)&&(c[f]=h[f])}}return c},s.shrinkBuf=function(c,u){return c.length===u?c:c.subarray?c.subarray(0,u):(c.length=u,c)};var i={arraySet:function(c,u,h,f,p){if(u.subarray&&c.subarray)c.set(u.subarray(h,h+f),p);else for(var m=0;m<f;m++)c[p+m]=u[h+m]},flattenChunks:function(c){var u,h,f,p,m,v;for(u=f=0,h=c.length;u<h;u++)f+=c[u].length;for(v=new Uint8Array(f),u=p=0,h=c.length;u<h;u++)m=c[u],v.set(m,p),p+=m.length;return v}},l={arraySet:function(c,u,h,f,p){for(var m=0;m<f;m++)c[p+m]=u[h+m]},flattenChunks:function(c){return[].concat.apply([],c)}};s.setTyped=function(c){c?(s.Buf8=Uint8Array,s.Buf16=Uint16Array,s.Buf32=Int32Array,s.assign(s,i)):(s.Buf8=Array,s.Buf16=Array,s.Buf32=Array,s.assign(s,l))},s.setTyped(a)},{}],42:[function(n,r,s){var a=n("./common"),i=!0,l=!0;try{String.fromCharCode.apply(null,[0])}catch{i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{l=!1}for(var c=new a.Buf8(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function h(f,p){if(p<65537&&(f.subarray&&l||!f.subarray&&i))return String.fromCharCode.apply(null,a.shrinkBuf(f,p));for(var m="",v=0;v<p;v++)m+=String.fromCharCode(f[v]);return m}c[254]=c[254]=1,s.string2buf=function(f){var p,m,v,g,x,w=f.length,y=0;for(g=0;g<w;g++)(64512&(m=f.charCodeAt(g)))==55296&&g+1<w&&(64512&(v=f.charCodeAt(g+1)))==56320&&(m=65536+(m-55296<<10)+(v-56320),g++),y+=m<128?1:m<2048?2:m<65536?3:4;for(p=new a.Buf8(y),g=x=0;x<y;g++)(64512&(m=f.charCodeAt(g)))==55296&&g+1<w&&(64512&(v=f.charCodeAt(g+1)))==56320&&(m=65536+(m-55296<<10)+(v-56320),g++),m<128?p[x++]=m:(m<2048?p[x++]=192|m>>>6:(m<65536?p[x++]=224|m>>>12:(p[x++]=240|m>>>18,p[x++]=128|m>>>12&63),p[x++]=128|m>>>6&63),p[x++]=128|63&m);return p},s.buf2binstring=function(f){return h(f,f.length)},s.binstring2buf=function(f){for(var p=new a.Buf8(f.length),m=0,v=p.length;m<v;m++)p[m]=f.charCodeAt(m);return p},s.buf2string=function(f,p){var m,v,g,x,w=p||f.length,y=new Array(2*w);for(m=v=0;m<w;)if((g=f[m++])<128)y[v++]=g;else if(4<(x=c[g]))y[v++]=65533,m+=x-1;else{for(g&=x===2?31:x===3?15:7;1<x&&m<w;)g=g<<6|63&f[m++],x--;1<x?y[v++]=65533:g<65536?y[v++]=g:(g-=65536,y[v++]=55296|g>>10&1023,y[v++]=56320|1023&g)}return h(y,v)},s.utf8border=function(f,p){var m;for((p=p||f.length)>f.length&&(p=f.length),m=p-1;0<=m&&(192&f[m])==128;)m--;return m<0||m===0?p:m+c[f[m]]>p?m:p}},{"./common":41}],43:[function(n,r,s){r.exports=function(a,i,l,c){for(var u=65535&a|0,h=a>>>16&65535|0,f=0;l!==0;){for(l-=f=2e3<l?2e3:l;h=h+(u=u+i[c++]|0)|0,--f;);u%=65521,h%=65521}return u|h<<16|0}},{}],44:[function(n,r,s){r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,s){var a=function(){for(var i,l=[],c=0;c<256;c++){i=c;for(var u=0;u<8;u++)i=1&i?3988292384^i>>>1:i>>>1;l[c]=i}return l}();r.exports=function(i,l,c,u){var h=a,f=u+c;i^=-1;for(var p=u;p<f;p++)i=i>>>8^h[255&(i^l[p])];return-1^i}},{}],46:[function(n,r,s){var a,i=n("../utils/common"),l=n("./trees"),c=n("./adler32"),u=n("./crc32"),h=n("./messages"),f=0,p=4,m=0,v=-2,g=-1,x=4,w=2,y=8,C=9,S=286,j=30,I=19,b=2*S+1,k=15,N=3,A=258,P=A+N+1,E=42,R=113,_=1,M=2,L=3,F=4;function D(T,le){return T.msg=h[le],le}function O(T){return(T<<1)-(4<T?9:0)}function K(T){for(var le=T.length;0<=--le;)T[le]=0}function $(T){var le=T.state,ie=le.pending;ie>T.avail_out&&(ie=T.avail_out),ie!==0&&(i.arraySet(T.output,le.pending_buf,le.pending_out,ie,T.next_out),T.next_out+=ie,le.pending_out+=ie,T.total_out+=ie,T.avail_out-=ie,le.pending-=ie,le.pending===0&&(le.pending_out=0))}function W(T,le){l._tr_flush_block(T,0<=T.block_start?T.block_start:-1,T.strstart-T.block_start,le),T.block_start=T.strstart,$(T.strm)}function V(T,le){T.pending_buf[T.pending++]=le}function X(T,le){T.pending_buf[T.pending++]=le>>>8&255,T.pending_buf[T.pending++]=255&le}function H(T,le){var ie,q,B=T.max_chain_length,ee=T.strstart,U=T.prev_length,Y=T.nice_match,G=T.strstart>T.w_size-P?T.strstart-(T.w_size-P):0,ae=T.window,oe=T.w_mask,se=T.prev,me=T.strstart+A,Pe=ae[ee+U-1],Ne=ae[ee+U];T.prev_length>=T.good_match&&(B>>=2),Y>T.lookahead&&(Y=T.lookahead);do if(ae[(ie=le)+U]===Ne&&ae[ie+U-1]===Pe&&ae[ie]===ae[ee]&&ae[++ie]===ae[ee+1]){ee+=2,ie++;do;while(ae[++ee]===ae[++ie]&&ae[++ee]===ae[++ie]&&ae[++ee]===ae[++ie]&&ae[++ee]===ae[++ie]&&ae[++ee]===ae[++ie]&&ae[++ee]===ae[++ie]&&ae[++ee]===ae[++ie]&&ae[++ee]===ae[++ie]&&ee<me);if(q=A-(me-ee),ee=me-A,U<q){if(T.match_start=le,Y<=(U=q))break;Pe=ae[ee+U-1],Ne=ae[ee+U]}}while((le=se[le&oe])>G&&--B!=0);return U<=T.lookahead?U:T.lookahead}function Q(T){var le,ie,q,B,ee,U,Y,G,ae,oe,se=T.w_size;do{if(B=T.window_size-T.lookahead-T.strstart,T.strstart>=se+(se-P)){for(i.arraySet(T.window,T.window,se,se,0),T.match_start-=se,T.strstart-=se,T.block_start-=se,le=ie=T.hash_size;q=T.head[--le],T.head[le]=se<=q?q-se:0,--ie;);for(le=ie=se;q=T.prev[--le],T.prev[le]=se<=q?q-se:0,--ie;);B+=se}if(T.strm.avail_in===0)break;if(U=T.strm,Y=T.window,G=T.strstart+T.lookahead,ae=B,oe=void 0,oe=U.avail_in,ae<oe&&(oe=ae),ie=oe===0?0:(U.avail_in-=oe,i.arraySet(Y,U.input,U.next_in,oe,G),U.state.wrap===1?U.adler=c(U.adler,Y,oe,G):U.state.wrap===2&&(U.adler=u(U.adler,Y,oe,G)),U.next_in+=oe,U.total_in+=oe,oe),T.lookahead+=ie,T.lookahead+T.insert>=N)for(ee=T.strstart-T.insert,T.ins_h=T.window[ee],T.ins_h=(T.ins_h<<T.hash_shift^T.window[ee+1])&T.hash_mask;T.insert&&(T.ins_h=(T.ins_h<<T.hash_shift^T.window[ee+N-1])&T.hash_mask,T.prev[ee&T.w_mask]=T.head[T.ins_h],T.head[T.ins_h]=ee,ee++,T.insert--,!(T.lookahead+T.insert<N)););}while(T.lookahead<P&&T.strm.avail_in!==0)}function z(T,le){for(var ie,q;;){if(T.lookahead<P){if(Q(T),T.lookahead<P&&le===f)return _;if(T.lookahead===0)break}if(ie=0,T.lookahead>=N&&(T.ins_h=(T.ins_h<<T.hash_shift^T.window[T.strstart+N-1])&T.hash_mask,ie=T.prev[T.strstart&T.w_mask]=T.head[T.ins_h],T.head[T.ins_h]=T.strstart),ie!==0&&T.strstart-ie<=T.w_size-P&&(T.match_length=H(T,ie)),T.match_length>=N)if(q=l._tr_tally(T,T.strstart-T.match_start,T.match_length-N),T.lookahead-=T.match_length,T.match_length<=T.max_lazy_match&&T.lookahead>=N){for(T.match_length--;T.strstart++,T.ins_h=(T.ins_h<<T.hash_shift^T.window[T.strstart+N-1])&T.hash_mask,ie=T.prev[T.strstart&T.w_mask]=T.head[T.ins_h],T.head[T.ins_h]=T.strstart,--T.match_length!=0;);T.strstart++}else T.strstart+=T.match_length,T.match_length=0,T.ins_h=T.window[T.strstart],T.ins_h=(T.ins_h<<T.hash_shift^T.window[T.strstart+1])&T.hash_mask;else q=l._tr_tally(T,0,T.window[T.strstart]),T.lookahead--,T.strstart++;if(q&&(W(T,!1),T.strm.avail_out===0))return _}return T.insert=T.strstart<N-1?T.strstart:N-1,le===p?(W(T,!0),T.strm.avail_out===0?L:F):T.last_lit&&(W(T,!1),T.strm.avail_out===0)?_:M}function Z(T,le){for(var ie,q,B;;){if(T.lookahead<P){if(Q(T),T.lookahead<P&&le===f)return _;if(T.lookahead===0)break}if(ie=0,T.lookahead>=N&&(T.ins_h=(T.ins_h<<T.hash_shift^T.window[T.strstart+N-1])&T.hash_mask,ie=T.prev[T.strstart&T.w_mask]=T.head[T.ins_h],T.head[T.ins_h]=T.strstart),T.prev_length=T.match_length,T.prev_match=T.match_start,T.match_length=N-1,ie!==0&&T.prev_length<T.max_lazy_match&&T.strstart-ie<=T.w_size-P&&(T.match_length=H(T,ie),T.match_length<=5&&(T.strategy===1||T.match_length===N&&4096<T.strstart-T.match_start)&&(T.match_length=N-1)),T.prev_length>=N&&T.match_length<=T.prev_length){for(B=T.strstart+T.lookahead-N,q=l._tr_tally(T,T.strstart-1-T.prev_match,T.prev_length-N),T.lookahead-=T.prev_length-1,T.prev_length-=2;++T.strstart<=B&&(T.ins_h=(T.ins_h<<T.hash_shift^T.window[T.strstart+N-1])&T.hash_mask,ie=T.prev[T.strstart&T.w_mask]=T.head[T.ins_h],T.head[T.ins_h]=T.strstart),--T.prev_length!=0;);if(T.match_available=0,T.match_length=N-1,T.strstart++,q&&(W(T,!1),T.strm.avail_out===0))return _}else if(T.match_available){if((q=l._tr_tally(T,0,T.window[T.strstart-1]))&&W(T,!1),T.strstart++,T.lookahead--,T.strm.avail_out===0)return _}else T.match_available=1,T.strstart++,T.lookahead--}return T.match_available&&(q=l._tr_tally(T,0,T.window[T.strstart-1]),T.match_available=0),T.insert=T.strstart<N-1?T.strstart:N-1,le===p?(W(T,!0),T.strm.avail_out===0?L:F):T.last_lit&&(W(T,!1),T.strm.avail_out===0)?_:M}function J(T,le,ie,q,B){this.good_length=T,this.max_lazy=le,this.nice_length=ie,this.max_chain=q,this.func=B}function ce(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=y,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new i.Buf16(2*b),this.dyn_dtree=new i.Buf16(2*(2*j+1)),this.bl_tree=new i.Buf16(2*(2*I+1)),K(this.dyn_ltree),K(this.dyn_dtree),K(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new i.Buf16(k+1),this.heap=new i.Buf16(2*S+1),K(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i.Buf16(2*S+1),K(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function de(T){var le;return T&&T.state?(T.total_in=T.total_out=0,T.data_type=w,(le=T.state).pending=0,le.pending_out=0,le.wrap<0&&(le.wrap=-le.wrap),le.status=le.wrap?E:R,T.adler=le.wrap===2?0:1,le.last_flush=f,l._tr_init(le),m):D(T,v)}function fe(T){var le=de(T);return le===m&&function(ie){ie.window_size=2*ie.w_size,K(ie.head),ie.max_lazy_match=a[ie.level].max_lazy,ie.good_match=a[ie.level].good_length,ie.nice_match=a[ie.level].nice_length,ie.max_chain_length=a[ie.level].max_chain,ie.strstart=0,ie.block_start=0,ie.lookahead=0,ie.insert=0,ie.match_length=ie.prev_length=N-1,ie.match_available=0,ie.ins_h=0}(T.state),le}function ge(T,le,ie,q,B,ee){if(!T)return v;var U=1;if(le===g&&(le=6),q<0?(U=0,q=-q):15<q&&(U=2,q-=16),B<1||C<B||ie!==y||q<8||15<q||le<0||9<le||ee<0||x<ee)return D(T,v);q===8&&(q=9);var Y=new ce;return(T.state=Y).strm=T,Y.wrap=U,Y.gzhead=null,Y.w_bits=q,Y.w_size=1<<Y.w_bits,Y.w_mask=Y.w_size-1,Y.hash_bits=B+7,Y.hash_size=1<<Y.hash_bits,Y.hash_mask=Y.hash_size-1,Y.hash_shift=~~((Y.hash_bits+N-1)/N),Y.window=new i.Buf8(2*Y.w_size),Y.head=new i.Buf16(Y.hash_size),Y.prev=new i.Buf16(Y.w_size),Y.lit_bufsize=1<<B+6,Y.pending_buf_size=4*Y.lit_bufsize,Y.pending_buf=new i.Buf8(Y.pending_buf_size),Y.d_buf=1*Y.lit_bufsize,Y.l_buf=3*Y.lit_bufsize,Y.level=le,Y.strategy=ee,Y.method=ie,fe(T)}a=[new J(0,0,0,0,function(T,le){var ie=65535;for(ie>T.pending_buf_size-5&&(ie=T.pending_buf_size-5);;){if(T.lookahead<=1){if(Q(T),T.lookahead===0&&le===f)return _;if(T.lookahead===0)break}T.strstart+=T.lookahead,T.lookahead=0;var q=T.block_start+ie;if((T.strstart===0||T.strstart>=q)&&(T.lookahead=T.strstart-q,T.strstart=q,W(T,!1),T.strm.avail_out===0)||T.strstart-T.block_start>=T.w_size-P&&(W(T,!1),T.strm.avail_out===0))return _}return T.insert=0,le===p?(W(T,!0),T.strm.avail_out===0?L:F):(T.strstart>T.block_start&&(W(T,!1),T.strm.avail_out),_)}),new J(4,4,8,4,z),new J(4,5,16,8,z),new J(4,6,32,32,z),new J(4,4,16,16,Z),new J(8,16,32,32,Z),new J(8,16,128,128,Z),new J(8,32,128,256,Z),new J(32,128,258,1024,Z),new J(32,258,258,4096,Z)],s.deflateInit=function(T,le){return ge(T,le,y,15,8,0)},s.deflateInit2=ge,s.deflateReset=fe,s.deflateResetKeep=de,s.deflateSetHeader=function(T,le){return T&&T.state?T.state.wrap!==2?v:(T.state.gzhead=le,m):v},s.deflate=function(T,le){var ie,q,B,ee;if(!T||!T.state||5<le||le<0)return T?D(T,v):v;if(q=T.state,!T.output||!T.input&&T.avail_in!==0||q.status===666&&le!==p)return D(T,T.avail_out===0?-5:v);if(q.strm=T,ie=q.last_flush,q.last_flush=le,q.status===E)if(q.wrap===2)T.adler=0,V(q,31),V(q,139),V(q,8),q.gzhead?(V(q,(q.gzhead.text?1:0)+(q.gzhead.hcrc?2:0)+(q.gzhead.extra?4:0)+(q.gzhead.name?8:0)+(q.gzhead.comment?16:0)),V(q,255&q.gzhead.time),V(q,q.gzhead.time>>8&255),V(q,q.gzhead.time>>16&255),V(q,q.gzhead.time>>24&255),V(q,q.level===9?2:2<=q.strategy||q.level<2?4:0),V(q,255&q.gzhead.os),q.gzhead.extra&&q.gzhead.extra.length&&(V(q,255&q.gzhead.extra.length),V(q,q.gzhead.extra.length>>8&255)),q.gzhead.hcrc&&(T.adler=u(T.adler,q.pending_buf,q.pending,0)),q.gzindex=0,q.status=69):(V(q,0),V(q,0),V(q,0),V(q,0),V(q,0),V(q,q.level===9?2:2<=q.strategy||q.level<2?4:0),V(q,3),q.status=R);else{var U=y+(q.w_bits-8<<4)<<8;U|=(2<=q.strategy||q.level<2?0:q.level<6?1:q.level===6?2:3)<<6,q.strstart!==0&&(U|=32),U+=31-U%31,q.status=R,X(q,U),q.strstart!==0&&(X(q,T.adler>>>16),X(q,65535&T.adler)),T.adler=1}if(q.status===69)if(q.gzhead.extra){for(B=q.pending;q.gzindex<(65535&q.gzhead.extra.length)&&(q.pending!==q.pending_buf_size||(q.gzhead.hcrc&&q.pending>B&&(T.adler=u(T.adler,q.pending_buf,q.pending-B,B)),$(T),B=q.pending,q.pending!==q.pending_buf_size));)V(q,255&q.gzhead.extra[q.gzindex]),q.gzindex++;q.gzhead.hcrc&&q.pending>B&&(T.adler=u(T.adler,q.pending_buf,q.pending-B,B)),q.gzindex===q.gzhead.extra.length&&(q.gzindex=0,q.status=73)}else q.status=73;if(q.status===73)if(q.gzhead.name){B=q.pending;do{if(q.pending===q.pending_buf_size&&(q.gzhead.hcrc&&q.pending>B&&(T.adler=u(T.adler,q.pending_buf,q.pending-B,B)),$(T),B=q.pending,q.pending===q.pending_buf_size)){ee=1;break}ee=q.gzindex<q.gzhead.name.length?255&q.gzhead.name.charCodeAt(q.gzindex++):0,V(q,ee)}while(ee!==0);q.gzhead.hcrc&&q.pending>B&&(T.adler=u(T.adler,q.pending_buf,q.pending-B,B)),ee===0&&(q.gzindex=0,q.status=91)}else q.status=91;if(q.status===91)if(q.gzhead.comment){B=q.pending;do{if(q.pending===q.pending_buf_size&&(q.gzhead.hcrc&&q.pending>B&&(T.adler=u(T.adler,q.pending_buf,q.pending-B,B)),$(T),B=q.pending,q.pending===q.pending_buf_size)){ee=1;break}ee=q.gzindex<q.gzhead.comment.length?255&q.gzhead.comment.charCodeAt(q.gzindex++):0,V(q,ee)}while(ee!==0);q.gzhead.hcrc&&q.pending>B&&(T.adler=u(T.adler,q.pending_buf,q.pending-B,B)),ee===0&&(q.status=103)}else q.status=103;if(q.status===103&&(q.gzhead.hcrc?(q.pending+2>q.pending_buf_size&&$(T),q.pending+2<=q.pending_buf_size&&(V(q,255&T.adler),V(q,T.adler>>8&255),T.adler=0,q.status=R)):q.status=R),q.pending!==0){if($(T),T.avail_out===0)return q.last_flush=-1,m}else if(T.avail_in===0&&O(le)<=O(ie)&&le!==p)return D(T,-5);if(q.status===666&&T.avail_in!==0)return D(T,-5);if(T.avail_in!==0||q.lookahead!==0||le!==f&&q.status!==666){var Y=q.strategy===2?function(G,ae){for(var oe;;){if(G.lookahead===0&&(Q(G),G.lookahead===0)){if(ae===f)return _;break}if(G.match_length=0,oe=l._tr_tally(G,0,G.window[G.strstart]),G.lookahead--,G.strstart++,oe&&(W(G,!1),G.strm.avail_out===0))return _}return G.insert=0,ae===p?(W(G,!0),G.strm.avail_out===0?L:F):G.last_lit&&(W(G,!1),G.strm.avail_out===0)?_:M}(q,le):q.strategy===3?function(G,ae){for(var oe,se,me,Pe,Ne=G.window;;){if(G.lookahead<=A){if(Q(G),G.lookahead<=A&&ae===f)return _;if(G.lookahead===0)break}if(G.match_length=0,G.lookahead>=N&&0<G.strstart&&(se=Ne[me=G.strstart-1])===Ne[++me]&&se===Ne[++me]&&se===Ne[++me]){Pe=G.strstart+A;do;while(se===Ne[++me]&&se===Ne[++me]&&se===Ne[++me]&&se===Ne[++me]&&se===Ne[++me]&&se===Ne[++me]&&se===Ne[++me]&&se===Ne[++me]&&me<Pe);G.match_length=A-(Pe-me),G.match_length>G.lookahead&&(G.match_length=G.lookahead)}if(G.match_length>=N?(oe=l._tr_tally(G,1,G.match_length-N),G.lookahead-=G.match_length,G.strstart+=G.match_length,G.match_length=0):(oe=l._tr_tally(G,0,G.window[G.strstart]),G.lookahead--,G.strstart++),oe&&(W(G,!1),G.strm.avail_out===0))return _}return G.insert=0,ae===p?(W(G,!0),G.strm.avail_out===0?L:F):G.last_lit&&(W(G,!1),G.strm.avail_out===0)?_:M}(q,le):a[q.level].func(q,le);if(Y!==L&&Y!==F||(q.status=666),Y===_||Y===L)return T.avail_out===0&&(q.last_flush=-1),m;if(Y===M&&(le===1?l._tr_align(q):le!==5&&(l._tr_stored_block(q,0,0,!1),le===3&&(K(q.head),q.lookahead===0&&(q.strstart=0,q.block_start=0,q.insert=0))),$(T),T.avail_out===0))return q.last_flush=-1,m}return le!==p?m:q.wrap<=0?1:(q.wrap===2?(V(q,255&T.adler),V(q,T.adler>>8&255),V(q,T.adler>>16&255),V(q,T.adler>>24&255),V(q,255&T.total_in),V(q,T.total_in>>8&255),V(q,T.total_in>>16&255),V(q,T.total_in>>24&255)):(X(q,T.adler>>>16),X(q,65535&T.adler)),$(T),0<q.wrap&&(q.wrap=-q.wrap),q.pending!==0?m:1)},s.deflateEnd=function(T){var le;return T&&T.state?(le=T.state.status)!==E&&le!==69&&le!==73&&le!==91&&le!==103&&le!==R&&le!==666?D(T,v):(T.state=null,le===R?D(T,-3):m):v},s.deflateSetDictionary=function(T,le){var ie,q,B,ee,U,Y,G,ae,oe=le.length;if(!T||!T.state||(ee=(ie=T.state).wrap)===2||ee===1&&ie.status!==E||ie.lookahead)return v;for(ee===1&&(T.adler=c(T.adler,le,oe,0)),ie.wrap=0,oe>=ie.w_size&&(ee===0&&(K(ie.head),ie.strstart=0,ie.block_start=0,ie.insert=0),ae=new i.Buf8(ie.w_size),i.arraySet(ae,le,oe-ie.w_size,ie.w_size,0),le=ae,oe=ie.w_size),U=T.avail_in,Y=T.next_in,G=T.input,T.avail_in=oe,T.next_in=0,T.input=le,Q(ie);ie.lookahead>=N;){for(q=ie.strstart,B=ie.lookahead-(N-1);ie.ins_h=(ie.ins_h<<ie.hash_shift^ie.window[q+N-1])&ie.hash_mask,ie.prev[q&ie.w_mask]=ie.head[ie.ins_h],ie.head[ie.ins_h]=q,q++,--B;);ie.strstart=q,ie.lookahead=N-1,Q(ie)}return ie.strstart+=ie.lookahead,ie.block_start=ie.strstart,ie.insert=ie.lookahead,ie.lookahead=0,ie.match_length=ie.prev_length=N-1,ie.match_available=0,T.next_in=Y,T.input=G,T.avail_in=U,ie.wrap=ee,m},s.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,s){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,s){r.exports=function(a,i){var l,c,u,h,f,p,m,v,g,x,w,y,C,S,j,I,b,k,N,A,P,E,R,_,M;l=a.state,c=a.next_in,_=a.input,u=c+(a.avail_in-5),h=a.next_out,M=a.output,f=h-(i-a.avail_out),p=h+(a.avail_out-257),m=l.dmax,v=l.wsize,g=l.whave,x=l.wnext,w=l.window,y=l.hold,C=l.bits,S=l.lencode,j=l.distcode,I=(1<<l.lenbits)-1,b=(1<<l.distbits)-1;e:do{C<15&&(y+=_[c++]<<C,C+=8,y+=_[c++]<<C,C+=8),k=S[y&I];t:for(;;){if(y>>>=N=k>>>24,C-=N,(N=k>>>16&255)===0)M[h++]=65535&k;else{if(!(16&N)){if((64&N)==0){k=S[(65535&k)+(y&(1<<N)-1)];continue t}if(32&N){l.mode=12;break e}a.msg="invalid literal/length code",l.mode=30;break e}A=65535&k,(N&=15)&&(C<N&&(y+=_[c++]<<C,C+=8),A+=y&(1<<N)-1,y>>>=N,C-=N),C<15&&(y+=_[c++]<<C,C+=8,y+=_[c++]<<C,C+=8),k=j[y&b];n:for(;;){if(y>>>=N=k>>>24,C-=N,!(16&(N=k>>>16&255))){if((64&N)==0){k=j[(65535&k)+(y&(1<<N)-1)];continue n}a.msg="invalid distance code",l.mode=30;break e}if(P=65535&k,C<(N&=15)&&(y+=_[c++]<<C,(C+=8)<N&&(y+=_[c++]<<C,C+=8)),m<(P+=y&(1<<N)-1)){a.msg="invalid distance too far back",l.mode=30;break e}if(y>>>=N,C-=N,(N=h-f)<P){if(g<(N=P-N)&&l.sane){a.msg="invalid distance too far back",l.mode=30;break e}if(R=w,(E=0)===x){if(E+=v-N,N<A){for(A-=N;M[h++]=w[E++],--N;);E=h-P,R=M}}else if(x<N){if(E+=v+x-N,(N-=x)<A){for(A-=N;M[h++]=w[E++],--N;);if(E=0,x<A){for(A-=N=x;M[h++]=w[E++],--N;);E=h-P,R=M}}}else if(E+=x-N,N<A){for(A-=N;M[h++]=w[E++],--N;);E=h-P,R=M}for(;2<A;)M[h++]=R[E++],M[h++]=R[E++],M[h++]=R[E++],A-=3;A&&(M[h++]=R[E++],1<A&&(M[h++]=R[E++]))}else{for(E=h-P;M[h++]=M[E++],M[h++]=M[E++],M[h++]=M[E++],2<(A-=3););A&&(M[h++]=M[E++],1<A&&(M[h++]=M[E++]))}break}}break}}while(c<u&&h<p);c-=A=C>>3,y&=(1<<(C-=A<<3))-1,a.next_in=c,a.next_out=h,a.avail_in=c<u?u-c+5:5-(c-u),a.avail_out=h<p?p-h+257:257-(h-p),l.hold=y,l.bits=C}},{}],49:[function(n,r,s){var a=n("../utils/common"),i=n("./adler32"),l=n("./crc32"),c=n("./inffast"),u=n("./inftrees"),h=1,f=2,p=0,m=-2,v=1,g=852,x=592;function w(E){return(E>>>24&255)+(E>>>8&65280)+((65280&E)<<8)+((255&E)<<24)}function y(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new a.Buf16(320),this.work=new a.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function C(E){var R;return E&&E.state?(R=E.state,E.total_in=E.total_out=R.total=0,E.msg="",R.wrap&&(E.adler=1&R.wrap),R.mode=v,R.last=0,R.havedict=0,R.dmax=32768,R.head=null,R.hold=0,R.bits=0,R.lencode=R.lendyn=new a.Buf32(g),R.distcode=R.distdyn=new a.Buf32(x),R.sane=1,R.back=-1,p):m}function S(E){var R;return E&&E.state?((R=E.state).wsize=0,R.whave=0,R.wnext=0,C(E)):m}function j(E,R){var _,M;return E&&E.state?(M=E.state,R<0?(_=0,R=-R):(_=1+(R>>4),R<48&&(R&=15)),R&&(R<8||15<R)?m:(M.window!==null&&M.wbits!==R&&(M.window=null),M.wrap=_,M.wbits=R,S(E))):m}function I(E,R){var _,M;return E?(M=new y,(E.state=M).window=null,(_=j(E,R))!==p&&(E.state=null),_):m}var b,k,N=!0;function A(E){if(N){var R;for(b=new a.Buf32(512),k=new a.Buf32(32),R=0;R<144;)E.lens[R++]=8;for(;R<256;)E.lens[R++]=9;for(;R<280;)E.lens[R++]=7;for(;R<288;)E.lens[R++]=8;for(u(h,E.lens,0,288,b,0,E.work,{bits:9}),R=0;R<32;)E.lens[R++]=5;u(f,E.lens,0,32,k,0,E.work,{bits:5}),N=!1}E.lencode=b,E.lenbits=9,E.distcode=k,E.distbits=5}function P(E,R,_,M){var L,F=E.state;return F.window===null&&(F.wsize=1<<F.wbits,F.wnext=0,F.whave=0,F.window=new a.Buf8(F.wsize)),M>=F.wsize?(a.arraySet(F.window,R,_-F.wsize,F.wsize,0),F.wnext=0,F.whave=F.wsize):(M<(L=F.wsize-F.wnext)&&(L=M),a.arraySet(F.window,R,_-M,L,F.wnext),(M-=L)?(a.arraySet(F.window,R,_-M,M,0),F.wnext=M,F.whave=F.wsize):(F.wnext+=L,F.wnext===F.wsize&&(F.wnext=0),F.whave<F.wsize&&(F.whave+=L))),0}s.inflateReset=S,s.inflateReset2=j,s.inflateResetKeep=C,s.inflateInit=function(E){return I(E,15)},s.inflateInit2=I,s.inflate=function(E,R){var _,M,L,F,D,O,K,$,W,V,X,H,Q,z,Z,J,ce,de,fe,ge,T,le,ie,q,B=0,ee=new a.Buf8(4),U=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!E||!E.state||!E.output||!E.input&&E.avail_in!==0)return m;(_=E.state).mode===12&&(_.mode=13),D=E.next_out,L=E.output,K=E.avail_out,F=E.next_in,M=E.input,O=E.avail_in,$=_.hold,W=_.bits,V=O,X=K,le=p;e:for(;;)switch(_.mode){case v:if(_.wrap===0){_.mode=13;break}for(;W<16;){if(O===0)break e;O--,$+=M[F++]<<W,W+=8}if(2&_.wrap&&$===35615){ee[_.check=0]=255&$,ee[1]=$>>>8&255,_.check=l(_.check,ee,2,0),W=$=0,_.mode=2;break}if(_.flags=0,_.head&&(_.head.done=!1),!(1&_.wrap)||(((255&$)<<8)+($>>8))%31){E.msg="incorrect header check",_.mode=30;break}if((15&$)!=8){E.msg="unknown compression method",_.mode=30;break}if(W-=4,T=8+(15&($>>>=4)),_.wbits===0)_.wbits=T;else if(T>_.wbits){E.msg="invalid window size",_.mode=30;break}_.dmax=1<<T,E.adler=_.check=1,_.mode=512&$?10:12,W=$=0;break;case 2:for(;W<16;){if(O===0)break e;O--,$+=M[F++]<<W,W+=8}if(_.flags=$,(255&_.flags)!=8){E.msg="unknown compression method",_.mode=30;break}if(57344&_.flags){E.msg="unknown header flags set",_.mode=30;break}_.head&&(_.head.text=$>>8&1),512&_.flags&&(ee[0]=255&$,ee[1]=$>>>8&255,_.check=l(_.check,ee,2,0)),W=$=0,_.mode=3;case 3:for(;W<32;){if(O===0)break e;O--,$+=M[F++]<<W,W+=8}_.head&&(_.head.time=$),512&_.flags&&(ee[0]=255&$,ee[1]=$>>>8&255,ee[2]=$>>>16&255,ee[3]=$>>>24&255,_.check=l(_.check,ee,4,0)),W=$=0,_.mode=4;case 4:for(;W<16;){if(O===0)break e;O--,$+=M[F++]<<W,W+=8}_.head&&(_.head.xflags=255&$,_.head.os=$>>8),512&_.flags&&(ee[0]=255&$,ee[1]=$>>>8&255,_.check=l(_.check,ee,2,0)),W=$=0,_.mode=5;case 5:if(1024&_.flags){for(;W<16;){if(O===0)break e;O--,$+=M[F++]<<W,W+=8}_.length=$,_.head&&(_.head.extra_len=$),512&_.flags&&(ee[0]=255&$,ee[1]=$>>>8&255,_.check=l(_.check,ee,2,0)),W=$=0}else _.head&&(_.head.extra=null);_.mode=6;case 6:if(1024&_.flags&&(O<(H=_.length)&&(H=O),H&&(_.head&&(T=_.head.extra_len-_.length,_.head.extra||(_.head.extra=new Array(_.head.extra_len)),a.arraySet(_.head.extra,M,F,H,T)),512&_.flags&&(_.check=l(_.check,M,H,F)),O-=H,F+=H,_.length-=H),_.length))break e;_.length=0,_.mode=7;case 7:if(2048&_.flags){if(O===0)break e;for(H=0;T=M[F+H++],_.head&&T&&_.length<65536&&(_.head.name+=String.fromCharCode(T)),T&&H<O;);if(512&_.flags&&(_.check=l(_.check,M,H,F)),O-=H,F+=H,T)break e}else _.head&&(_.head.name=null);_.length=0,_.mode=8;case 8:if(4096&_.flags){if(O===0)break e;for(H=0;T=M[F+H++],_.head&&T&&_.length<65536&&(_.head.comment+=String.fromCharCode(T)),T&&H<O;);if(512&_.flags&&(_.check=l(_.check,M,H,F)),O-=H,F+=H,T)break e}else _.head&&(_.head.comment=null);_.mode=9;case 9:if(512&_.flags){for(;W<16;){if(O===0)break e;O--,$+=M[F++]<<W,W+=8}if($!==(65535&_.check)){E.msg="header crc mismatch",_.mode=30;break}W=$=0}_.head&&(_.head.hcrc=_.flags>>9&1,_.head.done=!0),E.adler=_.check=0,_.mode=12;break;case 10:for(;W<32;){if(O===0)break e;O--,$+=M[F++]<<W,W+=8}E.adler=_.check=w($),W=$=0,_.mode=11;case 11:if(_.havedict===0)return E.next_out=D,E.avail_out=K,E.next_in=F,E.avail_in=O,_.hold=$,_.bits=W,2;E.adler=_.check=1,_.mode=12;case 12:if(R===5||R===6)break e;case 13:if(_.last){$>>>=7&W,W-=7&W,_.mode=27;break}for(;W<3;){if(O===0)break e;O--,$+=M[F++]<<W,W+=8}switch(_.last=1&$,W-=1,3&($>>>=1)){case 0:_.mode=14;break;case 1:if(A(_),_.mode=20,R!==6)break;$>>>=2,W-=2;break e;case 2:_.mode=17;break;case 3:E.msg="invalid block type",_.mode=30}$>>>=2,W-=2;break;case 14:for($>>>=7&W,W-=7&W;W<32;){if(O===0)break e;O--,$+=M[F++]<<W,W+=8}if((65535&$)!=($>>>16^65535)){E.msg="invalid stored block lengths",_.mode=30;break}if(_.length=65535&$,W=$=0,_.mode=15,R===6)break e;case 15:_.mode=16;case 16:if(H=_.length){if(O<H&&(H=O),K<H&&(H=K),H===0)break e;a.arraySet(L,M,F,H,D),O-=H,F+=H,K-=H,D+=H,_.length-=H;break}_.mode=12;break;case 17:for(;W<14;){if(O===0)break e;O--,$+=M[F++]<<W,W+=8}if(_.nlen=257+(31&$),$>>>=5,W-=5,_.ndist=1+(31&$),$>>>=5,W-=5,_.ncode=4+(15&$),$>>>=4,W-=4,286<_.nlen||30<_.ndist){E.msg="too many length or distance symbols",_.mode=30;break}_.have=0,_.mode=18;case 18:for(;_.have<_.ncode;){for(;W<3;){if(O===0)break e;O--,$+=M[F++]<<W,W+=8}_.lens[U[_.have++]]=7&$,$>>>=3,W-=3}for(;_.have<19;)_.lens[U[_.have++]]=0;if(_.lencode=_.lendyn,_.lenbits=7,ie={bits:_.lenbits},le=u(0,_.lens,0,19,_.lencode,0,_.work,ie),_.lenbits=ie.bits,le){E.msg="invalid code lengths set",_.mode=30;break}_.have=0,_.mode=19;case 19:for(;_.have<_.nlen+_.ndist;){for(;J=(B=_.lencode[$&(1<<_.lenbits)-1])>>>16&255,ce=65535&B,!((Z=B>>>24)<=W);){if(O===0)break e;O--,$+=M[F++]<<W,W+=8}if(ce<16)$>>>=Z,W-=Z,_.lens[_.have++]=ce;else{if(ce===16){for(q=Z+2;W<q;){if(O===0)break e;O--,$+=M[F++]<<W,W+=8}if($>>>=Z,W-=Z,_.have===0){E.msg="invalid bit length repeat",_.mode=30;break}T=_.lens[_.have-1],H=3+(3&$),$>>>=2,W-=2}else if(ce===17){for(q=Z+3;W<q;){if(O===0)break e;O--,$+=M[F++]<<W,W+=8}W-=Z,T=0,H=3+(7&($>>>=Z)),$>>>=3,W-=3}else{for(q=Z+7;W<q;){if(O===0)break e;O--,$+=M[F++]<<W,W+=8}W-=Z,T=0,H=11+(127&($>>>=Z)),$>>>=7,W-=7}if(_.have+H>_.nlen+_.ndist){E.msg="invalid bit length repeat",_.mode=30;break}for(;H--;)_.lens[_.have++]=T}}if(_.mode===30)break;if(_.lens[256]===0){E.msg="invalid code -- missing end-of-block",_.mode=30;break}if(_.lenbits=9,ie={bits:_.lenbits},le=u(h,_.lens,0,_.nlen,_.lencode,0,_.work,ie),_.lenbits=ie.bits,le){E.msg="invalid literal/lengths set",_.mode=30;break}if(_.distbits=6,_.distcode=_.distdyn,ie={bits:_.distbits},le=u(f,_.lens,_.nlen,_.ndist,_.distcode,0,_.work,ie),_.distbits=ie.bits,le){E.msg="invalid distances set",_.mode=30;break}if(_.mode=20,R===6)break e;case 20:_.mode=21;case 21:if(6<=O&&258<=K){E.next_out=D,E.avail_out=K,E.next_in=F,E.avail_in=O,_.hold=$,_.bits=W,c(E,X),D=E.next_out,L=E.output,K=E.avail_out,F=E.next_in,M=E.input,O=E.avail_in,$=_.hold,W=_.bits,_.mode===12&&(_.back=-1);break}for(_.back=0;J=(B=_.lencode[$&(1<<_.lenbits)-1])>>>16&255,ce=65535&B,!((Z=B>>>24)<=W);){if(O===0)break e;O--,$+=M[F++]<<W,W+=8}if(J&&(240&J)==0){for(de=Z,fe=J,ge=ce;J=(B=_.lencode[ge+(($&(1<<de+fe)-1)>>de)])>>>16&255,ce=65535&B,!(de+(Z=B>>>24)<=W);){if(O===0)break e;O--,$+=M[F++]<<W,W+=8}$>>>=de,W-=de,_.back+=de}if($>>>=Z,W-=Z,_.back+=Z,_.length=ce,J===0){_.mode=26;break}if(32&J){_.back=-1,_.mode=12;break}if(64&J){E.msg="invalid literal/length code",_.mode=30;break}_.extra=15&J,_.mode=22;case 22:if(_.extra){for(q=_.extra;W<q;){if(O===0)break e;O--,$+=M[F++]<<W,W+=8}_.length+=$&(1<<_.extra)-1,$>>>=_.extra,W-=_.extra,_.back+=_.extra}_.was=_.length,_.mode=23;case 23:for(;J=(B=_.distcode[$&(1<<_.distbits)-1])>>>16&255,ce=65535&B,!((Z=B>>>24)<=W);){if(O===0)break e;O--,$+=M[F++]<<W,W+=8}if((240&J)==0){for(de=Z,fe=J,ge=ce;J=(B=_.distcode[ge+(($&(1<<de+fe)-1)>>de)])>>>16&255,ce=65535&B,!(de+(Z=B>>>24)<=W);){if(O===0)break e;O--,$+=M[F++]<<W,W+=8}$>>>=de,W-=de,_.back+=de}if($>>>=Z,W-=Z,_.back+=Z,64&J){E.msg="invalid distance code",_.mode=30;break}_.offset=ce,_.extra=15&J,_.mode=24;case 24:if(_.extra){for(q=_.extra;W<q;){if(O===0)break e;O--,$+=M[F++]<<W,W+=8}_.offset+=$&(1<<_.extra)-1,$>>>=_.extra,W-=_.extra,_.back+=_.extra}if(_.offset>_.dmax){E.msg="invalid distance too far back",_.mode=30;break}_.mode=25;case 25:if(K===0)break e;if(H=X-K,_.offset>H){if((H=_.offset-H)>_.whave&&_.sane){E.msg="invalid distance too far back",_.mode=30;break}Q=H>_.wnext?(H-=_.wnext,_.wsize-H):_.wnext-H,H>_.length&&(H=_.length),z=_.window}else z=L,Q=D-_.offset,H=_.length;for(K<H&&(H=K),K-=H,_.length-=H;L[D++]=z[Q++],--H;);_.length===0&&(_.mode=21);break;case 26:if(K===0)break e;L[D++]=_.length,K--,_.mode=21;break;case 27:if(_.wrap){for(;W<32;){if(O===0)break e;O--,$|=M[F++]<<W,W+=8}if(X-=K,E.total_out+=X,_.total+=X,X&&(E.adler=_.check=_.flags?l(_.check,L,X,D-X):i(_.check,L,X,D-X)),X=K,(_.flags?$:w($))!==_.check){E.msg="incorrect data check",_.mode=30;break}W=$=0}_.mode=28;case 28:if(_.wrap&&_.flags){for(;W<32;){if(O===0)break e;O--,$+=M[F++]<<W,W+=8}if($!==(4294967295&_.total)){E.msg="incorrect length check",_.mode=30;break}W=$=0}_.mode=29;case 29:le=1;break e;case 30:le=-3;break e;case 31:return-4;case 32:default:return m}return E.next_out=D,E.avail_out=K,E.next_in=F,E.avail_in=O,_.hold=$,_.bits=W,(_.wsize||X!==E.avail_out&&_.mode<30&&(_.mode<27||R!==4))&&P(E,E.output,E.next_out,X-E.avail_out)?(_.mode=31,-4):(V-=E.avail_in,X-=E.avail_out,E.total_in+=V,E.total_out+=X,_.total+=X,_.wrap&&X&&(E.adler=_.check=_.flags?l(_.check,L,X,E.next_out-X):i(_.check,L,X,E.next_out-X)),E.data_type=_.bits+(_.last?64:0)+(_.mode===12?128:0)+(_.mode===20||_.mode===15?256:0),(V==0&&X===0||R===4)&&le===p&&(le=-5),le)},s.inflateEnd=function(E){if(!E||!E.state)return m;var R=E.state;return R.window&&(R.window=null),E.state=null,p},s.inflateGetHeader=function(E,R){var _;return E&&E.state?(2&(_=E.state).wrap)==0?m:((_.head=R).done=!1,p):m},s.inflateSetDictionary=function(E,R){var _,M=R.length;return E&&E.state?(_=E.state).wrap!==0&&_.mode!==11?m:_.mode===11&&i(1,R,M,0)!==_.check?-3:P(E,R,M,M)?(_.mode=31,-4):(_.havedict=1,p):m},s.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,s){var a=n("../utils/common"),i=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],l=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(h,f,p,m,v,g,x,w){var y,C,S,j,I,b,k,N,A,P=w.bits,E=0,R=0,_=0,M=0,L=0,F=0,D=0,O=0,K=0,$=0,W=null,V=0,X=new a.Buf16(16),H=new a.Buf16(16),Q=null,z=0;for(E=0;E<=15;E++)X[E]=0;for(R=0;R<m;R++)X[f[p+R]]++;for(L=P,M=15;1<=M&&X[M]===0;M--);if(M<L&&(L=M),M===0)return v[g++]=20971520,v[g++]=20971520,w.bits=1,0;for(_=1;_<M&&X[_]===0;_++);for(L<_&&(L=_),E=O=1;E<=15;E++)if(O<<=1,(O-=X[E])<0)return-1;if(0<O&&(h===0||M!==1))return-1;for(H[1]=0,E=1;E<15;E++)H[E+1]=H[E]+X[E];for(R=0;R<m;R++)f[p+R]!==0&&(x[H[f[p+R]]++]=R);if(b=h===0?(W=Q=x,19):h===1?(W=i,V-=257,Q=l,z-=257,256):(W=c,Q=u,-1),E=_,I=g,D=R=$=0,S=-1,j=(K=1<<(F=L))-1,h===1&&852<K||h===2&&592<K)return 1;for(;;){for(k=E-D,A=x[R]<b?(N=0,x[R]):x[R]>b?(N=Q[z+x[R]],W[V+x[R]]):(N=96,0),y=1<<E-D,_=C=1<<F;v[I+($>>D)+(C-=y)]=k<<24|N<<16|A|0,C!==0;);for(y=1<<E-1;$&y;)y>>=1;if(y!==0?($&=y-1,$+=y):$=0,R++,--X[E]==0){if(E===M)break;E=f[p+x[R]]}if(L<E&&($&j)!==S){for(D===0&&(D=L),I+=_,O=1<<(F=E-D);F+D<M&&!((O-=X[F+D])<=0);)F++,O<<=1;if(K+=1<<F,h===1&&852<K||h===2&&592<K)return 1;v[S=$&j]=L<<24|F<<16|I-g|0}}return $!==0&&(v[I+$]=E-D<<24|64<<16|0),w.bits=L,0}},{"../utils/common":41}],51:[function(n,r,s){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,s){var a=n("../utils/common"),i=0,l=1;function c(B){for(var ee=B.length;0<=--ee;)B[ee]=0}var u=0,h=29,f=256,p=f+1+h,m=30,v=19,g=2*p+1,x=15,w=16,y=7,C=256,S=16,j=17,I=18,b=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],k=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],N=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],A=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],P=new Array(2*(p+2));c(P);var E=new Array(2*m);c(E);var R=new Array(512);c(R);var _=new Array(256);c(_);var M=new Array(h);c(M);var L,F,D,O=new Array(m);function K(B,ee,U,Y,G){this.static_tree=B,this.extra_bits=ee,this.extra_base=U,this.elems=Y,this.max_length=G,this.has_stree=B&&B.length}function $(B,ee){this.dyn_tree=B,this.max_code=0,this.stat_desc=ee}function W(B){return B<256?R[B]:R[256+(B>>>7)]}function V(B,ee){B.pending_buf[B.pending++]=255&ee,B.pending_buf[B.pending++]=ee>>>8&255}function X(B,ee,U){B.bi_valid>w-U?(B.bi_buf|=ee<<B.bi_valid&65535,V(B,B.bi_buf),B.bi_buf=ee>>w-B.bi_valid,B.bi_valid+=U-w):(B.bi_buf|=ee<<B.bi_valid&65535,B.bi_valid+=U)}function H(B,ee,U){X(B,U[2*ee],U[2*ee+1])}function Q(B,ee){for(var U=0;U|=1&B,B>>>=1,U<<=1,0<--ee;);return U>>>1}function z(B,ee,U){var Y,G,ae=new Array(x+1),oe=0;for(Y=1;Y<=x;Y++)ae[Y]=oe=oe+U[Y-1]<<1;for(G=0;G<=ee;G++){var se=B[2*G+1];se!==0&&(B[2*G]=Q(ae[se]++,se))}}function Z(B){var ee;for(ee=0;ee<p;ee++)B.dyn_ltree[2*ee]=0;for(ee=0;ee<m;ee++)B.dyn_dtree[2*ee]=0;for(ee=0;ee<v;ee++)B.bl_tree[2*ee]=0;B.dyn_ltree[2*C]=1,B.opt_len=B.static_len=0,B.last_lit=B.matches=0}function J(B){8<B.bi_valid?V(B,B.bi_buf):0<B.bi_valid&&(B.pending_buf[B.pending++]=B.bi_buf),B.bi_buf=0,B.bi_valid=0}function ce(B,ee,U,Y){var G=2*ee,ae=2*U;return B[G]<B[ae]||B[G]===B[ae]&&Y[ee]<=Y[U]}function de(B,ee,U){for(var Y=B.heap[U],G=U<<1;G<=B.heap_len&&(G<B.heap_len&&ce(ee,B.heap[G+1],B.heap[G],B.depth)&&G++,!ce(ee,Y,B.heap[G],B.depth));)B.heap[U]=B.heap[G],U=G,G<<=1;B.heap[U]=Y}function fe(B,ee,U){var Y,G,ae,oe,se=0;if(B.last_lit!==0)for(;Y=B.pending_buf[B.d_buf+2*se]<<8|B.pending_buf[B.d_buf+2*se+1],G=B.pending_buf[B.l_buf+se],se++,Y===0?H(B,G,ee):(H(B,(ae=_[G])+f+1,ee),(oe=b[ae])!==0&&X(B,G-=M[ae],oe),H(B,ae=W(--Y),U),(oe=k[ae])!==0&&X(B,Y-=O[ae],oe)),se<B.last_lit;);H(B,C,ee)}function ge(B,ee){var U,Y,G,ae=ee.dyn_tree,oe=ee.stat_desc.static_tree,se=ee.stat_desc.has_stree,me=ee.stat_desc.elems,Pe=-1;for(B.heap_len=0,B.heap_max=g,U=0;U<me;U++)ae[2*U]!==0?(B.heap[++B.heap_len]=Pe=U,B.depth[U]=0):ae[2*U+1]=0;for(;B.heap_len<2;)ae[2*(G=B.heap[++B.heap_len]=Pe<2?++Pe:0)]=1,B.depth[G]=0,B.opt_len--,se&&(B.static_len-=oe[2*G+1]);for(ee.max_code=Pe,U=B.heap_len>>1;1<=U;U--)de(B,ae,U);for(G=me;U=B.heap[1],B.heap[1]=B.heap[B.heap_len--],de(B,ae,1),Y=B.heap[1],B.heap[--B.heap_max]=U,B.heap[--B.heap_max]=Y,ae[2*G]=ae[2*U]+ae[2*Y],B.depth[G]=(B.depth[U]>=B.depth[Y]?B.depth[U]:B.depth[Y])+1,ae[2*U+1]=ae[2*Y+1]=G,B.heap[1]=G++,de(B,ae,1),2<=B.heap_len;);B.heap[--B.heap_max]=B.heap[1],function(Ne,dt){var Ht,wt,Ot,gt,Nt,Jt,Wt=dt.dyn_tree,xe=dt.max_code,$e=dt.stat_desc.static_tree,Me=dt.stat_desc.has_stree,Fe=dt.stat_desc.extra_bits,ft=dt.stat_desc.extra_base,He=dt.stat_desc.max_length,Ut=0;for(gt=0;gt<=x;gt++)Ne.bl_count[gt]=0;for(Wt[2*Ne.heap[Ne.heap_max]+1]=0,Ht=Ne.heap_max+1;Ht<g;Ht++)He<(gt=Wt[2*Wt[2*(wt=Ne.heap[Ht])+1]+1]+1)&&(gt=He,Ut++),Wt[2*wt+1]=gt,xe<wt||(Ne.bl_count[gt]++,Nt=0,ft<=wt&&(Nt=Fe[wt-ft]),Jt=Wt[2*wt],Ne.opt_len+=Jt*(gt+Nt),Me&&(Ne.static_len+=Jt*($e[2*wt+1]+Nt)));if(Ut!==0){do{for(gt=He-1;Ne.bl_count[gt]===0;)gt--;Ne.bl_count[gt]--,Ne.bl_count[gt+1]+=2,Ne.bl_count[He]--,Ut-=2}while(0<Ut);for(gt=He;gt!==0;gt--)for(wt=Ne.bl_count[gt];wt!==0;)xe<(Ot=Ne.heap[--Ht])||(Wt[2*Ot+1]!==gt&&(Ne.opt_len+=(gt-Wt[2*Ot+1])*Wt[2*Ot],Wt[2*Ot+1]=gt),wt--)}}(B,ee),z(ae,Pe,B.bl_count)}function T(B,ee,U){var Y,G,ae=-1,oe=ee[1],se=0,me=7,Pe=4;for(oe===0&&(me=138,Pe=3),ee[2*(U+1)+1]=65535,Y=0;Y<=U;Y++)G=oe,oe=ee[2*(Y+1)+1],++se<me&&G===oe||(se<Pe?B.bl_tree[2*G]+=se:G!==0?(G!==ae&&B.bl_tree[2*G]++,B.bl_tree[2*S]++):se<=10?B.bl_tree[2*j]++:B.bl_tree[2*I]++,ae=G,Pe=(se=0)===oe?(me=138,3):G===oe?(me=6,3):(me=7,4))}function le(B,ee,U){var Y,G,ae=-1,oe=ee[1],se=0,me=7,Pe=4;for(oe===0&&(me=138,Pe=3),Y=0;Y<=U;Y++)if(G=oe,oe=ee[2*(Y+1)+1],!(++se<me&&G===oe)){if(se<Pe)for(;H(B,G,B.bl_tree),--se!=0;);else G!==0?(G!==ae&&(H(B,G,B.bl_tree),se--),H(B,S,B.bl_tree),X(B,se-3,2)):se<=10?(H(B,j,B.bl_tree),X(B,se-3,3)):(H(B,I,B.bl_tree),X(B,se-11,7));ae=G,Pe=(se=0)===oe?(me=138,3):G===oe?(me=6,3):(me=7,4)}}c(O);var ie=!1;function q(B,ee,U,Y){X(B,(u<<1)+(Y?1:0),3),function(G,ae,oe,se){J(G),V(G,oe),V(G,~oe),a.arraySet(G.pending_buf,G.window,ae,oe,G.pending),G.pending+=oe}(B,ee,U)}s._tr_init=function(B){ie||(function(){var ee,U,Y,G,ae,oe=new Array(x+1);for(G=Y=0;G<h-1;G++)for(M[G]=Y,ee=0;ee<1<<b[G];ee++)_[Y++]=G;for(_[Y-1]=G,G=ae=0;G<16;G++)for(O[G]=ae,ee=0;ee<1<<k[G];ee++)R[ae++]=G;for(ae>>=7;G<m;G++)for(O[G]=ae<<7,ee=0;ee<1<<k[G]-7;ee++)R[256+ae++]=G;for(U=0;U<=x;U++)oe[U]=0;for(ee=0;ee<=143;)P[2*ee+1]=8,ee++,oe[8]++;for(;ee<=255;)P[2*ee+1]=9,ee++,oe[9]++;for(;ee<=279;)P[2*ee+1]=7,ee++,oe[7]++;for(;ee<=287;)P[2*ee+1]=8,ee++,oe[8]++;for(z(P,p+1,oe),ee=0;ee<m;ee++)E[2*ee+1]=5,E[2*ee]=Q(ee,5);L=new K(P,b,f+1,p,x),F=new K(E,k,0,m,x),D=new K(new Array(0),N,0,v,y)}(),ie=!0),B.l_desc=new $(B.dyn_ltree,L),B.d_desc=new $(B.dyn_dtree,F),B.bl_desc=new $(B.bl_tree,D),B.bi_buf=0,B.bi_valid=0,Z(B)},s._tr_stored_block=q,s._tr_flush_block=function(B,ee,U,Y){var G,ae,oe=0;0<B.level?(B.strm.data_type===2&&(B.strm.data_type=function(se){var me,Pe=4093624447;for(me=0;me<=31;me++,Pe>>>=1)if(1&Pe&&se.dyn_ltree[2*me]!==0)return i;if(se.dyn_ltree[18]!==0||se.dyn_ltree[20]!==0||se.dyn_ltree[26]!==0)return l;for(me=32;me<f;me++)if(se.dyn_ltree[2*me]!==0)return l;return i}(B)),ge(B,B.l_desc),ge(B,B.d_desc),oe=function(se){var me;for(T(se,se.dyn_ltree,se.l_desc.max_code),T(se,se.dyn_dtree,se.d_desc.max_code),ge(se,se.bl_desc),me=v-1;3<=me&&se.bl_tree[2*A[me]+1]===0;me--);return se.opt_len+=3*(me+1)+5+5+4,me}(B),G=B.opt_len+3+7>>>3,(ae=B.static_len+3+7>>>3)<=G&&(G=ae)):G=ae=U+5,U+4<=G&&ee!==-1?q(B,ee,U,Y):B.strategy===4||ae===G?(X(B,2+(Y?1:0),3),fe(B,P,E)):(X(B,4+(Y?1:0),3),function(se,me,Pe,Ne){var dt;for(X(se,me-257,5),X(se,Pe-1,5),X(se,Ne-4,4),dt=0;dt<Ne;dt++)X(se,se.bl_tree[2*A[dt]+1],3);le(se,se.dyn_ltree,me-1),le(se,se.dyn_dtree,Pe-1)}(B,B.l_desc.max_code+1,B.d_desc.max_code+1,oe+1),fe(B,B.dyn_ltree,B.dyn_dtree)),Z(B),Y&&J(B)},s._tr_tally=function(B,ee,U){return B.pending_buf[B.d_buf+2*B.last_lit]=ee>>>8&255,B.pending_buf[B.d_buf+2*B.last_lit+1]=255&ee,B.pending_buf[B.l_buf+B.last_lit]=255&U,B.last_lit++,ee===0?B.dyn_ltree[2*U]++:(B.matches++,ee--,B.dyn_ltree[2*(_[U]+f+1)]++,B.dyn_dtree[2*W(ee)]++),B.last_lit===B.lit_bufsize-1},s._tr_align=function(B){X(B,2,3),H(B,C,P),function(ee){ee.bi_valid===16?(V(ee,ee.bi_buf),ee.bi_buf=0,ee.bi_valid=0):8<=ee.bi_valid&&(ee.pending_buf[ee.pending++]=255&ee.bi_buf,ee.bi_buf>>=8,ee.bi_valid-=8)}(B)}},{"../utils/common":41}],53:[function(n,r,s){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,s){(function(a){(function(i,l){if(!i.setImmediate){var c,u,h,f,p=1,m={},v=!1,g=i.document,x=Object.getPrototypeOf&&Object.getPrototypeOf(i);x=x&&x.setTimeout?x:i,c={}.toString.call(i.process)==="[object process]"?function(S){process.nextTick(function(){y(S)})}:function(){if(i.postMessage&&!i.importScripts){var S=!0,j=i.onmessage;return i.onmessage=function(){S=!1},i.postMessage("","*"),i.onmessage=j,S}}()?(f="setImmediate$"+Math.random()+"$",i.addEventListener?i.addEventListener("message",C,!1):i.attachEvent("onmessage",C),function(S){i.postMessage(f+S,"*")}):i.MessageChannel?((h=new MessageChannel).port1.onmessage=function(S){y(S.data)},function(S){h.port2.postMessage(S)}):g&&"onreadystatechange"in g.createElement("script")?(u=g.documentElement,function(S){var j=g.createElement("script");j.onreadystatechange=function(){y(S),j.onreadystatechange=null,u.removeChild(j),j=null},u.appendChild(j)}):function(S){setTimeout(y,0,S)},x.setImmediate=function(S){typeof S!="function"&&(S=new Function(""+S));for(var j=new Array(arguments.length-1),I=0;I<j.length;I++)j[I]=arguments[I+1];var b={callback:S,args:j};return m[p]=b,c(p),p++},x.clearImmediate=w}function w(S){delete m[S]}function y(S){if(v)setTimeout(y,0,S);else{var j=m[S];if(j){v=!0;try{(function(I){var b=I.callback,k=I.args;switch(k.length){case 0:b();break;case 1:b(k[0]);break;case 2:b(k[0],k[1]);break;case 3:b(k[0],k[1],k[2]);break;default:b.apply(l,k)}})(j)}finally{w(S),v=!1}}}}function C(S){S.source===i&&typeof S.data=="string"&&S.data.indexOf(f)===0&&y(+S.data.slice(f.length))}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,typeof Fl<"u"?Fl:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})}(ef)),ef.exports}var j7=k7();const E7=z_(j7),N7=100*1024*1024,T7=({open:e,onOpenChange:t,onImport:n})=>{const{validationLimits:r}=on(),s=r==null?void 0:r.maxUploadSizeBytes,a=(r==null?void 0:r.maxZipUploadSizeBytes)??N7,[i,l]=d.useState(null),[c,u]=d.useState(null),[h,f]=d.useState(""),[p,m]=d.useState(null),[v,g]=d.useState(!1),x=(i==null?void 0:i[0])||null,w=()=>{v||(l(null),u(null),f(""),m(null),t(!1))},y=async k=>{if(m(null),!k.name.endsWith(".zip"))return m("Please select a ZIP file"),!1;if(k.size>a)return m(`ZIP file size exceeds ${ds(a)} limit`),!1;try{const N=await E7.loadAsync(k);if(!N.files["project.json"])return m("Invalid project export: missing project.json"),!1;const A=await N.files["project.json"].async("string"),P=JSON.parse(A);if(P.version!=="1.0")return m(`Unsupported export version: ${P.version}. Only version 1.0 is currently supported.`),!1;const E=Object.keys(N.files).filter(D=>D.startsWith("artifacts/")&&D!=="artifacts/"),R=E.map(D=>D.replace("artifacts/","")),_=P.artifacts||[],M=new Map;for(const D of _)D.filename&&typeof D.size=="number"&&M.set(D.filename,D.size);const L=[],F=[];for(const D of E){const O=N.files[D],K=D.replace("artifacts/","");let $=M.get(K);if($===void 0)try{$=(await O.async("uint8array")).length}catch{$=0}const W=s?$>s:!1,V={name:K,size:$,isOversized:W};L.push(V),W&&F.push(V)}return u({name:P.project.name,description:P.project.description,systemPrompt:P.project.systemPrompt,defaultAgentId:P.project.defaultAgentId,artifactCount:E.length,artifactNames:R,artifacts:L,oversizedArtifacts:F}),f(P.project.name),!0}catch(N){return console.error("Error validating file:",N),m("Invalid ZIP file or corrupted project export"),!1}},C=async k=>{l(k),k&&k[0]?await y(k[0]):(u(null),f(""))},S=k=>{const N=k[0];return N.name.endsWith(".zip")?N.size>a?{valid:!1,error:`ZIP file size exceeds ${ds(a)} limit`}:{valid:!0}:{valid:!1,error:"Please select a ZIP file"}},j=async()=>{if(!x){m("Please select a file to import");return}g(!0),m(null);try{await n(x,{preserveName:!1,customName:h.trim()||void 0}),l(null),u(null),f(""),m(null)}catch(k){const N=k instanceof Error?k.message:"Failed to import project";throw m(N),k}finally{g(!1)}},I=()=>{v||w()},b=o.jsxs("div",{className:"space-y-4",children:[o.jsx("div",{className:"mt-2 py-2",children:o.jsx(Rm,{name:"projectFile",accept:".zip",multiple:!1,disabled:v,value:i,onChange:C,onValidate:S})}),c&&o.jsxs("div",{className:"bg-muted/30 space-y-3 rounded-lg border p-4",children:[o.jsxs("div",{children:[o.jsx(zt,{className:"text-muted-foreground text-xs",children:"Original Name"}),o.jsx("p",{className:"text-sm font-medium",children:c.name})]}),c.description&&o.jsxs("div",{children:[o.jsx(zt,{className:"text-muted-foreground text-xs",children:"Description"}),o.jsx("p",{className:"text-sm",children:c.description})]}),c.systemPrompt&&o.jsxs("div",{children:[o.jsx(zt,{className:"text-muted-foreground text-xs",children:"Instructions"}),o.jsx("p",{className:"line-clamp-3 text-sm",children:c.systemPrompt})]}),c.defaultAgentId&&o.jsxs("div",{children:[o.jsx(zt,{className:"text-muted-foreground text-xs",children:"Default Agent"}),o.jsx("p",{className:"font-mono text-sm",children:c.defaultAgentId})]}),o.jsxs("div",{children:[o.jsxs(zt,{className:"text-muted-foreground text-xs",children:["Artifacts (",c.artifactCount," ",c.artifactCount===1?"file":"files",")"]}),c.artifacts.length>0&&o.jsxs("div",{className:"mt-1 space-y-1",children:[c.artifacts.slice(0,5).map((k,N)=>o.jsxs("div",{className:`flex items-center gap-1.5 text-xs ${k.isOversized?"text-destructive":""}`,children:[k.isOversized?o.jsx(mh,{className:"text-destructive h-3 w-3 flex-shrink-0"}):o.jsx(bv,{className:"text-muted-foreground h-3 w-3 flex-shrink-0"}),o.jsx("span",{className:"truncate",children:k.name}),o.jsxs("span",{className:"text-muted-foreground flex-shrink-0",children:["(",ds(k.size),")"]})]},N)),c.artifacts.length>5&&o.jsxs("p",{className:"text-muted-foreground text-xs italic",children:["+ ",c.artifacts.length-5," more files"]})]})]}),c.oversizedArtifacts.length>0&&s&&o.jsx("div",{className:"mt-2",children:o.jsx(Xt,{variant:"warning",message:`${c.oversizedArtifacts.length} ${c.oversizedArtifacts.length===1?"file exceeds":"files exceed"} the maximum size of ${ds(s)} and will be skipped during import: ${c.oversizedArtifacts.slice(0,3).map(k=>k.name).join(", ")}${c.oversizedArtifacts.length>3?` and ${c.oversizedArtifacts.length-3} more`:""}`})})]}),c&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(zt,{htmlFor:"customName",children:"Project Name"}),o.jsx(_r,{id:"customName",value:h,onChange:k=>f(k.target.value),placeholder:"Enter project name",disabled:v}),o.jsx("p",{className:"text-muted-foreground text-xs",children:"Name conflicts will be resolved automatically"})]}),p&&o.jsx(Xt,{variant:"error",message:p})]});return o.jsx(Rr,{open:e,onOpenChange:k=>!k&&w(),title:"Import Project",description:"Import a project from an exported project ZIP file.",content:b,actionLabels:{confirm:"Import",cancel:"Cancel"},onConfirm:j,onCancel:I,isLoading:v,isEnabled:!!c})},n_="Projects allow you to give the AI a re-usable set of context for conversations. You can upload files, select a default agent and provide custom instructions.",r_="When you ask a question, it will find the most relevant file and pull answers directly from it. It's great for diving into your documents through natural conversation.",A7=`${n_} ${r_}`,I7=()=>o.jsxs("span",{children:[n_,o.jsx("br",{}),o.jsx("br",{}),r_]}),R7=({projects:e,searchQuery:t,onSearchChange:n,onProjectClick:r,onCreateNew:s,onDelete:a,onExport:i,isLoading:l=!1})=>o.jsx("div",{className:"bg-card-background flex h-full flex-col",children:o.jsxs("div",{className:"flex h-full flex-col pt-6 pb-6 pl-6",children:[e.length>0||t?o.jsx(Qh,{value:t,onChange:n,placeholder:"Filter by name...",className:"mb-4 w-xs"}):null,l?o.jsx(rr,{variant:"loading",title:"Loading projects..."}):e.length===0&&t?o.jsx(rr,{variant:"notFound",title:"No Projects Match Your Filter",subtitle:"Try adjusting your filter terms.",buttons:[{text:"Clear Filter",variant:"default",onClick:()=>n("")}]}):e.length===0?o.jsx(rr,{variant:"noImage",title:"No Projects Found",subtitle:o.jsx(I7,{}),buttons:[{text:"Create New Project",variant:"default",onClick:()=>s()}]}):o.jsxs("div",{className:"flex-1 overflow-y-auto",children:[o.jsx(Xt,{variant:"info",message:A7,className:"mr-6 mb-4"}),o.jsxs("div",{className:"flex flex-wrap gap-6",children:[o.jsx(C7,{onClick:s}),e.map(c=>o.jsx(_7,{project:c,onClick:()=>r(c),onDelete:a,onExport:i},c.id))]})]})]})}),P7=({isOpen:e,onClose:t,onSave:n,project:r,isSaving:s,error:a})=>{const{validationLimits:i}=on(),l=(i==null?void 0:i.projectInstructionsMax)??4e3,[c,u]=d.useState(r.systemPrompt||""),[h,f]=d.useState(null);d.useEffect(()=>{e&&(u(r.systemPrompt||""),f(null))},[e,r.systemPrompt]),d.useEffect(()=>{a&&f(a)},[a]);const p=async()=>{if(f(null),c.trim()!==(r.systemPrompt||""))try{await n(c.trim()),t()}catch{}else t()},m=()=>{u(r.systemPrompt||""),f(null),t()},v=c.length,g=v>l;return o.jsx(Nr,{open:e,onOpenChange:x=>!x&&m(),children:o.jsxs(Tr,{className:"flex max-h-[80vh] max-w-3xl flex-col",children:[o.jsxs(rs,{children:[o.jsx(Ar,{children:"Edit Project Instructions"}),o.jsx(Ir,{children:"Provide instructions that will guide the AI when working with this project."})]}),o.jsxs("div",{className:"min-h-0 flex-1 pt-4",children:[o.jsxs("div",{className:"relative",children:[o.jsx(ts,{value:c,onChange:x=>u(x.target.value),placeholder:"Add instructions for this project...",rows:15,disabled:s,maxLength:l+1,className:`resize-none text-sm ${g?"border-destructive":""}`}),o.jsxs("div",{className:`text-xs ${g?"text-destructive":"text-muted-foreground text-right"}`,children:[g&&`Instructions must be less than ${l} characters`,!g&&`${v} / ${l}`]})]}),h&&o.jsx(Xt,{variant:"error",message:h,className:"py-3"})]}),o.jsxs(Cs,{children:[o.jsx(ye,{variant:"outline",onClick:m,disabled:s,children:"Discard Changes"}),o.jsx(ye,{onClick:p,disabled:s||g,children:"Save"})]})]})})},M7=({project:e,onSave:t,isSaving:n,error:r})=>{const[s,a]=d.useState(!1);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"mb-6",children:[o.jsxs("div",{className:"mb-3 flex items-center justify-between px-4 pt-4",children:[o.jsx("h3",{className:"text-foreground text-sm font-semibold",children:"Instructions"}),o.jsx(ye,{variant:"ghost",size:"sm",onClick:()=>a(!0),className:"h-8 w-8 p-0",tooltip:"Edit",children:o.jsx(ys,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"px-4",children:o.jsx("div",{className:`text-muted-foreground bg-muted max-h-[240px] min-h-[120px] overflow-y-auto rounded-md p-3 text-sm whitespace-pre-wrap ${e.systemPrompt?"":"flex items-center justify-center"}`,children:e.systemPrompt||"No instructions. Provide instructions to tailor the chat responses to your needs."})})]}),o.jsx(P7,{isOpen:s,onClose:()=>a(!1),onSave:t,project:e,isSaving:n,error:r})]})},D7=({project:e,onSave:t,isSaving:n})=>{const{agents:r,agentsLoading:s,agentNameDisplayNameMap:a}=$t(),[i,l]=d.useState(!1),[c,u]=d.useState(e.defaultAgentId||null);d.useEffect(()=>{u(e.defaultAgentId||null)},[e.defaultAgentId]);const h=async()=>{c!==(e.defaultAgentId||null)&&await t(c),l(!1)},f=()=>{u(e.defaultAgentId||null),l(!1)};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"mb-6",children:[o.jsxs("div",{className:"mb-3 flex items-center justify-between px-4",children:[o.jsx("h3",{className:"text-foreground text-sm font-semibold",children:"Default Agent"}),o.jsx(ye,{variant:"ghost",size:"sm",onClick:()=>l(!0),disabled:s,className:"h-8 w-8 p-0",tooltip:"Edit",children:o.jsx(ys,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"px-4",children:o.jsx("div",{className:"text-muted-foreground bg-muted flex items-center rounded-md p-2.5 text-sm",children:e.defaultAgentId?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(cu,{className:"h-4 w-4"}),o.jsx("span",{children:a[e.defaultAgentId??""]||"N/A"})]}):o.jsx("span",{className:"w-full text-center",children:"No default agent set."})})})]}),o.jsx(Nr,{open:i,onOpenChange:l,children:o.jsxs(Tr,{children:[o.jsxs(rs,{children:[o.jsx(Ar,{children:"Edit Default Agent"}),o.jsx(Ir,{children:"Select the default agent for this project. This agent will be used when starting new chats in this project."})]}),o.jsx("div",{className:"py-4",children:o.jsxs(Wr,{value:c||"none",onValueChange:p=>u(p==="none"?null:p),disabled:n||s,children:[o.jsx(Gr,{className:"w-full",children:o.jsx(Zr,{placeholder:"Select default agent..."})}),o.jsxs(qr,{children:[o.jsx(Pt,{value:"none",children:o.jsx("span",{className:"text-muted-foreground italic",children:"No default agent"})}),r.map(p=>o.jsx(Pt,{value:p.name||"",children:p.displayName||p.name},p.name))]})]})}),o.jsxs(Cs,{children:[o.jsx(ye,{variant:"ghost",onClick:f,disabled:n,children:"Cancel"}),o.jsx(ye,{onClick:h,disabled:n||s,children:"Save"})]})]})})]})},O7=({isOpen:e,artifact:t,onClose:n,onSave:r,isSaving:s=!1})=>{const[a,i]=d.useState("");d.useEffect(()=>{e&&t&&i(t.description||"")},[e,t]);const l=async()=>{await r(a)},c=()=>{i((t==null?void 0:t.description)||""),n()};if(!t)return null;const u=o.jsxs("div",{className:"my-5 flex flex-col gap-4",children:[o.jsx(rd,{fileName:t.filename,fileSize:t.size}),o.jsx("div",{children:o.jsx(ts,{className:"mt-1",rows:2,disabled:s,value:a,onChange:h=>i(h.target.value)})})]});return o.jsx(Rr,{open:e,onOpenChange:h=>!h&&n(),title:"Edit Project File Description",description:"Update the description to help Solace Agent Mesh understand its purpose.",content:u,actionLabels:{cancel:"Discard Changes",confirm:"Save"},isLoading:s,onConfirm:l,onCancel:c})},L7=({isOpen:e,artifact:t,onClose:n,onEdit:r})=>t?o.jsx(Nr,{open:e,onOpenChange:n,children:o.jsxs(Tr,{className:"w-xl max-w-xl sm:max-w-xl",children:[o.jsxs(rs,{children:[o.jsxs("div",{className:"flex justify-between",children:[o.jsx("h2",{className:"text-lg font-semibold",children:"Project File Details"}),o.jsxs(ye,{variant:"ghost",size:"sm",onClick:r,className:"flex-shrink-0 gap-2 text-sm",children:[o.jsx(ys,{className:"h-4 w-4"}),"Edit Description"]})]}),o.jsxs(ju,{children:[o.jsx(Ar,{children:"Project File Details"}),o.jsx(Ir,{children:"Project File Information"})]})]}),o.jsxs("div",{className:"my-5 flex flex-col gap-2 overflow-hidden",children:[o.jsx(rd,{fileName:t.filename,fileSize:t.size}),o.jsxs("div",{children:[o.jsx("div",{className:"text-secondary-foreground my-1",children:"Description:"}),o.jsx("div",{className:"max-h-[50vh] overflow-y-auto text-sm whitespace-pre-wrap",children:t.description||"No description provided"})]})]}),o.jsx(Cs,{children:o.jsx(ye,{variant:"outline",onClick:n,children:"Close"})})]})}):null,F7=({isOpen:e,fileToDelete:t,handleConfirmDelete:n,setFileToDelete:r})=>t?o.jsx(Rr,{title:"Delete Project File",content:o.jsxs("div",{className:"flex flex-col gap-4",children:["This action cannot be undone. This file will be permanently removed from the project.",o.jsx(rd,{fileName:t.filename,fileSize:t.size})]}),actionLabels:{confirm:"Delete"},open:e,onConfirm:n,onOpenChange:s=>!s&&r(null)}):null,z7=({project:e})=>{const{artifacts:t,isLoading:n,error:r,refetch:s}=tP(e.id),{addFilesToProject:a,removeFileFromProject:i,updateFileMetadata:l}=Bs(),{onDownload:c}=hm(e.id),{validationLimits:u}=on(),h=u==null?void 0:u.maxUploadSizeBytes,[f,p]=d.useState(null),[m,v]=d.useState(!1),[g,x]=d.useState(null),[w,y]=d.useState(!1),[C,S]=d.useState(null),[j,I]=d.useState(!1),[b,k]=d.useState(!1),[N,A]=d.useState(null),[P,E]=d.useState(null),R=xt.useMemo(()=>[...t].sort((Z,J)=>{const ce=Z.last_modified?new Date(Z.last_modified).getTime():0;return(J.last_modified?new Date(J.last_modified).getTime():0)-ce}),[t]),_=d.useCallback(Z=>O2(Z,{maxSizeBytes:h}),[h]),M=Z=>{p(Z)},L=async Z=>{v(!0),A(null);try{await a(e.id,Z),await s(),p(null)}catch(J){console.error("Failed to add files:",J);const ce=J instanceof Error?J.message:"Failed to upload files. Please try again.";A(ce)}finally{v(!1)}},F=()=>{p(null),A(null)},D=()=>{A(null)},O=Z=>{E(Z)},K=async()=>{if(P)try{await i(e.id,P.filename),await s(),E(null)}catch(Z){console.error(`Failed to delete file ${P.filename}:`,Z)}},$=Z=>{S(C===Z?null:Z)},W=Z=>{x(Z),y(!0)},V=Z=>{x(Z),I(!0)},X=async Z=>{if(g){k(!0);try{await l(e.id,g.filename,Z),await s(),I(!1),x(null)}catch(J){console.error("Failed to update file description:",J)}finally{k(!1)}}},H=()=>{y(!1),x(null)},Q=()=>{I(!1),w||x(null)},z=()=>{y(!1),I(!0)};return o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[o.jsx("div",{className:"mb-3 flex items-center justify-between px-4",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h3",{className:"text-foreground text-sm font-semibold",children:"Knowledge"}),!n&&t.length>0&&o.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",t.length,")"]})]})}),o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col px-4 pb-3",children:[n&&o.jsx("div",{className:"flex items-center justify-center p-4",children:o.jsx(ws,{})}),r&&o.jsx(Xt,{variant:"error",message:`Error loading files: ${r}`}),!n&&!r&&o.jsxs(o.Fragment,{children:[f?null:o.jsx(Rm,{name:"project-files",accept:"*",multiple:!0,value:f,onChange:M,onValidate:_}),t.length>0&&o.jsx("div",{className:"mt-4 min-h-0 flex-1 overflow-y-auto border-t",children:R.map(Z=>{const J=C===Z.filename,ce=J?o.jsx(yS,{description:Z.description??void 0,size:Z.size,lastModified:Z.last_modified,mimeType:Z.mime_type}):void 0;return o.jsx("div",{className:"border-r border-l",children:o.jsx(vS,{filename:Z.filename,description:Z.description||Pc(Z.last_modified),mimeType:Z.mime_type,size:Z.size,status:"completed",context:"list",expandable:!0,expanded:J,expandedContent:ce,actions:{onInfo:()=>$(Z.filename),onEdit:()=>V(Z),onDownload:()=>c(Z),onDelete:()=>O(Z),onPreview:()=>W(Z)}},Z.filename)},Z.filename)})})]})]}),o.jsx(S7,{isOpen:!!f,files:f,onClose:F,onConfirm:L,isSubmitting:m,error:N,onClearError:D}),o.jsx(L7,{isOpen:w,artifact:g,onClose:H,onEdit:z}),o.jsx(O7,{isOpen:j,artifact:g,onClose:Q,onSave:X,isSaving:b}),o.jsx(F7,{isOpen:!!P,fileToDelete:P,handleConfirmDelete:K,setFileToDelete:E})]})},$7=({project:e,onChatClick:t,onStartNewChat:n})=>{const{sessions:r,isLoading:s,error:a}=bP(e.id);return o.jsxs("div",{className:"px-6 py-4",children:[o.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[o.jsx("h3",{className:"text-foreground text-sm font-semibold",children:"Chats"}),n&&o.jsxs(ye,{onClick:n,size:"sm",children:[o.jsx(Vo,{className:"mr-2 h-4 w-4"}),"New Chat"]})]}),s&&o.jsx("div",{className:"flex items-center justify-center p-8",children:o.jsx(ws,{size:"small"})}),a&&o.jsxs("div",{className:"text-destructive border-destructive/50 rounded-md border p-4 text-sm",children:["Error loading chats: ",a]}),!s&&!a&&r.length===0&&o.jsxs("div",{className:"flex flex-col items-center justify-center rounded-md border border-dashed p-8 text-center",children:[o.jsx(Nc,{className:"text-muted-foreground mb-2 h-8 w-8"}),o.jsx("p",{className:"text-muted-foreground mb-4 text-sm",children:"No chats. Start a chat with all the knowledge and context from this project."}),n&&o.jsxs(ye,{onClick:n,size:"sm",children:[o.jsx(Vo,{className:"mr-2 h-4 w-4"}),"Start New Chat"]})]}),!s&&!a&&r.length>0&&o.jsx("div",{className:"space-y-2",children:r.map(i=>o.jsx("div",{className:"hover:bg-accent/50 cursor-pointer rounded-md border p-3 shadow-sm transition-colors",onClick:()=>t(i.id),role:"button",tabIndex:0,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),t(i.id))},children:o.jsx("div",{className:"flex items-start justify-between gap-2",children:o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("p",{className:"text-foreground truncate text-sm font-medium",children:i.name||`Chat ${i.id.substring(0,8)}`}),o.jsxs("div",{className:"text-muted-foreground mt-1 flex items-center gap-1 text-xs",children:[o.jsx(Bv,{className:"h-3 w-3"}),o.jsx("span",{children:Ah(i.updatedTime)})]})]})})},i.id))})]})},U7=({project:e,onBack:t,onStartNewChat:n,onChatClick:r})=>{const{updateProject:s,projects:a,deleteProject:i}=Bs(),[l,c]=d.useState(!1),[u,h]=d.useState(null),[f,p]=d.useState(!1),[m,v]=d.useState(e.name),[g,x]=d.useState(e.description||""),[w,y]=d.useState(null),[C,S]=d.useState(!1),[j,I]=d.useState(!1),b=async R=>{h(null),c(!0);try{const _={systemPrompt:R};await s(e.id,_)}catch(_){const M=_ instanceof Error?_.message:"Failed to update instructions";throw h(M),_}finally{c(!1)}},k=async R=>{c(!0);try{const _={defaultAgentId:R};await s(e.id,_)}catch(_){throw console.error("Failed to update default agent:",_),_}finally{c(!1)}},N=async()=>{const R=m.trim(),_=g.trim();if(a.some(L=>L.id!==e.id&&L.name.toLowerCase()===R.toLowerCase())){y("A project with this name already exists");return}y(null),c(!0);try{const L={};R!==e.name&&(L.name=R),_!==(e.description||"")&&(L.description=_),Object.keys(L).length>0&&await s(e.id,L),p(!1)}catch(L){console.error("Failed to update project:",L),y(L instanceof Error?L.message:"Failed to update project")}finally{c(!1)}},A=()=>{v(e.name),x(e.description||""),p(!1),y(null)},P=()=>{S(!0)},E=async()=>{I(!0);try{await i(e.id),S(!1),t()}catch(R){console.error("Failed to delete project:",R)}finally{I(!1)}};return o.jsxs("div",{className:"flex h-full flex-col",children:[o.jsx(sa,{title:e.name,breadcrumbs:[{label:"Projects",onClick:t},{label:e.name}],buttons:[o.jsxs(ye,{variant:"ghost",size:"sm",onClick:()=>p(!0),className:"gap-2",children:[o.jsx(ys,{className:"h-4 w-4"}),"Edit Details"]},"edit"),o.jsxs(Ga,{children:[o.jsx(qa,{asChild:!0,children:o.jsx(ye,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:o.jsx(fo,{className:"h-4 w-4"})})}),o.jsx(Ya,{align:"end",children:o.jsxs(An,{onClick:P,children:[o.jsx(Ho,{className:"mr-2 h-4 w-4"}),"Delete"]})})]},"more")]}),o.jsxs("div",{className:"flex min-h-0 flex-1",children:[o.jsxs("div",{className:"w-[60%] overflow-y-auto border-r",children:[e.description&&o.jsx("div",{className:"px-8 py-4",children:o.jsx("p",{className:"text-muted-foreground text-sm",children:e.description})}),r&&o.jsx($7,{project:e,onChatClick:r,onStartNewChat:n})]}),o.jsxs("div",{className:"flex min-h-0 w-[40%] flex-col",children:[o.jsx(M7,{project:e,onSave:b,isSaving:l,error:u}),o.jsx(D7,{project:e,onSave:k,isSaving:l}),o.jsx(z7,{project:e})]})]}),o.jsx(C5,{children:o.jsx(ye,{variant:"outline","data-testid":"closeButton",title:"Close",onClick:t,children:"Close"})}),o.jsx(Nr,{open:f,onOpenChange:p,children:o.jsxs(Tr,{onOpenAutoFocus:R=>R.preventDefault(),children:[o.jsxs(rs,{children:[o.jsx(Ar,{children:"Edit Project Details"}),o.jsx(Ir,{children:"Update the name and description for this project."})]}),o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:"Name*"}),o.jsx(_r,{value:m,onChange:R=>v(R.target.value),placeholder:"Project name",disabled:l,maxLength:255,autoFocus:!1})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium",children:"Description*"}),o.jsx(ts,{value:g,onChange:R=>x(R.target.value),placeholder:"Project description",rows:4,disabled:l,maxLength:1e3}),o.jsxs("div",{className:"text-muted-foreground text-right text-xs",children:[g.length,"/1000"]})]}),w&&o.jsx(Xt,{variant:"error",message:w})]}),o.jsxs(Cs,{children:[o.jsx(ye,{variant:"outline",onClick:A,disabled:l,children:"Discard Changes"}),o.jsx(ye,{onClick:N,disabled:l,children:"Save"})]})]})}),o.jsx(t_,{isOpen:C,onClose:()=>S(!1),onConfirm:E,project:e,isDeleting:j})]})},cv=()=>{const e=bo(),t=gw(),{projects:n,isLoading:r,createProject:s,activeProject:a,setActiveProject:i,refetch:l,searchQuery:c,setSearchQuery:u,filteredProjects:h,deleteProject:f}=Bs(),{handleNewSession:p,handleSwitchSession:m,addNotification:v,displayError:g}=$t(),[x,w]=d.useState(!1),[y,C]=d.useState(!1),[S,j]=d.useState(!1),[I,b]=d.useState(null),[k,N]=d.useState(!1),[A,P]=d.useState(!1),[E,R]=d.useState(null);d.useEffect(()=>{if(t!=null&&t.projectId){const H=n.find(Q=>Q.id===t.projectId)||null;R(H)}else a?e(`/projects/${a.id}`,{replace:!0}):(R(null),i(null))},[t==null?void 0:t.projectId,a,n,e,i]);const _=async H=>{C(!0);try{const Q=new FormData;Q.append("name",H.name),H.description&&Q.append("description",H.description);const z=await s(Q);w(!1),await l(),e(`/projects/${z.id}`)}finally{C(!1)}},M=H=>{e(`/projects/${H.id}`)},L=()=>{i(null),e("/projects")},F=async H=>{E&&i(E),await m(H),e("chat")},D=()=>{w(!0)},O=H=>{b(H),j(!0)},K=async()=>{if(I){N(!0);try{await f(I.id),j(!1),b(null)}catch(H){console.error("Failed to delete project:",H)}finally{N(!1)}}},$=d.useCallback(async()=>{E&&(i(E),await p(!0),e("chat"))},[E,i,p,e]),W=async H=>{try{const Q=await Ie.webui.get(`/api/v1/projects/${H.id}/export`,{fullResponse:!0});if(!Q.ok)throw new Error(`Failed to export project: ${Q.statusText}`);const z=await Q.blob(),Z=`project-${H.name.replace(/[^a-z0-9]/gi,"-").toLowerCase()}-${Date.now()}.zip`;hl(z,Z),v("Project exported","success")}catch(Q){console.error("Failed to export project:",Q),g({title:"Failed to Export Project",error:Zt(Q,"An unknown error occurred while exporting the project.")})}},V=async(H,Q)=>{try{const z=new FormData;z.append("file",H),z.append("options",JSON.stringify(Q));const Z=await Ie.webui.post("/api/v1/projects/import",z);if(Z.warnings&&Z.warnings.length>0){const J=Z.warnings.length===1?Z.warnings[0]:`Import completed with ${Z.warnings.length} warnings:
|
|
434
|
+
${Z.warnings.join(`
|
|
435
|
+
`)}`;v(J,"info")}await l(),e(`/projects/${Z.projectId}`),v(`Project imported with ${Z.artifactsImported} artifacts`,"success")}catch(z){throw console.error("Failed to import project:",z),z}},X=E!==null;return o.jsxs("div",{className:"flex h-full w-full flex-col",children:[!X&&o.jsx(sa,{title:"Projects",buttons:[o.jsxs(ye,{variant:"ghost",title:"Import Project",onClick:()=>P(!0),children:[o.jsx(Vv,{className:"size-4"}),"Import Project"]},"importProject"),o.jsxs(ye,{"data-testid":"refreshProjects",disabled:r,variant:"ghost",title:"Refresh Projects",onClick:()=>l(),children:[o.jsx(uu,{className:"size-4"}),"Refresh Projects"]},"refreshProjects")]}),o.jsx("div",{className:"min-h-0 flex-1",children:X?o.jsx(U7,{project:E,onBack:L,onStartNewChat:$,onChatClick:F}):o.jsx(R7,{projects:h,searchQuery:c,onSearchChange:u,onProjectClick:M,onCreateNew:D,onDelete:O,onExport:W,isLoading:r})}),o.jsx(b7,{isOpen:x,onClose:()=>w(!1),onSubmit:_,isSubmitting:y}),o.jsx(t_,{isOpen:S,onClose:()=>{j(!1),b(null)},onConfirm:K,project:I,isDeleting:k}),o.jsx(T7,{open:A,onOpenChange:P,onImport:V})]})};let hc=null,mc=null;function B7({children:e}){const{fetchCsrfToken:t}=Xy(),[n,r]=d.useState(hc),[s,a]=d.useState(!hc&&!mc),[i,l]=d.useState(mc);return d.useEffect(()=>{if(hc||mc)return;let c=!0;return(async()=>{var h,f,p;a(!0),l(null);try{let m=await Ie.webui.get("/api/v1/config",{credentials:"include",headers:{Accept:"application/json"},fullResponse:!0}),v;if(m.ok)v=await m.json();else{const j=await m.text();if(console.error("Initial config fetch failed:",m.status,j),m.status===403){console.log("Config fetch failed with 403, attempting to get CSRF token first...");const I=await t();if(!I)throw new Error("Failed to obtain CSRF token after config fetch failed.");if(console.log("Retrying config fetch with CSRF token..."),m=await Ie.webui.get("/api/v1/config",{credentials:"include",headers:{"X-CSRF-TOKEN":I,Accept:"application/json"},fullResponse:!0}),!m.ok){const b=await m.text();throw console.error("Config fetch retry failed:",m.status,b),new Error(`Failed to fetch config on retry: ${m.status} ${b}`)}v=await m.json()}else throw new Error(`Failed to fetch config: ${m.status} ${j}`)}const g=v.frontend_use_authorization??!1;g&&(console.log("Fetching CSRF token for config-related requests..."),await t());const x=((h=v.frontend_feature_enablement)==null?void 0:h.projects)??!1,w=((f=v.frontend_feature_enablement)==null?void 0:f.background_tasks)??!1,y=((p=v.background_tasks_config)==null?void 0:p.default_timeout_ms)??36e5,C=!!v.frontend_platform_server_url,S={webuiServerUrl:v.frontend_server_url,platformServerUrl:v.frontend_platform_server_url,configAuthLoginUrl:v.frontend_auth_login_url,configUseAuthorization:g,configWelcomeMessage:v.frontend_welcome_message,configRedirectUrl:v.frontend_redirect_url,configCollectFeedback:v.frontend_collect_feedback,configBotName:v.frontend_bot_name,configLogoUrl:v.frontend_logo_url,configFeatureEnablement:v.frontend_feature_enablement??{},frontend_use_authorization:v.frontend_use_authorization,persistenceEnabled:v.persistence_enabled??!1,projectsEnabled:x,validationLimits:v.validation_limits,backgroundTasksEnabled:w,backgroundTasksDefaultTimeoutMs:y,platformConfigured:C};c&&(hc=S,r(S),Ie.configure(S.webuiServerUrl,S.platformServerUrl),console.log("API client configured with:",{webui:S.webuiServerUrl,platform:S.platformServerUrl})),console.log("App config processed and set:",S)}catch(m){if(console.error("Error initializing app:",m),c){const v=m.message||"Failed to load application configuration.";mc=v,l(v)}}finally{c&&a(!1)}})(),()=>{c=!1}},[t]),n?o.jsx(Gy.Provider,{value:n,children:e}):s?o.jsx(rr,{variant:"loading",title:"Loading Configuration...",className:"h-screen w-screen"}):i?o.jsx(rr,{variant:"error",title:"Configuration Error",subtitle:"Please check the backend server and network connection, then refresh the page.",className:"h-screen w-screen"}):o.jsx(rr,{variant:"loading",title:"Initializing Application...",className:"h-screen w-screen"})}const V7=({children:e})=>{const[t,n]=d.useState(null),[r,s]=d.useState(!1),[a,i]=d.useState(!1),[l,c]=d.useState(null),[u,h]=d.useState({}),[f,p]=d.useState([]),[m,v]=d.useState(null),[g,x]=d.useState(0),[w,y]=d.useState(!1),C=10,S=d.useRef(null),j=d.useRef(null),I=d.useRef(null);d.useEffect(()=>{j.current=t},[t]);const b=d.useCallback(F=>{h(D=>{var W,V,X;const O=F.task_id;if(!O)return F.direction==="discovery"||console.warn("TaskMonitorContext: Received event without task_id, skipping:",F),D;const K=D[O],$=new Date(F.timestamp);if(K){const H=[...K.events,F].sort((Q,z)=>new Date(Q.timestamp).getTime()-new Date(z.timestamp).getTime());return{...D,[O]:{...K,events:H,lastUpdated:$}}}else{let H="Task started...";if(F.direction==="request"&&((V=(W=F.full_payload)==null?void 0:W.method)!=null&&V.startsWith("message/"))){const z=F.full_payload.params;if((X=z==null?void 0:z.message)!=null&&X.parts){const Z=z.message.parts.filter(J=>J.kind==="text"&&J.text);Z.length>0&&(H=Z[Z.length-1].text)}}const Q={taskId:O,initialRequestText:H,events:[F],firstSeen:$,lastUpdated:$};return p(z=>[O,...z.filter(Z=>Z!==O)]),{...D,[O]:Q}}})},[]),k=d.useCallback(()=>{console.log("TaskMonitorContext: SSE connection opened."),s(!1),i(!0),c(null),x(0),y(!1),I.current&&(clearTimeout(I.current),I.current=null)},[]),N=d.useCallback(F=>{try{const D=JSON.parse(F.data);b(D)}catch(D){console.error("TaskMonitorContext: Failed to parse SSE 'a2a_message' event data:",D,"Raw data:",F.data),c("Received unparseable 'a2a_message' event from server.")}},[b]),A=d.useCallback(F=>{console.error("TaskMonitorContext: SSE connection error:",F),s(!1),i(!1),S.current&&S.current.readyState===EventSource.CLOSED?c("Task Monitor SSE connection closed by server or network issue."):c("Task Monitor SSE connection error occurred."),S.current&&(S.current.close(),S.current=null),I.current&&(clearTimeout(I.current),I.current=null)},[]),P=d.useCallback(async()=>{if(a||r){console.warn("TaskMonitorContext: Stream is already active or connecting.");return}console.log("TaskMonitorContext: Attempting to connect stream..."),s(!0);try{const F=await Ie.webui.post("/api/v1/visualization/subscribe",{subscription_targets:[{type:"my_a2a_messages"}]},{fullResponse:!0});if(!F.ok){const V=await F.json().catch(()=>({detail:"Failed to subscribe"}));if(V.error_type==="authorization_failure"){const X=V.message||"Access denied: insufficient permissions",H=V.suggested_action?` ${V.suggested_action}`:"";throw new Error(`${X}${H}`)}else if(V.error_type==="subscription_failure"){const X=V.message||"Subscription failed",H=V.suggested_action?` ${V.suggested_action}`:"";throw new Error(`${X}${H}`)}else throw new Error(V.detail||V.message||`Subscription failed: ${F.statusText}`)}const D=await F.json();n(D.stream_id);const O=D.sse_endpoint_url.startsWith("/")?Ie.webui.getFullUrl(D.sse_endpoint_url):D.sse_endpoint_url;S.current&&S.current.close();const K=jh(),$=`${O}${K?`?token=${K}`:""}`,W=new EventSource($,{withCredentials:!0});S.current=W,W.onopen=k,W.addEventListener("a2a_message",N),W.onerror=A}catch(F){console.error("TaskMonitorContext: Error connecting stream:",F),c(F instanceof Error?F.message:String(F)),s(!1),i(!1),n(null),S.current&&(S.current.close(),S.current=null),I.current&&(clearTimeout(I.current),I.current=null)}},[a,r,k,N,A]),E=d.useCallback(()=>{if(I.current){console.log("TaskMonitorContext: Reconnection already in progress, skipping...");return}if(g>=C){console.warn("TaskMonitorContext: Max reconnection attempts reached. Stopping auto-reconnection."),y(!1),c(`Connection lost. Max reconnection attempts (${C}) reached.`);return}const F=2e3;console.log(`TaskMonitorContext: Attempting reconnection ${g+1}/${C} in ${F}ms...`),y(!0),x(D=>D+1),I.current=setTimeout(()=>{P()},F)},[g,P]),R=d.useCallback(async()=>{console.log("TaskMonitorContext: Disconnecting stream..."),I.current&&(clearTimeout(I.current),I.current=null),S.current&&(S.current.close(),S.current=null);const F=j.current;if(F)try{await Ie.webui.delete(`/api/v1/visualization/${F}/unsubscribe`)}catch(D){console.error(`TaskMonitorContext: Error unsubscribing from stream ID: ${F}`,D)}n(null),s(!1),i(!1),c(null),h({}),p([]),v(null),x(0),y(!1)},[]);d.useEffect(()=>()=>{console.log("TaskMonitorProvider: Unmounting. Cleaning up Task Monitor SSE connection."),S.current&&(S.current.close(),S.current=null);const F=j.current;if(F){const D=Ie.webui.getFullUrl(`/api/v1/visualization/${F}/unsubscribe`);if(navigator.sendBeacon){const O=new FormData;navigator.sendBeacon(D,O)}else Ie.webui.delete(`/api/v1/visualization/${F}/unsubscribe`,{credentials:"include",keepalive:!0}).catch(O=>console.error("TaskMonitorProvider: Error in final unsubscribe on unmount (fetch):",O))}},[]),d.useEffect(()=>{!a&&!r&&(console.log("TaskProvider: Auto-connecting to task monitor stream..."),P())},[]),d.useEffect(()=>{!a&&!r&&l&&(console.log("TaskMonitorContext: Connection lost, initiating auto-reconnection..."),E())},[a,r,l,E]),d.useEffect(()=>()=>{I.current&&(clearTimeout(I.current),I.current=null)},[]);const _=d.useCallback(F=>{v(F)},[]),M=d.useCallback(async F=>{var D,O;try{const $=(await Ie.webui.get(`/api/v1/tasks/${F}/events`)).tasks,W={};for(const[V,X]of Object.entries($)){const H=X.events,Q={taskId:V,initialRequestText:X.initial_request_text||"Task loaded from history",events:H,firstSeen:new Date(((D=H[0])==null?void 0:D.timestamp)||Date.now()),lastUpdated:new Date(((O=H[H.length-1])==null?void 0:O.timestamp)||Date.now())};W[V]=Q}return h(V=>({...V,...W})),p(V=>V.includes(F)?V:[F,...V]),W[F]||null}catch(K){return console.error(`TaskProvider: Error loading task ${F} from backend:`,K),null}},[]),L={isTaskMonitorConnecting:r,isTaskMonitorConnected:a,taskMonitorSseError:l,monitoredTasks:u,monitoredTaskOrder:f,highlightedStepId:m,isReconnecting:w,reconnectionAttempts:g,connectTaskMonitorStream:P,disconnectTaskMonitorStream:R,setHighlightedStepId:_,loadTaskFromBackend:M};return o.jsx(Yy.Provider,{value:L,children:e})},Pn=[];for(let e=0;e<256;++e)Pn.push((e+256).toString(16).slice(1));function H7(e,t=0){return(Pn[e[t+0]]+Pn[e[t+1]]+Pn[e[t+2]]+Pn[e[t+3]]+"-"+Pn[e[t+4]]+Pn[e[t+5]]+"-"+Pn[e[t+6]]+Pn[e[t+7]]+"-"+Pn[e[t+8]]+Pn[e[t+9]]+"-"+Pn[e[t+10]]+Pn[e[t+11]]+Pn[e[t+12]]+Pn[e[t+13]]+Pn[e[t+14]]+Pn[e[t+15]]).toLowerCase()}let tf;const W7=new Uint8Array(16);function Z7(){if(!tf){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");tf=crypto.getRandomValues.bind(crypto)}return tf(W7)}const G7=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),uv={randomUUID:G7};function q7(e,t,n){var s;e=e||{};const r=e.random??((s=e.rng)==null?void 0:s.call(e))??Z7();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,H7(r)}function ss(e,t,n){return uv.randomUUID&&!e?uv.randomUUID():q7(e)}const Y7=1*1024*1024,K7=({children:e})=>{const{configWelcomeMessage:t,persistenceEnabled:n,configCollectFeedback:r,backgroundTasksEnabled:s,backgroundTasksDefaultTimeoutMs:a}=on(),{activeProject:i,setActiveProject:l,projects:c}=Bs(),{ErrorDialog:u,setError:h}=kP(),[f,p]=d.useState(""),[m,v]=d.useState([]),[g,x]=d.useState(!1),[w,y]=d.useState([]),C=d.useRef([]),[S]=d.useState(!0),j=d.useCallback(ke=>{y(Oe=>{const Re=typeof ke=="function"?ke(Oe):ke;return C.current=Re,Re})},[]),[I,b]=d.useState([]),[k,N]=d.useState(null),A=d.useRef(null),[P,E]=d.useState(""),[R,_]=d.useState(!1),M=d.useRef(new Set),L=d.useRef(R);d.useEffect(()=>{L.current=R},[R]);const F=d.useRef(f);d.useEffect(()=>{F.current=f},[f]);const[D,O]=d.useState(null),K=d.useRef(null),$=d.useRef(!1),W=d.useRef(null),V=d.useRef(0),X=d.useRef([]),H=d.useRef([]),Q=d.useRef(new Map),{agents:z,agentNameMap:Z,error:J,isLoading:ce,refetch:de}=SR(),{artifacts:fe,isLoading:ge,refetch:T,setArtifacts:le}=ZR(f),[ie,q]=d.useState(!0),[B,ee]=d.useState("files"),[U,Y]=d.useState({}),[G,ae]=d.useState(null),oe=d.useCallback((ke,Oe)=>{b(Re=>{if(Re.find(Ae=>Ae.message===ke))return Re;const ht=Date.now().toString(),We={id:ht,message:ke,type:Oe||"info"};return setTimeout(()=>{b(Ae=>Ae.filter(bt=>bt.id!==ht))},4e3),[...Re,We]})},[]),{preview:{availableVersions:se,currentVersion:me,content:Pe},previewArtifact:Ne,openPreview:dt,navigateToVersion:Ht,closePreview:wt,setPreviewByArtifact:Ot}=jR({sessionId:f,projectId:i==null?void 0:i.id,artifacts:fe,setError:h}),{uploadArtifactFile:gt,isDeleteModalOpen:Nt,artifactToDelete:Jt,openDeleteModal:Wt,closeDeleteModal:xe,confirmDelete:$e,isArtifactEditMode:Me,setIsArtifactEditMode:Fe,selectedArtifactFilenames:ft,setSelectedArtifactFilenames:He,isBatchDeleteModalOpen:Ut,setIsBatchDeleteModalOpen:Qe,handleDeleteSelectedArtifacts:St,confirmBatchDeleteArtifacts:Lt,downloadAndResolveArtifact:ln}=kR({sessionId:f,artifacts:fe,setArtifacts:le,artifactsRefetch:T,addNotification:oe,setError:h,previewArtifact:Ne,closePreview:wt}),{backgroundTasks:nn,notifications:On,registerBackgroundTask:Un,unregisterBackgroundTask:Yt,updateTaskTimestamp:te,isTaskRunningInBackground:re,checkTaskStatus:ue}=YR({userId:"sam_dev_user",onTaskCompleted:d.useCallback(ke=>{oe("Background task completed","success"),typeof window<"u"&&(window.dispatchEvent(new CustomEvent("background-task-completed",{detail:{taskId:ke}})),window.dispatchEvent(new CustomEvent("new-chat-session")))},[oe]),onTaskFailed:d.useCallback((ke,Oe)=>{h({title:"Background Task Failed",error:Oe}),typeof window<"u"&&(window.dispatchEvent(new CustomEvent("background-task-completed",{detail:{taskId:ke}})),window.dispatchEvent(new CustomEvent("new-chat-session")))},[h])});d.useEffect(()=>{X.current=nn},[nn]),d.useEffect(()=>{H.current=m},[m]);const Ce=d.useCallback(ke=>{var Ze,ht;let Oe="";const Re=ke.parts||[];for(const We of Re)We.kind==="text"?Oe+=We.text:We.kind==="artifact"&&(Oe+=`«artifact_return:${We.name}»`);return{id:((Ze=ke.metadata)==null?void 0:Ze.messageId)||`msg-${ss()}`,type:ke.isUser?"user":"agent",text:Oe,parts:ke.parts,uploadedFiles:(ht=ke.uploadedFiles)==null?void 0:ht.map(We=>({name:We.name,type:We.type})),isError:ke.isError}},[]),je=d.useCallback(async(ke,Oe)=>{const Re=Oe||f;if(!n||!Re||M.current.has(ke.task_id))return!1;M.current.add(ke.task_id);try{return await Ie.webui.post(`/api/v1/sessions/${Re}/chat-tasks`,{taskId:ke.task_id,userMessage:ke.user_message,messageBubbles:JSON.stringify(ke.message_bubbles),taskMetadata:ke.task_metadata?JSON.stringify(ke.task_metadata):null}),!0}catch(Ze){return console.error(`Failed saving task ${ke.task_id}:`,Ze),!1}finally{setTimeout(()=>{M.current.delete(ke.task_id)},100)}},[f,n]),Be=d.useCallback((ke,Oe,Re,Ze)=>{const ht=/«artifact_return:([^»]+)»/g,We=/«artifact:([^»]+)»/g,Ae=ut=>{let Rt=ut;if(ut.includes(":")){const pn=ut.split(":"),Dr=pn[pn.length-1];/^\d+$/.test(Dr)&&(Rt=pn.slice(0,-1).join(":"))}return{kind:"artifact",status:"completed",name:Rt,file:{name:Rt,uri:`artifact://${Oe}/${Rt}`}}};let bt;for(;(bt=ht.exec(ke))!==null;){const ut=bt[1],Rt=ut.includes(":")&&/:\d+$/.test(ut)?ut.substring(0,ut.lastIndexOf(":")):ut;Re.has(Rt)||(Re.add(Rt),Ze.push(Ae(ut)))}for(;(bt=We.exec(ke))!==null;){const ut=bt[1];Re.has(ut)||(Re.add(ut),Ze.push(Ae(ut)))}},[]),qe=d.useCallback((ke,Oe)=>ke.messageBubbles.map(Re=>{const Ze=[],ht=Re.parts||[{kind:"text",text:Re.text||""}],We=new Set;Re.text&&Be(Re.text,Oe,We,Ze);for(const Ae of ht)if(Ae.kind==="text"&&Ae.text){let bt=Ae.text;Be(bt,Oe,We,Ze),bt=bt.replace(/«artifact_return:[^»]+»/g,""),bt=bt.replace(/«artifact:[^»]+»/g,""),bt=bt.replace(/«status_update:[^»]+»\n?/g,""),bt.trim()&&Ze.push({kind:"text",text:bt})}else if(Ae.kind==="artifact"){const bt=Ae.name;bt&&!We.has(bt)&&(We.add(bt),Ze.push(Ae))}else Ze.push(Ae);return{taskId:ke.taskId,role:Re.type==="user"?"user":"agent",parts:Ze,isUser:Re.type==="user",isComplete:!0,files:Re.files,uploadedFiles:Re.uploadedFiles,artifactNotification:Re.artifactNotification,isError:Re.isError,metadata:{messageId:Re.id,sessionId:Oe,lastProcessedEventSequence:0}}}),[Be]),Te=d.useCallback(async ke=>{var Rt,pn,Dr;const Oe=await Ie.webui.get(`/api/v1/sessions/${ke}/chat-tasks`);if(F.current!==ke){console.log(`Session ${ke} is no longer the active session: ${F.current}`);return}const ht=(Oe.tasks||[]).map(Ft=>({...Ft,messageBubbles:JSON.parse(Ft.messageBubbles),taskMetadata:Ft.taskMetadata?JSON.parse(Ft.taskMetadata):null})).map(B2),We=[];for(const Ft of ht){const No=qe(Ft,ke);We.push(...No)}const Ae={},bt=[];for(const Ft of ht)(Rt=Ft.taskMetadata)!=null&&Rt.feedback&&(Ae[Ft.taskId]={type:Ft.taskMetadata.feedback.type,text:Ft.taskMetadata.feedback.text||""}),(pn=Ft.taskMetadata)!=null&&pn.rag_data&&Array.isArray(Ft.taskMetadata.rag_data)&&bt.push(...Ft.taskMetadata.rag_data);let ut=null;for(let Ft=ht.length-1;Ft>=0;Ft--)if((Dr=ht[Ft].taskMetadata)!=null&&Dr.agent_name){ut=ht[Ft].taskMetadata.agent_name;break}if(v(We),Y(Ae),bt.length>0&&j(bt),ut&&E(ut),ht.length>0){const Ft=ht[ht.length-1];O(Ft.taskId)}},[qe,j]),[Se,Ee]=d.useState(null),[Le,_e]=d.useState(null),[et,be]=d.useState(!1),ne=d.useCallback(ke=>{q(!1),ee(ke),typeof window<"u"&&window.dispatchEvent(new CustomEvent("expand-side-panel",{detail:{tab:ke}}))},[]),he=d.useCallback(()=>{K.current&&(clearTimeout(K.current),K.current=null),A.current&&(A.current.close(),A.current=null),$.current=!1},[]),we=d.useCallback(ke=>{var pn,Dr,Ft,No,Ol,Ws;V.current+=1;const Oe=V.current;let Re;try{Re=JSON.parse(ke.data)}catch(Vt){console.error("Failed to parse SSE message:",Vt);return}if("result"in Re&&Re.result){const Vt=Re.result,at=Vt.kind==="task"?Vt.id:Vt.kind==="status-update"?Vt.taskId:void 0;at&&re(at)&&te(at,Date.now())}if("error"in Re&&Re.error){const at=`Error: ${Re.error.message}`;v(tt=>{const Je=tt.filter(nt=>!nt.isStatusBubble);return Je.push({role:"agent",parts:[{kind:"text",text:at}],isUser:!1,isError:!0,isComplete:!0,metadata:{messageId:`msg-${ss()}`,lastProcessedEventSequence:Oe}}),Je}),x(!1),he(),N(null);return}if(!("result"in Re)||!Re.result){console.warn("Received SSE message without a result or error field.",Re);return}const Ze=Re.result;let ht=!1,We,Ae;switch(Ze.kind){case"task":ht=!0,We=void 0,Ae=Ze.id;break;case"status-update":ht=Ze.final,We=(pn=Ze.status)==null?void 0:pn.message,Ae=Ze.taskId;break;case"artifact-update":T();return;default:console.warn("Received unknown result kind in SSE message:",Ze);return}if(We!=null&&We.parts){const Vt=We.parts.filter(at=>at.kind==="data");if(Vt.length>0)for(const at of Vt){const tt=at.data;if(tt&&typeof tt=="object"&&"type"in tt)switch(tt.type){case"agent_progress_update":{if(W.current=String((tt==null?void 0:tt.status_text)??"Processing..."),We.parts.filter(nt=>nt.kind!=="data").length===0)return;break}case"artifact_creation_progress":{const{filename:Je,status:nt,bytes_transferred:At,mime_type:ze,description:rt,artifact_chunk:Ge,version:lt}=tt;let xr=!1;le(vr=>{const gn=vr.findIndex(Jn=>Jn.filename===Je);if(gn>=0){const Jn=[...vr],Qt=Jn[gn],wr=Qt.isDisplayed||!1;return nt==="completed"&&wr&&(xr=!0),Jn[gn]={...Qt,description:rt!==void 0?rt:Qt.description,size:At||Qt.size,last_modified:new Date().toISOString(),uri:Qt.uri||`artifact://${f}/${Je}`,accumulatedContent:nt==="in-progress"&&Ge?(Qt.accumulatedContent||"")+Ge:nt==="completed"&&!wr?void 0:Qt.accumulatedContent,isAccumulatedContentPlainText:nt==="in-progress"&&Ge?!0:Qt.isAccumulatedContentPlainText,mime_type:nt==="completed"&&ze?ze:Qt.mime_type,needsEmbedResolution:nt==="completed"?!0:Qt.needsEmbedResolution},Jn}else if(rt!==void 0||nt==="in-progress")return[...vr,{filename:Je,description:rt||null,mime_type:ze||"application/octet-stream",size:At||0,last_modified:new Date().toISOString(),uri:`artifact://${f}/${Je}`,accumulatedContent:nt==="in-progress"&&Ge?Ge:void 0,isAccumulatedContentPlainText:!!(nt==="in-progress"&&Ge),needsEmbedResolution:nt==="completed"}];return vr}),xr&&setTimeout(()=>{ln(Je).catch(vr=>{console.error(`Auto-download failed for ${Je}:`,vr)})},100),v(vr=>{const gn=[...vr];let Jn=gn.findLastIndex(bn=>!bn.isUser&&bn.taskId===Ae);if(Jn===-1){const bn={role:"agent",parts:[],taskId:Ae,isUser:!1,isComplete:!1,isStatusBubble:!1,metadata:{lastProcessedEventSequence:Oe}};gn.push(bn),Jn=gn.length-1}const Qt={...gn[Jn],parts:[...gn[Jn].parts]};Qt.isStatusBubble=!1;const wr=Qt.parts.findIndex(bn=>bn.kind==="artifact"&&bn.name===Je);if(nt==="in-progress")if(wr>-1){const ia={...Qt.parts[wr],bytesTransferred:At,status:"in-progress"};Qt.parts[wr]=ia}else{const bn={kind:"artifact",status:"in-progress",name:Je,bytesTransferred:At};Qt.parts.push(bn)}else if(nt==="completed"){const bn={name:Je,mime_type:ze,uri:lt!==void 0?`artifact://${f}/${Je}?version=${lt}`:`artifact://${f}/${Je}`};if(wr>-1){const hi={...Qt.parts[wr],status:"completed",file:bn};delete hi.bytesTransferred,Qt.parts[wr]=hi}else Qt.parts.push({kind:"artifact",status:"completed",name:Je,file:bn});T()}else{const bn=`Failed to create artifact: ${Je}`;if(wr>-1){const hi={...Qt.parts[wr],status:"failed",error:bn};delete hi.bytesTransferred,Qt.parts[wr]=hi}else Qt.parts.push({kind:"artifact",status:"failed",name:Je,error:bn});Qt.isError=!0}return gn[Jn]=Qt,gn.filter(bn=>!bn.isStatusBubble||bn.parts.some(ia=>ia.kind==="artifact"||ia.kind==="file"))});return}case"tool_invocation_start":break;case"authentication_required":{const Je=tt==null?void 0:tt.auth_uri,nt=typeof(tt==null?void 0:tt.target_agent)=="string"?tt.target_agent:"Agent",At=typeof(tt==null?void 0:tt.gateway_task_id)=="string"?tt.gateway_task_id:void 0;if(typeof Je=="string"&&Je.startsWith("http")){const ze={role:"agent",parts:[{kind:"text",text:""}],authenticationLink:{url:Je,text:"Click to Authenticate",targetAgent:nt,gatewayTaskId:At},isUser:!1,isComplete:!0,metadata:{messageId:`auth-${ss()}`}};v(rt=>[...rt,ze])}break}case"rag_info_update":{const Je=tt;S&&j(nt=>{const At=Je.search_turn??nt.filter(Ge=>Ge.taskId===Ae).length,ze=(Je.sources||[]).map((Ge,lt)=>({citationId:Ge.citationId||`s${At}r${lt}`,title:Ge.title||Ge.url,sourceUrl:Ge.url,url:Ge.url,contentPreview:`Source: ${Ge.title||Ge.url}`,relevanceScore:1,retrievedAt:Je.timestamp,metadata:{favicon:Ge.favicon||`https://www.google.com/s2/favicons?domain=${Ge.url}&sz=32`,type:"web_search",source_type:Ge.source_type||"web"}})),rt=nt.findIndex(Ge=>Ge.searchType==="deep_research"&&Ge.taskId===Ae&&Ge.query===Je.query);if(rt!==-1){const Ge=[...nt],lt=Ge[rt],xr=new Set(lt.sources.map(gn=>gn.sourceUrl||gn.url)),vr=ze.filter(gn=>!xr.has(gn.sourceUrl||gn.url));return Ge[rt]={...lt,title:Je.title||lt.title,sources:[...lt.sources,...vr]},Ge}else{const Ge={query:Je.query,title:Je.title,searchType:"deep_research",timestamp:Je.timestamp,sources:ze,taskId:Ae};return[...nt,Ge]}});break}case"deep_research_progress":{W.current=null;const Je=tt;if(Ae){const nt=Q.current.get(Ae)||[];if(Je.current_query){const At=nt.findIndex(ze=>ze.query===Je.current_query);if(At===-1)nt.push({query:Je.current_query,timestamp:new Date().toISOString(),urls:Je.fetching_urls||[]});else if(Je.fetching_urls&&Je.fetching_urls.length>0){const ze=nt[At],rt=new Set(ze.urls.map(lt=>lt.url)),Ge=Je.fetching_urls.filter(lt=>!rt.has(lt.url));Ge.length>0&&(nt[At]={...ze,urls:[...ze.urls,...Ge]})}}else if(Je.fetching_urls&&Je.fetching_urls.length>0&&nt.length>0){const At=nt.length-1,ze=nt[At],rt=new Set(ze.urls.map(lt=>lt.url)),Ge=Je.fetching_urls.filter(lt=>!rt.has(lt.url));Ge.length>0&&(nt[At]={...ze,urls:[...ze.urls,...Ge]})}Q.current.set(Ae,nt),tt.query_history=nt}break}case"tool_result":{const Je=tt.result_data;if(Je&&typeof Je=="object"&&Je.rag_metadata){const nt=Je.rag_metadata;if(nt&&S){console.log("[ChatProvider] Received tool_result with RAG metadata:",{searchType:nt.searchType,sourcesCount:(Dr=nt.sources)==null?void 0:Dr.length,taskId:Ae,sampleSources:(Ft=nt.sources)==null?void 0:Ft.slice(0,3).map(ze=>{var rt,Ge,lt;return{title:ze.title,fetched:(rt=ze.metadata)==null?void 0:rt.fetched,fetch_status:(Ge=ze.metadata)==null?void 0:Ge.fetch_status,contentPreview:(lt=ze.contentPreview)==null?void 0:lt.substring(0,100)}})});const At={query:nt.query,title:nt.title,searchType:nt.searchType,timestamp:nt.timestamp,sources:nt.sources,taskId:Ae,metadata:nt.metadata};nt.searchType==="deep_research"?(console.log("[ChatProvider] Replacing deep research RAG data for task",Ae),j(ze=>{const rt=ze.filter(xr=>xr.searchType==="deep_research"&&xr.taskId===Ae).length,lt=[...ze.filter(xr=>!(xr.searchType==="deep_research"&&xr.taskId===Ae)),At];return console.log("[ChatProvider] Deep research RAG data replaced:",{removedEntries:rt,newSourcesCount:At.sources.length}),lt})):j(ze=>[...ze,At])}}break}default:console.warn("Received unknown data part type:",tt.type)}}}const bt=(No=We==null?void 0:We.parts)==null?void 0:No.some(Vt=>{if(Vt.kind==="data"){const at=Vt;return at.data&&at.data.type==="deep_research_progress"}return!1}),ut=((Ol=We==null?void 0:We.parts)==null?void 0:Ol.filter(Vt=>{if(Vt.kind==="data"){const at=Vt;return at.data&&at.data.type==="deep_research_progress"}return!(Vt.kind==="text"&&bt)}))||[],Rt=ut.some(Vt=>Vt.kind==="file");if(v(Vt=>{var nt;const at=[...Vt];let tt=at[at.length-1];if(tt!=null&&tt.isStatusBubble&&(at.pop(),tt=at[at.length-1]),ut.length===1&&ut[0].kind==="data"&&ut[0].data&&ut[0].data.type==="deep_research_progress"&&tt&&!tt.isUser&&tt.taskId===Ze.taskId){const At={...tt,parts:ut,isComplete:ht||Rt,metadata:{...tt.metadata,lastProcessedEventSequence:Oe}};at[at.length-1]=At}else if(tt&&!tt.isUser&&tt.taskId===Ze.taskId&&ut.length>0){const At={...tt,parts:[...tt.parts,...ut],isComplete:ht||Rt,metadata:{...tt.metadata,lastProcessedEventSequence:Oe}};at[at.length-1]=At}else if(ut.some(ze=>ze.kind==="text"&&ze.text.trim()||ze.kind==="file"||ze.kind==="data"&&ze.data&&ze.data.type==="deep_research_progress")){const ze={role:"agent",parts:ut,taskId:Ze.taskId,isUser:!1,isComplete:ht||Rt,metadata:{messageId:((nt=Re.id)==null?void 0:nt.toString())||`msg-${ss()}`,sessionId:Ze.contextId,lastProcessedEventSequence:Oe}};at.push(ze)}if(ht){W.current=null;for(let ze=at.length-1;ze>=0;ze--){const rt=at[ze];if(rt.taskId===Ae&&rt.parts.some(Ge=>Ge.kind==="artifact"&&Ge.status==="in-progress")){const Ge=rt.parts.map(lt=>lt.kind==="artifact"&<.status==="in-progress"?{...lt,status:"failed",error:`Artifact creation for "${lt.name}" did not complete.`}:lt);at[ze]={...rt,parts:Ge,isError:!0,isComplete:!0}}}const At=at.findLastIndex(ze=>!ze.isUser&&ze.taskId===Ae);At!==-1&&(at[At]={...at[At],isComplete:!0,metadata:{...at[At].metadata,lastProcessedEventSequence:Oe}})}return at}),ht){if(L.current&&(oe("Task cancelled.","success"),K.current&&clearTimeout(K.current),_(!1)),Ae)if(re(Ae))Yt(Ae),typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"));else{const at=H.current.filter(tt=>tt.taskId===Ae&&!tt.isStatusBubble);if(at.length>0){const tt=at.map(Ce),Je=at.find(lt=>lt.isUser),nt=((Ws=Je==null?void 0:Je.parts)==null?void 0:Ws.filter(lt=>lt.kind==="text").map(lt=>lt.text).join(""))||"",ze=at.some(lt=>lt.isError)?"error":"completed",rt=C.current.filter(lt=>lt.taskId===Ae),Ge=Ze.contextId||f;je({task_id:Ae,user_message:nt,message_bubbles:tt,task_metadata:{schema_version:Mc,status:ze,agent_name:P,rag_data:rt.length>0?rt:void 0}},Ge).then(lt=>{lt&&typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}).catch(lt=>{console.error(`[ChatProvider] Error saving task ${Ae}:`,lt)})}}v(Vt=>Vt.map(at=>at.isUser||!at.parts.some(Je=>Je.kind==="artifact"&&Je.status==="in-progress")?at:{...at,parts:at.parts.map(Je=>{var nt;if(Je.kind==="artifact"&&Je.status==="in-progress"){const At=Je,ze={name:At.name,mime_type:(nt=At.file)==null?void 0:nt.mime_type,uri:`artifact://${f}/${At.name}`};return{kind:"artifact",status:"completed",name:At.name,file:ze}}return Je})})),x(!1),he(),N(null),$.current=!0,T(),Ae&&Q.current.delete(Ae),setTimeout(()=>{$.current=!1},100)}},[oe,he,T,f,P,je,Ce,ln,le,j,S,re,te,Yt]),Ve=d.useCallback(async(ke=!1)=>{const Oe="ChatProvider.handleNewSession:";he(),g&&k&&P&&!R&&(re(k)||Ie.webui.post(`/api/v1/tasks/${k}:cancel`,{jsonrpc:"2.0",id:`req-${ss()}`,method:"tasks/cancel",params:{id:k}}).catch(Ze=>console.warn(`${Oe} Failed to cancel current task:`,Ze))),K.current&&(clearTimeout(K.current),K.current=null),_(!1),p(""),Ee(null),i&&!ke?l(null):i&&ke&&console.log(`${Oe} Preserving project context: ${i.name}`),E(""),v([]),x(!1),N(null),O(null),wt(),$.current=!1,W.current=null,V.current=0,j([]),Q.current.clear(),typeof window<"u"&&window.dispatchEvent(new CustomEvent("focus-chat-input"))},[g,k,P,R,he,i,l,wt,re,j]),De=d.useCallback(ke=>{ae(ke),Ve()},[Ve]),ot=d.useCallback(()=>{ae(null)},[]),_t=d.useCallback(async ke=>{const Oe="ChatProvider.handleSwitchSession:";console.log(`${Oe} Switching to session ${ke}...`),be(!0);const Re=nn.filter(We=>We.sessionId===f),Ze=Re.some(We=>We.taskId===k),ht=Re.length>0;if(!Ze&&!ht&&v([]),he(),g&&k&&P&&!R&&!re(k)){console.log(`${Oe} Cancelling current task ${k}`);try{await Ie.webui.post(`/api/v1/tasks/${k}:cancel`,{jsonrpc:"2.0",id:`req-${ss()}`,method:"tasks/cancel",params:{id:k}})}catch(Ae){console.warn(`${Oe} Failed to cancel current task:`,Ae)}}K.current&&(clearTimeout(K.current),K.current=null),_(!1);try{const We=await Ie.webui.get(`/api/v1/sessions/${ke}`),Ae=We==null?void 0:We.data;if(Ee((Ae==null?void 0:Ae.name)??"N/A"),Ss.current=!0,Ae!=null&&Ae.projectId)if(console.log(`${Oe} Session belongs to project ${Ae.projectId}`),(i==null?void 0:i.id)!==Ae.projectId){const ut=c.find(Rt=>Rt.id===(Ae==null?void 0:Ae.projectId));ut?(console.log(`${Oe} Activating project context: ${ut.name}`),l(ut)):console.warn(`${Oe} Project ${Ae.projectId} not found in projects array`)}else console.log(`${Oe} Already in correct project context`);else i!==null&&(console.log(`${Oe} Session has no project, deactivating project context`),l(null));p(ke),x(!1),N(null),O(null),wt(),$.current=!1,W.current=null,V.current=0,j([]),Q.current.clear(),await Te(ke);const bt=nn.filter(ut=>ut.sessionId===ke);if(bt.length>0)for(const ut of bt){const Rt=await ue(ut.taskId);if(Rt&&Rt.is_running){console.log(`[ChatProvider] Reconnecting to running background task ${ut.taskId}`),N(ut.taskId),x(!0),ut.agentName&&E(ut.agentName);break}else console.log(`[ChatProvider] Background task ${ut.taskId} is not running, unregistering`),Yt(ut.taskId)}}catch(We){h({title:"Switching Chats Failed",error:Zt(We,"Failed to switch chat sessions.")})}finally{be(!1)}},[he,g,k,P,R,Te,i,c,l,wt,h,j,nn,ue,f,Yt,re]),mt=d.useCallback(async(ke,Oe)=>{try{const Re=await Ie.webui.patch(`/api/v1/sessions/${ke}`,{name:Oe},{fullResponse:!0});if(Re.status===422)throw new Error("Invalid name");if(!Re.ok){const Ze=await Re.json().catch(()=>({}));throw new Error(Ze.message||"Failed to update session name")}Ee(Oe),typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}catch(Re){h({title:"Session Name Update Failed",error:Zt(Re,"Failed to update session name.")})}},[h]),vt=d.useCallback(async ke=>{try{await Ie.webui.delete(`/api/v1/sessions/${ke}`),oe("Session deleted.","success"),ke===f&&Ve(),typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}catch(Oe){h({title:"Chat Deletion Failed",error:Zt(Oe,"Failed to delete session.")})}},[oe,Ve,f,h]),En=d.useCallback((ke,Oe)=>{le(Re=>Re.map(Ze=>Ze.filename===ke?{...Ze,isDisplayed:Oe}:Ze))},[]),Bt=d.useCallback(ke=>{_e(ke)},[]),Bn=d.useCallback(()=>{_e(null)},[]),gr=d.useCallback(async()=>{Le&&(await vt(Le.id),_e(null))},[Le,vt]),Vs=d.useCallback(async()=>{if(!(!g&&!R||!k)&&!R){_(!0);try{const ke={jsonrpc:"2.0",id:`req-${ss()}`,method:"tasks/cancel",params:{id:k}},Oe=await Ie.webui.post(`/api/v1/tasks/${k}:cancel`,ke,{fullResponse:!0});if(Oe.status===202)K.current&&clearTimeout(K.current),K.current=setTimeout(()=>{oe("Cancellation timed out. Allowing new input."),_(!1),x(!1),he(),N(null),K.current=null,v(Re=>Re.filter(Ze=>!Ze.isStatusBubble))},15e3);else{const Re=await Oe.json().catch(()=>({message:"Unknown cancellation error"}));throw new Error(Re.message||`HTTP error ${Oe.status}`)}}catch(ke){h({title:"Task Cancellation Failed",error:Zt(ke,"An unknown error occurred.")}),_(!1)}}},[g,R,k,oe,h,he]),Tt=d.useCallback(async(ke,Oe,Re)=>{if(!f){console.error("Cannot submit feedback without a session ID.");return}try{await Ie.webui.post("/api/v1/feedback",{taskId:ke,sessionId:f,feedbackType:Oe,feedbackText:Re}),Y(Ze=>({...Ze,[ke]:{type:Oe,text:Re}}))}catch(Ze){throw console.error("Failed to submit feedback:",Ze),Ze}},[f]),kt=d.useCallback(()=>{},[]),In=d.useCallback(()=>{g&&!$.current&&!L.current&&h({title:"Connection Failed",error:"Connection lost. Please try again."}),$.current||(x(!1),L.current||(he(),N(null)),W.current=null),v(ke=>ke.filter(Oe=>!Oe.isStatusBubble).map((Oe,Re,Ze)=>Re===Ze.length-1&&!Oe.isUser?{...Oe,isComplete:!0}:Oe))},[he,g,h]),Vn=d.useCallback(async ke=>{if(ke.length!==0)for(const{filename:Oe,sessionId:Re}of ke)try{await Ie.webui.delete(`/api/v1/artifacts/${Re}/${encodeURIComponent(Oe)}`)}catch(Ze){console.error(`[cleanupUploadedFiles] Exception while cleaning up file ${Oe}:`,Ze)}},[]),Dt=d.useCallback(async(ke,Oe,Re,Ze)=>{ke.preventDefault();const ht=(Re==null?void 0:Re.trim())||"",We=Oe||[];if(!ht&&We.length===0||g||R||!P)return;he(),$.current=!1,x(!0),N(null),W.current=null,V.current=0;const Ae={role:"user",parts:[{kind:"text",text:ht}],isUser:!0,uploadedFiles:We.length>0?We:void 0,metadata:{messageId:`msg-${ss()}`,sessionId:Ze||f,lastProcessedEventSequence:0}};W.current="Thinking",v(bt=>[...bt,Ae]);try{const bt=[],ut=[];let Rt=Ze||f;console.log(`[handleSubmit] Processing ${We.length} file(s)`);for(const ze of We){if(ze.type==="application/x-artifact-reference")try{const rt=await ze.text(),Ge=JSON.parse(rt);if(Ge.isArtifactReference&&Ge.uri){console.log(`[handleSubmit] Adding artifact reference: ${Ge.filename} (${Ge.uri})`),bt.push({kind:"file",file:{uri:Ge.uri,name:Ge.filename,mimeType:Ge.mimeType||"application/octet-stream"}});continue}}catch(rt){console.error("[handleSubmit] Error processing artifact reference:",rt)}if(ze.size<Y7){const rt=await D2(ze);bt.push({kind:"file",file:{bytes:rt,name:ze.name,mimeType:ze.type}})}else{const rt=await gt(ze,Rt);if(rt&&"uri"in rt&&rt.uri&&rt.sessionId)Rt||(Rt=rt.sessionId),ut.push({filename:ze.name,sessionId:rt.sessionId}),bt.push({kind:"file",file:{uri:rt.uri,name:ze.name,mimeType:ze.type}});else{console.error(`[handleSubmit] File upload failed for "${ze.name}". Result:`,rt),await Vn(ut);const Ge=ut.length>0?" Previously uploaded files have been cleaned up.":"",lt=rt&&"error"in rt?` (${rt.error})`:"";h({title:"File Upload Failed",error:`Message not sent. File upload failed for "${ze.name}"${lt}.${Ge}.`}),x(!1),v(xr=>xr.filter(vr=>{var gn,Jn;return((gn=vr.metadata)==null?void 0:gn.messageId)!==((Jn=Ae.metadata)==null?void 0:Jn.messageId)}));return}}}const pn=[];if(ht&&pn.push({kind:"text",text:ht}),pn.push(...bt),pn.length===0)return;console.log(`ChatProvider handleSubmit: Using effectiveSessionId for contextId: ${Rt}`);const Dr=s??!1;console.log(`[ChatProvider] Building metadata for ${P}, enableBackground=${Dr}`);const Ft={agent_name:P};i!=null&&i.id&&(Ft.project_id=i.id),Dr&&(Ft.backgroundExecutionEnabled=!0,Ft.maxExecutionTimeMs=a??36e5,console.log(`[ChatProvider] Enabling background execution for ${P}`),console.log("[ChatProvider] Metadata object:",Ft));const No={role:"user",parts:pn,messageId:`msg-${ss()}`,kind:"message",contextId:Rt,metadata:Ft};console.log("[ChatProvider] A2A message metadata:",No.metadata);const Ol={jsonrpc:"2.0",id:`req-${ss()}`,method:"message/stream",params:{message:No}};console.log("ChatProvider handleSubmit: Sending POST to /message:stream");const Ws=await Ie.webui.post("/api/v1/message:stream",Ol),Vt=Ws==null?void 0:Ws.result,at=Vt==null?void 0:Vt.id,tt=Vt==null?void 0:Vt.contextId;if(console.log(`ChatProvider handleSubmit: Extracted responseSessionId: ${tt}, current sessionId: ${f}`),console.log("ChatProvider handleSubmit: Full result object:",Ws),!at)throw console.error("ChatProvider handleSubmit: Backend did not return a valid taskId. Result:",Ws),new Error("Backend did not return a valid taskId.");console.log(`ChatProvider handleSubmit: Checking session update condition - responseSessionId: ${tt}, sessionId: ${f}, different: ${tt!==f}`);const Je=!f||f==="",nt=tt||f;if(tt&&tt!==f){if(console.log(`ChatProvider handleSubmit: Updating sessionId from ${f} to ${tt}`),p(tt),v(ze=>ze.map(rt=>{var Ge,lt;return((Ge=rt.metadata)==null?void 0:Ge.messageId)===((lt=Ae.metadata)==null?void 0:lt.messageId)?{...rt,metadata:{...rt.metadata,sessionId:tt}}:rt})),Je){let ze="New Chat";const Ge=Ae.parts.filter(lt=>lt.kind==="text").map(lt=>lt.text).join(" ").trim();Ge?ze=Ge.length>100?`${Ge.substring(0,100)}...`:Ge:We.length>0&&(We.length===1?ze=We[0].name:ze=`${We[0].name} +${We.length-1} more`),ze&&(Ee(ze),await mt(tt,ze))}Je&&typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}const At=s??!1;nt&&await je({task_id:at,user_message:ht,message_bubbles:[Ce(Ae)],task_metadata:{schema_version:Mc,status:"pending",agent_name:P,is_background_task:At}},nt),console.log(`ChatProvider handleSubmit: Received taskId ${at}. Setting currentTaskId and taskIdInSidePanel.`),N(at),O(at),At&&(console.log(`[ChatProvider] Registering ${at} as background task`),Un(at,nt,P),typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))),v(ze=>ze.map(rt=>{var Ge,lt;return((Ge=rt.metadata)==null?void 0:Ge.messageId)===((lt=Ae.metadata)==null?void 0:lt.messageId)?{...rt,taskId:at}:rt}))}catch(bt){h({title:"Message Failed",error:Zt(bt,"An error occurred. Please try again.")}),x(!1),v(ut=>ut.filter(Rt=>!Rt.isStatusBubble)),N(null),$.current=!1,W.current=null}},[f,g,R,P,he,gt,mt,je,Ce,i,Vn,h,a,s,Un]),Hs=d.useRef(""),Ss=d.useRef(!1),Mr=d.useRef(!1);d.useEffect(()=>{VR(Oe=>{(i==null?void 0:i.id)===Oe&&(console.log(`Project ${Oe} was deleted, clearing session context`),Ve(!1))})},[i,Ve]),d.useEffect(()=>{const ke=async Oe=>{const Re=Oe,{sessionId:Ze,projectId:ht}=Re.detail;if(Ze===f)if(Mr.current=!0,ht){const We=c.find(Ae=>Ae.id===ht);We&&l(We)}else l(null)};return window.addEventListener("session-moved",ke),()=>{window.removeEventListener("session-moved",ke)}},[f,c,l]),d.useEffect(()=>{const ke=async Oe=>{const Re=Oe,{taskId:Ze}=Re.detail,ht=X.current.find(We=>We.taskId===Ze);ht&&(console.log(`[ChatProvider] Background task ${Ze} completed, will reload session ${ht.sessionId} after delay`),setTimeout(async()=>{F.current===ht.sessionId&&(console.log(`[ChatProvider] Reloading current session ${ht.sessionId} to get latest data`),await Te(ht.sessionId))},1500))};return window.addEventListener("background-task-completed",ke),()=>{window.removeEventListener("background-task-completed",ke)}},[Te]),d.useEffect(()=>{const ke=Hs.current,Oe=i==null?void 0:i.id;Oe!==void 0&&ke!==Oe&&!Ss.current&&!Mr.current&&(console.log("Active project changed explicitly, resetting chat view and preserving project context."),Ve(!0)),Hs.current=Oe,Ss.current=!1,Mr.current=!1},[i,Ve]),d.useEffect(()=>{if(!P&&z.length>0&&m.length===0&&!et){let ke=z[0];const Re=new URLSearchParams(window.location.search).get("agent");let Ze;if(Re&&(Ze=z.find(We=>We.name===Re),Ze?(ke=Ze,console.log(`Using URL parameter agent: ${ke.name}`)):console.warn(`URL parameter agent "${Re}" not found in available agents, falling back to priority order`)),!Ze)if(i!=null&&i.defaultAgentId){const We=z.find(Ae=>Ae.name===i.defaultAgentId);We?(ke=We,console.log(`Using project default agent: ${ke.name}`)):(console.warn(`Project default agent "${i.defaultAgentId}" not found, falling back to OrchestratorAgent`),ke=z.find(Ae=>Ae.name==="OrchestratorAgent")??z[0])}else ke=z.find(We=>We.name==="OrchestratorAgent")??z[0];E(ke.name);const ht=t||`Hi! I'm the ${ke==null?void 0:ke.displayName}. How can I help?`;v([{parts:[{kind:"text",text:ht}],isUser:!1,isComplete:!0,role:"agent",metadata:{sessionId:"",lastProcessedEventSequence:0}}])}},[z,t,m.length,P,f,et,i]);const ui=d.useRef(we),di=d.useRef(kt),fi=d.useRef(In);d.useEffect(()=>{ui.current=we,di.current=kt,fi.current=In},[we,kt,In]),d.useEffect(()=>{if(k){const ke=jh(),Re=X.current.find(pn=>pn.taskId===k)!==void 0,Ze=new URLSearchParams;ke&&Ze.append("token",ke),Re&&(Ze.append("reconnect","true"),Ze.append("last_event_timestamp","0"),console.log(`[ChatProvider] Reconnecting to background task ${k} - requesting full event replay`),v(pn=>pn.filter(Ft=>!!(Ft.isUser||Ft.taskId!==k))));const ht=Ie.webui.getFullUrl(`/api/v1/sse/subscribe/${k}`),We=Ze.toString()?`${ht}?${Ze.toString()}`:ht,Ae=new EventSource(We,{withCredentials:!0});A.current=Ae;const bt=()=>{di.current()},ut=()=>{fi.current()},Rt=pn=>{ui.current(pn)};return Ae.onopen=bt,Ae.onerror=ut,Ae.addEventListener("status_update",Rt),Ae.addEventListener("artifact_update",Rt),Ae.addEventListener("final_response",Rt),Ae.addEventListener("error",Rt),()=>{Ae.removeEventListener("status_update",Rt),Ae.removeEventListener("artifact_update",Rt),Ae.removeEventListener("final_response",Rt),Ae.removeEventListener("error",Rt),Ae.close()}}else he()},[k,he]);const Dl={ragData:w,ragEnabled:S,configCollectFeedback:r,submittedFeedback:U,handleFeedbackSubmit:Tt,sessionId:f,setSessionId:p,sessionName:Se,setSessionName:Ee,messages:m,setMessages:v,isResponding:g,currentTaskId:k,isCancelling:R,latestStatusText:W,isLoadingSession:et,agents:z,agentsLoading:ce,agentsError:J,agentsRefetch:de,agentNameDisplayNameMap:Z,handleNewSession:Ve,handleSwitchSession:_t,handleSubmit:Dt,handleCancel:Vs,notifications:I,addNotification:oe,selectedAgentName:P,setSelectedAgentName:E,artifacts:fe,artifactsLoading:ge,artifactsRefetch:T,setArtifacts:le,uploadArtifactFile:gt,isSidePanelCollapsed:ie,activeSidePanelTab:B,setIsSidePanelCollapsed:q,setActiveSidePanelTab:ee,openSidePanelTab:ne,taskIdInSidePanel:D,setTaskIdInSidePanel:O,isDeleteModalOpen:Nt,artifactToDelete:Jt,openDeleteModal:Wt,closeDeleteModal:xe,confirmDelete:$e,openSessionDeleteModal:Bt,closeSessionDeleteModal:Bn,confirmSessionDelete:gr,sessionToDelete:Le,isArtifactEditMode:Me,setIsArtifactEditMode:Fe,selectedArtifactFilenames:ft,setSelectedArtifactFilenames:He,handleDeleteSelectedArtifacts:St,confirmBatchDeleteArtifacts:Lt,isBatchDeleteModalOpen:Ut,setIsBatchDeleteModalOpen:Qe,previewedArtifactAvailableVersions:se,currentPreviewedVersionNumber:me,previewFileContent:Pe,openArtifactForPreview:dt,navigateArtifactVersion:Ht,previewArtifact:Ne,setPreviewArtifact:Ot,updateSessionName:mt,deleteSession:vt,markArtifactAsDisplayed:En,downloadAndResolveArtifact:ln,displayError:h,pendingPrompt:G,startNewChatWithPrompt:De,clearPendingPrompt:ot,backgroundTasks:nn,backgroundNotifications:On,isTaskRunningInBackground:re};return o.jsxs(Zy.Provider,{value:Dl,children:[e,o.jsx(u,{})]})},X7=({children:e})=>{const{configUseAuthorization:t,configAuthLoginUrl:n}=on(),{fetchCsrfToken:r,clearCsrfToken:s}=Xy(),[a,i]=d.useState(!1),[l,c]=d.useState(!0),[u,h]=d.useState(null);d.useEffect(()=>{let m=!0;const v=async()=>{if(!t){m&&(i(!0),c(!1));return}try{const x=await Ie.webui.get("/api/v1/users/me");console.log("User is authenticated:",x),m&&(h(x),i(!0)),console.log("Fetching CSRF token for authenticated requests..."),await r()}catch(x){console.error("Error checking authentication:",x),m&&i(!1)}finally{m&&c(!1)}};v();const g=x=>{x.key==="access_token"&&v()};return window.addEventListener("storage",g),()=>{m=!1,window.removeEventListener("storage",g)}},[t,n,r]);const f=()=>{window.location.href=n},p=async()=>{try{t&&(await Ie.webui.post("/api/v1/auth/logout"),i(!1),h(null),s(),localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token"),window.location.href=n)}catch(m){console.error("Error calling logout endpoint:",m)}};return l?o.jsx(rr,{variant:"loading",title:"Checking Authentication...",className:"h-screen w-screen"}):o.jsx(Hy.Provider,{value:{isAuthenticated:a,useAuthorization:t,login:f,logout:p,userInfo:u},children:e})};function J7(e){var r;if(typeof document>"u")return null;const n=`; ${document.cookie}`.split(`; ${e}=`);return n.length===2&&((r=n.pop())==null?void 0:r.split(";").shift())||null}const Q7=e=>new Promise(t=>setTimeout(t,e)),eU=async(e=5,t=50)=>{try{const n=await Ie.webui.get("/api/v1/csrf-token",{credentials:"include",fullResponse:!0});if(!n.ok)throw new Error(`CSRF endpoint returned status ${n.status}`);const r=await n.json();if(r.csrf_token)return console.log("CSRF token found in response body:",r.csrf_token),r.csrf_token;for(let s=0;s<e;s++){const a=J7("csrf_token");if(a)return console.log(`CSRF token found in cookie after ${s} retries:`,a),a;console.log(`CSRF token not found in cookie, attempt ${s+1}/${e}. Waiting ${t}ms...`),await Q7(t)}throw new Error("CSRF token not available in response or cookie after retries")}catch(n){return console.error("Error fetching/reading CSRF token:",n),null}};function tU({children:e}){const[t,n]=d.useState(null),r=d.useCallback(async()=>{if(t)return t;const i=await eU();if(i)n(i);else throw new Error("Failed to obtain CSRF token after config fetch failed.");return i},[t]),s=d.useCallback(()=>{n(null)},[]),a={fetchCsrfToken:r,clearCsrfToken:s};return o.jsx(qy.Provider,{value:a,children:e})}const nU={brand:{wMain:"#00C895",w30:"#B3EFDF",wMain30:"#00C8954d",w10:"#E6FAF4",w60:"#66DEBF",w100:"#00AD93"},primary:{w100:"#01374E",w90:"#014968",wMain:"#015B82",w60:"#679DB4",w40:"#99BDCD",w20:"#CCDEE6",w10:"#E6EFF2",text:{wMain:"#273749",w100:"#000000",w10:"#CCCCCC"}},secondary:{w70:"#536574",w80:"#354E62",w8040:"#354E6240",w100:"#000000",wMain:"#8790A0",w40:"#CFD3D9",w20:"#E7E9EC",w10:"#F3F4F6",text:{wMain:"#647481",w50:"#B1B9C0"}},background:{w100:"#021B2F",wMain:"#03223B",w20:"#F7F8F9",w10:"#FFFFFF"},info:{w100:"#2B71B1",wMain:"#0591D3",w70:"#7CD3F6",w30:"#B4DEF2",w20:"#CDE9F6",w10:"#E6F4FB"},error:{w100:"#C33135",wMain:"#E94C4E",w70:"#ED9B9D",w30:"#F8C9CA",w20:"#FBDBDC",w10:"#FDEDED"},warning:{w100:"#E1681F",wMain:"#FF8E2B",w70:"#F8C785",w30:"#FFDDBF",w20:"#FFE8D5",w10:"#FFF4EA"},success:{w100:"#006B53",wMain:"#009A80",w70:"#6FCCBC",w30:"#B3E1D9",w20:"#CCEBE6",w10:"#E6F5F2"},stateLayer:{w10:"#03223B1a",w20:"#03223B33"},accent:{n0:{w100:"#2F51AD",wMain:"#3C69E1",w30:"#C5D2F6",w10:"#ECF0FC"},n1:{w100:"#1F284C",wMain:"#3A4880",w30:"#C4C8D9",w60:"#8991B3",w20:"#D8DAE6",w10:"#EBEDF2"},n2:{w100:"#165E64",wMain:"#009193",w30:"#B3DEDF",w20:"#CCE9E9",w10:"#E6F4F4"},n3:{w100:"#542D75",wMain:"#7841A8",w30:"#D7C6E5",w10:"#F2ECF6"},n4:{w100:"#951379",wMain:"#CB1AA5",w30:"#F2C4E8"},n5:{w100:"#D03C1B",wMain:"#F66651",w30:"#FCCEC7",w60:"#FAA397"},n6:{w100:"#DE7E00",wMain:"#FCA829",w30:"#FEE5BF"},n7:{w100:"#2DADE1",wMain:"#7CD3F6",w30:"#CBEDFB"},n8:{w100:"#4F5A63",wMain:"#86939E",w30:"#DBDFE2"},n9:{wMain:"#DA162D"}},learning:{wMain:"#033A6F",w90:"#022E59",w100:"#022343",w20:"#CDD8E2",w10:"#E6EBF1"}},rU={light:{background:"background.w10","card-background":"background.w20",foreground:"primary.text.wMain",card:"background.w10","card-foreground":"primary.text.wMain",popover:"background.w10","popover-foreground":"primary.text.wMain",primary:"primary.wMain","primary-foreground":"primary.text.w10",secondary:"secondary.w10","secondary-foreground":"secondary.text.wMain",muted:"secondary.w10","muted-foreground":"secondary.text.wMain",accent:"secondary.w40","accent-foreground":"secondary.text.wMain",destructive:"error.wMain",border:"secondary.w40",input:"secondary.w40",ring:"brand.wMain","ring-offset":"brand.wMain","accent-background":"background.w20","message-background":"secondary.w20","chart-1":"brand.w60","chart-2":"primary.wMain","chart-3":"accent.n3.wMain","chart-4":"accent.n6.wMain","chart-5":"accent.n5.wMain",sidebar:"background.w20","sidebar-foreground":"primary.text.wMain","sidebar-primary":"primary.wMain","sidebar-primary-foreground":"primary.text.w10","sidebar-accent":"secondary.w10","sidebar-accent-foreground":"secondary.text.wMain","sidebar-border":"secondary.w40","sidebar-ring":"brand.wMain"},dark:{background:"background.w100","card-background":"background.w100",foreground:"primary.text.w10",card:"background.wMain","card-foreground":"primary.text.w10",popover:"background.wMain","popover-foreground":"primary.text.w10",primary:"primary.w60","primary-foreground":"primary.text.wMain",secondary:"secondary.w80","secondary-foreground":"secondary.text.w50",muted:"secondary.w80","muted-foreground":"secondary.text.w50",accent:"secondary.w80","accent-foreground":"secondary.text.w50",destructive:"error.w70",border:"secondary.w70",input:"secondary.w70",ring:"brand.w60","ring-offset":"brand.w60","accent-background":"primary.w90","message-background":"secondary.w70","chart-1":"brand.w100","chart-2":"primary.wMain","chart-3":"accent.n3.w100","chart-4":"accent.n6.w30","chart-5":"accent.n5.w60",sidebar:"background.wMain","sidebar-foreground":"primary.text.w10","sidebar-primary":"primary.w60","sidebar-primary-foreground":"primary.text.wMain","sidebar-accent":"secondary.w80","sidebar-accent-foreground":"secondary.text.w50","sidebar-border":"secondary.w70","sidebar-ring":"brand.w60"}},sU={"error-text-wMain":"error.wMain","error-text-w50":"error.w70","warning-text-wMain":"warning.wMain","warning-text-w50":"warning.w70","success-text-wMain":"success.wMain","success-text-w50":"success.w70","info-text-wMain":"info.wMain","info-text-w50":"info.w70"};function dv(e,t){const n=t.split(".");let r=e;for(const s of n)if(r&&typeof r=="object"&&s in r)r=r[s];else return console.warn(`Color path not found: ${t}`),"#000000";return typeof r=="string"?r:"#000000"}function oU(e,t){const n={},r=rU[t];for(const[s,a]of Object.entries(r)){const i=dv(e,a);n[`--${s}`]=i}for(const[s,a]of Object.entries(sU)){const i=dv(e,a);n[`--color-${s}`]=i}return n}const au="sam-theme";function aU(e){var n,r,s,a,i,l,c,u,h,f,p,m,v,g,x,w,y,C,S,j,I,b,k,N,A,P,E,R,_,M,L,F,D,O,K,$,W,V,X,H,Q,z,Z,J,ce,de,fe,ge,T,le,ie,q,B,ee,U,Y,G,ae,oe,se,me,Pe,Ne,dt,Ht,wt,Ot,gt,Nt,Jt,Wt,xe,$e,Me,Fe,ft,He,Ut,Qe,St,Lt,ln,nn,On,Un,Yt,te,re,ue,Ce,je,Be,qe,Te,Se,Ee,Le,_e,et,be,ne,he,we;const t={};return e.brand.wMain&&(t["--color-brand-wMain"]=e.brand.wMain),e.brand.wMain30&&(t["--color-brand-wMain30"]=e.brand.wMain30),e.brand.w100&&(t["--color-brand-w100"]=e.brand.w100),e.brand.w60&&(t["--color-brand-w60"]=e.brand.w60),e.brand.w30&&(t["--color-brand-w30"]=e.brand.w30),e.brand.w10&&(t["--color-brand-w10"]=e.brand.w10),e.primary.wMain&&(t["--color-primary-wMain"]=e.primary.wMain),e.primary.w100&&(t["--color-primary-w100"]=e.primary.w100),e.primary.w90&&(t["--color-primary-w90"]=e.primary.w90),e.primary.w60&&(t["--color-primary-w60"]=e.primary.w60),e.primary.w40&&(t["--color-primary-w40"]=e.primary.w40),e.primary.w20&&(t["--color-primary-w20"]=e.primary.w20),e.primary.w10&&(t["--color-primary-w10"]=e.primary.w10),e.primary.text.wMain&&(t["--color-primary-text-wMain"]=e.primary.text.wMain),e.primary.text.w100&&(t["--color-primary-text-w100"]=e.primary.text.w100),e.primary.text.w10&&(t["--color-primary-text-w10"]=e.primary.text.w10),e.secondary.wMain&&(t["--color-secondary-wMain"]=e.secondary.wMain),e.secondary.w100&&(t["--color-secondary-w100"]=e.secondary.w100),e.secondary.w80&&(t["--color-secondary-w80"]=e.secondary.w80),e.secondary.w8040&&(t["--color-secondary-w8040"]=e.secondary.w8040),e.secondary.w70&&(t["--color-secondary-w70"]=e.secondary.w70),e.secondary.w40&&(t["--color-secondary-w40"]=e.secondary.w40),e.secondary.w20&&(t["--color-secondary-w20"]=e.secondary.w20),e.secondary.w10&&(t["--color-secondary-w10"]=e.secondary.w10),e.secondary.text.wMain&&(t["--color-secondary-text-wMain"]=e.secondary.text.wMain),e.secondary.text.w50&&(t["--color-secondary-text-w50"]=e.secondary.text.w50),e.background.wMain&&(t["--color-background-wMain"]=e.background.wMain),e.background.w100&&(t["--color-background-w100"]=e.background.w100),e.background.w20&&(t["--color-background-w20"]=e.background.w20),e.background.w10&&(t["--color-background-w10"]=e.background.w10),(n=e.info)!=null&&n.wMain&&(t["--color-info-wMain"]=e.info.wMain),(r=e.info)!=null&&r.w100&&(t["--color-info-w100"]=e.info.w100),(s=e.info)!=null&&s.w70&&(t["--color-info-w70"]=e.info.w70),(a=e.info)!=null&&a.w30&&(t["--color-info-w30"]=e.info.w30),(i=e.info)!=null&&i.w20&&(t["--color-info-w20"]=e.info.w20),(l=e.info)!=null&&l.w10&&(t["--color-info-w10"]=e.info.w10),(c=e.error)!=null&&c.wMain&&(t["--color-error-wMain"]=e.error.wMain),(u=e.error)!=null&&u.w100&&(t["--color-error-w100"]=e.error.w100),(h=e.error)!=null&&h.w70&&(t["--color-error-w70"]=e.error.w70),(f=e.error)!=null&&f.w30&&(t["--color-error-w30"]=e.error.w30),(p=e.error)!=null&&p.w20&&(t["--color-error-w20"]=e.error.w20),(m=e.error)!=null&&m.w10&&(t["--color-error-w10"]=e.error.w10),(v=e.warning)!=null&&v.wMain&&(t["--color-warning-wMain"]=e.warning.wMain),(g=e.warning)!=null&&g.w100&&(t["--color-warning-w100"]=e.warning.w100),(x=e.warning)!=null&&x.w70&&(t["--color-warning-w70"]=e.warning.w70),(w=e.warning)!=null&&w.w30&&(t["--color-warning-w30"]=e.warning.w30),(y=e.warning)!=null&&y.w20&&(t["--color-warning-w20"]=e.warning.w20),(C=e.warning)!=null&&C.w10&&(t["--color-warning-w10"]=e.warning.w10),(S=e.success)!=null&&S.wMain&&(t["--color-success-wMain"]=e.success.wMain),(j=e.success)!=null&&j.w100&&(t["--color-success-w100"]=e.success.w100),(I=e.success)!=null&&I.w70&&(t["--color-success-w70"]=e.success.w70),(b=e.success)!=null&&b.w30&&(t["--color-success-w30"]=e.success.w30),(k=e.success)!=null&&k.w20&&(t["--color-success-w20"]=e.success.w20),(N=e.success)!=null&&N.w10&&(t["--color-success-w10"]=e.success.w10),(A=e.stateLayer)!=null&&A.w10&&(t["--color-stateLayer-w10"]=e.stateLayer.w10),(P=e.stateLayer)!=null&&P.w20&&(t["--color-stateLayer-w20"]=e.stateLayer.w20),(R=(E=e.accent)==null?void 0:E.n0)!=null&&R.wMain&&(t["--color-accent-n0-wMain"]=e.accent.n0.wMain),(M=(_=e.accent)==null?void 0:_.n0)!=null&&M.w100&&(t["--color-accent-n0-w100"]=e.accent.n0.w100),(F=(L=e.accent)==null?void 0:L.n0)!=null&&F.w30&&(t["--color-accent-n0-w30"]=e.accent.n0.w30),(O=(D=e.accent)==null?void 0:D.n0)!=null&&O.w10&&(t["--color-accent-n0-w10"]=e.accent.n0.w10),($=(K=e.accent)==null?void 0:K.n1)!=null&&$.wMain&&(t["--color-accent-n1-wMain"]=e.accent.n1.wMain),(V=(W=e.accent)==null?void 0:W.n1)!=null&&V.w100&&(t["--color-accent-n1-w100"]=e.accent.n1.w100),(H=(X=e.accent)==null?void 0:X.n1)!=null&&H.w60&&(t["--color-accent-n1-w60"]=e.accent.n1.w60),(z=(Q=e.accent)==null?void 0:Q.n1)!=null&&z.w30&&(t["--color-accent-n1-w30"]=e.accent.n1.w30),(J=(Z=e.accent)==null?void 0:Z.n1)!=null&&J.w20&&(t["--color-accent-n1-w20"]=e.accent.n1.w20),(de=(ce=e.accent)==null?void 0:ce.n1)!=null&&de.w10&&(t["--color-accent-n1-w10"]=e.accent.n1.w10),(ge=(fe=e.accent)==null?void 0:fe.n2)!=null&&ge.wMain&&(t["--color-accent-n2-wMain"]=e.accent.n2.wMain),(le=(T=e.accent)==null?void 0:T.n2)!=null&&le.w100&&(t["--color-accent-n2-w100"]=e.accent.n2.w100),(q=(ie=e.accent)==null?void 0:ie.n2)!=null&&q.w30&&(t["--color-accent-n2-w30"]=e.accent.n2.w30),(ee=(B=e.accent)==null?void 0:B.n2)!=null&&ee.w20&&(t["--color-accent-n2-w20"]=e.accent.n2.w20),(Y=(U=e.accent)==null?void 0:U.n2)!=null&&Y.w10&&(t["--color-accent-n2-w10"]=e.accent.n2.w10),(ae=(G=e.accent)==null?void 0:G.n3)!=null&&ae.wMain&&(t["--color-accent-n3-wMain"]=e.accent.n3.wMain),(se=(oe=e.accent)==null?void 0:oe.n3)!=null&&se.w100&&(t["--color-accent-n3-w100"]=e.accent.n3.w100),(Pe=(me=e.accent)==null?void 0:me.n3)!=null&&Pe.w30&&(t["--color-accent-n3-w30"]=e.accent.n3.w30),(dt=(Ne=e.accent)==null?void 0:Ne.n3)!=null&&dt.w10&&(t["--color-accent-n3-w10"]=e.accent.n3.w10),(wt=(Ht=e.accent)==null?void 0:Ht.n4)!=null&&wt.wMain&&(t["--color-accent-n4-wMain"]=e.accent.n4.wMain),(gt=(Ot=e.accent)==null?void 0:Ot.n4)!=null&>.w100&&(t["--color-accent-n4-w100"]=e.accent.n4.w100),(Jt=(Nt=e.accent)==null?void 0:Nt.n4)!=null&&Jt.w30&&(t["--color-accent-n4-w30"]=e.accent.n4.w30),(xe=(Wt=e.accent)==null?void 0:Wt.n5)!=null&&xe.wMain&&(t["--color-accent-n5-wMain"]=e.accent.n5.wMain),(Me=($e=e.accent)==null?void 0:$e.n5)!=null&&Me.w100&&(t["--color-accent-n5-w100"]=e.accent.n5.w100),(ft=(Fe=e.accent)==null?void 0:Fe.n5)!=null&&ft.w60&&(t["--color-accent-n5-w60"]=e.accent.n5.w60),(Ut=(He=e.accent)==null?void 0:He.n5)!=null&&Ut.w30&&(t["--color-accent-n5-w30"]=e.accent.n5.w30),(St=(Qe=e.accent)==null?void 0:Qe.n6)!=null&&St.wMain&&(t["--color-accent-n6-wMain"]=e.accent.n6.wMain),(ln=(Lt=e.accent)==null?void 0:Lt.n6)!=null&&ln.w100&&(t["--color-accent-n6-w100"]=e.accent.n6.w100),(On=(nn=e.accent)==null?void 0:nn.n6)!=null&&On.w30&&(t["--color-accent-n6-w30"]=e.accent.n6.w30),(Yt=(Un=e.accent)==null?void 0:Un.n7)!=null&&Yt.wMain&&(t["--color-accent-n7-wMain"]=e.accent.n7.wMain),(re=(te=e.accent)==null?void 0:te.n7)!=null&&re.w100&&(t["--color-accent-n7-w100"]=e.accent.n7.w100),(Ce=(ue=e.accent)==null?void 0:ue.n7)!=null&&Ce.w30&&(t["--color-accent-n7-w30"]=e.accent.n7.w30),(Be=(je=e.accent)==null?void 0:je.n8)!=null&&Be.wMain&&(t["--color-accent-n8-wMain"]=e.accent.n8.wMain),(Te=(qe=e.accent)==null?void 0:qe.n8)!=null&&Te.w100&&(t["--color-accent-n8-w100"]=e.accent.n8.w100),(Ee=(Se=e.accent)==null?void 0:Se.n8)!=null&&Ee.w30&&(t["--color-accent-n8-w30"]=e.accent.n8.w30),(_e=(Le=e.accent)==null?void 0:Le.n9)!=null&&_e.wMain&&(t["--color-accent-n9-wMain"]=e.accent.n9.wMain),(et=e.learning)!=null&&et.wMain&&(t["--color-learning-wMain"]=e.learning.wMain),(be=e.learning)!=null&&be.w100&&(t["--color-learning-w100"]=e.learning.w100),(ne=e.learning)!=null&&ne.w90&&(t["--color-learning-w90"]=e.learning.w90),(he=e.learning)!=null&&he.w20&&(t["--color-learning-w20"]=e.learning.w20),(we=e.learning)!=null&&we.w10&&(t["--color-learning-w10"]=e.learning.w10),t}function iU(e,t="light"){const n={};if(e){const s=aU(e);Object.assign(n,s)}const r=oU(e,t);return Object.assign(n,r),n}function lU(){const e=localStorage.getItem(au);return e==="dark"||e==="light"?e:window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function cU(e,t){const n=iU(e,t),r=document.documentElement;for(const[s,a]of Object.entries(n))r.style.setProperty(s,a);requestAnimationFrame(()=>{r.classList.remove("light","dark"),r.classList.add(t),localStorage.setItem(au,t)})}const uU=({children:e})=>{const t=d.useMemo(()=>nU,[]),[n,r]=d.useState(()=>lU()),s=d.useMemo(()=>({currentTheme:n,toggleTheme:()=>{const a=n==="light"?"dark":"light";r(a),localStorage.setItem(au,a)}}),[n]);return d.useEffect(()=>{if(!(localStorage.getItem(au)!==null)){const i=window.matchMedia("(prefers-color-scheme: dark)"),l=c=>{r(c.matches?"dark":"light")};return i.addEventListener?i.addEventListener("change",l):i.addListener(l),()=>{i.removeEventListener?i.removeEventListener("change",l):i.removeListener(l)}}},[]),d.useEffect(()=>{document.documentElement.classList.remove("light","dark"),cU(t,n)},[n,t]),o.jsx(Ky.Provider,{value:s,children:e})},dU=new R2({defaultOptions:{queries:{staleTime:1e3*60*5}}}),fU=({children:e})=>o.jsx(M2,{client:dU,children:e});function hU(){const e=es(),t=bo(),{isAuthenticated:n,login:r,useAuthorization:s}=Wy(),{configFeatureEnablement:a}=on(),{isMenuOpen:i,menuPosition:l,selectedText:c,clearSelection:u}=_w();d.useEffect(()=>{const v=new MutationObserver(()=>{const g=document.body.style.pointerEvents;!document.querySelector('[data-state="open"]')&&g==="none"&&document.body.style.removeProperty("pointer-events")});return v.observe(document.body,{attributes:!0,attributeFilter:["style"],childList:!0,subtree:!0}),()=>{v.disconnect()}},[]);const h=RF(a);KR();const f=()=>{const v=e.pathname;return v==="/"||v.startsWith("/chat")?"chat":v.startsWith("/projects")?"projects":v.startsWith("/prompts")?"prompts":v.startsWith("/agents")?"agentMesh":"chat"};if(s&&!n)return o.jsx("div",{className:"bg-background flex h-screen items-center justify-center",children:o.jsx(ye,{onClick:r,children:"Login"})});const p=v=>{const g=h.find(x=>x.id===v)||Dx.find(x=>x.id===v);g!=null&&g.onClick&&v!=="settings"?g.onClick():v!=="settings"&&t(`/${v==="agentMesh"?"agents":v}`)},m=()=>{t("/chat")};return o.jsxs("div",{className:"relative flex h-screen",children:[o.jsx(jF,{items:h,bottomItems:Dx,activeItem:f(),onItemChange:p,onHeaderClick:m}),o.jsx("main",{className:"h-full w-full flex-1 overflow-auto",children:o.jsx(Nj,{})}),o.jsx(f5,{}),o.jsx(m5,{isOpen:i,position:l,selectedText:c||"",onClose:u})]})}function mU(){return o.jsx(K7,{children:o.jsx(hU,{})})}const pU=()=>Qj([{path:"/",element:o.jsx(mU,{}),children:[{index:!0,element:o.jsx(Op,{to:"/chat",replace:!0})},{path:"chat",element:o.jsx(DF,{})},{path:"projects",children:[{index:!0,element:o.jsx(cv,{})},{path:":id",element:o.jsx(cv,{}),loader:({params:e})=>({projectId:e.id})}]},{path:"prompts",children:[{index:!0,element:o.jsx(dc,{})},{path:"new",element:o.jsx(dc,{}),loader:({request:e})=>({view:"builder",mode:new URL(e.url).searchParams.get("mode")||"manual"})},{path:":id/edit",element:o.jsx(dc,{}),loader:({params:e})=>({promptId:e.id,view:"builder",mode:"edit"})},{path:":id/versions",element:o.jsx(dc,{}),loader:({params:e})=>({promptId:e.id,view:"versions"})}]},{path:"agents",element:o.jsx(PF,{})},{path:"*",element:o.jsx(Op,{to:"/chat",replace:!0})}]}]);function gU(){return o.jsx(dE,{router:pU()})}function xU(){return o.jsx(fU,{children:o.jsx(uU,{children:o.jsx(tU,{children:o.jsx(B7,{children:o.jsx(X7,{children:o.jsx(HR,{children:o.jsx(qR,{children:o.jsx(V7,{children:o.jsx(fE,{children:o.jsx(gU,{})})})})})})})})})})}a_.createRoot(document.getElementById("root")).render(o.jsx(d.StrictMode,{children:o.jsx(xU,{})}));
|