@reportman/engine 0.0.0-stage → 4.1.0-alpha.1

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 (252) hide show
  1. package/LICENSE +373 -0
  2. package/dist/.tsbuildinfo +1 -0
  3. package/dist/data/columns.d.ts +50 -0
  4. package/dist/data/columns.d.ts.map +1 -0
  5. package/dist/data/columns.js +385 -0
  6. package/dist/data/columns.js.map +1 -0
  7. package/dist/data/databaseinfo.d.ts +41 -0
  8. package/dist/data/databaseinfo.d.ts.map +1 -0
  9. package/dist/data/databaseinfo.js +145 -0
  10. package/dist/data/databaseinfo.js.map +1 -0
  11. package/dist/data/datainfo.d.ts +82 -0
  12. package/dist/data/datainfo.d.ts.map +1 -0
  13. package/dist/data/datainfo.js +449 -0
  14. package/dist/data/datainfo.js.map +1 -0
  15. package/dist/data/errors.d.ts +8 -0
  16. package/dist/data/errors.d.ts.map +1 -0
  17. package/dist/data/errors.js +14 -0
  18. package/dist/data/errors.js.map +1 -0
  19. package/dist/data/host.d.ts +132 -0
  20. package/dist/data/host.d.ts.map +1 -0
  21. package/dist/data/host.js +108 -0
  22. package/dist/data/host.js.map +1 -0
  23. package/dist/data/op.d.ts +21 -0
  24. package/dist/data/op.d.ts.map +1 -0
  25. package/dist/data/op.js +97 -0
  26. package/dist/data/op.js.map +1 -0
  27. package/dist/data/reportdataset.d.ts +116 -0
  28. package/dist/data/reportdataset.d.ts.map +1 -0
  29. package/dist/data/reportdataset.js +396 -0
  30. package/dist/data/reportdataset.js.map +1 -0
  31. package/dist/data/transfer.d.ts +46 -0
  32. package/dist/data/transfer.d.ts.map +1 -0
  33. package/dist/data/transfer.js +100 -0
  34. package/dist/data/transfer.js.map +1 -0
  35. package/dist/data/union.d.ts +88 -0
  36. package/dist/data/union.d.ts.map +1 -0
  37. package/dist/data/union.js +733 -0
  38. package/dist/data/union.js.map +1 -0
  39. package/dist/eval/chinesetables.d.ts +5 -0
  40. package/dist/eval/chinesetables.d.ts.map +1 -0
  41. package/dist/eval/chinesetables.js +8 -0
  42. package/dist/eval/chinesetables.js.map +1 -0
  43. package/dist/eval/evaluator.d.ts +100 -0
  44. package/dist/eval/evaluator.d.ts.map +1 -0
  45. package/dist/eval/evaluator.js +667 -0
  46. package/dist/eval/evaluator.js.map +1 -0
  47. package/dist/eval/exception.d.ts +9 -0
  48. package/dist/eval/exception.d.ts.map +1 -0
  49. package/dist/eval/exception.js +15 -0
  50. package/dist/eval/exception.js.map +1 -0
  51. package/dist/eval/fields.d.ts +60 -0
  52. package/dist/eval/fields.d.ts.map +1 -0
  53. package/dist/eval/fields.js +104 -0
  54. package/dist/eval/fields.js.map +1 -0
  55. package/dist/eval/functions.d.ts +27 -0
  56. package/dist/eval/functions.d.ts.map +1 -0
  57. package/dist/eval/functions.js +810 -0
  58. package/dist/eval/functions.js.map +1 -0
  59. package/dist/eval/identifiers.d.ts +100 -0
  60. package/dist/eval/identifiers.d.ts.map +1 -0
  61. package/dist/eval/identifiers.js +195 -0
  62. package/dist/eval/identifiers.js.map +1 -0
  63. package/dist/eval/parser.d.ts +47 -0
  64. package/dist/eval/parser.d.ts.map +1 -0
  65. package/dist/eval/parser.js +336 -0
  66. package/dist/eval/parser.js.map +1 -0
  67. package/dist/index.d.ts +52 -0
  68. package/dist/index.d.ts.map +1 -0
  69. package/dist/index.js +42 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/params/param.d.ts +92 -0
  72. package/dist/params/param.d.ts.map +1 -0
  73. package/dist/params/param.js +358 -0
  74. package/dist/params/param.js.map +1 -0
  75. package/dist/params/parameters.d.ts +87 -0
  76. package/dist/params/parameters.d.ts.map +1 -0
  77. package/dist/params/parameters.js +499 -0
  78. package/dist/params/parameters.js.map +1 -0
  79. package/dist/report/barcode/barcodeitem.d.ts +76 -0
  80. package/dist/report/barcode/barcodeitem.d.ts.map +1 -0
  81. package/dist/report/barcode/barcodeitem.js +864 -0
  82. package/dist/report/barcode/barcodeitem.js.map +1 -0
  83. package/dist/report/barcode/code128.d.ts +18 -0
  84. package/dist/report/barcode/code128.d.ts.map +1 -0
  85. package/dist/report/barcode/code128.js +187 -0
  86. package/dist/report/barcode/code128.js.map +1 -0
  87. package/dist/report/barcode/netutil.d.ts +30 -0
  88. package/dist/report/barcode/netutil.d.ts.map +1 -0
  89. package/dist/report/barcode/netutil.js +65 -0
  90. package/dist/report/barcode/netutil.js.map +1 -0
  91. package/dist/report/barcode/pdf417.d.ts +17 -0
  92. package/dist/report/barcode/pdf417.d.ts.map +1 -0
  93. package/dist/report/barcode/pdf417.js +782 -0
  94. package/dist/report/barcode/pdf417.js.map +1 -0
  95. package/dist/report/barcode/pdf417tables.d.ts +11 -0
  96. package/dist/report/barcode/pdf417tables.d.ts.map +1 -0
  97. package/dist/report/barcode/pdf417tables.js +880 -0
  98. package/dist/report/barcode/pdf417tables.js.map +1 -0
  99. package/dist/report/barcode/qrcode.d.ts +14 -0
  100. package/dist/report/barcode/qrcode.d.ts.map +1 -0
  101. package/dist/report/barcode/qrcode.js +214 -0
  102. package/dist/report/barcode/qrcode.js.map +1 -0
  103. package/dist/report/barcode/zxingwidth.d.ts +4 -0
  104. package/dist/report/barcode/zxingwidth.d.ts.map +1 -0
  105. package/dist/report/barcode/zxingwidth.js +247 -0
  106. package/dist/report/barcode/zxingwidth.js.map +1 -0
  107. package/dist/report/chart/chartidens.d.ts +70 -0
  108. package/dist/report/chart/chartidens.d.ts.map +1 -0
  109. package/dist/report/chart/chartidens.js +162 -0
  110. package/dist/report/chart/chartidens.js.map +1 -0
  111. package/dist/report/chart/chartitem.d.ts +110 -0
  112. package/dist/report/chart/chartitem.d.ts.map +1 -0
  113. package/dist/report/chart/chartitem.js +403 -0
  114. package/dist/report/chart/chartitem.js.map +1 -0
  115. package/dist/report/chart/series.d.ts +65 -0
  116. package/dist/report/chart/series.d.ts.map +1 -0
  117. package/dist/report/chart/series.js +74 -0
  118. package/dist/report/chart/series.js.map +1 -0
  119. package/dist/report/chart/vectorchart.d.ts +18 -0
  120. package/dist/report/chart/vectorchart.d.ts.map +1 -0
  121. package/dist/report/chart/vectorchart.js +356 -0
  122. package/dist/report/chart/vectorchart.js.map +1 -0
  123. package/dist/report/convert.d.ts +4 -0
  124. package/dist/report/convert.d.ts.map +1 -0
  125. package/dist/report/convert.js +162 -0
  126. package/dist/report/convert.js.map +1 -0
  127. package/dist/report/errors.d.ts +13 -0
  128. package/dist/report/errors.d.ts.map +1 -0
  129. package/dist/report/errors.js +20 -0
  130. package/dist/report/errors.js.map +1 -0
  131. package/dist/report/identifiers.d.ts +91 -0
  132. package/dist/report/identifiers.d.ts.map +1 -0
  133. package/dist/report/identifiers.js +404 -0
  134. package/dist/report/identifiers.js.map +1 -0
  135. package/dist/report/imageitem.d.ts +66 -0
  136. package/dist/report/imageitem.d.ts.map +1 -0
  137. package/dist/report/imageitem.js +190 -0
  138. package/dist/report/imageitem.js.map +1 -0
  139. package/dist/report/items.d.ts +219 -0
  140. package/dist/report/items.d.ts.map +1 -0
  141. package/dist/report/items.js +1015 -0
  142. package/dist/report/items.js.map +1 -0
  143. package/dist/report/report.d.ts +221 -0
  144. package/dist/report/report.d.ts.map +1 -0
  145. package/dist/report/report.js +1974 -0
  146. package/dist/report/report.js.map +1 -0
  147. package/dist/report/run.d.ts +87 -0
  148. package/dist/report/run.d.ts.map +1 -0
  149. package/dist/report/run.js +121 -0
  150. package/dist/report/run.js.map +1 -0
  151. package/dist/report/section.d.ts +86 -0
  152. package/dist/report/section.d.ts.map +1 -0
  153. package/dist/report/section.js +325 -0
  154. package/dist/report/section.js.map +1 -0
  155. package/dist/report/subreport.d.ts +49 -0
  156. package/dist/report/subreport.d.ts.map +1 -0
  157. package/dist/report/subreport.js +220 -0
  158. package/dist/report/subreport.js.map +1 -0
  159. package/dist/util/base64.d.ts +9 -0
  160. package/dist/util/base64.d.ts.map +1 -0
  161. package/dist/util/base64.js +60 -0
  162. package/dist/util/base64.js.map +1 -0
  163. package/dist/util/chars.d.ts +45 -0
  164. package/dist/util/chars.d.ts.map +1 -0
  165. package/dist/util/chars.js +194 -0
  166. package/dist/util/chars.js.map +1 -0
  167. package/dist/util/compositeformat.d.ts +3 -0
  168. package/dist/util/compositeformat.d.ts.map +1 -0
  169. package/dist/util/compositeformat.js +99 -0
  170. package/dist/util/compositeformat.js.map +1 -0
  171. package/dist/util/culture.d.ts +84 -0
  172. package/dist/util/culture.d.ts.map +1 -0
  173. package/dist/util/culture.js +59 -0
  174. package/dist/util/culture.js.map +1 -0
  175. package/dist/util/cultures.generated.d.ts +3 -0
  176. package/dist/util/cultures.generated.d.ts.map +1 -0
  177. package/dist/util/cultures.generated.js +1043 -0
  178. package/dist/util/cultures.generated.js.map +1 -0
  179. package/dist/util/dateformat.d.ts +21 -0
  180. package/dist/util/dateformat.d.ts.map +1 -0
  181. package/dist/util/dateformat.js +439 -0
  182. package/dist/util/dateformat.js.map +1 -0
  183. package/dist/util/dateparse.d.ts +12 -0
  184. package/dist/util/dateparse.d.ts.map +1 -0
  185. package/dist/util/dateparse.js +1212 -0
  186. package/dist/util/dateparse.js.map +1 -0
  187. package/dist/util/datetime.d.ts +70 -0
  188. package/dist/util/datetime.d.ts.map +1 -0
  189. package/dist/util/datetime.js +265 -0
  190. package/dist/util/datetime.js.map +1 -0
  191. package/dist/util/decimal.d.ts +54 -0
  192. package/dist/util/decimal.d.ts.map +1 -0
  193. package/dist/util/decimal.js +365 -0
  194. package/dist/util/decimal.js.map +1 -0
  195. package/dist/util/delphidateformat.d.ts +34 -0
  196. package/dist/util/delphidateformat.d.ts.map +1 -0
  197. package/dist/util/delphidateformat.js +247 -0
  198. package/dist/util/delphidateformat.js.map +1 -0
  199. package/dist/util/delphiformatsettings.generated.d.ts +3 -0
  200. package/dist/util/delphiformatsettings.generated.d.ts.map +1 -0
  201. package/dist/util/delphiformatsettings.generated.js +15 -0
  202. package/dist/util/delphiformatsettings.generated.js.map +1 -0
  203. package/dist/util/delphitext.d.ts +40 -0
  204. package/dist/util/delphitext.d.ts.map +1 -0
  205. package/dist/util/delphitext.js +408 -0
  206. package/dist/util/delphitext.js.map +1 -0
  207. package/dist/util/doubleutil.d.ts +30 -0
  208. package/dist/util/doubleutil.d.ts.map +1 -0
  209. package/dist/util/doubleutil.js +651 -0
  210. package/dist/util/doubleutil.js.map +1 -0
  211. package/dist/util/inflate.d.ts +7 -0
  212. package/dist/util/inflate.d.ts.map +1 -0
  213. package/dist/util/inflate.js +256 -0
  214. package/dist/util/inflate.js.map +1 -0
  215. package/dist/util/netexception.d.ts +59 -0
  216. package/dist/util/netexception.d.ts.map +1 -0
  217. package/dist/util/netexception.js +94 -0
  218. package/dist/util/netexception.js.map +1 -0
  219. package/dist/util/numberformat.d.ts +14 -0
  220. package/dist/util/numberformat.d.ts.map +1 -0
  221. package/dist/util/numberformat.js +828 -0
  222. package/dist/util/numberformat.js.map +1 -0
  223. package/dist/util/numberparse.d.ts +49 -0
  224. package/dist/util/numberparse.d.ts.map +1 -0
  225. package/dist/util/numberparse.js +568 -0
  226. package/dist/util/numberparse.js.map +1 -0
  227. package/dist/util/reportmanres.en.generated.d.ts +2 -0
  228. package/dist/util/reportmanres.en.generated.d.ts.map +1 -0
  229. package/dist/util/reportmanres.en.generated.js +2082 -0
  230. package/dist/util/reportmanres.en.generated.js.map +1 -0
  231. package/dist/util/reportmanres.es.generated.d.ts +2 -0
  232. package/dist/util/reportmanres.es.generated.d.ts.map +1 -0
  233. package/dist/util/reportmanres.es.generated.js +2082 -0
  234. package/dist/util/reportmanres.es.generated.js.map +1 -0
  235. package/dist/util/translator.d.ts +29 -0
  236. package/dist/util/translator.d.ts.map +1 -0
  237. package/dist/util/translator.js +79 -0
  238. package/dist/util/translator.js.map +1 -0
  239. package/dist/variant/coercion.d.ts +9 -0
  240. package/dist/variant/coercion.d.ts.map +1 -0
  241. package/dist/variant/coercion.js +298 -0
  242. package/dist/variant/coercion.js.map +1 -0
  243. package/dist/variant/context.d.ts +30 -0
  244. package/dist/variant/context.d.ts.map +1 -0
  245. package/dist/variant/context.js +22 -0
  246. package/dist/variant/context.js.map +1 -0
  247. package/dist/variant/variant.d.ts +193 -0
  248. package/dist/variant/variant.d.ts.map +1 -0
  249. package/dist/variant/variant.js +1235 -0
  250. package/dist/variant/variant.js.map +1 -0
  251. package/package.json +35 -4
  252. package/README.md +0 -3
