(); return; } const { _blocks: t, ...o } = e; this._blocks.forEach((i, r) => i.state = t[r]), super.state = o; } reset() { super.reset(), this._blocks.forEach((e) => e.reset()); } get isComplete() { return this.exposeBlock ? this.exposeBlock.isComplete : this._blocks.every((e) => e.isComplete); } get isFilled() { return this._blocks.every((e) => e.isFilled); } get isFixed() { return this._blocks.every((e) => e.isFixed); } get isOptional() { return this._blocks.every((e) => e.isOptional); } doCommit() { this._blocks.forEach((e) => e.doCommit()), super.doCommit(); } get unmaskedValue() { return this.exposeBlock ? this.exposeBlock.unmaskedValue : this._blocks.reduce((e, t) => e += t.unmaskedValue, ""); } set unmaskedValue(e) { if (this.exposeBlock) { const t = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length); this.exposeBlock.unmaskedValue = e, this.appendTail(t), this.doCommit(); } else super.unmaskedValue = e; } get value() { return this.exposeBlock ? this.exposeBlock.value : ( // TODO return _value when not in change? this._blocks.reduce((e, t) => e += t.value, "") ); } set value(e) { if (this.exposeBlock) { const t = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length); this.exposeBlock.value = e, this.appendTail(t), this.doCommit(); } else super.value = e; } get typedValue() { return this.exposeBlock ? this.exposeBlock.typedValue : super.typedValue; } set typedValue(e) { if (this.exposeBlock) { const t = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length); this.exposeBlock.typedValue = e, this.appendTail(t), this.doCommit(); } else super.typedValue = e; } get displayValue() { return this._blocks.reduce((e, t) => e += t.displayValue, ""); } appendTail(e) { return super.appendTail(e).aggregate(this._appendPlaceholder()); } _appendEager() { var e; const t = new I(); let o = (e = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : e.index; if (o == null) return t; this._blocks[o].isFilled && ++o; for (let i = o; i < this._blocks.length; ++i) { const r = this._blocks[i]._appendEager(); if (!r.inserted) break; t.aggregate(r); } return t; } _appendCharRaw(e, t) { t === void 0 && (t = {}); const o = this._mapPosToBlock(this.displayValue.length), i = new I(); if (!o) return i; for (let n = o.index, c; c = this._blocks[n]; ++n) { var r; const m = c._appendChar(e, { ...t, _beforeTailState: (r = t._beforeTailState) == null || (r = r._blocks) == null ? void 0 : r[n] }); if (i.aggregate(m), m.consumed) break; } return i; } extractTail(e, t) { e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length); const o = new ro(); return e === t || this._forEachBlocksInRange(e, t, (i, r, n, c) => { const m = i.extractTail(n, c); m.stop = this._findStopBefore(r), m.from = this._blockStartPos(r), m instanceof ro && (m.blockIndex = r), o.extend(m); }), o; } extractInput(e, t, o) { if (e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), o === void 0 && (o = {}), e === t) return ""; let i = ""; return this._forEachBlocksInRange(e, t, (r, n, c, m) => { i += r.extractInput(c, m, o); }), i; } _findStopBefore(e) { let t; for (let o = 0; o < this._stops.length; ++o) { const i = this._stops[o]; if (i <= e) t = i; else break; } return t; } /** Appends placeholder depending on laziness */ _appendPlaceholder(e) { const t = new I(); if (this.lazy && e == null) return t; const o = this._mapPosToBlock(this.displayValue.length); if (!o) return t; const i = o.index, r = e ?? this._blocks.length; return this._blocks.slice(i, r).forEach((n) => { if (!n.lazy || e != null) { var c; t.aggregate(n._appendPlaceholder((c = n._blocks) == null ? void 0 : c.length)); } }), t; } /** Finds block in pos */ _mapPosToBlock(e) { let t = ""; for (let o = 0; o < this._blocks.length; ++o) { const i = this._blocks[o], r = t.length; if (t += i.displayValue, e <= t.length) return { index: o, offset: e - r }; } } _blockStartPos(e) { return this._blocks.slice(0, e).reduce((t, o) => t += o.displayValue.length, 0); } _forEachBlocksInRange(e, t, o) { t === void 0 && (t = this.displayValue.length); const i = this._mapPosToBlock(e); if (i) { const r = this._mapPosToBlock(t), n = r && i.index === r.index, c = i.offset, m = r && n ? r.offset : this._blocks[i.index].displayValue.length; if (o(this._blocks[i.index], i.index, c, m), r && !n) { for (let g = i.index + 1; g < r.index; ++g) o(this._blocks[g], g, 0, this._blocks[g].displayValue.length); o(this._blocks[r.index], r.index, 0, r.offset); } } } remove(e, t) { e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length); const o = super.remove(e, t); return this._forEachBlocksInRange(e, t, (i, r, n, c) => { o.aggregate(i.remove(n, c)); }), o; } nearestInputPos(e, t) { if (t === void 0 && (t = B.NONE), !this._blocks.length) return 0; const o = new Rf(this, e); if (t === B.NONE) return o.pushRightBeforeInput() || (o.popState(), o.pushLeftBeforeInput()) ? o.pos : this.displayValue.length; if (t === B.LEFT || t === B.FORCE_LEFT) { if (t === B.LEFT) { if (o.pushRightBeforeFilled(), o.ok && o.pos === e) return e; o.popState(); } if (o.pushLeftBeforeInput(), o.pushLeftBeforeRequired(), o.pushLeftBeforeFilled(), t === B.LEFT) { if (o.pushRightBeforeInput(), o.pushRightBeforeRequired(), o.ok && o.pos <= e || (o.popState(), o.ok && o.pos <= e)) return o.pos; o.popState(); } return o.ok ? o.pos : t === B.FORCE_LEFT ? 0 : (o.popState(), o.ok || (o.popState(), o.ok) ? o.pos : 0); } return t === B.RIGHT || t === B.FORCE_RIGHT ? (o.pushRightBeforeInput(), o.pushRightBeforeRequired(), o.pushRightBeforeFilled() ? o.pos : t === B.FORCE_RIGHT ? this.displayValue.length : (o.popState(), o.ok || (o.popState(), o.ok) ? o.pos : this.nearestInputPos(e, B.LEFT))) : e; } totalInputPositions(e, t) { e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length); let o = 0; return this._forEachBlocksInRange(e, t, (i, r, n, c) => { o += i.totalInputPositions(n, c); }), o; } /** Get block by name */ maskedBlock(e) { return this.maskedBlocks(e)[0]; } /** Get all blocks by name */ maskedBlocks(e) { const t = this._maskedBlocks[e]; return t ? t.map((o) => this._blocks[o]) : []; } pad(e) { const t = new I(); return this._forEachBlocksInRange(0, this.displayValue.length, (o) => t.aggregate(o.pad(e))), t; } } de.DEFAULTS = { ...ce.DEFAULTS, lazy: !0, placeholderChar: "_" }; de.STOP_CHAR = "`"; de.ESCAPE_CHAR = "\\"; de.InputDefinition = sa; de.FixedDefinition = Bs; z.MaskedPattern = de; class Ki extends de { /** Optionally sets max length of pattern. Used when pattern length is longer then `to` param length. Pads zeros at start in this case. */ /** Min bound */ /** Max bound */ get _matchFrom() { return this.maxLength - String(this.from).length; } constructor(e) { super(e); } updateOptions(e) { super.updateOptions(e); } _update(e) { const { to: t = this.to || 0, from: o = this.from || 0, maxLength: i = this.maxLength || 0, autofix: r = this.autofix, ...n } = e; this.to = t, this.from = o, this.maxLength = Math.max(String(t).length, i), this.autofix = r; const c = String(this.from).padStart(this.maxLength, "0"), m = String(this.to).padStart(this.maxLength, "0"); let g = 0; for (; g < m.length && m[g] === c[g]; ) ++g; n.mask = m.slice(0, g).replace(/0/g, "\\0") + "0".repeat(this.maxLength - g), super._update(n); } get isComplete() { return super.isComplete && !!this.value; } boundaries(e) { let t = "", o = ""; const [, i, r] = e.match(/^(\D*)(\d*)(\D*)/) || []; return r && (t = "0".repeat(i.length) + r, o = "9".repeat(i.length) + r), t = t.padEnd(this.maxLength, "0"), o = o.padEnd(this.maxLength, "9"), [t, o]; } doPrepareChar(e, t) { t === void 0 && (t = {}); let o; return [e, o] = super.doPrepareChar(e.replace(/\D/g, ""), t), e || (o.skip = !this.isComplete), [e, o]; } _appendCharRaw(e, t) { if (t === void 0 && (t = {}), !this.autofix || this.value.length + 1 > this.maxLength) return super._appendCharRaw(e, t); const o = String(this.from).padStart(this.maxLength, "0"), i = String(this.to).padStart(this.maxLength, "0"), [r, n] = this.boundaries(this.value + e); return Number(n) < this.from ? super._appendCharRaw(o[this.value.length], t) : Number(r) > this.to ? !t.tail && this.autofix === "pad" && this.value.length + 1 < this.maxLength ? super._appendCharRaw(o[this.value.length], t).aggregate(this._appendCharRaw(e, t)) : super._appendCharRaw(i[this.value.length], t) : super._appendCharRaw(e, t); } doValidate(e) { const t = this.value; if (t.search(/[^0]/) === -1 && t.length <= this._matchFrom) return !0; const [i, r] = this.boundaries(t); return this.from <= Number(r) && Number(i) <= this.to && super.doValidate(e); } pad(e) { const t = new I(); if (this.value.length === this.maxLength) return t; const o = this.value, i = this.maxLength - this.value.length; if (i) { this.reset(); for (let r = 0; r < i; ++r) t.aggregate(super._appendCharRaw("0", e)); o.split("").forEach((r) => this._appendCharRaw(r)); } return t; } } z.MaskedRange = Ki; const Ef = "d{.}`m{.}`Y"; class yt extends de { static extractPatternOptions(e) { const { mask: t, pattern: o, ...i } = e; return { ...i, mask: Ft(t) ? t : o }; } /** Pattern mask for date according to {@link MaskedDate#format} */ /** Start date */ /** End date */ /** Format typed value to string */ /** Parse string to get typed value */ constructor(e) { super(yt.extractPatternOptions({ ...yt.DEFAULTS, ...e })); } updateOptions(e) { super.updateOptions(e); } _update(e) { const { mask: t, pattern: o, blocks: i, ...r } = { ...yt.DEFAULTS, ...e }, n = Object.assign({}, yt.GET_DEFAULT_BLOCKS()); e.min && (n.Y.from = e.min.getFullYear()), e.max && (n.Y.to = e.max.getFullYear()), e.min && e.max && n.Y.from === n.Y.to && (n.m.from = e.min.getMonth() + 1, n.m.to = e.max.getMonth() + 1, n.m.from === n.m.to && (n.d.from = e.min.getDate(), n.d.to = e.max.getDate())), Object.assign(n, this.blocks, i), super._update({ ...r, mask: Ft(t) ? t : o, blocks: n }); } doValidate(e) { const t = this.date; return super.doValidate(e) && (!this.isComplete || this.isDateExist(this.value) && t != null && (this.min == null || this.min <= t) && (this.max == null || t <= this.max)); } /** Checks if date is exists */ isDateExist(e) { return this.format(this.parse(e, this), this).indexOf(e) >= 0; } /** Parsed Date */ get date() { return this.typedValue; } set date(e) { this.typedValue = e; } get typedValue() { return this.isComplete ? super.typedValue : null; } set typedValue(e) { super.typedValue = e; } maskEquals(e) { return e === Date || super.maskEquals(e); } optionsIsChanged(e) { return super.optionsIsChanged(yt.extractPatternOptions(e)); } } yt.GET_DEFAULT_BLOCKS = () => ({ d: { mask: Ki, from: 1, to: 31, maxLength: 2 }, m: { mask: Ki, from: 1, to: 12, maxLength: 2 }, Y: { mask: Ki, from: 1900, to: 9999 } }); yt.DEFAULTS = { ...de.DEFAULTS, mask: Date, pattern: Ef, format: (a, e) => { if (!a) return ""; const t = String(a.getDate()).padStart(2, "0"), o = String(a.getMonth() + 1).padStart(2, "0"), i = a.getFullYear(); return [t, o, i].join("."); }, parse: (a, e) => { const [t, o, i] = a.split(".").map(Number); return new Date(i, o - 1, t); } }; z.MaskedDate = yt; class Sa extends ce { constructor(e) { super({ ...Sa.DEFAULTS, ...e }), this.currentMask = void 0; } updateOptions(e) { super.updateOptions(e); } _update(e) { super._update(e), "mask" in e && (this.exposeMask = void 0, this.compiledMasks = Array.isArray(e.mask) ? e.mask.map((t) => { const { expose: o, ...i } = pi(t), r = $t({ overwrite: this._overwrite, eager: this._eager, skipInvalid: this._skipInvalid, ...i }); return o && (this.exposeMask = r), r; }) : []); } _appendCharRaw(e, t) { t === void 0 && (t = {}); const o = this._applyDispatch(e, t); return this.currentMask && o.aggregate(this.currentMask._appendChar(e, this.currentMaskFlags(t))), o; } _applyDispatch(e, t, o) { e === void 0 && (e = ""), t === void 0 && (t = {}), o === void 0 && (o = ""); const i = t.tail && t._beforeTailState != null ? t._beforeTailState._value : this.value, r = this.rawInputValue, n = t.tail && t._beforeTailState != null ? t._beforeTailState._rawInputValue : r, c = r.slice(n.length), m = this.currentMask, g = new I(), f = m?.state; return this.currentMask = this.doDispatch(e, { ...t }, o), this.currentMask && (this.currentMask !== m ? (this.currentMask.reset(), n && (this.currentMask.append(n, { raw: !0 }), g.tailShift = this.currentMask.value.length - i.length), c && (g.tailShift += this.currentMask.append(c, { raw: !0, tail: !0 }).tailShift)) : f && (this.currentMask.state = f)), g; } _appendPlaceholder() { const e = this._applyDispatch(); return this.currentMask && e.aggregate(this.currentMask._appendPlaceholder()), e; } _appendEager() { const e = this._applyDispatch(); return this.currentMask && e.aggregate(this.currentMask._appendEager()), e; } appendTail(e) { const t = new I(); return e && t.aggregate(this._applyDispatch("", {}, e)), t.aggregate(this.currentMask ? this.currentMask.appendTail(e) : super.appendTail(e)); } currentMaskFlags(e) { var t, o; return { ...e, _beforeTailState: ((t = e._beforeTailState) == null ? void 0 : t.currentMaskRef) === this.currentMask && ((o = e._beforeTailState) == null ? void 0 : o.currentMask) || e._beforeTailState }; } doDispatch(e, t, o) { return t === void 0 && (t = {}), o === void 0 && (o = ""), this.dispatch(e, this, t, o); } doValidate(e) { return super.doValidate(e) && (!this.currentMask || this.currentMask.doValidate(this.currentMaskFlags(e))); } doPrepare(e, t) { t === void 0 && (t = {}); let [o, i] = super.doPrepare(e, t); if (this.currentMask) { let r; [o, r] = super.doPrepare(o, this.currentMaskFlags(t)), i = i.aggregate(r); } return [o, i]; } doPrepareChar(e, t) { t === void 0 && (t = {}); let [o, i] = super.doPrepareChar(e, t); if (this.currentMask) { let r; [o, r] = super.doPrepareChar(o, this.currentMaskFlags(t)), i = i.aggregate(r); } return [o, i]; } reset() { var e; (e = this.currentMask) == null || e.reset(), this.compiledMasks.forEach((t) => t.reset()); } get value() { return this.exposeMask ? this.exposeMask.value : this.currentMask ? this.currentMask.value : ""; } set value(e) { this.exposeMask ? (this.exposeMask.value = e, this.currentMask = this.exposeMask, this._applyDispatch()) : super.value = e; } get unmaskedValue() { return this.exposeMask ? this.exposeMask.unmaskedValue : this.currentMask ? this.currentMask.unmaskedValue : ""; } set unmaskedValue(e) { this.exposeMask ? (this.exposeMask.unmaskedValue = e, this.currentMask = this.exposeMask, this._applyDispatch()) : super.unmaskedValue = e; } get typedValue() { return this.exposeMask ? this.exposeMask.typedValue : this.currentMask ? this.currentMask.typedValue : ""; } set typedValue(e) { if (this.exposeMask) { this.exposeMask.typedValue = e, this.currentMask = this.exposeMask, this._applyDispatch(); return; } let t = String(e); this.currentMask && (this.currentMask.typedValue = e, t = this.currentMask.unmaskedValue), this.unmaskedValue = t; } get displayValue() { return this.currentMask ? this.currentMask.displayValue : ""; } get isComplete() { var e; return !!((e = this.currentMask) != null && e.isComplete); } get isFilled() { var e; return !!((e = this.currentMask) != null && e.isFilled); } remove(e, t) { const o = new I(); return this.currentMask && o.aggregate(this.currentMask.remove(e, t)).aggregate(this._applyDispatch()), o; } get state() { var e; return { ...super.state, _rawInputValue: this.rawInputValue, compiledMasks: this.compiledMasks.map((t) => t.state), currentMaskRef: this.currentMask, currentMask: (e = this.currentMask) == null ? void 0 : e.state }; } set state(e) { const { compiledMasks: t, currentMaskRef: o, currentMask: i, ...r } = e; t && this.compiledMasks.forEach((n, c) => n.state = t[c]), o != null && (this.currentMask = o, this.currentMask.state = i), super.state = r; } extractInput(e, t, o) { return this.currentMask ? this.currentMask.extractInput(e, t, o) : ""; } extractTail(e, t) { return this.currentMask ? this.currentMask.extractTail(e, t) : super.extractTail(e, t); } doCommit() { this.currentMask && this.currentMask.doCommit(), super.doCommit(); } nearestInputPos(e, t) { return this.currentMask ? this.currentMask.nearestInputPos(e, t) : super.nearestInputPos(e, t); } get overwrite() { return this.currentMask ? this.currentMask.overwrite : this._overwrite; } set overwrite(e) { this._overwrite = e; } get eager() { return this.currentMask ? this.currentMask.eager : this._eager; } set eager(e) { this._eager = e; } get skipInvalid() { return this.currentMask ? this.currentMask.skipInvalid : this._skipInvalid; } set skipInvalid(e) { this._skipInvalid = e; } get autofix() { return this.currentMask ? this.currentMask.autofix : this._autofix; } set autofix(e) { this._autofix = e; } maskEquals(e) { return Array.isArray(e) ? this.compiledMasks.every((t, o) => { if (!e[o]) return; const { mask: i, ...r } = e[o]; return na(t, r) && t.maskEquals(i); }) : super.maskEquals(e); } typedValueEquals(e) { var t; return !!((t = this.currentMask) != null && t.typedValueEquals(e)); } } Sa.DEFAULTS = { ...ce.DEFAULTS, dispatch: (a, e, t, o) => { if (!e.compiledMasks.length) return; const i = e.rawInputValue, r = e.compiledMasks.map((n, c) => { const m = e.currentMask === n, g = m ? n.displayValue.length : n.nearestInputPos(n.displayValue.length, B.FORCE_LEFT); return n.rawInputValue !== i ? (n.reset(), n.append(i, { raw: !0 })) : m || n.remove(g), n.append(a, e.currentMaskFlags(t)), n.appendTail(o), { index: c, weight: n.rawInputValue.length, totalInputPositions: n.totalInputPositions(0, Math.max(g, n.nearestInputPos(n.displayValue.length, B.FORCE_LEFT))) }; }); return r.sort((n, c) => c.weight - n.weight || c.totalInputPositions - n.totalInputPositions), e.compiledMasks[r[0].index]; } }; z.MaskedDynamic = Sa; class Oa extends de { constructor(e) { super({ ...Oa.DEFAULTS, ...e }); } updateOptions(e) { super.updateOptions(e); } _update(e) { const { enum: t, ...o } = e; if (t) { const i = t.map((c) => c.length), r = Math.min(...i), n = Math.max(...i) - r; o.mask = "*".repeat(r), n && (o.mask += "[" + "*".repeat(n) + "]"), this.enum = t; } super._update(o); } _appendCharRaw(e, t) { t === void 0 && (t = {}); const o = Math.min(this.nearestInputPos(0, B.FORCE_RIGHT), this.value.length), i = this.enum.filter((r) => this.matchValue(r, this.unmaskedValue + e, o)); if (i.length) { i.length === 1 && this._forEachBlocksInRange(0, this.value.length, (n, c) => { const m = i[0][c]; c >= this.value.length || m === n.value || (n.reset(), n._appendChar(m, t)); }); const r = super._appendCharRaw(i[0][this.value.length], t); return i.length === 1 && i[0].slice(this.unmaskedValue.length).split("").forEach((n) => r.aggregate(super._appendCharRaw(n))), r; } return new I({ skip: !this.isComplete }); } extractTail(e, t) { return e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), new Qe("", e); } remove(e, t) { if (e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), e === t) return new I(); const o = Math.min(super.nearestInputPos(0, B.FORCE_RIGHT), this.value.length); let i; for (i = e; i >= 0 && !(this.enum.filter((c) => this.matchValue(c, this.value.slice(o, i), o)).length > 1); --i) ; const r = super.remove(i, t); return r.tailShift += i - e, r; } get isComplete() { return this.enum.indexOf(this.value) >= 0; } } Oa.DEFAULTS = { ...de.DEFAULTS, matchValue: (a, e, t) => a.indexOf(e, t) === t }; z.MaskedEnum = Oa; class Pf extends ce { /** */ /** Enable characters overwriting */ /** */ /** */ /** */ updateOptions(e) { super.updateOptions(e); } _update(e) { super._update({ ...e, validate: e.mask }); } } z.MaskedFunction = Pf; var Cs; class Le extends ce { /** Single char */ /** Single char */ /** Array of single chars */ /** */ /** */ /** Digits after point */ /** Flag to remove leading and trailing zeros in the end of editing */ /** Flag to pad trailing zeros after point in the end of editing */ /** Enable characters overwriting */ /** */ /** */ /** */ /** Format typed value to string */ /** Parse string to get typed value */ constructor(e) { super({ ...Le.DEFAULTS, ...e }); } updateOptions(e) { super.updateOptions(e); } _update(e) { super._update(e), this._updateRegExps(); } _updateRegExps() { const e = "^" + (this.allowNegative ? "[+|\\-]?" : ""), t = "\\d*", o = (this.scale ? "(" + Pa(this.radix) + "\\d{0," + this.scale + "})?" : "") + "$"; this._numberRegExp = new RegExp(e + t + o), this._mapToRadixRegExp = new RegExp("[" + this.mapToRadix.map(Pa).join("") + "]", "g"), this._thousandsSeparatorRegExp = new RegExp(Pa(this.thousandsSeparator), "g"); } _removeThousandsSeparators(e) { return e.replace(this._thousandsSeparatorRegExp, ""); } _insertThousandsSeparators(e) { const t = e.split(this.radix); return t[0] = t[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandsSeparator), t.join(this.radix); } doPrepareChar(e, t) { t === void 0 && (t = {}); const [o, i] = super.doPrepareChar(this._removeThousandsSeparators(this.scale && this.mapToRadix.length && /* radix should be mapped when 1) input is done from keyboard = flags.input && flags.raw 2) unmasked value is set = !flags.input && !flags.raw and should not be mapped when 1) value is set = flags.input && !flags.raw 2) raw value is set = !flags.input && flags.raw */ (t.input && t.raw || !t.input && !t.raw) ? e.replace(this._mapToRadixRegExp, this.radix) : e), t); return e && !o && (i.skip = !0), o && !this.allowPositive && !this.value && o !== "-" && i.aggregate(this._appendChar("-")), [o, i]; } _separatorsCount(e, t) { t === void 0 && (t = !1); let o = 0; for (let i = 0; i < e; ++i) this._value.indexOf(this.thousandsSeparator, i) === i && (++o, t && (e += this.thousandsSeparator.length)); return o; } _separatorsCountFromSlice(e) { return e === void 0 && (e = this._value), this._separatorsCount(this._removeThousandsSeparators(e).length, !0); } extractInput(e, t, o) { return e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), [e, t] = this._adjustRangeWithSeparators(e, t), this._removeThousandsSeparators(super.extractInput(e, t, o)); } _appendCharRaw(e, t) { t === void 0 && (t = {}); const o = t.tail && t._beforeTailState ? t._beforeTailState._value : this._value, i = this._separatorsCountFromSlice(o); this._value = this._removeThousandsSeparators(this.value); const r = this._value; this._value += e; const n = this.number; let c = !isNaN(n), m = !1; if (c) { let x; this.min != null && this.min < 0 && this.number < this.min && (x = this.min), this.max != null && this.max > 0 && this.number > this.max && (x = this.max), x != null && (this.autofix ? (this._value = this.format(x, this).replace(Le.UNMASKED_RADIX, this.radix), m || (m = r === this._value && !t.tail)) : c = !1), c && (c = !!this._value.match(this._numberRegExp)); } let g; c ? g = new I({ inserted: this._value.slice(r.length), rawInserted: m ? "" : e, skip: m }) : (this._value = r, g = new I()), this._value = this._insertThousandsSeparators(this._value); const f = t.tail && t._beforeTailState ? t._beforeTailState._value : this._value, v = this._separatorsCountFromSlice(f); return g.tailShift += (v - i) * this.thousandsSeparator.length, g; } _findSeparatorAround(e) { if (this.thousandsSeparator) { const t = e - this.thousandsSeparator.length + 1, o = this.value.indexOf(this.thousandsSeparator, t); if (o <= e) return o; } return -1; } _adjustRangeWithSeparators(e, t) { const o = this._findSeparatorAround(e); o >= 0 && (e = o); const i = this._findSeparatorAround(t); return i >= 0 && (t = i + this.thousandsSeparator.length), [e, t]; } remove(e, t) { e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), [e, t] = this._adjustRangeWithSeparators(e, t); const o = this.value.slice(0, e), i = this.value.slice(t), r = this._separatorsCount(o.length); this._value = this._insertThousandsSeparators(this._removeThousandsSeparators(o + i)); const n = this._separatorsCountFromSlice(o); return new I({ tailShift: (n - r) * this.thousandsSeparator.length }); } nearestInputPos(e, t) { if (!this.thousandsSeparator) return e; switch (t) { case B.NONE: case B.LEFT: case B.FORCE_LEFT: { const o = this._findSeparatorAround(e - 1); if (o >= 0) { const i = o + this.thousandsSeparator.length; if (e < i || this.value.length <= i || t === B.FORCE_LEFT) return o; } break; } case B.RIGHT: case B.FORCE_RIGHT: { const o = this._findSeparatorAround(e); if (o >= 0) return o + this.thousandsSeparator.length; } } return e; } doCommit() { if (this.value) { const e = this.number; let t = e; this.min != null && (t = Math.max(t, this.min)), this.max != null && (t = Math.min(t, this.max)), t !== e && (this.unmaskedValue = this.format(t, this)); let o = this.value; this.normalizeZeros && (o = this._normalizeZeros(o)), this.padFractionalZeros && this.scale > 0 && (o = this._padFractionalZeros(o)), this._value = o; } super.doCommit(); } _normalizeZeros(e) { const t = this._removeThousandsSeparators(e).split(this.radix); return t[0] = t[0].replace(/^(\D*)(0*)(\d*)/, (o, i, r, n) => i + n), e.length && !/\d$/.test(t[0]) && (t[0] = t[0] + "0"), t.length > 1 && (t[1] = t[1].replace(/0*$/, ""), t[1].length || (t.length = 1)), this._insertThousandsSeparators(t.join(this.radix)); } _padFractionalZeros(e) { if (!e) return e; const t = e.split(this.radix); return t.length < 2 && t.push(""), t[1] = t[1].padEnd(this.scale, "0"), t.join(this.radix); } doSkipInvalid(e, t, o) { t === void 0 && (t = {}); const i = this.scale === 0 && e !== this.thousandsSeparator && (e === this.radix || e === Le.UNMASKED_RADIX || this.mapToRadix.includes(e)); return super.doSkipInvalid(e, t, o) && !i; } get unmaskedValue() { return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix, Le.UNMASKED_RADIX); } set unmaskedValue(e) { super.unmaskedValue = e; } get typedValue() { return this.parse(this.unmaskedValue, this); } set typedValue(e) { this.rawInputValue = this.format(e, this).replace(Le.UNMASKED_RADIX, this.radix); } /** Parsed Number */ get number() { return this.typedValue; } set number(e) { this.typedValue = e; } get allowNegative() { return this.min != null && this.min < 0 || this.max != null && this.max < 0; } get allowPositive() { return this.min != null && this.min > 0 || this.max != null && this.max > 0; } typedValueEquals(e) { return (super.typedValueEquals(e) || Le.EMPTY_VALUES.includes(e) && Le.EMPTY_VALUES.includes(this.typedValue)) && !(e === 0 && this.value === ""); } } Cs = Le; Le.UNMASKED_RADIX = "."; Le.EMPTY_VALUES = [...ce.EMPTY_VALUES, 0]; Le.DEFAULTS = { ...ce.DEFAULTS, mask: Number, radix: ",", thousandsSeparator: "", mapToRadix: [Cs.UNMASKED_RADIX], min: Number.MIN_SAFE_INTEGER, max: Number.MAX_SAFE_INTEGER, scale: 2, normalizeZeros: !0, padFractionalZeros: !1, parse: Number, format: (a) => a.toLocaleString("en-US", { useGrouping: !1, maximumFractionDigits: 20 }) }; z.MaskedNumber = Le; const Qa = { MASKED: "value", UNMASKED: "unmaskedValue", TYPED: "typedValue" }; function zs(a, e, t) { e === void 0 && (e = Qa.MASKED), t === void 0 && (t = Qa.MASKED); const o = $t(a); return (i) => o.runIsolated((r) => (r[e] = i, r[t])); } function Hf(a, e, t, o) { return zs(e, t, o)(a); } z.PIPE_TYPE = Qa; z.createPipe = zs; z.pipe = Hf; class Gf extends de { get repeatFrom() { var e; return (e = Array.isArray(this.repeat) ? this.repeat[0] : this.repeat === 1 / 0 ? 0 : this.repeat) != null ? e : 0; } get repeatTo() { var e; return (e = Array.isArray(this.repeat) ? this.repeat[1] : this.repeat) != null ? e : 1 / 0; } constructor(e) { super(e); } updateOptions(e) { super.updateOptions(e); } _update(e) { var t, o, i; const { repeat: r, ...n } = pi(e); this._blockOpts = Object.assign({}, this._blockOpts, n); const c = $t(this._blockOpts); this.repeat = (t = (o = r ?? c.repeat) != null ? o : this.repeat) != null ? t : 1 / 0, super._update({ mask: "m".repeat(Math.max(this.repeatTo === 1 / 0 && ((i = this._blocks) == null ? void 0 : i.length) || 0, this.repeatFrom)), blocks: { m: c }, eager: c.eager, overwrite: c.overwrite, skipInvalid: c.skipInvalid, lazy: c.lazy, placeholderChar: c.placeholderChar, displayChar: c.displayChar }); } _allocateBlock(e) { if (e < this._blocks.length) return this._blocks[e]; if (this.repeatTo === 1 / 0 || this._blocks.length < this.repeatTo) return this._blocks.push($t(this._blockOpts)), this.mask += "m", this._blocks[this._blocks.length - 1]; } _appendCharRaw(e, t) { t === void 0 && (t = {}); const o = new I(); for ( let m = (i = (r = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : r.index) != null ? i : Math.max(this._blocks.length - 1, 0), g, f; // try to get a block or // try to allocate a new block if not allocated already g = (n = this._blocks[m]) != null ? n : f = !f && this._allocateBlock(m); ++m ) { var i, r, n, c; const v = g._appendChar(e, { ...t, _beforeTailState: (c = t._beforeTailState) == null || (c = c._blocks) == null ? void 0 : c[m] }); if (v.skip && f) { this._blocks.pop(), this.mask = this.mask.slice(1); break; } if (o.aggregate(v), v.consumed) break; } return o; } _trimEmptyTail(e, t) { var o, i; e === void 0 && (e = 0); const r = Math.max(((o = this._mapPosToBlock(e)) == null ? void 0 : o.index) || 0, this.repeatFrom, 0); let n; t != null && (n = (i = this._mapPosToBlock(t)) == null ? void 0 : i.index), n == null && (n = this._blocks.length - 1); let c = 0; for (let m = n; r <= m && !this._blocks[m].unmaskedValue; --m, ++c) ; c && (this._blocks.splice(n - c + 1, c), this.mask = this.mask.slice(c)); } reset() { super.reset(), this._trimEmptyTail(); } remove(e, t) { e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length); const o = super.remove(e, t); return this._trimEmptyTail(e, t), o; } totalInputPositions(e, t) { return e === void 0 && (e = 0), t == null && this.repeatTo === 1 / 0 ? 1 / 0 : super.totalInputPositions(e, t); } get state() { return super.state; } set state(e) { this._blocks.length = e._blocks.length, this.mask = this.mask.slice(0, this._blocks.length), super.state = e; } } z.RepeatBlock = Gf; try { globalThis.IMask = z; } catch { } var Yf = Object.defineProperty, Tf = Object.getOwnPropertyDescriptor, pe = (a, e, t, o) => { for (var i = o > 1 ? void 0 : o ? Tf(e, t) : e, r = a.length - 1, n; r >= 0; r--) (n = a[r]) && (i = (o ? n(e, t, i) : n(i)) || i); return o && i && Yf(e, t, i), i; }; class re extends k { constructor() { super(...arguments), this.nestedHint = "", this.nestedPlaceholder = "", this.preserveHint = !1, this.preservePlaceholder = !1, this.mask = "", this.variant = "date", this.value = "", this.handleSlotChange = (e) => { const t = e.target; if (X(t, ["MAUI-INPUT"], 1, !1), this.maskedInput = t.assignedElements()[0], !this.maskedInput) throw new Error("No MAUI-INPUT element found"); this.maskedInput.setAttribute("controlled", ""), this.maskedInput.setAttribute("theme", this.theme), this.maskedInput.addEventListener( "maui-clear", () => this.handleInputClear() ); }; } handleInputClear() { this.value = "", this.masked.value = "", this.masked.unmaskedValue = "", this.maskedInput.value = ""; } createMaskedInput() { const { maskOptions: e } = this.getMask(); if (this.maskedInput && this.maskedInput.shadowRoot) { const t = this.maskedInput.shadowRoot.querySelector( ".control" ); this.masked = z(t, e), this.masked.on("complete", () => { this.maskedInput.value = this.masked.value.replace( /[\u{0080}-\u{10FFFF}]/gu, "" ), this.value = this.masked.value.replace(/[\u{0080}-\u{10FFFF}]/gu, ""), this.emit("maui-complete", { detail: { value: { masked: this.masked.value.replace(/[\u{0080}-\u{10FFFF}]/gu, ""), unmasked: this.masked.unmaskedValue } } }); }); } } getMask() { let e = { lazy: !0, eager: !0, overwrite: !0 }; const t = { locale: this.customLocale || navigator.languages[0] }; switch (this.variant) { case "date": { const { format: o, separators: i } = kr(t), [r, n, c] = an( this.minDate || (/* @__PURE__ */ new Date("01/01/1900")).toISOString() ), [m, g, f] = an( this.maxDate || (/* @__PURE__ */ new Date("12/31/9999")).toISOString() ), v = `${o.split(i[0].replace(/[\u{0080}-\u{10FFFF}]/gu, "")).join(`${i[0].replace(/[\u{0080}-\u{10FFFF}]/gu, "")}\``).replace(/[\u{0080}-\u{10FFFF}]/gu, "")}`; this.mask = o, e = { ...e, lazy: !0, mask: o, overwrite: !1, autofix: !0, pattern: v, blocks: { DD: { mask: z.MaskedRange, from: n, to: g, maxLength: 2, placeholderChar: "D" }, MM: { mask: z.MaskedRange, from: r, to: m, maxLength: 2, placeholderChar: "M" }, YYYY: { mask: z.MaskedRange, from: c, to: f, maxLength: 4, placeholderChar: "Y" } } }; break; } case "ticketnr": { this.mask = "123-4567890123", e = { mask: "000-0000000000", eager: !0, overwrite: !0 }; break; } case "flightnr": { this.mask = `${this.theme === "b2b" ? "LH" : this.theme?.toUpperCase()} 100`, e = { ...e, mask: "aa 000[0]", prepareChar: (o) => o.toUpperCase() }; break; } case "custom": { if (!this.mask) throw new Error("No mask provided"); e = { ...e, mask: this.mask }; break; } default: this.mask = ""; } return { mask: this.mask, maskOptions: e }; } destroyMaskedInput() { this.masked && (this.masked.off("complete"), this.masked.destroy(), this.masked = null); } handleInput(e) { e.stopPropagation(), this.maskedInput.value = this.masked.value.replace( /[\u{0080}-\u{10FFFF}]/gu, "" ), this.emit("maui-input", { detail: { value: { masked: this.masked.value.replace(/[\u{0080}-\u{10FFFF}]/gu, ""), unmasked: this.masked.unmaskedValue } } }); } updateHint() { this.preserveHint ? this.maskedInput.setAttribute("hint", this.nestedHint) : this.maskedInput.setAttribute( "hint", this.getMask().mask || this.nestedHint ); } updatePlaceHolder() { this.preservePlaceholder ? this.maskedInput.setAttribute("placeholder", this.nestedPlaceholder) : this.maskedInput.setAttribute( "placeholder", this.getMask().mask || this.nestedPlaceholder ); } disconnectedCallback() { this.destroyMaskedInput(), super.disconnectedCallback(); } watchMaskedInput() { this.masked && this.destroyMaskedInput(), this.nestedHint = this.maskedInput.getAttribute("hint") || "", this.nestedPlaceholder = this.maskedInput.getAttribute("placeholder") || "", this.updateHint(), this.updatePlaceHolder(), this.createMaskedInput(), this.value && (this.masked.value = this.value); } watchPreserveHint() { this.maskedInput && this.updateHint(); } watchPreservePlaceholder() { this.maskedInput && this.updatePlaceHolder(); } watchValue() { this.masked && (this.masked.value = this.value); } render() { return u`