@omem-ai/plugin-sdk 0.0.0-stage → 0.0.2

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/charts.js ADDED
@@ -0,0 +1,686 @@
1
+ const me = "cubic-bezier(.22,.7,.25,1)", ue = `
2
+ .oc { display: grid; gap: 10px; min-width: 0; color: var(--ink); }
3
+ .oc-head { display: grid; gap: 2px; min-width: 0; }
4
+ .oc-title { font-size: 14px; font-weight: 650; letter-spacing: -0.005em; color: var(--ink); overflow-wrap: anywhere; }
5
+ .oc-sub { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
6
+ .oc-note { margin: 0; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
7
+ .oc-foot { margin: 0; font-size: 10.5px; letter-spacing: .14em; color: var(--muted); opacity: .85; text-align: center; overflow-wrap: anywhere; }
8
+ .oc-plot { position: relative; outline: none; border-radius: 6px; min-width: 0; }
9
+ .oc-plot:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
10
+ .oc-plot > svg { width: 100%; height: auto; display: block; overflow: visible; touch-action: pan-y; }
11
+ .oc-plot.clickable > svg { cursor: pointer; }
12
+ .oc-base { stroke: var(--chart-axis); stroke-width: 1; shape-rendering: crispEdges; }
13
+ .oc-tick { stroke: var(--chart-axis); stroke-width: 1; shape-rendering: crispEdges; }
14
+ .oc-tick.major { stroke: var(--muted); }
15
+ .oc-goal { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 2 3; opacity: .75; }
16
+ .oc-cross { stroke: var(--ink-2); stroke-width: 1; opacity: .55; shape-rendering: crispEdges; }
17
+ .oc-axis { fill: var(--muted); font: 500 10px var(--sans); letter-spacing: .1em; }
18
+ .oc-val { fill: var(--ink-2); font: 500 10.5px var(--sans); font-variant-numeric: tabular-nums; }
19
+ .oc-val.key { fill: var(--ink); font-weight: 700; font-size: 12px; }
20
+ .oc-val.accent { fill: var(--chart-accent); }
21
+ .oc-name { fill: var(--muted); font: 500 10.5px var(--sans); letter-spacing: .08em; }
22
+ .oc-dot { stroke: var(--chart-surface, var(--panel)); stroke-width: 1.5; }
23
+ .oc-hollow { fill: var(--chart-surface, var(--panel)); stroke-width: 1.25; }
24
+ .oc-rung { shape-rendering: crispEdges; }
25
+ .oc-col, .oc-series, .oc-part { transition: opacity .18s; }
26
+ .oc-hovering .oc-col:not(.on), .oc-hovering .oc-series:not(.on), .oc-hovering .oc-part:not(.on) { opacity: .26; }
27
+ .oc-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 11.5px; letter-spacing: .06em; color: var(--ink-2); }
28
+ .oc-key { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
29
+ .oc-key i { width: 9px; height: 7px; flex: none; background: repeating-linear-gradient(to bottom, var(--k) 0 1.5px, transparent 1.5px 3px); }
30
+ .oc-key i.line { height: 2px; width: 12px; background: var(--k); }
31
+ .oc-key b { font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: 0; }
32
+ .oc-tip { position: absolute; z-index: 3; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 7px 10px; font-size: 12px; line-height: 1.5; min-width: 110px; white-space: nowrap; }
33
+ .oc-tip-title { color: var(--muted); margin-bottom: 2px; letter-spacing: .06em; font-size: 11px; }
34
+ .oc-tip-row { display: flex; align-items: center; gap: 8px; }
35
+ .oc-tip-row i { width: 8px; height: 2px; flex: none; }
36
+ .oc-tip-row b { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
37
+ .oc-tip-row span { color: var(--ink-2); }
38
+ .oc details summary { cursor: pointer; color: var(--muted); font-size: 12px; width: fit-content; }
39
+ .oc-scroll { overflow-x: auto; max-width: 100%; }
40
+ .oc table { border-collapse: collapse; font-size: 12.5px; margin-top: 6px; }
41
+ .oc th, .oc td { border-bottom: 1px solid var(--line); padding: 4px 12px 4px 0; text-align: left; font-weight: 400; vertical-align: top; }
42
+ .oc thead th { color: var(--muted); font-weight: 550; white-space: nowrap; }
43
+ .oc td.num { text-align: right; font-variant-numeric: tabular-nums; }
44
+ .oc td a { color: inherit; }
45
+ /* rows: a ranking, long names, several measures side by side */
46
+ .oc-rows { display: grid; gap: 1px; min-width: 0; --label-w: 9.5em; }
47
+ .oc-row { display: grid; grid-template-columns: minmax(0, var(--label-w)) minmax(48px, 1fr) var(--extras, 0); align-items: center; column-gap: 14px; padding: 4px 0; font-size: 13px; color: inherit; text-decoration: none; min-width: 0; transition: opacity .18s; }
48
+ .oc-row.head { padding-top: 0; padding-bottom: 0; font-size: 10.5px; letter-spacing: .1em; color: var(--muted); }
49
+ .oc-rows:hover > .oc-row:not(.head):not(:hover) { opacity: .4; }
50
+ a.oc-row:focus-visible, .oc-row a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 2px; }
51
+ a.oc-row:hover .oc-row-label { text-decoration: underline; text-underline-offset: 2px; }
52
+ .oc-row-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
53
+ .oc-row-label.key { color: var(--ink); font-weight: 650; }
54
+ .oc-bars { position: relative; display: grid; gap: 3px; min-width: 0; padding: 1px 0; }
55
+ .oc-track { position: relative; height: 14px; margin-right: var(--room, 3em); margin-left: var(--room-left, 0); display: block; color: inherit; text-decoration: none; }
56
+ .oc-bars.multi { gap: 4px; padding: 3px 0; }
57
+ .oc-row.multi { padding: 7px 0; }
58
+ .oc-row.multi + .oc-row.multi { border-top: 1px solid var(--chart-grid); }
59
+ .oc-bars.multi .oc-track { height: 11px; }
60
+ .oc-bars.multi .oc-bar-v { font-size: 11px; }
61
+ .oc-ticks { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
62
+ .oc-ticks line { vector-effect: non-scaling-stroke; shape-rendering: crispEdges; }
63
+ .oc-thin { position: absolute; top: 50%; height: 2px; transform: translateY(-50%); }
64
+ .oc-bar-v { position: absolute; top: 50%; transform: translateY(-50%); padding: 0 7px; font-size: 11.5px; line-height: 1; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
65
+ .oc-bar-v.key { color: var(--ink); font-weight: 700; }
66
+ .oc-bar-v small { margin-left: 5px; font-size: 10.5px; letter-spacing: .08em; color: var(--muted); font-weight: 500; }
67
+ .oc-goal-v { position: absolute; top: -5px; bottom: -5px; border-left: 1px dashed var(--ink-2); opacity: .5; pointer-events: none; }
68
+ .oc-goal-label { position: relative; height: 14px; font-size: 10.5px; letter-spacing: .1em; color: var(--muted); }
69
+ .oc-goal-label span { position: absolute; bottom: 0; transform: translateX(-50%); white-space: nowrap; }
70
+ .oc-extras { display: grid; grid-template-columns: repeat(var(--n, 1), minmax(3.6em, auto)); column-gap: 12px; justify-content: end; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
71
+ .oc-extras a { color: inherit; text-decoration: none; }
72
+ .oc-extras a:hover { text-decoration: underline; }
73
+ .oc-extras small { margin-left: 2px; font-size: 11px; color: var(--muted); }
74
+ /* shares */
75
+ .oc-total { fill: var(--ink); font: 650 26px var(--sans); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
76
+ /* figures */
77
+ .oc-mgroup { display: grid; gap: 10px; min-width: 0; container-type: inline-size; }
78
+ .oc-mtitle { font-size: 14px; font-weight: 650; }
79
+ .oc-metrics { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); row-gap: 18px; overflow: hidden; }
80
+ @container (max-width: 520px) { .oc-metrics { grid-template-columns: repeat(var(--cols-narrow, 2), minmax(0, 1fr)); } }
81
+ .oc-metric { display: grid; gap: 3px; align-content: start; min-width: 0; padding: 2px 18px; margin-left: -1px; border-left: 1px solid var(--line); color: inherit; text-decoration: none; }
82
+ a.oc-metric, button.oc-metric { border-radius: 0 6px 6px 0; }
83
+ button.oc-metric { font: inherit; text-align: left; background: none; border: 0; border-left: 1px solid var(--line); padding-top: 6px; padding-bottom: 8px; cursor: pointer; transition: background-color .15s, box-shadow .15s; }
84
+ a.oc-metric:hover, button.oc-metric:hover { background: var(--hover); }
85
+ a.oc-metric:focus-visible, button.oc-metric:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
86
+ button.oc-metric[aria-expanded="true"] { background: var(--accent-soft, var(--hover)); box-shadow: inset 0 -2px 0 var(--accent); }
87
+ .oc-mlabel { color: var(--muted); font-size: 11.5px; letter-spacing: .1em; overflow-wrap: anywhere; }
88
+ .oc-mtag { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 999px; background: var(--warn-soft, var(--hover)); color: var(--warn, var(--ink-2)); font-size: 10.5px; letter-spacing: .04em; line-height: 17px; vertical-align: 1px; white-space: nowrap; }
89
+ .oc-mvalue { display: flex; align-items: baseline; gap: 4px; min-width: 0; }
90
+ .oc-mvalue b { font: 650 30px/1.15 var(--sans); letter-spacing: -0.02em; color: var(--ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
91
+ .oc-mvalue span { color: var(--muted); font-size: 12px; letter-spacing: .06em; }
92
+ .oc-mfoot { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; font-size: 12px; color: var(--muted); }
93
+ .oc-delta { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-2); }
94
+ .oc-delta[data-tone="good"] { color: var(--ok); }
95
+ .oc-delta[data-tone="bad"] { color: var(--danger); }
96
+ .oc-even .oc-metrics { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
97
+ @container (max-width: 520px) { .oc-even .oc-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
98
+ .oc-mpending { display: flex; align-items: center; min-height: 34.5px; font-size: 12.5px; color: var(--ink-2); }
99
+ .oc-even .oc-mlabel { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; line-height: 1.5; }
100
+ .oc-even .oc-mfoot { flex-wrap: nowrap; overflow: hidden; white-space: nowrap; }
101
+ .oc-even .oc-mfoot > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
102
+ .oc-even .oc-mfoot > .oc-delta { flex: none; }
103
+ .oc-spark { width: 100%; max-width: 150px; height: auto; display: block; margin-top: 6px; overflow: visible; }
104
+ .oc-spark-hair { stroke: var(--chart-seq-2); stroke-width: 1; }
105
+ .oc-spark-line { fill: none; stroke: var(--chart-seq-3); stroke-width: 1.25; stroke-linejoin: round; stroke-linecap: round; }
106
+ .oc-spark-dot { fill: var(--chart-seq-4); }
107
+ @media (max-width: 520px) { .oc-mvalue b { font-size: 26px; } .oc-rows { --label-w: 7em; } }
108
+ /* entrance: drawn in once, paused until the chart is in view */
109
+ .oc-anim .oc-m { animation-duration: var(--t, 220ms); animation-timing-function: ${me}; animation-fill-mode: both; animation-delay: var(--d, 0ms); animation-play-state: paused; }
110
+ .oc-anim.oc-run .oc-m { animation-play-state: running; }
111
+ .oc-anim .oc-m.in { animation-name: oc-in; }
112
+ .oc-anim .oc-m.up { animation-name: oc-up; }
113
+ .oc-anim .oc-m.grow { animation-name: oc-grow; transform-box: fill-box; transform-origin: 50% 100%; }
114
+ .oc-anim .oc-m.draw { animation-name: oc-draw; animation-timing-function: cubic-bezier(.45,.05,.35,1); }
115
+ .oc-anim .oc-m.wipe { animation-name: oc-wipe; animation-timing-function: cubic-bezier(.3,.6,.3,1); }
116
+ .oc-anim .oc-m.pop { animation-name: oc-pop; transform-box: fill-box; transform-origin: center; }
117
+ @keyframes oc-in { from { opacity: 0; } }
118
+ @keyframes oc-up { from { opacity: 0; transform: translateY(4px); } }
119
+ @keyframes oc-grow { from { transform: scaleY(0); } }
120
+ @keyframes oc-draw { from { stroke-dashoffset: 1; } }
121
+ @keyframes oc-wipe { from { clip-path: inset(0 100% 0 0); } }
122
+ @keyframes oc-pop { from { opacity: 0; transform: scale(.3); } }
123
+ @media (prefers-reduced-motion: reduce) { .oc-anim .oc-m { animation: none !important; } }
124
+ `;
125
+ function qt(e) {
126
+ if (e.getElementById("omem-chart-style")) return;
127
+ const t = e.createElement("style");
128
+ t.id = "omem-chart-style", t.textContent = ue, e.head.appendChild(t);
129
+ }
130
+ function c(e, t, o = {}, ...a) {
131
+ const s = e.createElement(t);
132
+ for (const [r, n] of Object.entries(o)) n !== void 0 && n !== !1 && s.setAttribute(r, n === !0 ? "" : String(n));
133
+ for (const r of a) r != null && r !== !1 && s.append(typeof r == "string" ? e.createTextNode(r) : r);
134
+ return s;
135
+ }
136
+ const fe = "http://www.w3.org/2000/svg";
137
+ function g(e, t, o = {}, a) {
138
+ const s = e.createElementNS(fe, t);
139
+ for (const [r, n] of Object.entries(o)) n !== void 0 && s.setAttribute(r, String(n));
140
+ return a !== void 0 && (s.textContent = a), s;
141
+ }
142
+ const Gt = (e, t, o, a = {}) => c(e, t ? "a" : "div", { class: o, ...t ? { href: t } : {}, ...a });
143
+ function C(e, t, o, a) {
144
+ e.classList.add("oc-m", t);
145
+ const s = `--d:${Math.round(o)}ms${a ? `;--t:${Math.round(a)}ms` : ""}`, r = e.getAttribute("style");
146
+ return e.setAttribute("style", r ? `${r};${s}` : s), e;
147
+ }
148
+ let Jt = !0;
149
+ function Fe(e) {
150
+ Jt = e;
151
+ }
152
+ function de(e) {
153
+ const t = e.defaultView;
154
+ return !Jt || !t || typeof t.IntersectionObserver > "u" || e.documentElement.dataset.chartMotion === "off" ? !1 : !(typeof t.matchMedia == "function" && t.matchMedia("(prefers-reduced-motion: reduce)").matches);
155
+ }
156
+ function Qt(e, t) {
157
+ const o = e.ownerDocument;
158
+ if (!de(o)) return () => {
159
+ };
160
+ e.classList.add("oc-anim");
161
+ const a = new o.defaultView.IntersectionObserver((s) => {
162
+ if (!s.some((n) => n.isIntersecting)) return;
163
+ if (a.disconnect(), e.closest("[data-chart-still]")) return e.classList.remove("oc-anim");
164
+ e.classList.add("oc-run"), t?.();
165
+ const r = Math.max(0, ...Array.from(e.querySelectorAll(".oc-m")).map((n) => (parseFloat(n.style.getPropertyValue("--d")) || 0) + (parseFloat(n.style.getPropertyValue("--t")) || 220)));
166
+ setTimeout(() => e.classList.remove("oc-anim", "oc-run"), r + 60);
167
+ }, { threshold: 0.2 });
168
+ return a.observe(e), () => a.disconnect();
169
+ }
170
+ function Wt(e, t = 800) {
171
+ const o = e.textContent ?? "", a = o.match(/^([^\d-]*)(-?[\d,]+(?:\.\d+)?)(.*)$/), s = e.ownerDocument.defaultView;
172
+ if (!a || !s) return;
173
+ const r = Number(a[2].replace(/,/g, ""));
174
+ if (!Number.isFinite(r) || r === 0) return;
175
+ const n = (a[2].split(".")[1] ?? "").length, p = a[2].includes(","), l = (h) => `${a[1]}${p ? h.toLocaleString("en-US", { minimumFractionDigits: n, maximumFractionDigits: n }) : h.toFixed(n)}${a[3]}`, m = s.performance.now(), f = (h) => {
176
+ const y = Math.min(1, (h - m) / t);
177
+ e.textContent = y >= 1 ? o : l(r * (1 - (1 - y) ** 3)), y < 1 && s.requestAnimationFrame(f);
178
+ };
179
+ s.requestAnimationFrame(f);
180
+ }
181
+ const et = (e) => e.toLocaleString("zh-CN", { maximumFractionDigits: 4 });
182
+ function gt(e) {
183
+ const t = Math.abs(e), o = (a) => a.toLocaleString("zh-CN", { maximumFractionDigits: t >= 1e4 ? 1 : t >= 100 ? 0 : t >= 10 ? 1 : 2 });
184
+ return t >= 1e8 ? `${o(e / 1e8)}亿` : t >= 1e4 ? `${o(e / 1e4)}万` : o(e);
185
+ }
186
+ function Kt(e, t = "", o = !0) {
187
+ return t === "秒" && Math.abs(e) >= 7200 ? `${Math.round(e / 360) / 10}小时` : t === "秒" && Math.abs(e) >= 120 ? `${Math.round(e / 6) / 10}分钟` : `${o ? gt(e) : et(e)}${t === "%" ? "%" : ""}`;
188
+ }
189
+ function xe(e) {
190
+ const t = Math.max(...e.map(Math.abs)), [o, a] = t >= 1e8 ? [1e8, "亿"] : t >= 1e4 ? [1e4, "万"] : [1, ""];
191
+ return (s) => s === 0 ? "0" : `${(s / o).toLocaleString("zh-CN", { maximumFractionDigits: 2 })}${a}`;
192
+ }
193
+ function ge(e, t, o = 3, a = !1) {
194
+ t === e && (t = e + (Math.abs(e) || 1));
195
+ const s = t - e, r = 10 ** Math.floor(Math.log10(s / o));
196
+ let n = [1, 2, 2.5, 5, 10].map((f) => f * r).find((f) => s / f <= o) ?? 10 * r;
197
+ a && n < 1 && (n = 1), a && !Number.isInteger(n) && (n = Math.ceil(n));
198
+ const p = Math.floor(e / n + 1e-9) * n, l = Math.ceil(t / n - 1e-9) * n, m = [];
199
+ for (let f = p; f <= l + n / 2; f += n) m.push(Number(f.toFixed(10)));
200
+ return { min: p, max: l, ticks: m };
201
+ }
202
+ function te(e, t, o = 45) {
203
+ const a = Math.abs(e);
204
+ if (!(a > 0) || t && a <= o) return 1;
205
+ let s = 10 ** Math.floor(Math.log10(a / o));
206
+ for (let r = 0; r < 40; r++, s *= 10)
207
+ for (const n of [1, 2, 5]) {
208
+ const p = Number((n * s).toPrecision(6));
209
+ if (a / p <= o && (!t || p >= 1)) return p;
210
+ }
211
+ return a;
212
+ }
213
+ function ve(e, t = 100) {
214
+ const o = e.map((l) => Number.isFinite(l) && l > 0 ? l : 0), a = o.reduce((l, m) => l + m, 0);
215
+ if (!a) return o.map(() => 0);
216
+ const s = o.map((l) => l / a * t), r = s.map((l, m) => o[m] > 0 ? Math.max(1, Math.floor(l)) : 0);
217
+ let n = t - r.reduce((l, m) => l + m, 0);
218
+ const p = s.map((l, m) => [l - Math.floor(l), m]).filter(([, l]) => o[l] > 0).sort((l, m) => m[0] - l[0]);
219
+ for (let l = 0; n > 0 && p.length; l = (l + 1) % p.length, n--) r[p[l][1]]++;
220
+ for (; n < 0; ) {
221
+ const l = r.indexOf(Math.max(...r));
222
+ r[l]--, n++;
223
+ }
224
+ return r;
225
+ }
226
+ const nt = (e, t = 11, o = 0) => Array.from(e).reduce((a, s) => a + (s.codePointAt(0) > 255 ? t : t * 0.6) + o, 0);
227
+ function It(e, t, o = 11) {
228
+ if (nt(e, o) <= t) return e;
229
+ const a = Array.from(e);
230
+ for (; a.length > 1 && nt(a.join("") + "…", o) > t; ) a.pop();
231
+ return a.join("") + "…";
232
+ }
233
+ const Xt = (e) => e.replace(/^\d{4}-(\d{2})-(\d{2})(?!\d)/, "$1-$2");
234
+ function be(e) {
235
+ if (e.length < 2) return null;
236
+ const t = e.map((o) => /^\d{4}-\d{2}-\d{2}$/.test(o) ? Date.parse(`${o}T00:00:00Z`) : NaN);
237
+ if (t.some((o) => !Number.isFinite(o))) return null;
238
+ for (let o = 1; o < t.length; o++) if (Math.round((t[o] - t[o - 1]) / 864e5) !== 1) return null;
239
+ return t.map((o) => new Date(o).getUTCDay());
240
+ }
241
+ const ye = (e) => e.map(([t, o], a) => `${a ? "L" : "M"}${t.toFixed(1)},${o.toFixed(1)}`).join(" ");
242
+ function Bt(e) {
243
+ const t = e.length;
244
+ if (t < 3) return ye(e);
245
+ const o = [], a = [];
246
+ for (let n = 0; n < t - 1; n++)
247
+ o.push(e[n + 1][0] - e[n][0]), a.push(o[n] ? (e[n + 1][1] - e[n][1]) / o[n] : 0);
248
+ const s = [a[0]];
249
+ for (let n = 1; n < t - 1; n++) s.push(a[n - 1] * a[n] <= 0 ? 0 : 3 * (o[n - 1] + o[n]) / ((2 * o[n] + o[n - 1]) / a[n - 1] + (o[n] + 2 * o[n - 1]) / a[n]));
250
+ s.push(a[t - 2]);
251
+ let r = `M${e[0][0].toFixed(1)},${e[0][1].toFixed(1)}`;
252
+ for (let n = 0; n < t - 1; n++) {
253
+ const [p, l] = e[n], [m, f] = e[n + 1], h = o[n] / 3;
254
+ r += ` C${(p + h).toFixed(1)},${(l + s[n] * h).toFixed(1)} ${(m - h).toFixed(1)},${(f - s[n + 1] * h).toFixed(1)} ${m.toFixed(1)},${f.toFixed(1)}`;
255
+ }
256
+ return r;
257
+ }
258
+ const ee = (e, t) => `${et(e)}${t === "%" ? "%" : t ? ` ${t}` : ""}`, bt = (e, t) => `var(--chart-${((e?.slot ?? t) % 8 + 8) % 8 + 1})`, Ot = (e, t) => e.series.length === 1 ? "var(--chart-seq-3)" : bt(e.series[t], t), Et = "var(--chart-accent)";
259
+ function Ce(e, t) {
260
+ const o = e.ownerDocument;
261
+ qt(o), e.classList.add("oc");
262
+ const a = we(t), s = a.unit && a.unit !== "%" ? `单位:${a.unit}` : "", r = [a.caption, s].filter(Boolean).join(" · "), n = a.title || r ? c(o, "div", { class: "oc-head" }, a.title ? c(o, "span", { class: "oc-title" }, a.title) : null, r ? c(o, "span", { class: "oc-sub" }, r) : null) : null, p = c(o, "div", { class: "oc", style: "gap:8px" }), l = a.note ? c(o, "p", { class: "oc-note" }, a.note) : null, m = a.table !== !1 && a.kind !== "hbar";
263
+ e.replaceChildren(...[n, p, l, m ? ke(o, a) : null].filter((N) => !!N));
264
+ let f = () => {
265
+ }, h = [], y = !1, q = !1;
266
+ const k = () => {
267
+ y || (y = !0, f = Qt(p, () => {
268
+ q = !0, h.forEach((N) => Wt(N));
269
+ }));
270
+ };
271
+ let F = 0;
272
+ const R = () => {
273
+ const N = Math.max(240, Math.min(960, Math.round(p.clientWidth || e.clientWidth || 600)));
274
+ if (Math.abs(N - F) < 8) return;
275
+ q && p.classList.remove("oc-anim", "oc-run"), F = N;
276
+ const _ = a.kind === "pie" ? Le(o, a, N) : a.kind === "hbar" ? Ee(o, a, N) : $e(o, a, N);
277
+ h = Array.from(_.flatMap((at) => Array.from(at.querySelectorAll(".oc-count")))), p.replaceChildren(..._), k();
278
+ };
279
+ if (R(), typeof ResizeObserver > "u") return () => f();
280
+ const M = new ResizeObserver(R);
281
+ return M.observe(p), () => {
282
+ M.disconnect(), f();
283
+ };
284
+ }
285
+ function we(e) {
286
+ const t = e.labels.length, o = (e.kind === "pie" ? e.series.slice(0, 1) : e.series).map((a) => ({ ...a, values: Array.from({ length: t }, (s, r) => Number.isFinite(a.values[r]) ? a.values[r] : 0) }));
287
+ return { ...e, series: o };
288
+ }
289
+ function ke(e, t) {
290
+ const o = t.unit ?? "", a = (r, n) => {
291
+ const p = `${et(r.values[n])}${o}`, l = r.links?.[n] ?? (t.series.length === 1 ? t.links?.[n] : void 0);
292
+ return c(e, "td", { class: "num" }, l ? c(e, "a", { href: l }, p) : p);
293
+ }, s = t.extras ?? [];
294
+ return c(
295
+ e,
296
+ "details",
297
+ {},
298
+ c(e, "summary", {}, "看数据"),
299
+ c(
300
+ e,
301
+ "div",
302
+ { class: "oc-scroll" },
303
+ c(
304
+ e,
305
+ "table",
306
+ {},
307
+ c(e, "thead", {}, c(e, "tr", {}, c(e, "th", {}, ""), ...t.series.map((r) => c(e, "th", {}, r.name)), ...s.map((r) => c(e, "th", {}, r.name)))),
308
+ c(e, "tbody", {}, ...t.labels.map((r, n) => c(e, "tr", {}, c(e, "th", {}, r), ...t.series.map((p) => a(p, n)), ...s.map((p) => c(e, "td", { class: "num" }, p.values[n] ?? "")))))
309
+ )
310
+ )
311
+ );
312
+ }
313
+ function ne(e, t) {
314
+ const o = c(e, "div", { class: "oc-tip", role: "status", hidden: !0 });
315
+ return t.append(o), {
316
+ show(a, s, r, n) {
317
+ o.replaceChildren(
318
+ c(e, "div", { class: "oc-tip-title" }, r),
319
+ ...n.map((h) => c(e, "div", { class: "oc-tip-row" }, c(e, "i", { style: `background:${h.key}` }), c(e, "b", {}, h.value), c(e, "span", {}, h.name)))
320
+ ), o.hidden = !1;
321
+ const p = t.clientWidth, l = o.offsetWidth, m = o.offsetHeight, f = a + 14 + l > p ? Math.max(0, a - 14 - l) : a + 14;
322
+ o.style.left = `${f}px`, o.style.top = `${Math.max(0, Math.min(s - m / 2, t.clientHeight - m))}px`;
323
+ },
324
+ hide() {
325
+ o.hidden = !0;
326
+ }
327
+ };
328
+ }
329
+ function ae(e, t, o, a, s, r, n) {
330
+ let p = -1;
331
+ const l = (f, h = -1) => {
332
+ f === p && h < 0 || (p = f, f < 0 ? r() : s(f, h));
333
+ }, m = (f) => {
334
+ const h = e.getBoundingClientRect();
335
+ return [f.clientX - h.left, f.clientY - h.top];
336
+ };
337
+ t.addEventListener("pointermove", (f) => {
338
+ const [h, y] = m(f);
339
+ l(a(h, y), y);
340
+ }), t.addEventListener("pointerleave", () => l(-1)), n && t.addEventListener("click", (f) => {
341
+ const [h, y] = m(f), q = a(h, y);
342
+ q >= 0 && n(q, h, y);
343
+ }), e.addEventListener("focus", () => l(Math.max(0, p))), e.addEventListener("blur", () => l(-1)), e.addEventListener("keydown", (f) => {
344
+ const h = f.key;
345
+ if (h === "ArrowRight" || h === "ArrowDown") l(Math.min(o - 1, p + 1));
346
+ else if (h === "ArrowLeft" || h === "ArrowUp") l(Math.max(0, p - 1));
347
+ else if (h === "Home") l(0);
348
+ else if (h === "End") l(o - 1);
349
+ else if (h === "Escape") l(-1);
350
+ else if (h === "Enter" && n && p >= 0) n(p, -1, -1);
351
+ else return;
352
+ f.preventDefault();
353
+ });
354
+ }
355
+ function Me(e, t) {
356
+ if (!t) return;
357
+ const o = e.defaultView;
358
+ o && (o.location.href = t);
359
+ }
360
+ function oe(e, t, o) {
361
+ return c(e, "div", { class: "oc-legend" }, ...t.series.map((a, s) => c(
362
+ e,
363
+ "span",
364
+ { class: "oc-key" },
365
+ c(e, "i", { class: t.kind === "line" ? "line" : "", style: `--k:${Ot(t, s)}` }),
366
+ a.name,
367
+ o ? c(e, "b", {}, Kt(a.values.reduce((r, n) => r + n, 0), t.unit)) : null
368
+ )));
369
+ }
370
+ function Dt(e, t, o, a = 14) {
371
+ const s = [...e].sort((n, p) => n.ty - p.ty);
372
+ for (let n = 1; n < s.length; n++) s[n].ty = Math.max(s[n].ty, s[n - 1].ty + a);
373
+ const r = s.length ? s[s.length - 1].ty - o : 0;
374
+ if (r > 0) for (const n of s) n.ty -= r;
375
+ for (let n = s.length - 2; n >= 0; n--) s[n].ty = Math.min(s[n].ty, s[n + 1].ty - a);
376
+ if (s.length && s[0].ty < t) {
377
+ const n = t - s[0].ty;
378
+ for (const p of s) p.ty += n;
379
+ }
380
+ return s;
381
+ }
382
+ function $e(e, t, o) {
383
+ const a = t.labels.length, s = t.series.length, r = t.unit ?? "", n = s > 1 && !!t.stack && t.kind !== "line", p = t.kind === "line" || t.kind === "area", l = s === 1, m = t.highlight ? t.labels.indexOf(t.highlight) : -1, f = t.series.map(() => new Array(a).fill(0)), h = t.series.map((i) => [...i.values]);
384
+ if (n) {
385
+ const i = new Array(a).fill(0), d = new Array(a).fill(0);
386
+ t.series.forEach((A, b) => A.values.forEach((S, j) => {
387
+ const B = S >= 0 ? i : d;
388
+ f[b][j] = B[j], B[j] += S, h[b][j] = B[j];
389
+ }));
390
+ }
391
+ const y = t.labels.map((i, d) => t.series.reduce((A, b) => A + b.values[d], 0)), q = t.series.every((i) => i.values.every(Number.isInteger)) && (t.goal === void 0 || Number.isInteger(t.goal)), k = [...h.flat(), ...n ? f.flat() : [], ...t.goal !== void 0 ? [t.goal] : []], F = n || t.kind !== "bar" ? 1 : s, R = t.kind === "bar" && a * F <= 60, M = R ? te(Math.max(...k.map(Math.abs)), q) : 1, N = t.kind === "line" && Math.min(...k) > 0 && Math.min(...k) > Math.max(...k) * 0.45, _ = N ? [Math.min(...k) - (Math.max(...k) - Math.min(...k)) * 0.15, ...k] : [...k, 0], at = R ? { min: Math.min(0, Math.floor(Math.min(..._) / M) * M), max: Math.max(M, Math.ceil(Math.max(..._) / M) * M), ticks: [] } : ge(Math.min(..._), Math.max(..._), 3, q), { min: Q, max: vt, ticks: ft } = at, ot = R && a * F <= 16, U = o < 480 ? 188 : 216, st = 26, x = 24, E = ft.map(xe(ft)), v = ft.length ? Math.ceil(Math.max(...E.map((i) => nt(i, 10, 1)))) + 12 : 4, V = p && !n ? t.series.map((i, d) => ({ si: d, v: h[d][a - 1], text: gt(i.values[a - 1]), name: l ? "" : i.name })) : [], it = (i) => nt(i.text, 12) + (i.name ? nt(i.name, 10.5, 0.8) + 6 : 0);
392
+ let W = V.length > 0 && !l, P = V.length ? Math.ceil(Math.max(...V.map(it))) + 16 : 8;
393
+ W && P > o * 0.3 && (W = !1, P = Math.ceil(Math.max(...V.map((i) => nt(i.text, 12)))) + 16), W || V.forEach((i) => i.name = "");
394
+ const u = n && R ? t.series.map((i, d) => ({ si: d, v: i.values[a - 1], name: i.name })) : [], O = u.length ? Math.ceil(Math.max(...u.map((i) => nt(i.name, 10.5, 0.8)))) + 14 : 0, D = u.length > 0 && u.every((i) => i.v > 0) && O < o * 0.24;
395
+ D && (P = Math.max(P, O));
396
+ const Y = s > 1 && !W && !D, z = (i) => st + (U - st - x) * (1 - (i - Q) / (vt - Q)), Z = (o - v - P) / a, I = (i) => v + Z * (i + 0.5), T = g(e, "svg", { viewBox: `0 0 ${o} ${U}`, role: "img", "aria-label": se(t) });
397
+ ft.forEach((i, d) => {
398
+ i === 0 && !N || (T.append(g(e, "text", { x: v - 10, y: z(i) + 3.5, "text-anchor": "end", class: "oc-axis" }, E[d])), T.append(g(e, "line", { x1: v - 6, x2: v - 2, y1: Math.round(z(i)) + 0.5, y2: Math.round(z(i)) + 0.5, class: "oc-tick" })));
399
+ });
400
+ const rt = Math.round(z(N ? Q : Math.max(0, Q))) + 0.5, w = be(t.labels), X = Math.max(...t.labels.map((i) => nt(Xt(i), 10, 1))) + 12, L = Math.max(1, Math.ceil(a / Math.max(1, Math.floor((o - v - P) / Math.max(30, Math.min(120, X)))))), lt = /* @__PURE__ */ new Set();
401
+ for (let i = 0; i < a; i += L) lt.add(i);
402
+ const G = Math.max(...lt);
403
+ G !== a - 1 && (a - 1 - G < L * 0.75 && G !== 0 && lt.delete(G), lt.add(a - 1));
404
+ const K = g(e, "g");
405
+ T.append(K), t.labels.forEach((i, d) => {
406
+ if (a > 1 && (p || a > 6)) {
407
+ const S = w ? w[d] === 1 : !1;
408
+ K.append(g(e, "line", { x1: Math.round(I(d)) + 0.5, x2: Math.round(I(d)) + 0.5, y1: rt + 2, y2: rt + (S ? 7 : 5), class: `oc-tick${S ? " major" : ""}` }));
409
+ }
410
+ if (!lt.has(d)) return;
411
+ const A = It(Xt(i), Math.max(36, Z * L - 6), 10), b = nt(A, 10, 1) / 2;
412
+ K.append(g(e, "text", { x: Math.max(b, Math.min(o - b, I(d))), y: U - 4, "text-anchor": "middle", class: "oc-axis" }, A));
413
+ });
414
+ const J = g(e, "g");
415
+ T.append(J);
416
+ const Lt = [], ct = 900, wt = (i) => (i - v) / Math.max(1, o - v - P) * ct, At = [];
417
+ if (p) {
418
+ const i = t.kind === "line" && Zt(t, Z);
419
+ if (t.series.forEach((d, A) => {
420
+ const b = Ot(t, A), S = g(e, "g", { class: "oc-series" });
421
+ At.push(S), J.append(S);
422
+ const j = h[A].map((pt, ht) => [I(ht), z(pt)]), B = m >= 0 ? m : d.values.indexOf(Math.max(...d.values));
423
+ if (t.kind === "area" && (l || n) ? j.forEach(([pt, ht], mt) => {
424
+ const $ = z(n ? f[A][mt] : 0);
425
+ if (Math.abs($ - ht) < 0.5) return;
426
+ const tt = !n && mt === B, H = g(e, "line", { x1: pt, x2: pt, y1: $, y2: ht, stroke: tt ? Et : b, "stroke-width": tt ? 1.5 : 1, opacity: tt ? 1 : n ? 0.75 : 0.5 });
427
+ S.append(C(H, "grow", mt / a * 700, 320));
428
+ }) : t.kind === "area" && S.append(C(g(e, "path", { d: `${Bt(j)} L${I(a - 1)},${z(0)} L${I(0)},${z(0)} Z`, fill: b, "fill-opacity": 0.07, stroke: "none" }), "in", 300, 600)), !n || A === s - 1) {
429
+ const pt = g(e, "path", { d: Bt(j), fill: "none", stroke: n ? "var(--ink-2)" : l && t.kind === "area" ? "var(--chart-seq-4)" : b, "stroke-width": l ? 1.5 : 1.75, "stroke-linejoin": "round", "stroke-linecap": "round", pathLength: 1, "stroke-dasharray": "1 2" });
430
+ S.append(C(pt, "draw", 0, ct));
431
+ }
432
+ i && j.forEach(([pt, ht], mt) => {
433
+ if (mt === a - 1 || mt === B) return;
434
+ const $ = w && (w[mt] === 0 || w[mt] === 6), tt = g(e, "circle", { cx: pt, cy: ht, r: a <= 14 ? 2.6 : 2.1, fill: $ ? void 0 : b, stroke: $ ? b : void 0, class: $ ? "oc-hollow" : "" });
435
+ S.append(C(tt, "pop", wt(pt), 200));
436
+ }), n || (B !== a - 1 && (l || m >= 0) ? Lt.push({ x: j[B][0], y: j[B][1], text: gt(d.values[B]), color: l ? Et : b, accent: l, delay: wt(j[B][0]) }) : !l && B !== a - 1 && S.append(C(g(e, "circle", { cx: j[B][0], cy: j[B][1], r: 2.5, fill: b, class: "oc-dot" }), "pop", wt(j[B][0]), 200)), S.append(C(g(e, "circle", { cx: j[a - 1][0], cy: j[a - 1][1], r: 3.75, fill: l ? "var(--chart-seq-4)" : b, class: "oc-dot" }), "pop", ct - 60, 240)));
437
+ }), n) {
438
+ const d = m >= 0 ? m : y.indexOf(Math.max(...y));
439
+ Lt.push({ x: I(d), y: z(Math.max(...h.map((A) => A[d]))), text: gt(y[d]), color: "var(--ink)", delay: wt(I(d)) });
440
+ }
441
+ for (const d of Dt(V.map((A) => ({ ...A, ty: z(A.v) })), st - 8, U - x - 2, 15)) {
442
+ const A = I(a - 1) + 9;
443
+ J.append(C(g(e, "text", { x: A, y: d.ty + 4, class: "oc-val key" }, d.text), "in", ct, 260)), d.name && J.append(C(g(e, "text", { x: A + nt(d.text, 12) + 5, y: d.ty + 4, class: "oc-name" }, d.name), "in", ct + 60, 260));
444
+ }
445
+ } else {
446
+ const i = F > 1 ? Math.max(2, Math.min(4, Z * 0.06)) : 0, d = Math.max(2, Math.min(l || n ? 30 : 16, (Z * (l || n ? 0.6 : 0.74) - i * (F - 1)) / F)), A = Math.abs(z(M) - z(0)), b = A >= 10 ? 2.5 : A >= 7 ? 2 : A >= 4.5 ? 1.5 : 1, S = y.indexOf(Math.max(...y)), j = new Set(m >= 0 ? [m] : ot ? [] : [S, a - 1]), B = l ? m >= 0 ? m : a >= 3 && y.filter(($) => $ === y[S]).length === 1 ? S : -1 : -1, pt = Math.max(1, Math.round((vt - Math.min(0, Q)) / M)), ht = Math.min(45, 320 / a), mt = 560 / pt;
447
+ for (let $ = 0; $ < a; $++) {
448
+ const tt = g(e, "g", { class: "oc-col" });
449
+ if (At.push(tt), J.append(tt), t.series.forEach((H, dt) => {
450
+ const xt = l ? $ === B ? Et : "var(--chart-seq-3)" : bt(H, dt), yt = F === 1 ? I($) - d / 2 : I($) - (F * d + i * (F - 1)) / 2 + dt * (d + i), Ct = H.values[$];
451
+ if (!Ct) return;
452
+ if (!R) {
453
+ const ut = z(n ? f[dt][$] : 0), $t = z(h[dt][$]);
454
+ tt.append(C(g(e, "rect", { x: yt, y: Math.min(ut, $t), width: d, height: Math.max(0.5, Math.abs(ut - $t) - (n ? 1 : 0)), fill: xt }), "grow", $ * ht, 420));
455
+ return;
456
+ }
457
+ const le = Ct >= 0 ? 1 : -1, ce = n ? Math.round(Math.abs(f[dt][$]) / M) : 0, Nt = Math.abs(n ? h[dt][$] : Ct) / M, jt = n ? Math.round(Nt) : Math.floor(Nt + 1e-9), Ht = n ? 0 : Nt - jt, Ut = (ut, $t) => {
458
+ const _t = z(le * (ut + 0.5) * M), Yt = (ut + 1) % 5 === 0, pe = l && t.goal !== void 0 && (ut + 1) * M > t.goal + 1e-9, he = g(e, "line", { x1: yt + (d - $t) / 2, x2: yt + (d + $t) / 2, y1: _t, y2: _t, stroke: pe ? Et : xt, "stroke-width": Yt ? b + 0.75 : b, opacity: Yt || $t < d ? 1 : l ? 0.58 : 0.82, class: "oc-rung" });
459
+ tt.append(C(he, "up", $ * ht + ut * mt, 200));
460
+ };
461
+ for (let ut = ce; ut < jt; ut++) Ut(ut, d);
462
+ Ht >= 0.12 && Ut(jt, Math.max(2, d * Ht));
463
+ }), !n && F > 1 && (ot || j.has($)))
464
+ t.series.forEach((H, dt) => {
465
+ const xt = H.values[$], yt = I($) - (F * d + i * (F - 1)) / 2 + dt * (d + i) + d / 2;
466
+ tt.append(C(g(e, "text", { x: yt, y: xt >= 0 ? z(xt) - 6 : z(xt) + 13, "text-anchor": "middle", class: `oc-val${j.has($) ? " key" : ""}` }, gt(xt)), "in", $ * ht + 600, 260));
467
+ });
468
+ else if (ot || j.has($)) {
469
+ const H = y[$], dt = n ? Math.min(...h.map((yt) => z(yt[$])), z(0)) : z(H), xt = `oc-val${j.has($) || ot ? " key" : ""}${$ === B ? " accent" : ""}`;
470
+ tt.append(C(g(e, "text", { x: I($), y: H >= 0 ? dt - 7 : z(H) + 14, "text-anchor": "middle", class: xt }, gt(H)), "in", $ * ht + Math.min(560, Math.abs(H / M) * mt) + 120, 260));
471
+ }
472
+ }
473
+ if (D) {
474
+ const $ = Dt(u.map((H) => ({ ...H, ty: z((f[H.si][a - 1] + h[H.si][a - 1]) / 2) })), st, U - x - 4, 13), tt = I(a - 1) + d / 2 + 8;
475
+ for (const H of $) J.append(C(g(e, "text", { x: tt, y: H.ty + 3.5, class: "oc-name", fill: bt(t.series[H.si], H.si) }, H.name), "in", 900, 260));
476
+ }
477
+ }
478
+ for (const i of Lt)
479
+ J.append(C(g(e, "circle", { cx: i.x, cy: i.y, r: 4, fill: i.color, class: "oc-dot" }), "pop", i.delay, 260)), J.append(C(g(e, "text", { x: i.x, y: i.y - 10 < st - 14 ? i.y + 18 : i.y - 10, "text-anchor": "middle", class: `oc-val key${i.accent ? " accent" : ""}` }, i.text), "in", i.delay + 80, 260));
480
+ if (T.append(g(e, "line", { x1: v, x2: o - P + (V.length ? 4 : 0), y1: rt, y2: rt, class: "oc-base" })), t.goal !== void 0) {
481
+ const i = z(t.goal);
482
+ T.append(g(e, "line", { x1: v, x2: o - P, y1: i, y2: i, class: "oc-goal" })), T.append(g(e, "text", { x: o - P, y: i - 5, "text-anchor": "end", class: "oc-axis" }, `目标 ${gt(t.goal)}`));
483
+ }
484
+ const zt = g(e, "line", { x1: 0, x2: 0, y1: st - 10, y2: rt, class: "oc-cross", visibility: "hidden" }), kt = g(e, "circle", { r: 4.5, fill: "none", stroke: "var(--ink)", "stroke-width": 1.25, visibility: "hidden" });
485
+ T.append(zt, kt);
486
+ const Rt = g(e, "rect", { x: v, y: 0, width: o - v - P, height: U, fill: "transparent" });
487
+ T.append(Rt);
488
+ const Ft = !!(t.links?.some(Boolean) || t.series.some((i) => i.links?.some(Boolean))), St = c(e, "div", { class: `oc-plot${Ft ? " clickable" : ""}`, tabindex: 0, "aria-label": `${t.title ?? "图表"}:方向键逐个看数值${Ft ? ",回车打开明细" : ""}` });
489
+ St.append(T);
490
+ const Pt = ne(e, St), ie = (i) => i < v || i > o - P ? -1 : Math.min(a - 1, Math.max(0, Math.floor((i - v) / Z))), Mt = () => o / (T.getBoundingClientRect().width || o), Tt = (i, d) => d < 0 || s < 2 ? -1 : h.map((A, b) => [Math.abs(z(A[i]) - d * Mt()), b]).sort((A, b) => A[0] - b[0])[0][1];
491
+ ae(
492
+ St,
493
+ Rt,
494
+ a,
495
+ (i) => ie(i * Mt()),
496
+ (i, d) => {
497
+ if (T.classList.add("oc-hovering"), p) {
498
+ zt.setAttribute("x1", String(I(i))), zt.setAttribute("x2", String(I(i))), zt.setAttribute("visibility", "visible");
499
+ const b = n ? -1 : Tt(i, d);
500
+ At.forEach((j, B) => j.classList.toggle("on", b < 0 || B === b));
501
+ const S = b >= 0 ? b : l ? 0 : -1;
502
+ S >= 0 ? (kt.setAttribute("cx", String(I(i))), kt.setAttribute("cy", String(z(h[S][i]))), kt.setAttribute("visibility", "visible")) : kt.setAttribute("visibility", "hidden");
503
+ } else At.forEach((b, S) => b.classList.toggle("on", S === i));
504
+ const A = t.series.map((b, S) => ({ key: Ot(t, S), name: b.name, value: `${et(b.values[i])}${r}` }));
505
+ n && A.push({ key: "transparent", name: "合计", value: `${et(y[i])}${r}` }), Pt.show(I(i) / Mt(), Math.min(...h.map((b) => z(b[i]))) / Mt(), t.labels[i], A);
506
+ },
507
+ () => {
508
+ T.classList.remove("oc-hovering"), At.forEach((i) => i.classList.remove("on")), zt.setAttribute("visibility", "hidden"), kt.setAttribute("visibility", "hidden"), Pt.hide();
509
+ },
510
+ Ft ? (i, d, A) => {
511
+ let b = -1;
512
+ if (A >= 0 && s > 1) {
513
+ const S = Q + (vt - Q) * (1 - (A * Mt() - st) / (U - st - x));
514
+ n ? b = t.series.findIndex((j, B) => Math.min(f[B][i], h[B][i]) <= S && S <= Math.max(f[B][i], h[B][i])) : p ? b = Tt(i, A) : b = Math.min(s - 1, Math.max(0, Math.floor((d * Mt() - (I(i) - Z * 0.37)) / (Z * 0.74) * s)));
515
+ }
516
+ Me(e, (b >= 0 ? t.series[b].links?.[i] : void 0) ?? t.links?.[i] ?? t.series.map((S) => S.links?.[i]).find(Boolean));
517
+ } : void 0
518
+ );
519
+ const Vt = R ? [`一格 = ${ee(M, r)}`, "每五格加粗", t.goal !== void 0 && l ? "过目标的格标红" : ""] : t.kind === "line" && Zt(t, Z) ? [w ? "一点一天 · 空心是周末" : "一点一个值", "标出最高和最后"] : t.kind === "area" && (l || n) ? [w ? "一根竖线一天" : "一根竖线一个值", l ? "最高的那根加深" : "按种类分段"] : [], re = Vt.filter(Boolean).length ? c(e, "p", { class: "oc-foot" }, Vt.filter(Boolean).join(" · ")) : null;
520
+ return [Y ? oe(e, t, n) : null, St, re].filter((i) => !!i);
521
+ }
522
+ const Zt = (e, t) => e.series.length === 1 && e.labels.length <= 45 && t >= 6;
523
+ function se(e) {
524
+ const t = e.labels.length, o = t > 1 ? `${e.labels[0]} 到 ${e.labels[t - 1]}` : e.labels[0] ?? "", a = e.series.map((s) => `${s.name} ${e.kind === "line" ? `最后 ${et(s.values[t - 1])}` : `合计 ${et(s.values.reduce((r, n) => r + n, 0))}`}`).join(",");
525
+ return `${e.title ?? "图表"}${e.unit ? `(${e.unit})` : ""}:${o};${a}`;
526
+ }
527
+ function Ee(e, t, o) {
528
+ const a = t.labels.length, s = t.series.length, r = s > 1 && !!t.stack, n = t.unit ?? "", p = t.highlight ? t.labels.indexOf(t.highlight) : -1, l = t.labels.map((u, O) => t.series.reduce((D, Y) => D + Math.max(0, Y.values[O]), 0)), m = t.labels.map((u, O) => t.series.reduce((D, Y) => D + Math.min(0, Y.values[O]), 0)), f = r ? [...l, ...m] : t.series.flatMap((u) => u.values), h = f.every(Number.isInteger), y = a <= 2 && s === 1, q = Math.max(100, o * 0.6 - (t.extras?.length ?? 0) * 70), k = te(Math.max(...f.map(Math.abs), ...t.goal !== void 0 ? [Math.abs(t.goal)] : []), h, Math.max(12, Math.min(110, Math.round(q / 4.5)))), F = Math.min(0, Math.floor(Math.min(...f, ...t.goal !== void 0 ? [t.goal] : []) / k) * k), M = Math.max(k, Math.ceil(Math.max(0, ...f, ...t.goal !== void 0 ? [t.goal] : []) / k) * k) - F, N = (u) => (u - F) / M * 100, _ = (u) => Kt(u, n), at = s > 1 && !r, Q = Math.max(...(r ? t.labels.map((u, O) => _(t.series.reduce((D, Y) => D + Y.values[O], 0))) : t.series.flatMap((u) => u.values.map(_))).map((u) => u.length)), vt = at ? Math.max(...t.series.map((u) => nt(u.name, 10.5, 0.8) / 12)) + 0.6 : 0, ft = `${Math.max(2.4, Q * 0.62 + 1.4 + vt)}em`, ot = F < 0 ? ft : "0px", U = t.extras ?? [], x = `--label-w:${Math.min(16, Math.max(4, Math.max(...t.labels.map((u) => nt(u, 13) / 13)) + 0.6))}em;${U.length ? "--extras:auto;" : ""}`, E = c(e, "div", { class: "oc-rows", style: x, role: "list", "aria-label": se(t) });
529
+ U.length && E.append(c(e, "div", { class: "oc-row head", "aria-hidden": "true" }, c(e, "span", {}, ""), c(e, "span", {}, ""), c(e, "span", { class: "oc-extras", style: `--n:${U.length}` }, ...U.map((u) => c(e, "span", {}, u.name)))));
530
+ const v = M / k, V = y ? "" : `max-width:${Math.ceil(v * 7)}px`;
531
+ t.goal !== void 0 && E.append(c(e, "div", { class: "oc-row head", "aria-hidden": "true" }, c(e, "span", {}, ""), c(e, "span", {}, c(e, "span", { class: "oc-goal-label", style: `display:block;margin-left:${ot};margin-right:${ft};${V}` }, c(e, "span", { style: `left:${N(t.goal)}%` }, `目标 ${gt(t.goal)}`))), U.length ? c(e, "span", {}, "") : null));
532
+ const it = (u, O, D, Y, z = 1 / 0, Z = 0) => {
533
+ const I = D >= O ? 1 : -1, T = Math.abs(D - O), rt = Math.floor(T + 1e-9), w = T - rt, X = (L, lt) => {
534
+ const G = O + I * (L + 0.5), K = (Z + L + 1) % 5 === 0, J = (Z + L + 1) * k > z + 1e-9 ? Et : Y;
535
+ u.append(g(e, "line", { x1: G, x2: G, y1: K ? 0 : 3.5 + (1 - lt) * 9.5, y2: 14, stroke: J, "stroke-width": K ? 1.6 : 1.1, opacity: K || lt < 1 ? 1 : 0.7 }));
536
+ };
537
+ for (let L = 0; L < rt; L++) X(L, 1);
538
+ w >= 0.12 && X(rt, Math.max(0.25, w));
539
+ }, W = () => g(e, "svg", { class: "oc-ticks", viewBox: `0 0 ${v} 14`, preserveAspectRatio: "none", "aria-hidden": "true" });
540
+ for (let u = 0; u < a; u++) {
541
+ const O = t.links?.[u], D = !O && t.series.some((w) => w.links?.[u]), Y = t.labels[u], z = r ? `${Y}:合计 ${et(t.series.reduce((w, X) => w + X.values[u], 0))}${n}(${t.series.map((w) => `${w.name} ${et(w.values[u])}`).join(",")})` : `${Y}:${t.series.map((w) => `${s > 1 ? `${w.name} ` : ""}${et(w.values[u])}${n}`).join(",")}`, Z = Gt(e, O, at ? "oc-row multi" : "oc-row", { role: "listitem", "aria-label": z, title: z });
542
+ Z.append(c(e, "span", { class: `oc-row-label${p === u ? " key" : ""}` }, Y));
543
+ const I = c(e, "span", { class: `oc-bars${at ? " multi" : ""}` }), T = Math.min(u * 55, 360), rt = (w, X) => {
544
+ const L = c(e, w ? "a" : "span", { class: "oc-track", style: `--room:${ft};--room-left:${ot};${V}`, ...w ? { href: w, "aria-label": X } : {} });
545
+ return t.goal !== void 0 && L.append(c(e, "span", { class: "oc-goal-v", style: `left:${N(t.goal)}%` })), L;
546
+ };
547
+ if (r) {
548
+ const w = rt(), X = W();
549
+ let L = 0;
550
+ t.series.forEach((G, K) => {
551
+ const J = Math.max(0, G.values[u]);
552
+ J && (it(X, (0 - F) / k + L / k, (0 - F) / k + (L + J) / k, bt(G, K), 1 / 0, Math.round(L / k)), L += J);
553
+ }), w.append(C(X, "wipe", T, 700));
554
+ const lt = t.series.reduce((G, K) => G + K.values[u], 0);
555
+ w.append(C(c(e, "span", { class: "oc-bar-v key", style: `left:${N(Math.max(0, l[u]))}%` }, _(lt)), "in", T + 560, 260)), I.append(w);
556
+ } else
557
+ t.series.forEach((w, X) => {
558
+ const L = w.values[u], lt = D ? w.links?.[u] : void 0, G = rt(lt, `${Y} ${w.name} ${et(L)}${n}`), K = s === 1 ? p === u ? Et : "var(--chart-seq-3)" : bt(w, X);
559
+ if (y) {
560
+ const ct = N(Math.min(0, L)), wt = N(Math.max(0, L));
561
+ G.append(C(c(e, "span", { class: "oc-thin", style: `left:${ct}%;width:${Math.max(wt - ct, L ? 0.6 : 0)}%;background:${K}` }), "wipe", T, 600));
562
+ } else {
563
+ const ct = W();
564
+ it(ct, (0 - F) / k, (L - F) / k, K, s === 1 && t.goal !== void 0 ? t.goal : 1 / 0), G.append(C(ct, "wipe", T + X * 40, 700));
565
+ }
566
+ const J = p === u || s === 1 && p < 0 && a > 2 && L === Math.max(...w.values) && L > 0, Lt = c(e, "span", { class: `oc-bar-v${J ? " key" : ""}`, style: L < 0 ? `right:${100 - N(L)}%` : `left:${N(L)}%` }, _(L), at ? c(e, "small", {}, w.name) : null);
567
+ G.append(C(Lt, "in", T + X * 40 + 520, 260)), I.append(G);
568
+ });
569
+ Z.append(I), U.length && Z.append(c(e, "span", { class: "oc-extras", style: `--n:${U.length}` }, ...U.map((w) => {
570
+ const X = w.values[u] ?? "", L = w.links?.[u];
571
+ return L && !O ? c(e, "a", { href: L }, X) : c(e, "span", {}, X || "—");
572
+ }))), E.append(Z);
573
+ }
574
+ const P = y ? null : c(e, "p", { class: "oc-foot" }, [`一格 = ${ee(k, n)}`, "每五格加长", r ? "颜色分种类" : "", p >= 0 && s === 1 ? "红的是要看的那一行" : ""].filter(Boolean).join(" · "));
575
+ return [r ? oe(e, t, !0) : null, E, P].filter((u) => !!u);
576
+ }
577
+ function Le(e, t, o) {
578
+ const a = t.series[0], s = a.values.map((x) => Math.max(0, x)), r = s.reduce((x, E) => x + E, 0) || 1, n = t.unit ?? "", p = ve(s), l = o < 420, m = l ? 64 : 78, f = m - (l ? 15 : 18), h = Math.min(150, Math.max(...t.labels.map((x, E) => nt(`${It(x, 96, 10.5)} · ${Math.round(s[E] / r * 100)}%`, 10.5, 0.8))) + 22), y = Math.min(o, Math.max(2 * (m + h), 2 * m + 40)), q = y / 2, k = m + 28, F = 2 * m + 56, R = (x) => `${Math.round(x / r * 1e3) / 10}%`, M = g(e, "svg", { viewBox: `0 0 ${y} ${F}`, role: "img", "aria-label": `${t.title ?? "构成"}:${t.labels.map((x, E) => `${x} ${et(a.values[E])}${n}(${R(s[E])})`).join(",")}`, style: `max-width:${y}px;margin:0 auto` }), N = [], _ = (x, E) => [q + x * Math.cos(E), k + x * Math.sin(E)], at = (x) => -Math.PI / 2 + (x + 0.5) / 100 * Math.PI * 2;
579
+ let Q = 0;
580
+ const vt = [];
581
+ p.forEach((x, E) => {
582
+ const v = g(e, "g", { class: "oc-part" });
583
+ N.push(v), M.append(v);
584
+ const V = bt({ slot: E }, E);
585
+ for (let it = 0; it < x; it++, Q++) {
586
+ const W = at(Q), P = (Q + 1) % 10 === 0, [u, O] = _(f, W), [D, Y] = _(P ? m + 3 : m, W);
587
+ v.append(C(g(e, "line", { x1: u, y1: O, x2: D, y2: Y, stroke: V, "stroke-width": l ? 1.6 : 1.9, "stroke-linecap": "butt" }), "in", Q * 7, 160));
588
+ }
589
+ x && vt.push({ i: E, a: at(Q - x / 2 - 0.5) });
590
+ });
591
+ for (let x = 9; x < 100; x += 10) {
592
+ const [E, v] = _(m + 7, at(x));
593
+ M.append(C(g(e, "circle", { cx: E, cy: v, r: 0.9, fill: "var(--chart-axis)" }), "in", x * 7, 160));
594
+ }
595
+ const ft = vt.map((x) => {
596
+ const E = Math.cos(x.a) >= 0, [v, V] = _(m + 10, x.a);
597
+ return { ...x, right: E, ax: v, ay: V, ty: V };
598
+ });
599
+ for (const x of [!0, !1]) {
600
+ const E = Dt(ft.filter((v) => v.right === x), 8, F - 6, 14);
601
+ for (const v of E) {
602
+ const V = q + (x ? 1 : -1) * (m + 18), [it, W] = _(m + 4, v.a), P = bt({ slot: v.i }, v.i);
603
+ M.append(C(g(e, "path", { d: `M${it},${W} L${v.ax},${v.ay} L${V + (x ? -4 : 4)},${v.ty}`, fill: "none", stroke: P, "stroke-width": 1, opacity: 0.7 }), "in", 700, 300));
604
+ const u = g(e, "text", { x: V, y: v.ty + 3.5, "text-anchor": x ? "start" : "end", class: "oc-name" }), O = It(t.labels[v.i], Math.max(40, h - 60), 10.5), D = g(e, "tspan", {}, `${O} · `), Y = g(e, "tspan", { fill: "var(--ink)", "font-weight": 650 }, s[v.i] / r < 0.01 ? "<1%" : `${Math.round(s[v.i] / r * 100)}%`);
605
+ u.append(D, Y), M.append(C(u, "in", 760, 300));
606
+ }
607
+ }
608
+ n !== "%" && M.append(g(e, "text", { x: q, y: k + 6, "text-anchor": "middle", class: "oc-total oc-count" }, gt(r))), M.append(g(e, "text", { x: q, y: k + (n !== "%" ? 22 : 4), "text-anchor": "middle", class: "oc-axis" }, n !== "%" ? n ? `合计 · ${n}` : "合计" : "一格 1%"));
609
+ const ot = c(e, "div", { class: "oc-plot", tabindex: 0, "aria-label": `${t.title ?? "构成"}:方向键逐个看数值` });
610
+ ot.append(M);
611
+ const U = ne(e, ot), st = (x) => {
612
+ M.classList.toggle("oc-hovering", x >= 0), N.forEach((E, v) => E.classList.toggle("on", v === x));
613
+ };
614
+ return ae(
615
+ ot,
616
+ M,
617
+ t.labels.length,
618
+ (x, E) => {
619
+ const v = y / (M.getBoundingClientRect().width || y), V = x * v - q, it = E * v - k, W = Math.hypot(V, it);
620
+ if (W < f - 6 || W > m + 10) return -1;
621
+ let P = Math.atan2(it, V) + Math.PI / 2;
622
+ P < 0 && (P += Math.PI * 2);
623
+ const u = Math.floor(P / (Math.PI * 2) * 100);
624
+ let O = 0;
625
+ for (let D = 0; D < p.length; D++)
626
+ if (O += p[D], u < O) return D;
627
+ return p.length - 1;
628
+ },
629
+ (x) => {
630
+ st(x);
631
+ const E = y / (M.getBoundingClientRect().width || y);
632
+ U.show((q + m * 0.6) / E, k / E, t.labels[x], [{ key: bt({ slot: x }, x), name: R(s[x]), value: `${et(a.values[x])}${n}` }]);
633
+ },
634
+ () => {
635
+ st(-1), U.hide();
636
+ }
637
+ ), [ot, c(e, "p", { class: "oc-foot" }, "一格 = 1% · 从十二点起顺时针 · 每十格一个点")];
638
+ }
639
+ function Ae(e) {
640
+ if (e.trend) return e.trend;
641
+ const t = e.change?.trim();
642
+ return t ? /^[++↑▲]/.test(t) ? /^[++]\s*0+(\.0+)?(?![\d.])/.test(t) ? "flat" : "up" : /^[-−–↓▼]/.test(t) ? /^[-−–]\s*0+(\.0+)?(?![\d.])/.test(t) ? "flat" : "down" : /^(持平|不变|0+(\.0+)?%?$)/.test(t) ? "flat" : null : null;
643
+ }
644
+ function ze(e, t, o) {
645
+ qt(e);
646
+ const a = 150, s = 30, r = 3, n = (Math.min(...t) + Math.max(...t)) / 2, p = Math.max(Math.max(...t) - Math.min(...t), Math.abs(n) * 0.2) || 1, l = Math.min(n - p / 2, Math.min(...t) >= 0 ? Math.max(0, n - p) : n - p / 2), m = n + p / 2, f = (R) => r + (a - 2 * r) * R / Math.max(1, t.length - 1), h = (R) => r + (s - 2 * r) * (1 - (R - l) / (m - l)), y = t.map((R, M) => [f(M), h(R)]), q = g(e, "svg", { viewBox: `0 0 ${a} ${s}`, class: "oc-spark", ...o ? { role: "img", "aria-label": o } : { "aria-hidden": "true" } });
647
+ t.length <= 60 && y.forEach(([R, M], N) => q.append(C(g(e, "line", { x1: R, x2: R, y1: s, y2: M, class: "oc-spark-hair" }), "grow", N / t.length * 600, 260))), q.append(C(g(e, "path", { d: Bt(y), class: "oc-spark-line", pathLength: 1, "stroke-dasharray": "1 2" }), "draw", 0, 800));
648
+ const [k, F] = y[y.length - 1];
649
+ return q.append(C(g(e, "circle", { cx: k, cy: F, r: 2.5, class: "oc-spark-dot" }), "pop", 760, 220)), q;
650
+ }
651
+ function Se(e, t, o) {
652
+ const a = Ae(t), s = a ? a === "flat" || t.good === "none" ? "neutral" : a === (t.good ?? "up") ? "good" : "bad" : "", r = t.change?.trim(), n = r && a && !/^[↑↓→▲▼]/.test(r) ? `${{ up: "↑", down: "↓", flat: "→" }[a]} ` : "", p = o ? c(e, "button", { type: "button", class: "oc-metric", title: t.hint, "aria-expanded": "false" }) : Gt(e, t.link, "oc-metric", { title: t.hint });
653
+ o && p.addEventListener("click", o);
654
+ const l = String(t.value);
655
+ return p.append(
656
+ c(e, "span", { class: "oc-mlabel", title: t.hint ? void 0 : t.label }, t.label, t.tag ? c(e, "span", { class: "oc-mtag" }, t.tag) : null),
657
+ t.pending ? c(e, "span", { class: "oc-mpending" }, t.pending) : c(e, "span", { class: "oc-mvalue", "aria-label": `${l}${t.unit?.trim() ?? ""}` }, c(e, "b", { class: "oc-count", "aria-hidden": "true" }, l), t.unit?.trim() ? c(e, "span", { "aria-hidden": "true" }, t.unit.trim()) : null)
658
+ ), (r || t.note) && p.append(c(e, "span", { class: "oc-mfoot" }, r ? c(e, "span", { class: "oc-delta", "data-tone": s || "neutral" }, `${n}${r}`) : null, t.note ? c(e, "span", {}, t.note) : null)), t.spark && t.spark.length > 1 && p.append(ze(e, t.spark, `${t.label}最近的走势:${t.spark.map(et).join("、")}`)), p;
659
+ }
660
+ function Ne(e, t, o = {}) {
661
+ qt(e);
662
+ const a = t.items.length, s = a <= 4 ? a : a <= 6 ? 3 : 4, r = o.select, n = c(e, "div", { class: "oc-metrics", style: `--cols:${s};--cols-narrow:${Math.min(2, a)}` }, ...t.items.map((l, m) => Se(e, l, r ? () => r(m) : void 0))), p = c(
663
+ e,
664
+ "div",
665
+ { class: t.even ? "oc-mgroup oc-even" : "oc-mgroup" },
666
+ t.title ? c(e, "span", { class: "oc-mtitle" }, t.title) : null,
667
+ n,
668
+ t.note ? c(e, "p", { class: "oc-note" }, t.note) : null
669
+ );
670
+ return queueMicrotask(() => Qt(n, () => n.querySelectorAll(".oc-count").forEach((l) => Wt(l)))), p;
671
+ }
672
+ export {
673
+ gt as compact,
674
+ Bt as curve,
675
+ ve as dialTicks,
676
+ qt as ensureChartStyle,
677
+ et as full,
678
+ Ne as metricsElement,
679
+ Ce as mountChart,
680
+ te as rungUnit,
681
+ bt as seriesColor,
682
+ Fe as setChartMotion,
683
+ ze as sparkline,
684
+ Ae as trendOf,
685
+ Kt as withUnit
686
+ };