skypilot-nightly 1.0.0.dev20250509__py3-none-any.whl → 1.0.0.dev20251107__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of skypilot-nightly might be problematic. Click here for more details.
- sky/__init__.py +22 -6
- sky/adaptors/aws.py +25 -7
- sky/adaptors/common.py +24 -1
- sky/adaptors/coreweave.py +278 -0
- sky/adaptors/do.py +8 -2
- sky/adaptors/hyperbolic.py +8 -0
- sky/adaptors/kubernetes.py +149 -18
- sky/adaptors/nebius.py +170 -17
- sky/adaptors/primeintellect.py +1 -0
- sky/adaptors/runpod.py +68 -0
- sky/adaptors/seeweb.py +167 -0
- sky/adaptors/shadeform.py +89 -0
- sky/admin_policy.py +187 -4
- sky/authentication.py +179 -225
- sky/backends/__init__.py +4 -2
- sky/backends/backend.py +22 -9
- sky/backends/backend_utils.py +1299 -380
- sky/backends/cloud_vm_ray_backend.py +1715 -518
- sky/backends/docker_utils.py +1 -1
- sky/backends/local_docker_backend.py +11 -6
- sky/backends/wheel_utils.py +37 -9
- sky/{clouds/service_catalog → catalog}/__init__.py +21 -19
- sky/{clouds/service_catalog → catalog}/aws_catalog.py +27 -8
- sky/{clouds/service_catalog → catalog}/azure_catalog.py +10 -7
- sky/{clouds/service_catalog → catalog}/common.py +89 -48
- sky/{clouds/service_catalog → catalog}/cudo_catalog.py +8 -5
- sky/{clouds/service_catalog → catalog}/data_fetchers/analyze.py +1 -1
- sky/{clouds/service_catalog → catalog}/data_fetchers/fetch_aws.py +30 -40
- sky/{clouds/service_catalog → catalog}/data_fetchers/fetch_cudo.py +38 -38
- sky/{clouds/service_catalog → catalog}/data_fetchers/fetch_gcp.py +42 -15
- sky/catalog/data_fetchers/fetch_hyperbolic.py +136 -0
- sky/{clouds/service_catalog → catalog}/data_fetchers/fetch_lambda_cloud.py +1 -0
- sky/catalog/data_fetchers/fetch_nebius.py +335 -0
- sky/catalog/data_fetchers/fetch_runpod.py +698 -0
- sky/catalog/data_fetchers/fetch_seeweb.py +329 -0
- sky/catalog/data_fetchers/fetch_shadeform.py +142 -0
- sky/{clouds/service_catalog → catalog}/data_fetchers/fetch_vast.py +1 -1
- sky/{clouds/service_catalog → catalog}/data_fetchers/fetch_vsphere.py +1 -1
- sky/{clouds/service_catalog → catalog}/do_catalog.py +5 -2
- sky/{clouds/service_catalog → catalog}/fluidstack_catalog.py +6 -3
- sky/{clouds/service_catalog → catalog}/gcp_catalog.py +41 -15
- sky/catalog/hyperbolic_catalog.py +136 -0
- sky/{clouds/service_catalog → catalog}/ibm_catalog.py +9 -6
- sky/{clouds/service_catalog → catalog}/kubernetes_catalog.py +36 -24
- sky/{clouds/service_catalog → catalog}/lambda_catalog.py +9 -6
- sky/{clouds/service_catalog → catalog}/nebius_catalog.py +9 -7
- sky/{clouds/service_catalog → catalog}/oci_catalog.py +9 -6
- sky/{clouds/service_catalog → catalog}/paperspace_catalog.py +5 -2
- sky/catalog/primeintellect_catalog.py +95 -0
- sky/{clouds/service_catalog → catalog}/runpod_catalog.py +11 -4
- sky/{clouds/service_catalog → catalog}/scp_catalog.py +9 -6
- sky/catalog/seeweb_catalog.py +184 -0
- sky/catalog/shadeform_catalog.py +165 -0
- sky/catalog/ssh_catalog.py +167 -0
- sky/{clouds/service_catalog → catalog}/vast_catalog.py +6 -3
- sky/{clouds/service_catalog → catalog}/vsphere_catalog.py +5 -2
- sky/check.py +491 -203
- sky/cli.py +5 -6005
- sky/client/{cli.py → cli/command.py} +2477 -1885
- sky/client/cli/deprecation_utils.py +99 -0
- sky/client/cli/flags.py +359 -0
- sky/client/cli/table_utils.py +320 -0
- sky/client/common.py +70 -32
- sky/client/oauth.py +82 -0
- sky/client/sdk.py +1203 -297
- sky/client/sdk_async.py +833 -0
- sky/client/service_account_auth.py +47 -0
- sky/cloud_stores.py +73 -0
- sky/clouds/__init__.py +13 -0
- sky/clouds/aws.py +358 -93
- sky/clouds/azure.py +105 -83
- sky/clouds/cloud.py +127 -36
- sky/clouds/cudo.py +68 -50
- sky/clouds/do.py +66 -48
- sky/clouds/fluidstack.py +63 -44
- sky/clouds/gcp.py +339 -110
- sky/clouds/hyperbolic.py +293 -0
- sky/clouds/ibm.py +70 -49
- sky/clouds/kubernetes.py +563 -162
- sky/clouds/lambda_cloud.py +74 -54
- sky/clouds/nebius.py +206 -80
- sky/clouds/oci.py +88 -66
- sky/clouds/paperspace.py +61 -44
- sky/clouds/primeintellect.py +317 -0
- sky/clouds/runpod.py +164 -74
- sky/clouds/scp.py +89 -83
- sky/clouds/seeweb.py +466 -0
- sky/clouds/shadeform.py +400 -0
- sky/clouds/ssh.py +263 -0
- sky/clouds/utils/aws_utils.py +10 -4
- sky/clouds/utils/gcp_utils.py +87 -11
- sky/clouds/utils/oci_utils.py +38 -14
- sky/clouds/utils/scp_utils.py +177 -124
- sky/clouds/vast.py +99 -77
- sky/clouds/vsphere.py +51 -40
- sky/core.py +349 -139
- sky/dag.py +15 -0
- sky/dashboard/out/404.html +1 -1
- sky/dashboard/out/_next/static/chunks/1141-e6aa9ab418717c59.js +11 -0
- sky/dashboard/out/_next/static/chunks/1272-1ef0bf0237faccdb.js +1 -0
- sky/dashboard/out/_next/static/chunks/1871-74503c8e80fd253b.js +6 -0
- sky/dashboard/out/_next/static/chunks/2260-7703229c33c5ebd5.js +1 -0
- sky/dashboard/out/_next/static/chunks/2350.fab69e61bac57b23.js +1 -0
- sky/dashboard/out/_next/static/chunks/2369.fc20f0c2c8ed9fe7.js +15 -0
- sky/dashboard/out/_next/static/chunks/2755.fff53c4a3fcae910.js +26 -0
- sky/dashboard/out/_next/static/chunks/3294.72362fa129305b19.js +1 -0
- sky/dashboard/out/_next/static/chunks/3785.ad6adaa2a0fa9768.js +1 -0
- sky/dashboard/out/_next/static/chunks/3850-ff4a9a69d978632b.js +1 -0
- sky/dashboard/out/_next/static/chunks/3937.210053269f121201.js +1 -0
- sky/dashboard/out/_next/static/chunks/4725.a830b5c9e7867c92.js +1 -0
- sky/dashboard/out/_next/static/chunks/4937.a2baa2df5572a276.js +15 -0
- sky/dashboard/out/_next/static/chunks/5739-d67458fcb1386c92.js +8 -0
- sky/dashboard/out/_next/static/chunks/6130-2be46d70a38f1e82.js +1 -0
- sky/dashboard/out/_next/static/chunks/616-3d59f75e2ccf9321.js +39 -0
- sky/dashboard/out/_next/static/chunks/6212-7bd06f60ba693125.js +13 -0
- sky/dashboard/out/_next/static/chunks/6601-06114c982db410b6.js +1 -0
- sky/dashboard/out/_next/static/chunks/6856-ef8ba11f96d8c4a3.js +1 -0
- sky/dashboard/out/_next/static/chunks/6989-01359c57e018caa4.js +1 -0
- sky/dashboard/out/_next/static/chunks/6990-32b6e2d3822301fa.js +1 -0
- sky/dashboard/out/_next/static/chunks/7359-c8d04e06886000b3.js +30 -0
- sky/dashboard/out/_next/static/chunks/7411-b15471acd2cba716.js +41 -0
- sky/dashboard/out/_next/static/chunks/7615-3301e838e5f25772.js +1 -0
- sky/dashboard/out/_next/static/chunks/8640.5b9475a2d18c5416.js +16 -0
- sky/dashboard/out/_next/static/chunks/8969-1e4613c651bf4051.js +1 -0
- sky/dashboard/out/_next/static/chunks/9025.fa408f3242e9028d.js +6 -0
- sky/dashboard/out/_next/static/chunks/9353-cff34f7e773b2e2b.js +1 -0
- sky/dashboard/out/_next/static/chunks/9360.7310982cf5a0dc79.js +31 -0
- sky/dashboard/out/_next/static/chunks/9847.3aaca6bb33455140.js +30 -0
- sky/dashboard/out/_next/static/chunks/fd9d1056-86323a29a8f7e46a.js +1 -0
- sky/dashboard/out/_next/static/chunks/framework-cf60a09ccd051a10.js +33 -0
- sky/dashboard/out/_next/static/chunks/main-app-587214043926b3cc.js +1 -0
- sky/dashboard/out/_next/static/chunks/main-f15ccb73239a3bf1.js +1 -0
- sky/dashboard/out/_next/static/chunks/pages/_app-bde01e4a2beec258.js +34 -0
- sky/dashboard/out/_next/static/chunks/pages/_error-c66a4e8afc46f17b.js +1 -0
- sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]/[job]-c736ead69c2d86ec.js +16 -0
- sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]-a37d2063af475a1c.js +1 -0
- sky/dashboard/out/_next/static/chunks/pages/clusters-d44859594e6f8064.js +1 -0
- sky/dashboard/out/_next/static/chunks/pages/config-dfb9bf07b13045f4.js +1 -0
- sky/dashboard/out/_next/static/chunks/pages/index-444f1804401f04ea.js +1 -0
- sky/dashboard/out/_next/static/chunks/pages/infra/[context]-c0b5935149902e6f.js +1 -0
- sky/dashboard/out/_next/static/chunks/pages/infra-aed0ea19df7cf961.js +1 -0
- sky/dashboard/out/_next/static/chunks/pages/jobs/[job]-5796e8d6aea291a0.js +16 -0
- sky/dashboard/out/_next/static/chunks/pages/jobs/pools/[pool]-6edeb7d06032adfc.js +21 -0
- sky/dashboard/out/_next/static/chunks/pages/jobs-479dde13399cf270.js +1 -0
- sky/dashboard/out/_next/static/chunks/pages/users-5ab3b907622cf0fe.js +1 -0
- sky/dashboard/out/_next/static/chunks/pages/volumes-b84b948ff357c43e.js +1 -0
- sky/dashboard/out/_next/static/chunks/pages/workspace/new-3f88a1c7e86a3f86.js +1 -0
- sky/dashboard/out/_next/static/chunks/pages/workspaces/[name]-c5a3eeee1c218af1.js +1 -0
- sky/dashboard/out/_next/static/chunks/pages/workspaces-22b23febb3e89ce1.js +1 -0
- sky/dashboard/out/_next/static/chunks/webpack-2679be77fc08a2f8.js +1 -0
- sky/dashboard/out/_next/static/css/0748ce22df867032.css +3 -0
- sky/dashboard/out/_next/static/zB0ed6ge_W1MDszVHhijS/_buildManifest.js +1 -0
- sky/dashboard/out/clusters/[cluster]/[job].html +1 -1
- sky/dashboard/out/clusters/[cluster].html +1 -1
- sky/dashboard/out/clusters.html +1 -1
- sky/dashboard/out/config.html +1 -0
- sky/dashboard/out/index.html +1 -1
- sky/dashboard/out/infra/[context].html +1 -0
- sky/dashboard/out/infra.html +1 -0
- sky/dashboard/out/jobs/[job].html +1 -1
- sky/dashboard/out/jobs/pools/[pool].html +1 -0
- sky/dashboard/out/jobs.html +1 -1
- sky/dashboard/out/users.html +1 -0
- sky/dashboard/out/volumes.html +1 -0
- sky/dashboard/out/workspace/new.html +1 -0
- sky/dashboard/out/workspaces/[name].html +1 -0
- sky/dashboard/out/workspaces.html +1 -0
- sky/data/data_utils.py +137 -1
- sky/data/mounting_utils.py +269 -84
- sky/data/storage.py +1451 -1807
- sky/data/storage_utils.py +43 -57
- sky/exceptions.py +132 -2
- sky/execution.py +206 -63
- sky/global_user_state.py +2374 -586
- sky/jobs/__init__.py +5 -0
- sky/jobs/client/sdk.py +242 -65
- sky/jobs/client/sdk_async.py +143 -0
- sky/jobs/constants.py +9 -8
- sky/jobs/controller.py +839 -277
- sky/jobs/file_content_utils.py +80 -0
- sky/jobs/log_gc.py +201 -0
- sky/jobs/recovery_strategy.py +398 -152
- sky/jobs/scheduler.py +315 -189
- sky/jobs/server/core.py +829 -255
- sky/jobs/server/server.py +156 -115
- sky/jobs/server/utils.py +136 -0
- sky/jobs/state.py +2092 -701
- sky/jobs/utils.py +1242 -160
- sky/logs/__init__.py +21 -0
- sky/logs/agent.py +108 -0
- sky/logs/aws.py +243 -0
- sky/logs/gcp.py +91 -0
- sky/metrics/__init__.py +0 -0
- sky/metrics/utils.py +443 -0
- sky/models.py +78 -1
- sky/optimizer.py +164 -70
- sky/provision/__init__.py +90 -4
- sky/provision/aws/config.py +147 -26
- sky/provision/aws/instance.py +135 -50
- sky/provision/azure/instance.py +10 -5
- sky/provision/common.py +13 -1
- sky/provision/cudo/cudo_machine_type.py +1 -1
- sky/provision/cudo/cudo_utils.py +14 -8
- sky/provision/cudo/cudo_wrapper.py +72 -71
- sky/provision/cudo/instance.py +10 -6
- sky/provision/do/instance.py +10 -6
- sky/provision/do/utils.py +4 -3
- sky/provision/docker_utils.py +114 -23
- sky/provision/fluidstack/instance.py +13 -8
- sky/provision/gcp/__init__.py +1 -0
- sky/provision/gcp/config.py +301 -19
- sky/provision/gcp/constants.py +218 -0
- sky/provision/gcp/instance.py +36 -8
- sky/provision/gcp/instance_utils.py +18 -4
- sky/provision/gcp/volume_utils.py +247 -0
- sky/provision/hyperbolic/__init__.py +12 -0
- sky/provision/hyperbolic/config.py +10 -0
- sky/provision/hyperbolic/instance.py +437 -0
- sky/provision/hyperbolic/utils.py +373 -0
- sky/provision/instance_setup.py +93 -14
- sky/provision/kubernetes/__init__.py +5 -0
- sky/provision/kubernetes/config.py +9 -52
- sky/provision/kubernetes/constants.py +17 -0
- sky/provision/kubernetes/instance.py +789 -247
- sky/provision/kubernetes/manifests/fusermount-server-daemonset.yaml +1 -2
- sky/provision/kubernetes/network.py +27 -17
- sky/provision/kubernetes/network_utils.py +40 -43
- sky/provision/kubernetes/utils.py +1192 -531
- sky/provision/kubernetes/volume.py +282 -0
- sky/provision/lambda_cloud/instance.py +22 -16
- sky/provision/nebius/constants.py +50 -0
- sky/provision/nebius/instance.py +19 -6
- sky/provision/nebius/utils.py +196 -91
- sky/provision/oci/instance.py +10 -5
- sky/provision/paperspace/instance.py +10 -7
- sky/provision/paperspace/utils.py +1 -1
- sky/provision/primeintellect/__init__.py +10 -0
- sky/provision/primeintellect/config.py +11 -0
- sky/provision/primeintellect/instance.py +454 -0
- sky/provision/primeintellect/utils.py +398 -0
- sky/provision/provisioner.py +110 -36
- sky/provision/runpod/__init__.py +5 -0
- sky/provision/runpod/instance.py +27 -6
- sky/provision/runpod/utils.py +51 -18
- sky/provision/runpod/volume.py +180 -0
- sky/provision/scp/__init__.py +15 -0
- sky/provision/scp/config.py +93 -0
- sky/provision/scp/instance.py +531 -0
- sky/provision/seeweb/__init__.py +11 -0
- sky/provision/seeweb/config.py +13 -0
- sky/provision/seeweb/instance.py +807 -0
- sky/provision/shadeform/__init__.py +11 -0
- sky/provision/shadeform/config.py +12 -0
- sky/provision/shadeform/instance.py +351 -0
- sky/provision/shadeform/shadeform_utils.py +83 -0
- sky/provision/ssh/__init__.py +18 -0
- sky/provision/vast/instance.py +13 -8
- sky/provision/vast/utils.py +10 -7
- sky/provision/vsphere/common/vim_utils.py +1 -2
- sky/provision/vsphere/instance.py +15 -10
- sky/provision/vsphere/vsphere_utils.py +9 -19
- sky/py.typed +0 -0
- sky/resources.py +844 -118
- sky/schemas/__init__.py +0 -0
- sky/schemas/api/__init__.py +0 -0
- sky/schemas/api/responses.py +225 -0
- sky/schemas/db/README +4 -0
- sky/schemas/db/env.py +90 -0
- sky/schemas/db/global_user_state/001_initial_schema.py +124 -0
- sky/schemas/db/global_user_state/002_add_workspace_to_cluster_history.py +35 -0
- sky/schemas/db/global_user_state/003_fix_initial_revision.py +61 -0
- sky/schemas/db/global_user_state/004_is_managed.py +34 -0
- sky/schemas/db/global_user_state/005_cluster_event.py +32 -0
- sky/schemas/db/global_user_state/006_provision_log.py +41 -0
- sky/schemas/db/global_user_state/007_cluster_event_request_id.py +34 -0
- sky/schemas/db/global_user_state/008_skylet_ssh_tunnel_metadata.py +34 -0
- sky/schemas/db/global_user_state/009_last_activity_and_launched_at.py +89 -0
- sky/schemas/db/global_user_state/010_save_ssh_key.py +66 -0
- sky/schemas/db/script.py.mako +28 -0
- sky/schemas/db/serve_state/001_initial_schema.py +67 -0
- sky/schemas/db/skypilot_config/001_initial_schema.py +30 -0
- sky/schemas/db/spot_jobs/001_initial_schema.py +97 -0
- sky/schemas/db/spot_jobs/002_cluster_pool.py +42 -0
- sky/schemas/db/spot_jobs/003_pool_hash.py +34 -0
- sky/schemas/db/spot_jobs/004_job_file_contents.py +42 -0
- sky/schemas/db/spot_jobs/005_logs_gc.py +38 -0
- sky/schemas/generated/__init__.py +0 -0
- sky/schemas/generated/autostopv1_pb2.py +36 -0
- sky/schemas/generated/autostopv1_pb2.pyi +43 -0
- sky/schemas/generated/autostopv1_pb2_grpc.py +146 -0
- sky/schemas/generated/jobsv1_pb2.py +86 -0
- sky/schemas/generated/jobsv1_pb2.pyi +254 -0
- sky/schemas/generated/jobsv1_pb2_grpc.py +542 -0
- sky/schemas/generated/managed_jobsv1_pb2.py +74 -0
- sky/schemas/generated/managed_jobsv1_pb2.pyi +278 -0
- sky/schemas/generated/managed_jobsv1_pb2_grpc.py +278 -0
- sky/schemas/generated/servev1_pb2.py +58 -0
- sky/schemas/generated/servev1_pb2.pyi +115 -0
- sky/schemas/generated/servev1_pb2_grpc.py +322 -0
- sky/serve/autoscalers.py +357 -5
- sky/serve/client/impl.py +310 -0
- sky/serve/client/sdk.py +47 -139
- sky/serve/client/sdk_async.py +130 -0
- sky/serve/constants.py +10 -8
- sky/serve/controller.py +64 -19
- sky/serve/load_balancer.py +106 -60
- sky/serve/load_balancing_policies.py +115 -1
- sky/serve/replica_managers.py +273 -162
- sky/serve/serve_rpc_utils.py +179 -0
- sky/serve/serve_state.py +554 -251
- sky/serve/serve_utils.py +733 -220
- sky/serve/server/core.py +66 -711
- sky/serve/server/impl.py +1093 -0
- sky/serve/server/server.py +21 -18
- sky/serve/service.py +133 -48
- sky/serve/service_spec.py +135 -16
- sky/serve/spot_placer.py +3 -0
- sky/server/auth/__init__.py +0 -0
- sky/server/auth/authn.py +50 -0
- sky/server/auth/loopback.py +38 -0
- sky/server/auth/oauth2_proxy.py +200 -0
- sky/server/common.py +475 -181
- sky/server/config.py +81 -23
- sky/server/constants.py +44 -6
- sky/server/daemons.py +229 -0
- sky/server/html/token_page.html +185 -0
- sky/server/metrics.py +160 -0
- sky/server/requests/executor.py +528 -138
- sky/server/requests/payloads.py +351 -17
- sky/server/requests/preconditions.py +21 -17
- sky/server/requests/process.py +112 -29
- sky/server/requests/request_names.py +120 -0
- sky/server/requests/requests.py +817 -224
- sky/server/requests/serializers/decoders.py +82 -31
- sky/server/requests/serializers/encoders.py +140 -22
- sky/server/requests/threads.py +106 -0
- sky/server/rest.py +417 -0
- sky/server/server.py +1290 -284
- sky/server/state.py +20 -0
- sky/server/stream_utils.py +345 -57
- sky/server/uvicorn.py +217 -3
- sky/server/versions.py +270 -0
- sky/setup_files/MANIFEST.in +5 -0
- sky/setup_files/alembic.ini +156 -0
- sky/setup_files/dependencies.py +136 -31
- sky/setup_files/setup.py +44 -42
- sky/sky_logging.py +102 -5
- sky/skylet/attempt_skylet.py +1 -0
- sky/skylet/autostop_lib.py +129 -8
- sky/skylet/configs.py +27 -20
- sky/skylet/constants.py +171 -19
- sky/skylet/events.py +105 -21
- sky/skylet/job_lib.py +335 -104
- sky/skylet/log_lib.py +297 -18
- sky/skylet/log_lib.pyi +44 -1
- sky/skylet/ray_patches/__init__.py +17 -3
- sky/skylet/ray_patches/autoscaler.py.diff +18 -0
- sky/skylet/ray_patches/cli.py.diff +19 -0
- sky/skylet/ray_patches/command_runner.py.diff +17 -0
- sky/skylet/ray_patches/log_monitor.py.diff +20 -0
- sky/skylet/ray_patches/resource_demand_scheduler.py.diff +32 -0
- sky/skylet/ray_patches/updater.py.diff +18 -0
- sky/skylet/ray_patches/worker.py.diff +41 -0
- sky/skylet/services.py +564 -0
- sky/skylet/skylet.py +63 -4
- sky/skylet/subprocess_daemon.py +103 -29
- sky/skypilot_config.py +506 -99
- sky/ssh_node_pools/__init__.py +1 -0
- sky/ssh_node_pools/core.py +135 -0
- sky/ssh_node_pools/server.py +233 -0
- sky/task.py +621 -137
- sky/templates/aws-ray.yml.j2 +10 -3
- sky/templates/azure-ray.yml.j2 +1 -1
- sky/templates/do-ray.yml.j2 +1 -1
- sky/templates/gcp-ray.yml.j2 +57 -0
- sky/templates/hyperbolic-ray.yml.j2 +67 -0
- sky/templates/jobs-controller.yaml.j2 +27 -24
- sky/templates/kubernetes-loadbalancer.yml.j2 +2 -0
- sky/templates/kubernetes-ray.yml.j2 +607 -51
- sky/templates/lambda-ray.yml.j2 +1 -1
- sky/templates/nebius-ray.yml.j2 +33 -12
- sky/templates/paperspace-ray.yml.j2 +1 -1
- sky/templates/primeintellect-ray.yml.j2 +71 -0
- sky/templates/runpod-ray.yml.j2 +9 -1
- sky/templates/scp-ray.yml.j2 +3 -50
- sky/templates/seeweb-ray.yml.j2 +108 -0
- sky/templates/shadeform-ray.yml.j2 +72 -0
- sky/templates/sky-serve-controller.yaml.j2 +22 -2
- sky/templates/websocket_proxy.py +178 -18
- sky/usage/usage_lib.py +18 -11
- sky/users/__init__.py +0 -0
- sky/users/model.conf +15 -0
- sky/users/permission.py +387 -0
- sky/users/rbac.py +121 -0
- sky/users/server.py +720 -0
- sky/users/token_service.py +218 -0
- sky/utils/accelerator_registry.py +34 -5
- sky/utils/admin_policy_utils.py +84 -38
- sky/utils/annotations.py +16 -5
- sky/utils/asyncio_utils.py +78 -0
- sky/utils/auth_utils.py +153 -0
- sky/utils/benchmark_utils.py +60 -0
- sky/utils/cli_utils/status_utils.py +159 -86
- sky/utils/cluster_utils.py +31 -9
- sky/utils/command_runner.py +354 -68
- sky/utils/command_runner.pyi +93 -3
- sky/utils/common.py +35 -8
- sky/utils/common_utils.py +310 -87
- sky/utils/config_utils.py +87 -5
- sky/utils/context.py +402 -0
- sky/utils/context_utils.py +222 -0
- sky/utils/controller_utils.py +264 -89
- sky/utils/dag_utils.py +31 -12
- sky/utils/db/__init__.py +0 -0
- sky/utils/db/db_utils.py +470 -0
- sky/utils/db/migration_utils.py +133 -0
- sky/utils/directory_utils.py +12 -0
- sky/utils/env_options.py +13 -0
- sky/utils/git.py +567 -0
- sky/utils/git_clone.sh +460 -0
- sky/utils/infra_utils.py +195 -0
- sky/utils/kubernetes/cleanup-tunnel.sh +62 -0
- sky/utils/kubernetes/config_map_utils.py +133 -0
- sky/utils/kubernetes/create_cluster.sh +13 -27
- sky/utils/kubernetes/delete_cluster.sh +10 -7
- sky/utils/kubernetes/deploy_remote_cluster.py +1299 -0
- sky/utils/kubernetes/exec_kubeconfig_converter.py +22 -31
- sky/utils/kubernetes/generate_kind_config.py +6 -66
- sky/utils/kubernetes/generate_kubeconfig.sh +4 -1
- sky/utils/kubernetes/gpu_labeler.py +5 -5
- sky/utils/kubernetes/kubernetes_deploy_utils.py +354 -47
- sky/utils/kubernetes/ssh-tunnel.sh +379 -0
- sky/utils/kubernetes/ssh_utils.py +221 -0
- sky/utils/kubernetes_enums.py +8 -15
- sky/utils/lock_events.py +94 -0
- sky/utils/locks.py +368 -0
- sky/utils/log_utils.py +300 -6
- sky/utils/perf_utils.py +22 -0
- sky/utils/resource_checker.py +298 -0
- sky/utils/resources_utils.py +249 -32
- sky/utils/rich_utils.py +213 -37
- sky/utils/schemas.py +905 -147
- sky/utils/serialize_utils.py +16 -0
- sky/utils/status_lib.py +10 -0
- sky/utils/subprocess_utils.py +38 -15
- sky/utils/tempstore.py +70 -0
- sky/utils/timeline.py +24 -52
- sky/utils/ux_utils.py +84 -15
- sky/utils/validator.py +11 -1
- sky/utils/volume.py +86 -0
- sky/utils/yaml_utils.py +111 -0
- sky/volumes/__init__.py +13 -0
- sky/volumes/client/__init__.py +0 -0
- sky/volumes/client/sdk.py +149 -0
- sky/volumes/server/__init__.py +0 -0
- sky/volumes/server/core.py +258 -0
- sky/volumes/server/server.py +122 -0
- sky/volumes/volume.py +212 -0
- sky/workspaces/__init__.py +0 -0
- sky/workspaces/core.py +655 -0
- sky/workspaces/server.py +101 -0
- sky/workspaces/utils.py +56 -0
- skypilot_nightly-1.0.0.dev20251107.dist-info/METADATA +675 -0
- skypilot_nightly-1.0.0.dev20251107.dist-info/RECORD +594 -0
- {skypilot_nightly-1.0.0.dev20250509.dist-info → skypilot_nightly-1.0.0.dev20251107.dist-info}/WHEEL +1 -1
- sky/benchmark/benchmark_state.py +0 -256
- sky/benchmark/benchmark_utils.py +0 -641
- sky/clouds/service_catalog/constants.py +0 -7
- sky/dashboard/out/_next/static/LksQgChY5izXjokL3LcEu/_buildManifest.js +0 -1
- sky/dashboard/out/_next/static/chunks/236-f49500b82ad5392d.js +0 -6
- sky/dashboard/out/_next/static/chunks/312-c3c8845990db8ffc.js +0 -15
- sky/dashboard/out/_next/static/chunks/37-0a572fe0dbb89c4d.js +0 -6
- sky/dashboard/out/_next/static/chunks/678-206dddca808e6d16.js +0 -59
- sky/dashboard/out/_next/static/chunks/845-0f8017370869e269.js +0 -1
- sky/dashboard/out/_next/static/chunks/979-7bf73a4c7cea0f5c.js +0 -1
- sky/dashboard/out/_next/static/chunks/fd9d1056-2821b0f0cabcd8bd.js +0 -1
- sky/dashboard/out/_next/static/chunks/framework-87d061ee6ed71b28.js +0 -33
- sky/dashboard/out/_next/static/chunks/main-app-241eb28595532291.js +0 -1
- sky/dashboard/out/_next/static/chunks/main-e0e2335212e72357.js +0 -1
- sky/dashboard/out/_next/static/chunks/pages/_app-e6b013bc3f77ad60.js +0 -1
- sky/dashboard/out/_next/static/chunks/pages/_error-1be831200e60c5c0.js +0 -1
- sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]/[job]-e15db85d0ea1fbe1.js +0 -1
- sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]-f383db7389368ea7.js +0 -1
- sky/dashboard/out/_next/static/chunks/pages/clusters-a93b93e10b8b074e.js +0 -1
- sky/dashboard/out/_next/static/chunks/pages/index-f9f039532ca8cbc4.js +0 -1
- sky/dashboard/out/_next/static/chunks/pages/jobs/[job]-03f279c6741fb48b.js +0 -1
- sky/dashboard/out/_next/static/chunks/pages/jobs-a75029b67aab6a2e.js +0 -1
- sky/dashboard/out/_next/static/chunks/webpack-830f59b8404e96b8.js +0 -1
- sky/dashboard/out/_next/static/css/c6933bbb2ce7f4dd.css +0 -3
- sky/jobs/dashboard/dashboard.py +0 -223
- sky/jobs/dashboard/static/favicon.ico +0 -0
- sky/jobs/dashboard/templates/index.html +0 -831
- sky/jobs/server/dashboard_utils.py +0 -69
- sky/skylet/providers/scp/__init__.py +0 -2
- sky/skylet/providers/scp/config.py +0 -149
- sky/skylet/providers/scp/node_provider.py +0 -578
- sky/templates/kubernetes-ssh-jump.yml.j2 +0 -94
- sky/utils/db_utils.py +0 -100
- sky/utils/kubernetes/deploy_remote_cluster.sh +0 -308
- sky/utils/kubernetes/ssh_jump_lifecycle_manager.py +0 -191
- skypilot_nightly-1.0.0.dev20250509.dist-info/METADATA +0 -361
- skypilot_nightly-1.0.0.dev20250509.dist-info/RECORD +0 -396
- /sky/{clouds/service_catalog → catalog}/config.py +0 -0
- /sky/{benchmark → catalog/data_fetchers}/__init__.py +0 -0
- /sky/{clouds/service_catalog → catalog}/data_fetchers/fetch_azure.py +0 -0
- /sky/{clouds/service_catalog → catalog}/data_fetchers/fetch_fluidstack.py +0 -0
- /sky/{clouds/service_catalog → catalog}/data_fetchers/fetch_ibm.py +0 -0
- /sky/{clouds/service_catalog/data_fetchers → client/cli}/__init__.py +0 -0
- /sky/dashboard/out/_next/static/{LksQgChY5izXjokL3LcEu → zB0ed6ge_W1MDszVHhijS}/_ssgManifest.js +0 -0
- {skypilot_nightly-1.0.0.dev20250509.dist-info → skypilot_nightly-1.0.0.dev20251107.dist-info}/entry_points.txt +0 -0
- {skypilot_nightly-1.0.0.dev20250509.dist-info → skypilot_nightly-1.0.0.dev20251107.dist-info}/licenses/LICENSE +0 -0
- {skypilot_nightly-1.0.0.dev20250509.dist-info → skypilot_nightly-1.0.0.dev20251107.dist-info}/top_level.txt +0 -0
sky/dag.py
CHANGED
|
@@ -24,6 +24,7 @@ class Dag:
|
|
|
24
24
|
self.graph = nx.DiGraph()
|
|
25
25
|
self.name: Optional[str] = None
|
|
26
26
|
self.policy_applied: bool = False
|
|
27
|
+
self.pool: Optional[str] = None
|
|
27
28
|
|
|
28
29
|
def add(self, task: 'task.Task') -> None:
|
|
29
30
|
self.graph.add_node(task)
|
|
@@ -83,6 +84,20 @@ class Dag:
|
|
|
83
84
|
task.validate(skip_file_mounts=skip_file_mounts,
|
|
84
85
|
skip_workdir=skip_workdir)
|
|
85
86
|
|
|
87
|
+
def resolve_and_validate_volumes(self) -> None:
|
|
88
|
+
for task in self.tasks:
|
|
89
|
+
task.resolve_and_validate_volumes()
|
|
90
|
+
|
|
91
|
+
def pre_mount_volumes(self) -> None:
|
|
92
|
+
vol_map = {}
|
|
93
|
+
# Deduplicate volume mounts.
|
|
94
|
+
for task in self.tasks:
|
|
95
|
+
if task.volume_mounts is not None:
|
|
96
|
+
for volume_mount in task.volume_mounts:
|
|
97
|
+
vol_map[volume_mount.volume_name] = volume_mount
|
|
98
|
+
for volume_mount in vol_map.values():
|
|
99
|
+
volume_mount.pre_mount()
|
|
100
|
+
|
|
86
101
|
|
|
87
102
|
class _DagContext(threading.local):
|
|
88
103
|
"""A thread-local stack of Dags."""
|
sky/dashboard/out/404.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><
|
|
1
|
+
<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="/dashboard/_next/static/css/0748ce22df867032.css" as="style"/><link rel="stylesheet" href="/dashboard/_next/static/css/0748ce22df867032.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/dashboard/_next/static/chunks/polyfills-78c92fac7aa8fdd8.js"></script><script src="/dashboard/_next/static/chunks/webpack-2679be77fc08a2f8.js" defer=""></script><script src="/dashboard/_next/static/chunks/framework-cf60a09ccd051a10.js" defer=""></script><script src="/dashboard/_next/static/chunks/main-f15ccb73239a3bf1.js" defer=""></script><script src="/dashboard/_next/static/chunks/pages/_app-bde01e4a2beec258.js" defer=""></script><script src="/dashboard/_next/static/chunks/pages/_error-c66a4e8afc46f17b.js" defer=""></script><script src="/dashboard/_next/static/zB0ed6ge_W1MDszVHhijS/_buildManifest.js" defer=""></script><script src="/dashboard/_next/static/zB0ed6ge_W1MDszVHhijS/_ssgManifest.js" defer=""></script></head><body><div id="__next"></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"zB0ed6ge_W1MDszVHhijS","assetPrefix":"/dashboard","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1141],{99333:function(e,s,t){t.d(s,{Z:function(){return a}});/**
|
|
2
|
+
* @license lucide-react v0.407.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/let a=(0,t(60998).Z)("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]])},98418:function(e,s,t){t.d(s,{Z:function(){return a}});/**
|
|
7
|
+
* @license lucide-react v0.407.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/let a=(0,t(60998).Z)("Trash",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]])},1812:function(e,s,t){t.d(s,{X:function(){return n}});var a=t(85893),r=t(67294);let l=e=>{if(!(null==e?void 0:e.message))return"An unexpected error occurred.";let s=e.message;return s.includes("failed:")&&(s=s.split("failed:")[1].trim()),s},n=e=>{let{error:s,title:t="Error",onDismiss:n}=e,[c,i]=(0,r.useState)(!1);if((0,r.useEffect)(()=>{s&&i(!1)},[s]),!s||c)return null;let o="string"==typeof s?s:l(s);return(0,a.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-md p-3 mb-4",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsx)("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),(0,a.jsx)("div",{className:"ml-3",children:(0,a.jsxs)("div",{className:"text-sm text-red-800",children:[(0,a.jsxs)("strong",{children:[t,":"]})," ",o]})})]}),(0,a.jsx)("button",{onClick:()=>{i(!0),n&&n()},className:"flex-shrink-0 ml-4 text-red-400 hover:text-red-600 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 focus:ring-offset-red-50 rounded","aria-label":"Dismiss error",children:(0,a.jsx)("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})})}},69123:function(e,s,t){t.d(s,{g:function(){return n}});var a=t(85893),r=t(67294),l=t(32350);let n=r.forwardRef((e,s)=>{let{className:t,...r}=e;return(0,a.jsx)("textarea",{className:(0,l.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:s,...r})});n.displayName="Textarea"},11141:function(e,s,t){t.r(s),t.d(s,{WorkspaceEditor:function(){return _}});var a=t(85893),r=t(67294),l=t(11163),n=t(17324),c=t(23266),i=t(68969);t(9353);var o=t(41664),d=t.n(o),u=t(9008),x=t.n(u),m=t(37673),h=t(30803),f=t(69123),g=t(55739),p=t(70282),b=t(6021),j=t(13626),y=t(98418),N=t(99333),w=t(50326);let k=e=>{let{className:s="",variant:t="default",children:r,...l}=e;return(0,a.jsx)("div",{role:"alert",className:"".concat("relative w-full rounded-lg border p-4 flex items-start space-x-2"," ").concat({default:"bg-blue-50 border-blue-200 text-blue-800",destructive:"bg-red-50 border-red-200 text-red-800"}[t]," ").concat(s),...l,children:r})},v=e=>{let{className:s="",children:t,...r}=e;return(0,a.jsx)("div",{className:"text-sm leading-relaxed ".concat(s),...r,children:t})};var C=t(53850),L=t(1812),E=t(47615),S=t(1272),W=t(93225),A=t(53081),M=t(6378);let Z=e=>{let{message:s}=e;return s?(0,a.jsxs)(k,{className:"border-green-200 bg-green-50",children:[(0,a.jsx)(p.Z,{className:"h-4 w-4 text-green-600"}),(0,a.jsx)(v,{className:"text-green-800",children:s})]}):null},D=e=>{let{workspaceName:s,config:t,enabledClouds:r=[]}=e;if(!t)return null;let l="default"===s,n=0===Object.keys(t).length;if(l&&n)return(0,a.jsx)("div",{className:"text-sm text-gray-500 mb-3 italic p-3 bg-sky-50 rounded border border-sky-200",children:"Workspace 'default' can use all accessible infrastructure."});let c=[],i=[],o=[],d=new Set(r.map(e=>e.toLowerCase()));Object.entries(t).forEach(e=>{let[s,t]=e;if("private"===s||"allowed_users"===s)return;let r=W.Z2[s.toLowerCase()]||s.toUpperCase(),l=null==r?void 0:r.toLowerCase(),n=d.has(l)||Array.from(d).some(e=>e.startsWith(l+"/")),u=()=>"kubernetes"===s.toLowerCase()?Array.from(d).filter(e=>e.startsWith(l+"/")).map(e=>e.split("/")[1]):[];if((null==t?void 0:t.disabled)===!0)i.push(r);else if(t&&Object.keys(t).length>0){let e="";if("gcp"===s.toLowerCase()&&t.project_id)e=" (Project ID: ".concat(t.project_id,")");else if("aws"===s.toLowerCase()&&t.region)e=" (Region: ".concat(t.region,")");else if("kubernetes"===s.toLowerCase()){let s=u();s.length>0&&(e=" (Contexts: ".concat(s.join(", "),")"))}n?c.push((0,a.jsxs)("span",{className:"block",children:[r,e," is enabled."]},"".concat(s,"-enabled"))):o.push((0,a.jsxs)("span",{className:"block text-amber-700",children:[r,e," is configured but not currently available."]},"".concat(s,"-configured-not-enabled")))}else if(n){let e="";if("kubernetes"===s.toLowerCase()){let s=u();s.length>0&&(e=" (Contexts: ".concat(s.join(", "),")"))}c.push((0,a.jsxs)("span",{className:"block",children:[r,e," is enabled (using default settings)."]},"".concat(s,"-default-enabled")))}else o.push((0,a.jsxs)("span",{className:"block text-amber-700",children:[r," is configured but not currently available."]},"".concat(s,"-default-not-enabled")))});let u=[];if(i.length>0){let e=i.join(" and ");u.push((0,a.jsxs)("span",{className:"block",children:[e," ",1===i.length?"is":"are"," explicitly disabled."]},"disabled-clouds"))}return(u.push(...c),u.push(...o),u.length>0)?(0,a.jsx)("div",{className:"text-sm text-gray-700 mb-3 p-3 bg-sky-50 rounded border border-sky-200",children:u}):!l&&n?(0,a.jsx)("div",{className:"text-sm text-gray-500 mb-3 italic p-3 bg-sky-50 rounded border border-sky-200",children:"This workspace has no specific cloud resource configurations and can use all accessible infrastructure."}):null},R=e=>{let{isPrivate:s}=e;return s?(0,a.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-gray-100 text-gray-700 border border-gray-300",children:"Private"}):(0,a.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-green-100 text-green-700 border border-green-300",children:"Public"})},P=e=>{let{workspaceConfig:s,allUsers:t}=e;if(!s.private)return null;let r=s.allowed_users||[],l=(t||[]).filter(e=>"admin"===e.role).map(e=>e.username),n=[...new Set([...r,...l])];return 0===n.length?(0,a.jsxs)("div",{className:"mt-4",children:[(0,a.jsx)("h4",{className:"mb-2 text-xs text-gray-500 tracking-wider",children:"Allowed Users (0)"}),(0,a.jsx)("div",{className:"text-amber-600 text-xs italic p-2 bg-amber-50 rounded border border-amber-200",children:"No users configured (workspace may be inaccessible)"})]}):(0,a.jsxs)("div",{className:"mt-4",children:[(0,a.jsxs)("h4",{className:"mb-2 text-xs text-gray-500 tracking-wider",children:["Allowed Users (",n.length,")"]}),(0,a.jsx)("div",{className:"space-y-1 max-h-48 overflow-y-auto border border-gray-200 rounded",children:n.map(e=>{let s=l.includes(e);return(0,a.jsxs)("div",{className:"flex items-center justify-between text-xs p-2 bg-gray-50 hover:bg-gray-100 border-b border-gray-100 last:border-b-0",children:[(0,a.jsx)("span",{className:"font-medium text-gray-700",children:e}),s?(0,a.jsxs)("span",{className:"inline-flex items-center text-blue-600",children:[(0,a.jsx)(C.r7,{className:"w-3 h-3 mr-1"}),"Admin"]}):(0,a.jsxs)("span",{className:"inline-flex items-center text-gray-600",children:[(0,a.jsx)(b.Z,{className:"w-3 h-3 mr-1"}),"User"]})]},e)})})]})};function _(e){let{workspaceName:s,isNewWorkspace:t=!1}=e,o=(0,l.useRouter)(),[u,p]=(0,r.useState)({}),[b,k]=(0,r.useState)({}),[v,W]=(0,r.useState)(""),[_,z]=(0,r.useState)(!0),[O,U]=(0,r.useState)(!1),[F,T]=(0,r.useState)(!1),[Y,I]=(0,r.useState)(null),[J,V]=(0,r.useState)(null),[H,B]=(0,r.useState)(null),[X,G]=(0,r.useState)([]),[q,K]=(0,r.useState)({showDialog:!1,deleting:!1,error:null}),[Q,$]=(0,r.useState)({totalClusterCount:0,runningClusterCount:0,managedJobsCount:0,clouds:[]}),[ee,es]=(0,r.useState)(!1),et=(0,r.useCallback)(async()=>{z(!0),I(null);try{let e;let[t,a]=await Promise.all([(0,n.getWorkspaces)(),(0,A.R)()]),r=t[s]||{};p(r),k(r),G(a||[]),e=0===Object.keys(r).length?"".concat(s,":\n # Empty workspace configuration - uses all accessible infrastructure\n"):S.ZP.dump({[s]:r},{indent:2,lineWidth:-1,noRefs:!0,skipInvalid:!0,flowLevel:-1}),W(e)}catch(e){console.error("Error fetching workspace config:",e),I(e)}finally{z(!1)}},[s]),ea=(0,r.useCallback)(async()=>{if(!t){es(!0);try{let[e,t,a]=await Promise.all([M.dashboardCache.get(c.getClusters),M.dashboardCache.get(i.getManagedJobs,[{allUsers:!0,skipFinished:!0,workspaceMatch:s,fields:["workspace","status"]}]),M.dashboardCache.get(n.getEnabledClouds,[s,!0])]),r=e.filter(e=>(e.workspace||"default")===s),l=r.filter(e=>"RUNNING"===e.status||"LAUNCHING"===e.status),o={};e.forEach(e=>{o[e.cluster]=e.workspace||"default"});let d=t.jobs||[],u=new Set(E.statusGroups.active),x=0;d.forEach(e=>{e.workspace===s&&u.has(e.status)&&x++}),$({totalClusterCount:r.length,runningClusterCount:l.length,managedJobsCount:x,clouds:Array.isArray(a)?a:[]})}catch(e){console.error("Failed to fetch workspace stats:",e)}finally{es(!1)}}},[s,t]);(0,r.useEffect)(()=>{t?(z(!1),W("".concat(s,":\n # New workspace configuration\n # Leave empty to use all accessible infrastructure\n"))):(et(),ea())},[s,t,et,ea]),(0,r.useEffect)(()=>{T(JSON.stringify(u)!==JSON.stringify(b))},[u,b]);let er=e=>{W(e),B(null);try{let t=S.ZP.load(e)||{},a=Object.keys(t);if(0===a.length)p({});else if(1===a.length){let e=a[0];if(e!==s){B('Workspace name cannot be changed. Expected "'.concat(s,'" but found "').concat(e,'".'));return}let r=t[s]||{};p(r)}else B("Configuration must contain only one workspace. Found: ".concat(a.join(", ")))}catch(e){B("Invalid YAML: ".concat(e.message))}},el=async()=>{U(!0),I(null),V(null);try{if(H)throw Error("Please fix YAML errors before saving");let e=S.ZP.load(v)||{},a=Object.keys(e);if(a.length>0&&a[0]!==s)throw Error('Workspace name cannot be changed. Expected "'.concat(s,'".'));t?(await (0,n.MB)(s,u),V("Workspace created successfully!"),setTimeout(()=>{o.push("/workspaces/".concat(s))},1500)):(await (0,n.eA)(s,u),V("Workspace updated successfully!"),k(u),ea())}catch(e){console.error("Error saving workspace:",e),I(e)}finally{U(!1)}},en=async()=>{K(e=>({...e,deleting:!0,error:null}));try{await (0,n.zl)(s),V("Workspace deleted successfully!"),setTimeout(()=>{o.push("/workspaces")},1500)}catch(e){console.error("Error deleting workspace:",e),K(s=>({...s,deleting:!1,error:e}))}},ec=()=>{K({showDialog:!1,deleting:!1,error:null})},ei=async()=>{await Promise.all([et(),ea()])};if(!o.isReady)return(0,a.jsx)("div",{children:"Loading..."});let eo=t?"Create New Workspace | SkyPilot Dashboard":"Workspace: ".concat(s," | SkyPilot Dashboard");return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(x(),{children:(0,a.jsx)("title",{children:eo})}),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4 h-5",children:[(0,a.jsxs)("div",{className:"text-base flex items-center",children:[(0,a.jsx)(d(),{href:"/workspaces",className:"text-sky-blue hover:underline",children:"Workspaces"}),(0,a.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,a.jsx)(d(),{href:t?"/workspace/new":"/workspaces/".concat(s),className:"text-sky-blue hover:underline",children:t?"New Workspace":s}),F&&(0,a.jsx)("span",{className:"ml-3 px-2 py-1 bg-yellow-100 text-yellow-800 text-xs rounded",children:"Unsaved changes"})]}),(0,a.jsxs)("div",{className:"text-sm flex items-center",children:[(_||O||ee)&&(0,a.jsxs)("div",{className:"flex items-center mr-4",children:[(0,a.jsx)(g.Z,{size:15,className:"mt-0"}),(0,a.jsx)("span",{className:"ml-2 text-gray-500",children:O?"Saving...":"Loading..."})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-4",children:[!t&&(0,a.jsxs)("button",{onClick:ei,disabled:_||O||ee,className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center",children:[(0,a.jsx)(j.Z,{className:"w-4 h-4 mr-1.5"}),"Refresh"]}),!t&&"default"!==s&&(0,a.jsxs)("button",{onClick:()=>K({...q,showDialog:!0}),disabled:q.deleting||O,className:"text-red-600 hover:text-red-700 font-medium inline-flex items-center",children:[(0,a.jsx)(y.Z,{className:"w-4 h-4 mr-1.5"}),"Delete"]})]})]})]}),_?(0,a.jsxs)("div",{className:"flex justify-center items-center py-12",children:[(0,a.jsx)(g.Z,{size:24,className:"mr-2"}),(0,a.jsx)("span",{className:"text-gray-500",children:"Loading workspace configuration..."})]}):(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsx)(L.X,{error:Y,title:"Error",onDismiss:()=>I(null)}),(0,a.jsx)(Z,{message:J}),(0,a.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[!t&&(0,a.jsx)("div",{className:"lg:col-span-1",children:(0,a.jsxs)(m.Zb,{className:"h-full",children:[(0,a.jsx)(m.Ol,{children:(0,a.jsx)(m.ll,{className:"text-base font-normal",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"font-semibold",children:"Workspace:"})," ",s]}),(0,a.jsx)(R,{isPrivate:!0===b.private})]})})}),(0,a.jsxs)(m.aY,{className:"text-sm pb-2 flex-1",children:[(0,a.jsxs)("div",{className:"py-2 flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center text-gray-600",children:[(0,a.jsx)(C.QT,{className:"w-4 h-4 mr-2 text-gray-500"}),(0,a.jsx)("span",{children:"Clusters (Running / Total)"})]}),(0,a.jsx)("span",{className:"font-normal text-gray-800",children:ee?"...":"".concat(Q.runningClusterCount," / ").concat(Q.totalClusterCount)})]}),(0,a.jsxs)("div",{className:"py-2 flex items-center justify-between border-t border-gray-100",children:[(0,a.jsxs)("div",{className:"flex items-center text-gray-600",children:[(0,a.jsx)(C.Vp,{className:"w-4 h-4 mr-2 text-gray-500"}),(0,a.jsx)("span",{children:"Managed Jobs"})]}),(0,a.jsx)("span",{className:"font-normal text-gray-800",children:ee?"...":Q.managedJobsCount})]})]}),(0,a.jsxs)("div",{className:"px-6 pb-6 text-sm pt-3",children:[(0,a.jsx)("h4",{className:"mb-2 text-xs text-gray-500 tracking-wider",children:"Enabled Infra"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-x-4 gap-y-1",children:ee?(0,a.jsx)("span",{className:"text-gray-500",children:"Loading..."}):Q.clouds.length>0?Q.clouds.map(e=>(0,a.jsxs)("div",{className:"flex items-center text-gray-700",children:[(0,a.jsx)(C.Ye,{className:"w-3.5 h-3.5 mr-1.5 text-green-500"}),(0,a.jsx)("span",{children:e})]},e)):(0,a.jsx)("span",{className:"text-gray-500 italic",children:"No enabled infrastructure"})}),(0,a.jsx)("div",{className:"mt-4",children:(0,a.jsx)(D,{workspaceName:s,config:b,enabledClouds:Q.clouds})}),(0,a.jsx)(P,{workspaceConfig:b,allUsers:X})]})]})}),(0,a.jsx)("div",{className:t?"lg:col-span-3":"lg:col-span-2",children:(0,a.jsxs)(m.Zb,{className:"h-full flex flex-col",children:[(0,a.jsx)(m.Ol,{children:(0,a.jsx)(m.ll,{className:"text-base font-normal",children:t?"New Workspace YAML":"Edit Workspace YAML"})}),(0,a.jsx)(m.aY,{className:"flex-1 flex flex-col",children:(0,a.jsxs)("div",{className:"space-y-4 flex-1 flex flex-col",children:[H&&(0,a.jsx)(L.X,{error:H,onDismiss:()=>B(null)}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,a.jsxs)("p",{className:"text-sm text-gray-600 mb-3",children:["Configure infra-specific settings for this workspace. Leave empty to use all accessible infrastructure. Refer to"," ",(0,a.jsx)("a",{href:"https://docs.skypilot.co/en/latest/admin/workspaces.html#configuration",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600",children:"SkyPilot Docs"})," ","for more details."]}),(0,a.jsxs)("div",{className:"mb-4",children:[(0,a.jsx)("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Example configuration:"}),(0,a.jsx)("div",{className:"p-3 bg-gray-50 border rounded-lg",children:(0,a.jsx)("pre",{className:"text-xs font-mono text-gray-600 whitespace-pre-wrap",children:"".concat(s||"my-workspace",":\n private: true\n allowed_users:\n - user1@mydomain.com\n - user2@mydomain.com\n gcp:\n project_id: xxx\n disabled: false\n kubernetes:\n allowed_contexts:\n - context-1")})})]}),(0,a.jsx)(f.g,{value:v,onChange:e=>er(e.target.value),className:"font-mono text-sm flex-1 resize-none",style:{minHeight:"350px"},spellCheck:!1,placeholder:"# Enter workspace configuration in YAML format"}),(0,a.jsx)("div",{className:"flex justify-end space-x-3 pt-3 border-gray-200",children:(0,a.jsxs)(h.z,{onClick:el,disabled:O||H||_,className:"inline-flex items-center bg-sky-600 hover:bg-sky-700 text-white",children:[(0,a.jsx)(N.Z,{className:"w-4 h-4 mr-1.5"}),O?"Applying...":"Apply"]})})]})]})})]})})]})]}),(0,a.jsx)(w.Vq,{open:q.showDialog,onOpenChange:ec,children:(0,a.jsxs)(w.cZ,{className:"sm:max-w-md",children:[(0,a.jsxs)(w.fK,{className:"",children:[(0,a.jsx)(w.$N,{children:"Delete Workspace"}),(0,a.jsxs)(w.Be,{children:['Are you sure you want to delete workspace "',s,'"? This action cannot be undone.']})]}),q.error&&(0,a.jsx)(L.X,{error:q.error,title:"Deletion Failed",onDismiss:()=>K(e=>({...e,error:null}))}),(0,a.jsxs)(w.cN,{className:"",children:[(0,a.jsx)(h.z,{variant:"outline",onClick:ec,disabled:q.deleting,children:"Cancel"}),(0,a.jsx)(h.z,{variant:"destructive",onClick:en,disabled:q.deleting,children:q.deleting?"Deleting...":"Delete"})]})]})})]})]})}},53081:function(e,s,t){t.d(s,{R:function(){return r}});var a=t(47145);async function r(){try{let e=await a.x.get("/users");if(!e.ok)throw Error("Failed to fetch users with status ".concat(e.status));return(await e.json()).map(e=>({userId:e.id,username:e.name,role:e.role,created_at:e.created_at}))||[]}catch(e){throw console.error("Failed to fetch users:",e),e}}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1272],{1272:function(e,t,n){var i={isNothing:/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */function(e){return null==e},isObject:function(e){return"object"==typeof e&&null!==e},repeat:function(e,t){var n,i="";for(n=0;n<t;n+=1)i+=e;return i},isNegativeZero:function(e){return 0===e&&Number.NEGATIVE_INFINITY===1/e}};function r(e,t){var n="",i=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+="\n\n"+e.mark.snippet),i+" "+n):i}function o(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=r(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=Error().stack||""}function a(e,t,n,i,r){var o="",a="",l=Math.floor(r/2)-1;return i-t>l&&(t=i-l+(o=" ... ").length),n-i>l&&(n=i+l-(a=" ...").length),{str:o+e.slice(t,n).replace(/\t/g,"→")+a,pos:i-t+o.length}}function l(e,t){return i.repeat(" ",t-e.length)+e}o.prototype=Object.create(Error.prototype),o.prototype.constructor=o,o.prototype.toString=function(e){return this.name+": "+r(this,e)};var c=function(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),"number"!=typeof t.indent&&(t.indent=1),"number"!=typeof t.linesBefore&&(t.linesBefore=3),"number"!=typeof t.linesAfter&&(t.linesAfter=2);for(var n=/\r?\n|\r|\0/g,r=[0],o=[],c=-1;s=n.exec(e.buffer);)o.push(s.index),r.push(s.index+s[0].length),e.position<=s.index&&c<0&&(c=r.length-2);c<0&&(c=r.length-1);var s,u,p,f="",d=Math.min(e.line+t.linesAfter,o.length).toString().length,h=t.maxLength-(t.indent+d+3);for(u=1;u<=t.linesBefore&&!(c-u<0);u++)p=a(e.buffer,r[c-u],o[c-u],e.position-(r[c]-r[c-u]),h),f=i.repeat(" ",t.indent)+l((e.line-u+1).toString(),d)+" | "+p.str+"\n"+f;for(p=a(e.buffer,r[c],o[c],e.position,h),f+=i.repeat(" ",t.indent)+l((e.line+1).toString(),d)+" | "+p.str+"\n"+i.repeat("-",t.indent+d+3+p.pos)+"^\n",u=1;u<=t.linesAfter&&!(c+u>=o.length);u++)p=a(e.buffer,r[c+u],o[c+u],e.position-(r[c]-r[c+u]),h),f+=i.repeat(" ",t.indent)+l((e.line+u+1).toString(),d)+" | "+p.str+"\n";return f.replace(/\n$/,"")},s=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],u=["scalar","sequence","mapping"],p=function(e,t){var n,i;if(Object.keys(t=t||{}).forEach(function(t){if(-1===s.indexOf(t))throw new o('Unknown option "'+t+'" is met in definition of "'+e+'" YAML type.')}),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=(n=t.styleAliases||null,i={},null!==n&&Object.keys(n).forEach(function(e){n[e].forEach(function(t){i[String(t)]=e})}),i),-1===u.indexOf(this.kind))throw new o('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')};function f(e,t){var n=[];return e[t].forEach(function(e){var t=n.length;n.forEach(function(n,i){n.tag===e.tag&&n.kind===e.kind&&n.multi===e.multi&&(t=i)}),n[t]=e}),n}function d(e){return this.extend(e)}d.prototype.extend=function(e){var t=[],n=[];if(e instanceof p)n.push(e);else if(Array.isArray(e))n=n.concat(e);else if(e&&(Array.isArray(e.implicit)||Array.isArray(e.explicit)))e.implicit&&(t=t.concat(e.implicit)),e.explicit&&(n=n.concat(e.explicit));else throw new o("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");t.forEach(function(e){if(!(e instanceof p))throw new o("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(e.loadKind&&"scalar"!==e.loadKind)throw new o("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(e.multi)throw new o("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),n.forEach(function(e){if(!(e instanceof p))throw new o("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var i=Object.create(d.prototype);return i.implicit=(this.implicit||[]).concat(t),i.explicit=(this.explicit||[]).concat(n),i.compiledImplicit=f(i,"implicit"),i.compiledExplicit=f(i,"explicit"),i.compiledTypeMap=function(){var e,t,n={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function i(e){e.multi?(n.multi[e.kind].push(e),n.multi.fallback.push(e)):n[e.kind][e.tag]=n.fallback[e.tag]=e}for(e=0,t=arguments.length;e<t;e+=1)arguments[e].forEach(i);return n}(i.compiledImplicit,i.compiledExplicit),i};var h=new p("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return null!==e?e:""}}),g=new p("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return null!==e?e:[]}}),m=new p("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return null!==e?e:{}}}),y=new d({explicit:[h,g,m]}),b=new p("tag:yaml.org,2002:null",{kind:"scalar",resolve:function(e){if(null===e)return!0;var t=e.length;return 1===t&&"~"===e||4===t&&("null"===e||"Null"===e||"NULL"===e)},construct:function(){return null},predicate:function(e){return null===e},represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"}),A=new p("tag:yaml.org,2002:bool",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t=e.length;return 4===t&&("true"===e||"True"===e||"TRUE"===e)||5===t&&("false"===e||"False"===e||"FALSE"===e)},construct:function(e){return"true"===e||"True"===e||"TRUE"===e},predicate:function(e){return"[object Boolean]"===Object.prototype.toString.call(e)},represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"}),v=new p("tag:yaml.org,2002:int",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,n,i,r,o=e.length,a=0,l=!1;if(!o)return!1;if(("-"===(r=e[a])||"+"===r)&&(r=e[++a]),"0"===r){if(a+1===o)return!0;if("b"===(r=e[++a])){for(a++;a<o;a++)if("_"!==(r=e[a])){if("0"!==r&&"1"!==r)return!1;l=!0}return l&&"_"!==r}if("x"===r){for(a++;a<o;a++)if("_"!==(r=e[a])){if(!(48<=(t=e.charCodeAt(a))&&t<=57||65<=t&&t<=70||97<=t&&t<=102))return!1;l=!0}return l&&"_"!==r}if("o"===r){for(a++;a<o;a++)if("_"!==(r=e[a])){if(!(48<=(n=e.charCodeAt(a))&&n<=55))return!1;l=!0}return l&&"_"!==r}}if("_"===r)return!1;for(;a<o;a++)if("_"!==(r=e[a])){if(!(48<=(i=e.charCodeAt(a))&&i<=57))return!1;l=!0}return!!l&&"_"!==r},construct:function(e){var t,n=e,i=1;if(-1!==n.indexOf("_")&&(n=n.replace(/_/g,"")),("-"===(t=n[0])||"+"===t)&&("-"===t&&(i=-1),t=(n=n.slice(1))[0]),"0"===n)return 0;if("0"===t){if("b"===n[1])return i*parseInt(n.slice(2),2);if("x"===n[1])return i*parseInt(n.slice(2),16);if("o"===n[1])return i*parseInt(n.slice(2),8)}return i*parseInt(n,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&e%1==0&&!i.isNegativeZero(e)},represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),k=RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),w=/^[-+]?[0-9]+e/,C=new p("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(e){return!!(null!==e&&k.test(e)&&"_"!==e[e.length-1])},construct:function(e){var t,n;return(n="-"===(t=e.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(t[0])>=0&&(t=t.slice(1)),".inf"===t)?1===n?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===t?NaN:n*parseFloat(t,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&(e%1!=0||i.isNegativeZero(e))},represent:function(e,t){var n;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(i.isNegativeZero(e))return"-0.0";return n=e.toString(10),w.test(n)?n.replace("e",".e"):n},defaultStyle:"lowercase"}),x=y.extend({implicit:[b,A,v,C]}),I=RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),O=RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"),S=new p("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(e){return null!==e&&(null!==I.exec(e)||null!==O.exec(e))},construct:function(e){var t,n,i,r,o,a,l,c,s=0,u=null;if(null===(t=I.exec(e))&&(t=O.exec(e)),null===t)throw Error("Date resolve error");if(n=+t[1],i=+t[2]-1,r=+t[3],!t[4])return new Date(Date.UTC(n,i,r));if(o=+t[4],a=+t[5],l=+t[6],t[7]){for(s=t[7].slice(0,3);s.length<3;)s+="0";s=+s}return t[9]&&(u=(60*+t[10]+ +(t[11]||0))*6e4,"-"===t[9]&&(u=-u)),c=new Date(Date.UTC(n,i,r,o,a,l,s)),u&&c.setTime(c.getTime()-u),c},instanceOf:Date,represent:function(e){return e.toISOString()}}),j=new p("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(e){return"<<"===e||null===e}}),T="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r",N=new p("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,n,i=0,r=e.length;for(n=0;n<r;n++)if(!((t=T.indexOf(e.charAt(n)))>64)){if(t<0)return!1;i+=6}return i%8==0},construct:function(e){var t,n,i=e.replace(/[\r\n=]/g,""),r=i.length,o=0,a=[];for(t=0;t<r;t++)t%4==0&&t&&(a.push(o>>16&255),a.push(o>>8&255),a.push(255&o)),o=o<<6|T.indexOf(i.charAt(t));return 0==(n=r%4*6)?(a.push(o>>16&255),a.push(o>>8&255),a.push(255&o)):18===n?(a.push(o>>10&255),a.push(o>>2&255)):12===n&&a.push(o>>4&255),new Uint8Array(a)},predicate:function(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)},represent:function(e){var t,n,i="",r=0,o=e.length;for(t=0;t<o;t++)t%3==0&&t&&(i+=T[r>>18&63]+T[r>>12&63]+T[r>>6&63]+T[63&r]),r=(r<<8)+e[t];return 0==(n=o%3)?i+=T[r>>18&63]+T[r>>12&63]+T[r>>6&63]+T[63&r]:2===n?i+=T[r>>10&63]+T[r>>4&63]+T[r<<2&63]+T[64]:1===n&&(i+=T[r>>2&63]+T[r<<4&63]+T[64]+T[64]),i}}),F=Object.prototype.hasOwnProperty,E=Object.prototype.toString,M=new p("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(e){if(null===e)return!0;var t,n,i,r,o,a=[];for(t=0,n=e.length;t<n;t+=1){if(i=e[t],o=!1,"[object Object]"!==E.call(i))return!1;for(r in i)if(F.call(i,r)){if(o)return!1;o=!0}if(!o||-1!==a.indexOf(r))return!1;a.push(r)}return!0},construct:function(e){return null!==e?e:[]}}),L=Object.prototype.toString,_=new p("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:function(e){var t,n,i,r,o;if(null===e)return!0;for(t=0,o=Array(e.length),n=e.length;t<n;t+=1){if(i=e[t],"[object Object]"!==L.call(i)||1!==(r=Object.keys(i)).length)return!1;o[t]=[r[0],i[r[0]]]}return!0},construct:function(e){var t,n,i,r,o;if(null===e)return[];for(t=0,o=Array(e.length),n=e.length;t<n;t+=1)r=Object.keys(i=e[t]),o[t]=[r[0],i[r[0]]];return o}}),D=Object.prototype.hasOwnProperty,q=new p("tag:yaml.org,2002:set",{kind:"mapping",resolve:function(e){var t;if(null===e)return!0;for(t in e)if(D.call(e,t)&&null!==e[t])return!1;return!0},construct:function(e){return null!==e?e:{}}}),U=x.extend({implicit:[S,j],explicit:[N,M,_,q]}),Y=Object.prototype.hasOwnProperty,R=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,B=/[\x85\u2028\u2029]/,K=/[,\[\]\{\}]/,P=/^(?:!|!!|![a-z\-]+!)$/i,W=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function $(e){return Object.prototype.toString.call(e)}function G(e){return 10===e||13===e}function Z(e){return 9===e||32===e}function V(e){return 9===e||32===e||10===e||13===e}function H(e){return 44===e||91===e||93===e||123===e||125===e}function Q(e){return 48===e?"\0":97===e?"\x07":98===e?"\b":116===e?" ":9===e?" ":110===e?"\n":118===e?"\v":102===e?"\f":114===e?"\r":101===e?"\x1b":32===e?" ":34===e?'"':47===e?"/":92===e?"\\":78===e?"\x85":95===e?"\xa0":76===e?"\u2028":80===e?"\u2029":""}for(var z=Array(256),J=Array(256),X=0;X<256;X++)z[X]=Q(X)?1:0,J[X]=Q(X);function ee(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||U,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function et(e,t){var n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=c(n),new o(t,n)}function en(e,t){throw et(e,t)}function ei(e,t){e.onWarning&&e.onWarning.call(null,et(e,t))}var er={YAML:function(e,t,n){var i,r,o;null!==e.version&&en(e,"duplication of %YAML directive"),1!==n.length&&en(e,"YAML directive accepts exactly one argument"),null===(i=/^([0-9]+)\.([0-9]+)$/.exec(n[0]))&&en(e,"ill-formed argument of the YAML directive"),r=parseInt(i[1],10),o=parseInt(i[2],10),1!==r&&en(e,"unacceptable YAML version of the document"),e.version=n[0],e.checkLineBreaks=o<2,1!==o&&2!==o&&ei(e,"unsupported YAML version of the document")},TAG:function(e,t,n){var i,r;2!==n.length&&en(e,"TAG directive accepts exactly two arguments"),i=n[0],r=n[1],P.test(i)||en(e,"ill-formed tag handle (first argument) of the TAG directive"),Y.call(e.tagMap,i)&&en(e,'there is a previously declared suffix for "'+i+'" tag handle'),W.test(r)||en(e,"ill-formed tag prefix (second argument) of the TAG directive");try{r=decodeURIComponent(r)}catch(t){en(e,"tag prefix is malformed: "+r)}e.tagMap[i]=r}};function eo(e,t,n,i){var r,o,a,l;if(t<n){if(l=e.input.slice(t,n),i)for(r=0,o=l.length;r<o;r+=1)9===(a=l.charCodeAt(r))||32<=a&&a<=1114111||en(e,"expected valid JSON character");else R.test(l)&&en(e,"the stream contains non-printable characters");e.result+=l}}function ea(e,t,n,r){var o,a,l,c;for(i.isObject(n)||en(e,"cannot merge mappings; the provided source object is unacceptable"),l=0,c=(o=Object.keys(n)).length;l<c;l+=1)a=o[l],Y.call(t,a)||(t[a]=n[a],r[a]=!0)}function el(e,t,n,i,r,o,a,l,c){var s,u;if(Array.isArray(r))for(s=0,u=(r=Array.prototype.slice.call(r)).length;s<u;s+=1)Array.isArray(r[s])&&en(e,"nested arrays are not supported inside keys"),"object"==typeof r&&"[object Object]"===$(r[s])&&(r[s]="[object Object]");if("object"==typeof r&&"[object Object]"===$(r)&&(r="[object Object]"),r=String(r),null===t&&(t={}),"tag:yaml.org,2002:merge"===i){if(Array.isArray(o))for(s=0,u=o.length;s<u;s+=1)ea(e,t,o[s],n);else ea(e,t,o,n)}else!e.json&&!Y.call(n,r)&&Y.call(t,r)&&(e.line=a||e.line,e.lineStart=l||e.lineStart,e.position=c||e.position,en(e,"duplicated mapping key")),"__proto__"===r?Object.defineProperty(t,r,{configurable:!0,enumerable:!0,writable:!0,value:o}):t[r]=o,delete n[r];return t}function ec(e){var t;10===(t=e.input.charCodeAt(e.position))?e.position++:13===t?(e.position++,10===e.input.charCodeAt(e.position)&&e.position++):en(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function es(e,t,n){for(var i=0,r=e.input.charCodeAt(e.position);0!==r;){for(;Z(r);)9===r&&-1===e.firstTabInLine&&(e.firstTabInLine=e.position),r=e.input.charCodeAt(++e.position);if(t&&35===r)do r=e.input.charCodeAt(++e.position);while(10!==r&&13!==r&&0!==r);if(G(r))for(ec(e),r=e.input.charCodeAt(e.position),i++,e.lineIndent=0;32===r;)e.lineIndent++,r=e.input.charCodeAt(++e.position);else break}return -1!==n&&0!==i&&e.lineIndent<n&&ei(e,"deficient indentation"),i}function eu(e){var t,n=e.position;return!!((45===(t=e.input.charCodeAt(n))||46===t)&&t===e.input.charCodeAt(n+1)&&t===e.input.charCodeAt(n+2)&&(n+=3,0===(t=e.input.charCodeAt(n))||V(t)))}function ep(e,t){1===t?e.result+=" ":t>1&&(e.result+=i.repeat("\n",t-1))}function ef(e,t){var n,i,r=e.tag,o=e.anchor,a=[],l=!1;if(-1!==e.firstTabInLine)return!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=a),i=e.input.charCodeAt(e.position);0!==i&&(-1!==e.firstTabInLine&&(e.position=e.firstTabInLine,en(e,"tab characters must not be used in indentation")),45===i&&V(e.input.charCodeAt(e.position+1)));){if(l=!0,e.position++,es(e,!0,-1)&&e.lineIndent<=t){a.push(null),i=e.input.charCodeAt(e.position);continue}if(n=e.line,ed(e,t,3,!1,!0),a.push(e.result),es(e,!0,-1),i=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&0!==i)en(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break}return!!l&&(e.tag=r,e.anchor=o,e.kind="sequence",e.result=a,!0)}function ed(e,t,n,r,o){var a,l,c,s,u,p,f,d,h,g=1,m=!1,y=!1;if(null!==e.listener&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,a=l=c=4===n||3===n,r&&es(e,!0,-1)&&(m=!0,e.lineIndent>t?g=1:e.lineIndent===t?g=0:e.lineIndent<t&&(g=-1)),1===g)for(;function(e){var t,n,i,r,o=!1,a=!1;if(33!==(r=e.input.charCodeAt(e.position)))return!1;if(null!==e.tag&&en(e,"duplication of a tag property"),60===(r=e.input.charCodeAt(++e.position))?(o=!0,r=e.input.charCodeAt(++e.position)):33===r?(a=!0,n="!!",r=e.input.charCodeAt(++e.position)):n="!",t=e.position,o){do r=e.input.charCodeAt(++e.position);while(0!==r&&62!==r);e.position<e.length?(i=e.input.slice(t,e.position),r=e.input.charCodeAt(++e.position)):en(e,"unexpected end of the stream within a verbatim tag")}else{for(;0!==r&&!V(r);)33===r&&(a?en(e,"tag suffix cannot contain exclamation marks"):(n=e.input.slice(t-1,e.position+1),P.test(n)||en(e,"named tag handle cannot contain such characters"),a=!0,t=e.position+1)),r=e.input.charCodeAt(++e.position);i=e.input.slice(t,e.position),K.test(i)&&en(e,"tag suffix cannot contain flow indicator characters")}i&&!W.test(i)&&en(e,"tag name cannot contain such characters: "+i);try{i=decodeURIComponent(i)}catch(t){en(e,"tag name is malformed: "+i)}return o?e.tag=i:Y.call(e.tagMap,n)?e.tag=e.tagMap[n]+i:"!"===n?e.tag="!"+i:"!!"===n?e.tag="tag:yaml.org,2002:"+i:en(e,'undeclared tag handle "'+n+'"'),!0}(e)||function(e){var t,n;if(38!==(n=e.input.charCodeAt(e.position)))return!1;for(null!==e.anchor&&en(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;0!==n&&!V(n)&&!H(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&en(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}(e);)es(e,!0,-1)?(m=!0,c=a,e.lineIndent>t?g=1:e.lineIndent===t?g=0:e.lineIndent<t&&(g=-1)):c=!1;if(c&&(c=m||o),(1===g||4===n)&&(d=1===n||2===n?t:t+1,h=e.position-e.lineStart,1===g?c&&(ef(e,h)||function(e,t,n){var i,r,o,a,l,c,s,u=e.tag,p=e.anchor,f={},d=Object.create(null),h=null,g=null,m=null,y=!1,b=!1;if(-1!==e.firstTabInLine)return!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=f),s=e.input.charCodeAt(e.position);0!==s;){if(y||-1===e.firstTabInLine||(e.position=e.firstTabInLine,en(e,"tab characters must not be used in indentation")),i=e.input.charCodeAt(e.position+1),o=e.line,(63===s||58===s)&&V(i))63===s?(y&&(el(e,f,d,h,g,null,a,l,c),h=g=m=null),b=!0,y=!0,r=!0):y?(y=!1,r=!0):en(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,s=i;else{if(a=e.line,l=e.lineStart,c=e.position,!ed(e,n,2,!1,!0))break;if(e.line===o){for(s=e.input.charCodeAt(e.position);Z(s);)s=e.input.charCodeAt(++e.position);if(58===s)V(s=e.input.charCodeAt(++e.position))||en(e,"a whitespace character is expected after the key-value separator within a block mapping"),y&&(el(e,f,d,h,g,null,a,l,c),h=g=m=null),b=!0,y=!1,r=!1,h=e.tag,g=e.result;else{if(!b)return e.tag=u,e.anchor=p,!0;en(e,"can not read an implicit mapping pair; a colon is missed")}}else{if(!b)return e.tag=u,e.anchor=p,!0;en(e,"can not read a block mapping entry; a multiline key may not be an implicit key")}}if((e.line===o||e.lineIndent>t)&&(y&&(a=e.line,l=e.lineStart,c=e.position),ed(e,t,4,!0,r)&&(y?g=e.result:m=e.result),y||(el(e,f,d,h,g,m,a,l,c),h=g=m=null),es(e,!0,-1),s=e.input.charCodeAt(e.position)),(e.line===o||e.lineIndent>t)&&0!==s)en(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return y&&el(e,f,d,h,g,null,a,l,c),b&&(e.tag=u,e.anchor=p,e.kind="mapping",e.result=f),b}(e,h,d))||function(e,t){var n,i,r,o,a,l,c,s,u,p,f,d,h=!0,g=e.tag,m=e.anchor,y=Object.create(null);if(91===(d=e.input.charCodeAt(e.position)))a=93,s=!1,o=[];else{if(123!==d)return!1;a=125,s=!0,o={}}for(null!==e.anchor&&(e.anchorMap[e.anchor]=o),d=e.input.charCodeAt(++e.position);0!==d;){if(es(e,!0,t),(d=e.input.charCodeAt(e.position))===a)return e.position++,e.tag=g,e.anchor=m,e.kind=s?"mapping":"sequence",e.result=o,!0;h?44===d&&en(e,"expected the node content, but found ','"):en(e,"missed comma between flow collection entries"),p=u=f=null,l=c=!1,63===d&&V(e.input.charCodeAt(e.position+1))&&(l=c=!0,e.position++,es(e,!0,t)),n=e.line,i=e.lineStart,r=e.position,ed(e,t,1,!1,!0),p=e.tag,u=e.result,es(e,!0,t),d=e.input.charCodeAt(e.position),(c||e.line===n)&&58===d&&(l=!0,d=e.input.charCodeAt(++e.position),es(e,!0,t),ed(e,t,1,!1,!0),f=e.result),s?el(e,o,y,p,u,f,n,i,r):l?o.push(el(e,null,y,p,u,f,n,i,r)):o.push(u),es(e,!0,t),44===(d=e.input.charCodeAt(e.position))?(h=!0,d=e.input.charCodeAt(++e.position)):h=!1}en(e,"unexpected end of the stream within a flow collection")}(e,d)?y=!0:(l&&function(e,t){var n,r,o,a,l,c=1,s=!1,u=!1,p=t,f=0,d=!1;if(124===(l=e.input.charCodeAt(e.position)))o=!1;else{if(62!==l)return!1;o=!0}for(e.kind="scalar",e.result="";0!==l;)if(43===(l=e.input.charCodeAt(++e.position))||45===l)1===c?c=43===l?3:2:en(e,"repeat of a chomping mode identifier");else if((a=48<=(n=l)&&n<=57?n-48:-1)>=0)0===a?en(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):u?en(e,"repeat of an indentation width identifier"):(p=t+a-1,u=!0);else break;if(Z(l)){do l=e.input.charCodeAt(++e.position);while(Z(l));if(35===l)do l=e.input.charCodeAt(++e.position);while(!G(l)&&0!==l)}for(;0!==l;){for(ec(e),e.lineIndent=0,l=e.input.charCodeAt(e.position);(!u||e.lineIndent<p)&&32===l;)e.lineIndent++,l=e.input.charCodeAt(++e.position);if(!u&&e.lineIndent>p&&(p=e.lineIndent),G(l)){f++;continue}if(e.lineIndent<p){3===c?e.result+=i.repeat("\n",s?1+f:f):1===c&&s&&(e.result+="\n");break}for(o?Z(l)?(d=!0,e.result+=i.repeat("\n",s?1+f:f)):d?(d=!1,e.result+=i.repeat("\n",f+1)):0===f?s&&(e.result+=" "):e.result+=i.repeat("\n",f):e.result+=i.repeat("\n",s?1+f:f),s=!0,u=!0,f=0,r=e.position;!G(l)&&0!==l;)l=e.input.charCodeAt(++e.position);eo(e,r,e.position,!1)}return!0}(e,d)||function(e,t){var n,i,r;if(39!==(n=e.input.charCodeAt(e.position)))return!1;for(e.kind="scalar",e.result="",e.position++,i=r=e.position;0!==(n=e.input.charCodeAt(e.position));)if(39===n){if(eo(e,i,e.position,!0),39!==(n=e.input.charCodeAt(++e.position)))return!0;i=e.position,e.position++,r=e.position}else G(n)?(eo(e,i,r,!0),ep(e,es(e,!1,t)),i=r=e.position):e.position===e.lineStart&&eu(e)?en(e,"unexpected end of the document within a single quoted scalar"):(e.position++,r=e.position);en(e,"unexpected end of the stream within a single quoted scalar")}(e,d)||function(e,t){var n,i,r,o,a,l,c,s;if(34!==(l=e.input.charCodeAt(e.position)))return!1;for(e.kind="scalar",e.result="",e.position++,n=i=e.position;0!==(l=e.input.charCodeAt(e.position));){if(34===l)return eo(e,n,e.position,!0),e.position++,!0;if(92===l){if(eo(e,n,e.position,!0),G(l=e.input.charCodeAt(++e.position)))es(e,!1,t);else if(l<256&&z[l])e.result+=J[l],e.position++;else if((a=120===(c=l)?2:117===c?4:85===c?8:0)>0){for(r=a,o=0;r>0;r--)(a=function(e){var t;return 48<=e&&e<=57?e-48:97<=(t=32|e)&&t<=102?t-97+10:-1}(l=e.input.charCodeAt(++e.position)))>=0?o=(o<<4)+a:en(e,"expected hexadecimal character");e.result+=(s=o)<=65535?String.fromCharCode(s):String.fromCharCode((s-65536>>10)+55296,(s-65536&1023)+56320),e.position++}else en(e,"unknown escape sequence");n=i=e.position}else G(l)?(eo(e,n,i,!0),ep(e,es(e,!1,t)),n=i=e.position):e.position===e.lineStart&&eu(e)?en(e,"unexpected end of the document within a double quoted scalar"):(e.position++,i=e.position)}en(e,"unexpected end of the stream within a double quoted scalar")}(e,d)?y=!0:function(e){var t,n,i;if(42!==(i=e.input.charCodeAt(e.position)))return!1;for(i=e.input.charCodeAt(++e.position),t=e.position;0!==i&&!V(i)&&!H(i);)i=e.input.charCodeAt(++e.position);return e.position===t&&en(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),Y.call(e.anchorMap,n)||en(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],es(e,!0,-1),!0}(e)?(y=!0,(null!==e.tag||null!==e.anchor)&&en(e,"alias node should not have any properties")):function(e,t,n){var i,r,o,a,l,c,s,u,p=e.kind,f=e.result;if(V(u=e.input.charCodeAt(e.position))||H(u)||35===u||38===u||42===u||33===u||124===u||62===u||39===u||34===u||37===u||64===u||96===u||(63===u||45===u)&&(V(i=e.input.charCodeAt(e.position+1))||n&&H(i)))return!1;for(e.kind="scalar",e.result="",r=o=e.position,a=!1;0!==u;){if(58===u){if(V(i=e.input.charCodeAt(e.position+1))||n&&H(i))break}else if(35===u){if(V(e.input.charCodeAt(e.position-1)))break}else if(e.position===e.lineStart&&eu(e)||n&&H(u))break;else if(G(u)){if(l=e.line,c=e.lineStart,s=e.lineIndent,es(e,!1,-1),e.lineIndent>=t){a=!0,u=e.input.charCodeAt(e.position);continue}e.position=o,e.line=l,e.lineStart=c,e.lineIndent=s;break}a&&(eo(e,r,o,!1),ep(e,e.line-l),r=o=e.position,a=!1),Z(u)||(o=e.position+1),u=e.input.charCodeAt(++e.position)}return eo(e,r,o,!1),!!e.result||(e.kind=p,e.result=f,!1)}(e,d,1===n)&&(y=!0,null===e.tag&&(e.tag="?")),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):0===g&&(y=c&&ef(e,h))),null===e.tag)null!==e.anchor&&(e.anchorMap[e.anchor]=e.result);else if("?"===e.tag){for(null!==e.result&&"scalar"!==e.kind&&en(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),s=0,u=e.implicitTypes.length;s<u;s+=1)if((f=e.implicitTypes[s]).resolve(e.result)){e.result=f.construct(e.result),e.tag=f.tag,null!==e.anchor&&(e.anchorMap[e.anchor]=e.result);break}}else if("!"!==e.tag){if(Y.call(e.typeMap[e.kind||"fallback"],e.tag))f=e.typeMap[e.kind||"fallback"][e.tag];else for(s=0,f=null,u=(p=e.typeMap.multi[e.kind||"fallback"]).length;s<u;s+=1)if(e.tag.slice(0,p[s].tag.length)===p[s].tag){f=p[s];break}f||en(e,"unknown tag !<"+e.tag+">"),null!==e.result&&f.kind!==e.kind&&en(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+f.kind+'", not "'+e.kind+'"'),f.resolve(e.result,e.tag)?(e.result=f.construct(e.result,e.tag),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):en(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return null!==e.listener&&e.listener("close",e),null!==e.tag||null!==e.anchor||y}function eh(e,t){e=String(e),t=t||{},0!==e.length&&(10!==e.charCodeAt(e.length-1)&&13!==e.charCodeAt(e.length-1)&&(e+="\n"),65279===e.charCodeAt(0)&&(e=e.slice(1)));var n=new ee(e,t),i=e.indexOf("\0");for(-1!==i&&(n.position=i,en(n,"null byte is not allowed in input")),n.input+="\0";32===n.input.charCodeAt(n.position);)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)!function(e){var t,n,i,r,o=e.position,a=!1;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);0!==(r=e.input.charCodeAt(e.position))&&(es(e,!0,-1),r=e.input.charCodeAt(e.position),!(e.lineIndent>0)&&37===r);){for(a=!0,r=e.input.charCodeAt(++e.position),t=e.position;0!==r&&!V(r);)r=e.input.charCodeAt(++e.position);for(n=e.input.slice(t,e.position),i=[],n.length<1&&en(e,"directive name must not be less than one character in length");0!==r;){for(;Z(r);)r=e.input.charCodeAt(++e.position);if(35===r){do r=e.input.charCodeAt(++e.position);while(0!==r&&!G(r));break}if(G(r))break;for(t=e.position;0!==r&&!V(r);)r=e.input.charCodeAt(++e.position);i.push(e.input.slice(t,e.position))}0!==r&&ec(e),Y.call(er,n)?er[n](e,n,i):ei(e,'unknown document directive "'+n+'"')}if(es(e,!0,-1),0===e.lineIndent&&45===e.input.charCodeAt(e.position)&&45===e.input.charCodeAt(e.position+1)&&45===e.input.charCodeAt(e.position+2)?(e.position+=3,es(e,!0,-1)):a&&en(e,"directives end mark is expected"),ed(e,e.lineIndent-1,4,!1,!0),es(e,!0,-1),e.checkLineBreaks&&B.test(e.input.slice(o,e.position))&&ei(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&eu(e)){46===e.input.charCodeAt(e.position)&&(e.position+=3,es(e,!0,-1));return}e.position<e.length-1&&en(e,"end of the stream or a document separator is expected")}(n);return n.documents}var eg=Object.prototype.toString,em=Object.prototype.hasOwnProperty,ey={};ey[0]="\\0",ey[7]="\\a",ey[8]="\\b",ey[9]="\\t",ey[10]="\\n",ey[11]="\\v",ey[12]="\\f",ey[13]="\\r",ey[27]="\\e",ey[34]='\\"',ey[92]="\\\\",ey[133]="\\N",ey[160]="\\_",ey[8232]="\\L",ey[8233]="\\P";var eb=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],eA=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function ev(e){this.schema=e.schema||U,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=i.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=function(e,t){var n,i,r,o,a,l,c;if(null===t)return{};for(r=0,n={},o=(i=Object.keys(t)).length;r<o;r+=1)l=String(t[a=i[r]]),"!!"===a.slice(0,2)&&(a="tag:yaml.org,2002:"+a.slice(2)),(c=e.compiledTypeMap.fallback[a])&&em.call(c.styleAliases,l)&&(l=c.styleAliases[l]),n[a]=l;return n}(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType='"'===e.quotingType?2:1,this.forceQuotes=e.forceQuotes||!1,this.replacer="function"==typeof e.replacer?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function ek(e,t){for(var n,r=i.repeat(" ",t),o=0,a=-1,l="",c=e.length;o<c;)-1===(a=e.indexOf("\n",o))?(n=e.slice(o),o=c):(n=e.slice(o,a+1),o=a+1),n.length&&"\n"!==n&&(l+=r),l+=n;return l}function ew(e,t){return"\n"+i.repeat(" ",e.indent*t)}function eC(e){return 32===e||9===e}function ex(e){return 32<=e&&e<=126||161<=e&&e<=55295&&8232!==e&&8233!==e||57344<=e&&e<=65533&&65279!==e||65536<=e&&e<=1114111}function eI(e){return ex(e)&&65279!==e&&13!==e&&10!==e}function eO(e,t,n){var i=eI(e),r=i&&!eC(e);return(n?i:i&&44!==e&&91!==e&&93!==e&&123!==e&&125!==e)&&35!==e&&!(58===t&&!r)||eI(t)&&!eC(t)&&35===e||58===t&&r}function eS(e,t){var n,i=e.charCodeAt(t);return i>=55296&&i<=56319&&t+1<e.length&&(n=e.charCodeAt(t+1))>=56320&&n<=57343?(i-55296)*1024+n-56320+65536:i}function ej(e){return/^\n* /.test(e)}function eT(e,t){var n=ej(e)?String(t):"",i="\n"===e[e.length-1];return n+(i&&("\n"===e[e.length-2]||"\n"===e)?"+":i?"":"-")+"\n"}function eN(e){return"\n"===e[e.length-1]?e.slice(0,-1):e}function eF(e,t){if(""===e||" "===e[0])return e;for(var n,i,r=/ [^ ]/g,o=0,a=0,l=0,c="";n=r.exec(e);)(l=n.index)-o>t&&(i=a>o?a:l,c+="\n"+e.slice(o,i),o=i+1),a=l;return c+="\n",e.length-o>t&&a>o?c+=e.slice(o,a)+"\n"+e.slice(a+1):c+=e.slice(o),c.slice(1)}function eE(e,t,n,i){var r,o,a,l="",c=e.tag;for(r=0,o=n.length;r<o;r+=1)a=n[r],e.replacer&&(a=e.replacer.call(n,String(r),a)),(eL(e,t+1,a,!0,!0,!1,!0)||void 0===a&&eL(e,t+1,null,!0,!0,!1,!0))&&(i&&""===l||(l+=ew(e,t)),e.dump&&10===e.dump.charCodeAt(0)?l+="-":l+="- ",l+=e.dump);e.tag=c,e.dump=l||"[]"}function eM(e,t,n){var i,r,a,l,c,s;for(a=0,l=(r=n?e.explicitTypes:e.implicitTypes).length;a<l;a+=1)if(((c=r[a]).instanceOf||c.predicate)&&(!c.instanceOf||"object"==typeof t&&t instanceof c.instanceOf)&&(!c.predicate||c.predicate(t))){if(n?c.multi&&c.representName?e.tag=c.representName(t):e.tag=c.tag:e.tag="?",c.represent){if(s=e.styleMap[c.tag]||c.defaultStyle,"[object Function]"===eg.call(c.represent))i=c.represent(t,s);else if(em.call(c.represent,s))i=c.represent[s](t,s);else throw new o("!<"+c.tag+'> tag resolver accepts not "'+s+'" style');e.dump=i}return!0}return!1}function eL(e,t,n,r,a,l,c){e.tag=null,e.dump=n,eM(e,n,!1)||eM(e,n,!0);var s,u=eg.call(e.dump),p=r;r&&(r=e.flowLevel<0||e.flowLevel>t);var f,d,h,g="[object Object]"===u||"[object Array]"===u;if(g&&(h=-1!==(d=e.duplicates.indexOf(n))),(null!==e.tag&&"?"!==e.tag||h||2!==e.indent&&t>0)&&(a=!1),h&&e.usedDuplicates[d])e.dump="*ref_"+d;else{if(g&&h&&!e.usedDuplicates[d]&&(e.usedDuplicates[d]=!0),"[object Object]"===u)r&&0!==Object.keys(e.dump).length?(!function(e,t,n,i){var r,a,l,c,s,u,p="",f=e.tag,d=Object.keys(n);if(!0===e.sortKeys)d.sort();else if("function"==typeof e.sortKeys)d.sort(e.sortKeys);else if(e.sortKeys)throw new o("sortKeys must be a boolean or a function");for(r=0,a=d.length;r<a;r+=1)u="",i&&""===p||(u+=ew(e,t)),c=n[l=d[r]],e.replacer&&(c=e.replacer.call(n,l,c)),eL(e,t+1,l,!0,!0,!0)&&((s=null!==e.tag&&"?"!==e.tag||e.dump&&e.dump.length>1024)&&(e.dump&&10===e.dump.charCodeAt(0)?u+="?":u+="? "),u+=e.dump,s&&(u+=ew(e,t)),eL(e,t+1,c,!0,s)&&(e.dump&&10===e.dump.charCodeAt(0)?u+=":":u+=": ",u+=e.dump,p+=u));e.tag=f,e.dump=p||"{}"}(e,t,e.dump,a),h&&(e.dump="&ref_"+d+e.dump)):(!function(e,t,n){var i,r,o,a,l,c="",s=e.tag,u=Object.keys(n);for(i=0,r=u.length;i<r;i+=1)l="",""!==c&&(l+=", "),e.condenseFlow&&(l+='"'),a=n[o=u[i]],e.replacer&&(a=e.replacer.call(n,o,a)),eL(e,t,o,!1,!1)&&(e.dump.length>1024&&(l+="? "),l+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),eL(e,t,a,!1,!1)&&(l+=e.dump,c+=l));e.tag=s,e.dump="{"+c+"}"}(e,t,e.dump),h&&(e.dump="&ref_"+d+" "+e.dump));else if("[object Array]"===u)r&&0!==e.dump.length?(e.noArrayIndent&&!c&&t>0?eE(e,t-1,e.dump,a):eE(e,t,e.dump,a),h&&(e.dump="&ref_"+d+e.dump)):(!function(e,t,n){var i,r,o,a="",l=e.tag;for(i=0,r=n.length;i<r;i+=1)o=n[i],e.replacer&&(o=e.replacer.call(n,String(i),o)),(eL(e,t,o,!1,!1)||void 0===o&&eL(e,t,null,!1,!1))&&(""!==a&&(a+=","+(e.condenseFlow?"":" ")),a+=e.dump);e.tag=l,e.dump="["+a+"]"}(e,t,e.dump),h&&(e.dump="&ref_"+d+" "+e.dump));else if("[object String]"===u)"?"!==e.tag&&(s=e.dump,e.dump=function(){if(0===s.length)return 2===e.quotingType?'""':"''";if(!e.noCompatMode&&(-1!==eb.indexOf(s)||eA.test(s)))return 2===e.quotingType?'"'+s+'"':"'"+s+"'";var n=e.indent*Math.max(1,t),r=-1===e.lineWidth?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-n);switch(function(e,t,n,i,r,o,a,l){var c,s,u,p=0,f=null,d=!1,h=!1,g=-1!==i,m=-1,y=ex(c=eS(e,0))&&65279!==c&&!eC(c)&&45!==c&&63!==c&&58!==c&&44!==c&&91!==c&&93!==c&&123!==c&&125!==c&&35!==c&&38!==c&&42!==c&&33!==c&&124!==c&&61!==c&&62!==c&&39!==c&&34!==c&&37!==c&&64!==c&&96!==c&&!eC(s=eS(e,e.length-1))&&58!==s;if(t||a)for(u=0;u<e.length;p>=65536?u+=2:u++){if(!ex(p=eS(e,u)))return 5;y=y&&eO(p,f,l),f=p}else{for(u=0;u<e.length;p>=65536?u+=2:u++){if(10===(p=eS(e,u)))d=!0,g&&(h=h||u-m-1>i&&" "!==e[m+1],m=u);else if(!ex(p))return 5;y=y&&eO(p,f,l),f=p}h=h||g&&u-m-1>i&&" "!==e[m+1]}return d||h?n>9&&ej(e)?5:a?2===o?5:2:h?4:3:!y||a||r(e)?2===o?5:2:1}(s,l||e.flowLevel>-1&&t>=e.flowLevel,e.indent,r,function(t){return function(e,t){var n,i;for(n=0,i=e.implicitTypes.length;n<i;n+=1)if(e.implicitTypes[n].resolve(t))return!0;return!1}(e,t)},e.quotingType,e.forceQuotes&&!l,p)){case 1:return s;case 2:return"'"+s.replace(/'/g,"''")+"'";case 3:return"|"+eT(s,e.indent)+eN(ek(s,n));case 4:return">"+eT(s,e.indent)+eN(ek(function(e,t){for(var n,i,r,o=/(\n+)([^\n]*)/g,a=(n=-1!==(n=e.indexOf("\n"))?n:e.length,o.lastIndex=n,eF(e.slice(0,n),t)),l="\n"===e[0]||" "===e[0];r=o.exec(e);){var c=r[1],s=r[2];i=" "===s[0],a+=c+(l||i||""===s?"":"\n")+eF(s,t),l=i}return a}(s,r),n));case 5:return'"'+function(e){for(var t,n="",r=0,a=0;a<e.length;r>=65536?a+=2:a++)!(t=ey[r=eS(e,a)])&&ex(r)?(n+=e[a],r>=65536&&(n+=e[a+1])):n+=t||function(e){var t,n,r;if(t=e.toString(16).toUpperCase(),e<=255)n="x",r=2;else if(e<=65535)n="u",r=4;else if(e<=4294967295)n="U",r=8;else throw new o("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+n+i.repeat("0",r-t.length)+t}(r);return n}(s)+'"';default:throw new o("impossible error: invalid scalar style")}}());else{if("[object Undefined]"===u||e.skipInvalid)return!1;throw new o("unacceptable kind of an object to dump "+u)}null!==e.tag&&"?"!==e.tag&&(f=encodeURI("!"===e.tag[0]?e.tag.slice(1):e.tag).replace(/!/g,"%21"),f="!"===e.tag[0]?"!"+f:"tag:yaml.org,2002:"===f.slice(0,18)?"!!"+f.slice(18):"!<"+f+">",e.dump=f+" "+e.dump)}return!0}function e_(e,t){return function(){throw Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+t+" instead, which is now safe by default.")}}var eD=e_("safeLoad","load"),eq=e_("safeLoadAll","loadAll"),eU=e_("safeDump","dump");t.ZP={Type:p,Schema:d,FAILSAFE_SCHEMA:y,JSON_SCHEMA:x,CORE_SCHEMA:x,DEFAULT_SCHEMA:U,load:function(e,t){var n=eh(e,t);if(0!==n.length){if(1===n.length)return n[0];throw new o("expected a single document in the stream, but found more")}},loadAll:function(e,t,n){null!==t&&"object"==typeof t&&void 0===n&&(n=t,t=null);var i=eh(e,n);if("function"!=typeof t)return i;for(var r=0,o=i.length;r<o;r+=1)t(i[r])},dump:function(e,t){var n=new ev(t=t||{});n.noRefs||function(e,t){var n,i,r=[],o=[];for(function e(t,n,i){var r,o,a;if(null!==t&&"object"==typeof t){if(-1!==(o=n.indexOf(t)))-1===i.indexOf(o)&&i.push(o);else if(n.push(t),Array.isArray(t))for(o=0,a=t.length;o<a;o+=1)e(t[o],n,i);else for(o=0,a=(r=Object.keys(t)).length;o<a;o+=1)e(t[r[o]],n,i)}}(e,r,o),n=0,i=o.length;n<i;n+=1)t.duplicates.push(r[o[n]]);t.usedDuplicates=Array(i)}(e,n);var i=e;return(n.replacer&&(i=n.replacer.call({"":i},"",i)),eL(n,0,i,!0,!0))?n.dump+"\n":""},YAMLException:o,types:{binary:N,float:C,map:m,null:b,pairs:_,set:q,timestamp:S,bool:A,int:v,merge:j,omap:M,seq:g,str:h},safeLoad:eD,safeLoadAll:eq,safeDump:eU}}}]);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1871],{39037:function(e,s,t){t.r(s),t.d(s,{ClusterTable:function(){return _},Clusters:function(){return I},Status2Actions:function(){return F},enabledActions:function(){return H},handleVSCodeConnection:function(){return O}});var r=t(85893),l=t(67294),a=t(11163),n=t(55739),i=t(36989),c=t(41664),o=t.n(c),u=t(30803),d=t(37673),h=t(68764),x=t(23266),p=t(17324),m=t(94545),f=t(13626),j=t(60998);/**
|
|
2
|
+
* @license lucide-react v0.407.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/let v=(0,j.Z)("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]),g=(0,j.Z)("SquareCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);t(9353);var y=t(92128),w=t(99307),b=t(23001),k=t(88950),N=t(6378),C=t(36856);t(1272);var S=t(20546);let L=[{label:"Status",value:"status"},{label:"Cluster",value:"cluster"},{label:"User",value:"user"},{label:"Workspace",value:"workspace"},{label:"Infra",value:"infra"}],M=(e,s)=>{let t="",r="";return e>=0&&(t=e+"m",r=" "),s&&(t+="".concat(r,"(down)")),""===t&&(t="-"),t},R=(e,s)=>{if(e&&e.includes("@")){let t=e.split("@")[0];return s&&s!==t?"".concat(t," (").concat(s,")"):t}let t=e||s||"N/A";return s&&s!==t?"".concat(t," (").concat(s,")"):t},E=e=>{if(!e||0===e)return"-";let s=e=Math.floor(e),t="",r=0;for(let e of[{value:31536e3,label:"y"},{value:2592e3,label:"mo"},{value:86400,label:"d"},{value:3600,label:"h"},{value:60,label:"m"},{value:1,label:"s"}])if(s>=e.value&&r<2){let l=Math.floor(s/e.value);t+="".concat(l).concat(e.label," "),s%=e.value,r++}return t.trim()||"0s"};function I(){let e=(0,a.useRouter)(),[s,t]=(0,l.useState)(!1),c=l.useRef(null),[u,d]=(0,l.useState)(!1),[h,m]=(0,l.useState)(!1),[j,v]=(0,l.useState)(null),[g,w]=(0,l.useState)(()=>!!e.isReady&&"true"===e.query.history),[S,M]=(0,l.useState)(!0),[E,I]=(0,l.useState)(()=>{if(e.isReady){let s=e.query.historyDays;if(s&&"string"==typeof s&&["1","5","10","30"].includes(s))return parseInt(s)}return 1}),O=(0,b.X)(),[q,H]=(0,l.useState)([]),[W,F]=(0,l.useState)({status:[],cluster:[],user:[],workspace:[],infra:[]}),[A,D]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(e.isReady){U();let s="true"===e.query.history;g!==s&&(M(!1),w(s),setTimeout(()=>M(!0),50));let t=e.query.historyDays;if(t&&"string"==typeof t&&["1","5","10","30"].includes(t)){let e=parseInt(t);E!==e&&I(e)}}},[e.isReady,e.query.history,e.query.historyDays]),(0,l.useEffect)(()=>{(async()=>{try{await C.ZP.preloadForPage("clusters");let e=await N.default.get(p.getWorkspaces),s=Object.keys(e),t=await N.default.get(x.getClusters),r=[...new Set(t.map(e=>e.workspace||"default").filter(e=>e))],l=new Set(s);r.includes("default")&&l.has("default"),r.forEach(e=>l.add(e));let a=[...new Set(t.map(e=>({userId:e.user_hash||e.user,username:e.user})).filter(e=>e.userId)).values()],n=new Map;a.forEach(e=>{n.set(e.userId,{userId:e.userId,username:e.username,display:R(e.username,e.userId)})}),D(!0)}catch(e){console.error("Error fetching data for filters:",e),D(!0)}})()},[]);let P=s=>{let t={...e.query},r=[],l=[],a=[];s.map((e,s)=>{var t;r.push(null!==(t=e.property.toLowerCase())&&void 0!==t?t:""),l.push(e.operator),a.push(e.value)}),t.property=r,t.operator=l,t.value=a,e.replace({pathname:e.pathname,query:t},void 0,{shallow:!0})},Z=s=>{let t={...e.query};t.history=s.toString(),e.replace({pathname:e.pathname,query:t},void 0,{shallow:!0})},B=s=>{let t={...e.query};t.historyDays=s.toString(),e.replace({pathname:e.pathname,query:t},void 0,{shallow:!0})},U=()=>{let s={...e.query},t=s.property,r=s.operator,l=s.value;if(void 0===t)return;let a=[],n=Array.isArray(t)?t.length:1,i=new Map;if(i.set("",""),i.set("status","Status"),i.set("cluster","Cluster"),i.set("user","User"),i.set("workspace","Workspace"),i.set("infra","Infra"),1===n)a.push({property:i.get(t),operator:r,value:l});else for(let e=0;e<n;e++)a.push({property:i.get(t[e]),operator:r[e],value:l[e]});H(a)};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mb-1 min-h-[20px]",children:[(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsx)(o(),{href:"/clusters",className:"text-sky-blue hover:underline leading-none text-base",children:"Sky Clusters"})}),(0,r.jsx)("div",{className:"w-full sm:w-auto",children:(0,r.jsx)(V,{propertyList:L,valueList:W,setFilters:H,updateURLParams:P,placeholder:"Filter clusters",filters:q})}),(0,r.jsxs)("div",{className:"flex items-center gap-2 ml-auto",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("label",{className:"flex items-center cursor-pointer",children:[(0,r.jsx)("input",{type:"checkbox",checked:g,onChange:e=>{let s=e.target.checked;w(s),Z(s)},className:"sr-only"}),(0,r.jsx)("div",{className:"relative inline-flex h-5 w-9 items-center rounded-full ".concat(S?"transition-colors":""," ").concat(g?"bg-sky-600":"bg-gray-300"),children:(0,r.jsx)("span",{className:"inline-block h-3 w-3 transform rounded-full bg-white ".concat(S?"transition-transform":""," ").concat(g?"translate-x-5":"translate-x-1")})}),(0,r.jsx)("span",{className:"ml-2 text-sm text-gray-700",children:"Show history"})]}),g&&(0,r.jsxs)(k.Ph,{value:E.toString(),onValueChange:e=>{let s=parseInt(e);I(s),B(s)},children:[(0,r.jsx)(k.i4,{className:"w-24 h-8 text-xs",children:(0,r.jsx)(k.ki,{})}),(0,r.jsxs)(k.Bw,{children:[(0,r.jsx)(k.Ql,{value:"1",children:"1 day"}),(0,r.jsx)(k.Ql,{value:"5",children:"5 days"}),(0,r.jsx)(k.Ql,{value:"10",children:"10 days"}),(0,r.jsx)(k.Ql,{value:"30",children:"30 days"})]})]})]}),s&&(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)(n.Z,{size:15,className:"mt-0"}),(0,r.jsx)("span",{className:"ml-2 text-gray-500 text-sm",children:"Loading..."})]}),(0,r.jsxs)("button",{onClick:()=>{N.default.invalidate(x.getClusters),N.default.invalidate(p.getWorkspaces),g&&N.default.invalidate(x.uR),D(!1),C.ZP.preloadForPage("clusters",{force:!0}).then(()=>{D(!0),c.current&&c.current()})},disabled:s,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:[(0,r.jsx)(f.Z,{className:"h-4 w-4 mr-1.5"}),!O&&(0,r.jsx)("span",{children:"Refresh"})]})]})]}),(0,r.jsx)(z,{filters:q,setFilters:H,updateURLParams:P}),(0,r.jsx)(_,{refreshInterval:i.yc,setLoading:t,refreshDataRef:c,filters:q,showHistory:g,historyDays:E,onOpenSSHModal:e=>{v(e),d(!0)},onOpenVSCodeModal:e=>{v(e),m(!0)},setOptionValues:F,preloadingComplete:A}),(0,r.jsx)(y.Oh,{isOpen:u,onClose:()=>d(!1),cluster:j}),(0,r.jsx)(y._R,{isOpen:h,onClose:()=>m(!1),cluster:j})]})}function _(e){let{refreshInterval:s,setLoading:t,refreshDataRef:a,filters:c,showHistory:p,historyDays:f,onOpenSSHModal:j,onOpenVSCodeModal:v,setOptionValues:g,preloadingComplete:y}=e,[b,k]=(0,l.useState)([]),[C,L]=(0,l.useState)({key:null,direction:"ascending"}),[R,I]=(0,l.useState)(!1),[_,O]=(0,l.useState)(!0),[q,H]=(0,l.useState)(1),[W,V]=(0,l.useState)(10),z=e=>{let s={status:[],cluster:[],user:[],workspace:[],infra:[]},t=(e,s)=>{e.includes(s)||e.push(s)};return e.map(e=>{t(s.status,e.status),t(s.cluster,e.cluster),t(s.user,e.user),t(s.workspace,e.workspace),t(s.infra,e.infra)}),s},A=l.useCallback(async()=>{t(!0),I(!0);try{let e=await N.default.get(x.getClusters);if(p){let s=[];try{s=await N.default.get(x.uR,[null,f])}catch(e){console.error("Error fetching cluster history:",e)}let t=e.map(e=>({...e,isHistorical:!1})),r=s.map(e=>({...e,isHistorical:!0})),l=[...t];r.forEach(s=>{e.some(e=>e.cluster_hash===s.cluster_hash)||l.push(s)}),g(z(l)),k(l)}else{let s=e.map(e=>({...e,isHistorical:!1}));g(z(s)),k(s)}}catch(e){console.error("Error fetching cluster data:",e),g(z([])),k([])}t(!1),I(!1),O(!1)},[t,p,f,g]),D=(e,s)=>{var t;let{property:r,operator:l,value:a}=s;if(!a)return!0;if(!r){let s=a.toLowerCase();return Object.values(e).some(e=>null==e?void 0:e.toString().toLowerCase().includes(s))}let n=null===(t=e[r.toLowerCase()])||void 0===t?void 0:t.toString().toLowerCase(),i=a.toString().toLowerCase();switch(l){case"=":return n===i;case":":return null==n?void 0:n.includes(i);default:return!0}},P=l.useMemo(()=>{let e=0===c.length?b:b.filter(e=>{let s=null;for(let t=0;t<c.length;t++){let r=D(e,c[t]);s=null===s?r:s&&r}return s});return(0,m.R0)(e,C.key,C.direction)},[b,C,c]);l.useEffect(()=>{a&&(a.current=A)},[a,A]),(0,l.useEffect)(()=>{k([]);let e=!0;if(y){A();let t=setInterval(()=>{e&&"visible"===window.document.visibilityState&&A()},s);return()=>{e=!1,clearInterval(t)}}return()=>{e=!1}},[s,A,y]),(0,l.useEffect)(()=>{H(1)},[b.length]);let Z=e=>{let s="ascending";C.key===e&&"ascending"===C.direction&&(s="descending"),L({key:e,direction:s})},B=e=>C.key===e?"ascending"===C.direction?" ↑":" ↓":"",U=Math.ceil(P.length/W),Q=(q-1)*W,T=Q+W,X=P.slice(Q,T);return(0,r.jsxs)("div",{children:[(0,r.jsx)(d.Zb,{children:(0,r.jsx)("div",{className:"overflow-x-auto rounded-lg",children:(0,r.jsxs)(h.iA,{className:"min-w-full",children:[(0,r.jsx)(h.xD,{children:(0,r.jsxs)(h.SC,{children:[(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("status"),children:["Status",B("status")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("cluster"),children:["Cluster",B("cluster")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("user"),children:["User",B("user")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("workspace"),children:["Workspace",B("workspace")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("infra"),children:["Infra",B("infra")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("resources_str"),children:["Resources",B("resources_str")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("time"),children:["Started",B("time")]}),p&&(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("duration"),children:["Duration",B("duration")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("autostop"),children:["Autostop",B("autostop")]}),(0,r.jsx)(h.ss,{className:"md:sticky md:right-0 md:bg-white",children:"Actions"})]})}),(0,r.jsx)(h.RM,{children:R||!y?(0,r.jsx)(h.SC,{children:(0,r.jsx)(h.pj,{colSpan:9,className:"text-center py-6 text-gray-500",children:(0,r.jsxs)("div",{className:"flex justify-center items-center",children:[(0,r.jsx)(n.Z,{size:20,className:"mr-2"}),(0,r.jsx)("span",{children:"Loading..."})]})})}):X.length>0?X.map((e,s)=>(0,r.jsxs)(h.SC,{children:[(0,r.jsx)(h.pj,{children:(0,r.jsx)(w.OE,{status:e.status})}),(0,r.jsx)(h.pj,{children:(0,r.jsx)(o(),{href:"/clusters/".concat(e.isHistorical?e.cluster_hash:e.cluster||e.name),className:"text-blue-600",children:e.cluster||e.name})}),(0,r.jsx)(h.pj,{children:(0,r.jsx)(S.H,{username:e.user,userHash:e.user_hash})}),(0,r.jsx)(h.pj,{children:(0,r.jsx)(o(),{href:"/workspaces",className:"text-gray-700 hover:text-blue-600 hover:underline",children:e.workspace||"default"})}),(0,r.jsx)(h.pj,{children:(0,r.jsx)(i.Md,{content:e.full_infra||e.infra,className:"text-sm text-muted-foreground",children:(0,r.jsxs)("span",{children:[(0,r.jsx)(o(),{href:"/infra",className:"text-blue-600 hover:underline",children:e.cloud}),e.infra.includes("(")&&(0,r.jsx)("span",{children:" "+e.infra.substring(e.infra.indexOf("("))})]})})}),(0,r.jsx)(h.pj,{children:(0,r.jsx)(i.Md,{content:e.resources_str_full||e.resources_str,className:"text-sm text-muted-foreground",children:(0,r.jsx)("span",{children:e.resources_str})})}),(0,r.jsx)(h.pj,{children:(0,r.jsx)(i.Zg,{date:e.time})}),p&&(0,r.jsx)(h.pj,{children:E(e.duration)}),(0,r.jsx)(h.pj,{children:e.isHistorical?"-":M(e.autostop,e.to_down)}),(0,r.jsx)(h.pj,{className:"text-left md:sticky md:right-0 md:bg-white",children:!e.isHistorical&&(0,r.jsx)(F,{cluster:e.cluster,status:e.status,onOpenSSHModal:j,onOpenVSCodeModal:v})})]},s)):(0,r.jsx)(h.SC,{children:(0,r.jsx)(h.pj,{colSpan:9,className:"text-center py-6 text-gray-500",children:p?"No clusters found":"No active clusters"})})})]})})}),b.length>0&&(0,r.jsx)("div",{className:"flex justify-end items-center py-2 px-4 text-sm text-gray-700",children:(0,r.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("span",{className:"mr-2",children:"Rows per page:"}),(0,r.jsxs)("div",{className:"relative inline-block",children:[(0,r.jsxs)("select",{value:W,onChange:e=>{V(parseInt(e.target.value,10)),H(1)},className:"py-1 pl-2 pr-6 appearance-none outline-none cursor-pointer border-none bg-transparent",style:{minWidth:"40px"},children:[(0,r.jsx)("option",{value:10,children:"10"}),(0,r.jsx)("option",{value:30,children:"30"}),(0,r.jsx)("option",{value:50,children:"50"}),(0,r.jsx)("option",{value:100,children:"100"}),(0,r.jsx)("option",{value:200,children:"200"})]}),(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-gray-500 absolute right-0 top-1/2 transform -translate-y-1/2 pointer-events-none",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),(0,r.jsx)("div",{children:"".concat(Q+1," - ").concat(Math.min(T,P.length)," of ").concat(P.length)}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)(u.z,{variant:"ghost",size:"icon",onClick:()=>{H(e=>Math.max(e-1,1))},disabled:1===q,className:"text-gray-500 h-8 w-8 p-0",children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"chevron-left",children:(0,r.jsx)("path",{d:"M15 18l-6-6 6-6"})})}),(0,r.jsx)(u.z,{variant:"ghost",size:"icon",onClick:()=>{H(e=>Math.min(e+1,U))},disabled:q===U||0===U,className:"text-gray-500 h-8 w-8 p-0",children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"chevron-right",children:(0,r.jsx)("path",{d:"M9 18l6-6-6-6"})})})]})]})})]})}let O=(e,s)=>{s&&s(e)},q=(e,s)=>{s?s(e):window.open("ssh://".concat(e))},H=e=>"RUNNING"===e?["connect","VSCode"]:[],W={connect:(0,r.jsx)(v,{className:"w-4 h-4 text-gray-500 inline-block"}),VSCode:(0,r.jsx)(g,{className:"w-4 h-4 text-gray-500 inline-block"})};function F(e){let{withLabel:s=!1,cluster:t,status:l,onOpenSSHModal:a,onOpenVSCodeModal:n}=e,c=H(l),o=(0,b.X)(),u=e=>{switch(e){case"connect":q(t,a);break;case"VSCode":O(t,n);break;default:return}};return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("div",{className:"flex items-center space-x-4",children:Object.entries(W).map(e=>{let t,l,[a,n]=e;switch(a){case"connect":t="Connect",l="Connect with SSH";break;case"VSCode":t="VSCode",l="Open in VS Code"}return(s||(t=""),c.includes(a))?(0,r.jsx)(i.WH,{content:l,className:"capitalize text-sm text-muted-foreground",children:(0,r.jsxs)("button",{onClick:()=>u(a),className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center",children:[n,!o&&(0,r.jsx)("span",{className:"ml-1.5",children:t})]})},a):(0,r.jsx)(i.WH,{content:l,className:"capitalize text-sm text-muted-foreground",children:(0,r.jsxs)("span",{className:"opacity-30 flex items-center cursor-not-allowed text-sm",title:a,children:[n,!o&&(0,r.jsx)("span",{className:"ml-1.5",children:t})]})},a)})})})}let V=e=>{let{propertyList:s=[],valueList:t,setFilters:a,updateURLParams:n,placeholder:i="Filter clusters",filters:c=[]}=e,o=(0,l.useRef)(null),u=(0,l.useRef)(null),[d,h]=(0,l.useState)(!1),[x,p]=(0,l.useState)(""),[m,f]=(0,l.useState)("status"),[j,v]=(0,l.useState)([]);(0,l.useEffect)(()=>{let e=e=>{u.current&&!u.current.contains(e.target)&&o.current&&!o.current.contains(e.target)&&h(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[]),(0,l.useEffect)(()=>{let e=[],s=m||"";if(s.length>1){s=m[0].toUpperCase();for(let e=1;e<m.length;e++)s+=m[e]}let r=c.filter(e=>e.property===s).map(e=>e.value);if(t&&"object"==typeof t)switch(m){case"status":e=t.status.filter(e=>!r.find(s=>s===e))||[];break;case"user":e=t.user.filter(e=>!r.find(s=>s===e))||[];break;case"cluster":e=t.cluster.filter(e=>!r.find(s=>s===e))||[];break;case"workspace":e=t.workspace.filter(e=>!r.find(s=>s===e))||[];break;case"infra":e=t.infra.filter(e=>!r.find(s=>s===e))||[]}""!==x.trim()&&(e=e.filter(e=>e&&e.toString().toLowerCase().includes(x.toLowerCase()))),v(e)},[m,t,x,c]);let g=e=>{let t=s.find(s=>s.value===e);return t?t.label:e},y=e=>{a(s=>{let t=[...s,{property:g(m),operator:":",value:e}];return n(t),t}),h(!1),p(""),o.current.focus()};return(0,r.jsxs)("div",{className:"flex flex-row border border-gray-300 rounded-md overflow-visible",children:[(0,r.jsx)("div",{className:"border-r border-gray-300 flex-shrink-0",children:(0,r.jsxs)(k.Ph,{onValueChange:f,value:m,children:[(0,r.jsx)(k.i4,{"aria-label":"Filter Property",className:"focus:ring-0 focus:ring-offset-0 border-none rounded-l-md rounded-r-none w-20 sm:w-24 md:w-32 h-8 text-xs sm:text-sm",children:(0,r.jsx)(k.ki,{placeholder:"Status"})}),(0,r.jsx)(k.Bw,{children:s.map((e,s)=>(0,r.jsx)(k.Ql,{value:e.value,children:e.label},"property-item-".concat(s)))})]})}),(0,r.jsxs)("div",{className:"relative flex-1",children:[(0,r.jsx)("input",{type:"text",ref:o,placeholder:i,value:x,onChange:e=>{p(e.target.value),d||h(!0)},onFocus:()=>{h(!0)},onKeyDown:e=>{"Enter"===e.key&&""!==x.trim()?(a(e=>{let s=[...e,{property:g(m),operator:":",value:x}];return n(s),s}),p(""),h(!1)):"Escape"===e.key&&(h(!1),o.current.blur())},className:"h-8 w-full sm:w-96 px-3 pr-8 text-sm border-none rounded-l-none rounded-r-md focus:ring-0 focus:outline-none",autoComplete:"off"}),x&&(0,r.jsx)("button",{onClick:()=>{p(""),h(!1)},className:"absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600",title:"Clear filter",tabIndex:-1,children:(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),d&&j.length>0&&(0,r.jsx)("div",{ref:u,className:"absolute z-50 mt-1 w-full bg-white border border-gray-200 rounded-md shadow-lg max-h-60 overflow-y-auto",style:{zIndex:9999},children:j.map((e,s)=>(0,r.jsx)("div",{className:"px-3 py-2 cursor-pointer hover:bg-gray-50 text-sm ".concat(s!==j.length-1?"border-b border-gray-100":""),onClick:()=>y(e),children:(0,r.jsx)("span",{className:"text-sm text-gray-700",children:e})},"".concat(e,"-").concat(s)))})]})]})},z=e=>{let{filters:s=[],setFilters:t,updateURLParams:l}=e,a=e=>{t(s=>{let t=s.filter((s,t)=>t!==e);return l(t),t})};return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("div",{className:"flex items-center gap-4 py-2 px-2",children:(0,r.jsxs)("div",{className:"flex flex-wrap items-content gap-2",children:[s.map((e,s)=>(0,r.jsx)(A,{filter:e,onRemove:()=>a(s)},"filteritem-".concat(s))),s.length>0&&(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("button",{onClick:()=>{l([]),t([])},className:"rounded-full px-4 py-1 text-sm text-gray-700 bg-gray-200 hover:bg-gray-300",children:"Clear filters"})})]})})})},A=e=>{let{filter:s,onRemove:t}=e;return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"flex items-center text-blue-600 bg-blue-100 px-1 py-1 rounded-full text-sm",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2",children:[(0,r.jsx)("span",{children:"".concat(s.property," ")}),(0,r.jsx)("span",{children:"".concat(s.operator," ")}),(0,r.jsx)("span",{children:" ".concat(s.value)})]}),(0,r.jsx)("button",{onClick:()=>t(),className:"p-0.5 ml-1 transform text-gray-400 hover:text-gray-600 bg-blue-500 hover:bg-blue-600 rounded-full flex flex-col items-center",title:"Clear filter",children:(0,r.jsx)("svg",{className:"h-3 w-3",fill:"none",stroke:"white",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:5,d:"M6 18L18 6M6 6l12 12"})})})]})})}},12003:function(e,s,t){t.d(s,{j:function(){return n}});var r=t(90512);let l=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,a=r.W,n=(e,s)=>t=>{var r;if((null==s?void 0:s.variants)==null)return a(e,null==t?void 0:t.class,null==t?void 0:t.className);let{variants:n,defaultVariants:i}=s,c=Object.keys(n).map(e=>{let s=null==t?void 0:t[e],r=null==i?void 0:i[e];if(null===s)return null;let a=l(s)||l(r);return n[e][a]}),o=t&&Object.entries(t).reduce((e,s)=>{let[t,r]=s;return void 0===r||(e[t]=r),e},{});return a(e,c,null==s?void 0:null===(r=s.compoundVariants)||void 0===r?void 0:r.reduce((e,s)=>{let{class:t,className:r,...l}=s;return Object.entries(l).every(e=>{let[s,t]=e;return Array.isArray(t)?t.includes({...i,...o}[s]):({...i,...o})[s]===t})?[...e,t,r]:e},[]),null==t?void 0:t.class,null==t?void 0:t.className)}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2260],{50326:function(e,t,a){a.d(t,{$N:function(){return m},Be:function(){return h},Vq:function(){return c},cN:function(){return _},cZ:function(){return d},fK:function(){return f}});var s=a(85893),r=a(67294),o=a(6327),n=a(32350),l=a(43767);let c=o.fC;o.xz;let u=o.h_;o.x8;let i=r.forwardRef((e,t)=>{let{className:a,...r}=e;return(0,s.jsx)(o.aV,{ref:t,className:(0,n.cn)("fixed inset-0 z-50 bg-black/50 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...r})});i.displayName=o.aV.displayName;let d=r.forwardRef((e,t)=>{let{className:a,children:r,...c}=e;return(0,s.jsxs)(u,{children:[(0,s.jsx)(i,{}),(0,s.jsxs)(o.VY,{ref:t,className:(0,n.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-gray-200 bg-white p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",a),...c,children:[r,(0,s.jsxs)(o.x8,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-gray-400 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-gray-100 data-[state=open]:text-gray-500",children:[(0,s.jsx)(l.Z,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})});d.displayName=o.VY.displayName;let f=e=>{let{className:t,...a}=e;return(0,s.jsx)("div",{className:(0,n.cn)("flex flex-col space-y-1.5 text-center sm:text-left",t),...a})};f.displayName="DialogHeader";let _=e=>{let{className:t,...a}=e;return(0,s.jsx)("div",{className:(0,n.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...a})};_.displayName="DialogFooter";let m=r.forwardRef((e,t)=>{let{className:a,...r}=e;return(0,s.jsx)(o.Dx,{ref:t,className:(0,n.cn)("text-lg font-semibold leading-none tracking-tight",a),...r})});m.displayName=o.Dx.displayName;let h=r.forwardRef((e,t)=>{let{className:a,...r}=e;return(0,s.jsx)(o.dk,{ref:t,className:(0,n.cn)("text-sm text-gray-500",a),...r})});h.displayName=o.dk.displayName},23266:function(e,t,a){a.d(t,{GH:function(){return f},QL:function(){return m},Sl:function(){return d},getClusters:function(){return u},uR:function(){return i}});var s=a(67294),r=a(15821),o=a(47145),n=a(93225),l=a(6378);let c={UP:"RUNNING",STOPPED:"STOPPED",INIT:"LAUNCHING",null:"TERMINATED"};async function u(){let{clusterNames:e=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return(await o.x.fetch("/status",{cluster_names:e,all_users:!0,include_credentials:!1,include_handle:!1,summary_response:null==e})).map(e=>{let t="",a=t=e.zone?e.zone:e.region;return t&&t.length>25&&(t=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:15;if(!e||e.length<=t)return e;if(t<=3)return"...";let a=Math.floor((t-3)/2),s=a+(t-3)%2;return 0===a?e.substring(0,s)+"...":e.substring(0,s)+"..."+e.substring(e.length-a)}(t,25)),{status:c[e.status],cluster:e.name,user:e.user_name,user_hash:e.user_hash,cluster_hash:e.cluster_hash,cloud:e.cloud,region:e.region,infra:t?e.cloud+" ("+t+")":e.cloud,full_infra:a?"".concat(e.cloud," (").concat(a,")"):e.cloud,cpus:e.cpus,mem:e.memory,gpus:e.accelerators,resources_str:e.resources_str,resources_str_full:e.resources_str_full,time:new Date(1e3*e.launched_at),num_nodes:e.nodes,workspace:e.workspace,autostop:e.autostop,last_event:e.last_event,to_down:e.to_down,cluster_name_on_cloud:e.cluster_name_on_cloud,jobs:[],command:e.last_creation_command||e.last_use,task_yaml:e.last_creation_yaml||"{}",events:[{time:new Date(1e3*e.launched_at),event:"Cluster created."}]}})}catch(e){throw console.error("Error fetching clusters:",e),e}}async function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:30;try{let a={days:t,dashboard_summary_response:!0};e&&(a.cluster_hashes=[e]);let s=await o.x.fetch("/cost_report",a);console.log("Raw cluster history data:",s);let r=s.map(e=>{let t="Unknown";e.cloud?t=e.cloud:e.resources&&e.resources.cloud&&(t=e.resources.cloud);let a=e.user_name||"-";return{status:e.status?c[e.status]:"TERMINATED",cluster:e.name,user:a,user_hash:e.user_hash,cluster_hash:e.cluster_hash,cloud:t,region:"",infra:t,full_infra:t,resources_str:e.resources_str,resources_str_full:e.resources_str_full,time:e.launched_at?new Date(1e3*e.launched_at):null,num_nodes:e.num_nodes||1,duration:e.duration,total_cost:e.total_cost,workspace:e.workspace||"default",autostop:-1,last_event:e.last_event,to_down:!1,cluster_name_on_cloud:null,usage_intervals:e.usage_intervals,command:e.last_creation_command||"",task_yaml:e.last_creation_yaml||"{}",events:[{time:e.launched_at?new Date(1e3*e.launched_at):new Date,event:"Cluster created."}]}});return console.log("Processed cluster history data:",r),r}catch(e){throw console.error("Error fetching cluster history:",e),e}}async function d(e){let{clusterName:t,jobId:a,onNewLog:s,workspace:n}=e;try{await o.x.stream("/logs",{follow:!1,cluster_name:t,job_id:a,tail:1e4,override_skypilot_config:{active_workspace:n||"default"}},s)}catch(e){console.error("Error in streamClusterJobLogs:",e),(0,r.C)("Error in streamClusterJobLogs: ".concat(e.message),"error")}}async function f(e){let{clusterName:t,jobIds:a=null,workspace:s}=e;try{let e=await o.x.fetch("/download_logs",{cluster_name:t,job_ids:a?a.map(String):null,override_skypilot_config:{active_workspace:s||"default"}}),l=Object.values(e||{});if(!l.length){(0,r.C)("No logs found to download.","warning");return}let c=window.location.origin,u="".concat(c).concat(n.f4,"/download"),i=await fetch("".concat(u,"?relative=items"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({folder_paths:l})});if(!i.ok){let e=await i.text();throw Error("Download failed: ".concat(i.status," ").concat(e))}let d=await i.blob(),f=window.URL.createObjectURL(d),_=document.createElement("a"),m=new Date().toISOString().replace(/[:.]/g,"-"),h=a&&1===a.length?"job-".concat(a[0]):"jobs";_.href=f,_.download="".concat(t,"-").concat(h,"-logs-").concat(m,".zip"),document.body.appendChild(_),_.click(),_.remove(),window.URL.revokeObjectURL(f)}catch(e){console.error("Error downloading logs:",e),(0,r.C)("Error downloading logs: ".concat(e.message),"error")}}async function _(e){let{clusterName:t,workspace:a}=e;try{return(await o.x.fetch("/queue",{cluster_name:t,all_users:!0,override_skypilot_config:{active_workspace:a}})).map(e=>{var s;let r=e.end_at?e.end_at:Date.now()/1e3,o=0,n=0;return e.submitted_at&&(o=r-e.submitted_at),e.start_at&&(n=r-e.start_at),{id:e.job_id,status:e.status,job:e.job_name,user:e.username,user_hash:e.user_hash,gpus:e.accelerators||{},submitted_at:e.submitted_at?new Date(1e3*e.submitted_at):null,resources:e.resources,cluster:t,total_duration:o,job_duration:n,infra:"",logs:"",workspace:a||"default",git_commit:(null===(s=e.metadata)||void 0===s?void 0:s.git_commit)||"-"}})}catch(e){throw console.error("Error fetching cluster jobs:",e),e}}function m(e){let{cluster:t,job:a=null}=e,[r,o]=(0,s.useState)(null),[n,c]=(0,s.useState)(null),[i,d]=(0,s.useState)(!0),[f,m]=(0,s.useState)(!0),h=(0,s.useCallback)(async()=>{if(t)try{d(!0);let e=await l.default.get(u,[{clusterNames:[t]}]);if(e.length>0)return o(e[0]),e[0];return console.error("No cluster data found for cluster:",t),null}catch(e){console.error("Error fetching cluster data:",e)}finally{d(!1)}return null},[t]),g=(0,s.useCallback)(async e=>{if(t)try{m(!0);let a=await l.default.get(_,[{clusterName:t,workspace:e||"default"}]);c(a)}catch(e){console.error("Error fetching cluster job data:",e)}finally{m(!1)}},[t]),p=(0,s.useCallback)(async()=>{l.default.invalidate(u,[{clusterNames:[t]}]);let e=await h();e&&(l.default.invalidate(_,[{clusterName:t,workspace:e.workspace||"default"}]),await g(e.workspace))},[h,g,t]),w=(0,s.useCallback)(async()=>{r&&(l.default.invalidate(_,[{clusterName:t,workspace:r.workspace||"default"}]),await g(r.workspace))},[g,r,t]);return(0,s.useEffect)(()=>{(async()=>{let e=await h();e&&g(e.workspace)})()},[t,a,h,g]),{clusterData:r,clusterJobData:n,loading:i,clusterDetailsLoading:i,clusterJobsLoading:f,refreshData:p,refreshClusterJobsOnly:w}}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2350],{32350:function(n,r,u){u.d(r,{cn:function(){return c}});var e=u(90512),t=u(98388);function c(){for(var n=arguments.length,r=Array(n),u=0;u<n;u++)r[u]=arguments[u];return(0,t.m6)((0,e.W)(r))}}}]);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2369],{27325:function(e,t,n){n.d(t,{Z:function(){return r}});/**
|
|
2
|
+
* @license lucide-react v0.407.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/let r=(0,n(60998).Z)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},13626:function(e,t,n){n.d(t,{Z:function(){return r}});/**
|
|
7
|
+
* @license lucide-react v0.407.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/let r=(0,n(60998).Z)("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]])},6327:function(e,t,n){n.d(t,{x8:function(){return eu},VY:function(){return eo},dk:function(){return ea},aV:function(){return er},h_:function(){return en},fC:function(){return ee},Dx:function(){return ei},xz:function(){return et}});var r=n(67294),o=n(36206),i=n(28771),a=n(25360),u=n(91276),l=n(77342),s=n(46063),c=n(95420),d=n(42651),f=n(9981),p=e=>{let t,n;let{present:o,children:a}=e,u=function(e){var t,n;let[o,i]=r.useState(),a=r.useRef(null),u=r.useRef(e),l=r.useRef("none"),[s,c]=(t=e?"mounted":"unmounted",n={mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}},r.useReducer((e,t)=>n[e][t]??e,t));return r.useEffect(()=>{let e=m(a.current);l.current="mounted"===s?e:"none"},[s]),(0,f.b)(()=>{let t=a.current,n=u.current;if(n!==e){let r=l.current,o=m(t);e?c("MOUNT"):"none"===o||t?.display==="none"?c("UNMOUNT"):n&&r!==o?c("ANIMATION_OUT"):c("UNMOUNT"),u.current=e}},[e,c]),(0,f.b)(()=>{if(o){let e;let t=o.ownerDocument.defaultView??window,n=n=>{let r=m(a.current).includes(n.animationName);if(n.target===o&&r&&(c("ANIMATION_END"),!u.current)){let n=o.style.animationFillMode;o.style.animationFillMode="forwards",e=t.setTimeout(()=>{"forwards"===o.style.animationFillMode&&(o.style.animationFillMode=n)})}},r=e=>{e.target===o&&(l.current=m(a.current))};return o.addEventListener("animationstart",r),o.addEventListener("animationcancel",n),o.addEventListener("animationend",n),()=>{t.clearTimeout(e),o.removeEventListener("animationstart",r),o.removeEventListener("animationcancel",n),o.removeEventListener("animationend",n)}}c("ANIMATION_END")},[o,c]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:r.useCallback(e=>{a.current=e?getComputedStyle(e):null,i(e)},[])}}(o),l="function"==typeof a?a({present:u.isPresent}):r.Children.only(a),s=(0,i.e)(u.ref,(t=Object.getOwnPropertyDescriptor(l.props,"ref")?.get)&&"isReactWarning"in t&&t.isReactWarning?l.ref:(t=Object.getOwnPropertyDescriptor(l,"ref")?.get)&&"isReactWarning"in t&&t.isReactWarning?l.props.ref:l.props.ref||l.ref);return"function"==typeof a||u.isPresent?r.cloneElement(l,{ref:s}):null};function m(e){return e?.animationName||"none"}p.displayName="Presence";var g=n(75320),y=n(27552),v=n(6223),N=n(23541),h=n(88426),D=n(85893),R="Dialog",[M,O]=(0,a.b)(R),[x,w]=M(R),b=e=>{let{__scopeDialog:t,children:n,open:o,defaultOpen:i,onOpenChange:a,modal:s=!0}=e,c=r.useRef(null),d=r.useRef(null),[f,p]=(0,l.T)({prop:o,defaultProp:i??!1,onChange:a,caller:R});return(0,D.jsx)(x,{scope:t,triggerRef:c,contentRef:d,contentId:(0,u.M)(),titleId:(0,u.M)(),descriptionId:(0,u.M)(),open:f,onOpenChange:p,onOpenToggle:r.useCallback(()=>p(e=>!e),[p]),modal:s,children:n})};b.displayName=R;var I="DialogTrigger",j=r.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,a=w(I,n),u=(0,i.e)(t,a.triggerRef);return(0,D.jsx)(g.WV.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":K(a.open),...r,ref:u,onClick:(0,o.M)(e.onClick,a.onOpenToggle)})});j.displayName=I;var C="DialogPortal",[E,_]=M(C,{forceMount:void 0}),T=e=>{let{__scopeDialog:t,forceMount:n,children:o,container:i}=e,a=w(C,t);return(0,D.jsx)(E,{scope:t,forceMount:n,children:r.Children.map(o,e=>(0,D.jsx)(p,{present:n||a.open,children:(0,D.jsx)(d.h,{asChild:!0,container:i,children:e})}))})};T.displayName=C;var A="DialogOverlay",F=r.forwardRef((e,t)=>{let n=_(A,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=w(A,e.__scopeDialog);return i.modal?(0,D.jsx)(p,{present:r||i.open,children:(0,D.jsx)(P,{...o,ref:t})}):null});F.displayName=A;var k=(0,h.Z8)("DialogOverlay.RemoveScroll"),P=r.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,o=w(A,n);return(0,D.jsx)(v.Z,{as:k,allowPinchZoom:!0,shards:[o.contentRef],children:(0,D.jsx)(g.WV.div,{"data-state":K(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),W="DialogContent",U=r.forwardRef((e,t)=>{let n=_(W,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=w(W,e.__scopeDialog);return(0,D.jsx)(p,{present:r||i.open,children:i.modal?(0,D.jsx)(V,{...o,ref:t}):(0,D.jsx)(S,{...o,ref:t})})});U.displayName=W;var V=r.forwardRef((e,t)=>{let n=w(W,e.__scopeDialog),a=r.useRef(null),u=(0,i.e)(t,n.contentRef,a);return r.useEffect(()=>{let e=a.current;if(e)return(0,N.Ry)(e)},[]),(0,D.jsx)(L,{...e,ref:u,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:(0,o.M)(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:(0,o.M)(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;(2===t.button||n)&&e.preventDefault()}),onFocusOutside:(0,o.M)(e.onFocusOutside,e=>e.preventDefault())})}),S=r.forwardRef((e,t)=>{let n=w(W,e.__scopeDialog),o=r.useRef(!1),i=r.useRef(!1);return(0,D.jsx)(L,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(o.current||n.triggerRef.current?.focus(),t.preventDefault()),o.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(o.current=!0,"pointerdown"!==t.detail.originalEvent.type||(i.current=!0));let r=t.target;n.triggerRef.current?.contains(r)&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&i.current&&t.preventDefault()}})}),L=r.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:a,onCloseAutoFocus:u,...l}=e,d=w(W,n),f=r.useRef(null),p=(0,i.e)(t,f);return(0,y.EW)(),(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(c.M,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:a,onUnmountAutoFocus:u,children:(0,D.jsx)(s.XB,{role:"dialog",id:d.contentId,"aria-describedby":d.descriptionId,"aria-labelledby":d.titleId,"data-state":K(d.open),...l,ref:p,onDismiss:()=>d.onOpenChange(!1)})}),(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(J,{titleId:d.titleId}),(0,D.jsx)(Q,{contentRef:f,descriptionId:d.descriptionId})]})]})}),Z="DialogTitle",$=r.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,o=w(Z,n);return(0,D.jsx)(g.WV.h2,{id:o.titleId,...r,ref:t})});$.displayName=Z;var B="DialogDescription",q=r.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,o=w(B,n);return(0,D.jsx)(g.WV.p,{id:o.descriptionId,...r,ref:t})});q.displayName=B;var z="DialogClose",H=r.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=w(z,n);return(0,D.jsx)(g.WV.button,{type:"button",...r,ref:t,onClick:(0,o.M)(e.onClick,()=>i.onOpenChange(!1))})});function K(e){return e?"open":"closed"}H.displayName=z;var X="DialogTitleWarning",[Y,G]=(0,a.k)(X,{contentName:W,titleName:Z,docsSlug:"dialog"}),J=({titleId:e})=>{let t=G(X),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
12
|
+
|
|
13
|
+
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
14
|
+
|
|
15
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return r.useEffect(()=>{e&&!document.getElementById(e)&&console.error(n)},[n,e]),null},Q=({contentRef:e,descriptionId:t})=>{let n=G("DialogDescriptionWarning"),o=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${n.contentName}}.`;return r.useEffect(()=>{let n=e.current?.getAttribute("aria-describedby");t&&n&&!document.getElementById(t)&&console.warn(o)},[o,e,t]),null},ee=b,et=j,en=T,er=F,eo=U,ei=$,ea=q,eu=H}}]);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2755],{81260:function(e,t,s){s.d(t,{Z:function(){return r}});/**
|
|
2
|
+
* @license lucide-react v0.407.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/let r=(0,s(60998).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},47603:function(e,t,s){s.d(t,{Z:function(){return r}});/**
|
|
7
|
+
* @license lucide-react v0.407.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/let r=(0,s(60998).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},1812:function(e,t,s){s.d(t,{X:function(){return l}});var r=s(85893),n=s(67294);let a=e=>{if(!(null==e?void 0:e.message))return"An unexpected error occurred.";let t=e.message;return t.includes("failed:")&&(t=t.split("failed:")[1].trim()),t},l=e=>{let{error:t,title:s="Error",onDismiss:l}=e,[o,i]=(0,n.useState)(!1);if((0,n.useEffect)(()=>{t&&i(!1)},[t]),!t||o)return null;let c="string"==typeof t?t:a(t);return(0,r.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-md p-3 mb-4",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),(0,r.jsx)("div",{className:"ml-3",children:(0,r.jsxs)("div",{className:"text-sm text-red-800",children:[(0,r.jsxs)("strong",{children:[s,":"]})," ",c]})})]}),(0,r.jsx)("button",{onClick:()=>{i(!0),l&&l()},className:"flex-shrink-0 ml-4 text-red-400 hover:text-red-600 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 focus:ring-offset-red-50 rounded","aria-label":"Dismiss error",children:(0,r.jsx)("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})})}},27669:function(e,t,s){s.r(t),s.d(t,{Users:function(){return H}});var r=s(85893),n=s(67294),a=s(45697),l=s.n(a),o=s(55739),i=s(41664),c=s.n(i),u=s(11163),d=s(30803),m=s(68764),x=s(53081),h=s(23266),p=s(68969),f=s(6378),g=s(36856),b=s(51214),j=s(94545),y=s(36989),v=s(60998);/**
|
|
12
|
+
* @license lucide-react v0.407.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/let w=(0,v.Z)("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);var N=s(13626),k=s(81260);/**
|
|
17
|
+
* @license lucide-react v0.407.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/let C=(0,v.Z)("EyeOff",[["path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24",key:"1jxqfv"}],["path",{d:"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68",key:"9wicm4"}],["path",{d:"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61",key:"1jreej"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]),_=(0,v.Z)("Eye",[["path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z",key:"rwhkz3"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);var S=s(16826),E=s(70282),R=s(43767);/**
|
|
22
|
+
* @license lucide-react v0.407.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/let D=(0,v.Z)("Pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]),I=(0,v.Z)("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);var T=s(47603),L=s(27325);s(9353);var U=s(23001),F=s(66235),Z=s(37673),A=s(47145),P=s(50326),O=s(1812),M=s(47615),z=s(10546);let q=new Set(M.statusGroups.active),V=[{label:"Name",value:"name"},{label:"GPU",value:"gpu type"},{label:"Infra",value:"infra"},{label:"User ID",value:"user id"},{label:"Role",value:"role"}],B=(e,t)=>{if(!e)return 0;let s=e;if("string"==typeof e)try{let t=e.replace(/'/g,'"').replace(/None/g,"null");s=JSON.parse(t)}catch(t){return console.error("Failed to parse accelerators string:",e,t),0}if("object"==typeof s&&null!==s){let e=Object.entries(s);return 0===e.length?0:(e.length>1&&console.warn("".concat(t," has ").concat(e.length," accelerator entries:"),s),Number(e[0][1])||0)}return 0},G=(e,t)=>e&&e.includes("@")?e.split("@")[0]:e||"N/A",J=(e,t)=>e&&e.includes("@")?e:t||"-",K=b.nb.REFRESH_INTERVAL,$=e=>{let{message:t,onDismiss:s}=e;return t?(0,r.jsx)("div",{className:"bg-green-50 border border-green-200 rounded p-4 mb-6",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)("svg",{className:"h-5 w-5 text-green-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})}),(0,r.jsx)("div",{className:"ml-3",children:(0,r.jsx)("p",{className:"text-sm font-medium text-green-800",children:t})})]}),s&&(0,r.jsx)("div",{className:"ml-auto pl-3",children:(0,r.jsx)("div",{className:"-mx-1.5 -my-1.5",children:(0,r.jsxs)("button",{type:"button",onClick:s,className:"inline-flex rounded-md bg-green-50 p-1.5 text-green-500 hover:bg-green-100 focus:outline-none focus:ring-2 focus:ring-green-600 focus:ring-offset-2 focus:ring-offset-green-50",children:[(0,r.jsx)("span",{className:"sr-only",children:"Dismiss"}),(0,r.jsx)("svg",{className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})]})})})]})}):null};function H(){let e=(0,u.useRouter)(),{userEmail:t}=(0,F.Ap)(),[s,a]=(0,n.useState)(!1),l=(0,n.useRef)(null),i=(0,U.X)(),[c,m]=(0,n.useState)(!1),[g,b]=(0,n.useState)({username:"",password:"",role:"user"}),[j,y]=(0,n.useState)(!1),[v,E]=(0,n.useState)({open:!1,message:"",userName:""}),[R,D]=(0,n.useState)(null),[I,T]=(0,n.useState)(!1),[L,Z]=(0,n.useState)(!1),[M,q]=(0,n.useState)(!1),[B,G]=(0,n.useState)(null),[J,H]=(0,n.useState)(!1),[Q,Y]=(0,n.useState)(null),[ee,et]=(0,n.useState)("import"),[es,er]=(0,n.useState)(!1),[en,ea]=(0,n.useState)(null),[el,eo]=(0,n.useState)(""),[ei,ec]=(0,n.useState)(!1),[eu,ed]=(0,n.useState)(null),[em,ex]=(0,n.useState)(!1),[eh,ep]=(0,n.useState)(null),[ef,eg]=(0,n.useState)(null),[eb,ej]=(0,n.useState)(!1),[ey,ev]=(0,n.useState)(null),[ew,eN]=(0,n.useState)(null),[ek,eC]=(0,n.useState)(void 0),[e_,eS]=(0,n.useState)(void 0),[eE,eR]=(0,n.useState)(void 0),[eD,eI]=(0,n.useState)(!0),[eT,eL]=(0,n.useState)("users"),[eU,eF]=(0,n.useState)(!1),[eZ,eA]=(0,n.useState)(!1),[eP,eO]=(0,n.useState)(null),[eM,ez]=(0,n.useState)(!1),[eq,eV]=(0,n.useState)(""),[eB,eG]=(0,n.useState)(""),[eJ,eK]=(0,n.useState)([]),[e$,eH]=(0,n.useState)({name:[],"user id":[],role:[],"gpu type":[],infra:[]}),[eW,eX]=(0,n.useState)(()=>{if(e.isReady){let t=e.query.deduplicate;if(void 0!==t)return"true"===t}return!0});(0,n.useEffect)(()=>{if(e.isReady){let s=e.query.deduplicate;if(void 0===s)eQ(!t);else{let e="true"===s;eW!==e&&eX(e)}}},[e.isReady,e.query.deduplicate,t]);let eQ=t=>{let s={...e.query};s.deduplicate=t.toString(),e.replace({pathname:e.pathname,query:s},void 0,{shallow:!0})},eY=t=>{(0,z.eG)(e,t)},e0=new Map([["name","Name"],["user id","User ID"],["role","Role"],["gpu type","GPU"],["infra","Infra"]]);(0,n.useEffect)(()=>{if(e.isReady&&"users"===eT){let t=(0,z.Fu)(e,e0);t.length>0&&eK(t)}},[e.isReady,eT]),(0,n.useEffect)(()=>{e.isReady&&("service-accounts"===e.query.tab&&e_?eL("service-accounts"):eL("users"))},[e.isReady,e.query.tab,e_]),(0,n.useEffect)(()=>{(async function(){eI(!0);try{let e=await A.x.get("/api/health");if(e.ok){let t=await e.json();eC(!!t.basic_auth_enabled),eS(!!t.service_account_token_enabled),eR(!!t.ingress_basic_auth_enabled)}else eC(!1),eS(!1),eR(!1)}catch(e){eC(!1),eS(!1),eR(!1)}finally{eI(!1)}})()},[]);let e1=(0,n.useCallback)(async()=>{if(R&&Date.now()-R.timestamp<3e5)return R;T(!0);try{let e=await A.x.get("/users/role");if(!e.ok){let t=await e.json();throw Error(t.detail||"Failed to get user role")}let t=await e.json(),s={role:t.role,name:t.name,id:t.id,timestamp:Date.now()};return D(s),T(!1),s}catch(e){throw T(!1),e}},[R]);(0,n.useEffect)(()=>{e1().catch(()=>{console.error("Failed to get user role")})},[e1]);let e2=async(e,t)=>{try{let s=await e1();if("admin"!==s.role)return E({open:!0,message:e,userName:s.name.toLowerCase()}),!1;return t(),!0}catch(e){return console.error("Failed to check user role:",e),E({open:!0,message:"Error: ".concat(e.message),userName:""}),!1}},e4=()=>{f.default.invalidate(x.R),f.default.invalidate(h.getClusters),f.default.invalidate(p.getManagedJobs,[{allUsers:!0,skipFinished:!0,fields:["user_hash","status"]}]),l.current&&l.current()},e3=async()=>{if(!g.username||!g.password){eN(Error("Username and password are required.")),m(!1);return}y(!0),eN(null),ev(null);try{let e=await A.x.post("/users/create",g);if(!e.ok){let t=await e.json();throw Error(t.detail||"Failed to create user")}ev('User "'.concat(g.username,'" created successfully!')),m(!1),b({username:"",password:"",role:"user"}),e4()}catch(e){eN(e),m(!1),b({username:"",password:"",role:"user"})}finally{y(!1)}},e5=async e=>{let t=e.target.files[0];t&&(G(t),Y(null))},e6=async()=>{if(!B){alert("Please select a CSV file first.");return}H(!0);try{let e=new FileReader;e.onload=async e=>{try{let t=e.target.result,s=await A.x.post("/users/import",{csv_content:t});if(!s.ok){let e=await s.json();throw Error(e.detail||"Failed to import users")}let r=await s.json(),n="Import completed. ".concat(r.success_count," users created successfully.");r.error_count>0&&(n+="\n".concat(r.error_count," failed."),r.creation_errors.length>0&&(n+="\nErrors: ".concat(r.creation_errors.slice(0,3).join(", ")),r.creation_errors.length>3&&(n+=" and ".concat(r.creation_errors.length-3," more...")))),Y({message:n}),r.success_count>0&&e4()}catch(e){alert("Error importing users: ".concat(e.message))}finally{H(!1)}},e.readAsText(B)}catch(e){alert("Error reading file: ".concat(e.message)),H(!1)}},e7=async e=>{ea(e),eo(""),er(!0)},e8=async()=>{if(!el){eN(Error("Please enter a new password."));return}ec(!0),ed(null);try{let e=await A.x.post("/users/update",{user_id:en.userId,password:el});if(!e.ok){let t=await e.json();throw Error(t.detail||"Failed to reset password")}ev('Password reset successfully for user "'.concat(en.usernameDisplay,'"!')),er(!1),ea(null),eo("")}catch(e){er(!1),ea(null),eo(""),ed(null),eN(e)}finally{ec(!1)}},e9=async()=>{if(eh){ej(!0),eg(null);try{let e=await A.x.post("/users/delete",{user_id:eh.userId});if(!e.ok){let t=await e.json();throw Error(t.detail||"Failed to delete user")}ev('User "'.concat(eh.usernameDisplay,'" deleted successfully!')),ex(!1),ep(null),e4()}catch(e){ex(!1),ep(null),eg(null),eN(e)}finally{ej(!1)}}},te=()=>{ex(!1),ep(null)},tt=()=>{er(!1),ea(null),eo("")};return eD?(0,r.jsxs)("div",{className:"flex justify-center items-center h-64",children:[(0,r.jsx)(o.Z,{}),(0,r.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading..."})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsxs)("div",{className:"text-base flex items-center",children:[(0,r.jsx)("button",{className:e_?"leading-none mr-6 pb-2 px-2 border-b-2 ".concat("users"===eT?"text-sky-blue border-sky-500":"text-gray-500 hover:text-gray-700 border-transparent"):"leading-none mr-6 pb-2 px-2",onClick:()=>{eL("users"),e.push("/users",void 0,{shallow:!0})},children:"Users"}),e_&&(0,r.jsx)("button",{className:"leading-none pb-2 px-2 border-b-2 ".concat("service-accounts"===eT?"text-sky-blue border-sky-500":"text-gray-500 hover:text-gray-700 border-transparent"),onClick:()=>{eL("service-accounts"),e.push("/users?tab=service-accounts",void 0,{shallow:!0})},children:"Service Accounts"})]}),(0,r.jsxs)("div",{className:"flex items-center",children:[s&&(0,r.jsxs)("div",{className:"flex items-center mr-2",children:[(0,r.jsx)(o.Z,{size:15,className:"mt-0"}),(0,r.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading..."})]}),"users"===eT&&ek&&(null==R?void 0:R.role)==="admin"&&(0,r.jsx)("button",{onClick:async()=>{await e2("cannot create users",()=>{m(!0)})},className:"text-sky-blue hover:text-sky-blue-bright flex items-center rounded px-2 py-1 mr-2",title:"Create New User",children:"+ New User"}),"users"===eT&&ek&&(null==R?void 0:R.role)==="admin"&&(0,r.jsxs)("button",{onClick:async()=>{await e2("cannot import users",()=>{q(!0)})},className:"text-sky-blue hover:text-sky-blue-bright flex items-center rounded px-2 py-1 mr-2",title:"Import/Export Users",children:[(0,r.jsx)(w,{className:"h-4 w-4 mr-1"}),"Import/Export"]}),(0,r.jsxs)("button",{onClick:e4,disabled:s,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:[(0,r.jsx)(N.Z,{className:"h-4 w-4 mr-1.5"}),!i&&(0,r.jsx)("span",{children:"Refresh"})]})]})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:["users"===eT?(0,r.jsx)("div",{className:"w-full sm:w-auto max-w-md",children:(0,r.jsx)(z.ML,{propertyList:V,valueList:e$,setFilters:eK,updateURLParams:eY,placeholder:"Filter users"})}):(0,r.jsxs)("div",{className:"relative flex-1 max-w-md",children:[(0,r.jsx)("input",{type:"text",placeholder:"Search by service account name, or created by",value:eB,onChange:e=>{eG(e.target.value)},className:"h-8 w-full px-3 pr-8 text-sm border border-gray-300 rounded-md focus:ring-1 focus:ring-sky-500 focus:border-sky-500 outline-none"}),eB&&(0,r.jsx)("button",{onClick:()=>{eG("")},className:"absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600",title:"Clear search",children:(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),"users"===eT&&!t&&(0,r.jsxs)("label",{className:"flex items-center cursor-pointer ml-4",children:[(0,r.jsx)("input",{type:"checkbox",checked:eW,onChange:e=>{let t=e.target.checked;eX(t),eQ(t)},className:"sr-only"}),(0,r.jsx)("div",{className:"relative inline-flex h-5 w-9 items-center rounded-full transition-colors ".concat(eW?"bg-sky-600":"bg-gray-300"),children:(0,r.jsx)("span",{className:"inline-block h-3 w-3 transform rounded-full bg-white transition-transform ".concat(eW?"translate-x-5":"translate-x-1")})}),(0,r.jsx)("span",{className:"ml-2 text-sm text-gray-700",children:"Deduplicate users"})]}),"service-accounts"===eT&&e_&&(0,r.jsxs)("button",{onClick:()=>{e2("cannot create service account tokens",()=>{eF(!0)})},className:"ml-4 bg-sky-600 hover:bg-sky-700 text-white flex items-center rounded-md px-3 py-1 text-sm font-medium transition-colors duration-200",title:"Create Service Account",children:[(0,r.jsx)(k.Z,{className:"h-4 w-4 mr-2"}),"Create Service Account"]})]}),"users"===eT&&(0,r.jsx)(z.x$,{filters:eJ,setFilters:eK,updateURLParams:eY}),(0,r.jsxs)("div",{className:"fixed top-20 right-4 z-[9999] max-w-md",children:[(0,r.jsx)($,{message:ey,onDismiss:()=>ev(null)}),(0,r.jsx)(O.X,{error:ew,title:"Error",onDismiss:()=>eN(null)})]}),"users"===eT?(0,r.jsx)(W,{refreshInterval:K,setLoading:a,refreshDataRef:l,checkPermissionAndAct:e2,roleLoading:I,onResetPassword:e7,onDeleteUser:e=>{e2("cannot delete users",()=>{ep(e),ex(!0)})},basicAuthEnabled:ek,ingressBasicAuthEnabled:eE,currentUserRole:null==R?void 0:R.role,currentUserId:null==R?void 0:R.id,filters:eJ,setValueList:eH,deduplicateUsers:eW}):e_&&(0,r.jsx)(X,{checkPermissionAndAct:e2,userRoleCache:R,setCreateSuccess:ev,setCreateError:eN,showCreateDialog:eU,setShowCreateDialog:eF,showRotateDialog:eZ,setShowRotateDialog:eA,tokenToRotate:eP,setTokenToRotate:eO,rotating:eM,setRotating:ez,searchQuery:eB,setSearchQuery:eG}),(0,r.jsx)(P.Vq,{open:c,onOpenChange:e=>{m(e),e||eN(null)},children:(0,r.jsxs)(P.cZ,{className:"sm:max-w-md",children:[(0,r.jsx)(P.fK,{children:(0,r.jsx)(P.$N,{children:"Create User"})}),(0,r.jsxs)("div",{className:"flex flex-col gap-4 py-4",children:[(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Username"}),(0,r.jsx)("input",{className:"border rounded px-3 py-2 w-full",placeholder:"Username",value:g.username,onChange:e=>b({...g,username:e.target.value})})]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Password"}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("input",{className:"border rounded px-3 py-2 w-full pr-10",placeholder:"Password",type:L?"text":"password",value:g.password,onChange:e=>b({...g,password:e.target.value})}),(0,r.jsx)("button",{type:"button",className:"absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400 hover:text-gray-600",onClick:()=>Z(!L),children:L?(0,r.jsx)(C,{className:"h-4 w-4"}):(0,r.jsx)(_,{className:"h-4 w-4"})})]})]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Role"}),(0,r.jsxs)("select",{className:"border rounded px-3 py-2 w-full",value:g.role,onChange:e=>b({...g,role:e.target.value}),children:[(0,r.jsx)("option",{value:"user",children:"User"}),(0,r.jsx)("option",{value:"admin",children:"Admin"})]})]})]}),(0,r.jsxs)(P.cN,{children:[(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2",onClick:()=>m(!1),disabled:j,children:"Cancel"}),(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:e3,disabled:j,children:j?"Creating...":"Create"})]})]})}),(0,r.jsx)(P.Vq,{open:v.open,onOpenChange:e=>{E(t=>({...t,open:e})),e||eN(null)},children:(0,r.jsxs)(P.cZ,{className:"sm:max-w-md transition-all duration-200 ease-in-out",children:[(0,r.jsxs)(P.fK,{children:[(0,r.jsx)(P.$N,{children:"Permission Denied"}),(0,r.jsx)(P.Be,{children:I?(0,r.jsxs)("div",{className:"flex items-center py-2",children:[(0,r.jsx)(o.Z,{size:16,className:"mr-2"}),(0,r.jsx)("span",{children:"Checking permissions..."})]}):(0,r.jsx)(r.Fragment,{children:v.userName?(0,r.jsxs)(r.Fragment,{children:[v.userName," is logged in as non-admin and ",v.message,"."]}):v.message})})]}),(0,r.jsx)(P.cN,{children:(0,r.jsx)(d.z,{variant:"outline",onClick:()=>E(e=>({...e,open:!1})),disabled:I,children:"OK"})})]})}),(0,r.jsx)(P.Vq,{open:M,onOpenChange:e=>{q(e),e||eN(null)},children:(0,r.jsxs)(P.cZ,{className:"sm:max-w-lg",children:[(0,r.jsx)(P.fK,{children:(0,r.jsx)(P.$N,{children:"Import/Export Users"})}),(0,r.jsxs)("div",{className:"flex border-b border-gray-200 mb-4",children:[(0,r.jsx)("button",{className:"px-4 py-2 text-sm font-medium ".concat("import"===ee?"border-b-2 border-sky-500 text-sky-600":"text-gray-500 hover:text-gray-700"),onClick:()=>et("import"),children:"Import"}),(0,r.jsx)("button",{className:"px-4 py-2 text-sm font-medium ".concat("export"===ee?"border-b-2 border-sky-500 text-sky-600":"text-gray-500 hover:text-gray-700"),onClick:()=>et("export"),children:"Export"})]}),(0,r.jsx)("div",{className:"flex flex-col gap-4 py-4",children:"import"===ee?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"CSV File"}),(0,r.jsx)("input",{type:"file",accept:".csv",onChange:e5,className:"border rounded px-3 py-2 w-full"}),(0,r.jsxs)("p",{className:"text-xs text-gray-500",children:["CSV should have columns: username, password, role",(0,r.jsx)("br",{}),"Supports both plain text passwords and exported password hashes."]})]}),Q&&(0,r.jsx)("div",{className:"p-3 bg-green-50 border border-green-200 rounded text-green-700 text-sm",children:Q.message})]}):(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Export Users to CSV"}),(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"Download all users as a CSV file with password hashes."}),(0,r.jsxs)("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:[(0,r.jsx)("p",{className:"text-sm text-amber-700",children:"⚠️ This will export all users with columns: username, password (hashed), role"}),(0,r.jsx)("p",{className:"text-xs text-amber-600 mt-1",children:"Password hashes can be imported directly for system backups."})]})]})})}),(0,r.jsxs)(P.cN,{children:[(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2",onClick:()=>q(!1),disabled:J,children:"Cancel"}),"import"===ee?(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:e6,disabled:J||!B,children:J?"Importing...":"Import"}):(0,r.jsxs)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:async()=>{try{let e=await A.x.get("/users/export");if(!e.ok){let t=await e.json();throw Error(t.detail||"Failed to export users")}let t=await e.json(),s=t.csv_content,r=new Blob([s],{type:"text/csv;charset=utf-8;"}),n=URL.createObjectURL(r),a=document.createElement("a");a.href=n;let l=new Date,o=e=>String(e).padStart(2,"0"),i=l.getFullYear(),c=o(l.getMonth()+1),u=o(l.getDate()),d=o(l.getHours()),m=o(l.getMinutes()),x=o(l.getSeconds());a.download="users_export_".concat(i,"-").concat(c,"-").concat(u,"-").concat(d,"-").concat(m,"-").concat(x,".csv"),a.click(),URL.revokeObjectURL(n),alert("Successfully exported ".concat(t.user_count," users to CSV file."))}catch(e){alert("Error exporting users: ".concat(e.message))}},children:[(0,r.jsx)(S.Z,{className:"h-4 w-4 mr-1"}),"Export"]})]})]})}),(0,r.jsx)(P.Vq,{open:es,onOpenChange:e=>{e||(tt(),eN(null))},children:(0,r.jsxs)(P.cZ,{className:"sm:max-w-md",children:[(0,r.jsxs)(P.fK,{children:[(0,r.jsx)(P.$N,{children:"Reset Password"}),(0,r.jsxs)(P.Be,{children:["Enter a new password for"," ",(null==en?void 0:en.usernameDisplay)||"this user","."]})]}),(0,r.jsx)("div",{className:"flex flex-col gap-4 py-4",children:(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"New Password"}),(0,r.jsx)("input",{type:"password",className:"border rounded px-3 py-2 w-full",placeholder:"Enter new password",value:el,onChange:e=>eo(e.target.value),autoFocus:!0})]})}),(0,r.jsxs)(P.cN,{children:[(0,r.jsx)(d.z,{variant:"outline",onClick:tt,disabled:ei,children:"Cancel"}),(0,r.jsx)(d.z,{variant:"default",onClick:e8,disabled:ei||!el,className:"bg-sky-600 text-white hover:bg-sky-700",children:ei?"Resetting...":"Reset Password"})]})]})}),(0,r.jsx)(P.Vq,{open:em,onOpenChange:e=>{e||(te(),eN(null))},children:(0,r.jsxs)(P.cZ,{className:"sm:max-w-md",children:[(0,r.jsxs)(P.fK,{children:[(0,r.jsx)(P.$N,{children:"Delete User"}),(0,r.jsxs)(P.Be,{children:['Are you sure you want to delete user "',(null==eh?void 0:eh.usernameDisplay)||"this user",'"? This action cannot be undone.']})]}),(0,r.jsxs)(P.cN,{children:[(0,r.jsx)(d.z,{variant:"outline",onClick:te,disabled:eb,children:"Cancel"}),(0,r.jsx)(d.z,{variant:"destructive",onClick:e9,disabled:eb,children:eb?"Deleting...":"Delete"})]})]})})]})}function W(e){let{refreshInterval:t,setLoading:s,refreshDataRef:a,checkPermissionAndAct:l,roleLoading:i,onResetPassword:u,onDeleteUser:d,basicAuthEnabled:b,ingressBasicAuthEnabled:v,currentUserRole:w,currentUserId:N,filters:k,setValueList:C,deduplicateUsers:_}=e,[S,L]=(0,n.useState)([]),[U,F]=(0,n.useState)(!0),[P,O]=(0,n.useState)(!1),[M,V]=(0,n.useState)({key:"username",direction:"ascending"}),[K,$]=(0,n.useState)(null),[H,W]=(0,n.useState)(""),[X,Q]=(0,n.useState)({}),[Y,ee]=(0,n.useState)(!1),et=(0,n.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];s&&e&&s(!0),e&&F(!0),ee(!1);try{let t=await f.default.get(x.R),r=(t||[]).map(e=>({...e,usernameDisplay:G(e.username,e.userId),fullEmailID:J(e.username,e.userId),clusterCount:-1,jobCount:-1,gpuCount:-1}));L(r),O(!0),s&&e&&s(!1),e&&F(!1);let n=[],a={jobs:[]};try{[n,a]=await Promise.all([f.default.get(h.getClusters),f.default.get(p.getManagedJobs,[{allUsers:!0,skipFinished:!0,fields:["user_hash","status","accelerators","job_name","job_id","infra"]}])])}catch(e){console.error("Error fetching clusters and managed jobs:",e)}let l=a.jobs||[],o={},i=e=>{if(!e)return null;let t=e;if("string"==typeof e)try{let s=e.replace(/'/g,'"').replace(/None/g,"null");t=JSON.parse(s)}catch(e){return null}if("object"==typeof t&&null!==t){let e=Object.entries(t);if(e.length>0)return e[0][0]}return null},c=(e,t,s,r,n,a)=>{e&&t&&(o[e]||(o[e]={}),o[e][t]||(o[e][t]={}),o[e].Total||(o[e].Total={}),o[e][t].Total||(o[e][t].Total={clusterCount:0,jobCount:0,gpuCount:0}),o[e][t].Total.clusterCount+=r,o[e][t].Total.jobCount+=n,o[e][t].Total.gpuCount+=a,s&&(o[e][t][s]||(o[e][t][s]={clusterCount:0,jobCount:0,gpuCount:0}),o[e][t][s].clusterCount+=r,o[e][t][s].jobCount+=n,o[e][t][s].gpuCount+=a,o[e].Total[s]||(o[e].Total[s]={clusterCount:0,jobCount:0,gpuCount:0}),o[e].Total[s].clusterCount+=r,o[e].Total[s].jobCount+=n,o[e].Total[s].gpuCount+=a))};for(let e of n||[]){let t=e.user_hash;if(!t)continue;let s=i(e.gpus),r=e.infra,n=0;if("STOPPED"!==e.status&&"TERMINATED"!==e.status){let t=B(e.gpus,"Cluster ".concat(e.cluster)),s=e.num_nodes||1;n=t*s}c(t,r,s,1,0,n)}let u=e=>{if(!e||"string"!=typeof e)return 1;let t=e.match(/^(\d+)x/);return t?parseInt(t[1],10):1};for(let e of l||[]){if(!q.has(e.status))continue;let t=e.user_hash;if(!t)continue;let s=i(e.accelerators),r=e.infra,n=B(e.accelerators,"Job ".concat(e.job_id)),a=u(e.resources_str_full),l=n*a;c(t,r,s,0,1,l)}Q(o),ee(!0);let d=(t||[]).map(e=>{let t=0,s=0,r=0,a=0;for(let r of n||[])if(r.user_hash===e.userId&&(t++,"STOPPED"!==r.status&&"TERMINATED"!==r.status)){let e=B(r.gpus,"Cluster ".concat(r.cluster)),t=r.num_nodes||1;s+=e*t}for(let t of l||[])if(t.user_hash===e.userId&&q.has(t.status)){r++;let e=B(t.accelerators,"Job ".concat(t.job_id)),s=u(t.resources_str_full);a+=e*s}return{...e,usernameDisplay:G(e.username,e.userId),fullEmailID:J(e.username,e.userId),clusterCount:t,jobCount:r,gpuCount:s+a}}),m=new Set,g=new Set;for(let e of Object.values(o)){for(let t of Object.keys(e))"Total"!==t&&m.add(t);if(e.Total)for(let t of Object.keys(e.Total))g.add(t)}let b=new Set,j=new Set,y=new Set;d.forEach(e=>{e.usernameDisplay&&b.add(e.usernameDisplay),e.userId&&j.add(e.userId),e.role&&y.add(e.role)}),C({name:Array.from(b).sort(),"user id":Array.from(j).sort(),role:Array.from(y).sort(),"gpu type":Array.from(g).sort(),infra:Array.from(m).sort()}),L(d)}catch(t){console.error("Failed to fetch or process user data:",t),L([]),O(!0),s&&e&&s(!1),e&&F(!1)}},[s]);(0,n.useEffect)(()=>{a&&(a.current=()=>et(!0))},[a,et]),(0,n.useEffect)(()=>{(async()=>{O(!1),F(!0),await g.ZP.preloadForPage("users"),et(!0)})();let e=setInterval(()=>{"visible"===window.document.visibilityState&&et(!1)},t);return()=>clearInterval(e)},[et,t]);let es=(0,n.useMemo)(()=>{let e=S,t=k.filter(e=>"GPU"!==e.property&&"Infra"!==e.property),s=k.filter(e=>"GPU"===e.property),r=k.filter(e=>"Infra"===e.property);t.length>0&&(e=(0,z.cm)(S.map(e=>({...e,name:e.usernameDisplay,"user id":e.userId})),t));let n=(e,t,s)=>{let r=0,n=0,a=0,l=X[e];if(!l)return{clusterCount:0,jobCount:0,gpuCount:0};let o=t.map(e=>e.toLowerCase()),i=s.map(e=>e.toLowerCase()),c=o.length>0,u=i.length>0;if(c&&u){for(let e of i)for(let[t,s]of Object.entries(l))if("Total"!==t&&t.toLowerCase()===e)for(let e of o)for(let[t,l]of Object.entries(s))"Total"!==t&&t.toLowerCase()===e&&(r+=l.clusterCount,n+=l.jobCount,a+=l.gpuCount)}else if(u){for(let e of i)for(let[t,s]of Object.entries(l))if("Total"!==t&&t.toLowerCase()===e&&s.Total){let e=s.Total;r+=e.clusterCount,n+=e.jobCount,a+=e.gpuCount}}else if(c&&l.Total)for(let e of o)for(let[t,s]of Object.entries(l.Total))t.toLowerCase()===e&&(r+=s.clusterCount,n+=s.jobCount,a+=s.gpuCount);return{clusterCount:r,jobCount:n,gpuCount:a}},a=s.length>0,l=r.length>0;if(a||l){let t=s.map(e=>e.value).filter(Boolean),o=r.map(e=>e.value).filter(Boolean),i=t.map(e=>e.toLowerCase()),c=o.map(e=>e.toLowerCase());e=(e=e.filter(e=>{let t=X[e.userId];if(!t)return!1;if(a&&l){for(let e of c)for(let[s,r]of Object.entries(t))if("Total"!==s&&s.toLowerCase()===e){for(let e of i)for(let t of Object.keys(r))if("Total"!==t&&t.toLowerCase()===e)return!0}}else if(l){for(let e of c)for(let s of Object.keys(t))if("Total"!==s&&s.toLowerCase()===e)return!0}else if(a&&t.Total){for(let e of i)for(let s of Object.keys(t.Total))if(s.toLowerCase()===e)return!0}return!1})).map(e=>{let s=n(e.userId,t,o);return{...e,clusterCount:s.clusterCount,jobCount:s.jobCount,gpuCount:s.gpuCount}})}if(_){let t={};e.forEach(e=>{let s=e.usernameDisplay;t[s]?(t[s].userIds.push(e.userId),-1!==e.clusterCount&&(-1===t[s].clusterCount?t[s].clusterCount=e.clusterCount:t[s].clusterCount+=e.clusterCount),-1!==e.jobCount&&(-1===t[s].jobCount?t[s].jobCount=e.jobCount:t[s].jobCount+=e.jobCount),-1!==e.gpuCount&&(-1===t[s].gpuCount?t[s].gpuCount=e.gpuCount:t[s].gpuCount+=e.gpuCount),e.created_at&&(!t[s].created_at||e.created_at<t[s].created_at)&&(t[s].created_at=e.created_at)):t[s]={...e,userIds:[e.userId],clusterCount:e.clusterCount,jobCount:e.jobCount,gpuCount:e.gpuCount,created_at:e.created_at}}),e=Object.values(t)}return(0,j.R0)(e,M.key,M.direction)},[S,M,k,_,X]),er=e=>{let t="ascending";M.key===e&&"ascending"===M.direction&&(t="descending"),V({key:e,direction:t})},en=e=>M.key===e?"ascending"===M.direction?" ↑":" ↓":"",ea=async(e,t)=>{await l("cannot edit user role",()=>{$(e),W(t)})},el=()=>{$(null),W("")},eo=async e=>{if(!e||!H){console.error("User ID or role is missing."),alert("Error: User ID or role is missing.");return}F(!0);try{let t=await A.x.post("/users/update",{user_id:e,role:H});if(!t.ok){let e=await t.json();throw Error(e.detail||"Failed to update role")}f.default.invalidate(x.R),await et(!0),el()}catch(e){console.error("Failed to update user role:",e),alert("Error updating role: ".concat(e.message))}finally{F(!1)}};return U&&0===S.length&&!P?(0,r.jsx)("div",{className:"flex justify-center items-center h-64",children:(0,r.jsx)(o.Z,{})}):P?k.some(e=>"GPU"===e.property||"Infra"===e.property)&&!Y?(0,r.jsxs)("div",{className:"flex justify-center items-center h-64",children:[(0,r.jsx)(o.Z,{}),(0,r.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading filtered data..."})]}):es&&0!==es.length?(0,r.jsx)(Z.Zb,{children:(0,r.jsx)("div",{className:"overflow-x-auto rounded-lg",children:(0,r.jsxs)(m.iA,{className:"min-w-full",children:[(0,r.jsx)(m.xD,{children:(0,r.jsxs)(m.SC,{children:[(0,r.jsxs)(m.ss,{onClick:()=>er("usernameDisplay"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Name",en("usernameDisplay")]}),!_&&(0,r.jsxs)(m.ss,{onClick:()=>er("fullEmailID"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["User ID",en("fullEmailID")]}),!_&&!v&&(0,r.jsxs)(m.ss,{onClick:()=>er("role"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Role",en("role")]}),(0,r.jsxs)(m.ss,{onClick:()=>er("created_at"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Joined",en("created_at")]}),(0,r.jsxs)(m.ss,{onClick:()=>er("gpuCount"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["GPUs",en("gpuCount")]}),(0,r.jsxs)(m.ss,{onClick:()=>er("clusterCount"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Clusters",en("clusterCount")]}),(0,r.jsxs)(m.ss,{onClick:()=>er("jobCount"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Jobs",en("jobCount")]}),!_&&(b||"admin"===w)&&(0,r.jsx)(m.ss,{className:"whitespace-nowrap w-1/7",children:"Actions"})]})}),(0,r.jsx)(m.RM,{children:es.map(e=>(0,r.jsxs)(m.SC,{children:[(0,r.jsx)(m.pj,{className:"truncate",title:e.username,children:e.usernameDisplay}),!_&&(0,r.jsx)(m.pj,{className:"truncate",title:e.fullEmailID,children:e.fullEmailID}),!_&&!v&&(0,r.jsx)(m.pj,{className:"truncate",title:e.role,children:(0,r.jsx)("div",{className:"flex items-center gap-2",children:K===e.userId?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("select",{value:H,onChange:e=>W(e.target.value),className:"block w-auto p-1 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-sky-blue focus:border-sky-blue sm:text-sm",children:[(0,r.jsx)("option",{value:"admin",children:"Admin"}),(0,r.jsx)("option",{value:"user",children:"User"})]}),(0,r.jsx)("button",{onClick:()=>eo(e.userId),className:"text-green-600 hover:text-green-800 p-1",title:"Save",children:(0,r.jsx)(E.Z,{className:"h-4 w-4"})}),(0,r.jsx)("button",{onClick:el,className:"text-gray-500 hover:text-gray-700 p-1",title:"Cancel",children:(0,r.jsx)(R.Z,{className:"h-4 w-4"})})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"capitalize",children:e.role}),"admin"===w&&(0,r.jsx)("button",{onClick:()=>ea(e.userId,e.role),className:"text-blue-600 hover:text-blue-700 p-1",title:"Edit role",children:(0,r.jsx)(D,{className:"h-3 w-3"})})]})})}),(0,r.jsx)(m.pj,{className:"truncate",children:e.created_at?(0,r.jsx)(y.Zg,{date:new Date(1e3*e.created_at)}):"-"}),(0,r.jsx)(m.pj,{children:-1===e.gpuCount?(0,r.jsxs)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-400 rounded text-xs font-medium flex items-center",children:[(0,r.jsx)(o.Z,{size:10,className:"mr-1"}),"Loading..."]}):(0,r.jsx)("span",{className:"px-2 py-0.5 rounded text-xs font-medium ".concat(e.gpuCount>0?"bg-purple-100 text-purple-600":"bg-gray-100 text-gray-500"),title:"Total GPUs: ".concat(e.gpuCount),children:e.gpuCount})}),(0,r.jsx)(m.pj,{children:-1===e.clusterCount?(0,r.jsxs)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-400 rounded text-xs font-medium flex items-center",children:[(0,r.jsx)(o.Z,{size:10,className:"mr-1"}),"Loading..."]}):(0,r.jsx)(c(),{href:"/clusters?user=".concat(encodeURIComponent(e.userId)),className:"px-2 py-0.5 rounded text-xs font-medium transition-colors duration-200 cursor-pointer inline-block ".concat(e.clusterCount>0?"bg-blue-100 text-blue-600 hover:bg-blue-200 hover:text-blue-700":"bg-gray-100 text-gray-500 hover:bg-gray-200 hover:text-gray-700"),title:"View ".concat(e.clusterCount," cluster").concat(1!==e.clusterCount?"s":""," for ").concat(e.usernameDisplay),children:e.clusterCount})}),(0,r.jsx)(m.pj,{children:-1===e.jobCount?(0,r.jsxs)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-400 rounded text-xs font-medium flex items-center",children:[(0,r.jsx)(o.Z,{size:10,className:"mr-1"}),"Loading..."]}):(0,r.jsx)(c(),{href:"/jobs?user=".concat(encodeURIComponent(e.userId)),className:"px-2 py-0.5 rounded text-xs font-medium transition-colors duration-200 cursor-pointer inline-block ".concat(e.jobCount>0?"bg-green-100 text-green-600 hover:bg-green-200 hover:text-green-700":"bg-gray-100 text-gray-500 hover:bg-gray-200 hover:text-gray-700"),title:"View ".concat(e.jobCount," active job").concat(1!==e.jobCount?"s":""," for ").concat(e.usernameDisplay),children:e.jobCount})}),!_&&(b||"admin"===w)&&(0,r.jsx)(m.pj,{className:"relative",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[b&&(0,r.jsx)("button",{onClick:"admin"===w||e.userId===N?async()=>{u(e)}:void 0,className:"admin"===w||e.userId===N?"text-blue-600 hover:text-blue-700 p-1":"text-gray-300 cursor-not-allowed p-1",title:"admin"===w||e.userId===N?"Reset Password":"You can only reset your own password",disabled:"admin"!==w&&e.userId!==N,children:(0,r.jsx)(I,{className:"h-4 w-4"})}),"admin"===w&&(0,r.jsx)("button",{onClick:()=>d(e),className:"text-red-600 hover:text-red-700 p-1",title:"Delete User",children:(0,r.jsx)(T.Z,{className:"h-4 w-4"})})]})})]},e.userId))})]})})}):(0,r.jsxs)("div",{className:"text-center py-12",children:[(0,r.jsx)("p",{className:"text-lg font-semibold text-gray-500",children:k.length>0?"No users match your filters.":"No users found."}),(0,r.jsx)("p",{className:"text-sm text-gray-400 mt-1",children:k.length>0?"Try adjusting your filter criteria.":"There are currently no users to display."})]}):(0,r.jsxs)("div",{className:"flex justify-center items-center h-64",children:[(0,r.jsx)(o.Z,{}),(0,r.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading users..."})]})}function X(e){let{checkPermissionAndAct:t,userRoleCache:s,setCreateSuccess:a,setCreateError:l,showCreateDialog:i,setShowCreateDialog:u,showRotateDialog:d,setShowRotateDialog:x,tokenToRotate:g,setTokenToRotate:b,rotating:j,setRotating:v,searchQuery:w,setSearchQuery:k}=e,[C,_]=(0,n.useState)([]),[S,U]=(0,n.useState)(!0),[F,O]=(0,n.useState)(!1),[M,z]=(0,n.useState)(null),[V,G]=(0,n.useState)(null),[J,K]=(0,n.useState)({token_name:"",expires_in_days:30}),[$,H]=(0,n.useState)(""),[W,X]=(0,n.useState)(!1),[Q,Y]=(0,n.useState)(!1),[ee,et]=(0,n.useState)(""),[es,er]=(0,n.useState)(null),[en,ea]=(0,n.useState)(null),[el,eo]=(0,n.useState)(null),[ei,ec]=(0,n.useState)(""),[eu,ed]=(0,n.useState)([]),em=async()=>{try{U(!0);let e=await A.x.get("/users/service-account-tokens");if(!e.ok){console.error("Failed to fetch tokens"),_([]),ed([]);return}let t=await e.json();_(t||[]);let s=[],r={jobs:[]};try{[s,r]=await Promise.all([f.default.get(h.getClusters),f.default.get(p.getManagedJobs,[{allUsers:!0,skipFinished:!0,fields:["user_hash","status","accelerators","job_id","infra"]}])])}catch(e){console.error("Error fetching clusters and managed jobs:",e)}let n=s||[],a=(null==r?void 0:r.jobs)||[],l=(t||[]).map(e=>{let t=e.service_account_user_id,s=0,r=0,l=0,o=0;for(let e of n)e.user_hash===t&&(s++,"STOPPED"!==e.status&&"TERMINATED"!==e.status&&(r+=B(e.gpus,"Cluster ".concat(e.cluster))));for(let e of a)e.user_hash===t&&q.has(e.status)&&(l++,o+=B(e.accelerators,"Job ".concat(e.job_name||e.job_id)));return{...e,clusterCount:s,jobCount:l,gpuCount:r+o,primaryRole:e.service_account_roles&&e.service_account_roles.length>0?e.service_account_roles[0]:"user"}});ed(l)}catch(e){console.error("Error fetching tokens and counts:",e),_([]),ed([])}finally{U(!1)}};(0,n.useEffect)(()=>{em()},[]);let ex=async(e,s)=>{await t("cannot edit service account role",()=>{eo(e),ec(s)})},eh=()=>{eo(null),ec("")},ep=async e=>{if(!e||!ei){console.error("Token ID or role is missing."),l(Error("Token ID or role is missing."));return}U(!0);try{let t=await A.x.post("/users/service-account-tokens/update-role",{token_id:e,role:ei});if(!t.ok){let e=await t.json();throw Error(e.detail||"Failed to update role")}a("Service account role updated successfully!"),await em(),eh()}catch(e){console.error("Failed to update service account role:",e),l(e)}finally{U(!1)}},ef=async e=>{try{await navigator.clipboard.writeText(e),et("Copied!"),setTimeout(()=>et(""),2e3)}catch(e){console.error("Failed to copy:",e)}},eg=async()=>{if(!J.token_name.trim()){l(Error("Token name is required"));return}X(!0);try{let e={token_name:J.token_name.trim(),expires_in_days:""===J.expires_in_days?null:J.expires_in_days},t=await A.x.post("/users/service-account-tokens",e);if(t.ok){let e=await t.json();er(e.token),K({token_name:"",expires_in_days:30}),await em()}else{let e=await t.json();throw Error(e.detail||"Failed to create token")}}catch(e){l(e)}finally{X(!1)}},eb=async()=>{if(M){Y(!0),G(null);try{let e=await A.x.post("/users/service-account-tokens/delete",{token_id:M.token_id});if(e.ok)a('Service account "'.concat(M.token_name,'" deleted successfully!')),O(!1),z(null),G(null),await em();else{let t=await e.json();throw Error(t.detail||"Failed to delete service account")}}catch(e){O(!1),z(null),G(null),l(e)}finally{Y(!1)}}},ej=async()=>{if(g){v(!0);try{let e={token_id:g.token_id,expires_in_days:""===$?null:parseInt($)},t=await A.x.post("/users/service-account-tokens/rotate",e);if(t.ok){let e=await t.json();ea(e.token),await em()}else{let e=await t.json();throw Error(e.detail||"Failed to rotate token")}}catch(e){l(e)}finally{v(!1)}}},ey=eu.filter(e=>{var t,s,r,n;if(!(null==w?void 0:w.trim()))return!0;let a=w.toLowerCase();return(null===(t=e.token_name)||void 0===t?void 0:t.toLowerCase().includes(a))||(null===(s=e.creator_name)||void 0===s?void 0:s.toLowerCase().includes(a))||(null===(r=e.service_account_name)||void 0===r?void 0:r.toLowerCase().includes(a))||(null===(n=e.primaryRole)||void 0===n?void 0:n.toLowerCase().includes(a))});return S&&0===eu.length?(0,r.jsxs)("div",{className:"flex items-center justify-center py-8",children:[(0,r.jsx)(o.Z,{size:32}),(0,r.jsx)("span",{className:"ml-3",children:"Loading tokens..."})]}):(0,r.jsxs)(r.Fragment,{children:[0===ey.length?(0,r.jsxs)("div",{className:"text-center py-12",children:[(0,r.jsx)(I,{className:"mx-auto h-12 w-12 text-gray-400"}),(0,r.jsx)("h3",{className:"mt-2 text-sm font-medium text-gray-900",children:(null==w?void 0:w.trim())?"No tokens match your search":"No service accounts"}),(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-500",children:(null==w?void 0:w.trim())?"Try adjusting your search terms.":"No service accounts have been created yet."})]}):(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(Z.Zb,{children:(0,r.jsxs)(m.iA,{children:[(0,r.jsx)(m.xD,{children:(0,r.jsxs)(m.SC,{children:[(0,r.jsx)(m.ss,{children:"Name"}),(0,r.jsx)(m.ss,{children:"Created by"}),(0,r.jsx)(m.ss,{children:"Role"}),(0,r.jsx)(m.ss,{children:"Clusters"}),(0,r.jsx)(m.ss,{children:"Jobs"}),(0,r.jsx)(m.ss,{children:"GPUs"}),(0,r.jsx)(m.ss,{children:"Created"}),(0,r.jsx)(m.ss,{children:"Last used"}),(0,r.jsx)(m.ss,{children:"Expires"}),(0,r.jsx)(m.ss,{children:"Actions"})]})}),(0,r.jsx)(m.RM,{children:ey.map(e=>(0,r.jsxs)(m.SC,{children:[(0,r.jsx)(m.pj,{className:"truncate",title:e.token_name,children:e.token_name}),(0,r.jsx)(m.pj,{className:"truncate",children:(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("span",{children:e.creator_name||"Unknown"}),e.creator_user_hash!==(null==s?void 0:s.id)&&(0,r.jsx)("span",{className:"ml-2 px-1.5 py-0.5 text-xs bg-gray-100 text-gray-600 rounded",children:"Other"})]})}),(0,r.jsx)(m.pj,{className:"truncate",children:(0,r.jsx)("div",{className:"flex items-center gap-2",children:el===e.token_id?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("select",{value:ei,onChange:e=>ec(e.target.value),className:"block w-auto p-1 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-sky-blue focus:border-sky-blue sm:text-sm",children:[(0,r.jsx)("option",{value:"admin",children:"Admin"}),(0,r.jsx)("option",{value:"user",children:"User"})]}),(0,r.jsx)("button",{onClick:()=>ep(e.token_id),className:"text-green-600 hover:text-green-800 p-1",title:"Save",children:(0,r.jsx)(E.Z,{className:"h-4 w-4"})}),(0,r.jsx)("button",{onClick:eh,className:"text-gray-500 hover:text-gray-700 p-1",title:"Cancel",children:(0,r.jsx)(R.Z,{className:"h-4 w-4"})})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"capitalize",children:e.primaryRole}),((null==s?void 0:s.role)==="admin"||e.creator_user_hash===(null==s?void 0:s.id))&&(0,r.jsx)("button",{onClick:()=>ex(e.token_id,e.primaryRole),className:"text-blue-600 hover:text-blue-700 p-1",title:"Edit role",children:(0,r.jsx)(D,{className:"h-3 w-3"})})]})})}),(0,r.jsx)(m.pj,{children:(0,r.jsx)(c(),{href:"/clusters?user=".concat(encodeURIComponent(e.service_account_user_id)),className:"px-2 py-0.5 rounded text-xs font-medium transition-colors duration-200 cursor-pointer inline-block ".concat(e.clusterCount>0?"bg-blue-100 text-blue-600 hover:bg-blue-200 hover:text-blue-700":"bg-gray-100 text-gray-500 hover:bg-gray-200 hover:text-gray-700"),title:"View ".concat(e.clusterCount," cluster").concat(1!==e.clusterCount?"s":""," for ").concat(e.token_name),children:e.clusterCount})}),(0,r.jsx)(m.pj,{children:(0,r.jsx)(c(),{href:"/jobs?user=".concat(encodeURIComponent(e.service_account_user_id)),className:"px-2 py-0.5 rounded text-xs font-medium transition-colors duration-200 cursor-pointer inline-block ".concat(e.jobCount>0?"bg-green-100 text-green-600 hover:bg-green-200 hover:text-green-700":"bg-gray-100 text-gray-500 hover:bg-gray-200 hover:text-gray-700"),title:"View ".concat(e.jobCount," active job").concat(1!==e.jobCount?"s":""," for ").concat(e.token_name),children:e.jobCount})}),(0,r.jsx)(m.pj,{children:(0,r.jsx)("span",{className:"px-2 py-0.5 rounded text-xs font-medium ".concat(e.gpuCount>0?"bg-purple-100 text-purple-600":"bg-gray-100 text-gray-500"),title:"Total GPUs: ".concat(e.gpuCount),children:e.gpuCount})}),(0,r.jsx)(m.pj,{className:"truncate",children:e.created_at?(0,r.jsx)(y.Zg,{date:new Date(1e3*e.created_at)}):"Never"}),(0,r.jsx)(m.pj,{className:"truncate",children:e.last_used_at?(0,r.jsx)(y.Zg,{date:new Date(1e3*e.last_used_at)}):"Never"}),(0,r.jsx)(m.pj,{className:"truncate",children:e.expires_at?new Date(1e3*e.expires_at)<new Date?(0,r.jsx)("span",{className:"text-red-600",children:"Expired"}):(0,r.jsx)(y.Zg,{date:new Date(1e3*e.expires_at)}):"Never"}),(0,r.jsx)(m.pj,{children:(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[((null==s?void 0:s.role)==="admin"||e.creator_user_hash===(null==s?void 0:s.id))&&(0,r.jsx)(y.WH,{content:"Rotate token",className:"capitalize text-sm text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>{t("cannot rotate service account tokens",()=>{b(e),x(!0)})},className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center",children:(0,r.jsx)(N.Z,{className:"h-4 w-4"})})}),((null==s?void 0:s.role)==="admin"||e.creator_user_hash===(null==s?void 0:s.id))&&(0,r.jsx)(y.WH,{content:"Delete ".concat(e.token_name),className:"capitalize text-sm text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>{t("cannot delete service account tokens",()=>{z(e),O(!0)})},className:"text-red-600 hover:text-red-800 font-medium inline-flex items-center",children:(0,r.jsx)(T.Z,{className:"h-4 w-4"})})})]})})]},e.token_id))})]})})}),(0,r.jsx)(P.Vq,{open:i,onOpenChange:e=>{u(e),e||(er(null),l(null))},children:(0,r.jsxs)(P.cZ,{className:"sm:max-w-2xl",children:[(0,r.jsxs)(P.fK,{children:[(0,r.jsx)(P.$N,{children:"Create Service Account"}),(0,r.jsx)(P.Be,{children:"Create a new service account with an API token for programmatic access to SkyPilot."})]}),(0,r.jsx)("div",{className:"flex flex-col gap-4 py-4",children:es?(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"p-4 bg-green-50 border border-green-200 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex items-center mb-3",children:[(0,r.jsx)("h4",{className:"text-sm font-medium text-green-900",children:"⚠️ Service account created successfully - save this token now!"}),(0,r.jsx)(y.WH,{content:ee?"Copied!":"Copy token",className:"text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>ef(es),className:"flex items-center text-green-600 hover:text-green-800 transition-colors duration-200 p-1 ml-2",children:ee?(0,r.jsx)(E.Z,{className:"w-4 h-4"}):(0,r.jsx)(L.Z,{className:"w-4 h-4"})})})]}),(0,r.jsx)("p",{className:"text-sm text-green-700 mb-3",children:"This service account token will not be shown again. Please copy and store it securely."}),(0,r.jsx)("div",{className:"bg-white border border-green-300 rounded-md p-3",children:(0,r.jsx)("code",{className:"text-sm text-gray-800 font-mono break-all block",children:es})})]})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Service Account Name"}),(0,r.jsx)("input",{className:"border rounded px-3 py-2 w-full",placeholder:"e.g., ci-pipeline, monitoring-system",value:J.token_name,onChange:e=>K({...J,token_name:e.target.value})})]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Expiration (days)"}),(0,r.jsx)("input",{type:"number",className:"border rounded px-3 py-2 w-full",placeholder:"e.g., 30",min:"0",max:"365",value:J.expires_in_days||"",onChange:e=>K({...J,expires_in_days:e.target.value?parseInt(e.target.value):null})}),(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"Leave empty or enter 0 to never expire. Maximum 365 days."})]})]})}),(0,r.jsx)(P.cN,{children:es?(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:()=>{u(!1),er(null)},children:"Close"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2",onClick:()=>{u(!1),er(null)},disabled:W,children:"Cancel"}),(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:eg,disabled:W||!J.token_name.trim(),children:W?"Creating...":"Create Token"})]})})]})}),(0,r.jsx)(P.Vq,{open:F,onOpenChange:e=>{O(e),e||(z(null),l(null))},children:(0,r.jsxs)(P.cZ,{className:"sm:max-w-md",children:[(0,r.jsxs)(P.fK,{children:[(0,r.jsx)(P.$N,{children:"Delete Service Account Token"}),(0,r.jsxs)(P.Be,{children:['Are you sure you want to delete the service account "',null==M?void 0:M.token_name,'"',(null==M?void 0:M.creator_user_hash)!==(null==s?void 0:s.id)&&(null==s?void 0:s.role)==="admin"?" owned by ".concat(null==M?void 0:M.creator_name):"","? This action cannot be undone and will immediately revoke access for any systems using this token."]})]}),(0,r.jsxs)(P.cN,{children:[(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2",onClick:()=>{O(!1),z(null)},disabled:Q,children:"Cancel"}),(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-red-600 text-white hover:bg-red-700 h-10 px-4 py-2",onClick:eb,disabled:Q,children:Q?"Deleting...":"Delete Token"})]})]})}),(0,r.jsx)(P.Vq,{open:d,onOpenChange:e=>{x(e),e||(b(null),H(""),ea(null),l(null))},children:(0,r.jsxs)(P.cZ,{className:"sm:max-w-2xl",children:[(0,r.jsxs)(P.fK,{children:[(0,r.jsx)(P.$N,{children:"Rotate Service Account Token"}),(0,r.jsxs)(P.Be,{children:['Rotate the service account token "',null==g?void 0:g.token_name,'"',(null==g?void 0:g.creator_user_hash)!==(null==s?void 0:s.id)&&(null==s?void 0:s.role)==="admin"?" owned by ".concat(null==g?void 0:g.creator_name):"",". This will generate a new token value and invalidate the current one."]})]}),(0,r.jsx)("div",{className:"flex flex-col gap-4 py-4",children:en?(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"p-4 bg-green-50 border border-green-200 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex items-center mb-3",children:[(0,r.jsx)("h4",{className:"text-sm font-medium text-green-900",children:"\uD83D\uDD04 Service account token rotated successfully - save this new token now!"}),(0,r.jsx)(y.WH,{content:ee?"Copied!":"Copy token",className:"text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>ef(en),className:"flex items-center text-green-600 hover:text-green-800 transition-colors duration-200 p-1 ml-2",children:ee?(0,r.jsx)(E.Z,{className:"w-4 h-4"}):(0,r.jsx)(L.Z,{className:"w-4 h-4"})})})]}),(0,r.jsx)("p",{className:"text-sm text-green-700 mb-3",children:"This new token replaces the old one. Please copy and store it securely. The old token is now invalid."}),(0,r.jsx)("div",{className:"bg-white border border-green-300 rounded-md p-3",children:(0,r.jsx)("code",{className:"text-sm text-gray-800 font-mono break-all block",children:en})})]})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"New Expiration (days)"}),(0,r.jsx)("input",{type:"number",className:"border rounded px-3 py-2 w-full",placeholder:"Leave empty to preserve current expiration",min:"0",max:"365",value:$,onChange:e=>H(e.target.value)}),(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"Leave empty to preserve current expiration. Enter number of days for new expiration, or enter 0 to set to never expire. Maximum 365 days."})]}),(0,r.jsx)("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:(0,r.jsx)("p",{className:"text-sm text-amber-700",children:"⚠️ Any systems using the current token will need to be updated with the new token."})})]})}),(0,r.jsx)(P.cN,{children:en?(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-green-600 text-white hover:bg-green-700 h-10 px-4 py-2",onClick:()=>{x(!1),b(null),H(""),ea(null)},children:"Close"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2",onClick:()=>{x(!1),b(null),H(""),ea(null)},disabled:j,children:"Cancel"}),(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:ej,disabled:j,children:j?"Rotating...":"Rotate Token"})]})})]})})]})}W.propTypes={refreshInterval:l().number.isRequired,setLoading:l().func.isRequired,refreshDataRef:l().shape({current:l().func}).isRequired,checkPermissionAndAct:l().func.isRequired,roleLoading:l().bool.isRequired,onResetPassword:l().func.isRequired,onDeleteUser:l().func.isRequired,basicAuthEnabled:l().bool,ingressBasicAuthEnabled:l().bool,currentUserRole:l().string,currentUserId:l().string}},12003:function(e,t,s){s.d(t,{j:function(){return l}});var r=s(90512);let n=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,a=r.W,l=(e,t)=>s=>{var r;if((null==t?void 0:t.variants)==null)return a(e,null==s?void 0:s.class,null==s?void 0:s.className);let{variants:l,defaultVariants:o}=t,i=Object.keys(l).map(e=>{let t=null==s?void 0:s[e],r=null==o?void 0:o[e];if(null===t)return null;let a=n(t)||n(r);return l[e][a]}),c=s&&Object.entries(s).reduce((e,t)=>{let[s,r]=t;return void 0===r||(e[s]=r),e},{});return a(e,i,null==t?void 0:null===(r=t.compoundVariants)||void 0===r?void 0:r.reduce((e,t)=>{let{class:s,className:r,...n}=t;return Object.entries(n).every(e=>{let[t,s]=e;return Array.isArray(s)?s.includes({...o,...c}[t]):({...o,...c})[t]===s})?[...e,s,r]:e},[]),null==s?void 0:s.class,null==s?void 0:s.className)}}}]);
|