@kubed.io/cdn 0.0.3 → 0.0.5

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 (59) hide show
  1. package/README.md +33 -5
  2. package/dist/chunks/define-BSZoKakE.js +10 -0
  3. package/dist/chunks/define-BSZoKakE.js.map +1 -0
  4. package/dist/chunks/element-ChNBLJ5X.js +632 -0
  5. package/dist/chunks/element-ChNBLJ5X.js.map +1 -0
  6. package/dist/chunks/kd-BeZbw7cp.js +1149 -0
  7. package/dist/chunks/kd-BeZbw7cp.js.map +1 -0
  8. package/dist/chunks/scene-CUr0fSXC.js +240 -0
  9. package/dist/chunks/scene-CUr0fSXC.js.map +1 -0
  10. package/dist/k8s/elements/events.d.ts +54 -0
  11. package/dist/k8s/elements/object.d.ts +47 -0
  12. package/dist/k8s/elements/ref.d.ts +45 -0
  13. package/dist/k8s/events.d.ts +63 -0
  14. package/dist/k8s/icons.d.ts +18 -0
  15. package/dist/k8s/index.d.ts +13 -0
  16. package/dist/k8s/links.d.ts +72 -0
  17. package/dist/k8s/map.d.ts +114 -0
  18. package/dist/k8s.js +909 -0
  19. package/dist/k8s.js.map +1 -0
  20. package/dist/kd/cell.d.ts +45 -0
  21. package/dist/kd/element.d.ts +32 -0
  22. package/dist/kd/elements/bar.d.ts +33 -0
  23. package/dist/kd/elements/data.d.ts +27 -0
  24. package/dist/kd/elements/groups.d.ts +32 -0
  25. package/dist/kd/elements/link.d.ts +67 -0
  26. package/dist/kd/elements/mask.d.ts +22 -0
  27. package/dist/kd/elements/meter.d.ts +37 -0
  28. package/dist/kd/elements/pill.d.ts +15 -0
  29. package/dist/kd/elements/sheet.d.ts +28 -0
  30. package/dist/kd/elements/steps.d.ts +30 -0
  31. package/dist/kd/elements/table.d.ts +38 -0
  32. package/dist/kd/elements/tabs.d.ts +27 -0
  33. package/dist/kd/elements/tile.d.ts +19 -0
  34. package/dist/kd/helpers.d.ts +12 -0
  35. package/dist/kd/index.d.ts +30 -0
  36. package/dist/kd/parts.d.ts +15 -0
  37. package/dist/kd/scene.d.ts +178 -0
  38. package/dist/kd/theme.d.ts +2 -0
  39. package/dist/kd/yaml.d.ts +17 -0
  40. package/dist/kd.js +5 -64
  41. package/dist/n8n/config.d.ts +58 -0
  42. package/dist/n8n/fetch.d.ts +35 -0
  43. package/dist/n8n/history.d.ts +8 -0
  44. package/dist/n8n/index.d.ts +8 -0
  45. package/dist/n8n/metadata.d.ts +10 -0
  46. package/dist/n8n/mount.d.ts +29 -0
  47. package/dist/n8n/state.d.ts +44 -0
  48. package/dist/n8n/stream.d.ts +17 -0
  49. package/dist/n8n/styles.d.ts +1 -0
  50. package/dist/n8n.js +384 -0
  51. package/dist/n8n.js.map +1 -0
  52. package/dist/openapi/describe.d.ts +20 -0
  53. package/dist/openapi/index.d.ts +6 -0
  54. package/dist/openapi/model.d.ts +154 -0
  55. package/dist/openapi/schema.d.ts +52 -0
  56. package/dist/openapi.js +504 -0
  57. package/dist/openapi.js.map +1 -0
  58. package/package.json +26 -2
  59. package/dist/kd.js.map +0 -1
