oakscriptjs 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/README.md +42 -8
  2. package/dist/array/index.d.ts +7 -7
  3. package/dist/array/index.d.ts.map +1 -1
  4. package/dist/box/index.d.ts +11 -3
  5. package/dist/box/index.d.ts.map +1 -1
  6. package/dist/drawing/registry.d.ts +19 -0
  7. package/dist/drawing/registry.d.ts.map +1 -0
  8. package/dist/index.cjs +1661 -571
  9. package/dist/index.d.ts +8 -5
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.mjs +1661 -571
  12. package/dist/input.d.ts +7 -1
  13. package/dist/input.d.ts.map +1 -1
  14. package/dist/label/index.d.ts +12 -4
  15. package/dist/label/index.d.ts.map +1 -1
  16. package/dist/line/index.d.ts +11 -3
  17. package/dist/line/index.d.ts.map +1 -1
  18. package/dist/linefill/index.d.ts +3 -1
  19. package/dist/linefill/index.d.ts.map +1 -1
  20. package/dist/map/index.d.ts +14 -0
  21. package/dist/map/index.d.ts.map +1 -0
  22. package/dist/polyline/index.d.ts +1 -0
  23. package/dist/polyline/index.d.ts.map +1 -1
  24. package/dist/runtime/adapters/SimpleInputAdapter.d.ts.map +1 -1
  25. package/dist/runtime/index.cjs +40 -1
  26. package/dist/runtime/index.d.ts +1 -1
  27. package/dist/runtime/index.d.ts.map +1 -1
  28. package/dist/runtime/index.mjs +40 -1
  29. package/dist/runtime/inputs.d.ts +3 -0
  30. package/dist/runtime/inputs.d.ts.map +1 -1
  31. package/dist/runtime/types.d.ts +1 -1
  32. package/dist/runtime/types.d.ts.map +1 -1
  33. package/dist/script/index.cjs +3042 -622
  34. package/dist/script/index.d.ts +277 -12
  35. package/dist/script/index.d.ts.map +1 -1
  36. package/dist/script/index.mjs +3042 -622
  37. package/dist/security/resample.d.ts +13 -0
  38. package/dist/security/resample.d.ts.map +1 -0
  39. package/dist/session/bars.d.ts +34 -0
  40. package/dist/session/bars.d.ts.map +1 -0
  41. package/dist/session/calendar.d.ts +31 -0
  42. package/dist/session/calendar.d.ts.map +1 -0
  43. package/dist/str/dateformat.d.ts +2 -0
  44. package/dist/str/dateformat.d.ts.map +1 -0
  45. package/dist/str/index.d.ts +1 -1
  46. package/dist/str/index.d.ts.map +1 -1
  47. package/dist/str/messageformat.d.ts +2 -0
  48. package/dist/str/messageformat.d.ts.map +1 -0
  49. package/dist/str/numberformat.d.ts +3 -0
  50. package/dist/str/numberformat.d.ts.map +1 -0
  51. package/dist/ta/index.d.ts +14 -5
  52. package/dist/ta/index.d.ts.map +1 -1
  53. package/dist/ta-series.d.ts +23 -5
  54. package/dist/ta-series.d.ts.map +1 -1
  55. package/dist/text/index.d.ts +4 -0
  56. package/dist/text/index.d.ts.map +1 -0
  57. package/dist/time/datestring.d.ts +2 -0
  58. package/dist/time/datestring.d.ts.map +1 -0
  59. package/dist/time/index.d.ts +11 -0
  60. package/dist/time/index.d.ts.map +1 -1
  61. package/dist/time/session.d.ts +2 -0
  62. package/dist/time/session.d.ts.map +1 -0
  63. package/dist/time/timezone.d.ts +13 -0
  64. package/dist/time/timezone.d.ts.map +1 -0
  65. package/dist/timeframe/index.d.ts +17 -0
  66. package/dist/timeframe/index.d.ts.map +1 -0
  67. package/dist/types/index.d.ts +7 -0
  68. package/dist/types/index.d.ts.map +1 -1
  69. package/dist/types/metadata.d.ts +1 -1
  70. package/dist/types/metadata.d.ts.map +1 -1
  71. package/dist/utils/index.d.ts +1 -0
  72. package/dist/utils/index.d.ts.map +1 -1
  73. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __export = (target, all) => {
3
- for (var name in all)
4
- __defProp(target, name, { get: all[name], enumerable: true });
2
+ var __export = (target, all7) => {
3
+ for (var name in all7)
4
+ __defProp(target, name, { get: all7[name], enumerable: true });
5
5
  };
6
6
 
7
7
  // src/types/index.ts
@@ -15,6 +15,7 @@ var xloc = {
15
15
  // src/ta/index.ts
16
16
  var ta_exports = {};
17
17
  __export(ta_exports, {
18
+ accdist: () => accdist,
18
19
  alma: () => alma,
19
20
  atr: () => atr,
20
21
  barssince: () => barssince,
@@ -37,6 +38,7 @@ __export(ta_exports, {
37
38
  highestbars: () => highestbars,
38
39
  hma: () => hma,
39
40
  ichimoku: () => ichimoku,
41
+ iii: () => iii,
40
42
  kc: () => kc,
41
43
  kcw: () => kcw,
42
44
  linreg: () => linreg,
@@ -49,12 +51,16 @@ __export(ta_exports, {
49
51
  min: () => min,
50
52
  mode: () => mode,
51
53
  mom: () => mom,
54
+ nvi: () => nvi,
55
+ obv: () => obv,
52
56
  percentile_linear_interpolation: () => percentile_linear_interpolation,
53
57
  percentile_nearest_rank: () => percentile_nearest_rank,
54
58
  percentrank: () => percentrank,
55
59
  pivot_point_levels: () => pivot_point_levels,
56
60
  pivothigh: () => pivothigh,
57
61
  pivotlow: () => pivotlow,
62
+ pvi: () => pvi,
63
+ pvt: () => pvt,
58
64
  range: () => range,
59
65
  rci: () => rci,
60
66
  rising: () => rising,
@@ -73,8 +79,10 @@ __export(ta_exports, {
73
79
  variance: () => variance,
74
80
  vwap: () => vwap,
75
81
  vwma: () => vwma,
82
+ wad: () => wad,
76
83
  wma: () => wma,
77
84
  wpr: () => wpr,
85
+ wvad: () => wvad,
78
86
  zigzag: () => zigzag
79
87
  });
80
88
  function sma(source, length2) {
@@ -174,23 +182,42 @@ function bb(series, length2, mult2) {
174
182
  }
175
183
  return [basis, upper2, lower2];
176
184
  }
177
- function stdev(source, length2) {
178
- const result = [];
185
+ function stdev(source, length2, biased = true) {
179
186
  const len = Math.floor(length2);
180
- const avg4 = sma(source, len);
181
- for (let i = 0; i < source.length; i++) {
182
- if (i < len - 1) {
183
- result.push(NaN);
184
- } else {
185
- let sumSquares = 0;
186
- for (let j = 0; j < len; j++) {
187
- const diff2 = source[i - j] - avg4[i];
188
- sumSquares += diff2 * diff2;
189
- }
190
- result.push(Math.sqrt(sumSquares / len));
191
- }
192
- }
193
- return result;
187
+ return source.map((_, i) => {
188
+ const values2 = lastValues(source, i, len);
189
+ if (!values2) return NaN;
190
+ const mean = values2.reduce((a, b2) => a + b2, 0) / len;
191
+ const squares = values2.reduce((a, b2) => a + (b2 - mean) * (b2 - mean), 0);
192
+ return Math.sqrt(squares / (biased ? len : len - 1));
193
+ });
194
+ }
195
+ function lastValues(source, i, length2) {
196
+ const values2 = [];
197
+ for (let j = i; j >= 0 && values2.length < length2; j--) {
198
+ const x = source[j];
199
+ if (!Number.isNaN(x)) values2.push(x);
200
+ }
201
+ return values2.length === length2 ? values2 : null;
202
+ }
203
+ function windowUntilNa(source, i, length2) {
204
+ const values2 = [];
205
+ for (let j = 0; j < length2 && i - j >= 0; j++) {
206
+ const x = source[i - j];
207
+ if (Number.isNaN(x)) break;
208
+ values2.push([x, -j]);
209
+ }
210
+ return values2;
211
+ }
212
+ function extremeOffset(source, length2, isHigher) {
213
+ return source.map((_, i) => {
214
+ if (i < length2 - 1) return NaN;
215
+ const w = windowUntilNa(source, i, length2);
216
+ if (w.length === 0) return 0;
217
+ let best = w[0];
218
+ for (const item of w) if (isHigher(item[0], best[0])) best = item;
219
+ return best[1];
220
+ });
194
221
  }
195
222
  function crossover(series1, series2) {
196
223
  const result = [];
@@ -369,47 +396,26 @@ function wma(source, length2) {
369
396
  return result;
370
397
  }
371
398
  function highest(source, length2) {
372
- const result = [];
373
- for (let i = 0; i < source.length; i++) {
374
- if (i < length2 - 1) {
375
- result.push(NaN);
376
- } else {
377
- let max6 = -Infinity;
378
- for (let j = 0; j < length2; j++) {
379
- if (!isNaN(source[i - j])) {
380
- max6 = Math.max(max6, source[i - j]);
381
- }
382
- }
383
- result.push(max6 === -Infinity ? NaN : max6);
384
- }
385
- }
386
- return result;
399
+ return source.map((_, i) => {
400
+ if (i < length2 - 1) return NaN;
401
+ const w = windowUntilNa(source, i, length2);
402
+ return w.length ? Math.max(...w.map((x) => x[0])) : NaN;
403
+ });
387
404
  }
388
405
  function lowest(source, length2) {
389
- const result = [];
390
- for (let i = 0; i < source.length; i++) {
391
- if (i < length2 - 1) {
392
- result.push(NaN);
393
- } else {
394
- let min6 = Infinity;
395
- for (let j = 0; j < length2; j++) {
396
- if (!isNaN(source[i - j])) {
397
- min6 = Math.min(min6, source[i - j]);
398
- }
399
- }
400
- result.push(min6 === Infinity ? NaN : min6);
401
- }
402
- }
403
- return result;
406
+ return source.map((_, i) => {
407
+ if (i < length2 - 1) return NaN;
408
+ const w = windowUntilNa(source, i, length2);
409
+ return w.length ? Math.min(...w.map((x) => x[0])) : NaN;
410
+ });
404
411
  }
405
412
  function cum(source) {
406
- const result = [];
407
413
  let sum4 = 0;
408
- for (let i = 0; i < source.length; i++) {
409
- sum4 += source[i];
410
- result.push(sum4);
411
- }
412
- return result;
414
+ return source.map((v) => {
415
+ if (Number.isNaN(v)) return NaN;
416
+ sum4 += v;
417
+ return sum4;
418
+ });
413
419
  }
414
420
  function cross(source1, source2) {
415
421
  const result = [];
@@ -538,21 +544,21 @@ function median(source, length2) {
538
544
  if (i < length2 - 1) {
539
545
  result.push(NaN);
540
546
  } else {
541
- const values = [];
547
+ const values2 = [];
542
548
  for (let j = 0; j < length2; j++) {
543
549
  if (!isNaN(source[i - j])) {
544
- values.push(source[i - j]);
550
+ values2.push(source[i - j]);
545
551
  }
546
552
  }
547
- if (values.length === 0) {
553
+ if (values2.length === 0) {
548
554
  result.push(NaN);
549
555
  } else {
550
- values.sort((a, b2) => a - b2);
551
- const mid = Math.floor(values.length / 2);
552
- if (values.length % 2 === 0) {
553
- result.push((values[mid - 1] + values[mid]) / 2);
556
+ values2.sort((a, b2) => a - b2);
557
+ const mid = Math.floor(values2.length / 2);
558
+ if (values2.length % 2 === 0) {
559
+ result.push((values2[mid - 1] + values2[mid]) / 2);
554
560
  } else {
555
- result.push(values[mid]);
561
+ result.push(values2[mid]);
556
562
  }
557
563
  }
558
564
  }
@@ -882,89 +888,44 @@ function sar(start, inc, max6, high, low, close) {
882
888
  }
883
889
  return result;
884
890
  }
891
+ function pivot(source, leftbars, rightbars, isHigh) {
892
+ const beatsLeft = isHigh ? (x, v) => x > v : (x, v) => x < v;
893
+ const beatsRight = isHigh ? (x, v) => x >= v : (x, v) => x <= v;
894
+ return source.map((_, i) => {
895
+ const center = i - rightbars;
896
+ if (center - leftbars < 0) return NaN;
897
+ const v = source[center];
898
+ if (Number.isNaN(v)) return NaN;
899
+ for (let j = 1; j <= leftbars; j++) {
900
+ const x = source[center - j];
901
+ if (Number.isNaN(x)) break;
902
+ if (beatsLeft(x, v)) return NaN;
903
+ }
904
+ for (let j = 1; j <= rightbars; j++) {
905
+ const x = source[center + j];
906
+ if (Number.isNaN(x)) break;
907
+ if (beatsRight(x, v)) return NaN;
908
+ }
909
+ return v;
910
+ });
911
+ }
885
912
  function pivothigh(sourceOrLeftbars, leftbarsOrRightbars, rightbars, high) {
886
- let source;
887
- let leftbars;
888
- let right;
889
913
  if (rightbars === void 0) {
890
914
  if (!high) {
891
915
  throw new Error("ta.pivothigh() requires high series when using two-parameter version.");
892
916
  }
893
- source = high;
894
- leftbars = sourceOrLeftbars;
895
- right = leftbarsOrRightbars;
896
- } else {
897
- source = sourceOrLeftbars;
898
- leftbars = leftbarsOrRightbars;
899
- right = rightbars;
900
- }
901
- const result = [];
902
- for (let i = 0; i < source.length; i++) {
903
- if (i < leftbars || i + right >= source.length) {
904
- result.push(NaN);
905
- continue;
906
- }
907
- const centerValue = source[i];
908
- let isPivot = true;
909
- for (let j = 1; j <= leftbars; j++) {
910
- if (source[i - j] >= centerValue) {
911
- isPivot = false;
912
- break;
913
- }
914
- }
915
- if (isPivot) {
916
- for (let j = 1; j <= right; j++) {
917
- if (source[i + j] >= centerValue) {
918
- isPivot = false;
919
- break;
920
- }
921
- }
922
- }
923
- result.push(isPivot ? centerValue : NaN);
917
+ return pivot(high, sourceOrLeftbars, leftbarsOrRightbars, true);
924
918
  }
925
- return result;
919
+ return pivot(sourceOrLeftbars, leftbarsOrRightbars, rightbars, true);
926
920
  }
927
921
  function pivotlow(sourceOrLeftbars, leftbarsOrRightbars, rightbars, low) {
928
- let source;
929
- let leftbars;
930
- let right;
931
922
  if (rightbars === void 0) {
932
923
  if (!low) {
933
924
  throw new Error("ta.pivotlow() requires low series when using two-parameter version.");
934
925
  }
935
- source = low;
936
- leftbars = sourceOrLeftbars;
937
- right = leftbarsOrRightbars;
938
- } else {
939
- source = sourceOrLeftbars;
940
- leftbars = leftbarsOrRightbars;
941
- right = rightbars;
926
+ return pivot(low, sourceOrLeftbars, leftbarsOrRightbars, false);
942
927
  }
943
- const result = [];
944
- for (let i = 0; i < source.length; i++) {
945
- if (i < leftbars || i + right >= source.length) {
946
- result.push(NaN);
947
- continue;
948
- }
949
- const centerValue = source[i];
950
- let isPivot = true;
951
- for (let j = 1; j <= leftbars; j++) {
952
- if (source[i - j] <= centerValue) {
953
- isPivot = false;
954
- break;
955
- }
956
- }
957
- if (isPivot) {
958
- for (let j = 1; j <= right; j++) {
959
- if (source[i + j] <= centerValue) {
960
- isPivot = false;
961
- break;
962
- }
963
- }
964
- }
965
- result.push(isPivot ? centerValue : NaN);
966
- }
967
- return result;
928
+ return pivot(sourceOrLeftbars, leftbarsOrRightbars, rightbars, false);
968
929
  }
969
930
  function barssince(condition) {
970
931
  const result = [];
@@ -1158,27 +1119,38 @@ function wpr(high, low, close, length2 = 14) {
1158
1119
  }
1159
1120
  return result;
1160
1121
  }
1161
- function vwap(source, volume) {
1122
+ function vwap(source, volume, anchor, stdev_mult) {
1162
1123
  if (source.length !== volume.length) {
1163
1124
  throw new Error("ta.vwap: source and volume must have the same length");
1164
1125
  }
1165
- const result = [];
1166
- let cumulativePV = 0;
1167
- let cumulativeVolume = 0;
1126
+ const mid = [];
1127
+ const upper2 = [];
1128
+ const lower2 = [];
1129
+ let sumPV = 0;
1130
+ let sumV = 0;
1131
+ let sumPPV = 0;
1168
1132
  for (let i = 0; i < source.length; i++) {
1169
- if (isNaN(source[i]) || isNaN(volume[i])) {
1170
- result.push(NaN);
1171
- continue;
1133
+ if (anchor && anchor[i]) {
1134
+ sumPV = 0;
1135
+ sumV = 0;
1136
+ sumPPV = 0;
1172
1137
  }
1173
- cumulativePV += source[i] * volume[i];
1174
- cumulativeVolume += volume[i];
1175
- if (cumulativeVolume === 0) {
1176
- result.push(NaN);
1177
- } else {
1178
- result.push(cumulativePV / cumulativeVolume);
1138
+ const s = source[i];
1139
+ const v = volume[i];
1140
+ if (!Number.isNaN(s) && !Number.isNaN(v)) {
1141
+ sumPV += s * v;
1142
+ sumV += v;
1143
+ sumPPV += s * s * v;
1144
+ }
1145
+ const m = sumV === 0 ? NaN : sumPV / sumV;
1146
+ mid.push(m);
1147
+ if (stdev_mult !== void 0) {
1148
+ const sd = Math.sqrt(Math.max(0, sumPPV / sumV - m * m));
1149
+ upper2.push(m + stdev_mult * sd);
1150
+ lower2.push(m - stdev_mult * sd);
1179
1151
  }
1180
1152
  }
1181
- return result;
1153
+ return stdev_mult === void 0 ? mid : [mid, upper2, lower2];
1182
1154
  }
1183
1155
  function alma(source, length2 = 9, offset = 0.85, sigma = 6, floor2 = false) {
1184
1156
  const result = [];
@@ -1220,85 +1192,31 @@ function kcw(source, length2 = 20, mult2 = 2, useTrueRange = true, high, low, cl
1220
1192
  }
1221
1193
  return result;
1222
1194
  }
1223
- function range(high, low) {
1224
- if (high.length !== low.length) {
1225
- throw new Error("ta.range: high and low must have the same length");
1226
- }
1227
- const result = [];
1228
- for (let i = 0; i < high.length; i++) {
1229
- if (isNaN(high[i]) || isNaN(low[i])) {
1230
- result.push(NaN);
1231
- } else {
1232
- result.push(high[i] - low[i]);
1233
- }
1234
- }
1235
- return result;
1195
+ function range(source, length2) {
1196
+ return source.map((_, i) => {
1197
+ const values2 = lastValues(source, i, length2);
1198
+ return values2 ? Math.max(...values2) - Math.min(...values2) : NaN;
1199
+ });
1236
1200
  }
1237
1201
  function highestbars(source, length2) {
1238
- const result = [];
1239
- for (let i = 0; i < source.length; i++) {
1240
- if (i < length2 - 1) {
1241
- result.push(NaN);
1242
- continue;
1243
- }
1244
- let highestValue = source[i - length2 + 1];
1245
- let highestOffset = length2 - 1;
1246
- for (let j = i - length2 + 2; j <= i; j++) {
1247
- if (source[j] > highestValue) {
1248
- highestValue = source[j];
1249
- highestOffset = i - j;
1250
- }
1251
- }
1252
- result.push(highestOffset);
1253
- }
1254
- return result;
1202
+ return extremeOffset(source, length2, (a, b2) => a >= b2);
1255
1203
  }
1256
1204
  function lowestbars(source, length2) {
1257
- const result = [];
1258
- for (let i = 0; i < source.length; i++) {
1259
- if (i < length2 - 1) {
1260
- result.push(NaN);
1261
- continue;
1262
- }
1263
- let lowestValue = source[i - length2 + 1];
1264
- let lowestOffset = length2 - 1;
1265
- for (let j = i - length2 + 2; j <= i; j++) {
1266
- if (source[j] < lowestValue) {
1267
- lowestValue = source[j];
1268
- lowestOffset = i - j;
1269
- }
1270
- }
1271
- result.push(lowestOffset);
1272
- }
1273
- return result;
1205
+ return extremeOffset(source, length2, (a, b2) => a <= b2);
1274
1206
  }
1275
- function max(source1, source2) {
1276
- if (source1.length !== source2.length) {
1277
- throw new Error("ta.max: source1 and source2 must have the same length");
1278
- }
1279
- const result = [];
1280
- for (let i = 0; i < source1.length; i++) {
1281
- if (isNaN(source1[i]) || isNaN(source2[i])) {
1282
- result.push(NaN);
1283
- } else {
1284
- result.push(Math.max(source1[i], source2[i]));
1285
- }
1286
- }
1287
- return result;
1207
+ function max(source) {
1208
+ let best = NaN;
1209
+ return source.map((x) => {
1210
+ if (!Number.isNaN(x) && !(x <= best)) best = x;
1211
+ return best;
1212
+ });
1288
1213
  }
1289
- function min(source1, source2) {
1290
- if (source1.length !== source2.length) {
1291
- throw new Error("ta.min: source1 and source2 must have the same length");
1292
- }
1293
- const result = [];
1294
- for (let i = 0; i < source1.length; i++) {
1295
- if (isNaN(source1[i]) || isNaN(source2[i])) {
1296
- result.push(NaN);
1297
- } else {
1298
- result.push(Math.min(source1[i], source2[i]));
1299
- }
1300
- }
1301
- return result;
1214
+ function min(source) {
1215
+ let best = NaN;
1216
+ return source.map((x) => {
1217
+ if (!Number.isNaN(x) && !(x >= best)) best = x;
1218
+ return best;
1219
+ });
1302
1220
  }
1303
1221
  function cog(source, length2 = 10) {
1304
1222
  const result = [];
@@ -1331,19 +1249,19 @@ function mode(source, length2) {
1331
1249
  result.push(NaN);
1332
1250
  continue;
1333
1251
  }
1334
- const values = [];
1252
+ const values2 = [];
1335
1253
  for (let j = 0; j < length2; j++) {
1336
1254
  const value = source[i - j];
1337
1255
  if (!isNaN(value)) {
1338
- values.push(value);
1256
+ values2.push(value);
1339
1257
  }
1340
1258
  }
1341
- if (values.length === 0) {
1259
+ if (values2.length === 0) {
1342
1260
  result.push(NaN);
1343
1261
  continue;
1344
1262
  }
1345
1263
  const frequencyMap = /* @__PURE__ */ new Map();
1346
- for (const value of values) {
1264
+ for (const value of values2) {
1347
1265
  frequencyMap.set(value, (frequencyMap.get(value) || 0) + 1);
1348
1266
  }
1349
1267
  let maxFrequency = 0;
@@ -1369,16 +1287,16 @@ function percentile_linear_interpolation(source, length2, percentage) {
1369
1287
  result.push(NaN);
1370
1288
  continue;
1371
1289
  }
1372
- const values = [];
1290
+ const values2 = [];
1373
1291
  for (let j = 0; j < length2; j++) {
1374
1292
  const value = source[i - j];
1375
- values.push(value);
1293
+ values2.push(value);
1376
1294
  }
1377
- if (values.some((v) => isNaN(v))) {
1295
+ if (values2.some((v) => isNaN(v))) {
1378
1296
  result.push(NaN);
1379
1297
  continue;
1380
1298
  }
1381
- const sorted = [...values].sort((a, b2) => a - b2);
1299
+ const sorted = [...values2].sort((a, b2) => a - b2);
1382
1300
  const position = percentage / 100 * (sorted.length - 1);
1383
1301
  const lowerIndex = Math.floor(position);
1384
1302
  const upperIndex = Math.ceil(position);
@@ -1399,18 +1317,18 @@ function percentile_nearest_rank(source, length2, percentage) {
1399
1317
  result.push(NaN);
1400
1318
  continue;
1401
1319
  }
1402
- const values = [];
1320
+ const values2 = [];
1403
1321
  for (let j = 0; j < length2; j++) {
1404
1322
  const value = source[i - j];
1405
1323
  if (!isNaN(value)) {
1406
- values.push(value);
1324
+ values2.push(value);
1407
1325
  }
1408
1326
  }
1409
- if (values.length === 0) {
1327
+ if (values2.length === 0) {
1410
1328
  result.push(NaN);
1411
1329
  continue;
1412
1330
  }
1413
- const sorted = [...values].sort((a, b2) => a - b2);
1331
+ const sorted = [...values2].sort((a, b2) => a - b2);
1414
1332
  if (percentage >= 100) {
1415
1333
  result.push(sorted[sorted.length - 1]);
1416
1334
  continue;
@@ -1428,15 +1346,15 @@ function rci(source, length2) {
1428
1346
  result.push(NaN);
1429
1347
  continue;
1430
1348
  }
1431
- const values = [];
1349
+ const values2 = [];
1432
1350
  for (let j = 0; j < length2; j++) {
1433
- values.push(source[i - length2 + 1 + j]);
1351
+ values2.push(source[i - length2 + 1 + j]);
1434
1352
  }
1435
- if (values.some((v) => isNaN(v))) {
1353
+ if (values2.some((v) => isNaN(v))) {
1436
1354
  result.push(NaN);
1437
1355
  continue;
1438
1356
  }
1439
- const indexed = values.map((value, index) => ({ value, index }));
1357
+ const indexed = values2.map((value, index) => ({ value, index }));
1440
1358
  const sorted = [...indexed].sort((a, b2) => a.value - b2.value);
1441
1359
  const ranks = new Array(length2).fill(0);
1442
1360
  let currentRank = 1;
@@ -1800,23 +1718,86 @@ function zigzag(deviation = 5, depth = 10, backstep = 3, source, high, low) {
1800
1718
  if (potentialPivot) {
1801
1719
  confirmedPivots.push(potentialPivot);
1802
1720
  }
1803
- for (const pivot of confirmedPivots) {
1804
- zigzagValues[pivot.index] = pivot.price;
1805
- isPivot[pivot.index] = true;
1721
+ for (const pivot2 of confirmedPivots) {
1722
+ zigzagValues[pivot2.index] = pivot2.price;
1723
+ isPivot[pivot2.index] = true;
1806
1724
  }
1807
1725
  let currentDir = 0;
1808
1726
  let pivotIdx = 0;
1809
1727
  const numConfirmed = lastPotentialWasAdded ? confirmedPivots.length - 1 : confirmedPivots.length;
1810
1728
  for (let i = 0; i < length2; i++) {
1811
1729
  while (pivotIdx < numConfirmed && confirmedPivots[pivotIdx].index <= i) {
1812
- const pivot = confirmedPivots[pivotIdx];
1813
- currentDir = pivot.type === "low" ? 1 : -1;
1730
+ const pivot2 = confirmedPivots[pivotIdx];
1731
+ currentDir = pivot2.type === "low" ? 1 : -1;
1814
1732
  pivotIdx++;
1815
1733
  }
1816
1734
  directions[i] = currentDir;
1817
1735
  }
1818
1736
  return [zigzagValues, directions, isPivot];
1819
1737
  }
1738
+ function obv(close, volume) {
1739
+ return cum(close.map((c, i) => i === 0 ? NaN : Math.sign(c - close[i - 1]) * volume[i]));
1740
+ }
1741
+ function pvt(close, volume) {
1742
+ return cum(
1743
+ close.map((c, i) => i === 0 ? NaN : (c - close[i - 1]) / close[i - 1] * volume[i])
1744
+ );
1745
+ }
1746
+ function accdist(high, low, close, volume) {
1747
+ return cum(
1748
+ close.map((c, i) => {
1749
+ const h = high[i];
1750
+ const l = low[i];
1751
+ return h === l ? 0 : (2 * c - l - h) / (h - l) * volume[i];
1752
+ })
1753
+ );
1754
+ }
1755
+ function iii(high, low, close, volume) {
1756
+ return close.map((c, i) => {
1757
+ const range4 = high[i] - low[i];
1758
+ return range4 === 0 ? NaN : (2 * c - high[i] - low[i]) / range4 * volume[i];
1759
+ });
1760
+ }
1761
+ function wvad(open, high, low, close, volume) {
1762
+ return close.map((c, i) => {
1763
+ const range4 = high[i] - low[i];
1764
+ return range4 === 0 ? NaN : (c - open[i]) / range4 * volume[i];
1765
+ });
1766
+ }
1767
+ function wad(high, low, close) {
1768
+ return cum(
1769
+ close.map((c, i) => {
1770
+ const prev = i === 0 ? NaN : close[i - 1];
1771
+ const mom3 = c - prev;
1772
+ if (mom3 > 0) return c - Math.min(low[i], prev);
1773
+ if (mom3 < 0) return c - Math.max(high[i], prev);
1774
+ return 0;
1775
+ })
1776
+ );
1777
+ }
1778
+ function volumeIndex(close, volume, use) {
1779
+ const result = [];
1780
+ let prevIndex = NaN;
1781
+ for (let i = 0; i < close.length; i++) {
1782
+ const prev = !prevIndex ? 1 : prevIndex;
1783
+ const c = close[i];
1784
+ const prevC = i === 0 ? NaN : close[i - 1];
1785
+ let value = prev;
1786
+ if (c && prevC) {
1787
+ const prevV = i === 0 || Number.isNaN(volume[i - 1]) ? 0 : volume[i - 1];
1788
+ if (use(volume[i], prevV)) value = prev + (c - prevC) / prevC * prev;
1789
+ }
1790
+ result.push(value);
1791
+ prevIndex = value;
1792
+ }
1793
+ return result;
1794
+ }
1795
+ function nvi(close, volume) {
1796
+ return volumeIndex(close, volume, (v, prevV) => v < prevV);
1797
+ }
1798
+ function pvi(close, volume) {
1799
+ return volumeIndex(close, volume, (v, prevV) => v > prevV);
1800
+ }
1820
1801
 
1821
1802
  // src/math/index.ts
1822
1803
  var math_exports = {};
@@ -1993,8 +1974,8 @@ var Series = class _Series {
1993
1974
  * @param field - Field to extract ('open', 'high', 'low', 'close', 'volume')
1994
1975
  * @returns Series with extracted field values
1995
1976
  */
1996
- static fromBars(bars, field) {
1997
- return new _Series(bars, (bar) => bar[field] ?? NaN);
1977
+ static fromBars(bars, field2) {
1978
+ return new _Series(bars, (bar) => bar[field2] ?? NaN);
1998
1979
  }
1999
1980
  /**
2000
1981
  * Create a constant series (same value for all bars)
@@ -2011,8 +1992,8 @@ var Series = class _Series {
2011
1992
  * @param values - Array of values
2012
1993
  * @returns Series
2013
1994
  */
2014
- static fromArray(bars, values) {
2015
- return new _Series(bars, (_bar, i) => values[i] ?? NaN);
1995
+ static fromArray(bars, values2) {
1996
+ return new _Series(bars, (_bar, i) => values2[i] ?? NaN);
2016
1997
  }
2017
1998
  // ============================================
2018
1999
  // Arithmetic Operations
@@ -2302,8 +2283,8 @@ var Series = class _Series {
2302
2283
  * @returns New Series with computed values and no closure dependencies
2303
2284
  */
2304
2285
  materialize() {
2305
- const values = this.toArray();
2306
- const valuesCopy = [...values];
2286
+ const values2 = this.toArray();
2287
+ const valuesCopy = [...values2];
2307
2288
  return _Series.fromArray(this.dataSource, valuesCopy);
2308
2289
  }
2309
2290
  /**
@@ -2333,16 +2314,16 @@ var Series = class _Series {
2333
2314
  * @returns Value at that index
2334
2315
  */
2335
2316
  get(index) {
2336
- const values = this.toArray();
2337
- return values[index] ?? NaN;
2317
+ const values2 = this.toArray();
2318
+ return values2[index] ?? NaN;
2338
2319
  }
2339
2320
  /**
2340
2321
  * Get the last value (most recent bar)
2341
2322
  * @returns Most recent value
2342
2323
  */
2343
2324
  last() {
2344
- const values = this.toArray();
2345
- return values[values.length - 1] ?? NaN;
2325
+ const values2 = this.toArray();
2326
+ return values2[values2.length - 1] ?? NaN;
2346
2327
  }
2347
2328
  /**
2348
2329
  * Get number of values
@@ -2356,11 +2337,11 @@ var Series = class _Series {
2356
2337
  * @returns Array of { time, value } objects
2357
2338
  */
2358
2339
  toTimeValuePairs() {
2359
- const values = this.toArray();
2340
+ const values2 = this.toArray();
2360
2341
  const bars = this.dataSource.bars;
2361
2342
  return bars.map((bar, i) => ({
2362
2343
  time: bar.time,
2363
- value: values[i]
2344
+ value: values2[i]
2364
2345
  })).filter((point) => !Number.isNaN(point.value));
2365
2346
  }
2366
2347
  };
@@ -2434,60 +2415,60 @@ function round(value, precision) {
2434
2415
  const multiplier = Math.pow(10, precision);
2435
2416
  return Math.round(value * multiplier) / multiplier;
2436
2417
  }
2437
- function max2(...values) {
2438
- const hasSeries = values.some((v) => v instanceof Series);
2418
+ function max2(...values2) {
2419
+ const hasSeries = values2.some((v) => v instanceof Series);
2439
2420
  if (!hasSeries) {
2440
- return Math.max(...values);
2421
+ return Math.max(...values2);
2441
2422
  }
2442
- const firstSeries = values.find((v) => v instanceof Series);
2423
+ const firstSeries = values2.find((v) => v instanceof Series);
2443
2424
  const bars = firstSeries.bars;
2444
2425
  const length2 = bars.length;
2445
- const valueArrays = values.map(
2426
+ const valueArrays = values2.map(
2446
2427
  (v) => v instanceof Series ? v.toArray() : null
2447
2428
  );
2448
2429
  const result = [];
2449
2430
  for (let i = 0; i < length2; i++) {
2450
- const nums = values.map(
2431
+ const nums = values2.map(
2451
2432
  (v, idx) => valueArrays[idx] ? valueArrays[idx][i] ?? NaN : v
2452
2433
  );
2453
2434
  result.push(Math.max(...nums));
2454
2435
  }
2455
2436
  return Series.fromArray(bars, result);
2456
2437
  }
2457
- function min2(...values) {
2458
- const hasSeries = values.some((v) => v instanceof Series);
2438
+ function min2(...values2) {
2439
+ const hasSeries = values2.some((v) => v instanceof Series);
2459
2440
  if (!hasSeries) {
2460
- return Math.min(...values);
2441
+ return Math.min(...values2);
2461
2442
  }
2462
- const firstSeries = values.find((v) => v instanceof Series);
2443
+ const firstSeries = values2.find((v) => v instanceof Series);
2463
2444
  const bars = firstSeries.bars;
2464
2445
  const length2 = bars.length;
2465
- const valueArrays = values.map(
2446
+ const valueArrays = values2.map(
2466
2447
  (v) => v instanceof Series ? v.toArray() : null
2467
2448
  );
2468
2449
  const result = [];
2469
2450
  for (let i = 0; i < length2; i++) {
2470
- const nums = values.map(
2451
+ const nums = values2.map(
2471
2452
  (v, idx) => valueArrays[idx] ? valueArrays[idx][i] ?? NaN : v
2472
2453
  );
2473
2454
  result.push(Math.min(...nums));
2474
2455
  }
2475
2456
  return Series.fromArray(bars, result);
2476
2457
  }
2477
- function avg(...values) {
2478
- const hasSeries = values.some((v) => v instanceof Series);
2458
+ function avg(...values2) {
2459
+ const hasSeries = values2.some((v) => v instanceof Series);
2479
2460
  if (!hasSeries) {
2480
- return values.reduce((a, b2) => a + b2, 0) / values.length;
2461
+ return values2.reduce((a, b2) => a + b2, 0) / values2.length;
2481
2462
  }
2482
- const firstSeries = values.find((v) => v instanceof Series);
2463
+ const firstSeries = values2.find((v) => v instanceof Series);
2483
2464
  const bars = firstSeries.bars;
2484
2465
  const length2 = bars.length;
2485
- const valueArrays = values.map(
2466
+ const valueArrays = values2.map(
2486
2467
  (v) => v instanceof Series ? v.toArray() : null
2487
2468
  );
2488
2469
  const result = [];
2489
2470
  for (let i = 0; i < length2; i++) {
2490
- const nums = values.map(
2471
+ const nums = values2.map(
2491
2472
  (v, idx) => valueArrays[idx] ? valueArrays[idx][i] ?? NaN : v
2492
2473
  );
2493
2474
  const sum4 = nums.reduce((a, b2) => a + b2, 0);
@@ -2721,10 +2702,10 @@ function sign(value) {
2721
2702
  }
2722
2703
  return value > 0 ? 1 : value < 0 ? -1 : 0;
2723
2704
  }
2724
- function round_to_mintick(number, mintick) {
2725
- if (number instanceof Series) {
2726
- const bars = number.bars;
2727
- const valueArray = number.toArray();
2705
+ function round_to_mintick(number2, mintick) {
2706
+ if (number2 instanceof Series) {
2707
+ const bars = number2.bars;
2708
+ const valueArray = number2.toArray();
2728
2709
  const length2 = bars.length;
2729
2710
  if (mintick === void 0) {
2730
2711
  throw new Error(
@@ -2748,7 +2729,7 @@ function round_to_mintick(number, mintick) {
2748
2729
  }
2749
2730
  return Series.fromArray(bars, result);
2750
2731
  }
2751
- if (isNaN(number)) {
2732
+ if (isNaN(number2)) {
2752
2733
  return NaN;
2753
2734
  }
2754
2735
  if (mintick === void 0) {
@@ -2757,9 +2738,9 @@ function round_to_mintick(number, mintick) {
2757
2738
  );
2758
2739
  }
2759
2740
  if (mintick === 0) {
2760
- return number;
2741
+ return number2;
2761
2742
  }
2762
- return Math.round(number / mintick) * mintick;
2743
+ return Math.round(number2 / mintick) * mintick;
2763
2744
  }
2764
2745
  var pi = Math.PI;
2765
2746
  var e = Math.E;
@@ -2825,9 +2806,9 @@ __export(array_exports, {
2825
2806
  unshift: () => unshift,
2826
2807
  variance: () => variance2
2827
2808
  });
2828
- function new_array(size2 = 0, initial_value) {
2809
+ function new_array(size3 = 0, initial_value) {
2829
2810
  const arr = [];
2830
- for (let i = 0; i < size2; i++) {
2811
+ for (let i = 0; i < size3; i++) {
2831
2812
  arr.push(initial_value);
2832
2813
  }
2833
2814
  return arr;
@@ -2901,11 +2882,13 @@ function sum2(id) {
2901
2882
  function avg2(id) {
2902
2883
  return sum2(id) / size(id);
2903
2884
  }
2904
- function min3(id) {
2905
- return Math.min(...id);
2885
+ function min3(id, nth = 0) {
2886
+ const values2 = id.filter((v) => !Number.isNaN(v)).sort((a, b2) => a - b2);
2887
+ return values2.length ? values2[Math.min(nth, values2.length - 1)] : NaN;
2906
2888
  }
2907
- function max3(id) {
2908
- return Math.max(...id);
2889
+ function max3(id, nth = 0) {
2890
+ const values2 = id.filter((v) => !Number.isNaN(v)).sort((a, b2) => b2 - a);
2891
+ return values2.length ? values2[Math.min(nth, values2.length - 1)] : NaN;
2909
2892
  }
2910
2893
  function median2(id) {
2911
2894
  const sorted = [...id].sort((a, b2) => a - b2);
@@ -2926,16 +2909,15 @@ function mode2(id) {
2926
2909
  }
2927
2910
  return mode5;
2928
2911
  }
2929
- function stdev2(id) {
2930
- const mean = avg2(id);
2931
- const squareDiffs = id.map((value) => Math.pow(value - mean, 2));
2932
- const avgSquareDiff = sum2(squareDiffs) / size(id);
2933
- return Math.sqrt(avgSquareDiff);
2912
+ function stdev2(id, biased = true) {
2913
+ return Math.sqrt(variance2(id, biased));
2934
2914
  }
2935
- function variance2(id) {
2936
- const mean = avg2(id);
2937
- const squareDiffs = id.map((value) => Math.pow(value - mean, 2));
2938
- return sum2(squareDiffs) / size(id);
2915
+ function variance2(id, biased = true) {
2916
+ const values2 = id.filter((v) => !Number.isNaN(v));
2917
+ if (!values2.length) return NaN;
2918
+ const mean = values2.reduce((a, b2) => a + b2, 0) / values2.length;
2919
+ const squares = values2.reduce((a, b2) => a + (b2 - mean) * (b2 - mean), 0);
2920
+ return squares / (biased ? values2.length : values2.length - 1);
2939
2921
  }
2940
2922
  function fill(id, value, index_from = 0, index_to) {
2941
2923
  const end = index_to ?? id.length;
@@ -2943,8 +2925,8 @@ function fill(id, value, index_from = 0, index_to) {
2943
2925
  id[i] = value;
2944
2926
  }
2945
2927
  }
2946
- function from(id) {
2947
- return copy(id);
2928
+ function from(...values2) {
2929
+ return [...values2];
2948
2930
  }
2949
2931
  function first(id) {
2950
2932
  return id[0];
@@ -2952,38 +2934,38 @@ function first(id) {
2952
2934
  function last(id) {
2953
2935
  return id[id.length - 1];
2954
2936
  }
2955
- function some(id, predicate) {
2956
- return id.some(predicate);
2937
+ function some(id) {
2938
+ return id.some((v) => v === true);
2957
2939
  }
2958
- function every(id, predicate) {
2959
- return id.every(predicate);
2940
+ function every(id) {
2941
+ return id.length > 0 && id.every((v) => v === true);
2960
2942
  }
2961
- function new_bool(size2 = 0, initial_value = false) {
2962
- return new_array(size2, initial_value);
2943
+ function new_bool(size3 = 0, initial_value = false) {
2944
+ return new_array(size3, initial_value);
2963
2945
  }
2964
- function new_float(size2 = 0, initial_value = NaN) {
2965
- return new_array(size2, initial_value);
2946
+ function new_float(size3 = 0, initial_value = NaN) {
2947
+ return new_array(size3, initial_value);
2966
2948
  }
2967
- function new_int(size2 = 0, initial_value = NaN) {
2968
- return new_array(size2, initial_value);
2949
+ function new_int(size3 = 0, initial_value = NaN) {
2950
+ return new_array(size3, initial_value);
2969
2951
  }
2970
- function new_string(size2 = 0, initial_value) {
2971
- return new_array(size2, initial_value);
2952
+ function new_string(size3 = 0, initial_value) {
2953
+ return new_array(size3, initial_value);
2972
2954
  }
2973
- function new_color(size2 = 0, initial_value) {
2974
- return new_array(size2, initial_value);
2955
+ function new_color(size3 = 0, initial_value) {
2956
+ return new_array(size3, initial_value);
2975
2957
  }
2976
- function new_line(size2 = 0, initial_value) {
2977
- return new_array(size2, initial_value);
2958
+ function new_line(size3 = 0, initial_value) {
2959
+ return new_array(size3, initial_value);
2978
2960
  }
2979
- function new_box(size2 = 0, initial_value) {
2980
- return new_array(size2, initial_value);
2961
+ function new_box(size3 = 0, initial_value) {
2962
+ return new_array(size3, initial_value);
2981
2963
  }
2982
- function new_label(size2 = 0, initial_value) {
2983
- return new_array(size2, initial_value);
2964
+ function new_label(size3 = 0, initial_value) {
2965
+ return new_array(size3, initial_value);
2984
2966
  }
2985
- function new_linefill(size2 = 0, initial_value) {
2986
- return new_array(size2, initial_value);
2967
+ function new_linefill(size3 = 0, initial_value) {
2968
+ return new_array(size3, initial_value);
2987
2969
  }
2988
2970
  function abs2(id) {
2989
2971
  return id.map((x) => Math.abs(x));
@@ -3123,8 +3105,70 @@ function standardize(id) {
3123
3105
  }
3124
3106
  return id.map((value) => (value - mean) / stdDev);
3125
3107
  }
3126
- function newtype(size2 = 0, initial_value) {
3127
- return new_array(size2, initial_value);
3108
+ function newtype(size3 = 0, initial_value) {
3109
+ return new_array(size3, initial_value);
3110
+ }
3111
+
3112
+ // src/map/index.ts
3113
+ var map_exports = {};
3114
+ __export(map_exports, {
3115
+ MAX_SIZE: () => MAX_SIZE,
3116
+ clear: () => clear2,
3117
+ contains: () => contains,
3118
+ copy: () => copy2,
3119
+ get: () => get2,
3120
+ keys: () => keys,
3121
+ new_map: () => new_map,
3122
+ put: () => put,
3123
+ put_all: () => put_all,
3124
+ remove: () => remove2,
3125
+ size: () => size2,
3126
+ values: () => values
3127
+ });
3128
+ var MAX_SIZE = 5e4;
3129
+ function tooLarge(size3) {
3130
+ return new RangeError(`A map cannot have more than ${MAX_SIZE} key-value pairs. The current size is ${size3}.`);
3131
+ }
3132
+ function new_map() {
3133
+ return /* @__PURE__ */ new Map();
3134
+ }
3135
+ function put(id, key, value) {
3136
+ const previous = id.get(key);
3137
+ if (!id.has(key) && id.size >= MAX_SIZE) throw tooLarge(id.size + 1);
3138
+ id.set(key, value);
3139
+ return previous;
3140
+ }
3141
+ function put_all(id, id2) {
3142
+ let size3 = id.size;
3143
+ for (const key of id2.keys()) if (!id.has(key)) size3++;
3144
+ if (size3 > MAX_SIZE) throw tooLarge(size3);
3145
+ for (const [key, value] of id2) id.set(key, value);
3146
+ }
3147
+ function get2(id, key) {
3148
+ return id.get(key);
3149
+ }
3150
+ function contains(id, key) {
3151
+ return id.has(key);
3152
+ }
3153
+ function remove2(id, key) {
3154
+ const value = id.get(key);
3155
+ id.delete(key);
3156
+ return value;
3157
+ }
3158
+ function size2(id) {
3159
+ return id.size;
3160
+ }
3161
+ function clear2(id) {
3162
+ id.clear();
3163
+ }
3164
+ function keys(id) {
3165
+ return [...id.keys()];
3166
+ }
3167
+ function values(id) {
3168
+ return [...id.values()];
3169
+ }
3170
+ function copy2(id) {
3171
+ return new Map(id);
3128
3172
  }
3129
3173
 
3130
3174
  // src/str/index.ts
@@ -3132,7 +3176,7 @@ var str_exports = {};
3132
3176
  __export(str_exports, {
3133
3177
  charAt: () => charAt,
3134
3178
  concat: () => concat2,
3135
- contains: () => contains,
3179
+ contains: () => contains2,
3136
3180
  endswith: () => endswith,
3137
3181
  format: () => format,
3138
3182
  format_time: () => format_time,
@@ -3153,15 +3197,486 @@ __export(str_exports, {
3153
3197
  trimRight: () => trimRight,
3154
3198
  upper: () => upper
3155
3199
  });
3200
+
3201
+ // src/str/numberformat.ts
3202
+ var patterns = /* @__PURE__ */ new Map();
3203
+ function parsePattern(pattern) {
3204
+ const cached = patterns.get(pattern);
3205
+ if (cached) return cached;
3206
+ let prefix = "";
3207
+ let suffix = "";
3208
+ let number2 = "";
3209
+ let percent = false;
3210
+ let phase = "prefix";
3211
+ for (let i = 0; i < pattern.length; i++) {
3212
+ const ch = pattern[i];
3213
+ let literal;
3214
+ if (ch === "'") {
3215
+ const end = pattern.indexOf("'", i + 1);
3216
+ if (end === i + 1) {
3217
+ literal = "'";
3218
+ i = end;
3219
+ } else {
3220
+ literal = pattern.slice(i + 1, end === -1 ? void 0 : end);
3221
+ i = end === -1 ? pattern.length : end;
3222
+ }
3223
+ } else if (phase !== "suffix" && ("#0,.".includes(ch) || phase === "number" && ch === "E")) {
3224
+ phase = "number";
3225
+ number2 += ch;
3226
+ continue;
3227
+ } else {
3228
+ if (ch === "%") percent = true;
3229
+ literal = ch;
3230
+ }
3231
+ if (phase === "number") phase = "suffix";
3232
+ if (phase === "prefix") prefix += literal;
3233
+ else suffix += literal;
3234
+ }
3235
+ const [mantissa = "", exp2] = number2.split("E");
3236
+ const [intPart = "", fracPart = ""] = mantissa.split(".");
3237
+ const lastComma = intPart.lastIndexOf(",");
3238
+ const parsed = {
3239
+ prefix,
3240
+ suffix,
3241
+ // as in Java, a pattern with a decimal point and no '0' at all ("#.##") shows one integer digit
3242
+ minInt: !mantissa.includes("0") && mantissa.includes(".") ? 1 : [...intPart].filter((c) => c === "0").length,
3243
+ minFrac: [...fracPart].filter((c) => c === "0").length,
3244
+ maxFrac: [...fracPart].filter((c) => c === "0" || c === "#").length,
3245
+ grouping: lastComma === -1 ? 0 : intPart.length - lastComma - 1,
3246
+ percent,
3247
+ exponent: exp2 === void 0 ? null : exp2.length,
3248
+ hasDigits: /[0#]/.test(mantissa)
3249
+ };
3250
+ patterns.set(pattern, parsed);
3251
+ return parsed;
3252
+ }
3253
+ function shortestDigits(x) {
3254
+ const m = /^(\d+)(?:\.(\d+))?(?:e([+-]\d+))?$/.exec(String(Math.abs(x)));
3255
+ const all7 = m[1] + (m[2] ?? "");
3256
+ let intLen = m[1].length + Number(m[3] ?? 0);
3257
+ const lead = all7.length - all7.replace(/^0+/, "").length;
3258
+ intLen -= lead;
3259
+ const digits = all7.slice(lead).replace(/0+$/, "");
3260
+ return { digits, intLen: digits ? intLen : 0 };
3261
+ }
3262
+ function exactDigits(x) {
3263
+ const abs3 = Math.abs(x);
3264
+ if (abs3 === 0) return { digits: "", intLen: 0 };
3265
+ const view = new DataView(new ArrayBuffer(8));
3266
+ view.setFloat64(0, abs3);
3267
+ const bits = view.getBigUint64(0);
3268
+ const expBits = Number(bits >> 52n & 0x7ffn);
3269
+ let mant = bits & 0xfffffffffffffn;
3270
+ const e2 = expBits === 0 ? -1074 : expBits - 1075;
3271
+ if (expBits !== 0) mant |= 1n << 52n;
3272
+ let str;
3273
+ let fracDigits;
3274
+ if (e2 >= 0) {
3275
+ str = (mant << BigInt(e2)).toString();
3276
+ fracDigits = 0;
3277
+ } else {
3278
+ str = (mant * 5n ** BigInt(-e2)).toString();
3279
+ fracDigits = -e2;
3280
+ }
3281
+ const intLen = str.length - fracDigits;
3282
+ const lead = str.length - str.replace(/^0+/, "").length;
3283
+ const digits = str.slice(lead).replace(/0+$/, "");
3284
+ return { digits, intLen: intLen - lead };
3285
+ }
3286
+ function roundDigits(d, frac, mode5) {
3287
+ const keep = d.intLen + frac;
3288
+ if (keep >= d.digits.length) return d;
3289
+ if (keep < 0) return { digits: "", intLen: 0 };
3290
+ const first2 = d.digits.charCodeAt(keep) - 48;
3291
+ let up;
3292
+ if (mode5 === "halfUpShortest") up = first2 >= 5;
3293
+ else if (first2 !== 5) up = first2 > 5;
3294
+ else if (d.digits.length > keep + 1) up = true;
3295
+ else up = keep > 0 && (d.digits.charCodeAt(keep - 1) - 48) % 2 === 1;
3296
+ let kept = d.digits.slice(0, keep);
3297
+ let intLen = d.intLen;
3298
+ if (up) {
3299
+ const n = (BigInt(kept || "0") + 1n).toString();
3300
+ if (n.length > kept.length) intLen += 1;
3301
+ kept = n;
3302
+ }
3303
+ kept = kept.replace(/0+$/, "");
3304
+ return { digits: kept, intLen: kept ? intLen : 0 };
3305
+ }
3306
+ function group(int, size3) {
3307
+ if (!size3 || int.length <= size3) return int;
3308
+ const parts = [];
3309
+ for (let end = int.length; end > 0; end -= size3) parts.unshift(int.slice(Math.max(0, end - size3), end));
3310
+ return parts.join(",");
3311
+ }
3312
+ function layout(d, p) {
3313
+ let int = d.intLen > 0 ? d.digits.slice(0, d.intLen).padEnd(d.intLen, "0") : "";
3314
+ int = int.replace(/^0+/, "").padStart(p.minInt, "0");
3315
+ let frac = d.intLen < 0 ? "0".repeat(-d.intLen) + d.digits : d.digits.slice(Math.max(0, d.intLen));
3316
+ frac = frac.slice(0, p.maxFrac).replace(/0+$/, "").padEnd(p.minFrac, "0");
3317
+ if (!int && !frac) int = "0";
3318
+ return group(int, p.grouping) + (frac ? "." + frac : "");
3319
+ }
3320
+ function formatNumber(value, pattern, mode5) {
3321
+ if (Number.isNaN(value)) return "NaN";
3322
+ const p = parsePattern(pattern);
3323
+ if (!Number.isFinite(value)) return (value < 0 ? "-" : "") + p.prefix + "\u221E" + p.suffix;
3324
+ const x = p.percent ? value * 100 : value;
3325
+ const toDigits = mode5 === "halfUpShortest" ? shortestDigits : exactDigits;
3326
+ let body;
3327
+ let isZero;
3328
+ if (p.exponent !== null) {
3329
+ const rounded = roundDigits(toDigits(x), p.maxFrac, mode5);
3330
+ const intDigits = Math.max(p.minInt, 1);
3331
+ isZero = rounded.digits === "";
3332
+ let exponent = isZero ? 0 : rounded.intLen - intDigits;
3333
+ let mant = roundDigits({ digits: rounded.digits, intLen: isZero ? 0 : intDigits }, p.maxFrac, mode5);
3334
+ if (mant.intLen > intDigits) {
3335
+ exponent += 1;
3336
+ mant = { digits: mant.digits, intLen: intDigits };
3337
+ }
3338
+ const e2 = String(Math.abs(exponent)).padStart(p.exponent, "0");
3339
+ body = layout(mant, p) + "E" + (exponent < 0 ? "-" : "") + e2;
3340
+ } else {
3341
+ const rounded = roundDigits(toDigits(x), p.hasDigits ? p.maxFrac : 0, mode5);
3342
+ isZero = rounded.digits === "";
3343
+ body = p.hasDigits ? layout(rounded, p) : layout(rounded, { ...p, minInt: 0, maxFrac: 0, minFrac: 0 });
3344
+ }
3345
+ const negative = x < 0 && (!isZero || !p.hasDigits);
3346
+ return (negative ? "-" : "") + p.prefix + body + p.suffix;
3347
+ }
3348
+
3349
+ // src/time/timezone.ts
3350
+ var MS_PER_SECOND = 1e3;
3351
+ var MS_PER_DAY = 864e5;
3352
+ var MAX_OFFSET_SECONDS = 18 * 3600;
3353
+ var OFFSET_NOTATION = /^(?:UTC|GMT)(?:([+-])(\d{1,2})(?::?(\d{2})(?::?(\d{2}))?)?)?$/;
3354
+ var REJECTED_NAMES = /* @__PURE__ */ new Set(["EST", "MST", "HST"]);
3355
+ var canonicalNames;
3356
+ function hasTimeZoneCase(name) {
3357
+ if (name.split("/").some((segment) => !/^[A-Z]/.test(segment))) return false;
3358
+ canonicalNames ??= new Map(Intl.supportedValuesOf("timeZone").map((n) => [n.toLowerCase(), n]));
3359
+ const canonical = canonicalNames.get(name.toLowerCase());
3360
+ return canonical === void 0 || canonical === name;
3361
+ }
3362
+ var zones = /* @__PURE__ */ new Map();
3363
+ function resolveZone(timezone) {
3364
+ let zone = zones.get(timezone);
3365
+ if (zone) return zone;
3366
+ const invalid = () => new RangeError(
3367
+ `Invalid time zone "${timezone}": use UTC/GMT offset notation ("UTC-5", "GMT+0530") or an IANA name ("America/New_York")`
3368
+ );
3369
+ const m = OFFSET_NOTATION.exec(timezone);
3370
+ if (m) {
3371
+ const [, sign2, h = "0", mi = "0", s] = m;
3372
+ const minutes = Number(mi);
3373
+ const seconds = s === void 0 ? 0 : Number(s);
3374
+ if (minutes > 59 || seconds > 59 || s !== void 0 && h.length !== 2) throw invalid();
3375
+ const offsetSeconds = Number(h) * 3600 + minutes * 60 + seconds;
3376
+ if (offsetSeconds > MAX_OFFSET_SECONDS) throw invalid();
3377
+ zone = { kind: "fixed", offsetMs: (sign2 === "-" ? -offsetSeconds : offsetSeconds) * MS_PER_SECOND };
3378
+ } else {
3379
+ if (REJECTED_NAMES.has(timezone) || !hasTimeZoneCase(timezone)) throw invalid();
3380
+ let format2;
3381
+ try {
3382
+ format2 = new Intl.DateTimeFormat("en-US", {
3383
+ timeZone: timezone,
3384
+ hourCycle: "h23",
3385
+ year: "numeric",
3386
+ month: "numeric",
3387
+ day: "numeric",
3388
+ hour: "numeric",
3389
+ minute: "numeric",
3390
+ second: "numeric"
3391
+ });
3392
+ } catch {
3393
+ throw invalid();
3394
+ }
3395
+ zone = { kind: "iana", format: format2 };
3396
+ }
3397
+ zones.set(timezone, zone);
3398
+ return zone;
3399
+ }
3400
+ function offsetAt(zone, time) {
3401
+ if (zone.kind === "fixed") return zone.offsetMs;
3402
+ const wholeSecond = Math.floor(time / 1e3) * 1e3;
3403
+ const f = {};
3404
+ for (const part of zone.format.formatToParts(wholeSecond)) {
3405
+ if (part.type !== "literal") f[part.type] = Number(part.value);
3406
+ }
3407
+ const local = Date.UTC(f.year, f.month - 1, f.day, f.hour, f.minute, f.second);
3408
+ return local - wholeSecond;
3409
+ }
3410
+ function zoneOffset(time, timezone) {
3411
+ return offsetAt(resolveZone(timezone), time);
3412
+ }
3413
+ function zonedFields(time, timezone) {
3414
+ const local = new Date(time + offsetAt(resolveZone(timezone), time));
3415
+ return {
3416
+ year: local.getUTCFullYear(),
3417
+ month: local.getUTCMonth() + 1,
3418
+ day: local.getUTCDate(),
3419
+ hour: local.getUTCHours(),
3420
+ minute: local.getUTCMinutes(),
3421
+ second: local.getUTCSeconds(),
3422
+ dayOfWeek: local.getUTCDay() + 1
3423
+ };
3424
+ }
3425
+ function zonedToUnix(timezone, year2, month2, day, hour2 = 0, minute2 = 0, second2 = 0) {
3426
+ const zone = resolveZone(timezone);
3427
+ const local = Date.UTC(year2, month2 - 1, day, hour2, minute2, second2);
3428
+ if (zone.kind === "fixed") return local - zone.offsetMs;
3429
+ const before = offsetAt(zone, local - MS_PER_DAY);
3430
+ const after = offsetAt(zone, local + MS_PER_DAY);
3431
+ const candidates = [local - before, local - after].filter((t2) => local - offsetAt(zone, t2) === t2);
3432
+ if (candidates.length) return Math.max(...candidates);
3433
+ return local - before;
3434
+ }
3435
+
3436
+ // src/str/dateformat.ts
3437
+ var MONTHS = [
3438
+ "January",
3439
+ "February",
3440
+ "March",
3441
+ "April",
3442
+ "May",
3443
+ "June",
3444
+ "July",
3445
+ "August",
3446
+ "September",
3447
+ "October",
3448
+ "November",
3449
+ "December"
3450
+ ];
3451
+ var DAYS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
3452
+ var pad = (n, width) => String(n).padStart(width, "0");
3453
+ function zoneName(time, timezone, offsetMs) {
3454
+ if (timezone === "Etc/UTC") return "UTC";
3455
+ if (/^(UTC|GMT)/.test(timezone)) {
3456
+ if (offsetMs === 0) return "GMT";
3457
+ const minutes = Math.abs(offsetMs) / 6e4;
3458
+ return `GMT${offsetMs < 0 ? "-" : "+"}${pad(Math.floor(minutes / 60), 2)}:${pad(minutes % 60, 2)}`;
3459
+ }
3460
+ const part = new Intl.DateTimeFormat("en-US", { timeZone: timezone, timeZoneName: "short" }).formatToParts(time).find((p) => p.type === "timeZoneName");
3461
+ return part?.value ?? timezone;
3462
+ }
3463
+ function weekOfYear(year2, month2, day) {
3464
+ const date = Date.UTC(year2, month2 - 1, day);
3465
+ const dow = new Date(date).getUTCDay();
3466
+ const weekStart = date - dow * 864e5;
3467
+ if (weekStart + 6 * 864e5 >= Date.UTC(year2 + 1, 0, 1)) return 1;
3468
+ const jan1 = Date.UTC(year2, 0, 1);
3469
+ const jan1Dow = new Date(jan1).getUTCDay();
3470
+ return Math.floor((date - jan1 + jan1Dow * 864e5) / (7 * 864e5)) + 1;
3471
+ }
3472
+ function formatDate(time, pattern, timezone) {
3473
+ if (Number.isNaN(time)) return "NaN";
3474
+ const f = zonedFields(time, timezone);
3475
+ const offset = zoneOffset(time, timezone);
3476
+ const ms = (time % 1e3 + 1e3) % 1e3;
3477
+ const dayOfYear = (Date.UTC(f.year, f.month - 1, f.day) - Date.UTC(f.year, 0, 1)) / 864e5 + 1;
3478
+ let out = "";
3479
+ for (let i = 0; i < pattern.length; ) {
3480
+ const ch = pattern[i];
3481
+ if (ch === "'") {
3482
+ const end = pattern.indexOf("'", i + 1);
3483
+ if (end === i + 1) {
3484
+ out += "'";
3485
+ i += 2;
3486
+ } else {
3487
+ out += pattern.slice(i + 1, end === -1 ? void 0 : end);
3488
+ i = end === -1 ? pattern.length : end + 1;
3489
+ }
3490
+ continue;
3491
+ }
3492
+ if (!/[A-Za-z]/.test(ch)) {
3493
+ out += ch;
3494
+ i++;
3495
+ continue;
3496
+ }
3497
+ let n = 1;
3498
+ while (pattern[i + n] === ch) n++;
3499
+ i += n;
3500
+ const hour12 = f.hour % 12;
3501
+ switch (ch) {
3502
+ case "y":
3503
+ out += n === 2 ? pad(f.year % 100, 2) : pad(f.year, n);
3504
+ break;
3505
+ case "M":
3506
+ out += n >= 4 ? MONTHS[f.month - 1] : n === 3 ? MONTHS[f.month - 1].slice(0, 3) : pad(f.month, n);
3507
+ break;
3508
+ case "d":
3509
+ out += pad(f.day, n);
3510
+ break;
3511
+ case "E":
3512
+ out += n >= 4 ? DAYS[f.dayOfWeek - 1] : DAYS[f.dayOfWeek - 1].slice(0, 3);
3513
+ break;
3514
+ case "u":
3515
+ out += pad(f.dayOfWeek === 1 ? 7 : f.dayOfWeek - 1, n);
3516
+ break;
3517
+ case "D":
3518
+ out += pad(dayOfYear, n);
3519
+ break;
3520
+ case "w":
3521
+ out += pad(weekOfYear(f.year, f.month, f.day), n);
3522
+ break;
3523
+ case "H":
3524
+ out += pad(f.hour, n);
3525
+ break;
3526
+ case "k":
3527
+ out += pad(f.hour === 0 ? 24 : f.hour, n);
3528
+ break;
3529
+ case "K":
3530
+ out += pad(hour12, n);
3531
+ break;
3532
+ case "h":
3533
+ out += pad(hour12 === 0 ? 12 : hour12, n);
3534
+ break;
3535
+ case "a":
3536
+ out += f.hour < 12 ? "AM" : "PM";
3537
+ break;
3538
+ case "m":
3539
+ out += pad(f.minute, n);
3540
+ break;
3541
+ case "s":
3542
+ out += pad(f.second, n);
3543
+ break;
3544
+ case "S":
3545
+ out += pad(ms, n);
3546
+ break;
3547
+ case "Z": {
3548
+ const minutes = Math.abs(offset) / 6e4;
3549
+ out += (offset < 0 ? "-" : "+") + pad(Math.floor(minutes / 60), 2) + pad(minutes % 60, 2);
3550
+ break;
3551
+ }
3552
+ case "z":
3553
+ out += zoneName(time, timezone, offset);
3554
+ break;
3555
+ default:
3556
+ throw new SyntaxError(`Unsupported date pattern letter "${ch}" in "${pattern}"`);
3557
+ }
3558
+ }
3559
+ return out;
3560
+ }
3561
+
3562
+ // src/str/messageformat.ts
3563
+ var DATE_STYLES = {
3564
+ short: "M/d/yy",
3565
+ medium: "MMM d, yyyy",
3566
+ long: "MMMM d, yyyy",
3567
+ full: "EEEE, MMMM d, yyyy"
3568
+ };
3569
+ var TIME_STYLES = {
3570
+ short: "h:mm\u202Fa",
3571
+ medium: "h:mm:ss\u202Fa",
3572
+ long: "h:mm:ss\u202Fa z",
3573
+ full: "h:mm:ss\u202Fa z"
3574
+ };
3575
+ function number(value, pattern) {
3576
+ return typeof value === "number" ? formatNumber(value, pattern, "halfEvenExact") : String(value);
3577
+ }
3578
+ function choice(value, spec) {
3579
+ const options = spec.split("|").map((part) => {
3580
+ const m = /^\s*(-?[\d.]+|-?∞)\s*([#<≤])(.*)$/.exec(part);
3581
+ if (!m) throw new SyntaxError(`Invalid choice format "${spec}"`);
3582
+ const limit = m[1].includes("\u221E") ? m[1].startsWith("-") ? -Infinity : Infinity : Number(m[1]);
3583
+ return { limit: m[2] === "<" ? limit + Number.EPSILON * Math.max(1, Math.abs(limit)) : limit, text: m[3] };
3584
+ });
3585
+ let chosen = options[0];
3586
+ for (const o of options) if (value >= o.limit) chosen = o;
3587
+ return chosen.text;
3588
+ }
3589
+ function formatArgument(value, type, style, timezone) {
3590
+ if (value === void 0) return "";
3591
+ if (!type) return typeof value === "number" ? number(value, "#,##0.###") : String(value);
3592
+ switch (type.trim()) {
3593
+ case "number": {
3594
+ const s = style?.trim();
3595
+ if (!s) return number(value, "#,##0.###");
3596
+ if (s === "integer") return number(value, "#,##0");
3597
+ if (s === "percent") return number(value, "#,##0%");
3598
+ if (s === "currency") return number(value, "'$'#,##0.00");
3599
+ return number(value, style);
3600
+ }
3601
+ case "date":
3602
+ case "time": {
3603
+ const styles = type.trim() === "date" ? DATE_STYLES : TIME_STYLES;
3604
+ const s = style?.trim() ?? "medium";
3605
+ return formatDate(Number(value), styles[s] ?? style, typeof timezone === "function" ? timezone() : timezone);
3606
+ }
3607
+ case "choice":
3608
+ return choice(Number(value), style ?? "");
3609
+ default:
3610
+ throw new SyntaxError(`Unknown format type "${type}"`);
3611
+ }
3612
+ }
3613
+ function formatMessage(pattern, args, timezone) {
3614
+ let out = "";
3615
+ for (let i = 0; i < pattern.length; ) {
3616
+ const ch = pattern[i];
3617
+ if (ch === "'") {
3618
+ if (pattern[i + 1] === "'") {
3619
+ out += "'";
3620
+ i += 2;
3621
+ continue;
3622
+ }
3623
+ const end = pattern.indexOf("'", i + 1);
3624
+ out += pattern.slice(i + 1, end === -1 ? void 0 : end);
3625
+ i = end === -1 ? pattern.length : end + 1;
3626
+ continue;
3627
+ }
3628
+ if (ch !== "{") {
3629
+ out += ch;
3630
+ i++;
3631
+ continue;
3632
+ }
3633
+ let depth = 1;
3634
+ let j = i + 1;
3635
+ let inQuote = false;
3636
+ for (; j < pattern.length && depth > 0; j++) {
3637
+ const c = pattern[j];
3638
+ if (c === "'") inQuote = !inQuote;
3639
+ else if (!inQuote && c === "{") depth++;
3640
+ else if (!inQuote && c === "}") depth--;
3641
+ }
3642
+ const inner = pattern.slice(i + 1, j - 1);
3643
+ const [index = "", type, ...rest] = inner.split(",");
3644
+ const style = rest.length ? rest.join(",") : void 0;
3645
+ const n = Number(index.trim());
3646
+ out += n < args.length ? formatArgument(args[n], type, style, timezone) : `{${inner}}`;
3647
+ i = j;
3648
+ }
3649
+ return out;
3650
+ }
3651
+
3652
+ // src/str/index.ts
3156
3653
  function length(str) {
3157
3654
  return str.length;
3158
3655
  }
3159
3656
  function tostring(value, format2) {
3160
- if (typeof value === "number" && format2) {
3161
- const decimals = format2.split(".")[1]?.length || 0;
3162
- return value.toFixed(decimals);
3657
+ if (typeof value !== "number") return String(value);
3658
+ if (!Number.isFinite(value)) return String(value);
3659
+ if (format2 === void 0 || format2 === "") {
3660
+ if (Math.abs(value) >= 1e21 && Number.isFinite(value)) {
3661
+ return String(value).replace("e+", "E").replace(/\.0+E/, "E");
3662
+ }
3663
+ return formatNumber(value, "#.##########", "halfUpShortest");
3664
+ }
3665
+ switch (format2) {
3666
+ case "percent":
3667
+ return formatNumber(value, "0.00", "halfUpShortest") + "%";
3668
+ case "volume": {
3669
+ const abs3 = Math.abs(value);
3670
+ for (const [size3, unit] of [[1e12, "T"], [1e9, "B"], [1e6, "M"], [1e3, "K"]]) {
3671
+ if (abs3 >= size3) return formatNumber(value / size3, "#.###", "halfUpShortest") + unit;
3672
+ }
3673
+ return formatNumber(value, "#", "halfUpShortest");
3674
+ }
3675
+ case "mintick":
3676
+ throw new Error("str.tostring(x, format.mintick) needs the symbol tick size (syminfo.mintick), which is not known here");
3677
+ default:
3678
+ return formatNumber(value, format2, "halfUpShortest");
3163
3679
  }
3164
- return String(value);
3165
3680
  }
3166
3681
  function tonumber(str) {
3167
3682
  const num = parseFloat(str);
@@ -3176,7 +3691,7 @@ function upper(str) {
3176
3691
  function lower(str) {
3177
3692
  return str.toLowerCase();
3178
3693
  }
3179
- function contains(source, str) {
3694
+ function contains2(source, str) {
3180
3695
  return source.includes(str);
3181
3696
  }
3182
3697
  function pos(source, str) {
@@ -3199,11 +3714,7 @@ function concat2(...strings) {
3199
3714
  return strings.join("");
3200
3715
  }
3201
3716
  function format(formatStr, ...args) {
3202
- let result = formatStr;
3203
- args.forEach((arg, index) => {
3204
- result = result.replaceAll(`{${index}}`, String(arg));
3205
- });
3206
- return result;
3717
+ return formatMessage(formatStr, args, "Etc/UTC");
3207
3718
  }
3208
3719
  function startswith(source, str) {
3209
3720
  return source.startsWith(str);
@@ -3231,84 +3742,8 @@ function repeat(source, count, separator = "") {
3231
3742
  if (count <= 0) return "";
3232
3743
  return Array(count).fill(source).join(separator);
3233
3744
  }
3234
- function format_time(time, format2) {
3235
- const date = new Date(time);
3236
- const monthNames = [
3237
- "January",
3238
- "February",
3239
- "March",
3240
- "April",
3241
- "May",
3242
- "June",
3243
- "July",
3244
- "August",
3245
- "September",
3246
- "October",
3247
- "November",
3248
- "December"
3249
- ];
3250
- const monthNamesShort = [
3251
- "Jan",
3252
- "Feb",
3253
- "Mar",
3254
- "Apr",
3255
- "May",
3256
- "Jun",
3257
- "Jul",
3258
- "Aug",
3259
- "Sep",
3260
- "Oct",
3261
- "Nov",
3262
- "Dec"
3263
- ];
3264
- const year = date.getUTCFullYear();
3265
- const month = date.getUTCMonth();
3266
- const day = date.getUTCDate();
3267
- const hours = date.getUTCHours();
3268
- const minutes = date.getUTCMinutes();
3269
- const seconds = date.getUTCSeconds();
3270
- const pad = (num, len = 2) => num.toString().padStart(len, "0");
3271
- const hours12 = hours % 12 || 12;
3272
- const ampm = hours < 12 ? "AM" : "PM";
3273
- const replacements = [
3274
- // Year (process yyyy before yy)
3275
- [/yyyy/g, year.toString()],
3276
- [/yy/g, year.toString().slice(-2)],
3277
- // Month (process MMMM before MMM before MM before M)
3278
- [/MMMM/g, monthNames[month]],
3279
- [/MMM/g, monthNamesShort[month]],
3280
- [/MM/g, pad(month + 1)],
3281
- [/M/g, (month + 1).toString()],
3282
- // Day (process dd before d)
3283
- [/dd/g, pad(day)],
3284
- [/d/g, day.toString()],
3285
- // Hours 24-hour (process HH before H)
3286
- [/HH/g, pad(hours)],
3287
- [/H/g, hours.toString()],
3288
- // Hours 12-hour (process hh before h)
3289
- [/hh/g, pad(hours12)],
3290
- [/h/g, hours12.toString()],
3291
- // Minutes (process mm before m)
3292
- [/mm/g, pad(minutes)],
3293
- [/m/g, minutes.toString()],
3294
- // Seconds (process ss before s)
3295
- [/ss/g, pad(seconds)],
3296
- [/s/g, seconds.toString()],
3297
- // AM/PM
3298
- [/a/g, ampm]
3299
- ];
3300
- let result = format2;
3301
- const tokens = [];
3302
- replacements.forEach(([pattern, value], index) => {
3303
- const token = `\uFFF0${index}\uFFF1`;
3304
- result = result.replace(pattern, token);
3305
- tokens[index] = value;
3306
- });
3307
- tokens.forEach((value, index) => {
3308
- const token = `\uFFF0${index}\uFFF1`;
3309
- result = result.replaceAll(token, value);
3310
- });
3311
- return result;
3745
+ function format_time(time, format2 = "yyyy-MM-dd'T'HH:mm:ssZ", timezone = "Etc/UTC") {
3746
+ return formatDate(time, format2, timezone);
3312
3747
  }
3313
3748
 
3314
3749
  // src/color/index.ts
@@ -3406,16 +3841,16 @@ var teal = "#008080";
3406
3841
  var white = "#FFFFFF";
3407
3842
  var yellow = "#FFFF00";
3408
3843
  function from_gradient(value, bottom_value, top_value, bottom_color, top_color) {
3409
- const parseColor2 = (col2) => {
3410
- if (typeof col2 === "string") {
3411
- if (col2.startsWith("#")) {
3412
- const hex = col2.slice(1);
3844
+ const parseColor2 = (col3) => {
3845
+ if (typeof col3 === "string") {
3846
+ if (col3.startsWith("#")) {
3847
+ const hex = col3.slice(1);
3413
3848
  const r4 = parseInt(hex.slice(0, 2), 16);
3414
3849
  const g4 = parseInt(hex.slice(2, 4), 16);
3415
3850
  const b4 = parseInt(hex.slice(4, 6), 16);
3416
3851
  return [r4, g4, b4, 1];
3417
3852
  }
3418
- const match2 = col2.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);
3853
+ const match2 = col3.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);
3419
3854
  if (match2) {
3420
3855
  return [
3421
3856
  parseInt(match2[1]),
@@ -3450,21 +3885,260 @@ function from_gradient(value, bottom_value, top_value, bottom_color, top_color)
3450
3885
  // src/time/index.ts
3451
3886
  var time_exports = {};
3452
3887
  __export(time_exports, {
3888
+ dayofmonth: () => dayofmonth,
3889
+ dayofweek: () => dayofweek,
3890
+ hour: () => hour,
3891
+ inSession: () => inSession2,
3892
+ minute: () => minute,
3893
+ month: () => month,
3453
3894
  now: () => now,
3454
- timestamp: () => timestamp
3895
+ second: () => second,
3896
+ timestamp: () => timestamp,
3897
+ weekofyear: () => weekofyear,
3898
+ year: () => year
3455
3899
  });
3900
+
3901
+ // src/time/datestring.ts
3902
+ var MONTHS2 = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
3903
+ var FULL_MONTHS = [
3904
+ "january",
3905
+ "february",
3906
+ "march",
3907
+ "april",
3908
+ "may",
3909
+ "june",
3910
+ "july",
3911
+ "august",
3912
+ "september",
3913
+ "october",
3914
+ "november",
3915
+ "december"
3916
+ ];
3917
+ var ZONE_NAMES = {
3918
+ ut: 0,
3919
+ utc: 0,
3920
+ gmt: 0,
3921
+ est: -5,
3922
+ edt: -4,
3923
+ cst: -6,
3924
+ cdt: -5,
3925
+ mst: -7,
3926
+ mdt: -6,
3927
+ pst: -8,
3928
+ pdt: -7
3929
+ };
3930
+ var TIME = String.raw`(\d{1,2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3})\d*)?)?`;
3931
+ var ZONE = String.raw`(ut|utc|gmt|[ecmp][sd]t|(?:utc|gmt)?\s*[+-]\d{1,2}(?::?\d{2})?)`;
3932
+ var NUMERIC_ZONE = String.raw`([+-]\d{2}(?::?\d{2})?)`;
3933
+ var DATE = String.raw`(\d{4})([-/])(\d{1,2})\2(\d{1,2})`;
3934
+ var WEEKDAY = String.raw`(?:[a-z]{3,9},?\s+)?`;
3935
+ var ISO_T = new RegExp(String.raw`^${DATE}t${TIME}\s*${NUMERIC_ZONE}?$`, "i");
3936
+ var ISO = new RegExp(String.raw`^${DATE}(?:\s+${TIME})?\s*${ZONE}?$`, "i");
3937
+ var DAY_FIRST = new RegExp(String.raw`^${WEEKDAY}(\d{1,2})(?:\s+|-)([a-z]+)\.?,?(?:\s+|-)(\d{4})(?:,?\s+${TIME})?\s*${ZONE}?$`, "i");
3938
+ var MONTH_FIRST = new RegExp(String.raw`^${WEEKDAY}([a-z]+)\.?\s+(\d{1,2}),?\s+(\d{4})(?:,?\s+${TIME})?\s*${ZONE}?$`, "i");
3939
+ function monthNumber(name) {
3940
+ const lower2 = name.toLowerCase();
3941
+ const i = FULL_MONTHS.findIndex((full, k) => lower2.startsWith(MONTHS2[k]) && full.startsWith(lower2));
3942
+ return i + 1;
3943
+ }
3944
+ function zoneMinutes(zone) {
3945
+ if (!zone) return 0;
3946
+ const lower2 = zone.toLowerCase().replace(/\s+/g, "");
3947
+ const named = ZONE_NAMES[lower2];
3948
+ if (named !== void 0) return named * 60;
3949
+ const m = /^(?:utc|gmt)?([+-])(\d{1,2})(?::?(\d{2}))?$/.exec(lower2);
3950
+ if (!m) return NaN;
3951
+ const minutes = Number(m[2]) * 60 + (m[3] ? Number(m[3]) : 0);
3952
+ return m[1] === "-" ? -minutes : minutes;
3953
+ }
3954
+ function parseDateString(dateString) {
3955
+ const text = dateString.trim();
3956
+ let year2, month2, day;
3957
+ let rest;
3958
+ let m;
3959
+ if (m = ISO_T.exec(text) ?? ISO.exec(text)) {
3960
+ [year2, month2, day] = [m[1], Number(m[3]), m[4]];
3961
+ rest = m.slice(5);
3962
+ } else if (m = DAY_FIRST.exec(text)) {
3963
+ [day, month2, year2] = [m[1], monthNumber(m[2]), m[3]];
3964
+ rest = m.slice(4);
3965
+ } else if (m = MONTH_FIRST.exec(text)) {
3966
+ [month2, day, year2] = [monthNumber(m[1]), m[2], m[3]];
3967
+ rest = m.slice(4);
3968
+ } else {
3969
+ throw new SyntaxError(`Invalid date string "${dateString}": use RFC 2822 or ISO 8601 ("20 Feb 2020", "2020-02-20T14:48:00")`);
3970
+ }
3971
+ const [hour2 = "0", minute2 = "0", second2 = "0", millis = "0", zone] = rest;
3972
+ const d = Number(day);
3973
+ const h = Number(hour2);
3974
+ const mi = Number(minute2);
3975
+ const s = Number(second2);
3976
+ const offset = zoneMinutes(zone);
3977
+ const endOfDay = h === 24 && mi === 0 && s === 0 && Number(millis) === 0;
3978
+ if (month2 < 1 || month2 > 12 || d < 1 || d > 31 || h > 23 && !endOfDay || mi > 59 || s > 59 || Number.isNaN(offset)) {
3979
+ throw new SyntaxError(`Invalid date string "${dateString}": a field is out of range`);
3980
+ }
3981
+ const ms = Number(millis.padEnd(3, "0"));
3982
+ return Date.UTC(Number(year2), month2 - 1, d, h, mi, s, ms) - offset * 6e4;
3983
+ }
3984
+
3985
+ // src/time/session.ts
3986
+ var PERIOD = /^(\d{2})(\d{2})-(\d{2})(\d{2})$/;
3987
+ var sessions = /* @__PURE__ */ new Map();
3988
+ function parseSession(session) {
3989
+ let parsed = sessions.get(session);
3990
+ if (parsed) return parsed;
3991
+ const invalid = () => new SyntaxError(`Invalid session "${session}": expected "HHmm-HHmm[,HHmm-HHmm...][:days]"`);
3992
+ const text = session.trim() === "24x7" ? "0000-0000" : session.replace(/\s+/g, "");
3993
+ const [periodText = "", dayText, extra] = text.split(":");
3994
+ if (extra !== void 0 || periodText === "") throw invalid();
3995
+ const periods = periodText.split(",").map((p) => {
3996
+ const m = PERIOD.exec(p);
3997
+ if (!m) throw invalid();
3998
+ const [h1, m1, h2, m2] = [m[1], m[2], m[3], m[4]].map(Number);
3999
+ if (h1 > 23 || h2 > 23 || m1 > 59 || m2 > 59) throw invalid();
4000
+ return { start: h1 * 60 + m1, end: h2 * 60 + m2 };
4001
+ });
4002
+ const dayDigits = dayText ?? (periods.length > 1 ? "23456" : "1234567");
4003
+ if (!/^[1-7]+$/.test(dayDigits)) throw invalid();
4004
+ const days = new Array(8).fill(false);
4005
+ for (const d of dayDigits) days[Number(d)] = true;
4006
+ parsed = { periods, days };
4007
+ sessions.set(session, parsed);
4008
+ return parsed;
4009
+ }
4010
+ function inSession(time, session, timezone) {
4011
+ if (Number.isNaN(time)) return false;
4012
+ const { periods, days } = parseSession(session);
4013
+ const f = zonedFields(time, timezone);
4014
+ const minute2 = f.hour * 60 + f.minute;
4015
+ const nextDay = f.dayOfWeek % 7 + 1;
4016
+ for (const { start, end } of periods) {
4017
+ if (start < end || start === 0 && end === 0) {
4018
+ if (minute2 >= start && (minute2 < end || end === 0) && days[f.dayOfWeek]) return true;
4019
+ } else {
4020
+ if (minute2 >= start && days[nextDay]) return true;
4021
+ if (minute2 < end && days[f.dayOfWeek]) return true;
4022
+ }
4023
+ }
4024
+ return false;
4025
+ }
4026
+
4027
+ // src/time/index.ts
3456
4028
  function now() {
3457
4029
  return Date.now();
3458
4030
  }
3459
- function timestamp(year, month, day, hour, minute, second) {
3460
- return new Date(
3461
- year,
3462
- month - 1,
3463
- day,
3464
- hour || 0,
3465
- minute || 0,
3466
- second || 0
3467
- ).getTime();
4031
+ function timestamp(first2, ...rest) {
4032
+ if (typeof first2 === "string") {
4033
+ if (rest.length === 0) return parseDateString(first2);
4034
+ const [year2, month3, day2, hour3, minute3, second3] = rest;
4035
+ return zonedToUnix(first2, year2, month3, day2, hour3 ?? 0, minute3 ?? 0, second3 ?? 0);
4036
+ }
4037
+ const [month2, day, hour2, minute2, second2] = rest;
4038
+ return new Date(first2, month2 - 1, day, hour2 || 0, minute2 || 0, second2 || 0).getTime();
4039
+ }
4040
+ function field(time, timezone, pick) {
4041
+ return Number.isNaN(time) ? NaN : pick(zonedFields(time, timezone));
4042
+ }
4043
+ function year(time, timezone) {
4044
+ return field(time, timezone, (f) => f.year);
4045
+ }
4046
+ function month(time, timezone) {
4047
+ return field(time, timezone, (f) => f.month);
4048
+ }
4049
+ function dayofmonth(time, timezone) {
4050
+ return field(time, timezone, (f) => f.day);
4051
+ }
4052
+ function dayofweek(time, timezone) {
4053
+ return field(time, timezone, (f) => f.dayOfWeek);
4054
+ }
4055
+ function weekofyear(time, timezone) {
4056
+ return field(time, timezone, (f) => {
4057
+ const date = Date.UTC(f.year, f.month - 1, f.day);
4058
+ const mondayBased = (f.dayOfWeek + 5) % 7;
4059
+ const thursday = new Date(date + (3 - mondayBased) * 864e5);
4060
+ const yearStart = Date.UTC(thursday.getUTCFullYear(), 0, 1);
4061
+ return 1 + Math.floor((thursday.getTime() - yearStart) / (7 * 864e5));
4062
+ });
4063
+ }
4064
+ function hour(time, timezone) {
4065
+ return field(time, timezone, (f) => f.hour);
4066
+ }
4067
+ function minute(time, timezone) {
4068
+ return field(time, timezone, (f) => f.minute);
4069
+ }
4070
+ function second(time, timezone) {
4071
+ return field(time, timezone, (f) => f.second);
4072
+ }
4073
+ function inSession2(time, session, timezone) {
4074
+ return inSession(time, session, timezone);
4075
+ }
4076
+
4077
+ // src/timeframe/index.ts
4078
+ var timeframe_exports = {};
4079
+ __export(timeframe_exports, {
4080
+ from_seconds: () => from_seconds,
4081
+ in_seconds: () => in_seconds,
4082
+ info: () => info
4083
+ });
4084
+ var SECONDS_PER_MINUTE = 60;
4085
+ var SECONDS_PER_DAY = 86400;
4086
+ var SECONDS_PER_WEEK = 604800;
4087
+ var SECONDS_PER_MONTH = 2628003;
4088
+ var SECONDS_365_DAYS = 365 * SECONDS_PER_DAY;
4089
+ var UNIT_SECONDS = {
4090
+ S: 1,
4091
+ "": SECONDS_PER_MINUTE,
4092
+ D: SECONDS_PER_DAY,
4093
+ W: SECONDS_PER_WEEK,
4094
+ M: SECONDS_PER_MONTH
4095
+ };
4096
+ var SECOND_TIMEFRAMES = [1, 5, 10, 15, 30];
4097
+ function in_seconds(timeframe) {
4098
+ const text = timeframe.trim();
4099
+ if (text === "") {
4100
+ throw new RangeError("timeframe.in_seconds() needs a timeframe: the chart timeframe is not known here");
4101
+ }
4102
+ const before = /^(\d*)([SDWMT]?)$/.exec(text);
4103
+ const after = before ? null : /^([SDWMT])(\d+)$/.exec(text);
4104
+ if (!before && !after) throw new RangeError(`Invalid timeframe "${timeframe}"`);
4105
+ const [digits, unit] = before ? [before[1], before[2]] : [after[2], after[1]];
4106
+ if (unit === "T") return NaN;
4107
+ const multiplier = digits === "" ? 1 : Number(digits);
4108
+ return multiplier * UNIT_SECONDS[unit];
4109
+ }
4110
+ function from_seconds(seconds) {
4111
+ if (Number.isNaN(seconds)) throw new RangeError("timeframe.from_seconds() needs a number of seconds");
4112
+ if (seconds >= SECONDS_365_DAYS) return "12M";
4113
+ if (seconds > 0) {
4114
+ if (seconds % SECONDS_PER_MONTH === 0) return `${seconds / SECONDS_PER_MONTH}M`;
4115
+ if (seconds % SECONDS_PER_WEEK === 0) return `${seconds / SECONDS_PER_WEEK}W`;
4116
+ if (seconds % SECONDS_PER_DAY === 0) return `${seconds / SECONDS_PER_DAY}D`;
4117
+ if (seconds % SECONDS_PER_MINUTE === 0 && seconds < SECONDS_PER_DAY) return `${seconds / SECONDS_PER_MINUTE}`;
4118
+ }
4119
+ const second2 = SECOND_TIMEFRAMES.find((m) => seconds <= m);
4120
+ if (second2 !== void 0) return `${second2}S`;
4121
+ if (seconds < SECONDS_PER_DAY) return `${Math.ceil(seconds / SECONDS_PER_MINUTE)}`;
4122
+ return `${Math.ceil(seconds / SECONDS_PER_DAY)}D`;
4123
+ }
4124
+ function info(timeframe) {
4125
+ const text = timeframe.trim();
4126
+ const m = /^(\d*)([SDWMT]?)$/.exec(text);
4127
+ if (!m || text === "") throw new RangeError(`Invalid timeframe "${timeframe}"`);
4128
+ const unit = m[2];
4129
+ const multiplier = m[1] === "" ? 1 : Number(m[1]);
4130
+ return {
4131
+ period: unit === "" ? String(multiplier) : `${multiplier}${unit}`,
4132
+ multiplier,
4133
+ isintraday: unit === "" || unit === "S" || unit === "T",
4134
+ isdaily: unit === "D",
4135
+ isweekly: unit === "W",
4136
+ ismonthly: unit === "M",
4137
+ isminutes: unit === "",
4138
+ isseconds: unit === "S",
4139
+ isticks: unit === "T",
4140
+ isdwm: unit === "D" || unit === "W" || unit === "M"
4141
+ };
3468
4142
  }
3469
4143
 
3470
4144
  // src/matrix/index.ts
@@ -3476,14 +4150,14 @@ __export(matrix_exports, {
3476
4150
  col: () => col,
3477
4151
  columns: () => columns,
3478
4152
  concat: () => concat3,
3479
- copy: () => copy2,
4153
+ copy: () => copy3,
3480
4154
  det: () => det,
3481
4155
  diff: () => diff,
3482
4156
  eigenvalues: () => eigenvalues,
3483
4157
  eigenvectors: () => eigenvectors,
3484
4158
  elements_count: () => elements_count,
3485
4159
  fill: () => fill2,
3486
- get: () => get2,
4160
+ get: () => get3,
3487
4161
  inv: () => inv,
3488
4162
  is_antidiagonal: () => is_antidiagonal,
3489
4163
  is_antisymmetric: () => is_antisymmetric,
@@ -3532,7 +4206,7 @@ function new_matrix(rows2, columns2, initial_value) {
3532
4206
  }
3533
4207
  return { rows: rows2, columns: columns2, data };
3534
4208
  }
3535
- function get2(id, row2, column) {
4209
+ function get3(id, row2, column) {
3536
4210
  if (row2 < 0 || row2 >= id.rows || column < 0 || column >= id.columns) {
3537
4211
  throw new Error(`Matrix index out of bounds: [${row2}, ${column}] for matrix of size [${id.rows}, ${id.columns}]`);
3538
4212
  }
@@ -3565,7 +4239,7 @@ function col(id, column_index) {
3565
4239
  }
3566
4240
  return id.data.map((r2) => r2[column_index]);
3567
4241
  }
3568
- function copy2(id) {
4242
+ function copy3(id) {
3569
4243
  const newData = id.data.map((r2) => [...r2]);
3570
4244
  return {
3571
4245
  rows: id.rows,
@@ -3917,24 +4591,24 @@ function median3(id) {
3917
4591
  if (id.rows === 0 || id.columns === 0) {
3918
4592
  return NaN;
3919
4593
  }
3920
- const values = [];
4594
+ const values2 = [];
3921
4595
  for (let i = 0; i < id.rows; i++) {
3922
4596
  for (let j = 0; j < id.columns; j++) {
3923
4597
  const val = id.data[i][j];
3924
4598
  if (val !== null && val !== void 0 && !isNaN(val)) {
3925
- values.push(val);
4599
+ values2.push(val);
3926
4600
  }
3927
4601
  }
3928
4602
  }
3929
- if (values.length === 0) {
4603
+ if (values2.length === 0) {
3930
4604
  return NaN;
3931
4605
  }
3932
- values.sort((a, b2) => a - b2);
3933
- const mid = Math.floor(values.length / 2);
3934
- if (values.length % 2 === 0) {
3935
- return (values[mid - 1] + values[mid]) / 2;
4606
+ values2.sort((a, b2) => a - b2);
4607
+ const mid = Math.floor(values2.length / 2);
4608
+ if (values2.length % 2 === 0) {
4609
+ return (values2[mid - 1] + values2[mid]) / 2;
3936
4610
  } else {
3937
- return values[mid];
4611
+ return values2[mid];
3938
4612
  }
3939
4613
  }
3940
4614
  function mode3(id) {
@@ -4180,7 +4854,7 @@ function pow2(id, power) {
4180
4854
  base = inverse;
4181
4855
  p = -power;
4182
4856
  } else {
4183
- base = copy2(id);
4857
+ base = copy3(id);
4184
4858
  }
4185
4859
  let result = createIdentity(n);
4186
4860
  while (p > 0) {
@@ -4209,31 +4883,31 @@ function det(id) {
4209
4883
  const a = id.data.map((row2) => [...row2]);
4210
4884
  let determinant = 1;
4211
4885
  let swapCount = 0;
4212
- for (let col2 = 0; col2 < n; col2++) {
4213
- let maxRow = col2;
4214
- let maxVal = Math.abs(a[col2][col2]);
4215
- for (let row2 = col2 + 1; row2 < n; row2++) {
4216
- const absVal = Math.abs(a[row2][col2]);
4886
+ for (let col3 = 0; col3 < n; col3++) {
4887
+ let maxRow = col3;
4888
+ let maxVal = Math.abs(a[col3][col3]);
4889
+ for (let row2 = col3 + 1; row2 < n; row2++) {
4890
+ const absVal = Math.abs(a[row2][col3]);
4217
4891
  if (absVal > maxVal) {
4218
4892
  maxVal = absVal;
4219
4893
  maxRow = row2;
4220
4894
  }
4221
4895
  }
4222
- if (maxRow !== col2) {
4223
- const temp = a[col2];
4224
- a[col2] = a[maxRow];
4896
+ if (maxRow !== col3) {
4897
+ const temp = a[col3];
4898
+ a[col3] = a[maxRow];
4225
4899
  a[maxRow] = temp;
4226
4900
  swapCount++;
4227
4901
  }
4228
- const pivot = a[col2][col2];
4229
- if (Math.abs(pivot) < EPSILON) {
4902
+ const pivot2 = a[col3][col3];
4903
+ if (Math.abs(pivot2) < EPSILON) {
4230
4904
  return 0;
4231
4905
  }
4232
- determinant *= pivot;
4233
- for (let row2 = col2 + 1; row2 < n; row2++) {
4234
- const factor = a[row2][col2] / pivot;
4235
- for (let j = col2; j < n; j++) {
4236
- a[row2][j] = a[row2][j] - factor * a[col2][j];
4906
+ determinant *= pivot2;
4907
+ for (let row2 = col3 + 1; row2 < n; row2++) {
4908
+ const factor = a[row2][col3] / pivot2;
4909
+ for (let j = col3; j < n; j++) {
4910
+ a[row2][j] = a[row2][j] - factor * a[col3][j];
4237
4911
  }
4238
4912
  }
4239
4913
  }
@@ -4261,33 +4935,33 @@ function inv(id) {
4261
4935
  }
4262
4936
  aug.push(row2);
4263
4937
  }
4264
- for (let col2 = 0; col2 < n; col2++) {
4265
- let maxRow = col2;
4266
- let maxVal = Math.abs(aug[col2][col2]);
4267
- for (let row2 = col2 + 1; row2 < n; row2++) {
4268
- const absVal = Math.abs(aug[row2][col2]);
4938
+ for (let col3 = 0; col3 < n; col3++) {
4939
+ let maxRow = col3;
4940
+ let maxVal = Math.abs(aug[col3][col3]);
4941
+ for (let row2 = col3 + 1; row2 < n; row2++) {
4942
+ const absVal = Math.abs(aug[row2][col3]);
4269
4943
  if (absVal > maxVal) {
4270
4944
  maxVal = absVal;
4271
4945
  maxRow = row2;
4272
4946
  }
4273
4947
  }
4274
- if (maxRow !== col2) {
4275
- const temp = aug[col2];
4276
- aug[col2] = aug[maxRow];
4948
+ if (maxRow !== col3) {
4949
+ const temp = aug[col3];
4950
+ aug[col3] = aug[maxRow];
4277
4951
  aug[maxRow] = temp;
4278
4952
  }
4279
- const pivot = aug[col2][col2];
4280
- if (Math.abs(pivot) < EPSILON) {
4953
+ const pivot2 = aug[col3][col3];
4954
+ if (Math.abs(pivot2) < EPSILON) {
4281
4955
  return null;
4282
4956
  }
4283
4957
  for (let j = 0; j < 2 * n; j++) {
4284
- aug[col2][j] = aug[col2][j] / pivot;
4958
+ aug[col3][j] = aug[col3][j] / pivot2;
4285
4959
  }
4286
4960
  for (let row2 = 0; row2 < n; row2++) {
4287
- if (row2 !== col2) {
4288
- const factor = aug[row2][col2];
4961
+ if (row2 !== col3) {
4962
+ const factor = aug[row2][col3];
4289
4963
  for (let j = 0; j < 2 * n; j++) {
4290
- aug[row2][j] = aug[row2][j] - factor * aug[col2][j];
4964
+ aug[row2][j] = aug[row2][j] - factor * aug[col3][j];
4291
4965
  }
4292
4966
  }
4293
4967
  }
@@ -4350,11 +5024,11 @@ function rank(id) {
4350
5024
  const m = id.rows;
4351
5025
  const n = id.columns;
4352
5026
  let r2 = 0;
4353
- for (let col2 = 0; col2 < n && r2 < m; col2++) {
5027
+ for (let col3 = 0; col3 < n && r2 < m; col3++) {
4354
5028
  let maxRow = r2;
4355
- let maxVal = Math.abs(a[r2][col2]);
5029
+ let maxVal = Math.abs(a[r2][col3]);
4356
5030
  for (let row2 = r2 + 1; row2 < m; row2++) {
4357
- const absVal = Math.abs(a[row2][col2]);
5031
+ const absVal = Math.abs(a[row2][col3]);
4358
5032
  if (absVal > maxVal) {
4359
5033
  maxVal = absVal;
4360
5034
  maxRow = row2;
@@ -4368,10 +5042,10 @@ function rank(id) {
4368
5042
  a[r2] = a[maxRow];
4369
5043
  a[maxRow] = temp;
4370
5044
  }
4371
- const pivot = a[r2][col2];
5045
+ const pivot2 = a[r2][col3];
4372
5046
  for (let row2 = r2 + 1; row2 < m; row2++) {
4373
- const factor = a[row2][col2] / pivot;
4374
- for (let j = col2; j < n; j++) {
5047
+ const factor = a[row2][col3] / pivot2;
5048
+ for (let j = col3; j < n; j++) {
4375
5049
  a[row2][j] = a[row2][j] - factor * a[r2][j];
4376
5050
  }
4377
5051
  }
@@ -4579,29 +5253,29 @@ function inverseIteration(m, lambda) {
4579
5253
  function solveLinearSystem(a, b2) {
4580
5254
  const n = a.length;
4581
5255
  const aug = a.map((row2, i) => [...row2, b2[i]]);
4582
- for (let col2 = 0; col2 < n; col2++) {
4583
- let maxRow = col2;
4584
- let maxVal = Math.abs(aug[col2][col2]);
4585
- for (let row2 = col2 + 1; row2 < n; row2++) {
4586
- const absVal = Math.abs(aug[row2][col2]);
5256
+ for (let col3 = 0; col3 < n; col3++) {
5257
+ let maxRow = col3;
5258
+ let maxVal = Math.abs(aug[col3][col3]);
5259
+ for (let row2 = col3 + 1; row2 < n; row2++) {
5260
+ const absVal = Math.abs(aug[row2][col3]);
4587
5261
  if (absVal > maxVal) {
4588
5262
  maxVal = absVal;
4589
5263
  maxRow = row2;
4590
5264
  }
4591
5265
  }
4592
- if (maxRow !== col2) {
4593
- const temp = aug[col2];
4594
- aug[col2] = aug[maxRow];
5266
+ if (maxRow !== col3) {
5267
+ const temp = aug[col3];
5268
+ aug[col3] = aug[maxRow];
4595
5269
  aug[maxRow] = temp;
4596
5270
  }
4597
- const pivot = aug[col2][col2];
4598
- if (Math.abs(pivot) < EPSILON) {
5271
+ const pivot2 = aug[col3][col3];
5272
+ if (Math.abs(pivot2) < EPSILON) {
4599
5273
  continue;
4600
5274
  }
4601
- for (let row2 = col2 + 1; row2 < n; row2++) {
4602
- const factor = aug[row2][col2] / pivot;
4603
- for (let j = col2; j <= n; j++) {
4604
- aug[row2][j] = aug[row2][j] - factor * aug[col2][j];
5275
+ for (let row2 = col3 + 1; row2 < n; row2++) {
5276
+ const factor = aug[row2][col3] / pivot2;
5277
+ for (let j = col3; j <= n; j++) {
5278
+ aug[row2][j] = aug[row2][j] - factor * aug[col3][j];
4605
5279
  }
4606
5280
  }
4607
5281
  }
@@ -4633,8 +5307,8 @@ function kron(id1, id2) {
4633
5307
  for (let i2 = 0; i2 < m2; i2++) {
4634
5308
  for (let j2 = 0; j2 < n2; j2++) {
4635
5309
  const row2 = i1 * m2 + i2;
4636
- const col2 = j1 * n2 + j2;
4637
- data[row2][col2] = a * id2.data[i2][j2];
5310
+ const col3 = j1 * n2 + j2;
5311
+ data[row2][col3] = a * id2.data[i2][j2];
4638
5312
  }
4639
5313
  }
4640
5314
  }
@@ -4652,7 +5326,9 @@ function newtype2(rows2 = 0, columns2 = 0, initial_value) {
4652
5326
  // src/line/index.ts
4653
5327
  var line_exports = {};
4654
5328
  __export(line_exports, {
4655
- copy: () => copy3,
5329
+ all: () => all2,
5330
+ copy: () => copy4,
5331
+ delete: () => delete_line,
4656
5332
  delete_line: () => delete_line,
4657
5333
  get_price: () => get_price,
4658
5334
  get_x1: () => get_x1,
@@ -4663,6 +5339,8 @@ __export(line_exports, {
4663
5339
  new_line: () => new_line2,
4664
5340
  set_color: () => set_color,
4665
5341
  set_extend: () => set_extend,
5342
+ set_first_point: () => set_first_point,
5343
+ set_second_point: () => set_second_point,
4666
5344
  set_style: () => set_style,
4667
5345
  set_width: () => set_width,
4668
5346
  set_x1: () => set_x1,
@@ -4673,18 +5351,78 @@ __export(line_exports, {
4673
5351
  set_y1: () => set_y1,
4674
5352
  set_y2: () => set_y2
4675
5353
  });
4676
- function new_line2(x1, y1, x2, y2, xloc2 = "bar_index", extend = "none", lineColor, style, width) {
4677
- return {
5354
+
5355
+ // src/drawing/registry.ts
5356
+ var DEFAULT_MAX_COUNT = 50;
5357
+ var SLACK = 5;
5358
+ var live = { line: [], label: [], box: [], polyline: [], linefill: [] };
5359
+ var limits = {
5360
+ line: DEFAULT_MAX_COUNT,
5361
+ label: DEFAULT_MAX_COUNT,
5362
+ box: DEFAULT_MAX_COUNT,
5363
+ polyline: DEFAULT_MAX_COUNT
5364
+ };
5365
+ var deleted = /* @__PURE__ */ new WeakSet();
5366
+ var COORDINATES = {
5367
+ line: ["x1", "y1", "x2", "y2"],
5368
+ label: ["x", "y"],
5369
+ box: ["left", "top", "right", "bottom"],
5370
+ polyline: [],
5371
+ linefill: []
5372
+ };
5373
+ function markDeleted(kind, obj, explicit) {
5374
+ deleted.add(obj);
5375
+ for (const field2 of COORDINATES[kind]) obj[field2] = NaN;
5376
+ if (kind === "line" && explicit) {
5377
+ for (const fill3 of live.linefill.filter((f) => f.line1 === obj || f.line2 === obj)) remove3("linefill", fill3);
5378
+ }
5379
+ }
5380
+ function register(kind, obj) {
5381
+ const list = live[kind];
5382
+ list.push(obj);
5383
+ const max6 = limits[kind === "linefill" ? "line" : kind];
5384
+ if (list.length > max6 + SLACK) {
5385
+ for (const old of list.splice(0, list.length - max6)) markDeleted(kind, old, false);
5386
+ }
5387
+ return obj;
5388
+ }
5389
+ function remove3(kind, obj) {
5390
+ const list = live[kind];
5391
+ const index = list.indexOf(obj);
5392
+ if (index !== -1) list.splice(index, 1);
5393
+ if (!deleted.has(obj)) markDeleted(kind, obj, true);
5394
+ }
5395
+ function isDeleted(obj) {
5396
+ return typeof obj === "object" && obj !== null && deleted.has(obj);
5397
+ }
5398
+ function all(kind) {
5399
+ return [...live[kind]];
5400
+ }
5401
+
5402
+ // src/line/index.ts
5403
+ function new_line2(...args) {
5404
+ let x1, y1, x2, y2, rest;
5405
+ if (typeof args[0] === "object" && args[0] !== null) {
5406
+ const [p1, p2, ...others] = args;
5407
+ const xloc3 = others[0] ?? "bar_index";
5408
+ [x1, y1, x2, y2, rest] = [pointX(p1, xloc3), p1.price, pointX(p2, xloc3), p2.price, others];
5409
+ } else {
5410
+ [x1, y1, x2, y2] = args;
5411
+ rest = args.slice(4);
5412
+ }
5413
+ const [xloc2, extend, lineColor, style, width, force_overlay] = rest;
5414
+ return register("line", {
4678
5415
  x1,
4679
5416
  y1,
4680
5417
  x2,
4681
5418
  y2,
4682
- xloc: xloc2,
4683
- extend,
5419
+ xloc: xloc2 ?? "bar_index",
5420
+ extend: extend ?? "none",
4684
5421
  color: lineColor,
4685
5422
  style: style || "solid",
4686
- width: width || 1
4687
- };
5423
+ width: width || 1,
5424
+ force_overlay: force_overlay ?? false
5425
+ });
4688
5426
  }
4689
5427
  function get_price(id, x) {
4690
5428
  const { x1, y1, x2, y2, extend, xloc: xloc2 } = id;
@@ -4723,64 +5461,97 @@ function get_y1(id) {
4723
5461
  function get_y2(id) {
4724
5462
  return id.y2;
4725
5463
  }
4726
- function copy3(id) {
4727
- return { ...id };
5464
+ function copy4(id) {
5465
+ return register("line", { ...id });
4728
5466
  }
4729
5467
  function set_x1(id, x) {
5468
+ if (isDeleted(id)) return id;
4730
5469
  id.x1 = x;
4731
5470
  return id;
4732
5471
  }
4733
5472
  function set_x2(id, x) {
5473
+ if (isDeleted(id)) return id;
4734
5474
  id.x2 = x;
4735
5475
  return id;
4736
5476
  }
4737
5477
  function set_y1(id, y) {
5478
+ if (isDeleted(id)) return id;
4738
5479
  id.y1 = y;
4739
5480
  return id;
4740
5481
  }
4741
5482
  function set_y2(id, y) {
5483
+ if (isDeleted(id)) return id;
4742
5484
  id.y2 = y;
4743
5485
  return id;
4744
5486
  }
4745
5487
  function set_xy1(id, x, y) {
5488
+ if (isDeleted(id)) return id;
4746
5489
  id.x1 = x;
4747
5490
  id.y1 = y;
4748
5491
  return id;
4749
5492
  }
4750
5493
  function set_xy2(id, x, y) {
5494
+ if (isDeleted(id)) return id;
4751
5495
  id.x2 = x;
4752
5496
  id.y2 = y;
4753
5497
  return id;
4754
5498
  }
4755
5499
  function set_xloc(id, x1, x2, xloc2) {
5500
+ if (isDeleted(id)) return id;
4756
5501
  id.x1 = x1;
4757
5502
  id.x2 = x2;
4758
5503
  id.xloc = xloc2;
4759
5504
  return id;
4760
5505
  }
4761
5506
  function set_extend(id, extend) {
5507
+ if (isDeleted(id)) return id;
4762
5508
  id.extend = extend;
4763
5509
  return id;
4764
5510
  }
4765
5511
  function set_color(id, lineColor) {
5512
+ if (isDeleted(id)) return id;
4766
5513
  id.color = lineColor;
4767
5514
  return id;
4768
5515
  }
4769
5516
  function set_style(id, style) {
5517
+ if (isDeleted(id)) return id;
4770
5518
  id.style = style;
4771
5519
  return id;
4772
5520
  }
4773
5521
  function set_width(id, width) {
5522
+ if (isDeleted(id)) return id;
4774
5523
  id.width = width;
4775
5524
  return id;
4776
5525
  }
4777
- function delete_line(_id) {
5526
+ function delete_line(id) {
5527
+ remove3("line", id);
5528
+ }
5529
+ function pointX(point, xloc2) {
5530
+ const x = xloc2 === "bar_time" ? point.time : point.index;
5531
+ return x ?? NaN;
5532
+ }
5533
+ function all2() {
5534
+ return all("line");
5535
+ }
5536
+ function set_first_point(id, point) {
5537
+ if (isDeleted(id)) return id;
5538
+ id.x1 = pointX(point, id.xloc);
5539
+ id.y1 = point.price;
5540
+ return id;
5541
+ }
5542
+ function set_second_point(id, point) {
5543
+ if (isDeleted(id)) return id;
5544
+ id.x2 = pointX(point, id.xloc);
5545
+ id.y2 = point.price;
5546
+ return id;
4778
5547
  }
4779
5548
 
4780
5549
  // src/box/index.ts
4781
5550
  var box_exports = {};
4782
5551
  __export(box_exports, {
4783
- copy: () => copy4,
5552
+ all: () => all3,
5553
+ copy: () => copy5,
5554
+ delete: () => delete_box,
4784
5555
  delete_box: () => delete_box,
4785
5556
  get_bottom: () => get_bottom,
4786
5557
  get_left: () => get_left,
@@ -4793,6 +5564,7 @@ __export(box_exports, {
4793
5564
  set_border_style: () => set_border_style,
4794
5565
  set_border_width: () => set_border_width,
4795
5566
  set_bottom: () => set_bottom,
5567
+ set_bottom_right_point: () => set_bottom_right_point,
4796
5568
  set_extend: () => set_extend2,
4797
5569
  set_left: () => set_left,
4798
5570
  set_lefttop: () => set_lefttop,
@@ -4801,21 +5573,49 @@ __export(box_exports, {
4801
5573
  set_text: () => set_text,
4802
5574
  set_text_color: () => set_text_color,
4803
5575
  set_text_font_family: () => set_text_font_family,
5576
+ set_text_formatting: () => set_text_formatting,
4804
5577
  set_text_halign: () => set_text_halign,
4805
5578
  set_text_size: () => set_text_size,
4806
5579
  set_text_valign: () => set_text_valign,
4807
5580
  set_text_wrap: () => set_text_wrap,
4808
5581
  set_top: () => set_top,
5582
+ set_top_left_point: () => set_top_left_point,
4809
5583
  set_xloc: () => set_xloc2
4810
5584
  });
4811
- function new_box2(left, top, right, bottom, xloc2 = "bar_index", extend = "none", border_color, border_width, border_style, bgcolor, text, text_size, text_color, text_halign, text_valign, text_wrap, text_font_family) {
4812
- return {
5585
+ function new_box2(...args) {
5586
+ let left, top, right, bottom, rest;
5587
+ if (typeof args[0] === "object" && args[0] !== null) {
5588
+ const [tl, br, ...others] = args;
5589
+ const xloc3 = others[4] ?? "bar_index";
5590
+ [left, top, right, bottom, rest] = [pointX2(tl, xloc3), tl.price, pointX2(br, xloc3), br.price, others];
5591
+ } else {
5592
+ [left, top, right, bottom] = args;
5593
+ rest = args.slice(4);
5594
+ }
5595
+ const [
5596
+ border_color,
5597
+ border_width,
5598
+ border_style,
5599
+ extend,
5600
+ xloc2,
5601
+ bgcolor,
5602
+ text,
5603
+ text_size,
5604
+ text_color,
5605
+ text_halign,
5606
+ text_valign,
5607
+ text_wrap,
5608
+ text_font_family,
5609
+ force_overlay,
5610
+ text_formatting
5611
+ ] = rest;
5612
+ return register("box", {
4813
5613
  left,
4814
5614
  top,
4815
5615
  right,
4816
5616
  bottom,
4817
- xloc: xloc2,
4818
- extend,
5617
+ xloc: xloc2 ?? "bar_index",
5618
+ extend: extend ?? "none",
4819
5619
  border_color,
4820
5620
  border_width: border_width || 1,
4821
5621
  border_style: border_style || "solid",
@@ -4826,8 +5626,10 @@ function new_box2(left, top, right, bottom, xloc2 = "bar_index", extend = "none"
4826
5626
  text_halign,
4827
5627
  text_valign,
4828
5628
  text_wrap,
4829
- text_font_family
4830
- };
5629
+ text_font_family,
5630
+ force_overlay: force_overlay ?? false,
5631
+ text_formatting
5632
+ });
4831
5633
  }
4832
5634
  function get_left(id) {
4833
5635
  return id.left;
@@ -4841,96 +5643,142 @@ function get_top(id) {
4841
5643
  function get_bottom(id) {
4842
5644
  return id.bottom;
4843
5645
  }
4844
- function copy4(id) {
4845
- return { ...id };
5646
+ function copy5(id) {
5647
+ return register("box", { ...id });
4846
5648
  }
4847
5649
  function set_left(id, left) {
5650
+ if (isDeleted(id)) return id;
4848
5651
  id.left = left;
4849
5652
  return id;
4850
5653
  }
4851
5654
  function set_right(id, right) {
5655
+ if (isDeleted(id)) return id;
4852
5656
  id.right = right;
4853
5657
  return id;
4854
5658
  }
4855
5659
  function set_top(id, top) {
5660
+ if (isDeleted(id)) return id;
4856
5661
  id.top = top;
4857
5662
  return id;
4858
5663
  }
4859
5664
  function set_bottom(id, bottom) {
5665
+ if (isDeleted(id)) return id;
4860
5666
  id.bottom = bottom;
4861
5667
  return id;
4862
5668
  }
4863
5669
  function set_lefttop(id, left, top) {
5670
+ if (isDeleted(id)) return id;
4864
5671
  id.left = left;
4865
5672
  id.top = top;
4866
5673
  return id;
4867
5674
  }
4868
5675
  function set_rightbottom(id, right, bottom) {
5676
+ if (isDeleted(id)) return id;
4869
5677
  id.right = right;
4870
5678
  id.bottom = bottom;
4871
5679
  return id;
4872
5680
  }
4873
5681
  function set_xloc2(id, left, right, xloc2) {
5682
+ if (isDeleted(id)) return id;
4874
5683
  id.left = left;
4875
5684
  id.right = right;
4876
5685
  id.xloc = xloc2;
4877
5686
  return id;
4878
5687
  }
4879
5688
  function set_extend2(id, extend) {
5689
+ if (isDeleted(id)) return id;
4880
5690
  id.extend = extend;
4881
5691
  return id;
4882
5692
  }
4883
5693
  function set_border_color(id, borderColor) {
5694
+ if (isDeleted(id)) return id;
4884
5695
  id.border_color = borderColor;
4885
5696
  return id;
4886
5697
  }
4887
5698
  function set_border_width(id, width) {
5699
+ if (isDeleted(id)) return id;
4888
5700
  id.border_width = width;
4889
5701
  return id;
4890
5702
  }
4891
5703
  function set_border_style(id, style) {
5704
+ if (isDeleted(id)) return id;
4892
5705
  id.border_style = style;
4893
5706
  return id;
4894
5707
  }
4895
5708
  function set_bgcolor(id, bgColor) {
5709
+ if (isDeleted(id)) return id;
4896
5710
  id.bgcolor = bgColor;
4897
5711
  return id;
4898
5712
  }
4899
5713
  function set_text(id, text) {
5714
+ if (isDeleted(id)) return id;
4900
5715
  id.text = text;
4901
5716
  return id;
4902
5717
  }
4903
5718
  function set_text_color(id, textColor) {
5719
+ if (isDeleted(id)) return id;
4904
5720
  id.text_color = textColor;
4905
5721
  return id;
4906
5722
  }
4907
- function set_text_size(id, size2) {
4908
- id.text_size = size2;
5723
+ function set_text_size(id, size3) {
5724
+ if (isDeleted(id)) return id;
5725
+ id.text_size = size3;
4909
5726
  return id;
4910
5727
  }
4911
5728
  function set_text_halign(id, align) {
5729
+ if (isDeleted(id)) return id;
4912
5730
  id.text_halign = align;
4913
5731
  return id;
4914
5732
  }
4915
5733
  function set_text_valign(id, align) {
5734
+ if (isDeleted(id)) return id;
4916
5735
  id.text_valign = align;
4917
5736
  return id;
4918
5737
  }
4919
5738
  function set_text_wrap(id, wrap) {
5739
+ if (isDeleted(id)) return id;
4920
5740
  id.text_wrap = wrap;
4921
5741
  return id;
4922
5742
  }
4923
5743
  function set_text_font_family(id, font) {
5744
+ if (isDeleted(id)) return id;
4924
5745
  id.text_font_family = font;
4925
5746
  return id;
4926
5747
  }
4927
- function delete_box(_id) {
5748
+ function delete_box(id) {
5749
+ remove3("box", id);
5750
+ }
5751
+ function pointX2(point, xloc2) {
5752
+ const x = xloc2 === "bar_time" ? point.time : point.index;
5753
+ return x ?? NaN;
5754
+ }
5755
+ function all3() {
5756
+ return all("box");
5757
+ }
5758
+ function set_top_left_point(id, point) {
5759
+ if (isDeleted(id)) return id;
5760
+ id.left = pointX2(point, id.xloc);
5761
+ id.top = point.price;
5762
+ return id;
5763
+ }
5764
+ function set_bottom_right_point(id, point) {
5765
+ if (isDeleted(id)) return id;
5766
+ id.right = pointX2(point, id.xloc);
5767
+ id.bottom = point.price;
5768
+ return id;
5769
+ }
5770
+ function set_text_formatting(id, formatting) {
5771
+ if (isDeleted(id)) return id;
5772
+ id.text_formatting = formatting;
5773
+ return id;
4928
5774
  }
4929
5775
 
4930
5776
  // src/label/index.ts
4931
5777
  var label_exports = {};
4932
5778
  __export(label_exports, {
4933
- copy: () => copy5,
5779
+ all: () => all4,
5780
+ copy: () => copy6,
5781
+ delete: () => delete_label,
4934
5782
  delete_label: () => delete_label,
4935
5783
  get_text: () => get_text,
4936
5784
  get_x: () => get_x,
@@ -4938,10 +5786,12 @@ __export(label_exports, {
4938
5786
  new: () => new_label2,
4939
5787
  new_label: () => new_label2,
4940
5788
  set_color: () => set_color2,
5789
+ set_point: () => set_point,
4941
5790
  set_size: () => set_size,
4942
5791
  set_style: () => set_style2,
4943
5792
  set_text: () => set_text2,
4944
5793
  set_text_font_family: () => set_text_font_family2,
5794
+ set_text_formatting: () => set_text_formatting2,
4945
5795
  set_textalign: () => set_textalign,
4946
5796
  set_textcolor: () => set_textcolor,
4947
5797
  set_tooltip: () => set_tooltip,
@@ -4951,21 +5801,47 @@ __export(label_exports, {
4951
5801
  set_y: () => set_y,
4952
5802
  set_yloc: () => set_yloc
4953
5803
  });
4954
- function new_label2(x, y, text, xloc2 = "bar_index", yloc = "price", labelColor, style, textcolor, size2, textalign, tooltip, text_font_family) {
4955
- return {
5804
+ function new_label2(...args) {
5805
+ let x, y, rest;
5806
+ if (typeof args[0] === "object" && args[0] !== null) {
5807
+ const point = args[0];
5808
+ rest = args.slice(1);
5809
+ x = pointX3(point, rest[1] ?? "bar_index");
5810
+ y = point.price;
5811
+ } else {
5812
+ [x, y] = args;
5813
+ rest = args.slice(2);
5814
+ }
5815
+ const [
5816
+ text,
5817
+ xloc2,
5818
+ yloc,
5819
+ labelColor,
5820
+ style,
5821
+ textcolor,
5822
+ size3,
5823
+ textalign,
5824
+ tooltip,
5825
+ text_font_family,
5826
+ force_overlay,
5827
+ text_formatting
5828
+ ] = rest;
5829
+ return register("label", {
4956
5830
  x,
4957
5831
  y,
4958
- xloc: xloc2,
4959
- yloc,
5832
+ xloc: xloc2 ?? "bar_index",
5833
+ yloc: yloc ?? "price",
4960
5834
  text,
4961
5835
  tooltip,
4962
5836
  color: labelColor,
4963
5837
  style,
4964
5838
  textcolor,
4965
- size: size2,
5839
+ size: size3,
4966
5840
  textalign,
4967
- text_font_family
4968
- };
5841
+ text_font_family,
5842
+ force_overlay: force_overlay ?? false,
5843
+ text_formatting
5844
+ });
4969
5845
  }
4970
5846
  function get_x(id) {
4971
5847
  return id.x;
@@ -4976,70 +5852,103 @@ function get_y(id) {
4976
5852
  function get_text(id) {
4977
5853
  return id.text;
4978
5854
  }
4979
- function copy5(id) {
4980
- return { ...id };
5855
+ function copy6(id) {
5856
+ return register("label", { ...id });
4981
5857
  }
4982
5858
  function set_x(id, x) {
5859
+ if (isDeleted(id)) return id;
4983
5860
  id.x = x;
4984
5861
  return id;
4985
5862
  }
4986
5863
  function set_y(id, y) {
5864
+ if (isDeleted(id)) return id;
4987
5865
  id.y = y;
4988
5866
  return id;
4989
5867
  }
4990
5868
  function set_xy(id, x, y) {
5869
+ if (isDeleted(id)) return id;
4991
5870
  id.x = x;
4992
5871
  id.y = y;
4993
5872
  return id;
4994
5873
  }
4995
5874
  function set_xloc3(id, x, xloc2) {
5875
+ if (isDeleted(id)) return id;
4996
5876
  id.x = x;
4997
5877
  id.xloc = xloc2;
4998
5878
  return id;
4999
5879
  }
5000
- function set_yloc(id, y, yloc) {
5001
- id.y = y;
5880
+ function set_yloc(id, yloc) {
5881
+ if (isDeleted(id)) return id;
5002
5882
  id.yloc = yloc;
5003
5883
  return id;
5004
5884
  }
5005
5885
  function set_text2(id, text) {
5886
+ if (isDeleted(id)) return id;
5006
5887
  id.text = text;
5007
5888
  return id;
5008
5889
  }
5009
5890
  function set_tooltip(id, tooltip) {
5891
+ if (isDeleted(id)) return id;
5010
5892
  id.tooltip = tooltip;
5011
5893
  return id;
5012
5894
  }
5013
5895
  function set_color2(id, labelColor) {
5896
+ if (isDeleted(id)) return id;
5014
5897
  id.color = labelColor;
5015
5898
  return id;
5016
5899
  }
5017
5900
  function set_textcolor(id, textColor) {
5901
+ if (isDeleted(id)) return id;
5018
5902
  id.textcolor = textColor;
5019
5903
  return id;
5020
5904
  }
5021
5905
  function set_style2(id, style) {
5906
+ if (isDeleted(id)) return id;
5022
5907
  id.style = style;
5023
5908
  return id;
5024
5909
  }
5025
- function set_size(id, size2) {
5026
- id.size = size2;
5910
+ function set_size(id, size3) {
5911
+ if (isDeleted(id)) return id;
5912
+ id.size = size3;
5027
5913
  return id;
5028
5914
  }
5029
5915
  function set_textalign(id, align) {
5916
+ if (isDeleted(id)) return id;
5030
5917
  id.textalign = align;
5031
5918
  return id;
5032
5919
  }
5033
5920
  function set_text_font_family2(id, font) {
5921
+ if (isDeleted(id)) return id;
5034
5922
  id.text_font_family = font;
5035
5923
  return id;
5036
5924
  }
5037
- function delete_label(_id) {
5925
+ function delete_label(id) {
5926
+ remove3("label", id);
5927
+ }
5928
+ function pointX3(point, xloc2) {
5929
+ const x = xloc2 === "bar_time" ? point.time : point.index;
5930
+ return x ?? NaN;
5931
+ }
5932
+ function all4() {
5933
+ return all("label");
5934
+ }
5935
+ function set_point(id, point) {
5936
+ if (isDeleted(id)) return id;
5937
+ id.x = pointX3(point, id.xloc);
5938
+ id.y = point.price;
5939
+ return id;
5940
+ }
5941
+ function set_text_formatting2(id, formatting) {
5942
+ if (isDeleted(id)) return id;
5943
+ id.text_formatting = formatting;
5944
+ return id;
5038
5945
  }
5039
5946
 
5040
5947
  // src/linefill/index.ts
5041
5948
  var linefill_exports = {};
5042
5949
  __export(linefill_exports, {
5950
+ all: () => all5,
5951
+ delete: () => delete_linefill,
5043
5952
  delete_linefill: () => delete_linefill,
5044
5953
  get_line1: () => get_line1,
5045
5954
  get_line2: () => get_line2,
@@ -5048,11 +5957,11 @@ __export(linefill_exports, {
5048
5957
  set_color: () => set_color3
5049
5958
  });
5050
5959
  function new_linefill2(line1, line2, fillColor) {
5051
- return {
5960
+ return register("linefill", {
5052
5961
  line1,
5053
5962
  line2,
5054
5963
  color: fillColor
5055
- };
5964
+ });
5056
5965
  }
5057
5966
  function get_line1(id) {
5058
5967
  return id.line1;
@@ -5061,16 +5970,21 @@ function get_line2(id) {
5061
5970
  return id.line2;
5062
5971
  }
5063
5972
  function set_color3(id, fillColor) {
5973
+ if (isDeleted(id)) return id;
5064
5974
  id.color = fillColor;
5065
5975
  return id;
5066
5976
  }
5067
- function delete_linefill(_id) {
5977
+ function delete_linefill(id) {
5978
+ remove3("linefill", id);
5979
+ }
5980
+ function all5() {
5981
+ return all("linefill");
5068
5982
  }
5069
5983
 
5070
5984
  // src/chartpoint/index.ts
5071
5985
  var chartpoint_exports = {};
5072
5986
  __export(chartpoint_exports, {
5073
- copy: () => copy6,
5987
+ copy: () => copy7,
5074
5988
  from_index: () => from_index,
5075
5989
  from_time: () => from_time,
5076
5990
  new: () => new_point,
@@ -5097,7 +6011,7 @@ function from_index(index, price) {
5097
6011
  price
5098
6012
  };
5099
6013
  }
5100
- function copy6(point) {
6014
+ function copy7(point) {
5101
6015
  return {
5102
6016
  time: point.time,
5103
6017
  index: point.index,
@@ -5108,6 +6022,7 @@ function copy6(point) {
5108
6022
  // src/polyline/index.ts
5109
6023
  var polyline_exports = {};
5110
6024
  __export(polyline_exports, {
6025
+ all: () => all6,
5111
6026
  clear_all: () => clear_all,
5112
6027
  delete: () => delete_polyline,
5113
6028
  delete_polyline: () => delete_polyline,
@@ -5117,7 +6032,6 @@ __export(polyline_exports, {
5117
6032
  reset_id_counter: () => reset_id_counter
5118
6033
  });
5119
6034
  var polylineIdCounter = 0;
5120
- var allPolylines = [];
5121
6035
  function generateId() {
5122
6036
  return `polyline_${++polylineIdCounter}`;
5123
6037
  }
@@ -5144,28 +6058,39 @@ function new_polyline(points, curved = false, closed = false, xloc2 = "bar_index
5144
6058
  line_width,
5145
6059
  force_overlay
5146
6060
  };
5147
- allPolylines.push(polyline);
5148
- return polyline;
6061
+ return register("polyline", polyline);
5149
6062
  }
5150
6063
  function delete_polyline(id) {
5151
- const index = allPolylines.findIndex((p) => p.id === id.id);
5152
- if (index !== -1) {
5153
- allPolylines.splice(index, 1);
5154
- }
6064
+ remove3("polyline", id);
5155
6065
  }
5156
6066
  function get_all() {
5157
- return [...allPolylines];
6067
+ return all("polyline");
6068
+ }
6069
+ function all6() {
6070
+ return all("polyline");
5158
6071
  }
5159
6072
  function clear_all() {
5160
- allPolylines.length = 0;
6073
+ for (const p of all("polyline")) remove3("polyline", p);
5161
6074
  }
5162
6075
  function reset_id_counter() {
5163
6076
  polylineIdCounter = 0;
5164
6077
  }
5165
6078
 
6079
+ // src/text/index.ts
6080
+ var text_exports = {};
6081
+ __export(text_exports, {
6082
+ format_bold: () => format_bold,
6083
+ format_italic: () => format_italic,
6084
+ format_none: () => format_none
6085
+ });
6086
+ var format_none = 0;
6087
+ var format_bold = 1;
6088
+ var format_italic = 2;
6089
+
5166
6090
  // src/ta-series.ts
5167
6091
  var ta_series_exports = {};
5168
6092
  __export(ta_series_exports, {
6093
+ accdist: () => accdist2,
5169
6094
  alma: () => alma2,
5170
6095
  atr: () => atr2,
5171
6096
  barssince: () => barssince2,
@@ -5188,6 +6113,7 @@ __export(ta_series_exports, {
5188
6113
  highestbars: () => highestbars2,
5189
6114
  hma: () => hma2,
5190
6115
  ichimoku: () => ichimoku2,
6116
+ iii: () => iii2,
5191
6117
  kc: () => kc2,
5192
6118
  kcw: () => kcw2,
5193
6119
  linreg: () => linreg2,
@@ -5200,11 +6126,15 @@ __export(ta_series_exports, {
5200
6126
  min: () => min5,
5201
6127
  mode: () => mode4,
5202
6128
  mom: () => mom2,
6129
+ nvi: () => nvi2,
6130
+ obv: () => obv2,
5203
6131
  percentile_linear_interpolation: () => percentile_linear_interpolation3,
5204
6132
  percentile_nearest_rank: () => percentile_nearest_rank3,
5205
6133
  percentrank: () => percentrank3,
5206
6134
  pivothigh: () => pivothigh2,
5207
6135
  pivotlow: () => pivotlow2,
6136
+ pvi: () => pvi2,
6137
+ pvt: () => pvt2,
5208
6138
  range: () => range3,
5209
6139
  rci: () => rci2,
5210
6140
  rising: () => rising2,
@@ -5223,9 +6153,12 @@ __export(ta_series_exports, {
5223
6153
  valuewhen: () => valuewhen2,
5224
6154
  variance: () => variance3,
5225
6155
  vwap: () => vwap2,
6156
+ vwapBands: () => vwapBands,
5226
6157
  vwma: () => vwma2,
6158
+ wad: () => wad2,
5227
6159
  wma: () => wma2,
5228
6160
  wpr: () => wpr2,
6161
+ wvad: () => wvad2,
5229
6162
  zigzag: () => zigzag2
5230
6163
  });
5231
6164
  function sma2(source, length2) {
@@ -5276,11 +6209,9 @@ function bb2(source, length2, mult2) {
5276
6209
  const lowerSeries = Series.fromArray(bars, lowerVals);
5277
6210
  return [upperSeries, basisSeries, lowerSeries];
5278
6211
  }
5279
- function stdev3(source, length2) {
6212
+ function stdev3(source, length2, biased = true) {
5280
6213
  const bars = source.bars;
5281
- const sourceValues = source.toArray();
5282
- const result = stdev(sourceValues, length2);
5283
- return Series.fromArray(bars, result);
6214
+ return Series.fromArray(bars, stdev(source.toArray(), length2, biased));
5284
6215
  }
5285
6216
  function atr2(bars, length2) {
5286
6217
  const high = bars.map((b2) => b2.high);
@@ -5296,6 +6227,40 @@ function tr2(bars, handle_na = false) {
5296
6227
  const result = tr(handle_na, high, low, close);
5297
6228
  return Series.fromArray(bars, result);
5298
6229
  }
6230
+ var col2 = (bars, f) => bars.map((b2) => b2[f] ?? NaN);
6231
+ function obv2(bars) {
6232
+ return Series.fromArray(bars, obv(col2(bars, "close"), col2(bars, "volume")));
6233
+ }
6234
+ function pvt2(bars) {
6235
+ return Series.fromArray(bars, pvt(col2(bars, "close"), col2(bars, "volume")));
6236
+ }
6237
+ function accdist2(bars) {
6238
+ return Series.fromArray(
6239
+ bars,
6240
+ accdist(col2(bars, "high"), col2(bars, "low"), col2(bars, "close"), col2(bars, "volume"))
6241
+ );
6242
+ }
6243
+ function nvi2(bars) {
6244
+ return Series.fromArray(bars, nvi(col2(bars, "close"), col2(bars, "volume")));
6245
+ }
6246
+ function pvi2(bars) {
6247
+ return Series.fromArray(bars, pvi(col2(bars, "close"), col2(bars, "volume")));
6248
+ }
6249
+ function iii2(bars) {
6250
+ return Series.fromArray(
6251
+ bars,
6252
+ iii(col2(bars, "high"), col2(bars, "low"), col2(bars, "close"), col2(bars, "volume"))
6253
+ );
6254
+ }
6255
+ function wad2(bars) {
6256
+ return Series.fromArray(bars, wad(col2(bars, "high"), col2(bars, "low"), col2(bars, "close")));
6257
+ }
6258
+ function wvad2(bars) {
6259
+ return Series.fromArray(
6260
+ bars,
6261
+ wvad(col2(bars, "open"), col2(bars, "high"), col2(bars, "low"), col2(bars, "close"), col2(bars, "volume"))
6262
+ );
6263
+ }
5299
6264
  function stoch2(source, high, low, length2) {
5300
6265
  const bars = source.bars;
5301
6266
  const sourceValues = source.toArray();
@@ -5387,12 +6352,14 @@ function supertrend2(bars, factor, atrLength) {
5387
6352
  const dirSeries = Series.fromArray(bars, dirVals);
5388
6353
  return [trendSeries, dirSeries];
5389
6354
  }
5390
- function vwap2(source, volume) {
6355
+ function vwap2(source, volume, anchor) {
5391
6356
  const bars = source.bars;
5392
- const sourceValues = source.toArray();
5393
- const volumeValues = volume.toArray();
5394
- const result = vwap(sourceValues, volumeValues);
5395
- return Series.fromArray(bars, result);
6357
+ return Series.fromArray(bars, vwap(source.toArray(), volume.toArray(), anchor?.toArray()));
6358
+ }
6359
+ function vwapBands(source, volume, anchor, stdev_mult) {
6360
+ const bars = source.bars;
6361
+ const [m, u, l] = vwap(source.toArray(), volume.toArray(), anchor?.toArray(), stdev_mult);
6362
+ return [Series.fromArray(bars, m), Series.fromArray(bars, u), Series.fromArray(bars, l)];
5396
6363
  }
5397
6364
  function ichimoku2(bars, conversionPeriods, basePeriods, laggingSpan2Periods, displacement) {
5398
6365
  const high = bars.map((b2) => b2.high);
@@ -5577,10 +6544,9 @@ function kcw2(bars, source, length2 = 20, mult2 = 2, useTrueRange = true) {
5577
6544
  const result = kcw(source.toArray(), length2, mult2, useTrueRange, high, low, close);
5578
6545
  return Series.fromArray(bars, result);
5579
6546
  }
5580
- function range3(high, low) {
5581
- const bars = high.bars;
5582
- const result = range(high.toArray(), low.toArray());
5583
- return Series.fromArray(bars, result);
6547
+ function range3(source, length2) {
6548
+ const bars = source.bars;
6549
+ return Series.fromArray(bars, range(source.toArray(), length2));
5584
6550
  }
5585
6551
  function highestbars2(source, length2) {
5586
6552
  const bars = source.bars;
@@ -5592,15 +6558,13 @@ function lowestbars2(source, length2) {
5592
6558
  const result = lowestbars(source.toArray(), length2);
5593
6559
  return Series.fromArray(bars, result);
5594
6560
  }
5595
- function max5(source1, source2) {
5596
- const bars = source1.bars;
5597
- const result = max(source1.toArray(), source2.toArray());
5598
- return Series.fromArray(bars, result);
6561
+ function max5(source) {
6562
+ const bars = source.bars;
6563
+ return Series.fromArray(bars, max(source.toArray()));
5599
6564
  }
5600
- function min5(source1, source2) {
5601
- const bars = source1.bars;
5602
- const result = min(source1.toArray(), source2.toArray());
5603
- return Series.fromArray(bars, result);
6565
+ function min5(source) {
6566
+ const bars = source.bars;
6567
+ return Series.fromArray(bars, min(source.toArray()));
5604
6568
  }
5605
6569
  function cog2(source, length2 = 10) {
5606
6570
  const bars = source.bars;
@@ -5683,6 +6647,15 @@ var ta = {
5683
6647
  lowestbars: lowestbars2,
5684
6648
  max: max5,
5685
6649
  min: min5,
6650
+ vwapBands,
6651
+ obv: obv2,
6652
+ pvt: pvt2,
6653
+ accdist: accdist2,
6654
+ nvi: nvi2,
6655
+ pvi: pvi2,
6656
+ iii: iii2,
6657
+ wad: wad2,
6658
+ wvad: wvad2,
5686
6659
  cog: cog2,
5687
6660
  mode: mode4,
5688
6661
  percentile_linear_interpolation: percentile_linear_interpolation3,
@@ -5692,11 +6665,23 @@ var ta = {
5692
6665
 
5693
6666
  // src/utils/index.ts
5694
6667
  function isNA(value) {
5695
- return value === null || value === void 0 || Number.isNaN(value);
6668
+ return value === null || value === void 0 || Number.isNaN(value) || isDeleted(value);
5696
6669
  }
5697
6670
  function nz(value, defaultValue = 0) {
5698
6671
  return isNA(value) ? defaultValue : value;
5699
6672
  }
6673
+ function fixnan(source) {
6674
+ let last2;
6675
+ let seen = false;
6676
+ return source.map((v) => {
6677
+ if (!isNA(v)) {
6678
+ last2 = v;
6679
+ seen = true;
6680
+ return v;
6681
+ }
6682
+ return seen ? last2 : v;
6683
+ });
6684
+ }
5700
6685
  function ohlcFromBars(bars) {
5701
6686
  return {
5702
6687
  open: bars.map((b2) => b2.open),
@@ -6088,16 +7073,78 @@ var input = {
6088
7073
  title: options.title,
6089
7074
  options: options.options
6090
7075
  };
7076
+ },
7077
+ /**
7078
+ * Create a timeframe input parameter (PineScript `input.timeframe`)
7079
+ * @param defaultValue - Default timeframe string ("60", "1D", "W"); "" means the chart timeframe
7080
+ * @param options - Additional options (title, options for dropdown)
7081
+ * @returns Input value object
7082
+ *
7083
+ * @example
7084
+ * ```typescript
7085
+ * const htf = input.timeframe('1D', { title: 'Higher timeframe' });
7086
+ * console.log(htf.value); // '1D'
7087
+ * ```
7088
+ */
7089
+ timeframe(defaultValue, options = {}) {
7090
+ return {
7091
+ type: "timeframe",
7092
+ defaultValue,
7093
+ value: defaultValue,
7094
+ title: options.title,
7095
+ options: options.options
7096
+ };
7097
+ },
7098
+ /**
7099
+ * Create a session input parameter (PineScript `input.session`)
7100
+ * @param defaultValue - Default session string ("0930-1600", "0930-1600:23456")
7101
+ * @param options - Additional options (title, options for dropdown)
7102
+ * @returns Input value object
7103
+ *
7104
+ * @example
7105
+ * ```typescript
7106
+ * const rth = input.session('0930-1600', { title: 'Regular hours' });
7107
+ * console.log(rth.value); // '0930-1600'
7108
+ * ```
7109
+ */
7110
+ session(defaultValue, options = {}) {
7111
+ return {
7112
+ type: "session",
7113
+ defaultValue,
7114
+ value: defaultValue,
7115
+ title: options.title,
7116
+ options: options.options
7117
+ };
7118
+ },
7119
+ /**
7120
+ * Create a date/time input parameter (PineScript `input.time`)
7121
+ * @param defaultValue - Default UNIX time in milliseconds, e.g. `time.timestamp('2024-01-01')`
7122
+ * @param options - Additional options (title)
7123
+ * @returns Input value object
7124
+ *
7125
+ * @example
7126
+ * ```typescript
7127
+ * const start = input.time(time.timestamp('2024-01-01'), { title: 'Start' });
7128
+ * console.log(start.value); // 1704067200000
7129
+ * ```
7130
+ */
7131
+ time(defaultValue, options = {}) {
7132
+ return {
7133
+ type: "time",
7134
+ defaultValue,
7135
+ value: defaultValue,
7136
+ title: options.title
7137
+ };
6091
7138
  }
6092
7139
  };
6093
7140
  Object.freeze(input);
6094
7141
 
6095
7142
  // src/plot.ts
6096
- function plot(values, times, options = {}) {
7143
+ function plot(values2, times, options = {}) {
6097
7144
  const result = [];
6098
7145
  const offset = options.offset ?? 0;
6099
- for (let i = 0; i < values.length; i++) {
6100
- const value = values[i];
7146
+ for (let i = 0; i < values2.length; i++) {
7147
+ const value = values2[i];
6101
7148
  const timeIndex = i + offset;
6102
7149
  if (value === null || value === void 0 || Number.isNaN(value)) {
6103
7150
  continue;
@@ -6112,10 +7159,10 @@ function plot(values, times, options = {}) {
6112
7159
  }
6113
7160
  return result;
6114
7161
  }
6115
- function createPlot(id, values, times, options = {}) {
7162
+ function createPlot(id, values2, times, options = {}) {
6116
7163
  return {
6117
7164
  id,
6118
- data: plot(values, times, options),
7165
+ data: plot(values2, times, options),
6119
7166
  options
6120
7167
  };
6121
7168
  }
@@ -6356,6 +7403,42 @@ function input_string(defval, title, options) {
6356
7403
  const value = context2.inputs.getValue(id);
6357
7404
  return typeof value === "string" ? value : defval;
6358
7405
  }
7406
+ function registerOnce(config) {
7407
+ const context2 = getContext();
7408
+ if (!registeredInputs.has(config.id)) {
7409
+ context2.inputs.registerInput(config);
7410
+ registeredInputs.set(config.id, true);
7411
+ if (autoRecalculateEnabled) {
7412
+ context2.inputs.onInputChange((changedId) => {
7413
+ if (changedId === config.id) {
7414
+ recalculate();
7415
+ }
7416
+ });
7417
+ }
7418
+ }
7419
+ return context2.inputs.getValue(config.id);
7420
+ }
7421
+ function input_timeframe(defval, title, options) {
7422
+ if (!getContext()) {
7423
+ return defval;
7424
+ }
7425
+ const value = registerOnce({ id: generateInputId(title, defval, "timeframe"), type: "timeframe", defval, title, options });
7426
+ return typeof value === "string" ? value : defval;
7427
+ }
7428
+ function input_session(defval, title, options) {
7429
+ if (!getContext()) {
7430
+ return defval;
7431
+ }
7432
+ const value = registerOnce({ id: generateInputId(title, defval, "session"), type: "session", defval, title, options });
7433
+ return typeof value === "string" ? value : defval;
7434
+ }
7435
+ function input_time(defval, title) {
7436
+ if (!getContext()) {
7437
+ return defval;
7438
+ }
7439
+ const value = registerOnce({ id: generateInputId(title, defval, "time"), type: "time", defval, title });
7440
+ return typeof value === "number" ? value : defval;
7441
+ }
6359
7442
  function input_source(defval, title) {
6360
7443
  const context2 = getContext();
6361
7444
  if (!context2) {
@@ -6578,7 +7661,7 @@ var SimpleInputAdapter = class {
6578
7661
  validatedValue = Math.floor(validatedValue);
6579
7662
  }
6580
7663
  }
6581
- if (config.type === "string" && config.options && typeof value === "string") {
7664
+ if ((config.type === "string" || config.type === "timeframe" || config.type === "session") && config.options && typeof value === "string") {
6582
7665
  if (!config.options.includes(value)) {
6583
7666
  return;
6584
7667
  }
@@ -6626,8 +7709,8 @@ var SimpleInputAdapter = class {
6626
7709
  };
6627
7710
 
6628
7711
  // src/index.ts
6629
- var VERSION = "0.5.0";
6630
- var info = {
7712
+ var VERSION = "0.6.0";
7713
+ var info2 = {
6631
7714
  name: "OakScriptJS",
6632
7715
  version: VERSION,
6633
7716
  description: "Simplified PineScript-like library - Series + TA functions",
@@ -6640,8 +7723,8 @@ var info = {
6640
7723
  minimal: "No DSL layer - complexity in transpiler"
6641
7724
  },
6642
7725
  namespaces: {
6643
- core: ["ta", "math", "array", "str", "color", "time", "matrix"],
6644
- drawing: ["line", "box", "label", "linefill", "chartPoint", "polyline"],
7726
+ core: ["ta", "math", "array", "map", "str", "color", "time", "timeframe", "matrix"],
7727
+ drawing: ["line", "box", "label", "linefill", "chartPoint", "polyline", "text"],
6645
7728
  runtime: ["setContext", "plot", "hline", "input_*"],
6646
7729
  indicator: ["indicator", "input", "plotHelper", "createPlot"]
6647
7730
  }
@@ -6677,6 +7760,7 @@ export {
6677
7760
  cum2 as cum,
6678
7761
  ema2 as ema,
6679
7762
  exp,
7763
+ fixnan,
6680
7764
  floor,
6681
7765
  getClose,
6682
7766
  getContext,
@@ -6686,18 +7770,22 @@ export {
6686
7770
  getSourceSeries,
6687
7771
  hline,
6688
7772
  indicator,
6689
- info,
7773
+ info2 as info,
6690
7774
  input,
6691
7775
  input_bool,
6692
7776
  input_float,
6693
7777
  input_int,
7778
+ input_session,
6694
7779
  input_source,
6695
7780
  input_string,
7781
+ input_time,
7782
+ input_timeframe,
6696
7783
  label_exports as label,
6697
7784
  line_exports as line,
6698
7785
  linefill_exports as linefill,
6699
7786
  log,
6700
7787
  macd2 as macd,
7788
+ map_exports as map,
6701
7789
  math_exports as math,
6702
7790
  matrix_exports as matrix,
6703
7791
  max2 as max,
@@ -6725,7 +7813,9 @@ export {
6725
7813
  ta_series_exports as ta,
6726
7814
  ta_exports as taCore,
6727
7815
  tan,
7816
+ text_exports as text,
6728
7817
  time_exports as time,
7818
+ timeframe_exports as timeframe,
6729
7819
  tr2 as tr,
6730
7820
  vwap2 as vwap,
6731
7821
  xloc,