UNPKG

stone-kit

Version:
1,439 lines (1,438 loc) • 112 kB
import { jsx as et, jsxs as Vt, Fragment as ne } from "react/jsx-runtime"; import J, { forwardRef as ae } from "react"; import { g as ue, c as oe } from "../../../index-YnD2EP-S.js"; const le = "_inputWrapper_1ln65_10", he = "_inputIMask_1ln65_37", pe = "_inputWrapperPost_1ln65_41", ce = "_inputWrapperPre_1ln65_42", de = "_light_1ln65_58", fe = "_gray_1ln65_96", _e = "_dark_1ln65_128", me = "_transparent_1ln65_169", ge = "_inputWrapperError_1ln65_227", ke = "_inputWrapperErrorWithoutBorder_1ln65_241", ve = "_inputWrapperErrorDark_1ln65_252", Ee = "_checkBox_1ln65_266", M = { "auto-width": "_auto-width_1ln65_1", "full-width": "_full-width_1ln65_6", inputWrapper: le, inputIMask: he, inputWrapperPost: pe, inputWrapperPre: ce, light: de, gray: fe, dark: _e, transparent: me, inputWrapperError: ge, inputWrapperErrorWithoutBorder: ke, inputWrapperErrorDark: ve, checkBox: Ee, "tiny-size_s": "_tiny-size_s_1ln65_270", "small-size_s": "_small-size_s_1ln65_278", "medium-size_s": "_medium-size_s_1ln65_286", "large-size_s": "_large-size_s_1ln65_294", "tiny-size_m": "_tiny-size_m_1ln65_303", "small-size_m": "_small-size_m_1ln65_310", "medium-size_m": "_medium-size_m_1ln65_317", "large-size_m": "_large-size_m_1ln65_324", "tiny-size_l": "_tiny-size_l_1ln65_333", "small-size_l": "_small-size_l_1ln65_340", "medium-size_l": "_medium-size_l_1ln65_347", "large-size_l": "_large-size_l_1ln65_354" }; function G(a) { return typeof a == "string" || a instanceof String; } function Pt(a) { var t; return typeof a == "object" && a != null && (a == null || (t = a.constructor) == null ? void 0 : t.name) === "Object"; } function Gt(a, t) { return Array.isArray(t) ? Gt(a, (e, s) => t.includes(s)) : Object.entries(a).reduce((e, s) => { let [i, r] = s; return t(r, i) && (e[i] = r), e; }, {}); } const _ = { NONE: "NONE", LEFT: "LEFT", FORCE_LEFT: "FORCE_LEFT", RIGHT: "RIGHT", FORCE_RIGHT: "FORCE_RIGHT" }; function ye(a) { switch (a) { case _.LEFT: return _.FORCE_LEFT; case _.RIGHT: return _.FORCE_RIGHT; default: return a; } } function bt(a) { return a.replace(/([.*+?^=!:${}()|[\]/\\])/g, "\\$1"); } function ht(a, t) { if (t === a) return !0; const e = Array.isArray(t), s = Array.isArray(a); let i; if (e && s) { if (t.length != a.length) return !1; for (i = 0; i < t.length; i++) if (!ht(t[i], a[i])) return !1; return !0; } if (e != s) return !1; if (t && a && typeof t == "object" && typeof a == "object") { const r = t instanceof Date, n = a instanceof Date; if (r && n) return t.getTime() == a.getTime(); if (r != n) return !1; const u = t instanceof RegExp, o = a instanceof RegExp; if (u && o) return t.toString() == a.toString(); if (u != o) return !1; const h = Object.keys(t); for (i = 0; i < h.length; i++) if (!Object.prototype.hasOwnProperty.call(a, h[i])) return !1; for (i = 0; i < h.length; i++) if (!ht(a[h[i]], t[h[i]])) return !1; return !0; } else if (t && a && typeof t == "function" && typeof a == "function") return t.toString() === a.toString(); return !1; } class Ce { /** Current input value */ /** Current cursor position */ /** Old input value */ /** Old selection */ constructor(t) { for (Object.assign(this, t); this.value.slice(0, this.startChangePos) !== this.oldValue.slice(0, this.startChangePos); ) --this.oldSelection.start; if (this.insertedCount) for (; this.value.slice(this.cursorPos) !== this.oldValue.slice(this.oldSelection.end); ) this.value.length - this.cursorPos < this.oldValue.length - this.oldSelection.end ? ++this.oldSelection.end : ++this.cursorPos; } /** Start changing position */ get startChangePos() { return Math.min(this.cursorPos, this.oldSelection.start); } /** Inserted symbols count */ get insertedCount() { return this.cursorPos - this.startChangePos; } /** Inserted symbols */ get inserted() { return this.value.substr(this.startChangePos, this.insertedCount); } /** Removed symbols count */ get removedCount() { return Math.max(this.oldSelection.end - this.startChangePos || // for Delete this.oldValue.length - this.value.length, 0); } /** Removed symbols */ get removed() { return this.oldValue.substr(this.startChangePos, this.removedCount); } /** Unchanged head symbols */ get head() { return this.value.substring(0, this.startChangePos); } /** Unchanged tail symbols */ get tail() { return this.value.substring(this.startChangePos + this.insertedCount); } /** Remove direction */ get removeDirection() { return !this.removedCount || this.insertedCount ? _.NONE : (this.oldSelection.end === this.cursorPos || this.oldSelection.start === this.cursorPos) && // if not range removed (event with backspace) this.oldSelection.end === this.oldSelection.start ? _.RIGHT : _.LEFT; } } function k(a, t) { return new k.InputMask(a, t); } function Zt(a) { if (a == null) throw new Error("mask property should be defined"); return a instanceof RegExp ? k.MaskedRegExp : G(a) ? k.MaskedPattern : a === Date ? k.MaskedDate : a === Number ? k.MaskedNumber : Array.isArray(a) || a === Array ? k.MaskedDynamic : k.Masked && a.prototype instanceof k.Masked ? a : k.Masked && a instanceof k.Masked ? a.constructor : a instanceof Function ? k.MaskedFunction : (console.warn("Mask not found for mask", a), k.Masked); } function it(a) { if (!a) throw new Error("Options in not defined"); if (k.Masked) { if (a.prototype instanceof k.Masked) return { mask: a }; const { mask: t = void 0, ...e } = a instanceof k.Masked ? { mask: a } : Pt(a) && a.mask instanceof k.Masked ? a : {}; if (t) { const s = t.mask; return { ...Gt(t, (i, r) => !r.startsWith("_")), mask: t.constructor, _mask: s, ...e }; } } return Pt(a) ? { ...a } : { mask: a }; } function K(a) { if (k.Masked && a instanceof k.Masked) return a; const t = it(a), e = Zt(t.mask); if (!e) throw new Error("Masked class is not found for provided mask " + t.mask + ", appropriate module needs to be imported manually before creating mask."); return t.mask === e && delete t.mask, t._mask && (t.mask = t._mask, delete t._mask), new e(t); } k.createMask = K; class Mt { /** */ /** */ /** */ /** Safely returns selection start */ get selectionStart() { let t; try { t = this._unsafeSelectionStart; } catch { } return t ?? this.value.length; } /** Safely returns selection end */ get selectionEnd() { let t; try { t = this._unsafeSelectionEnd; } catch { } return t ?? this.value.length; } /** Safely sets element selection */ select(t, e) { if (!(t == null || e == null || t === this.selectionStart && e === this.selectionEnd)) try { this._unsafeSelect(t, e); } catch { } } /** */ get isActive() { return !1; } /** */ /** */ /** */ } k.MaskElement = Mt; const Lt = 90, Ae = 89; class ct extends Mt { /** HTMLElement to use mask on */ constructor(t) { 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); } get rootElement() { var t, e, s; return (t = (e = (s = this.input).getRootNode) == null ? void 0 : e.call(s)) != null ? t : document; } /** Is element in focus */ get isActive() { return this.input === this.rootElement.activeElement; } /** Binds HTMLElement events to mask internal events */ bindEvents(t) { 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; } _onKeydown(t) { if (this._handlers.redo && (t.keyCode === Lt && t.shiftKey && (t.metaKey || t.ctrlKey) || t.keyCode === Ae && t.ctrlKey)) return t.preventDefault(), this._handlers.redo(t); if (this._handlers.undo && t.keyCode === Lt && (t.metaKey || t.ctrlKey)) return t.preventDefault(), this._handlers.undo(t); t.isComposing || this._handlers.selectionChange(t); } _onBeforeinput(t) { if (t.inputType === "historyUndo" && this._handlers.undo) return t.preventDefault(), this._handlers.undo(t); if (t.inputType === "historyRedo" && this._handlers.redo) return t.preventDefault(), this._handlers.redo(t); } _onCompositionEnd(t) { this._handlers.input(t); } _onInput(t) { t.isComposing || this._handlers.input(t); } /** Unbinds HTMLElement events to mask internal events */ unbindEvents() { 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 = {}; } } k.HTMLMaskElement = ct; class be extends ct { /** InputElement to use mask on */ constructor(t) { super(t), this.input = t; } /** Returns InputElement selection start */ get _unsafeSelectionStart() { return this.input.selectionStart != null ? this.input.selectionStart : this.value.length; } /** Returns InputElement selection end */ get _unsafeSelectionEnd() { return this.input.selectionEnd; } /** Sets InputElement selection */ _unsafeSelect(t, e) { this.input.setSelectionRange(t, e); } get value() { return this.input.value; } set value(t) { this.input.value = t; } } k.HTMLMaskElement = ct; class Xt extends ct { /** Returns HTMLElement selection start */ get _unsafeSelectionStart() { const t = this.rootElement, e = t.getSelection && t.getSelection(), s = e && e.anchorOffset, i = e && e.focusOffset; return i == null || s == null || s < i ? s : i; } /** Returns HTMLElement selection end */ get _unsafeSelectionEnd() { const t = this.rootElement, e = t.getSelection && t.getSelection(), s = e && e.anchorOffset, i = e && e.focusOffset; return i == null || s == null || s > i ? s : i; } /** Sets HTMLElement selection */ _unsafeSelect(t, e) { if (!this.rootElement.createRange) return; const s = this.rootElement.createRange(); s.setStart(this.input.firstChild || this.input, t), s.setEnd(this.input.lastChild || this.input, e); const i = this.rootElement, r = i.getSelection && i.getSelection(); r && (r.removeAllRanges(), r.addRange(s)); } /** HTMLElement value */ get value() { return this.input.textContent || ""; } set value(t) { this.input.textContent = t; } } k.HTMLContenteditableMaskElement = Xt; class dt { constructor() { this.states = [], this.currentIndex = 0; } get currentState() { return this.states[this.currentIndex]; } get isEmpty() { return this.states.length === 0; } push(t) { this.currentIndex < this.states.length - 1 && (this.states.length = this.currentIndex + 1), this.states.push(t), this.states.length > dt.MAX_LENGTH && this.states.shift(), this.currentIndex = this.states.length - 1; } go(t) { return this.currentIndex = Math.min(Math.max(this.currentIndex + t, 0), this.states.length - 1), this.currentState; } undo() { return this.go(-1); } redo() { return this.go(1); } clear() { this.states.length = 0, this.currentIndex = 0; } } dt.MAX_LENGTH = 100; class xe { /** View element */ /** Internal {@link Masked} model */ constructor(t, e) { this.el = t instanceof Mt ? t : t.isContentEditable && t.tagName !== "INPUT" && t.tagName !== "TEXTAREA" ? new Xt(t) : new be(t), this.masked = K(e), this._listeners = {}, this._value = "", this._unmaskedValue = "", this._rawInputValue = "", this.history = new dt(), 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(); } maskEquals(t) { var e; return t == null || ((e = this.masked) == null ? void 0 : e.maskEquals(t)); } /** Masked */ get mask() { return this.masked.mask; } set mask(t) { if (this.maskEquals(t)) return; if (!(t instanceof k.Masked) && this.masked.constructor === Zt(t)) { this.masked.updateOptions({ mask: t }); return; } const e = t instanceof k.Masked ? t : K({ mask: t }); e.unmaskedValue = this.masked.unmaskedValue, this.masked = e; } /** Raw value */ get value() { return this._value; } set value(t) { this.value !== t && (this.masked.value = t, this.updateControl("auto")); } /** Unmasked value */ get unmaskedValue() { return this._unmaskedValue; } set unmaskedValue(t) { this.unmaskedValue !== t && (this.masked.unmaskedValue = t, this.updateControl("auto")); } /** Raw input value */ get rawInputValue() { return this._rawInputValue; } set rawInputValue(t) { this.rawInputValue !== t && (this.masked.rawInputValue = t, this.updateControl(), this.alignCursor()); } /** Typed unmasked value */ get typedValue() { return this.masked.typedValue; } set typedValue(t) { this.masked.typedValueEquals(t) || (this.masked.typedValue = t, this.updateControl("auto")); } /** Display value */ get displayValue() { return this.masked.displayValue; } /** Starts listening to element events */ _bindEvents() { this.el.bindEvents({ selectionChange: this._saveSelection, input: this._onInput, drop: this._onDrop, click: this._onClick, focus: this._onFocus, commit: this._onChange, undo: this._onUndo, redo: this._onRedo }); } /** Stops listening to element events */ _unbindEvents() { this.el && this.el.unbindEvents(); } /** Fires custom event */ _fireEvent(t, e) { const s = this._listeners[t]; s && s.forEach((i) => i(e)); } /** Current selection start */ get selectionStart() { return this._cursorChanging ? this._changingCursorPos : this.el.selectionStart; } /** Current cursor position */ get cursorPos() { return this._cursorChanging ? this._changingCursorPos : this.el.selectionEnd; } set cursorPos(t) { !this.el || !this.el.isActive || (this.el.select(t, t), this._saveSelection()); } /** Stores current selection */ _saveSelection() { this.displayValue !== this.el.value && console.warn("Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly."), this._selection = { start: this.selectionStart, end: this.cursorPos }; } /** Syncronizes model value from view */ updateValue() { this.masked.value = this.el.value, this._value = this.masked.value, this._unmaskedValue = this.masked.unmaskedValue, this._rawInputValue = this.masked.rawInputValue; } /** Syncronizes view from model value, fires change events */ updateControl(t) { const e = this.masked.unmaskedValue, s = this.masked.value, i = this.masked.rawInputValue, r = this.displayValue, n = this.unmaskedValue !== e || this.value !== s || this._rawInputValue !== i; this._unmaskedValue = e, this._value = s, this._rawInputValue = i, this.el.value !== r && (this.el.value = r), t === "auto" ? this.alignCursor() : t != null && (this.cursorPos = t), n && this._fireChangeEvents(), !this._historyChanging && (n || this.history.isEmpty) && this.history.push({ unmaskedValue: e, selection: { start: this.selectionStart, end: this.cursorPos } }); } /** Updates options with deep equal check, recreates {@link Masked} model if mask type changes */ updateOptions(t) { const { mask: e, ...s } = t, i = !this.maskEquals(e), r = this.masked.optionsIsChanged(s); i && (this.mask = e), r && this.masked.updateOptions(s), (i || r) && this.updateControl(); } /** Updates cursor */ updateCursor(t) { t != null && (this.cursorPos = t, this._delayUpdateCursor(t)); } /** Delays cursor update to support mobile browsers */ _delayUpdateCursor(t) { this._abortUpdateCursor(), this._changingCursorPos = t, this._cursorChanging = setTimeout(() => { this.el && (this.cursorPos = this._changingCursorPos, this._abortUpdateCursor()); }, 10); } /** Fires custom events */ _fireChangeEvents() { this._fireEvent("accept", this._inputEvent), this.masked.isComplete && this._fireEvent("complete", this._inputEvent); } /** Aborts delayed cursor update */ _abortUpdateCursor() { this._cursorChanging && (clearTimeout(this._cursorChanging), delete this._cursorChanging); } /** Aligns cursor to nearest available position */ alignCursor() { this.cursorPos = this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos, _.LEFT)); } /** Aligns cursor only if selection is empty */ alignCursorFriendly() { this.selectionStart === this.cursorPos && this.alignCursor(); } /** Adds listener on custom event */ on(t, e) { return this._listeners[t] || (this._listeners[t] = []), this._listeners[t].push(e), this; } /** Removes custom event listener */ off(t, e) { if (!this._listeners[t]) return this; if (!e) return delete this._listeners[t], this; const s = this._listeners[t].indexOf(e); return s >= 0 && this._listeners[t].splice(s, 1), this; } /** Handles view input event */ _onInput(t) { this._inputEvent = t, this._abortUpdateCursor(); const e = new Ce({ // new state value: this.el.value, cursorPos: this.cursorPos, // old state oldValue: this.displayValue, oldSelection: this._selection }), s = this.masked.rawInputValue, i = this.masked.splice(e.startChangePos, e.removed.length, e.inserted, e.removeDirection, { input: !0, raw: !0 }).offset, r = s === this.masked.rawInputValue ? e.removeDirection : _.NONE; let n = this.masked.nearestInputPos(e.startChangePos + i, r); r !== _.NONE && (n = this.masked.nearestInputPos(n, _.NONE)), this.updateControl(n), delete this._inputEvent; } /** Handles view change event and commits model value */ _onChange() { this.displayValue !== this.el.value && this.updateValue(), this.masked.doCommit(), this.updateControl(), this._saveSelection(); } /** Handles view drop event, prevents by default */ _onDrop(t) { t.preventDefault(), t.stopPropagation(); } /** Restore last selection on focus */ _onFocus(t) { this.alignCursorFriendly(); } /** Restore last selection on focus */ _onClick(t) { this.alignCursorFriendly(); } _onUndo() { this._applyHistoryState(this.history.undo()); } _onRedo() { this._applyHistoryState(this.history.redo()); } _applyHistoryState(t) { t && (this._historyChanging = !0, this.unmaskedValue = t.unmaskedValue, this.el.select(t.selection.start, t.selection.end), this._saveSelection(), this._historyChanging = !1); } /** Unbind view events and removes element reference */ destroy() { this._unbindEvents(), this._listeners.length = 0, delete this.el; } } k.InputMask = xe; class E { /** Inserted symbols */ /** Additional offset if any changes occurred before tail */ /** Raw inserted is used by dynamic mask */ /** Can skip chars */ static normalize(t) { return Array.isArray(t) ? t : [t, new E()]; } constructor(t) { Object.assign(this, { inserted: "", rawInserted: "", tailShift: 0, skip: !1 }, t); } /** Aggregate changes */ aggregate(t) { return this.inserted += t.inserted, this.rawInserted += t.rawInserted, this.tailShift += t.tailShift, this.skip = this.skip || t.skip, this; } /** Total offset considering all changes */ get offset() { return this.tailShift + this.inserted.length; } get consumed() { return !!this.rawInserted || this.skip; } equals(t) { return this.inserted === t.inserted && this.tailShift === t.tailShift && this.rawInserted === t.rawInserted && this.skip === t.skip; } } k.ChangeDetails = E; class Y { /** Tail value as string */ /** Tail start position */ /** Start position */ constructor(t, e, s) { t === void 0 && (t = ""), e === void 0 && (e = 0), this.value = t, this.from = e, this.stop = s; } toString() { return this.value; } extend(t) { this.value += String(t); } appendTo(t) { return t.append(this.toString(), { tail: !0 }).aggregate(t._appendPlaceholder()); } get state() { return { value: this.value, from: this.from, stop: this.stop }; } set state(t) { Object.assign(this, t); } unshift(t) { if (!this.value.length || t != null && this.from >= t) return ""; const e = this.value[0]; return this.value = this.value.slice(1), e; } shift() { if (!this.value.length) return ""; const t = this.value[this.value.length - 1]; return this.value = this.value.slice(0, -1), t; } } class L { /** */ /** */ /** Transforms value before mask processing */ /** Transforms each char before mask processing */ /** Validates if value is acceptable */ /** Does additional processing at the end of editing */ /** Format typed value to string */ /** Parse string to get typed value */ /** Enable characters overwriting */ /** */ /** */ /** */ /** */ constructor(t) { this._value = "", this._update({ ...L.DEFAULTS, ...t }), this._initialized = !0; } /** Sets and applies new options */ updateOptions(t) { this.optionsIsChanged(t) && this.withValueRefresh(this._update.bind(this, t)); } /** Sets new options */ _update(t) { Object.assign(this, t); } /** Mask state */ get state() { return { _value: this.value, _rawInputValue: this.rawInputValue }; } set state(t) { this._value = t._value; } /** Resets value */ reset() { this._value = ""; } get value() { return this._value; } set value(t) { this.resolve(t, { input: !0 }); } /** Resolve new value */ resolve(t, e) { e === void 0 && (e = { input: !0 }), this.reset(), this.append(t, e, ""), this.doCommit(); } get unmaskedValue() { return this.value; } set unmaskedValue(t) { this.resolve(t, {}); } get typedValue() { return this.parse ? this.parse(this.value, this) : this.unmaskedValue; } set typedValue(t) { this.format ? this.value = this.format(t, this) : this.unmaskedValue = String(t); } /** Value that includes raw user input */ get rawInputValue() { return this.extractInput(0, this.displayValue.length, { raw: !0 }); } set rawInputValue(t) { this.resolve(t, { raw: !0 }); } get displayValue() { return this.value; } get isComplete() { return !0; } get isFilled() { return this.isComplete; } /** Finds nearest input position in direction */ nearestInputPos(t, e) { return t; } totalInputPositions(t, e) { return t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), Math.min(this.displayValue.length, e - t); } /** Extracts value in range considering flags */ extractInput(t, e, s) { return t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), this.displayValue.slice(t, e); } /** Extracts tail in range */ extractTail(t, e) { return t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), new Y(this.extractInput(t, e), t); } /** Appends tail */ appendTail(t) { return G(t) && (t = new Y(String(t))), t.appendTo(this); } /** Appends char */ _appendCharRaw(t, e) { return t ? (this._value += t, new E({ inserted: t, rawInserted: t })) : new E(); } /** Appends char */ _appendChar(t, e, s) { e === void 0 && (e = {}); const i = this.state; let r; if ([t, r] = this.doPrepareChar(t, e), t && (r = r.aggregate(this._appendCharRaw(t, e)), !r.rawInserted && this.autofix === "pad")) { const n = this.state; this.state = i; let u = this.pad(e); const o = this._appendCharRaw(t, e); u = u.aggregate(o), o.rawInserted || u.equals(r) ? r = u : this.state = n; } if (r.inserted) { let n, u = this.doValidate(e) !== !1; if (u && s != null) { const o = this.state; if (this.overwrite === !0) { n = s.state; for (let m = 0; m < r.rawInserted.length; ++m) s.unshift(this.displayValue.length - r.tailShift); } let h = this.appendTail(s); if (u = h.rawInserted.length === s.toString().length, !(u && h.inserted) && this.overwrite === "shift") { this.state = o, n = s.state; for (let m = 0; m < r.rawInserted.length; ++m) s.shift(); h = this.appendTail(s), u = h.rawInserted.length === s.toString().length; } u && h.inserted && (this.state = o); } u || (r = new E(), this.state = i, s && n && (s.state = n)); } return r; } /** Appends optional placeholder at the end */ _appendPlaceholder() { return new E(); } /** Appends optional eager placeholder at the end */ _appendEager() { return new E(); } /** Appends symbols considering flags */ append(t, e, s) { if (!G(t)) throw new Error("value should be string"); const i = G(s) ? new Y(String(s)) : s; e != null && e.tail && (e._beforeTailState = this.state); let r; [t, r] = this.doPrepare(t, e); for (let n = 0; n < t.length; ++n) { const u = this._appendChar(t[n], e, i); if (!u.rawInserted && !this.doSkipInvalid(t[n], e, i)) break; r.aggregate(u); } return (this.eager === !0 || this.eager === "append") && e != null && e.input && t && r.aggregate(this._appendEager()), i != null && (r.tailShift += this.appendTail(i).tailShift), r; } remove(t, e) { 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 E(); } /** Calls function and reapplies current value */ withValueRefresh(t) { if (this._refreshing || !this._initialized) return t(); this._refreshing = !0; const e = this.rawInputValue, s = this.value, i = t(); 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; } runIsolated(t) { if (this._isolated || !this._initialized) return t(this); this._isolated = !0; const e = this.state, s = t(this); return this.state = e, delete this._isolated, s; } doSkipInvalid(t, e, s) { return !!this.skipInvalid; } /** Prepares string before mask processing */ doPrepare(t, e) { return e === void 0 && (e = {}), E.normalize(this.prepare ? this.prepare(t, this, e) : t); } /** Prepares each char before mask processing */ doPrepareChar(t, e) { return e === void 0 && (e = {}), E.normalize(this.prepareChar ? this.prepareChar(t, this, e) : t); } /** Validates if value is acceptable */ doValidate(t) { return (!this.validate || this.validate(this.value, this, t)) && (!this.parent || this.parent.doValidate(t)); } /** Does additional processing at the end of editing */ doCommit() { this.commit && this.commit(this.value, this); } splice(t, e, s, i, r) { s === void 0 && (s = ""), i === void 0 && (i = _.NONE), r === void 0 && (r = { input: !0 }); const n = t + e, u = this.extractTail(n), o = this.eager === !0 || this.eager === "remove"; let h; o && (i = ye(i), h = this.extractInput(0, n, { raw: !0 })); let m = t; const g = new E(); if (i !== _.NONE && (m = this.nearestInputPos(t, e > 1 && t !== 0 && !o ? _.NONE : i), g.tailShift = m - t), g.aggregate(this.remove(m)), o && i !== _.NONE && h === this.rawInputValue) if (i === _.FORCE_LEFT) { let y; for (; h === this.rawInputValue && (y = this.displayValue.length); ) g.aggregate(new E({ tailShift: -1 })).aggregate(this.remove(y - 1)); } else i === _.FORCE_RIGHT && u.unshift(); return g.aggregate(this.append(s, r, u)); } maskEquals(t) { return this.mask === t; } optionsIsChanged(t) { return !ht(this, t); } typedValueEquals(t) { const e = this.typedValue; return t === e || L.EMPTY_VALUES.includes(t) && L.EMPTY_VALUES.includes(e) || (this.format ? this.format(t, this) === this.format(this.typedValue, this) : !1); } pad(t) { return new E(); } } L.DEFAULTS = { skipInvalid: !0 }; L.EMPTY_VALUES = [void 0, null, ""]; k.Masked = L; class Q { /** */ constructor(t, e) { t === void 0 && (t = []), e === void 0 && (e = 0), this.chunks = t, this.from = e; } toString() { return this.chunks.map(String).join(""); } extend(t) { if (!String(t)) return; t = G(t) ? new Y(String(t)) : t; const e = this.chunks[this.chunks.length - 1], s = e && // if stops are same or tail has no stop (e.stop === t.stop || t.stop == null) && // if tail chunk goes just after last chunk t.from === e.from + e.toString().length; if (t instanceof Y) s ? e.extend(t.toString()) : this.chunks.push(t); else if (t instanceof Q) { if (t.stop == null) { let i; for (; t.chunks.length && t.chunks[0].stop == null; ) i = t.chunks.shift(), i.from += t.from, this.extend(i); } t.toString() && (t.stop = t.blockIndex, this.chunks.push(t)); } } appendTo(t) { if (!(t instanceof k.MaskedPattern)) return new Y(this.toString()).appendTo(t); const e = new E(); for (let s = 0; s < this.chunks.length; ++s) { const i = this.chunks[s], r = t._mapPosToBlock(t.displayValue.length), n = i.stop; let u; if (n != null && // if block not found or stop is behind lastBlock (!r || r.index <= n) && ((i instanceof Q || // for continuous block also check if stop is exist t._stops.indexOf(n) >= 0) && e.aggregate(t._appendPlaceholder(n)), u = i instanceof Q && t._blocks[n]), u) { const o = u.appendTail(i); e.aggregate(o); const h = i.toString().slice(o.rawInserted.length); h && e.aggregate(t.append(h, { tail: !0 })); } else e.aggregate(t.append(i.toString(), { tail: !0 })); } return e; } get state() { return { chunks: this.chunks.map((t) => t.state), from: this.from, stop: this.stop, blockIndex: this.blockIndex }; } set state(t) { const { chunks: e, ...s } = t; Object.assign(this, s), this.chunks = e.map((i) => { const r = "chunks" in i ? new Q() : new Y(); return r.state = i, r; }); } unshift(t) { if (!this.chunks.length || t != null && this.from >= t) return ""; const e = t != null ? t - this.from : t; let s = 0; for (; s < this.chunks.length; ) { const i = this.chunks[s], r = i.unshift(e); if (i.toString()) { if (!r) break; ++s; } else this.chunks.splice(s, 1); if (r) return r; } return ""; } shift() { if (!this.chunks.length) return ""; let t = this.chunks.length - 1; for (; 0 <= t; ) { const e = this.chunks[t], s = e.shift(); if (e.toString()) { if (!s) break; --t; } else this.chunks.splice(t, 1); if (s) return s; } return ""; } } class Fe { constructor(t, e) { this.masked = t, this._log = []; const { offset: s, index: i } = t._mapPosToBlock(e) || (e < 0 ? ( // first { index: 0, offset: 0 } ) : ( // last { index: this.masked._blocks.length, offset: 0 } )); this.offset = s, this.index = i, this.ok = !1; } get block() { return this.masked._blocks[this.index]; } get pos() { return this.masked._blockStartPos(this.index) + this.offset; } get state() { return { index: this.index, offset: this.offset, ok: this.ok }; } set state(t) { Object.assign(this, t); } pushState() { this._log.push(this.state); } popState() { const t = this._log.pop(); return t && (this.state = t), t; } bindBlock() { 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)); } _pushLeft(t) { for (this.pushState(), this.bindBlock(); 0 <= this.index; --this.index, this.offset = ((e = this.block) == null ? void 0 : e.displayValue.length) || 0) { var e; if (t()) return this.ok = !0; } return this.ok = !1; } _pushRight(t) { for (this.pushState(), this.bindBlock(); this.index < this.masked._blocks.length; ++this.index, this.offset = 0) if (t()) return this.ok = !0; return this.ok = !1; } pushLeftBeforeFilled() { return this._pushLeft(() => { if (!(this.block.isFixed || !this.block.value) && (this.offset = this.block.nearestInputPos(this.offset, _.FORCE_LEFT), this.offset !== 0)) return !0; }); } pushLeftBeforeInput() { return this._pushLeft(() => { if (!this.block.isFixed) return this.offset = this.block.nearestInputPos(this.offset, _.LEFT), !0; }); } pushLeftBeforeRequired() { return this._pushLeft(() => { if (!(this.block.isFixed || this.block.isOptional && !this.block.value)) return this.offset = this.block.nearestInputPos(this.offset, _.LEFT), !0; }); } pushRightBeforeFilled() { return this._pushRight(() => { if (!(this.block.isFixed || !this.block.value) && (this.offset = this.block.nearestInputPos(this.offset, _.FORCE_RIGHT), this.offset !== this.block.value.length)) return !0; }); } pushRightBeforeInput() { return this._pushRight(() => { if (!this.block.isFixed) return this.offset = this.block.nearestInputPos(this.offset, _.NONE), !0; }); } pushRightBeforeRequired() { return this._pushRight(() => { if (!(this.block.isFixed || this.block.isOptional && !this.block.value)) return this.offset = this.block.nearestInputPos(this.offset, _.NONE), !0; }); } } class Jt { /** */ /** */ /** */ /** */ /** */ /** */ constructor(t) { Object.assign(this, t), this._value = "", this.isFixed = !0; } get value() { return this._value; } get unmaskedValue() { return this.isUnmasking ? this.value : ""; } get rawInputValue() { return this._isRawInput ? this.value : ""; } get displayValue() { return this.value; } reset() { this._isRawInput = !1, this._value = ""; } remove(t, e) { 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 E(); } nearestInputPos(t, e) { e === void 0 && (e = _.NONE); const s = 0, i = this._value.length; switch (e) { case _.LEFT: case _.FORCE_LEFT: return s; case _.NONE: case _.RIGHT: case _.FORCE_RIGHT: default: return i; } } totalInputPositions(t, e) { return t === void 0 && (t = 0), e === void 0 && (e = this._value.length), this._isRawInput ? e - t : 0; } extractInput(t, e, s) { 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) || ""; } get isComplete() { return !0; } get isFilled() { return !!this._value; } _appendChar(t, e) { if (e === void 0 && (e = {}), this.isFilled) return new E(); const s = this.eager === !0 || this.eager === "append", r = this.char === t && (this.isUnmasking || e.input || e.raw) && (!e.raw || !s) && !e.tail, n = new E({ inserted: this.char, rawInserted: r ? this.char : "" }); return this._value = this.char, this._isRawInput = r && (e.raw || e.input), n; } _appendEager() { return this._appendChar(this.char, { tail: !0 }); } _appendPlaceholder() { const t = new E(); return this.isFilled || (this._value = t.inserted = this.char), t; } extractTail() { return new Y(""); } appendTail(t) { return G(t) && (t = new Y(String(t))), t.appendTo(this); } append(t, e, s) { const i = this._appendChar(t[0], e); return s != null && (i.tailShift += this.appendTail(s).tailShift), i; } doCommit() { } get state() { return { _value: this._value, _rawInputValue: this.rawInputValue }; } set state(t) { this._value = t._value, this._isRawInput = !!t._rawInputValue; } pad(t) { return this._appendPlaceholder(); } } class pt { /** */ /** */ /** */ /** */ /** */ /** */ /** */ /** */ constructor(t) { const { parent: e, isOptional: s, placeholderChar: i, displayChar: r, lazy: n, eager: u, ...o } = t; this.masked = K(o), Object.assign(this, { parent: e, isOptional: s, placeholderChar: i, displayChar: r, lazy: n, eager: u }); } reset() { this.isFilled = !1, this.masked.reset(); } remove(t, e) { 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 E(); } get value() { return this.masked.value || (this.isFilled && !this.isOptional ? this.placeholderChar : ""); } get unmaskedValue() { return this.masked.unmaskedValue; } get rawInputValue() { return this.masked.rawInputValue; } get displayValue() { return this.masked.value && this.displayChar || this.value; } get isComplete() { return !!this.masked.value || this.isOptional; } _appendChar(t, e) { if (e === void 0 && (e = {}), this.isFilled) return new E(); const s = this.masked.state; let i = this.masked._appendChar(t, this.currentMaskFlags(e)); return i.inserted && this.doValidate(e) === !1 && (i = new E(), 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; } append(t, e, s) { return this.masked.append(t, this.currentMaskFlags(e), s); } _appendPlaceholder() { return this.isFilled || this.isOptional ? new E() : (this.isFilled = !0, new E({ inserted: this.placeholderChar })); } _appendEager() { return new E(); } extractTail(t, e) { return this.masked.extractTail(t, e); } appendTail(t) { return this.masked.appendTail(t); } extractInput(t, e, s) { return t === void 0 && (t = 0), e === void 0 && (e = this.value.length), this.masked.extractInput(t, e, s); } nearestInputPos(t, e) { e === void 0 && (e = _.NONE); const s = 0, i = this.value.length, r = Math.min(Math.max(t, s), i); switch (e) { case _.LEFT: case _.FORCE_LEFT: return this.isComplete ? r : s; case _.RIGHT: case _.FORCE_RIGHT: return this.isComplete ? r : i; case _.NONE: default: return r; } } totalInputPositions(t, e) { return t === void 0 && (t = 0), e === void 0 && (e = this.value.length), this.value.slice(t, e).length; } doValidate(t) { return this.masked.doValidate(this.currentMaskFlags(t)) && (!this.parent || this.parent.doValidate(this.currentMaskFlags(t))); } doCommit() { this.masked.doCommit(); } get state() { return { _value: this.value, _rawInputValue: this.rawInputValue, masked: this.masked.state, isFilled: this.isFilled }; } set state(t) { this.masked.state = t.masked, this.isFilled = t.isFilled; } currentMaskFlags(t) { var e; return { ...t, _beforeTailState: (t == null || (e = t._beforeTailState) == null ? void 0 : e.masked) || t?._beforeTailState }; } pad(t) { return new E(); } } pt.DEFAULT_DEFINITIONS = { 0: /\d/, 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]/, // http://stackoverflow.com/a/22075070 "*": /./ }; class Se extends L { /** */ /** Enable characters overwriting */ /** */ /** */ /** */ updateOptions(t) { super.updateOptions(t); } _update(t) { const e = t.mask; e && (t.validate = (s) => s.search(e) >= 0), super._update(t); } } k.MaskedRegExp = Se; class N extends L { /** */ /** */ /** Single char for empty input */ /** Single char for filled input */ /** Show placeholder only when needed */ /** Enable characters overwriting */ /** */ /** */ /** */ constructor(t) { super({ ...N.DEFAULTS, ...t, definitions: Object.assign({}, pt.DEFAULT_DEFINITIONS, t?.definitions) }); } updateOptions(t) { super.updateOptions(t); } _update(t) { t.definitions = Object.assign({}, this.definitions, t.definitions), super._update(t), this._rebuildMask(); } _rebuildMask() { const t = this.definitions; this._blocks = [], this.exposeBlock = void 0, this._stops = [], this._maskedBlocks = {}; const e = this.mask; if (!e || !t) return; let s = !1, i = !1; for (let r = 0; r < e.length; ++r) { if (this.blocks) { const h = e.slice(r), m = Object.keys(this.blocks).filter((y) => h.indexOf(y) === 0); m.sort((y, O) => O.length - y.length); const g = m[0]; if (g) { const { expose: y, repeat: O, ...j } = it(this.blocks[g]), B = { lazy: this.lazy, eager: this.eager, placeholderChar: this.placeholderChar, displayChar: this.displayChar, overwrite: this.overwrite, autofix: this.autofix, ...j, repeat: O, parent: this }, D = O != null ? new k.RepeatBlock( B /* TODO */ ) : K(B); D && (this._blocks.push(D), y && (this.exposeBlock = D), this._maskedBlocks[g] || (this._maskedBlocks[g] = []), this._maskedBlocks[g].push(this._blocks.length - 1)), r += g.length - 1; continue; } } let n = e[r], u = n in t; if (n === N.STOP_CHAR) { this._stops.push(this._blocks.length); continue; } if (n === "{" || n === "}") { s = !s; continue; } if (n === "[" || n === "]") { i = !i; continue; } if (n === N.ESCAPE_CHAR) { if (++r, n = e[r], !n) break; u = !1; } const o = u ? new pt({ isOptional: i, lazy: this.lazy, eager: this.eager, placeholderChar: this.placeholderChar, displayChar: this.displayChar, ...it(t[n]), parent: this }) : new Jt({ char: n, eager: this.eager, isUnmasking: s }); this._blocks.push(o); } } get state() { return { ...super.state, _blocks: this._blocks.map((t) => t.state) }; } set state(t) { if (!t) { this.reset(); return; } const { _blocks: e, ...s } = t; this._blocks.forEach((i, r) => i.state = e[r]), super.state = s; } reset() { super.reset(), this._blocks.forEach((t) => t.reset()); } get isComplete() { return this.exposeBlock ? this.exposeBlock.isComplete : this._blocks.every((t) => t.isComplete); } get isFilled() { return this._blocks.every((t) => t.isFilled); } get isFixed() { return this._blocks.every((t) => t.isFixed); } get isOptional() { return this._blocks.every((t) => t.isOptional); } doCommit() { this._blocks.forEach((t) => t.doCommit()), super.doCommit(); } get unmaskedValue() { return this.exposeBlock ? this.exposeBlock.unmaskedValue : this._blocks.reduce((t, e) => t += e.unmaskedValue, ""); } set unmaskedValue(t) { if (this.exposeBlock) { const e = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length); this.exposeBlock.unmaskedValue = t, this.appendTail(e), this.doCommit(); } else super.unmaskedValue = t; } get value() { return this.exposeBlock ? this.exposeBlock.value : ( // TODO return _value when not in change? this._blocks.reduce((t, e) => t += e.value, "") ); } set value(t) { if (this.exposeBlock) {