skypilot-nightly 1.0.0.dev20250625__py3-none-any.whl → 1.0.0.dev20250626__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.
Files changed (84) hide show
  1. sky/__init__.py +2 -2
  2. sky/adaptors/kubernetes.py +1 -6
  3. sky/client/cli/command.py +10 -5
  4. sky/client/sdk.py +91 -15
  5. sky/clouds/ssh.py +36 -0
  6. sky/core.py +20 -0
  7. sky/dashboard/out/404.html +1 -1
  8. sky/dashboard/out/_next/static/bs6UB9V4Jq10TIZ5x-kBK/_buildManifest.js +1 -0
  9. sky/dashboard/out/_next/static/chunks/141-fa5a20cbf401b351.js +11 -0
  10. sky/dashboard/out/_next/static/chunks/25.76c246239df93d50.js +6 -0
  11. sky/dashboard/out/_next/static/chunks/43-36177d00f6956ab2.js +1 -0
  12. sky/dashboard/out/_next/static/chunks/430.ed51037d1a4a438b.js +1 -0
  13. sky/dashboard/out/_next/static/chunks/690.55f9eed3be903f56.js +16 -0
  14. sky/dashboard/out/_next/static/chunks/785.dc2686c3c1235554.js +1 -0
  15. sky/dashboard/out/_next/static/chunks/871-3db673be3ee3750b.js +6 -0
  16. sky/dashboard/out/_next/static/chunks/875.52c962183328b3f2.js +25 -0
  17. sky/dashboard/out/_next/static/chunks/973-81b2d057178adb76.js +1 -0
  18. sky/dashboard/out/_next/static/chunks/982.1b61658204416b0f.js +1 -0
  19. sky/dashboard/out/_next/static/chunks/984.e8bac186a24e5178.js +1 -0
  20. sky/dashboard/out/_next/static/chunks/990-0ad5ea1699e03ee8.js +1 -0
  21. sky/dashboard/out/_next/static/chunks/pages/clusters/{[cluster]-32ce4f49f2261f55.js → [cluster]-8040f2483897ed0c.js} +1 -1
  22. sky/dashboard/out/_next/static/chunks/pages/clusters-f119a5630a1efd61.js +1 -0
  23. sky/dashboard/out/_next/static/chunks/pages/config-6b255eae088da6a3.js +1 -0
  24. sky/dashboard/out/_next/static/chunks/pages/infra/[context]-b302aea4d65766bf.js +1 -0
  25. sky/dashboard/out/_next/static/chunks/pages/infra-ee8cc4d449945d19.js +1 -0
  26. sky/dashboard/out/_next/static/chunks/pages/{jobs-26da173e20af16e4.js → jobs-0a5695ff3075d94a.js} +1 -1
  27. sky/dashboard/out/_next/static/chunks/pages/{users-ce29e7420385563d.js → users-4978cbb093e141e7.js} +1 -1
  28. sky/dashboard/out/_next/static/chunks/pages/workspace/new-5b59bce9eb208d84.js +1 -0
  29. sky/dashboard/out/_next/static/chunks/pages/workspaces/[name]-cb7e720b739de53a.js +1 -0
  30. sky/dashboard/out/_next/static/chunks/pages/{workspaces-862b120406461b10.js → workspaces-50e230828730cfb3.js} +1 -1
  31. sky/dashboard/out/_next/static/chunks/webpack-08fdb9e6070127fc.js +1 -0
  32. sky/dashboard/out/_next/static/css/52082cf558ec9705.css +3 -0
  33. sky/dashboard/out/clusters/[cluster]/[job].html +1 -1
  34. sky/dashboard/out/clusters/[cluster].html +1 -1
  35. sky/dashboard/out/clusters.html +1 -1
  36. sky/dashboard/out/config.html +1 -1
  37. sky/dashboard/out/index.html +1 -1
  38. sky/dashboard/out/infra/[context].html +1 -1
  39. sky/dashboard/out/infra.html +1 -1
  40. sky/dashboard/out/jobs/[job].html +1 -1
  41. sky/dashboard/out/jobs.html +1 -1
  42. sky/dashboard/out/users.html +1 -1
  43. sky/dashboard/out/volumes.html +1 -1
  44. sky/dashboard/out/workspace/new.html +1 -1
  45. sky/dashboard/out/workspaces/[name].html +1 -1
  46. sky/dashboard/out/workspaces.html +1 -1
  47. sky/provision/kubernetes/utils.py +18 -2
  48. sky/server/rest.py +3 -2
  49. sky/server/server.py +4 -27
  50. sky/skylet/constants.py +5 -0
  51. sky/skypilot_config.py +3 -0
  52. sky/ssh_node_pools/__init__.py +1 -0
  53. sky/ssh_node_pools/core.py +133 -0
  54. sky/ssh_node_pools/server.py +232 -0
  55. sky/utils/kubernetes/deploy_remote_cluster.py +12 -185
  56. sky/utils/kubernetes/ssh_utils.py +221 -0
  57. {skypilot_nightly-1.0.0.dev20250625.dist-info → skypilot_nightly-1.0.0.dev20250626.dist-info}/METADATA +1 -1
  58. {skypilot_nightly-1.0.0.dev20250625.dist-info → skypilot_nightly-1.0.0.dev20250626.dist-info}/RECORD +64 -59
  59. sky/dashboard/out/_next/static/ZWdSYkqVe3WjnFR8ocqoG/_buildManifest.js +0 -1
  60. sky/dashboard/out/_next/static/chunks/211.692afc57e812ae1a.js +0 -1
  61. sky/dashboard/out/_next/static/chunks/310.2671028c20e892c7.js +0 -16
  62. sky/dashboard/out/_next/static/chunks/37-1f1e94f5a561202a.js +0 -6
  63. sky/dashboard/out/_next/static/chunks/42.bc85e5b1a4debf22.js +0 -6
  64. sky/dashboard/out/_next/static/chunks/443.b2242d0efcdf5f47.js +0 -1
  65. sky/dashboard/out/_next/static/chunks/513.309df9e18a9ff005.js +0 -1
  66. sky/dashboard/out/_next/static/chunks/66-66ae330df2d3c1c7.js +0 -1
  67. sky/dashboard/out/_next/static/chunks/682.00e56a220dd26fe1.js +0 -6
  68. sky/dashboard/out/_next/static/chunks/843-07d25a7e64462fd8.js +0 -11
  69. sky/dashboard/out/_next/static/chunks/856-cdf66268ec878d0c.js +0 -1
  70. sky/dashboard/out/_next/static/chunks/973-5b5019ba333e8d62.js +0 -1
  71. sky/dashboard/out/_next/static/chunks/pages/clusters-4aa031d1f42723d8.js +0 -1
  72. sky/dashboard/out/_next/static/chunks/pages/config-3102d02a188f04b3.js +0 -1
  73. sky/dashboard/out/_next/static/chunks/pages/infra/[context]-6f1e02e31eecb5ce.js +0 -1
  74. sky/dashboard/out/_next/static/chunks/pages/infra-fd5dc8a91bd9169a.js +0 -1
  75. sky/dashboard/out/_next/static/chunks/pages/workspace/new-09ae0f6f972aa871.js +0 -1
  76. sky/dashboard/out/_next/static/chunks/pages/workspaces/[name]-0b4c662a25e4747a.js +0 -1
  77. sky/dashboard/out/_next/static/chunks/webpack-6133dc1e928bd0b5.js +0 -1
  78. sky/dashboard/out/_next/static/css/b23cb0257bf96c51.css +0 -3
  79. /sky/dashboard/out/_next/static/{ZWdSYkqVe3WjnFR8ocqoG → bs6UB9V4Jq10TIZ5x-kBK}/_ssgManifest.js +0 -0
  80. /sky/dashboard/out/_next/static/chunks/pages/{_app-0ef7418d1a3822f3.js → _app-9a3ce3170d2edcec.js} +0 -0
  81. {skypilot_nightly-1.0.0.dev20250625.dist-info → skypilot_nightly-1.0.0.dev20250626.dist-info}/WHEEL +0 -0
  82. {skypilot_nightly-1.0.0.dev20250625.dist-info → skypilot_nightly-1.0.0.dev20250626.dist-info}/entry_points.txt +0 -0
  83. {skypilot_nightly-1.0.0.dev20250625.dist-info → skypilot_nightly-1.0.0.dev20250626.dist-info}/licenses/LICENSE +0 -0
  84. {skypilot_nightly-1.0.0.dev20250625.dist-info → skypilot_nightly-1.0.0.dev20250626.dist-info}/top_level.txt +0 -0
sky/__init__.py CHANGED
@@ -5,7 +5,7 @@ from typing import Optional
5
5
  import urllib.request
6
6
 
7
7
  # Replaced with the current commit when building the wheels.
8
- _SKYPILOT_COMMIT_SHA = 'cc8dbb73a2d26e8c017a788b0bbfc63041c78bae'
8
+ _SKYPILOT_COMMIT_SHA = '512c53be5771c003cd9d94b5b89c23638a5e735e'
9
9
 
10
10
 
11
11
  def _get_git_commit():
@@ -35,7 +35,7 @@ def _get_git_commit():
35
35
 
36
36
 
37
37
  __commit__ = _get_git_commit()
38
- __version__ = '1.0.0.dev20250625'
38
+ __version__ = '1.0.0.dev20250626'
39
39
  __root_dir__ = os.path.dirname(os.path.abspath(__file__))
40
40
 
41
41
 
@@ -133,12 +133,7 @@ def _load_config(context: Optional[str] = None):
133
133
  '\nHint: Kubernetes attempted to query the current-context '
134
134
  'set in kubeconfig. Check if the current-context is valid.')
135
135
  with ux_utils.print_exception_no_traceback():
136
- if is_ssh_node_pool:
137
- # For SSH Node Pool, we don't want to surface k8s errors
138
- # (e.g., missing context) unless debug flag is set.
139
- logging.debug(f'Kubernetes error: {suffix}')
140
- else:
141
- raise ValueError(err_str) from None
136
+ raise ValueError(err_str) from None
142
137
 
143
138
  if context == in_cluster_context_name() or context is None:
144
139
  try:
sky/client/cli/command.py CHANGED
@@ -5404,13 +5404,18 @@ def ssh():
5404
5404
  is_flag=True,
5405
5405
  hidden=True,
5406
5406
  help='Run the command asynchronously.')
5407
- def ssh_up(infra: Optional[str], async_call: bool):
5408
- """Set up a cluster using SSH targets from ~/.sky/ssh_node_pools.yaml.
5407
+ @click.option('--file',
5408
+ '-f',
5409
+ required=False,
5410
+ help='The file containing the SSH targets.')
5411
+ def ssh_up(infra: Optional[str], async_call: bool, file: Optional[str]):
5412
+ """Set up a cluster using SSH targets from a file. If not specified,
5413
+ ~/.sky/ssh_node_pools.yaml will be used.
5409
5414
 
5410
- This command sets up a Kubernetes cluster on the machines specified in
5411
- ~/.sky/ssh_node_pools.yaml and configures SkyPilot to use it.
5415
+ This command sets up a Kubernetes cluster on the machines specified in the
5416
+ config file and configures SkyPilot to use it.
5412
5417
  """
5413
- request_id = sdk.ssh_up(infra=infra)
5418
+ request_id = sdk.ssh_up(infra=infra, file=file)
5414
5419
  if async_call:
5415
5420
  print(f'Request submitted with ID: {request_id}')
5416
5421
  else:
sky/client/sdk.py CHANGED
@@ -55,6 +55,7 @@ from sky.utils import rich_utils
55
55
  from sky.utils import status_lib
56
56
  from sky.utils import subprocess_utils
57
57
  from sky.utils import ux_utils
58
+ from sky.utils.kubernetes import ssh_utils
58
59
 
59
60
  if typing.TYPE_CHECKING:
60
61
  import io
@@ -1512,26 +1513,95 @@ def local_down() -> server_common.RequestId:
1512
1513
  return server_common.get_request_id(response)
1513
1514
 
1514
1515
 
1516
+ def _update_remote_ssh_node_pools(file: str,
1517
+ infra: Optional[str] = None) -> None:
1518
+ """Update the SSH node pools on the remote server.
1519
+
1520
+ This function will also upload the local SSH key to the remote server, and
1521
+ replace the file path to the remote SSH key file path.
1522
+
1523
+ Args:
1524
+ file: The path to the local SSH node pools config file.
1525
+ infra: The name of the cluster configuration in the local SSH node
1526
+ pools config file. If None, all clusters in the file are updated.
1527
+ """
1528
+ file = os.path.expanduser(file)
1529
+ if not os.path.exists(file):
1530
+ with ux_utils.print_exception_no_traceback():
1531
+ raise ValueError(
1532
+ f'SSH Node Pool config file {file} does not exist. '
1533
+ 'Please check if the file exists and the path is correct.')
1534
+ config = ssh_utils.load_ssh_targets(file)
1535
+ config = ssh_utils.get_cluster_config(config, infra)
1536
+ pools_config = {}
1537
+ for name, pool_config in config.items():
1538
+ hosts_info = ssh_utils.prepare_hosts_info(
1539
+ name, pool_config, upload_ssh_key_func=_upload_ssh_key_and_wait)
1540
+ pools_config[name] = {'hosts': hosts_info}
1541
+ rest.post(f'{server_common.get_server_url()}/ssh_node_pools',
1542
+ json=pools_config,
1543
+ cookies=server_common.get_api_cookie_jar())
1544
+
1545
+
1546
+ def _upload_ssh_key_and_wait(key_name: str, key_file_path: str) -> str:
1547
+ """Upload the SSH key to the remote server and wait for the key to be
1548
+ uploaded.
1549
+
1550
+ Args:
1551
+ key_name: The name of the SSH key.
1552
+ key_file_path: The path to the local SSH key file.
1553
+
1554
+ Returns:
1555
+ The path for the remote SSH key file on the API server.
1556
+ """
1557
+ if not os.path.exists(os.path.expanduser(key_file_path)):
1558
+ with ux_utils.print_exception_no_traceback():
1559
+ raise ValueError(f'SSH key file not found: {key_file_path}')
1560
+
1561
+ with open(os.path.expanduser(key_file_path), 'rb') as key_file:
1562
+ response = rest.post(
1563
+ f'{server_common.get_server_url()}/ssh_node_pools/keys',
1564
+ files={
1565
+ 'key_file': (key_name, key_file, 'application/octet-stream')
1566
+ },
1567
+ data={'key_name': key_name},
1568
+ cookies=server_common.get_api_cookie_jar())
1569
+
1570
+ return response.json()['key_path']
1571
+
1572
+
1515
1573
  @usage_lib.entrypoint
1516
1574
  @server_common.check_server_healthy_or_start
1517
1575
  @annotations.client_api
1518
- def ssh_up(infra: Optional[str] = None) -> server_common.RequestId:
1576
+ def ssh_up(infra: Optional[str] = None,
1577
+ file: Optional[str] = None) -> server_common.RequestId:
1519
1578
  """Deploys the SSH Node Pools defined in ~/.sky/ssh_targets.yaml.
