codexLB-up 1.25.0b10__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.
- app/__init__.py +10 -0
- app/admin_cli.py +494 -0
- app/cli.py +339 -0
- app/codex_sessions_retag.py +487 -0
- app/core/__init__.py +0 -0
- app/core/audit/__init__.py +0 -0
- app/core/audit/service.py +216 -0
- app/core/audit/types.py +94 -0
- app/core/auth/__init__.py +236 -0
- app/core/auth/api_key_cache.py +65 -0
- app/core/auth/dashboard_access.py +429 -0
- app/core/auth/dashboard_mode.py +171 -0
- app/core/auth/dashboard_session_ttl.py +74 -0
- app/core/auth/dashboard_users_cache.py +120 -0
- app/core/auth/dependencies.py +710 -0
- app/core/auth/external_identity.py +78 -0
- app/core/auth/guardian.py +374 -0
- app/core/auth/models.py +49 -0
- app/core/auth/providers/__init__.py +129 -0
- app/core/auth/providers/oidc.py +838 -0
- app/core/auth/providers/registry.py +118 -0
- app/core/auth/refresh.py +394 -0
- app/core/auth/step_up.py +117 -0
- app/core/auth/totp.py +81 -0
- app/core/balancer/__init__.py +71 -0
- app/core/balancer/logic.py +1612 -0
- app/core/balancer/rendezvous_hash.py +21 -0
- app/core/balancer/types.py +21 -0
- app/core/bootstrap.py +172 -0
- app/core/cache/invalidation.py +426 -0
- app/core/clients/__init__.py +0 -0
- app/core/clients/codex.py +996 -0
- app/core/clients/codex_version.py +187 -0
- app/core/clients/codex_version_snapshot.py +2 -0
- app/core/clients/files.py +534 -0
- app/core/clients/headers.py +29 -0
- app/core/clients/http.py +511 -0
- app/core/clients/model_fetcher.py +276 -0
- app/core/clients/native_egress.py +1304 -0
- app/core/clients/oauth.py +477 -0
- app/core/clients/proxy.py +6089 -0
- app/core/clients/proxy_websocket.py +1411 -0
- app/core/clients/rate_limit_reset_credits.py +412 -0
- app/core/clients/stream_errors.py +12 -0
- app/core/clients/thread_cache_identity.py +347 -0
- app/core/clients/usage.py +467 -0
- app/core/clock.py +170 -0
- app/core/config/__init__.py +0 -0
- app/core/config/background_jobs.py +73 -0
- app/core/config/context_window_overrides.py +166 -0
- app/core/config/dashboard_overrides.py +145 -0
- app/core/config/inheritable.py +47 -0
- app/core/config/key_fingerprint.py +115 -0
- app/core/config/settings.py +872 -0
- app/core/config/settings_cache.py +100 -0
- app/core/config/spool_retention.py +217 -0
- app/core/config/tiers.py +174 -0
- app/core/conversation_archive.py +568 -0
- app/core/crypto.py +37 -0
- app/core/draining.py +11 -0
- app/core/errors.py +365 -0
- app/core/exceptions.py +155 -0
- app/core/handlers/__init__.py +3 -0
- app/core/handlers/exceptions.py +478 -0
- app/core/http_protocol.py +176 -0
- app/core/http_protocol_httptools.py +204 -0
- app/core/ingress_limits.py +17 -0
- app/core/metadata_store.py +18 -0
- app/core/metrics/__init__.py +0 -0
- app/core/metrics/middleware.py +74 -0
- app/core/metrics/prometheus.py +604 -0
- app/core/middleware/__init__.py +25 -0
- app/core/middleware/api_firewall.py +111 -0
- app/core/middleware/app_version.py +37 -0
- app/core/middleware/dashboard_auth_proxy.py +55 -0
- app/core/middleware/dashboard_csrf.py +177 -0
- app/core/middleware/dashboard_gzip.py +41 -0
- app/core/middleware/dashboard_overrides.py +59 -0
- app/core/middleware/firewall_cache.py +91 -0
- app/core/middleware/inflight.py +126 -0
- app/core/middleware/multipart_content_encoding.py +129 -0
- app/core/middleware/path_rewrite.py +148 -0
- app/core/middleware/request_body_limit.py +196 -0
- app/core/middleware/request_decompression.py +209 -0
- app/core/middleware/request_id.py +72 -0
- app/core/middleware/required_capability_http.py +116 -0
- app/core/middleware/trusted_proxy_headers.py +36 -0
- app/core/multipart.py +237 -0
- app/core/multipart_fields.py +91 -0
- app/core/openai/__init__.py +0 -0
- app/core/openai/chat_requests.py +493 -0
- app/core/openai/chat_responses.py +931 -0
- app/core/openai/contracts.py +46 -0
- app/core/openai/exceptions.py +24 -0
- app/core/openai/host_models.py +14 -0
- app/core/openai/images.py +413 -0
- app/core/openai/message_coercion.py +376 -0
- app/core/openai/model_refresh_scheduler.py +423 -0
- app/core/openai/model_registry.py +997 -0
- app/core/openai/model_registry_store.py +548 -0
- app/core/openai/models.py +172 -0
- app/core/openai/parsing.py +97 -0
- app/core/openai/requests.py +1980 -0
- app/core/openai/strict_schema.py +199 -0
- app/core/openai/tool_call_safety.py +99 -0
- app/core/openai/v1_requests.py +187 -0
- app/core/plan_types.py +90 -0
- app/core/prestop.py +202 -0
- app/core/rate_limiter/__init__.py +0 -0
- app/core/rate_limiter/db_rate_limiter.py +215 -0
- app/core/request_locality.py +473 -0
- app/core/resilience/__init__.py +0 -0
- app/core/resilience/backpressure.py +57 -0
- app/core/resilience/bulkhead.py +202 -0
- app/core/resilience/circuit_breaker.py +150 -0
- app/core/resilience/degradation.py +55 -0
- app/core/resilience/loop_lag_monitor.py +60 -0
- app/core/resilience/memory_monitor.py +137 -0
- app/core/resilience/network_recovery.py +256 -0
- app/core/resilience/overload.py +98 -0
- app/core/resilience/toggles.py +114 -0
- app/core/retention/__init__.py +0 -0
- app/core/retention/job.py +240 -0
- app/core/retention/scheduler.py +69 -0
- app/core/runtime_logging.py +601 -0
- app/core/scheduling/__init__.py +0 -0
- app/core/scheduling/leader_election.py +993 -0
- app/core/scheduling/leader_election_handle.py +25 -0
- app/core/server.py +140 -0
- app/core/shutdown.py +326 -0
- app/core/socket_peer.py +22 -0
- app/core/startup.py +41 -0
- app/core/timeout_invariants.py +347 -0
- app/core/tracing/__init__.py +0 -0
- app/core/tracing/otel.py +207 -0
- app/core/types.py +6 -0
- app/core/upstream_proxy/__init__.py +13 -0
- app/core/upstream_proxy/cache.py +130 -0
- app/core/upstream_proxy/resolver.py +189 -0
- app/core/upstream_proxy/types.py +104 -0
- app/core/usage/__init__.py +407 -0
- app/core/usage/depletion.py +109 -0
- app/core/usage/live_hub.py +41 -0
- app/core/usage/live_snapshots.py +174 -0
- app/core/usage/logs.py +212 -0
- app/core/usage/metadata_scheduler.py +118 -0
- app/core/usage/models.py +54 -0
- app/core/usage/pricing.py +576 -0
- app/core/usage/pricing_catalog.py +241 -0
- app/core/usage/pricing_snapshot.json +821 -0
- app/core/usage/quota.py +133 -0
- app/core/usage/refresh_policy.py +21 -0
- app/core/usage/refresh_scheduler.py +713 -0
- app/core/usage/reset_credits_refresh_scheduler.py +435 -0
- app/core/usage/types.py +168 -0
- app/core/utils/__init__.py +0 -0
- app/core/utils/json_guards.py +18 -0
- app/core/utils/locks.py +33 -0
- app/core/utils/masking.py +20 -0
- app/core/utils/proxy_env.py +104 -0
- app/core/utils/request_id.py +65 -0
- app/core/utils/retry.py +77 -0
- app/core/utils/shared_future.py +172 -0
- app/core/utils/sse.py +286 -0
- app/core/utils/time.py +24 -0
- app/db/__init__.py +0 -0
- app/db/account_identity_lock.py +56 -0
- app/db/alembic/__init__.py +1 -0
- app/db/alembic/env.py +70 -0
- app/db/alembic/revision_ids.py +43 -0
- app/db/alembic/versions/20260213_000000_base_schema.py +248 -0
- app/db/alembic/versions/20260213_000100_normalize_account_plan_types.py +45 -0
- app/db/alembic/versions/20260213_000200_add_request_logs_reasoning_effort.py +45 -0
- app/db/alembic/versions/20260213_000300_add_accounts_reset_at.py +45 -0
- app/db/alembic/versions/20260213_000400_add_accounts_chatgpt_account_id.py +45 -0
- app/db/alembic/versions/20260213_000500_add_dashboard_settings.py +70 -0
- app/db/alembic/versions/20260213_000600_add_dashboard_settings_totp.py +64 -0
- app/db/alembic/versions/20260213_000700_add_dashboard_settings_password.py +59 -0
- app/db/alembic/versions/20260213_000800_add_api_keys.py +87 -0
- app/db/alembic/versions/20260214_000000_add_api_key_limits.py +143 -0
- app/db/alembic/versions/20260215_000000_add_idx_logs_requested_at.py +38 -0
- app/db/alembic/versions/20260218_000000_add_api_key_usage_reservations.py +117 -0
- app/db/alembic/versions/20260218_000100_add_import_without_overwrite_and_drop_accounts_email_unique.py +198 -0
- app/db/alembic/versions/20260225_000000_add_dashboard_settings_routing_strategy.py +53 -0
- app/db/alembic/versions/20260228_020000_align_api_key_limit_enum_types.py +104 -0
- app/db/alembic/versions/20260228_030000_add_api_firewall_allowlist.py +42 -0
- app/db/alembic/versions/20260306_000000_add_request_logs_service_tier.py +45 -0
- app/db/alembic/versions/20260307_000000_add_api_key_enforcement_fields.py +56 -0
- app/db/alembic/versions/20260308_000000_add_sqlite_performance_indexes.py +41 -0
- app/db/alembic/versions/20260309_000000_add_additional_usage_history.py +71 -0
- app/db/alembic/versions/20260309_000000_request_logs_nullable_account_id.py +28 -0
- app/db/alembic/versions/20260310_000000_add_request_logs_transport.py +45 -0
- app/db/alembic/versions/20260310_000000_fix_postgresql_enum_value_casing.py +79 -0
- app/db/alembic/versions/20260310_120000_add_sticky_session_kinds_and_affinity_ttl.py +110 -0
- app/db/alembic/versions/20260312_000000_add_additional_usage_quota_key.py +193 -0
- app/db/alembic/versions/20260312_000000_split_sticky_sessions_primary_key_by_kind.py +96 -0
- app/db/alembic/versions/20260312_010000_merge_additional_usage_and_sticky_session_heads.py +25 -0
- app/db/alembic/versions/20260312_020000_merge_request_logs_transport_and_feature_heads.py +25 -0
- app/db/alembic/versions/20260312_020000_merge_request_logs_transport_and_sticky_heads.py +25 -0
- app/db/alembic/versions/20260312_120000_add_dashboard_upstream_stream_transport.py +62 -0
- app/db/alembic/versions/20260313_024500_merge_request_log_transport_heads.py +27 -0
- app/db/alembic/versions/20260319_100937_increase_prompt_cache_ttl_to_1800s.py +73 -0
- app/db/alembic/versions/20260319_111500_merge_prompt_cache_ttl_and_upstream_transport_heads.py +25 -0
- app/db/alembic/versions/20260319_183000_normalize_sqlite_account_status_casing.py +48 -0
- app/db/alembic/versions/20260320_000000_add_request_log_requested_actual_tiers.py +51 -0
- app/db/alembic/versions/20260321_190000_tighten_dashboard_db_indexes.py +64 -0
- app/db/alembic/versions/20260321_210000_merge_request_log_tiers_and_dashboard_index_heads.py +25 -0
- app/db/alembic/versions/20260325_000000_add_request_log_cost.py +193 -0
- app/db/alembic/versions/20260328_000000_add_rate_limit_attempts.py +48 -0
- app/db/alembic/versions/20260328_120000_add_request_log_ttft.py +37 -0
- app/db/alembic/versions/20260328_130000_add_audit_logs_table.py +45 -0
- app/db/alembic/versions/20260328_140000_add_scheduler_leader_table.py +39 -0
- app/db/alembic/versions/20260330_000000_add_cache_locality_settings.py +69 -0
- app/db/alembic/versions/20260330_010000_merge_scheduler_leader_and_cache_locality_heads.py +25 -0
- app/db/alembic/versions/20260330_020000_add_bridge_ring_members.py +46 -0
- app/db/alembic/versions/20260401_000000_add_api_key_enforced_service_tier.py +52 -0
- app/db/alembic/versions/20260401_000000_add_cache_invalidation.py +41 -0
- app/db/alembic/versions/20260401_020000_merge_cache_invalidation_and_api_key_service_tier_heads.py +22 -0
- app/db/alembic/versions/20260402_000000_switch_dashboard_routing_default_to_capacity_weighted.py +66 -0
- app/db/alembic/versions/20260403_000000_add_credit_api_key_limit_values.py +44 -0
- app/db/alembic/versions/20260406_000000_add_api_key_account_assignments.py +57 -0
- app/db/alembic/versions/20260406_010000_add_api_key_assignment_scope_flag.py +75 -0
- app/db/alembic/versions/20260407_000000_add_bridge_gateway_safe_mode.py +51 -0
- app/db/alembic/versions/20260407_010000_merge_api_key_assignment_and_bridge_gateway_heads.py +25 -0
- app/db/alembic/versions/20260408_000000_switch_import_without_overwrite_default_to_true.py +73 -0
- app/db/alembic/versions/20260408_010000_merge_import_without_overwrite_and_assignment_heads.py +25 -0
- app/db/alembic/versions/20260409_000000_add_http_bridge_sessions.py +130 -0
- app/db/alembic/versions/20260409_000000_switch_sticky_threads_and_prefer_earlier_reset_defaults_to_true.py +89 -0
- app/db/alembic/versions/20260409_010000_add_dashboard_settings_bootstrap_token.py +57 -0
- app/db/alembic/versions/20260409_010000_merge_http_bridge_and_import_without_overwrite_heads.py +25 -0
- app/db/alembic/versions/20260409_020000_fix_http_bridge_last_seen_index.py +46 -0
- app/db/alembic/versions/20260410_000000_backfill_pristine_dashboard_settings_defaults.py +77 -0
- app/db/alembic/versions/20260410_030000_restore_import_without_overwrite_default_true.py +73 -0
- app/db/alembic/versions/20260410_040000_merge_dashboard_defaults_and_import_default_heads.py +25 -0
- app/db/alembic/versions/20260413_000000_add_accounts_blocked_at.py +44 -0
- app/db/alembic/versions/20260415_160000_add_automations_tables.py +189 -0
- app/db/alembic/versions/20260415_160000_add_request_logs_response_lookup_index.py +67 -0
- app/db/alembic/versions/20260417_000000_add_request_log_plan_type.py +44 -0
- app/db/alembic/versions/20260418_190000_add_automation_runs_cycle_key.py +87 -0
- app/db/alembic/versions/20260419_000000_add_automation_run_cycle_metadata.py +56 -0
- app/db/alembic/versions/20260419_020000_add_automation_run_cycles_snapshot_tables.py +342 -0
- app/db/alembic/versions/20260421_000000_add_dashboard_session_ttl_setting.py +51 -0
- app/db/alembic/versions/20260421_120000_merge_request_log_lookup_and_plan_type_heads.py +25 -0
- app/db/alembic/versions/20260421_130000_merge_automation_and_request_log_heads.py +25 -0
- app/db/alembic/versions/20260422_103000_normalize_legacy_automation_run_cycle_keys.py +648 -0
- app/db/alembic/versions/20260423_120000_add_api_key_limit_reset_at_index.py +43 -0
- app/db/alembic/versions/20260424_000000_merge_dashboard_session_ttl_and_request_log_heads.py +25 -0
- app/db/alembic/versions/20260426_000000_add_dashboard_relative_availability_settings.py +68 -0
- app/db/alembic/versions/20260427_130000_add_warmup_model_and_request_kind.py +75 -0
- app/db/alembic/versions/20260506_000000_add_account_routing_policy.py +37 -0
- app/db/alembic/versions/20260509_000000_add_api_key_traffic_class.py +37 -0
- app/db/alembic/versions/20260509_010000_add_additional_quota_routing_policies.py +37 -0
- app/db/alembic/versions/20260513_000000_add_accounts_alias.py +44 -0
- app/db/alembic/versions/20260513_000000_add_api_key_apply_to_codex_model.py +59 -0
- app/db/alembic/versions/20260514_000000_add_request_logs_api_key_time_index.py +43 -0
- app/db/alembic/versions/20260515_000000_add_prefer_earlier_reset_window.py +47 -0
- app/db/alembic/versions/20260515_000000_soft_delete_request_logs_on_account_delete.py +83 -0
- app/db/alembic/versions/20260515_020000_add_split_sticky_budget_thresholds.py +62 -0
- app/db/alembic/versions/20260516_000000_add_sqlite_hot_path_indexes.py +75 -0
- app/db/alembic/versions/20260517_000000_merge_sqlite_hot_path_and_request_log_delete_heads.py +24 -0
- app/db/alembic/versions/20260518_000000_add_http_bridge_durable_input_prefix.py +44 -0
- app/db/alembic/versions/20260518_010000_merge_http_bridge_and_sqlite_recovery_heads.py +25 -0
- app/db/alembic/versions/20260518_120000_add_dashboard_guest_access.py +57 -0
- app/db/alembic/versions/20260520_000000_merge_api_key_and_http_bridge_heads.py +26 -0
- app/db/alembic/versions/20260520_010000_add_request_logs_api_key_account_index.py +45 -0
- app/db/alembic/versions/20260520_010000_merge_automation_and_api_key_heads.py +26 -0
- app/db/alembic/versions/20260520_030000_add_quota_planner.py +194 -0
- app/db/alembic/versions/20260520_040000_merge_quota_planner_and_request_log_index_heads.py +24 -0
- app/db/alembic/versions/20260521_000000_add_account_security_work_authorized.py +46 -0
- app/db/alembic/versions/20260521_000000_merge_dashboard_guest_and_api_key_heads.py +26 -0
- app/db/alembic/versions/20260521_000000_merge_prefer_reset_window_head.py +26 -0
- app/db/alembic/versions/20260521_000000_merge_warmup_and_request_log_index_heads.py +25 -0
- app/db/alembic/versions/20260522_000000_add_limit_warmup_trigger.py +195 -0
- app/db/alembic/versions/20260524_000000_merge_accounts_alias_and_reset_window_heads.py +24 -0
- app/db/alembic/versions/20260525_000000_add_usage_raw_window_latest_index.py +31 -0
- app/db/alembic/versions/20260526_000000_add_request_log_failure_metadata.py +100 -0
- app/db/alembic/versions/20260531_000000_add_account_workspace_identity.py +39 -0
- app/db/alembic/versions/20260531_000000_add_single_account_routing.py +42 -0
- app/db/alembic/versions/20260601_000000_merge_relative_availability_and_usage_raw_heads.py +24 -0
- app/db/alembic/versions/20260601_010000_add_api_key_usage_sections.py +58 -0
- app/db/alembic/versions/20260601_010000_add_routing_policy_persistence.py +67 -0
- app/db/alembic/versions/20260601_010000_merge_security_work_and_relative_availability_heads.py +25 -0
- app/db/alembic/versions/20260601_010000_merge_split_sticky_and_relative_usage_heads.py +25 -0
- app/db/alembic/versions/20260601_010000_merge_warmup_and_relative_availability_heads.py +25 -0
- app/db/alembic/versions/20260601_020000_merge_additional_quota_routing_and_relative_availability_heads.py +25 -0
- app/db/alembic/versions/20260601_020000_merge_quota_planner_and_relative_availability_heads.py +25 -0
- app/db/alembic/versions/20260601_020000_merge_reset_window_and_relative_availability_heads.py +25 -0
- app/db/alembic/versions/20260601_020000_merge_routing_policy_and_split_threshold_heads.py +24 -0
- app/db/alembic/versions/20260601_020000_merge_warmup_and_request_log_failure_heads.py +25 -0
- app/db/alembic/versions/20260601_030000_merge_single_account_and_routing_quota_heads.py +29 -0
- app/db/alembic/versions/20260601_040000_merge_security_work_and_routing_consolidation_heads.py +25 -0
- app/db/alembic/versions/20260601_050000_merge_quota_planner_and_routing_consolidation_heads.py +25 -0
- app/db/alembic/versions/20260602_050000_add_upstream_proxy_routing.py +164 -0
- app/db/alembic/versions/20260602_060000_merge_account_workspace_and_failure_heads.py +25 -0
- app/db/alembic/versions/20260602_070000_add_request_log_useragent_fields.py +86 -0
- app/db/alembic/versions/20260602_070000_merge_quota_planner_and_account_workspace_heads.py +25 -0
- app/db/alembic/versions/20260602_080000_merge_upstream_proxy_and_quota_planner_heads.py +25 -0
- app/db/alembic/versions/20260602_080000_merge_useragent_and_upstream_proxy_heads.py +24 -0
- app/db/alembic/versions/20260603_000000_add_weekly_pace_working_days.py +52 -0
- app/db/alembic/versions/20260603_000000_free_account_monthly_window.py +60 -0
- app/db/alembic/versions/20260604_000000_add_reauth_required_account_status.py +159 -0
- app/db/alembic/versions/20260604_010000_merge_automations_and_reauth_status_heads.py +25 -0
- app/db/alembic/versions/20260604_010000_merge_dashboard_guest_and_reauth_status_heads.py +25 -0
- app/db/alembic/versions/20260604_010000_merge_useragent_and_reauth_heads.py +24 -0
- app/db/alembic/versions/20260607_000000_merge_weekly_monthly_useragent_heads.py +28 -0
- app/db/alembic/versions/20260608_000000_add_hide_upstream_quota_from_api_keys.py +50 -0
- app/db/alembic/versions/20260611_000000_add_request_log_archive_request_id.py +47 -0
- app/db/alembic/versions/20260611_000000_merge_automations_and_weekly_monthly_useragent_heads.py +26 -0
- app/db/alembic/versions/20260611_000000_merge_dashboard_guest_and_weekly_useragent_heads.py +26 -0
- app/db/alembic/versions/20260611_010000_add_request_log_client_ip.py +57 -0
- app/db/alembic/versions/20260611_020000_merge_request_log_archive_and_client_ip_heads.py +26 -0
- app/db/alembic/versions/20260611_030000_merge_dashboard_guest_and_request_log_client_ip_heads.py +26 -0
- app/db/alembic/versions/20260613_000000_add_accounts_codex_installation_id.py +57 -0
- app/db/alembic/versions/20260613_010000_merge_installation_id_and_dashboard_weekly_heads.py +26 -0
- app/db/alembic/versions/20260615_000000_merge_automations_and_dashboard_guest_heads.py +26 -0
- app/db/alembic/versions/20260623_000000_add_limit_warmup_exhausted_threshold.py +51 -0
- app/db/alembic/versions/20260626_000000_add_http_downstream_transport_policy.py +46 -0
- app/db/alembic/versions/20260626_010000_add_request_logs_upstream_transport.py +31 -0
- app/db/alembic/versions/20260629_000000_add_dashboard_query_hot_path_indexes.py +53 -0
- app/db/alembic/versions/20260630_000000_add_limit_warmup_staggered_idle.py +47 -0
- app/db/alembic/versions/20260630_000000_merge_request_log_client_ip_and_dashboard_hot_path_heads.py +26 -0
- app/db/alembic/versions/20260630_010000_merge_warmup_and_request_log_dashboard_heads.py +26 -0
- app/db/alembic/versions/20260630_020000_merge_automations_and_main_heads.py +26 -0
- app/db/alembic/versions/20260630_020000_merge_warmup_threshold_and_main_heads.py +26 -0
- app/db/alembic/versions/20260630_030000_add_automation_run_model_snapshot.py +59 -0
- app/db/alembic/versions/20260630_040000_merge_automation_snapshot_and_warmup_threshold_heads.py +26 -0
- app/db/alembic/versions/20260630_050000_add_automation_run_prompt_snapshot.py +52 -0
- app/db/alembic/versions/20260701_000000_add_weekly_pace_smoothing_minutes.py +51 -0
- app/db/alembic/versions/20260702_000000_add_model_sources.py +176 -0
- app/db/alembic/versions/20260705_000000_add_model_source_audio_transcriptions.py +50 -0
- app/db/alembic/versions/20260705_000000_harden_dashboard_session_ttl.py +62 -0
- app/db/alembic/versions/20260706_000000_add_model_source_audio_per_minute.py +43 -0
- app/db/alembic/versions/20260707_000000_merge_model_sources_and_session_ttl.py +24 -0
- app/db/alembic/versions/20260707_010000_merge_automations_and_model_sources_heads.py +24 -0
- app/db/alembic/versions/20260707_020000_add_automation_job_account_scope.py +125 -0
- app/db/alembic/versions/20260709_000000_add_ttft_phase_observability.py +66 -0
- app/db/alembic/versions/20260711_000000_add_dashboard_prohibit_fast_mode.py +42 -0
- app/db/alembic/versions/20260711_010000_add_account_chatgpt_user_id.py +40 -0
- app/db/alembic/versions/20260711_020000_add_dashboard_account_concurrency_caps.py +71 -0
- app/db/alembic/versions/20260711_030000_add_limit_warmup_idle_threshold.py +51 -0
- app/db/alembic/versions/20260712_010000_add_account_usage_rollups.py +56 -0
- app/db/alembic/versions/20260712_020000_add_api_key_usage_rollups.py +53 -0
- app/db/alembic/versions/20260713_020000_add_model_registry_snapshot.py +42 -0
- app/db/alembic/versions/20260713_040000_add_account_refresh_claims.py +42 -0
- app/db/alembic/versions/20260713_040000_add_replica_guardrails.py +64 -0
- app/db/alembic/versions/20260713_070000_add_reset_credit_redeem_tables.py +58 -0
- app/db/alembic/versions/20260714_000000_add_oauth_flow_states.py +63 -0
- app/db/alembic/versions/20260715_000000_add_request_log_queue_latency.py +44 -0
- app/db/alembic/versions/20260716_000000_add_oauth_device_flow_slots.py +41 -0
- app/db/alembic/versions/20260716_010000_add_dashboard_retention_settings.py +48 -0
- app/db/alembic/versions/20260716_010000_add_reset_credit_display_settings.py +73 -0
- app/db/alembic/versions/20260717_000000_add_http_bridge_retry_circuits.py +47 -0
- app/db/alembic/versions/20260717_000000_merge_retention_and_reset_credit_display_heads.py +26 -0
- app/db/alembic/versions/20260717_000000_optimize_dashboard_hot_path_indexes.py +162 -0
- app/db/alembic/versions/20260717_000001_merge_retry_circuits_and_dashboard_indexes.py +22 -0
- app/db/alembic/versions/20260720_000000_add_request_log_conversation_id.py +57 -0
- app/db/alembic/versions/20260722_000000_backfill_request_log_useragent_families.py +40 -0
- app/db/alembic/versions/20260724_000000_add_request_usage_time_rollups.py +176 -0
- app/db/alembic/versions/20260724_000000_merge_request_log_schema_heads.py +33 -0
- app/db/alembic/versions/20260725_000000_add_http_bridge_pending_tool_calls.py +43 -0
- app/db/alembic/versions/20260726_000000_add_account_plan_downgrade_observations.py +44 -0
- app/db/alembic/versions/20260726_000000_repair_request_usage_rollups_after_merge.py +37 -0
- app/db/alembic/versions/20260727_000000_add_sticky_session_continuity_abandoned_at.py +45 -0
- app/db/alembic/versions/20260728_000000_merge_pending_tool_calls_and_rollup_repair_heads.py +31 -0
- app/db/alembic/versions/20260730_000000_add_api_key_fair_share_threshold.py +44 -0
- app/db/alembic/versions/20260730_000000_add_http_bridge_recovery_attempts.py +60 -0
- app/db/alembic/versions/20260731_000000_add_capability_lineage_markers.py +38 -0
- app/db/alembic/versions/20260803_000000_merge_http_bridge_recovery_and_capability_lineage_heads.py +30 -0
- app/db/alembic/versions/20260804_000000_add_http_bridge_operations.py +63 -0
- app/db/alembic/versions/20260804_000001_add_global_http_bridge_operation_fingerprint.py +53 -0
- app/db/alembic/versions/20260804_230000_add_request_log_connection_request_kind.py +43 -0
- app/db/alembic/versions/20260805_000000_add_http_bridge_operation_spool.py +75 -0
- app/db/alembic/versions/20260805_000001_finalize_http_bridge_operation_spool.py +65 -0
- app/db/alembic/versions/20260806_000000_add_additional_usage_alias_probe_indexes.py +84 -0
- app/db/alembic/versions/20260806_000000_add_anonymous_telemetry.py +49 -0
- app/db/alembic/versions/20260806_010000_add_conversation_presence_rollup.py +72 -0
- app/db/alembic/versions/20260806_020000_add_usage_history_bulk_covering_indexes.py +99 -0
- app/db/alembic/versions/20260806_030000_add_api_key_allowed_reasoning_efforts.py +65 -0
- app/db/alembic/versions/20260806_120000_add_http_bridge_owner_process_epoch.py +57 -0
- app/db/alembic/versions/20260807_000000_merge_http_bridge_operation_spool_and_latest_main.py +24 -0
- app/db/alembic/versions/20260808_000000_tune_usage_history_autovacuum.py +54 -0
- app/db/alembic/versions/20260810_000000_add_http_bridge_recovery_dispatch_count.py +44 -0
- app/db/alembic/versions/20260811_000000_add_hourly_rollup_cancelled_count.py +92 -0
- app/db/alembic/versions/20260812_000000_merge_recovery_dispatch_and_hourly_cancelled_heads.py +25 -0
- app/db/alembic/versions/20260812_120000_add_sticky_abandonment_scope.py +43 -0
- app/db/alembic/versions/20260813_000000_add_file_account_pins.py +40 -0
- app/db/alembic/versions/20260816_000000_add_account_pending_deletion.py +81 -0
- app/db/alembic/versions/20260816_000000_add_model_source_embeddings.py +50 -0
- app/db/alembic/versions/20260821_000000_add_retry_circuit_admission_generation.py +49 -0
- app/db/alembic/versions/20260826_000000_add_http_bridge_event_chunks.py +107 -0
- app/db/alembic/versions/20260828_000000_add_accounts_chatgpt_identity_index.py +55 -0
- app/db/alembic/versions/20260830_000000_add_quota_warmup_claim_expiry.py +83 -0
- app/db/alembic/versions/20260908_000000_add_guest_session_generation.py +37 -0
- app/db/alembic/versions/20260908_000000_add_subscription_overflow.py +140 -0
- app/db/alembic/versions/20260908_000000_replace_upstream_stream_transport_default_sentinel.py +50 -0
- app/db/alembic/versions/20260908_020000_merge_overflow_transport_heads.py +27 -0
- app/db/alembic/versions/20260909_000000_add_dashboard_roles.py +72 -0
- app/db/alembic/versions/20260909_010000_add_dashboard_users.py +183 -0
- app/db/alembic/versions/20260909_020000_reproject_compat_admin_credentials.py +105 -0
- app/db/alembic/versions/20260909_030000_add_audit_actor_columns.py +103 -0
- app/db/alembic/versions/20260909_030000_dashboard_resilience_toggle_settings.py +63 -0
- app/db/alembic/versions/20260909_040000_add_dashboard_user_invites.py +54 -0
- app/db/alembic/versions/20260909_040000_dashboard_timeout_settings.py +68 -0
- app/db/alembic/versions/20260909_050000_dashboard_routing_overload_settings.py +65 -0
- app/db/alembic/versions/20260909_060000_add_report_rollup.py +74 -0
- app/db/alembic/versions/20260909_070000_automation_run_claim_budget.py +50 -0
- app/db/alembic/versions/20260909_080000_dashboard_stream_bridge_budgets.py +62 -0
- app/db/alembic/versions/20260909_090000_dashboard_background_job_toggles.py +63 -0
- app/db/alembic/versions/20260909_100000_dashboard_codex_prewarm.py +49 -0
- app/db/alembic/versions/20260909_110000_model_context_window_overrides.py +45 -0
- app/db/alembic/versions/20260909_120000_dashboard_conversation_archive.py +48 -0
- app/db/alembic/versions/20260909_130000_add_request_logs_live_facet_indexes.py +96 -0
- app/db/alembic/versions/20260910_000000_add_totp_required_for_admin_role.py +44 -0
- app/db/alembic/versions/20260910_000000_request_logs_missing_cost_index.py +52 -0
- app/db/alembic/versions/20260910_010000_add_dashboard_auth_providers.py +134 -0
- app/db/alembic/versions/20260910_010000_dashboard_spool_retention.py +52 -0
- app/db/alembic/versions/20260910_020000_add_dashboard_role_mappings.py +74 -0
- app/db/alembic/versions/20260910_143000_request_log_affinity.py +28 -0
- app/db/alembic/versions/20260910_180000_merge_affinity_guest_heads.py +17 -0
- app/db/alembic/versions/20260910_200000_merge_affinity_identity_heads.py +17 -0
- app/db/alembic/versions/20260910_220000_merge_affinity_invite_heads.py +17 -0
- app/db/alembic/versions/20260911_000000_model_source_pins_kind_expires_index.py +43 -0
- app/db/alembic/versions/20260911_010000_merge_pin_index_and_affinity_heads.py +17 -0
- app/db/alembic/versions/20260911_020000_add_http_bridge_terminal_append_phase.py +54 -0
- app/db/alembic/versions/20260911_030000_add_local_login_policy.py +48 -0
- app/db/alembic/versions/20260911_040000_add_thread_cache_identity_mode.py +48 -0
- app/db/alembic/versions/20260911_060000_add_bridge_session_continuity_abandonment.py +40 -0
- app/db/alembic/versions/20260912_000000_merge_thread_cache_and_bridge_retirement_heads.py +22 -0
- app/db/alembic/versions/20260912_010000_drop_legacy_dashboard_credentials.py +140 -0
- app/db/alembic/versions/20260913_000000_add_oidc_provider_flow.py +134 -0
- app/db/alembic/versions/20260914_000000_add_scim_tokens.py +78 -0
- app/db/alembic/versions/20260914_000000_drop_subscription_overflow_schema.py +132 -0
- app/db/alembic/versions/20260918_000000_merge_scim_and_overflow_heads.py +17 -0
- app/db/alembic/versions/__init__.py +1 -0
- app/db/backup.py +64 -0
- app/db/migrate.py +1249 -0
- app/db/migration_lock.py +160 -0
- app/db/migration_url.py +18 -0
- app/db/models.py +3100 -0
- app/db/recover.py +244 -0
- app/db/session.py +1295 -0
- app/db/snapshot.py +46 -0
- app/db/sqlite_lock_retry.py +190 -0
- app/db/sqlite_utils.py +549 -0
- app/dependencies.py +462 -0
- app/main.py +1240 -0
- app/modules/__init__.py +0 -0
- app/modules/accounts/__init__.py +0 -0
- app/modules/accounts/api.py +426 -0
- app/modules/accounts/auth_manager.py +1439 -0
- app/modules/accounts/background_repository.py +160 -0
- app/modules/accounts/deletion.py +540 -0
- app/modules/accounts/mappers.py +654 -0
- app/modules/accounts/refresh_claims.py +352 -0
- app/modules/accounts/repository.py +1679 -0
- app/modules/accounts/schemas.py +308 -0
- app/modules/accounts/service.py +809 -0
- app/modules/accounts/usage_rollup.py +486 -0
- app/modules/accounts/usage_rollup_scheduler.py +75 -0
- app/modules/accounts/usage_time_rollup.py +1037 -0
- app/modules/accounts/usage_time_rollup_read.py +522 -0
- app/modules/api_keys/__init__.py +1 -0
- app/modules/api_keys/api.py +344 -0
- app/modules/api_keys/last_used_coalescer.py +216 -0
- app/modules/api_keys/limit_windows.py +41 -0
- app/modules/api_keys/repository.py +1200 -0
- app/modules/api_keys/reset_scheduler.py +85 -0
- app/modules/api_keys/schemas.py +135 -0
- app/modules/api_keys/service.py +2123 -0
- app/modules/audit/__init__.py +0 -0
- app/modules/audit/api.py +88 -0
- app/modules/audit/repository.py +74 -0
- app/modules/audit/schemas.py +33 -0
- app/modules/audit/service.py +71 -0
- app/modules/auth_providers/__init__.py +0 -0
- app/modules/auth_providers/api.py +127 -0
- app/modules/auth_providers/config.py +343 -0
- app/modules/auth_providers/repository.py +101 -0
- app/modules/auth_providers/schemas.py +88 -0
- app/modules/auth_providers/seed.py +105 -0
- app/modules/auth_providers/service.py +289 -0
- app/modules/automations/__init__.py +1 -0
- app/modules/automations/api.py +369 -0
- app/modules/automations/repository.py +1896 -0
- app/modules/automations/scheduler.py +107 -0
- app/modules/automations/schemas.py +158 -0
- app/modules/automations/service.py +2548 -0
- app/modules/cache_isolation_probe/__init__.py +0 -0
- app/modules/cache_isolation_probe/api.py +188 -0
- app/modules/cache_isolation_probe/prefix.py +144 -0
- app/modules/cache_isolation_probe/schemas.py +94 -0
- app/modules/cache_isolation_probe/sender.py +229 -0
- app/modules/cache_isolation_probe/service.py +525 -0
- app/modules/conversation_archive/__init__.py +1 -0
- app/modules/conversation_archive/api.py +101 -0
- app/modules/conversation_archive/schemas.py +28 -0
- app/modules/conversation_archive/service.py +165 -0
- app/modules/dashboard/__init__.py +1 -0
- app/modules/dashboard/api.py +106 -0
- app/modules/dashboard/builders.py +107 -0
- app/modules/dashboard/repository.py +304 -0
- app/modules/dashboard/schemas.py +148 -0
- app/modules/dashboard/service.py +534 -0
- app/modules/dashboard/timeframes.py +19 -0
- app/modules/dashboard/weekly_pace.py +617 -0
- app/modules/dashboard_auth/__init__.py +1 -0
- app/modules/dashboard_auth/api.py +1344 -0
- app/modules/dashboard_auth/oidc_api.py +753 -0
- app/modules/dashboard_auth/oidc_flows.py +330 -0
- app/modules/dashboard_auth/repository.py +452 -0
- app/modules/dashboard_auth/schemas.py +232 -0
- app/modules/dashboard_auth/service.py +1384 -0
- app/modules/dashboard_roles/__init__.py +0 -0
- app/modules/dashboard_roles/api.py +64 -0
- app/modules/dashboard_roles/repository.py +54 -0
- app/modules/dashboard_roles/schemas.py +29 -0
- app/modules/dashboard_roles/seed.py +80 -0
- app/modules/dashboard_roles/service.py +142 -0
- app/modules/dashboard_users/__init__.py +0 -0
- app/modules/dashboard_users/api.py +278 -0
- app/modules/dashboard_users/break_glass.py +169 -0
- app/modules/dashboard_users/credentials.py +18 -0
- app/modules/dashboard_users/identity_resolver.py +665 -0
- app/modules/dashboard_users/repository.py +725 -0
- app/modules/dashboard_users/schemas.py +117 -0
- app/modules/dashboard_users/service.py +1054 -0
- app/modules/firewall/__init__.py +1 -0
- app/modules/firewall/api.py +78 -0
- app/modules/firewall/repository.py +51 -0
- app/modules/firewall/schemas.py +28 -0
- app/modules/firewall/service.py +93 -0
- app/modules/fleet/__init__.py +1 -0
- app/modules/fleet/api.py +177 -0
- app/modules/fleet/mappers.py +56 -0
- app/modules/fleet/observability.py +372 -0
- app/modules/fleet/schemas.py +119 -0
- app/modules/health/__init__.py +0 -0
- app/modules/health/api.py +246 -0
- app/modules/health/schemas.py +27 -0
- app/modules/limit_warmup/__init__.py +1 -0
- app/modules/limit_warmup/repository.py +159 -0
- app/modules/limit_warmup/service.py +1001 -0
- app/modules/model_sources/__init__.py +1 -0
- app/modules/model_sources/api.py +99 -0
- app/modules/model_sources/catalog.py +307 -0
- app/modules/model_sources/forwarding.py +1435 -0
- app/modules/model_sources/projection.py +55 -0
- app/modules/model_sources/repository.py +201 -0
- app/modules/model_sources/schemas.py +79 -0
- app/modules/model_sources/selection.py +166 -0
- app/modules/model_sources/service.py +236 -0
- app/modules/oauth/__init__.py +0 -0
- app/modules/oauth/api.py +101 -0
- app/modules/oauth/repository.py +238 -0
- app/modules/oauth/schemas.py +49 -0
- app/modules/oauth/service.py +1196 -0
- app/modules/oauth/templates/oauth_success.html +122 -0
- app/modules/proxy/__init__.py +0 -0
- app/modules/proxy/_load_balancer/__init__.py +1 -0
- app/modules/proxy/_load_balancer/error_rate.py +116 -0
- app/modules/proxy/_load_balancer/latency_cohort.py +154 -0
- app/modules/proxy/_load_balancer/model_eligibility.py +250 -0
- app/modules/proxy/_load_balancer/opportunistic_admission.py +350 -0
- app/modules/proxy/_load_balancer/overload_backoff.py +394 -0
- app/modules/proxy/_load_balancer/sticky_selection.py +2417 -0
- app/modules/proxy/_load_balancer/throughput_cohort.py +233 -0
- app/modules/proxy/_load_balancer/ttft_cohort.py +214 -0
- app/modules/proxy/_load_balancer/tunables.py +97 -0
- app/modules/proxy/_load_balancer/types.py +96 -0
- app/modules/proxy/_load_balancer/unbound_selection.py +534 -0
- app/modules/proxy/_service/__init__.py +6 -0
- app/modules/proxy/_service/api_key_usage.py +745 -0
- app/modules/proxy/_service/clock_budget.py +38 -0
- app/modules/proxy/_service/codex_control.py +611 -0
- app/modules/proxy/_service/compact.py +2211 -0
- app/modules/proxy/_service/file_ops.py +749 -0
- app/modules/proxy/_service/http_bridge/__init__.py +3 -0
- app/modules/proxy/_service/http_bridge/accepted_replay.py +331 -0
- app/modules/proxy/_service/http_bridge/account_sessions.py +57 -0
- app/modules/proxy/_service/http_bridge/activity.py +178 -0
- app/modules/proxy/_service/http_bridge/helpers.py +3959 -0
- app/modules/proxy/_service/http_bridge/mixin.py +2435 -0
- app/modules/proxy/_service/http_bridge/owner_forwarding.py +609 -0
- app/modules/proxy/_service/http_bridge/protocol.py +167 -0
- app/modules/proxy/_service/http_bridge/proxy_failover.py +58 -0
- app/modules/proxy/_service/http_bridge/quarantine.py +443 -0
- app/modules/proxy/_service/http_bridge/request_submit.py +4582 -0
- app/modules/proxy/_service/http_bridge/retry_circuit.py +2442 -0
- app/modules/proxy/_service/http_bridge/service_stubs.py +492 -0
- app/modules/proxy/_service/http_bridge/session_registry.py +778 -0
- app/modules/proxy/_service/http_bridge/streaming.py +5328 -0
- app/modules/proxy/_service/http_bridge/upstream_events.py +4538 -0
- app/modules/proxy/_service/observability.py +410 -0
- app/modules/proxy/_service/rate_limit.py +361 -0
- app/modules/proxy/_service/realtime_live.py +655 -0
- app/modules/proxy/_service/refresh.py +154 -0
- app/modules/proxy/_service/request_log.py +585 -0
- app/modules/proxy/_service/response_create.py +930 -0
- app/modules/proxy/_service/streaming/__init__.py +3 -0
- app/modules/proxy/_service/streaming/helpers.py +1317 -0
- app/modules/proxy/_service/streaming/mixin.py +1100 -0
- app/modules/proxy/_service/streaming/protocol.py +32 -0
- app/modules/proxy/_service/streaming/retry.py +3762 -0
- app/modules/proxy/_service/support.py +2122 -0
- app/modules/proxy/_service/transcribe.py +434 -0
- app/modules/proxy/_service/warmup.py +483 -0
- app/modules/proxy/_service/websocket/__init__.py +3 -0
- app/modules/proxy/_service/websocket/helpers.py +2360 -0
- app/modules/proxy/_service/websocket/mixin.py +7285 -0
- app/modules/proxy/_service/websocket/protocol.py +74 -0
- app/modules/proxy/account_cache.py +229 -0
- app/modules/proxy/account_eligibility.py +87 -0
- app/modules/proxy/additional_model_limits.py +40 -0
- app/modules/proxy/affinity.py +830 -0
- app/modules/proxy/affinity_observation.py +101 -0
- app/modules/proxy/api.py +10254 -0
- app/modules/proxy/api_key_usage.py +113 -0
- app/modules/proxy/cap_partitioning.py +280 -0
- app/modules/proxy/capability_lineage.py +65 -0
- app/modules/proxy/capability_lineage_repository.py +82 -0
- app/modules/proxy/capability_routing.py +253 -0
- app/modules/proxy/continuity.py +112 -0
- app/modules/proxy/downstream_delivery.py +277 -0
- app/modules/proxy/durable_bridge_coordinator.py +1217 -0
- app/modules/proxy/durable_bridge_repository.py +4516 -0
- app/modules/proxy/durable_bridge_runtime.py +9 -0
- app/modules/proxy/durable_bridge_transcript_codec.py +122 -0
- app/modules/proxy/fair_share.py +131 -0
- app/modules/proxy/file_pin_repository.py +210 -0
- app/modules/proxy/helpers.py +439 -0
- app/modules/proxy/http_bridge_event_batcher.py +613 -0
- app/modules/proxy/http_bridge_forwarding.py +797 -0
- app/modules/proxy/http_continuation.py +76 -0
- app/modules/proxy/images_observability.py +62 -0
- app/modules/proxy/images_service.py +1054 -0
- app/modules/proxy/load_balancer.py +3016 -0
- app/modules/proxy/rate_limit_cache.py +46 -0
- app/modules/proxy/replay_safety.py +1063 -0
- app/modules/proxy/repo_bundle.py +31 -0
- app/modules/proxy/request_policy.py +1054 -0
- app/modules/proxy/ring_membership.py +251 -0
- app/modules/proxy/schemas.py +345 -0
- app/modules/proxy/selection_errors.py +41 -0
- app/modules/proxy/service.py +2600 -0
- app/modules/proxy/source_admission.py +125 -0
- app/modules/proxy/source_dispatch.py +999 -0
- app/modules/proxy/sticky_repository.py +831 -0
- app/modules/proxy/thread_anchors.py +491 -0
- app/modules/proxy/tool_call_dedupe.py +802 -0
- app/modules/proxy/types.py +54 -0
- app/modules/proxy/work_admission.py +121 -0
- app/modules/quota_planner/__init__.py +1 -0
- app/modules/quota_planner/api.py +276 -0
- app/modules/quota_planner/logic.py +743 -0
- app/modules/quota_planner/repository.py +722 -0
- app/modules/quota_planner/scheduler.py +212 -0
- app/modules/quota_planner/schemas.py +102 -0
- app/modules/quota_planner/warmup.py +693 -0
- app/modules/rate_limit_reset_credits/__init__.py +0 -0
- app/modules/rate_limit_reset_credits/api.py +601 -0
- app/modules/rate_limit_reset_credits/redeem_coordination.py +274 -0
- app/modules/rate_limit_reset_credits/store.py +114 -0
- app/modules/reports/__init__.py +1 -0
- app/modules/reports/api.py +134 -0
- app/modules/reports/cache.py +74 -0
- app/modules/reports/filters.py +27 -0
- app/modules/reports/repository.py +525 -0
- app/modules/reports/rollup.py +150 -0
- app/modules/reports/rollup_read.py +148 -0
- app/modules/reports/schemas.py +123 -0
- app/modules/reports/service.py +287 -0
- app/modules/reports/thread_identity.py +256 -0
- app/modules/request_logs/__init__.py +0 -0
- app/modules/request_logs/api.py +224 -0
- app/modules/request_logs/cost_backfill.py +154 -0
- app/modules/request_logs/mappers.py +97 -0
- app/modules/request_logs/repository.py +1765 -0
- app/modules/request_logs/schemas.py +145 -0
- app/modules/request_logs/service.py +348 -0
- app/modules/role_mappings/__init__.py +0 -0
- app/modules/role_mappings/api.py +206 -0
- app/modules/role_mappings/matching.py +55 -0
- app/modules/role_mappings/repository.py +106 -0
- app/modules/role_mappings/schemas.py +67 -0
- app/modules/role_mappings/service.py +334 -0
- app/modules/runtime/__init__.py +1 -0
- app/modules/runtime/api.py +18 -0
- app/modules/runtime/schemas.py +14 -0
- app/modules/runtime/service.py +218 -0
- app/modules/scim/__init__.py +1 -0
- app/modules/scim/api.py +194 -0
- app/modules/scim/dependencies.py +112 -0
- app/modules/scim/errors.py +77 -0
- app/modules/scim/management_api.py +156 -0
- app/modules/scim/repository.py +212 -0
- app/modules/scim/schemas.py +145 -0
- app/modules/scim/service.py +786 -0
- app/modules/scim/tokens.py +43 -0
- app/modules/settings/__init__.py +1 -0
- app/modules/settings/api.py +1677 -0
- app/modules/settings/repository.py +606 -0
- app/modules/settings/schemas.py +496 -0
- app/modules/settings/service.py +769 -0
- app/modules/shared/__init__.py +0 -0
- app/modules/shared/schemas.py +22 -0
- app/modules/sticky_sessions/__init__.py +1 -0
- app/modules/sticky_sessions/api.py +118 -0
- app/modules/sticky_sessions/cleanup_scheduler.py +487 -0
- app/modules/sticky_sessions/schemas.py +78 -0
- app/modules/sticky_sessions/service.py +196 -0
- app/modules/telemetry/__init__.py +5 -0
- app/modules/telemetry/api.py +115 -0
- app/modules/telemetry/clients.py +62 -0
- app/modules/telemetry/consent.py +115 -0
- app/modules/telemetry/scheduler.py +85 -0
- app/modules/telemetry/schemas.py +163 -0
- app/modules/telemetry/sender.py +221 -0
- app/modules/telemetry/snapshot.py +490 -0
- app/modules/usage/__init__.py +0 -0
- app/modules/usage/additional_quota_keys.py +379 -0
- app/modules/usage/api.py +45 -0
- app/modules/usage/background_repository.py +147 -0
- app/modules/usage/builders.py +559 -0
- app/modules/usage/depletion_service.py +277 -0
- app/modules/usage/live_ingest.py +356 -0
- app/modules/usage/mappers.py +29 -0
- app/modules/usage/plan_downgrade_observations.py +488 -0
- app/modules/usage/repository.py +1890 -0
- app/modules/usage/schemas.py +68 -0
- app/modules/usage/service.py +102 -0
- app/modules/usage/updater.py +1488 -0
- app/static/assets/Trans-Cj-J9mVA.js +1 -0
- app/static/assets/access-page-DHzZiXZi.js +1 -0
- app/static/assets/account-cost-donut-DGhfA4U8.js +1 -0
- app/static/assets/account-identifiers-CxbdLshZ.js +1 -0
- app/static/assets/account-status-DIsU5sUS.js +1 -0
- app/static/assets/account-trend-chart-BptlfwwQ.js +1 -0
- app/static/assets/accounts-page-Bbai8ift.js +3 -0
- app/static/assets/api-Dwa7XxPe.js +1 -0
- app/static/assets/api-client-dugX1Pti.js +55 -0
- app/static/assets/api-key-create-dialog-DnRm0oYN.js +1 -0
- app/static/assets/api-key-created-dialog-B6jkDG9f.js +1 -0
- app/static/assets/api-key-edit-dialog-Ck3Bnc3V.js +1 -0
- app/static/assets/api-trend-chart-BchCw7Hj.js +1 -0
- app/static/assets/apis-page-BvXz9c6i.js +2 -0
- app/static/assets/arrow-up-Dqh_KzJo.js +1 -0
- app/static/assets/arrow-up-down-LBRgVDGY.js +1 -0
- app/static/assets/automations-page-DQgNAJOR.js +3 -0
- app/static/assets/badge-DqMb9es0.js +1 -0
- app/static/assets/blur-email-HEvKagG2.js +1 -0
- app/static/assets/button-BjVmmiGW.js +1 -0
- app/static/assets/checkbox-apsl9vzk.js +1 -0
- app/static/assets/chevron-left-1d_pHVa5.js +1 -0
- app/static/assets/circle-alert-BS0xd_o1.js +1 -0
- app/static/assets/clsx-DB0hHKMi.js +1 -0
- app/static/assets/colors-BBy8GEtr.js +1 -0
- app/static/assets/copy-button-D7nAvOKR.js +1 -0
- app/static/assets/cost-per-day-chart-YdqlkZVM.js +1 -0
- app/static/assets/createLucideIcon-DBLzLNh2.js +1 -0
- app/static/assets/dashboard-page-CSdhBy0f.js +2 -0
- app/static/assets/distribution-metric-format-yZTy1ZEu.js +1 -0
- app/static/assets/donut-chart-Bxc69cra.js +1 -0
- app/static/assets/download-kQteIcsB.js +1 -0
- app/static/assets/ellipsis-B_5OgIre.js +1 -0
- app/static/assets/empty-state-JcA7tc8m.js +1 -0
- app/static/assets/es2015-bMH8YKZT.js +41 -0
- app/static/assets/es6-B264ni6W.js +69 -0
- app/static/assets/external-link-UVAOgMQ0.js +1 -0
- app/static/assets/i18n-BWqZ9Ua2.js +1 -0
- app/static/assets/inbox-B_RM2s1J.js +1 -0
- app/static/assets/index-DIpd264Z.js +23 -0
- app/static/assets/index-DMeLKRJx.css +2 -0
- app/static/assets/inherit-badge-QhTYVaU6.js +1 -0
- app/static/assets/invite-dialog-0CYh0GiQ.js +1 -0
- app/static/assets/iso-Bpe5Ihbb.js +1 -0
- app/static/assets/label-CGaLmLNf.js +1 -0
- app/static/assets/lazy-recharts-Pv8p9ArM.js +2 -0
- app/static/assets/loading-overlay-CzKQfHLI.js +1 -0
- app/static/assets/mini-quota-bar-cGT_t8Ae.js +1 -0
- app/static/assets/model-distribution-donut-BKjAfT48.js +1 -0
- app/static/assets/model-source-multi-select-D2d06Vc7.js +1 -0
- app/static/assets/multi-select-filter-KIA5qU6Z.js +1 -0
- app/static/assets/oauth-dialog-XeaGGDjS.js +1 -0
- app/static/assets/pagination-controls-D1Ypd0RU.js +1 -0
- app/static/assets/payload-CIYnGZz9.js +1 -0
- app/static/assets/queue-wait-chart-VoV7Yg9L.js +1 -0
- app/static/assets/report-chart-card-BXDliwcc.js +1 -0
- app/static/assets/reports-page-CGCJeMHG.js +3 -0
- app/static/assets/reset-credit-confirm-dialog-QOifTnVB.js +1 -0
- app/static/assets/rolldown-runtime-hePW80VL.js +1 -0
- app/static/assets/search-HfhqwERt.js +1 -0
- app/static/assets/select-Cl33bz-g.js +1 -0
- app/static/assets/settings-page-mZj01HYl.js +2 -0
- app/static/assets/shim-CZwyM4Q7.js +1 -0
- app/static/assets/skeleton-C_EUc4Rp.js +1 -0
- app/static/assets/sparkline-chart-DdNNsddM.js +1 -0
- app/static/assets/status-badge-CHHA5X6c.js +1 -0
- app/static/assets/switch-CzxgokcM.js +1 -0
- app/static/assets/table-DXaNSQ0G.js +1 -0
- app/static/assets/time-to-first-token-chart--68L0u_v.js +1 -0
- app/static/assets/tokens-per-day-chart-Cs82BFuE.js +1 -0
- app/static/assets/tokens-per-second-chart-AD2dfOn6.js +1 -0
- app/static/assets/totp-settings-CRHtxQ7j.js +1 -0
- app/static/assets/trash-D3KyWr1h.js +1 -0
- app/static/assets/use-account-quota-display-BPmrTBTC.js +1 -0
- app/static/assets/use-accounts-PWlVGw3z.js +1 -0
- app/static/assets/use-auth-CuDlW3iC.js +1 -0
- app/static/assets/use-chart-colors-DIu6tClI.js +1 -0
- app/static/assets/use-model-sources-Bul24JBu.js +1 -0
- app/static/assets/use-models-DUCPUuZg.js +1 -0
- app/static/assets/use-reduced-motion-hAm5r6_d.js +1 -0
- app/static/assets/useTranslation--56nHhlH.js +1 -0
- app/static/assets/useragent-distribution-donut-Dup6sf_n.js +1 -0
- app/static/assets/users-uIC3TIlE.js +1 -0
- app/static/assets/vendor-query-_bHZuxEx.js +1 -0
- app/static/assets/vendor-react-BVL0YZPW.js +9 -0
- app/static/favicon.svg +10 -0
- app/static/fonts/GeistSans-Variable.woff2 +0 -0
- app/static/fonts/jetbrains-mono-latin-ext.woff2 +0 -0
- app/static/fonts/jetbrains-mono-latin.woff2 +0 -0
- app/static/index.html +29 -0
- codexlb_up-1.25.0b10.dist-info/METADATA +124 -0
- codexlb_up-1.25.0b10.dist-info/RECORD +827 -0
- codexlb_up-1.25.0b10.dist-info/WHEEL +4 -0
- codexlb_up-1.25.0b10.dist-info/entry_points.txt +3 -0
- codexlb_up-1.25.0b10.dist-info/licenses/LICENSE +21 -0
- config/additional_quota_registry.json +11 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/api-key-create-dialog-DnRm0oYN.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-query-_bHZuxEx.js","assets/model-source-multi-select-D2d06Vc7.js","assets/createLucideIcon-DBLzLNh2.js","assets/iso-Bpe5Ihbb.js","assets/vendor-react-BVL0YZPW.js","assets/es2015-bMH8YKZT.js","assets/button-BjVmmiGW.js","assets/clsx-DB0hHKMi.js","assets/api-client-dugX1Pti.js","assets/chevron-left-1d_pHVa5.js","assets/select-Cl33bz-g.js","assets/index-DIpd264Z.js","assets/circle-alert-BS0xd_o1.js","assets/i18n-BWqZ9Ua2.js","assets/useTranslation--56nHhlH.js","assets/shim-CZwyM4Q7.js","assets/label-CGaLmLNf.js","assets/use-auth-CuDlW3iC.js","assets/index-DMeLKRJx.css","assets/use-models-DUCPUuZg.js","assets/account-status-DIsU5sUS.js","assets/use-accounts-PWlVGw3z.js","assets/badge-DqMb9es0.js","assets/status-badge-CHHA5X6c.js","assets/api-Dwa7XxPe.js","assets/trash-D3KyWr1h.js","assets/switch-CzxgokcM.js","assets/use-model-sources-Bul24JBu.js","assets/checkbox-apsl9vzk.js","assets/api-key-edit-dialog-Ck3Bnc3V.js","assets/totp-settings-CRHtxQ7j.js","assets/use-account-quota-display-BPmrTBTC.js","assets/payload-CIYnGZz9.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{C as t,S as n,n as r,r as i,t as a,x as o}from"./vendor-query-_bHZuxEx.js";import{t as s}from"./createLucideIcon-DBLzLNh2.js";import{i as c,n as l,r as u,t as d}from"./Trans-Cj-J9mVA.js";import{n as f,t as p}from"./arrow-up-Dqh_KzJo.js";import{s as m,t as h}from"./iso-Bpe5Ihbb.js";import{n as g}from"./chevron-left-1d_pHVa5.js";import{i as _,n as v,o as y,s as b,t as x}from"./select-Cl33bz-g.js";import{t as S}from"./pagination-controls-D1Ypd0RU.js";import{a as C,i as w,n as T,o as E,r as ee,t as D}from"./use-account-quota-display-BPmrTBTC.js";import{t as te}from"./copy-button-D7nAvOKR.js";import{t as O}from"./ellipsis-B_5OgIre.js";import{n as ne,r as re,t as ie}from"./trash-D3KyWr1h.js";import{n as ae,t as oe}from"./account-identifiers-CxbdLshZ.js";import{t as se}from"./users-uIC3TIlE.js";import{_ as ce,f as le,g as ue,h as de,m as fe,p as pe,v as me}from"./es2015-bMH8YKZT.js";import{t as k}from"./useTranslation--56nHhlH.js";import{c as he,s as ge,t as A}from"./button-BjVmmiGW.js";import{a as j,b as _e,d as M,f as N,g as ve,h as P,i as ye,m as F,n as be,o as xe,p as Se,r as Ce,t as we,u as I,v as L}from"./api-client-dugX1Pti.js";import{t as Te}from"./checkbox-apsl9vzk.js";import{t as Ee}from"./label-CGaLmLNf.js";import{t as R}from"./switch-CzxgokcM.js";import{E as De,f as Oe,n as z,r as B,u as ke}from"./use-auth-CuDlW3iC.js";import{$n as Ae,$t as je,Bt as Me,Cn as Ne,En as Pe,Fn as Fe,Gt as V,Ht as Ie,In as Le,Jt as Re,K as ze,Kt as H,Ln as Be,Nn as Ve,O as He,On as Ue,Pn as We,Qt as Ge,R as Ke,Sn as qe,Tn as Je,Ut as Ye,Vt as Xe,Wt as Ze,X as Qe,Xn as $e,Xt as et,Yn as tt,Zn as nt,Zt as rt,_n as it,a as at,an as ot,ar as st,b as ct,bn as lt,c as ut,cn as U,cr as dt,d as ft,dr as pt,en as mt,er as ht,et as gt,f as _t,fn as vt,gn as yt,gt as bt,hn as xt,ht as St,i as Ct,in as wt,j as Tt,kn as Et,l as Dt,ln as Ot,n as kt,nn as At,nr as jt,o as Mt,on as Nt,pn as Pt,pt as Ft,qt as It,r as Lt,rn as Rt,rr as zt,s as Bt,sn as W,t as Vt,tn as Ht,u as Ut,un as Wt,v as Gt,vn as Kt,w as qt,wn as Jt,xn as Yt,y as Xt,yn as Zt,zt as Qt}from"./index-DIpd264Z.js";import{n as $t,o as G,s as en}from"./account-status-DIsU5sUS.js";import{t as tn}from"./loading-overlay-CzKQfHLI.js";import{i as nn}from"./use-accounts-PWlVGw3z.js";import{t as K}from"./badge-DqMb9es0.js";import{t as q}from"./skeleton-C_EUc4Rp.js";import{i as rn,n as an,o as on,r as sn,s as cn}from"./api-Dwa7XxPe.js";import{t as ln}from"./use-model-sources-Bul24JBu.js";import{t as un}from"./api-key-created-dialog-B6jkDG9f.js";import{t as dn}from"./empty-state-JcA7tc8m.js";import{a as fn,i as J,n as pn,o as mn,r as Y,t as hn}from"./table-DXaNSQ0G.js";import{t as X}from"./payload-CIYnGZz9.js";import{t as Z}from"./inherit-badge-QhTYVaU6.js";import{A as gn,C as _n,D as vn,E as yn,M as bn,O as xn,S as Sn,T as Cn,_ as wn,a as Tn,b as En,c as Dn,d as On,f as kn,g as An,h as jn,i as Mn,j as Nn,k as Pn,l as Fn,m as In,n as Ln,o as Rn,p as zn,r as Bn,s as Vn,t as Hn,u as Un,v as Wn,w as Gn,x as Kn,y as qn}from"./invite-dialog-0CYh0GiQ.js";var Jn={name:`archive`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]};Jn.node;var Yn=s(Jn),Xn={name:`book-open`,size:24,node:[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}]]};Xn.node;var Zn=s(Xn),Qn={name:`boxes`,size:24,node:[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]};Qn.node;var $n=s(Qn),er={name:`calendar-clock`,size:24,node:[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338`,key:`7hb8p4`}],[`path`,{d:`M3 9h5.859`,key:`numkqi`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]};er.node;var tr=s(er),nr={name:`database`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]};nr.node;var rr=s(nr),ir={name:`database-zap`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 15 21.84`,key:`14ibmq`}],[`path`,{d:`M21 5V8`,key:`1marbg`}],[`path`,{d:`M21 12L18 17H22L19 22`,key:`zafso`}],[`path`,{d:`M3 12A9 3 0 0 0 14.59 14.87`,key:`1y4wr8`}]]};ir.node;var ar=s(ir),or={name:`flask-conical`,size:24,node:[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]};or.node;var sr=s(or),cr={name:`grip-vertical`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]};cr.node;var lr=s(cr),ur={name:`key-square`,size:24,node:[[`path`,{d:`M12.4 2.7a2.5 2.5 0 0 1 3.4 0l5.5 5.5a2.5 2.5 0 0 1 0 3.4l-3.7 3.7a2.5 2.5 0 0 1-3.4 0L8.7 9.8a2.5 2.5 0 0 1 0-3.4z`,key:`165ttr`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`m9.4 10.6-6.814 6.814A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814`,key:`1ubxi2`}]]};ur.node;var dr=s(ur),fr={name:`list-ordered`,size:24,node:[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]};fr.node;var pr=s(fr),mr={name:`monitor`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]};mr.node;var hr=s(mr),gr={name:`moon`,size:24,node:[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]};gr.node;var _r=s(gr),vr={name:`palette`,size:24,node:[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]};vr.node;var yr=s(vr),br={name:`pin`,size:24,node:[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]};br.node;var xr=s(br),Sr={name:`server`,size:24,node:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]};Sr.node;var Cr=s(Sr),wr={name:`settings`,size:24,node:[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};wr.node;var Tr=s(wr),Er={name:`shield-x`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m14.5 9.5-5 5`,key:`17q4r4`}],[`path`,{d:`m9.5 9.5 5 5`,key:`18nt4w`}]],aliases:[`shield-close`]};Er.node;var Dr=s(Er),Or={name:`sun`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]};Or.node;var kr=s(Or),Ar={name:`timer-reset`,size:24,node:[[`path`,{d:`M10 2h4`,key:`n1abiw`}],[`path`,{d:`M12 14v-4`,key:`1evpnu`}],[`path`,{d:`M4 13a8 8 0 0 1 8-7 8 8 0 1 1-5.3 14L4 17.6`,key:`1ts96g`}],[`path`,{d:`M9 17H4v5`,key:`8t5av`}]]};Ar.node;var jr=s(Ar),Mr={name:`timer`,size:24,node:[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]};Mr.node;var Nr=s(Mr),Pr={name:`workflow`,size:24,node:[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]};Pr.node;var Fr=s(Pr),Q=e(t(),1),$=n(),Ir=Object.defineProperty,Lr=(e,t)=>Ir(e,`name`,{value:t,configurable:!0}),Rr=`Collapsible`,[zr,Br]=ce(Rr),[Vr,Hr]=zr(Rr),Ur=Q.forwardRef(Lr(function(e,t){let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:o,...s}=e,[c,l]=fe({prop:r,defaultProp:i??!1,onChange:o,caller:Rr});return(0,$.jsx)(Vr,{scope:n,disabled:a,contentId:le(),open:c,onOpenToggle:Q.useCallback(()=>l(e=>!e),[l]),children:(0,$.jsx)(me.div,{"data-state":Yr(c),"data-disabled":a?``:void 0,...s,ref:t})})},`Collapsible`)),Wr=`CollapsibleTrigger`,Gr=Q.forwardRef(Lr(function(e,t){let{__scopeCollapsible:n,...r}=e,i=Hr(Wr,n);return(0,$.jsx)(me.button,{type:`button`,"aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open||!1,"data-state":Yr(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:ue(e.onClick,i.onOpenToggle)})},`CollapsibleTrigger`)),Kr=`CollapsibleContent`,qr=Q.forwardRef(Lr(function(e,t){let{forceMount:n,...r}=e,i=Hr(Kr,e.__scopeCollapsible);return(0,$.jsx)(pe,{present:n||i.open,children:({present:e})=>(0,$.jsx)(Jr,{...r,ref:t,present:e})})},`CollapsibleContent`)),Jr=Q.forwardRef(Lr(function(e,t){let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=Hr(Kr,n),[s,c]=Q.useState(r),l=Q.useRef(null),u=ge(t,l),d=Q.useRef(0),f=d.current,p=Q.useRef(0),m=p.current,h=o.open||s,g=Q.useRef(h),_=Q.useRef(void 0);return Q.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),de(()=>{let e=l.current;if(e){_.current=_.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();d.current=t.height,p.current=t.width,g.current||(e.style.transitionDuration=_.current.transitionDuration,e.style.animationName=_.current.animationName),c(r)}},[o.open,r]),(0,$.jsx)(me.div,{"data-state":Yr(o.open),"data-disabled":o.disabled?``:void 0,id:o.contentId,hidden:!h,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:h&&i})},`CollapsibleContentImpl`));function Yr(e){return e?`open`:`closed`}Lr(Yr,`getState`);var Xr=Object.defineProperty,Zr=(e,t)=>Xr(e,`name`,{value:t,configurable:!0}),Qr={Automatic:`automatic`,Manual:`manual`},$r=`Tabs`,[ei,ti]=ce($r,[Be]),ni=Be(),[ri,ii]=ei($r),ai=Q.forwardRef(Zr(function(e,t){let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=Qr.Automatic,...l}=e,u=m(s),[d,f]=fe({prop:r,onChange:i,defaultProp:a??``,caller:$r});return(0,$.jsx)(ri,{scope:n,baseId:le(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,$.jsx)(me.div,{dir:u,"data-orientation":o,...l,ref:t})})},`Tabs`)),oi=`TabsList`,si=Q.forwardRef(Zr(function(e,t){let{__scopeTabs:n,loop:r=!0,...i}=e,a=ii(oi,n),o=ni(n);return(0,$.jsx)(Fe,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,$.jsx)(me.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})},`TabsList`)),ci=`TabsTrigger`,li=Q.forwardRef(Zr(function(e,t){let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=ii(ci,n),s=ni(n),c=fi(o.baseId,r),l=pi(o.baseId,r),u=r===o.value;return(0,$.jsx)(Le,{asChild:!0,...s,focusable:!i,active:u,children:(0,$.jsx)(me.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:ue(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?(e.currentTarget.focus(),o.onValueChange(r)):e.preventDefault()}),onKeyDown:ue(e.onKeyDown,e=>{i||e.target!==e.currentTarget||[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:ue(e.onFocus,()=>{let e=o.activationMode!==Qr.Manual;!u&&!i&&e&&o.onValueChange(r)})})})},`TabsTrigger`)),ui=`TabsContent`,di=Q.forwardRef(Zr(function(e,t){let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=ii(ui,n),c=fi(s.baseId,r),l=pi(s.baseId,r),u=r===s.value,d=Q.useRef(u);return Q.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,$.jsx)(pe,{present:i||u,children:({present:n})=>(0,$.jsx)(me.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})},`TabsContent`));function fi(e,t){return`${e}-trigger-${t}`}Zr(fi,`makeTriggerId`);function pi(e,t){return`${e}-content-${t}`}Zr(pi,`makeContentId`);function mi({enabled:e,disabled:t=!1,onChange:n}){let{t:r}=k();return(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:r(`apiKeys.authToggle.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`apiKeys.authToggle.description`)})]}),(0,$.jsx)(R,{checked:e,disabled:t,onCheckedChange:n})]})}function hi({enabled:e,disabled:t=!1,onChange:n}){let{t:r}=k();return(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:r(`apiKeys.quotaPrivacy.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`apiKeys.quotaPrivacy.description`)})]}),(0,$.jsx)(R,{checked:e,disabled:t,onCheckedChange:n})]})}function gi(e,t,n){if(!e)return t;let r=ze(e,n);return`${r.date} ${r.time}`}var _i={total_tokens:`Tokens`,input_tokens:`Input`,output_tokens:`Output`,cost_usd:`Cost`,credits:`Credits`};function vi(e,t){return e.length===0?`-`:e.map(e=>{let n=t(`apiKeys.limitTypes.${e.limitType}`,{defaultValue:_i[e.limitType]}),r=e.limitType===`cost_usd`,i=e.limitType===`credits`;return`${n}: ${r?`$${(e.currentValue/1e6).toFixed(2)}`:He(e.currentValue)}/${r?`$${(e.maxValue/1e6).toFixed(2)}`:He(e.maxValue)} ${r?e.limitWindow:i?`${e.limitWindow}`:e.limitWindow}`}).join(` | `)}function yi(e,t,n,r,i){return i(`apiKeys.table.usageSummary`,{total:He(t),cached:He(n),requests:He(e),cost:Tt(r)})}function bi(e,t){return e.usageSummary?yi(e.usageSummary.requestCount,e.usageSummary.totalTokens,e.usageSummary.cachedInputTokens,e.usageSummary.totalCostUsd,t):t(`apiKeys.table.noUsage`)}function xi(e,t){return e.limits.length===0?t(`apiKeys.table.noLimit`):vi(e.limits,t)}function Si({keys:e,busy:t,onEdit:n,onDelete:r,onRegenerate:i}){let{t:a}=k(),o=gt(e=>e.dateDisplayFormat);return e.length===0?(0,$.jsx)(dn,{icon:ht,title:a(`apiKeys.table.empty`)}):(0,$.jsx)(`div`,{className:`overflow-x-auto rounded-xl border`,children:(0,$.jsxs)(hn,{className:`table-fixed`,children:[(0,$.jsx)(fn,{children:(0,$.jsxs)(mn,{children:[(0,$.jsx)(J,{className:`w-[20%] min-w-[12rem] pl-4 text-[11px] uppercase tracking-wider text-muted-foreground/80`,children:a(`apiKeys.table.name`)}),(0,$.jsx)(J,{className:`w-[10%] min-w-[8rem] text-[11px] uppercase tracking-wider text-muted-foreground/80`,children:a(`apiKeys.table.prefix`)}),(0,$.jsx)(J,{className:`w-[9%] min-w-[6.5rem] text-[11px] uppercase tracking-wider text-muted-foreground/80`,children:a(`apiKeys.table.models`)}),(0,$.jsx)(J,{className:`w-[9%] min-w-[6.5rem] text-[11px] uppercase tracking-wider text-muted-foreground/80`,children:a(`apiKeys.table.traffic`)}),(0,$.jsx)(J,{className:`w-[26%] min-w-[17rem] text-[11px] uppercase tracking-wider text-muted-foreground/80`,children:a(`apiKeys.table.usage`)}),(0,$.jsx)(J,{className:`w-[14%] min-w-[12rem] text-[11px] uppercase tracking-wider text-muted-foreground/80`,children:a(`apiKeys.table.limit`)}),(0,$.jsx)(J,{className:`w-[8%] min-w-[7rem] text-[11px] uppercase tracking-wider text-muted-foreground/80`,children:a(`apiKeys.table.expiry`)}),(0,$.jsx)(J,{className:`w-[7%] min-w-[5.5rem] text-[11px] uppercase tracking-wider text-muted-foreground/80`,children:a(`apiKeys.table.status`)}),(0,$.jsx)(J,{className:`w-[6%] min-w-[4.5rem] pr-4 text-right text-[11px] uppercase tracking-wider text-muted-foreground/80`,children:a(`apiKeys.table.actions`)})]})}),(0,$.jsx)(pn,{children:e.map(e=>{let s=e.allowedModels?.join(`, `)||a(`common.options.all`),c=e.trafficClass===`opportunistic`?a(`common.traffic.opportunistic`):a(`common.traffic.foreground`);return(0,$.jsxs)(mn,{children:[(0,$.jsx)(Y,{className:`pl-4 font-medium truncate`,children:e.name}),(0,$.jsx)(Y,{className:`truncate font-mono text-xs`,children:e.keyPrefix}),(0,$.jsx)(Y,{className:`truncate`,children:s}),(0,$.jsx)(Y,{className:`truncate text-xs tabular-nums`,children:c}),(0,$.jsx)(Y,{className:`text-xs tabular-nums leading-tight whitespace-normal`,children:bi(e,a)}),(0,$.jsx)(Y,{className:`text-xs tabular-nums leading-tight whitespace-normal`,children:xi(e,a)}),(0,$.jsx)(Y,{className:`truncate text-xs text-muted-foreground`,children:gi(e.expiresAt,a(`common.time.never`),o)}),(0,$.jsx)(Y,{children:(0,$.jsx)(K,{className:e.isActive?`bg-emerald-500 text-white`:`bg-zinc-500 text-white`,children:e.isActive?a(`common.states.active`):a(`common.states.disabled`)})}),(0,$.jsx)(Y,{className:`pr-4 text-right`,children:(0,$.jsxs)(Pe,{children:[(0,$.jsx)(We,{asChild:!0,children:(0,$.jsxs)(A,{type:`button`,size:`icon-sm`,variant:`ghost`,disabled:t,children:[(0,$.jsx)(O,{className:`size-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:a(`apiKeys.table.actions`)})]})}),(0,$.jsxs)(Ue,{align:`end`,children:[(0,$.jsxs)(Et,{onClick:()=>n(e),children:[(0,$.jsx)(re,{className:`size-4`}),a(`common.actions.edit`)]}),(0,$.jsxs)(Et,{onClick:()=>i(e),children:[(0,$.jsx)(nt,{className:`size-4`}),a(`common.actions.regenerate`)]}),(0,$.jsx)(Ve,{}),(0,$.jsxs)(Et,{variant:`destructive`,onClick:()=>r(e),children:[(0,$.jsx)(ie,{className:`size-4`}),a(`common.actions.delete`)]})]})]})})]},e.id)})})]})})}function Ci(){let{t:e}=k(),t=o(),{data:n,error:r,isFetching:s,isLoading:c,isPending:l,isSuccess:u,refetch:d}=i({queryKey:[`api-keys`,`list`],queryFn:rn});return{apiKeysQuery:{data:n,error:r,isFetching:s,isLoading:c,isPending:l,isSuccess:u,refetch:d},createMutation:a({mutationFn:e=>an(e),onSuccess:()=>{U.success(e(`apiKeys.toasts.created`)),t.invalidateQueries({queryKey:[`api-keys`,`list`]})},onError:t=>{U.error(t.message||e(`apiKeys.toasts.createFailed`))}}),updateMutation:a({mutationFn:({keyId:e,payload:t})=>cn(e,t),onSuccess:()=>{U.success(e(`apiKeys.toasts.updated`)),t.invalidateQueries({queryKey:[`api-keys`,`list`]})},onError:t=>{U.error(t.message||e(`apiKeys.toasts.updateFailed`))}}),deleteMutation:a({mutationFn:e=>sn(e),onSuccess:()=>{U.success(e(`apiKeys.toasts.deleted`)),t.invalidateQueries({queryKey:[`api-keys`,`list`]})},onError:t=>{U.error(t.message||e(`apiKeys.toasts.deleteFailed`))}}),regenerateMutation:a({mutationFn:e=>on(e),onSuccess:()=>{U.success(e(`apiKeys.toasts.regenerated`)),t.invalidateQueries({queryKey:[`api-keys`,`list`]})},onError:t=>{U.error(t.message||e(`apiKeys.toasts.regenerateFailed`))}})}}var wi=(0,Q.lazy)(()=>pt(()=>import(`./api-key-create-dialog-DnRm0oYN.js`).then(e=>({default:e.ApiKeyCreateDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]))),Ti=(0,Q.lazy)(()=>pt(()=>import(`./api-key-edit-dialog-Ck3Bnc3V.js`).then(e=>({default:e.ApiKeyEditDialog})),__vite__mapDeps([31,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30])));function Ei({apiKeyAuthEnabled:e,hideUpstreamQuotaFromApiKeys:t,disabled:n=!1,policyControlsDisabled:r=n,onApiKeyAuthEnabledChange:i,onHideUpstreamQuotaFromApiKeysChange:a}){let{t:o}=k(),{apiKeysQuery:s,createMutation:c,updateMutation:l,deleteMutation:u,regenerateMutation:d}=Ci(),f=G(),p=G(),m=G(),h=G(),g=s.data??[],_=n||s.isFetching||c.isPending||l.isPending||u.isPending||d.isPending,v=(0,Q.useMemo)(()=>V(c.error)||V(l.error)||V(u.error)||V(d.error),[c.error,u.error,d.error,l.error]);return(0,$.jsxs)(`section`,{className:`space-y-3 rounded-xl border bg-card p-5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(dr,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:o(`apiKeys.section.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`apiKeys.section.description`)})]})]}),(0,$.jsx)(A,{type:`button`,size:`sm`,className:`h-8 text-xs`,onClick:()=>f.show(),disabled:_,children:o(`apiKeys.section.createKey`)})]}),(0,$.jsx)(mi,{enabled:e,disabled:_||r,onChange:i}),(0,$.jsx)(hi,{enabled:t,disabled:_||r,onChange:a}),v?(0,$.jsx)(W,{variant:`error`,children:v}):null,(0,$.jsx)(Si,{keys:g,busy:_,onEdit:e=>p.show(e),onDelete:e=>m.show(e),onRegenerate:e=>{d.mutateAsync(e.id).then(e=>{h.show(e.key)})}}),(0,$.jsx)(wi,{open:f.open,busy:c.isPending,onOpenChange:f.onOpenChange,onSubmit:async e=>{let t=await c.mutateAsync(e);h.show(t.key)}}),(0,$.jsx)(Ti,{open:p.open,busy:l.isPending,apiKey:p.data,onOpenChange:p.onOpenChange,onSubmit:async e=>{p.data&&await l.mutateAsync({keyId:p.data.id,payload:e})}}),(0,$.jsx)(un,{open:h.open,apiKey:h.data,onOpenChange:h.onOpenChange}),(0,$.jsx)(en,{open:m.open,title:o(`apiKeys.deleteDialog.title`),description:o(`apiKeys.deleteDialog.description`),confirmLabel:o(`common.actions.delete`),onOpenChange:m.onOpenChange,onConfirm:()=>{m.data&&u.mutateAsync(m.data.id).finally(()=>{m.hide()})}})]})}var Di=I([`allow_all`,`allowlist_active`]),Oi=P({ipAddress:L().min(1),createdAt:h({offset:!0})}),ki=P({mode:Di,entries:M(Oi).default([])}),Ai=P({ipAddress:L().min(1)}),ji=P({status:L().min(1)}),Mi=`/api/firewall/ips`;function Ni(){return Ce(Mi,ki)}function Pi(e){let t=Ai.parse(e);return j(Mi,Oi,{body:t})}function Fi(e){return be(`${Mi}/${encodeURIComponent(e)}`,ji)}function Ii(){let{t:e}=k(),t=o(),{data:n,error:r,isFetching:s,isLoading:c,isPending:l,isSuccess:u,refetch:d}=i({queryKey:[`firewall`,`ips`],queryFn:Ni,refetchInterval:3e4,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0});return{firewallQuery:{data:n,error:r,isFetching:s,isLoading:c,isPending:l,isSuccess:u,refetch:d},createMutation:a({mutationFn:e=>Pi({ipAddress:e}),onSuccess:()=>{U.success(e(`firewall.toasts.added`)),t.invalidateQueries({queryKey:[`firewall`,`ips`]})},onError:t=>{U.error(t.message||e(`firewall.toasts.addFailed`))}}),deleteMutation:a({mutationFn:e=>Fi(e),onSuccess:()=>{U.success(e(`firewall.toasts.removed`)),t.invalidateQueries({queryKey:[`firewall`,`ips`]})},onError:t=>{U.error(t.message||e(`firewall.toasts.removeFailed`))}})}}function Li(e,t){return t(e===`allow_all`?`firewall.modes.allowAll`:`firewall.modes.allowlistActive`)}function Ri({disabled:e=!1}){let{t}=k(),n=gt(e=>e.dateDisplayFormat),[r,i]=(0,Q.useState)(``),{firewallQuery:a,createMutation:o,deleteMutation:s}=Ii(),c=G(),l=(0,Q.useMemo)(()=>V(a.error)||V(o.error)||V(s.error),[a.error,o.error,s.error]),u=a.data?.entries??[],d=a.data?.mode??`allow_all`,f=e||o.isPending||s.isPending,p=async()=>{let e=r.trim();e&&(await o.mutateAsync(e),i(``))};return(0,$.jsxs)(`section`,{id:`firewall`,className:`scroll-mt-16 space-y-3 rounded-xl border bg-card p-5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(ee,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`firewall.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`firewall.description`)})]})]}),l?(0,$.jsx)(W,{variant:`error`,children:l}):null,(0,$.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`firewall.mode`)}),(0,$.jsx)(K,{variant:`outline`,children:Li(d,t)})]}),(0,$.jsx)(`div`,{className:`h-4 w-px bg-border`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`firewall.allowedIps`)}),(0,$.jsx)(`span`,{className:`text-sm font-medium tabular-nums`,children:u.length})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(H,{value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&p()},placeholder:`127.0.0.1 or 2001:db8::1`,className:`h-8 text-xs`,disabled:f}),(0,$.jsx)(A,{type:`button`,size:`sm`,className:`h-8 text-xs`,onClick:()=>void p(),disabled:f||!r.trim(),children:t(`firewall.actions.addIp`)})]}),a.isLoading&&!a.data?(0,$.jsx)(`div`,{className:`py-8`,children:(0,$.jsx)(Ft,{})}):u.length===0?(0,$.jsx)(dn,{icon:ee,title:t(`firewall.empty.title`),description:t(`firewall.empty.description`)}):(0,$.jsx)(`div`,{className:`overflow-x-auto rounded-xl border`,children:(0,$.jsxs)(hn,{children:[(0,$.jsx)(fn,{children:(0,$.jsxs)(mn,{children:[(0,$.jsx)(J,{children:t(`firewall.table.ipAddress`)}),(0,$.jsx)(J,{children:t(`firewall.table.created`)}),(0,$.jsx)(J,{className:`w-[96px] text-right`,children:t(`apiKeys.table.actions`)})]})}),(0,$.jsx)(pn,{children:u.map(e=>{let r=ze(e.createdAt,n);return(0,$.jsxs)(mn,{children:[(0,$.jsx)(Y,{className:`font-mono text-xs`,children:e.ipAddress}),(0,$.jsxs)(Y,{className:`text-xs text-muted-foreground`,children:[r.date,` `,r.time]}),(0,$.jsx)(Y,{className:`text-right`,children:(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`ghost`,className:`text-destructive hover:text-destructive`,disabled:f,onClick:()=>c.show(e.ipAddress),children:t(`common.actions.remove`)})})]},e.ipAddress)})})]})}),(0,$.jsx)(en,{open:c.open,title:t(`firewall.removeDialog.title`),description:t(`firewall.removeDialog.description`,{ip:c.data??``}),confirmLabel:t(`common.actions.remove`),onOpenChange:c.onOpenChange,onConfirm:()=>{c.data&&s.mutateAsync(c.data).finally(()=>{c.hide()})}})]})}function zi(e){return P({name:L().min(1,e(`modelSources.validation.nameRequired`)),baseUrl:L().min(1,e(`modelSources.validation.baseUrlRequired`)),apiKey:L(),models:L().min(1,e(`modelSources.validation.modelsRequired`))})}P({name:L().min(1,`Name is required`),baseUrl:L().min(1,`Base URL is required`),apiKey:L(),models:L().min(1,`At least one model is required`)});var Bi={supportsChatCompletions:!0,supportsResponses:!1,supportsAudioTranscriptions:!1,supportsEmbeddings:!1,supportsStreaming:!0,supportsTools:!1,supportsVision:!1,supportsReasoning:!1,reasoningEffortsInput:``,reasoningEfforts:[],defaultReasoningEffort:``,contextWindow:``,maxOutputTokens:``,inputPer1M:``,cachedInputPer1M:``,outputPer1M:``,audioPerMinute:``};function Vi(e,t){return{...e,...t}}function Hi(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);return Number.isFinite(n)&&n>0?n:void 0}function Ui(e){let t=e.trim();if(!t)return;let n=Number.parseFloat(t);return Number.isFinite(n)&&n>=0?n:void 0}var Wi=[`low`,`medium`,`high`];function Gi(e){return e.trim()}function Ki(e){let t=new Set,n=[];for(let r of e){let e=Gi(r);e&&!t.has(e)&&(t.add(e),n.push(e))}return n}function qi(e){return Ki(e.split(/[\n,]/))}function Ji(e,t){let n=Gi(t);return n&&e.includes(n)?n:e[0]??``}function Yi(e,t,n=[],r=``){let i={};if(e)try{let t=JSON.parse(e);t&&typeof t==`object`&&!Array.isArray(t)&&(i=t)}catch{i={}}return t?(i.supports_reasoning=!0,n.length>0?(i.supported_reasoning_levels=n,i.default_reasoning_level=Ji(n,r)):(delete i.supported_reasoning_levels,delete i.default_reasoning_level)):(delete i.supports_reasoning,delete i.supported_reasoning_levels,delete i.default_reasoning_level),Object.keys(i).length>0?JSON.stringify(i):null}function Xi(e,t,n={},r={}){let i=Hi(t.contextWindow),a=Hi(t.maxOutputTokens),o=Ui(t.inputPer1M),s=Ui(t.cachedInputPer1M),c=Ui(t.outputPer1M),l=Ui(t.audioPerMinute);return e.models.split(/[\n,]/).map(e=>e.trim()).filter(Boolean).map(e=>({model:e,displayName:e,contextWindow:i,maxOutputTokens:a,supportsStreaming:t.supportsStreaming,supportsTools:t.supportsTools,supportsVision:t.supportsVision,inputPer1M:o??null,cachedInputPer1M:s??null,outputPer1M:c??null,audioPerMinute:l??null,rawMetadataJson:Yi(n[e],t.supportsReasoning,t.reasoningEfforts,t.defaultReasoningEffort),isEnabled:r[e]??!0}))}function Zi(e){return e==null?``:String(e)}function Qi(e){let t={supportsReasoning:!1,reasoningEffortsInput:``,reasoningEfforts:[],defaultReasoningEffort:``};if(!e)return t;try{let n=JSON.parse(e);if(typeof n!=`object`||!n||Array.isArray(n))return t;let r=n,i=r.supports_reasoning===!0,a=Array.isArray(r.supported_reasoning_levels)?Ki(r.supported_reasoning_levels.flatMap(e=>{if(typeof e==`string`)return[e];if(typeof e!=`object`||!e||Array.isArray(e))return[];let t=e.effort;return typeof t==`string`?[t]:[]})):[],o=i&&a.length===0?Wi:a;return{supportsReasoning:i,reasoningEffortsInput:o.join(`, `),reasoningEfforts:o,defaultReasoningEffort:Ji(o,typeof r.default_reasoning_level==`string`?r.default_reasoning_level:``)}}catch{return t}}function $i(e){let t=e.models[0],n=Qi(t?.rawMetadataJson);return{supportsChatCompletions:e.supportsChatCompletions,supportsResponses:e.supportsResponses,supportsAudioTranscriptions:e.supportsAudioTranscriptions,supportsEmbeddings:e.supportsEmbeddings,supportsStreaming:t?.supportsStreaming??!0,supportsTools:t?.supportsTools??!1,supportsVision:t?.supportsVision??!1,supportsReasoning:n.supportsReasoning,reasoningEffortsInput:n.reasoningEffortsInput,reasoningEfforts:n.reasoningEfforts,defaultReasoningEffort:n.defaultReasoningEffort,contextWindow:Zi(t?.contextWindow),maxOutputTokens:Zi(t?.maxOutputTokens),inputPer1M:Zi(t?.inputPer1M),cachedInputPer1M:Zi(t?.cachedInputPer1M),outputPer1M:Zi(t?.outputPer1M),audioPerMinute:Zi(t?.audioPerMinute)}}function ea(e){return e.models.map(e=>e.model).join(`, `)}var ta=[[`supportsChatCompletions`,`modelSources.capabilities.chatCompletions`],[`supportsResponses`,`modelSources.capabilities.responses`],[`supportsAudioTranscriptions`,`modelSources.capabilities.audioTranscriptions`],[`supportsEmbeddings`,`modelSources.capabilities.embeddings`],[`supportsStreaming`,`modelSources.capabilities.streaming`],[`supportsTools`,`modelSources.capabilities.tools`],[`supportsVision`,`modelSources.capabilities.vision`],[`supportsReasoning`,`modelSources.capabilities.reasoning`]],na=[`low`,`medium`,`high`];function ra({control:e,draft:t,updateDraft:n,apiKeyLabel:r,apiKeyPlaceholder:i}){let{t:a}=k();return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsx)(et,{control:e,name:`name`,render:({field:e})=>(0,$.jsxs)(rt,{children:[(0,$.jsx)(Ge,{children:a(`apiKeys.table.name`)}),(0,$.jsx)(Re,{children:(0,$.jsx)(H,{...e,autoComplete:`off`})}),(0,$.jsx)(je,{})]})}),(0,$.jsx)(et,{control:e,name:`baseUrl`,render:({field:e})=>(0,$.jsxs)(rt,{children:[(0,$.jsx)(Ge,{children:a(`modelSources.fields.baseUrl`)}),(0,$.jsx)(Re,{children:(0,$.jsx)(H,{...e,placeholder:`https://api.example.com/v1`,autoComplete:`off`})}),(0,$.jsx)(je,{})]})})]}),(0,$.jsx)(et,{control:e,name:`apiKey`,render:({field:e})=>(0,$.jsxs)(rt,{children:[(0,$.jsx)(Ge,{children:r}),(0,$.jsx)(Re,{children:(0,$.jsx)(H,{...e,type:`password`,autoComplete:`new-password`,placeholder:i})}),(0,$.jsx)(je,{})]})}),(0,$.jsx)(et,{control:e,name:`models`,render:({field:e})=>(0,$.jsxs)(rt,{children:[(0,$.jsx)(Ge,{children:a(`apiKeys.table.models`)}),(0,$.jsx)(Re,{children:(0,$.jsx)(H,{...e,placeholder:`deepseek-v4-flash, local-coder`,autoComplete:`off`})}),(0,$.jsx)(je,{})]})}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium`,children:a(`modelSources.fields.contextWindow`)}),(0,$.jsx)(H,{value:t.contextWindow,onChange:e=>n({contextWindow:e.target.value}),placeholder:`e.g. 32768`,inputMode:`numeric`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium`,children:a(`modelSources.fields.maxOutputTokens`)}),(0,$.jsx)(H,{value:t.maxOutputTokens,onChange:e=>n({maxOutputTokens:e.target.value}),placeholder:`e.g. 4096`,inputMode:`numeric`})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium`,children:a(`modelSources.fields.pricing`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`modelSources.fields.pricingDescription`)}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:a(`common.units.input`)}),(0,$.jsx)(H,{value:t.inputPer1M,onChange:e=>n({inputPer1M:e.target.value}),placeholder:`0.00`,inputMode:`decimal`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:a(`common.units.cached`)}),(0,$.jsx)(H,{value:t.cachedInputPer1M,onChange:e=>n({cachedInputPer1M:e.target.value}),placeholder:`0.00`,inputMode:`decimal`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:a(`common.units.output`)}),(0,$.jsx)(H,{value:t.outputPer1M,onChange:e=>n({outputPer1M:e.target.value}),placeholder:`0.00`,inputMode:`decimal`})]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium`,children:a(`modelSources.fields.audioPricing`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`modelSources.fields.audioPricingDescription`)}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:a(`modelSources.fields.perMinute`)}),(0,$.jsx)(H,{value:t.audioPerMinute,onChange:e=>n({audioPerMinute:e.target.value}),placeholder:`0.00`,inputMode:`decimal`})]})})]}),(0,$.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:ta.map(([e,r])=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md border p-2 text-sm`,children:[(0,$.jsx)(Te,{checked:t[e],onCheckedChange:r=>n({[e]:r===!0,...e===`supportsReasoning`&&r===!0?{reasoningEffortsInput:t.reasoningEffortsInput||na.join(`, `),reasoningEfforts:t.reasoningEfforts.length>0?t.reasoningEfforts:na,defaultReasoningEffort:t.defaultReasoningEffort||`medium`}:{}})}),a(r)]},e))}),t.supportsReasoning?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-md border p-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium`,children:a(`modelSources.fields.reasoningEfforts`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`modelSources.fields.reasoningEffortsDescription`)})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`text-xs text-muted-foreground`,htmlFor:`model-source-reasoning-efforts`,children:a(`modelSources.fields.reasoningEfforts`)}),(0,$.jsx)(H,{id:`model-source-reasoning-efforts`,"aria-label":a(`modelSources.fields.reasoningEfforts`),value:t.reasoningEffortsInput,onChange:e=>{let r=e.target.value,i=qi(r);n({reasoningEffortsInput:r,reasoningEfforts:i,defaultReasoningEffort:i.includes(t.defaultReasoningEffort)?t.defaultReasoningEffort:i[0]??``})},placeholder:a(`modelSources.fields.reasoningEffortsPlaceholder`),autoComplete:`off`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`text-xs text-muted-foreground`,htmlFor:`model-source-default-reasoning-effort`,children:a(`modelSources.fields.defaultReasoningEffort`)}),(0,$.jsxs)(x,{value:t.defaultReasoningEffort,onValueChange:e=>n({defaultReasoningEffort:e}),disabled:t.reasoningEfforts.length===0,children:[(0,$.jsx)(y,{id:`model-source-default-reasoning-effort`,"aria-label":a(`modelSources.fields.defaultReasoningEffort`),className:`w-full`,children:(0,$.jsx)(b,{})}),(0,$.jsx)(v,{children:t.reasoningEfforts.map(e=>(0,$.jsx)(_,{value:e,children:e},e))})]})]})]}):null]})}function ia({open:e,busy:t,onOpenChange:n,onSubmit:r}){let{t:i}=k(),a=Wt({resolver:Ot(zi(i)),defaultValues:{name:``,baseUrl:``,apiKey:``,models:``}}),[o,s]=(0,Q.useReducer)(Vi,Bi),c=async e=>{await r({name:e.name,baseUrl:e.baseUrl,apiKey:e.apiKey.trim()?e.apiKey.trim():void 0,supportsChatCompletions:o.supportsChatCompletions,supportsResponses:o.supportsResponses,supportsAudioTranscriptions:o.supportsAudioTranscriptions,supportsEmbeddings:o.supportsEmbeddings,models:Xi(e,o)}),n(!1)};return(0,$.jsx)(mt,{open:e,onOpenChange:n,children:(0,$.jsxs)(Ht,{className:`flex max-h-[calc(100dvh-2rem)] flex-col gap-0 overflow-clip p-0 sm:max-w-2xl`,children:[(0,$.jsxs)(wt,{className:`shrink-0 px-6 pt-6 pr-12 pb-2`,children:[(0,$.jsx)(ot,{children:i(`modelSources.createDialog.title`)}),(0,$.jsx)(At,{children:i(`modelSources.createDialog.description`)})]}),(0,$.jsx)(It,{...a,children:(0,$.jsxs)(`form`,{onSubmit:a.handleSubmit(c),className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsx)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto overscroll-contain px-6 pb-4`,"data-testid":`model-source-create-scroll-region`,children:(0,$.jsx)(ra,{control:a.control,draft:o,updateDraft:s,apiKeyLabel:i(`modelSources.fields.upstreamApiKey`)})}),(0,$.jsx)(Rt,{className:`shrink-0 border-t px-6 py-4`,children:(0,$.jsx)(A,{type:`submit`,disabled:t||a.formState.isSubmitting,children:i(`common.actions.create`)})})]})})]})})}function aa(e){let t=e.trim();if(!t)return null;let n=Number.parseInt(t,10);return Number.isFinite(n)&&n>0?n:null}function oa(e){let t=e.trim();if(!t)return null;let n=Number.parseFloat(t);return Number.isFinite(n)&&n>=0?n:null}function sa(e){return e.split(/[\n,]/).map(e=>e.trim()).filter(Boolean)}function ca(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function la(e,t){return{contextWindow:e.contextWindow!==t.contextWindow,maxOutputTokens:e.maxOutputTokens!==t.maxOutputTokens,inputPer1M:e.inputPer1M!==t.inputPer1M,cachedInputPer1M:e.cachedInputPer1M!==t.cachedInputPer1M,outputPer1M:e.outputPer1M!==t.outputPer1M,audioPerMinute:e.audioPerMinute!==t.audioPerMinute,supportsStreaming:e.supportsStreaming!==t.supportsStreaming,supportsTools:e.supportsTools!==t.supportsTools,supportsVision:e.supportsVision!==t.supportsVision,supportsReasoning:e.supportsReasoning!==t.supportsReasoning||JSON.stringify(e.reasoningEfforts)!==JSON.stringify(t.reasoningEfforts)||e.defaultReasoningEffort!==t.defaultReasoningEffort}}function ua(e){return Object.values(e).some(Boolean)}function da(e,t,n,r){return e.map(e=>{let i=r.get(e);return{model:e,displayName:i?.displayName??e,contextWindow:n.contextWindow?aa(t.contextWindow):i?.contextWindow??null,maxOutputTokens:n.maxOutputTokens?aa(t.maxOutputTokens):i?.maxOutputTokens??null,supportsStreaming:n.supportsStreaming?t.supportsStreaming:i?.supportsStreaming??!0,supportsTools:n.supportsTools?t.supportsTools:i?.supportsTools??!1,supportsVision:n.supportsVision?t.supportsVision:i?.supportsVision??!1,inputPer1M:n.inputPer1M?oa(t.inputPer1M):i?.inputPer1M??null,cachedInputPer1M:n.cachedInputPer1M?oa(t.cachedInputPer1M):i?.cachedInputPer1M??null,outputPer1M:n.outputPer1M?oa(t.outputPer1M):i?.outputPer1M??null,audioPerMinute:n.audioPerMinute?oa(t.audioPerMinute):i?.audioPerMinute??null,rawMetadataJson:n.supportsReasoning?Yi(i?.rawMetadataJson,t.supportsReasoning,t.reasoningEfforts,t.defaultReasoningEffort):i?.rawMetadataJson??null,isEnabled:i?.isEnabled??!0}})}function fa({source:e,busy:t,onSubmit:n,onClose:r}){let{t:i}=k(),a=Wt({resolver:Ot(zi(i)),defaultValues:{name:e.name,baseUrl:e.baseUrl,apiKey:``,models:ea(e)}}),[o,s]=(0,Q.useReducer)(Vi,e,$i),c=async t=>{let i=$i(e),a=la(o,i),s=e.models.map(e=>e.model),c=sa(t.models),l=!ca(c,s),u={name:t.name,baseUrl:t.baseUrl,supportsChatCompletions:o.supportsChatCompletions,supportsResponses:o.supportsResponses,supportsAudioTranscriptions:o.supportsAudioTranscriptions,supportsEmbeddings:o.supportsEmbeddings};if(l||ua(a)){let t=new Map(e.models.map(e=>[e.model,e]));u.models=da(c,o,a,t)}let d=t.apiKey.trim();d&&(u.apiKey=d);try{await n(e.id,u)}catch{return}r()};return(0,$.jsx)(It,{...a,children:(0,$.jsxs)(`form`,{onSubmit:a.handleSubmit(c),className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsx)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto overscroll-contain px-6 pb-4`,"data-testid":`model-source-edit-scroll-region`,children:(0,$.jsx)(ra,{control:a.control,draft:o,updateDraft:s,apiKeyLabel:i(`modelSources.fields.upstreamApiKey`),apiKeyPlaceholder:i(`modelSources.editDialog.keepCurrentKey`)})}),(0,$.jsx)(Rt,{className:`shrink-0 border-t px-6 py-4`,children:(0,$.jsx)(A,{type:`submit`,disabled:t||a.formState.isSubmitting,children:i(`common.actions.save`)})})]})})}function pa({open:e,busy:t,source:n,onOpenChange:r,onSubmit:i}){let{t:a}=k();return(0,$.jsx)(mt,{open:e,onOpenChange:r,children:(0,$.jsxs)(Ht,{className:`flex max-h-[calc(100dvh-2rem)] flex-col gap-0 overflow-clip p-0 sm:max-w-2xl`,children:[(0,$.jsxs)(wt,{className:`shrink-0 px-6 pt-6 pr-12 pb-2`,children:[(0,$.jsx)(ot,{children:a(`modelSources.editDialog.title`)}),(0,$.jsx)(At,{children:a(`modelSources.editDialog.description`)})]}),n?(0,$.jsx)(fa,{source:n,busy:t,onSubmit:i,onClose:()=>r(!1)},`${n.id}:${e?`open`:`closed`}`):(0,$.jsx)(`p`,{className:`px-6 pb-6 text-sm text-muted-foreground`,children:a(`modelSources.editDialog.selectSource`)})]})})}function ma(e){let t=e.models.find(e=>e.inputPer1M!==null||e.outputPer1M!==null);return t?`$${t.inputPer1M??0}/$${t.outputPer1M??0} per 1M`:null}function ha(e){return[e.supportsChatCompletions?`chat`:null,e.supportsResponses?`responses`:null,e.supportsAudioTranscriptions?`audio`:null,e.supportsEmbeddings?`embeddings`:null].filter(e=>e!==null)}function ga({disabled:e=!1}){let{t}=k(),{modelSourcesQuery:n,createMutation:r,updateMutation:i,deleteMutation:a}=ln(),o=G(),s=G(),c=G(),l=n.data?.sources??[],u=e||n.isFetching||r.isPending||i.isPending||a.isPending,d=V(n.error)||V(r.error)||V(i.error)||V(a.error);return(0,$.jsxs)(`section`,{className:`space-y-4 rounded-xl border bg-card p-5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(rr,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`modelSources.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`modelSources.description`)})]})]}),(0,$.jsxs)(A,{type:`button`,size:`sm`,className:`h-8 gap-1.5 text-xs`,disabled:u,onClick:()=>o.show(),children:[(0,$.jsx)(ne,{className:`h-3.5 w-3.5`}),t(`modelSources.actions.addSource`)]})]}),d?(0,$.jsx)(W,{variant:`error`,children:d}):null,(0,$.jsx)(`div`,{className:`space-y-2`,children:l.length>0?l.map(e=>(0,$.jsx)(`div`,{className:`rounded-lg border p-3`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,$.jsx)(K,{variant:e.isEnabled?`default`:`secondary`,children:e.isEnabled?t(`common.states.enabled`):t(`common.states.disabled`)}),ha(e).map(e=>(0,$.jsx)(K,{variant:`secondary`,children:e},e))]}),(0,$.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.baseUrl}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pt-1`,children:[e.models.map(e=>(0,$.jsx)(K,{variant:e.isEnabled?`outline`:`secondary`,children:e.model},e.id)),ma(e)?(0,$.jsx)(K,{variant:`secondary`,children:ma(e)}):null]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,$.jsx)(R,{"aria-label":t(`modelSources.actions.toggleAria`,{name:e.name}),checked:e.isEnabled,disabled:u,onCheckedChange:t=>void i.mutateAsync({sourceId:e.id,payload:{isEnabled:t}})}),(0,$.jsxs)(A,{type:`button`,size:`icon-sm`,variant:`ghost`,disabled:u,onClick:()=>s.show(e),children:[(0,$.jsx)(re,{className:`size-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:t(`modelSources.actions.editAria`,{name:e.name})})]}),(0,$.jsxs)(A,{type:`button`,size:`icon-sm`,variant:`ghost`,disabled:u,onClick:()=>c.show(e),children:[(0,$.jsx)(ie,{className:`size-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:t(`modelSources.actions.deleteAria`,{name:e.name})})]})]})]})},e.id)):(0,$.jsx)(`div`,{className:`rounded-lg border border-dashed p-4 text-sm text-muted-foreground`,children:t(`modelSources.empty`)})}),(0,$.jsx)(ia,{open:o.open,busy:r.isPending,onOpenChange:o.onOpenChange,onSubmit:async e=>{await r.mutateAsync(e)}}),(0,$.jsx)(pa,{open:s.open,busy:i.isPending,source:s.data,onOpenChange:s.onOpenChange,onSubmit:async(e,t)=>{await i.mutateAsync({sourceId:e,payload:t})}}),(0,$.jsx)(en,{open:c.open,title:t(`modelSources.deleteDialog.title`),description:t(`modelSources.deleteDialog.description`),confirmLabel:t(`common.actions.delete`),onOpenChange:c.onOpenChange,onConfirm:()=>{c.data&&a.mutateAsync(c.data.id).finally(()=>c.hide())}})]})}var _a=I([`off`,`shadow`,`suggest`,`auto`]),va=I([`p50`,`p75`,`p90`]),ya=P({mode:_a,timezone:L(),workingDays:M(F().int().min(0).max(6)),workingHoursStart:L(),workingHoursEnd:L(),prewarmEnabled:N(),prewarmLeadMinutes:F().int().min(0).max(1440),maxWarmupsPerDay:F().int().min(0),maxWarmupCreditsPerDay:F().min(0),minExpectedGain:F().min(0),forecastQuantile:va,allowSyntheticTraffic:N(),warmupModelPreference:L().nullable(),dryRun:N()}),ba=ya.partial(),xa=P({id:L(),createdAt:L(),mode:_a,accountId:L().nullable(),action:L(),scheduledAt:L().nullable(),executedAt:L().nullable(),score:F(),reason:L().nullable(),details:ve(L(),_e()).nullable().optional(),status:L(),idempotencyKey:L()}),Sa=P({slotStart:L(),demandUnits:F(),requestCount:F(),source:L()}),Ca=P({loss:F(),unmetDemand:F(),wastedCapacity:F(),coldStartPenalty:F(),synchronizationPenalty:F(),forecastUnits:F(),servedUnits:F()}),wa=P({generatedAt:L(),horizonHours:F().int(),slotSeconds:F().int(),totalDemandUnits:F(),peakSlotStart:L().nullable(),peakDemandUnits:F(),simulation:Ca,slots:M(Sa)}),Ta=P({accountId:L().min(1),model:L().nullable().optional(),apiKeyId:L().nullable().optional(),forceProbe:N().optional()}),Ea=P({decisionId:L(),status:L(),reason:L(),requestId:L().nullable(),executedAt:L().nullable()}),Da=`/api/quota-planner`;function Oa(){return Ce(`${Da}/settings`,ya)}function ka(e){let t=ba.parse(e);return xe(`${Da}/settings`,ya,{body:t})}function Aa(e=20){let t=new URLSearchParams({limit:String(e)});return Ce(`${Da}/decisions?${t.toString()}`,M(xa))}function ja(e=36){let t=new URLSearchParams({horizonHours:String(e)});return Ce(`${Da}/forecast?${t.toString()}`,wa)}function Ma(e){let t=Ta.parse(e);return j(`${Da}/warm-now`,Ea,{body:t})}function Na(e){return j(`${Da}/decisions/${encodeURIComponent(e)}/cancel`,Ea)}function Pa(){let{t:e}=k(),t=o(),{data:n,error:r,isFetching:s,isLoading:c,isPending:l,isSuccess:u,refetch:d}=i({queryKey:[`quota-planner`,`settings`],queryFn:Oa,refetchOnWindowFocus:!0}),f={data:n,error:r,isFetching:s,isLoading:c,isPending:l,isSuccess:u,refetch:d},{data:p,error:m,isFetching:h,isLoading:g,isPending:_,isSuccess:v,refetch:y}=i({queryKey:[`quota-planner`,`decisions`],queryFn:()=>Aa(20),refetchInterval:3e4,refetchIntervalInBackground:!1}),b={data:p,error:m,isFetching:h,isLoading:g,isPending:_,isSuccess:v,refetch:y},{data:x,error:S,isFetching:C,isLoading:w,isPending:T,isSuccess:E,refetch:ee}=i({queryKey:[`quota-planner`,`forecast`],queryFn:()=>ja(36),refetchInterval:6e4,refetchIntervalInBackground:!1});return{settingsQuery:f,decisionsQuery:b,forecastQuery:{data:x,error:S,isFetching:C,isLoading:w,isPending:T,isSuccess:E,refetch:ee},updateSettingsMutation:a({mutationFn:e=>ka(e),onSuccess:async()=>{U.success(e(`quotaPlanner.toasts.saved`)),await Promise.all([t.invalidateQueries({queryKey:[`quota-planner`,`settings`]}),t.invalidateQueries({queryKey:[`quota-planner`,`forecast`]}),t.invalidateQueries({queryKey:[`quota-planner`,`decisions`]})])},onError:t=>{U.error(t.message||e(`quotaPlanner.toasts.saveFailed`))}}),warmNowMutation:a({mutationFn:e=>Ma(e),onSuccess:async n=>{U.success(e(`quotaPlanner.toasts.warmupResult`,{status:n.status,reason:n.reason})),await Promise.all([t.invalidateQueries({queryKey:[`quota-planner`,`decisions`]}),t.invalidateQueries({queryKey:[`quota-planner`,`forecast`]})])},onError:t=>{U.error(t.message||e(`quotaPlanner.toasts.warmupFailed`))}}),cancelDecisionMutation:a({mutationFn:e=>Na(e),onSuccess:async()=>{U.success(e(`quotaPlanner.toasts.canceled`)),await t.invalidateQueries({queryKey:[`quota-planner`,`decisions`]})},onError:t=>{U.error(t.message||e(`quotaPlanner.toasts.cancelFailed`))}})}}var Fa=[{value:0,label:`Mon`},{value:1,label:`Tue`},{value:2,label:`Wed`},{value:3,label:`Thu`},{value:4,label:`Fri`},{value:5,label:`Sat`},{value:6,label:`Sun`}];function Ia(e){return e.toLocaleString(void 0,{maximumFractionDigits:1})}function La(e,t){let n=ze(e,t);return`${n.date} ${n.time}`}function Ra(e,t){let n=e?.[t];return n==null||n===``?null:typeof n==`number`?Ia(n):String(n)}function za(e){return{...e,workingDays:[...e.workingDays]}}function Ba({disabled:e=!1}){let{t}=k(),n=gt(e=>e.dateDisplayFormat),{settingsQuery:r,decisionsQuery:i,forecastQuery:a,updateSettingsMutation:o,warmNowMutation:s,cancelDecisionMutation:l}=Pa(),u=r.data,[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(!1),S=d??(u?za(u):null),C=(0,Q.useMemo)(()=>V(r.error)||V(i.error)||V(a.error)||V(o.error)||V(s.error)||V(l.error),[r.error,i.error,a.error,o.error,s.error,l.error]),w=o.isPending||e,T=s.isPending||e,E=l.isPending||e,ee=u&&S?JSON.stringify(u)!==JSON.stringify(S):!1,D=a.data,te=i.data??[],O=e=>{f(t=>{let n=t??(u?za(u):null);return n?{...n,...e}:null})},ne=(e,t)=>{f(n=>{let r=n??(u?za(u):null);if(!r)return null;let i=t?Array.from(new Set([...r.workingDays,e])).toSorted((e,t)=>e-t):r.workingDays.filter(t=>t!==e);return{...r,workingDays:i.length>0?i:r.workingDays}})};return(0,$.jsxs)(`section`,{className:`space-y-3 rounded-xl border bg-card p-5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(tr,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`quotaPlanner.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`quotaPlanner.description`)})]})]}),C?(0,$.jsx)(W,{variant:`error`,children:C}):null,S?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-[1.2fr_0.8fr]`,children:[(0,$.jsxs)(`div`,{className:`divide-y rounded-lg border`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 p-3 sm:grid-cols-3`,children:[(0,$.jsxs)(`label`,{htmlFor:`quota-planner-mode`,className:`space-y-1 text-xs font-medium`,children:[t(`quotaPlanner.fields.mode`),(0,$.jsxs)(x,{value:S.mode,onValueChange:e=>O({mode:e}),children:[(0,$.jsx)(y,{id:`quota-planner-mode`,className:`h-8 text-xs`,disabled:w,children:(0,$.jsx)(b,{})}),(0,$.jsxs)(v,{children:[(0,$.jsx)(_,{value:`shadow`,children:t(`quotaPlanner.modes.shadow`)}),(0,$.jsx)(_,{value:`suggest`,children:t(`quotaPlanner.modes.suggest`)}),(0,$.jsx)(_,{value:`auto`,children:t(`quotaPlanner.modes.auto`)}),(0,$.jsx)(_,{value:`off`,children:t(`quotaPlanner.modes.off`)})]})]})]}),(0,$.jsxs)(`label`,{htmlFor:`quota-planner-timezone`,className:`space-y-1 text-xs font-medium`,children:[t(`quotaPlanner.fields.timezone`),(0,$.jsx)(H,{id:`quota-planner-timezone`,className:`h-8 text-xs`,value:S.timezone,disabled:w,onChange:e=>O({timezone:e.target.value})})]}),(0,$.jsxs)(`label`,{htmlFor:`quota-planner-forecast`,className:`space-y-1 text-xs font-medium`,children:[t(`quotaPlanner.fields.forecast`),(0,$.jsxs)(x,{value:S.forecastQuantile,onValueChange:e=>O({forecastQuantile:e}),children:[(0,$.jsx)(y,{id:`quota-planner-forecast`,className:`h-8 text-xs`,disabled:w,children:(0,$.jsx)(b,{})}),(0,$.jsxs)(v,{children:[(0,$.jsx)(_,{value:`p50`,children:`P50`}),(0,$.jsx)(_,{value:`p75`,children:`P75`}),(0,$.jsx)(_,{value:`p90`,children:`P90`})]})]})]})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 p-3 sm:grid-cols-4`,children:[(0,$.jsxs)(`label`,{htmlFor:`quota-planner-work-start`,className:`space-y-1 text-xs font-medium`,children:[t(`quotaPlanner.fields.workStart`),(0,$.jsx)(H,{id:`quota-planner-work-start`,className:`h-8 text-xs`,type:`time`,value:S.workingHoursStart,disabled:w,onChange:e=>O({workingHoursStart:e.target.value})})]}),(0,$.jsxs)(`label`,{htmlFor:`quota-planner-work-end`,className:`space-y-1 text-xs font-medium`,children:[t(`quotaPlanner.fields.workEnd`),(0,$.jsx)(H,{id:`quota-planner-work-end`,className:`h-8 text-xs`,type:`time`,value:S.workingHoursEnd,disabled:w,onChange:e=>O({workingHoursEnd:e.target.value})})]}),(0,$.jsxs)(`label`,{htmlFor:`quota-planner-lead-minutes`,className:`space-y-1 text-xs font-medium`,children:[t(`quotaPlanner.fields.leadMinutes`),(0,$.jsx)(H,{id:`quota-planner-lead-minutes`,className:`h-8 text-xs`,type:`number`,min:0,max:1440,value:S.prewarmLeadMinutes,disabled:w,onChange:e=>O({prewarmLeadMinutes:Number.parseInt(e.target.value||`0`,10)})})]}),(0,$.jsxs)(`label`,{htmlFor:`quota-planner-max-decisions`,className:`space-y-1 text-xs font-medium`,children:[t(`quotaPlanner.fields.maxDecisions`),(0,$.jsx)(H,{id:`quota-planner-max-decisions`,className:`h-8 text-xs`,type:`number`,min:0,value:S.maxWarmupsPerDay,disabled:w,onChange:e=>O({maxWarmupsPerDay:Number.parseInt(e.target.value||`0`,10)})})]})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2 p-3`,children:Fa.map(e=>(0,$.jsxs)(`label`,{className:`flex h-8 items-center gap-2 rounded-md border px-2 text-xs font-medium`,children:[(0,$.jsx)(Te,{checked:S.workingDays.includes(e.value),disabled:w,onCheckedChange:t=>ne(e.value,t===!0)}),t(`settings.routing.workingDays.days.${e.label.toLowerCase()}`,{defaultValue:e.label})]},e.value))}),(0,$.jsxs)(`div`,{className:`grid gap-3 p-3 sm:grid-cols-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border px-3 py-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:t(`quotaPlanner.fields.prewarmPlanning`)}),(0,$.jsx)(R,{checked:S.prewarmEnabled,disabled:w,onCheckedChange:e=>O({prewarmEnabled:e})})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border px-3 py-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:t(`quotaPlanner.fields.syntheticTraffic`)}),(0,$.jsx)(R,{checked:S.allowSyntheticTraffic,disabled:w,onCheckedChange:e=>O({allowSyntheticTraffic:e})})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border px-3 py-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:t(`quotaPlanner.fields.dryRun`)}),(0,$.jsx)(R,{checked:S.dryRun,disabled:w,onCheckedChange:e=>O({dryRun:e})})]})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 p-3 sm:grid-cols-3`,children:[(0,$.jsxs)(`label`,{htmlFor:`quota-planner-min-expected-gain`,className:`space-y-1 text-xs font-medium`,children:[t(`quotaPlanner.fields.minExpectedGain`),(0,$.jsx)(H,{id:`quota-planner-min-expected-gain`,className:`h-8 text-xs`,type:`number`,min:0,step:`0.1`,value:S.minExpectedGain,disabled:w,onChange:e=>O({minExpectedGain:Number.parseFloat(e.target.value||`0`)})})]}),(0,$.jsxs)(`label`,{htmlFor:`quota-planner-daily-warmup-credits`,className:`space-y-1 text-xs font-medium`,children:[t(`quotaPlanner.fields.dailyWarmupCredits`),(0,$.jsx)(H,{id:`quota-planner-daily-warmup-credits`,className:`h-8 text-xs`,type:`number`,min:0,step:`0.1`,value:S.maxWarmupCreditsPerDay,disabled:w,onChange:e=>O({maxWarmupCreditsPerDay:Number.parseFloat(e.target.value||`0`)})})]}),(0,$.jsxs)(`label`,{htmlFor:`quota-planner-warmup-model`,className:`space-y-1 text-xs font-medium`,children:[t(`quotaPlanner.fields.warmupModel`),(0,$.jsx)(H,{id:`quota-planner-warmup-model`,className:`h-8 text-xs`,value:S.warmupModelPreference??``,disabled:w,onChange:e=>O({warmupModelPreference:e.target.value.trim()||null})})]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-3 rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(c,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`text-sm font-semibold`,children:t(`quotaPlanner.forecast.title`)})]}),(0,$.jsx)(K,{variant:S.mode===`off`?`secondary`:`default`,children:S.mode})]}),a.isLoading&&!D?(0,$.jsx)(Ft,{}):D?(0,$.jsxs)(`div`,{className:`grid gap-2 text-xs`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:t(`quotaPlanner.forecast.demand`)}),(0,$.jsx)(`span`,{className:`font-medium tabular-nums`,children:Ia(D.totalDemandUnits)})]}),(0,$.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:t(`quotaPlanner.forecast.served`)}),(0,$.jsx)(`span`,{className:`font-medium tabular-nums`,children:Ia(D.simulation.servedUnits)})]}),(0,$.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:t(`quotaPlanner.forecast.unmet`)}),(0,$.jsx)(`span`,{className:`font-medium tabular-nums`,children:Ia(D.simulation.unmetDemand)})]}),(0,$.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:t(`quotaPlanner.forecast.peak`)}),(0,$.jsx)(`span`,{className:`font-medium tabular-nums`,children:Ia(D.peakDemandUnits)})]}),(0,$.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:t(`quotaPlanner.forecast.peakSlot`)}),(0,$.jsx)(`span`,{className:`text-right font-medium`,children:D.peakSlotStart?La(D.peakSlotStart,n):t(`quotaPlanner.forecast.noDemand`)})]})]}):null]})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsx)(H,{"aria-label":t(`quotaPlanner.actions.warmAccountAria`),className:`h-8 w-48 text-xs`,placeholder:t(`quotaPlanner.actions.warmAccountPlaceholder`),value:p,disabled:T,onChange:e=>m(e.target.value)}),(0,$.jsxs)(`label`,{htmlFor:`quota-planner-force-probe`,className:`flex h-8 items-center gap-2 rounded-md border px-2 text-xs font-medium`,children:[(0,$.jsx)(Te,{id:`quota-planner-force-probe`,checked:h,disabled:T,onCheckedChange:e=>g(e===!0)}),t(`quotaPlanner.actions.forceProbe`)]}),(0,$.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,className:`h-8 text-xs`,disabled:T||p.trim().length===0,onClick:()=>{s.mutate({accountId:p.trim(),model:S.warmupModelPreference,forceProbe:h})},children:t(`quotaPlanner.actions.warmNow`)}),(0,$.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,className:`h-8 text-xs`,disabled:w||!ee||!u,onClick:()=>f(null),children:t(`common.actions.reset`)}),(0,$.jsx)(A,{type:`button`,size:`sm`,className:`h-8 text-xs`,disabled:w||!ee,onClick:()=>{S&&o.mutate(S,{onSuccess:()=>f(null)})},children:t(`quotaPlanner.actions.save`)})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h4`,{className:`text-xs font-semibold uppercase text-muted-foreground`,children:t(`quotaPlanner.decisions.title`)}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`quotaPlanner.decisions.shown`,{count:te.length})})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg border`,children:te.length===0?(0,$.jsx)(`div`,{className:`px-3 py-5 text-center text-xs text-muted-foreground`,children:t(`quotaPlanner.decisions.empty`)}):(0,$.jsx)(`div`,{className:`divide-y`,children:te.slice(0,8).map(e=>{let r=e.details?.target_peak_at,i=typeof r==`string`&&r?La(r,n):null,a=Ra(e.details,`warmup_cycle`),o=Ra(e.details,`expected_gain`),s=Ra(e.details,`expected_cost`),c=Ra(e.details,`skip_reason`)||Ra(e.details,`noop_reason`);return(0,$.jsxs)(`div`,{className:`grid gap-2 px-3 py-2 text-xs sm:grid-cols-[9rem_1fr_5rem_5rem]`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:La(e.createdAt,n)}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsxs)(`span`,{className:`block truncate`,children:[e.action,e.accountId?` ${e.accountId}`:``,` · `,e.status,e.scheduledAt?` · ${t(`quotaPlanner.decisions.scheduled`,{time:La(e.scheduledAt,n)})}`:``]}),(0,$.jsxs)(`span`,{className:`block truncate text-muted-foreground`,children:[i?t(`quotaPlanner.decisions.peak`,{value:i}):e.reason??t(`quotaPlanner.decisions.noReason`),o?` · ${t(`quotaPlanner.decisions.gain`,{value:o})}`:``,s?` · ${t(`quotaPlanner.decisions.cost`,{value:s})}`:``,a?` · ${a}`:``,c?` · ${c}`:``]})]}),(0,$.jsx)(`span`,{className:`text-right font-medium tabular-nums`,children:Ia(e.score)}),(0,$.jsx)(A,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 text-xs`,disabled:E||![`planned`,`skipped`].includes(e.status),onClick:()=>l.mutate(e.id),children:t(`common.cancel`)})]},e.id)})})})]})]}):(0,$.jsx)(`div`,{className:`py-8`,children:(0,$.jsx)(Ft,{})})]})}function Va({className:e,...t}){return(0,$.jsx)(ai,{"data-slot":`tabs`,className:he(`flex flex-col gap-4`,e),...t})}function Ha({className:e,...t}){return(0,$.jsx)(si,{"data-slot":`tabs-list`,className:he(`flex gap-1 rounded-lg bg-muted/60 p-1`,e),...t})}function Ua({className:e,...t}){return(0,$.jsx)(li,{"data-slot":`tabs-trigger`,className:he(`flex-1 rounded-md px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground`,`data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-xs`,`focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] focus-visible:outline-none`,e),...t})}function Wa({className:e,...t}){return(0,$.jsx)(di,{"data-slot":`tabs-content`,className:he(`outline-none`,e),...t})}function Ga(e,t){let n=De(e);if(n)return t(n,{defaultValue:n});let r=Ze(e);return t(r,{defaultValue:r})}function Ka({settings:e,busy:t,onSave:n,onRefresh:r}){let{t:i}=k(),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(null),d=t||s,f=t=>void n(X(e,t)),p=async()=>{u(null),c(!0);try{await Oe({password:a}),o(``),await r(),U.success(i(`settings.guestAccess.toasts.passwordSaved`))}catch(e){u(Ga(e,i))}finally{c(!1)}},m=async()=>{u(null),c(!0);try{await ke(),await r(),U.success(i(`settings.guestAccess.toasts.passwordRemoved`))}catch(e){u(Ga(e,i))}finally{c(!1)}};return(0,$.jsx)(`section`,{className:`rounded-xl border bg-card p-5`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(jt,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:i(`settings.guestAccess.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`settings.guestAccess.description`)})]})]}),(0,$.jsx)(R,{"aria-label":i(`settings.guestAccess.toggleAria`),checked:e.guestAccessEnabled,disabled:d,onCheckedChange:e=>f({guestAccessEnabled:e})})]}),l?(0,$.jsx)(W,{variant:`error`,children:l}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:i(`settings.guestAccess.password.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.guestPasswordConfigured?i(`settings.guestAccess.password.configuredDescription`):i(`settings.guestAccess.password.emptyDescription`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,$.jsx)(H,{type:`password`,autoComplete:`new-password`,value:a,disabled:d,onChange:e=>o(e.target.value),placeholder:i(`settings.guestAccess.password.placeholder`),className:`h-8 text-xs sm:w-56`}),(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 text-xs`,disabled:d||!a.trim(),onClick:()=>void p(),children:i(`settings.guestAccess.password.save`)}),e.guestPasswordConfigured?(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 text-xs text-destructive hover:text-destructive`,disabled:d,onClick:()=>void m(),children:i(`settings.guestAccess.password.remove`)}):null]})]})]})})}var qa=3600,Ja=2592e3,Ya=/^\d+$/;function Xa(e){let t=e/3600;return Number.isInteger(t)?String(t):t.toFixed(2)}function Za({settings:e,busy:t,onSave:n}){let{t:r}=k(),[i,a]=(0,Q.useState)(Xa(e.dashboardSessionTtlSeconds)),o=i.trim(),s=Ya.test(o),c=s?Number.parseInt(o,10):NaN,l=c*3600,u=s&&Number.isFinite(c)&&c>0&&l>=qa,f=u&&l!==e.dashboardSessionTtlSeconds,p=u&&l>Ja,m=o!==``&&!u,h=()=>void n(X(e,{dashboardSessionTtlSeconds:l}));return(0,$.jsx)(`section`,{className:`rounded-xl border bg-card p-5`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(jr,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`settings.session.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings.session.description`)})]})]})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:r(`settings.session.lifetime.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings.session.lifetime.description`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(H,{type:`number`,min:1,step:1,inputMode:`numeric`,value:i,disabled:t,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&f&&h()},className:`h-8 w-24 text-xs`,"aria-label":r(`settings.session.lifetime.ariaLabel`)}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`settings.session.lifetime.hoursSuffix`)}),(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 text-xs`,disabled:t||!f,onClick:h,children:r(`settings.session.lifetime.save`)})]})]}),m?(0,$.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs font-medium text-destructive`,children:(0,$.jsx)(d,{i18nKey:`settings.session.lifetime.invalid`,components:[(0,$.jsx)(`code`,{},`0`)]})}):null,p?(0,$.jsx)(`div`,{className:`rounded-lg border border-amber-500/20 bg-amber-500/10 px-3 py-2 text-xs font-medium text-foreground`,children:r(`settings.session.lifetime.longWarning`)}):null]})})}var Qa=(0,Q.lazy)(()=>pt(()=>import(`./totp-settings-CRHtxQ7j.js`).then(e=>({default:e.TotpSettings})),__vite__mapDeps([32,1,2,33,4,15,16,17,8,9,10,7,6,28,19,13,5,14,18,20,34])));function $a({settings:e,busy:t,onSave:n,onRefresh:r}){let i=z(e=>e.canWrite),a=B(`security:write`),o=z(e=>e.passwordManagementEnabled),s=z(e=>e.passwordManagementEnabled&&(e.passwordSessionActive||e.user!==null));return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[a?(0,$.jsx)(Ka,{settings:e,busy:t,onSave:n,onRefresh:r}):null,i||s?(0,$.jsx)(Xt,{disabled:t}):null,a&&o?(0,$.jsx)(Za,{settings:e,busy:t,onSave:n}):null,s?(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Qa,{settings:e,disabled:t,canEditPolicy:a,onSave:n})}):null]})}function eo({onInvite:e,...t}){let{t:n}=k(),r=B(`users:manage`),i=z(e=>e.authMode),a=z(e=>e.user),[o,s]=(0,Q.useState)(!1),c=r&&i!==`disabled`,l=a===null;return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[c?(0,$.jsxs)(`div`,{"data-testid":`access-solo-line`,className:`flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(l?`access.solo.passwordFirst`:`access.solo.onlyYou`)}),l?(0,$.jsx)(ct,{open:o,onOpenChange:s,disabled:t.busy,children:(0,$.jsx)(A,{type:`button`,size:`sm`,className:`h-8 shrink-0 text-xs`,disabled:t.busy,children:n(`access.solo.setPassword`)})}):(0,$.jsx)(A,{type:`button`,size:`sm`,className:`h-8 shrink-0 text-xs`,disabled:t.busy,onClick:e,children:n(`access.solo.invite`)})]}):null,(0,$.jsx)($a,{...t})]})}function to(e){let{t}=k(),{hash:n,key:r}=dt(),i=z(e=>e.tier),a=z(e=>e.user),o=B(`users:manage`),s=Ne(n),[c,l]=(0,Q.useState)(null),u=c?.key===r?c.tab:s??`people`,[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),h=i!==`individual`&&o&&a!==null;(0,Q.useEffect)(()=>{if(s===null)return;let e=n===Pt||n===`#access-people`?vt:n.slice(1),t=window.requestAnimationFrame(()=>{document.getElementById(e)?.scrollIntoView({block:`start`})});return()=>window.cancelAnimationFrame(t)},[n,s,r]);let g=()=>f(!0),_=()=>{m(null),z.getState().refreshSession().catch(()=>void 0)};return(0,$.jsxs)(`section`,{id:vt,className:`scroll-mt-20 rounded-xl border bg-card p-5`,children:[(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(se,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`access.card.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`access.card.description`)})]})]}),h?(0,$.jsxs)(Va,{value:u,onValueChange:e=>l({key:r,tab:e}),children:[(0,$.jsxs)(Ha,{"aria-label":t(`access.card.title`),children:[(0,$.jsx)(Ua,{value:`people`,children:t(`access.tabs.people`)}),(0,$.jsx)(Ua,{value:`my-sign-in`,children:t(`access.tabs.mySignIn`)})]}),(0,$.jsx)(Wa,{value:`people`,children:(0,$.jsx)(Bn,{onOpenMySignIn:()=>l({key:r,tab:`my-sign-in`}),onInvite:g,onIssued:m})}),(0,$.jsx)(Wa,{value:`my-sign-in`,children:(0,$.jsx)($a,{...e})})]}):i===`individual`?(0,$.jsx)(eo,{...e,onInvite:g}):(0,$.jsx)($a,{...e})]}),(0,$.jsx)(Hn,{open:d,onOpenChange:f,onIssued:m}),(0,$.jsx)(Ln,{issued:p,onClose:_})]})}function no({...e}){return(0,$.jsx)(Ur,{"data-slot":`collapsible`,...e})}function ro({...e}){return(0,$.jsx)(Gr,{"data-slot":`collapsible-trigger`,...e})}function io({...e}){return(0,$.jsx)(qr,{"data-slot":`collapsible-content`,...e})}var ao=[],oo={title:`settings.advanced.title`,description:`settings.advanced.description`,show:`settings.advanced.show`,hide:`settings.advanced.hide`};function so({children:e,defaultOpen:t=!1,scrollToId:n,waitForQueryKeys:i=ao,labels:a=oo,descriptionValues:s,descriptionTestId:c}){let{t:l}=k(),[u,d]=(0,Q.useState)(t),f=o(),p=(0,Q.useCallback)(e=>i.some(t=>t.every((t,n)=>Object.is(e.queryKey[n],t))),[i]),m=r({predicate:p}),h=(0,Q.useRef)(void 0);return(0,Q.useEffect)(()=>{if(!u||!n){h.current=void 0;return}if(h.current===n)return;let e=window.requestAnimationFrame(()=>{if(f.isFetching({predicate:p})>0)return;let e=document.getElementById(n);e&&(e.scrollIntoView({block:`start`}),h.current=n)});return()=>{window.cancelAnimationFrame(e)}},[m,p,u,f,n]),(0,$.jsxs)(no,{open:u,onOpenChange:d,className:`rounded-xl border bg-card`,children:[(0,$.jsxs)(ro,{"aria-label":l(u?a.hide:a.show),className:`flex w-full items-center gap-3 rounded-xl p-5 text-left transition-colors hover:bg-muted/40`,children:[(0,$.jsx)(g,{"aria-hidden":`true`,className:he(`h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200`,u&&`rotate-90`)}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-semibold tracking-tight`,children:l(a.title)}),(0,$.jsx)(`span`,{"data-testid":c,className:`mt-0.5 block text-xs text-muted-foreground`,children:l(a.description,s)})]})]}),(0,$.jsx)(io,{className:`space-y-4 border-t p-4`,children:e})]})}var co=`/api/auth-providers`,lo=`/api/role-mappings`,uo=`/api/audit-logs`,fo=`/api/scim-tokens`,po=`/api/dashboard-auth/oidc/test-login/start`,mo=P({id:L(),kind:L(),providerKey:L(),label:L(),enabled:N(),active:N(),unknownIdentityRoleId:L().nullable().default(null),noMatchRoleId:L().nullable().default(null),linkByEmail:N(),skipRoleSync:N(),idpMfaEnforced:N(),config:ve(L(),L()).default({}),testLoginVerifiedAt:L().nullable().default(null),createdAt:L(),updatedAt:L()}),ho=P({id:L(),provider:L(),providerKey:L(),claimName:L(),claimValue:L(),roleId:L(),priority:F().int(),createdAt:L(),updatedAt:L()}),go=P({id:L(),slug:L(),name:L(),description:L().nullable().default(null),kind:L(),locked:N()}),_o=P({id:F().int(),timestamp:L(),action:L(),actorIp:L().nullable().default(null),details:ve(L(),_e()).nullable().default(null),severity:L().default(`info`)}),vo=`/api/dashboard-auth/oidc/callback`,yo=P({authorizationUrl:L()});function bo(){return Ce(co,M(mo))}function xo(e,t){return ye(`${co}/${encodeURIComponent(e)}`,mo,{body:t})}function So(){return j(po,yo)}function Co(){return Ce(lo,M(ho))}function wo(){return Ce(`${lo}/assignable-roles`,M(go))}function To(e){return j(lo,ho,{body:e})}function Eo(e,t){return ye(`${lo}/${encodeURIComponent(e)}`,ho,{body:t})}function Do(e){return be(`${lo}/${encodeURIComponent(e)}`)}function Oo(e){return xe(`${lo}/order`,M(ho),{body:e})}var ko=P({id:L(),label:L(),tokenPrefix:L(),createdAt:L(),createdByUserId:L().nullable().default(null),lastUsedAt:L().nullable().default(null),rotatedAt:L().nullable().default(null)}),Ao=P({tokens:M(ko),basePath:L()}),jo=P({token:ko,secret:L()});function Mo(){return Ce(fo,Ao)}function No(e){return j(fo,jo,{body:e})}function Po(e){return j(`${fo}/${encodeURIComponent(e)}/rotate`,jo)}function Fo(e){return be(`${fo}/${encodeURIComponent(e)}`)}function Io({action:e,reason:t,since:n,limit:r=50}){let i=new URLSearchParams({action:e,reason:t,since:n,limit:String(r)});return Ce(`${uo}?${i.toString()}`,M(_o))}var Lo=[`auth-providers`,`list`],Ro=[`role-mappings`,`list`],zo=[`audit-logs`,`refused-sign-ins`],Bo=[`role-mappings`,`assignable-roles`],Vo=[`scim-tokens`,`list`],Ho=[`settings`,`detail`],Uo=new Set([`admin_account_required`,`insufficient_delegation`,`mapping_exists`,`mapping_limit_reached`,`order_stale`,`provider_not_found`,`mapping_not_found`,`role_not_assignable`,`unknown_claim`,`break_glass_requires_totp`,`last_break_glass_protected`,`oidc_test_login_required`,`invalid_provider_config`,`config_not_supported`,`oidc_provider_unreachable`,`oidc_rate_limited`,`scim_token_not_found`]);function Wo(e){if(!(e instanceof we))return null;let t=e.details;if(typeof t!=`object`||!t||!(`details`in t))return null;let n=t.details;if(typeof n!=`object`||!n||!(`username`in n))return null;let r=n.username;return typeof r==`string`&&r.length>0?r:null}function Go(e){if(!(e instanceof we))return null;let t=e.details;if(typeof t!=`object`||!t||!(`param`in t))return null;let n=t.param;return typeof n==`string`?Cn(n):null}function Ko(e,t){return e instanceof we&&Uo.has(e.code)?t(`organisation.errors.${e.code}`):Ze(e)}function qo(e=!0){return i({queryKey:Ho,queryFn:St,enabled:e})}function Jo(e=!0){return i({queryKey:Lo,queryFn:bo,enabled:e})}function Yo(e=!0){return i({queryKey:Ro,queryFn:Co,enabled:e})}function Xo(e=!0){return i({queryKey:Bo,queryFn:wo,enabled:e})}function Zo(e=!0){return i({queryKey:Vo,queryFn:Mo,enabled:e})}function Qo(e=!0){return i({queryKey:zo,queryFn:()=>Io({action:Un,reason:On,since:vn(),limit:50}),enabled:e,retry:!1})}function $o(){let e=o(),t=async()=>{await Promise.all([e.invalidateQueries({queryKey:Lo}),e.invalidateQueries({queryKey:Ro})]),await z.getState().refreshSession().catch(()=>void 0)},n=a({mutationFn:({providerId:e,payload:t})=>xo(e,t),onSuccess:t}),r=a({mutationFn:({providerId:e,payload:t})=>xo(e,t),onSuccess:t,gcTime:0}),i=a({mutationFn:So}),s=()=>e.invalidateQueries({queryKey:Lo}),c=a({mutationFn:e=>To(e),onSuccess:t}),l=a({mutationFn:({mappingId:e,payload:t})=>Eo(e,t),onSuccess:t}),u=a({mutationFn:e=>Do(e),onSuccess:t}),d=a({mutationFn:e=>bt(e),onSuccess:async()=>{await e.invalidateQueries({queryKey:Ho}),await t()},onError:t=>{t instanceof we&&t.code===`settings_conflict`&&e.invalidateQueries({queryKey:Ho})}}),f=a({mutationFn:e=>Oo(e),onSuccess:t}),p=a({mutationFn:e=>No(e),gcTime:0}),m=a({mutationFn:e=>Po(e),gcTime:0}),h=a({mutationFn:e=>Fo(e),onSuccess:async()=>{await e.invalidateQueries({queryKey:Vo}),await t()}});return{updateProvider:n,updateOidcProvider:r,startTestLogin:i,refreshProviders:s,createMapping:c,updateMapping:l,removeMapping:u,reorderMappings:f,updateLoginPolicy:d,issueToken:p,rotateToken:m,revokeToken:h,settleScimTokens:async()=>{await e.invalidateQueries({queryKey:Vo}),await t()},busy:[n,r,i,c,l,u,f,d,p,m,h].some(e=>e.isPending)}}var es=64;function ts({tokensQuery:e,providers:t,mutations:n,disabled:r=!1}){let{t:i}=k(),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),d=jn(t),f=d!==null,p=r||n.busy,m=e.data?.tokens??[],h=e.data===void 0?null:rs(e.data.basePath),g=e=>{u(null),c(e),n.issueToken.reset(),n.rotateToken.reset()},_=()=>{u(null),n.issueToken.mutateAsync({label:a.trim()}).then(e=>{o(``),g(e)}).catch(u)},v=e=>{u(null),n.rotateToken.mutateAsync(e).then(g).catch(u)},y=e=>{u(null),n.revokeToken.mutateAsync(e).catch(u)};return(0,$.jsxs)(`section`,{id:qe,className:`scroll-mt-16 space-y-3 rounded-xl border bg-card p-5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(Fr,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:i(`organisation.automaticAccounts.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`organisation.automaticAccounts.description`)})]})]}),l===null?null:(0,$.jsx)(W,{variant:`error`,children:Ko(l,i)}),f?null:(0,$.jsx)(`div`,{"data-testid":`automatic-accounts-blocked`,children:(0,$.jsx)(W,{variant:`warning`,children:i(`organisation.automaticAccounts.needsCompanyLogin`)})}),f&&!d.linkByEmail?(0,$.jsx)(W,{variant:`warning`,children:i(`organisation.automaticAccounts.separateAccountsHint`,{label:d.label})}):null,h===null?null:(0,$.jsxs)(`div`,{className:`space-y-1 rounded-lg border p-3`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`organisation.automaticAccounts.address`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`p`,{className:`min-w-0 flex-1 font-mono text-sm font-medium break-all select-all`,"data-testid":`scim-base-url`,children:h}),(0,$.jsx)(te,{value:h,label:i(`organisation.automaticAccounts.copyAddress`)})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:i(`organisation.automaticAccounts.addressHelp`)})]}),e.data===void 0?e.isError?(0,$.jsx)(W,{variant:`error`,children:(0,$.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[i(`organisation.automaticAccounts.loadFailed`),(0,$.jsx)(A,{type:`button`,variant:`outline`,size:`xs`,disabled:e.isFetching,onClick:()=>void e.refetch(),children:i(`common.actions.retry`)})]})}):(0,$.jsx)(Ft,{}):(0,$.jsx)(`div`,{className:`space-y-2`,"data-testid":`scim-token-list`,children:m.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`organisation.automaticAccounts.empty`)}):m.map(e=>(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,$.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e.label}),(0,$.jsxs)(`p`,{className:`font-mono text-[11px] text-muted-foreground`,children:[e.tokenPrefix,`…`]}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e.lastUsedAt?i(`organisation.automaticAccounts.lastSync`,{when:new Date(e.lastUsedAt).toLocaleString()}):i(`organisation.automaticAccounts.neverSynced`)})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(A,{type:`button`,variant:`outline`,size:`xs`,disabled:p,onClick:()=>v(e.id),children:i(`organisation.automaticAccounts.actions.rotate`)}),(0,$.jsx)(A,{type:`button`,variant:`outline`,size:`xs`,disabled:p,onClick:()=>y(e.id),children:i(`organisation.automaticAccounts.actions.revoke`)})]})]},e.id))}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(Ee,{htmlFor:`organisation-scim-label`,className:`text-xs font-medium`,children:i(`organisation.automaticAccounts.labelField`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(H,{id:`organisation-scim-label`,className:`max-w-xs`,value:a,maxLength:es,disabled:p||!f,placeholder:i(`organisation.automaticAccounts.labelPlaceholder`),onChange:e=>o(e.target.value)}),(0,$.jsx)(A,{type:`button`,size:`sm`,disabled:p||!f||a.trim()===``,onClick:_,children:i(`organisation.automaticAccounts.actions.issue`)})]})]}),(0,$.jsx)(ns,{issued:s,onClose:()=>{c(null),n.settleScimTokens()}})]})}function ns({issued:e,onClose:t}){let{t:n}=k();return(0,$.jsx)(mt,{open:e!==null,onOpenChange:e=>!e&&t(),children:(0,$.jsxs)(Ht,{className:`sm:max-w-md`,children:[(0,$.jsxs)(wt,{children:[(0,$.jsx)(ot,{children:n(`organisation.automaticAccounts.secret.title`)}),(0,$.jsx)(At,{children:n(`organisation.automaticAccounts.secret.description`,{label:e?.token.label??``})})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`organisation.automaticAccounts.secret.warning`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 overflow-hidden rounded-lg border bg-muted/20 px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,"data-testid":`scim-token-secret`,children:e?.secret??``}),(0,$.jsx)(te,{value:e?.secret??``,label:n(`organisation.automaticAccounts.secret.copy`)})]})]}),(0,$.jsx)(Rt,{children:(0,$.jsx)(A,{type:`button`,onClick:t,children:n(`common.actions.done`)})})]})})}function rs(e){return typeof window>`u`?e:`${window.location.origin}${e}`}function is(e,t){let n=e.details?.[t];return typeof n==`string`&&n.length>0?n:null}function as({open:e,onOpenChange:t,entries:n,loading:r}){let{t:i}=k(),a=gt(e=>e.dateDisplayFormat);return(0,$.jsx)(Qt,{open:e,onOpenChange:t,children:(0,$.jsxs)(Me,{className:`w-full overflow-y-auto sm:max-w-md`,children:[(0,$.jsxs)(Ie,{children:[(0,$.jsx)(Ye,{children:i(`organisation.refused.title`)}),(0,$.jsx)(Xe,{children:i(`organisation.refused.description`,{days:7})})]}),(0,$.jsx)(`div`,{className:`space-y-2 px-4 pb-4`,children:r?(0,$.jsx)(Ft,{}):n.length===0?(0,$.jsx)(dn,{icon:Dr,title:i(`organisation.refused.empty`)}):n.map(e=>{let t=ze(e.timestamp,a),n=is(e,`subject`)??i(`organisation.refused.unknownSubject`),r=is(e,`email`);return(0,$.jsxs)(`div`,{"data-testid":`refused-sign-in-row`,className:`rounded-lg border p-3`,children:[(0,$.jsx)(`p`,{className:`font-mono text-xs font-medium`,children:n}),r?(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r,` `,(0,$.jsxs)(`span`,{className:`font-mono`,children:[`(`,Sn(r),`)`]})]}):null,(0,$.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[t.date,` `,t.time]})]},e.id)})})]})})}var os=[Vn,Rn];function ss(e){return(e.find(e=>e.slug===`viewer`)??e[0])?.id??``}function cs({provider:e,roles:t,rules:n,mutations:r,canReadAudit:i,refusedOpen:a=!1,disabled:o=!1}){let{t:s}=k(),c=Qo(i),[l,u]=(0,Q.useState)(a),[d,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(n.length===0?Rn:Vn),[S,C]=(0,Q.useState)(``),[w,T]=(0,Q.useState)(``),E=o||r.busy,ee=r.createMapping.error||r.updateMapping.error||r.removeMapping.error||r.reorderMappings.error,D=ee?Ko(ee,s):null,te=c.data??[],O=te.length,ne=Pn(te),re=w||ss(t),ie=S||(h===`email_domain`?ne:``),ae=ie.trim().length>0&&re!==``&&!E,oe=()=>{if(!ae)return;let t=h===`email_domain`?Gn(ie):ie.trim();r.createMapping.mutateAsync({provider:e.kind,providerKey:e.providerKey,claimName:h,claimValue:t,roleId:re}).then(()=>{C(``),T(``)}).catch(()=>void 0)},se=t=>{r.reorderMappings.mutateAsync({provider:e.kind,providerKey:e.providerKey,ids:t.map(e=>e.id)}).catch(()=>void 0)},ce=(e,t)=>{t<0||t>=n.length||se(_n(n,e,t))},le=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,"data-testid":`organisation-rule-add`,children:[(0,$.jsxs)(x,{value:h,onValueChange:g,disabled:E,children:[(0,$.jsx)(y,{className:`sm:w-44`,"aria-label":s(`organisation.rules.add.claimLabel`),children:(0,$.jsx)(b,{})}),(0,$.jsx)(v,{children:os.map(e=>(0,$.jsx)(_,{value:e,children:s(`organisation.rules.claims.${e}`)},e))})]}),(0,$.jsx)(H,{value:ie,onChange:e=>C(e.target.value),onKeyDown:e=>{e.key===`Enter`&&oe()},"aria-label":s(`organisation.rules.add.valueLabel`),placeholder:s(h===`email_domain`?`organisation.rules.add.domainPlaceholder`:`organisation.rules.add.groupPlaceholder`),className:`h-9 text-xs`,disabled:E}),(0,$.jsx)(Mn,{value:re,onValueChange:T,roles:t,disabled:E,ariaLabel:s(`organisation.rules.add.roleLabel`),className:`sm:w-44`}),(0,$.jsx)(A,{type:`button`,size:`sm`,className:`h-9 text-xs`,onClick:oe,disabled:!ae,children:s(`organisation.rules.add.submit`)})]});return(0,$.jsxs)(`section`,{id:`organisation-rules`,className:`scroll-mt-16 space-y-3 rounded-xl border bg-card p-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(pr,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:s(`organisation.rules.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s(`organisation.rules.description`)})]})]}),i&&c.isSuccess&&O>0?(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,"data-testid":`organisation-refused-line`,children:[s(`organisation.rules.refused`,{count:O,days:7}),` `,(0,$.jsx)(A,{type:`button`,variant:`link`,size:`sm`,className:`h-auto p-0 text-xs`,onClick:()=>u(!0),children:s(`organisation.rules.refusedView`)})]}):null]}),D?(0,$.jsx)(W,{variant:`error`,children:D}):null,n.length===0?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-dashed border-border/60 p-5`,"data-testid":`organisation-rules-empty`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:s(`organisation.rules.empty.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80`,children:e.unknownIdentityRoleId===null?s(`organisation.rules.empty.refuses`):s(`organisation.rules.empty.admits`,{role:t.find(t=>t.id===e.unknownIdentityRoleId)?.name??``})}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80`,children:s(`organisation.rules.empty.reevaluation`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80`,children:s(`organisation.rules.empty.quickAdd`)}),le]}):(0,$.jsxs)($.Fragment,{children:[le,(0,$.jsx)(`div`,{className:`overflow-x-auto rounded-xl border`,children:(0,$.jsxs)(hn,{children:[(0,$.jsx)(fn,{children:(0,$.jsxs)(mn,{children:[(0,$.jsx)(J,{className:`w-[120px]`,children:s(`organisation.rules.table.order`)}),(0,$.jsx)(J,{children:s(`organisation.rules.table.matches`)}),(0,$.jsx)(J,{className:`w-[200px]`,children:s(`organisation.rules.table.role`)}),(0,$.jsx)(J,{className:`w-[96px] text-right`,children:s(`apiKeys.table.actions`)})]})}),(0,$.jsx)(pn,{children:n.map((e,i)=>(0,$.jsxs)(mn,{"data-testid":`organisation-rule-${e.claimValue}`,draggable:!E,onDragStart:()=>m(i),onDragOver:e=>e.preventDefault(),onDrop:()=>{d!==null&&d!==i&&se(_n(n,d,i)),m(null)},onDragEnd:()=>m(null),children:[(0,$.jsx)(Y,{children:(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(lr,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:i+1}),(0,$.jsx)(A,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":s(`organisation.rules.actions.moveUp`,{value:e.claimValue}),disabled:E||i===0,onClick:()=>ce(i,i-1),children:(0,$.jsx)(p,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})}),(0,$.jsx)(A,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":s(`organisation.rules.actions.moveDown`,{value:e.claimValue}),disabled:E||i===n.length-1,onClick:()=>ce(i,i+1),children:(0,$.jsx)(f,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})]})}),(0,$.jsxs)(Y,{className:`text-xs`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:s(`organisation.rules.claims.${e.claimName}`)}),` `,(0,$.jsx)(`span`,{className:`font-mono font-medium`,children:e.claimValue})]}),(0,$.jsx)(Y,{children:(0,$.jsxs)(x,{value:e.roleId,disabled:E||t.length===0,onValueChange:t=>void r.updateMapping.mutateAsync({mappingId:e.id,payload:{roleId:t}}).catch(()=>void 0),children:[(0,$.jsx)(y,{className:`h-8`,"aria-label":s(`organisation.rules.actions.role`,{value:e.claimValue}),children:(0,$.jsx)(b,{})}),(0,$.jsx)(v,{children:(0,$.jsx)(Tn,{roles:t})})]})}),(0,$.jsx)(Y,{className:`text-right`,children:(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`ghost`,className:`text-destructive hover:text-destructive`,disabled:E,onClick:()=>void r.removeMapping.mutateAsync(e.id).catch(()=>void 0),children:s(`common.actions.remove`)})})]},e.id))})]})})]}),(0,$.jsx)(as,{open:l,onOpenChange:u,entries:te,loading:c.isLoading})]})}var ls=[`enabled`,`admins_only`,`break_glass_only`];function us({settingsQuery:e,usersQuery:t,canSeeAccounts:n,mutations:r,disabled:i=!1}){let{t:a}=k(),o=r.updateLoginPolicy,s=i||o.isPending,c=e.data,l=c?.localLoginPolicy??`enabled`,u=t.data===void 0,d=zn(t.data),f=d.filter(Kn),p=(f[0]??d[0])?.username??null,m=Wo(o.error)??p,h=o.error?Ko(o.error,a):null,g=e=>{c&&e!==l&&o.mutateAsync(X(c,{localLoginPolicy:e})).catch(()=>void 0)};return(0,$.jsxs)(`section`,{id:`organisation-login-policy`,className:`scroll-mt-16 space-y-3 rounded-xl border bg-card p-5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(ht,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:a(`organisation.loginPolicy.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`organisation.loginPolicy.description`)})]})]}),h?(0,$.jsx)(W,{variant:`error`,children:h}):null,c===void 0?e.isError?(0,$.jsx)(W,{variant:`error`,children:(0,$.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[a(`organisation.loginPolicy.loadFailed`),(0,$.jsx)(A,{type:`button`,variant:`outline`,size:`xs`,disabled:e.isFetching,onClick:()=>void e.refetch(),children:a(`common.actions.retry`)})]})}):(0,$.jsx)(Ft,{}):(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(Ee,{htmlFor:`organisation-login-policy-select`,className:`text-xs font-medium`,children:a(`organisation.loginPolicy.label`)}),(0,$.jsxs)(x,{value:l,disabled:s,onValueChange:e=>g(e),children:[(0,$.jsx)(y,{id:`organisation-login-policy-select`,"aria-label":a(`organisation.loginPolicy.label`),children:(0,$.jsx)(b,{})}),(0,$.jsx)(v,{children:ls.map(e=>(0,$.jsx)(_,{value:e,children:a(`organisation.loginPolicy.options.${e}`)},e))})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:a(`organisation.loginPolicy.help.${l}`)})]}),n&&u?(0,$.jsx)(W,{variant:`warning`,children:t.isError?a(`organisation.loginPolicy.accountsLoadFailed`):a(`organisation.loginPolicy.accountsLoading`)}):n&&f.length===0?(0,$.jsx)(W,{variant:`warning`,children:m?a(`organisation.loginPolicy.enrolHint`,{username:m}):a(`organisation.loginPolicy.noDesignation`)}):null,(0,$.jsxs)(`div`,{className:`grid gap-2 rounded-lg border p-3 sm:grid-cols-2`,"data-testid":`organisation-emergency-facts`,children:[(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`organisation.loginPolicy.emergencyAccount`)}),n?u?(0,$.jsx)(`p`,{className:`text-sm`,children:a(`organisation.loginPolicy.accountUnknown`)}):(0,$.jsx)(`p`,{className:`font-mono text-sm font-medium select-all`,children:p??`-`}):(0,$.jsx)(`p`,{className:`text-sm`,children:a(`organisation.loginPolicy.accountUnavailable`)}),n&&!u&&p?(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:f.length>0?a(`organisation.loginPolicy.ready`):a(`organisation.loginPolicy.notReady`)}):null]}),(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`organisation.loginPolicy.emergencyUrl`)}),(0,$.jsx)(`p`,{className:`font-mono text-sm font-medium break-all select-all`,children:ds()}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:a(`organisation.loginPolicy.emergencyUrlHelp`)})]})]})]})}function ds(){return typeof window>`u`?Gt:`${window.location.origin}${Gt}`}var fs=[`connection`,`claims`,`test`],ps={subjectClaim:`sub`,emailClaim:`email`,nameClaim:`name`,groupsClaim:`groups`},ms={issuer:``,discoveryUrl:``,clientId:``,clientSecret:``,redirectUri:``,subjectClaim:``,emailClaim:``,nameClaim:``,groupsClaim:``};function hs(e){let t=e.config,n={...ms};for(let e of[...Fn,...Dn])e!==`clientSecret`&&(n[e]=t[e]??``);return n.redirectUri===``&&typeof window<`u`&&(n.redirectUri=`${window.location.origin}${vo}`),n}function gs(e){let t=e=>e.trim()===``?null:e.trim();return{issuer:e.issuer.trim(),discoveryUrl:t(e.discoveryUrl),clientId:e.clientId.trim(),clientSecret:e.clientSecret,redirectUri:e.redirectUri.trim(),subjectClaim:t(e.subjectClaim),emailClaim:t(e.emailClaim),nameClaim:t(e.nameClaim),groupsClaim:t(e.groupsClaim)}}function _s({provider:e,startAt:t,onClose:n,onConnectionSaved:r,mutations:i,children:a}){let{t:o}=k(),[s,c]=(0,Q.useState)(t),[l,u]=(0,Q.useState)(()=>hs(e)),[d,f]=(0,Q.useState)({}),[p,m]=(0,Q.useState)(null),h=Go(p),g=p===null?null:Ko(p,o),_=i.busy,v=e.config.clientSecret??null,y=async()=>{let t=Nn(l,{callbackPath:vo});if(f(t),Object.keys(t).length>0)c(Fn.some(e=>t[e])?`connection`:`claims`);else try{await i.updateOidcProvider.mutateAsync({providerId:e.id,payload:{config:gs(l)}}),m(null),r(),c(`test`)}catch(e){m(e);let t=Go(e);t&&c(Fn.some(e=>e===t)?`connection`:`claims`)}finally{i.updateOidcProvider.reset()}},b=(e,{optional:t=!1}={})=>{let n=d[e],r=h===e;return(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(Ee,{htmlFor:`oidc-${e}`,className:`text-xs font-medium`,children:[o(`organisation.oidc.fields.${e}`),t?(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:` ${o(`organisation.oidc.optional`)}`}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(H,{id:`oidc-${e}`,value:l[e],type:e===`clientSecret`?`password`:`text`,autoComplete:e===`clientSecret`?`new-password`:`off`,"aria-invalid":n!==void 0||r,disabled:_,onChange:t=>u({...l,[e]:t.target.value})}),e===`redirectUri`?(0,$.jsx)(te,{value:l.redirectUri,label:o(`organisation.oidc.copyRedirect`)}):null]}),n?(0,$.jsx)(`p`,{className:`text-[11px] font-medium text-destructive`,children:o(`organisation.oidc.validation.${n}`,{path:vo})}):r?(0,$.jsx)(`p`,{className:`text-[11px] font-medium text-destructive`,children:o(`organisation.oidc.fieldRefused`)}):(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o(`organisation.oidc.help.${e}`)})]})};return(0,$.jsx)(mt,{open:!0,onOpenChange:e=>!e&&n(),children:(0,$.jsxs)(Ht,{className:`max-h-[85vh] overflow-y-auto sm:max-w-lg`,children:[(0,$.jsxs)(wt,{children:[(0,$.jsx)(ot,{children:o(`organisation.oidc.dialog.title`)}),(0,$.jsx)(At,{children:o(`organisation.oidc.dialog.stepOf`,{current:fs.indexOf(s)+1,total:fs.length,name:o(`organisation.oidc.steps.${s}`)})})]}),g?(0,$.jsx)(W,{variant:`error`,children:g}):null,s===`connection`?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`organisation.oidc.dialog.connectionHelp`)}),b(`issuer`),b(`discoveryUrl`,{optional:!0}),b(`clientId`),b(`clientSecret`),v?(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,"data-testid":`oidc-stored-secret`,children:o(`organisation.oidc.secretStored`,{masked:v})}):null,b(`redirectUri`)]}):null,s===`claims`?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`organisation.oidc.dialog.claimsHelp`)}),Dn.map(e=>(0,$.jsxs)(`div`,{className:`space-y-1`,children:[b(e,{optional:!0}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o(`organisation.oidc.claimDefault`,{name:ps[e]})})]},e))]}):null,s===`test`?a:null,(0,$.jsxs)(Rt,{className:`sm:justify-between`,children:[(0,$.jsx)(A,{type:`button`,variant:`ghost`,disabled:_||s===`connection`,onClick:()=>c(s===`test`?`claims`:`connection`),children:o(`organisation.oidc.actions.back`)}),s===`connection`?(0,$.jsx)(A,{type:`button`,disabled:_,onClick:()=>c(`claims`),children:o(`organisation.oidc.actions.next`)}):s===`claims`?(0,$.jsx)(A,{type:`button`,disabled:_,onClick:()=>void y(),children:o(`organisation.oidc.actions.save`)}):(0,$.jsx)(A,{type:`button`,variant:`outline`,disabled:_,onClick:n,children:o(`organisation.oidc.actions.done`)})]})]})})}function vs({provider:e,mutations:t,disabled:n=!1}){let{t:r}=k(),[i]=(0,Q.useState)(ft),a=i!==null&&i.providerId===e.id?i:null,[o,s]=(0,Q.useState)(a===null?null:`test`),[c,l]=(0,Q.useState)(a===null?null:{observed:a.verifiedAt}),[u,d]=(0,Q.useState)(a!==null),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),g=(0,Q.useRef)(null),_=n||t.busy,v=Wn(e),y=c!==null&&kn(c.observed,e.testLoginVerifiedAt);(0,Q.useEffect)(()=>()=>g.current?.(),[]);let b=()=>{let n=Dt(),r=e.testLoginVerifiedAt;p(null),h(null),d(!1),l({observed:r}),t.startTestLogin.mutateAsync().then(({authorizationUrl:i})=>{n===null?(Ut({providerId:e.id,purpose:`test-login`,verifiedAt:r}),ut.go(i)):(n.location.href=i,g.current?.(),g.current=_t(n,e=>{d(e!==`closed`),t.refreshProviders()}))}).catch(e=>{n?.close(),l(null),p(e)})},x=n=>t.updateOidcProvider.mutateAsync({providerId:e.id,payload:n}),S=(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`organisation.oidc.test.help`)}),f===null?null:(0,$.jsx)(W,{variant:`error`,children:f instanceof we&&f.code===`oidc_rate_limited`&&f.retryAfter!==null?r(`organisation.oidc.rateLimited`,{seconds:f.retryAfter}):Ko(f,r)}),m===null?null:(0,$.jsx)(W,{variant:`error`,children:Ko(m,r)}),y?(0,$.jsx)(W,{variant:`success`,children:r(`organisation.oidc.test.armed`)}):u?(0,$.jsx)(W,{variant:`warning`,children:r(`organisation.oidc.test.incomplete`)}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,disabled:_,onClick:b,children:r(`organisation.oidc.actions.runTest`)}),(0,$.jsx)(A,{type:`button`,size:`sm`,disabled:_||!y,onClick:()=>{h(null),x({enabled:!0}).then(()=>{l(null),d(!1),s(null)}).catch(h)},children:r(`organisation.oidc.actions.turnOn`)})]}),y?null:(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:r(`organisation.oidc.test.gate`)})]});return(0,$.jsxs)(`section`,{id:Zt,className:`scroll-mt-16 space-y-3 rounded-xl border bg-card p-5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(st,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`organisation.oidc.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`organisation.oidc.description`)})]})]}),v?(0,$.jsxs)(`div`,{className:`space-y-3`,"data-testid":`oidc-connected`,children:[(0,$.jsxs)(`div`,{className:`grid gap-2 rounded-lg border p-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`organisation.oidc.fields.label`)}),(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:e.label})]}),(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`organisation.oidc.fields.issuer`)}),(0,$.jsx)(`p`,{className:`font-mono text-sm font-medium break-all`,children:e.config.issuer??`-`})]})]}),e.enabled?(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:r(`organisation.oidc.onLabel`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`organisation.oidc.onDescription`,{label:e.label})})]}),(0,$.jsx)(R,{"aria-label":r(`organisation.oidc.onLabel`),checked:!0,disabled:_,onCheckedChange:()=>void x({enabled:!1}).catch(h)})]}):(0,$.jsx)(W,{variant:`warning`,children:r(`organisation.oidc.savedNotOn`)}),m!==null&&o===null?(0,$.jsx)(W,{variant:`error`,children:Ko(m,r)}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.enabled?null:(0,$.jsx)(A,{type:`button`,size:`sm`,disabled:_,onClick:()=>s(`test`),children:r(`organisation.oidc.actions.testAndTurnOn`)}),(0,$.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,disabled:_,onClick:()=>s(`connection`),children:r(`organisation.oidc.actions.edit`)})]})]}):(0,$.jsxs)(`div`,{className:`space-y-2`,"data-testid":`oidc-empty`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`organisation.oidc.empty`)}),(0,$.jsx)(A,{type:`button`,size:`sm`,disabled:_,onClick:()=>s(`connection`),children:r(`organisation.oidc.actions.connect`)})]}),o===null?null:(0,$.jsx)(_s,{provider:e,startAt:o,mutations:t,onClose:()=>s(null),onConnectionSaved:()=>{l(null),d(!1),h(null)},children:S})]})}var ys=`__none__`;function bs({provider:e,roles:t,mutations:n,disabled:r=!1}){let{t:i}=k(),a=r||n.updateProvider.isPending,o=n.updateProvider.error?Ko(n.updateProvider.error,i):null,s=t=>void n.updateProvider.mutateAsync({providerId:e.id,payload:t}).catch(()=>void 0),c=t.find(t=>t.id===e.unknownIdentityRoleId)?.slug===`admin`,l=[{key:`identity`,label:i(`organisation.reverseProxy.identityHeader`),value:e.config.identityHeader,variable:`CODEX_LB_DASHBOARD_AUTH_PROXY_HEADER`},{key:`groups`,label:i(`organisation.reverseProxy.groupsHeader`),value:e.config.groupsHeader,variable:`CODEX_LB_DASHBOARD_AUTH_PROXY_GROUPS_HEADER`}];return(0,$.jsxs)(`section`,{id:`organisation-reverse-proxy`,className:`scroll-mt-16 space-y-3 rounded-xl border bg-card p-5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(C,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:i(`organisation.reverseProxy.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`organisation.reverseProxy.description`)})]})]}),o?(0,$.jsx)(W,{variant:`error`,children:o}):null,e.active?null:(0,$.jsx)(`p`,{className:`rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-xs text-foreground`,children:i(`organisation.reverseProxy.inactiveNote`)}),(0,$.jsx)(`div`,{className:`grid gap-2 rounded-lg border p-3 sm:grid-cols-2`,children:l.map(e=>(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.label}),(0,$.jsx)(`p`,{className:`font-mono text-sm font-medium`,children:e.value||`-`}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:i(`organisation.reverseProxy.setVia`,{variable:e.variable})})]},e.key))}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(Ee,{htmlFor:`organisation-unknown-identity`,className:`text-xs font-medium`,children:i(`organisation.reverseProxy.unknownIdentity.label`)}),(0,$.jsxs)(x,{value:e.unknownIdentityRoleId??ys,disabled:a||t.length===0,onValueChange:e=>s({unknownIdentityRoleId:e===ys?null:e}),children:[(0,$.jsx)(y,{id:`organisation-unknown-identity`,"aria-label":i(`organisation.reverseProxy.unknownIdentity.label`),children:(0,$.jsx)(b,{})}),(0,$.jsxs)(v,{children:[(0,$.jsx)(_,{value:ys,children:i(`organisation.reverseProxy.unknownIdentity.refuse`)}),(0,$.jsx)(Tn,{roles:t})]})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:i(`organisation.reverseProxy.unknownIdentity.help`)}),c?(0,$.jsx)(W,{variant:`warning`,children:i(`organisation.reverseProxy.unknownIdentity.adminNote`)}):null]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(Ee,{htmlFor:`organisation-no-match`,className:`text-xs font-medium`,children:i(`organisation.reverseProxy.noMatch.label`)}),(0,$.jsxs)(x,{value:e.noMatchRoleId??ys,disabled:a||t.length===0,onValueChange:e=>s({noMatchRoleId:e===ys?null:e}),children:[(0,$.jsx)(y,{id:`organisation-no-match`,"aria-label":i(`organisation.reverseProxy.noMatch.label`),children:(0,$.jsx)(b,{})}),(0,$.jsxs)(v,{children:[(0,$.jsx)(_,{value:ys,children:i(`organisation.reverseProxy.noMatch.turnOff`)}),(0,$.jsx)(Tn,{roles:t})]})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:i(`organisation.reverseProxy.noMatch.help`)})]})]}),(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:i(`organisation.reverseProxy.linkByEmail.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`organisation.reverseProxy.linkByEmail.description`)})]}),(0,$.jsx)(R,{"aria-label":i(`organisation.reverseProxy.linkByEmail.label`),checked:e.linkByEmail,disabled:a,onCheckedChange:e=>s({linkByEmail:e})})]}),(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:i(`organisation.reverseProxy.skipRoleSync.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`organisation.reverseProxy.skipRoleSync.description`)})]}),(0,$.jsx)(R,{"aria-label":i(`organisation.reverseProxy.skipRoleSync.label`),checked:e.skipRoleSync,disabled:a,onCheckedChange:e=>s({skipRoleSync:e})})]})]})}var xs={show:`organisation.group.show`,hide:`organisation.group.hide`,title:`organisation.group.title`},Ss={...xs,description:`organisation.group.oneLiner`},Cs={...xs,description:`organisation.group.summary`},ws={...xs,description:`organisation.group.summaryRestricted`},Ts={...xs,description:`organisation.group.summaryPolicyOnly`},Es={...xs,description:`organisation.group.summaryAutomatic`},Ds={...xs,description:`organisation.group.summaryAutomaticRestricted`},Os={...xs,description:`organisation.group.summaryNamed`},ks={...xs,description:`organisation.group.summaryNamedRestricted`};function As({configured:e,companyLogin:t,automatic:n,restricted:r,named:i}){return e?t?i?r?ks:Os:r?ws:Cs:n?r?Ds:Es:Ts:Ss}var js=[Lo,Ro,Bo],Ms={[yt]:it,[Kt]:Zt,[Yt]:qe};function Ns({refusedOpen:e,disabled:t}){let{t:n}=k(),r=B(`users:manage`),i=B(`audit:read`),a=Jo(),o=Yo(),s=Xo(),c=bn(r),l=qo(),u=Zo(),d=$o();if(a.isLoading||o.isLoading||s.isLoading)return(0,$.jsx)(Ft,{});let f=gn(a.data),p=yn(a.data),m=s.data??[],h=(0,$.jsx)(us,{settingsQuery:l,usersQuery:c,canSeeAccounts:r,mutations:d,disabled:t});return(0,$.jsxs)($.Fragment,{children:[p===null?null:(0,$.jsx)(vs,{provider:p,mutations:d,disabled:t}),f===null?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`organisation.group.noReverseProxy`)}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(bs,{provider:f,roles:m,mutations:d,disabled:t}),(0,$.jsx)(cs,{provider:f,roles:m,rules:xn(o.data,f),mutations:d,canReadAudit:i,refusedOpen:e,disabled:t})]}),h,(0,$.jsx)(ts,{tokensQuery:u,providers:a.data,mutations:d,disabled:t})]})}function Ps({disabled:e=!1}){let{search:t,hash:n}=dt(),r=B(`security:write`),i=z(e=>e.accessSummary),a=z(e=>e.loginHint.providers);if(!r)return null;let o=In(a),s=As({configured:En(i),companyLogin:An(i),automatic:wn(i),restricted:qn(i),named:o!==null}),c=Je(t,n);return(0,$.jsx)(`div`,{id:xt,className:`scroll-mt-16`,children:(0,$.jsx)(so,{defaultOpen:c,scrollToId:c?Ms[n]??`organisation`:void 0,waitForQueryKeys:js,labels:s,descriptionValues:{count:i?.roleMappings??0,provider:o??``},descriptionTestId:`organisation-group-line`,children:(0,$.jsx)(Ns,{refusedOpen:n===lt,disabled:e})},c?`open:${n}`:`closed`)})}var Fs=[{value:`light`,labelKey:`settings.appearance.theme.light`,icon:kr},{value:`dark`,labelKey:`settings.appearance.theme.dark`,icon:_r},{value:`auto`,labelKey:`settings.appearance.theme.auto`,icon:hr}],Is=[{value:`12h`,labelKey:`settings.appearance.timeFormat.h12`},{value:`24h`,labelKey:`settings.appearance.timeFormat.h24`}],Ls=[{value:`default`,labelKey:`settings.appearance.dateFormat.default`},{value:`iso8601`,labelKey:`settings.appearance.dateFormat.iso8601`}],Rs=[5,15,30,60],zs=[{value:`5h`,labelKey:`settings.appearance.accountRows.fiveHour`,descriptionKey:`settings.appearance.accountRows.fiveHourDescription`},{value:`weekly`,labelKey:`settings.appearance.accountRows.weekly`,descriptionKey:`settings.appearance.accountRows.weeklyDescription`},{value:`both`,labelKey:`settings.appearance.accountRows.both`,descriptionKey:`settings.appearance.accountRows.bothDescription`}];function Bs(){let{t:e}=k(),t=qt(e=>e.preference),n=qt(e=>e.setTheme),r=Qe(e=>e.timeFormat),i=Qe(e=>e.setTimeFormat),a=D(e=>e.quotaDisplay),o=D(e=>e.setQuotaDisplay),s=Vt(e=>e.accountBurnrateEnabled),c=Vt(e=>e.setAccountBurnrateEnabled),l=gt(e=>e.dateDisplayFormat),u=gt(e=>e.setDateDisplayFormat),d=Vt(e=>e.refreshSeconds),f=Vt(e=>e.setRefreshSeconds);return(0,$.jsx)(`section`,{className:`rounded-xl border bg-card p-5`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(yr,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:e(`settings.appearance.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings.appearance.description`)})]})]})}),(0,$.jsxs)(`div`,{className:`divide-y rounded-lg border`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:e(`settings.appearance.theme.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings.appearance.theme.description`)})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1 rounded-lg border border-border/50 bg-muted/40 p-0.5`,children:Fs.map(({value:r,labelKey:i,icon:a})=>(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t===r,onClick:()=>n(r),className:he(`flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors duration-200`,t===r?`bg-background text-foreground shadow-[var(--shadow-xs)]`:`text-muted-foreground hover:text-foreground`),children:[(0,$.jsx)(a,{className:`h-3.5 w-3.5`}),e(i)]},r))})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:e(`settings.appearance.timeFormat.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings.appearance.timeFormat.description`)})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1 rounded-lg border border-border/50 bg-muted/40 p-0.5`,children:Is.map(({value:t,labelKey:n})=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":r===t,onClick:()=>i(t),className:he(`rounded-md px-3 py-1.5 text-left text-xs font-medium transition-colors duration-200`,r===t?`bg-background text-foreground shadow-[var(--shadow-xs)]`:`text-muted-foreground hover:text-foreground`),children:(0,$.jsx)(`span`,{className:`block`,children:e(n)})},t))})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:e(`settings.appearance.dateFormat.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings.appearance.dateFormat.description`)})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1 rounded-lg border border-border/50 bg-muted/40 p-0.5`,children:Ls.map(({value:t,labelKey:n})=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":l===t,onClick:()=>u(t),className:he(`rounded-md px-3 py-1.5 text-left text-xs font-medium transition-colors duration-200`,l===t?`bg-background text-foreground shadow-[var(--shadow-xs)]`:`text-muted-foreground hover:text-foreground`),children:(0,$.jsx)(`span`,{className:`block`,children:e(n)})},t))})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:e(`settings.appearance.accountRows.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings.appearance.accountRows.description`)})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1 rounded-lg border border-border/50 bg-muted/40 p-0.5`,children:zs.map(({value:t,labelKey:n,descriptionKey:r})=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":a===t,title:e(r),onClick:()=>o(t),className:he(`rounded-md px-3 py-1.5 text-left text-xs font-medium transition-colors duration-200`,a===t?`bg-background text-foreground shadow-[var(--shadow-xs)]`:`text-muted-foreground hover:text-foreground`),children:(0,$.jsx)(`span`,{className:`block`,children:e(n)})},t))})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:e(`settings.appearance.refreshRate.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings.appearance.refreshRate.description`)})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1 rounded-lg border border-border/50 bg-muted/40 p-0.5`,children:Rs.map(t=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":d===t,onClick:()=>f(t),className:he(`rounded-md px-3 py-1.5 text-left text-xs font-medium transition-colors duration-200`,d===t?`bg-background text-foreground shadow-[var(--shadow-xs)]`:`text-muted-foreground hover:text-foreground`),children:e(`settings.appearance.refreshRate.seconds`,{seconds:t})},t))})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:e(`settings.appearance.burnProjection.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings.appearance.burnProjection.description`)})]}),(0,$.jsx)(R,{"aria-label":e(`settings.appearance.burnProjection.ariaLabel`),checked:s,onCheckedChange:c})]})]})]})})}var Vs=`conversation_archive_enabled`;function Hs({settings:e,busy:t,onSave:n}){let{t:r}=k(),[i,a]=(0,Q.useState)(!1),o=e.conversationArchiveEnabled,s=e.provenance?.[Vs],c=!o&&s?.source===`dashboard`&&s.envValue===!0,l=t=>void n(X(e,{conversationArchiveEnabled:t}));return(0,$.jsxs)(`section`,{className:`rounded-xl border bg-card p-5`,children:[(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(Yn,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`settings.conversationArchive.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings.conversationArchive.description`)})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:r(`settings.conversationArchive.toggle.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings.conversationArchive.toggle.description`)}),(0,$.jsx)(Z,{settings:e,name:Vs,field:`conversationArchiveEnabled`,busy:t,onSave:n,resetBlockedReason:c?r(`settings.conversationArchive.resetBlocked`):void 0})]}),(0,$.jsx)(R,{"aria-label":r(`settings.conversationArchive.toggle.ariaLabel`),checked:o,disabled:t,onCheckedChange:e=>{e?a(!0):l(!1)}})]}),o?(0,$.jsx)(`div`,{role:`status`,className:`rounded-lg border border-amber-500/20 bg-amber-500/10 px-3 py-2 text-xs font-medium text-foreground`,children:r(`settings.conversationArchive.recordingNotice`)}):null,(0,$.jsxs)(`div`,{className:`space-y-1 rounded-lg border p-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:r(`settings.conversationArchive.directory.label`)}),(0,$.jsx)(`code`,{className:`block break-all rounded bg-muted px-2 py-1 font-mono text-xs`,children:e.conversationArchiveDir??r(`settings.conversationArchive.directory.unavailable`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings.conversationArchive.directory.note`)})]})]}),(0,$.jsx)(en,{open:i,title:r(`settings.conversationArchive.confirm.title`),description:r(`settings.conversationArchive.confirm.description`),confirmLabel:r(`settings.conversationArchive.confirm.action`),onConfirm:()=>{a(!1),l(!0)},onOpenChange:a})]})}var Us=3650,Ws=30,Gs=45,Ks=/^\d+$/,qs=/^\d+(\.\d+)?$/,Js=[30,90],Ys=31536e4;function Xs(e,t){let n=e.trim();if(n===``)return{valid:!0,value:null};if(!Ks.test(n))return{valid:!1};let r=Number.parseInt(n,10);return!Number.isFinite(r)||r>Us||r!==0&&r<t?{valid:!1}:{valid:!0,value:r}}function Zs(e){return e===null?``:String(e)}function Qs(e,t){let n=e.trim();if(n===``)return{valid:!0,value:null};if(!qs.test(n))return{valid:!1};let r=Number.parseFloat(n);return!Number.isFinite(r)||r<=0||r>Ys||r<t?{valid:!1}:{valid:!0,value:r}}function $s(e){return e.provenance?.http_responses_session_bridge_operation_spool_retention_seconds?.source===`dashboard`?String(e.httpResponsesSessionBridgeOperationSpoolRetentionSeconds):``}function ec({settings:e,busy:t,onSave:n}){let{t:r}=k(),[i,a]=(0,Q.useState)(Zs(e.requestLogRetentionOverrideDays)),[o,s]=(0,Q.useState)(Zs(e.usageHistoryRetentionOverrideDays)),[c,l]=(0,Q.useState)(()=>$s(e)),u=e.httpResponsesSessionBridgeOperationSpoolRetentionFloorSeconds,d=Xs(i,Ws),f=Xs(o,Gs),p=d.valid&&d.value!==e.requestLogRetentionOverrideDays,m=f.valid&&f.value!==e.usageHistoryRetentionOverrideDays,h=Qs(c,u),g=c.trim()!==$s(e),_=h.valid&&g,v=g&&!h.valid,y=d.valid&&f.valid&&!v&&(p||m||_),b=()=>{let t={};p&&d.valid&&(t.requestLogRetentionOverrideDays=d.value),m&&f.valid&&(t.usageHistoryRetentionOverrideDays=f.value),_&&h.valid&&(t.httpResponsesSessionBridgeOperationSpoolRetentionSeconds=h.value),n(X(e,t))},x=e.requestLogRetentionDays===0;return(0,$.jsx)(`section`,{className:`rounded-xl border bg-card p-5`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(ar,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`settings.retention.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings.retention.description`)})]})]})}),x?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings.retention.requestLogs.disabledInfo`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,role:`group`,"aria-label":r(`settings.retention.requestLogs.presetsLabel`),children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:r(`settings.retention.requestLogs.presetsLabel`)}),Js.map(e=>{let n=i===String(e);return(0,$.jsx)(A,{type:`button`,size:`sm`,variant:n?`default`:`outline`,className:`h-7 px-2.5 text-xs`,disabled:t,"aria-pressed":n,onClick:()=>a(String(e)),children:r(`settings.retention.requestLogs.presetButton`,{days:e})},e)})]})]}):null,(0,$.jsxs)(`div`,{className:`divide-y rounded-lg border`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:r(`settings.retention.requestLogs.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings.retention.requestLogs.description`)}),(0,$.jsx)(Z,{settings:e,name:`request_log_retention_days`,field:`requestLogRetentionOverrideDays`,busy:t,onSave:n})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(H,{type:`number`,min:0,max:Us,step:1,inputMode:`numeric`,value:i,disabled:t,placeholder:r(`settings.retention.inheritPlaceholder`),onChange:e=>a(e.target.value),className:`h-8 w-24 text-xs`,"aria-label":r(`settings.retention.requestLogs.ariaLabel`)}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`settings.retention.daysSuffix`)})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:r(`settings.retention.usageHistory.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings.retention.usageHistory.description`)}),(0,$.jsx)(Z,{settings:e,name:`usage_history_retention_days`,field:`usageHistoryRetentionOverrideDays`,busy:t,onSave:n})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(H,{type:`number`,min:0,max:Us,step:1,inputMode:`numeric`,value:o,disabled:t,placeholder:r(`settings.retention.inheritPlaceholder`),onChange:e=>s(e.target.value),className:`h-8 w-24 text-xs`,"aria-label":r(`settings.retention.usageHistory.ariaLabel`)}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`settings.retention.daysSuffix`)})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:r(`settings.retention.spool.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings.retention.spool.description`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings.retention.spool.floorHint`,{seconds:u})}),(0,$.jsx)(Z,{settings:e,name:`http_responses_session_bridge_operation_spool_retention_seconds`,field:`httpResponsesSessionBridgeOperationSpoolRetentionSeconds`,busy:t,onSave:n})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(H,{type:`number`,min:u,max:Ys,step:`any`,inputMode:`decimal`,value:c,disabled:t,placeholder:r(`settings.retention.inheritPlaceholder`),onChange:e=>l(e.target.value),className:`h-8 w-28 text-xs`,"aria-label":r(`settings.retention.spool.ariaLabel`)}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`settings.retention.secondsSuffix`)})]})]})]}),d.valid?null:(0,$.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs font-medium text-destructive`,children:r(`settings.retention.requestLogs.invalid`)}),f.valid?null:(0,$.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs font-medium text-destructive`,children:r(`settings.retention.usageHistory.invalid`)}),v?(0,$.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs font-medium text-destructive`,children:r(`settings.retention.spool.invalid`,{seconds:u})}):null,(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 text-xs`,disabled:t||!y,onClick:b,children:r(`settings.retention.save`)})})]})})}function tc({settings:e,busy:t,onSave:n}){let{t:r}=k(),i=t=>void n(X(e,t));return(0,$.jsx)(`section`,{className:`rounded-xl border bg-card p-5`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(T,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`settings.import.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings.import.description`)})]})]})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:r(`settings.import.allowDuplicates.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings.import.allowDuplicates.description`)})]}),(0,$.jsx)(R,{"aria-label":r(`settings.import.allowDuplicates.ariaLabel`),checked:e.importWithoutOverwrite,disabled:t,onCheckedChange:e=>i({importWithoutOverwrite:e})})]})]})})}var nc={slug:``,contextWindow:``,editing:null};function rc(e){let t=e.trim();if(!/^\d+$/.test(t))return null;let n=Number(t);return Number.isSafeInteger(n)&&n>=1?n:null}function ic({disabled:e=!1}){let{t}=k(),{overridesQuery:n,upsertMutation:r,deleteMutation:i}=kt(),[a,o]=(0,Q.useState)(nc),s=G(),c=(0,Q.useMemo)(()=>V(n.error)||V(r.error)||V(i.error),[n.error,r.error,i.error]),l=n.data?.overrides??[],u=e||r.isPending||i.isPending,d=(a.editing??a.slug).trim(),f=rc(a.contextWindow),p=!u&&d.length>0&&!/\s/.test(d)&&f!==null,m=async()=>{p&&f!==null&&(await r.mutateAsync({slug:d,contextWindow:f}),o(nc))},h=e=>{o({slug:e.slug,contextWindow:String(e.contextWindow),editing:e.slug})};return(0,$.jsxs)(`section`,{id:`model-catalogue`,className:`scroll-mt-16 space-y-3 rounded-xl border bg-card p-5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(Zn,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`settings.modelCatalogue.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings.modelCatalogue.description`)})]})]}),c?(0,$.jsx)(W,{variant:`error`,children:c}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(H,{"aria-label":t(`settings.modelCatalogue.form.slugLabel`),value:a.editing??a.slug,onChange:e=>o(t=>({...t,slug:e.target.value})),placeholder:`gpt-5.4`,className:`h-8 font-mono text-xs`,disabled:u||a.editing!==null}),(0,$.jsx)(H,{"aria-label":t(`settings.modelCatalogue.form.contextWindowLabel`),value:a.contextWindow,onChange:e=>o(t=>({...t,contextWindow:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&m()},inputMode:`numeric`,placeholder:`272000`,className:`h-8 text-xs tabular-nums sm:max-w-[160px]`,disabled:u}),(0,$.jsx)(A,{type:`button`,size:`sm`,className:`h-8 text-xs`,onClick:()=>void m(),disabled:!p,children:a.editing===null?t(`settings.modelCatalogue.actions.add`):t(`common.actions.save`)}),a.editing===null?null:(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>o(nc),disabled:u,children:t(`common.cancel`)})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:t(`settings.modelCatalogue.clampHint`)}),n.isLoading&&!n.data?(0,$.jsx)(`div`,{className:`py-8`,children:(0,$.jsx)(Ft,{})}):l.length===0?(0,$.jsx)(dn,{icon:Zn,title:t(`settings.modelCatalogue.empty.title`),description:t(`settings.modelCatalogue.empty.description`)}):(0,$.jsx)(`div`,{className:`overflow-x-auto rounded-xl border`,children:(0,$.jsxs)(hn,{children:[(0,$.jsx)(fn,{children:(0,$.jsxs)(mn,{children:[(0,$.jsx)(J,{children:t(`settings.modelCatalogue.table.model`)}),(0,$.jsx)(J,{children:t(`settings.modelCatalogue.table.contextWindow`)}),(0,$.jsx)(J,{children:t(`settings.modelCatalogue.table.source`)}),(0,$.jsx)(J,{className:`w-[200px] text-right`,children:t(`apiKeys.table.actions`)})]})}),(0,$.jsx)(pn,{children:l.map(e=>(0,$.jsxs)(mn,{children:[(0,$.jsx)(Y,{className:`font-mono text-xs`,children:e.slug}),(0,$.jsx)(Y,{className:`text-xs tabular-nums`,children:e.contextWindow.toLocaleString()}),(0,$.jsx)(Y,{children:e.source===`dashboard`?(0,$.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(K,{variant:`secondary`,className:`text-[10px] font-normal`,children:t(`settings.modelCatalogue.source.dashboard`)}),e.envValue===null?null:(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t(`settings.modelCatalogue.source.environmentValue`,{value:e.envValue.toLocaleString()})})]}):(0,$.jsx)(K,{variant:`outline`,className:`text-[10px] font-normal`,children:t(`settings.inherit.environment`,{value:e.contextWindow.toLocaleString()})})}),(0,$.jsx)(Y,{className:`text-right`,children:e.source===`dashboard`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`ghost`,disabled:u,onClick:()=>h(e),children:t(`common.actions.edit`)}),(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`ghost`,className:`text-destructive hover:text-destructive`,disabled:u,onClick:()=>s.show(e),children:e.envValue===null?t(`common.actions.remove`):t(`settings.inherit.reset`)})]}):(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`ghost`,disabled:u,onClick:()=>h(e),children:t(`settings.modelCatalogue.actions.override`)})})]},e.slug))})]})}),(0,$.jsx)(en,{open:s.open,title:s.data?.envValue==null?t(`settings.modelCatalogue.removeDialog.title`):t(`settings.modelCatalogue.removeDialog.resetTitle`),description:s.data?.envValue==null?t(`settings.modelCatalogue.removeDialog.description`,{slug:s.data?.slug??``}):t(`settings.modelCatalogue.removeDialog.resetDescription`,{slug:s.data?.slug??``,value:s.data?.envValue.toLocaleString()??``}),confirmLabel:s.data?.envValue==null?t(`common.actions.remove`):t(`settings.inherit.reset`),onOpenChange:s.onOpenChange,onConfirm:()=>{s.data&&i.mutateAsync(s.data.slug).finally(()=>{s.hide()})}})]})}function ac({settings:e,busy:t,onSave:n}){let{t:r}=k(),i=t=>void n(X(e,t));return(0,$.jsx)(`section`,{className:`rounded-xl border bg-card p-5`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(ae,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`settings.resetCredits.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings.resetCredits.description`)})]})]})}),(0,$.jsx)(oc,{label:r(`settings.resetCredits.badges.label`),description:r(`settings.resetCredits.badges.description`),ariaLabel:r(`settings.resetCredits.badges.ariaLabel`),checked:e.showResetCreditBadges,disabled:t,onCheckedChange:e=>i({showResetCreditBadges:e})}),(0,$.jsx)(oc,{label:r(`settings.resetCredits.expiryBadge.label`),description:r(`settings.resetCredits.expiryBadge.description`),ariaLabel:r(`settings.resetCredits.expiryBadge.ariaLabel`),checked:e.showResetCreditExpiryBadge,disabled:t,onCheckedChange:e=>i({showResetCreditExpiryBadge:e})}),(0,$.jsx)(oc,{label:r(`settings.resetCredits.autoRedeem.label`),description:r(`settings.resetCredits.autoRedeem.description`),ariaLabel:r(`settings.resetCredits.autoRedeem.ariaLabel`),checked:e.autoRedeemResetCreditsBeforeExpiry,disabled:t,onCheckedChange:e=>i({autoRedeemResetCreditsBeforeExpiry:e})})]})})}function oc({label:e,description:t,ariaLabel:n,checked:r,disabled:i,onCheckedChange:a}){return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:e}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t})]}),(0,$.jsx)(R,{"aria-label":n,checked:r,disabled:i,onCheckedChange:a})]})}var sc=[{name:`soft_drain_enabled`,field:`softDrainEnabled`,i18nKey:`softDrain`},{name:`deterministic_failover_enabled`,field:`deterministicFailoverEnabled`,i18nKey:`deterministicFailover`},{name:`circuit_breaker_enabled`,field:`circuitBreakerEnabled`,i18nKey:`circuitBreaker`}];function cc({settings:e,busy:t,onSave:n}){let{t:r}=k(),i=t=>void n(X(e,t));return(0,$.jsx)(`section`,{className:`rounded-xl border bg-card p-5`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)($e,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`settings.resilience.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings.resilience.description`)})]})]}),sc.map(a=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:r(`settings.resilience.${a.i18nKey}.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings.resilience.${a.i18nKey}.description`)}),(0,$.jsx)(Z,{settings:e,name:a.name,field:a.field,busy:t,onSave:n})]}),(0,$.jsx)(R,{"aria-label":r(`settings.resilience.${a.i18nKey}.ariaLabel`),checked:e[a.field],disabled:t,onCheckedChange:e=>i({[a.field]:e})})]},a.name))]})})}function lc({settings:e,busy:t,onSave:n}){let{t:r}=k(),i=t=>void n(X(e,t));return(0,$.jsx)(`section`,{className:`rounded-xl border bg-card p-5`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(u,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`settings.sessionBridge.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings.sessionBridge.description`)})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:r(`settings.sessionBridge.codexPrewarm.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings.sessionBridge.codexPrewarm.description`)}),(0,$.jsx)(Z,{settings:e,name:`http_responses_session_bridge_codex_prewarm_enabled`,field:`httpResponsesSessionBridgeCodexPrewarmEnabled`,busy:t,onSave:n})]}),(0,$.jsx)(R,{"aria-label":r(`settings.sessionBridge.codexPrewarm.ariaLabel`),checked:e.httpResponsesSessionBridgeCodexPrewarmEnabled,disabled:t,onCheckedChange:e=>i({httpResponsesSessionBridgeCodexPrewarmEnabled:e})})]})]})})}var uc=[{name:`auth_guardian_enabled`,field:`authGuardianEnabled`,i18nKey:`authGuardian`},{name:`automations_scheduler_enabled`,field:`automationsSchedulerEnabled`,i18nKey:`automations`},{name:`rate_limit_reset_credits_refresh_enabled`,field:`rateLimitResetCreditsRefreshEnabled`,i18nKey:`resetCredits`}];function dc({settings:e,busy:t,onSave:n}){let{t:r}=k(),i=t=>void n(X(e,t));return(0,$.jsx)(`section`,{className:`rounded-xl border bg-card p-5`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(Nr,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`settings.backgroundJobs.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings.backgroundJobs.description`)})]})]}),uc.map(a=>{let o=a.name===`auth_guardian_enabled`&&e.authGuardianBlockedByTopology;return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:r(`settings.backgroundJobs.${a.i18nKey}.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings.backgroundJobs.${a.i18nKey}.description`)}),o?(0,$.jsx)(`p`,{role:`note`,className:`text-xs text-amber-600 dark:text-amber-400`,children:r(`settings.backgroundJobs.authGuardian.blockedByTopology`)}):null,(0,$.jsx)(Z,{settings:e,name:a.name,field:a.field,busy:t,onSave:n})]}),(0,$.jsx)(R,{"aria-label":r(`settings.backgroundJobs.${a.i18nKey}.ariaLabel`),checked:e[a.field],disabled:t,onCheckedChange:e=>i({[a.field]:e})})]},a.name)})]})})}var fc=128,pc=128,mc=512,hc=[{value:0,key:`mon`},{value:1,key:`tue`},{value:2,key:`wed`},{value:3,key:`thu`},{value:4,key:`fri`},{value:5,key:`sat`},{value:6,key:`sun`}],gc=[{value:15,label:`15m`},{value:30,label:`30m`},{value:60,label:`1h`},{value:120,label:`2h`},{value:240,label:`4h`}],_c={capacityWeighted:`capacity_weighted`,relativeAvailability:`relative_availability`,usageWeighted:`usage_weighted`,roundRobin:`round_robin`,fillFirst:`fill_first`,sequentialDrain:`sequential_drain`,resetDrain:`reset_drain`,singleAccount:`single_account`};function vc(e){let t=new Set(e.split(`,`).map(e=>Number(e.trim())).filter(e=>Number.isInteger(e)&&e>=0&&e<=6));return t.size>0?t:new Set(hc.map(e=>e.value))}function yc(e){return Array.from(e).toSorted((e,t)=>e-t).join(`,`)}var bc=[];function xc(e){return`${e.alias?.trim()||e.displayName?.trim()||e.email?.trim()||e.accountId} (${oe(e.accountId,6,4)})`}function Sc(e){return{warmupModel:e.warmupModel,cacheAffinityTtl:String(e.openaiCacheAffinityMaxAgeSeconds),proxyAccountResponseCreateLimit:Dc(e.proxyAccountResponseCreateLimitOverride),proxyAccountStreamLimit:Dc(e.proxyAccountStreamLimitOverride),proxyAccountStreamRecoveryReserve:Dc(e.proxyAccountStreamRecoveryReserveOverride),proxyApiKeyFairShareCongestionThresholdPct:Dc(e.proxyApiKeyFairShareCongestionThresholdPctOverride),proxyOverloadIsolationSeconds:Dc(Oc(e,`proxy_overload_isolation_seconds`,e.proxyOverloadIsolationSeconds)),proxyAccountInflightPenaltyPct:Dc(Oc(e,`proxy_account_inflight_penalty_pct`,e.proxyAccountInflightPenaltyPct)),proxyAccountLeaseTokenWeight:Dc(Oc(e,`proxy_account_lease_token_weight`,e.proxyAccountLeaseTokenWeight)),proxyAccountLeaseTtlSeconds:Dc(Oc(e,`proxy_account_lease_ttl_seconds`,e.proxyAccountLeaseTtlSeconds)),relativeAvailabilityPower:String(e.relativeAvailabilityPower),relativeAvailabilityTopK:String(e.relativeAvailabilityTopK),stickyPrimaryThreshold:String(e.stickyReallocationPrimaryBudgetThresholdPct??95),stickySecondaryThreshold:String(e.stickyReallocationSecondaryBudgetThresholdPct??100),limitWarmupModel:e.limitWarmupModel,limitWarmupPrompt:e.limitWarmupPrompt,limitWarmupCooldown:String(e.limitWarmupCooldownSeconds),limitWarmupExhaustedThreshold:String(e.limitWarmupExhaustedThresholdPercent),limitWarmupIdleThreshold:String(e.limitWarmupIdleThresholdPercent),additionalQuotaKey:``,additionalQuotaPolicy:`inherit`}}function Cc(e,t){return{...e,...t}}function wc(e){let t=e.trim();if(!/^\d+$/.test(t))return null;let n=Number(t);return Number.isSafeInteger(n)&&n>=0?n:null}function Tc(e){let t=Number(e.toFixed(1)),n=Number((100-t).toFixed(1));return{used:String(t),remaining:String(n)}}function Ec(e,t=null){if(e.trim()===``)return{valid:!0,value:null};let n=wc(e);return n===null||t!==null&&n>t?{valid:!1,value:null}:{valid:!0,value:n}}function Dc(e){return e==null?``:String(e)}function Oc(e,t,n){return e.provenance?.[t]?.source===`dashboard`?n:null}function kc(e,t){let n=e.trim();if(n===``)return{valid:!0,value:null};let r=t.integer?/^\d+$/.test(n)?Number(n):NaN:Number(n);return!Number.isFinite(r)||t.min!==void 0&&r<t.min||t.exclusiveMin!==void 0&&r<=t.exclusiveMin||t.max!==void 0&&r>t.max?{valid:!1,value:null}:{valid:!0,value:r}}function Ac({settings:e,accounts:t=bc,accountsLoading:n=!1,busy:r,onSave:i}){let{t:a}=k(),[o,s]=(0,Q.useReducer)(Cc,e,Sc),c=t=>void i(X(e,t)),u=(t,n)=>{let r=t.trim();r&&c({additionalQuotaRoutingPolicies:{...e.additionalQuotaRoutingPolicies??{},[r]:n}})},d=t=>{let n={...e.additionalQuotaRoutingPolicies??{}};delete n[t],c({additionalQuotaRoutingPolicies:n})},f=Number.parseInt(o.cacheAffinityTtl,10),p=Number.isInteger(f)&&f>0&&f!==e.openaiCacheAffinityMaxAgeSeconds,m=Ec(o.proxyAccountResponseCreateLimit),h=Ec(o.proxyAccountStreamLimit),g=Ec(o.proxyAccountStreamRecoveryReserve),S=Ec(o.proxyApiKeyFairShareCongestionThresholdPct,100),C=h.value??e.proxyAccountStreamLimitEnvironmentValue,T=g.value??e.proxyAccountStreamRecoveryReserveEnvironmentValue,E=e.proxyAccountStreamLimitEnvironmentValue,ee=E>0&&e.proxyAccountStreamRecoveryReserve>E?a(`settings.inherit.resetBlockedByReserve`):void 0,D=e.proxyAccountStreamLimit>0&&e.proxyAccountStreamRecoveryReserveEnvironmentValue>e.proxyAccountStreamLimit?a(`settings.inherit.resetBlockedByReserve`):void 0,te=m.valid&&h.valid&&g.valid&&S.valid&&(C===0||T<=C)&&(m.value!==(e.proxyAccountResponseCreateLimitOverride??null)||h.value!==(e.proxyAccountStreamLimitOverride??null)||g.value!==(e.proxyAccountStreamRecoveryReserveOverride??null)||S.value!==(e.proxyApiKeyFairShareCongestionThresholdPctOverride??null)),O={};m.value!==(e.proxyAccountResponseCreateLimitOverride??null)&&(O.proxyAccountResponseCreateLimit=m.value),h.value!==(e.proxyAccountStreamLimitOverride??null)&&(O.proxyAccountStreamLimit=h.value),g.value!==(e.proxyAccountStreamRecoveryReserveOverride??null)&&(O.proxyAccountStreamRecoveryReserve=g.value),S.value!==(e.proxyApiKeyFairShareCongestionThresholdPctOverride??null)&&(O.proxyApiKeyFairShareCongestionThresholdPct=S.value);let ne=[{field:`proxyOverloadIsolationSeconds`,name:`proxy_overload_isolation_seconds`,parsed:kc(o.proxyOverloadIsolationSeconds,{integer:!0,min:0}),current:Oc(e,`proxy_overload_isolation_seconds`,e.proxyOverloadIsolationSeconds)},{field:`proxyAccountInflightPenaltyPct`,name:`proxy_account_inflight_penalty_pct`,parsed:kc(o.proxyAccountInflightPenaltyPct,{min:0,max:100}),current:Oc(e,`proxy_account_inflight_penalty_pct`,e.proxyAccountInflightPenaltyPct)},{field:`proxyAccountLeaseTokenWeight`,name:`proxy_account_lease_token_weight`,parsed:kc(o.proxyAccountLeaseTokenWeight,{min:0}),current:Oc(e,`proxy_account_lease_token_weight`,e.proxyAccountLeaseTokenWeight)},{field:`proxyAccountLeaseTtlSeconds`,name:`proxy_account_lease_ttl_seconds`,parsed:kc(o.proxyAccountLeaseTtlSeconds,{exclusiveMin:0}),current:Oc(e,`proxy_account_lease_ttl_seconds`,e.proxyAccountLeaseTtlSeconds)}],re=ne.every(e=>e.parsed.valid),ie={};for(let e of ne)e.parsed.value!==e.current&&(ie[e.field]=e.parsed.value);let ae=re&&Object.keys(ie).length>0,oe=o.warmupModel.trim()!==e.warmupModel,se=o.warmupModel.trim().length>0&&o.warmupModel.trim().length<=fc,ce=Number(o.limitWarmupCooldown),le=Number.isInteger(ce)&&ce>=60,ue=Number(o.limitWarmupExhaustedThreshold),de=Number.isFinite(ue)&&ue>0&&ue<=100,fe=Number(o.limitWarmupIdleThreshold),pe=Number.isFinite(fe)&&fe>0&&fe<=100,me=o.limitWarmupModel.trim()!==e.limitWarmupModel||o.limitWarmupPrompt.trim()!==e.limitWarmupPrompt||de&&ue!==e.limitWarmupExhaustedThresholdPercent||pe&&fe!==e.limitWarmupIdleThresholdPercent||le&&ce!==e.limitWarmupCooldownSeconds,ge=o.limitWarmupModel.trim().length>0&&o.limitWarmupModel.trim().length<=pc&&o.limitWarmupPrompt.trim().length>0&&o.limitWarmupPrompt.trim().length<=mc&&de&&pe&&le,j=Number.parseFloat(o.relativeAvailabilityPower),_e=Number.isFinite(j)&&j>0&&j!==e.relativeAvailabilityPower,M=o.relativeAvailabilityTopK.trim(),N=Number(M),ve=/^[0-9]+$/.test(M)&&Number.isInteger(N)&&N>=1&&N<=20&&N!==e.relativeAvailabilityTopK,P=e.routingStrategy===`relative_availability`,ye=t.filter(e=>$t(e.status)),F=t.find(t=>t.accountId===e.singleAccountId),be=F!==void 0&&!$t(F.status)?F:null,xe=ye[0]?.accountId,Se=e.additionalQuotaRoutingPolicies??{},Ce=new Set((e.additionalQuotaPolicies??[]).map(e=>e.quotaKey)),we=[...(e.additionalQuotaPolicies??[]).map(e=>({quotaKey:e.quotaKey,label:e.displayLabel||e.quotaKey,policy:e.routingPolicy,hasOverride:Object.prototype.hasOwnProperty.call(Se,e.quotaKey)})),...Object.entries(Se).reduce((e,[t,n])=>(Ce.has(t)||e.push({quotaKey:t,label:t,policy:n,hasOverride:!0}),e),[])],I=Number.parseFloat(o.stickyPrimaryThreshold),L=Number.isFinite(I)&&I>=0&&I<=100,Ee=L&&I!==(e.stickyReallocationPrimaryBudgetThresholdPct??95),De=Number.parseFloat(o.stickySecondaryThreshold),Oe=Number.isFinite(De)&&De>=0&&De<=100,z=Oe&&De!==(e.stickyReallocationSecondaryBudgetThresholdPct??100),B=vc(e.weeklyPaceWorkingDays),ke=(e,t)=>{let n=new Set(B);t?n.add(e):n.size>1&&n.delete(e),c({weeklyPaceWorkingDays:yc(n)})};return(0,$.jsx)(`section`,{className:`rounded-xl border bg-card p-5`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(w,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:a(`settings.routing.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.description`)})]})]})}),(0,$.jsxs)(`div`,{className:`divide-y rounded-lg border`,children:[(0,$.jsxs)(`div`,{className:`space-y-3 p-3`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between gap-4`,children:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:a(`settings.routing.warmupModel.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.warmupModel.description`)})]})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(H,{value:o.warmupModel,disabled:r,maxLength:fc,onChange:e=>s({warmupModel:e.target.value}),className:`h-8 text-xs`,"aria-label":a(`settings.routing.warmupModel.label`)}),(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 text-xs sm:w-24`,disabled:r||!oe||!se,onClick:()=>void c({warmupModel:o.warmupModel.trim()}),children:a(`settings.routing.warmupModel.save`)})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4 p-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:a(`settings.routing.upstream.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.upstream.description`)})]}),(0,$.jsxs)(x,{value:e.upstreamStreamTransport,onValueChange:e=>c({upstreamStreamTransport:e}),children:[(0,$.jsx)(y,{className:`h-8 w-44 text-xs`,disabled:r,children:(0,$.jsx)(b,{})}),(0,$.jsxs)(v,{align:`end`,children:[(0,$.jsx)(_,{value:`auto`,children:a(`settings.routing.upstream.auto`)}),(0,$.jsx)(_,{value:`http`,children:a(`settings.routing.upstream.http`)}),(0,$.jsx)(_,{value:`websocket`,children:a(`settings.routing.upstream.websocket`)})]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4 p-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:a(`settings.routing.fastMode.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.fastMode.description`)})]}),(0,$.jsx)(R,{checked:e.prohibitFastMode,disabled:r,onCheckedChange:e=>c({prohibitFastMode:e}),"aria-label":a(`settings.routing.fastMode.ariaLabel`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4 p-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:a(`settings.routing.httpDownstream.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.httpDownstream.description`)})]}),(0,$.jsxs)(x,{value:e.httpDownstreamTransportPolicy,onValueChange:e=>c({httpDownstreamTransportPolicy:e}),children:[(0,$.jsx)(y,{className:`h-8 w-52 text-xs`,disabled:r,"aria-label":a(`settings.routing.httpDownstream.label`),children:(0,$.jsx)(b,{})}),(0,$.jsx)(v,{align:`end`,children:[`smart`,`always_http`,`always_websocket`,`pinned`].map(e=>(0,$.jsx)(_,{value:e,children:a(`settings.routing.httpDownstream.policies.${e}`)},e))})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2 p-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:a(`settings.routing.strategy.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.strategy.description`)})]}),(0,$.jsx)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[`capacityWeighted`,`relativeAvailability`,`usageWeighted`,`roundRobin`,`fillFirst`,`sequentialDrain`,`resetDrain`,`singleAccount`].map(t=>{let n=_c[t],i=e.routingStrategy===n,o=n===`single_account`&&!e.singleAccountId&&!xe;return(0,$.jsxs)(`button`,{type:`button`,disabled:r||o,onClick:()=>{if(n===`single_account`){let t=e.singleAccountId??xe;if(!t)return;c({routingStrategy:n,singleAccountId:t})}else c({routingStrategy:n})},className:he(`space-y-0.5 rounded-md border p-2 text-left text-xs transition-colors`,i?`border-primary/40 bg-primary/5`:`border-border/40 hover:border-border hover:bg-muted/30`,(r||o)&&`cursor-not-allowed opacity-50`),"aria-pressed":i,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5 font-medium text-foreground text-xs`,children:[i&&(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-primary`,"aria-hidden":`true`}),a(`settings.routing.strategy.${t}`)]}),(0,$.jsx)(`span`,{className:`block pl-3 text-muted-foreground text-xs`,children:a(`settings.routing.strategy.guide.${t}`)})]},t)})}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.strategy.safetyNote`)})]}),(0,$.jsxs)(`div`,{className:`space-y-3 p-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:a(`settings.routing.additionalQuota.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.additionalQuota.description`)})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[we.map(({quotaKey:e,label:t,policy:n,hasOverride:i})=>(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1 truncate rounded-md border bg-muted/20 px-2 py-1.5 text-xs`,children:t}),(0,$.jsxs)(x,{value:n,onValueChange:t=>u(e,t),children:[(0,$.jsx)(y,{className:`h-8 w-full text-xs sm:w-36`,disabled:r,"aria-label":a(`settings.routing.additionalQuota.policyAria`,{quotaKey:e}),children:(0,$.jsx)(b,{})}),(0,$.jsxs)(v,{align:`end`,children:[(0,$.jsx)(_,{value:`inherit`,children:a(`settings.routing.additionalQuota.policies.inherit`)}),(0,$.jsx)(_,{value:`normal`,children:a(`settings.routing.additionalQuota.policies.normal`)}),(0,$.jsx)(_,{value:`burn_first`,children:a(`settings.routing.additionalQuota.policies.burnFirst`)}),(0,$.jsx)(_,{value:`preserve`,children:a(`settings.routing.additionalQuota.policies.preserve`)})]})]}),i?(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 text-xs sm:w-20`,disabled:r,onClick:()=>d(e),children:a(`settings.routing.additionalQuota.reset`)}):null]},e)),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,$.jsx)(H,{value:o.additionalQuotaKey,disabled:r,onChange:e=>s({additionalQuotaKey:e.target.value}),className:`h-8 text-xs`,"aria-label":a(`settings.routing.additionalQuota.keyAria`),placeholder:a(`settings.routing.additionalQuota.keyPlaceholder`)}),(0,$.jsxs)(x,{value:o.additionalQuotaPolicy,onValueChange:e=>s({additionalQuotaPolicy:e}),children:[(0,$.jsx)(y,{className:`h-8 w-full text-xs sm:w-36`,disabled:r,"aria-label":a(`settings.routing.additionalQuota.selectAria`),children:(0,$.jsx)(b,{})}),(0,$.jsxs)(v,{align:`end`,children:[(0,$.jsx)(_,{value:`inherit`,children:a(`settings.routing.additionalQuota.policies.inherit`)}),(0,$.jsx)(_,{value:`normal`,children:a(`settings.routing.additionalQuota.policies.normal`)}),(0,$.jsx)(_,{value:`burn_first`,children:a(`settings.routing.additionalQuota.policies.burnFirst`)}),(0,$.jsx)(_,{value:`preserve`,children:a(`settings.routing.additionalQuota.policies.preserve`)})]})]}),(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 text-xs sm:w-24`,disabled:r||!o.additionalQuotaKey.trim(),onClick:()=>u(o.additionalQuotaKey,o.additionalQuotaPolicy),children:a(`settings.routing.additionalQuota.save`)})]})]})]}),P?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:a(`settings.routing.relativeAvailability.powerLabel`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.relativeAvailability.powerDescription`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(H,{"aria-label":a(`settings.routing.relativeAvailability.powerLabel`),type:`number`,min:.1,step:.1,inputMode:`decimal`,value:o.relativeAvailabilityPower,disabled:r,onChange:e=>s({relativeAvailabilityPower:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&_e&&c({relativeAvailabilityPower:j})},className:`h-8 w-28 text-xs`}),(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 text-xs`,disabled:r||!_e,onClick:()=>void c({relativeAvailabilityPower:j}),children:a(`settings.routing.relativeAvailability.savePower`)})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:a(`settings.routing.relativeAvailability.topKLabel`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.relativeAvailability.topKDescription`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(H,{"aria-label":a(`settings.routing.relativeAvailability.topKLabel`),type:`number`,min:1,max:20,step:1,inputMode:`numeric`,value:o.relativeAvailabilityTopK,disabled:r,onChange:e=>s({relativeAvailabilityTopK:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&ve&&c({relativeAvailabilityTopK:N})},className:`h-8 w-28 text-xs`}),(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 text-xs`,disabled:r||!ve,onClick:()=>void c({relativeAvailabilityTopK:N}),children:a(`settings.routing.relativeAvailability.saveTopK`)})]})]})]}):null,e.routingStrategy===`single_account`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:a(`settings.routing.singleAccount.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.singleAccount.description`)})]}),(0,$.jsxs)(x,{value:e.singleAccountId??void 0,onValueChange:e=>c({singleAccountId:e}),children:[(0,$.jsx)(y,{"aria-label":a(`settings.routing.singleAccount.label`),className:`h-8 w-full text-xs sm:w-64`,disabled:r||n||ye.length===0,children:(0,$.jsx)(b,{placeholder:a(n?`settings.routing.singleAccount.loading`:`settings.routing.singleAccount.placeholder`)})}),(0,$.jsxs)(v,{align:`end`,children:[be?(0,$.jsx)(_,{value:be.accountId,disabled:!0,children:xc(be)},be.accountId):null,ye.map(e=>(0,$.jsx)(_,{value:e.accountId,children:xc(e)},e.accountId))]})]}),!n&&ye.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.singleAccount.empty`)}):null]}):null,(0,$.jsxs)(`div`,{className:`space-y-3 p-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:a(`settings.routing.overload.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.overload.description`)})]}),(0,$.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`block space-y-1`,children:[(0,$.jsx)(`span`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`settings.routing.overload.isolationSecondsLabel`)}),(0,$.jsx)(H,{"aria-label":a(`settings.routing.overload.isolationSecondsLabel`),type:`number`,min:0,step:1,inputMode:`numeric`,className:`h-8 text-xs`,value:o.proxyOverloadIsolationSeconds,placeholder:a(`settings.routing.overload.inheritPlaceholder`),onChange:e=>s({proxyOverloadIsolationSeconds:e.target.value})}),(0,$.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:a(`settings.routing.overload.isolationSecondsDescription`)}),(0,$.jsx)(Z,{settings:e,name:`proxy_overload_isolation_seconds`,field:`proxyOverloadIsolationSeconds`,busy:r,onSave:i})]}),(0,$.jsxs)(`label`,{className:`block space-y-1`,children:[(0,$.jsx)(`span`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`settings.routing.overload.inflightPenaltyPctLabel`)}),(0,$.jsx)(H,{"aria-label":a(`settings.routing.overload.inflightPenaltyPctLabel`),type:`number`,min:0,max:100,step:`any`,inputMode:`decimal`,className:`h-8 text-xs`,value:o.proxyAccountInflightPenaltyPct,placeholder:a(`settings.routing.overload.inheritPlaceholder`),onChange:e=>s({proxyAccountInflightPenaltyPct:e.target.value})}),(0,$.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:a(`settings.routing.overload.inflightPenaltyPctDescription`)}),(0,$.jsx)(Z,{settings:e,name:`proxy_account_inflight_penalty_pct`,field:`proxyAccountInflightPenaltyPct`,busy:r,onSave:i})]}),(0,$.jsxs)(`label`,{className:`block space-y-1`,children:[(0,$.jsx)(`span`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`settings.routing.overload.leaseTokenWeightLabel`)}),(0,$.jsx)(H,{"aria-label":a(`settings.routing.overload.leaseTokenWeightLabel`),type:`number`,min:0,step:`any`,inputMode:`decimal`,className:`h-8 text-xs`,value:o.proxyAccountLeaseTokenWeight,placeholder:a(`settings.routing.overload.inheritPlaceholder`),onChange:e=>s({proxyAccountLeaseTokenWeight:e.target.value})}),(0,$.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:a(`settings.routing.overload.leaseTokenWeightDescription`)}),(0,$.jsx)(Z,{settings:e,name:`proxy_account_lease_token_weight`,field:`proxyAccountLeaseTokenWeight`,busy:r,onSave:i})]}),(0,$.jsxs)(`label`,{className:`block space-y-1`,children:[(0,$.jsx)(`span`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`settings.routing.overload.leaseTtlSecondsLabel`)}),(0,$.jsx)(H,{"aria-label":a(`settings.routing.overload.leaseTtlSecondsLabel`),type:`number`,min:0,step:`any`,inputMode:`decimal`,className:`h-8 text-xs`,value:o.proxyAccountLeaseTtlSeconds,placeholder:a(`settings.routing.overload.inheritPlaceholder`),onChange:e=>s({proxyAccountLeaseTtlSeconds:e.target.value})}),(0,$.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:a(`settings.routing.overload.leaseTtlSecondsDescription`)}),(0,$.jsx)(Z,{settings:e,name:`proxy_account_lease_ttl_seconds`,field:`proxyAccountLeaseTtlSeconds`,busy:r,onSave:i})]})]}),(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 text-xs sm:w-44`,disabled:r||!ae,onClick:()=>void c(ie),children:a(`settings.routing.overload.save`)}),(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-t pt-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:a(`settings.routing.overload.errorRateWeightingLabel`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.overload.errorRateWeightingDescription`)}),(0,$.jsx)(Z,{settings:e,name:`proxy_account_error_rate_weighting_enabled`,field:`proxyAccountErrorRateWeightingEnabled`,busy:r,onSave:i})]}),(0,$.jsx)(R,{"aria-label":a(`settings.routing.overload.errorRateWeightingAriaLabel`),checked:e.proxyAccountErrorRateWeightingEnabled,disabled:r,onCheckedChange:e=>c({proxyAccountErrorRateWeightingEnabled:e})})]})]}),(0,$.jsxs)(`div`,{className:`space-y-3 p-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:a(`settings.routing.accountCapacity.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.accountCapacity.description`)})]}),(0,$.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[(0,$.jsxs)(`label`,{className:`block space-y-1`,children:[(0,$.jsx)(`span`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`settings.routing.accountCapacity.responseCreateLabel`)}),(0,$.jsx)(H,{"aria-label":a(`settings.routing.accountCapacity.responseCreateLabel`),type:`number`,min:0,step:1,inputMode:`numeric`,value:o.proxyAccountResponseCreateLimit,placeholder:a(`settings.routing.accountCapacity.inheritPlaceholder`),disabled:r,onChange:e=>s({proxyAccountResponseCreateLimit:e.target.value}),className:`h-8 text-xs`}),(0,$.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:a(`settings.routing.accountCapacity.responseCreateDescription`)}),(0,$.jsx)(Z,{settings:e,name:`proxy_account_response_create_limit`,field:`proxyAccountResponseCreateLimit`,busy:r,onSave:i,fallbackValue:o.proxyAccountResponseCreateLimit.trim()===``?e.proxyAccountResponseCreateLimitEnvironmentValue:void 0})]}),(0,$.jsxs)(`label`,{className:`block space-y-1`,children:[(0,$.jsx)(`span`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`settings.routing.accountCapacity.streamLabel`)}),(0,$.jsx)(H,{"aria-label":a(`settings.routing.accountCapacity.streamLabel`),type:`number`,min:0,step:1,inputMode:`numeric`,value:o.proxyAccountStreamLimit,placeholder:a(`settings.routing.accountCapacity.inheritPlaceholder`),disabled:r,onChange:e=>s({proxyAccountStreamLimit:e.target.value}),className:`h-8 text-xs`}),(0,$.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:a(`settings.routing.accountCapacity.streamDescription`)}),(0,$.jsx)(Z,{settings:e,name:`proxy_account_stream_limit`,field:`proxyAccountStreamLimit`,busy:r,onSave:i,resetBlockedReason:ee,fallbackValue:o.proxyAccountStreamLimit.trim()===``?e.proxyAccountStreamLimitEnvironmentValue:void 0})]}),(0,$.jsxs)(`label`,{className:`block space-y-1`,children:[(0,$.jsx)(`span`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`settings.routing.accountCapacity.streamRecoveryReserveLabel`)}),(0,$.jsx)(H,{"aria-label":a(`settings.routing.accountCapacity.streamRecoveryReserveLabel`),type:`number`,min:0,step:1,inputMode:`numeric`,value:o.proxyAccountStreamRecoveryReserve,placeholder:a(`settings.routing.accountCapacity.inheritPlaceholder`),disabled:r,onChange:e=>s({proxyAccountStreamRecoveryReserve:e.target.value}),className:`h-8 text-xs`}),(0,$.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:a(`settings.routing.accountCapacity.streamRecoveryReserveDescription`)}),(0,$.jsx)(Z,{settings:e,name:`proxy_account_stream_recovery_reserve`,field:`proxyAccountStreamRecoveryReserve`,busy:r,onSave:i,resetBlockedReason:D,fallbackValue:o.proxyAccountStreamRecoveryReserve.trim()===``?e.proxyAccountStreamRecoveryReserveEnvironmentValue:void 0})]}),(0,$.jsxs)(`label`,{className:`block space-y-1`,children:[(0,$.jsx)(`span`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`settings.routing.accountCapacity.fairShareThresholdLabel`)}),(0,$.jsx)(H,{"aria-label":a(`settings.routing.accountCapacity.fairShareThresholdLabel`),type:`number`,min:0,max:100,step:1,inputMode:`numeric`,value:o.proxyApiKeyFairShareCongestionThresholdPct,placeholder:a(`settings.routing.accountCapacity.inheritPlaceholder`),disabled:r,onChange:e=>s({proxyApiKeyFairShareCongestionThresholdPct:e.target.value}),className:`h-8 text-xs`}),(0,$.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:a(`settings.routing.accountCapacity.fairShareThresholdDescription`)}),(0,$.jsx)(Z,{settings:e,name:`proxy_api_key_fair_share_congestion_threshold_pct`,field:`proxyApiKeyFairShareCongestionThresholdPct`,busy:r,onSave:i,fallbackValue:o.proxyApiKeyFairShareCongestionThresholdPct.trim()===``?e.proxyApiKeyFairShareCongestionThresholdPctEnvironmentValue:void 0})]})]}),(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 text-xs sm:w-40`,disabled:r||!te,onClick:()=>void c(O),children:a(`settings.routing.accountCapacity.save`)})]}),(0,$.jsxs)(`div`,{className:`space-y-2 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:a(`settings.routing.stickyThreads.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.stickyThreads.description`)})]}),(0,$.jsx)(R,{"aria-label":a(`settings.routing.stickyThreads.ariaLabel`),checked:e.stickyThreadsEnabled,disabled:r,onCheckedChange:e=>c({stickyThreadsEnabled:e})})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.stickyThreads.hardAffinityNote`)})]}),(0,$.jsxs)(`div`,{className:`space-y-1 p-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:a(`settings.routing.quotaWindows.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.quotaWindows.explainer`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:a(`settings.routing.stickyThresholds.primaryLabel`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.stickyThresholds.primaryDescription`)}),L?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.stickyThresholds.usedRemainingHint`,Tc(I))}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(H,{"aria-label":a(`settings.routing.stickyThresholds.primaryLabel`),type:`number`,min:0,max:100,step:.1,inputMode:`decimal`,value:o.stickyPrimaryThreshold,disabled:r,onChange:e=>s({stickyPrimaryThreshold:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&Ee&&c({stickyReallocationPrimaryBudgetThresholdPct:I})},className:`h-8 w-28 text-xs`}),(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 text-xs`,disabled:r||!Ee,onClick:()=>void c({stickyReallocationPrimaryBudgetThresholdPct:I}),children:a(`settings.routing.stickyThresholds.savePrimary`)})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:a(`settings.routing.stickyThresholds.secondaryLabel`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.stickyThresholds.secondaryDescription`)}),Oe?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.stickyThresholds.usedRemainingHint`,Tc(De))}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(H,{"aria-label":a(`settings.routing.stickyThresholds.secondaryLabel`),type:`number`,min:0,max:100,step:.1,inputMode:`decimal`,value:o.stickySecondaryThreshold,disabled:r,onChange:e=>s({stickySecondaryThreshold:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&z&&c({stickyReallocationSecondaryBudgetThresholdPct:De})},className:`h-8 w-28 text-xs`}),(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 text-xs`,disabled:r||!z,onClick:()=>void c({stickyReallocationSecondaryBudgetThresholdPct:De}),children:a(`settings.routing.stickyThresholds.saveSecondary`)})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between p-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:a(`settings.routing.preferEarlier.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.preferEarlier.description`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsxs)(x,{value:e.preferEarlierResetWindow,onValueChange:e=>c({preferEarlierResetWindow:e}),children:[(0,$.jsx)(y,{"aria-label":a(`settings.routing.preferEarlier.windowAria`),className:`h-8 w-36 text-xs`,disabled:r||!e.preferEarlierResetAccounts,children:(0,$.jsx)(b,{})}),(0,$.jsxs)(v,{align:`end`,children:[(0,$.jsx)(_,{value:`secondary`,children:a(`settings.routing.quotaWindows.weekly`)}),(0,$.jsx)(_,{value:`primary`,children:a(`settings.routing.quotaWindows.fiveHour`)})]})]}),(0,$.jsx)(R,{"aria-label":a(`settings.routing.preferEarlier.ariaLabel`),checked:e.preferEarlierResetAccounts,disabled:r,onCheckedChange:e=>c({preferEarlierResetAccounts:e})})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:a(`settings.routing.workingDays.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.workingDays.description`)})]}),(0,$.jsx)(`div`,{className:`grid grid-cols-7 gap-1`,children:hc.map(e=>(0,$.jsxs)(`label`,{className:`flex min-w-0 flex-col items-center gap-1 rounded-md border bg-background px-2 py-1.5 text-[11px] font-medium`,children:[(0,$.jsx)(Te,{"aria-label":a(`settings.routing.workingDays.dayAria`,{day:a(`settings.routing.workingDays.days.${e.key}`)}),checked:B.has(e.value),disabled:r||B.size===1&&B.has(e.value),onCheckedChange:t=>ke(e.value,t===!0)}),a(`settings.routing.workingDays.days.${e.key}`)]},e.value))})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:a(`settings.routing.paceSmoothing.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.paceSmoothing.description`)})]}),(0,$.jsxs)(x,{value:String(e.weeklyPaceSmoothingMinutes),onValueChange:e=>c({weeklyPaceSmoothingMinutes:Number(e)}),children:[(0,$.jsx)(y,{"aria-label":a(`settings.routing.paceSmoothing.label`),className:`h-8 w-full text-xs sm:w-32`,disabled:r,children:(0,$.jsx)(b,{})}),(0,$.jsx)(v,{align:`end`,children:gc.map(e=>(0,$.jsx)(_,{value:String(e.value),children:e.label},e.value))})]})]}),(0,$.jsxs)(`div`,{className:`space-y-4 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(l,{className:`h-4 w-4 shrink-0 text-primary`,"aria-hidden":`true`}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:a(`settings.routing.limitWarmup.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.limitWarmup.description`)})]}),(0,$.jsx)(R,{"aria-label":a(`settings.routing.limitWarmup.ariaLabel`),checked:e.limitWarmupEnabled,disabled:r,onCheckedChange:e=>c({limitWarmupEnabled:e}),className:`ml-auto`})]}),(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[10rem_minmax(0,1fr)_7rem_7rem]`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`span`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`settings.routing.limitWarmup.shared.windowsLabel`)}),(0,$.jsxs)(x,{value:e.limitWarmupWindows,onValueChange:e=>c({limitWarmupWindows:e}),children:[(0,$.jsx)(y,{className:`h-8 text-xs`,disabled:r,"aria-label":a(`settings.routing.limitWarmup.shared.windowsAria`),children:(0,$.jsx)(b,{})}),(0,$.jsxs)(v,{align:`start`,children:[(0,$.jsx)(_,{value:`both`,children:a(`settings.routing.limitWarmup.windows.both`)}),(0,$.jsx)(_,{value:`primary`,children:a(`settings.routing.limitWarmup.windows.primary`)}),(0,$.jsx)(_,{value:`secondary`,children:a(`settings.routing.limitWarmup.windows.secondary`)})]})]})]}),(0,$.jsxs)(`label`,{className:`block space-y-1`,children:[(0,$.jsx)(`span`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`settings.routing.limitWarmup.shared.modelLabel`)}),(0,$.jsx)(H,{value:o.limitWarmupModel,disabled:r,maxLength:pc,onChange:e=>s({limitWarmupModel:e.target.value}),className:`h-8 text-xs`,"aria-label":a(`settings.routing.limitWarmup.modelAria`)})]}),(0,$.jsxs)(`label`,{className:`block space-y-1`,children:[(0,$.jsx)(`span`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`settings.routing.limitWarmup.shared.cooldownLabel`)}),(0,$.jsx)(H,{type:`number`,min:60,step:60,inputMode:`numeric`,value:o.limitWarmupCooldown,disabled:r,onChange:e=>s({limitWarmupCooldown:e.target.value}),className:`h-8 text-xs`,"aria-label":a(`settings.routing.limitWarmup.cooldownAria`)})]}),(0,$.jsxs)(`label`,{className:`block space-y-1`,children:[(0,$.jsx)(`span`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`settings.routing.limitWarmup.shared.promptLabel`)}),(0,$.jsx)(H,{value:o.limitWarmupPrompt,disabled:r,maxLength:mc,onChange:e=>s({limitWarmupPrompt:e.target.value}),className:`h-8 text-xs`,"aria-label":a(`settings.routing.limitWarmup.promptAria`)})]})]}),(0,$.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border/60 p-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(K,{variant:`secondary`,className:`text-[10px]`,children:a(`settings.routing.limitWarmup.resetConfirmed.badge`)}),(0,$.jsx)(`p`,{className:`text-xs font-medium`,children:a(`settings.routing.limitWarmup.resetConfirmed.title`)})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:a(`settings.routing.limitWarmup.resetConfirmed.description`)}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground whitespace-nowrap`,children:a(`settings.routing.limitWarmup.resetConfirmed.thresholdLabel`)}),(0,$.jsx)(H,{type:`number`,min:1,max:100,step:.1,inputMode:`decimal`,value:o.limitWarmupExhaustedThreshold,disabled:r,onChange:e=>s({limitWarmupExhaustedThreshold:e.target.value}),className:`h-8 w-full text-xs`,"aria-label":a(`settings.routing.limitWarmup.resetConfirmed.thresholdAria`)})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border/60 p-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(K,{variant:`secondary`,className:`text-[10px]`,children:a(`settings.routing.limitWarmup.staggeredIdle.badge`)}),(0,$.jsx)(`p`,{className:`text-xs font-medium`,children:a(`settings.routing.limitWarmup.staggeredIdle.title`)}),(0,$.jsx)(R,{"aria-label":a(`settings.routing.limitWarmup.staggeredIdle.toggleAria`),checked:e.limitWarmupStaggeredIdleEnabled,disabled:r,onCheckedChange:e=>c({limitWarmupStaggeredIdleEnabled:e}),className:`ml-auto`})]}),e.limitWarmupStaggeredIdleEnabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:a(`settings.routing.limitWarmup.staggeredIdle.description`)}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground whitespace-nowrap`,children:a(`settings.routing.limitWarmup.staggeredIdle.thresholdLabel`)}),(0,$.jsx)(H,{type:`number`,min:.1,max:100,step:.1,inputMode:`decimal`,value:o.limitWarmupIdleThreshold,disabled:r,onChange:e=>s({limitWarmupIdleThreshold:e.target.value}),className:`h-8 w-full text-xs`,"aria-label":a(`settings.routing.limitWarmup.staggeredIdle.thresholdAria`)})]})]}):(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:a(`settings.routing.limitWarmup.staggeredIdle.disabledDescription`)})]})]}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 text-xs sm:w-24`,disabled:r||!me||!ge,"aria-label":a(`settings.routing.limitWarmup.saveAria`),onClick:()=>void c({limitWarmupModel:o.limitWarmupModel.trim(),limitWarmupPrompt:o.limitWarmupPrompt.trim(),limitWarmupExhaustedThresholdPercent:ue,limitWarmupIdleThresholdPercent:fe,limitWarmupCooldownSeconds:ce}),children:a(`settings.routing.limitWarmup.save`)})})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:a(`settings.routing.promptCacheTtl.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`settings.routing.promptCacheTtl.description`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(H,{"aria-label":a(`settings.routing.promptCacheTtl.label`),type:`number`,min:1,step:1,inputMode:`numeric`,value:o.cacheAffinityTtl,disabled:r,onChange:e=>s({cacheAffinityTtl:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&p&&c({openaiCacheAffinityMaxAgeSeconds:f})},className:`h-8 w-28 text-xs`}),(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 text-xs`,disabled:r||!p,onClick:()=>void c({openaiCacheAffinityMaxAgeSeconds:f}),children:a(`settings.routing.promptCacheTtl.save`)})]})]})]})]})})}var jc=[{field:`upstreamConnectTimeoutSeconds`,name:`upstream_connect_timeout_seconds`,key:`connect`},{field:`proxyRequestBudgetSeconds`,name:`proxy_request_budget_seconds`,key:`proxyBudget`},{field:`compactRequestBudgetSeconds`,name:`compact_request_budget_seconds`,key:`compactBudget`},{field:`transcriptionRequestBudgetSeconds`,name:`transcription_request_budget_seconds`,key:`transcriptionBudget`},{field:`httpResponsesStreamRequestBudgetSeconds`,name:`http_responses_stream_request_budget_seconds`,key:`streamBudget`},{field:`httpResponsesSessionBridgeRequestBudgetSeconds`,name:`http_responses_session_bridge_request_budget_seconds`,key:`bridgeBudget`},{field:`streamIdleTimeoutSeconds`,name:`stream_idle_timeout_seconds`,key:`streamIdle`},{field:`proxyDownstreamWebsocketIdleTimeoutSeconds`,name:`proxy_downstream_websocket_idle_timeout_seconds`,key:`websocketIdle`},{field:`sseKeepaliveIntervalSeconds`,name:`sse_keepalive_interval_seconds`,key:`keepalive`}],Mc=[`proxyRequestBudgetSeconds`,`compactRequestBudgetSeconds`,`transcriptionRequestBudgetSeconds`,`httpResponsesStreamRequestBudgetSeconds`,`httpResponsesSessionBridgeRequestBudgetSeconds`],Nc=600,Pc=10,Fc=86400,Ic=new Set([`sseKeepaliveIntervalSeconds`]);function Lc(e,t){return e.provenance?.[t]?.source===`dashboard`}function Rc(e){let t={};for(let{field:n,name:r}of jc)t[n]=Lc(e,r)?String(e[n]):``;return t}function zc(e,t){let n=e.trim();if(n===``)return{valid:!0,value:null};let r=Number(n);return!Number.isFinite(r)||r>Fc||r<0||r===0&&!Ic.has(t)?{valid:!1}:{valid:!0,value:r}}function Bc(e,t,n){let r=e.provenance?.[n],i=r?.envValue??r?.default;return typeof i==`number`?i:e[t]}function Vc({settings:e,busy:t,onSave:n}){let{t:r}=k(),[i,a]=(0,Q.useState)(()=>Rc(e)),o=Object.fromEntries(jc.map(({field:e})=>[e,zc(i[e],e)])),s=(t,n)=>{let r=o[t];return r.valid&&r.value!==null?r.value:Bc(e,t,n)},c={};for(let{field:t,name:n}of jc){let r=o[t];if(!r.valid)continue;let i=Lc(e,n);r.value===null?i&&(c[t]=null):(!i||r.value!==e[t])&&(c[t]=r.value)}let l=jc.filter(({field:e})=>!o[e].valid).map(({key:e})=>e),u=s(`upstreamConnectTimeoutSeconds`,`upstream_connect_timeout_seconds`),d=jc.filter(({field:t,name:n})=>Mc.includes(t)&&u>s(t,n)&&!(e.upstreamConnectTimeoutSeconds>e[t])),f=s(`httpResponsesSessionBridgeRequestBudgetSeconds`,`http_responses_session_bridge_request_budget_seconds`),p=f<=Nc&&!(e.httpResponsesSessionBridgeRequestBudgetSeconds<=Nc),m=s(`httpResponsesStreamRequestBudgetSeconds`,`http_responses_stream_request_budget_seconds`),h=m<Pc&&!(e.httpResponsesStreamRequestBudgetSeconds<Pc),g=Object.keys(c).length>0&&l.length===0&&d.length===0&&!p&&!h,_=()=>void n(X(e,c));return(0,$.jsx)(`section`,{className:`rounded-xl border bg-card p-5`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(Nr,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`settings.upstreamTimeouts.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings.upstreamTimeouts.description`)})]})]}),(0,$.jsx)(`div`,{className:`divide-y rounded-lg border`,children:jc.map(({field:o,name:s,key:c})=>(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:r(`settings.upstreamTimeouts.${c}.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings.upstreamTimeouts.${c}.description`)}),(0,$.jsx)(Z,{settings:e,name:s,field:o,busy:t,onSave:n})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(H,{type:`number`,min:Ic.has(o)?0:void 0,step:`any`,inputMode:`decimal`,value:i[o],disabled:t,placeholder:String(e[o]),onChange:e=>a(t=>({...t,[o]:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&g&&_()},className:`h-8 w-28 text-xs`,"aria-label":r(`settings.upstreamTimeouts.${c}.label`)}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`settings.upstreamTimeouts.secondsSuffix`)})]})]},o))}),l.map(e=>(0,$.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs font-medium text-destructive`,children:r(e===`keepalive`?`settings.upstreamTimeouts.invalidNonNegative`:`settings.upstreamTimeouts.invalidPositive`,{field:r(`settings.upstreamTimeouts.${e}.label`)})},e)),d.map(({key:e})=>(0,$.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs font-medium text-destructive`,children:r(`settings.upstreamTimeouts.connectExceedsBudget`,{connect:u,budget:r(`settings.upstreamTimeouts.${e}.label`)})},e)),h?(0,$.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs font-medium text-destructive`,children:r(`settings.upstreamTimeouts.streamBudgetBelowAdmissionWait`,{budget:m,minimum:Pc})}):null,p?(0,$.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs font-medium text-destructive`,children:r(`settings.upstreamTimeouts.bridgeBudgetTooLow`,{budget:f,minimum:Nc})}):null,(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 text-xs`,disabled:t||!g,onClick:_,children:r(`settings.upstreamTimeouts.save`)})})]})})}function Hc(){return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`div`,{className:`rounded-xl border bg-card p-5`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(q,{className:`h-8 w-8 rounded-lg`}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(q,{className:`h-4 w-24`}),(0,$.jsx)(q,{className:`h-3 w-48`})]})]})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(q,{className:`h-3.5 w-14`}),(0,$.jsx)(q,{className:`h-3 w-48`})]}),(0,$.jsx)(q,{className:`h-8 w-44 rounded-lg`})]})]})}),(0,$.jsx)(`div`,{className:`rounded-xl border bg-card p-5`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(q,{className:`h-8 w-8 rounded-lg`}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(q,{className:`h-4 w-16`}),(0,$.jsx)(q,{className:`h-3 w-64`})]})]})}),(0,$.jsx)(`div`,{className:`divide-y rounded-lg border`,children:Array.from({length:2}).map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between p-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(q,{className:`h-3.5 w-28`}),(0,$.jsx)(q,{className:`h-3 w-52`})]}),(0,$.jsx)(q,{className:`h-5 w-9 rounded-full`})]},t))})]})}),(0,$.jsx)(`div`,{className:`rounded-xl border bg-card p-5`,children:(0,$.jsx)(`div`,{className:`space-y-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(q,{className:`h-8 w-8 rounded-lg`}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(q,{className:`h-4 w-20`}),(0,$.jsx)(q,{className:`h-3 w-36`})]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(q,{className:`h-8 w-20 rounded-md`})})]})})}),(0,$.jsx)(`div`,{className:`rounded-xl border bg-card p-5`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(q,{className:`h-8 w-8 rounded-lg`}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(q,{className:`h-4 w-12`}),(0,$.jsx)(q,{className:`h-3 w-36`})]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(q,{className:`h-8 w-24 rounded-md`})})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(q,{className:`h-3.5 w-36`}),(0,$.jsx)(q,{className:`h-3 w-56`})]}),(0,$.jsx)(q,{className:`h-5 w-9 rounded-full`})]})]})}),(0,$.jsxs)(`div`,{className:`space-y-3 rounded-xl border bg-card p-5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(q,{className:`h-8 w-8 rounded-lg`}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(q,{className:`h-4 w-20`}),(0,$.jsx)(q,{className:`h-3 w-52`})]})]}),(0,$.jsx)(q,{className:`h-8 w-24 rounded-md`})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(q,{className:`h-3.5 w-24`}),(0,$.jsx)(q,{className:`h-3 w-56`})]}),(0,$.jsx)(q,{className:`h-5 w-9 rounded-full`})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:Array.from({length:3}).map((e,t)=>(0,$.jsx)(q,{className:`h-10 w-full`},t))})]}),(0,$.jsx)(`div`,{className:`rounded-xl border bg-card p-5`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(q,{className:`h-8 w-8 rounded-lg`}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(q,{className:`h-4 w-36`}),(0,$.jsx)(q,{className:`h-3 w-64`})]})]}),(0,$.jsx)(q,{className:`h-5 w-9 rounded-full`})]}),(0,$.jsx)(q,{className:`h-3 w-96 max-w-full`}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(q,{className:`h-3.5 w-24`}),(0,$.jsx)(q,{className:`h-3 w-56`})]}),(0,$.jsx)(q,{className:`h-8 w-32 rounded-md`})]})]})}),(0,$.jsxs)(`div`,{className:`space-y-3 rounded-xl border bg-card p-5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(q,{className:`h-8 w-8 rounded-lg`}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(q,{className:`h-4 w-16`}),(0,$.jsx)(q,{className:`h-3 w-52`})]})]}),(0,$.jsx)(q,{className:`h-8 w-20 rounded-md`})]}),(0,$.jsx)(`div`,{className:`divide-y rounded-lg border`,children:Array.from({length:2}).map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between p-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(q,{className:`h-3.5 w-20`}),(0,$.jsx)(q,{className:`h-3 w-44`})]}),(0,$.jsx)(q,{className:`h-5 w-16 rounded-md`})]},t))}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(q,{className:`h-8 flex-1 rounded-md`}),(0,$.jsx)(q,{className:`h-8 w-16 rounded-md`})]})]})]})}function Uc({disabled:e}){let{t}=k(),[n,r]=(0,Q.useState)(!1),{telemetryConsentQuery:i,updateTelemetryConsentMutation:a}=Ct(),{telemetryPreviewQuery:o}=at(n),s=i.data,l=s?.source===`env`,u=e||a.isPending||!s,d=o.data?.preview??null;return(0,$.jsx)(`section`,{className:`rounded-xl border bg-card p-5`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(c,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`settings.telemetry.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings.telemetry.description`)})]})]}),(0,$.jsx)(R,{"aria-label":t(`settings.telemetry.toggleAria`),checked:s?.active??!1,disabled:u,onCheckedChange:e=>a.mutate({enabled:e})})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings.telemetry.optOutNotice`)}),l?(0,$.jsx)(`div`,{className:`rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-xs font-medium text-foreground`,children:t(`settings.telemetry.envNotice`)}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:t(`settings.telemetry.collectedData.label`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings.telemetry.collectedData.description`)})]}),(0,$.jsxs)(mt,{open:n,onOpenChange:r,children:[(0,$.jsx)(Nt,{asChild:!0,children:(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 text-xs`,disabled:!s,children:t(`settings.telemetry.collectedData.view`)})}),n?(0,$.jsxs)(Ht,{className:`sm:max-w-2xl`,children:[(0,$.jsxs)(wt,{children:[(0,$.jsx)(ot,{children:t(`settings.telemetry.previewDialog.title`)}),(0,$.jsx)(At,{children:t(`settings.telemetry.previewDialog.description`)})]}),d?(0,$.jsx)(Bt,{preview:d}):o.error?(0,$.jsx)(W,{variant:`error`,children:o.error.message}):(0,$.jsx)(q,{className:`h-64 w-full rounded-lg`}),(0,$.jsx)(Rt,{showCloseButton:!0})]}):null]})]})]})})}var Wc=[`http`,`https`,`socks5`,`socks5h`];function Gc({busy:e,onClose:t,onSubmit:n}){let{t:r}=k(),i=P({name:L().trim().min(1,r(`upstreamProxy.validation.nameRequired`)),scheme:I(Wc),host:L().trim().min(1,r(`upstreamProxy.validation.hostRequired`)),port:L().refine(e=>{let t=Number(e);return Number.isInteger(t)&&t>=1&&t<=65535},r(`upstreamProxy.validation.portInvalid`)),username:L(),password:L()}),a=Wt({resolver:Ot(i),defaultValues:{name:``,scheme:`http`,host:``,port:`8080`,username:``,password:``}}),o=async e=>{let r=e.username.trim(),i={name:e.name.trim(),scheme:e.scheme,host:e.host.trim(),port:Number(e.port),username:r||null,password:e.password?e.password:null,isActive:!0};try{await n(i)}catch{return}t()};return(0,$.jsx)(It,{...a,children:(0,$.jsxs)(`form`,{className:`space-y-4`,onSubmit:a.handleSubmit(o),children:[(0,$.jsx)(et,{control:a.control,name:`name`,render:({field:e})=>(0,$.jsxs)(rt,{children:[(0,$.jsx)(Ge,{children:r(`apiKeys.table.name`)}),(0,$.jsx)(Re,{children:(0,$.jsx)(H,{...e,autoComplete:`off`,placeholder:r(`upstreamProxy.endpointDialog.placeholders.name`)})}),(0,$.jsx)(je,{})]})}),(0,$.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-[8rem_minmax(0,1fr)]`,children:[(0,$.jsx)(et,{control:a.control,name:`scheme`,render:({field:e})=>(0,$.jsxs)(rt,{children:[(0,$.jsx)(Ge,{children:r(`upstreamProxy.endpointDialog.scheme`)}),(0,$.jsxs)(x,{value:e.value,onValueChange:e.onChange,children:[(0,$.jsx)(Re,{children:(0,$.jsx)(y,{className:`w-full`,children:(0,$.jsx)(b,{})})}),(0,$.jsx)(v,{children:Wc.map(e=>(0,$.jsx)(_,{value:e,children:e},e))})]}),(0,$.jsx)(je,{})]})}),(0,$.jsx)(et,{control:a.control,name:`host`,render:({field:e})=>(0,$.jsxs)(rt,{children:[(0,$.jsx)(Ge,{children:r(`upstreamProxy.endpointDialog.host`)}),(0,$.jsx)(Re,{children:(0,$.jsx)(H,{...e,autoComplete:`off`,placeholder:`proxy.example.com`})}),(0,$.jsx)(je,{})]})})]}),(0,$.jsx)(et,{control:a.control,name:`port`,render:({field:e})=>(0,$.jsxs)(rt,{children:[(0,$.jsx)(Ge,{children:r(`upstreamProxy.endpointDialog.port`)}),(0,$.jsx)(Re,{children:(0,$.jsx)(H,{...e,inputMode:`numeric`,autoComplete:`off`,placeholder:`8080`})}),(0,$.jsx)(je,{})]})}),(0,$.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,$.jsx)(et,{control:a.control,name:`username`,render:({field:e})=>(0,$.jsxs)(rt,{children:[(0,$.jsx)(Ge,{children:r(`upstreamProxy.endpointDialog.username`)}),(0,$.jsx)(Re,{children:(0,$.jsx)(H,{...e,autoComplete:`off`,placeholder:r(`upstreamProxy.optional`)})}),(0,$.jsx)(je,{})]})}),(0,$.jsx)(et,{control:a.control,name:`password`,render:({field:e})=>(0,$.jsxs)(rt,{children:[(0,$.jsx)(Ge,{children:r(`auth.login.passwordLabel`)}),(0,$.jsx)(Re,{children:(0,$.jsx)(H,{...e,type:`password`,autoComplete:`new-password`,placeholder:r(`upstreamProxy.optional`)})}),(0,$.jsx)(je,{})]})})]}),(0,$.jsx)(Rt,{className:`mt-2`,children:(0,$.jsx)(A,{type:`submit`,disabled:e||a.formState.isSubmitting,children:r(`upstreamProxy.actions.createEndpoint`)})})]})})}function Kc({open:e,busy:t,onOpenChange:n,onSubmit:r}){let{t:i}=k();return(0,$.jsx)(mt,{open:e,onOpenChange:n,children:e?(0,$.jsxs)(Ht,{className:`sm:max-w-md`,children:[(0,$.jsxs)(wt,{children:[(0,$.jsx)(ot,{children:i(`upstreamProxy.endpointDialog.title`)}),(0,$.jsx)(At,{children:i(`upstreamProxy.endpointDialog.description`)})]}),(0,$.jsx)(Gc,{busy:t,onClose:()=>n(!1),onSubmit:r})]}):null})}function qc({busy:e,endpoints:t,onClose:n,onSubmit:r}){let{t:i}=k(),a=P({name:L().trim().min(1,i(`upstreamProxy.validation.nameRequired`))}),o=Wt({resolver:Ot(a),defaultValues:{name:``}}),[s,c]=(0,Q.useState)(new Set),l=(e,t)=>{c(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},u=async e=>{let t={name:e.name.trim(),endpointIds:[...s],isActive:!0};try{await r(t)}catch{return}n()};return(0,$.jsx)(It,{...o,children:(0,$.jsxs)(`form`,{className:`space-y-4`,onSubmit:o.handleSubmit(u),children:[(0,$.jsx)(et,{control:o.control,name:`name`,render:({field:e})=>(0,$.jsxs)(rt,{children:[(0,$.jsx)(Ge,{children:i(`upstreamProxy.poolDialog.poolName`)}),(0,$.jsx)(Re,{children:(0,$.jsx)(H,{...e,autoComplete:`off`,placeholder:i(`upstreamProxy.poolDialog.placeholders.name`)})}),(0,$.jsx)(je,{})]})}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:i(`upstreamProxy.endpoints.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`upstreamProxy.poolDialog.endpointsDescription`)}),(0,$.jsx)(`div`,{className:`max-h-48 space-y-2 overflow-y-auto overscroll-contain rounded-md border p-2`,children:t.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`upstreamProxy.poolDialog.createEndpointFirst`)}):t.map(t=>(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded-md px-1 py-1 text-xs hover:bg-muted/50`,children:[(0,$.jsx)(Te,{checked:s.has(t.id),disabled:e,onCheckedChange:e=>l(t.id,e===!0)}),(0,$.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:t.name}),(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,`· `,t.scheme,`://`,t.host,`:`,t.port]})]})]},t.id))})]}),(0,$.jsx)(Rt,{className:`mt-2`,children:(0,$.jsx)(A,{type:`submit`,disabled:e||o.formState.isSubmitting,children:i(`upstreamProxy.actions.createPool`)})})]})})}function Jc({open:e,busy:t,endpoints:n,onOpenChange:r,onSubmit:i}){let{t:a}=k();return(0,$.jsx)(mt,{open:e,onOpenChange:r,children:e?(0,$.jsxs)(Ht,{className:`sm:max-w-md`,children:[(0,$.jsxs)(wt,{children:[(0,$.jsx)(ot,{children:a(`upstreamProxy.poolDialog.title`)}),(0,$.jsx)(At,{children:a(`upstreamProxy.poolDialog.description`)})]}),(0,$.jsx)(qc,{busy:t,endpoints:n,onClose:()=>r(!1),onSubmit:i})]}):null})}function Yc({busy:e,pools:t,endpoints:n,onClose:r,onSubmit:i}){let{t:a}=k(),[o,s]=(0,Q.useState)(t[0]?.id??``),[c,l]=(0,Q.useState)(n[0]?.id??``),u=t.find(e=>e.id===o)??null,d=u?.endpointIds.includes(c)??!1,f=!!(o&&c&&!d),p=async()=>{if(f){try{await i(o,{endpointId:c,sortOrder:u?.endpointIds.length??0,weight:1,isActive:!0})}catch{return}r()}};return(0,$.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(Ee,{htmlFor:`proxy-member-pool`,children:a(`upstreamProxy.memberDialog.pool`)}),(0,$.jsxs)(x,{value:o,onValueChange:s,disabled:e||t.length===0,children:[(0,$.jsx)(y,{id:`proxy-member-pool`,className:`w-full`,children:(0,$.jsx)(b,{placeholder:a(`upstreamProxy.memberDialog.selectPool`)})}),(0,$.jsx)(v,{children:t.map(e=>(0,$.jsx)(_,{value:e.id,children:e.name},e.id))})]})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(Ee,{htmlFor:`proxy-member-endpoint`,children:a(`upstreamProxy.memberDialog.endpoint`)}),(0,$.jsxs)(x,{value:c,onValueChange:l,disabled:e||n.length===0,children:[(0,$.jsx)(y,{id:`proxy-member-endpoint`,className:`w-full`,children:(0,$.jsx)(b,{placeholder:a(`upstreamProxy.memberDialog.selectEndpoint`)})}),(0,$.jsx)(v,{children:n.map(e=>(0,$.jsx)(_,{value:e.id,children:e.name},e.id))})]})]}),d&&u?(0,$.jsx)(W,{variant:`warning`,children:a(`upstreamProxy.memberDialog.alreadyPresent`,{pool:u.name})}):null,(0,$.jsx)(Rt,{className:`mt-2`,children:(0,$.jsx)(A,{type:`submit`,disabled:e||!f,children:a(`upstreamProxy.actions.addMember`)})})]})}function Xc({open:e,busy:t,pools:n,endpoints:r,onOpenChange:i,onSubmit:a}){let{t:o}=k();return(0,$.jsx)(mt,{open:e,onOpenChange:i,children:e?(0,$.jsxs)(Ht,{className:`sm:max-w-md`,children:[(0,$.jsxs)(wt,{children:[(0,$.jsx)(ot,{children:o(`upstreamProxy.memberDialog.title`)}),(0,$.jsx)(At,{children:o(`upstreamProxy.memberDialog.description`)})]}),(0,$.jsx)(Yc,{busy:t,pools:n,endpoints:r,onClose:()=>i(!1),onSubmit:a})]}):null})}var Zc=`__none__`;function Qc({admin:e,busy:t,onSaveSettings:n,canCreateEndpoint:r=!0,onCreateEndpoint:i,onTestEndpoint:a,onCreatePool:o,onAddPoolMember:s}){let{t:c}=k(),l=G(),u=G(),d=G(),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)({}),g=e.endpoints.length>0,S=e.pools.length>0,w=async e=>{if(f===null){p(e);try{let t=await a(e);h(n=>({...n,[e]:t}))}finally{p(null)}}};return(0,$.jsxs)(`section`,{className:`rounded-xl border bg-card p-5`,children:[(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(C,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:c(`upstreamProxy.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:c(`upstreamProxy.description`)})]})]}),(0,$.jsx)(R,{"aria-label":c(`upstreamProxy.enableAria`),checked:e.routingEnabled,disabled:t,onCheckedChange:e=>void n({upstreamProxyRoutingEnabled:e})})]}),(0,$.jsx)(`div`,{className:`rounded-lg border p-3`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:c(`upstreamProxy.defaultPool.title`)}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:c(`upstreamProxy.defaultPool.description`)})]}),(0,$.jsxs)(x,{value:e.defaultPoolId??Zc,onValueChange:e=>void n({upstreamProxyDefaultPoolId:e===Zc?null:e}),disabled:t,children:[(0,$.jsx)(y,{className:`h-8 w-full min-w-0 text-xs sm:w-56`,"aria-label":c(`upstreamProxy.defaultPool.aria`),children:(0,$.jsx)(b,{})}),(0,$.jsxs)(v,{children:[(0,$.jsx)(_,{value:Zc,children:c(`upstreamProxy.defaultPool.none`)}),e.pools.map(e=>(0,$.jsx)(_,{value:e.id,children:e.name},e.id))]})]})]})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(A,{type:`button`,size:`sm`,className:`h-8 gap-1.5 text-xs`,disabled:t||!r,onClick:()=>l.show(),children:[(0,$.jsx)(ne,{className:`h-3.5 w-3.5`}),c(`upstreamProxy.actions.addEndpoint`)]}),(0,$.jsxs)(A,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 gap-1.5 text-xs`,disabled:t||!g,onClick:()=>u.show(),children:[(0,$.jsx)($n,{className:`h-3.5 w-3.5`}),c(`upstreamProxy.actions.createPool`)]}),(0,$.jsxs)(A,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 gap-1.5 text-xs`,disabled:t||!S||!g,onClick:()=>d.show(),children:[(0,$.jsx)(ne,{className:`h-3.5 w-3.5`}),c(`upstreamProxy.actions.addMember`)]})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[(0,$.jsx)(Cr,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),c(`upstreamProxy.endpoints.title`)]}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:e.endpoints.length})]}),(0,$.jsx)(`div`,{className:`mt-2 space-y-1.5`,children:g?e.endpoints.map(e=>{let n=m[e.id];return(0,$.jsxs)(`div`,{className:`space-y-1 rounded-md bg-muted/50 px-2.5 py-1.5 text-xs`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:e.name}),(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,`· `,e.scheme,`://`,e.username?`${e.username}@`:``,e.host,`:`,e.port]})]}),(0,$.jsxs)(A,{type:`button`,size:`sm`,variant:`outline`,className:`h-7 shrink-0 px-2 text-xs`,disabled:t||f!==null,onClick:()=>void w(e.id),children:[f===e.id?(0,$.jsx)(Ae,{className:`mr-1 h-3 w-3 animate-spin`,"aria-hidden":`true`}):null,c(`upstreamProxy.actions.test`)]})]}),e.plaintextCredentials?(0,$.jsxs)(`div`,{role:`note`,className:`flex items-start gap-1 text-amber-600 dark:text-amber-500`,"data-testid":`proxy-endpoint-plaintext-warning-${e.id}`,children:[(0,$.jsx)(tt,{className:`mt-0.5 h-3 w-3 shrink-0`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:c(`upstreamProxy.endpoints.plaintextCredentials`,{scheme:e.scheme})})]}):null,n?(0,$.jsxs)(`div`,{className:n.ok?`flex items-center gap-1 text-emerald-600`:`flex items-center gap-1 text-destructive`,children:[n.ok?(0,$.jsx)(zt,{className:`h-3 w-3`,"aria-hidden":`true`}):(0,$.jsx)(E,{className:`h-3 w-3`,"aria-hidden":`true`}),(0,$.jsxs)(`span`,{children:[n.ok?c(`upstreamProxy.endpoints.connectionOk`):c(`upstreamProxy.endpoints.connectionFailed`),n.statusCode?` · HTTP ${n.statusCode}`:``,n.elapsedMs!==null&&n.elapsedMs!==void 0?` · ${n.elapsedMs}ms`:``,!n.ok&&n.error?` · ${n.error}`:``]})]}):null]},e.id)}):(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:c(`upstreamProxy.endpoints.empty`)})})]}),(0,$.jsxs)(`div`,{className:`rounded-lg border p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[(0,$.jsx)($n,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),c(`upstreamProxy.pools.title`)]}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:e.pools.length})]}),(0,$.jsx)(`div`,{className:`mt-2 space-y-1.5`,children:S?e.pools.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md bg-muted/50 px-2.5 py-1.5 text-xs`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground`,children:e.name}),(0,$.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[e.isActive?c(`common.states.active`):c(`common.states.inactive`),` · `,c(`upstreamProxy.pools.endpointCount`,{count:e.endpointIds.length})]})]},e.id)):(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:c(`upstreamProxy.pools.empty`)})})]})]})]}),(0,$.jsx)(Kc,{open:l.open,busy:t,onOpenChange:l.onOpenChange,onSubmit:i}),(0,$.jsx)(Jc,{open:u.open,busy:t,endpoints:e.endpoints,onOpenChange:u.onOpenChange,onSubmit:o}),(0,$.jsx)(Xc,{open:d.open,busy:t,pools:e.pools,endpoints:e.endpoints,onOpenChange:d.onOpenChange,onSubmit:s})]})}var $c=[`seed`,`other`],el=[`hit`,`miss`,`error`],tl=[`cross_account_sharing`,`no_cross_account_hit`,`inconclusive`],nl=I($c),rl=I(el),il=I(tl),al=P({accountId:L().min(1),label:L().min(1)}),ol=P({underPressure:N(),reason:L().nullish(),detail:L().nullish(),selectableAccountCount:F().int().nonnegative(),eligibleAccountCount:F().int().nonnegative(),pressuredAccountCount:F().int().nonnegative()}),sl=P({model:L().nullish(),seedAccount:al.nullish(),availableOtherAccounts:M(al).default([]),seedRepetitions:F().int().positive(),totalCalls:F().int().nonnegative(),estimatedInputTokensPerCall:F().int().nonnegative(),estimatedTotalInputTokens:F().int().nonnegative(),maxSeedRepetitions:F().int().positive(),maxOtherAccounts:F().int().positive(),pressure:ol}),cl=P({sequence:F().int().positive(),accountId:L().min(1),accountLabel:L().min(1),role:nl,status:rl,cacheHit:N(),inputTokens:F().int().nonnegative().nullish(),cachedTokens:F().int().nonnegative().nullish(),latencyMs:F().int().nonnegative(),errorCode:L().nullish()}),ll=P({runId:L().min(1),model:L().min(1),startedAt:h({offset:!0}),completedAt:h({offset:!0}),seedAccount:al,seedRepetitions:F().int().positive(),calls:M(cl).default([]),seedHitCount:F().int().nonnegative(),seedCallCount:F().int().nonnegative(),otherHitCount:F().int().nonnegative(),otherCallCount:F().int().nonnegative(),crossAccountHit:N(),verdict:il}),ul=P({confirm:Se(!0),seedRepetitions:F().int().positive(),otherAccountCount:F().int().positive()}),dl=`/api/diagnostics/cache-isolation-probe`;function fl(){return Ce(dl,sl)}function pl(e){let t=ul.parse(e);return j(`${dl}/run`,ll,{body:t})}var ml=[`cache-isolation-probe`,`plan`],hl=3,gl=4;function _l(e){let{t}=k(),n=o(),[r,s]=(0,Q.useState)(hl),[c,l]=(0,Q.useState)(gl),[u,d]=(0,Q.useState)(null);return{planQuery:i({queryKey:ml,queryFn:fl,enabled:e,refetchOnWindowFocus:!1}),runMutation:a({mutationFn:()=>pl({confirm:!0,seedRepetitions:r,otherAccountCount:c}),onSuccess:async e=>{d(e),e.crossAccountHit?U.warning(t(`cacheProbe.toasts.crossAccountHit`)):U.success(t(`cacheProbe.toasts.completed`)),await n.invalidateQueries({queryKey:ml})},onError:e=>{U.error(e.message||t(`cacheProbe.toasts.failed`))}}),result:u,seedRepetitions:r,otherAccountCount:c,setSeedRepetitions:s,setOtherAccountCount:l}}var vl={cross_account_sharing:`destructive`,no_cross_account_hit:`secondary`,inconclusive:`outline`};function yl(e,t){return Array.from({length:Math.max(0,t-e+1)},(t,n)=>e+n)}function bl(e){return e.cachedTokens==null||e.inputTokens==null?`—`:`${Ke(e.cachedTokens)} / ${Ke(e.inputTokens)}`}function xl({disabled:e=!1}){let{t}=k(),{planQuery:n,runMutation:r,result:i,seedRepetitions:a,otherAccountCount:o,setSeedRepetitions:s,setOtherAccountCount:c}=_l(!e),l=G(),u=n.data,d=(0,Q.useMemo)(()=>V(n.error)||V(r.error),[n.error,r.error]),f=Math.min(o,u?.availableOtherAccounts.length??0),p=a+f,m=(u?.estimatedInputTokensPerCall??0)*p,h=u?.pressure.underPressure??!1,g=e||r.isPending;return(0,$.jsxs)(`section`,{className:`space-y-3 rounded-xl border bg-card p-5`,"data-testid":`cache-isolation-probe`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(sr,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`cacheProbe.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`cacheProbe.description`)})]})]}),d?(0,$.jsx)(W,{variant:`error`,children:d}):null,n.isLoading?(0,$.jsx)(Ft,{}):null,u?(0,$.jsxs)($.Fragment,{children:[h?(0,$.jsx)(W,{variant:`warning`,children:u.pressure.detail||t(`cacheProbe.pressure.generic`)}):null,(0,$.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`space-y-1`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`cacheProbe.controls.seedRepetitions`)}),(0,$.jsxs)(x,{value:String(a),onValueChange:e=>s(Number(e)),children:[(0,$.jsx)(y,{"aria-label":t(`cacheProbe.controls.seedRepetitions`),children:(0,$.jsx)(b,{})}),(0,$.jsx)(v,{children:yl(1,u.maxSeedRepetitions).map(e=>(0,$.jsx)(_,{value:String(e),children:e},e))})]})]}),(0,$.jsxs)(`label`,{className:`space-y-1`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`cacheProbe.controls.otherAccounts`)}),(0,$.jsxs)(x,{value:String(o),onValueChange:e=>c(Number(e)),children:[(0,$.jsx)(y,{"aria-label":t(`cacheProbe.controls.otherAccounts`),children:(0,$.jsx)(b,{})}),(0,$.jsx)(v,{children:yl(1,u.maxOtherAccounts).map(e=>(0,$.jsx)(_,{value:String(e),children:e},e))})]})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border px-3 py-2 sm:flex-row sm:items-center sm:justify-between`,"data-testid":`cache-isolation-probe-cost`,children:[(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`cacheProbe.cost.summary`,{calls:p,tokens:Ke(m)})}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u.seedAccount?t(`cacheProbe.cost.accounts`,{seed:u.seedAccount.label,others:f,model:u.model??`—`}):t(`cacheProbe.cost.noAccounts`)})]}),(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 text-xs`,disabled:g||h||!u.seedAccount||f===0,onClick:()=>l.show(),children:r.isPending?t(`cacheProbe.actions.running`):t(`cacheProbe.actions.run`)})]}),(0,$.jsx)(W,{variant:`warning`,children:t(`cacheProbe.interpretation.seedMisses`)})]}):null,i?(0,$.jsxs)(`div`,{className:`space-y-3`,"data-testid":`cache-isolation-probe-result`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(K,{variant:vl[i.verdict],children:t(`cacheProbe.verdicts.${i.verdict}.label`)}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`cacheProbe.result.counts`,{otherHits:i.otherHitCount,otherCalls:i.otherCallCount,seedHits:i.seedHitCount,seedCalls:i.seedCallCount})})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`cacheProbe.verdicts.${i.verdict}.detail`)}),(0,$.jsxs)(hn,{children:[(0,$.jsx)(fn,{children:(0,$.jsxs)(mn,{children:[(0,$.jsx)(J,{children:t(`cacheProbe.table.call`)}),(0,$.jsx)(J,{children:t(`cacheProbe.table.account`)}),(0,$.jsx)(J,{children:t(`cacheProbe.table.role`)}),(0,$.jsx)(J,{children:t(`cacheProbe.table.cached`)}),(0,$.jsx)(J,{children:t(`cacheProbe.table.result`)})]})}),(0,$.jsx)(pn,{children:i.calls.map(e=>(0,$.jsxs)(mn,{children:[(0,$.jsx)(Y,{className:`tabular-nums`,children:e.sequence}),(0,$.jsx)(Y,{children:e.accountLabel}),(0,$.jsx)(Y,{children:t(`cacheProbe.roles.${e.role}`)}),(0,$.jsx)(Y,{className:`tabular-nums`,children:bl(e)}),(0,$.jsx)(Y,{children:e.status===`error`?t(`cacheProbe.callStatus.error`,{code:e.errorCode??`unknown`}):t(`cacheProbe.callStatus.${e.status}`)})]},e.sequence))})]})]}):null,(0,$.jsx)(en,{open:l.open,title:t(`cacheProbe.confirm.title`),description:t(`cacheProbe.confirm.description`,{calls:p,tokens:Ke(m)}),confirmLabel:t(`cacheProbe.confirm.confirmLabel`),onConfirm:()=>{l.hide(),r.mutate()},onOpenChange:l.onOpenChange})]})}var Sl=[`codex_session`,`sticky_thread`,`prompt_cache`],Cl=[`updated_at`,`created_at`,`account`,`key`],wl=[`asc`,`desc`],Tl=I(Sl),El=I(Cl),Dl=I(wl),Ol=P({key:L().min(1),displayName:L().min(1),kind:Tl,createdAt:h({offset:!0}),updatedAt:h({offset:!0}),expiresAt:h({offset:!0}).nullable(),isStale:N()}),kl=P({key:L().min(1),kind:Tl}),Al=P({sessions:M(kl).min(1).max(500).refine(e=>new Set(e.map(e=>`${e.kind}:${e.key}`)).size===e.length,`Duplicate sticky session targets are not allowed`)}),jl=P({key:L().min(1),kind:Tl,reason:L().min(1)}),Ml=P({entries:M(Ol).default([]),stalePromptCacheCount:F().int().nonnegative().default(0),total:F().int().nonnegative().default(0),hasMore:N().default(!1)}),Nl=P({staleOnly:N().default(!1),accountQuery:L().default(``),keyQuery:L().default(``),sortBy:El.default(`updated_at`),sortDir:Dl.default(`desc`),offset:F().int().nonnegative().default(0),limit:F().int().positive().max(500).default(10)}),Pl=P({deletedCount:F().int().nonnegative(),deleted:M(kl).default([]),failed:M(jl).default([])}),Fl=P({staleOnly:N().default(!1),accountQuery:L().default(``),keyQuery:L().default(``)}),Il=P({deletedCount:F().int().nonnegative()}),Ll=P({staleOnly:N().default(!0)}),Rl=P({deletedCount:F().int().nonnegative()}),zl=`/api/sticky-sessions`;function Bl(e){let t=Nl.parse(e),n=new URLSearchParams({staleOnly:String(t.staleOnly),offset:String(t.offset),limit:String(t.limit)});return t.accountQuery&&n.set(`accountQuery`,t.accountQuery),t.keyQuery&&n.set(`keyQuery`,t.keyQuery),n.set(`sortBy`,t.sortBy),n.set(`sortDir`,t.sortDir),Ce(`${zl}?${n.toString()}`,Ml)}function Vl(e){let t=Al.parse(e);return j(`${zl}/delete`,Pl,{body:t})}function Hl(e){let t=Fl.parse(e);return j(`${zl}/delete-filtered`,Il,{body:t})}function Ul(e){let t=Ll.parse(e);return j(`${zl}/purge`,Rl,{body:t})}var Wl=10;function Gl(){let{t:e}=k(),t=o(),[n,r]=(0,Q.useState)({staleOnly:!1,accountQuery:``,keyQuery:``,sortBy:`updated_at`,sortDir:`desc`,offset:0,limit:Wl}),s=(0,Q.useDeferredValue)(n.accountQuery),c=(0,Q.useDeferredValue)(n.keyQuery),l=(0,Q.useMemo)(()=>({...n,accountQuery:s,keyQuery:c}),[s,c,n]),{data:u,error:d,isFetching:f,isLoading:p,isPending:m,isSuccess:h,refetch:g}=i({queryKey:[`sticky-sessions`,`list`,l],queryFn:()=>Bl(l),placeholderData:e=>e,refetchInterval:3e4,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0});return{params:n,setAccountQuery:e=>{r(t=>({...t,accountQuery:e,offset:0}))},setKeyQuery:e=>{r(t=>({...t,keyQuery:e,offset:0}))},setSort:(e,t)=>{r(n=>({...n,sortBy:e,sortDir:t,offset:0}))},setOffset:e=>{r(t=>({...t,offset:e}))},setLimit:e=>{r(t=>({...t,limit:e,offset:0}))},stickySessionsQuery:{data:u,error:d,isFetching:f,isLoading:p,isPending:m,isSuccess:h,refetch:g},deleteMutation:a({mutationFn:e=>Vl({sessions:e}),onSuccess:async n=>{n.deletedCount>0&&n.failed.length===0?U.success(n.deletedCount===1?e(`stickySessions.toasts.deletedOne`):e(`stickySessions.toasts.deletedMany`,{count:n.deletedCount})):n.deletedCount>0?U.warning(e(`stickySessions.toasts.deletedPartial`,{deleted:n.deletedCount,failed:n.failed.length})):U.error(e(`stickySessions.toasts.noneSelectedDeleted`)),await t.invalidateQueries({queryKey:[`sticky-sessions`,`list`]})},onError:t=>{U.error(t.message||e(`stickySessions.toasts.deleteFailed`))}}),deleteFilteredMutation:a({mutationFn:()=>Hl({staleOnly:l.staleOnly,accountQuery:l.accountQuery,keyQuery:l.keyQuery}),onSuccess:async n=>{n.deletedCount>0?U.success(n.deletedCount===1?e(`stickySessions.toasts.filteredDeletedOne`):e(`stickySessions.toasts.filteredDeletedMany`,{count:n.deletedCount})):U.error(e(`stickySessions.toasts.noneFilteredDeleted`)),await t.invalidateQueries({queryKey:[`sticky-sessions`,`list`]})},onError:t=>{U.error(t.message||e(`stickySessions.toasts.deleteFilteredFailed`))}}),purgeMutation:a({mutationFn:e=>Ul({staleOnly:e}),onSuccess:n=>{U.success(e(`stickySessions.toasts.purged`,{count:n.deletedCount})),t.invalidateQueries({queryKey:[`sticky-sessions`,`list`]})},onError:t=>{U.error(t.message||e(`stickySessions.toasts.purgeFailed`))}})}}function Kl(e,t){switch(e){case`codex_session`:return t(`stickySessions.kinds.codexSession`);case`sticky_thread`:return t(`stickySessions.kinds.stickyThread`);case`prompt_cache`:return t(`stickySessions.kinds.promptCache`)}}function ql(e){return`${e.kind}:${e.key}`}var Jl=[];function Yl(e,t,n){return e==n?t===`asc`?`desc`:`asc`:n===`updated_at`?`desc`:`asc`}function Xl(e,t,n){return e===n?t===`asc`?` ↑`:` ↓`:null}function Zl({disabled:e=!1}){let{t}=k(),n=gt(e=>e.dateDisplayFormat),{params:r,setAccountQuery:i,setKeyQuery:a,setSort:o,setLimit:s,setOffset:c,stickySessionsQuery:l,deleteMutation:u,deleteFilteredMutation:d,purgeMutation:f}=Gl(),p=G(),m=G(),h=G(),g=G(),[_,v]=(0,Q.useState)([]),y=(0,Q.useMemo)(()=>V(l.error)||V(u.error)||V(d.error)||V(f.error),[l.error,u.error,d.error,f.error]),b=l.data?.entries??Jl,x=l.data?.stalePromptCacheCount??0,C=l.data?.total??0,w=l.data?.hasMore??!1,T=e||u.isPending||d.isPending||f.isPending,E=b.length>0,ee=C>0,D=r.accountQuery.trim().length>0||r.keyQuery.trim().length>0,te=(0,Q.useMemo)(()=>new Set(b.map(e=>ql(e))),[b]),O=(0,Q.useMemo)(()=>new Set(_),[_]),ne=(0,Q.useMemo)(()=>b.reduce((e,t)=>(O.has(ql(t))&&e.push({key:t.key,kind:t.kind}),e),[]),[b,O]),re=ne.length,ie=E&&re===b.length,ae=re>0&&!ie,oe=m.data??[],se=oe.length;(0,Q.useEffect)(()=>{if(!l.isLoading&&C>0&&b.length===0&&r.offset>0){let e=Math.max(0,Math.floor((C-1)/r.limit)*r.limit);e!==r.offset&&c(e)}},[b.length,r.limit,r.offset,c,l.isLoading,C]);let ce=(e,t)=>{let n=ql(e);v(e=>t?e.includes(n)?e:[...e,n]:e.filter(e=>e!==n))},le=e=>{v(t=>{let n=t.filter(e=>!te.has(e));return e?[...n,...b.map(e=>ql(e))]:n})};return(0,$.jsxs)(`section`,{className:`space-y-3 rounded-xl border bg-card p-5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10`,children:(0,$.jsx)(xr,{className:`h-4 w-4 text-primary`,"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`stickySessions.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`stickySessions.description`)})]})]}),y?(0,$.jsx)(W,{variant:`error`,children:y}):null,(0,$.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,$.jsx)(H,{"aria-label":t(`stickySessions.filters.accountAria`),placeholder:t(`stickySessions.filters.accountPlaceholder`),value:r.accountQuery,onChange:e=>i(e.target.value)}),(0,$.jsx)(H,{"aria-label":t(`stickySessions.filters.keyAria`),placeholder:t(`stickySessions.filters.keyPlaceholder`),value:r.keyQuery,onChange:e=>a(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border px-3 py-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`stickySessions.summary.visibleRows`)}),(0,$.jsx)(`span`,{className:`text-sm font-medium tabular-nums`,children:C})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`stickySessions.summary.stalePromptCache`)}),(0,$.jsx)(`span`,{className:`text-sm font-medium tabular-nums`,children:x})]}),re>0?(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`stickySessions.summary.selected`)}),(0,$.jsx)(`span`,{className:`text-sm font-medium tabular-nums`,children:re})]}):null]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 text-xs`,disabled:T||!D||C===0,onClick:()=>h.show(C),children:t(`stickySessions.actions.deleteFiltered`)}),(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`destructive`,className:`h-8 text-xs`,disabled:T||re===0,onClick:()=>m.show(ne),children:t(`stickySessions.actions.deleteSessions`)}),(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 text-xs`,disabled:T||x===0,onClick:()=>g.show(),children:t(`stickySessions.actions.purgeStale`)})]})]}),l.isLoading&&!l.data?(0,$.jsx)(`div`,{className:`py-8`,children:(0,$.jsx)(Ft,{})}):ee?(0,$.jsxs)($.Fragment,{children:[E?(0,$.jsx)(`div`,{className:`overflow-x-auto rounded-xl border`,children:(0,$.jsxs)(hn,{className:`table-fixed`,children:[(0,$.jsx)(fn,{children:(0,$.jsxs)(mn,{children:[(0,$.jsx)(J,{className:`w-[5%] min-w-[3rem] pl-4 text-[11px] uppercase tracking-wider text-muted-foreground/80`,children:(0,$.jsx)(Te,{"aria-label":t(`stickySessions.table.selectAllAria`),checked:ie?!0:ae?`indeterminate`:!1,disabled:T||!E,onCheckedChange:e=>le(e===!0)})}),(0,$.jsx)(J,{className:`w-[25%] min-w-[14rem] text-[11px] uppercase tracking-wider text-muted-foreground/80`,children:(0,$.jsx)(`button`,{type:`button`,className:`cursor-pointer text-left transition-colors hover:text-foreground`,onClick:()=>o(`key`,Yl(r.sortBy,r.sortDir,`key`)),children:`${t(`stickySessions.table.key`)}${Xl(r.sortBy,r.sortDir,`key`)??``}`})}),(0,$.jsx)(J,{className:`w-[14%] min-w-[8rem] text-[11px] uppercase tracking-wider text-muted-foreground/80`,children:t(`stickySessions.table.kind`)}),(0,$.jsx)(J,{className:`w-[18%] min-w-[9rem] text-[11px] uppercase tracking-wider text-muted-foreground/80`,children:(0,$.jsx)(`button`,{type:`button`,className:`cursor-pointer text-left transition-colors hover:text-foreground`,onClick:()=>o(`account`,Yl(r.sortBy,r.sortDir,`account`)),children:`${t(`dashboard.requests.columns.account`)}${Xl(r.sortBy,r.sortDir,`account`)??``}`})}),(0,$.jsx)(J,{className:`w-[16%] min-w-[9rem] text-[11px] uppercase tracking-wider text-muted-foreground/80`,children:(0,$.jsx)(`button`,{type:`button`,className:`cursor-pointer text-left transition-colors hover:text-foreground`,onClick:()=>o(`updated_at`,Yl(r.sortBy,r.sortDir,`updated_at`)),children:`${t(`stickySessions.table.updated`)}${Xl(r.sortBy,r.sortDir,`updated_at`)??``}`})}),(0,$.jsx)(J,{className:`w-[16%] min-w-[9rem] text-[11px] uppercase tracking-wider text-muted-foreground/80`,children:t(`apiKeys.table.expiry`)}),(0,$.jsx)(J,{className:`w-[6%] min-w-[4.5rem] pr-4 text-right align-middle text-[11px] uppercase tracking-wider text-muted-foreground/80`,children:t(`apiKeys.table.actions`)})]})}),(0,$.jsx)(pn,{children:b.map(e=>{let r=ze(e.updatedAt,n),i=e.expiresAt?ze(e.expiresAt,n):null,a=O.has(ql(e));return(0,$.jsxs)(mn,{"data-state":a?`selected`:void 0,children:[(0,$.jsx)(Y,{className:`pl-4`,children:(0,$.jsx)(Te,{"aria-label":t(`stickySessions.table.selectRowAria`,{key:e.key}),checked:a,disabled:T,onCheckedChange:t=>ce(e,t===!0)})}),(0,$.jsx)(Y,{className:`max-w-[18rem] truncate font-mono text-xs`,title:e.key,children:e.key}),(0,$.jsx)(Y,{children:(0,$.jsx)(K,{variant:`outline`,children:Kl(e.kind,t)})}),(0,$.jsx)(Y,{className:`truncate text-xs`,children:e.displayName}),(0,$.jsxs)(Y,{className:`text-xs text-muted-foreground`,children:[r.date,` `,r.time]}),(0,$.jsx)(Y,{className:`text-xs text-muted-foreground`,children:e.isStale?(0,$.jsx)(K,{variant:`secondary`,children:t(`stickySessions.states.stale`)}):i?`${i.date} ${i.time}`:t(`stickySessions.states.durable`)}),(0,$.jsx)(Y,{className:`pr-4 text-right`,children:(0,$.jsx)(A,{type:`button`,size:`sm`,variant:`ghost`,className:`text-destructive hover:text-destructive`,disabled:T,onClick:()=>p.show({key:e.key,kind:e.kind}),children:t(`common.actions.remove`)})})]},`${e.kind}:${e.key}`)})})]})}):(0,$.jsx)(dn,{icon:xr,title:t(`stickySessions.emptyPage.title`),description:t(`stickySessions.emptyPage.description`)}),(0,$.jsx)(`div`,{className:`flex justify-end pt-3`,children:(0,$.jsx)(S,{total:C,limit:r.limit,offset:r.offset,hasMore:w,onLimitChange:s,onOffsetChange:c})})]}):(0,$.jsx)(dn,{icon:xr,title:t(`stickySessions.empty.title`),description:t(`stickySessions.empty.description`)}),(0,$.jsx)(en,{open:p.open,title:t(`stickySessions.removeDialog.title`),description:p.data?t(`stickySessions.removeDialog.description`,{kind:Kl(p.data.kind,t),key:p.data.key}):``,confirmLabel:t(`common.actions.delete`),onOpenChange:p.onOpenChange,onConfirm:()=>{p.data&&u.mutateAsync([p.data]).finally(()=>{p.hide()})}}),(0,$.jsx)(en,{open:m.open,title:t(`stickySessions.deleteSelectedDialog.title`),description:se===1?t(`stickySessions.deleteSelectedDialog.descriptionOne`):t(`stickySessions.deleteSelectedDialog.descriptionMany`,{count:se}),confirmLabel:t(`stickySessions.actions.deleteSessions`),onOpenChange:m.onOpenChange,onConfirm:()=>{oe.length!==0&&u.mutateAsync(oe).then(e=>{v(e.failed.map(e=>ql(e)))}).finally(()=>{m.hide()})}}),(0,$.jsx)(en,{open:h.open,title:t(`stickySessions.deleteFilteredDialog.title`),description:t(`stickySessions.deleteFilteredDialog.description`,{count:h.data??0}),confirmLabel:t(`stickySessions.actions.deleteFiltered`),onOpenChange:h.onOpenChange,onConfirm:()=>{d.mutateAsync().then(()=>{v([])}).finally(()=>{h.hide()})}}),(0,$.jsx)(en,{open:g.open,title:t(`stickySessions.purgeDialog.title`),description:t(`stickySessions.purgeDialog.description`),confirmLabel:t(`stickySessions.actions.purge`),onOpenChange:g.onOpenChange,onConfirm:()=>{f.mutateAsync(!0).finally(()=>{g.hide()})}})]})}var Ql=[`proxy_overload_isolation_seconds`,`proxy_account_error_rate_weighting_enabled`,`proxy_account_inflight_penalty_pct`,`proxy_account_lease_token_weight`,`proxy_account_lease_ttl_seconds`],$l=[[`accounts`,`list`],[`settings`,`upstream-proxy`],[`model-sources`,`list`],[`settings`,`model-context-window-overrides`]];function eu(){let{t:e}=k(),t=dt(),n=Jt(t.search,t.hash),r=t.hash.replace(/^#/,``)||void 0,{settingsQuery:i,updateSettingsMutation:a}=Lt(),[o,s]=(0,Q.useState)(null),{accountsQuery:c}=nn(),l=z(e=>e.authMode),u=z(e=>e.canWrite),d=B(`security:write`),f=B(`ops:write`),p=z(e=>e.passwordManagementEnabled&&(e.passwordSessionActive||e.user!==null)),{upstreamProxyQuery:m,createEndpointMutation:h,createPoolMutation:g,addPoolMemberMutation:_,testEndpointMutation:v}=Mt({enabled:u}),y=i.data,b=a.isPending||h.isPending||g.isPending||_.isPending||v.isPending,x=b||!u,S=V(i.error,e(`settings.toasts.loadFailed`)),C=S||o,w=(y?S:null)||V(m.error)||V(a.error)||V(h.error)||V(g.error)||V(_.error)||V(v.error),T=async e=>{await a.mutateAsync(e)};return(0,$.jsxs)(`div`,{className:`animate-fade-in-up space-y-6`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`h1`,{className:`flex items-center gap-2 text-2xl font-semibold tracking-tight`,children:[(0,$.jsx)(Tr,{className:`h-5 w-5 text-primary`}),e(`settings.page.title`)]}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e(`settings.page.subtitle`)})]}),i.isPending&&!y&&o===null?(0,$.jsx)(Hc,{}):y?(0,$.jsxs)($.Fragment,{children:[w?(0,$.jsx)(W,{variant:`error`,children:w}):null,u?null:(0,$.jsx)(`div`,{className:`rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-xs font-medium text-foreground`,children:e(`settings.page.readOnlyNotice`)}),l===`trusted_header`?(0,$.jsx)(`div`,{className:`rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-xs font-medium text-foreground`,children:e(`settings.page.trustedHeaderNotice`)}):null,l===`disabled`?(0,$.jsx)(`div`,{className:`rounded-lg border border-amber-500/20 bg-amber-500/10 px-3 py-2 text-xs font-medium text-foreground`,children:e(`settings.page.disabledNotice`)}):null,(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(Bs,{}),(0,$.jsx)(tc,{settings:y,busy:x,onSave:T}),(0,$.jsx)(ac,{settings:y,busy:x,onSave:T}),u||p?(0,$.jsx)(to,{settings:y,busy:b,onSave:T,onRefresh:()=>i.refetch()}):null,u?(0,$.jsx)(Ei,{apiKeyAuthEnabled:y.apiKeyAuthEnabled,hideUpstreamQuotaFromApiKeys:y.hideUpstreamQuotaFromApiKeys,disabled:x,policyControlsDisabled:x||!d,onApiKeyAuthEnabledChange:e=>void T(X(y,{apiKeyAuthEnabled:e})),onHideUpstreamQuotaFromApiKeysChange:e=>void T(X(y,{hideUpstreamQuotaFromApiKeys:e}))}):null,(0,$.jsx)(Uc,{disabled:x}),(0,$.jsxs)(so,{defaultOpen:n,scrollToId:r,waitForQueryKeys:$l,children:[(0,$.jsx)(Ac,{settings:y,accounts:c.data??[],accountsLoading:c.isLoading,busy:x,onSave:T},[y.openaiCacheAffinityMaxAgeSeconds,y.warmupModel,y.limitWarmupModel,y.limitWarmupPrompt,y.limitWarmupExhaustedThresholdPercent,y.limitWarmupIdleThresholdPercent,y.limitWarmupCooldownSeconds,y.limitWarmupStaggeredIdleEnabled,y.proxyAccountResponseCreateLimit,y.proxyAccountResponseCreateLimitOverride,y.proxyAccountStreamLimit,y.proxyAccountStreamLimitOverride,y.proxyAccountStreamRecoveryReserve,y.proxyAccountStreamRecoveryReserveOverride,y.proxyApiKeyFairShareCongestionThresholdPct,y.proxyApiKeyFairShareCongestionThresholdPctOverride,y.proxyOverloadIsolationSeconds,y.proxyAccountErrorRateWeightingEnabled,y.proxyAccountInflightPenaltyPct,y.proxyAccountLeaseTokenWeight,y.proxyAccountLeaseTtlSeconds,...Ql.map(e=>y.provenance?.[e]?.source??``)].join(`:`)),(0,$.jsx)(cc,{settings:y,busy:x,onSave:T}),(0,$.jsx)(lc,{settings:y,busy:x,onSave:T}),(0,$.jsx)(dc,{settings:y,busy:x,onSave:T}),u&&m.data?(0,$.jsx)(Qc,{admin:m.data,busy:x,canCreateEndpoint:d,onSaveSettings:T,onCreateEndpoint:e=>h.mutateAsync(e),onTestEndpoint:e=>v.mutateAsync(e),onCreatePool:e=>g.mutateAsync(e),onAddPoolMember:(e,t)=>_.mutateAsync({poolId:e,payload:t})}):null,(0,$.jsx)(ga,{disabled:x}),(0,$.jsx)(ic,{disabled:x}),(0,$.jsx)(Ri,{disabled:x||!d}),(0,$.jsx)(Ba,{disabled:x}),u?(0,$.jsx)(Zl,{disabled:x}):null,f?(0,$.jsx)(xl,{disabled:x}):null,(0,$.jsx)(ec,{settings:y,busy:x,onSave:T},[y.requestLogRetentionOverrideDays,y.usageHistoryRetentionOverrideDays,y.requestLogRetentionDays,y.usageHistoryRetentionDays,y.httpResponsesSessionBridgeOperationSpoolRetentionSeconds,y.provenance?.http_responses_session_bridge_operation_spool_retention_seconds?.source??``].join(`:`)),(0,$.jsx)(Hs,{settings:y,busy:x,onSave:T}),(0,$.jsx)(Vc,{settings:y,busy:x,onSave:T},[y.version,y.upstreamConnectTimeoutSeconds,y.proxyRequestBudgetSeconds,y.compactRequestBudgetSeconds,y.transcriptionRequestBudgetSeconds,y.httpResponsesStreamRequestBudgetSeconds,y.httpResponsesSessionBridgeRequestBudgetSeconds,y.streamIdleTimeoutSeconds,y.proxyDownstreamWebsocketIdleTimeoutSeconds,y.sseKeepaliveIntervalSeconds].join(`:`))]},n?`open:${r??``}`:`closed`),(0,$.jsx)(Ps,{disabled:x})]}),(0,$.jsx)(tn,{visible:!!y&&b,label:e(`settings.page.savingLabel`)})]}):(0,$.jsxs)(`div`,{className:`space-y-3 rounded-xl border bg-card p-4`,children:[(0,$.jsx)(`div`,{role:`alert`,children:(0,$.jsx)(W,{variant:`error`,children:C||e(`settings.toasts.loadFailed`)})}),(0,$.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{s(C||e(`settings.toasts.loadFailed`)),i.refetch().finally(()=>{s(null)})},disabled:i.isFetching||o!==null,children:e(`common.actions.retry`)})]})]})}export{eu as SettingsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./rolldown-runtime-hePW80VL.js";import{C as t}from"./vendor-query-_bHZuxEx.js";var n=e((e=>{var n=t();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useState,o=n.useEffect,s=n.useLayoutEffect,c=n.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=n.useSyncExternalStore===void 0?f:n.useSyncExternalStore})),r=e(((e,t)=>{t.exports=n()}));export{r as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as e}from"./vendor-query-_bHZuxEx.js";import{c as t}from"./button-BjVmmiGW.js";var n=e();function r({className:e,...r}){return(0,n.jsx)(`div`,{"data-slot":`skeleton`,className:t(`bg-accent animate-pulse rounded-md`,e),...r})}export{r as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as e}from"./vendor-query-_bHZuxEx.js";import{c as t,n,t as r}from"./lazy-recharts-Pv8p9ArM.js";import{t as i}from"./use-reduced-motion-hAm5r6_d.js";var a=e(),o={top:2,right:0,bottom:2,left:0};function s({data:e,color:s,index:c,height:l=40}){let u=i(),d=`sparkline-fill-${c}`;return(0,a.jsx)(t,{width:`100%`,height:l,children:(0,a.jsxs)(n,{data:e,margin:o,children:[(0,a.jsx)(`defs`,{children:(0,a.jsxs)(`linearGradient`,{id:d,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,a.jsx)(`stop`,{offset:`0%`,stopColor:s,stopOpacity:.3}),(0,a.jsx)(`stop`,{offset:`100%`,stopColor:s,stopOpacity:.05})]})}),(0,a.jsx)(r,{type:`monotone`,dataKey:`value`,stroke:s,strokeWidth:1.5,fill:`url(#${d})`,isAnimationActive:!u,animationDuration:500,animationBegin:c*100})]})})}export{s as SparklineChart};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as e}from"./vendor-query-_bHZuxEx.js";import{t}from"./useTranslation--56nHhlH.js";import{c as n}from"./button-BjVmmiGW.js";import{t as r}from"./badge-DqMb9es0.js";var i=e(),a={active:`bg-emerald-500/15 text-emerald-700 border-emerald-500/20 hover:bg-emerald-500/20 dark:text-emerald-400`,paused:`bg-amber-500/15 text-amber-700 border-amber-500/20 hover:bg-amber-500/20 dark:text-amber-400`,limited:`bg-orange-500/15 text-orange-700 border-orange-500/20 hover:bg-orange-500/20 dark:text-orange-400`,exceeded:`bg-red-500/15 text-red-700 border-red-500/20 hover:bg-red-500/20 dark:text-red-400`,reauth:`bg-sky-500/15 text-sky-700 border-sky-500/20 hover:bg-sky-500/20 dark:text-sky-300`,deactivated:`bg-zinc-500/15 text-zinc-600 border-zinc-500/20 hover:bg-zinc-500/20 dark:text-zinc-400`};function o({status:e,title:o}){let{t:s}=t(),c=a[e]??a.deactivated,l=s(`common.status.${e}`,{defaultValue:e});return(0,i.jsxs)(r,{className:n(`gap-1.5`,c),variant:`outline`,title:o,children:[(0,i.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-current`,"aria-hidden":!0}),l]})}export{o as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{C as t,S as n}from"./vendor-query-_bHZuxEx.js";import{_ as r,g as i,m as a,v as o}from"./es2015-bMH8YKZT.js";import{c as s,s as c}from"./button-BjVmmiGW.js";import{w as l}from"./api-client-dugX1Pti.js";var u=e(t(),1),d=n(),f=Object.defineProperty,p=(e,t)=>f(e,`name`,{value:t,configurable:!0}),m=`Switch`,[h,g]=r(m),[_,v]=h(m);function y(e){let{__scopeSwitch:t,checked:n,children:r,defaultChecked:i,disabled:o,form:s,name:c,onCheckedChange:l,required:f,value:p=`on`,internal_do_not_use_render:h}=e,[g,v]=a({prop:n,defaultProp:i??!1,onChange:l,caller:m}),[y,b]=u.useState(null),[x,S]=u.useState(null),C=u.useRef(!1),[w,T]=u.useReducer(e=>e+1,0),E={checked:g,setChecked:v,disabled:o,control:y,setControl:b,name:c,form:s,value:p,hasConsumerStoppedPropagationRef:C,userInteractionCount:w,onUserInteraction:T,required:f,defaultChecked:i,isFormControl:!y||!!s||!!y.closest(`form`),bubbleInput:x,setBubbleInput:S};return(0,d.jsx)(_,{scope:t,...E,children:D(h)?h(E):r})}p(y,`SwitchProvider`);var b=`SwitchTrigger`,x=u.forwardRef(p(function({__scopeSwitch:e,onClick:t,...n},r){let{control:a,form:s,value:l,disabled:f,checked:m,required:h,setControl:g,setChecked:_,hasConsumerStoppedPropagationRef:y,onUserInteraction:x,isFormControl:S,bubbleInput:C}=v(b,e),w=c(r,g),T=u.useRef(m);return u.useEffect(()=>{let e=s?a?.ownerDocument.getElementById(s):a?.form;if(e instanceof HTMLFormElement){let t=p(()=>_(T.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,s,_]),(0,d.jsx)(o.button,{type:`button`,role:`switch`,"aria-checked":m,"aria-required":h,"data-state":O(m),"data-disabled":f?``:void 0,disabled:f,value:l,...n,ref:w,onClick:i(t,e=>{x(),_(e=>!e),C&&S&&(y.current=e.isPropagationStopped(),y.current||e.stopPropagation())})})},`SwitchTrigger`)),S=u.forwardRef(p(function(e,t){let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...f}=e;return(0,d.jsx)(y,{__scopeSwitch:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(x,{...f,ref:t,__scopeSwitch:n}),e&&(0,d.jsx)(E,{__scopeSwitch:n})]})})},`Switch`)),C=`SwitchThumb`,w=u.forwardRef(p(function(e,t){let{__scopeSwitch:n,...r}=e,i=v(C,n);return(0,d.jsx)(o.span,{"data-state":O(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})},`SwitchThumb`)),T=`SwitchBubbleInput`,E=u.forwardRef(p(function({__scopeSwitch:e,onClick:t,...n},r){let{control:a,hasConsumerStoppedPropagationRef:s,userInteractionCount:f,checked:p,defaultChecked:m,required:h,disabled:g,name:_,value:y,form:b,bubbleInput:x,setBubbleInput:S}=v(T,e),C=c(r,S),w=l(a),E=u.useRef(!1),D=u.useRef(p),O=u.useRef(f);u.useEffect(()=>{let e=x;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=f!==O.current;O.current=f;let i=D.current!==p;D.current=p;let a=!(r&&s.current);if(i&&n){E.current=!r;let t=new Event(`click`,{bubbles:a});n.call(e,p),e.dispatchEvent(t),E.current=!1}},[x,p,s,f]);let k=u.useRef(p);return(0,d.jsx)(o.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:m??k.current,required:h,disabled:g,name:_,value:y,form:b,...n,tabIndex:-1,ref:C,onClick:i(t,e=>{E.current&&e.stopPropagation()}),style:{...n.style,...w,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`SwitchBubbleInput`));function D(e){return typeof e==`function`}p(D,`isFunction`);function O(e){return e?`checked`:`unchecked`}p(O,`getState`);function k({className:e,size:t=`default`,...n}){return(0,d.jsx)(S,{"data-slot":`switch`,"data-size":t,className:s(`peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 group/switch inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[1.15rem] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6`,e),...n,children:(0,d.jsx)(w,{"data-slot":`switch-thumb`,className:s(`bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block rounded-full ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0`)})})}export{k as t};
|