@kong-ui-public/analytics-metric-provider 11.0.3-pr.2637.cd79373fe.0 → 11.0.3-pr.2686.97d4ee647.0

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.
@@ -1,4 +1,4 @@
1
- import { ref as Y, watchEffect as Ne, computed as g, getCurrentInstance as ke, reactive as Fe, onMounted as xe, onUnmounted as qe, watch as Ue, isReadonly as Pe, toRefs as $e, defineComponent as W, inject as Se, toRef as G, provide as ze, renderSlot as Ce, resolveComponent as Ie, createElementBlock as S, openBlock as R, normalizeClass as z, createElementVNode as q, createCommentVNode as M, createBlock as U, unref as E, resolveDynamicComponent as re, withCtx as me, createTextVNode as Ae, toDisplayString as w, createVNode as F, Fragment as ye, renderList as Ke, mergeProps as Be, normalizeProps as Xe, guardReactiveProps as Ge } from "vue";
1
+ import { ref as Y, watchEffect as ke, computed as p, getCurrentInstance as Me, reactive as Fe, onMounted as xe, onUnmounted as qe, watch as Ue, isReadonly as Pe, toRefs as $e, defineComponent as W, inject as Ce, toRef as G, provide as ze, renderSlot as Se, resolveComponent as Ie, createElementBlock as S, openBlock as T, normalizeClass as z, createElementVNode as q, createCommentVNode as V, createBlock as U, unref as C, resolveDynamicComponent as re, withCtx as me, createTextVNode as Ae, toDisplayString as w, createVNode as F, Fragment as ge, renderList as Ke, mergeProps as Be, normalizeProps as Xe, guardReactiveProps as Ge } from "vue";
2
2
  import { stripUnknownFilters as je, queryableExploreDimensions as He } from "@kong-ui-public/analytics-utilities";
3
3
  import { createI18n as Ye, i18nTComponent as Qe } from "@kong-ui-public/i18n";
4
4
  import "axios";
@@ -55,19 +55,19 @@ function cr() {
55
55
  // Translation component <i18n-t>
56
56
  };
57
57
  }
58
- const dr = 2, B = ["1XX", "2XX", "3XX", "4XX", "5XX"], ge = ["4XX", "5XX"], yt = ["1XX", "2XX", "3XX"], fr = 30 * 1e3, vr = "analytics-query-provider";
58
+ const dr = 2, B = ["1XX", "2XX", "3XX", "4XX", "5XX"], ye = ["4XX", "5XX"], mt = ["1XX", "2XX", "3XX"], fr = 30 * 1e3, vr = "analytics-query-provider";
59
59
  var we = /* @__PURE__ */ ((e) => (e.VALIDATING = "VALIDATING", e.VALIDATING_HAS_DATA = "VALIDATING_HAS_DATA", e.PENDING = "PENDING", e.SUCCESS = "SUCCESS", e.SUCCESS_HAS_DATA = "SUCCESS_HAS_DATA", e.ERROR = "ERROR", e.STALE_IF_ERROR = "STALE_IF_ERROR", e))(we || {});
60
60
  const mr = (e) => {
61
61
  var r, t, o, a, n;
62
62
  return e ? !!// TODO: revisit: currently only the first check ever matters?
63
63
  ((r = Object.keys(e)) != null && r.length || (t = e.data) != null && t.length || (a = (o = e.data) == null ? void 0 : o.data) != null && a.length || !((n = e.data) != null && n.data) && typeof e.data == "object" && Object.keys(e == null ? void 0 : e.data).length) : !1;
64
64
  };
