@opengis/cms 0.0.26 → 0.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +98 -98
  2. package/dist/index-W-qQIppj-DunG40EG.js +2452 -0
  3. package/dist/index.html +28 -28
  4. package/dist/index.js +12683 -6702
  5. package/dist/index.umd.cjs +87 -41
  6. package/dist/style.css +1 -0
  7. package/package.json +68 -68
  8. package/plugin.js +76 -76
  9. package/server/app.js +35 -35
  10. package/server/config.js +4 -4
  11. package/server/functions/getDraftKey.js +22 -22
  12. package/server/index.js +22 -22
  13. package/server/migrations/fixes.sql +123 -123
  14. package/server/migrations/site.sql +545 -545
  15. package/server/plugins/adminHook.js +78 -78
  16. package/server/plugins/hook.js +59 -59
  17. package/server/plugins/vite.js +84 -84
  18. package/server/routes/category/controllers/cms.category.delete.js +21 -21
  19. package/server/routes/category/controllers/cms.category.get.js +17 -17
  20. package/server/routes/category/controllers/cms.category.list.js +16 -16
  21. package/server/routes/category/controllers/cms.category.post.js +21 -21
  22. package/server/routes/category/controllers/cms.category.put.js +23 -23
  23. package/server/routes/category/index.mjs +22 -22
  24. package/server/routes/cms/controllers/cmsStat.js +55 -55
  25. package/server/routes/cms/controllers/cmsSuggest.js +57 -57
  26. package/server/routes/cms/controllers/deleteContent.js +114 -114
  27. package/server/routes/cms/controllers/deleteMedia.js +75 -75
  28. package/server/routes/cms/controllers/downloadMedia.js +48 -48
  29. package/server/routes/cms/controllers/getContent.js +110 -110
  30. package/server/routes/cms/controllers/getContentBySlug.js +95 -95
  31. package/server/routes/cms/controllers/getPermissions.js +15 -15
  32. package/server/routes/cms/controllers/insertContent.js +218 -218
  33. package/server/routes/cms/controllers/listMedia.js +93 -93
  34. package/server/routes/cms/controllers/metadataMedia.js +38 -38
  35. package/server/routes/cms/controllers/properties.get.js +53 -53
  36. package/server/routes/cms/controllers/properties.post.js +99 -99
  37. package/server/routes/cms/controllers/searchContent.js +205 -205
  38. package/server/routes/cms/controllers/setPermissions.js +49 -49
  39. package/server/routes/cms/controllers/translate.js +89 -89
  40. package/server/routes/cms/controllers/updateContent.js +238 -238
  41. package/server/routes/cms/controllers/uploadMedia.js +78 -78
  42. package/server/routes/cms/index.mjs +114 -114
  43. package/server/routes/cms/utils/additionalData.js +35 -35
  44. package/server/routes/cms/utils/getCollection.js +81 -81
  45. package/server/routes/cms/utils/getSingle.js +187 -187
  46. package/server/routes/cms/utils/insertContentLocalization.js +86 -86
  47. package/server/routes/cms/utils/requestTranslation.js +85 -85
  48. package/server/routes/cms/utils/updateLocalization.js +47 -47
  49. package/server/routes/cmsSpace/controllers/deleteSpace.js +25 -25
  50. package/server/routes/cmsSpace/controllers/getSpaces.js +27 -27
  51. package/server/routes/cmsSpace/controllers/insertSpace.js +21 -21
  52. package/server/routes/cmsSpace/controllers/updateSpace.js +23 -23
  53. package/server/routes/cmsSpace/index.mjs +20 -20
  54. package/server/routes/contentType/controllers/addContentType.js +162 -162
  55. package/server/routes/contentType/controllers/contentTypeList.js +54 -54
  56. package/server/routes/contentType/controllers/delContentType.js +75 -75
  57. package/server/routes/contentType/controllers/editContentType.js +61 -61
  58. package/server/routes/contentType/controllers/getContentType.js +37 -37
  59. package/server/routes/contentType/index.mjs +35 -35
  60. package/server/routes/contentType/utils/updateContents.js +28 -28
  61. package/server/routes/contentType/utils/updateCustomContentTable.js +55 -55
  62. package/server/routes/feedback/controllers/email.list.js +24 -24
  63. package/server/routes/feedback/controllers/feedback.js +48 -48
  64. package/server/routes/feedback/controllers/feedback.list.js +37 -37
  65. package/server/routes/feedback/controllers/news.subscriptions.js +44 -44
  66. package/server/routes/feedback/index.mjs +71 -71
  67. package/server/routes/logs/controllers/export.user.logs.js +77 -77
  68. package/server/routes/logs/controllers/user.logs.js +44 -44
  69. package/server/routes/logs/index.mjs +9 -9
  70. package/server/routes/menu/controllers/addMenu.js +37 -37
  71. package/server/routes/menu/controllers/delMenu.js +31 -31
  72. package/server/routes/menu/controllers/editMenu.js +41 -41
  73. package/server/routes/menu/controllers/getMenu.js +42 -42
  74. package/server/routes/menu/index.mjs +13 -13
  75. package/server/routes/migration/controllers/collectionToCustom.js +137 -137
  76. package/server/routes/migration/index.mjs +8 -8
  77. package/server/routes/root.mjs +8 -8
  78. package/server/routes/tags/controllers/add.tags.js +24 -24
  79. package/server/routes/tags/controllers/del.tags.js +19 -19
  80. package/server/routes/tags/controllers/edit.tags.js +25 -25
  81. package/server/routes/tags/controllers/get.tags.js +15 -15
  82. package/server/routes/tags/index.mjs +14 -14
  83. package/server/templates/cls/cms.category_type.json +9 -9
  84. package/server/templates/cls/cms.content_review_status.json +9 -9
  85. package/server/templates/cls/cms.content_status.json +9 -9
  86. package/server/templates/cls/cms.content_type.json +9 -9
  87. package/server/templates/cls/cms.lang.json +9 -9
  88. package/server/templates/page/login.html +126 -126
  89. package/server/templates/select/core.user_mentioned.sql +1 -1
  90. package/dist/index-W-qQIppj-DRzFSjU1.js +0 -2452
