@splunk/visualizations 26.1.2 → 26.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/Area.config.js +2 -1
  2. package/Area.config.js.map +1 -1
  3. package/Area.js +1562 -433
  4. package/Area.js.map +1 -1
  5. package/Bar.config.js +1 -0
  6. package/Bar.config.js.map +1 -1
  7. package/Bar.js +1555 -430
  8. package/Bar.js.map +1 -1
  9. package/Bubble.config.js +1 -0
  10. package/Bubble.config.js.map +1 -1
  11. package/Bubble.js +1580 -455
  12. package/Bubble.js.map +1 -1
  13. package/ChoroplethSvg.config.js +1 -0
  14. package/ChoroplethSvg.config.js.map +1 -1
  15. package/ChoroplethSvg.js +1418 -351
  16. package/ChoroplethSvg.js.map +1 -1
  17. package/Column.config.js +2 -1
  18. package/Column.config.js.map +1 -1
  19. package/Column.js +1564 -435
  20. package/Column.js.map +1 -1
  21. package/Ellipse.config.js +1 -0
  22. package/Ellipse.config.js.map +1 -1
  23. package/Ellipse.js +1342 -297
  24. package/Ellipse.js.map +1 -1
  25. package/Events.config.js +4 -0
  26. package/Events.config.js.map +1 -1
  27. package/Events.js +1503 -489
  28. package/Events.js.map +1 -1
  29. package/FEATUREFLAGS.md +3 -0
  30. package/FillerGauge.config.js +1 -0
  31. package/FillerGauge.config.js.map +1 -1
  32. package/FillerGauge.js +1406 -345
  33. package/FillerGauge.js.map +1 -1
  34. package/Image.config.js +1 -0
  35. package/Image.config.js.map +1 -1
  36. package/Image.js +2355 -1183
  37. package/Image.js.map +1 -1
  38. package/Line.config.js +2 -1
  39. package/Line.config.js.map +1 -1
  40. package/Line.js +1562 -433
  41. package/Line.js.map +1 -1
  42. package/LinkGraph.config.js +1 -0
  43. package/LinkGraph.config.js.map +1 -1
  44. package/LinkGraph.js +2013 -968
  45. package/LinkGraph.js.map +1 -1
  46. package/Map.config.js +1 -0
  47. package/Map.config.js.map +1 -1
  48. package/Map.js +2556 -1527
  49. package/Map.js.map +1 -1
  50. package/Markdown.config.js +1 -0
  51. package/Markdown.config.js.map +1 -1
  52. package/Markdown.js +1952 -883
  53. package/Markdown.js.map +1 -1
  54. package/MarkerGauge.config.js +1 -0
  55. package/MarkerGauge.config.js.map +1 -1
  56. package/MarkerGauge.js +4049 -2965
  57. package/MarkerGauge.js.map +1 -1
  58. package/ParallelCoordinates.config.js +1 -0
  59. package/ParallelCoordinates.config.js.map +1 -1
  60. package/ParallelCoordinates.js +3286 -2215
  61. package/ParallelCoordinates.js.map +1 -1
  62. package/Pie.config.js +1 -0
  63. package/Pie.config.js.map +1 -1
  64. package/Pie.js +2187 -1036
  65. package/Pie.js.map +1 -1
  66. package/Punchcard.config.js +1 -0
  67. package/Punchcard.config.js.map +1 -1
  68. package/Punchcard.js +3397 -2299
  69. package/Punchcard.js.map +1 -1
  70. package/Rectangle.config.js +1 -0
  71. package/Rectangle.config.js.map +1 -1
  72. package/Rectangle.js +2181 -1112
  73. package/Rectangle.js.map +1 -1
  74. package/Sankey.config.js +1 -0
  75. package/Sankey.config.js.map +1 -1
  76. package/Sankey.js +3275 -2199
  77. package/Sankey.js.map +1 -1
  78. package/Scatter.config.js +1 -0
  79. package/Scatter.config.js.map +1 -1
  80. package/Scatter.js +3551 -2400
  81. package/Scatter.js.map +1 -1
  82. package/SingleValue.config.js +27 -0
  83. package/SingleValue.config.js.map +1 -1
  84. package/SingleValue.js +5551 -4397
  85. package/SingleValue.js.map +1 -1
  86. package/SingleValueBasic.js +1227 -1209
  87. package/SingleValueBasic.js.map +1 -1
  88. package/SingleValueIcon.config.js +27 -0
  89. package/SingleValueIcon.config.js.map +1 -1
  90. package/SingleValueIcon.js +2850 -1696
  91. package/SingleValueIcon.js.map +1 -1
  92. package/SingleValueRadial.config.js +1 -0
  93. package/SingleValueRadial.config.js.map +1 -1
  94. package/SingleValueRadial.js +6334 -5215
  95. package/SingleValueRadial.js.map +1 -1
  96. package/SparkLine.js +96 -96
  97. package/SparkLine.js.map +1 -1
  98. package/Table.config.js +172 -7
  99. package/Table.config.js.map +1 -1
  100. package/Table.js +3500 -2195
  101. package/Table.js.map +1 -1
  102. package/common/Charting.js +1009 -82
  103. package/common/Charting.js.map +1 -1
  104. package/common/ChartingApi.js +4 -4
  105. package/common/ChartingApi.js.map +1 -1
  106. package/common/DocExampleWithVizSandbox.js +54 -57
  107. package/common/DocExampleWithVizSandbox.js.map +1 -1
  108. package/common/EventsDoc.js +40 -40
  109. package/common/EventsDoc.js.map +1 -1
  110. package/common/GaugeMajorTicks.js +15 -13
  111. package/common/GaugeMajorTicks.js.map +1 -1
  112. package/common/GaugeValueMarker.js +12 -12
  113. package/common/GaugeValueMarker.js.map +1 -1
  114. package/common/OptionsDoc.js +34 -34
  115. package/common/OptionsDoc.js.map +1 -1
  116. package/common/OverviewDoc.js +124 -103
  117. package/common/OverviewDoc.js.map +1 -1
  118. package/common/SplunkVisualization.js +49 -49
  119. package/common/SplunkVisualization.js.map +1 -1
  120. package/common/SplunkVisualizationApi.js +4 -4
  121. package/common/SplunkVisualizationApi.js.map +1 -1
  122. package/common/ThemesDoc.js +31 -31
  123. package/common/ThemesDoc.js.map +1 -1
  124. package/common/chartingUtils.js +24 -8
  125. package/common/chartingUtils.js.map +1 -1
  126. package/common/docUtils.js +4 -4
  127. package/common/docUtils.js.map +1 -1
  128. package/common/gaugeUtils.js +16 -16
  129. package/common/gaugeUtils.js.map +1 -1
  130. package/common/shapeUtils.js +36 -36
  131. package/common/shapeUtils.js.map +1 -1
  132. package/common/utils/configUtils.js +48 -47
  133. package/common/utils/configUtils.js.map +1 -1
  134. package/common/utils/dataUtils.js +832 -6
  135. package/common/utils/dataUtils.js.map +1 -1
  136. package/common/utils/featureFlagUtils.js +139 -0
  137. package/common/utils/featureFlagUtils.js.map +1 -0
  138. package/common/utils/hocUtils.js +2 -2
  139. package/common/utils/hocUtils.js.map +1 -1
  140. package/common/utils/layoutUtils.js +2 -2
  141. package/common/utils/layoutUtils.js.map +1 -1
  142. package/common/utils/mapUtils.js +77 -54
  143. package/common/utils/mapUtils.js.map +1 -1
  144. package/common/utils/singleValueUtils.js +28 -19
  145. package/common/utils/singleValueUtils.js.map +1 -1
  146. package/common/utils/testHelper.js +10 -10
  147. package/common/utils/testHelper.js.map +1 -1
  148. package/common/utils/trellisUtils.js +6 -6
  149. package/common/utils/trellisUtils.js.map +1 -1
  150. package/common/utils/urlUtils.js +2 -2
  151. package/common/utils/urlUtils.js.map +1 -1
  152. package/common/withDashboardViz.js +1313 -235
  153. package/common/withDashboardViz.js.map +1 -1
  154. package/package.json +13 -12
  155. package/__mocks__/fileMock.js +0 -2
  156. package/__mocks__/styleMock.js +0 -2
  157. package/babel.config.js +0 -11
  158. package/jest.config.js +0 -8
  159. package/loki.config.js +0 -14
package/Image.js CHANGED
@@ -87,47 +87,42 @@ module.exports =
87
87
  /******/
88
88
  /******/
89
89
  /******/ // Load entry module and return exports
90
- /******/ return __webpack_require__(__webpack_require__.s = 221);
90
+ /******/ return __webpack_require__(__webpack_require__.s = 243);
91
91
  /******/ })
92
92
  /************************************************************************/
