@perses-dev/core 0.0.0-snapshot-panel-extra-content-3-17f9c42 → 0.0.0-snapshot-scatterplot-fix-imports-95e1b59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/dist/cjs/constants/dashboard-defaults.js +6 -2
  2. package/dist/cjs/constants/dialog.js +3 -1
  3. package/dist/cjs/constants/index.js +11 -9
  4. package/dist/cjs/index.js +12 -10
  5. package/dist/cjs/model/calculations.js +61 -51
  6. package/dist/cjs/model/ephemeraldashboard.js +16 -0
  7. package/dist/cjs/model/http-proxy.js +16 -0
  8. package/dist/cjs/model/index.js +35 -26
  9. package/dist/cjs/model/kind.js +39 -0
  10. package/dist/cjs/model/legend.js +39 -19
  11. package/dist/cjs/model/resource.js +9 -0
  12. package/dist/cjs/model/rolebindings.js +16 -0
  13. package/dist/cjs/model/roles.js +60 -0
  14. package/dist/cjs/model/secrets.js +16 -0
  15. package/dist/cjs/model/time-series-queries.js +3 -1
  16. package/dist/cjs/model/time.js +151 -65
  17. package/dist/cjs/model/trace-data.js +16 -0
  18. package/dist/cjs/model/units/bytes.js +37 -25
  19. package/dist/cjs/model/units/constants.js +3 -1
  20. package/dist/cjs/model/units/decimal.js +22 -16
  21. package/dist/cjs/model/units/index.js +13 -11
  22. package/dist/cjs/model/units/percent.js +26 -19
  23. package/dist/cjs/model/units/throughput.js +113 -0
  24. package/dist/cjs/model/units/time.js +99 -38
  25. package/dist/cjs/model/units/types.js +5 -2
  26. package/dist/cjs/model/units/units.js +81 -45
  27. package/dist/cjs/model/units/utils.js +13 -7
  28. package/dist/cjs/model/variables.js +16 -3
  29. package/dist/cjs/utils/event.js +3 -1
  30. package/dist/cjs/utils/fetch.js +32 -7
  31. package/dist/cjs/utils/index.js +17 -14
  32. package/dist/cjs/utils/is-empty-object.js +3 -1
  33. package/dist/cjs/utils/mathjs.js +4 -2
  34. package/dist/cjs/utils/memo.js +10 -6
  35. package/dist/cjs/utils/panel-refs.js +9 -3
  36. package/dist/cjs/utils/text.js +33 -21
  37. package/dist/cjs/utils/time-series-data.js +21 -11
  38. package/dist/cjs/utils/types.js +16 -0
  39. package/dist/constants/dashboard-defaults.js.map +1 -1
  40. package/dist/constants/dialog.js.map +1 -1
  41. package/dist/constants/index.js.map +1 -1
  42. package/dist/index.js.map +1 -1
  43. package/dist/model/calculations.d.ts +12 -12
  44. package/dist/model/calculations.d.ts.map +1 -1
  45. package/dist/model/calculations.js +46 -46
  46. package/dist/model/calculations.js.map +1 -1
  47. package/dist/model/dashboard.js.map +1 -1
  48. package/dist/model/datasource.d.ts +17 -3
  49. package/dist/model/datasource.d.ts.map +1 -1
  50. package/dist/model/datasource.js +3 -1
  51. package/dist/model/datasource.js.map +1 -1
  52. package/dist/model/definitions.d.ts +1 -1
  53. package/dist/model/definitions.d.ts.map +1 -1
  54. package/dist/model/definitions.js +3 -0
  55. package/dist/model/definitions.js.map +1 -1
  56. package/dist/model/display.d.ts +1 -1
  57. package/dist/model/display.d.ts.map +1 -1
  58. package/dist/model/display.js.map +1 -1
  59. package/dist/model/ephemeraldashboard.d.ts +15 -0
  60. package/dist/model/ephemeraldashboard.d.ts.map +1 -0
  61. package/dist/model/ephemeraldashboard.js +15 -0
  62. package/dist/model/ephemeraldashboard.js.map +1 -0
  63. package/dist/model/http-proxy.d.ts +16 -0
  64. package/dist/model/http-proxy.d.ts.map +1 -0
  65. package/dist/model/http-proxy.js +15 -0
  66. package/dist/model/http-proxy.js.map +1 -0
  67. package/dist/model/http.d.ts +1 -1
  68. package/dist/model/http.d.ts.map +1 -1
  69. package/dist/model/index.d.ts +7 -0
  70. package/dist/model/index.d.ts.map +1 -1
  71. package/dist/model/index.js +7 -0
  72. package/dist/model/index.js.map +1 -1
  73. package/dist/model/kind.d.ts +3 -0
  74. package/dist/model/kind.d.ts.map +1 -0
  75. package/dist/model/kind.js +31 -0
  76. package/dist/model/kind.js.map +1 -0
  77. package/dist/model/layout.d.ts +1 -1
  78. package/dist/model/layout.d.ts.map +1 -1
  79. package/dist/model/layout.js.map +1 -1
  80. package/dist/model/legend.d.ts +9 -9
  81. package/dist/model/legend.d.ts.map +1 -1
  82. package/dist/model/legend.js +9 -9
  83. package/dist/model/legend.js.map +1 -1
  84. package/dist/model/panels.d.ts +5 -2
  85. package/dist/model/panels.d.ts.map +1 -1
  86. package/dist/model/panels.js +3 -1
  87. package/dist/model/panels.js.map +1 -1
  88. package/dist/model/project.js.map +1 -1
  89. package/dist/model/query.d.ts +15 -2
  90. package/dist/model/query.d.ts.map +1 -1
  91. package/dist/model/query.js +4 -1
  92. package/dist/model/query.js.map +1 -1
  93. package/dist/model/resource.d.ts +3 -2
  94. package/dist/model/resource.d.ts.map +1 -1
  95. package/dist/model/resource.js +3 -1
  96. package/dist/model/resource.js.map +1 -1
  97. package/dist/model/rolebindings.d.ts +27 -0
  98. package/dist/model/rolebindings.d.ts.map +1 -0
  99. package/dist/model/rolebindings.js +15 -0
  100. package/dist/model/rolebindings.js.map +1 -0
  101. package/dist/model/roles.d.ts +32 -0
  102. package/dist/model/roles.d.ts.map +1 -0
  103. package/dist/model/roles.js +41 -0
  104. package/dist/model/roles.js.map +1 -0
  105. package/dist/model/secrets.d.ts +44 -0
  106. package/dist/model/secrets.d.ts.map +1 -0
  107. package/dist/model/secrets.js +15 -0
  108. package/dist/model/secrets.js.map +1 -0
  109. package/dist/model/thresholds.d.ts +2 -2
  110. package/dist/model/thresholds.d.ts.map +1 -1
  111. package/dist/model/thresholds.js.map +1 -1
  112. package/dist/model/time-series-data.js.map +1 -1
  113. package/dist/model/time-series-queries.d.ts +3 -3
  114. package/dist/model/time-series-queries.d.ts.map +1 -1
  115. package/dist/model/time-series-queries.js.map +1 -1
  116. package/dist/model/time.d.ts +15 -11
  117. package/dist/model/time.d.ts.map +1 -1
  118. package/dist/model/time.js +117 -57
  119. package/dist/model/time.js.map +1 -1
  120. package/dist/model/trace-data.d.ts +20 -0
  121. package/dist/model/trace-data.d.ts.map +1 -0
  122. package/dist/model/trace-data.js +18 -0
  123. package/dist/model/trace-data.js.map +1 -0
  124. package/dist/model/units/bytes.d.ts +8 -8
  125. package/dist/model/units/bytes.d.ts.map +1 -1
  126. package/dist/model/units/bytes.js +27 -21
  127. package/dist/model/units/bytes.js.map +1 -1
  128. package/dist/model/units/constants.js.map +1 -1
  129. package/dist/model/units/decimal.d.ts +8 -8
  130. package/dist/model/units/decimal.d.ts.map +1 -1
  131. package/dist/model/units/decimal.js +14 -14
  132. package/dist/model/units/decimal.js.map +1 -1
  133. package/dist/model/units/index.js.map +1 -1
  134. package/dist/model/units/percent.d.ts +7 -7
  135. package/dist/model/units/percent.d.ts.map +1 -1
  136. package/dist/model/units/percent.js +17 -16
  137. package/dist/model/units/percent.js.map +1 -1
  138. package/dist/model/units/throughput.d.ts +13 -0
  139. package/dist/model/units/throughput.d.ts.map +1 -0
  140. package/dist/model/units/throughput.js +94 -0
  141. package/dist/model/units/throughput.js.map +1 -0
  142. package/dist/model/units/time.d.ts +15 -15
  143. package/dist/model/units/time.d.ts.map +1 -1
  144. package/dist/model/units/time.js +87 -34
  145. package/dist/model/units/time.js.map +1 -1
  146. package/dist/model/units/types.d.ts +18 -9
  147. package/dist/model/units/types.d.ts.map +1 -1
  148. package/dist/model/units/types.js +2 -1
  149. package/dist/model/units/types.js.map +1 -1
  150. package/dist/model/units/units.d.ts +50 -31
  151. package/dist/model/units/units.d.ts.map +1 -1
  152. package/dist/model/units/units.js +52 -37
  153. package/dist/model/units/units.js.map +1 -1
  154. package/dist/model/units/utils.d.ts +2 -2
  155. package/dist/model/units/utils.d.ts.map +1 -1
  156. package/dist/model/units/utils.js +4 -4
  157. package/dist/model/units/utils.js.map +1 -1
  158. package/dist/model/variables.d.ts +28 -9
  159. package/dist/model/variables.d.ts.map +1 -1
  160. package/dist/model/variables.js +3 -0
  161. package/dist/model/variables.js.map +1 -1
  162. package/dist/test/setup-tests.js.map +1 -1
  163. package/dist/utils/event.js.map +1 -1
  164. package/dist/utils/fetch.d.ts +3 -1
  165. package/dist/utils/fetch.d.ts.map +1 -1
  166. package/dist/utils/fetch.js +21 -4
  167. package/dist/utils/fetch.js.map +1 -1
  168. package/dist/utils/index.d.ts +2 -1
  169. package/dist/utils/index.d.ts.map +1 -1
  170. package/dist/utils/index.js +2 -1
  171. package/dist/utils/index.js.map +1 -1
  172. package/dist/utils/is-empty-object.js.map +1 -1
  173. package/dist/utils/mathjs.js +1 -1
  174. package/dist/utils/mathjs.js.map +1 -1
  175. package/dist/utils/memo.js +2 -2
  176. package/dist/utils/memo.js.map +1 -1
  177. package/dist/utils/panel-refs.js.map +1 -1
  178. package/dist/utils/text.d.ts +7 -7
  179. package/dist/utils/text.d.ts.map +1 -1
  180. package/dist/utils/text.js +17 -17
  181. package/dist/utils/text.js.map +1 -1
  182. package/dist/utils/time-series-data.d.ts +1 -1
  183. package/dist/utils/time-series-data.d.ts.map +1 -1
  184. package/dist/utils/time-series-data.js +7 -7
  185. package/dist/utils/time-series-data.js.map +1 -1
  186. package/dist/utils/types.d.ts +2 -0
  187. package/dist/utils/types.d.ts.map +1 -0
  188. package/dist/utils/types.js +15 -0
  189. package/dist/utils/types.js.map +1 -0
  190. package/package.json +5 -4
