@grafana/scenes 5.23.1--canary.955.11689118589.0 → 5.23.1--canary.858.11699916776.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. package/CHANGELOG.md +6 -6
  2. package/dist/esm/behaviors/SceneQueryController.js +60 -5
  3. package/dist/esm/behaviors/SceneQueryController.js.map +1 -1
  4. package/dist/esm/behaviors/SceneRenderProfiler.js +169 -0
  5. package/dist/esm/behaviors/SceneRenderProfiler.js.map +1 -0
  6. package/dist/esm/components/SceneRefreshPicker.js +4 -1
  7. package/dist/esm/components/SceneRefreshPicker.js.map +1 -1
  8. package/dist/esm/components/VizPanel/VizPanel.js +9 -6
  9. package/dist/esm/components/VizPanel/VizPanel.js.map +1 -1
  10. package/dist/esm/core/SceneTimeRange.js +3 -0
  11. package/dist/esm/core/SceneTimeRange.js.map +1 -1
  12. package/dist/esm/core/sceneGraph/getQueryController.js +19 -0
  13. package/dist/esm/core/sceneGraph/getQueryController.js.map +1 -0
  14. package/dist/esm/core/sceneGraph/index.js +3 -3
  15. package/dist/esm/core/sceneGraph/index.js.map +1 -1
  16. package/dist/esm/core/sceneGraph/sceneGraph.js +1 -26
  17. package/dist/esm/core/sceneGraph/sceneGraph.js.map +1 -1
  18. package/dist/esm/index.js.map +1 -1
  19. package/dist/esm/querying/SceneQueryRunner.js +1 -3
  20. package/dist/esm/querying/SceneQueryRunner.js.map +1 -1
  21. package/dist/esm/querying/registerQueryWithController.js +19 -2
  22. package/dist/esm/querying/registerQueryWithController.js.map +1 -1
  23. package/dist/esm/utils/getDataSource.js +17 -1
  24. package/dist/esm/utils/getDataSource.js.map +1 -1
  25. package/dist/esm/variables/adhoc/AdHocFilterRenderer.js +12 -8
  26. package/dist/esm/variables/adhoc/AdHocFilterRenderer.js.map +1 -1
  27. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.js +2 -14
  28. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.js.map +1 -1
  29. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js +58 -46
  30. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js.map +1 -1
  31. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/utils.js +1 -14
  32. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/utils.js.map +1 -1
  33. package/dist/esm/variables/adhoc/AdHocFiltersVariableUrlSyncHandler.js +1 -4
  34. package/dist/esm/variables/adhoc/AdHocFiltersVariableUrlSyncHandler.js.map +1 -1
  35. package/dist/esm/variables/components/VariableValueSelect.js +5 -0
  36. package/dist/esm/variables/components/VariableValueSelect.js.map +1 -1
  37. package/dist/esm/variables/utils.js.map +1 -1
  38. package/dist/esm/variables/variants/MultiValueVariable.js.map +1 -1
  39. package/dist/esm/variables/variants/TestVariable.js.map +1 -1
  40. package/dist/index.d.ts +44 -32
  41. package/dist/index.js +600 -471
  42. package/dist/index.js.map +1 -1
  43. package/package.json +2 -2
  44. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/MultiValuePill.js +0 -114
  45. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/MultiValuePill.js.map +0 -1
package/dist/index.js CHANGED
@@ -188,32 +188,32 @@ class UserActionEvent extends data.BusEventWithPayload {
188
188
  }
189
189
  UserActionEvent.type = "scene-object-user-action";
190
190
 
