@cat-of-summer/st-script 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mask.min.js CHANGED
@@ -1,2 +1,2 @@
1
- var Mask=(()=>{var W=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var se=Object.prototype.hasOwnProperty;var ae=(r,e)=>{for(var t in e)W(r,t,{get:e[t],enumerable:!0})},fe=(r,e,t,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ne(e))!se.call(r,i)&&i!==t&&W(r,i,{get:()=>e[i],enumerable:!(l=ie(e,i))||l.enumerable});return r};var oe=r=>fe(W({},"__esModule",{value:!0}),r);var ge={};ae(ge,{default:()=>R});var J=Symbol(),ue=Symbol(),T=r=>{try{return r instanceof Element?r:document.querySelector(r)}catch{return}},O=r=>{if(r==null)return[];if(r instanceof Element)return[r];if(r instanceof NodeList||r instanceof HTMLCollection)return[...r];if(Array.isArray(r))return r.flatMap(O);try{return[...document.querySelectorAll(r)]}catch{return[]}},q=r=>T(r)?.[J],K=(r,e)=>(r&&(r[J]=e),r),U=(r,e)=>{if(!r)return r;let t=r[ue]??=new Set;for(let[l,i]of Object.entries(e)){if(l in r&&!t.has(l)){console.warn(`\u0418\u043C\u044F "${l}" \u0443\u0436\u0435 \u0437\u0430\u043D\u044F\u0442\u043E \u043D\u0430 \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0435 \u2014 \u043C\u0435\u0442\u043E\u0434 \u043D\u0435 \u043E\u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u0430\u043D`,r);continue}Object.defineProperty(r,l,{value:i,writable:!0,configurable:!0,enumerable:!1}),t.add(l)}return r};var Q={0:/^[0-9]$/,a:/^\p{L}$/u,"*":/^[^\n]$/},X=/^[\p{L}\p{N}]$/u,Y=r=>r.replace(/\\(.)/g,"$1"),Z=r=>r.global?new RegExp(r.source,r.flags.replace("g","")):r;function D(r,e){let t=r[e],l=t=="{"?"}":"]",i=0;for(let n=e;n<r.length;n++){let s=r[n];if(s=="\\"){n++;continue}if(t=="["&&s=="{"){if((n=D(r,n))<0)return-1}else if(s==t)i++;else if(s==l&&--i==0)return n}return-1}function ee(r,e){let t=0,l=-1;for(let i=0;i<r.length;i++){if(r[i]=="\\"){i++;continue}r[i]=="{"||r[i]=="["?t++:r[i]=="}"||r[i]=="]"?t--:t==0&&r.startsWith(e,i)&&(l=i)}return l}function ce(r){let e=()=>(console.warn("\u041D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 \u0431\u043B\u043E\u043A \u043C\u0430\u0441\u043A\u0438",`{${r}}`),[...`{${r}}`].map(i=>({type:"literal",char:i}))),t=ee(r,";");if(t>0){let i=r.slice(t+1);if(/^(\d+|\d*-\d*)$/.test(i)&&i!="-"){let[n,s]=/^\d+$/.test(i)?[+i,+i]:i.split("-").map((h,a)=>h===""?a?1/0:0:+h);return s<n?e():[{type:"repeat",children:V(r.slice(0,t)),min:n,max:s}]}}if(r[0]=="{"&&r.at(-1)=="}")try{return[{type:"slot",test:new RegExp(`^(?:${r.slice(1,-1)})$`,"u")}]}catch{return e()}let l=ee(r,"=>");if(l>0){let i=Y(r.slice(0,l)),n=Y(r.slice(l+2));return i.length!=1||!n?e():[{type:"transform",from:i,to:n}]}return e()}function V(r){let e=[];for(let t=0;t<r.length;t++){let l=r[t],i;l=="\\"?e.push({type:"literal",char:r[++t]??"\\"}):l=="["&&(i=D(r,t))>=0?(e.push({type:"optional",children:V(r.slice(t+1,i))}),t=i):l=="{"&&(i=D(r,t))>=0?(e.push(...ce(r.slice(t+1,i))),t=i):e.push(Q[l]?{type:"slot",test:Q[l]}:{type:"literal",char:l})}return e}function te(r){return r.every(e=>e.type=="literal"||e.type=="slot"||e.type=="repeat"&&e.min==e.max&&te(e.children))}function E(r,e={}){if(r&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof RegExp)&&r.pattern==null&&r.filter==null&&r.numeral==null)return Object.entries(r).flatMap(([l,i])=>E(i,e).map(n=>({...n,key:l})));let t=(Array.isArray(r)?r:[r]).map(l=>{if(typeof l=="function")return{fn:l,base:e};if(l instanceof RegExp&&(l={filter:l}),typeof l=="string"&&(l={pattern:l}),l.numeral){let n={fraction:0,group:" ",decimal:",",prefix:"",suffix:"",sign:!1,...l.numeral};return{numeral:n,fixed:!1,valid:null,message:l.message??n.message,filler:l.filler??e.filler,before_char:null,before_slot:null}}let i=l.pattern!=null?V(l.pattern):[{type:"repeat",min:0,max:l.max_length??1/0,greedy:!0,children:[{type:"slot",test:Z(l.filter)}]}];return{nodes:i,fixed:l.pattern!=null&&te(i),valid:l.valid?Z(l.valid):l.filter?/./:null,message:l.message,filler:l.filler??e.filler,before_char:l.before_char??e.before_char,before_slot:l.before_slot??e.before_slot}});return t.forEach((l,i)=>l.key??=i),t}function j(r,e){let t=r.filler??"_";return t[e]??t.at(-1)??"_"}function z(r,e,t){let l=[...String(e??"")];return r.before_char?l.flatMap(i=>{let n=r.before_char(t?.input,{char:i});return n===!1||n===""||n===null?[]:typeof n=="string"?[...n]:[i]}):l}function he(r,e,t){return r.type=="slot"?r.test.test(e):r.type=="transform"?r.from===e||t.input.slice(t.ip,t.ip+r.to.length).join("")===r.to:r.type=="repeat"?M(r.children,e,t):!1}function M(r,e,t,l){for(let i of r){if(i.type=="literal"){if(!l&&i.char===e)return!0;continue}if(i.type=="optional"||i.type=="repeat"&&i.min==0){if(M(i.children,e,t,l))return!0;continue}return he(i,e,t)}return l?r.some(i=>i.type=="literal"&&i.char===e):!1}function F(r,e,t,l="char",i=null){r.units.push({kind:l,ordinal:i,stream_start:r.stream.length,stream_end:r.stream.length+e.length,fmt_start:r.formatted.length,fmt_end:r.formatted.length+t.length}),r.stream+=e,l=="char"&&(r.raw+=e),i!=null&&(r.cells[i]=l=="char"?e:null),r.formatted+=t}function G(r){r.stop_fmt<0&&(r.stop_fmt=r.formatted.length+r.tail.length)}function B(r){r.complete=!1,r.done=!0,G(r)}function $(r,e,t){for(let l=0;l<r.length;l++){let i=r[l];if(i.type=="literal")e.done?e.ph+=i.char:e.ip<e.input.length?e.input[e.ip]===i.char?(e.ip++,e.consumed++,!e.diverged&&X.test(i.char)&&e.lead++,F(e,i.char,i.char,"literal")):(X.test(i.char)&&(!e.diverged&&e.raw===""&&(e.lead=0),e.diverged=!0),e.formatted+=i.char):e.tail+=i.char;else if(i.type=="slot"){let n=e.ordinal++,s=j(t,n);if(e.done){e.ph_slots.push({fmt:e.formatted.length+e.tail.length+e.ph.length,node:i}),e.ph+=s;continue}let h=!1;for(;;){if(e.ip>=e.input.length){B(e),e.ph_slots.push({fmt:e.formatted.length+e.tail.length,node:i}),e.ph+=s;break}let a=e.input[e.ip];if(i.test.test(a)){if(t.before_slot&&!h){let f=t.before_slot(e.ctx?.input,{char:a,slot:n,cells:e.cells,raw:e.raw,node:i});if(f===!1){e.ip++;continue}if(typeof f=="string"&&f!==a){e.input.splice(e.ip,1,...f),h=!0;continue}}F(e,a,a,"char",n)}else if(a===s)e.complete=!1,F(e,a,a,"hole",n);else{e.ip++;continue}e.ip++,e.consumed++;break}}else if(i.type=="transform"){if(e.done){e.ph+=i.to;continue}for(;;){if(e.ip>=e.input.length){B(e),e.ph+=i.to;break}if(e.input.slice(e.ip,e.ip+i.to.length).join("")===i.to)e.ip+=i.to.length,e.consumed+=i.to.length;else if(e.input[e.ip]===i.from)e.ip++,e.consumed++;else{e.ip++;continue}e.diverged||e.lead++,F(e,i.to,i.to);break}}else if(i.type=="repeat"){if(e.done){for(let s=0;s<i.min;s++)$(i.children,e,t);continue}let n=0;for(;n<i.max;){if(e.ip>=e.input.length){if(n<i.min){B(e);for(let h=n;h<i.min;h++)$(i.children,e,t)}else G(e);break}if(!M(i.children,e.input[e.ip],e)){if(!i.greedy&&n>=i.min)break;e.ip++;continue}let s=e.ip;if($(i.children,e,t),e.done){for(let h=n+1;h<i.min;h++)$(i.children,e,t);break}if(e.ip===s)break;n++}}else if(i.type=="optional"){if(e.done)continue;let n=r.slice(l+1),s=!1;for(;e.ip<e.input.length;){let h=e.input[e.ip];if(M(i.children,h,e,!0)){s=!0,$(i.children,e,t);break}if(M(n,h,e))break;e.ip++}!s&&e.ip>=e.input.length&&G(e)}}}function de(r,e){let t=r.numeral,l=String(e??""),i=t.sign&&l.includes("-"),n;if(t.decimal&&(l.includes(t.decimal)||l.includes("."))){let p=L=>L.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),A=l.replace(new RegExp(`[^0-9${p(t.decimal)}.]`,"g"),"").replace(t.decimal,"."),v=parseFloat(A);n=Number.isFinite(v)?String(Math.round(v*10**t.fraction)):""}else{let p=l.replace(/\D/g,"");n=p===""?"":p.replace(/^0+/,"")||"0"}if(!n){let p=t.prefix+j(r,0);if(t.fraction){p+=t.decimal;for(let A=1;A<=t.fraction;A++)p+=j(r,A)}return{stream:"",raw:"",formatted:"",tail:"",ph:p+t.suffix,ph_slots:[],complete:!1,consumed:0,lead:0,units:[],cells:[],stop_fmt:p.length}}let s=t.fraction,h=n.padStart(s+1,"0"),a=(s?h.slice(0,-s):h).replace(/^0+(?=\d)/,""),f=s?h.slice(-s):"",c=a.length+f.length-n.length,o=(i?"-":"")+n,d="",_=[],y=0,w=0,b=p=>{d+=p},u=p=>{_.push({kind:"char",ordinal:null,stream_start:y,stream_end:y+1,fmt_start:d.length,fmt_end:d.length+1}),d+=p,y++};b(t.prefix),i&&u("-");for(let p=0;p<a.length;p++,w++)p&&(a.length-p)%3==0&&b(t.group),w>=c?u(a[p]):b(a[p]);if(s){b(t.decimal);for(let p=0;p<f.length;p++,w++)w>=c?u(f[p]):b(f[p])}let k=d.length;b(t.suffix);let x=(i?-1:1)*parseFloat(a+(s?"."+f:"")),S=(t.min==null||x>=t.min)&&(t.max==null||x<=t.max);return{stream:o,raw:o,formatted:d,tail:"",ph:"",ph_slots:[],complete:S,consumed:o.length,lead:0,units:_,cells:[],stop_fmt:k}}function I(r,e,t){if(r.numeral)return de(r,e);let l={input:z(r,e,t),ctx:t,ip:0,stream:"",raw:"",formatted:"",tail:"",ph:"",ph_slots:[],units:[],cells:[],consumed:0,lead:0,diverged:!1,ordinal:0,complete:!0,done:!1,stop_fmt:-1};return $(r.nodes,l,r),l.stop_fmt<0&&(l.stop_fmt=l.formatted.length),r.valid&&(l.complete=l.complete&&r.valid.test(l.raw)),{stream:l.stream,raw:l.raw,formatted:l.formatted,tail:l.tail,ph:l.ph,ph_slots:l.ph_slots,complete:l.complete,consumed:l.consumed,lead:l.lead,units:l.units,cells:l.cells,stop_fmt:l.stop_fmt}}function H(r,e,t={}){let l=[];t={...t,stream:String(e??"")};for(let n of r)n.fn?l.push(...E(n.fn(t),n.base).map(s=>({...s,key:n.key??s.key}))):l.push(n);let i=null;for(let n of l){let s=I(n,e,t);(!i||me(s,i.result))&&(i={result:s,def:n,mask_id:n.key})}return i}function me(r,e){return r.consumed!=e.consumed?r.consumed>e.consumed:r.lead>e.lead}function C(r,e){return e=="always"?r.formatted+r.tail+r.ph:e===!1?r.formatted:r.formatted+r.tail}function le(r,e){for(let t of r.units)if(t.kind!="literal"&&(e<=t.stream_start||e<t.stream_end))return t.fmt_start;return r.stop_fmt}function re(r,e){let t=r.units.filter(l=>l.kind=="char");return t.length>e?t[e-1].stream_end:r.stream.length}var pe=["before_init","on_init","before_char","before_slot","before_input","on_input","before_paste","on_paste","on_accept","on_complete","on_incomplete","on_mask_change"],R=class r{static#m=["target","mask"];static#p=["text","search","tel","url","password"];static#u(e){let t=I(e,""),l=0;return t.slots=t.ph_slots,t.parts=t.slots.map((i,n)=>n&&i.fmt>t.slots[n-1].fmt+1?++l:l),t.template=C(t,"always"),t}static#g(e){if(!/^\s*[[{]/.test(e))return e;let t=l=>typeof l=="string"||Array.isArray(l)&&l.every(i=>typeof i=="string");try{let l=JSON.parse(e);if(Array.isArray(l)?t(l):l&&typeof l=="object"&&Object.values(l).every(t))return l}catch{}return e}#e={};#c={};#n=null;#t=new WeakMap;#r=[];static find=q;get params(){return this.#e}get value(){return this.#r.map(e=>e.value)}clone(e){return new r({...this.#e,...this.#c,...e,parent:this})}constructor(e){e={target:"input[mask]",mask:null,numeral:null,filler:"_",placeholder:!0,flow:!0,rewrite:!1,caret:!0,coerce_type:!0,max_raw:null,validate:null,validation_message:null,...Object.fromEntries(pe.map(t=>[t,()=>{}])),...e};for(let[t,l]of Object.entries(e))typeof l=="function"&&!r.#m.includes(t)?(this[t]=l.bind(this),this.#c[t]=l):this.#e[t]=l;this.before_init(this.#e),this.#e.numeral!=null?this.#n=E({numeral:this.#e.numeral},this.#i()):this.#e.mask!=null&&(this.#n=E(this.#e.mask,this.#i()));for(let t of O(this.#e.target))this.#y(t);this.on_init(this.#e)}raw(e=this.#a()){return this.#t.get(T(e))?.result?.raw??""}state(e=this.#a()){let t=T(e),l=this.#t.get(t);return l?.result?this.#s(t,l):null}set(e,t){arguments.length<2&&([e,t]=[this.#a(),e]);for(let l of O(e))this.#t.has(l)&&this.#l(l,String(t??""),{prefix:String(t??"")})}clear(e=this.#r){this.set(e,"")}#a(){if(this.#r.length!=1)throw new Error(`Mask: \u043C\u0430\u0441\u043A\u0430 \u043F\u0440\u0438\u0432\u044F\u0437\u0430\u043D\u0430 \u043A ${this.#r.length} \u043F\u043E\u043B\u044F\u043C \u2014 \u0443\u043A\u0430\u0436\u0438\u0442\u0435 \u043F\u043E\u043B\u0435 \u044F\u0432\u043D\u043E`);return this.#r[0]}set_mask(e,t=null){let l=E(e,this.#i());t||(this.#n=l);for(let i of t?O(t):this.#r){let n=this.#t.get(i);n&&(n.defs=l,n.run=null,this.#l(i,n.stream,{}))}}#i(){return{filler:this.#e.filler,before_char:this.before_char,before_slot:this.before_slot}}#_(e){return e=="email"?E({filter:/[a-z0-9@._%+-]/i,valid:/^[^@\s]+@[^@\s]+\.[^@\s]{2,}$/},this.#i()):e=="number"?E({numeral:{}},this.#i()):null}#y(e){if(q(e))throw new Error("\u041C\u0430\u0441\u043A\u0430 \u0443\u0436\u0435 \u043F\u0440\u0438\u0432\u044F\u0437\u0430\u043D\u0430 \u043A \u044D\u0442\u043E\u043C\u0443 \u043F\u043E\u043B\u044E");K(e,this);let t=null;this.#e.coerce_type!==!1&&(e.type=="number"||e.type=="email")&&(t=e.type,e.inputMode=t=="number"?"numeric":"email",e.type="text"),r.#p.includes(e.type)||console.warn(`Mask: \u043F\u043E\u043B\u0435 type="${e.type}" \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0443\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u043A\u0430\u0440\u0435\u0442\u043A\u043E\u0439 \u2014 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 type="text" \u0438\u043B\u0438 "tel"`,e);let l=e.getAttribute("maxlength");l!=null&&e.removeAttribute("maxlength");let i=this.#e.max_raw??(l!=null?+l:null),n=e.getAttribute("mask"),s=this.#n??(n?E(r.#g(n),this.#i()):this.#_(t));if(!s){console.warn("Mask: \u0434\u043B\u044F \u043F\u043E\u043B\u044F \u043D\u0435 \u0437\u0430\u0434\u0430\u043D\u0430 \u043C\u0430\u0441\u043A\u0430 (\u043D\u0438 \u0432 params.mask, \u043D\u0438 \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0435 mask)",e);return}let h=t=="number"||this.#e.numeral!=null,a={defs:s,def:null,stream:"",result:null,mask_id:null,rendered:"",run:null,composing:!1,handled:!1,coerced:t,max_raw:i,numeric:h};this.#t.set(e,a),this.#r.push(e),U(e,{raw:()=>this.raw(e),state:()=>this.state(e),set:o=>this.set(e,o),clear:()=>this.clear(e),set_mask:o=>this.set_mask(o,e)});let f=()=>this.#e.caret=="hide"&&e.style.setProperty("caret-color","transparent","important");if(f(),e.addEventListener("beforeinput",o=>this.#w(e,o)),this.#e.caret!==!0){let o=()=>this.#b(e);for(let d of["selectionchange","click","keyup","select"])e.addEventListener(d,o)}let c=()=>{if(a.handled){a.handled=!1;return}a.composing||this.#o(e)};e.addEventListener("input",c),e.addEventListener("change",c),e.addEventListener("compositionstart",()=>a.composing=!0),e.addEventListener("compositionend",()=>{a.composing=!1,this.#o(e)}),e.addEventListener("focus",()=>{f(),this.#l(e,a.stream,{prefix:a.stream,silent:!0})}),e.addEventListener("blur",()=>{a.run=null,this.#l(e,a.stream,{silent:!0})}),e.closest("form")?.addEventListener("reset",()=>queueMicrotask(()=>this.#o(e))),this.#l(e,e.value,{silent:!0})}#w(e,t){let l=this.#t.get(e),i=t.inputType??"insertText";if(t.isComposing||i=="insertCompositionText"||i=="deleteCompositionText"){l.composing=!0;return}if(i=="historyUndo"||i=="historyRedo")return;let n=e.selectionStart??0,s=e.selectionEnd??n;this.#e.caret!==!0&&l.result&&!(n==0&&s==e.value.length)&&(n=s=this.#h(e,l,n)),t.preventDefault(),l.handled=!0;let h=i.startsWith("delete"),a="";if(!h){if(i=="insertLineBreak"||i=="insertParagraph")return;if(a=t.data??t.dataTransfer?.getData("text/plain")??"",i=="insertFromPaste"){let c=this.before_paste(e,a);if(c===!1)return;typeof c=="string"&&(a=c)}if(l.numeric){let c=l.defs.some(o=>o.numeral?.sign);a=[...a].filter(o=>o>="0"&&o<="9"||c&&o=="-").join("")}}if(this.before_input(e,{type:i,insert:a,start:n,end:s})===!1)return;let f=e.value;this.#e.placeholder=="always"&&l.def?.fixed?this.#v(e,i,n,s,h?"":a):this.#x(e,n,s,h?"":a,i),i=="insertFromPaste"&&this.on_paste(e,this.#s(e,l)),t.defaultPrevented&&e.value!==f&&e.dispatchEvent(new InputEvent("input",{bubbles:!0,inputType:i,data:a||null}))}#x(e,t,l,i,n){let s=this.#t.get(e),h=s.result?.units??[],a,f,c;if(t!=l){let d=h.filter(_=>_.fmt_start<l&&_.fmt_end>t);a=d.length?d[0].stream_start:this.#d(h,t),f=d.length?d.at(-1).stream_end:a}else if(!n.startsWith("delete"))a=f=this.#d(h,t);else{if(n.includes("Forward"))c=h.find(d=>d.fmt_end>t&&d.kind!="literal")??h.find(d=>d.fmt_end>t);else{let d;for(let _ of h)_.fmt_start<t&&(_.kind=="literal"?d=_:c=_);c??=d}if(!c)return;a=c.stream_start,f=c.stream_end}let o=s.stream.slice(0,a)+i;this.#l(e,o+s.stream.slice(f),{prefix:o})}#v(e,t,l,i,n){let s=this.#t.get(e),h=s.def,a=h.layout??=r.#u(h),f=a.slots,c=a.parts,o=f.length,d=this.#e.flow,_=this.#e.rewrite,y=Array.from({length:o},(m,g)=>s.result?.cells?.[g]??null),w=m=>{let g=f.findIndex(N=>N.fmt>=m);return g<0?o:g},b=m=>a.template.slice(f[m-1].fmt+1,f[m].fmt),u,k=null,x=null;if(l!=i){u=w(l);for(let m=u;m<o&&f[m].fmt<i;m++)y[m]=null;s.run=null}else if(!n&&t.startsWith("delete")){if(t.includes("Forward")){if((u=w(l))>=o)return;let m=c[u];for(;u<o&&y[u]==null;)u++;if(u>=o||!d&&c[u]!=m)return}else{let m=-1;for(let g=0;g<o;g++)f[g].fmt<l&&(m=g);if(m<0)return;for(u=m;u>=0&&y[u]==null;)u--;if(u<0||!d&&(c[u]!=c[m]||l>f[m].fmt+1))return}y[u]=null}else if(u=w(l),u>=o&&(u=y.indexOf(null))<0&&(u=o),k=this.#f(a,u,l),_){let m=k??c[Math.min(u,o-1)];(s.run?.part!==m||s.run.k!==u||c[u]!==m)&&(x=m)}k??=u<o?c[u]:null;let S=null;for(let m of z(h,n,{input:e})){if(u>=o){if(x==null)break;u=c.indexOf(x)}if(!d&&c[u]!=k){if(b(u).includes(m)){k=c[u],S=u,x=_?c[u]:null;continue}if(x==null)continue;u=c.indexOf(x)}if(!f[u].node.test.test(m)){let g=c.lastIndexOf(c[u]);g+1<o&&b(g+1).includes(m)&&(u=g+1,k=c[u],S=u,x=_?c[u]:null);continue}if(x!=null){for(let g=0;g<o;g++)c[g]==x&&(y[g]=null);u=c.indexOf(x),k=x,x=null}y[u++]=m}let p=y.reduce((m,g,N)=>g!=null?N:m,-1),A=y.slice(0,p+1).map((m,g)=>m??j(h,g)).join(""),v=Math.min(I(h,A.slice(0,u),{input:e}).stream.length,o),L=v<o?f[v].fmt:f[o-1].fmt+1;!d&&n&&v>0&&v<o&&c[v]!=c[v-1]&&(L=f[v-1].fmt+1),S!=null&&u==S&&(L=f[S].fmt);let P=w(L);s.run=S!=null?null:{part:this.#f(a,P,L)??c[Math.min(P,o-1)],k:P},this.#l(e,A,{caret_fmt:L})}#b(e){let t=this.#t.get(e);if(document.activeElement!==e||!t?.result)return;let l=e.selectionStart,i=e.selectionEnd;if(l==null)return;if(l!==i){(l!=0||i!=e.value.length)&&e.setSelectionRange(0,e.value.length);return}if(l===t.caret)return;let n=this.#h(e,t,l);l!==n&&e.setSelectionRange(n,n),t.caret=n}#h(e,t,l){let i=t.def;if(this.#e.placeholder=="always"&&i?.fixed&&!this.#e.flow){let n=i.layout??=r.#u(i),{slots:s,parts:h}=n,a=s.findIndex(d=>d.fmt>=l);a<0&&(a=s.length-1);let f=this.#f(n,a,l)??h[a],c=h.indexOf(f),o=h.lastIndexOf(f);for(let d=c;d<=o;d++)if(t.result.cells?.[d]==null)return s[d].fmt;return s[o].fmt+1}return Math.min(t.result.stop_fmt,e.value.length)}#f(e,t,l){let{slots:i,parts:n}=e;return!this.#e.flow&&t>0&&t<i.length&&n[t]!=n[t-1]&&l==i[t-1].fmt+1?n[t-1]:null}#d(e,t){let l=0;for(let i of e)(i.fmt_end<=t||i.fmt_start<t)&&(l=i.stream_end);return l}#o(e){let t=this.#t.get(e);if(e.value===t.rendered)return;t.run=null;let l=e.selectionStart??e.value.length;this.#l(e,e.value,{prefix:e.value.slice(0,l)})}#l(e,t,{prefix:l=null,caret_fmt:i=null,silent:n=!1}={}){let s=this.#t.get(e),h={raw:s.result?.raw??"",value:e.value,input:e},a=H(s.defs,t,h);if(!a)return;let{result:f,def:c,mask_id:o}=a;s.max_raw!=null&&f.raw.length>s.max_raw&&(a=H(s.defs,f.stream.slice(0,re(f,s.max_raw)),h),{result:f,def:c,mask_id:o}=a);let d=this.#k(e,f);e.value!==d&&(e.value=d),s.rendered=d,i==null&&l!=null&&document.activeElement===e&&(i=le(f,I(c,l,{input:e}).stream.length)),i!=null&&document.activeElement===e&&(i=Math.min(i,d.length),e.setSelectionRange(i,i),s.caret=i);let _=s.result,y=s.mask_id;if(s.result=f,s.stream=f.stream,s.def=c,s.mask_id=o,e.setAttribute("mask_id",o),e.setAttribute("progress",f.raw.length),e.setAttribute("is_complete",f.complete),this.#E(s)&&e.setCustomValidity&&e.setCustomValidity(!f.stream||f.complete?"":this.#S(e,s)),n)return;let w=this.#s(e,s);this.on_input(e,w),f.raw!==(_?.raw??"")&&this.on_accept(e,w),f.complete&&!_?.complete&&this.on_complete(e,w),!f.complete&&_?.complete&&this.on_incomplete(e,w),_&&o!==y&&this.on_mask_change(e,w)}#k(e,t){return t.stream?C(t,this.#e.placeholder):document.activeElement!==e?"":this.#e.placeholder=="always"?C(t,"always"):this.#e.placeholder==!1?"":C(t,!0)}#s(e,t){return{raw:t.result?.raw??"",formatted:e.value,complete:t.result?.complete??!1,mask_id:t.mask_id,progress:t.result?.raw.length??0}}#E(e){let t=this.#e.validate;return t===!0||t==null&&e.coerced!=null}#S(e,t){let l=typeof this.validation_message=="function"?this.validation_message:this.#e.validation_message??t.def?.message;return typeof l=="function"?l(e,this.#s(e,t))||"":typeof l=="string"?l:t.coerced=="email"?"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 \u0430\u0434\u0440\u0435\u0441 \u044D\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u043E\u0439 \u043F\u043E\u0447\u0442\u044B":t.coerced=="number"||t.def?.numeral?"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0447\u0438\u0441\u043B\u043E \u0432 \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E\u043C \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D\u0435":"\u0417\u0430\u043F\u043E\u043B\u043D\u0438\u0442\u0435 \u043F\u043E\u043B\u0435 \u043F\u043E\u043B\u043D\u043E\u0441\u0442\u044C\u044E"}};return oe(ge);})();
1
+ var Mask=(()=>{var N=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var fe=Object.getOwnPropertyNames;var ue=Object.prototype.hasOwnProperty;var he=(i,e)=>{for(var t in e)N(i,t,{get:e[t],enumerable:!0})},ce=(i,e,t,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of fe(e))!ue.call(i,r)&&r!==t&&N(i,r,{get:()=>e[r],enumerable:!(l=oe(e,r))||l.enumerable});return i};var de=i=>ce(N({},"__esModule",{value:!0}),i);var be={};he(be,{default:()=>I});var q=Symbol(),me=Symbol(),L=i=>{try{return i instanceof Element?i:document.querySelector(i)}catch{return}},E=i=>{if(i==null)return[];if(i instanceof Element)return[i];if(i instanceof NodeList||i instanceof HTMLCollection)return[...i];if(Array.isArray(i))return i.flatMap(E);try{return[...document.querySelectorAll(i)]}catch{return[]}},P=i=>L(i)?.[q],G=(i,e)=>(i&&(i[q]=e),i),z=(i,e)=>{if(!i)return i;let t=i[me]??=new Set;for(let[l,r]of Object.entries(e)){if(l in i&&!t.has(l)){console.warn(`\u0418\u043C\u044F "${l}" \u0443\u0436\u0435 \u0437\u0430\u043D\u044F\u0442\u043E \u043D\u0430 \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0435 \u2014 \u043C\u0435\u0442\u043E\u0434 \u043D\u0435 \u043E\u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u0430\u043D`,i);continue}Object.defineProperty(i,l,{value:r,writable:!0,configurable:!0,enumerable:!1}),t.add(l)}return i};var H={0:/^[0-9]$/,a:/^\p{L}$/u,"*":/^[^\n]$/},V=/^[\p{L}\p{N}]$/u,J=i=>i.replace(/\\(.)/g,"$1"),Z=i=>i.global?new RegExp(i.source,i.flags.replace("g","")):i;function F(i,e){let t=i[e],l=t=="{"?"}":"]",r=0;for(let n=e;n<i.length;n++){let s=i[n];if(s=="\\"){n++;continue}if(t=="["&&s=="{"){if((n=F(i,n))<0)return-1}else if(s==t)r++;else if(s==l&&--r==0)return n}return-1}function Q(i,e){let t=0,l=-1;for(let r=0;r<i.length;r++){if(i[r]=="\\"){r++;continue}i[r]=="{"||i[r]=="["?t++:i[r]=="}"||i[r]=="]"?t--:t==0&&i.startsWith(e,r)&&(l=r)}return l}function X(i,e){return i.every(t=>t.group==null&&(t.group=e,!t.children||X(t.children,e)))}function pe(i){let e=()=>(console.warn("\u041D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 \u0431\u043B\u043E\u043A \u043C\u0430\u0441\u043A\u0438",`{${i}}`),[...`{${i}}`].map(n=>({type:"literal",char:n}))),t=/^([A-Za-z_]\w*):/.exec(i);if(t){let n=$(i.slice(t[0].length));return X(n,t[1])?n:e()}let l=Q(i,";");if(l>0){let n=i.slice(l+1);if(/^(\d+|\d*-\d*)$/.test(n)&&n!="-"){let[s,a]=/^\d+$/.test(n)?[+n,+n]:n.split("-").map((u,o)=>u===""?o?1/0:0:+u);return a<s?e():[{type:"repeat",children:$(i.slice(0,l)),min:s,max:a}]}}if(i[0]=="{"&&i.at(-1)=="}")try{return[{type:"slot",test:new RegExp(`^(?:${i.slice(1,-1)})$`,"u")}]}catch{return e()}let r=Q(i,"=>");if(r>0){let n=J(i.slice(0,r)),s=J(i.slice(r+2));return n.length!=1||!s?e():[{type:"transform",from:n,to:s}]}return e()}function $(i){let e=[];for(let t=0;t<i.length;t++){let l=i[t],r;l=="\\"?e.push({type:"literal",char:i[++t]??"\\"}):l=="["&&(r=F(i,t))>=0?(e.push({type:"optional",children:$(i.slice(t+1,r))}),t=r):l=="{"&&(r=F(i,t))>=0?(e.push(...pe(i.slice(t+1,r))),t=r):e.push(H[l]?{type:"slot",test:H[l]}:{type:"literal",char:l})}return e}function Y(i){return i.every(e=>e.type=="literal"||e.type=="slot"||e.type=="repeat"&&e.min==e.max&&Y(e.children))}function ee(i,e=new Set){for(let t of i)t.group!=null&&e.add(t.group),t.children&&ee(t.children,e);return e}function w(i,e={}){if(i&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof RegExp)&&i.pattern==null&&i.filter==null&&i.numeral==null)return Object.entries(i).flatMap(([l,r])=>w(r,e).map(n=>({...n,key:l})));let t=(Array.isArray(i)?i:[i]).map(l=>{if(typeof l=="function")return{fn:l,base:e};if(l instanceof RegExp&&(l={filter:l}),typeof l=="string"&&(l={pattern:l}),l.numeral){let s={fraction:0,group:" ",decimal:",",prefix:"",suffix:"",sign:!1,...l.numeral};return{numeral:s,fixed:!1,valid:null,message:l.message??s.message,filler:l.filler??e.filler,before_char:null,before_slot:null}}let r=l.pattern!=null?$(l.pattern):[{type:"repeat",min:0,max:l.max_length??1/0,greedy:!0,children:[{type:"slot",test:Z(l.filter)}]}],n=l.groups??e.groups??{};return{nodes:r,names:[...ee(r)],fills:Object.fromEntries(Object.entries(n).filter(([,s])=>s?.filler!=null).map(([s,a])=>[s,a.filler])),fixed:l.pattern!=null&&Y(r),valid:l.valid?Z(l.valid):l.filter?/./:null,message:l.message,filler:l.filler??e.filler,before_char:l.before_char??e.before_char,before_slot:l.before_slot??e.before_slot}});return t.forEach((l,r)=>l.key??=r),t}function D(i,e,t,l){let r=i.fills?.[t];return r==null&&(r=i.filler??"_",l=e),r[l]??r.at(-1)??"_"}function M(i,e,t){let l=[...String(e??"")];return i.before_char?l.flatMap(r=>{let n=i.before_char(t?.input,{char:r});return n===!1||n===""||n===null?[]:typeof n=="string"?[...n]:[r]}):l}function ge(i,e,t){return i.type=="slot"?i.test.test(e):i.type=="transform"?i.from===e||t.input.slice(t.ip,t.ip+i.to.length).join("")===i.to:i.type=="repeat"?S(i.children,e,t):!1}function S(i,e,t,l){for(let r of i){if(r.type=="literal"){if(!l&&r.char===e)return!0;continue}if(r.type=="optional"||r.type=="repeat"&&r.min==0){if(S(r.children,e,t,l))return!0;continue}return ge(r,e,t)}return l?i.some(r=>r.type=="literal"&&r.char===e):!1}function j(i,e,t,l="char",r=null,n=null){i.units.push({kind:l,ordinal:r,group:n,stream_start:i.stream.length,stream_end:i.stream.length+e.length,fmt_start:i.formatted.length,fmt_end:i.formatted.length+t.length}),i.stream+=e,l=="char"&&(i.raw+=e),l=="char"&&n!=null&&(i.groups[n]+=e),r!=null&&(i.cells[r]=l=="char"?e:null),i.formatted+=t}function W(i){i.stop_fmt<0&&(i.stop_fmt=i.formatted.length+i.tail.length)}function R(i){i.complete=!1,i.done=!0,W(i)}function v(i,e,t){for(let l=0;l<i.length;l++){let r=i[l];if(r.type=="literal")e.done?e.ph+=r.char:e.ip<e.input.length?e.input[e.ip]===r.char?(e.ip++,e.consumed++,!e.diverged&&V.test(r.char)&&e.lead++,j(e,r.char,r.char,"literal")):(V.test(r.char)&&(!e.diverged&&e.raw===""&&(e.lead=0),e.diverged=!0),e.formatted+=r.char):e.tail+=r.char;else if(r.type=="slot"){let n=e.ordinal++,s=r.group??null,a=s==null?null:e.local[s]=(e.local[s]??-1)+1,u=D(t,n,s,a);if(e.done){e.ph_slots.push({fmt:e.formatted.length+e.tail.length+e.ph.length,node:r,fill:u}),e.ph+=u;continue}let o=!1;for(;;){if(e.ip>=e.input.length){R(e),e.ph_slots.push({fmt:e.formatted.length+e.tail.length,node:r,fill:u}),e.ph+=u;break}let c=e.input[e.ip];if(r.test.test(c)){if(t.before_slot&&!o){let h=t.before_slot(e.ctx?.input,{char:c,slot:n,cells:e.cells,raw:e.raw,node:r});if(h===!1){e.ip++;continue}if(typeof h=="string"&&h!==c){e.input.splice(e.ip,1,...h),o=!0;continue}}j(e,c,c,"char",n,s)}else if(c===u)e.complete=!1,j(e,c,c,"hole",n,s);else{e.ip++;continue}e.ip++,e.consumed++;break}}else if(r.type=="transform"){if(e.done){e.ph+=r.to;continue}for(;;){if(e.ip>=e.input.length){R(e),e.ph+=r.to;break}if(e.input.slice(e.ip,e.ip+r.to.length).join("")===r.to)e.ip+=r.to.length,e.consumed+=r.to.length;else if(e.input[e.ip]===r.from)e.ip++,e.consumed++;else{e.ip++;continue}e.diverged||e.lead++,j(e,r.to,r.to);break}}else if(r.type=="repeat"){if(e.done){for(let s=0;s<r.min;s++)v(r.children,e,t);continue}let n=0;for(;n<r.max;){if(e.ip>=e.input.length){if(n<r.min){R(e);for(let a=n;a<r.min;a++)v(r.children,e,t)}else W(e);break}if(!S(r.children,e.input[e.ip],e)){if(!r.greedy&&n>=r.min)break;e.ip++;continue}let s=e.ip;if(v(r.children,e,t),e.done){for(let a=n+1;a<r.min;a++)v(r.children,e,t);break}if(e.ip===s)break;n++}}else if(r.type=="optional"){if(e.done)continue;let n=i.slice(l+1),s=!1;for(;e.ip<e.input.length;){let a=e.input[e.ip];if(S(r.children,a,e,!0)){s=!0,v(r.children,e,t);break}if(S(n,a,e))break;e.ip++}!s&&e.ip>=e.input.length&&W(e)}}}function _e(i,e){let t=i.numeral,l=String(e??""),r=t.sign&&l.includes("-"),n;if(t.decimal&&(l.includes(t.decimal)||l.includes("."))){let p=ae=>ae.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),k=l.replace(new RegExp(`[^0-9${p(t.decimal)}.]`,"g"),"").replace(t.decimal,"."),U=parseFloat(k);n=Number.isFinite(U)?String(Math.round(U*10**t.fraction)):""}else{let p=l.replace(/\D/g,"");n=p===""?"":p.replace(/^0+/,"")||"0"}if(!n){let p=t.prefix+D(i,0);if(t.fraction){p+=t.decimal;for(let k=1;k<=t.fraction;k++)p+=D(i,k)}return{stream:"",raw:"",formatted:"",tail:"",ph:p+t.suffix,ph_slots:[],complete:!1,consumed:0,lead:0,units:[],cells:[],groups:{},stop_fmt:p.length}}let s=t.fraction,a=n.padStart(s+1,"0"),u=(s?a.slice(0,-s):a).replace(/^0+(?=\d)/,""),o=s?a.slice(-s):"",c=u.length+o.length-n.length,h=(r?"-":"")+n,f="",d=[],x=0,m=0,_=p=>{f+=p},b=p=>{d.push({kind:"char",ordinal:null,stream_start:x,stream_end:x+1,fmt_start:f.length,fmt_end:f.length+1}),f+=p,x++};_(t.prefix),r&&b("-");for(let p=0;p<u.length;p++,m++)p&&(u.length-p)%3==0&&_(t.group),m>=c?b(u[p]):_(u[p]);if(s){_(t.decimal);for(let p=0;p<o.length;p++,m++)m>=c?b(o[p]):_(o[p])}let g=f.length;_(t.suffix);let y=(r?-1:1)*parseFloat(u+(s?"."+o:"")),C=(t.min==null||y>=t.min)&&(t.max==null||y<=t.max);return{stream:h,raw:h,formatted:f,tail:"",ph:"",ph_slots:[],complete:C,consumed:h.length,lead:0,units:d,cells:[],groups:{},stop_fmt:g}}function A(i,e,t){if(i.numeral)return _e(i,e);let l={input:M(i,e,t),ctx:t,ip:0,stream:"",raw:"",formatted:"",tail:"",ph:"",ph_slots:[],units:[],cells:[],groups:Object.fromEntries((i.names??[]).map(r=>[r,""])),local:{},consumed:0,lead:0,diverged:!1,ordinal:0,complete:!0,done:!1,stop_fmt:-1};return v(i.nodes,l,i),l.stop_fmt<0&&(l.stop_fmt=l.formatted.length),i.valid&&(l.complete=l.complete&&i.valid.test(l.raw)),{stream:l.stream,raw:l.raw,formatted:l.formatted,tail:l.tail,ph:l.ph,ph_slots:l.ph_slots,complete:l.complete,consumed:l.consumed,lead:l.lead,units:l.units,cells:l.cells,groups:l.groups,stop_fmt:l.stop_fmt}}function K(i,e,t={}){let l=[];t={...t,stream:String(e??"")};for(let n of i)n.fn?l.push(...w(n.fn(t),n.base).map(s=>({...s,key:n.key??s.key}))):l.push(n);let r=null;for(let n of l){let s=A(n,e,t);(!r||ye(s,r.result))&&(r={result:s,def:n,mask_id:n.key})}return r}function ye(i,e){return i.consumed!=e.consumed?i.consumed>e.consumed:i.lead>e.lead}function O(i,e){return e=="always"?i.formatted+i.tail+i.ph:e===!1?i.formatted:i.formatted+i.tail}function te(i,e){for(let t of i.units)if(t.kind!="literal"&&(e<=t.stream_start||e<t.stream_end))return t.fmt_start;return i.stop_fmt}function le(i,e){let t=i.units.filter(l=>l.kind=="char");return t.length>e?t[e-1].stream_end:i.stream.length}var we=["edit","pad","align","min","max"];function re(i,e){let t=[];i.slots.forEach((l,r)=>{let n=l.node.group??null,s=t.at(-1);if(!s||s.name!==n){let a=Object.fromEntries(we.map(u=>[u,e[u]]));n!=null&&Object.assign(a,e.groups?.[n]),t.push(s={name:n,first:r,fmts:[],digits:!0,opts:a})}s.fmts.push(l.fmt),s.last=r,s.digits&&=l.node.test.test("0")&&!l.node.test.test("a")});for(let l of t)[l.start,l.end]=[l.fmts[0],l.fmts.at(-1)+1];return t}function B(i,e){let t=i.fmts.length,l=[...e].slice(-t),r=Array(t-l.length).fill(i.opts.pad??null);return i.opts.align=="right"?[...r,...l]:[...l,...r]}function ie(i,e,t){let{max:l}=i.opts,r=i.digits&&l!=null;return e+=t,r&&+e>l&&(e=String(l)),{buffer:e,cells:B(i,e),advance:e.length>=i.fmts.length||r&&+e*10>l}}function T(i,e){let{min:t}=i.opts,l=i.fmts.length;return!i.digits||t==null||e.includes(null)||+e.join("")>=t?e:B(i,String(t).padStart(l,"0"))}function ne(i,e,t){if(!i.digits)return null;let l=i.fmts.length,r=e.join(""),{min:n=null,max:s=null}=i.opts;n??=0,s??=10**l-1;let a=r===""?t>0?n:s:+r+t;return a>s?a=n:a<n&&(a=s),B(i,String(a).padStart(l,"0"))}function se(i,e,t){return(i.length?i:[null]).every(l=>{let r={min:t.min,max:t.max,...l!=null&&t.groups?.[l]},n=e[l];return r.min==null&&r.max==null||!/^\d+$/.test(n??"")?!0:(r.min==null||+n>=r.min)&&(r.max==null||+n<=r.max)})}var xe=["before_init","on_init","before_char","before_slot","before_input","on_input","before_paste","on_paste","on_accept","on_complete","on_incomplete","on_mask_change"],I=class i{static#w=["target","mask"];static#x=["text","search","tel","url","password"];static#b(e){let t=A(e,""),l=0;return t.slots=t.ph_slots,t.parts=t.slots.map((r,n)=>n&&r.fmt>t.slots[n-1].fmt+1?++l:l),t.template=O(t,"always"),t}static#v(e){if(!/^\s*[[{]/.test(e))return e;let t=l=>typeof l=="string"||Array.isArray(l)&&l.every(r=>typeof r=="string");try{let l=JSON.parse(e);if(Array.isArray(l)?t(l):l&&typeof l=="object"&&Object.values(l).every(t))return l}catch{}return e}#e={};#p={};#o=null;#t=new WeakMap;#i=[];static find=P;get params(){return this.#e}get value(){return this.#i.map(e=>e.value)}clone(e){return new i({...this.#e,...this.#p,...e,parent:this})}constructor(e){e={target:"input[mask]",mask:null,numeral:null,filler:"_",placeholder:!0,edit:"free",pad:null,align:"left",min:null,max:null,groups:{},caret:!0,coerce_type:!0,max_raw:null,validate:null,validation_message:null,...Object.fromEntries(xe.map(t=>[t,()=>{}])),...e};for(let[t,l]of Object.entries(e))typeof l=="function"&&!i.#w.includes(t)?(this[t]=l.bind(this),this.#p[t]=l):this.#e[t]=l;this.before_init(this.#e),this.#e.numeral!=null?this.#o=w({numeral:this.#e.numeral},this.#n()):this.#e.mask!=null&&(this.#o=w(this.#e.mask,this.#n()));for(let t of E(this.#e.target))this.#E(t);this.on_init(this.#e)}raw(e=this.#c()){return this.#t.get(L(e))?.result?.raw??""}state(e=this.#c()){let t=L(e),l=this.#t.get(t);return l?.result?this.#h(t,l):null}set(e,t){arguments.length<2&&([e,t]=[this.#c(),e]);for(let l of E(e))this.#t.has(l)&&this.#r(l,String(t??""),{prefix:String(t??"")})}clear(e=this.#i){this.set(e,"")}#c(){if(this.#i.length!=1)throw new Error(`Mask: \u043C\u0430\u0441\u043A\u0430 \u043F\u0440\u0438\u0432\u044F\u0437\u0430\u043D\u0430 \u043A ${this.#i.length} \u043F\u043E\u043B\u044F\u043C \u2014 \u0443\u043A\u0430\u0436\u0438\u0442\u0435 \u043F\u043E\u043B\u0435 \u044F\u0432\u043D\u043E`);return this.#i[0]}set_mask(e,t=null){let l=w(e,this.#n());t||(this.#o=l);for(let r of t?E(t):this.#i){let n=this.#t.get(r);n&&(n.defs=l,n.seg=null,this.#r(r,n.stream,{}))}}#n(){return{filler:this.#e.filler,groups:this.#e.groups,before_char:this.before_char,before_slot:this.before_slot}}#k(e){return e=="email"?w({filter:/[a-z0-9@._%+-]/i,valid:/^[^@\s]+@[^@\s]+\.[^@\s]{2,}$/},this.#n()):e=="number"?w({numeral:{}},this.#n()):null}#E(e){if(P(e))throw new Error("\u041C\u0430\u0441\u043A\u0430 \u0443\u0436\u0435 \u043F\u0440\u0438\u0432\u044F\u0437\u0430\u043D\u0430 \u043A \u044D\u0442\u043E\u043C\u0443 \u043F\u043E\u043B\u044E");G(e,this);let t=null;this.#e.coerce_type!==!1&&(e.type=="number"||e.type=="email")&&(t=e.type,e.inputMode=t=="number"?"numeric":"email",e.type="text"),i.#x.includes(e.type)||console.warn(`Mask: \u043F\u043E\u043B\u0435 type="${e.type}" \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0443\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u043A\u0430\u0440\u0435\u0442\u043A\u043E\u0439 \u2014 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 type="text" \u0438\u043B\u0438 "tel"`,e);let l=e.getAttribute("maxlength");l!=null&&e.removeAttribute("maxlength");let r=this.#e.max_raw??(l!=null?+l:null),n=e.getAttribute("mask"),s=this.#o??(n?w(i.#v(n),this.#n()):this.#k(t));if(!s){console.warn("Mask: \u0434\u043B\u044F \u043F\u043E\u043B\u044F \u043D\u0435 \u0437\u0430\u0434\u0430\u043D\u0430 \u043C\u0430\u0441\u043A\u0430 (\u043D\u0438 \u0432 params.mask, \u043D\u0438 \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0435 mask)",e);return}let a=t=="number"||this.#e.numeral!=null,u={defs:s,def:null,stream:"",result:null,mask_id:null,rendered:"",seg:null,composing:!1,handled:!1,coerced:t,max_raw:r,numeric:a};this.#t.set(e,u),this.#i.push(e),z(e,{raw:()=>this.raw(e),state:()=>this.state(e),set:f=>this.set(e,f),clear:()=>this.clear(e),set_mask:f=>this.set_mask(f,e)});let o=()=>this.#e.caret=="hide"&&e.style.setProperty("caret-color","transparent","important");o(),e.addEventListener("beforeinput",f=>this.#S(e,f));let c=[this.#e.edit,...Object.values(this.#e.groups??{}).map(f=>f?.edit)];if(c.includes("whole")&&(this.#e.placeholder!="always"||s.some(f=>!f.fixed&&!f.fn))&&console.warn("Mask: edit: 'whole' \u0440\u0430\u0431\u043E\u0442\u0430\u0435\u0442 \u0441 \u0444\u0438\u043A\u0441\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u043E\u0439 \u043C\u0430\u0441\u043A\u043E\u0439 \u0438 placeholder: 'always' - \u0438\u043D\u0430\u0447\u0435 \u0432\u0435\u0434\u0451\u0442 \u0441\u0435\u0431\u044F \u043A\u0430\u043A 'end'",e),c.some(f=>f&&f!="free")){let f=d=>this.#M(e,d.type=="click");for(let d of["selectionchange","click","keyup","select"])e.addEventListener(d,f);e.addEventListener("keydown",d=>this.#j(e,d))}let h=()=>{if(u.handled){u.handled=!1;return}u.composing||this.#m(e)};e.addEventListener("input",h),e.addEventListener("change",h),e.addEventListener("compositionstart",()=>u.composing=!0),e.addEventListener("compositionend",()=>{u.composing=!1,this.#m(e)}),e.addEventListener("focus",f=>{o(),this.#r(e,u.stream,{prefix:u.stream,silent:!0}),this.#$(e,f.relatedTarget)}),e.addEventListener("blur",()=>{this.#d(e),u.seg=null,this.#r(e,u.stream,{silent:!0})}),e.closest("form")?.addEventListener("reset",()=>queueMicrotask(()=>this.#m(e))),this.#r(e,e.value,{silent:!0})}#S(e,t){let l=this.#t.get(e),r=t.inputType??"insertText";if(t.isComposing||r=="insertCompositionText"||r=="deleteCompositionText"){l.composing=!0;return}if(r=="historyUndo"||r=="historyRedo")return;let n=e.selectionStart??0,s=e.selectionEnd??n,{g:a,edit:u}=this.#a(l,n,s);u=="end"&&l.result&&!(n==0&&s==e.value.length)&&!(a&&n==a.start&&s==a.end)&&(n=s=this.#_(e,l,a)),t.preventDefault(),l.handled=!0;let o=r.startsWith("delete"),c="";if(!o){if(r=="insertLineBreak"||r=="insertParagraph")return;if(c=t.data??t.dataTransfer?.getData("text/plain")??"",r=="insertFromPaste"){let f=this.before_paste(e,c);if(f===!1)return;typeof f=="string"&&(c=f)}if(l.numeric){let f=l.defs.some(d=>d.numeral?.sign);c=[...c].filter(d=>d>="0"&&d<="9"||f&&d=="-").join("")}}if(this.before_input(e,{type:r,insert:c,start:n,end:s})===!1)return;let h=e.value;u=="whole"?this.#L(e,r,o?"":c):this.#l(l)?this.#O(e,r,n,s,o?"":c):this.#A(e,n,s,o?"":c,r),r=="insertFromPaste"&&this.on_paste(e,this.#h(e,l)),t.defaultPrevented&&e.value!==h&&e.dispatchEvent(new InputEvent("input",{bubbles:!0,inputType:r,data:c||null}))}#A(e,t,l,r,n){let s=this.#t.get(e),a=s.result?.units??[],u,o,c;if(t!=l){let f=a.filter(d=>d.fmt_start<l&&d.fmt_end>t);u=f.length?f[0].stream_start:this.#y(a,t),o=f.length?f.at(-1).stream_end:u}else if(!n.startsWith("delete"))u=o=this.#y(a,t);else{if(n.includes("Forward"))c=a.find(f=>f.fmt_end>t&&f.kind!="literal")??a.find(f=>f.fmt_end>t);else{let f;for(let d of a)d.fmt_start<t&&(d.kind=="literal"?f=d:c=d);c??=f}if(!c)return;u=c.stream_start,o=c.stream_end}let h=s.stream.slice(0,u)+r;this.#r(e,h+s.stream.slice(o),{prefix:h})}#O(e,t,l,r,n){let s=this.#t.get(e),a=s.def,u=this.#l(s),{slots:o,parts:c}=u,h=o.length,f=this.#f(s,u),d=g=>{let y=o.findIndex(C=>C.fmt>=g);return y<0?h:y},x=g=>u.template.slice(o[g-1].fmt+1,o[g].fmt),m;if(l!=r){m=d(l);for(let g=m;g<h&&o[g].fmt<r;g++)f[g]=null}else if(!n&&t.startsWith("delete")){if(t.includes("Forward")){for(m=d(l);m<h&&f[m]==null;)m++;if(m>=h)return}else{m=-1;for(let g=0;g<h;g++)o[g].fmt<l&&(m=g);for(;m>=0&&f[m]==null;)m--;if(m<0)return}f[m]=null}else m=d(l),m>=h&&(m=f.indexOf(null))<0&&(m=h);for(let g of M(a,n,{input:e})){if(m>=h)break;if(!o[m].node.test.test(g)){let y=c.lastIndexOf(c[m]);y+1<h&&x(y+1).includes(g)&&(m=y+1);continue}f[m++]=g}let _=this.#u(u,f),b=Math.min(A(a,_.slice(0,m),{input:e}).stream.length,h);this.#r(e,_,{caret_fmt:b<h?o[b].fmt:o[h-1].fmt+1})}#L(e,t,l){let r=this.#t.get(e),n=this.#l(r),s=n.spans,a=this.#g(e,r),u=this.#f(r,n),o=f=>u.slice(f.first,f.last+1),c=(f,d)=>u.splice(f.first,d.length,...d),h=s[a.gi];if(t.startsWith("delete")){if(o(h).every(f=>f==null)){t.includes("Backward")&&a.gi>0&&this.#s(e,a.gi-1);return}c(h,o(h).fill(null)),a.buffer=""}else{t=="insertFromPaste"&&(a.buffer="");for(let f of M(r.def,l,{input:e})){h=s[a.gi];let d=s[a.gi+1];if(d&&n.template.slice(h.end,d.start).includes(f)){a.buffer&&(c(h,T(h,o(h))),a.gi++,a.buffer="");continue}if(!n.slots[h.first+Math.min(a.buffer.length,h.fmts.length-1)].node.test.test(f))continue;let m=ie(h,a.buffer,f);c(h,m.cells),a.buffer=m.buffer,m.advance&&(c(h,T(h,o(h))),a.buffer="",d&&a.gi++)}}this.#r(e,this.#u(n,u),{}),this.#s(e,a.gi,!1)}#j(e,t){let l=this.#t.get(e);if(t.altKey||t.ctrlKey||t.metaKey||!l?.result)return;let{g:r,edit:n}=this.#a(l,e.selectionStart??0,e.selectionEnd??0);if(n!="whole")return;let s=this.#l(l).spans,a=s.length-1,u=this.#g(e,l).gi,o;switch(t.key){case"ArrowLeft":o=u-1;break;case"ArrowRight":o=u+1;break;case"Home":o=0;break;case"End":o=a;break;case"Tab":if(o=u+(t.shiftKey?-1:1),o<0||o>a)return;break;case"ArrowUp":case"ArrowDown":{t.preventDefault();let c=this.#l(l),h=this.#f(l,c),f=ne(s[u],h.slice(s[u].first,s[u].last+1),t.key=="ArrowUp"?1:-1);if(!f)return;h.splice(s[u].first,f.length,...f);let d=e.value;this.#r(e,this.#u(c,h),{}),this.#s(e,u),e.value!==d&&(l.handled=!0,e.dispatchEvent(new InputEvent("input",{bubbles:!0,inputType:"insertReplacementText"})));return}default:return}t.preventDefault(),this.#s(e,Math.max(0,Math.min(o,a)))}#s(e,t,l=!0){let r=this.#t.get(e);r.seg&&r.seg.gi!==t&&this.#d(e),(l||r.seg?.gi!==t)&&(r.seg={gi:t,buffer:""});let n=this.#l(r).spans[t];document.activeElement===e&&e.setSelectionRange(n.start,n.end)}#g(e,t){let{g:l}=this.#a(t,e.selectionStart??0,e.selectionEnd??0),r=this.#l(t).spans.indexOf(l);return t.seg?.gi!==r&&(this.#d(e),t.seg={gi:r,buffer:""}),t.seg}#d(e){let t=this.#t.get(e),l=this.#l(t);if(!t.seg?.buffer||!l)return;let r=l.spans[t.seg.gi],n=this.#f(t,l),s=n.slice(r.first,r.last+1),a=T(r,s);t.seg.buffer="",a!==s&&(n.splice(r.first,a.length,...a),this.#r(e,this.#u(l,n),{}))}#$(e,t){let l=this.#t.get(e),r=this.#l(l);if(!r||this.#a(l,0).edit!="whole")return;let n=t&&e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING;this.#s(e,n?r.spans.length-1:0)}#M(e,t=!1){let l=this.#t.get(e);if(document.activeElement!==e||!l?.result)return;let r=e.selectionStart,n=e.selectionEnd;if(r==null)return;let{g:s,edit:a}=this.#a(l,r,n);if(a=="whole"){let o=this.#l(l).spans.indexOf(s);return!t&&l.seg?.gi===o&&r==s.start&&n==s.end?void 0:this.#s(e,o,t||l.seg?.gi!==o)}if(a!="end")return;if(r!==n){let[o,c]=s?[s.start,s.end]:[0,e.value.length];(r!=0||n!=e.value.length)&&(r!=o||n!=c)&&e.setSelectionRange(o,c);return}if(r===l.caret)return;let u=this.#_(e,l,s);r!==u&&e.setSelectionRange(u,u),l.caret=u}#_(e,t,l){if(l){let r=this.#l(t).slots;for(let n=l.first;n<r.length;n++)if(t.result.cells?.[n]==null)return r[n].fmt;return r.at(-1).fmt+1}return Math.min(t.result.stop_fmt,e.value.length)}#l(e){let t=e.def;if(this.#e.placeholder!="always"||!t?.fixed)return null;let l=t.layout??=i.#b(t);return l.spans??=re(l,this.#e),l}#a(e,t,l=t){let r=this.#l(e)?.spans??[],n=r.find(a=>t!=l&&a.start==t&&a.end==l)??r.find(a=>t<=a.end)??r.at(-1)??null,s=n?n.opts.edit:this.#e.edit;return{g:n,edit:s=="whole"&&!n?"end":s}}#f(e,t){return t.slots.map((l,r)=>e.result?.cells?.[r]??null)}#u(e,t){let l=t.reduce((r,n,s)=>n!=null?s:r,-1);return t.slice(0,l+1).map((r,n)=>r??e.slots[n].fill).join("")}#y(e,t){let l=0;for(let r of e)(r.fmt_end<=t||r.fmt_start<t)&&(l=r.stream_end);return l}#m(e){let t=this.#t.get(e);if(e.value===t.rendered)return;t.seg=null;let l=e.selectionStart??e.value.length;this.#r(e,e.value,{prefix:e.value.slice(0,l)})}#r(e,t,{prefix:l=null,caret_fmt:r=null,silent:n=!1}={}){let s=this.#t.get(e),a={raw:s.result?.raw??"",value:e.value,input:e},u=K(s.defs,t,a);if(!u)return;let{result:o,def:c,mask_id:h}=u;s.max_raw!=null&&o.raw.length>s.max_raw&&(u=K(s.defs,o.stream.slice(0,le(o,s.max_raw)),a),{result:o,def:c,mask_id:h}=u),!c.numeral&&!se(c.names,{...o.groups,null:o.raw},this.#e)&&(o.complete=!1);let f=this.#T(e,o);e.value!==f&&(e.value=f),s.rendered=f,r==null&&l!=null&&document.activeElement===e&&(r=te(o,A(c,l,{input:e}).stream.length)),r!=null&&document.activeElement===e&&(r=Math.min(r,f.length),e.setSelectionRange(r,r),s.caret=r);let d=s.result,x=s.mask_id;if(s.result=o,s.stream=o.stream,s.def=c,s.mask_id=h,e.setAttribute("mask_id",h),e.setAttribute("progress",o.raw.length),e.setAttribute("is_complete",o.complete),this.#I(s)&&e.setCustomValidity&&e.setCustomValidity(!o.stream||o.complete?"":this.#C(e,s)),n)return;let m=this.#h(e,s);this.on_input(e,m),o.raw!==(d?.raw??"")&&this.on_accept(e,m),o.complete&&!d?.complete&&this.on_complete(e,m),!o.complete&&d?.complete&&this.on_incomplete(e,m),d&&h!==x&&this.on_mask_change(e,m)}#T(e,t){return t.stream?O(t,this.#e.placeholder):document.activeElement!==e?"":this.#e.placeholder=="always"?O(t,"always"):this.#e.placeholder==!1?"":O(t,!0)}#h(e,t){return{raw:t.result?.raw??"",formatted:e.value,complete:t.result?.complete??!1,mask_id:t.mask_id,progress:t.result?.raw.length??0,groups:{...t.result?.groups}}}#I(e){let t=this.#e.validate;return t===!0||t==null&&e.coerced!=null}#C(e,t){let l=typeof this.validation_message=="function"?this.validation_message:this.#e.validation_message??t.def?.message;return typeof l=="function"?l(e,this.#h(e,t))||"":typeof l=="string"?l:t.coerced=="email"?"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 \u0430\u0434\u0440\u0435\u0441 \u044D\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u043E\u0439 \u043F\u043E\u0447\u0442\u044B":t.coerced=="number"||t.def?.numeral?"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0447\u0438\u0441\u043B\u043E \u0432 \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E\u043C \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D\u0435":"\u0417\u0430\u043F\u043E\u043B\u043D\u0438\u0442\u0435 \u043F\u043E\u043B\u0435 \u043F\u043E\u043B\u043D\u043E\u0441\u0442\u044C\u044E"}};return de(be);})();
2
2
  if(typeof Mask!=="undefined"&&Mask&&Mask.default)globalThis.Mask=Mask.default;