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