1520
1579
 
1521
1580
  Args:
1522
1581
  infra: Name of the cluster configuration in ssh_targets.yaml.
1523
1582
  If None, the first cluster in the file is used.
1583
+ file: Name of the ssh node pool configuration file to use. If
1584
+ None, the default path, ~/.sky/ssh_node_pools.yaml is used.
1524
1585
 
1525
1586
  Returns:
1526
1587
  request_id: The request ID of the SSH cluster deployment request.
1527
1588
  """
1528
- body = payloads.SSHUpBody(
1529
- infra=infra,
1530
- cleanup=False,
1531
- )
1532
- response = rest.post(f'{server_common.get_server_url()}/ssh_up',
1533
- json=json.loads(body.model_dump_json()),
1534
- cookies=server_common.get_api_cookie_jar())
1589
+ if file is not None:
1590
+ _update_remote_ssh_node_pools(file, infra)
1591
+
1592
+ # Use SSH node pools router endpoint
1593
+ body = payloads.SSHUpBody(infra=infra, cleanup=False)
1594
+ if infra is not None:
1595
+ # Call the specific pool deployment endpoint
1596
+ response = rest.post(
1597
+ f'{server_common.get_server_url()}/ssh_node_pools/{infra}/deploy',
1598
+ cookies=server_common.get_api_cookie_jar())
1599
+ else:
1600
+ # Call the general deployment endpoint
1601
+ response = rest.post(
1602
+ f'{server_common.get_server_url()}/ssh_node_pools/deploy',
1603
+ json=json.loads(body.model_dump_json()),
1604
+ cookies=server_common.get_api_cookie_jar())
1535
1605
  return server_common.get_request_id(response)
1536
1606
 
1537
1607
 
@@ -1548,13 +1618,19 @@ def ssh_down(infra: Optional[str] = None) -> server_common.RequestId:
1548
1618
  Returns:
1549
1619
  request_id: The request ID of the SSH cluster teardown request.
1550
1620
  """
1551
- body = payloads.SSHUpBody(
1552
- infra=infra,
1553
- cleanup=True,
1554
- )
1555
- response = rest.post(f'{server_common.get_server_url()}/ssh_down',
1556
- json=json.loads(body.model_dump_json()),
1557
- cookies=server_common.get_api_cookie_jar())
1621
+ # Use SSH node pools router endpoint
1622
+ body = payloads.SSHUpBody(infra=infra, cleanup=True)
1623
+ if infra is not None:
1624
+ # Call the specific pool down endpoint
1625
+ response = rest.post(
1626
+ f'{server_common.get_server_url()}/ssh_node_pools/{infra}/down',
1627
+ cookies=server_common.get_api_cookie_jar())
1628
+ else:
1629
+ # Call the general down endpoint
1630
+ response = rest.post(
1631
+ f'{server_common.get_server_url()}/ssh_node_pools/down',
1632
+ json=json.loads(body.model_dump_json()),
1633
+ cookies=server_common.get_api_cookie_jar())
1558
1634
  return server_common.get_request_id(response)
1559
1635
 
1560
1636
 
sky/clouds/ssh.py CHANGED
@@ -211,6 +211,42 @@ class SSH(kubernetes.Kubernetes):
211
211
 
212
212
  return success, ctx2text
213
213
 
214
+ @classmethod
215
+ def check_single_context(cls, context: str) -> Tuple[bool, str]:
216
+ """Checks if the context is valid and accessible."""
217
+ reasons = kubernetes_utils.check_port_forward_mode_dependencies(False)
218
+ if reasons is not None:
219
+ formatted = '\n'.join(
220
+ [reasons[0]] +
221
+ [f'{cls._INDENT_PREFIX}' + r for r in reasons[1:]])
222
+ return (False, formatted)
223
+
224
+ # Add ssh- prefix to the context
225
+ if not context.startswith('ssh-'):
226
+ context = f'ssh-{context}'
227
+
228
+ # Get SSH contexts
229
+ try:
230
+ existing_allowed_contexts = cls.existing_allowed_contexts()
231
+ except Exception as e: # pylint: disable=broad-except
232
+ return (False, f'Failed to get SSH contexts: {str(e)}')
233
+
234
+ if not existing_allowed_contexts:
235
+ return (False,
236
+ 'No SSH Node Pools are up. Run `sky ssh up` to set up '
237
+ f'Node Pools from {SSH_NODE_POOLS_PATH}.')
238
+
239
+ if context not in existing_allowed_contexts:
240
+ return (False, f'SSH Node Pool {context} is not set up. '
241
+ f'Run `sky ssh up --infra {context}` to set up.')
242
+
243
+ # Check if the context is valid
244
+ suc, text = super()._check_single_context(context)
245
+ if not suc:
246
+ return (False, text)
247
+
248
+ return (True, 'SSH Node Pool is set up.')
249
+
214
250
  @classmethod
215
251
  def expand_infras(cls) -> List[str]:
216
252
  return [
sky/core.py CHANGED
@@ -1307,6 +1307,26 @@ def ssh_up(infra: Optional[str] = None, cleanup: bool = False) -> None:
1307
1307
  )
1308
1308
 
1309
1309
 
1310
+ @usage_lib.entrypoint
1311
+ def ssh_status(context_name: str) -> Tuple[bool, str]:
1312
+ """Check the status of an SSH Node Pool context.
1313
+
1314
+ Args:
1315
+ context_name: The SSH context name (e.g., 'ssh-my-cluster')
1316
+
1317
+ Returns:
1318
+ Tuple[bool, str]: (is_ready, reason)
1319
+ - is_ready: True if the SSH Node Pool is ready, False otherwise
1320
+ - reason: Explanation of the status
1321
+ """
1322
+ try:
1323
+ is_ready, reason = clouds.SSH.check_single_context(context_name)
1324
+ return is_ready, reason
1325
+ except Exception as e: # pylint: disable=broad-except
1326
+ return False, ('Failed to check SSH context: '
1327
+ f'{common_utils.format_exception(e)}')
1328
+
1329
+
1310
1330
  def get_all_contexts() -> List[str]:
