numora 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  var K = Object.defineProperty;
2
2
  var Q = (e, t, n) => t in e ? K(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var w = (e, t, n) => Q(e, typeof t != "symbol" ? t + "" : t, n);
4
- var v = /* @__PURE__ */ ((e) => (e.Blur = "blur", e.Change = "change", e))(v || {}), b = /* @__PURE__ */ ((e) => (e.None = "none", e.Thousand = "thousand", e.Lakh = "lakh", e.Wan = "wan", e))(b || {});
5
- const x = 2, I = 0, R = v.Blur, O = ",", _ = b.None, E = ".", X = !1, P = !1, B = !1, W = !1;
6
- function M(e) {
3
+ var L = (e, t, n) => Q(e, typeof t != "symbol" ? t + "" : t, n);
4
+ var v = /* @__PURE__ */ ((e) => (e.Blur = "blur", e.Change = "change", e))(v || {}), S = /* @__PURE__ */ ((e) => (e.None = "none", e.Thousand = "thousand", e.Lakh = "lakh", e.Wan = "wan", e))(S || {});
5
+ const I = 2, R = 0, O = v.Blur, _ = ",", B = S.None, E = ".", X = !1, P = !1, W = !1, k = !1;
6
+ function D(e) {
7
7
  return e.replace(/[-[\]/{}()*+?.\\^$|]/g, "\\$&");
8
8
  }
9
- function C(e) {
9
+ function A(e) {
10
10
  return {
11
11
  decimalSeparator: (e == null ? void 0 : e.decimalSeparator) ?? E,
12
12
  thousandSeparator: e == null ? void 0 : e.thousandSeparator
@@ -17,13 +17,13 @@ function Y(e, t) {
17
17
  return n ? n.value.includes(t) : !1;
18
18
  }
19
19
  function V(e, t, n, r) {
20
- const { selectionStart: i, selectionEnd: a, value: s } = t, { key: o } = e, c = n == null ? void 0 : n.ThousandStyle;
21
- if (c !== b.None && c !== void 0 || o !== "," && o !== ".")
20
+ const { selectionStart: i, selectionEnd: o, value: s } = t, { key: a } = e, c = n == null ? void 0 : n.ThousandStyle;
21
+ if (c !== S.None && c !== void 0 || a !== "," && a !== ".")
22
22
  return !1;
23
23
  if (Y(e, r))
24
24
  return !0;
25
- if (o !== r) {
26
- const l = i ?? 0, h = a ?? l, d = s.slice(0, l) + r + s.slice(h);
25
+ if (a !== r) {
26
+ const l = i ?? 0, h = o ?? l, d = s.slice(0, l) + r + s.slice(h);
27
27
  t.value = d;
28
28
  const u = l + 1;
29
29
  return t.setSelectionRange(u, u), !0;
@@ -34,330 +34,167 @@ const F = (e, t, n = E) => {
34
34
  const [r, i] = e.split(n);
35
35
  return i ? `${r}${n}${i.slice(0, t)}` : e;
36
36
  }, ee = (e, t = E) => {
37
- const n = M(t), r = new RegExp(`(${n}.*?)${n}`, "g");
37
+ const n = D(t), r = new RegExp(`(${n}.*?)${n}`, "g");
38
38
  return e.replace(r, `$1${t}`);
39
39
  }, te = (e, t = 0, n = E) => {
40
40
  if (t === 0)
41
41
  return e;
42
42
  if (!e || e === "0" || e === n || e === "-" || e === `-${n}`)
43
43
  return e === "-" || e === `-${n}` ? `-${n}${"0".repeat(t)}` : e === n ? `${n}${"0".repeat(t)}` : `${e}${n}${"0".repeat(t)}`;
44
- const r = e.includes(n), i = e.startsWith("-"), a = i ? e.slice(1) : e, [s, o = ""] = a.split(n);
44
+ const r = e.includes(n), i = e.startsWith("-"), o = i ? e.slice(1) : e, [s, a = ""] = o.split(n);
45
45
  if (!r) {
46
46
  const c = "0".repeat(t);
47
47
  return i ? `-${s}${n}${c}` : `${s}${n}${c}`;
48
48
  }
49
- if (o.length < t) {
50
- const c = t - o.length, l = o + "0".repeat(c);
49
+ if (a.length < t) {
50
+ const c = t - a.length, l = a + "0".repeat(c);
51
51
  return i ? `-${s}${n}${l}` : `${s}${n}${l}`;
52
52
  }
53
53
  return e;
54
- }, ne = (e, t = !1, n = ".") => {
55
- const r = M(n), i = new RegExp(`[^0-9${r}]`, "g");
56
- if (!t)
57
- return e.replace(i, "");
58
- const a = e.startsWith("-"), s = e.replace(i, "");
59
- if (a) {
60
- if (s.length > 0)
61
- return "-" + s;
62
- if (e === "-")
63
- return "-";
64
- }
65
- return s;
66
- };
67
- function re(e) {
68
- const t = /([+-]?\d+\.?\d*)[eE]([+-]?\d+)/g;
69
- let n = e, r;
70
- const i = [];
71
- for (; (r = t.exec(e)) !== null; ) {
72
- const a = r[0], s = r[1], o = parseInt(r[2], 10);
73
- let c;
74
- if (o === 0)
75
- c = s;
76
- else {
77
- const l = s.startsWith("-"), h = l ? s.slice(1) : s, [d, u = ""] = h.split(".");
78
- o > 0 ? c = se(d, u, o) : c = ie(d, u, Math.abs(o)), l && (c = "-" + c);
79
- }
80
- i.push({ full: a, expanded: c });
81
- }
82
- for (const { full: a, expanded: s } of i)
83
- n = n.replace(a, s);
84
- return n;
85
- }
86
- function se(e, t, n) {
87
- const r = e + t;
88
- if (r === "0" || r.match(/^0+$/))
89
- return "0";
90
- const i = t.length;
91
- if (n <= i) {
92
- const s = r.slice(0, e.length + n), o = r.slice(e.length + n);
93
- return o ? `${s}.${o}` : s;
94
- }
95
- const a = n - i;
96
- return r + "0".repeat(a);
97
- }
98
- function ie(e, t, n) {
99
- const r = e + t;
100
- if (r === "0" || r.match(/^0+$/))
101
- return "0";
102
- const s = e.length - n;
103
- if (s <= 0) {
104
- const o = Math.abs(s), c = `0.${"0".repeat(o)}${r}`;
105
- return y(c);
106
- }
107
- if (s < e.length) {
108
- const o = r.slice(0, s), c = r.slice(s), l = `${o}.${c}`;
109
- return y(l);
110
- }
111
- return y(r);
112
- }
113
- function y(e) {
114
- if (!e.includes("."))
115
- return e;
116
- if (e === "0" || e === "0.")
117
- return "0";
118
- if (e.startsWith("0.")) {
119
- const t = e.replace(/\.?0+$/, "");
120
- return t === "0" ? "0" : t || "0";
121
- }
122
- if (e.startsWith("-0.")) {
123
- const t = e.replace(/\.?0+$/, "");
124
- return t === "-0" || t === "0" ? "0" : t || "0";
125
- }
126
- return e.replace(/\.?0+$/, "") || e;
127
- }
128
- function ae(e) {
129
- const t = /(\d+\.?\d*)\s*(Qa|Qi|Sx|Sp|[kmbMTO]|N)/gi;
130
- return e.replace(t, (n, r, i) => {
131
- const a = {
132
- k: 3,
133
- // Thousand
134
- K: 3,
135
- // Thousand
136
- m: 6,
137
- // Million (lowercase)
138
- M: 6,
139
- // Million (uppercase)
140
- b: 9,
141
- // Billion
142
- B: 9,
143
- // Billion
144
- T: 12,
145
- // Trillion
146
- t: 12
147
- // Trillion
148
- };
149
- let s;
150
- if (i.length > 1) {
151
- const f = i.charAt(0).toUpperCase() + i.slice(1).toLowerCase();
152
- s = a[i] || a[f];
153
- } else {
154
- const f = i.toLowerCase();
155
- s = a[i] || a[f];
156
- }
157
- if (!s)
158
- return n;
159
- const o = r.startsWith("-"), c = o ? r.slice(1) : r, [l, h = ""] = c.split("."), d = l.replace(/^0+/, "") || "0";
160
- let u;
161
- if (h.length === 0)
162
- u = d + "0".repeat(s);
163
- else if (h.length <= s) {
164
- const f = s - h.length;
165
- u = d + h + "0".repeat(f);
166
- } else {
167
- const f = h.slice(0, s), g = h.slice(s);
168
- u = d + f + "." + g;
169
- }
170
- return u = u.replace(/^(-?)0+([1-9])/, "$1$2"), u.match(/^-?0+$/) && (u = o ? "-0" : "0"), u.includes(".") && (u = u.replace(/\.?0+$/, "")), o && !u.startsWith("-") ? "-" + u : u;
171
- });
172
- }
173
- function oe(e) {
174
- if (!e || e === "0" || e === "-0" || e === "-" || e === ".")
175
- return e;
176
- const t = e.startsWith("-"), n = t ? e.slice(1) : e;
177
- if (!n || n === "0" || n === ".")
178
- return e;
179
- if (n.includes(".")) {
180
- const [i, a] = n.split(".");
181
- if (i && i.length > 0) {
182
- const o = (i.replace(/^0+/, "") || "0") + "." + a;
183
- return t ? "-" + o : o;
184
- }
185
- return e;
186
- }
187
- if (n.startsWith("0") && n.length > 1) {
188
- const i = n.replace(/^0+/, "") || "0";
189
- return t ? "-" + i : i;
190
- }
191
- return e;
192
- }
193
- function ce(e) {
194
- return e.replace(/[\u00A0\u2000-\u200B\u202F\u205F\u3000]/g, " ").replace(/\s/g, "");
195
- }
196
- function L(e, t) {
197
- const n = M(t);
198
- return e.replace(new RegExp(n, "g"), "");
199
- }
200
- const le = (e, t) => {
201
- let n = ce(e);
202
- return t != null && t.thousandSeparator && (n = L(n, t.thousandSeparator)), t != null && t.enableCompactNotation && (n = ae(n)), n = re(n), n = ne(
203
- n,
204
- t == null ? void 0 : t.enableNegative,
205
- t == null ? void 0 : t.decimalSeparator
206
- ), n = ee(n, (t == null ? void 0 : t.decimalSeparator) || E), t != null && t.enableLeadingZeros || (n = oe(n)), n;
207
- };
208
- function he(e, t, n) {
209
- return {
210
- enableCompactNotation: e == null ? void 0 : e.enableCompactNotation,
211
- enableNegative: e == null ? void 0 : e.enableNegative,
212
- enableLeadingZeros: e == null ? void 0 : e.enableLeadingZeros,
213
- decimalSeparator: t.decimalSeparator,
214
- thousandSeparator: n ? t.thousandSeparator : void 0
215
- };
216
- }
217
- const N = {
54
+ }, N = {
218
55
  thousand: { size: 3 },
219
56
  lakh: { firstGroup: 3, restGroup: 2 },
220
57
  wan: { size: 4 }
221
58
  };
222
- function z(e, t, n, r = !1, i = ".") {
59
+ function G(e, t, n, r = !1, i = ".") {
223
60
  if (!e || e === "0" || e === i || e === "-" || e === `-${i}`)
224
61
  return e;
225
- const a = e.includes(i), s = e.startsWith("-"), o = s ? e.slice(1) : e, [c, l] = o.split(i);
62
+ const o = e.includes(i), s = e.startsWith("-"), a = s ? e.slice(1) : e, [c, l] = a.split(i);
226
63
  if (!c) {
227
- const u = l ? `${i}${l}` : o;
64
+ const u = l ? `${i}${l}` : a;
228
65
  return s ? `-${u}` : u;
229
66
  }
230
67
  if (r && c.startsWith("0") && c.length > 1) {
231
68
  const u = c.match(/^(0+)/);
232
69
  if (u) {
233
- const f = u[1], g = c.slice(f.length);
234
- if (g) {
235
- const p = k(g, t, n), $ = f + p, D = s ? "-" : "";
236
- return a ? l ? `${D}${$}${i}${l}` : `${D}${$}${i}` : `${D}${$}`;
70
+ const g = u[1], f = c.slice(g.length);
71
+ if (f) {
72
+ const p = Z(f, t, n), $ = g + p, m = s ? "-" : "";
73
+ return o ? l ? `${m}${$}${i}${l}` : `${m}${$}${i}` : `${m}${$}`;
237
74
  }
238
75
  }
239
76
  }
240
- const h = k(c, t, n), d = s ? "-" : "";
241
- return a ? l ? `${d}${h}${i}${l}` : `${d}${h}${i}` : `${d}${h}`;
77
+ const h = Z(c, t, n), d = s ? "-" : "";
78
+ return o ? l ? `${d}${h}${i}${l}` : `${d}${h}${i}` : `${d}${h}`;
242
79
  }
243
- function k(e, t, n) {
80
+ function Z(e, t, n) {
244
81
  if (e === "0" || e === "")
245
82
  return e;
246
83
  switch (n) {
247
- case b.None:
84
+ case S.None:
248
85
  return e;
249
- case b.Thousand:
250
- return ue(e, t);
251
- case b.Lakh:
252
- return de(e, t);
253
- case b.Wan:
254
- return fe(e, t);
86
+ case S.Thousand:
87
+ return ne(e, t);
88
+ case S.Lakh:
89
+ return re(e, t);
90
+ case S.Wan:
91
+ return se(e, t);
255
92
  default:
256
93
  return e;
257
94
  }
258
95
  }
259
- function ue(e, t) {
260
- return G(e, t, N.thousand.size);
96
+ function ne(e, t) {
97
+ return U(e, t, N.thousand.size);
261
98
  }
262
- function de(e, t) {
99
+ function re(e, t) {
263
100
  if (e.length <= N.lakh.firstGroup)
264
101
  return e;
265
102
  const n = e.split("").reverse(), r = [], i = n.slice(0, N.lakh.firstGroup).reverse().join("");
266
103
  r.push(i);
267
- for (let a = N.lakh.firstGroup; a < n.length; a += N.lakh.restGroup)
268
- r.push(n.slice(a, a + N.lakh.restGroup).reverse().join(""));
104
+ for (let o = N.lakh.firstGroup; o < n.length; o += N.lakh.restGroup)
105
+ r.push(n.slice(o, o + N.lakh.restGroup).reverse().join(""));
269
106
  return r.reverse().join(t);
270
107
  }
271
- function fe(e, t) {
272
- return G(e, t, N.wan.size);
108
+ function se(e, t) {
109
+ return U(e, t, N.wan.size);
273
110
  }
274
- function G(e, t, n) {
111
+ function U(e, t, n) {
275
112
  const r = e.split("").reverse(), i = [];
276
- for (let a = 0; a < r.length; a += n)
277
- i.push(r.slice(a, a + n).reverse().join(""));
113
+ for (let o = 0; o < r.length; o += n)
114
+ i.push(r.slice(o, o + n).reverse().join(""));
278
115
  return i.reverse().join(t);
279
116
  }
280
- function ge(e, t, n) {
281
- return (t == null ? void 0 : t.formatOn) === "change" && t.thousandSeparator ? z(
117
+ function ie(e, t, n) {
118
+ return (t == null ? void 0 : t.formatOn) === "change" && t.thousandSeparator ? G(
282
119
  e,
283
120
  t.thousandSeparator,
284
- t.ThousandStyle ?? b.None,
121
+ t.ThousandStyle ?? S.None,
285
122
  t.enableLeadingZeros,
286
123
  (n == null ? void 0 : n.decimalSeparator) ?? E
287
124
  ) : e;
288
125
  }
289
- function S(e, t, n, r = ".") {
126
+ function b(e, t, n, r = ".") {
290
127
  let i = 0;
291
- for (let a = 0; a < t && a < e.length; a++) {
292
- const s = e[a];
128
+ for (let o = 0; o < t && o < e.length; o++) {
129
+ const s = e[o];
293
130
  s !== n && s !== r && i++;
294
131
  }
295
132
  return i;
296
133
  }
297
- function pe(e, t, n, r = ".") {
134
+ function oe(e, t, n, r = ".") {
298
135
  if (t === 0)
299
136
  return 0;
300
137
  let i = 0;
301
- for (let a = 0; a < e.length; a++) {
302
- const s = e[a];
138
+ for (let o = 0; o < e.length; o++) {
139
+ const s = e[o];
303
140
  if (s !== n && s !== r) {
304
141
  if (i === t - 1)
305
- return a + 1;
142
+ return o + 1;
306
143
  i++;
307
144
  }
308
145
  }
309
146
  return e.length;
310
147
  }
311
- function A(e, t, n, r = ".") {
148
+ function C(e, t, n, r = ".") {
312
149
  if (t === 0)
313
150
  return 0;
314
151
  let i = 0;
315
- for (let a = 0; a < e.length; a++) {
316
- const s = e[a];
152
+ for (let o = 0; o < e.length; o++) {
153
+ const s = e[o];
317
154
  if (s !== n && s !== r) {
318
155
  if (i++, i === t)
319
- return a + 1;
156
+ return o + 1;
320
157
  if (i > t)
321
- return a;
158
+ return o;
322
159
  }
323
160
  }
324
161
  return e.length;
325
162
  }
326
- function U(e, t, n) {
163
+ function j(e, t, n) {
327
164
  return t < 0 || t >= e.length ? !1 : e[t] === n;
328
165
  }
329
- function be(e, t = {}) {
166
+ function ae(e, t = {}) {
330
167
  const {
331
168
  thousandSeparator: n,
332
169
  decimalSeparator: r = ".",
333
170
  prefix: i = "",
334
- suffix: a = ""
171
+ suffix: o = ""
335
172
  } = t, s = Array.from({ length: e.length + 1 }).map(() => !0);
336
- if (i && s.fill(!1, 0, i.length), a) {
337
- const o = e.length - a.length;
338
- s.fill(!1, o + 1, e.length + 1);
173
+ if (i && s.fill(!1, 0, i.length), o) {
174
+ const a = e.length - o.length;
175
+ s.fill(!1, a + 1, e.length + 1);
339
176
  }
340
- for (let o = 0; o < e.length; o++) {
341
- const c = e[o];
342
- (n && c === n || c === r) && (s[o] = !1, o + 1 < e.length && !/\d/.test(e[o + 1]) && (s[o + 1] = !1));
177
+ for (let a = 0; a < e.length; a++) {
178
+ const c = e[a];
179
+ (n && c === n || c === r) && (s[a] = !1, a + 1 < e.length && !/\d/.test(e[a + 1]) && (s[a + 1] = !1));
343
180
  }
344
- return s.some((o) => o) || s.fill(!0), s;
181
+ return s.some((a) => a) || s.fill(!0), s;
345
182
  }
346
183
  function T(e, t, n, r) {
347
184
  const i = e.length;
348
185
  if (t = Math.max(0, Math.min(t, i)), !n[t]) {
349
- let a = t;
350
- for (; a <= i && !n[a]; )
351
- a++;
186
+ let o = t;
187
+ for (; o <= i && !n[o]; )
188
+ o++;
352
189
  let s = t;
353
190
  for (; s >= 0 && !n[s]; )
354
191
  s--;
355
- a <= i && s >= 0 ? t = t - s < a - t ? s : a : a <= i ? t = a : s >= 0 && (t = s);
192
+ o <= i && s >= 0 ? t = t - s < o - t ? s : o : o <= i ? t = o : s >= 0 && (t = s);
356
193
  }
357
194
  return (t === -1 || t > i) && (t = i), t;
358
195
  }
359
- const j = (e, t) => e === t;
360
- function Se(e, t, n, r, i, a, s = ".", o = {}) {
196
+ const J = (e, t) => e === t;
197
+ function ce(e, t, n, r, i, o, s = ".", a = {}) {
361
198
  if (n < 0)
362
199
  return 0;
363
200
  if (n > e.length || e === "" || t === "")
@@ -365,25 +202,25 @@ function Se(e, t, n, r, i, a, s = ".", o = {}) {
365
202
  const c = /(\d+\.?\d*)\s*[kmbMTOQaqiSxsxSpOoNn]$/i;
366
203
  if (c.test(e) && !c.test(t) && t.length > e.length && n >= e.length - 1)
367
204
  return t.length;
368
- const l = t.length < e.length, h = U(
205
+ const l = t.length < e.length, h = j(
369
206
  e,
370
207
  n,
371
208
  r
372
209
  ), d = e.indexOf(s), u = t.indexOf(s);
373
- if (o.isCharacterEquivalent && e !== t) {
374
- const p = ve(
210
+ if (a.isCharacterEquivalent && e !== t) {
211
+ const p = le(
375
212
  e,
376
213
  t,
377
214
  n,
378
- o.isCharacterEquivalent || j,
379
- a,
380
- o
215
+ a.isCharacterEquivalent || J,
216
+ o,
217
+ a
381
218
  );
382
219
  if (p !== void 0)
383
220
  return p;
384
221
  }
385
222
  if (l)
386
- return $e(
223
+ return he(
387
224
  e,
388
225
  t,
389
226
  n,
@@ -391,11 +228,11 @@ function Se(e, t, n, r, i, a, s = ".", o = {}) {
391
228
  h,
392
229
  d,
393
230
  u,
394
- a,
231
+ o,
395
232
  s,
396
- o
233
+ a
397
234
  );
398
- const g = Le(
235
+ const f = ge(
399
236
  e,
400
237
  t,
401
238
  n,
@@ -403,26 +240,26 @@ function Se(e, t, n, r, i, a, s = ".", o = {}) {
403
240
  h,
404
241
  s
405
242
  );
406
- return o.boundary ? T(t, g, o.boundary) : g;
243
+ return a.boundary ? T(t, f, a.boundary) : f;
407
244
  }
408
- function ve(e, t, n, r, i, a) {
409
- const s = e.length, o = t.length, c = {}, l = new Array(s);
410
- for (let g = 0; g < s; g++) {
411
- l[g] = -1;
412
- for (let p = 0; p < o; p++) {
245
+ function le(e, t, n, r, i, o) {
246
+ const s = e.length, a = t.length, c = {}, l = new Array(s);
247
+ for (let f = 0; f < s; f++) {
248
+ l[f] = -1;
249
+ for (let p = 0; p < a; p++) {
413
250
  if (c[p]) continue;
414
251
  if (r(
415
- e[g],
252
+ e[f],
416
253
  t[p],
417
254
  {
418
255
  oldValue: e,
419
256
  newValue: t,
420
257
  typedRange: i,
421
- oldIndex: g,
258
+ oldIndex: f,
422
259
  newIndex: p
423
260
  }
424
261
  )) {
425
- l[g] = p, c[p] = !0;
262
+ l[f] = p, c[p] = !0;
426
263
  break;
427
264
  }
428
265
  }
@@ -430,16 +267,16 @@ function ve(e, t, n, r, i, a) {
430
267
  let h = n;
431
268
  for (; h < s && (l[h] === -1 || !/\d/.test(e[h])); )
432
269
  h++;
433
- const d = h === s || l[h] === -1 ? o : l[h];
270
+ const d = h === s || l[h] === -1 ? a : l[h];
434
271
  for (h = n - 1; h >= 0 && l[h] === -1; ) h--;
435
272
  const u = h === -1 || l[h] === -1 ? 0 : l[h] + 1;
436
273
  if (u > d) return d;
437
- const f = n - u < d - n ? u : d;
438
- return a.boundary ? T(t, f, a.boundary) : f;
274
+ const g = n - u < d - n ? u : d;
275
+ return o.boundary ? T(t, g, o.boundary) : g;
439
276
  }
440
- function $e(e, t, n, r, i, a, s, o, c, l = {}) {
277
+ function he(e, t, n, r, i, o, s, a, c, l = {}) {
441
278
  if (i)
442
- return Ee(
279
+ return ue(
443
280
  e,
444
281
  t,
445
282
  n,
@@ -447,97 +284,97 @@ function $e(e, t, n, r, i, a, s, o, c, l = {}) {
447
284
  s,
448
285
  c
449
286
  );
450
- const h = S(
287
+ const h = b(
451
288
  e,
452
289
  n,
453
290
  r,
454
291
  c
455
- ), d = S(
292
+ ), d = b(
456
293
  e,
457
294
  e.length,
458
295
  r,
459
296
  c
460
- ), u = S(
297
+ ), u = b(
461
298
  t,
462
299
  t.length,
463
300
  r,
464
301
  c
465
- ), f = d - u, g = Ne(
302
+ ), g = d - u, f = de(
466
303
  e,
467
304
  n,
468
305
  r,
469
306
  h,
470
- f,
471
- a,
307
+ g,
472
308
  o,
309
+ a,
473
310
  c
474
- ), p = a === -1 || n <= a, $ = we(
311
+ ), p = o === -1 || n <= o, $ = fe(
475
312
  t,
476
- g,
477
- r,
478
313
  f,
479
- o,
314
+ r,
315
+ g,
316
+ a,
480
317
  c,
481
318
  p,
482
319
  s
483
320
  );
484
321
  return l.boundary ? T(t, $, l.boundary) : $;
485
322
  }
486
- function Ee(e, t, n, r, i, a) {
323
+ function ue(e, t, n, r, i, o) {
487
324
  const s = n + 1;
488
325
  if (s < e.length) {
489
- const o = S(
326
+ const a = b(
490
327
  e,
491
328
  s,
492
329
  r,
493
- a
494
- ), c = pe(
330
+ o
331
+ ), c = oe(
495
332
  t,
496
- o,
333
+ a,
497
334
  r,
498
- a
335
+ o
499
336
  );
500
337
  return c < t.length && t[c] !== r ? c + 1 : c;
501
338
  }
502
339
  return n;
503
340
  }
504
- function Ne(e, t, n, r, i, a, s, o) {
341
+ function de(e, t, n, r, i, o, s, a) {
505
342
  if (s) {
506
343
  const { start: l, isDelete: h } = s;
507
- return h ? S(
344
+ return h ? b(
508
345
  e,
509
346
  l,
510
347
  n,
511
- o
512
- ) : Math.max(0, S(
348
+ a
349
+ ) : Math.max(0, b(
513
350
  e,
514
351
  l,
515
352
  n,
516
- o
353
+ a
517
354
  ));
518
355
  }
519
356
  return t > 0 && e[t - 1] === n && i > 0 ? r + 1 : r;
520
357
  }
521
- function we(e, t, n, r, i, a, s, o) {
522
- if (s && o !== -1) {
523
- const l = e.substring(0, o), h = S(
358
+ function fe(e, t, n, r, i, o, s, a) {
359
+ if (s && a !== -1) {
360
+ const l = e.substring(0, a), h = b(
524
361
  l,
525
362
  l.length,
526
363
  n,
527
- a
364
+ o
528
365
  );
529
366
  if (t <= h) {
530
- const d = A(
367
+ const d = C(
531
368
  l,
532
369
  t,
533
370
  n,
534
- a
371
+ o
535
372
  );
536
- if (d > 0 && d < l.length && S(
373
+ if (d > 0 && d < l.length && b(
537
374
  l,
538
375
  d,
539
376
  n,
540
- a
377
+ o
541
378
  ) === t) {
542
379
  if (l[d] === n && i && r > 0 && d < l.length - 1)
543
380
  return d + 1;
@@ -547,17 +384,17 @@ function we(e, t, n, r, i, a, s, o) {
547
384
  return d;
548
385
  }
549
386
  }
550
- const c = A(
387
+ const c = C(
551
388
  e,
552
389
  t,
553
390
  n,
554
- a
391
+ o
555
392
  );
556
- if (c > 0 && c < e.length && S(
393
+ if (c > 0 && c < e.length && b(
557
394
  e,
558
395
  c,
559
396
  n,
560
- a
397
+ o
561
398
  ) === t) {
562
399
  if (e[c] === n && i && r > 0 && c < e.length - 1)
563
400
  return c + 1;
@@ -566,38 +403,38 @@ function we(e, t, n, r, i, a, s, o) {
566
403
  }
567
404
  return c;
568
405
  }
569
- function Le(e, t, n, r, i, a) {
570
- const s = n >= e.length, o = S(
406
+ function ge(e, t, n, r, i, o) {
407
+ const s = n >= e.length, a = b(
571
408
  e,
572
409
  n,
573
410
  r,
574
- a
575
- ), c = S(
411
+ o
412
+ ), c = b(
576
413
  e,
577
414
  e.length,
578
415
  r,
579
- a
580
- ), l = S(
416
+ o
417
+ ), l = b(
581
418
  t,
582
419
  t.length,
583
420
  r,
584
- a
421
+ o
585
422
  );
586
- if (s || o === c)
423
+ if (s || a === c)
587
424
  return t.length;
588
425
  const h = l - c;
589
- let d = o;
590
- h > 0 && !s && o < c && (d = o + 1);
591
- const u = A(
426
+ let d = a;
427
+ h > 0 && !s && a < c && (d = a + 1);
428
+ const u = C(
592
429
  t,
593
430
  d,
594
431
  r,
595
- a
432
+ o
596
433
  );
597
- return i && !U(t, u, r) ? Math.max(0, u - 1) : u;
434
+ return i && !j(t, u, r) ? Math.max(0, u - 1) : u;
598
435
  }
599
- function Me(e, t, n) {
600
- const { selectionStart: r, selectionEnd: i, endOffset: a = 0 } = e;
436
+ function pe(e, t, n) {
437
+ const { selectionStart: r, selectionEnd: i, endOffset: o = 0 } = e;
601
438
  if (r !== i) {
602
439
  const h = i - r;
603
440
  return {
@@ -607,8 +444,8 @@ function Me(e, t, n) {
607
444
  isDelete: !1
608
445
  };
609
446
  }
610
- if (a > 0) {
611
- const h = a;
447
+ if (o > 0) {
448
+ const h = o;
612
449
  return {
613
450
  start: r,
614
451
  end: r + h,
@@ -616,7 +453,7 @@ function Me(e, t, n) {
616
453
  isDelete: !0
617
454
  };
618
455
  }
619
- const o = t.length, c = n.length, l = o - c;
456
+ const a = t.length, c = n.length, l = a - c;
620
457
  if (!(l <= 0))
621
458
  return {
622
459
  start: r,
@@ -625,7 +462,7 @@ function Me(e, t, n) {
625
462
  isDelete: !1
626
463
  };
627
464
  }
628
- function De(e, t) {
465
+ function Se(e, t) {
629
466
  if (e === t)
630
467
  return;
631
468
  let n = 0;
@@ -634,16 +471,16 @@ function De(e, t) {
634
471
  let r = e.length - 1, i = t.length - 1;
635
472
  for (; r >= n && i >= n && e[r] === t[i]; )
636
473
  r--, i--;
637
- const a = r - n + 1, s = i - n + 1;
638
- if (!(a === 0 && s === 0))
474
+ const o = r - n + 1, s = i - n + 1;
475
+ if (!(o === 0 && s === 0))
639
476
  return {
640
477
  start: n,
641
478
  end: r + 1,
642
- deletedLength: a,
643
- isDelete: a > s
479
+ deletedLength: o,
480
+ isDelete: o > s
644
481
  };
645
482
  }
646
- function Z(e, t) {
483
+ function z(e, t) {
647
484
  if (e.value = e.value, e === null)
648
485
  return !1;
649
486
  if (e.createTextRange) {
@@ -652,65 +489,237 @@ function Z(e, t) {
652
489
  }
653
490
  return e.selectionStart !== null || e.selectionStart === 0 ? (e.focus(), e.setSelectionRange(t, t), !0) : (e.focus(), !1);
654
491
  }
655
- function me(e, t, n) {
656
- return e.selectionStart === 0 && e.selectionEnd === e.value.length ? null : (Z(e, t), setTimeout(() => {
657
- e.value === n && e.selectionStart !== t && Z(e, t);
492
+ function be(e, t, n) {
493
+ return e.selectionStart === 0 && e.selectionEnd === e.value.length ? null : (z(e, t), setTimeout(() => {
494
+ e.value === n && e.selectionStart !== t && z(e, t);
658
495
  }, 0));
659
496
  }
660
- function ye(e) {
497
+ function ve(e) {
661
498
  return Math.max(e.selectionStart, e.selectionEnd);
662
499
  }
663
- function Ae(e, t, n) {
500
+ function $e(e, t, n) {
664
501
  if ((n == null ? void 0 : n.formatOn) !== v.Change || !n.thousandSeparator)
665
502
  return;
666
- const { selectionStart: r, selectionEnd: i, value: a } = t;
503
+ const { selectionStart: r, selectionEnd: i, value: o } = t;
667
504
  if (r === null || i === null || r !== i)
668
505
  return;
669
- const { key: s } = e, o = n.thousandSeparator;
670
- s === "Backspace" && r > 0 && a[r - 1] === o && t.setSelectionRange(r - 1, r - 1), s === "Delete" && a[r] === o && t.setSelectionRange(r + 1, r + 1);
506
+ const { key: s } = e, a = n.thousandSeparator;
507
+ s === "Backspace" && r > 0 && o[r - 1] === a && t.setSelectionRange(r - 1, r - 1), s === "Delete" && o[r] === a && t.setSelectionRange(r + 1, r + 1);
671
508
  }
672
- function Ce(e, t, n, r, i, a, s) {
509
+ function Ee(e, t, n, r, i, o, s) {
673
510
  if (!i) return;
674
- const { selectionStart: o = 0, selectionEnd: c = 0, endOffset: l = 0 } = i;
675
- let h = Me(
676
- { selectionStart: o, selectionEnd: c, endOffset: l },
511
+ const { selectionStart: a = 0, selectionEnd: c = 0, endOffset: l = 0 } = i;
512
+ let h = pe(
513
+ { selectionStart: a, selectionEnd: c, endOffset: l },
677
514
  t,
678
515
  n
679
516
  );
680
- if (h || (h = De(t, n)), !h) return;
681
- const d = be(n, {
682
- thousandSeparator: (s == null ? void 0 : s.thousandSeparator) ?? a.thousandSeparator,
683
- decimalSeparator: a.decimalSeparator
517
+ if (h || (h = Se(t, n)), !h) return;
518
+ const d = ae(n, {
519
+ thousandSeparator: (s == null ? void 0 : s.thousandSeparator) ?? o.thousandSeparator,
520
+ decimalSeparator: o.decimalSeparator
684
521
  }), u = {
685
- thousandSeparator: (s == null ? void 0 : s.thousandSeparator) ?? a.thousandSeparator,
686
- isCharacterEquivalent: j,
522
+ thousandSeparator: (s == null ? void 0 : s.thousandSeparator) ?? o.thousandSeparator,
523
+ isCharacterEquivalent: J,
687
524
  boundary: d
688
- }, f = (s == null ? void 0 : s.thousandSeparator) ?? a.thousandSeparator ?? ",", g = (s == null ? void 0 : s.ThousandStyle) ?? b.None, p = Se(
525
+ }, g = (s == null ? void 0 : s.thousandSeparator) ?? o.thousandSeparator ?? ",", f = (s == null ? void 0 : s.ThousandStyle) ?? S.None, p = ce(
689
526
  t,
690
527
  n,
691
528
  r,
692
- f,
693
529
  g,
530
+ f,
694
531
  h,
695
- a.decimalSeparator,
532
+ o.decimalSeparator,
696
533
  u
697
534
  );
698
- me(e, p, n);
535
+ be(e, p, n);
536
+ }
537
+ const Ne = (e, t = !1, n = ".") => {
538
+ const r = D(n), i = new RegExp(`[^0-9${r}]`, "g");
539
+ if (!t)
540
+ return e.replace(i, "");
541
+ const o = e.startsWith("-"), s = e.replace(i, "");
542
+ if (o) {
543
+ if (s.length > 0)
544
+ return "-" + s;
545
+ if (e === "-")
546
+ return "-";
547
+ }
548
+ return s;
549
+ };
550
+ function Le(e) {
551
+ const t = /([+-]?\d+\.?\d*)[eE]([+-]?\d+)/g;
552
+ let n = e, r;
553
+ const i = [];
554
+ for (; (r = t.exec(e)) !== null; ) {
555
+ const o = r[0], s = r[1], a = parseInt(r[2], 10);
556
+ let c;
557
+ if (a === 0)
558
+ c = s;
559
+ else {
560
+ const l = s.startsWith("-"), h = l ? s.slice(1) : s, [d, u = ""] = h.split(".");
561
+ a > 0 ? c = we(d, u, a) : c = De(d, u, Math.abs(a)), l && (c = "-" + c);
562
+ }
563
+ i.push({ full: o, expanded: c });
564
+ }
565
+ for (const { full: o, expanded: s } of i)
566
+ n = n.replace(o, s);
567
+ return n;
568
+ }
569
+ function we(e, t, n) {
570
+ const r = e + t;
571
+ if (r === "0" || r.match(/^0+$/))
572
+ return "0";
573
+ const i = t.length;
574
+ if (n <= i) {
575
+ const s = r.slice(0, e.length + n), a = r.slice(e.length + n);
576
+ return a ? `${s}.${a}` : s;
577
+ }
578
+ const o = n - i;
579
+ return r + "0".repeat(o);
580
+ }
581
+ function De(e, t, n) {
582
+ const r = e + t;
583
+ if (r === "0" || r.match(/^0+$/))
584
+ return "0";
585
+ const s = e.length - n;
586
+ if (s <= 0) {
587
+ const a = Math.abs(s), c = `0.${"0".repeat(a)}${r}`;
588
+ return y(c);
589
+ }
590
+ if (s < e.length) {
591
+ const a = r.slice(0, s), c = r.slice(s), l = `${a}.${c}`;
592
+ return y(l);
593
+ }
594
+ return y(r);
699
595
  }
700
- function J(e, t, n, r, i) {
701
- const a = le(
596
+ function y(e) {
597
+ if (!e.includes("."))
598
+ return e;
599
+ if (e === "0" || e === "0.")
600
+ return "0";
601
+ if (e.startsWith("0.")) {
602
+ const t = e.replace(/\.?0+$/, "");
603
+ return t === "0" ? "0" : t || "0";
604
+ }
605
+ if (e.startsWith("-0.")) {
606
+ const t = e.replace(/\.?0+$/, "");
607
+ return t === "-0" || t === "0" ? "0" : t || "0";
608
+ }
609
+ return e.replace(/\.?0+$/, "") || e;
610
+ }
611
+ function me(e) {
612
+ const t = /(\d+\.?\d*)\s*(Qa|Qi|Sx|Sp|[kmbMTO]|N)/gi;
613
+ return e.replace(t, (n, r, i) => {
614
+ const o = {
615
+ k: 3,
616
+ // Thousand
617
+ K: 3,
618
+ // Thousand
619
+ m: 6,
620
+ // Million (lowercase)
621
+ M: 6,
622
+ // Million (uppercase)
623
+ b: 9,
624
+ // Billion
625
+ B: 9,
626
+ // Billion
627
+ T: 12,
628
+ // Trillion
629
+ t: 12
630
+ // Trillion
631
+ };
632
+ let s;
633
+ if (i.length > 1) {
634
+ const g = i.charAt(0).toUpperCase() + i.slice(1).toLowerCase();
635
+ s = o[i] || o[g];
636
+ } else {
637
+ const g = i.toLowerCase();
638
+ s = o[i] || o[g];
639
+ }
640
+ if (!s)
641
+ return n;
642
+ const a = r.startsWith("-"), c = a ? r.slice(1) : r, [l, h = ""] = c.split("."), d = l.replace(/^0+/, "") || "0";
643
+ let u;
644
+ if (h.length === 0)
645
+ u = d + "0".repeat(s);
646
+ else if (h.length <= s) {
647
+ const g = s - h.length;
648
+ u = d + h + "0".repeat(g);
649
+ } else {
650
+ const g = h.slice(0, s), f = h.slice(s);
651
+ u = d + g + "." + f;
652
+ }
653
+ return u = u.replace(/^(-?)0+([1-9])/, "$1$2"), u.match(/^-?0+$/) && (u = a ? "-0" : "0"), u.includes(".") && (u = u.replace(/\.?0+$/, "")), a && !u.startsWith("-") ? "-" + u : u;
654
+ });
655
+ }
656
+ function Me(e) {
657
+ if (!e || e === "0" || e === "-0" || e === "-" || e === ".")
658
+ return e;
659
+ const t = e.startsWith("-"), n = t ? e.slice(1) : e;
660
+ if (!n || n === "0" || n === ".")
661
+ return e;
662
+ if (n.includes(".")) {
663
+ const [i, o] = n.split(".");
664
+ if (i && i.length > 0) {
665
+ const a = (i.replace(/^0+/, "") || "0") + "." + o;
666
+ return t ? "-" + a : a;
667
+ }
668
+ return e;
669
+ }
670
+ if (n.startsWith("0") && n.length > 1) {
671
+ const i = n.replace(/^0+/, "") || "0";
672
+ return t ? "-" + i : i;
673
+ }
674
+ return e;
675
+ }
676
+ function ye(e) {
677
+ return e.replace(/[\u00A0\u2000-\u200B\u202F\u205F\u3000]/g, " ").replace(/\s/g, "");
678
+ }
679
+ function w(e, t) {
680
+ const n = D(t);
681
+ return e.replace(new RegExp(n, "g"), "");
682
+ }
683
+ const Ce = (e, t) => {
684
+ let n = ye(e);
685
+ return t != null && t.thousandSeparator && (n = w(n, t.thousandSeparator)), t != null && t.enableCompactNotation && (n = me(n)), n = Le(n), n = Ne(
686
+ n,
687
+ t == null ? void 0 : t.enableNegative,
688
+ t == null ? void 0 : t.decimalSeparator
689
+ ), n = ee(n, (t == null ? void 0 : t.decimalSeparator) || E), t != null && t.enableLeadingZeros || (n = Me(n)), n;
690
+ };
691
+ function Ae(e, t, n) {
692
+ return {
693
+ enableCompactNotation: e == null ? void 0 : e.enableCompactNotation,
694
+ enableNegative: e == null ? void 0 : e.enableNegative,
695
+ enableLeadingZeros: e == null ? void 0 : e.enableLeadingZeros,
696
+ decimalSeparator: t.decimalSeparator,
697
+ thousandSeparator: n ? t.thousandSeparator : void 0
698
+ };
699
+ }
700
+ function x(e, t, n, r) {
701
+ const i = A(n), o = r ?? (n == null ? void 0 : n.formatOn) === v.Change, s = Ce(
702
702
  e,
703
- he(r, i, n)
704
- ), s = F(
705
- a,
703
+ Ae(n, i, o)
704
+ ), a = F(
705
+ s,
706
706
  t,
707
707
  i.decimalSeparator
708
- ), o = (r == null ? void 0 : r.decimalMinLength) ?? 0, c = te(
709
- s,
710
- o,
708
+ ), c = (n == null ? void 0 : n.decimalMinLength) ?? 0, l = te(
709
+ a,
710
+ c,
711
711
  i.decimalSeparator
712
- ), l = c;
713
- return { formatted: ge(c, r, i), raw: l };
712
+ ), h = l;
713
+ return { formatted: ie(l, n, i), raw: h };
714
+ }
715
+ function Ke(e, t, n) {
716
+ const r = !!(n != null && n.thousandSeparator);
717
+ return x(
718
+ e,
719
+ t,
720
+ n,
721
+ r
722
+ );
714
723
  }
715
724
  function Te(e, t, n) {
716
725
  if (e === "Backspace" || e === "Delete")
@@ -721,62 +730,60 @@ function Te(e, t, n) {
721
730
  };
722
731
  }
723
732
  function xe(e, t) {
724
- const { decimalSeparator: n } = C(t), r = e.target;
733
+ const { decimalSeparator: n } = A(t), r = e.target;
725
734
  if (V(e, r, t, n)) {
726
735
  e.preventDefault();
727
736
  return;
728
737
  }
729
- return Ae(e, r, t), Te(e.key, r.selectionStart, r.selectionEnd);
738
+ return $e(e, r, t), Te(e.key, r.selectionStart, r.selectionEnd);
730
739
  }
731
740
  function Ie(e, t, n, r) {
732
- const i = e.target, a = i.value, s = ye(i), o = C(r), c = (r == null ? void 0 : r.formatOn) === v.Change, { formatted: l, raw: h } = J(
733
- a,
741
+ const i = e.target, o = i.value, s = ve(i), a = A(r), c = (r == null ? void 0 : r.formatOn) === v.Change, { formatted: l, raw: h } = x(
742
+ o,
734
743
  t,
735
- c,
736
744
  r,
737
- o
745
+ c
738
746
  );
739
- i.value = l, r != null && r.rawValueMode && i.setAttribute("data-raw-value", h), a !== l && Ce(
747
+ return i.value = l, o !== l && Ee(
740
748
  i,
741
- a,
749
+ o,
742
750
  l,
743
751
  s,
744
752
  n,
745
- o,
753
+ a,
746
754
  r
747
- );
755
+ ), { formatted: l, raw: h };
748
756
  }
749
757
  function Re(e, t, n, r) {
750
758
  const i = r - n;
751
759
  return e + t + i;
752
760
  }
753
761
  function Oe(e, t, n) {
754
- var f;
762
+ var u;
755
763
  e.preventDefault();
756
- const r = e.target, { value: i, selectionStart: a, selectionEnd: s } = r, o = C(n), c = ((f = e.clipboardData) == null ? void 0 : f.getData("text/plain")) || "", l = i.slice(0, a || 0) + c + i.slice(s || 0), { formatted: h, raw: d } = J(
757
- l,
764
+ const r = e.target, { value: i, selectionStart: o, selectionEnd: s } = r, a = ((u = e.clipboardData) == null ? void 0 : u.getData("text/plain")) || "", c = i.slice(0, o || 0) + a + i.slice(s || 0), { formatted: l, raw: h } = x(
765
+ c,
758
766
  t,
759
- !0,
760
767
  n,
761
- o
768
+ !0
762
769
  );
763
- r.value = h, n != null && n.rawValueMode && r.setAttribute("data-raw-value", d);
764
- const u = Re(
765
- a || 0,
770
+ r.value = l;
771
+ const d = Re(
772
+ o || 0,
773
+ a.length,
766
774
  c.length,
767
- l.length,
768
- h.length
775
+ l.length
769
776
  );
770
- return r.setSelectionRange(u, u), r.value;
777
+ return r.setSelectionRange(d, d), { formatted: l, raw: h };
771
778
  }
772
779
  function _e(e, t) {
773
- const n = M(e);
780
+ const n = D(e);
774
781
  return t ? `^-?[0-9]*[${n}]?[0-9]*$` : `^[0-9]*[${n}]?[0-9]*$`;
775
782
  }
776
- function Pe(e) {
777
- Be(e.decimalMaxLength), We(e.decimalMinLength), ke(e.decimalMinLength, e.decimalMaxLength), Ze(e.formatOn), ze(e.thousandSeparator), Ge(e.thousandStyle), Ue(e.decimalSeparator), je(e.thousandSeparator, e.decimalSeparator), m("enableCompactNotation", e.enableCompactNotation), m("enableNegative", e.enableNegative), m("enableLeadingZeros", e.enableLeadingZeros), m("rawValueMode", e.rawValueMode), Je(e.onChange);
778
- }
779
783
  function Be(e) {
784
+ Pe(e.decimalMaxLength), We(e.decimalMinLength), ke(e.decimalMinLength, e.decimalMaxLength), Ze(e.formatOn), ze(e.thousandSeparator), Ge(e.thousandStyle), Ue(e.decimalSeparator), je(e.thousandSeparator, e.decimalSeparator), M("enableCompactNotation", e.enableCompactNotation), M("enableNegative", e.enableNegative), M("enableLeadingZeros", e.enableLeadingZeros), M("rawValueMode", e.rawValueMode), Je(e.onChange);
785
+ }
786
+ function Pe(e) {
780
787
  if (e !== void 0) {
781
788
  if (typeof e != "number")
782
789
  throw new Error(
@@ -837,9 +844,9 @@ function ze(e) {
837
844
  }
838
845
  }
839
846
  function Ge(e) {
840
- if (e !== void 0 && !Object.values(b).includes(e))
847
+ if (e !== void 0 && !Object.values(S).includes(e))
841
848
  throw new Error(
842
- `ThousandStyle must be one of: ${Object.values(b).map((t) => `'${t}'`).join(", ")}. Received: ${JSON.stringify(e)}`
849
+ `ThousandStyle must be one of: ${Object.values(S).map((t) => `'${t}'`).join(", ")}. Received: ${JSON.stringify(e)}`
843
850
  );
844
851
  }
845
852
  function Ue(e) {
@@ -864,7 +871,7 @@ function je(e, t) {
864
871
  `Decimal separator can't be same as thousand separator. thousandSeparator: ${e}, decimalSeparator: ${t}`
865
872
  );
866
873
  }
867
- function m(e, t) {
874
+ function M(e, t) {
868
875
  if (t !== void 0 && typeof t != "boolean")
869
876
  throw new Error(
870
877
  `${e} must be a boolean. Received: ${typeof t} (${JSON.stringify(t)})`
@@ -876,33 +883,33 @@ function Je(e) {
876
883
  `onChange must be a function or undefined. Received: ${typeof e} (${JSON.stringify(e)})`
877
884
  );
878
885
  }
879
- class Ke {
886
+ class Qe {
880
887
  constructor(t, {
881
- decimalMaxLength: n = x,
882
- decimalMinLength: r = I,
883
- formatOn: i = R,
884
- thousandSeparator: a = O,
885
- thousandStyle: s = _,
886
- decimalSeparator: o = E,
888
+ decimalMaxLength: n = I,
889
+ decimalMinLength: r = R,
890
+ formatOn: i = O,
891
+ thousandSeparator: o = _,
892
+ thousandStyle: s = B,
893
+ decimalSeparator: a = E,
887
894
  enableCompactNotation: c = !0,
888
895
  enableNegative: l = P,
889
- enableLeadingZeros: h = B,
890
- rawValueMode: d = W,
896
+ enableLeadingZeros: h = W,
897
+ rawValueMode: d = k,
891
898
  onChange: u,
892
- ...f
899
+ ...g
893
900
  }) {
894
- w(this, "element");
895
- w(this, "options");
896
- w(this, "resolvedOptions");
897
- w(this, "rawValue", "");
898
- w(this, "caretPositionBeforeChange");
899
- if (Pe({
901
+ L(this, "element");
902
+ L(this, "options");
903
+ L(this, "resolvedOptions");
904
+ L(this, "rawValue", "");
905
+ L(this, "caretPositionBeforeChange");
906
+ if (Be({
900
907
  decimalMaxLength: n,
901
908
  decimalMinLength: r,
902
909
  formatOn: i,
903
- thousandSeparator: a,
910
+ thousandSeparator: o,
904
911
  thousandStyle: s,
905
- decimalSeparator: o,
912
+ decimalSeparator: a,
906
913
  enableCompactNotation: c,
907
914
  enableNegative: l,
908
915
  enableLeadingZeros: h,
@@ -913,20 +920,20 @@ class Ke {
913
920
  decimalMinLength: r,
914
921
  onChange: u,
915
922
  formatOn: i,
916
- thousandSeparator: a,
923
+ thousandSeparator: o,
917
924
  thousandStyle: s,
918
- decimalSeparator: o,
925
+ decimalSeparator: a,
919
926
  enableCompactNotation: c,
920
927
  enableNegative: l,
921
928
  enableLeadingZeros: h,
922
929
  rawValueMode: d,
923
- ...f
930
+ ...g
924
931
  }, this.resolvedOptions = this.getResolvedOptions(), this.createInputElement(t), this.setupEventListeners(), this.resolvedOptions.rawValueMode && this.element.value) {
925
- const g = this.element.value, p = this.resolvedOptions.thousandSeparator ? L(g, this.resolvedOptions.thousandSeparator) : g;
932
+ const f = this.element.value, p = this.resolvedOptions.thousandSeparator ? w(f, this.resolvedOptions.thousandSeparator) : f;
926
933
  this.rawValue = p, this.element.value = this.formatValueForDisplay(p);
927
- } else if (this.element.value && !this.resolvedOptions.rawValueMode) {
928
- const g = this.element.value;
929
- this.element.value = this.formatValueForDisplay(g);
934
+ } else if (this.element.value) {
935
+ const f = this.element.value;
936
+ this.element.value = this.formatValueForDisplay(f);
930
937
  }
931
938
  }
932
939
  createInputElement(t) {
@@ -938,43 +945,39 @@ class Ke {
938
945
  decimalMaxLength: n,
939
946
  decimalMinLength: r,
940
947
  formatOn: i,
941
- thousandSeparator: a,
948
+ thousandSeparator: o,
942
949
  thousandStyle: s,
943
- decimalSeparator: o,
950
+ decimalSeparator: a,
944
951
  enableCompactNotation: c,
945
952
  enableNegative: l,
946
953
  enableLeadingZeros: h,
947
954
  rawValueMode: d,
948
955
  onChange: u,
949
- value: f,
950
- defaultValue: g,
956
+ value: g,
957
+ defaultValue: f,
951
958
  type: p,
952
- // Exclude - forced to 'text' above
953
959
  inputMode: $,
954
- // Exclude - forced to 'decimal' above
955
- spellcheck: D,
956
- // Exclude - forced to 'false' above
960
+ spellcheck: m,
957
961
  autocomplete: qe,
958
- // Exclude - forced to 'off' above
959
962
  ...q
960
963
  } = this.options;
961
- Object.assign(this.element, q), f !== void 0 ? this.element.value = f : g !== void 0 && (this.element.defaultValue = g, this.element.value = g), t.appendChild(this.element);
964
+ Object.assign(this.element, q), g !== void 0 ? this.element.value = g : f !== void 0 && (this.element.defaultValue = f, this.element.value = f), t.appendChild(this.element);
962
965
  }
963
966
  setupEventListeners() {
964
967
  this.element.addEventListener("input", this.handleChange.bind(this)), this.element.addEventListener("keydown", this.handleKeyDown.bind(this)), this.element.addEventListener("paste", this.handlePaste.bind(this)), this.resolvedOptions.formatOn === v.Blur && this.resolvedOptions.thousandSeparator && (this.element.addEventListener("focus", this.handleFocus.bind(this)), this.element.addEventListener("blur", this.handleBlur.bind(this)));
965
968
  }
966
969
  getResolvedOptions() {
967
970
  return {
968
- decimalMaxLength: this.options.decimalMaxLength ?? x,
969
- decimalMinLength: this.options.decimalMinLength ?? I,
970
- formatOn: this.options.formatOn ?? R,
971
- thousandSeparator: this.options.thousandSeparator ?? O,
972
- thousandStyle: this.options.thousandStyle ?? _,
971
+ decimalMaxLength: this.options.decimalMaxLength ?? I,
972
+ decimalMinLength: this.options.decimalMinLength ?? R,
973
+ formatOn: this.options.formatOn ?? O,
974
+ thousandSeparator: this.options.thousandSeparator ?? _,
975
+ thousandStyle: this.options.thousandStyle ?? B,
973
976
  decimalSeparator: this.options.decimalSeparator ?? E,
974
977
  enableCompactNotation: this.options.enableCompactNotation ?? X,
975
978
  enableNegative: this.options.enableNegative ?? P,
976
- enableLeadingZeros: this.options.enableLeadingZeros ?? B,
977
- rawValueMode: this.options.rawValueMode ?? W,
979
+ enableLeadingZeros: this.options.enableLeadingZeros ?? W,
980
+ rawValueMode: this.options.rawValueMode ?? k,
978
981
  onChange: this.options.onChange
979
982
  };
980
983
  }
@@ -992,39 +995,38 @@ class Ke {
992
995
  };
993
996
  }
994
997
  handleValueChange(t, n) {
995
- const r = n ?? t;
996
- if (this.resolvedOptions.rawValueMode && this.updateRawValue(r), this.resolvedOptions.onChange) {
997
- const i = this.resolvedOptions.rawValueMode ? this.rawValue : t;
998
- this.resolvedOptions.onChange(i);
998
+ if (this.resolvedOptions.rawValueMode && n !== void 0 && (this.rawValue = n), this.resolvedOptions.onChange) {
999
+ const r = this.resolvedOptions.rawValueMode ? this.rawValue : t;
1000
+ this.resolvedOptions.onChange(r);
999
1001
  }
1000
1002
  }
1001
1003
  formatValueForDisplay(t) {
1002
1004
  if (!t)
1003
1005
  return t;
1004
- const { thousandSeparator: n, thousandStyle: r, enableLeadingZeros: i, decimalSeparator: a } = this.resolvedOptions;
1005
- return n && r !== b.None ? z(
1006
+ const { thousandSeparator: n, thousandStyle: r, enableLeadingZeros: i, decimalSeparator: o } = this.resolvedOptions;
1007
+ return n && r !== S.None ? G(
1006
1008
  t,
1007
1009
  n,
1008
1010
  r,
1009
1011
  i,
1010
- a
1012
+ o
1011
1013
  ) : t;
1012
1014
  }
1013
1015
  handleChange(t) {
1014
- const n = t.target;
1015
- Ie(
1016
+ const { formatted: n, raw: r } = Ie(
1016
1017
  t,
1017
1018
  this.resolvedOptions.decimalMaxLength,
1018
1019
  this.caretPositionBeforeChange,
1019
1020
  this.buildFormattingOptions()
1020
- ), this.caretPositionBeforeChange = void 0, this.handleValueChange(n.value);
1021
+ );
1022
+ this.caretPositionBeforeChange = void 0, this.handleValueChange(n, r);
1021
1023
  }
1022
1024
  handleKeyDown(t) {
1023
- const n = t.target, { selectionStart: r, selectionEnd: i } = n, a = this.buildFormattingOptions(), s = xe(t, {
1024
- formatOn: a.formatOn,
1025
- thousandSeparator: a.thousandSeparator,
1026
- ThousandStyle: a.ThousandStyle,
1027
- decimalSeparator: a.decimalSeparator
1025
+ const n = t.target, { selectionStart: r, selectionEnd: i } = n, o = this.buildFormattingOptions(), s = xe(t, {
1026
+ formatOn: o.formatOn,
1027
+ thousandSeparator: o.thousandSeparator,
1028
+ ThousandStyle: o.ThousandStyle,
1029
+ decimalSeparator: o.decimalSeparator
1028
1030
  });
1029
1031
  s ? this.caretPositionBeforeChange = {
1030
1032
  selectionStart: r ?? 0,
@@ -1036,51 +1038,37 @@ class Ke {
1036
1038
  };
1037
1039
  }
1038
1040
  handlePaste(t) {
1039
- const n = Oe(t, this.resolvedOptions.decimalMaxLength, this.buildFormattingOptions());
1040
- this.handleValueChange(n);
1041
- const r = new Event("input", { bubbles: !0, cancelable: !0 });
1042
- this.element.dispatchEvent(r);
1041
+ const { formatted: n, raw: r } = Oe(t, this.resolvedOptions.decimalMaxLength, this.buildFormattingOptions());
1042
+ this.handleValueChange(n, r);
1043
+ const i = new Event("input", { bubbles: !0, cancelable: !0 });
1044
+ this.element.dispatchEvent(i);
1043
1045
  }
1044
1046
  handleFocus(t) {
1045
1047
  if (this.resolvedOptions.formatOn === v.Blur && this.resolvedOptions.thousandSeparator) {
1046
1048
  const n = t.target;
1047
- n.value = L(n.value, this.resolvedOptions.thousandSeparator);
1049
+ n.value = w(n.value, this.resolvedOptions.thousandSeparator);
1048
1050
  }
1049
1051
  }
1050
1052
  handleBlur(t) {
1051
1053
  const n = t.target, { thousandSeparator: r, thousandStyle: i } = this.resolvedOptions;
1052
- if (r && i !== b.None && n.value) {
1053
- const a = n.value, s = this.formatValueForDisplay(n.value);
1054
- if (n.value = s, this.handleValueChange(s), a !== s) {
1055
- const o = new Event("input", { bubbles: !0, cancelable: !0 });
1056
- this.element.dispatchEvent(o);
1057
- const c = new Event("change", { bubbles: !0, cancelable: !0 });
1054
+ if (r && i !== S.None && n.value) {
1055
+ const o = n.value, s = this.formatValueForDisplay(n.value);
1056
+ n.value = s;
1057
+ const a = this.resolvedOptions.rawValueMode ? w(s, r) : void 0;
1058
+ if (this.handleValueChange(s, a), o !== s) {
1059
+ const c = new Event("input", { bubbles: !0, cancelable: !0 });
1058
1060
  this.element.dispatchEvent(c);
1061
+ const l = new Event("change", { bubbles: !0, cancelable: !0 });
1062
+ this.element.dispatchEvent(l);
1059
1063
  }
1060
1064
  }
1061
1065
  }
1062
- /**
1063
- * Extracts and stores the raw numeric value from a formatted value.
1064
- * Gets the raw value from the data attribute set by event handlers, or extracts it from formatted value.
1065
- */
1066
- updateRawValue(t) {
1067
- const n = this.element.getAttribute("data-raw-value");
1068
- if (n !== null) {
1069
- this.rawValue = n, this.element.removeAttribute("data-raw-value");
1070
- return;
1071
- }
1072
- if (!this.resolvedOptions.thousandSeparator) {
1073
- this.rawValue = t;
1074
- return;
1075
- }
1076
- this.rawValue = L(t, this.resolvedOptions.thousandSeparator);
1077
- }
1078
1066
  getValue() {
1079
1067
  return this.resolvedOptions.rawValueMode ? this.rawValue : this.element.value;
1080
1068
  }
1081
1069
  setValue(t) {
1082
1070
  if (this.resolvedOptions.rawValueMode) {
1083
- const n = this.resolvedOptions.thousandSeparator ? L(t, this.resolvedOptions.thousandSeparator) : t;
1071
+ const n = this.resolvedOptions.thousandSeparator ? w(t, this.resolvedOptions.thousandSeparator) : t;
1084
1072
  this.rawValue = n, this.element.value = this.formatValueForDisplay(n);
1085
1073
  } else
1086
1074
  this.element.value = t;
@@ -1128,7 +1116,7 @@ class Ke {
1128
1116
  const t = this.getValue();
1129
1117
  if (!t)
1130
1118
  return NaN;
1131
- const n = this.resolvedOptions.thousandSeparator ? L(t, this.resolvedOptions.thousandSeparator) : t, r = this.resolvedOptions.decimalSeparator && this.resolvedOptions.decimalSeparator !== "." ? n.replace(new RegExp(M(this.resolvedOptions.decimalSeparator), "g"), ".") : n;
1119
+ const n = this.resolvedOptions.thousandSeparator ? w(t, this.resolvedOptions.thousandSeparator) : t, r = this.resolvedOptions.decimalSeparator && this.resolvedOptions.decimalSeparator !== "." ? n.replace(new RegExp(D(this.resolvedOptions.decimalSeparator), "g"), ".") : n;
1132
1120
  return parseFloat(r);
1133
1121
  }
1134
1122
  /**
@@ -1145,9 +1133,11 @@ class Ke {
1145
1133
  }
1146
1134
  export {
1147
1135
  v as FormatOn,
1148
- Ke as NumoraInput,
1149
- b as ThousandStyle,
1136
+ Qe as NumoraInput,
1137
+ S as ThousandStyle,
1138
+ Ke as formatValue,
1150
1139
  Ie as handleOnChangeNumoraInput,
1151
1140
  xe as handleOnKeyDownNumoraInput,
1152
- Oe as handleOnPasteNumoraInput
1141
+ Oe as handleOnPasteNumoraInput,
1142
+ x as processAndFormatValue
1153
1143
  };