@@ -0,0 +1,365 @@
1
+ // System.Decimal: a 96-bit unsigned mantissa, a scale (number of decimal places, 0 to 28) and a
2
+ // sign, with the arithmetic of .NET's DecCalc (decimal.DecCalc.cs):
3
+ //
4
+ // - add / subtract: exact at the larger scale; when the mantissa does not fit in 96 bits the
5
+ // scale is reduced, rounding half to even. The sign of a zero result is the sign of the operand
6
+ // with the smaller scale (1.0m - 1m is -0.0, as in .NET).
7
+ // - multiply: exact at scale s1 + s2, then reduced to scale <= 28 and 96 bits, half to even.
8
+ // A zero product of a mantissa wider than 32 bits is +0 with scale 0, and two 32-bit mantissas
9
+ // with s1 + s2 > 47 give +0 (the ReturnZero paths of VarDecMul).
10
+ // - divide: exact at the natural scale s1 - s2 when the remainder is zero; otherwise the quotient
11
+ // takes as many decimal places as fit (scale <= 28, 96 bits), rounds half to even and drops its
12
+ // trailing zeros (1.0m / 4m is 0.25, 1m / 3m is 0.3333333333333333333333333333).
13
+ // - conversion from double rounds to 15 significant digits (VarDecFromR8) and conversion to
14
+ // double is VarR8FromDec, not a correctly rounded conversion.
15
+ //
16
+ // bigint is used for the mantissa so every operation is exact before the .NET rounding step.
17
+ import { divideByZeroException, NetMessages, overflowException } from './netexception.js';
18
+ const MAX_SCALE = 28;
19
+ const TWO32 = 1n << 32n;
20
+ const TWO64 = 1n << 64n;
21
+ const TWO96 = 1n << 96n;
22
+ const MASK64 = TWO64 - 1n;
23
+ const POW10 = [1n];
24
+ /** 10^n as a bigint (cached). */
25
+ export function pow10n(n) {
26
+ while (POW10.length <= n)
27
+ POW10.push(POW10[POW10.length - 1] * 10n);
28
+ return POW10[n];
29
+ }
30
+ // s_doublePowers10 of DecCalc: the double literals 1e0 ... 1e80.
31
+ const DOUBLE_POWERS10 = [];
32
+ for (let i = 0; i <= 80; i++)
33
+ DOUBLE_POWERS10.push(Number('1e' + i));
34
+ /** n / d rounded half to even (n >= 0, d > 0). */
35
+ function divRoundHalfEven(n, d) {
36
+ const q = n / d;
37
+ const twice = (n - q * d) * 2n;
38
+ if (twice > d || (twice === d && (q & 1n) === 1n))
39
+ return q + 1n;
40
+ return q;
41
+ }
42
+ function overflow() {
43
+ throw overflowException(NetMessages.overflowDecimal);
44
+ }
45
+ /**
46
+ * The largest scale s <= min(scale, 28) at which the exact value mag / 10^scale fits in 96 bits
47
+ * once rounded half to even (ScaleResult of DecCalc). Overflow when not even scale 0 fits.
48
+ */
49
+ function fitToDecimal(mag, scale) {
50
+ if (scale <= MAX_SCALE && mag < TWO96)
51
+ return { mag, scale };
52
+ let s = Math.min(scale, MAX_SCALE);
53
+ // Start from an estimate of the digits to drop so that the loop runs few times.
54
+ const excessBits = mag.toString(2).length - 96;
55
+ if (excessBits > 2) {
56
+ // a lower bound of the digits to drop: mag >= 2^(95 + excessBits)
57
+ const minDrop = Math.floor((excessBits - 2) * 0.301);
58
+ if (scale - minDrop < s)
59
+ s = scale - minDrop;
60
+ }
61
+ for (;;) {
62
+ if (s < 0)
63
+ overflow();
64
+ const div = pow10n(scale - s);
65
+ if (mag / div >= TWO96) {
66
+ s--;
67
+ continue;
68
+ }
69
+ const m = divRoundHalfEven(mag, div);
70
+ if (m >= TWO96) {
71
+ s--;
72
+ continue;
73
+ }
74
+ return { mag: m, scale: s };
75
+ }
76
+ }
77
+ export class CsDecimal {
78
+ /** The magnitude of the mantissa, 0 <= mag < 2^96. */
79
+ mag;
80
+ /** Decimal places, 0 to 28. */
81
+ scale;
82
+ /** The sign bit (a decimal can be negative zero, which prints as 0). */
83
+ negative;
84
+ constructor(mag, scale, negative) {
85
+ this.mag = mag;
86
+ this.scale = scale;
87
+ this.negative = negative;
88
+ }
89
+ static zero = new CsDecimal(0n, 0, false);
90
+ static one = new CsDecimal(1n, 0, false);
91
+ /** A decimal from its parts; throws when they are out of the decimal range. */
92
+ static fromParts(mag, scale, negative) {
93
+ if (mag < 0n) {
94
+ mag = -mag;
95
+ negative = !negative;
96
+ }
97
+ if (mag >= TWO96 || scale < 0 || scale > MAX_SCALE || !Number.isInteger(scale))
98
+ overflow();
99
+ return new CsDecimal(mag, scale, negative);
100
+ }
101
+ /** (decimal) of an integer (int, long): scale 0. */
102
+ static fromInteger(value) {
103
+ const b = typeof value === 'bigint' ? value : BigInt(value);
104
+ if (b < 0n)
105
+ return CsDecimal.fromParts(-b, 0, true);
106
+ return CsDecimal.fromParts(b, 0, false);
107
+ }
108
+ /** (decimal)double, Convert.ToDecimal(double): VarDecFromR8, 15 significant digits. */
109
+ static fromDouble(input) {
110
+ const view = new DataView(new ArrayBuffer(8));
111
+ view.setFloat64(0, input);
112
+ const biasedExp = (view.getUint32(0) >>> 20) & 0x7ff;
113
+ const exp = biasedExp - 1022;
114
+ if (exp < -94)
115
+ return CsDecimal.zero;
116
+ if (exp > 96)
117
+ overflow();
118
+ let negative = false;
119
+ if (input < 0) {
120
+ input = -input;
121
+ negative = true;
122
+ }
123
+ let dbl = input;
124
+ let power = 14 - ((exp * 19728) >> 16);
125
+ if (power >= 0) {
126
+ if (power > MAX_SCALE)
127
+ power = MAX_SCALE;
128
+ dbl *= DOUBLE_POWERS10[power];
129
+ }
130
+ else {
131
+ if (power !== -1 || dbl >= 1e15)
132
+ dbl /= DOUBLE_POWERS10[-power];
133
+ else
134
+ power = 0;
135
+ }
136
+ if (dbl < 1e14 && power < MAX_SCALE) {
137
+ dbl *= 10;
138
+ power++;
139
+ }
140
+ // Math.Round: half to even
141
+ let r = Math.round(dbl);
142
+ if (r - dbl === 0.5 && r % 2 !== 0)
143
+ r -= 1;
144
+ let mant = BigInt(r);
145
+ if (mant === 0n)
146
+ return CsDecimal.zero;
147
+ if (power < 0) {
148
+ return new CsDecimal(mant * pow10n(-power), 0, negative);
149
+ }
150
+ let lmax = power > 14 ? 14 : power;
151
+ if ((mant & 0xffn) === 0n && lmax >= 8) {
152
+ if (mant % 100000000n === 0n) {
153
+ mant /= 100000000n;
154
+ power -= 8;
155
+ lmax -= 8;
156
+ }
157
+ }
158
+ if ((mant & 0xfn) === 0n && lmax >= 4) {
159
+ if (mant % 10000n === 0n) {
160
+ mant /= 10000n;
161
+ power -= 4;
162
+ lmax -= 4;
163
+ }
164
+ }
165
+ if ((mant & 3n) === 0n && lmax >= 2) {
166
+ if (mant % 100n === 0n) {
167
+ mant /= 100n;
168
+ power -= 2;
169
+ lmax -= 2;
170
+ }
171
+ }
172
+ if ((mant & 1n) === 0n && lmax >= 1) {
173
+ if (mant % 10n === 0n) {
174
+ mant /= 10n;
175
+ power--;
176
+ }
177
+ }
178
+ return new CsDecimal(mant, power, negative);
179
+ }
180
+ /** (double)decimal: VarR8FromDec. */
181
+ toDouble() {
182
+ const low64 = this.mag & MASK64;
183
+ const high = this.mag >> 64n;
184
+ let dbl = (Number(low64) + Number(high) * 18446744073709551616) / DOUBLE_POWERS10[this.scale];
185
+ if (this.negative)
186
+ dbl = -dbl;
187
+ return dbl;
188
+ }
189
+ get isZero() {
190
+ return this.mag === 0n;
191
+ }
192
+ /** decimal.Negate (flips the sign, also of zero). */
193
+ negate() {
194
+ return new CsDecimal(this.mag, this.scale, !this.negative);
195
+ }
196
+ /** Math.Abs(decimal). */
197
+ abs() {
198
+ return this.negative ? new CsDecimal(this.mag, this.scale, false) : this;
199
+ }
200
+ /** The exact value as numerator / 10^scale with sign: used to compare. */
201
+ signedMantissaAt(scale) {
202
+ const m = this.mag * pow10n(scale - this.scale);
203
+ return this.negative ? -m : m;
204
+ }
205
+ /** decimal.CompareTo: -1, 0 or 1 (zero and negative zero are equal). */
206
+ compareTo(other) {
207
+ const s = Math.max(this.scale, other.scale);
208
+ const a = this.signedMantissaAt(s);
209
+ const b = other.signedMantissaAt(s);
210
+ return a < b ? -1 : a > b ? 1 : 0;
211
+ }
212
+ equals(other) {
213
+ return this.compareTo(other) === 0;
214
+ }
215
+ add(other) {
216
+ return CsDecimal.addSub(this, other, false);
217
+ }
218
+ sub(other) {
219
+ return CsDecimal.addSub(this, other, true);
220
+ }
221
+ static addSub(a, b, subtract) {
222
+ const bNegative = subtract ? !b.negative : b.negative;
223
+ const scale = Math.max(a.scale, b.scale);
224
+ const am = a.mag * pow10n(scale - a.scale);
225
+ const bm = b.mag * pow10n(scale - b.scale);
226
+ // The operand with the smaller scale is the base of DecAddSub: its sign is the starting sign.
227
+ const swapped = b.scale < a.scale;
228
+ if (a.scale !== b.scale && (swapped ? b.mag : a.mag) === 0n) {
229
+ // "Left arg is zero, return right": the other operand as it is (0 - x is -x, x + 0 is x).
230
+ return swapped ? a : new CsDecimal(b.mag, b.scale, bNegative);
231
+ }
232
+ let negative = swapped ? bNegative : a.negative;
233
+ let mag;
234
+ if (a.negative === bNegative) {
235
+ mag = am + bm;
236
+ }
237
+ else {
238
+ const base = swapped ? bm : am;
239
+ const other = swapped ? am : bm;
240
+ mag = base - other;
241
+ if (mag < 0n) {
242
+ mag = -mag;
243
+ negative = !negative;
244
+ }
245
+ }
246
+ const fit = fitToDecimal(mag, scale);
247
+ return new CsDecimal(fit.mag, fit.scale, negative);
248
+ }
249
+ mul(other) {
250
+ const negative = this.negative !== other.negative;
251
+ const scale = this.scale + other.scale;
252
+ const product = this.mag * other.mag;
253
+ if (this.mag < TWO32 && other.mag < TWO32) {
254
+ if (scale > MAX_SCALE) {
255
+ if (scale > MAX_SCALE + 19)
256
+ return CsDecimal.zero;
257
+ const p = divRoundHalfEven(product, pow10n(scale - MAX_SCALE));
258
+ return new CsDecimal(p, MAX_SCALE, negative);
259
+ }
260
+ return new CsDecimal(product, scale, negative);
261
+ }
262
+ if (product === 0n)
263
+ return CsDecimal.zero;
264
+ const fit = fitToDecimal(product, scale);
265
+ return new CsDecimal(fit.mag, fit.scale, negative);
266
+ }
267
+ div(other) {
268
+ if (other.mag === 0n)
269
+ throw divideByZeroException();
270
+ const negative = this.negative !== other.negative;
271
+ const natural = this.scale - other.scale;
272
+ const num = this.mag;
273
+ const den = other.mag;
274
+ const q0 = num / den;
275
+ if (q0 * den === num) {
276
+ if (natural >= 0)
277
+ return new CsDecimal(q0, natural, negative);
278
+ const m = q0 * pow10n(-natural);
279
+ if (m >= TWO96)
280
+ overflow();
281
+ return new CsDecimal(m, 0, negative);
282
+ }
283
+ // Inexact at the natural scale: as many decimal places as fit, then the trailing zeros go.
284
+ // value = num / den * 10^-natural; at scale s the mantissa is num * 10^(s - natural) / den.
285
+ const atScale = (s) => s >= natural ? { n: num * pow10n(s - natural), d: den } : { n: num, d: den * pow10n(natural - s) };
286
+ let s = MAX_SCALE;
287
+ while (s >= 0) {
288
+ const { n, d } = atScale(s);
289
+ if (n / d < TWO96)
290
+ break;
291
+ s--;
292
+ }
293
+ if (s < 0)
294
+ overflow();
295
+ let mag;
296
+ // The remainder may become zero before the maximum scale: the quotient is then exact.
297
+ for (;;) {
298
+ const { n, d } = atScale(s);
299
+ mag = divRoundHalfEven(n, d);
300
+ if (mag >= TWO96) {
301
+ s--;
302
+ if (s < 0)
303
+ overflow();
304
+ continue;
305
+ }
306
+ break;
307
+ }
308
+ while (s > 0 && mag % 10n === 0n) {
309
+ mag /= 10n;
310
+ s--;
311
+ }
312
+ return new CsDecimal(mag, s, negative);
313
+ }
314
+ /** decimal.Truncate / Math.Truncate(decimal): scale 0, sign kept. */
315
+ truncate() {
316
+ if (this.scale === 0)
317
+ return this;
318
+ return new CsDecimal(this.mag / pow10n(this.scale), 0, this.negative);
319
+ }
320
+ /** Math.Round(decimal) / decimal.Round(d, 0): half to even, scale 0, sign kept. */
321
+ round() {
322
+ if (this.scale === 0)
323
+ return this;
324
+ return new CsDecimal(divRoundHalfEven(this.mag, pow10n(this.scale)), 0, this.negative);
325
+ }
326
+ /** decimal.ToInt64 (truncates; OverflowException out of range). */
327
+ toInt64() {
328
+ const t = this.mag / pow10n(this.scale);
329
+ const v = this.negative ? -t : t;
330
+ if (v > 9223372036854775807n || v < -9223372036854775808n)
331
+ throw overflowException(NetMessages.overflowInt64);
332
+ return v;
333
+ }
334
+ /** decimal.ToInt32 (truncates; OverflowException out of range). */
335
+ toInt32() {
336
+ const t = this.mag / pow10n(this.scale);
337
+ const v = this.negative ? -t : t;
338
+ if (v > 2147483647n || v < -2147483648n)
339
+ throw overflowException(NetMessages.overflowInt32);
340
+ return Number(v);
341
+ }
342
+ /** The decimal digits of the mantissa ("" for zero) and the decimal point position. */
343
+ digits() {
344
+ const d = this.mag === 0n ? '' : this.mag.toString();
345
+ return { digits: d, pointPos: d.length - this.scale };
346
+ }
347
+ /** Invariant text with the scale ("1.50", "-0.001", "0.00"): the "G" format of InvariantCulture. */
348
+ toInvariantString() {
349
+ let s = this.mag.toString();
350
+ if (this.scale > 0) {
351
+ s = s.padStart(this.scale + 1, '0');
352
+ s = s.slice(0, s.length - this.scale) + '.' + s.slice(s.length - this.scale);
353
+ }
354
+ return this.negative && this.mag !== 0n ? '-' + s : s;
355
+ }
356
+ /** Reads the invariant text of toInvariantString (digits, optional '-', optional '.'). */
357
+ static parseInvariant(text) {
358
+ const m = /^(-?)(\d+)(?:\.(\d+))?$/.exec(text);
359
+ if (m === null)
360
+ throw new Error(`Not an invariant decimal: '${text}'`);
361
+ const frac = m[3] ?? '';
362
+ return CsDecimal.fromParts(BigInt(m[2] + frac), frac.length, m[1] === '-');
363
+ }
364
+ }
365
+ //# sourceMappingURL=decimal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decimal.js","sourceRoot":"","sources":["../../src/util/decimal.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,oEAAoE;AACpE,EAAE;AACF,8FAA8F;AAC9F,mGAAmG;AACnG,6DAA6D;AAC7D,8FAA8F;AAC9F,kGAAkG;AAClG,oEAAoE;AACpE,mGAAmG;AACnG,mGAAmG;AACnG,oFAAoF;AACpF,6FAA6F;AAC7F,iEAAiE;AACjE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AG,CAAC,EAAE,CAAC;YACnB,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;YACpC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QAC/E,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,0FAA0F;IAC1F,MAAM,CAAC,cAAc,CAAC,IAAY;QAChC,MAAM,CAAC,GAAG,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/C,IAAI,CAAC,KAAK,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,IAAI,GAAG,CAAC,CAAC;QACvE,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAE,GAAG,IAAI,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;IAC9E,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { CultureInfo } from './culture.js';
2
+ import type { RpDateTime } from './datetime.js';
3
+ /** TFormatSettings: what FormatDateTime reads, the day names from Sunday. */
4
+ export interface DelphiFormatSettings {
5
+ readonly shortDateFormat: string;
6
+ readonly longDateFormat: string;
7
+ readonly shortTimeFormat: string;
8
+ readonly longTimeFormat: string;
9
+ readonly timeAMString: string;
10
+ readonly timePMString: string;
11
+ /** '' when Delphi has #0 (nothing is written). */
12
+ readonly dateSeparator: string;
13
+ readonly timeSeparator: string;
14
+ readonly shortMonthNames: readonly string[];
15
+ readonly longMonthNames: readonly string[];
16
+ readonly shortDayNames: readonly string[];
17
+ readonly longDayNames: readonly string[];
18
+ /** The era of the calendar of the locale (GetDateFormat 'gg'), for the g mask. */
19
+ readonly eraName: string;
20
+ }
21
+ /**
22
+ * The format settings of a culture: those of Delphi on Windows for the cultures with a table, by
23
+ * name or, for a neutral culture ("ca"), the first of its language.
24
+ */
25
+ export declare function delphiFormatSettings(culture: CultureInfo): DelphiFormatSettings;
26
+ /**
27
+ * FormatDateTime(mask, value) of Delphi: d m y h n s z for day, month, year, hour, minute, second
28
+ * and millisecond (m is the minute right after an h), ddd dddd mmm mmmm for the names, ddddd
29
+ * dddddd c t tt for the formats of the settings (one level deep, as Delphi), am/pm a/p ampm for the
30
+ * 12 hour clock (an h looks ahead for one before the next h), g and e for the era, / and : for the
31
+ * separators, quoted text as it is. An empty mask is c.
32
+ */
33
+ export declare function formatDateTimeDelphi(value: RpDateTime, mask: string, fs: DelphiFormatSettings): string;
34
+ //# sourceMappingURL=delphidateformat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delphidateformat.d.ts","sourceRoot":"","sources":["../../src/util/delphidateformat.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,6EAA6E;AAC7E,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,kDAAkD;IAClD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5C,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,kFAAkF;IAClF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,WAAW,GAAG,oBAAoB,CAO/E;AA2BD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,oBAAoB,GAAG,MAAM,CA2KtG"}
@@ -0,0 +1,247 @@
1
+ // The date masks of the Delphi engine, for the reports converted from Delphi (convertedFromDelphi,
2
+ // decision of 22-11-2026): FormatDateTime of the Delphi RTL (DateTimeToString of
3
+ // System.SysUtils), with the format settings Delphi takes from Windows for the culture
4
+ // (TFormatSettings.Create). The reports of the C# engine keep the masks of .NET (dateFormatMask).
5
+ // The same code as DelphiDateFormat.cs of the C# engine; both are checked against Delphi itself
6
+ // (tools/golden-delphi-dates).
7
+ import { DELPHI_FORMAT_SETTINGS } from './delphiformatsettings.generated.js';
8
+ /**
9
+ * The format settings of a culture: those of Delphi on Windows for the cultures with a table, by
10
+ * name or, for a neutral culture ("ca"), the first of its language.
11
+ */
12
+ export function delphiFormatSettings(culture) {
13
+ const name = culture.name.toLowerCase();
14
+ const keys = Object.keys(DELPHI_FORMAT_SETTINGS);
15
+ const key = keys.find((k) => k.toLowerCase() === name) ?? (name.includes('-') ? undefined : keys.find((k) => k.toLowerCase().startsWith(name + '-')));
16
+ // The engine has data for the cultures of the table only (CultureInfo.get)
17
+ return DELPHI_FORMAT_SETTINGS[key ?? 'en-US'];
18
+ }
19
+ const isHigh = (c) => c >= 0xd800 && c <= 0xdbff;
20
+ const isLow = (c) => c >= 0xdc00 && c <= 0xdfff;
21
+ /** The length of the character at i (StrCharLength): a surrogate pair is two code units. */
22
+ function charLength(s, i) {
23
+ return isHigh(s.charCodeAt(i)) && i + 1 < s.length && isLow(s.charCodeAt(i + 1)) ? 2 : 1;
24
+ }
25
+ /** StrLIComp(P, S, Length(S)) = 0: the text at i is s, ASCII letters in any case. */
26
+ function startsWithI(text, i, s) {
27
+ if (i + s.length > text.length)
28
+ return false;
29
+ for (let k = 0; k < s.length; k++) {
30
+ let a = text.charCodeAt(i + k);
31
+ if (a >= 97 && a <= 122)
32
+ a -= 32;
33
+ if (a !== s.charCodeAt(k))
34
+ return false;
35
+ }
36
+ return true;
37
+ }
38
+ /** '%.*d': at least digits digits. */
39
+ function pad(n, digits) {
40
+ const s = String(n);
41
+ return s.length >= digits ? s : '0'.repeat(digits - s.length) + s;
42
+ }
43
+ /**
44
+ * FormatDateTime(mask, value) of Delphi: d m y h n s z for day, month, year, hour, minute, second
45
+ * and millisecond (m is the minute right after an h), ddd dddd mmm mmmm for the names, ddddd
46
+ * dddddd c t tt for the formats of the settings (one level deep, as Delphi), am/pm a/p ampm for the
47
+ * 12 hour clock (an h looks ahead for one before the next h), g and e for the era, / and : for the
48
+ * separators, quoted text as it is. An empty mask is c.
49
+ */
50
+ export function formatDateTimeDelphi(value, mask, fs) {
51
+ const year = value.year;
52
+ const month = value.month;
53
+ const day = value.day;
54
+ const dow = value.dayOfWeek;
55
+ const hour = value.hour;
56
+ const min = value.minute;
57
+ const sec = value.second;
58
+ const msec = value.millisecond;
59
+ let out = '';
60
+ let level = 0;
61
+ const appendFormat = (format) => {
62
+ if (level >= 2)
63
+ return;
64
+ level++;
65
+ let lastToken = ' ';
66
+ let use12HourClock = false;
67
+ let i = 0;
68
+ while (i < format.length) {
69
+ const starter = format.charAt(i);
70
+ if (isHigh(format.charCodeAt(i))) {
71
+ const n = charLength(format, i);
72
+ out += format.substr(i, n);
73
+ i += n;
74
+ lastToken = ' ';
75
+ continue;
76
+ }
77
+ i++;
78
+ // GetCount: the starter and the same characters after it
79
+ const getCount = () => {
80
+ const p = i;
81
+ while (i < format.length && format.charAt(i) === starter)
82
+ i++;
83
+ return i - p + 1;
84
+ };
85
+ let token = starter;
86
+ const tc = token.charCodeAt(0);
87
+ if (tc >= 97 && tc <= 122)
88
+ token = String.fromCharCode(tc - 32);
89
+ const uc = token.charCodeAt(0);
90
+ if (uc >= 65 && uc <= 90) {
91
+ if (token === 'M' && lastToken === 'H')
92
+ token = 'N';
93
+ lastToken = token;
94
+ }
95
+ switch (token) {
96
+ case 'Y': {
97
+ const count = getCount();
98
+ out += count <= 2 ? pad(year % 100, 2) : pad(year, 4);
99
+ break;
100
+ }
101
+ case 'G':
102
+ getCount();
103
+ out += fs.eraName;
104
+ break;
105
+ case 'E': {
106
+ // ConvertYearString: GetDateFormat 'yy' or 'yyyy' in the calendar of the locale (Gregorian)
107
+ const count = getCount();
108
+ let s = count <= 2 ? pad(year % 100, 2) : pad(year, 4);
109
+ if (count === 1 && s.charAt(0) === '0')
110
+ s = s.substring(1);
111
+ out += s;
112
+ break;
113
+ }
114
+ case 'M': {
115
+ const count = getCount();
116
+ if (count <= 2)
117
+ out += pad(month, count);
118
+ else
119
+ out += count === 3 ? fs.shortMonthNames[month - 1] : fs.longMonthNames[month - 1];
120
+ break;
121
+ }
122
+ case 'D': {
123
+ const count = getCount();
124
+ if (count <= 2)
125
+ out += pad(day, count);
126
+ else if (count === 3)
127
+ out += fs.shortDayNames[dow];
128
+ else if (count === 4)
129
+ out += fs.longDayNames[dow];
130
+ else if (count === 5)
131
+ appendFormat(fs.shortDateFormat);
132
+ else
133
+ appendFormat(fs.longDateFormat);
134
+ break;
135
+ }
136
+ case 'H': {
137
+ let count = getCount();
138
+ // The 12 hour clock when an am/pm follows before another hour (outside quotes)
139
+ let betweenQuotes = false;
140
+ let p = i;
141
+ while (p < format.length) {
142
+ const ch = format.charAt(p);
143
+ if (isHigh(format.charCodeAt(p))) {
144
+ p += charLength(format, p);
145
+ continue;
146
+ }
147
+ if (ch === 'A' || ch === 'a') {
148
+ if (!betweenQuotes) {
149
+ if (startsWithI(format, p, 'AM/PM') || startsWithI(format, p, 'A/P') || startsWithI(format, p, 'AMPM'))
150
+ use12HourClock = true;
151
+ break;
152
+ }
153
+ }
154
+ else if (ch === 'H' || ch === 'h')
155
+ break;
156
+ else if (ch === "'" || ch === '"')
157
+ betweenQuotes = !betweenQuotes;
158
+ p++;
159
+ }
160
+ let h = hour;
161
+ if (use12HourClock) {
162
+ if (h === 0)
163
+ h = 12;
164
+ else if (h > 12)
165
+ h -= 12;
166
+ }
167
+ if (count > 2)
168
+ count = 2;
169
+ out += pad(h, count);
170
+ break;
171
+ }
172
+ case 'N':
173
+ out += pad(min, Math.min(getCount(), 2));
174
+ break;
175
+ case 'S':
176
+ out += pad(sec, Math.min(getCount(), 2));
177
+ break;
178
+ case 'T':
179
+ appendFormat(getCount() === 1 ? fs.shortTimeFormat : fs.longTimeFormat);
180
+ break;
181
+ case 'Z':
182
+ out += pad(msec, Math.min(getCount(), 3));
183
+ break;
184
+ case 'A': {
185
+ const p = i - 1;
186
+ if (startsWithI(format, p, 'AM/PM')) {
187
+ // The text of the mask itself: am/pm gives am or pm
188
+ out += format.substr(hour >= 12 ? p + 3 : p, 2);
189
+ i += 4;
190
+ use12HourClock = true;
191
+ }
192
+ else if (startsWithI(format, p, 'A/P')) {
193
+ out += format.charAt(hour >= 12 ? p + 2 : p);
194
+ i += 2;
195
+ use12HourClock = true;
196
+ }
197
+ else if (startsWithI(format, p, 'AMPM')) {
198
+ out += hour < 12 ? fs.timeAMString : fs.timePMString;
199
+ i += 3;
200
+ use12HourClock = true;
201
+ }
202
+ else if (startsWithI(format, p, 'AAAA')) {
203
+ out += fs.longDayNames[dow];
204
+ i += 3;
205
+ }
206
+ else if (startsWithI(format, p, 'AAA')) {
207
+ out += fs.shortDayNames[dow];
208
+ i += 2;
209
+ }
210
+ else
211
+ out += starter;
212
+ break;
213
+ }
214
+ case 'C':
215
+ getCount();
216
+ appendFormat(fs.shortDateFormat);
217
+ if (hour !== 0 || min !== 0 || sec !== 0 || msec !== 0) {
218
+ out += ' ';
219
+ appendFormat(fs.longTimeFormat);
220
+ }
221
+ break;
222
+ case '/':
223
+ out += fs.dateSeparator;
224
+ break;
225
+ case ':':
226
+ out += fs.timeSeparator;
227
+ break;
228
+ case "'":
229
+ case '"': {
230
+ const p = i;
231
+ while (i < format.length && format.charAt(i) !== starter)
232
+ i += isHigh(format.charCodeAt(i)) ? charLength(format, i) : 1;
233
+ out += format.substring(p, i);
234
+ if (i < format.length)
235
+ i++;
236
+ break;
237
+ }
238
+ default:
239
+ out += starter;
240
+ }
241
+ }
242
+ level--;
243
+ };
244
+ appendFormat(mask === '' ? 'C' : mask);
245
+ return out;
246
+ }
247
+ //# sourceMappingURL=delphidateformat.js.map