191
- var __accessCheck$3 = (obj, member, msg) => {
191
+ var __accessCheck$4 = (obj, member, msg) => {
192
192
  if (!member.has(obj))
193
193
  throw TypeError("Cannot " + msg);
194
194
  };
195
- var __privateGet$3 = (obj, member, getter) => {
196
- __accessCheck$3(obj, member, "read from private field");
195
+ var __privateGet$4 = (obj, member, getter) => {
196
+ __accessCheck$4(obj, member, "read from private field");
197
197
  return getter ? getter.call(obj) : member.get(obj);
198
198
  };
199
- var __privateAdd$3 = (obj, member, value) => {
199
+ var __privateAdd$4 = (obj, member, value) => {
200
200
  if (member.has(obj))
201
201
  throw TypeError("Cannot add the same private member more than once");
202
202
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
203
203
  };
204
- var __privateSet$2 = (obj, member, value, setter) => {
205
- __accessCheck$3(obj, member, "write to private field");
204
+ var __privateSet$4 = (obj, member, value, setter) => {
205
+ __accessCheck$4(obj, member, "write to private field");
206
206
  setter ? setter.call(obj, value) : member.set(obj, value);
207
207
  return value;
208
208
  };
209
209
  var _ref;
210
210
  class SceneObjectRef {
211
211
  constructor(ref) {
212
- __privateAdd$3(this, _ref, void 0);
213
- __privateSet$2(this, _ref, ref);
212
+ __privateAdd$4(this, _ref, void 0);
213
+ __privateSet$4(this, _ref, ref);
214
214
  }
215
215
  resolve() {
216
- return __privateGet$3(this, _ref);
216
+ return __privateGet$4(this, _ref);
217
217
  }
218
218
  }
219
219
  _ref = new WeakMap();
@@ -611,7 +611,184 @@ function lookupVariable(name, sceneObject) {
611
611
  return null;
612
612
  }
613
613
 
614
+ function writeSceneLog(logger, message, ...rest) {
615
+ let loggingEnabled = false;
616
+ if (typeof window !== "undefined") {
617
+ loggingEnabled = localStorage.getItem("grafana.debug.scenes") === "true";
618
+ }
619
+ if (loggingEnabled) {
620
+ console.log(`${logger}: `, message, ...rest);
621
+ }
622
+ }
623
+
624
+ var __accessCheck$3 = (obj, member, msg) => {
625
+ if (!member.has(obj))
626
+ throw TypeError("Cannot " + msg);
627
+ };
628
+ var __privateGet$3 = (obj, member, getter) => {
629
+ __accessCheck$3(obj, member, "read from private field");
630
+ return getter ? getter.call(obj) : member.get(obj);
631
+ };
632
+ var __privateAdd$3 = (obj, member, value) => {
633
+ if (member.has(obj))
634
+ throw TypeError("Cannot add the same private member more than once");
635
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
636
+ };
637
+ var __privateSet$3 = (obj, member, value, setter) => {
638
+ __accessCheck$3(obj, member, "write to private field");
639
+ setter ? setter.call(obj, value) : member.set(obj, value);
640
+ return value;
641
+ };
642
+ var _profileInProgress, _profileStartTs, _trailAnimationFrameId, _recordedTrailingSpans;
643
+ const POST_STORM_WINDOW = 2e3;
644
+ const SPAN_THRESHOLD = 30;
645
+ class SceneRenderProfiler {
646
+ constructor(queryController) {
647
+ this.queryController = queryController;
648
+ __privateAdd$3(this, _profileInProgress, null);
649
+ __privateAdd$3(this, _profileStartTs, null);
650
+ __privateAdd$3(this, _trailAnimationFrameId, null);
651
+ __privateAdd$3(this, _recordedTrailingSpans, []);
652
+ this.lastFrameTime = 0;
653
+ this.measureTrailingFrames = (measurementStartTs, lastFrameTime, profileStartTs) => {
654
+ const currentFrameTime = performance.now();
655
+ const frameLength = currentFrameTime - lastFrameTime;
656
+ __privateGet$3(this, _recordedTrailingSpans).push(frameLength);
657
+ if (currentFrameTime - measurementStartTs < POST_STORM_WINDOW) {
658
+ __privateSet$3(this, _trailAnimationFrameId, requestAnimationFrame(
659
+ () => this.measureTrailingFrames(measurementStartTs, currentFrameTime, profileStartTs)
660
+ ));
661
+ } else {
662
+ const slowFrames = processRecordedSpans(__privateGet$3(this, _recordedTrailingSpans));
663
+ const slowFramesTime = slowFrames.reduce((acc, val) => acc + val, 0);
664
+ writeSceneLog(
665
+ this.constructor.name,
666
+ "Profile tail recorded, slow frames duration:",
667
+ slowFramesTime,
668
+ slowFrames,
669
+ __privateGet$3(this, _profileInProgress)
670
+ );
671
+ __privateSet$3(this, _recordedTrailingSpans, []);
672
+ const profileDuration = measurementStartTs - profileStartTs;
673
+ writeSceneLog(
674
+ this.constructor.name,
675
+ "Stoped recording, total measured time (network included):",
676
+ profileDuration + slowFramesTime
677
+ );
678
+ __privateSet$3(this, _trailAnimationFrameId, null);
679
+ const profileEndTs = profileStartTs + profileDuration + slowFramesTime;
680
+ performance.measure("DashboardInteraction", {
681
+ start: profileStartTs,
682
+ end: profileEndTs
683
+ });
684
+ const networkDuration = captureNetwork(profileStartTs, profileEndTs);
685
+ if (this.queryController.state.onProfileComplete) {
686
+ this.queryController.state.onProfileComplete({
687
+ origin: __privateGet$3(this, _profileInProgress).origin,
688
+ crumbs: __privateGet$3(this, _profileInProgress).crumbs,
689
+ duration: profileDuration + slowFramesTime,
690
+ networkDuration,
691
+ jsHeapSizeLimit: performance.memory ? performance.memory.jsHeapSizeLimit : 0,
692
+ usedJSHeapSize: performance.memory ? performance.memory.usedJSHeapSize : 0,
693
+ totalJSHeapSize: performance.memory ? performance.memory.totalJSHeapSize : 0
694
+ });
695
+ }
696
+ if (window.__runs) {
697
+ window.__runs += `${Date.now()}, ${profileDuration + slowFramesTime}
698
+ `;
699
+ } else {
700
+ window.__runs = `${Date.now()}, ${profileDuration + slowFramesTime}
701
+ `;
702
+ }
703
+ }
704
+ };
705
+ }
706
+ startProfile(name) {
707
+ if (__privateGet$3(this, _trailAnimationFrameId)) {
708
+ cancelAnimationFrame(__privateGet$3(this, _trailAnimationFrameId));
709
+ __privateSet$3(this, _trailAnimationFrameId, null);
710
+ writeSceneLog(this.constructor.name, "New profile: Stopped recording frames");
711
+ }
712
+ __privateSet$3(this, _profileInProgress, { origin: name, crumbs: [] });
713
+ __privateSet$3(this, _profileStartTs, performance.now());
714
+ writeSceneLog(this.constructor.name, "Profile started:", __privateGet$3(this, _profileInProgress), __privateGet$3(this, _profileStartTs));
715
+ }
716
+ recordProfileTail(measurementStartTime, profileStartTs) {
717
+ __privateSet$3(this, _trailAnimationFrameId, requestAnimationFrame(
718
+ () => this.measureTrailingFrames(measurementStartTime, measurementStartTime, profileStartTs)
719
+ ));
720
+ }
721
+ tryCompletingProfile() {
722
+ writeSceneLog(this.constructor.name, "Trying to complete profile", __privateGet$3(this, _profileInProgress));
723
+ if (this.queryController.runningQueriesCount() === 0 && __privateGet$3(this, _profileInProgress)) {
724
+ writeSceneLog(this.constructor.name, "All queries completed, stopping profile");
725
+ this.recordProfileTail(performance.now(), __privateGet$3(this, _profileStartTs));
726
+ }
727
+ }
728
+ isTailRecording() {
729
+ return Boolean(__privateGet$3(this, _trailAnimationFrameId));
730
+ }
731
+ cancelTailRecording() {
732
+ if (__privateGet$3(this, _trailAnimationFrameId)) {
733
+ cancelAnimationFrame(__privateGet$3(this, _trailAnimationFrameId));
734
+ __privateSet$3(this, _trailAnimationFrameId, null);
735
+ writeSceneLog(this.constructor.name, "Cancelled recording frames, new profile started");
736
+ }
737
+ }
738
+ addCrumb(crumb) {
739
+ if (__privateGet$3(this, _profileInProgress)) {
740
+ __privateGet$3(this, _profileInProgress).crumbs.push(crumb);
741
+ }
742
+ }
743
+ }
744
+ _profileInProgress = new WeakMap();
745
+ _profileStartTs = new WeakMap();
746
+ _trailAnimationFrameId = new WeakMap();
747
+ _recordedTrailingSpans = new WeakMap();
748
+ function processRecordedSpans(spans) {
749
+ for (let i = spans.length - 1; i >= 0; i--) {
750
+ if (spans[i] > SPAN_THRESHOLD) {
751
+ return spans.slice(0, i + 1);
752
+ }
753
+ }
754
+ return [spans[0]];
755
+ }
756
+ function captureNetwork(startTs, endTs) {
757
+ const entries = performance.getEntriesByType("resource");
758
+ performance.clearResourceTimings();
759
+ const networkEntries = entries.filter((entry) => entry.startTime >= startTs && entry.startTime <= endTs);
760
+ for (const entry of networkEntries) {
761
+ performance.measure("Network entry " + entry.name, {
762
+ start: entry.startTime,
763
+ end: entry.responseEnd
764
+ });
765
+ }
766
+ return calculateNetworkTime(networkEntries);
767
+ }
768
+ function calculateNetworkTime(requests) {
769
+ if (requests.length === 0) {
770
+ return 0;
771
+ }
772
+ requests.sort((a, b) => a.startTime - b.startTime);
773
+ let totalNetworkTime = 0;
774
+ let currentStart = requests[0].startTime;
775
+ let currentEnd = requests[0].responseEnd;
776
+ for (let i = 1; i < requests.length; i++) {
777
+ if (requests[i].startTime <= currentEnd) {
778
+ currentEnd = Math.max(currentEnd, requests[i].responseEnd);
779
+ } else {
780
+ totalNetworkTime += currentEnd - currentStart;
781
+ currentStart = requests[i].startTime;
782
+ currentEnd = requests[i].responseEnd;
783
+ }
784
+ }
785
+ totalNetworkTime += currentEnd - currentStart;
786
+ return totalNetworkTime;
787
+ }
788
+
614
789
  var __defProp$K = Object.defineProperty;
790
+ var __defProps$u = Object.defineProperties;
791
+ var __getOwnPropDescs$u = Object.getOwnPropertyDescriptors;
615
792
  var __getOwnPropSymbols$K = Object.getOwnPropertySymbols;
616
793
  var __hasOwnProp$K = Object.prototype.hasOwnProperty;
617
794
  var __propIsEnum$K = Object.prototype.propertyIsEnumerable;
@@ -627,9 +804,131 @@ var __spreadValues$K = (a, b) => {
627
804
  }
628
805
  return a;
629
806
  };
807
+ var __spreadProps$u = (a, b) => __defProps$u(a, __getOwnPropDescs$u(b));
808
+ var __accessCheck$2 = (obj, member, msg) => {
809
+ if (!member.has(obj))
810
+ throw TypeError("Cannot " + msg);
811
+ };
812
+ var __privateGet$2 = (obj, member, getter) => {
813
+ __accessCheck$2(obj, member, "read from private field");
814
+ return getter ? getter.call(obj) : member.get(obj);
815
+ };
816
+ var __privateAdd$2 = (obj, member, value) => {
817
+ if (member.has(obj))
818
+ throw TypeError("Cannot add the same private member more than once");
819
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
820
+ };
821
+ var __privateSet$2 = (obj, member, value, setter) => {
822
+ __accessCheck$2(obj, member, "write to private field");
823
+ setter ? setter.call(obj, value) : member.set(obj, value);
824
+ return value;
825
+ };
826
+ var _running, _tryCompleteProfileFrameId;
827
+ function isQueryController(s) {
828
+ return "isQueryController" in s;
829
+ }
830
+ class SceneQueryController extends SceneObjectBase {
831
+ constructor(state = {}) {
832
+ super(__spreadProps$u(__spreadValues$K({}, state), { isRunning: false }));
833
+ this.isQueryController = true;
834
+ this.profiler = new SceneRenderProfiler(this);
835
+ __privateAdd$2(this, _running, /* @__PURE__ */ new Set());
836
+ __privateAdd$2(this, _tryCompleteProfileFrameId, null);
837
+ this.runningQueriesCount = () => {
838
+ return __privateGet$2(this, _running).size;
839
+ };
840
+ this.addActivationHandler(() => {
841
+ return () => __privateGet$2(this, _running).clear();
842
+ });
843
+ }
844
+ startProfile(source) {
845
+ if (!this.state.enableProfiling) {
846
+ return;
847
+ }
848
+ this.profiler.startProfile(source.constructor.name);
849
+ }
850
+ queryStarted(entry) {
851
+ __privateGet$2(this, _running).add(entry);
852
+ this.changeRunningQueryCount(1, entry);
853
+ if (!this.state.isRunning) {
854
+ this.setState({ isRunning: true });
855
+ }
856
+ }
857
+ queryCompleted(entry) {
858
+ if (!__privateGet$2(this, _running).has(entry)) {
859
+ return;
860
+ }
861
+ __privateGet$2(this, _running).delete(entry);
862
+ this.changeRunningQueryCount(-1);
863
+ if (__privateGet$2(this, _running).size === 0) {
864
+ this.setState({ isRunning: false });
865
+ }
866
+ }
867
+ changeRunningQueryCount(dir, entry) {
868
+ var _a;
869
+ window.__grafanaRunningQueryCount = ((_a = window.__grafanaRunningQueryCount) != null ? _a : 0) + dir;
870
+ if (dir === 1 && this.state.enableProfiling) {
871
+ if (entry) {
872
+ this.profiler.addCrumb(`${entry.origin.constructor.name}/${entry.type}`);
873
+ }
874
+ if (this.profiler.isTailRecording()) {
875
+ writeSceneLog(this.constructor.name, "New query started, cancelling tail recording");
876
+ this.profiler.cancelTailRecording();
877
+ }
878
+ }
879
+ if (this.state.enableProfiling) {
880
+ if (__privateGet$2(this, _tryCompleteProfileFrameId)) {
881
+ cancelAnimationFrame(__privateGet$2(this, _tryCompleteProfileFrameId));
882
+ }
883
+ __privateSet$2(this, _tryCompleteProfileFrameId, requestAnimationFrame(() => {
884
+ this.profiler.tryCompletingProfile();
885
+ }));
886
+ }
887
+ }
888
+ cancelAll() {
889
+ var _a;
890
+ for (const entry of __privateGet$2(this, _running).values()) {
891
+ (_a = entry.cancel) == null ? void 0 : _a.call(entry);
892
+ }
893
+ }
894
+ }
895
+ _running = new WeakMap();
896
+ _tryCompleteProfileFrameId = new WeakMap();
897
+
898
+ function getQueryController(sceneObject) {
899
+ let parent = sceneObject;
900
+ while (parent) {
901
+ if (parent.state.$behaviors) {
902
+ for (const behavior of parent.state.$behaviors) {
903
+ if (isQueryController(behavior)) {
904
+ return behavior;
905
+ }
906
+ }
907
+ }
908
+ parent = parent.parent;
909
+ }
910
+ return void 0;
911
+ }
912
+
913
+ var __defProp$J = Object.defineProperty;
914
+ var __getOwnPropSymbols$J = Object.getOwnPropertySymbols;
915
+ var __hasOwnProp$J = Object.prototype.hasOwnProperty;
916
+ var __propIsEnum$J = Object.prototype.propertyIsEnumerable;
917
+ var __defNormalProp$J = (obj, key, value) => key in obj ? __defProp$J(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
918
+ var __spreadValues$J = (a, b) => {
919
+ for (var prop in b || (b = {}))
920
+ if (__hasOwnProp$J.call(b, prop))
921
+ __defNormalProp$J(a, prop, b[prop]);
922
+ if (__getOwnPropSymbols$J)
923
+ for (var prop of __getOwnPropSymbols$J(b)) {
924
+ if (__propIsEnum$J.call(b, prop))
925
+ __defNormalProp$J(a, prop, b[prop]);
926
+ }
927
+ return a;
928
+ };
630
929
  class SceneDataNode extends SceneObjectBase {
631
930
  constructor(state) {
632
- super(__spreadValues$K({
931
+ super(__spreadValues$J({
633
932
  data: emptyPanelData
634
933
  }, state));
635
934
  }
@@ -735,19 +1034,19 @@ function isValid$1(value, roundUp, timeZone) {
735
1034
  return parsed.isValid();
736
1035
  }
737
1036
 
738
- var __defProp$J = Object.defineProperty;
739
- var __getOwnPropSymbols$J = Object.getOwnPropertySymbols;
740
- var __hasOwnProp$J = Object.prototype.hasOwnProperty;
741
- var __propIsEnum$J = Object.prototype.propertyIsEnumerable;
742
- var __defNormalProp$J = (obj, key, value) => key in obj ? __defProp$J(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
743
- var __spreadValues$J = (a, b) => {
1037
+ var __defProp$I = Object.defineProperty;
1038
+ var __getOwnPropSymbols$I = Object.getOwnPropertySymbols;
1039
+ var __hasOwnProp$I = Object.prototype.hasOwnProperty;
1040
+ var __propIsEnum$I = Object.prototype.propertyIsEnumerable;
1041
+ var __defNormalProp$I = (obj, key, value) => key in obj ? __defProp$I(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1042
+ var __spreadValues$I = (a, b) => {
744
1043
  for (var prop in b || (b = {}))
745
- if (__hasOwnProp$J.call(b, prop))
746
- __defNormalProp$J(a, prop, b[prop]);
747
- if (__getOwnPropSymbols$J)
748
- for (var prop of __getOwnPropSymbols$J(b)) {
749
- if (__propIsEnum$J.call(b, prop))
750
- __defNormalProp$J(a, prop, b[prop]);
1044
+ if (__hasOwnProp$I.call(b, prop))
1045
+ __defNormalProp$I(a, prop, b[prop]);
1046
+ if (__getOwnPropSymbols$I)
1047
+ for (var prop of __getOwnPropSymbols$I(b)) {
1048
+ if (__propIsEnum$I.call(b, prop))
1049
+ __defNormalProp$I(a, prop, b[prop]);
751
1050
  }
752
1051
  return a;
753
1052
  };
@@ -765,7 +1064,7 @@ class SceneTimeRange extends SceneObjectBase {
765
1064
  state.UNSAFE_nowDelay
766
1065
  );
767
1066
  const refreshOnActivate = (_a = state.refreshOnActivate) != null ? _a : { percent: 10 };
768
- super(__spreadValues$J({ from, to, timeZone, value, refreshOnActivate }, state));
1067
+ super(__spreadValues$I({ from, to, timeZone, value, refreshOnActivate }, state));
769
1068
  this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: ["from", "to", "timezone", "time", "time.window"] });
770
1069
  this.onTimeRangeChange = (timeRange) => {
771
1070
  const update = {};
@@ -787,6 +1086,8 @@ class SceneTimeRange extends SceneObjectBase {
787
1086
  this.state.UNSAFE_nowDelay
788
1087
  );
789
1088
  if (update.from !== this.state.from || update.to !== this.state.to) {
1089
+ const queryController = getQueryController(this);
1090
+ queryController == null ? void 0 : queryController.startProfile(this);
790
1091
  this._urlSync.performBrowserHistoryAction(() => {
791
1092
  this.setState(update);
792
1093
  });
@@ -1749,25 +2050,25 @@ function collectAllVariables(sceneObject, record = {}) {
1749
2050
  return record;
1750
2051
  }
1751
2052
 
1752
- var __defProp$I = Object.defineProperty;
1753
- var __defProps$u = Object.defineProperties;
1754
- var __getOwnPropDescs$u = Object.getOwnPropertyDescriptors;
1755
- var __getOwnPropSymbols$I = Object.getOwnPropertySymbols;
1756
- var __hasOwnProp$I = Object.prototype.hasOwnProperty;
1757
- var __propIsEnum$I = Object.prototype.propertyIsEnumerable;
1758
- var __defNormalProp$I = (obj, key, value) => key in obj ? __defProp$I(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1759
- var __spreadValues$I = (a, b) => {
2053
+ var __defProp$H = Object.defineProperty;
2054
+ var __defProps$t = Object.defineProperties;
2055
+ var __getOwnPropDescs$t = Object.getOwnPropertyDescriptors;
2056
+ var __getOwnPropSymbols$H = Object.getOwnPropertySymbols;
2057
+ var __hasOwnProp$H = Object.prototype.hasOwnProperty;
2058
+ var __propIsEnum$H = Object.prototype.propertyIsEnumerable;
2059
+ var __defNormalProp$H = (obj, key, value) => key in obj ? __defProp$H(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2060
+ var __spreadValues$H = (a, b) => {
1760
2061
  for (var prop in b || (b = {}))
1761
- if (__hasOwnProp$I.call(b, prop))
1762
- __defNormalProp$I(a, prop, b[prop]);
1763
- if (__getOwnPropSymbols$I)
1764
- for (var prop of __getOwnPropSymbols$I(b)) {
1765
- if (__propIsEnum$I.call(b, prop))
1766
- __defNormalProp$I(a, prop, b[prop]);
2062
+ if (__hasOwnProp$H.call(b, prop))
2063
+ __defNormalProp$H(a, prop, b[prop]);
2064
+ if (__getOwnPropSymbols$H)
2065
+ for (var prop of __getOwnPropSymbols$H(b)) {
2066
+ if (__propIsEnum$H.call(b, prop))
2067
+ __defNormalProp$H(a, prop, b[prop]);
1767
2068
  }
1768
2069
  return a;
1769
2070
  };
1770
- var __spreadProps$u = (a, b) => __defProps$u(a, __getOwnPropDescs$u(b));
2071
+ var __spreadProps$t = (a, b) => __defProps$t(a, __getOwnPropDescs$t(b));
1771
2072
  function getTemplateProxyForField(field, frame, frames) {
1772
2073
  return new Proxy(
1773
2074
  {},
@@ -1783,7 +2084,7 @@ function getTemplateProxyForField(field, frame, frames) {
1783
2084
  if (!field.labels) {
1784
2085
  return "";
1785
2086
  }
1786
- return __spreadProps$u(__spreadValues$I({}, field.labels), {
2087
+ return __spreadProps$t(__spreadValues$H({}, field.labels), {
1787
2088
  __values: Object.values(field.labels).sort().join(", "),
1788
2089
  toString: () => {
1789
2090
  return data.formatLabels(field.labels, "", true);
@@ -2131,70 +2432,56 @@ function isDataLayer(obj) {
2131
2432
  return "isDataLayer" in obj;
2132
2433
  }
2133
2434
 
2134
- var __accessCheck$2 = (obj, member, msg) => {
2135
- if (!member.has(obj))
2136
- throw TypeError("Cannot " + msg);
2137
- };
2138
- var __privateGet$2 = (obj, member, getter) => {
2139
- __accessCheck$2(obj, member, "read from private field");
2140
- return getter ? getter.call(obj) : member.get(obj);
2141
- };
2142
- var __privateAdd$2 = (obj, member, value) => {
2143
- if (member.has(obj))
2144
- throw TypeError("Cannot add the same private member more than once");
2145
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2146
- };
2147
- var _running;
2148
- function isQueryController(s) {
2149
- return "isQueryController" in s;
2150
- }
2151
- class SceneQueryController extends SceneObjectBase {
2152
- constructor() {
2153
- super({ isRunning: false });
2154
- this.isQueryController = true;
2155
- __privateAdd$2(this, _running, /* @__PURE__ */ new Set());
2156
- this.addActivationHandler(() => {
2157
- return () => __privateGet$2(this, _running).clear();
2158
- });
2159
- }
2160
- queryStarted(entry) {
2161
- __privateGet$2(this, _running).add(entry);
2162
- this.changeRunningQueryCount(1);
2163
- if (!this.state.isRunning) {
2164
- this.setState({ isRunning: true });
2165
- }
2166
- }
2167
- queryCompleted(entry) {
2168
- if (!__privateGet$2(this, _running).has(entry)) {
2169
- return;
2170
- }
2171
- __privateGet$2(this, _running).delete(entry);
2172
- this.changeRunningQueryCount(-1);
2173
- if (__privateGet$2(this, _running).size === 0) {
2174
- this.setState({ isRunning: false });
2175
- }
2176
- }
2177
- changeRunningQueryCount(dir) {
2178
- var _a;
2179
- window.__grafanaRunningQueryCount = ((_a = window.__grafanaRunningQueryCount) != null ? _a : 0) + dir;
2180
- }
2181
- cancelAll() {
2182
- var _a;
2183
- for (const entry of __privateGet$2(this, _running).values()) {
2184
- (_a = entry.cancel) == null ? void 0 : _a.call(entry);
2435
+ function registerQueryWithController(entry) {
2436
+ return (queryStream) => {
2437
+ const queryControler = sceneGraph.getQueryController(entry.origin);
2438
+ if (!queryControler) {
2439
+ return queryStream;
2185
2440
  }
2186
- }
2441
+ return new rxjs.Observable((observer) => {
2442
+ if (!entry.cancel) {
2443
+ entry.cancel = () => observer.complete();
2444
+ }
2445
+ queryControler.queryStarted(entry);
2446
+ let markedAsCompleted = false;
2447
+ const sub = queryStream.subscribe({
2448
+ next: (v) => {
2449
+ if (!markedAsCompleted && v.state !== schema.LoadingState.Loading) {
2450
+ markedAsCompleted = true;
2451
+ queryControler.queryCompleted(entry);
2452
+ }
2453
+ observer.next(v);
2454
+ },
2455
+ error: (e) => observer.error(e),
2456
+ complete: () => {
2457
+ observer.complete();
2458
+ }
2459
+ });
2460
+ return () => {
2461
+ sub.unsubscribe();
2462
+ if (!markedAsCompleted) {
2463
+ queryControler.queryCompleted(entry);
2464
+ }
2465
+ };
2466
+ });
2467
+ };
2187
2468
  }
2188
- _running = new WeakMap();
2189
-
2190
- function writeSceneLog(logger, message, ...rest) {
2191
- let loggingEnabled = false;
2192
- if (typeof window !== "undefined") {
2193
- loggingEnabled = localStorage.getItem("grafana.debug.scenes") === "true";
2194
- }
2195
- if (loggingEnabled) {
2196
- console.log(`${logger}: `, message, ...rest);
2197
- }
2469
+ function wrapPromiseInStateObservable(promise) {
2470
+ console.log("wrapPromiseInStateObservable", promise);
2471
+ return new rxjs.Observable((observer) => {
2472
+ observer.next({ state: schema.LoadingState.Loading });
2473
+ const promiseObservable = rxjs.from(promise);
2474
+ promiseObservable.pipe(
2475
+ rxjs.map(() => ({ state: schema.LoadingState.Done })),
2476
+ rxjs.catchError(() => {
2477
+ observer.next({ state: schema.LoadingState.Error });
2478
+ return [];
2479
+ })
2480
+ ).subscribe({
2481
+ next: (result) => observer.next(result),
2482
+ complete: () => observer.complete()
2483
+ });
2484
+ });
2198
2485
  }
2199
2486
 
2200
2487
  async function getDataSource(datasource, scopedVars) {
@@ -2207,7 +2494,21 @@ async function getDataSource(datasource, scopedVars) {
2207
2494
  if (datasource && datasource.query) {
2208
2495
  return datasource;
2209
2496
  }
2210
- return await runtime.getDataSourceSrv().get(datasource, scopedVars);
2497
+ const dsPromise = runtime.getDataSourceSrv().get(datasource, scopedVars);
2498
+ if (scopedVars.__sceneObject && scopedVars.__sceneObject.value.valueOf()) {
2499
+ const queryControler = sceneGraph.getQueryController(scopedVars.__sceneObject.value.valueOf());
2500
+ if (queryControler && queryControler.state.enableProfiling) {
2501
+ wrapPromiseInStateObservable(dsPromise).pipe(
2502
+ registerQueryWithController({
2503
+ type: "plugin",
2504
+ origin: scopedVars.__sceneObject.value.valueOf()
2505
+ })
2506
+ ).subscribe(() => {
2507
+ });
2508
+ }
2509
+ }
2510
+ const result = await dsPromise;
2511
+ return result;
2211
2512
  }
2212
2513
 
2213
2514
  class VariableValueRecorder {
@@ -2280,25 +2581,25 @@ function isExtraQueryProvider(obj) {
2280
2581
  return typeof obj === "object" && "getExtraQueries" in obj;
2281
2582
  }
2282
2583
 
2283
- var __defProp$H = Object.defineProperty;
2284
- var __defProps$t = Object.defineProperties;
2285
- var __getOwnPropDescs$t = Object.getOwnPropertyDescriptors;
2286
- var __getOwnPropSymbols$H = Object.getOwnPropertySymbols;
2287
- var __hasOwnProp$H = Object.prototype.hasOwnProperty;
2288
- var __propIsEnum$H = Object.prototype.propertyIsEnumerable;
2289
- var __defNormalProp$H = (obj, key, value) => key in obj ? __defProp$H(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2290
- var __spreadValues$H = (a, b) => {
2584
+ var __defProp$G = Object.defineProperty;
2585
+ var __defProps$s = Object.defineProperties;
2586
+ var __getOwnPropDescs$s = Object.getOwnPropertyDescriptors;
2587
+ var __getOwnPropSymbols$G = Object.getOwnPropertySymbols;
2588
+ var __hasOwnProp$G = Object.prototype.hasOwnProperty;
2589
+ var __propIsEnum$G = Object.prototype.propertyIsEnumerable;
2590
+ var __defNormalProp$G = (obj, key, value) => key in obj ? __defProp$G(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2591
+ var __spreadValues$G = (a, b) => {
2291
2592
  for (var prop in b || (b = {}))
2292
- if (__hasOwnProp$H.call(b, prop))
2293
- __defNormalProp$H(a, prop, b[prop]);
2294
- if (__getOwnPropSymbols$H)
2295
- for (var prop of __getOwnPropSymbols$H(b)) {
2296
- if (__propIsEnum$H.call(b, prop))
2297
- __defNormalProp$H(a, prop, b[prop]);
2593
+ if (__hasOwnProp$G.call(b, prop))
2594
+ __defNormalProp$G(a, prop, b[prop]);
2595
+ if (__getOwnPropSymbols$G)
2596
+ for (var prop of __getOwnPropSymbols$G(b)) {
2597
+ if (__propIsEnum$G.call(b, prop))
2598
+ __defNormalProp$G(a, prop, b[prop]);
2298
2599
  }
2299
2600
  return a;
2300
2601
  };
2301
- var __spreadProps$t = (a, b) => __defProps$t(a, __getOwnPropDescs$t(b));
2602
+ var __spreadProps$s = (a, b) => __defProps$s(a, __getOwnPropDescs$s(b));
2302
2603
  const passthroughProcessor = (_, secondary) => rxjs.of(secondary);
2303
2604
  const extraQueryProcessingOperator = (processors) => (data) => {
2304
2605
  return data.pipe(
@@ -2311,7 +2612,7 @@ const extraQueryProcessingOperator = (processors) => (data) => {
2311
2612
  }),
2312
2613
  rxjs.map(([primary, ...processedSecondaries]) => {
2313
2614
  var _a;
2314
- return __spreadProps$t(__spreadValues$H({}, primary), {
2615
+ return __spreadProps$s(__spreadValues$G({}, primary), {
2315
2616
  series: [...primary.series, ...processedSecondaries.flatMap((s) => s.series)],
2316
2617
  annotations: [...(_a = primary.annotations) != null ? _a : [], ...processedSecondaries.flatMap((s) => {
2317
2618
  var _a2;
@@ -2322,25 +2623,25 @@ const extraQueryProcessingOperator = (processors) => (data) => {
2322
2623
  );
2323
2624
  };
2324
2625
 
2325
- var __defProp$G = Object.defineProperty;
2326
- var __defProps$s = Object.defineProperties;
2327
- var __getOwnPropDescs$s = Object.getOwnPropertyDescriptors;
2328
- var __getOwnPropSymbols$G = Object.getOwnPropertySymbols;
2329
- var __hasOwnProp$G = Object.prototype.hasOwnProperty;
2330
- var __propIsEnum$G = Object.prototype.propertyIsEnumerable;
2331
- var __defNormalProp$G = (obj, key, value) => key in obj ? __defProp$G(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2332
- var __spreadValues$G = (a, b) => {
2626
+ var __defProp$F = Object.defineProperty;
2627
+ var __defProps$r = Object.defineProperties;
2628
+ var __getOwnPropDescs$r = Object.getOwnPropertyDescriptors;
2629
+ var __getOwnPropSymbols$F = Object.getOwnPropertySymbols;
2630
+ var __hasOwnProp$F = Object.prototype.hasOwnProperty;
2631
+ var __propIsEnum$F = Object.prototype.propertyIsEnumerable;
2632
+ var __defNormalProp$F = (obj, key, value) => key in obj ? __defProp$F(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2633
+ var __spreadValues$F = (a, b) => {
2333
2634
  for (var prop in b || (b = {}))
2334
- if (__hasOwnProp$G.call(b, prop))
2335
- __defNormalProp$G(a, prop, b[prop]);
2336
- if (__getOwnPropSymbols$G)
2337
- for (var prop of __getOwnPropSymbols$G(b)) {
2338
- if (__propIsEnum$G.call(b, prop))
2339
- __defNormalProp$G(a, prop, b[prop]);
2635
+ if (__hasOwnProp$F.call(b, prop))
2636
+ __defNormalProp$F(a, prop, b[prop]);
2637
+ if (__getOwnPropSymbols$F)
2638
+ for (var prop of __getOwnPropSymbols$F(b)) {
2639
+ if (__propIsEnum$F.call(b, prop))
2640
+ __defNormalProp$F(a, prop, b[prop]);
2340
2641
  }
2341
2642
  return a;
2342
2643
  };
2343
- var __spreadProps$s = (a, b) => __defProps$s(a, __getOwnPropDescs$s(b));
2644
+ var __spreadProps$r = (a, b) => __defProps$r(a, __getOwnPropDescs$r(b));
2344
2645
  function filterAnnotations(data, filters) {
2345
2646
  var _a;
2346
2647
  if (!Array.isArray(data) || data.length === 0) {
@@ -2391,11 +2692,11 @@ function filterAnnotations(data, filters) {
2391
2692
  continue;
2392
2693
  }
2393
2694
  }
2394
- fields.push(__spreadProps$s(__spreadValues$G({}, field), {
2695
+ fields.push(__spreadProps$r(__spreadValues$F({}, field), {
2395
2696
  values: buffer
2396
2697
  }));
2397
2698
  }
2398
- processed.push(__spreadProps$s(__spreadValues$G({}, frame), {
2699
+ processed.push(__spreadProps$r(__spreadValues$F({}, frame), {
2399
2700
  fields,
2400
2701
  length: frameLength
2401
2702
  }));
@@ -2455,41 +2756,6 @@ function findActiveAdHocFilterVariableByUid(dsUid) {
2455
2756
  return void 0;
2456
2757
  }
2457
2758
 
2458
- function registerQueryWithController(entry) {
2459
- return (queryStream) => {
2460
- const queryControler = sceneGraph.getQueryController(entry.origin);
2461
- if (!queryControler) {
2462
- return queryStream;
2463
- }
2464
- return new rxjs.Observable((observer) => {
2465
- if (!entry.cancel) {
2466
- entry.cancel = () => observer.complete();
2467
- }
2468
- queryControler.queryStarted(entry);
2469
- let markedAsCompleted = false;
2470
- const sub = queryStream.subscribe({
2471
- next: (v) => {
2472
- if (!markedAsCompleted && v.state !== schema.LoadingState.Loading) {
2473
- markedAsCompleted = true;
2474
- queryControler.queryCompleted(entry);
2475
- }
2476
- observer.next(v);
2477
- },
2478
- error: (e) => observer.error(e),
2479
- complete: () => {
2480
- observer.complete();
2481
- }
2482
- });
2483
- return () => {
2484
- sub.unsubscribe();
2485
- if (!markedAsCompleted) {
2486
- queryControler.queryCompleted(entry);
2487
- }
2488
- };
2489
- });
2490
- };
2491
- }
2492
-
2493
2759
  const allActiveGroupByVariables = /* @__PURE__ */ new Set();
2494
2760
  function findActiveGroupByVariablesByUid(dsUid) {
2495
2761
  var _a;
@@ -2545,33 +2811,33 @@ function getOptionSearcher(options, includeAll) {
2545
2811
  };
2546
2812
  }
2547
2813
 
2548
- var __defProp$F = Object.defineProperty;
2549
- var __defProps$r = Object.defineProperties;
2550
- var __getOwnPropDescs$r = Object.getOwnPropertyDescriptors;
2551
- var __getOwnPropSymbols$F = Object.getOwnPropertySymbols;
2552
- var __hasOwnProp$F = Object.prototype.hasOwnProperty;
2553
- var __propIsEnum$F = Object.prototype.propertyIsEnumerable;
2554
- var __defNormalProp$F = (obj, key, value) => key in obj ? __defProp$F(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2555
- var __spreadValues$F = (a, b) => {
2814
+ var __defProp$E = Object.defineProperty;
2815
+ var __defProps$q = Object.defineProperties;
2816
+ var __getOwnPropDescs$q = Object.getOwnPropertyDescriptors;
2817
+ var __getOwnPropSymbols$E = Object.getOwnPropertySymbols;
2818
+ var __hasOwnProp$E = Object.prototype.hasOwnProperty;
2819
+ var __propIsEnum$E = Object.prototype.propertyIsEnumerable;
2820
+ var __defNormalProp$E = (obj, key, value) => key in obj ? __defProp$E(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2821
+ var __spreadValues$E = (a, b) => {
2556
2822
  for (var prop in b || (b = {}))
2557
- if (__hasOwnProp$F.call(b, prop))
2558
- __defNormalProp$F(a, prop, b[prop]);
2559
- if (__getOwnPropSymbols$F)
2560
- for (var prop of __getOwnPropSymbols$F(b)) {
2561
- if (__propIsEnum$F.call(b, prop))
2562
- __defNormalProp$F(a, prop, b[prop]);
2823
+ if (__hasOwnProp$E.call(b, prop))
2824
+ __defNormalProp$E(a, prop, b[prop]);
2825
+ if (__getOwnPropSymbols$E)
2826
+ for (var prop of __getOwnPropSymbols$E(b)) {
2827
+ if (__propIsEnum$E.call(b, prop))
2828
+ __defNormalProp$E(a, prop, b[prop]);
2563
2829
  }
2564
2830
  return a;
2565
2831
  };
2566
- var __spreadProps$r = (a, b) => __defProps$r(a, __getOwnPropDescs$r(b));
2832
+ var __spreadProps$q = (a, b) => __defProps$q(a, __getOwnPropDescs$q(b));
2567
2833
  var __objRest$4 = (source, exclude) => {
2568
2834
  var target = {};
2569
2835
  for (var prop in source)
2570
- if (__hasOwnProp$F.call(source, prop) && exclude.indexOf(prop) < 0)
2836
+ if (__hasOwnProp$E.call(source, prop) && exclude.indexOf(prop) < 0)
2571
2837
  target[prop] = source[prop];
2572
- if (source != null && __getOwnPropSymbols$F)
2573
- for (var prop of __getOwnPropSymbols$F(source)) {
2574
- if (exclude.indexOf(prop) < 0 && __propIsEnum$F.call(source, prop))
2838
+ if (source != null && __getOwnPropSymbols$E)
2839
+ for (var prop of __getOwnPropSymbols$E(source)) {
2840
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$E.call(source, prop))
2575
2841
  target[prop] = source[prop];
2576
2842
  }
2577
2843
  return target;
@@ -2598,6 +2864,7 @@ function VariableValueSelect({ model }) {
2598
2864
  const [inputValue, setInputValue] = React.useState("");
2599
2865
  const [hasCustomValue, setHasCustomValue] = React.useState(false);
2600
2866
  const selectValue = toSelectableValue$2(value, String(text));
2867
+ const queryController = sceneGraph.getQueryController(model);
2601
2868
  const optionSearcher = React.useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);
2602
2869
  const onInputChange = (value2, { action }) => {
2603
2870
  if (action === "input-change") {
@@ -2637,6 +2904,7 @@ function VariableValueSelect({ model }) {
2637
2904
  "data-testid": e2eSelectors.selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${value}`),
2638
2905
  onChange: (newValue) => {
2639
2906
  model.changeValueTo(newValue.value, newValue.label);
2907
+ queryController == null ? void 0 : queryController.startProfile(model);
2640
2908
  if (hasCustomValue !== newValue.__isNew__) {
2641
2909
  setHasCustomValue(newValue.__isNew__);
2642
2910
  }
@@ -2648,6 +2916,7 @@ function VariableValueSelectMulti({ model }) {
2648
2916
  const arrayValue = React.useMemo(() => lodash.isArray(value) ? value : [value], [value]);
2649
2917
  const [uncommittedValue, setUncommittedValue] = React.useState(arrayValue);
2650
2918
  const [inputValue, setInputValue] = React.useState("");
2919
+ const queryController = sceneGraph.getQueryController(model);
2651
2920
  const optionSearcher = React.useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);
2652
2921
  React.useEffect(() => {
2653
2922
  setUncommittedValue(arrayValue);
@@ -2693,6 +2962,7 @@ function VariableValueSelectMulti({ model }) {
2693
2962
  onInputChange,
2694
2963
  onBlur: () => {
2695
2964
  model.changeValueTo(uncommittedValue);
2965
+ queryController == null ? void 0 : queryController.startProfile(model);
2696
2966
  },
2697
2967
  filterOption: filterNoOp$2,
2698
2968
  "data-testid": e2eSelectors.selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${uncommittedValue}`),
@@ -2719,7 +2989,7 @@ const OptionWithCheckbox = ({
2719
2989
  const theme = ui.useTheme2();
2720
2990
  const selectStyles = ui.getSelectStyles(theme);
2721
2991
  const optionStyles = ui.useStyles2(getOptionStyles);
2722
- return /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$r(__spreadValues$F({
2992
+ return /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$q(__spreadValues$E({
2723
2993
  ref: innerRef,
2724
2994
  className: css.cx(selectStyles.option, isFocused && selectStyles.optionFocused)
2725
2995
  }, rest), {
@@ -2884,28 +3154,28 @@ function wrapInSafeSerializableSceneObject(sceneObject) {
2884
3154
  return { value: sceneObject, text: "__sceneObject" };
2885
3155
  }
2886
3156
 
2887
- var __defProp$E = Object.defineProperty;
2888
- var __defProps$q = Object.defineProperties;
2889
- var __getOwnPropDescs$q = Object.getOwnPropertyDescriptors;
2890
- var __getOwnPropSymbols$E = Object.getOwnPropertySymbols;
2891
- var __hasOwnProp$E = Object.prototype.hasOwnProperty;
2892
- var __propIsEnum$E = Object.prototype.propertyIsEnumerable;
2893
- var __defNormalProp$E = (obj, key, value) => key in obj ? __defProp$E(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2894
- var __spreadValues$E = (a, b) => {
2895
- for (var prop in b || (b = {}))
2896
- if (__hasOwnProp$E.call(b, prop))
2897
- __defNormalProp$E(a, prop, b[prop]);
2898
- if (__getOwnPropSymbols$E)
2899
- for (var prop of __getOwnPropSymbols$E(b)) {
2900
- if (__propIsEnum$E.call(b, prop))
2901
- __defNormalProp$E(a, prop, b[prop]);
3157
+ var __defProp$D = Object.defineProperty;
3158
+ var __defProps$p = Object.defineProperties;
3159
+ var __getOwnPropDescs$p = Object.getOwnPropertyDescriptors;
3160
+ var __getOwnPropSymbols$D = Object.getOwnPropertySymbols;
3161
+ var __hasOwnProp$D = Object.prototype.hasOwnProperty;
3162
+ var __propIsEnum$D = Object.prototype.propertyIsEnumerable;
3163
+ var __defNormalProp$D = (obj, key, value) => key in obj ? __defProp$D(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3164
+ var __spreadValues$D = (a, b) => {
3165
+ for (var prop in b || (b = {}))
3166
+ if (__hasOwnProp$D.call(b, prop))
3167
+ __defNormalProp$D(a, prop, b[prop]);
3168
+ if (__getOwnPropSymbols$D)
3169
+ for (var prop of __getOwnPropSymbols$D(b)) {
3170
+ if (__propIsEnum$D.call(b, prop))
3171
+ __defNormalProp$D(a, prop, b[prop]);
2902
3172
  }
2903
3173
  return a;
2904
3174
  };
2905
- var __spreadProps$q = (a, b) => __defProps$q(a, __getOwnPropDescs$q(b));
3175
+ var __spreadProps$p = (a, b) => __defProps$p(a, __getOwnPropDescs$p(b));
2906
3176
  class GroupByVariable extends MultiValueVariable {
2907
3177
  constructor(initialState) {
2908
- super(__spreadProps$q(__spreadValues$E({
3178
+ super(__spreadProps$p(__spreadValues$D({
2909
3179
  isMulti: true,
2910
3180
  name: "",
2911
3181
  value: [],
@@ -2936,7 +3206,7 @@ class GroupByVariable extends MultiValueVariable {
2936
3206
  const queries = getQueriesForVariables(this);
2937
3207
  const otherFilters = this.state.baseFilters || [];
2938
3208
  const timeRange = sceneGraph.getTimeRange(this).state.value;
2939
- const response = await ds.getTagKeys(__spreadValues$E({
3209
+ const response = await ds.getTagKeys(__spreadValues$D({
2940
3210
  filters: otherFilters,
2941
3211
  queries,
2942
3212
  timeRange
@@ -3131,7 +3401,7 @@ function LoadingIndicator(props) {
3131
3401
  }
3132
3402
 
3133
3403
  function ControlsLabel(props) {
3134
- const styles = ui.useStyles2(getStyles$f);
3404
+ const styles = ui.useStyles2(getStyles$e);
3135
3405
  const theme = ui.useTheme2();
3136
3406
  const isVertical = props.layout === "vertical";
3137
3407
  const loadingIndicator = Boolean(props.isLoading) ? /* @__PURE__ */ React__default["default"].createElement("div", {
@@ -3194,7 +3464,7 @@ function ControlsLabel(props) {
3194
3464
  }
3195
3465
  return labelElement;
3196
3466
  }
3197
- const getStyles$f = (theme) => ({
3467
+ const getStyles$e = (theme) => ({
3198
3468
  horizontalLabel: css.css({
3199
3469
  background: theme.isDark ? theme.colors.background.primary : theme.colors.background.secondary,
3200
3470
  display: `flex`,
@@ -3270,19 +3540,19 @@ function getAdhocOptionSearcher(options) {
3270
3540
  };
3271
3541
  }
3272
3542
 
3273
- var __defProp$D = Object.defineProperty;
3274
- var __getOwnPropSymbols$D = Object.getOwnPropertySymbols;
3275
- var __hasOwnProp$D = Object.prototype.hasOwnProperty;
3276
- var __propIsEnum$D = Object.prototype.propertyIsEnumerable;
3277
- var __defNormalProp$D = (obj, key, value) => key in obj ? __defProp$D(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3278
- var __spreadValues$D = (a, b) => {
3543
+ var __defProp$C = Object.defineProperty;
3544
+ var __getOwnPropSymbols$C = Object.getOwnPropertySymbols;
3545
+ var __hasOwnProp$C = Object.prototype.hasOwnProperty;
3546
+ var __propIsEnum$C = Object.prototype.propertyIsEnumerable;
3547
+ var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3548
+ var __spreadValues$C = (a, b) => {
3279
3549
  for (var prop in b || (b = {}))
3280
- if (__hasOwnProp$D.call(b, prop))
3281
- __defNormalProp$D(a, prop, b[prop]);
3282
- if (__getOwnPropSymbols$D)
3283
- for (var prop of __getOwnPropSymbols$D(b)) {
3284
- if (__propIsEnum$D.call(b, prop))
3285
- __defNormalProp$D(a, prop, b[prop]);
3550
+ if (__hasOwnProp$C.call(b, prop))
3551
+ __defNormalProp$C(a, prop, b[prop]);
3552
+ if (__getOwnPropSymbols$C)
3553
+ for (var prop of __getOwnPropSymbols$C(b)) {
3554
+ if (__propIsEnum$C.call(b, prop))
3555
+ __defNormalProp$C(a, prop, b[prop]);
3286
3556
  }
3287
3557
  return a;
3288
3558
  };
@@ -3295,7 +3565,7 @@ function keyLabelToOption(key, label) {
3295
3565
  const filterNoOp = () => true;
3296
3566
  function AdHocFilterRenderer({ filter, model }) {
3297
3567
  var _a, _b, _c;
3298
- const styles = ui.useStyles2(getStyles$e);
3568
+ const styles = ui.useStyles2(getStyles$d);
3299
3569
  const [keys, setKeys] = React.useState([]);
3300
3570
  const [values, setValues] = React.useState([]);
3301
3571
  const [isKeysLoading, setIsKeysLoading] = React.useState(false);
@@ -3305,10 +3575,12 @@ function AdHocFilterRenderer({ filter, model }) {
3305
3575
  const [isOperatorOpen, setIsOperatorOpen] = React.useState(false);
3306
3576
  const [valueInputValue, setValueInputValue] = React.useState("");
3307
3577
  const [valueHasCustomValue, setValueHasCustomValue] = React.useState(false);
3308
- const [uncommittedValue, setUncommittedValue] = React.useState(filter.values ? filter.values.map((value, index) => {
3309
- var _a2;
3310
- return keyLabelToOption(value, (_a2 = filter.valueLabels) == null ? void 0 : _a2[index]);
3311
- }) : []);
3578
+ const [uncommittedValue, setUncommittedValue] = React.useState(
3579
+ filter.values ? filter.values.map((value, index) => {
3580
+ var _a2;
3581
+ return keyLabelToOption(value, (_a2 = filter.valueLabels) == null ? void 0 : _a2[index]);
3582
+ }) : []
3583
+ );
3312
3584
  const isMultiValue = isMultiValueOperator(filter.operator);
3313
3585
  const keyValue = keyLabelToOption(filter.key, filter.keyLabel);
3314
3586
  const valueValue = keyLabelToOption(filter.value, (_a = filter.valueLabels) == null ? void 0 : _a[0]);
@@ -3331,10 +3603,12 @@ function AdHocFilterRenderer({ filter, model }) {
3331
3603
  setUncommittedValue([]);
3332
3604
  } else if (!isMultiValueOperator(existingOperator) && isMultiValueOperator(newOperator) && filter.value) {
3333
3605
  update.values = [filter.value];
3334
- setUncommittedValue([{
3335
- value: filter.value,
3336
- label: (_b2 = (_a2 = filter.valueLabels) == null ? void 0 : _a2[0]) != null ? _b2 : filter.value
3337
- }]);
3606
+ setUncommittedValue([
3607
+ {
3608
+ value: filter.value,
3609
+ label: (_b2 = (_a2 = filter.valueLabels) == null ? void 0 : _a2[0]) != null ? _b2 : filter.value
3610
+ }
3611
+ ]);
3338
3612
  }
3339
3613
  model._updateFilter(filter, update);
3340
3614
  };
@@ -3366,7 +3640,7 @@ function AdHocFilterRenderer({ filter, model }) {
3366
3640
  });
3367
3641
  }
3368
3642
  };
3369
- const valueSelect = /* @__PURE__ */ React__default["default"].createElement(ui.Select, __spreadValues$D({
3643
+ const valueSelect = /* @__PURE__ */ React__default["default"].createElement(ui.Select, __spreadValues$C({
3370
3644
  virtualized: true,
3371
3645
  allowCustomValue: true,
3372
3646
  isValidNewOption: (inputValue) => inputValue.trim().length > 0,
@@ -3498,7 +3772,7 @@ function AdHocFilterRenderer({ filter, model }) {
3498
3772
  onClick: () => model._removeFilter(filter)
3499
3773
  }));
3500
3774
  }
3501
- const getStyles$e = (theme) => ({
3775
+ const getStyles$d = (theme) => ({
3502
3776
  field: css.css({
3503
3777
  marginBottom: 0
3504
3778
  }),
@@ -3613,10 +3887,7 @@ function deserializeUrlToFilters(value) {
3613
3887
  }
3614
3888
  function toArray(filter) {
3615
3889
  var _a;
3616
- const result = [
3617
- toUrlCommaDelimitedString(filter.key, filter.keyLabel),
3618
- filter.operator
3619
- ];
3890
+ const result = [toUrlCommaDelimitedString(filter.key, filter.keyLabel), filter.operator];
3620
3891
  if (isMultiValueOperator(filter.operator)) {
3621
3892
  filter.values.forEach((value, index) => {
3622
3893
  var _a2;
@@ -3650,30 +3921,30 @@ function isFilter(filter) {
3650
3921
  return filter !== null && typeof filter.key === "string" && typeof filter.value === "string";
3651
3922
  }
3652
3923
 
3653
- var __defProp$C = Object.defineProperty;
3654
- var __getOwnPropSymbols$C = Object.getOwnPropertySymbols;
3655
- var __hasOwnProp$C = Object.prototype.hasOwnProperty;
3656
- var __propIsEnum$C = Object.prototype.propertyIsEnumerable;
3657
- var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3658
- var __spreadValues$C = (a, b) => {
3924
+ var __defProp$B = Object.defineProperty;
3925
+ var __getOwnPropSymbols$B = Object.getOwnPropertySymbols;
3926
+ var __hasOwnProp$B = Object.prototype.hasOwnProperty;
3927
+ var __propIsEnum$B = Object.prototype.propertyIsEnumerable;
3928
+ var __defNormalProp$B = (obj, key, value) => key in obj ? __defProp$B(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3929
+ var __spreadValues$B = (a, b) => {
3659
3930
  for (var prop in b || (b = {}))
3660
- if (__hasOwnProp$C.call(b, prop))
3661
- __defNormalProp$C(a, prop, b[prop]);
3662
- if (__getOwnPropSymbols$C)
3663
- for (var prop of __getOwnPropSymbols$C(b)) {
3664
- if (__propIsEnum$C.call(b, prop))
3665
- __defNormalProp$C(a, prop, b[prop]);
3931
+ if (__hasOwnProp$B.call(b, prop))
3932
+ __defNormalProp$B(a, prop, b[prop]);
3933
+ if (__getOwnPropSymbols$B)
3934
+ for (var prop of __getOwnPropSymbols$B(b)) {
3935
+ if (__propIsEnum$B.call(b, prop))
3936
+ __defNormalProp$B(a, prop, b[prop]);
3666
3937
  }
3667
3938
  return a;
3668
3939
  };
3669
3940
  var __objRest$3 = (source, exclude) => {
3670
3941
  var target = {};
3671
3942
  for (var prop in source)
3672
- if (__hasOwnProp$C.call(source, prop) && exclude.indexOf(prop) < 0)
3943
+ if (__hasOwnProp$B.call(source, prop) && exclude.indexOf(prop) < 0)
3673
3944
  target[prop] = source[prop];
3674
- if (source != null && __getOwnPropSymbols$C)
3675
- for (var prop of __getOwnPropSymbols$C(source)) {
3676
- if (exclude.indexOf(prop) < 0 && __propIsEnum$C.call(source, prop))
3945
+ if (source != null && __getOwnPropSymbols$B)
3946
+ for (var prop of __getOwnPropSymbols$B(source)) {
3947
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$B.call(source, prop))
3677
3948
  target[prop] = source[prop];
3678
3949
  }
3679
3950
  return target;
@@ -3681,9 +3952,9 @@ var __objRest$3 = (source, exclude) => {
3681
3952
  const DropdownItem = React.forwardRef(
3682
3953
  function DropdownItem2(_a, ref) {
3683
3954
  var _b = _a, { children, active, addGroupBottomBorder, isMultiValueEdit, checked } = _b, rest = __objRest$3(_b, ["children", "active", "addGroupBottomBorder", "isMultiValueEdit", "checked"]);
3684
- const styles = ui.useStyles2(getStyles$d);
3955
+ const styles = ui.useStyles2(getStyles$c);
3685
3956
  const id = React.useId();
3686
- return /* @__PURE__ */ React__default["default"].createElement("div", __spreadValues$C({
3957
+ return /* @__PURE__ */ React__default["default"].createElement("div", __spreadValues$B({
3687
3958
  ref,
3688
3959
  role: "option",
3689
3960
  id,
@@ -3699,7 +3970,7 @@ const DropdownItem = React.forwardRef(
3699
3970
  }) : null, children)));
3700
3971
  }
3701
3972
  );
3702
- const getStyles$d = (theme) => ({
3973
+ const getStyles$c = (theme) => ({
3703
3974
  option: css.css({
3704
3975
  label: "grafana-select-option",
3705
3976
  top: 0,
@@ -3770,7 +4041,7 @@ const OptionsErrorPlaceholder = ({ handleFetchOptions }) => {
3770
4041
  }, "An error has occurred fetching labels. Click to retry");
3771
4042
  };
3772
4043
  const MultiValueApplyButton = ({ onApply, floatingElement, maxOptionWidth, menuHeight }) => {
3773
- const styles = ui.useStyles2(getStyles$d);
4044
+ const styles = ui.useStyles2(getStyles$c);
3774
4045
  const floatingElementRect = floatingElement == null ? void 0 : floatingElement.getBoundingClientRect();
3775
4046
  return /* @__PURE__ */ React__default["default"].createElement("div", {
3776
4047
  className: styles.multiValueApplyWrapper,
@@ -3951,19 +4222,6 @@ const generatePlaceholder = (filter, filterInputType, isMultiValueEdit, isAlways
3951
4222
  }
3952
4223
  return filter[filterInputType] && !isAlwaysWip ? `${filter[filterInputType]}` : INPUT_PLACEHOLDER;
3953
4224
  };
3954
- const populateInputValueOnInputTypeSwitch = ({
3955
- populateInputOnEdit,
3956
- item,
3957
- filterInputType,
3958
- setInputValue,
3959
- filter
3960
- }) => {
3961
- if (populateInputOnEdit && !isMultiValueOperator(item.value || "") && nextInputTypeMap[filterInputType] === "value") {
3962
- setInputValue((filter == null ? void 0 : filter.value) || "");
3963
- } else {
3964
- setInputValue("");
3965
- }
3966
- };
3967
4225
 
3968
4226
  const MAX_MENU_HEIGHT = 300;
3969
4227
  const useFloatingInteractions = ({
@@ -4029,114 +4287,6 @@ const useFloatingInteractions = ({
4029
4287
  };
4030
4288
  };
4031
4289
 
4032
- var __defProp$B = Object.defineProperty;
4033
- var __defProps$p = Object.defineProperties;
4034
- var __getOwnPropDescs$p = Object.getOwnPropertyDescriptors;
4035
- var __getOwnPropSymbols$B = Object.getOwnPropertySymbols;
4036
- var __hasOwnProp$B = Object.prototype.hasOwnProperty;
4037
- var __propIsEnum$B = Object.prototype.propertyIsEnumerable;
4038
- var __defNormalProp$B = (obj, key, value) => key in obj ? __defProp$B(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4039
- var __spreadValues$B = (a, b) => {
4040
- for (var prop in b || (b = {}))
4041
- if (__hasOwnProp$B.call(b, prop))
4042
- __defNormalProp$B(a, prop, b[prop]);
4043
- if (__getOwnPropSymbols$B)
4044
- for (var prop of __getOwnPropSymbols$B(b)) {
4045
- if (__propIsEnum$B.call(b, prop))
4046
- __defNormalProp$B(a, prop, b[prop]);
4047
- }
4048
- return a;
4049
- };
4050
- var __spreadProps$p = (a, b) => __defProps$p(a, __getOwnPropDescs$p(b));
4051
- const MultiValuePill = ({
4052
- item,
4053
- handleRemoveMultiValue,
4054
- index,
4055
- handleEditMultiValuePill
4056
- }) => {
4057
- var _a, _b;
4058
- const styles = ui.useStyles2(getStyles$c);
4059
- const editMultiValuePill = React.useCallback(
4060
- (e) => {
4061
- e.stopPropagation();
4062
- e.preventDefault();
4063
- handleEditMultiValuePill(item);
4064
- },
4065
- [handleEditMultiValuePill, item]
4066
- );
4067
- const editMultiValuePillWithKeyboard = React.useCallback(
4068
- (e) => {
4069
- if (e.key === "Enter") {
4070
- editMultiValuePill(e);
4071
- }
4072
- },
4073
- [editMultiValuePill]
4074
- );
4075
- const removePillHandler = React.useCallback(
4076
- (e) => {
4077
- e.stopPropagation();
4078
- e.preventDefault();
4079
- handleRemoveMultiValue(item);
4080
- },
4081
- [handleRemoveMultiValue, item]
4082
- );
4083
- const removePillHandlerWithKeyboard = React.useCallback(
4084
- (e) => {
4085
- if (e.key === "Enter") {
4086
- removePillHandler(e);
4087
- }
4088
- },
4089
- [removePillHandler]
4090
- );
4091
- return /* @__PURE__ */ React__default["default"].createElement("div", {
4092
- className: css.cx(styles.basePill, styles.valuePill),
4093
- onClick: editMultiValuePill,
4094
- onKeyDown: editMultiValuePillWithKeyboard,
4095
- tabIndex: 0,
4096
- id: `${item.value}-${index}`
4097
- }, (_a = item.label) != null ? _a : item.value, /* @__PURE__ */ React__default["default"].createElement(ui.Button, {
4098
- onClick: removePillHandler,
4099
- onKeyDownCapture: removePillHandlerWithKeyboard,
4100
- fill: "text",
4101
- size: "sm",
4102
- variant: "secondary",
4103
- className: styles.removeButton,
4104
- tooltip: `Remove filter value - ${(_b = item.label) != null ? _b : item.value}`
4105
- }, /* @__PURE__ */ React__default["default"].createElement(ui.Icon, {
4106
- name: "times",
4107
- size: "md",
4108
- id: `${item.value}-${index}-close-icon`
4109
- })));
4110
- };
4111
- const getStyles$c = (theme) => ({
4112
- basePill: css.css(__spreadProps$p(__spreadValues$B({
4113
- display: "flex",
4114
- alignItems: "center",
4115
- background: theme.colors.action.disabledBackground,
4116
- border: `1px solid ${theme.colors.border.weak}`,
4117
- padding: theme.spacing(0.125, 1, 0.125, 1),
4118
- color: theme.colors.text.primary,
4119
- overflow: "hidden",
4120
- whiteSpace: "nowrap",
4121
- minHeight: theme.spacing(2.75)
4122
- }, theme.typography.bodySmall), {
4123
- cursor: "pointer"
4124
- })),
4125
- valuePill: css.css({
4126
- background: theme.colors.action.selected,
4127
- padding: theme.spacing(0.125, 0, 0.125, 1)
4128
- }),
4129
- removeButton: css.css({
4130
- marginInline: theme.spacing(0.5),
4131
- height: "100%",
4132
- padding: 0,
4133
- cursor: "pointer",
4134
- "&:hover": {
4135
- color: theme.colors.text.primary
4136
- }
4137
- })
4138
- });
4139
-
4140
4290
  var __defProp$A = Object.defineProperty;
4141
4291
  var __defProps$o = Object.defineProperties;
4142
4292
  var __getOwnPropDescs$o = Object.getOwnPropertyDescriptors;
@@ -4156,7 +4306,7 @@ var __spreadValues$A = (a, b) => {
4156
4306
  return a;
4157
4307
  };
4158
4308
  var __spreadProps$o = (a, b) => __defProps$o(a, __getOwnPropDescs$o(b));
4159
- const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model, isAlwaysWip, handleChangeViewMode, focusOnWipInputRef, populateInputOnEdit }, parentRef) {
4309
+ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model, isAlwaysWip, handleChangeViewMode, focusOnWipInputRef }, parentRef) {
4160
4310
  var _a, _b, _c;
4161
4311
  const [open, setOpen] = React.useState(false);
4162
4312
  const [options, setOptions] = React.useState([]);
@@ -4243,13 +4393,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4243
4393
  ]
4244
4394
  );
4245
4395
  const outsidePressIdsToIgnore = React.useMemo(() => {
4246
- return [
4247
- operatorIdentifier,
4248
- ...filterMultiValues.reduce(
4249
- (acc, item, i) => [...acc, `${item.value}-${i}`, `${item.value}-${i}-close-icon`],
4250
- []
4251
- )
4252
- ];
4396
+ return [operatorIdentifier, ...filterMultiValues.map((item, i) => `${item.value}-${i}`)];
4253
4397
  }, [operatorIdentifier, filterMultiValues]);
4254
4398
  const { refs, floatingStyles, context, getReferenceProps, getFloatingProps, getItemProps } = useFloatingInteractions({
4255
4399
  open,
@@ -4402,7 +4546,6 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4402
4546
  const selectedItem = filteredDropDownItems[activeIndex];
4403
4547
  if (multiValueEdit) {
4404
4548
  handleLocalMultiValueChange(selectedItem);
4405
- setInputValue("");
4406
4549
  } else {
4407
4550
  model._updateFilter(
4408
4551
  filter,
@@ -4413,13 +4556,6 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4413
4556
  setFilterMultiValues
4414
4557
  })
4415
4558
  );
4416
- populateInputValueOnInputTypeSwitch({
4417
- populateInputOnEdit,
4418
- item: selectedItem,
4419
- filterInputType,
4420
- setInputValue,
4421
- filter
4422
- });
4423
4559
  switchToNextInputType(
4424
4560
  filterInputType,
4425
4561
  setInputType,
@@ -4432,6 +4568,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4432
4568
  focusOnWipInputRef == null ? void 0 : focusOnWipInputRef();
4433
4569
  }
4434
4570
  }
4571
+ setInputValue("");
4435
4572
  }
4436
4573
  },
4437
4574
  [
@@ -4441,23 +4578,12 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4441
4578
  model,
4442
4579
  filter,
4443
4580
  filterInputType,
4444
- populateInputOnEdit,
4445
4581
  handleChangeViewMode,
4446
4582
  refs.domReference,
4447
4583
  isLastFilter,
4448
4584
  focusOnWipInputRef
4449
4585
  ]
4450
4586
  );
4451
- const handleEditMultiValuePill = React.useCallback(
4452
- (value) => {
4453
- var _a2;
4454
- const valueLabel = value.label || value.value;
4455
- setFilterMultiValues((prev) => prev.filter((item) => item.value !== value.value));
4456
- setInputValue(valueLabel);
4457
- (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
4458
- },
4459
- [refs.domReference]
4460
- );
4461
4587
  React.useEffect(() => {
4462
4588
  if (open) {
4463
4589
  handleFetchOptions(filterInputType);
@@ -4466,6 +4592,8 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4466
4592
  React.useEffect(() => {
4467
4593
  var _a2, _b2;
4468
4594
  if (!isAlwaysWip) {
4595
+ setInputType("value");
4596
+ setInputValue("");
4469
4597
  if (hasMultiValueOperator && ((_a2 = filter == null ? void 0 : filter.values) == null ? void 0 : _a2.length)) {
4470
4598
  const multiValueOptions = filter.values.reduce(
4471
4599
  (acc, value, i) => {
@@ -4482,9 +4610,6 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4482
4610
  );
4483
4611
  setFilterMultiValues(multiValueOptions);
4484
4612
  }
4485
- if (!hasMultiValueOperator && populateInputOnEdit) {
4486
- setInputValue((filter == null ? void 0 : filter.value) || "");
4487
- }
4488
4613
  (_b2 = refs.domReference.current) == null ? void 0 : _b2.focus();
4489
4614
  }
4490
4615
  }, []);
@@ -4514,13 +4639,11 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4514
4639
  tabIndex: 0,
4515
4640
  onClick: (event) => {
4516
4641
  event.stopPropagation();
4517
- setInputValue("");
4518
4642
  switchInputType("operator", setInputType, void 0, refs.domReference.current);
4519
4643
  },
4520
4644
  onKeyDown: (event) => {
4521
4645
  handleShiftTabInput(event, hasMultiValueOperator);
4522
4646
  if (event.key === "Enter") {
4523
- setInputValue("");
4524
4647
  switchInputType("operator", setInputType, void 0, refs.domReference.current);
4525
4648
  }
4526
4649
  }
@@ -4530,8 +4653,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4530
4653
  key: `${item.value}-${i}`,
4531
4654
  item,
4532
4655
  index: i,
4533
- handleRemoveMultiValue,
4534
- handleEditMultiValuePill
4656
+ handleRemoveMultiValue
4535
4657
  })) : null) : null, /* @__PURE__ */ React__default["default"].createElement("input", __spreadProps$o(__spreadValues$A({}, getReferenceProps({
4536
4658
  ref: refs.setReference,
4537
4659
  onChange,
@@ -4618,7 +4740,6 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4618
4740
  event.preventDefault();
4619
4741
  event.stopPropagation();
4620
4742
  handleLocalMultiValueChange(item);
4621
- setInputValue("");
4622
4743
  (_a3 = refs.domReference.current) == null ? void 0 : _a3.focus();
4623
4744
  } else {
4624
4745
  model._updateFilter(
@@ -4630,13 +4751,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4630
4751
  setFilterMultiValues
4631
4752
  })
4632
4753
  );
4633
- populateInputValueOnInputTypeSwitch({
4634
- populateInputOnEdit,
4635
- item,
4636
- filterInputType,
4637
- setInputValue,
4638
- filter
4639
- });
4754
+ setInputValue("");
4640
4755
  switchToNextInputType(
4641
4756
  filterInputType,
4642
4757
  setInputType,
@@ -4669,6 +4784,35 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4669
4784
  menuHeight: Math.min(rowVirtualizer.getTotalSize(), MAX_MENU_HEIGHT)
4670
4785
  }) : null))));
4671
4786
  });
4787
+ const MultiValuePill = ({ item, handleRemoveMultiValue, index }) => {
4788
+ var _a, _b;
4789
+ const styles = ui.useStyles2(getStyles$b);
4790
+ return /* @__PURE__ */ React__default["default"].createElement("div", {
4791
+ className: css.cx(styles.basePill, styles.valuePill)
4792
+ }, /* @__PURE__ */ React__default["default"].createElement("span", null, " ", (_a = item.label) != null ? _a : item.value), /* @__PURE__ */ React__default["default"].createElement(ui.Button, {
4793
+ onClick: (e) => {
4794
+ e.stopPropagation();
4795
+ e.preventDefault();
4796
+ handleRemoveMultiValue(item);
4797
+ },
4798
+ onKeyDownCapture: (e) => {
4799
+ if (e.key === "Enter") {
4800
+ e.preventDefault();
4801
+ e.stopPropagation();
4802
+ handleRemoveMultiValue(item);
4803
+ }
4804
+ },
4805
+ fill: "text",
4806
+ size: "sm",
4807
+ variant: "secondary",
4808
+ className: styles.removeButton,
4809
+ tooltip: `Remove filter value - ${(_b = item.label) != null ? _b : item.value}`
4810
+ }, /* @__PURE__ */ React__default["default"].createElement(ui.Icon, {
4811
+ name: "times",
4812
+ size: "md",
4813
+ id: `${item.value}-${index}`
4814
+ })));
4815
+ };
4672
4816
  const getStyles$b = (theme) => ({
4673
4817
  comboboxWrapper: css.css({
4674
4818
  display: "flex",
@@ -4701,6 +4845,10 @@ const getStyles$b = (theme) => ({
4701
4845
  background: theme.colors.action.hover
4702
4846
  }
4703
4847
  }),
4848
+ valuePill: css.css({
4849
+ background: theme.colors.action.selected,
4850
+ padding: theme.spacing(0.125, 0, 0.125, 1)
4851
+ }),
4704
4852
  dropdownWrapper: css.css({
4705
4853
  backgroundColor: theme.colors.background.primary,
4706
4854
  color: theme.colors.text.primary,
@@ -4733,10 +4881,25 @@ const getStyles$b = (theme) => ({
4733
4881
  borderTop: `1px solid ${theme.colors.border.weak}`
4734
4882
  }
4735
4883
  }),
4884
+ removeButton: css.css({
4885
+ marginInline: theme.spacing(0.5),
4886
+ height: "100%",
4887
+ padding: 0,
4888
+ cursor: "pointer",
4889
+ "&:hover": {
4890
+ color: theme.colors.text.primary
4891
+ }
4892
+ }),
4736
4893
  descriptionText: css.css(__spreadProps$o(__spreadValues$A({}, theme.typography.bodySmall), {
4737
4894
  color: theme.colors.text.secondary,
4738
4895
  paddingTop: theme.spacing(0.5)
4739
- }))
4896
+ })),
4897
+ multiValueApply: css.css({
4898
+ position: "absolute",
4899
+ top: 0,
4900
+ left: 0,
4901
+ display: "flex"
4902
+ })
4740
4903
  });
4741
4904
 
4742
4905
  var __defProp$z = Object.defineProperty;
@@ -4764,7 +4927,6 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
4764
4927
  const [viewMode, setViewMode] = React.useState(true);
4765
4928
  const [shouldFocusOnPillWrapper, setShouldFocusOnPillWrapper] = React.useState(false);
4766
4929
  const pillWrapperRef = React.useRef(null);
4767
- const [populateInputOnEdit, setPopulateInputOnEdit] = React.useState(false);
4768
4930
  const keyLabel = (_a = filter.keyLabel) != null ? _a : filter.key;
4769
4931
  const valueLabel = ((_b = filter.valueLabels) == null ? void 0 : _b.join(", ")) || ((_c = filter.values) == null ? void 0 : _c.join(", ")) || filter.value;
4770
4932
  const handleChangeViewMode = React.useCallback(
@@ -4791,25 +4953,15 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
4791
4953
  model._updateFilter(filter, { forceEdit: void 0 });
4792
4954
  }
4793
4955
  }, [filter, model, viewMode]);
4794
- React.useEffect(() => {
4795
- if (populateInputOnEdit && viewMode) {
4796
- setPopulateInputOnEdit(false);
4797
- }
4798
- }, [viewMode]);
4799
4956
  if (viewMode) {
4800
4957
  const pillText = /* @__PURE__ */ React__default["default"].createElement("span", {
4801
4958
  className: styles.pillText
4802
4959
  }, keyLabel, " ", filter.operator, " ", valueLabel);
4803
4960
  return /* @__PURE__ */ React__default["default"].createElement("div", {
4804
4961
  className: css.cx(styles.combinedFilterPill, { [styles.readOnlyCombinedFilter]: readOnly }),
4805
- onClick: (e) => {
4806
- e.stopPropagation();
4807
- setPopulateInputOnEdit(true);
4808
- handleChangeViewMode();
4809
- },
4962
+ onClick: handleChangeViewMode,
4810
4963
  onKeyDown: (e) => {
4811
4964
  if (e.key === "Enter") {
4812
- setPopulateInputOnEdit(true);
4813
4965
  handleChangeViewMode();
4814
4966
  }
4815
4967
  },
@@ -4846,8 +4998,7 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
4846
4998
  filter,
4847
4999
  model,
4848
5000
  handleChangeViewMode,
4849
- focusOnWipInputRef,
4850
- populateInputOnEdit
5001
+ focusOnWipInputRef
4851
5002
  });
4852
5003
  }
4853
5004
  const getStyles$a = (theme) => ({
@@ -5343,9 +5494,7 @@ class SceneQueryRunner extends SceneObjectBase {
5343
5494
  })
5344
5495
  );
5345
5496
  }
5346
- this.subscribeToTimeRangeChanges(
5347
- timeRange
5348
- );
5497
+ this.subscribeToTimeRangeChanges(timeRange);
5349
5498
  if (this.shouldRunQueriesOnActivate()) {
5350
5499
  this.runQueries();
5351
5500
  }
@@ -6597,30 +6746,6 @@ function findDescendents(scene, descendentType) {
6597
6746
  const targetScenes = findAllObjects(scene, isDescendentType);
6598
6747
  return targetScenes.filter(isDescendentType);
6599
6748
  }
6600
- function getQueryController(sceneObject) {
6601
- let parent = sceneObject;
6602
- while (parent) {
6603
- if (parent.state.$behaviors) {
6604
- for (const behavior of parent.state.$behaviors) {
6605
- if (isQueryController(behavior)) {
6606
- return behavior;
6607
- }
6608
- }
6609
- }
6610
- parent = parent.parent;
6611
- }
6612
- return void 0;
6613
- }
6614
- function getUrlSyncManager(sceneObject) {
6615
- let parent = sceneObject;
6616
- while (parent) {
6617
- if ("urlSyncManager" in parent.state) {
6618
- return parent.state.urlSyncManager;
6619
- }
6620
- parent = parent.parent;
6621
- }
6622
- return void 0;
6623
- }
6624
6749
 
6625
6750
  const sceneGraph = {
6626
6751
  getVariables,
@@ -6636,9 +6761,8 @@ const sceneGraph = {
6636
6761
  findObject,
6637
6762
  findAllObjects,
6638
6763
  getAncestor,
6639
- findDescendents,
6640
6764
  getQueryController,
6641
- getUrlSyncManager
6765
+ findDescendents
6642
6766
  };
6643
6767
 
6644
6768
  class UniqueUrlKeyMapper {
@@ -7510,7 +7634,13 @@ class VizPanel extends SceneObjectBase {
7510
7634
  } else {
7511
7635
  const { importPanelPlugin } = runtime.getPluginImportUtils();
7512
7636
  try {
7513
- const result = await importPanelPlugin(pluginId);
7637
+ const panelPromise = importPanelPlugin(pluginId);
7638
+ const queryControler = sceneGraph.getQueryController(this);
7639
+ if (queryControler && queryControler.state.enableProfiling) {
7640
+ wrapPromiseInStateObservable(panelPromise).pipe(registerQueryWithController({ type: "plugin", origin: this })).subscribe(() => {
7641
+ });
7642
+ }
7643
+ const result = await panelPromise;
7514
7644
  this._pluginLoaded(result, overwriteOptions, overwriteFieldConfig, isAfterPluginChange);
7515
7645
  } catch (err) {
7516
7646
  this._pluginLoaded(getPanelPluginNotFound(pluginId));
@@ -7579,11 +7709,7 @@ class VizPanel extends SceneObjectBase {
7579
7709
  }
7580
7710
  async changePluginType(pluginId, newOptions, newFieldConfig) {
7581
7711
  var _a, _b;
7582
- const {
7583
- options: prevOptions,
7584
- fieldConfig: prevFieldConfig,
7585
- pluginId: prevPluginId
7586
- } = this.state;
7712
+ const { options: prevOptions, fieldConfig: prevFieldConfig, pluginId: prevPluginId } = this.state;
7587
7713
  this._dataWithFieldConfig = void 0;
7588
7714
  const isAfterPluginChange = this.state.pluginId !== pluginId;
7589
7715
  await this._loadPlugin(pluginId, newOptions != null ? newOptions : {}, newFieldConfig, isAfterPluginChange);
@@ -11057,6 +11183,7 @@ class SceneRefreshPicker extends SceneObjectBase {
11057
11183
  this._autoRefreshBlocked = false;
11058
11184
  this.onRefresh = () => {
11059
11185
  const queryController = sceneGraph.getQueryController(this);
11186
+ queryController == null ? void 0 : queryController.startProfile(this);
11060
11187
  if (queryController == null ? void 0 : queryController.state.isRunning) {
11061
11188
  queryController.cancelAll();
11062
11189
  return;
@@ -11185,7 +11312,9 @@ function SceneRefreshPickerRenderer({ model }) {
11185
11312
  tooltip,
11186
11313
  width,
11187
11314
  text,
11188
- onRefresh: model.onRefresh,
11315
+ onRefresh: () => {
11316
+ model.onRefresh();
11317
+ },
11189
11318
  primary,
11190
11319
  onIntervalChanged: model.onIntervalChanged,
11191
11320
  isLoading: isRunning,