93
- /******/ ({
94
-
95
- /***/ 0:
93
+ /******/ ([
94
+ /* 0 */
96
95
  /***/ (function(module, exports) {
97
96
 
98
- module.exports = require("prop-types");
97
+ module.exports = require("react");
99
98
 
100
99
  /***/ }),
101
-
102
- /***/ 1:
100
+ /* 1 */
103
101
  /***/ (function(module, exports) {
104
102
 
105
- module.exports = require("react");
103
+ module.exports = require("prop-types");
106
104
 
107
105
  /***/ }),
108
-
109
- /***/ 10:
106
+ /* 2 */
110
107
  /***/ (function(module, exports) {
111
108
 
112
- module.exports = require("@splunk/visualizations-shared/Message");
109
+ module.exports = require("@splunk/ui-utils/i18n");
113
110
 
114
111
  /***/ }),
115
-
116
- /***/ 11:
112
+ /* 3 */
117
113
  /***/ (function(module, exports) {
118
114
 
119
- module.exports = require("@splunk/themes/variables");
115
+ module.exports = require("lodash");
120
116
 
121
117
  /***/ }),
122
-
123
- /***/ 12:
118
+ /* 4 */
124
119
  /***/ (function(module, exports) {
125
120
 
126
- module.exports = require("@splunk/visualizations-shared/colorUtils");
121
+ module.exports = require("styled-components");
127
122
 
128
123
  /***/ }),
129
-
130
- /***/ 13:
124
+ /* 5 */,
125
+ /* 6 */
131
126
  /***/ (function(module, exports, __webpack_require__) {
132
127
 
133
128
  "use strict";
@@ -136,102 +131,79 @@ module.exports = require("@splunk/visualizations-shared/colorUtils");
136
131
  Object.defineProperty(exports, "__esModule", {
137
132
  value: true
138
133
  });
134
+ exports.VizBehavior = void 0;
135
+ var VizBehavior;
139
136
 
140
- var React = __webpack_require__(1);
137
+ (function (VizBehavior) {
138
+ /**
139
+ * Dynamic Options Behavior.
140
+ * This allows visualization options to be powered by data
141
+ *
142
+ * **Example**
143
+ *
144
+ * sparklineValues: ">primary|seriesByIndex(0)"
145
+ * would configure sparklineValues with an array of data points
146
+ * coming from the first series in the primary datasource
147
+ *
148
+ */
149
+ VizBehavior["DYNAMIC_OPTIONS"] = "dynamic-options";
150
+ VizBehavior["EVENTS"] = "events";
151
+ VizBehavior["DOWNSAMPLING"] = "downsampling";
152
+ /**
153
+ * Placeholder behavior: visualization will display a placeholder rather than fail if any of the `requiredProps` is
154
+ * missing.
155
+ * @type {string}
156
+ */
141
157
 
142
- var styled_components_1 = __webpack_require__(4);
158
+ VizBehavior["PLACEHOLDER"] = "placeholder";
159
+ VizBehavior["PAGE_AND_SORT"] = "page-and-sort";
160
+ VizBehavior["TRELLIS"] = "trellis";
161
+ })(VizBehavior = exports.VizBehavior || (exports.VizBehavior = {}));
143
162
 
144
- var SizeAwareWrapper_1 = __webpack_require__(19);
163
+ /***/ }),
164
+ /* 7 */
165
+ /***/ (function(module, exports) {
145
166
 
146
- var style_1 = __webpack_require__(14);
167
+ module.exports = require("@babel/runtime/helpers/slicedToArray");
147
168
 
148
- var colorUtils_1 = __webpack_require__(12);
169
+ /***/ }),
170
+ /* 8 */
171
+ /***/ (function(module, exports) {
149
172
 
150
- var Item = styled_components_1.default.div.attrs(function (_ref) {
151
- var width = _ref.width;
152
- return {
153
- style: {
154
- width: (0, style_1.toPx)(width)
155
- }
156
- };
157
- }).withConfig({
158
- displayName: "FixedSizeContainer__Item",
159
- componentId: "sc-1yhgpod-0"
160
- })(["position:relative;background-color:", "};"], function (props) {
161
- return (0, colorUtils_1.isColor)(props.backgroundColor) && props.backgroundColor || props.theme.defaultBackgroundColor;
162
- }); // Use `.attrs()` for highly dynamic styles. Ref: https://github.com/styled-components/styled-components/issues/134#issuecomment-312415291
173
+ module.exports = require("@babel/runtime/helpers/toConsumableArray");
163
174
 
164
- var FixSizeItem = styled_components_1.default.div.attrs(function (_ref2) {
165
- var width = _ref2.width,
166
- height = _ref2.height;
167
- return {
168
- style: Object.assign(Object.assign({}, width && {
169
- width: (0, style_1.toPx)(width)
170
- }), height && {
171
- height: (0, style_1.toPx)(height)
172
- })
173
- };
174
- }).withConfig({
175
- displayName: "FixedSizeContainer__FixSizeItem",
176
- componentId: "sc-1yhgpod-1"
177
- })(["position:relative;flex-direction:column;flex:1;display:flex;background-color:", "};"], function (props) {
178
- return (0, colorUtils_1.isColor)(props.backgroundColor) && props.backgroundColor || props.theme.defaultBackgroundColor;
179
- });
180
- var ItemContent = styled_components_1.default.div.withConfig({
181
- displayName: "FixedSizeContainer__ItemContent",
182
- componentId: "sc-1yhgpod-2"
183
- })(["position:relative;min-height:100px;width:100%;"]);
184
- var FixSizeItemContent = styled_components_1.default.div.withConfig({
185
- displayName: "FixedSizeContainer__FixSizeItemContent",
186
- componentId: "sc-1yhgpod-3"
187
- })(["min-height:0px;flex:1;position:relative;box-sizing:border-box;"]);
175
+ /***/ }),
176
+ /* 9 */
177
+ /***/ (function(module, exports) {
188
178
 
189
- var withFixedSizeContainer = function withFixedSizeContainer(Viz) {
190
- var FixedSizeContainer = function FixedSizeContainer(props) {
191
- var width = props.width,
192
- height = props.height,
193
- backgroundColor = props.backgroundColor;
179
+ module.exports = require("@babel/runtime/helpers/defineProperty");
194
180
 
195
- if (!height) {
196
- return React.createElement(Item, {
197
- "data-test": "item",
198
- width: width,
199
- backgroundColor: backgroundColor
200
- }, React.createElement(ItemContent, null, React.createElement(Viz, Object.assign({}, props))));
201
- }
181
+ /***/ }),
182
+ /* 10 */
183
+ /***/ (function(module, exports) {
202
184
 
203
- return React.createElement(FixSizeItem, {
204
- "data-test": "fix-size-item",
205
- "data-splunk-visualization-version": "26.1.2 - 9c7479612",
206
- width: width,
207
- height: height,
208
- backgroundColor: backgroundColor
209
- }, React.createElement(FixSizeItemContent, null, React.createElement(SizeAwareWrapper_1.default, null, function (_ref3) {
210
- var newWidth = _ref3.width,
211
- newHeight = _ref3.height;
212
- return React.createElement(Viz, Object.assign({}, props, {
213
- width: newWidth,
214
- height: newHeight
215
- }));
216
- })));
217
- };
185
+ module.exports = require("@babel/runtime/helpers/classCallCheck");
218
186
 
219
- FixedSizeContainer.displayName = 'withFixedSizeContainer';
220
- return FixedSizeContainer;
221
- };
187
+ /***/ }),
188
+ /* 11 */
189
+ /***/ (function(module, exports) {
222
190
 
223
- exports.default = withFixedSizeContainer;
191
+ module.exports = require("@splunk/visualizations-shared/numberUtils");
224
192
 
225
193
  /***/ }),
226
-
227
- /***/ 14:
194
+ /* 12 */
228
195
  /***/ (function(module, exports) {
229
196
 
230
- module.exports = require("@splunk/visualizations-shared/style");
197
+ module.exports = require("@splunk/visualizations-shared/Message");
231
198
 
232
199
  /***/ }),
200
+ /* 13 */
201
+ /***/ (function(module, exports) {
202
+
203
+ module.exports = require("@splunk/themes/variables");
233
204
 
234
- /***/ 15:
205
+ /***/ }),
206
+ /* 14 */
235
207
  /***/ (function(module, exports, __webpack_require__) {
236
208
 
237
209
  "use strict";
@@ -240,547 +212,655 @@ module.exports = require("@splunk/visualizations-shared/style");
240
212
  Object.defineProperty(exports, "__esModule", {
241
213
  value: true
242
214
  });
243
- exports.extendStaticWrapperProps = void 0;
244
- /**
245
- * @method extendStaticWrapperProps
246
- * @param {Object} props
247
- * @param {DashboardVizType} props.Wrapper
248
- * @param {DashboardVizType} props.Visualization
249
- */
250
-
251
- var extendStaticWrapperProps = function extendStaticWrapperProps(_ref) {
252
- var Wrapper = _ref.Wrapper,
253
- Visualization = _ref.Visualization;
254
- var extendProperties = ['propTypes', 'defaultProps', 'config'];
255
- extendProperties.forEach(function (prop) {
256
- if (Visualization[prop]) {
257
- // eslint-disable-next-line no-param-reassign
258
- Wrapper[prop] = Visualization[prop];
259
- }
260
- });
261
- };
215
+ exports.downsampleDataSources = exports.calculateDownsamplingThreshold = exports.calculateThresholdOnRangeSelect = exports.isDownsamplingEnabledForViz = exports.convertToArrOfObjects = void 0;
262
216
 
263
- exports.extendStaticWrapperProps = extendStaticWrapperProps;
217
+ var numberUtils_1 = __webpack_require__(11);
264
218
 
265
- /***/ }),
219
+ var interfaces_1 = __webpack_require__(40); // TODO: utilize this fn in ParallelCoordinates
266
220
 
267
- /***/ 153:
268
- /***/ (function(module, exports, __webpack_require__) {
269
221
 
270
- "use strict";
222
+ var convertToArrOfObjects = function convertToArrOfObjects(columns, fields) {
223
+ if (!columns || !columns[0] || !columns[0].length) return [];
224
+ var data = [];
271
225
 
226
+ var _loop = function _loop(i) {
227
+ var newObj = {};
228
+ fields.forEach(function (field, index) {
229
+ var fieldName = typeof field === 'string' ? field : field.name;
272
230
 
273
- var __rest = this && this.__rest || function (s, e) {
274
- var t = {};
231
+ if (columns[index][i] === '') {
232
+ newObj[fieldName] = null;
233
+ } else {
234
+ newObj[fieldName] = columns[index][i];
235
+ }
236
+ });
237
+ data.push(newObj);
238
+ };
275
239
 
276
- for (var p in s) {
277
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
240
+ for (var i = 0; i < columns[0].length; i += 1) {
241
+ _loop(i);
278
242
  }
279
243
 
280
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
281
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
282
- }
283
- return t;
244
+ return data;
284
245
  };
285
246
 
286
- Object.defineProperty(exports, "__esModule", {
287
- value: true
288
- });
289
- exports.config = exports.themes = exports.toImageDimensions = exports.shouldShowPlaceholder = void 0;
247
+ exports.convertToArrOfObjects = convertToArrOfObjects; // LTTB algorithm which can be used to downsample time series data while striving to maintain
248
+ // the spikes and overall shape of the chart
249
+ // Copied from https://github.com/sveinn-steinarsson/flot-downsample/blob/0815010016fc94b1bbc6a010afb8aad13ada6d0d/jquery.flot.downsample.js
250
+ // Modifications include:
251
+ // 1) Convert to modern JavaScript(use const, let, and use array.push to push to last element of array)
252
+ // 2) Convert to camel case
253
+ // 3) Convert to TS and also return the indices of the points that are in the downsampled result.
254
+ // 4) Add a new parameter preferredDownsampleIndices that correspond to the indices of points
255
+ // that should be used in case of a tie of the max area in a bucket
256
+
257
+ var largestTriangleThreeBuckets = function largestTriangleThreeBuckets(data, threshold, preferredDownsampleIndices) {
258
+ var dataLength = data.length;
259
+ var downsampledIndices = [];
260
+
261
+ if (threshold >= dataLength || threshold === 0) {
262
+ var allIndices = data.map(function (values, index) {
263
+ return index;
264
+ });
265
+ return {
266
+ downsampledData: data,
267
+ downsampledIndices: allIndices
268
+ }; // Nothing to do
269
+ }
290
270
 
291
- var lodash_1 = __webpack_require__(3);
271
+ var sampled = [];
272
+ var sampledIndex = 0; // Bucket size. Leave room for start and end data points
292
273
 
293
- var React = __webpack_require__(1);
274
+ var every = (dataLength - 2) / (threshold - 2);
275
+ var a = 0; // Initially a is the first point in the triangle
294
276
 
295
- var i18n_1 = __webpack_require__(2);
277
+ var maxAreaPoint;
278
+ var maxArea;
279
+ var area;
280
+ var nextA;
281
+ sampled.push(data[a]); // Always add the first point
296
282
 
297
- var style_1 = __webpack_require__(14);
283
+ downsampledIndices.push(0); // eslint-disable-next-line no-plusplus
298
284
 
299
- var RemoteImage_1 = __webpack_require__(154);
285
+ for (var i = 0; i < threshold - 2; i++) {
286
+ // Calculate point average for next bucket (containing c)
287
+ var avgX = 0;
288
+ var avgY = 0;
289
+ var avgRangeStart = Math.floor((i + 1) * every) + 1;
290
+ var avgRangeEnd = Math.floor((i + 2) * every) + 1;
291
+ avgRangeEnd = avgRangeEnd < dataLength ? avgRangeEnd : dataLength;
292
+ var avgRangeLength = avgRangeEnd - avgRangeStart; // eslint-disable-next-line no-plusplus
300
293
 
301
- var styled_components_1 = __webpack_require__(4);
294
+ for (; avgRangeStart < avgRangeEnd; avgRangeStart++) {
295
+ avgX += Number(data[avgRangeStart][0]); // * 1 enforces Number (value may be Date)
296
+
297
+ avgY += data[avgRangeStart][1] * 1;
298
+ }
302
299
 
303
- var T = __webpack_require__(0);
300
+ avgX /= avgRangeLength;
301
+ avgY /= avgRangeLength; // Get the range for this bucket
304
302
 
305
- var config_1 = __webpack_require__(222);
303
+ var rangeOffs = Math.floor((i + 0) * every) + 1;
304
+ var rangeTo = Math.floor((i + 1) * every) + 1; // Point a
306
305
 
307
- exports.config = config_1.default;
306
+ var pointAX = Number(data[a][0]); // Enforce Number (value may be Date)
308
307
 
309
- var withDashboardViz_1 = __webpack_require__(37);
308
+ var pointAY = data[a][1] * 1; // eslint-disable-next-line no-multi-assign
310
309
 
311
- var ImageApi_1 = __webpack_require__(223);
310
+ maxArea = area = -1;
311
+ var maxAreaIndex = rangeOffs; // eslint-disable-next-line no-plusplus
312
312
 
313
- var useEffect = React.useEffect,
314
- useRef = React.useRef;
315
- var validOptions = Object.keys(config_1.default.optionsSchema);
316
- var Container = styled_components_1.default.div.attrs(function () {
313
+ for (; rangeOffs < rangeTo; rangeOffs++) {
314
+ // Calculate triangle area over three buckets
315
+ area = Math.abs((pointAX - avgX) * (data[rangeOffs][1] - pointAY) - (pointAX - Number(data[rangeOffs][0])) * (avgY - pointAY)) * 0.5; // Modification: try to downsample the least amount of points possible when there are multiple series
316
+ // If all points in a bucket have the same area, prioritize the one with an x index
317
+ // that also existed from another series so we don't add another point unnecessarily.
318
+ // By default LTTB picks the leftmost point in the bucket
319
+
320
+ if (area > maxArea || area === maxArea && preferredDownsampleIndices.has(rangeOffs)) {
321
+ maxArea = area;
322
+ maxAreaPoint = data[rangeOffs];
323
+ nextA = rangeOffs; // Next a is this b
324
+ // Modification: save the index of the point with the most area
325
+
326
+ maxAreaIndex = rangeOffs;
327
+ }
328
+ } // eslint-disable-next-line no-plusplus
329
+
330
+
331
+ sampled[sampledIndex++] = maxAreaPoint; // Pick this point from the bucket
332
+
333
+ downsampledIndices.push(maxAreaIndex);
334
+ a = nextA; // This a is the next a (chosen b)
335
+ } // eslint-disable-next-line no-plusplus
336
+
337
+
338
+ sampled[sampledIndex++] = data[dataLength - 1]; // Always add last
339
+
340
+ downsampledIndices.push(dataLength - 1);
317
341
  return {
318
- 'data-test': 'image-container'
342
+ downsampledData: sampled,
343
+ downsampledIndices: downsampledIndices
319
344
  };
320
- }).withConfig({
321
- displayName: "Image__Container",
322
- componentId: "kplb09-0"
323
- })(["position:relative;box-sizing:border-box;display:flex;justify-content:center;align-items:center;cursor:", ";", ";"], function (props) {
324
- return props.onClick ? 'pointer' : 'inherit';
325
- }, function (props) {
326
- return (0, style_1.toDimension)((0, lodash_1.pick)(props, ['width', 'height']));
327
- });
345
+ };
346
+ /**
347
+ * Strictly coerces the entire column to numbers if it only consists of numeric strings or numbers. Also determines
348
+ * if at least one of the values in the column can be loosely coerced to a number.
349
+ * If the column cannot be strictly downsampled (if it contains nulls or non-numeric strings), returns an empty array and
350
+ * returns that it cannot downsample the column.
351
+ */
328
352
 
329
- var shouldShowPlaceholder = function shouldShowPlaceholder(dataSources, loading, options) {
330
- if (options.src) {
353
+
354
+ var strictlyCoerceYColumn = function strictlyCoerceYColumn(column) {
355
+ // Splunk charting allows for numbers in formats such as negative hex that
356
+ // Number() does not support and also allows loose coercion of hex numbers (but not other formats)
357
+ // We want to identify columns which contain at least one value that can be loosely coerced
358
+ var canLooselyCoerceSomeValues = column.findIndex(function (value) {
359
+ return (0, numberUtils_1.startsWithNumber)("".concat(value));
360
+ }) >= 0; // If not all values in column can be strictly coerced to a number, we do not downsample
361
+
362
+ var coercedColumn = [];
363
+ var canDownsampleColumn = !column.some(function (value) {
364
+ var coercedValue = Number(value); // if it can't be parsed or isn't safe, fail
365
+
366
+ if (Number.isNaN(coercedValue) || coercedValue <= Number.MIN_SAFE_INTEGER || coercedValue >= Number.MAX_SAFE_INTEGER || typeof value !== 'string' && typeof value !== 'number') {
367
+ return true;
368
+ } // save value and continue to next
369
+
370
+
371
+ coercedColumn.push(coercedValue);
331
372
  return false;
373
+ });
374
+ return {
375
+ canDownsampleColumn: canDownsampleColumn,
376
+ canLooselyCoerceSomeValues: canLooselyCoerceSomeValues,
377
+ coercedColumn: canDownsampleColumn ? coercedColumn : []
378
+ };
379
+ };
380
+ /**
381
+ * Tries to coerce the x-column to numbers or dates, if it is eligible for downsampling.
382
+ * Only strictly increasing x-columns are eligible for downsampling.
383
+ * If the column is not eligible for downsampling, returns an empty array.
384
+ */
385
+
386
+
387
+ var strictlyCoerceXColumn = function strictlyCoerceXColumn(column, fieldType) {
388
+ if (fieldType === 'number') {
389
+ var coercedXColumn = column.map(function (xValue) {
390
+ return Number(xValue);
391
+ });
392
+
393
+ if (isColumnStrictlyIncreasing(coercedXColumn, fieldType)) {
394
+ return coercedXColumn;
395
+ }
396
+ } else if (fieldType === 'time') {
397
+ var _coercedXColumn = column.map(function (xValue) {
398
+ return new Date(xValue);
399
+ });
400
+
401
+ if (isColumnStrictlyIncreasing(_coercedXColumn, fieldType)) {
402
+ return _coercedXColumn;
403
+ }
332
404
  }
333
405
 
334
- return true;
406
+ return [];
335
407
  };
336
408
 
337
- exports.shouldShowPlaceholder = shouldShowPlaceholder;
409
+ var isDownsamplingEnabledForViz = function isDownsamplingEnabledForViz(_ref) {
410
+ var vizConfig = _ref.vizConfig;
338
411
 
339
- var toImageDimensions = function toImageDimensions(props) {
340
- if (props.shouldPreserveAspectRatio) {
341
- return "\n max-width: 100%;\n max-height: 100%;\n width: auto;\n height: auto;\n ";
342
- }
412
+ var _a;
343
413
 
344
- return (0, style_1.toDimension)((0, lodash_1.pick)(props, ['width', 'height']));
414
+ return (_a = vizConfig.supports) === null || _a === void 0 ? void 0 : _a.includes(interfaces_1.VizBehavior.DOWNSAMPLING);
345
415
  };
346
416
 
347
- exports.toImageDimensions = toImageDimensions;
348
- var StyledImage = styled_components_1.default.img.withConfig({
349
- displayName: "Image__StyledImage",
350
- componentId: "kplb09-1"
351
- })(["display:block;", ";"], function (props) {
352
- return (0, exports.toImageDimensions)(props);
353
- });
417
+ exports.isDownsamplingEnabledForViz = isDownsamplingEnabledForViz;
354
418
 
355
- var computeVizProps = function computeVizProps(_a) {
356
- var visualizationApiRef = _a.visualizationApiRef,
357
- title = _a.title,
358
- otherOptions = __rest(_a, ["visualizationApiRef", "title"]);
419
+ var calculateThresholdOnRangeSelect = function calculateThresholdOnRangeSelect(_ref2) {
420
+ var firstIndex = _ref2.firstIndex,
421
+ lastIndex = _ref2.lastIndex,
422
+ dataSources = _ref2.dataSources,
423
+ width = _ref2.width;
359
424
 
360
- var options = (0, lodash_1.chain)(otherOptions).pick(validOptions).value();
361
- return {
362
- options: options,
363
- title: title,
364
- visualizationApiRef: visualizationApiRef
365
- };
425
+ var _a, _b, _c;
426
+
427
+ var window = lastIndex - firstIndex + 1;
428
+ var ratio = Math.round(Number(((_c = (_b = (_a = dataSources === null || dataSources === void 0 ? void 0 : dataSources.primary) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.columns[0]) === null || _c === void 0 ? void 0 : _c.length) / window) * 10) / 10;
429
+ return Math.round(ratio * Number(width));
366
430
  };
367
431
 
368
- var ImageVisualization = function ImageVisualization(_ref) {
369
- var height = _ref.height,
370
- width = _ref.width,
371
- _ref$title = _ref.title,
372
- title = _ref$title === void 0 ? '' : _ref$title,
373
- visualizationApiRef = _ref.visualizationApiRef,
374
- options = _ref.options,
375
- onImageClick = _ref.onImageClick;
376
- var src = options.src,
377
- preserveAspectRatio = options.preserveAspectRatio;
378
- var remoteImage = useRef(null);
379
- var api = useRef(new ImageApi_1.default({
380
- options: {
381
- src: src,
382
- preserveAspectRatio: preserveAspectRatio
383
- },
384
- remoteImage: remoteImage
385
- }));
386
- var isRemote = (0, RemoteImage_1.isRemoteImage)(src);
387
- useEffect(function () {
388
- visualizationApiRef(api.current);
389
- return function () {
390
- visualizationApiRef(null);
391
- };
392
- }, []);
393
- return React.createElement(Container, {
394
- width: width,
395
- height: height,
396
- onClick: onImageClick
397
- }, isRemote ? React.createElement(RemoteImage_1.default, {
398
- imageURL: src,
399
- title: title,
400
- preserveAspectRatio: preserveAspectRatio,
401
- width: width,
402
- height: height,
403
- ref: remoteImage
404
- }) : React.createElement(StyledImage, {
405
- "data-test": "image",
406
- src: src,
407
- shouldPreserveAspectRatio: preserveAspectRatio,
408
- width: width,
409
- height: height,
410
- alt: (0, i18n_1._)(title),
411
- onError: function onError(e) {
412
- e.target.alt = (0, i18n_1._)('Image not found');
413
- },
414
- referrerPolicy: "no-referrer"
415
- }));
416
- };
417
-
418
- var propTypes = {
419
- width: T.oneOfType([T.string, T.number]),
420
- height: T.oneOfType([T.string, T.number]),
421
- options: T.object,
422
- title: T.string,
423
- visualizationApiRef: T.func,
424
- onImageClick: T.func
425
- };
426
- var defaultProps = {
427
- width: '100%',
428
- height: undefined,
429
- options: {},
430
- title: '',
431
- visualizationApiRef: lodash_1.noop,
432
- onImageClick: lodash_1.noop
433
- };
434
- ImageVisualization.propTypes = propTypes;
435
- ImageVisualization.defaultProps = defaultProps;
436
- var Image = (0, withDashboardViz_1.default)({
437
- ReactViz: ImageVisualization,
438
- vizConfig: config_1.default,
439
- useIconPlaceholder: exports.shouldShowPlaceholder,
440
- computeVizProps: computeVizProps
441
- });
442
- var themes = null;
443
- exports.themes = themes;
444
- exports.default = Image;
432
+ exports.calculateThresholdOnRangeSelect = calculateThresholdOnRangeSelect;
433
+ /**
434
+ * Calculates the downsampling threshold based on the range selection. If search zoom is enabled or there is no selection,
435
+ * then returns the width of the visualization.
436
+ *
437
+ * Otherwise calculates the threshold based on the ratio of the window selected compared to the size of the non-downsampled
438
+ * data sources. Returns null if the chart event's dataset does not match the passed in primary data source or if the chart is zoomed
439
+ * in for a categorical chart.
440
+ */
445
441
 
446
- /***/ }),
442
+ var calculateDownsamplingThreshold = function calculateDownsamplingThreshold(_ref3) {
443
+ var enableSearchZoom = _ref3.enableSearchZoom,
444
+ dataSources = _ref3.dataSources,
445
+ selectChartEvent = _ref3.selectChartEvent,
446
+ width = _ref3.width,
447
+ xField = _ref3.xField,
448
+ y2Fields = _ref3.y2Fields;
447
449
 
448
- /***/ 154:
449
- /***/ (function(module, exports) {
450
+ var _a, _b, _c;
450
451
 
451
- module.exports = require("@splunk/visualizations-shared/RemoteImage");
452
+ if (enableSearchZoom || !selectChartEvent) {
453
+ return Number(width);
454
+ }
452
455
 
453
- /***/ }),
456
+ var primaryDataSource = dataSources === null || dataSources === void 0 ? void 0 : dataSources.primary;
454
457
 
455
- /***/ 16:
456
- /***/ (function(module, exports) {
458
+ if (!primaryDataSource) {
459
+ return null;
460
+ }
457
461
 
458
- module.exports = require("@splunk/visualizations-shared/schemaUtils");
462
+ var startXIndex = selectChartEvent.startXIndex,
463
+ endXIndex = selectChartEvent.endXIndex,
464
+ currentTarget = selectChartEvent.currentTarget;
459
465
 
460
- /***/ }),
466
+ try {
467
+ var xFieldIndex = (_a = primaryDataSource === null || primaryDataSource === void 0 ? void 0 : primaryDataSource.data) === null || _a === void 0 ? void 0 : _a.fields.findIndex(function (field) {
468
+ return field.name === xField;
469
+ });
470
+ var downsampledXFieldIndex = (_b = currentTarget.dataSet) === null || _b === void 0 ? void 0 : _b.fields.findIndex(function (field) {
471
+ return field === xField;
472
+ });
461
473
 
462
- /***/ 17:
463
- /***/ (function(module, exports) {
474
+ if (xFieldIndex === -1 || downsampledXFieldIndex === -1) {
475
+ return null;
476
+ }
464
477
 
465
- module.exports = require("@babel/runtime/helpers/slicedToArray");
478
+ var fullSeries = (_c = primaryDataSource === null || primaryDataSource === void 0 ? void 0 : primaryDataSource.data) === null || _c === void 0 ? void 0 : _c.columns[xFieldIndex];
479
+ var downsampledSeries = currentTarget.dataSet.seriesList[downsampledXFieldIndex];
480
+ var firstIndex = fullSeries.findIndex(function (x) {
481
+ return downsampledSeries[startXIndex] === x;
482
+ });
483
+ var lastIndex = fullSeries.findIndex(function (x) {
484
+ return downsampledSeries[endXIndex] === x;
485
+ }); // For charts with categorical x-axis (charts with an xField that isn't _time), do not support
486
+ // re-calculating downsampling threshold if the chart is zoomed in until SPL-259458 is fixed
487
+ // Also do not support re-calculating downsampling threshold for zoomed-in charts with y2
488
+ // until SPL-259611 is fixed
489
+
490
+ if (xField !== '_time' || (y2Fields === null || y2Fields === void 0 ? void 0 : y2Fields.length)) {
491
+ return firstIndex === 0 && lastIndex === fullSeries.length - 1 ? width : null;
492
+ }
466
493
 
467
- /***/ }),
494
+ if (firstIndex >= 0 && lastIndex >= 0 && firstIndex <= lastIndex) {
495
+ return (0, exports.calculateThresholdOnRangeSelect)({
496
+ firstIndex: firstIndex,
497
+ lastIndex: lastIndex,
498
+ dataSources: dataSources,
499
+ width: width
500
+ });
501
+ }
502
+ } catch (e) {
503
+ console.error('Error occurred while setting downsample threshold on range select event', e);
504
+ }
468
505
 
469
- /***/ 18:
470
- /***/ (function(module, exports) {
506
+ return null;
507
+ };
471
508
 
472
- module.exports = require("@babel/runtime/helpers/createClass");
509
+ exports.calculateDownsamplingThreshold = calculateDownsamplingThreshold;
473
510
 
474
- /***/ }),
511
+ var isColumnStrictlyIncreasing = function isColumnStrictlyIncreasing(column, fieldType) {
512
+ return column.every(function (value, index) {
513
+ if (fieldType === 'number') {
514
+ if (Number.isNaN(value)) {
515
+ return false;
516
+ }
517
+ }
475
518
 
476
- /***/ 19:
477
- /***/ (function(module, exports) {
519
+ if (fieldType === 'time') {
520
+ if (Number.isNaN(value.getTime())) {
521
+ return false;
522
+ }
523
+ }
478
524
 
479
- module.exports = require("@splunk/visualizations-shared/SizeAwareWrapper");
525
+ if (index === 0) {
526
+ return true;
527
+ }
480
528
 
481
- /***/ }),
529
+ return value > column[index - 1];
530
+ });
531
+ };
532
+ /**
533
+ * Verifies that all of the columns that are displayed in a chart can be downsampled. Valid columns that can be
534
+ * displayed are those that contain at least one number. We can only downsample columns that only consist of numbers.
535
+ *
536
+ * If all columns can be downsampled, returns the x column coerced to time/number and y columns coerced to numbers.
537
+ * If not all columns can be downsampled, then returns empty arrays for both x and y
538
+ */
482
539
 
483
- /***/ 2:
484
- /***/ (function(module, exports) {
485
540
 
486
- module.exports = require("@splunk/ui-utils/i18n");
541
+ var tryToCoerceAllDisplayedFields = function tryToCoerceAllDisplayedFields(ds, xField, yFields, fieldTypes) {
542
+ var xColumn = [];
543
+ var yColumns = [];
544
+ var canDownsample = !ds.data.fields.some(function (field, index) {
545
+ var _a, _b;
487
546
 
488
- /***/ }),
547
+ var fieldName = (_a = field.name) !== null && _a !== void 0 ? _a : field;
548
+ var fieldType = (_b = fieldTypes[index]) !== null && _b !== void 0 ? _b : 'unknown';
549
+ var column = ds.data.columns[index];
550
+ var hasDisplayedColumnThatCantBeDownsampled = false;
489
551
 
490
- /***/ 20:
491
- /***/ (function(module, exports, __webpack_require__) {
552
+ if (fieldName === xField) {
553
+ xColumn = strictlyCoerceXColumn(column, fieldType);
554
+ } else if (yFields.has(fieldName)) {
555
+ var _strictlyCoerceYColum = strictlyCoerceYColumn(ds.data.columns[index]),
556
+ coercedColumn = _strictlyCoerceYColum.coercedColumn,
557
+ canLooselyCoerceSomeValues = _strictlyCoerceYColum.canLooselyCoerceSomeValues,
558
+ canDownsampleColumn = _strictlyCoerceYColum.canDownsampleColumn; // do not perform downsampling if a column can possibly be displayed but cannot
559
+ // be downsampled using LTTB
492
560
 
493
- "use strict";
494
561
 
562
+ hasDisplayedColumnThatCantBeDownsampled = canLooselyCoerceSomeValues && !canDownsampleColumn;
495
563
 
496
- var _toConsumableArray = __webpack_require__(8);
564
+ if (hasDisplayedColumnThatCantBeDownsampled) {
565
+ return true;
566
+ }
497
567
 
498
- var _defineProperty = __webpack_require__(7);
568
+ if (canDownsampleColumn) {
569
+ yColumns.push(coercedColumn);
570
+ }
571
+ }
499
572
 
500
- var __rest = this && this.__rest || function (s, e) {
501
- var t = {};
573
+ return false;
574
+ });
502
575
 
503
- for (var p in s) {
504
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
576
+ if (canDownsample) {
577
+ return {
578
+ xColumn: xColumn,
579
+ yColumns: yColumns
580
+ };
505
581
  }
506
582
 
507
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
508
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
509
- }
510
- return t;
583
+ return {
584
+ xColumn: [],
585
+ yColumns: []
586
+ };
511
587
  };
512
588
 
513
- Object.defineProperty(exports, "__esModule", {
514
- value: true
515
- });
516
- exports.insertLayout = exports.isDynamicOption = exports.uncollapseEditorConfig = exports.generatePrecisionValues = exports.getInitialPreset = exports.enhanceOptionsSchemaWithDynamicOptions = exports.enhanceConfig = void 0;
589
+ var pickIndicesFromDataSource = function pickIndicesFromDataSource(ds, indices) {
590
+ var sortedIndices = Array.from(indices).sort(function (a, b) {
591
+ return a - b;
592
+ });
593
+ var slicedColumns = [];
594
+ ds.data.columns.forEach(function (column) {
595
+ var slicedColumn = [];
596
+ sortedIndices.forEach(function (index) {
597
+ slicedColumn.push(column[index]);
598
+ });
599
+ slicedColumns.push(slicedColumn);
600
+ }); // update data columns with downsampled columns
517
601
 
518
- var lodash_1 = __webpack_require__(3);
602
+ return Object.assign(Object.assign({}, ds), {
603
+ data: Object.assign(Object.assign({}, ds.data), {
604
+ columns: slicedColumns
605
+ })
606
+ });
607
+ };
519
608
 
520
- var schemaUtils_1 = __webpack_require__(16);
609
+ var downsampleDataSources = function downsampleDataSources(_ref4) {
610
+ var dataSources = _ref4.dataSources,
611
+ threshold = _ref4.threshold,
612
+ options = _ref4.options;
521
613
 
522
- var VizBehavior_1 = __webpack_require__(6);
614
+ var _a, _b, _c;
523
615
 
524
- var dynamicOptionsDSLType = {
525
- type: 'string',
526
- pattern: schemaUtils_1.DYNAMIC_OPTIONS_DSL_PATTERN
527
- };
528
- /**
529
- * Helper function to extend an options schema with dynamic options DSL
530
- * @param optionsSchema a visualization's options schema
531
- * @returns an updated options schema that additionally allows strings starting with > for each option
532
- */
616
+ var primaryDS = dataSources === null || dataSources === void 0 ? void 0 : dataSources.primary; // only downsample time series when number of data points are over threshold
533
617
 
534
- function enhanceOptionsSchemaWithDynamicOptions(optionsSchema) {
535
- var enhancedOptionsSchema = {};
536
- Object.keys(optionsSchema).forEach(function (key) {
537
- var _a = optionsSchema[key],
538
- title = _a.title,
539
- description = _a.description,
540
- readOnly = _a.readOnly,
541
- writeOnly = _a.writeOnly,
542
- examples = _a.examples,
543
- defaultValue = _a.default,
544
- type = _a.type,
545
- properties = _a.properties,
546
- patternProperties = _a.patternProperties,
547
- remainingSchemaEntry = __rest(_a, ["title", "description", "readOnly", "writeOnly", "examples", "default", "type", "properties", "patternProperties"]);
618
+ var numPoints = (_c = (_b = (_a = primaryDS === null || primaryDS === void 0 ? void 0 : primaryDS.data) === null || _a === void 0 ? void 0 : _a.columns[0]) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
548
619
 
549
- var annotations = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, title !== undefined && {
550
- title: title
551
- }), description !== undefined && {
552
- description: description
553
- }), readOnly !== undefined && {
554
- readOnly: readOnly
555
- }), writeOnly !== undefined && {
556
- writeOnly: writeOnly
557
- }), examples !== undefined && {
558
- examples: examples
559
- }), defaultValue !== undefined && {
560
- default: defaultValue
561
- });
620
+ if (Number.isNaN(threshold) || numPoints <= threshold || threshold < 2) {
621
+ return dataSources;
622
+ }
562
623
 
563
- if (type === 'object') {
564
- enhancedOptionsSchema[key] = Object.assign(Object.assign(Object.assign(Object.assign({}, remainingSchemaEntry), annotations), {
565
- type: type
566
- }), properties && {
567
- properties: enhanceOptionsSchemaWithDynamicOptions(properties)
568
- });
624
+ var xField = options.xField,
625
+ yFields = options.yFields,
626
+ fieldTypes = options.fieldTypes;
569
627
 
570
- if (patternProperties) {
571
- var enhancedPatternProperties = {};
572
- Object.keys(patternProperties).forEach(function (opt) {
573
- enhancedPatternProperties = Object.assign(Object.assign({}, enhancedPatternProperties), enhanceOptionsSchemaWithDynamicOptions(_defineProperty({}, opt, patternProperties[opt])));
574
- });
575
- enhancedOptionsSchema[key].patternProperties = enhancedPatternProperties;
576
- }
577
- } else {
578
- enhancedOptionsSchema[key] = Object.assign(Object.assign({}, annotations), {
579
- anyOf: [Object.assign(Object.assign({}, type !== undefined && {
580
- type: type
581
- }), remainingSchemaEntry), dynamicOptionsDSLType]
582
- });
583
- }
584
- });
585
- return enhancedOptionsSchema;
586
- }
628
+ if (!xField || !(yFields === null || yFields === void 0 ? void 0 : yFields.length) || !(fieldTypes === null || fieldTypes === void 0 ? void 0 : fieldTypes.length)) {
629
+ return dataSources;
630
+ }
587
631
 
588
- exports.enhanceOptionsSchemaWithDynamicOptions = enhanceOptionsSchemaWithDynamicOptions;
589
- /**
590
- * Helper function to enhance a Visualization Config as needed based on behaviors specified in supports block
591
- * this function also collapse all editor panels
592
- * @param vizConfig a Visualization Config
593
- * @returns an enhanced Visualization Config containing updated config entries based on behaviors it supports
594
- * and containing `open: false` for all editor panels in editorConfig
595
- */
632
+ var nonInternalYFields = new Set(yFields.filter(function (yField) {
633
+ return !yField.startsWith('_');
634
+ }));
635
+ var maxPointsInDownsample = Math.min(nonInternalYFields.size * threshold, numPoints); // Do not try to downsample if there are too many downsampled pts
636
+ // At the worst case, each series has non-overlapping downsampled pts
637
+ // which will mean that all points will be included in the downsampled result
638
+ // This will just lead to additional overhead due to coercing each
639
+ // x and y field to number
640
+
641
+ if (maxPointsInDownsample >= numPoints) {
642
+ return dataSources;
643
+ }
596
644
 
597
- function enhanceConfig(vizConfig) {
598
- var enhancedConfig = Object.assign({}, vizConfig);
645
+ var _tryToCoerceAllDispla = tryToCoerceAllDisplayedFields(primaryDS, xField, nonInternalYFields, fieldTypes),
646
+ xColumn = _tryToCoerceAllDispla.xColumn,
647
+ yColumns = _tryToCoerceAllDispla.yColumns;
599
648
 
600
- if (vizConfig.supports.indexOf(VizBehavior_1.VizBehavior.DYNAMIC_OPTIONS) !== -1) {
601
- enhancedConfig.optionsSchema = enhanceOptionsSchemaWithDynamicOptions(vizConfig.optionsSchema);
649
+ if (!yColumns.length || !xColumn.length) {
650
+ return dataSources;
602
651
  }
603
652
 
604
- enhancedConfig.editorConfig = vizConfig.editorConfig.map(function (config) {
605
- return Object.assign(Object.assign({}, config), {
606
- open: config.open || false
653
+ var downsampledDataSources = Object.assign({}, dataSources);
654
+ var downsampledIndices = new Set();
655
+ yColumns.forEach(function (yColumn, columnIndex) {
656
+ // perform LTTB downsampling for current series, LTTB takes an [x, y] pair
657
+ var xyPair = yColumn.map(function (yValue, index) {
658
+ return [xColumn[index], yValue];
607
659
  });
608
- });
609
- return enhancedConfig;
610
- }
611
660
 
612
- exports.enhanceConfig = enhanceConfig;
613
- /**
614
- * Helper function to uncollapse all editor panels by adding `open: true` to the editorConfig
615
- * Created for editor unit tests
616
- * @param vizConfig a Visualization Config
617
- * @returns a Visualization Config containing `open: true` for all editor panels in editorConfig
618
- */
661
+ try {
662
+ var _largestTriangleThree = largestTriangleThreeBuckets(xyPair, threshold, downsampledIndices),
663
+ downsampledIndicesForSeries = _largestTriangleThree.downsampledIndices;
619
664
 
620
- function uncollapseEditorConfig(vizConfig) {
621
- var editorPanelUncollapsedConfig = Object.assign({}, vizConfig);
622
- editorPanelUncollapsedConfig.editorConfig = vizConfig.editorConfig.map(function (config) {
623
- return Object.assign(Object.assign({}, config), {
624
- open: true
625
- });
626
- });
627
- return editorPanelUncollapsedConfig;
628
- }
665
+ downsampledIndicesForSeries.forEach(function (downsampleIndex) {
666
+ return downsampledIndices.add(downsampleIndex);
667
+ });
668
+ } catch (e) {
669
+ console.error("Error occurred while downsampling column ".concat(columnIndex), e);
670
+ }
671
+ }); // update data columns with downsampled columns
629
672
 
630
- exports.uncollapseEditorConfig = uncollapseEditorConfig;
673
+ downsampledDataSources.primary = pickIndicesFromDataSource(primaryDS, downsampledIndices);
674
+ return downsampledDataSources;
675
+ };
631
676
 
632
- function isDynamicOption(option) {
633
- return option && typeof option === 'string' && option.trim().startsWith('>') || false;
634
- }
677
+ exports.downsampleDataSources = downsampleDataSources;
635
678
 
636
- exports.isDynamicOption = isDynamicOption; // private helpers to improve readability of getInitialPreset
637
- // this shouldn't be tested since this util isn't something that we expect to use outside of getInitialPreset
679
+ /***/ }),
680
+ /* 15 */
681
+ /***/ (function(module, exports) {
638
682
 
639
- /**
640
- * this checks to make sure that all values within vizContext are compatible with the given preset's context to determine the initialPreset
641
- * if a preset has explicitly specified a key as being undefined, the vizContext must also has that key as undefined, or else this CANNOT be the initialPreset
642
- * the inverse is true; if a preset has key is NOT undefined, it must also be NOT undefined in the corresponding vizContext
643
- * the internal config contents are irrelevant (as the user could customize them in source), just as long as the presence of `undefined`s match up
644
- *
645
- * Since the presetConfigs have explicit undefined keys to override the existing config, we need to explicitly check the undefined values
646
- */
683
+ module.exports = require("@splunk/visualizations-shared/colorUtils");
647
684
 
648
- function hasCompatibleContexts(vizContext, presetContext) {
649
- var presetContextKeys = Object.keys(presetContext);
650
- return presetContextKeys.every(function (contextKey) {
651
- return presetContext[contextKey] === undefined && vizContext[contextKey] === undefined || presetContext[contextKey] !== undefined && vizContext[contextKey] !== undefined;
652
- });
653
- }
654
- /**
655
- * Checks to make sure that dynamic (non-dynamic) options in a given preset are also dynamic (non-dynamic) in the vizOptions
656
- */
685
+ /***/ }),
686
+ /* 16 */
687
+ /***/ (function(module, exports) {
657
688
 
689
+ module.exports = require("@splunk/visualization-encoding/Options");
658
690
 
659
- function hasCompatibleOptions(vizOptions, presetOptions) {
660
- var presetOptionKeys = Object.keys(presetOptions);
661
- return presetOptionKeys.every(function (optionKey) {
662
- return isDynamicOption(presetOptions[optionKey]) === isDynamicOption(vizOptions[optionKey]);
663
- });
664
- }
665
- /**
666
- * Evaluates whether there is an initialPreset that fits the current state of vizContext + vizOptions
667
- * This function ignores extraneous vizOptions or vizContext keys, as they could be outside the scope of what the preset is intended to configure
668
- *
669
- * @param {Object} vizContext - the current vizContext definition
670
- * @param {Object} vizOptions - the current vizOptions definition
671
- * @param {PresetEntry[]} presets - the list of presets, one of which can be considered an initialPreset
672
- */
691
+ /***/ }),
692
+ /* 17 */
693
+ /***/ (function(module, exports, __webpack_require__) {
673
694
 
695
+ "use strict";
674
696
 
675
- function getInitialPreset(vizContext, vizOptions, presets) {
676
- return presets.find(function (preset) {
677
- var presetContext = (0, lodash_1.get)(preset, ['value', 'context'], {});
678
- var presetOptions = (0, lodash_1.get)(preset, ['value', 'options'], {});
679
- var presetContextKeys = Object.keys(presetContext);
680
- var presetOptionKeys = Object.keys(presetOptions); // all presets have to explicitly specify which options to reset (i.e. need explicitly undefined keys)
681
- // if not, then the preset is invalid in config.ts
682
697
 
683
- if (presetContextKeys.length === 0 || presetOptionKeys.length === 0) return false;
684
- return hasCompatibleContexts(vizContext, presetContext) && hasCompatibleOptions(vizOptions, presetOptions);
685
- });
686
- }
698
+ var _slicedToArray = __webpack_require__(7);
687
699
 
688
- exports.getInitialPreset = getInitialPreset;
689
- /**
690
- * generates number precision values for a Select editor
691
- *
692
- * @param {Number} numPrecisionValues - number of integer precision values to generate
693
- * @returns {{ label: string; value; string }[]} array of { label, value } tuples
694
- */
700
+ Object.defineProperty(exports, "__esModule", {
701
+ value: true
702
+ });
695
703
 
696
- function generatePrecisionValues(numPrecisionValues) {
697
- return (0, lodash_1.range)(0, numPrecisionValues + 1).map(function (i) {
698
- return {
699
- label: "".concat(i, " (0").concat(i > 0 ? '.' : '').concat('0'.repeat(i), ")"),
700
- value: i
701
- };
702
- });
703
- }
704
+ var React = __webpack_require__(0);
704
705
 
705
- exports.generatePrecisionValues = generatePrecisionValues;
706
- /**
707
- * insert layout in layout array, return a new layout array instead of updating the original
708
- *
709
- * @param {EditorLayoutConfig[][]} layout - editor layout
710
- * @param {Number} index - the index to insert layout item(s)
711
- * @param {EditorLayoutConfig[][]} layoutItems - the item(s) to insert
712
- * @returns {EditorLayoutConfig[][]} new editor layout with insertion
713
- */
706
+ var styled_components_1 = __webpack_require__(4);
714
707
 
715
- var insertLayout = function insertLayout(layout, index) {
716
- for (var _len = arguments.length, layoutItems = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
717
- layoutItems[_key - 2] = arguments[_key];
718
- }
708
+ var style_1 = __webpack_require__(18);
719
709
 
720
- return [].concat(_toConsumableArray(layout.slice(0, index)), layoutItems, _toConsumableArray(layout.slice(index)));
710
+ var colorUtils_1 = __webpack_require__(15);
711
+
712
+ var SizeAwareWrapper_1 = __webpack_require__(26);
713
+
714
+ var Item = styled_components_1.default.div.attrs(function (_ref) {
715
+ var width = _ref.width;
716
+ return {
717
+ style: {
718
+ width: (0, style_1.toPx)(width)
719
+ }
720
+ };
721
+ }).withConfig({
722
+ displayName: "FixedSizeContainer__Item",
723
+ componentId: "sc-1yhgpod-0"
724
+ })(["position:relative;background-color:", "};"], function (props) {
725
+ return (0, colorUtils_1.isColor)(props.backgroundColor) && props.backgroundColor || props.theme.defaultBackgroundColor;
726
+ }); // Use `.attrs()` for highly dynamic styles. Ref: https://github.com/styled-components/styled-components/issues/134#issuecomment-312415291
727
+
728
+ var FixSizeItem = styled_components_1.default.div.attrs(function (_ref2) {
729
+ var width = _ref2.width,
730
+ height = _ref2.height;
731
+ return {
732
+ style: Object.assign(Object.assign({}, width && {
733
+ width: (0, style_1.toPx)(width)
734
+ }), height && {
735
+ height: (0, style_1.toPx)(height)
736
+ })
737
+ };
738
+ }).withConfig({
739
+ displayName: "FixedSizeContainer__FixSizeItem",
740
+ componentId: "sc-1yhgpod-1"
741
+ })(["position:relative;flex-direction:column;flex:1;display:flex;background-color:", "};"], function (props) {
742
+ return (0, colorUtils_1.isColor)(props.backgroundColor) && props.backgroundColor || props.theme.defaultBackgroundColor;
743
+ });
744
+ var ItemContent = styled_components_1.default.div.withConfig({
745
+ displayName: "FixedSizeContainer__ItemContent",
746
+ componentId: "sc-1yhgpod-2"
747
+ })(["position:relative;min-height:100px;width:100%;"]);
748
+ var FixSizeItemContent = styled_components_1.default.div.withConfig({
749
+ displayName: "FixedSizeContainer__FixSizeItemContent",
750
+ componentId: "sc-1yhgpod-3"
751
+ })(["min-height:0px;flex:1;position:relative;box-sizing:border-box;"]);
752
+
753
+ var withFixedSizeContainer = function withFixedSizeContainer(Viz) {
754
+ var FixedSizeContainer = function FixedSizeContainer(props) {
755
+ var width = props.width,
756
+ height = props.height,
757
+ backgroundColor = props.backgroundColor;
758
+ var cachedHandleResize = React.useCallback(function (w, h) {
759
+ setContainerWidth(w);
760
+ setContainerHeight(h);
761
+ }, []);
762
+
763
+ var _React$useState = React.useState(Number(props.width)),
764
+ _React$useState2 = _slicedToArray(_React$useState, 2),
765
+ containerWidth = _React$useState2[0],
766
+ setContainerWidth = _React$useState2[1];
767
+
768
+ var _React$useState3 = React.useState(Number(props.height)),
769
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
770
+ containerHeight = _React$useState4[0],
771
+ setContainerHeight = _React$useState4[1];
772
+
773
+ if (!height) {
774
+ return React.createElement(Item, {
775
+ "data-test": "item",
776
+ width: width,
777
+ backgroundColor: backgroundColor
778
+ }, React.createElement(ItemContent, null, React.createElement(Viz, Object.assign({}, props))));
779
+ }
780
+
781
+ return React.createElement(FixSizeItem, {
782
+ "data-test": "fix-size-item",
783
+ "data-splunk-visualization-version": "26.2.0 - 49b909915",
784
+ width: width,
785
+ height: height,
786
+ backgroundColor: backgroundColor
787
+ }, React.createElement(FixSizeItemContent, null, React.createElement(SizeAwareWrapper_1.default, {
788
+ width: width,
789
+ height: height,
790
+ onResize: cachedHandleResize
791
+ }), React.createElement(Viz, Object.assign({}, props, {
792
+ width: containerWidth,
793
+ height: containerHeight
794
+ }))));
795
+ };
796
+
797
+ FixedSizeContainer.displayName = 'withFixedSizeContainer';
798
+ return FixedSizeContainer;
721
799
  };
722
800
 
723
- exports.insertLayout = insertLayout;
801
+ exports.default = withFixedSizeContainer;
724
802
 
725
803
  /***/ }),
726
-
727
- /***/ 21:
804
+ /* 18 */
728
805
  /***/ (function(module, exports) {
729
806
 
730
- module.exports = require("@splunk/visualization-context/FeatureFlagContext");
807
+ module.exports = require("@splunk/visualizations-shared/style");
731
808
 
732
809
  /***/ }),
733
-
734
- /***/ 221:
810
+ /* 19 */
735
811
  /***/ (function(module, exports, __webpack_require__) {
736
812
 
737
813
  "use strict";
738
814
 
739
815
 
740
- var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
741
- if (k2 === undefined) k2 = k;
742
- var desc = Object.getOwnPropertyDescriptor(m, k);
816
+ Object.defineProperty(exports, "__esModule", {
817
+ value: true
818
+ });
819
+ exports.validOutputModes = exports.validSegmentationModes = exports.validSortDirs = void 0;
820
+ exports.validSortDirs = ['asc', 'desc', 'none'];
821
+ exports.validSegmentationModes = ['none', 'inner'];
822
+ exports.validOutputModes = ['json_cols', 'json'];
743
823
 
744
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
745
- desc = {
746
- enumerable: true,
747
- get: function get() {
748
- return m[k];
749
- }
750
- };
751
- }
824
+ /***/ }),
825
+ /* 20 */,
826
+ /* 21 */
827
+ /***/ (function(module, exports, __webpack_require__) {
752
828
 
753
- Object.defineProperty(o, k2, desc);
754
- } : function (o, m, k, k2) {
755
- if (k2 === undefined) k2 = k;
756
- o[k2] = m[k];
757
- });
829
+ "use strict";
758
830
 
759
- var __exportStar = this && this.__exportStar || function (m, exports) {
760
- for (var p in m) {
761
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
762
- }
763
- };
831
+
832
+ var _classCallCheck = __webpack_require__(10);
833
+
834
+ var _createClass = __webpack_require__(25);
764
835
 
765
836
  Object.defineProperty(exports, "__esModule", {
766
837
  value: true
767
838
  });
768
- exports.default = void 0;
839
+ exports.DefaultVizActionHandler = void 0;
840
+
841
+ var DefaultVizActionHandler = /*#__PURE__*/function () {
842
+ function DefaultVizActionHandler() {
843
+ _classCallCheck(this, DefaultVizActionHandler);
844
+ }
769
845
 
770
- __exportStar(__webpack_require__(153), exports);
846
+ _createClass(DefaultVizActionHandler, [{
847
+ key: "focus",
848
+ value: function focus() {// noop
849
+ }
850
+ }, {
851
+ key: "snapshot",
852
+ value: function snapshot() {
853
+ return null; // noop
854
+ }
855
+ }]);
771
856
 
772
- var Image_1 = __webpack_require__(153);
857
+ return DefaultVizActionHandler;
858
+ }();
773
859
 
774
- Object.defineProperty(exports, "default", {
775
- enumerable: true,
776
- get: function get() {
777
- return Image_1.default;
778
- }
779
- });
860
+ exports.DefaultVizActionHandler = DefaultVizActionHandler;
780
861
 
781
862
  /***/ }),
782
-
783
- /***/ 222:
863
+ /* 22 */
784
864
  /***/ (function(module, exports, __webpack_require__) {
785
865
 
786
866
  "use strict";
@@ -789,252 +869,419 @@ Object.defineProperty(exports, "default", {
789
869
  Object.defineProperty(exports, "__esModule", {
790
870
  value: true
791
871
  });
872
+ exports.VizCategory = void 0;
873
+ var VizCategory;
792
874
 
793
- var i18n_1 = __webpack_require__(2);
875
+ (function (VizCategory) {
876
+ VizCategory["SINGLE_VALUE"] = "Single Value";
877
+ VizCategory["TRENDS"] = "Trends";
878
+ VizCategory["COMPARISONS"] = "Comparisons";
879
+ VizCategory["TABLE"] = "Table";
880
+ VizCategory["GAUGE"] = "Gauge";
881
+ VizCategory["DISTRIBUTIONS"] = "Distributions";
882
+ VizCategory["CHOROPLETH"] = "Choropleth Maps";
883
+ VizCategory["SHAPES"] = "Shapes";
884
+ VizCategory["MISC"] = "misc";
885
+ VizCategory["FLOW"] = "Flow";
886
+ VizCategory["CORRELATION"] = "Correlation";
887
+ VizCategory["SPATIAL"] = "Spatial";
888
+ })(VizCategory = exports.VizCategory || (exports.VizCategory = {}));
794
889
 
795
- var visualization_icons_1 = __webpack_require__(52);
890
+ /***/ }),
891
+ /* 23 */
892
+ /***/ (function(module, exports, __webpack_require__) {
796
893
 
797
- var VizBehavior_1 = __webpack_require__(6);
894
+ "use strict";
798
895
 
799
- var VizCategory_1 = __webpack_require__(36);
800
896
 
801
- var configUtils_1 = __webpack_require__(20);
897
+ Object.defineProperty(exports, "__esModule", {
898
+ value: true
899
+ });
900
+ exports.extendStaticWrapperProps = void 0;
901
+ /**
902
+ * @method extendStaticWrapperProps
903
+ * @param {Object} props
904
+ * @param {DashboardVizType} props.Wrapper
905
+ * @param {DashboardVizType} props.Visualization
906
+ */
802
907
 
803
- var dataContract = {
804
- requiredDataSources: [],
805
- optionalDataSources: [// Note: SCP-14090 disable ui for optional datasources. We may need to add it back later
806
- // {
807
- // name: 'annotation',
808
- // description: 'DataSource that populate event annotations',
809
- // },
810
- ],
811
- initialRequestParams: {}
812
- };
813
- var size = {
814
- initialWidth: 300,
815
- initialHeight: 300
816
- };
817
- var defaultContext = {};
818
- var optionsSchema = {
819
- src: {
820
- description: 'URL of an image file. All browser-supported image formats are acceptable.',
821
- type: 'string'
822
- },
823
- preserveAspectRatio: {
824
- default: false,
825
- description: 'Set to true to maintain the aspect ratio of an image when the screen is resized.',
826
- type: 'boolean'
827
- }
828
- };
829
- var editorConfig = [{
830
- label: (0, i18n_1._)('Image content'),
831
- layout: [[{
832
- label: (0, i18n_1._)('Image file'),
833
- option: 'src',
834
- editor: 'editor.image'
835
- }], [{
836
- label: (0, i18n_1._)('Preserve aspect ratio'),
837
- option: 'preserveAspectRatio',
838
- editor: 'editor.checkbox',
839
- showEditor: function showEditor(_ref) {
840
- var options = _ref.options;
841
- return !!options.src;
842
- }
843
- }]]
844
- }];
845
- var themes = {};
846
- /**
847
- * visualization configuration
848
- */
849
-
850
- var config = {
851
- /**
852
- * unique viz key
853
- */
854
- key: 'splunk.image',
855
-
856
- /**
857
- * viz name
858
- */
859
- name: (0, i18n_1._)('Image'),
860
- category: VizCategory_1.VizCategory.MISC,
861
-
862
- /**
863
- * viz icon
864
- */
865
- icon: visualization_icons_1.Image,
866
- dataContract: dataContract,
867
- size: size,
868
- defaultContext: defaultContext,
869
- optionsSchema: optionsSchema,
870
- editorConfig: editorConfig,
871
- supports: [VizBehavior_1.VizBehavior.DYNAMIC_OPTIONS, VizBehavior_1.VizBehavior.PLACEHOLDER, VizBehavior_1.VizBehavior.EVENTS],
872
- themes: themes,
873
- events: {
874
- 'image.click': {
875
- description: 'triggered when user clicks on the image'
908
+ var extendStaticWrapperProps = function extendStaticWrapperProps(_ref) {
909
+ var Wrapper = _ref.Wrapper,
910
+ Visualization = _ref.Visualization;
911
+ var extendProperties = ['propTypes', 'defaultProps', 'config'];
912
+ extendProperties.forEach(function (prop) {
913
+ if (Visualization[prop]) {
914
+ // eslint-disable-next-line no-param-reassign
915
+ Wrapper[prop] = Visualization[prop];
876
916
  }
877
- }
917
+ });
878
918
  };
879
- exports.default = (0, configUtils_1.enhanceConfig)(config);
880
-
881
- /***/ }),
882
-
883
- /***/ 223:
884
- /***/ (function(module, exports, __webpack_require__) {
885
-
886
- "use strict";
887
-
888
-
889
- var _classCallCheck = __webpack_require__(9);
890
-
891
- var _createClass = __webpack_require__(18);
892
-
893
- Object.defineProperty(exports, "__esModule", {
894
- value: true
895
- });
896
-
897
- var lodash_1 = __webpack_require__(3);
898
-
899
- var RemoteImage_1 = __webpack_require__(154);
900
- /**
901
- * Image Api
902
- */
903
-
904
-
905
- var ImageApi = /*#__PURE__*/function () {
906
- function ImageApi(viz) {
907
- _classCallCheck(this, ImageApi);
908
-
909
- this.viz = viz;
910
- }
911
- /**
912
- * put focus on the visualization
913
- */
914
- // eslint-disable-next-line class-methods-use-this
915
-
916
-
917
- _createClass(ImageApi, [{
918
- key: "focus",
919
- value: function focus() {}
920
- /**
921
- * return snapshot of that includes inlined image
922
- */
923
-
924
- }, {
925
- key: "snapshot",
926
- value: function snapshot() {
927
- var srcFromOptions = (0, lodash_1.get)(this.viz.options, 'src', '');
928
- var isRemote = (0, RemoteImage_1.isRemoteImage)(srcFromOptions);
929
- return {
930
- options: Object.assign(Object.assign({}, this.viz.options), {
931
- src: isRemote && this.viz.remoteImage ? (0, lodash_1.get)(this.viz.remoteImage, ['current', 'state', 'imageDataURI'], '') : srcFromOptions
932
- })
933
- };
934
- }
935
- }]);
936
-
937
- return ImageApi;
938
- }();
939
-
940
- exports.default = ImageApi;
941
-
942
- /***/ }),
943
-
944
- /***/ 25:
945
- /***/ (function(module, exports) {
946
919
 
947
- module.exports = require("@splunk/ui-utils/id");
920
+ exports.extendStaticWrapperProps = extendStaticWrapperProps;
948
921
 
949
922
  /***/ }),
950
-
951
- /***/ 26:
923
+ /* 24 */
952
924
  /***/ (function(module, exports) {
953
925
 
954
- module.exports = require("@splunk/visualization-context/TimezoneContext");
926
+ module.exports = require("@splunk/visualizations-shared/schemaUtils");
955
927
 
956
928
  /***/ }),
957
-
958
- /***/ 27:
929
+ /* 25 */
959
930
  /***/ (function(module, exports) {
960
931
 
961
- module.exports = require("@splunk/visualizations-shared/hocUtils");
932
+ module.exports = require("@babel/runtime/helpers/createClass");
962
933
 
963
934
  /***/ }),
964
-
965
- /***/ 28:
935
+ /* 26 */
966
936
  /***/ (function(module, exports) {
967
937
 
968
- module.exports = require("@splunk/visualizations-shared/JSONSchemaUtils");
938
+ module.exports = require("@splunk/visualizations-shared/SizeAwareWrapper");
969
939
 
970
940
  /***/ }),
941
+ /* 27 */
942
+ /***/ (function(module, exports, __webpack_require__) {
971
943
 
972
- /***/ 3:
973
- /***/ (function(module, exports) {
974
-
975
- module.exports = require("lodash");
976
-
977
- /***/ }),
944
+ "use strict";
978
945
 
979
- /***/ 30:
980
- /***/ (function(module, exports) {
981
946
 
982
- module.exports = require("@splunk/visualization-encoding/Options");
947
+ var _toConsumableArray = __webpack_require__(8);
983
948
 
984
- /***/ }),
949
+ var _defineProperty = __webpack_require__(9);
985
950
 
986
- /***/ 32:
987
- /***/ (function(module, exports, __webpack_require__) {
951
+ var __rest = this && this.__rest || function (s, e) {
952
+ var t = {};
988
953
 
989
- "use strict";
954
+ for (var p in s) {
955
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
956
+ }
990
957
 
958
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
959
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
960
+ }
961
+ return t;
962
+ };
991
963
 
992
964
  Object.defineProperty(exports, "__esModule", {
993
965
  value: true
994
966
  });
995
- exports.shouldShowIconPlaceholder = void 0;
996
-
997
- var React = __webpack_require__(1);
998
-
999
- var T = __webpack_require__(0);
967
+ exports.insertLayout = exports.isDynamicOption = exports.uncollapseEditorConfig = exports.generatePrecisionValues = exports.getInitialPreset = exports.enhanceOptionsSchemaWithDynamicOptions = exports.enhanceConfig = void 0;
1000
968
 
1001
969
  var lodash_1 = __webpack_require__(3);
1002
970
 
1003
- var i18n_1 = __webpack_require__(2);
971
+ var schemaUtils_1 = __webpack_require__(24);
1004
972
 
1005
- var Message_1 = __webpack_require__(10);
973
+ var VizBehavior_1 = __webpack_require__(6);
1006
974
 
1007
- var FixedSizeContainer_1 = __webpack_require__(13);
975
+ var dynamicOptionsDSLType = {
976
+ type: 'string',
977
+ pattern: schemaUtils_1.DYNAMIC_OPTIONS_DSL_PATTERN
978
+ };
1008
979
  /**
1009
- * @method shouldShowIconPlaceholder
1010
- * @param {object} dataSources
1011
- * @param {boolean} loading
1012
- * @returns {boolean}
980
+ * Helper function to extend an options schema with dynamic options DSL
981
+ * @param optionsSchema a visualization's options schema
982
+ * @returns an updated options schema that additionally allows strings starting with > for each option
1013
983
  */
1014
984
 
985
+ function enhanceOptionsSchemaWithDynamicOptions(optionsSchema) {
986
+ var enhancedOptionsSchema = {};
987
+ Object.keys(optionsSchema).forEach(function (key) {
988
+ var _a = optionsSchema[key],
989
+ title = _a.title,
990
+ description = _a.description,
991
+ readOnly = _a.readOnly,
992
+ writeOnly = _a.writeOnly,
993
+ examples = _a.examples,
994
+ defaultValue = _a.default,
995
+ type = _a.type,
996
+ properties = _a.properties,
997
+ patternProperties = _a.patternProperties,
998
+ remainingSchemaEntry = __rest(_a, ["title", "description", "readOnly", "writeOnly", "examples", "default", "type", "properties", "patternProperties"]);
999
+
1000
+ var annotations = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, title !== undefined && {
1001
+ title: title
1002
+ }), description !== undefined && {
1003
+ description: description
1004
+ }), readOnly !== undefined && {
1005
+ readOnly: readOnly
1006
+ }), writeOnly !== undefined && {
1007
+ writeOnly: writeOnly
1008
+ }), examples !== undefined && {
1009
+ examples: examples
1010
+ }), defaultValue !== undefined && {
1011
+ default: defaultValue
1012
+ });
1015
1013
 
1016
- var shouldShowIconPlaceholder = function shouldShowIconPlaceholder(dataSources) {
1017
- var loading = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1018
- var data = (0, lodash_1.get)(dataSources, 'primary.data.columns[0]', undefined);
1019
- var noData = data === undefined;
1020
- var fields = (0, lodash_1.get)(dataSources, 'primary.data.fields[0]', undefined);
1021
- var noFields = fields === undefined;
1022
- return loading || noData || noFields;
1023
- };
1014
+ if (type === 'object') {
1015
+ enhancedOptionsSchema[key] = Object.assign(Object.assign(Object.assign(Object.assign({}, remainingSchemaEntry), annotations), {
1016
+ type: type
1017
+ }), properties && {
1018
+ properties: enhanceOptionsSchemaWithDynamicOptions(properties)
1019
+ });
1024
1020
 
1025
- exports.shouldShowIconPlaceholder = shouldShowIconPlaceholder;
1026
- var propTypes = {
1027
- icon: T.func,
1028
- width: T.oneOfType([T.string, T.number]),
1029
- height: T.oneOfType([T.string, T.number]),
1030
- // eslint-disable-next-line react/no-unused-prop-types
1031
- backgroundColor: T.string,
1032
- iconColor: T.string
1033
- };
1021
+ if (patternProperties) {
1022
+ var enhancedPatternProperties = {};
1023
+ Object.keys(patternProperties).forEach(function (opt) {
1024
+ enhancedPatternProperties = Object.assign(Object.assign({}, enhancedPatternProperties), enhanceOptionsSchemaWithDynamicOptions(_defineProperty({}, opt, patternProperties[opt])));
1025
+ });
1026
+ enhancedOptionsSchema[key].patternProperties = enhancedPatternProperties;
1027
+ }
1028
+ } else {
1029
+ enhancedOptionsSchema[key] = Object.assign(Object.assign({}, annotations), {
1030
+ anyOf: [Object.assign(Object.assign({}, type !== undefined && {
1031
+ type: type
1032
+ }), remainingSchemaEntry), dynamicOptionsDSLType]
1033
+ });
1034
+ }
1035
+ });
1036
+ return enhancedOptionsSchema;
1037
+ }
1038
+
1039
+ exports.enhanceOptionsSchemaWithDynamicOptions = enhanceOptionsSchemaWithDynamicOptions;
1034
1040
  /**
1035
- * @method IconPlaceholder
1036
- * @param {IconPlaceholderProps} props
1037
- * @returns {React.ReactElement}
1041
+ * Helper function to enhance a Visualization Config as needed based on behaviors specified in supports block
1042
+ * this function also collapse all editor panels
1043
+ * @param vizConfig a Visualization Config
1044
+ * @returns an enhanced Visualization Config containing updated config entries based on behaviors it supports
1045
+ * and containing `open: false` for all editor panels in editorConfig
1046
+ */
1047
+
1048
+ function enhanceConfig(vizConfig) {
1049
+ var enhancedConfig = Object.assign({}, vizConfig);
1050
+
1051
+ if (vizConfig.supports.indexOf(VizBehavior_1.VizBehavior.DYNAMIC_OPTIONS) !== -1) {
1052
+ enhancedConfig.optionsSchema = enhanceOptionsSchemaWithDynamicOptions(vizConfig.optionsSchema);
1053
+ }
1054
+
1055
+ enhancedConfig.editorConfig = vizConfig.editorConfig.map(function (config) {
1056
+ return Object.assign(Object.assign({}, config), {
1057
+ open: config.open || false
1058
+ });
1059
+ });
1060
+ return enhancedConfig;
1061
+ }
1062
+
1063
+ exports.enhanceConfig = enhanceConfig;
1064
+ /**
1065
+ * Helper function to uncollapse all editor panels by adding `open: true` to the editorConfig
1066
+ * Created for editor unit tests
1067
+ * @param vizConfig a Visualization Config
1068
+ * @returns a Visualization Config containing `open: true` for all editor panels in editorConfig
1069
+ */
1070
+
1071
+ function uncollapseEditorConfig(vizConfig) {
1072
+ var editorPanelUncollapsedConfig = Object.assign({}, vizConfig);
1073
+ editorPanelUncollapsedConfig.editorConfig = vizConfig.editorConfig.map(function (config) {
1074
+ return Object.assign(Object.assign({}, config), {
1075
+ open: true
1076
+ });
1077
+ });
1078
+ return editorPanelUncollapsedConfig;
1079
+ }
1080
+
1081
+ exports.uncollapseEditorConfig = uncollapseEditorConfig;
1082
+
1083
+ function isDynamicOption(option) {
1084
+ return option && typeof option === 'string' && option.trim().startsWith('>') || false;
1085
+ }
1086
+
1087
+ exports.isDynamicOption = isDynamicOption; // private helpers to improve readability of getInitialPreset
1088
+ // this shouldn't be tested since this util isn't something that we expect to use outside of getInitialPreset
1089
+
1090
+ /**
1091
+ * this checks to make sure that all values within vizContext are compatible with the given preset's context to determine the initialPreset
1092
+ * if a preset has explicitly specified a key as being undefined, the vizContext must also has that key as undefined, or else this CANNOT be the initialPreset
1093
+ * the inverse is true; if a preset has key is NOT undefined, it must also be NOT undefined in the corresponding vizContext
1094
+ * the internal config contents are irrelevant (as the user could customize them in source), just as long as the presence of `undefined`s match up
1095
+ *
1096
+ * Since the presetConfigs have explicit undefined keys to override the existing config, we need to explicitly check the undefined values
1097
+ */
1098
+
1099
+ function hasCompatibleContexts(vizContext, presetContext) {
1100
+ var presetContextKeys = Object.keys(presetContext);
1101
+ return presetContextKeys.every(function (contextKey) {
1102
+ return presetContext[contextKey] === undefined && vizContext[contextKey] === undefined || presetContext[contextKey] !== undefined && vizContext[contextKey] !== undefined;
1103
+ });
1104
+ }
1105
+ /**
1106
+ * Checks to make sure that dynamic (non-dynamic) options in a given preset are also dynamic (non-dynamic) in the vizOptions
1107
+ */
1108
+
1109
+
1110
+ function hasCompatibleOptions(vizOptions, presetOptions) {
1111
+ var presetOptionKeys = Object.keys(presetOptions);
1112
+ return presetOptionKeys.every(function (optionKey) {
1113
+ return isDynamicOption(presetOptions[optionKey]) === isDynamicOption(vizOptions[optionKey]);
1114
+ });
1115
+ }
1116
+ /**
1117
+ * Evaluates whether there is an initialPreset that fits the current state of vizContext + vizOptions
1118
+ * This function ignores extraneous vizOptions or vizContext keys, as they could be outside the scope of what the preset is intended to configure
1119
+ *
1120
+ * @param {Object} vizContext - the current vizContext definition
1121
+ * @param {Object} vizOptions - the current vizOptions definition
1122
+ * @param {PresetEntry[]} presets - the list of presets, one of which can be considered an initialPreset
1123
+ */
1124
+
1125
+
1126
+ function getInitialPreset(vizContext, vizOptions, presets) {
1127
+ return presets.find(function (preset) {
1128
+ var presetContext = (0, lodash_1.get)(preset, ['value', 'context'], {});
1129
+ var presetOptions = (0, lodash_1.get)(preset, ['value', 'options'], {});
1130
+ var presetContextKeys = Object.keys(presetContext);
1131
+ var presetOptionKeys = Object.keys(presetOptions); // all presets have to explicitly specify which options to reset (i.e. need explicitly undefined keys)
1132
+ // if not, then the preset is invalid in config.ts
1133
+
1134
+ if (presetContextKeys.length === 0 || presetOptionKeys.length === 0) return false;
1135
+ return hasCompatibleContexts(vizContext, presetContext) && hasCompatibleOptions(vizOptions, presetOptions);
1136
+ });
1137
+ }
1138
+
1139
+ exports.getInitialPreset = getInitialPreset;
1140
+ /**
1141
+ * generates number precision values for a Select editor
1142
+ *
1143
+ * @param {Number} numPrecisionValues - number of integer precision values to generate
1144
+ * @returns {{ label: string; value; string }[]} array of { label, value } tuples
1145
+ */
1146
+
1147
+ function generatePrecisionValues(numPrecisionValues) {
1148
+ return (0, lodash_1.range)(0, numPrecisionValues + 1).map(function (i) {
1149
+ return {
1150
+ label: "".concat(i, " (0").concat(i > 0 ? '.' : '').concat('0'.repeat(i), ")"),
1151
+ value: i
1152
+ };
1153
+ });
1154
+ }
1155
+
1156
+ exports.generatePrecisionValues = generatePrecisionValues;
1157
+ /**
1158
+ * insert layout in layout array, return a new layout array instead of updating the original
1159
+ *
1160
+ * @param {EditorLayoutConfig[][]} layout - editor layout
1161
+ * @param {Number} index - the index to insert layout item(s)
1162
+ * @param {EditorLayoutConfig[][]} layoutItems - the item(s) to insert
1163
+ * @returns {EditorLayoutConfig[][]} new editor layout with insertion
1164
+ */
1165
+
1166
+ var insertLayout = function insertLayout(layout, index) {
1167
+ for (var _len = arguments.length, layoutItems = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
1168
+ layoutItems[_key - 2] = arguments[_key];
1169
+ }
1170
+
1171
+ return [].concat(_toConsumableArray(layout.slice(0, index)), layoutItems, _toConsumableArray(layout.slice(index)));
1172
+ };
1173
+
1174
+ exports.insertLayout = insertLayout;
1175
+
1176
+ /***/ }),
1177
+ /* 28 */
1178
+ /***/ (function(module, exports) {
1179
+
1180
+ module.exports = require("@splunk/visualization-context/FeatureFlagContext");
1181
+
1182
+ /***/ }),
1183
+ /* 29 */,
1184
+ /* 30 */,
1185
+ /* 31 */
1186
+ /***/ (function(module, exports) {
1187
+
1188
+ module.exports = require("@splunk/ui-utils/id");
1189
+
1190
+ /***/ }),
1191
+ /* 32 */
1192
+ /***/ (function(module, exports) {
1193
+
1194
+ module.exports = require("@splunk/visualization-context/TimezoneContext");
1195
+
1196
+ /***/ }),
1197
+ /* 33 */
1198
+ /***/ (function(module, exports, __webpack_require__) {
1199
+
1200
+ "use strict";
1201
+
1202
+
1203
+ Object.defineProperty(exports, "__esModule", {
1204
+ value: true
1205
+ });
1206
+
1207
+ var react_1 = __webpack_require__(0);
1208
+
1209
+ function usePrevious(value) {
1210
+ var ref = (0, react_1.useRef)();
1211
+ (0, react_1.useEffect)(function () {
1212
+ ref.current = value;
1213
+ });
1214
+ return ref.current;
1215
+ }
1216
+
1217
+ exports.default = usePrevious;
1218
+
1219
+ /***/ }),
1220
+ /* 34 */
1221
+ /***/ (function(module, exports) {
1222
+
1223
+ module.exports = require("@splunk/visualizations-shared/hocUtils");
1224
+
1225
+ /***/ }),
1226
+ /* 35 */
1227
+ /***/ (function(module, exports) {
1228
+
1229
+ module.exports = require("@splunk/visualizations-shared/JSONSchemaUtils");
1230
+
1231
+ /***/ }),
1232
+ /* 36 */,
1233
+ /* 37 */
1234
+ /***/ (function(module, exports, __webpack_require__) {
1235
+
1236
+ "use strict";
1237
+
1238
+
1239
+ Object.defineProperty(exports, "__esModule", {
1240
+ value: true
1241
+ });
1242
+ exports.shouldShowIconPlaceholder = void 0;
1243
+
1244
+ var React = __webpack_require__(0);
1245
+
1246
+ var T = __webpack_require__(1);
1247
+
1248
+ var lodash_1 = __webpack_require__(3);
1249
+
1250
+ var i18n_1 = __webpack_require__(2);
1251
+
1252
+ var Message_1 = __webpack_require__(12);
1253
+
1254
+ var FixedSizeContainer_1 = __webpack_require__(17);
1255
+ /**
1256
+ * @method shouldShowIconPlaceholder
1257
+ * @param {object} dataSources
1258
+ * @param {boolean} loading
1259
+ * @returns {boolean}
1260
+ */
1261
+
1262
+
1263
+ var shouldShowIconPlaceholder = function shouldShowIconPlaceholder(dataSources) {
1264
+ var loading = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1265
+ var data = (0, lodash_1.get)(dataSources, 'primary.data.columns[0]', undefined);
1266
+ var noData = data === undefined;
1267
+ var fields = (0, lodash_1.get)(dataSources, 'primary.data.fields[0]', undefined);
1268
+ var noFields = fields === undefined;
1269
+ return loading || noData || noFields;
1270
+ };
1271
+
1272
+ exports.shouldShowIconPlaceholder = shouldShowIconPlaceholder;
1273
+ var propTypes = {
1274
+ icon: T.func,
1275
+ width: T.oneOfType([T.string, T.number]),
1276
+ height: T.oneOfType([T.string, T.number]),
1277
+ // eslint-disable-next-line react/no-unused-prop-types
1278
+ backgroundColor: T.string,
1279
+ iconColor: T.string
1280
+ };
1281
+ /**
1282
+ * @method IconPlaceholder
1283
+ * @param {IconPlaceholderProps} props
1284
+ * @returns {React.ReactElement}
1038
1285
  */
1039
1286
 
1040
1287
  var IconPlaceholder = function IconPlaceholder(props) {
@@ -1075,25 +1322,24 @@ IconPlaceholder.defaultProps = {
1075
1322
  exports.default = (0, FixedSizeContainer_1.default)(IconPlaceholder);
1076
1323
 
1077
1324
  /***/ }),
1078
-
1079
- /***/ 33:
1325
+ /* 38 */
1080
1326
  /***/ (function(module, exports, __webpack_require__) {
1081
1327
 
1082
1328
  "use strict";
1083
1329
 
1084
1330
 
1085
- var _defineProperty = __webpack_require__(7);
1331
+ var _defineProperty = __webpack_require__(9);
1086
1332
 
1087
1333
  Object.defineProperty(exports, "__esModule", {
1088
1334
  value: true
1089
1335
  });
1090
1336
  exports.getSortingParams = exports.SortParamsPropTypes = void 0;
1091
1337
 
1092
- var T = __webpack_require__(0);
1338
+ var T = __webpack_require__(1);
1093
1339
 
1094
1340
  var lodash_1 = __webpack_require__(3);
1095
1341
 
1096
- var DataSource_1 = __webpack_require__(34);
1342
+ var DataSource_1 = __webpack_require__(19);
1097
1343
 
1098
1344
  exports.SortParamsPropTypes = T.shape({
1099
1345
  currentSortKey: T.string,
@@ -1146,24 +1392,7 @@ var getSortingParams = function getSortingParams(_ref) {
1146
1392
  exports.getSortingParams = getSortingParams;
1147
1393
 
1148
1394
  /***/ }),
1149
-
1150
- /***/ 34:
1151
- /***/ (function(module, exports, __webpack_require__) {
1152
-
1153
- "use strict";
1154
-
1155
-
1156
- Object.defineProperty(exports, "__esModule", {
1157
- value: true
1158
- });
1159
- exports.validOutputModes = exports.validSegmentationModes = exports.validSortDirs = void 0;
1160
- exports.validSortDirs = ['asc', 'desc', 'none'];
1161
- exports.validSegmentationModes = ['none', 'inner'];
1162
- exports.validOutputModes = ['json_cols', 'json'];
1163
-
1164
- /***/ }),
1165
-
1166
- /***/ 35:
1395
+ /* 39 */
1167
1396
  /***/ (function(module, exports, __webpack_require__) {
1168
1397
 
1169
1398
  "use strict";
@@ -1174,7 +1403,7 @@ Object.defineProperty(exports, "__esModule", {
1174
1403
  });
1175
1404
  exports.getPaginationParams = exports.PaginatorParamsPropTypes = void 0;
1176
1405
 
1177
- var T = __webpack_require__(0);
1406
+ var T = __webpack_require__(1);
1178
1407
 
1179
1408
  var lodash_1 = __webpack_require__(3);
1180
1409
 
@@ -1227,89 +1456,307 @@ var getPaginationParams = function getPaginationParams(_ref) {
1227
1456
  exports.getPaginationParams = getPaginationParams;
1228
1457
 
1229
1458
  /***/ }),
1230
-
1231
- /***/ 36:
1459
+ /* 40 */
1232
1460
  /***/ (function(module, exports, __webpack_require__) {
1233
1461
 
1234
1462
  "use strict";
1235
1463
 
1236
1464
 
1237
- Object.defineProperty(exports, "__esModule", {
1238
- value: true
1239
- });
1240
- exports.VizCategory = void 0;
1241
- var VizCategory;
1465
+ var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
1466
+ if (k2 === undefined) k2 = k;
1467
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1242
1468
 
1243
- (function (VizCategory) {
1244
- VizCategory["SINGLE_VALUE"] = "Single Value";
1245
- VizCategory["TRENDS"] = "Trends";
1246
- VizCategory["COMPARISONS"] = "Comparisons";
1247
- VizCategory["TABLE"] = "Table";
1248
- VizCategory["GAUGE"] = "Gauge";
1249
- VizCategory["DISTRIBUTIONS"] = "Distributions";
1250
- VizCategory["CHOROPLETH"] = "Choropleth Maps";
1251
- VizCategory["SHAPES"] = "Shapes";
1252
- VizCategory["MISC"] = "misc";
1253
- VizCategory["FLOW"] = "Flow";
1254
- VizCategory["CORRELATION"] = "Correlation";
1255
- VizCategory["SPATIAL"] = "Spatial";
1256
- })(VizCategory = exports.VizCategory || (exports.VizCategory = {}));
1469
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1470
+ desc = {
1471
+ enumerable: true,
1472
+ get: function get() {
1473
+ return m[k];
1474
+ }
1475
+ };
1476
+ }
1477
+
1478
+ Object.defineProperty(o, k2, desc);
1479
+ } : function (o, m, k, k2) {
1480
+ if (k2 === undefined) k2 = k;
1481
+ o[k2] = m[k];
1482
+ });
1483
+
1484
+ var __exportStar = this && this.__exportStar || function (m, exports) {
1485
+ for (var p in m) {
1486
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1487
+ }
1488
+ };
1489
+
1490
+ Object.defineProperty(exports, "__esModule", {
1491
+ value: true
1492
+ });
1493
+
1494
+ __exportStar(__webpack_require__(41), exports);
1495
+
1496
+ __exportStar(__webpack_require__(42), exports);
1497
+
1498
+ __exportStar(__webpack_require__(19), exports);
1499
+
1500
+ __exportStar(__webpack_require__(43), exports);
1501
+
1502
+ __exportStar(__webpack_require__(44), exports);
1503
+
1504
+ __exportStar(__webpack_require__(45), exports);
1505
+
1506
+ __exportStar(__webpack_require__(46), exports);
1507
+
1508
+ __exportStar(__webpack_require__(47), exports);
1509
+
1510
+ __exportStar(__webpack_require__(48), exports);
1511
+
1512
+ __exportStar(__webpack_require__(49), exports);
1513
+
1514
+ __exportStar(__webpack_require__(21), exports);
1515
+
1516
+ __exportStar(__webpack_require__(6), exports);
1517
+
1518
+ __exportStar(__webpack_require__(22), exports);
1519
+
1520
+ __exportStar(__webpack_require__(50), exports);
1521
+
1522
+ __exportStar(__webpack_require__(51), exports);
1523
+
1524
+ __exportStar(__webpack_require__(52), exports);
1525
+
1526
+ __exportStar(__webpack_require__(53), exports);
1527
+
1528
+ __exportStar(__webpack_require__(54), exports);
1529
+
1530
+ __exportStar(__webpack_require__(55), exports);
1531
+
1532
+ /***/ }),
1533
+ /* 41 */
1534
+ /***/ (function(module, exports, __webpack_require__) {
1535
+
1536
+ "use strict";
1537
+
1538
+
1539
+ Object.defineProperty(exports, "__esModule", {
1540
+ value: true
1541
+ });
1542
+
1543
+ /***/ }),
1544
+ /* 42 */
1545
+ /***/ (function(module, exports, __webpack_require__) {
1546
+
1547
+ "use strict";
1548
+
1549
+ /**
1550
+ * A data structure used at runtime to wire up a visualization.
1551
+ */
1552
+
1553
+ Object.defineProperty(exports, "__esModule", {
1554
+ value: true
1555
+ });
1556
+
1557
+ /***/ }),
1558
+ /* 43 */
1559
+ /***/ (function(module, exports, __webpack_require__) {
1560
+
1561
+ "use strict";
1562
+
1563
+
1564
+ Object.defineProperty(exports, "__esModule", {
1565
+ value: true
1566
+ });
1567
+
1568
+ /***/ }),
1569
+ /* 44 */
1570
+ /***/ (function(module, exports, __webpack_require__) {
1571
+
1572
+ "use strict";
1573
+
1574
+
1575
+ Object.defineProperty(exports, "__esModule", {
1576
+ value: true
1577
+ });
1578
+
1579
+ /***/ }),
1580
+ /* 45 */
1581
+ /***/ (function(module, exports, __webpack_require__) {
1582
+
1583
+ "use strict";
1584
+
1585
+
1586
+ Object.defineProperty(exports, "__esModule", {
1587
+ value: true
1588
+ });
1589
+
1590
+ /***/ }),
1591
+ /* 46 */
1592
+ /***/ (function(module, exports, __webpack_require__) {
1593
+
1594
+ "use strict";
1595
+
1596
+
1597
+ Object.defineProperty(exports, "__esModule", {
1598
+ value: true
1599
+ });
1600
+
1601
+ /***/ }),
1602
+ /* 47 */
1603
+ /***/ (function(module, exports, __webpack_require__) {
1604
+
1605
+ "use strict";
1606
+
1607
+
1608
+ Object.defineProperty(exports, "__esModule", {
1609
+ value: true
1610
+ });
1611
+
1612
+ /***/ }),
1613
+ /* 48 */
1614
+ /***/ (function(module, exports, __webpack_require__) {
1615
+
1616
+ "use strict";
1617
+
1618
+
1619
+ Object.defineProperty(exports, "__esModule", {
1620
+ value: true
1621
+ });
1257
1622
 
1258
1623
  /***/ }),
1624
+ /* 49 */
1625
+ /***/ (function(module, exports, __webpack_require__) {
1626
+
1627
+ "use strict";
1628
+
1629
+
1630
+ Object.defineProperty(exports, "__esModule", {
1631
+ value: true
1632
+ });
1633
+
1634
+ /***/ }),
1635
+ /* 50 */
1636
+ /***/ (function(module, exports, __webpack_require__) {
1637
+
1638
+ "use strict";
1639
+
1640
+
1641
+ Object.defineProperty(exports, "__esModule", {
1642
+ value: true
1643
+ });
1644
+
1645
+ /***/ }),
1646
+ /* 51 */
1647
+ /***/ (function(module, exports, __webpack_require__) {
1648
+
1649
+ "use strict";
1650
+
1651
+
1652
+ Object.defineProperty(exports, "__esModule", {
1653
+ value: true
1654
+ });
1655
+
1656
+ /***/ }),
1657
+ /* 52 */
1658
+ /***/ (function(module, exports, __webpack_require__) {
1659
+
1660
+ "use strict";
1661
+
1662
+
1663
+ Object.defineProperty(exports, "__esModule", {
1664
+ value: true
1665
+ });
1666
+
1667
+ /***/ }),
1668
+ /* 53 */
1669
+ /***/ (function(module, exports, __webpack_require__) {
1670
+
1671
+ "use strict";
1672
+
1673
+
1674
+ Object.defineProperty(exports, "__esModule", {
1675
+ value: true
1676
+ });
1677
+
1678
+ /***/ }),
1679
+ /* 54 */
1680
+ /***/ (function(module, exports, __webpack_require__) {
1681
+
1682
+ "use strict";
1683
+
1684
+
1685
+ Object.defineProperty(exports, "__esModule", {
1686
+ value: true
1687
+ });
1688
+
1689
+ /***/ }),
1690
+ /* 55 */
1691
+ /***/ (function(module, exports, __webpack_require__) {
1692
+
1693
+ "use strict";
1694
+
1259
1695
 
1260
- /***/ 37:
1696
+ Object.defineProperty(exports, "__esModule", {
1697
+ value: true
1698
+ });
1699
+
1700
+ /***/ }),
1701
+ /* 56 */
1261
1702
  /***/ (function(module, exports, __webpack_require__) {
1262
1703
 
1263
1704
  "use strict";
1264
1705
 
1265
1706
 
1266
- var _slicedToArray = __webpack_require__(17);
1707
+ var _slicedToArray = __webpack_require__(7);
1267
1708
 
1268
1709
  Object.defineProperty(exports, "__esModule", {
1269
1710
  value: true
1270
1711
  });
1271
1712
 
1272
- var React = __webpack_require__(1);
1713
+ var React = __webpack_require__(0);
1273
1714
 
1274
1715
  var lodash_1 = __webpack_require__(3);
1275
1716
 
1276
- var getSettingsFromThemedProps_1 = __webpack_require__(38);
1717
+ var getSettingsFromThemedProps_1 = __webpack_require__(57);
1277
1718
 
1278
- var Options_1 = __webpack_require__(30);
1719
+ var Options_1 = __webpack_require__(16);
1279
1720
 
1280
- var SanitizeProps_1 = __webpack_require__(39);
1721
+ var SanitizeProps_1 = __webpack_require__(58);
1281
1722
 
1282
- var TimezoneContext_1 = __webpack_require__(26);
1723
+ var TimezoneContext_1 = __webpack_require__(32);
1283
1724
 
1284
- var moment_1 = __webpack_require__(40);
1725
+ var moment_1 = __webpack_require__(59);
1285
1726
 
1286
- var FeatureFlagContext_1 = __webpack_require__(21);
1727
+ var FeatureFlagContext_1 = __webpack_require__(28);
1287
1728
 
1288
1729
  var styled_components_1 = __webpack_require__(4);
1289
1730
 
1290
- var hocUtils_1 = __webpack_require__(27);
1731
+ var hocUtils_1 = __webpack_require__(34);
1291
1732
 
1292
- var JSONSchemaUtils_1 = __webpack_require__(28);
1733
+ var JSONSchemaUtils_1 = __webpack_require__(35);
1293
1734
 
1294
- var async_dynamic_options_evaluator_1 = __webpack_require__(41);
1735
+ var async_dynamic_options_evaluator_1 = __webpack_require__(60);
1295
1736
 
1296
- var id_1 = __webpack_require__(25);
1737
+ var id_1 = __webpack_require__(31);
1297
1738
 
1298
- var SplunkVisualization_1 = __webpack_require__(42);
1739
+ var SplunkVisualization_1 = __webpack_require__(61);
1299
1740
 
1300
1741
  var VizBehavior_1 = __webpack_require__(6);
1301
1742
 
1302
- var getSorting_1 = __webpack_require__(33);
1743
+ var getSorting_1 = __webpack_require__(38);
1744
+
1745
+ var getPagination_1 = __webpack_require__(39);
1746
+
1747
+ var useDeepMemo_1 = __webpack_require__(62);
1748
+
1749
+ var MissingPropsMessage_1 = __webpack_require__(63);
1303
1750
 
1304
- var getPagination_1 = __webpack_require__(35);
1751
+ var withEditModeCover_1 = __webpack_require__(64);
1305
1752
 
1306
- var useDeepMemo_1 = __webpack_require__(44);
1753
+ var withPlaceholder_1 = __webpack_require__(65);
1307
1754
 
1308
- var MissingPropsMessage_1 = __webpack_require__(45);
1755
+ var useDownsampleDataSources_1 = __webpack_require__(66);
1309
1756
 
1310
- var withEditModeCover_1 = __webpack_require__(46);
1757
+ var dataUtils_1 = __webpack_require__(14);
1311
1758
 
1312
- var withPlaceholder_1 = __webpack_require__(47);
1759
+ var featureFlagUtils_1 = __webpack_require__(68);
1313
1760
  /**
1314
1761
  * hoc that wraps a pure react visualization in a Dashboard visualization
1315
1762
  * @param {DashboardVizOpts} opts
@@ -1400,25 +1847,61 @@ var withDashboardViz = function withDashboardViz(opts) {
1400
1847
  dataFramesInState = _React$useState8[0],
1401
1848
  setDataFramesInState = _React$useState8[1];
1402
1849
 
1403
- var _React$useState9 = React.useState(Boolean(featureFlagContext === null || featureFlagContext === void 0 ? void 0 : featureFlagContext.visualizations_useWebWorkersForDSL)),
1850
+ var _React$useState9 = React.useState(Boolean((0, featureFlagUtils_1.getFeatureFlag)(featureFlagContext, 'visualizations_useWebWorkersForDSL'))),
1404
1851
  _React$useState10 = _slicedToArray(_React$useState9, 2),
1405
1852
  useAsyncEvaluatedOptions = _React$useState10[0],
1406
1853
  setUseAsyncEvaluatedOptions = _React$useState10[1];
1407
1854
 
1855
+ var isDownsamplingEnabledByFeatureFlag = Boolean(featureFlagContext === null || featureFlagContext === void 0 ? void 0 : featureFlagContext.visualizations_enableDownsampling);
1408
1856
  var isMounted = React.useRef(true);
1857
+ var optionsToEvaluate = React.useMemo(function () {
1858
+ return {
1859
+ context: (0, lodash_1.defaultsDeep)({}, context, vizConfig.defaultContext),
1860
+ options: (0, hocUtils_1.deepMergeWithArrayPrimitiveOverrides)({}, options, defaultOptions)
1861
+ };
1862
+ }, [options, context]);
1863
+
1864
+ var _React$useState11 = React.useState(Number(width)),
1865
+ _React$useState12 = _slicedToArray(_React$useState11, 2),
1866
+ threshold = _React$useState12[0],
1867
+ setThreshold = _React$useState12[1];
1868
+
1869
+ var onDownsamplingThresholdChange = React.useCallback(function (newThreshold) {
1870
+ setThreshold(newThreshold);
1871
+ }, []);
1872
+ var isDownsamplingEnabled = React.useMemo(function () {
1873
+ return isDownsamplingEnabledByFeatureFlag && (0, dataUtils_1.isDownsamplingEnabledForViz)({
1874
+ vizConfig: vizConfig
1875
+ });
1876
+ }, [isDownsamplingEnabledByFeatureFlag]);
1877
+ var downsamplingProps = React.useMemo(function () {
1878
+ if (!isDownsamplingEnabled) {
1879
+ return {};
1880
+ }
1881
+
1882
+ return {
1883
+ onDownsamplingThresholdChange: onDownsamplingThresholdChange,
1884
+ originalDataSources: dataSources
1885
+ };
1886
+ }, [dataSources, isDownsamplingEnabled, onDownsamplingThresholdChange]);
1887
+ var downsampledDataSources = (0, useDownsampleDataSources_1.default)({
1888
+ options: optionsToEvaluate.options,
1889
+ context: optionsToEvaluate.context,
1890
+ dataSources: dataSources,
1891
+ threshold: threshold,
1892
+ isDownsamplingEnabled: isDownsamplingEnabled
1893
+ });
1409
1894
  evaluatedOptions = (0, useDeepMemo_1.useDeepMemo)(function () {
1410
1895
  try {
1411
1896
  if (useAsyncEvaluatedOptions) {
1412
- var optionsToEvaluate = {
1413
- context: (0, lodash_1.defaultsDeep)({}, context, vizConfig.defaultContext),
1414
- options: (0, hocUtils_1.deepMergeWithArrayPrimitiveOverrides)({}, options, defaultOptions)
1415
- };
1416
1897
  var asyncDynamicOptionsEvaluatorParams = {
1417
1898
  visualizationID: visualizationID,
1418
1899
  props: props,
1419
1900
  options: optionsToEvaluate,
1420
- dataSources: dataSources,
1421
- theme: vizConfig.themes
1901
+ dataSources: downsampledDataSources,
1902
+ theme: vizConfig.themes,
1903
+ bypassCloneDeepOptionScope: Boolean((0, featureFlagUtils_1.getFeatureFlag)(featureFlagContext, 'visualizations_bypassCloneDeepOptionScope')),
1904
+ lazyLoadingDataFrame: Boolean((0, featureFlagUtils_1.getFeatureFlag)(featureFlagContext, 'visualizations_lazyLoadingDataFrame'))
1422
1905
  };
1423
1906
  async_dynamic_options_evaluator_1.default.evaluate(asyncDynamicOptionsEvaluatorParams).then(function (results) {
1424
1907
  setEvaluatedOptionsAsync(results.results);
@@ -1430,16 +1913,14 @@ var withDashboardViz = function withDashboardViz(opts) {
1430
1913
  } else {
1431
1914
  var dataFrames = dataFramesInState;
1432
1915
 
1433
- if (dataSources !== dataSourcesInState) {
1434
- setDataSourcesInState(dataSources);
1435
- dataFrames = Options_1.Options.dataFrameFromDataSource(dataSources);
1916
+ if (downsampledDataSources !== dataSourcesInState) {
1917
+ setDataSourcesInState(downsampledDataSources);
1918
+ dataFrames = Options_1.Options.dataFrameFromDataSource(downsampledDataSources, (0, featureFlagUtils_1.getFeatureFlag)(featureFlagContext, 'visualizations_lazyLoadingDataFrame'));
1436
1919
  setDataFramesInState(dataFrames);
1437
1920
  }
1438
1921
 
1439
- return Options_1.Options.evaluate({
1440
- context: (0, lodash_1.defaultsDeep)({}, context, vizConfig.defaultContext),
1441
- options: (0, hocUtils_1.deepMergeWithArrayPrimitiveOverrides)({}, options, defaultOptions)
1442
- }, dataSources, themeFunc, dataFrames);
1922
+ var result = Options_1.Options.evaluate(optionsToEvaluate, downsampledDataSources, themeFunc, dataFrames, (0, featureFlagUtils_1.getFeatureFlag)(featureFlagContext, 'visualizations_bypassCloneDeepOptionScope'));
1923
+ return result;
1443
1924
  }
1444
1925
  } catch (e) {
1445
1926
  // eslint-disable-next-line no-console
@@ -1448,7 +1929,7 @@ var withDashboardViz = function withDashboardViz(opts) {
1448
1929
  }
1449
1930
 
1450
1931
  return {};
1451
- }, [currentThemeFamily, currentThemeColorScheme, currentThemeDensity, options, context, dataSources, serializedTimezone, useAsyncEvaluatedOptions]);
1932
+ }, [currentThemeFamily, currentThemeColorScheme, currentThemeDensity, optionsToEvaluate, downsampledDataSources, serializedTimezone, useAsyncEvaluatedOptions]);
1452
1933
  var evaluatedOptionsToUse = !useAsyncEvaluatedOptions ? evaluatedOptions : evaluatedOptionsAsync; // trellis specific backgroundColor update for onComputedProps
1453
1934
  // if trellis is enabled following these three criteria - 1) trellis feature flag is enabled 2) vizConfig supports array has 'trellis' 3) option 'splitByLayout' is set to 'trellis
1454
1935
  // onComputedProps api should return back trellisBackgroundColor value for backgroundColor option to support coloring of sibling panels (for eg:- title/ description on UDF side)
@@ -1582,258 +2063,651 @@ var withDashboardViz = function withDashboardViz(opts) {
1582
2063
  } // if were using webworkers and this is the first render we dont want to show a viz with missing data so we return null
1583
2064
 
1584
2065
 
1585
- if (useAsyncEvaluatedOptions && Object.keys(evaluatedOptionsToUse).length === 0) {
1586
- return null;
1587
- }
2066
+ if (useAsyncEvaluatedOptions && Object.keys(evaluatedOptionsToUse).length === 0) {
2067
+ return null;
2068
+ }
2069
+
2070
+ return React.createElement(SanitizedReactViz, Object.assign({
2071
+ mode: mode,
2072
+ width: width,
2073
+ height: height
2074
+ }, downsamplingProps, evaluatedOptionsToUse, computedVizProps, eventCallbackProps, dataSourceMetadata));
2075
+ };
2076
+
2077
+ DashboardViz.propTypes = Object.assign(Object.assign({}, SplunkVisualization_1.default.propTypes), ReactViz.propTypes);
2078
+ DashboardViz.defaultProps = Object.assign(Object.assign(Object.assign({}, SplunkVisualization_1.default.defaultProps), ReactViz.defaultProps), {
2079
+ // using withTheme requires component to receive theme prop. In case the consumer did not provide ThemeProvider, a default empty object will prevent warnings.
2080
+ theme: {}
2081
+ }); // attach viz config
2082
+
2083
+ DashboardViz.config = vizConfig; // @ts-ignore: TODO fix sc upgrade TS issues
2084
+
2085
+ return (0, styled_components_1.withTheme)((0, withPlaceholder_1.default)((0, withEditModeCover_1.default)(DashboardViz, disableEditModeCover), useIconPlaceholder));
2086
+ };
2087
+
2088
+ exports.default = withDashboardViz;
2089
+
2090
+ /***/ }),
2091
+ /* 57 */
2092
+ /***/ (function(module, exports) {
2093
+
2094
+ module.exports = require("@splunk/themes/getSettingsFromThemedProps");
2095
+
2096
+ /***/ }),
2097
+ /* 58 */
2098
+ /***/ (function(module, exports) {
2099
+
2100
+ module.exports = require("@splunk/visualizations-shared/SanitizeProps");
2101
+
2102
+ /***/ }),
2103
+ /* 59 */
2104
+ /***/ (function(module, exports) {
2105
+
2106
+ module.exports = require("@splunk/moment");
2107
+
2108
+ /***/ }),
2109
+ /* 60 */
2110
+ /***/ (function(module, exports) {
2111
+
2112
+ module.exports = require("@splunk/async-dynamic-options-evaluator");
2113
+
2114
+ /***/ }),
2115
+ /* 61 */
2116
+ /***/ (function(module, exports, __webpack_require__) {
2117
+
2118
+ "use strict";
2119
+
2120
+
2121
+ var _classCallCheck = __webpack_require__(10);
2122
+
2123
+ Object.defineProperty(exports, "__esModule", {
2124
+ value: true
2125
+ });
2126
+ exports.INITIAL_HEIGHT = exports.INITIAL_WIDTH = void 0;
2127
+ /* eslint-disable react/no-unused-prop-types,react/prefer-stateless-function */
2128
+
2129
+ var T = __webpack_require__(1);
2130
+
2131
+ var lodash_1 = __webpack_require__(3);
2132
+
2133
+ var VizActionHandler_1 = __webpack_require__(21); // this is identical to the initial height and width we use in BaseVisualization in dashboard-visualizations
2134
+
2135
+
2136
+ exports.INITIAL_WIDTH = 250;
2137
+ exports.INITIAL_HEIGHT = 250;
2138
+ /**
2139
+ * A Splunk visualization
2140
+ */
2141
+
2142
+ var SplunkVisualization = function SplunkVisualization() {
2143
+ _classCallCheck(this, SplunkVisualization);
2144
+ };
2145
+
2146
+ SplunkVisualization.propTypes = {
2147
+ /**
2148
+ * display mode
2149
+ */
2150
+ mode: T.oneOf(['view', 'edit', 'export']).isRequired,
2151
+
2152
+ /**
2153
+ * width in pixel or string, defaults to 100%
2154
+ */
2155
+ width: T.oneOfType([T.string, T.number]).isRequired,
2156
+
2157
+ /**
2158
+ * height in pixel or string
2159
+ */
2160
+ height: T.oneOfType([T.string, T.number]).isRequired,
2161
+
2162
+ /**
2163
+ * visualization context used for dynamic option evaluation
2164
+ */
2165
+ context: T.object,
2166
+
2167
+ /**
2168
+ * visualization formatting options
2169
+ */
2170
+ options: T.object,
2171
+
2172
+ /**
2173
+ * A callback to update formatting options
2174
+ */
2175
+ onOptionsChange: T.func,
2176
+
2177
+ /**
2178
+ * datasource state which include data and request params, object key indicate the datasource type.
2179
+ */
2180
+ dataSources: T.objectOf(T.shape({
2181
+ /**
2182
+ * current request params
2183
+ */
2184
+ requestParams: T.object,
2185
+
2186
+ /**
2187
+ * current dataset
2188
+ */
2189
+ data: T.shape({
2190
+ fields: T.array,
2191
+ columns: T.array
2192
+ }),
2193
+
2194
+ /**
2195
+ * error
2196
+ */
2197
+ error: T.shape({
2198
+ level: T.string,
2199
+ message: T.string
2200
+ }),
2201
+
2202
+ /**
2203
+ * meta data that came with the dataset
2204
+ */
2205
+ meta: T.object
2206
+ })),
2207
+
2208
+ /**
2209
+ * A callback to trigger event
2210
+ */
2211
+ onEventTrigger: T.func,
2212
+
2213
+ /**
2214
+ * Inform viz if there are handlers listening to events
2215
+ */
2216
+ hasEventHandlers: T.bool,
2217
+
2218
+ /**
2219
+ * A callback to communicate computed props to a consumer
2220
+ */
2221
+ onComputedProps: T.func,
2222
+
2223
+ /**
2224
+ * A callback to obtain visualization api
2225
+ */
2226
+ vizActionHandlerRef: T.func,
2227
+ loading: T.bool,
2228
+ theme: T.object,
2229
+
2230
+ /**
2231
+ * A callback to request new data with updated request params
2232
+ */
2233
+ onRequestParamsChange: T.func
2234
+ };
2235
+ /**
2236
+ *
2237
+ */
2238
+
2239
+ SplunkVisualization.defaultProps = {
2240
+ // BaseVisualization in dashboard-visualizations uses 100% for width but 250 for height
2241
+ width: '100%',
2242
+ height: exports.INITIAL_HEIGHT,
2243
+ dataSources: {},
2244
+ onEventTrigger: function onEventTrigger() {
2245
+ return {};
2246
+ },
2247
+ mode: 'view',
2248
+ hasEventHandlers: false,
2249
+ options: {},
2250
+ context: {},
2251
+ onOptionsChange: function onOptionsChange() {
2252
+ return {};
2253
+ },
2254
+ vizActionHandlerRef: function vizActionHandlerRef() {
2255
+ return new VizActionHandler_1.DefaultVizActionHandler();
2256
+ },
2257
+ onComputedProps: function onComputedProps() {
2258
+ return {};
2259
+ },
2260
+ loading: false,
2261
+ onRequestParamsChange: lodash_1.noop
2262
+ };
2263
+ exports.default = SplunkVisualization;
2264
+
2265
+ /***/ }),
2266
+ /* 62 */
2267
+ /***/ (function(module, exports, __webpack_require__) {
2268
+
2269
+ "use strict";
2270
+
2271
+
2272
+ Object.defineProperty(exports, "__esModule", {
2273
+ value: true
2274
+ });
2275
+ exports.useDeepMemo = void 0;
2276
+
2277
+ var react_1 = __webpack_require__(0);
2278
+
2279
+ var lodash_1 = __webpack_require__(3);
2280
+ /**
2281
+ * This hook evaluates and stores the result of a passed function and only
2282
+ * re-evaluates the function when passed dependencies change.
2283
+ *
2284
+ * It is different from the internal React useMemo in the following aspects:
2285
+ * - it only stores the last evaluated result
2286
+ * - it uses a deep equality check to determine if dependencies have changed
2287
+ *
2288
+ * Inspired by apollo-client's useDeepMemo
2289
+ *
2290
+ * @param fn the function to be executed and
2291
+ * @param dependencies an array of dependencies
2292
+ */
2293
+
2294
+
2295
+ var useDeepMemo = function useDeepMemo(fn, dependencies) {
2296
+ var ref = (0, react_1.useRef)();
2297
+
2298
+ if (!ref.current || !(0, lodash_1.isEqual)(dependencies, ref.current.dependencies)) {
2299
+ ref.current = {
2300
+ dependencies: dependencies,
2301
+ value: fn()
2302
+ };
2303
+ }
2304
+
2305
+ return ref.current.value;
2306
+ };
2307
+
2308
+ exports.useDeepMemo = useDeepMemo;
2309
+
2310
+ /***/ }),
2311
+ /* 63 */
2312
+ /***/ (function(module, exports, __webpack_require__) {
2313
+
2314
+ "use strict";
2315
+
2316
+
2317
+ Object.defineProperty(exports, "__esModule", {
2318
+ value: true
2319
+ });
2320
+ exports.MissingPropsMessage = exports.missingKeys = exports.isMissing = void 0;
2321
+
2322
+ var React = __webpack_require__(0);
2323
+
2324
+ var T = __webpack_require__(1);
2325
+
2326
+ var i18n_1 = __webpack_require__(2);
2327
+
2328
+ var Message_1 = __webpack_require__(12);
2329
+
2330
+ var FixedSizeContainer_1 = __webpack_require__(17);
2331
+ /**
2332
+ * @method isMissing
2333
+ * @param {any} v
2334
+ * @returns {boolean} true if the input value === null or undefined
2335
+ */
2336
+
2337
+
2338
+ var isMissing = function isMissing(v) {
2339
+ return v === null || v === undefined;
2340
+ };
2341
+
2342
+ exports.isMissing = isMissing;
2343
+ /**
2344
+ * @method misskingKeys
2345
+ * @param {string[]} keys
2346
+ * @param {object} target
2347
+ * @returns {string[]} the keys of missing required props
2348
+ */
2349
+
2350
+ var missingKeys = function missingKeys(keys, target) {
2351
+ return keys.filter(function (k) {
2352
+ return (0, exports.isMissing)(target[k]);
2353
+ });
2354
+ };
2355
+
2356
+ exports.missingKeys = missingKeys;
2357
+ var propTypes = {
2358
+ width: T.oneOfType([T.string, T.number]),
2359
+ height: T.oneOfType([T.string, T.number]),
2360
+ // eslint-disable-next-line react/no-unused-prop-types
2361
+ backgroundColor: T.string,
2362
+ missingProps: T.arrayOf(T.string)
2363
+ };
2364
+ /**
2365
+ * @method MissingPropsMessage
2366
+ * @param {MissingPropsProps} props
2367
+ * @returns {React.ReactElement}
2368
+ */
2369
+
2370
+ var MissingPropsMessage = function MissingPropsMessage(props) {
2371
+ var width = props.width,
2372
+ height = props.height,
2373
+ missingProps = props.missingProps;
2374
+ return React.createElement(Message_1.default, {
2375
+ "data-test": "message",
2376
+ width: width,
2377
+ height: height,
2378
+ message: (0, i18n_1._)("Missing property: ".concat(missingProps.join(', ')))
2379
+ });
2380
+ };
2381
+
2382
+ exports.MissingPropsMessage = MissingPropsMessage;
2383
+ exports.MissingPropsMessage.propTypes = propTypes;
2384
+ exports.MissingPropsMessage.defaultProps = {
2385
+ width: '100%',
2386
+ height: 250
2387
+ };
2388
+ exports.default = (0, FixedSizeContainer_1.default)(exports.MissingPropsMessage);
2389
+
2390
+ /***/ }),
2391
+ /* 64 */
2392
+ /***/ (function(module, exports, __webpack_require__) {
2393
+
2394
+ "use strict";
1588
2395
 
1589
- return React.createElement(SanitizedReactViz, Object.assign({
1590
- mode: mode,
1591
- width: width,
1592
- height: height
1593
- }, evaluatedOptionsToUse, computedVizProps, eventCallbackProps, dataSourceMetadata));
1594
- };
1595
2396
 
1596
- DashboardViz.propTypes = Object.assign(Object.assign({}, SplunkVisualization_1.default.propTypes), ReactViz.propTypes);
1597
- DashboardViz.defaultProps = Object.assign(Object.assign(Object.assign({}, SplunkVisualization_1.default.defaultProps), ReactViz.defaultProps), {
1598
- // using withTheme requires component to receive theme prop. In case the consumer did not provide ThemeProvider, a default empty object will prevent warnings.
1599
- theme: {}
1600
- }); // attach viz config
2397
+ Object.defineProperty(exports, "__esModule", {
2398
+ value: true
2399
+ });
1601
2400
 
1602
- DashboardViz.config = vizConfig; // @ts-ignore: TODO fix sc upgrade TS issues
2401
+ var React = __webpack_require__(0);
1603
2402
 
1604
- return (0, styled_components_1.withTheme)((0, withPlaceholder_1.default)((0, withEditModeCover_1.default)(DashboardViz, disableEditModeCover), useIconPlaceholder));
2403
+ var styled_components_1 = __webpack_require__(4);
2404
+
2405
+ var hocUtils_1 = __webpack_require__(23);
2406
+
2407
+ var Cover = styled_components_1.default.div.withConfig({
2408
+ displayName: "withEditModeCover__Cover",
2409
+ componentId: "sc-1gsbnxb-0"
2410
+ })(["position:absolute;left:0;right:0;top:0;bottom:0;"]);
2411
+ var Blocker = styled_components_1.default.div.attrs({
2412
+ 'data-splunk-visualization-version': "26.2.0 - 49b909915"
2413
+ }).withConfig({
2414
+ displayName: "withEditModeCover__Blocker",
2415
+ componentId: "sc-1gsbnxb-1"
2416
+ })(["position:relative;width:100%;height:100%;"]);
2417
+ /**
2418
+ * HOC that renders a cover layer in edit mode
2419
+ * @method withEditModeCover
2420
+ * @param {ExtendedDashViz} Visualization
2421
+ * @returns {ExtendedDashViz} Wrapper
2422
+ */
2423
+
2424
+ var withEditModeCover = function withEditModeCover(Visualization, disableEditModeCover) {
2425
+ var Wrapper = function Wrapper(props) {
2426
+ var mode = props.mode;
2427
+ var showEditCover = mode === 'edit' && !disableEditModeCover;
2428
+ return React.createElement(Blocker, null, React.createElement(Visualization, Object.assign({}, props)), showEditCover && React.createElement(Cover, {
2429
+ "data-test": "edit-mode-cover"
2430
+ }));
2431
+ };
2432
+
2433
+ (0, hocUtils_1.extendStaticWrapperProps)({
2434
+ Wrapper: Wrapper,
2435
+ Visualization: Visualization
2436
+ });
2437
+ return Wrapper;
1605
2438
  };
1606
2439
 
1607
- exports.default = withDashboardViz;
2440
+ exports.default = withEditModeCover;
1608
2441
 
1609
2442
  /***/ }),
2443
+ /* 65 */
2444
+ /***/ (function(module, exports, __webpack_require__) {
1610
2445
 
1611
- /***/ 38:
1612
- /***/ (function(module, exports) {
2446
+ "use strict";
1613
2447
 
1614
- module.exports = require("@splunk/themes/getSettingsFromThemedProps");
1615
2448
 
1616
- /***/ }),
2449
+ Object.defineProperty(exports, "__esModule", {
2450
+ value: true
2451
+ });
1617
2452
 
1618
- /***/ 39:
1619
- /***/ (function(module, exports) {
2453
+ var React = __webpack_require__(0);
1620
2454
 
1621
- module.exports = require("@splunk/visualizations-shared/SanitizeProps");
2455
+ var colorUtils_1 = __webpack_require__(15);
1622
2456
 
1623
- /***/ }),
2457
+ var variables_1 = __webpack_require__(13);
1624
2458
 
1625
- /***/ 4:
1626
- /***/ (function(module, exports) {
2459
+ var IconPlaceholder_1 = __webpack_require__(37);
1627
2460
 
1628
- module.exports = require("styled-components");
2461
+ var VizBehavior_1 = __webpack_require__(6);
1629
2462
 
1630
- /***/ }),
2463
+ var hocUtils_1 = __webpack_require__(23);
1631
2464
 
1632
- /***/ 40:
1633
- /***/ (function(module, exports) {
2465
+ var withPlaceholder = function withPlaceholder(Visualization) {
2466
+ var useIconPlaceholder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : IconPlaceholder_1.shouldShowIconPlaceholder;
2467
+ var config = Visualization.config;
2468
+ var themes = config.themes;
1634
2469
 
1635
- module.exports = require("@splunk/moment");
2470
+ var Wrapper = function Wrapper(props) {
2471
+ var _a, _b;
1636
2472
 
1637
- /***/ }),
2473
+ var dataSources = props.dataSources,
2474
+ loading = props.loading,
2475
+ options = props.options,
2476
+ height = props.height,
2477
+ width = props.width;
2478
+ var showPlaceholder = useIconPlaceholder(dataSources, loading, options);
2479
+ var bgColorFromTheme = (0, colorUtils_1.isColor)(options === null || options === void 0 ? void 0 : options.backgroundColor) ? options === null || options === void 0 ? void 0 : options.backgroundColor : (_a = themes === null || themes === void 0 ? void 0 : themes.defaultBackgroundColor) === null || _a === void 0 ? void 0 : _a.call(themes, props);
2480
+ var icon = (_b = config.placeholderIcon) !== null && _b !== void 0 ? _b : config.icon;
2481
+ var iconColor = variables_1.default.contentColorActive(props);
1638
2482
 
1639
- /***/ 41:
1640
- /***/ (function(module, exports) {
2483
+ if (config.supports.includes(VizBehavior_1.VizBehavior.PLACEHOLDER) && showPlaceholder) {
2484
+ return React.createElement(IconPlaceholder_1.default, {
2485
+ "data-test": "icon-placeholder",
2486
+ icon: icon,
2487
+ width: width,
2488
+ height: height,
2489
+ backgroundColor: bgColorFromTheme,
2490
+ iconColor: iconColor
2491
+ });
2492
+ }
1641
2493
 
1642
- module.exports = require("@splunk/async-dynamic-options-evaluator");
2494
+ return React.createElement(Visualization, Object.assign({}, props));
2495
+ };
1643
2496
 
1644
- /***/ }),
2497
+ (0, hocUtils_1.extendStaticWrapperProps)({
2498
+ Wrapper: Wrapper,
2499
+ Visualization: Visualization
2500
+ });
2501
+ return Wrapper;
2502
+ };
2503
+
2504
+ exports.default = withPlaceholder;
1645
2505
 
1646
- /***/ 42:
2506
+ /***/ }),
2507
+ /* 66 */
1647
2508
  /***/ (function(module, exports, __webpack_require__) {
1648
2509
 
1649
2510
  "use strict";
1650
2511
 
1651
2512
 
1652
- var _classCallCheck = __webpack_require__(9);
2513
+ var _slicedToArray = __webpack_require__(7);
1653
2514
 
1654
2515
  Object.defineProperty(exports, "__esModule", {
1655
2516
  value: true
1656
2517
  });
1657
- exports.INITIAL_HEIGHT = exports.INITIAL_WIDTH = void 0;
1658
- /* eslint-disable react/no-unused-prop-types,react/prefer-stateless-function */
1659
2518
 
1660
- var T = __webpack_require__(0);
2519
+ var react_1 = __webpack_require__(0);
1661
2520
 
1662
2521
  var lodash_1 = __webpack_require__(3);
1663
2522
 
1664
- var VizActionHandler_1 = __webpack_require__(43); // this is identical to the initial height and width we use in BaseVisualization in dashboard-visualizations
1665
-
1666
-
1667
- exports.INITIAL_WIDTH = 250;
1668
- exports.INITIAL_HEIGHT = 250;
1669
- /**
1670
- * A Splunk visualization
1671
- */
1672
-
1673
- var SplunkVisualization = function SplunkVisualization() {
1674
- _classCallCheck(this, SplunkVisualization);
1675
- };
2523
+ var dataUtils_1 = __webpack_require__(14);
1676
2524
 
1677
- SplunkVisualization.propTypes = {
1678
- /**
1679
- * display mode
1680
- */
1681
- mode: T.oneOf(['view', 'edit', 'export']).isRequired,
2525
+ var usePrevious_1 = __webpack_require__(33);
1682
2526
 
1683
- /**
1684
- * width in pixel or string, defaults to 100%
1685
- */
1686
- width: T.oneOfType([T.string, T.number]).isRequired,
2527
+ var useGetXAndYFields_1 = __webpack_require__(67);
1687
2528
 
1688
- /**
1689
- * height in pixel or string
1690
- */
1691
- height: T.oneOfType([T.string, T.number]).isRequired,
2529
+ var useDownsampleDataSources = function useDownsampleDataSources(_ref) {
2530
+ var dataSources = _ref.dataSources,
2531
+ options = _ref.options,
2532
+ context = _ref.context,
2533
+ threshold = _ref.threshold,
2534
+ isDownsamplingEnabled = _ref.isDownsamplingEnabled;
2535
+ var isFirstUseEffectCall = (0, react_1.useRef)(true);
2536
+ var xAndYFieldsWithTypes = (0, useGetXAndYFields_1.default)({
2537
+ shouldEvaluateDSL: isDownsamplingEnabled,
2538
+ options: options,
2539
+ context: context,
2540
+ dataSources: dataSources
2541
+ });
2542
+ var previousXAndYFieldsWithTypes = (0, usePrevious_1.default)(xAndYFieldsWithTypes);
2543
+ var previousDataSources = (0, usePrevious_1.default)(dataSources);
2544
+ var previousThreshold = (0, usePrevious_1.default)(threshold);
2545
+
2546
+ var _ref2 = (0, react_1.useState)(function () {
2547
+ return isDownsamplingEnabled ? (0, dataUtils_1.downsampleDataSources)({
2548
+ dataSources: dataSources,
2549
+ threshold: threshold,
2550
+ options: xAndYFieldsWithTypes
2551
+ }) : dataSources;
2552
+ }),
2553
+ _ref3 = _slicedToArray(_ref2, 2),
2554
+ downsampledDataSources = _ref3[0],
2555
+ setDownsampledDataSources = _ref3[1];
2556
+
2557
+ var debouncedDownsampleDataSources = (0, react_1.useMemo)(function () {
2558
+ return (0, lodash_1.debounce)(function (downsampleOptions) {
2559
+ var downsampledResult = (0, dataUtils_1.downsampleDataSources)(downsampleOptions);
2560
+ setDownsampledDataSources(downsampledResult);
2561
+ }, 100, {
2562
+ trailing: true
2563
+ });
2564
+ }, []);
2565
+ (0, react_1.useEffect)(function () {
2566
+ // don't downsample again on the use effect call that happened due to the initial render
2567
+ // this is since we already downsampled as part of the useState call
2568
+ if (isFirstUseEffectCall.current) {
2569
+ isFirstUseEffectCall.current = false;
2570
+ return;
2571
+ }
1692
2572
 
1693
- /**
1694
- * visualization context used for dynamic option evaluation
1695
- */
1696
- context: T.object,
2573
+ if (!isDownsamplingEnabled) {
2574
+ setDownsampledDataSources(dataSources);
2575
+ return;
2576
+ }
1697
2577
 
1698
- /**
1699
- * visualization formatting options
1700
- */
1701
- options: T.object,
2578
+ if ((0, lodash_1.isEqual)(previousXAndYFieldsWithTypes, xAndYFieldsWithTypes) && previousDataSources === dataSources && previousThreshold === threshold) {
2579
+ return;
2580
+ } // Debounce the downsampling so we don't have to downsample and execute DSL multiple times
2581
+ // while the viz is being resized
1702
2582
 
1703
- /**
1704
- * A callback to update formatting options
1705
- */
1706
- onOptionsChange: T.func,
1707
2583
 
1708
- /**
1709
- * datasource state which include data and request params, object key indicate the datasource type.
1710
- */
1711
- dataSources: T.objectOf(T.shape({
1712
- /**
1713
- * current request params
1714
- */
1715
- requestParams: T.object,
2584
+ debouncedDownsampleDataSources({
2585
+ dataSources: dataSources,
2586
+ options: xAndYFieldsWithTypes,
2587
+ threshold: threshold
2588
+ }); // need to detect if this runs as part of the initial render
2589
+ }, [dataSources, debouncedDownsampleDataSources, xAndYFieldsWithTypes, threshold, isDownsamplingEnabled, previousXAndYFieldsWithTypes, previousDataSources, previousThreshold]);
2590
+ return downsampledDataSources;
2591
+ };
1716
2592
 
1717
- /**
1718
- * current dataset
1719
- */
1720
- data: T.shape({
1721
- fields: T.array,
1722
- columns: T.array
1723
- }),
2593
+ exports.default = useDownsampleDataSources;
1724
2594
 
1725
- /**
1726
- * error
1727
- */
1728
- error: T.shape({
1729
- level: T.string,
1730
- message: T.string
1731
- }),
2595
+ /***/ }),
2596
+ /* 67 */
2597
+ /***/ (function(module, exports, __webpack_require__) {
1732
2598
 
1733
- /**
1734
- * meta data that came with the dataset
1735
- */
1736
- meta: T.object
1737
- })),
2599
+ "use strict";
1738
2600
 
1739
- /**
1740
- * A callback to trigger event
1741
- */
1742
- onEventTrigger: T.func,
1743
2601
 
1744
- /**
1745
- * Inform viz if there are handlers listening to events
1746
- */
1747
- hasEventHandlers: T.bool,
2602
+ var _toConsumableArray = __webpack_require__(8);
1748
2603
 
1749
- /**
1750
- * A callback to communicate computed props to a consumer
1751
- */
1752
- onComputedProps: T.func,
2604
+ Object.defineProperty(exports, "__esModule", {
2605
+ value: true
2606
+ });
1753
2607
 
1754
- /**
1755
- * A callback to obtain visualization api
1756
- */
1757
- vizActionHandlerRef: T.func,
1758
- loading: T.bool,
1759
- theme: T.object,
2608
+ var react_1 = __webpack_require__(0);
1760
2609
 
1761
- /**
1762
- * A callback to request new data with updated request params
1763
- */
1764
- onRequestParamsChange: T.func
1765
- };
2610
+ var Options_1 = __webpack_require__(16);
1766
2611
  /**
1767
- *
2612
+ * Hook that evaluates the DSL for subset of a viz's options needed to determine
2613
+ * its x and y fields as well as the types of all its fields.
1768
2614
  */
1769
2615
 
1770
- SplunkVisualization.defaultProps = {
1771
- // BaseVisualization in dashboard-visualizations uses 100% for width but 250 for height
1772
- width: '100%',
1773
- height: exports.INITIAL_HEIGHT,
1774
- dataSources: {},
1775
- onEventTrigger: function onEventTrigger() {
1776
- return {};
1777
- },
1778
- mode: 'view',
1779
- hasEventHandlers: false,
1780
- options: {},
1781
- context: {},
1782
- onOptionsChange: function onOptionsChange() {
1783
- return {};
1784
- },
1785
- vizActionHandlerRef: function vizActionHandlerRef() {
1786
- return new VizActionHandler_1.DefaultVizActionHandler();
1787
- },
1788
- onComputedProps: function onComputedProps() {
1789
- return {};
1790
- },
1791
- loading: false,
1792
- onRequestParamsChange: lodash_1.noop
1793
- };
1794
- exports.default = SplunkVisualization;
1795
2616
 
1796
- /***/ }),
2617
+ var useGetXAndYFields = function useGetXAndYFields(_ref) {
2618
+ var shouldEvaluateDSL = _ref.shouldEvaluateDSL,
2619
+ options = _ref.options,
2620
+ context = _ref.context,
2621
+ dataSources = _ref.dataSources;
1797
2622
 
1798
- /***/ 43:
1799
- /***/ (function(module, exports, __webpack_require__) {
2623
+ var _ref2 = (0, react_1.useMemo)(function () {
2624
+ var _a, _b, _c;
1800
2625
 
1801
- "use strict";
2626
+ if (!shouldEvaluateDSL) {
2627
+ return {
2628
+ dataSourcesWithOnlyOnePoint: null,
2629
+ dataFrameWithOnlyOnePoint: null
2630
+ };
2631
+ }
1802
2632
 
2633
+ if (!((_c = (_b = (_a = dataSources === null || dataSources === void 0 ? void 0 : dataSources.primary) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.columns) === null || _c === void 0 ? void 0 : _c.length)) {
2634
+ return {
2635
+ dataSourcesWithOnlyOnePoint: null,
2636
+ dataFrameWithOnlyOnePoint: null
2637
+ };
2638
+ }
1803
2639
 
1804
- var _classCallCheck = __webpack_require__(9);
2640
+ var primaryDS = dataSources.primary;
2641
+ var columnsWithOnlyOnePoint = primaryDS.data.columns.map(function (column) {
2642
+ return [column[0]];
2643
+ });
2644
+ var filteredDataSources = {
2645
+ primary: Object.assign(Object.assign({}, primaryDS), {
2646
+ data: Object.assign(Object.assign({}, primaryDS.data), {
2647
+ columns: columnsWithOnlyOnePoint
2648
+ })
2649
+ })
2650
+ };
2651
+ return {
2652
+ dataSourcesWithOnlyOnePoint: filteredDataSources,
2653
+ dataFrameWithOnlyOnePoint: Options_1.Options.dataFrameFromDataSource(filteredDataSources)
2654
+ };
2655
+ }, [dataSources, shouldEvaluateDSL]),
2656
+ dataSourcesWithOnlyOnePoint = _ref2.dataSourcesWithOnlyOnePoint,
2657
+ dataFrameWithOnlyOnePoint = _ref2.dataFrameWithOnlyOnePoint;
2658
+
2659
+ var xAndYFieldsWithTypes = (0, react_1.useMemo)(function () {
2660
+ try {
2661
+ if (!dataSourcesWithOnlyOnePoint || !dataFrameWithOnlyOnePoint) {
2662
+ return options;
2663
+ }
1805
2664
 
1806
- var _createClass = __webpack_require__(18);
2665
+ if (!(options === null || options === void 0 ? void 0 : options.x) || !(options === null || options === void 0 ? void 0 : options.y) && !(options === null || options === void 0 ? void 0 : options.y2)) {
2666
+ return options;
2667
+ }
1807
2668
 
1808
- Object.defineProperty(exports, "__esModule", {
1809
- value: true
1810
- });
1811
- exports.DefaultVizActionHandler = void 0;
2669
+ var optionsToEvaluate = {
2670
+ x: options.x,
2671
+ xField: '> x | getField()',
2672
+ y: options.y,
2673
+ yFields: options.y ? '> y | getField()' : undefined,
2674
+ y2: options.y2,
2675
+ y2Fields: options.y2 ? '> y2 | getField()' : undefined,
2676
+ fieldTypes: '> primary | getType()'
2677
+ };
1812
2678
 
1813
- var DefaultVizActionHandler = /*#__PURE__*/function () {
1814
- function DefaultVizActionHandler() {
1815
- _classCallCheck(this, DefaultVizActionHandler);
1816
- }
2679
+ var _Options_1$Options$ev = Options_1.Options.evaluate({
2680
+ options: optionsToEvaluate,
2681
+ context: context
2682
+ }, dataSourcesWithOnlyOnePoint, function () {}, dataFrameWithOnlyOnePoint),
2683
+ _Options_1$Options$ev2 = _Options_1$Options$ev.xField,
2684
+ xField = _Options_1$Options$ev2 === void 0 ? '' : _Options_1$Options$ev2,
2685
+ _Options_1$Options$ev3 = _Options_1$Options$ev.yFields,
2686
+ yFields = _Options_1$Options$ev3 === void 0 ? [] : _Options_1$Options$ev3,
2687
+ _Options_1$Options$ev4 = _Options_1$Options$ev.y2Fields,
2688
+ y2Fields = _Options_1$Options$ev4 === void 0 ? [] : _Options_1$Options$ev4,
2689
+ fieldTypes = _Options_1$Options$ev.fieldTypes;
1817
2690
 
1818
- _createClass(DefaultVizActionHandler, [{
1819
- key: "focus",
1820
- value: function focus() {// noop
1821
- }
1822
- }, {
1823
- key: "snapshot",
1824
- value: function snapshot() {
1825
- return null; // noop
2691
+ return {
2692
+ xField: xField,
2693
+ yFields: [].concat(_toConsumableArray(yFields), _toConsumableArray(y2Fields)),
2694
+ fieldTypes: fieldTypes
2695
+ };
2696
+ } catch (e) {
2697
+ return {
2698
+ xField: undefined,
2699
+ yFields: [],
2700
+ fieldTypes: []
2701
+ };
1826
2702
  }
1827
- }]);
1828
-
1829
- return DefaultVizActionHandler;
1830
- }();
2703
+ }, [options, context, dataSourcesWithOnlyOnePoint, dataFrameWithOnlyOnePoint]);
2704
+ return xAndYFieldsWithTypes;
2705
+ };
1831
2706
 
1832
- exports.DefaultVizActionHandler = DefaultVizActionHandler;
2707
+ exports.default = useGetXAndYFields;
1833
2708
 
1834
2709
  /***/ }),
1835
-
1836
- /***/ 44:
2710
+ /* 68 */
1837
2711
  /***/ (function(module, exports, __webpack_require__) {
1838
2712
 
1839
2713
  "use strict";
@@ -1842,178 +2716,449 @@ exports.DefaultVizActionHandler = DefaultVizActionHandler;
1842
2716
  Object.defineProperty(exports, "__esModule", {
1843
2717
  value: true
1844
2718
  });
1845
- exports.useDeepMemo = void 0;
2719
+ exports.getFeatureFlag = void 0;
1846
2720
 
1847
- var react_1 = __webpack_require__(1);
2721
+ var FeatureFlags_1 = __webpack_require__(69);
1848
2722
 
1849
- var lodash_1 = __webpack_require__(3);
1850
- /**
1851
- * This hook evaluates and stores the result of a passed function and only
1852
- * re-evaluates the function when passed dependencies change.
1853
- *
1854
- * It is different from the internal React useMemo in the following aspects:
1855
- * - it only stores the last evaluated result
1856
- * - it uses a deep equality check to determine if dependencies have changed
1857
- *
1858
- * Inspired by apollo-client's useDeepMemo
1859
- *
1860
- * @param fn the function to be executed and
1861
- * @param dependencies an array of dependencies
1862
- */
2723
+ var getFeatureFlag = function getFeatureFlag(context, flagName) {
2724
+ // look for feature flag in context first
2725
+ if (context && Object.keys(context).find(function (key) {
2726
+ return key === flagName;
2727
+ })) {
2728
+ return context[flagName];
2729
+ } // fall back to defaults
1863
2730
 
1864
2731
 
1865
- var useDeepMemo = function useDeepMemo(fn, dependencies) {
1866
- var ref = (0, react_1.useRef)();
2732
+ if (Object.keys(FeatureFlags_1.default).find(function (key) {
2733
+ return key === flagName;
2734
+ })) {
2735
+ return FeatureFlags_1.default[flagName];
2736
+ } // fall back to false
1867
2737
 
1868
- if (!ref.current || !(0, lodash_1.isEqual)(dependencies, ref.current.dependencies)) {
1869
- ref.current = {
1870
- dependencies: dependencies,
1871
- value: fn()
1872
- };
1873
- }
1874
2738
 
1875
- return ref.current.value;
2739
+ return false;
1876
2740
  };
1877
2741
 
1878
- exports.useDeepMemo = useDeepMemo;
2742
+ exports.getFeatureFlag = getFeatureFlag;
2743
+
2744
+ /***/ }),
2745
+ /* 69 */
2746
+ /***/ (function(module, exports) {
2747
+
2748
+ module.exports = require("@splunk/visualization-context/FeatureFlags");
1879
2749
 
1880
2750
  /***/ }),
2751
+ /* 70 */,
2752
+ /* 71 */,
2753
+ /* 72 */,
2754
+ /* 73 */,
2755
+ /* 74 */
2756
+ /***/ (function(module, exports) {
1881
2757
 
1882
- /***/ 45:
2758
+ module.exports = require("@splunk/visualization-icons");
2759
+
2760
+ /***/ }),
2761
+ /* 75 */,
2762
+ /* 76 */,
2763
+ /* 77 */,
2764
+ /* 78 */,
2765
+ /* 79 */,
2766
+ /* 80 */,
2767
+ /* 81 */,
2768
+ /* 82 */,
2769
+ /* 83 */,
2770
+ /* 84 */,
2771
+ /* 85 */,
2772
+ /* 86 */,
2773
+ /* 87 */,
2774
+ /* 88 */,
2775
+ /* 89 */,
2776
+ /* 90 */,
2777
+ /* 91 */,
2778
+ /* 92 */,
2779
+ /* 93 */,
2780
+ /* 94 */,
2781
+ /* 95 */,
2782
+ /* 96 */,
2783
+ /* 97 */,
2784
+ /* 98 */,
2785
+ /* 99 */,
2786
+ /* 100 */,
2787
+ /* 101 */,
2788
+ /* 102 */,
2789
+ /* 103 */,
2790
+ /* 104 */,
2791
+ /* 105 */,
2792
+ /* 106 */,
2793
+ /* 107 */,
2794
+ /* 108 */,
2795
+ /* 109 */,
2796
+ /* 110 */,
2797
+ /* 111 */,
2798
+ /* 112 */,
2799
+ /* 113 */,
2800
+ /* 114 */,
2801
+ /* 115 */,
2802
+ /* 116 */,
2803
+ /* 117 */,
2804
+ /* 118 */,
2805
+ /* 119 */,
2806
+ /* 120 */,
2807
+ /* 121 */,
2808
+ /* 122 */,
2809
+ /* 123 */,
2810
+ /* 124 */,
2811
+ /* 125 */,
2812
+ /* 126 */,
2813
+ /* 127 */,
2814
+ /* 128 */,
2815
+ /* 129 */,
2816
+ /* 130 */,
2817
+ /* 131 */,
2818
+ /* 132 */,
2819
+ /* 133 */,
2820
+ /* 134 */,
2821
+ /* 135 */,
2822
+ /* 136 */,
2823
+ /* 137 */,
2824
+ /* 138 */,
2825
+ /* 139 */,
2826
+ /* 140 */,
2827
+ /* 141 */,
2828
+ /* 142 */,
2829
+ /* 143 */,
2830
+ /* 144 */,
2831
+ /* 145 */,
2832
+ /* 146 */,
2833
+ /* 147 */,
2834
+ /* 148 */,
2835
+ /* 149 */,
2836
+ /* 150 */,
2837
+ /* 151 */,
2838
+ /* 152 */,
2839
+ /* 153 */,
2840
+ /* 154 */,
2841
+ /* 155 */,
2842
+ /* 156 */,
2843
+ /* 157 */,
2844
+ /* 158 */,
2845
+ /* 159 */,
2846
+ /* 160 */,
2847
+ /* 161 */,
2848
+ /* 162 */,
2849
+ /* 163 */,
2850
+ /* 164 */,
2851
+ /* 165 */,
2852
+ /* 166 */,
2853
+ /* 167 */,
2854
+ /* 168 */,
2855
+ /* 169 */,
2856
+ /* 170 */,
2857
+ /* 171 */,
2858
+ /* 172 */,
2859
+ /* 173 */,
2860
+ /* 174 */,
2861
+ /* 175 */
1883
2862
  /***/ (function(module, exports, __webpack_require__) {
1884
2863
 
1885
2864
  "use strict";
1886
2865
 
1887
2866
 
2867
+ var __rest = this && this.__rest || function (s, e) {
2868
+ var t = {};
2869
+
2870
+ for (var p in s) {
2871
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
2872
+ }
2873
+
2874
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2875
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
2876
+ }
2877
+ return t;
2878
+ };
2879
+
1888
2880
  Object.defineProperty(exports, "__esModule", {
1889
2881
  value: true
1890
2882
  });
1891
- exports.MissingPropsMessage = exports.missingKeys = exports.isMissing = void 0;
2883
+ exports.config = exports.themes = exports.toImageDimensions = exports.shouldShowPlaceholder = void 0;
1892
2884
 
1893
- var React = __webpack_require__(1);
2885
+ var lodash_1 = __webpack_require__(3);
1894
2886
 
1895
- var T = __webpack_require__(0);
2887
+ var React = __webpack_require__(0);
1896
2888
 
1897
2889
  var i18n_1 = __webpack_require__(2);
1898
2890
 
1899
- var Message_1 = __webpack_require__(10);
2891
+ var style_1 = __webpack_require__(18);
1900
2892
 
1901
- var FixedSizeContainer_1 = __webpack_require__(13);
1902
- /**
1903
- * @method isMissing
1904
- * @param {any} v
1905
- * @returns {boolean} true if the input value === null or undefined
1906
- */
2893
+ var RemoteImage_1 = __webpack_require__(176);
1907
2894
 
2895
+ var styled_components_1 = __webpack_require__(4);
1908
2896
 
1909
- var isMissing = function isMissing(v) {
1910
- return v === null || v === undefined;
2897
+ var T = __webpack_require__(1);
2898
+
2899
+ var config_1 = __webpack_require__(244);
2900
+
2901
+ exports.config = config_1.default;
2902
+
2903
+ var withDashboardViz_1 = __webpack_require__(56);
2904
+
2905
+ var ImageApi_1 = __webpack_require__(245);
2906
+
2907
+ var useEffect = React.useEffect,
2908
+ useRef = React.useRef;
2909
+ var validOptions = Object.keys(config_1.default.optionsSchema);
2910
+ var Container = styled_components_1.default.div.attrs(function () {
2911
+ return {
2912
+ 'data-test': 'image-container'
2913
+ };
2914
+ }).withConfig({
2915
+ displayName: "Image__Container",
2916
+ componentId: "kplb09-0"
2917
+ })(["position:relative;box-sizing:border-box;display:flex;justify-content:center;align-items:center;cursor:", ";", ";"], function (props) {
2918
+ return props.onClick ? 'pointer' : 'inherit';
2919
+ }, function (props) {
2920
+ return (0, style_1.toDimension)((0, lodash_1.pick)(props, ['width', 'height']));
2921
+ });
2922
+
2923
+ var shouldShowPlaceholder = function shouldShowPlaceholder(dataSources, loading, options) {
2924
+ if (options.src) {
2925
+ return false;
2926
+ }
2927
+
2928
+ return true;
1911
2929
  };
1912
2930
 
1913
- exports.isMissing = isMissing;
1914
- /**
1915
- * @method misskingKeys
1916
- * @param {string[]} keys
1917
- * @param {object} target
1918
- * @returns {string[]} the keys of missing required props
1919
- */
2931
+ exports.shouldShowPlaceholder = shouldShowPlaceholder;
1920
2932
 
1921
- var missingKeys = function missingKeys(keys, target) {
1922
- return keys.filter(function (k) {
1923
- return (0, exports.isMissing)(target[k]);
1924
- });
2933
+ var toImageDimensions = function toImageDimensions(props) {
2934
+ if (props.shouldPreserveAspectRatio) {
2935
+ return "\n max-width: 100%;\n max-height: 100%;\n width: auto;\n height: auto;\n ";
2936
+ }
2937
+
2938
+ return (0, style_1.toDimension)((0, lodash_1.pick)(props, ['width', 'height']));
1925
2939
  };
1926
2940
 
1927
- exports.missingKeys = missingKeys;
1928
- var propTypes = {
1929
- width: T.oneOfType([T.string, T.number]),
1930
- height: T.oneOfType([T.string, T.number]),
1931
- // eslint-disable-next-line react/no-unused-prop-types
1932
- backgroundColor: T.string,
1933
- missingProps: T.arrayOf(T.string)
2941
+ exports.toImageDimensions = toImageDimensions;
2942
+ var StyledImage = styled_components_1.default.img.withConfig({
2943
+ displayName: "Image__StyledImage",
2944
+ componentId: "kplb09-1"
2945
+ })(["display:block;", ";"], function (props) {
2946
+ return (0, exports.toImageDimensions)(props);
2947
+ });
2948
+
2949
+ var computeVizProps = function computeVizProps(_a) {
2950
+ var visualizationApiRef = _a.visualizationApiRef,
2951
+ title = _a.title,
2952
+ otherOptions = __rest(_a, ["visualizationApiRef", "title"]);
2953
+
2954
+ var options = (0, lodash_1.chain)(otherOptions).pick(validOptions).value();
2955
+ return {
2956
+ options: options,
2957
+ title: title,
2958
+ visualizationApiRef: visualizationApiRef
2959
+ };
1934
2960
  };
1935
- /**
1936
- * @method MissingPropsMessage
1937
- * @param {MissingPropsProps} props
1938
- * @returns {React.ReactElement}
1939
- */
1940
2961
 
1941
- var MissingPropsMessage = function MissingPropsMessage(props) {
1942
- var width = props.width,
1943
- height = props.height,
1944
- missingProps = props.missingProps;
1945
- return React.createElement(Message_1.default, {
1946
- "data-test": "message",
2962
+ var ImageVisualization = function ImageVisualization(_ref) {
2963
+ var height = _ref.height,
2964
+ width = _ref.width,
2965
+ _ref$title = _ref.title,
2966
+ title = _ref$title === void 0 ? '' : _ref$title,
2967
+ visualizationApiRef = _ref.visualizationApiRef,
2968
+ options = _ref.options,
2969
+ onImageClick = _ref.onImageClick;
2970
+ var src = options.src,
2971
+ preserveAspectRatio = options.preserveAspectRatio;
2972
+ var remoteImage = useRef(null);
2973
+ var api = useRef(new ImageApi_1.default({
2974
+ options: {
2975
+ src: src,
2976
+ preserveAspectRatio: preserveAspectRatio
2977
+ },
2978
+ remoteImage: remoteImage
2979
+ }));
2980
+ var isRemote = (0, RemoteImage_1.isRemoteImage)(src);
2981
+ useEffect(function () {
2982
+ visualizationApiRef(api.current);
2983
+ return function () {
2984
+ visualizationApiRef(null);
2985
+ };
2986
+ }, []);
2987
+ return React.createElement(Container, {
1947
2988
  width: width,
1948
2989
  height: height,
1949
- message: (0, i18n_1._)("Missing property: ".concat(missingProps.join(', ')))
1950
- });
2990
+ onClick: onImageClick
2991
+ }, isRemote ? React.createElement(RemoteImage_1.default, {
2992
+ imageURL: src,
2993
+ title: title,
2994
+ preserveAspectRatio: preserveAspectRatio,
2995
+ width: width,
2996
+ height: height,
2997
+ ref: remoteImage
2998
+ }) : React.createElement(StyledImage, {
2999
+ "data-test": "image",
3000
+ src: src,
3001
+ shouldPreserveAspectRatio: preserveAspectRatio,
3002
+ width: width,
3003
+ height: height,
3004
+ alt: (0, i18n_1._)(title),
3005
+ onError: function onError(e) {
3006
+ e.target.alt = (0, i18n_1._)('Image not found');
3007
+ },
3008
+ referrerPolicy: "no-referrer"
3009
+ }));
1951
3010
  };
1952
3011
 
1953
- exports.MissingPropsMessage = MissingPropsMessage;
1954
- exports.MissingPropsMessage.propTypes = propTypes;
1955
- exports.MissingPropsMessage.defaultProps = {
3012
+ var propTypes = {
3013
+ width: T.oneOfType([T.string, T.number]),
3014
+ height: T.oneOfType([T.string, T.number]),
3015
+ options: T.object,
3016
+ title: T.string,
3017
+ visualizationApiRef: T.func,
3018
+ onImageClick: T.func
3019
+ };
3020
+ var defaultProps = {
1956
3021
  width: '100%',
1957
- height: 250
3022
+ height: undefined,
3023
+ options: {},
3024
+ title: '',
3025
+ visualizationApiRef: lodash_1.noop,
3026
+ onImageClick: lodash_1.noop
1958
3027
  };
1959
- exports.default = (0, FixedSizeContainer_1.default)(exports.MissingPropsMessage);
3028
+ ImageVisualization.propTypes = propTypes;
3029
+ ImageVisualization.defaultProps = defaultProps;
3030
+ var Image = (0, withDashboardViz_1.default)({
3031
+ ReactViz: ImageVisualization,
3032
+ vizConfig: config_1.default,
3033
+ useIconPlaceholder: exports.shouldShowPlaceholder,
3034
+ computeVizProps: computeVizProps
3035
+ });
3036
+ var themes = null;
3037
+ exports.themes = themes;
3038
+ exports.default = Image;
1960
3039
 
1961
3040
  /***/ }),
3041
+ /* 176 */
3042
+ /***/ (function(module, exports) {
3043
+
3044
+ module.exports = require("@splunk/visualizations-shared/RemoteImage");
1962
3045
 
1963
- /***/ 46:
3046
+ /***/ }),
3047
+ /* 177 */,
3048
+ /* 178 */,
3049
+ /* 179 */,
3050
+ /* 180 */,
3051
+ /* 181 */,
3052
+ /* 182 */,
3053
+ /* 183 */,
3054
+ /* 184 */,
3055
+ /* 185 */,
3056
+ /* 186 */,
3057
+ /* 187 */,
3058
+ /* 188 */,
3059
+ /* 189 */,
3060
+ /* 190 */,
3061
+ /* 191 */,
3062
+ /* 192 */,
3063
+ /* 193 */,
3064
+ /* 194 */,
3065
+ /* 195 */,
3066
+ /* 196 */,
3067
+ /* 197 */,
3068
+ /* 198 */,
3069
+ /* 199 */,
3070
+ /* 200 */,
3071
+ /* 201 */,
3072
+ /* 202 */,
3073
+ /* 203 */,
3074
+ /* 204 */,
3075
+ /* 205 */,
3076
+ /* 206 */,
3077
+ /* 207 */,
3078
+ /* 208 */,
3079
+ /* 209 */,
3080
+ /* 210 */,
3081
+ /* 211 */,
3082
+ /* 212 */,
3083
+ /* 213 */,
3084
+ /* 214 */,
3085
+ /* 215 */,
3086
+ /* 216 */,
3087
+ /* 217 */,
3088
+ /* 218 */,
3089
+ /* 219 */,
3090
+ /* 220 */,
3091
+ /* 221 */,
3092
+ /* 222 */,
3093
+ /* 223 */,
3094
+ /* 224 */,
3095
+ /* 225 */,
3096
+ /* 226 */,
3097
+ /* 227 */,
3098
+ /* 228 */,
3099
+ /* 229 */,
3100
+ /* 230 */,
3101
+ /* 231 */,
3102
+ /* 232 */,
3103
+ /* 233 */,
3104
+ /* 234 */,
3105
+ /* 235 */,
3106
+ /* 236 */,
3107
+ /* 237 */,
3108
+ /* 238 */,
3109
+ /* 239 */,
3110
+ /* 240 */,
3111
+ /* 241 */,
3112
+ /* 242 */,
3113
+ /* 243 */
1964
3114
  /***/ (function(module, exports, __webpack_require__) {
1965
3115
 
1966
3116
  "use strict";
1967
3117
 
1968
3118
 
1969
- Object.defineProperty(exports, "__esModule", {
1970
- value: true
1971
- });
3119
+ var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
3120
+ if (k2 === undefined) k2 = k;
3121
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1972
3122
 
1973
- var React = __webpack_require__(1);
3123
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3124
+ desc = {
3125
+ enumerable: true,
3126
+ get: function get() {
3127
+ return m[k];
3128
+ }
3129
+ };
3130
+ }
1974
3131
 
1975
- var styled_components_1 = __webpack_require__(4);
3132
+ Object.defineProperty(o, k2, desc);
3133
+ } : function (o, m, k, k2) {
3134
+ if (k2 === undefined) k2 = k;
3135
+ o[k2] = m[k];
3136
+ });
1976
3137
 
1977
- var hocUtils_1 = __webpack_require__(15);
3138
+ var __exportStar = this && this.__exportStar || function (m, exports) {
3139
+ for (var p in m) {
3140
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
3141
+ }
3142
+ };
1978
3143
 
1979
- var Cover = styled_components_1.default.div.withConfig({
1980
- displayName: "withEditModeCover__Cover",
1981
- componentId: "sc-1gsbnxb-0"
1982
- })(["position:absolute;left:0;right:0;top:0;bottom:0;"]);
1983
- var Blocker = styled_components_1.default.div.attrs({
1984
- 'data-splunk-visualization-version': "26.1.2 - 9c7479612"
1985
- }).withConfig({
1986
- displayName: "withEditModeCover__Blocker",
1987
- componentId: "sc-1gsbnxb-1"
1988
- })(["position:relative;width:100%;height:100%;"]);
1989
- /**
1990
- * HOC that renders a cover layer in edit mode
1991
- * @method withEditModeCover
1992
- * @param {ExtendedDashViz} Visualization
1993
- * @returns {ExtendedDashViz} Wrapper
1994
- */
3144
+ Object.defineProperty(exports, "__esModule", {
3145
+ value: true
3146
+ });
3147
+ exports.default = void 0;
1995
3148
 
1996
- var withEditModeCover = function withEditModeCover(Visualization, disableEditModeCover) {
1997
- var Wrapper = function Wrapper(props) {
1998
- var mode = props.mode;
1999
- var showEditCover = mode === 'edit' && !disableEditModeCover;
2000
- return React.createElement(Blocker, null, React.createElement(Visualization, Object.assign({}, props)), showEditCover && React.createElement(Cover, {
2001
- "data-test": "edit-mode-cover"
2002
- }));
2003
- };
3149
+ __exportStar(__webpack_require__(175), exports);
2004
3150
 
2005
- (0, hocUtils_1.extendStaticWrapperProps)({
2006
- Wrapper: Wrapper,
2007
- Visualization: Visualization
2008
- });
2009
- return Wrapper;
2010
- };
3151
+ var Image_1 = __webpack_require__(175);
2011
3152
 
2012
- exports.default = withEditModeCover;
3153
+ Object.defineProperty(exports, "default", {
3154
+ enumerable: true,
3155
+ get: function get() {
3156
+ return Image_1.default;
3157
+ }
3158
+ });
2013
3159
 
2014
3160
  /***/ }),
2015
-
2016
- /***/ 47:
3161
+ /* 244 */
2017
3162
  /***/ (function(module, exports, __webpack_require__) {
2018
3163
 
2019
3164
  "use strict";
@@ -2023,127 +3168,154 @@ Object.defineProperty(exports, "__esModule", {
2023
3168
  value: true
2024
3169
  });
2025
3170
 
2026
- var React = __webpack_require__(1);
2027
-
2028
- var colorUtils_1 = __webpack_require__(12);
2029
-
2030
- var variables_1 = __webpack_require__(11);
3171
+ var i18n_1 = __webpack_require__(2);
2031
3172
 
2032
- var IconPlaceholder_1 = __webpack_require__(32);
3173
+ var visualization_icons_1 = __webpack_require__(74);
2033
3174
 
2034
3175
  var VizBehavior_1 = __webpack_require__(6);
2035
3176
 
2036
- var hocUtils_1 = __webpack_require__(15);
2037
-
2038
- var withPlaceholder = function withPlaceholder(Visualization) {
2039
- var useIconPlaceholder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : IconPlaceholder_1.shouldShowIconPlaceholder;
2040
- var config = Visualization.config;
2041
- var themes = config.themes;
2042
-
2043
- var Wrapper = function Wrapper(props) {
2044
- var _a, _b;
2045
-
2046
- var dataSources = props.dataSources,
2047
- loading = props.loading,
2048
- options = props.options,
2049
- height = props.height,
2050
- width = props.width;
2051
- var showPlaceholder = useIconPlaceholder(dataSources, loading, options);
2052
- var bgColorFromTheme = (0, colorUtils_1.isColor)(options === null || options === void 0 ? void 0 : options.backgroundColor) ? options === null || options === void 0 ? void 0 : options.backgroundColor : (_a = themes === null || themes === void 0 ? void 0 : themes.defaultBackgroundColor) === null || _a === void 0 ? void 0 : _a.call(themes, props);
2053
- var icon = (_b = config.placeholderIcon) !== null && _b !== void 0 ? _b : config.icon;
2054
- var iconColor = variables_1.default.contentColorActive(props);
2055
-
2056
- if (config.supports.includes(VizBehavior_1.VizBehavior.PLACEHOLDER) && showPlaceholder) {
2057
- return React.createElement(IconPlaceholder_1.default, {
2058
- "data-test": "icon-placeholder",
2059
- icon: icon,
2060
- width: width,
2061
- height: height,
2062
- backgroundColor: bgColorFromTheme,
2063
- iconColor: iconColor
2064
- });
2065
- }
3177
+ var VizCategory_1 = __webpack_require__(22);
2066
3178
 
2067
- return React.createElement(Visualization, Object.assign({}, props));
2068
- };
3179
+ var configUtils_1 = __webpack_require__(27);
2069
3180
 
2070
- (0, hocUtils_1.extendStaticWrapperProps)({
2071
- Wrapper: Wrapper,
2072
- Visualization: Visualization
2073
- });
2074
- return Wrapper;
3181
+ var dataContract = {
3182
+ requiredDataSources: [],
3183
+ optionalDataSources: [// Note: SCP-14090 disable ui for optional datasources. We may need to add it back later
3184
+ // {
3185
+ // name: 'annotation',
3186
+ // description: 'DataSource that populate event annotations',
3187
+ // },
3188
+ ],
3189
+ initialRequestParams: {}
2075
3190
  };
3191
+ var size = {
3192
+ initialWidth: 300,
3193
+ initialHeight: 300
3194
+ };
3195
+ var defaultContext = {};
3196
+ var optionsSchema = {
3197
+ src: {
3198
+ description: 'URL of an image file. All browser-supported image formats are acceptable.',
3199
+ type: 'string'
3200
+ },
3201
+ preserveAspectRatio: {
3202
+ default: false,
3203
+ description: 'Set to true to maintain the aspect ratio of an image when the screen is resized.',
3204
+ type: 'boolean'
3205
+ }
3206
+ };
3207
+ var editorConfig = [{
3208
+ label: (0, i18n_1._)('Image content'),
3209
+ layout: [[{
3210
+ label: (0, i18n_1._)('Image file'),
3211
+ option: 'src',
3212
+ editor: 'editor.image'
3213
+ }], [{
3214
+ label: (0, i18n_1._)('Preserve aspect ratio'),
3215
+ option: 'preserveAspectRatio',
3216
+ editor: 'editor.checkbox',
3217
+ showEditor: function showEditor(_ref) {
3218
+ var options = _ref.options;
3219
+ return !!options.src;
3220
+ }
3221
+ }]]
3222
+ }];
3223
+ var themes = {};
3224
+ /**
3225
+ * visualization configuration
3226
+ */
2076
3227
 
2077
- exports.default = withPlaceholder;
2078
-
2079
- /***/ }),
3228
+ var config = {
3229
+ /**
3230
+ * unique viz key
3231
+ */
3232
+ key: 'splunk.image',
2080
3233
 
2081
- /***/ 52:
2082
- /***/ (function(module, exports) {
3234
+ /**
3235
+ * viz name
3236
+ */
3237
+ name: (0, i18n_1._)('Image'),
3238
+ category: VizCategory_1.VizCategory.MISC,
2083
3239
 
2084
- module.exports = require("@splunk/visualization-icons");
3240
+ /**
3241
+ * viz icon
3242
+ */
3243
+ icon: visualization_icons_1.Image,
3244
+ dataContract: dataContract,
3245
+ size: size,
3246
+ defaultContext: defaultContext,
3247
+ optionsSchema: optionsSchema,
3248
+ editorConfig: editorConfig,
3249
+ supports: [VizBehavior_1.VizBehavior.DYNAMIC_OPTIONS, VizBehavior_1.VizBehavior.PLACEHOLDER, VizBehavior_1.VizBehavior.EVENTS],
3250
+ themes: themes,
3251
+ events: {
3252
+ 'image.click': {
3253
+ description: 'triggered when user clicks on the image'
3254
+ }
3255
+ }
3256
+ };
3257
+ exports.default = (0, configUtils_1.enhanceConfig)(config);
2085
3258
 
2086
3259
  /***/ }),
2087
-
2088
- /***/ 6:
3260
+ /* 245 */
2089
3261
  /***/ (function(module, exports, __webpack_require__) {
2090
3262
 
2091
3263
  "use strict";
2092
3264
 
2093
3265
 
3266
+ var _classCallCheck = __webpack_require__(10);
3267
+
3268
+ var _createClass = __webpack_require__(25);
3269
+
2094
3270
  Object.defineProperty(exports, "__esModule", {
2095
3271
  value: true
2096
3272
  });
2097
- exports.VizBehavior = void 0;
2098
- var VizBehavior;
2099
-
2100
- (function (VizBehavior) {
2101
- /**
2102
- * Dynamic Options Behavior.
2103
- * This allows visualization options to be powered by data
2104
- *
2105
- * **Example**
2106
- *
2107
- * sparklineValues: ">primary|seriesByIndex(0)"
2108
- * would configure sparklineValues with an array of data points
2109
- * coming from the first series in the primary datasource
2110
- *
2111
- */
2112
- VizBehavior["DYNAMIC_OPTIONS"] = "dynamic-options";
2113
- VizBehavior["EVENTS"] = "events";
2114
- /**
2115
- * Placeholder behavior: visualization will display a placeholder rather than fail if any of the `requiredProps` is
2116
- * missing.
2117
- * @type {string}
2118
- */
2119
3273
 
2120
- VizBehavior["PLACEHOLDER"] = "placeholder";
2121
- VizBehavior["PAGE_AND_SORT"] = "page-and-sort";
2122
- VizBehavior["TRELLIS"] = "trellis";
2123
- })(VizBehavior = exports.VizBehavior || (exports.VizBehavior = {}));
3274
+ var lodash_1 = __webpack_require__(3);
2124
3275
 
2125
- /***/ }),
3276
+ var RemoteImage_1 = __webpack_require__(176);
3277
+ /**
3278
+ * Image Api
3279
+ */
2126
3280
 
2127
- /***/ 7:
2128
- /***/ (function(module, exports) {
2129
3281
 
2130
- module.exports = require("@babel/runtime/helpers/defineProperty");
3282
+ var ImageApi = /*#__PURE__*/function () {
3283
+ function ImageApi(viz) {
3284
+ _classCallCheck(this, ImageApi);
2131
3285
 
2132
- /***/ }),
3286
+ this.viz = viz;
3287
+ }
3288
+ /**
3289
+ * put focus on the visualization
3290
+ */
3291
+ // eslint-disable-next-line class-methods-use-this
2133
3292
 
2134
- /***/ 8:
2135
- /***/ (function(module, exports) {
2136
3293
 
2137
- module.exports = require("@babel/runtime/helpers/toConsumableArray");
3294
+ _createClass(ImageApi, [{
3295
+ key: "focus",
3296
+ value: function focus() {}
3297
+ /**
3298
+ * return snapshot of that includes inlined image
3299
+ */
2138
3300
 
2139
- /***/ }),
3301
+ }, {
3302
+ key: "snapshot",
3303
+ value: function snapshot() {
3304
+ var srcFromOptions = (0, lodash_1.get)(this.viz.options, 'src', '');
3305
+ var isRemote = (0, RemoteImage_1.isRemoteImage)(srcFromOptions);
3306
+ return {
3307
+ options: Object.assign(Object.assign({}, this.viz.options), {
3308
+ src: isRemote && this.viz.remoteImage ? (0, lodash_1.get)(this.viz.remoteImage, ['current', 'state', 'imageDataURI'], '') : srcFromOptions
3309
+ })
3310
+ };
3311
+ }
3312
+ }]);
2140
3313
 
2141
- /***/ 9:
2142
- /***/ (function(module, exports) {
3314
+ return ImageApi;
3315
+ }();
2143
3316
 
2144
- module.exports = require("@babel/runtime/helpers/classCallCheck");
3317
+ exports.default = ImageApi;
2145
3318
 
2146
3319
  /***/ })
2147
-
2148
- /******/ });
3320
+ /******/ ]);
2149
3321
  //# sourceMappingURL=Image.js.map