@splunk/visualizations 27.1.0 → 27.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 (52) hide show
  1. package/Area.js +2 -2
  2. package/Bar.js +2 -2
  3. package/Bubble.js +2 -2
  4. package/ChoroplethSvg.js +6 -9
  5. package/ChoroplethSvg.js.map +3 -3
  6. package/Column.js +2 -2
  7. package/Ellipse.js +2 -2
  8. package/Events.js +106 -491
  9. package/Events.js.map +4 -4
  10. package/FillerGauge.js +3 -3
  11. package/FillerGauge.js.map +3 -3
  12. package/Image.js +2 -2
  13. package/Line.js +2 -2
  14. package/LinkGraph.js +23 -18
  15. package/LinkGraph.js.map +2 -2
  16. package/Map.config.js +114 -72
  17. package/Map.config.js.map +4 -4
  18. package/Map.js +139 -86
  19. package/Map.js.map +4 -4
  20. package/Markdown.js +2 -2
  21. package/MarkerGauge.js +2 -2
  22. package/ParallelCoordinates.js +3 -3
  23. package/ParallelCoordinates.js.map +3 -3
  24. package/Pie.js +2 -2
  25. package/Punchcard.js +199 -26
  26. package/Punchcard.js.map +4 -4
  27. package/Rectangle.js +2 -2
  28. package/Sankey.js +2 -2
  29. package/Scatter.js +2 -2
  30. package/SingleValue.js +19 -9
  31. package/SingleValue.js.map +3 -3
  32. package/SingleValueBasic.js +1 -1
  33. package/SingleValueBasic.js.map +3 -3
  34. package/SingleValueIcon.js +380 -117
  35. package/SingleValueIcon.js.map +4 -4
  36. package/SingleValueRadial.js +16 -9
  37. package/SingleValueRadial.js.map +3 -3
  38. package/SparkLine.js +1 -1
  39. package/SparkLine.js.map +3 -3
  40. package/Table.js +15 -10
  41. package/Table.js.map +3 -3
  42. package/Timeline.config.js +418 -0
  43. package/Timeline.config.js.map +7 -0
  44. package/Timeline.js +3074 -0
  45. package/Timeline.js.map +7 -0
  46. package/common/OptionsDoc.js +2 -2
  47. package/common/OptionsDoc.js.map +1 -1
  48. package/common/utils/mapUtils.js.map +2 -2
  49. package/common/utils/singleValueUtils.js +18 -8
  50. package/common/utils/singleValueUtils.js.map +2 -2
  51. package/common/withDashboardViz.js +2 -2
  52. package/package.json +43 -31