@@ -16,10 +16,12 @@ Object.defineProperty(exports, "__esModule", {
16
16
  });
17
17
  Object.defineProperty(exports, "gcd", {
18
18
  enumerable: true,
19
- get: ()=>gcd
19
+ get: function() {
20
+ return gcd;
21
+ }
20
22
  });
21
23
  const _mathjs = require("mathjs");
22
24
  // This ensures we get a minimal mathjs bundle for just what we need (see https://mathjs.org/docs/custom_bundling.html)
23
- const { gcd } = (0, _mathjs.create)({
25
+ const { gcd } = (0, _mathjs.create)({
24
26
  gcdDependencies: _mathjs.gcdDependencies
25
27
  });
@@ -21,12 +21,16 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- useMemoized: ()=>useMemoized,
25
- useDeepMemo: ()=>useDeepMemo
24
+ useDeepMemo: function() {
25
+ return useDeepMemo;
26
+ },
27
+ useMemoized: function() {
28
+ return useMemoized;
29
+ }
26
30
  });
27
31
  const _react = require("react");
28
- const _isEqual = /*#__PURE__*/ _interopRequireDefault(require("lodash/isEqual"));
29
- function _interopRequireDefault(obj) {
32
+ const _isEqual = /*#__PURE__*/ _interop_require_default(require("lodash/isEqual"));
33
+ function _interop_require_default(obj) {
30
34
  return obj && obj.__esModule ? obj : {
31
35
  default: obj
32
36
  };
@@ -35,8 +39,8 @@ function useMemoized(factory, deps) {
35
39
  const ref = (0, _react.useRef)();
36
40
  let areEqual = true;
37
41
  for(let i = 0; i < deps.length; i++){
38
- var ref1;
39
- if (((ref1 = ref.current) === null || ref1 === void 0 ? void 0 : ref1.deps[i]) !== deps[i]) {
42
+ var _ref_current;
43
+ if (((_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.deps[i]) !== deps[i]) {
40
44
  areEqual = false;
41
45
  break;
42
46
  }
@@ -21,9 +21,15 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- resolvePanelRef: ()=>resolvePanelRef,
25
- getPanelKeyFromRef: ()=>getPanelKeyFromRef,
26
- createPanelRef: ()=>createPanelRef
24
+ createPanelRef: function() {
25
+ return createPanelRef;
26
+ },
27
+ getPanelKeyFromRef: function() {
28
+ return getPanelKeyFromRef;
29
+ },
30
+ resolvePanelRef: function() {
31
+ return resolvePanelRef;
32
+ }
27
33
  });
28
34
  function resolvePanelRef(spec, panelRef) {
29
35
  const panelsKey = getPanelKeyFromRef(panelRef);
@@ -21,45 +21,57 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- getDashboardDisplayName: ()=>getDashboardDisplayName,
25
- getVariableDisplayName: ()=>getVariableDisplayName,
26
- getDatasourceDisplayName: ()=>getDatasourceDisplayName,
27
- getDashboardExtendedDisplayName: ()=>getDashboardExtendedDisplayName,
28
- getVariableExtendedDisplayName: ()=>getVariableExtendedDisplayName,
29
- getDatasourceExtendedDisplayName: ()=>getDatasourceExtendedDisplayName
24
+ getDashboardDisplayName: function() {
25
+ return getDashboardDisplayName;
26
+ },
27
+ getDashboardExtendedDisplayName: function() {
28
+ return getDashboardExtendedDisplayName;
29
+ },
30
+ getDatasourceDisplayName: function() {
31
+ return getDatasourceDisplayName;
32
+ },
33
+ getDatasourceExtendedDisplayName: function() {
34
+ return getDatasourceExtendedDisplayName;
35
+ },
36
+ getVariableDisplayName: function() {
37
+ return getVariableDisplayName;
38
+ },
39
+ getVariableExtendedDisplayName: function() {
40
+ return getVariableExtendedDisplayName;
41
+ }
30
42
  });
31
43
  function getDashboardDisplayName(dashboard) {
32
- var ref;
33
- var ref1;
34
- return (ref1 = (ref = dashboard.spec.display) === null || ref === void 0 ? void 0 : ref.name) !== null && ref1 !== void 0 ? ref1 : dashboard.metadata.name;
44
+ var _dashboard_spec_display;
45
+ var _dashboard_spec_display_name;
46
+ return (_dashboard_spec_display_name = (_dashboard_spec_display = dashboard.spec.display) === null || _dashboard_spec_display === void 0 ? void 0 : _dashboard_spec_display.name) !== null && _dashboard_spec_display_name !== void 0 ? _dashboard_spec_display_name : dashboard.metadata.name;
35
47
  }
36
48
  function getVariableDisplayName(variable) {
37
- var ref;
38
- var ref1;
39
- return (ref1 = (ref = variable.spec.spec.display) === null || ref === void 0 ? void 0 : ref.name) !== null && ref1 !== void 0 ? ref1 : variable.metadata.name;
49
+ var _variable_spec_spec_display;
50
+ var _variable_spec_spec_display_name;
51
+ return (_variable_spec_spec_display_name = (_variable_spec_spec_display = variable.spec.spec.display) === null || _variable_spec_spec_display === void 0 ? void 0 : _variable_spec_spec_display.name) !== null && _variable_spec_spec_display_name !== void 0 ? _variable_spec_spec_display_name : variable.metadata.name;
40
52
  }
41
53
  function getDatasourceDisplayName(datasource) {
42
- var ref;
43
- return ((ref = datasource.spec.display) === null || ref === void 0 ? void 0 : ref.name) || datasource.metadata.name;
54
+ var _datasource_spec_display;
55
+ return ((_datasource_spec_display = datasource.spec.display) === null || _datasource_spec_display === void 0 ? void 0 : _datasource_spec_display.name) || datasource.metadata.name;
44
56
  }
45
57
  function getDashboardExtendedDisplayName(dashboard) {
46
- var ref;
47
- if ((ref = dashboard.spec.display) === null || ref === void 0 ? void 0 : ref.name) {
58
+ var _dashboard_spec_display;
59
+ if ((_dashboard_spec_display = dashboard.spec.display) === null || _dashboard_spec_display === void 0 ? void 0 : _dashboard_spec_display.name) {
48
60
  return `${dashboard.spec.display.name} (Name: ${dashboard.metadata.name})`;
49
61
  }
50
62
  return dashboard.metadata.name;
51
63
  }
52
64
  function getVariableExtendedDisplayName(variable) {
53
- var ref;
54
- if ((ref = variable.spec.spec.display) === null || ref === void 0 ? void 0 : ref.name) {
65
+ var _variable_spec_spec_display;
66
+ if ((_variable_spec_spec_display = variable.spec.spec.display) === null || _variable_spec_spec_display === void 0 ? void 0 : _variable_spec_spec_display.name) {
55
67
  return `${variable.spec.spec.display.name} (Name: ${variable.metadata.name})`;
56
68
  }
57
69
  return variable.metadata.name;
58
70
  }
59
71
  function getDatasourceExtendedDisplayName(datasource) {
60
- var ref;
61
- if ((ref = datasource.spec.display) === null || ref === void 0 ? void 0 : ref.name) {
62
- return `${datasource.spec.display.name} (ID: ${datasource.metadata.name})`;
72
+ var _datasource_spec_display;
73
+ if ((_datasource_spec_display = datasource.spec.display) === null || _datasource_spec_display === void 0 ? void 0 : _datasource_spec_display.name) {
74
+ return `${datasource.spec.display.name} (Name: ${datasource.metadata.name})`;
63
75
  }
64
76
  return datasource.metadata.name;
65
77
  }
@@ -21,11 +21,21 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- MIN_STEP_INTERVAL_MS: ()=>MIN_STEP_INTERVAL_MS,
25
- getXValues: ()=>getXValues,
26
- getTimeSeriesValues: ()=>getTimeSeriesValues,
27
- getYValues: ()=>getYValues,
28
- getCommonTimeScale: ()=>getCommonTimeScale
24
+ MIN_STEP_INTERVAL_MS: function() {
25
+ return MIN_STEP_INTERVAL_MS;
26
+ },
27
+ getCommonTimeScale: function() {
28
+ return getCommonTimeScale;
29
+ },
30
+ getTimeSeriesValues: function() {
31
+ return getTimeSeriesValues;
32
+ },
33
+ getXValues: function() {
34
+ return getXValues;
35
+ },
36
+ getYValues: function() {
37
+ return getYValues;
38
+ }
29
39
  });
30
40
  const _mathjs = require("./mathjs");
31
41
  const MIN_STEP_INTERVAL_MS = 10;
@@ -154,13 +164,13 @@ function getCommonTimeScale(seriesData) {
154
164
  const calculatedStepMs = (0, _mathjs.gcd)(...steps);
155
165
  stepMs = calculatedStepMs < MIN_STEP_INTERVAL_MS ? MIN_STEP_INTERVAL_MS : calculatedStepMs;
156
166
  }
157
- const startMs1 = timeRange.start.valueOf();
158
- const endMs1 = timeRange.end.valueOf();
159
- const rangeMs1 = endMs1 - startMs1;
167
+ const startMs = timeRange.start.valueOf();
168
+ const endMs = timeRange.end.valueOf();
169
+ const rangeMs = endMs - startMs;
160
170
  return {
161
- startMs: startMs1,
162
- endMs: endMs1,
171
+ startMs,
172
+ endMs,
163
173
  stepMs,
164
- rangeMs: rangeMs1
174
+ rangeMs
165
175
  };
166
176
  }
@@ -0,0 +1,16 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/constants/dashboard-defaults.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DurationString } from '../model';\n\nexport const DEFAULT_DASHBOARD_DURATION: DurationString = '1h';\n\nexport const DEFAULT_REFRESH_INTERVAL: DurationString = '0s';\n"],"names":["DEFAULT_DASHBOARD_DURATION","DEFAULT_REFRESH_INTERVAL"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,OAAO,MAAMA,0BAA0B,GAAmB,IAAI,CAAC;AAE/D,OAAO,MAAMC,wBAAwB,GAAmB,IAAI,CAAC"}
1
+ {"version":3,"sources":["../../src/constants/dashboard-defaults.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DurationString } from '../model';\n\nexport const DEFAULT_DASHBOARD_DURATION: DurationString = '1h';\n\nexport const DEFAULT_REFRESH_INTERVAL: DurationString = '0s';\n"],"names":["DEFAULT_DASHBOARD_DURATION","DEFAULT_REFRESH_INTERVAL"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,OAAO,MAAMA,6BAA6C,KAAK;AAE/D,OAAO,MAAMC,2BAA2C,KAAK"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/constants/dialog.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport const SAVE_DEFAULTS_DIALOG_TEXT =\n 'You have made changes to the time range or the variables values. Would you like to save these as defaults?';\n"],"names":["SAVE_DEFAULTS_DIALOG_TEXT"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,MAAMA,yBAAyB,GACpC,4GAA4G,CAAC"}
1
+ {"version":3,"sources":["../../src/constants/dialog.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport const SAVE_DEFAULTS_DIALOG_TEXT =\n 'You have made changes to the time range or the variables values. Would you like to save these as defaults?';\n"],"names":["SAVE_DEFAULTS_DIALOG_TEXT"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,MAAMA,4BACX,6GAA6G"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/constants/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './dashboard-defaults';\nexport * from './dialog';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,UAAU,CAAC"}
1
+ {"version":3,"sources":["../../src/constants/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './dashboard-defaults';\nexport * from './dialog';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,uBAAuB;AACrC,cAAc,WAAW"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './constants';\nexport * from './model';\nexport * from './utils';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './constants';\nexport * from './model';\nexport * from './utils';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,cAAc;AAC5B,cAAc,UAAU;AACxB,cAAc,UAAU"}
@@ -1,22 +1,22 @@
1
1
  import { TimeSeriesValueTuple } from '@perses-dev/core';
2
+ export declare const DEFAULT_CALCULATION: CalculationType;
2
3
  export declare const CalculationsMap: {
3
- First: typeof first;
4
- Last: typeof last;
5
- FirstNumber: typeof firstNumber;
6
- LastNumber: typeof lastNumber;
7
- Mean: typeof mean;
8
- Sum: typeof sum;
9
- Min: typeof min;
10
- Max: typeof max;
4
+ first: typeof first;
5
+ last: typeof last;
6
+ 'first-number': typeof firstNumber;
7
+ 'last-number': typeof lastNumber;
8
+ mean: typeof mean;
9
+ sum: typeof sum;
10
+ min: typeof min;
11
+ max: typeof max;
11
12
  };
12
- export declare type CalculationType = keyof typeof CalculationsMap;
13
- export declare type CalculationConfig = {
13
+ export type CalculationType = keyof typeof CalculationsMap;
14
+ export type CalculationConfig = {
14
15
  label: string;
15
16
  description: string;
16
17
  };
17
18
  export declare const CALCULATIONS_CONFIG: Readonly<Record<CalculationType, CalculationConfig>>;
18
- export declare const DEFAULT_CALCULATION: CalculationType;
19
- declare type CalculationValue = number | null | undefined;
19
+ type CalculationValue = number | null | undefined;
20
20
  /**
21
21
  * Calculate a multiple values for a set of time series data.
22
22
  *
@@ -1 +1 @@
1
- {"version":3,"file":"calculations.d.ts","sourceRoot":"","sources":["../../src/model/calculations.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,eAAO,MAAM,eAAe;;;;;;;;;CAS3B,CAAC;AAEF,oBAAY,eAAe,GAAG,MAAM,OAAO,eAAe,CAAC;AAE3D,oBAAY,iBAAiB,GAAG;IAC9B,KAAK,EAAE,MAAM,CAAC;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iBAAS,GAAG,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,gBAAgB,CAE7D;AAED,iBAAS,GAAG,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,gBAAgB,CAE7D"}
@@ -10,51 +10,51 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
+ export const DEFAULT_CALCULATION = 'last-number';
13
14
  export const CalculationsMap = {
14
- First: first,
15
- Last: last,
16
- FirstNumber: firstNumber,
17
- LastNumber: lastNumber,
18
- Mean: mean,
19
- Sum: sum,
20
- Min: min,
21
- Max: max
15
+ first: first,
16
+ last: last,
17
+ 'first-number': firstNumber,
18
+ 'last-number': lastNumber,
19
+ mean: mean,
20
+ sum: sum,
21
+ min: min,
22
+ max: max
22
23
  };
23
24
  export const CALCULATIONS_CONFIG = {
24
- First: {
25
+ first: {
25
26
  label: 'First',
26
27
  description: 'First value'
27
28
  },
28
- Last: {
29
+ last: {
29
30
  label: 'Last',
30
31
  description: 'Last value'
31
32
  },
32
- FirstNumber: {
33
+ 'first-number': {
33
34
  label: 'First *',
34
35
  description: 'First numeric value'
35
36
  },
36
- LastNumber: {
37
+ 'last-number': {
37
38
  label: 'Last *',
38
39
  description: 'Last numeric value'
39
40
  },
40
- Mean: {
41
+ mean: {
41
42
  label: 'Avg',
42
43
  description: 'Average value excluding nulls'
43
44
  },
44
- Sum: {
45
+ sum: {
45
46
  label: 'Sum',
46
47
  description: 'The sum of all values'
47
48
  },
48
- Min: {
49
+ min: {
49
50
  label: 'Min',
50
51
  description: 'Minimum value'
51
52
  },
52
- Max: {
53
+ max: {
53
54
  label: 'Max',
54
55
  description: 'Maximum value'
55
56
  }
56
57
  };
57
- export const DEFAULT_CALCULATION = 'Sum';
58
58
  /**
59
59
  * Calculate a multiple values for a set of time series data.
60
60
  *
@@ -73,55 +73,55 @@ export const DEFAULT_CALCULATION = 'Sum';
73
73
  // in a single iteration of the data to minimize the performance impact of
74
74
  // generating multiple calculations for large timeseries values. This is
75
75
  // less optimized for certain single calculations when done in isolation (e.g.
76
- // `Last`), but will be more performant in the more expensive cases where
76
+ // `last`), but will be more performant in the more expensive cases where
77
77
  // multiple values are being used (e.g. table legend).
78
78
  values.forEach((tuple, i)=>{
79
79
  const value = tuple[1];
80
- if (i === 0 && 'First' in calculations) {
81
- calculations.First = value;
80
+ if (i === 0 && 'first' in calculations) {
81
+ calculations.first = value;
82
82
  }
83
- if (i === values.length - 1 && 'Last' in calculations) {
84
- calculations.Last = value;
83
+ if (i === values.length - 1 && 'last' in calculations) {
84
+ calculations.last = value;
85
85
  }
86
86
  // Handling specific to non-null values.
87
87
  if (typeof value === 'number') {
88
88
  nonNullCount += 1;
89
89
  sum += value;
90
- if ('FirstNumber' in calculations && calculations.FirstNumber === undefined) {
90
+ if ('first-number' in calculations && calculations['first-number'] === undefined) {
91
91
  // Save the first number we see.
92
- calculations.FirstNumber = value;
92
+ calculations['first-number'] = value;
93
93
  }
94
- if ('LastNumber' in calculations) {
94
+ if ('last-number' in calculations) {
95
95
  // Keep setting the numbers we see, which will eventually be set to the
96
96
  // last number when finished iterating.
97
- calculations.LastNumber = value;
97
+ calculations['last-number'] = value;
98
98
  }
99
- if ('Min' in calculations) {
100
- if (typeof calculations.Min !== 'number') {
99
+ if ('min' in calculations) {
100
+ if (typeof calculations.min !== 'number') {
101
101
  // Init the first time we see a number
102
- calculations.Min = value;
102
+ calculations.min = value;
103
103
  } else {
104
104
  // Use lowest value once initialized
105
- calculations.Min = Math.min(calculations.Min, value);
105
+ calculations.min = Math.min(calculations.min, value);
106
106
  }
107
107
  }
108
- if ('Max' in calculations) {
109
- if (typeof calculations.Max !== 'number') {
108
+ if ('max' in calculations) {
109
+ if (typeof calculations.max !== 'number') {
110
110
  // Init the first time we see a number
111
- calculations.Max = value;
111
+ calculations.max = value;
112
112
  } else {
113
113
  // Use highest value once initialized
114
- calculations.Max = Math.max(calculations.Max, value);
114
+ calculations.max = Math.max(calculations.max, value);
115
115
  }
116
116
  }
117
117
  }
118
118
  });
119
119
  // Set calculations that require iterating over all values.
120
- if (nonNullCount > 0 && 'Sum' in calculations) {
121
- calculations.Sum = sum;
120
+ if (nonNullCount > 0 && 'sum' in calculations) {
121
+ calculations.sum = sum;
122
122
  }
123
- if (nonNullCount > 0 && 'Mean' in calculations) {
124
- calculations.Mean = sum / nonNullCount;
123
+ if (nonNullCount > 0 && 'mean' in calculations) {
124
+ calculations.mean = sum / nonNullCount;
125
125
  }
126
126
  return calculations;
127
127
  }
@@ -138,28 +138,28 @@ export const DEFAULT_CALCULATION = 'Sum';
138
138
  ])[calculation];
139
139
  }
140
140
  function first(values) {
141
- return getCalculation(values, 'First');
141
+ return getCalculation(values, 'first');
142
142
  }
143
143
  function last(values) {
144
- return getCalculation(values, 'Last');
144
+ return getCalculation(values, 'last');
145
145
  }
146
146
  function firstNumber(values) {
147
- return getCalculation(values, 'FirstNumber');
147
+ return getCalculation(values, 'first-number');
148
148
  }
149
149
  function lastNumber(values) {
150
- return getCalculation(values, 'LastNumber');
150
+ return getCalculation(values, 'last-number');
151
151
  }
152
152
  function mean(values) {
153
- return getCalculation(values, 'Mean');
153
+ return getCalculation(values, 'mean');
154
154
  }
155
155
  function sum(values) {
156
- return getCalculation(values, 'Sum');
156
+ return getCalculation(values, 'sum');
157
157
  }
158
158
  function min(values) {
159
- return getCalculation(values, 'Min');
159
+ return getCalculation(values, 'min');
160
160
  }
161
161
  function max(values) {
162
- return getCalculation(values, 'Max');
162
+ return getCalculation(values, 'max');
163
163
  }
164
164
 
165
165
  //# sourceMappingURL=calculations.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/calculations.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { TimeSeriesValueTuple } from '@perses-dev/core';\n\nexport const CalculationsMap = {\n First: first,\n Last: last,\n FirstNumber: firstNumber,\n LastNumber: lastNumber,\n Mean: mean,\n Sum: sum,\n Min: min,\n Max: max,\n};\n\nexport type CalculationType = keyof typeof CalculationsMap;\n\nexport type CalculationConfig = {\n label: string;\n description: string;\n};\n\nexport const CALCULATIONS_CONFIG: Readonly<Record<CalculationType, CalculationConfig>> = {\n First: {\n label: 'First',\n description: 'First value',\n },\n Last: {\n label: 'Last',\n description: 'Last value',\n },\n FirstNumber: {\n label: 'First *',\n description: 'First numeric value',\n },\n LastNumber: {\n label: 'Last *',\n description: 'Last numeric value',\n },\n Mean: {\n label: 'Avg',\n description: 'Average value excluding nulls',\n },\n Sum: {\n label: 'Sum',\n description: 'The sum of all values',\n },\n Min: {\n label: 'Min',\n description: 'Minimum value',\n },\n Max: {\n label: 'Max',\n description: 'Maximum value',\n },\n} as const;\n\nexport const DEFAULT_CALCULATION: CalculationType = 'Sum';\n\ntype CalculationValue = number | null | undefined;\n\n/**\n * Calculate a multiple values for a set of time series data.\n *\n * @param values - Array of time series data.\n * @param includeCalculations - Array of calculations to include.\n */\nexport function getCalculations<IncludeCalcs extends CalculationType[]>(\n values: TimeSeriesValueTuple[],\n includeCalculations: IncludeCalcs\n): Record<\n // This extract combined with the generics above keeps the key of the returned\n // record to *just* the specified calculations.\n Extract<CalculationType, IncludeCalcs[number]>,\n CalculationValue\n> {\n const calculations = includeCalculations.reduce((initResult, calculation) => {\n initResult[calculation] = undefined;\n return initResult;\n }, {} as Record<string, CalculationValue>);\n\n // We save these values as separate values instead of directly setting them\n // in the calculations because they are needed by multiple calculations.\n let nonNullCount = 0;\n let sum = 0;\n\n // We use this large function capable of performing one or more calculations\n // in a single iteration of the data to minimize the performance impact of\n // generating multiple calculations for large timeseries values. This is\n // less optimized for certain single calculations when done in isolation (e.g.\n // `Last`), but will be more performant in the more expensive cases where\n // multiple values are being used (e.g. table legend).\n values.forEach((tuple, i) => {\n const value = tuple[1];\n\n if (i === 0 && 'First' in calculations) {\n calculations.First = value;\n }\n if (i === values.length - 1 && 'Last' in calculations) {\n calculations.Last = value;\n }\n\n // Handling specific to non-null values.\n if (typeof value === 'number') {\n nonNullCount += 1;\n sum += value;\n\n if ('FirstNumber' in calculations && calculations.FirstNumber === undefined) {\n // Save the first number we see.\n calculations.FirstNumber = value;\n }\n\n if ('LastNumber' in calculations) {\n // Keep setting the numbers we see, which will eventually be set to the\n // last number when finished iterating.\n calculations.LastNumber = value;\n }\n\n if ('Min' in calculations) {\n if (typeof calculations.Min !== 'number') {\n // Init the first time we see a number\n calculations.Min = value;\n } else {\n // Use lowest value once initialized\n calculations.Min = Math.min(calculations.Min, value);\n }\n }\n\n if ('Max' in calculations) {\n if (typeof calculations.Max !== 'number') {\n // Init the first time we see a number\n calculations.Max = value;\n } else {\n // Use highest value once initialized\n calculations.Max = Math.max(calculations.Max, value);\n }\n }\n }\n });\n\n // Set calculations that require iterating over all values.\n if (nonNullCount > 0 && 'Sum' in calculations) {\n calculations.Sum = sum;\n }\n\n if (nonNullCount > 0 && 'Mean' in calculations) {\n calculations.Mean = sum / nonNullCount;\n }\n\n return calculations;\n}\n\n/**\n * Calculate a single value for a set of time series data.\n *\n * Use `getCalculations` instead if you need multiple calculations.\n *\n * @param values - Array of time series data.\n * @param calculation - Name of the calculation to calculate.\n */\nexport function getCalculation(values: TimeSeriesValueTuple[], calculation: CalculationType) {\n return getCalculations(values, [calculation])[calculation];\n}\n\nfunction first(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'First');\n}\n\nfunction last(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'Last');\n}\n\nfunction firstNumber(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'FirstNumber');\n}\n\nfunction lastNumber(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'LastNumber');\n}\n\nfunction mean(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'Mean');\n}\n\nfunction sum(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'Sum');\n}\n\nfunction min(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'Min');\n}\n\nfunction max(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'Max');\n}\n"],"names":["CalculationsMap","First","first","Last","last","FirstNumber","firstNumber","LastNumber","lastNumber","Mean","mean","Sum","sum","Min","min","Max","max","CALCULATIONS_CONFIG","label","description","DEFAULT_CALCULATION","getCalculations","values","includeCalculations","calculations","reduce","initResult","calculation","undefined","nonNullCount","forEach","tuple","i","value","length","Math","getCalculation"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,OAAO,MAAMA,eAAe,GAAG;IAC7BC,KAAK,EAAEC,KAAK;IACZC,IAAI,EAAEC,IAAI;IACVC,WAAW,EAAEC,WAAW;IACxBC,UAAU,EAAEC,UAAU;IACtBC,IAAI,EAAEC,IAAI;IACVC,GAAG,EAAEC,GAAG;IACRC,GAAG,EAAEC,GAAG;IACRC,GAAG,EAAEC,GAAG;CACT,CAAC;AASF,OAAO,MAAMC,mBAAmB,GAAyD;IACvFhB,KAAK,EAAE;QACLiB,KAAK,EAAE,OAAO;QACdC,WAAW,EAAE,aAAa;KAC3B;IACDhB,IAAI,EAAE;QACJe,KAAK,EAAE,MAAM;QACbC,WAAW,EAAE,YAAY;KAC1B;IACDd,WAAW,EAAE;QACXa,KAAK,EAAE,SAAS;QAChBC,WAAW,EAAE,qBAA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,KAAK,CAAC,CAAC;AACvC,CAAC"}
1
+ {"version":3,"sources":["../../src/model/calculations.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { TimeSeriesValueTuple } from '@perses-dev/core';\n\nexport const DEFAULT_CALCULATION: CalculationType = 'last-number';\n\nexport const CalculationsMap = {\n first: first,\n last: last,\n 'first-number': firstNumber,\n 'last-number': lastNumber,\n mean: mean,\n sum: sum,\n min: min,\n max: max,\n};\n\nexport type CalculationType = keyof typeof CalculationsMap;\n\nexport type CalculationConfig = {\n label: string;\n description: string;\n};\n\nexport const CALCULATIONS_CONFIG: Readonly<Record<CalculationType, CalculationConfig>> = {\n first: {\n label: 'First',\n description: 'First value',\n },\n last: {\n label: 'Last',\n description: 'Last value',\n },\n 'first-number': {\n label: 'First *',\n description: 'First numeric value',\n },\n 'last-number': {\n label: 'Last *',\n description: 'Last numeric value',\n },\n mean: {\n label: 'Avg',\n description: 'Average value excluding nulls',\n },\n sum: {\n label: 'Sum',\n description: 'The sum of all values',\n },\n min: {\n label: 'Min',\n description: 'Minimum value',\n },\n max: {\n label: 'Max',\n description: 'Maximum value',\n },\n} as const;\n\ntype CalculationValue = number | null | undefined;\n\n/**\n * Calculate a multiple values for a set of time series data.\n *\n * @param values - Array of time series data.\n * @param includeCalculations - Array of calculations to include.\n */\nexport function getCalculations<IncludeCalcs extends CalculationType[]>(\n values: TimeSeriesValueTuple[],\n includeCalculations: IncludeCalcs\n): Record<\n // This extract combined with the generics above keeps the key of the returned\n // record to *just* the specified calculations.\n Extract<CalculationType, IncludeCalcs[number]>,\n CalculationValue\n> {\n const calculations = includeCalculations.reduce(\n (initResult, calculation) => {\n initResult[calculation] = undefined;\n return initResult;\n },\n {} as Record<string, CalculationValue>\n );\n\n // We save these values as separate values instead of directly setting them\n // in the calculations because they are needed by multiple calculations.\n let nonNullCount = 0;\n let sum = 0;\n\n // We use this large function capable of performing one or more calculations\n // in a single iteration of the data to minimize the performance impact of\n // generating multiple calculations for large timeseries values. This is\n // less optimized for certain single calculations when done in isolation (e.g.\n // `last`), but will be more performant in the more expensive cases where\n // multiple values are being used (e.g. table legend).\n values.forEach((tuple, i) => {\n const value = tuple[1];\n\n if (i === 0 && 'first' in calculations) {\n calculations.first = value;\n }\n if (i === values.length - 1 && 'last' in calculations) {\n calculations.last = value;\n }\n\n // Handling specific to non-null values.\n if (typeof value === 'number') {\n nonNullCount += 1;\n sum += value;\n\n if ('first-number' in calculations && calculations['first-number'] === undefined) {\n // Save the first number we see.\n calculations['first-number'] = value;\n }\n\n if ('last-number' in calculations) {\n // Keep setting the numbers we see, which will eventually be set to the\n // last number when finished iterating.\n calculations['last-number'] = value;\n }\n\n if ('min' in calculations) {\n if (typeof calculations.min !== 'number') {\n // Init the first time we see a number\n calculations.min = value;\n } else {\n // Use lowest value once initialized\n calculations.min = Math.min(calculations.min, value);\n }\n }\n\n if ('max' in calculations) {\n if (typeof calculations.max !== 'number') {\n // Init the first time we see a number\n calculations.max = value;\n } else {\n // Use highest value once initialized\n calculations.max = Math.max(calculations.max, value);\n }\n }\n }\n });\n\n // Set calculations that require iterating over all values.\n if (nonNullCount > 0 && 'sum' in calculations) {\n calculations.sum = sum;\n }\n\n if (nonNullCount > 0 && 'mean' in calculations) {\n calculations.mean = sum / nonNullCount;\n }\n\n return calculations;\n}\n\n/**\n * Calculate a single value for a set of time series data.\n *\n * Use `getCalculations` instead if you need multiple calculations.\n *\n * @param values - Array of time series data.\n * @param calculation - Name of the calculation to calculate.\n */\nexport function getCalculation(values: TimeSeriesValueTuple[], calculation: CalculationType) {\n return getCalculations(values, [calculation])[calculation];\n}\n\nfunction first(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'first');\n}\n\nfunction last(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'last');\n}\n\nfunction firstNumber(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'first-number');\n}\n\nfunction lastNumber(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'last-number');\n}\n\nfunction mean(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'mean');\n}\n\nfunction sum(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'sum');\n}\n\nfunction min(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'min');\n}\n\nfunction max(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'max');\n}\n"],"names":["DEFAULT_CALCULATION","CalculationsMap","first","last","firstNumber","lastNumber","mean","sum","min","max","CALCULATIONS_CONFIG","label","description","getCalculations","values","includeCalculations","calculations","reduce","initResult","calculation","undefined","nonNullCount","forEach","tuple","i","value","length","Math","getCalculation"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,OAAO,MAAMA,sBAAuC,cAAc;AAElE,OAAO,MAAMC,kBAAkB;IAC7BC,OAAOA;IACPC,MAAMA;IACN,gBAAgBC;IAChB,eAAeC;IACfC,MAAMA;IACNC,KAAKA;IACLC,KAAKA;IACLC,KAAKA;AACP,EAAE;AASF,OAAO,MAAMC,sBAA4E;IACvFR,OAAO;QACLS,OAAO;QACPC,aAAa;IACf;IACAT,MAAM;QACJQ,OAAO;QACPC,aAAa;IACf;IACA,gBAAgB;QACdD,OAAO;QACPC,aAAa;IACf;IACA,eAAe;QACbD,OAAO;Q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,GAAG,GAAGmB,KAAKnB,GAAG,CAACQ,aAAaR,GAAG,EAAEiB;gBAChD;YACF;YAEA,IAAI,SAAST,cAAc;gBACzB,IAAI,OAAOA,aAAaP,GAAG,KAAK,UAAU;oBACxC,sCAAsC;oBACtCO,aAAaP,GAAG,GAAGgB;gBACrB,OAAO;oBACL,qCAAqC;oBACrCT,aAAaP,GAAG,GAAGkB,KAAKlB,GAAG,CAACO,aAAaP,GAAG,EAAEgB;gBAChD;YACF;QACF;IACF;IAEA,2DAA2D;IAC3D,IAAIJ,eAAe,KAAK,SAASL,cAAc;QAC7CA,aAAaT,GAAG,GAAGA;IACrB;IAEA,IAAIc,eAAe,KAAK,UAAUL,cAAc;QAC9CA,aAAaV,IAAI,GAAGC,MAAMc;IAC5B;IAEA,OAAOL;AACT;AAEA;;;;;;;CAOC,GACD,OAAO,SAASY,eAAed,MAA8B,EAAEK,WAA4B;IACzF,OAAON,gBAAgBC,QAAQ;QAACK;KAAY,CAAC,CAACA,YAAY;AAC5D;AAEA,SAASjB,MAAMY,MAA8B;IAC3C,OAAOc,eAAed,QAAQ;AAChC;AAEA,SAASX,KAAKW,MAA8B;IAC1C,OAAOc,eAAed,QAAQ;AAChC;AAEA,SAASV,YAAYU,MAA8B;IACjD,OAAOc,eAAed,QAAQ;AAChC;AAEA,SAAST,WAAWS,MAA8B;IAChD,OAAOc,eAAed,QAAQ;AAChC;AAEA,SAASR,KAAKQ,MAA8B;IAC1C,OAAOc,eAAed,QAAQ;AAChC;AAEA,SAASP,IAAIO,MAA8B;IACzC,OAAOc,eAAed,QAAQ;AAChC;AAEA,SAASN,IAAIM,MAA8B;IACzC,OAAOc,eAAed,QAAQ;AAChC;AAEA,SAASL,IAAIK,MAA8B;IACzC,OAAOc,eAAed,QAAQ;AAChC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/dashboard.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DatasourceSpec } from './datasource';\nimport { LayoutDefinition } from './layout';\nimport { PanelDefinition } from './panels';\nimport { ProjectMetadata } from './resource';\nimport { DurationString } from './time';\nimport { VariableDefinition } from './variables';\nimport { Display } from './display';\n\nexport interface DashboardResource {\n kind: 'Dashboard';\n metadata: ProjectMetadata;\n spec: DashboardSpec;\n}\n\nexport interface DashboardSpec {\n display?: Display;\n datasources?: Record<string, DatasourceSpec>;\n duration: DurationString;\n refreshInterval?: DurationString;\n variables: VariableDefinition[];\n layouts: LayoutDefinition[];\n panels: Record<string, PanelDefinition>;\n}\n\nexport interface DashboardSelector {\n project: string;\n dashboard: string;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,WA2BC"}
1
+ {"version":3,"sources":["../../src/model/dashboard.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DatasourceSpec } from './datasource';\nimport { LayoutDefinition } from './layout';\nimport { PanelDefinition } from './panels';\nimport { ProjectMetadata } from './resource';\nimport { DurationString } from './time';\nimport { VariableDefinition } from './variables';\nimport { Display } from './display';\n\nexport interface DashboardResource {\n kind: 'Dashboard';\n metadata: ProjectMetadata;\n spec: DashboardSpec;\n}\n\nexport interface DashboardSpec {\n display?: Display;\n datasources?: Record<string, DatasourceSpec>;\n duration: DurationString;\n refreshInterval?: DurationString;\n variables: VariableDefinition[];\n layouts: LayoutDefinition[];\n panels: Record<string, PanelDefinition>;\n}\n\nexport interface DashboardSelector {\n project: string;\n dashboard: string;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AA0BjC,WAGC"}
@@ -12,22 +12,36 @@ export interface GlobalDatasource {
12
12
  /**
13
13
  * A Datasource resource, that belongs to a project.
14
14
  */
15
- export interface Datasource {
15
+ export interface ProjectDatasource {
16
16
  kind: 'Datasource';
17
17
  metadata: ProjectMetadata;
18
18
  spec: DatasourceSpec;
19
19
  }
20
+ export type Datasource = ProjectDatasource | GlobalDatasource;
20
21
  export interface DatasourceSpec<PluginSpec = UnknownSpec> {
21
22
  display?: Display;
22
23
  default: boolean;
23
24
  plugin: Definition<PluginSpec>;
24
25
  }
25
26
  /**
26
- * A selector for pointing at a specific Datasource. If name is omitted, it's assumed that you want the default
27
- * Datasource for the specified kind.
27
+ * A selector for pointing at a specific Datasource.
28
28
  */
29
29
  export interface DatasourceSelector {
30
+ /**
31
+ * Kind of the datasource.
32
+ */
30
33
  kind: string;
34
+ /**
35
+ * Name of the datasource.
36
+ * If omitted, it's assumed that you target the default datasource for the specified kind (and group, if set)
37
+ */
31
38
  name?: string;
32
39
  }
40
+ /**
41
+ * An intermediary type to regroup the name and the spec of a datasource.
42
+ */
43
+ export interface DatasourceDefinition {
44
+ name: string;
45
+ spec: DatasourceSpec;
46
+ }
33
47
  //# sourceMappingURL=datasource.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"datasource.d.ts","sourceRoot":"","sources":["../../src/model/datasource.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,kBAAkB,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,cAAc,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,eAAe,CAAC;IAC1B,IAAI,EAAE,cAAc,CAAC;CACtB;AAED,MAAM,WAAW,cAAc,CAAC,UAAU,GAAG,WAAW;IACtD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;CAChC;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
1
+ {"version":3,"file":"datasource.d.ts","sourceRoot":"","sources":["../../src/model/datasource.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,kBAAkB,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,cAAc,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,eAAe,CAAC;IAC1B,IAAI,EAAE,cAAc,CAAC;CACtB;AAED,MAAM,MAAM,UAAU,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;AAE9D,MAAM,WAAW,cAAc,CAAC,UAAU,GAAG,WAAW;IACtD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,cAAc,CAAC;CACtB"}
@@ -10,6 +10,8 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- export { };
13
+ /**
14
+ * An intermediary type to regroup the name and the spec of a datasource.
15
+ */ export { };
14
16
 
15
17
  //# sourceMappingURL=datasource.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/datasource.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Definition, UnknownSpec } from './definitions';\nimport { Metadata, ProjectMetadata } from './resource';\nimport { Display } from './display';\n\n/**\n * A Datasource that's available across all projects.\n */\nexport interface GlobalDatasource {\n kind: 'GlobalDatasource';\n metadata: Metadata;\n spec: DatasourceSpec;\n}\n\n/**\n * A Datasource resource, that belongs to a project.\n */\nexport interface Datasource {\n kind: 'Datasource';\n metadata: ProjectMetadata;\n spec: DatasourceSpec;\n}\n\nexport interface DatasourceSpec<PluginSpec = UnknownSpec> {\n display?: Display;\n default: boolean;\n plugin: Definition<PluginSpec>;\n}\n\n/**\n * A selector for pointing at a specific Datasource. If name is omitted, it's assumed that you want the default\n * Datasource for the specified kind.\n */\nexport interface DatasourceSelector {\n kind: string;\n name?: string;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,WAmCC"}
1
+ {"version":3,"sources":["../../src/model/datasource.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Definition, UnknownSpec } from './definitions';\nimport { Metadata, ProjectMetadata } from './resource';\nimport { Display } from './display';\n\n/**\n * A Datasource that's available across all projects.\n */\nexport interface GlobalDatasource {\n kind: 'GlobalDatasource';\n metadata: Metadata;\n spec: DatasourceSpec;\n}\n\n/**\n * A Datasource resource, that belongs to a project.\n */\nexport interface ProjectDatasource {\n kind: 'Datasource';\n metadata: ProjectMetadata;\n spec: DatasourceSpec;\n}\n\nexport type Datasource = ProjectDatasource | GlobalDatasource;\n\nexport interface DatasourceSpec<PluginSpec = UnknownSpec> {\n display?: Display;\n default: boolean;\n plugin: Definition<PluginSpec>;\n}\n\n/**\n * A selector for pointing at a specific Datasource.\n */\nexport interface DatasourceSelector {\n /**\n * Kind of the datasource.\n */\n kind: string;\n\n /**\n * Name of the datasource.\n * If omitted, it's assumed that you target the default datasource for the specified kind (and group, if set)\n */\n name?: string;\n}\n\n/**\n * An intermediary type to regroup the name and the spec of a datasource.\n */\nexport interface DatasourceDefinition {\n name: string;\n spec: DatasourceSpec;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAgDjC;;CAEC,GACD,WAGC"}
@@ -9,5 +9,5 @@ export interface Definition<Spec> {
9
9
  * Type to represent specs at runtime in framework code where we don't know the spec's real type, probably because it's
10
10
  * part of a plugin.
11
11
  */
12
- export declare type UnknownSpec = Record<string, unknown>;
12
+ export type UnknownSpec = Record<string, unknown>;
13
13
  //# sourceMappingURL=definitions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/model/definitions.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,IAAI;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;CACZ;AAED;;;GAGG;AACH,oBAAY,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
1
+ {"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/model/definitions.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,IAAI;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;CACZ;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}