package/dist/k8s.js ADDED
@@ -0,0 +1,909 @@
1
+ import { c as e, l as t, n, o as r, r as i, t as a, u as o } from "./chunks/element-ChNBLJ5X.js";
2
+ import { n as s, t as c } from "./chunks/define-BSZoKakE.js";
3
+ import "./chunks/kd-BeZbw7cp.js";
4
+ import { h as l } from "./chunks/scene-CUr0fSXC.js";
5
+ //#region src/k8s/icons.ts
6
+ var u = "https://cdn.jsdelivr.net/gh/kubernetes/community@149066325ed521eab576a262ddff8f4da074d5de/icons/svg/", d = "https://cdn.jsdelivr.net/gh/cncf/artwork@002662490acb2303c7301acc0256c00790e03e9f/projects/", ee = "https://cdn.jsdelivr.net/gh/external-secrets/external-secrets@088f9e5ff057d35bd9f68779893b691abb948b33/assets/", f = "https://cdn.jsdelivr.net/gh/devicons/devicon@7330accdbc47e2dc0c19789a48533c4a3c50fe58/icons/", p = (e) => `${u}resources/unlabeled/${e}.svg`, m = `${d}kubernetes/icon/color/kubernetes-icon-color.svg`, te = p("crd"), h = {
7
+ Pod: p("pod"),
8
+ Deployment: p("deploy"),
9
+ StatefulSet: p("sts"),
10
+ DaemonSet: p("ds"),
11
+ ReplicaSet: p("rs"),
12
+ CronJob: p("cronjob"),
13
+ Job: p("job"),
14
+ Service: p("svc"),
15
+ Ingress: p("ing"),
16
+ IngressClass: p("ing"),
17
+ Endpoints: p("ep"),
18
+ EndpointSlice: p("ep"),
19
+ NetworkPolicy: p("netpol"),
20
+ ConfigMap: p("cm"),
21
+ Secret: p("secret"),
22
+ PersistentVolumeClaim: p("pvc"),
23
+ PersistentVolume: p("pv"),
24
+ StorageClass: p("sc"),
25
+ Volume: p("vol"),
26
+ ServiceAccount: p("sa"),
27
+ Role: p("role"),
28
+ RoleBinding: p("rb"),
29
+ ClusterRole: p("c-role"),
30
+ ClusterRoleBinding: p("crb"),
31
+ User: p("user"),
32
+ Group: p("group"),
33
+ Namespace: p("ns"),
34
+ ResourceQuota: p("quota"),
35
+ PriorityClass: p("quota"),
36
+ LimitRange: p("limits"),
37
+ HorizontalPodAutoscaler: p("hpa"),
38
+ PodSecurityPolicy: p("psp"),
39
+ CustomResourceDefinition: p("crd"),
40
+ Node: `${u}infrastructure_components/unlabeled/node.svg`
41
+ }, g = {
42
+ "cert-manager.io": `${d}cert-manager/icon/color/cert-manager-icon-color.svg`,
43
+ "external-secrets.io": `${ee}eso-round-logo.svg`,
44
+ "postgresql.kubed.io": `${f}postgresql/postgresql-original.svg`,
45
+ "gcp.kubed.io": `${f}googlecloud/googlecloud-original.svg`,
46
+ "keycloak.kubed.io": `${d}keycloak/icon/color/keycloak-icon-color.svg`,
47
+ "pkg.crossplane.io": `${d}crossplane/icon/color/crossplane-icon-color.svg`
48
+ }, ne = [["crossplane.io", g["pkg.crossplane.io"]], ["kubed.io", g["pkg.crossplane.io"]]], re = /^(|apps|batch|policy|autoscaling|[a-z0-9.-]*\.k8s\.io)$/;
49
+ function _(e) {
50
+ let t = e ?? "", n = t.indexOf("/");
51
+ return n < 0 ? "" : t.slice(0, n);
52
+ }
53
+ function v(e) {
54
+ return re.test(e);
55
+ }
56
+ function y(e, t) {
57
+ let n = e ?? "";
58
+ if (t != null && t !== "") {
59
+ let e = _(t);
60
+ if (!v(e)) {
61
+ if (e === "ldap.kubed.io") return h[n === "ServiceAccount" ? "ServiceAccount" : "User"];
62
+ let t = g[e];
63
+ if (t) return t;
64
+ let r = ne.find(([t]) => e === t || e.endsWith(`.${t}`));
65
+ return r ? r[1] : te;
66
+ }
67
+ }
68
+ return h[n] ?? m;
69
+ }
70
+ //#endregion
71
+ //#region src/k8s/links.ts
72
+ var b = {
73
+ Deployment: "apps/v1",
74
+ StatefulSet: "apps/v1",
75
+ DaemonSet: "apps/v1",
76
+ ReplicaSet: "apps/v1",
77
+ Job: "batch/v1",
78
+ CronJob: "batch/v1"
79
+ }, x = {
80
+ pod: "k8s-pod",
81
+ workload: "k8s-workload",
82
+ maps: "k8s-maps",
83
+ volume: "k8s-volume",
84
+ class: "k8s-class",
85
+ serviceaccount: "k8s-serviceaccount",
86
+ crd: "k8s-crd",
87
+ rd: "k8s-rd",
88
+ namespace: "k8s-namespace",
89
+ node: "k8s-node",
90
+ service: "k8s-service",
91
+ ingress: "k8s-ingress",
92
+ resource: "k8s-resource"
93
+ };
94
+ function S(e) {
95
+ let t = e.toLowerCase();
96
+ return t === "endpoints" ? t : /(s|x|z|ch|sh)$/.test(t) ? `${t}es` : /[^aeiou]y$/.test(t) ? `${t.slice(0, -1)}ies` : `${t}s`;
97
+ }
98
+ function C(e) {
99
+ if (!e.apiVersion) return;
100
+ let t = e.apiVersion.includes("/") ? "apis" : "api", n = e.namespace ? `/namespaces/${e.namespace}` : "";
101
+ return `${t}/${e.apiVersion}${n}/${e.plural || S(e.kind)}/${e.name}`;
102
+ }
103
+ function w(e) {
104
+ return {
105
+ dashboard: x.namespace,
106
+ vars: { app_namespace: e }
107
+ };
108
+ }
109
+ function T(e) {
110
+ let { kind: t, name: n } = e, r = e.namespace ?? "";
111
+ if (!e.apiVersion || v(_(e.apiVersion))) {
112
+ if (t === "Pod") return {
113
+ dashboard: x.pod,
114
+ vars: {
115
+ app_namespace: r,
116
+ pod: n
117
+ }
118
+ };
119
+ if (t in b) {
120
+ let i = e.apiVersion || b[t];
121
+ return {
122
+ dashboard: x.workload,
123
+ vars: {
124
+ kind: `${i}/${e.plural || S(t)}`,
125
+ app_namespace: r,
126
+ workload: n
127
+ }
128
+ };
129
+ }
130
+ if (t === "ConfigMap" || t === "Secret") return {
131
+ dashboard: x.maps,
132
+ vars: {
133
+ kind: t === "Secret" ? "secrets" : "configmaps",
134
+ app_namespace: r,
135
+ mapname: n
136
+ }
137
+ };
138
+ if (t === "PersistentVolumeClaim" || t === "PersistentVolume") return {
139
+ dashboard: x.volume,
140
+ vars: {
141
+ kind: t === "PersistentVolume" ? "persistentvolumes" : "persistentvolumeclaims",
142
+ app_namespace: t === "PersistentVolume" ? "" : r,
143
+ volname: n
144
+ }
145
+ };
146
+ if (t === "StorageClass" || t === "IngressClass") return {
147
+ dashboard: x.class,
148
+ vars: {
149
+ kind: t === "IngressClass" ? "networking.k8s.io/v1/ingressclasses" : "storage.k8s.io/v1/storageclasses",
150
+ classname: n
151
+ }
152
+ };
153
+ if (t === "ServiceAccount") return {
154
+ dashboard: x.serviceaccount,
155
+ vars: {
156
+ app_namespace: r,
157
+ saname: n
158
+ }
159
+ };
160
+ if (t === "CustomResourceDefinition") return {
161
+ dashboard: x.crd,
162
+ vars: { crdname: n }
163
+ };
164
+ if (t === "Namespace") return w(n);
165
+ if (t === "Node") return {
166
+ dashboard: x.node,
167
+ vars: { node: n }
168
+ };
169
+ if (t === "Service") return {
170
+ dashboard: x.service,
171
+ vars: {
172
+ app_namespace: r,
173
+ service: n
174
+ }
175
+ };
176
+ if (t === "Ingress") return {
177
+ dashboard: x.ingress,
178
+ vars: {
179
+ app_namespace: r,
180
+ ingress: n
181
+ }
182
+ };
183
+ }
184
+ let i = C(e);
185
+ return i ? {
186
+ dashboard: x.resource,
187
+ vars: { path: i }
188
+ } : void 0;
189
+ }
190
+ function E(e, t, n) {
191
+ let r = _(t);
192
+ if (!v(r)) return {
193
+ dashboard: x.crd,
194
+ vars: { crdname: `${n || S(e)}.${r}` }
195
+ };
196
+ let i = t.includes("/") ? "apis" : "api";
197
+ return {
198
+ dashboard: x.rd,
199
+ vars: { rd: `${i}/${t}#${e}` }
200
+ };
201
+ }
202
+ function D(e, t) {
203
+ if (t.icon !== !1) return typeof t.icon == "string" ? t.icon : y(e.kind, e.apiVersion);
204
+ }
205
+ function O(e, t = {}) {
206
+ let n = t.text ?? e.name, r = t.title ?? e.kind, i = T(e), a = D(e, t);
207
+ return i ? {
208
+ dashboard: i.dashboard,
209
+ vars: i.vars,
210
+ back: !0,
211
+ text: n,
212
+ title: r,
213
+ ...a ? { icon: a } : {}
214
+ } : {
215
+ href: "",
216
+ text: n,
217
+ title: r,
218
+ ...a ? { icon: a } : {}
219
+ };
220
+ }
221
+ function k(e, t = {}) {
222
+ return O({
223
+ kind: "Namespace",
224
+ name: e,
225
+ apiVersion: "v1"
226
+ }, {
227
+ title: "Namespace",
228
+ ...t
229
+ });
230
+ }
231
+ function ie(e, t, n = {}) {
232
+ let r = E(e, t), i = D({
233
+ kind: e,
234
+ name: e,
235
+ apiVersion: t
236
+ }, n);
237
+ return {
238
+ dashboard: r.dashboard,
239
+ vars: r.vars,
240
+ back: !0,
241
+ text: n.text ?? e,
242
+ title: n.title ?? t,
243
+ ...i ? { icon: i } : {}
244
+ };
245
+ }
246
+ //#endregion
247
+ //#region src/k8s/map.ts
248
+ var ae = {
249
+ n: 1e-9,
250
+ u: 1e-6,
251
+ m: .001,
252
+ "": 1,
253
+ k: 1e3,
254
+ M: 1e6,
255
+ G: 1e9,
256
+ T: 0xe8d4a51000,
257
+ P: 0x38d7ea4c68000,
258
+ E: 0xde0b6b3a7640000,
259
+ Ki: 1024,
260
+ Mi: 2 ** 20,
261
+ Gi: 2 ** 30,
262
+ Ti: 2 ** 40,
263
+ Pi: 2 ** 50,
264
+ Ei: 2 ** 60
265
+ }, oe = /^([+-]?(?:\d+(?:\.\d*)?|\.\d+))(?:([eE][+-]?\d+)|(Ki|Mi|Gi|Ti|Pi|Ei|[numkMGTPE]))?$/;
266
+ function A(e) {
267
+ if (typeof e == "number") return e;
268
+ if (typeof e != "string") return NaN;
269
+ let t = oe.exec(e.trim());
270
+ if (!t) return NaN;
271
+ let n = Number(t[1]);
272
+ return t[2] ? n * 10 ** Number(t[2].slice(1)) : n * ae[t[3] ?? ""];
273
+ }
274
+ function j(e) {
275
+ let t = Math.max(0, Math.floor(e));
276
+ return t < 60 ? `${t}s` : t < 3600 ? `${Math.floor(t / 60)}m` : t < 86400 ? `${Math.floor(t / 3600)}h ${Math.floor(t % 3600 / 60)}m` : `${Math.floor(t / 86400)}d ${Math.floor(t % 86400 / 3600)}h`;
277
+ }
278
+ var M = (e) => e ? Date.parse(e) : NaN;
279
+ function N(e, t = Date.now()) {
280
+ let n = M(e);
281
+ return Number.isFinite(n) ? j((t - n) / 1e3) : "";
282
+ }
283
+ var P = (e) => e === "cpu" ? 0 : e === "memory" ? 1 : 2, se = /^(memory|ephemeral-storage|storage|hugepages-.*)$/;
284
+ function ce(e, t) {
285
+ return e === "cpu" ? {
286
+ unit: "m",
287
+ factor: 1e3
288
+ } : se.test(e) ? t >= 2 ** 40 ? {
289
+ unit: "Ti",
290
+ factor: 2 ** -40
291
+ } : t >= 2 ** 30 ? {
292
+ unit: "Gi",
293
+ factor: 2 ** -30
294
+ } : t >= 2 ** 20 ? {
295
+ unit: "Mi",
296
+ factor: 2 ** -20
297
+ } : {
298
+ unit: "Ki",
299
+ factor: 2 ** -10
300
+ } : {
301
+ unit: "",
302
+ factor: 1
303
+ };
304
+ }
305
+ function le(e, t = {}) {
306
+ let n = e?.resources?.requests ?? {}, r = e?.resources?.limits ?? {};
307
+ return [.../* @__PURE__ */ new Set([...Object.keys(n), ...Object.keys(r)])].sort((e, t) => P(e) - P(t) || (e < t ? -1 : +(e > t))).map((e) => {
308
+ let i = A(n[e]), a = A(r[e]), o = A(t[e]), { unit: s, factor: c } = ce(e, Math.max(...[
309
+ i,
310
+ a,
311
+ o
312
+ ].filter(Number.isFinite), 0)), l = [];
313
+ Number.isFinite(i) && l.push({
314
+ label: "request",
315
+ value: i * c
316
+ }), Number.isFinite(a) && l.push({
317
+ label: "limit",
318
+ value: a * c,
319
+ tone: "error"
320
+ });
321
+ let u = {
322
+ unit: s,
323
+ marks: l
324
+ };
325
+ return Number.isFinite(o) && (u.value = o * c), {
326
+ resource: e,
327
+ data: u
328
+ };
329
+ });
330
+ }
331
+ var ue = {
332
+ Pod: [
333
+ "PodScheduled",
334
+ "PodReadyToStartContainers",
335
+ "Initialized",
336
+ "ContainersReady",
337
+ "Ready"
338
+ ],
339
+ Node: [
340
+ "MemoryPressure",
341
+ "DiskPressure",
342
+ "PIDPressure",
343
+ "NetworkUnavailable",
344
+ "Ready"
345
+ ],
346
+ Deployment: [
347
+ "Progressing",
348
+ "Available",
349
+ "ReplicaFailure"
350
+ ]
351
+ }, F = /* @__PURE__ */ new Set([
352
+ "Failed",
353
+ "Stalled",
354
+ "Degraded",
355
+ "FailureTarget",
356
+ "Suspended",
357
+ "Terminating",
358
+ "DisruptionTarget",
359
+ "ReplicaFailure",
360
+ "MemoryPressure",
361
+ "DiskPressure",
362
+ "PIDPressure",
363
+ "NetworkUnavailable"
364
+ ]), de = {
365
+ PodScheduled: "Scheduled",
366
+ PodReadyToStartContainers: "Sandbox",
367
+ ContainersReady: "Containers",
368
+ MemoryPressure: "Memory",
369
+ DiskPressure: "Disk",
370
+ PIDPressure: "PIDs",
371
+ NetworkUnavailable: "Network"
372
+ };
373
+ function I(e) {
374
+ let t = F.has(e.type);
375
+ return e.status === "True" ? !t : e.status === "False" ? t : null;
376
+ }
377
+ var L = (e) => [e.reason, e.message].filter((e) => e != null && e !== "").join(": ");
378
+ function R(e) {
379
+ let t = Array.isArray(e?.status?.conditions) ? e.status.conditions : [], n = ue[e?.kind ?? ""] ?? [], r = (e) => n.includes(e.type) ? n.indexOf(e.type) : n.length, i = M(e?.metadata?.creationTimestamp);
380
+ return [...t].sort((e, t) => r(e) - r(t) || (M(e.lastTransitionTime) || 0) - (M(t.lastTransitionTime) || 0)).map((e) => {
381
+ let t = I(e), n = t === !0 ? "done" : t === !1 ? "failed" : "warning", r = {
382
+ label: de[e.type] ?? e.type,
383
+ status: n
384
+ }, a = M(e.lastTransitionTime);
385
+ Number.isFinite(a) && Number.isFinite(i) && (r.time = `+${j((a - i) / 1e3)}`);
386
+ let o = L(e);
387
+ return o && t !== !0 && (r.detail = o), r;
388
+ });
389
+ }
390
+ var fe = (e, t) => t.uid && e.metadata?.uid === t.uid || e.kind === t.kind && e.metadata?.name === t.name;
391
+ function z(e, t = []) {
392
+ let n = [], r = /* @__PURE__ */ new Set(), i = (e) => {
393
+ let a = e.metadata?.namespace, o = e.metadata?.labels?.["pod-template-hash"];
394
+ for (let s of e.metadata?.ownerReferences ?? []) {
395
+ let e = s.uid || `${s.kind}/${s.name}`;
396
+ if (r.has(e)) continue;
397
+ r.add(e);
398
+ let c = t.find((e) => fe(e, s));
399
+ if (c) i(c);
400
+ else if (s.kind === "ReplicaSet" && o && s.name.endsWith(`-${o}`)) {
401
+ let e = s.name.slice(0, -o.length - 1);
402
+ n.push(O({
403
+ kind: "Deployment",
404
+ name: e,
405
+ namespace: a,
406
+ apiVersion: s.apiVersion ?? "apps/v1"
407
+ }));
408
+ }
409
+ n.push(O({
410
+ kind: s.kind,
411
+ name: s.name,
412
+ namespace: a,
413
+ apiVersion: s.apiVersion
414
+ }));
415
+ }
416
+ };
417
+ return e && i(e), n;
418
+ }
419
+ function B(e) {
420
+ return { ...e?.metadata?.labels ?? {} };
421
+ }
422
+ var V = ["kubectl.kubernetes.io/last-applied-configuration"];
423
+ function H(e) {
424
+ let t = { ...e?.metadata?.annotations ?? {} };
425
+ for (let e of V) delete t[e];
426
+ return t;
427
+ }
428
+ var U = (e) => e == null || e === "" ? void 0 : { code: String(e) }, W = (e, t, n) => n ? {
429
+ text: e,
430
+ tone: t,
431
+ title: n
432
+ } : {
433
+ text: e,
434
+ tone: t
435
+ };
436
+ function G(e, t) {
437
+ let n = N(e, t);
438
+ return n ? [`${n} ago`, { code: e }] : void 0;
439
+ }
440
+ function pe(e, t) {
441
+ let n = e.spec ?? {}, r = e.status ?? {}, i = e.metadata?.namespace, a = (e) => Array.isArray(e) ? e.map((e) => U(e?.ip)) : void 0;
442
+ return [
443
+ {
444
+ key: "Started",
445
+ value: G(r.startTime, t)
446
+ },
447
+ {
448
+ key: "Node",
449
+ value: n.nodeName ? O({
450
+ kind: "Node",
451
+ name: n.nodeName,
452
+ apiVersion: "v1"
453
+ }) : W("unscheduled", "warning")
454
+ },
455
+ {
456
+ key: "Pod IP",
457
+ value: a(r.podIPs) ?? U(r.podIP)
458
+ },
459
+ {
460
+ key: "Host IP",
461
+ value: a(r.hostIPs) ?? U(r.hostIP)
462
+ },
463
+ {
464
+ key: "QoS",
465
+ value: r.qosClass
466
+ },
467
+ {
468
+ key: "Priority",
469
+ value: [n.priorityClassName ? O({
470
+ kind: "PriorityClass",
471
+ name: n.priorityClassName,
472
+ apiVersion: "scheduling.k8s.io/v1"
473
+ }) : void 0, U(n.priority ?? 0)]
474
+ },
475
+ {
476
+ key: "Service account",
477
+ value: n.serviceAccountName ? O({
478
+ kind: "ServiceAccount",
479
+ name: n.serviceAccountName,
480
+ namespace: i,
481
+ apiVersion: "v1"
482
+ }) : void 0
483
+ },
484
+ {
485
+ key: "Restart policy",
486
+ value: n.restartPolicy
487
+ }
488
+ ];
489
+ }
490
+ function me(e) {
491
+ let t = e.spec ?? {}, n = e.metadata?.namespace, r = t.selector?.matchLabels, i = t.template?.spec?.serviceAccountName ?? t.jobTemplate?.spec?.template?.spec?.serviceAccountName;
492
+ return [
493
+ {
494
+ key: "Replicas",
495
+ value: J(e)?.text
496
+ },
497
+ {
498
+ key: "Strategy",
499
+ value: t.strategy?.type ?? t.updateStrategy?.type
500
+ },
501
+ {
502
+ key: "Schedule",
503
+ value: U(t.schedule)
504
+ },
505
+ {
506
+ key: "Selector",
507
+ value: r ? Object.entries(r).map(([e, t]) => U(`${e}=${t}`)) : void 0
508
+ },
509
+ {
510
+ key: "Service account",
511
+ value: i ? O({
512
+ kind: "ServiceAccount",
513
+ name: i,
514
+ namespace: n,
515
+ apiVersion: "v1"
516
+ }) : void 0
517
+ }
518
+ ];
519
+ }
520
+ var he = "node-role.kubernetes.io/";
521
+ function ge(e) {
522
+ let t = e.status ?? {}, n = t.nodeInfo ?? {}, r = (e) => (Array.isArray(t.addresses) ? t.addresses : []).filter((t) => t?.type === e).map((e) => U(e.address)), i = t.capacity ?? {}, a = A(i.memory);
523
+ return [
524
+ {
525
+ key: "Roles",
526
+ value: Object.keys(e.metadata?.labels ?? {}).filter((e) => e.startsWith(he)).map((e) => e.slice(24)).join(", ")
527
+ },
528
+ {
529
+ key: "Internal IP",
530
+ value: r("InternalIP")
531
+ },
532
+ {
533
+ key: "External IP",
534
+ value: r("ExternalIP")
535
+ },
536
+ {
537
+ key: "Kubelet",
538
+ value: U(n.kubeletVersion)
539
+ },
540
+ {
541
+ key: "OS",
542
+ value: [n.osImage, n.architecture].filter(Boolean).join(" · ")
543
+ },
544
+ {
545
+ key: "Kernel",
546
+ value: U(n.kernelVersion)
547
+ },
548
+ {
549
+ key: "Runtime",
550
+ value: U(n.containerRuntimeVersion)
551
+ },
552
+ {
553
+ key: "CPU",
554
+ value: i.cpu === void 0 ? void 0 : `${i.cpu} cores`
555
+ },
556
+ {
557
+ key: "Memory",
558
+ value: Number.isFinite(a) ? `${(a / 2 ** 30).toFixed(1)} Gi` : void 0
559
+ },
560
+ {
561
+ key: "Pods",
562
+ value: i.pods
563
+ }
564
+ ];
565
+ }
566
+ function K(e, t = {}) {
567
+ if (!e) return [];
568
+ let n = t.now ?? Date.now(), r = e.metadata ?? {}, i = e.kind ?? "", a = [
569
+ {
570
+ key: "Kind",
571
+ value: i && e.apiVersion ? ie(i, e.apiVersion) : i
572
+ },
573
+ {
574
+ key: "Namespace",
575
+ value: r.namespace ? k(r.namespace) : void 0
576
+ },
577
+ {
578
+ key: "Created",
579
+ value: G(r.creationTimestamp, n)
580
+ },
581
+ {
582
+ key: "Deleting",
583
+ value: r.deletionTimestamp ? W("terminating", "warning", r.deletionTimestamp) : void 0
584
+ },
585
+ {
586
+ key: "Controlled by",
587
+ value: z(e, t.related)
588
+ }
589
+ ];
590
+ return i === "Pod" ? a.push(...pe(e, n)) : i in b ? a.push(...me(e)) : i === "Node" && a.push(...ge(e)), a.push({
591
+ key: "UID",
592
+ value: U(r.uid)
593
+ }, {
594
+ key: "Finalizers",
595
+ value: (r.finalizers ?? []).map((e) => U(e))
596
+ }), a;
597
+ }
598
+ var _e = [
599
+ [/^(Running|Bound|Succeeded|Active|Available)$/, "success"],
600
+ [/^(Pending|Terminating|Released)$/, "warning"],
601
+ [/^(Failed|Lost)$/, "error"]
602
+ ], q = (e) => _e.find(([t]) => t.test(e))?.[1] ?? "neutral";
603
+ function J(e) {
604
+ let t = e.status ?? {}, n = e.kind, r, i;
605
+ if (n === "DaemonSet" ? (r = t.numberReady ?? 0, i = t.desiredNumberScheduled ?? 0) : (n === "Deployment" || n === "StatefulSet" || n === "ReplicaSet") && (r = t.readyReplicas ?? 0, i = e.spec?.replicas ?? 1), r !== void 0 && i !== void 0) return W(`${r}/${i} ready`, r >= i ? "success" : "warning");
606
+ }
607
+ function ve(e) {
608
+ let t = e.status ?? {}, n = new Set((e.spec?.initContainers ?? []).filter((e) => e.restartPolicy === "Always").map((e) => e.name)), r = [...t.containerStatuses ?? [], ...(t.initContainerStatuses ?? []).filter((e) => n.has(e.name))], i = [
609
+ ...t.initContainerStatuses ?? [],
610
+ ...t.containerStatuses ?? [],
611
+ ...t.ephemeralContainerStatuses ?? []
612
+ ], a = r.filter((e) => e.ready).length, o = i.reduce((e, t) => e + (t.restartCount ?? 0), 0), s = e.metadata?.deletionTimestamp ? "Terminating" : t.phase ?? "Unknown", c = s === "Succeeded" ? "neutral" : q(s), l = r.length || (e.spec?.containers ?? []).length;
613
+ return [
614
+ W(s, c, t.message ?? t.reason),
615
+ W(`${a}/${l} ready`, a === l ? "success" : "warning"),
616
+ o > 0 ? W(`↻ ${o}`, "warning", "restarts") : void 0
617
+ ];
618
+ }
619
+ function ye(e) {
620
+ let t = (e.status?.conditions ?? []).find((e) => e.type === "Ready"), n = (e.status?.conditions ?? []).filter((e) => e.type !== "Ready" && I(e) === !1);
621
+ return [
622
+ t ? W(t.status === "True" ? "Ready" : "NotReady", t.status === "True" ? "success" : "error", L(t)) : void 0,
623
+ e.spec?.unschedulable ? W("cordoned", "warning", "unschedulable") : void 0,
624
+ ...n.map((e) => W(`✗ ${e.type}`, "error", L(e)))
625
+ ];
626
+ }
627
+ function be(e) {
628
+ let t = e.status ?? {}, n = Array.isArray(t.conditions) ? t.conditions : [], r = n.filter((e) => I(e) === !0), i = [
629
+ "Ready",
630
+ "Available",
631
+ "Complete"
632
+ ].find((e) => r.some((t) => t.type === e)) ?? r[0]?.type;
633
+ return [
634
+ typeof t.phase == "string" ? W(t.phase, q(t.phase), "phase") : void 0,
635
+ Y(e) in b ? J(e) : void 0,
636
+ r.length ? W(`✓ ${i}${r.length > 1 ? ` +${r.length - 1}` : ""}`, "success", r.map((e) => e.type).join(", ")) : void 0,
637
+ ...n.filter((e) => I(e) !== !0).map((e) => I(e) === null ? W(`? ${e.type}`, "warning", L(e)) : W(`✗ ${e.type}`, "error", L(e)))
638
+ ];
639
+ }
640
+ var Y = (e) => e.kind ?? "";
641
+ function X(e) {
642
+ return e ? (Y(e) === "Pod" ? ve(e) : Y(e) === "Node" ? ye(e) : be(e)).filter((e) => e !== void 0) : [];
643
+ }
644
+ function Z(e, t = {}) {
645
+ if (!e) return { title: "" };
646
+ let n = e.metadata?.namespace;
647
+ return {
648
+ icon: y(e.kind, e.apiVersion),
649
+ eyebrow: n ? [`${Y(e)} ·`, k(n, { icon: !1 })] : Y(e),
650
+ title: e.metadata?.name ?? "",
651
+ chips: X(e),
652
+ chain: z(e, t.related)
653
+ };
654
+ }
655
+ function xe(e) {
656
+ let { managedFields: t, ...n } = e.metadata ?? {}, r = {
657
+ ...e,
658
+ metadata: n
659
+ };
660
+ if (n.annotations) {
661
+ let t = H(e);
662
+ Object.keys(t).length ? n.annotations = t : delete n.annotations;
663
+ }
664
+ return r;
665
+ }
666
+ //#endregion
667
+ //#region src/k8s/events.ts
668
+ var Q = /^(BackOff|Failed|Unhealthy|Evicted|OOM|Killing|Preempt|ExceededGracePeriod|NetworkNotReady|NodeNotReady|InspectFailed|ErrImage|ProbeWarning|FreeDiskSpaceFailed|BadConfig|Error)/;
669
+ function Se(e) {
670
+ return e.type === "Warning" || Q.test(e.reason ?? "");
671
+ }
672
+ var Ce = (e) => typeof e == "object" && !!e && Array.isArray(e.fields);
673
+ function we(e) {
674
+ let t = e.fields.map((e) => ({
675
+ name: e.name,
676
+ values: Array.from("toArray" in e.values && typeof e.values.toArray == "function" ? e.values.toArray() : e.values)
677
+ })), n = Math.max(0, ...t.map((e) => e.values.length));
678
+ return Array.from({ length: n }, (e, n) => Object.fromEntries(t.map((e) => [e.name, e.values[n]])));
679
+ }
680
+ function Te(e) {
681
+ let t = [], n = (e) => {
682
+ Array.isArray(e) ? e.forEach(n) : Ce(e) ? we(e).forEach(n) : typeof e == "object" && e && (e.Line !== void 0 || e.body !== void 0) && t.push(e);
683
+ };
684
+ return n(e), t;
685
+ }
686
+ function Ee(e) {
687
+ let t = e.labels;
688
+ if (typeof t == "string") try {
689
+ return JSON.parse(t) ?? {};
690
+ } catch {
691
+ return {};
692
+ }
693
+ return t ?? {};
694
+ }
695
+ function De(e) {
696
+ if (e.tsNs) return Number(e.tsNs) / 1e6;
697
+ let t = e.Time ?? e.timestamp;
698
+ if (typeof t == "number") return t;
699
+ if (typeof t == "string") {
700
+ let e = Number(t);
701
+ return Number.isFinite(e) ? e > 0x5af3107a4000 ? e / 1e6 : e : Date.parse(t);
702
+ }
703
+ return NaN;
704
+ }
705
+ function Oe(e) {
706
+ let t = /* @__PURE__ */ new Map();
707
+ for (let n of Te(e)) {
708
+ let e = Ee(n), r = String(n.Line ?? n.body ?? ""), i = [
709
+ e.kind ?? "",
710
+ e.namespace ?? "",
711
+ e.name ?? "",
712
+ e.reason ?? "",
713
+ r
714
+ ].join("\0"), a = De(n), o = t.get(i);
715
+ o || (o = {
716
+ kind: e.kind ?? "",
717
+ name: e.name ?? "",
718
+ namespace: e.namespace ?? "",
719
+ apiVersion: e.objectAPIversion ?? "",
720
+ reason: e.reason ?? "",
721
+ message: r,
722
+ source: e.sourcecomponent || e.reportingcontroller || "",
723
+ warning: Se(e),
724
+ count: 0,
725
+ first: a,
726
+ last: a
727
+ }, t.set(i, o)), o.count += 1, Number.isFinite(a) && (o.first = Number.isFinite(o.first) ? Math.min(o.first, a) : a, o.last = Number.isFinite(o.last) ? Math.max(o.last, a) : a);
728
+ }
729
+ return [...t.values()].sort((e, t) => (t.last || 0) - (e.last || 0));
730
+ }
731
+ function ke(e, t = {}) {
732
+ let n = t.now ?? Date.now(), r = [
733
+ {
734
+ key: "reason",
735
+ label: "Reason",
736
+ nowrap: !0
737
+ },
738
+ ...t.namespace ? [{
739
+ key: "namespace",
740
+ label: "Namespace"
741
+ }] : [],
742
+ ...t.object ? [{
743
+ key: "object",
744
+ label: "Object"
745
+ }] : [],
746
+ {
747
+ key: "message",
748
+ label: "Message"
749
+ },
750
+ {
751
+ key: "count",
752
+ label: "",
753
+ align: "right",
754
+ nowrap: !0
755
+ },
756
+ {
757
+ key: "last",
758
+ label: "Last seen",
759
+ nowrap: !0
760
+ }
761
+ ], i = (e) => Number.isFinite(e) ? `${j((n - e) / 1e3)} ago` : "";
762
+ return {
763
+ columns: r,
764
+ rows: e.map((e) => ({
765
+ reason: {
766
+ text: e.reason || "?",
767
+ tone: e.warning ? "error" : "info",
768
+ title: `${e.warning ? "Warning" : "Normal"}${e.source ? ` · from ${e.source}` : ""}`
769
+ },
770
+ namespace: e.namespace ? k(e.namespace) : "",
771
+ object: e.kind && e.name ? O({
772
+ kind: e.kind,
773
+ name: e.name,
774
+ namespace: e.namespace || void 0,
775
+ apiVersion: e.apiVersion || void 0
776
+ }) : "",
777
+ message: e.message,
778
+ count: e.count > 1 ? `×${e.count}` : "",
779
+ last: e.count > 1 && e.first !== e.last ? [i(e.last), `(first ${i(e.first).replace(/ ago$/, "")})`] : i(e.last)
780
+ }))
781
+ };
782
+ }
783
+ //#endregion
784
+ //#region src/k8s/elements/events.ts
785
+ var Ae = class extends a {
786
+ static properties = {
787
+ data: {
788
+ attribute: "data",
789
+ converter: i
790
+ },
791
+ object: { type: Boolean },
792
+ namespace: { type: Boolean },
793
+ now: { type: Number },
794
+ empty: {}
795
+ };
796
+ static styles = n;
797
+ #e = [];
798
+ get groups() {
799
+ return this.#e;
800
+ }
801
+ get count() {
802
+ return this.#e.length;
803
+ }
804
+ get warnings() {
805
+ return this.#e.filter((e) => e.warning).length;
806
+ }
807
+ #t() {
808
+ if (typeof this.now == "number" && Number.isFinite(this.now)) return this.now;
809
+ let e = l(this)?.toIso, t = e ? Date.parse(e) : NaN;
810
+ return Number.isFinite(t) ? t : Date.now();
811
+ }
812
+ willUpdate(e) {
813
+ e.has("data") && (this.#e = Oe(this.data));
814
+ }
815
+ updated() {
816
+ let e = this.parentElement;
817
+ e?.parentElement?.localName === "kd-tabs" && e.getAttribute("count") !== String(this.count) && e.setAttribute("count", String(this.count));
818
+ }
819
+ render() {
820
+ if (this.data === void 0 || this.data === null) return r;
821
+ let t = ke(this.#e, {
822
+ object: this.object,
823
+ namespace: this.namespace,
824
+ now: this.#t()
825
+ });
826
+ return e`<kd-table .data=${t} empty=${this.empty ?? "No events in this time range"}></kd-table>`;
827
+ }
828
+ };
829
+ s("kd-k8s-events", Ae);
830
+ //#endregion
831
+ //#region src/k8s/elements/object.ts
832
+ var je = class extends a {
833
+ static properties = {
834
+ data: {
835
+ attribute: "data",
836
+ converter: i
837
+ },
838
+ events: { attribute: !1 },
839
+ related: { attribute: !1 },
840
+ key: {},
841
+ now: { type: Number }
842
+ };
843
+ static styles = [n, t`
844
+ .page {
845
+ display: flex;
846
+ flex-direction: column;
847
+ gap: 16px;
848
+ }
849
+ `];
850
+ render() {
851
+ let t = this.data;
852
+ if (!t || typeof t != "object") return r;
853
+ let n = {
854
+ now: this.now,
855
+ related: this.related
856
+ }, i = R(t), a = B(t), o = H(t), s = (e) => String(Object.keys(e).length);
857
+ return e`<div class="page">
858
+ <kd-bar .data=${Z(t, n)}></kd-bar>
859
+ ${i.length ? e`<kd-steps .data=${i}></kd-steps>` : r}
860
+ <kd-tabs key=${this.key ?? r}>
861
+ <section label="Summary"><kd-sheet .data=${K(t, n)}></kd-sheet></section>
862
+ <section label="Labels" count=${s(a)}><kd-groups mode="pills" .data=${a}></kd-groups></section>
863
+ <section label="Annotations" count=${s(o)}><kd-groups mode="tree" .data=${o}></kd-groups></section>
864
+ ${this.events === void 0 ? r : e`<section label="Events"><kd-k8s-events .data=${this.events} .now=${this.now}></kd-k8s-events></section>`}
865
+ <section label="YAML"><kd-data fold="0" .data=${xe(t)}></kd-data></section>
866
+ </kd-tabs>
867
+ </div>`;
868
+ }
869
+ };
870
+ s("kd-k8s-object", je);
871
+ //#endregion
872
+ //#region src/k8s/elements/ref.ts
873
+ var $ = class extends a {
874
+ static properties = {
875
+ data: {
876
+ attribute: "data",
877
+ converter: i
878
+ },
879
+ kind: {},
880
+ name: {},
881
+ namespace: {},
882
+ apiVersion: { attribute: "api-version" },
883
+ plural: {}
884
+ };
885
+ static styles = [n, t`
886
+ :host {
887
+ display: inline;
888
+ }
889
+ `];
890
+ get ref() {
891
+ let e = this.data ?? {}, t = e.kind ?? this.kind, n = e.name ?? e.metadata?.name ?? this.name;
892
+ if (t && n) return {
893
+ kind: t,
894
+ name: n,
895
+ namespace: e.namespace ?? e.metadata?.namespace ?? this.namespace,
896
+ apiVersion: e.apiVersion ?? this.apiVersion,
897
+ plural: e.plural ?? this.plural
898
+ };
899
+ }
900
+ render() {
901
+ let t = this.ref;
902
+ return t ? e`<kd-link .data=${O(t)}></kd-link>` : r;
903
+ }
904
+ };
905
+ s("kd-k8s-ref", $);
906
+ //#endregion
907
+ export { te as CRD_ICON, x as DASHBOARDS, m as DEFAULT_ICON, g as GROUP_ICONS, V as HIDDEN_ANNOTATIONS, h as KIND_ICONS, Ae as KdK8sEvents, je as KdK8sObject, $ as KdK8sRef, F as NEGATIVE_CONDITIONS, c as VERSION, Q as WARNING_REASONS, b as WORKLOAD_KINDS, N as age, H as annotations, _ as apiGroup, C as apiPath, o as applyTheme, Z as bar, X as chips, I as conditionOk, R as conditions, E as definitionRoute, j as duration, Te as eventRows, ke as eventsTable, Oe as foldEvents, v as isBuiltInGroup, Se as isWarning, y as kindIcon, ie as kindLink, B as labels, k as namespaceLink, w as namespaceRoute, z as owners, S as plural, A as quantity, O as refLink, le as resources, T as route, K as summary, xe as trimmed };
908
+
909
+ //# sourceMappingURL=k8s.js.map