@graphysdk/viz-engine 0.0.1-plugins.9 → 1.8.1-beta.1786024899180

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.
@@ -0,0 +1,966 @@
1
+ import { A as q, L as $, Nt as u, R as J, V as Q, a as T, bt as A, c as Z, i as G, jt as L, m as y, n as ee, nt as re, o as p, r as g, rt as P, t as ie, y as v, z as se } from "./config.types-uM8CYfC1.js";
2
+ var h = "value", F = L("lineSeriesLabel"), M = L("barSeriesLabel"), D = L("constantY"), te = 0.15, ae = (e, r, i, s) => fe[r](e, i, s), B = (e) => {
3
+ const { numeric: r, categorical: i, temporal: s } = e.groupVariableNamesByType();
4
+ return u(s[0]) ? s[0] : u(i[0]) ? i[0] : u(r[0]) ? r[0] : "";
5
+ }, O = (e) => {
6
+ const r = B(e), { numeric: i } = e.groupVariableNamesByType(), s = i.filter((t) => t !== r);
7
+ return s.length <= 1 ? {
8
+ transforms: [],
9
+ mapping: {
10
+ x: r,
11
+ y: s[0] ?? ""
12
+ },
13
+ seriesVariables: s
14
+ } : {
15
+ transforms: [g.reshape({
16
+ keep: [r],
17
+ keyName: "key",
18
+ valueName: h
19
+ })],
20
+ mapping: {
21
+ x: r,
22
+ y: h,
23
+ color: "key"
24
+ },
25
+ seriesVariables: s
26
+ };
27
+ }, I = (e) => {
28
+ const r = e.appearance?.seriesStyles;
29
+ if (!r || e.seriesVariables.length === 0) return {
30
+ mapping: {},
31
+ scales: []
32
+ };
33
+ if (!e.seriesVariables.some((s) => u(r[s]?.lineStyle))) return {
34
+ mapping: {},
35
+ scales: []
36
+ };
37
+ if (e.seriesVariables.length === 1) {
38
+ const s = e.seriesVariables[0];
39
+ if (!s) return {
40
+ mapping: {},
41
+ scales: []
42
+ };
43
+ const t = r[s]?.lineStyle;
44
+ return t ? {
45
+ mapping: { lineType: { value: t } },
46
+ scales: []
47
+ } : {
48
+ mapping: {},
49
+ scales: []
50
+ };
51
+ }
52
+ const i = e.seriesVariables.map((s) => r[s]?.lineStyle ?? "solid");
53
+ return {
54
+ mapping: { lineType: "key" },
55
+ scales: [T.lineType.discrete({
56
+ domain: e.seriesVariables,
57
+ range: i
58
+ })]
59
+ };
60
+ }, ne = (e) => {
61
+ const { categorical: r, temporal: i, numeric: s } = e.groupVariableNamesByType(), t = s[0];
62
+ if (!u(t)) throw new P({
63
+ code: "INVALID_DATA_SHAPE",
64
+ message: "No first numeric variable found",
65
+ suggestion: "Provide at least one numeric column for this chart type."
66
+ });
67
+ const a = s.slice(1);
68
+ return a.length === 0 ? {
69
+ ...K(),
70
+ mapping: {
71
+ x: t,
72
+ y: D,
73
+ label: r[0]
74
+ }
75
+ } : a.length === 1 ? {
76
+ transforms: [],
77
+ scales: [],
78
+ mapping: {
79
+ x: t,
80
+ y: a[0] ?? "",
81
+ label: r[0]
82
+ }
83
+ } : {
84
+ transforms: [g.reshape({
85
+ keep: [
86
+ t,
87
+ ...r,
88
+ ...i
89
+ ],
90
+ keyName: "key",
91
+ valueName: h
92
+ })],
93
+ scales: [],
94
+ mapping: {
95
+ x: t,
96
+ y: h,
97
+ label: r[0],
98
+ color: "key"
99
+ }
100
+ };
101
+ }, K = () => ({
102
+ transforms: [g.constant({
103
+ variableName: D,
104
+ type: "categorical",
105
+ value: ""
106
+ })],
107
+ scales: [T.y.discrete()]
108
+ }), le = (e) => {
109
+ const { categorical: r, temporal: i, numeric: s } = e.groupVariableNamesByType();
110
+ let t, a;
111
+ if (u(r[0]) && u(s[0]))
112
+ t = r[0], a = s[0];
113
+ else if (u(i[0]) && u(s[0]))
114
+ t = i[0], a = s[0];
115
+ else if (u(s[0]) && u(s[1]))
116
+ t = s[0], a = s[1];
117
+ else throw new P({
118
+ code: "INVALID_DATA_SHAPE",
119
+ message: "No label or value variable found",
120
+ suggestion: "Provide a label column and a numeric value column for this chart type."
121
+ });
122
+ return {
123
+ x: "",
124
+ y: a,
125
+ color: t
126
+ };
127
+ }, X = (e, r, i) => {
128
+ const { transforms: s, mapping: t, seriesVariables: a } = O(e.dataset), n = I({
129
+ appearance: i,
130
+ seriesVariables: a
131
+ }), c = a.length <= 1, l = [v.line({ params: {
132
+ interpolate: r?.isSmoothLine ? "catmull-rom" : "linear",
133
+ missingValues: r?.missingValues
134
+ } })], o = [];
135
+ return c && (r?.showFill ?? !0) && o.push(y.geom.line({ fillAlpha: te })), typeof r?.lineThickness == "number" && o.push(y.geom.line({ strokeWidth: r.lineThickness })), r?.showPoints && (l.push(v.point({ interactive: !1 })), typeof r.pointSize == "number" && o.push(y.geom.point({ size: r.pointSize }))), {
136
+ layers: l,
137
+ coords: p.cartesian(),
138
+ mapping: {
139
+ ...t,
140
+ ...n.mapping
141
+ },
142
+ scales: n.scales,
143
+ transforms: s,
144
+ seriesVariables: a,
145
+ styleDefaults: o
146
+ };
147
+ }, oe = (e, r, i) => {
148
+ const { transforms: s, mapping: t, seriesVariables: a } = O(e.dataset), n = I({
149
+ appearance: i,
150
+ seriesVariables: a
151
+ }), c = [v.area({
152
+ position: "stack",
153
+ params: {
154
+ interpolate: r?.isSmoothLine ? "catmull-rom" : "linear",
155
+ missingValues: r?.missingValues
156
+ }
157
+ })], l = [];
158
+ return typeof r?.lineThickness == "number" && l.push(y.geom.area({ strokeWidth: r.lineThickness })), r?.showPoints && (c.push(v.point({
159
+ position: "stack",
160
+ interactive: !1
161
+ })), typeof r.pointSize == "number" && l.push(y.geom.point({ size: r.pointSize }))), {
162
+ layers: c,
163
+ coords: p.cartesian(),
164
+ mapping: {
165
+ ...t,
166
+ ...n.mapping
167
+ },
168
+ scales: n.scales,
169
+ transforms: s,
170
+ seriesVariables: a,
171
+ styleDefaults: l
172
+ };
173
+ }, V = (e, r, i, s, t) => {
174
+ const { transforms: a, mapping: n, seriesVariables: c } = O(e.dataset), l = [...a];
175
+ if (s?.sortBars) {
176
+ const o = A(n.y);
177
+ o !== null && o !== "" && l.push(g.sort({
178
+ variableName: o,
179
+ direction: "desc"
180
+ }));
181
+ }
182
+ if (!t?.useSingleColorForBars) {
183
+ const o = B(e.dataset), { numeric: b } = e.dataset.groupVariableNamesByType();
184
+ b.filter((S) => S !== o).length === 1 && e.dataset.getType(o) === "categorical" && (n.color = o);
185
+ }
186
+ return {
187
+ layers: [v.bar({ position: r })],
188
+ coords: i,
189
+ mapping: n,
190
+ scales: [],
191
+ transforms: l,
192
+ seriesVariables: c
193
+ };
194
+ }, C = (e, r) => ({
195
+ layers: [v.bar({ position: "fill" })],
196
+ coords: p.polar({
197
+ theta: "y",
198
+ innerRadius: r === "donut" ? 0.55 : 0
199
+ }),
200
+ mapping: le(e.dataset),
201
+ scales: [],
202
+ seriesVariables: []
203
+ }), ce = (e) => {
204
+ const { transforms: r, scales: i, mapping: s } = ne(e.dataset);
205
+ return {
206
+ layers: [v.point()],
207
+ coords: p.cartesian(),
208
+ mapping: s,
209
+ scales: i,
210
+ transforms: r,
211
+ seriesVariables: []
212
+ };
213
+ }, ue = (e) => {
214
+ const { numeric: r, categorical: i } = e.dataset.groupVariableNamesByType(), s = r[0];
215
+ if (!u(s)) throw new P({
216
+ code: "INVALID_DATA_SHAPE",
217
+ message: "No first numeric variable found",
218
+ suggestion: "Provide at least one numeric column for this chart type."
219
+ });
220
+ const t = u(r[1]) ? {
221
+ transforms: [],
222
+ scales: []
223
+ } : K(), a = {
224
+ x: s,
225
+ y: r[1] ?? D,
226
+ size: r[2],
227
+ label: i[0]
228
+ }, n = [...t.scales];
229
+ return u(a.size) && n.push(T.size.continuous()), {
230
+ layers: [v.point()],
231
+ coords: p.cartesian(),
232
+ mapping: a,
233
+ scales: n,
234
+ transforms: t.transforms,
235
+ seriesVariables: []
236
+ };
237
+ }, _ = (e, r, i) => {
238
+ const s = i?.seriesStyles?.[e]?.lineStyle;
239
+ return v.line({
240
+ transforms: [g.constant({
241
+ variableName: F,
242
+ type: "categorical",
243
+ value: e
244
+ })],
245
+ aes: {
246
+ y: e,
247
+ color: F,
248
+ ...s ? { lineType: { value: s } } : {}
249
+ },
250
+ ...r ? { yScaleType: "secondary" } : void 0
251
+ });
252
+ }, de = (e, r, i) => {
253
+ const { numeric: s, categorical: t, temporal: a } = e.dataset.groupVariableNamesByType(), n = B(e.dataset), c = [...t, ...a], l = s.filter((m) => m !== n), o = r?.comboType ?? "grouped-bars", b = o === "lines";
254
+ if (l.length === 1) return b ? X(e, r, i) : V(e, "dodge", p.cartesian(), r, i);
255
+ const S = e.axes?.hasDualYAxis === !0, k = b ? [] : l.slice(0, -1), f = b ? l : l.slice(-1), d = [], H = [];
256
+ if (k.length > 0) {
257
+ const m = o === "stacked-bars" ? "stack" : "dodge", N = k.length === 1 ? k[0] : null;
258
+ u(N) ? d.push(v.bar({
259
+ transforms: [g.constant({
260
+ variableName: M,
261
+ type: "categorical",
262
+ value: N
263
+ })],
264
+ aes: {
265
+ y: N,
266
+ color: M
267
+ },
268
+ position: m
269
+ })) : d.push(v.bar({
270
+ transforms: [g.reshape({
271
+ keep: c,
272
+ reshape: k,
273
+ keyName: "key",
274
+ valueName: h
275
+ })],
276
+ aes: {
277
+ y: h,
278
+ color: "key"
279
+ },
280
+ position: m
281
+ }));
282
+ }
283
+ if (b && f.length >= 2) {
284
+ const m = S ? f.slice(0, -1) : f, N = m.length === 1 ? m[0] : null;
285
+ if (u(N)) d.push(_(N, !1, i));
286
+ else {
287
+ const E = I({
288
+ appearance: i,
289
+ seriesVariables: m
290
+ });
291
+ d.push(v.line({
292
+ transforms: [g.reshape({
293
+ keep: c,
294
+ reshape: m,
295
+ keyName: "key",
296
+ valueName: h
297
+ })],
298
+ aes: {
299
+ y: h,
300
+ color: "key",
301
+ ...E.mapping
302
+ }
303
+ })), H.push(...E.scales);
304
+ }
305
+ if (S) {
306
+ const E = f[f.length - 1];
307
+ u(E) && d.push(_(E, !0, i));
308
+ }
309
+ } else for (const m of f) d.push(_(m, S, i));
310
+ return {
311
+ layers: d,
312
+ coords: p.cartesian(),
313
+ mapping: { x: n },
314
+ scales: H,
315
+ seriesVariables: l
316
+ };
317
+ }, w = (e) => () => {
318
+ throw new P({
319
+ code: "UNSUPPORTED_GRAPH_TYPE",
320
+ message: `Unsupported graph type: ${e}`,
321
+ context: { requested: e }
322
+ });
323
+ }, fe = {
324
+ line: (e, r, i) => X(e, r, i),
325
+ areaStacked: (e, r, i) => oe(e, r, i),
326
+ bar: (e, r, i) => V(e, "dodge", p.flip(), r, i),
327
+ barStacked: (e, r, i) => V(e, "stack", p.flip(), r, i),
328
+ barStackedFill: (e, r, i) => V(e, "fill", p.flip(), r, i),
329
+ column: (e, r, i) => V(e, "dodge", p.cartesian(), r, i),
330
+ columnStacked: (e, r, i) => V(e, "stack", p.cartesian(), r, i),
331
+ columnStackedFill: (e, r, i) => V(e, "fill", p.cartesian(), r, i),
332
+ pie: (e) => C(e, "pie"),
333
+ donut: (e) => C(e, "donut"),
334
+ scatter: (e) => ce(e),
335
+ bubble: (e) => ue(e),
336
+ combo: (e, r, i) => de(e, r, i),
337
+ funnel: w("funnel"),
338
+ heatmap: w("heatmap"),
339
+ waterfall: w("waterfall"),
340
+ mekko: w("mekko"),
341
+ table: w("table")
342
+ }, ve = "#%_ENCODED_%#", j = (e) => {
343
+ if (!e.startsWith(ve)) return e;
344
+ try {
345
+ const { value: r } = JSON.parse(e.slice(13));
346
+ return typeof r == "string" ? r : e;
347
+ } catch {
348
+ return e;
349
+ }
350
+ }, pe = ({ annotations: e, dataset: r, mapping: i, seriesVariables: s }) => {
351
+ const t = [], a = [], n = [], c = [], l = [], o = [], b = [], S = [], k = {
352
+ dataset: r,
353
+ ...me(i, s)
354
+ };
355
+ for (const f of e ?? []) switch (f.type) {
356
+ case "difference-arrow": {
357
+ const d = ye(f, k);
358
+ d !== null && t.push(d);
359
+ break;
360
+ }
361
+ case "shape":
362
+ a.push(be(f));
363
+ break;
364
+ case "arrow":
365
+ n.push(Ve(f));
366
+ break;
367
+ case "highlight":
368
+ break;
369
+ case "text":
370
+ c.push(ge(f));
371
+ break;
372
+ case "image":
373
+ l.push(he(f));
374
+ break;
375
+ case "sticker": {
376
+ const d = Se(f, k);
377
+ d !== null && o.push(d);
378
+ break;
379
+ }
380
+ case "tooltip": {
381
+ const d = ke(f, k);
382
+ if (d === null) break;
383
+ d.kind === "pinnedNumber" ? b.push(d.value) : S.push(d.value);
384
+ break;
385
+ }
386
+ default:
387
+ throw new re({ message: `Unsupported annotation type: ${f.type}` });
388
+ }
389
+ return {
390
+ differenceArrows: t,
391
+ shapes: a,
392
+ arrows: n,
393
+ textAnnotations: c,
394
+ images: l,
395
+ stickers: o,
396
+ pinnedNumbers: b,
397
+ comments: S
398
+ };
399
+ }, me = (e, r) => {
400
+ const i = A(e.x), s = A(e.group) ?? A(e.color), t = i !== null && i !== "", a = s === "key" || r.length >= 2;
401
+ return {
402
+ anchorVariable: t ? i : s,
403
+ groupIsSeriesKey: a
404
+ };
405
+ }, ye = (e, r) => {
406
+ const i = x(r, e.start), s = x(r, e.end);
407
+ return i === null || s === null ? null : {
408
+ id: e.id,
409
+ start: i,
410
+ end: s,
411
+ label: e.show,
412
+ color: e.color ?? null,
413
+ size: e.size,
414
+ labelCrossPosition: e.labelPosition
415
+ };
416
+ }, be = (e) => ({
417
+ id: e.id,
418
+ kind: e.shape,
419
+ zOrder: e.layer === "abovePlot" ? "foreground" : "background",
420
+ region: {
421
+ anchorType: "panel",
422
+ x: e.x,
423
+ y: e.y,
424
+ width: e.width,
425
+ height: e.height
426
+ },
427
+ fillColor: e.fillColor,
428
+ fillOpacity: e.fillOpacity,
429
+ strokeWidth: e.strokeWidth,
430
+ strokeColor: e.fillColor
431
+ }), he = (e) => ({
432
+ id: e.id,
433
+ src: e.src,
434
+ zOrder: e.layer === "abovePlot" ? "foreground" : "background",
435
+ region: {
436
+ anchorType: "panel",
437
+ x: e.x,
438
+ y: e.y,
439
+ width: e.width,
440
+ height: e.height
441
+ },
442
+ fit: e.fit,
443
+ opacity: e.opacity
444
+ }), ge = (e) => ({
445
+ id: e.id,
446
+ content: e.content,
447
+ at: {
448
+ anchorType: "panel",
449
+ x: e.x,
450
+ y: e.y
451
+ },
452
+ width: e.width,
453
+ align: "top-left",
454
+ backgroundColor: e.backgroundColor ?? null,
455
+ backgroundColorStyle: e.backgroundColorStyle
456
+ }), Se = (e, r) => {
457
+ const i = x(r, e);
458
+ return i === null ? null : {
459
+ id: e.id,
460
+ at: {
461
+ anchorType: "observation",
462
+ ...i
463
+ },
464
+ sticker: e.sticker
465
+ };
466
+ }, ke = (e, r) => {
467
+ const i = x(r, e);
468
+ return i === null ? null : e.caption === null || e.caption === void 0 ? {
469
+ kind: "pinnedNumber",
470
+ value: {
471
+ id: e.id,
472
+ at: i
473
+ }
474
+ } : {
475
+ kind: "comment",
476
+ value: {
477
+ id: e.id,
478
+ at: i,
479
+ content: e.caption
480
+ }
481
+ };
482
+ }, Ve = (e) => ({
483
+ id: e.id,
484
+ start: {
485
+ anchorType: "panel",
486
+ x: e.startX,
487
+ y: e.startY
488
+ },
489
+ end: {
490
+ anchorType: "panel",
491
+ x: e.endX,
492
+ y: e.endY
493
+ },
494
+ color: e.color ?? null,
495
+ thickness: e.thickness,
496
+ startArrowheadStyle: e.startArrowheadStyle,
497
+ endArrowheadStyle: e.endArrowheadStyle,
498
+ lineStyle: e.lineStyle,
499
+ hasStickerStyle: e.hasStickerStyle
500
+ }), x = (e, r) => {
501
+ if (!u(r)) return null;
502
+ const { dataset: i, anchorVariable: s, groupIsSeriesKey: t } = e;
503
+ if (s === null) return null;
504
+ const a = Te(r, s, i);
505
+ return a === null ? null : t ? u(r.columnKey) ? {
506
+ anchorValue: a,
507
+ groupValue: j(r.columnKey)
508
+ } : null : {
509
+ anchorValue: a,
510
+ groupValue: void 0
511
+ };
512
+ }, Te = (e, r, i) => !u(e.rowIndex) || !i.hasVariable(r) ? null : i.getValues(r)[e.rowIndex] ?? null, Ae = "#E5E5E5", Ne = {
513
+ x: "top",
514
+ y: "left"
515
+ }, Ee = /* @__PURE__ */ new Set(["pie", "donut"]);
516
+ function we(e, r = !1) {
517
+ return ee({
518
+ legend: Re(e.legend),
519
+ axes: Be(e.axes, r),
520
+ headline: Oe(e),
521
+ numberFormat: Ie(e.appearance),
522
+ content: He(e.content),
523
+ appearance: Le(e.appearance, e.themeOverrides)
524
+ }).config;
525
+ }
526
+ function Le(e, r) {
527
+ const i = _e(e?.border), s = e?.hasRoundedCorners === !1 ? 0 : void 0, t = xe(e, r), a = {};
528
+ return e?.textScale !== void 0 && (a.textScale = e.textScale), i !== void 0 && (a.border = i), s !== void 0 && (a.cornerRadius = s), t !== void 0 && (a.background = t), Object.keys(a).length > 0 ? a : void 0;
529
+ }
530
+ function xe(e, r) {
531
+ if (e?.backgroundModifier === "tint") return { type: "tinted" };
532
+ const i = r?.graphBackground;
533
+ if (typeof i == "string") return {
534
+ type: "solid",
535
+ color: i
536
+ };
537
+ }
538
+ var Pe = (e) => ie.includes(e);
539
+ function _e(e) {
540
+ if (!e?.style) return;
541
+ if (e.style === "none") return { type: "none" };
542
+ const r = e.width ?? 0;
543
+ if (e.style === "grey") return {
544
+ type: "solid",
545
+ color: Ae,
546
+ width: r
547
+ };
548
+ if (e.style === "preset")
549
+ return e.color === void 0 || !Pe(e.color) ? void 0 : {
550
+ type: "preset",
551
+ preset: e.color,
552
+ width: r
553
+ };
554
+ if (e.color !== void 0)
555
+ return e.style === "custom" ? {
556
+ type: "solid",
557
+ color: e.color,
558
+ width: r
559
+ } : {
560
+ type: e.style,
561
+ color: e.color,
562
+ width: r
563
+ };
564
+ }
565
+ function Re(e) {
566
+ if (e)
567
+ return { position: e.position };
568
+ }
569
+ function W(e, r, i) {
570
+ return !r && i === void 0 ? {} : {
571
+ ...r?.isHidden !== void 0 ? { isVisible: !r.isHidden } : void 0,
572
+ ...r?.label !== void 0 ? { label: r.label } : void 0,
573
+ ...r?.isReversed ? { position: Ne[e] } : void 0,
574
+ ...r?.tickDisplayMode ? { ticks: { mode: r.tickDisplayMode } } : void 0,
575
+ ...i !== void 0 ? { grid: { isVisible: i } } : void 0
576
+ };
577
+ }
578
+ function De(e) {
579
+ return { ...e.label !== void 0 ? { label: e.label } : void 0 };
580
+ }
581
+ function Be(e, r = !1) {
582
+ if (!e) return;
583
+ const i = W("x", e.x, e.showGridLines), s = W("y", e.y, e.showGridLines);
584
+ return {
585
+ x: r ? s : i,
586
+ y: r ? i : s,
587
+ ...e.y2 ? { ySecondary: De(e.y2) } : void 0
588
+ };
589
+ }
590
+ function Oe(e) {
591
+ const { headlineNumbers: r, options: i, type: s } = e, t = s !== void 0 && Ee.has(s) ? i?.pieTotalPosition : void 0;
592
+ if (r === void 0 && t === void 0) return;
593
+ const a = {};
594
+ return r?.show !== void 0 && (a.show = r.show), r?.compareWith !== void 0 && (a.compareWith = r.compareWith), r?.size !== void 0 && (a.size = r.size), t !== void 0 && (a.show = "total", a.position = t === "center" ? "center" : "above"), a;
595
+ }
596
+ function Ie(e) {
597
+ if (e?.numberFormat)
598
+ return {
599
+ decimals: e.numberFormat.decimalPlaces,
600
+ abbreviation: e.numberFormat.abbreviation
601
+ };
602
+ }
603
+ function He(e) {
604
+ if (!e) return;
605
+ const r = {};
606
+ e.title !== void 0 && (r.title = e.title), e.isTitleHidden !== void 0 && (r.isTitleVisible = !e.isTitleHidden), e.subtitle !== void 0 && (r.subtitle = e.subtitle), e.isSubtitleHidden !== void 0 && (r.isSubtitleVisible = !e.isSubtitleHidden), e.caption !== void 0 && (r.caption = e.caption), e.isCaptionHidden !== void 0 && (r.isCaptionVisible = !e.isCaptionHidden);
607
+ const i = Fe(e.source);
608
+ return i !== void 0 && (r.source = i), e.isSourceHidden !== void 0 && (r.isSourceVisible = !e.isSourceHidden), e.brandMark !== void 0 && (r.brandMark = { ...e.brandMark }, e.brandMark.enabled !== void 0 && (r.isBrandMarkVisible = e.brandMark.enabled)), e.isBrandMarkHidden !== void 0 && e.brandMark?.enabled === void 0 && (r.isBrandMarkVisible = !e.isBrandMarkHidden), r;
609
+ }
610
+ function Fe(e) {
611
+ if (!e) return;
612
+ const r = {};
613
+ return e.label !== void 0 && (r.label = e.label), e.url !== void 0 && (r.url = e.url), Object.keys(r).length === 0 ? void 0 : r;
614
+ }
615
+ var Me = new se(), Ce = [
616
+ "key",
617
+ L("lineSeriesLabel"),
618
+ L("barSeriesLabel")
619
+ ];
620
+ function We(e) {
621
+ const r = e.annotations ?? [], i = Ye(e.mapping), s = Ge(e.dataset, e.transforms, e.layers), t = [];
622
+ for (const a of r) {
623
+ if (a.type !== "highlight") continue;
624
+ const n = Ue({
625
+ annotation: a,
626
+ rowIdentityVariable: i,
627
+ dataset: e.dataset,
628
+ compiledVariableNames: s
629
+ });
630
+ n !== null && t.push({
631
+ type: "highlight",
632
+ id: a.id,
633
+ predicate: n,
634
+ scope: ze(a.highlight, e.mapping)
635
+ });
636
+ }
637
+ return t;
638
+ }
639
+ function ze(e, r) {
640
+ const i = A(r.x);
641
+ return !(i !== null && i !== "") && e === "x-value" ? "series" : e;
642
+ }
643
+ function Ye(e) {
644
+ const r = A(e.x);
645
+ return r !== null && r !== "" ? r : A(e.color);
646
+ }
647
+ function Ue({ annotation: e, rowIdentityVariable: r, dataset: i, compiledVariableNames: s }) {
648
+ switch (e.highlight) {
649
+ case "x-value":
650
+ return z(e, r, i);
651
+ case "series":
652
+ return Y(e, s);
653
+ case "data-point": {
654
+ const t = z(e, r, i), a = Y(e, s);
655
+ return t === null && a === null ? null : t === null ? a : a === null ? t : { and: [t, a] };
656
+ }
657
+ }
658
+ }
659
+ function z(e, r, i) {
660
+ if (r === null) return null;
661
+ const s = Ke(e, r, i);
662
+ return s === null ? null : {
663
+ variable: r,
664
+ eq: s
665
+ };
666
+ }
667
+ function Y(e, r) {
668
+ const i = e.columnKey;
669
+ if (!u(i)) return null;
670
+ const s = Ce.filter((t) => r.includes(t));
671
+ return s.length === 0 ? null : { or: s.map((t) => ({
672
+ variable: t,
673
+ eq: i
674
+ })) };
675
+ }
676
+ function Ge(e, r, i) {
677
+ const s = [...e.getVariableNames()], t = (a) => {
678
+ for (const n of a) {
679
+ const { getIntroducedVariables: c } = Me.get(n.transformType), l = c?.(n);
680
+ l && s.push(...l);
681
+ }
682
+ };
683
+ t(r);
684
+ for (const a of i) t(a.transforms ?? []);
685
+ return s;
686
+ }
687
+ function Ke(e, r, i) {
688
+ return e.rowValue !== void 0 ? e.rowValue : !u(e.rowIndex) || !i.getVariableNames().includes(r) ? null : i.getValues(r)[e.rowIndex] ?? null;
689
+ }
690
+ function Xe(e, r, i) {
691
+ const { colorScheme: s, customPalettes: t } = i;
692
+ if (t && e && t[e]) return {
693
+ type: "custom",
694
+ id: e
695
+ };
696
+ if (e?.startsWith("preset:pastel")) return {
697
+ type: "pastel",
698
+ variant: R(r)
699
+ };
700
+ if (e?.startsWith("preset:graphy")) return {
701
+ type: "graphy",
702
+ variant: R(r)
703
+ };
704
+ if (e?.startsWith("preset:mono:")) {
705
+ const a = e.slice(12);
706
+ if (je(a)) return {
707
+ type: "mono",
708
+ base: a,
709
+ variant: s
710
+ };
711
+ }
712
+ if (e?.startsWith("preset:neon:")) {
713
+ const a = e.slice(12);
714
+ if (qe(a)) return {
715
+ type: "neon",
716
+ base: a,
717
+ variant: R(r)
718
+ };
719
+ }
720
+ return { type: "default" };
721
+ }
722
+ function R(e) {
723
+ if (e === "waterfall") return "waterfall";
724
+ }
725
+ function je(e) {
726
+ return $.includes(e);
727
+ }
728
+ function qe(e) {
729
+ return J.includes(e);
730
+ }
731
+ function $e({ axes: e, palette: r, overrides: i, isFlipped: s }) {
732
+ const t = [];
733
+ return t.push(U("x", s ? e?.y : e?.x)), t.push(U("y", s ? e?.x : e?.y)), t.push(T.color.palette({
734
+ palette: r,
735
+ overrides: i
736
+ })), t;
737
+ }
738
+ function U(e, r) {
739
+ return r?.scaleType === "logarithmic" || r?.min !== void 0 || r?.max !== void 0 ? r.scaleType === "logarithmic" ? T[e].log({
740
+ domainMin: r.min ?? void 0,
741
+ domainMax: r.max ?? void 0
742
+ }) : T[e]({
743
+ domainMin: r.min ?? void 0,
744
+ domainMax: r.max ?? void 0
745
+ }) : T[e]();
746
+ }
747
+ function Je(e) {
748
+ if (!e) return;
749
+ const r = {};
750
+ for (const [i, s] of Object.entries(e)) {
751
+ if (!i.startsWith("series")) continue;
752
+ const t = Number.parseInt(i.slice(6));
753
+ if (Number.isNaN(t)) continue;
754
+ const a = {
755
+ hex: s.customColor,
756
+ id: s.paletteColorId
757
+ };
758
+ (a.hex !== void 0 || a.id !== void 0) && (r[t] = a);
759
+ }
760
+ return Object.keys(r).length > 0 ? r : void 0;
761
+ }
762
+ function Qe({ palette: e, overrides: r, ctx: i }) {
763
+ const s = er(e, r, i);
764
+ if (s !== void 0)
765
+ return {
766
+ type: "styles",
767
+ defaults: [
768
+ y.geom.bar({ color: s }),
769
+ y.geom.line({ color: s }),
770
+ y.geom.area({ color: s }),
771
+ y.geom.point({ color: s })
772
+ ]
773
+ };
774
+ }
775
+ function Ze(e) {
776
+ return e?.highlightStyle === void 0 ? [] : e.highlightStyle === "grey" ? [y.geom({
777
+ saturation: 0,
778
+ alpha: 0.6
779
+ }, { state: "dimmed" })] : [y.geom({ alpha: Z }, { state: "dimmed" })];
780
+ }
781
+ function er(e, r, i) {
782
+ const s = e.type === "custom" ? i.customPalettes?.[e.id] : void 0, t = r?.[1];
783
+ if (t?.hex !== void 0) return t.hex;
784
+ if (t?.id !== void 0) {
785
+ const a = s?.find((n) => n.id === t.id)?.hex;
786
+ if (a !== void 0) return a;
787
+ }
788
+ if (e.type !== "default")
789
+ return e.type === "custom" ? s?.[0]?.hex : q(e)[0];
790
+ }
791
+ var rr = /* @__PURE__ */ new Set([
792
+ "column",
793
+ "columnStacked",
794
+ "columnStackedFill",
795
+ "bar",
796
+ "barStacked",
797
+ "barStackedFill",
798
+ "line",
799
+ "areaStacked",
800
+ "scatter",
801
+ "bubble",
802
+ "funnel",
803
+ "combo"
804
+ ]), ir = /* @__PURE__ */ new Set([
805
+ "column",
806
+ "columnStacked",
807
+ "columnStackedFill",
808
+ "bar",
809
+ "barStacked",
810
+ "barStackedFill",
811
+ "line",
812
+ "areaStacked",
813
+ "combo"
814
+ ]);
815
+ function fr(e, r, i = {}) {
816
+ return sr(Q(r), e, i);
817
+ }
818
+ function sr(e, r, i = {}) {
819
+ const s = r.type ?? "column", t = ae({
820
+ dataset: e,
821
+ axes: r.axes
822
+ }, s, r.options ?? void 0, r.appearance ?? void 0), a = t.coords.coordType === "flip", n = t.transforms ?? [], c = Xe(r.appearance?.paletteId, s, i), l = Je(r.appearance?.seriesStyles);
823
+ return {
824
+ mapping: t.mapping,
825
+ layers: ar(s, r, t.layers, t.coords, t.mapping, t.seriesVariables),
826
+ scales: [...$e({
827
+ axes: r.axes,
828
+ palette: c,
829
+ overrides: l,
830
+ isFlipped: a
831
+ }), ...t.scales],
832
+ styles: tr(Qe({
833
+ palette: c,
834
+ overrides: l,
835
+ ctx: i
836
+ }), [...t.styleDefaults ?? [], ...Ze(r.appearance ?? void 0)]),
837
+ transforms: n,
838
+ highlights: We({
839
+ annotations: r.annotations,
840
+ dataset: e,
841
+ mapping: t.mapping,
842
+ transforms: n,
843
+ layers: t.layers
844
+ }),
845
+ annotations: pe({
846
+ annotations: r.annotations,
847
+ dataset: e,
848
+ mapping: t.mapping,
849
+ seriesVariables: t.seriesVariables
850
+ }),
851
+ coords: t.coords,
852
+ config: we(r, a)
853
+ };
854
+ }
855
+ function tr(e, r) {
856
+ const i = [...e?.defaults ?? [], ...r ?? []];
857
+ if (i.length !== 0)
858
+ return {
859
+ type: "styles",
860
+ defaults: i
861
+ };
862
+ }
863
+ function ar(e, r, i, s, t, a) {
864
+ const n = ur(r.dataLabels), c = n === void 0 ? i : i.filter((o) => o.interactive !== !1).map((o) => ({
865
+ ...o,
866
+ dataLabels: {
867
+ ...n,
868
+ ...o.dataLabels
869
+ }
870
+ })), l = r.axes?.hasDualYAxis ?? !1;
871
+ return [
872
+ ...c,
873
+ ...nr({
874
+ type: e,
875
+ trendline: r.referenceLines?.trendline,
876
+ coords: s
877
+ }),
878
+ ...lr({
879
+ type: e,
880
+ hasDualYAxis: l,
881
+ goalLine: r.referenceLines?.goalLine,
882
+ coords: s
883
+ }),
884
+ ...cr({
885
+ type: e,
886
+ hasDualYAxis: l,
887
+ averageLine: r.referenceLines?.averageLine,
888
+ coords: s,
889
+ mapping: t,
890
+ seriesVariables: a
891
+ })
892
+ ];
893
+ }
894
+ function nr({ type: e, trendline: r, coords: i }) {
895
+ return r === void 0 ? [] : rr.has(e) ? i.coordType === "polar" ? [] : [v.line({
896
+ aes: { lineType: { value: "dashed" } },
897
+ stat: G.smooth({ method: r }),
898
+ interactive: !1
899
+ })] : [];
900
+ }
901
+ function lr({ type: e, hasDualYAxis: r, goalLine: i, coords: s }) {
902
+ if (!or(i)) return [];
903
+ if (s.coordType === "polar") return [];
904
+ const t = s.coordType === "flip" ? "end" : "start";
905
+ return [v.rule({
906
+ aes: { y: { value: i.target } },
907
+ params: {
908
+ labelPosition: t,
909
+ label: i.label ?? "Goal"
910
+ },
911
+ yScaleType: e === "combo" && r ? "secondary" : "primary",
912
+ interactive: !1
913
+ })];
914
+ }
915
+ function or(e) {
916
+ return e !== void 0 && Number.isFinite(e.target);
917
+ }
918
+ function cr({ type: e, hasDualYAxis: r, averageLine: i, coords: s, mapping: t, seriesVariables: a }) {
919
+ if (i === void 0) return [];
920
+ if (!ir.has(e)) return [];
921
+ if (s.coordType === "polar") return [];
922
+ const n = j(i.columnKey);
923
+ if (!a.includes(n)) return [];
924
+ const c = t.color === "key", l = c ? h : n, o = c ? [g.filter({
925
+ variableName: "key",
926
+ operator: "eq",
927
+ value: n
928
+ })] : [];
929
+ return [v.rule({
930
+ aes: {
931
+ y: l,
932
+ color: void 0,
933
+ group: void 0,
934
+ lineType: void 0
935
+ },
936
+ stat: G.mean(),
937
+ transforms: o,
938
+ params: {
939
+ label: "Average",
940
+ labelPosition: s.coordType === "flip" ? "end" : "start"
941
+ },
942
+ yScaleType: e === "combo" && r ? "secondary" : "primary",
943
+ interactive: !1
944
+ })];
945
+ }
946
+ function ur(e) {
947
+ if (!e) return;
948
+ const r = {};
949
+ return e.showDataLabels !== void 0 && (r.showDataLabels = e.showDataLabels), e.dataLabelFormat !== void 0 && (r.format = e.dataLabelFormat), e.showStackTotals !== void 0 && (r.showStackTotals = e.showStackTotals), e.showCategoryLabels !== void 0 && (r.showCategoryLabels = e.showCategoryLabels), Object.keys(r).length === 0 ? void 0 : r;
950
+ }
951
+ var vr = [
952
+ 0.8,
953
+ 1,
954
+ 1.2,
955
+ 1.4,
956
+ 1.6,
957
+ 1.8,
958
+ 2,
959
+ 2.5,
960
+ 3,
961
+ 4
962
+ ];
963
+ export {
964
+ vr as CHART_TEXT_SCALES,
965
+ fr as convertGraphConfig
966
+ };