@kong-ui-public/analytics-metric-provider 11.0.3-pr.2637.cd79373fe.0 → 11.0.3-pr.2637.f703f4556.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 g, 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 C, openBlock as R, normalizeClass as z, createElementVNode as q, createCommentVNode as V, 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";
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";
@@ -58,17 +58,17 @@ function cr() {
58
58
  const dr = 2, B = ["1XX", "2XX", "3XX", "4XX", "5XX"], ge = ["4XX", "5XX"], yt = ["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
- var r, t, o, a, n;
61
+ var r, t, i, a, n;
62
62
  return e ? !!// TODO: revisit: currently only the first check ever matters?
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;
63
+ ((r = Object.keys(e)) != null && r.length || (t = e.data) != null && t.length || (a = (i = e.data) == null ? void 0 : i.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 yr(e = Y({}), r, t, i = mr) {
66
66
  const a = Y(
67
67
  "PENDING"
68
68
  /* PENDING */
69
69
  );
70
- return Ne(() => {
71
- const n = o(e.value);
70
+ return ke(() => {
71
+ const n = i(e.value);
72
72
  if (e.value && n && t.value) {
73
73
  a.value = "VALIDATING_HAS_DATA";
74
74
  return;
@@ -99,18 +99,18 @@ function yr(e = Y({}), r, t, o = mr) {
99
99
  swrvState: we
100
100
  };
101
101
  }
102
- const L = Symbol("default"), te = "status_code_grouped", he = (e, r, t, o, a) => {
103
- e[r][t] || (e[r][t] = {}), e[r][t][o] = a;
102
+ const L = Symbol("default"), te = "status_code_grouped", he = (e, r, t, i, a) => {
103
+ e[r][t] || (e[r][t] = {}), e[r][t][i] = a;
104
104
  };
105
105
  function gr(e, r) {
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);
106
+ var c;
107
+ const t = ((c = e.meta.metric_names) == null ? void 0 : c[0]) || "", i = e.meta.start_ms, a = Object.keys(e.meta.display || {}), n = !!a.find((d) => d === te), u = a.find((d) => d !== 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
- }) : 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;
111
+ }) : e.data.reduce((d, o) => {
112
+ const s = o.event[t], l = u ? o.event[u] : L, f = n ? o.event[te] : L;
113
+ return new Date(o.timestamp).getTime() === i && r ? he(d, "previous", l, f, s) : he(d, "current", l, f, s), d;
114
114
  }, {
115
115
  previous: {},
116
116
  current: {}
@@ -119,7 +119,7 @@ function gr(e, r) {
119
119
  function hr(e) {
120
120
  e.queryReady === void 0 && (e.queryReady = g(() => !0));
121
121
  const r = g(() => {
122
- var s, u;
122
+ var s, l;
123
123
  return {
124
124
  metrics: e.metrics.value,
125
125
  dimensions: [
@@ -127,16 +127,16 @@ function hr(e) {
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
+ ...(l = e.filter.value) != null && l.length ? { filters: e.filter.value } : {},
131
131
  time_range: e.timeRange.value
132
132
  };
133
133
  }), t = g(() => {
134
- var u, c, v, p;
135
- if (!((u = e.queryReady) != null && u.value))
134
+ var l, f, v, p;
135
+ if (!((l = e.queryReady) != null && l.value))
136
136
  return null;
137
- const s = (c = e.filter) != null && c.value ? JSON.stringify(e.filter.value) : "";
137
+ const s = (f = e.filter) != null && f.value ? JSON.stringify(e.filter.value) : "";
138
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(
139
+ }), { response: i, error: a, isValidating: n } = N.useRequest(
140
140
  () => t.value,
141
141
  () => e.queryFn({
142
142
  // TODO: Use a type guard to validate that if the datasource is basic,
@@ -149,90 +149,77 @@ function hr(e) {
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(() => {
152
+ ), { state: u, swrvState: c } = yr(i, a, n), d = g(() => {
153
+ var s, l, f, v, p, _, h;
154
+ return !((l = (s = i.value) == null ? void 0 : s.data) != null && l.length) || !((v = (f = i.value) == null ? void 0 : f.meta) != null && v.display) || !((h = (_ = (p = i.value) == null ? void 0 : p.meta) == null ? void 0 : _.metric_names) != null && h.length) ? { current: {}, previous: {} } : gr(i.value, e.withTrend.value);
155
+ }), o = N.useTrendRange(e.withTrend, e.timeRange, g(() => {
156
156
  var s;
157
- return (s = o.value) == null ? void 0 : s.meta;
157
+ return (s = i.value) == null ? void 0 : s.meta;
158
158
  }));
159
159
  return {
160
- isLoading: g(() => d.PENDING === l.value),
161
- hasError: g(() => d.ERROR === l.value),
162
- raw: o,
163
- mapped: f,
164
- trendRange: i
160
+ isLoading: g(() => c.PENDING === u.value),
161
+ hasError: g(() => c.ERROR === u.value),
162
+ raw: i,
163
+ mapped: d,
164
+ trendRange: o
165
165
  };
166
166
  }
167
- const K = (e, r, t = L, o) => (o ?? [L]).reduce((n, l) => {
168
- const d = e[r][t];
169
- return d ? n + (d[l] || 0) : n;
167
+ const K = (e, r, t = L, i) => (i ?? [L]).reduce((n, u) => {
168
+ const c = e[r][t];
169
+ return c ? n + (c[u] || 0) : n;
170
170
  }, 0);
171
171
  function pr(e) {
172
172
  const {
173
173
  cardType: r,
174
174
  title: t,
175
- description: o,
175
+ description: i,
176
176
  record: a,
177
177
  hasError: n,
178
- increaseIsBad: l,
179
- formatValueFn: d,
180
- trendRange: f
178
+ increaseIsBad: u,
179
+ formatValueFn: c,
180
+ trendRange: d
181
181
  } = e;
182
182
  return g(() => {
183
- let i = 0, s = 0;
183
+ let o = 0, s = 0;
184
184
  if (a != null && a.value)
185
185
  try {
186
- i = K(a.value, "current", e.lookupKey, e.sumGroupedValues), s = K(a.value, "previous", e.lookupKey, e.sumGroupedValues);
187
- } catch (u) {
186
+ o = K(a.value, "current", e.lookupKey, e.sumGroupedValues), s = K(a.value, "previous", e.lookupKey, e.sumGroupedValues);
187
+ } catch (l) {
188
188
  console.error(
189
189
  "Metric card data doesn't have the expected structure:",
190
- u
190
+ l
191
191
  );
192
192
  }
193
193
  return {
194
194
  cardType: r,
195
195
  hasError: n.value,
196
- currentValue: i,
196
+ currentValue: o,
197
197
  previousValue: s,
198
198
  title: t.value,
199
- description: o,
200
- increaseIsBad: !!l,
199
+ description: i,
200
+ increaseIsBad: !!u,
201
201
  // Coerce undefined to false
202
- formatValueFn: d,
203
- trendRange: f == null ? void 0 : f.value
202
+ formatValueFn: c,
203
+ trendRange: d == null ? void 0 : d.value
204
204
  };
205
205
  });
206
206
  }
207
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
- };
208
+ const { i18n: i } = N.useI18n();
226
209
  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);
210
+ var a, n, u;
211
+ if (((a = r == null ? void 0 : r.value) == null ? void 0 : a.type) === "absolute") {
212
+ let c, d;
213
+ if ((n = t == null ? void 0 : t.value) != null && n.start_ms && t.value.end_ms)
214
+ c = t.value.start_ms, d = t.value.end_ms;
215
+ else if (r.value.start && r.value.end)
216
+ c = new Date(r.value.start).getTime(), d = new Date(r.value.end).getTime();
217
+ else
218
+ return "";
219
+ let o = (d - c) / (1e3 * 60 * 60 * 24), s = (d - c) / (1e3 * 60 * 60), l = (d - c) / (1e3 * 60);
220
+ return e.value && (o /= 2, s /= 2, l /= 2), o >= 1 ? i.t("trendRange.custom_days", { numDays: Math.round(o) }) : s >= 1 ? i.t("trendRange.custom_hours", { numHours: Math.round(s) }) : l >= 1 ? i.t("trendRange.custom_minutes", { numMinutes: Math.round(l) }) : i.t("trendRange.custom_days", { numDays: Math.round(o) });
234
221
  }
235
- return "";
222
+ return ((u = r == null ? void 0 : r.value) == null ? void 0 : u.type) === "relative" && e.value ? i.t(`trendRange.${r.value.time_range}`) : "";
236
223
  });
237
224
  }
238
225
  var ne = /* @__PURE__ */ new WeakMap(), pe = 0;
@@ -240,8 +227,8 @@ function Tr(e) {
240
227
  if (!e.length)
241
228
  return "";
242
229
  for (var r = "arg", t = 0; t < e.length; ++t) {
243
- var o = void 0;
244
- e[t] === null || typeof e[t] != "object" && typeof e[t] != "function" ? typeof e[t] == "string" ? o = '"' + e[t] + '"' : o = String(e[t]) : ne.has(e[t]) ? o = ne.get(e[t]) : (o = pe, ne.set(e[t], pe++)), r += "@" + o;
230
+ var i = void 0;
231
+ e[t] === null || typeof e[t] != "object" && typeof e[t] != "function" ? typeof e[t] == "string" ? i = '"' + e[t] + '"' : i = String(e[t]) : ne.has(e[t]) ? i = ne.get(e[t]) : (i = pe, ne.set(e[t], pe++)), r += "@" + i;
245
232
  }
246
233
  return r;
247
234
  }
@@ -265,18 +252,18 @@ var se = (
265
252
  }, e.prototype.get = function(r) {
266
253
  var t = this.serializeKey(r);
267
254
  return this.items.get(t);
268
- }, e.prototype.set = function(r, t, o) {
269
- var a = this.serializeKey(r), n = o || this.ttl, l = Date.now(), d = {
255
+ }, e.prototype.set = function(r, t, i) {
256
+ var a = this.serializeKey(r), n = i || this.ttl, u = Date.now(), c = {
270
257
  data: t,
271
- createdAt: l,
272
- expiresAt: n ? l + n : 1 / 0
258
+ createdAt: u,
259
+ expiresAt: n ? u + n : 1 / 0
273
260
  };
274
- this.dispatchExpire(n, d, a), this.items.set(a, d);
275
- }, e.prototype.dispatchExpire = function(r, t, o) {
261
+ this.dispatchExpire(n, c, a), this.items.set(a, c);
262
+ }, e.prototype.dispatchExpire = function(r, t, i) {
276
263
  var a = this;
277
264
  r && setTimeout(function() {
278
- var n = Date.now(), l = n >= t.expiresAt;
279
- l && a.delete(o);
265
+ var n = Date.now(), u = n >= t.expiresAt;
266
+ u && a.delete(i);
280
267
  }, r);
281
268
  }, e.prototype.delete = function(r) {
282
269
  this.items.delete(r);
@@ -286,131 +273,131 @@ var se = (
286
273
  function _r() {
287
274
  return typeof navigator.onLine < "u" ? navigator.onLine : !0;
288
275
  }
289
- function Sr() {
276
+ function Cr() {
290
277
  return typeof document < "u" && typeof document.visibilityState < "u" ? document.visibilityState !== "hidden" : !0;
291
278
  }
292
- var Cr = function(e) {
279
+ var Sr = function(e) {
293
280
  return fetch(e).then(function(r) {
294
281
  return r.json();
295
282
  });
296
283
  };
297
284
  const ae = {
298
285
  isOnline: _r,
299
- isDocumentVisible: Sr,
300
- fetcher: Cr
286
+ isDocumentVisible: Cr,
287
+ fetcher: Sr
301
288
  };
302
289
  var b = function() {
303
290
  return b = Object.assign || function(e) {
304
- for (var r, t = 1, o = arguments.length; t < o; t++) {
291
+ for (var r, t = 1, i = arguments.length; t < i; t++) {
305
292
  r = arguments[t];
306
293
  for (var a in r) Object.prototype.hasOwnProperty.call(r, a) && (e[a] = r[a]);
307
294
  }
308
295
  return e;
309
296
  }, b.apply(this, arguments);
310
- }, P = function(e, r, t, o) {
297
+ }, P = function(e, r, t, i) {
311
298
  function a(n) {
312
- return n instanceof t ? n : new t(function(l) {
313
- l(n);
299
+ return n instanceof t ? n : new t(function(u) {
300
+ u(n);
314
301
  });
315
302
  }
316
- return new (t || (t = Promise))(function(n, l) {
317
- function d(s) {
303
+ return new (t || (t = Promise))(function(n, u) {
304
+ function c(s) {
318
305
  try {
319
- i(o.next(s));
320
- } catch (u) {
321
- l(u);
306
+ o(i.next(s));
307
+ } catch (l) {
308
+ u(l);
322
309
  }
323
310
  }
324
- function f(s) {
311
+ function d(s) {
325
312
  try {
326
- i(o.throw(s));
327
- } catch (u) {
328
- l(u);
313
+ o(i.throw(s));
314
+ } catch (l) {
315
+ u(l);
329
316
  }
330
317
  }
331
- function i(s) {
332
- s.done ? n(s.value) : a(s.value).then(d, f);
318
+ function o(s) {
319
+ s.done ? n(s.value) : a(s.value).then(c, d);
333
320
  }
334
- i((o = o.apply(e, r || [])).next());
321
+ o((i = i.apply(e, r || [])).next());
335
322
  });
336
323
  }, $ = function(e, r) {
337
324
  var t = { label: 0, sent: function() {
338
325
  if (n[0] & 1) throw n[1];
339
326
  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() {
327
+ }, trys: [], ops: [] }, i, a, n, u;
328
+ return u = { next: c(0), throw: c(1), return: c(2) }, typeof Symbol == "function" && (u[Symbol.iterator] = function() {
342
329
  return this;
343
- }), l;
344
- function d(i) {
330
+ }), u;
331
+ function c(o) {
345
332
  return function(s) {
346
- return f([i, s]);
333
+ return d([o, s]);
347
334
  };
348
335
  }
349
- function f(i) {
350
- if (o) throw new TypeError("Generator is already executing.");
336
+ function d(o) {
337
+ if (i) throw new TypeError("Generator is already executing.");
351
338
  for (; t; ) try {
352
- if (o = 1, a && (n = i[0] & 2 ? a.return : i[0] ? a.throw || ((n = a.return) && n.call(a), 0) : a.next) && !(n = n.call(a, i[1])).done) return n;
353
- switch (a = 0, n && (i = [i[0] & 2, n.value]), i[0]) {
339
+ if (i = 1, a && (n = o[0] & 2 ? a.return : o[0] ? a.throw || ((n = a.return) && n.call(a), 0) : a.next) && !(n = n.call(a, o[1])).done) return n;
340
+ switch (a = 0, n && (o = [o[0] & 2, n.value]), o[0]) {
354
341
  case 0:
355
342
  case 1:
356
- n = i;
343
+ n = o;
357
344
  break;
358
345
  case 4:
359
- return t.label++, { value: i[1], done: !1 };
346
+ return t.label++, { value: o[1], done: !1 };
360
347
  case 5:
361
- t.label++, a = i[1], i = [0];
348
+ t.label++, a = o[1], o = [0];
362
349
  continue;
363
350
  case 7:
364
- i = t.ops.pop(), t.trys.pop();
351
+ o = t.ops.pop(), t.trys.pop();
365
352
  continue;
366
353
  default:
367
- if (n = t.trys, !(n = n.length > 0 && n[n.length - 1]) && (i[0] === 6 || i[0] === 2)) {
354
+ if (n = t.trys, !(n = n.length > 0 && n[n.length - 1]) && (o[0] === 6 || o[0] === 2)) {
368
355
  t = 0;
369
356
  continue;
370
357
  }
371
- if (i[0] === 3 && (!n || i[1] > n[0] && i[1] < n[3])) {
372
- t.label = i[1];
358
+ if (o[0] === 3 && (!n || o[1] > n[0] && o[1] < n[3])) {
359
+ t.label = o[1];
373
360
  break;
374
361
  }
375
- if (i[0] === 6 && t.label < n[1]) {
376
- t.label = n[1], n = i;
362
+ if (o[0] === 6 && t.label < n[1]) {
363
+ t.label = n[1], n = o;
377
364
  break;
378
365
  }
379
366
  if (n && t.label < n[2]) {
380
- t.label = n[2], t.ops.push(i);
367
+ t.label = n[2], t.ops.push(o);
381
368
  break;
382
369
  }
383
370
  n[2] && t.ops.pop(), t.trys.pop();
384
371
  continue;
385
372
  }
386
- i = r.call(e, t);
373
+ o = r.call(e, t);
387
374
  } catch (s) {
388
- i = [6, s], a = 0;
375
+ o = [6, s], a = 0;
389
376
  } finally {
390
- o = n = 0;
377
+ i = n = 0;
391
378
  }
392
- if (i[0] & 5) throw i[1];
393
- return { value: i[0] ? i[1] : void 0, done: !0 };
379
+ if (o[0] & 5) throw o[1];
380
+ return { value: o[0] ? o[1] : void 0, done: !0 };
394
381
  }
395
382
  }, Ir = function(e, r) {
396
383
  var t = typeof Symbol == "function" && e[Symbol.iterator];
397
384
  if (!t) return e;
398
- var o = t.call(e), a, n = [], l;
385
+ var i = t.call(e), a, n = [], u;
399
386
  try {
400
- for (; (r === void 0 || r-- > 0) && !(a = o.next()).done; ) n.push(a.value);
401
- } catch (d) {
402
- l = { error: d };
387
+ for (; (r === void 0 || r-- > 0) && !(a = i.next()).done; ) n.push(a.value);
388
+ } catch (c) {
389
+ u = { error: c };
403
390
  } finally {
404
391
  try {
405
- a && !a.done && (t = o.return) && t.call(o);
392
+ a && !a.done && (t = i.return) && t.call(i);
406
393
  } finally {
407
- if (l) throw l.error;
394
+ if (u) throw u.error;
408
395
  }
409
396
  }
410
397
  return n;
411
398
  }, Ar = function(e, r, t) {
412
- if (t || arguments.length === 2) for (var o = 0, a = r.length, n; o < a; o++)
413
- (n || !(o in r)) && (n || (n = Array.prototype.slice.call(r, 0, o)), n[o] = r[o]);
399
+ if (t || arguments.length === 2) for (var i = 0, a = r.length, n; i < a; i++)
400
+ (n || !(i in r)) && (n || (n = Array.prototype.slice.call(r, 0, i)), n[i] = r[i]);
414
401
  return e.concat(n || Array.prototype.slice.call(r));
415
402
  }, Oe = new se(), Q = new se(), ie = new se(), Le = {
416
403
  cache: Oe,
@@ -428,9 +415,9 @@ var b = function() {
428
415
  isDocumentVisible: ae.isDocumentVisible
429
416
  };
430
417
  function Dr(e, r, t) {
431
- var o = Q.get(e);
432
- if (o)
433
- o.data.push(r);
418
+ var i = Q.get(e);
419
+ if (i)
420
+ i.data.push(r);
434
421
  else {
435
422
  var a = 5e3;
436
423
  Q.set(e, [r], t > 0 ? t + a : t);
@@ -438,44 +425,44 @@ function Dr(e, r, t) {
438
425
  }
439
426
  function br(e, r, t) {
440
427
  if (t.isDocumentVisible() && !(t.errorRetryCount !== void 0 && r > t.errorRetryCount)) {
441
- var o = Math.min(r || 0, t.errorRetryCount), a = o * t.errorRetryInterval;
428
+ var i = Math.min(r || 0, t.errorRetryCount), a = i * t.errorRetryInterval;
442
429
  setTimeout(function() {
443
- e(null, { errorRetryCount: o + 1, shouldRetryOnError: !0 });
430
+ e(null, { errorRetryCount: i + 1, shouldRetryOnError: !0 });
444
431
  }, a);
445
432
  }
446
433
  }
447
- var Re = function(e, r, t, o) {
448
- 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) {
434
+ var Re = function(e, r, t, i) {
435
+ return t === void 0 && (t = Oe), i === void 0 && (i = Le.ttl), P(void 0, void 0, void 0, function() {
436
+ var a, n, u, c, d, o, s;
437
+ return $(this, function(l) {
438
+ switch (l.label) {
452
439
  case 0:
453
440
  if (!Or(r)) return [3, 5];
454
- u.label = 1;
441
+ l.label = 1;
455
442
  case 1:
456
- return u.trys.push([1, 3, , 4]), [4, r];
443
+ return l.trys.push([1, 3, , 4]), [4, r];
457
444
  case 2:
458
- return a = u.sent(), [3, 4];
445
+ return a = l.sent(), [3, 4];
459
446
  case 3:
460
- return d = u.sent(), n = d, [3, 4];
447
+ return c = l.sent(), n = c, [3, 4];
461
448
  case 4:
462
449
  return [3, 6];
463
450
  case 5:
464
- a = r, u.label = 6;
451
+ a = r, l.label = 6;
465
452
  case 6:
466
- if (l = !1, f = { data: a, error: n, isValidating: l }, typeof a < "u")
453
+ if (u = !1, d = { data: a, error: n, isValidating: u }, typeof a < "u")
467
454
  try {
468
- t.set(e, f, o);
469
- } catch (c) {
470
- console.error("swrv(mutate): failed to set cache", c);
455
+ t.set(e, d, i);
456
+ } catch (f) {
457
+ console.error("swrv(mutate): failed to set cache", f);
471
458
  }
472
- return i = Q.get(e), i && i.data.length && (s = i.data.filter(function(c) {
473
- return c.key === e;
474
- }), s.forEach(function(c, v) {
475
- typeof f.data < "u" && (c.data = f.data), c.error = f.error, c.isValidating = f.isValidating, c.isLoading = f.isValidating;
459
+ return o = Q.get(e), o && o.data.length && (s = o.data.filter(function(f) {
460
+ return f.key === e;
461
+ }), s.forEach(function(f, v) {
462
+ typeof d.data < "u" && (f.data = d.data), f.error = d.error, f.isValidating = d.isValidating, f.isLoading = d.isValidating;
476
463
  var p = v === s.length - 1;
477
464
  p || delete s[v];
478
- }), s = s.filter(Boolean)), [2, f];
465
+ }), s = s.filter(Boolean)), [2, d];
479
466
  }
480
467
  });
481
468
  });
@@ -483,12 +470,12 @@ var Re = function(e, r, t, o) {
483
470
  function wr() {
484
471
  for (var e = this, r = [], t = 0; t < arguments.length; t++)
485
472
  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;
487
- if (!i)
473
+ var i, a, n = b({}, Le), u = !1, c = !1, d = Me(), o = (d == null ? void 0 : d.proxy) || d;
474
+ if (!o)
488
475
  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
- var s = (i == null ? void 0 : i.$isServer) || !1;
490
- 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);
476
+ var s = (o == null ? void 0 : o.$isServer) || !1;
477
+ r.length >= 1 && (i = r[0]), r.length >= 2 && (a = r[1]), r.length > 2 && (n = b(b({}, n), r[2]));
478
+ var l = s ? n.serverTTL : n.ttl, f = typeof i == "function" ? i : Y(i);
492
479
  typeof a > "u" && (a = n.fetcher);
493
480
  var v = null;
494
481
  v || (v = Fe({
@@ -500,31 +487,31 @@ function wr() {
500
487
  }));
501
488
  var p = function(m, y) {
502
489
  return P(e, void 0, void 0, function() {
503
- var N, T, C, A, x, ce, J, de = this;
490
+ var k, T, S, A, x, ce, J, de = this;
504
491
  return $(this, function(Z) {
505
492
  switch (Z.label) {
506
493
  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, [
494
+ return k = v.data === void 0, T = f.value, T ? (S = n.cache.get(T), A = S && S.data, v.isValidating = !0, v.isLoading = !A, A && (v.data = A.data, v.error = A.error), x = m || a, !x || !n.isDocumentVisible() && !k || (y == null ? void 0 : y.forceRevalidate) !== void 0 && !(y != null && y.forceRevalidate) ? (v.isValidating = !1, v.isLoading = !1, [
508
495
  2
509
496
  /*return*/
510
- ]) : C && (ce = !!(Date.now() - C.createdAt >= n.dedupingInterval || y != null && y.forceRevalidate), !ce) ? (v.isValidating = !1, v.isLoading = !1, [
497
+ ]) : S && (ce = !!(Date.now() - S.createdAt >= n.dedupingInterval || y != null && y.forceRevalidate), !ce) ? (v.isValidating = !1, v.isLoading = !1, [
511
498
  2
512
499
  /*return*/
513
500
  ]) : (J = function() {
514
501
  return P(de, void 0, void 0, function() {
515
- var k, fe, ee, ve;
502
+ var M, fe, ee, ve;
516
503
  return $(this, function(X) {
517
504
  switch (X.label) {
518
505
  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)]);
506
+ return M = ie.get(T), M ? [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, l)]);
520
507
  case 1:
521
508
  return X.sent(), [3, 4];
522
509
  case 2:
523
- return [4, Re(T, k.data, n.cache, u)];
510
+ return [4, Re(T, M.data, n.cache, l)];
524
511
  case 3:
525
512
  X.sent(), X.label = 4;
526
513
  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)), [
514
+ return v.isValidating = !1, v.isLoading = !1, ie.delete(T), v.error !== void 0 && (ve = !u && n.shouldRetryOnError && (y ? y.shouldRetryOnError : !0), ve && br(p, y ? y.errorRetryCount : 1, n)), [
528
515
  2
529
516
  /*return*/
530
517
  ];
@@ -533,12 +520,12 @@ function wr() {
533
520
  });
534
521
  }, A && n.revalidateDebounce ? (setTimeout(function() {
535
522
  return P(de, void 0, void 0, function() {
536
- return $(this, function(k) {
537
- switch (k.label) {
523
+ return $(this, function(M) {
524
+ switch (M.label) {
538
525
  case 0:
539
- return l ? [3, 2] : [4, J()];
526
+ return u ? [3, 2] : [4, J()];
540
527
  case 1:
541
- k.sent(), k.label = 2;
528
+ M.sent(), M.label = 2;
542
529
  case 2:
543
530
  return [
544
531
  2
@@ -582,7 +569,7 @@ function wr() {
582
569
  case 2:
583
570
  h && clearTimeout(h), y.label = 3;
584
571
  case 3:
585
- return n.refreshInterval && !l && (h = setTimeout(m, n.refreshInterval)), [
572
+ return n.refreshInterval && !u && (h = setTimeout(m, n.refreshInterval)), [
586
573
  2
587
574
  /*return*/
588
575
  ];
@@ -592,15 +579,15 @@ function wr() {
592
579
  };
593
580
  n.refreshInterval && (h = setTimeout(m, n.refreshInterval)), n.revalidateOnFocus && (document.addEventListener("visibilitychange", _, !1), window.addEventListener("focus", _, !1));
594
581
  }), qe(function() {
595
- l = !0, h && clearTimeout(h), n.revalidateOnFocus && (document.removeEventListener("visibilitychange", _, !1), window.removeEventListener("focus", _, !1));
596
- var m = Q.get(c.value);
582
+ u = !0, h && clearTimeout(h), n.revalidateOnFocus && (document.removeEventListener("visibilitychange", _, !1), window.removeEventListener("focus", _, !1));
583
+ var m = Q.get(f.value);
597
584
  m && (m.data = m.data.filter(function(y) {
598
585
  return y !== v;
599
586
  }));
600
587
  });
601
588
  try {
602
- 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;
589
+ Ue(f, function(m) {
590
+ Pe(f) || (f.value = m), v.key = m, v.isValidating = !!m, Dr(f.value, v, l), !s && !c && f.value && p(), c = !1;
604
591
  }, {
605
592
  immediate: !0
606
593
  });
@@ -616,10 +603,10 @@ function Or(e) {
616
603
  }
617
604
  function Lr(e, r, t) {
618
605
  const {
619
- data: o,
606
+ data: i,
620
607
  error: a,
621
608
  isValidating: n,
622
- mutate: l
609
+ mutate: u
623
610
  } = wr(e, r, {
624
611
  revalidateDebounce: 500,
625
612
  revalidateOnFocus: !1,
@@ -627,41 +614,41 @@ function Lr(e, r, t) {
627
614
  ...t
628
615
  });
629
616
  return {
630
- data: g(() => o.value),
631
- response: o,
617
+ data: g(() => i.value),
618
+ response: i,
632
619
  error: a,
633
620
  isValidating: n,
634
- revalidate: l
621
+ revalidate: u
635
622
  };
636
623
  }
637
- const V = {
624
+ const N = {
638
625
  useI18n: cr,
639
626
  useMetricCardBuilder: pr,
640
627
  useMetricFetcher: hr,
641
628
  useTrendRange: Rr,
642
629
  useRequest: Lr
643
- }, Me = Symbol("METRICS_PROVIDER_KEY"), Mr = (e) => {
630
+ }, Ve = Symbol("METRICS_PROVIDER_KEY"), Vr = (e) => {
644
631
  const {
645
632
  datasource: r,
646
633
  dimension: t,
647
- dimensionFilterValue: o,
634
+ dimensionFilterValue: i,
648
635
  additionalFilter: a,
649
636
  queryReady: n,
650
- timeRange: l,
651
- hasTrendAccess: d,
652
- refreshInterval: f,
653
- abortController: i,
637
+ timeRange: u,
638
+ hasTrendAccess: c,
639
+ refreshInterval: d,
640
+ abortController: o,
654
641
  queryFn: s,
655
- averageLatencies: u
642
+ averageLatencies: l
656
643
  } = e;
657
- if (o && !t)
644
+ if (i && !t)
658
645
  throw new Error("Must provide a dimension if filtering by a value");
659
- const c = !!(t && o), v = !!(t && !o), p = g(() => {
646
+ const f = !!(t && i), v = !!(t && !i), p = g(() => {
660
647
  const y = [];
661
- return c && y.push({
648
+ return f && y.push({
662
649
  field: t,
663
650
  operator: "in",
664
- value: [o]
651
+ value: [i]
665
652
  }), a.value && y.push(...je(r.value, a.value)), y;
666
653
  }), _ = {
667
654
  datasource: r,
@@ -671,36 +658,36 @@ const V = {
671
658
  // Traffic and error rate cards should only try to query for the dimension if it's going to be used.
672
659
  // It isn't used for single entity queries.
673
660
  dimensions: [
674
- ...t && !c ? [t] : [],
661
+ ...t && !f ? [t] : [],
675
662
  "status_code_grouped"
676
663
  ],
677
664
  filter: p,
678
665
  queryReady: n,
679
- timeRange: l,
666
+ timeRange: u,
680
667
  // Traffic and error rate cards can't query trend if multiple entities are expected.
681
- withTrend: g(() => d.value && !v),
682
- refreshInterval: f,
668
+ withTrend: g(() => c.value && !v),
669
+ refreshInterval: d,
683
670
  queryFn: s,
684
- abortController: i,
671
+ abortController: o,
685
672
  refreshCounter: e.refreshCounter
686
673
  }, h = {
687
674
  datasource: r,
688
675
  metrics: g(() => [
689
- u.value ? "response_latency_average" : "response_latency_p99"
676
+ l.value ? "response_latency_average" : "response_latency_p99"
690
677
  ]),
691
678
  // To keep single-entity queries consistent, don't bother querying the dimension for latency
692
679
  // in the single-entity case, even though it's possible.
693
- ...t && !c ? { dimensions: [t] } : {},
680
+ ...t && !f ? { dimensions: [t] } : {},
694
681
  filter: p,
695
682
  queryReady: n,
696
- timeRange: l,
683
+ timeRange: u,
697
684
  // Don't query latency trends in the multi-entity case: it's possible, but wasteful.
698
- withTrend: g(() => d.value && !v),
699
- refreshInterval: f,
685
+ withTrend: g(() => c.value && !v),
686
+ refreshInterval: d,
700
687
  queryFn: s,
701
- abortController: i,
688
+ abortController: o,
702
689
  refreshCounter: e.refreshCounter
703
- }, I = V.useMetricFetcher(_), m = V.useMetricFetcher(h);
690
+ }, I = N.useMetricFetcher(_), m = N.useMetricFetcher(h);
704
691
  return {
705
692
  trafficData: I,
706
693
  latencyData: m
@@ -725,87 +712,87 @@ const V = {
725
712
  },
726
713
  setup(e) {
727
714
  const r = e;
728
- if (r.dimension && He.findIndex((c) => c === r.dimension) === -1)
715
+ if (r.dimension && He.findIndex((f) => f === r.dimension) === -1)
729
716
  throw new Error(`Attempted to use MetricsProvider with an invalid dimension: ${r.dimension}`);
730
- const t = Se(vr);
731
- let o;
732
- 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(() => {
734
- const c = r.overrideTimeRange;
735
- return c && !c.tz && (c.tz = new Intl.DateTimeFormat().resolvedOptions().timeZone), c || {
717
+ const t = Ce(vr);
718
+ let i;
719
+ t ? i = 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"), i = () => Promise.reject(new Error("Query bridge required")));
720
+ const a = We(), n = g(() => !0), u = g(() => !a.loading && r.queryReady), c = g(() => r.datasource ? r.datasource : "basic"), d = g(() => {
721
+ const f = r.overrideTimeRange;
722
+ return f && !f.tz && (f.tz = new Intl.DateTimeFormat().resolvedOptions().timeZone), f || {
736
723
  type: "relative",
737
724
  time_range: "7d",
738
725
  tz: new Intl.DateTimeFormat().resolvedOptions().timeZone
739
726
  };
740
- }), i = g(() => !r.percentileLatency), {
727
+ }), o = g(() => !r.percentileLatency), {
741
728
  trafficData: s,
742
- latencyData: u
743
- } = Mr({
744
- datasource: d,
729
+ latencyData: l
730
+ } = Vr({
731
+ datasource: c,
745
732
  dimension: r.dimension,
746
733
  dimensionFilterValue: r.filterValue,
747
734
  additionalFilter: G(r, "additionalFilter"),
748
- queryReady: l,
749
- timeRange: f,
735
+ queryReady: u,
736
+ timeRange: d,
750
737
  hasTrendAccess: n,
751
738
  refreshInterval: r.refreshInterval,
752
- queryFn: o,
753
- averageLatencies: i,
739
+ queryFn: i,
740
+ averageLatencies: o,
754
741
  abortController: r.abortController,
755
742
  refreshCounter: G(r, "refreshCounter")
756
743
  });
757
- return ze(Me, {
744
+ return ze(Ve, {
758
745
  data: {
759
746
  traffic: s,
760
- latency: u
747
+ latency: l
761
748
  },
762
749
  description: G(() => r.description),
763
750
  containerTitle: G(() => r.containerTitle),
764
751
  hasTrendAccess: n,
765
752
  longCardTitles: r.longCardTitles,
766
- averageLatencies: i
767
- }), (c, v) => Ce(c.$slots, "default", {
753
+ averageLatencies: o
754
+ }), (f, v) => Se(f.$slots, "default", {
768
755
  hasTrendAccess: n.value,
769
- timeRange: f.value
756
+ timeRange: d.value
770
757
  });
771
758
  }
772
759
  });
773
- function Vr(e) {
760
+ function Nr(e) {
774
761
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
775
762
  }
776
- var Ve = { exports: {} };
763
+ var Ne = { exports: {} };
777
764
  (function(e) {
778
765
  (function() {
779
- function r(i, s) {
780
- if (s.separator === !1 || i < 1e3)
781
- return i.toString();
782
- var u = typeof s.separator == "string" ? s.separator : ",", c = [], v = Math.round(i).toString().split("");
766
+ function r(o, s) {
767
+ if (s.separator === !1 || o < 1e3)
768
+ return o.toString();
769
+ var l = typeof s.separator == "string" ? s.separator : ",", f = [], v = Math.round(o).toString().split("");
783
770
  return v.reverse().forEach(function(p, _) {
784
- _ && _ % 3 === 0 && c.push(u), c.push(p);
785
- }), c.reverse().join("");
771
+ _ && _ % 3 === 0 && f.push(l), f.push(p);
772
+ }), f.reverse().join("");
786
773
  }
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);
774
+ function t(o, s, l) {
775
+ var f = o / s, v = l.round ? "round" : "floor";
776
+ return l.decimal === !1 ? (o = Math[v](f), o.toString()) : (l.precision ? o = f : o = f < 10 ? Math[v](f * 10) / 10 : Math[v](f), o = o.toString(), typeof l.decimal == "string" && (o = o.replace(".", l.decimal)), o);
790
777
  }
791
- var o = 1e3, a = 1e4, n = 1e6, l = 1e9, d = 1e12;
792
- function f(i, s) {
793
- var u;
778
+ var i = 1e3, a = 1e4, n = 1e6, u = 1e9, c = 1e12;
779
+ function d(o, s) {
780
+ var l;
794
781
  s = s || {};
795
- var c = i < 0;
796
- c && (i = Math.abs(i)), s.precision && (i = parseFloat(i.toPrecision(s.precision)));
797
- 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;
782
+ var f = o < 0;
783
+ f && (o = Math.abs(o)), s.precision && (o = parseFloat(o.toPrecision(s.precision)));
784
+ var v = s.min10k ? a : i;
785
+ return o < v || s.precision && s.precision > Math.log10(o) ? l = r(t(o, 1, s), s) : o < n ? l = t(o, i, s) + "k" : o < u ? l = t(o, n, s) + "m" : o < c ? l = r(t(o, u, s), s) + "b" : l = r(t(o, c, s), s) + "t", f && (l = "-" + l), s.capital && (l = l.toUpperCase()), s.prefix && (l = s.prefix + l), s.suffix && (l = l + s.suffix), l;
799
786
  }
800
- f.addCommas = r, e.exports = f;
787
+ d.addCommas = r, e.exports = d;
801
788
  })();
802
- })(Ve);
803
- var Nr = Ve.exports;
804
- const kr = /* @__PURE__ */ Vr(Nr);
789
+ })(Ne);
790
+ var kr = Ne.exports;
791
+ const Mr = /* @__PURE__ */ Nr(kr);
805
792
  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
793
  const ue = 2, Te = ue + 2, Fr = (e, r, t = !1) => {
807
- let o = !r || Number(e.toFixed(Te)) === 0 ? 0 : Number(e.toFixed(Te)) > 0 ? 1 : -1;
808
- return t && (o *= -1), o;
794
+ let i = !r || Number(e.toFixed(Te)) === 0 ? 0 : Number(e.toFixed(Te)) > 0 ? 1 : -1;
795
+ return t && (i *= -1), i;
809
796
  }, 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 = {
810
797
  key: 0,
811
798
  class: "metricscard-description"
@@ -895,23 +882,23 @@ const ue = 2, Te = ue + 2, Fr = (e, r, t = !1) => {
895
882
  [O.TRAFFIC, rr],
896
883
  [O.ERROR_RATE, tr],
897
884
  [O.LATENCY, nr]
898
- ]), t = e, o = (d) => {
899
- const f = {
885
+ ]), t = e, i = (c) => {
886
+ const d = {
900
887
  red: `var(--kui-color-text-danger-strong, ${Pr})`,
901
888
  green: `var(--kui-color-text-success, ${$r})`,
902
889
  grey: `var(--kui-color-text-neutral-strong, ${Ee})`
903
890
  };
904
- 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);
906
- return (d, f) => {
907
- const i = Ie("KTooltip");
908
- return R(), S("div", {
891
+ return c > 0 ? d.green : c < 0 ? d.red : d.grey;
892
+ }, a = (c) => c > 0 ? "positive" : c < 0 ? "negative" : "neutral", n = [D.Medium, D.Large].includes(t.cardSize), u = [D.Small].includes(t.cardSize);
893
+ return (c, d) => {
894
+ const o = Ie("KTooltip");
895
+ return R(), C("div", {
909
896
  class: z(["metricscard", e.cardSize])
910
897
  }, [
911
898
  q("div", {
912
899
  class: z(["metricscard-title", e.cardSize])
913
900
  }, [
914
- E(l) ? M("", !0) : (R(), U(re(E(r).get(e.cardType)), {
901
+ E(u) ? V("", !0) : (R(), U(re(E(r).get(e.cardType)), {
915
902
  key: 0,
916
903
  class: "metricscard-icon",
917
904
  color: `var(--kui-color-text-neutral, ${E(oe)})`,
@@ -923,7 +910,7 @@ const ue = 2, Te = ue + 2, Fr = (e, r, t = !1) => {
923
910
  ]),
924
911
  _: 1
925
912
  })),
926
- e.tooltip ? (R(), U(i, {
913
+ e.tooltip ? (R(), U(o, {
927
914
  key: 1,
928
915
  class: "metricscard-tooltip",
929
916
  placement: "right",
@@ -936,31 +923,31 @@ const ue = 2, Te = ue + 2, Fr = (e, r, t = !1) => {
936
923
  }, null, 8, ["color", "size"])
937
924
  ]),
938
925
  _: 1
939
- }, 8, ["text"])) : M("", !0)
926
+ }, 8, ["text"])) : V("", !0)
940
927
  ], 2),
941
- e.description && E(n) ? (R(), S("div", Kr, [
928
+ e.description && E(n) ? (R(), C("div", Kr, [
942
929
  q("span", null, w(e.description), 1)
943
- ])) : M("", !0),
930
+ ])) : V("", !0),
944
931
  q("div", Br, [
945
- e.hasError ? (R(), S("div", Xr, [
932
+ e.hasError ? (R(), C("div", Xr, [
946
933
  F(E(be), {
947
934
  color: `var(--kui-color-text-neutral, ${E(oe)})`,
948
935
  size: E(zr)
949
936
  }, null, 8, ["color", "size"]),
950
937
  q("div", null, " " + w(e.errorMessage), 1)
951
- ])) : (R(), S("div", {
938
+ ])) : (R(), C("div", {
952
939
  key: 1,
953
940
  class: z(["metricscard-value", e.cardSize]),
954
941
  "data-testid": "metric-value"
955
942
  }, w(e.metricValue), 3)),
956
- E(n) ? (R(), S("div", Gr, [
943
+ E(n) ? (R(), C("div", Gr, [
957
944
  q("div", {
958
945
  class: z(["metricscard-trend-change", a(e.changePolarity)]),
959
946
  "data-testid": "metric-trend-parent"
960
947
  }, [
961
948
  e.changePolarity !== 0 ? (R(), U(re(e.trendIcon), {
962
949
  key: 0,
963
- color: o(e.changePolarity),
950
+ color: i(e.changePolarity),
964
951
  size: E(j)
965
952
  }, null, 8, ["color", "size"])) : (R(), U(E(ir), {
966
953
  key: 1,
@@ -969,21 +956,21 @@ const ue = 2, Te = ue + 2, Fr = (e, r, t = !1) => {
969
956
  }, null, 8, ["color", "size"])),
970
957
  q("div", jr, w(e.metricChange), 1)
971
958
  ], 2),
972
- e.trendRange ? (R(), S("div", Hr, w(e.trendRange), 1)) : M("", !0)
973
- ])) : M("", !0)
959
+ e.trendRange ? (R(), C("div", Hr, w(e.trendRange), 1)) : V("", !0)
960
+ ])) : V("", !0)
974
961
  ])
975
962
  ], 2);
976
963
  };
977
964
  }
978
965
  }), le = (e, r) => {
979
966
  const t = e.__vccOpts || e;
980
- for (const [o, a] of r)
981
- t[o] = a;
967
+ for (const [i, a] of r)
968
+ t[i] = a;
982
969
  return t;
983
970
  }, Qr = /* @__PURE__ */ le(Yr, [["__scopeId", "data-v-b1513f6f"]]), Wr = {}, Jr = { class: "loading-tabs" };
984
971
  function Zr(e, r) {
985
972
  const t = Ie("KSkeletonBox");
986
- return R(), S("div", Jr, [
973
+ return R(), C("div", Jr, [
987
974
  F(t, { width: "100" }),
988
975
  F(t, { width: "75" })
989
976
  ]);
@@ -1046,46 +1033,46 @@ const et = /* @__PURE__ */ le(Wr, [["render", Zr], ["__scopeId", "data-v-9c7113d
1046
1033
  }
1047
1034
  },
1048
1035
  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);
1036
+ const r = e, t = g(() => r.cards.every((a) => (a == null ? void 0 : a.hasError) === !0)), i = (a) => {
1037
+ const n = qr(a.currentValue, a.previousValue) || 0, u = Fr(n, r.hasTrendAccess, a.increaseIsBad);
1051
1038
  return {
1052
- metricValue: a.formatValueFn ? a.formatValueFn(a.currentValue) : kr(a.currentValue, { capital: !0, round: !0 }) || "0",
1039
+ metricValue: a.formatValueFn ? a.formatValueFn(a.currentValue) : Mr(a.currentValue, { capital: !0, round: !0 }) || "0",
1053
1040
  metricChange: a.formatChangeFn ? a.formatChangeFn(n) : xr(n, r.hasTrendAccess, r.fallbackDisplayText),
1054
- changePolarity: l,
1055
- trendIcon: Ur(l, a.increaseIsBad),
1041
+ changePolarity: u,
1042
+ trendIcon: Ur(u, a.increaseIsBad),
1056
1043
  cardSize: r.cardSize,
1057
1044
  hasContainerTitle: !!r.containerTitle
1058
1045
  };
1059
1046
  };
1060
- return (a, n) => (R(), S("div", {
1047
+ return (a, n) => (R(), C("div", {
1061
1048
  class: z(["kong-ui-public-metric-card-container", e.cardSize])
1062
1049
  }, [
1063
- r.containerTitle || r.containerDescription ? (R(), S("div", rt, [
1050
+ r.containerTitle || r.containerDescription ? (R(), C("div", rt, [
1064
1051
  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, [
1052
+ r.containerDescription ? (R(), C("div", tt, w(r.containerDescription), 1)) : V("", !0)
1053
+ ])) : V("", !0),
1054
+ t.value ? (R(), C("div", nt, [
1068
1055
  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", {
1073
- key: `skeleton-${d}`,
1056
+ e.errorMessage ? (R(), C("div", at, w(e.errorMessage), 1)) : V("", !0)
1057
+ ])) : (R(), C("div", it, [
1058
+ (R(!0), C(ye, null, Ke(e.cards, (u, c) => (R(), C(ye, null, [
1059
+ e.loading ? (R(), C("div", {
1060
+ key: `skeleton-${c}`,
1074
1061
  class: "loading-tab"
1075
1062
  }, [
1076
1063
  F(et, {
1077
1064
  class: z(e.cardSize === E(D).Small ? "loading-tabs-small" : "loading-tabs-large")
1078
1065
  }, null, 8, ["class"])
1079
- ])) : (R(), U(Qr, Be({ key: d }, { ref_for: !0 }, o(l), {
1066
+ ])) : (R(), U(Qr, Be({ key: c }, { ref_for: !0 }, i(u), {
1080
1067
  "card-size": e.cardSize,
1081
- "card-type": l.cardType,
1082
- description: l.description,
1068
+ "card-type": u.cardType,
1069
+ description: u.description,
1083
1070
  "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
1071
+ "has-error": u.hasError,
1072
+ title: u.title,
1073
+ "title-tag": u.titleTag,
1074
+ tooltip: u.tooltip,
1075
+ "trend-range": u.trendRange
1089
1076
  }), null, 16, ["card-size", "card-type", "description", "error-message", "has-error", "title", "title-tag", "tooltip", "trend-range"]))
1090
1077
  ], 64))), 256))
1091
1078
  ]))
@@ -1099,34 +1086,34 @@ const et = /* @__PURE__ */ le(Wr, [["render", Zr], ["__scopeId", "data-v-9c7113d
1099
1086
  cardToDisplay: { default: void 0 }
1100
1087
  },
1101
1088
  setup(e) {
1102
- const r = e, t = Se(Me);
1089
+ const r = e, t = Ce(Ve);
1103
1090
  if (!t)
1104
1091
  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({
1092
+ const { traffic: i, latency: a } = t.data, { i18n: n } = N.useI18n(), u = g(() => t.containerTitle.value ? D.Medium : r.cardSize), c = N.useMetricCardBuilder({
1106
1093
  cardType: O.TRAFFIC,
1107
1094
  title: g(() => t.longCardTitles ? n.t("metricCard.long.traffic") : n.t("metricCard.short.traffic")),
1108
- record: o.mapped,
1109
- hasError: o.hasError,
1095
+ record: i.mapped,
1096
+ hasError: i.hasError,
1110
1097
  lookupKey: r.lookupKey,
1111
1098
  sumGroupedValues: B,
1112
- 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;
1099
+ trendRange: i.trendRange
1100
+ }), d = (h) => `${h.toFixed(ue)}%`, o = g(() => {
1101
+ const h = i.mapped.value, I = K(h, "current", r.lookupKey, ge), m = K(h, "current", r.lookupKey, B), y = I / m * 100 || 0, k = K(h, "previous", r.lookupKey, ge), T = K(h, "previous", r.lookupKey, B), S = k / T * 100 || 0;
1115
1102
  return {
1116
1103
  cardType: O.ERROR_RATE,
1117
- hasError: o.hasError.value,
1104
+ hasError: i.hasError.value,
1118
1105
  currentValue: y,
1119
- previousValue: C,
1120
- formatValueFn: f,
1106
+ previousValue: S,
1107
+ formatValueFn: d,
1121
1108
  title: t.longCardTitles ? n.t("metricCard.long.errorRate") : n.t("metricCard.short.errorRate"),
1122
1109
  increaseIsBad: !0,
1123
- trendRange: o.trendRange.value
1110
+ trendRange: i.trendRange.value
1124
1111
  };
1125
- }), s = (h) => `${h}ms`, u = V.useMetricCardBuilder({
1112
+ }), s = (h) => `${h}ms`, l = N.useMetricCardBuilder({
1126
1113
  cardType: O.LATENCY,
1127
1114
  title: g(() => {
1128
1115
  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}`);
1116
+ return h ? n.t(`metricCard.long.${m}`) : u.value === D.Small ? n.t(`metricCard.small.${m}`) : n.t(`metricCard.short.${m}`);
1130
1117
  }),
1131
1118
  hasError: a.hasError,
1132
1119
  record: a.mapped,
@@ -1134,24 +1121,24 @@ const et = /* @__PURE__ */ le(Wr, [["render", Zr], ["__scopeId", "data-v-9c7113d
1134
1121
  increaseIsBad: !0,
1135
1122
  formatValueFn: s,
1136
1123
  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(() => ({
1138
- cards: c.value,
1124
+ }), f = g(() => r.cardToDisplay === "TRAFFIC" ? [c.value] : r.cardToDisplay === "ERROR_RATE" ? [o.value] : r.cardToDisplay === "LATENCY" ? [l.value] : [c.value, o.value, l.value]), v = g(() => r.cardToDisplay === "TRAFFIC" || r.cardToDisplay === "ERROR_RATE" ? i.isLoading.value : r.cardToDisplay === "LATENCY" ? a.isLoading.value : i.isLoading.value || a.isLoading.value), p = g(() => ({
1125
+ cards: f.value,
1139
1126
  containerTitle: t.containerTitle.value,
1140
1127
  containerDescription: t.description.value,
1141
1128
  loading: v.value,
1142
1129
  hasTrendAccess: t.hasTrendAccess.value,
1143
1130
  fallbackDisplayText: n.t("general.notAvailable"),
1144
- cardSize: l.value,
1131
+ cardSize: u.value,
1145
1132
  hideTitle: !0
1146
1133
  })), _ = g(() => ({
1147
1134
  loading: p.value.loading,
1148
- trafficCard: d.value,
1149
- errorRateCard: i.value,
1150
- latencyCard: u.value,
1151
- errorRateFormatted: f(i.value.currentValue),
1152
- latencyFormatted: s(u.value.currentValue)
1135
+ trafficCard: c.value,
1136
+ errorRateCard: o.value,
1137
+ latencyCard: l.value,
1138
+ errorRateFormatted: d(o.value.currentValue),
1139
+ latencyFormatted: s(l.value.currentValue)
1153
1140
  }));
1154
- return (h, I) => Ce(h.$slots, "default", { cardValues: _.value }, () => [
1141
+ return (h, I) => Se(h.$slots, "default", { cardValues: _.value }, () => [
1155
1142
  F(st, Xe(Ge(p.value)), null, 16)
1156
1143
  ]);
1157
1144
  }
@@ -1174,42 +1161,42 @@ const et = /* @__PURE__ */ le(Wr, [["render", Zr], ["__scopeId", "data-v-9c7113d
1174
1161
  } : {
1175
1162
  start: new Date(Date.now() - 864e5),
1176
1163
  end: /* @__PURE__ */ new Date()
1177
- }, o = t.end.getTime() - t.start.getTime(), a = e.granularity === "trend" ? {
1178
- start: new Date(t.start.getTime() - o),
1164
+ }, i = t.end.getTime() - t.start.getTime(), a = e.granularity === "trend" ? {
1165
+ start: new Date(t.start.getTime() - i),
1179
1166
  end: t.end,
1180
1167
  granularity: t.end.getTime() - t.start.getTime()
1181
1168
  } : {
1182
1169
  start: t.start,
1183
1170
  end: t.end,
1184
1171
  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;
1172
+ }, n = a.end.getTime(), u = a.start.getTime(), c = a.granularity, d = e.granularity === "trend" ? 2 : 1;
1186
1173
  if ((e.dimensions ?? []).length > 2)
1187
1174
  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 = [];
1189
- for (let m = 0; m < f; m++)
1190
- for (let y = 0; y < u; y++) {
1191
- const N = i ? { [i]: s[y] } : {};
1175
+ const o = (e.dimensions ?? []).find((m) => m !== "time"), s = (r == null ? void 0 : r.dimensionNames) ?? [], l = Math.max(s.length, 1), f = e.metrics || [], v = [];
1176
+ for (let m = 0; m < d; m++)
1177
+ for (let y = 0; y < l; y++) {
1178
+ const k = o ? { [o]: s[y] } : {};
1192
1179
  (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 });
1180
+ const S = f.reduce((A, x) => ((r == null ? void 0 : r.deterministic) ?? !0 ? A[x] = (d - m) * 1e3 + 100 * y + 1 : A[x] = Math.round(Math.random() * 1e3), A), { ...k, status_code_grouped: T });
1194
1181
  v.push({
1195
1182
  version: "v1",
1196
- timestamp: m === 0 ? H(l).toISOString() : H(l + d).toISOString(),
1197
- event: C
1183
+ timestamp: m === 0 ? H(u).toISOString() : H(u + c).toISOString(),
1184
+ event: S
1198
1185
  });
1199
1186
  }) : v.push({
1200
1187
  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 })
1188
+ timestamp: m === 0 ? H(u).toISOString() : H(u + c).toISOString(),
1189
+ event: f.reduce((T, S) => ((r == null ? void 0 : r.deterministic) ?? !0 ? T[S] = (d - m) * 1e3 + 100 * y + 1 : T[S] = Math.round(Math.random() * 1e3), T), { ...k })
1203
1190
  });
1204
1191
  }
1205
1192
  const p = {
1206
- start_ms: l,
1193
+ start_ms: u,
1207
1194
  end_ms: n,
1208
- start: new Date(l).toISOString(),
1195
+ start: new Date(u).toISOString(),
1209
1196
  end: new Date(n).toISOString(),
1210
- granularity_ms: d,
1211
- display: i ? {
1212
- [i]: _e(s),
1197
+ granularity_ms: c,
1198
+ display: o ? {
1199
+ [o]: _e(s),
1213
1200
  ...(I = e.dimensions) != null && I.includes("status_code_grouped") ? { status_code_grouped: _e(B) } : {}
1214
1201
  } : {},
1215
1202
  metric_names: e.metrics,