@alphapoint/apex-chart-react 5.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2628 @@
1
+ class b {
2
+ addEventListener(t, i) {
3
+ this.listeners || (this.listeners = {}), this.listeners[t] = this.listeners[t] || [], this.listeners[t].push(i);
4
+ }
5
+ removeEventListener(t, i) {
6
+ if (!this.listeners)
7
+ return;
8
+ let e = this.listeners[t];
9
+ e && e.splice(e.indexOf(i), 1);
10
+ }
11
+ dispatchEvent(t, ...i) {
12
+ if (!this.listeners)
13
+ return;
14
+ let e = this.listeners[t];
15
+ e && e.forEach((s) => {
16
+ s.apply(null, i);
17
+ });
18
+ }
19
+ removeAllEventListeners(t) {
20
+ t && (this.listeners[t] = []);
21
+ }
22
+ removeAllListeners() {
23
+ this.listeners = {};
24
+ }
25
+ }
26
+ class T {
27
+ /**
28
+ * Instantiates the history data item and defines all private properties
29
+ *
30
+ * @param {Number} timestamp - seconds since UTC epoch
31
+ * @param {Number} open - open price
32
+ * @param {Number} close - close price
33
+ * @param {Number} high - high price
34
+ * @param {Number} low - low price
35
+ * @param {Number} volume
36
+ * @param {Number} simpleMovingAverage
37
+ * @param {Number} exponentialMovingAverage
38
+ * @param {Number} standardDeviation
39
+ * @param {Number} macdShortAverage
40
+ * @param {Number} macdLongAverage
41
+ * @param {Number} macdSignalAverage
42
+ *
43
+ */
44
+ constructor(t = 0, i = 0, e = 0, s = 0, a = 0, n = 0, r = 0, o = 0, h = 0, _ = 0, l = 0, u = 0) {
45
+ this._timestamp = t, this._open = i, this._close = e, this._low = a, this._high = s, this._highLowSpan = s - a, this._volume = n, this._bullish = e >= i, this._simpleMovingAverage = r, this._exponentialMovingAverage = o, this._standardDeviation = h, this._macdShortAverage = _, this._macdLongAverage = l, this._macdSignalAverage = u;
46
+ }
47
+ get timestamp() {
48
+ return this._timestamp;
49
+ }
50
+ set timestamp(t) {
51
+ this._timestamp = t;
52
+ }
53
+ get bullish() {
54
+ return this._bullish;
55
+ }
56
+ get open() {
57
+ return this._open;
58
+ }
59
+ set open(t) {
60
+ this._open !== t && (this._open = t, this._bullish = this._close >= this._open);
61
+ }
62
+ get close() {
63
+ return this._close;
64
+ }
65
+ set close(t) {
66
+ this._close !== t && (this._close = t, this._bullish = this._close >= this._open);
67
+ }
68
+ get high() {
69
+ return this._high;
70
+ }
71
+ set high(t) {
72
+ this._high !== t && (this._high = t, this._highLowSpan = this._high - this._low);
73
+ }
74
+ get low() {
75
+ return this._low;
76
+ }
77
+ set low(t) {
78
+ this._low !== t && (this._low = t, this._highLowSpan = this._high - this._low);
79
+ }
80
+ get volume() {
81
+ return this._volume;
82
+ }
83
+ set volume(t) {
84
+ this._volume !== t && (this._volume = t);
85
+ }
86
+ get simpleMovingAverage() {
87
+ return this._simpleMovingAverage;
88
+ }
89
+ set simpleMovingAverage(t) {
90
+ this._simpleMovingAverage = t;
91
+ }
92
+ get exponentialMovingAverage() {
93
+ return this._exponentialMovingAverage;
94
+ }
95
+ set exponentialMovingAverage(t) {
96
+ this._exponentialMovingAverage = t;
97
+ }
98
+ get standardDeviation() {
99
+ return this._standardDeviation;
100
+ }
101
+ set standardDeviation(t) {
102
+ this._standardDeviation = t;
103
+ }
104
+ get macdShortAverage() {
105
+ return this._macdShortAverage;
106
+ }
107
+ set macdShortAverage(t) {
108
+ this._macdShortAverage = t;
109
+ }
110
+ get macdLongAverage() {
111
+ return this._macdLongAverage;
112
+ }
113
+ set macdLongAverage(t) {
114
+ this._macdLongAverage = t;
115
+ }
116
+ get macdSignalAverage() {
117
+ return this._macdSignalAverage;
118
+ }
119
+ set macdSignalAverage(t) {
120
+ this._macdSignalAverage = t;
121
+ }
122
+ get macdIndicator() {
123
+ return this._macdShortAverage - this._macdLongAverage;
124
+ }
125
+ get macdSignal() {
126
+ return this.macdIndicator - this._macdSignalAverage;
127
+ }
128
+ get macdDisparity() {
129
+ return this.macdIndicator - this.macdSignal;
130
+ }
131
+ }
132
+ class R extends b {
133
+ /**
134
+ * Instantiates the history data and defines all private properties
135
+ *
136
+ */
137
+ constructor() {
138
+ super(), this._data = [], this._configuration = d.configuration.history_data, this._simpleMovingAverageWindow = this._configuration.simple_moving_average_window, this._exponentialMovingAverageWindow = this._configuration.exponential_moving_average_window, this._macdShortWindow = this._configuration.convergence_divergence_short_window, this._macdLongWindow = this._configuration.convergence_divergence_long_window, this._macdSignalWindow = this._configuration.convergence_divergence_signal_window, this._lowerPriceBound = Number.MAX_SAFE_INTEGER, this._upperPriceBound = 0, this._priceBoundsSpan = 0, this._lowerVolumeBound = Number.MAX_SAFE_INTEGER, this._upperVolumeBound = 0, this._lowerTimeBound = Number.MAX_SAFE_INTEGER, this._upperTimeBound = 0, this._lowerMACDIndicatorBound = Number.MAX_SAFE_INTEGER, this._upperMACDIndicatorBound = 0, this._lowerMACDSignalBound = Number.MAX_SAFE_INTEGER, this._upperMACDSignalBound = 0, this._lowerMACDDisparityBound = Number.MAX_SAFE_INTEGER, this._upperMACDDisparityBound = 0, this._interval = d.configuration.defaults.history_interval;
139
+ }
140
+ /**
141
+ * Computes an item average given an accumulator, value and alpha
142
+ *
143
+ * @param {Number} accumulator
144
+ * @param {Number} newValue
145
+ * @param {Number} alpha
146
+ *
147
+ */
148
+ calcMovingAvg(t, i, e) {
149
+ return e * i + (1 - e) * t;
150
+ }
151
+ /**
152
+ * Appends a new item to the dataset
153
+ *
154
+ * @param {Number} timestamp - seconds since UTC epoch
155
+ * @param {Number} open - open price
156
+ * @param {Number} close - close price
157
+ * @param {Number} high - high price
158
+ * @param {Number} low - low price
159
+ * @param {Number} volume
160
+ *
161
+ */
162
+ _append(t, i, e, s, a, n) {
163
+ let r, o, h, _, l, u;
164
+ if (this._data.length > 0 && this._data[this._data.length - 1].timestamp, this._data.length > 0) {
165
+ let p = this._data[this._data.length - 1], f = 1 / this._simpleMovingAverageWindow, x = 2 / this._exponentialMovingAverageWindow, M = 2 / this._macdShortWindow, A = 2 / this._macdLongWindow, P = 2 / this._macdSignalWindow;
166
+ r = this.calcMovingAvg(p.simpleMovingAverage, e, f), o = this.calcMovingAvg(p.exponentialMovingAverage, e, x), h = this.calcMovingAvg(Math.pow(p.standardDeviation, 2), Math.pow(Math.abs(e - r), 2), f), _ = this.calcMovingAvg(p.macdShortAverage, e, M), l = this.calcMovingAvg(p.macdLongAverage, e, A), u = this.calcMovingAvg(p.macdSignalAverage, _ - l, P);
167
+ } else
168
+ r = e, o = e, h = 0, _ = e, l = e, u = 0;
169
+ let g = new T(t, i, e, s, a, n);
170
+ g.simpleMovingAverage = r, g.exponentialMovingAverage = o, g.standardDeviation = Math.sqrt(h), g.macdShortAverage = _, g.macdLongAverage = l, g.macdSignalAverage = u, this._adjustBounds(g), this._data.push(g);
171
+ }
172
+ /**
173
+ * Adjusts upper and lower bounds given an item
174
+ *
175
+ * @param {HistoryDataItem} item
176
+ *
177
+ */
178
+ _adjustBounds(t) {
179
+ t.close < this._lowerPriceBound && (this._lowerPriceBound = t.close), t.close > this._upperPriceBound && (this._upperPriceBound = t.close), this._priceBoundsSpan = this._upperPriceBound - this._lowerPriceBound, t.volume < this._lowerVolumeBound && (this._lowerVolumeBound = t.volume), t.volume > this._upperVolumeBound && (this._upperVolumeBound = t.volume), t.timestamp < this._lowerTimeBound && (this._lowerTimeBound = t.timestamp), t.timestamp > this._upperTimeBound && (this._upperTimeBound = t.timestamp), t.macd < this._lowerMACDIndicatorBound && (this._lowerMACDIndicatorBound = t.macd), t.macd > this._upperMACDIndicatorBound && (this._upperMACDIndicatorBound = t.macd), t.macdSignal < this._lowerMACDSignalBound && (this._lowerMACDSignalBound = t.macdSignal), t.macdSignal > this._upperMACDSignalBound && (this._upperMACDSignalBound = t.macdSignal), t.macdDisparity < this._lowerMACDDisparityBound && (this._lowerMACDDisparityBound = t.macdDisparity), t.macdDisparity > this._upperMACDDisparityBound && (this._upperMACDDisparityBound = t.macdDisparity);
180
+ }
181
+ /**
182
+ * Parses a dataset received from a history API - data is an array of arrays in format:
183
+ * [[timestamp, open, close, high, low, volume], [timestamp, open, close, high, low, volume], ...]
184
+ *
185
+ * @param {Number} interval - interval is propagated out of the API
186
+ * @param {Array} data
187
+ *
188
+ */
189
+ parse(t, i) {
190
+ this._lowerPriceBound = Number.MAX_SAFE_INTEGER, this._upperPriceBound = 0, this._priceBoundsSpan = 0, this._lowerVolumeBound = Number.MAX_SAFE_INTEGER, this._upperVolumeBound = 0, this._lowerTimeBound = Number.MAX_SAFE_INTEGER, this._upperTimeBound = 0, this._lowerMACDBound = Number.MAX_SAFE_INTEGER, this._upperMACDBound = 0, this._lowerSignalBound = Number.MAX_SAFE_INTEGER, this._upperSignalBound = 0, this._data = [], this._iterator = 1, this._interval = t, i.forEach((e) => {
191
+ this._append(e[0], e[1], e[2], e[3], e[4], e[5]);
192
+ }), this.dispatchEvent("parseComplete");
193
+ }
194
+ /**
195
+ * Public method to append a new item to the dataset
196
+ *
197
+ * @param {Number} timestamp - seconds since UTC epoch
198
+ * @param {Number} open - open price
199
+ * @param {Number} close - close price
200
+ * @param {Number} high - high price
201
+ * @param {Number} low - low price
202
+ * @param {Number} volume
203
+ *
204
+ */
205
+ append(t, i, e, s, a, n) {
206
+ this._append(t, i, e, s, a, n), this.dispatchEvent("appendComplete");
207
+ }
208
+ /**
209
+ * Convenience method to get an item at a specified index
210
+ *
211
+ * @param {Number} index
212
+ *
213
+ */
214
+ getItemAt(t) {
215
+ return this._data[t];
216
+ }
217
+ get hasData() {
218
+ return this._data.length > 0;
219
+ }
220
+ get lowerPriceBound() {
221
+ return this._lowerPriceBound;
222
+ }
223
+ get upperPriceBound() {
224
+ return this._upperPriceBound;
225
+ }
226
+ get priceBoundsSpan() {
227
+ return this._priceBoundsSpan;
228
+ }
229
+ get lowerVolumeBound() {
230
+ return this._lowerVolumeBound;
231
+ }
232
+ get upperVolumeBound() {
233
+ return this._upperVolumeBound;
234
+ }
235
+ get lowerTimeBound() {
236
+ return this._lowerTimeBound;
237
+ }
238
+ get upperTimeBound() {
239
+ return this._upperTimeBound;
240
+ }
241
+ get lowerMACDIndicatorBound() {
242
+ return this._lowerMACDIndicatorBound;
243
+ }
244
+ get upperMACDIndicatorBound() {
245
+ return this._upperMACDIndicatorBound;
246
+ }
247
+ get lowerMACDSignalBound() {
248
+ return this._lowerMACDSignalBound;
249
+ }
250
+ get upperMACDSignalBound() {
251
+ return this._upperMACDSignalBound;
252
+ }
253
+ get interval() {
254
+ return this._interval;
255
+ }
256
+ get length() {
257
+ return this._data.length;
258
+ }
259
+ }
260
+ class E {
261
+ constructor(t = 0, i = 0, e = 0, s = 0) {
262
+ this._previous = null, this._next = null, this._price = t, this._count = i, this._cumulativeCount = e, this._cumulativeCost = s;
263
+ }
264
+ get previous() {
265
+ return this._previous;
266
+ }
267
+ set previous(t) {
268
+ this._previous = t;
269
+ }
270
+ get next() {
271
+ return this._next;
272
+ }
273
+ set next(t) {
274
+ this._next = t;
275
+ }
276
+ get price() {
277
+ return this._price;
278
+ }
279
+ set price(t) {
280
+ this._price = t;
281
+ }
282
+ get count() {
283
+ return this._count;
284
+ }
285
+ set count(t) {
286
+ this._count = t;
287
+ }
288
+ get cumulativeCount() {
289
+ return this._cumulativeCount;
290
+ }
291
+ set cumulativeCount(t) {
292
+ this._cumulativeCount = t;
293
+ }
294
+ get cumulativeCost() {
295
+ return this._cumulativeCost;
296
+ }
297
+ set cumulativeCost(t) {
298
+ this._cumulativeCost = t;
299
+ }
300
+ }
301
+ class S {
302
+ // Maybe needs to reverse output array for rendering, depending on whether this is a bid or ask map
303
+ constructor(t = "ascending") {
304
+ this._data = /* @__PURE__ */ new Map(), this._lowerPriceBound = Number.MAX_SAFE_INTEGER, this._upperPriceBound = 0, this._upperCountBound = 0, this._firstItem = null, this._lastItem = null, this._currentItem = null, this._cumulativeTotalDirection = t;
305
+ }
306
+ _updateItem(t, i) {
307
+ t.count = i, this._currentItem = t;
308
+ }
309
+ _insertItem(t) {
310
+ let i = this._currentItem;
311
+ for (; i !== t; )
312
+ if (t.price < i.price)
313
+ if (i.previous !== null)
314
+ if (t.price < i.previous.price) {
315
+ i = i.previous;
316
+ continue;
317
+ } else {
318
+ t.previous = i.previous, t.next = i, i.previous.next = t, i.previous = t, this._currentItem = t;
319
+ return;
320
+ }
321
+ else {
322
+ i.previous = t, t.next = i, this._firstItem = t, this._currentItem = t;
323
+ return;
324
+ }
325
+ else if (t.price > i.price)
326
+ if (i.next !== null)
327
+ if (t.price > i.next.price) {
328
+ i = i.next;
329
+ continue;
330
+ } else {
331
+ t.previous = i, t.next = i.next, i.next.previous = t, i.next = t, this._currentItem = t;
332
+ return;
333
+ }
334
+ else {
335
+ i.next = t, t.previous = i, this._lastItem = t, this._currentItem = t;
336
+ return;
337
+ }
338
+ }
339
+ _deleteItem(t) {
340
+ let i = t.price.toString();
341
+ if (this._data.has(i)) {
342
+ let e = t.previous, s = t.next;
343
+ e !== null && s !== null ? (e.next = s, s.previous = e, this._currentItem = e) : s !== null ? (s.previous = null, this._firstItem = s, this._currentItem = s) : e !== null && (e.next = null, this._lastItem = e, this._currentItem = e);
344
+ }
345
+ t.next = null, t.previous = null, this._data.delete(i), this._data.size === 0 ? (this._currentItem = null, this._firstItem = null, this._lastItem = null, this._lowerPriceBound = Number.MAX_SAFE_INTEGER, this._upperPriceBound = 0, this._upperCountBound = 0) : (this._computeCumulatives(), this._computeBounds());
346
+ }
347
+ _computeBounds() {
348
+ this._lowerPriceBound = this._firstItem.price, this._upperPriceBound = this._lastItem.price, this._upperCountBound = this._cumulativeTotalDirection === "ascending" ? this._lastItem.cumulativeCount : this._firstItem.cumulativeCount;
349
+ }
350
+ _computeCumulatives() {
351
+ let t = this._cumulativeTotalDirection === "ascending" ? this._firstItem : this._lastItem;
352
+ for (; t !== null; ) {
353
+ let i = this._cumulativeTotalDirection === "ascending" ? t.previous : t.next;
354
+ i !== null ? (t.cumulativeCount = i.cumulativeCount + t.count, t.cumulativeCost = i.cumulativeCost + t.count * t.price) : (t.cumulativeCount = t.count, t.cumulativeCost = t.count * t.price), this._cumulativeTotalDirection, t = this._cumulativeTotalDirection === "ascending" ? t.next : t.previous;
355
+ }
356
+ }
357
+ add(t, i) {
358
+ let e = t.toString();
359
+ if (this._data.size === 0) {
360
+ let s = new E(t, i, i);
361
+ this._firstItem = s, this._lastItem = s, this._data.set(e, s), this._currentItem = s;
362
+ } else if (this._data.has(e)) {
363
+ let s = this._data.get(e);
364
+ i > 0 ? s.count !== i && (s.count, this._updateItem(s, i)) : this._deleteItem(s);
365
+ } else if (i > 0) {
366
+ let s = new E(t, i, i);
367
+ this._data.set(e, s), this._insertItem(s);
368
+ }
369
+ this._computeCumulatives(), this._computeBounds();
370
+ }
371
+ getClosestItem(t) {
372
+ if (this._data.has(t.toString()))
373
+ this._data.get(t.toString());
374
+ else {
375
+ if (this._firstItem !== null && this._firstItem.price > t)
376
+ return this._firstItem;
377
+ if (this._lastItem !== null && this._lastItem.price < t)
378
+ return this._lastItem;
379
+ {
380
+ let i = this._firstItem, e = this._lastItem;
381
+ for (; i !== null && e !== null; ) {
382
+ if (i.next !== null)
383
+ if (t > i.next.price)
384
+ i = i.next;
385
+ else
386
+ return Math.abs(i.next.price - t) > Math.abs(i.price - t) ? i : i.next;
387
+ else
388
+ i = null;
389
+ if (e.previous !== null)
390
+ if (t < e.previous.price)
391
+ e = e.previous;
392
+ else
393
+ return Math.abs(e.previous.price - t) > Math.abs(e.price - t) ? e : e.previous;
394
+ else
395
+ e = null;
396
+ }
397
+ return null;
398
+ }
399
+ }
400
+ }
401
+ [Symbol.iterator]() {
402
+ let t = this._cumulativeTotalDirection, i = t === "ascending" ? this._firstItem : this._lastItem;
403
+ return {
404
+ next: () => {
405
+ if (i !== null) {
406
+ let e = { value: i.valueOf(), done: !1 };
407
+ return i = t === "ascending" ? i.next : i.previous, e;
408
+ }
409
+ return { value: void 0, done: !0 };
410
+ }
411
+ };
412
+ }
413
+ get length() {
414
+ return this._data.size;
415
+ }
416
+ get firstItem() {
417
+ return this._firstItem;
418
+ }
419
+ get lastItem() {
420
+ return this._lastItem;
421
+ }
422
+ get lowerPriceBound() {
423
+ return this._lowerPriceBound;
424
+ }
425
+ get upperPriceBound() {
426
+ return this._upperPriceBound;
427
+ }
428
+ get upperCountBound() {
429
+ return this._upperCountBound;
430
+ }
431
+ }
432
+ class H extends b {
433
+ /**
434
+ * Instantiates the order book data and defines all private properties
435
+ *
436
+ */
437
+ constructor() {
438
+ super(), this._askData = new S("ascending"), this._bidData = new S("descending"), this._marketPrice = 0;
439
+ }
440
+ /**
441
+ * Parses a dataset received from an order book API
442
+ *
443
+ * @param {Array} data
444
+ *
445
+ */
446
+ parse(t) {
447
+ t.asks.constructor === Array && t.asks.length > 0 && t.asks.forEach((i) => {
448
+ this._askData.add(i[0], i[1]);
449
+ }), t.bids.constructor === Array && t.bids.length > 0 && t.bids.forEach((i) => {
450
+ this._bidData.add(i[0], i[1]);
451
+ }), this.dispatchEvent("parseComplete");
452
+ }
453
+ add(t, i, e) {
454
+ t === "ask" ? this._askData.add(i, e) : t === "bid" && this._bidData.add(i, e), this.dispatchEvent("addComplete");
455
+ }
456
+ remove(t, i, e) {
457
+ t === "ask" ? this._askData.remove(i) : t === "bid" && this._bidData.remove(i), this.dispatchEvent("removeComplete");
458
+ }
459
+ getClosestItem(t, i) {
460
+ return t === "ask" ? this._askData.getClosestItem(i) : t === "bid" ? this._bidData.getClosestItem(i) : null;
461
+ }
462
+ get hasData() {
463
+ return this._askData.length > 0 && this._bidData.length > 0;
464
+ }
465
+ get askData() {
466
+ return this._askData;
467
+ }
468
+ get bidData() {
469
+ return this._bidData;
470
+ }
471
+ get lowerPriceBound() {
472
+ return this._bidData.lowerPriceBound;
473
+ }
474
+ get upperPriceBound() {
475
+ return this._askData.upperPriceBound;
476
+ }
477
+ get upperCountBound() {
478
+ return Math.max(this._askData.upperCountBound, this._bidData.upperCountBound);
479
+ }
480
+ }
481
+ class N extends b {
482
+ /**
483
+ * Instantiates the component and defines all private properties
484
+ *
485
+ * @param {HTMLElement} container
486
+ *
487
+ */
488
+ constructor(t) {
489
+ super(), this._containerElement = t, this._timeIntervalGroup = null, this._chartLineGroup = null, this._chartTypeGroup = null, this._timeIntervals = d.configuration.time_intervals, this._historyInterval = d.configuration.defaults.history_interval, this._drawSimpleMovingAverage = d.configuration.defaults.draw_simple_moving_average, this._drawExponentialMovingAverage = d.configuration.defaults.draw_exponential_moving_average, this._drawBollingerBands = d.configuration.defaults.draw_bollinger_bands, this._chartType = d.configuration.defaults.chart_type, this._build(), this._registerListeners(), this._updateState();
490
+ }
491
+ /**
492
+ * Instantiates a dropdown component and assigns it a group name
493
+ *
494
+ * @param {String} groupName
495
+ *
496
+ */
497
+ _buildSelectGroup(t) {
498
+ let i = document.createElement("div");
499
+ i.classList.add("select-group"), this._containerElement.appendChild(i);
500
+ let e = document.createElement("button");
501
+ e.setAttribute("data-group", t), i.appendChild(e);
502
+ let s = document.createElement("ul");
503
+ return i.appendChild(s), i;
504
+ }
505
+ /**
506
+ * Instantiates a button bar component and assigns it a group name
507
+ *
508
+ * @param {String} groupName
509
+ *
510
+ */
511
+ _buildButtonGroup(t) {
512
+ let i = document.createElement("div");
513
+ return i.classList.add("button-group"), this._containerElement.appendChild(i), i;
514
+ }
515
+ /**
516
+ * Adds an item to a dropdown component
517
+ *
518
+ * @param {HTMLElement} groupElement
519
+ * @param {String} groupName
520
+ * @param {String} value
521
+ * @param {String} label
522
+ *
523
+ */
524
+ _addItemToSelectGroup(t, i, e, s) {
525
+ let a = t.getElementsByTagName("ul")[0];
526
+ if (!a)
527
+ return;
528
+ let n = document.createElement("li");
529
+ n.setAttribute("data-group", i), n.setAttribute("data-value", e), n.innerHTML = s, a.appendChild(n);
530
+ }
531
+ /**
532
+ * Adds an item to a button bar component
533
+ *
534
+ * @param {HTMLElement} groupElement
535
+ * @param {String} groupName
536
+ * @param {String} value
537
+ * @param {String} label
538
+ *
539
+ */
540
+ _addItemToButtonGroup(t, i, e, s) {
541
+ let a = document.createElement("button");
542
+ a.setAttribute("data-group", i), a.setAttribute("data-value", e), a.innerHTML = s, t.appendChild(a);
543
+ }
544
+ /**
545
+ * Structures the component on the DOM and instantiates all child elements
546
+ *
547
+ */
548
+ _build() {
549
+ this._timeIntervalGroup = this._buildSelectGroup("time-interval"), this._timeIntervals.forEach((t) => {
550
+ this._addItemToSelectGroup(this._timeIntervalGroup, "time-interval", t.seconds.toString(), t.label);
551
+ }), this._chartLineGroup = this._buildButtonGroup("chart-line"), this._addItemToButtonGroup(this._chartLineGroup, "chart-line", "sma", "SMA"), this._addItemToButtonGroup(this._chartLineGroup, "chart-line", "ema", "EMA"), this._addItemToButtonGroup(this._chartLineGroup, "chart-line", "bb", "BB"), this._chartTypeGroup = this._buildButtonGroup("chart-type"), this._addItemToButtonGroup(this._chartTypeGroup, "chart-type", "candlestick", "candle"), this._addItemToButtonGroup(this._chartTypeGroup, "chart-type", "line", "line"), this._addItemToButtonGroup(this._chartTypeGroup, "chart-type", "bar", "bar");
552
+ }
553
+ /**
554
+ * Updates the visual state of the controls based on the values of our properties
555
+ *
556
+ */
557
+ _updateState() {
558
+ let t = this._timeIntervalGroup.getElementsByTagName("button")[0], i = this._timeIntervalGroup.getElementsByTagName("ul")[0];
559
+ i.classList.remove("active"), i.childNodes.forEach((e) => {
560
+ parseInt(e.dataset.value, 10) === this._historyInterval ? (e.classList.add("active"), t.innerHTML = e.innerHTML + "&nbsp;&#9660;") : e.classList.remove("active");
561
+ }), this._chartLineGroup.childNodes.forEach((e) => {
562
+ e.dataset.value === "sma" ? this._drawSimpleMovingAverage ? e.classList.add("active") : e.classList.remove("active") : e.dataset.value === "ema" ? this._drawExponentialMovingAverage ? e.classList.add("active") : e.classList.remove("active") : e.dataset.value === "bb" && (this._drawBollingerBands ? e.classList.add("active") : e.classList.remove("active"));
563
+ }), this._chartTypeGroup.childNodes.forEach((e) => {
564
+ e.dataset.value === this._chartType ? e.classList.add("active") : e.classList.remove("active");
565
+ });
566
+ }
567
+ /**
568
+ * Initializes all event listener bindings for this component
569
+ *
570
+ */
571
+ _registerListeners() {
572
+ this._containerElement.addEventListener("click", (t) => {
573
+ t.target.nodeName === "BUTTON" ? this._onButtonClick(t) : t.target.nodeName === "LI" && this._onListItemClick(t);
574
+ });
575
+ }
576
+ /**
577
+ * Triggered when time interval is clicked
578
+ *
579
+ */
580
+ _onTimeIntervalButtonClick(t) {
581
+ let i = this._timeIntervalGroup.getElementsByTagName("ul")[0];
582
+ i.classList.contains("active") ? i.classList.remove("active") : i.classList.add("active");
583
+ }
584
+ /**
585
+ * Triggered when time interval list item is clicked
586
+ *
587
+ */
588
+ _onTimeIntervalListItemClick(t) {
589
+ let i = parseInt(t.target.dataset.value, 10);
590
+ this.historyInterval !== i && (this.historyInterval = i, this.dispatchEvent("stateChanged"));
591
+ }
592
+ /**
593
+ * Triggered when chart line style button is clicked
594
+ *
595
+ */
596
+ _onChartLineButtonClick(t) {
597
+ t.target.dataset.value === "sma" ? this.drawSimpleMovingAverage = !t.target.classList.contains("active") : t.target.dataset.value === "ema" ? this.drawExponentialMovingAverage = !t.target.classList.contains("active") : t.target.dataset.value === "bb" && (this.drawBollingerBands = !t.target.classList.contains("active")), this.dispatchEvent("stateChanged");
598
+ }
599
+ /**
600
+ * Triggered when chart type button is clicked
601
+ *
602
+ */
603
+ _onChartTypeButtonClick(t) {
604
+ this.chartType = t.target.dataset.value, this.dispatchEvent("stateChanged");
605
+ }
606
+ /**
607
+ * Triggered when a list item is clicked
608
+ *
609
+ */
610
+ _onListItemClick(t) {
611
+ t.target.dataset.group === "time-interval" && this._onTimeIntervalListItemClick(t);
612
+ }
613
+ /**
614
+ * Triggered when a button is clicked
615
+ *
616
+ */
617
+ _onButtonClick(t) {
618
+ t.target.dataset.group === "time-interval" ? this._onTimeIntervalButtonClick(t) : t.target.dataset.group === "chart-line" ? this._onChartLineButtonClick(t) : t.target.dataset.group === "chart-type" && this._onChartTypeButtonClick(t);
619
+ }
620
+ get containerElement() {
621
+ return this._containerElement;
622
+ }
623
+ get historyInterval() {
624
+ return this._historyInterval;
625
+ }
626
+ set historyInterval(t) {
627
+ this._historyInterval = t, this._updateState();
628
+ }
629
+ get drawSimpleMovingAverage() {
630
+ return this._drawSimpleMovingAverage;
631
+ }
632
+ set drawSimpleMovingAverage(t) {
633
+ this._drawSimpleMovingAverage = t, this._updateState();
634
+ }
635
+ get drawExponentialMovingAverage() {
636
+ return this._drawExponentialMovingAverage;
637
+ }
638
+ set drawExponentialMovingAverage(t) {
639
+ this._drawExponentialMovingAverage = t, this._updateState();
640
+ }
641
+ get drawBollingerBands() {
642
+ return this._drawBollingerBands;
643
+ }
644
+ set drawBollingerBands(t) {
645
+ this._drawBollingerBands = t, this._updateState();
646
+ }
647
+ get chartType() {
648
+ return this._chartType;
649
+ }
650
+ set chartType(t) {
651
+ this._chartType = t, this._updateState();
652
+ }
653
+ }
654
+ class D {
655
+ constructor(t = 0, i = 0, e = 0, s = 0) {
656
+ this._x = t, this._y = i, this._width = e, this._height = s;
657
+ }
658
+ setDimensions(t = 0, i = 0, e = 0, s = 0) {
659
+ (this._x !== t || this._y !== i || this._width !== e || this._height !== s) && (this._x = t, this._y = i, this._width = e, this._height = s);
660
+ }
661
+ get x() {
662
+ return this._x;
663
+ }
664
+ set x(t) {
665
+ this._x !== t && (this._x = t);
666
+ }
667
+ get y() {
668
+ return this._y;
669
+ }
670
+ set y(t) {
671
+ this._y !== t && (this._y = t);
672
+ }
673
+ get width() {
674
+ return this._width;
675
+ }
676
+ set width(t) {
677
+ this._width !== t && (this._width = t);
678
+ }
679
+ get height() {
680
+ return this._height;
681
+ }
682
+ set height(t) {
683
+ this._height !== t && (this._height = t);
684
+ }
685
+ }
686
+ const L = {
687
+ VERTICAL: "1",
688
+ HORIZONTAL: "2"
689
+ }, v = {
690
+ NUMBER: "1",
691
+ CURRENCY: "2",
692
+ DATETIME: "3"
693
+ }, w = {
694
+ PAN: "1",
695
+ RESIZE_LEFT: "2",
696
+ RESIZE_RIGHT: "3"
697
+ };
698
+ class C {
699
+ // https://github.com/curran/ticks/blob/master/index.js
700
+ static getBases() {
701
+ return [1, 2, 2.5, 5];
702
+ }
703
+ static getNiceInterval(t, i, e) {
704
+ var s = (i - t) / e, a = Math.log10(s);
705
+ let n = [Math.floor(a), Math.ceil(a)], r = 1 / 0;
706
+ return C.getBases().forEach((o) => {
707
+ n.forEach((h) => {
708
+ let _ = o * Math.pow(10, h), l = Math.abs(s - _), u = Math.abs(s - r);
709
+ l < u && (r = _);
710
+ });
711
+ }), r;
712
+ }
713
+ static generate(t, i, e, s) {
714
+ let a = t < 10 && i < 10;
715
+ a && (t = t * 1e3, i = i * 1e3);
716
+ let n = C.getNiceInterval(t, i, e), r = Math.ceil(t / n) * n, o = [r];
717
+ for (; r < i && r + n < i; )
718
+ r += n, o.push(r);
719
+ let h = Math.pow(10, Math.ceil(Math.log10(n)) + 1);
720
+ return o = o.map((_) => {
721
+ let l = Math.round(_ * h) / h;
722
+ return a && (l = l / 1e3), l;
723
+ }), s && (a && (t = t / 1e3, i = i / 1e3), o[0] = t, o[o.length - 1] = i), o;
724
+ }
725
+ }
726
+ class m {
727
+ static drawPath(t, i, e, s, a) {
728
+ e !== null && (t.fillStyle = e), s !== null && a !== null && (t.lineWidth = a, t.strokeStyle = s), t.beginPath();
729
+ let n, r, o;
730
+ i.forEach((h, _) => {
731
+ _ === 0 ? (n = r = h[0], o = h[1], t.moveTo(h[0], (h[1] | 0) + 0.5)) : (n = h[0] > n ? h[0] : n, r = h[0] < r ? h[0] : r, o = h[1] > o ? h[1] : o, t.lineTo(h[0], (h[1] | 0) + 0.5));
732
+ }), s !== null && a !== null && t.stroke(), t.lineTo(n, o), t.lineTo(r, o), e !== null && t.fill();
733
+ }
734
+ static drawAliasedLine(t, i, e, s, a, n) {
735
+ let r = Math.abs(a - e), o = e < a ? 1 : -1, h = -Math.abs(n - s), _ = s < n ? 1 : -1, l = r + h, u;
736
+ for (t.fillStyle = i; t.fillRect(e, s, 1, 1), !(e === a && s === n); )
737
+ u = 2 * l, u >= h && (l += h, e += o), u <= r && (l += r, s += _);
738
+ }
739
+ static debounce(t, i, e, s) {
740
+ var a;
741
+ return function() {
742
+ var n = t, r = arguments, o = function() {
743
+ a = null, s || i.apply(n, r);
744
+ }, h = s && !a;
745
+ clearTimeout(a), a = setTimeout(o, e), h && i.apply(n, r);
746
+ };
747
+ }
748
+ static throttle(t, i, e) {
749
+ e || (e = 250);
750
+ let s, a;
751
+ return function() {
752
+ var n = t || this, r = Date.now(), o = arguments;
753
+ s && r < s + e ? (clearTimeout(a), a = setTimeout(function() {
754
+ s = r, i.apply(n, o);
755
+ }, e)) : (s = r, i.apply(n, o));
756
+ };
757
+ }
758
+ static abbreviateNumber(t) {
759
+ var i = Math.log10(t) / 3 | 0;
760
+ if (i === 0)
761
+ return t;
762
+ let e = d.configuration.number_suffixes[i], s = Math.pow(10, i * 3);
763
+ return (t / s | 0) + e;
764
+ }
765
+ static formatNumberToLocale(t, i) {
766
+ const e = d.configuration.locale || "en-US", s = 10 ** i;
767
+ return isNaN(t) ? "" : i === 0 ? parseInt(t, 10).toLocaleString(e) : (Math.floor(t * s) / s).toLocaleString(e, {
768
+ minimumFractionDigits: i,
769
+ maximumFractionDigits: i
770
+ });
771
+ }
772
+ static formatUSD(t, i) {
773
+ var e = "\\d(?=(\\d{3})+" + (i > 0 ? "\\." : "$") + ")";
774
+ return t.toFixed(Math.max(0, ~~i)).replace(new RegExp(e, "g"), "$&,");
775
+ }
776
+ }
777
+ class k extends b {
778
+ constructor(t = null, i = 0, e = 0, s = 0, a = "sans-serif", n = 12, r = "#ffffff", o = "", h = !1) {
779
+ super(), t !== null && (this._dimensions = t), this._type = i, this._orientation = e, this._precision = s, this._fontFace = a, this._fontSize = n, this._fontColor = r, this._tickPrefix = o, this._abbreviate = h, this._minimum = 0, this._maximum = 0, this._span = 0, this._tickPoints = [];
780
+ }
781
+ _drawHorizontal(t) {
782
+ let i = this._dimensions.width / (this._fontSize * 10) | 0;
783
+ if (this._tickPoints = [], this._type === v.DATETIME) {
784
+ let e = this._span / i | 0, s = this._maximum;
785
+ for (; s > this._minimum && s - e > this._minimum; ) {
786
+ s -= e;
787
+ let a = (s - this._minimum) / this._span, n = this._dimensions.x + a * this._dimensions.width, r = this._dimensions.y;
788
+ this._tickPoints.push(n);
789
+ let o = new Date(s * 1e3);
790
+ o.getUTCDate();
791
+ let h = d.configuration.date_format_months[o.getMonth()] + " " + o.getDate(), _ = t.measureText(h).width / 2 | 0;
792
+ t.fillRect(n, r, 1, 5), t.fillText(h, n - _, r + this._fontSize + 5);
793
+ }
794
+ } else
795
+ C.generate(this._minimum, this._maximum, i, !1).forEach((s) => {
796
+ let a = (s - this._minimum) / this._span, n = this._dimensions.x + a * this._dimensions.width, r = this._dimensions.y, o;
797
+ if (this._tickPoints.push(n), this._type === v.DATETIME) {
798
+ let _ = new Date(s * 1e3);
799
+ _.getUTCDate(), d.configuration.date_format_months[_.getMonth()] + "" + _.getDate(), console.log(s);
800
+ } else
801
+ this._abbreviate ? o = m.abbreviateNumber(s) : o = m.formatNumberToLocale(s, this._precision), this._tickPrefix !== "" && (o = this._tickPrefix + o);
802
+ let h = t.measureText(o).width / 2 | 0;
803
+ t.fillRect(n, r, 1, 5), t.fillText(o, n - h, r + this._fontSize + 5);
804
+ });
805
+ }
806
+ _drawVertical(t) {
807
+ let i = this._dimensions.height / (this._fontSize * 2) | 0, e = C.generate(this._minimum, this._maximum, i, !1);
808
+ this._tickPoints = [], e.forEach((s) => {
809
+ let a = 1 - (s - this._minimum) / this._span, n = this._dimensions.x, r = this._dimensions.y + 2 + a * this._dimensions.height;
810
+ this._tickPoints.push(r), s % 1 !== 0 && this._precision > 0 && (s = s.toFixed(this._precision));
811
+ let o;
812
+ this._abbreviate ? o = m.abbreviateNumber(s) : o = m.formatNumberToLocale(s, this._precision), this._tickPrefix !== "" && (o = this._tickPrefix + o), o = "- " + o, t.fillText(o, n, r);
813
+ });
814
+ }
815
+ draw(t) {
816
+ t === void 0 || this._dimensions === null || this._type === 0 || this._span === 0 || this._dimensions.width === 0 || this._dimensions.height === 0 || (t.font = this._font, t.fillStyle = this._fontColor, this._orientation === L.HORIZONTAL ? this._drawHorizontal(t) : this._orientation === L.VERTICAL && this._drawVertical(t));
817
+ }
818
+ get dimensions() {
819
+ return this._dimensions;
820
+ }
821
+ set dimensions(t) {
822
+ this._dimensions !== t && (this._dimensions = t);
823
+ }
824
+ get type() {
825
+ return this._type;
826
+ }
827
+ set type(t) {
828
+ this._type !== t && (this._type = t);
829
+ }
830
+ get orientation() {
831
+ return this._orientation;
832
+ }
833
+ set orientation(t) {
834
+ this._orientation !== t && (this._orientation = t);
835
+ }
836
+ get precision() {
837
+ return this._precision;
838
+ }
839
+ set precision(t) {
840
+ this._precision !== t && (this._precision = t);
841
+ }
842
+ get fontFace() {
843
+ return this._fontFace;
844
+ }
845
+ set fontFace(t) {
846
+ this._fontFace !== t && (this._fontFace = t);
847
+ }
848
+ get fontSize() {
849
+ return this._fontSize;
850
+ }
851
+ set fontSize(t) {
852
+ this._fontSize !== t && (this._fontSize = t);
853
+ }
854
+ get fontColor() {
855
+ return this._fontColor;
856
+ }
857
+ set fontColor(t) {
858
+ this._fontColor !== t && (this._fontColor = t);
859
+ }
860
+ get font() {
861
+ return this._font;
862
+ }
863
+ set font(t) {
864
+ this._font !== t && (this._font = t);
865
+ }
866
+ get tickPrefix() {
867
+ return this._tickPrefix;
868
+ }
869
+ set tickPrefix(t) {
870
+ this._tickPrefix !== t && (this._tickPrefix = t);
871
+ }
872
+ get abbreviate() {
873
+ return this._abbreviate;
874
+ }
875
+ set abbreviate(t) {
876
+ this._abbreviate !== t && (this._abbreviate = t);
877
+ }
878
+ get minimum() {
879
+ return this._minimum;
880
+ }
881
+ set minimum(t) {
882
+ this._minimum !== t && (this._minimum = t, this._span = this._maximum - this._minimum);
883
+ }
884
+ get maximum() {
885
+ return this._maximum;
886
+ }
887
+ set maximum(t) {
888
+ this._maximum !== t && (this._maximum = t, this._span = this._maximum - this._minimum);
889
+ }
890
+ get tickPoints() {
891
+ return this._tickPoints;
892
+ }
893
+ }
894
+ class I extends b {
895
+ /**
896
+ * Instantiates the component and defines all private properties
897
+ *
898
+ * @param {HTMLElement} container
899
+ *
900
+ */
901
+ constructor(t) {
902
+ super(), this._containerElement = t, this._element = null, this._drawingCanvas = null, this._drawingContext = null, this._renderingCanvas = null, this._renderingContext = null, this._xLabels = null, this._yLabels = null, this._x = 0, this._y = 0, this._width = 0, this._height = 0, this._mouseIsDown = !1, this._mouseDownX = 0, this._mouseDownY = 0, this._mouseUpX = 0, this._mouseUpY = 0, this._mouseDragXDistance = 0, this._mouseDragYDistance = 0, this._currentMouseCursor = "default", this._currentTouchID = null, this._chartDimensions = null, this._xLabelDimensions = null, this._yLabelDimensions = null, this._dimensionsInvalidated = !1, this._elementBoundingRect = null, this._configuration = null, this._pixelRatio = window.devicePixelRatio, this._fontSize = d.configuration.defaults.font_size * this._pixelRatio, this._fontFace = d.configuration.defaults.font_face, this._font = this._fontSize + "px " + this._fontFace, this._onMouseMove = this._onMouseMove.bind(this), this._onMouseUp = this._onMouseUp.bind(this);
903
+ }
904
+ /**
905
+ * Structures the component on the DOM, assigns dimension objects to the component, and
906
+ * instanciates axis label components
907
+ *
908
+ */
909
+ _build() {
910
+ this._pixelRatio = window.devicePixelRatio, this._fontSize = this._configuration.font_size * this._pixelRatio, this._fontFace = this._configuration.font_face, this._font = this._fontSize + "px " + this._fontFace, this._chartDimensions = new D(), this._xLabelDimensions = new D(), this._yLabelDimensions = new D(), this._element = document.createElement("div"), this._element.classList.add("chart"), this._drawingCanvas = document.createElement("canvas"), this._drawingContext = this._drawingCanvas.getContext("2d", { antialias: !1, alpha: !1 }), this._drawingContext.imageSmoothingEnabled = !1, this._drawingContext.imageSmoothingQuality = "low", this._drawingContext.font = this._font, this._renderingCanvas = document.createElement("canvas"), this._renderingContext = this._renderingCanvas.getContext("2d", { antialias: !1, alpha: !1 }), this._renderingContext.imageSmoothingEnabled = !1, this._renderingContext.imageSmoothingQuality = "low", this._renderingCanvas.classList.add("chart-canvas"), this._containerElement.append(this._element), this._element.append(this._renderingCanvas), this._elementBoundingRect = this._element.getBoundingClientRect(), this._xLabels = new k(), this._xLabels.dimensions = this._xLabelDimensions, this._xLabels.type = v.NUMBER, this._xLabels.orientation = L.HORIZONTAL, this._xLabels.precision = this._configuration.x_label_precision, this._xLabels.font = this._font, this._yLabels = new k(), this._yLabels.dimensions = this._yLabelDimensions, this._yLabels.type = v.NUMBER, this._yLabels.orientation = L.VERTICAL, this._yLabels.precision = this._configuration.y_label_precision, this._yLabels.fontFace = this._fontFace, this._yLabels.fontSize = this._fontSize;
911
+ }
912
+ /**
913
+ * Provides a way to recompute the component dimensions
914
+ *
915
+ */
916
+ invalidateDimensions() {
917
+ this._computeDimensions();
918
+ }
919
+ /**
920
+ * In conjunction with the assigned _configuration property in subclasses,
921
+ * determines the new dimensions for the component, canvases, axis labeling, etc
922
+ *
923
+ */
924
+ _computeDimensions() {
925
+ if (this._configuration === null)
926
+ return;
927
+ this._dimensionsInvalidated = !1;
928
+ let t = 0, i = 0, e = this._element.offsetWidth * this._pixelRatio, s = this._element.offsetHeight * this._pixelRatio;
929
+ if (this._x !== t || this._y !== i || this._width !== e || this._height !== s) {
930
+ this._x = t, this._y = i, this._width = e, this._height = s, this._drawingCanvas.width = this._width, this._drawingCanvas.height = this._height, this._renderingCanvas.width = this._width, this._renderingCanvas.height = this._height;
931
+ let a;
932
+ this._configuration.x_label_height % 1 === 0 ? a = this._configuration.x_label_height : a = this._height * this._configuration.x_label_height;
933
+ let n;
934
+ this._configuration.x_label_height % 1 === 0 ? n = this._configuration.y_label_width : n = this._height * this._configuration.y_label_width, this._chartDimensions.x = 0, this._chartDimensions.y = 0, this._chartDimensions.width = this._width - n * this._pixelRatio, this._chartDimensions.height = this._height - a * this._pixelRatio, this._xLabelDimensions.x = 0, this._xLabelDimensions.y = this._height - a * this._pixelRatio, this._xLabelDimensions.width = this._width - n * this._pixelRatio, this._xLabelDimensions.height = a * this._pixelRatio, this._yLabelDimensions.x = this._width - n * this._pixelRatio, this._yLabelDimensions.y = 0, this._yLabelDimensions.width = n * this._pixelRatio, this._yLabelDimensions.height = this._height - a * this._pixelRatio, this._elementBoundingRect = this._element.getBoundingClientRect(), this._dimensionsInvalidated = !0;
935
+ }
936
+ }
937
+ /**
938
+ * Performs all drawing operations for this component - drawing is performed on
939
+ * this._drawingContext and composited and rendered to DOM on this._renderingContext
940
+ *
941
+ * @param {Boolean} force - Forces drawing operations to perform regardless of invalidation checks
942
+ *
943
+ */
944
+ _draw(t) {
945
+ requestAnimationFrame((i) => {
946
+ this._drawBackground(t), this._drawLabels(t), this._drawChart(t), this._drawBorders(t), this._render(t), this._dimensionsInvalidated = !1;
947
+ });
948
+ }
949
+ /**
950
+ * Performs the drawing operation for the background of this component - background
951
+ * is drawn on this._drawingContext
952
+ *
953
+ * @param | force | Boolean - Forces method to perform regardless of invalidation checks
954
+ *
955
+ */
956
+ _drawBackground(t) {
957
+ this._configuration !== null && (this._drawingContext.fillStyle = this._configuration.background_color, this._drawingContext.fillRect(0, 0, this._width, this._height));
958
+ }
959
+ /**
960
+ * Performs bulk of work of drawing data visualization for this component - chart is drawn
961
+ * on this._drawingContext
962
+ *
963
+ * @param {Boolean} force - Forces method to perform regardless of invalidation checks
964
+ *
965
+ */
966
+ _drawChart(t) {
967
+ }
968
+ /**
969
+ * Performs of axis labels for this component - labels are only drawn with instruction from this
970
+ * component and are drawwn on this._drawingContext
971
+ *
972
+ * @param {Boolean} force - Forces method to perform regardless of invalidation checks
973
+ *
974
+ */
975
+ _drawLabels(t) {
976
+ this._xLabels.draw(this._drawingContext), this._yLabels.draw(this._drawingContext);
977
+ }
978
+ /**
979
+ * Performs drawing of all borders for this component - borders are drawwn on this._drawingContext
980
+ *
981
+ * @param {Boolean} force - Forces method to perform regardless of invalidation checks
982
+ *
983
+ */
984
+ _drawBorders(t) {
985
+ }
986
+ /**
987
+ * Performs compositing of drawing canvas onto rendering canvesa and painting to the DOM
988
+ *
989
+ * @param {Boolean} force - Forces method to perform regardless of invalidation checks
990
+ *
991
+ */
992
+ _render(t) {
993
+ this._renderingContext.clearRect(0, 0, this._width, this._height), this._drawingCanvas.width && this._drawingCanvas.height && this._renderingContext.drawImage(this._drawingCanvas, 0, 0);
994
+ }
995
+ /**
996
+ * Initializes all event listener bindings for this component
997
+ *
998
+ */
999
+ _registerListeners() {
1000
+ this._element.addEventListener("mouseleave", (t) => this._onMouseLeave(t), !0), this._element.addEventListener("mouseenter", (t) => this._onMouseEnter(t), !0), window.addEventListener("mousemove", this._onMouseMove, !0), this._element.addEventListener("mousedown", (t) => this._onMouseDown(t)), window.addEventListener("mouseup", this._onMouseUp), this._element.addEventListener("wheel", m.throttle(this, function(t) {
1001
+ this._onMouseWheel(t);
1002
+ }, d.configuration.mouse_wheel_throttle_rate), !0), this._element.addEventListener("touchstart", (t) => this._onTouchStart(t)), this._element.addEventListener("touchend", (t) => this._onTouchEnd(t)), this._element.addEventListener("touchcancel", (t) => this._onTouchCancel(t)), this._element.addEventListener("touchmove", (t) => this._onTouchMove(t));
1003
+ }
1004
+ _unregisterListeners() {
1005
+ window.removeEventListener("mousemove", this._onMouseMove, !0), window.removeEventListener("mouseup", this._onMouseUp);
1006
+ }
1007
+ /**
1008
+ * Triggered when mouse pointer enters the bounds of this._element
1009
+ *
1010
+ */
1011
+ _onMouseEnter(t) {
1012
+ t.preventDefault !== void 0 && t.preventDefault();
1013
+ }
1014
+ /**
1015
+ * Triggered when mouse pointer leaves the bounds of this._element
1016
+ *
1017
+ */
1018
+ _onMouseLeave(t) {
1019
+ t.preventDefault !== void 0 && t.preventDefault();
1020
+ }
1021
+ /**
1022
+ * Triggered when mouse changes position within the bounds of this._element
1023
+ *
1024
+ */
1025
+ _onMouseMove(t) {
1026
+ t.preventDefault !== void 0 && t.preventDefault(), this._mouseX = t.clientX * this._pixelRatio - this._elementBoundingRect.left * this._pixelRatio, this._mouseY = t.clientY * this._pixelRatio - this._elementBoundingRect.top * this._pixelRatio, this._mouseIsDown && (this._mouseDragXDistance = this._mouseX - this._mouseDownX, this._mouseDragYDistance = this._mouseY - this._mouseDownY);
1027
+ }
1028
+ /**
1029
+ * Triggered when mouse is pressed within the bounds of this._element
1030
+ *
1031
+ */
1032
+ _onMouseDown(t) {
1033
+ t.preventDefault !== void 0 && t.preventDefault(), this._mouseIsDown = !0, this._mouseDownX = t.clientX * this._pixelRatio - this._elementBoundingRect.left * this._pixelRatio, this._mouseDownY = t.clientY * this._pixelRatio - this._elementBoundingRect.top * this._pixelRatio, this._mouseDragXDistance = 0, this._mouseDragYDistance = 0;
1034
+ }
1035
+ /**
1036
+ * Triggered when mouse is released within the bounds of this._containerElement
1037
+ *
1038
+ */
1039
+ _onMouseUp(t) {
1040
+ t.preventDefault !== void 0 && t.preventDefault(), this._mouseIsDown && (this._mouseIsDown = !1, this._mouseUpX = t.clientX * this._pixelRatio - this._elementBoundingRect.left * this._pixelRatio, this._mouseUpY = t.clientY * this._pixelRatio - this._elementBoundingRect.top * this._pixelRatio), this._mouseDragXDistance = 0, this._mouseDragYDistance = 0;
1041
+ }
1042
+ /**
1043
+ * Triggered when mouse or trackpad scrolling is performed - mouse move is triggered
1044
+ * in order to ensure mouse position is update for computation required during scroll
1045
+ * events
1046
+ *
1047
+ */
1048
+ _onMouseWheel(t) {
1049
+ t.preventDefault !== void 0 && t.preventDefault(), this._onMouseMove(t);
1050
+ }
1051
+ /**
1052
+ * Triggered when device surface is touched within the bounds of this._element - this is
1053
+ * abstracted out to performs mouse down events
1054
+ *
1055
+ */
1056
+ _onTouchStart(t) {
1057
+ if (t.preventDefault !== void 0 && t.preventDefault(), t.changedTouches.length > 0) {
1058
+ let i = t.changedTouches[0];
1059
+ this._currentTouchID = i.identifier, this._onMouseDown(i);
1060
+ }
1061
+ }
1062
+ /**
1063
+ * Triggered when device surface is released within the bounds of this._element - this is
1064
+ * abstracted out to performs mouse up events
1065
+ *
1066
+ */
1067
+ _onTouchEnd(t) {
1068
+ if (t.preventDefault !== void 0 && t.preventDefault(), t.changedTouches.length > 0)
1069
+ for (let i = 0; i < t.changedTouches.length; i++) {
1070
+ let e = t.changedTouches[i];
1071
+ if (this._currentTouchID === e.identifier) {
1072
+ this._onMouseUp(e), this._currentTouchID = null;
1073
+ break;
1074
+ }
1075
+ }
1076
+ }
1077
+ /**
1078
+ * Triggered when device surface touch is moved within the bounds of this._element - this is
1079
+ * abstracted out to performs mouse move events
1080
+ *
1081
+ */
1082
+ _onTouchMove(t) {
1083
+ if (t.preventDefault !== void 0 && t.preventDefault(), t.changedTouches.length > 0)
1084
+ for (let i = 0; i < t.changedTouches.length; i++) {
1085
+ let e = t.changedTouches[i];
1086
+ if (this._currentTouchID === e.identifier) {
1087
+ this._onMouseMove(e);
1088
+ break;
1089
+ }
1090
+ }
1091
+ }
1092
+ /**
1093
+ * Triggered when I dunno yet
1094
+ *
1095
+ */
1096
+ _onTouchCancel(t) {
1097
+ t.preventDefault !== void 0 && t.preventDefault();
1098
+ }
1099
+ // Presumption is made that any chart component will have some data from which to draw from
1100
+ get data() {
1101
+ return this._data;
1102
+ }
1103
+ get x() {
1104
+ return this._x / this._pixelRatio;
1105
+ }
1106
+ get y() {
1107
+ return this._y / this._pixelRatio;
1108
+ }
1109
+ get width() {
1110
+ return this._width / this._pixelRatio;
1111
+ }
1112
+ get height() {
1113
+ return this._height / this._pixelRatio;
1114
+ }
1115
+ get containerElement() {
1116
+ return this._containerElement;
1117
+ }
1118
+ }
1119
+ class B extends I {
1120
+ /**
1121
+ * Instantiates the component and defines all private properties
1122
+ *
1123
+ * @param {HTMLElement} container
1124
+ * @param {HistoryData} data
1125
+ *
1126
+ */
1127
+ constructor(t, i) {
1128
+ super(t), this._data = i, this._itemWidth = 0, this._itemMargin = 0, this._drawStartIndex = Number.MAX_SAFE_INTEGER, this._drawEndIndex = 0, this._dragStartIndex = 0, this._interval = null;
1129
+ }
1130
+ /**
1131
+ * Determines the indices from which the data is drawn
1132
+ *
1133
+ */
1134
+ _computeIndices() {
1135
+ let t = this._itemWidth + this._itemMargin, i = this._chartDimensions.width / t | 0, e = this._drawStartIndex, s = 0;
1136
+ if (this._mouseDragXDistance !== 0) {
1137
+ let a = -(this._mouseDragXDistance / t | 0), n = this._data.length - 1 - i;
1138
+ e = Math.max(Math.min(this._dragStartIndex + a, n), 0);
1139
+ }
1140
+ return s = e + i, i > this._data.length && (e = 0, s = this._data.length - 1), s > this._data.length - 1 && (s = this._data.length - 1, e = s - i), this._drawStartIndex !== e || this._drawEndIndex !== s ? (this._drawStartIndex = e, this._drawEndIndex = s, this.dispatchEvent("indicesChanged", e, s), !0) : !1;
1141
+ }
1142
+ /**
1143
+ * Stub for subclasses
1144
+ *
1145
+ */
1146
+ _computeBounds() {
1147
+ }
1148
+ /**
1149
+ * Initializes all event listener bindings for this component
1150
+ *
1151
+ */
1152
+ _registerListeners() {
1153
+ super._registerListeners(), this._data.addEventListener("parseComplete", () => {
1154
+ this._onParseComplete();
1155
+ });
1156
+ }
1157
+ _unregisterListeners() {
1158
+ super._unregisterListeners();
1159
+ }
1160
+ /**
1161
+ * Triggered when the data object has parsed its data
1162
+ *
1163
+ */
1164
+ _onParseComplete() {
1165
+ this._interval = this._data.interval, this._itemWidth = d.configuration.defaults.history_item_width, this._itemMargin = d.configuration.defaults.history_item_margin;
1166
+ let t = this._chartDimensions.width / (this._itemWidth + this._itemMargin) | 0;
1167
+ this._drawEndIndex = this._data.length - 1, this._drawStartIndex = Math.max(this._drawEndIndex - t, 0), this.dispatchEvent("indicesChanged", this._drawStartIndex, this._drawEndIndex), this._draw(!0);
1168
+ }
1169
+ /**
1170
+ * Triggered when mouse pointer leaves the bounds of this._element - this instance
1171
+ * also triggers onMouseUp when the mouse leaves
1172
+ *
1173
+ */
1174
+ _onMouseLeave(t) {
1175
+ t.target === this._element && super._onMouseLeave(t);
1176
+ }
1177
+ /**
1178
+ * Triggered when mouse is pressed within the bounds of this._element - this._dragStartIndex
1179
+ * is set here
1180
+ *
1181
+ */
1182
+ _onMouseDown(t) {
1183
+ super._onMouseDown(t), this._dragStartIndex = this._drawStartIndex;
1184
+ }
1185
+ /**
1186
+ * Triggered when mouse is released within the bounds of this._containerElement - draw is also
1187
+ * forced in case indices and bounds have changed while pointer is leaving
1188
+ *
1189
+ */
1190
+ _onMouseUp(t) {
1191
+ super._onMouseUp(t), this._draw(!0);
1192
+ }
1193
+ /**
1194
+ * Triggered when mouse changes position within the bounds of this._element - if mouse is down
1195
+ * drag operation is being performed, necessitating a draw, under the presumption that the
1196
+ * drawing window has changed
1197
+ *
1198
+ */
1199
+ _onMouseMove(t) {
1200
+ super._onMouseMove(t), this._mouseIsDown && this._draw(!0);
1201
+ }
1202
+ /**
1203
+ * Triggered when mouse or trackpad scrolling is performed - history components also change
1204
+ * their drawing indices based on the scroll delta, simulating zooming in and out - drawing
1205
+ * position is changed relative to the pointer position on this component
1206
+ *
1207
+ */
1208
+ _onMouseWheel(t) {
1209
+ if (super._onMouseWheel(t), this._mouseIsDown)
1210
+ return;
1211
+ let i = this._itemWidth, e = this._itemMargin;
1212
+ t.deltaY < 0 ? i = i + i * 0.1 : i = i - i * 0.1, i = Math.max(i, 0.05), e = 0;
1213
+ let s = this._itemWidth + this._itemMargin, a = i + e, n = this._chartDimensions.width / s | 0, r = Math.min(this._chartDimensions.width / a | 0, this._data.length);
1214
+ this._data.length - 1 - r;
1215
+ let o = (this._mouseX - this._chartDimensions.x) / this._chartDimensions.width, h = n - r, _ = o * h | 0;
1216
+ r > this._data.length && (_ = -this._drawStartIndex), this._drawStartIndex = Math.max(this._drawStartIndex + _, 0), this._itemWidth = i, this._itemMargin = e, this._draw(!0);
1217
+ }
1218
+ /**
1219
+ * Allow setting the drawing indices for this component by an external source, particularly
1220
+ * other history components that share the data this component uses
1221
+ *
1222
+ * @param {Number} startIndex
1223
+ * @param {Number} endIndex
1224
+ *
1225
+ */
1226
+ setIndices(t, i) {
1227
+ t = Math.max(t, 0), i = Math.min(i, this._data.length - 1);
1228
+ let e = i - t, s = this._chartDimensions.width / e, a = 0;
1229
+ (this._itemWidth !== s || this._itemMargin !== a || this._drawStartIndex !== t || this._drawEndIndex !== i) && (this._itemWidth = s, this._itemMargin = a, this._drawStartIndex = t, this._drawEndIndex = i, this._draw(!0));
1230
+ }
1231
+ get drawStartIndex() {
1232
+ return this._drawStartIndex;
1233
+ }
1234
+ get drawEndIndex() {
1235
+ return this._drawEndIndex;
1236
+ }
1237
+ get interval() {
1238
+ return this._interval;
1239
+ }
1240
+ /*
1241
+ set interval(i){
1242
+ this._interval = i;
1243
+
1244
+ this._drawStartIndex = Number.MAX_SAFE_INTEGER;
1245
+ this._drawEndIndex = 0;
1246
+ }
1247
+ */
1248
+ }
1249
+ class F extends B {
1250
+ /**
1251
+ * Instantiates the component and defines all private properties
1252
+ *
1253
+ * @param {HTMLElement} container
1254
+ * @param {HistoryData} data
1255
+ *
1256
+ */
1257
+ constructor(t, i) {
1258
+ super(t, i), this._infoElement = null, this._itemWidth = d.configuration.defaults.price_volume_history_item_width, this._itemMargin = 0, this._drawSimpleMovingAverage = d.configuration.defaults.draw_simple_moving_average, this._drawExponentialMovingAverage = d.configuration.defaults.draw_exponential_moving_average, this._drawBollingerBands = d.configuration.defaults.draw_bollinger_bands, this._useGradient = d.configuration.price_history.use_gradient, this._useGridLines = d.configuration.price_history.use_grid_lines, this._lowerPriceBound = Number.MAX_SAFE_INTEGER, this._upperPriceBound = 0, this._priceBoundsSpan = 0, this._marketPrice = 0, this._chartType = d.configuration.defaults.chart_type, this._configuration = Object.assign({}, d.configuration.price_history), this._infoDimensions = new D(), this._priceChartDimensions = new D(), this._build(), this._registerListeners();
1259
+ }
1260
+ /**
1261
+ * Structures the component on the DOM, creates the information component and sets
1262
+ * axis labeling properties
1263
+ *
1264
+ */
1265
+ _build() {
1266
+ super._build(), this._element.classList.add("price-history"), this._infoElement = document.createElement("div"), this._infoElement.classList.add("info"), this._infoLabels = this._configuration.info_labels ? this._configuration.info_labels : ["P", "O", "C", "H", "L", "V"], this._element.append(this._infoElement), this._infoElement.append(document.createElement("span")), this._infoElement.append(document.createElement("span")), this._infoElement.append(document.createElement("span")), this._infoElement.append(document.createElement("span")), this._infoElement.append(document.createElement("span")), this._infoElement.append(document.createElement("span")), this._xLabels.type = v.DATETIME, this._xLabels.fontFace = this._fontFace, this._xLabels.fontSize = this._fontSize, this._xLabels.fontColor = this._configuration.x_label_color, this._yLabels.type = v.CURRENCY, this._yLabels.fontFace = this._fontFace, this._yLabels.fontSize = this._fontSize, this._yLabels.fontColor = this._configuration.y_label_color, this._yLabels.tickPrefix = d.configuration.currency_character, this._yLabels.precision = this._configuration.y_label_precision;
1267
+ }
1268
+ /**
1269
+ * Computes dimensions for chart, information section and axis labeling
1270
+ *
1271
+ */
1272
+ _computeDimensions() {
1273
+ super._computeDimensions(), this._configuration.info_height % 1 === 0 ? this._infoDimensions.height = this._configuration.info_height * this._pixelRatio : this._infoDimensions.height = this._chartDimensions.height * this._configuration.info_height | 0, this._infoDimensions.width = this._chartDimensions.width, this._infoDimensions.x = this._chartDimensions.x, this._infoDimensions.y = this._chartDimensions.y, this._priceChartDimensions.x = this._chartDimensions.x, this._priceChartDimensions.y = this._chartDimensions.y + this._infoDimensions.height, this._priceChartDimensions.width = this._chartDimensions.width, this._priceChartDimensions.height = this._chartDimensions.height - this._infoDimensions.height - 1;
1274
+ let t = this._infoElement.style;
1275
+ t.top = this._infoDimensions.y / this._pixelRatio + "px", t.left = this._infoDimensions.x / this._pixelRatio + "px", t.width = this._infoDimensions.width / this._pixelRatio + "px", t.height = this._infoDimensions.height / this._pixelRatio + "px", this._yLabelDimensions.y = this._priceChartDimensions.y, this._yLabelDimensions.height = this._priceChartDimensions.height, this._draw();
1276
+ }
1277
+ /**
1278
+ * Computes the upper and lower bounds for all data points this chart component uses
1279
+ *
1280
+ * @return {Boolean} - whether or not bounds have changed
1281
+ *
1282
+ */
1283
+ _computeBounds() {
1284
+ super._computeBounds();
1285
+ let t = Number.MAX_SAFE_INTEGER, i = 0;
1286
+ for (let e = this._drawStartIndex; e < this._drawEndIndex; e++) {
1287
+ let s = this._data.getItemAt(e);
1288
+ s.low < t && (t = s.low), this._drawSimpleMovingAverage && s.simpleMovingAverage < t && (t = s.simpleMovingAverage.toFixed(6)), this._drawExponentialMovingAverage && s.exponentialMovingAverage < t && (t = s.exponentialMovingAverage), this._drawBollingerBands && Math.max(s.simpleMovingAverage - s.standardDeviation * this._configuration.bollinger_standard_deviation_offset, 0) < t && (t = Math.max(s.simpleMovingAverage - s.standardDeviation * this._configuration.bollinger_standard_deviation_offset, 0)), s.high > i && (i = s.high), this._drawSimpleMovingAverage && s.simpleMovingAverage > i && (i = s.simpleMovingAverage), this._drawExponentialMovingAverage && s.exponentialMovingAverage > i && (i = s.exponentialMovingAverage), this._drawBollingerBands && s.simpleMovingAverage + s.standardDeviation * this._configuration.bollinger_standard_deviation_offset > i && (i = s.simpleMovingAverage + s.standardDeviation * this._configuration.bollinger_standard_deviation_offset);
1289
+ }
1290
+ return this._lowerPriceBound !== t || this._upperPriceBound !== i ? (this._lowerPriceBound = t, this._upperPriceBound = i, this._priceBoundsSpan = this._upperPriceBound - this._lowerPriceBound, !0) : !1;
1291
+ }
1292
+ /**
1293
+ * Draws a candlestick to this._drawingContext using an item from HistoryData
1294
+ *
1295
+ */
1296
+ _drawCandlestick(t, i) {
1297
+ let e = this._itemWidth / 2 || 0.5, s = this._itemWidth > 1 ? 1 : 0.5, a = s / 2;
1298
+ this._drawingContext.fillStyle = t.bullish ? this._configuration.bullish_color : this._configuration.bearish_color;
1299
+ let n = Math.max(t.high, t.low), r = Math.min(t.high, t.low), o = Math.max(t.open, t.close), h = Math.min(t.open, t.close), _ = 1 - (n - this._lowerPriceBound) / this._priceBoundsSpan, l = 1 - (r - this._lowerPriceBound) / this._priceBoundsSpan, u = 1 - (o - this._lowerPriceBound) / this._priceBoundsSpan, g = 1 - (h - this._lowerPriceBound) / this._priceBoundsSpan, p = this._priceChartDimensions.y + _ * this._priceChartDimensions.height, f = this._priceChartDimensions.y + l * this._priceChartDimensions.height, x = this._priceChartDimensions.y + u * this._priceChartDimensions.height, M = this._priceChartDimensions.y + g * this._priceChartDimensions.height;
1300
+ this._drawingContext.fillRect(i + e - a, (p | 0) + 0.5, s, f - p), this._itemWidth > 1 && this._drawingContext.fillRect(i, (x | 0) + 0.5, this._itemWidth, Math.max(M - x, 0.5));
1301
+ }
1302
+ /**
1303
+ * Draws a bar to this._drawingContext using an item from HistoryData
1304
+ *
1305
+ */
1306
+ _drawBar(t, i) {
1307
+ let e = this._itemWidth / 2 || 0.5, s = this._itemWidth > 1 ? 1 : 0.5, a = s / 2;
1308
+ this._drawingContext.fillStyle = t.bullish ? this._configuration.bullish_color : this._configuration.bearish_color;
1309
+ let n = Math.max(t.high, t.low), r = Math.min(t.high, t.low), o = 1 - (n - this._lowerPriceBound) / this._priceBoundsSpan, h = 1 - (r - this._lowerPriceBound) / this._priceBoundsSpan, _ = 1 - (t.open - this._lowerPriceBound) / this._priceBoundsSpan, l = 1 - (t.close - this._lowerPriceBound) / this._priceBoundsSpan, u = this._priceChartDimensions.y + o * this._priceChartDimensions.height, g = this._priceChartDimensions.y + h * this._priceChartDimensions.height, p = this._priceChartDimensions.y + _ * this._priceChartDimensions.height, f = this._priceChartDimensions.y + l * this._priceChartDimensions.height;
1310
+ this._drawingContext.fillRect(i + e - a, (u | 0) + 0.5, s, g - u), this._itemWidth > 1 && (this._drawingContext.fillRect(i, (p | 0) + 0.5, e, s), this._drawingContext.fillRect(i + e, (f | 0) + 0.5, e, s));
1311
+ }
1312
+ /**
1313
+ * Inject gridlines in the background, if needed.
1314
+ *
1315
+ * @param {Boolean} force - Forces method to perform regardless of invalidation checks
1316
+ */
1317
+ _drawBackground(t) {
1318
+ super._drawBackground(t);
1319
+ }
1320
+ /**
1321
+ * Performs bulk of work of drawing data visualization for this component - chart is drawn
1322
+ * on this._drawingContext - includes drawing chart items, moving averages and Bollinger bands
1323
+ *
1324
+ * @param {Boolean} force - Forces method to perform regardless of invalidation checks
1325
+ */
1326
+ _drawChart(t) {
1327
+ if (super._drawChart(t), !this._data.hasData || !t && !this.indicesInvalidated && !this.boundsInvalidated && !this._dimensionsInvalidated)
1328
+ return;
1329
+ let i = this._itemWidth + this._itemMargin, e = this._drawEndIndex - this._drawStartIndex, s = this._priceChartDimensions.width / i | 0, a = this._priceChartDimensions.x, n = [], r = [], o = [], h = [], _ = [];
1330
+ s > e && (a += (s - e) * i | 0);
1331
+ for (let l = this._drawStartIndex; l < this._drawEndIndex; l++) {
1332
+ let u = this._data.getItemAt(l), g = a + (l - this._drawStartIndex) * i, p = g + (this._itemWidth / 2 | 0);
1333
+ if (this._chartType === "candlestick")
1334
+ this._drawCandlestick(u, g);
1335
+ else if (this._chartType === "bar")
1336
+ this._drawBar(u, g);
1337
+ else {
1338
+ let f = this._priceChartDimensions.y + (1 - (u.close - this._lowerPriceBound) / this._priceBoundsSpan) * this._priceChartDimensions.height;
1339
+ n.push([p, f]);
1340
+ }
1341
+ if (this._drawSimpleMovingAverage || this._drawBollingerBands) {
1342
+ let f = this._priceChartDimensions.y + (1 - (u.simpleMovingAverage - this._lowerPriceBound) / this._priceBoundsSpan) * this._priceChartDimensions.height;
1343
+ r.push([p, f]);
1344
+ }
1345
+ if (this._drawExponentialMovingAverage) {
1346
+ let f = this._priceChartDimensions.y + (1 - (u.exponentialMovingAverage - this._lowerPriceBound) / this._priceBoundsSpan) * this._priceChartDimensions.height;
1347
+ o.push([p, f]);
1348
+ }
1349
+ if (this._drawBollingerBands) {
1350
+ let f = this._priceChartDimensions.y + (1 - (u.simpleMovingAverage + u.standardDeviation * this._configuration.bollinger_standard_deviation_offset - this._lowerPriceBound) / this._priceBoundsSpan) * this._priceChartDimensions.height, x = this._priceChartDimensions.y + (1 - (u.simpleMovingAverage - u.standardDeviation * this._configuration.bollinger_standard_deviation_offset - this._lowerPriceBound) / this._priceBoundsSpan) * this._priceChartDimensions.height;
1351
+ h.push([p, f]), _.push([p, x]);
1352
+ }
1353
+ }
1354
+ if (this._chartType === "line") {
1355
+ let l = this._useGradient && n.length > 0 ? this._createGradient(n) : null;
1356
+ m.drawPath(this._drawingContext, n, l, this._configuration.price_line_color, 1);
1357
+ }
1358
+ if ((this._drawSimpleMovingAverage || this._drawBollingerBands) && m.drawPath(this._drawingContext, r, null, this._configuration.sma_line_color, 1), this._drawExponentialMovingAverage && m.drawPath(this._drawingContext, o, null, this._configuration.ema_line_color, 1), this._drawBollingerBands && (m.drawPath(this._drawingContext, h, null, this._configuration.bollinger_band_upper_line_color, 1), m.drawPath(this._drawingContext, _, null, this._configuration.bollinger_band_lower_line_color, 1)), this._marketPrice >= this._lowerPriceBound && this._marketPrice <= this._upperPriceBound) {
1359
+ let l = (this._priceChartDimensions.y + (1 - (this._marketPrice - this._lowerPriceBound) / this._priceBoundsSpan) * this._priceChartDimensions.height | 0) + 0.5;
1360
+ this._drawingContext.beginPath(), this._drawingContext.strokeStyle = this._configuration.market_price_line_color, this._drawingContext.lineWidth = 0.5, this._drawingContext.setLineDash([6, 4]), this._drawingContext.moveTo(this._priceChartDimensions.x, l), this._drawingContext.lineTo(this._priceChartDimensions.x + this._priceChartDimensions.width, l), this._drawingContext.stroke(), this._drawingContext.setLineDash([]);
1361
+ }
1362
+ }
1363
+ /**
1364
+ * Creates linear gradient from top to bottom
1365
+ * @param {Array.<[]>} pricePoints array of points
1366
+ */
1367
+ _createGradient(t) {
1368
+ const i = this._configuration.first_gradient_color, e = this._configuration.second_gradient_color, s = t.reduce((l, u) => u[1] > l ? u[1] : l, t[0][1]), a = t.reduce((l, u) => u[1] < l ? u[1] : l, t[0][1]), n = t.reduce((l, u) => u[0] > l ? u[0] : l, t[0][0]), r = n / 2, o = a, h = n / 2, _ = s;
1369
+ if (!isNaN(r) && !isNaN(o) && !isNaN(h) && !isNaN(_)) {
1370
+ const l = this._drawingContext.createLinearGradient(r, o, h, _);
1371
+ return l.addColorStop(0, i), l.addColorStop(1, e), l;
1372
+ }
1373
+ }
1374
+ /**
1375
+ * Performs of axis labels for this component - labels are only drawn with instruction from this
1376
+ * component and are drawwn on this._drawingContext - also draws Market Price
1377
+ *
1378
+ * @param {Boolean} force - Forces method to perform regardless of invalidation checks
1379
+ */
1380
+ _drawLabels(t) {
1381
+ if (this._data.hasData && (this.indicesInvalidated = this._computeIndices(), this.boundsInvalidated = this._computeBounds(), this._xLabels.minimum = this._data.getItemAt(this._drawStartIndex).timestamp, this._xLabels.maximum = this._data.getItemAt(this._drawEndIndex).timestamp, this._yLabels.minimum = this._lowerPriceBound, this._yLabels.maximum = this._upperPriceBound, super._drawLabels(t), this._useGridLines && this._drawGridLines(t), this._marketPrice >= this._lowerPriceBound && this._marketPrice <= this._upperPriceBound)) {
1382
+ const i = m.formatNumberToLocale(this._marketPrice, this._yLabels.precision), e = this._yLabelDimensions.y + (1 - (this._marketPrice - this._lowerPriceBound) / this._priceBoundsSpan) * this._yLabelDimensions.height | 0;
1383
+ this._drawingContext.fillStyle = this._configuration.market_price_background_color, this._drawingContext.fillRect(this._yLabelDimensions.x, e - this._fontSize * 0.75, this._yLabelDimensions.width, this._fontSize * 1.5), this._drawingContext.fillStyle = this._configuration.market_price_label_color, this._drawingContext.fillText("- " + d.configuration.currency_character + i, this._yLabelDimensions.x, e + this._fontSize / 4);
1384
+ }
1385
+ }
1386
+ /**
1387
+ * Draws grid lines based on x and y labels ticks
1388
+ *
1389
+ * @param {Boolean} force Forces method to perform regardless of invalidation checks
1390
+ */
1391
+ _drawGridLines(t) {
1392
+ const s = d.configuration.price_history.grid_lines_color, a = d.configuration.price_history.grid_lines_dashed ? [5, 3] : [];
1393
+ this._drawingContext.setLineDash(a), this._drawingContext.lineWidth = 1, this._drawingContext.beginPath(), this._yLabels.tickPoints.forEach((n) => {
1394
+ this._drawingContext.moveTo(this._xLabelDimensions.width, n - 2.5), this._drawingContext.lineTo(0, n - 2.5);
1395
+ }), this._xLabels.tickPoints.forEach((n) => {
1396
+ this._drawingContext.moveTo(n + 0.5, this._yLabelDimensions.y + this._yLabelDimensions.height), this._drawingContext.lineTo(n + 0.5, this._yLabelDimensions.y);
1397
+ }), this._drawingContext.strokeStyle = s, this._drawingContext.stroke(), this._drawingContext.setLineDash([]);
1398
+ }
1399
+ /**
1400
+ * Performs drawing of all borders for this component - borders are drawwn on this._drawingContext
1401
+ *
1402
+ * @param {Boolean} force - Forces method to perform regardless of invalidation checks
1403
+ *
1404
+ */
1405
+ _drawBorders(t) {
1406
+ super._drawBorders(t), this._drawingContext.fillStyle = this._configuration.border_secondary_color, this._drawingContext.fillRect(this._infoDimensions.x, this._infoDimensions.y + this._infoDimensions.height - 1, this._infoDimensions.width, 1), this._drawingContext.fillRect(this._xLabelDimensions.x, this._xLabelDimensions.y, this._xLabelDimensions.width, 1), this._drawingContext.fillRect(this._yLabelDimensions.x, this._yLabelDimensions.y, 1, this._yLabelDimensions.height);
1407
+ }
1408
+ /**
1409
+ * Computes and renders information for the item currently proximal to the pointer device
1410
+ *
1411
+ */
1412
+ _updateInfo(t) {
1413
+ let i = (this._mouseX - this._priceChartDimensions.x) / this._priceChartDimensions.width, e = this._drawEndIndex - this._drawStartIndex + 1, s = Math.floor(e * i);
1414
+ s = Math.min(Math.max(s, 0), e);
1415
+ let a = this._drawStartIndex + s, n = this._data.getItemAt(a), r = [];
1416
+ const o = m.formatNumberToLocale(this._marketPrice, this._configuration.info_precision);
1417
+ if (!n || t !== void 0)
1418
+ r = ['<label class="ac-price">' + this._infoLabels[0] + "</label> " + d.configuration.currency_character + o, "", "", "", "", ""];
1419
+ else {
1420
+ const h = m.formatNumberToLocale(n.open, this._configuration.info_precision), _ = m.formatNumberToLocale(n.close, this._configuration.info_precision), l = m.formatNumberToLocale(n.high, this._configuration.info_precision), u = m.formatNumberToLocale(n.low, this._configuration.info_precision), g = m.formatNumberToLocale(n.volume, this._configuration.info_precision), p = d.configuration.currency_character;
1421
+ r.push('<label class="ac-price">' + this._infoLabels[0] + "</label> " + p + o), r.push('<label class="ac-open">' + this._infoLabels[1] + "</label> " + p + h), r.push('<label class="ac-close">' + this._infoLabels[2] + "</label> " + p + _), r.push('<label class="ac-high">' + this._infoLabels[3] + "</label> " + p + l), r.push('<label class="ac-low">' + this._infoLabels[4] + "</label> " + p + u), r.push('<label class="ac-volume">' + this._infoLabels[5] + "</label> " + g);
1422
+ }
1423
+ if (this._infoElement.hasChildNodes()) {
1424
+ let h = this._infoElement.childNodes;
1425
+ for (let _ = 0; _ < h.length; _++)
1426
+ h[_].innerHTML = r[_];
1427
+ }
1428
+ }
1429
+ /**
1430
+ * Triggered when mouse pointer leaves the bounds of this._element - information component
1431
+ * is cleared
1432
+ *
1433
+ */
1434
+ _onMouseLeave(t) {
1435
+ super._onMouseLeave(t), t.target === this._element && this._updateInfo("");
1436
+ }
1437
+ /**
1438
+ * Triggered when mouse is pressed within the bounds of this._element - information component
1439
+ * is updated
1440
+ *
1441
+ */
1442
+ _onMouseDown(t) {
1443
+ super._onMouseDown(t), this._updateInfo();
1444
+ }
1445
+ /**
1446
+ * Triggered when mouse changes position within the bounds of this._element - if the user is
1447
+ * is dragging, information component is now updated
1448
+ *
1449
+ */
1450
+ _onMouseMove(t) {
1451
+ super._onMouseMove(t);
1452
+ const i = t.target.offsetParent && t.target.offsetParent.classList.contains("price-history");
1453
+ !this._mouseIsDown && i && this._updateInfo();
1454
+ }
1455
+ _unregisterListeners() {
1456
+ super._unregisterListeners();
1457
+ }
1458
+ get marketPrice() {
1459
+ return this._marketPrice;
1460
+ }
1461
+ set marketPrice(t) {
1462
+ this._marketPrice !== t && (this._marketPrice = t, this._updateInfo(), this._draw(!0));
1463
+ }
1464
+ get drawSimpleMovingAverage() {
1465
+ return this._drawSimpleMovingAverage;
1466
+ }
1467
+ set drawSimpleMovingAverage(t) {
1468
+ this._drawSimpleMovingAverage !== t && (this._drawSimpleMovingAverage = t, this._draw(!0));
1469
+ }
1470
+ get drawExponentialMovingAverage() {
1471
+ return this._drawExponentialMovingAverage;
1472
+ }
1473
+ set drawExponentialMovingAverage(t) {
1474
+ this._drawExponentialMovingAverage !== t && (this._drawExponentialMovingAverage = t, this._draw(!0));
1475
+ }
1476
+ get drawBollingerBands() {
1477
+ return this._drawBollingerBands;
1478
+ }
1479
+ set drawBollingerBands(t) {
1480
+ this._drawBollingerBands !== t && (this._drawBollingerBands = t, this._draw(!0));
1481
+ }
1482
+ get chartType() {
1483
+ return this._chartType;
1484
+ }
1485
+ set chartType(t) {
1486
+ this._chartType = t, this._draw(!0);
1487
+ }
1488
+ }
1489
+ class O extends B {
1490
+ /**
1491
+ * Instantiates the component and defines all private properties
1492
+ *
1493
+ * @param {HTMLElement} container
1494
+ * @param {HistoryData} data
1495
+ *
1496
+ */
1497
+ constructor(t, i) {
1498
+ super(t, i), this._upperVolumeBound = 0, this._configuration = Object.assign({}, d.configuration.volume_history), this._build(), this._registerListeners();
1499
+ }
1500
+ /**
1501
+ * Structures the component on the DOM sets axis labeling properties
1502
+ *
1503
+ */
1504
+ _build() {
1505
+ super._build(), this._element.classList.add("volume-history"), this._yLabels.type = v.NUMBER, this._yLabels.fontFace = this._fontFace, this._yLabels.fontSize = this._fontSize, this._yLabels.fontColor = this._configuration.y_label_color, this._yLabels.abbreviate = !0;
1506
+ }
1507
+ /**
1508
+ * Computes dimensions for chart, information section and axis labeling
1509
+ *
1510
+ */
1511
+ _computeDimensions() {
1512
+ super._computeDimensions(), this._draw();
1513
+ }
1514
+ /**
1515
+ * Computes the upper and lower bounds for all data points this chart component uses
1516
+ *
1517
+ * @return {Boolean} - whether or not bounds have changed
1518
+ *
1519
+ */
1520
+ _computeBounds() {
1521
+ super._computeBounds();
1522
+ let t = 0;
1523
+ for (let i = this._drawStartIndex; i < this._drawEndIndex; i++) {
1524
+ let e = this._data.getItemAt(i);
1525
+ e.volume > t && (t = e.volume);
1526
+ }
1527
+ return this._upperVolumeBound !== t ? (this._upperVolumeBound = t, !0) : !1;
1528
+ }
1529
+ /**
1530
+ * Draws a volume bar to this._drawingContext using an item from HistoryData
1531
+ *
1532
+ */
1533
+ _drawVolumeItem(t, i) {
1534
+ this._drawingContext.fillStyle = t.bullish ? this._configuration.bullish_color : this._configuration.bearish_color;
1535
+ let e = this._chartDimensions.y + (1 - t.volume / this._upperVolumeBound) * this._chartDimensions.height, s = this._chartDimensions.y + this._chartDimensions.height - e;
1536
+ this._drawingContext.fillRect(i, e, this._itemWidth, s);
1537
+ }
1538
+ /**
1539
+ * Performs bulk of work of drawing data visualization for this component - chart is drawn
1540
+ * on this._drawingContext - includes drawing chart items
1541
+ *
1542
+ * @param {Boolean} force - Forces method to perform regardless of invalidation checks
1543
+ *
1544
+ */
1545
+ _drawChart(t) {
1546
+ if (super._drawChart(t), !this._data.hasData)
1547
+ return;
1548
+ let i = this._computeIndices(), e = this._computeBounds();
1549
+ if (!t && !i && !e && !this._dimensionsInvalidated)
1550
+ return;
1551
+ let s = this._itemWidth + this._itemMargin, a = this._drawEndIndex - this._drawStartIndex, n = this._chartDimensions.width / s | 0, r = this._chartDimensions.x;
1552
+ n > a && (r += (n - a) * s | 0);
1553
+ for (let o = this._drawStartIndex; o < this._drawEndIndex; o++) {
1554
+ let h = this._data.getItemAt(o), _ = r + (o - this._drawStartIndex) * s;
1555
+ this._drawVolumeItem(h, _);
1556
+ }
1557
+ }
1558
+ /**
1559
+ * Performs of axis labels for this component - labels are only drawn with instruction from this
1560
+ * component and are drawwn on this._drawingContext
1561
+ *
1562
+ * @param {Boolean} force - Forces method to perform regardless of invalidation checks
1563
+ */
1564
+ _drawLabels(t) {
1565
+ this._data.hasData && (this._yLabels.minimum = 0, this._yLabels.maximum = this._upperVolumeBound, super._drawLabels(t));
1566
+ }
1567
+ /**
1568
+ * Performs drawing of all borders for this component - borders are drawwn on this._drawingContext
1569
+ *
1570
+ * @param {Boolean} force - Forces method to perform regardless of invalidation checks
1571
+ *
1572
+ */
1573
+ _drawBorders(t) {
1574
+ super._drawBorders(t), this._drawingContext.fillStyle = this._configuration.border_secondary_color, this._drawingContext.fillRect(this._yLabelDimensions.x, this._yLabelDimensions.y, 1, this._yLabelDimensions.height);
1575
+ }
1576
+ _unregisterListeners() {
1577
+ super._unregisterListeners();
1578
+ }
1579
+ }
1580
+ class U extends B {
1581
+ /**
1582
+ * Instantiates the component and defines all private properties
1583
+ *
1584
+ * @param {HTMLElement} container
1585
+ * @param {HistoryData} data
1586
+ *
1587
+ */
1588
+ constructor(t, i) {
1589
+ super(t, i), this._upperMACDBound = 0, this._configuration = Object.assign({}, d.configuration.macd_history), this._build(), this._registerListeners();
1590
+ }
1591
+ /**
1592
+ * Structures the component on the DOM sets axis labeling properties
1593
+ *
1594
+ */
1595
+ _build() {
1596
+ super._build(), this._element.classList.add("macd-history"), this._yLabels.type = v.NUMBER, this._yLabels.fontFace = this._fontFace, this._yLabels.fontSize = this._fontSize, this._yLabels.fontColor = this._configuration.y_label_color;
1597
+ }
1598
+ /**
1599
+ * Computes dimensions for chart, information section and axis labeling
1600
+ *
1601
+ */
1602
+ _computeDimensions() {
1603
+ super._computeDimensions(), this._draw();
1604
+ }
1605
+ /**
1606
+ * Computes the upper and lower bounds for all data points this chart component uses
1607
+ *
1608
+ * @return {Boolean} - whether or not bounds have changed
1609
+ *
1610
+ */
1611
+ _computeBounds() {
1612
+ let t = 0;
1613
+ for (let i = this._drawStartIndex; i < this._drawEndIndex; i++) {
1614
+ let e = this._data.getItemAt(i);
1615
+ Math.abs(e.macdIndicator) > t && (t = Math.abs(e.macdIndicator)), Math.abs(e.macdSignal) > t && (t = Math.abs(e.macdIndicator)), Math.abs(e.macdDisparity) > t && (t = Math.abs(e.macdDisparity));
1616
+ }
1617
+ return this._upperMACDBound !== t ? (this._upperMACDBound = t, !0) : !1;
1618
+ }
1619
+ /**
1620
+ * Draws a MACD bar to this._drawingContext using an item from HistoryData
1621
+ *
1622
+ */
1623
+ _drawMACD(t, i) {
1624
+ this._chartDimensions;
1625
+ let e = this._chartDimensions.y + this._chartDimensions.height / 2, s = Math.abs(t.macdDisparity) / this._upperMACDBound * (this._chartDimensions.height / 2);
1626
+ t.macdDisparity >= 0 ? (this._drawingContext.fillStyle = this._configuration.histogram_positive_color, e -= s) : this._drawingContext.fillStyle = this._configuration.histogram_negative_color, this._drawingContext.fillRect(i, e, this._itemWidth, s);
1627
+ }
1628
+ /**
1629
+ * Performs bulk of work of drawing data visualization for this component - chart is drawn
1630
+ * on this._drawingContext - includes drawing chart items
1631
+ *
1632
+ * @param {Boolean} force - Forces method to perform regardless of invalidation checks
1633
+ *
1634
+ */
1635
+ _drawChart(t) {
1636
+ if (super._drawChart(), !this._data.hasData)
1637
+ return;
1638
+ let i = this._computeIndices(), e = this._computeBounds();
1639
+ if (!t && !i && !e && !this._dimensionsInvalidated)
1640
+ return;
1641
+ let s = this._itemWidth + this._itemMargin, a = this._drawEndIndex - this._drawStartIndex, n = this._chartDimensions.width / s | 0, r = this._chartDimensions.x, o = [], h = [];
1642
+ n > a && (r += (n - a) * s | 0);
1643
+ for (let _ = this._drawStartIndex; _ < this._drawEndIndex; _++) {
1644
+ let l = this._data.getItemAt(_), u = r + (_ - this._drawStartIndex) * s, g = u + (this._itemWidth / 2 | 0), p = this._chartDimensions.y + (1 - (this._upperMACDBound + l.macdIndicator) / (this._upperMACDBound * 2)) * this._chartDimensions.height, f = this._chartDimensions.y + (1 - (this._upperMACDBound + l.macdSignal) / (this._upperMACDBound * 2)) * this._chartDimensions.height;
1645
+ o.push([g, p]), h.push([g, f]), this._drawMACD(l, u);
1646
+ }
1647
+ m.drawPath(this._drawingContext, o, null, this._configuration.indicator_line_color, 1), m.drawPath(this._drawingContext, h, null, this._configuration.signal_line_color, 1);
1648
+ }
1649
+ /**
1650
+ * Performs of axis labels for this component - labels are only drawn with instruction from this
1651
+ * component and are drawwn on this._drawingContext
1652
+ *
1653
+ * @param {Boolean} force - Forces method to perform regardless of invalidation checks
1654
+ */
1655
+ _drawLabels(t) {
1656
+ this._data.hasData && (this._yLabels.minimum = -this._upperMACDBound, this._yLabels.maximum = this._upperMACDBound, super._drawLabels(t));
1657
+ }
1658
+ /**
1659
+ * Performs drawing of all borders for this component - borders are drawwn on this._drawingContext
1660
+ *
1661
+ * @param {Boolean} force - Forces method to perform regardless of invalidation checks
1662
+ *
1663
+ */
1664
+ _drawBorders(t) {
1665
+ super._drawBorders(t), this._drawingContext.fillStyle = this._configuration.border_secondary_color, this._drawingContext.fillRect(this._yLabelDimensions.x, this._yLabelDimensions.y, 1, this._yLabelDimensions.height), this._drawingContext.fillStyle = this._configuration.zero_line_color, this._drawingContext.fillRect(this._chartDimensions.x, this._chartDimensions.y + this._chartDimensions.height / 2, this._chartDimensions.width, 1);
1666
+ }
1667
+ _unregisterListeners() {
1668
+ super._unregisterListeners();
1669
+ }
1670
+ }
1671
+ class X extends I {
1672
+ /**
1673
+ * Instantiates the component and defines all private properties
1674
+ *
1675
+ * @param {HTMLElement} container
1676
+ * @param {HistoryData} data
1677
+ *
1678
+ */
1679
+ constructor(t, i) {
1680
+ super(t), this._fullRangeCanvas = null, this._fullRangeContext = null, this._data = i, this._rangeStartIndex = 0, this._rangeEndIndex = 100, this._range = null, this._leftHandle = null, this._rightHandle = null, this._dragMode = null, this._dragStartIndex = 0, this._dragStartSpan = 0, this._configuration = Object.assign({}, d.configuration.range_selector), this._build(), this._registerListeners();
1681
+ }
1682
+ /**
1683
+ * Structures the component on the DOM, creates the information component and sets
1684
+ * axis labeling properties
1685
+ *
1686
+ */
1687
+ _build() {
1688
+ super._build(), this._element.classList.add("range-selector"), this._fullRangeCanvas = document.createElement("canvas"), this._fullRangeContext = this._fullRangeCanvas.getContext("2d", { antialias: !1, alpha: !1 }), this._fullRangeContext.imageSmoothingEnabled = !1, this._fullRangeContext.imageSmoothingQuality = "low", this._range = document.createElement("div"), this._range.classList.add("range"), this._range.style.cursor = "move", this._range.style.left = "-5000px", this._leftHandle = document.createElement("button"), this._leftHandle.classList.add("handle"), this._leftHandle.style.cursor = "col-resize", this._leftHandle.style.left = "-5000px", this._rightHandle = document.createElement("button"), this._rightHandle.classList.add("handle"), this._rightHandle.style.cursor = "col-resize", this._rightHandle.style.left = "-5000px", this._element.append(this._range), this._element.append(this._leftHandle), this._element.append(this._rightHandle), this._xLabels.type = v.DATETIME, this._xLabels.fontFace = this._fontFace, this._xLabels.fontSize = this._fontSize, this._xLabels.fontColor = this._configuration.x_label_color;
1689
+ }
1690
+ /**
1691
+ * Computes dimensions for chart, information section and axis labeling
1692
+ *
1693
+ */
1694
+ _computeDimensions() {
1695
+ super._computeDimensions(), this._draw();
1696
+ }
1697
+ /**
1698
+ * Draws full range of history chart, upon which the selected range is only
1699
+ * a portion
1700
+ *
1701
+ */
1702
+ _drawFullRange() {
1703
+ let t = this._data.length - 1;
1704
+ if (this._fullRangeCanvas.width = this._chartDimensions.width * 2, this._fullRangeCanvas.height = this._chartDimensions.height * 2, this._fullRangeContext.fillStyle = this._configuration.background_color, this._fullRangeContext.fillRect(0, 0, this._fullRangeCanvas.width, this._fullRangeCanvas.height), Math.max(this._fullRangeCanvas.width / t, 0.05), !!this._data.hasData) {
1705
+ this._fullRangeContext.strokeStyle = this._configuration.price_line_color, this._fullRangeContext.lineWidth = 1, this._fullRangeContext.beginPath();
1706
+ for (let i = 0; i < t; i++) {
1707
+ let e = this._data.getItemAt(i), s = i / t * this._fullRangeCanvas.width, a = ((1 - (e.close - this._data.lowerPriceBound) / this._data.priceBoundsSpan) * this._fullRangeCanvas.height | 0) + 0.5;
1708
+ i === 0 ? this._fullRangeContext.moveTo(s, a) : this._fullRangeContext.lineTo(s, a);
1709
+ }
1710
+ this._fullRangeContext.stroke();
1711
+ }
1712
+ }
1713
+ /**
1714
+ * Performs the drawing operation for the background of this component - background
1715
+ * is drawn on this._drawingContext - also triggers drawing of full range
1716
+ *
1717
+ * @param | force | Boolean - Forces method to perform regardless of invalidation checks
1718
+ *
1719
+ */
1720
+ _drawBackground(t) {
1721
+ super._drawBackground(t), this._dimensionsInvalidated && this._drawFullRange(), this._fullRangeCanvas.width && this._fullRangeCanvas.height && this._drawingContext.drawImage(this._fullRangeCanvas, 0, 0, this._chartDimensions.width, this._chartDimensions.height);
1722
+ }
1723
+ /**
1724
+ * Performs bulk of work of drawing data visualization for this component - chart is drawn
1725
+ * on this._drawingContext - includes positioning of selected range
1726
+ *
1727
+ * @param {Boolean} force - Forces method to perform regardless of invalidation checks
1728
+ */
1729
+ _drawChart(t) {
1730
+ if (super._drawChart(t), !this._data.hasData) {
1731
+ this._range.style.left = "-5000px", this._leftHandle.style.left = "-5000px", this._rightHandle.style.left = "-5000px";
1732
+ return;
1733
+ }
1734
+ let i = this._leftHandle.offsetWidth, e = this._leftHandle.offsetHeight, s = this._rangeStartIndex / (this._data.length - 1), a = this._rangeEndIndex / (this._data.length - 1), n = this._leftHandle.style;
1735
+ n.left = this._chartDimensions.x / this._pixelRatio + (s * (this._chartDimensions.width / this._pixelRatio) - i / 2) + "px", n.top = (this._chartDimensions.height / this._pixelRatio - e) / 2 + "px";
1736
+ let r = this._rightHandle.style;
1737
+ r.left = this._chartDimensions.x / this._pixelRatio + (a * (this._chartDimensions.width / this._pixelRatio) - i / 2) + "px", r.top = (this._chartDimensions.height / this._pixelRatio - e) / 2 + "px";
1738
+ let o = this._range.style;
1739
+ o.left = this._chartDimensions.x + s * (this._chartDimensions.width / this._pixelRatio) + "px", o.right = this._width / this._pixelRatio - (this._chartDimensions.x / this._pixelRatio + a * (this._chartDimensions.width / this._pixelRatio)) + "px", o.top = this._chartDimensions.y / this._pixelRatio + "px", o.height = this._chartDimensions.height / this._pixelRatio + "px";
1740
+ }
1741
+ /**
1742
+ * Performs of axis labels for this component - labels are only drawn with instruction from this
1743
+ * component and are drawwn on this._drawingContext
1744
+ *
1745
+ * @param {Boolean} force - Forces method to perform regardless of invalidation checks
1746
+ */
1747
+ _drawLabels(t) {
1748
+ this._data.hasData && (this._xLabels.minimum = this._data.getItemAt(0).timestamp, this._xLabels.maximum = this._data.getItemAt(this._data.length - 1).timestamp, super._drawLabels(t));
1749
+ }
1750
+ /**
1751
+ * Performs drawing of all borders for this component - borders are drawwn on this._drawingContext
1752
+ *
1753
+ * @param {Boolean} force - Forces method to perform regardless of invalidation checks
1754
+ *
1755
+ */
1756
+ _drawBorders(t) {
1757
+ super._drawBorders(t), this._drawingContext.fillStyle = this._configuration.border_secondary_color, this._drawingContext.fillRect(this._xLabelDimensions.x, this._xLabelDimensions.y, this._xLabelDimensions.width, 1);
1758
+ }
1759
+ /**
1760
+ * Initializes all event listener bindings for this component
1761
+ *
1762
+ */
1763
+ _registerListeners() {
1764
+ super._registerListeners(), this._data.addEventListener("parseComplete", () => {
1765
+ this._drawFullRange(), this._draw();
1766
+ });
1767
+ }
1768
+ _unregisterListeners() {
1769
+ super._unregisterListeners();
1770
+ }
1771
+ /**
1772
+ * Triggered when mouse pointer leaves the bounds of this._element - this instance
1773
+ * also triggers onMouseUp when the mouse leaves
1774
+ *
1775
+ */
1776
+ _onMouseLeave(t) {
1777
+ t.target === this._element && super._onMouseLeave(t);
1778
+ }
1779
+ /**
1780
+ * Triggered when drag operation starts
1781
+ *
1782
+ */
1783
+ _handleDragStart(t) {
1784
+ this._dragMode = t, this._dragStartIndex = this._rangeStartIndex, this._dragStartSpan = this._rangeEndIndex - this._rangeStartIndex;
1785
+ }
1786
+ /**
1787
+ * Triggered when drag operation proceeds
1788
+ *
1789
+ */
1790
+ _handleDrag() {
1791
+ if (this._mouseDragXDistance !== 0) {
1792
+ let t = this._mouseDragXDistance / this._chartDimensions.width, i = Math.abs(t) * (this._data.length - 1) | 0, e = this._rangeStartIndex, s = this._rangeEndIndex;
1793
+ this._mouseDragXDistance < 0 && (i = -i), this._dragMode === w.PAN ? (e = Math.min(Math.max(this._dragStartIndex + i, 0), this._data.length - 1 - this._dragStartSpan), s = e + this._dragStartSpan) : this._dragMode === w.RESIZE_LEFT ? e = Math.min(Math.max(this._dragStartIndex + i, 0), s) : this._dragMode === w.RESIZE_RIGHT && (s = Math.min(Math.max(this._dragStartIndex + this._dragStartSpan + i, e), this._data.length - 1)), (this._rangeStartIndex !== e || this._rangeEndIndex !== s) && (this._rangeStartIndex = e, this._rangeEndIndex = s, this._draw(), this._dragMode === w.PAN && this.dispatchEvent("rangeChanged", this._rangeStartIndex, this._rangeEndIndex));
1794
+ }
1795
+ }
1796
+ /**
1797
+ * Triggered when drag operation ends
1798
+ *
1799
+ */
1800
+ _handleDragEnd() {
1801
+ (this._dragMode === w.PAN || this._dragMode === w.RESIZE_LEFT || this._dragMode === w.RESIZE_RIGHT) && this.dispatchEvent("rangeChanged", this._rangeStartIndex, this._rangeEndIndex), this._dragMode = null;
1802
+ }
1803
+ _onMouseMove(t) {
1804
+ super._onMouseMove(t), this._mouseIsDown && this._handleDrag();
1805
+ }
1806
+ /**
1807
+ * Triggered when mouse is pressed within the bounds of this._element - drag mode is also determined
1808
+ *
1809
+ */
1810
+ _onMouseDown(t) {
1811
+ super._onMouseDown(t), t.target === this._leftHandle ? this._handleDragStart(w.RESIZE_LEFT) : t.target === this._rightHandle ? this._handleDragStart(w.RESIZE_RIGHT) : t.target === this._range && this._handleDragStart(w.PAN);
1812
+ }
1813
+ /**
1814
+ * Triggered when mouse is released within the bounds of this._containerElement
1815
+ *
1816
+ */
1817
+ _onMouseUp(t) {
1818
+ super._onMouseUp(t), this._handleDragEnd();
1819
+ }
1820
+ /**
1821
+ * Allow setting the range for this component by an external source, particularly
1822
+ * other history components that share the data this component uses
1823
+ *
1824
+ * @param {Number} startIndex
1825
+ * @param {Number} endIndex
1826
+ *
1827
+ */
1828
+ setRange(t, i) {
1829
+ this._rangeStartIndex = t, this._rangeEndIndex = i, this._draw();
1830
+ }
1831
+ get rangeStartIndex() {
1832
+ return this._rangeStartIndex;
1833
+ }
1834
+ get rangeEndIndex() {
1835
+ return this._rangeEndIndex;
1836
+ }
1837
+ }
1838
+ class G extends I {
1839
+ /**
1840
+ * Instantiates the component and defines all private properties
1841
+ *
1842
+ * @param {HTMLElement} container
1843
+ * @param {HistoryData} data
1844
+ *
1845
+ */
1846
+ constructor(t, i) {
1847
+ super(t), this._data = i, this._infoElement = null, this._marketPrice = 0, this._lowerPriceBound = Number.MAX_SAFE_INTEGER, this._upperPriceBound = 0, this._upperCountBound = 0, this._priceBoundsSpan = 0, this._configuration = Object.assign({}, d.configuration.order_book_depth), this._infoDimensions = new D(), this._depthChartDimensions = new D(), this._infoXOffset = -1, this._infoTargetPrice = -1, this._parseTimeout = null, this._build(), this._registerListeners();
1848
+ }
1849
+ /**
1850
+ * Structures the component on the DOM, creates the information component and sets
1851
+ * axis labeling properties
1852
+ *
1853
+ */
1854
+ _build() {
1855
+ super._build(), this._element.classList.add("order-book-depth"), this._infoElement = document.createElement("div"), this._infoElement.classList.add("info"), this._element.append(this._infoElement), this._xLabels.type = v.CURRENCY, this._xLabels.fontFace = this._fontFace, this._xLabels.fontSize = this._fontSize, this._xLabels.fontColor = this._configuration.x_label_color, this._xLabels.tickPrefix = "$", this._yLabels.type = v.NUMBER, this._yLabels.fontFace = this._fontFace, this._yLabels.fontSize = this._fontSize, this._yLabels.fontColor = this._configuration.y_label_color;
1856
+ }
1857
+ /**
1858
+ * Computes dimensions for chart, information section and axis labeling
1859
+ *
1860
+ */
1861
+ _computeDimensions() {
1862
+ super._computeDimensions(), this._configuration.info_height % 1 === 0 ? this._infoDimensions.height = this._configuration.info_height * this._pixelRatio : this._infoDimensions.height = this._chartDimensions.height * this._configuration.info_height | 0, this._infoDimensions.width = this._chartDimensions.width, this._infoDimensions.x = this._chartDimensions.x, this._infoDimensions.y = this._chartDimensions.y, this._depthChartDimensions.x = this._chartDimensions.x, this._depthChartDimensions.y = this._chartDimensions.y + this._infoDimensions.height, this._depthChartDimensions.width = this._chartDimensions.width, this._depthChartDimensions.height = this._chartDimensions.height - this._infoDimensions.height - 1;
1863
+ let t = this._infoElement.style;
1864
+ t.top = this._infoDimensions.y / this._pixelRatio + "px", t.left = this._infoDimensions.x / this._pixelRatio + "px", t.width = this._infoDimensions.width / this._pixelRatio + "px", t.height = this._infoDimensions.height / this._pixelRatio + "px", this._yLabelDimensions.y = this._depthChartDimensions.y, this._yLabelDimensions.height = this._depthChartDimensions.height, this._draw();
1865
+ }
1866
+ /**
1867
+ * Computes the upper and lower bounds for all data points this chart component uses
1868
+ *
1869
+ * @return {Boolean} - whether or not bounds have changed
1870
+ *
1871
+ */
1872
+ _computeBounds() {
1873
+ let t = Math.abs(this._marketPrice - this._data.lowerPriceBound), i = Math.abs(this._marketPrice - this._data.upperPriceBound), e = Math.max(t, i), s = this._marketPrice - e, a = this._marketPrice + e, n = this._data.upperCountBound;
1874
+ return this._lowerPriceBound !== s || this._upperPriceBound !== a || this._upperCountBound !== n ? (this._lowerPriceBound = s, this._upperPriceBound = a, this._upperCountBound = n, this._priceBoundsSpan = this._upperPriceBound - this._lowerPriceBound, !0) : !1;
1875
+ }
1876
+ /**
1877
+ * Performs bulk of work of drawing data visualization for this component - chart is drawn
1878
+ * on this._drawingContext - includes bid and ask order regions
1879
+ *
1880
+ * @param {Boolean} force - Forces method to perform regardless of invalidation checks
1881
+ */
1882
+ _drawChart(t) {
1883
+ if (super._drawChart(t), !this._data.hasData)
1884
+ return;
1885
+ let i = this._computeBounds();
1886
+ if (!t && !i && !this._dimensionsInvalidated)
1887
+ return;
1888
+ let e = (this._marketPrice - this._lowerPriceBound) / this._priceBoundsSpan, s = 1, a = this._depthChartDimensions.x + (this._depthChartDimensions.width * e | 0), n = this._depthChartDimensions.y + (this._depthChartDimensions.height * s | 0), r = [[a, n]];
1889
+ for (let g of this._data.askData) {
1890
+ if (g.price > this._upperPriceBound)
1891
+ break;
1892
+ e = (g.price - this._lowerPriceBound) / this._priceBoundsSpan, s = 1 - g.cumulativeCount / this._upperCountBound, a = this._depthChartDimensions.x + (this._depthChartDimensions.width * e | 0), n = this._depthChartDimensions.y + (this._depthChartDimensions.height * s | 0), r.push([a, n]);
1893
+ }
1894
+ a < this._depthChartDimensions.x + this._depthChartDimensions.width && r.push([this._depthChartDimensions.x + this._depthChartDimensions.width, n]), r.push([this._depthChartDimensions.x + this._depthChartDimensions.width, this._depthChartDimensions.y + this._depthChartDimensions.height]), r.push([r[0][0], this._depthChartDimensions.y + this._depthChartDimensions.height]);
1895
+ let o = (this._marketPrice - this._lowerPriceBound) / this._priceBoundsSpan, h = 1, _ = this._depthChartDimensions.x + (this._depthChartDimensions.width * o | 0), l = this._depthChartDimensions.y + (this._depthChartDimensions.height * h | 0), u = [[_, l]];
1896
+ for (let g of this._data.bidData) {
1897
+ if (g.price < this._lowerPriceBound)
1898
+ break;
1899
+ o = (g.price - this._lowerPriceBound) / this._priceBoundsSpan, h = 1 - g.cumulativeCount / this._upperCountBound, _ = this._depthChartDimensions.x + (this._depthChartDimensions.width * o | 0), l = this._depthChartDimensions.y + (this._depthChartDimensions.height * h | 0), u.push([_, l]);
1900
+ }
1901
+ _ > this._depthChartDimensions.x && u.push([this._depthChartDimensions.x, l]), u.push([this._depthChartDimensions.x, this._depthChartDimensions.y + this._depthChartDimensions.height]), u.push([u[0][0], this._depthChartDimensions.y + this._depthChartDimensions.height]), m.drawPath(this._drawingContext, r, this._configuration.ask_fill_color, this._configuration.ask_line_color, 1), m.drawPath(this._drawingContext, u, this._configuration.bid_fill_color, this._configuration.bid_line_color, 1);
1902
+ }
1903
+ /**
1904
+ * Performs of axis labels for this component - labels are only drawn with instruction from this
1905
+ * component and are drawwn on this._drawingContext - also draws Market Price
1906
+ *
1907
+ * @param {Boolean} force - Forces method to perform regardless of invalidation checks
1908
+ */
1909
+ _drawLabels(t) {
1910
+ if (!this._data.hasData)
1911
+ return;
1912
+ this._xLabels.minimum = this._lowerPriceBound, this._xLabels.maximum = this._upperPriceBound, this._yLabels.minimum = 0, this._yLabels.maximum = this._upperCountBound, super._drawLabels(t);
1913
+ let i = (this._marketPrice - this._lowerPriceBound) / this._priceBoundsSpan, e = this._depthChartDimensions.x + (i * this._depthChartDimensions.width | 0), s = this._marketPrice;
1914
+ s % 1 !== 0 && (s = s.toFixed(this._configuration.x_label_precision)), s = d.configuration.currency_character + s;
1915
+ let a = this._drawingContext.measureText(s).width / 2 | 0;
1916
+ this._drawingContext.fillStyle = this._configuration.market_price_color, this._drawingContext.fillText(s, e - a, this._infoDimensions.height + this._fontSize + 4), this._drawingContext.fillRect(e, this._infoDimensions.height + this._fontSize * 2, 1, this._depthChartDimensions.height - this._fontSize * 2);
1917
+ }
1918
+ /**
1919
+ * Performs drawing of all borders for this component - borders are drawwn on this._drawingContext
1920
+ *
1921
+ * @param {Boolean} force - Forces method to perform regardless of invalidation checks
1922
+ *
1923
+ */
1924
+ _drawBorders() {
1925
+ super._drawBorders(), this._drawingContext.fillStyle = this._configuration.border_secondary_color, this._drawingContext.fillRect(this._infoDimensions.x, this._infoDimensions.y + this._infoDimensions.height - 1, this._infoDimensions.width, 1), this._drawingContext.fillRect(this._xLabelDimensions.x, this._xLabelDimensions.y, this._xLabelDimensions.width, 1), this._drawingContext.fillRect(this._yLabelDimensions.x, this._yLabelDimensions.y, 1, this._yLabelDimensions.height);
1926
+ }
1927
+ /**
1928
+ * Computes and renders information for the price point currently proximal to the pointer device
1929
+ *
1930
+ */
1931
+ _updateInfo(t) {
1932
+ let i = this._infoXOffset / this._depthChartDimensions.width, e = this._lowerPriceBound + i * this._priceBoundsSpan, s;
1933
+ if (this._infoTargetPrice !== e) {
1934
+ let a = null;
1935
+ if (i < 0.5 ? (s = "bid", a = this._data.getClosestItem("bid", e)) : (s = "ask", a = this._data.getClosestItem("ask", e)), a) {
1936
+ let n = m.formatUSD(a.cumulativeCost / a.cumulativeCount, this._configuration.info_precision), r = a.cumulativeCount;
1937
+ r % 1 !== 0 && (r = r.toFixed(this._configuration.info_precision));
1938
+ let o = m.formatUSD(a.cumulativeCost, this._configuration.info_precision);
1939
+ this._infoElement.innerHTML = "<em>avg:&nbsp;</em><strong>" + d.configuration.currency_character + n + "</strong>&nbsp;-&nbsp;<em>" + (s === "bid" ? "sell" : "buy") + ":&nbsp;</em><strong>" + r + "</strong><em>&nbsp;for:&nbsp;</em><strong>" + d.configuration.currency_character + o + "</strong>";
1940
+ }
1941
+ }
1942
+ }
1943
+ /**
1944
+ * Initializes all event listener bindings for this component
1945
+ *
1946
+ */
1947
+ _registerListeners() {
1948
+ super._registerListeners(), this._data.addEventListener("parseComplete", () => {
1949
+ this._draw(!0);
1950
+ }), this._data.addEventListener("addComplete", () => {
1951
+ this._parseTimeout === null && (this._parseTimeout = setTimeout(() => {
1952
+ this._draw(!0), this._parseTimeout = null;
1953
+ }, 1e3));
1954
+ });
1955
+ }
1956
+ _unregisterListeners() {
1957
+ super._unregisterListeners();
1958
+ }
1959
+ /**
1960
+ * Triggered when mouse changes position within the bounds of this._element
1961
+ * information component is updated - used to update info for touch devices
1962
+ *
1963
+ */
1964
+ _onMouseMove(t) {
1965
+ super._onMouseMove(t);
1966
+ let i = this._mouseX - this._depthChartDimensions.x;
1967
+ this._infoXOffset !== i && (this._infoXOffset = this._mouseX - this._depthChartDimensions.x, this._updateInfo());
1968
+ }
1969
+ /**
1970
+ * Triggered when mouse is pressed within the bounds of this._element - used to update info for
1971
+ * touch devices
1972
+ *
1973
+ */
1974
+ _onMouseDown(t) {
1975
+ super._onMouseMove(t);
1976
+ let i = this._mouseX - this._depthChartDimensions.x;
1977
+ this._infoXOffset !== i && (this._infoXOffset = this._mouseX - this._depthChartDimensions.x, this._updateInfo());
1978
+ }
1979
+ get marketPrice() {
1980
+ return this._marketPrice;
1981
+ }
1982
+ set marketPrice(t) {
1983
+ this._marketPrice = t, this._draw(!0);
1984
+ }
1985
+ }
1986
+ class d extends b {
1987
+ constructor(t, i) {
1988
+ super(), this._configuration = null, this._containerElement = document.createElement("div"), this._containerElement.id = "apex-chart-container", t.append(this._containerElement), this._loadingElement = null, this._noChartDataElement = null, this._controlsElement = null, this._chartsElement = null, this._width = 0, this._height = 0, this._historyData = null, this._orderBookData = null, this._priceHistory = null, this._volumeHistory = null, this._macdHistory = null, this._rangeSelector = null, this._orderBookDepth = null, this._marketPrice = 0, this._loadConfiguration(i), this.setNoChartData(!0);
1989
+ }
1990
+ _loadConfiguration(t) {
1991
+ d.configuration = t, this._configuration = t, this._initialize(), this.dispatchEvent("configurationLoaded");
1992
+ }
1993
+ _initialize() {
1994
+ this._initializeData(), this._build(), this._registerListeners();
1995
+ }
1996
+ _initializeData() {
1997
+ this._historyData = new R(), this._orderBookData = new H();
1998
+ }
1999
+ /*
2000
+ // BEGIN: Building
2001
+ */
2002
+ _build() {
2003
+ this._loadingElement = document.createElement("div"), this._loadingElement.classList.add("loading"), this._containerElement.append(this._loadingElement), this._loadingElement.innerText = this._configuration.loading_text, this._noChartDataElement = document.createElement("div"), this._noChartDataElement.classList.add("no-chart-data"), this._containerElement.append(this._noChartDataElement), this._noChartDataElement.innerText = "⦸ No Chart data", this._controlsElement = document.createElement("div"), this._controlsElement.classList.add("controls"), this._containerElement.append(this._controlsElement), this._chartsElement = document.createElement("div"), this._chartsElement.classList.add("charts"), this._containerElement.append(this._chartsElement), this._chartControls = new N(this._controlsElement), this._priceHistory = new F(this._chartsElement, this._historyData), this._volumeHistory = new O(this._chartsElement, this._historyData), this._macdHistory = new U(this._chartsElement, this._historyData), this._rangeSelector = new X(this._chartsElement, this._historyData), this._orderBookDepth = new G(this._chartsElement, this._orderBookData), setTimeout(() => this._layout(), 100);
2004
+ }
2005
+ /*
2006
+ // END: Building
2007
+ */
2008
+ /*
2009
+ // BEGIN: Remove Element
2010
+ */
2011
+ _removeChartElement() {
2012
+ this._containerElement.remove(), this._unregisterListeners();
2013
+ }
2014
+ /*
2015
+ // END: Remove Element
2016
+ */
2017
+ /*
2018
+ // BEGIN: Layout
2019
+ */
2020
+ _layout() {
2021
+ this._width = this._containerElement.offsetWidth, this._height = this._containerElement.offsetHeight, this._priceHistory.invalidateDimensions(), this._volumeHistory.invalidateDimensions(), this._macdHistory.invalidateDimensions(), this._rangeSelector.invalidateDimensions(), this._orderBookDepth.invalidateDimensions();
2022
+ }
2023
+ /*
2024
+ // END: Layout
2025
+ */
2026
+ /*
2027
+ // BEGIN: Event Listeners
2028
+ */
2029
+ _registerListeners() {
2030
+ this._onResize = m.debounce(this, function() {
2031
+ (this._width !== this._containerElement.offsetWidth || this._height !== this._containerElement.offsetHeight) && this._layout();
2032
+ }, 1e3 / d.configuration.max_fps), window.addEventListener("resize", this._onResize, !0), this._chartControls.addEventListener("stateChanged", () => {
2033
+ this._onControlStateChange();
2034
+ }), this._priceHistory.addEventListener("indicesChanged", (t, i) => {
2035
+ this._volumeHistory.setIndices(t, i), this._macdHistory.setIndices(t, i), this._rangeSelector.setRange(t, i);
2036
+ }), this._volumeHistory.addEventListener("indicesChanged", (t, i) => {
2037
+ this._priceHistory.setIndices(t, i), this._macdHistory.setIndices(t, i), this._rangeSelector.setRange(t, i);
2038
+ }), this._macdHistory.addEventListener("indicesChanged", (t, i) => {
2039
+ this._priceHistory.setIndices(t, i), this._volumeHistory.setIndices(t, i), this._rangeSelector.setRange(t, i);
2040
+ }), this._rangeSelector.addEventListener("rangeChanged", (t, i) => {
2041
+ this._priceHistory.setIndices(t, i), this._volumeHistory.setIndices(t, i), this._macdHistory.setIndices(t, i);
2042
+ });
2043
+ }
2044
+ _unregisterListeners() {
2045
+ window.removeEventListener("resize", this._onResize, !0), this._rangeSelector._unregisterListeners(), this._priceHistory._unregisterListeners(), this._volumeHistory._unregisterListeners(), this._macdHistory._unregisterListeners(), this._rangeSelector._unregisterListeners(), this._orderBookDepth._unregisterListeners();
2046
+ }
2047
+ /*
2048
+ // END: Event Listeners
2049
+ */
2050
+ /*
2051
+ // BEGIN: Register Data APIS
2052
+ */
2053
+ registerAPI(t) {
2054
+ t.addEventListener("historyDataLoad", (i) => {
2055
+ this._chartControls.historyInterval = t.interval, this._historyData.parse(t.interval, i), this.setLoadingState(!1), this.setNoChartData(i.length === 0);
2056
+ }), t.addEventListener("loadingStateChanged", (i) => {
2057
+ this.setLoadingState(i);
2058
+ }), t.addEventListener("historyDataUpdate", (i) => {
2059
+ }), t.addEventListener("orderBookDataLoad", (i) => {
2060
+ this._orderBookData.parse(i);
2061
+ }), t.addEventListener("orderBookDataUpdate", (i, e, s) => {
2062
+ this._orderBookData.add(i, e, s);
2063
+ }), t.addEventListener("marketPriceDataUpdate", (i) => {
2064
+ this.marketPrice = i;
2065
+ });
2066
+ }
2067
+ /*
2068
+ // END: Register Data APIS
2069
+ */
2070
+ _onControlStateChange() {
2071
+ this._priceHistory.interval !== this._chartControls.historyInterval && this.dispatchEvent("historyIntervalChange", this._chartControls.historyInterval), this._priceHistory.drawSimpleMovingAverage !== this._chartControls.drawSimpleMovingAverage && (this._priceHistory.drawSimpleMovingAverage = this._chartControls.drawSimpleMovingAverage), this._priceHistory.drawExponentialMovingAverage !== this._chartControls.drawExponentialMovingAverage && (this._priceHistory.drawExponentialMovingAverage = this._chartControls.drawExponentialMovingAverage), this._priceHistory.drawBollingerBands !== this._chartControls.drawBollingerBands && (this._priceHistory.drawBollingerBands = this._chartControls.drawBollingerBands), this._priceHistory.chartType !== this._chartControls.chartType && (this._priceHistory.chartType = this._chartControls.chartType);
2072
+ }
2073
+ setLoadingState(t) {
2074
+ t ? (this._containerElement.style.pointerEvents = "none", this._loadingElement.style.opacity = "1") : (this._containerElement.style.pointerEvents = "", this._loadingElement.style.opacity = "0");
2075
+ }
2076
+ setNoChartData(t) {
2077
+ t ? (this._containerElement.style.pointerEvents = "none", this._noChartDataElement.style.opacity = "1") : (this._containerElement.style.pointerEvents = "", this._noChartDataElement.style.opacity = "0");
2078
+ }
2079
+ get configuration() {
2080
+ return this._configuration;
2081
+ }
2082
+ get marketPrice() {
2083
+ return this._marketPrice;
2084
+ }
2085
+ set marketPrice(t) {
2086
+ this._marketPrice = t, this._priceHistory && (this._priceHistory.marketPrice = t), this._orderBookDepth && (this._orderBookDepth.marketPrice = t);
2087
+ }
2088
+ }
2089
+ class W extends b {
2090
+ /* PRIVATE PROPERTIES
2091
+ //
2092
+ this._uri
2093
+ this._socket
2094
+ //
2095
+ */
2096
+ constructor() {
2097
+ super(), this._socket = null, this._uri = null;
2098
+ }
2099
+ connect(t) {
2100
+ this._uri = t, this._socket = new WebSocket(this._uri), this._socket.onopen = (i) => {
2101
+ this.onOpen(i);
2102
+ }, this._socket.onmessage = (i) => {
2103
+ this.onMessage(i);
2104
+ }, this._socket.onerror = (i) => {
2105
+ this.onError(i);
2106
+ }, this._socket.onclose = (i) => {
2107
+ this.onClose(i);
2108
+ };
2109
+ }
2110
+ send(t) {
2111
+ this._socket.send(t);
2112
+ }
2113
+ disconnect() {
2114
+ this._socket.onopen = null, this._socket.onmessage = null, this._socket.onerror = null, this._socket.onclose = null, this._socket.close();
2115
+ }
2116
+ onMessage(t) {
2117
+ }
2118
+ onOpen(t) {
2119
+ }
2120
+ onError(t) {
2121
+ }
2122
+ onClose(t) {
2123
+ }
2124
+ get connected() {
2125
+ return !!(this._socket && this._socket.readyState === 1);
2126
+ }
2127
+ get bufferedAmount() {
2128
+ return this._socket ? this._socket.bufferedAmount : 0;
2129
+ }
2130
+ }
2131
+ class z extends W {
2132
+ constructor() {
2133
+ super(), this._uri = d.configuration.alphapoint_api.uri, this._instrumentId = d.configuration.instrument_id, this._orderBookDepthCount = d.configuration.defaults.order_book_depth_count, this._interval = d.configuration.defaults.history_interval, this._marketPrice = 0;
2134
+ }
2135
+ connect() {
2136
+ super.connect(this._uri);
2137
+ }
2138
+ send(t) {
2139
+ t = JSON.stringify(t), super.send(t);
2140
+ }
2141
+ disconnect() {
2142
+ super.disconnect();
2143
+ }
2144
+ onMessage(t) {
2145
+ super.onMessage(t);
2146
+ let i;
2147
+ try {
2148
+ i = JSON.parse(t.data), i.n === "SubscribeTicker" ? this._onPriceVolumeHistoryLoad(JSON.parse(i.o)) : i.n === "SubscribeLevel1" || i.n === "Level1UpdateEvent" ? this._onMarketPriceLoad(JSON.parse(i.o)) : i.n === "SubscribeLevel2" ? this._onOrderBookDataLoad(JSON.parse(i.o)) : i.n === "Level2UpdateEvent" && this._onOrderBookDataUpdate(JSON.parse(i.o));
2149
+ } catch (e) {
2150
+ console.log(e);
2151
+ return;
2152
+ }
2153
+ }
2154
+ onOpen(t) {
2155
+ super.onOpen(t), this.subscribeToPriceVolumeHistory(), this.subscribeToOrderBookDepth();
2156
+ }
2157
+ onError(t) {
2158
+ super.onError(t);
2159
+ }
2160
+ onClose(t) {
2161
+ super.onClose(t);
2162
+ }
2163
+ /*
2164
+ subscribeToMarketPrice(){
2165
+ let payload = {
2166
+ m: 1,
2167
+ i: 0,
2168
+ n: "SubscribeLevel1",
2169
+ o: "{\"OMSId\":1,\"InstrumentId\":1}"
2170
+ }
2171
+ this.send(payload);
2172
+ }
2173
+
2174
+ unsubscribeFromMarketPrice(){
2175
+ }
2176
+ */
2177
+ subscribeToPriceVolumeHistory() {
2178
+ let t = {
2179
+ m: 0,
2180
+ i: 6,
2181
+ n: "SubscribeTicker",
2182
+ o: `{"OMSId":1,"InstrumentId":${this._instrumentId},"Interval":${this._interval},"IncludeLastCount":1000}`
2183
+ };
2184
+ this.send(t);
2185
+ }
2186
+ unsubscribeFromPriceVolumeHistory() {
2187
+ let t = {
2188
+ m: 0,
2189
+ i: 8,
2190
+ n: "UnsubscribeTicker",
2191
+ o: `{"OMSId":1,"InstrumentId":${this._instrumentId}}`
2192
+ };
2193
+ this.send(t);
2194
+ }
2195
+ subscribeToOrderBookDepth() {
2196
+ let t = {
2197
+ m: 0,
2198
+ i: 6,
2199
+ n: "SubscribeLevel2",
2200
+ o: `{"OMSId":1,"InstrumentId":${this._instrumentId},"Depth":${this._orderBookDepthCount}}`
2201
+ };
2202
+ this.send(t);
2203
+ }
2204
+ unsubscribeFromOrderBookDepth() {
2205
+ let t = {
2206
+ m: 0,
2207
+ i: 8,
2208
+ n: "UnubscribeLevel2",
2209
+ o: `{"OMSId":1,"InstrumentId":${this._instrumentId}}`
2210
+ };
2211
+ this.send(t);
2212
+ }
2213
+ _onMarketPriceLoad(t) {
2214
+ this._marketPrice !== t && (this._marketPrice = t, this.dispatchEvent("marketPriceDataUpdate", t));
2215
+ }
2216
+ _onPriceVolumeHistoryLoad(t) {
2217
+ let i = [];
2218
+ t.forEach((e) => {
2219
+ i.push([parseInt(e[0], 10) / 1e3 | 0, parseFloat(e[3]), parseFloat(e[4]), parseFloat(e[1]), parseFloat(e[2]), parseFloat(e[5])]);
2220
+ }), this.dispatchEvent("historyDataLoad", i);
2221
+ }
2222
+ _onOrderBookDataLoad(t) {
2223
+ let i = { asks: [], bids: [] };
2224
+ t.forEach((e) => {
2225
+ e[9] === 1 ? i.asks.push([e[6], e[5]]) : e[9] === 0 && i.bids.push([e[6], e[5]]), this._onMarketPriceLoad(e[4]);
2226
+ }), this.dispatchEvent("orderBookDataLoad", i);
2227
+ }
2228
+ _onOrderBookDataUpdate(t) {
2229
+ t.forEach((i) => {
2230
+ i[9] === 1 ? this.dispatchEvent("orderBookDataUpdate", "ask", i[6], i[5]) : i[9] === 0 && this.dispatchEvent("orderBookDataUpdate", "bid", i[6], i[5]), this._onMarketPriceLoad(i[4]);
2231
+ });
2232
+ }
2233
+ get interval() {
2234
+ return this._interval;
2235
+ }
2236
+ set interval(t) {
2237
+ this._interval !== t && (this._interval = t, this.unsubscribeFromPriceVolumeHistory(), setTimeout(() => this.subscribeToPriceVolumeHistory(), 250));
2238
+ }
2239
+ /*
2240
+ get orderbookDepthCount(){
2241
+ return this._orderbookDepthCount;
2242
+ }
2243
+
2244
+ set interval(c){
2245
+ if(this._orderbookDepthCount !== c){
2246
+ this._orderbookDepthCount = c;
2247
+
2248
+ this.unsubscribeFromOrderbookDepth();
2249
+ setTimeout(() => this.subscribeToOrderbookDepth(), 250);
2250
+ }
2251
+ }
2252
+ */
2253
+ }
2254
+ class V extends b {
2255
+ constructor(t, i) {
2256
+ super(), this.initialChartData = t, this._changeTickersInterval = i, this._interval = d.configuration.defaults.history_interval;
2257
+ }
2258
+ connect() {
2259
+ this.UpdateLevel2Data(this.initialChartData.level2), this.UpdateTickersData(this.initialChartData.tickers.tickers), this.OnLoadingStateChange(this.initialChartData.tickers.fetching), this.UpdateMarketPrice(this.initialChartData.marketPrice);
2260
+ }
2261
+ disconnect() {
2262
+ }
2263
+ UpdateLevel2Data(t) {
2264
+ const i = {};
2265
+ i.asks = t.sell.map((e) => [e.Price, e.NumberOfOrders]), i.bids = t.buy.map((e) => [e.Price, e.NumberOfOrders]), this.dispatchEvent("orderBookDataLoad", i);
2266
+ }
2267
+ UpdateTickersData(t) {
2268
+ let i = [];
2269
+ t.forEach((e) => {
2270
+ i.push([parseInt(e[0], 10) / 1e3 | 0, parseFloat(e[3]), parseFloat(e[4]), parseFloat(e[1]), parseFloat(e[2]), parseFloat(e[5])]);
2271
+ }), this.dispatchEvent("historyDataLoad", i);
2272
+ }
2273
+ OnLoadingStateChange(t) {
2274
+ this.dispatchEvent("loadingStateChanged", t);
2275
+ }
2276
+ UpdateMarketPrice(t) {
2277
+ this.dispatchEvent("marketPriceDataUpdate", t);
2278
+ }
2279
+ get interval() {
2280
+ return this._interval;
2281
+ }
2282
+ set interval(t) {
2283
+ this._interval !== t && (this._interval = t, this._changeTickersInterval(this._interval));
2284
+ }
2285
+ }
2286
+ function Y(c, t) {
2287
+ return c === t;
2288
+ }
2289
+ function y(c, t, i, e = Y) {
2290
+ let s = t(c.getState());
2291
+ return i(s), c.subscribe(() => {
2292
+ const n = t(c.getState());
2293
+ if (!e(s, n)) {
2294
+ const r = s;
2295
+ s = n, i(n, r);
2296
+ }
2297
+ });
2298
+ }
2299
+ const j = (c) => c.tickers.fetching, Z = (c) => c.tickers.tickers, J = (c) => c.level2, $ = (c) => {
2300
+ const { selectedInstrumentId: t } = c.instrument;
2301
+ return !t || !c.level1[t] ? 0 : c.level1[t].LastTradedPx;
2302
+ };
2303
+ class Q extends b {
2304
+ constructor(t, i) {
2305
+ super(), this._store = t, this._changeTickersInterval = i, this._interval = d.configuration.defaults.history_interval, this._marketPrice = 0;
2306
+ }
2307
+ connect() {
2308
+ this.subscribeToPriceVolumeHistory(), this.subscribeToOrderBookDepth(), this.subscribeToMarketPrice(), this.subscribeToLoadingState();
2309
+ }
2310
+ disconnect() {
2311
+ this.unsubscribePriceVolume(), this.unsubscribePriceVolume = null, this.unsubscribeOrderBook(), this.unsubscribeOrderBook = null, this.unsubscribeMarketPrice(), this.unsubscribeMarketPrice = null, this.unsubscribeToLoadingState(), this.unsubscribeToLoadingState = null;
2312
+ }
2313
+ subscribeToPriceVolumeHistory() {
2314
+ this.unsubscribePriceVolume = y(this._store, Z, (t, i) => {
2315
+ this._onPriceVolumeHistoryLoad(t);
2316
+ });
2317
+ }
2318
+ subscribeToLoadingState() {
2319
+ this.unsubscribeToLoadingState = y(this._store, j, (t, i) => {
2320
+ this._onLoadingStateChanged(t);
2321
+ });
2322
+ }
2323
+ subscribeToOrderBookDepth() {
2324
+ this.unsubscribeOrderBook = y(this._store, J, (t, i) => {
2325
+ this._onOrderBookDataLoad(t);
2326
+ });
2327
+ }
2328
+ subscribeToMarketPrice() {
2329
+ this.unsubscribeMarketPrice = y(this._store, $, (t, i) => {
2330
+ this._onMarketPriceLoad(t);
2331
+ });
2332
+ }
2333
+ _onPriceVolumeHistoryLoad(t) {
2334
+ let i = [];
2335
+ t.forEach((e) => {
2336
+ i.push([parseInt(e[0], 10) / 1e3 | 0, parseFloat(e[3]), parseFloat(e[4]), parseFloat(e[1]), parseFloat(e[2]), parseFloat(e[5])]);
2337
+ }), this.dispatchEvent("historyDataLoad", i);
2338
+ }
2339
+ _onOrderBookDataLoad(t) {
2340
+ const i = {};
2341
+ i.asks = t.sell.map((e) => [e.Price, e.NumberOfOrders]), i.bids = t.buy.map((e) => [e.Price, e.NumberOfOrders]), this.dispatchEvent("orderBookDataLoad", i);
2342
+ }
2343
+ _onMarketPriceLoad(t) {
2344
+ this._marketPrice !== t && (this._marketPrice = t, this.dispatchEvent("marketPriceDataUpdate", t));
2345
+ }
2346
+ _onLoadingStateChanged(t) {
2347
+ this.dispatchEvent("loadingStateChanged", t);
2348
+ }
2349
+ get interval() {
2350
+ return this._interval;
2351
+ }
2352
+ set interval(t) {
2353
+ this._interval !== t && (this._interval = t, this._changeTickersInterval(this._interval));
2354
+ }
2355
+ }
2356
+ class q extends b {
2357
+ constructor(t, i) {
2358
+ super(), this.subject = t, this._changeTickersInterval = i, this._interval = d.configuration.defaults.history_interval, this.level2 = {}, this.tickers = {}, this.fetching = !0, this.marketPrice = 0;
2359
+ }
2360
+ connect() {
2361
+ this.subject.subscribe((t) => {
2362
+ this.level2 !== t.level2 && (this.level2 = t.level2, this.UpdateLevel2Data(t.level2)), this.tickers !== t.tickers.tickers && (this.tickers = t.tickers.tickers, this.UpdateTickersData(t.tickers.tickers)), this.fetching !== t.tickers.fetching && (this.fetching = t.tickers.fetching, this.OnLoadingStateChange(t.tickers.fetching)), this.marketPrice !== t.marketPrice && this.UpdateMarketPrice(t.marketPrice);
2363
+ });
2364
+ }
2365
+ disconnect() {
2366
+ this.subject.unsubscribe();
2367
+ }
2368
+ UpdateLevel2Data(t) {
2369
+ const i = {};
2370
+ i.asks = t.sell.map((e) => [e.Price, e.NumberOfOrders]), i.bids = t.buy.map((e) => [e.Price, e.NumberOfOrders]), this.dispatchEvent("orderBookDataLoad", i);
2371
+ }
2372
+ UpdateTickersData(t) {
2373
+ let i = [];
2374
+ t.forEach((e) => {
2375
+ i.push([parseInt(e[0], 10) / 1e3 | 0, parseFloat(e[3]), parseFloat(e[4]), parseFloat(e[1]), parseFloat(e[2]), parseFloat(e[5])]);
2376
+ }), this.dispatchEvent("historyDataLoad", i);
2377
+ }
2378
+ OnLoadingStateChange(t) {
2379
+ this.dispatchEvent("loadingStateChanged", t);
2380
+ }
2381
+ UpdateMarketPrice(t) {
2382
+ this.marketPrice = t, this.dispatchEvent("marketPriceDataUpdate", t);
2383
+ }
2384
+ get interval() {
2385
+ return this._interval;
2386
+ }
2387
+ set interval(t) {
2388
+ this._interval !== t && (this._interval = t, this._changeTickersInterval(this._interval));
2389
+ }
2390
+ }
2391
+ const K = {
2392
+ instrument_id: 1,
2393
+ max_fps: 60,
2394
+ snap_mouse_x: !0,
2395
+ snap_mouse_y: !1,
2396
+ mouse_move_throttle_rate: 33,
2397
+ mouse_wheel_throttle_rate: 50,
2398
+ currency_character: "฿",
2399
+ locale: "en-US",
2400
+ loading_text: "loading",
2401
+ time_intervals: [
2402
+ {
2403
+ label: "5m",
2404
+ seconds: 300
2405
+ },
2406
+ {
2407
+ label: "15m",
2408
+ seconds: 900
2409
+ },
2410
+ {
2411
+ label: "30m",
2412
+ seconds: 1800
2413
+ },
2414
+ {
2415
+ label: "1h",
2416
+ seconds: 3600
2417
+ },
2418
+ {
2419
+ label: "2h",
2420
+ seconds: 7200
2421
+ },
2422
+ {
2423
+ label: "4h",
2424
+ seconds: 14400
2425
+ },
2426
+ {
2427
+ label: "1d",
2428
+ seconds: 86400
2429
+ }
2430
+ ],
2431
+ defaults: {
2432
+ font_size: 12,
2433
+ font_face: "sans-serif",
2434
+ history_item_width: 20,
2435
+ history_item_margin: 0,
2436
+ history_interval: 86400,
2437
+ draw_simple_moving_average: !0,
2438
+ draw_exponential_moving_average: !0,
2439
+ draw_bollinger_bands: !1,
2440
+ chart_type: "candlestick",
2441
+ order_book_depth_count: 20
2442
+ },
2443
+ history_data: {
2444
+ simple_moving_average_window: 20,
2445
+ exponential_moving_average_window: 20,
2446
+ bollinger_standard_deviation_offset: 2,
2447
+ convergence_divergence_short_window: 12,
2448
+ convergence_divergence_long_window: 26,
2449
+ convergence_divergence_signal_window: 9
2450
+ },
2451
+ price_history: {
2452
+ font_size: 12,
2453
+ font_face: "sans-serif",
2454
+ border_primary_color: "#3f4b6d",
2455
+ border_secondary_color: "#242a3b",
2456
+ background_color: "#1f2531",
2457
+ bullish_color: "rgba(63, 204, 124, 1)",
2458
+ bearish_color: "rgba(255, 71, 71, 1)",
2459
+ price_line_color: "rgba(83, 175, 224, 1)",
2460
+ sma_line_color: "rgba(128, 142, 166, 1)",
2461
+ ema_line_color: "rgba(209, 187, 111, 1)",
2462
+ bollinger_band_upper_line_color: "rgba(100, 200, 100, 1)",
2463
+ bollinger_band_lower_line_color: "rgba(200, 100, 100, 1)",
2464
+ market_price_line_color: "rgba(49, 149, 96, 1)",
2465
+ market_price_label_color: "rgba(255, 255, 255, 1)",
2466
+ market_price_background_color: "rgba(49, 149, 96, .5)",
2467
+ x_label_color: "#76809b",
2468
+ y_label_color: "#76809b",
2469
+ info_height: 30,
2470
+ info_precision: 5,
2471
+ y_label_width: 60,
2472
+ y_label_precision: 5,
2473
+ x_label_height: 30,
2474
+ x_label_precision: 5,
2475
+ info_labels: [
2476
+ "Price",
2477
+ "Open",
2478
+ "Close",
2479
+ "High",
2480
+ "Low",
2481
+ "Volume"
2482
+ ],
2483
+ use_gradient: !1,
2484
+ first_gradient_color: "red",
2485
+ second_gradient_color: "blue",
2486
+ use_grid_lines: !1,
2487
+ grid_lines_dashed: !0,
2488
+ grid_lines_color: "white"
2489
+ },
2490
+ volume_history: {
2491
+ font_size: 12,
2492
+ font_face: "sans-serif",
2493
+ border_primary_color: "#3f4b6d",
2494
+ border_secondary_color: "#242a3b",
2495
+ background_color: "#1f2531",
2496
+ bullish_color: "rgba(63, 204, 124, 1)",
2497
+ bearish_color: "rgba(255, 71, 71, 1)",
2498
+ x_label_color: "#76809b",
2499
+ y_label_color: "#76809b",
2500
+ y_label_width: 60,
2501
+ y_label_precision: 0,
2502
+ x_label_height: 0,
2503
+ x_label_precision: 0
2504
+ },
2505
+ macd_history: {
2506
+ font_size: 12,
2507
+ font_face: "sans-serif",
2508
+ border_primary_color: "#3f4b6d",
2509
+ border_secondary_color: "#242a3b",
2510
+ background_color: "#1f2531",
2511
+ zero_line_color: "rgba(36, 42, 59, 1)",
2512
+ indicator_line_color: "rgba(71, 129, 255, 1)",
2513
+ signal_line_color: "rgba(255, 71, 71, 1)",
2514
+ histogram_positive_color: "rgba(63, 204, 124, .25)",
2515
+ histogram_negative_color: "rgba(255, 71, 71, .25)",
2516
+ x_label_color: "#76809b",
2517
+ y_label_color: "#76809b",
2518
+ y_label_width: 60,
2519
+ y_label_precision: 0,
2520
+ x_label_height: 0,
2521
+ x_label_precision: 0
2522
+ },
2523
+ range_selector: {
2524
+ font_size: 12,
2525
+ font_face: "sans-serif",
2526
+ border_primary_color: "#3f4b6d",
2527
+ border_secondary_color: "#242a3b",
2528
+ background_color: "#1f2531",
2529
+ market_price_line_color: "rgba(232, 232, 92, 1)",
2530
+ market_price_label_color: "rgba(232, 232, 92, 1)",
2531
+ price_line_color: "rgba(83, 175, 224, 1)",
2532
+ range_selection_color: "rgba(255, 255, 255, .2)",
2533
+ x_label_color: "#76809b",
2534
+ y_label_color: "#76809b",
2535
+ y_label_width: 0,
2536
+ y_label_precision: 0,
2537
+ x_label_height: 22,
2538
+ x_label_precision: 0
2539
+ },
2540
+ order_book_depth: {
2541
+ font_size: 12,
2542
+ font_face: "sans-serif",
2543
+ border_primary_color: "#3f4b6d",
2544
+ border_secondary_color: "#242a3b",
2545
+ background_color: "#1f2531",
2546
+ ask_line_color: "rgba(255, 71, 71, 1)",
2547
+ ask_fill_color: "rgba(255, 71, 71, .5)",
2548
+ bid_line_color: "rgba(63, 204, 124, 1)",
2549
+ bid_fill_color: "rgba(63, 204, 124, .5)",
2550
+ market_price_color: "#6f7faa",
2551
+ x_label_color: "#76809b",
2552
+ y_label_color: "#76809b",
2553
+ info_height: 30,
2554
+ info_precision: 2,
2555
+ y_label_width: 60,
2556
+ y_label_precision: 2,
2557
+ x_label_height: 22,
2558
+ x_label_precision: 5,
2559
+ update_interval: 1e3,
2560
+ depth: 10
2561
+ },
2562
+ number_suffixes: [
2563
+ "",
2564
+ "k",
2565
+ "M",
2566
+ "B",
2567
+ "T",
2568
+ "Q"
2569
+ ],
2570
+ date_format_days: [
2571
+ "Sun",
2572
+ "Mon",
2573
+ "Tue",
2574
+ "Wed",
2575
+ "Thu",
2576
+ "Fri",
2577
+ "Sat"
2578
+ ],
2579
+ date_format_months: [
2580
+ "Jan",
2581
+ "Feb",
2582
+ "Mar",
2583
+ "Apr",
2584
+ "May",
2585
+ "Jun",
2586
+ "Jul",
2587
+ "Aug",
2588
+ "Sep",
2589
+ "Oct",
2590
+ "Nov",
2591
+ "Dec"
2592
+ ],
2593
+ alphapoint_api: {
2594
+ uri: "wss://api_demo2.alphapoint.com/WSGateway/"
2595
+ }
2596
+ };
2597
+ class tt {
2598
+ constructor(t, i) {
2599
+ this.chartContainer = document.getElementById(t), this.config = Object.assign({}, K, i);
2600
+ }
2601
+ DrawChart() {
2602
+ this.chart = new d(this.chartContainer, this.config), this._alphaPointAPI = this.createAlphaPointAPI(), this.chart.registerAPI(this._alphaPointAPI), this._alphaPointAPI.connect(), this.chart.addEventListener("historyIntervalChange", (t) => {
2603
+ this.chart.setLoadingState(!0), this._alphaPointAPI.interval = t;
2604
+ });
2605
+ }
2606
+ // Methods for manual-api
2607
+ UpdateLevel2Data(t) {
2608
+ this._alphaPointAPI.UpdateLevel2Data(t);
2609
+ }
2610
+ UpdateTickersData(t) {
2611
+ this._alphaPointAPI.UpdateTickersData(t);
2612
+ }
2613
+ OnLoadingStateChange(t) {
2614
+ this._alphaPointAPI.OnLoadingStateChange(t);
2615
+ }
2616
+ UpdateMarketPrice(t) {
2617
+ this._alphaPointAPI.UpdateMarketPrice(t);
2618
+ }
2619
+ DestroyChart() {
2620
+ this.chart && (this._alphaPointAPI.disconnect(), this.chart._removeChartElement());
2621
+ }
2622
+ createAlphaPointAPI() {
2623
+ return this.config.store ? new Q(this.config.store, this.config.changeTickersInterval) : this.config.chartDataSubject ? new q(this.config.chartDataSubject, this.config.changeTickersInterval) : this.config.chartData ? new V(this.config.chartData, this.config.changeTickersInterval) : new z();
2624
+ }
2625
+ }
2626
+ export {
2627
+ tt as default
2628
+ };