65
- function yr(e = Y({}), r, t, o = mr) {
65
+ function gr(e = Y({}), r, t, o = mr) {
66
66
  const a = Y(
67
67
  "PENDING"
68
68
  /* PENDING */
69
69
  );
70
- return Ne(() => {
70
+ return ke(() => {
71
71
  const n = o(e.value);
72
72
  if (e.value && n && t.value) {
73
73
  a.value = "VALIDATING_HAS_DATA";
@@ -102,71 +102,78 @@ function yr(e = Y({}), r, t, o = mr) {
102
102
  const L = Symbol("default"), te = "status_code_grouped", he = (e, r, t, o, a) => {
103
103
  e[r][t] || (e[r][t] = {}), e[r][t][o] = a;
104
104
  };
105
- function gr(e, r) {
105
+ function yr(e, r) {
106
106
  var d;
107
- const t = ((d = e.meta.metric_names) == null ? void 0 : d[0]) || "", o = e.meta.start_ms, a = Object.keys(e.meta.display || {}), n = !!a.find((f) => f === te), l = a.find((f) => f !== te);
107
+ const t = ((d = e.meta.metric_names) == null ? void 0 : d[0]) || "", o = e.meta.start_ms, a = Object.keys(e.meta.display || {}), n = !!a.find((f) => f === te), u = a.find((f) => f !== te);
108
108
  return a.length > 2 || a.length > 1 && !n ? (console.error("Don't know how to work with provided dimensions:", a), {
109
109
  previous: { [L]: { [L]: 0 } },
110
110
  current: { [L]: { [L]: 0 } }
111
111
  }) : e.data.reduce((f, i) => {
112
- const s = i.event[t], u = l ? i.event[l] : L, c = n ? i.event[te] : L;
113
- return new Date(i.timestamp).getTime() === o && r ? he(f, "previous", u, c, s) : he(f, "current", u, c, s), f;
112
+ const s = i.event[t], l = u ? i.event[u] : L, c = n ? i.event[te] : L;
113
+ return new Date(i.timestamp).getTime() === o && r ? he(f, "previous", l, c, s) : he(f, "current", l, c, s), f;
114
114
  }, {
115
115
  previous: {},
116
116
  current: {}
117
117
  });
118
118
  }
119
119
  function hr(e) {
120
- e.queryReady === void 0 && (e.queryReady = g(() => !0));
121
- const r = g(() => {
122
- var s, u;
120
+ e.queryReady === void 0 && (e.queryReady = p(() => !0));
121
+ const { i18n: r } = M.useI18n(), t = p(() => {
122
+ var l, c;
123
123
  return {
124
124
  metrics: e.metrics.value,
125
125
  dimensions: [
126
- ...(s = e.dimensions) != null && s.length ? [...e.dimensions] : [],
126
+ ...(l = e.dimensions) != null && l.length ? [...e.dimensions] : [],
127
127
  ...e.withTrend.value ? ["time"] : []
128
128
  ],
129
129
  granularity: e.withTrend.value ? "trend" : void 0,
130
- ...(u = e.filter.value) != null && u.length ? { filters: e.filter.value } : {},
130
+ ...(c = e.filter.value) != null && c.length ? { filters: e.filter.value } : {},
131
131
  time_range: e.timeRange.value
132
132
  };
133
- }), t = g(() => {
134
- var u, c, v, p;
135
- if (!((u = e.queryReady) != null && u.value))
133
+ }), o = p(() => {
134
+ var c, v, h, R;
135
+ if (!((c = e.queryReady) != null && c.value))
136
136
  return null;
137
- const s = (c = e.filter) != null && c.value ? JSON.stringify(e.filter.value) : "";
138
- return `metric-fetcher-${JSON.stringify(e.timeRange.value)}-${(v = e.dimensions) == null ? void 0 : v.join("-")}-${(p = e.metrics.value) == null ? void 0 : p.join("-")}-${s}-${e.refreshCounter.value}`;
139
- }), { response: o, error: a, isValidating: n } = V.useRequest(
140
- () => t.value,
137
+ const l = (v = e.filter) != null && v.value ? JSON.stringify(e.filter.value) : "";
138
+ return `metric-fetcher-${JSON.stringify(e.timeRange.value)}-${(h = e.dimensions) == null ? void 0 : h.join("-")}-${(R = e.metrics.value) == null ? void 0 : R.join("-")}-${l}-${e.refreshCounter.value}`;
139
+ }), { response: a, error: n, isValidating: u } = M.useRequest(
140
+ () => o.value,
141
141
  () => e.queryFn({
142
142
  // TODO: Use a type guard to validate that if the datasource is basic,
143
143
  // the query is a valid basic explore query.
144
144
  datasource: e.datasource.value,
145
- query: r.value
145
+ query: t.value
146
146
  }, e.abortController ?? new AbortController()),
147
147
  {
148
148
  refreshInterval: e.refreshInterval,
149
149
  revalidateOnFocus: !1,
150
150
  errorRetryCount: dr
151
151
  }
152
- ), { state: l, swrvState: d } = yr(o, a, n), f = g(() => {
153
- var s, u, c, v, p, _, h;
154
- return !((u = (s = o.value) == null ? void 0 : s.data) != null && u.length) || !((v = (c = o.value) == null ? void 0 : c.meta) != null && v.display) || !((h = (_ = (p = o.value) == null ? void 0 : p.meta) == null ? void 0 : _.metric_names) != null && h.length) ? { current: {}, previous: {} } : gr(o.value, e.withTrend.value);
155
- }), i = V.useTrendRange(e.withTrend, e.timeRange, g(() => {
156
- var s;
157
- return (s = o.value) == null ? void 0 : s.meta;
158
- }));
152
+ ), { state: d, swrvState: f } = gr(a, n, u), i = p(() => {
153
+ var l, c, v, h, R, y, _;
154
+ return !((c = (l = a.value) == null ? void 0 : l.data) != null && c.length) || !((h = (v = a.value) == null ? void 0 : v.meta) != null && h.display) || !((_ = (y = (R = a.value) == null ? void 0 : R.meta) == null ? void 0 : y.metric_names) != null && _.length) ? { current: {}, previous: {} } : yr(a.value, e.withTrend.value);
155
+ }), s = p(() => {
156
+ var l, c;
157
+ if (e.timeRange.value.type === "absolute") {
158
+ if (!((c = (l = a.value) == null ? void 0 : l.meta) != null && c.start_ms))
159
+ return "";
160
+ const { start_ms: v, end_ms: h } = a.value.meta;
161
+ let R = (h - v) / (1e3 * 60 * 60 * 24), y = (h - v) / (1e3 * 60 * 60), _ = (h - v) / (1e3 * 60);
162
+ return e.withTrend.value && (R /= 2, y /= 2, _ /= 2), R >= 1 ? r.t("trendRange.custom_days", { numDays: Math.round(R) }) : y >= 1 ? r.t("trendRange.custom_hours", { numHours: Math.round(y) }) : _ >= 1 ? r.t("trendRange.custom_minutes", { numMinutes: Math.round(_) }) : r.t("trendRange.custom_days", { numDays: Math.round(R) });
163
+ } else
164
+ return e.withTrend.value ? r.t(`trendRange.${e.timeRange.value.time_range}`) : "";
165
+ });
159
166
  return {
160
- isLoading: g(() => d.PENDING === l.value),
161
- hasError: g(() => d.ERROR === l.value),
162
- raw: o,
163
- mapped: f,
164
- trendRange: i
167
+ isLoading: p(() => f.PENDING === d.value),
168
+ hasError: p(() => f.ERROR === d.value),
169
+ raw: a,
170
+ mapped: i,
171
+ trendRange: s
165
172
  };
166
173
  }
167
- const K = (e, r, t = L, o) => (o ?? [L]).reduce((n, l) => {
174
+ const K = (e, r, t = L, o) => (o ?? [L]).reduce((n, u) => {
168
175
  const d = e[r][t];
169
- return d ? n + (d[l] || 0) : n;
176
+ return d ? n + (d[u] || 0) : n;
170
177
  }, 0);
171
178
  function pr(e) {
172
179
  const {
@@ -175,19 +182,19 @@ function pr(e) {
175
182
  description: o,
176
183
  record: a,
177
184
  hasError: n,
178
- increaseIsBad: l,
185
+ increaseIsBad: u,
179
186
  formatValueFn: d,
180
187
  trendRange: f
181
188
  } = e;
182
- return g(() => {
189
+ return p(() => {
183
190
  let i = 0, s = 0;
184
191
  if (a != null && a.value)
185
192
  try {
186
193
  i = K(a.value, "current", e.lookupKey, e.sumGroupedValues), s = K(a.value, "previous", e.lookupKey, e.sumGroupedValues);
187
- } catch (u) {
194
+ } catch (l) {
188
195
  console.error(
189
196
  "Metric card data doesn't have the expected structure:",
190
- u
197
+ l
191
198
  );
192
199
  }
193
200
  return {
@@ -197,46 +204,15 @@ function pr(e) {
197
204
  previousValue: s,
198
205
  title: t.value,
199
206
  description: o,
200
- increaseIsBad: !!l,
207
+ increaseIsBad: !!u,
201
208
  // Coerce undefined to false
202
209
  formatValueFn: d,
203
210
  trendRange: f == null ? void 0 : f.value
204
211
  };
205
212
  });
206
213
  }
207
- function Rr(e, r, t) {
208
- const { i18n: o } = V.useI18n(), a = 1e3 * 60, n = a * 60, l = n * 24, d = (i, s) => {
209
- let u = s - i;
210
- e.value && (u /= 2);
211
- const c = u / l, v = u / n, p = u / a;
212
- return c >= 1 ? o.t("trendRange.custom_days", { numDays: Math.round(c) }) : v >= 1 ? o.t("trendRange.custom_hours", { numHours: Math.round(v) }) : p >= 1 ? o.t("trendRange.custom_minutes", { numMinutes: Math.round(p) }) : o.t("trendRange.custom_days", { numDays: Math.round(c) });
213
- }, f = () => {
214
- var i, s;
215
- if ((i = t == null ? void 0 : t.value) != null && i.start_ms && t.value.end_ms)
216
- return {
217
- startMs: t.value.start_ms,
218
- endMs: t.value.end_ms
219
- };
220
- if (((s = r == null ? void 0 : r.value) == null ? void 0 : s.type) === "absolute" && r.value.start && r.value.end)
221
- return {
222
- startMs: new Date(r.value.start).getTime(),
223
- endMs: new Date(r.value.end).getTime()
224
- };
225
- };
226
- return g(() => {
227
- var i, s;
228
- if (((i = r == null ? void 0 : r.value) == null ? void 0 : i.type) === "relative" && e.value)
229
- return o.t(`trendRange.${r.value.time_range}`);
230
- if (e.value || ((s = r == null ? void 0 : r.value) == null ? void 0 : s.type) === "absolute") {
231
- const u = f();
232
- if (u)
233
- return d(u.startMs, u.endMs);
234
- }
235
- return "";
236
- });
237
- }
238
214
  var ne = /* @__PURE__ */ new WeakMap(), pe = 0;
239
- function Tr(e) {
215
+ function Rr(e) {
240
216
  if (!e.length)
241
217
  return "";
242
218
  for (var r = "arg", t = 0; t < e.length; ++t) {
@@ -245,14 +221,14 @@ function Tr(e) {
245
221
  }
246
222
  return r;
247
223
  }
248
- function Er(e) {
224
+ function Tr(e) {
249
225
  if (typeof e == "function")
250
226
  try {
251
227
  e = e();
252
228
  } catch {
253
229
  e = "";
254
230
  }
255
- return Array.isArray(e) ? e = Tr(e) : e = String(e || ""), e;
231
+ return Array.isArray(e) ? e = Rr(e) : e = String(e || ""), e;
256
232
  }
257
233
  var se = (
258
234
  /** @class */
@@ -261,32 +237,32 @@ var se = (
261
237
  r === void 0 && (r = 0), this.items = /* @__PURE__ */ new Map(), this.ttl = r;
262
238
  }
263
239
  return e.prototype.serializeKey = function(r) {
264
- return Er(r);
240
+ return Tr(r);
265
241
  }, e.prototype.get = function(r) {
266
242
  var t = this.serializeKey(r);
267
243
  return this.items.get(t);
268
244
  }, e.prototype.set = function(r, t, o) {
269
- var a = this.serializeKey(r), n = o || this.ttl, l = Date.now(), d = {
245
+ var a = this.serializeKey(r), n = o || this.ttl, u = Date.now(), d = {
270
246
  data: t,
271
- createdAt: l,
272
- expiresAt: n ? l + n : 1 / 0
247
+ createdAt: u,
248
+ expiresAt: n ? u + n : 1 / 0
273
249
  };
274
250
  this.dispatchExpire(n, d, a), this.items.set(a, d);
275
251
  }, e.prototype.dispatchExpire = function(r, t, o) {
276
252
  var a = this;
277
253
  r && setTimeout(function() {
278
- var n = Date.now(), l = n >= t.expiresAt;
279
- l && a.delete(o);
254
+ var n = Date.now(), u = n >= t.expiresAt;
255
+ u && a.delete(o);
280
256
  }, r);
281
257
  }, e.prototype.delete = function(r) {
282
258
  this.items.delete(r);
283
259
  }, e;
284
260
  }()
285
261
  );
286
- function _r() {
262
+ function Er() {
287
263
  return typeof navigator.onLine < "u" ? navigator.onLine : !0;
288
264
  }
289
- function Sr() {
265
+ function _r() {
290
266
  return typeof document < "u" && typeof document.visibilityState < "u" ? document.visibilityState !== "hidden" : !0;
291
267
  }
292
268
  var Cr = function(e) {
@@ -295,8 +271,8 @@ var Cr = function(e) {
295
271
  });
296
272
  };
297
273
  const ae = {
298
- isOnline: _r,
299
- isDocumentVisible: Sr,
274
+ isOnline: Er,
275
+ isDocumentVisible: _r,
300
276
  fetcher: Cr
301
277
  };
302
278
  var b = function() {
@@ -309,23 +285,23 @@ var b = function() {
309
285
  }, b.apply(this, arguments);
310
286
  }, P = function(e, r, t, o) {
311
287
  function a(n) {
312
- return n instanceof t ? n : new t(function(l) {
313
- l(n);
288
+ return n instanceof t ? n : new t(function(u) {
289
+ u(n);
314
290
  });
315
291
  }
316
- return new (t || (t = Promise))(function(n, l) {
292
+ return new (t || (t = Promise))(function(n, u) {
317
293
  function d(s) {
318
294
  try {
319
295
  i(o.next(s));
320
- } catch (u) {
321
- l(u);
296
+ } catch (l) {
297
+ u(l);
322
298
  }
323
299
  }
324
300
  function f(s) {
325
301
  try {
326
302
  i(o.throw(s));
327
- } catch (u) {
328
- l(u);
303
+ } catch (l) {
304
+ u(l);
329
305
  }
330
306
  }
331
307
  function i(s) {
@@ -337,10 +313,10 @@ var b = function() {
337
313
  var t = { label: 0, sent: function() {
338
314
  if (n[0] & 1) throw n[1];
339
315
  return n[1];
340
- }, trys: [], ops: [] }, o, a, n, l;
341
- return l = { next: d(0), throw: d(1), return: d(2) }, typeof Symbol == "function" && (l[Symbol.iterator] = function() {
316
+ }, trys: [], ops: [] }, o, a, n, u;
317
+ return u = { next: d(0), throw: d(1), return: d(2) }, typeof Symbol == "function" && (u[Symbol.iterator] = function() {
342
318
  return this;
343
- }), l;
319
+ }), u;
344
320
  function d(i) {
345
321
  return function(s) {
346
322
  return f([i, s]);
@@ -392,23 +368,23 @@ var b = function() {
392
368
  if (i[0] & 5) throw i[1];
393
369
  return { value: i[0] ? i[1] : void 0, done: !0 };
394
370
  }
395
- }, Ir = function(e, r) {
371
+ }, Sr = function(e, r) {
396
372
  var t = typeof Symbol == "function" && e[Symbol.iterator];
397
373
  if (!t) return e;
398
- var o = t.call(e), a, n = [], l;
374
+ var o = t.call(e), a, n = [], u;
399
375
  try {
400
376
  for (; (r === void 0 || r-- > 0) && !(a = o.next()).done; ) n.push(a.value);
401
377
  } catch (d) {
402
- l = { error: d };
378
+ u = { error: d };
403
379
  } finally {
404
380
  try {
405
381
  a && !a.done && (t = o.return) && t.call(o);
406
382
  } finally {
407
- if (l) throw l.error;
383
+ if (u) throw u.error;
408
384
  }
409
385
  }
410
386
  return n;
411
- }, Ar = function(e, r, t) {
387
+ }, Ir = function(e, r, t) {
412
388
  if (t || arguments.length === 2) for (var o = 0, a = r.length, n; o < a; o++)
413
389
  (n || !(o in r)) && (n || (n = Array.prototype.slice.call(r, 0, o)), n[o] = r[o]);
414
390
  return e.concat(n || Array.prototype.slice.call(r));
@@ -427,7 +403,7 @@ var b = function() {
427
403
  isOnline: ae.isOnline,
428
404
  isDocumentVisible: ae.isDocumentVisible
429
405
  };
430
- function Dr(e, r, t) {
406
+ function Ar(e, r, t) {
431
407
  var o = Q.get(e);
432
408
  if (o)
433
409
  o.data.push(r);
@@ -436,7 +412,7 @@ function Dr(e, r, t) {
436
412
  Q.set(e, [r], t > 0 ? t + a : t);
437
413
  }
438
414
  }
439
- function br(e, r, t) {
415
+ function Dr(e, r, t) {
440
416
  if (t.isDocumentVisible() && !(t.errorRetryCount !== void 0 && r > t.errorRetryCount)) {
441
417
  var o = Math.min(r || 0, t.errorRetryCount), a = o * t.errorRetryInterval;
442
418
  setTimeout(function() {
@@ -446,24 +422,24 @@ function br(e, r, t) {
446
422
  }
447
423
  var Re = function(e, r, t, o) {
448
424
  return t === void 0 && (t = Oe), o === void 0 && (o = Le.ttl), P(void 0, void 0, void 0, function() {
449
- var a, n, l, d, f, i, s;
450
- return $(this, function(u) {
451
- switch (u.label) {
425
+ var a, n, u, d, f, i, s;
426
+ return $(this, function(l) {
427
+ switch (l.label) {
452
428
  case 0:
453
- if (!Or(r)) return [3, 5];
454
- u.label = 1;
429
+ if (!wr(r)) return [3, 5];
430
+ l.label = 1;
455
431
  case 1:
456
- return u.trys.push([1, 3, , 4]), [4, r];
432
+ return l.trys.push([1, 3, , 4]), [4, r];
457
433
  case 2:
458
- return a = u.sent(), [3, 4];
434
+ return a = l.sent(), [3, 4];
459
435
  case 3:
460
- return d = u.sent(), n = d, [3, 4];
436
+ return d = l.sent(), n = d, [3, 4];
461
437
  case 4:
462
438
  return [3, 6];
463
439
  case 5:
464
- a = r, u.label = 6;
440
+ a = r, l.label = 6;
465
441
  case 6:
466
- if (l = !1, f = { data: a, error: n, isValidating: l }, typeof a < "u")
442
+ if (u = !1, f = { data: a, error: n, isValidating: u }, typeof a < "u")
467
443
  try {
468
444
  t.set(e, f, o);
469
445
  } catch (c) {
@@ -473,22 +449,22 @@ var Re = function(e, r, t, o) {
473
449
  return c.key === e;
474
450
  }), s.forEach(function(c, v) {
475
451
  typeof f.data < "u" && (c.data = f.data), c.error = f.error, c.isValidating = f.isValidating, c.isLoading = f.isValidating;
476
- var p = v === s.length - 1;
477
- p || delete s[v];
452
+ var h = v === s.length - 1;
453
+ h || delete s[v];
478
454
  }), s = s.filter(Boolean)), [2, f];
479
455
  }
480
456
  });
481
457
  });
482
458
  };
483
- function wr() {
459
+ function br() {
484
460
  for (var e = this, r = [], t = 0; t < arguments.length; t++)
485
461
  r[t] = arguments[t];
486
- var o, a, n = b({}, Le), l = !1, d = !1, f = ke(), i = (f == null ? void 0 : f.proxy) || f;
462
+ var o, a, n = b({}, Le), u = !1, d = !1, f = Me(), i = (f == null ? void 0 : f.proxy) || f;
487
463
  if (!i)
488
464
  return console.error("Could not get current instance, check to make sure that `useSwrv` is declared in the top level of the setup function."), null;
489
465
  var s = (i == null ? void 0 : i.$isServer) || !1;
490
466
  r.length >= 1 && (o = r[0]), r.length >= 2 && (a = r[1]), r.length > 2 && (n = b(b({}, n), r[2]));
491
- var u = s ? n.serverTTL : n.ttl, c = typeof o == "function" ? o : Y(o);
467
+ var l = s ? n.serverTTL : n.ttl, c = typeof o == "function" ? o : Y(o);
492
468
  typeof a > "u" && (a = n.fetcher);
493
469
  var v = null;
494
470
  v || (v = Fe({
@@ -498,16 +474,16 @@ function wr() {
498
474
  isLoading: !0,
499
475
  key: null
500
476
  }));
501
- var p = function(m, y) {
477
+ var h = function(m, g) {
502
478
  return P(e, void 0, void 0, function() {
503
- var N, T, C, A, x, ce, J, de = this;
479
+ var N, E, I, A, x, ce, J, de = this;
504
480
  return $(this, function(Z) {
505
481
  switch (Z.label) {
506
482
  case 0:
507
- return N = v.data === void 0, T = c.value, T ? (C = n.cache.get(T), A = C && C.data, v.isValidating = !0, v.isLoading = !A, A && (v.data = A.data, v.error = A.error), x = m || a, !x || !n.isDocumentVisible() && !N || (y == null ? void 0 : y.forceRevalidate) !== void 0 && !(y != null && y.forceRevalidate) ? (v.isValidating = !1, v.isLoading = !1, [
483
+ return N = v.data === void 0, E = c.value, E ? (I = n.cache.get(E), A = I && I.data, v.isValidating = !0, v.isLoading = !A, A && (v.data = A.data, v.error = A.error), x = m || a, !x || !n.isDocumentVisible() && !N || (g == null ? void 0 : g.forceRevalidate) !== void 0 && !(g != null && g.forceRevalidate) ? (v.isValidating = !1, v.isLoading = !1, [
508
484
  2
509
485
  /*return*/
510
- ]) : C && (ce = !!(Date.now() - C.createdAt >= n.dedupingInterval || y != null && y.forceRevalidate), !ce) ? (v.isValidating = !1, v.isLoading = !1, [
486
+ ]) : I && (ce = !!(Date.now() - I.createdAt >= n.dedupingInterval || g != null && g.forceRevalidate), !ce) ? (v.isValidating = !1, v.isLoading = !1, [
511
487
  2
512
488
  /*return*/
513
489
  ]) : (J = function() {
@@ -516,15 +492,15 @@ function wr() {
516
492
  return $(this, function(X) {
517
493
  switch (X.label) {
518
494
  case 0:
519
- return k = ie.get(T), k ? [3, 2] : (fe = Array.isArray(T) ? T : [T], ee = x.apply(void 0, Ar([], Ir(fe), !1)), ie.set(T, ee, n.dedupingInterval), [4, Re(T, ee, n.cache, u)]);
495
+ return k = ie.get(E), k ? [3, 2] : (fe = Array.isArray(E) ? E : [E], ee = x.apply(void 0, Ir([], Sr(fe), !1)), ie.set(E, ee, n.dedupingInterval), [4, Re(E, ee, n.cache, l)]);
520
496
  case 1:
521
497
  return X.sent(), [3, 4];
522
498
  case 2:
523
- return [4, Re(T, k.data, n.cache, u)];
499
+ return [4, Re(E, k.data, n.cache, l)];
524
500
  case 3:
525
501
  X.sent(), X.label = 4;
526
502
  case 4:
527
- return v.isValidating = !1, v.isLoading = !1, ie.delete(T), v.error !== void 0 && (ve = !l && n.shouldRetryOnError && (y ? y.shouldRetryOnError : !0), ve && br(p, y ? y.errorRetryCount : 1, n)), [
503
+ return v.isValidating = !1, v.isLoading = !1, ie.delete(E), v.error !== void 0 && (ve = !u && n.shouldRetryOnError && (g ? g.shouldRetryOnError : !0), ve && Dr(h, g ? g.errorRetryCount : 1, n)), [
528
504
  2
529
505
  /*return*/
530
506
  ];
@@ -536,7 +512,7 @@ function wr() {
536
512
  return $(this, function(k) {
537
513
  switch (k.label) {
538
514
  case 0:
539
- return l ? [3, 2] : [4, J()];
515
+ return u ? [3, 2] : [4, J()];
540
516
  case 1:
541
517
  k.sent(), k.label = 2;
542
518
  case 2:
@@ -563,26 +539,26 @@ function wr() {
563
539
  }
564
540
  });
565
541
  });
566
- }, _ = function() {
542
+ }, R = function() {
567
543
  return P(e, void 0, void 0, function() {
568
544
  return $(this, function(m) {
569
- return [2, p(null, { shouldRetryOnError: !1 })];
545
+ return [2, h(null, { shouldRetryOnError: !1 })];
570
546
  });
571
547
  });
572
- }, h = null;
548
+ }, y = null;
573
549
  xe(function() {
574
550
  var m = function() {
575
551
  return P(e, void 0, void 0, function() {
576
- return $(this, function(y) {
577
- switch (y.label) {
552
+ return $(this, function(g) {
553
+ switch (g.label) {
578
554
  case 0:
579
- return !v.error && n.isOnline() ? [4, p()] : [3, 2];
555
+ return !v.error && n.isOnline() ? [4, h()] : [3, 2];
580
556
  case 1:
581
- return y.sent(), [3, 3];
557
+ return g.sent(), [3, 3];
582
558
  case 2:
583
- h && clearTimeout(h), y.label = 3;
559
+ y && clearTimeout(y), g.label = 3;
584
560
  case 3:
585
- return n.refreshInterval && !l && (h = setTimeout(m, n.refreshInterval)), [
561
+ return n.refreshInterval && !u && (y = setTimeout(m, n.refreshInterval)), [
586
562
  2
587
563
  /*return*/
588
564
  ];
@@ -590,80 +566,79 @@ function wr() {
590
566
  });
591
567
  });
592
568
  };
593
- n.refreshInterval && (h = setTimeout(m, n.refreshInterval)), n.revalidateOnFocus && (document.addEventListener("visibilitychange", _, !1), window.addEventListener("focus", _, !1));
569
+ n.refreshInterval && (y = setTimeout(m, n.refreshInterval)), n.revalidateOnFocus && (document.addEventListener("visibilitychange", R, !1), window.addEventListener("focus", R, !1));
594
570
  }), qe(function() {
595
- l = !0, h && clearTimeout(h), n.revalidateOnFocus && (document.removeEventListener("visibilitychange", _, !1), window.removeEventListener("focus", _, !1));
571
+ u = !0, y && clearTimeout(y), n.revalidateOnFocus && (document.removeEventListener("visibilitychange", R, !1), window.removeEventListener("focus", R, !1));
596
572
  var m = Q.get(c.value);
597
- m && (m.data = m.data.filter(function(y) {
598
- return y !== v;
573
+ m && (m.data = m.data.filter(function(g) {
574
+ return g !== v;
599
575
  }));
600
576
  });
601
577
  try {
602
578
  Ue(c, function(m) {
603
- Pe(c) || (c.value = m), v.key = m, v.isValidating = !!m, Dr(c.value, v, u), !s && !d && c.value && p(), d = !1;
579
+ Pe(c) || (c.value = m), v.key = m, v.isValidating = !!m, Ar(c.value, v, l), !s && !d && c.value && h(), d = !1;
604
580
  }, {
605
581
  immediate: !0
606
582
  });
607
583
  } catch {
608
584
  }
609
- var I = b(b({}, $e(v)), { mutate: function(m, y) {
610
- return p(m, b(b({}, y), { forceRevalidate: !0 }));
585
+ var _ = b(b({}, $e(v)), { mutate: function(m, g) {
586
+ return h(m, b(b({}, g), { forceRevalidate: !0 }));
611
587
  } });
612
- return I;
588
+ return _;
613
589
  }
614
- function Or(e) {
590
+ function wr(e) {
615
591
  return e !== null && typeof e == "object" && typeof e.then == "function";
616
592
  }
617
- function Lr(e, r, t) {
593
+ function Or(e, r, t) {
618
594
  const {
619
595
  data: o,
620
596
  error: a,
621
597
  isValidating: n,
622
- mutate: l
623
- } = wr(e, r, {
598
+ mutate: u
599
+ } = br(e, r, {
624
600
  revalidateDebounce: 500,
625
601
  revalidateOnFocus: !1,
626
602
  dedupingInterval: 100,
627
603
  ...t
628
604
  });
629
605
  return {
630
- data: g(() => o.value),
606
+ data: p(() => o.value),
631
607
  response: o,
632
608
  error: a,
633
609
  isValidating: n,
634
- revalidate: l
610
+ revalidate: u
635
611
  };
636
612
  }
637
- const V = {
613
+ const M = {
638
614
  useI18n: cr,
639
615
  useMetricCardBuilder: pr,
640
616
  useMetricFetcher: hr,
641
- useTrendRange: Rr,
642
- useRequest: Lr
643
- }, Me = Symbol("METRICS_PROVIDER_KEY"), Mr = (e) => {
617
+ useRequest: Or
618
+ }, Ve = Symbol("METRICS_PROVIDER_KEY"), Lr = (e) => {
644
619
  const {
645
620
  datasource: r,
646
621
  dimension: t,
647
622
  dimensionFilterValue: o,
648
623
  additionalFilter: a,
649
624
  queryReady: n,
650
- timeRange: l,
625
+ timeRange: u,
651
626
  hasTrendAccess: d,
652
627
  refreshInterval: f,
653
628
  abortController: i,
654
629
  queryFn: s,
655
- averageLatencies: u
630
+ averageLatencies: l
656
631
  } = e;
657
632
  if (o && !t)
658
633
  throw new Error("Must provide a dimension if filtering by a value");
659
- const c = !!(t && o), v = !!(t && !o), p = g(() => {
660
- const y = [];
661
- return c && y.push({
634
+ const c = !!(t && o), v = !!(t && !o), h = p(() => {
635
+ const g = [];
636
+ return c && g.push({
662
637
  field: t,
663
638
  operator: "in",
664
639
  value: [o]
665
- }), a.value && y.push(...je(r.value, a.value)), y;
666
- }), _ = {
640
+ }), a.value && g.push(...je(r.value, a.value)), g;
641
+ }), R = {
667
642
  datasource: r,
668
643
  metrics: Y([
669
644
  "request_count"
@@ -674,35 +649,35 @@ const V = {
674
649
  ...t && !c ? [t] : [],
675
650
  "status_code_grouped"
676
651
  ],
677
- filter: p,
652
+ filter: h,
678
653
  queryReady: n,
679
- timeRange: l,
654
+ timeRange: u,
680
655
  // Traffic and error rate cards can't query trend if multiple entities are expected.
681
- withTrend: g(() => d.value && !v),
656
+ withTrend: p(() => d.value && !v),
682
657
  refreshInterval: f,
683
658
  queryFn: s,
684
659
  abortController: i,
685
660
  refreshCounter: e.refreshCounter
686
- }, h = {
661
+ }, y = {
687
662
  datasource: r,
688
- metrics: g(() => [
689
- u.value ? "response_latency_average" : "response_latency_p99"
663
+ metrics: p(() => [
664
+ l.value ? "response_latency_average" : "response_latency_p99"
690
665
  ]),
691
666
  // To keep single-entity queries consistent, don't bother querying the dimension for latency
692
667
  // in the single-entity case, even though it's possible.
693
668
  ...t && !c ? { dimensions: [t] } : {},
694
- filter: p,
669
+ filter: h,
695
670
  queryReady: n,
696
- timeRange: l,
671
+ timeRange: u,
697
672
  // Don't query latency trends in the multi-entity case: it's possible, but wasteful.
698
- withTrend: g(() => d.value && !v),
673
+ withTrend: p(() => d.value && !v),
699
674
  refreshInterval: f,
700
675
  queryFn: s,
701
676
  abortController: i,
702
677
  refreshCounter: e.refreshCounter
703
- }, I = V.useMetricFetcher(_), m = V.useMetricFetcher(h);
678
+ }, _ = M.useMetricFetcher(R), m = M.useMetricFetcher(y);
704
679
  return {
705
- trafficData: I,
680
+ trafficData: _,
706
681
  latencyData: m
707
682
  };
708
683
  }, gt = /* @__PURE__ */ W({
@@ -727,25 +702,25 @@ const V = {
727
702
  const r = e;
728
703
  if (r.dimension && He.findIndex((c) => c === r.dimension) === -1)
729
704
  throw new Error(`Attempted to use MetricsProvider with an invalid dimension: ${r.dimension}`);
730
- const t = Se(vr);
705
+ const t = Ce(vr);
731
706
  let o;
732
707
  t ? o = t.queryFn : (console.warn("Analytics dashboards require a query bridge supplied via provide / inject."), console.warn("Please ensure your application has a query bridge provided under the key 'analytics-query-provider', as described in"), console.warn("https://github.com/Kong/public-ui-components/blob/main/packages/analytics/analytics-metric-provider/README.md#requirements"), o = () => Promise.reject(new Error("Query bridge required")));
733
- const a = We(), n = g(() => !0), l = g(() => !a.loading && r.queryReady), d = g(() => r.datasource ? r.datasource : "basic"), f = g(() => {
708
+ const a = We(), n = p(() => !0), u = p(() => !a.loading && r.queryReady), d = p(() => r.datasource ? r.datasource : "basic"), f = p(() => {
734
709
  const c = r.overrideTimeRange;
735
710
  return c && !c.tz && (c.tz = new Intl.DateTimeFormat().resolvedOptions().timeZone), c || {
736
711
  type: "relative",
737
712
  time_range: "7d",
738
713
  tz: new Intl.DateTimeFormat().resolvedOptions().timeZone
739
714
  };
740
- }), i = g(() => !r.percentileLatency), {
715
+ }), i = p(() => !r.percentileLatency), {
741
716
  trafficData: s,
742
- latencyData: u
743
- } = Mr({
717
+ latencyData: l
718
+ } = Lr({
744
719
  datasource: d,
745
720
  dimension: r.dimension,
746
721
  dimensionFilterValue: r.filterValue,
747
722
  additionalFilter: G(r, "additionalFilter"),
748
- queryReady: l,
723
+ queryReady: u,
749
724
  timeRange: f,
750
725
  hasTrendAccess: n,
751
726
  refreshInterval: r.refreshInterval,
@@ -754,17 +729,17 @@ const V = {
754
729
  abortController: r.abortController,
755
730
  refreshCounter: G(r, "refreshCounter")
756
731
  });
757
- return ze(Me, {
732
+ return ze(Ve, {
758
733
  data: {
759
734
  traffic: s,
760
- latency: u
735
+ latency: l
761
736
  },
762
737
  description: G(() => r.description),
763
738
  containerTitle: G(() => r.containerTitle),
764
739
  hasTrendAccess: n,
765
740
  longCardTitles: r.longCardTitles,
766
741
  averageLatencies: i
767
- }), (c, v) => Ce(c.$slots, "default", {
742
+ }), (c, v) => Se(c.$slots, "default", {
768
743
  hasTrendAccess: n.value,
769
744
  timeRange: f.value
770
745
  });
@@ -773,52 +748,52 @@ const V = {
773
748
  function Vr(e) {
774
749
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
775
750
  }
776
- var Ve = { exports: {} };
751
+ var Ne = { exports: {} };
777
752
  (function(e) {
778
753
  (function() {
779
754
  function r(i, s) {
780
755
  if (s.separator === !1 || i < 1e3)
781
756
  return i.toString();
782
- var u = typeof s.separator == "string" ? s.separator : ",", c = [], v = Math.round(i).toString().split("");
783
- return v.reverse().forEach(function(p, _) {
784
- _ && _ % 3 === 0 && c.push(u), c.push(p);
757
+ var l = typeof s.separator == "string" ? s.separator : ",", c = [], v = Math.round(i).toString().split("");
758
+ return v.reverse().forEach(function(h, R) {
759
+ R && R % 3 === 0 && c.push(l), c.push(h);
785
760
  }), c.reverse().join("");
786
761
  }
787
- function t(i, s, u) {
788
- var c = i / s, v = u.round ? "round" : "floor";
789
- return u.decimal === !1 ? (i = Math[v](c), i.toString()) : (u.precision ? i = c : i = c < 10 ? Math[v](c * 10) / 10 : Math[v](c), i = i.toString(), typeof u.decimal == "string" && (i = i.replace(".", u.decimal)), i);
762
+ function t(i, s, l) {
763
+ var c = i / s, v = l.round ? "round" : "floor";
764
+ return l.decimal === !1 ? (i = Math[v](c), i.toString()) : (l.precision ? i = c : i = c < 10 ? Math[v](c * 10) / 10 : Math[v](c), i = i.toString(), typeof l.decimal == "string" && (i = i.replace(".", l.decimal)), i);
790
765
  }
791
- var o = 1e3, a = 1e4, n = 1e6, l = 1e9, d = 1e12;
766
+ var o = 1e3, a = 1e4, n = 1e6, u = 1e9, d = 1e12;
792
767
  function f(i, s) {
793
- var u;
768
+ var l;
794
769
  s = s || {};
795
770
  var c = i < 0;
796
771
  c && (i = Math.abs(i)), s.precision && (i = parseFloat(i.toPrecision(s.precision)));
797
772
  var v = s.min10k ? a : o;
798
- return i < v || s.precision && s.precision > Math.log10(i) ? u = r(t(i, 1, s), s) : i < n ? u = t(i, o, s) + "k" : i < l ? u = t(i, n, s) + "m" : i < d ? u = r(t(i, l, s), s) + "b" : u = r(t(i, d, s), s) + "t", c && (u = "-" + u), s.capital && (u = u.toUpperCase()), s.prefix && (u = s.prefix + u), s.suffix && (u = u + s.suffix), u;
773
+ return i < v || s.precision && s.precision > Math.log10(i) ? l = r(t(i, 1, s), s) : i < n ? l = t(i, o, s) + "k" : i < u ? l = t(i, n, s) + "m" : i < d ? l = r(t(i, u, s), s) + "b" : l = r(t(i, d, s), s) + "t", c && (l = "-" + l), s.capital && (l = l.toUpperCase()), s.prefix && (l = s.prefix + l), s.suffix && (l = l + s.suffix), l;
799
774
  }
800
775
  f.addCommas = r, e.exports = f;
801
776
  })();
802
- })(Ve);
803
- var Nr = Ve.exports;
777
+ })(Ne);
778
+ var Nr = Ne.exports;
804
779
  const kr = /* @__PURE__ */ Vr(Nr);
805
780
  var O = /* @__PURE__ */ ((e) => (e.GENERIC_COUNT = "GenericCount", e.TRAFFIC = "Traffic", e.ERROR_RATE = "ErrorRate", e.LATENCY = "Latency", e))(O || {}), D = /* @__PURE__ */ ((e) => (e.Small = "sm", e.Medium = "md", e.Large = "lg", e.ExtraLarge = "xl", e))(D || {});
806
- const ue = 2, Te = ue + 2, Fr = (e, r, t = !1) => {
781
+ const ue = 2, Te = ue + 2, Mr = (e, r, t = !1) => {
807
782
  let o = !r || Number(e.toFixed(Te)) === 0 ? 0 : Number(e.toFixed(Te)) > 0 ? 1 : -1;
808
783
  return t && (o *= -1), o;
809
- }, xr = (e, r, t) => r ? `${Math.abs(e * 100).toFixed(ue)}%` : t, qr = (e, r) => r === 0 ? 0 : e / r - 1, Ur = (e, r = !1) => (r && (e *= -1), e > 0 ? Je : e < 0 ? Ze : De), Pr = "#ad000e", oe = "#6c7489", Ee = "#52596e", $r = "#007d60", j = "16px", zr = "20px", Kr = {
784
+ }, Fr = (e, r, t) => r ? `${Math.abs(e * 100).toFixed(ue)}%` : t, xr = (e, r) => r === 0 ? 0 : e / r - 1, qr = (e, r = !1) => (r && (e *= -1), e > 0 ? Je : e < 0 ? Ze : De), Ur = "#ad000e", oe = "#6c7489", Ee = "#52596e", Pr = "#007d60", j = "16px", $r = "20px", zr = {
810
785
  key: 0,
811
786
  class: "metricscard-description"
812
- }, Br = { class: "metricscard-valuetrend" }, Xr = {
787
+ }, Kr = { class: "metricscard-valuetrend" }, Br = {
813
788
  key: 0,
814
789
  class: "metricscard-error"
815
- }, Gr = {
790
+ }, Xr = {
816
791
  key: 2,
817
792
  class: "metricscard-trend"
818
- }, jr = { "data-testid": "metric-trend-change" }, Hr = {
793
+ }, Gr = { "data-testid": "metric-trend-change" }, jr = {
819
794
  key: 0,
820
795
  class: "metricscard-trend-range"
821
- }, Yr = /* @__PURE__ */ W({
796
+ }, Hr = /* @__PURE__ */ W({
822
797
  __name: "MetricsCard",
823
798
  props: {
824
799
  cardType: {
@@ -897,80 +872,80 @@ const ue = 2, Te = ue + 2, Fr = (e, r, t = !1) => {
897
872
  [O.LATENCY, nr]
898
873
  ]), t = e, o = (d) => {
899
874
  const f = {
900
- red: `var(--kui-color-text-danger-strong, ${Pr})`,
901
- green: `var(--kui-color-text-success, ${$r})`,
875
+ red: `var(--kui-color-text-danger-strong, ${Ur})`,
876
+ green: `var(--kui-color-text-success, ${Pr})`,
902
877
  grey: `var(--kui-color-text-neutral-strong, ${Ee})`
903
878
  };
904
879
  return d > 0 ? f.green : d < 0 ? f.red : f.grey;
905
- }, a = (d) => d > 0 ? "positive" : d < 0 ? "negative" : "neutral", n = [D.Medium, D.Large].includes(t.cardSize), l = [D.Small].includes(t.cardSize);
880
+ }, a = (d) => d > 0 ? "positive" : d < 0 ? "negative" : "neutral", n = [D.Medium, D.Large].includes(t.cardSize), u = [D.Small].includes(t.cardSize);
906
881
  return (d, f) => {
907
882
  const i = Ie("KTooltip");
908
- return R(), S("div", {
883
+ return T(), S("div", {
909
884
  class: z(["metricscard", e.cardSize])
910
885
  }, [
911
886
  q("div", {
912
887
  class: z(["metricscard-title", e.cardSize])
913
888
  }, [
914
- E(l) ? M("", !0) : (R(), U(re(E(r).get(e.cardType)), {
889
+ C(u) ? V("", !0) : (T(), U(re(C(r).get(e.cardType)), {
915
890
  key: 0,
916
891
  class: "metricscard-icon",
917
- color: `var(--kui-color-text-neutral, ${E(oe)})`,
918
- size: E(j)
892
+ color: `var(--kui-color-text-neutral, ${C(oe)})`,
893
+ size: C(j)
919
894
  }, null, 8, ["color", "size"])),
920
- (R(), U(re(e.titleTag), null, {
895
+ (T(), U(re(e.titleTag), null, {
921
896
  default: me(() => [
922
897
  Ae(w(e.title), 1)
923
898
  ]),
924
899
  _: 1
925
900
  })),
926
- e.tooltip ? (R(), U(i, {
901
+ e.tooltip ? (T(), U(i, {
927
902
  key: 1,
928
903
  class: "metricscard-tooltip",
929
904
  placement: "right",
930
905
  text: e.tooltip
931
906
  }, {
932
907
  default: me(() => [
933
- F(E(ar), {
934
- color: `var(--kui-color-text-neutral, ${E(oe)})`,
935
- size: E(j)
908
+ F(C(ar), {
909
+ color: `var(--kui-color-text-neutral, ${C(oe)})`,
910
+ size: C(j)
936
911
  }, null, 8, ["color", "size"])
937
912
  ]),
938
913
  _: 1
939
- }, 8, ["text"])) : M("", !0)
914
+ }, 8, ["text"])) : V("", !0)
940
915
  ], 2),
941
- e.description && E(n) ? (R(), S("div", Kr, [
916
+ e.description && C(n) ? (T(), S("div", zr, [
942
917
  q("span", null, w(e.description), 1)
943
- ])) : M("", !0),
944
- q("div", Br, [
945
- e.hasError ? (R(), S("div", Xr, [
946
- F(E(be), {
947
- color: `var(--kui-color-text-neutral, ${E(oe)})`,
948
- size: E(zr)
918
+ ])) : V("", !0),
919
+ q("div", Kr, [
920
+ e.hasError ? (T(), S("div", Br, [
921
+ F(C(be), {
922
+ color: `var(--kui-color-text-neutral, ${C(oe)})`,
923
+ size: C($r)
949
924
  }, null, 8, ["color", "size"]),
950
925
  q("div", null, " " + w(e.errorMessage), 1)
951
- ])) : (R(), S("div", {
926
+ ])) : (T(), S("div", {
952
927
  key: 1,
953
928
  class: z(["metricscard-value", e.cardSize]),
954
929
  "data-testid": "metric-value"
955
930
  }, w(e.metricValue), 3)),
956
- E(n) ? (R(), S("div", Gr, [
931
+ C(n) ? (T(), S("div", Xr, [
957
932
  q("div", {
958
933
  class: z(["metricscard-trend-change", a(e.changePolarity)]),
959
934
  "data-testid": "metric-trend-parent"
960
935
  }, [
961
- e.changePolarity !== 0 ? (R(), U(re(e.trendIcon), {
936
+ e.changePolarity !== 0 ? (T(), U(re(e.trendIcon), {
962
937
  key: 0,
963
938
  color: o(e.changePolarity),
964
- size: E(j)
965
- }, null, 8, ["color", "size"])) : (R(), U(E(ir), {
939
+ size: C(j)
940
+ }, null, 8, ["color", "size"])) : (T(), U(C(ir), {
966
941
  key: 1,
967
- color: `var(--kui-color-text-neutral-strong, ${E(Ee)})`,
968
- size: E(j)
942
+ color: `var(--kui-color-text-neutral-strong, ${C(Ee)})`,
943
+ size: C(j)
969
944
  }, null, 8, ["color", "size"])),
970
- q("div", jr, w(e.metricChange), 1)
945
+ q("div", Gr, w(e.metricChange), 1)
971
946
  ], 2),
972
- e.trendRange ? (R(), S("div", Hr, w(e.trendRange), 1)) : M("", !0)
973
- ])) : M("", !0)
947
+ e.trendRange ? (T(), S("div", jr, w(e.trendRange), 1)) : V("", !0)
948
+ ])) : V("", !0)
974
949
  ])
975
950
  ], 2);
976
951
  };
@@ -980,30 +955,30 @@ const ue = 2, Te = ue + 2, Fr = (e, r, t = !1) => {
980
955
  for (const [o, a] of r)
981
956
  t[o] = a;
982
957
  return t;
983
- }, Qr = /* @__PURE__ */ le(Yr, [["__scopeId", "data-v-b1513f6f"]]), Wr = {}, Jr = { class: "loading-tabs" };
984
- function Zr(e, r) {
958
+ }, Yr = /* @__PURE__ */ le(Hr, [["__scopeId", "data-v-b1513f6f"]]), Qr = {}, Wr = { class: "loading-tabs" };
959
+ function Jr(e, r) {
985
960
  const t = Ie("KSkeletonBox");
986
- return R(), S("div", Jr, [
961
+ return T(), S("div", Wr, [
987
962
  F(t, { width: "100" }),
988
963
  F(t, { width: "75" })
989
964
  ]);
990
965
  }
991
- const et = /* @__PURE__ */ le(Wr, [["render", Zr], ["__scopeId", "data-v-9c7113d7"]]), rt = {
966
+ const Zr = /* @__PURE__ */ le(Qr, [["render", Jr], ["__scopeId", "data-v-9c7113d7"]]), et = {
992
967
  key: 0,
993
968
  class: "container-title"
994
- }, tt = {
969
+ }, rt = {
995
970
  key: 0,
996
971
  class: "container-description"
997
- }, nt = {
972
+ }, tt = {
998
973
  key: 1,
999
974
  class: "error-display"
1000
- }, at = {
975
+ }, nt = {
1001
976
  key: 0,
1002
977
  class: "error-display-message"
1003
- }, it = {
978
+ }, at = {
1004
979
  key: 2,
1005
980
  class: "cards-wrapper"
1006
- }, ot = /* @__PURE__ */ W({
981
+ }, it = /* @__PURE__ */ W({
1007
982
  __name: "MetricCardContainer",
1008
983
  props: {
1009
984
  fallbackDisplayText: {
@@ -1046,52 +1021,52 @@ const et = /* @__PURE__ */ le(Wr, [["render", Zr], ["__scopeId", "data-v-9c7113d
1046
1021
  }
1047
1022
  },
1048
1023
  setup(e) {
1049
- const r = e, t = g(() => r.cards.every((a) => (a == null ? void 0 : a.hasError) === !0)), o = (a) => {
1050
- const n = qr(a.currentValue, a.previousValue) || 0, l = Fr(n, r.hasTrendAccess, a.increaseIsBad);
1024
+ const r = e, t = p(() => r.cards.every((a) => (a == null ? void 0 : a.hasError) === !0)), o = (a) => {
1025
+ const n = xr(a.currentValue, a.previousValue) || 0, u = Mr(n, r.hasTrendAccess, a.increaseIsBad);
1051
1026
  return {
1052
1027
  metricValue: a.formatValueFn ? a.formatValueFn(a.currentValue) : kr(a.currentValue, { capital: !0, round: !0 }) || "0",
1053
- metricChange: a.formatChangeFn ? a.formatChangeFn(n) : xr(n, r.hasTrendAccess, r.fallbackDisplayText),
1054
- changePolarity: l,
1055
- trendIcon: Ur(l, a.increaseIsBad),
1028
+ metricChange: a.formatChangeFn ? a.formatChangeFn(n) : Fr(n, r.hasTrendAccess, r.fallbackDisplayText),
1029
+ changePolarity: u,
1030
+ trendIcon: qr(u, a.increaseIsBad),
1056
1031
  cardSize: r.cardSize,
1057
1032
  hasContainerTitle: !!r.containerTitle
1058
1033
  };
1059
1034
  };
1060
- return (a, n) => (R(), S("div", {
1035
+ return (a, n) => (T(), S("div", {
1061
1036
  class: z(["kong-ui-public-metric-card-container", e.cardSize])
1062
1037
  }, [
1063
- r.containerTitle || r.containerDescription ? (R(), S("div", rt, [
1038
+ r.containerTitle || r.containerDescription ? (T(), S("div", et, [
1064
1039
  Ae(w(r.containerTitle) + " ", 1),
1065
- r.containerDescription ? (R(), S("div", tt, w(r.containerDescription), 1)) : M("", !0)
1066
- ])) : M("", !0),
1067
- t.value ? (R(), S("div", nt, [
1068
- F(E(be), { class: "error-display-icon" }),
1069
- e.errorMessage ? (R(), S("div", at, w(e.errorMessage), 1)) : M("", !0)
1070
- ])) : (R(), S("div", it, [
1071
- (R(!0), S(ye, null, Ke(e.cards, (l, d) => (R(), S(ye, null, [
1072
- e.loading ? (R(), S("div", {
1040
+ r.containerDescription ? (T(), S("div", rt, w(r.containerDescription), 1)) : V("", !0)
1041
+ ])) : V("", !0),
1042
+ t.value ? (T(), S("div", tt, [
1043
+ F(C(be), { class: "error-display-icon" }),
1044
+ e.errorMessage ? (T(), S("div", nt, w(e.errorMessage), 1)) : V("", !0)
1045
+ ])) : (T(), S("div", at, [
1046
+ (T(!0), S(ge, null, Ke(e.cards, (u, d) => (T(), S(ge, null, [
1047
+ e.loading ? (T(), S("div", {
1073
1048
  key: `skeleton-${d}`,
1074
1049
  class: "loading-tab"
1075
1050
  }, [
1076
- F(et, {
1077
- class: z(e.cardSize === E(D).Small ? "loading-tabs-small" : "loading-tabs-large")
1051
+ F(Zr, {
1052
+ class: z(e.cardSize === C(D).Small ? "loading-tabs-small" : "loading-tabs-large")
1078
1053
  }, null, 8, ["class"])
1079
- ])) : (R(), U(Qr, Be({ key: d }, { ref_for: !0 }, o(l), {
1054
+ ])) : (T(), U(Yr, Be({ key: d }, { ref_for: !0 }, o(u), {
1080
1055
  "card-size": e.cardSize,
1081
- "card-type": l.cardType,
1082
- description: l.description,
1056
+ "card-type": u.cardType,
1057
+ description: u.description,
1083
1058
  "error-message": e.errorMessage,
1084
- "has-error": l.hasError,
1085
- title: l.title,
1086
- "title-tag": l.titleTag,
1087
- tooltip: l.tooltip,
1088
- "trend-range": l.trendRange
1059
+ "has-error": u.hasError,
1060
+ title: u.title,
1061
+ "title-tag": u.titleTag,
1062
+ tooltip: u.tooltip,
1063
+ "trend-range": u.trendRange
1089
1064
  }), null, 16, ["card-size", "card-type", "description", "error-message", "has-error", "title", "title-tag", "tooltip", "trend-range"]))
1090
1065
  ], 64))), 256))
1091
1066
  ]))
1092
1067
  ], 2));
1093
1068
  }
1094
- }), st = /* @__PURE__ */ le(ot, [["__scopeId", "data-v-7080ba56"]]), ht = /* @__PURE__ */ W({
1069
+ }), ot = /* @__PURE__ */ le(it, [["__scopeId", "data-v-7080ba56"]]), yt = /* @__PURE__ */ W({
1095
1070
  __name: "MetricsConsumer",
1096
1071
  props: {
1097
1072
  lookupKey: { default: void 0 },
@@ -1099,34 +1074,34 @@ const et = /* @__PURE__ */ le(Wr, [["render", Zr], ["__scopeId", "data-v-9c7113d
1099
1074
  cardToDisplay: { default: void 0 }
1100
1075
  },
1101
1076
  setup(e) {
1102
- const r = e, t = Se(Me);
1077
+ const r = e, t = Ce(Ve);
1103
1078
  if (!t)
1104
1079
  throw new Error("MetricsConsumer must be nested inside a MetricsProvider instance.");
1105
- const { traffic: o, latency: a } = t.data, { i18n: n } = V.useI18n(), l = g(() => t.containerTitle.value ? D.Medium : r.cardSize), d = V.useMetricCardBuilder({
1080
+ const { traffic: o, latency: a } = t.data, { i18n: n } = M.useI18n(), u = p(() => t.containerTitle.value ? D.Medium : r.cardSize), d = M.useMetricCardBuilder({
1106
1081
  cardType: O.TRAFFIC,
1107
- title: g(() => t.longCardTitles ? n.t("metricCard.long.traffic") : n.t("metricCard.short.traffic")),
1082
+ title: p(() => t.longCardTitles ? n.t("metricCard.long.traffic") : n.t("metricCard.short.traffic")),
1108
1083
  record: o.mapped,
1109
1084
  hasError: o.hasError,
1110
1085
  lookupKey: r.lookupKey,
1111
1086
  sumGroupedValues: B,
1112
1087
  trendRange: o.trendRange
1113
- }), f = (h) => `${h.toFixed(ue)}%`, i = g(() => {
1114
- const h = o.mapped.value, I = K(h, "current", r.lookupKey, ge), m = K(h, "current", r.lookupKey, B), y = I / m * 100 || 0, N = K(h, "previous", r.lookupKey, ge), T = K(h, "previous", r.lookupKey, B), C = N / T * 100 || 0;
1088
+ }), f = (y) => `${y.toFixed(ue)}%`, i = p(() => {
1089
+ const y = o.mapped.value, _ = K(y, "current", r.lookupKey, ye), m = K(y, "current", r.lookupKey, B), g = _ / m * 100 || 0, N = K(y, "previous", r.lookupKey, ye), E = K(y, "previous", r.lookupKey, B), I = N / E * 100 || 0;
1115
1090
  return {
1116
1091
  cardType: O.ERROR_RATE,
1117
1092
  hasError: o.hasError.value,
1118
- currentValue: y,
1119
- previousValue: C,
1093
+ currentValue: g,
1094
+ previousValue: I,
1120
1095
  formatValueFn: f,
1121
1096
  title: t.longCardTitles ? n.t("metricCard.long.errorRate") : n.t("metricCard.short.errorRate"),
1122
1097
  increaseIsBad: !0,
1123
1098
  trendRange: o.trendRange.value
1124
1099
  };
1125
- }), s = (h) => `${h}ms`, u = V.useMetricCardBuilder({
1100
+ }), s = (y) => `${y}ms`, l = M.useMetricCardBuilder({
1126
1101
  cardType: O.LATENCY,
1127
- title: g(() => {
1128
- const { longCardTitles: h, averageLatencies: I } = t, m = I.value ? "averageLatency" : "p99Latency";
1129
- return h ? n.t(`metricCard.long.${m}`) : l.value === D.Small ? n.t(`metricCard.small.${m}`) : n.t(`metricCard.short.${m}`);
1102
+ title: p(() => {
1103
+ const { longCardTitles: y, averageLatencies: _ } = t, m = _.value ? "averageLatency" : "p99Latency";
1104
+ return y ? n.t(`metricCard.long.${m}`) : u.value === D.Small ? n.t(`metricCard.small.${m}`) : n.t(`metricCard.short.${m}`);
1130
1105
  }),
1131
1106
  hasError: a.hasError,
1132
1107
  record: a.mapped,
@@ -1134,39 +1109,39 @@ const et = /* @__PURE__ */ le(Wr, [["render", Zr], ["__scopeId", "data-v-9c7113d
1134
1109
  increaseIsBad: !0,
1135
1110
  formatValueFn: s,
1136
1111
  trendRange: a.trendRange
1137
- }), c = g(() => r.cardToDisplay === "TRAFFIC" ? [d.value] : r.cardToDisplay === "ERROR_RATE" ? [i.value] : r.cardToDisplay === "LATENCY" ? [u.value] : [d.value, i.value, u.value]), v = g(() => r.cardToDisplay === "TRAFFIC" || r.cardToDisplay === "ERROR_RATE" ? o.isLoading.value : r.cardToDisplay === "LATENCY" ? a.isLoading.value : o.isLoading.value || a.isLoading.value), p = g(() => ({
1112
+ }), c = p(() => r.cardToDisplay === "TRAFFIC" ? [d.value] : r.cardToDisplay === "ERROR_RATE" ? [i.value] : r.cardToDisplay === "LATENCY" ? [l.value] : [d.value, i.value, l.value]), v = p(() => r.cardToDisplay === "TRAFFIC" || r.cardToDisplay === "ERROR_RATE" ? o.isLoading.value : r.cardToDisplay === "LATENCY" ? a.isLoading.value : o.isLoading.value || a.isLoading.value), h = p(() => ({
1138
1113
  cards: c.value,
1139
1114
  containerTitle: t.containerTitle.value,
1140
1115
  containerDescription: t.description.value,
1141
1116
  loading: v.value,
1142
1117
  hasTrendAccess: t.hasTrendAccess.value,
1143
1118
  fallbackDisplayText: n.t("general.notAvailable"),
1144
- cardSize: l.value,
1119
+ cardSize: u.value,
1145
1120
  hideTitle: !0
1146
- })), _ = g(() => ({
1147
- loading: p.value.loading,
1121
+ })), R = p(() => ({
1122
+ loading: h.value.loading,
1148
1123
  trafficCard: d.value,
1149
1124
  errorRateCard: i.value,
1150
- latencyCard: u.value,
1125
+ latencyCard: l.value,
1151
1126
  errorRateFormatted: f(i.value.currentValue),
1152
- latencyFormatted: s(u.value.currentValue)
1127
+ latencyFormatted: s(l.value.currentValue)
1153
1128
  }));
1154
- return (h, I) => Ce(h.$slots, "default", { cardValues: _.value }, () => [
1155
- F(st, Xe(Ge(p.value)), null, 16)
1129
+ return (y, _) => Se(y.$slots, "default", { cardValues: R.value }, () => [
1130
+ F(ot, Xe(Ge(h.value)), null, 16)
1156
1131
  ]);
1157
1132
  }
1158
- }), H = (e) => new Date(e), pt = (e, r) => {
1133
+ }), H = (e) => new Date(e), ht = (e, r) => {
1159
1134
  const t = e.body;
1160
1135
  e.reply({
1161
1136
  statusCode: 200,
1162
- body: ut(t, r)
1137
+ body: st(t, r)
1163
1138
  });
1164
- }, _e = (e) => e.reduce((r, t) => (r[t] = { name: t }, r), {}), ut = (e, r) => {
1165
- var _, h, I;
1139
+ }, _e = (e) => e.reduce((r, t) => (r[t] = { name: t }, r), {}), st = (e, r) => {
1140
+ var R, y, _;
1166
1141
  const t = r != null && r.timeRange && {
1167
1142
  start: r.timeRange.start,
1168
1143
  end: r.timeRange.end
1169
- } || ((_ = e.time_range) == null ? void 0 : _.type) === "absolute" ? {
1144
+ } || ((R = e.time_range) == null ? void 0 : R.type) === "absolute" ? {
1170
1145
  // @ts-ignore - already asserted time range is absolute above
1171
1146
  start: new Date(e.time_range.start),
1172
1147
  // @ts-ignore - already asserted time range is absolute above
@@ -1182,62 +1157,55 @@ const et = /* @__PURE__ */ le(Wr, [["render", Zr], ["__scopeId", "data-v-9c7113d
1182
1157
  start: t.start,
1183
1158
  end: t.end,
1184
1159
  granularity: t.end.getTime() - t.start.getTime()
1185
- }, n = a.end.getTime(), l = a.start.getTime(), d = a.granularity, f = e.granularity === "trend" ? 2 : 1;
1160
+ }, n = a.end.getTime(), u = a.start.getTime(), d = a.granularity, f = e.granularity === "trend" ? 2 : 1;
1186
1161
  if ((e.dimensions ?? []).length > 2)
1187
1162
  throw new Error(`Explore only supports 0-2 dimensions; got: ${JSON.stringify(e.dimensions)}`);
1188
- const i = (e.dimensions ?? []).find((m) => m !== "time"), s = (r == null ? void 0 : r.dimensionNames) ?? [], u = Math.max(s.length, 1), c = e.metrics || [], v = [];
1163
+ const i = (e.dimensions ?? []).find((m) => m !== "time"), s = (r == null ? void 0 : r.dimensionNames) ?? [], l = Math.max(s.length, 1), c = e.metrics || [], v = [];
1189
1164
  for (let m = 0; m < f; m++)
1190
- for (let y = 0; y < u; y++) {
1191
- const N = i ? { [i]: s[y] } : {};
1192
- (h = e.dimensions) != null && h.includes("status_code_grouped") ? B.forEach((T) => {
1193
- const C = c.reduce((A, x) => ((r == null ? void 0 : r.deterministic) ?? !0 ? A[x] = (f - m) * 1e3 + 100 * y + 1 : A[x] = Math.round(Math.random() * 1e3), A), { ...N, status_code_grouped: T });
1165
+ for (let g = 0; g < l; g++) {
1166
+ const N = i ? { [i]: s[g] } : {};
1167
+ (y = e.dimensions) != null && y.includes("status_code_grouped") ? B.forEach((E) => {
1168
+ const I = c.reduce((A, x) => ((r == null ? void 0 : r.deterministic) ?? !0 ? A[x] = (f - m) * 1e3 + 100 * g + 1 : A[x] = Math.round(Math.random() * 1e3), A), { ...N, status_code_grouped: E });
1194
1169
  v.push({
1195
1170
  version: "v1",
1196
- timestamp: m === 0 ? H(l).toISOString() : H(l + d).toISOString(),
1197
- event: C
1171
+ timestamp: m === 0 ? H(u).toISOString() : H(u + d).toISOString(),
1172
+ event: I
1198
1173
  });
1199
1174
  }) : v.push({
1200
1175
  version: "v1",
1201
- timestamp: m === 0 ? H(l).toISOString() : H(l + d).toISOString(),
1202
- event: c.reduce((T, C) => ((r == null ? void 0 : r.deterministic) ?? !0 ? T[C] = (f - m) * 1e3 + 100 * y + 1 : T[C] = Math.round(Math.random() * 1e3), T), { ...N })
1176
+ timestamp: m === 0 ? H(u).toISOString() : H(u + d).toISOString(),
1177
+ event: c.reduce((E, I) => ((r == null ? void 0 : r.deterministic) ?? !0 ? E[I] = (f - m) * 1e3 + 100 * g + 1 : E[I] = Math.round(Math.random() * 1e3), E), { ...N })
1203
1178
  });
1204
1179
  }
1205
- const p = {
1206
- start_ms: l,
1180
+ const h = {
1181
+ start_ms: u,
1207
1182
  end_ms: n,
1208
- start: new Date(l).toISOString(),
1183
+ start: new Date(u).toISOString(),
1209
1184
  end: new Date(n).toISOString(),
1210
1185
  granularity_ms: d,
1211
1186
  display: i ? {
1212
1187
  [i]: _e(s),
1213
- ...(I = e.dimensions) != null && I.includes("status_code_grouped") ? { status_code_grouped: _e(B) } : {}
1188
+ ...(_ = e.dimensions) != null && _.includes("status_code_grouped") ? { status_code_grouped: _e(B) } : {}
1214
1189
  } : {},
1215
1190
  metric_names: e.metrics,
1216
1191
  query_id: "test"
1217
1192
  };
1218
1193
  return {
1219
1194
  data: v,
1220
- meta: p
1195
+ meta: h
1221
1196
  };
1222
1197
  };
1223
1198
  export {
1224
1199
  B as ALL_STATUS_CODE_GROUPS,
1225
- ue as DECIMAL_DISPLAY,
1226
- Te as DECIMAL_ROUNDING_PRECISION,
1227
1200
  fr as DEFAULT_REFRESH_INTERVAL,
1228
1201
  vr as INJECT_QUERY_PROVIDER,
1229
1202
  dr as MAX_ANALYTICS_REQUEST_RETRIES,
1230
1203
  D as MetricCardSize,
1231
1204
  O as MetricCardType,
1232
- ht as MetricsConsumer,
1205
+ yt as MetricsConsumer,
1233
1206
  gt as MetricsProvider,
1234
- ge as STATUS_CODES_FAILED,
1235
- yt as STATUS_CODES_SUCCESS,
1236
- qr as calculateChange,
1237
- Fr as changePolarity,
1238
- Ur as defineIcon,
1239
- xr as metricChange,
1240
- ut as mockExploreResponse,
1241
- pt as mockExploreResponseFromCypress,
1242
- Rr as useTrendRange
1207
+ ye as STATUS_CODES_FAILED,
1208
+ mt as STATUS_CODES_SUCCESS,
1209
+ st as mockExploreResponse,
1210
+ ht as mockExploreResponseFromCypress
1243
1211
  };