@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,1129 @@
1
+ import { o as e } from "./rolldown-runtime-DleVn1XH.js";
2
+ import { No as t, Oa as n, Ta as r, Ti as i, Wc as a, Xs as o, Yn as s, lo as c, pc as l, qs as u, so as d, ta as f, ti as p } from "./interfaces-VUY4_yVO.js";
3
+ import { I as m, Ki as h, P as g, Zt as _, o as v, wi as y } from "./utils-Ba9T0TqC.js";
4
+ import { It as b, Jt as x, Lt as S, Vt as C, X as w, Z as T, bt as E, cn as D, en as ee, i as O, in as k, j as te, ln as A, n as ne, nn as j, rn as M, rt as re, sn as N, tn as ie, un as P, xt as ae } from "./escobar-BGqT1EsE.js";
5
+ import { l as F, vt as I } from "./_baseFlatten-DPXPOrea.js";
6
+ import { a as oe, r as se, t as ce } from "./coloring-C16AUZEi.js";
7
+ import { f as le, r as L, t as ue, u as de } from "./src-D9XogOrc.js";
8
+ var fe = /* @__PURE__ */ e(h()), R = /* @__PURE__ */ function(e) {
9
+ return e.sankey = "key-sankey", e.labels = "key-labels", e.columnLabels = "key-column-labels", e;
10
+ }({}), z = /* @__PURE__ */ function(e) {
11
+ return e.NodeFlow = "flow", e.NodeColor = "color", e;
12
+ }({}), B = /* @__PURE__ */ function(e) {
13
+ return e.ColumnTitleLeft = "columnTitleLeft", e.ColumnTitleCenter = "columnTitleCenter", e.ColumnTitleRight = "columnTitleRight", e.NodeLabelLeft = "nodeLabelLeft", e.NodeLabelCenter = "nodeLabelCenter", e.NodeLabelRight = "nodeLabelRight", e;
14
+ }({}), pe = class extends ce {
15
+ dimensionIds = [];
16
+ dimensionColoring = {};
17
+ constructor(e, t, n) {
18
+ super(e, t, n), this.dimensionIds = [], this.vSpec.dimensions.filter((e) => i(e)).forEach((e) => {
19
+ let t = l(e.dataItem);
20
+ this.dimensionColoring[t] = e.coloring, this.dimensionIds.push(t);
21
+ });
22
+ }
23
+ getColorByScale(e, t = {}) {
24
+ let { ref: n } = t, r = this.getDatumFromProp(e, n, "color"), i = r?.value, a = e.resources.scale(r.source?.field ?? r.label), s = r.source.field && this.dimensionColoring[r.source.field];
25
+ if (s?.type === o.Categorical && s.persistentColors === !0) {
26
+ let e = a.range();
27
+ return e[this.getHash(i) % e.length];
28
+ }
29
+ return a(i);
30
+ }
31
+ getDatumFromProp(e, t, n) {
32
+ return t === this.MAIN_FIELD ? e.datum : e.datum[t || n];
33
+ }
34
+ getLinkOverwrite(e) {
35
+ let t = this.vSpec.coloring?.overwrites;
36
+ for (let n = 0; n < t.length; n++) {
37
+ let r = t[n], i = e.datum, a = r.operator || "equals";
38
+ if ([i, ...Object.keys(i).filter((e) => this.dimensionIds.includes(i[e]?.source?.field)).map((e) => i[e])].find((e) => e.source.field === r?.dataItemId ? a === "equals" ? r.value === e.value || r.value === String(e.value) : se(r, e.value) : !1)) return r.color;
39
+ }
40
+ }
41
+ getFilteredColor() {
42
+ return null;
43
+ }
44
+ getLinkColorDefinition() {
45
+ return (e) => {
46
+ if (this.notAffectedItems?.pattern?.length && this.vSpec.staticFilters.ignoreGlobalFilters && this.vSpec.staticFilters.showGlobalFiltersEffect) {
47
+ let t = oe(e, this.notAffectedItems);
48
+ if (t) return t;
49
+ }
50
+ if (this.isColorOverwriteActive()) {
51
+ let t = this.getLinkOverwrite(e);
52
+ if (t) return t;
53
+ }
54
+ if (this.isColorRulesActive()) {
55
+ let t = this.getColorByColorRules(e);
56
+ if (t) return t;
57
+ }
58
+ };
59
+ }
60
+ }, me = (e, t) => e.data.value === t.data.value ? 0 : e.data.value < t.data.value ? 1 : -1, he = (e, t) => e.data.value === t.data.value ? 0 : e.data.value < t.data.value ? -1 : 1, ge = (e, t) => e.data.flow.value === t.data.flow.value ? 0 : e.data.flow.value < t.data.flow.value ? 1 : -1, _e = (e, t) => e.data.flow.value === t.data.flow.value ? 0 : e.data.flow.value < t.data.flow.value ? -1 : 1;
61
+ function ve(e, t) {
62
+ let n = e.dimensions.filter((e) => i(e)), r = (e.querySettings?.sortingOrder ?? []).map((e) => ({
63
+ id: l(e.dataItem),
64
+ direction: e.sortDirection,
65
+ type: e.fieldType
66
+ })), a = r.find((e) => e.type === "measure"), o = r.indexOf(a);
67
+ return n.map((n) => {
68
+ let i = l(n.dataItem), s;
69
+ if (e.sankeySettings.applyDataSortOnNodeColumns) {
70
+ let e = r.find((e) => e.id === i), t = r.indexOf(e);
71
+ e && t < o ? s = e.direction === "desc" ? me : he : a && (s = a.direction === "desc" ? ge : _e);
72
+ }
73
+ return {
74
+ id: i,
75
+ sort: s,
76
+ isGrouped: p(e.dimensions, e.enableAlternate, t)
77
+ };
78
+ });
79
+ }
80
+ var ye = (e, t) => {
81
+ let r = e.sankeySettings.linkColoring?.opacity ?? .3, i = t.valuePickerMode ?? !1, a = i ? t.valuePickerTargetDataItemId : "";
82
+ return {
83
+ trigger: [{
84
+ on: D.Tap,
85
+ action: N.Toggle,
86
+ globalPropagation: "stop",
87
+ data: ["", "linkTarget"],
88
+ contexts: [M.Selection]
89
+ }, {
90
+ on: D.Over,
91
+ action: N.Set,
92
+ globalPropagation: "stop",
93
+ data: ["", "linkTarget"],
94
+ contexts: [M.Highlight]
95
+ }],
96
+ consume: [
97
+ {
98
+ context: M.Selection,
99
+ data: ["", "linkTarget"],
100
+ filter: (e) => e.data?.type?.value === "link",
101
+ mode: A.Or,
102
+ style: { inactive: { opacity: r * .25 } }
103
+ },
104
+ {
105
+ context: M.Selection,
106
+ data: [""],
107
+ filter: (e) => e.data?.type?.value === "node",
108
+ mode: A.Or,
109
+ style: { inactive: { fill: (e) => {
110
+ let t = !e.fill || e.fill === "none" || e.fill === "transparent";
111
+ switch (!0) {
112
+ case t:
113
+ case i && e.data.source.field === a: return e.fill;
114
+ default: return ee(ie(e.fill), .25);
115
+ }
116
+ } } }
117
+ },
118
+ {
119
+ context: M.Highlight,
120
+ data: [""],
121
+ filter: (e) => e.data?.type?.value === "node",
122
+ mode: A.Or,
123
+ style: { active: {
124
+ strokeWidth: (e) => i && e.data.source.field !== a ? 0 : 1,
125
+ stroke: n.mainDarkNavy
126
+ } }
127
+ }
128
+ ]
129
+ };
130
+ }, be = (e, t, n, r, a, o) => {
131
+ let s = e.dimensions.filter((e) => i(e)), c = new pe(e, t, a?.[0]?.itemsNotAffectedByFiltering), u = e.sankeySettings.linkColoring?.opacity ?? .3, d = e.sankeySettings.linkColoring, f = s.map((e) => l(e.dataItem)), p = f.map((e, t) => `dim${t}`), m = e.sankeySettings.showNullNodes ? (e, t) => p[f.indexOf(t) + 1] : (e, t) => {
132
+ let n = f.indexOf(t), r = f.slice(n + 1).find((t) => e[p[f.indexOf(t)]].value !== null);
133
+ return p[f.indexOf(r)];
134
+ }, h = {
135
+ key: R.sankey,
136
+ type: P.Sankey,
137
+ data: { collection: "coll" },
138
+ settings: {
139
+ showNullNodes: e.sankeySettings.showNullNodes,
140
+ nodePadding: e.sankeySettings.nodePadding,
141
+ nodeWidth: e.sankeySettings.nodeWidth,
142
+ linkMargin: e.sankeySettings.linkMargin,
143
+ showColumnHeaderLabels: e.sankeySettings.showColumnHeaderLabels,
144
+ linkFillStrategy: e.sankeySettings.linkColoring.type,
145
+ nodeFillOverride: e.sankeySettings.nodeColoring.override ? e.sankeySettings.nodeColoring.color || t.colors.brandColors[0] : void 0,
146
+ showNodeDimensionLabel: e.sankeySettings.nodeLabels.enabled && e.sankeySettings.nodeLabels.showDimensionValue,
147
+ showNodeFlowLabel: e.sankeySettings.nodeLabels.enabled && e.sankeySettings.nodeLabels.showFlowValue,
148
+ showNodeLabelBackdrop: e.sankeySettings.nodeLabels.showBackdrop !== !1,
149
+ nodeLabelBackdropColor: e.sankeySettings.nodeLabels.backdropColor,
150
+ columnFields: ve(e, o.isPrintMode),
151
+ nodeLabelPlacements: e.sankeySettings.nodeLabels.placements.filter((e) => e.enabled).map((e) => e.placement),
152
+ node: {
153
+ id: (e) => `${e.datum.source.field}::${e.datum.value}`,
154
+ fill: c.getColorDefinition({
155
+ ref: z.NodeColor,
156
+ overwriteSources: [c.MAIN_FIELD, "color"]
157
+ })
158
+ },
159
+ link: {
160
+ linkSource: (e) => `${e.datum.source.field}::${e.datum.value}`,
161
+ linkTarget: (e) => {
162
+ let t = m(e.datum, e.datum.source.field);
163
+ return t ? (e.datum.linkTarget = e.datum[t], `${e.datum[t].source.field}::${e.datum[t].value}`) : null;
164
+ },
165
+ value: { ref: "flow" },
166
+ dataFill: c.getLinkColorDefinition(),
167
+ fill: () => d.override ? d.color || t.colors.brandColors[0] : void 0,
168
+ opacity: u
169
+ }
170
+ },
171
+ brush: o.disable?.brushing === !0 ? void 0 : ye(e, o),
172
+ animations: {
173
+ presetId: "simple-opacity",
174
+ enabled: !0
175
+ }
176
+ };
177
+ return {
178
+ ...n,
179
+ components: [...n.components, h]
180
+ };
181
+ }, xe = (e, t, n) => {
182
+ let r = e.measures.filter((e) => i(e)), a = e.dimensions.filter((e) => i(e)), o = l(r[0].dataItem), s = a.map((e) => l(e.dataItem)), c = s.map((e) => ({
183
+ field: e,
184
+ trackBy: (e) => e,
185
+ reduce: "first",
186
+ props: {
187
+ [z.NodeFlow]: {
188
+ field: o,
189
+ reduce: "sum"
190
+ },
191
+ [o]: {
192
+ field: o,
193
+ reduce: "sum"
194
+ },
195
+ [z.NodeColor]: { field: e },
196
+ type: "node"
197
+ }
198
+ })), u = s.slice(0, s.length - 1).map((e, t) => {
199
+ let n = {
200
+ field: s[t],
201
+ props: {
202
+ flow: { field: o },
203
+ [o]: { field: o },
204
+ type: "link"
205
+ }
206
+ };
207
+ return s.forEach((e, t) => {
208
+ n.field !== e && (n.props[`dim${t}`] = { field: e });
209
+ }), n;
210
+ }), d = [{
211
+ key: "coll",
212
+ data: {
213
+ extract: [...c, ...u],
214
+ filter: e.sankeySettings.showNullNodes ? void 0 : (e) => e.value !== null
215
+ }
216
+ }];
217
+ return {
218
+ ...n,
219
+ collections: d,
220
+ formatters: { flow: {
221
+ type: "excel-format",
222
+ format: r[0].formatter?.format
223
+ } }
224
+ };
225
+ }, V = (e, t) => ({
226
+ component: R.sankey,
227
+ selector: e,
228
+ strategy: {
229
+ type: "rows",
230
+ settings: {
231
+ justify: .5,
232
+ align: t,
233
+ labels: [{
234
+ linkData: ({ node: e }) => e.desc.field,
235
+ label({ node: e }) {
236
+ let t = e.desc.label;
237
+ return e.desc?.isGrouped ? C(t) : t;
238
+ }
239
+ }]
240
+ }
241
+ }
242
+ }), H = 64, Se = new F(I.fontLight), Ce = new F(I.fontDark), U = (e, t, n) => {
243
+ let r = new F(n.fonts.general.color);
244
+ return {
245
+ component: R.sankey,
246
+ selector: e,
247
+ strategy: {
248
+ type: "rows",
249
+ settings: {
250
+ justify: .5,
251
+ align: t,
252
+ labels: [{
253
+ id({ node: e }) {
254
+ return e.attrs?.id?.replace("::labelTarget", "");
255
+ },
256
+ backdrop({ node: e }) {
257
+ return e.desc?.backdrop;
258
+ },
259
+ fill({ node: e }) {
260
+ return !e.desc.backdrop && !e.desc.background ? r.rgb() : new F(e.desc?.backdrop?.fill || e.desc.background).betterContrast(r, Se, Ce).rgb();
261
+ },
262
+ linkData({ node: e }) {
263
+ return e.desc?.data;
264
+ },
265
+ label({ node: e, formatter: t }) {
266
+ let n = e.desc.showFlow ? t("flow")(e.desc?.data?.[z.NodeFlow]?.value) : void 0, r = e.desc?.label?.length > H - 1 ? `${e.desc?.label?.substring(0, H - 1).replace(/\s+$/, "")}…` : e.desc?.label;
267
+ return [e.desc.showDimension ? r : void 0, n].filter(Boolean).join(": ");
268
+ }
269
+ }]
270
+ }
271
+ }
272
+ };
273
+ }, we = (e, n, r, o, c, u, d, f) => {
274
+ let m = [];
275
+ f && m.push(S(R.columnLabels, R.columnLabels, f));
276
+ let h = {
277
+ type: P.Labels,
278
+ key: R.columnLabels,
279
+ layout: { displayOrder: 2 },
280
+ settings: { sources: [
281
+ V(`.${B.ColumnTitleLeft}`, 0),
282
+ V(`.${B.ColumnTitleCenter}`, .5),
283
+ V(`.${B.ColumnTitleRight}`, 1)
284
+ ] },
285
+ style: { label: "$title" },
286
+ animations: {
287
+ presetId: "simple-opacity",
288
+ enabled: !0
289
+ }
290
+ }, g = e?.measures.find(i), _ = g ? l(g.dataItem) : void 0, v = g && (s(g) || g.label || g.dataItem?.name || "Measure");
291
+ f && g && e.measures.length > 1 && m.push(b(P.Text, f));
292
+ let y = g && e.measures.length > 1 ? {
293
+ type: P.Text,
294
+ key: `text-${_}`,
295
+ dataItemType: a.Measure,
296
+ dataItemRole: g.role,
297
+ text: p(e.measures, e.enableAlternate, u.isPrintMode) ? C(v) : v,
298
+ layout: {
299
+ dock: t.Bottom,
300
+ color: "red"
301
+ },
302
+ style: { text: {
303
+ fontFamily: n.fonts.general.fontFamily,
304
+ fontSize: `${I.fieldTitle.fontSize}px`,
305
+ fontStyle: "normal",
306
+ fill: n.fonts.general.color
307
+ } },
308
+ anchor: t.Center
309
+ } : void 0, x = {
310
+ type: P.Labels,
311
+ key: R.labels,
312
+ layout: { displayOrder: 2 },
313
+ settings: { sources: [
314
+ U(`.${B.NodeLabelLeft}`, 0, n),
315
+ U(`.${B.NodeLabelCenter}`, .5, n),
316
+ U(`.${B.NodeLabelRight}`, 1, n)
317
+ ] },
318
+ style: { label: "$label" },
319
+ brush: u.disable?.brushing === !0 ? void 0 : {
320
+ trigger: [{
321
+ on: D.Tap,
322
+ action: N.Toggle,
323
+ globalPropagation: "stop",
324
+ data: [""],
325
+ contexts: [M.Selection]
326
+ }],
327
+ consume: [{
328
+ context: M.Selection,
329
+ data: [""],
330
+ style: { inactive: { opacity: .3 } }
331
+ }]
332
+ },
333
+ animations: {
334
+ presetId: "simple-opacity",
335
+ enabled: !0
336
+ }
337
+ };
338
+ return {
339
+ ...r,
340
+ components: [
341
+ ...r.components,
342
+ h,
343
+ ...y ? [y] : [],
344
+ x
345
+ ],
346
+ interactions: r.interactions ? [...r.interactions, ...m] : [...m]
347
+ };
348
+ }, Te = (e, t, n, r, i) => {
349
+ if (n.type !== o.PerEachDimension) {
350
+ let e = n.color || t?.colors?.brandColors?.[0] || "#aaa";
351
+ return {
352
+ type: k.CategoricalColor,
353
+ data: [],
354
+ range: [e],
355
+ unknown: e
356
+ };
357
+ }
358
+ let a = r.coloring || {};
359
+ if (a.type !== o.Categorical) {
360
+ let n = i[e.dimensions.indexOf(r) % i.length], o = a.color || n || t?.colors?.brandColors?.[0] || "#aaa";
361
+ return {
362
+ type: k.CategoricalColor,
363
+ data: [],
364
+ range: [o],
365
+ unknown: o
366
+ };
367
+ }
368
+ return ae(e, t, l(r.dataItem), {
369
+ customPalette: a.customPalette ?? f.customPalette,
370
+ palette: a.palette
371
+ });
372
+ }, Ee = (e, t, n) => {
373
+ let r = e.dimensions.filter((e) => i(e));
374
+ if (!r[0]) return n;
375
+ let a = {}, o = E({
376
+ palette: e.coloring.palette,
377
+ customPalette: e.coloring.customPalette ?? f.customPalette
378
+ }, t);
379
+ return r.forEach((n) => {
380
+ let r = l(n.dataItem);
381
+ a[r] = Te(e, t, e.coloring, n, o);
382
+ }), {
383
+ ...n,
384
+ scales: a
385
+ };
386
+ }, De = (e, t, n) => {
387
+ let r = e.dimensions.filter((e) => i(e)), a = e.measures.filter((e) => i(e));
388
+ if (!r[0] || !a[0]) return n;
389
+ let o = {
390
+ "$font-family": t.fonts.general.fontFamily,
391
+ "$font-color": t.fonts.general.color,
392
+ "$font-size": `${x(e.sankeySettings?.nodeLabels?.fontSize)}px`,
393
+ $label: {
394
+ fontSize: "$font-size",
395
+ fontFamily: "$font-family",
396
+ fill: "$font-color",
397
+ padding: 1
398
+ },
399
+ $title: {
400
+ "@extend": "$label",
401
+ fontSize: `${I.fieldTitle.fontSize}px`,
402
+ padding: 4
403
+ }
404
+ };
405
+ return {
406
+ ...n,
407
+ style: o
408
+ };
409
+ }, Oe = (e, t) => t?.data?.type?.value === "link" ? `${t.data.label} - ${t.data.linkTarget.label}` : t.data.label, ke = (e, t, n, r, i, a, o) => {
410
+ let c = [], l = s(e[0]) || e[0].label || e[0].dataItem.name || "", u = e.length ? l : "Count", d = t.desc?.flow ?? t.data?.flow.value;
411
+ return d = o ? n.formatter(re())(d) : n.formatter("flow")(d), c.push({
412
+ label: u,
413
+ value: d
414
+ }), c;
415
+ }, Ae = (e, t, n, r, i) => {
416
+ let a = { placement: ({ nodes: e }) => ({
417
+ area: "target",
418
+ type: e[0]?.data?.type?.value === "link" ? "pointer" : "bounds"
419
+ }) };
420
+ return a.extract = T(e, t, ke, Oe), w(e, t, n, a, "tooltip", i);
421
+ }, je = class extends te {
422
+ constructor() {
423
+ super([
424
+ xe,
425
+ Ee,
426
+ be,
427
+ we,
428
+ De,
429
+ Ae
430
+ ]);
431
+ }
432
+ preCompile(e, t) {
433
+ let n = e.measures.filter((e) => i(e)), r = e.dimensions.filter((e) => i(e)), a = n[0];
434
+ if (!a) return;
435
+ let o = l(a.dataItem), s = r.map((e) => l(e.dataItem));
436
+ t.forEach((t) => {
437
+ if (t.items?.length) {
438
+ if (t.items = t.items.filter((e) => e[o] > 0), !t.items.length) throw Error("Current data query resulted in only negative and/or null values which can not be displayed in this chart.");
439
+ if (!e.sankeySettings.showNullNodes && !t.items.find((e) => s.find((t) => e[t] !== null))) throw Error("Current dataset contains only non-null dimension values and can not be displayed in the current configuration of this chart.");
440
+ }
441
+ });
442
+ }
443
+ }, W = {
444
+ showNullNodes: !1,
445
+ nodePadding: .2,
446
+ nodeWidth: .2,
447
+ linkMargin: 0,
448
+ showColumnHeaderLabels: !1,
449
+ linkFillStrategy: d.Interpolated,
450
+ nodeFillOverride: null,
451
+ showNodeFlowLabel: !0,
452
+ showNodeDimensionLabel: !0,
453
+ showNodeLabelBackdrop: !0,
454
+ nodeLabelBackdropColor: null,
455
+ columnFields: [],
456
+ nodeLabelPlacements: [c.Beside],
457
+ node: {
458
+ id: "",
459
+ fill: "#333333"
460
+ },
461
+ link: {
462
+ fill: "rgba(100, 100, 100, 0.5)",
463
+ linkSource: "",
464
+ linkTarget: "",
465
+ value: 1
466
+ }
467
+ };
468
+ function G(e, t) {
469
+ return e.dataFill === t.dataFill ? 0 : e.dataFill < t.dataFill ? -1 : 1;
470
+ }
471
+ function Me(e) {
472
+ let t = e.target.x0 - e.source.x1, n = e.y0 - e.y1, r = Math.abs(n) < .1 ? 0 : .5;
473
+ return [
474
+ `M${e.source.x1},${e.y0}`,
475
+ `C${e.source.x1 + t * r},${e.y0}`,
476
+ `${e.source.x1 + t * (1 - r)},${e.y1}`,
477
+ `${e.target.x0},${e.y1}`
478
+ ].join(" ");
479
+ }
480
+ function Ne(e) {
481
+ return e.map((e) => ({
482
+ type: j.Path,
483
+ data: e.data,
484
+ desc: { flow: e.value },
485
+ d: Me(e),
486
+ fill: "none",
487
+ strokeWidth: Math.max(.5, e.width),
488
+ stroke: e.fill,
489
+ strokeLinecap: "butt",
490
+ opacity: e.opacity,
491
+ id: e.id,
492
+ collider: { visual: !0 }
493
+ }));
494
+ }
495
+ function Pe(e) {
496
+ let { data: t, resolver: n, settings: r, resolvedNodes: i } = e, a = {};
497
+ i.forEach((e) => {
498
+ a[e.id] = e;
499
+ });
500
+ let o = t.items.filter((e) => e.type.value === "link"), { items: s } = n.resolve({
501
+ data: { items: o },
502
+ defaults: { ...W.link },
503
+ settings: r.link
504
+ }), c = {};
505
+ return s.filter((e) => !!e.linkTarget).forEach((e) => {
506
+ let t = a[e.linkSource], n = a[e.linkTarget], i;
507
+ if (!e.fill && !e.dataFill) switch (r.linkFillStrategy) {
508
+ case d.Source:
509
+ e.fill = t.fill;
510
+ break;
511
+ case d.Target:
512
+ e.fill = n.fill;
513
+ break;
514
+ case d.Interpolated:
515
+ e.fill = {
516
+ type: "gradient",
517
+ orientation: "linear",
518
+ degree: -180,
519
+ stops: [{
520
+ color: t.fill,
521
+ offset: 0
522
+ }, {
523
+ color: n.fill,
524
+ offset: 1
525
+ }]
526
+ }, i = `${t.fill}::${n.fill}`;
527
+ break;
528
+ }
529
+ else e.dataFill && (e.fill = e.dataFill);
530
+ i ||= e.fill, e.fillId = i;
531
+ let o = `${e.linkSource}::${e.linkTarget}`;
532
+ c[o] && c[o].fillId !== e.fillId && (o += `::${e.fillId}`), c[o] ? c[o].value += e.value : (c[o] = e, e.id = o);
533
+ }), Object.values(c).map((e) => ({
534
+ source: e.linkSource,
535
+ target: e.linkTarget,
536
+ id: e.id,
537
+ value: e.value,
538
+ fill: e.fill,
539
+ dataFill: e.dataFill,
540
+ data: e.data,
541
+ opacity: e.opacity
542
+ }));
543
+ }
544
+ function Fe(e) {
545
+ let { data: t, resolver: n, settings: r } = e, i = t.items.filter((e) => e.type.value === "node"), { items: a } = n.resolve({
546
+ data: { items: i },
547
+ defaults: { ...W.node },
548
+ settings: {
549
+ ...r.node,
550
+ fixedValue: ({ datum: e }) => e.flow.value
551
+ }
552
+ });
553
+ return a;
554
+ }
555
+ function Ie(e, t) {
556
+ let n = [];
557
+ return e.map((e) => {
558
+ let r = {};
559
+ e.sourceLinks.forEach((e) => {
560
+ e.dataFill && (r[e.dataFill] || (r[e.dataFill] = {
561
+ dataFill: e.dataFill,
562
+ sourceSum: 0,
563
+ targetSum: 0
564
+ }), r[e.dataFill].sourceSum += e.value);
565
+ }), e.targetLinks.forEach((e) => {
566
+ e.dataFill && (r[e.dataFill] || (r[e.dataFill] = {
567
+ dataFill: e.dataFill,
568
+ sourceSum: 0,
569
+ targetSum: 0
570
+ }), r[e.dataFill].targetSum += e.value);
571
+ });
572
+ let i = Object.values(r);
573
+ i.sort(G);
574
+ let a = i.reduce(([e, t], n) => [e + n.sourceSum, t + n.targetSum], [0, 0]), o = 1 - Math.max(...a) / e.value, s = e.y1 - e.y0, c = e.y0;
575
+ n.push({
576
+ id: e.id,
577
+ type: j.Rect,
578
+ x: e.x0 + t.nodeMargin,
579
+ width: e.x1 - e.x0 - t.nodeMargin * 2,
580
+ y: c,
581
+ height: Math.max(.5, o * s),
582
+ fill: e.fill,
583
+ opacity: 1,
584
+ data: e.data,
585
+ desc: {
586
+ data: e.data,
587
+ label: e.data.label,
588
+ flow: e.data.flow.value
589
+ }
590
+ }), c += o * s, i.forEach(({ dataFill: r, sourceSum: i, targetSum: a }, o) => {
591
+ let l = s * (Math.max(i, a) / e.value);
592
+ n.push({
593
+ id: `${e.id}::${o}`,
594
+ type: j.Rect,
595
+ x: e.x0 + t.nodeMargin,
596
+ width: e.x1 - e.x0 - t.nodeMargin * 2,
597
+ y: c,
598
+ height: Math.max(.5, l),
599
+ fill: r,
600
+ opacity: 1,
601
+ data: e.data,
602
+ desc: {
603
+ data: e.data,
604
+ label: e.data.label,
605
+ flow: e.data.flow.value
606
+ }
607
+ }), c += l;
608
+ });
609
+ }), n;
610
+ }
611
+ var K = (e, t, n = !1, r = [4, 2]) => ({
612
+ data: e.data,
613
+ background: n ? e.fill : void 0,
614
+ label: e.data.label,
615
+ showDimension: t.showDimensionLabel,
616
+ showFlow: t.showFlowLabel,
617
+ backdrop: t.showBackdrop ? {
618
+ fill: t.backdropColor ?? e.fill,
619
+ opacity: t.backdropColor ? 1 : .8,
620
+ padding: r
621
+ } : void 0
622
+ }), Le = (e, t, n, r) => {
623
+ let { nodeLabelHeight: i, nodePadding: a } = r;
624
+ return a < i ? [] : e.map((e) => {
625
+ let t = n[e.layer], a = K(e, r, !1, [4, 0]), o = a.backdrop?.padding ?? [0, 0], s = t.align < .5 ? B.NodeLabelLeft : t.align > .5 ? B.NodeLabelRight : B.NodeLabelCenter;
626
+ return {
627
+ type: j.Rect,
628
+ id: `${e.id}::labelTarget`,
629
+ x: t.fullX + (t.align < .5 ? r.nodeMargin + o[0] : 0),
630
+ width: t.fullWidth - (t.align === .5 ? 0 : r.nodeMargin + o[0]),
631
+ y: e.y0 - i,
632
+ height: i,
633
+ desc: a,
634
+ tag: s,
635
+ fill: "none"
636
+ };
637
+ });
638
+ }, Re = (e) => e.canShowNodeLabelAboveNode, ze = (e, t, n, r) => {
639
+ let { nodePadding: i } = r;
640
+ return e.filter((e) => e.y1 - e.y0 + i >= r.nodeLabelHeight).map((e) => {
641
+ let t = n[e.layer], a = t.align <= .5 ? B.NodeLabelLeft : B.NodeLabelRight, o = K(e, r, !1, [4, 2]), s = o.backdrop?.padding ?? [0, 0], c = [2, 2], l = [s[0] + c[0], s[1] + c[1]], u = {
642
+ type: j.Rect,
643
+ id: `${e.id}::labelTarget`,
644
+ x: t.gapX + l[0],
645
+ width: t.gapWidth - 2 * l[0],
646
+ y: e.y0 - i / 2,
647
+ height: e.y1 - e.y0 + i,
648
+ desc: o,
649
+ tag: a,
650
+ fill: "none"
651
+ };
652
+ return t.nodeWidth === 0 && (u.x = t.fullX + s[0], u.width = t.fullWidth - 2 * s[1], u.tag = t.align < .5 ? B.NodeLabelLeft : t.align > .5 ? B.NodeLabelRight : B.NodeLabelCenter), u;
653
+ });
654
+ }, Be = (e) => e.columnGap >= 20, Ve = (e, t, n, r) => e.filter((e) => e.y1 - e.y0 >= r.nodeLabelHeight).map((e) => {
655
+ let t = K(e, r, !0, [4, 2]);
656
+ return {
657
+ type: j.Rect,
658
+ id: `${e.id}::labelTarget`,
659
+ x: e.x0 + r.nodeMargin,
660
+ width: e.x1 - e.x0 - r.nodeMargin * 2,
661
+ y: e.y0,
662
+ height: e.y1 - e.y0,
663
+ desc: t,
664
+ tag: B.NodeLabelCenter,
665
+ fill: "none"
666
+ };
667
+ }), He = (e) => e.columnWidth >= 80, q = {
668
+ [c.Above]: {
669
+ condition: Re,
670
+ create: Le
671
+ },
672
+ [c.Beside]: {
673
+ condition: Be,
674
+ create: ze
675
+ },
676
+ [c.Inside]: {
677
+ condition: He,
678
+ create: Ve
679
+ }
680
+ }, Ue = (e) => e.priority.find((t) => q[t]?.condition(e)), We = (e, t, n, r) => {
681
+ let i = [], a = n[0];
682
+ if (!r.showDimensionLabel && !r.showFlowLabel) return [];
683
+ let o = r.priority.find((e) => q[e]?.condition({
684
+ canShowNodeLabelAboveNode: r.canShowNodeLabelAboveNode,
685
+ columnGap: a.gapWidth,
686
+ columnWidth: a.nodeWidth,
687
+ priority: r.priority
688
+ }));
689
+ return o && i.push(...q[o].create(e, t, n, r)), i;
690
+ };
691
+ function Ge(e, t) {
692
+ let { headerHeight: n } = t;
693
+ return e.map((e) => {
694
+ let t = e.align < .5 ? B.ColumnTitleLeft : e.align > .5 ? B.ColumnTitleRight : B.ColumnTitleCenter;
695
+ return {
696
+ type: j.Rect,
697
+ id: `column::${e.field}::labelTarget`,
698
+ tag: t,
699
+ fill: "none",
700
+ strokeWidth: 0,
701
+ x: e.fullX,
702
+ y: 0,
703
+ width: e.fullWidth,
704
+ height: n,
705
+ desc: {
706
+ isGrouped: e.isGrouped,
707
+ field: e.field,
708
+ label: e.label
709
+ }
710
+ };
711
+ });
712
+ }
713
+ function Ke(e, t, n, r) {
714
+ let i = {};
715
+ e.columnFields.forEach((e) => {
716
+ i[e.id] = {
717
+ count: 0,
718
+ label: r.field(e.id).title()
719
+ };
720
+ }), t.forEach((t) => {
721
+ e.nodeFillOverride && (t.fill = e.nodeFillOverride);
722
+ let n = t.data.source.field;
723
+ i[n].count++;
724
+ });
725
+ let a = e.columnFields.map((e) => ({
726
+ ...i[e.id],
727
+ isGrouped: e.isGrouped,
728
+ field: e.id,
729
+ sort: e.sort
730
+ }));
731
+ return qe(a, t, n, e.showNullNodes), a;
732
+ }
733
+ function qe(e, t, n, r = !1) {
734
+ (e.find((e) => !e.count) || !r) && e.forEach((r, i) => {
735
+ let a = `dummy-${i}`, o = `dummy-${i + 1}`;
736
+ t.unshift({
737
+ id: a,
738
+ fill: "none",
739
+ data: {
740
+ source: {
741
+ field: r.field,
742
+ key: ""
743
+ },
744
+ label: "",
745
+ value: null,
746
+ flow: {
747
+ value: 0,
748
+ label: ""
749
+ }
750
+ },
751
+ fixedValue: 0
752
+ }), i < e.length - 1 && n.unshift({
753
+ fill: "none",
754
+ source: a,
755
+ target: o,
756
+ value: 0
757
+ });
758
+ });
759
+ }
760
+ function Je(e, t) {
761
+ return {
762
+ nodes: e.filter((e) => !e.id.startsWith("dummy-")),
763
+ links: t.filter((e) => !e.source.id.startsWith("dummy-"))
764
+ };
765
+ }
766
+ function Ye(e, t, n) {
767
+ let r = n[1][1] - n[0][1], i = e.reduce(([e, t], n) => [Math.min(e, n.y0), Math.max(t, n.y1)], [e[0].y0, e[0].y1]), a = i[0] - n[0][1], o = n[1][1] - i[1], s = 0;
768
+ a > o && r / a > .1 ? s = -a / 2 : o > a && r / o > .1 && (s = o / 2), s !== 0 && (e.forEach((e) => {
769
+ e.y0 += s, e.y1 += s;
770
+ }), t.forEach((e) => {
771
+ e.y0 += s, e.y1 += s;
772
+ }));
773
+ }
774
+ function Xe(e, t, n) {
775
+ return e.map((r) => {
776
+ let i = t.find((e) => e.data.source.field === r.field), a = i.x0, o = i.x1 - i.x0, s = i.x1, c = n, l = i.x0 - n / 2, u = n + o, d = .5;
777
+ return i.layer ? i.layer === e.length - 2 ? c = n / 2 : i.layer === e.length - 1 && (u = o + n / 2, c = n / 2, s = a - n / 2, d = 1) : (u = o + n / 2, l = 0, d = 0), {
778
+ ...r,
779
+ gapX: s,
780
+ gapWidth: c,
781
+ fullX: l,
782
+ fullWidth: u,
783
+ nodeX: a,
784
+ nodeWidth: o,
785
+ align: d
786
+ };
787
+ });
788
+ }
789
+ function Ze(e, t, n, r, i) {
790
+ let a = Math.max(0, n.width / (e.length * 2) * t.nodeWidth), o = a > 0 ? t.linkMargin * .5 * Math.min(24, (n.width - a * e.length) / (e.length - 1) / 2) : 0;
791
+ a += o * 2;
792
+ let s = (n.width - a * e.length) / (e.length - 1), l = Math.max(...e.map((e) => e.count)), u = r.measureText(i.title).height + 2 * i.title.padding, d = 8 + u, f = t.showColumnHeaderLabels && n.height - 8 - d > 0, p = r.measureText(i.label).height + 2 * i.label.padding, m = f ? d : 0, h = n.height - m, g = h / l / 2 * t.nodePadding, _ = (t.showNodeDimensionLabel || t.showNodeFlowLabel) && p * l < h / 2, v = g, y = Ue({
793
+ canShowNodeLabelAboveNode: _,
794
+ columnGap: s,
795
+ columnWidth: a,
796
+ priority: t.nodeLabelPlacements
797
+ });
798
+ return _ && y === c.Above && (m += p, v = Math.max(p, g)), {
799
+ columnGap: s,
800
+ columnWidth: a,
801
+ nodePadding: v,
802
+ availableHeight: h,
803
+ nodeLabelHeight: p,
804
+ nodeMargin: o,
805
+ top: m,
806
+ showHeader: f,
807
+ headerTitleHeight: u,
808
+ canShowNodeLabelAboveNode: _
809
+ };
810
+ }
811
+ function Qe(e, t) {
812
+ return e.sourceLinks.length ? e.depth : t - 1;
813
+ }
814
+ function J(e) {
815
+ return function() {
816
+ return e;
817
+ };
818
+ }
819
+ ue();
820
+ function Y(e, t) {
821
+ return Z(e.source, t.source) || e.index - t.index;
822
+ }
823
+ function X(e, t) {
824
+ return Z(e.target, t.target) || e.index - t.index;
825
+ }
826
+ function Z(e, t) {
827
+ return e.y0 - t.y0;
828
+ }
829
+ function Q(e) {
830
+ return e.value;
831
+ }
832
+ function $e(e) {
833
+ return e.index;
834
+ }
835
+ function et(e) {
836
+ return e.nodes;
837
+ }
838
+ function tt(e) {
839
+ return e.links;
840
+ }
841
+ function nt(e, t) {
842
+ let n = e.get(t);
843
+ if (!n) throw Error("missing: " + t);
844
+ return n;
845
+ }
846
+ function rt({ nodes: e }) {
847
+ for (let t of e) {
848
+ let e = t.y0, n = e;
849
+ for (let n of t.sourceLinks) n.y0 = e + n.width / 2, e += n.width;
850
+ for (let e of t.targetLinks) e.y1 = n + e.width / 2, n += e.width;
851
+ }
852
+ }
853
+ function it() {
854
+ let e = 0, t = 0, n = 1, r = 1, i = 24, a = 8, o, s = $e, c = Qe, l, u, d = et, f = tt, p = 6;
855
+ function m() {
856
+ let e = {
857
+ nodes: d.apply(null, arguments),
858
+ links: f.apply(null, arguments)
859
+ };
860
+ return h(e), g(e), _(e), v(e), x(e), rt(e), e;
861
+ }
862
+ m.update = function(e) {
863
+ return rt(e), e;
864
+ }, m.nodeId = function(e) {
865
+ return arguments.length ? (s = typeof e == "function" ? e : J(e), m) : s;
866
+ }, m.nodeAlign = function(e) {
867
+ return arguments.length ? (c = typeof e == "function" ? e : J(e), m) : c;
868
+ }, m.nodeSort = function(e) {
869
+ return arguments.length ? (l = e, m) : l;
870
+ }, m.nodeWidth = function(e) {
871
+ return arguments.length ? (i = +e, m) : i;
872
+ }, m.nodePadding = function(e) {
873
+ return arguments.length ? (a = o = +e, m) : a;
874
+ }, m.nodes = function(e) {
875
+ return arguments.length ? (d = typeof e == "function" ? e : J(e), m) : d;
876
+ }, m.links = function(e) {
877
+ return arguments.length ? (f = typeof e == "function" ? e : J(e), m) : f;
878
+ }, m.linkSort = function(e) {
879
+ return arguments.length ? (u = e, m) : u;
880
+ }, m.size = function(i) {
881
+ return arguments.length ? (e = t = 0, n = +i[0], r = +i[1], m) : [n - e, r - t];
882
+ }, m.extent = function(i) {
883
+ return arguments.length ? (e = +i[0][0], n = +i[1][0], t = +i[0][1], r = +i[1][1], m) : [[e, t], [n, r]];
884
+ }, m.iterations = function(e) {
885
+ return arguments.length ? (p = +e, m) : p;
886
+ };
887
+ function h({ nodes: e, links: t }) {
888
+ for (let [t, n] of e.entries()) n.index = t, n.sourceLinks = [], n.targetLinks = [];
889
+ let n = new Map(e.map((t, n) => [s(t, n, e), t]));
890
+ for (let [e, r] of t.entries()) {
891
+ r.index = e;
892
+ let { source: t, target: i } = r;
893
+ typeof t != "object" && (t = r.source = nt(n, t)), typeof i != "object" && (i = r.target = nt(n, i)), t.sourceLinks.push(r), i.targetLinks.push(r);
894
+ }
895
+ if (u != null) for (let { sourceLinks: t, targetLinks: n } of e) t.sort(u), n.sort(u);
896
+ }
897
+ function g({ nodes: e }) {
898
+ for (let t of e) t.value = t.fixedValue === void 0 ? Math.max(L(t.sourceLinks, Q), L(t.targetLinks, Q)) : t.fixedValue;
899
+ }
900
+ function _({ nodes: e }) {
901
+ let t = e.length, n = new Set(e), r = /* @__PURE__ */ new Set(), i = 0;
902
+ for (; n.size;) {
903
+ for (let e of n) {
904
+ e.depth = i;
905
+ for (let { target: t } of e.sourceLinks) r.add(t);
906
+ }
907
+ if (++i > t) throw Error("circular link");
908
+ n = r, r = /* @__PURE__ */ new Set();
909
+ }
910
+ }
911
+ function v({ nodes: e }) {
912
+ let t = e.length, n = new Set(e), r = /* @__PURE__ */ new Set(), i = 0;
913
+ for (; n.size;) {
914
+ for (let e of n) {
915
+ e.height = i;
916
+ for (let { source: t } of e.targetLinks) r.add(t);
917
+ }
918
+ if (++i > t) throw Error("circular link");
919
+ n = r, r = /* @__PURE__ */ new Set();
920
+ }
921
+ }
922
+ function y({ nodes: t }) {
923
+ let r = le(t, (e) => e.depth) + 1, a = (n - e - i) / (r - 1), o = Array(r);
924
+ for (let n of t) {
925
+ let t = Math.max(0, Math.min(r - 1, Math.floor(c.call(null, n, r))));
926
+ n.layer = t, n.x0 = e + t * a, n.x1 = n.x0 + i, o[t] ? o[t].push(n) : o[t] = [n];
927
+ }
928
+ if (l) for (let e of o) e.sort(l);
929
+ return o;
930
+ }
931
+ function b(e) {
932
+ let n = de(e, (e) => (r - t - (e.length - 1) * o) / L(e, Q));
933
+ for (let i of e) {
934
+ let e = t;
935
+ for (let t of i) {
936
+ t.y0 = e, t.y1 = e + t.value * n, e = t.y1 + o;
937
+ for (let e of t.sourceLinks) e.width = e.value * n;
938
+ }
939
+ e = (r - e + o) / (i.length + 1);
940
+ for (let t = 0; t < i.length; ++t) {
941
+ let n = i[t];
942
+ n.y0 += e * (t + 1), n.y1 += e * (t + 1);
943
+ }
944
+ ee(i);
945
+ }
946
+ }
947
+ function x(e) {
948
+ let n = y(e);
949
+ o = Math.min(a, (r - t) / (le(n, (e) => e.length) - 1)), b(n);
950
+ for (let e = 0; e < p; ++e) {
951
+ let t = .99 ** e, r = Math.max(1 - t, (e + 1) / p);
952
+ C(n, t, r), S(n, t, r);
953
+ }
954
+ }
955
+ function S(e, t, n) {
956
+ for (let r = 1, i = e.length; r < i; ++r) {
957
+ let i = e[r];
958
+ for (let e of i) {
959
+ let n = 0, r = 0;
960
+ for (let { source: t, value: i } of e.targetLinks) {
961
+ let a = i * (e.layer - t.layer);
962
+ n += O(t, e) * a, r += a;
963
+ }
964
+ if (!(r > 0)) continue;
965
+ let i = (n / r - e.y0) * t;
966
+ e.y0 += i, e.y1 += i, D(e);
967
+ }
968
+ l === void 0 && i.sort(Z), w(i, n);
969
+ }
970
+ }
971
+ function C(e, t, n) {
972
+ for (let r = e.length - 2; r >= 0; --r) {
973
+ let i = e[r];
974
+ for (let e of i) {
975
+ let n = 0, r = 0;
976
+ for (let { target: t, value: i } of e.sourceLinks) {
977
+ let a = i * (t.layer - e.layer);
978
+ n += k(e, t) * a, r += a;
979
+ }
980
+ if (!(r > 0)) continue;
981
+ let i = (n / r - e.y0) * t;
982
+ e.y0 += i, e.y1 += i, D(e);
983
+ }
984
+ l === void 0 && i.sort(Z), w(i, n);
985
+ }
986
+ }
987
+ function w(e, n) {
988
+ let i = e.length >> 1, a = e[i];
989
+ E(e, a.y0 - o, i - 1, n), T(e, a.y1 + o, i + 1, n), E(e, r, e.length - 1, n), T(e, t, 0, n);
990
+ }
991
+ function T(e, t, n, r) {
992
+ for (; n < e.length; ++n) {
993
+ let i = e[n], a = (t - i.y0) * r;
994
+ a > 1e-6 && (i.y0 += a, i.y1 += a), t = i.y1 + o;
995
+ }
996
+ }
997
+ function E(e, t, n, r) {
998
+ for (; n >= 0; --n) {
999
+ let i = e[n], a = (i.y1 - t) * r;
1000
+ a > 1e-6 && (i.y0 -= a, i.y1 -= a), t = i.y0 - o;
1001
+ }
1002
+ }
1003
+ function D({ sourceLinks: e, targetLinks: t }) {
1004
+ if (u === void 0) {
1005
+ for (let { source: { sourceLinks: e } } of t) e.sort(X);
1006
+ for (let { target: { targetLinks: t } } of e) t.sort(Y);
1007
+ }
1008
+ }
1009
+ function ee(e) {
1010
+ if (u === void 0) for (let { sourceLinks: t, targetLinks: n } of e) t.sort(X), n.sort(Y);
1011
+ }
1012
+ function O(e, t) {
1013
+ let n = e.y0 - (e.sourceLinks.length - 1) * o / 2;
1014
+ for (let { target: r, width: i } of e.sourceLinks) {
1015
+ if (r === t) break;
1016
+ n += i + o;
1017
+ }
1018
+ for (let { source: r, width: i } of t.targetLinks) {
1019
+ if (r === e) break;
1020
+ n -= i;
1021
+ }
1022
+ return n;
1023
+ }
1024
+ function k(e, t) {
1025
+ let n = t.y0 - (t.targetLinks.length - 1) * o / 2;
1026
+ for (let { source: r, width: i } of t.targetLinks) {
1027
+ if (r === e) break;
1028
+ n += i + o;
1029
+ }
1030
+ for (let { target: r, width: i } of e.sourceLinks) {
1031
+ if (r === t) break;
1032
+ n -= i;
1033
+ }
1034
+ return n;
1035
+ }
1036
+ return m;
1037
+ }
1038
+ var $ = 4;
1039
+ function at(e) {
1040
+ let { columns: t, sankeyNodes: n, sankeyLinks: r, columnWidth: i, columnGap: a, nodePadding: o, top: s, rect: c } = e, l = t.map((e) => e.field), u = (e) => l.indexOf(e.data.source.field), d = t.find((e) => !!e.sort) ? (e, n) => t[e.layer].sort?.(e, n) : void 0, f = [[0, s + $], [c.width, c.height - 2 * $]];
1041
+ it().nodeId((e) => e.id).nodePadding(o).nodeWidth(i).linkSort((e, t) => e.dataFill && t.dataFill ? G(e, t) : e.dataFill ? 1 : -1).nodeSort(d).nodeAlign(u).extent(f).iterations(6)({
1042
+ nodes: n,
1043
+ links: r
1044
+ });
1045
+ let p = Xe(t, n, a), { nodes: m, links: h } = Je(n, r);
1046
+ return Ye(m, h, f), {
1047
+ nodes: m,
1048
+ links: h,
1049
+ columns: p
1050
+ };
1051
+ }
1052
+ var ot = {
1053
+ require: [
1054
+ "resolver",
1055
+ "chart",
1056
+ "renderer"
1057
+ ],
1058
+ defaultSettings: {
1059
+ settings: W,
1060
+ style: {
1061
+ title: "$title",
1062
+ label: "$label"
1063
+ }
1064
+ },
1065
+ render({ data: e }) {
1066
+ let { settings: t } = this.settings, n = Fe({
1067
+ data: e,
1068
+ resolver: this.resolver,
1069
+ settings: t
1070
+ }), r = Pe({
1071
+ data: e,
1072
+ resolver: this.resolver,
1073
+ settings: t,
1074
+ resolvedNodes: n
1075
+ }), i = Ke(t, n, r, this.chart.dataset()), { columnGap: a, columnWidth: o, nodePadding: s, availableHeight: c, nodeLabelHeight: l, nodeMargin: u, top: d, showHeader: f, headerTitleHeight: p, canShowNodeLabelAboveNode: m } = Ze(i, t, this.rect, this.renderer, this.style);
1076
+ if (c < 8) return [];
1077
+ let h = [];
1078
+ ({nodes: n, links: r, columns: h} = at({
1079
+ columns: i,
1080
+ sankeyNodes: n,
1081
+ sankeyLinks: r,
1082
+ columnWidth: o,
1083
+ columnGap: a,
1084
+ nodePadding: s,
1085
+ top: d,
1086
+ rect: this.rect
1087
+ }));
1088
+ let g = Ie(n, { nodeMargin: u }), _ = We(n, g, h, {
1089
+ nodeLabelHeight: l,
1090
+ canShowNodeLabelAboveNode: m,
1091
+ nodePadding: s,
1092
+ nodeMargin: u,
1093
+ showDimensionLabel: t.showNodeDimensionLabel,
1094
+ showFlowLabel: t.showNodeFlowLabel,
1095
+ backdropColor: t.nodeLabelBackdropColor,
1096
+ showBackdrop: t.showNodeLabelBackdrop,
1097
+ priority: t.nodeLabelPlacements
1098
+ });
1099
+ return [
1100
+ ...Ne(r),
1101
+ ...g,
1102
+ ...f ? Ge(h, { headerHeight: p }) : [],
1103
+ ..._
1104
+ ];
1105
+ }
1106
+ };
1107
+ function st(e) {
1108
+ e.component(P.Sankey, ot);
1109
+ }
1110
+ var ct = y(), lt = _(({ vSpec: e, vTheme: t, data: n, elementSize: i, vizProperties: a }) => {
1111
+ let o = g(), [s] = (0, fe.useState)(() => new je()), c = t || r, d = v(), f = m(), p = d.targetDataItemId;
1112
+ if (!p && d.targetInternalKey) {
1113
+ let t = e.dimensions.find((e) => e.dataItem.internalKey === d.targetInternalKey);
1114
+ t && (p = l(t.dataItem));
1115
+ }
1116
+ let h = {
1117
+ ...a,
1118
+ valuePickerMode: !!d.activeKey,
1119
+ valuePickerTargetDataItemId: p
1120
+ }, _ = s.compile(e, c, n, i, h, u.Sankey, o, f, ne());
1121
+ return _ ? /* @__PURE__ */ (0, ct.jsx)(O, {
1122
+ config: a,
1123
+ definition: _,
1124
+ size: i,
1125
+ vSpec: e,
1126
+ escobarPlugins: [st]
1127
+ }) : null;
1128
+ });
1129
+ export { lt as Sankey };