@grafana/scenes 5.11.0 → 5.11.1--canary.830.10631142943.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -14,6 +14,8 @@ var ui = require('@grafana/ui');
14
14
  var e2eSelectors = require('@grafana/e2e-selectors');
15
15
  var css = require('@emotion/css');
16
16
  var uFuzzy = require('@leeoniya/ufuzzy');
17
+ var react = require('@floating-ui/react');
18
+ var reactVirtual = require('@tanstack/react-virtual');
17
19
  var reactUse = require('react-use');
18
20
  var operators = require('rxjs/operators');
19
21
  var ReactGridLayout = require('react-grid-layout');
@@ -39,19 +41,19 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
39
41
  var uFuzzy__default = /*#__PURE__*/_interopDefaultLegacy(uFuzzy);
40
42
  var ReactGridLayout__default = /*#__PURE__*/_interopDefaultLegacy(ReactGridLayout);
41
43
 
42
- var __defProp$L = Object.defineProperty;
43
- var __getOwnPropSymbols$L = Object.getOwnPropertySymbols;
44
- var __hasOwnProp$L = Object.prototype.hasOwnProperty;
45
- var __propIsEnum$L = Object.prototype.propertyIsEnumerable;
46
- var __defNormalProp$L = (obj, key, value) => key in obj ? __defProp$L(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
47
- var __spreadValues$L = (a, b) => {
44
+ var __defProp$O = Object.defineProperty;
45
+ var __getOwnPropSymbols$O = Object.getOwnPropertySymbols;
46
+ var __hasOwnProp$O = Object.prototype.hasOwnProperty;
47
+ var __propIsEnum$O = Object.prototype.propertyIsEnumerable;
48
+ var __defNormalProp$O = (obj, key, value) => key in obj ? __defProp$O(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
49
+ var __spreadValues$O = (a, b) => {
48
50
  for (var prop in b || (b = {}))
49
- if (__hasOwnProp$L.call(b, prop))
50
- __defNormalProp$L(a, prop, b[prop]);
51
- if (__getOwnPropSymbols$L)
52
- for (var prop of __getOwnPropSymbols$L(b)) {
53
- if (__propIsEnum$L.call(b, prop))
54
- __defNormalProp$L(a, prop, b[prop]);
51
+ if (__hasOwnProp$O.call(b, prop))
52
+ __defNormalProp$O(a, prop, b[prop]);
53
+ if (__getOwnPropSymbols$O)
54
+ for (var prop of __getOwnPropSymbols$O(b)) {
55
+ if (__propIsEnum$O.call(b, prop))
56
+ __defNormalProp$O(a, prop, b[prop]);
55
57
  }
56
58
  return a;
57
59
  };
@@ -60,7 +62,7 @@ function useAppQueryParams() {
60
62
  return runtime.locationSearchToObject(location.search || "");
61
63
  }
62
64
  function getUrlWithAppState(path, preserveParams) {
63
- const paramsCopy = __spreadValues$L({}, runtime.locationService.getSearchObject());
65
+ const paramsCopy = __spreadValues$O({}, runtime.locationService.getSearchObject());
64
66
  if (preserveParams) {
65
67
  for (const key of Object.keys(paramsCopy)) {
66
68
  if (!preserveParams.includes(key)) {
@@ -74,31 +76,31 @@ function renderSceneComponentWithRouteProps(sceneObject, routeProps) {
74
76
  return React__default["default"].createElement(sceneObject.Component, { model: sceneObject, routeProps });
75
77
  }
76
78
 
77
- var __defProp$K = Object.defineProperty;
78
- var __defProps$s = Object.defineProperties;
79
- var __getOwnPropDescs$s = Object.getOwnPropertyDescriptors;
80
- var __getOwnPropSymbols$K = Object.getOwnPropertySymbols;
81
- var __hasOwnProp$K = Object.prototype.hasOwnProperty;
82
- var __propIsEnum$K = Object.prototype.propertyIsEnumerable;
83
- var __defNormalProp$K = (obj, key, value) => key in obj ? __defProp$K(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
84
- var __spreadValues$K = (a, b) => {
79
+ var __defProp$N = Object.defineProperty;
80
+ var __defProps$u = Object.defineProperties;
81
+ var __getOwnPropDescs$u = Object.getOwnPropertyDescriptors;
82
+ var __getOwnPropSymbols$N = Object.getOwnPropertySymbols;
83
+ var __hasOwnProp$N = Object.prototype.hasOwnProperty;
84
+ var __propIsEnum$N = Object.prototype.propertyIsEnumerable;
85
+ var __defNormalProp$N = (obj, key, value) => key in obj ? __defProp$N(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
86
+ var __spreadValues$N = (a, b) => {
85
87
  for (var prop in b || (b = {}))
86
- if (__hasOwnProp$K.call(b, prop))
87
- __defNormalProp$K(a, prop, b[prop]);
88
- if (__getOwnPropSymbols$K)
89
- for (var prop of __getOwnPropSymbols$K(b)) {
90
- if (__propIsEnum$K.call(b, prop))
91
- __defNormalProp$K(a, prop, b[prop]);
88
+ if (__hasOwnProp$N.call(b, prop))
89
+ __defNormalProp$N(a, prop, b[prop]);
90
+ if (__getOwnPropSymbols$N)
91
+ for (var prop of __getOwnPropSymbols$N(b)) {
92
+ if (__propIsEnum$N.call(b, prop))
93
+ __defNormalProp$N(a, prop, b[prop]);
92
94
  }
93
95
  return a;
94
96
  };
95
- var __spreadProps$s = (a, b) => __defProps$s(a, __getOwnPropDescs$s(b));
97
+ var __spreadProps$u = (a, b) => __defProps$u(a, __getOwnPropDescs$u(b));
96
98
  const runtimePanelPlugins = /* @__PURE__ */ new Map();
97
99
  function registerRuntimePanelPlugin({ pluginId, plugin }) {
98
100
  if (runtimePanelPlugins.has(pluginId)) {
99
101
  throw new Error(`A runtime panel plugin with id ${pluginId} has already been registered`);
100
102
  }
101
- plugin.meta = __spreadProps$s(__spreadValues$K({}, plugin.meta), {
103
+ plugin.meta = __spreadProps$u(__spreadValues$N({}, plugin.meta), {
102
104
  id: pluginId,
103
105
  name: pluginId,
104
106
  module: "runtime plugin",
@@ -126,39 +128,39 @@ function loadPanelPluginSync(pluginId) {
126
128
  return (_a = getPanelPluginFromCache(pluginId)) != null ? _a : runtimePanelPlugins.get(pluginId);
127
129
  }
128
130
 
129
- var __defProp$J = Object.defineProperty;
130
- var __defProps$r = Object.defineProperties;
131
- var __getOwnPropDescs$r = Object.getOwnPropertyDescriptors;
132
- var __getOwnPropSymbols$J = Object.getOwnPropertySymbols;
133
- var __hasOwnProp$J = Object.prototype.hasOwnProperty;
134
- var __propIsEnum$J = Object.prototype.propertyIsEnumerable;
135
- var __defNormalProp$J = (obj, key, value) => key in obj ? __defProp$J(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
136
- var __spreadValues$J = (a, b) => {
131
+ var __defProp$M = Object.defineProperty;
132
+ var __defProps$t = Object.defineProperties;
133
+ var __getOwnPropDescs$t = Object.getOwnPropertyDescriptors;
134
+ var __getOwnPropSymbols$M = Object.getOwnPropertySymbols;
135
+ var __hasOwnProp$M = Object.prototype.hasOwnProperty;
136
+ var __propIsEnum$M = Object.prototype.propertyIsEnumerable;
137
+ var __defNormalProp$M = (obj, key, value) => key in obj ? __defProp$M(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
138
+ var __spreadValues$M = (a, b) => {
137
139
  for (var prop in b || (b = {}))
138
- if (__hasOwnProp$J.call(b, prop))
139
- __defNormalProp$J(a, prop, b[prop]);
140
- if (__getOwnPropSymbols$J)
141
- for (var prop of __getOwnPropSymbols$J(b)) {
142
- if (__propIsEnum$J.call(b, prop))
143
- __defNormalProp$J(a, prop, b[prop]);
140
+ if (__hasOwnProp$M.call(b, prop))
141
+ __defNormalProp$M(a, prop, b[prop]);
142
+ if (__getOwnPropSymbols$M)
143
+ for (var prop of __getOwnPropSymbols$M(b)) {
144
+ if (__propIsEnum$M.call(b, prop))
145
+ __defNormalProp$M(a, prop, b[prop]);
144
146
  }
145
147
  return a;
146
148
  };
147
- var __spreadProps$r = (a, b) => __defProps$r(a, __getOwnPropDescs$r(b));
148
- var __objRest$4 = (source, exclude) => {
149
+ var __spreadProps$t = (a, b) => __defProps$t(a, __getOwnPropDescs$t(b));
150
+ var __objRest$5 = (source, exclude) => {
149
151
  var target = {};
150
152
  for (var prop in source)
151
- if (__hasOwnProp$J.call(source, prop) && exclude.indexOf(prop) < 0)
153
+ if (__hasOwnProp$M.call(source, prop) && exclude.indexOf(prop) < 0)
152
154
  target[prop] = source[prop];
153
- if (source != null && __getOwnPropSymbols$J)
154
- for (var prop of __getOwnPropSymbols$J(source)) {
155
- if (exclude.indexOf(prop) < 0 && __propIsEnum$J.call(source, prop))
155
+ if (source != null && __getOwnPropSymbols$M)
156
+ for (var prop of __getOwnPropSymbols$M(source)) {
157
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$M.call(source, prop))
156
158
  target[prop] = source[prop];
157
159
  }
158
160
  return target;
159
161
  };
160
162
  function SceneComponentWrapperWithoutMemo(_a) {
161
- var _b = _a, { model } = _b, otherProps = __objRest$4(_b, ["model"]);
163
+ var _b = _a, { model } = _b, otherProps = __objRest$5(_b, ["model"]);
162
164
  var _a2;
163
165
  const Component = (_a2 = model.constructor["Component"]) != null ? _a2 : EmptyRenderer;
164
166
  const [_, setValue] = React.useState(0);
@@ -170,7 +172,7 @@ function SceneComponentWrapperWithoutMemo(_a) {
170
172
  if (!model.isActive) {
171
173
  return null;
172
174
  }
173
- return /* @__PURE__ */ React__default["default"].createElement(Component, __spreadProps$r(__spreadValues$J({}, otherProps), {
175
+ return /* @__PURE__ */ React__default["default"].createElement(Component, __spreadProps$t(__spreadValues$M({}, otherProps), {
174
176
  model
175
177
  }));
176
178
  }
@@ -216,19 +218,19 @@ class SceneObjectRef {
216
218
  }
217
219
  _ref = new WeakMap();
218
220
 
219
- var __defProp$I = Object.defineProperty;
220
- var __getOwnPropSymbols$I = Object.getOwnPropertySymbols;
221
- var __hasOwnProp$I = Object.prototype.hasOwnProperty;
222
- var __propIsEnum$I = Object.prototype.propertyIsEnumerable;
223
- var __defNormalProp$I = (obj, key, value) => key in obj ? __defProp$I(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
224
- var __spreadValues$I = (a, b) => {
221
+ var __defProp$L = Object.defineProperty;
222
+ var __getOwnPropSymbols$L = Object.getOwnPropertySymbols;
223
+ var __hasOwnProp$L = Object.prototype.hasOwnProperty;
224
+ var __propIsEnum$L = Object.prototype.propertyIsEnumerable;
225
+ var __defNormalProp$L = (obj, key, value) => key in obj ? __defProp$L(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
226
+ var __spreadValues$L = (a, b) => {
225
227
  for (var prop in b || (b = {}))
226
- if (__hasOwnProp$I.call(b, prop))
227
- __defNormalProp$I(a, prop, b[prop]);
228
- if (__getOwnPropSymbols$I)
229
- for (var prop of __getOwnPropSymbols$I(b)) {
230
- if (__propIsEnum$I.call(b, prop))
231
- __defNormalProp$I(a, prop, b[prop]);
228
+ if (__hasOwnProp$L.call(b, prop))
229
+ __defNormalProp$L(a, prop, b[prop]);
230
+ if (__getOwnPropSymbols$L)
231
+ for (var prop of __getOwnPropSymbols$L(b)) {
232
+ if (__propIsEnum$L.call(b, prop))
233
+ __defNormalProp$L(a, prop, b[prop]);
232
234
  }
233
235
  return a;
234
236
  };
@@ -288,7 +290,7 @@ class SceneObjectBase {
288
290
  }
289
291
  setState(update) {
290
292
  const prevState = this._state;
291
- const newState = __spreadValues$I(__spreadValues$I({}, this._state), update);
293
+ const newState = __spreadValues$L(__spreadValues$L({}, this._state), update);
292
294
  this._state = Object.freeze(newState);
293
295
  this._setParent(update);
294
296
  this._handleActivationOfChangedStateProps(prevState, newState);
@@ -484,19 +486,19 @@ function forEachChild(state, callback) {
484
486
  }
485
487
  }
486
488
 
487
- var __defProp$H = Object.defineProperty;
488
- var __getOwnPropSymbols$H = Object.getOwnPropertySymbols;
489
- var __hasOwnProp$H = Object.prototype.hasOwnProperty;
490
- var __propIsEnum$H = Object.prototype.propertyIsEnumerable;
491
- var __defNormalProp$H = (obj, key, value) => key in obj ? __defProp$H(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
492
- var __spreadValues$H = (a, b) => {
489
+ var __defProp$K = Object.defineProperty;
490
+ var __getOwnPropSymbols$K = Object.getOwnPropertySymbols;
491
+ var __hasOwnProp$K = Object.prototype.hasOwnProperty;
492
+ var __propIsEnum$K = Object.prototype.propertyIsEnumerable;
493
+ var __defNormalProp$K = (obj, key, value) => key in obj ? __defProp$K(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
494
+ var __spreadValues$K = (a, b) => {
493
495
  for (var prop in b || (b = {}))
494
- if (__hasOwnProp$H.call(b, prop))
495
- __defNormalProp$H(a, prop, b[prop]);
496
- if (__getOwnPropSymbols$H)
497
- for (var prop of __getOwnPropSymbols$H(b)) {
498
- if (__propIsEnum$H.call(b, prop))
499
- __defNormalProp$H(a, prop, b[prop]);
496
+ if (__hasOwnProp$K.call(b, prop))
497
+ __defNormalProp$K(a, prop, b[prop]);
498
+ if (__getOwnPropSymbols$K)
499
+ for (var prop of __getOwnPropSymbols$K(b)) {
500
+ if (__propIsEnum$K.call(b, prop))
501
+ __defNormalProp$K(a, prop, b[prop]);
500
502
  }
501
503
  return a;
502
504
  };
@@ -505,7 +507,7 @@ function cloneSceneObject(sceneObject, withState) {
505
507
  return new sceneObject.constructor(clonedState);
506
508
  }
507
509
  function cloneSceneObjectState(sceneState, withState) {
508
- const clonedState = __spreadValues$H({}, sceneState);
510
+ const clonedState = __spreadValues$K({}, sceneState);
509
511
  for (const key in clonedState) {
510
512
  const propValue = clonedState[key];
511
513
  if (propValue instanceof SceneObjectBase) {
@@ -602,25 +604,25 @@ function lookupVariable(name, sceneObject) {
602
604
  return null;
603
605
  }
604
606
 
605
- var __defProp$G = Object.defineProperty;
606
- var __getOwnPropSymbols$G = Object.getOwnPropertySymbols;
607
- var __hasOwnProp$G = Object.prototype.hasOwnProperty;
608
- var __propIsEnum$G = Object.prototype.propertyIsEnumerable;
609
- var __defNormalProp$G = (obj, key, value) => key in obj ? __defProp$G(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
610
- var __spreadValues$G = (a, b) => {
607
+ var __defProp$J = Object.defineProperty;
608
+ var __getOwnPropSymbols$J = Object.getOwnPropertySymbols;
609
+ var __hasOwnProp$J = Object.prototype.hasOwnProperty;
610
+ var __propIsEnum$J = Object.prototype.propertyIsEnumerable;
611
+ var __defNormalProp$J = (obj, key, value) => key in obj ? __defProp$J(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
612
+ var __spreadValues$J = (a, b) => {
611
613
  for (var prop in b || (b = {}))
612
- if (__hasOwnProp$G.call(b, prop))
613
- __defNormalProp$G(a, prop, b[prop]);
614
- if (__getOwnPropSymbols$G)
615
- for (var prop of __getOwnPropSymbols$G(b)) {
616
- if (__propIsEnum$G.call(b, prop))
617
- __defNormalProp$G(a, prop, b[prop]);
614
+ if (__hasOwnProp$J.call(b, prop))
615
+ __defNormalProp$J(a, prop, b[prop]);
616
+ if (__getOwnPropSymbols$J)
617
+ for (var prop of __getOwnPropSymbols$J(b)) {
618
+ if (__propIsEnum$J.call(b, prop))
619
+ __defNormalProp$J(a, prop, b[prop]);
618
620
  }
619
621
  return a;
620
622
  };
621
623
  class SceneDataNode extends SceneObjectBase {
622
624
  constructor(state) {
623
- super(__spreadValues$G({
625
+ super(__spreadValues$J({
624
626
  data: emptyPanelData
625
627
  }, state));
626
628
  }
@@ -701,19 +703,19 @@ function evaluateTimeRange(from, to, timeZone, fiscalYearStartMonth, delay) {
701
703
  };
702
704
  }
703
705
 
704
- var __defProp$F = Object.defineProperty;
705
- var __getOwnPropSymbols$F = Object.getOwnPropertySymbols;
706
- var __hasOwnProp$F = Object.prototype.hasOwnProperty;
707
- var __propIsEnum$F = Object.prototype.propertyIsEnumerable;
708
- var __defNormalProp$F = (obj, key, value) => key in obj ? __defProp$F(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
709
- var __spreadValues$F = (a, b) => {
706
+ var __defProp$I = Object.defineProperty;
707
+ var __getOwnPropSymbols$I = Object.getOwnPropertySymbols;
708
+ var __hasOwnProp$I = Object.prototype.hasOwnProperty;
709
+ var __propIsEnum$I = Object.prototype.propertyIsEnumerable;
710
+ var __defNormalProp$I = (obj, key, value) => key in obj ? __defProp$I(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
711
+ var __spreadValues$I = (a, b) => {
710
712
  for (var prop in b || (b = {}))
711
- if (__hasOwnProp$F.call(b, prop))
712
- __defNormalProp$F(a, prop, b[prop]);
713
- if (__getOwnPropSymbols$F)
714
- for (var prop of __getOwnPropSymbols$F(b)) {
715
- if (__propIsEnum$F.call(b, prop))
716
- __defNormalProp$F(a, prop, b[prop]);
713
+ if (__hasOwnProp$I.call(b, prop))
714
+ __defNormalProp$I(a, prop, b[prop]);
715
+ if (__getOwnPropSymbols$I)
716
+ for (var prop of __getOwnPropSymbols$I(b)) {
717
+ if (__propIsEnum$I.call(b, prop))
718
+ __defNormalProp$I(a, prop, b[prop]);
717
719
  }
718
720
  return a;
719
721
  };
@@ -731,7 +733,7 @@ class SceneTimeRange extends SceneObjectBase {
731
733
  state.UNSAFE_nowDelay
732
734
  );
733
735
  const refreshOnActivate = (_c = state.refreshOnActivate) != null ? _c : { percent: 10 };
734
- super(__spreadValues$F({ from, to, timeZone, value, refreshOnActivate }, state));
736
+ super(__spreadValues$I({ from, to, timeZone, value, refreshOnActivate }, state));
735
737
  this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: ["from", "to", "timezone"] });
736
738
  this.onTimeRangeChange = (timeRange) => {
737
739
  const update = {};
@@ -1398,25 +1400,25 @@ function collectAllVariables(sceneObject, record = {}) {
1398
1400
  return record;
1399
1401
  }
1400
1402
 
1401
- var __defProp$E = Object.defineProperty;
1402
- var __defProps$q = Object.defineProperties;
1403
- var __getOwnPropDescs$q = Object.getOwnPropertyDescriptors;
1404
- var __getOwnPropSymbols$E = Object.getOwnPropertySymbols;
1405
- var __hasOwnProp$E = Object.prototype.hasOwnProperty;
1406
- var __propIsEnum$E = Object.prototype.propertyIsEnumerable;
1407
- var __defNormalProp$E = (obj, key, value) => key in obj ? __defProp$E(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1408
- var __spreadValues$E = (a, b) => {
1403
+ var __defProp$H = Object.defineProperty;
1404
+ var __defProps$s = Object.defineProperties;
1405
+ var __getOwnPropDescs$s = Object.getOwnPropertyDescriptors;
1406
+ var __getOwnPropSymbols$H = Object.getOwnPropertySymbols;
1407
+ var __hasOwnProp$H = Object.prototype.hasOwnProperty;
1408
+ var __propIsEnum$H = Object.prototype.propertyIsEnumerable;
1409
+ var __defNormalProp$H = (obj, key, value) => key in obj ? __defProp$H(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1410
+ var __spreadValues$H = (a, b) => {
1409
1411
  for (var prop in b || (b = {}))
1410
- if (__hasOwnProp$E.call(b, prop))
1411
- __defNormalProp$E(a, prop, b[prop]);
1412
- if (__getOwnPropSymbols$E)
1413
- for (var prop of __getOwnPropSymbols$E(b)) {
1414
- if (__propIsEnum$E.call(b, prop))
1415
- __defNormalProp$E(a, prop, b[prop]);
1412
+ if (__hasOwnProp$H.call(b, prop))
1413
+ __defNormalProp$H(a, prop, b[prop]);
1414
+ if (__getOwnPropSymbols$H)
1415
+ for (var prop of __getOwnPropSymbols$H(b)) {
1416
+ if (__propIsEnum$H.call(b, prop))
1417
+ __defNormalProp$H(a, prop, b[prop]);
1416
1418
  }
1417
1419
  return a;
1418
1420
  };
1419
- var __spreadProps$q = (a, b) => __defProps$q(a, __getOwnPropDescs$q(b));
1421
+ var __spreadProps$s = (a, b) => __defProps$s(a, __getOwnPropDescs$s(b));
1420
1422
  function getTemplateProxyForField(field, frame, frames) {
1421
1423
  return new Proxy(
1422
1424
  {},
@@ -1432,7 +1434,7 @@ function getTemplateProxyForField(field, frame, frames) {
1432
1434
  if (!field.labels) {
1433
1435
  return "";
1434
1436
  }
1435
- return __spreadProps$q(__spreadValues$E({}, field.labels), {
1437
+ return __spreadProps$s(__spreadValues$H({}, field.labels), {
1436
1438
  __values: Object.values(field.labels).sort().join(", "),
1437
1439
  toString: () => {
1438
1440
  return data.formatLabels(field.labels, "", true);
@@ -1929,25 +1931,25 @@ function isExtraQueryProvider(obj) {
1929
1931
  return typeof obj === "object" && "getExtraQueries" in obj;
1930
1932
  }
1931
1933
 
1932
- var __defProp$D = Object.defineProperty;
1933
- var __defProps$p = Object.defineProperties;
1934
- var __getOwnPropDescs$p = Object.getOwnPropertyDescriptors;
1935
- var __getOwnPropSymbols$D = Object.getOwnPropertySymbols;
1936
- var __hasOwnProp$D = Object.prototype.hasOwnProperty;
1937
- var __propIsEnum$D = Object.prototype.propertyIsEnumerable;
1938
- var __defNormalProp$D = (obj, key, value) => key in obj ? __defProp$D(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1939
- var __spreadValues$D = (a, b) => {
1934
+ var __defProp$G = Object.defineProperty;
1935
+ var __defProps$r = Object.defineProperties;
1936
+ var __getOwnPropDescs$r = Object.getOwnPropertyDescriptors;
1937
+ var __getOwnPropSymbols$G = Object.getOwnPropertySymbols;
1938
+ var __hasOwnProp$G = Object.prototype.hasOwnProperty;
1939
+ var __propIsEnum$G = Object.prototype.propertyIsEnumerable;
1940
+ var __defNormalProp$G = (obj, key, value) => key in obj ? __defProp$G(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1941
+ var __spreadValues$G = (a, b) => {
1940
1942
  for (var prop in b || (b = {}))
1941
- if (__hasOwnProp$D.call(b, prop))
1942
- __defNormalProp$D(a, prop, b[prop]);
1943
- if (__getOwnPropSymbols$D)
1944
- for (var prop of __getOwnPropSymbols$D(b)) {
1945
- if (__propIsEnum$D.call(b, prop))
1946
- __defNormalProp$D(a, prop, b[prop]);
1943
+ if (__hasOwnProp$G.call(b, prop))
1944
+ __defNormalProp$G(a, prop, b[prop]);
1945
+ if (__getOwnPropSymbols$G)
1946
+ for (var prop of __getOwnPropSymbols$G(b)) {
1947
+ if (__propIsEnum$G.call(b, prop))
1948
+ __defNormalProp$G(a, prop, b[prop]);
1947
1949
  }
1948
1950
  return a;
1949
1951
  };
1950
- var __spreadProps$p = (a, b) => __defProps$p(a, __getOwnPropDescs$p(b));
1952
+ var __spreadProps$r = (a, b) => __defProps$r(a, __getOwnPropDescs$r(b));
1951
1953
  const passthroughProcessor = (_, secondary) => rxjs.of(secondary);
1952
1954
  const extraQueryProcessingOperator = (processors) => (data) => {
1953
1955
  return data.pipe(
@@ -1960,7 +1962,7 @@ const extraQueryProcessingOperator = (processors) => (data) => {
1960
1962
  }),
1961
1963
  rxjs.map(([primary, ...processedSecondaries]) => {
1962
1964
  var _a;
1963
- return __spreadProps$p(__spreadValues$D({}, primary), {
1965
+ return __spreadProps$r(__spreadValues$G({}, primary), {
1964
1966
  series: [...primary.series, ...processedSecondaries.flatMap((s) => s.series)],
1965
1967
  annotations: [...(_a = primary.annotations) != null ? _a : [], ...processedSecondaries.flatMap((s) => {
1966
1968
  var _a2;
@@ -1971,25 +1973,25 @@ const extraQueryProcessingOperator = (processors) => (data) => {
1971
1973
  );
1972
1974
  };
1973
1975
 
1974
- var __defProp$C = Object.defineProperty;
1975
- var __defProps$o = Object.defineProperties;
1976
- var __getOwnPropDescs$o = Object.getOwnPropertyDescriptors;
1977
- var __getOwnPropSymbols$C = Object.getOwnPropertySymbols;
1978
- var __hasOwnProp$C = Object.prototype.hasOwnProperty;
1979
- var __propIsEnum$C = Object.prototype.propertyIsEnumerable;
1980
- var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1981
- var __spreadValues$C = (a, b) => {
1976
+ var __defProp$F = Object.defineProperty;
1977
+ var __defProps$q = Object.defineProperties;
1978
+ var __getOwnPropDescs$q = Object.getOwnPropertyDescriptors;
1979
+ var __getOwnPropSymbols$F = Object.getOwnPropertySymbols;
1980
+ var __hasOwnProp$F = Object.prototype.hasOwnProperty;
1981
+ var __propIsEnum$F = Object.prototype.propertyIsEnumerable;
1982
+ var __defNormalProp$F = (obj, key, value) => key in obj ? __defProp$F(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1983
+ var __spreadValues$F = (a, b) => {
1982
1984
  for (var prop in b || (b = {}))
1983
- if (__hasOwnProp$C.call(b, prop))
1984
- __defNormalProp$C(a, prop, b[prop]);
1985
- if (__getOwnPropSymbols$C)
1986
- for (var prop of __getOwnPropSymbols$C(b)) {
1987
- if (__propIsEnum$C.call(b, prop))
1988
- __defNormalProp$C(a, prop, b[prop]);
1985
+ if (__hasOwnProp$F.call(b, prop))
1986
+ __defNormalProp$F(a, prop, b[prop]);
1987
+ if (__getOwnPropSymbols$F)
1988
+ for (var prop of __getOwnPropSymbols$F(b)) {
1989
+ if (__propIsEnum$F.call(b, prop))
1990
+ __defNormalProp$F(a, prop, b[prop]);
1989
1991
  }
1990
1992
  return a;
1991
1993
  };
1992
- var __spreadProps$o = (a, b) => __defProps$o(a, __getOwnPropDescs$o(b));
1994
+ var __spreadProps$q = (a, b) => __defProps$q(a, __getOwnPropDescs$q(b));
1993
1995
  function filterAnnotations(data, filters) {
1994
1996
  var _a;
1995
1997
  if (!Array.isArray(data) || data.length === 0) {
@@ -2040,11 +2042,11 @@ function filterAnnotations(data, filters) {
2040
2042
  continue;
2041
2043
  }
2042
2044
  }
2043
- fields.push(__spreadProps$o(__spreadValues$C({}, field), {
2045
+ fields.push(__spreadProps$q(__spreadValues$F({}, field), {
2044
2046
  values: buffer
2045
2047
  }));
2046
2048
  }
2047
- processed.push(__spreadProps$o(__spreadValues$C({}, frame), {
2049
+ processed.push(__spreadProps$q(__spreadValues$F({}, frame), {
2048
2050
  fields,
2049
2051
  length: frameLength
2050
2052
  }));
@@ -2475,33 +2477,33 @@ function getOptionSearcher(options, includeAll) {
2475
2477
  };
2476
2478
  }
2477
2479
 
2478
- var __defProp$B = Object.defineProperty;
2479
- var __defProps$n = Object.defineProperties;
2480
- var __getOwnPropDescs$n = Object.getOwnPropertyDescriptors;
2481
- var __getOwnPropSymbols$B = Object.getOwnPropertySymbols;
2482
- var __hasOwnProp$B = Object.prototype.hasOwnProperty;
2483
- var __propIsEnum$B = Object.prototype.propertyIsEnumerable;
2484
- var __defNormalProp$B = (obj, key, value) => key in obj ? __defProp$B(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2485
- var __spreadValues$B = (a, b) => {
2480
+ var __defProp$E = Object.defineProperty;
2481
+ var __defProps$p = Object.defineProperties;
2482
+ var __getOwnPropDescs$p = Object.getOwnPropertyDescriptors;
2483
+ var __getOwnPropSymbols$E = Object.getOwnPropertySymbols;
2484
+ var __hasOwnProp$E = Object.prototype.hasOwnProperty;
2485
+ var __propIsEnum$E = Object.prototype.propertyIsEnumerable;
2486
+ var __defNormalProp$E = (obj, key, value) => key in obj ? __defProp$E(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2487
+ var __spreadValues$E = (a, b) => {
2486
2488
  for (var prop in b || (b = {}))
2487
- if (__hasOwnProp$B.call(b, prop))
2488
- __defNormalProp$B(a, prop, b[prop]);
2489
- if (__getOwnPropSymbols$B)
2490
- for (var prop of __getOwnPropSymbols$B(b)) {
2491
- if (__propIsEnum$B.call(b, prop))
2492
- __defNormalProp$B(a, prop, b[prop]);
2493
- }
2494
- return a;
2495
- };
2496
- var __spreadProps$n = (a, b) => __defProps$n(a, __getOwnPropDescs$n(b));
2497
- var __objRest$3 = (source, exclude) => {
2489
+ if (__hasOwnProp$E.call(b, prop))
2490
+ __defNormalProp$E(a, prop, b[prop]);
2491
+ if (__getOwnPropSymbols$E)
2492
+ for (var prop of __getOwnPropSymbols$E(b)) {
2493
+ if (__propIsEnum$E.call(b, prop))
2494
+ __defNormalProp$E(a, prop, b[prop]);
2495
+ }
2496
+ return a;
2497
+ };
2498
+ var __spreadProps$p = (a, b) => __defProps$p(a, __getOwnPropDescs$p(b));
2499
+ var __objRest$4 = (source, exclude) => {
2498
2500
  var target = {};
2499
2501
  for (var prop in source)
2500
- if (__hasOwnProp$B.call(source, prop) && exclude.indexOf(prop) < 0)
2502
+ if (__hasOwnProp$E.call(source, prop) && exclude.indexOf(prop) < 0)
2501
2503
  target[prop] = source[prop];
2502
- if (source != null && __getOwnPropSymbols$B)
2503
- for (var prop of __getOwnPropSymbols$B(source)) {
2504
- if (exclude.indexOf(prop) < 0 && __propIsEnum$B.call(source, prop))
2504
+ if (source != null && __getOwnPropSymbols$E)
2505
+ for (var prop of __getOwnPropSymbols$E(source)) {
2506
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$E.call(source, prop))
2505
2507
  target[prop] = source[prop];
2506
2508
  }
2507
2509
  return target;
@@ -2629,11 +2631,11 @@ const OptionWithCheckbox = ({
2629
2631
  renderOptionLabel
2630
2632
  }) => {
2631
2633
  var _b;
2632
- const _a = innerProps, rest = __objRest$3(_a, ["onMouseMove", "onMouseOver"]);
2634
+ const _a = innerProps, rest = __objRest$4(_a, ["onMouseMove", "onMouseOver"]);
2633
2635
  const theme = ui.useTheme2();
2634
2636
  const selectStyles = ui.getSelectStyles(theme);
2635
2637
  const optionStyles = ui.useStyles2(getOptionStyles);
2636
- return /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$n(__spreadValues$B({
2638
+ return /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$p(__spreadValues$E({
2637
2639
  ref: innerRef,
2638
2640
  className: css.cx(selectStyles.option, isFocused && selectStyles.optionFocused)
2639
2641
  }, rest), {
@@ -2797,28 +2799,28 @@ function wrapInSafeSerializableSceneObject(sceneObject) {
2797
2799
  return { value: sceneObject, text: "__sceneObject" };
2798
2800
  }
2799
2801
 
2800
- var __defProp$A = Object.defineProperty;
2801
- var __defProps$m = Object.defineProperties;
2802
- var __getOwnPropDescs$m = Object.getOwnPropertyDescriptors;
2803
- var __getOwnPropSymbols$A = Object.getOwnPropertySymbols;
2804
- var __hasOwnProp$A = Object.prototype.hasOwnProperty;
2805
- var __propIsEnum$A = Object.prototype.propertyIsEnumerable;
2806
- var __defNormalProp$A = (obj, key, value) => key in obj ? __defProp$A(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2807
- var __spreadValues$A = (a, b) => {
2802
+ var __defProp$D = Object.defineProperty;
2803
+ var __defProps$o = Object.defineProperties;
2804
+ var __getOwnPropDescs$o = Object.getOwnPropertyDescriptors;
2805
+ var __getOwnPropSymbols$D = Object.getOwnPropertySymbols;
2806
+ var __hasOwnProp$D = Object.prototype.hasOwnProperty;
2807
+ var __propIsEnum$D = Object.prototype.propertyIsEnumerable;
2808
+ var __defNormalProp$D = (obj, key, value) => key in obj ? __defProp$D(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2809
+ var __spreadValues$D = (a, b) => {
2808
2810
  for (var prop in b || (b = {}))
2809
- if (__hasOwnProp$A.call(b, prop))
2810
- __defNormalProp$A(a, prop, b[prop]);
2811
- if (__getOwnPropSymbols$A)
2812
- for (var prop of __getOwnPropSymbols$A(b)) {
2813
- if (__propIsEnum$A.call(b, prop))
2814
- __defNormalProp$A(a, prop, b[prop]);
2811
+ if (__hasOwnProp$D.call(b, prop))
2812
+ __defNormalProp$D(a, prop, b[prop]);
2813
+ if (__getOwnPropSymbols$D)
2814
+ for (var prop of __getOwnPropSymbols$D(b)) {
2815
+ if (__propIsEnum$D.call(b, prop))
2816
+ __defNormalProp$D(a, prop, b[prop]);
2815
2817
  }
2816
2818
  return a;
2817
2819
  };
2818
- var __spreadProps$m = (a, b) => __defProps$m(a, __getOwnPropDescs$m(b));
2820
+ var __spreadProps$o = (a, b) => __defProps$o(a, __getOwnPropDescs$o(b));
2819
2821
  class GroupByVariable extends MultiValueVariable {
2820
2822
  constructor(initialState) {
2821
- super(__spreadProps$m(__spreadValues$A({
2823
+ super(__spreadProps$o(__spreadValues$D({
2822
2824
  isMulti: true,
2823
2825
  name: "",
2824
2826
  value: [],
@@ -2849,7 +2851,7 @@ class GroupByVariable extends MultiValueVariable {
2849
2851
  const queries = getQueriesForVariables(this);
2850
2852
  const otherFilters = this.state.baseFilters || [];
2851
2853
  const timeRange = sceneGraph.getTimeRange(this).state.value;
2852
- const response = await ds.getTagKeys(__spreadValues$A({
2854
+ const response = await ds.getTagKeys(__spreadValues$D({
2853
2855
  filters: otherFilters,
2854
2856
  queries,
2855
2857
  timeRange
@@ -3044,7 +3046,7 @@ function LoadingIndicator(props) {
3044
3046
  }
3045
3047
 
3046
3048
  function ControlsLabel(props) {
3047
- const styles = ui.useStyles2(getStyles$a);
3049
+ const styles = ui.useStyles2(getStyles$e);
3048
3050
  const theme = ui.useTheme2();
3049
3051
  const isVertical = props.layout === "vertical";
3050
3052
  const loadingIndicator = Boolean(props.isLoading) ? /* @__PURE__ */ React__default["default"].createElement("div", {
@@ -3107,7 +3109,7 @@ function ControlsLabel(props) {
3107
3109
  }
3108
3110
  return labelElement;
3109
3111
  }
3110
- const getStyles$a = (theme) => ({
3112
+ const getStyles$e = (theme) => ({
3111
3113
  horizontalLabel: css.css({
3112
3114
  background: theme.isDark ? theme.colors.background.primary : theme.colors.background.secondary,
3113
3115
  display: `flex`,
@@ -3178,19 +3180,19 @@ function getAdhocOptionSearcher(options) {
3178
3180
  };
3179
3181
  }
3180
3182
 
3181
- var __defProp$z = Object.defineProperty;
3182
- var __getOwnPropSymbols$z = Object.getOwnPropertySymbols;
3183
- var __hasOwnProp$z = Object.prototype.hasOwnProperty;
3184
- var __propIsEnum$z = Object.prototype.propertyIsEnumerable;
3185
- var __defNormalProp$z = (obj, key, value) => key in obj ? __defProp$z(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3186
- var __spreadValues$z = (a, b) => {
3183
+ var __defProp$C = Object.defineProperty;
3184
+ var __getOwnPropSymbols$C = Object.getOwnPropertySymbols;
3185
+ var __hasOwnProp$C = Object.prototype.hasOwnProperty;
3186
+ var __propIsEnum$C = Object.prototype.propertyIsEnumerable;
3187
+ var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3188
+ var __spreadValues$C = (a, b) => {
3187
3189
  for (var prop in b || (b = {}))
3188
- if (__hasOwnProp$z.call(b, prop))
3189
- __defNormalProp$z(a, prop, b[prop]);
3190
- if (__getOwnPropSymbols$z)
3191
- for (var prop of __getOwnPropSymbols$z(b)) {
3192
- if (__propIsEnum$z.call(b, prop))
3193
- __defNormalProp$z(a, prop, b[prop]);
3190
+ if (__hasOwnProp$C.call(b, prop))
3191
+ __defNormalProp$C(a, prop, b[prop]);
3192
+ if (__getOwnPropSymbols$C)
3193
+ for (var prop of __getOwnPropSymbols$C(b)) {
3194
+ if (__propIsEnum$C.call(b, prop))
3195
+ __defNormalProp$C(a, prop, b[prop]);
3194
3196
  }
3195
3197
  return a;
3196
3198
  };
@@ -3203,7 +3205,7 @@ function keyLabelToOption(key, label) {
3203
3205
  const filterNoOp = () => true;
3204
3206
  function AdHocFilterRenderer({ filter, model }) {
3205
3207
  var _a, _b, _c;
3206
- const styles = ui.useStyles2(getStyles$9);
3208
+ const styles = ui.useStyles2(getStyles$d);
3207
3209
  const [keys, setKeys] = React.useState([]);
3208
3210
  const [values, setValues] = React.useState([]);
3209
3211
  const [isKeysLoading, setIsKeysLoading] = React.useState(false);
@@ -3274,7 +3276,7 @@ function AdHocFilterRenderer({ filter, model }) {
3274
3276
  });
3275
3277
  }
3276
3278
  };
3277
- const valueSelect = /* @__PURE__ */ React__default["default"].createElement(ui.Select, __spreadValues$z({
3279
+ const valueSelect = /* @__PURE__ */ React__default["default"].createElement(ui.Select, __spreadValues$C({
3278
3280
  virtualized: true,
3279
3281
  allowCustomValue: true,
3280
3282
  isValidNewOption: (inputValue) => inputValue.trim().length > 0,
@@ -3406,7 +3408,7 @@ function AdHocFilterRenderer({ filter, model }) {
3406
3408
  onClick: () => model._removeFilter(filter)
3407
3409
  }));
3408
3410
  }
3409
- const getStyles$9 = (theme) => ({
3411
+ const getStyles$d = (theme) => ({
3410
3412
  field: css.css({
3411
3413
  marginBottom: 0
3412
3414
  }),
@@ -3558,6 +3560,815 @@ function isFilter(filter) {
3558
3560
  return filter !== null && typeof filter.key === "string" && typeof filter.value === "string";
3559
3561
  }
3560
3562
 
3563
+ var __defProp$B = Object.defineProperty;
3564
+ var __getOwnPropSymbols$B = Object.getOwnPropertySymbols;
3565
+ var __hasOwnProp$B = Object.prototype.hasOwnProperty;
3566
+ var __propIsEnum$B = Object.prototype.propertyIsEnumerable;
3567
+ var __defNormalProp$B = (obj, key, value) => key in obj ? __defProp$B(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3568
+ var __spreadValues$B = (a, b) => {
3569
+ for (var prop in b || (b = {}))
3570
+ if (__hasOwnProp$B.call(b, prop))
3571
+ __defNormalProp$B(a, prop, b[prop]);
3572
+ if (__getOwnPropSymbols$B)
3573
+ for (var prop of __getOwnPropSymbols$B(b)) {
3574
+ if (__propIsEnum$B.call(b, prop))
3575
+ __defNormalProp$B(a, prop, b[prop]);
3576
+ }
3577
+ return a;
3578
+ };
3579
+ var __objRest$3 = (source, exclude) => {
3580
+ var target = {};
3581
+ for (var prop in source)
3582
+ if (__hasOwnProp$B.call(source, prop) && exclude.indexOf(prop) < 0)
3583
+ target[prop] = source[prop];
3584
+ if (source != null && __getOwnPropSymbols$B)
3585
+ for (var prop of __getOwnPropSymbols$B(source)) {
3586
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$B.call(source, prop))
3587
+ target[prop] = source[prop];
3588
+ }
3589
+ return target;
3590
+ };
3591
+ const DropdownItem = React.forwardRef(
3592
+ function DropdownItem2(_a, ref) {
3593
+ var _b = _a, { children, active, addGroupBottomBorder } = _b, rest = __objRest$3(_b, ["children", "active", "addGroupBottomBorder"]);
3594
+ const styles = ui.useStyles2(getStyles$c);
3595
+ const id = React.useId();
3596
+ return /* @__PURE__ */ React__default["default"].createElement("div", __spreadValues$B({
3597
+ ref,
3598
+ role: "option",
3599
+ id,
3600
+ "aria-selected": active,
3601
+ className: css.cx(styles.option, active && styles.optionFocused, addGroupBottomBorder && styles.groupBottomBorder)
3602
+ }, rest), /* @__PURE__ */ React__default["default"].createElement("div", {
3603
+ className: styles.optionBody,
3604
+ "data-testid": `data-testid ad hoc filter option value ${children}`
3605
+ }, /* @__PURE__ */ React__default["default"].createElement("span", null, children)));
3606
+ }
3607
+ );
3608
+ const getStyles$c = (theme) => ({
3609
+ option: css.css({
3610
+ label: "grafana-select-option",
3611
+ top: 0,
3612
+ left: 0,
3613
+ width: "100%",
3614
+ position: "absolute",
3615
+ padding: theme.spacing(1),
3616
+ display: "flex",
3617
+ alignItems: "center",
3618
+ flexDirection: "row",
3619
+ flexShrink: 0,
3620
+ whiteSpace: "nowrap",
3621
+ cursor: "pointer",
3622
+ "&:hover": {
3623
+ background: theme.colors.action.hover,
3624
+ "@media (forced-colors: active), (prefers-contrast: more)": {
3625
+ border: `1px solid ${theme.colors.primary.border}`
3626
+ }
3627
+ }
3628
+ }),
3629
+ optionFocused: css.css({
3630
+ label: "grafana-select-option-focused",
3631
+ background: theme.colors.action.focus,
3632
+ "@media (forced-colors: active), (prefers-contrast: more)": {
3633
+ border: `1px solid ${theme.colors.primary.border}`
3634
+ }
3635
+ }),
3636
+ optionBody: css.css({
3637
+ label: "grafana-select-option-body",
3638
+ display: "flex",
3639
+ fontWeight: theme.typography.fontWeightMedium,
3640
+ flexDirection: "column",
3641
+ flexGrow: 1
3642
+ }),
3643
+ groupBottomBorder: css.css({
3644
+ borderBottom: `1px solid ${theme.colors.border.weak}`
3645
+ })
3646
+ });
3647
+ const LoadingOptionsPlaceholder = () => {
3648
+ return /* @__PURE__ */ React__default["default"].createElement(DropdownItem, {
3649
+ onClick: (e) => e.stopPropagation()
3650
+ }, "Loading options...");
3651
+ };
3652
+ const NoOptionsPlaceholder = () => {
3653
+ return /* @__PURE__ */ React__default["default"].createElement(DropdownItem, {
3654
+ onClick: (e) => e.stopPropagation()
3655
+ }, "No options found");
3656
+ };
3657
+ const OptionsErrorPlaceholder = ({ handleFetchOptions }) => {
3658
+ return /* @__PURE__ */ React__default["default"].createElement(DropdownItem, {
3659
+ onClick: handleFetchOptions
3660
+ }, "An error has occurred fetching labels. Click to retry");
3661
+ };
3662
+
3663
+ const VIRTUAL_LIST_WIDTH_ESTIMATE_MULTIPLIER = 8;
3664
+ const VIRTUAL_LIST_PADDING = 8;
3665
+ const VIRTUAL_LIST_OVERSCAN = 5;
3666
+ const VIRTUAL_LIST_ITEM_HEIGHT = 38;
3667
+ const ERROR_STATE_DROPDOWN_WIDTH = 366;
3668
+ function fuzzySearchOptions(options) {
3669
+ const ufuzzy = new uFuzzy__default["default"]();
3670
+ const haystack = [];
3671
+ const limit = 1e4;
3672
+ return (search, filterInputType) => {
3673
+ var _a;
3674
+ if (search === "") {
3675
+ if (options.length > limit) {
3676
+ return options.slice(0, limit);
3677
+ } else {
3678
+ return options;
3679
+ }
3680
+ }
3681
+ if (filterInputType === "operator") {
3682
+ const filteredOperators = [];
3683
+ for (let i = 0; i < options.length; i++) {
3684
+ if ((_a = options[i].label || options[i].value) == null ? void 0 : _a.includes(search)) {
3685
+ filteredOperators.push(options[i]);
3686
+ if (filteredOperators.length > limit) {
3687
+ return filteredOperators;
3688
+ }
3689
+ }
3690
+ }
3691
+ return filteredOperators;
3692
+ }
3693
+ if (haystack.length === 0) {
3694
+ for (let i = 0; i < options.length; i++) {
3695
+ haystack.push(options[i].label || options[i].value);
3696
+ }
3697
+ }
3698
+ const idxs = ufuzzy.filter(haystack, search);
3699
+ const filteredOptions = [];
3700
+ if (idxs) {
3701
+ for (let i = 0; i < idxs.length; i++) {
3702
+ filteredOptions.push(options[idxs[i]]);
3703
+ if (filteredOptions.length > limit) {
3704
+ return filteredOptions;
3705
+ }
3706
+ }
3707
+ return filteredOptions;
3708
+ }
3709
+ if (options.length > limit) {
3710
+ return options.slice(0, limit);
3711
+ }
3712
+ return options;
3713
+ };
3714
+ }
3715
+ const flattenOptionGroups = (options) => options.flatMap((option) => option.options ? [option, ...option.options] : [option]);
3716
+ const setupDropdownAccessibility = (options, listRef, disabledIndicesRef) => {
3717
+ var _a, _b, _c;
3718
+ let maxOptionWidth = 182;
3719
+ const listRefArr = [];
3720
+ const disabledIndices = [];
3721
+ for (let i = 0; i < options.length; i++) {
3722
+ listRefArr.push(null);
3723
+ if ((_a = options[i]) == null ? void 0 : _a.options) {
3724
+ disabledIndices.push(i);
3725
+ }
3726
+ let label = (_c = (_b = options[i].label) != null ? _b : options[i].value) != null ? _c : "";
3727
+ const widthEstimate = (options[i].isCustom ? label.length + 18 : label.length) * VIRTUAL_LIST_WIDTH_ESTIMATE_MULTIPLIER + VIRTUAL_LIST_PADDING * 2;
3728
+ if (widthEstimate > maxOptionWidth) {
3729
+ maxOptionWidth = widthEstimate;
3730
+ }
3731
+ }
3732
+ listRef.current = [...listRefArr];
3733
+ disabledIndicesRef.current = [...disabledIndices];
3734
+ return maxOptionWidth;
3735
+ };
3736
+ const nextInputTypeMap = {
3737
+ key: "operator",
3738
+ operator: "value",
3739
+ value: "key"
3740
+ };
3741
+ const switchToNextInputType = (filterInputType, setInputType, handleChangeViewMode, element) => switchInputType(
3742
+ nextInputTypeMap[filterInputType],
3743
+ setInputType,
3744
+ filterInputType === "value" ? handleChangeViewMode : void 0,
3745
+ element
3746
+ );
3747
+ const switchInputType = (filterInputType, setInputType, handleChangeViewMode, element) => {
3748
+ setInputType(filterInputType);
3749
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3750
+ setTimeout(() => element == null ? void 0 : element.focus());
3751
+ };
3752
+ const generateFilterUpdatePayload = (filterInputType, item) => {
3753
+ if (filterInputType === "key") {
3754
+ return {
3755
+ key: item.value,
3756
+ keyLabel: item.label ? item.label : item.value
3757
+ };
3758
+ }
3759
+ if (filterInputType === "value") {
3760
+ return {
3761
+ value: item.value,
3762
+ valueLabels: [item.label ? item.label : item.value]
3763
+ };
3764
+ }
3765
+ return {
3766
+ [filterInputType]: item.value
3767
+ };
3768
+ };
3769
+
3770
+ const MAX_MENU_HEIGHT = 300;
3771
+ const useFloatingInteractions = ({
3772
+ open,
3773
+ onOpenChange,
3774
+ activeIndex,
3775
+ setActiveIndex,
3776
+ operatorIdentifier,
3777
+ listRef,
3778
+ disabledIndicesRef
3779
+ }) => {
3780
+ const { refs, floatingStyles, context } = react.useFloating({
3781
+ whileElementsMounted: react.autoUpdate,
3782
+ open,
3783
+ onOpenChange,
3784
+ placement: "bottom-start",
3785
+ middleware: [
3786
+ react.offset(10),
3787
+ react.flip({ padding: 10 }),
3788
+ react.size({
3789
+ apply({ availableHeight, availableWidth, elements }) {
3790
+ elements.floating.style.maxHeight = `${Math.min(MAX_MENU_HEIGHT, availableHeight)}px`;
3791
+ elements.floating.style.maxWidth = `${availableWidth}px`;
3792
+ },
3793
+ padding: 10
3794
+ })
3795
+ ]
3796
+ });
3797
+ const role = react.useRole(context, { role: "listbox" });
3798
+ const dismiss = react.useDismiss(context, {
3799
+ outsidePress: (event) => {
3800
+ if (event.currentTarget instanceof HTMLElement && event.currentTarget.id === operatorIdentifier) {
3801
+ return false;
3802
+ }
3803
+ return true;
3804
+ }
3805
+ });
3806
+ const listNav = react.useListNavigation(context, {
3807
+ listRef,
3808
+ activeIndex,
3809
+ onNavigate: setActiveIndex,
3810
+ virtual: true,
3811
+ loop: true,
3812
+ disabledIndices: disabledIndicesRef.current
3813
+ });
3814
+ const { getReferenceProps, getFloatingProps, getItemProps } = react.useInteractions([role, dismiss, listNav]);
3815
+ return {
3816
+ refs,
3817
+ floatingStyles,
3818
+ context,
3819
+ getReferenceProps,
3820
+ getFloatingProps,
3821
+ getItemProps
3822
+ };
3823
+ };
3824
+
3825
+ var __defProp$A = Object.defineProperty;
3826
+ var __defProps$n = Object.defineProperties;
3827
+ var __getOwnPropDescs$n = Object.getOwnPropertyDescriptors;
3828
+ var __getOwnPropSymbols$A = Object.getOwnPropertySymbols;
3829
+ var __hasOwnProp$A = Object.prototype.hasOwnProperty;
3830
+ var __propIsEnum$A = Object.prototype.propertyIsEnumerable;
3831
+ var __defNormalProp$A = (obj, key, value) => key in obj ? __defProp$A(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3832
+ var __spreadValues$A = (a, b) => {
3833
+ for (var prop in b || (b = {}))
3834
+ if (__hasOwnProp$A.call(b, prop))
3835
+ __defNormalProp$A(a, prop, b[prop]);
3836
+ if (__getOwnPropSymbols$A)
3837
+ for (var prop of __getOwnPropSymbols$A(b)) {
3838
+ if (__propIsEnum$A.call(b, prop))
3839
+ __defNormalProp$A(a, prop, b[prop]);
3840
+ }
3841
+ return a;
3842
+ };
3843
+ var __spreadProps$n = (a, b) => __defProps$n(a, __getOwnPropDescs$n(b));
3844
+ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model, isAlwaysWip, handleChangeViewMode }, parentRef) {
3845
+ var _a, _b, _c;
3846
+ const [open, setOpen] = React.useState(false);
3847
+ const [options, setOptions] = React.useState([]);
3848
+ const [optionsLoading, setOptionsLoading] = React.useState(false);
3849
+ const [optionsError, setOptionsError] = React.useState(false);
3850
+ const [inputValue, setInputValue] = React.useState("");
3851
+ const [activeIndex, setActiveIndex] = React.useState(null);
3852
+ const [filterInputType, setInputType] = React.useState(!isAlwaysWip ? "value" : "key");
3853
+ const styles = ui.useStyles2(getStyles$b);
3854
+ const operatorIdentifier = React.useId();
3855
+ const listRef = React.useRef([]);
3856
+ const disabledIndicesRef = React.useRef([]);
3857
+ const optionsSearcher = React.useMemo(() => fuzzySearchOptions(options), [options]);
3858
+ const handleResetWip = React.useCallback(() => {
3859
+ if (isAlwaysWip) {
3860
+ model._addWip();
3861
+ setInputType("key");
3862
+ setInputValue("");
3863
+ }
3864
+ }, [model, isAlwaysWip]);
3865
+ const onOpenChange = React.useCallback(
3866
+ (nextOpen, _, reason) => {
3867
+ setOpen(nextOpen);
3868
+ if (reason && ["outside-press", "escape-key"].includes(reason)) {
3869
+ handleResetWip();
3870
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3871
+ }
3872
+ },
3873
+ [handleChangeViewMode, handleResetWip]
3874
+ );
3875
+ const { refs, floatingStyles, context, getReferenceProps, getFloatingProps, getItemProps } = useFloatingInteractions({
3876
+ open,
3877
+ onOpenChange,
3878
+ activeIndex,
3879
+ setActiveIndex,
3880
+ operatorIdentifier,
3881
+ listRef,
3882
+ disabledIndicesRef
3883
+ });
3884
+ React.useImperativeHandle(parentRef, () => () => {
3885
+ var _a2;
3886
+ return (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
3887
+ }, [refs.domReference]);
3888
+ function onChange(event) {
3889
+ const value = event.target.value;
3890
+ setInputValue(value);
3891
+ setActiveIndex(0);
3892
+ }
3893
+ const filteredDropDownItems = flattenOptionGroups(handleOptionGroups(optionsSearcher(inputValue, filterInputType)));
3894
+ if (filterInputType !== "operator" && inputValue) {
3895
+ filteredDropDownItems.push({
3896
+ value: inputValue.trim(),
3897
+ label: inputValue.trim(),
3898
+ isCustom: true
3899
+ });
3900
+ }
3901
+ const maxOptionWidth = setupDropdownAccessibility(filteredDropDownItems, listRef, disabledIndicesRef);
3902
+ const handleFetchOptions = React.useCallback(
3903
+ async (inputType) => {
3904
+ var _a2;
3905
+ setOptionsError(false);
3906
+ setOptionsLoading(true);
3907
+ setOptions([]);
3908
+ let options2 = [];
3909
+ try {
3910
+ if (inputType === "key") {
3911
+ options2 = await model._getKeys(null);
3912
+ } else if (inputType === "operator") {
3913
+ options2 = model._getOperators();
3914
+ } else if (inputType === "value") {
3915
+ options2 = await model._getValuesFor(filter);
3916
+ }
3917
+ setOptions(options2);
3918
+ if ((_a2 = options2[0]) == null ? void 0 : _a2.group) {
3919
+ setActiveIndex(1);
3920
+ }
3921
+ } catch (e) {
3922
+ setOptionsError(true);
3923
+ }
3924
+ setOptionsLoading(false);
3925
+ },
3926
+ [filter, model]
3927
+ );
3928
+ const rowVirtualizer = reactVirtual.useVirtualizer({
3929
+ count: filteredDropDownItems.length,
3930
+ getScrollElement: () => refs.floating.current,
3931
+ estimateSize: () => VIRTUAL_LIST_ITEM_HEIGHT,
3932
+ overscan: VIRTUAL_LIST_OVERSCAN
3933
+ });
3934
+ const handleBackspaceInput = React.useCallback(
3935
+ (event) => {
3936
+ if (event.key === "Backspace" && !inputValue && filterInputType === "key") {
3937
+ model._removeLastFilter();
3938
+ handleFetchOptions(filterInputType);
3939
+ }
3940
+ },
3941
+ [inputValue, filterInputType]
3942
+ );
3943
+ const handleTabInput = React.useCallback((event) => {
3944
+ if (event.key === "Tab" && !event.shiftKey) {
3945
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3946
+ handleResetWip();
3947
+ }
3948
+ }, []);
3949
+ const handleShiftTabInput = React.useCallback((event) => {
3950
+ if (event.key === "Tab" && event.shiftKey) {
3951
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3952
+ handleResetWip();
3953
+ }
3954
+ }, []);
3955
+ const handleEnterInput = React.useCallback(
3956
+ (event) => {
3957
+ if (event.key === "Enter" && activeIndex != null) {
3958
+ if (!filteredDropDownItems[activeIndex]) {
3959
+ return;
3960
+ }
3961
+ model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, filteredDropDownItems[activeIndex]));
3962
+ setInputValue("");
3963
+ setActiveIndex(0);
3964
+ switchToNextInputType(filterInputType, setInputType, handleChangeViewMode, refs.domReference.current);
3965
+ }
3966
+ },
3967
+ [activeIndex, filter, filterInputType, filteredDropDownItems, model]
3968
+ );
3969
+ React.useEffect(() => {
3970
+ if (open) {
3971
+ handleFetchOptions(filterInputType);
3972
+ }
3973
+ }, [open, filterInputType]);
3974
+ React.useEffect(() => {
3975
+ var _a2;
3976
+ if (!isAlwaysWip) {
3977
+ setInputType("value");
3978
+ setInputValue("");
3979
+ (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
3980
+ }
3981
+ }, []);
3982
+ React.useLayoutEffect(() => {
3983
+ var _a2, _b2;
3984
+ if (activeIndex !== null && rowVirtualizer.range && (activeIndex > ((_a2 = rowVirtualizer.range) == null ? void 0 : _a2.endIndex) || activeIndex < ((_b2 = rowVirtualizer.range) == null ? void 0 : _b2.startIndex))) {
3985
+ rowVirtualizer.scrollToIndex(activeIndex);
3986
+ }
3987
+ }, [activeIndex, rowVirtualizer]);
3988
+ const keyLabel = (_a = filter == null ? void 0 : filter.keyLabel) != null ? _a : filter == null ? void 0 : filter.key;
3989
+ const valueLabel = (_c = (_b = filter == null ? void 0 : filter.valueLabels) == null ? void 0 : _b[0]) != null ? _c : filter == null ? void 0 : filter.value;
3990
+ return /* @__PURE__ */ React__default["default"].createElement("div", {
3991
+ className: styles.comboboxWrapper
3992
+ }, filter ? /* @__PURE__ */ React__default["default"].createElement("div", {
3993
+ className: styles.pillWrapper
3994
+ }, (filter == null ? void 0 : filter.key) ? /* @__PURE__ */ React__default["default"].createElement("div", {
3995
+ className: css.cx(styles.basePill, styles.keyPill)
3996
+ }, keyLabel) : null, (filter == null ? void 0 : filter.key) && (filter == null ? void 0 : filter.operator) && filterInputType !== "operator" ? /* @__PURE__ */ React__default["default"].createElement("div", {
3997
+ id: operatorIdentifier,
3998
+ className: css.cx(styles.basePill, styles.operatorPill, operatorIdentifier),
3999
+ role: "button",
4000
+ "aria-label": "Edit filter operator",
4001
+ tabIndex: 0,
4002
+ onClick: (event) => {
4003
+ event.stopPropagation();
4004
+ switchInputType("operator", setInputType, void 0, refs.domReference.current);
4005
+ },
4006
+ onKeyDown: (event) => {
4007
+ handleShiftTabInput(event);
4008
+ if (event.key === "Enter") {
4009
+ switchInputType("operator", setInputType, void 0, refs.domReference.current);
4010
+ }
4011
+ }
4012
+ }, filter.operator) : null, (filter == null ? void 0 : filter.key) && (filter == null ? void 0 : filter.operator) && (filter == null ? void 0 : filter.value) && !["operator", "value"].includes(filterInputType) ? /* @__PURE__ */ React__default["default"].createElement("div", {
4013
+ className: css.cx(styles.basePill, styles.valuePill)
4014
+ }, valueLabel) : null) : null, /* @__PURE__ */ React__default["default"].createElement("input", __spreadProps$n(__spreadValues$A({}, getReferenceProps({
4015
+ ref: refs.setReference,
4016
+ onChange,
4017
+ value: inputValue,
4018
+ placeholder: !isAlwaysWip ? filterInputType === "operator" ? `${filter[filterInputType]} ${valueLabel}` : filter[filterInputType] : "Filter by label values",
4019
+ "aria-autocomplete": "list",
4020
+ onKeyDown(event) {
4021
+ if (!open) {
4022
+ setOpen(true);
4023
+ return;
4024
+ }
4025
+ if (filterInputType === "operator") {
4026
+ handleShiftTabInput(event);
4027
+ }
4028
+ handleBackspaceInput(event);
4029
+ handleTabInput(event);
4030
+ handleEnterInput(event);
4031
+ }
4032
+ })), {
4033
+ className: css.cx(styles.inputStyle, { [styles.loadingInputPadding]: !optionsLoading }),
4034
+ onClick: (event) => {
4035
+ event.stopPropagation();
4036
+ setOpen(true);
4037
+ },
4038
+ onFocus: () => {
4039
+ setActiveIndex(0);
4040
+ setOpen(true);
4041
+ }
4042
+ })), optionsLoading ? /* @__PURE__ */ React__default["default"].createElement(ui.Spinner, {
4043
+ className: styles.loadingIndicator,
4044
+ inline: true
4045
+ }) : null, /* @__PURE__ */ React__default["default"].createElement(react.FloatingPortal, null, open && /* @__PURE__ */ React__default["default"].createElement(react.FloatingFocusManager, {
4046
+ context,
4047
+ initialFocus: -1,
4048
+ visuallyHiddenDismiss: true,
4049
+ modal: false
4050
+ }, /* @__PURE__ */ React__default["default"].createElement("div", {
4051
+ style: __spreadProps$n(__spreadValues$A({}, floatingStyles), {
4052
+ width: `${optionsError ? ERROR_STATE_DROPDOWN_WIDTH : maxOptionWidth}px`
4053
+ }),
4054
+ ref: refs.setFloating,
4055
+ className: styles.dropdownWrapper,
4056
+ tabIndex: -1
4057
+ }, /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$n(__spreadValues$A({
4058
+ style: {
4059
+ height: `${rowVirtualizer.getTotalSize() || VIRTUAL_LIST_ITEM_HEIGHT}px`
4060
+ }
4061
+ }, getFloatingProps()), {
4062
+ tabIndex: -1
4063
+ }), optionsLoading ? /* @__PURE__ */ React__default["default"].createElement(LoadingOptionsPlaceholder, null) : optionsError ? /* @__PURE__ */ React__default["default"].createElement(OptionsErrorPlaceholder, {
4064
+ handleFetchOptions: () => handleFetchOptions(filterInputType)
4065
+ }) : !filteredDropDownItems.length && (filterInputType === "operator" || !inputValue) ? /* @__PURE__ */ React__default["default"].createElement(NoOptionsPlaceholder, null) : rowVirtualizer.getVirtualItems().map((virtualItem) => {
4066
+ var _a2;
4067
+ const item = filteredDropDownItems[virtualItem.index];
4068
+ const index = virtualItem.index;
4069
+ if (item.options) {
4070
+ return /* @__PURE__ */ React__default["default"].createElement("div", {
4071
+ key: `${item.label}+${index}`,
4072
+ className: css.cx(styles.optionGroupLabel, styles.groupTopBorder),
4073
+ style: {
4074
+ height: `${virtualItem.size}px`,
4075
+ transform: `translateY(${virtualItem.start}px)`
4076
+ }
4077
+ }, /* @__PURE__ */ React__default["default"].createElement(ui.Text, {
4078
+ weight: "bold",
4079
+ variant: "bodySmall",
4080
+ color: "secondary"
4081
+ }, item.label));
4082
+ }
4083
+ const nextItem = filteredDropDownItems[virtualItem.index + 1];
4084
+ const shouldAddBottomBorder = nextItem && !nextItem.group && !nextItem.options && item.group;
4085
+ return /* @__PURE__ */ React__default["default"].createElement(DropdownItem, __spreadProps$n(__spreadValues$A({}, getItemProps({
4086
+ key: `${item.value}-${index}`,
4087
+ ref(node) {
4088
+ listRef.current[index] = node;
4089
+ },
4090
+ onClick(event) {
4091
+ if (filterInputType !== "value") {
4092
+ event.stopPropagation();
4093
+ }
4094
+ model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, item));
4095
+ setInputValue("");
4096
+ switchToNextInputType(
4097
+ filterInputType,
4098
+ setInputType,
4099
+ handleChangeViewMode,
4100
+ refs.domReference.current
4101
+ );
4102
+ }
4103
+ })), {
4104
+ active: activeIndex === index,
4105
+ addGroupBottomBorder: shouldAddBottomBorder,
4106
+ style: {
4107
+ height: `${virtualItem.size}px`,
4108
+ transform: `translateY(${virtualItem.start}px)`
4109
+ },
4110
+ "aria-setsize": filteredDropDownItems.length,
4111
+ "aria-posinset": virtualItem.index + 1
4112
+ }), item.isCustom ? "Use custom value: " : "", " ", (_a2 = item.label) != null ? _a2 : item.value);
4113
+ }))))));
4114
+ });
4115
+ const getStyles$b = (theme) => ({
4116
+ comboboxWrapper: css.css({
4117
+ display: "flex",
4118
+ flexWrap: "nowrap"
4119
+ }),
4120
+ pillWrapper: css.css({
4121
+ display: "flex",
4122
+ alignItems: "center",
4123
+ whiteSpace: "nowrap"
4124
+ }),
4125
+ basePill: css.css(__spreadProps$n(__spreadValues$A({
4126
+ display: "flex",
4127
+ alignItems: "center",
4128
+ background: theme.colors.action.disabledBackground,
4129
+ border: `1px solid ${theme.colors.border.weak}`,
4130
+ padding: theme.spacing(0.125, 1, 0.125, 1),
4131
+ color: theme.colors.text.primary,
4132
+ overflow: "hidden",
4133
+ whiteSpace: "nowrap",
4134
+ minHeight: theme.spacing(2.75)
4135
+ }, theme.typography.bodySmall), {
4136
+ cursor: "pointer"
4137
+ })),
4138
+ keyPill: css.css({
4139
+ fontWeight: theme.typography.fontWeightBold,
4140
+ cursor: "default"
4141
+ }),
4142
+ operatorPill: css.css({
4143
+ "&:hover": {
4144
+ background: theme.colors.action.hover
4145
+ }
4146
+ }),
4147
+ valuePill: css.css({
4148
+ background: theme.colors.action.selected
4149
+ }),
4150
+ dropdownWrapper: css.css({
4151
+ backgroundColor: theme.colors.background.primary,
4152
+ color: theme.colors.text.primary,
4153
+ boxShadow: theme.shadows.z2,
4154
+ overflowY: "auto",
4155
+ zIndex: theme.zIndex.dropdown
4156
+ }),
4157
+ inputStyle: css.css({
4158
+ paddingBlock: 0,
4159
+ "&:focus": {
4160
+ outline: "none"
4161
+ }
4162
+ }),
4163
+ loadingIndicator: css.css({
4164
+ color: theme.colors.text.secondary,
4165
+ marginLeft: theme.spacing(0.5)
4166
+ }),
4167
+ loadingInputPadding: css.css({
4168
+ paddingRight: theme.spacing(2.5)
4169
+ }),
4170
+ optionGroupLabel: css.css({
4171
+ padding: theme.spacing(1),
4172
+ position: "absolute",
4173
+ top: 0,
4174
+ left: 0,
4175
+ width: "100%"
4176
+ }),
4177
+ groupTopBorder: css.css({
4178
+ "&:not(:first-child)": {
4179
+ borderTop: `1px solid ${theme.colors.border.weak}`
4180
+ }
4181
+ })
4182
+ });
4183
+
4184
+ var __defProp$z = Object.defineProperty;
4185
+ var __defProps$m = Object.defineProperties;
4186
+ var __getOwnPropDescs$m = Object.getOwnPropertyDescriptors;
4187
+ var __getOwnPropSymbols$z = Object.getOwnPropertySymbols;
4188
+ var __hasOwnProp$z = Object.prototype.hasOwnProperty;
4189
+ var __propIsEnum$z = Object.prototype.propertyIsEnumerable;
4190
+ var __defNormalProp$z = (obj, key, value) => key in obj ? __defProp$z(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4191
+ var __spreadValues$z = (a, b) => {
4192
+ for (var prop in b || (b = {}))
4193
+ if (__hasOwnProp$z.call(b, prop))
4194
+ __defNormalProp$z(a, prop, b[prop]);
4195
+ if (__getOwnPropSymbols$z)
4196
+ for (var prop of __getOwnPropSymbols$z(b)) {
4197
+ if (__propIsEnum$z.call(b, prop))
4198
+ __defNormalProp$z(a, prop, b[prop]);
4199
+ }
4200
+ return a;
4201
+ };
4202
+ var __spreadProps$m = (a, b) => __defProps$m(a, __getOwnPropDescs$m(b));
4203
+ function AdHocFilterPill({ filter, model, readOnly }) {
4204
+ var _a, _b, _c;
4205
+ const styles = ui.useStyles2(getStyles$a);
4206
+ const [viewMode, setViewMode] = React.useState(true);
4207
+ const [shouldFocus, setShouldFocus] = React.useState(false);
4208
+ const pillWrapperRef = React.useRef(null);
4209
+ const keyLabel = (_a = filter.keyLabel) != null ? _a : filter.key;
4210
+ const valueLabel = (_c = (_b = filter.valueLabels) == null ? void 0 : _b[0]) != null ? _c : filter.value;
4211
+ const handleChangeViewMode = React.useCallback(
4212
+ (event) => {
4213
+ event == null ? void 0 : event.stopPropagation();
4214
+ if (readOnly) {
4215
+ return;
4216
+ }
4217
+ setShouldFocus(!viewMode);
4218
+ setViewMode(!viewMode);
4219
+ },
4220
+ [readOnly, viewMode]
4221
+ );
4222
+ React.useEffect(() => {
4223
+ var _a2;
4224
+ if (shouldFocus) {
4225
+ (_a2 = pillWrapperRef.current) == null ? void 0 : _a2.focus();
4226
+ setShouldFocus(false);
4227
+ }
4228
+ }, [shouldFocus]);
4229
+ if (viewMode) {
4230
+ return /* @__PURE__ */ React__default["default"].createElement("div", {
4231
+ className: css.cx(styles.combinedFilterPill, { [styles.readOnlyCombinedFilter]: readOnly }),
4232
+ onClick: handleChangeViewMode,
4233
+ onKeyDown: (e) => {
4234
+ if (e.key === "Enter") {
4235
+ handleChangeViewMode();
4236
+ }
4237
+ },
4238
+ role: "button",
4239
+ "aria-label": `Edit filter with key ${keyLabel}`,
4240
+ tabIndex: 0,
4241
+ ref: pillWrapperRef
4242
+ }, /* @__PURE__ */ React__default["default"].createElement("span", null, keyLabel, " ", filter.operator, " ", valueLabel), !readOnly ? /* @__PURE__ */ React__default["default"].createElement(ui.IconButton, {
4243
+ onClick: (e) => {
4244
+ e.stopPropagation();
4245
+ model._removeFilter(filter);
4246
+ },
4247
+ onKeyDownCapture: (e) => {
4248
+ if (e.key === "Enter") {
4249
+ e.preventDefault();
4250
+ e.stopPropagation();
4251
+ model._removeFilter(filter);
4252
+ }
4253
+ },
4254
+ name: "times",
4255
+ size: "md",
4256
+ className: styles.removeButton,
4257
+ tooltip: `Remove filter with key ${keyLabel}`
4258
+ }) : null);
4259
+ }
4260
+ return /* @__PURE__ */ React__default["default"].createElement(AdHocCombobox, {
4261
+ filter,
4262
+ model,
4263
+ handleChangeViewMode
4264
+ });
4265
+ }
4266
+ const getStyles$a = (theme) => ({
4267
+ combinedFilterPill: css.css(__spreadProps$m(__spreadValues$z({
4268
+ display: "flex",
4269
+ alignItems: "center",
4270
+ background: theme.colors.action.selected,
4271
+ borderRadius: theme.shape.radius.default,
4272
+ border: `1px solid ${theme.colors.border.weak}`,
4273
+ padding: theme.spacing(0.125, 0, 0.125, 1),
4274
+ color: theme.colors.text.primary,
4275
+ overflow: "hidden",
4276
+ whiteSpace: "nowrap",
4277
+ minHeight: theme.spacing(2.75)
4278
+ }, theme.typography.bodySmall), {
4279
+ fontWeight: theme.typography.fontWeightBold,
4280
+ cursor: "pointer",
4281
+ "&:hover": {
4282
+ background: theme.colors.action.hover
4283
+ }
4284
+ })),
4285
+ readOnlyCombinedFilter: css.css({
4286
+ paddingRight: theme.spacing(1),
4287
+ cursor: "text",
4288
+ "&:hover": {
4289
+ background: theme.colors.action.selected
4290
+ }
4291
+ }),
4292
+ removeButton: css.css({
4293
+ marginInline: theme.spacing(0.5),
4294
+ cursor: "pointer",
4295
+ "&:hover": {
4296
+ color: theme.colors.text.primary
4297
+ }
4298
+ })
4299
+ });
4300
+
4301
+ const AdHocFiltersAlwaysWipCombobox = React.forwardRef(function AdHocFiltersAlwaysWipCombobox2({ model }, parentRef) {
4302
+ const { _wip } = model.useState();
4303
+ React.useLayoutEffect(() => {
4304
+ if (!_wip) {
4305
+ model._addWip();
4306
+ }
4307
+ }, [_wip]);
4308
+ return /* @__PURE__ */ React__default["default"].createElement(AdHocCombobox, {
4309
+ model,
4310
+ filter: _wip,
4311
+ isAlwaysWip: true,
4312
+ ref: parentRef
4313
+ });
4314
+ });
4315
+
4316
+ const AdHocFiltersComboboxRenderer = React.memo(function AdHocFiltersComboboxRenderer2({ model }) {
4317
+ const { filters, readOnly } = model.useState();
4318
+ const styles = ui.useStyles2(getStyles$9);
4319
+ const focusOnInputRef = React.useRef();
4320
+ return /* @__PURE__ */ React__default["default"].createElement("div", {
4321
+ className: css.cx(styles.comboboxWrapper, { [styles.comboboxFocusOutline]: !readOnly }),
4322
+ onClick: () => {
4323
+ var _a;
4324
+ (_a = focusOnInputRef.current) == null ? void 0 : _a.call(focusOnInputRef);
4325
+ }
4326
+ }, /* @__PURE__ */ React__default["default"].createElement(ui.Icon, {
4327
+ name: "filter",
4328
+ className: styles.filterIcon,
4329
+ size: "lg"
4330
+ }), filters.map((filter, index) => /* @__PURE__ */ React__default["default"].createElement(AdHocFilterPill, {
4331
+ key: index,
4332
+ filter,
4333
+ model,
4334
+ readOnly
4335
+ })), !readOnly ? /* @__PURE__ */ React__default["default"].createElement(AdHocFiltersAlwaysWipCombobox, {
4336
+ model,
4337
+ ref: focusOnInputRef
4338
+ }) : null);
4339
+ });
4340
+ const getStyles$9 = (theme) => ({
4341
+ comboboxWrapper: css.css({
4342
+ display: "flex",
4343
+ flexWrap: "wrap",
4344
+ alignItems: "center",
4345
+ columnGap: theme.spacing(1),
4346
+ rowGap: theme.spacing(0.5),
4347
+ minHeight: theme.spacing(4),
4348
+ backgroundColor: theme.components.input.background,
4349
+ border: `1px solid ${theme.colors.border.strong}`,
4350
+ borderRadius: theme.shape.radius.default,
4351
+ paddingInline: theme.spacing(1),
4352
+ paddingBlock: theme.spacing(0.5),
4353
+ flexGrow: 1
4354
+ }),
4355
+ comboboxFocusOutline: css.css({
4356
+ "&:focus-within": {
4357
+ outline: "2px dotted transparent",
4358
+ outlineOffset: "2px",
4359
+ boxShadow: `0 0 0 2px ${theme.colors.background.canvas}, 0 0 0px 4px ${theme.colors.primary.main}`,
4360
+ transitionTimingFunction: `cubic-bezier(0.19, 1, 0.22, 1)`,
4361
+ transitionDuration: "0.2s",
4362
+ transitionProperty: "outline, outline-offset, box-shadow",
4363
+ zIndex: 2
4364
+ }
4365
+ }),
4366
+ filterIcon: css.css({
4367
+ color: theme.colors.text.secondary,
4368
+ alignSelf: "center"
4369
+ })
4370
+ });
4371
+
3561
4372
  var __defProp$y = Object.defineProperty;
3562
4373
  var __getOwnPropSymbols$y = Object.getOwnPropertySymbols;
3563
4374
  var __hasOwnProp$y = Object.prototype.hasOwnProperty;
@@ -3574,29 +4385,38 @@ var __spreadValues$y = (a, b) => {
3574
4385
  }
3575
4386
  return a;
3576
4387
  };
3577
- const OPERATORS = [{
3578
- value: "="
3579
- }, {
3580
- value: "!="
3581
- }, {
3582
- value: "=|",
3583
- description: "Is one of. Use to filter on multiple values.",
3584
- isMulti: true
3585
- }, {
3586
- value: "!=|",
3587
- description: "Is not one of. Use to exclude multiple values.",
3588
- isMulti: true
3589
- }, {
3590
- value: "=~",
3591
- description: "Matches regex"
3592
- }, {
3593
- value: "!~",
3594
- description: "Does not match regex"
3595
- }, {
3596
- value: "<"
3597
- }, {
3598
- value: ">"
3599
- }];
4388
+ const OPERATORS = [
4389
+ {
4390
+ value: "="
4391
+ },
4392
+ {
4393
+ value: "!="
4394
+ },
4395
+ {
4396
+ value: "=|",
4397
+ description: "Is one of. Use to filter on multiple values.",
4398
+ isMulti: true
4399
+ },
4400
+ {
4401
+ value: "!=|",
4402
+ description: "Is not one of. Use to exclude multiple values.",
4403
+ isMulti: true
4404
+ },
4405
+ {
4406
+ value: "=~",
4407
+ description: "Matches regex"
4408
+ },
4409
+ {
4410
+ value: "!~",
4411
+ description: "Does not match regex"
4412
+ },
4413
+ {
4414
+ value: "<"
4415
+ },
4416
+ {
4417
+ value: ">"
4418
+ }
4419
+ ];
3600
4420
  class AdHocFiltersVariable extends SceneObjectBase {
3601
4421
  constructor(state) {
3602
4422
  var _a, _b;
@@ -3651,6 +4471,12 @@ class AdHocFiltersVariable extends SceneObjectBase {
3651
4471
  }
3652
4472
  this.setState({ filters: this.state.filters.filter((f) => f !== filter) });
3653
4473
  }
4474
+ _removeLastFilter() {
4475
+ const filterToRemove = this.state.filters.at(-1);
4476
+ if (filterToRemove) {
4477
+ this._removeFilter(filterToRemove);
4478
+ }
4479
+ }
3654
4480
  async _getKeys(currentKey) {
3655
4481
  var _a, _b, _c;
3656
4482
  const override = await ((_b = (_a = this.state).getTagKeysProvider) == null ? void 0 : _b.call(_a, this, currentKey));
@@ -3734,6 +4560,11 @@ function renderExpression(builder, filters) {
3734
4560
  function AdHocFiltersVariableRenderer({ model }) {
3735
4561
  const { filters, readOnly, addFilterButtonText } = model.useState();
3736
4562
  const styles = ui.useStyles2(getStyles$8);
4563
+ if (!model.state.supportsMultiValueOperators && model.state.layout === "combobox") {
4564
+ return /* @__PURE__ */ React__default["default"].createElement(AdHocFiltersComboboxRenderer, {
4565
+ model
4566
+ });
4567
+ }
3737
4568
  return /* @__PURE__ */ React__default["default"].createElement("div", {
3738
4569
  className: styles.wrapper
3739
4570
  }, filters.map((filter, index) => /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, {
@@ -3754,10 +4585,6 @@ const getStyles$8 = (theme) => ({
3754
4585
  alignItems: "flex-end",
3755
4586
  columnGap: theme.spacing(2),
3756
4587
  rowGap: theme.spacing(1)
3757
- }),
3758
- filterIcon: css.css({
3759
- color: theme.colors.text.secondary,
3760
- paddingRight: theme.spacing(0.5)
3761
4588
  })
3762
4589
  });
3763
4590
  function toSelectableValue(input) {