@@ -0,0 +1,2452 @@
1
+ function A(n) {
2
+ return typeof n == "string" || n instanceof String;
3
+ }
4
+ function L(n) {
5
+ var t;
6
+ return typeof n == "object" && n != null && (n == null || (t = n.constructor) == null ? void 0 : t.name) === "Object";
7
+ }
8
+ function U(n, t) {
9
+ return Array.isArray(t) ? U(n, (e, s) => t.includes(s)) : Object.entries(n).reduce((e, s) => {
10
+ let [i, a] = s;
11
+ return t(a, i) && (e[i] = a), e;
12
+ }, {});
13
+ }
14
+ const o = {
15
+ NONE: "NONE",
16
+ LEFT: "LEFT",
17
+ FORCE_LEFT: "FORCE_LEFT",
18
+ RIGHT: "RIGHT",
19
+ FORCE_RIGHT: "FORCE_RIGHT"
20
+ };
21
+ function Y(n) {
22
+ switch (n) {
23
+ case o.LEFT:
24
+ return o.FORCE_LEFT;
25
+ case o.RIGHT:
26
+ return o.FORCE_RIGHT;
27
+ default:
28
+ return n;
29
+ }
30
+ }
31
+ function w(n) {
32
+ return n.replace(/([.*+?^=!:${}()|[\]/\\])/g, "\\$1");
33
+ }
34
+ function D(n, t) {
35
+ if (t === n)
36
+ return !0;
37
+ const e = Array.isArray(t), s = Array.isArray(n);
38
+ let i;
39
+ if (e && s) {
40
+ if (t.length != n.length)
41
+ return !1;
42
+ for (i = 0; i < t.length; i++)
43
+ if (!D(t[i], n[i]))
44
+ return !1;
45
+ return !0;
46
+ }
47
+ if (e != s)
48
+ return !1;
49
+ if (t && n && typeof t == "object" && typeof n == "object") {
50
+ const a = t instanceof Date, r = n instanceof Date;
51
+ if (a && r)
52
+ return t.getTime() == n.getTime();
53
+ if (a != r)
54
+ return !1;
55
+ const u = t instanceof RegExp, h = n instanceof RegExp;
56
+ if (u && h)
57
+ return t.toString() == n.toString();
58
+ if (u != h)
59
+ return !1;
60
+ const l = Object.keys(t);
61
+ for (i = 0; i < l.length; i++)
62
+ if (!Object.prototype.hasOwnProperty.call(n, l[i]))
63
+ return !1;
64
+ for (i = 0; i < l.length; i++)
65
+ if (!D(n[l[i]], t[l[i]]))
66
+ return !1;
67
+ return !0;
68
+ } else if (t && n && typeof t == "function" && typeof n == "function")
69
+ return t.toString() === n.toString();
70
+ return !1;
71
+ }
72
+ class X {
73
+ /** Current input value */
74
+ /** Current cursor position */
75
+ /** Old input value */
76
+ /** Old selection */
77
+ constructor(t) {
78
+ for (Object.assign(this, t); this.value.slice(0, this.startChangePos) !== this.oldValue.slice(0, this.startChangePos); )
79
+ --this.oldSelection.start;
80
+ if (this.insertedCount)
81
+ for (; this.value.slice(this.cursorPos) !== this.oldValue.slice(this.oldSelection.end); )
82
+ this.value.length - this.cursorPos < this.oldValue.length - this.oldSelection.end ? ++this.oldSelection.end : ++this.cursorPos;
83
+ }
84
+ /** Start changing position */
85
+ get startChangePos() {
86
+ return Math.min(this.cursorPos, this.oldSelection.start);
87
+ }
88
+ /** Inserted symbols count */
89
+ get insertedCount() {
90
+ return this.cursorPos - this.startChangePos;
91
+ }
92
+ /** Inserted symbols */
93
+ get inserted() {
94
+ return this.value.substr(this.startChangePos, this.insertedCount);
95
+ }
96
+ /** Removed symbols count */
97
+ get removedCount() {
98
+ return Math.max(this.oldSelection.end - this.startChangePos || // for Delete
99
+ this.oldValue.length - this.value.length, 0);
100
+ }
101
+ /** Removed symbols */
102
+ get removed() {
103
+ return this.oldValue.substr(this.startChangePos, this.removedCount);
104
+ }
105
+ /** Unchanged head symbols */
106
+ get head() {
107
+ return this.value.substring(0, this.startChangePos);
108
+ }
109
+ /** Unchanged tail symbols */
110
+ get tail() {
111
+ return this.value.substring(this.startChangePos + this.insertedCount);
112
+ }
113
+ /** Remove direction */
114
+ get removeDirection() {
115
+ return !this.removedCount || this.insertedCount ? o.NONE : (this.oldSelection.end === this.cursorPos || this.oldSelection.start === this.cursorPos) && // if not range removed (event with backspace)
116
+ this.oldSelection.end === this.oldSelection.start ? o.RIGHT : o.LEFT;
117
+ }
118
+ }
119
+ function p(n, t) {
120
+ return new p.InputMask(n, t);
121
+ }
122
+ function H(n) {
123
+ if (n == null)
124
+ throw new Error("mask property should be defined");
125
+ return n instanceof RegExp ? p.MaskedRegExp : A(n) ? p.MaskedPattern : n === Date ? p.MaskedDate : n === Number ? p.MaskedNumber : Array.isArray(n) || n === Array ? p.MaskedDynamic : p.Masked && n.prototype instanceof p.Masked ? n : p.Masked && n instanceof p.Masked ? n.constructor : n instanceof Function ? p.MaskedFunction : (console.warn("Mask not found for mask", n), p.Masked);
126
+ }
127
+ function x(n) {
128
+ if (!n)
129
+ throw new Error("Options in not defined");
130
+ if (p.Masked) {
131
+ if (n.prototype instanceof p.Masked)
132
+ return {
133
+ mask: n
134
+ };
135
+ const {
136
+ mask: t = void 0,
137
+ ...e
138
+ } = n instanceof p.Masked ? {
139
+ mask: n
140
+ } : L(n) && n.mask instanceof p.Masked ? n : {};
141
+ if (t) {
142
+ const s = t.mask;
143
+ return {
144
+ ...U(t, (i, a) => !a.startsWith("_")),
145
+ mask: t.constructor,
146
+ _mask: s,
147
+ ...e
148
+ };
149
+ }
150
+ }
151
+ return L(n) ? {
152
+ ...n
153
+ } : {
154
+ mask: n
155
+ };
156
+ }
157
+ function C(n) {
158
+ if (p.Masked && n instanceof p.Masked)
159
+ return n;
160
+ const t = x(n), e = H(t.mask);
161
+ if (!e)
162
+ throw new Error("Masked class is not found for provided mask " + t.mask + ", appropriate module needs to be imported manually before creating mask.");
163
+ return t.mask === e && delete t.mask, t._mask && (t.mask = t._mask, delete t._mask), new e(t);
164
+ }
165
+ p.createMask = C;
166
+ class P {
167
+ /** */
168
+ /** */
169
+ /** */
170
+ /** Safely returns selection start */
171
+ get selectionStart() {
172
+ let t;
173
+ try {
174
+ t = this._unsafeSelectionStart;
175
+ } catch {
176
+ }
177
+ return t ?? this.value.length;
178
+ }
179
+ /** Safely returns selection end */
180
+ get selectionEnd() {
181
+ let t;
182
+ try {
183
+ t = this._unsafeSelectionEnd;
184
+ } catch {
185
+ }
186
+ return t ?? this.value.length;
187
+ }
188
+ /** Safely sets element selection */
189
+ select(t, e) {
190
+ if (!(t == null || e == null || t === this.selectionStart && e === this.selectionEnd))
191
+ try {
192
+ this._unsafeSelect(t, e);
193
+ } catch {
194
+ }
195
+ }
196
+ /** */
197
+ get isActive() {
198
+ return !1;
199
+ }
200
+ /** */
201
+ /** */
202
+ /** */
203
+ }
204
+ p.MaskElement = P;
205
+ const N = 90, Z = 89;
206
+ class y extends P {
207
+ /** HTMLElement to use mask on */
208
+ constructor(t) {
209
+ super(), this.input = t, this._onKeydown = this._onKeydown.bind(this), this._onInput = this._onInput.bind(this), this._onBeforeinput = this._onBeforeinput.bind(this), this._onCompositionEnd = this._onCompositionEnd.bind(this);
210
+ }
211
+ get rootElement() {
212
+ var t, e, s;
213
+ return (t = (e = (s = this.input).getRootNode) == null ? void 0 : e.call(s)) != null ? t : document;
214
+ }
215
+ /** Is element in focus */
216
+ get isActive() {
217
+ return this.input === this.rootElement.activeElement;
218
+ }
219
+ /** Binds HTMLElement events to mask internal events */
220
+ bindEvents(t) {
221
+ this.input.addEventListener("keydown", this._onKeydown), this.input.addEventListener("input", this._onInput), this.input.addEventListener("beforeinput", this._onBeforeinput), this.input.addEventListener("compositionend", this._onCompositionEnd), this.input.addEventListener("drop", t.drop), this.input.addEventListener("click", t.click), this.input.addEventListener("focus", t.focus), this.input.addEventListener("blur", t.commit), this._handlers = t;
222
+ }
223
+ _onKeydown(t) {
224
+ if (this._handlers.redo && (t.keyCode === N && t.shiftKey && (t.metaKey || t.ctrlKey) || t.keyCode === Z && t.ctrlKey))
225
+ return t.preventDefault(), this._handlers.redo(t);
226
+ if (this._handlers.undo && t.keyCode === N && (t.metaKey || t.ctrlKey))
227
+ return t.preventDefault(), this._handlers.undo(t);
228
+ t.isComposing || this._handlers.selectionChange(t);
229
+ }
230
+ _onBeforeinput(t) {
231
+ if (t.inputType === "historyUndo" && this._handlers.undo)
232
+ return t.preventDefault(), this._handlers.undo(t);
233
+ if (t.inputType === "historyRedo" && this._handlers.redo)
234
+ return t.preventDefault(), this._handlers.redo(t);
235
+ }
236
+ _onCompositionEnd(t) {
237
+ this._handlers.input(t);
238
+ }
239
+ _onInput(t) {
240
+ t.isComposing || this._handlers.input(t);
241
+ }
242
+ /** Unbinds HTMLElement events to mask internal events */
243
+ unbindEvents() {
244
+ this.input.removeEventListener("keydown", this._onKeydown), this.input.removeEventListener("input", this._onInput), this.input.removeEventListener("beforeinput", this._onBeforeinput), this.input.removeEventListener("compositionend", this._onCompositionEnd), this.input.removeEventListener("drop", this._handlers.drop), this.input.removeEventListener("click", this._handlers.click), this.input.removeEventListener("focus", this._handlers.focus), this.input.removeEventListener("blur", this._handlers.commit), this._handlers = {};
245
+ }
246
+ }
247
+ p.HTMLMaskElement = y;
248
+ class $ extends y {
249
+ /** InputElement to use mask on */
250
+ constructor(t) {
251
+ super(t), this.input = t;
252
+ }
253
+ /** Returns InputElement selection start */
254
+ get _unsafeSelectionStart() {
255
+ return this.input.selectionStart != null ? this.input.selectionStart : this.value.length;
256
+ }
257
+ /** Returns InputElement selection end */
258
+ get _unsafeSelectionEnd() {
259
+ return this.input.selectionEnd;
260
+ }
261
+ /** Sets InputElement selection */
262
+ _unsafeSelect(t, e) {
263
+ this.input.setSelectionRange(t, e);
264
+ }
265
+ get value() {
266
+ return this.input.value;
267
+ }
268
+ set value(t) {
269
+ this.input.value = t;
270
+ }
271
+ }
272
+ p.HTMLMaskElement = y;
273
+ class j extends y {
274
+ /** Returns HTMLElement selection start */
275
+ get _unsafeSelectionStart() {
276
+ const t = this.rootElement, e = t.getSelection && t.getSelection(), s = e && e.anchorOffset, i = e && e.focusOffset;
277
+ return i == null || s == null || s < i ? s : i;
278
+ }
279
+ /** Returns HTMLElement selection end */
280
+ get _unsafeSelectionEnd() {
281
+ const t = this.rootElement, e = t.getSelection && t.getSelection(), s = e && e.anchorOffset, i = e && e.focusOffset;
282
+ return i == null || s == null || s > i ? s : i;
283
+ }
284
+ /** Sets HTMLElement selection */
285
+ _unsafeSelect(t, e) {
286
+ if (!this.rootElement.createRange)
287
+ return;
288
+ const s = this.rootElement.createRange();
289
+ s.setStart(this.input.firstChild || this.input, t), s.setEnd(this.input.lastChild || this.input, e);
290
+ const i = this.rootElement, a = i.getSelection && i.getSelection();
291
+ a && (a.removeAllRanges(), a.addRange(s));
292
+ }
293
+ /** HTMLElement value */
294
+ get value() {
295
+ return this.input.textContent || "";
296
+ }
297
+ set value(t) {
298
+ this.input.textContent = t;
299
+ }
300
+ }
301
+ p.HTMLContenteditableMaskElement = j;
302
+ class I {
303
+ constructor() {
304
+ this.states = [], this.currentIndex = 0;
305
+ }
306
+ get currentState() {
307
+ return this.states[this.currentIndex];
308
+ }
309
+ get isEmpty() {
310
+ return this.states.length === 0;
311
+ }
312
+ push(t) {
313
+ this.currentIndex < this.states.length - 1 && (this.states.length = this.currentIndex + 1), this.states.push(t), this.states.length > I.MAX_LENGTH && this.states.shift(), this.currentIndex = this.states.length - 1;
314
+ }
315
+ go(t) {
316
+ return this.currentIndex = Math.min(Math.max(this.currentIndex + t, 0), this.states.length - 1), this.currentState;
317
+ }
318
+ undo() {
319
+ return this.go(-1);
320
+ }
321
+ redo() {
322
+ return this.go(1);
323
+ }
324
+ clear() {
325
+ this.states.length = 0, this.currentIndex = 0;
326
+ }
327
+ }
328
+ I.MAX_LENGTH = 100;
329
+ class W {
330
+ /**
331
+ View element
332
+ */
333
+ /** Internal {@link Masked} model */
334
+ constructor(t, e) {
335
+ this.el = t instanceof P ? t : t.isContentEditable && t.tagName !== "INPUT" && t.tagName !== "TEXTAREA" ? new j(t) : new $(t), this.masked = C(e), this._listeners = {}, this._value = "", this._unmaskedValue = "", this._rawInputValue = "", this.history = new I(), this._saveSelection = this._saveSelection.bind(this), this._onInput = this._onInput.bind(this), this._onChange = this._onChange.bind(this), this._onDrop = this._onDrop.bind(this), this._onFocus = this._onFocus.bind(this), this._onClick = this._onClick.bind(this), this._onUndo = this._onUndo.bind(this), this._onRedo = this._onRedo.bind(this), this.alignCursor = this.alignCursor.bind(this), this.alignCursorFriendly = this.alignCursorFriendly.bind(this), this._bindEvents(), this.updateValue(), this._onChange();
336
+ }
337
+ maskEquals(t) {
338
+ var e;
339
+ return t == null || ((e = this.masked) == null ? void 0 : e.maskEquals(t));
340
+ }
341
+ /** Masked */
342
+ get mask() {
343
+ return this.masked.mask;
344
+ }
345
+ set mask(t) {
346
+ if (this.maskEquals(t))
347
+ return;
348
+ if (!(t instanceof p.Masked) && this.masked.constructor === H(t)) {
349
+ this.masked.updateOptions({
350
+ mask: t
351
+ });
352
+ return;
353
+ }
354
+ const e = t instanceof p.Masked ? t : C({
355
+ mask: t
356
+ });
357
+ e.unmaskedValue = this.masked.unmaskedValue, this.masked = e;
358
+ }
359
+ /** Raw value */
360
+ get value() {
361
+ return this._value;
362
+ }
363
+ set value(t) {
364
+ this.value !== t && (this.masked.value = t, this.updateControl("auto"));
365
+ }
366
+ /** Unmasked value */
367
+ get unmaskedValue() {
368
+ return this._unmaskedValue;
369
+ }
370
+ set unmaskedValue(t) {
371
+ this.unmaskedValue !== t && (this.masked.unmaskedValue = t, this.updateControl("auto"));
372
+ }
373
+ /** Raw input value */
374
+ get rawInputValue() {
375
+ return this._rawInputValue;
376
+ }
377
+ set rawInputValue(t) {
378
+ this.rawInputValue !== t && (this.masked.rawInputValue = t, this.updateControl(), this.alignCursor());
379
+ }
380
+ /** Typed unmasked value */
381
+ get typedValue() {
382
+ return this.masked.typedValue;
383
+ }
384
+ set typedValue(t) {
385
+ this.masked.typedValueEquals(t) || (this.masked.typedValue = t, this.updateControl("auto"));
386
+ }
387
+ /** Display value */
388
+ get displayValue() {
389
+ return this.masked.displayValue;
390
+ }
391
+ /** Starts listening to element events */
392
+ _bindEvents() {
393
+ this.el.bindEvents({
394
+ selectionChange: this._saveSelection,
395
+ input: this._onInput,
396
+ drop: this._onDrop,
397
+ click: this._onClick,
398
+ focus: this._onFocus,
399
+ commit: this._onChange,
400
+ undo: this._onUndo,
401
+ redo: this._onRedo
402
+ });
403
+ }
404
+ /** Stops listening to element events */
405
+ _unbindEvents() {
406
+ this.el && this.el.unbindEvents();
407
+ }
408
+ /** Fires custom event */
409
+ _fireEvent(t, e) {
410
+ const s = this._listeners[t];
411
+ s && s.forEach((i) => i(e));
412
+ }
413
+ /** Current selection start */
414
+ get selectionStart() {
415
+ return this._cursorChanging ? this._changingCursorPos : this.el.selectionStart;
416
+ }
417
+ /** Current cursor position */
418
+ get cursorPos() {
419
+ return this._cursorChanging ? this._changingCursorPos : this.el.selectionEnd;
420
+ }
421
+ set cursorPos(t) {
422
+ !this.el || !this.el.isActive || (this.el.select(t, t), this._saveSelection());
423
+ }
424
+ /** Stores current selection */
425
+ _saveSelection() {
426
+ this.displayValue !== this.el.value && console.warn("Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly."), this._selection = {
427
+ start: this.selectionStart,
428
+ end: this.cursorPos
429
+ };
430
+ }
431
+ /** Syncronizes model value from view */
432
+ updateValue() {
433
+ this.masked.value = this.el.value, this._value = this.masked.value, this._unmaskedValue = this.masked.unmaskedValue, this._rawInputValue = this.masked.rawInputValue;
434
+ }
435
+ /** Syncronizes view from model value, fires change events */
436
+ updateControl(t) {
437
+ const e = this.masked.unmaskedValue, s = this.masked.value, i = this.masked.rawInputValue, a = this.displayValue, r = this.unmaskedValue !== e || this.value !== s || this._rawInputValue !== i;
438
+ this._unmaskedValue = e, this._value = s, this._rawInputValue = i, this.el.value !== a && (this.el.value = a), t === "auto" ? this.alignCursor() : t != null && (this.cursorPos = t), r && this._fireChangeEvents(), !this._historyChanging && (r || this.history.isEmpty) && this.history.push({
439
+ unmaskedValue: e,
440
+ selection: {
441
+ start: this.selectionStart,
442
+ end: this.cursorPos
443
+ }
444
+ });
445
+ }
446
+ /** Updates options with deep equal check, recreates {@link Masked} model if mask type changes */
447
+ updateOptions(t) {
448
+ const {
449
+ mask: e,
450
+ ...s
451
+ } = t, i = !this.maskEquals(e), a = this.masked.optionsIsChanged(s);
452
+ i && (this.mask = e), a && this.masked.updateOptions(s), (i || a) && this.updateControl();
453
+ }
454
+ /** Updates cursor */
455
+ updateCursor(t) {
456
+ t != null && (this.cursorPos = t, this._delayUpdateCursor(t));
457
+ }
458
+ /** Delays cursor update to support mobile browsers */
459
+ _delayUpdateCursor(t) {
460
+ this._abortUpdateCursor(), this._changingCursorPos = t, this._cursorChanging = setTimeout(() => {
461
+ this.el && (this.cursorPos = this._changingCursorPos, this._abortUpdateCursor());
462
+ }, 10);
463
+ }
464
+ /** Fires custom events */
465
+ _fireChangeEvents() {
466
+ this._fireEvent("accept", this._inputEvent), this.masked.isComplete && this._fireEvent("complete", this._inputEvent);
467
+ }
468
+ /** Aborts delayed cursor update */
469
+ _abortUpdateCursor() {
470
+ this._cursorChanging && (clearTimeout(this._cursorChanging), delete this._cursorChanging);
471
+ }
472
+ /** Aligns cursor to nearest available position */
473
+ alignCursor() {
474
+ this.cursorPos = this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos, o.LEFT));
475
+ }
476
+ /** Aligns cursor only if selection is empty */
477
+ alignCursorFriendly() {
478
+ this.selectionStart === this.cursorPos && this.alignCursor();
479
+ }
480
+ /** Adds listener on custom event */
481
+ on(t, e) {
482
+ return this._listeners[t] || (this._listeners[t] = []), this._listeners[t].push(e), this;
483
+ }
484
+ /** Removes custom event listener */
485
+ off(t, e) {
486
+ if (!this._listeners[t])
487
+ return this;
488
+ if (!e)
489
+ return delete this._listeners[t], this;
490
+ const s = this._listeners[t].indexOf(e);
491
+ return s >= 0 && this._listeners[t].splice(s, 1), this;
492
+ }
493
+ /** Handles view input event */
494
+ _onInput(t) {
495
+ this._inputEvent = t, this._abortUpdateCursor();
496
+ const e = new X({
497
+ // new state
498
+ value: this.el.value,
499
+ cursorPos: this.cursorPos,
500
+ // old state
501
+ oldValue: this.displayValue,
502
+ oldSelection: this._selection
503
+ }), s = this.masked.rawInputValue, i = this.masked.splice(e.startChangePos, e.removed.length, e.inserted, e.removeDirection, {
504
+ input: !0,
505
+ raw: !0
506
+ }).offset, a = s === this.masked.rawInputValue ? e.removeDirection : o.NONE;
507
+ let r = this.masked.nearestInputPos(e.startChangePos + i, a);
508
+ a !== o.NONE && (r = this.masked.nearestInputPos(r, o.NONE)), this.updateControl(r), delete this._inputEvent;
509
+ }
510
+ /** Handles view change event and commits model value */
511
+ _onChange() {
512
+ this.displayValue !== this.el.value && this.updateValue(), this.masked.doCommit(), this.updateControl(), this._saveSelection();
513
+ }
514
+ /** Handles view drop event, prevents by default */
515
+ _onDrop(t) {
516
+ t.preventDefault(), t.stopPropagation();
517
+ }
518
+ /** Restore last selection on focus */
519
+ _onFocus(t) {
520
+ this.alignCursorFriendly();
521
+ }
522
+ /** Restore last selection on focus */
523
+ _onClick(t) {
524
+ this.alignCursorFriendly();
525
+ }
526
+ _onUndo() {
527
+ this._applyHistoryState(this.history.undo());
528
+ }
529
+ _onRedo() {
530
+ this._applyHistoryState(this.history.redo());
531
+ }
532
+ _applyHistoryState(t) {
533
+ t && (this._historyChanging = !0, this.unmaskedValue = t.unmaskedValue, this.el.select(t.selection.start, t.selection.end), this._saveSelection(), this._historyChanging = !1);
534
+ }
535
+ /** Unbind view events and removes element reference */
536
+ destroy() {
537
+ this._unbindEvents(), this._listeners.length = 0, delete this.el;
538
+ }
539
+ }
540
+ p.InputMask = W;
541
+ class d {
542
+ /** Inserted symbols */
543
+ /** Additional offset if any changes occurred before tail */
544
+ /** Raw inserted is used by dynamic mask */
545
+ /** Can skip chars */
546
+ static normalize(t) {
547
+ return Array.isArray(t) ? t : [t, new d()];
548
+ }
549
+ constructor(t) {
550
+ Object.assign(this, {
551
+ inserted: "",
552
+ rawInserted: "",
553
+ tailShift: 0,
554
+ skip: !1
555
+ }, t);
556
+ }
557
+ /** Aggregate changes */
558
+ aggregate(t) {
559
+ return this.inserted += t.inserted, this.rawInserted += t.rawInserted, this.tailShift += t.tailShift, this.skip = this.skip || t.skip, this;
560
+ }
561
+ /** Total offset considering all changes */
562
+ get offset() {
563
+ return this.tailShift + this.inserted.length;
564
+ }
565
+ get consumed() {
566
+ return !!this.rawInserted || this.skip;
567
+ }
568
+ equals(t) {
569
+ return this.inserted === t.inserted && this.tailShift === t.tailShift && this.rawInserted === t.rawInserted && this.skip === t.skip;
570
+ }
571
+ }
572
+ p.ChangeDetails = d;
573
+ class v {
574
+ /** Tail value as string */
575
+ /** Tail start position */
576
+ /** Start position */
577
+ constructor(t, e, s) {
578
+ t === void 0 && (t = ""), e === void 0 && (e = 0), this.value = t, this.from = e, this.stop = s;
579
+ }
580
+ toString() {
581
+ return this.value;
582
+ }
583
+ extend(t) {
584
+ this.value += String(t);
585
+ }
586
+ appendTo(t) {
587
+ return t.append(this.toString(), {
588
+ tail: !0
589
+ }).aggregate(t._appendPlaceholder());
590
+ }
591
+ get state() {
592
+ return {
593
+ value: this.value,
594
+ from: this.from,
595
+ stop: this.stop
596
+ };
597
+ }
598
+ set state(t) {
599
+ Object.assign(this, t);
600
+ }
601
+ unshift(t) {
602
+ if (!this.value.length || t != null && this.from >= t)
603
+ return "";
604
+ const e = this.value[0];
605
+ return this.value = this.value.slice(1), e;
606
+ }
607
+ shift() {
608
+ if (!this.value.length)
609
+ return "";
610
+ const t = this.value[this.value.length - 1];
611
+ return this.value = this.value.slice(0, -1), t;
612
+ }
613
+ }
614
+ class k {
615
+ /** */
616
+ /** */
617
+ /** Transforms value before mask processing */
618
+ /** Transforms each char before mask processing */
619
+ /** Validates if value is acceptable */
620
+ /** Does additional processing at the end of editing */
621
+ /** Format typed value to string */
622
+ /** Parse string to get typed value */
623
+ /** Enable characters overwriting */
624
+ /** */
625
+ /** */
626
+ /** */
627
+ /** */
628
+ constructor(t) {
629
+ this._value = "", this._update({
630
+ ...k.DEFAULTS,
631
+ ...t
632
+ }), this._initialized = !0;
633
+ }
634
+ /** Sets and applies new options */
635
+ updateOptions(t) {
636
+ this.optionsIsChanged(t) && this.withValueRefresh(this._update.bind(this, t));
637
+ }
638
+ /** Sets new options */
639
+ _update(t) {
640
+ Object.assign(this, t);
641
+ }
642
+ /** Mask state */
643
+ get state() {
644
+ return {
645
+ _value: this.value,
646
+ _rawInputValue: this.rawInputValue
647
+ };
648
+ }
649
+ set state(t) {
650
+ this._value = t._value;
651
+ }
652
+ /** Resets value */
653
+ reset() {
654
+ this._value = "";
655
+ }
656
+ get value() {
657
+ return this._value;
658
+ }
659
+ set value(t) {
660
+ this.resolve(t, {
661
+ input: !0
662
+ });
663
+ }
664
+ /** Resolve new value */
665
+ resolve(t, e) {
666
+ e === void 0 && (e = {
667
+ input: !0
668
+ }), this.reset(), this.append(t, e, ""), this.doCommit();
669
+ }
670
+ get unmaskedValue() {
671
+ return this.value;
672
+ }
673
+ set unmaskedValue(t) {
674
+ this.resolve(t, {});
675
+ }
676
+ get typedValue() {
677
+ return this.parse ? this.parse(this.value, this) : this.unmaskedValue;
678
+ }
679
+ set typedValue(t) {
680
+ this.format ? this.value = this.format(t, this) : this.unmaskedValue = String(t);
681
+ }
682
+ /** Value that includes raw user input */
683
+ get rawInputValue() {
684
+ return this.extractInput(0, this.displayValue.length, {
685
+ raw: !0
686
+ });
687
+ }
688
+ set rawInputValue(t) {
689
+ this.resolve(t, {
690
+ raw: !0
691
+ });
692
+ }
693
+ get displayValue() {
694
+ return this.value;
695
+ }
696
+ get isComplete() {
697
+ return !0;
698
+ }
699
+ get isFilled() {
700
+ return this.isComplete;
701
+ }
702
+ /** Finds nearest input position in direction */
703
+ nearestInputPos(t, e) {
704
+ return t;
705
+ }
706
+ totalInputPositions(t, e) {
707
+ return t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), Math.min(this.displayValue.length, e - t);
708
+ }
709
+ /** Extracts value in range considering flags */
710
+ extractInput(t, e, s) {
711
+ return t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), this.displayValue.slice(t, e);
712
+ }
713
+ /** Extracts tail in range */
714
+ extractTail(t, e) {
715
+ return t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), new v(this.extractInput(t, e), t);
716
+ }
717
+ /** Appends tail */
718
+ appendTail(t) {
719
+ return A(t) && (t = new v(String(t))), t.appendTo(this);
720
+ }
721
+ /** Appends char */
722
+ _appendCharRaw(t, e) {
723
+ return t ? (this._value += t, new d({
724
+ inserted: t,
725
+ rawInserted: t
726
+ })) : new d();
727
+ }
728
+ /** Appends char */
729
+ _appendChar(t, e, s) {
730
+ e === void 0 && (e = {});
731
+ const i = this.state;
732
+ let a;
733
+ if ([t, a] = this.doPrepareChar(t, e), t && (a = a.aggregate(this._appendCharRaw(t, e)), !a.rawInserted && this.autofix === "pad")) {
734
+ const r = this.state;
735
+ this.state = i;
736
+ let u = this.pad(e);
737
+ const h = this._appendCharRaw(t, e);
738
+ u = u.aggregate(h), h.rawInserted || u.equals(a) ? a = u : this.state = r;
739
+ }
740
+ if (a.inserted) {
741
+ let r, u = this.doValidate(e) !== !1;
742
+ if (u && s != null) {
743
+ const h = this.state;
744
+ if (this.overwrite === !0) {
745
+ r = s.state;
746
+ for (let c = 0; c < a.rawInserted.length; ++c)
747
+ s.unshift(this.displayValue.length - a.tailShift);
748
+ }
749
+ let l = this.appendTail(s);
750
+ if (u = l.rawInserted.length === s.toString().length, !(u && l.inserted) && this.overwrite === "shift") {
751
+ this.state = h, r = s.state;
752
+ for (let c = 0; c < a.rawInserted.length; ++c)
753
+ s.shift();
754
+ l = this.appendTail(s), u = l.rawInserted.length === s.toString().length;
755
+ }
756
+ u && l.inserted && (this.state = h);
757
+ }
758
+ u || (a = new d(), this.state = i, s && r && (s.state = r));
759
+ }
760
+ return a;
761
+ }
762
+ /** Appends optional placeholder at the end */
763
+ _appendPlaceholder() {
764
+ return new d();
765
+ }
766
+ /** Appends optional eager placeholder at the end */
767
+ _appendEager() {
768
+ return new d();
769
+ }
770
+ /** Appends symbols considering flags */
771
+ append(t, e, s) {
772
+ if (!A(t))
773
+ throw new Error("value should be string");
774
+ const i = A(s) ? new v(String(s)) : s;
775
+ e != null && e.tail && (e._beforeTailState = this.state);
776
+ let a;
777
+ [t, a] = this.doPrepare(t, e);
778
+ for (let r = 0; r < t.length; ++r) {
779
+ const u = this._appendChar(t[r], e, i);
780
+ if (!u.rawInserted && !this.doSkipInvalid(t[r], e, i))
781
+ break;
782
+ a.aggregate(u);
783
+ }
784
+ return (this.eager === !0 || this.eager === "append") && e != null && e.input && t && a.aggregate(this._appendEager()), i != null && (a.tailShift += this.appendTail(i).tailShift), a;
785
+ }
786
+ remove(t, e) {
787
+ return t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), this._value = this.displayValue.slice(0, t) + this.displayValue.slice(e), new d();
788
+ }
789
+ /** Calls function and reapplies current value */
790
+ withValueRefresh(t) {
791
+ if (this._refreshing || !this._initialized)
792
+ return t();
793
+ this._refreshing = !0;
794
+ const e = this.rawInputValue, s = this.value, i = t();
795
+ return this.rawInputValue = e, this.value && this.value !== s && s.indexOf(this.value) === 0 && (this.append(s.slice(this.displayValue.length), {}, ""), this.doCommit()), delete this._refreshing, i;
796
+ }
797
+ runIsolated(t) {
798
+ if (this._isolated || !this._initialized)
799
+ return t(this);
800
+ this._isolated = !0;
801
+ const e = this.state, s = t(this);
802
+ return this.state = e, delete this._isolated, s;
803
+ }
804
+ doSkipInvalid(t, e, s) {
805
+ return !!this.skipInvalid;
806
+ }
807
+ /** Prepares string before mask processing */
808
+ doPrepare(t, e) {
809
+ return e === void 0 && (e = {}), d.normalize(this.prepare ? this.prepare(t, this, e) : t);
810
+ }
811
+ /** Prepares each char before mask processing */
812
+ doPrepareChar(t, e) {
813
+ return e === void 0 && (e = {}), d.normalize(this.prepareChar ? this.prepareChar(t, this, e) : t);
814
+ }
815
+ /** Validates if value is acceptable */
816
+ doValidate(t) {
817
+ return (!this.validate || this.validate(this.value, this, t)) && (!this.parent || this.parent.doValidate(t));
818
+ }
819
+ /** Does additional processing at the end of editing */
820
+ doCommit() {
821
+ this.commit && this.commit(this.value, this);
822
+ }
823
+ splice(t, e, s, i, a) {
824
+ s === void 0 && (s = ""), i === void 0 && (i = o.NONE), a === void 0 && (a = {
825
+ input: !0
826
+ });
827
+ const r = t + e, u = this.extractTail(r), h = this.eager === !0 || this.eager === "remove";
828
+ let l;
829
+ h && (i = Y(i), l = this.extractInput(0, r, {
830
+ raw: !0
831
+ }));
832
+ let c = t;
833
+ const g = new d();
834
+ if (i !== o.NONE && (c = this.nearestInputPos(t, e > 1 && t !== 0 && !h ? o.NONE : i), g.tailShift = c - t), g.aggregate(this.remove(c)), h && i !== o.NONE && l === this.rawInputValue)
835
+ if (i === o.FORCE_LEFT) {
836
+ let f;
837
+ for (; l === this.rawInputValue && (f = this.displayValue.length); )
838
+ g.aggregate(new d({
839
+ tailShift: -1
840
+ })).aggregate(this.remove(f - 1));
841
+ } else
842
+ i === o.FORCE_RIGHT && u.unshift();
843
+ return g.aggregate(this.append(s, a, u));
844
+ }
845
+ maskEquals(t) {
846
+ return this.mask === t;
847
+ }
848
+ optionsIsChanged(t) {
849
+ return !D(this, t);
850
+ }
851
+ typedValueEquals(t) {
852
+ const e = this.typedValue;
853
+ return t === e || k.EMPTY_VALUES.includes(t) && k.EMPTY_VALUES.includes(e) || (this.format ? this.format(t, this) === this.format(this.typedValue, this) : !1);
854
+ }
855
+ pad(t) {
856
+ return new d();
857
+ }
858
+ }
859
+ k.DEFAULTS = {
860
+ skipInvalid: !0
861
+ };
862
+ k.EMPTY_VALUES = [void 0, null, ""];
863
+ p.Masked = k;
864
+ class F {
865
+ /** */
866
+ constructor(t, e) {
867
+ t === void 0 && (t = []), e === void 0 && (e = 0), this.chunks = t, this.from = e;
868
+ }
869
+ toString() {
870
+ return this.chunks.map(String).join("");
871
+ }
872
+ extend(t) {
873
+ if (!String(t))
874
+ return;
875
+ t = A(t) ? new v(String(t)) : t;
876
+ const e = this.chunks[this.chunks.length - 1], s = e && // if stops are same or tail has no stop
877
+ (e.stop === t.stop || t.stop == null) && // if tail chunk goes just after last chunk
878
+ t.from === e.from + e.toString().length;
879
+ if (t instanceof v)
880
+ s ? e.extend(t.toString()) : this.chunks.push(t);
881
+ else if (t instanceof F) {
882
+ if (t.stop == null) {
883
+ let i;
884
+ for (; t.chunks.length && t.chunks[0].stop == null; )
885
+ i = t.chunks.shift(), i.from += t.from, this.extend(i);
886
+ }
887
+ t.toString() && (t.stop = t.blockIndex, this.chunks.push(t));
888
+ }
889
+ }
890
+ appendTo(t) {
891
+ if (!(t instanceof p.MaskedPattern))
892
+ return new v(this.toString()).appendTo(t);
893
+ const e = new d();
894
+ for (let s = 0; s < this.chunks.length; ++s) {
895
+ const i = this.chunks[s], a = t._mapPosToBlock(t.displayValue.length), r = i.stop;
896
+ let u;
897
+ if (r != null && // if block not found or stop is behind lastBlock
898
+ (!a || a.index <= r) && ((i instanceof F || // for continuous block also check if stop is exist
899
+ t._stops.indexOf(r) >= 0) && e.aggregate(t._appendPlaceholder(r)), u = i instanceof F && t._blocks[r]), u) {
900
+ const h = u.appendTail(i);
901
+ e.aggregate(h);
902
+ const l = i.toString().slice(h.rawInserted.length);
903
+ l && e.aggregate(t.append(l, {
904
+ tail: !0
905
+ }));
906
+ } else
907
+ e.aggregate(t.append(i.toString(), {
908
+ tail: !0
909
+ }));
910
+ }
911
+ return e;
912
+ }
913
+ get state() {
914
+ return {
915
+ chunks: this.chunks.map((t) => t.state),
916
+ from: this.from,
917
+ stop: this.stop,
918
+ blockIndex: this.blockIndex
919
+ };
920
+ }
921
+ set state(t) {
922
+ const {
923
+ chunks: e,
924
+ ...s
925
+ } = t;
926
+ Object.assign(this, s), this.chunks = e.map((i) => {
927
+ const a = "chunks" in i ? new F() : new v();
928
+ return a.state = i, a;
929
+ });
930
+ }
931
+ unshift(t) {
932
+ if (!this.chunks.length || t != null && this.from >= t)
933
+ return "";
934
+ const e = t != null ? t - this.from : t;
935
+ let s = 0;
936
+ for (; s < this.chunks.length; ) {
937
+ const i = this.chunks[s], a = i.unshift(e);
938
+ if (i.toString()) {
939
+ if (!a)
940
+ break;
941
+ ++s;
942
+ } else
943
+ this.chunks.splice(s, 1);
944
+ if (a)
945
+ return a;
946
+ }
947
+ return "";
948
+ }
949
+ shift() {
950
+ if (!this.chunks.length)
951
+ return "";
952
+ let t = this.chunks.length - 1;
953
+ for (; 0 <= t; ) {
954
+ const e = this.chunks[t], s = e.shift();
955
+ if (e.toString()) {
956
+ if (!s)
957
+ break;
958
+ --t;
959
+ } else
960
+ this.chunks.splice(t, 1);
961
+ if (s)
962
+ return s;
963
+ }
964
+ return "";
965
+ }
966
+ }
967
+ class J {
968
+ constructor(t, e) {
969
+ this.masked = t, this._log = [];
970
+ const {
971
+ offset: s,
972
+ index: i
973
+ } = t._mapPosToBlock(e) || (e < 0 ? (
974
+ // first
975
+ {
976
+ index: 0,
977
+ offset: 0
978
+ }
979
+ ) : (
980
+ // last
981
+ {
982
+ index: this.masked._blocks.length,
983
+ offset: 0
984
+ }
985
+ ));
986
+ this.offset = s, this.index = i, this.ok = !1;
987
+ }
988
+ get block() {
989
+ return this.masked._blocks[this.index];
990
+ }
991
+ get pos() {
992
+ return this.masked._blockStartPos(this.index) + this.offset;
993
+ }
994
+ get state() {
995
+ return {
996
+ index: this.index,
997
+ offset: this.offset,
998
+ ok: this.ok
999
+ };
1000
+ }
1001
+ set state(t) {
1002
+ Object.assign(this, t);
1003
+ }
1004
+ pushState() {
1005
+ this._log.push(this.state);
1006
+ }
1007
+ popState() {
1008
+ const t = this._log.pop();
1009
+ return t && (this.state = t), t;
1010
+ }
1011
+ bindBlock() {
1012
+ this.block || (this.index < 0 && (this.index = 0, this.offset = 0), this.index >= this.masked._blocks.length && (this.index = this.masked._blocks.length - 1, this.offset = this.block.displayValue.length));
1013
+ }
1014
+ _pushLeft(t) {
1015
+ for (this.pushState(), this.bindBlock(); 0 <= this.index; --this.index, this.offset = ((e = this.block) == null ? void 0 : e.displayValue.length) || 0) {
1016
+ var e;
1017
+ if (t())
1018
+ return this.ok = !0;
1019
+ }
1020
+ return this.ok = !1;
1021
+ }
1022
+ _pushRight(t) {
1023
+ for (this.pushState(), this.bindBlock(); this.index < this.masked._blocks.length; ++this.index, this.offset = 0)
1024
+ if (t())
1025
+ return this.ok = !0;
1026
+ return this.ok = !1;
1027
+ }
1028
+ pushLeftBeforeFilled() {
1029
+ return this._pushLeft(() => {
1030
+ if (!(this.block.isFixed || !this.block.value) && (this.offset = this.block.nearestInputPos(this.offset, o.FORCE_LEFT), this.offset !== 0))
1031
+ return !0;
1032
+ });
1033
+ }
1034
+ pushLeftBeforeInput() {
1035
+ return this._pushLeft(() => {
1036
+ if (!this.block.isFixed)
1037
+ return this.offset = this.block.nearestInputPos(this.offset, o.LEFT), !0;
1038
+ });
1039
+ }
1040
+ pushLeftBeforeRequired() {
1041
+ return this._pushLeft(() => {
1042
+ if (!(this.block.isFixed || this.block.isOptional && !this.block.value))
1043
+ return this.offset = this.block.nearestInputPos(this.offset, o.LEFT), !0;
1044
+ });
1045
+ }
1046
+ pushRightBeforeFilled() {
1047
+ return this._pushRight(() => {
1048
+ if (!(this.block.isFixed || !this.block.value) && (this.offset = this.block.nearestInputPos(this.offset, o.FORCE_RIGHT), this.offset !== this.block.value.length))
1049
+ return !0;
1050
+ });
1051
+ }
1052
+ pushRightBeforeInput() {
1053
+ return this._pushRight(() => {
1054
+ if (!this.block.isFixed)
1055
+ return this.offset = this.block.nearestInputPos(this.offset, o.NONE), !0;
1056
+ });
1057
+ }
1058
+ pushRightBeforeRequired() {
1059
+ return this._pushRight(() => {
1060
+ if (!(this.block.isFixed || this.block.isOptional && !this.block.value))
1061
+ return this.offset = this.block.nearestInputPos(this.offset, o.NONE), !0;
1062
+ });
1063
+ }
1064
+ }
1065
+ class G {
1066
+ /** */
1067
+ /** */
1068
+ /** */
1069
+ /** */
1070
+ /** */
1071
+ /** */
1072
+ constructor(t) {
1073
+ Object.assign(this, t), this._value = "", this.isFixed = !0;
1074
+ }
1075
+ get value() {
1076
+ return this._value;
1077
+ }
1078
+ get unmaskedValue() {
1079
+ return this.isUnmasking ? this.value : "";
1080
+ }
1081
+ get rawInputValue() {
1082
+ return this._isRawInput ? this.value : "";
1083
+ }
1084
+ get displayValue() {
1085
+ return this.value;
1086
+ }
1087
+ reset() {
1088
+ this._isRawInput = !1, this._value = "";
1089
+ }
1090
+ remove(t, e) {
1091
+ return t === void 0 && (t = 0), e === void 0 && (e = this._value.length), this._value = this._value.slice(0, t) + this._value.slice(e), this._value || (this._isRawInput = !1), new d();
1092
+ }
1093
+ nearestInputPos(t, e) {
1094
+ e === void 0 && (e = o.NONE);
1095
+ const s = 0, i = this._value.length;
1096
+ switch (e) {
1097
+ case o.LEFT:
1098
+ case o.FORCE_LEFT:
1099
+ return s;
1100
+ case o.NONE:
1101
+ case o.RIGHT:
1102
+ case o.FORCE_RIGHT:
1103
+ default:
1104
+ return i;
1105
+ }
1106
+ }
1107
+ totalInputPositions(t, e) {
1108
+ return t === void 0 && (t = 0), e === void 0 && (e = this._value.length), this._isRawInput ? e - t : 0;
1109
+ }
1110
+ extractInput(t, e, s) {
1111
+ return t === void 0 && (t = 0), e === void 0 && (e = this._value.length), s === void 0 && (s = {}), s.raw && this._isRawInput && this._value.slice(t, e) || "";
1112
+ }
1113
+ get isComplete() {
1114
+ return !0;
1115
+ }
1116
+ get isFilled() {
1117
+ return !!this._value;
1118
+ }
1119
+ _appendChar(t, e) {
1120
+ if (e === void 0 && (e = {}), this.isFilled)
1121
+ return new d();
1122
+ const s = this.eager === !0 || this.eager === "append", i = this.char === t && (this.isUnmasking || e.input || e.raw) && (!e.raw || !s) && !e.tail, a = new d({
1123
+ inserted: this.char,
1124
+ rawInserted: i ? this.char : ""
1125
+ });
1126
+ return this._value = this.char, this._isRawInput = i && (e.raw || e.input), a;
1127
+ }
1128
+ _appendEager() {
1129
+ return this._appendChar(this.char, {
1130
+ tail: !0
1131
+ });
1132
+ }
1133
+ _appendPlaceholder() {
1134
+ const t = new d();
1135
+ return this.isFilled || (this._value = t.inserted = this.char), t;
1136
+ }
1137
+ extractTail() {
1138
+ return new v("");
1139
+ }
1140
+ appendTail(t) {
1141
+ return A(t) && (t = new v(String(t))), t.appendTo(this);
1142
+ }
1143
+ append(t, e, s) {
1144
+ const i = this._appendChar(t[0], e);
1145
+ return s != null && (i.tailShift += this.appendTail(s).tailShift), i;
1146
+ }
1147
+ doCommit() {
1148
+ }
1149
+ get state() {
1150
+ return {
1151
+ _value: this._value,
1152
+ _rawInputValue: this.rawInputValue
1153
+ };
1154
+ }
1155
+ set state(t) {
1156
+ this._value = t._value, this._isRawInput = !!t._rawInputValue;
1157
+ }
1158
+ pad(t) {
1159
+ return this._appendPlaceholder();
1160
+ }
1161
+ }
1162
+ class b {
1163
+ /** */
1164
+ /** */
1165
+ /** */
1166
+ /** */
1167
+ /** */
1168
+ /** */
1169
+ /** */
1170
+ /** */
1171
+ constructor(t) {
1172
+ const {
1173
+ parent: e,
1174
+ isOptional: s,
1175
+ placeholderChar: i,
1176
+ displayChar: a,
1177
+ lazy: r,
1178
+ eager: u,
1179
+ ...h
1180
+ } = t;
1181
+ this.masked = C(h), Object.assign(this, {
1182
+ parent: e,
1183
+ isOptional: s,
1184
+ placeholderChar: i,
1185
+ displayChar: a,
1186
+ lazy: r,
1187
+ eager: u
1188
+ });
1189
+ }
1190
+ reset() {
1191
+ this.isFilled = !1, this.masked.reset();
1192
+ }
1193
+ remove(t, e) {
1194
+ return t === void 0 && (t = 0), e === void 0 && (e = this.value.length), t === 0 && e >= 1 ? (this.isFilled = !1, this.masked.remove(t, e)) : new d();
1195
+ }
1196
+ get value() {
1197
+ return this.masked.value || (this.isFilled && !this.isOptional ? this.placeholderChar : "");
1198
+ }
1199
+ get unmaskedValue() {
1200
+ return this.masked.unmaskedValue;
1201
+ }
1202
+ get rawInputValue() {
1203
+ return this.masked.rawInputValue;
1204
+ }
1205
+ get displayValue() {
1206
+ return this.masked.value && this.displayChar || this.value;
1207
+ }
1208
+ get isComplete() {
1209
+ return !!this.masked.value || this.isOptional;
1210
+ }
1211
+ _appendChar(t, e) {
1212
+ if (e === void 0 && (e = {}), this.isFilled)
1213
+ return new d();
1214
+ const s = this.masked.state;
1215
+ let i = this.masked._appendChar(t, this.currentMaskFlags(e));
1216
+ return i.inserted && this.doValidate(e) === !1 && (i = new d(), this.masked.state = s), !i.inserted && !this.isOptional && !this.lazy && !e.input && (i.inserted = this.placeholderChar), i.skip = !i.inserted && !this.isOptional, this.isFilled = !!i.inserted, i;
1217
+ }
1218
+ append(t, e, s) {
1219
+ return this.masked.append(t, this.currentMaskFlags(e), s);
1220
+ }
1221
+ _appendPlaceholder() {
1222
+ return this.isFilled || this.isOptional ? new d() : (this.isFilled = !0, new d({
1223
+ inserted: this.placeholderChar
1224
+ }));
1225
+ }
1226
+ _appendEager() {
1227
+ return new d();
1228
+ }
1229
+ extractTail(t, e) {
1230
+ return this.masked.extractTail(t, e);
1231
+ }
1232
+ appendTail(t) {
1233
+ return this.masked.appendTail(t);
1234
+ }
1235
+ extractInput(t, e, s) {
1236
+ return t === void 0 && (t = 0), e === void 0 && (e = this.value.length), this.masked.extractInput(t, e, s);
1237
+ }
1238
+ nearestInputPos(t, e) {
1239
+ e === void 0 && (e = o.NONE);
1240
+ const s = 0, i = this.value.length, a = Math.min(Math.max(t, s), i);
1241
+ switch (e) {
1242
+ case o.LEFT:
1243
+ case o.FORCE_LEFT:
1244
+ return this.isComplete ? a : s;
1245
+ case o.RIGHT:
1246
+ case o.FORCE_RIGHT:
1247
+ return this.isComplete ? a : i;
1248
+ case o.NONE:
1249
+ default:
1250
+ return a;
1251
+ }
1252
+ }
1253
+ totalInputPositions(t, e) {
1254
+ return t === void 0 && (t = 0), e === void 0 && (e = this.value.length), this.value.slice(t, e).length;
1255
+ }
1256
+ doValidate(t) {
1257
+ return this.masked.doValidate(this.currentMaskFlags(t)) && (!this.parent || this.parent.doValidate(this.currentMaskFlags(t)));
1258
+ }
1259
+ doCommit() {
1260
+ this.masked.doCommit();
1261
+ }
1262
+ get state() {
1263
+ return {
1264
+ _value: this.value,
1265
+ _rawInputValue: this.rawInputValue,
1266
+ masked: this.masked.state,
1267
+ isFilled: this.isFilled
1268
+ };
1269
+ }
1270
+ set state(t) {
1271
+ this.masked.state = t.masked, this.isFilled = t.isFilled;
1272
+ }
1273
+ currentMaskFlags(t) {
1274
+ var e;
1275
+ return {
1276
+ ...t,
1277
+ _beforeTailState: (t == null || (e = t._beforeTailState) == null ? void 0 : e.masked) || (t == null ? void 0 : t._beforeTailState)
1278
+ };
1279
+ }
1280
+ pad(t) {
1281
+ return new d();
1282
+ }
1283
+ }
1284
+ b.DEFAULT_DEFINITIONS = {
1285
+ 0: /\d/,
1286
+ a: /[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,
1287
+ // http://stackoverflow.com/a/22075070
1288
+ "*": /./
1289
+ };
1290
+ class Q extends k {
1291
+ /** */
1292
+ /** Enable characters overwriting */
1293
+ /** */
1294
+ /** */
1295
+ /** */
1296
+ updateOptions(t) {
1297
+ super.updateOptions(t);
1298
+ }
1299
+ _update(t) {
1300
+ const e = t.mask;
1301
+ e && (t.validate = (s) => s.search(e) >= 0), super._update(t);
1302
+ }
1303
+ }
1304
+ p.MaskedRegExp = Q;
1305
+ class m extends k {
1306
+ /** */
1307
+ /** */
1308
+ /** Single char for empty input */
1309
+ /** Single char for filled input */
1310
+ /** Show placeholder only when needed */
1311
+ /** Enable characters overwriting */
1312
+ /** */
1313
+ /** */
1314
+ /** */
1315
+ constructor(t) {
1316
+ super({
1317
+ ...m.DEFAULTS,
1318
+ ...t,
1319
+ definitions: Object.assign({}, b.DEFAULT_DEFINITIONS, t == null ? void 0 : t.definitions)
1320
+ });
1321
+ }
1322
+ updateOptions(t) {
1323
+ super.updateOptions(t);
1324
+ }
1325
+ _update(t) {
1326
+ t.definitions = Object.assign({}, this.definitions, t.definitions), super._update(t), this._rebuildMask();
1327
+ }
1328
+ _rebuildMask() {
1329
+ const t = this.definitions;
1330
+ this._blocks = [], this.exposeBlock = void 0, this._stops = [], this._maskedBlocks = {};
1331
+ const e = this.mask;
1332
+ if (!e || !t)
1333
+ return;
1334
+ let s = !1, i = !1;
1335
+ for (let a = 0; a < e.length; ++a) {
1336
+ if (this.blocks) {
1337
+ const l = e.slice(a), c = Object.keys(this.blocks).filter((f) => l.indexOf(f) === 0);
1338
+ c.sort((f, S) => S.length - f.length);
1339
+ const g = c[0];
1340
+ if (g) {
1341
+ const {
1342
+ expose: f,
1343
+ repeat: S,
1344
+ ...K
1345
+ } = x(this.blocks[g]), O = {
1346
+ lazy: this.lazy,
1347
+ eager: this.eager,
1348
+ placeholderChar: this.placeholderChar,
1349
+ displayChar: this.displayChar,
1350
+ overwrite: this.overwrite,
1351
+ autofix: this.autofix,
1352
+ ...K,
1353
+ repeat: S,
1354
+ parent: this
1355
+ }, T = S != null ? new p.RepeatBlock(
1356
+ O
1357
+ /* TODO */
1358
+ ) : C(O);
1359
+ T && (this._blocks.push(T), f && (this.exposeBlock = T), this._maskedBlocks[g] || (this._maskedBlocks[g] = []), this._maskedBlocks[g].push(this._blocks.length - 1)), a += g.length - 1;
1360
+ continue;
1361
+ }
1362
+ }
1363
+ let r = e[a], u = r in t;
1364
+ if (r === m.STOP_CHAR) {
1365
+ this._stops.push(this._blocks.length);
1366
+ continue;
1367
+ }
1368
+ if (r === "{" || r === "}") {
1369
+ s = !s;
1370
+ continue;
1371
+ }
1372
+ if (r === "[" || r === "]") {
1373
+ i = !i;
1374
+ continue;
1375
+ }
1376
+ if (r === m.ESCAPE_CHAR) {
1377
+ if (++a, r = e[a], !r)
1378
+ break;
1379
+ u = !1;
1380
+ }
1381
+ const h = u ? new b({
1382
+ isOptional: i,
1383
+ lazy: this.lazy,
1384
+ eager: this.eager,
1385
+ placeholderChar: this.placeholderChar,
1386
+ displayChar: this.displayChar,
1387
+ ...x(t[r]),
1388
+ parent: this
1389
+ }) : new G({
1390
+ char: r,
1391
+ eager: this.eager,
1392
+ isUnmasking: s
1393
+ });
1394
+ this._blocks.push(h);
1395
+ }
1396
+ }
1397
+ get state() {
1398
+ return {
1399
+ ...super.state,
1400
+ _blocks: this._blocks.map((t) => t.state)
1401
+ };
1402
+ }
1403
+ set state(t) {
1404
+ if (!t) {
1405
+ this.reset();
1406
+ return;
1407
+ }
1408
+ const {
1409
+ _blocks: e,
1410
+ ...s
1411
+ } = t;
1412
+ this._blocks.forEach((i, a) => i.state = e[a]), super.state = s;
1413
+ }
1414
+ reset() {
1415
+ super.reset(), this._blocks.forEach((t) => t.reset());
1416
+ }
1417
+ get isComplete() {
1418
+ return this.exposeBlock ? this.exposeBlock.isComplete : this._blocks.every((t) => t.isComplete);
1419
+ }
1420
+ get isFilled() {
1421
+ return this._blocks.every((t) => t.isFilled);
1422
+ }
1423
+ get isFixed() {
1424
+ return this._blocks.every((t) => t.isFixed);
1425
+ }
1426
+ get isOptional() {
1427
+ return this._blocks.every((t) => t.isOptional);
1428
+ }
1429
+ doCommit() {
1430
+ this._blocks.forEach((t) => t.doCommit()), super.doCommit();
1431
+ }
1432
+ get unmaskedValue() {
1433
+ return this.exposeBlock ? this.exposeBlock.unmaskedValue : this._blocks.reduce((t, e) => t += e.unmaskedValue, "");
1434
+ }
1435
+ set unmaskedValue(t) {
1436
+ if (this.exposeBlock) {
1437
+ const e = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
1438
+ this.exposeBlock.unmaskedValue = t, this.appendTail(e), this.doCommit();
1439
+ } else
1440
+ super.unmaskedValue = t;
1441
+ }
1442
+ get value() {
1443
+ return this.exposeBlock ? this.exposeBlock.value : (
1444
+ // TODO return _value when not in change?
1445
+ this._blocks.reduce((t, e) => t += e.value, "")
1446
+ );
1447
+ }
1448
+ set value(t) {
1449
+ if (this.exposeBlock) {
1450
+ const e = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
1451
+ this.exposeBlock.value = t, this.appendTail(e), this.doCommit();
1452
+ } else
1453
+ super.value = t;
1454
+ }
1455
+ get typedValue() {
1456
+ return this.exposeBlock ? this.exposeBlock.typedValue : super.typedValue;
1457
+ }
1458
+ set typedValue(t) {
1459
+ if (this.exposeBlock) {
1460
+ const e = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
1461
+ this.exposeBlock.typedValue = t, this.appendTail(e), this.doCommit();
1462
+ } else
1463
+ super.typedValue = t;
1464
+ }
1465
+ get displayValue() {
1466
+ return this._blocks.reduce((t, e) => t += e.displayValue, "");
1467
+ }
1468
+ appendTail(t) {
1469
+ return super.appendTail(t).aggregate(this._appendPlaceholder());
1470
+ }
1471
+ _appendEager() {
1472
+ var t;
1473
+ const e = new d();
1474
+ let s = (t = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : t.index;
1475
+ if (s == null)
1476
+ return e;
1477
+ this._blocks[s].isFilled && ++s;
1478
+ for (let i = s; i < this._blocks.length; ++i) {
1479
+ const a = this._blocks[i]._appendEager();
1480
+ if (!a.inserted)
1481
+ break;
1482
+ e.aggregate(a);
1483
+ }
1484
+ return e;
1485
+ }
1486
+ _appendCharRaw(t, e) {
1487
+ e === void 0 && (e = {});
1488
+ const s = this._mapPosToBlock(this.displayValue.length), i = new d();
1489
+ if (!s)
1490
+ return i;
1491
+ for (let r = s.index, u; u = this._blocks[r]; ++r) {
1492
+ var a;
1493
+ const h = u._appendChar(t, {
1494
+ ...e,
1495
+ _beforeTailState: (a = e._beforeTailState) == null || (a = a._blocks) == null ? void 0 : a[r]
1496
+ });
1497
+ if (i.aggregate(h), h.consumed)
1498
+ break;
1499
+ }
1500
+ return i;
1501
+ }
1502
+ extractTail(t, e) {
1503
+ t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length);
1504
+ const s = new F();
1505
+ return t === e || this._forEachBlocksInRange(t, e, (i, a, r, u) => {
1506
+ const h = i.extractTail(r, u);
1507
+ h.stop = this._findStopBefore(a), h.from = this._blockStartPos(a), h instanceof F && (h.blockIndex = a), s.extend(h);
1508
+ }), s;
1509
+ }
1510
+ extractInput(t, e, s) {
1511
+ if (t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), s === void 0 && (s = {}), t === e)
1512
+ return "";
1513
+ let i = "";
1514
+ return this._forEachBlocksInRange(t, e, (a, r, u, h) => {
1515
+ i += a.extractInput(u, h, s);
1516
+ }), i;
1517
+ }
1518
+ _findStopBefore(t) {
1519
+ let e;
1520
+ for (let s = 0; s < this._stops.length; ++s) {
1521
+ const i = this._stops[s];
1522
+ if (i <= t)
1523
+ e = i;
1524
+ else
1525
+ break;
1526
+ }
1527
+ return e;
1528
+ }
1529
+ /** Appends placeholder depending on laziness */
1530
+ _appendPlaceholder(t) {
1531
+ const e = new d();
1532
+ if (this.lazy && t == null)
1533
+ return e;
1534
+ const s = this._mapPosToBlock(this.displayValue.length);
1535
+ if (!s)
1536
+ return e;
1537
+ const i = s.index, a = t ?? this._blocks.length;
1538
+ return this._blocks.slice(i, a).forEach((r) => {
1539
+ if (!r.lazy || t != null) {
1540
+ var u;
1541
+ e.aggregate(r._appendPlaceholder((u = r._blocks) == null ? void 0 : u.length));
1542
+ }
1543
+ }), e;
1544
+ }
1545
+ /** Finds block in pos */
1546
+ _mapPosToBlock(t) {
1547
+ let e = "";
1548
+ for (let s = 0; s < this._blocks.length; ++s) {
1549
+ const i = this._blocks[s], a = e.length;
1550
+ if (e += i.displayValue, t <= e.length)
1551
+ return {
1552
+ index: s,
1553
+ offset: t - a
1554
+ };
1555
+ }
1556
+ }
1557
+ _blockStartPos(t) {
1558
+ return this._blocks.slice(0, t).reduce((e, s) => e += s.displayValue.length, 0);
1559
+ }
1560
+ _forEachBlocksInRange(t, e, s) {
1561
+ e === void 0 && (e = this.displayValue.length);
1562
+ const i = this._mapPosToBlock(t);
1563
+ if (i) {
1564
+ const a = this._mapPosToBlock(e), r = a && i.index === a.index, u = i.offset, h = a && r ? a.offset : this._blocks[i.index].displayValue.length;
1565
+ if (s(this._blocks[i.index], i.index, u, h), a && !r) {
1566
+ for (let l = i.index + 1; l < a.index; ++l)
1567
+ s(this._blocks[l], l, 0, this._blocks[l].displayValue.length);
1568
+ s(this._blocks[a.index], a.index, 0, a.offset);
1569
+ }
1570
+ }
1571
+ }
1572
+ remove(t, e) {
1573
+ t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length);
1574
+ const s = super.remove(t, e);
1575
+ return this._forEachBlocksInRange(t, e, (i, a, r, u) => {
1576
+ s.aggregate(i.remove(r, u));
1577
+ }), s;
1578
+ }
1579
+ nearestInputPos(t, e) {
1580
+ if (e === void 0 && (e = o.NONE), !this._blocks.length)
1581
+ return 0;
1582
+ const s = new J(this, t);
1583
+ if (e === o.NONE)
1584
+ return s.pushRightBeforeInput() || (s.popState(), s.pushLeftBeforeInput()) ? s.pos : this.displayValue.length;
1585
+ if (e === o.LEFT || e === o.FORCE_LEFT) {
1586
+ if (e === o.LEFT) {
1587
+ if (s.pushRightBeforeFilled(), s.ok && s.pos === t)
1588
+ return t;
1589
+ s.popState();
1590
+ }
1591
+ if (s.pushLeftBeforeInput(), s.pushLeftBeforeRequired(), s.pushLeftBeforeFilled(), e === o.LEFT) {
1592
+ if (s.pushRightBeforeInput(), s.pushRightBeforeRequired(), s.ok && s.pos <= t || (s.popState(), s.ok && s.pos <= t))
1593
+ return s.pos;
1594
+ s.popState();
1595
+ }
1596
+ return s.ok ? s.pos : e === o.FORCE_LEFT ? 0 : (s.popState(), s.ok || (s.popState(), s.ok) ? s.pos : 0);
1597
+ }
1598
+ return e === o.RIGHT || e === o.FORCE_RIGHT ? (s.pushRightBeforeInput(), s.pushRightBeforeRequired(), s.pushRightBeforeFilled() ? s.pos : e === o.FORCE_RIGHT ? this.displayValue.length : (s.popState(), s.ok || (s.popState(), s.ok) ? s.pos : this.nearestInputPos(t, o.LEFT))) : t;
1599
+ }
1600
+ totalInputPositions(t, e) {
1601
+ t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length);
1602
+ let s = 0;
1603
+ return this._forEachBlocksInRange(t, e, (i, a, r, u) => {
1604
+ s += i.totalInputPositions(r, u);
1605
+ }), s;
1606
+ }
1607
+ /** Get block by name */
1608
+ maskedBlock(t) {
1609
+ return this.maskedBlocks(t)[0];
1610
+ }
1611
+ /** Get all blocks by name */
1612
+ maskedBlocks(t) {
1613
+ const e = this._maskedBlocks[t];
1614
+ return e ? e.map((s) => this._blocks[s]) : [];
1615
+ }
1616
+ pad(t) {
1617
+ const e = new d();
1618
+ return this._forEachBlocksInRange(0, this.displayValue.length, (s) => e.aggregate(s.pad(t))), e;
1619
+ }
1620
+ }
1621
+ m.DEFAULTS = {
1622
+ ...k.DEFAULTS,
1623
+ lazy: !0,
1624
+ placeholderChar: "_"
1625
+ };
1626
+ m.STOP_CHAR = "`";
1627
+ m.ESCAPE_CHAR = "\\";
1628
+ m.InputDefinition = b;
1629
+ m.FixedDefinition = G;
1630
+ p.MaskedPattern = m;
1631
+ class B extends m {
1632
+ /**
1633
+ Optionally sets max length of pattern.
1634
+ Used when pattern length is longer then `to` param length. Pads zeros at start in this case.
1635
+ */
1636
+ /** Min bound */
1637
+ /** Max bound */
1638
+ get _matchFrom() {
1639
+ return this.maxLength - String(this.from).length;
1640
+ }
1641
+ constructor(t) {
1642
+ super(t);
1643
+ }
1644
+ updateOptions(t) {
1645
+ super.updateOptions(t);
1646
+ }
1647
+ _update(t) {
1648
+ const {
1649
+ to: e = this.to || 0,
1650
+ from: s = this.from || 0,
1651
+ maxLength: i = this.maxLength || 0,
1652
+ autofix: a = this.autofix,
1653
+ ...r
1654
+ } = t;
1655
+ this.to = e, this.from = s, this.maxLength = Math.max(String(e).length, i), this.autofix = a;
1656
+ const u = String(this.from).padStart(this.maxLength, "0"), h = String(this.to).padStart(this.maxLength, "0");
1657
+ let l = 0;
1658
+ for (; l < h.length && h[l] === u[l]; )
1659
+ ++l;
1660
+ r.mask = h.slice(0, l).replace(/0/g, "\\0") + "0".repeat(this.maxLength - l), super._update(r);
1661
+ }
1662
+ get isComplete() {
1663
+ return super.isComplete && !!this.value;
1664
+ }
1665
+ boundaries(t) {
1666
+ let e = "", s = "";
1667
+ const [, i, a] = t.match(/^(\D*)(\d*)(\D*)/) || [];
1668
+ return a && (e = "0".repeat(i.length) + a, s = "9".repeat(i.length) + a), e = e.padEnd(this.maxLength, "0"), s = s.padEnd(this.maxLength, "9"), [e, s];
1669
+ }
1670
+ doPrepareChar(t, e) {
1671
+ e === void 0 && (e = {});
1672
+ let s;
1673
+ return [t, s] = super.doPrepareChar(t.replace(/\D/g, ""), e), t || (s.skip = !this.isComplete), [t, s];
1674
+ }
1675
+ _appendCharRaw(t, e) {
1676
+ if (e === void 0 && (e = {}), !this.autofix || this.value.length + 1 > this.maxLength)
1677
+ return super._appendCharRaw(t, e);
1678
+ const s = String(this.from).padStart(this.maxLength, "0"), i = String(this.to).padStart(this.maxLength, "0"), [a, r] = this.boundaries(this.value + t);
1679
+ return Number(r) < this.from ? super._appendCharRaw(s[this.value.length], e) : Number(a) > this.to ? !e.tail && this.autofix === "pad" && this.value.length + 1 < this.maxLength ? super._appendCharRaw(s[this.value.length], e).aggregate(this._appendCharRaw(t, e)) : super._appendCharRaw(i[this.value.length], e) : super._appendCharRaw(t, e);
1680
+ }
1681
+ doValidate(t) {
1682
+ const e = this.value;
1683
+ if (e.search(/[^0]/) === -1 && e.length <= this._matchFrom)
1684
+ return !0;
1685
+ const [s, i] = this.boundaries(e);
1686
+ return this.from <= Number(i) && Number(s) <= this.to && super.doValidate(t);
1687
+ }
1688
+ pad(t) {
1689
+ const e = new d();
1690
+ if (this.value.length === this.maxLength)
1691
+ return e;
1692
+ const s = this.value, i = this.maxLength - this.value.length;
1693
+ if (i) {
1694
+ this.reset();
1695
+ for (let a = 0; a < i; ++a)
1696
+ e.aggregate(super._appendCharRaw("0", t));
1697
+ s.split("").forEach((a) => this._appendCharRaw(a));
1698
+ }
1699
+ return e;
1700
+ }
1701
+ }
1702
+ p.MaskedRange = B;
1703
+ const tt = "d{.}`m{.}`Y";
1704
+ class E extends m {
1705
+ static extractPatternOptions(t) {
1706
+ const {
1707
+ mask: e,
1708
+ pattern: s,
1709
+ ...i
1710
+ } = t;
1711
+ return {
1712
+ ...i,
1713
+ mask: A(e) ? e : s
1714
+ };
1715
+ }
1716
+ /** Pattern mask for date according to {@link MaskedDate#format} */
1717
+ /** Start date */
1718
+ /** End date */
1719
+ /** Format typed value to string */
1720
+ /** Parse string to get typed value */
1721
+ constructor(t) {
1722
+ super(E.extractPatternOptions({
1723
+ ...E.DEFAULTS,
1724
+ ...t
1725
+ }));
1726
+ }
1727
+ updateOptions(t) {
1728
+ super.updateOptions(t);
1729
+ }
1730
+ _update(t) {
1731
+ const {
1732
+ mask: e,
1733
+ pattern: s,
1734
+ blocks: i,
1735
+ ...a
1736
+ } = {
1737
+ ...E.DEFAULTS,
1738
+ ...t
1739
+ }, r = Object.assign({}, E.GET_DEFAULT_BLOCKS());
1740
+ t.min && (r.Y.from = t.min.getFullYear()), t.max && (r.Y.to = t.max.getFullYear()), t.min && t.max && r.Y.from === r.Y.to && (r.m.from = t.min.getMonth() + 1, r.m.to = t.max.getMonth() + 1, r.m.from === r.m.to && (r.d.from = t.min.getDate(), r.d.to = t.max.getDate())), Object.assign(r, this.blocks, i), super._update({
1741
+ ...a,
1742
+ mask: A(e) ? e : s,
1743
+ blocks: r
1744
+ });
1745
+ }
1746
+ doValidate(t) {
1747
+ const e = this.date;
1748
+ return super.doValidate(t) && (!this.isComplete || this.isDateExist(this.value) && e != null && (this.min == null || this.min <= e) && (this.max == null || e <= this.max));
1749
+ }
1750
+ /** Checks if date is exists */
1751
+ isDateExist(t) {
1752
+ return this.format(this.parse(t, this), this).indexOf(t) >= 0;
1753
+ }
1754
+ /** Parsed Date */
1755
+ get date() {
1756
+ return this.typedValue;
1757
+ }
1758
+ set date(t) {
1759
+ this.typedValue = t;
1760
+ }
1761
+ get typedValue() {
1762
+ return this.isComplete ? super.typedValue : null;
1763
+ }
1764
+ set typedValue(t) {
1765
+ super.typedValue = t;
1766
+ }
1767
+ maskEquals(t) {
1768
+ return t === Date || super.maskEquals(t);
1769
+ }
1770
+ optionsIsChanged(t) {
1771
+ return super.optionsIsChanged(E.extractPatternOptions(t));
1772
+ }
1773
+ }
1774
+ E.GET_DEFAULT_BLOCKS = () => ({
1775
+ d: {
1776
+ mask: B,
1777
+ from: 1,
1778
+ to: 31,
1779
+ maxLength: 2
1780
+ },
1781
+ m: {
1782
+ mask: B,
1783
+ from: 1,
1784
+ to: 12,
1785
+ maxLength: 2
1786
+ },
1787
+ Y: {
1788
+ mask: B,
1789
+ from: 1900,
1790
+ to: 9999
1791
+ }
1792
+ });
1793
+ E.DEFAULTS = {
1794
+ ...m.DEFAULTS,
1795
+ mask: Date,
1796
+ pattern: tt,
1797
+ format: (n, t) => {
1798
+ if (!n)
1799
+ return "";
1800
+ const e = String(n.getDate()).padStart(2, "0"), s = String(n.getMonth() + 1).padStart(2, "0"), i = n.getFullYear();
1801
+ return [e, s, i].join(".");
1802
+ },
1803
+ parse: (n, t) => {
1804
+ const [e, s, i] = n.split(".").map(Number);
1805
+ return new Date(i, s - 1, e);
1806
+ }
1807
+ };
1808
+ p.MaskedDate = E;
1809
+ class M extends k {
1810
+ constructor(t) {
1811
+ super({
1812
+ ...M.DEFAULTS,
1813
+ ...t
1814
+ }), this.currentMask = void 0;
1815
+ }
1816
+ updateOptions(t) {
1817
+ super.updateOptions(t);
1818
+ }
1819
+ _update(t) {
1820
+ super._update(t), "mask" in t && (this.exposeMask = void 0, this.compiledMasks = Array.isArray(t.mask) ? t.mask.map((e) => {
1821
+ const {
1822
+ expose: s,
1823
+ ...i
1824
+ } = x(e), a = C({
1825
+ overwrite: this._overwrite,
1826
+ eager: this._eager,
1827
+ skipInvalid: this._skipInvalid,
1828
+ ...i
1829
+ });
1830
+ return s && (this.exposeMask = a), a;
1831
+ }) : []);
1832
+ }
1833
+ _appendCharRaw(t, e) {
1834
+ e === void 0 && (e = {});
1835
+ const s = this._applyDispatch(t, e);
1836
+ return this.currentMask && s.aggregate(this.currentMask._appendChar(t, this.currentMaskFlags(e))), s;
1837
+ }
1838
+ _applyDispatch(t, e, s) {
1839
+ t === void 0 && (t = ""), e === void 0 && (e = {}), s === void 0 && (s = "");
1840
+ const i = e.tail && e._beforeTailState != null ? e._beforeTailState._value : this.value, a = this.rawInputValue, r = e.tail && e._beforeTailState != null ? e._beforeTailState._rawInputValue : a, u = a.slice(r.length), h = this.currentMask, l = new d(), c = h == null ? void 0 : h.state;
1841
+ return this.currentMask = this.doDispatch(t, {
1842
+ ...e
1843
+ }, s), this.currentMask && (this.currentMask !== h ? (this.currentMask.reset(), r && (this.currentMask.append(r, {
1844
+ raw: !0
1845
+ }), l.tailShift = this.currentMask.value.length - i.length), u && (l.tailShift += this.currentMask.append(u, {
1846
+ raw: !0,
1847
+ tail: !0
1848
+ }).tailShift)) : c && (this.currentMask.state = c)), l;
1849
+ }
1850
+ _appendPlaceholder() {
1851
+ const t = this._applyDispatch();
1852
+ return this.currentMask && t.aggregate(this.currentMask._appendPlaceholder()), t;
1853
+ }
1854
+ _appendEager() {
1855
+ const t = this._applyDispatch();
1856
+ return this.currentMask && t.aggregate(this.currentMask._appendEager()), t;
1857
+ }
1858
+ appendTail(t) {
1859
+ const e = new d();
1860
+ return t && e.aggregate(this._applyDispatch("", {}, t)), e.aggregate(this.currentMask ? this.currentMask.appendTail(t) : super.appendTail(t));
1861
+ }
1862
+ currentMaskFlags(t) {
1863
+ var e, s;
1864
+ return {
1865
+ ...t,
1866
+ _beforeTailState: ((e = t._beforeTailState) == null ? void 0 : e.currentMaskRef) === this.currentMask && ((s = t._beforeTailState) == null ? void 0 : s.currentMask) || t._beforeTailState
1867
+ };
1868
+ }
1869
+ doDispatch(t, e, s) {
1870
+ return e === void 0 && (e = {}), s === void 0 && (s = ""), this.dispatch(t, this, e, s);
1871
+ }
1872
+ doValidate(t) {
1873
+ return super.doValidate(t) && (!this.currentMask || this.currentMask.doValidate(this.currentMaskFlags(t)));
1874
+ }
1875
+ doPrepare(t, e) {
1876
+ e === void 0 && (e = {});
1877
+ let [s, i] = super.doPrepare(t, e);
1878
+ if (this.currentMask) {
1879
+ let a;
1880
+ [s, a] = super.doPrepare(s, this.currentMaskFlags(e)), i = i.aggregate(a);
1881
+ }
1882
+ return [s, i];
1883
+ }
1884
+ doPrepareChar(t, e) {
1885
+ e === void 0 && (e = {});
1886
+ let [s, i] = super.doPrepareChar(t, e);
1887
+ if (this.currentMask) {
1888
+ let a;
1889
+ [s, a] = super.doPrepareChar(s, this.currentMaskFlags(e)), i = i.aggregate(a);
1890
+ }
1891
+ return [s, i];
1892
+ }
1893
+ reset() {
1894
+ var t;
1895
+ (t = this.currentMask) == null || t.reset(), this.compiledMasks.forEach((e) => e.reset());
1896
+ }
1897
+ get value() {
1898
+ return this.exposeMask ? this.exposeMask.value : this.currentMask ? this.currentMask.value : "";
1899
+ }
1900
+ set value(t) {
1901
+ this.exposeMask ? (this.exposeMask.value = t, this.currentMask = this.exposeMask, this._applyDispatch()) : super.value = t;
1902
+ }
1903
+ get unmaskedValue() {
1904
+ return this.exposeMask ? this.exposeMask.unmaskedValue : this.currentMask ? this.currentMask.unmaskedValue : "";
1905
+ }
1906
+ set unmaskedValue(t) {
1907
+ this.exposeMask ? (this.exposeMask.unmaskedValue = t, this.currentMask = this.exposeMask, this._applyDispatch()) : super.unmaskedValue = t;
1908
+ }
1909
+ get typedValue() {
1910
+ return this.exposeMask ? this.exposeMask.typedValue : this.currentMask ? this.currentMask.typedValue : "";
1911
+ }
1912
+ set typedValue(t) {
1913
+ if (this.exposeMask) {
1914
+ this.exposeMask.typedValue = t, this.currentMask = this.exposeMask, this._applyDispatch();
1915
+ return;
1916
+ }
1917
+ let e = String(t);
1918
+ this.currentMask && (this.currentMask.typedValue = t, e = this.currentMask.unmaskedValue), this.unmaskedValue = e;
1919
+ }
1920
+ get displayValue() {
1921
+ return this.currentMask ? this.currentMask.displayValue : "";
1922
+ }
1923
+ get isComplete() {
1924
+ var t;
1925
+ return !!((t = this.currentMask) != null && t.isComplete);
1926
+ }
1927
+ get isFilled() {
1928
+ var t;
1929
+ return !!((t = this.currentMask) != null && t.isFilled);
1930
+ }
1931
+ remove(t, e) {
1932
+ const s = new d();
1933
+ return this.currentMask && s.aggregate(this.currentMask.remove(t, e)).aggregate(this._applyDispatch()), s;
1934
+ }
1935
+ get state() {
1936
+ var t;
1937
+ return {
1938
+ ...super.state,
1939
+ _rawInputValue: this.rawInputValue,
1940
+ compiledMasks: this.compiledMasks.map((e) => e.state),
1941
+ currentMaskRef: this.currentMask,
1942
+ currentMask: (t = this.currentMask) == null ? void 0 : t.state
1943
+ };
1944
+ }
1945
+ set state(t) {
1946
+ const {
1947
+ compiledMasks: e,
1948
+ currentMaskRef: s,
1949
+ currentMask: i,
1950
+ ...a
1951
+ } = t;
1952
+ e && this.compiledMasks.forEach((r, u) => r.state = e[u]), s != null && (this.currentMask = s, this.currentMask.state = i), super.state = a;
1953
+ }
1954
+ extractInput(t, e, s) {
1955
+ return this.currentMask ? this.currentMask.extractInput(t, e, s) : "";
1956
+ }
1957
+ extractTail(t, e) {
1958
+ return this.currentMask ? this.currentMask.extractTail(t, e) : super.extractTail(t, e);
1959
+ }
1960
+ doCommit() {
1961
+ this.currentMask && this.currentMask.doCommit(), super.doCommit();
1962
+ }
1963
+ nearestInputPos(t, e) {
1964
+ return this.currentMask ? this.currentMask.nearestInputPos(t, e) : super.nearestInputPos(t, e);
1965
+ }
1966
+ get overwrite() {
1967
+ return this.currentMask ? this.currentMask.overwrite : this._overwrite;
1968
+ }
1969
+ set overwrite(t) {
1970
+ this._overwrite = t;
1971
+ }
1972
+ get eager() {
1973
+ return this.currentMask ? this.currentMask.eager : this._eager;
1974
+ }
1975
+ set eager(t) {
1976
+ this._eager = t;
1977
+ }
1978
+ get skipInvalid() {
1979
+ return this.currentMask ? this.currentMask.skipInvalid : this._skipInvalid;
1980
+ }
1981
+ set skipInvalid(t) {
1982
+ this._skipInvalid = t;
1983
+ }
1984
+ get autofix() {
1985
+ return this.currentMask ? this.currentMask.autofix : this._autofix;
1986
+ }
1987
+ set autofix(t) {
1988
+ this._autofix = t;
1989
+ }
1990
+ maskEquals(t) {
1991
+ return Array.isArray(t) ? this.compiledMasks.every((e, s) => {
1992
+ if (!t[s])
1993
+ return;
1994
+ const {
1995
+ mask: i,
1996
+ ...a
1997
+ } = t[s];
1998
+ return D(e, a) && e.maskEquals(i);
1999
+ }) : super.maskEquals(t);
2000
+ }
2001
+ typedValueEquals(t) {
2002
+ var e;
2003
+ return !!((e = this.currentMask) != null && e.typedValueEquals(t));
2004
+ }
2005
+ }
2006
+ M.DEFAULTS = {
2007
+ ...k.DEFAULTS,
2008
+ dispatch: (n, t, e, s) => {
2009
+ if (!t.compiledMasks.length)
2010
+ return;
2011
+ const i = t.rawInputValue, a = t.compiledMasks.map((r, u) => {
2012
+ const h = t.currentMask === r, l = h ? r.displayValue.length : r.nearestInputPos(r.displayValue.length, o.FORCE_LEFT);
2013
+ return r.rawInputValue !== i ? (r.reset(), r.append(i, {
2014
+ raw: !0
2015
+ })) : h || r.remove(l), r.append(n, t.currentMaskFlags(e)), r.appendTail(s), {
2016
+ index: u,
2017
+ weight: r.rawInputValue.length,
2018
+ totalInputPositions: r.totalInputPositions(0, Math.max(l, r.nearestInputPos(r.displayValue.length, o.FORCE_LEFT)))
2019
+ };
2020
+ });
2021
+ return a.sort((r, u) => u.weight - r.weight || u.totalInputPositions - r.totalInputPositions), t.compiledMasks[a[0].index];
2022
+ }
2023
+ };
2024
+ p.MaskedDynamic = M;
2025
+ class V extends m {
2026
+ constructor(t) {
2027
+ super({
2028
+ ...V.DEFAULTS,
2029
+ ...t
2030
+ });
2031
+ }
2032
+ updateOptions(t) {
2033
+ super.updateOptions(t);
2034
+ }
2035
+ _update(t) {
2036
+ const {
2037
+ enum: e,
2038
+ ...s
2039
+ } = t;
2040
+ if (e) {
2041
+ const i = e.map((u) => u.length), a = Math.min(...i), r = Math.max(...i) - a;
2042
+ s.mask = "*".repeat(a), r && (s.mask += "[" + "*".repeat(r) + "]"), this.enum = e;
2043
+ }
2044
+ super._update(s);
2045
+ }
2046
+ _appendCharRaw(t, e) {
2047
+ e === void 0 && (e = {});
2048
+ const s = Math.min(this.nearestInputPos(0, o.FORCE_RIGHT), this.value.length), i = this.enum.filter((a) => this.matchValue(a, this.unmaskedValue + t, s));
2049
+ if (i.length) {
2050
+ i.length === 1 && this._forEachBlocksInRange(0, this.value.length, (r, u) => {
2051
+ const h = i[0][u];
2052
+ u >= this.value.length || h === r.value || (r.reset(), r._appendChar(h, e));
2053
+ });
2054
+ const a = super._appendCharRaw(i[0][this.value.length], e);
2055
+ return i.length === 1 && i[0].slice(this.unmaskedValue.length).split("").forEach((r) => a.aggregate(super._appendCharRaw(r))), a;
2056
+ }
2057
+ return new d({
2058
+ skip: !this.isComplete
2059
+ });
2060
+ }
2061
+ extractTail(t, e) {
2062
+ return t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), new v("", t);
2063
+ }
2064
+ remove(t, e) {
2065
+ if (t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), t === e)
2066
+ return new d();
2067
+ const s = Math.min(super.nearestInputPos(0, o.FORCE_RIGHT), this.value.length);
2068
+ let i;
2069
+ for (i = t; i >= 0 && !(this.enum.filter((r) => this.matchValue(r, this.value.slice(s, i), s)).length > 1); --i)
2070
+ ;
2071
+ const a = super.remove(i, e);
2072
+ return a.tailShift += i - t, a;
2073
+ }
2074
+ get isComplete() {
2075
+ return this.enum.indexOf(this.value) >= 0;
2076
+ }
2077
+ }
2078
+ V.DEFAULTS = {
2079
+ ...m.DEFAULTS,
2080
+ matchValue: (n, t, e) => n.indexOf(t, e) === e
2081
+ };
2082
+ p.MaskedEnum = V;
2083
+ class et extends k {
2084
+ /** */
2085
+ /** Enable characters overwriting */
2086
+ /** */
2087
+ /** */
2088
+ /** */
2089
+ updateOptions(t) {
2090
+ super.updateOptions(t);
2091
+ }
2092
+ _update(t) {
2093
+ super._update({
2094
+ ...t,
2095
+ validate: t.mask
2096
+ });
2097
+ }
2098
+ }
2099
+ p.MaskedFunction = et;
2100
+ var z;
2101
+ class _ extends k {
2102
+ /** Single char */
2103
+ /** Single char */
2104
+ /** Array of single chars */
2105
+ /** */
2106
+ /** */
2107
+ /** Digits after point */
2108
+ /** Flag to remove leading and trailing zeros in the end of editing */
2109
+ /** Flag to pad trailing zeros after point in the end of editing */
2110
+ /** Enable characters overwriting */
2111
+ /** */
2112
+ /** */
2113
+ /** */
2114
+ /** Format typed value to string */
2115
+ /** Parse string to get typed value */
2116
+ constructor(t) {
2117
+ super({
2118
+ ..._.DEFAULTS,
2119
+ ...t
2120
+ });
2121
+ }
2122
+ updateOptions(t) {
2123
+ super.updateOptions(t);
2124
+ }
2125
+ _update(t) {
2126
+ super._update(t), this._updateRegExps();
2127
+ }
2128
+ _updateRegExps() {
2129
+ const t = "^" + (this.allowNegative ? "[+|\\-]?" : ""), e = "\\d*", s = (this.scale ? "(" + w(this.radix) + "\\d{0," + this.scale + "})?" : "") + "$";
2130
+ this._numberRegExp = new RegExp(t + e + s), this._mapToRadixRegExp = new RegExp("[" + this.mapToRadix.map(w).join("") + "]", "g"), this._thousandsSeparatorRegExp = new RegExp(w(this.thousandsSeparator), "g");
2131
+ }
2132
+ _removeThousandsSeparators(t) {
2133
+ return t.replace(this._thousandsSeparatorRegExp, "");
2134
+ }
2135
+ _insertThousandsSeparators(t) {
2136
+ const e = t.split(this.radix);
2137
+ return e[0] = e[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandsSeparator), e.join(this.radix);
2138
+ }
2139
+ doPrepareChar(t, e) {
2140
+ e === void 0 && (e = {});
2141
+ const [s, i] = super.doPrepareChar(this._removeThousandsSeparators(this.scale && this.mapToRadix.length && /*
2142
+ radix should be mapped when
2143
+ 1) input is done from keyboard = flags.input && flags.raw
2144
+ 2) unmasked value is set = !flags.input && !flags.raw
2145
+ and should not be mapped when
2146
+ 1) value is set = flags.input && !flags.raw
2147
+ 2) raw value is set = !flags.input && flags.raw
2148
+ */
2149
+ (e.input && e.raw || !e.input && !e.raw) ? t.replace(this._mapToRadixRegExp, this.radix) : t), e);
2150
+ return t && !s && (i.skip = !0), s && !this.allowPositive && !this.value && s !== "-" && i.aggregate(this._appendChar("-")), [s, i];
2151
+ }
2152
+ _separatorsCount(t, e) {
2153
+ e === void 0 && (e = !1);
2154
+ let s = 0;
2155
+ for (let i = 0; i < t; ++i)
2156
+ this._value.indexOf(this.thousandsSeparator, i) === i && (++s, e && (t += this.thousandsSeparator.length));
2157
+ return s;
2158
+ }
2159
+ _separatorsCountFromSlice(t) {
2160
+ return t === void 0 && (t = this._value), this._separatorsCount(this._removeThousandsSeparators(t).length, !0);
2161
+ }
2162
+ extractInput(t, e, s) {
2163
+ return t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), [t, e] = this._adjustRangeWithSeparators(t, e), this._removeThousandsSeparators(super.extractInput(t, e, s));
2164
+ }
2165
+ _appendCharRaw(t, e) {
2166
+ e === void 0 && (e = {});
2167
+ const s = e.tail && e._beforeTailState ? e._beforeTailState._value : this._value, i = this._separatorsCountFromSlice(s);
2168
+ this._value = this._removeThousandsSeparators(this.value);
2169
+ const a = this._value;
2170
+ this._value += t;
2171
+ const r = this.number;
2172
+ let u = !isNaN(r), h = !1;
2173
+ if (u) {
2174
+ let f;
2175
+ this.min != null && this.min < 0 && this.number < this.min && (f = this.min), this.max != null && this.max > 0 && this.number > this.max && (f = this.max), f != null && (this.autofix ? (this._value = this.format(f, this).replace(_.UNMASKED_RADIX, this.radix), h || (h = a === this._value && !e.tail)) : u = !1), u && (u = !!this._value.match(this._numberRegExp));
2176
+ }
2177
+ let l;
2178
+ u ? l = new d({
2179
+ inserted: this._value.slice(a.length),
2180
+ rawInserted: h ? "" : t,
2181
+ skip: h
2182
+ }) : (this._value = a, l = new d()), this._value = this._insertThousandsSeparators(this._value);
2183
+ const c = e.tail && e._beforeTailState ? e._beforeTailState._value : this._value, g = this._separatorsCountFromSlice(c);
2184
+ return l.tailShift += (g - i) * this.thousandsSeparator.length, l;
2185
+ }
2186
+ _findSeparatorAround(t) {
2187
+ if (this.thousandsSeparator) {
2188
+ const e = t - this.thousandsSeparator.length + 1, s = this.value.indexOf(this.thousandsSeparator, e);
2189
+ if (s <= t)
2190
+ return s;
2191
+ }
2192
+ return -1;
2193
+ }
2194
+ _adjustRangeWithSeparators(t, e) {
2195
+ const s = this._findSeparatorAround(t);
2196
+ s >= 0 && (t = s);
2197
+ const i = this._findSeparatorAround(e);
2198
+ return i >= 0 && (e = i + this.thousandsSeparator.length), [t, e];
2199
+ }
2200
+ remove(t, e) {
2201
+ t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), [t, e] = this._adjustRangeWithSeparators(t, e);
2202
+ const s = this.value.slice(0, t), i = this.value.slice(e), a = this._separatorsCount(s.length);
2203
+ this._value = this._insertThousandsSeparators(this._removeThousandsSeparators(s + i));
2204
+ const r = this._separatorsCountFromSlice(s);
2205
+ return new d({
2206
+ tailShift: (r - a) * this.thousandsSeparator.length
2207
+ });
2208
+ }
2209
+ nearestInputPos(t, e) {
2210
+ if (!this.thousandsSeparator)
2211
+ return t;
2212
+ switch (e) {
2213
+ case o.NONE:
2214
+ case o.LEFT:
2215
+ case o.FORCE_LEFT: {
2216
+ const s = this._findSeparatorAround(t - 1);
2217
+ if (s >= 0) {
2218
+ const i = s + this.thousandsSeparator.length;
2219
+ if (t < i || this.value.length <= i || e === o.FORCE_LEFT)
2220
+ return s;
2221
+ }
2222
+ break;
2223
+ }
2224
+ case o.RIGHT:
2225
+ case o.FORCE_RIGHT: {
2226
+ const s = this._findSeparatorAround(t);
2227
+ if (s >= 0)
2228
+ return s + this.thousandsSeparator.length;
2229
+ }
2230
+ }
2231
+ return t;
2232
+ }
2233
+ doCommit() {
2234
+ if (this.value) {
2235
+ const t = this.number;
2236
+ let e = t;
2237
+ this.min != null && (e = Math.max(e, this.min)), this.max != null && (e = Math.min(e, this.max)), e !== t && (this.unmaskedValue = this.format(e, this));
2238
+ let s = this.value;
2239
+ this.normalizeZeros && (s = this._normalizeZeros(s)), this.padFractionalZeros && this.scale > 0 && (s = this._padFractionalZeros(s)), this._value = s;
2240
+ }
2241
+ super.doCommit();
2242
+ }
2243
+ _normalizeZeros(t) {
2244
+ const e = this._removeThousandsSeparators(t).split(this.radix);
2245
+ return e[0] = e[0].replace(/^(\D*)(0*)(\d*)/, (s, i, a, r) => i + r), t.length && !/\d$/.test(e[0]) && (e[0] = e[0] + "0"), e.length > 1 && (e[1] = e[1].replace(/0*$/, ""), e[1].length || (e.length = 1)), this._insertThousandsSeparators(e.join(this.radix));
2246
+ }
2247
+ _padFractionalZeros(t) {
2248
+ if (!t)
2249
+ return t;
2250
+ const e = t.split(this.radix);
2251
+ return e.length < 2 && e.push(""), e[1] = e[1].padEnd(this.scale, "0"), e.join(this.radix);
2252
+ }
2253
+ doSkipInvalid(t, e, s) {
2254
+ e === void 0 && (e = {});
2255
+ const i = this.scale === 0 && t !== this.thousandsSeparator && (t === this.radix || t === _.UNMASKED_RADIX || this.mapToRadix.includes(t));
2256
+ return super.doSkipInvalid(t, e, s) && !i;
2257
+ }
2258
+ get unmaskedValue() {
2259
+ return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix, _.UNMASKED_RADIX);
2260
+ }
2261
+ set unmaskedValue(t) {
2262
+ super.unmaskedValue = t;
2263
+ }
2264
+ get typedValue() {
2265
+ return this.parse(this.unmaskedValue, this);
2266
+ }
2267
+ set typedValue(t) {
2268
+ this.rawInputValue = this.format(t, this).replace(_.UNMASKED_RADIX, this.radix);
2269
+ }
2270
+ /** Parsed Number */
2271
+ get number() {
2272
+ return this.typedValue;
2273
+ }
2274
+ set number(t) {
2275
+ this.typedValue = t;
2276
+ }
2277
+ get allowNegative() {
2278
+ return this.min != null && this.min < 0 || this.max != null && this.max < 0;
2279
+ }
2280
+ get allowPositive() {
2281
+ return this.min != null && this.min > 0 || this.max != null && this.max > 0;
2282
+ }
2283
+ typedValueEquals(t) {
2284
+ return (super.typedValueEquals(t) || _.EMPTY_VALUES.includes(t) && _.EMPTY_VALUES.includes(this.typedValue)) && !(t === 0 && this.value === "");
2285
+ }
2286
+ }
2287
+ z = _;
2288
+ _.UNMASKED_RADIX = ".";
2289
+ _.EMPTY_VALUES = [...k.EMPTY_VALUES, 0];
2290
+ _.DEFAULTS = {
2291
+ ...k.DEFAULTS,
2292
+ mask: Number,
2293
+ radix: ",",
2294
+ thousandsSeparator: "",
2295
+ mapToRadix: [z.UNMASKED_RADIX],
2296
+ min: Number.MIN_SAFE_INTEGER,
2297
+ max: Number.MAX_SAFE_INTEGER,
2298
+ scale: 2,
2299
+ normalizeZeros: !0,
2300
+ padFractionalZeros: !1,
2301
+ parse: Number,
2302
+ format: (n) => n.toLocaleString("en-US", {
2303
+ useGrouping: !1,
2304
+ maximumFractionDigits: 20
2305
+ })
2306
+ };
2307
+ p.MaskedNumber = _;
2308
+ const R = {
2309
+ MASKED: "value",
2310
+ UNMASKED: "unmaskedValue",
2311
+ TYPED: "typedValue"
2312
+ };
2313
+ function q(n, t, e) {
2314
+ t === void 0 && (t = R.MASKED), e === void 0 && (e = R.MASKED);
2315
+ const s = C(n);
2316
+ return (i) => s.runIsolated((a) => (a[t] = i, a[e]));
2317
+ }
2318
+ function st(n, t, e, s) {
2319
+ return q(t, e, s)(n);
2320
+ }
2321
+ p.PIPE_TYPE = R;
2322
+ p.createPipe = q;
2323
+ p.pipe = st;
2324
+ class it extends m {
2325
+ get repeatFrom() {
2326
+ var t;
2327
+ return (t = Array.isArray(this.repeat) ? this.repeat[0] : this.repeat === 1 / 0 ? 0 : this.repeat) != null ? t : 0;
2328
+ }
2329
+ get repeatTo() {
2330
+ var t;
2331
+ return (t = Array.isArray(this.repeat) ? this.repeat[1] : this.repeat) != null ? t : 1 / 0;
2332
+ }
2333
+ constructor(t) {
2334
+ super(t);
2335
+ }
2336
+ updateOptions(t) {
2337
+ super.updateOptions(t);
2338
+ }
2339
+ _update(t) {
2340
+ var e, s, i;
2341
+ const {
2342
+ repeat: a,
2343
+ ...r
2344
+ } = x(t);
2345
+ this._blockOpts = Object.assign({}, this._blockOpts, r);
2346
+ const u = C(this._blockOpts);
2347
+ this.repeat = (e = (s = a ?? u.repeat) != null ? s : this.repeat) != null ? e : 1 / 0, super._update({
2348
+ mask: "m".repeat(Math.max(this.repeatTo === 1 / 0 && ((i = this._blocks) == null ? void 0 : i.length) || 0, this.repeatFrom)),
2349
+ blocks: {
2350
+ m: u
2351
+ },
2352
+ eager: u.eager,
2353
+ overwrite: u.overwrite,
2354
+ skipInvalid: u.skipInvalid,
2355
+ lazy: u.lazy,
2356
+ placeholderChar: u.placeholderChar,
2357
+ displayChar: u.displayChar
2358
+ });
2359
+ }
2360
+ _allocateBlock(t) {
2361
+ if (t < this._blocks.length)
2362
+ return this._blocks[t];
2363
+ if (this.repeatTo === 1 / 0 || this._blocks.length < this.repeatTo)
2364
+ return this._blocks.push(C(this._blockOpts)), this.mask += "m", this._blocks[this._blocks.length - 1];
2365
+ }
2366
+ _appendCharRaw(t, e) {
2367
+ e === void 0 && (e = {});
2368
+ const s = new d();
2369
+ for (
2370
+ let h = (i = (a = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : a.index) != null ? i : Math.max(this._blocks.length - 1, 0), l, c;
2371
+ // try to get a block or
2372
+ // try to allocate a new block if not allocated already
2373
+ l = (r = this._blocks[h]) != null ? r : c = !c && this._allocateBlock(h);
2374
+ ++h
2375
+ ) {
2376
+ var i, a, r, u;
2377
+ const g = l._appendChar(t, {
2378
+ ...e,
2379
+ _beforeTailState: (u = e._beforeTailState) == null || (u = u._blocks) == null ? void 0 : u[h]
2380
+ });
2381
+ if (g.skip && c) {
2382
+ this._blocks.pop(), this.mask = this.mask.slice(1);
2383
+ break;
2384
+ }
2385
+ if (s.aggregate(g), g.consumed)
2386
+ break;
2387
+ }
2388
+ return s;
2389
+ }
2390
+ _trimEmptyTail(t, e) {
2391
+ var s, i;
2392
+ t === void 0 && (t = 0);
2393
+ const a = Math.max(((s = this._mapPosToBlock(t)) == null ? void 0 : s.index) || 0, this.repeatFrom, 0);
2394
+ let r;
2395
+ e != null && (r = (i = this._mapPosToBlock(e)) == null ? void 0 : i.index), r == null && (r = this._blocks.length - 1);
2396
+ let u = 0;
2397
+ for (let h = r; a <= h && !this._blocks[h].unmaskedValue; --h, ++u)
2398
+ ;
2399
+ u && (this._blocks.splice(r - u + 1, u), this.mask = this.mask.slice(u));
2400
+ }
2401
+ reset() {
2402
+ super.reset(), this._trimEmptyTail();
2403
+ }
2404
+ remove(t, e) {
2405
+ t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length);
2406
+ const s = super.remove(t, e);
2407
+ return this._trimEmptyTail(t, e), s;
2408
+ }
2409
+ totalInputPositions(t, e) {
2410
+ return t === void 0 && (t = 0), e == null && this.repeatTo === 1 / 0 ? 1 / 0 : super.totalInputPositions(t, e);
2411
+ }
2412
+ get state() {
2413
+ return super.state;
2414
+ }
2415
+ set state(t) {
2416
+ this._blocks.length = t._blocks.length, this.mask = this.mask.slice(0, this._blocks.length), super.state = t;
2417
+ }
2418
+ }
2419
+ p.RepeatBlock = it;
2420
+ try {
2421
+ globalThis.IMask = p;
2422
+ } catch {
2423
+ }
2424
+ export {
2425
+ d as ChangeDetails,
2426
+ F as ChunksTailDetails,
2427
+ o as DIRECTION,
2428
+ j as HTMLContenteditableMaskElement,
2429
+ $ as HTMLInputMaskElement,
2430
+ y as HTMLMaskElement,
2431
+ W as InputMask,
2432
+ P as MaskElement,
2433
+ k as Masked,
2434
+ E as MaskedDate,
2435
+ M as MaskedDynamic,
2436
+ V as MaskedEnum,
2437
+ et as MaskedFunction,
2438
+ _ as MaskedNumber,
2439
+ m as MaskedPattern,
2440
+ B as MaskedRange,
2441
+ Q as MaskedRegExp,
2442
+ R as PIPE_TYPE,
2443
+ G as PatternFixedDefinition,
2444
+ b as PatternInputDefinition,
2445
+ it as RepeatBlock,
2446
+ C as createMask,
2447
+ q as createPipe,
2448
+ p as default,
2449
+ Y as forceDirection,
2450
+ x as normalizeOpts,
2451
+ st as pipe
2452
+ };