Socket
Socket
Sign inDemoInstall

imask

Package Overview
Dependencies
Maintainers
1
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imask - npm Package Compare versions

Comparing version 7.0.0-alpha.4 to 7.0.0-alpha.5

2

dist/controls/input.d.ts

@@ -22,5 +22,5 @@ import { type Selection } from '../core/utils';

constructor(el: InputMaskElement, opts: Opts);
maskEquals(mask: any): boolean;
/** Read or update mask */
get mask(): FactoryReturnMasked<Opts>['mask'];
maskEquals(mask: any): boolean;
set mask(mask: any);

@@ -27,0 +27,0 @@ /** Raw value */

export type ElementEvent = 'selectionChange' | 'input' | 'drop' | 'click' | 'focus' | 'commit';
/**
Generic element API to use with mask
@interface
*/
/** Generic element API to use with mask */
export default class MaskElement {

@@ -7,0 +4,0 @@ /** */

export type ChangeDetailsOptions = Pick<ChangeDetails, 'inserted' | 'skip' | 'tailShift' | 'rawInserted'>;
/**
Provides details of changing model value
*/
/** Provides details of changing model value */
export default class ChangeDetails {

@@ -16,6 +14,3 @@ /** Inserted symbols */

constructor(details?: Partial<ChangeDetailsOptions>);
/**
Aggregate changes
@returns {ChangeDetails} `this`
*/
/** Aggregate changes */
aggregate(details: ChangeDetails): this;

@@ -22,0 +17,0 @@ /** Total offset considering all changes */

/** Checks if value is string */
export declare function isString(str: unknown): str is string;
/** Checks if value is object */
export declare function isObject(obj: unknown): obj is Object;
export declare function isObject(obj: unknown): obj is object;
export declare function pick<T, K extends keyof T, V>(obj: T, keys: K[] | ((v: V, k: K) => boolean)): Pick<T, K>;
/**
Direction
@prop {string} NONE
@prop {string} LEFT
@prop {string} FORCE_LEFT
@prop {string} RIGHT
@prop {string} FORCE_RIGHT
*/
/** Direction */
export declare const DIRECTION: {

@@ -21,6 +14,3 @@ readonly NONE: "NONE";

};
/**
Direction
@enum {string}
*/
/** Direction */
export type Direction = typeof DIRECTION[keyof typeof DIRECTION];

@@ -27,0 +17,0 @@ export declare function forceDirection(direction: Direction): Direction;

@@ -20,3 +20,3 @@ import IMask from './imask';

export { default as ChunksTailDetails, type ChunksTailState } from './masked/pattern/chunk-tail-details';
export { default as PatternFixedDefinition, type PatternFixedDefinitionOptions, type PatternFixedDefinitionState } from './masked/pattern/fixed-definition';
export { default as PatternFixedDefinition, type PatternFixedDefinitionOptions } from './masked/pattern/fixed-definition';
export { default as PatternInputDefinition, type PatternInputDefinitionOptions, type PatternInputDefinitionState } from './masked/pattern/input-definition';

@@ -23,0 +23,0 @@ export { createPipe, pipe, PIPE_TYPE } from './masked/pipe';

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).IMask={})}(this,(function(t){"use strict";function e(t){return"string"==typeof t||t instanceof String}function s(t,e){return Array.isArray(e)?s(t,((t,s)=>e.includes(s))):Object.entries(t).reduce(((t,s)=>{let[i,u]=s;return e(u,i)&&(t[i]=u),t}),{})}const i={NONE:"NONE",LEFT:"LEFT",FORCE_LEFT:"FORCE_LEFT",RIGHT:"RIGHT",FORCE_RIGHT:"FORCE_RIGHT"};function u(t){switch(t){case i.LEFT:return i.FORCE_LEFT;case i.RIGHT:return i.FORCE_RIGHT;default:return t}}function a(t){return t.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function r(t,e){if(e===t)return!0;var s,i=Array.isArray(e),u=Array.isArray(t);if(i&&u){if(e.length!=t.length)return!1;for(s=0;s<e.length;s++)if(!r(e[s],t[s]))return!1;return!0}if(i!=u)return!1;if(e&&t&&"object"==typeof e&&"object"==typeof t){var a=e instanceof Date,n=t instanceof Date;if(a&&n)return e.getTime()==t.getTime();if(a!=n)return!1;var h=e instanceof RegExp,o=t instanceof RegExp;if(h&&o)return e.toString()==t.toString();if(h!=o)return!1;var l=Object.keys(e);for(s=0;s<l.length;s++)if(!Object.prototype.hasOwnProperty.call(t,l[s]))return!1;for(s=0;s<l.length;s++)if(!r(t[l[s]],e[l[s]]))return!1;return!0}return!(!e||!t||"function"!=typeof e||"function"!=typeof t)&&e.toString()===t.toString()}class n{constructor(t){for(Object.assign(this,t);this.value.slice(0,this.startChangePos)!==this.oldValue.slice(0,this.startChangePos);)--this.oldSelection.start}get startChangePos(){return Math.min(this.cursorPos,this.oldSelection.start)}get insertedCount(){return this.cursorPos-this.startChangePos}get inserted(){return this.value.substr(this.startChangePos,this.insertedCount)}get removedCount(){return Math.max(this.oldSelection.end-this.startChangePos||this.oldValue.length-this.value.length,0)}get removed(){return this.oldValue.substr(this.startChangePos,this.removedCount)}get head(){return this.value.substring(0,this.startChangePos)}get tail(){return this.value.substring(this.startChangePos+this.insertedCount)}get removeDirection(){return!this.removedCount||this.insertedCount?i.NONE:this.oldSelection.end!==this.cursorPos&&this.oldSelection.start!==this.cursorPos||this.oldSelection.end!==this.oldSelection.start?i.LEFT:i.RIGHT}}function h(t,e){return new h.InputMask(t,e)}function o(t){if(null==t)throw new Error("mask property should be defined");return t instanceof RegExp?h.MaskedRegExp:e(t)?h.MaskedPattern:t===Date?h.MaskedDate:t===Number?h.MaskedNumber:Array.isArray(t)||t===Array?h.MaskedDynamic:h.Masked&&t.prototype instanceof h.Masked?t:h.Masked&&t instanceof h.Masked?t.constructor:t instanceof Function?h.MaskedFunction:(console.warn("Mask not found for mask",t),h.Masked)}function l(t){if(!t)throw new Error("Options in not defined");if(h.Masked){if(t.prototype instanceof h.Masked)return{mask:t};const{mask:e,...i}=t instanceof h.Masked?{mask:t}:t.mask instanceof h.Masked?t:{};if(e){const t=e.mask;return{...s(e,((t,e)=>!e.startsWith("_"))),mask:e.constructor,_mask:t,...i}}}return"object"!=typeof(e=t)||null==e||"Object"!==(null==e||null==(i=e.constructor)?void 0:i.name)?{mask:t}:{...t};var e,i}function d(t){if(h.Masked&&t instanceof h.Masked)return t;const e=l(t),s=o(e.mask);if(!s)throw new Error("Masked class is not found for provided mask, appropriate module needs to be imported manually before creating mask.");return e.mask===s&&delete e.mask,e._mask&&(e.mask=e._mask,delete e._mask),new s(e)}h.createMask=d;class p{get selectionStart(){let t;try{t=this._unsafeSelectionStart}catch(t){}return null!=t?t:this.value.length}get selectionEnd(){let t;try{t=this._unsafeSelectionEnd}catch(t){}return null!=t?t:this.value.length}select(t,e){if(null!=t&&null!=e&&(t!==this.selectionStart||e!==this.selectionEnd))try{this._unsafeSelect(t,e)}catch(t){}}_unsafeSelect(t,e){}get isActive(){return!1}bindEvents(t){}unbindEvents(){}}h.MaskElement=p;class c extends p{constructor(t){super(),this.input=t,this._handlers={}}get rootElement(){var t,e,s;return null!=(t=null==(e=(s=this.input).getRootNode)?void 0:e.call(s))?t:document}get isActive(){return this.input===this.rootElement.activeElement}bindEvents(t){Object.keys(t).forEach((e=>this._toggleEventHandler(c.EVENTS_MAP[e],t[e])))}unbindEvents(){Object.keys(this._handlers).forEach((t=>this._toggleEventHandler(t)))}_toggleEventHandler(t,e){this._handlers[t]&&(this.input.removeEventListener(t,this._handlers[t]),delete this._handlers[t]),e&&(this.input.addEventListener(t,e),this._handlers[t]=e)}}c.EVENTS_MAP={selectionChange:"keydown",input:"input",drop:"drop",click:"click",focus:"focus",commit:"blur"},h.HTMLMaskElement=c;class g extends c{constructor(t){super(t),this.input=t,this._handlers={}}get _unsafeSelectionStart(){return this.input.selectionStart}get _unsafeSelectionEnd(){return this.input.selectionEnd}_unsafeSelect(t,e){this.input.setSelectionRange(t,e)}get value(){return this.input.value}set value(t){this.input.value=t}}h.HTMLMaskElement=c;class k extends c{get _unsafeSelectionStart(){const t=this.rootElement,e=t.getSelection&&t.getSelection(),s=e&&e.anchorOffset,i=e&&e.focusOffset;return null==i||null==s||s<i?s:i}get _unsafeSelectionEnd(){const t=this.rootElement,e=t.getSelection&&t.getSelection(),s=e&&e.anchorOffset,i=e&&e.focusOffset;return null==i||null==s||s>i?s:i}_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,u=i.getSelection&&i.getSelection();u&&(u.removeAllRanges(),u.addRange(s))}get value(){return this.input.textContent}set value(t){this.input.textContent=t}}h.HTMLContenteditableMaskElement=k;class m{constructor(t,e){this.el=t instanceof p?t:t.isContentEditable&&"INPUT"!==t.tagName&&"TEXTAREA"!==t.tagName?new k(t):new g(t),this.masked=d(e),this._listeners={},this._value="",this._unmaskedValue="",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.alignCursor=this.alignCursor.bind(this),this.alignCursorFriendly=this.alignCursorFriendly.bind(this),this._bindEvents(),this.updateValue(),this._onChange()}get mask(){return this.masked.mask}maskEquals(t){var e;return null==t||(null==(e=this.masked)?void 0:e.maskEquals(t))}set mask(t){if(this.maskEquals(t))return;if(!(t instanceof h.Masked)&&this.masked.constructor===o(t))return void this.masked.updateOptions({mask:t});const e=t instanceof h.Masked?t:d({mask:t});e.unmaskedValue=this.masked.unmaskedValue,this.masked=e}get value(){return this._value}set value(t){this.value!==t&&(this.masked.value=t,this.updateControl(),this.alignCursor())}get unmaskedValue(){return this._unmaskedValue}set unmaskedValue(t){this.unmaskedValue!==t&&(this.masked.unmaskedValue=t,this.updateControl(),this.alignCursor())}get typedValue(){return this.masked.typedValue}set typedValue(t){this.masked.typedValueEquals(t)||(this.masked.typedValue=t,this.updateControl(),this.alignCursor())}get displayValue(){return this.masked.displayValue}_bindEvents(){this.el.bindEvents({selectionChange:this._saveSelection,input:this._onInput,drop:this._onDrop,click:this._onClick,focus:this._onFocus,commit:this._onChange})}_unbindEvents(){this.el&&this.el.unbindEvents()}_fireEvent(t,e){const s=this._listeners[t];s&&s.forEach((t=>t(e)))}get selectionStart(){return this._cursorChanging?this._changingCursorPos:this.el.selectionStart}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())}_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}}updateValue(){this.masked.value=this.el.value,this._value=this.masked.value}updateControl(){const t=this.masked.unmaskedValue,e=this.masked.value,s=this.displayValue,i=this.unmaskedValue!==t||this.value!==e;this._unmaskedValue=t,this._value=e,this.el.value!==s&&(this.el.value=s),i&&this._fireChangeEvents()}updateOptions(t){const{mask:e,...s}=t,i=!this.maskEquals(e),u=!r(this.masked,s);i&&(this.mask=e),u&&this.masked.updateOptions(s),(i||u)&&this.updateControl()}updateCursor(t){null!=t&&(this.cursorPos=t,this._delayUpdateCursor(t))}_delayUpdateCursor(t){this._abortUpdateCursor(),this._changingCursorPos=t,this._cursorChanging=setTimeout((()=>{this.el&&(this.cursorPos=this._changingCursorPos,this._abortUpdateCursor())}),10)}_fireChangeEvents(){this._fireEvent("accept",this._inputEvent),this.masked.isComplete&&this._fireEvent("complete",this._inputEvent)}_abortUpdateCursor(){this._cursorChanging&&(clearTimeout(this._cursorChanging),delete this._cursorChanging)}alignCursor(){this.cursorPos=this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos,i.LEFT))}alignCursorFriendly(){this.selectionStart===this.cursorPos&&this.alignCursor()}on(t,e){return this._listeners[t]||(this._listeners[t]=[]),this._listeners[t].push(e),this}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}_onInput(t){if(this._inputEvent=t,this._abortUpdateCursor(),!this._selection)return this.updateValue();const e=new n({value:this.el.value,cursorPos:this.cursorPos,oldValue:this.displayValue,oldSelection:this._selection}),s=this.masked.rawInputValue,u=this.masked.splice(e.startChangePos,e.removed.length,e.inserted,e.removeDirection,{input:!0,raw:!0}).offset,a=s===this.masked.rawInputValue?e.removeDirection:i.NONE;let r=this.masked.nearestInputPos(e.startChangePos+u,a);a!==i.NONE&&(r=this.masked.nearestInputPos(r,i.NONE)),this.updateControl(),this.updateCursor(r),delete this._inputEvent}_onChange(){this.displayValue!==this.el.value&&this.updateValue(),this.masked.doCommit(),this.updateControl(),this._saveSelection()}_onDrop(t){t.preventDefault(),t.stopPropagation()}_onFocus(t){this.alignCursorFriendly()}_onClick(t){this.alignCursorFriendly()}destroy(){this._unbindEvents(),this._listeners.length=0,delete this.el}}h.InputMask=m;class f{static normalize(t){return Array.isArray(t)?t:[t,new f]}constructor(t){Object.assign(this,{inserted:"",rawInserted:"",skip:!1,tailShift:0},t)}aggregate(t){return this.rawInserted+=t.rawInserted,this.skip=this.skip||t.skip,this.inserted+=t.inserted,this.tailShift+=t.tailShift,this}get offset(){return this.tailShift+this.inserted.length}}h.ChangeDetails=f;class _{constructor(t,e,s){void 0===t&&(t=""),void 0===e&&(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||null!=t&&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 v{constructor(t){this._value="",this._update({...v.DEFAULTS,...t}),this._initialized=!0}updateOptions(t){Object.keys(t).length&&this.withValueRefresh(this._update.bind(this,t))}_update(t){Object.assign(this,t)}get state(){return{_value:this.value}}set state(t){this._value=t._value}reset(){this._value=""}get value(){return this._value}set value(t){this.resolve(t,{input:!0})}resolve(t,e){void 0===e&&(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)}get rawInputValue(){return this.extractInput(0,this.value.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}nearestInputPos(t,e){return t}totalInputPositions(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.value.length),Math.min(this.value.length,e-t)}extractInput(t,e,s){return void 0===t&&(t=0),void 0===e&&(e=this.value.length),this.value.slice(t,e)}extractTail(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.value.length),new _(this.extractInput(t,e),t)}appendTail(t){return e(t)&&(t=new _(String(t))),t.appendTo(this)}_appendCharRaw(t,e){return t?(this._value+=t,new f({inserted:t,rawInserted:t})):new f}_appendChar(t,e,s){void 0===e&&(e={});const i=this.state;let u;if([t,u]=this.doPrepareChar(t,e),u=u.aggregate(this._appendCharRaw(t,e)),u.inserted){let t,a=!1!==this.doValidate(e);if(a&&null!=s){const e=this.state;!0===this.overwrite&&(t=s.state,s.unshift(this.value.length-u.tailShift));let i=this.appendTail(s);a=i.rawInserted===s.toString(),a&&i.inserted||"shift"!==this.overwrite||(this.state=e,t=s.state,s.shift(),i=this.appendTail(s),a=i.rawInserted===s.toString()),a&&i.inserted&&(this.state=e)}a||(u=new f,this.state=i,s&&t&&(s.state=t))}return u}_appendPlaceholder(){return new f}_appendEager(){return new f}append(t,s,i){if(!e(t))throw new Error("value should be string");const u=e(i)?new _(String(i)):i;let a;null!=s&&s.tail&&(s._beforeTailState=this.state),[t,a]=this.doPrepare(t,s);for(let e=0;e<t.length;++e){const i=this._appendChar(t[e],s,u);if(!i.rawInserted&&!this.doSkipInvalid(t[e],s,u))break;a.aggregate(i)}return(!0===this.eager||"append"===this.eager)&&null!=s&&s.input&&t&&a.aggregate(this._appendEager()),null!=u&&(a.tailShift+=this.appendTail(u).tailShift),a}remove(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.value.length),this._value=this.value.slice(0,t)+this.value.slice(e),new f}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&&0===s.indexOf(this.value)&&this.append(s.slice(this.value.length),{},""),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 Boolean(this.skipInvalid)}doPrepare(t,e){return void 0===e&&(e={}),f.normalize(this.prepare?this.prepare(t,this,e):t)}doPrepareChar(t,e){return void 0===e&&(e={}),f.normalize(this.prepareChar?this.prepareChar(t,this,e):t)}doValidate(t){return(!this.validate||this.validate(this.value,this,t))&&(!this.parent||this.parent.doValidate(t))}doCommit(){this.commit&&this.commit(this.value,this)}splice(t,e,s,a,r){void 0===a&&(a=i.NONE),void 0===r&&(r={input:!0});const n=t+e,h=this.extractTail(n),o=!0===this.eager||"remove"===this.eager;let l;o&&(a=u(a),l=this.extractInput(0,n,{raw:!0}));let d=t;const p=new f;if(a!==i.NONE&&(d=this.nearestInputPos(t,e>1&&0!==t&&!o?i.NONE:a),p.tailShift=d-t),p.aggregate(this.remove(d)),o&&a!==i.NONE&&l===this.rawInputValue)if(a===i.FORCE_LEFT){let t;for(;l===this.rawInputValue&&(t=this.value.length);)p.aggregate(new f({tailShift:-1})).aggregate(this.remove(t-1))}else a===i.FORCE_RIGHT&&h.unshift();return p.aggregate(this.append(s,r,h))}maskEquals(t){return this.mask===t}typedValueEquals(t){const e=this.typedValue;return t===e||v.EMPTY_VALUES.includes(t)&&v.EMPTY_VALUES.includes(e)||this.format&&this.format(t,this)===this.format(this.typedValue,this)}}v.DEFAULTS={skipInvalid:!0},v.EMPTY_VALUES=[void 0,null,""],h.Masked=v;class E{constructor(t,e){void 0===t&&(t=[]),void 0===e&&(e=0),this.chunks=t,this.from=e}toString(){return this.chunks.map(String).join("")}extend(t){if(!String(t))return;t=e(t)?new _(String(t)):t;const s=this.chunks[this.chunks.length-1],i=s&&(s.stop===t.stop||null==t.stop)&&t.from===s.from+s.toString().length;if(t instanceof _)i?s.extend(t.toString()):this.chunks.push(t);else if(t instanceof E){if(null==t.stop){let e;for(;t.chunks.length&&null==t.chunks[0].stop;)e=t.chunks.shift(),e.from+=t.from,this.extend(e)}t.toString()&&(t.stop=t.blockIndex,this.chunks.push(t))}}appendTo(t){if(!(t instanceof h.MaskedPattern)){return new _(this.toString()).appendTo(t)}const e=new f;for(let s=0;s<this.chunks.length&&!e.skip;++s){const i=this.chunks[s],u=t._mapPosToBlock(t.value.length),a=i.stop;let r;if(null!=a&&(!u||u.index<=a)){if(i instanceof E||t._stops.indexOf(a)>=0){const s=t._appendPlaceholder(a);e.aggregate(s)}r=i instanceof E&&t._blocks[a]}if(r){const s=r.appendTail(i);s.skip=!1,e.aggregate(s),t._value+=s.inserted;const u=i.toString().slice(s.rawInserted.length);u&&e.aggregate(t.append(u,{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((t=>{const e="chunks"in t?new E:new _;return e.state=t,e}))}unshift(t){if(!this.chunks.length||null!=t&&this.from>=t)return"";const e=null!=t?t-this.from:t;let s=0;for(;s<this.chunks.length;){const t=this.chunks[s],i=t.unshift(e);if(t.toString()){if(!i)break;++s}else this.chunks.splice(s,1);if(i)return i}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 A{constructor(t,e){this.masked=t,this._log=[];const{offset:s,index:i}=t._mapPosToBlock(e)||(e<0?{index:0,offset:0}:{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 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.value.length))}_pushLeft(t){for(this.pushState(),this.bindBlock();0<=this.index;--this.index,this.offset=(null==(e=this.block)?void 0:e.value.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)return this.offset=this.block.nearestInputPos(this.offset,i.FORCE_LEFT),0!==this.offset||void 0}))}pushLeftBeforeInput(){return this._pushLeft((()=>{if(!this.block.isFixed)return this.offset=this.block.nearestInputPos(this.offset,i.LEFT),!0}))}pushLeftBeforeRequired(){return this._pushLeft((()=>{if(!(this.block.isFixed||this.block.isOptional&&!this.block.value))return this.offset=this.block.nearestInputPos(this.offset,i.LEFT),!0}))}pushRightBeforeFilled(){return this._pushRight((()=>{if(!this.block.isFixed&&this.block.value)return this.offset=this.block.nearestInputPos(this.offset,i.FORCE_RIGHT),this.offset!==this.block.value.length||void 0}))}pushRightBeforeInput(){return this._pushRight((()=>{if(!this.block.isFixed)return this.offset=this.block.nearestInputPos(this.offset,i.NONE),!0}))}pushRightBeforeRequired(){return this._pushRight((()=>{if(!(this.block.isFixed||this.block.isOptional&&!this.block.value))return this.offset=this.block.nearestInputPos(this.offset,i.NONE),!0}))}}class F{constructor(t){Object.assign(this,t),this._value="",this.isFixed=!0}get value(){return this._value}get unmaskedValue(){return this.isUnmasking?this.value:""}get displayValue(){return this.value}reset(){this._isRawInput=!1,this._value=""}remove(t,e){return void 0===t&&(t=0),void 0===e&&(e=this._value.length),this._value=this._value.slice(0,t)+this._value.slice(e),this._value||(this._isRawInput=!1),new f}nearestInputPos(t,e){void 0===e&&(e=i.NONE);const s=this._value.length;switch(e){case i.LEFT:case i.FORCE_LEFT:return 0;default:return s}}totalInputPositions(t,e){return void 0===t&&(t=0),void 0===e&&(e=this._value.length),this._isRawInput?e-t:0}extractInput(t,e,s){return void 0===t&&(t=0),void 0===e&&(e=this._value.length),void 0===s&&(s={}),s.raw&&this._isRawInput&&this._value.slice(t,e)||""}get isComplete(){return!0}get isFilled(){return Boolean(this._value)}_appendChar(t,e){void 0===e&&(e={});const s=new f;if(this.isFilled)return s;const i=!0===this.eager||"append"===this.eager,u=this.char===t&&(this.isUnmasking||e.input||e.raw)&&(!e.raw||!i)&&!e.tail;return u&&(s.rawInserted=this.char),this._value=s.inserted=this.char,this._isRawInput=u&&(e.raw||e.input),s}_appendEager(){return this._appendChar(this.char,{tail:!0})}_appendPlaceholder(){const t=new f;return this.isFilled||(this._value=t.inserted=this.char),t}extractTail(t,e){return void 0===e&&(e=this.value.length),new _("")}appendTail(t){return e(t)&&(t=new _(String(t))),t.appendTo(this)}append(t,e,s){const i=this._appendChar(t[0],e);return null!=s&&(i.tailShift+=this.appendTail(s).tailShift),i}doCommit(){}get state(){return{_value:this._value,_isRawInput:this._isRawInput}}set state(t){Object.assign(this,t)}}class C{constructor(t){const{parent:e,isOptional:s,placeholderChar:i,displayChar:u,lazy:a,eager:r,...n}=t;this.masked=d(n),Object.assign(this,{parent:e,isOptional:s,placeholderChar:i,displayChar:u,lazy:a,eager:r})}reset(){this.isFilled=!1,this.masked.reset()}remove(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.value.length),0===t&&e>=1?(this.isFilled=!1,this.masked.remove(t,e)):new f}get value(){return this.masked.value||(this.isFilled&&!this.isOptional?this.placeholderChar:"")}get unmaskedValue(){return this.masked.unmaskedValue}get displayValue(){return this.masked.value&&this.displayChar||this.value}get isComplete(){return Boolean(this.masked.value)||this.isOptional}_appendChar(t,e){if(void 0===e&&(e={}),this.isFilled)return new f;const s=this.masked.state,i=this.masked._appendChar(t,e);return i.inserted&&!1===this.doValidate(e)&&(i.inserted=i.rawInserted="",this.masked.state=s),i.inserted||this.isOptional||this.lazy||e.input||(i.inserted=this.placeholderChar),i.skip=!i.inserted&&!this.isOptional,this.isFilled=Boolean(i.inserted),i}append(t,e,s){return this.masked.append(t,e,s)}_appendPlaceholder(){const t=new f;return this.isFilled||this.isOptional||(this.isFilled=!0,t.inserted=this.placeholderChar),t}_appendEager(){return new f}extractTail(t,e){return this.masked.extractTail(t,e)}appendTail(t){return this.masked.appendTail(t)}extractInput(t,e,s){return void 0===t&&(t=0),void 0===e&&(e=this.value.length),this.masked.extractInput(t,e,s)}nearestInputPos(t,e){void 0===e&&(e=i.NONE);const s=this.value.length,u=Math.min(Math.max(t,0),s);switch(e){case i.LEFT:case i.FORCE_LEFT:return this.isComplete?u:0;case i.RIGHT:case i.FORCE_RIGHT:return this.isComplete?u:s;default:return u}}totalInputPositions(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.value.length),this.value.slice(t,e).length}doValidate(t){return this.masked.doValidate(t)&&(!this.parent||this.parent.doValidate(t))}doCommit(){this.masked.doCommit()}get state(){return{masked:this.masked.state,isFilled:this.isFilled}}set state(t){this.masked.state=t.masked,this.isFilled=t.isFilled}}C.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]/,"*":/./};class S extends v{updateOptions(t){super.updateOptions(t)}_update(t){t.mask&&(t.validate=e=>e.search(t.mask)>=0),super._update(t)}}h.MaskedRegExp=S;class D extends v{constructor(t){super({...D.DEFAULTS,...t,definitions:Object.assign({},C.DEFAULT_DEFINITIONS,null==t?void 0: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._stops=[],this._maskedBlocks={};let e=this.mask;if(!e||!t)return;let s=!1,i=!1;for(let u=0;u<e.length;++u){if(this.blocks){const t=e.slice(u),s=Object.keys(this.blocks).filter((e=>0===t.indexOf(e)));s.sort(((t,e)=>e.length-t.length));const i=s[0];if(i){const t=d({lazy:this.lazy,eager:this.eager,placeholderChar:this.placeholderChar,displayChar:this.displayChar,overwrite:this.overwrite,...l(this.blocks[i]),parent:this});t&&(this._blocks.push(t),this._maskedBlocks[i]||(this._maskedBlocks[i]=[]),this._maskedBlocks[i].push(this._blocks.length-1)),u+=i.length-1;continue}}let a=e[u],r=a in t;if(a===D.STOP_CHAR){this._stops.push(this._blocks.length);continue}if("{"===a||"}"===a){s=!s;continue}if("["===a||"]"===a){i=!i;continue}if(a===D.ESCAPE_CHAR){if(++u,a=e[u],!a)break;r=!1}const n=r?new C({isOptional:i,lazy:this.lazy,eager:this.eager,placeholderChar:this.placeholderChar,displayChar:this.displayChar,...l(t[a]),parent:this}):new F({char:a,eager:this.eager,isUnmasking:s});this._blocks.push(n)}}get state(){return{...super.state,_blocks:this._blocks.map((t=>t.state))}}set state(t){const{_blocks:e,...s}=t;this._blocks.forEach(((t,s)=>t.state=e[s])),super.state=s}reset(){super.reset(),this._blocks.forEach((t=>t.reset()))}get isComplete(){return 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._blocks.reduce(((t,e)=>t+e.unmaskedValue),"")}set unmaskedValue(t){super.unmaskedValue=t}get value(){return this._blocks.reduce(((t,e)=>t+e.value),"")}set value(t){super.value=t}get displayValue(){return this._blocks.reduce(((t,e)=>t+e.displayValue),"")}appendTail(t){return super.appendTail(t).aggregate(this._appendPlaceholder())}_appendEager(){var t;const e=new f;let s=null==(t=this._mapPosToBlock(this.value.length))?void 0:t.index;if(null==s)return e;this._blocks[s].isFilled&&++s;for(let t=s;t<this._blocks.length;++t){const s=this._blocks[t]._appendEager();if(!s.inserted)break;e.aggregate(s)}return e}_appendCharRaw(t,e){void 0===e&&(e={});const s=this._mapPosToBlock(this.value.length),i=new f;if(!s)return i;for(let r=s.index;;++r){var u,a;const s=this._blocks[r];if(!s)break;const n=s._appendChar(t,{...e,_beforeTailState:null==(u=e._beforeTailState)||null==(a=u._blocks)?void 0:a[r]}),h=n.skip;if(i.aggregate(n),h||n.rawInserted)break}return i}extractTail(t,e){void 0===t&&(t=0),void 0===e&&(e=this.value.length);const s=new E;return t===e||this._forEachBlocksInRange(t,e,((t,e,i,u)=>{const a=t.extractTail(i,u);a.stop=this._findStopBefore(e),a.from=this._blockStartPos(e),a instanceof E&&(a.blockIndex=e),s.extend(a)})),s}extractInput(t,e,s){if(void 0===t&&(t=0),void 0===e&&(e=this.value.length),void 0===s&&(s={}),t===e)return"";let i="";return this._forEachBlocksInRange(t,e,((t,e,u,a)=>{i+=t.extractInput(u,a,s)})),i}_findStopBefore(t){let e;for(let s=0;s<this._stops.length;++s){const i=this._stops[s];if(!(i<=t))break;e=i}return e}_appendPlaceholder(t){const e=new f;if(this.lazy&&null==t)return e;const s=this._mapPosToBlock(this.value.length);if(!s)return e;const i=s.index,u=null!=t?t:this._blocks.length;return this._blocks.slice(i,u).forEach((s=>{if(!s.lazy||null!=t){var i;const t=s._appendPlaceholder(null==(i=s._blocks)?void 0:i.length);this._value+=t.inserted,e.aggregate(t)}})),e}_mapPosToBlock(t){let e="";for(let s=0;s<this._blocks.length;++s){const i=this._blocks[s],u=e.length;if(e+=i.value,t<=e.length)return{index:s,offset:t-u}}}_blockStartPos(t){return this._blocks.slice(0,t).reduce(((t,e)=>t+e.value.length),0)}_forEachBlocksInRange(t,e,s){void 0===e&&(e=this.value.length);const i=this._mapPosToBlock(t);if(i){const t=this._mapPosToBlock(e),u=t&&i.index===t.index,a=i.offset,r=t&&u?t.offset:this._blocks[i.index].value.length;if(s(this._blocks[i.index],i.index,a,r),t&&!u){for(let e=i.index+1;e<t.index;++e)s(this._blocks[e],e,0,this._blocks[e].value.length);s(this._blocks[t.index],t.index,0,t.offset)}}}remove(t,e){void 0===t&&(t=0),void 0===e&&(e=this.value.length);const s=super.remove(t,e);return this._forEachBlocksInRange(t,e,((t,e,i,u)=>{s.aggregate(t.remove(i,u))})),s}nearestInputPos(t,e){if(void 0===e&&(e=i.NONE),!this._blocks.length)return 0;const s=new A(this,t);if(e===i.NONE)return s.pushRightBeforeInput()?s.pos:(s.popState(),s.pushLeftBeforeInput()?s.pos:this.value.length);if(e===i.LEFT||e===i.FORCE_LEFT){if(e===i.LEFT){if(s.pushRightBeforeFilled(),s.ok&&s.pos===t)return t;s.popState()}if(s.pushLeftBeforeInput(),s.pushLeftBeforeRequired(),s.pushLeftBeforeFilled(),e===i.LEFT){if(s.pushRightBeforeInput(),s.pushRightBeforeRequired(),s.ok&&s.pos<=t)return s.pos;if(s.popState(),s.ok&&s.pos<=t)return s.pos;s.popState()}return s.ok?s.pos:e===i.FORCE_LEFT?0:(s.popState(),s.ok?s.pos:(s.popState(),s.ok?s.pos:0))}return e===i.RIGHT||e===i.FORCE_RIGHT?(s.pushRightBeforeInput(),s.pushRightBeforeRequired(),s.pushRightBeforeFilled()?s.pos:e===i.FORCE_RIGHT?this.value.length:(s.popState(),s.ok?s.pos:(s.popState(),s.ok?s.pos:this.nearestInputPos(t,i.LEFT)))):t}totalInputPositions(t,e){void 0===t&&(t=0),void 0===e&&(e=this.value.length);let s=0;return this._forEachBlocksInRange(t,e,((t,e,i,u)=>{s+=t.totalInputPositions(i,u)})),s}maskedBlock(t){return this.maskedBlocks(t)[0]}maskedBlocks(t){const e=this._maskedBlocks[t];return e?e.map((t=>this._blocks[t])):[]}}D.DEFAULTS={lazy:!0,placeholderChar:"_"},D.STOP_CHAR="`",D.ESCAPE_CHAR="\\",D.InputDefinition=C,D.FixedDefinition=F,h.MaskedPattern=D;class B extends D{get _matchFrom(){return this.maxLength-String(this.from).length}constructor(t){super(t)}updateOptions(t){super.updateOptions(t)}_update(t){const{to:e=this.to||0,from:s=this.from||0,maxLength:i=this.maxLength||0,autofix:u=this.autofix,...a}=t;this.to=e,this.from=s,this.maxLength=Math.max(String(e).length,i),this.autofix=u;const r=String(this.from).padStart(this.maxLength,"0"),n=String(this.to).padStart(this.maxLength,"0");let h=0;for(;h<n.length&&n[h]===r[h];)++h;a.mask=n.slice(0,h).replace(/0/g,"\\0")+"0".repeat(this.maxLength-h),super._update(a)}get isComplete(){return super.isComplete&&Boolean(this.value)}boundaries(t){let e="",s="";const[,i,u]=t.match(/^(\D*)(\d*)(\D*)/)||[];return u&&(e="0".repeat(i.length)+u,s="9".repeat(i.length)+u),e=e.padEnd(this.maxLength,"0"),s=s.padEnd(this.maxLength,"9"),[e,s]}doPrepareChar(t,e){let s;if(void 0===e&&(e={}),[t,s]=super.doPrepareChar(t.replace(/\D/g,""),e),!this.autofix||!t)return[t,s];const i=String(this.from).padStart(this.maxLength,"0"),u=String(this.to).padStart(this.maxLength,"0");let a=this.value+t;if(a.length>this.maxLength)return["",s];const[r,n]=this.boundaries(a);return Number(n)<this.from?[i[a.length-1],s]:Number(r)>this.to?"pad"===this.autofix&&a.length<this.maxLength?["",s.aggregate(this.append(i[a.length-1]+t,e))]:[u[a.length-1],s]:[t,s]}doValidate(t){const e=this.value;if(-1===e.search(/[^0]/)&&e.length<=this._matchFrom)return!0;const[s,i]=this.boundaries(e);return this.from<=Number(i)&&Number(s)<=this.to&&super.doValidate(t)}}h.MaskedRange=B;class b extends D{constructor(t){const{mask:s,pattern:i,...u}={...b.DEFAULTS,...t};super({...u,mask:e(s)?s:i})}updateOptions(t){super.updateOptions(t)}_update(t){const{mask:s,pattern:i,blocks:u,...a}={...b.DEFAULTS,...t};let r=Object.assign({},b.GET_DEFAULT_BLOCKS());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,u),Object.keys(r).forEach((e=>{const s=r[e];!("autofix"in s)&&"autofix"in t&&(s.autofix=t.autofix)})),super._update({...a,mask:e(s)?s:i,blocks:r})}doValidate(t){const e=this.date;return super.doValidate(t)&&(!this.isComplete||this.isDateExist(this.value)&&null!=e&&(null==this.min||this.min<=e)&&(null==this.max||e<=this.max))}isDateExist(t){return this.format(this.parse(t,this),this).indexOf(t)>=0}get date(){return this.typedValue}set date(t){this.typedValue=t}get typedValue(){return this.isComplete?super.typedValue:null}set typedValue(t){super.typedValue=t}maskEquals(t){return t===Date||super.maskEquals(t)}}b.GET_DEFAULT_BLOCKS=()=>({d:{mask:B,from:1,to:31,maxLength:2},m:{mask:B,from:1,to:12,maxLength:2},Y:{mask:B,from:1900,to:9999}}),b.DEFAULTS={mask:Date,pattern:"d{.}`m{.}`Y",format:t=>{if(!t)return"";return[String(t.getDate()).padStart(2,"0"),String(t.getMonth()+1).padStart(2,"0"),t.getFullYear()].join(".")},parse:t=>{const[e,s,i]=t.split(".").map(Number);return new Date(i,s-1,e)}},h.MaskedDate=b;class x extends v{constructor(t){super({...x.DEFAULTS,...t}),this.currentMask=null}updateOptions(t){super.updateOptions(t)}_update(t){super._update(t),"mask"in t&&(this.compiledMasks=Array.isArray(t.mask)?t.mask.map((t=>d({overwrite:this._overwrite,eager:this._eager,skipInvalid:this._skipInvalid,...l(t)}))):[])}_appendCharRaw(t,e){void 0===e&&(e={});const s=this._applyDispatch(t,e);return this.currentMask&&s.aggregate(this.currentMask._appendChar(t,this.currentMaskFlags(e))),s}_applyDispatch(t,e,s){void 0===t&&(t=""),void 0===e&&(e={}),void 0===s&&(s="");const i=e.tail&&null!=e._beforeTailState?e._beforeTailState._value:this.value,u=this.rawInputValue,a=e.tail&&null!=e._beforeTailState?e._beforeTailState._rawInputValue:u,r=u.slice(a.length),n=this.currentMask,h=new f,o=null==n?void 0:n.state;if(this.currentMask=this.doDispatch(t,{...e},s),this.currentMask)if(this.currentMask!==n){if(this.currentMask.reset(),a){const t=this.currentMask.append(a,{raw:!0});h.tailShift=t.inserted.length-i.length}r&&(h.tailShift+=this.currentMask.append(r,{raw:!0,tail:!0}).tailShift)}else this.currentMask.state=o;return h}_appendPlaceholder(){const t=this._applyDispatch();return this.currentMask&&t.aggregate(this.currentMask._appendPlaceholder()),t}_appendEager(){const t=this._applyDispatch();return this.currentMask&&t.aggregate(this.currentMask._appendEager()),t}appendTail(t){const e=new f;return t&&e.aggregate(this._applyDispatch("",{},t)),e.aggregate(this.currentMask?this.currentMask.appendTail(t):super.appendTail(t))}currentMaskFlags(t){var e,s;return{...t,_beforeTailState:(null==(e=t._beforeTailState)?void 0:e.currentMaskRef)===this.currentMask&&(null==(s=t._beforeTailState)?void 0:s.currentMask)||t._beforeTailState}}doDispatch(t,e,s){return void 0===e&&(e={}),void 0===s&&(s=""),this.dispatch(t,this,e,s)}doValidate(t){return super.doValidate(t)&&(!this.currentMask||this.currentMask.doValidate(this.currentMaskFlags(t)))}doPrepare(t,e){void 0===e&&(e={});let[s,i]=super.doPrepare(t,e);if(this.currentMask){let t;[s,t]=super.doPrepare(s,this.currentMaskFlags(e)),i=i.aggregate(t)}return[s,i]}doPrepareChar(t,e){void 0===e&&(e={});let[s,i]=super.doPrepareChar(t,e);if(this.currentMask){let t;[s,t]=super.doPrepareChar(s,this.currentMaskFlags(e)),i=i.aggregate(t)}return[s,i]}reset(){var t;null==(t=this.currentMask)||t.reset(),this.compiledMasks.forEach((t=>t.reset()))}get value(){return this.currentMask?this.currentMask.value:""}set value(t){super.value=t}get unmaskedValue(){return this.currentMask?this.currentMask.unmaskedValue:""}set unmaskedValue(t){super.unmaskedValue=t}get typedValue(){return this.currentMask?this.currentMask.typedValue:""}set typedValue(t){let e=String(t);this.currentMask&&(this.currentMask.typedValue=t,e=this.currentMask.unmaskedValue),this.unmaskedValue=e}get displayValue(){return this.currentMask?this.currentMask.displayValue:""}get isComplete(){var t;return Boolean(null==(t=this.currentMask)?void 0:t.isComplete)}get isFilled(){var t;return Boolean(null==(t=this.currentMask)?void 0:t.isFilled)}remove(t,e){const s=new f;return this.currentMask&&s.aggregate(this.currentMask.remove(t,e)).aggregate(this._applyDispatch()),s}get state(){var t;return{...super.state,_rawInputValue:this.rawInputValue,compiledMasks:this.compiledMasks.map((t=>t.state)),currentMaskRef:this.currentMask,currentMask:null==(t=this.currentMask)?void 0:t.state}}set state(t){const{compiledMasks:e,currentMaskRef:s,currentMask:i,...u}=t;this.compiledMasks.forEach(((t,s)=>t.state=e[s])),null!=s&&(this.currentMask=s,this.currentMask.state=i),super.state=u}extractInput(t,e,s){return this.currentMask?this.currentMask.extractInput(t,e,s):""}extractTail(t,e){return this.currentMask?this.currentMask.extractTail(t,e):super.extractTail(t,e)}doCommit(){this.currentMask&&this.currentMask.doCommit(),super.doCommit()}nearestInputPos(t,e){return this.currentMask?this.currentMask.nearestInputPos(t,e):super.nearestInputPos(t,e)}get overwrite(){return this.currentMask?this.currentMask.overwrite:this._overwrite}set overwrite(t){this._overwrite=t}get eager(){return this.currentMask?this.currentMask.eager:this._eager}set eager(t){this._eager=t}get skipInvalid(){return this.currentMask?this.currentMask.skipInvalid:this._skipInvalid}set skipInvalid(t){this._skipInvalid=t}maskEquals(t){return Array.isArray(t)?this.compiledMasks.every(((e,s)=>{if(!t[s])return;const{mask:i,...u}=t[s];return r(e,u)&&e.maskEquals(i)})):super.maskEquals(t)}typedValueEquals(t){var e;return Boolean(null==(e=this.currentMask)?void 0:e.typedValueEquals(t))}}x.DEFAULTS=void 0,x.DEFAULTS={dispatch:(t,e,s,u)=>{if(!e.compiledMasks.length)return;const a=e.rawInputValue,r=e.compiledMasks.map(((r,n)=>{const h=e.currentMask===r,o=h?r.value.length:r.nearestInputPos(r.value.length,i.FORCE_LEFT);return r.rawInputValue!==a?(r.reset(),r.append(a,{raw:!0})):h||r.remove(o),r.append(t,e.currentMaskFlags(s)),r.appendTail(u),{index:n,weight:r.rawInputValue.length,totalInputPositions:r.totalInputPositions(0,Math.max(o,r.nearestInputPos(r.value.length,i.FORCE_LEFT)))}}));return r.sort(((t,e)=>e.weight-t.weight||e.totalInputPositions-t.totalInputPositions)),e.compiledMasks[r[0].index]}},h.MaskedDynamic=x;class M extends D{updateOptions(t){super.updateOptions(t)}_update(t){const{enum:e,...s}=t;this.enum=this.enum,e&&(s.mask="*".repeat(e[0].length)),super._update(s)}doValidate(t){return this.enum.some((t=>t.indexOf(this.unmaskedValue)>=0))&&super.doValidate(t)}}h.MaskedEnum=M;class T extends v{updateOptions(t){super.updateOptions(t)}_update(t){super._update({...t,validate:t.mask})}}h.MaskedFunction=T;class I extends v{constructor(t){super({...I.DEFAULTS,...t})}updateOptions(t){super.updateOptions(t)}_update(t){super._update(t),this._updateRegExps()}_updateRegExps(){let t="^"+(this.allowNegative?"[+|\\-]?":""),e=(this.scale?"("+a(this.radix)+"\\d{0,"+this.scale+"})?":"")+"$";this._numberRegExp=new RegExp(t+"\\d*"+e),this._mapToRadixRegExp=new RegExp("["+this.mapToRadix.map(a).join("")+"]","g"),this._thousandsSeparatorRegExp=new RegExp(a(this.thousandsSeparator),"g")}_removeThousandsSeparators(t){return t.replace(this._thousandsSeparatorRegExp,"")}_insertThousandsSeparators(t){const e=t.split(this.radix);return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,this.thousandsSeparator),e.join(this.radix)}doPrepareChar(t,e){void 0===e&&(e={}),t=this._removeThousandsSeparators(this.scale&&this.mapToRadix.length&&(e.input&&e.raw||!e.input&&!e.raw)?t.replace(this._mapToRadixRegExp,this.radix):t);const[s,i]=super.doPrepareChar(t,e);return t&&!s&&(i.skip=!0),!s||this.allowPositive||this.value||"-"===s||i.aggregate(this._appendChar("-")),[s,i]}_separatorsCount(t,e){void 0===e&&(e=!1);let s=0;for(let i=0;i<t;++i)this._value.indexOf(this.thousandsSeparator,i)===i&&(++s,e&&(t+=this.thousandsSeparator.length));return s}_separatorsCountFromSlice(t){return void 0===t&&(t=this._value),this._separatorsCount(this._removeThousandsSeparators(t).length,!0)}extractInput(t,e,s){return void 0===t&&(t=0),void 0===e&&(e=this.value.length),[t,e]=this._adjustRangeWithSeparators(t,e),this._removeThousandsSeparators(super.extractInput(t,e,s))}_appendCharRaw(t,e){if(void 0===e&&(e={}),!this.thousandsSeparator)return super._appendCharRaw(t,e);const s=e.tail&&e._beforeTailState?e._beforeTailState._value:this._value,i=this._separatorsCountFromSlice(s);this._value=this._removeThousandsSeparators(this.value);const u=super._appendCharRaw(t,e);this._value=this._insertThousandsSeparators(this._value);const a=e.tail&&e._beforeTailState?e._beforeTailState._value:this._value,r=this._separatorsCountFromSlice(a);return u.tailShift+=(r-i)*this.thousandsSeparator.length,u.skip=!u.rawInserted&&t===this.thousandsSeparator,u}_findSeparatorAround(t){if(this.thousandsSeparator){const e=t-this.thousandsSeparator.length+1,s=this.value.indexOf(this.thousandsSeparator,e);if(s<=t)return s}return-1}_adjustRangeWithSeparators(t,e){const s=this._findSeparatorAround(t);s>=0&&(t=s);const i=this._findSeparatorAround(e);return i>=0&&(e=i+this.thousandsSeparator.length),[t,e]}remove(t,e){void 0===t&&(t=0),void 0===e&&(e=this.value.length),[t,e]=this._adjustRangeWithSeparators(t,e);const s=this.value.slice(0,t),i=this.value.slice(e),u=this._separatorsCount(s.length);this._value=this._insertThousandsSeparators(this._removeThousandsSeparators(s+i));const a=this._separatorsCountFromSlice(s);return new f({tailShift:(a-u)*this.thousandsSeparator.length})}nearestInputPos(t,e){if(!this.thousandsSeparator)return t;switch(e){case i.NONE:case i.LEFT:case i.FORCE_LEFT:{const s=this._findSeparatorAround(t-1);if(s>=0){const u=s+this.thousandsSeparator.length;if(t<u||this.value.length<=u||e===i.FORCE_LEFT)return s}break}case i.RIGHT:case i.FORCE_RIGHT:{const e=this._findSeparatorAround(t);if(e>=0)return e+this.thousandsSeparator.length}}return t}doValidate(t){let e=Boolean(this._removeThousandsSeparators(this.value).match(this._numberRegExp));if(e){const t=this.number;e=e&&!isNaN(t)&&(null==this.min||this.min>=0||this.min<=this.number)&&(null==this.max||this.max<=0||this.number<=this.max)}return e&&super.doValidate(t)}doCommit(){if(this.value){const t=this.number;let e=t;null!=this.min&&(e=Math.max(e,this.min)),null!=this.max&&(e=Math.min(e,this.max)),e!==t&&(this.unmaskedValue=this.format(e,this));let s=this.value;this.normalizeZeros&&(s=this._normalizeZeros(s)),this.padFractionalZeros&&this.scale>0&&(s=this._padFractionalZeros(s)),this._value=s}super.doCommit()}_normalizeZeros(t){const e=this._removeThousandsSeparators(t).split(this.radix);return e[0]=e[0].replace(/^(\D*)(0*)(\d*)/,((t,e,s,i)=>e+i)),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))}_padFractionalZeros(t){if(!t)return t;const e=t.split(this.radix);return e.length<2&&e.push(""),e[1]=e[1].padEnd(this.scale,"0"),e.join(this.radix)}doSkipInvalid(t,e,s){void 0===e&&(e={});const i=0===this.scale&&t!==this.thousandsSeparator&&(t===this.radix||t===I.UNMASKED_RADIX||this.mapToRadix.includes(t));return super.doSkipInvalid(t,e,s)&&!i}get unmaskedValue(){return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix,I.UNMASKED_RADIX)}set unmaskedValue(t){super.unmaskedValue=t}get typedValue(){return this.parse(this.unmaskedValue,this)}set typedValue(t){this.rawInputValue=this.format(t,this).replace(I.UNMASKED_RADIX,this.radix)}get number(){return this.typedValue}set number(t){this.typedValue=t}get allowNegative(){return null!=this.min&&this.min<0||null!=this.max&&this.max<0}get allowPositive(){return null!=this.min&&this.min>0||null!=this.max&&this.max>0}typedValueEquals(t){return(super.typedValueEquals(t)||I.EMPTY_VALUES.includes(t)&&I.EMPTY_VALUES.includes(this.typedValue))&&!(0===t&&""===this.value)}}I.UNMASKED_RADIX=".",I.EMPTY_VALUES=[...v.EMPTY_VALUES,0],I.DEFAULTS={mask:Number,radix:",",thousandsSeparator:"",mapToRadix:[I.UNMASKED_RADIX],min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,scale:2,normalizeZeros:!0,padFractionalZeros:!1,parse:Number,format:t=>t.toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:20})},h.MaskedNumber=I;const w={MASKED:"value",UNMASKED:"unmaskedValue",TYPED:"typedValue"};function V(t,e,s){void 0===e&&(e=w.MASKED),void 0===s&&(s=w.MASKED);const i=d(t);return t=>i.runIsolated((i=>(i[e]=t,i[s])))}function P(t,e,s,i){return V(e,s,i)(t)}h.PIPE_TYPE=w,h.createPipe=V,h.pipe=P;try{globalThis.IMask=h}catch(t){}t.ChangeDetails=f,t.ChunksTailDetails=E,t.DIRECTION=i,t.HTMLContenteditableMaskElement=k,t.HTMLInputMaskElement=g,t.HTMLMaskElement=c,t.InputMask=m,t.MaskElement=p,t.Masked=v,t.MaskedDate=b,t.MaskedDynamic=x,t.MaskedEnum=M,t.MaskedFunction=T,t.MaskedNumber=I,t.MaskedPattern=D,t.MaskedRange=B,t.MaskedRegExp=S,t.PIPE_TYPE=w,t.PatternFixedDefinition=F,t.PatternInputDefinition=C,t.createMask=d,t.createPipe=V,t.default=h,t.forceDirection=u,t.normalizeOpts=l,t.pipe=P,Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).IMask={})}(this,(function(t){"use strict";function e(t){return"string"==typeof t||t instanceof String}function s(t,e){return Array.isArray(e)?s(t,((t,s)=>e.includes(s))):Object.entries(t).reduce(((t,s)=>{let[i,u]=s;return e(u,i)&&(t[i]=u),t}),{})}const i={NONE:"NONE",LEFT:"LEFT",FORCE_LEFT:"FORCE_LEFT",RIGHT:"RIGHT",FORCE_RIGHT:"FORCE_RIGHT"};function u(t){switch(t){case i.LEFT:return i.FORCE_LEFT;case i.RIGHT:return i.FORCE_RIGHT;default:return t}}function a(t){return t.replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1")}function r(t,e){if(e===t)return!0;const s=Array.isArray(e),i=Array.isArray(t);let u;if(s&&i){if(e.length!=t.length)return!1;for(u=0;u<e.length;u++)if(!r(e[u],t[u]))return!1;return!0}if(s!=i)return!1;if(e&&t&&"object"==typeof e&&"object"==typeof t){const s=e instanceof Date,i=t instanceof Date;if(s&&i)return e.getTime()==t.getTime();if(s!=i)return!1;const a=e instanceof RegExp,n=t instanceof RegExp;if(a&&n)return e.toString()==t.toString();if(a!=n)return!1;const h=Object.keys(e);for(u=0;u<h.length;u++)if(!Object.prototype.hasOwnProperty.call(t,h[u]))return!1;for(u=0;u<h.length;u++)if(!r(t[h[u]],e[h[u]]))return!1;return!0}return!(!e||!t||"function"!=typeof e||"function"!=typeof t)&&e.toString()===t.toString()}class n{constructor(t){for(Object.assign(this,t);this.value.slice(0,this.startChangePos)!==this.oldValue.slice(0,this.startChangePos);)--this.oldSelection.start}get startChangePos(){return Math.min(this.cursorPos,this.oldSelection.start)}get insertedCount(){return this.cursorPos-this.startChangePos}get inserted(){return this.value.substr(this.startChangePos,this.insertedCount)}get removedCount(){return Math.max(this.oldSelection.end-this.startChangePos||this.oldValue.length-this.value.length,0)}get removed(){return this.oldValue.substr(this.startChangePos,this.removedCount)}get head(){return this.value.substring(0,this.startChangePos)}get tail(){return this.value.substring(this.startChangePos+this.insertedCount)}get removeDirection(){return!this.removedCount||this.insertedCount?i.NONE:this.oldSelection.end!==this.cursorPos&&this.oldSelection.start!==this.cursorPos||this.oldSelection.end!==this.oldSelection.start?i.LEFT:i.RIGHT}}function h(t,e){return new h.InputMask(t,e)}function o(t){if(null==t)throw new Error("mask property should be defined");return t instanceof RegExp?h.MaskedRegExp:e(t)?h.MaskedPattern:t===Date?h.MaskedDate:t===Number?h.MaskedNumber:Array.isArray(t)||t===Array?h.MaskedDynamic:h.Masked&&t.prototype instanceof h.Masked?t:h.Masked&&t instanceof h.Masked?t.constructor:t instanceof Function?h.MaskedFunction:(console.warn("Mask not found for mask",t),h.Masked)}function l(t){if(!t)throw new Error("Options in not defined");if(h.Masked){if(t.prototype instanceof h.Masked)return{mask:t};const{mask:e,...i}=t instanceof h.Masked?{mask:t}:t.mask instanceof h.Masked?t:{};if(e){const t=e.mask;return{...s(e,((t,e)=>!e.startsWith("_"))),mask:e.constructor,_mask:t,...i}}}return"object"!=typeof(e=t)||null==e||"Object"!==(null==e||null==(i=e.constructor)?void 0:i.name)?{mask:t}:{...t};var e,i}function d(t){if(h.Masked&&t instanceof h.Masked)return t;const e=l(t),s=o(e.mask);if(!s)throw new Error("Masked class is not found for provided mask, appropriate module needs to be imported manually before creating mask.");return e.mask===s&&delete e.mask,e._mask&&(e.mask=e._mask,delete e._mask),new s(e)}h.createMask=d;class p{get selectionStart(){let t;try{t=this._unsafeSelectionStart}catch{}return null!=t?t:this.value.length}get selectionEnd(){let t;try{t=this._unsafeSelectionEnd}catch{}return null!=t?t:this.value.length}select(t,e){if(null!=t&&null!=e&&(t!==this.selectionStart||e!==this.selectionEnd))try{this._unsafeSelect(t,e)}catch{}}_unsafeSelect(t,e){}get isActive(){return!1}bindEvents(t){}unbindEvents(){}}h.MaskElement=p;class c extends p{constructor(t){super(),this.input=t,this._handlers={}}get rootElement(){var t,e,s;return null!=(t=null==(e=(s=this.input).getRootNode)?void 0:e.call(s))?t:document}get isActive(){return this.input===this.rootElement.activeElement}bindEvents(t){Object.keys(t).forEach((e=>this._toggleEventHandler(c.EVENTS_MAP[e],t[e])))}unbindEvents(){Object.keys(this._handlers).forEach((t=>this._toggleEventHandler(t)))}_toggleEventHandler(t,e){this._handlers[t]&&(this.input.removeEventListener(t,this._handlers[t]),delete this._handlers[t]),e&&(this.input.addEventListener(t,e),this._handlers[t]=e)}}c.EVENTS_MAP={selectionChange:"keydown",input:"input",drop:"drop",click:"click",focus:"focus",commit:"blur"},h.HTMLMaskElement=c;class g extends c{constructor(t){super(t),this.input=t,this._handlers={}}get _unsafeSelectionStart(){return this.input.selectionStart}get _unsafeSelectionEnd(){return this.input.selectionEnd}_unsafeSelect(t,e){this.input.setSelectionRange(t,e)}get value(){return this.input.value}set value(t){this.input.value=t}}h.HTMLMaskElement=c;class k extends c{get _unsafeSelectionStart(){const t=this.rootElement,e=t.getSelection&&t.getSelection(),s=e&&e.anchorOffset,i=e&&e.focusOffset;return null==i||null==s||s<i?s:i}get _unsafeSelectionEnd(){const t=this.rootElement,e=t.getSelection&&t.getSelection(),s=e&&e.anchorOffset,i=e&&e.focusOffset;return null==i||null==s||s>i?s:i}_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,u=i.getSelection&&i.getSelection();u&&(u.removeAllRanges(),u.addRange(s))}get value(){return this.input.textContent}set value(t){this.input.textContent=t}}h.HTMLContenteditableMaskElement=k;class f{constructor(t,e){this.el=t instanceof p?t:t.isContentEditable&&"INPUT"!==t.tagName&&"TEXTAREA"!==t.tagName?new k(t):new g(t),this.masked=d(e),this._listeners={},this._value="",this._unmaskedValue="",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.alignCursor=this.alignCursor.bind(this),this.alignCursorFriendly=this.alignCursorFriendly.bind(this),this._bindEvents(),this.updateValue(),this._onChange()}maskEquals(t){var e;return null==t||(null==(e=this.masked)?void 0:e.maskEquals(t))}get mask(){return this.masked.mask}set mask(t){if(this.maskEquals(t))return;if(!(t instanceof h.Masked)&&this.masked.constructor===o(t))return void this.masked.updateOptions({mask:t});const e=t instanceof h.Masked?t:d({mask:t});e.unmaskedValue=this.masked.unmaskedValue,this.masked=e}get value(){return this._value}set value(t){this.value!==t&&(this.masked.value=t,this.updateControl(),this.alignCursor())}get unmaskedValue(){return this._unmaskedValue}set unmaskedValue(t){this.unmaskedValue!==t&&(this.masked.unmaskedValue=t,this.updateControl(),this.alignCursor())}get typedValue(){return this.masked.typedValue}set typedValue(t){this.masked.typedValueEquals(t)||(this.masked.typedValue=t,this.updateControl(),this.alignCursor())}get displayValue(){return this.masked.displayValue}_bindEvents(){this.el.bindEvents({selectionChange:this._saveSelection,input:this._onInput,drop:this._onDrop,click:this._onClick,focus:this._onFocus,commit:this._onChange})}_unbindEvents(){this.el&&this.el.unbindEvents()}_fireEvent(t,e){const s=this._listeners[t];s&&s.forEach((t=>t(e)))}get selectionStart(){return this._cursorChanging?this._changingCursorPos:this.el.selectionStart}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())}_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}}updateValue(){this.masked.value=this.el.value,this._value=this.masked.value}updateControl(){const t=this.masked.unmaskedValue,e=this.masked.value,s=this.displayValue,i=this.unmaskedValue!==t||this.value!==e;this._unmaskedValue=t,this._value=e,this.el.value!==s&&(this.el.value=s),i&&this._fireChangeEvents()}updateOptions(t){const{mask:e,...s}=t,i=!this.maskEquals(e),u=!r(this.masked,s);i&&(this.mask=e),u&&this.masked.updateOptions(s),(i||u)&&this.updateControl()}updateCursor(t){null!=t&&(this.cursorPos=t,this._delayUpdateCursor(t))}_delayUpdateCursor(t){this._abortUpdateCursor(),this._changingCursorPos=t,this._cursorChanging=setTimeout((()=>{this.el&&(this.cursorPos=this._changingCursorPos,this._abortUpdateCursor())}),10)}_fireChangeEvents(){this._fireEvent("accept",this._inputEvent),this.masked.isComplete&&this._fireEvent("complete",this._inputEvent)}_abortUpdateCursor(){this._cursorChanging&&(clearTimeout(this._cursorChanging),delete this._cursorChanging)}alignCursor(){this.cursorPos=this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos,i.LEFT))}alignCursorFriendly(){this.selectionStart===this.cursorPos&&this.alignCursor()}on(t,e){return this._listeners[t]||(this._listeners[t]=[]),this._listeners[t].push(e),this}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}_onInput(t){if(this._inputEvent=t,this._abortUpdateCursor(),!this._selection)return this.updateValue();const e=new n({value:this.el.value,cursorPos:this.cursorPos,oldValue:this.displayValue,oldSelection:this._selection}),s=this.masked.rawInputValue,u=this.masked.splice(e.startChangePos,e.removed.length,e.inserted,e.removeDirection,{input:!0,raw:!0}).offset,a=s===this.masked.rawInputValue?e.removeDirection:i.NONE;let r=this.masked.nearestInputPos(e.startChangePos+u,a);a!==i.NONE&&(r=this.masked.nearestInputPos(r,i.NONE)),this.updateControl(),this.updateCursor(r),delete this._inputEvent}_onChange(){this.displayValue!==this.el.value&&this.updateValue(),this.masked.doCommit(),this.updateControl(),this._saveSelection()}_onDrop(t){t.preventDefault(),t.stopPropagation()}_onFocus(t){this.alignCursorFriendly()}_onClick(t){this.alignCursorFriendly()}destroy(){this._unbindEvents(),this._listeners.length=0,delete this.el}}h.InputMask=f;class m{static normalize(t){return Array.isArray(t)?t:[t,new m]}constructor(t){Object.assign(this,{inserted:"",rawInserted:"",skip:!1,tailShift:0},t)}aggregate(t){return this.rawInserted+=t.rawInserted,this.skip=this.skip||t.skip,this.inserted+=t.inserted,this.tailShift+=t.tailShift,this}get offset(){return this.tailShift+this.inserted.length}}h.ChangeDetails=m;class _{constructor(t,e,s){void 0===t&&(t=""),void 0===e&&(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||null!=t&&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 v{constructor(t){this._value="",this._update({...v.DEFAULTS,...t}),this._initialized=!0}updateOptions(t){Object.keys(t).length&&this.withValueRefresh(this._update.bind(this,t))}_update(t){Object.assign(this,t)}get state(){return{_value:this.value,_rawInputValue:this.rawInputValue}}set state(t){this._value=t._value}reset(){this._value=""}get value(){return this._value}set value(t){this.resolve(t,{input:!0})}resolve(t,e){void 0===e&&(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)}get rawInputValue(){return this.extractInput(0,this.value.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}nearestInputPos(t,e){return t}totalInputPositions(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.value.length),Math.min(this.value.length,e-t)}extractInput(t,e,s){return void 0===t&&(t=0),void 0===e&&(e=this.value.length),this.value.slice(t,e)}extractTail(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.value.length),new _(this.extractInput(t,e),t)}appendTail(t){return e(t)&&(t=new _(String(t))),t.appendTo(this)}_appendCharRaw(t,e){return t?(this._value+=t,new m({inserted:t,rawInserted:t})):new m}_appendChar(t,e,s){void 0===e&&(e={});const i=this.state;let u;if([t,u]=this.doPrepareChar(t,e),u=u.aggregate(this._appendCharRaw(t,e)),u.inserted){let t,a=!1!==this.doValidate(e);if(a&&null!=s){const e=this.state;!0===this.overwrite&&(t=s.state,s.unshift(this.value.length-u.tailShift));let i=this.appendTail(s);a=i.rawInserted===s.toString(),a&&i.inserted||"shift"!==this.overwrite||(this.state=e,t=s.state,s.shift(),i=this.appendTail(s),a=i.rawInserted===s.toString()),a&&i.inserted&&(this.state=e)}a||(u=new m,this.state=i,s&&t&&(s.state=t))}return u}_appendPlaceholder(){return new m}_appendEager(){return new m}append(t,s,i){if(!e(t))throw new Error("value should be string");const u=e(i)?new _(String(i)):i;let a;null!=s&&s.tail&&(s._beforeTailState=this.state),[t,a]=this.doPrepare(t,s);for(let e=0;e<t.length;++e){const i=this._appendChar(t[e],s,u);if(!i.rawInserted&&!this.doSkipInvalid(t[e],s,u))break;a.aggregate(i)}return(!0===this.eager||"append"===this.eager)&&null!=s&&s.input&&t&&a.aggregate(this._appendEager()),null!=u&&(a.tailShift+=this.appendTail(u).tailShift),a}remove(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.value.length),this._value=this.value.slice(0,t)+this.value.slice(e),new m}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&&0===s.indexOf(this.value)&&this.append(s.slice(this.value.length),{},""),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 Boolean(this.skipInvalid)}doPrepare(t,e){return void 0===e&&(e={}),m.normalize(this.prepare?this.prepare(t,this,e):t)}doPrepareChar(t,e){return void 0===e&&(e={}),m.normalize(this.prepareChar?this.prepareChar(t,this,e):t)}doValidate(t){return(!this.validate||this.validate(this.value,this,t))&&(!this.parent||this.parent.doValidate(t))}doCommit(){this.commit&&this.commit(this.value,this)}splice(t,e,s,a,r){void 0===a&&(a=i.NONE),void 0===r&&(r={input:!0});const n=t+e,h=this.extractTail(n),o=!0===this.eager||"remove"===this.eager;let l;o&&(a=u(a),l=this.extractInput(0,n,{raw:!0}));let d=t;const p=new m;if(a!==i.NONE&&(d=this.nearestInputPos(t,e>1&&0!==t&&!o?i.NONE:a),p.tailShift=d-t),p.aggregate(this.remove(d)),o&&a!==i.NONE&&l===this.rawInputValue)if(a===i.FORCE_LEFT){let t;for(;l===this.rawInputValue&&(t=this.value.length);)p.aggregate(new m({tailShift:-1})).aggregate(this.remove(t-1))}else a===i.FORCE_RIGHT&&h.unshift();return p.aggregate(this.append(s,r,h))}maskEquals(t){return this.mask===t}typedValueEquals(t){const e=this.typedValue;return t===e||v.EMPTY_VALUES.includes(t)&&v.EMPTY_VALUES.includes(e)||this.format&&this.format(t,this)===this.format(this.typedValue,this)}}v.DEFAULTS={skipInvalid:!0},v.EMPTY_VALUES=[void 0,null,""],h.Masked=v;class E{constructor(t,e){void 0===t&&(t=[]),void 0===e&&(e=0),this.chunks=t,this.from=e}toString(){return this.chunks.map(String).join("")}extend(t){if(!String(t))return;t=e(t)?new _(String(t)):t;const s=this.chunks[this.chunks.length-1],i=s&&(s.stop===t.stop||null==t.stop)&&t.from===s.from+s.toString().length;if(t instanceof _)i?s.extend(t.toString()):this.chunks.push(t);else if(t instanceof E){if(null==t.stop){let e;for(;t.chunks.length&&null==t.chunks[0].stop;)e=t.chunks.shift(),e.from+=t.from,this.extend(e)}t.toString()&&(t.stop=t.blockIndex,this.chunks.push(t))}}appendTo(t){if(!(t instanceof h.MaskedPattern)){return new _(this.toString()).appendTo(t)}const e=new m;for(let s=0;s<this.chunks.length&&!e.skip;++s){const i=this.chunks[s],u=t._mapPosToBlock(t.value.length),a=i.stop;let r;if(null!=a&&(!u||u.index<=a)){if(i instanceof E||t._stops.indexOf(a)>=0){const s=t._appendPlaceholder(a);e.aggregate(s)}r=i instanceof E&&t._blocks[a]}if(r){const s=r.appendTail(i);s.skip=!1,e.aggregate(s),t._value+=s.inserted;const u=i.toString().slice(s.rawInserted.length);u&&e.aggregate(t.append(u,{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((t=>{const e="chunks"in t?new E:new _;return e.state=t,e}))}unshift(t){if(!this.chunks.length||null!=t&&this.from>=t)return"";const e=null!=t?t-this.from:t;let s=0;for(;s<this.chunks.length;){const t=this.chunks[s],i=t.unshift(e);if(t.toString()){if(!i)break;++s}else this.chunks.splice(s,1);if(i)return i}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 A{constructor(t,e){this.masked=t,this._log=[];const{offset:s,index:i}=t._mapPosToBlock(e)||(e<0?{index:0,offset:0}:{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 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.value.length))}_pushLeft(t){for(this.pushState(),this.bindBlock();0<=this.index;--this.index,this.offset=(null==(e=this.block)?void 0:e.value.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)return this.offset=this.block.nearestInputPos(this.offset,i.FORCE_LEFT),0!==this.offset||void 0}))}pushLeftBeforeInput(){return this._pushLeft((()=>{if(!this.block.isFixed)return this.offset=this.block.nearestInputPos(this.offset,i.LEFT),!0}))}pushLeftBeforeRequired(){return this._pushLeft((()=>{if(!(this.block.isFixed||this.block.isOptional&&!this.block.value))return this.offset=this.block.nearestInputPos(this.offset,i.LEFT),!0}))}pushRightBeforeFilled(){return this._pushRight((()=>{if(!this.block.isFixed&&this.block.value)return this.offset=this.block.nearestInputPos(this.offset,i.FORCE_RIGHT),this.offset!==this.block.value.length||void 0}))}pushRightBeforeInput(){return this._pushRight((()=>{if(!this.block.isFixed)return this.offset=this.block.nearestInputPos(this.offset,i.NONE),!0}))}pushRightBeforeRequired(){return this._pushRight((()=>{if(!(this.block.isFixed||this.block.isOptional&&!this.block.value))return this.offset=this.block.nearestInputPos(this.offset,i.NONE),!0}))}}class F{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 void 0===t&&(t=0),void 0===e&&(e=this._value.length),this._value=this._value.slice(0,t)+this._value.slice(e),this._value||(this._isRawInput=!1),new m}nearestInputPos(t,e){void 0===e&&(e=i.NONE);const s=this._value.length;switch(e){case i.LEFT:case i.FORCE_LEFT:return 0;default:return s}}totalInputPositions(t,e){return void 0===t&&(t=0),void 0===e&&(e=this._value.length),this._isRawInput?e-t:0}extractInput(t,e,s){return void 0===t&&(t=0),void 0===e&&(e=this._value.length),void 0===s&&(s={}),s.raw&&this._isRawInput&&this._value.slice(t,e)||""}get isComplete(){return!0}get isFilled(){return Boolean(this._value)}_appendChar(t,e){void 0===e&&(e={});const s=new m;if(this.isFilled)return s;const i=!0===this.eager||"append"===this.eager,u=this.char===t&&(this.isUnmasking||e.input||e.raw)&&(!e.raw||!i)&&!e.tail;return u&&(s.rawInserted=this.char),this._value=s.inserted=this.char,this._isRawInput=u&&(e.raw||e.input),s}_appendEager(){return this._appendChar(this.char,{tail:!0})}_appendPlaceholder(){const t=new m;return this.isFilled||(this._value=t.inserted=this.char),t}extractTail(){return new _("")}appendTail(t){return e(t)&&(t=new _(String(t))),t.appendTo(this)}append(t,e,s){const i=this._appendChar(t[0],e);return null!=s&&(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=Boolean(t._rawInputValue)}}class C{constructor(t){const{parent:e,isOptional:s,placeholderChar:i,displayChar:u,lazy:a,eager:r,...n}=t;this.masked=d(n),Object.assign(this,{parent:e,isOptional:s,placeholderChar:i,displayChar:u,lazy:a,eager:r})}reset(){this.isFilled=!1,this.masked.reset()}remove(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.value.length),0===t&&e>=1?(this.isFilled=!1,this.masked.remove(t,e)):new m}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 Boolean(this.masked.value)||this.isOptional}_appendChar(t,e){if(void 0===e&&(e={}),this.isFilled)return new m;const s=this.masked.state,i=this.masked._appendChar(t,this.currentMaskFlags(e));return i.inserted&&!1===this.doValidate(e)&&(i.inserted=i.rawInserted="",this.masked.state=s),i.inserted||this.isOptional||this.lazy||e.input||(i.inserted=this.placeholderChar),i.skip=!i.inserted&&!this.isOptional,this.isFilled=Boolean(i.inserted),i}append(t,e,s){return this.masked.append(t,this.currentMaskFlags(e),s)}_appendPlaceholder(){const t=new m;return this.isFilled||this.isOptional||(this.isFilled=!0,t.inserted=this.placeholderChar),t}_appendEager(){return new m}extractTail(t,e){return this.masked.extractTail(t,e)}appendTail(t){return this.masked.appendTail(t)}extractInput(t,e,s){return void 0===t&&(t=0),void 0===e&&(e=this.value.length),this.masked.extractInput(t,e,s)}nearestInputPos(t,e){void 0===e&&(e=i.NONE);const s=this.value.length,u=Math.min(Math.max(t,0),s);switch(e){case i.LEFT:case i.FORCE_LEFT:return this.isComplete?u:0;case i.RIGHT:case i.FORCE_RIGHT:return this.isComplete?u:s;default:return u}}totalInputPositions(t,e){return void 0===t&&(t=0),void 0===e&&(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:(null==(e=t._beforeTailState)?void 0:e.masked)||t._beforeTailState}}}C.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]/,"*":/./};class S extends v{updateOptions(t){super.updateOptions(t)}_update(t){t.mask&&(t.validate=e=>e.search(t.mask)>=0),super._update(t)}}h.MaskedRegExp=S;class D extends v{constructor(t){super({...D.DEFAULTS,...t,definitions:Object.assign({},C.DEFAULT_DEFINITIONS,null==t?void 0: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._stops=[],this._maskedBlocks={};const e=this.mask;if(!e||!t)return;let s=!1,i=!1;for(let u=0;u<e.length;++u){if(this.blocks){const t=e.slice(u),s=Object.keys(this.blocks).filter((e=>0===t.indexOf(e)));s.sort(((t,e)=>e.length-t.length));const i=s[0];if(i){const t=d({lazy:this.lazy,eager:this.eager,placeholderChar:this.placeholderChar,displayChar:this.displayChar,overwrite:this.overwrite,...l(this.blocks[i]),parent:this});t&&(this._blocks.push(t),this._maskedBlocks[i]||(this._maskedBlocks[i]=[]),this._maskedBlocks[i].push(this._blocks.length-1)),u+=i.length-1;continue}}let a=e[u],r=a in t;if(a===D.STOP_CHAR){this._stops.push(this._blocks.length);continue}if("{"===a||"}"===a){s=!s;continue}if("["===a||"]"===a){i=!i;continue}if(a===D.ESCAPE_CHAR){if(++u,a=e[u],!a)break;r=!1}const n=r?new C({isOptional:i,lazy:this.lazy,eager:this.eager,placeholderChar:this.placeholderChar,displayChar:this.displayChar,...l(t[a]),parent:this}):new F({char:a,eager:this.eager,isUnmasking:s});this._blocks.push(n)}}get state(){return{...super.state,_blocks:this._blocks.map((t=>t.state))}}set state(t){const{_blocks:e,...s}=t;this._blocks.forEach(((t,s)=>t.state=e[s])),super.state=s}reset(){super.reset(),this._blocks.forEach((t=>t.reset()))}get isComplete(){return 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._blocks.reduce(((t,e)=>t+e.unmaskedValue),"")}set unmaskedValue(t){super.unmaskedValue=t}get value(){return this._blocks.reduce(((t,e)=>t+e.value),"")}set value(t){super.value=t}get displayValue(){return this._blocks.reduce(((t,e)=>t+e.displayValue),"")}appendTail(t){return super.appendTail(t).aggregate(this._appendPlaceholder())}_appendEager(){var t;const e=new m;let s=null==(t=this._mapPosToBlock(this.value.length))?void 0:t.index;if(null==s)return e;this._blocks[s].isFilled&&++s;for(let t=s;t<this._blocks.length;++t){const s=this._blocks[t]._appendEager();if(!s.inserted)break;e.aggregate(s)}return e}_appendCharRaw(t,e){void 0===e&&(e={});const s=this._mapPosToBlock(this.value.length),i=new m;if(!s)return i;for(let r=s.index;;++r){var u,a;const s=this._blocks[r];if(!s)break;const n=s._appendChar(t,{...e,_beforeTailState:null==(u=e._beforeTailState)||null==(a=u._blocks)?void 0:a[r]}),h=n.skip;if(i.aggregate(n),h||n.rawInserted)break}return i}extractTail(t,e){void 0===t&&(t=0),void 0===e&&(e=this.value.length);const s=new E;return t===e||this._forEachBlocksInRange(t,e,((t,e,i,u)=>{const a=t.extractTail(i,u);a.stop=this._findStopBefore(e),a.from=this._blockStartPos(e),a instanceof E&&(a.blockIndex=e),s.extend(a)})),s}extractInput(t,e,s){if(void 0===t&&(t=0),void 0===e&&(e=this.value.length),void 0===s&&(s={}),t===e)return"";let i="";return this._forEachBlocksInRange(t,e,((t,e,u,a)=>{i+=t.extractInput(u,a,s)})),i}_findStopBefore(t){let e;for(let s=0;s<this._stops.length;++s){const i=this._stops[s];if(!(i<=t))break;e=i}return e}_appendPlaceholder(t){const e=new m;if(this.lazy&&null==t)return e;const s=this._mapPosToBlock(this.value.length);if(!s)return e;const i=s.index,u=null!=t?t:this._blocks.length;return this._blocks.slice(i,u).forEach((s=>{if(!s.lazy||null!=t){var i;const t=s._appendPlaceholder(null==(i=s._blocks)?void 0:i.length);this._value+=t.inserted,e.aggregate(t)}})),e}_mapPosToBlock(t){let e="";for(let s=0;s<this._blocks.length;++s){const i=this._blocks[s],u=e.length;if(e+=i.value,t<=e.length)return{index:s,offset:t-u}}}_blockStartPos(t){return this._blocks.slice(0,t).reduce(((t,e)=>t+e.value.length),0)}_forEachBlocksInRange(t,e,s){void 0===e&&(e=this.value.length);const i=this._mapPosToBlock(t);if(i){const t=this._mapPosToBlock(e),u=t&&i.index===t.index,a=i.offset,r=t&&u?t.offset:this._blocks[i.index].value.length;if(s(this._blocks[i.index],i.index,a,r),t&&!u){for(let e=i.index+1;e<t.index;++e)s(this._blocks[e],e,0,this._blocks[e].value.length);s(this._blocks[t.index],t.index,0,t.offset)}}}remove(t,e){void 0===t&&(t=0),void 0===e&&(e=this.value.length);const s=super.remove(t,e);return this._forEachBlocksInRange(t,e,((t,e,i,u)=>{s.aggregate(t.remove(i,u))})),s}nearestInputPos(t,e){if(void 0===e&&(e=i.NONE),!this._blocks.length)return 0;const s=new A(this,t);if(e===i.NONE)return s.pushRightBeforeInput()?s.pos:(s.popState(),s.pushLeftBeforeInput()?s.pos:this.value.length);if(e===i.LEFT||e===i.FORCE_LEFT){if(e===i.LEFT){if(s.pushRightBeforeFilled(),s.ok&&s.pos===t)return t;s.popState()}if(s.pushLeftBeforeInput(),s.pushLeftBeforeRequired(),s.pushLeftBeforeFilled(),e===i.LEFT){if(s.pushRightBeforeInput(),s.pushRightBeforeRequired(),s.ok&&s.pos<=t)return s.pos;if(s.popState(),s.ok&&s.pos<=t)return s.pos;s.popState()}return s.ok?s.pos:e===i.FORCE_LEFT?0:(s.popState(),s.ok?s.pos:(s.popState(),s.ok?s.pos:0))}return e===i.RIGHT||e===i.FORCE_RIGHT?(s.pushRightBeforeInput(),s.pushRightBeforeRequired(),s.pushRightBeforeFilled()?s.pos:e===i.FORCE_RIGHT?this.value.length:(s.popState(),s.ok?s.pos:(s.popState(),s.ok?s.pos:this.nearestInputPos(t,i.LEFT)))):t}totalInputPositions(t,e){void 0===t&&(t=0),void 0===e&&(e=this.value.length);let s=0;return this._forEachBlocksInRange(t,e,((t,e,i,u)=>{s+=t.totalInputPositions(i,u)})),s}maskedBlock(t){return this.maskedBlocks(t)[0]}maskedBlocks(t){const e=this._maskedBlocks[t];return e?e.map((t=>this._blocks[t])):[]}}D.DEFAULTS={lazy:!0,placeholderChar:"_"},D.STOP_CHAR="`",D.ESCAPE_CHAR="\\",D.InputDefinition=C,D.FixedDefinition=F,h.MaskedPattern=D;class B extends D{get _matchFrom(){return this.maxLength-String(this.from).length}constructor(t){super(t)}updateOptions(t){super.updateOptions(t)}_update(t){const{to:e=this.to||0,from:s=this.from||0,maxLength:i=this.maxLength||0,autofix:u=this.autofix,...a}=t;this.to=e,this.from=s,this.maxLength=Math.max(String(e).length,i),this.autofix=u;const r=String(this.from).padStart(this.maxLength,"0"),n=String(this.to).padStart(this.maxLength,"0");let h=0;for(;h<n.length&&n[h]===r[h];)++h;a.mask=n.slice(0,h).replace(/0/g,"\\0")+"0".repeat(this.maxLength-h),super._update(a)}get isComplete(){return super.isComplete&&Boolean(this.value)}boundaries(t){let e="",s="";const[,i,u]=t.match(/^(\D*)(\d*)(\D*)/)||[];return u&&(e="0".repeat(i.length)+u,s="9".repeat(i.length)+u),e=e.padEnd(this.maxLength,"0"),s=s.padEnd(this.maxLength,"9"),[e,s]}doPrepareChar(t,e){let s;if(void 0===e&&(e={}),[t,s]=super.doPrepareChar(t.replace(/\D/g,""),e),!this.autofix||!t)return[t,s];const i=String(this.from).padStart(this.maxLength,"0"),u=String(this.to).padStart(this.maxLength,"0"),a=this.value+t;if(a.length>this.maxLength)return["",s];const[r,n]=this.boundaries(a);return Number(n)<this.from?[i[a.length-1],s]:Number(r)>this.to?"pad"===this.autofix&&a.length<this.maxLength?["",s.aggregate(this.append(i[a.length-1]+t,e))]:[u[a.length-1],s]:[t,s]}doValidate(t){const e=this.value;if(-1===e.search(/[^0]/)&&e.length<=this._matchFrom)return!0;const[s,i]=this.boundaries(e);return this.from<=Number(i)&&Number(s)<=this.to&&super.doValidate(t)}}h.MaskedRange=B;class b extends D{constructor(t){const{mask:s,pattern:i,...u}={...b.DEFAULTS,...t};super({...u,mask:e(s)?s:i})}updateOptions(t){super.updateOptions(t)}_update(t){const{mask:s,pattern:i,blocks:u,...a}={...b.DEFAULTS,...t},r=Object.assign({},b.GET_DEFAULT_BLOCKS());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,u),Object.keys(r).forEach((e=>{const s=r[e];!("autofix"in s)&&"autofix"in t&&(s.autofix=t.autofix)})),super._update({...a,mask:e(s)?s:i,blocks:r})}doValidate(t){const e=this.date;return super.doValidate(t)&&(!this.isComplete||this.isDateExist(this.value)&&null!=e&&(null==this.min||this.min<=e)&&(null==this.max||e<=this.max))}isDateExist(t){return this.format(this.parse(t,this),this).indexOf(t)>=0}get date(){return this.typedValue}set date(t){this.typedValue=t}get typedValue(){return this.isComplete?super.typedValue:null}set typedValue(t){super.typedValue=t}maskEquals(t){return t===Date||super.maskEquals(t)}}b.GET_DEFAULT_BLOCKS=()=>({d:{mask:B,from:1,to:31,maxLength:2},m:{mask:B,from:1,to:12,maxLength:2},Y:{mask:B,from:1900,to:9999}}),b.DEFAULTS={mask:Date,pattern:"d{.}`m{.}`Y",format:t=>{if(!t)return"";return[String(t.getDate()).padStart(2,"0"),String(t.getMonth()+1).padStart(2,"0"),t.getFullYear()].join(".")},parse:t=>{const[e,s,i]=t.split(".").map(Number);return new Date(i,s-1,e)}},h.MaskedDate=b;class x extends v{constructor(t){super({...x.DEFAULTS,...t}),this.currentMask=null}updateOptions(t){super.updateOptions(t)}_update(t){super._update(t),"mask"in t&&(this.compiledMasks=Array.isArray(t.mask)?t.mask.map((t=>d({overwrite:this._overwrite,eager:this._eager,skipInvalid:this._skipInvalid,...l(t)}))):[])}_appendCharRaw(t,e){void 0===e&&(e={});const s=this._applyDispatch(t,e);return this.currentMask&&s.aggregate(this.currentMask._appendChar(t,this.currentMaskFlags(e))),s}_applyDispatch(t,e,s){void 0===t&&(t=""),void 0===e&&(e={}),void 0===s&&(s="");const i=e.tail&&null!=e._beforeTailState?e._beforeTailState._value:this.value,u=this.rawInputValue,a=e.tail&&null!=e._beforeTailState?e._beforeTailState._rawInputValue:u,r=u.slice(a.length),n=this.currentMask,h=new m,o=null==n?void 0:n.state;if(this.currentMask=this.doDispatch(t,{...e},s),this.currentMask)if(this.currentMask!==n){if(this.currentMask.reset(),a){const t=this.currentMask.append(a,{raw:!0});h.tailShift=t.inserted.length-i.length}r&&(h.tailShift+=this.currentMask.append(r,{raw:!0,tail:!0}).tailShift)}else this.currentMask.state=o;return h}_appendPlaceholder(){const t=this._applyDispatch();return this.currentMask&&t.aggregate(this.currentMask._appendPlaceholder()),t}_appendEager(){const t=this._applyDispatch();return this.currentMask&&t.aggregate(this.currentMask._appendEager()),t}appendTail(t){const e=new m;return t&&e.aggregate(this._applyDispatch("",{},t)),e.aggregate(this.currentMask?this.currentMask.appendTail(t):super.appendTail(t))}currentMaskFlags(t){var e,s;return{...t,_beforeTailState:(null==(e=t._beforeTailState)?void 0:e.currentMaskRef)===this.currentMask&&(null==(s=t._beforeTailState)?void 0:s.currentMask)||t._beforeTailState}}doDispatch(t,e,s){return void 0===e&&(e={}),void 0===s&&(s=""),this.dispatch(t,this,e,s)}doValidate(t){return super.doValidate(t)&&(!this.currentMask||this.currentMask.doValidate(this.currentMaskFlags(t)))}doPrepare(t,e){void 0===e&&(e={});let[s,i]=super.doPrepare(t,e);if(this.currentMask){let t;[s,t]=super.doPrepare(s,this.currentMaskFlags(e)),i=i.aggregate(t)}return[s,i]}doPrepareChar(t,e){void 0===e&&(e={});let[s,i]=super.doPrepareChar(t,e);if(this.currentMask){let t;[s,t]=super.doPrepareChar(s,this.currentMaskFlags(e)),i=i.aggregate(t)}return[s,i]}reset(){var t;null==(t=this.currentMask)||t.reset(),this.compiledMasks.forEach((t=>t.reset()))}get value(){return this.currentMask?this.currentMask.value:""}set value(t){super.value=t}get unmaskedValue(){return this.currentMask?this.currentMask.unmaskedValue:""}set unmaskedValue(t){super.unmaskedValue=t}get typedValue(){return this.currentMask?this.currentMask.typedValue:""}set typedValue(t){let e=String(t);this.currentMask&&(this.currentMask.typedValue=t,e=this.currentMask.unmaskedValue),this.unmaskedValue=e}get displayValue(){return this.currentMask?this.currentMask.displayValue:""}get isComplete(){var t;return Boolean(null==(t=this.currentMask)?void 0:t.isComplete)}get isFilled(){var t;return Boolean(null==(t=this.currentMask)?void 0:t.isFilled)}remove(t,e){const s=new m;return this.currentMask&&s.aggregate(this.currentMask.remove(t,e)).aggregate(this._applyDispatch()),s}get state(){var t;return{...super.state,_rawInputValue:this.rawInputValue,compiledMasks:this.compiledMasks.map((t=>t.state)),currentMaskRef:this.currentMask,currentMask:null==(t=this.currentMask)?void 0:t.state}}set state(t){const{compiledMasks:e,currentMaskRef:s,currentMask:i,...u}=t;e&&this.compiledMasks.forEach(((t,s)=>t.state=e[s])),null!=s&&(this.currentMask=s,this.currentMask.state=i),super.state=u}extractInput(t,e,s){return this.currentMask?this.currentMask.extractInput(t,e,s):""}extractTail(t,e){return this.currentMask?this.currentMask.extractTail(t,e):super.extractTail(t,e)}doCommit(){this.currentMask&&this.currentMask.doCommit(),super.doCommit()}nearestInputPos(t,e){return this.currentMask?this.currentMask.nearestInputPos(t,e):super.nearestInputPos(t,e)}get overwrite(){return this.currentMask?this.currentMask.overwrite:this._overwrite}set overwrite(t){this._overwrite=t}get eager(){return this.currentMask?this.currentMask.eager:this._eager}set eager(t){this._eager=t}get skipInvalid(){return this.currentMask?this.currentMask.skipInvalid:this._skipInvalid}set skipInvalid(t){this._skipInvalid=t}maskEquals(t){return Array.isArray(t)?this.compiledMasks.every(((e,s)=>{if(!t[s])return;const{mask:i,...u}=t[s];return r(e,u)&&e.maskEquals(i)})):super.maskEquals(t)}typedValueEquals(t){var e;return Boolean(null==(e=this.currentMask)?void 0:e.typedValueEquals(t))}}x.DEFAULTS=void 0,x.DEFAULTS={dispatch:(t,e,s,u)=>{if(!e.compiledMasks.length)return;const a=e.rawInputValue,r=e.compiledMasks.map(((r,n)=>{const h=e.currentMask===r,o=h?r.value.length:r.nearestInputPos(r.value.length,i.FORCE_LEFT);return r.rawInputValue!==a?(r.reset(),r.append(a,{raw:!0})):h||r.remove(o),r.append(t,e.currentMaskFlags(s)),r.appendTail(u),{index:n,weight:r.rawInputValue.length,totalInputPositions:r.totalInputPositions(0,Math.max(o,r.nearestInputPos(r.value.length,i.FORCE_LEFT)))}}));return r.sort(((t,e)=>e.weight-t.weight||e.totalInputPositions-t.totalInputPositions)),e.compiledMasks[r[0].index]}},h.MaskedDynamic=x;class M extends D{updateOptions(t){super.updateOptions(t)}_update(t){const{enum:e,...s}=t;this.enum=e,e&&(s.mask="*".repeat(e[0].length)),super._update(s)}doValidate(t){return this.enum.some((t=>t.indexOf(this.unmaskedValue)>=0))&&super.doValidate(t)}}h.MaskedEnum=M;class T extends v{updateOptions(t){super.updateOptions(t)}_update(t){super._update({...t,validate:t.mask})}}h.MaskedFunction=T;class I extends v{constructor(t){super({...I.DEFAULTS,...t})}updateOptions(t){super.updateOptions(t)}_update(t){super._update(t),this._updateRegExps()}_updateRegExps(){const t="^"+(this.allowNegative?"[+|\\-]?":""),e=(this.scale?"("+a(this.radix)+"\\d{0,"+this.scale+"})?":"")+"$";this._numberRegExp=new RegExp(t+"\\d*"+e),this._mapToRadixRegExp=new RegExp("["+this.mapToRadix.map(a).join("")+"]","g"),this._thousandsSeparatorRegExp=new RegExp(a(this.thousandsSeparator),"g")}_removeThousandsSeparators(t){return t.replace(this._thousandsSeparatorRegExp,"")}_insertThousandsSeparators(t){const e=t.split(this.radix);return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,this.thousandsSeparator),e.join(this.radix)}doPrepareChar(t,e){void 0===e&&(e={}),t=this._removeThousandsSeparators(this.scale&&this.mapToRadix.length&&(e.input&&e.raw||!e.input&&!e.raw)?t.replace(this._mapToRadixRegExp,this.radix):t);const[s,i]=super.doPrepareChar(t,e);return t&&!s&&(i.skip=!0),!s||this.allowPositive||this.value||"-"===s||i.aggregate(this._appendChar("-")),[s,i]}_separatorsCount(t,e){void 0===e&&(e=!1);let s=0;for(let i=0;i<t;++i)this._value.indexOf(this.thousandsSeparator,i)===i&&(++s,e&&(t+=this.thousandsSeparator.length));return s}_separatorsCountFromSlice(t){return void 0===t&&(t=this._value),this._separatorsCount(this._removeThousandsSeparators(t).length,!0)}extractInput(t,e,s){return void 0===t&&(t=0),void 0===e&&(e=this.value.length),[t,e]=this._adjustRangeWithSeparators(t,e),this._removeThousandsSeparators(super.extractInput(t,e,s))}_appendCharRaw(t,e){if(void 0===e&&(e={}),!this.thousandsSeparator)return super._appendCharRaw(t,e);const s=e.tail&&e._beforeTailState?e._beforeTailState._value:this._value,i=this._separatorsCountFromSlice(s);this._value=this._removeThousandsSeparators(this.value);const u=super._appendCharRaw(t,e);this._value=this._insertThousandsSeparators(this._value);const a=e.tail&&e._beforeTailState?e._beforeTailState._value:this._value,r=this._separatorsCountFromSlice(a);return u.tailShift+=(r-i)*this.thousandsSeparator.length,u.skip=!u.rawInserted&&t===this.thousandsSeparator,u}_findSeparatorAround(t){if(this.thousandsSeparator){const e=t-this.thousandsSeparator.length+1,s=this.value.indexOf(this.thousandsSeparator,e);if(s<=t)return s}return-1}_adjustRangeWithSeparators(t,e){const s=this._findSeparatorAround(t);s>=0&&(t=s);const i=this._findSeparatorAround(e);return i>=0&&(e=i+this.thousandsSeparator.length),[t,e]}remove(t,e){void 0===t&&(t=0),void 0===e&&(e=this.value.length),[t,e]=this._adjustRangeWithSeparators(t,e);const s=this.value.slice(0,t),i=this.value.slice(e),u=this._separatorsCount(s.length);this._value=this._insertThousandsSeparators(this._removeThousandsSeparators(s+i));const a=this._separatorsCountFromSlice(s);return new m({tailShift:(a-u)*this.thousandsSeparator.length})}nearestInputPos(t,e){if(!this.thousandsSeparator)return t;switch(e){case i.NONE:case i.LEFT:case i.FORCE_LEFT:{const s=this._findSeparatorAround(t-1);if(s>=0){const u=s+this.thousandsSeparator.length;if(t<u||this.value.length<=u||e===i.FORCE_LEFT)return s}break}case i.RIGHT:case i.FORCE_RIGHT:{const e=this._findSeparatorAround(t);if(e>=0)return e+this.thousandsSeparator.length}}return t}doValidate(t){let e=Boolean(this._removeThousandsSeparators(this.value).match(this._numberRegExp));if(e){const t=this.number;e=e&&!isNaN(t)&&(null==this.min||this.min>=0||this.min<=this.number)&&(null==this.max||this.max<=0||this.number<=this.max)}return e&&super.doValidate(t)}doCommit(){if(this.value){const t=this.number;let e=t;null!=this.min&&(e=Math.max(e,this.min)),null!=this.max&&(e=Math.min(e,this.max)),e!==t&&(this.unmaskedValue=this.format(e,this));let s=this.value;this.normalizeZeros&&(s=this._normalizeZeros(s)),this.padFractionalZeros&&this.scale>0&&(s=this._padFractionalZeros(s)),this._value=s}super.doCommit()}_normalizeZeros(t){const e=this._removeThousandsSeparators(t).split(this.radix);return e[0]=e[0].replace(/^(\D*)(0*)(\d*)/,((t,e,s,i)=>e+i)),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))}_padFractionalZeros(t){if(!t)return t;const e=t.split(this.radix);return e.length<2&&e.push(""),e[1]=e[1].padEnd(this.scale,"0"),e.join(this.radix)}doSkipInvalid(t,e,s){void 0===e&&(e={});const i=0===this.scale&&t!==this.thousandsSeparator&&(t===this.radix||t===I.UNMASKED_RADIX||this.mapToRadix.includes(t));return super.doSkipInvalid(t,e,s)&&!i}get unmaskedValue(){return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix,I.UNMASKED_RADIX)}set unmaskedValue(t){super.unmaskedValue=t}get typedValue(){return this.parse(this.unmaskedValue,this)}set typedValue(t){this.rawInputValue=this.format(t,this).replace(I.UNMASKED_RADIX,this.radix)}get number(){return this.typedValue}set number(t){this.typedValue=t}get allowNegative(){return null!=this.min&&this.min<0||null!=this.max&&this.max<0}get allowPositive(){return null!=this.min&&this.min>0||null!=this.max&&this.max>0}typedValueEquals(t){return(super.typedValueEquals(t)||I.EMPTY_VALUES.includes(t)&&I.EMPTY_VALUES.includes(this.typedValue))&&!(0===t&&""===this.value)}}I.UNMASKED_RADIX=".",I.EMPTY_VALUES=[...v.EMPTY_VALUES,0],I.DEFAULTS={mask:Number,radix:",",thousandsSeparator:"",mapToRadix:[I.UNMASKED_RADIX],min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,scale:2,normalizeZeros:!0,padFractionalZeros:!1,parse:Number,format:t=>t.toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:20})},h.MaskedNumber=I;const w={MASKED:"value",UNMASKED:"unmaskedValue",TYPED:"typedValue"};function V(t,e,s){void 0===e&&(e=w.MASKED),void 0===s&&(s=w.MASKED);const i=d(t);return t=>i.runIsolated((i=>(i[e]=t,i[s])))}function P(t,e,s,i){return V(e,s,i)(t)}h.PIPE_TYPE=w,h.createPipe=V,h.pipe=P;try{globalThis.IMask=h}catch{}t.ChangeDetails=m,t.ChunksTailDetails=E,t.DIRECTION=i,t.HTMLContenteditableMaskElement=k,t.HTMLInputMaskElement=g,t.HTMLMaskElement=c,t.InputMask=f,t.MaskElement=p,t.Masked=v,t.MaskedDate=b,t.MaskedDynamic=x,t.MaskedEnum=M,t.MaskedFunction=T,t.MaskedNumber=I,t.MaskedPattern=D,t.MaskedRange=B,t.MaskedRegExp=S,t.PIPE_TYPE=w,t.PatternFixedDefinition=F,t.PatternInputDefinition=C,t.createMask=d,t.createPipe=V,t.default=h,t.forceDirection=u,t.normalizeOpts=l,t.pipe=P,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=imask.min.js.map

@@ -20,3 +20,3 @@ import IMask from './imask';

export { default as ChunksTailDetails, type ChunksTailState } from './masked/pattern/chunk-tail-details';
export { default as PatternFixedDefinition, type PatternFixedDefinitionOptions, type PatternFixedDefinitionState } from './masked/pattern/fixed-definition';
export { default as PatternFixedDefinition, type PatternFixedDefinitionOptions } from './masked/pattern/fixed-definition';
export { default as PatternInputDefinition, type PatternInputDefinitionOptions, type PatternInputDefinitionState } from './masked/pattern/input-definition';

@@ -23,0 +23,0 @@ export { createPipe, pipe, PIPE_TYPE } from './masked/pipe';

@@ -6,2 +6,3 @@ import ChangeDetails from '../core/change-details';

_value: string;
_rawInputValue: string;
};

@@ -24,3 +25,3 @@ /** Append flags */

static EMPTY_VALUES: Array<any>;
/** @type {Mask} */
/** */
mask: unknown;

@@ -27,0 +28,0 @@ /** */

@@ -7,3 +7,2 @@ import ChangeDetails from '../core/change-details';

export type MaskedDynamicState = MaskedState & {
_rawInputValue: string;
compiledMasks: Array<MaskedState>;

@@ -15,2 +14,3 @@ currentMaskRef?: Masked;

export type MaskedDynamicOptions = MaskedOptions<MaskedDynamic, 'dispatch'>;
type HandleState = MaskedDynamicState | MaskedState;
/** Dynamic mask for choosing appropriate mask in run-time */

@@ -25,3 +25,3 @@ export default class MaskedDynamic<Value = any> extends Masked<Value> {

/** Chooses {@link Masked} depending on input value */
dispatch: (appended: string, masked: MaskedDynamic, flags: AppendFlags<MaskedDynamicState>, tail: string | String | TailDetails) => (Masked | undefined);
dispatch: (appended: string, masked: MaskedDynamic, flags: AppendFlags<HandleState>, tail: string | String | TailDetails) => (Masked | undefined);
_overwrite?: this['overwrite'];

@@ -33,12 +33,12 @@ _eager?: this['eager'];

_update(opts: Partial<MaskedDynamicOptions>): void;
_appendCharRaw(ch: string, flags?: AppendFlags<MaskedDynamicState>): ChangeDetails;
_applyDispatch(appended?: string, flags?: AppendFlags<MaskedDynamicState>, tail?: string | String | TailDetails): ChangeDetails;
_appendCharRaw(ch: string, flags?: AppendFlags<HandleState>): ChangeDetails;
_applyDispatch(appended?: string, flags?: AppendFlags<HandleState>, tail?: string | String | TailDetails): ChangeDetails;
_appendPlaceholder(): ChangeDetails;
_appendEager(): ChangeDetails;
appendTail(tail: string | String | TailDetails): ChangeDetails;
currentMaskFlags(flags: AppendFlags<MaskedDynamicState>): AppendFlags;
doDispatch(appended: string, flags?: AppendFlags<MaskedDynamicState>, tail?: string | String | TailDetails): Masked | undefined;
doValidate(flags: AppendFlags<MaskedDynamicState>): boolean;
doPrepare(str: string, flags?: AppendFlags<MaskedDynamicState>): [string, ChangeDetails];
doPrepareChar(str: string, flags?: AppendFlags<MaskedDynamicState>): [string, ChangeDetails];
currentMaskFlags(flags: AppendFlags<HandleState>): AppendFlags;
doDispatch(appended: string, flags?: AppendFlags<HandleState>, tail?: string | String | TailDetails): Masked | undefined;
doValidate(flags: AppendFlags<HandleState>): boolean;
doPrepare(str: string, flags?: AppendFlags<HandleState>): [string, ChangeDetails];
doPrepareChar(str: string, flags?: AppendFlags<HandleState>): [string, ChangeDetails];
reset(): void;

@@ -56,3 +56,3 @@ get value(): string;

get state(): MaskedDynamicState;
set state(state: MaskedDynamicState);
set state(state: HandleState);
extractInput(fromPos?: number, toPos?: number, flags?: ExtractFlags): string;

@@ -71,2 +71,3 @@ extractTail(fromPos?: number, toPos?: number): TailDetails;

}
export {};
//# sourceMappingURL=dynamic.d.ts.map

@@ -16,3 +16,3 @@ import ChangeDetails from '../core/change-details';

export type MaskedPatternState = MaskedState & {
_blocks: Array<any>;
_blocks: Array<MaskedState>;
};

@@ -19,0 +19,0 @@ export type BlockPosData = {

import type ChangeDetails from '../../core/change-details';
import { type TailDetails } from '../../core/tail-details';
import { type ExtractFlags, type AppendFlags } from '../base';
import { type ExtractFlags, type AppendFlags, type MaskedState } from '../base';
import { type Direction } from '../../core/utils';

@@ -9,3 +9,3 @@ /**

*/
export default interface PatternBlock {
export default interface PatternBlock<State = MaskedState> {
readonly value: string;

@@ -25,5 +25,5 @@ readonly unmaskedValue: string;

extractTail(fromPos?: number, toPos?: number): TailDetails;
append(str: string, flags?: AppendFlags, tail?: TailDetails): ChangeDetails;
append(str: string, flags?: AppendFlags<State>, tail?: TailDetails): ChangeDetails;
appendTail(tail: string | TailDetails): ChangeDetails;
_appendChar(str: string, flags: AppendFlags): ChangeDetails;
_appendChar(str: string, flags: AppendFlags<State>): ChangeDetails;
_appendPlaceholder(toBlockIndex?: number): ChangeDetails;

@@ -30,0 +30,0 @@ _appendEager(): ChangeDetails;

@@ -7,3 +7,2 @@ import ChangeDetails from '../../core/change-details';

export type PatternFixedDefinitionOptions = Pick<PatternFixedDefinition, 'char' | 'isUnmasking' | 'eager'>;
export type PatternFixedDefinitionState = MaskedState & Pick<PatternFixedDefinition, '_isRawInput'>;
export default class PatternFixedDefinition implements PatternBlock {

@@ -25,2 +24,3 @@ /** */

get unmaskedValue(): string;
get rawInputValue(): string;
get displayValue(): string;

@@ -37,9 +37,9 @@ reset(): void;

_appendPlaceholder(): ChangeDetails;
extractTail(fromPos?: number, toPos?: number): TailDetails;
extractTail(): TailDetails;
appendTail(tail: string | String | TailDetails): ChangeDetails;
append(str: string, flags?: AppendFlags, tail?: TailDetails): ChangeDetails;
doCommit(): void;
get state(): PatternFixedDefinitionState;
set state(state: PatternFixedDefinitionState);
get state(): MaskedState;
set state(state: MaskedState);
}
//# sourceMappingURL=fixed-definition.d.ts.map

@@ -1,6 +0,6 @@

import { type FactoryOpts } from '../factory';
import { type FactoryOpts, type FactoryReturnMasked } from '../factory';
import type Masked from '../base';
import type MaskedPattern from '../pattern';
import { type TailDetails } from '../../core/tail-details';
import { type ExtractFlags, type AppendFlags } from '../base';
import { type ExtractFlags, type AppendFlags, type MaskedState } from '../base';
import ChangeDetails from '../../core/change-details';

@@ -10,7 +10,7 @@ import { type Direction } from '../../core/utils';

export type PatternInputDefinitionOptions<Opts extends FactoryOpts> = Omit<Opts, 'parent' | 'isOptional' | 'lazy' | 'eager' | 'placeholderChar' | 'displayChar'> & Partial<Pick<PatternInputDefinition, 'parent' | 'isOptional' | 'lazy' | 'eager' | 'placeholderChar' | 'displayChar'>>;
export type PatternInputDefinitionState = {
masked: Masked['state'];
export type PatternInputDefinitionState<Opts> = MaskedState & {
masked: FactoryReturnMasked<Opts>['state'];
isFilled: boolean;
};
export default class PatternInputDefinition<Opts extends FactoryOpts = any> implements PatternBlock {
export default class PatternInputDefinition<Opts extends FactoryOpts = any> implements PatternBlock<PatternInputDefinitionState<Opts>> {
static DEFAULT_DEFINITIONS: {

@@ -20,3 +20,3 @@ [k: string]: RegExp;

/** */
readonly masked: Masked;
readonly masked: FactoryReturnMasked<Opts>;
/** */

@@ -41,6 +41,7 @@ parent: Masked;

get unmaskedValue(): string;
get rawInputValue(): string;
get displayValue(): string;
get isComplete(): boolean;
_appendChar(ch: string, flags?: AppendFlags): ChangeDetails;
append(str: string, flags?: AppendFlags, tail?: TailDetails): ChangeDetails;
_appendChar(ch: string, flags?: AppendFlags<PatternInputDefinitionState<Opts>>): ChangeDetails;
append(str: string, flags?: AppendFlags<PatternInputDefinitionState<Opts>>, tail?: TailDetails): ChangeDetails;
_appendPlaceholder(): ChangeDetails;

@@ -53,7 +54,8 @@ _appendEager(): ChangeDetails;

totalInputPositions(fromPos?: number, toPos?: number): number;
doValidate(flags: AppendFlags): boolean;
doValidate(flags: AppendFlags<PatternInputDefinitionState<Opts>>): boolean;
doCommit(): void;
get state(): PatternInputDefinitionState;
set state(state: PatternInputDefinitionState);
get state(): PatternInputDefinitionState<Opts>;
set state(state: PatternInputDefinitionState<Opts>);
currentMaskFlags(flags: AppendFlags<PatternInputDefinitionState<Opts>>): AppendFlags;
}
//# sourceMappingURL=input-definition.d.ts.map

@@ -22,5 +22,5 @@ import { type Selection } from '../core/utils';

constructor(el: InputMaskElement, opts: Opts);
maskEquals(mask: any): boolean;
/** Read or update mask */
get mask(): FactoryReturnMasked<Opts>['mask'];
maskEquals(mask: any): boolean;
set mask(mask: any);

@@ -27,0 +27,0 @@ /** Raw value */

@@ -38,2 +38,6 @@ import { objectIncludes, DIRECTION } from '../core/utils.js';

}
maskEquals(mask) {
var _this$masked;
return mask == null || ((_this$masked = this.masked) == null ? void 0 : _this$masked.maskEquals(mask));
}

@@ -44,6 +48,2 @@ /** Read or update mask */

}
maskEquals(mask) {
var _this$masked;
return mask == null || ((_this$masked = this.masked) == null ? void 0 : _this$masked.maskEquals(mask));
}
set mask(mask) {

@@ -50,0 +50,0 @@ if (this.maskEquals(mask)) return;

export type ElementEvent = 'selectionChange' | 'input' | 'drop' | 'click' | 'focus' | 'commit';
/**
Generic element API to use with mask
@interface
*/
/** Generic element API to use with mask */
export default class MaskElement {

@@ -7,0 +4,0 @@ /** */

import IMask from '../core/holder.js';
/**
Generic element API to use with mask
@interface
*/
/** Generic element API to use with mask */
class MaskElement {

@@ -19,3 +16,3 @@ /** */

start = this._unsafeSelectionStart;
} catch (e) {}
} catch {}
return start != null ? start : this.value.length;

@@ -29,3 +26,3 @@ }

end = this._unsafeSelectionEnd;
} catch (e) {}
} catch {}
return end != null ? end : this.value.length;

@@ -39,3 +36,3 @@ }

this._unsafeSelect(start, end);
} catch (e) {}
} catch {}
}

@@ -42,0 +39,0 @@

export type ChangeDetailsOptions = Pick<ChangeDetails, 'inserted' | 'skip' | 'tailShift' | 'rawInserted'>;
/**
Provides details of changing model value
*/
/** Provides details of changing model value */
export default class ChangeDetails {

@@ -16,6 +14,3 @@ /** Inserted symbols */

constructor(details?: Partial<ChangeDetailsOptions>);
/**
Aggregate changes
@returns {ChangeDetails} `this`
*/
/** Aggregate changes */
aggregate(details: ChangeDetails): this;

@@ -22,0 +17,0 @@ /** Total offset considering all changes */

import IMask from './holder.js';
/**
Provides details of changing model value
*/
/** Provides details of changing model value */
class ChangeDetails {

@@ -27,6 +25,3 @@ /** Inserted symbols */

/**
Aggregate changes
@returns {ChangeDetails} `this`
*/
/** Aggregate changes */
aggregate(details) {

@@ -33,0 +28,0 @@ this.rawInserted += details.rawInserted;

/** Checks if value is string */
export declare function isString(str: unknown): str is string;
/** Checks if value is object */
export declare function isObject(obj: unknown): obj is Object;
export declare function isObject(obj: unknown): obj is object;
export declare function pick<T, K extends keyof T, V>(obj: T, keys: K[] | ((v: V, k: K) => boolean)): Pick<T, K>;
/**
Direction
@prop {string} NONE
@prop {string} LEFT
@prop {string} FORCE_LEFT
@prop {string} RIGHT
@prop {string} FORCE_RIGHT
*/
/** Direction */
export declare const DIRECTION: {

@@ -21,6 +14,3 @@ readonly NONE: "NONE";

};
/**
Direction
@enum {string}
*/
/** Direction */
export type Direction = typeof DIRECTION[keyof typeof DIRECTION];

@@ -27,0 +17,0 @@ export declare function forceDirection(direction: Direction): Direction;

@@ -20,10 +20,3 @@ /** Checks if value is string */

/**
Direction
@prop {string} NONE
@prop {string} LEFT
@prop {string} FORCE_LEFT
@prop {string} RIGHT
@prop {string} FORCE_RIGHT
*/
/** Direction */
const DIRECTION = {

@@ -37,6 +30,3 @@ NONE: 'NONE',

/**
Direction
@enum {string}
*/
/** Direction */

@@ -56,3 +46,3 @@ function forceDirection(direction) {

function escapeRegExp(str) {
return str.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
return str.replace(/([.*+?^=!:${}()|[\]/\\])/g, '\\$1');
}

@@ -63,5 +53,5 @@

if (a === b) return true;
var arrA = Array.isArray(a),
arrB = Array.isArray(b),
i;
const arrA = Array.isArray(a),
arrB = Array.isArray(b);
let i;
if (arrA && arrB) {

@@ -74,11 +64,11 @@ if (a.length != b.length) return false;

if (a && b && typeof a === 'object' && typeof b === 'object') {
var dateA = a instanceof Date,
const dateA = a instanceof Date,
dateB = b instanceof Date;
if (dateA && dateB) return a.getTime() == b.getTime();
if (dateA != dateB) return false;
var regexpA = a instanceof RegExp,
const regexpA = a instanceof RegExp,
regexpB = b instanceof RegExp;
if (regexpA && regexpB) return a.toString() == b.toString();
if (regexpA != regexpB) return false;
var keys = Object.keys(a);
const keys = Object.keys(a);
// if (keys.length !== Object.keys(b).length) return false;

@@ -85,0 +75,0 @@

@@ -20,3 +20,3 @@ import IMask from './imask';

export { default as ChunksTailDetails, type ChunksTailState } from './masked/pattern/chunk-tail-details';
export { default as PatternFixedDefinition, type PatternFixedDefinitionOptions, type PatternFixedDefinitionState } from './masked/pattern/fixed-definition';
export { default as PatternFixedDefinition, type PatternFixedDefinitionOptions } from './masked/pattern/fixed-definition';
export { default as PatternInputDefinition, type PatternInputDefinitionOptions, type PatternInputDefinitionState } from './masked/pattern/input-definition';

@@ -23,0 +23,0 @@ export { createPipe, pipe, PIPE_TYPE } from './masked/pipe';

@@ -29,4 +29,4 @@ export { default as InputMask } from './controls/input.js';

globalThis.IMask = IMask;
} catch (e) {}
} catch {}
export { IMask as default };

@@ -6,2 +6,3 @@ import ChangeDetails from '../core/change-details';

_value: string;
_rawInputValue: string;
};

@@ -24,3 +25,3 @@ /** Append flags */

static EMPTY_VALUES: Array<any>;
/** @type {Mask} */
/** */
mask: unknown;

@@ -27,0 +28,0 @@ /** */

@@ -14,3 +14,3 @@ import ChangeDetails from '../core/change-details.js';

class Masked {
/** @type {Mask} */
/** */

@@ -62,3 +62,4 @@ /** */

return {
_value: this.value
_value: this.value,
_rawInputValue: this.rawInputValue
};

@@ -65,0 +66,0 @@ }

@@ -52,3 +52,3 @@ import MaskedPattern from './pattern.js';

};
let patternBlocks = Object.assign({}, MaskedDate.GET_DEFAULT_BLOCKS());
const patternBlocks = Object.assign({}, MaskedDate.GET_DEFAULT_BLOCKS());
// adjust year block

@@ -55,0 +55,0 @@ if (opts.min) patternBlocks.Y.from = opts.min.getFullYear();

@@ -7,3 +7,2 @@ import ChangeDetails from '../core/change-details';

export type MaskedDynamicState = MaskedState & {
_rawInputValue: string;
compiledMasks: Array<MaskedState>;

@@ -15,2 +14,3 @@ currentMaskRef?: Masked;

export type MaskedDynamicOptions = MaskedOptions<MaskedDynamic, 'dispatch'>;
type HandleState = MaskedDynamicState | MaskedState;
/** Dynamic mask for choosing appropriate mask in run-time */

@@ -25,3 +25,3 @@ export default class MaskedDynamic<Value = any> extends Masked<Value> {

/** Chooses {@link Masked} depending on input value */
dispatch: (appended: string, masked: MaskedDynamic, flags: AppendFlags<MaskedDynamicState>, tail: string | String | TailDetails) => (Masked | undefined);
dispatch: (appended: string, masked: MaskedDynamic, flags: AppendFlags<HandleState>, tail: string | String | TailDetails) => (Masked | undefined);
_overwrite?: this['overwrite'];

@@ -33,12 +33,12 @@ _eager?: this['eager'];

_update(opts: Partial<MaskedDynamicOptions>): void;
_appendCharRaw(ch: string, flags?: AppendFlags<MaskedDynamicState>): ChangeDetails;
_applyDispatch(appended?: string, flags?: AppendFlags<MaskedDynamicState>, tail?: string | String | TailDetails): ChangeDetails;
_appendCharRaw(ch: string, flags?: AppendFlags<HandleState>): ChangeDetails;
_applyDispatch(appended?: string, flags?: AppendFlags<HandleState>, tail?: string | String | TailDetails): ChangeDetails;
_appendPlaceholder(): ChangeDetails;
_appendEager(): ChangeDetails;
appendTail(tail: string | String | TailDetails): ChangeDetails;
currentMaskFlags(flags: AppendFlags<MaskedDynamicState>): AppendFlags;
doDispatch(appended: string, flags?: AppendFlags<MaskedDynamicState>, tail?: string | String | TailDetails): Masked | undefined;
doValidate(flags: AppendFlags<MaskedDynamicState>): boolean;
doPrepare(str: string, flags?: AppendFlags<MaskedDynamicState>): [string, ChangeDetails];
doPrepareChar(str: string, flags?: AppendFlags<MaskedDynamicState>): [string, ChangeDetails];
currentMaskFlags(flags: AppendFlags<HandleState>): AppendFlags;
doDispatch(appended: string, flags?: AppendFlags<HandleState>, tail?: string | String | TailDetails): Masked | undefined;
doValidate(flags: AppendFlags<HandleState>): boolean;
doPrepare(str: string, flags?: AppendFlags<HandleState>): [string, ChangeDetails];
doPrepareChar(str: string, flags?: AppendFlags<HandleState>): [string, ChangeDetails];
reset(): void;

@@ -56,3 +56,3 @@ get value(): string;

get state(): MaskedDynamicState;
set state(state: MaskedDynamicState);
set state(state: HandleState);
extractInput(fromPos?: number, toPos?: number, flags?: ExtractFlags): string;

@@ -71,2 +71,3 @@ extractTail(fromPos?: number, toPos?: number): TailDetails;

}
export {};
//# sourceMappingURL=dynamic.d.ts.map

@@ -228,3 +228,3 @@ import { DIRECTION, objectIncludes } from '../core/utils.js';

} = state;
this.compiledMasks.forEach((m, mi) => m.state = compiledMasks[mi]);
if (compiledMasks) this.compiledMasks.forEach((m, mi) => m.state = compiledMasks[mi]);
if (currentMaskRef != null) {

@@ -231,0 +231,0 @@ this.currentMask = currentMaskRef;

@@ -24,3 +24,3 @@ import MaskedPattern from './pattern.js';

} = opts;
this.enum = this.enum;
this.enum = _enum;
if (_enum) eopts.mask = '*'.repeat(_enum[0].length);

@@ -27,0 +27,0 @@ super._update(eopts);

@@ -41,5 +41,5 @@ import { escapeRegExp, DIRECTION } from '../core/utils.js';

_updateRegExps() {
let start = '^' + (this.allowNegative ? '[+|\\-]?' : '');
let mid = '\\d*';
let end = (this.scale ? "(" + escapeRegExp(this.radix) + "\\d{0," + this.scale + "})?" : '') + '$';
const start = '^' + (this.allowNegative ? '[+|\\-]?' : '');
const mid = '\\d*';
const end = (this.scale ? "(" + escapeRegExp(this.radix) + "\\d{0," + this.scale + "})?" : '') + '$';
this._numberRegExp = new RegExp(start + mid + end);

@@ -46,0 +46,0 @@ this._mapToRadixRegExp = new RegExp("[" + this.mapToRadix.map(escapeRegExp).join('') + "]", 'g');

@@ -16,3 +16,3 @@ import ChangeDetails from '../core/change-details';

export type MaskedPatternState = MaskedState & {
_blocks: Array<any>;
_blocks: Array<MaskedState>;
};

@@ -19,0 +19,0 @@ export type BlockPosData = {

@@ -47,3 +47,3 @@ import ChangeDetails from '../core/change-details.js';

this._maskedBlocks = {};
let pattern = this.mask;
const pattern = this.mask;
if (!pattern || !defs) return;

@@ -369,10 +369,2 @@ let unmaskingBlock = false;

if (cursor.ok) return cursor.pos;
// cursor.popState();
// if (
// cursor.pushRightBeforeInput() &&
// // TODO HACK for lazy if has aligned left inside fixed and has came to the start - use start position
// (!this.lazy || this.extractInput())
// ) return cursor.pos;
return 0;

@@ -379,0 +371,0 @@ }

import type ChangeDetails from '../../core/change-details';
import { type TailDetails } from '../../core/tail-details';
import { type ExtractFlags, type AppendFlags } from '../base';
import { type ExtractFlags, type AppendFlags, type MaskedState } from '../base';
import { type Direction } from '../../core/utils';

@@ -9,3 +9,3 @@ /**

*/
export default interface PatternBlock {
export default interface PatternBlock<State = MaskedState> {
readonly value: string;

@@ -25,5 +25,5 @@ readonly unmaskedValue: string;

extractTail(fromPos?: number, toPos?: number): TailDetails;
append(str: string, flags?: AppendFlags, tail?: TailDetails): ChangeDetails;
append(str: string, flags?: AppendFlags<State>, tail?: TailDetails): ChangeDetails;
appendTail(tail: string | TailDetails): ChangeDetails;
_appendChar(str: string, flags: AppendFlags): ChangeDetails;
_appendChar(str: string, flags: AppendFlags<State>): ChangeDetails;
_appendPlaceholder(toBlockIndex?: number): ChangeDetails;

@@ -30,0 +30,0 @@ _appendEager(): ChangeDetails;

@@ -7,3 +7,2 @@ import ChangeDetails from '../../core/change-details';

export type PatternFixedDefinitionOptions = Pick<PatternFixedDefinition, 'char' | 'isUnmasking' | 'eager'>;
export type PatternFixedDefinitionState = MaskedState & Pick<PatternFixedDefinition, '_isRawInput'>;
export default class PatternFixedDefinition implements PatternBlock {

@@ -25,2 +24,3 @@ /** */

get unmaskedValue(): string;
get rawInputValue(): string;
get displayValue(): string;

@@ -37,9 +37,9 @@ reset(): void;

_appendPlaceholder(): ChangeDetails;
extractTail(fromPos?: number, toPos?: number): TailDetails;
extractTail(): TailDetails;
appendTail(tail: string | String | TailDetails): ChangeDetails;
append(str: string, flags?: AppendFlags, tail?: TailDetails): ChangeDetails;
doCommit(): void;
get state(): PatternFixedDefinitionState;
set state(state: PatternFixedDefinitionState);
get state(): MaskedState;
set state(state: MaskedState);
}
//# sourceMappingURL=fixed-definition.d.ts.map

@@ -30,2 +30,5 @@ import ChangeDetails from '../../core/change-details.js';

}
get rawInputValue() {
return this._isRawInput ? this.value : '';
}
get displayValue() {

@@ -118,6 +121,3 @@ return this.value;

}
extractTail(fromPos, toPos) {
if (toPos === void 0) {
toPos = this.value.length;
}
extractTail() {
return new ContinuousTailDetails('');

@@ -140,7 +140,8 @@ }

_value: this._value,
_isRawInput: this._isRawInput
_rawInputValue: this.rawInputValue
};
}
set state(state) {
Object.assign(this, state);
this._value = state._value;
this._isRawInput = Boolean(state._rawInputValue);
}

@@ -147,0 +148,0 @@ }

@@ -1,6 +0,6 @@

import { type FactoryOpts } from '../factory';
import { type FactoryOpts, type FactoryReturnMasked } from '../factory';
import type Masked from '../base';
import type MaskedPattern from '../pattern';
import { type TailDetails } from '../../core/tail-details';
import { type ExtractFlags, type AppendFlags } from '../base';
import { type ExtractFlags, type AppendFlags, type MaskedState } from '../base';
import ChangeDetails from '../../core/change-details';

@@ -10,7 +10,7 @@ import { type Direction } from '../../core/utils';

export type PatternInputDefinitionOptions<Opts extends FactoryOpts> = Omit<Opts, 'parent' | 'isOptional' | 'lazy' | 'eager' | 'placeholderChar' | 'displayChar'> & Partial<Pick<PatternInputDefinition, 'parent' | 'isOptional' | 'lazy' | 'eager' | 'placeholderChar' | 'displayChar'>>;
export type PatternInputDefinitionState = {
masked: Masked['state'];
export type PatternInputDefinitionState<Opts> = MaskedState & {
masked: FactoryReturnMasked<Opts>['state'];
isFilled: boolean;
};
export default class PatternInputDefinition<Opts extends FactoryOpts = any> implements PatternBlock {
export default class PatternInputDefinition<Opts extends FactoryOpts = any> implements PatternBlock<PatternInputDefinitionState<Opts>> {
static DEFAULT_DEFINITIONS: {

@@ -20,3 +20,3 @@ [k: string]: RegExp;

/** */
readonly masked: Masked;
readonly masked: FactoryReturnMasked<Opts>;
/** */

@@ -41,6 +41,7 @@ parent: Masked;

get unmaskedValue(): string;
get rawInputValue(): string;
get displayValue(): string;
get isComplete(): boolean;
_appendChar(ch: string, flags?: AppendFlags): ChangeDetails;
append(str: string, flags?: AppendFlags, tail?: TailDetails): ChangeDetails;
_appendChar(ch: string, flags?: AppendFlags<PatternInputDefinitionState<Opts>>): ChangeDetails;
append(str: string, flags?: AppendFlags<PatternInputDefinitionState<Opts>>, tail?: TailDetails): ChangeDetails;
_appendPlaceholder(): ChangeDetails;

@@ -53,7 +54,8 @@ _appendEager(): ChangeDetails;

totalInputPositions(fromPos?: number, toPos?: number): number;
doValidate(flags: AppendFlags): boolean;
doValidate(flags: AppendFlags<PatternInputDefinitionState<Opts>>): boolean;
doCommit(): void;
get state(): PatternInputDefinitionState;
set state(state: PatternInputDefinitionState);
get state(): PatternInputDefinitionState<Opts>;
set state(state: PatternInputDefinitionState<Opts>);
currentMaskFlags(flags: AppendFlags<PatternInputDefinitionState<Opts>>): AppendFlags;
}
//# sourceMappingURL=input-definition.d.ts.map

@@ -66,2 +66,5 @@ import createMask from '../factory.js';

}
get rawInputValue() {
return this.masked.rawInputValue;
}
get displayValue() {

@@ -80,3 +83,3 @@ return this.masked.value && this.displayChar || this.value;

// simulate input
const details = this.masked._appendChar(ch, flags);
const details = this.masked._appendChar(ch, this.currentMaskFlags(flags));
if (details.inserted && this.doValidate(flags) === false) {

@@ -95,3 +98,3 @@ details.inserted = details.rawInserted = '';

// TODO probably should be done via _appendChar
return this.masked.append(str, flags, tail);
return this.masked.append(str, this.currentMaskFlags(flags), tail);
}

@@ -152,3 +155,3 @@ _appendPlaceholder() {

doValidate(flags) {
return this.masked.doValidate(flags) && (!this.parent || this.parent.doValidate(flags));
return this.masked.doValidate(this.currentMaskFlags(flags)) && (!this.parent || this.parent.doValidate(this.currentMaskFlags(flags)));
}

@@ -160,2 +163,4 @@ doCommit() {

return {
_value: this.value,
_rawInputValue: this.rawInputValue,
masked: this.masked.state,

@@ -169,2 +174,9 @@ isFilled: this.isFilled

}
currentMaskFlags(flags) {
var _flags$_beforeTailSta;
return {
...flags,
_beforeTailState: ((_flags$_beforeTailSta = flags._beforeTailState) == null ? void 0 : _flags$_beforeTailSta.masked) || flags._beforeTailState
};
}
}

@@ -171,0 +183,0 @@ PatternInputDefinition.DEFAULT_DEFINITIONS = {

@@ -80,3 +80,3 @@ import IMask from '../core/holder.js';

const toStr = String(this.to).padStart(this.maxLength, '0');
let nextVal = this.value + ch;
const nextVal = this.value + ch;
if (nextVal.length > this.maxLength) return ['', details];

@@ -83,0 +83,0 @@ const [minstr, maxstr] = this.boundaries(nextVal);

{
"name": "imask",
"version": "7.0.0-alpha.4",
"version": "7.0.0-alpha.5",
"author": "Alexey Kryazhev",

@@ -19,5 +19,5 @@ "license": "MIT",

"watch": "rollup -c -w",
"prebuild": "rimraf --glob \"{dist,esm}\"",
"lint": "eslint --quiet",
"prebuild": "npm run lint && rimraf --glob \"{dist,esm}\"",
"build": "tsc --emitDeclarationOnly && rollup -c",
"lint": "eslint src/",
"coveralls": "c8 report --reporter=text-lcov | coveralls"

@@ -31,3 +31,3 @@ },

],
"gitHead": "d29a59cbca5afc68339dd7cdde3c22f12c95e168",
"gitHead": "34bcafe7df2d9169efac422da8bfd8e7ccb22f85",
"dependencies": {

@@ -34,0 +34,0 @@ "@babel/runtime-corejs3": "^7.22.5"

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc