@astrato-io/visualizations 0.0.0-stage → 0.6.4

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 (145) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/LICENSE +93 -0
  3. package/README.md +843 -2
  4. package/THIRD_PARTY_NOTICES.md +8387 -0
  5. package/VISUALIZATION_DEFINITIONS.md +2378 -0
  6. package/chunks/LinearProgress-CUZ0D8_t.js +253 -0
  7. package/chunks/Radio-Ciu-F4CU.js +957 -0
  8. package/chunks/ToggleButton-BCJc3Jlc.js +153 -0
  9. package/chunks/_baseFlatten-DPXPOrea.js +7076 -0
  10. package/chunks/accessors-DemrDevR.js +128 -0
  11. package/chunks/app-filter-bar.compiler-j_CVoWTa.js +55 -0
  12. package/chunks/bar.compiler-oqaPzIut.js +370 -0
  13. package/chunks/color-settings-ZIvgNTq1.js +10 -0
  14. package/chunks/coloring-C16AUZEi.js +663 -0
  15. package/chunks/data-item-resolution-1lvYB5ln.js +53 -0
  16. package/chunks/debounce-fn-CUixuz45.js +7 -0
  17. package/chunks/escobar-BGqT1EsE.js +34580 -0
  18. package/chunks/event-bus-KiSiCJrC.js +2683 -0
  19. package/chunks/events-WZut5Ow6.js +4 -0
  20. package/chunks/extend-BKUkc4_i.js +37 -0
  21. package/chunks/filter.compiler-CuLtc_02.js +60 -0
  22. package/chunks/filtering-Yq4DEa0t.js +953 -0
  23. package/chunks/gauge-target-type-BkKXAqkX.js +4 -0
  24. package/chunks/grouping-type-BX_9Ix5q.js +3 -0
  25. package/chunks/interfaces-VUY4_yVO.js +8742 -0
  26. package/chunks/line-settings-DfYTUyPz.js +4 -0
  27. package/chunks/line.compiler-BpA_6Tc7.js +188 -0
  28. package/chunks/metadata-CPXdYoln.js +28 -0
  29. package/chunks/number.compiler-DbkWcG4S.js +44 -0
  30. package/chunks/pie-uv42Eqal.js +10 -0
  31. package/chunks/range-DrzdfBX4.js +22 -0
  32. package/chunks/registry-CExpGJ1N.js +920 -0
  33. package/chunks/requirements-DNhuShLS.js +6 -0
  34. package/chunks/rolldown-runtime-DleVn1XH.js +28 -0
  35. package/chunks/set-coloring-datafield-B3uIS1Pe.js +8 -0
  36. package/chunks/shared-CKDL4hx9.js +1171 -0
  37. package/chunks/src-BC7cGcJ-.js +2024 -0
  38. package/chunks/src-BOS6SqkZ.js +67 -0
  39. package/chunks/src-C0LgoUWY.js +26105 -0
  40. package/chunks/src-Cum_2NLV.js +12145 -0
  41. package/chunks/src-D9XogOrc.js +422 -0
  42. package/chunks/src-Dun_jXtz.js +10295 -0
  43. package/chunks/src-DvX5LU9T.js +14742 -0
  44. package/chunks/standalone-87YV_m9n.js +687 -0
  45. package/chunks/standalone-BDCwI6Hn.js +4619 -0
  46. package/chunks/standalone-BH5NqDwp.js +1763 -0
  47. package/chunks/standalone-BLVAWLNJ.js +385 -0
  48. package/chunks/standalone-BPomtAVs.js +2 -0
  49. package/chunks/standalone-BXyBcUOQ.js +2 -0
  50. package/chunks/standalone-BYm1UjLr.js +140 -0
  51. package/chunks/standalone-BllF4rDp.js +383 -0
  52. package/chunks/standalone-BmfMt74U.js +726 -0
  53. package/chunks/standalone-BqWyrnZI.js +281 -0
  54. package/chunks/standalone-C85u7U6I.js +340 -0
  55. package/chunks/standalone-CCNtaJ7s.js +741 -0
  56. package/chunks/standalone-CDQnr6qT.js +345 -0
  57. package/chunks/standalone-CNyNHKVx.js +674 -0
  58. package/chunks/standalone-CY57qwZ-.js +1129 -0
  59. package/chunks/standalone-CZynjFG7.js +12979 -0
  60. package/chunks/standalone-D5vnf-9y.js +3943 -0
  61. package/chunks/standalone-DFPva_ku.js +299 -0
  62. package/chunks/standalone-DQxxNwF8.js +675 -0
  63. package/chunks/standalone-DS9T0FZ-.js +830 -0
  64. package/chunks/standalone-Dx3MLlrO.js +512 -0
  65. package/chunks/standalone-DzixzZAL.js +411 -0
  66. package/chunks/standalone-QJ1kKMnO.js +6 -0
  67. package/chunks/standalone-jiz0L2Dg.js +3855 -0
  68. package/chunks/standalone-lBm9hQ-q.js +179 -0
  69. package/chunks/standalone-rJ45Zfl1.js +68 -0
  70. package/chunks/stroke-dash-UgMEcCS4.js +6 -0
  71. package/chunks/table.compiler-BrXkm4Fz.js +213 -0
  72. package/chunks/toInteger-DVZr-D1j.js +11 -0
  73. package/chunks/treemap-x_zmJoG7.js +23 -0
  74. package/chunks/typeof-CJDtcySz.js +13 -0
  75. package/chunks/types-dVVCsDWD.js +4 -0
  76. package/chunks/ui-D1HQNIBy.js +54039 -0
  77. package/chunks/url-utils-B17gj_mr.js +5501 -0
  78. package/chunks/useFieldName-oqQ3bvnO.js +7 -0
  79. package/chunks/utils-Ba9T0TqC.js +31097 -0
  80. package/chunks/view-CLqWMV7Z.js +156 -0
  81. package/definitions.js +3 -0
  82. package/docs/operations/astrato-app-filter-bar.md +161 -0
  83. package/docs/operations/bar.md +7050 -0
  84. package/docs/operations/combo.md +5825 -0
  85. package/docs/operations/date-picker.md +644 -0
  86. package/docs/operations/distribution-gauge.md +3218 -0
  87. package/docs/operations/dot.md +5662 -0
  88. package/docs/operations/filter.md +1507 -0
  89. package/docs/operations/gauge.md +3452 -0
  90. package/docs/operations/heatMap.md +6026 -0
  91. package/docs/operations/histogram.md +1870 -0
  92. package/docs/operations/iframe.md +56 -0
  93. package/docs/operations/image.md +177 -0
  94. package/docs/operations/index.md +46 -0
  95. package/docs/operations/line.md +6468 -0
  96. package/docs/operations/number.md +3969 -0
  97. package/docs/operations/pie.md +6089 -0
  98. package/docs/operations/radar.md +4646 -0
  99. package/docs/operations/sankey.md +3210 -0
  100. package/docs/operations/scatter.md +6075 -0
  101. package/docs/operations/shape.md +315 -0
  102. package/docs/operations/simpleTextObject.md +706 -0
  103. package/docs/operations/slider.md +230 -0
  104. package/docs/operations/table.md +8790 -0
  105. package/docs/operations/tree.md +2874 -0
  106. package/docs/operations/treemap.md +3619 -0
  107. package/docs/operations/waterfall.md +2938 -0
  108. package/docs/operations/word-cloud.md +3071 -0
  109. package/getters.js +18 -0
  110. package/index.js +1183 -0
  111. package/metadata.js +20 -0
  112. package/operations.js +64 -0
  113. package/package.json +191 -4
  114. package/src/definitions/index.d.ts +2 -0
  115. package/src/definitions/shared/index.d.ts +5 -0
  116. package/src/definitions/shared/lib/available-fields.d.ts +36 -0
  117. package/src/definitions/shared/lib/compilers/index.d.ts +7 -0
  118. package/src/definitions/shared/lib/registry/compile.d.ts +2 -0
  119. package/src/definitions/shared/lib/registry/descriptor-registry.d.ts +587 -0
  120. package/src/definitions/shared/lib/registry/index.d.ts +3 -0
  121. package/src/definitions/shared/lib/registry/validation.d.ts +3 -0
  122. package/src/definitions/shared/lib/schemas/app-filter-bar.schema.d.ts +22 -0
  123. package/src/definitions/shared/lib/schemas/bar.schema.d.ts +73 -0
  124. package/src/definitions/shared/lib/schemas/broad-chart.schema.d.ts +68 -0
  125. package/src/definitions/shared/lib/schemas/common.schema.d.ts +304 -0
  126. package/src/definitions/shared/lib/schemas/filter.schema.d.ts +22 -0
  127. package/src/definitions/shared/lib/schemas/index.d.ts +9 -0
  128. package/src/definitions/shared/lib/schemas/line.schema.d.ts +72 -0
  129. package/src/definitions/shared/lib/schemas/number.schema.d.ts +21 -0
  130. package/src/definitions/shared/lib/schemas/object.schema.d.ts +215 -0
  131. package/src/definitions/shared/lib/schemas/table.schema.d.ts +458 -0
  132. package/src/definitions/shared/lib/types/compilation.types.d.ts +36 -0
  133. package/src/definitions/shared/lib/types/definition.types.d.ts +2 -0
  134. package/src/definitions/shared/lib/types/descriptor.types.d.ts +39 -0
  135. package/src/definitions/shared/lib/types/index.d.ts +3 -0
  136. package/src/getters/index.d.ts +30 -0
  137. package/src/index.d.ts +4 -0
  138. package/src/metadata/index.d.ts +4 -0
  139. package/src/operations/index.d.ts +30 -0
  140. package/src/registry/index.d.ts +6 -0
  141. package/src/runtime/index.d.ts +2 -0
  142. package/src/types.d.ts +307 -0
  143. package/src/visualization-catalog.d.ts +82 -0
  144. package/src/web-components/index.d.ts +12 -0
  145. package/styles.css +2 -0