1311
1331
  """Get all available contexts from Kubernetes and SSH clouds.
1312
1332
 
@@ -1 +1 @@
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/b23cb0257bf96c51.css" as="style"/><link rel="stylesheet" href="/dashboard/_next/static/css/b23cb0257bf96c51.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-6133dc1e928bd0b5.js" defer=""></script><script src="/dashboard/_next/static/chunks/framework-87d061ee6ed71b28.js" defer=""></script><script src="/dashboard/_next/static/chunks/main-e0e2335212e72357.js" defer=""></script><script src="/dashboard/_next/static/chunks/pages/_app-0ef7418d1a3822f3.js" defer=""></script><script src="/dashboard/_next/static/chunks/pages/_error-1be831200e60c5c0.js" defer=""></script><script src="/dashboard/_next/static/ZWdSYkqVe3WjnFR8ocqoG/_buildManifest.js" defer=""></script><script src="/dashboard/_next/static/ZWdSYkqVe3WjnFR8ocqoG/_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":"ZWdSYkqVe3WjnFR8ocqoG","assetPrefix":"/dashboard","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
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/52082cf558ec9705.css" as="style"/><link rel="stylesheet" href="/dashboard/_next/static/css/52082cf558ec9705.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-08fdb9e6070127fc.js" defer=""></script><script src="/dashboard/_next/static/chunks/framework-87d061ee6ed71b28.js" defer=""></script><script src="/dashboard/_next/static/chunks/main-e0e2335212e72357.js" defer=""></script><script src="/dashboard/_next/static/chunks/pages/_app-9a3ce3170d2edcec.js" defer=""></script><script src="/dashboard/_next/static/chunks/pages/_error-1be831200e60c5c0.js" defer=""></script><script src="/dashboard/_next/static/bs6UB9V4Jq10TIZ5x-kBK/_buildManifest.js" defer=""></script><script src="/dashboard/_next/static/bs6UB9V4Jq10TIZ5x-kBK/_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":"bs6UB9V4Jq10TIZ5x-kBK","assetPrefix":"/dashboard","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
@@ -0,0 +1 @@
1
+ self.__BUILD_MANIFEST=function(s,c,e,a,t,u,n,r,b,i,j,k,f,o){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/":["static/chunks/pages/index-6b0d9e5031b70c58.js"],"/_error":["static/chunks/pages/_error-1be831200e60c5c0.js"],"/clusters":["static/chunks/pages/clusters-f119a5630a1efd61.js"],"/clusters/[cluster]":[s,c,e,a,t,r,i,u,n,j,b,k,f,o,"static/chunks/871-3db673be3ee3750b.js","static/chunks/pages/clusters/[cluster]-8040f2483897ed0c.js"],"/clusters/[cluster]/[job]":[s,c,e,a,t,u,n,"static/chunks/pages/clusters/[cluster]/[job]-aff040d7bc5d0086.js"],"/config":["static/chunks/pages/config-6b255eae088da6a3.js"],"/infra":["static/chunks/pages/infra-ee8cc4d449945d19.js"],"/infra/[context]":["static/chunks/pages/infra/[context]-b302aea4d65766bf.js"],"/jobs":["static/chunks/pages/jobs-0a5695ff3075d94a.js"],"/jobs/[job]":[s,c,e,a,t,r,u,n,b,"static/chunks/pages/jobs/[job]-e4b23128db0774cd.js"],"/users":["static/chunks/pages/users-4978cbb093e141e7.js"],"/volumes":["static/chunks/pages/volumes-476b670ef33d1ecd.js"],"/workspace/new":["static/chunks/pages/workspace/new-5b59bce9eb208d84.js"],"/workspaces":["static/chunks/pages/workspaces-50e230828730cfb3.js"],"/workspaces/[name]":[s,c,e,a,t,r,i,u,n,j,b,k,f,o,"static/chunks/141-fa5a20cbf401b351.js","static/chunks/pages/workspaces/[name]-cb7e720b739de53a.js"],sortedPages:["/","/_app","/_error","/clusters","/clusters/[cluster]","/clusters/[cluster]/[job]","/config","/infra","/infra/[context]","/jobs","/jobs/[job]","/users","/volumes","/workspace/new","/workspaces","/workspaces/[name]"]}}("static/chunks/616-d6128fa9e7cae6e6.js","static/chunks/230-d6e363362017ff3a.js","static/chunks/799-3625946b2ec2eb30.js","static/chunks/664-047bc03493fda379.js","static/chunks/804-4c9fc53aa74bc191.js","static/chunks/989-db34c16ad7ea6155.js","static/chunks/470-92dd1614396389be.js","static/chunks/798-c0525dc3f21e488d.js","static/chunks/969-d3a0b53f728d280a.js","static/chunks/947-6620842ef80ae879.js","static/chunks/990-0ad5ea1699e03ee8.js","static/chunks/43-36177d00f6956ab2.js","static/chunks/973-81b2d057178adb76.js","static/chunks/938-068520cc11738deb.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
@@ -0,0 +1,11 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[141],{9333:function(e,s,l){l.d(s,{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,l(998).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"}]])},8418:function(e,s,l){l.d(s,{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,l(998).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,l){l.d(s,{X:function(){return n}});var r=l(5893),a=l(7294);let t=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:l="Error",onDismiss:n}=e,[c,i]=(0,a.useState)(!1);if((0,a.useEffect)(()=>{s&&i(!1)},[s]),!s||c)return null;let o="string"==typeof s?s:t(s);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:[l,":"]})," ",o]})})]}),(0,r.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,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"})})})]})})}},9123:function(e,s,l){l.d(s,{g:function(){return n}});var r=l(5893),a=l(7294),t=l(2350);let n=a.forwardRef((e,s)=>{let{className:l,...a}=e;return(0,r.jsx)("textarea",{className:(0,t.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",l),ref:s,...a})});n.displayName="Textarea"},1141:function(e,s,l){l.r(s),l.d(s,{WorkspaceEditor:function(){return R}});var r=l(5893),a=l(7294),t=l(1163),n=l(7324),c=l(3266),i=l(8969);l(9470);var o=l(1664),d=l.n(o),u=l(9008),x=l.n(u),m=l(7673),h=l(803),f=l(9123),g=l(8799),p=l(282),b=l(6021),j=l(3626),y=l(8418),N=l(9333),v=l(326);let w=e=>{let{className:s="",variant:l="default",children:a,...t}=e;return(0,r.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"}[l]," ").concat(s),...t,children:a})},k=e=>{let{className:s="",children:l,...a}=e;return(0,r.jsx)("div",{className:"text-sm leading-relaxed ".concat(s),...a,children:l})};var C=l(3850),L=l(1812),S=l(938),E=l(1272),M=l(3225),D=l(3081);let Z=e=>{let{message:s}=e;return s?(0,r.jsxs)(w,{className:"border-green-200 bg-green-50",children:[(0,r.jsx)(p.Z,{className:"h-4 w-4 text-green-600"}),(0,r.jsx)(k,{className:"text-green-800",children:s})]}):null},A=e=>{let{workspaceName:s,config:l,enabledClouds:a=[]}=e;if(!l)return null;let t="default"===s,n=0===Object.keys(l).length;if(t&&n)return(0,r.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(a.map(e=>e.toLowerCase()));Object.entries(l).forEach(e=>{let[s,l]=e;if("private"===s||"allowed_users"===s)return;let a=M.MN[s.toLowerCase()]||s.toUpperCase(),t=d.has(null==a?void 0:a.toLowerCase());if((null==l?void 0:l.disabled)===!0)i.push(a);else if(l&&Object.keys(l).length>0){let e="";"gcp"===s.toLowerCase()&&l.project_id?e=" (Project ID: ".concat(l.project_id,")"):"aws"===s.toLowerCase()&&l.region&&(e=" (Region: ".concat(l.region,")")),t?c.push((0,r.jsxs)("span",{className:"block",children:[a,e," is enabled."]},"".concat(s,"-enabled"))):o.push((0,r.jsxs)("span",{className:"block text-amber-700",children:[a,e," is configured but not currently available."]},"".concat(s,"-configured-not-enabled")))}else t?c.push((0,r.jsxs)("span",{className:"block",children:[a," is enabled (using default settings)."]},"".concat(s,"-default-enabled"))):o.push((0,r.jsxs)("span",{className:"block text-amber-700",children:[a," 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,r.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,r.jsx)("div",{className:"text-sm text-gray-700 mb-3 p-3 bg-sky-50 rounded border border-sky-200",children:u}):!t&&n?(0,r.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},W=e=>{let{isPrivate:s}=e;return s?(0,r.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-amber-100 text-amber-800 border border-amber-300",children:"Private"}):(0,r.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-green-100 text-green-800 border border-green-300",children:"Public"})},P=e=>{let{workspaceConfig:s,allUsers:l}=e;if(!s.private)return null;let a=s.allowed_users||[],t=(l||[]).filter(e=>"admin"===e.role).map(e=>e.username),n=[...new Set([...a,...t])];return 0===n.length?(0,r.jsxs)("div",{className:"mt-4",children:[(0,r.jsx)("h4",{className:"mb-2 text-xs text-gray-500 tracking-wider",children:"Allowed Users (0)"}),(0,r.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,r.jsxs)("div",{className:"mt-4",children:[(0,r.jsxs)("h4",{className:"mb-2 text-xs text-gray-500 tracking-wider",children:["Allowed Users (",n.length,")"]}),(0,r.jsx)("div",{className:"space-y-1 max-h-48 overflow-y-auto border border-gray-200 rounded",children:n.map(e=>{let s=t.includes(e);return(0,r.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,r.jsx)("span",{className:"font-medium text-gray-700",children:e}),s?(0,r.jsxs)("span",{className:"inline-flex items-center text-blue-600",children:[(0,r.jsx)(C.r7,{className:"w-3 h-3 mr-1"}),"Admin"]}):(0,r.jsxs)("span",{className:"inline-flex items-center text-gray-600",children:[(0,r.jsx)(b.Z,{className:"w-3 h-3 mr-1"}),"User"]})]},e)})})]})};function R(e){let{workspaceName:s,isNewWorkspace:l=!1}=e,o=(0,t.useRouter)(),[u,p]=(0,a.useState)({}),[b,w]=(0,a.useState)({}),[k,M]=(0,a.useState)(""),[R,_]=(0,a.useState)(!0),[z,O]=(0,a.useState)(!1),[T,U]=(0,a.useState)(!1),[Y,J]=(0,a.useState)(null),[I,V]=(0,a.useState)(null),[F,H]=(0,a.useState)(null),[X,B]=(0,a.useState)([]),[G,q]=(0,a.useState)({showDialog:!1,deleting:!1,error:null}),[K,Q]=(0,a.useState)({totalClusterCount:0,runningClusterCount:0,managedJobsCount:0,clouds:[]}),[$,ee]=(0,a.useState)(!1),es=(0,a.useCallback)(async()=>{_(!0),J(null);try{let e;let[l,r]=await Promise.all([(0,n.fX)(),(0,D.R)()]),a=l[s]||{};p(a),w(a),B(r||[]),e=0===Object.keys(a).length?"".concat(s,":\n # Empty workspace configuration - uses all accessible infrastructure\n"):E.ZP.dump({[s]:a},{indent:2,lineWidth:-1,noRefs:!0,skipInvalid:!0,flowLevel:-1}),M(e)}catch(e){console.error("Error fetching workspace config:",e),J(e)}finally{_(!1)}},[s]),el=(0,a.useCallback)(async()=>{if(!l){ee(!0);try{let[e,l,r]=await Promise.all([(0,c.getClusters)(),(0,i.getManagedJobs)(),(0,n.yz)(s,!0)]),a=e.filter(e=>(e.workspace||"default")===s),t=a.filter(e=>"RUNNING"===e.status||"LAUNCHING"===e.status),o={};e.forEach(e=>{o[e.cluster]=e.workspace||"default"});let d=l.jobs||[],u=new Set(S.statusGroups.active),x=0;d.forEach(e=>{let l=e.cluster_name||e.resources&&e.resources.cluster_name;l&&o[l]===s&&u.has(e.status)&&x++}),Q({totalClusterCount:a.length,runningClusterCount:t.length,managedJobsCount:x,clouds:Array.isArray(r)?r:[]})}catch(e){console.error("Failed to fetch workspace stats:",e)}finally{ee(!1)}}},[s,l]);(0,a.useEffect)(()=>{l?(_(!1),M("".concat(s,":\n # New workspace configuration\n # Leave empty to use all accessible infrastructure\n"))):(es(),el())},[s,l,es,el]),(0,a.useEffect)(()=>{U(JSON.stringify(u)!==JSON.stringify(b))},[u,b]);let er=e=>{M(e),H(null);try{let l=E.ZP.load(e)||{},r=Object.keys(l);if(0===r.length)p({});else if(1===r.length){let e=r[0];if(e!==s){H('Workspace name cannot be changed. Expected "'.concat(s,'" but found "').concat(e,'".'));return}let a=l[s]||{};p(a)}else H("Configuration must contain only one workspace. Found: ".concat(r.join(", ")))}catch(e){H("Invalid YAML: ".concat(e.message))}},ea=async()=>{O(!0),J(null),V(null);try{if(F)throw Error("Please fix YAML errors before saving");let e=E.ZP.load(k)||{},r=Object.keys(e);if(r.length>0&&r[0]!==s)throw Error('Workspace name cannot be changed. Expected "'.concat(s,'".'));l?(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!"),w(u),el())}catch(e){console.error("Error saving workspace:",e),J(e)}finally{O(!1)}},et=async()=>{q(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),q(s=>({...s,deleting:!1,error:e}))}},en=()=>{q({showDialog:!1,deleting:!1,error:null})},ec=async()=>{await Promise.all([es(),el()])};if(!o.isReady)return(0,r.jsx)("div",{children:"Loading..."});let ei=l?"Create New Workspace | SkyPilot Dashboard":"Workspace: ".concat(s," | SkyPilot Dashboard");return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(x(),{children:(0,r.jsx)("title",{children:ei})}),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4 h-5",children:[(0,r.jsxs)("div",{className:"text-base flex items-center",children:[(0,r.jsx)(d(),{href:"/workspaces",className:"text-sky-blue hover:underline",children:"Workspaces"}),(0,r.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,r.jsx)(d(),{href:l?"/workspace/new":"/workspaces/".concat(s),className:"text-sky-blue hover:underline",children:l?"New Workspace":s}),T&&(0,r.jsx)("span",{className:"ml-3 px-2 py-1 bg-yellow-100 text-yellow-800 text-xs rounded",children:"Unsaved changes"})]}),(0,r.jsxs)("div",{className:"text-sm flex items-center",children:[(R||z||$)&&(0,r.jsxs)("div",{className:"flex items-center mr-4",children:[(0,r.jsx)(g.Z,{size:15,className:"mt-0"}),(0,r.jsx)("span",{className:"ml-2 text-gray-500",children:z?"Saving...":"Loading..."})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-4",children:[!l&&(0,r.jsxs)("button",{onClick:ec,disabled:R||z||$,className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center",children:[(0,r.jsx)(j.Z,{className:"w-4 h-4 mr-1.5"}),"Refresh"]}),!l&&"default"!==s&&(0,r.jsxs)("button",{onClick:()=>q({...G,showDialog:!0}),disabled:G.deleting||z,className:"text-red-600 hover:text-red-700 font-medium inline-flex items-center",children:[(0,r.jsx)(y.Z,{className:"w-4 h-4 mr-1.5"}),"Delete"]})]})]})]}),R?(0,r.jsxs)("div",{className:"flex justify-center items-center py-12",children:[(0,r.jsx)(g.Z,{size:24,className:"mr-2"}),(0,r.jsx)("span",{className:"text-gray-500",children:"Loading workspace configuration..."})]}):(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)(L.X,{error:Y,title:"Error",onDismiss:()=>J(null)}),(0,r.jsx)(Z,{message:I}),(0,r.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[!l&&(0,r.jsx)("div",{className:"lg:col-span-1",children:(0,r.jsxs)(m.Zb,{className:"h-full",children:[(0,r.jsx)(m.Ol,{children:(0,r.jsx)(m.ll,{className:"text-base font-normal",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"font-semibold",children:"Workspace:"})," ",s]}),(0,r.jsx)(W,{isPrivate:!0===b.private})]})})}),(0,r.jsxs)(m.aY,{className:"text-sm pb-2 flex-1",children:[(0,r.jsxs)("div",{className:"py-2 flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center text-gray-600",children:[(0,r.jsx)(C.QT,{className:"w-4 h-4 mr-2 text-gray-500"}),(0,r.jsx)("span",{children:"Clusters (Running / Total)"})]}),(0,r.jsx)("span",{className:"font-normal text-gray-800",children:$?"...":"".concat(K.runningClusterCount," / ").concat(K.totalClusterCount)})]}),(0,r.jsxs)("div",{className:"py-2 flex items-center justify-between border-t border-gray-100",children:[(0,r.jsxs)("div",{className:"flex items-center text-gray-600",children:[(0,r.jsx)(C.Vp,{className:"w-4 h-4 mr-2 text-gray-500"}),(0,r.jsx)("span",{children:"Managed Jobs"})]}),(0,r.jsx)("span",{className:"font-normal text-gray-800",children:$?"...":K.managedJobsCount})]})]}),(0,r.jsxs)("div",{className:"px-6 pb-6 text-sm pt-3",children:[(0,r.jsx)("h4",{className:"mb-2 text-xs text-gray-500 tracking-wider",children:"Enabled Infra"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-x-4 gap-y-1",children:$?(0,r.jsx)("span",{className:"text-gray-500",children:"Loading..."}):K.clouds.length>0?K.clouds.map(e=>(0,r.jsxs)("div",{className:"flex items-center text-gray-700",children:[(0,r.jsx)(C.Ye,{className:"w-3.5 h-3.5 mr-1.5 text-green-500"}),(0,r.jsx)("span",{children:e})]},e)):(0,r.jsx)("span",{className:"text-gray-500 italic",children:"No enabled infrastructure"})}),(0,r.jsx)("div",{className:"mt-4",children:(0,r.jsx)(A,{workspaceName:s,config:b,enabledClouds:K.clouds})}),(0,r.jsx)(P,{workspaceConfig:b,allUsers:X})]})]})}),(0,r.jsx)("div",{className:l?"lg:col-span-3":"lg:col-span-2",children:(0,r.jsxs)(m.Zb,{className:"h-full flex flex-col",children:[(0,r.jsx)(m.Ol,{children:(0,r.jsx)(m.ll,{className:"text-base font-normal",children:l?"New Workspace YAML":"Edit Workspace YAML"})}),(0,r.jsx)(m.aY,{className:"flex-1 flex flex-col",children:(0,r.jsxs)("div",{className:"space-y-4 flex-1 flex flex-col",children:[F&&(0,r.jsx)(L.X,{error:F,onDismiss:()=>H(null)}),(0,r.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,r.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,r.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,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsx)("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Example configuration:"}),(0,r.jsx)("div",{className:"p-3 bg-gray-50 border rounded-lg",children:(0,r.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,r.jsx)(f.g,{value:k,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,r.jsx)("div",{className:"flex justify-end space-x-3 pt-3 border-gray-200",children:(0,r.jsxs)(h.z,{onClick:ea,disabled:z||F||R,className:"inline-flex items-center bg-blue-600 hover:bg-blue-700 text-white",children:[(0,r.jsx)(N.Z,{className:"w-4 h-4 mr-1.5"}),z?"Applying...":"Apply"]})})]})]})})]})})]})]}),(0,r.jsx)(v.Vq,{open:G.showDialog,onOpenChange:en,children:(0,r.jsxs)(v.cZ,{className:"sm:max-w-md",children:[(0,r.jsxs)(v.fK,{className:"",children:[(0,r.jsx)(v.$N,{children:"Delete Workspace"}),(0,r.jsxs)(v.Be,{children:['Are you sure you want to delete workspace "',s,'"? This action cannot be undone.']})]}),G.error&&(0,r.jsx)(L.X,{error:G.error,title:"Deletion Failed",onDismiss:()=>q(e=>({...e,error:null}))}),(0,r.jsxs)(v.cN,{className:"",children:[(0,r.jsx)(h.z,{variant:"outline",onClick:en,disabled:G.deleting,children:"Cancel"}),(0,r.jsx)(h.z,{variant:"destructive",onClick:et,disabled:G.deleting,children:G.deleting?"Deleting...":"Delete"})]})]})})]})]})}}}]);
@@ -0,0 +1,6 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[25,430],{9333:function(e,n,r){"use strict";r.d(n,{Z:function(){return t}});/**
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 t=(0,r(998).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"}]])},4042:function(e,n,r){"use strict";r.r(n),r.d(n,{Config:function(){return g}});var t=r(5893),s=r(7294),l=r(1163),a=r(803),i=r(7673),o=r(7324),c=r(1812),u=r(8799),d=r(9333),m=r(1272),f=r(6989),x=r(7145);function h(){let[e,n]=(0,s.useState)(null),[r,l]=(0,s.useState)(null),a=async()=>{let e=await x.x.get("/api/health"),r=await e.json();r.version&&n(r.version),r.commit&&l(r.commit)};return((0,s.useEffect)(()=>{a()},[]),e)?(0,t.jsx)(f.Md,{content:r?"Commit: ".concat(r):"Commit information not available",className:"text-sm text-muted-foreground",children:(0,t.jsxs)("div",{className:"text-sm text-gray-500 cursor-help border-b border-dotted border-gray-400 inline-block",children:["Version: ",e]})}):null}var v=r(7853);function g(){let e=(0,l.useRouter)(),[n,r]=(0,s.useState)(""),[f,g]=(0,s.useState)(!0),[p,j]=(0,s.useState)(!1),[b,y]=(0,s.useState)(null),[w,N]=(0,s.useState)(!1),[k,C]=(0,s.useState)(!1),L=(0,s.useRef)(null);(0,s.useEffect)(()=>{A(),(async()=>{C(await (0,v.TO)())})()},[]),(0,s.useEffect)(()=>()=>{L.current&&clearTimeout(L.current)},[]);let A=async()=>{g(!0),y(null);try{let e=await (0,o.iE)();0===Object.keys(e).length?r(""):r(m.ZP.dump(e,{indent:2}))}catch(e){console.error("Error loading config:",e),y(e)}finally{g(!1)}},S=async()=>{j(!0),y(null),L.current&&(clearTimeout(L.current),L.current=null);try{let e=await x.x.get("/users/role");if(!e.ok){let n=await e.json();throw Error(n.detail||"Failed to get user role")}let r=await e.json(),t=r.role;if("admin"!=t){y(Error("".concat(r.name," is logged in as non-admin and cannot edit config"))),j(!1);return}let s=m.ZP.load(n);if(null==s&&(s={}),"object"!=typeof s||Array.isArray(s)){let e="Invalid config structure: Configuration must be a mapping (key-value pairs) in YAML format.";Array.isArray(s),e="Invalid config structure: Configuration must be a mapping (key-value pairs) in YAML format.",y(Error(e)),j(!1);return}await (0,o.rF)(s),N(!0),L.current=setTimeout(()=>{N(!1),L.current=null},5e3)}catch(e){console.error("Error saving config:",e),y(e)}finally{j(!1)}};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4 h-5",children:[(0,t.jsx)("div",{className:"text-base flex items-center",children:(0,t.jsx)("span",{className:"text-sky-blue",children:"SkyPilot API Server"})}),(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)("div",{className:"text-sm flex items-center",children:(f||p)&&(0,t.jsxs)("div",{className:"flex items-center mr-4",children:[(0,t.jsx)(u.Z,{size:15,className:"mt-0"}),(0,t.jsx)("span",{className:"ml-2 text-gray-500",children:p?"Applying...":"Loading..."})]})}),k&&(0,t.jsxs)("button",{onClick:()=>{let e=(0,v.ki)(),n=window.location.hostname;window.open("".concat(e,"/d/skypilot-apiserver-overview/skypilot-api-server?orgId=1&from=now-1h&to=now&timezone=browser&var-app=").concat(n),"_blank")},className:"inline-flex items-center px-3 py-2 text-sm font-medium text-white bg-sky-blue-bright border border-transparent rounded-md shadow-sm hover:bg-sky-blue focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-sky-blue mr-4",children:[(0,t.jsx)("svg",{className:"w-4 h-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})}),"View API Server Metrics"]}),(0,t.jsx)(h,{})]})]}),(0,t.jsxs)(i.Zb,{className:"w-full",children:[(0,t.jsx)(i.Ol,{children:(0,t.jsx)(i.ll,{className:"text-base font-normal flex items-center justify-between",children:(0,t.jsx)("span",{children:"Edit SkyPilot API Server Configuration"})})}),(0,t.jsxs)(i.aY,{className:"space-y-4",children:[(0,t.jsxs)("p",{className:"text-sm text-gray-600 mb-3",children:["Refer to the"," ",(0,t.jsx)("a",{href:"https://docs.skypilot.co/en/latest/reference/config.html",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline",children:"SkyPilot Docs"})," ","for details. The configuration should be in YAML format."]}),w&&(0,t.jsx)("div",{className:"bg-green-50 border border-green-200 rounded p-4 mb-6",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)("div",{className:"flex-shrink-0",children:(0,t.jsx)("svg",{className:"h-5 w-5 text-green-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.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,t.jsx)("div",{className:"ml-3",children:(0,t.jsx)("p",{className:"text-sm font-medium text-green-800",children:"Configuration saved successfully!"})})]}),(0,t.jsx)("div",{className:"ml-auto pl-3",children:(0,t.jsx)("div",{className:"-mx-1.5 -my-1.5",children:(0,t.jsxs)("button",{type:"button",onClick:()=>{N(!1),L.current&&(clearTimeout(L.current),L.current=null)},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,t.jsx)("span",{className:"sr-only",children:"Dismiss"}),(0,t.jsx)("svg",{className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.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"})})]})})})]})}),b&&(0,t.jsx)("div",{className:"mb-6",children:(0,t.jsx)(c.X,{error:b,title:"Failed to apply new configuration",onDismiss:()=>y(null)})}),(0,t.jsx)("div",{className:"w-full",children:(0,t.jsx)("textarea",{value:n,onChange:e=>r(e.target.value),className:"w-full h-96 p-3 border border-gray-300 rounded font-mono text-sm resize-vertical focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:f?"Loading configuration...":"# Enter SkyPilot configuration in YAML format\n# Example:\n# kubernetes:\n# allowed_contexts: [default, my-context]",disabled:f||p})}),(0,t.jsxs)("div",{className:"flex justify-end space-x-3 pt-3",children:[(0,t.jsx)(a.z,{variant:"outline",onClick:()=>{e.push("/workspaces")},disabled:p,children:"Cancel"}),(0,t.jsx)(a.z,{onClick:S,disabled:f||p,className:"inline-flex items-center bg-blue-600 hover:bg-blue-700 text-white",children:p?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(u.Z,{size:16,className:"mr-2"}),"Applying..."]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(d.Z,{className:"w-4 h-4 mr-1.5"}),"Apply"]})})]})]})]})]})}},1812:function(e,n,r){"use strict";r.d(n,{X:function(){return a}});var t=r(5893),s=r(7294);let l=e=>{if(!(null==e?void 0:e.message))return"An unexpected error occurred.";let n=e.message;return n.includes("failed:")&&(n=n.split("failed:")[1].trim()),n},a=e=>{let{error:n,title:r="Error",onDismiss:a}=e,[i,o]=(0,s.useState)(!1);if((0,s.useEffect)(()=>{n&&o(!1)},[n]),!n||i)return null;let c="string"==typeof n?n:l(n);return(0,t.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-md p-3 mb-4",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex",children:[(0,t.jsx)("div",{className:"flex-shrink-0",children:(0,t.jsx)("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.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,t.jsx)("div",{className:"ml-3",children:(0,t.jsxs)("div",{className:"text-sm text-red-800",children:[(0,t.jsxs)("strong",{children:[r,":"]})," ",c]})})]}),(0,t.jsx)("button",{onClick:()=>{o(!0),a&&a()},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,t.jsx)("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.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"})})})]})})}},7853:function(e,n,r){"use strict";r.d(n,{TO:function(){return l},ki:function(){return a}});let t=null,s=null,l=async()=>null!==t?t:s||(s=(async()=>{try{let e="".concat(window.location.origin,"/grafana"),n=await fetch("".concat(e,"/api/health"),{method:"GET",credentials:"include",headers:{Accept:"application/json"},signal:AbortSignal.timeout(5e3)});return 200==n.status}catch(e){return console.debug("Grafana availability check failed:",e),t=!1,!1}finally{s=null}})()),a=()=>"".concat(window.location.origin,"/grafana")},1163:function(e,n,r){e.exports=r(6036)},2003:function(e,n,r){"use strict";r.d(n,{j:function(){return a}});var t=r(512);let s=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,l=t.W,a=(e,n)=>r=>{var t;if((null==n?void 0:n.variants)==null)return l(e,null==r?void 0:r.class,null==r?void 0:r.className);let{variants:a,defaultVariants:i}=n,o=Object.keys(a).map(e=>{let n=null==r?void 0:r[e],t=null==i?void 0:i[e];if(null===n)return null;let l=s(n)||s(t);return a[e][l]}),c=r&&Object.entries(r).reduce((e,n)=>{let[r,t]=n;return void 0===t||(e[r]=t),e},{});return l(e,o,null==n?void 0:null===(t=n.compoundVariants)||void 0===t?void 0:t.reduce((e,n)=>{let{class:r,className:t,...s}=n;return Object.entries(s).every(e=>{let[n,r]=e;return Array.isArray(r)?r.includes({...i,...c}[n]):({...i,...c})[n]===r})?[...e,r,t]:e},[]),null==r?void 0:r.class,null==r?void 0:r.className)}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[43],{326:function(e,t,a){a.d(t,{$N:function(){return p},Be:function(){return _},Vq:function(){return c},cN:function(){return f},cZ:function(){return d},fK:function(){return g}});var r=a(5893),s=a(7294),o=a(6327),n=a(2350),l=a(3767);let c=o.fC;o.xz;let u=o.h_;o.x8;let i=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.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),...s})});i.displayName=o.aV.displayName;let d=s.forwardRef((e,t)=>{let{className:a,children:s,...c}=e;return(0,r.jsxs)(u,{children:[(0,r.jsx)(i,{}),(0,r.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:[s,(0,r.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,r.jsx)(l.Z,{className:"h-4 w-4"}),(0,r.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})});d.displayName=o.VY.displayName;let g=e=>{let{className:t,...a}=e;return(0,r.jsx)("div",{className:(0,n.cn)("flex flex-col space-y-1.5 text-center sm:text-left",t),...a})};g.displayName="DialogHeader";let f=e=>{let{className:t,...a}=e;return(0,r.jsx)("div",{className:(0,n.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...a})};f.displayName="DialogFooter";let p=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)(o.Dx,{ref:t,className:(0,n.cn)("text-lg font-semibold leading-none tracking-tight",a),...s})});p.displayName=o.Dx.displayName;let _=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)(o.dk,{ref:t,className:(0,n.cn)("text-sm text-gray-500",a),...s})});_.displayName=o.dk.displayName},3266:function(e,t,a){a.d(t,{QL:function(){return g},Sl:function(){return i},getClusters:function(){return c},uR:function(){return u}});var r=a(7294),s=a(5821),o=a(7145),n=a(6378);let l={UP:"RUNNING",STOPPED:"STOPPED",INIT:"LAUNCHING",null:"TERMINATED"};async function c(){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})).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),r=a+(t-3)%2;return 0===a?e.substring(0,r)+"...":e.substring(0,r)+"..."+e.substring(e.length-a)}(t,25)),{status:l[e.status],cluster:e.name,user:e.user_name,user_hash:e.user_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,to_down:e.to_down,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){return console.error("Error fetching clusters:",e),[]}}async function u(){try{let e=await o.x.fetch("/cost_report",{days:30});console.log("Raw cluster history data:",e);let t=e.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?l[e.status]:"TERMINATED",cluster:e.name,user:a,user_hash:e.user_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,to_down:!1,cluster_hash:e.cluster_hash,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:",t),t}catch(e){return console.error("Error fetching cluster history:",e),[]}}async function i(e){let{clusterName:t,jobId:a,onNewLog:r,workspace:n}=e;try{await o.x.stream("/logs",{follow:!1,cluster_name:t,job_id:a,override_skypilot_config:{active_workspace:n||"default"}},r)}catch(e){console.error("Error in streamClusterJobLogs:",e),(0,s.C)("Error in streamClusterJobLogs: ".concat(e.message),"error")}}async function d(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=>{let r=e.end_at?e.end_at:Date.now()/1e3,s=0,o=0;return e.submitted_at&&(s=r-e.submitted_at),e.start_at&&(o=r-e.start_at),{id:e.job_id,status:e.status,job:e.job_name,user:e.username,gpus:e.accelerators||{},submitted_at:e.submitted_at?new Date(1e3*e.submitted_at):null,resources:e.resources,cluster:t,total_duration:s,job_duration:o,infra:"",logs:"",workspace:a||"default"}})}catch(e){return console.error("Error fetching cluster jobs:",e),[]}}function g(e){let{cluster:t,job:a=null}=e,[s,o]=(0,r.useState)(null),[l,u]=(0,r.useState)(null),[i,g]=(0,r.useState)(!0),[f,p]=(0,r.useState)(!0),_=(0,r.useCallback)(async()=>{if(t)try{g(!0);let e=await n.default.get(c,[{clusterNames:[t]}]);return o(e[0]),e[0]}catch(e){console.error("Error fetching cluster data:",e)}finally{g(!1)}return null},[t]),h=(0,r.useCallback)(async e=>{if(t)try{p(!0);let a=await n.default.get(d,[{clusterName:t,workspace:e||"default"}]);u(a)}catch(e){console.error("Error fetching cluster job data:",e)}finally{p(!1)}},[t]),m=(0,r.useCallback)(async()=>{n.default.invalidate(c,[{clusterNames:[t]}]);let e=await _();e&&(n.default.invalidate(d,[{clusterName:t,workspace:e.workspace||"default"}]),await h(e.workspace))},[_,h,t]),b=(0,r.useCallback)(async()=>{s&&(n.default.invalidate(d,[{clusterName:t,workspace:s.workspace||"default"}]),await h(s.workspace))},[h,s,t]);return(0,r.useEffect)(()=>{(async()=>{let e=await _();e&&h(e.workspace)})()},[t,a,_,h]),{clusterData:s,clusterJobData:l,loading:i,clusterDetailsLoading:i,clusterJobsLoading:f,refreshData:m,refreshClusterJobsOnly:b}}},2045:function(e,t,a){a.d(t,{l4:function(){return n}});var r=a(3225),s=a(7145);async function o(e,t){try{let a=[];try{let e=await s.x.get("/enabled_clouds"),t=e.headers.get("X-Skypilot-Request-ID")||e.headers.get("X-Request-ID"),r=await s.x.get("/api/get?request_id=".concat(t)),o=await r.json();a=o.return_value?JSON.parse(o.return_value):[],console.log("Enabled clouds:",a)}catch(e){console.error("Error fetching enabled clouds:",e),a=[]}let o={};r.$m.forEach(e=>{let t=a.includes(e.toLowerCase());o[e]={name:e,clusters:0,jobs:0,enabled:t}}),e.forEach(e=>{if(e.cloud){let t=e.cloud;o[t]&&(o[t].clusters+=1,o[t].enabled=!0)}}),t.forEach(e=>{if(e.cloud){let t=e.cloud;o[t]&&(o[t].jobs+=1,o[t].enabled=!0)}});let n=r.$m.length,l=Object.values(o).filter(e=>e.enabled).length;return{clouds:Object.values(o).filter(e=>e.enabled).sort((e,t)=>t.clusters-e.clusters||t.jobs-e.jobs),totalClouds:n,enabledClouds:l}}catch(e){return console.error("Error fetching cloud infrastructure:",e),{clouds:[],totalClouds:r.$m.length,enabledClouds:0}}}async function n(){let{getClusters:e}=await Promise.resolve().then(a.bind(a,3266)),{getManagedJobs:t}=await Promise.resolve().then(a.bind(a,8969)),r=(await Promise.resolve().then(a.bind(a,6378))).default,[s,n]=await Promise.all([r.get(e),r.get(t,[{allUsers:!0}])]),c=s||[],u=(null==n?void 0:n.jobs)||[],[i,d]=await Promise.all([l(c,u),o(c,u)]);return{gpuData:i,cloudData:d}}async function l(e,t){return await g({clusters:e||[],jobs:t||[]})}async function c(){try{let e=await s.x.post("/realtime_kubernetes_gpu_availability",{context:null,name_filter:null,quantity_filter:null});if(!e.ok)return console.error("Error fetching Kubernetes context GPUs (in getKubernetesContextGPUs): ".concat(e.status," ").concat(e.statusText)),[];let t=e.headers.get("X-Skypilot-Request-ID")||e.headers.get("x-request-id");if(!t)return console.error("No request ID returned for Kubernetes GPU availability (in getKubernetesContextGPUs)"),[];let a=await s.x.get("/api/get?request_id=".concat(t)),r=await a.text();if(500===a.status){try{let e=JSON.parse(r);if(e.detail&&e.detail.error)try{let t=JSON.parse(e.detail.error);console.error("[infra.jsx] getKubernetesContextGPUs: Server error detail:",t.message)}catch(t){console.error("[infra.jsx] getKubernetesContextGPUs: Error parsing server error JSON:",t,"Original error text:",e.detail.error)}}catch(e){console.error("[infra.jsx] getKubernetesContextGPUs: Error parsing 500 error response JSON:",e,"Raw text was:",r)}return[]}let o=JSON.parse(r);return o.return_value?JSON.parse(o.return_value):[]}catch(e){return console.error("[infra.jsx] Outer error in getKubernetesContextGPUs:",e),[]}}async function u(){try{let e=await s.x.get("/all_contexts");if(!e.ok)return console.error("Error fetching all contexts: ".concat(e.status," ").concat(e.statusText)),[];let t=e.headers.get("X-Skypilot-Request-ID")||e.headers.get("x-request-id");if(!t)return console.error("No request ID returned for /all_contexts"),[];let a=await s.x.get("/api/get?request_id=".concat(t)),r=await a.json();return r.return_value?JSON.parse(r.return_value):[]}catch(e){return console.error("[infra.jsx] Error in getAllContexts:",e),[]}}async function i(e){try{let t=await s.x.post("/kubernetes_node_info",{context:e}),a=t.headers.get("X-Skypilot-Request-ID")||t.headers.get("x-request-id"),r=await s.x.get("/api/get?request_id=".concat(a));if(500===r.status){try{let e=await r.json();if(e.detail&&e.detail.error)try{let t=JSON.parse(e.detail.error);console.error("Error fetching Kubernetes per node GPUs:",t.message)}catch(e){console.error("Error parsing JSON:",e)}}catch(e){console.error("Error parsing JSON:",e)}return{}}let o=await r.json();return(o.return_value?JSON.parse(o.return_value):{}).node_info_dict||{}}catch(t){return console.error("[infra.jsx] Error in getKubernetesPerNodeGPUs for context",e,":",t),{}}}async function d(e){try{let t=e.clusters,a=e.jobs,r={};return t.forEach(e=>{let t=null;if("Kubernetes"===e.cloud)(t=e.region)&&(t="kubernetes/".concat(t));else if("SSH"===e.cloud&&(t=e.region)){let e=t.startsWith("ssh-")?t.substring(4):t;t="ssh/".concat(e)}t&&(r[t]||(r[t]={clusters:0,jobs:0}),r[t].clusters+=1)}),a.forEach(e=>{let t=null;if("Kubernetes"===e.cloud)(t=e.region)&&(t="kubernetes/".concat(t));else if("SSH"===e.cloud&&(t=e.region)){let e=t.startsWith("ssh-")?t.substring(4):t;t="ssh/".concat(e)}t&&(r[t]||(r[t]={clusters:0,jobs:0}),r[t].jobs+=1)}),r}catch(e){return console.error("=== Error in getContextClustersAndJobs ===",e),{}}}async function g(e){try{let o=await u();if(!o||0===o.length)return console.log("No contexts found from /all_contexts endpoint."),{allContextNames:[],allGPUs:[],perContextGPUs:[],perNodeGPUs:[],contextStats:{}};let n=await d(e),l=await c(),g=new Map;l&&l.forEach(e=>{g.set(e[0],e[1])});let f={},p={},_={};for(let e of o){p[e]||(p[e]=[]);let o=g.get(e);if(o&&o.length>0)for(let t of o){let a=t[0],r=t[1].join(", "),s=t[2],o=t[3];a in f?(f[a].gpu_total+=s,f[a].gpu_free+=o):f[a]={gpu_total:s,gpu_free:o,gpu_name:a},p[e].push({gpu_name:a,gpu_requestable_qty_per_node:r,gpu_total:s,gpu_free:o,context:e})}let n=await i(e);if(n&&Object.keys(n).length>0)for(let o in n){var t,a,r,s;let l=n[o],c=l.accelerator_type||"-",u=null!==(r=null===(t=l.total)||void 0===t?void 0:t.accelerator_count)&&void 0!==r?r:0,i=null!==(s=null===(a=l.free)||void 0===a?void 0:a.accelerators_available)&&void 0!==s?s:0;_["".concat(e,"/").concat(o)]={node_name:l.name,gpu_name:c,gpu_total:u,gpu_free:i,ip_address:l.ip_address||null,context:e},"-"===c||p[e].some(e=>e.gpu_name===c)||(c in f||(f[c]={gpu_total:0,gpu_free:0,gpu_name:c}),p[e].find(e=>e.gpu_name===c)||p[e].push({gpu_name:c,gpu_requestable_qty_per_node:"-",gpu_total:0,gpu_free:0,context:e}))}0===p[e].length&&n&&Object.keys(n).length}return{allContextNames:o.sort(),allGPUs:Object.values(f).sort((e,t)=>e.gpu_name.localeCompare(t.gpu_name)),perContextGPUs:Object.values(p).flat().sort((e,t)=>e.context.localeCompare(t.context)||e.gpu_name.localeCompare(t.gpu_name)),perNodeGPUs:Object.values(_).sort((e,t)=>e.context.localeCompare(t.context)||e.node_name.localeCompare(t.node_name)||e.gpu_name.localeCompare(t.gpu_name)),contextStats:n}}catch(e){return console.error("[infra.jsx] Outer error in getKubernetesGPUs:",e),{allContextNames:[],allGPUs:[],perContextGPUs:[],perNodeGPUs:[],contextStats:{}}}}},3081:function(e,t,a){a.d(t,{R:function(){return s}}),a(3266),a(8969);var r=a(7145);async function s(){try{let e=await r.x.get("/users");if(!e.ok)throw Error("HTTP error! status: ".concat(e.status));return(await e.json()).map(e=>({userId:e.id,username:e.name,role:e.role}))||[]}catch(e){return console.error("Failed to fetch users:",e),[]}}},6856:function(e,t,a){var r=a(6378),s=a(3266),o=a(8969),n=a(7324),l=a(3081),c=a(2045);let u={base:{getClusters:{fn:s.getClusters,args:[]},getClusterHistory:{fn:s.uR,args:[]},getManagedJobs:{fn:o.getManagedJobs,args:[{allUsers:!0}]},getWorkspaces:{fn:n.fX,args:[]},getUsers:{fn:l.R,args:[]},getInfraData:{fn:c.l4,args:[]}},dynamic:{getEnabledClouds:{fn:n.yz,requiresWorkspaces:!0}},pages:{clusters:["getClusters","getClusterHistory","getWorkspaces","getUsers"],jobs:["getManagedJobs","getClusters","getWorkspaces","getUsers"],infra:["getInfraData","getClusters","getManagedJobs"],workspaces:["getWorkspaces","getClusters","getManagedJobs","getEnabledClouds"],users:["getUsers","getClusters","getManagedJobs"]}};class i{async preloadForPage(e,t){let{backgroundPreload:a=!0,force:r=!1}=t||{};if(!u.pages[e]){console.warn("Unknown page: ".concat(e));return}console.log("[CachePreloader] Preloading cache for page: ".concat(e));try{await this._loadPageData(e,r),a&&this._backgroundPreloadOtherPages(e)}catch(t){console.error("[CachePreloader] Error preloading for page ".concat(e,":"),t)}}async _loadPageData(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a=u.pages[e],s=[];for(let e of a)if(u.base[e]){let{fn:a,args:o}=u.base[e];t&&r.default.invalidate(a,o),s.push(r.default.get(a,o))}else"getEnabledClouds"===e&&s.push(this._loadEnabledCloudsForAllWorkspaces(t));await Promise.allSettled(s),console.log("[CachePreloader] Loaded data for page: ".concat(e))}async _loadEnabledCloudsForAllWorkspaces(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];try{e&&r.default.invalidate(n.fX);let t=await r.default.get(n.fX),a=Object.keys(t||{}).map(t=>(e&&r.default.invalidate(n.yz,[t]),r.default.get(n.yz,[t])));await Promise.allSettled(a)}catch(e){console.error("[CachePreloader] Error loading enabled clouds:",e)}}_backgroundPreloadOtherPages(e){if(this.isPreloading)return;this.isPreloading=!0;let t=Object.keys(u.pages).filter(t=>t!==e);console.log("[CachePreloader] Background preloading pages: ".concat(t.join(", "))),Promise.allSettled(t.map(async e=>{try{await this._loadPageData(e,!1),console.log("[CachePreloader] Background loaded: ".concat(e))}catch(t){console.error("[CachePreloader] Background load failed for ".concat(e,":"),t)}})).then(()=>{this.isPreloading=!1,console.log("[CachePreloader] Background preloading complete")})}async preloadBaseFunctions(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];console.log("[CachePreloader] Preloading all base functions");let t=Object.entries(u.base).map(t=>{let[a,{fn:s,args:o}]=t;return e&&r.default.invalidate(s,o),r.default.get(s,o).catch(e=>{console.error("[CachePreloader] Failed to preload ".concat(a,":"),e)})});await Promise.allSettled(t),console.log("[CachePreloader] Base functions preloaded")}getCacheStats(){return{...r.default.getStats(),isPreloading:this.isPreloading}}clearCache(){r.default.clear(),this.isPreloading=!1,this.preloadPromises.clear(),console.log("[CachePreloader] Cache cleared")}constructor(){this.isPreloading=!1,this.preloadPromises=new Map}}let d=new i;t.ZP=d}}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[430],{1163:function(e,l,n){e.exports=n(6036)},2003:function(e,l,n){"use strict";n.d(l,{j:function(){return s}});var r=n(512);let u=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,t=r.W,s=(e,l)=>n=>{var r;if((null==l?void 0:l.variants)==null)return t(e,null==n?void 0:n.class,null==n?void 0:n.className);let{variants:s,defaultVariants:i}=l,a=Object.keys(s).map(e=>{let l=null==n?void 0:n[e],r=null==i?void 0:i[e];if(null===l)return null;let t=u(l)||u(r);return s[e][t]}),o=n&&Object.entries(n).reduce((e,l)=>{let[n,r]=l;return void 0===r||(e[n]=r),e},{});return t(e,a,null==l?void 0:null===(r=l.compoundVariants)||void 0===r?void 0:r.reduce((e,l)=>{let{class:n,className:r,...u}=l;return Object.entries(u).every(e=>{let[l,n]=e;return Array.isArray(n)?n.includes({...i,...o}[l]):({...i,...o})[l]===n})?[...e,n,r]:e},[]),null==n?void 0:n.class,null==n?void 0:n.className)}}}]);
@@ -0,0 +1,16 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[690],{1812:function(e,s,r){"use strict";r.d(s,{X:function(){return n}});var t=r(5893),a=r(7294);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:r="Error",onDismiss:n}=e,[i,o]=(0,a.useState)(!1);if((0,a.useEffect)(()=>{s&&o(!1)},[s]),!s||i)return null;let c="string"==typeof s?s:l(s);return(0,t.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-md p-3 mb-4",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex",children:[(0,t.jsx)("div",{className:"flex-shrink-0",children:(0,t.jsx)("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.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,t.jsx)("div",{className:"ml-3",children:(0,t.jsxs)("div",{className:"text-sm text-red-800",children:[(0,t.jsxs)("strong",{children:[r,":"]})," ",c]})})]}),(0,t.jsx)("button",{onClick:()=>{o(!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,t.jsx)("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.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"})})})]})})}},8764:function(e,s,r){"use strict";r.d(s,{RM:function(){return o},SC:function(){return c},iA:function(){return n},pj:function(){return u},ss:function(){return d},xD:function(){return i}});var t=r(5893),a=r(7294),l=r(2350);let n=a.forwardRef((e,s)=>{let{className:r,...a}=e;return(0,t.jsx)("div",{className:"relative w-full overflow-auto",children:(0,t.jsx)("table",{ref:s,className:(0,l.cn)("w-full caption-bottom text-base",r),...a})})});n.displayName="Table";let i=a.forwardRef((e,s)=>{let{className:r,...a}=e;return(0,t.jsx)("thead",{ref:s,className:(0,l.cn)("[&_tr]:border-b",r),...a})});i.displayName="TableHeader";let o=a.forwardRef((e,s)=>{let{className:r,...a}=e;return(0,t.jsx)("tbody",{ref:s,className:(0,l.cn)("[&_tr:last-child]:border-0",r),...a})});o.displayName="TableBody",a.forwardRef((e,s)=>{let{className:r,...a}=e;return(0,t.jsx)("tfoot",{ref:s,className:(0,l.cn)("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",r),...a})}).displayName="TableFooter";let c=a.forwardRef((e,s)=>{let{className:r,...a}=e;return(0,t.jsx)("tr",{ref:s,className:(0,l.cn)("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",r),...a})});c.displayName="TableRow";let d=a.forwardRef((e,s)=>{let{className:r,...a}=e;return(0,t.jsx)("th",{ref:s,className:(0,l.cn)("h-12 px-4 text-left align-middle font-medium text-[hsl(var(--text-strong))] [&:has([role=checkbox])]:pr-0",r),...a})});d.displayName="TableHead";let u=a.forwardRef((e,s)=>{let{className:r,...a}=e;return(0,t.jsx)("td",{ref:s,className:(0,l.cn)("p-4 align-middle [&:has([role=checkbox])]:pr-0",r),...a})});u.displayName="TableCell",a.forwardRef((e,s)=>{let{className:r,...a}=e;return(0,t.jsx)("caption",{ref:s,className:(0,l.cn)("mt-4 text-base text-muted-foreground",r),...a})}).displayName="TableCaption"},8310:function(e,s,r){"use strict";r.r(s),r.d(s,{Users:function(){return P}});var t=r(5893),a=r(7294),l=r(5697),n=r.n(l),i=r(8799),o=r(1664),c=r.n(o),d=r(803),u=r(8764),m=r(3081),x=r(3266),h=r(8969),p=r(6378),f=r(6856),g=r(1214),b=r(4545),j=r(998);/**
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 y=(0,j.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 v=r(3626);/**
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 w=(0,j.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"}]]),N=(0,j.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"}]]),k=(0,j.Z)("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);var C=r(282),R=r(3767);/**
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 E=(0,j.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"}]]),S=(0,j.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 D=r(7603);r(9470);var I=r(3001),U=r(7673),L=r(7145),F=r(326),_=r(1812);let Z=(e,s)=>e&&e.includes("@")?e.split("@")[0]:e||"N/A",z=(e,s)=>e&&e.includes("@")?e:s||"-",M=g.nb.REFRESH_INTERVAL,A=e=>{let{message:s,onDismiss:r}=e;return s?(0,t.jsx)("div",{className:"bg-green-50 border border-green-200 rounded p-4 mb-6",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)("div",{className:"flex-shrink-0",children:(0,t.jsx)("svg",{className:"h-5 w-5 text-green-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.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,t.jsx)("div",{className:"ml-3",children:(0,t.jsx)("p",{className:"text-sm font-medium text-green-800",children:s})})]}),r&&(0,t.jsx)("div",{className:"ml-auto pl-3",children:(0,t.jsx)("div",{className:"-mx-1.5 -my-1.5",children:(0,t.jsxs)("button",{type:"button",onClick:r,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,t.jsx)("span",{className:"sr-only",children:"Dismiss"}),(0,t.jsx)("svg",{className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.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 P(){let[e,s]=(0,a.useState)(!1),r=(0,a.useRef)(null),l=(0,I.X)(),[n,o]=(0,a.useState)(!1),[u,f]=(0,a.useState)({username:"",password:"",role:"user"}),[g,b]=(0,a.useState)(!1),[j,C]=(0,a.useState)({open:!1,message:"",userName:""}),[R,E]=(0,a.useState)(null),[S,D]=(0,a.useState)(!1),[U,Z]=(0,a.useState)(!1),[z,P]=(0,a.useState)(!1),[V,T]=(0,a.useState)(null),[B,O]=(0,a.useState)(!1),[K,H]=(0,a.useState)(null),[X,$]=(0,a.useState)("import"),[J,Y]=(0,a.useState)(!1),[W,G]=(0,a.useState)(null),[Q,ee]=(0,a.useState)(""),[es,er]=(0,a.useState)(!1),[et,ea]=(0,a.useState)(null),[el,en]=(0,a.useState)(!1),[ei,eo]=(0,a.useState)(null),[ec,ed]=(0,a.useState)(null),[eu,em]=(0,a.useState)(!1),[ex,eh]=(0,a.useState)(null),[ep,ef]=(0,a.useState)(null),[eg,eb]=(0,a.useState)(void 0);(0,a.useEffect)(()=>{!async function(){try{let e=await L.x.get("/api/health");if(e.ok){let s=await e.json();eb(!!s.basic_auth_enabled)}else eb(!1)}catch(e){eb(!1)}}()},[]);let ej=(0,a.useCallback)(async()=>{if(R&&Date.now()-R.timestamp<3e5)return R;D(!0);try{let e=await L.x.get("/users/role");if(!e.ok){let s=await e.json();throw Error(s.detail||"Failed to get user role")}let s=await e.json(),r={role:s.role,name:s.name,id:s.id,timestamp:Date.now()};return E(r),D(!1),r}catch(e){throw D(!1),e}},[R]);(0,a.useEffect)(()=>{ej().catch(()=>{console.error("Failed to get user role")})},[ej]);let ey=async(e,s)=>{try{let r=await ej();if("admin"!==r.role)return C({open:!0,message:e,userName:r.name.toLowerCase()}),!1;return s(),!0}catch(e){return console.error("Failed to check user role:",e),C({open:!0,message:"Error: ".concat(e.message),userName:""}),!1}},ev=()=>{p.default.invalidate(m.R),p.default.invalidate(x.getClusters),p.default.invalidate(h.getManagedJobs,[{allUsers:!0}]),r.current&&r.current()},ew=async()=>{if(!u.username||!u.password){ef(Error("Username and password are required.")),o(!1);return}b(!0),ef(null),eh(null);try{let e=await L.x.post("/users/create",u);if(!e.ok){let s=await e.json();throw Error(s.detail||"Failed to create user")}eh('User "'.concat(u.username,'" created successfully!')),o(!1),f({username:"",password:"",role:"user"}),ev()}catch(e){ef(e),o(!1),f({username:"",password:"",role:"user"})}finally{b(!1)}},eN=async e=>{let s=e.target.files[0];s&&(T(s),H(null))},ek=async()=>{if(!V){alert("Please select a CSV file first.");return}O(!0);try{let e=new FileReader;e.onload=async e=>{try{let s=e.target.result,r=await L.x.post("/users/import",{csv_content:s});if(!r.ok){let e=await r.json();throw Error(e.detail||"Failed to import users")}let t=await r.json(),a="Import completed. ".concat(t.success_count," users created successfully.");t.error_count>0&&(a+="\n".concat(t.error_count," failed."),t.creation_errors.length>0&&(a+="\nErrors: ".concat(t.creation_errors.slice(0,3).join(", ")),t.creation_errors.length>3&&(a+=" and ".concat(t.creation_errors.length-3," more...")))),H({message:a}),t.success_count>0&&ev()}catch(e){alert("Error importing users: ".concat(e.message))}finally{O(!1)}},e.readAsText(V)}catch(e){alert("Error reading file: ".concat(e.message)),O(!1)}},eC=async e=>{G(e),ee(""),Y(!0)},eR=async()=>{if(!Q){ea(Error("Please enter a new password."));return}er(!0),ea(null);try{let e=await L.x.post("/users/update",{user_id:W.userId,password:Q});if(!e.ok){let s=await e.json();throw Error(s.detail||"Failed to reset password")}eh('Password reset successfully for user "'.concat(W.usernameDisplay,'"!')),Y(!1),G(null),ee("")}catch(e){ea(e)}finally{er(!1)}},eE=async()=>{if(ei){em(!0),ed(null);try{let e=await L.x.post("/users/delete",{user_id:ei.userId});if(!e.ok){let s=await e.json();throw Error(s.detail||"Failed to delete user")}eh('User "'.concat(ei.usernameDisplay,'" deleted successfully!')),en(!1),eo(null),ev()}catch(e){ed(e)}finally{em(!1)}}},eS=()=>{en(!1),eo(null),ed(null)},eD=()=>{Y(!1),G(null),ee(""),ea(null)};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4 h-5",children:[(0,t.jsx)("div",{className:"text-base",children:(0,t.jsx)(c(),{href:"/users",className:"text-sky-blue hover:underline leading-none",children:"Users"})}),(0,t.jsxs)("div",{className:"flex items-center",children:[e&&(0,t.jsxs)("div",{className:"flex items-center mr-2",children:[(0,t.jsx)(i.Z,{size:15,className:"mt-0"}),(0,t.jsx)("span",{className:"ml-2 text-gray-500 text-sm",children:"Loading..."})]}),eg&&(null==R?void 0:R.role)==="admin"&&(0,t.jsx)("button",{onClick:async()=>{await ey("cannot create users",()=>{o(!0)})},className:"text-sky-blue hover:text-sky-blue-bright flex items-center border-sky-blue rounded px-2 py-1 mr-2",title:"Create New User",children:"+ New User"}),eg&&(null==R?void 0:R.role)==="admin"&&(0,t.jsxs)("button",{onClick:async()=>{await ey("cannot import users",()=>{P(!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,t.jsx)(y,{className:"h-4 w-4 mr-1"}),"Import/Export"]}),(0,t.jsxs)("button",{onClick:ev,disabled:e,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:[(0,t.jsx)(v.Z,{className:"h-4 w-4 mr-1.5"}),!l&&(0,t.jsx)("span",{children:"Refresh"})]})]})]}),(0,t.jsx)(A,{message:ex,onDismiss:()=>eh(null)}),(0,t.jsx)(_.X,{error:ep,title:"Error",onDismiss:()=>ef(null)}),(0,t.jsx)(q,{refreshInterval:M,setLoading:s,refreshDataRef:r,checkPermissionAndAct:ey,roleLoading:S,onResetPassword:eC,onDeleteUser:e=>{ey("cannot delete users",()=>{eo(e),en(!0)})},basicAuthEnabled:eg,currentUserRole:null==R?void 0:R.role,currentUserId:null==R?void 0:R.id}),(0,t.jsx)(F.Vq,{open:n,onOpenChange:o,children:(0,t.jsxs)(F.cZ,{className:"sm:max-w-md",children:[(0,t.jsx)(F.fK,{children:(0,t.jsx)(F.$N,{children:"Create User"})}),(0,t.jsxs)("div",{className:"flex flex-col gap-4 py-4",children:[(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Username"}),(0,t.jsx)("input",{className:"border rounded px-3 py-2 w-full",placeholder:"Username",value:u.username,onChange:e=>f({...u,username:e.target.value})})]}),(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Password"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{className:"border rounded px-3 py-2 w-full pr-10",placeholder:"Password",type:U?"text":"password",value:u.password,onChange:e=>f({...u,password:e.target.value})}),(0,t.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(!U),children:U?(0,t.jsx)(w,{className:"h-4 w-4"}):(0,t.jsx)(N,{className:"h-4 w-4"})})]})]}),(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Role"}),(0,t.jsxs)("select",{className:"border rounded px-3 py-2 w-full",value:u.role,onChange:e=>f({...u,role:e.target.value}),children:[(0,t.jsx)("option",{value:"user",children:"User"}),(0,t.jsx)("option",{value:"admin",children:"Admin"})]})]})]}),(0,t.jsxs)(F.cN,{children:[(0,t.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),disabled:g,children:"Cancel"}),(0,t.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:ew,disabled:g,children:g?"Creating...":"Create"})]})]})}),(0,t.jsx)(F.Vq,{open:j.open,onOpenChange:e=>C(s=>({...s,open:e})),children:(0,t.jsxs)(F.cZ,{className:"sm:max-w-md transition-all duration-200 ease-in-out",children:[(0,t.jsxs)(F.fK,{children:[(0,t.jsx)(F.$N,{children:"Permission Denied"}),(0,t.jsx)(F.Be,{children:S?(0,t.jsxs)("div",{className:"flex items-center py-2",children:[(0,t.jsx)(i.Z,{size:16,className:"mr-2"}),(0,t.jsx)("span",{children:"Checking permissions..."})]}):(0,t.jsx)(t.Fragment,{children:j.userName?(0,t.jsxs)(t.Fragment,{children:[j.userName," is logged in as non-admin and ",j.message,"."]}):j.message})})]}),(0,t.jsx)(F.cN,{children:(0,t.jsx)(d.z,{variant:"outline",onClick:()=>C(e=>({...e,open:!1})),disabled:S,children:"OK"})})]})}),(0,t.jsx)(F.Vq,{open:z,onOpenChange:P,children:(0,t.jsxs)(F.cZ,{className:"sm:max-w-lg",children:[(0,t.jsx)(F.fK,{children:(0,t.jsx)(F.$N,{children:"Import/Export Users"})}),(0,t.jsxs)("div",{className:"flex border-b border-gray-200 mb-4",children:[(0,t.jsx)("button",{className:"px-4 py-2 text-sm font-medium ".concat("import"===X?"border-b-2 border-sky-500 text-sky-600":"text-gray-500 hover:text-gray-700"),onClick:()=>$("import"),children:"Import"}),(0,t.jsx)("button",{className:"px-4 py-2 text-sm font-medium ".concat("export"===X?"border-b-2 border-sky-500 text-sky-600":"text-gray-500 hover:text-gray-700"),onClick:()=>$("export"),children:"Export"})]}),(0,t.jsx)("div",{className:"flex flex-col gap-4 py-4",children:"import"===X?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"CSV File"}),(0,t.jsx)("input",{type:"file",accept:".csv",onChange:eN,className:"border rounded px-3 py-2 w-full"}),(0,t.jsxs)("p",{className:"text-xs text-gray-500",children:["CSV should have columns: username, password, role",(0,t.jsx)("br",{}),"Supports both plain text passwords and exported password hashes."]})]}),K&&(0,t.jsx)("div",{className:"p-3 bg-green-50 border border-green-200 rounded text-green-700 text-sm",children:K.message})]}):(0,t.jsx)(t.Fragment,{children:(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Export Users to CSV"}),(0,t.jsx)("p",{className:"text-xs text-gray-500",children:"Download all users as a CSV file with password hashes."}),(0,t.jsxs)("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:[(0,t.jsx)("p",{className:"text-sm text-amber-700",children:"⚠️ This will export all users with columns: username, password (hashed), role"}),(0,t.jsx)("p",{className:"text-xs text-amber-600 mt-1",children:"Password hashes can be imported directly for system backups."})]})]})})}),(0,t.jsxs)(F.cN,{children:[(0,t.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:()=>P(!1),disabled:B,children:"Cancel"}),"import"===X?(0,t.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:ek,disabled:B||!V,children:B?"Importing...":"Import"}):(0,t.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 L.x.get("/users/export");if(!e.ok){let s=await e.json();throw Error(s.detail||"Failed to export users")}let s=await e.json(),r=s.csv_content,t=new Blob([r],{type:"text/csv;charset=utf-8;"}),a=URL.createObjectURL(t),l=document.createElement("a");l.href=a;let n=new Date,i=e=>String(e).padStart(2,"0"),o=n.getFullYear(),c=i(n.getMonth()+1),d=i(n.getDate()),u=i(n.getHours()),m=i(n.getMinutes()),x=i(n.getSeconds());l.download="users_export_".concat(o,"-").concat(c,"-").concat(d,"-").concat(u,"-").concat(m,"-").concat(x,".csv"),l.click(),URL.revokeObjectURL(a),alert("Successfully exported ".concat(s.user_count," users to CSV file."))}catch(e){alert("Error exporting users: ".concat(e.message))}},children:[(0,t.jsx)(k,{className:"h-4 w-4 mr-1"}),"Export"]})]})]})}),(0,t.jsx)(F.Vq,{open:J,onOpenChange:eD,children:(0,t.jsxs)(F.cZ,{className:"sm:max-w-md",children:[(0,t.jsxs)(F.fK,{children:[(0,t.jsx)(F.$N,{children:"Reset Password"}),(0,t.jsxs)(F.Be,{children:["Enter a new password for"," ",(null==W?void 0:W.usernameDisplay)||"this user","."]})]}),(0,t.jsx)("div",{className:"flex flex-col gap-4 py-4",children:(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"New Password"}),(0,t.jsx)("input",{type:"password",className:"border rounded px-3 py-2 w-full",placeholder:"Enter new password",value:Q,onChange:e=>ee(e.target.value),autoFocus:!0})]})}),(0,t.jsx)(_.X,{error:et,title:"Reset Failed",onDismiss:()=>ea(null)}),(0,t.jsxs)(F.cN,{children:[(0,t.jsx)(d.z,{variant:"outline",onClick:eD,disabled:es,children:"Cancel"}),(0,t.jsx)(d.z,{variant:"default",onClick:eR,disabled:es||!Q,className:"bg-sky-600 text-white hover:bg-sky-700",children:es?"Resetting...":"Reset Password"})]})]})}),(0,t.jsx)(F.Vq,{open:el,onOpenChange:eS,children:(0,t.jsxs)(F.cZ,{className:"sm:max-w-md",children:[(0,t.jsxs)(F.fK,{children:[(0,t.jsx)(F.$N,{children:"Delete User"}),(0,t.jsxs)(F.Be,{children:['Are you sure you want to delete user "',(null==ei?void 0:ei.usernameDisplay)||"this user",'"? This action cannot be undone.']})]}),(0,t.jsx)(_.X,{error:ec,title:"Deletion Failed",onDismiss:()=>ed(null)}),(0,t.jsxs)(F.cN,{children:[(0,t.jsx)(d.z,{variant:"outline",onClick:eS,disabled:eu,children:"Cancel"}),(0,t.jsx)(d.z,{variant:"destructive",onClick:eE,disabled:eu,children:eu?"Deleting...":"Delete"})]})]})})]})}function q(e){let{refreshInterval:s,setLoading:r,refreshDataRef:l,checkPermissionAndAct:n,roleLoading:o,onResetPassword:d,onDeleteUser:g,basicAuthEnabled:j,currentUserRole:y,currentUserId:v}=e,[w,N]=(0,a.useState)([]),[k,I]=(0,a.useState)(!0),[F,_]=(0,a.useState)(!1),[M,A]=(0,a.useState)({key:"username",direction:"ascending"}),[P,q]=(0,a.useState)(null),[V,T]=(0,a.useState)(""),B=(0,a.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];r&&e&&r(!0),e&&I(!0);try{let s=await p.default.get(m.R),t=(s||[]).map(e=>({...e,usernameDisplay:Z(e.username,e.userId),fullEmailID:z(e.username,e.userId),clusterCount:-1,jobCount:-1}));N(t),_(!0),r&&e&&r(!1),e&&I(!1);let[a,l]=await Promise.all([p.default.get(x.getClusters),p.default.get(h.getManagedJobs,[{allUsers:!0}])]),n=l.jobs||[],i=(s||[]).map(e=>{let s=(a||[]).filter(s=>s.user_hash===e.userId),r=(n||[]).filter(s=>s.user_hash===e.userId);return{...e,usernameDisplay:Z(e.username,e.userId),fullEmailID:z(e.username,e.userId),clusterCount:s.length,jobCount:r.length}});N(i)}catch(s){console.error("Failed to fetch or process user data:",s),N([]),_(!0),r&&e&&r(!1),e&&I(!1)}},[r]);(0,a.useEffect)(()=>{l&&(l.current=()=>B(!0))},[l,B]),(0,a.useEffect)(()=>{(async()=>{_(!1),I(!0),await f.ZP.preloadForPage("users"),B(!0)})();let e=setInterval(()=>{B(!1)},s);return()=>clearInterval(e)},[B,s]);let O=(0,a.useMemo)(()=>(0,b.R0)(w,M.key,M.direction),[w,M]),K=e=>{let s="ascending";M.key===e&&"ascending"===M.direction&&(s="descending"),A({key:e,direction:s})},H=e=>M.key===e?"ascending"===M.direction?" ↑":" ↓":"",X=async(e,s)=>{await n("cannot edit user role",()=>{q(e),T(s)})},$=()=>{q(null),T("")},J=async e=>{if(!e||!V){console.error("User ID or role is missing."),alert("Error: User ID or role is missing.");return}I(!0);try{let s=await L.x.post("/users/update",{user_id:e,role:V});if(!s.ok){let e=await s.json();throw Error(e.detail||"Failed to update role")}p.default.invalidate(m.R),await B(!0),$()}catch(e){console.error("Failed to update user role:",e),alert("Error updating role: ".concat(e.message))}finally{I(!1)}};return k&&0===w.length&&!F?(0,t.jsx)("div",{className:"flex justify-center items-center h-64",children:(0,t.jsx)(i.Z,{})}):F?O&&0!==O.length?(0,t.jsx)(U.Zb,{children:(0,t.jsxs)(u.iA,{children:[(0,t.jsx)(u.xD,{children:(0,t.jsxs)(u.SC,{children:[(0,t.jsxs)(u.ss,{onClick:()=>K("usernameDisplay"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/5",children:["Name",H("usernameDisplay")]}),(0,t.jsxs)(u.ss,{onClick:()=>K("fullEmailID"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/5",children:["User ID",H("fullEmailID")]}),(0,t.jsxs)(u.ss,{onClick:()=>K("role"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/5",children:["Role",H("role")]}),(0,t.jsxs)(u.ss,{onClick:()=>K("clusterCount"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/5",children:["Clusters",H("clusterCount")]}),(0,t.jsxs)(u.ss,{onClick:()=>K("jobCount"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/5",children:["Jobs",H("jobCount")]}),j&&(0,t.jsx)(u.ss,{className:"whitespace-nowrap w-1/6",children:"Actions"})]})}),(0,t.jsx)(u.RM,{children:O.map(e=>(0,t.jsxs)(u.SC,{children:[(0,t.jsx)(u.pj,{className:"truncate",title:e.username,children:e.usernameDisplay}),(0,t.jsx)(u.pj,{className:"truncate",title:e.fullEmailID,children:e.fullEmailID}),(0,t.jsx)(u.pj,{className:"truncate",title:e.role,children:(0,t.jsx)("div",{className:"flex items-center gap-2",children:P===e.userId?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("select",{value:V,onChange:e=>T(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,t.jsx)("option",{value:"admin",children:"Admin"}),(0,t.jsx)("option",{value:"user",children:"User"})]}),(0,t.jsx)("button",{onClick:()=>J(e.userId),className:"text-green-600 hover:text-green-800 p-1",title:"Save",children:(0,t.jsx)(C.Z,{className:"h-4 w-4"})}),(0,t.jsx)("button",{onClick:$,className:"text-gray-500 hover:text-gray-700 p-1",title:"Cancel",children:(0,t.jsx)(R.Z,{className:"h-4 w-4"})})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"capitalize",children:e.role}),"admin"===y&&(0,t.jsx)("button",{onClick:()=>X(e.userId,e.role),className:"text-sky-blue hover:text-sky-blue-bright p-1",title:"Edit role",children:(0,t.jsx)(E,{className:"h-3 w-3"})})]})})}),(0,t.jsx)(u.pj,{children:-1===e.clusterCount?(0,t.jsxs)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-400 rounded text-xs font-medium flex items-center",children:[(0,t.jsx)(i.Z,{size:10,className:"mr-1"}),"Loading..."]}):(0,t.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-800 hover:bg-blue-200 hover:text-blue-900":"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,t.jsx)(u.pj,{children:-1===e.jobCount?(0,t.jsxs)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-400 rounded text-xs font-medium flex items-center",children:[(0,t.jsx)(i.Z,{size:10,className:"mr-1"}),"Loading..."]}):(0,t.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-800 hover:bg-green-200 hover:text-green-900":"bg-gray-100 text-gray-500 hover:bg-gray-200 hover:text-gray-700"),title:"View ".concat(e.jobCount," job").concat(1!==e.jobCount?"s":""," for ").concat(e.usernameDisplay),children:e.jobCount})}),j&&(0,t.jsx)(u.pj,{className:"relative",children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("button",{onClick:"admin"===y||e.userId===v?async()=>{d(e)}:void 0,className:"admin"===y||e.userId===v?"text-sky-blue hover:text-sky-blue-bright p-1":"text-gray-300 cursor-not-allowed p-1",title:"admin"===y||e.userId===v?"Reset Password":"You can only reset your own password",disabled:"admin"!==y&&e.userId!==v,children:(0,t.jsx)(S,{className:"h-4 w-4"})}),"admin"===y&&(0,t.jsx)("button",{onClick:()=>g(e),className:"text-sky-blue hover:text-red-500 p-1",title:"Delete User",children:(0,t.jsx)(D.Z,{className:"h-4 w-4"})})]})})]},e.userId))})]})}):(0,t.jsxs)("div",{className:"text-center py-12",children:[(0,t.jsx)("p",{className:"text-lg font-semibold text-gray-500",children:"No users found."}),(0,t.jsx)("p",{className:"text-sm text-gray-400 mt-1",children:"There are currently no users to display."})]}):(0,t.jsxs)("div",{className:"flex justify-center items-center h-64",children:[(0,t.jsx)(i.Z,{}),(0,t.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading users..."})]})}q.propTypes={refreshInterval:n().number.isRequired,setLoading:n().func.isRequired,refreshDataRef:n().shape({current:n().func}).isRequired,checkPermissionAndAct:n().func.isRequired,roleLoading:n().bool.isRequired,onResetPassword:n().func.isRequired,onDeleteUser:n().func.isRequired,basicAuthEnabled:n().bool,currentUserRole:n().string,currentUserId:n().string}},4545:function(e,s,r){"use strict";function t(e){return e.startsWith("sky-jobs-controller-")}function a(e,s,r){return null===s?e:[...e].sort((e,t)=>e[s]<t[s]?"ascending"===r?-1:1:e[s]>t[s]?"ascending"===r?1:-1:0)}r.d(s,{R0:function(){return a},Ym:function(){return t}})},1163:function(e,s,r){e.exports=r(6036)}}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[785,430],{2557:function(e,s,t){"use strict";t.d(s,{I:function(){return l}});var r=t(5893),a=t(7294),n=t(2350);let l=a.forwardRef((e,s)=>{let{className:t,type:a,...l}=e;return(0,r.jsx)("input",{type:a,className:(0,n.cn)("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium 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,...l})});l.displayName="Input"},6185:function(e,s,t){"use strict";t.d(s,{_:function(){return c}});var r=t(5893),a=t(7294),n=t(9102),l=t(2003),i=t(2350);let o=(0,l.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),c=a.forwardRef((e,s)=>{let{className:t,...a}=e;return(0,r.jsx)(n.f,{ref:s,className:(0,i.cn)(o(),t),...a})});c.displayName=n.f.displayName},3785:function(e,s,t){"use strict";t.r(s),t.d(s,{NewWorkspace:function(){return b}});var r=t(5893),a=t(7294),n=t(1163),l=t(1664),i=t.n(l),o=t(5152),c=t.n(o),u=t(7324),d=t(803),f=t(2557),m=t(6185),p=t(7673);let x=c()(()=>Promise.all([t.e(616),t.e(799),t.e(804),t.e(798),t.e(947),t.e(989),t.e(470),t.e(969),t.e(43),t.e(973),t.e(938),t.e(141)]).then(t.bind(t,1141)).then(e=>e.WorkspaceEditor),{loadableGenerated:{webpack:()=>[1141]},ssr:!1});function b(){(0,n.useRouter)();let[e,s]=(0,a.useState)(""),[t,l]=(0,a.useState)(!1),[o,c]=(0,a.useState)({}),[b,h]=(0,a.useState)(!0);(0,a.useEffect)(()=>{v()},[]);let v=async()=>{try{let e=await (0,u.fX)();c(e)}catch(e){console.error("Failed to fetch existing workspaces:",e)}finally{h(!1)}},w=()=>{e.trim()&&!k&&l(!0)},k=e.trim()&&o.hasOwnProperty(e.trim()),y=e.trim()&&!k;return t?(0,r.jsx)(x,{workspaceName:e,isNewWorkspace:!0}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex items-center justify-between mb-4 h-5",children:(0,r.jsxs)("div",{className:"text-base flex items-center",children:[(0,r.jsx)(i(),{href:"/workspaces",className:"text-sky-blue hover:underline",children:"Workspaces"}),(0,r.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,r.jsx)("span",{className:"text-sky-blue",children:"New Workspace"})]})}),(0,r.jsxs)(p.Zb,{className:"max-w-md",children:[(0,r.jsx)(p.Ol,{children:(0,r.jsx)(p.ll,{className:"text-base font-normal",children:"Create New Workspace"})}),(0,r.jsxs)(p.aY,{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(m._,{htmlFor:"workspace-name",className:"text-sm font-normal",children:"Workspace name"}),(0,r.jsx)(f.I,{id:"workspace-name",value:e,onChange:e=>s(e.target.value),placeholder:"Enter workspace name",autoFocus:!0,onKeyPress:e=>{"Enter"===e.key&&y&&w()}}),k?(0,r.jsxs)("p",{className:"text-sm text-gray-500 mt-1",children:['Workspace "',e,'" already exists.'," ",(0,r.jsx)(i(),{href:"/workspaces/".concat(e),className:"text-blue-600 hover:underline",children:"View the workspace"})]}):(0,r.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"Choose a unique name for your workspace"})]}),(0,r.jsx)(d.z,{onClick:w,disabled:!y||b,className:"w-full bg-blue-600 hover:bg-blue-700 text-white disabled:bg-gray-300 disabled:text-gray-500",children:b?"Loading...":"Next: Configure Workspace"})]})]})]})}},1163:function(e,s,t){e.exports=t(6036)},9102:function(e,s,t){"use strict";t.d(s,{f:function(){return i}});var r=t(7294),a=t(5320),n=t(5893),l=r.forwardRef((e,s)=>(0,n.jsx)(a.WV.label,{...e,ref:s,onMouseDown:s=>{s.target.closest("button, input, select, textarea")||(e.onMouseDown?.(s),!s.defaultPrevented&&s.detail>1&&s.preventDefault())}}));l.displayName="Label";var i=l},2003:function(e,s,t){"use strict";t.d(s,{j:function(){return l}});var r=t(512);let a=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,n=r.W,l=(e,s)=>t=>{var r;if((null==s?void 0:s.variants)==null)return n(e,null==t?void 0:t.class,null==t?void 0:t.className);let{variants:l,defaultVariants:i}=s,o=Object.keys(l).map(e=>{let s=null==t?void 0:t[e],r=null==i?void 0:i[e];if(null===s)return null;let n=a(s)||a(r);return l[e][n]}),c=t&&Object.entries(t).reduce((e,s)=>{let[t,r]=s;return void 0===r||(e[t]=r),e},{});return n(e,o,null==s?void 0:null===(r=s.compoundVariants)||void 0===r?void 0:r.reduce((e,s)=>{let{class:t,className:r,...a}=s;return Object.entries(a).every(e=>{let[s,t]=e;return Array.isArray(t)?t.includes({...i,...c}[s]):({...i,...c})[s]===t})?[...e,t,r]:e},[]),null==t?void 0:t.class,null==t?void 0:t.className)}}}]);
@@ -0,0 +1,6 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[871,430],{9037:function(e,s,t){"use strict";t.r(s),t.d(s,{ClusterTable:function(){return E},Clusters:function(){return R},Status2Actions:function(){return F},enabledActions:function(){return V},filterClustersByName:function(){return L},handleVSCodeConnection:function(){return O}});var r=t(5893),l=t(7294),a=t(1163),n=t(8799),i=t(6989),c=t(1664),o=t.n(c),d=t(803),u=t(7673),h=t(8764),m=t(3266),x=t(7324),p=t(3081),f=t(4545),j=t(3626),y=t(998);/**
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 w=(0,y.Z)("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]),v=(0,y.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(9470);var g=t(9284),k=t(9307),b=t(3001),N=t(8950),C=t(6378),S=t(6856);t(1272);let _="__ALL_WORKSPACES__",A="__ALL_USERS__";function L(e,s){if(!s||""===s.trim())return e;let t=s.toLowerCase().trim();return e.filter(e=>(e.cluster||"").toLowerCase().includes(t))}let M=(e,s)=>{let t="",r="";return e>=0&&(t=e+"m",r=" "),s&&(t+="".concat(r,"(down)")),""===t&&(t="-"),t},q=(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},I=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 R(){var e;let s=(0,a.useRouter)(),[t,c]=(0,l.useState)(!1),d=l.useRef(null),[u,h]=(0,l.useState)(!1),[f,y]=(0,l.useState)(!1),[w,v]=(0,l.useState)(null),[k,L]=(0,l.useState)(_),[M,I]=(0,l.useState)(A),[R,O]=(0,l.useState)(""),[H,V]=(0,l.useState)([]),[W,F]=(0,l.useState)([]),[z,Z]=(0,l.useState)(!1),B=(0,b.X)();(0,l.useEffect)(()=>{s.isReady&&(s.query.workspace&&L(Array.isArray(s.query.workspace)?s.query.workspace[0]:s.query.workspace),s.query.user&&I(Array.isArray(s.query.user)?s.query.user[0]:s.query.user),s.query.name&&O(Array.isArray(s.query.name)?s.query.name[0]:s.query.name))},[s.isReady,s.query.workspace,s.query.user,s.query.name]);let P=(e,t,r)=>{let l={...s.query};e&&e!==_?l.workspace=e:delete l.workspace,t&&t!==A?l.user=t:delete l.user,r&&""!==r.trim()?l.name=r.trim():delete l.name,s.replace({pathname:s.pathname,query:l},void 0,{shallow:!0})},U=e=>{O(e),P(k,M,e)};return(0,l.useEffect)(()=>{(async()=>{try{await S.ZP.preloadForPage("clusters");let e=await C.default.get(x.fX),s=Object.keys(e),t=await C.default.get(m.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)),V(Array.from(l).sort());let a=await C.default.get(p.R),n=[...new Set(t.map(e=>({userId:e.user_hash||e.user,username:e.user})).filter(e=>e.userId)).values()],i=new Map;a.forEach(e=>{i.set(e.userId,{userId:e.userId,username:e.username,display:q(e.username,e.userId)})}),n.forEach(e=>{i.has(e.userId)||i.set(e.userId,{userId:e.userId,username:e.username,display:q(e.username,e.userId)})}),F(Array.from(i.values()).sort((e,s)=>e.display.localeCompare(s.display)))}catch(e){console.error("Error fetching data for filters:",e),V(["default"]),F([])}})()},[]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4 h-5",children:[(0,r.jsxs)("div",{className:"text-base flex items-center",children:[(0,r.jsx)(o(),{href:"/clusters",className:"text-sky-blue hover:underline leading-none",children:"Sky Clusters"}),(0,r.jsx)("div",{className:"flex items-center ml-6 space-x-3",children:(0,r.jsxs)("label",{className:"flex items-center cursor-pointer",children:[(0,r.jsx)("input",{type:"checkbox",checked:z,onChange:e=>Z(e.target.checked),className:"sr-only"}),(0,r.jsx)("div",{className:"relative inline-flex h-5 w-9 items-center rounded-full transition-colors ".concat(z?"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(z?"translate-x-5":"translate-x-1")})}),(0,r.jsx)("span",{className:"ml-2 text-sm text-gray-700",children:"Show history (Last 30 days)"})]})}),(0,r.jsxs)("div",{className:"relative ml-4 mr-2",children:[(0,r.jsx)("input",{type:"text",placeholder:"Filter by cluster name",value:R,onChange:e=>U(e.target.value),className:"h-8 w-32 sm:w-48 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"}),R&&(0,r.jsx)("button",{onClick:()=>U(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600",title:"Clear filter",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"})})})]}),(0,r.jsxs)(N.Ph,{value:k,onValueChange:e=>{L(e),P(e,M,R)},children:[(0,r.jsx)(N.i4,{className:"h-8 w-48 ml-2 mr-2 text-sm border-none focus:ring-0 focus:outline-none",children:(0,r.jsx)(N.ki,{placeholder:"Filter by workspace...",children:k===_?"All Workspaces":k})}),(0,r.jsxs)(N.Bw,{children:[(0,r.jsx)(N.Ql,{value:_,children:"All Workspaces"}),H.map(e=>(0,r.jsx)(N.Ql,{value:e,children:e},e))]})]}),(0,r.jsxs)(N.Ph,{value:M,onValueChange:e=>{I(e),P(k,e,R)},children:[(0,r.jsx)(N.i4,{className:"h-8 w-48 ml-2 mr-2 text-sm border-none focus:ring-0 focus:outline-none",children:(0,r.jsx)(N.ki,{placeholder:"Filter by user...",children:M===A?"All Users":(null===(e=W.find(e=>e.userId===M))||void 0===e?void 0:e.display)||M})}),(0,r.jsxs)(N.Bw,{children:[(0,r.jsx)(N.Ql,{value:A,children:"All Users"}),W.map(e=>(0,r.jsx)(N.Ql,{value:e.userId,children:e.display},e.userId))]})]})]}),(0,r.jsxs)("div",{className:"flex items-center",children:[t&&(0,r.jsxs)("div",{className:"flex items-center mr-2",children:[(0,r.jsx)(n.Z,{size:15,className:"mt-0"}),(0,r.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading..."})]}),(0,r.jsxs)("button",{onClick:()=>{C.default.invalidate(m.getClusters),C.default.invalidate(m.uR),C.default.invalidate(x.fX),C.default.invalidate(p.R),d.current&&d.current()},disabled:t,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:[(0,r.jsx)(j.Z,{className:"h-4 w-4 mr-1.5"}),!B&&(0,r.jsx)("span",{children:"Refresh"})]})]})]}),(0,r.jsx)(E,{refreshInterval:i.yc,setLoading:c,refreshDataRef:d,workspaceFilter:k,userFilter:M,nameFilter:R,showHistory:z,onOpenSSHModal:e=>{v(e),h(!0)},onOpenVSCodeModal:e=>{v(e),y(!0)}}),(0,r.jsx)(g.Oh,{isOpen:u,onClose:()=>h(!1),cluster:w}),(0,r.jsx)(g._R,{isOpen:f,onClose:()=>y(!1),cluster:w})]})}function E(e){let{refreshInterval:s,setLoading:t,refreshDataRef:a,workspaceFilter:c,userFilter:x,nameFilter:p,showHistory:j,onOpenSSHModal:y,onOpenVSCodeModal:w}=e,[v,g]=(0,l.useState)([]),[b,N]=(0,l.useState)({key:null,direction:"ascending"}),[S,q]=(0,l.useState)(!1),[R,E]=(0,l.useState)(!0),[O,H]=(0,l.useState)(1),[V,W]=(0,l.useState)(10),z=l.useCallback(async()=>{t(!0),q(!0);try{let e=await C.default.get(m.getClusters);if(j){let s=await C.default.get(m.uR),t=e.map(e=>({...e,isHistorical:!1})),r=s.map(e=>({...e,isHistorical:!0})),l=[...t];r.forEach(s=>{e.some(e=>(e.cluster||e.name)===(s.cluster||s.name))||l.push(s)}),g(l)}else{let s=e.map(e=>({...e,isHistorical:!1}));g(s)}}catch(e){console.error("Error fetching cluster data:",e),g([])}t(!1),q(!1),E(!1)},[t,j]),Z=l.useMemo(()=>{let e=v;return c&&c!==_&&(e=e.filter(e=>(e.workspace||"default").toLowerCase()===c.toLowerCase())),x&&x!==A&&(e=e.filter(e=>(e.user_hash||e.user)===x)),p&&(e=L(e,p)),(0,f.R0)(e,b.key,b.direction)},[v,b,c,x,p]);l.useEffect(()=>{a&&(a.current=z)},[a,z]),(0,l.useEffect)(()=>{g([]);let e=!0;z();let t=setInterval(()=>{e&&z()},s);return()=>{e=!1,clearInterval(t)}},[s,z]),(0,l.useEffect)(()=>{H(1)},[v.length]);let B=e=>{let s="ascending";b.key===e&&"ascending"===b.direction&&(s="descending"),N({key:e,direction:s})},P=e=>b.key===e?"ascending"===b.direction?" ↑":" ↓":"",U=Math.ceil(Z.length/V),Q=(O-1)*V,X=Q+V,D=Z.slice(Q,X);return(0,r.jsxs)("div",{children:[(0,r.jsx)(u.Zb,{children:(0,r.jsx)("div",{className:"overflow-x-auto",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:()=>B("status"),children:["Status",P("status")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>B("cluster"),children:["Cluster",P("cluster")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap hidden sm:table-cell",onClick:()=>B("user"),children:["User",P("user")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap hidden md:table-cell",onClick:()=>B("workspace"),children:["Workspace",P("workspace")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap hidden lg:table-cell",onClick:()=>B("infra"),children:["Infra",P("infra")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap hidden xl:table-cell",onClick:()=>B("resources_str"),children:["Resources",P("resources_str")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>B("time"),children:["Started",P("time")]}),j&&(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap hidden lg:table-cell",onClick:()=>B("duration"),children:["Duration",P("duration")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap hidden md:table-cell",onClick:()=>B("autostop"),children:["Autostop",P("autostop")]}),(0,r.jsx)(h.ss,{className:"sticky right-0 bg-white",children:"Actions"})]})}),(0,r.jsx)(h.RM,{children:S&&R?(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..."})]})})}):D.length>0?D.map((e,s)=>(0,r.jsxs)(h.SC,{children:[(0,r.jsx)(h.pj,{children:(0,r.jsx)(k.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,{className:"hidden sm:table-cell",children:e.user}),(0,r.jsx)(h.pj,{className:"hidden md:table-cell",children:(0,r.jsx)(o(),{href:"/workspaces",className:"text-blue-600 hover:underline",children:e.workspace||"default"})}),(0,r.jsx)(h.pj,{className:"hidden lg:table-cell",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,{className:"hidden xl:table-cell",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})}),j&&(0,r.jsx)(h.pj,{className:"hidden lg:table-cell",children:I(e.duration)}),(0,r.jsx)(h.pj,{className:"hidden md:table-cell",children:e.isHistorical?"-":M(e.autostop,e.to_down)}),(0,r.jsx)(h.pj,{className:"text-left sticky right-0 bg-white",children:!e.isHistorical&&(0,r.jsx)(F,{cluster:e.cluster,status:e.status,onOpenSSHModal:y,onOpenVSCodeModal:w})})]},s)):(0,r.jsx)(h.SC,{children:(0,r.jsx)(h.pj,{colSpan:9,className:"text-center py-6 text-gray-500",children:j?"No clusters found":"No active clusters"})})})]})})}),v.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:V,onChange:e=>{W(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.jsxs)("div",{children:[Q+1," – ",Math.min(X,v.length)," of"," ",v.length]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)(d.z,{variant:"ghost",size:"icon",onClick:()=>{H(e=>Math.max(e-1,1))},disabled:1===O,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)(d.z,{variant:"ghost",size:"icon",onClick:()=>{H(e=>Math.min(e+1,U))},disabled:O===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)},H=(e,s)=>{s?s(e):window.open("ssh://".concat(e))},V=e=>"RUNNING"===e?["connect","VSCode"]:[],W={connect:(0,r.jsx)(w,{className:"w-4 h-4 text-gray-500 inline-block"}),VSCode:(0,r.jsx)(v,{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=V(l),o=(0,b.X)(),d=e=>{switch(e){case"connect":H(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:()=>d(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)})})})}},1163:function(e,s,t){e.exports=t(6036)},2003:function(e,s,t){"use strict";t.d(s,{j:function(){return n}});var r=t(512);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)}}}]);