package/Timeline.js ADDED
@@ -0,0 +1,3074 @@
1
+ /* Copyright © 2020 Splunk Inc.
2
+ SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
3
+ in part without a valid written license from Splunk Inc. is PROHIBITED. */
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __defProps = Object.defineProperties;
7
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
11
+ var __getProtoOf = Object.getPrototypeOf;
12
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
13
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
14
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15
+ var __spreadValues = (a, b) => {
16
+ for (var prop in b || (b = {}))
17
+ if (__hasOwnProp.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ if (__getOwnPropSymbols)
20
+ for (var prop of __getOwnPropSymbols(b)) {
21
+ if (__propIsEnum.call(b, prop))
22
+ __defNormalProp(a, prop, b[prop]);
23
+ }
24
+ return a;
25
+ };
26
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
27
+ var __objRest = (source, exclude) => {
28
+ var target = {};
29
+ for (var prop in source)
30
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
31
+ target[prop] = source[prop];
32
+ if (source != null && __getOwnPropSymbols)
33
+ for (var prop of __getOwnPropSymbols(source)) {
34
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
35
+ target[prop] = source[prop];
36
+ }
37
+ return target;
38
+ };
39
+ var __export = (target, all) => {
40
+ for (var name in all)
41
+ __defProp(target, name, { get: all[name], enumerable: true });
42
+ };
43
+ var __copyProps = (to, from, except, desc) => {
44
+ if (from && typeof from === "object" || typeof from === "function") {
45
+ for (let key of __getOwnPropNames(from))
46
+ if (!__hasOwnProp.call(to, key) && key !== except)
47
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
48
+ }
49
+ return to;
50
+ };
51
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
52
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
53
+ // If the importer is in node compatibility mode or this is not an ESM
54
+ // file that has been converted to a CommonJS file using a Babel-
55
+ // compatible transform (i.e. "__esModule" has not been set), then set
56
+ // "default" to the CommonJS "module.exports" for node compatibility.
57
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
58
+ mod
59
+ ));
60
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
61
+
62
+ // src/Timeline/index.ts
63
+ var Timeline_exports = {};
64
+ __export(Timeline_exports, {
65
+ computeVizProps: () => computeVizProps,
66
+ config: () => config2,
67
+ default: () => Timeline_default,
68
+ themes: () => themes2
69
+ });
70
+ module.exports = __toCommonJS(Timeline_exports);
71
+
72
+ // esm-externals:lodash
73
+ var lodash_exports = {};
74
+ __export(lodash_exports, {
75
+ default: () => lodash_default
76
+ });
77
+ var defaultImport = __toESM(require("lodash"));
78
+ __reExport(lodash_exports, require("lodash"));
79
+ var lodash_default = "default" in defaultImport ? defaultImport.default : defaultImport;
80
+
81
+ // esm-externals:@splunk/visualization-schemas
82
+ var visualization_schemas_exports = {};
83
+ __export(visualization_schemas_exports, {
84
+ default: () => visualization_schemas_default
85
+ });
86
+ var defaultImport2 = __toESM(require("@splunk/visualization-schemas"));
87
+ __reExport(visualization_schemas_exports, require("@splunk/visualization-schemas"));
88
+ var visualization_schemas_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;
89
+
90
+ // esm-externals:@splunk/visualization-color-palettes
91
+ var visualization_color_palettes_exports = {};
92
+ __export(visualization_color_palettes_exports, {
93
+ default: () => visualization_color_palettes_default
94
+ });
95
+ var defaultImport3 = __toESM(require("@splunk/visualization-color-palettes"));
96
+ __reExport(visualization_color_palettes_exports, require("@splunk/visualization-color-palettes"));
97
+ var visualization_color_palettes_default = "default" in defaultImport3 ? defaultImport3.default : defaultImport3;
98
+
99
+ // esm-externals:@splunk/visualizations-shared/colorUtils
100
+ var colorUtils_exports = {};
101
+ __export(colorUtils_exports, {
102
+ default: () => colorUtils_default
103
+ });
104
+ var defaultImport4 = __toESM(require("@splunk/visualizations-shared/colorUtils"));
105
+ __reExport(colorUtils_exports, require("@splunk/visualizations-shared/colorUtils"));
106
+ var colorUtils_default = "default" in defaultImport4 ? defaultImport4.default : defaultImport4;
107
+
108
+ // esm-externals:@splunk/visualization-icons
109
+ var visualization_icons_exports = {};
110
+ __export(visualization_icons_exports, {
111
+ default: () => visualization_icons_default
112
+ });
113
+ var defaultImport5 = __toESM(require("@splunk/visualization-icons"));
114
+ __reExport(visualization_icons_exports, require("@splunk/visualization-icons"));
115
+ var visualization_icons_default = "default" in defaultImport5 ? defaultImport5.default : defaultImport5;
116
+
117
+ // esm-externals:@splunk/visualization-color-palettes/editors/PresetPalettes
118
+ var PresetPalettes_exports = {};
119
+ __export(PresetPalettes_exports, {
120
+ default: () => PresetPalettes_default
121
+ });
122
+ var defaultImport6 = __toESM(require("@splunk/visualization-color-palettes/editors/PresetPalettes"));
123
+ __reExport(PresetPalettes_exports, require("@splunk/visualization-color-palettes/editors/PresetPalettes"));
124
+ var PresetPalettes_default = "default" in defaultImport6 ? defaultImport6.default : defaultImport6;
125
+
126
+ // esm-externals:@splunk/ui-utils/i18n
127
+ var i18n_exports = {};
128
+ __export(i18n_exports, {
129
+ default: () => i18n_default
130
+ });
131
+ var defaultImport7 = __toESM(require("@splunk/ui-utils/i18n"));
132
+ __reExport(i18n_exports, require("@splunk/ui-utils/i18n"));
133
+ var i18n_default = "default" in defaultImport7 ? defaultImport7.default : defaultImport7;
134
+
135
+ // esm-externals:@splunk/themes/pick
136
+ var pick_exports = {};
137
+ __export(pick_exports, {
138
+ default: () => pick_default
139
+ });
140
+ var defaultImport8 = __toESM(require("@splunk/themes/pick"));
141
+ __reExport(pick_exports, require("@splunk/themes/pick"));
142
+ var pick_default = "default" in defaultImport8 ? defaultImport8.default : defaultImport8;
143
+
144
+ // esm-externals:@splunk/themes/variables
145
+ var variables_exports = {};
146
+ __export(variables_exports, {
147
+ default: () => variables_default
148
+ });
149
+ var defaultImport9 = __toESM(require("@splunk/themes/variables"));
150
+ __reExport(variables_exports, require("@splunk/themes/variables"));
151
+ var variables_default = "default" in defaultImport9 ? defaultImport9.default : defaultImport9;
152
+
153
+ // esm-externals:@splunk/visualizations-shared/configUtils
154
+ var configUtils_exports = {};
155
+ __export(configUtils_exports, {
156
+ default: () => configUtils_default
157
+ });
158
+ var defaultImport10 = __toESM(require("@splunk/visualizations-shared/configUtils"));
159
+ __reExport(configUtils_exports, require("@splunk/visualizations-shared/configUtils"));
160
+ var configUtils_default = "default" in defaultImport10 ? defaultImport10.default : defaultImport10;
161
+
162
+ // src/common/utils/configUtils.ts
163
+ function enhanceConfig(vizConfig) {
164
+ const enhancedConfig = __spreadValues({}, vizConfig);
165
+ enhancedConfig.editorConfig = vizConfig.editorConfig.map(
166
+ (config3) => {
167
+ return __spreadProps(__spreadValues({}, config3), { open: config3.open || false });
168
+ }
169
+ );
170
+ return enhancedConfig;
171
+ }
172
+
173
+ // src/common/editorConfig/BackgroundColor.ts
174
+ var background = ({
175
+ label,
176
+ themes: themes3,
177
+ labelPosition
178
+ }) => [
179
+ {
180
+ label: (0, i18n_exports._)(label || "Background color"),
181
+ option: "backgroundColor",
182
+ editor: "editor.color",
183
+ editorProps: {
184
+ labelPosition: labelPosition || "top",
185
+ themes: themes3
186
+ }
187
+ }
188
+ ];
189
+ var BackgroundColor_default = background;
190
+
191
+ // src/Timeline/config.ts
192
+ var dataContract = {
193
+ requiredDataSources: [],
194
+ optionalDataSources: [
195
+ {
196
+ name: "primary",
197
+ description: "DataSource that powers the visualization."
198
+ }
199
+ ],
200
+ initialRequestParams: {
201
+ primary: { offset: 0, count: 1e4 }
202
+ }
203
+ };
204
+ var size = {
205
+ initialWidth: 300,
206
+ initialHeight: 300
207
+ };
208
+ var defaultContext = {
209
+ colorRangeConfig: [
210
+ { to: 20, value: "#D41F1F" },
211
+ { from: 20, to: 40, value: "#D94E17" },
212
+ { from: 40, to: 60, value: "#CBA700" },
213
+ { from: 60, to: 80, value: "#669922" },
214
+ { from: 80, value: "#118832" }
215
+ ],
216
+ colorMatchConfig: [{ match: "", value: "#5C33FF" }]
217
+ };
218
+ var themes = {
219
+ defaultBackgroundColor: (props) => pick_default({
220
+ enterprise: {
221
+ dark: variables_default.black(props),
222
+ light: variables_default.backgroundColor(props)
223
+ },
224
+ prisma: variables_default.backgroundColorSidebar(props)
225
+ })(props)
226
+ };
227
+ var editorConfig = [
228
+ {
229
+ label: (0, i18n_exports._)("Data configurations"),
230
+ layout: [
231
+ [
232
+ {
233
+ label: (0, i18n_exports._)("X"),
234
+ option: "x",
235
+ editor: "editor.columnSelector",
236
+ editorProps: {
237
+ dataSourceKey: "primary",
238
+ shouldShowInternalFields: false,
239
+ filterByTypes: ["time"]
240
+ }
241
+ }
242
+ ],
243
+ [
244
+ {
245
+ label: (0, i18n_exports._)("Y"),
246
+ option: "y",
247
+ editor: "editor.columnSelector",
248
+ editorProps: {
249
+ dataSourceKey: "primary",
250
+ shouldShowInternalFields: false,
251
+ filterByTypes: ["string", "number"]
252
+ }
253
+ }
254
+ ],
255
+ [
256
+ {
257
+ label: (0, i18n_exports._)("Duration"),
258
+ option: "duration",
259
+ editor: "editor.columnSelector",
260
+ editorProps: {
261
+ dataSourceKey: "primary",
262
+ shouldShowInternalFields: false,
263
+ filterByTypes: ["number"]
264
+ }
265
+ }
266
+ ],
267
+ [
268
+ {
269
+ label: (0, i18n_exports._)("Category"),
270
+ option: "category",
271
+ editor: "editor.columnSelector",
272
+ editorProps: {
273
+ dataSourceKey: "primary",
274
+ shouldShowInternalFields: false,
275
+ filterByTypes: ["string", "number"]
276
+ }
277
+ }
278
+ ],
279
+ [
280
+ {
281
+ label: (0, i18n_exports._)("Additional tooltip fields"),
282
+ option: "additionalTooltipFields",
283
+ editor: "editor.columnMultiSelectionByFieldNameEditor"
284
+ }
285
+ ],
286
+ [
287
+ {
288
+ label: (0, i18n_exports._)("Result limit"),
289
+ option: "resultLimit",
290
+ editor: "editor.number"
291
+ }
292
+ ]
293
+ ]
294
+ },
295
+ {
296
+ label: (0, i18n_exports._)("Data display"),
297
+ layout: [
298
+ [
299
+ {
300
+ label: (0, i18n_exports._)("Lane label width"),
301
+ option: "yAxisLabelWidth",
302
+ editor: "editor.number",
303
+ editorProps: {
304
+ min: 0
305
+ }
306
+ }
307
+ ]
308
+ ]
309
+ },
310
+ {
311
+ label: (0, i18n_exports._)("Color and style"),
312
+ layout: [
313
+ [
314
+ {
315
+ label: (0, i18n_exports._)("Data colors"),
316
+ option: "dataColors",
317
+ context: {
318
+ colorRangeConfig: "colorRangeConfig",
319
+ colorMatchConfig: "colorMatchConfig"
320
+ },
321
+ editor: "editor.dynamicColorWithPrecedence",
322
+ editorProps: {
323
+ labelPosition: "top",
324
+ flyoutTitle: (0, i18n_exports._)("Dynamic coloring: value"),
325
+ formatters: [
326
+ {
327
+ label: (0, i18n_exports._)("Ranges"),
328
+ value: "rangeValue",
329
+ isDefault: true,
330
+ defaults: {
331
+ duration: defaultContext.colorRangeConfig
332
+ }
333
+ },
334
+ {
335
+ label: (0, i18n_exports._)("Matches"),
336
+ value: "matchValue",
337
+ defaults: {
338
+ duration: defaultContext.colorMatchConfig
339
+ }
340
+ }
341
+ ],
342
+ dataSelectors: [
343
+ {
344
+ label: (0, i18n_exports._)("Data values"),
345
+ value: "duration"
346
+ }
347
+ ],
348
+ defaultPalettesConfig: PresetPalettes_exports.defaultPalettesConfig
349
+ }
350
+ }
351
+ ],
352
+ [
353
+ {
354
+ label: (0, i18n_exports._)("Data values"),
355
+ editor: "editor.columnSelector",
356
+ option: "duration",
357
+ showEditor: ({ options }) => options.dataColors,
358
+ editorProps: {
359
+ dataSourceKey: "primary",
360
+ filterByTypes: ["number"]
361
+ }
362
+ }
363
+ ],
364
+ [
365
+ {
366
+ label: (0, i18n_exports._)("Series colors"),
367
+ option: "seriesColors",
368
+ editor: "editor.seriesColors",
369
+ showEditor: ({ options }) => !options.dataColors
370
+ }
371
+ ],
372
+ BackgroundColor_default({ themes })
373
+ ]
374
+ },
375
+ {
376
+ label: (0, i18n_exports._)("Legend"),
377
+ layout: [
378
+ [
379
+ {
380
+ label: (0, i18n_exports._)("Legend display"),
381
+ option: "legendDisplay",
382
+ editor: "editor.select",
383
+ editorProps: {
384
+ values: [
385
+ { label: (0, i18n_exports._)("Right"), value: "right" },
386
+ { label: (0, i18n_exports._)("Bottom"), value: "bottom" },
387
+ { label: (0, i18n_exports._)("Off"), value: "off" }
388
+ ]
389
+ },
390
+ // disable legend if dataColors is on
391
+ isDisabled: ({ options }) => options.dataColors
392
+ }
393
+ ],
394
+ [
395
+ {
396
+ label: (0, i18n_exports._)("Truncation"),
397
+ option: "legendTruncation",
398
+ editor: "editor.radioBar",
399
+ default: "ellipsisOff",
400
+ editorProps: {
401
+ values: [
402
+ { label: (0, i18n_exports._)("A..."), value: "ellipsisEnd" },
403
+ { label: (0, i18n_exports._)("A...Z"), value: "ellipsisMiddle" },
404
+ { label: (0, i18n_exports._)("...Z"), value: "ellipsisStart" },
405
+ { label: (0, i18n_exports._)("Off"), value: "ellipsisOff" }
406
+ ]
407
+ },
408
+ isDisabled: ({ options }) => options.dataColors,
409
+ showEditor: ({ options }) => options.legendDisplay && options.legendDisplay !== "off"
410
+ }
411
+ ]
412
+ ]
413
+ }
414
+ ];
415
+ var config = {
416
+ /**
417
+ * unique viz key
418
+ */
419
+ key: "splunk.timeline",
420
+ /**
421
+ * viz name
422
+ */
423
+ name: (0, i18n_exports._)("Timeline"),
424
+ category: "Timeline" /* TIMELINE */,
425
+ status: "preview",
426
+ /**
427
+ * viz icon
428
+ */
429
+ icon: visualization_icons_exports.Timeline,
430
+ // placeholderIcon: TimelinePlaceholderIcon, TBD
431
+ dataContract,
432
+ size,
433
+ defaultContext,
434
+ optionsSchema: visualization_schemas_exports.timelineOptionsSchema,
435
+ editorConfig,
436
+ events: {
437
+ "event.click": {
438
+ description: "triggered when user clicks on an event"
439
+ },
440
+ "lane.click": {
441
+ description: "triggered when user clicks on a lane label"
442
+ },
443
+ "legend.click": {
444
+ description: "triggered when user clicks on chart legend"
445
+ }
446
+ },
447
+ supports: ["dynamic-options" /* DYNAMIC_OPTIONS */, "placeholder" /* PLACEHOLDER */, "events" /* EVENTS */],
448
+ themes
449
+ };
450
+ var config_default = enhanceConfig(config);
451
+
452
+ // esm-externals:react
453
+ var react_exports = {};
454
+ __export(react_exports, {
455
+ default: () => react_default
456
+ });
457
+ var defaultImport11 = __toESM(require("react"));
458
+ __reExport(react_exports, require("react"));
459
+ var react_default = "default" in defaultImport11 ? defaultImport11.default : defaultImport11;
460
+
461
+ // esm-externals:@splunk/themes/getSettingsFromThemedProps
462
+ var getSettingsFromThemedProps_exports = {};
463
+ __export(getSettingsFromThemedProps_exports, {
464
+ default: () => getSettingsFromThemedProps_default
465
+ });
466
+ var defaultImport12 = __toESM(require("@splunk/themes/getSettingsFromThemedProps"));
467
+ __reExport(getSettingsFromThemedProps_exports, require("@splunk/themes/getSettingsFromThemedProps"));
468
+ var getSettingsFromThemedProps_default = "default" in defaultImport12 ? defaultImport12.default : defaultImport12;
469
+
470
+ // esm-externals:@splunk/visualization-encoding/Options
471
+ var Options_exports = {};
472
+ __export(Options_exports, {
473
+ default: () => Options_default
474
+ });
475
+ var defaultImport13 = __toESM(require("@splunk/visualization-encoding/Options"));
476
+ __reExport(Options_exports, require("@splunk/visualization-encoding/Options"));
477
+ var Options_default = "default" in defaultImport13 ? defaultImport13.default : defaultImport13;
478
+
479
+ // esm-externals:@splunk/visualizations-shared/SanitizeProps
480
+ var SanitizeProps_exports = {};
481
+ __export(SanitizeProps_exports, {
482
+ default: () => SanitizeProps_default
483
+ });
484
+ var defaultImport14 = __toESM(require("@splunk/visualizations-shared/SanitizeProps"));
485
+ __reExport(SanitizeProps_exports, require("@splunk/visualizations-shared/SanitizeProps"));
486
+ var SanitizeProps_default = "default" in defaultImport14 ? defaultImport14.default : defaultImport14;
487
+
488
+ // esm-externals:@splunk/visualization-context/TimezoneContext
489
+ var TimezoneContext_exports = {};
490
+ __export(TimezoneContext_exports, {
491
+ default: () => TimezoneContext_default
492
+ });
493
+ var defaultImport15 = __toESM(require("@splunk/visualization-context/TimezoneContext"));
494
+ __reExport(TimezoneContext_exports, require("@splunk/visualization-context/TimezoneContext"));
495
+ var TimezoneContext_default = "default" in defaultImport15 ? defaultImport15.default : defaultImport15;
496
+
497
+ // esm-externals:@splunk/moment
498
+ var moment_exports = {};
499
+ __export(moment_exports, {
500
+ default: () => moment_default
501
+ });
502
+ var defaultImport16 = __toESM(require("@splunk/moment"));
503
+ __reExport(moment_exports, require("@splunk/moment"));
504
+ var moment_default = "default" in defaultImport16 ? defaultImport16.default : defaultImport16;
505
+
506
+ // esm-externals:@splunk/visualization-context/FeatureFlagContext
507
+ var FeatureFlagContext_exports = {};
508
+ __export(FeatureFlagContext_exports, {
509
+ default: () => FeatureFlagContext_default
510
+ });
511
+ var defaultImport17 = __toESM(require("@splunk/visualization-context/FeatureFlagContext"));
512
+ __reExport(FeatureFlagContext_exports, require("@splunk/visualization-context/FeatureFlagContext"));
513
+ var FeatureFlagContext_default = "default" in defaultImport17 ? defaultImport17.default : defaultImport17;
514
+
515
+ // esm-externals:styled-components
516
+ var styled_components_exports = {};
517
+ __export(styled_components_exports, {
518
+ default: () => styled_components_default
519
+ });
520
+ var defaultImport18 = __toESM(require("styled-components"));
521
+ __reExport(styled_components_exports, require("styled-components"));
522
+ var styled_components_default = "default" in defaultImport18 ? defaultImport18.default : defaultImport18;
523
+
524
+ // esm-externals:@splunk/visualizations-shared/hocUtils
525
+ var hocUtils_exports = {};
526
+ __export(hocUtils_exports, {
527
+ default: () => hocUtils_default
528
+ });
529
+ var defaultImport19 = __toESM(require("@splunk/visualizations-shared/hocUtils"));
530
+ __reExport(hocUtils_exports, require("@splunk/visualizations-shared/hocUtils"));
531
+ var hocUtils_default = "default" in defaultImport19 ? defaultImport19.default : defaultImport19;
532
+
533
+ // esm-externals:@splunk/visualizations-shared/JSONSchemaUtils
534
+ var JSONSchemaUtils_exports = {};
535
+ __export(JSONSchemaUtils_exports, {
536
+ default: () => JSONSchemaUtils_default
537
+ });
538
+ var defaultImport20 = __toESM(require("@splunk/visualizations-shared/JSONSchemaUtils"));
539
+ __reExport(JSONSchemaUtils_exports, require("@splunk/visualizations-shared/JSONSchemaUtils"));
540
+ var JSONSchemaUtils_default = "default" in defaultImport20 ? defaultImport20.default : defaultImport20;
541
+
542
+ // esm-externals:@splunk/async-dynamic-options-evaluator
543
+ var async_dynamic_options_evaluator_exports = {};
544
+ __export(async_dynamic_options_evaluator_exports, {
545
+ default: () => async_dynamic_options_evaluator_default
546
+ });
547
+ var defaultImport21 = __toESM(require("@splunk/async-dynamic-options-evaluator"));
548
+ __reExport(async_dynamic_options_evaluator_exports, require("@splunk/async-dynamic-options-evaluator"));
549
+ var async_dynamic_options_evaluator_default = "default" in defaultImport21 ? defaultImport21.default : defaultImport21;
550
+
551
+ // esm-externals:@splunk/ui-utils/id
552
+ var id_exports = {};
553
+ __export(id_exports, {
554
+ default: () => id_default
555
+ });
556
+ var defaultImport22 = __toESM(require("@splunk/ui-utils/id"));
557
+ __reExport(id_exports, require("@splunk/ui-utils/id"));
558
+ var id_default = "default" in defaultImport22 ? defaultImport22.default : defaultImport22;
559
+
560
+ // esm-externals:prop-types
561
+ var prop_types_exports = {};
562
+ __export(prop_types_exports, {
563
+ default: () => prop_types_default
564
+ });
565
+ var defaultImport23 = __toESM(require("prop-types"));
566
+ __reExport(prop_types_exports, require("prop-types"));
567
+ var prop_types_default = "default" in defaultImport23 ? defaultImport23.default : defaultImport23;
568
+
569
+ // src/common/interfaces/VizActionHandler.ts
570
+ var DefaultVizActionHandler = class {
571
+ focus() {
572
+ }
573
+ snapshot() {
574
+ return null;
575
+ }
576
+ };
577
+
578
+ // src/common/SplunkVisualization.tsx
579
+ var INITIAL_HEIGHT = 250;
580
+ var SplunkVisualization = class {
581
+ };
582
+ SplunkVisualization.propTypes = {
583
+ /**
584
+ * display mode
585
+ */
586
+ mode: prop_types_exports.oneOf(["view", "edit", "export"]).isRequired,
587
+ /**
588
+ * width in pixel or string, defaults to 100%
589
+ */
590
+ width: prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number]).isRequired,
591
+ /**
592
+ * height in pixel or string
593
+ */
594
+ height: prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number]).isRequired,
595
+ /**
596
+ * visualization context used for dynamic option evaluation
597
+ */
598
+ context: prop_types_exports.object,
599
+ /**
600
+ * visualization formatting options
601
+ */
602
+ options: prop_types_exports.object,
603
+ /**
604
+ * A callback to update formatting options
605
+ */
606
+ onOptionsChange: prop_types_exports.func,
607
+ /**
608
+ * datasource state which include data and request params, object key indicate the datasource type.
609
+ */
610
+ dataSources: prop_types_exports.objectOf(
611
+ prop_types_exports.shape({
612
+ /**
613
+ * current request params
614
+ */
615
+ requestParams: prop_types_exports.object,
616
+ /**
617
+ * current dataset
618
+ */
619
+ data: prop_types_exports.shape({
620
+ fields: prop_types_exports.array,
621
+ columns: prop_types_exports.array
622
+ }),
623
+ /**
624
+ * error
625
+ */
626
+ error: prop_types_exports.shape({
627
+ level: prop_types_exports.string,
628
+ message: prop_types_exports.string
629
+ }),
630
+ /**
631
+ * meta data that came with the dataset
632
+ */
633
+ meta: prop_types_exports.object
634
+ })
635
+ ),
636
+ /**
637
+ * A callback to trigger event
638
+ */
639
+ onEventTrigger: prop_types_exports.func,
640
+ /**
641
+ * Inform viz if there are handlers listening to events
642
+ */
643
+ hasEventHandlers: prop_types_exports.bool,
644
+ /**
645
+ * A callback to communicate computed props to a consumer
646
+ */
647
+ onComputedProps: prop_types_exports.func,
648
+ /**
649
+ * A callback to obtain visualization api
650
+ */
651
+ vizActionHandlerRef: prop_types_exports.func,
652
+ loading: prop_types_exports.bool,
653
+ theme: prop_types_exports.object,
654
+ /**
655
+ * A callback to request new data with updated request params
656
+ */
657
+ onRequestParamsChange: prop_types_exports.func
658
+ };
659
+ /**
660
+ *
661
+ */
662
+ SplunkVisualization.defaultProps = {
663
+ // BaseVisualization in dashboard-visualizations uses 100% for width but 250 for height
664
+ width: "100%",
665
+ height: INITIAL_HEIGHT,
666
+ dataSources: {},
667
+ onEventTrigger: () => ({}),
668
+ mode: "view",
669
+ hasEventHandlers: false,
670
+ options: {},
671
+ context: {},
672
+ onOptionsChange: () => ({}),
673
+ vizActionHandlerRef: () => new DefaultVizActionHandler(),
674
+ onComputedProps: () => ({}),
675
+ loading: false,
676
+ onRequestParamsChange: lodash_exports.noop
677
+ };
678
+ var SplunkVisualization_default = SplunkVisualization;
679
+
680
+ // src/common/interfaces/DataSource.ts
681
+ var validSortDirs = ["asc", "desc", "none"];
682
+
683
+ // src/common/hooks/getSorting.ts
684
+ var SortParamsPropTypes = prop_types_exports.shape({
685
+ currentSortKey: prop_types_exports.string,
686
+ currentSortDir: prop_types_exports.oneOf(validSortDirs),
687
+ onSort: prop_types_exports.func
688
+ });
689
+ var getSortingParams = ({ requestParams, onRequestParamsChange }) => {
690
+ let currentSortKey;
691
+ let currentSortDir;
692
+ const nextSortDirMap = {
693
+ asc: "desc",
694
+ desc: "asc",
695
+ none: "asc"
696
+ };
697
+ let onSort;
698
+ if (typeof onRequestParamsChange === "function") {
699
+ if (requestParams && (0, lodash_exports.has)(requestParams, "sort")) {
700
+ currentSortKey = Object.keys(requestParams.sort).shift();
701
+ currentSortDir = requestParams.sort[currentSortKey];
702
+ }
703
+ onSort = (e, { sortKey, sortDir }) => {
704
+ if (typeof sortKey === "string") {
705
+ const nextSortDir = (0, lodash_exports.has)(nextSortDirMap, sortDir) ? nextSortDirMap[sortDir] : "none";
706
+ onRequestParamsChange(__spreadValues(__spreadValues({}, requestParams), { offset: 0, sort: { [sortKey]: nextSortDir } }));
707
+ } else {
708
+ onRequestParamsChange(requestParams);
709
+ }
710
+ };
711
+ }
712
+ return {
713
+ currentSortKey,
714
+ currentSortDir,
715
+ onSort
716
+ };
717
+ };
718
+
719
+ // src/common/hooks/getPagination.ts
720
+ var PaginatorParamsPropTypes = prop_types_exports.shape({
721
+ isPaging: prop_types_exports.bool,
722
+ current: prop_types_exports.number,
723
+ totalPages: prop_types_exports.number,
724
+ onChange: prop_types_exports.func
725
+ });
726
+ var getPaginationParams = ({
727
+ requestParams,
728
+ meta,
729
+ onRequestParamsChange
730
+ }) => {
731
+ const totalCount = meta && meta.totalCount || 0;
732
+ const offset = requestParams && requestParams.offset || 0;
733
+ const count = requestParams && requestParams.count;
734
+ const totalPages = typeof count === "number" && count > 0 ? Math.ceil(totalCount / count) : 0;
735
+ const current = typeof count === "number" && count > 0 ? Math.floor(offset / count) + 1 : 0;
736
+ const isPaging = totalPages > 1 && typeof onRequestParamsChange === "function";
737
+ const onChangeHandler = (e, { page, count: countArg }) => {
738
+ const newParams = (0, lodash_exports.cloneDeep)(requestParams);
739
+ if (typeof countArg === "number") {
740
+ newParams.count = countArg;
741
+ newParams.offset = 0;
742
+ }
743
+ const pageCount = typeof newParams.count === "number" ? newParams.count : 10;
744
+ if (typeof page === "number" && page > 0) {
745
+ newParams.count = pageCount;
746
+ newParams.offset = (page - 1) * pageCount;
747
+ }
748
+ onRequestParamsChange(newParams);
749
+ };
750
+ return {
751
+ isPaging,
752
+ current,
753
+ totalPages,
754
+ onChange: typeof onRequestParamsChange === "function" ? onChangeHandler : lodash_exports.noop
755
+ };
756
+ };
757
+
758
+ // src/common/hooks/useDeepMemo.ts
759
+ var useDeepMemo = (fn, dependencies) => {
760
+ const ref = (0, react_exports.useRef)();
761
+ if (!ref.current || !(0, lodash_exports.isEqual)(dependencies, ref.current.dependencies)) {
762
+ ref.current = {
763
+ dependencies,
764
+ value: fn()
765
+ };
766
+ }
767
+ return ref.current.value;
768
+ };
769
+
770
+ // esm-externals:@splunk/visualizations-shared/Message
771
+ var Message_exports = {};
772
+ __export(Message_exports, {
773
+ default: () => Message_default
774
+ });
775
+ var defaultImport24 = __toESM(require("@splunk/visualizations-shared/Message"));
776
+ __reExport(Message_exports, require("@splunk/visualizations-shared/Message"));
777
+ var Message_default = "default" in defaultImport24 ? defaultImport24.default : defaultImport24;
778
+
779
+ // esm-externals:@splunk/visualizations-shared/style
780
+ var style_exports = {};
781
+ __export(style_exports, {
782
+ default: () => style_default
783
+ });
784
+ var defaultImport25 = __toESM(require("@splunk/visualizations-shared/style"));
785
+ __reExport(style_exports, require("@splunk/visualizations-shared/style"));
786
+ var style_default = "default" in defaultImport25 ? defaultImport25.default : defaultImport25;
787
+
788
+ // esm-externals:@splunk/visualizations-shared/SizeAwareWrapper
789
+ var SizeAwareWrapper_exports = {};
790
+ __export(SizeAwareWrapper_exports, {
791
+ default: () => SizeAwareWrapper_default
792
+ });
793
+ var defaultImport26 = __toESM(require("@splunk/visualizations-shared/SizeAwareWrapper"));
794
+ __reExport(SizeAwareWrapper_exports, require("@splunk/visualizations-shared/SizeAwareWrapper"));
795
+ var SizeAwareWrapper_default = "default" in defaultImport26 ? defaultImport26.default : defaultImport26;
796
+
797
+ // src/common/hocs/FixedSizeContainer.tsx
798
+ var Item = styled_components_default.div.attrs(({ width }) => ({
799
+ style: {
800
+ width: (0, style_exports.toPx)(width)
801
+ }
802
+ }))`
803
+ position: relative;
804
+ background-color: ${(props) => (0, colorUtils_exports.isColor)(props.backgroundColor) && props.backgroundColor || props.theme.defaultBackgroundColor}};
805
+ `;
806
+ var FixSizeItem = styled_components_default.div.attrs(({ width, height }) => ({
807
+ style: __spreadValues(__spreadValues({}, width && { width: (0, style_exports.toPx)(width) }), height && { height: (0, style_exports.toPx)(height) })
808
+ }))`
809
+ position: relative;
810
+ flex-direction: column;
811
+ flex: 1;
812
+ display: flex;
813
+ background-color: ${(props) => (0, colorUtils_exports.isColor)(props.backgroundColor) && props.backgroundColor || props.theme.defaultBackgroundColor}};
814
+ `;
815
+ var ItemContent = styled_components_default.div`
816
+ position: relative;
817
+ min-height: 100px;
818
+ width: 100%;
819
+ `;
820
+ var FixSizeItemContent = styled_components_default.div`
821
+ min-height: 0px;
822
+ flex: 1;
823
+ position: relative;
824
+ box-sizing: border-box;
825
+ `;
826
+ var withFixedSizeContainer = (Viz) => {
827
+ const FixedSizeContainer = (props) => {
828
+ const { width, height, backgroundColor } = props;
829
+ const cachedHandleResize = react_exports.useCallback((w, h) => {
830
+ setContainerWidth(w);
831
+ setContainerHeight(h);
832
+ }, []);
833
+ const [containerWidth, setContainerWidth] = react_exports.useState(Number(props.width));
834
+ const [containerHeight, setContainerHeight] = react_exports.useState(Number(props.height));
835
+ if (!height) {
836
+ return /* @__PURE__ */ react_exports.createElement(Item, { "data-test": "item", width, backgroundColor }, /* @__PURE__ */ react_exports.createElement(ItemContent, null, /* @__PURE__ */ react_exports.createElement(Viz, __spreadValues({}, props))));
837
+ }
838
+ return /* @__PURE__ */ react_exports.createElement(
839
+ FixSizeItem,
840
+ {
841
+ "data-test": "fix-size-item",
842
+ "data-splunk-visualization-version": "27.2.0 - 2e7eda8d4",
843
+ width,
844
+ height,
845
+ backgroundColor
846
+ },
847
+ /* @__PURE__ */ react_exports.createElement(FixSizeItemContent, null, /* @__PURE__ */ react_exports.createElement(SizeAwareWrapper_default, { width, height, onResize: cachedHandleResize }), /* @__PURE__ */ react_exports.createElement(Viz, __spreadProps(__spreadValues({}, props), { width: containerWidth, height: containerHeight })))
848
+ );
849
+ };
850
+ FixedSizeContainer.displayName = "withFixedSizeContainer";
851
+ return FixedSizeContainer;
852
+ };
853
+ var FixedSizeContainer_default = withFixedSizeContainer;
854
+
855
+ // src/common/components/MissingPropsMessage.tsx
856
+ var isMissing = (v) => {
857
+ return v === null || v === void 0;
858
+ };
859
+ var missingKeys = (keys, target) => keys.filter((k) => isMissing(target[k]));
860
+ var propTypes = {
861
+ width: prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number]),
862
+ height: prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number]),
863
+ // eslint-disable-next-line react/no-unused-prop-types
864
+ backgroundColor: prop_types_exports.string,
865
+ missingProps: prop_types_exports.arrayOf(prop_types_exports.string)
866
+ };
867
+ var MissingPropsMessage = (props) => {
868
+ const { width, height, missingProps } = props;
869
+ return /* @__PURE__ */ react_exports.createElement(
870
+ Message_default,
871
+ {
872
+ "data-test": "message",
873
+ width,
874
+ height,
875
+ message: (0, i18n_exports._)(`Missing property: ${missingProps.join(", ")}`)
876
+ }
877
+ );
878
+ };
879
+ MissingPropsMessage.propTypes = propTypes;
880
+ MissingPropsMessage.defaultProps = {
881
+ width: "100%",
882
+ height: 250
883
+ };
884
+ var MissingPropsMessage_default = FixedSizeContainer_default(MissingPropsMessage);
885
+
886
+ // src/common/utils/hocUtils.ts
887
+ var extendStaticWrapperProps = ({
888
+ Wrapper,
889
+ Visualization
890
+ }) => {
891
+ const extendProperties = ["propTypes", "defaultProps", "config"];
892
+ extendProperties.forEach((prop) => {
893
+ if (Visualization[prop]) {
894
+ Wrapper[prop] = Visualization[prop];
895
+ }
896
+ });
897
+ };
898
+
899
+ // src/common/hocs/withEditModeCover.tsx
900
+ var Cover = styled_components_default.div`
901
+ position: absolute;
902
+ left: 0;
903
+ right: 0;
904
+ top: 0;
905
+ bottom: 0;
906
+ `;
907
+ var Blocker = styled_components_default.div.attrs({
908
+ "data-splunk-visualization-version": "27.2.0 - 2e7eda8d4"
909
+ })`
910
+ position: relative;
911
+ width: 100%;
912
+ height: 100%;
913
+ `;
914
+ var withEditModeCover = (Visualization, disableEditModeCover) => {
915
+ const Wrapper = (props) => {
916
+ const { mode } = props;
917
+ const showEditCover = mode === "edit" && !disableEditModeCover;
918
+ return /* @__PURE__ */ react_exports.createElement(Blocker, null, /* @__PURE__ */ react_exports.createElement(Visualization, __spreadValues({}, props)), showEditCover && /* @__PURE__ */ react_exports.createElement(Cover, { "data-test": "edit-mode-cover" }));
919
+ };
920
+ extendStaticWrapperProps({ Wrapper, Visualization });
921
+ return Wrapper;
922
+ };
923
+ var withEditModeCover_default = withEditModeCover;
924
+
925
+ // src/common/components/IconPlaceholder.tsx
926
+ var shouldShowIconPlaceholder = (dataSources, loading = false) => {
927
+ const data = (0, lodash_exports.get)(dataSources, "primary.data.columns[0]", void 0);
928
+ const noData = data === void 0;
929
+ const fields = (0, lodash_exports.get)(dataSources, "primary.data.fields[0]", void 0);
930
+ const noFields = fields === void 0;
931
+ return loading || noData || noFields;
932
+ };
933
+ var propTypes2 = {
934
+ icon: prop_types_exports.func,
935
+ width: prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number]),
936
+ height: prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number]),
937
+ // eslint-disable-next-line react/no-unused-prop-types
938
+ backgroundColor: prop_types_exports.string,
939
+ iconColor: prop_types_exports.string
940
+ };
941
+ var IconPlaceholder = (props) => {
942
+ const { width, height, icon, iconColor } = props;
943
+ if (icon) {
944
+ return react_exports.createElement(icon, {
945
+ style: {
946
+ left: "50%",
947
+ top: "50%",
948
+ color: iconColor,
949
+ opacity: 0.15,
950
+ position: "absolute",
951
+ transform: "translate(-50%, -50%)"
952
+ },
953
+ width: "50%",
954
+ height: "50%",
955
+ "data-test": "icon-placeholder"
956
+ });
957
+ }
958
+ return /* @__PURE__ */ react_exports.createElement(Message_default, { width, height, level: "warning", message: (0, i18n_exports._)("No DataSource Connected") });
959
+ };
960
+ IconPlaceholder.propTypes = propTypes2;
961
+ IconPlaceholder.defaultProps = {
962
+ width: "100%",
963
+ height: 250
964
+ };
965
+ var IconPlaceholder_default = FixedSizeContainer_default(IconPlaceholder);
966
+
967
+ // src/common/hocs/withPlaceholder.tsx
968
+ var withPlaceholder = (Visualization, useIconPlaceholder = shouldShowIconPlaceholder) => {
969
+ const { config: config3 } = Visualization;
970
+ const { themes: themes3 } = config3;
971
+ const Wrapper = (props) => {
972
+ var _a, _b;
973
+ const { dataSources, loading, options, height, width } = props;
974
+ const showPlaceholder = useIconPlaceholder(dataSources, loading, options);
975
+ const bgColorFromTheme = (0, colorUtils_exports.isColor)(options == null ? void 0 : options.backgroundColor) ? options == null ? void 0 : options.backgroundColor : (_a = themes3 == null ? void 0 : themes3.defaultBackgroundColor) == null ? void 0 : _a.call(themes3, props);
976
+ const icon = (_b = config3.placeholderIcon) != null ? _b : config3.icon;
977
+ const iconColor = variables_default.contentColorActive(props);
978
+ if (config3.supports.includes("placeholder" /* PLACEHOLDER */) && showPlaceholder) {
979
+ return /* @__PURE__ */ react_exports.createElement(
980
+ IconPlaceholder_default,
981
+ {
982
+ "data-test": "icon-placeholder",
983
+ icon,
984
+ width,
985
+ height,
986
+ backgroundColor: bgColorFromTheme,
987
+ iconColor
988
+ }
989
+ );
990
+ }
991
+ return /* @__PURE__ */ react_exports.createElement(Visualization, __spreadValues({}, props));
992
+ };
993
+ extendStaticWrapperProps({ Wrapper, Visualization });
994
+ return Wrapper;
995
+ };
996
+ var withPlaceholder_default = withPlaceholder;
997
+
998
+ // esm-externals:@splunk/visualizations-shared/numberUtils
999
+ var numberUtils_exports = {};
1000
+ __export(numberUtils_exports, {
1001
+ default: () => numberUtils_default
1002
+ });
1003
+ var defaultImport27 = __toESM(require("@splunk/visualizations-shared/numberUtils"));
1004
+ __reExport(numberUtils_exports, require("@splunk/visualizations-shared/numberUtils"));
1005
+ var numberUtils_default = "default" in defaultImport27 ? defaultImport27.default : defaultImport27;
1006
+
1007
+ // src/common/utils/dataUtils.ts
1008
+ var largestTriangleThreeBuckets = (data, threshold, preferredDownsampleIndices) => {
1009
+ const dataLength = data.length;
1010
+ const downsampledIndices = [];
1011
+ if (threshold >= dataLength || threshold === 0) {
1012
+ const allIndices = data.map((values, index) => index);
1013
+ return { downsampledData: data, downsampledIndices: allIndices };
1014
+ }
1015
+ const sampled = [];
1016
+ let sampledIndex = 0;
1017
+ const every = (dataLength - 2) / (threshold - 2);
1018
+ let a = 0;
1019
+ let maxAreaPoint;
1020
+ let maxArea;
1021
+ let area;
1022
+ let nextA;
1023
+ sampled.push(data[a]);
1024
+ downsampledIndices.push(0);
1025
+ for (let i = 0; i < threshold - 2; i++) {
1026
+ let avgX = 0;
1027
+ let avgY = 0;
1028
+ let avgRangeStart = Math.floor((i + 1) * every) + 1;
1029
+ let avgRangeEnd = Math.floor((i + 2) * every) + 1;
1030
+ avgRangeEnd = avgRangeEnd < dataLength ? avgRangeEnd : dataLength;
1031
+ const avgRangeLength = avgRangeEnd - avgRangeStart;
1032
+ for (; avgRangeStart < avgRangeEnd; avgRangeStart++) {
1033
+ avgX += Number(data[avgRangeStart][0]);
1034
+ avgY += data[avgRangeStart][1] * 1;
1035
+ }
1036
+ avgX /= avgRangeLength;
1037
+ avgY /= avgRangeLength;
1038
+ let rangeOffs = Math.floor((i + 0) * every) + 1;
1039
+ const rangeTo = Math.floor((i + 1) * every) + 1;
1040
+ const pointAX = Number(data[a][0]);
1041
+ const pointAY = data[a][1] * 1;
1042
+ maxArea = area = -1;
1043
+ let maxAreaIndex = rangeOffs;
1044
+ for (; rangeOffs < rangeTo; rangeOffs++) {
1045
+ area = Math.abs(
1046
+ (pointAX - avgX) * (data[rangeOffs][1] - pointAY) - (pointAX - Number(data[rangeOffs][0])) * (avgY - pointAY)
1047
+ ) * 0.5;
1048
+ if (area > maxArea || area === maxArea && preferredDownsampleIndices.has(rangeOffs)) {
1049
+ maxArea = area;
1050
+ maxAreaPoint = data[rangeOffs];
1051
+ nextA = rangeOffs;
1052
+ maxAreaIndex = rangeOffs;
1053
+ }
1054
+ }
1055
+ sampled[sampledIndex++] = maxAreaPoint;
1056
+ downsampledIndices.push(maxAreaIndex);
1057
+ a = nextA;
1058
+ }
1059
+ sampled[sampledIndex++] = data[dataLength - 1];
1060
+ downsampledIndices.push(dataLength - 1);
1061
+ return { downsampledData: sampled, downsampledIndices };
1062
+ };
1063
+ var strictlyCoerceYColumn = (column, options) => {
1064
+ const isNullCoercionEnabled = options.nullValueDisplay === "zero";
1065
+ const canLooselyCoerceSomeValues = column.findIndex(
1066
+ (value) => (0, numberUtils_exports.startsWithNumber)(`${value}`) || isNullCoercionEnabled && value === null
1067
+ ) >= 0;
1068
+ const coercedColumn = [];
1069
+ const canDownsampleColumn = !column.some((value) => {
1070
+ const coercedValue = Number(value);
1071
+ const coerceValueToZero = isNullCoercionEnabled && value === null;
1072
+ if (Number.isNaN(coercedValue) || coercedValue <= Number.MIN_SAFE_INTEGER || coercedValue >= Number.MAX_SAFE_INTEGER || typeof value !== "string" && typeof value !== "number" && !coerceValueToZero) {
1073
+ return true;
1074
+ }
1075
+ coercedColumn.push(coercedValue);
1076
+ return false;
1077
+ });
1078
+ return {
1079
+ canDownsampleColumn,
1080
+ canLooselyCoerceSomeValues,
1081
+ coercedColumn: canDownsampleColumn ? coercedColumn : []
1082
+ };
1083
+ };
1084
+ var strictlyCoerceXColumn = (column, fieldType) => {
1085
+ if (fieldType === "number") {
1086
+ const coercedXColumn = column.map((xValue) => Number(xValue));
1087
+ if (isColumnStrictlyIncreasing(coercedXColumn, fieldType)) {
1088
+ return coercedXColumn;
1089
+ }
1090
+ } else if (fieldType === "time") {
1091
+ const coercedXColumn = column.map((xValue) => new Date(xValue));
1092
+ if (isColumnStrictlyIncreasing(coercedXColumn, fieldType)) {
1093
+ return coercedXColumn;
1094
+ }
1095
+ }
1096
+ return [];
1097
+ };
1098
+ var isDownsamplingEnabledForViz = ({ vizConfig }) => {
1099
+ var _a;
1100
+ return (_a = vizConfig.supports) == null ? void 0 : _a.includes("downsampling" /* DOWNSAMPLING */);
1101
+ };
1102
+ var isColumnStrictlyIncreasing = (column, fieldType) => {
1103
+ return column.every((value, index) => {
1104
+ if (fieldType === "number") {
1105
+ if (Number.isNaN(value)) {
1106
+ return false;
1107
+ }
1108
+ }
1109
+ if (fieldType === "time") {
1110
+ if (Number.isNaN(value.getTime())) {
1111
+ return false;
1112
+ }
1113
+ }
1114
+ if (index === 0) {
1115
+ return true;
1116
+ }
1117
+ return value > column[index - 1];
1118
+ });
1119
+ };
1120
+ var tryToCoerceAllDisplayedFields = (ds, xField, yFields, fieldTypes, options) => {
1121
+ let xColumn = [];
1122
+ const yColumns = [];
1123
+ const canDownsample = !ds.data.fields.some((field, index) => {
1124
+ var _a, _b;
1125
+ const fieldName = (_a = field.name) != null ? _a : field;
1126
+ const fieldType = (_b = fieldTypes[index]) != null ? _b : "unknown";
1127
+ const column = ds.data.columns[index];
1128
+ let hasDisplayedColumnThatCantBeDownsampled = false;
1129
+ if (fieldName === xField) {
1130
+ xColumn = strictlyCoerceXColumn(column, fieldType);
1131
+ } else if (yFields.has(fieldName)) {
1132
+ const { coercedColumn, canLooselyCoerceSomeValues, canDownsampleColumn } = strictlyCoerceYColumn(
1133
+ ds.data.columns[index],
1134
+ options
1135
+ );
1136
+ hasDisplayedColumnThatCantBeDownsampled = canLooselyCoerceSomeValues && !canDownsampleColumn;
1137
+ if (hasDisplayedColumnThatCantBeDownsampled) {
1138
+ return true;
1139
+ }
1140
+ if (canDownsampleColumn) {
1141
+ yColumns.push(coercedColumn);
1142
+ }
1143
+ }
1144
+ return false;
1145
+ });
1146
+ if (canDownsample) {
1147
+ return { xColumn, yColumns };
1148
+ }
1149
+ return { xColumn: [], yColumns: [] };
1150
+ };
1151
+ var pickIndicesFromDataSource = (ds, indices) => {
1152
+ const sortedIndices = Array.from(indices).sort((a, b) => a - b);
1153
+ const slicedColumns = [];
1154
+ ds.data.columns.forEach((column) => {
1155
+ const slicedColumn = [];
1156
+ sortedIndices.forEach((index) => {
1157
+ slicedColumn.push(column[index]);
1158
+ });
1159
+ slicedColumns.push(slicedColumn);
1160
+ });
1161
+ return __spreadProps(__spreadValues({}, ds), {
1162
+ data: __spreadProps(__spreadValues({}, ds.data), {
1163
+ columns: slicedColumns
1164
+ })
1165
+ });
1166
+ };
1167
+ var downsampleDataSources = ({ dataSources, threshold, options }) => {
1168
+ var _a, _b, _c;
1169
+ const primaryDS = dataSources == null ? void 0 : dataSources.primary;
1170
+ const numPoints = (_c = (_b = (_a = primaryDS == null ? void 0 : primaryDS.data) == null ? void 0 : _a.columns[0]) == null ? void 0 : _b.length) != null ? _c : 0;
1171
+ if (Number.isNaN(threshold) || numPoints <= threshold || threshold < 2) {
1172
+ return dataSources;
1173
+ }
1174
+ const { xField, yFields, fieldTypes } = options;
1175
+ if (!xField || !(yFields == null ? void 0 : yFields.length) || !(fieldTypes == null ? void 0 : fieldTypes.length)) {
1176
+ return dataSources;
1177
+ }
1178
+ const nonInternalYFields = new Set(yFields.filter((yField) => !yField.startsWith("_")));
1179
+ const maxPointsInDownsample = Math.min(nonInternalYFields.size * threshold, numPoints);
1180
+ if (maxPointsInDownsample >= numPoints) {
1181
+ return dataSources;
1182
+ }
1183
+ const { xColumn, yColumns } = tryToCoerceAllDisplayedFields(
1184
+ primaryDS,
1185
+ xField,
1186
+ nonInternalYFields,
1187
+ fieldTypes,
1188
+ options
1189
+ );
1190
+ if (!yColumns.length || !xColumn.length) {
1191
+ return dataSources;
1192
+ }
1193
+ const downsampledDataSources = __spreadValues({}, dataSources);
1194
+ const downsampledIndices = /* @__PURE__ */ new Set();
1195
+ yColumns.forEach((yColumn, columnIndex) => {
1196
+ const xyPair = yColumn.map((yValue, index) => {
1197
+ return [xColumn[index], yValue];
1198
+ });
1199
+ try {
1200
+ const { downsampledIndices: downsampledIndicesForSeries } = largestTriangleThreeBuckets(
1201
+ xyPair,
1202
+ threshold,
1203
+ downsampledIndices
1204
+ );
1205
+ downsampledIndicesForSeries.forEach((downsampleIndex) => downsampledIndices.add(downsampleIndex));
1206
+ } catch (e) {
1207
+ console.error(`Error occurred while downsampling column ${columnIndex}`, e);
1208
+ }
1209
+ });
1210
+ downsampledDataSources.primary = pickIndicesFromDataSource(primaryDS, downsampledIndices);
1211
+ return downsampledDataSources;
1212
+ };
1213
+
1214
+ // src/common/hooks/usePrevious.ts
1215
+ function usePrevious(value) {
1216
+ const ref = (0, react_exports.useRef)();
1217
+ (0, react_exports.useEffect)(() => {
1218
+ ref.current = value;
1219
+ });
1220
+ return ref.current;
1221
+ }
1222
+
1223
+ // src/common/hooks/useGetXAndYFields.tsx
1224
+ var useGetXAndYFields = ({
1225
+ shouldEvaluateDSL,
1226
+ options,
1227
+ context,
1228
+ dataSources
1229
+ }) => {
1230
+ const { dataSourcesWithOnlyOnePoint, dataFrameWithOnlyOnePoint } = (0, react_exports.useMemo)(() => {
1231
+ var _a, _b, _c;
1232
+ if (!shouldEvaluateDSL) {
1233
+ return {
1234
+ dataSourcesWithOnlyOnePoint: null,
1235
+ dataFrameWithOnlyOnePoint: null
1236
+ };
1237
+ }
1238
+ if (!((_c = (_b = (_a = dataSources == null ? void 0 : dataSources.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.columns) == null ? void 0 : _c.length)) {
1239
+ return {
1240
+ dataSourcesWithOnlyOnePoint: null,
1241
+ dataFrameWithOnlyOnePoint: null
1242
+ };
1243
+ }
1244
+ const { primary: primaryDS } = dataSources;
1245
+ const columnsWithOnlyOnePoint = primaryDS.data.columns.map((column) => {
1246
+ return [column[0]];
1247
+ });
1248
+ const filteredDataSources = {
1249
+ primary: __spreadProps(__spreadValues({}, primaryDS), {
1250
+ data: __spreadProps(__spreadValues({}, primaryDS.data), {
1251
+ columns: columnsWithOnlyOnePoint
1252
+ })
1253
+ })
1254
+ };
1255
+ return {
1256
+ dataSourcesWithOnlyOnePoint: filteredDataSources,
1257
+ dataFrameWithOnlyOnePoint: Options_exports.Options.dataFrameFromDataSource(filteredDataSources)
1258
+ };
1259
+ }, [dataSources, shouldEvaluateDSL]);
1260
+ const xAndYFieldsWithTypes = (0, react_exports.useMemo)(() => {
1261
+ try {
1262
+ if (!dataSourcesWithOnlyOnePoint || !dataFrameWithOnlyOnePoint) {
1263
+ return options;
1264
+ }
1265
+ if (!(options == null ? void 0 : options.x) || !(options == null ? void 0 : options.y) && !(options == null ? void 0 : options.y2)) {
1266
+ return options;
1267
+ }
1268
+ const optionsToEvaluate = {
1269
+ x: options.x,
1270
+ xField: "> x | getField()",
1271
+ y: options.y,
1272
+ yFields: options.y ? "> y | getField()" : void 0,
1273
+ y2: options.y2,
1274
+ y2Fields: options.y2 ? "> y2 | getField()" : void 0,
1275
+ fieldTypes: "> primary | getType()"
1276
+ };
1277
+ const { xField = "", yFields = [], y2Fields = [], fieldTypes } = Options_exports.Options.evaluate(
1278
+ { options: optionsToEvaluate, context },
1279
+ dataSourcesWithOnlyOnePoint,
1280
+ () => {
1281
+ },
1282
+ dataFrameWithOnlyOnePoint
1283
+ );
1284
+ return {
1285
+ xField,
1286
+ yFields: [...yFields, ...y2Fields],
1287
+ fieldTypes
1288
+ };
1289
+ } catch (e) {
1290
+ return {
1291
+ xField: void 0,
1292
+ yFields: [],
1293
+ fieldTypes: []
1294
+ };
1295
+ }
1296
+ }, [options, context, dataSourcesWithOnlyOnePoint, dataFrameWithOnlyOnePoint]);
1297
+ return xAndYFieldsWithTypes;
1298
+ };
1299
+ var useGetXAndYFields_default = useGetXAndYFields;
1300
+
1301
+ // src/common/hooks/useDownsampleDataSources.tsx
1302
+ var downsampleVizOptionProperties = ["nullValueDisplay"];
1303
+ var useDownsampleDataSources = ({
1304
+ dataSources,
1305
+ options,
1306
+ context,
1307
+ threshold,
1308
+ isDownsamplingEnabled
1309
+ }) => {
1310
+ const isFirstUseEffectCall = (0, react_exports.useRef)(true);
1311
+ const xAndYFieldsWithTypes = useGetXAndYFields_default({
1312
+ shouldEvaluateDSL: isDownsamplingEnabled,
1313
+ options,
1314
+ context,
1315
+ dataSources
1316
+ });
1317
+ const downsampleVizOptions = (0, react_exports.useMemo)(() => (0, lodash_exports.pick)(options, downsampleVizOptionProperties), [options]);
1318
+ const downsampleDSOptions = (0, react_exports.useMemo)(
1319
+ () => __spreadValues(__spreadValues({}, downsampleVizOptions), xAndYFieldsWithTypes),
1320
+ [xAndYFieldsWithTypes, downsampleVizOptions]
1321
+ );
1322
+ const previousDownsampleDSOptions = usePrevious(downsampleDSOptions);
1323
+ const previousDataSources = usePrevious(dataSources);
1324
+ const previousThreshold = usePrevious(threshold);
1325
+ const [downsampledDataSources, setDownsampledDataSources] = (0, react_exports.useState)(() => {
1326
+ return isDownsamplingEnabled ? downsampleDataSources({
1327
+ dataSources,
1328
+ threshold,
1329
+ options: downsampleDSOptions
1330
+ }) : dataSources;
1331
+ });
1332
+ const debouncedDownsampleDataSources = (0, react_exports.useMemo)(() => {
1333
+ return (0, lodash_exports.debounce)(
1334
+ (downsampleOptions) => {
1335
+ const downsampledResult = downsampleDataSources(downsampleOptions);
1336
+ setDownsampledDataSources(downsampledResult);
1337
+ },
1338
+ 100,
1339
+ { trailing: true }
1340
+ );
1341
+ }, []);
1342
+ (0, react_exports.useEffect)(() => {
1343
+ if (isFirstUseEffectCall.current) {
1344
+ isFirstUseEffectCall.current = false;
1345
+ return;
1346
+ }
1347
+ if (!isDownsamplingEnabled) {
1348
+ setDownsampledDataSources(dataSources);
1349
+ return;
1350
+ }
1351
+ if ((0, lodash_exports.isEqual)(previousDownsampleDSOptions, downsampleDSOptions) && previousDataSources === dataSources && previousThreshold === threshold) {
1352
+ return;
1353
+ }
1354
+ debouncedDownsampleDataSources({
1355
+ dataSources,
1356
+ options: downsampleDSOptions,
1357
+ // Dont want to re-downsample everytime the options change
1358
+ threshold
1359
+ });
1360
+ }, [
1361
+ dataSources,
1362
+ downsampleDSOptions,
1363
+ debouncedDownsampleDataSources,
1364
+ xAndYFieldsWithTypes,
1365
+ threshold,
1366
+ isDownsamplingEnabled,
1367
+ previousDataSources,
1368
+ previousThreshold,
1369
+ previousDownsampleDSOptions
1370
+ ]);
1371
+ return downsampledDataSources;
1372
+ };
1373
+ var useDownsampleDataSources_default = useDownsampleDataSources;
1374
+
1375
+ // esm-externals:@splunk/visualization-context/FeatureFlags
1376
+ var FeatureFlags_exports = {};
1377
+ __export(FeatureFlags_exports, {
1378
+ default: () => FeatureFlags_default
1379
+ });
1380
+ var defaultImport28 = __toESM(require("@splunk/visualization-context/FeatureFlags"));
1381
+ __reExport(FeatureFlags_exports, require("@splunk/visualization-context/FeatureFlags"));
1382
+ var FeatureFlags_default = "default" in defaultImport28 ? defaultImport28.default : defaultImport28;
1383
+
1384
+ // src/common/utils/featureFlagUtils.ts
1385
+ var getFeatureFlag = (context, flagName) => {
1386
+ if (context && Object.keys(context).find((key) => key === flagName)) {
1387
+ return context[flagName];
1388
+ }
1389
+ if (Object.keys(FeatureFlags_default).find((key) => key === flagName)) {
1390
+ return FeatureFlags_default[flagName];
1391
+ }
1392
+ return false;
1393
+ };
1394
+
1395
+ // esm-externals:@splunk/visualizations-shared/trellisUtils
1396
+ var trellisUtils_exports = {};
1397
+ __export(trellisUtils_exports, {
1398
+ default: () => trellisUtils_default
1399
+ });
1400
+ var defaultImport29 = __toESM(require("@splunk/visualizations-shared/trellisUtils"));
1401
+ __reExport(trellisUtils_exports, require("@splunk/visualizations-shared/trellisUtils"));
1402
+ var trellisUtils_default = "default" in defaultImport29 ? defaultImport29.default : defaultImport29;
1403
+
1404
+ // src/common/utils/trellisUtils.ts
1405
+ var turnOffLegendDisplayWhenTrellisIsOn = (isTrellisOn, options) => {
1406
+ if (isTrellisOn && !options.legendDisplay) {
1407
+ return {
1408
+ legendDisplay: "off"
1409
+ };
1410
+ }
1411
+ return {};
1412
+ };
1413
+
1414
+ // src/common/withDashboardViz.tsx
1415
+ var withDashboardViz = (opts) => {
1416
+ const {
1417
+ ReactViz,
1418
+ vizConfig,
1419
+ computeVizProps: computeVizProps2 = () => {
1420
+ },
1421
+ computeVizPropsBeforeEval = () => {
1422
+ },
1423
+ disableEditModeCover,
1424
+ useIconPlaceholder
1425
+ } = opts;
1426
+ const SanitizedReactViz = (0, SanitizeProps_exports.withSanitizedProps)(ReactViz);
1427
+ const defaultOptions = (0, JSONSchemaUtils_exports.pickFieldFromJSONSchema)(vizConfig.optionsSchema, "default");
1428
+ const DashboardViz = (props) => {
1429
+ var _a;
1430
+ const {
1431
+ mode,
1432
+ hasEventHandlers,
1433
+ dataSources,
1434
+ // type of { [key: string]: DataSource }
1435
+ options,
1436
+ context = {},
1437
+ width,
1438
+ height,
1439
+ onComputedProps,
1440
+ onEventTrigger,
1441
+ theme,
1442
+ onRequestParamsChange
1443
+ } = props;
1444
+ const { serializedTimezone } = react_exports.useContext(TimezoneContext_default);
1445
+ if (serializedTimezone) {
1446
+ if (!moment_default.getDefaultSplunkTimezone()) {
1447
+ moment_default.setDefaultSplunkTimezone(serializedTimezone);
1448
+ }
1449
+ }
1450
+ const themeFunc = (themeVar) => {
1451
+ var _a2, _b;
1452
+ return (_b = (_a2 = vizConfig.themes)[themeVar]) == null ? void 0 : _b.call(_a2, props);
1453
+ };
1454
+ const bgColorFromTheme = themeFunc("defaultBackgroundColor");
1455
+ const {
1456
+ family: currentThemeFamily,
1457
+ colorScheme: currentThemeColorScheme,
1458
+ density: currentThemeDensity
1459
+ } = getSettingsFromThemedProps_default({ theme });
1460
+ let evaluatedOptions = {};
1461
+ const [evaluatedOptionsAsync, setEvaluatedOptionsAsync] = react_exports.useState({});
1462
+ const featureFlagContext = react_exports.useContext(FeatureFlagContext_default);
1463
+ const [visualizationID] = react_exports.useState(`${vizConfig.name} - ${(0, id_exports.createGUID)()}`);
1464
+ const [dataSourcesInState, setDataSourcesInState] = react_exports.useState({});
1465
+ const [dataFramesInState, setDataFramesInState] = react_exports.useState();
1466
+ const [useAsyncEvaluatedOptions, setUseAsyncEvaluatedOptions] = react_exports.useState(
1467
+ Boolean(getFeatureFlag(featureFlagContext, "visualizations_useWebWorkersForDSL"))
1468
+ );
1469
+ const isDownsamplingEnabledByFeatureFlag = Boolean(
1470
+ featureFlagContext == null ? void 0 : featureFlagContext.visualizations_enableDownsampling
1471
+ );
1472
+ const isTrellisFeatureFlagOn = Boolean(
1473
+ featureFlagContext && featureFlagContext.visualizations_enableTrellis
1474
+ );
1475
+ const isTrellisOn = isTrellisFeatureFlagOn && ((_a = vizConfig == null ? void 0 : vizConfig.supports) == null ? void 0 : _a.includes("trellis" /* TRELLIS */)) && (options == null ? void 0 : options.splitByLayout) === "trellis" /* TRELLIS */;
1476
+ const isMounted = react_exports.useRef(true);
1477
+ const optionsToEvaluate = react_exports.useMemo(() => {
1478
+ var _a2;
1479
+ const legendDisplay = turnOffLegendDisplayWhenTrellisIsOn(isTrellisOn, options);
1480
+ const computedOptions = (_a2 = computeVizPropsBeforeEval(options)) != null ? _a2 : {};
1481
+ return {
1482
+ context: (0, lodash_exports.defaultsDeep)({}, context, vizConfig.defaultContext),
1483
+ options: (0, hocUtils_exports.deepMergeWithArrayPrimitiveOverrides)(
1484
+ {},
1485
+ legendDisplay,
1486
+ computedOptions,
1487
+ options,
1488
+ defaultOptions
1489
+ )
1490
+ };
1491
+ }, [isTrellisOn, options, context]);
1492
+ const [threshold, setThreshold] = react_exports.useState(Number(width));
1493
+ const onDownsamplingThresholdChange = react_exports.useCallback((newThreshold) => {
1494
+ setThreshold(newThreshold);
1495
+ }, []);
1496
+ const isDownsamplingEnabled = react_exports.useMemo(() => {
1497
+ return isDownsamplingEnabledByFeatureFlag && isDownsamplingEnabledForViz({ vizConfig });
1498
+ }, [isDownsamplingEnabledByFeatureFlag]);
1499
+ const downsamplingProps = react_exports.useMemo(() => {
1500
+ if (!isDownsamplingEnabled) {
1501
+ return {};
1502
+ }
1503
+ return {
1504
+ onDownsamplingThresholdChange,
1505
+ originalDataSources: dataSources
1506
+ };
1507
+ }, [dataSources, isDownsamplingEnabled, onDownsamplingThresholdChange]);
1508
+ const downsampledDataSources = useDownsampleDataSources_default({
1509
+ options: optionsToEvaluate.options,
1510
+ context: optionsToEvaluate.context,
1511
+ dataSources,
1512
+ threshold,
1513
+ isDownsamplingEnabled
1514
+ });
1515
+ evaluatedOptions = useDeepMemo(() => {
1516
+ try {
1517
+ if (useAsyncEvaluatedOptions) {
1518
+ const asyncDynamicOptionsEvaluatorParams = {
1519
+ visualizationID,
1520
+ props,
1521
+ options: optionsToEvaluate,
1522
+ dataSources: downsampledDataSources,
1523
+ theme: vizConfig.themes,
1524
+ bypassCloneDeepOptionScope: Boolean(
1525
+ getFeatureFlag(featureFlagContext, "visualizations_bypassCloneDeepOptionScope")
1526
+ ),
1527
+ lazyLoadingDataFrame: Boolean(
1528
+ getFeatureFlag(featureFlagContext, "visualizations_lazyLoadingDataFrame")
1529
+ )
1530
+ };
1531
+ async_dynamic_options_evaluator_default.evaluate(asyncDynamicOptionsEvaluatorParams).then((results) => {
1532
+ setEvaluatedOptionsAsync(results.results);
1533
+ }).catch(() => {
1534
+ if (isMounted.current) {
1535
+ setUseAsyncEvaluatedOptions(false);
1536
+ }
1537
+ });
1538
+ } else {
1539
+ let dataFrames = dataFramesInState;
1540
+ if (downsampledDataSources !== dataSourcesInState) {
1541
+ setDataSourcesInState(downsampledDataSources);
1542
+ dataFrames = Options_exports.Options.dataFrameFromDataSource(
1543
+ downsampledDataSources,
1544
+ getFeatureFlag(featureFlagContext, "visualizations_lazyLoadingDataFrame")
1545
+ );
1546
+ setDataFramesInState(dataFrames);
1547
+ }
1548
+ const result = Options_exports.Options.evaluate(
1549
+ optionsToEvaluate,
1550
+ downsampledDataSources,
1551
+ themeFunc,
1552
+ dataFrames,
1553
+ getFeatureFlag(featureFlagContext, "visualizations_bypassCloneDeepOptionScope")
1554
+ );
1555
+ return result;
1556
+ }
1557
+ } catch (e) {
1558
+ console.error(`unexpected error evaluating options: ${e.message}`);
1559
+ return {};
1560
+ }
1561
+ return {};
1562
+ }, [
1563
+ currentThemeFamily,
1564
+ currentThemeColorScheme,
1565
+ currentThemeDensity,
1566
+ optionsToEvaluate,
1567
+ downsampledDataSources,
1568
+ serializedTimezone,
1569
+ useAsyncEvaluatedOptions
1570
+ ]);
1571
+ const evaluatedOptionsToUse = !useAsyncEvaluatedOptions ? evaluatedOptions : evaluatedOptionsAsync;
1572
+ let clonedEvaluatedOptions = evaluatedOptionsToUse;
1573
+ if (isTrellisOn) {
1574
+ clonedEvaluatedOptions = __spreadProps(__spreadValues({}, evaluatedOptionsToUse), {
1575
+ backgroundColor: clonedEvaluatedOptions == null ? void 0 : clonedEvaluatedOptions.trellisBackgroundColor
1576
+ });
1577
+ }
1578
+ react_exports.useEffect(() => {
1579
+ onComputedProps(clonedEvaluatedOptions);
1580
+ });
1581
+ react_exports.useEffect(() => {
1582
+ return () => {
1583
+ if (useAsyncEvaluatedOptions) {
1584
+ isMounted.current = false;
1585
+ async_dynamic_options_evaluator_default.reset(visualizationID);
1586
+ }
1587
+ };
1588
+ }, []);
1589
+ const { requiredProps = [], supports } = vizConfig;
1590
+ const missing = missingKeys(requiredProps, evaluatedOptionsToUse);
1591
+ if (missing.length > 0 && supports.includes("placeholder" /* PLACEHOLDER */) && vizConfig.key !== "splunk.singlevalue") {
1592
+ return /* @__PURE__ */ react_exports.createElement(
1593
+ MissingPropsMessage_default,
1594
+ {
1595
+ "data-test": "missing-props-message",
1596
+ width,
1597
+ height,
1598
+ missingProps: missing,
1599
+ backgroundColor: bgColorFromTheme
1600
+ }
1601
+ );
1602
+ }
1603
+ const eventCallbackProps = {};
1604
+ if (hasEventHandlers && mode === "view" && vizConfig.supports.indexOf("events" /* EVENTS */) > -1) {
1605
+ const supportedEvents = vizConfig.events;
1606
+ Object.keys(supportedEvents).forEach((eventName) => {
1607
+ const { parentKeys, payloadKeys } = supportedEvents[eventName];
1608
+ const eventCallbackPropName = (0, lodash_exports.camelCase)(`on.${eventName}`);
1609
+ let payload = {};
1610
+ if (Array.isArray(payloadKeys) && payloadKeys.length) {
1611
+ payloadKeys.forEach((p) => {
1612
+ payload[p] = evaluatedOptionsToUse[p];
1613
+ });
1614
+ }
1615
+ eventCallbackProps[eventCallbackPropName] = (ev) => {
1616
+ if (ev && ev.payload) {
1617
+ payload = ev.payload;
1618
+ }
1619
+ return onEventTrigger({ originalEvent: ev, payload, type: eventName });
1620
+ };
1621
+ if (parentKeys) {
1622
+ for (let i = parentKeys.length - 1; i >= 0; i -= 1) {
1623
+ const newObject = {};
1624
+ newObject[parentKeys[i]] = eventCallbackProps[eventCallbackPropName];
1625
+ eventCallbackProps[eventCallbackPropName] = newObject;
1626
+ }
1627
+ }
1628
+ });
1629
+ }
1630
+ const computedVizProps = computeVizProps2(__spreadProps(__spreadValues(__spreadValues(__spreadValues({}, props), evaluatedOptionsToUse), eventCallbackProps), {
1631
+ themeFunc
1632
+ }));
1633
+ let dataSourceMetadata = {};
1634
+ const OptionKey = "paginateDataSourceKey";
1635
+ const paginateDataSourceKey = (0, lodash_exports.has)(evaluatedOptionsToUse, OptionKey) && evaluatedOptionsToUse[OptionKey] || "primary";
1636
+ if (vizConfig.supports.indexOf("page-and-sort" /* PAGE_AND_SORT */) > -1 && (0, lodash_exports.has)(dataSources, paginateDataSourceKey)) {
1637
+ const requestParams = (0, lodash_exports.get)(dataSources, [paginateDataSourceKey, "requestParams"], {});
1638
+ const meta = (0, lodash_exports.get)(dataSources, [paginateDataSourceKey, "meta"], {});
1639
+ const handleRequestParamsChange = (payload) => onRequestParamsChange(paginateDataSourceKey, payload);
1640
+ const sortParams = getSortingParams({
1641
+ requestParams,
1642
+ meta,
1643
+ onRequestParamsChange: handleRequestParamsChange
1644
+ });
1645
+ const paginatorParams = getPaginationParams({
1646
+ requestParams,
1647
+ meta,
1648
+ onRequestParamsChange: handleRequestParamsChange
1649
+ });
1650
+ dataSourceMetadata = {
1651
+ sortParams,
1652
+ paginatorParams
1653
+ };
1654
+ }
1655
+ if (useAsyncEvaluatedOptions && Object.keys(evaluatedOptionsToUse).length === 0) {
1656
+ return null;
1657
+ }
1658
+ return /* @__PURE__ */ react_exports.createElement(
1659
+ SanitizedReactViz,
1660
+ __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
1661
+ mode,
1662
+ width,
1663
+ height
1664
+ }, downsamplingProps), evaluatedOptionsToUse), computedVizProps), eventCallbackProps), dataSourceMetadata)
1665
+ );
1666
+ };
1667
+ DashboardViz.propTypes = __spreadValues(__spreadValues({}, SplunkVisualization_default.propTypes), ReactViz.propTypes);
1668
+ DashboardViz.defaultProps = __spreadProps(__spreadValues(__spreadValues({}, SplunkVisualization_default.defaultProps), ReactViz.defaultProps), {
1669
+ // using withTheme requires component to receive theme prop. In case the consumer did not provide ThemeProvider, a default empty object will prevent warnings.
1670
+ theme: {}
1671
+ });
1672
+ DashboardViz.config = vizConfig;
1673
+ return (0, styled_components_exports.withTheme)(
1674
+ withPlaceholder_default(withEditModeCover_default(DashboardViz, disableEditModeCover), useIconPlaceholder)
1675
+ );
1676
+ };
1677
+ var withDashboardViz_default = withDashboardViz;
1678
+
1679
+ // esm-externals:@splunk/themes
1680
+ var themes_exports = {};
1681
+ __export(themes_exports, {
1682
+ default: () => themes_default
1683
+ });
1684
+ var defaultImport30 = __toESM(require("@splunk/themes"));
1685
+ __reExport(themes_exports, require("@splunk/themes"));
1686
+ var themes_default = "default" in defaultImport30 ? defaultImport30.default : defaultImport30;
1687
+
1688
+ // src/Timeline/PureTimeline/src/utils/timelineUtils.ts
1689
+ function hexToRgba(hex, opacity = 1) {
1690
+ const hexString = typeof hex === "string" ? hex.replace("#", "") : "#009CEB";
1691
+ const r = parseInt(hexString.substring(0, 2), 16);
1692
+ const g = parseInt(hexString.substring(2, 4), 16);
1693
+ const b = parseInt(hexString.substring(4, 6), 16);
1694
+ const alpha = Math.max(0, Math.min(opacity, 1));
1695
+ return `rgba(${r}, ${g}, ${b}, ${alpha})`;
1696
+ }
1697
+ function getAlternateColor(hex, percent) {
1698
+ const cleanedHex = typeof hex === "string" ? hex.replace("#", "") : "#009CEB";
1699
+ const bigint = parseInt(cleanedHex, 16);
1700
+ const r = bigint >> 16 & 255;
1701
+ const g = bigint >> 8 & 255;
1702
+ const b = bigint & 255;
1703
+ const luminance = (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255;
1704
+ const darken = (channel, factor) => {
1705
+ return Math.floor(channel * factor);
1706
+ };
1707
+ if (luminance > 0.8) {
1708
+ const darkenFactor = 0.95;
1709
+ const rDark = darken(r, darkenFactor);
1710
+ const gDark = darken(g, darkenFactor);
1711
+ const bDark = darken(b, darkenFactor);
1712
+ return `rgba(${rDark}, ${gDark}, ${bDark}, 1)`;
1713
+ }
1714
+ const lighten = (channel) => Math.min(255, Math.floor(channel + (255 - channel) * percent));
1715
+ const rLight = lighten(r);
1716
+ const gLight = lighten(g);
1717
+ const bLight = lighten(b);
1718
+ return `rgba(${rLight}, ${gLight}, ${bLight}, 1)`;
1719
+ }
1720
+ var toTimestamp = (dateStr, timezone = {}) => {
1721
+ try {
1722
+ let dateTime;
1723
+ if ("utcOffset" in timezone) {
1724
+ dateTime = moment_default.utc(dateStr).utcOffset(timezone.utcOffset, true);
1725
+ } else if ("ianaTimezone" in timezone) {
1726
+ dateTime = moment_default.tz(dateStr, timezone.ianaTimezone);
1727
+ } else if ("serializedTimezone" in timezone) {
1728
+ const splunkSerializedTimezone = moment_default.addSplunkTimezone(timezone.serializedTimezone);
1729
+ dateTime = moment_default.tz(dateStr, splunkSerializedTimezone);
1730
+ } else {
1731
+ dateTime = moment_default(dateStr);
1732
+ }
1733
+ if (!dateTime.isValid()) {
1734
+ console.error("Invalid date:", dateStr);
1735
+ return NaN;
1736
+ }
1737
+ return dateTime.toDate().getTime();
1738
+ } catch (error) {
1739
+ console.error("Invalid date or timezone:", dateStr, timezone, error);
1740
+ return NaN;
1741
+ }
1742
+ };
1743
+ function mapDataToTimeline(resultLimit, x, y, duration, category = [], dataColors = [], seriesColors = [], additionalTooltipValues = [], _timezone = {}, defaultColor = "#009CEB") {
1744
+ var _a, _b;
1745
+ const categoricalColors = /* @__PURE__ */ new Map();
1746
+ const lanesSet = /* @__PURE__ */ new Set();
1747
+ const laneSeriesMap = /* @__PURE__ */ new Map();
1748
+ const timeDifferences = [];
1749
+ for (let i = 0; i < Math.min(x.length, resultLimit); i += 1) {
1750
+ const lane = y[i];
1751
+ lanesSet.add(lane);
1752
+ let color = defaultColor;
1753
+ const categoryValue = ((_a = category[i]) == null ? void 0 : _a.toString()) || null;
1754
+ if (categoryValue && !categoricalColors.has(categoryValue)) {
1755
+ const colorIndex = categoricalColors.size;
1756
+ const assignedColor = seriesColors[colorIndex % seriesColors.length] || defaultColor;
1757
+ categoricalColors.set(categoryValue, assignedColor);
1758
+ }
1759
+ if (dataColors && (dataColors == null ? void 0 : dataColors.length) > 0) {
1760
+ const assignedDataColor = dataColors[i];
1761
+ color = assignedDataColor || defaultColor;
1762
+ } else if (categoryValue) {
1763
+ color = categoricalColors.get(categoryValue);
1764
+ }
1765
+ const start = toTimestamp(x[i].toString(), _timezone);
1766
+ const durationValue = duration[i] || 0;
1767
+ const end = start + durationValue;
1768
+ const additionalTooltipValue = additionalTooltipValues ? additionalTooltipValues[i] : null;
1769
+ if (!laneSeriesMap.has(lane)) {
1770
+ laneSeriesMap.set(lane, []);
1771
+ }
1772
+ (_b = laneSeriesMap.get(lane)) == null ? void 0 : _b.push({
1773
+ start,
1774
+ end,
1775
+ _time: x[i].toString(),
1776
+ duration: durationValue,
1777
+ category: categoryValue,
1778
+ color,
1779
+ additionalTooltipValue
1780
+ });
1781
+ if (i > 0) {
1782
+ const prevStart = toTimestamp(x[i - 1].toString(), _timezone);
1783
+ const timeDiff = start - prevStart;
1784
+ timeDifferences.push(timeDiff);
1785
+ }
1786
+ }
1787
+ const lanes = Array.from(lanesSet);
1788
+ const laneSeries = lanes.map((lane) => {
1789
+ const series = laneSeriesMap.get(lane) || [];
1790
+ series.sort((a, b) => b.duration - a.duration);
1791
+ return series;
1792
+ });
1793
+ let averageDiff = 0;
1794
+ if (timeDifferences.length > 0) {
1795
+ const sumOfDifferences = timeDifferences.reduce((acc, val) => acc + val, 0);
1796
+ averageDiff = sumOfDifferences / timeDifferences.length;
1797
+ }
1798
+ const tickInterval = getTickInterval(averageDiff);
1799
+ return { laneSeries, lanes, categoricalColors, tickInterval };
1800
+ }
1801
+ var drawRoundedRect = (ctx, x, y, width, height, radius) => {
1802
+ ctx.beginPath();
1803
+ ctx.moveTo(x + radius, y);
1804
+ ctx.lineTo(x + width - radius, y);
1805
+ ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
1806
+ ctx.lineTo(x + width, y + height - radius);
1807
+ ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
1808
+ ctx.lineTo(x + radius, y + height);
1809
+ ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
1810
+ ctx.lineTo(x, y + radius);
1811
+ ctx.quadraticCurveTo(x, y, x + radius, y);
1812
+ ctx.closePath();
1813
+ ctx.fill();
1814
+ ctx.stroke();
1815
+ };
1816
+ var truncateText = (text, maxWidth, truncationType, font = '10px "Splunk Data Sans"') => {
1817
+ const canvas = document.createElement("canvas");
1818
+ const context = canvas.getContext("2d");
1819
+ if (!context) return text;
1820
+ context.font = font;
1821
+ const ellipsis = "...";
1822
+ const ellipsisWidth = context.measureText(ellipsis).width;
1823
+ const fullTextWidth = context.measureText(text).width;
1824
+ if (fullTextWidth <= maxWidth) {
1825
+ return text;
1826
+ }
1827
+ if (truncationType === "ellipsisEnd") {
1828
+ for (let i = text.length - 1; i > 0; i -= 1) {
1829
+ const truncatedText = text.slice(0, i) + ellipsis;
1830
+ if (context.measureText(truncatedText).width <= maxWidth) {
1831
+ return truncatedText;
1832
+ }
1833
+ }
1834
+ } else if (truncationType === "ellipsisStart") {
1835
+ for (let i = 0; i < text.length; i += 1) {
1836
+ const truncatedText = ellipsis + text.slice(i);
1837
+ if (context.measureText(truncatedText).width <= maxWidth) {
1838
+ return truncatedText;
1839
+ }
1840
+ }
1841
+ } else if (truncationType === "ellipsisMiddle") {
1842
+ for (let i = 0; i < text.length / 2; i += 1) {
1843
+ const left = text.slice(0, Math.floor(text.length / 2) - i);
1844
+ const right = text.slice(Math.ceil(text.length / 2) + i);
1845
+ const truncatedText = left + ellipsis + right;
1846
+ if (context.measureText(left).width + ellipsisWidth + context.measureText(right).width <= maxWidth) {
1847
+ return truncatedText;
1848
+ }
1849
+ }
1850
+ }
1851
+ return ellipsis;
1852
+ };
1853
+ var getTickInterval = (averageDiff) => {
1854
+ if (averageDiff < 6e4) {
1855
+ return "1s";
1856
+ }
1857
+ if (averageDiff < 36e5) {
1858
+ return "1m";
1859
+ }
1860
+ if (averageDiff < 18e6) {
1861
+ return "30m";
1862
+ }
1863
+ if (averageDiff < 432e5) {
1864
+ return "1h";
1865
+ }
1866
+ if (averageDiff < 864e5) {
1867
+ return "12h";
1868
+ }
1869
+ if (averageDiff < 6048e5) {
1870
+ return "1d";
1871
+ }
1872
+ if (averageDiff < 2592e6) {
1873
+ return "7d";
1874
+ }
1875
+ return "1mo";
1876
+ };
1877
+ function convertTickIntervalToMs(tickInterval) {
1878
+ switch (tickInterval) {
1879
+ case "1s":
1880
+ return 1e3;
1881
+ case "1m":
1882
+ return 6e4;
1883
+ case "30m":
1884
+ return 18e5;
1885
+ case "1h":
1886
+ return 36e5;
1887
+ case "12h":
1888
+ return 432e5;
1889
+ case "1d":
1890
+ return 864e5;
1891
+ case "7d":
1892
+ return 6048e5;
1893
+ case "1mo":
1894
+ return 275e7;
1895
+ default:
1896
+ throw new Error("Unsupported tick interval");
1897
+ }
1898
+ }
1899
+ function calculateMaxNumberOfTicks(availableWidth, pixelPerLabel, extraSpacing) {
1900
+ const minSpacingPerLabel = pixelPerLabel + extraSpacing;
1901
+ const effectiveWidth = availableWidth - 2 * minSpacingPerLabel;
1902
+ const maxNumTicks = Math.floor(effectiveWidth / minSpacingPerLabel);
1903
+ return Math.max(maxNumTicks, 0);
1904
+ }
1905
+ var isSafari = () => /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
1906
+ var tooltipLocaleTimeFormat = (displaySeconds) => {
1907
+ const seconds = displaySeconds ? { second: "2-digit" } : {};
1908
+ return __spreadValues({
1909
+ hour: "numeric",
1910
+ minute: "2-digit",
1911
+ day: "numeric",
1912
+ month: "short",
1913
+ year: "numeric"
1914
+ }, seconds);
1915
+ };
1916
+
1917
+ // esm-externals:uplot-react
1918
+ var uplot_react_exports = {};
1919
+ __export(uplot_react_exports, {
1920
+ default: () => uplot_react_default
1921
+ });
1922
+ var defaultImport31 = __toESM(require("uplot-react"));
1923
+ __reExport(uplot_react_exports, require("uplot-react"));
1924
+ var uplot_react_default = "default" in defaultImport31 ? defaultImport31.default : defaultImport31;
1925
+
1926
+ // src/Timeline/PureTimeline/src/CursorPlugin.tsx
1927
+ var currentScaleFactor = 1;
1928
+ var canvasScaleObserver = null;
1929
+ var updateScaleFactor = () => {
1930
+ const canvasElement = document.querySelector('[data-test="canvas"]');
1931
+ if (canvasElement) {
1932
+ const computedStyle = window.getComputedStyle(canvasElement);
1933
+ const transformMatrix = computedStyle.getPropertyValue("transform");
1934
+ if (transformMatrix && transformMatrix !== "none") {
1935
+ const matrixValues = transformMatrix.match(/matrix(?:3d)?\((.+)\)/);
1936
+ if (matrixValues) {
1937
+ const values = matrixValues[1].split(", ");
1938
+ currentScaleFactor = parseFloat(values[0]);
1939
+ }
1940
+ } else {
1941
+ currentScaleFactor = 1;
1942
+ }
1943
+ } else {
1944
+ canvasScaleObserver == null ? void 0 : canvasScaleObserver.disconnect();
1945
+ }
1946
+ };
1947
+ var resetScaleFactorOnFullscreen = () => {
1948
+ document.addEventListener("fullscreenchange", () => {
1949
+ if (document.fullscreenElement) {
1950
+ currentScaleFactor = 1;
1951
+ } else {
1952
+ updateScaleFactor();
1953
+ }
1954
+ });
1955
+ };
1956
+ var initObserver = () => {
1957
+ const canvasElement = document.querySelector('[data-test="canvas"]');
1958
+ if (canvasElement) {
1959
+ canvasScaleObserver = new MutationObserver((mutationsList) => {
1960
+ mutationsList.forEach((mutation) => {
1961
+ if (mutation.type === "attributes" && mutation.attributeName === "style") {
1962
+ updateScaleFactor();
1963
+ }
1964
+ });
1965
+ });
1966
+ canvasScaleObserver.observe(canvasElement, { attributes: true, attributeFilter: ["style"] });
1967
+ }
1968
+ };
1969
+ document.addEventListener("DOMContentLoaded", () => {
1970
+ updateScaleFactor();
1971
+ initObserver();
1972
+ resetScaleFactorOnFullscreen();
1973
+ });
1974
+ var CursorPlugin = ({
1975
+ laneSeries,
1976
+ lanes,
1977
+ numTicks,
1978
+ durationPerTick,
1979
+ setHighlightedCategory,
1980
+ setHighlightedEvent,
1981
+ setHighlightedLane,
1982
+ handleEventClick,
1983
+ tooltipRef
1984
+ }) => {
1985
+ const FIXED_LANE_HEIGHT = 32;
1986
+ const MIN_BAR_WIDTH = 20;
1987
+ const CIRCLE_X_OFFSET = 10;
1988
+ const CIRCLE_LANE_SCALE_FACTOR = 0.85;
1989
+ let previousTooltipContent = null;
1990
+ const dpr = window.devicePixelRatio || 1;
1991
+ const handleMouseLeave = (u) => {
1992
+ const xCursorLine = u.root.querySelector(".u-cursor-x");
1993
+ xCursorLine.classList.add("u-off");
1994
+ tooltipRef.current = {
1995
+ visible: false,
1996
+ overflow: false,
1997
+ content: "",
1998
+ meta: ""
1999
+ };
2000
+ setHighlightedLane(null);
2001
+ setHighlightedEvent(null);
2002
+ setHighlightedCategory(null);
2003
+ };
2004
+ const handleClick = () => {
2005
+ if (tooltipRef.current.visible) {
2006
+ const { content, meta } = tooltipRef.current;
2007
+ if (!previousTooltipContent || JSON.stringify(previousTooltipContent) !== JSON.stringify(content)) {
2008
+ handleEventClick(content.from, meta.duration, content.lane, content.category);
2009
+ previousTooltipContent = __spreadValues({}, content);
2010
+ }
2011
+ }
2012
+ };
2013
+ return {
2014
+ hooks: {
2015
+ init: (u) => {
2016
+ const chartContainer = u.root;
2017
+ chartContainer.addEventListener("click", handleClick);
2018
+ if (!isSafari()) {
2019
+ chartContainer.addEventListener("mouseleave", () => handleMouseLeave(u));
2020
+ }
2021
+ return () => {
2022
+ chartContainer.removeEventListener("mouseleave", () => handleMouseLeave(u));
2023
+ chartContainer.removeEventListener("click", handleClick);
2024
+ };
2025
+ },
2026
+ setCursor: (u) => {
2027
+ const mouseEvent = u.cursor.event;
2028
+ const xCursorLine = u.root.querySelector(".u-cursor-x");
2029
+ if (!mouseEvent) {
2030
+ tooltipRef.current.visible = false;
2031
+ if (xCursorLine) {
2032
+ xCursorLine.classList.add("u-off");
2033
+ }
2034
+ return;
2035
+ }
2036
+ const effectiveWidth = u.bbox.width * currentScaleFactor;
2037
+ const effectiveHeight = u.bbox.height * currentScaleFactor;
2038
+ const xPos = (mouseEvent.clientX - u.root.getBoundingClientRect().left) * (u.bbox.width / effectiveWidth);
2039
+ const yPos = (mouseEvent.clientY - u.root.getBoundingClientRect().top) * (u.bbox.height / effectiveHeight);
2040
+ u.cursor.left = xPos;
2041
+ u.cursor.top = yPos;
2042
+ if (xCursorLine) {
2043
+ if (xPos < 0 || xPos > u.bbox.width || yPos < 0 || yPos > u.bbox.height) {
2044
+ xCursorLine.classList.add("u-off");
2045
+ } else {
2046
+ xCursorLine.classList.remove("u-off");
2047
+ xCursorLine.style.transform = `translateX(${xPos}px)`;
2048
+ }
2049
+ }
2050
+ const cursorSeriesIndex = Math.ceil(yPos / FIXED_LANE_HEIGHT);
2051
+ const events = laneSeries[cursorSeriesIndex - 1];
2052
+ let showTooltip = false;
2053
+ let tooltipContent = {};
2054
+ let tooltipMeta = {};
2055
+ let tooltipX = 0;
2056
+ let tooltipY = 0;
2057
+ let overflow = false;
2058
+ if (events) {
2059
+ const sortedEvents = [...events].sort((a, b) => {
2060
+ if (a.duration === 0 && b.duration !== 0) return 1;
2061
+ if (a.duration !== 0 && b.duration === 0) return -1;
2062
+ return 0;
2063
+ });
2064
+ for (let i = sortedEvents.length - 1; i >= 0; i -= 1) {
2065
+ const event = sortedEvents[i];
2066
+ const xStartFraction = (event.start - u.scales.x.min) / durationPerTick;
2067
+ const xStart = xStartFraction * (u.bbox.width / dpr / numTicks);
2068
+ const circleDiameter = FIXED_LANE_HEIGHT * CIRCLE_LANE_SCALE_FACTOR;
2069
+ const circleStart = xStart - CIRCLE_X_OFFSET;
2070
+ if (event.duration === 0) {
2071
+ if (xPos >= circleStart && xPos <= circleStart + circleDiameter) {
2072
+ tooltipX = circleStart + (circleDiameter + CIRCLE_X_OFFSET) / 2;
2073
+ tooltipY = cursorSeriesIndex * FIXED_LANE_HEIGHT;
2074
+ showTooltip = true;
2075
+ }
2076
+ } else {
2077
+ const durationWidth = event.duration / durationPerTick * (u.bbox.width / dpr / numTicks);
2078
+ const barWidth = Math.max(durationWidth, MIN_BAR_WIDTH);
2079
+ if (xPos >= xStart && xPos <= xStart + barWidth) {
2080
+ tooltipX = xStart + CIRCLE_X_OFFSET;
2081
+ tooltipY = cursorSeriesIndex * FIXED_LANE_HEIGHT;
2082
+ showTooltip = true;
2083
+ }
2084
+ }
2085
+ if (showTooltip) {
2086
+ const displaySeconds = durationPerTick < 6e4 && event.duration !== 0;
2087
+ const startTime = new Date(event.start).toLocaleTimeString(
2088
+ [],
2089
+ tooltipLocaleTimeFormat(displaySeconds)
2090
+ );
2091
+ const endTime = new Date(event.end).toLocaleTimeString(
2092
+ [],
2093
+ tooltipLocaleTimeFormat(displaySeconds)
2094
+ );
2095
+ const lane = lanes[cursorSeriesIndex - 1];
2096
+ tooltipContent = __spreadValues({
2097
+ from: startTime,
2098
+ to: endTime,
2099
+ lane,
2100
+ category: (event == null ? void 0 : event.category) || void 0
2101
+ }, event.additionalTooltipValue);
2102
+ tooltipMeta = __spreadValues({
2103
+ duration: event.duration
2104
+ }, event.additionalTooltipValue);
2105
+ const tooltipWidth = 85;
2106
+ const plotRightEdge = u.bbox.width / dpr;
2107
+ if (tooltipX + tooltipWidth > plotRightEdge) {
2108
+ overflow = true;
2109
+ tooltipY -= FIXED_LANE_HEIGHT / 2;
2110
+ tooltipX -= event.duration === 0 ? FIXED_LANE_HEIGHT : MIN_BAR_WIDTH;
2111
+ }
2112
+ if (!tooltipRef.current.visible || tooltipRef.current.content !== tooltipContent) {
2113
+ u.root.style.cursor = "pointer";
2114
+ tooltipRef.current = {
2115
+ visible: true,
2116
+ x: tooltipX,
2117
+ y: tooltipY,
2118
+ overflow,
2119
+ content: tooltipContent,
2120
+ meta: tooltipMeta
2121
+ };
2122
+ setHighlightedLane(lane);
2123
+ setHighlightedEvent(event);
2124
+ setHighlightedCategory(event.category);
2125
+ }
2126
+ break;
2127
+ }
2128
+ }
2129
+ }
2130
+ if (!showTooltip && tooltipRef.current.visible) {
2131
+ u.root.style.cursor = "default";
2132
+ tooltipRef.current = {
2133
+ visible: false,
2134
+ overflow: false,
2135
+ content: "",
2136
+ meta: ""
2137
+ };
2138
+ setHighlightedLane(null);
2139
+ setHighlightedEvent(null);
2140
+ setHighlightedCategory(null);
2141
+ }
2142
+ }
2143
+ }
2144
+ };
2145
+ };
2146
+ var CursorPlugin_default = CursorPlugin;
2147
+
2148
+ // src/Timeline/PureTimeline/src/TimelinePlugin.tsx
2149
+ var TimelinePlugin = ({
2150
+ laneSeries,
2151
+ lanes,
2152
+ backgroundColor,
2153
+ numTicks,
2154
+ durationPerTick,
2155
+ highlightedCategory = null,
2156
+ highlightedEvent = null
2157
+ }) => {
2158
+ const FIXED_LANE_HEIGHT = 32;
2159
+ const AXIS_COLOR = backgroundColor;
2160
+ const ALTERNATE_COLOR = getAlternateColor(backgroundColor, 0.1);
2161
+ const MIN_BAR_WIDTH = 20;
2162
+ const LANE_SCALE_FACTOR = 0.85;
2163
+ const theme = (0, themes_exports.useSplunkTheme)();
2164
+ let dpr = window.devicePixelRatio || 1;
2165
+ const redrawChart = (u) => {
2166
+ u.redraw();
2167
+ };
2168
+ return {
2169
+ hooks: {
2170
+ drawClear: (u) => {
2171
+ const { ctx } = u;
2172
+ const canvas = u.root.querySelector("canvas");
2173
+ if (canvas) {
2174
+ canvas.style.position = "absolute";
2175
+ }
2176
+ window.addEventListener("resize", () => {
2177
+ const newDpr = window.devicePixelRatio || 1;
2178
+ if (newDpr !== dpr) {
2179
+ dpr = newDpr;
2180
+ redrawChart(u);
2181
+ }
2182
+ });
2183
+ ctx.save();
2184
+ ctx.scale(dpr, dpr);
2185
+ const chartTopY = u.bbox.top / dpr;
2186
+ lanes.forEach((lane, sidx) => {
2187
+ const y = chartTopY + sidx * FIXED_LANE_HEIGHT;
2188
+ ctx.fillStyle = (lanes.length - sidx - 1) % 2 === 0 ? AXIS_COLOR : ALTERNATE_COLOR;
2189
+ ctx.fillRect(u.bbox.left / dpr, y, u.bbox.width / dpr, FIXED_LANE_HEIGHT);
2190
+ });
2191
+ ctx.restore();
2192
+ },
2193
+ draw: (u) => {
2194
+ const { ctx } = u;
2195
+ const widthPerTick = u.bbox.width / dpr / numTicks;
2196
+ const scaleMin = u.scales.x.min;
2197
+ ctx.save();
2198
+ ctx.scale(dpr, dpr);
2199
+ lanes.forEach((lane, sidx) => {
2200
+ const events = laneSeries[sidx];
2201
+ const laneCenterY = u.bbox.top / dpr + sidx * FIXED_LANE_HEIGHT + FIXED_LANE_HEIGHT / 2;
2202
+ events.forEach((event) => {
2203
+ const isHighlighted = highlightedEvent ? highlightedEvent === event : highlightedCategory === null || event.category === highlightedCategory;
2204
+ const fillColor = isHighlighted ? hexToRgba(event.color, 0.5) : hexToRgba(theme.contentColorMuted, 0.2);
2205
+ const strokeColor = isHighlighted ? hexToRgba(event.color, 0.8) : hexToRgba(theme.contentColorMuted, 0.2);
2206
+ const xStartFraction = (event.start - scaleMin) / durationPerTick;
2207
+ const xStart = sidx === 0 ? xStartFraction * widthPerTick + 2 : xStartFraction * widthPerTick;
2208
+ const durationWidth = event.duration / durationPerTick * widthPerTick;
2209
+ const barWidth = Math.max(durationWidth, MIN_BAR_WIDTH);
2210
+ const barHeight = FIXED_LANE_HEIGHT * LANE_SCALE_FACTOR;
2211
+ const yBarTop = laneCenterY - barHeight / 2;
2212
+ if (xStart >= 0) {
2213
+ if (event.duration === null || event.duration === 0) {
2214
+ const circleRadius = barHeight / 2;
2215
+ ctx.beginPath();
2216
+ ctx.arc(xStart, laneCenterY, circleRadius, 0, 2 * Math.PI);
2217
+ ctx.fillStyle = fillColor;
2218
+ ctx.fill();
2219
+ ctx.strokeStyle = strokeColor;
2220
+ ctx.lineWidth = 1;
2221
+ ctx.stroke();
2222
+ } else {
2223
+ ctx.fillStyle = fillColor;
2224
+ ctx.strokeStyle = strokeColor;
2225
+ ctx.lineWidth = 1;
2226
+ drawRoundedRect(ctx, xStart, yBarTop, barWidth, barHeight, 5);
2227
+ }
2228
+ }
2229
+ });
2230
+ });
2231
+ ctx.restore();
2232
+ }
2233
+ }
2234
+ };
2235
+ };
2236
+ var TimelinePlugin_default = TimelinePlugin;
2237
+
2238
+ // src/Timeline/PureTimeline/src/XAxisPlugin.tsx
2239
+ var X_AXIS_HEIGHT = 60;
2240
+ var XAxisPlugin = ({
2241
+ durationPerTick = 0,
2242
+ numTicks = 0,
2243
+ backgroundColor = "#0b0c0e",
2244
+ tickInterval = "1d"
2245
+ } = {}) => {
2246
+ const themes3 = (0, themes_exports.useSplunkTheme)();
2247
+ return {
2248
+ hooks: {
2249
+ drawClear: (u) => {
2250
+ const { ctx } = u;
2251
+ const dpr = window.devicePixelRatio || 1;
2252
+ ctx.save();
2253
+ ctx.scale(dpr, dpr);
2254
+ const xAxisY = (u.bbox.top + u.bbox.height - X_AXIS_HEIGHT * dpr) / dpr;
2255
+ ctx.fillStyle = backgroundColor;
2256
+ ctx.fillRect(0, xAxisY, u.bbox.width / dpr, X_AXIS_HEIGHT);
2257
+ ctx.restore();
2258
+ },
2259
+ draw: (u) => {
2260
+ const { ctx } = u;
2261
+ const dpr = window.devicePixelRatio || 1;
2262
+ const scaleMin = u.scales.x.min;
2263
+ const maxLabelWidth = 50;
2264
+ const ticks = [scaleMin];
2265
+ for (let i = 1; i <= numTicks; i += 1) {
2266
+ ticks.push(scaleMin + i * durationPerTick);
2267
+ }
2268
+ let lastDay = null;
2269
+ let lastYear = null;
2270
+ const labels = ticks.map((tick, index) => {
2271
+ const labelParts = [];
2272
+ const date = new Date(tick);
2273
+ const time = tickInterval === "1s" ? date.toLocaleTimeString([], {
2274
+ hour: "numeric",
2275
+ minute: "2-digit",
2276
+ second: "2-digit"
2277
+ }) : date.toLocaleTimeString([], { hour: "numeric", minute: "2-digit" });
2278
+ const day = date.toLocaleDateString([], {
2279
+ weekday: "short",
2280
+ month: "short",
2281
+ day: "numeric"
2282
+ });
2283
+ const month = date.toLocaleDateString([], {
2284
+ month: "long"
2285
+ });
2286
+ const year = date.getFullYear().toString();
2287
+ if (tickInterval !== "1d" && tickInterval !== "7d" && tickInterval !== "1mo") {
2288
+ labelParts.push(time);
2289
+ }
2290
+ if (tickInterval !== "1mo" && (index === 0 || day !== lastDay)) {
2291
+ labelParts.push(day);
2292
+ lastDay = day;
2293
+ }
2294
+ if (tickInterval === "1mo") {
2295
+ labelParts.push(month);
2296
+ }
2297
+ if (index === 0 || year !== lastYear) {
2298
+ labelParts.push(year);
2299
+ lastYear = year;
2300
+ }
2301
+ return labelParts;
2302
+ });
2303
+ ctx.save();
2304
+ ctx.scale(dpr, dpr);
2305
+ ctx.font = "10px sans-serif";
2306
+ ctx.fillStyle = themes3.contentColorMuted;
2307
+ ctx.textAlign = "left";
2308
+ ctx.textBaseline = "top";
2309
+ const tickHeight = 5;
2310
+ const labelOffset = 5;
2311
+ const lineHeight = 12;
2312
+ const xAxisY = (u.bbox.top + u.bbox.height - X_AXIS_HEIGHT * dpr) / dpr;
2313
+ ticks.forEach((val, i) => {
2314
+ let xTickPosition;
2315
+ if (i === 0) {
2316
+ xTickPosition = 0;
2317
+ } else {
2318
+ xTickPosition = i * (u.bbox.width / dpr / numTicks);
2319
+ }
2320
+ if (i === ticks.length - 1 && xTickPosition + maxLabelWidth > u.bbox.width / dpr) {
2321
+ return;
2322
+ }
2323
+ const yLabelPosition = xAxisY + tickHeight + labelOffset;
2324
+ ctx.beginPath();
2325
+ ctx.moveTo(xTickPosition, xAxisY);
2326
+ ctx.lineTo(xTickPosition, xAxisY + tickHeight);
2327
+ ctx.strokeStyle = "rgba(144, 144, 144, 0.5)";
2328
+ ctx.lineWidth = i === 0 ? 1 * dpr : 0.5 * dpr;
2329
+ ctx.stroke();
2330
+ const label = labels[i];
2331
+ if (label) {
2332
+ label.forEach((line, idx) => {
2333
+ ctx.fillText(line, xTickPosition, yLabelPosition + idx * lineHeight);
2334
+ });
2335
+ }
2336
+ });
2337
+ ctx.restore();
2338
+ }
2339
+ }
2340
+ };
2341
+ };
2342
+ var XAxisPlugin_default = XAxisPlugin;
2343
+
2344
+ // src/Timeline/PureTimeline/src/TimelineYAxis.tsx
2345
+ var YAxisContainer = styled_components_default.div`
2346
+ width: ${({ width }) => `${width}px`};
2347
+ height: ${({ height }) => `${height}px`};
2348
+ display: flex;
2349
+ flex-direction: column;
2350
+ align-items: flex-start;
2351
+ flex-shrink: 0;
2352
+ margin-right: -1px;
2353
+ z-index: 100;
2354
+ `;
2355
+ var YAxisLane = styled_components_default.div`
2356
+ overflow: hidden;
2357
+ white-space: nowrap;
2358
+ height: 32px;
2359
+ padding: 6px 8px;
2360
+ width: 100%;
2361
+ display: flex;
2362
+ align-items: center;
2363
+ justify-content: flex-start;
2364
+ text-align: left;
2365
+ font-size: 14px;
2366
+ border-right: 1px solid
2367
+ ${(0, themes_exports.pick)({
2368
+ enterprise: themes_exports.variables.borderColorWeak,
2369
+ prisma: themes_exports.variables.interactiveColorBackgroundDisabled
2370
+ })};
2371
+ background-color: ${({ isEven, backgroundColor }) => isEven ? hexToRgba(backgroundColor) : getAlternateColor(backgroundColor, 0.1)};
2372
+ box-sizing: border-box;
2373
+ color: ${({ color }) => `${color}`};
2374
+ `;
2375
+ var TimelineYAxis = ({
2376
+ height,
2377
+ lanes,
2378
+ yAxisLabelWidth,
2379
+ laneHeight,
2380
+ backgroundColor,
2381
+ highlightedLane,
2382
+ handleLaneClick
2383
+ }) => {
2384
+ const theme = (0, themes_exports.useSplunkTheme)();
2385
+ const lanePadding = 16;
2386
+ return /* @__PURE__ */ react_exports.createElement(YAxisContainer, { "data-test": "timeline-yaxis-container", height, width: yAxisLabelWidth }, lanes.map((lane, index) => {
2387
+ let laneTextColor = theme.contentColorDefault;
2388
+ const isHovering = highlightedLane !== null;
2389
+ const isMuted = highlightedLane !== lane;
2390
+ if (isHovering) {
2391
+ if (isMuted) {
2392
+ laneTextColor = theme.contentColorDisabled;
2393
+ } else {
2394
+ laneTextColor = theme.contentColorActive;
2395
+ }
2396
+ }
2397
+ const truncatedText = truncateText(
2398
+ lane.toString(),
2399
+ yAxisLabelWidth - lanePadding,
2400
+ "ellipsisMiddle",
2401
+ '14px "Splunk Data Sans"'
2402
+ );
2403
+ return /* @__PURE__ */ react_exports.createElement(
2404
+ YAxisLane,
2405
+ {
2406
+ key: lane,
2407
+ "data-test": "timeline-lane",
2408
+ height: laneHeight,
2409
+ color: laneTextColor,
2410
+ isEven: (lanes.length - index - 1) % 2 === 0,
2411
+ backgroundColor,
2412
+ onClick: () => {
2413
+ handleLaneClick(lane);
2414
+ }
2415
+ },
2416
+ truncatedText
2417
+ );
2418
+ }));
2419
+ };
2420
+ TimelineYAxis.propTypes = {
2421
+ lanes: prop_types_exports.arrayOf(prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number])).isRequired,
2422
+ yAxisLabelWidth: prop_types_exports.number.isRequired,
2423
+ laneHeight: prop_types_exports.number.isRequired
2424
+ };
2425
+ var TimelineYAxis_default = TimelineYAxis;
2426
+
2427
+ // src/Timeline/PureTimeline/src/TimelineLegend.tsx
2428
+ var LEGEND_WIDTH = 92;
2429
+ var LEGEND_TEXT_WIDTH = 55;
2430
+ var LegendContainer = styled_components_default.div`
2431
+ display: flex;
2432
+ justify-content: center;
2433
+ flex-direction: ${({ legendDisplay }) => legendDisplay === "bottom" ? "row" : "column"};
2434
+ align-items: flex-start;
2435
+ background-color: ${({ backgroundColor }) => backgroundColor};
2436
+ color: #fafafa;
2437
+ font-size: 10px;
2438
+ ${({ legendDisplay, height, width, yAxisLabelWidth }) => legendDisplay === "right" ? `
2439
+ width: ${LEGEND_WIDTH}px;
2440
+ height: ${height}px;
2441
+ margin-top: -30px;
2442
+ margin-left: 10px;
2443
+ margin-right: 12px;
2444
+ overflow-x: hidden;
2445
+ ` : `
2446
+ flex-wrap: wrap;
2447
+ height: 60px;
2448
+ width: ${width}px;
2449
+ margin-left: ${yAxisLabelWidth}px;
2450
+ padding-bottom: 10px;
2451
+ `}
2452
+ `;
2453
+ var LegendItem = styled_components_default.div`
2454
+ display: flex;
2455
+ align-items: center;
2456
+ margin: ${({ legendDisplay }) => legendDisplay === "bottom" ? "10px 20px 10px 0px" : "4px"};
2457
+ cursor: pointer;
2458
+ opacity: ${({ isHighlighted }) => isHighlighted ? 1 : 0.5};
2459
+ transition: opacity 0.2s ease;
2460
+ `;
2461
+ var LegendColor = styled_components_default.div`
2462
+ width: 6px;
2463
+ height: 11px;
2464
+ margin-right: ${({ legendDisplay }) => legendDisplay === "bottom" ? "8px" : "4px"};
2465
+ background-color: ${({ color }) => hexToRgba(color, 0.5)};
2466
+ border: 1px solid ${({ color }) => color};
2467
+ transform: ${({ legendDisplay }) => legendDisplay === "bottom" ? "rotate(90deg)" : "none"};
2468
+ opacity: ${({ isHighlighted }) => isHighlighted ? 1 : 0.5};
2469
+ `;
2470
+ var LegendText = styled_components_default.div`
2471
+ ${({ legendTruncation }) => legendTruncation !== "ellipsisOff" && `
2472
+ white-space: nowrap;
2473
+ overflow: hidden;
2474
+ text-overflow: ellipsis;
2475
+ `}
2476
+ font-size: 10px;
2477
+ color: ${themes_exports.variables.contentColorActive};
2478
+ `;
2479
+ var TimelineLegend = ({
2480
+ backgroundColor,
2481
+ categoryColors,
2482
+ highlightedCategory = null,
2483
+ setHighlightedCategory,
2484
+ height,
2485
+ width,
2486
+ handleLegendClick,
2487
+ legendDisplay = "right",
2488
+ legendTruncation = "ellipsisEnd",
2489
+ yAxisLabelWidth = 0
2490
+ }) => {
2491
+ const handleMouseEnter = (category) => {
2492
+ setHighlightedCategory == null ? void 0 : setHighlightedCategory(category);
2493
+ };
2494
+ const handleMouseLeave = (e) => {
2495
+ if (!e.currentTarget.contains(e.relatedTarget)) {
2496
+ setHighlightedCategory == null ? void 0 : setHighlightedCategory(null);
2497
+ }
2498
+ };
2499
+ return /* @__PURE__ */ react_exports.createElement(
2500
+ LegendContainer,
2501
+ {
2502
+ "data-test": "legend-container",
2503
+ "data-test-position-value": legendDisplay,
2504
+ "data-test-truncation-value": legendTruncation,
2505
+ legendDisplay,
2506
+ backgroundColor,
2507
+ height,
2508
+ width,
2509
+ yAxisLabelWidth
2510
+ },
2511
+ Array.from(categoryColors.entries()).map(([category, color]) => {
2512
+ const isHighlighted = !highlightedCategory || highlightedCategory === category;
2513
+ const truncatedText = legendTruncation === "ellipsisOff" || legendDisplay === "bottom" ? category : truncateText(category, LEGEND_TEXT_WIDTH, legendTruncation);
2514
+ return /* @__PURE__ */ react_exports.createElement(
2515
+ LegendItem,
2516
+ {
2517
+ "data-test": "legend-item",
2518
+ key: category,
2519
+ color,
2520
+ isHighlighted,
2521
+ legendDisplay,
2522
+ onMouseEnter: () => handleMouseEnter(category),
2523
+ onMouseOut: (e) => handleMouseLeave(e),
2524
+ onClick: () => {
2525
+ handleLegendClick(category);
2526
+ }
2527
+ },
2528
+ /* @__PURE__ */ react_exports.createElement(
2529
+ LegendColor,
2530
+ {
2531
+ "data-test": "legend-color",
2532
+ color,
2533
+ isHighlighted,
2534
+ legendDisplay
2535
+ }
2536
+ ),
2537
+ /* @__PURE__ */ react_exports.createElement(LegendText, { legendTruncation, "data-test": "legend-text" }, truncatedText)
2538
+ );
2539
+ })
2540
+ );
2541
+ };
2542
+ TimelineLegend.propTypes = {
2543
+ backgroundColor: prop_types_exports.string.isRequired,
2544
+ height: prop_types_exports.number.isRequired,
2545
+ legendDisplay: prop_types_exports.oneOf(["right", "bottom"]),
2546
+ legendTruncation: prop_types_exports.oneOf(["ellipsisEnd", "ellipsisMiddle", "ellipsisStart", "ellipsisOff"]),
2547
+ categoryColors: prop_types_exports.any,
2548
+ highlightedCategory: prop_types_exports.string,
2549
+ setHighlightedCategory: prop_types_exports.func
2550
+ };
2551
+ var TimelineLegend_default = TimelineLegend;
2552
+
2553
+ // esm-externals:@splunk/themes/useSplunkTheme
2554
+ var useSplunkTheme_exports = {};
2555
+ __export(useSplunkTheme_exports, {
2556
+ default: () => useSplunkTheme_default
2557
+ });
2558
+ var defaultImport32 = __toESM(require("@splunk/themes/useSplunkTheme"));
2559
+ __reExport(useSplunkTheme_exports, require("@splunk/themes/useSplunkTheme"));
2560
+ var useSplunkTheme_default = "default" in defaultImport32 ? defaultImport32.default : defaultImport32;
2561
+
2562
+ // src/Timeline/PureTimeline/src/TimelineTooltip.tsx
2563
+ var TooltipContainer = styled_components_default.div`
2564
+ position: absolute;
2565
+ background-color: ${({ backgroundColor }) => `${backgroundColor}`};
2566
+ box-shadow: ${(0, themes_exports.pick)({
2567
+ enterprise: themes_exports.variables.overlayShadow,
2568
+ prisma: themes_exports.variables.overlayShadow
2569
+ })};
2570
+ padding: 12px 16px;
2571
+ border-radius: 3px;
2572
+ pointer-events: none;
2573
+ display: ${({ visible }) => visible ? "block" : "none"};
2574
+ white-space: nowrap;
2575
+ left: ${({ x }) => `${x}px`};
2576
+ top: ${({ y, chartOverflow }) => `${chartOverflow ? y : y + 7}px`};
2577
+ transform: ${({ chartOverflow }) => chartOverflow ? "translate(-100%, -50%);" : "translate(-55%, 0);"}
2578
+ transition: left 0.1s ease-out, top 0.1s ease-out;
2579
+ z-index: 1000;
2580
+
2581
+ ::after {
2582
+ content: '';
2583
+ position: absolute;
2584
+ ${({ chartOverflow, backgroundColor }) => chartOverflow ? `
2585
+ top: 50%;
2586
+ left: 100%;
2587
+ transform: translateY(-50%);
2588
+ border-width: 5px;
2589
+ border-style: solid;
2590
+ border-bottom-color: transparent;
2591
+ border-top-color: transparent;
2592
+ border-right-color: transparent;
2593
+ border-left-color: ${backgroundColor};
2594
+ ` : `
2595
+ bottom: 100%;
2596
+ left: 50%;
2597
+ transform: translateX(-50%);
2598
+ border-width: 5px;
2599
+ border-style: solid;
2600
+ border-bottom-color: ${backgroundColor};
2601
+ border-top-color: transparent;
2602
+ border-right-color: transparent;
2603
+ border-left-color: transparent;
2604
+ `}
2605
+ }
2606
+ `;
2607
+ var TooltipLabel = styled_components_default.div`
2608
+ color: ${(0, themes_exports.pick)({
2609
+ enterprise: themes_exports.variables.contentColorDefault,
2610
+ prisma: themes_exports.variables.contentColorDefault
2611
+ })};
2612
+ `;
2613
+ var TooltipValue = styled_components_default.div`
2614
+ color: ${(0, themes_exports.pick)({
2615
+ enterprise: themes_exports.variables.contentColorActive,
2616
+ prisma: themes_exports.variables.contentColorActive
2617
+ })};
2618
+ `;
2619
+ var TooltipContent = styled_components_default.div`
2620
+ display: flex;
2621
+ flex-direction: row;
2622
+ justify-content: space-between;
2623
+ align-items: center;
2624
+ gap: 16px;
2625
+ font-weight: 400;
2626
+ font-size: 12px;
2627
+ line-height: 16px;
2628
+ `;
2629
+ var TimelineTooltip = ({ visible, content, x, y, overflow }) => {
2630
+ const theme = useSplunkTheme_default();
2631
+ let popoverBackground = "#33343b";
2632
+ if (theme.isPrisma) {
2633
+ popoverBackground = theme.backgroundColorPopup;
2634
+ } else if (theme.isEnterprise && theme.isLight) {
2635
+ popoverBackground = theme.white;
2636
+ }
2637
+ return /* @__PURE__ */ react_default.createElement(
2638
+ TooltipContainer,
2639
+ {
2640
+ "data-test": "timeline-tooltip",
2641
+ backgroundColor: popoverBackground,
2642
+ visible,
2643
+ x,
2644
+ y,
2645
+ chartOverflow: overflow
2646
+ },
2647
+ Object.entries(content).map(
2648
+ ([key, value]) => value !== void 0 && value !== null && /* @__PURE__ */ react_default.createElement(TooltipContent, { key }, /* @__PURE__ */ react_default.createElement(TooltipLabel, null, key.charAt(0).toUpperCase() + key.slice(1)), /* @__PURE__ */ react_default.createElement(TooltipValue, null, value))
2649
+ )
2650
+ );
2651
+ };
2652
+ var TimelineTooltip_default = TimelineTooltip;
2653
+
2654
+ // esm-externals:uplot/dist/uPlot.min.css
2655
+ var uPlot_min_exports = {};
2656
+ __export(uPlot_min_exports, {
2657
+ default: () => uPlot_min_default
2658
+ });
2659
+ var defaultImport33 = __toESM(require("uplot/dist/uPlot.min.css"));
2660
+ __reExport(uPlot_min_exports, require("uplot/dist/uPlot.min.css"));
2661
+ var uPlot_min_default = "default" in defaultImport33 ? defaultImport33.default : defaultImport33;
2662
+
2663
+ // src/Timeline/PureTimeline/src/TimelineUplot.tsx
2664
+ var TimelineUplotContainer = styled_components_default.div`
2665
+ display: flex;
2666
+ flex-direction: ${({ legendDisplay }) => legendDisplay === "bottom" ? "column" : "row"};
2667
+ width: 100%;
2668
+ height: 100%;
2669
+ padding: 10px 10px;
2670
+ overflow-y: scroll;
2671
+ overflow-x: hidden;
2672
+ `;
2673
+ var TimelineUplotWrapper = styled_components_default.div`
2674
+ width: ${({ width }) => `${width}px`};
2675
+ position: relative;
2676
+ `;
2677
+ var TimelineChartContainer = styled_components_default.div`
2678
+ display: flex;
2679
+ flex-direction: row;
2680
+ width: 100%;
2681
+ `;
2682
+ var TimelineUplot = ({
2683
+ backgroundColor,
2684
+ width,
2685
+ yAxisLabelWidth,
2686
+ laneSeries,
2687
+ lanes,
2688
+ showLegend = false,
2689
+ legendDisplay,
2690
+ categoryColors,
2691
+ legendTruncation,
2692
+ tickInterval,
2693
+ handleEventClick,
2694
+ handleLaneClick,
2695
+ handleLegendClick
2696
+ }) => {
2697
+ const [highlightedCategory, setHighlightedCategory] = react_exports.useState(null);
2698
+ const [highlightedEvent, setHighlightedEvent] = react_exports.useState(null);
2699
+ const [highlightedLane, setHighlightedLane] = react_exports.useState(null);
2700
+ const tooltipRef = react_exports.useRef({
2701
+ visible: false,
2702
+ x: 0,
2703
+ y: 0,
2704
+ overflow: false,
2705
+ content: {},
2706
+ meta: {}
2707
+ });
2708
+ const xMin = Math.min(...laneSeries.flatMap((lane) => lane.map((dp) => dp.start))) || 0;
2709
+ const xMax = Math.max(...laneSeries.flatMap((lane) => lane.map((dp) => dp.end))) || 1;
2710
+ const xAxisHeight = 60;
2711
+ const laneHeight = 32;
2712
+ const padding = 20;
2713
+ const legendWidth = showLegend && legendDisplay === "right" ? 88 : 0;
2714
+ const containerWidth = typeof width === "string" ? window.innerWidth : width;
2715
+ const chartWidth = containerWidth - yAxisLabelWidth - legendWidth - padding;
2716
+ const chartHeight = laneHeight * lanes.length + xAxisHeight;
2717
+ const granularityMultiplier = convertTickIntervalToMs(tickInterval);
2718
+ const totalRange = xMax + granularityMultiplier - xMin;
2719
+ const totalNumberOfTicks = totalRange / granularityMultiplier;
2720
+ const maxNumOfTicks = calculateMaxNumberOfTicks(chartWidth, 50, 10);
2721
+ const unitsPerTick = Math.ceil(totalNumberOfTicks / maxNumOfTicks);
2722
+ const numTicks = totalNumberOfTicks / unitsPerTick;
2723
+ const durationPerTick = granularityMultiplier * unitsPerTick;
2724
+ const opts = {
2725
+ width: chartWidth,
2726
+ height: chartHeight,
2727
+ series: [],
2728
+ axes: [
2729
+ { scale: "x", show: false },
2730
+ { scale: "y", show: false }
2731
+ ],
2732
+ cursor: {
2733
+ x: true,
2734
+ y: false,
2735
+ hover: {
2736
+ prox: 1e3,
2737
+ bias: 0
2738
+ },
2739
+ drag: {
2740
+ setScale: false,
2741
+ x: false,
2742
+ y: false
2743
+ }
2744
+ },
2745
+ padding: [0, 0, 0, 0],
2746
+ legend: { show: false },
2747
+ plugins: [
2748
+ TimelinePlugin_default({
2749
+ laneSeries,
2750
+ lanes,
2751
+ backgroundColor,
2752
+ numTicks,
2753
+ durationPerTick,
2754
+ highlightedCategory,
2755
+ highlightedEvent
2756
+ }),
2757
+ XAxisPlugin_default({ durationPerTick, numTicks, backgroundColor, tickInterval }),
2758
+ CursorPlugin_default({
2759
+ laneSeries,
2760
+ lanes,
2761
+ numTicks,
2762
+ durationPerTick,
2763
+ setHighlightedCategory,
2764
+ setHighlightedEvent,
2765
+ setHighlightedLane,
2766
+ handleEventClick,
2767
+ tooltipRef
2768
+ })
2769
+ ]
2770
+ };
2771
+ return /* @__PURE__ */ react_exports.createElement(TimelineUplotContainer, { legendDisplay }, /* @__PURE__ */ react_exports.createElement(TimelineChartContainer, { "data-test": "timeline-chart-container" }, /* @__PURE__ */ react_exports.createElement(
2772
+ TimelineYAxis_default,
2773
+ {
2774
+ height: chartHeight,
2775
+ laneHeight,
2776
+ lanes,
2777
+ yAxisLabelWidth,
2778
+ backgroundColor,
2779
+ highlightedLane,
2780
+ handleLaneClick
2781
+ }
2782
+ ), /* @__PURE__ */ react_exports.createElement(TimelineUplotWrapper, { width: chartWidth }, /* @__PURE__ */ react_exports.createElement(uplot_react_default, { options: opts, data: [[xMin], ...lanes.map(() => [])] }), /* @__PURE__ */ react_exports.createElement(TimelineTooltip_default, __spreadValues({}, tooltipRef.current)))), showLegend && /* @__PURE__ */ react_exports.createElement(
2783
+ TimelineLegend_default,
2784
+ {
2785
+ height: chartHeight,
2786
+ width: chartWidth,
2787
+ yAxisLabelWidth,
2788
+ backgroundColor,
2789
+ legendDisplay,
2790
+ categoryColors,
2791
+ highlightedCategory,
2792
+ setHighlightedCategory,
2793
+ legendTruncation,
2794
+ handleLegendClick
2795
+ }
2796
+ ));
2797
+ };
2798
+ var TimelineUplot_default = TimelineUplot;
2799
+
2800
+ // src/Timeline/PureTimeline/PureTimeline.tsx
2801
+ var TimelineContainer = styled_components_default.div`
2802
+ overflow: hidden;
2803
+ position: relative;
2804
+ background-color: ${(props) => props.backgroundColor};
2805
+ ${(props) => (0, style_exports.toDimension)((0, lodash_exports.pick)(props, ["width", "height"]))};
2806
+ `;
2807
+ var PureTimeline = (_a) => {
2808
+ var props = __objRest(_a, []);
2809
+ const {
2810
+ x,
2811
+ xField,
2812
+ y,
2813
+ yField,
2814
+ duration,
2815
+ durationField,
2816
+ category,
2817
+ categoryField,
2818
+ width,
2819
+ height,
2820
+ backgroundColor,
2821
+ seriesColors,
2822
+ dataColors,
2823
+ additionalTooltipValues,
2824
+ resultLimit,
2825
+ yAxisLabelWidth,
2826
+ legendDisplay,
2827
+ legendTruncation,
2828
+ onEventClick,
2829
+ onLaneClick,
2830
+ onLegendClick
2831
+ } = props;
2832
+ const showLegend = (!dataColors || (dataColors == null ? void 0 : dataColors.length) === 0) && (category == null ? void 0 : category.length) > 0 && (legendDisplay === "right" || legendDisplay === "bottom");
2833
+ const timezone = react_exports.useContext(TimezoneContext_default);
2834
+ const theme = (0, themes_exports.useSplunkTheme)();
2835
+ const { laneSeries, lanes, categoricalColors, tickInterval } = mapDataToTimeline(
2836
+ resultLimit,
2837
+ x,
2838
+ y,
2839
+ duration,
2840
+ category,
2841
+ dataColors,
2842
+ seriesColors,
2843
+ additionalTooltipValues,
2844
+ timezone
2845
+ );
2846
+ const handleLaneClick = (laneValue) => {
2847
+ onLaneClick({
2848
+ type: "lane.click",
2849
+ payload: {
2850
+ name: yField,
2851
+ value: laneValue
2852
+ }
2853
+ });
2854
+ };
2855
+ const handleLegendClick = (categoryValue) => {
2856
+ onLegendClick({
2857
+ type: "legend.click",
2858
+ payload: {
2859
+ name: categoryField,
2860
+ value: categoryValue
2861
+ }
2862
+ });
2863
+ };
2864
+ const handleEventClick = (xValue, durationValue, laneValue, categoryValue) => {
2865
+ const payload = {
2866
+ name: durationField,
2867
+ value: durationValue,
2868
+ [`row.${xField}.value`]: xValue,
2869
+ [`row.${yField}.value`]: laneValue
2870
+ };
2871
+ if (categoryValue !== void 0 && categoryValue) {
2872
+ payload[`row.${categoryField}.value`] = categoryValue;
2873
+ }
2874
+ onEventClick({
2875
+ type: "event.click",
2876
+ payload
2877
+ });
2878
+ };
2879
+ return /* @__PURE__ */ react_exports.createElement(
2880
+ TimelineContainer,
2881
+ {
2882
+ "data-test": "timeline-container",
2883
+ backgroundColor: backgroundColor || theme.backgroundColorPage,
2884
+ width,
2885
+ height,
2886
+ "data-test-data-colors": JSON.stringify(dataColors)
2887
+ },
2888
+ /* @__PURE__ */ react_exports.createElement(
2889
+ TimelineUplot_default,
2890
+ {
2891
+ backgroundColor: backgroundColor || theme.backgroundColorPage,
2892
+ width,
2893
+ lanes,
2894
+ laneSeries,
2895
+ yAxisLabelWidth,
2896
+ categoryColors: categoricalColors,
2897
+ showLegend,
2898
+ legendDisplay,
2899
+ legendTruncation,
2900
+ tickInterval,
2901
+ handleEventClick,
2902
+ handleLaneClick,
2903
+ handleLegendClick
2904
+ }
2905
+ )
2906
+ );
2907
+ };
2908
+ PureTimeline.propTypes = {
2909
+ x: prop_types_exports.arrayOf(prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number])),
2910
+ y: prop_types_exports.arrayOf(prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number])),
2911
+ duration: prop_types_exports.arrayOf(prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number])),
2912
+ category: prop_types_exports.arrayOf(prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number])),
2913
+ backgroundColor: prop_types_exports.string,
2914
+ width: prop_types_exports.number,
2915
+ height: prop_types_exports.number,
2916
+ xField: prop_types_exports.string,
2917
+ yField: prop_types_exports.string,
2918
+ durationField: prop_types_exports.string,
2919
+ categoryField: prop_types_exports.string,
2920
+ fields: prop_types_exports.array,
2921
+ columns: prop_types_exports.array,
2922
+ yAxisLabelWidth: prop_types_exports.number,
2923
+ seriesColors: prop_types_exports.oneOfType([prop_types_exports.arrayOf(prop_types_exports.string), prop_types_exports.string]),
2924
+ dataColors: prop_types_exports.oneOfType([prop_types_exports.arrayOf(prop_types_exports.string), prop_types_exports.string]),
2925
+ resultLimit: prop_types_exports.number,
2926
+ legendDisplay: prop_types_exports.oneOf(["right", "bottom", "off"]),
2927
+ legendTruncation: prop_types_exports.oneOf(["ellipsisEnd", "ellipsisMiddle", "ellipsisStart", "ellipsisOff"]),
2928
+ onEventClick: prop_types_exports.func,
2929
+ onLegendClick: prop_types_exports.func,
2930
+ onLaneClick: prop_types_exports.func,
2931
+ onRangeSelect: prop_types_exports.func
2932
+ };
2933
+ PureTimeline.defaultProps = {
2934
+ backgroundColor: null,
2935
+ width: 850,
2936
+ height: 395,
2937
+ xField: "_time",
2938
+ yField: "lane",
2939
+ durationField: "duration",
2940
+ categoryField: "category",
2941
+ fields: null,
2942
+ columns: [],
2943
+ yAxisLabelWidth: 100,
2944
+ seriesColors: [
2945
+ "#7B56DB",
2946
+ "#009CEB",
2947
+ "#00CDAF",
2948
+ "#DD9900",
2949
+ "#FF677B",
2950
+ "#CB2196",
2951
+ "#813193",
2952
+ "#0051B5",
2953
+ "#008C80",
2954
+ "#99B100",
2955
+ "#FFA476",
2956
+ "#FF6ACE",
2957
+ "#AE8CFF",
2958
+ "#00689D",
2959
+ "#00490A",
2960
+ "#465D00",
2961
+ "#9D6300",
2962
+ "#F6540B",
2963
+ "#FF969E",
2964
+ "#E47BFE"
2965
+ ],
2966
+ dataColors: [],
2967
+ resultLimit: 1e4,
2968
+ legendDisplay: "off",
2969
+ legendTruncation: "ellipsisEnd",
2970
+ onEventClick: lodash_exports.noop,
2971
+ onLaneClick: lodash_exports.noop,
2972
+ onLegendClick: lodash_exports.noop,
2973
+ onRangeSelect: lodash_exports.noop
2974
+ };
2975
+ var PureTimeline_default = PureTimeline;
2976
+
2977
+ // src/Timeline/Timeline.tsx
2978
+ var validOptions = Object.keys(visualization_schemas_exports.timelineOptionsSchema);
2979
+ var computeVizProps = (_a) => {
2980
+ var props = __objRest(_a, []);
2981
+ var _b, _c, _d, _e;
2982
+ const _a2 = props, {
2983
+ x,
2984
+ y,
2985
+ duration,
2986
+ category,
2987
+ dataSources,
2988
+ dataColors,
2989
+ seriesColors,
2990
+ onEventClick,
2991
+ onLegendClick,
2992
+ onLaneClick
2993
+ } = _a2, otherOptions = __objRest(_a2, [
2994
+ "x",
2995
+ "y",
2996
+ "duration",
2997
+ "category",
2998
+ "dataSources",
2999
+ "dataColors",
3000
+ "seriesColors",
3001
+ "onEventClick",
3002
+ "onLegendClick",
3003
+ "onLaneClick"
3004
+ ]);
3005
+ let timelineDataColors = dataColors;
3006
+ let timelineSeriesColors = seriesColors;
3007
+ const pickedOptions = (0, lodash_exports.chain)(otherOptions).pick(validOptions).value();
3008
+ const columns = ((_c = (_b = dataSources == null ? void 0 : dataSources.primary) == null ? void 0 : _b.data) == null ? void 0 : _c.columns) || [];
3009
+ const fields = ((_e = (_d = dataSources == null ? void 0 : dataSources.primary) == null ? void 0 : _d.data) == null ? void 0 : _e.fields) || [];
3010
+ const additionalTooltipValues = (pickedOptions == null ? void 0 : pickedOptions.additionalTooltipFields) ? extractAdditionalTooltipValues(columns, fields, pickedOptions == null ? void 0 : pickedOptions.additionalTooltipFields) : [];
3011
+ if (seriesColors && typeof seriesColors === "string") {
3012
+ try {
3013
+ timelineSeriesColors = JSON.parse(seriesColors);
3014
+ } catch (e) {
3015
+ timelineSeriesColors = visualization_color_palettes_exports.VIZ_CATEGORICAL;
3016
+ }
3017
+ } else if (!seriesColors) {
3018
+ timelineSeriesColors = visualization_color_palettes_exports.VIZ_CATEGORICAL;
3019
+ } else if (seriesColors && Array.isArray(seriesColors)) {
3020
+ timelineSeriesColors = (0, colorUtils_exports.sanitizeArrayOfColors)(seriesColors);
3021
+ }
3022
+ if (Array.isArray(dataColors) && (dataColors == null ? void 0 : dataColors.length)) {
3023
+ timelineDataColors = (0, colorUtils_exports.sanitizeArrayOfColors)(dataColors);
3024
+ } else if (dataColors && typeof dataColors === "string") {
3025
+ try {
3026
+ timelineDataColors = JSON.parse(dataColors);
3027
+ } catch (e) {
3028
+ timelineDataColors = visualization_color_palettes_exports.VIZ_CATEGORICAL;
3029
+ }
3030
+ }
3031
+ return __spreadValues({
3032
+ x,
3033
+ y,
3034
+ duration,
3035
+ category,
3036
+ additionalTooltipValues,
3037
+ onEventClick,
3038
+ onLegendClick,
3039
+ onLaneClick,
3040
+ dataColors: timelineDataColors,
3041
+ seriesColors: timelineSeriesColors
3042
+ }, pickedOptions);
3043
+ };
3044
+ function extractAdditionalTooltipValues(columns, fields, additionalTooltipFields) {
3045
+ var _a;
3046
+ const fieldIndexMap = fields.reduce((acc, field, index) => {
3047
+ acc[field.name] = index;
3048
+ return acc;
3049
+ }, {});
3050
+ const additionalTooltipValuesArray = [];
3051
+ const numRows = ((_a = columns[0]) == null ? void 0 : _a.length) || 0;
3052
+ for (let i = 0; i < numRows; i += 1) {
3053
+ const tooltipObject = {};
3054
+ additionalTooltipFields.forEach((field) => {
3055
+ if (field in fieldIndexMap) {
3056
+ const columnIndex = fieldIndexMap[field];
3057
+ tooltipObject[field] = columns[columnIndex][i];
3058
+ } else {
3059
+ tooltipObject[field] = null;
3060
+ }
3061
+ });
3062
+ additionalTooltipValuesArray.push(tooltipObject);
3063
+ }
3064
+ return additionalTooltipValuesArray;
3065
+ }
3066
+ var Timeline = withDashboardViz_default({
3067
+ ReactViz: PureTimeline_default,
3068
+ computeVizProps,
3069
+ vizConfig: config_default
3070
+ });
3071
+ var { themes: themes2 } = config_default;
3072
+ var config2 = config_default;
3073
+ var Timeline_default = Timeline;
3074
+ //# sourceMappingURL=Timeline.js.map