@@ -0,0 +1,128 @@
1
+ function e(e) {
2
+ var t = 0, n = e.children, r = n && n.length;
3
+ if (!r) t = 1;
4
+ else for (; --r >= 0;) t += n[r].value;
5
+ e.value = t;
6
+ }
7
+ function t() {
8
+ return this.eachAfter(e);
9
+ }
10
+ function n(e, t) {
11
+ let n = -1;
12
+ for (let r of this) e.call(t, r, ++n, this);
13
+ return this;
14
+ }
15
+ function r(e, t) {
16
+ for (var n = this, r = [n], i, a, o = -1; n = r.pop();) if (e.call(t, n, ++o, this), i = n.children) for (a = i.length - 1; a >= 0; --a) r.push(i[a]);
17
+ return this;
18
+ }
19
+ function i(e, t) {
20
+ for (var n = this, r = [n], i = [], a, o, s, c = -1; n = r.pop();) if (i.push(n), a = n.children) for (o = 0, s = a.length; o < s; ++o) r.push(a[o]);
21
+ for (; n = i.pop();) e.call(t, n, ++c, this);
22
+ return this;
23
+ }
24
+ function a(e, t) {
25
+ let n = -1;
26
+ for (let r of this) if (e.call(t, r, ++n, this)) return r;
27
+ }
28
+ function o(e) {
29
+ return this.eachAfter(function(t) {
30
+ for (var n = +e(t.data) || 0, r = t.children, i = r && r.length; --i >= 0;) n += r[i].value;
31
+ t.value = n;
32
+ });
33
+ }
34
+ function s(e) {
35
+ return this.eachBefore(function(t) {
36
+ t.children && t.children.sort(e);
37
+ });
38
+ }
39
+ function c(e) {
40
+ for (var t = this, n = l(t, e), r = [t]; t !== n;) t = t.parent, r.push(t);
41
+ for (var i = r.length; e !== n;) r.splice(i, 0, e), e = e.parent;
42
+ return r;
43
+ }
44
+ function l(e, t) {
45
+ if (e === t) return e;
46
+ var n = e.ancestors(), r = t.ancestors(), i = null;
47
+ for (e = n.pop(), t = r.pop(); e === t;) i = e, e = n.pop(), t = r.pop();
48
+ return i;
49
+ }
50
+ function u() {
51
+ for (var e = this, t = [e]; e = e.parent;) t.push(e);
52
+ return t;
53
+ }
54
+ function d() {
55
+ return Array.from(this);
56
+ }
57
+ function f() {
58
+ var e = [];
59
+ return this.eachBefore(function(t) {
60
+ t.children || e.push(t);
61
+ }), e;
62
+ }
63
+ function p() {
64
+ var e = this, t = [];
65
+ return e.each(function(n) {
66
+ n !== e && t.push({
67
+ source: n.parent,
68
+ target: n
69
+ });
70
+ }), t;
71
+ }
72
+ function* m() {
73
+ var e = this, t, n = [e], r, i, a;
74
+ do
75
+ for (t = n.reverse(), n = []; e = t.pop();) if (yield e, r = e.children) for (i = 0, a = r.length; i < a; ++i) n.push(r[i]);
76
+ while (n.length);
77
+ }
78
+ function h(e, t) {
79
+ e instanceof Map ? (e = [void 0, e], t === void 0 && (t = v)) : t === void 0 && (t = _);
80
+ for (var n = new x(e), r, i = [n], a, o, s, c; r = i.pop();) if ((o = t(r.data)) && (c = (o = Array.from(o)).length)) for (r.children = o, s = c - 1; s >= 0; --s) i.push(a = o[s] = new x(o[s])), a.parent = r, a.depth = r.depth + 1;
81
+ return n.eachBefore(b);
82
+ }
83
+ function g() {
84
+ return h(this).eachBefore(y);
85
+ }
86
+ function _(e) {
87
+ return e.children;
88
+ }
89
+ function v(e) {
90
+ return Array.isArray(e) ? e[1] : null;
91
+ }
92
+ function y(e) {
93
+ e.data.value !== void 0 && (e.value = e.data.value), e.data = e.data.data;
94
+ }
95
+ function b(e) {
96
+ var t = 0;
97
+ do
98
+ e.height = t;
99
+ while ((e = e.parent) && e.height < ++t);
100
+ }
101
+ function x(e) {
102
+ this.data = e, this.depth = this.height = 0, this.parent = null;
103
+ }
104
+ x.prototype = h.prototype = {
105
+ constructor: x,
106
+ count: t,
107
+ each: n,
108
+ eachAfter: i,
109
+ eachBefore: r,
110
+ find: a,
111
+ sum: o,
112
+ sort: s,
113
+ path: c,
114
+ ancestors: u,
115
+ descendants: d,
116
+ leaves: f,
117
+ links: p,
118
+ copy: g,
119
+ [Symbol.iterator]: m
120
+ };
121
+ function S(e) {
122
+ return e == null ? null : C(e);
123
+ }
124
+ function C(e) {
125
+ if (typeof e != "function") throw Error();
126
+ return e;
127
+ }
128
+ export { h as a, b as i, C as n, x as r, S as t };
@@ -0,0 +1,55 @@
1
+ import { Xd as e } from "./src-Dun_jXtz.js";
2
+ import { m as t } from "./src-C0LgoUWY.js";
3
+ import { B as n, d as r, g as i, h as a, u as o, v as s, w as c } from "./shared-CKDL4hx9.js";
4
+ var l = async (l) => {
5
+ let u = n.safeParse(l.definition);
6
+ if (!u.success) return {
7
+ issues: c(u.error, l.definition),
8
+ success: !1
9
+ };
10
+ let d = e.safeParse(l.baseVSpec);
11
+ if (!d.success) return {
12
+ issues: [r("invalid_structure", ["baseVSpec"], "Base app filter bar vSpec is invalid.")],
13
+ success: !1
14
+ };
15
+ let f = d.data;
16
+ if (!s(f, [])) return {
17
+ issues: [r("non_fresh_base_vspec", ["baseVSpec"], "App filter bar definitions require a fresh base vSpec.")],
18
+ success: !1
19
+ };
20
+ let p = u.data.settings ?? {}, m = [
21
+ ...p.orientation === void 0 ? [] : [{
22
+ name: t.SET_ORIENTATION,
23
+ payload: p.orientation
24
+ }],
25
+ ...p.selectionMode === void 0 ? [] : [{
26
+ name: t.SET_SELECTION_MODE,
27
+ payload: p.selectionMode
28
+ }],
29
+ ...p.enableAddingNewFilters === void 0 ? [] : [{
30
+ name: t.SET_ADDING_FILTERS_ENABLED,
31
+ payload: p.enableAddingNewFilters
32
+ }],
33
+ ...p.enableAssociativeFilter === void 0 ? [] : [{
34
+ name: t.SET_ASSOCIATIVE_FILTER_ENABLED,
35
+ payload: p.enableAssociativeFilter
36
+ }],
37
+ ...p.showClearAll === void 0 ? [] : [{
38
+ name: t.SET_CLEAR_ALL_ENABLED,
39
+ payload: p.showClearAll
40
+ }],
41
+ ...p.showChartBreakdown === void 0 ? [] : [{
42
+ name: t.SET_CHART_BREAKDOWN_ENABLED,
43
+ payload: p.showChartBreakdown
44
+ }],
45
+ ...p.selectableFieldKeys === void 0 ? [] : [{
46
+ name: t.SET_SELECTABLE_FIELD_KEYS,
47
+ payload: p.selectableFieldKeys
48
+ }]
49
+ ], h = await a(o(l, f), m, ["settings"]);
50
+ return "issue" in h ? {
51
+ issues: [h.issue],
52
+ success: !1
53
+ } : i(h.state, e);
54
+ };
55
+ export { l as compileAppFilterBarVisualizationDefinition };
@@ -0,0 +1,370 @@
1
+ import { Eo as e } from "./interfaces-VUY4_yVO.js";
2
+ import { Id as t } from "./src-Dun_jXtz.js";
3
+ import { _ as n, b as r, t as i, u as a, v as o, w as s } from "./src-C0LgoUWY.js";
4
+ import { S as c, _ as l, b as u, c as d, f, h as p, k as m, l as h, m as g, n as _, nt as v, w as y } from "./shared-CKDL4hx9.js";
5
+ import { a as b, i as x, n as S, t as C } from "./data-item-resolution-1lvYB5ln.js";
6
+ var w = {
7
+ formatString: "setDimensionFormatString",
8
+ formatType: "setDimensionFormatType"
9
+ }, T = {
10
+ currency: "setMeasureCurrency",
11
+ currencyIsPrefix: "setMeasureCurrencyIsPrefix",
12
+ formatString: "setMeasureFormatString",
13
+ formatType: "setMeasureFormatType",
14
+ negativeType: "setMeasureNegativeType"
15
+ }, E = (e, t, n, r = {}) => ({
16
+ code: e,
17
+ message: n,
18
+ path: t,
19
+ ...r
20
+ }), D = (e) => {
21
+ let t = [...e.data.dimensions.map((e, t) => ({
22
+ item: e,
23
+ path: [
24
+ "data",
25
+ "dimensions",
26
+ t,
27
+ "ref"
28
+ ]
29
+ })), ...e.data.measures.map((e, t) => ({
30
+ item: e,
31
+ path: [
32
+ "data",
33
+ "measures",
34
+ t,
35
+ "ref"
36
+ ]
37
+ }))], n = t.map(({ item: e }) => e.ref), r = new Set(n), i = /* @__PURE__ */ new Set(), a = [];
38
+ t.forEach(({ item: e, path: t }) => {
39
+ i.has(e.ref) && a.push(E("duplicate_alias", t, `Reference "${e.ref}" is duplicated.`)), i.add(e.ref);
40
+ }), e.sorting?.forEach((e, t) => {
41
+ r.has(e.by) || a.push(E("unknown_alias", [
42
+ "sorting",
43
+ t,
44
+ "by"
45
+ ], `Reference "${e.by}" does not exist.`, { allowedValues: n }));
46
+ }), a.push(...c(e.presentation?.coloring, e.data.dimensions.map((e) => e.ref), e.data.measures.map((e) => e.ref)));
47
+ let o = e.limiting?.topN?.by;
48
+ return o && !e.data.measures.some((e) => e.ref === o) && a.push(E("unknown_alias", [
49
+ "limiting",
50
+ "topN",
51
+ "by"
52
+ ], `Measure reference "${o}" does not exist.`, { allowedValues: e.data.measures.map((e) => e.ref) })), a;
53
+ }, O = (e) => {
54
+ if (e.type !== "bar") return E("unsupported_visualization", ["baseVSpec", "type"], `Definition type "bar" cannot compile against base vSpec type "${e.type}".`);
55
+ let t = e;
56
+ return t.dimensions.length > 0 || t.measures.length > 0 || (t.supportingMeasures?.length ?? 0) > 0 || Object.keys(t.referencedData).length > 0 ? E("non_fresh_base_vspec", ["baseVSpec"], "Bar visualization definitions can only compile against a fresh base vSpec.") : void 0;
57
+ }, k = (e) => {
58
+ let t = Object.entries(e).find(([, e]) => e.success === !1);
59
+ return t ? {
60
+ id: t[0],
61
+ result: t[1]
62
+ } : void 0;
63
+ }, A = (e, t) => {
64
+ if (!e || typeof e.data != "object" || e.data === null || !("dataItem" in e.data)) return;
65
+ let n = e.data.dataItem;
66
+ if (!(typeof n != "object" || !n || !("internalKey" in n) || typeof n.internalKey != "string" || !("uniqueSignature" in n) || typeof n.uniqueSignature != "string")) return {
67
+ dataItemInternalKey: n.internalKey,
68
+ dataItemUniqueSignature: n.uniqueSignature,
69
+ kind: t
70
+ };
71
+ }, j = async (e, t) => {
72
+ let n = e;
73
+ for (let [e, r] of t.data.dimensions.entries()) {
74
+ let t = `dimension:${r.ref}`, o = await i(n.vSpec, n.availableFields, [{
75
+ id: t,
76
+ name: a.ADD_DIMENSION,
77
+ payload: { key: r.fieldKey }
78
+ }], n.input.variables ?? [], [], n.input.theme), s = k(o.results), c = A(o.results[t], "dimension");
79
+ if (s || !c) return {
80
+ issue: E("operation_failed", [
81
+ "data",
82
+ "dimensions",
83
+ e
84
+ ], s?.result.error ?? "Dimension operation did not return the created data-item identity."),
85
+ success: !1
86
+ };
87
+ n = {
88
+ ...n,
89
+ resolvedRefs: {
90
+ ...n.resolvedRefs,
91
+ [r.ref]: c
92
+ },
93
+ vSpec: o.vSpec
94
+ };
95
+ }
96
+ for (let [r, o] of t.data.measures.entries()) {
97
+ let t = S(o, e.input.availableFields), s = `measure:${o.ref}`, c = await i(n.vSpec, n.availableFields, [{
98
+ id: s,
99
+ name: a.ADD_MEASURE,
100
+ payload: C(o, e.input.availableFields)
101
+ }], n.input.variables ?? [], [], n.input.theme), l = k(c.results), u = A(c.results[s], "measure");
102
+ if (l || !u) return {
103
+ issue: E("operation_failed", [
104
+ "data",
105
+ "measures",
106
+ r
107
+ ], l?.result.error ?? "Measure operation did not return the created data-item identity."),
108
+ success: !1
109
+ };
110
+ n = {
111
+ ...n,
112
+ measureAggregations: {
113
+ ...n.measureAggregations,
114
+ [o.ref]: t
115
+ },
116
+ resolvedRefs: {
117
+ ...n.resolvedRefs,
118
+ [o.ref]: u
119
+ },
120
+ vSpec: c.vSpec
121
+ };
122
+ }
123
+ return {
124
+ state: n,
125
+ success: !0
126
+ };
127
+ }, M = (e) => ({
128
+ dataItemInternalKey: e.dataItemInternalKey,
129
+ dataItemUniqueSignature: e.dataItemUniqueSignature
130
+ }), N = async (e, t) => {
131
+ let r = [];
132
+ return t.data.dimensions.forEach((t, n) => {
133
+ let i = e.resolvedRefs[t.ref];
134
+ t.showNullValues !== void 0 && r.push({
135
+ name: a.UPDATE_DIMENSION,
136
+ payload: {
137
+ ...M(i),
138
+ changes: { showNullValues: t.showNullValues }
139
+ }
140
+ }), t.temporalGrouping && r.push(g("setDimensionTemporalGrouping", i, t.ref, [
141
+ "data",
142
+ "dimensions",
143
+ n
144
+ ], t.temporalGrouping)), t.format?.formatType !== void 0 && r.push(h(w.formatType, i, t.ref, [
145
+ "data",
146
+ "dimensions",
147
+ n
148
+ ], "formatType", t.format.formatType)), t.format?.formatString !== void 0 && r.push(h(w.formatString, i, t.ref, [
149
+ "data",
150
+ "dimensions",
151
+ n
152
+ ], "formatString", t.format.formatString));
153
+ }), t.data.measures.forEach((t, i) => {
154
+ let a = e.resolvedRefs[t.ref];
155
+ [
156
+ "formatType",
157
+ "formatString",
158
+ "currency",
159
+ "currencyIsPrefix",
160
+ "negativeType"
161
+ ].forEach((e) => {
162
+ let n = t.format?.[e];
163
+ n !== void 0 && r.push(h(T[e], a, t.ref, [
164
+ "data",
165
+ "measures",
166
+ i
167
+ ], e, n));
168
+ }), t.dataLabels && r.push({
169
+ name: s.SET_MEASURE_DATA_LABELS_SHOW,
170
+ payload: {
171
+ ...M(a),
172
+ show: t.dataLabels.visible
173
+ }
174
+ }), t.dataLabels?.placements && r.push({
175
+ name: s.SET_MEASURE_DATA_LABEL_BAR_PLACEMENTS,
176
+ payload: {
177
+ ...M(a),
178
+ placements: t.dataLabels.placements.map((e) => ({ position: e }))
179
+ }
180
+ }), t.axis && r.push({
181
+ name: n.CHANGE_MEASURE_AXIS,
182
+ payload: {
183
+ ...M(a),
184
+ secondaryAxis: t.axis === "secondary"
185
+ }
186
+ });
187
+ }), p(e, r, ["data"]);
188
+ }, P = (e, t) => p(e, t.filterGroup ? [{
189
+ id: "filterGroup",
190
+ name: "setStaticFilterGroup",
191
+ payload: u(t.filterGroup)
192
+ }] : [], ["filterGroup"]), F = async (t, n) => {
193
+ if (!n.sorting?.length) return {
194
+ state: t,
195
+ success: !0
196
+ };
197
+ let r = t.vSpec, i = new Map(n.sorting.map((e) => [e.by, e])), o = new Map(Object.entries(t.resolvedRefs).map(([e, t]) => [`${t.dataItemInternalKey}:${t.dataItemUniqueSignature}`, e])), s = r.querySettings?.sortingOrder ?? [], c = n.sorting.map((e) => t.resolvedRefs[e.by]), l = new Set(c.map((e) => `${e.dataItemInternalKey}:${e.dataItemUniqueSignature}`)), u = [...c, ...s.filter((e) => !l.has(`${e.dataItem.internalKey}:${e.dataItem.uniqueSignature}`)).map((e) => ({
198
+ dataItemInternalKey: e.dataItem.internalKey,
199
+ dataItemUniqueSignature: e.dataItem.uniqueSignature,
200
+ kind: e.fieldType === "dimension" ? "dimension" : "measure"
201
+ }))].map((t, n) => {
202
+ let r = o.get(`${t.dataItemInternalKey}:${t.dataItemUniqueSignature}`), a = s.find((e) => e.dataItem.internalKey === t.dataItemInternalKey && e.dataItem.uniqueSignature === t.dataItemUniqueSignature);
203
+ return {
204
+ ...M(t),
205
+ newIndex: n,
206
+ sortDirection: (r ? i.get(r)?.direction : void 0) ?? a?.sortDirection ?? e.Asc
207
+ };
208
+ }), d = await p(t, [{
209
+ name: a.CHANGE_SORT_ORDER_AND_DIRECTION,
210
+ payload: { changeRequests: u }
211
+ }], ["sorting"]);
212
+ if (!d.success) return d;
213
+ let f = n.sorting.map((e) => ({
214
+ name: a.TOGGLE_SORTING_ITEM,
215
+ payload: {
216
+ ...M(t.resolvedRefs[e.by]),
217
+ enabled: e.enabled ?? !0
218
+ }
219
+ }));
220
+ return d = await p(d.state, f, ["sorting"]), d;
221
+ }, I = (e, t) => {
222
+ let n = [], { limiting: r } = t;
223
+ if (r?.queryLimit !== void 0 && n.push({
224
+ name: a.SET_QUERY_LIMIT,
225
+ payload: r.queryLimit
226
+ }), r?.topN) {
227
+ let t = e.resolvedRefs[r.topN.by];
228
+ n.push({
229
+ name: a.ENABLE_TOP_N,
230
+ payload: !0
231
+ }, {
232
+ name: a.SET_TOP_N_NUMBER_OF_VALUES,
233
+ payload: r.topN.count
234
+ }, {
235
+ name: a.SET_TOP_N_SORT_ORDER,
236
+ payload: r.topN.direction
237
+ }, {
238
+ name: a.SET_TOP_N_SHOW_OTHERS,
239
+ payload: r.topN.showOthers ?? !1
240
+ }, {
241
+ name: a.SET_TOP_N_RANK_MEASURE,
242
+ payload: {
243
+ ...M(t),
244
+ ...e.measureAggregations[r.topN.by] ? { aggregation: e.measureAggregations[r.topN.by] } : {}
245
+ }
246
+ });
247
+ }
248
+ return p(e, n, ["limiting"]);
249
+ }, L = (e, t) => {
250
+ let n = [], { presentation: i } = t, s = l(i?.axes);
251
+ if (s) return Promise.resolve({
252
+ issue: s,
253
+ success: !1
254
+ });
255
+ i?.orientation !== void 0 && n.push({
256
+ name: a.SET_BAR_CHART_ORIENTATION,
257
+ payload: i.orientation
258
+ });
259
+ let c = i?.legend;
260
+ c && n.push(...f(e.vSpec, c)), Object.entries(i?.axes ?? {}).forEach(([e, t]) => {
261
+ t.titleVisible !== void 0 && n.push({
262
+ name: a.SET_SHOW_AXIS_TITLE,
263
+ payload: {
264
+ axisName: e,
265
+ showAxisName: t.titleVisible
266
+ }
267
+ }), t.title !== void 0 && n.push({
268
+ name: a.SET_AXIS_TITLE,
269
+ payload: {
270
+ axisName: e,
271
+ axisTitle: t.title
272
+ }
273
+ }), t.labelsVisible !== void 0 && n.push({
274
+ name: a.SET_SHOW_AXIS_LABELS,
275
+ payload: {
276
+ axisName: e,
277
+ showLabels: t.labelsVisible
278
+ }
279
+ }), t.ticksVisible !== void 0 && n.push({
280
+ name: a.SET_SHOW_AXIS_TICKS,
281
+ payload: {
282
+ axisName: e,
283
+ showAxisTicks: t.ticksVisible
284
+ }
285
+ }), t.lineVisible !== void 0 && n.push({
286
+ name: a.SET_SHOW_AXIS_LINE,
287
+ payload: {
288
+ axisName: e,
289
+ showAxisLine: t.lineVisible
290
+ }
291
+ }), n.push(...d(e, t)), "scale" in t && t.scale !== void 0 && n.push({
292
+ name: o.SET_AXIS_SCALE,
293
+ payload: {
294
+ axisName: e,
295
+ scale: t.scale
296
+ }
297
+ });
298
+ });
299
+ let u = i?.axes?.primaryMeasure?.bands;
300
+ return u && n.push({
301
+ name: r.SET_MEASURE_AXIS_BANDS,
302
+ payload: { bands: u }
303
+ }), p(e, n, ["presentation"]);
304
+ }, R = async (e) => {
305
+ let n = v.safeParse(e.definition);
306
+ if (!n.success) return {
307
+ issues: y(n.error, e.definition),
308
+ success: !1
309
+ };
310
+ let r = t.safeParse(e.baseVSpec);
311
+ if (!r.success) return {
312
+ issues: [E("invalid_structure", ["baseVSpec"], "Base bar vSpec is invalid.", { details: { issues: r.error.issues } })],
313
+ success: !1
314
+ };
315
+ let i = r.data, a = O(i);
316
+ if (a) return {
317
+ issues: [a],
318
+ success: !1
319
+ };
320
+ let o = n.data.data.measures.find((e) => e.ref === n.data.limiting?.topN?.by), s = (o ? e.availableFields.find((e) => e.fieldKey === o.fieldKey) : void 0)?.kind === "measure" ? [E("unsupported_feature", [
321
+ "limiting",
322
+ "topN",
323
+ "by"
324
+ ], "Top N ranking by a predefined measure is not supported by the current query builder. Use a raw field or calculation.")] : [], c = [
325
+ ...D(n.data),
326
+ ...x(n.data.data.dimensions, e.availableFields, ["data", "dimensions"], "dimension"),
327
+ ...x(n.data.data.measures, e.availableFields, ["data", "measures"], "measure"),
328
+ ...b(n.data.filterGroup, e.availableFields),
329
+ ...s
330
+ ];
331
+ if (c.length > 0) return {
332
+ issues: c,
333
+ success: !1
334
+ };
335
+ let l = await j({
336
+ availableFields: m(e.availableFields),
337
+ input: e,
338
+ measureAggregations: {},
339
+ resolvedRefs: {},
340
+ vSpec: i
341
+ }, n.data), u = [
342
+ N,
343
+ P,
344
+ F,
345
+ I,
346
+ L,
347
+ (e, t) => _(e, t.presentation?.coloring)
348
+ ];
349
+ for (let e of u) {
350
+ if ("issue" in l) return {
351
+ issues: [l.issue],
352
+ success: !1
353
+ };
354
+ l = await e(l.state, n.data);
355
+ }
356
+ if ("issue" in l) return {
357
+ issues: [l.issue],
358
+ success: !1
359
+ };
360
+ let d = t.safeParse(l.state.vSpec);
361
+ return d.success ? {
362
+ resolvedRefs: l.state.resolvedRefs,
363
+ success: !0,
364
+ vSpec: d.data
365
+ } : {
366
+ issues: [E("invalid_compiled_vspec", [], "Compiled bar vSpec failed final validation.", { details: { issues: d.error.issues } })],
367
+ success: !1
368
+ };
369
+ };
370
+ export { R as compileBarVisualizationDefinition };
@@ -0,0 +1,10 @@
1
+ var e = /* @__PURE__ */ function(e) {
2
+ return e.Equals = "equals", e.InList = "inList", e.NotInList = "notInList", e.Greater = "greater", e.Less = "less", e.GreaterEquals = "greater-equals", e.LessEquals = "less-equals", e.Between = "between", e.NotEquals = "not-equals", e;
3
+ }({}), t = /* @__PURE__ */ function(e) {
4
+ return e.Custom = "custom", e.Gradient = "gradient", e;
5
+ }({}), n = /* @__PURE__ */ function(e) {
6
+ return e.ASC = "alpha-asc", e.DATA = "data", e;
7
+ }({}), r = /* @__PURE__ */ function(e) {
8
+ return e.SUPPORTING_MEASURE = "supporting-measure", e;
9
+ }({}), i = (e) => !!e && typeof e == "object" && "type" in e && e.type === "supporting-measure";
10
+ export { t as a, e as i, n, i as r, r as t };