numora 3.0.2 → 3.2.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.
package/dist/index.mjs CHANGED
@@ -1,459 +1,396 @@
1
- var re = Object.defineProperty;
2
- var ie = (e, t, n) => t in e ? re(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var w = (e, t, n) => ie(e, typeof t != "symbol" ? t + "" : t, n);
4
- var m = /* @__PURE__ */ ((e) => (e.Blur = "blur", e.Change = "change", e))(m || {}), S = /* @__PURE__ */ ((e) => (e.None = "none", e.Thousand = "thousand", e.Lakh = "lakh", e.Wan = "wan", e))(S || {});
5
- const _ = 2, z = 0, Z = m.Blur, B = ",", W = S.None, N = ".", oe = !1, k = !1, U = !1, G = !1;
6
- function T(e) {
1
+ var te = Object.defineProperty;
2
+ var ne = (e, t, n) => t in e ? te(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var D = (e, t, n) => ne(e, typeof t != "symbol" ? t + "" : t, n);
4
+ var b = /* @__PURE__ */ ((e) => (e.Blur = "blur", e.Change = "change", e))(b || {}), m = /* @__PURE__ */ ((e) => (e.None = "none", e.Thousand = "thousand", e.Lakh = "lakh", e.Wan = "wan", e.Locale = "locale", e))(m || {});
5
+ const G = 2, Z = 0, k = b.Blur, re = ",", H = m.None, v = ".", B = !1, P = !1, W = !1, U = !1;
6
+ function w(e) {
7
+ return e.replace(/[-[\]/{}()*+?.\\^$|]/g, "\\$&");
8
+ }
9
+ const z = /* @__PURE__ */ new Map();
10
+ function T(e, t = "g") {
11
+ const n = `${e}:${t}`;
12
+ let r = z.get(n);
13
+ return r || (r = new RegExp(e, t), z.set(n, r)), r;
14
+ }
15
+ function ie(e, t = "g") {
16
+ const n = w(e);
17
+ return T(n, t);
18
+ }
19
+ const se = /[.,]/g;
20
+ function _(e) {
7
21
  return {
8
- decimalSeparator: (e == null ? void 0 : e.decimalSeparator) ?? N,
22
+ decimalSeparator: (e == null ? void 0 : e.decimalSeparator) ?? v,
9
23
  thousandSeparator: e == null ? void 0 : e.thousandSeparator
10
24
  };
11
25
  }
12
- function K(e, t) {
13
- const n = e.startsWith("-"), s = n ? e.slice(1) : e, [o = "", r = ""] = s.split(t);
26
+ function Y(e, t) {
27
+ const n = e.startsWith("-"), r = n ? e.slice(1) : e, [i = "", s = ""] = r.split(t);
14
28
  return {
15
29
  sign: n ? "-" : "",
16
- integer: o,
17
- decimal: r
30
+ integer: i,
31
+ decimal: s
18
32
  };
19
33
  }
20
34
  function ae(e, t) {
21
35
  if (!e.value.includes(t)) return !1;
22
- const { selectionStart: n, selectionEnd: s, value: o } = e;
23
- return !o.slice(n ?? 0, s ?? 0).includes(t);
36
+ const { selectionStart: n, selectionEnd: r, value: i } = e;
37
+ return !i.slice(n ?? 0, r ?? 0).includes(t);
24
38
  }
25
39
  function ce(e, t, n) {
26
- const { key: s } = e;
27
- if (s !== "," && s !== ".") return !1;
40
+ const { key: r } = e;
41
+ if (r !== "," && r !== ".") return !1;
28
42
  if (ae(t, n))
29
43
  return !0;
30
- if (s !== n) {
31
- const { selectionStart: o, selectionEnd: r, value: i } = t, a = o ?? 0, c = r ?? a;
32
- t.value = i.slice(0, a) + n + i.slice(c);
33
- const l = a + 1;
34
- return t.setSelectionRange(l, l), !0;
44
+ if (r !== n) {
45
+ const { selectionStart: i, selectionEnd: s, value: a } = t, c = i ?? 0, l = s ?? c;
46
+ t.value = a.slice(0, c) + n + a.slice(l);
47
+ const o = c + 1;
48
+ return t.setSelectionRange(o, o), !0;
35
49
  }
36
50
  return !1;
37
51
  }
38
- const le = (e, t, n = N) => {
39
- const { sign: s, integer: o, decimal: r } = K(e, n);
40
- if (!e.includes(n)) return e;
41
- const a = r.slice(0, t);
42
- return `${s}${o}${n}${a}`;
43
- }, he = (e, t = N) => {
52
+ const oe = (e, t, n = v) => {
53
+ const { sign: r, integer: i, decimal: s } = Y(e, n);
54
+ if (!s) return e;
55
+ const a = s.slice(0, t);
56
+ return `${r}${i}${n}${a}`;
57
+ }, le = (e, t = v) => {
44
58
  const n = e.indexOf(t);
45
- if (n === -1) return e;
46
- const s = e.slice(0, n + 1), r = e.slice(n + 1).split(",").join("").split(".").join("").split(t).join("");
47
- return s + r;
48
- }, ue = (e, t = 0, n = N) => {
59
+ if (n === -1 || n === e.length - 1) return e;
60
+ const r = e.slice(0, n + 1), i = e.slice(n + 1), a = t === "." || t === "," ? se : T("[,\\." + w(t) + "]", "g");
61
+ return r + i.replace(a, "");
62
+ }, he = (e, t = 0, n = v) => {
49
63
  if (t <= 0) return e;
50
- const { sign: s, integer: o, decimal: r } = K(e, n);
51
- if (r.length >= t)
52
- return e.includes(n) ? e : `${s}${o}${n}${r}`;
53
- const i = r.padEnd(t, "0");
54
- return `${s}${o}${n}${i}`;
55
- }, L = {
64
+ const { sign: r, integer: i, decimal: s } = Y(e, n);
65
+ if (s.length >= t)
66
+ return e;
67
+ const a = s.padEnd(t, "0");
68
+ return `${r}${i}${n}${a}`;
69
+ }, $ = {
56
70
  thousand: { size: 3 },
57
71
  lakh: { firstGroup: 3, restGroup: 2 },
58
72
  wan: { size: 4 }
59
- };
60
- function y(e, t, n = S.Thousand, s = !1, o = ".") {
61
- if (!e || e === "0" || e === o || e === "-" || e === `-${o}`)
73
+ }, ue = /^(0+)/;
74
+ function Q(e, t, n = m.Thousand, r = !1, i = ".") {
75
+ if (!e || e === "0" || e === i || e === "-" || e === `-${i}`)
62
76
  return e;
63
- const r = e.includes(o), i = e.startsWith("-"), a = i ? e.slice(1) : e, [c, l] = a.split(o);
64
- if (!c) {
65
- const f = l ? `${o}${l}` : a;
66
- return i ? `-${f}` : f;
77
+ const s = e.includes(i), a = e.startsWith("-"), c = a ? e.slice(1) : e, [l, o] = c.split(i);
78
+ if (!l) {
79
+ const u = o ? `${i}${o}` : c;
80
+ return a ? `-${u}` : u;
67
81
  }
68
- if (s && c.startsWith("0") && c.length > 1) {
69
- const f = c.match(/^(0+)/);
70
- if (f) {
71
- const d = f[1], g = c.slice(d.length);
72
- if (g) {
73
- const p = j(g, t, n), $ = d + p, D = i ? "-" : "";
74
- return r ? l ? `${D}${$}${o}${l}` : `${D}${$}${o}` : `${D}${$}`;
82
+ if (r && l.startsWith("0") && l.length > 1) {
83
+ const u = l.match(ue);
84
+ if (u) {
85
+ const g = u[1], S = l.slice(g.length);
86
+ if (S) {
87
+ const E = J(S, t, n), f = g + E, p = a ? "-" : "";
88
+ return s ? o ? `${p}${f}${i}${o}` : `${p}${f}${i}` : `${p}${f}`;
75
89
  }
76
90
  }
77
91
  }
78
- const h = j(c, t, n), u = i ? "-" : "";
79
- return r ? l ? `${u}${h}${o}${l}` : `${u}${h}${o}` : `${u}${h}`;
92
+ const h = J(l, t, n), d = a ? "-" : "";
93
+ return s ? o ? `${d}${h}${i}${o}` : `${d}${h}${i}` : `${d}${h}`;
80
94
  }
81
- function j(e, t, n) {
95
+ function J(e, t, n) {
82
96
  if (e === "0" || e === "")
83
97
  return e;
84
98
  switch (n) {
85
- case S.None:
99
+ case m.None:
86
100
  return e;
87
- case S.Thousand:
88
- return fe(e, t);
89
- case S.Lakh:
101
+ case m.Thousand:
102
+ return X(e, t, $.thousand.size);
103
+ case m.Lakh:
90
104
  return de(e, t);
91
- case S.Wan:
92
- return ge(e, t);
105
+ case m.Wan:
106
+ return X(e, t, $.wan.size);
93
107
  default:
94
108
  return e;
95
109
  }
96
110
  }
97
- function fe(e, t) {
98
- return q(e, t, L.thousand.size);
99
- }
100
111
  function de(e, t) {
101
- if (e.length <= L.lakh.firstGroup)
112
+ if (e.length <= $.lakh.firstGroup)
102
113
  return e;
103
- const n = e.split("").reverse(), s = [], o = n.slice(0, L.lakh.firstGroup).reverse().join("");
104
- s.push(o);
105
- for (let r = L.lakh.firstGroup; r < n.length; r += L.lakh.restGroup)
106
- s.push(n.slice(r, r + L.lakh.restGroup).reverse().join(""));
107
- return s.reverse().join(t);
108
- }
109
- function ge(e, t) {
110
- return q(e, t, L.wan.size);
111
- }
112
- function q(e, t, n) {
113
- const s = e.split("").reverse(), o = [];
114
- for (let r = 0; r < s.length; r += n)
115
- o.push(s.slice(r, r + n).reverse().join(""));
116
- return o.reverse().join(t);
117
- }
118
- function pe(e, t, n) {
119
- return (t == null ? void 0 : t.formatOn) === m.Change && t.thousandSeparator ? y(
114
+ const n = [], r = e.length - $.lakh.firstGroup;
115
+ n.unshift(e.slice(r));
116
+ for (let i = r; i > 0; i -= $.lakh.restGroup)
117
+ n.unshift(e.slice(Math.max(0, i - $.lakh.restGroup), i));
118
+ return n.join(t);
119
+ }
120
+ function X(e, t, n) {
121
+ const r = [];
122
+ for (let i = e.length; i > 0; i -= n)
123
+ r.unshift(e.slice(Math.max(0, i - n), i));
124
+ return r.join(t);
125
+ }
126
+ function fe(e, t, n) {
127
+ return (t == null ? void 0 : t.formatOn) === b.Change && t.thousandSeparator ? Q(
120
128
  e,
121
129
  t.thousandSeparator,
122
- t.ThousandStyle ?? S.None,
130
+ t.ThousandStyle ?? m.None,
123
131
  t.enableLeadingZeros,
124
- (n == null ? void 0 : n.decimalSeparator) ?? N
132
+ (n == null ? void 0 : n.decimalSeparator) ?? v
125
133
  ) : e;
126
134
  }
127
- function b(e, t, n, s = ".") {
128
- let o = 0;
129
- for (let r = 0; r < t && r < e.length; r++)
130
- e[r] !== n && o++;
131
- return o;
135
+ function L(e, t, n) {
136
+ let r = 0;
137
+ for (let i = 0; i < t && i < e.length; i++)
138
+ e[i] !== n && r++;
139
+ return r;
132
140
  }
133
- function Se(e, t, n, s = ".") {
141
+ function ge(e, t, n) {
134
142
  if (t === 0)
135
143
  return 0;
136
- let o = 0;
137
- for (let r = 0; r < e.length; r++)
138
- if (e[r] !== n) {
139
- if (o === t - 1)
140
- return r + 1;
141
- o++;
144
+ let r = 0;
145
+ for (let i = 0; i < e.length; i++)
146
+ if (e[i] !== n) {
147
+ if (r === t - 1)
148
+ return i + 1;
149
+ r++;
142
150
  }
143
151
  return e.length;
144
152
  }
145
- function A(e, t, n, s = ".") {
153
+ function I(e, t, n) {
146
154
  if (t === 0)
147
155
  return 0;
148
- let o = 0;
149
- for (let r = 0; r < e.length; r++)
150
- if (e[r] !== n) {
151
- if (o++, o === t)
152
- return r + 1;
153
- if (o > t)
154
- return r;
156
+ let r = 0;
157
+ for (let i = 0; i < e.length; i++)
158
+ if (e[i] !== n) {
159
+ if (r++, r === t)
160
+ return i + 1;
161
+ if (r > t)
162
+ return i;
155
163
  }
156
164
  return e.length;
157
165
  }
158
- function Q(e, t, n) {
166
+ function V(e, t, n) {
159
167
  return t < 0 || t >= e.length ? !1 : e[t] === n;
160
168
  }
161
- function $e(e, t = {}) {
169
+ const Se = /\d/;
170
+ function Ee(e, t = {}) {
162
171
  const {
163
172
  thousandSeparator: n,
164
- decimalSeparator: s = ".",
165
- prefix: o = "",
166
- suffix: r = ""
167
- } = t, i = Array.from({ length: e.length + 1 }).map(() => !0);
168
- if (o && i.fill(!1, 0, o.length), r) {
169
- const a = e.length - r.length;
170
- i.fill(!1, a + 1, e.length + 1);
173
+ decimalSeparator: r = ".",
174
+ prefix: i = "",
175
+ suffix: s = ""
176
+ } = t, a = new Array(e.length + 1).fill(!0);
177
+ if (i && a.fill(!1, 0, i.length), s) {
178
+ const c = e.length - s.length;
179
+ a.fill(!1, c + 1, e.length + 1);
171
180
  }
172
- for (let a = 0; a < e.length; a++) {
173
- const c = e[a];
174
- (n && c === n || c === s) && (i[a] = !1, a + 1 < e.length && !/\d/.test(e[a + 1]) && (i[a + 1] = !1));
181
+ for (let c = 0; c < e.length; c++) {
182
+ const l = e[c];
183
+ (n && l === n || l === r) && (a[c] = !1, c + 1 < e.length && !Se.test(e[c + 1]) && (a[c + 1] = !1));
175
184
  }
176
- return i.some((a) => a) || i.fill(!0), i;
177
- }
178
- function I(e, t, n, s) {
179
- const o = e.length;
180
- if (t = Math.max(0, Math.min(t, o)), !n[t]) {
181
- let r = t;
182
- for (; r <= o && !n[r]; )
183
- r++;
184
- let i = t;
185
- for (; i >= 0 && !n[i]; )
186
- i--;
187
- r <= o && i >= 0 ? t = t - i < r - t ? i : r : r <= o ? t = r : i >= 0 && (t = i);
185
+ return a.some((c) => c) || a.fill(!0), a;
186
+ }
187
+ function x(e, t, n, r) {
188
+ const i = e.length;
189
+ if (t = Math.max(0, Math.min(t, i)), !n[t]) {
190
+ let s = t;
191
+ for (; s <= i && !n[s]; )
192
+ s++;
193
+ let a = t;
194
+ for (; a >= 0 && !n[a]; )
195
+ a--;
196
+ s <= i && a >= 0 ? t = t - a < s - t ? a : s : s <= i ? t = s : a >= 0 && (t = a);
188
197
  }
189
- return (t === -1 || t > o) && (t = o), t;
198
+ return (t === -1 || t > i) && (t = i), t;
190
199
  }
191
- const H = (e, t) => e === t;
192
- function me(e, t, n, s, o, r, i = ".", a = {}) {
200
+ const j = /(\d+\.?\d*)\s*[kmbt]$/i, me = (e, t) => e === t;
201
+ function be(e, t, n, r, i, s, a = ".", c = {}) {
193
202
  if (n < 0)
194
203
  return 0;
195
- if (n > e.length || e === "" || t === "")
204
+ if (n > e.length || e === "" || t === "" || j.test(e) && !j.test(t) && t.length > e.length && n >= e.length - 1)
196
205
  return t.length;
197
- const c = /(\d+\.?\d*)\s*[kmbMTOQaqiSxsxSpOoNn]$/i;
198
- if (c.test(e) && !c.test(t) && t.length > e.length && n >= e.length - 1)
199
- return t.length;
200
- const l = t.length < e.length, h = Q(
206
+ const l = t.length < e.length, o = V(
201
207
  e,
202
208
  n,
203
- s
204
- ), u = e.indexOf(i), f = t.indexOf(i);
205
- if (a.isCharacterEquivalent && e !== t) {
206
- const p = be(
209
+ r
210
+ ), h = e.indexOf(a), d = t.indexOf(a);
211
+ if (c.isCharacterEquivalent && e !== t) {
212
+ const f = pe(
207
213
  e,
208
214
  t,
209
215
  n,
210
- a.isCharacterEquivalent || H,
211
- r,
212
- a
216
+ c.isCharacterEquivalent || me,
217
+ s,
218
+ c
213
219
  );
214
- if (p !== void 0)
215
- return p;
220
+ if (f !== void 0)
221
+ return f;
216
222
  }
223
+ const g = /* @__PURE__ */ new Map(), S = (f, p, y) => {
224
+ const C = `${f === e ? "o" : "n"}:${p}`;
225
+ return g.has(C) || g.set(C, L(f, p, r)), g.get(C);
226
+ };
217
227
  if (l)
218
- return Ne(
228
+ return Le(
219
229
  e,
220
230
  t,
221
231
  n,
222
- s,
223
- h,
224
- u,
225
- f,
226
232
  r,
227
- i,
228
- a
233
+ o,
234
+ h,
235
+ d,
236
+ s,
237
+ c,
238
+ S
229
239
  );
230
- const g = we(
240
+ const E = De(
231
241
  e,
232
242
  t,
233
243
  n,
234
- s,
235
- h,
236
- i
244
+ r,
245
+ o,
246
+ S
237
247
  );
238
- return a.boundary ? I(t, g, a.boundary) : g;
239
- }
240
- function be(e, t, n, s, o, r) {
241
- const i = e.length, a = t.length, c = {}, l = new Array(i);
242
- for (let g = 0; g < i; g++) {
243
- l[g] = -1;
244
- for (let p = 0; p < a; p++) {
245
- if (c[p]) continue;
246
- if (s(
247
- e[g],
248
- t[p],
248
+ return c.boundary ? x(t, E, c.boundary) : E;
249
+ }
250
+ function pe(e, t, n, r, i, s) {
251
+ const a = e.length, c = t.length;
252
+ let l = 0, o = 0, h = c;
253
+ for (let u = 0; u < a; u++) {
254
+ let g = -1;
255
+ for (let S = l; S < c; S++)
256
+ if (r(
257
+ e[u],
258
+ t[S],
249
259
  {
250
260
  oldValue: e,
251
261
  newValue: t,
252
- typedRange: o,
253
- oldIndex: g,
254
- newIndex: p
262
+ typedRange: i,
263
+ oldIndex: u,
264
+ newIndex: S
255
265
  }
256
266
  )) {
257
- l[g] = p, c[p] = !0;
267
+ g = S;
258
268
  break;
259
269
  }
260
- }
270
+ g !== -1 && (l = g + 1, u < n ? o = g + 1 : h === c && /\d/.test(e[u]) && (h = g));
261
271
  }
262
- let h = n;
263
- for (; h < i && (l[h] === -1 || !/\d/.test(e[h])); )
264
- h++;
265
- const u = h === i || l[h] === -1 ? a : l[h];
266
- for (h = n - 1; h >= 0 && l[h] === -1; ) h--;
267
- const f = h === -1 || l[h] === -1 ? 0 : l[h] + 1;
268
- if (f > u) return u;
269
- const d = n - f < u - n ? f : u;
270
- return r.boundary ? I(t, d, r.boundary) : d;
271
- }
272
- function Ne(e, t, n, s, o, r, i, a, c, l = {}) {
273
- if (o)
274
- return De(
272
+ if (o > h) return h;
273
+ const d = n - o < h - n ? o : h;
274
+ return s.boundary ? x(t, d, s.boundary) : d;
275
+ }
276
+ function Le(e, t, n, r, i, s, a, c, l = {}, o = L) {
277
+ if (i)
278
+ return Ne(
275
279
  e,
276
280
  t,
277
281
  n,
278
- s,
279
- i,
280
- c
282
+ r,
283
+ a,
284
+ o
281
285
  );
282
- const h = b(
286
+ const h = o(e, n, r), d = o(e, e.length, r), u = o(t, t.length, r), g = d - u, S = $e(
283
287
  e,
284
288
  n,
289
+ r,
290
+ h,
291
+ g,
285
292
  s,
286
- c
287
- ), u = b(
288
- e,
289
- e.length,
290
- s,
291
- c
292
- ), f = b(
293
+ c,
294
+ o
295
+ ), E = s === -1 || n <= s, f = ve(
293
296
  t,
294
- t.length,
295
- s,
296
- c
297
- ), d = u - f, g = Ee(
298
- e,
299
- n,
300
- s,
301
- h,
302
- d,
297
+ S,
303
298
  r,
304
- a,
305
- c
306
- ), p = r === -1 || n <= r, $ = Le(
307
- t,
308
299
  g,
309
- s,
310
- d,
311
- a,
312
300
  c,
313
- p,
314
- i
301
+ E,
302
+ a,
303
+ o
315
304
  );
316
- return l.boundary ? I(t, $, l.boundary) : $;
305
+ return l.boundary ? x(t, f, l.boundary) : f;
317
306
  }
318
- function De(e, t, n, s, o, r) {
319
- const i = n + 1;
320
- if (i < e.length) {
321
- const a = b(
322
- e,
323
- i,
324
- s,
325
- r
326
- ), c = Se(
307
+ function Ne(e, t, n, r, i, s = L) {
308
+ const a = n + 1;
309
+ if (a < e.length) {
310
+ const c = s(e, a, r), l = ge(
327
311
  t,
328
- a,
329
- s,
312
+ c,
330
313
  r
331
314
  );
332
- return c < t.length && t[c] !== s ? c + 1 : c;
315
+ return l < t.length && t[l] !== r ? l + 1 : l;
333
316
  }
334
317
  return n;
335
318
  }
336
- function Ee(e, t, n, s, o, r, i, a) {
337
- if (i) {
338
- const { start: l, isDelete: h } = i;
339
- return h ? b(
340
- e,
341
- l,
342
- n,
343
- a
344
- ) : Math.max(0, b(
345
- e,
346
- l,
347
- n,
348
- a
349
- ));
319
+ function $e(e, t, n, r, i, s, a, c = L) {
320
+ if (a) {
321
+ const { start: o, isDelete: h } = a;
322
+ return h ? c(e, o, n) : Math.max(0, c(e, o, n));
350
323
  }
351
- return t > 0 && e[t - 1] === n && o > 0 ? s + 1 : s;
324
+ return t > 0 && e[t - 1] === n && i > 0 ? r + 1 : r;
325
+ }
326
+ function K(e, t, n, r, i, s, a = L) {
327
+ if (t > 0 && t < e.length && a(e, t, r) === n) {
328
+ if (e[t] === r && s && i > 0 && t < e.length - 1)
329
+ return t + 1;
330
+ if (!s && i > 0 && t < e.length - 1)
331
+ return Math.min(t + 1, e.length);
332
+ }
333
+ return t;
352
334
  }
353
- function Le(e, t, n, s, o, r, i, a) {
354
- if (i && a !== -1) {
355
- const l = e.substring(0, a), h = b(
356
- l,
357
- l.length,
358
- n,
359
- r
360
- );
335
+ function ve(e, t, n, r, i, s, a, c = L) {
336
+ if (s && a !== -1) {
337
+ const o = e.substring(0, a), h = c(o, o.length, n);
361
338
  if (t <= h) {
362
- const u = A(
363
- l,
339
+ const d = I(
340
+ o,
364
341
  t,
365
- n,
366
- r
342
+ n
367
343
  );
368
- if (u > 0 && u < l.length && b(
369
- l,
370
- u,
371
- n,
372
- r
373
- ) === t) {
374
- if (l[u] === n && o && s > 0 && u < l.length - 1)
375
- return u + 1;
376
- if (!o && s > 0 && u < l.length - 1)
377
- return Math.min(u + 1, l.length);
378
- }
379
- return u;
344
+ return K(o, d, t, n, r, i, c);
380
345
  }
381
346
  }
382
- const c = A(
347
+ const l = I(
383
348
  e,
384
349
  t,
385
- n,
386
- r
350
+ n
387
351
  );
388
- if (c > 0 && c < e.length && b(
389
- e,
390
- c,
391
- n,
392
- r
393
- ) === t) {
394
- if (e[c] === n && o && s > 0 && c < e.length - 1)
395
- return c + 1;
396
- if (!o && s > 0 && c < e.length - 1)
397
- return Math.min(c + 1, e.length);
398
- }
399
- return c;
352
+ return K(e, l, t, n, r, i, c);
400
353
  }
401
- function we(e, t, n, s, o, r) {
402
- const i = n >= e.length, a = b(
403
- e,
404
- n,
405
- s,
406
- r
407
- ), c = b(
408
- e,
409
- e.length,
410
- s,
411
- r
412
- ), l = b(
413
- t,
414
- t.length,
415
- s,
416
- r
417
- );
418
- if (i || a === c)
354
+ function De(e, t, n, r, i, s = L) {
355
+ const a = n >= e.length, c = s(e, n, r), l = s(e, e.length, r), o = s(t, t.length, r);
356
+ if (a || c === l)
419
357
  return t.length;
420
- const h = l - c;
421
- let u = a;
422
- h > 0 && !i && a < c && (u = a + 1);
423
- const f = A(
358
+ const h = o - l;
359
+ let d = c;
360
+ h > 0 && !a && c < l && (d = c + 1);
361
+ const u = I(
424
362
  t,
425
- u,
426
- s,
363
+ d,
427
364
  r
428
365
  );
429
- return o && !Q(t, f, s) ? Math.max(0, f - 1) : f;
366
+ return i && !V(t, u, r) ? Math.max(0, u - 1) : u;
430
367
  }
431
- function ve(e, t, n) {
432
- const { selectionStart: s, selectionEnd: o, endOffset: r = 0 } = e;
433
- if (s !== o) {
434
- const h = o - s;
368
+ function we(e, t, n) {
369
+ const { selectionStart: r, selectionEnd: i, endOffset: s = 0 } = e;
370
+ if (r !== i) {
371
+ const h = i - r;
435
372
  return {
436
- start: s,
437
- end: o,
373
+ start: r,
374
+ end: i,
438
375
  deletedLength: h,
439
376
  isDelete: !1
440
377
  };
441
378
  }
442
- if (r > 0) {
443
- const h = r;
379
+ if (s > 0) {
380
+ const h = s;
444
381
  return {
445
- start: s,
446
- end: s + h,
382
+ start: r,
383
+ end: r + h,
447
384
  deletedLength: h,
448
385
  isDelete: !0
449
386
  };
450
387
  }
451
- const a = t.length, c = n.length, l = a - c;
452
- if (!(l <= 0))
388
+ const c = t.length, l = n.length, o = c - l;
389
+ if (!(o <= 0))
453
390
  return {
454
- start: s,
455
- end: s + l,
456
- deletedLength: l,
391
+ start: r,
392
+ end: r + o,
393
+ deletedLength: o,
457
394
  isDelete: !1
458
395
  };
459
396
  }
@@ -463,19 +400,19 @@ function ye(e, t) {
463
400
  let n = 0;
464
401
  for (; n < e.length && n < t.length && e[n] === t[n]; )
465
402
  n++;
466
- let s = e.length - 1, o = t.length - 1;
467
- for (; s >= n && o >= n && e[s] === t[o]; )
468
- s--, o--;
469
- const r = s - n + 1, i = o - n + 1;
470
- if (!(r === 0 && i === 0))
403
+ let r = e.length - 1, i = t.length - 1;
404
+ for (; r >= n && i >= n && e[r] === t[i]; )
405
+ r--, i--;
406
+ const s = r - n + 1, a = i - n + 1;
407
+ if (!(s === 0 && a === 0))
471
408
  return {
472
409
  start: n,
473
- end: s + 1,
474
- deletedLength: r,
475
- isDelete: r > i
410
+ end: r + 1,
411
+ deletedLength: s,
412
+ isDelete: s > a
476
413
  };
477
414
  }
478
- function J(e, t) {
415
+ function q(e, t) {
479
416
  if (e.value = e.value, e === null)
480
417
  return !1;
481
418
  if (e.createTextRange) {
@@ -484,443 +421,176 @@ function J(e, t) {
484
421
  }
485
422
  return e.selectionStart !== null || e.selectionStart === 0 ? (e.focus(), e.setSelectionRange(t, t), !0) : (e.focus(), !1);
486
423
  }
487
- function Me(e, t, n) {
488
- return e.selectionStart === 0 && e.selectionEnd === e.value.length ? null : (J(e, t), setTimeout(() => {
489
- e.value === n && e.selectionStart !== t && J(e, t);
424
+ function Ce(e, t, n) {
425
+ return e.selectionStart === 0 && e.selectionEnd === e.value.length ? null : (q(e, t), setTimeout(() => {
426
+ e.value === n && e.selectionStart !== t && q(e, t);
490
427
  }, 0));
491
428
  }
492
- function xe(e) {
429
+ function Me(e) {
493
430
  return Math.max(e.selectionStart, e.selectionEnd);
494
431
  }
495
- function Ce(e, t, n) {
496
- if ((n == null ? void 0 : n.formatOn) !== m.Change || !n.thousandSeparator)
432
+ function Ae(e, t, n) {
433
+ if ((n == null ? void 0 : n.formatOn) !== b.Change || !n.thousandSeparator)
497
434
  return;
498
- const { selectionStart: s, selectionEnd: o, value: r } = t;
499
- if (s === null || o === null || s !== o)
435
+ const { selectionStart: r, selectionEnd: i, value: s } = t;
436
+ if (r === null || i === null || r !== i)
500
437
  return;
501
- const { key: i } = e, a = n.thousandSeparator;
502
- i === "Backspace" && s > 0 && r[s - 1] === a && t.setSelectionRange(s - 1, s - 1), i === "Delete" && r[s] === a && t.setSelectionRange(s + 1, s + 1);
503
- }
504
- function Ae(e, t, n, s, o, r, i) {
505
- if (!o) return;
506
- const { selectionStart: a = 0, selectionEnd: c = 0, endOffset: l = 0 } = o;
507
- let h = ve(
508
- { selectionStart: a, selectionEnd: c, endOffset: l },
438
+ const { key: a } = e, c = n.thousandSeparator;
439
+ a === "Backspace" && r > 0 && s[r - 1] === c && t.setSelectionRange(r - 1, r - 1), a === "Delete" && s[r] === c && t.setSelectionRange(r + 1, r + 1);
440
+ }
441
+ function Re(e, t, n, r, i, s, a) {
442
+ if (!i) return;
443
+ const { selectionStart: c = 0, selectionEnd: l = 0, endOffset: o = 0 } = i;
444
+ let h = we(
445
+ { selectionStart: c, selectionEnd: l, endOffset: o },
509
446
  t,
510
447
  n
511
448
  );
512
449
  if (h || (h = ye(t, n)), !h) return;
513
- const u = $e(n, {
514
- thousandSeparator: (i == null ? void 0 : i.thousandSeparator) ?? r.thousandSeparator,
515
- decimalSeparator: r.decimalSeparator
516
- }), f = {
517
- thousandSeparator: (i == null ? void 0 : i.thousandSeparator) ?? r.thousandSeparator,
518
- isCharacterEquivalent: H,
519
- boundary: u
520
- }, d = (i == null ? void 0 : i.thousandSeparator) ?? r.thousandSeparator ?? ",", g = (i == null ? void 0 : i.ThousandStyle) ?? S.None, p = me(
450
+ const d = Ee(n, {
451
+ thousandSeparator: (a == null ? void 0 : a.thousandSeparator) ?? s.thousandSeparator,
452
+ decimalSeparator: s.decimalSeparator
453
+ }), u = {
454
+ thousandSeparator: (a == null ? void 0 : a.thousandSeparator) ?? s.thousandSeparator,
455
+ isCharacterEquivalent: (f, p) => {
456
+ const y = (a == null ? void 0 : a.thousandSeparator) ?? s.thousandSeparator;
457
+ return y && f === y ? !1 : f === p;
458
+ },
459
+ boundary: d
460
+ }, g = (a == null ? void 0 : a.thousandSeparator) ?? s.thousandSeparator ?? ",", S = (a == null ? void 0 : a.ThousandStyle) ?? m.None, E = be(
521
461
  t,
522
462
  n,
523
- s,
524
- d,
463
+ r,
525
464
  g,
465
+ S,
526
466
  h,
527
- r.decimalSeparator,
528
- f
529
- );
530
- Me(e, p, n);
531
- }
532
- function X(e) {
533
- const [t, n = ""] = e.split(".");
534
- return t.length + n.length > 30;
535
- }
536
- function Y(e, t) {
537
- const n = e.replace(".", ""), s = t.replace(".", ""), o = Math.max(n.length, s.length), r = n.padStart(o, "0"), i = s.padStart(o, "0");
538
- for (let a = 0; a < o; a++) {
539
- const c = parseInt(r[a], 10), l = parseInt(i[a], 10);
540
- if (c !== l)
541
- return c - l;
542
- }
543
- return 0;
544
- }
545
- const Te = [
546
- { suffix: "N", zeros: 30 },
547
- // Nonillion
548
- { suffix: "O", zeros: 27 },
549
- // Octillion
550
- { suffix: "Sp", zeros: 24 },
551
- // Septillion
552
- { suffix: "Sx", zeros: 21 },
553
- // Sextillion
554
- { suffix: "Qi", zeros: 18 },
555
- // Quintillion
556
- { suffix: "Qa", zeros: 15 },
557
- // Quadrillion
558
- { suffix: "T", zeros: 12 },
559
- // Trillion
560
- { suffix: "B", zeros: 9 },
561
- // Billion
562
- { suffix: "M", zeros: 6 },
563
- // Million
564
- { suffix: "k", zeros: 3 }
565
- // Thousand
566
- ];
567
- function V(e, t, n = 0) {
568
- const [s, o = ""] = e.split(t), r = s.replace(/^0+/, "") || "0";
569
- for (const i of Te)
570
- if (i.zeros >= n && (r.length > i.zeros || r.length === i.zeros && o.length > 0)) {
571
- const a = i.zeros;
572
- if (r.length > a) {
573
- const c = r.slice(0, -a), u = (r.slice(-a) + o).replace(/0+$/, "");
574
- return { scaledValue: u ? `${c}${t}${u}` : c, scaleSuffix: i.suffix };
575
- } else {
576
- const c = a - r.length, l = "0", u = ("0".repeat(c) + r + o).replace(/0+$/, "");
577
- return { scaledValue: u ? `${l}${t}${u}` : l, scaleSuffix: i.suffix };
578
- }
579
- }
580
- return { scaledValue: e, scaleSuffix: "" };
581
- }
582
- function P(e, t, n, s, o = !1, r = !1) {
583
- if (r && o && n > 0)
584
- return `0${s}${"0".repeat(n)}`;
585
- const [i, a = ""] = e.split(s);
586
- let c;
587
- if (t === 0)
588
- c = i;
589
- else if (a.length === 0) {
590
- const l = "0".repeat(Math.max(t, n));
591
- c = `${i}${s}${l}`;
592
- } else if (a.length < t) {
593
- const l = Math.max(t - a.length, n - a.length);
594
- c = `${i}${s}${a}${"0".repeat(l)}`;
595
- } else
596
- c = `${i}${s}${a.slice(0, t)}`;
597
- if (n > 0) {
598
- const [l, h = ""] = c.split(s);
599
- if (h.length < n) {
600
- const u = n - h.length;
601
- c = `${l}${s}${h}${"0".repeat(u)}`;
602
- }
603
- }
604
- if (n === 0)
605
- c = c.replace(/(\.[0-9]*?)0+$/, "$1").replace(/\.$/, "");
606
- else {
607
- const [l, h = ""] = c.split(s);
608
- if (h) {
609
- const u = h.replace(/0+$/, ""), f = u.length >= n ? u : h.slice(0, n);
610
- c = f ? `${l}${s}${f}` : l;
611
- }
612
- }
613
- return c;
614
- }
615
- function F(e, t) {
616
- return !e || e === "0" || e === t || e === "-" || e === `-${t}`;
617
- }
618
- function ee(e) {
619
- const t = e.startsWith("-");
620
- return { isNegative: t, absoluteValue: t ? e.slice(1) : e };
621
- }
622
- function te(e, t) {
623
- if (!e || e === "0")
624
- return "0";
625
- const n = e.includes(t), [s, o = ""] = n ? e.split(t) : [e, ""];
626
- let r;
627
- if (o.length <= 2) {
628
- const a = 2 - o.length;
629
- r = s + o + "0".repeat(a);
630
- } else
631
- r = s + o.slice(0, 2) + t + o.slice(2);
632
- let i = r.replace(/^0+/, "") || "0";
633
- if (i.startsWith(t) && (i = "0" + i), i.includes(t)) {
634
- const [a, c] = i.split(t);
635
- return a === "0" && !c ? "0" : i;
636
- }
637
- return i;
638
- }
639
- function Ie(e, t) {
640
- const { decimals: n, decimalSeparator: s, thousandSeparator: o, thousandStyle: r, decimalsMin: i = 0 } = t;
641
- if (F(e, s))
642
- return "0";
643
- const { isNegative: a, absoluteValue: c } = ee(e), l = te(c, s);
644
- let h = l;
645
- o && r !== S.None && (h = y(l, o, r, !1, s));
646
- const u = P(
647
- h,
648
- n,
649
- i,
650
- s,
651
- !1,
652
- e === "0"
467
+ s.decimalSeparator,
468
+ u
653
469
  );
654
- return `${a ? "-" : ""}${u}`;
470
+ Ce(e, E, n);
655
471
  }
656
- function ot(e, t = 2, n = N, s, o = S.None) {
657
- const r = Ie(e, {
658
- decimals: t,
659
- decimalSeparator: n,
660
- thousandSeparator: s,
661
- thousandStyle: o,
662
- decimalsMin: t
663
- // Use decimals as decimalsMin to ensure trailing zeros are shown
664
- });
665
- return r === "0" ? "0%" : `${r}%`;
666
- }
667
- function at(e, t = 2, n = {}) {
668
- const {
669
- missingPlaceholder: s = "?",
670
- veryLargePlaceholder: o = "🔥",
671
- decimalsUnder: r = 1e3,
672
- decimalSeparator: i = N,
673
- thousandSeparator: a,
674
- thousandStyle: c = S.None
675
- } = n;
676
- if (e == null || e === "")
677
- return s;
678
- if (F(e, i))
679
- return "0%";
680
- const { isNegative: l, absoluteValue: h } = ee(e), u = te(h, i);
681
- if (X(u))
682
- return o;
683
- const { scaledValue: f, scaleSuffix: d } = V(u, i), p = Y(f, r.toString()) < 0 ? t : 0;
684
- let $ = f;
685
- a && c !== S.None && ($ = y(f, a, c, !1, i));
686
- const D = P(
687
- $,
688
- p,
689
- p,
690
- i,
691
- !1,
692
- !1
693
- );
694
- return `${l ? "-" : ""}${D}${d}%`;
695
- }
696
- function Pe(e) {
697
- const t = "₀₁₂₃₄₅₆₇₈₉";
698
- return e.replace(/[0-9]/g, (n) => t[+n]);
699
- }
700
- function ct(e, t = 8, n = N) {
701
- if (!e || !e.includes(n))
702
- return e;
703
- const s = e.startsWith("-"), o = s ? e.slice(1) : e, [r, i] = o.split(n);
704
- if (!i || !i.length)
705
- return e;
706
- const a = i.match(/^(0{3,})/);
707
- if (!a)
708
- return e;
709
- const l = a[1].length, h = i.slice(l), u = r === "0" && l >= 5 ? l + 1 : l, f = Pe(u.toString());
710
- let d = `0${f}${h}`;
711
- const g = f.length, p = Math.max(0, t - g - 1);
712
- h.length > p && (d = `0${f}${h.slice(0, p)}`), d = d.replace(/0+$/, "");
713
- const $ = r === "0" ? d : `${r}${d}`;
714
- return s ? `-${$}` : $;
715
- }
716
- const E = {
717
- minScale: 0,
718
- decimalsUnder: 1e3,
719
- decimals: 2,
720
- decimalsMin: 0,
721
- decimalsMinAppliesToZero: !1,
722
- veryLargePlaceholder: "🔥",
723
- decimalSeparator: N
724
- };
725
- function lt(e, t = {}) {
726
- const {
727
- minScale: n = E.minScale,
728
- decimalsUnder: s = E.decimalsUnder,
729
- decimals: o = E.decimals,
730
- decimalsMin: r = E.decimalsMin,
731
- decimalsMinAppliesToZero: i = E.decimalsMinAppliesToZero,
732
- veryLargePlaceholder: a = E.veryLargePlaceholder,
733
- decimalSeparator: c = E.decimalSeparator,
734
- thousandSeparator: l,
735
- thousandStyle: h = S.None
736
- } = t;
737
- if (!e || e === "0" || e === c || e === "-" || e === `-${c}`)
738
- return i && r > 0 ? `0${c}${"0".repeat(r)}` : "0";
739
- const u = e.startsWith("-"), f = u ? e.slice(1) : e;
740
- if (X(f))
741
- return a;
742
- const { scaledValue: d, scaleSuffix: g } = V(
743
- f,
744
- c,
745
- n
746
- ), $ = Y(d, s.toString()) < 0 ? o : 0;
747
- let D = d;
748
- l && h !== S.None && (D = y(
749
- d,
750
- l,
751
- h,
752
- !1,
753
- c
754
- ));
755
- const R = P(
756
- D,
757
- $,
758
- r,
759
- c,
760
- i,
761
- e === "0"
762
- // Pass whether the original value is '0'
763
- );
764
- return `${u ? "-" : ""}${R}${g}`;
765
- }
766
- function x(e) {
767
- return e.replace(/[-[\]/{}()*+?.\\^$|]/g, "\\$&");
768
- }
769
- const Oe = (e, t = !1, n = ".") => {
770
- const s = x(n), o = new RegExp(`[^0-9${s}]`, "g");
472
+ const Ie = (e, t = !1, n = ".") => {
473
+ const r = w(n), i = T(`[^0-9${r}]`, "g");
771
474
  if (!t)
772
- return e.replace(o, "");
773
- const r = e.startsWith("-"), i = e.replace(o, "");
774
- if (r) {
775
- if (i.length > 0)
776
- return "-" + i;
777
- if (e === "-")
778
- return "-";
779
- }
780
- return i;
781
- };
782
- function Re(e) {
783
- const t = /([+-]?\d+\.?\d*)[eE]([+-]?\d+)/g;
784
- let n = e, s;
785
- const o = [];
786
- for (; (s = t.exec(e)) !== null; ) {
787
- const r = s[0], i = s[1], a = parseInt(s[2], 10);
788
- let c;
789
- if (a === 0)
790
- c = i;
791
- else {
792
- const l = i.startsWith("-"), h = l ? i.slice(1) : i, [u, f = ""] = h.split(".");
793
- a > 0 ? c = _e(u, f, a) : c = ze(u, f, Math.abs(a)), l && (c = "-" + c);
794
- }
795
- o.push({ full: r, expanded: c });
796
- }
797
- for (const { full: r, expanded: i } of o)
798
- n = n.replace(r, i);
799
- return n;
475
+ return e.replace(i, "");
476
+ const s = e.startsWith("-"), a = e.replace(i, "");
477
+ return s && (a.length > 0 || e === "-") ? "-" + a : a;
478
+ }, Te = /([+-]?\d+\.?\d*)[eE]([+-]?\d+)/g, F = /^0+$/, A = /\.?0+$/;
479
+ function _e(e) {
480
+ return !e.includes("e") && !e.includes("E") ? e : e.replace(Te, (t, n, r) => {
481
+ const i = parseInt(r, 10);
482
+ if (i === 0) return n;
483
+ const s = n.startsWith("-"), a = s ? n.slice(1) : n, [c, l = ""] = a.split("."), o = i > 0 ? xe(c, l, i) : Oe(c, l, Math.abs(i));
484
+ return s ? "-" + o : o;
485
+ });
800
486
  }
801
- function _e(e, t, n) {
802
- const s = e + t;
803
- if (s === "0" || s.match(/^0+$/))
487
+ function xe(e, t, n) {
488
+ const r = e + t;
489
+ if (r === "0" || F.test(r))
804
490
  return "0";
805
- const o = t.length;
806
- if (n <= o) {
807
- const i = s.slice(0, e.length + n), a = s.slice(e.length + n);
808
- return a ? `${i}.${a}` : i;
491
+ const i = t.length;
492
+ if (n <= i) {
493
+ const a = r.slice(0, e.length + n), c = r.slice(e.length + n);
494
+ return c ? `${a}.${c}` : a;
809
495
  }
810
- const r = n - o;
811
- return s + "0".repeat(r);
496
+ const s = n - i;
497
+ return r + "0".repeat(s);
812
498
  }
813
- function ze(e, t, n) {
814
- const s = e + t;
815
- if (s === "0" || s.match(/^0+$/))
499
+ function Oe(e, t, n) {
500
+ const r = e + t;
501
+ if (r === "0" || F.test(r))
816
502
  return "0";
817
- const i = e.length - n;
818
- if (i <= 0) {
819
- const a = Math.abs(i), c = `0.${"0".repeat(a)}${s}`;
820
- return C(c);
503
+ const s = e.length - n;
504
+ if (s <= 0) {
505
+ const a = Math.abs(s), c = `0.${"0".repeat(a)}${r}`;
506
+ return R(c);
821
507
  }
822
- if (i < e.length) {
823
- const a = s.slice(0, i), c = s.slice(i), l = `${a}.${c}`;
824
- return C(l);
508
+ if (s < e.length) {
509
+ const a = r.slice(0, s), c = r.slice(s), l = `${a}.${c}`;
510
+ return R(l);
825
511
  }
826
- return C(s);
512
+ return R(r);
827
513
  }
828
- function C(e) {
514
+ function R(e) {
829
515
  if (!e.includes("."))
830
516
  return e;
831
- if (e === "0" || e === "0.")
517
+ if (e === "0.")
832
518
  return "0";
833
519
  if (e.startsWith("0.")) {
834
- const t = e.replace(/\.?0+$/, "");
520
+ const t = e.replace(A, "");
835
521
  return t === "0" ? "0" : t || "0";
836
522
  }
837
523
  if (e.startsWith("-0.")) {
838
- const t = e.replace(/\.?0+$/, "");
524
+ const t = e.replace(A, "");
839
525
  return t === "-0" || t === "0" ? "0" : t || "0";
840
526
  }
841
- return e.replace(/\.?0+$/, "") || e;
842
- }
843
- function Ze(e) {
844
- const t = /(\d+\.?\d*)\s*(Qa|Qi|Sx|Sp|[kmbMTO]|N)/gi;
845
- return e.replace(t, (n, s, o) => {
846
- const r = {
847
- k: 3,
848
- // Thousand
849
- K: 3,
850
- // Thousand
851
- m: 6,
852
- // Million (lowercase)
853
- M: 6,
854
- // Million (uppercase)
855
- b: 9,
856
- // Billion
857
- B: 9,
858
- // Billion
859
- T: 12,
860
- // Trillion
861
- t: 12
862
- // Trillion
863
- };
864
- let i;
865
- if (o.length > 1) {
866
- const d = o.charAt(0).toUpperCase() + o.slice(1).toLowerCase();
867
- i = r[o] || r[d];
868
- } else {
869
- const d = o.toLowerCase();
870
- i = r[o] || r[d];
871
- }
872
- if (!i)
873
- return n;
874
- const a = s.startsWith("-"), c = a ? s.slice(1) : s, [l, h = ""] = c.split("."), u = l.replace(/^0+/, "") || "0";
875
- let f;
876
- if (h.length === 0)
877
- f = u + "0".repeat(i);
878
- else if (h.length <= i) {
879
- const d = i - h.length;
880
- f = u + h + "0".repeat(d);
527
+ return e.replace(A, "") || e;
528
+ }
529
+ const Ge = /(\d+\.?\d*)\s*([kmbt])/gi, Ze = /^0+/, ke = /^(-?)0+([1-9])/, Be = /^-?0+$/, Pe = /\.?0+$/, We = {
530
+ k: 3,
531
+ // Thousand
532
+ m: 6,
533
+ // Million
534
+ b: 9,
535
+ // Billion
536
+ t: 12
537
+ // Trillion
538
+ };
539
+ function Ue(e) {
540
+ return e.replace(Ge, (t, n, r) => {
541
+ const i = r.toLowerCase(), s = We[i];
542
+ if (!s)
543
+ return t;
544
+ const [a, c = ""] = n.split("."), l = a.replace(Ze, "") || "0";
545
+ let o;
546
+ if (c.length === 0)
547
+ o = l + "0".repeat(s);
548
+ else if (c.length <= s) {
549
+ const h = s - c.length;
550
+ o = l + c + "0".repeat(h);
881
551
  } else {
882
- const d = h.slice(0, i), g = h.slice(i);
883
- f = u + d + "." + g;
552
+ const h = c.slice(0, s), d = c.slice(s);
553
+ o = l + h + "." + d;
884
554
  }
885
- return f = f.replace(/^(-?)0+([1-9])/, "$1$2"), f.match(/^-?0+$/) && (f = a ? "-0" : "0"), f.includes(".") && (f = f.replace(/\.?0+$/, "")), a && !f.startsWith("-") ? "-" + f : f;
555
+ return o = o.replace(ke, "$1$2"), Be.test(o) && (o = "0"), o.includes(".") && (o = o.replace(Pe, "")), o;
886
556
  });
887
557
  }
888
- function Be(e) {
558
+ function ze(e) {
889
559
  if (!e || e === "0" || e === "-0" || e === "-" || e === ".")
890
560
  return e;
891
561
  const t = e.startsWith("-"), n = t ? e.slice(1) : e;
892
- if (!n || n === "0" || n === ".")
562
+ if (n === ".")
893
563
  return e;
894
564
  if (n.includes(".")) {
895
- const [o, r] = n.split(".");
896
- if (o && o.length > 0) {
897
- const a = (o.replace(/^0+/, "") || "0") + "." + r;
898
- return t ? "-" + a : a;
565
+ const [i, s] = n.split(".");
566
+ if (i) {
567
+ const c = (i.replace(/^0+/, "") || "0") + "." + s;
568
+ return t ? "-" + c : c;
899
569
  }
900
570
  return e;
901
571
  }
902
- if (n.startsWith("0") && n.length > 1) {
903
- const o = n.replace(/^0+/, "") || "0";
904
- return t ? "-" + o : o;
572
+ if (n.startsWith("0")) {
573
+ const i = n.replace(/^0+/, "") || "0";
574
+ return t ? "-" + i : i;
905
575
  }
906
576
  return e;
907
577
  }
908
- function We(e) {
909
- return e.replace(/[\u00A0\u2000-\u200B\u202F\u205F\u3000]/g, " ").replace(/\s/g, "");
578
+ function Je(e) {
579
+ return e.replace(/[\s\u200B]/g, "");
910
580
  }
911
- function v(e, t) {
912
- const n = x(t);
913
- return e.replace(new RegExp(n, "g"), "");
581
+ function N(e, t) {
582
+ const n = ie(t);
583
+ return e.replace(n, "");
914
584
  }
915
- const ke = (e, t) => {
916
- let n = We(e);
917
- return t != null && t.thousandSeparator && (n = v(n, t.thousandSeparator)), t != null && t.enableCompactNotation && (n = Ze(n)), n = Re(n), n = Oe(
585
+ const Xe = (e, t) => {
586
+ let n = Je(e);
587
+ return t != null && t.thousandSeparator && (n = N(n, t.thousandSeparator)), t != null && t.enableCompactNotation && (n = Ue(n)), n = _e(n), n = Ie(
918
588
  n,
919
589
  t == null ? void 0 : t.enableNegative,
920
590
  t == null ? void 0 : t.decimalSeparator
921
- ), n = he(n, (t == null ? void 0 : t.decimalSeparator) || N), t != null && t.enableLeadingZeros || (n = Be(n)), n;
591
+ ), n = le(n, t == null ? void 0 : t.decimalSeparator), t != null && t.enableLeadingZeros || (n = ze(n)), n;
922
592
  };
923
- function Ue(e, t, n) {
593
+ function je(e, t, n) {
924
594
  return {
925
595
  enableCompactNotation: e == null ? void 0 : e.enableCompactNotation,
926
596
  enableNegative: e == null ? void 0 : e.enableNegative,
@@ -929,31 +599,31 @@ function Ue(e, t, n) {
929
599
  thousandSeparator: n ? t.thousandSeparator : void 0
930
600
  };
931
601
  }
932
- function O(e, t, n, s) {
933
- const o = T(n), r = s ?? (n == null ? void 0 : n.formatOn) === m.Change, i = ke(
602
+ function O(e, t, n, r) {
603
+ const i = _(n), s = r ?? (n == null ? void 0 : n.formatOn) === b.Change, a = Xe(
934
604
  e,
935
- Ue(n, o, r)
936
- ), a = le(
937
- i,
938
- t,
939
- o.decimalSeparator
940
- ), c = (n == null ? void 0 : n.decimalMinLength) ?? 0, l = ue(
605
+ je(n, i, s)
606
+ ), c = oe(
941
607
  a,
608
+ t,
609
+ i.decimalSeparator
610
+ ), l = (n == null ? void 0 : n.decimalMinLength) ?? 0, o = he(
942
611
  c,
943
- o.decimalSeparator
944
- ), h = l;
945
- return { formatted: pe(l, n, o), raw: h };
612
+ l,
613
+ i.decimalSeparator
614
+ );
615
+ return { formatted: fe(o, n, i), raw: o };
946
616
  }
947
- function ht(e, t, n) {
948
- const s = !!(n != null && n.thousandSeparator);
617
+ function ft(e, t, n) {
618
+ const r = !!(n != null && n.thousandSeparator);
949
619
  return O(
950
620
  e,
951
621
  t,
952
622
  n,
953
- s
623
+ r
954
624
  );
955
625
  }
956
- function Ge(e, t, n) {
626
+ function Ke(e, t, n) {
957
627
  if (e === "Backspace" || e === "Delete")
958
628
  return e === "Delete" && t === n ? {
959
629
  endOffset: 1
@@ -961,61 +631,81 @@ function Ge(e, t, n) {
961
631
  endOffset: 0
962
632
  };
963
633
  }
964
- function je(e, t) {
965
- const { decimalSeparator: n } = T(t), s = e.target;
966
- if (ce(e, s, n)) {
634
+ function qe(e, t) {
635
+ const { decimalSeparator: n } = _(t), r = e.target;
636
+ if (ce(e, r, n)) {
967
637
  e.preventDefault();
968
638
  return;
969
639
  }
970
- return Ce(e, s, t), Ge(e.key, s.selectionStart, s.selectionEnd);
640
+ return Ae(e, r, t), Ke(e.key, r.selectionStart, r.selectionEnd);
971
641
  }
972
- function Je(e, t, n, s) {
973
- const o = e.target, r = o.value, i = xe(o), a = T(s), c = (s == null ? void 0 : s.formatOn) === m.Change, { formatted: l, raw: h } = O(
974
- r,
975
- t,
642
+ function He(e, t, n, r) {
643
+ const i = e.target, s = i.value, a = Me(i), c = _(r), l = (r == null ? void 0 : r.formatOn) === b.Change, { formatted: o, raw: h } = O(
976
644
  s,
977
- c
978
- );
979
- return o.value = l, r !== l && Ae(
980
- o,
645
+ t,
981
646
  r,
982
- l,
647
+ l
648
+ );
649
+ return i.value = o, s !== o && Re(
983
650
  i,
984
- n,
651
+ s,
652
+ o,
985
653
  a,
986
- s
987
- ), { formatted: l, raw: h };
654
+ n,
655
+ c,
656
+ r
657
+ ), { formatted: o, raw: h };
988
658
  }
989
- function Ke(e, t, n, s) {
990
- const o = s - n;
991
- return e + t + o;
659
+ function Ye(e, t, n, r) {
660
+ const i = r - n;
661
+ return e + t + i;
992
662
  }
993
- function qe(e, t, n) {
994
- var f;
663
+ function Qe(e, t, n) {
664
+ var u;
995
665
  e.preventDefault();
996
- const s = e.target, { value: o, selectionStart: r, selectionEnd: i } = s, a = ((f = e.clipboardData) == null ? void 0 : f.getData("text/plain")) || "", c = o.slice(0, r || 0) + a + o.slice(i || 0), { formatted: l, raw: h } = O(
997
- c,
666
+ const r = e.target, { value: i, selectionStart: s, selectionEnd: a } = r, c = ((u = e.clipboardData) == null ? void 0 : u.getData("text/plain")) || "", l = i.slice(0, s || 0) + c + i.slice(a || 0), { formatted: o, raw: h } = O(
667
+ l,
998
668
  t,
999
669
  n,
1000
670
  !0
1001
671
  );
1002
- s.value = l;
1003
- const u = Ke(
1004
- r || 0,
1005
- a.length,
672
+ r.value = o;
673
+ const d = Ye(
674
+ s || 0,
1006
675
  c.length,
1007
- l.length
676
+ l.length,
677
+ o.length
1008
678
  );
1009
- return s.setSelectionRange(u, u), { formatted: l, raw: h };
679
+ return r.setSelectionRange(d, d), { formatted: o, raw: h };
1010
680
  }
1011
- function Qe(e, t) {
1012
- const n = x(e);
681
+ function Ve(e, t) {
682
+ const n = w(e);
1013
683
  return t ? `^-?[0-9]*[${n}]?[0-9]*$` : `^[0-9]*[${n}]?[0-9]*$`;
1014
684
  }
1015
- function He(e) {
1016
- Xe(e.decimalMaxLength), Ye(e.decimalMinLength), Ve(e.decimalMinLength, e.decimalMaxLength), Fe(e.formatOn), et(e.thousandSeparator), tt(e.thousandStyle), nt(e.decimalSeparator), st(e.thousandSeparator, e.decimalSeparator), M("enableCompactNotation", e.enableCompactNotation), M("enableNegative", e.enableNegative), M("enableLeadingZeros", e.enableLeadingZeros), M("rawValueMode", e.rawValueMode), rt(e.onChange);
685
+ function Fe(e) {
686
+ var t, n;
687
+ try {
688
+ const i = new Intl.NumberFormat(e).formatToParts(123456789e-2);
689
+ return {
690
+ decimalSeparator: ((t = i.find((s) => s.type === "decimal")) == null ? void 0 : t.value) ?? ".",
691
+ thousandSeparator: ((n = i.find((s) => s.type === "group")) == null ? void 0 : n.value) ?? ","
692
+ };
693
+ } catch {
694
+ return { thousandSeparator: ",", decimalSeparator: "." };
695
+ }
696
+ }
697
+ function et(e) {
698
+ let t = e.thousandSeparator ?? re, n = e.decimalSeparator ?? v, r = e.thousandStyle ?? H;
699
+ if (e.thousandStyle === m.Locale || e.decimalSeparator === "auto") {
700
+ const s = Fe();
701
+ e.thousandStyle === m.Locale && (t = e.thousandSeparator ?? s.thousandSeparator, n = e.decimalSeparator === "auto" || e.decimalSeparator === void 0 ? s.decimalSeparator : e.decimalSeparator, r = m.Thousand), e.decimalSeparator === "auto" && (n = s.decimalSeparator);
702
+ }
703
+ return { thousandSeparator: t, thousandStyle: r, decimalSeparator: n };
704
+ }
705
+ function tt(e) {
706
+ nt(e.decimalMaxLength), rt(e.decimalMinLength), it(e.decimalMinLength, e.decimalMaxLength), st(e.formatOn), at(e.thousandSeparator), ct(e.thousandStyle), ot(e.decimalSeparator), lt(e.thousandSeparator, e.decimalSeparator), M("enableCompactNotation", e.enableCompactNotation), M("enableNegative", e.enableNegative), M("enableLeadingZeros", e.enableLeadingZeros), M("rawValueMode", e.rawValueMode), ht(e.onChange);
1017
707
  }
1018
- function Xe(e) {
708
+ function nt(e) {
1019
709
  if (e !== void 0) {
1020
710
  if (typeof e != "number")
1021
711
  throw new Error(
@@ -1031,7 +721,7 @@ function Xe(e) {
1031
721
  );
1032
722
  }
1033
723
  }
1034
- function Ye(e) {
724
+ function rt(e) {
1035
725
  if (e !== void 0) {
1036
726
  if (typeof e != "number")
1037
727
  throw new Error(
@@ -1047,19 +737,19 @@ function Ye(e) {
1047
737
  );
1048
738
  }
1049
739
  }
1050
- function Ve(e, t) {
740
+ function it(e, t) {
1051
741
  if (!(e === void 0 || t === void 0) && e > t)
1052
742
  throw new Error(
1053
743
  `decimalMinLength (${e}) cannot be greater than decimalMaxLength (${t}).`
1054
744
  );
1055
745
  }
1056
- function Fe(e) {
1057
- if (e !== void 0 && e !== m.Blur && e !== m.Change)
746
+ function st(e) {
747
+ if (e !== void 0 && e !== b.Blur && e !== b.Change)
1058
748
  throw new Error(
1059
- `formatOn must be either ${m.Blur} or ${m.Change}. Received: ${JSON.stringify(e)}`
749
+ `formatOn must be either ${b.Blur} or ${b.Change}. Received: ${JSON.stringify(e)}`
1060
750
  );
1061
751
  }
1062
- function et(e) {
752
+ function at(e) {
1063
753
  if (e !== void 0) {
1064
754
  if (typeof e != "string")
1065
755
  throw new Error(
@@ -1075,14 +765,14 @@ function et(e) {
1075
765
  );
1076
766
  }
1077
767
  }
1078
- function tt(e) {
1079
- if (e !== void 0 && !Object.values(S).includes(e))
768
+ function ct(e) {
769
+ if (e !== void 0 && !Object.values(m).includes(e))
1080
770
  throw new Error(
1081
- `ThousandStyle must be one of: ${Object.values(S).map((t) => `'${t}'`).join(", ")}. Received: ${JSON.stringify(e)}`
771
+ `ThousandStyle must be one of: ${Object.values(m).map((t) => `'${t}'`).join(", ")}. Received: ${JSON.stringify(e)}`
1082
772
  );
1083
773
  }
1084
- function nt(e) {
1085
- if (e !== void 0) {
774
+ function ot(e) {
775
+ if (!(e === void 0 || e === "auto")) {
1086
776
  if (typeof e != "string")
1087
777
  throw new Error(
1088
778
  `decimalSeparator must be a string. Received: ${typeof e} (${JSON.stringify(e)})`
@@ -1097,8 +787,8 @@ function nt(e) {
1097
787
  );
1098
788
  }
1099
789
  }
1100
- function st(e, t) {
1101
- if (!(e === void 0 || t === void 0) && e === t)
790
+ function lt(e, t) {
791
+ if (!(e === void 0 || t === void 0) && t !== "auto" && e === t)
1102
792
  throw new Error(
1103
793
  `Decimal separator can't be same as thousand separator. thousandSeparator: ${e}, decimalSeparator: ${t}`
1104
794
  );
@@ -1109,108 +799,113 @@ function M(e, t) {
1109
799
  `${e} must be a boolean. Received: ${typeof t} (${JSON.stringify(t)})`
1110
800
  );
1111
801
  }
1112
- function rt(e) {
802
+ function ht(e) {
1113
803
  if (e !== void 0 && typeof e != "function")
1114
804
  throw new Error(
1115
805
  `onChange must be a function or undefined. Received: ${typeof e} (${JSON.stringify(e)})`
1116
806
  );
1117
807
  }
1118
- class ut {
808
+ class gt {
1119
809
  constructor(t, {
1120
- decimalMaxLength: n = _,
1121
- decimalMinLength: s = z,
1122
- formatOn: o = Z,
1123
- thousandSeparator: r = B,
1124
- thousandStyle: i = W,
1125
- decimalSeparator: a = N,
1126
- enableCompactNotation: c = !0,
1127
- enableNegative: l = k,
1128
- enableLeadingZeros: h = U,
1129
- rawValueMode: u = G,
1130
- onChange: f,
1131
- ...d
810
+ decimalMaxLength: n = G,
811
+ decimalMinLength: r = Z,
812
+ formatOn: i = k,
813
+ thousandSeparator: s,
814
+ thousandStyle: a = H,
815
+ decimalSeparator: c,
816
+ enableCompactNotation: l = B,
817
+ enableNegative: o = P,
818
+ enableLeadingZeros: h = W,
819
+ rawValueMode: d = U,
820
+ onChange: u,
821
+ ...g
1132
822
  }) {
1133
- w(this, "element");
1134
- w(this, "options");
1135
- w(this, "resolvedOptions");
1136
- w(this, "rawValue", "");
1137
- w(this, "caretPositionBeforeChange");
1138
- if (He({
823
+ D(this, "element");
824
+ D(this, "resolvedOptions");
825
+ D(this, "rawValue", "");
826
+ D(this, "caretPositionBeforeChange");
827
+ tt({
1139
828
  decimalMaxLength: n,
1140
- decimalMinLength: s,
1141
- formatOn: o,
1142
- thousandSeparator: r,
1143
- thousandStyle: i,
1144
- decimalSeparator: a,
1145
- enableCompactNotation: c,
1146
- enableNegative: l,
829
+ decimalMinLength: r,
830
+ formatOn: i,
831
+ thousandSeparator: s,
832
+ thousandStyle: a,
833
+ decimalSeparator: c,
834
+ enableCompactNotation: l,
835
+ enableNegative: o,
1147
836
  enableLeadingZeros: h,
1148
- rawValueMode: u,
1149
- onChange: f
1150
- }), this.options = {
837
+ rawValueMode: d,
838
+ onChange: u
839
+ });
840
+ const S = {
1151
841
  decimalMaxLength: n,
1152
- decimalMinLength: s,
1153
- onChange: f,
1154
- formatOn: o,
1155
- thousandSeparator: r,
1156
- thousandStyle: i,
1157
- decimalSeparator: a,
1158
- enableCompactNotation: c,
1159
- enableNegative: l,
842
+ decimalMinLength: r,
843
+ onChange: u,
844
+ formatOn: i,
845
+ thousandSeparator: s,
846
+ thousandStyle: a,
847
+ decimalSeparator: c,
848
+ enableCompactNotation: l,
849
+ enableNegative: o,
1160
850
  enableLeadingZeros: h,
1161
- rawValueMode: u,
1162
- ...d
1163
- }, this.resolvedOptions = this.getResolvedOptions(), this.createInputElement(t), this.setupEventListeners(), this.resolvedOptions.rawValueMode && this.element.value) {
1164
- const g = this.element.value, p = this.resolvedOptions.thousandSeparator ? v(g, this.resolvedOptions.thousandSeparator) : g;
1165
- this.rawValue = p, this.element.value = this.formatValueForDisplay(p);
851
+ rawValueMode: d,
852
+ ...g
853
+ };
854
+ if (this.resolvedOptions = this.getResolvedOptions(S), this.createInputElement(t, S), this.setupEventListeners(), this.resolvedOptions.rawValueMode && this.element.value) {
855
+ const E = this.element.value, f = this.resolvedOptions.thousandSeparator ? N(E, this.resolvedOptions.thousandSeparator) : E;
856
+ this.rawValue = f, this.element.value = this.formatValueForDisplay(f);
1166
857
  } else if (this.element.value) {
1167
- const g = this.element.value;
1168
- this.element.value = this.formatValueForDisplay(g);
858
+ const E = this.element.value;
859
+ this.element.value = this.formatValueForDisplay(E);
1169
860
  }
1170
861
  }
1171
- createInputElement(t) {
1172
- if (this.element = document.createElement("input"), this.element.setAttribute("type", "text"), this.element.setAttribute("inputmode", "decimal"), this.element.setAttribute("spellcheck", "false"), this.element.setAttribute("autocomplete", "off"), this.resolvedOptions.decimalSeparator !== void 0 && this.resolvedOptions.enableNegative !== void 0) {
1173
- const se = Qe(this.resolvedOptions.decimalSeparator, this.resolvedOptions.enableNegative);
1174
- this.element.setAttribute("pattern", se);
1175
- }
862
+ createInputElement(t, n) {
863
+ this.element = document.createElement("input"), this.element.setAttribute("type", "text"), this.element.setAttribute("inputmode", "decimal"), this.element.setAttribute("spellcheck", "false"), this.element.setAttribute("autocomplete", "off");
864
+ const r = Ve(this.resolvedOptions.decimalSeparator, this.resolvedOptions.enableNegative);
865
+ this.element.setAttribute("pattern", r);
1176
866
  const {
1177
- decimalMaxLength: n,
867
+ decimalMaxLength: i,
1178
868
  decimalMinLength: s,
1179
- formatOn: o,
1180
- thousandSeparator: r,
1181
- thousandStyle: i,
1182
- decimalSeparator: a,
1183
- enableCompactNotation: c,
1184
- enableNegative: l,
1185
- enableLeadingZeros: h,
1186
- rawValueMode: u,
1187
- onChange: f,
1188
- value: d,
1189
- defaultValue: g,
869
+ formatOn: a,
870
+ thousandSeparator: c,
871
+ thousandStyle: l,
872
+ decimalSeparator: o,
873
+ enableCompactNotation: h,
874
+ enableNegative: d,
875
+ enableLeadingZeros: u,
876
+ rawValueMode: g,
877
+ onChange: S,
878
+ value: E,
879
+ defaultValue: f,
1190
880
  type: p,
1191
- inputMode: $,
1192
- spellcheck: D,
1193
- autocomplete: R,
1194
- ...ne
1195
- } = this.options;
1196
- Object.assign(this.element, ne), d !== void 0 ? this.element.value = d : g !== void 0 && (this.element.defaultValue = g, this.element.value = g), t.appendChild(this.element);
881
+ inputMode: y,
882
+ spellcheck: C,
883
+ autocomplete: ut,
884
+ ...ee
885
+ } = n;
886
+ Object.assign(this.element, ee), E !== void 0 ? this.element.value = E : f !== void 0 && (this.element.defaultValue = f, this.element.value = f), t.appendChild(this.element);
1197
887
  }
1198
888
  setupEventListeners() {
1199
- 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 === m.Blur && this.resolvedOptions.thousandSeparator && (this.element.addEventListener("focus", this.handleFocus.bind(this)), this.element.addEventListener("blur", this.handleBlur.bind(this)));
889
+ 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 === b.Blur && this.resolvedOptions.thousandSeparator && (this.element.addEventListener("focus", this.handleFocus.bind(this)), this.element.addEventListener("blur", this.handleBlur.bind(this)));
1200
890
  }
1201
- getResolvedOptions() {
891
+ getResolvedOptions(t) {
892
+ const n = et({
893
+ thousandSeparator: t.thousandSeparator,
894
+ thousandStyle: t.thousandStyle,
895
+ decimalSeparator: t.decimalSeparator
896
+ });
1202
897
  return {
1203
- decimalMaxLength: this.options.decimalMaxLength ?? _,
1204
- decimalMinLength: this.options.decimalMinLength ?? z,
1205
- formatOn: this.options.formatOn ?? Z,
1206
- thousandSeparator: this.options.thousandSeparator ?? B,
1207
- thousandStyle: this.options.thousandStyle ?? W,
1208
- decimalSeparator: this.options.decimalSeparator ?? N,
1209
- enableCompactNotation: this.options.enableCompactNotation ?? oe,
1210
- enableNegative: this.options.enableNegative ?? k,
1211
- enableLeadingZeros: this.options.enableLeadingZeros ?? U,
1212
- rawValueMode: this.options.rawValueMode ?? G,
1213
- onChange: this.options.onChange
898
+ decimalMaxLength: t.decimalMaxLength ?? G,
899
+ decimalMinLength: t.decimalMinLength ?? Z,
900
+ formatOn: t.formatOn ?? k,
901
+ thousandSeparator: n.thousandSeparator,
902
+ thousandStyle: n.thousandStyle,
903
+ decimalSeparator: n.decimalSeparator,
904
+ enableCompactNotation: t.enableCompactNotation ?? B,
905
+ enableNegative: t.enableNegative ?? P,
906
+ enableLeadingZeros: t.enableLeadingZeros ?? W,
907
+ rawValueMode: t.rawValueMode ?? U,
908
+ onChange: t.onChange
1214
909
  };
1215
910
  }
1216
911
  buildFormattingOptions() {
@@ -1228,67 +923,66 @@ class ut {
1228
923
  }
1229
924
  handleValueChange(t, n) {
1230
925
  if (this.resolvedOptions.rawValueMode && n !== void 0 && (this.rawValue = n), this.resolvedOptions.onChange) {
1231
- const s = this.resolvedOptions.rawValueMode ? this.rawValue : t;
1232
- this.resolvedOptions.onChange(s);
926
+ const r = this.resolvedOptions.rawValueMode ? this.rawValue : t;
927
+ this.resolvedOptions.onChange(r);
1233
928
  }
1234
929
  }
1235
930
  formatValueForDisplay(t) {
1236
931
  if (!t)
1237
932
  return t;
1238
- const { thousandSeparator: n, thousandStyle: s, enableLeadingZeros: o, decimalSeparator: r } = this.resolvedOptions;
1239
- return n && s !== S.None ? y(
933
+ const { thousandSeparator: n, thousandStyle: r, enableLeadingZeros: i, decimalSeparator: s } = this.resolvedOptions;
934
+ return n && r !== m.None ? Q(
1240
935
  t,
1241
936
  n,
1242
- s,
1243
- o,
1244
- r
937
+ r,
938
+ i,
939
+ s
1245
940
  ) : t;
1246
941
  }
1247
942
  handleChange(t) {
1248
- const { formatted: n, raw: s } = Je(
943
+ const { formatted: n, raw: r } = He(
1249
944
  t,
1250
945
  this.resolvedOptions.decimalMaxLength,
1251
946
  this.caretPositionBeforeChange,
1252
947
  this.buildFormattingOptions()
1253
948
  );
1254
- this.caretPositionBeforeChange = void 0, this.handleValueChange(n, s);
949
+ this.caretPositionBeforeChange = void 0, this.handleValueChange(n, r);
1255
950
  }
1256
951
  handleKeyDown(t) {
1257
- const n = t.target, { selectionStart: s, selectionEnd: o } = n, r = this.buildFormattingOptions(), i = je(t, {
1258
- formatOn: r.formatOn,
1259
- thousandSeparator: r.thousandSeparator,
1260
- ThousandStyle: r.ThousandStyle,
1261
- decimalSeparator: r.decimalSeparator
952
+ const n = t.target, { selectionStart: r, selectionEnd: i } = n, s = this.buildFormattingOptions(), a = qe(t, {
953
+ formatOn: s.formatOn,
954
+ thousandSeparator: s.thousandSeparator,
955
+ ThousandStyle: s.ThousandStyle,
956
+ decimalSeparator: s.decimalSeparator
1262
957
  });
1263
- i ? this.caretPositionBeforeChange = {
1264
- selectionStart: s ?? 0,
1265
- selectionEnd: o ?? 0,
1266
- endOffset: i.endOffset
958
+ a ? this.caretPositionBeforeChange = {
959
+ selectionStart: r ?? 0,
960
+ selectionEnd: i ?? 0,
961
+ endOffset: a.endOffset
1267
962
  } : this.caretPositionBeforeChange = {
1268
- selectionStart: s ?? 0,
1269
- selectionEnd: o ?? 0
963
+ selectionStart: r ?? 0,
964
+ selectionEnd: i ?? 0
1270
965
  };
1271
966
  }
1272
967
  handlePaste(t) {
1273
- const { formatted: n, raw: s } = qe(t, this.resolvedOptions.decimalMaxLength, this.buildFormattingOptions());
1274
- this.handleValueChange(n, s);
1275
- const o = new Event("input", { bubbles: !0, cancelable: !0 });
1276
- this.element.dispatchEvent(o);
968
+ const { formatted: n, raw: r } = Qe(t, this.resolvedOptions.decimalMaxLength, this.buildFormattingOptions());
969
+ this.handleValueChange(n, r);
970
+ const i = new Event("input", { bubbles: !0, cancelable: !0 });
971
+ this.element.dispatchEvent(i);
1277
972
  }
1278
973
  handleFocus(t) {
1279
- if (this.resolvedOptions.formatOn === m.Blur && this.resolvedOptions.thousandSeparator) {
974
+ if (this.resolvedOptions.formatOn === b.Blur && this.resolvedOptions.thousandSeparator) {
1280
975
  const n = t.target;
1281
- n.value = v(n.value, this.resolvedOptions.thousandSeparator);
976
+ n.value = N(n.value, this.resolvedOptions.thousandSeparator);
1282
977
  }
1283
978
  }
1284
979
  handleBlur(t) {
1285
- const n = t.target, { thousandSeparator: s, thousandStyle: o } = this.resolvedOptions;
1286
- if (s && o !== S.None && n.value) {
1287
- n.value;
1288
- const r = this.formatValueForDisplay(n.value);
1289
- n.value = r;
1290
- const i = this.resolvedOptions.rawValueMode ? v(r, s) : void 0;
1291
- this.handleValueChange(r, i);
980
+ const n = t.target, { thousandSeparator: r, thousandStyle: i } = this.resolvedOptions;
981
+ if (r && i !== m.None && n.value) {
982
+ const s = this.formatValueForDisplay(n.value);
983
+ n.value = s;
984
+ const a = this.resolvedOptions.rawValueMode ? N(s, r) : void 0;
985
+ this.handleValueChange(s, a);
1292
986
  }
1293
987
  }
1294
988
  getValue() {
@@ -1296,7 +990,7 @@ class ut {
1296
990
  }
1297
991
  setValue(t) {
1298
992
  if (this.resolvedOptions.rawValueMode) {
1299
- const n = this.resolvedOptions.thousandSeparator ? v(t, this.resolvedOptions.thousandSeparator) : t;
993
+ const n = this.resolvedOptions.thousandSeparator ? N(t, this.resolvedOptions.thousandSeparator) : t;
1300
994
  this.rawValue = n, this.element.value = this.formatValueForDisplay(n);
1301
995
  } else
1302
996
  this.element.value = t;
@@ -1344,8 +1038,8 @@ class ut {
1344
1038
  const t = this.getValue();
1345
1039
  if (!t)
1346
1040
  return NaN;
1347
- const n = this.resolvedOptions.thousandSeparator ? v(t, this.resolvedOptions.thousandSeparator) : t, s = this.resolvedOptions.decimalSeparator && this.resolvedOptions.decimalSeparator !== "." ? n.replace(new RegExp(x(this.resolvedOptions.decimalSeparator), "g"), ".") : n;
1348
- return parseFloat(s);
1041
+ const n = this.resolvedOptions.thousandSeparator ? N(t, this.resolvedOptions.thousandSeparator) : t, r = this.resolvedOptions.decimalSeparator && this.resolvedOptions.decimalSeparator !== "." ? n.replace(new RegExp(w(this.resolvedOptions.decimalSeparator), "g"), ".") : n;
1042
+ return parseFloat(r);
1349
1043
  }
1350
1044
  /**
1351
1045
  * Sets the value from a number, similar to HTMLInputElement.valueAsNumber.
@@ -1360,17 +1054,17 @@ class ut {
1360
1054
  }
1361
1055
  }
1362
1056
  export {
1363
- m as FormatOn,
1364
- ut as NumoraInput,
1365
- S as ThousandStyle,
1366
- ct as condenseDecimalZeros,
1057
+ b as FormatOn,
1058
+ gt as NumoraInput,
1059
+ m as ThousandStyle,
1367
1060
  O as formatInputValue,
1368
- lt as formatLargeNumber,
1369
- at as formatLargePercent,
1370
- ot as formatPercent,
1371
- ht as formatValueForDisplay,
1372
- Je as handleOnChangeNumoraInput,
1373
- je as handleOnKeyDownNumoraInput,
1374
- qe as handleOnPasteNumoraInput,
1375
- v as removeThousandSeparators
1061
+ ft as formatValueForDisplay,
1062
+ Ve as getNumoraPattern,
1063
+ Fe as getSeparatorsFromLocale,
1064
+ He as handleOnChangeNumoraInput,
1065
+ qe as handleOnKeyDownNumoraInput,
1066
+ Qe as handleOnPasteNumoraInput,
1067
+ N as removeThousandSeparators,
1068
+ et as resolveLocaleOptions,
1069
+ tt as validateNumoraInputOptions
1376
1070
  };