@carto/ps-react-ui 4.6.2 → 4.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{download-config-C3I0jWIL.js → download-config-DNLkypdN.js} +8 -7
- package/dist/{download-config-C3I0jWIL.js.map → download-config-DNLkypdN.js.map} +1 -1
- package/dist/options-CthfUJDz.js +46 -0
- package/dist/options-CthfUJDz.js.map +1 -0
- package/dist/shared-resize-observer-98b1SK1e.js +17 -0
- package/dist/shared-resize-observer-98b1SK1e.js.map +1 -0
- package/dist/styles-BYTyKQFP.js +142 -0
- package/dist/{styles-Y8q7Jff3.js.map → styles-BYTyKQFP.js.map} +1 -1
- package/dist/types/widgets/actions/brush-toggle/brush-overlay.d.ts +24 -0
- package/dist/types/widgets/actions/brush-toggle/brush-toggle.d.ts +15 -10
- package/dist/types/widgets/actions/brush-toggle/hit-test.d.ts +19 -0
- package/dist/types/widgets/actions/brush-toggle/hit-test.test.d.ts +1 -0
- package/dist/types/widgets/actions/brush-toggle/style.d.ts +8 -0
- package/dist/types/widgets/actions/brush-toggle/types.d.ts +35 -1
- package/dist/types/widgets/utils/chart-config/index.d.ts +1 -1
- package/dist/types/widgets/utils/chart-config/option-builders.d.ts +27 -0
- package/dist/widgets/actions.js +985 -772
- package/dist/widgets/actions.js.map +1 -1
- package/dist/widgets/bar.js +34 -30
- package/dist/widgets/bar.js.map +1 -1
- package/dist/widgets/category.js +9 -8
- package/dist/widgets/category.js.map +1 -1
- package/dist/widgets/echart.js +79 -91
- package/dist/widgets/echart.js.map +1 -1
- package/dist/widgets/formula.js +43 -42
- package/dist/widgets/formula.js.map +1 -1
- package/dist/widgets/histogram.js +67 -63
- package/dist/widgets/histogram.js.map +1 -1
- package/dist/widgets/markdown.js +15 -14
- package/dist/widgets/markdown.js.map +1 -1
- package/dist/widgets/pie.js +38 -37
- package/dist/widgets/pie.js.map +1 -1
- package/dist/widgets/scatterplot.js +31 -30
- package/dist/widgets/scatterplot.js.map +1 -1
- package/dist/widgets/spread.js +47 -46
- package/dist/widgets/spread.js.map +1 -1
- package/dist/widgets/table.js +17 -16
- package/dist/widgets/table.js.map +1 -1
- package/dist/widgets/timeseries.js +35 -34
- package/dist/widgets/timeseries.js.map +1 -1
- package/dist/widgets/utils.js +2 -2
- package/package.json +3 -1
- package/src/widgets/actions/brush-toggle/brush-overlay.tsx +386 -0
- package/src/widgets/actions/brush-toggle/brush-toggle.tsx +88 -152
- package/src/widgets/actions/brush-toggle/hit-test.test.ts +65 -0
- package/src/widgets/actions/brush-toggle/hit-test.ts +45 -0
- package/src/widgets/actions/brush-toggle/style.ts +32 -0
- package/src/widgets/actions/brush-toggle/types.ts +36 -1
- package/src/widgets/bar/config.ts +5 -0
- package/src/widgets/echart/options.ts +1 -4
- package/src/widgets/histogram/config.ts +9 -4
- package/src/widgets/pie/config.ts +2 -0
- package/src/widgets/scatterplot/config.ts +2 -0
- package/src/widgets/timeseries/config.ts +2 -0
- package/src/widgets/utils/chart-config/index.ts +2 -0
- package/src/widgets/utils/chart-config/option-builders.test.ts +105 -1
- package/src/widgets/utils/chart-config/option-builders.ts +56 -0
- package/dist/options-D9wflre6.js +0 -49
- package/dist/options-D9wflre6.js.map +0 -1
- package/dist/styles-Y8q7Jff3.js +0 -118
package/dist/widgets/echart.js
CHANGED
|
@@ -1,132 +1,120 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { c as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import * as
|
|
5
|
-
import { u as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { g as
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return I ??= new ResizeObserver((t) => {
|
|
13
|
-
for (const e of t)
|
|
14
|
-
z.get(e.target)?.();
|
|
15
|
-
}), I;
|
|
16
|
-
}
|
|
17
|
-
function H(t, e) {
|
|
18
|
-
return z.set(t, e), S().observe(t), () => {
|
|
19
|
-
z.delete(t), S().unobserve(t);
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
function N(t) {
|
|
23
|
-
const e = W(21), {
|
|
1
|
+
import { jsx as S } from "react/jsx-runtime";
|
|
2
|
+
import { c as j } from "react/compiler-runtime";
|
|
3
|
+
import { useRef as W, useImperativeHandle as k, useEffect as x } from "react";
|
|
4
|
+
import * as U from "echarts";
|
|
5
|
+
import { u as Z } from "../use-widget-ref-Ddr_SlJJ.js";
|
|
6
|
+
import { o as $ } from "../shared-resize-observer-98b1SK1e.js";
|
|
7
|
+
import { u as B } from "../use-widget-selector-DFl2hW0R.js";
|
|
8
|
+
import { g as Q } from "../options-CthfUJDz.js";
|
|
9
|
+
import { g as V, a as X, b as Y, m as w } from "../utils-BOhInag6.js";
|
|
10
|
+
function D(r) {
|
|
11
|
+
const t = j(21), {
|
|
24
12
|
id: a,
|
|
25
|
-
ref:
|
|
13
|
+
ref: m,
|
|
26
14
|
init: c,
|
|
27
15
|
option: u,
|
|
28
16
|
className: f,
|
|
29
17
|
style: l,
|
|
30
|
-
onEvents:
|
|
31
|
-
} =
|
|
32
|
-
ref:
|
|
33
|
-
instance:
|
|
34
|
-
} =
|
|
35
|
-
let s,
|
|
36
|
-
|
|
18
|
+
onEvents: o
|
|
19
|
+
} = r, {
|
|
20
|
+
ref: e,
|
|
21
|
+
instance: i
|
|
22
|
+
} = Z(a), n = W(null);
|
|
23
|
+
let s, d;
|
|
24
|
+
t[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (s = () => n.current, d = [], t[0] = s, t[1] = d) : (s = t[0], d = t[1]), k(m, s, d);
|
|
37
25
|
let g, h;
|
|
38
|
-
|
|
39
|
-
if (
|
|
40
|
-
return n.current =
|
|
26
|
+
t[2] !== i || t[3] !== e || t[4] !== c ? (g = () => {
|
|
27
|
+
if (e.current)
|
|
28
|
+
return n.current = U.init(e.current, null, {
|
|
41
29
|
renderer: "svg",
|
|
42
30
|
height: 304,
|
|
43
31
|
...c
|
|
44
|
-
}),
|
|
45
|
-
n.current?.dispose(), n.current = null,
|
|
32
|
+
}), i.current = n.current, () => {
|
|
33
|
+
n.current?.dispose(), n.current = null, i.current = null;
|
|
46
34
|
};
|
|
47
|
-
}, h = [
|
|
48
|
-
let
|
|
49
|
-
|
|
35
|
+
}, h = [i, e, c], t[2] = i, t[3] = e, t[4] = c, t[5] = g, t[6] = h) : (g = t[5], h = t[6]), x(g, h);
|
|
36
|
+
let p, E;
|
|
37
|
+
t[7] !== u ? (p = () => {
|
|
50
38
|
n.current?.setOption(u, {
|
|
51
39
|
lazyUpdate: !0,
|
|
52
40
|
notMerge: !0
|
|
53
41
|
});
|
|
54
|
-
},
|
|
55
|
-
let
|
|
56
|
-
|
|
57
|
-
if (
|
|
58
|
-
return
|
|
42
|
+
}, E = [u], t[7] = u, t[8] = p, t[9] = E) : (p = t[8], E = t[9]), x(p, E);
|
|
43
|
+
let v, C;
|
|
44
|
+
t[10] !== e ? (v = () => {
|
|
45
|
+
if (e.current)
|
|
46
|
+
return $(e.current, () => {
|
|
59
47
|
n.current?.resize();
|
|
60
48
|
});
|
|
61
|
-
},
|
|
62
|
-
let
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
...
|
|
49
|
+
}, C = [e], t[10] = e, t[11] = v, t[12] = C) : (v = t[11], C = t[12]), x(v, C);
|
|
50
|
+
let b, O;
|
|
51
|
+
t[13] !== o ? (b = () => {
|
|
52
|
+
const _ = {
|
|
53
|
+
...o ?? {}
|
|
66
54
|
};
|
|
67
|
-
return
|
|
55
|
+
return _.click || (_.mousemove = () => {
|
|
68
56
|
n.current?.getZr().setCursorStyle("default");
|
|
69
|
-
}), Object.entries(
|
|
70
|
-
const [
|
|
71
|
-
n.current?.on(
|
|
57
|
+
}), Object.entries(_).forEach((y) => {
|
|
58
|
+
const [I, z] = y;
|
|
59
|
+
n.current?.on(I, z);
|
|
72
60
|
}), () => {
|
|
73
|
-
Object.entries(
|
|
74
|
-
const [
|
|
75
|
-
n.current?.off(
|
|
61
|
+
Object.entries(_).forEach((y) => {
|
|
62
|
+
const [I] = y;
|
|
63
|
+
n.current?.off(I);
|
|
76
64
|
});
|
|
77
65
|
};
|
|
78
|
-
}, O = [
|
|
66
|
+
}, O = [o], t[13] = o, t[14] = b, t[15] = O) : (b = t[14], O = t[15]), x(b, O);
|
|
79
67
|
let R;
|
|
80
|
-
return
|
|
68
|
+
return t[16] !== e || t[17] !== f || t[18] !== a || t[19] !== l ? (R = /* @__PURE__ */ S("div", { id: a, ref: e, style: l, className: f }), t[16] = e, t[17] = f, t[18] = a, t[19] = l, t[20] = R) : R = t[20], R;
|
|
81
69
|
}
|
|
82
|
-
function
|
|
83
|
-
const
|
|
70
|
+
function K(r) {
|
|
71
|
+
const t = j(12), {
|
|
84
72
|
id: a,
|
|
85
|
-
data:
|
|
73
|
+
data: m,
|
|
86
74
|
widgetOption: c,
|
|
87
75
|
onEvents: u,
|
|
88
76
|
init: f
|
|
89
|
-
} =
|
|
77
|
+
} = B(r.id, H);
|
|
90
78
|
let l;
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
let
|
|
94
|
-
|
|
95
|
-
dataset:
|
|
96
|
-
},
|
|
97
|
-
let
|
|
98
|
-
|
|
79
|
+
t[0] !== m ? (l = M(m), t[0] = m, t[1] = l) : l = t[1];
|
|
80
|
+
const o = l;
|
|
81
|
+
let e;
|
|
82
|
+
t[2] !== o ? (e = o && {
|
|
83
|
+
dataset: o
|
|
84
|
+
}, t[2] = o, t[3] = e) : e = t[3];
|
|
85
|
+
let i;
|
|
86
|
+
t[4] !== e || t[5] !== c ? (i = {
|
|
99
87
|
...c,
|
|
100
|
-
...
|
|
101
|
-
},
|
|
102
|
-
const n =
|
|
88
|
+
...e
|
|
89
|
+
}, t[4] = e, t[5] = c, t[6] = i) : i = t[6];
|
|
90
|
+
const n = i;
|
|
103
91
|
if (!a)
|
|
104
92
|
return null;
|
|
105
93
|
let s;
|
|
106
|
-
return
|
|
94
|
+
return t[7] !== f || t[8] !== u || t[9] !== n || t[10] !== r.id ? (s = /* @__PURE__ */ S(D, { id: r.id, option: n, onEvents: u, init: f }), t[7] = f, t[8] = u, t[9] = n, t[10] = r.id, t[11] = s) : s = t[11], s;
|
|
107
95
|
}
|
|
108
|
-
function
|
|
96
|
+
function H(r) {
|
|
109
97
|
return {
|
|
110
|
-
id:
|
|
111
|
-
data:
|
|
112
|
-
widgetOption:
|
|
113
|
-
onEvents:
|
|
114
|
-
init:
|
|
98
|
+
id: r?.id,
|
|
99
|
+
data: r?.data,
|
|
100
|
+
widgetOption: r?.option,
|
|
101
|
+
onEvents: r?.onEvents,
|
|
102
|
+
init: r?.init
|
|
115
103
|
};
|
|
116
104
|
}
|
|
117
|
-
function
|
|
118
|
-
if (!(!
|
|
119
|
-
return
|
|
120
|
-
source:
|
|
105
|
+
function M(r) {
|
|
106
|
+
if (!(!r || r.length === 0))
|
|
107
|
+
return r.map((t) => ({
|
|
108
|
+
source: t
|
|
121
109
|
}));
|
|
122
110
|
}
|
|
123
111
|
export {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
112
|
+
K as Echart,
|
|
113
|
+
D as EchartUI,
|
|
114
|
+
Q as getCommonOptions,
|
|
115
|
+
V as getEChartBrushConfig,
|
|
116
|
+
X as getEChartStackConfig,
|
|
117
|
+
Y as getEChartZoomConfig,
|
|
118
|
+
w as mergeEchartWidgetConfig
|
|
131
119
|
};
|
|
132
120
|
//# sourceMappingURL=echart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"echart.js","sources":["../../src/widgets/echart/shared-resize-observer.ts","../../src/widgets/echart/echart-ui.tsx","../../src/widgets/echart/echart.tsx"],"sourcesContent":["/**\n * Shared ResizeObserver singleton for all ECharts instances.\n *\n * Instead of creating 100+ individual ResizeObserver instances (one per chart),\n * this module provides a single shared observer that efficiently handles resize\n * callbacks for all registered elements.\n */\n\ntype ResizeCallback = () => void\n\nconst callbacks = new Map<Element, ResizeCallback>()\n\nlet observer: ResizeObserver | null = null\n\nfunction getObserver(): ResizeObserver {\n observer ??= new ResizeObserver((entries) => {\n for (const entry of entries) {\n const callback = callbacks.get(entry.target)\n callback?.()\n }\n })\n return observer\n}\n\nexport function observeResize(\n element: Element,\n callback: ResizeCallback,\n): () => void {\n callbacks.set(element, callback)\n getObserver().observe(element)\n\n return () => {\n callbacks.delete(element)\n getObserver().unobserve(element)\n }\n}\n\n/** Reset the shared observer (for testing only). */\nexport function resetSharedResizeObserver(): void {\n if (observer) {\n observer.disconnect()\n observer = null\n }\n callbacks.clear()\n}\n","import { useEffect, useRef, useImperativeHandle } from 'react'\nimport * as echarts from 'echarts'\nimport type { EchartUIProps } from './types'\nimport { useWidgetRef } from '../../hooks'\nimport { observeResize } from './shared-resize-observer'\n\n/**\n * Presentational component that initializes and manages an Apache ECharts instance.\n *\n * @remarks\n * Handles chart lifecycle (init, dispose), option updates, resize observation, and event listener management.\n * Uses SVG renderer with a default height of 304px.\n */\nexport function EchartUI(props: EchartUIProps) {\n const { id, ref, init, option, className, style, onEvents } = props\n\n const { ref: chartRef, instance: chartInstanceRef } =\n useWidgetRef<HTMLDivElement>(id)\n const chartInstance = useRef<echarts.ECharts>(null)\n\n useImperativeHandle(ref, () => chartInstance.current!, [])\n\n useEffect(() => {\n if (!chartRef.current) return\n\n chartInstance.current = echarts.init(chartRef.current, null, {\n renderer: 'svg',\n height: 304,\n ...init,\n })\n chartInstanceRef.current = chartInstance.current\n // Cleanup function\n return () => {\n chartInstance.current?.dispose()\n chartInstance.current = null\n chartInstanceRef.current = null\n }\n }, [chartInstanceRef, chartRef, init])\n\n // Update chart when options change\n useEffect(() => {\n chartInstance.current?.setOption(option, {\n lazyUpdate: true,\n notMerge: true,\n })\n }, [option])\n\n // Handle resize using shared ResizeObserver (single instance for all charts)\n useEffect(() => {\n if (!chartRef.current) return\n\n return observeResize(chartRef.current, () => {\n chartInstance.current?.resize()\n })\n }, [chartRef])\n\n useEffect(() => {\n const _onEvents = { ...(onEvents ?? {}) }\n if (!_onEvents.click) {\n _onEvents.mousemove = () => {\n chartInstance.current?.getZr().setCursorStyle('default')\n }\n }\n\n // Attach event listeners\n Object.entries(_onEvents).forEach(([event, handler]) => {\n chartInstance.current?.on(event, handler)\n })\n // Cleanup function to remove event listeners\n return () => {\n Object.entries(_onEvents).forEach(([event]) => {\n chartInstance.current?.off(event)\n })\n }\n }, [onEvents])\n\n return <div id={id} ref={chartRef} style={style} className={className} />\n}\n","import type {\n EchartProps,\n EchartWidgetState,\n EchartWidgetData,\n EchartOptionsProps,\n} from './types'\nimport { EchartUI } from './echart-ui'\nimport { useWidgetSelector } from '../stores/use-widget-selector'\nimport { useMemo } from 'react'\n\n/**\n * Stateful EChart widget component that reads data and options from the widget store and renders an ECharts chart.\n *\n * @remarks\n * Transforms widget data into ECharts dataset format and delegates rendering to {@link EchartUI}.\n */\nexport function Echart(props: EchartProps) {\n // Single consolidated subscription instead of 5 separate ones.\n const { id, data, widgetOption, onEvents, init } = useWidgetSelector(\n props.id,\n (w) => ({\n id: w?.id,\n data: (w as EchartWidgetState | undefined)?.data as\n | EchartWidgetData\n | undefined,\n widgetOption: (w as EchartWidgetState | undefined)?.option,\n onEvents: (w as EchartWidgetState | undefined)?.onEvents,\n init: (w as EchartWidgetState | undefined)?.init,\n }),\n )\n\n // Memoize dataset transformation to avoid re-computing on every render\n const dataset = useMemo(() => buildDataset(data), [data])\n\n const option = useMemo<EchartOptionsProps>(\n () => ({\n ...widgetOption,\n ...(dataset && { dataset }),\n }),\n [widgetOption, dataset],\n )\n\n if (!id) {\n return null\n }\n\n return (\n <EchartUI id={props.id} option={option} onEvents={onEvents} init={init} />\n )\n}\n\n/**\n * Builds the dataset configuration from widget data\n * @param data - The widget data array\n * @returns The dataset configuration for ECharts\n */\nfunction buildDataset(\n data: EchartWidgetData | undefined,\n): EchartOptionsProps['dataset'] {\n if (!data || data.length === 0) {\n return undefined\n }\n\n return data.map((d) => ({\n source: d,\n }))\n}\n"],"names":["callbacks","Map","observer","getObserver","ResizeObserver","entries","entry","callback","get","target","observeResize","element","set","observe","delete","unobserve","EchartUI","props","$","_c","id","ref","init","option","className","style","onEvents","chartRef","instance","chartInstanceRef","useWidgetRef","chartInstance","useRef","t0","t1","Symbol","for","current","useImperativeHandle","t2","t3","echarts","renderer","height","dispose","useEffect","t4","t5","setOption","lazyUpdate","notMerge","t6","t7","resize","t8","t9","_onEvents","click","mousemove","getZr","setCursorStyle","Object","forEach","t10","event","handler","on","t11","event_0","off","Echart","data","widgetOption","useWidgetSelector","_temp","buildDataset","dataset","w","length","map","d","source"],"mappings":";;;;;;;;AAUA,MAAMA,wBAAgBC,IAAAA;AAEtB,IAAIC,IAAkC;AAEtC,SAASC,IAA8B;AACrCD,SAAAA,MAAa,IAAIE,eAAgBC,CAAAA,MAAY;AAC3C,eAAWC,KAASD;AAElBE,MADiBP,EAAUQ,IAAIF,EAAMG,MAAM,IAC3CF;AAAAA,EAEJ,CAAC,GACML;AACT;AAEO,SAASQ,EACdC,GACAJ,GACY;AACZP,SAAAA,EAAUY,IAAID,GAASJ,CAAQ,GAC/BJ,EAAAA,EAAcU,QAAQF,CAAO,GAEtB,MAAM;AACXX,IAAAA,EAAUc,OAAOH,CAAO,GACxBR,EAAAA,EAAcY,UAAUJ,CAAO;AAAA,EACjC;AACF;ACtBO,SAAAK,EAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,EAAA,GACL;AAAA,IAAAC,IAAAA;AAAAA,IAAAC,KAAAA;AAAAA,IAAAC,MAAAA;AAAAA,IAAAC,QAAAA;AAAAA,IAAAC,WAAAA;AAAAA,IAAAC,OAAAA;AAAAA,IAAAC,UAAAA;AAAAA,EAAAA,IAA8DT,GAE9D;AAAA,IAAAI,KAAAM;AAAAA,IAAAC,UAAAC;AAAAA,EAAAA,IACEC,EAA6BV,CAAE,GACjCW,IAAsBC,EAAwB,IAAI;AAAC,MAAAC,GAAAC;AAA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AAAG,IAAAF,QAAAsB,KAAAA,IAAAtB,EAAA,EAAA,GAA1EsB;AAA0E;AA/BvE,SAAAkC,EAAAG,GAAA;AAAA,SAIK;AAAA,IAAAzD,IACFyD,GAACzD;AAAAA,IAAImD,MACFM,GAAyCN;AAAAA,IAEnCC,cACEK,GAA2CtD;AAAAA,IAAAG,UAC/CmD,GAA6CnD;AAAAA,IAAAJ,MACjDuD,GAAyCvD;AAAAA,EAAAA;AACjD;AA4BL,SAASqD,EACPJ,GAC+B;AAC/B,MAAI,GAACA,KAAQA,EAAKO,WAAW;AAI7B,WAAOP,EAAKQ,IAAKC,CAAAA,OAAO;AAAA,MACtBC,QAAQD;AAAAA,IAAAA,EACR;AACJ;"}
|
|
1
|
+
{"version":3,"file":"echart.js","sources":["../../src/widgets/echart/echart-ui.tsx","../../src/widgets/echart/echart.tsx"],"sourcesContent":["import { useEffect, useRef, useImperativeHandle } from 'react'\nimport * as echarts from 'echarts'\nimport type { EchartUIProps } from './types'\nimport { useWidgetRef } from '../../hooks'\nimport { observeResize } from './shared-resize-observer'\n\n/**\n * Presentational component that initializes and manages an Apache ECharts instance.\n *\n * @remarks\n * Handles chart lifecycle (init, dispose), option updates, resize observation, and event listener management.\n * Uses SVG renderer with a default height of 304px.\n */\nexport function EchartUI(props: EchartUIProps) {\n const { id, ref, init, option, className, style, onEvents } = props\n\n const { ref: chartRef, instance: chartInstanceRef } =\n useWidgetRef<HTMLDivElement>(id)\n const chartInstance = useRef<echarts.ECharts>(null)\n\n useImperativeHandle(ref, () => chartInstance.current!, [])\n\n useEffect(() => {\n if (!chartRef.current) return\n\n chartInstance.current = echarts.init(chartRef.current, null, {\n renderer: 'svg',\n height: 304,\n ...init,\n })\n chartInstanceRef.current = chartInstance.current\n // Cleanup function\n return () => {\n chartInstance.current?.dispose()\n chartInstance.current = null\n chartInstanceRef.current = null\n }\n }, [chartInstanceRef, chartRef, init])\n\n // Update chart when options change\n useEffect(() => {\n chartInstance.current?.setOption(option, {\n lazyUpdate: true,\n notMerge: true,\n })\n }, [option])\n\n // Handle resize using shared ResizeObserver (single instance for all charts)\n useEffect(() => {\n if (!chartRef.current) return\n\n return observeResize(chartRef.current, () => {\n chartInstance.current?.resize()\n })\n }, [chartRef])\n\n useEffect(() => {\n const _onEvents = { ...(onEvents ?? {}) }\n if (!_onEvents.click) {\n _onEvents.mousemove = () => {\n chartInstance.current?.getZr().setCursorStyle('default')\n }\n }\n\n // Attach event listeners\n Object.entries(_onEvents).forEach(([event, handler]) => {\n chartInstance.current?.on(event, handler)\n })\n // Cleanup function to remove event listeners\n return () => {\n Object.entries(_onEvents).forEach(([event]) => {\n chartInstance.current?.off(event)\n })\n }\n }, [onEvents])\n\n return <div id={id} ref={chartRef} style={style} className={className} />\n}\n","import type {\n EchartProps,\n EchartWidgetState,\n EchartWidgetData,\n EchartOptionsProps,\n} from './types'\nimport { EchartUI } from './echart-ui'\nimport { useWidgetSelector } from '../stores/use-widget-selector'\nimport { useMemo } from 'react'\n\n/**\n * Stateful EChart widget component that reads data and options from the widget store and renders an ECharts chart.\n *\n * @remarks\n * Transforms widget data into ECharts dataset format and delegates rendering to {@link EchartUI}.\n */\nexport function Echart(props: EchartProps) {\n // Single consolidated subscription instead of 5 separate ones.\n const { id, data, widgetOption, onEvents, init } = useWidgetSelector(\n props.id,\n (w) => ({\n id: w?.id,\n data: (w as EchartWidgetState | undefined)?.data as\n | EchartWidgetData\n | undefined,\n widgetOption: (w as EchartWidgetState | undefined)?.option,\n onEvents: (w as EchartWidgetState | undefined)?.onEvents,\n init: (w as EchartWidgetState | undefined)?.init,\n }),\n )\n\n // Memoize dataset transformation to avoid re-computing on every render\n const dataset = useMemo(() => buildDataset(data), [data])\n\n const option = useMemo<EchartOptionsProps>(\n () => ({\n ...widgetOption,\n ...(dataset && { dataset }),\n }),\n [widgetOption, dataset],\n )\n\n if (!id) {\n return null\n }\n\n return (\n <EchartUI id={props.id} option={option} onEvents={onEvents} init={init} />\n )\n}\n\n/**\n * Builds the dataset configuration from widget data\n * @param data - The widget data array\n * @returns The dataset configuration for ECharts\n */\nfunction buildDataset(\n data: EchartWidgetData | undefined,\n): EchartOptionsProps['dataset'] {\n if (!data || data.length === 0) {\n return undefined\n }\n\n return data.map((d) => ({\n source: d,\n }))\n}\n"],"names":["EchartUI","props","$","_c","id","ref","init","option","className","style","onEvents","chartRef","instance","chartInstanceRef","useWidgetRef","chartInstance","useRef","t0","t1","Symbol","for","current","useImperativeHandle","t2","t3","echarts","renderer","height","dispose","useEffect","t4","t5","setOption","lazyUpdate","notMerge","t6","t7","observeResize","resize","t8","t9","_onEvents","click","mousemove","getZr","setCursorStyle","Object","entries","forEach","t10","event","handler","on","t11","event_0","off","Echart","data","widgetOption","useWidgetSelector","_temp","buildDataset","dataset","w","length","map","d","source"],"mappings":";;;;;;;;;AAaO,SAAAA,EAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,EAAA,GACL;AAAA,IAAAC,IAAAA;AAAAA,IAAAC,KAAAA;AAAAA,IAAAC,MAAAA;AAAAA,IAAAC,QAAAA;AAAAA,IAAAC,WAAAA;AAAAA,IAAAC,OAAAA;AAAAA,IAAAC,UAAAA;AAAAA,EAAAA,IAA8DT,GAE9D;AAAA,IAAAI,KAAAM;AAAAA,IAAAC,UAAAC;AAAAA,EAAAA,IACEC,EAA6BV,CAAE,GACjCW,IAAsBC,EAAwB,IAAI;AAAC,MAAAC,GAAAC;AAAA,EAAAhB,EAAA,CAAA,MAAAiB,uBAAAC,IAAA,2BAAA,KAE1BH,IAAAA,MAAMF,EAAaM,SAAWH,IAAA,CAAA,GAAEhB,OAAAe,GAAAf,OAAAgB,MAAAD,IAAAf,EAAA,CAAA,GAAAgB,IAAAhB,EAAA,CAAA,IAAzDoB,EAAoBjB,GAAKY,GAA8BC,CAAE;AAAC,MAAAK,GAAAC;AAAA,EAAAtB,EAAA,CAAA,MAAAW,KAAAX,SAAAS,KAAAT,EAAA,CAAA,MAAAI,KAEhDiB,IAAAA,MAAA;AACR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AAW;AAI7B,WAAOP,EAAKQ,IAAKC,CAAAA,OAAO;AAAA,MACtBC,QAAQD;AAAAA,IAAAA,EACR;AACJ;"}
|
package/dist/widgets/formula.js
CHANGED
|
@@ -15,107 +15,108 @@ import "../cjs-D4KH3azB.js";
|
|
|
15
15
|
import "@dnd-kit/core";
|
|
16
16
|
import "@dnd-kit/sortable";
|
|
17
17
|
import "@dnd-kit/utilities";
|
|
18
|
+
import "react-dom";
|
|
18
19
|
import { u as j } from "../use-widget-ref-Ddr_SlJJ.js";
|
|
19
|
-
function z(
|
|
20
|
-
const
|
|
20
|
+
function z(e) {
|
|
21
|
+
const t = g(15);
|
|
21
22
|
let r, i, o;
|
|
22
|
-
|
|
23
|
+
t[0] !== e ? ({
|
|
23
24
|
id: r,
|
|
24
25
|
index: o,
|
|
25
26
|
...i
|
|
26
|
-
} =
|
|
27
|
+
} = e, t[0] = e, t[1] = r, t[2] = i, t[3] = o) : (r = t[1], i = t[2], o = t[3]);
|
|
27
28
|
const n = o === void 0 ? 0 : o;
|
|
28
29
|
let a;
|
|
29
|
-
|
|
30
|
+
t[4] !== n ? (a = (w) => {
|
|
30
31
|
const p = w;
|
|
31
32
|
return {
|
|
32
33
|
value: p?.data?.[n]?.value,
|
|
33
34
|
color: p?.data?.[n]?.color,
|
|
34
35
|
formatter: p?.formatter ?? C
|
|
35
36
|
};
|
|
36
|
-
},
|
|
37
|
+
}, t[4] = n, t[5] = a) : a = t[5];
|
|
37
38
|
const {
|
|
38
39
|
value: l,
|
|
39
40
|
color: u,
|
|
40
41
|
formatter: c
|
|
41
42
|
} = R(r, a);
|
|
42
43
|
let m;
|
|
43
|
-
|
|
44
|
+
t[6] !== u ? (m = {
|
|
44
45
|
color: u
|
|
45
|
-
},
|
|
46
|
+
}, t[6] = u, t[7] = m) : m = t[7];
|
|
46
47
|
const x = l ?? 0;
|
|
47
48
|
let s;
|
|
48
|
-
|
|
49
|
+
t[8] !== c || t[9] !== x ? (s = c(x), t[8] = c, t[9] = x, t[10] = s) : s = t[10];
|
|
49
50
|
let d;
|
|
50
|
-
return
|
|
51
|
+
return t[11] !== i || t[12] !== m || t[13] !== s ? (d = /* @__PURE__ */ f(y, { TypographyProps: m, ...i, children: s }), t[11] = i, t[12] = m, t[13] = s, t[14] = d) : d = t[14], d;
|
|
51
52
|
}
|
|
52
|
-
function
|
|
53
|
-
refUI:
|
|
53
|
+
function tt({
|
|
54
|
+
refUI: e
|
|
54
55
|
}) {
|
|
55
56
|
return [{
|
|
56
57
|
...h,
|
|
57
|
-
modifier: () => h.modifier(
|
|
58
|
+
modifier: () => h.modifier(e)
|
|
58
59
|
}, {
|
|
59
60
|
...S,
|
|
60
|
-
modifier: async (
|
|
61
|
-
const r = [
|
|
61
|
+
modifier: async (t) => {
|
|
62
|
+
const r = [t?.map((i) => i.value) ?? []];
|
|
62
63
|
return S.modifier(r);
|
|
63
64
|
}
|
|
64
65
|
}];
|
|
65
66
|
}
|
|
66
|
-
function
|
|
67
|
+
function et() {
|
|
67
68
|
return {
|
|
68
69
|
series: []
|
|
69
70
|
};
|
|
70
71
|
}
|
|
71
|
-
function
|
|
72
|
-
const
|
|
72
|
+
function it(e) {
|
|
73
|
+
const t = g(8), {
|
|
73
74
|
ref: r
|
|
74
|
-
} = j(
|
|
75
|
+
} = j(e.id);
|
|
75
76
|
let i;
|
|
76
|
-
|
|
77
|
+
t[0] !== e.id ? (i = (a) => {
|
|
77
78
|
const {
|
|
78
79
|
index: l
|
|
79
80
|
} = a;
|
|
80
81
|
return /* @__PURE__ */ P(k, { children: [
|
|
81
|
-
/* @__PURE__ */ f(F, { id:
|
|
82
|
-
/* @__PURE__ */ f(I, { id:
|
|
83
|
-
/* @__PURE__ */ f(z, { id:
|
|
84
|
-
/* @__PURE__ */ f(D, { id:
|
|
82
|
+
/* @__PURE__ */ f(F, { id: e.id, index: l }),
|
|
83
|
+
/* @__PURE__ */ f(I, { id: e.id, index: l }),
|
|
84
|
+
/* @__PURE__ */ f(z, { id: e.id, index: l }),
|
|
85
|
+
/* @__PURE__ */ f(D, { id: e.id, index: l })
|
|
85
86
|
] });
|
|
86
|
-
},
|
|
87
|
+
}, t[0] = e.id, t[1] = i) : i = t[1];
|
|
87
88
|
let o;
|
|
88
|
-
|
|
89
|
+
t[2] !== e.id || t[3] !== i ? (o = /* @__PURE__ */ f(T, { id: e.id, children: i }), t[2] = e.id, t[3] = i, t[4] = o) : o = t[4];
|
|
89
90
|
let n;
|
|
90
|
-
return
|
|
91
|
+
return t[5] !== r || t[6] !== o ? (n = /* @__PURE__ */ f(v, { ref: r, children: o }), t[5] = r, t[6] = o, t[7] = n) : n = t[7], n;
|
|
91
92
|
}
|
|
92
|
-
function
|
|
93
|
-
const
|
|
94
|
-
let
|
|
95
|
-
return
|
|
93
|
+
function ot() {
|
|
94
|
+
const e = g(1);
|
|
95
|
+
let t;
|
|
96
|
+
return e[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t = /* @__PURE__ */ f(v, { sx: $.row, "aria-label": "Formula skeleton", children: /* @__PURE__ */ f(b, { width: 120, height: 32 }) }), e[0] = t) : t = e[0], t;
|
|
96
97
|
}
|
|
97
|
-
function V(
|
|
98
|
+
function V(e) {
|
|
98
99
|
return {
|
|
99
|
-
...
|
|
100
|
-
prefix: typeof
|
|
101
|
-
suffix: typeof
|
|
100
|
+
...e,
|
|
101
|
+
prefix: typeof e.prefix == "string" ? e.prefix : void 0,
|
|
102
|
+
suffix: typeof e.suffix == "string" ? e.suffix : void 0
|
|
102
103
|
};
|
|
103
104
|
}
|
|
104
|
-
function
|
|
105
|
-
return
|
|
105
|
+
function rt(e) {
|
|
106
|
+
return e?.map(V);
|
|
106
107
|
}
|
|
107
108
|
export {
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
ot as FormulaSkeleton,
|
|
110
|
+
it as FormulaUI,
|
|
110
111
|
y as Item,
|
|
111
112
|
I as Prefix,
|
|
112
113
|
T as Row,
|
|
113
114
|
F as Series,
|
|
114
115
|
D as Suffix,
|
|
115
116
|
z as Value,
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
et as formulaConfig,
|
|
118
|
+
tt as formulaDownloadConfig,
|
|
118
119
|
V as sanitizeDataItem,
|
|
119
|
-
|
|
120
|
+
rt as sanitizeDataItems
|
|
120
121
|
};
|
|
121
122
|
//# sourceMappingURL=formula.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formula.js","sources":["../../src/widgets/formula/components/value.tsx","../../src/widgets/formula/config.ts","../../src/widgets/formula/formula-ui.tsx","../../src/widgets/formula/skeleton.tsx","../../src/widgets/formula/serializer.ts"],"sourcesContent":["import { type FormulaWidgetState, type ValueProps } from '../types'\nimport { Item } from './item'\nimport { defaultFormatter } from '../../utils/formatter'\nimport { useWidgetSelector } from '../../stores/use-widget-selector'\n\n/**\n * Displays the formatted numeric value for a formula widget data item, applying the widget's formatter and color.\n */\nexport function Value({ id, index = 0, ...props }: ValueProps) {\n const { value, color, formatter } = useWidgetSelector(id, (w) => {\n const widget = w as FormulaWidgetState | undefined\n return {\n value: widget?.data?.[index]?.value,\n color: widget?.data?.[index]?.color,\n formatter: widget?.formatter ?? defaultFormatter,\n }\n })\n\n return (\n <Item TypographyProps={{ color }} {...props}>\n {formatter(value ?? 0)}\n </Item>\n )\n}\n","import { downloadToCSV, downloadToPNG } from '../actions'\nimport type { ConfigProps } from '../loader/types'\nimport type { FormulaDownloadConfig, FormulaWidgetConfig } from './types'\n\n/**\n * Creates download configuration for formula widgets, supporting PNG (screenshot) and CSV (data) exports.\n *\n * @param props - Configuration with `refUI` reference for PNG export.\n * @returns Array of download items for use with the Download action.\n */\nexport function formulaDownloadConfig({\n refUI,\n}: ConfigProps): FormulaDownloadConfig {\n return [\n {\n ...downloadToPNG,\n modifier: () => downloadToPNG.modifier(refUI),\n },\n {\n ...downloadToCSV,\n modifier: async (data) => {\n const formulaData = [data?.map((item) => item.value) ?? []]\n return downloadToCSV.modifier(formulaData)\n },\n },\n ]\n}\n\n/**\n * Returns the default configuration for formula (single or multiple numeric value) widgets.\n *\n * @returns Default formula widget config with empty series.\n */\nexport function formulaConfig(): FormulaWidgetConfig {\n return {\n series: [],\n }\n}\n","import type { FormulaUIProps } from './types'\nimport { Row } from './components/row'\nimport { Value } from './components/value'\nimport { Prefix } from './components/prefix'\nimport { Suffix } from './components/suffix'\nimport { Series } from './components/series'\nimport { useWidgetRef } from '../../hooks'\nimport { Box } from '@mui/material'\n\n/**\n * Renders a formula widget displaying one or more KPI values with optional prefixes, suffixes, and series indicators.\n */\nexport function FormulaUI(props: FormulaUIProps) {\n const { ref } = useWidgetRef(props.id)\n\n return (\n <Box ref={ref}>\n <Row id={props.id}>\n {({ index }) => (\n <>\n <Series id={props.id} index={index} />\n <Prefix id={props.id} index={index} />\n <Value id={props.id} index={index} />\n <Suffix id={props.id} index={index} />\n </>\n )}\n </Row>\n </Box>\n )\n}\n","import { Box, Skeleton } from '@mui/material'\nimport { styles } from './style'\n\nexport function FormulaSkeleton() {\n return (\n <Box sx={styles.row} aria-label='Formula skeleton'>\n <Skeleton width={120} height={32} />\n </Box>\n )\n}\n","import type { DataItem } from './types'\n\n/**\n * Sanitizes DataItem by converting ReactNode prefix/suffix values to undefined.\n * This ensures only string values are stored in the widget state.\n *\n * @param item - The DataItem to sanitize\n * @returns A new DataItem with ReactNode prefix/suffix values converted to undefined\n */\nexport function sanitizeDataItem(item: DataItem): DataItem {\n return {\n ...item,\n prefix: typeof item.prefix === 'string' ? item.prefix : undefined,\n suffix: typeof item.suffix === 'string' ? item.suffix : undefined,\n }\n}\n\n/**\n * Sanitizes an array of DataItems by converting ReactNode prefix/suffix values to undefined.\n *\n * @param items - Array of DataItems to sanitize\n * @returns A new array with sanitized DataItems\n */\nexport function sanitizeDataItems(\n items: DataItem[] | undefined,\n): DataItem[] | undefined {\n return items?.map(sanitizeDataItem)\n}\n"],"names":["Value","t0","$","_c","id","props","t1","index","undefined","t2","w","widget","value","data","color","formatter","defaultFormatter","useWidgetSelector","t3","t4","t5","t6","Item","formulaDownloadConfig","refUI","downloadToPNG","modifier","downloadToCSV","formulaData","map","item","formulaConfig","series","FormulaUI","ref","useWidgetRef","jsxs","Fragment","jsx","Series","Prefix","Suffix","Row","Box","FormulaSkeleton","Symbol","for","styles","row","Skeleton","sanitizeDataItem","prefix","suffix","sanitizeDataItems","items"],"mappings":"
|
|
1
|
+
{"version":3,"file":"formula.js","sources":["../../src/widgets/formula/components/value.tsx","../../src/widgets/formula/config.ts","../../src/widgets/formula/formula-ui.tsx","../../src/widgets/formula/skeleton.tsx","../../src/widgets/formula/serializer.ts"],"sourcesContent":["import { type FormulaWidgetState, type ValueProps } from '../types'\nimport { Item } from './item'\nimport { defaultFormatter } from '../../utils/formatter'\nimport { useWidgetSelector } from '../../stores/use-widget-selector'\n\n/**\n * Displays the formatted numeric value for a formula widget data item, applying the widget's formatter and color.\n */\nexport function Value({ id, index = 0, ...props }: ValueProps) {\n const { value, color, formatter } = useWidgetSelector(id, (w) => {\n const widget = w as FormulaWidgetState | undefined\n return {\n value: widget?.data?.[index]?.value,\n color: widget?.data?.[index]?.color,\n formatter: widget?.formatter ?? defaultFormatter,\n }\n })\n\n return (\n <Item TypographyProps={{ color }} {...props}>\n {formatter(value ?? 0)}\n </Item>\n )\n}\n","import { downloadToCSV, downloadToPNG } from '../actions'\nimport type { ConfigProps } from '../loader/types'\nimport type { FormulaDownloadConfig, FormulaWidgetConfig } from './types'\n\n/**\n * Creates download configuration for formula widgets, supporting PNG (screenshot) and CSV (data) exports.\n *\n * @param props - Configuration with `refUI` reference for PNG export.\n * @returns Array of download items for use with the Download action.\n */\nexport function formulaDownloadConfig({\n refUI,\n}: ConfigProps): FormulaDownloadConfig {\n return [\n {\n ...downloadToPNG,\n modifier: () => downloadToPNG.modifier(refUI),\n },\n {\n ...downloadToCSV,\n modifier: async (data) => {\n const formulaData = [data?.map((item) => item.value) ?? []]\n return downloadToCSV.modifier(formulaData)\n },\n },\n ]\n}\n\n/**\n * Returns the default configuration for formula (single or multiple numeric value) widgets.\n *\n * @returns Default formula widget config with empty series.\n */\nexport function formulaConfig(): FormulaWidgetConfig {\n return {\n series: [],\n }\n}\n","import type { FormulaUIProps } from './types'\nimport { Row } from './components/row'\nimport { Value } from './components/value'\nimport { Prefix } from './components/prefix'\nimport { Suffix } from './components/suffix'\nimport { Series } from './components/series'\nimport { useWidgetRef } from '../../hooks'\nimport { Box } from '@mui/material'\n\n/**\n * Renders a formula widget displaying one or more KPI values with optional prefixes, suffixes, and series indicators.\n */\nexport function FormulaUI(props: FormulaUIProps) {\n const { ref } = useWidgetRef(props.id)\n\n return (\n <Box ref={ref}>\n <Row id={props.id}>\n {({ index }) => (\n <>\n <Series id={props.id} index={index} />\n <Prefix id={props.id} index={index} />\n <Value id={props.id} index={index} />\n <Suffix id={props.id} index={index} />\n </>\n )}\n </Row>\n </Box>\n )\n}\n","import { Box, Skeleton } from '@mui/material'\nimport { styles } from './style'\n\nexport function FormulaSkeleton() {\n return (\n <Box sx={styles.row} aria-label='Formula skeleton'>\n <Skeleton width={120} height={32} />\n </Box>\n )\n}\n","import type { DataItem } from './types'\n\n/**\n * Sanitizes DataItem by converting ReactNode prefix/suffix values to undefined.\n * This ensures only string values are stored in the widget state.\n *\n * @param item - The DataItem to sanitize\n * @returns A new DataItem with ReactNode prefix/suffix values converted to undefined\n */\nexport function sanitizeDataItem(item: DataItem): DataItem {\n return {\n ...item,\n prefix: typeof item.prefix === 'string' ? item.prefix : undefined,\n suffix: typeof item.suffix === 'string' ? item.suffix : undefined,\n }\n}\n\n/**\n * Sanitizes an array of DataItems by converting ReactNode prefix/suffix values to undefined.\n *\n * @param items - Array of DataItems to sanitize\n * @returns A new array with sanitized DataItems\n */\nexport function sanitizeDataItems(\n items: DataItem[] | undefined,\n): DataItem[] | undefined {\n return items?.map(sanitizeDataItem)\n}\n"],"names":["Value","t0","$","_c","id","props","t1","index","undefined","t2","w","widget","value","data","color","formatter","defaultFormatter","useWidgetSelector","t3","t4","t5","t6","Item","formulaDownloadConfig","refUI","downloadToPNG","modifier","downloadToCSV","formulaData","map","item","formulaConfig","series","FormulaUI","ref","useWidgetRef","jsxs","Fragment","jsx","Series","Prefix","Suffix","Row","Box","FormulaSkeleton","Symbol","for","styles","row","Skeleton","sanitizeDataItem","prefix","suffix","sanitizeDataItems","items"],"mappings":";;;;;;;;;;;;;;;;;;;AAQO,SAAAA,EAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,EAAA;AAAA,MAAAC,GAAAC,GAAAC;AAAA,EAAAJ,SAAAD,KAAe;AAAA,IAAAG,IAAAA;AAAAA,IAAAG,OAAAD;AAAAA,IAAA,GAAAD;AAAAA,EAAAA,IAAAJ,GAAuCC,OAAAD,GAAAC,OAAAE,GAAAF,OAAAG,GAAAH,OAAAI,MAAAF,IAAAF,EAAA,CAAA,GAAAG,IAAAH,EAAA,CAAA,GAAAI,IAAAJ,EAAA,CAAA;AAAjC,QAAAK,IAAAD,MAAAE,SAAA,IAAAF;AAAS,MAAAG;AAAA,EAAAP,SAAAK,KACuBE,IAAAC,CAAAA,MAAA;AACxD,UAAAC,IAAeD;AAAmC,WAC3C;AAAA,MAAAE,OACED,GAAME,OAASN,CAAK,GAAQK;AAAAA,MAAAE,OAC5BH,GAAME,OAASN,CAAK,GAAQO;AAAAA,MAAAC,WACxBJ,GAAMI,aAANC;AAAAA,IAAAA;AAAAA,EACZ,GACFd,OAAAK,GAAAL,OAAAO,KAAAA,IAAAP,EAAA,CAAA;AAPD,QAAA;AAAA,IAAAU,OAAAA;AAAAA,IAAAE,OAAAA;AAAAA,IAAAC,WAAAA;AAAAA,EAAAA,IAAoCE,EAAkBb,GAAIK,CAOzD;AAAC,MAAAS;AAAA,EAAAhB,SAAAY,KAGuBI,IAAA;AAAA,IAAAJ,OAAAA;AAAAA,EAAAA,GAASZ,OAAAY,GAAAZ,OAAAgB,KAAAA,IAAAhB,EAAA,CAAA;AACnB,QAAAiB,IAAAP,KAAA;AAAU,MAAAQ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