@hybridcore/ui 1.6.21 → 1.6.23

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.
@@ -1,19 +1,21 @@
1
- import { R as ke, A as Ie } from "../../../AnimatedTheme-ktdO3Bel.js";
2
- import { useTheme as Oe, useThemeProps as Te } from "@mui/material";
3
- import z from "lodash";
4
- import { useState as Ce, useRef as P, useLayoutEffect as Xe, useEffect as Me } from "react";
5
- import { getTooltipDateFormat as Pe, attachCursorTooltip as Ee } from "../_common/tooltip.js";
6
- import { applyValueFormat as Ye } from "../_common/utils.js";
7
- import { c as A, a as ue } from "../../../Entity-BJCuhdq_.js";
8
- import { X as Le, V as Se } from "../../../AxisRenderer-BCQoUJw6.js";
9
- import { X as je } from "../../../XYCursor-CVUSpqb9.js";
10
- import { A as Re, a as $e } from "../../../AxisRendererY-AXWvGU6r.js";
11
- import { L as Ve } from "../../../Legend-CFvQiIfn.js";
12
- import { L as q } from "../../../LineSeries-D_IL2qGF.js";
13
- import { G as He, D as Ue } from "../../../GaplessDateAxis-B2g2jgSG.js";
14
- import { D as Be } from "../../../DateAxis-DEXKps1S.js";
15
- class Ge {
16
- constructor(t, n) {
1
+ import { R as Be, A as je } from "../../../AnimatedTheme-ktdO3Bel.js";
2
+ import { useTheme as Ue, useThemeProps as $e } from "@mui/material";
3
+ import Q from "lodash";
4
+ import { useState as Ne, useRef as M, useLayoutEffect as Ge, useEffect as He } from "react";
5
+ import { getTooltipDateFormat as We, attachCursorTooltip as ze } from "../_common/tooltip.js";
6
+ import { applyValueFormat as Ze } from "../_common/utils.js";
7
+ import { c as O, a as Ae } from "../../../Entity-BJCuhdq_.js";
8
+ import { X as qe, V as Je } from "../../../AxisRenderer-BCQoUJw6.js";
9
+ import { X as Ke } from "../../../XYCursor-CVUSpqb9.js";
10
+ import { A as Qe, a as et } from "../../../AxisRendererY-AXWvGU6r.js";
11
+ import { L as tt } from "../../../Legend-CFvQiIfn.js";
12
+ import { L as G } from "../../../LineSeries-D_IL2qGF.js";
13
+ import { C as it } from "../../../Circle-BnfBNKBD.js";
14
+ import { B as rt } from "../../../Bullet-Djj7Vs9T.js";
15
+ import { G as nt, D as st } from "../../../GaplessDateAxis-B2g2jgSG.js";
16
+ import { D as ot } from "../../../DateAxis-DEXKps1S.js";
17
+ class at {
18
+ constructor(r, a) {
17
19
  Object.defineProperty(this, "_line", {
18
20
  enumerable: !0,
19
21
  configurable: !0,
@@ -59,7 +61,7 @@ class Ge {
59
61
  configurable: !0,
60
62
  writable: !0,
61
63
  value: 0
62
- }), this._context = t, this._tension = n;
64
+ }), this._context = r, this._tension = a;
63
65
  }
64
66
  areaStart() {
65
67
  this._line = 0;
@@ -76,77 +78,77 @@ class Ge {
76
78
  this._context.lineTo(this._x1, this._y1);
77
79
  break;
78
80
  case 3:
79
- Z(this, this._t0, de(this, this._t0));
81
+ ae(this, this._t0, Oe(this, this._t0));
80
82
  break;
81
83
  }
82
84
  (this._line || this._line !== 0 && this._point === 1) && this._context.closePath(), this._line = 1 - this._line;
83
85
  }
84
- point(t, n) {
85
- let c = NaN;
86
- if (t = +t, n = +n, !(t === this._x1 && n === this._y1)) {
86
+ point(r, a) {
87
+ let h = NaN;
88
+ if (r = +r, a = +a, !(r === this._x1 && a === this._y1)) {
87
89
  switch (this._point) {
88
90
  case 0:
89
- this._point = 1, this._line ? this._context.lineTo(t, n) : this._context.moveTo(t, n);
91
+ this._point = 1, this._line ? this._context.lineTo(r, a) : this._context.moveTo(r, a);
90
92
  break;
91
93
  case 1:
92
94
  this._point = 2;
93
95
  break;
94
96
  case 2:
95
- this._point = 3, Z(this, de(this, c = pe(this, t, n)), c);
97
+ this._point = 3, ae(this, Oe(this, h = De(this, r, a)), h);
96
98
  break;
97
99
  default:
98
- Z(this, this._t0, c = pe(this, t, n));
100
+ ae(this, this._t0, h = De(this, r, a));
99
101
  break;
100
102
  }
101
- this._x0 = this._x1, this._x1 = t, this._y0 = this._y1, this._y1 = n, this._t0 = c;
103
+ this._x0 = this._x1, this._x1 = r, this._y0 = this._y1, this._y1 = a, this._t0 = h;
102
104
  }
103
105
  }
104
106
  }
105
- function he(r) {
106
- function t(n) {
107
- return new Ge(n, r);
107
+ function Ie(i) {
108
+ function r(a) {
109
+ return new at(a, i);
108
110
  }
109
- return t;
111
+ return r;
110
112
  }
111
- function me(r) {
112
- return r < 0 ? -1 : 1;
113
+ function ke(i) {
114
+ return i < 0 ? -1 : 1;
113
115
  }
114
- function pe(r, t, n) {
115
- let c = r._x1 - r._x0, a = t - r._x1, m = (r._y1 - r._y0) / (c || a < 0 && -0), u = (n - r._y1) / (a || c < 0 && -0), _ = (m * a + u * c) / (c + a);
116
- return (me(m) + me(u)) * Math.min(Math.abs(m), Math.abs(u), 0.5 * Math.abs(_)) || 0;
116
+ function De(i, r, a) {
117
+ let h = i._x1 - i._x0, s = r - i._x1, f = (i._y1 - i._y0) / (h || s < 0 && -0), c = (a - i._y1) / (s || h < 0 && -0), x = (f * s + c * h) / (h + s);
118
+ return (ke(f) + ke(c)) * Math.min(Math.abs(f), Math.abs(c), 0.5 * Math.abs(x)) || 0;
117
119
  }
118
- function de(r, t) {
119
- let n = r._x1 - r._x0;
120
- return n ? (3 * (r._y1 - r._y0) / n - t) / 2 : t;
120
+ function Oe(i, r) {
121
+ let a = i._x1 - i._x0;
122
+ return a ? (3 * (i._y1 - i._y0) / a - r) / 2 : r;
121
123
  }
122
- function Z(r, t, n) {
123
- let c = r._x0, a = r._y0, m = r._x1, u = r._y1, _ = (m - c) / 1.5 * (1 - r._tension);
124
- r._context.bezierCurveTo(c + _, a + _ * t, m - _, u - _ * n, m, u);
124
+ function ae(i, r, a) {
125
+ let h = i._x0, s = i._y0, f = i._x1, c = i._y1, x = (f - h) / 1.5 * (1 - i._tension);
126
+ i._context.bezierCurveTo(h + x, s + x * r, f - x, c - x * a, f, c);
125
127
  }
126
- class E extends q {
128
+ class H extends G {
127
129
  _afterNew() {
128
- this._setDefault("curveFactory", he(this.get("tension", 0.5))), super._afterNew();
130
+ this._setDefault("curveFactory", Ie(this.get("tension", 0.5))), super._afterNew();
129
131
  }
130
132
  _updateChildren() {
131
- this.isDirty("tension") && (this.set("curveFactory", he(this.get("tension", 0.5))), this._valuesDirty = !0), super._updateChildren();
133
+ this.isDirty("tension") && (this.set("curveFactory", Ie(this.get("tension", 0.5))), this._valuesDirty = !0), super._updateChildren();
132
134
  }
133
135
  }
134
- Object.defineProperty(E, "className", {
136
+ Object.defineProperty(H, "className", {
135
137
  enumerable: !0,
136
138
  configurable: !0,
137
139
  writable: !0,
138
140
  value: "SmoothedXLineSeries"
139
141
  });
140
- Object.defineProperty(E, "classNames", {
142
+ Object.defineProperty(H, "classNames", {
141
143
  enumerable: !0,
142
144
  configurable: !0,
143
145
  writable: !0,
144
- value: q.classNames.concat([E.className])
146
+ value: G.classNames.concat([H.className])
145
147
  });
146
- const We = [
148
+ const lt = [
147
149
  { lowerField: "low95", upperField: "high95", label: "95% expected move" },
148
150
  { lowerField: "low68", upperField: "high68", label: "68% expected move" }
149
- ], ze = [0.15, 0.3, 0.45], Ze = 1.1, qe = {
151
+ ], ct = [0.15, 0.3, 0.45], le = 1.1, ut = "spineValue", Te = 5, pt = 7.5, mt = {
150
152
  millisecond: 1,
151
153
  second: 1e3,
152
154
  minute: 6e4,
@@ -155,62 +157,67 @@ const We = [
155
157
  week: 6048e5,
156
158
  month: 2592e6,
157
159
  year: 31536e6
158
- }, T = (r) => new Date(r).getTime(), Je = (r) => new Intl.DateTimeFormat("en-US", {
160
+ }, T = (i) => new Date(i).getTime(), dt = (i) => new Intl.DateTimeFormat("en-US", {
159
161
  month: "short",
160
162
  day: "numeric",
161
163
  hour: "2-digit",
162
164
  minute: "2-digit"
163
- }).format(new Date(r)), ft = (r) => {
164
- const t = Oe(), n = Te({ props: r, name: "HCForecastCone" }), {
165
- data: c = [],
166
- dateField: a = "date",
167
- historyField: m = "close",
168
- centreField: u = "center",
169
- bands: _ = We,
170
- forecasts: g,
171
- nowValue: $,
172
- color: J = t.palette.warning.main,
173
- connectMissingData: V = !0,
174
- skipEmptyDates: K = !0,
175
- baseInterval: Q,
176
- chartId: ee = "forecast-cone-chart",
177
- height: fe = "100%",
178
- width: be = "100%",
179
- loading: te = !1,
180
- emptyMessage: re = "No data available",
181
- sx: _e,
182
- ...ge
183
- } = n, N = Array.isArray(g) && g.length > 0, [X, ye] = Ce(
184
- () => N ? g.length - 1 : 0
185
- ), ie = P(X);
186
- ie.current = X;
187
- const y = z.orderBy(c, [a]).map((e) => ({ ...e }));
188
- if (!N) {
189
- const e = y.findIndex(
190
- (h) => h[u] !== null && h[u] !== void 0
165
+ }).format(new Date(i)), Ce = (i) => i.label ?? dt(i.origin), Et = (i) => {
166
+ const r = Ue(), a = $e({ props: i, name: "HCForecastCone" }), {
167
+ data: h = [],
168
+ dateField: s = "date",
169
+ historyField: f = "close",
170
+ centreField: c = "center",
171
+ bands: x = lt,
172
+ forecasts: _,
173
+ showOriginMarkers: ee = !0,
174
+ nowValue: te,
175
+ color: ce = r.palette.warning.main,
176
+ connectMissingData: R = !0,
177
+ skipEmptyDates: ue = !0,
178
+ baseInterval: pe,
179
+ chartId: me = "forecast-cone-chart",
180
+ height: Ee = "100%",
181
+ width: Pe = "100%",
182
+ loading: de = !1,
183
+ emptyMessage: he = "No data available",
184
+ sx: Le,
185
+ ...Se
186
+ } = a, C = Array.isArray(_) && _.length > 0, [fe, be] = Ne(
187
+ () => C ? _.length - 1 : 0
188
+ ), [W, ie] = Ne(
189
+ null
190
+ ), Y = W ?? fe, z = M(Y);
191
+ z.current = Y;
192
+ const ge = M(W !== null);
193
+ ge.current = W !== null;
194
+ const w = Q.orderBy(h, [s]).map((e) => ({ ...e }));
195
+ if (!C) {
196
+ const e = w.findIndex(
197
+ (p) => p[c] !== null && p[c] !== void 0
191
198
  );
192
- V && e > 0 && (y[e][m] === null || y[e][m] === void 0) && (y[e][m] = y[e][u]);
199
+ R && e > 0 && (w[e][f] === null || w[e][f] === void 0) && (w[e][f] = w[e][c]);
193
200
  }
194
- const ve = {
195
- ...n,
196
- height: fe,
197
- width: be,
198
- chartId: ee,
199
- loading: te,
200
- emptyMessage: re,
201
- baseInterval: Q
202
- }, se = P(null), ne = P(null), H = P(null), M = P(null);
203
- Xe(() => {
204
- var ae, le;
205
- if (!H.current) return;
206
- const e = ke.new(H.current);
207
- ne.current = e, e.setThemes([Ie.new(e)]), e.interfaceColors.setAll({
208
- text: A(t.palette.text.primary),
209
- grid: A(t.palette.divider),
210
- stroke: A(t.palette.divider)
211
- }), Ye(e);
212
- const h = e.container.children.push(
213
- Le.new(e, {
201
+ const Xe = {
202
+ ...a,
203
+ height: Ee,
204
+ width: Pe,
205
+ chartId: me,
206
+ loading: de,
207
+ emptyMessage: he,
208
+ baseInterval: pe
209
+ }, _e = M(null), ve = M(null), re = M(null), V = M(null);
210
+ Ge(() => {
211
+ var xe, we;
212
+ if (!re.current) return;
213
+ const e = Be.new(re.current);
214
+ ve.current = e, e.setThemes([je.new(e)]), e.interfaceColors.setAll({
215
+ text: O(r.palette.text.primary),
216
+ grid: O(r.palette.divider),
217
+ stroke: O(r.palette.divider)
218
+ }), Ze(e);
219
+ const p = e.container.children.push(
220
+ qe.new(e, {
214
221
  panX: !0,
215
222
  panY: !1,
216
223
  wheelX: "none",
@@ -220,206 +227,302 @@ const We = [
220
227
  layout: e.verticalLayout
221
228
  })
222
229
  );
223
- se.current = h, h.set(
230
+ _e.current = p, p.set(
224
231
  "cursor",
225
- je.new(e, { behavior: "none" })
232
+ Ke.new(e, { behavior: "none" })
226
233
  ).lineY.set("visible", !1);
227
- const Y = Q ?? { timeUnit: "hour", count: 1 }, we = K && !N ? He : Be, f = h.xAxes.push(
228
- we.new(e, {
234
+ const Z = pe ?? { timeUnit: "hour", count: 1 }, ne = ue, Re = ne ? nt : ot, b = p.xAxes.push(
235
+ Re.new(e, {
229
236
  maxDeviation: 0.1,
230
237
  groupData: !1,
231
- baseInterval: Y,
232
- renderer: Re.new(e, {})
238
+ baseInterval: Z,
239
+ renderer: Qe.new(e, {})
233
240
  })
234
241
  );
235
- (ae = f.get("renderer")) == null || ae.grid.template.setAll({
236
- stroke: A(t.palette.divider),
242
+ (xe = b.get("renderer")) == null || xe.grid.template.setAll({
243
+ stroke: O(r.palette.divider),
237
244
  strokeOpacity: 1
238
245
  });
239
- const I = h.yAxes.push(
240
- Se.new(e, {
241
- renderer: $e.new(e, {})
246
+ const E = p.yAxes.push(
247
+ Je.new(e, {
248
+ renderer: et.new(e, {})
242
249
  })
243
250
  );
244
- (le = I.get("renderer")) == null || le.grid.template.setAll({
245
- stroke: A(t.palette.divider),
251
+ (we = E.get("renderer")) == null || we.grid.template.setAll({
252
+ stroke: O(r.palette.divider),
246
253
  strokeOpacity: 1
247
254
  });
248
- const L = A(J), Ne = h.children.push(
249
- Ve.new(e, { centerX: ue, x: ue })
250
- ), U = () => Ue.new(e, { dateFormat: "i", dateFields: [a] }), oe = N ? [] : y, S = [];
251
- _.forEach((o, l) => {
252
- const s = h.series.push(
253
- E.new(e, {
254
- name: o.label ?? `Band ${l + 1}`,
255
- xAxis: f,
256
- yAxis: I,
257
- valueYField: o.upperField,
258
- openValueYField: o.lowerField,
259
- valueXField: a,
260
- fill: L,
261
- stroke: L
255
+ const B = O(ce), Ye = p.children.push(
256
+ tt.new(e, { centerX: Ae, x: Ae })
257
+ ), se = () => st.new(e, { dateFormat: "i", dateFields: [s] }), ye = C ? [] : w, q = [];
258
+ x.forEach((u, d) => {
259
+ const l = p.series.push(
260
+ H.new(e, {
261
+ name: u.label ?? `Band ${d + 1}`,
262
+ xAxis: b,
263
+ yAxis: E,
264
+ valueYField: u.upperField,
265
+ openValueYField: u.lowerField,
266
+ valueXField: s,
267
+ connect: R,
268
+ autoGapCount: le,
269
+ fill: B,
270
+ stroke: B
262
271
  })
263
272
  );
264
- s.strokes.template.set("strokeOpacity", 0), s.fills.template.setAll({
273
+ l.strokes.template.set("strokeOpacity", 0), l.fills.template.setAll({
265
274
  visible: !0,
266
- fill: L,
267
- fillOpacity: o.fillOpacity ?? ze[l] ?? 0.2
268
- }), s.data.processor = U(), s.data.setAll(oe), S.push(s);
275
+ fill: B,
276
+ fillOpacity: u.fillOpacity ?? ct[d] ?? 0.2
277
+ }), l.data.processor = se(), l.data.setAll(ye), q.push(l);
269
278
  });
270
- let v;
271
- u && (v = h.series.push(
272
- E.new(e, {
279
+ let F;
280
+ c && (F = p.series.push(
281
+ H.new(e, {
273
282
  name: "Forecast centre",
274
- xAxis: f,
275
- yAxis: I,
276
- valueYField: u,
277
- valueXField: a,
278
- stroke: A(t.palette.error.main)
283
+ xAxis: b,
284
+ yAxis: E,
285
+ valueYField: c,
286
+ valueXField: s,
287
+ connect: R,
288
+ autoGapCount: le,
289
+ stroke: O(r.palette.error.main)
279
290
  })
280
- ), v.strokes.template.setAll({
291
+ ), F.strokes.template.setAll({
281
292
  strokeWidth: 1.5,
282
293
  strokeDasharray: [4, 4]
283
- }), v.fills.template.set("visible", !1), v.data.processor = U(), v.data.setAll(oe));
284
- const O = N ? z.orderBy(c, [a]).map((o) => ({ ...o })) : y, j = h.series.push(
285
- q.new(e, {
294
+ }), F.fills.template.set("visible", !1), F.data.processor = se(), F.data.setAll(ye));
295
+ const L = C ? Q.orderBy(h, [s]).map((u) => ({ ...u })) : w, J = p.series.push(
296
+ G.new(e, {
286
297
  name: "History",
287
- xAxis: f,
288
- yAxis: I,
289
- valueYField: m,
290
- valueXField: a,
298
+ xAxis: b,
299
+ yAxis: E,
300
+ valueYField: f,
301
+ valueXField: s,
291
302
  // When false, the history line breaks at missing dates (gap > ~1 base
292
303
  // interval) instead of bridging across them.
293
- connect: V,
294
- autoGapCount: Ze,
295
- stroke: A(t.palette.primary.main)
304
+ connect: R,
305
+ autoGapCount: le,
306
+ stroke: O(r.palette.primary.main)
296
307
  })
297
308
  );
298
- j.strokes.template.setAll({ strokeWidth: 2 }), j.data.processor = U(), j.data.setAll(O), Ne.data.setAll(h.series.values);
299
- const R = (qe[Y.timeUnit] ?? 0) * Y.count / 2, B = (o, l) => {
300
- var s;
301
- return (s = o.get("grid")) == null ? void 0 : s.setAll({
309
+ J.strokes.template.setAll({ strokeWidth: 2 }), J.data.processor = se(), J.data.setAll(L), Ye.data.setAll(p.series.values);
310
+ const K = (mt[Z.timeUnit] ?? 0) * Z.count / 2, oe = (u, d) => {
311
+ var l;
312
+ return (l = u.get("grid")) == null ? void 0 : l.setAll({
302
313
  visible: !0,
303
- stroke: A(t.palette.text.secondary),
304
- strokeOpacity: l,
314
+ stroke: O(r.palette.text.secondary),
315
+ strokeOpacity: d,
305
316
  strokeDasharray: [2, 3]
306
317
  });
307
318
  };
308
- if (N) {
309
- let o = 1 / 0, l = -1 / 0, s = -1 / 0;
310
- const x = (i) => {
311
- typeof i == "number" && Number.isFinite(i) && (i < o && (o = i), i > l && (l = i));
319
+ if (C) {
320
+ const u = /* @__PURE__ */ new Set();
321
+ let d = 1 / 0, l = -1 / 0, v = -1 / 0;
322
+ const A = (t) => {
323
+ typeof t == "number" && Number.isFinite(t) && (t < d && (d = t), t > l && (l = t));
312
324
  };
313
- O.forEach((i) => x(i[m]));
314
- const F = O.length ? T(O[0][a]) : NaN;
315
- if (g.forEach(
316
- (i) => i.rows.forEach((p) => {
317
- _.forEach((k) => {
318
- x(p[k.lowerField]), x(p[k.upperField]);
319
- }), u && x(p[u]);
320
- const d = T(p[a]);
321
- Number.isFinite(d) && d > s && (s = d);
325
+ L.forEach((t) => {
326
+ A(t[f]);
327
+ const n = T(t[s]);
328
+ Number.isFinite(n) && u.add(n);
329
+ });
330
+ const y = L.length ? T(L[0][s]) : NaN;
331
+ if (_.forEach(
332
+ (t) => t.rows.forEach((n) => {
333
+ x.forEach((g) => {
334
+ A(n[g.lowerField]), A(n[g.upperField]);
335
+ }), c && A(n[c]);
336
+ const m = T(n[s]);
337
+ Number.isFinite(m) && (u.add(m), m > v && (v = m));
322
338
  })
323
- ), O.length) {
324
- const i = T(O[O.length - 1][a]);
325
- Number.isFinite(i) && i > s && (s = i);
339
+ ), L.length) {
340
+ const t = T(L[L.length - 1][s]);
341
+ Number.isFinite(t) && t > v && (v = t);
326
342
  }
327
- if (Number.isFinite(o) && Number.isFinite(l)) {
328
- const i = (l - o) * 0.05 || 1;
329
- I.set("min", o - i), I.set("max", l + i), I.set("strictMinMax", !0);
343
+ if (Number.isFinite(d) && Number.isFinite(l)) {
344
+ const t = (l - d) * 0.05 || 1;
345
+ E.set("min", d - t), E.set("max", l + t), E.set("strictMinMax", !0);
330
346
  }
331
- Number.isFinite(F) && Number.isFinite(s) && (f.set("min", F), f.set("max", s + R), f.set("strictMinMax", !0)), g.forEach((i) => {
332
- const p = T(i.origin);
333
- if (Number.isNaN(p)) return;
334
- const d = f.createAxisRange(
335
- f.makeDataItem({ value: p + R })
347
+ if (ne) {
348
+ const t = p.series.push(
349
+ G.new(e, {
350
+ name: "Timeline",
351
+ xAxis: b,
352
+ yAxis: E,
353
+ valueXField: s,
354
+ valueYField: ut
355
+ })
356
+ );
357
+ t.strokes.template.set("strokeOpacity", 0), t.fills.template.set("visible", !1), t.data.setAll(
358
+ Array.from(u).sort((n, m) => n - m).map((n) => ({ [s]: n }))
336
359
  );
337
- B(d, 0.25);
360
+ }
361
+ !ne && Number.isFinite(y) && Number.isFinite(v) && (b.set("min", y), b.set("max", v + K), b.set("strictMinMax", !0)), ee || _.forEach((t) => {
362
+ const n = T(t.origin);
363
+ if (Number.isNaN(n)) return;
364
+ const m = b.createAxisRange(
365
+ b.makeDataItem({ value: n + K })
366
+ );
367
+ oe(m, 0.25);
368
+ });
369
+ const I = b.makeDataItem({ value: 0 }), j = b.createAxisRange(I);
370
+ oe(j, 0.8);
371
+ const X = /* @__PURE__ */ new Map(), U = (t, n) => t.setAll({
372
+ radius: n ? pt : Te,
373
+ fillOpacity: n ? 1 : 0.6
338
374
  });
339
- const b = f.makeDataItem({ value: 0 }), D = f.createAxisRange(b);
340
- B(D, 0.8);
341
- const C = (i) => {
342
- const p = g[i] ?? g[g.length - 1];
343
- if (!p) return;
344
- const d = z.orderBy(p.rows, [a]).map((w) => ({
345
- ...w
375
+ if (ee) {
376
+ const t = L.map((o) => ({ t: T(o[s]), v: o[f] })).filter(
377
+ (o) => Number.isFinite(o.t) && typeof o.v == "number" && Number.isFinite(o.v)
378
+ ), n = (o) => {
379
+ let P;
380
+ for (const k of t) {
381
+ if (k.t > o) break;
382
+ P = k.v;
383
+ }
384
+ return P;
385
+ }, m = [];
386
+ _.forEach((o, P) => {
387
+ var $;
388
+ const k = T(o.origin);
389
+ if (!Number.isFinite(k)) return;
390
+ const S = c ? ($ = Q.orderBy(o.rows, [s]).find(
391
+ (Fe) => Fe[c] !== null && Fe[c] !== void 0
392
+ )) == null ? void 0 : $[c] : void 0, D = n(k) ?? S;
393
+ typeof D != "number" || !Number.isFinite(D) || m.push({
394
+ originDate: k,
395
+ originValue: D,
396
+ originIndex: P
397
+ });
398
+ });
399
+ const g = p.series.push(
400
+ G.new(e, {
401
+ name: "Forecast runs",
402
+ xAxis: b,
403
+ yAxis: E,
404
+ valueXField: "originDate",
405
+ valueYField: "originValue"
406
+ })
407
+ );
408
+ g.strokes.template.set("strokeOpacity", 0), g.fills.template.set("visible", !1), g.bullets.push((o, P, k) => {
409
+ const S = k.dataContext, D = it.new(o, {
410
+ radius: Te,
411
+ fill: B,
412
+ fillOpacity: 0.6,
413
+ stroke: O(r.palette.background.paper),
414
+ strokeWidth: 2,
415
+ interactive: !0,
416
+ cursorOverStyle: "pointer"
417
+ });
418
+ return U(D, S.originIndex === z.current), D.events.on(
419
+ "pointerover",
420
+ () => ie(S.originIndex)
421
+ ), D.events.on(
422
+ "pointerout",
423
+ () => (
424
+ // Guard against a neighbouring bullet's `pointerover` landing first.
425
+ ie(
426
+ ($) => $ === S.originIndex ? null : $
427
+ )
428
+ )
429
+ ), D.events.on("click", () => {
430
+ be(S.originIndex), ie(null);
431
+ }), X.set(S.originIndex, D), rt.new(o, { sprite: D });
432
+ }), g.data.setAll(m);
433
+ }
434
+ const N = (t) => {
435
+ const n = _[t] ?? _[_.length - 1];
436
+ if (!n) return;
437
+ const m = Q.orderBy(n.rows, [s]).map((o) => ({
438
+ ...o
346
439
  }));
347
- S.forEach((w) => w.data.setAll(d)), v == null || v.data.setAll(d);
348
- const k = T(p.origin);
349
- b.set("value", Number.isNaN(k) ? 0 : k + R);
440
+ q.forEach((o) => o.data.setAll(m)), F == null || F.data.setAll(m);
441
+ const g = T(n.origin);
442
+ I.set("value", Number.isNaN(g) ? 0 : g + K), X.forEach(
443
+ (o, P) => U(o, P === t)
444
+ );
350
445
  };
351
- M.current = C, C(ie.current);
446
+ V.current = N, N(z.current);
352
447
  } else {
353
- const o = y.findIndex(
354
- (b) => b[u] !== null && b[u] !== void 0
355
- ), l = [...y].reverse().find(
356
- (b) => b[m] !== null && b[m] !== void 0
357
- ), s = o >= 0 ? y[o] : l, x = $ !== void 0 ? T($) : s ? T(s[a]) : NaN, F = Number.isNaN(x) ? NaN : x + R;
358
- if (!Number.isNaN(F)) {
359
- const b = f.createAxisRange(
360
- f.makeDataItem({ value: F })
448
+ const u = w.findIndex(
449
+ (y) => y[c] !== null && y[c] !== void 0
450
+ ), d = [...w].reverse().find(
451
+ (y) => y[f] !== null && y[f] !== void 0
452
+ ), l = u >= 0 ? w[u] : d, v = te !== void 0 ? T(te) : l ? T(l[s]) : NaN, A = Number.isNaN(v) ? NaN : v + K;
453
+ if (!Number.isNaN(A)) {
454
+ const y = b.createAxisRange(
455
+ b.makeDataItem({ value: A })
361
456
  );
362
- B(b, 0.7);
457
+ oe(y, 0.7);
363
458
  }
364
459
  }
365
- const Ae = Pe(Y);
366
- return Ee({
460
+ const Ve = We(Z);
461
+ return ze({
367
462
  root: e,
368
- chart: h,
369
- theme: t,
463
+ chart: p,
464
+ theme: r,
370
465
  getText: () => {
371
- var p;
372
- const o = (d) => d == null ? "—" : e.numberFormatter.format(d), l = j.get("tooltipDataItem"), s = v == null ? void 0 : v.get("tooltipDataItem"), x = s ?? l ?? ((p = S[0]) == null ? void 0 : p.get("tooltipDataItem")), F = x == null ? void 0 : x.get("valueX"), b = typeof F == "number" ? e.dateFormatter.format(new Date(F), Ae) : "", D = [], C = l == null ? void 0 : l.get("valueY");
373
- C != null && D.push(`History: ${o(C)}`);
374
- const i = s == null ? void 0 : s.get("valueY");
375
- return i != null && D.push(`Centre: ${o(i)}`), _.forEach((d, k) => {
376
- var ce;
377
- const w = (ce = S[k]) == null ? void 0 : ce.get("tooltipDataItem"), G = w == null ? void 0 : w.get("valueY"), W = w == null ? void 0 : w.get("openValueY");
378
- if (G != null && W !== void 0 && W !== null) {
379
- const Fe = (G - W) / 2, De = d.label ?? `Band ${k + 1}`;
380
- D.push(`[${L.toCSSHex()}]●[/] ${De}: ±${o(Fe)}`);
466
+ var U;
467
+ const u = (N) => N == null ? "—" : e.numberFormatter.format(N), d = J.get("tooltipDataItem"), l = F == null ? void 0 : F.get("tooltipDataItem"), v = l ?? d ?? ((U = q[0]) == null ? void 0 : U.get("tooltipDataItem")), A = v == null ? void 0 : v.get("valueX"), y = typeof A == "number" ? e.dateFormatter.format(new Date(A), Ve) : "", I = [];
468
+ if (C && ge.current) {
469
+ const N = _[z.current];
470
+ N && I.push(`Forecast run: ${Ce(N)}`);
471
+ }
472
+ const j = d == null ? void 0 : d.get("valueY");
473
+ j != null && I.push(`History: ${u(j)}`);
474
+ const X = l == null ? void 0 : l.get("valueY");
475
+ return X != null && I.push(`Centre: ${u(X)}`), x.forEach((N, t) => {
476
+ var o;
477
+ const n = (o = q[t]) == null ? void 0 : o.get("tooltipDataItem"), m = n == null ? void 0 : n.get("valueY"), g = n == null ? void 0 : n.get("openValueY");
478
+ if (m != null && g !== void 0 && g !== null) {
479
+ const P = (m - g) / 2, k = N.label ?? `Band ${t + 1}`;
480
+ I.push(`[${B.toCSSHex()}]●[/] ${k}: ±${u(P)}`);
381
481
  }
382
- }), D.length === 0 ? "" : b ? `[bold]${b}[/]
383
- ${D.join(`
384
- `)}` : D.join(`
482
+ }), I.length === 0 ? "" : y ? `[bold]${y}[/]
483
+ ${I.join(`
484
+ `)}` : I.join(`
385
485
  `);
386
486
  }
387
- }), h.appear(1e3, 100), () => {
388
- M.current = null, e.dispose(), ne.current = null, se.current = null;
487
+ }), p.appear(1e3, 100), () => {
488
+ V.current = null, e.dispose(), ve.current = null, _e.current = null;
389
489
  };
390
490
  }, [
391
- t.palette.mode,
392
- c,
491
+ r.palette.mode,
492
+ h,
493
+ x,
393
494
  _,
394
- g,
395
- J,
396
- $,
397
- V,
398
- K
399
- ]), Me(() => {
495
+ ee,
496
+ ce,
497
+ te,
498
+ R,
499
+ ue
500
+ ]), He(() => {
400
501
  var e;
401
- (e = M.current) == null || e.call(M, X);
402
- }, [X]);
403
- const xe = N ? g.map((e) => e.label ?? Je(e.origin)) : [];
502
+ (e = V.current) == null || e.call(V, Y);
503
+ }, [Y]);
504
+ const Me = C ? _.map(Ce) : [];
404
505
  return {
405
- chartDivRef: H,
406
- data: y,
407
- chartId: ee,
408
- loading: te,
409
- emptyMessage: re,
410
- isMulti: N,
411
- origins: xe,
412
- selectedOriginIndex: X,
506
+ chartDivRef: re,
507
+ data: w,
508
+ chartId: me,
509
+ loading: de,
510
+ emptyMessage: he,
511
+ isMulti: C,
512
+ origins: Me,
513
+ selectedOriginIndex: fe,
514
+ shownOriginIndex: Y,
515
+ isPreviewing: W !== null,
413
516
  onOriginChange: (e) => {
414
- if (!N) return;
415
- const h = Math.max(0, Math.min(g.length - 1, e));
416
- ye(h);
517
+ if (!C) return;
518
+ const p = Math.max(0, Math.min(_.length - 1, e));
519
+ be(p);
417
520
  },
418
- sx: _e,
419
- other: ge,
420
- ownerState: ve
521
+ sx: Le,
522
+ other: Se,
523
+ ownerState: Xe
421
524
  };
422
525
  };
423
526
  export {
424
- ft as useForecastConeChartLogic
527
+ Et as useForecastConeChartLogic
425
528
  };