@cat-of-summer/st-script 1.0.3 → 1.0.5

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.
@@ -1 +1 @@
1
- var R=Symbol(),F=Symbol(),S=n=>{try{return n instanceof Element?n:document.querySelector(n)}catch{return}},E=n=>{if(n==null)return[];if(n instanceof Element)return[n];if(n instanceof NodeList||n instanceof HTMLCollection)return[...n];if(Array.isArray(n))return n.flatMap(E);try{return[...document.querySelectorAll(n)]}catch{return[]}},M=n=>S(n)?.[R],T=(n,e)=>(n&&(n[R]=e),n),I=(n,e)=>{if(!n)return n;let t=n[F]??=new Set;for(let[r,i]of Object.entries(e)){if(r in n&&!t.has(r)){console.warn(`\u0418\u043C\u044F "${r}" \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`,n);continue}Object.defineProperty(n,r,{value:i,writable:!0,configurable:!0,enumerable:!1}),t.add(r)}return n};var O=class n{static#m={0:/^[0-9]$/,a:/^\p{L}$/u,"*":/^[^\n]$/};static#L=["target","mask"];static#A=["text","search","tel","url","password"];static#g=e=>e.replace(/\\(.)/g,"$1");static#y=e=>e.global?new RegExp(e.source,e.flags.replace("g","")):e;static#o(e,t){let r=e[t],i=r=="{"?"}":"]",l=0;for(let s=t;s<e.length;s++){let a=e[s];if(a=="\\"){s++;continue}if(r=="["&&a=="{"){if((s=n.#o(e,s))<0)return-1}else if(a==r)l++;else if(a==i&&--l==0)return s}return-1}static#w(e,t){let r=0,i=-1;for(let l=0;l<e.length;l++){if(e[l]=="\\"){l++;continue}e[l]=="{"||e[l]=="["?r++:e[l]=="}"||e[l]=="]"?r--:r==0&&e.startsWith(t,l)&&(i=l)}return i}static#M(e){let t=()=>(console.warn("\u041D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 \u0431\u043B\u043E\u043A \u043C\u0430\u0441\u043A\u0438",`{${e}}`),[...`{${e}}`].map(l=>({type:"literal",char:l}))),r=n.#w(e,";");if(r>0){let l=e.slice(r+1);if(/^(\d+|\d*-\d*)$/.test(l)&&l!="-"){let[s,a]=/^\d+$/.test(l)?[+l,+l]:l.split("-").map((o,h)=>o===""?h?1/0:0:+o);return a<s?t():[{type:"repeat",children:n.compile(e.slice(0,r)),min:s,max:a}]}}if(e[0]=="{"&&e.at(-1)=="}")try{return[{type:"slot",test:new RegExp(`^(?:${e.slice(1,-1)})$`,"u")}]}catch{return t()}let i=n.#w(e,"=>");if(i>0){let l=n.#g(e.slice(0,i)),s=n.#g(e.slice(i+2));return l.length!=1||!s?t():[{type:"transform",from:l,to:s}]}return t()}static compile(e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],l;i=="\\"?t.push({type:"literal",char:e[++r]??"\\"}):i=="["&&(l=n.#o(e,r))>=0?(t.push({type:"optional",children:n.compile(e.slice(r+1,l))}),r=l):i=="{"&&(l=n.#o(e,r))>=0?(t.push(...n.#M(e.slice(r+1,l))),r=l):t.push(n.#m[i]?{type:"slot",test:n.#m[i]}:{type:"literal",char:i})}return t}static#b(e){return e.every(t=>t.type=="literal"||t.type=="slot"||t.type=="repeat"&&t.min==t.max&&n.#b(t.children))}static build(e,t={}){if(e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof RegExp)&&e.pattern==null&&e.filter==null)return Object.entries(e).flatMap(([i,l])=>n.build(l,t).map(s=>({...s,key:i})));let r=(Array.isArray(e)?e:[e]).map(i=>{if(typeof i=="function")return{fn:i,base:t};i instanceof RegExp&&(i={filter:i}),typeof i=="string"&&(i={pattern:i});let l=i.pattern!=null?n.compile(i.pattern):[{type:"repeat",min:0,max:i.max_length??1/0,greedy:!0,children:[{type:"slot",test:n.#y(i.filter)}]}];return{nodes:l,fixed:i.pattern!=null&&n.#b(l),valid:i.valid?n.#y(i.valid):i.filter?/./:null,filler:i.filler??t.filler,before_char:i.before_char??t.before_char,before_slot:i.before_slot??t.before_slot}});return r.forEach((i,l)=>i.key??=l),r}static#k(e,t){let r=e.filler??"_";return r[t]??r[r.length-1]??"_"}static#v(e,t,r){let i=[...String(t??"")];return e.before_char?i.flatMap(l=>{let s=e.before_char(r?.input,{char:l});return s===!1||s===""||s===null?[]:typeof s=="string"?[...s]:[l]}):i}static#O(e,t,r){return e.type=="slot"?e.test.test(t):e.type=="transform"?e.from===t||r.input.slice(r.ip,r.ip+e.to.length).join("")===e.to:e.type=="repeat"?n.#n(e.children,t,r):!1}static#n(e,t,r,i){for(let l of e){if(l.type=="literal"){if(!i&&l.char===t)return!0;continue}if(l.type=="optional"||l.type=="repeat"&&l.min==0){if(n.#n(l.children,t,r,i))return!0;continue}return n.#O(l,t,r)}return i?e.some(l=>l.type=="literal"&&l.char===t):!1}static#a(e,t,r,i="char",l=null){e.units.push({kind:i,ordinal:l,stream_start:e.stream.length,stream_end:e.stream.length+t.length,fmt_start:e.formatted.length,fmt_end:e.formatted.length+r.length}),e.stream+=t,i=="char"&&(e.raw+=t),l!=null&&(e.cells[l]=i=="char"?t:null),e.formatted+=r}static#s(e){e.stop_fmt<0&&(e.stop_fmt=e.formatted.length+e.tail.length)}static#i(e,t,r){for(let i=0;i<e.length;i++){let l=e[i];if(l.type=="literal")t.done?t.ph+=l.char:t.ip<t.input.length?t.input[t.ip]===l.char?(t.ip++,t.consumed++,n.#a(t,l.char,l.char,"literal")):t.formatted+=l.char:t.tail+=l.char;else if(l.type=="slot"){let s=t.ordinal++,a=n.#k(r,s);if(t.done){t.ph_slots.push({fmt:t.formatted.length+t.tail.length+t.ph.length,node:l}),t.ph+=a;continue}let o=!1;for(;;){if(t.ip>=t.input.length){t.complete=!1,t.done=!0,n.#s(t),t.ph_slots.push({fmt:t.formatted.length+t.tail.length,node:l}),t.ph+=a;break}let h=t.input[t.ip];if(l.test.test(h)){if(r.before_slot&&!o){let u=r.before_slot(t.ctx?.input,{char:h,slot:s,cells:t.cells,raw:t.raw,node:l});if(u===!1){t.ip++;continue}if(typeof u=="string"&&u!==h){t.input.splice(t.ip,1,...u),o=!0;continue}}n.#a(t,h,h,"char",s)}else if(h===a)t.complete=!1,n.#a(t,h,h,"hole",s);else{t.ip++;continue}t.ip++,t.consumed++;break}}else if(l.type=="transform"){if(t.done){t.ph+=l.to;continue}for(;;){if(t.ip>=t.input.length){t.complete=!1,t.done=!0,n.#s(t),t.ph+=l.to;break}if(t.input.slice(t.ip,t.ip+l.to.length).join("")===l.to)t.ip+=l.to.length,t.consumed+=l.to.length;else if(t.input[t.ip]===l.from)t.ip++,t.consumed++;else{t.ip++;continue}n.#a(t,l.to,l.to);break}}else if(l.type=="repeat"){if(t.done){for(let a=0;a<l.min;a++)n.#i(l.children,t,r);continue}let s=0;for(;s<l.max;){if(t.ip>=t.input.length){if(s<l.min){t.complete=!1,t.done=!0,n.#s(t);for(let o=s;o<l.min;o++)n.#i(l.children,t,r)}else n.#s(t);break}if(!n.#n(l.children,t.input[t.ip],t)){if(!l.greedy&&s>=l.min)break;t.ip++;continue}let a=t.ip;if(n.#i(l.children,t,r),t.done){for(let o=s+1;o<l.min;o++)n.#i(l.children,t,r);break}if(t.ip===a)break;s++}}else if(l.type=="optional"){if(t.done)continue;let s=e.slice(i+1),a=!1;for(;t.ip<t.input.length;){let o=t.input[t.ip];if(n.#n(l.children,o,t,!0)){a=!0,n.#i(l.children,t,r);break}if(n.#n(s,o,t))break;t.ip++}!a&&t.ip>=t.input.length&&n.#s(t)}}}static run(e,t,r){let i={input:n.#v(e,t,r),ctx:r,ip:0,stream:"",raw:"",formatted:"",tail:"",ph:"",ph_slots:[],units:[],cells:[],consumed:0,ordinal:0,complete:!0,done:!1,stop_fmt:-1};return n.#i(e.nodes,i,e),i.stop_fmt<0&&(i.stop_fmt=i.formatted.length),e.valid&&(i.complete=i.complete&&e.valid.test(i.raw)),{stream:i.stream,raw:i.raw,formatted:i.formatted,tail:i.tail,ph:i.ph,ph_slots:i.ph_slots,complete:i.complete,consumed:i.consumed,units:i.units,cells:i.cells,stop_fmt:i.stop_fmt}}static run_all(e,t,r={}){let i=[];r={...r,stream:String(t??"")};for(let s of e)s.fn?i.push(...n.build(s.fn(r),s.base).map(a=>({...a,key:s.key??a.key}))):i.push(s);let l=null;for(let s of i){let a=n.run(s,t,r);(!l||a.consumed>l.result.consumed||a.consumed==l.result.consumed&&a.complete&&!l.result.complete)&&(l={result:a,def:s,mask_id:s.key})}return l}static render(e,t){return t=="always"?e.formatted+e.tail+e.ph:t===!1?e.formatted:e.formatted+e.tail}static caret_for(e,t){for(let r of e.units)if(r.kind!="literal"&&(t<=r.stream_start||t<r.stream_end))return r.fmt_start;return e.stop_fmt}static#x(e){let t=n.run(e,""),r=0;return t.slots=t.ph_slots,t.parts=t.slots.map((i,l)=>l&&i.fmt>t.slots[l-1].fmt+1?++r:r),t.template=n.render(t,"always"),t}#e={};#E={};#f=null;#t=new WeakMap;#r=[];static find=M;get params(){return this.#e}get value(){return this.#r.map(e=>e.value)}clone(e){return new n({...this.#e,...this.#E,...e,parent:this})}constructor(e){e={target:"input[mask]",mask:null,filler:"_",placeholder:!0,flow:!0,rewrite:!1,caret:!0,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:()=>{},...e};for(let[t,r]of Object.entries(e))typeof r=="function"&&!n.#L.includes(t)?(this[t]=r.bind(this),this.#E[t]=r):this.#e[t]=r;this.before_init(this.#e),this.#e.mask!=null&&(this.#f=n.build(this.#e.mask,this.#h()));for(let t of E(this.#e.target))this.#$(t);this.on_init(this.#e)}raw(e=this.#u()){return this.#t.get(S(e))?.result?.raw??""}state(e=this.#u()){let t=S(e),r=this.#t.get(t);return r?.result?this.#p(t,r):null}set(e,t){arguments.length<2&&([e,t]=[this.#u(),e]);for(let r of E(e))this.#t.has(r)&&this.#l(r,String(t??""),{prefix:String(t??"")})}clear(e=this.#r){this.set(e,"")}#u(){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 r=n.build(e,this.#h());t||(this.#f=r);for(let i of t?E(t):this.#r){let l=this.#t.get(i);l&&(l.defs=r,l.run=null,this.#l(i,l.stream,{}))}}#h(){return{filler:this.#e.filler,before_char:this.before_char,before_slot:this.before_slot}}#$(e){if(M(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");T(e,this),n.#A.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 t=this.#f??(e.getAttribute("mask")?n.build(e.getAttribute("mask"),this.#h()):null);if(!t){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 r={defs:t,def:null,stream:"",result:null,mask_id:null,rendered:"",run:null,composing:!1,handled:!1};this.#t.set(e,r),this.#r.push(e),I(e,{raw:()=>this.raw(e),state:()=>this.state(e),set:s=>this.set(e,s),clear:()=>this.clear(e),set_mask:s=>this.set_mask(s,e)});let i=()=>this.#e.caret=="hide"&&e.style.setProperty("caret-color","transparent","important");if(i(),e.addEventListener("beforeinput",s=>this.#j(e,s)),this.#e.caret!==!0){let s=()=>this.#I(e);for(let a of["selectionchange","click","keyup","select"])e.addEventListener(a,s)}let l=()=>{if(r.handled){r.handled=!1;return}r.composing||this.#d(e)};e.addEventListener("input",l),e.addEventListener("change",l),e.addEventListener("compositionstart",()=>r.composing=!0),e.addEventListener("compositionend",()=>{r.composing=!1,this.#d(e)}),e.addEventListener("focus",()=>{i(),this.#l(e,r.stream,{prefix:r.stream,silent:!0})}),e.addEventListener("blur",()=>{r.run=null,this.#l(e,r.stream,{silent:!0})}),e.closest("form")?.addEventListener("reset",()=>queueMicrotask(()=>this.#d(e))),this.#l(e,e.value,{silent:!0})}#j(e,t){let r=this.#t.get(e),i=t.inputType??"insertText";if(t.isComposing||i=="insertCompositionText"||i=="deleteCompositionText"){r.composing=!0;return}if(i=="historyUndo"||i=="historyRedo")return;let l=e.selectionStart??0,s=e.selectionEnd??l;this.#e.caret!==!0&&r.result&&!(l==0&&s==e.value.length)&&(l=s=this.#_(e,r,l)),t.preventDefault(),r.handled=!0;let a=i.startsWith("delete"),o="";if(!a){if(i=="insertLineBreak"||i=="insertParagraph")return;if(o=t.data??t.dataTransfer?.getData("text/plain")??"",i=="insertFromPaste"){let h=this.before_paste(e,o);if(h===!1)return;typeof h=="string"&&(o=h)}}this.before_input(e,{type:i,insert:o,start:l,end:s})!==!1&&(this.#e.placeholder=="always"&&r.def?.fixed?this.#T(e,i,l,s,a?"":o):this.#R(e,l,s,a?"":o,i),i=="insertFromPaste"&&this.on_paste(e,this.#p(e,r)))}#R(e,t,r,i,l){let s=this.#t.get(e),a=s.result?.units??[],o,h,u;if(t!=r){let p=a.filter(y=>y.fmt_start<r&&y.fmt_end>t);o=p.length?p[0].stream_start:this.#S(a,t),h=p.length?p.at(-1).stream_end:o}else if(!l.startsWith("delete"))o=h=this.#S(a,t);else{if(l.includes("Forward"))u=a.find(p=>p.fmt_end>t&&p.kind!="literal")??a.find(p=>p.fmt_end>t);else{let p;for(let y of a)y.fmt_start<t&&(y.kind=="literal"?p=y:u=y);u??=p}if(!u)return;o=u.stream_start,h=u.stream_end}let d=s.stream.slice(0,o)+i;this.#l(e,d+s.stream.slice(h),{prefix:d})}#T(e,t,r,i,l){let s=this.#t.get(e),a=s.def,o=a.layout??=n.#x(a),h=o.slots,u=o.parts,d=h.length,p=this.#e.flow,y=this.#e.rewrite,g=Array.from({length:d},(c,m)=>s.result?.cells?.[m]??null),_=c=>{let m=h.findIndex(A=>A.fmt>=c);return m<0?d:m},$=c=>o.template.slice(h[c-1].fmt+1,h[c].fmt),f,b=null,w=null;if(r!=i){f=_(r);for(let c=f;c<d&&h[c].fmt<i;c++)g[c]=null;s.run=null}else if(!l&&t.startsWith("delete")){if(t.includes("Forward")){if((f=_(r))>=d)return;let c=u[f];for(;f<d&&g[f]==null;)f++;if(f>=d||!p&&u[f]!=c)return}else{let c=-1;for(let m=0;m<d;m++)h[m].fmt<r&&(c=m);if(c<0)return;for(f=c;f>=0&&g[f]==null;)f--;if(f<0||!p&&(u[f]!=u[c]||r>h[c].fmt+1))return}g[f]=null}else if(f=_(r),f>=d&&(f=g.indexOf(null))<0&&(f=d),b=this.#c(o,f,r),y){let c=b??u[Math.min(f,d-1)];(s.run?.part!==c||s.run.k!==f||u[f]!==c)&&(w=c)}b??=f<d?u[f]:null;let v=null;for(let c of n.#v(a,l,{input:e})){if(f>=d){if(w==null)break;f=u.indexOf(w)}if(!p&&u[f]!=b){if($(f).includes(c)){b=u[f],v=f,w=y?u[f]:null;continue}if(w==null)continue;f=u.indexOf(w)}if(!h[f].node.test.test(c)){let m=u.lastIndexOf(u[f]);m+1<d&&$(m+1).includes(c)&&(f=m+1,b=u[f],v=f,w=y?u[f]:null);continue}if(w!=null){for(let m=0;m<d;m++)u[m]==w&&(g[m]=null);f=u.indexOf(w),b=w,w=null}g[f++]=c}let C=g.reduce((c,m,A)=>m!=null?A:c,-1),j=g.slice(0,C+1).map((c,m)=>c??n.#k(a,m)).join(""),k=Math.min(n.run(a,j.slice(0,f),{input:e}).stream.length,d),x=k<d?h[k].fmt:h[d-1].fmt+1;!p&&l&&k>0&&k<d&&u[k]!=u[k-1]&&(x=h[k-1].fmt+1),v!=null&&f==v&&(x=h[v].fmt);let L=_(x);s.run=v!=null?null:{part:this.#c(o,L,x)??u[Math.min(L,d-1)],k:L},this.#l(e,j,{caret_fmt:x})}#I(e){let t=this.#t.get(e);if(document.activeElement!==e||!t?.result)return;let r=e.selectionStart,i=e.selectionEnd;if(r==null)return;if(r!==i){(r!=0||i!=e.value.length)&&e.setSelectionRange(0,e.value.length);return}if(r===t.caret)return;let l=this.#_(e,t,r);r!==l&&e.setSelectionRange(l,l),t.caret=l}#_(e,t,r){let i=t.def;if(this.#e.placeholder=="always"&&i?.fixed&&!this.#e.flow){let l=i.layout??=n.#x(i),{slots:s,parts:a}=l,o=s.findIndex(p=>p.fmt>=r);o<0&&(o=s.length-1);let h=this.#c(l,o,r)??a[o],u=a.indexOf(h),d=a.lastIndexOf(h);for(let p=u;p<=d;p++)if(t.result.cells?.[p]==null)return s[p].fmt;return s[d].fmt+1}return Math.min(t.result.stop_fmt,e.value.length)}#c(e,t,r){let{slots:i,parts:l}=e;return!this.#e.flow&&t>0&&t<i.length&&l[t]!=l[t-1]&&r==i[t-1].fmt+1?l[t-1]:null}#S(e,t){let r=0;for(let i of e)(i.fmt_end<=t||i.fmt_start<t)&&(r=i.stream_end);return r}#d(e){let t=this.#t.get(e);if(e.value===t.rendered)return;t.run=null;let r=e.selectionStart??e.value.length;this.#l(e,e.value,{prefix:e.value.slice(0,r)})}#l(e,t,{prefix:r=null,caret_fmt:i=null,silent:l=!1}={}){let s=this.#t.get(e),a=n.run_all(s.defs,t,{raw:s.result?.raw??"",value:e.value,input:e});if(!a)return;let{result:o,def:h,mask_id:u}=a,d=this.#C(e,o);e.value!==d&&(e.value=d),s.rendered=d,i==null&&r!=null&&document.activeElement===e&&(i=n.caret_for(o,n.run(h,r,{input:e}).stream.length)),i!=null&&document.activeElement===e&&(i=Math.min(i,d.length),e.setSelectionRange(i,i),s.caret=i);let p=s.result,y=s.mask_id;if(s.result=o,s.stream=o.stream,s.def=h,s.mask_id=u,e.setAttribute("mask_id",u),e.setAttribute("progress",o.raw.length),e.setAttribute("is_complete",o.complete),l)return;let g=this.#p(e,s);this.on_input(e,g),o.raw!==(p?.raw??"")&&this.on_accept(e,g),o.complete&&!p?.complete&&this.on_complete(e,g),!o.complete&&p?.complete&&this.on_incomplete(e,g),p&&u!==y&&this.on_mask_change(e,g)}#C(e,t){return t.stream?n.render(t,this.#e.placeholder):document.activeElement!==e?"":this.#e.placeholder=="always"?n.render(t,"always"):this.#e.placeholder==!1?"":n.render(t,!0)}#p(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}}};export{O as default};
1
+ var H=Symbol(),le=Symbol(),T=i=>{try{return i instanceof Element?i:document.querySelector(i)}catch{return}},M=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(M);try{return[...document.querySelectorAll(i)]}catch{return[]}},W=i=>T(i)?.[H],K=(i,e)=>(i&&(i[H]=e),i),U=(i,e)=>{if(!i)return i;let t=i[le]??=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 J={0:/^[0-9]$/,a:/^\p{L}$/u,"*":/^[^\n]$/},Q=i=>i.replace(/\\(.)/g,"$1"),X=i=>i.global?new RegExp(i.source,i.flags.replace("g","")):i;function B(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=B(i,n))<0)return-1}else if(s==t)r++;else if(s==l&&--r==0)return n}return-1}function Y(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 re(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(r=>({type:"literal",char:r}))),t=Y(i,";");if(t>0){let r=i.slice(t+1);if(/^(\d+|\d*-\d*)$/.test(r)&&r!="-"){let[n,s]=/^\d+$/.test(r)?[+r,+r]:r.split("-").map((a,f)=>a===""?f?1/0:0:+a);return s<n?e():[{type:"repeat",children:N(i.slice(0,t)),min:n,max:s}]}}if(i[0]=="{"&&i.at(-1)=="}")try{return[{type:"slot",test:new RegExp(`^(?:${i.slice(1,-1)})$`,"u")}]}catch{return e()}let l=Y(i,"=>");if(l>0){let r=Q(i.slice(0,l)),n=Q(i.slice(l+2));return r.length!=1||!n?e():[{type:"transform",from:r,to:n}]}return e()}function N(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=B(i,t))>=0?(e.push({type:"optional",children:N(i.slice(t+1,r))}),t=r):l=="{"&&(r=B(i,t))>=0?(e.push(...re(i.slice(t+1,r))),t=r):e.push(J[l]?{type:"slot",test:J[l]}:{type:"literal",char:l})}return e}function Z(i){return i.every(e=>e.type=="literal"||e.type=="slot"||e.type=="repeat"&&e.min==e.max&&Z(e.children))}function E(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])=>E(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 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 r=l.pattern!=null?N(l.pattern):[{type:"repeat",min:0,max:l.max_length??1/0,greedy:!0,children:[{type:"slot",test:X(l.filter)}]}];return{nodes:r,fixed:l.pattern!=null&&Z(r),valid:l.valid?X(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 j(i,e){let t=i.filler??"_";return t[e]??t.at(-1)??"_"}function V(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 ie(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"?O(i.children,e,t):!1}function O(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(O(r.children,e,t,l))return!0;continue}return ie(r,e,t)}return l?i.some(r=>r.type=="literal"&&r.char===e):!1}function F(i,e,t,l="char",r=null){i.units.push({kind:l,ordinal:r,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),r!=null&&(i.cells[r]=l=="char"?e:null),i.formatted+=t}function D(i){i.stop_fmt<0&&(i.stop_fmt=i.formatted.length+i.tail.length)}function q(i){i.complete=!1,i.done=!0,D(i)}function $(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++,F(e,r.char,r.char,"literal")):e.formatted+=r.char:e.tail+=r.char;else if(r.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:r}),e.ph+=s;continue}let a=!1;for(;;){if(e.ip>=e.input.length){q(e),e.ph_slots.push({fmt:e.formatted.length+e.tail.length,node:r}),e.ph+=s;break}let f=e.input[e.ip];if(r.test.test(f)){if(t.before_slot&&!a){let o=t.before_slot(e.ctx?.input,{char:f,slot:n,cells:e.cells,raw:e.raw,node:r});if(o===!1){e.ip++;continue}if(typeof o=="string"&&o!==f){e.input.splice(e.ip,1,...o),a=!0;continue}}F(e,f,f,"char",n)}else if(f===s)e.complete=!1,F(e,f,f,"hole",n);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){q(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}F(e,r.to,r.to);break}}else if(r.type=="repeat"){if(e.done){for(let s=0;s<r.min;s++)$(r.children,e,t);continue}let n=0;for(;n<r.max;){if(e.ip>=e.input.length){if(n<r.min){q(e);for(let a=n;a<r.min;a++)$(r.children,e,t)}else D(e);break}if(!O(r.children,e.input[e.ip],e)){if(!r.greedy&&n>=r.min)break;e.ip++;continue}let s=e.ip;if($(r.children,e,t),e.done){for(let a=n+1;a<r.min;a++)$(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(O(r.children,a,e,!0)){s=!0,$(r.children,e,t);break}if(O(n,a,e))break;e.ip++}!s&&e.ip>=e.input.length&&D(e)}}}function ne(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=L=>L.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),A=l.replace(new RegExp(`[^0-9${p(t.decimal)}.]`,"g"),"").replace(t.decimal,"."),b=parseFloat(A);n=Number.isFinite(b)?String(Math.round(b*10**t.fraction)):""}else{let p=l.replace(/\D/g,"");n=p===""?"":p.replace(/^0+/,"")||"0"}if(!n){let p=t.prefix+j(i,0);if(t.fraction){p+=t.decimal;for(let A=1;A<=t.fraction;A++)p+=j(i,A)}return{stream:"",raw:"",formatted:"",tail:"",ph:p+t.suffix,ph_slots:[],complete:!1,consumed:0,units:[],cells:[],stop_fmt:p.length}}let s=t.fraction,a=n.padStart(s+1,"0"),f=(s?a.slice(0,-s):a).replace(/^0+(?=\d)/,""),o=s?a.slice(-s):"",u=f.length+o.length-n.length,h=(r?"-":"")+n,m="",_=[],y=0,w=0,v=p=>{m+=p},c=p=>{_.push({kind:"char",ordinal:null,stream_start:y,stream_end:y+1,fmt_start:m.length,fmt_end:m.length+1}),m+=p,y++};v(t.prefix),r&&c("-");for(let p=0;p<f.length;p++,w++)p&&(f.length-p)%3==0&&v(t.group),w>=u?c(f[p]):v(f[p]);if(s){v(t.decimal);for(let p=0;p<o.length;p++,w++)w>=u?c(o[p]):v(o[p])}let k=m.length;v(t.suffix);let x=(r?-1:1)*parseFloat(f+(s?"."+o:"")),S=(t.min==null||x>=t.min)&&(t.max==null||x<=t.max);return{stream:h,raw:h,formatted:m,tail:"",ph:"",ph_slots:[],complete:S,consumed:h.length,units:_,cells:[],stop_fmt:k}}function C(i,e,t){if(i.numeral)return ne(i,e);let l={input:V(i,e,t),ctx:t,ip:0,stream:"",raw:"",formatted:"",tail:"",ph:"",ph_slots:[],units:[],cells:[],consumed:0,ordinal:0,complete:!0,done:!1,stop_fmt:-1};return $(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,units:l.units,cells:l.cells,stop_fmt:l.stop_fmt}}function z(i,e,t={}){let l=[];t={...t,stream:String(e??"")};for(let n of i)n.fn?l.push(...E(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=C(n,e,t);(!r||s.consumed>r.result.consumed||s.consumed==r.result.consumed&&s.complete&&!r.result.complete)&&(r={result:s,def:n,mask_id:n.key})}return r}function R(i,e){return e=="always"?i.formatted+i.tail+i.ph:e===!1?i.formatted:i.formatted+i.tail}function ee(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 te(i,e){let t=i.units.filter(l=>l.kind=="char");return t.length>e?t[e-1].stream_end:i.stream.length}var se=["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"],G=class i{static#d=["target","mask"];static#p=["text","search","tel","url","password"];static#u(e){let t=C(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=R(t,"always"),t}#e={};#c={};#n=null;#t=new WeakMap;#r=[];static find=W;get params(){return this.#e}get value(){return this.#r.map(e=>e.value)}clone(e){return new i({...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(se.map(t=>[t,()=>{}])),...e};for(let[t,l]of Object.entries(e))typeof l=="function"&&!i.#d.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 M(this.#e.target))this.#_(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 M(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 r of t?M(t):this.#r){let n=this.#t.get(r);n&&(n.defs=l,n.run=null,this.#l(r,n.stream,{}))}}#i(){return{filler:this.#e.filler,before_char:this.before_char,before_slot:this.before_slot}}#g(e){return e=="email"?E({filter:/[a-z0-9@._%+-]/i,valid:/^[^@\s]+@[^@\s]+\.[^@\s]{2,}$/},this.#i()):e=="number"?E({numeral:{}},this.#i()):null}#_(e){if(W(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"),i.#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 r=this.#e.max_raw??(l!=null?+l:null),n=this.#n??(e.getAttribute("mask")?E(e.getAttribute("mask"),this.#i()):this.#g(t));if(!n){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 s=t=="number"||this.#e.numeral!=null,a={defs:n,def:null,stream:"",result:null,mask_id:null,rendered:"",run:null,composing:!1,handled:!1,coerced:t,max_raw:r,numeric:s};this.#t.set(e,a),this.#r.push(e),U(e,{raw:()=>this.raw(e),state:()=>this.state(e),set:u=>this.set(e,u),clear:()=>this.clear(e),set_mask:u=>this.set_mask(u,e)});let f=()=>this.#e.caret=="hide"&&e.style.setProperty("caret-color","transparent","important");if(f(),e.addEventListener("beforeinput",u=>this.#y(e,u)),this.#e.caret!==!0){let u=()=>this.#b(e);for(let h of["selectionchange","click","keyup","select"])e.addEventListener(h,u)}let o=()=>{if(a.handled){a.handled=!1;return}a.composing||this.#o(e)};e.addEventListener("input",o),e.addEventListener("change",o),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})}#y(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;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 a=r.startsWith("delete"),f="";if(!a){if(r=="insertLineBreak"||r=="insertParagraph")return;if(f=t.data??t.dataTransfer?.getData("text/plain")??"",r=="insertFromPaste"){let u=this.before_paste(e,f);if(u===!1)return;typeof u=="string"&&(f=u)}if(l.numeric){let u=l.defs.some(h=>h.numeral?.sign);f=[...f].filter(h=>h>="0"&&h<="9"||u&&h=="-").join("")}}if(this.before_input(e,{type:r,insert:f,start:n,end:s})===!1)return;let o=e.value;this.#e.placeholder=="always"&&l.def?.fixed?this.#x(e,r,n,s,a?"":f):this.#w(e,n,s,a?"":f,r),r=="insertFromPaste"&&this.on_paste(e,this.#s(e,l)),t.defaultPrevented&&e.value!==o&&e.dispatchEvent(new InputEvent("input",{bubbles:!0,inputType:r,data:f||null}))}#w(e,t,l,r,n){let s=this.#t.get(e),a=s.result?.units??[],f,o,u;if(t!=l){let m=a.filter(_=>_.fmt_start<l&&_.fmt_end>t);f=m.length?m[0].stream_start:this.#m(a,t),o=m.length?m.at(-1).stream_end:f}else if(!n.startsWith("delete"))f=o=this.#m(a,t);else{if(n.includes("Forward"))u=a.find(m=>m.fmt_end>t&&m.kind!="literal")??a.find(m=>m.fmt_end>t);else{let m;for(let _ of a)_.fmt_start<t&&(_.kind=="literal"?m=_:u=_);u??=m}if(!u)return;f=u.stream_start,o=u.stream_end}let h=s.stream.slice(0,f)+r;this.#l(e,h+s.stream.slice(o),{prefix:h})}#x(e,t,l,r,n){let s=this.#t.get(e),a=s.def,f=a.layout??=i.#u(a),o=f.slots,u=f.parts,h=o.length,m=this.#e.flow,_=this.#e.rewrite,y=Array.from({length:h},(d,g)=>s.result?.cells?.[g]??null),w=d=>{let g=o.findIndex(P=>P.fmt>=d);return g<0?h:g},v=d=>f.template.slice(o[d-1].fmt+1,o[d].fmt),c,k=null,x=null;if(l!=r){c=w(l);for(let d=c;d<h&&o[d].fmt<r;d++)y[d]=null;s.run=null}else if(!n&&t.startsWith("delete")){if(t.includes("Forward")){if((c=w(l))>=h)return;let d=u[c];for(;c<h&&y[c]==null;)c++;if(c>=h||!m&&u[c]!=d)return}else{let d=-1;for(let g=0;g<h;g++)o[g].fmt<l&&(d=g);if(d<0)return;for(c=d;c>=0&&y[c]==null;)c--;if(c<0||!m&&(u[c]!=u[d]||l>o[d].fmt+1))return}y[c]=null}else if(c=w(l),c>=h&&(c=y.indexOf(null))<0&&(c=h),k=this.#f(f,c,l),_){let d=k??u[Math.min(c,h-1)];(s.run?.part!==d||s.run.k!==c||u[c]!==d)&&(x=d)}k??=c<h?u[c]:null;let S=null;for(let d of V(a,n,{input:e})){if(c>=h){if(x==null)break;c=u.indexOf(x)}if(!m&&u[c]!=k){if(v(c).includes(d)){k=u[c],S=c,x=_?u[c]:null;continue}if(x==null)continue;c=u.indexOf(x)}if(!o[c].node.test.test(d)){let g=u.lastIndexOf(u[c]);g+1<h&&v(g+1).includes(d)&&(c=g+1,k=u[c],S=c,x=_?u[c]:null);continue}if(x!=null){for(let g=0;g<h;g++)u[g]==x&&(y[g]=null);c=u.indexOf(x),k=x,x=null}y[c++]=d}let p=y.reduce((d,g,P)=>g!=null?P:d,-1),A=y.slice(0,p+1).map((d,g)=>d??j(a,g)).join(""),b=Math.min(C(a,A.slice(0,c),{input:e}).stream.length,h),L=b<h?o[b].fmt:o[h-1].fmt+1;!m&&n&&b>0&&b<h&&u[b]!=u[b-1]&&(L=o[b-1].fmt+1),S!=null&&c==S&&(L=o[S].fmt);let I=w(L);s.run=S!=null?null:{part:this.#f(f,I,L)??u[Math.min(I,h-1)],k:I},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,r=e.selectionEnd;if(l==null)return;if(l!==r){(l!=0||r!=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 r=t.def;if(this.#e.placeholder=="always"&&r?.fixed&&!this.#e.flow){let n=r.layout??=i.#u(r),{slots:s,parts:a}=n,f=s.findIndex(m=>m.fmt>=l);f<0&&(f=s.length-1);let o=this.#f(n,f,l)??a[f],u=a.indexOf(o),h=a.lastIndexOf(o);for(let m=u;m<=h;m++)if(t.result.cells?.[m]==null)return s[m].fmt;return s[h].fmt+1}return Math.min(t.result.stop_fmt,e.value.length)}#f(e,t,l){let{slots:r,parts:n}=e;return!this.#e.flow&&t>0&&t<r.length&&n[t]!=n[t-1]&&l==r[t-1].fmt+1?n[t-1]:null}#m(e,t){let l=0;for(let r of e)(r.fmt_end<=t||r.fmt_start<t)&&(l=r.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:r=null,silent:n=!1}={}){let s=this.#t.get(e),a={raw:s.result?.raw??"",value:e.value,input:e},f=z(s.defs,t,a);if(!f)return;let{result:o,def:u,mask_id:h}=f;s.max_raw!=null&&o.raw.length>s.max_raw&&(f=z(s.defs,o.stream.slice(0,te(o,s.max_raw)),a),{result:o,def:u,mask_id:h}=f);let m=this.#v(e,o);e.value!==m&&(e.value=m),s.rendered=m,r==null&&l!=null&&document.activeElement===e&&(r=ee(o,C(u,l,{input:e}).stream.length)),r!=null&&document.activeElement===e&&(r=Math.min(r,m.length),e.setSelectionRange(r,r),s.caret=r);let _=s.result,y=s.mask_id;if(s.result=o,s.stream=o.stream,s.def=u,s.mask_id=h,e.setAttribute("mask_id",h),e.setAttribute("progress",o.raw.length),e.setAttribute("is_complete",o.complete),this.#k(s)&&e.setCustomValidity&&e.setCustomValidity(!o.stream||o.complete?"":this.#E(e,s)),n)return;let w=this.#s(e,s);this.on_input(e,w),o.raw!==(_?.raw??"")&&this.on_accept(e,w),o.complete&&!_?.complete&&this.on_complete(e,w),!o.complete&&_?.complete&&this.on_incomplete(e,w),_&&h!==y&&this.on_mask_change(e,w)}#v(e,t){return t.stream?R(t,this.#e.placeholder):document.activeElement!==e?"":this.#e.placeholder=="always"?R(t,"always"):this.#e.placeholder==!1?"":R(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}}#k(e){let t=this.#e.validate;return t===!0||t==null&&e.coerced!=null}#E(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"}};export{G as default};
package/dist/mask.min.js CHANGED
@@ -1,2 +1,2 @@
1
- var Mask=(()=>{var O=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var q=Object.prototype.hasOwnProperty;var B=(n,e)=>{for(var t in e)O(n,t,{get:e[t],enumerable:!0})},D=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of W(e))!q.call(n,i)&&i!==t&&O(n,i,{get:()=>e[i],enumerable:!(r=P(e,i))||r.enumerable});return n};var N=n=>D(O({},"__esModule",{value:!0}),n);var H={};B(H,{default:()=>L});var T=Symbol(),G=Symbol(),S=n=>{try{return n instanceof Element?n:document.querySelector(n)}catch{return}},E=n=>{if(n==null)return[];if(n instanceof Element)return[n];if(n instanceof NodeList||n instanceof HTMLCollection)return[...n];if(Array.isArray(n))return n.flatMap(E);try{return[...document.querySelectorAll(n)]}catch{return[]}},$=n=>S(n)?.[T],I=(n,e)=>(n&&(n[T]=e),n),C=(n,e)=>{if(!n)return n;let t=n[G]??=new Set;for(let[r,i]of Object.entries(e)){if(r in n&&!t.has(r)){console.warn(`\u0418\u043C\u044F "${r}" \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`,n);continue}Object.defineProperty(n,r,{value:i,writable:!0,configurable:!0,enumerable:!1}),t.add(r)}return n};var L=class n{static#m={0:/^[0-9]$/,a:/^\p{L}$/u,"*":/^[^\n]$/};static#L=["target","mask"];static#A=["text","search","tel","url","password"];static#g=e=>e.replace(/\\(.)/g,"$1");static#y=e=>e.global?new RegExp(e.source,e.flags.replace("g","")):e;static#o(e,t){let r=e[t],i=r=="{"?"}":"]",l=0;for(let s=t;s<e.length;s++){let a=e[s];if(a=="\\"){s++;continue}if(r=="["&&a=="{"){if((s=n.#o(e,s))<0)return-1}else if(a==r)l++;else if(a==i&&--l==0)return s}return-1}static#w(e,t){let r=0,i=-1;for(let l=0;l<e.length;l++){if(e[l]=="\\"){l++;continue}e[l]=="{"||e[l]=="["?r++:e[l]=="}"||e[l]=="]"?r--:r==0&&e.startsWith(t,l)&&(i=l)}return i}static#M(e){let t=()=>(console.warn("\u041D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 \u0431\u043B\u043E\u043A \u043C\u0430\u0441\u043A\u0438",`{${e}}`),[...`{${e}}`].map(l=>({type:"literal",char:l}))),r=n.#w(e,";");if(r>0){let l=e.slice(r+1);if(/^(\d+|\d*-\d*)$/.test(l)&&l!="-"){let[s,a]=/^\d+$/.test(l)?[+l,+l]:l.split("-").map((o,h)=>o===""?h?1/0:0:+o);return a<s?t():[{type:"repeat",children:n.compile(e.slice(0,r)),min:s,max:a}]}}if(e[0]=="{"&&e.at(-1)=="}")try{return[{type:"slot",test:new RegExp(`^(?:${e.slice(1,-1)})$`,"u")}]}catch{return t()}let i=n.#w(e,"=>");if(i>0){let l=n.#g(e.slice(0,i)),s=n.#g(e.slice(i+2));return l.length!=1||!s?t():[{type:"transform",from:l,to:s}]}return t()}static compile(e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],l;i=="\\"?t.push({type:"literal",char:e[++r]??"\\"}):i=="["&&(l=n.#o(e,r))>=0?(t.push({type:"optional",children:n.compile(e.slice(r+1,l))}),r=l):i=="{"&&(l=n.#o(e,r))>=0?(t.push(...n.#M(e.slice(r+1,l))),r=l):t.push(n.#m[i]?{type:"slot",test:n.#m[i]}:{type:"literal",char:i})}return t}static#b(e){return e.every(t=>t.type=="literal"||t.type=="slot"||t.type=="repeat"&&t.min==t.max&&n.#b(t.children))}static build(e,t={}){if(e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof RegExp)&&e.pattern==null&&e.filter==null)return Object.entries(e).flatMap(([i,l])=>n.build(l,t).map(s=>({...s,key:i})));let r=(Array.isArray(e)?e:[e]).map(i=>{if(typeof i=="function")return{fn:i,base:t};i instanceof RegExp&&(i={filter:i}),typeof i=="string"&&(i={pattern:i});let l=i.pattern!=null?n.compile(i.pattern):[{type:"repeat",min:0,max:i.max_length??1/0,greedy:!0,children:[{type:"slot",test:n.#y(i.filter)}]}];return{nodes:l,fixed:i.pattern!=null&&n.#b(l),valid:i.valid?n.#y(i.valid):i.filter?/./:null,filler:i.filler??t.filler,before_char:i.before_char??t.before_char,before_slot:i.before_slot??t.before_slot}});return r.forEach((i,l)=>i.key??=l),r}static#k(e,t){let r=e.filler??"_";return r[t]??r[r.length-1]??"_"}static#v(e,t,r){let i=[...String(t??"")];return e.before_char?i.flatMap(l=>{let s=e.before_char(r?.input,{char:l});return s===!1||s===""||s===null?[]:typeof s=="string"?[...s]:[l]}):i}static#O(e,t,r){return e.type=="slot"?e.test.test(t):e.type=="transform"?e.from===t||r.input.slice(r.ip,r.ip+e.to.length).join("")===e.to:e.type=="repeat"?n.#n(e.children,t,r):!1}static#n(e,t,r,i){for(let l of e){if(l.type=="literal"){if(!i&&l.char===t)return!0;continue}if(l.type=="optional"||l.type=="repeat"&&l.min==0){if(n.#n(l.children,t,r,i))return!0;continue}return n.#O(l,t,r)}return i?e.some(l=>l.type=="literal"&&l.char===t):!1}static#a(e,t,r,i="char",l=null){e.units.push({kind:i,ordinal:l,stream_start:e.stream.length,stream_end:e.stream.length+t.length,fmt_start:e.formatted.length,fmt_end:e.formatted.length+r.length}),e.stream+=t,i=="char"&&(e.raw+=t),l!=null&&(e.cells[l]=i=="char"?t:null),e.formatted+=r}static#s(e){e.stop_fmt<0&&(e.stop_fmt=e.formatted.length+e.tail.length)}static#i(e,t,r){for(let i=0;i<e.length;i++){let l=e[i];if(l.type=="literal")t.done?t.ph+=l.char:t.ip<t.input.length?t.input[t.ip]===l.char?(t.ip++,t.consumed++,n.#a(t,l.char,l.char,"literal")):t.formatted+=l.char:t.tail+=l.char;else if(l.type=="slot"){let s=t.ordinal++,a=n.#k(r,s);if(t.done){t.ph_slots.push({fmt:t.formatted.length+t.tail.length+t.ph.length,node:l}),t.ph+=a;continue}let o=!1;for(;;){if(t.ip>=t.input.length){t.complete=!1,t.done=!0,n.#s(t),t.ph_slots.push({fmt:t.formatted.length+t.tail.length,node:l}),t.ph+=a;break}let h=t.input[t.ip];if(l.test.test(h)){if(r.before_slot&&!o){let u=r.before_slot(t.ctx?.input,{char:h,slot:s,cells:t.cells,raw:t.raw,node:l});if(u===!1){t.ip++;continue}if(typeof u=="string"&&u!==h){t.input.splice(t.ip,1,...u),o=!0;continue}}n.#a(t,h,h,"char",s)}else if(h===a)t.complete=!1,n.#a(t,h,h,"hole",s);else{t.ip++;continue}t.ip++,t.consumed++;break}}else if(l.type=="transform"){if(t.done){t.ph+=l.to;continue}for(;;){if(t.ip>=t.input.length){t.complete=!1,t.done=!0,n.#s(t),t.ph+=l.to;break}if(t.input.slice(t.ip,t.ip+l.to.length).join("")===l.to)t.ip+=l.to.length,t.consumed+=l.to.length;else if(t.input[t.ip]===l.from)t.ip++,t.consumed++;else{t.ip++;continue}n.#a(t,l.to,l.to);break}}else if(l.type=="repeat"){if(t.done){for(let a=0;a<l.min;a++)n.#i(l.children,t,r);continue}let s=0;for(;s<l.max;){if(t.ip>=t.input.length){if(s<l.min){t.complete=!1,t.done=!0,n.#s(t);for(let o=s;o<l.min;o++)n.#i(l.children,t,r)}else n.#s(t);break}if(!n.#n(l.children,t.input[t.ip],t)){if(!l.greedy&&s>=l.min)break;t.ip++;continue}let a=t.ip;if(n.#i(l.children,t,r),t.done){for(let o=s+1;o<l.min;o++)n.#i(l.children,t,r);break}if(t.ip===a)break;s++}}else if(l.type=="optional"){if(t.done)continue;let s=e.slice(i+1),a=!1;for(;t.ip<t.input.length;){let o=t.input[t.ip];if(n.#n(l.children,o,t,!0)){a=!0,n.#i(l.children,t,r);break}if(n.#n(s,o,t))break;t.ip++}!a&&t.ip>=t.input.length&&n.#s(t)}}}static run(e,t,r){let i={input:n.#v(e,t,r),ctx:r,ip:0,stream:"",raw:"",formatted:"",tail:"",ph:"",ph_slots:[],units:[],cells:[],consumed:0,ordinal:0,complete:!0,done:!1,stop_fmt:-1};return n.#i(e.nodes,i,e),i.stop_fmt<0&&(i.stop_fmt=i.formatted.length),e.valid&&(i.complete=i.complete&&e.valid.test(i.raw)),{stream:i.stream,raw:i.raw,formatted:i.formatted,tail:i.tail,ph:i.ph,ph_slots:i.ph_slots,complete:i.complete,consumed:i.consumed,units:i.units,cells:i.cells,stop_fmt:i.stop_fmt}}static run_all(e,t,r={}){let i=[];r={...r,stream:String(t??"")};for(let s of e)s.fn?i.push(...n.build(s.fn(r),s.base).map(a=>({...a,key:s.key??a.key}))):i.push(s);let l=null;for(let s of i){let a=n.run(s,t,r);(!l||a.consumed>l.result.consumed||a.consumed==l.result.consumed&&a.complete&&!l.result.complete)&&(l={result:a,def:s,mask_id:s.key})}return l}static render(e,t){return t=="always"?e.formatted+e.tail+e.ph:t===!1?e.formatted:e.formatted+e.tail}static caret_for(e,t){for(let r of e.units)if(r.kind!="literal"&&(t<=r.stream_start||t<r.stream_end))return r.fmt_start;return e.stop_fmt}static#x(e){let t=n.run(e,""),r=0;return t.slots=t.ph_slots,t.parts=t.slots.map((i,l)=>l&&i.fmt>t.slots[l-1].fmt+1?++r:r),t.template=n.render(t,"always"),t}#e={};#E={};#f=null;#t=new WeakMap;#r=[];static find=$;get params(){return this.#e}get value(){return this.#r.map(e=>e.value)}clone(e){return new n({...this.#e,...this.#E,...e,parent:this})}constructor(e){e={target:"input[mask]",mask:null,filler:"_",placeholder:!0,flow:!0,rewrite:!1,caret:!0,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:()=>{},...e};for(let[t,r]of Object.entries(e))typeof r=="function"&&!n.#L.includes(t)?(this[t]=r.bind(this),this.#E[t]=r):this.#e[t]=r;this.before_init(this.#e),this.#e.mask!=null&&(this.#f=n.build(this.#e.mask,this.#h()));for(let t of E(this.#e.target))this.#$(t);this.on_init(this.#e)}raw(e=this.#u()){return this.#t.get(S(e))?.result?.raw??""}state(e=this.#u()){let t=S(e),r=this.#t.get(t);return r?.result?this.#p(t,r):null}set(e,t){arguments.length<2&&([e,t]=[this.#u(),e]);for(let r of E(e))this.#t.has(r)&&this.#l(r,String(t??""),{prefix:String(t??"")})}clear(e=this.#r){this.set(e,"")}#u(){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 r=n.build(e,this.#h());t||(this.#f=r);for(let i of t?E(t):this.#r){let l=this.#t.get(i);l&&(l.defs=r,l.run=null,this.#l(i,l.stream,{}))}}#h(){return{filler:this.#e.filler,before_char:this.before_char,before_slot:this.before_slot}}#$(e){if($(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");I(e,this),n.#A.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 t=this.#f??(e.getAttribute("mask")?n.build(e.getAttribute("mask"),this.#h()):null);if(!t){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 r={defs:t,def:null,stream:"",result:null,mask_id:null,rendered:"",run:null,composing:!1,handled:!1};this.#t.set(e,r),this.#r.push(e),C(e,{raw:()=>this.raw(e),state:()=>this.state(e),set:s=>this.set(e,s),clear:()=>this.clear(e),set_mask:s=>this.set_mask(s,e)});let i=()=>this.#e.caret=="hide"&&e.style.setProperty("caret-color","transparent","important");if(i(),e.addEventListener("beforeinput",s=>this.#j(e,s)),this.#e.caret!==!0){let s=()=>this.#I(e);for(let a of["selectionchange","click","keyup","select"])e.addEventListener(a,s)}let l=()=>{if(r.handled){r.handled=!1;return}r.composing||this.#d(e)};e.addEventListener("input",l),e.addEventListener("change",l),e.addEventListener("compositionstart",()=>r.composing=!0),e.addEventListener("compositionend",()=>{r.composing=!1,this.#d(e)}),e.addEventListener("focus",()=>{i(),this.#l(e,r.stream,{prefix:r.stream,silent:!0})}),e.addEventListener("blur",()=>{r.run=null,this.#l(e,r.stream,{silent:!0})}),e.closest("form")?.addEventListener("reset",()=>queueMicrotask(()=>this.#d(e))),this.#l(e,e.value,{silent:!0})}#j(e,t){let r=this.#t.get(e),i=t.inputType??"insertText";if(t.isComposing||i=="insertCompositionText"||i=="deleteCompositionText"){r.composing=!0;return}if(i=="historyUndo"||i=="historyRedo")return;let l=e.selectionStart??0,s=e.selectionEnd??l;this.#e.caret!==!0&&r.result&&!(l==0&&s==e.value.length)&&(l=s=this.#_(e,r,l)),t.preventDefault(),r.handled=!0;let a=i.startsWith("delete"),o="";if(!a){if(i=="insertLineBreak"||i=="insertParagraph")return;if(o=t.data??t.dataTransfer?.getData("text/plain")??"",i=="insertFromPaste"){let h=this.before_paste(e,o);if(h===!1)return;typeof h=="string"&&(o=h)}}this.before_input(e,{type:i,insert:o,start:l,end:s})!==!1&&(this.#e.placeholder=="always"&&r.def?.fixed?this.#T(e,i,l,s,a?"":o):this.#R(e,l,s,a?"":o,i),i=="insertFromPaste"&&this.on_paste(e,this.#p(e,r)))}#R(e,t,r,i,l){let s=this.#t.get(e),a=s.result?.units??[],o,h,u;if(t!=r){let p=a.filter(y=>y.fmt_start<r&&y.fmt_end>t);o=p.length?p[0].stream_start:this.#S(a,t),h=p.length?p.at(-1).stream_end:o}else if(!l.startsWith("delete"))o=h=this.#S(a,t);else{if(l.includes("Forward"))u=a.find(p=>p.fmt_end>t&&p.kind!="literal")??a.find(p=>p.fmt_end>t);else{let p;for(let y of a)y.fmt_start<t&&(y.kind=="literal"?p=y:u=y);u??=p}if(!u)return;o=u.stream_start,h=u.stream_end}let d=s.stream.slice(0,o)+i;this.#l(e,d+s.stream.slice(h),{prefix:d})}#T(e,t,r,i,l){let s=this.#t.get(e),a=s.def,o=a.layout??=n.#x(a),h=o.slots,u=o.parts,d=h.length,p=this.#e.flow,y=this.#e.rewrite,g=Array.from({length:d},(c,m)=>s.result?.cells?.[m]??null),_=c=>{let m=h.findIndex(M=>M.fmt>=c);return m<0?d:m},j=c=>o.template.slice(h[c-1].fmt+1,h[c].fmt),f,b=null,w=null;if(r!=i){f=_(r);for(let c=f;c<d&&h[c].fmt<i;c++)g[c]=null;s.run=null}else if(!l&&t.startsWith("delete")){if(t.includes("Forward")){if((f=_(r))>=d)return;let c=u[f];for(;f<d&&g[f]==null;)f++;if(f>=d||!p&&u[f]!=c)return}else{let c=-1;for(let m=0;m<d;m++)h[m].fmt<r&&(c=m);if(c<0)return;for(f=c;f>=0&&g[f]==null;)f--;if(f<0||!p&&(u[f]!=u[c]||r>h[c].fmt+1))return}g[f]=null}else if(f=_(r),f>=d&&(f=g.indexOf(null))<0&&(f=d),b=this.#c(o,f,r),y){let c=b??u[Math.min(f,d-1)];(s.run?.part!==c||s.run.k!==f||u[f]!==c)&&(w=c)}b??=f<d?u[f]:null;let v=null;for(let c of n.#v(a,l,{input:e})){if(f>=d){if(w==null)break;f=u.indexOf(w)}if(!p&&u[f]!=b){if(j(f).includes(c)){b=u[f],v=f,w=y?u[f]:null;continue}if(w==null)continue;f=u.indexOf(w)}if(!h[f].node.test.test(c)){let m=u.lastIndexOf(u[f]);m+1<d&&j(m+1).includes(c)&&(f=m+1,b=u[f],v=f,w=y?u[f]:null);continue}if(w!=null){for(let m=0;m<d;m++)u[m]==w&&(g[m]=null);f=u.indexOf(w),b=w,w=null}g[f++]=c}let F=g.reduce((c,m,M)=>m!=null?M:c,-1),R=g.slice(0,F+1).map((c,m)=>c??n.#k(a,m)).join(""),k=Math.min(n.run(a,R.slice(0,f),{input:e}).stream.length,d),x=k<d?h[k].fmt:h[d-1].fmt+1;!p&&l&&k>0&&k<d&&u[k]!=u[k-1]&&(x=h[k-1].fmt+1),v!=null&&f==v&&(x=h[v].fmt);let A=_(x);s.run=v!=null?null:{part:this.#c(o,A,x)??u[Math.min(A,d-1)],k:A},this.#l(e,R,{caret_fmt:x})}#I(e){let t=this.#t.get(e);if(document.activeElement!==e||!t?.result)return;let r=e.selectionStart,i=e.selectionEnd;if(r==null)return;if(r!==i){(r!=0||i!=e.value.length)&&e.setSelectionRange(0,e.value.length);return}if(r===t.caret)return;let l=this.#_(e,t,r);r!==l&&e.setSelectionRange(l,l),t.caret=l}#_(e,t,r){let i=t.def;if(this.#e.placeholder=="always"&&i?.fixed&&!this.#e.flow){let l=i.layout??=n.#x(i),{slots:s,parts:a}=l,o=s.findIndex(p=>p.fmt>=r);o<0&&(o=s.length-1);let h=this.#c(l,o,r)??a[o],u=a.indexOf(h),d=a.lastIndexOf(h);for(let p=u;p<=d;p++)if(t.result.cells?.[p]==null)return s[p].fmt;return s[d].fmt+1}return Math.min(t.result.stop_fmt,e.value.length)}#c(e,t,r){let{slots:i,parts:l}=e;return!this.#e.flow&&t>0&&t<i.length&&l[t]!=l[t-1]&&r==i[t-1].fmt+1?l[t-1]:null}#S(e,t){let r=0;for(let i of e)(i.fmt_end<=t||i.fmt_start<t)&&(r=i.stream_end);return r}#d(e){let t=this.#t.get(e);if(e.value===t.rendered)return;t.run=null;let r=e.selectionStart??e.value.length;this.#l(e,e.value,{prefix:e.value.slice(0,r)})}#l(e,t,{prefix:r=null,caret_fmt:i=null,silent:l=!1}={}){let s=this.#t.get(e),a=n.run_all(s.defs,t,{raw:s.result?.raw??"",value:e.value,input:e});if(!a)return;let{result:o,def:h,mask_id:u}=a,d=this.#C(e,o);e.value!==d&&(e.value=d),s.rendered=d,i==null&&r!=null&&document.activeElement===e&&(i=n.caret_for(o,n.run(h,r,{input:e}).stream.length)),i!=null&&document.activeElement===e&&(i=Math.min(i,d.length),e.setSelectionRange(i,i),s.caret=i);let p=s.result,y=s.mask_id;if(s.result=o,s.stream=o.stream,s.def=h,s.mask_id=u,e.setAttribute("mask_id",u),e.setAttribute("progress",o.raw.length),e.setAttribute("is_complete",o.complete),l)return;let g=this.#p(e,s);this.on_input(e,g),o.raw!==(p?.raw??"")&&this.on_accept(e,g),o.complete&&!p?.complete&&this.on_complete(e,g),!o.complete&&p?.complete&&this.on_incomplete(e,g),p&&u!==y&&this.on_mask_change(e,g)}#C(e,t){return t.stream?n.render(t,this.#e.placeholder):document.activeElement!==e?"":this.#e.placeholder=="always"?n.render(t,"always"):this.#e.placeholder==!1?"":n.render(t,!0)}#p(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}}};return N(H);})();
1
+ var Mask=(()=>{var q=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var ne=Object.prototype.hasOwnProperty;var se=(i,e)=>{for(var t in e)q(i,t,{get:e[t],enumerable:!0})},ae=(i,e,t,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ie(e))!ne.call(i,r)&&r!==t&&q(i,r,{get:()=>e[r],enumerable:!(l=re(e,r))||l.enumerable});return i};var fe=i=>ae(q({},"__esModule",{value:!0}),i);var de={};se(de,{default:()=>I});var K=Symbol(),oe=Symbol(),T=i=>{try{return i instanceof Element?i:document.querySelector(i)}catch{return}},M=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(M);try{return[...document.querySelectorAll(i)]}catch{return[]}},B=i=>T(i)?.[K],U=(i,e)=>(i&&(i[K]=e),i),J=(i,e)=>{if(!i)return i;let t=i[oe]??=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 Q={0:/^[0-9]$/,a:/^\p{L}$/u,"*":/^[^\n]$/},X=i=>i.replace(/\\(.)/g,"$1"),Y=i=>i.global?new RegExp(i.source,i.flags.replace("g","")):i;function N(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=N(i,n))<0)return-1}else if(s==t)r++;else if(s==l&&--r==0)return n}return-1}function Z(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 ue(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(r=>({type:"literal",char:r}))),t=Z(i,";");if(t>0){let r=i.slice(t+1);if(/^(\d+|\d*-\d*)$/.test(r)&&r!="-"){let[n,s]=/^\d+$/.test(r)?[+r,+r]:r.split("-").map((a,f)=>a===""?f?1/0:0:+a);return s<n?e():[{type:"repeat",children:z(i.slice(0,t)),min:n,max:s}]}}if(i[0]=="{"&&i.at(-1)=="}")try{return[{type:"slot",test:new RegExp(`^(?:${i.slice(1,-1)})$`,"u")}]}catch{return e()}let l=Z(i,"=>");if(l>0){let r=X(i.slice(0,l)),n=X(i.slice(l+2));return r.length!=1||!n?e():[{type:"transform",from:r,to:n}]}return e()}function z(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=N(i,t))>=0?(e.push({type:"optional",children:z(i.slice(t+1,r))}),t=r):l=="{"&&(r=N(i,t))>=0?(e.push(...ue(i.slice(t+1,r))),t=r):e.push(Q[l]?{type:"slot",test:Q[l]}:{type:"literal",char:l})}return e}function ee(i){return i.every(e=>e.type=="literal"||e.type=="slot"||e.type=="repeat"&&e.min==e.max&&ee(e.children))}function E(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])=>E(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 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 r=l.pattern!=null?z(l.pattern):[{type:"repeat",min:0,max:l.max_length??1/0,greedy:!0,children:[{type:"slot",test:Y(l.filter)}]}];return{nodes:r,fixed:l.pattern!=null&&ee(r),valid:l.valid?Y(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 j(i,e){let t=i.filler??"_";return t[e]??t.at(-1)??"_"}function G(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 ce(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"?O(i.children,e,t):!1}function O(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(O(r.children,e,t,l))return!0;continue}return ce(r,e,t)}return l?i.some(r=>r.type=="literal"&&r.char===e):!1}function F(i,e,t,l="char",r=null){i.units.push({kind:l,ordinal:r,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),r!=null&&(i.cells[r]=l=="char"?e:null),i.formatted+=t}function V(i){i.stop_fmt<0&&(i.stop_fmt=i.formatted.length+i.tail.length)}function D(i){i.complete=!1,i.done=!0,V(i)}function $(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++,F(e,r.char,r.char,"literal")):e.formatted+=r.char:e.tail+=r.char;else if(r.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:r}),e.ph+=s;continue}let a=!1;for(;;){if(e.ip>=e.input.length){D(e),e.ph_slots.push({fmt:e.formatted.length+e.tail.length,node:r}),e.ph+=s;break}let f=e.input[e.ip];if(r.test.test(f)){if(t.before_slot&&!a){let o=t.before_slot(e.ctx?.input,{char:f,slot:n,cells:e.cells,raw:e.raw,node:r});if(o===!1){e.ip++;continue}if(typeof o=="string"&&o!==f){e.input.splice(e.ip,1,...o),a=!0;continue}}F(e,f,f,"char",n)}else if(f===s)e.complete=!1,F(e,f,f,"hole",n);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){D(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}F(e,r.to,r.to);break}}else if(r.type=="repeat"){if(e.done){for(let s=0;s<r.min;s++)$(r.children,e,t);continue}let n=0;for(;n<r.max;){if(e.ip>=e.input.length){if(n<r.min){D(e);for(let a=n;a<r.min;a++)$(r.children,e,t)}else V(e);break}if(!O(r.children,e.input[e.ip],e)){if(!r.greedy&&n>=r.min)break;e.ip++;continue}let s=e.ip;if($(r.children,e,t),e.done){for(let a=n+1;a<r.min;a++)$(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(O(r.children,a,e,!0)){s=!0,$(r.children,e,t);break}if(O(n,a,e))break;e.ip++}!s&&e.ip>=e.input.length&&V(e)}}}function he(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=L=>L.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),A=l.replace(new RegExp(`[^0-9${p(t.decimal)}.]`,"g"),"").replace(t.decimal,"."),b=parseFloat(A);n=Number.isFinite(b)?String(Math.round(b*10**t.fraction)):""}else{let p=l.replace(/\D/g,"");n=p===""?"":p.replace(/^0+/,"")||"0"}if(!n){let p=t.prefix+j(i,0);if(t.fraction){p+=t.decimal;for(let A=1;A<=t.fraction;A++)p+=j(i,A)}return{stream:"",raw:"",formatted:"",tail:"",ph:p+t.suffix,ph_slots:[],complete:!1,consumed:0,units:[],cells:[],stop_fmt:p.length}}let s=t.fraction,a=n.padStart(s+1,"0"),f=(s?a.slice(0,-s):a).replace(/^0+(?=\d)/,""),o=s?a.slice(-s):"",u=f.length+o.length-n.length,h=(r?"-":"")+n,m="",_=[],y=0,w=0,v=p=>{m+=p},c=p=>{_.push({kind:"char",ordinal:null,stream_start:y,stream_end:y+1,fmt_start:m.length,fmt_end:m.length+1}),m+=p,y++};v(t.prefix),r&&c("-");for(let p=0;p<f.length;p++,w++)p&&(f.length-p)%3==0&&v(t.group),w>=u?c(f[p]):v(f[p]);if(s){v(t.decimal);for(let p=0;p<o.length;p++,w++)w>=u?c(o[p]):v(o[p])}let k=m.length;v(t.suffix);let x=(r?-1:1)*parseFloat(f+(s?"."+o:"")),S=(t.min==null||x>=t.min)&&(t.max==null||x<=t.max);return{stream:h,raw:h,formatted:m,tail:"",ph:"",ph_slots:[],complete:S,consumed:h.length,units:_,cells:[],stop_fmt:k}}function C(i,e,t){if(i.numeral)return he(i,e);let l={input:G(i,e,t),ctx:t,ip:0,stream:"",raw:"",formatted:"",tail:"",ph:"",ph_slots:[],units:[],cells:[],consumed:0,ordinal:0,complete:!0,done:!1,stop_fmt:-1};return $(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,units:l.units,cells:l.cells,stop_fmt:l.stop_fmt}}function H(i,e,t={}){let l=[];t={...t,stream:String(e??"")};for(let n of i)n.fn?l.push(...E(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=C(n,e,t);(!r||s.consumed>r.result.consumed||s.consumed==r.result.consumed&&s.complete&&!r.result.complete)&&(r={result:s,def:n,mask_id:n.key})}return r}function R(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 me=["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#d=["target","mask"];static#p=["text","search","tel","url","password"];static#u(e){let t=C(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=R(t,"always"),t}#e={};#c={};#n=null;#t=new WeakMap;#r=[];static find=B;get params(){return this.#e}get value(){return this.#r.map(e=>e.value)}clone(e){return new i({...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(me.map(t=>[t,()=>{}])),...e};for(let[t,l]of Object.entries(e))typeof l=="function"&&!i.#d.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 M(this.#e.target))this.#_(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 M(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 r of t?M(t):this.#r){let n=this.#t.get(r);n&&(n.defs=l,n.run=null,this.#l(r,n.stream,{}))}}#i(){return{filler:this.#e.filler,before_char:this.before_char,before_slot:this.before_slot}}#g(e){return e=="email"?E({filter:/[a-z0-9@._%+-]/i,valid:/^[^@\s]+@[^@\s]+\.[^@\s]{2,}$/},this.#i()):e=="number"?E({numeral:{}},this.#i()):null}#_(e){if(B(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");U(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.#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 r=this.#e.max_raw??(l!=null?+l:null),n=this.#n??(e.getAttribute("mask")?E(e.getAttribute("mask"),this.#i()):this.#g(t));if(!n){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 s=t=="number"||this.#e.numeral!=null,a={defs:n,def:null,stream:"",result:null,mask_id:null,rendered:"",run:null,composing:!1,handled:!1,coerced:t,max_raw:r,numeric:s};this.#t.set(e,a),this.#r.push(e),J(e,{raw:()=>this.raw(e),state:()=>this.state(e),set:u=>this.set(e,u),clear:()=>this.clear(e),set_mask:u=>this.set_mask(u,e)});let f=()=>this.#e.caret=="hide"&&e.style.setProperty("caret-color","transparent","important");if(f(),e.addEventListener("beforeinput",u=>this.#y(e,u)),this.#e.caret!==!0){let u=()=>this.#b(e);for(let h of["selectionchange","click","keyup","select"])e.addEventListener(h,u)}let o=()=>{if(a.handled){a.handled=!1;return}a.composing||this.#o(e)};e.addEventListener("input",o),e.addEventListener("change",o),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})}#y(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;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 a=r.startsWith("delete"),f="";if(!a){if(r=="insertLineBreak"||r=="insertParagraph")return;if(f=t.data??t.dataTransfer?.getData("text/plain")??"",r=="insertFromPaste"){let u=this.before_paste(e,f);if(u===!1)return;typeof u=="string"&&(f=u)}if(l.numeric){let u=l.defs.some(h=>h.numeral?.sign);f=[...f].filter(h=>h>="0"&&h<="9"||u&&h=="-").join("")}}if(this.before_input(e,{type:r,insert:f,start:n,end:s})===!1)return;let o=e.value;this.#e.placeholder=="always"&&l.def?.fixed?this.#x(e,r,n,s,a?"":f):this.#w(e,n,s,a?"":f,r),r=="insertFromPaste"&&this.on_paste(e,this.#s(e,l)),t.defaultPrevented&&e.value!==o&&e.dispatchEvent(new InputEvent("input",{bubbles:!0,inputType:r,data:f||null}))}#w(e,t,l,r,n){let s=this.#t.get(e),a=s.result?.units??[],f,o,u;if(t!=l){let m=a.filter(_=>_.fmt_start<l&&_.fmt_end>t);f=m.length?m[0].stream_start:this.#m(a,t),o=m.length?m.at(-1).stream_end:f}else if(!n.startsWith("delete"))f=o=this.#m(a,t);else{if(n.includes("Forward"))u=a.find(m=>m.fmt_end>t&&m.kind!="literal")??a.find(m=>m.fmt_end>t);else{let m;for(let _ of a)_.fmt_start<t&&(_.kind=="literal"?m=_:u=_);u??=m}if(!u)return;f=u.stream_start,o=u.stream_end}let h=s.stream.slice(0,f)+r;this.#l(e,h+s.stream.slice(o),{prefix:h})}#x(e,t,l,r,n){let s=this.#t.get(e),a=s.def,f=a.layout??=i.#u(a),o=f.slots,u=f.parts,h=o.length,m=this.#e.flow,_=this.#e.rewrite,y=Array.from({length:h},(d,g)=>s.result?.cells?.[g]??null),w=d=>{let g=o.findIndex(W=>W.fmt>=d);return g<0?h:g},v=d=>f.template.slice(o[d-1].fmt+1,o[d].fmt),c,k=null,x=null;if(l!=r){c=w(l);for(let d=c;d<h&&o[d].fmt<r;d++)y[d]=null;s.run=null}else if(!n&&t.startsWith("delete")){if(t.includes("Forward")){if((c=w(l))>=h)return;let d=u[c];for(;c<h&&y[c]==null;)c++;if(c>=h||!m&&u[c]!=d)return}else{let d=-1;for(let g=0;g<h;g++)o[g].fmt<l&&(d=g);if(d<0)return;for(c=d;c>=0&&y[c]==null;)c--;if(c<0||!m&&(u[c]!=u[d]||l>o[d].fmt+1))return}y[c]=null}else if(c=w(l),c>=h&&(c=y.indexOf(null))<0&&(c=h),k=this.#f(f,c,l),_){let d=k??u[Math.min(c,h-1)];(s.run?.part!==d||s.run.k!==c||u[c]!==d)&&(x=d)}k??=c<h?u[c]:null;let S=null;for(let d of G(a,n,{input:e})){if(c>=h){if(x==null)break;c=u.indexOf(x)}if(!m&&u[c]!=k){if(v(c).includes(d)){k=u[c],S=c,x=_?u[c]:null;continue}if(x==null)continue;c=u.indexOf(x)}if(!o[c].node.test.test(d)){let g=u.lastIndexOf(u[c]);g+1<h&&v(g+1).includes(d)&&(c=g+1,k=u[c],S=c,x=_?u[c]:null);continue}if(x!=null){for(let g=0;g<h;g++)u[g]==x&&(y[g]=null);c=u.indexOf(x),k=x,x=null}y[c++]=d}let p=y.reduce((d,g,W)=>g!=null?W:d,-1),A=y.slice(0,p+1).map((d,g)=>d??j(a,g)).join(""),b=Math.min(C(a,A.slice(0,c),{input:e}).stream.length,h),L=b<h?o[b].fmt:o[h-1].fmt+1;!m&&n&&b>0&&b<h&&u[b]!=u[b-1]&&(L=o[b-1].fmt+1),S!=null&&c==S&&(L=o[S].fmt);let P=w(L);s.run=S!=null?null:{part:this.#f(f,P,L)??u[Math.min(P,h-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,r=e.selectionEnd;if(l==null)return;if(l!==r){(l!=0||r!=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 r=t.def;if(this.#e.placeholder=="always"&&r?.fixed&&!this.#e.flow){let n=r.layout??=i.#u(r),{slots:s,parts:a}=n,f=s.findIndex(m=>m.fmt>=l);f<0&&(f=s.length-1);let o=this.#f(n,f,l)??a[f],u=a.indexOf(o),h=a.lastIndexOf(o);for(let m=u;m<=h;m++)if(t.result.cells?.[m]==null)return s[m].fmt;return s[h].fmt+1}return Math.min(t.result.stop_fmt,e.value.length)}#f(e,t,l){let{slots:r,parts:n}=e;return!this.#e.flow&&t>0&&t<r.length&&n[t]!=n[t-1]&&l==r[t-1].fmt+1?n[t-1]:null}#m(e,t){let l=0;for(let r of e)(r.fmt_end<=t||r.fmt_start<t)&&(l=r.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:r=null,silent:n=!1}={}){let s=this.#t.get(e),a={raw:s.result?.raw??"",value:e.value,input:e},f=H(s.defs,t,a);if(!f)return;let{result:o,def:u,mask_id:h}=f;s.max_raw!=null&&o.raw.length>s.max_raw&&(f=H(s.defs,o.stream.slice(0,le(o,s.max_raw)),a),{result:o,def:u,mask_id:h}=f);let m=this.#v(e,o);e.value!==m&&(e.value=m),s.rendered=m,r==null&&l!=null&&document.activeElement===e&&(r=te(o,C(u,l,{input:e}).stream.length)),r!=null&&document.activeElement===e&&(r=Math.min(r,m.length),e.setSelectionRange(r,r),s.caret=r);let _=s.result,y=s.mask_id;if(s.result=o,s.stream=o.stream,s.def=u,s.mask_id=h,e.setAttribute("mask_id",h),e.setAttribute("progress",o.raw.length),e.setAttribute("is_complete",o.complete),this.#k(s)&&e.setCustomValidity&&e.setCustomValidity(!o.stream||o.complete?"":this.#E(e,s)),n)return;let w=this.#s(e,s);this.on_input(e,w),o.raw!==(_?.raw??"")&&this.on_accept(e,w),o.complete&&!_?.complete&&this.on_complete(e,w),!o.complete&&_?.complete&&this.on_incomplete(e,w),_&&h!==y&&this.on_mask_change(e,w)}#v(e,t){return t.stream?R(t,this.#e.placeholder):document.activeElement!==e?"":this.#e.placeholder=="always"?R(t,"always"):this.#e.placeholder==!1?"":R(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}}#k(e){let t=this.#e.validate;return t===!0||t==null&&e.coerced!=null}#E(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 fe(de);})();
2
2
  if(typeof Mask!=="undefined"&&Mask&&Mask.default)globalThis.Mask=Mask.default;
@@ -1 +1 @@
1
- var u=Symbol(),m=Symbol(),c=i=>{try{return i instanceof Element?i:document.querySelector(i)}catch{return}};var f=i=>c(i)?.[u],r=(i,n)=>(i&&(i[u]=n),i);var a=class i{modal;overlay;area;container;content;#t={};#i={};#e="hidden";static find=f;get state(){return this.#e}get params(){return this.#t}clone(n){let o=this.content.cloneNode(!0);return o.id=n.id??(o.id||"modal").replace(/#+$/,"")+(n.suffix??"_copy"),new i({...this.#t,...this.#i,content:o,...n,parent:this})}constructor(n){n={zIndex:1e3,duration:0,container:"body",overlay:!0,overlay_shading:.5,overlay_blur:"5px",overlay_scroll_lock:!0,content:"<div></div>",location:"center center",trigger:null,close_by_overlay:!0,close_by_esc:!0,auto_close:-1,allow_interrupt:!1,before_show:()=>{},on_show:()=>{},before_hide:()=>{},on_hide:()=>{},before_init:()=>{},on_init:()=>{},...n};let o,e,h;for(let[t,l]of Object.entries(n))typeof l=="function"?(this[t]=l.bind(this),this.#i[t]=l):this.#t[t]=l;this.before_init(this.#t),this.modal=document.createElement("modal"),r(this.modal,this),Object.assign(this.modal.style,{position:"fixed",top:"0",left:"0",right:"0",bottom:"0",zIndex:this.#t.zIndex,transition:`all ${this.#t.duration}s`,pointerEvents:"none",display:"none",overflow:"hidden"}),this.modal.setAttribute("state","hidden");try{c(this.#t.container).append(this.modal)}catch{throw new Error("\u041D\u0435\u0443\u0434\u0430\u0447\u043D\u0430\u044F \u043F\u043E\u043F\u044B\u0442\u043A\u0430 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u043C\u043E\u0434\u0430\u043B\u044C\u043D\u043E\u0435 \u043E\u043A\u043D\u043E \u0432 \u0443\u043A\u0430\u0437\u0430\u043D\u043D\u044B\u0439 \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440")}this.#t.overlay&&(this.overlay=document.createElement("modal-overlay"),r(this.overlay,this),Object.assign(this.overlay.style,{position:"absolute",top:"0",left:"0",right:"0",bottom:"0",backgroundColor:`rgba(0, 0, 0, ${this.#t.overlay_shading})`,backdropFilter:`blur(${this.#t.overlay_blur})`,zIndex:++this.#t.zIndex,transition:"inherit"}),this.modal.append(this.overlay));let s=(this.#t.location||"").toLowerCase().split(/\s+/);this.area=document.createElement("modal-area"),r(this.area,this),Object.assign(this.area.style,{position:"absolute",top:"0",left:"0",right:"0",bottom:"0",overflowY:"auto",overflowX:"clip",display:"flex",alignItems:"flex-start",justifyContent:s.includes("left")?"flex-start":s.includes("right")?"flex-end":"center",zIndex:++this.#t.zIndex,pointerEvents:"all",transition:"inherit"}),this.modal.append(this.area),this.#t.close_by_overlay&&this.area.addEventListener("click",t=>{this.container.contains(t.target)||this.hide(t)}),this.container=document.createElement("modal-container"),r(this.container,this),Object.assign(this.container.style,{position:"relative",flexShrink:"0",width:"max-content",height:"max-content",maxWidth:"100vw",zIndex:++this.#t.zIndex,transition:"inherit",pointerEvents:"all",marginTop:s.includes("top")?"0":"auto",marginBottom:s.includes("bottom")?"0":"auto",marginLeft:s.includes("left")?"0":"auto",marginRight:s.includes("right")?"0":"auto"}),this.area.append(this.container);try{this.content=c(this.#t.content)??new DOMParser().parseFromString(this.#t.content,"text/html").body.firstElementChild}catch{throw new Error("\u041D\u0435\u0443\u0434\u0430\u0447\u043D\u0430\u044F \u043F\u043E\u043F\u044B\u0442\u043A\u0430 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u043F\u0435\u0440\u0435\u0434\u0430\u043D\u043D\u044B\u0439 \u043A\u043E\u043D\u0442\u0435\u043D\u0442 \u0432 \u043C\u043E\u0434\u0430\u043B\u044C\u043D\u043E\u0435 \u043E\u043A\u043D\u043E")}this.container.append(this.content),r(this.content,this),this.content.style.transition="inherit",this.content.querySelectorAll('[action="close"]').forEach(t=>{t.addEventListener("click",()=>this.hide())});let d=t=>{t.before_func(t.data),clearTimeout(o),this.modal.style.display="flex",requestAnimationFrame(()=>{this.#e=t.process,this.modal.setAttribute("state",this.#e),requestAnimationFrame(()=>{o=setTimeout(()=>{this.#e=t.final,this.modal.setAttribute("state",this.#e),t.hide&&(this.modal.style.display="none"),t.after_func(t.data)},this.#t.duration*1e3)})})};this.show=(t=null)=>{(this.#e=="hidden"||this.#t.allow_interrupt&&this.#e=="hiding")&&(d({before_func:this.before_show,after_func:this.on_show,process:"showing",final:"shown",hide:!1,data:t}),this.#t.overlay_scroll_lock&&this.overlay&&(h=document.documentElement.style.scrollBehavior,e=document.body.style,e={position:e.position,top:e.top,left:e.left,width:e.width,scroll_Y:window.scrollY||document.documentElement.scrollTop,scroll_X:window.scrollX||document.documentElement.scrollLeft},document.documentElement.style.scrollBehavior="unset",Object.assign(document.body.style,{position:"fixed",width:"100vw",top:`-${e.scroll_Y}px`,left:`-${e.scroll_X}px`})),this.#t.auto_close>0&&(clearTimeout(o),o=setTimeout(()=>{this.hide()},this.#t.auto_close*1e3)))},this.hide=(t=null)=>{(this.#e=="shown"||this.#t.allow_interrupt&&this.#e=="showing")&&(d({before_func:this.before_hide,after_func:this.on_hide,process:"hiding",final:"hidden",hide:!0,data:t}),clearTimeout(o),o=setTimeout(()=>{e&&(Object.assign(document.body.style,e),window.scrollTo(e.scroll_X,e.scroll_Y)),h!=null&&(document.documentElement.style.scrollBehavior=h)},this.#t.duration*1e3))},this.#t.close_by_esc&&document.addEventListener("keydown",t=>{(t.code==="Escape"||t.keyCode===27)&&this.hide(t)}),this.#t.trigger&&document.querySelectorAll(this.#t.trigger).forEach(t=>{t.addEventListener("click",()=>this.show(t))}),this.on_init(this.#t)}};export{a as default};
1
+ var u=Symbol(),m=Symbol(),c=i=>{try{return i instanceof Element?i:document.querySelector(i)}catch{return}};var f=i=>c(i)?.[u],l=(i,n)=>(i&&(i[u]=n),i);var a=class i{modal;overlay;area;container;content;#t={};#i={};#e="hidden";static find=f;get state(){return this.#e}get params(){return this.#t}clone(n){let o=this.content.cloneNode(!0);return o.id=n.id??(o.id||"modal").replace(/#+$/,"")+(n.suffix??"_copy"),new i({...this.#t,...this.#i,content:o,...n,parent:this})}constructor(n){n={zIndex:1e3,duration:0,container:"body",overlay:!0,overlay_shading:.5,overlay_blur:"5px",overlay_scroll_lock:!0,content:"<div></div>",location:"center center",fluid:!1,trigger:null,close_by_overlay:!0,close_by_esc:!0,auto_close:-1,allow_interrupt:!1,before_show:()=>{},on_show:()=>{},before_hide:()=>{},on_hide:()=>{},before_init:()=>{},on_init:()=>{},...n};let o,e,h;for(let[t,r]of Object.entries(n))typeof r=="function"?(this[t]=r.bind(this),this.#i[t]=r):this.#t[t]=r;this.before_init(this.#t),this.modal=document.createElement("modal"),l(this.modal,this),Object.assign(this.modal.style,{position:"fixed",top:"0",left:"0",right:"0",bottom:"0",zIndex:this.#t.zIndex,transition:`all ${this.#t.duration}s`,pointerEvents:"none",display:"none",overflow:"hidden"}),this.modal.setAttribute("state","hidden");try{c(this.#t.container).append(this.modal)}catch{throw new Error("\u041D\u0435\u0443\u0434\u0430\u0447\u043D\u0430\u044F \u043F\u043E\u043F\u044B\u0442\u043A\u0430 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u043C\u043E\u0434\u0430\u043B\u044C\u043D\u043E\u0435 \u043E\u043A\u043D\u043E \u0432 \u0443\u043A\u0430\u0437\u0430\u043D\u043D\u044B\u0439 \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440")}this.#t.overlay&&(this.overlay=document.createElement("modal-overlay"),l(this.overlay,this),Object.assign(this.overlay.style,{position:"absolute",top:"0",left:"0",right:"0",bottom:"0",backgroundColor:`rgba(0, 0, 0, ${this.#t.overlay_shading})`,backdropFilter:`blur(${this.#t.overlay_blur})`,zIndex:++this.#t.zIndex,transition:"inherit"}),this.modal.append(this.overlay));let s=(this.#t.location||"").toLowerCase().split(/\s+/);this.area=document.createElement("modal-area"),l(this.area,this),Object.assign(this.area.style,{position:"absolute",top:"0",left:"0",right:"0",bottom:"0",overflowY:"auto",overflowX:"clip",display:"flex",alignItems:"flex-start",justifyContent:s.includes("left")?"flex-start":s.includes("right")?"flex-end":"center",zIndex:++this.#t.zIndex,pointerEvents:"all",transition:"inherit"}),this.modal.append(this.area),this.#t.close_by_overlay&&this.area.addEventListener("click",t=>{this.container.contains(t.target)||this.hide(t)}),this.container=document.createElement("modal-container"),l(this.container,this),Object.assign(this.container.style,{position:"relative",flexShrink:"0",width:this.#t.fluid?"100%":"max-content",height:"max-content",maxWidth:this.#t.fluid?"none":"100vw",zIndex:++this.#t.zIndex,transition:"inherit",pointerEvents:"all",marginTop:s.includes("top")?"0":"auto",marginBottom:s.includes("bottom")?"0":"auto",marginLeft:s.includes("left")?"0":"auto",marginRight:s.includes("right")?"0":"auto"}),this.area.append(this.container);try{this.content=c(this.#t.content)??new DOMParser().parseFromString(this.#t.content,"text/html").body.firstElementChild}catch{throw new Error("\u041D\u0435\u0443\u0434\u0430\u0447\u043D\u0430\u044F \u043F\u043E\u043F\u044B\u0442\u043A\u0430 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u043F\u0435\u0440\u0435\u0434\u0430\u043D\u043D\u044B\u0439 \u043A\u043E\u043D\u0442\u0435\u043D\u0442 \u0432 \u043C\u043E\u0434\u0430\u043B\u044C\u043D\u043E\u0435 \u043E\u043A\u043D\u043E")}this.container.append(this.content),l(this.content,this),this.content.style.transition="inherit",this.content.querySelectorAll('[action="close"]').forEach(t=>{t.addEventListener("click",()=>this.hide())});let d=t=>{t.before_func(t.data),clearTimeout(o),this.modal.style.display="flex",requestAnimationFrame(()=>{this.#e=t.process,this.modal.setAttribute("state",this.#e),requestAnimationFrame(()=>{o=setTimeout(()=>{this.#e=t.final,this.modal.setAttribute("state",this.#e),t.hide&&(this.modal.style.display="none"),t.after_func(t.data)},this.#t.duration*1e3)})})};this.show=(t=null)=>{(this.#e=="hidden"||this.#t.allow_interrupt&&this.#e=="hiding")&&(d({before_func:this.before_show,after_func:this.on_show,process:"showing",final:"shown",hide:!1,data:t}),this.#t.overlay_scroll_lock&&this.overlay&&(h=document.documentElement.style.scrollBehavior,e=document.body.style,e={position:e.position,top:e.top,left:e.left,width:e.width,scroll_Y:window.scrollY||document.documentElement.scrollTop,scroll_X:window.scrollX||document.documentElement.scrollLeft},document.documentElement.style.scrollBehavior="unset",Object.assign(document.body.style,{position:"fixed",width:"100vw",top:`-${e.scroll_Y}px`,left:`-${e.scroll_X}px`})),this.#t.auto_close>0&&(clearTimeout(o),o=setTimeout(()=>{this.hide()},this.#t.auto_close*1e3)))},this.hide=(t=null)=>{(this.#e=="shown"||this.#t.allow_interrupt&&this.#e=="showing")&&(d({before_func:this.before_hide,after_func:this.on_hide,process:"hiding",final:"hidden",hide:!0,data:t}),clearTimeout(o),o=setTimeout(()=>{e&&(Object.assign(document.body.style,e),window.scrollTo(e.scroll_X,e.scroll_Y)),h!=null&&(document.documentElement.style.scrollBehavior=h)},this.#t.duration*1e3))},this.#t.close_by_esc&&document.addEventListener("keydown",t=>{(t.code==="Escape"||t.keyCode===27)&&this.hide(t)}),this.#t.trigger&&document.querySelectorAll(this.#t.trigger).forEach(t=>{t.addEventListener("click",()=>this.show(t))}),this.on_init(this.#t)}};export{a as default};
package/dist/modal.min.js CHANGED
@@ -1,2 +1,2 @@
1
- var Modal=(()=>{var d=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var p=(e,i)=>{for(var o in i)d(e,o,{get:i[o],enumerable:!0})},w=(e,i,o,n)=>{if(i&&typeof i=="object"||typeof i=="function")for(let s of b(i))!_.call(e,s)&&s!==o&&d(e,s,{get:()=>i[s],enumerable:!(n=y(i,s))||n.enumerable});return e};var v=e=>w(d({},"__esModule",{value:!0}),e);var g={};p(g,{default:()=>a});var f=Symbol(),E=Symbol(),h=e=>{try{return e instanceof Element?e:document.querySelector(e)}catch{return}};var m=e=>h(e)?.[f],l=(e,i)=>(e&&(e[f]=i),e);var a=class e{modal;overlay;area;container;content;#t={};#i={};#e="hidden";static find=m;get state(){return this.#e}get params(){return this.#t}clone(i){let o=this.content.cloneNode(!0);return o.id=i.id??(o.id||"modal").replace(/#+$/,"")+(i.suffix??"_copy"),new e({...this.#t,...this.#i,content:o,...i,parent:this})}constructor(i){i={zIndex:1e3,duration:0,container:"body",overlay:!0,overlay_shading:.5,overlay_blur:"5px",overlay_scroll_lock:!0,content:"<div></div>",location:"center center",trigger:null,close_by_overlay:!0,close_by_esc:!0,auto_close:-1,allow_interrupt:!1,before_show:()=>{},on_show:()=>{},before_hide:()=>{},on_hide:()=>{},before_init:()=>{},on_init:()=>{},...i};let o,n,s;for(let[t,c]of Object.entries(i))typeof c=="function"?(this[t]=c.bind(this),this.#i[t]=c):this.#t[t]=c;this.before_init(this.#t),this.modal=document.createElement("modal"),l(this.modal,this),Object.assign(this.modal.style,{position:"fixed",top:"0",left:"0",right:"0",bottom:"0",zIndex:this.#t.zIndex,transition:`all ${this.#t.duration}s`,pointerEvents:"none",display:"none",overflow:"hidden"}),this.modal.setAttribute("state","hidden");try{h(this.#t.container).append(this.modal)}catch{throw new Error("\u041D\u0435\u0443\u0434\u0430\u0447\u043D\u0430\u044F \u043F\u043E\u043F\u044B\u0442\u043A\u0430 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u043C\u043E\u0434\u0430\u043B\u044C\u043D\u043E\u0435 \u043E\u043A\u043D\u043E \u0432 \u0443\u043A\u0430\u0437\u0430\u043D\u043D\u044B\u0439 \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440")}this.#t.overlay&&(this.overlay=document.createElement("modal-overlay"),l(this.overlay,this),Object.assign(this.overlay.style,{position:"absolute",top:"0",left:"0",right:"0",bottom:"0",backgroundColor:`rgba(0, 0, 0, ${this.#t.overlay_shading})`,backdropFilter:`blur(${this.#t.overlay_blur})`,zIndex:++this.#t.zIndex,transition:"inherit"}),this.modal.append(this.overlay));let r=(this.#t.location||"").toLowerCase().split(/\s+/);this.area=document.createElement("modal-area"),l(this.area,this),Object.assign(this.area.style,{position:"absolute",top:"0",left:"0",right:"0",bottom:"0",overflowY:"auto",overflowX:"clip",display:"flex",alignItems:"flex-start",justifyContent:r.includes("left")?"flex-start":r.includes("right")?"flex-end":"center",zIndex:++this.#t.zIndex,pointerEvents:"all",transition:"inherit"}),this.modal.append(this.area),this.#t.close_by_overlay&&this.area.addEventListener("click",t=>{this.container.contains(t.target)||this.hide(t)}),this.container=document.createElement("modal-container"),l(this.container,this),Object.assign(this.container.style,{position:"relative",flexShrink:"0",width:"max-content",height:"max-content",maxWidth:"100vw",zIndex:++this.#t.zIndex,transition:"inherit",pointerEvents:"all",marginTop:r.includes("top")?"0":"auto",marginBottom:r.includes("bottom")?"0":"auto",marginLeft:r.includes("left")?"0":"auto",marginRight:r.includes("right")?"0":"auto"}),this.area.append(this.container);try{this.content=h(this.#t.content)??new DOMParser().parseFromString(this.#t.content,"text/html").body.firstElementChild}catch{throw new Error("\u041D\u0435\u0443\u0434\u0430\u0447\u043D\u0430\u044F \u043F\u043E\u043F\u044B\u0442\u043A\u0430 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u043F\u0435\u0440\u0435\u0434\u0430\u043D\u043D\u044B\u0439 \u043A\u043E\u043D\u0442\u0435\u043D\u0442 \u0432 \u043C\u043E\u0434\u0430\u043B\u044C\u043D\u043E\u0435 \u043E\u043A\u043D\u043E")}this.container.append(this.content),l(this.content,this),this.content.style.transition="inherit",this.content.querySelectorAll('[action="close"]').forEach(t=>{t.addEventListener("click",()=>this.hide())});let u=t=>{t.before_func(t.data),clearTimeout(o),this.modal.style.display="flex",requestAnimationFrame(()=>{this.#e=t.process,this.modal.setAttribute("state",this.#e),requestAnimationFrame(()=>{o=setTimeout(()=>{this.#e=t.final,this.modal.setAttribute("state",this.#e),t.hide&&(this.modal.style.display="none"),t.after_func(t.data)},this.#t.duration*1e3)})})};this.show=(t=null)=>{(this.#e=="hidden"||this.#t.allow_interrupt&&this.#e=="hiding")&&(u({before_func:this.before_show,after_func:this.on_show,process:"showing",final:"shown",hide:!1,data:t}),this.#t.overlay_scroll_lock&&this.overlay&&(s=document.documentElement.style.scrollBehavior,n=document.body.style,n={position:n.position,top:n.top,left:n.left,width:n.width,scroll_Y:window.scrollY||document.documentElement.scrollTop,scroll_X:window.scrollX||document.documentElement.scrollLeft},document.documentElement.style.scrollBehavior="unset",Object.assign(document.body.style,{position:"fixed",width:"100vw",top:`-${n.scroll_Y}px`,left:`-${n.scroll_X}px`})),this.#t.auto_close>0&&(clearTimeout(o),o=setTimeout(()=>{this.hide()},this.#t.auto_close*1e3)))},this.hide=(t=null)=>{(this.#e=="shown"||this.#t.allow_interrupt&&this.#e=="showing")&&(u({before_func:this.before_hide,after_func:this.on_hide,process:"hiding",final:"hidden",hide:!0,data:t}),clearTimeout(o),o=setTimeout(()=>{n&&(Object.assign(document.body.style,n),window.scrollTo(n.scroll_X,n.scroll_Y)),s!=null&&(document.documentElement.style.scrollBehavior=s)},this.#t.duration*1e3))},this.#t.close_by_esc&&document.addEventListener("keydown",t=>{(t.code==="Escape"||t.keyCode===27)&&this.hide(t)}),this.#t.trigger&&document.querySelectorAll(this.#t.trigger).forEach(t=>{t.addEventListener("click",()=>this.show(t))}),this.on_init(this.#t)}};return v(g);})();
1
+ var Modal=(()=>{var d=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var p=(e,i)=>{for(var o in i)d(e,o,{get:i[o],enumerable:!0})},w=(e,i,o,n)=>{if(i&&typeof i=="object"||typeof i=="function")for(let s of b(i))!_.call(e,s)&&s!==o&&d(e,s,{get:()=>i[s],enumerable:!(n=y(i,s))||n.enumerable});return e};var v=e=>w(d({},"__esModule",{value:!0}),e);var g={};p(g,{default:()=>a});var f=Symbol(),E=Symbol(),h=e=>{try{return e instanceof Element?e:document.querySelector(e)}catch{return}};var m=e=>h(e)?.[f],r=(e,i)=>(e&&(e[f]=i),e);var a=class e{modal;overlay;area;container;content;#t={};#i={};#e="hidden";static find=m;get state(){return this.#e}get params(){return this.#t}clone(i){let o=this.content.cloneNode(!0);return o.id=i.id??(o.id||"modal").replace(/#+$/,"")+(i.suffix??"_copy"),new e({...this.#t,...this.#i,content:o,...i,parent:this})}constructor(i){i={zIndex:1e3,duration:0,container:"body",overlay:!0,overlay_shading:.5,overlay_blur:"5px",overlay_scroll_lock:!0,content:"<div></div>",location:"center center",fluid:!1,trigger:null,close_by_overlay:!0,close_by_esc:!0,auto_close:-1,allow_interrupt:!1,before_show:()=>{},on_show:()=>{},before_hide:()=>{},on_hide:()=>{},before_init:()=>{},on_init:()=>{},...i};let o,n,s;for(let[t,c]of Object.entries(i))typeof c=="function"?(this[t]=c.bind(this),this.#i[t]=c):this.#t[t]=c;this.before_init(this.#t),this.modal=document.createElement("modal"),r(this.modal,this),Object.assign(this.modal.style,{position:"fixed",top:"0",left:"0",right:"0",bottom:"0",zIndex:this.#t.zIndex,transition:`all ${this.#t.duration}s`,pointerEvents:"none",display:"none",overflow:"hidden"}),this.modal.setAttribute("state","hidden");try{h(this.#t.container).append(this.modal)}catch{throw new Error("\u041D\u0435\u0443\u0434\u0430\u0447\u043D\u0430\u044F \u043F\u043E\u043F\u044B\u0442\u043A\u0430 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u043C\u043E\u0434\u0430\u043B\u044C\u043D\u043E\u0435 \u043E\u043A\u043D\u043E \u0432 \u0443\u043A\u0430\u0437\u0430\u043D\u043D\u044B\u0439 \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440")}this.#t.overlay&&(this.overlay=document.createElement("modal-overlay"),r(this.overlay,this),Object.assign(this.overlay.style,{position:"absolute",top:"0",left:"0",right:"0",bottom:"0",backgroundColor:`rgba(0, 0, 0, ${this.#t.overlay_shading})`,backdropFilter:`blur(${this.#t.overlay_blur})`,zIndex:++this.#t.zIndex,transition:"inherit"}),this.modal.append(this.overlay));let l=(this.#t.location||"").toLowerCase().split(/\s+/);this.area=document.createElement("modal-area"),r(this.area,this),Object.assign(this.area.style,{position:"absolute",top:"0",left:"0",right:"0",bottom:"0",overflowY:"auto",overflowX:"clip",display:"flex",alignItems:"flex-start",justifyContent:l.includes("left")?"flex-start":l.includes("right")?"flex-end":"center",zIndex:++this.#t.zIndex,pointerEvents:"all",transition:"inherit"}),this.modal.append(this.area),this.#t.close_by_overlay&&this.area.addEventListener("click",t=>{this.container.contains(t.target)||this.hide(t)}),this.container=document.createElement("modal-container"),r(this.container,this),Object.assign(this.container.style,{position:"relative",flexShrink:"0",width:this.#t.fluid?"100%":"max-content",height:"max-content",maxWidth:this.#t.fluid?"none":"100vw",zIndex:++this.#t.zIndex,transition:"inherit",pointerEvents:"all",marginTop:l.includes("top")?"0":"auto",marginBottom:l.includes("bottom")?"0":"auto",marginLeft:l.includes("left")?"0":"auto",marginRight:l.includes("right")?"0":"auto"}),this.area.append(this.container);try{this.content=h(this.#t.content)??new DOMParser().parseFromString(this.#t.content,"text/html").body.firstElementChild}catch{throw new Error("\u041D\u0435\u0443\u0434\u0430\u0447\u043D\u0430\u044F \u043F\u043E\u043F\u044B\u0442\u043A\u0430 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u043F\u0435\u0440\u0435\u0434\u0430\u043D\u043D\u044B\u0439 \u043A\u043E\u043D\u0442\u0435\u043D\u0442 \u0432 \u043C\u043E\u0434\u0430\u043B\u044C\u043D\u043E\u0435 \u043E\u043A\u043D\u043E")}this.container.append(this.content),r(this.content,this),this.content.style.transition="inherit",this.content.querySelectorAll('[action="close"]').forEach(t=>{t.addEventListener("click",()=>this.hide())});let u=t=>{t.before_func(t.data),clearTimeout(o),this.modal.style.display="flex",requestAnimationFrame(()=>{this.#e=t.process,this.modal.setAttribute("state",this.#e),requestAnimationFrame(()=>{o=setTimeout(()=>{this.#e=t.final,this.modal.setAttribute("state",this.#e),t.hide&&(this.modal.style.display="none"),t.after_func(t.data)},this.#t.duration*1e3)})})};this.show=(t=null)=>{(this.#e=="hidden"||this.#t.allow_interrupt&&this.#e=="hiding")&&(u({before_func:this.before_show,after_func:this.on_show,process:"showing",final:"shown",hide:!1,data:t}),this.#t.overlay_scroll_lock&&this.overlay&&(s=document.documentElement.style.scrollBehavior,n=document.body.style,n={position:n.position,top:n.top,left:n.left,width:n.width,scroll_Y:window.scrollY||document.documentElement.scrollTop,scroll_X:window.scrollX||document.documentElement.scrollLeft},document.documentElement.style.scrollBehavior="unset",Object.assign(document.body.style,{position:"fixed",width:"100vw",top:`-${n.scroll_Y}px`,left:`-${n.scroll_X}px`})),this.#t.auto_close>0&&(clearTimeout(o),o=setTimeout(()=>{this.hide()},this.#t.auto_close*1e3)))},this.hide=(t=null)=>{(this.#e=="shown"||this.#t.allow_interrupt&&this.#e=="showing")&&(u({before_func:this.before_hide,after_func:this.on_hide,process:"hiding",final:"hidden",hide:!0,data:t}),clearTimeout(o),o=setTimeout(()=>{n&&(Object.assign(document.body.style,n),window.scrollTo(n.scroll_X,n.scroll_Y)),s!=null&&(document.documentElement.style.scrollBehavior=s)},this.#t.duration*1e3))},this.#t.close_by_esc&&document.addEventListener("keydown",t=>{(t.code==="Escape"||t.keyCode===27)&&this.hide(t)}),this.#t.trigger&&document.querySelectorAll(this.#t.trigger).forEach(t=>{t.addEventListener("click",()=>this.show(t))}),this.on_init(this.#t)}};return v(g);})();
2
2
  if(typeof Modal!=="undefined"&&Modal&&Modal.default)globalThis.Modal=Modal.default;
@@ -1 +1 @@
1
- var d=Symbol(),_=Symbol(),p=s=>{try{return s instanceof Element?s:document.querySelector(s)}catch{return}},h=s=>{if(s==null)return[];if(s instanceof Element)return[s];if(s instanceof NodeList||s instanceof HTMLCollection)return[...s];if(Array.isArray(s))return s.flatMap(h);try{return[...document.querySelectorAll(s)]}catch{return[]}},v=s=>p(s)?.[d],b=(s,t)=>(s&&(s[d]=t),s),y=(s,t)=>{if(!s)return s;let i=s[_]??=new Set;for(let[e,a]of Object.entries(t)){if(e in s&&!i.has(e)){console.warn(`\u0418\u043C\u044F "${e}" \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`,s);continue}Object.defineProperty(s,e,{value:a,writable:!0,configurable:!0,enumerable:!1}),i.add(e)}return s};var f=class s{#t={};#a={};#n=new WeakMap;#r=new Map;#e=null;static find=v;get params(){return this.#t}clone(t){return new s({...this.#t,...this.#a,...t,parent:this})}constructor(t){t={duration:0,trigger:"[trigger]",target:null,allow_interrupt:!1,action:"click",anchor:!1,keep_history:!1,before_activate:()=>{},on_activate:()=>{},before_deactivate:()=>{},on_deactivate:()=>{},before_activated:()=>{},on_activated:()=>{},before_deactivated:()=>{},on_deactivated:()=>{},before_init:()=>{},on_init:()=>{},...t},t.keep_history&&(t.anchor=!0);for(let[e,a]of Object.entries(t))typeof a=="function"&&e!="target"?(this[e]=a.bind(this),this.#a[e]=a):this.#t[e]=a;this.before_init(this.#t);let i=e=>e.hasAttribute("state")||e.setAttribute("state","inactive");for(let e of h(this.#t.trigger)){b(e,this),y(e,{toggle:()=>this.toggle(e),activate:()=>this.activate(e),deactivate:()=>this.deactivate(e)}),i(e),this.#i(e).forEach(i);let a=this.#o(e);a&&this.#r.set(a,e),this.#t.action=="hover"?(e.addEventListener("mouseenter",()=>this.activate(e)),e.addEventListener("mouseleave",()=>this.deactivate(e))):e.addEventListener(this.#t.action,()=>this.toggle(e))}this.#t.anchor&&(this.#h(),this.#t.keep_history&&window.addEventListener("hashchange",()=>this.#h())),this.on_init(this.#t)}#i(t){let i=this.#t.target;return typeof i=="function"&&(i=i(t)),i??=t.getAttribute("target"),h(i)}#o(t){if(!this.#t.anchor)return null;if(t.id)return t.id;let i=this.#i(t);return i.length===1&&i[0].id?i[0].id:null}#l(t){let i="#"+t;location.hash!==i&&(this.#t.keep_history?history.pushState(null,"",i):history.replaceState(null,"",i))}#u(){if(!location.hash)return;let t=location.pathname+location.search;this.#t.keep_history?history.pushState(null,"",t):history.replaceState(null,"",t)}#h(){let t=this.#r.get(location.hash.slice(1));t?this.activate(t):this.#t.keep_history&&this.#e&&(this.deactivate(this.#e),this.#e=null)}#c(t,i,e,a,c){t.forEach(n=>(a(n),clearTimeout(this.#n.get(n)))),requestAnimationFrame(()=>{t.forEach(n=>n.setAttribute("state",i)),requestAnimationFrame(()=>{let n=setTimeout(()=>t.forEach(r=>(r.setAttribute("state",e),c(r))),this.#t.duration*1e3);t.forEach(r=>this.#n.set(r,n))})})}#s(t,i){let e=t.getAttribute("state")??"inactive",a=this.#t.allow_interrupt;if(!(i?e=="inactive"||a&&e=="deactivating":e=="active"||a&&e=="activating"))return;let c=i?"activate":"deactivate",n=i?"activating":"deactivating",r=i?"active":"inactive",l=this.#i(t),u=this.#o(t);u&&(i?(this.#l(u),this.#e=t):location.hash.slice(1)===u&&(this.#u(),this.#e=null)),this.#c([t],n,r,o=>this[`before_${c}`](o,l),o=>this[`on_${c}`](o,l)),this.#c(l,n,r,o=>this[`before_${c}d`](o,t),o=>this[`on_${c}d`](o,t))}toggle(t){h(t).forEach(i=>this.#s(i,!["active","activating"].includes(i.getAttribute("state"))))}activate(t){h(t).forEach(i=>this.#s(i,!0))}deactivate(t){h(t).forEach(i=>this.#s(i,!1))}};export{f as default};
1
+ var d=Symbol(),g=Symbol(),y=s=>{try{return s instanceof Element?s:document.querySelector(s)}catch{return}},h=s=>{if(s==null)return[];if(s instanceof Element)return[s];if(s instanceof NodeList||s instanceof HTMLCollection)return[...s];if(Array.isArray(s))return s.flatMap(h);try{return[...document.querySelectorAll(s)]}catch{return[]}},v=s=>y(s)?.[d],b=(s,t)=>(s&&(s[d]=t),s),p=(s,t)=>{if(!s)return s;let i=s[g]??=new Set;for(let[e,a]of Object.entries(t)){if(e in s&&!i.has(e)){console.warn(`\u0418\u043C\u044F "${e}" \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`,s);continue}Object.defineProperty(s,e,{value:a,writable:!0,configurable:!0,enumerable:!1}),i.add(e)}return s};var f=class s{#t={};#a={};#n=new WeakMap;#r=new Map;#o=[];#e=null;static find=v;get params(){return this.#t}clone(t){return new s({...this.#t,...this.#a,...t,parent:this})}constructor(t){t={duration:0,trigger:"[trigger]",target:null,allow_interrupt:!1,action:"click",anchor:!1,keep_history:!1,group:!1,before_activate:()=>{},on_activate:()=>{},before_deactivate:()=>{},on_deactivate:()=>{},before_activated:()=>{},on_activated:()=>{},before_deactivated:()=>{},on_deactivated:()=>{},before_init:()=>{},on_init:()=>{},...t},t.keep_history&&(t.anchor=!0);for(let[e,a]of Object.entries(t))typeof a=="function"&&e!="target"?(this[e]=a.bind(this),this.#a[e]=a):this.#t[e]=a;this.before_init(this.#t);let i=e=>e.hasAttribute("state")||e.setAttribute("state","inactive");for(let e of h(this.#t.trigger)){b(e,this),this.#o.push(e),p(e,{toggle:()=>this.toggle(e),activate:()=>this.activate(e),deactivate:()=>this.deactivate(e)}),i(e),this.#s(e).forEach(i);let a=this.#h(e);a&&this.#r.set(a,e),this.#t.action=="hover"?(e.addEventListener("mouseenter",()=>this.activate(e)),e.addEventListener("mouseleave",()=>this.deactivate(e))):e.addEventListener(this.#t.action,()=>this.toggle(e))}this.#t.anchor&&(this.#c(),this.#t.keep_history&&window.addEventListener("hashchange",()=>this.#c())),this.on_init(this.#t)}#s(t){let i=this.#t.target;return typeof i=="function"&&(i=i(t)),i??=t.getAttribute("target"),h(i)}#h(t){if(!this.#t.anchor)return null;if(t.id)return t.id;let i=this.#s(t);return i.length===1&&i[0].id?i[0].id:null}#u(t){let i="#"+t;location.hash!==i&&(this.#t.keep_history?history.pushState(null,"",i):history.replaceState(null,"",i))}#f(){if(!location.hash)return;let t=location.pathname+location.search;this.#t.keep_history?history.pushState(null,"",t):history.replaceState(null,"",t)}#c(){let t=this.#r.get(location.hash.slice(1));t?this.activate(t):this.#t.keep_history&&this.#e&&(this.deactivate(this.#e),this.#e=null)}#l(t,i,e,a,c){t.forEach(r=>(a(r),clearTimeout(this.#n.get(r)))),requestAnimationFrame(()=>{t.forEach(r=>r.setAttribute("state",i)),requestAnimationFrame(()=>{let r=setTimeout(()=>t.forEach(o=>(o.setAttribute("state",e),c(o))),this.#t.duration*1e3);t.forEach(o=>this.#n.set(o,r))})})}#i(t,i){let e=t.getAttribute("state")??"inactive",a=this.#t.allow_interrupt;if(!(i?e=="inactive"||a&&e=="deactivating":e=="active"||a&&e=="activating"))return;let c=i?"activate":"deactivate",r=i?"activating":"deactivating",o=i?"active":"inactive",l=this.#s(t);i&&this.#t.group&&this.#o.filter(n=>n!==t&&["active","activating"].includes(n.getAttribute("state"))).forEach(n=>this.#i(n,!1));let u=this.#h(t);u&&(i?(this.#u(u),this.#e=t):location.hash.slice(1)===u&&(this.#f(),this.#e=null)),this.#l([t],r,o,n=>this[`before_${c}`](n,l),n=>this[`on_${c}`](n,l)),this.#l(l,r,o,n=>this[`before_${c}d`](n,t),n=>this[`on_${c}d`](n,t))}toggle(t){h(t).forEach(i=>{let e=!["active","activating"].includes(i.getAttribute("state"));(e||this.#t.group!="radio")&&this.#i(i,e)})}activate(t){h(t).forEach(i=>this.#i(i,!0))}deactivate(t){h(t).forEach(i=>this.#i(i,!1))}};export{f as default};
@@ -1,2 +1,2 @@
1
- var Toggle=(()=>{var d=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var m=(s,t)=>{for(var e in t)d(s,e,{get:t[e],enumerable:!0})},w=(s,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of g(t))!E.call(s,a)&&a!==e&&d(s,a,{get:()=>t[a],enumerable:!(i=p(t,a))||i.enumerable});return s};var A=s=>w(d({},"__esModule",{value:!0}),s);var S={};m(S,{default:()=>l});var v=Symbol(),k=Symbol(),x=s=>{try{return s instanceof Element?s:document.querySelector(s)}catch{return}},h=s=>{if(s==null)return[];if(s instanceof Element)return[s];if(s instanceof NodeList||s instanceof HTMLCollection)return[...s];if(Array.isArray(s))return s.flatMap(h);try{return[...document.querySelectorAll(s)]}catch{return[]}},b=s=>x(s)?.[v],y=(s,t)=>(s&&(s[v]=t),s),_=(s,t)=>{if(!s)return s;let e=s[k]??=new Set;for(let[i,a]of Object.entries(t)){if(i in s&&!e.has(i)){console.warn(`\u0418\u043C\u044F "${i}" \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`,s);continue}Object.defineProperty(s,i,{value:a,writable:!0,configurable:!0,enumerable:!1}),e.add(i)}return s};var l=class s{#t={};#a={};#n=new WeakMap;#r=new Map;#e=null;static find=b;get params(){return this.#t}clone(t){return new s({...this.#t,...this.#a,...t,parent:this})}constructor(t){t={duration:0,trigger:"[trigger]",target:null,allow_interrupt:!1,action:"click",anchor:!1,keep_history:!1,before_activate:()=>{},on_activate:()=>{},before_deactivate:()=>{},on_deactivate:()=>{},before_activated:()=>{},on_activated:()=>{},before_deactivated:()=>{},on_deactivated:()=>{},before_init:()=>{},on_init:()=>{},...t},t.keep_history&&(t.anchor=!0);for(let[i,a]of Object.entries(t))typeof a=="function"&&i!="target"?(this[i]=a.bind(this),this.#a[i]=a):this.#t[i]=a;this.before_init(this.#t);let e=i=>i.hasAttribute("state")||i.setAttribute("state","inactive");for(let i of h(this.#t.trigger)){y(i,this),_(i,{toggle:()=>this.toggle(i),activate:()=>this.activate(i),deactivate:()=>this.deactivate(i)}),e(i),this.#i(i).forEach(e);let a=this.#o(i);a&&this.#r.set(a,i),this.#t.action=="hover"?(i.addEventListener("mouseenter",()=>this.activate(i)),i.addEventListener("mouseleave",()=>this.deactivate(i))):i.addEventListener(this.#t.action,()=>this.toggle(i))}this.#t.anchor&&(this.#h(),this.#t.keep_history&&window.addEventListener("hashchange",()=>this.#h())),this.on_init(this.#t)}#i(t){let e=this.#t.target;return typeof e=="function"&&(e=e(t)),e??=t.getAttribute("target"),h(e)}#o(t){if(!this.#t.anchor)return null;if(t.id)return t.id;let e=this.#i(t);return e.length===1&&e[0].id?e[0].id:null}#l(t){let e="#"+t;location.hash!==e&&(this.#t.keep_history?history.pushState(null,"",e):history.replaceState(null,"",e))}#u(){if(!location.hash)return;let t=location.pathname+location.search;this.#t.keep_history?history.pushState(null,"",t):history.replaceState(null,"",t)}#h(){let t=this.#r.get(location.hash.slice(1));t?this.activate(t):this.#t.keep_history&&this.#e&&(this.deactivate(this.#e),this.#e=null)}#c(t,e,i,a,c){t.forEach(n=>(a(n),clearTimeout(this.#n.get(n)))),requestAnimationFrame(()=>{t.forEach(n=>n.setAttribute("state",e)),requestAnimationFrame(()=>{let n=setTimeout(()=>t.forEach(r=>(r.setAttribute("state",i),c(r))),this.#t.duration*1e3);t.forEach(r=>this.#n.set(r,n))})})}#s(t,e){let i=t.getAttribute("state")??"inactive",a=this.#t.allow_interrupt;if(!(e?i=="inactive"||a&&i=="deactivating":i=="active"||a&&i=="activating"))return;let c=e?"activate":"deactivate",n=e?"activating":"deactivating",r=e?"active":"inactive",u=this.#i(t),f=this.#o(t);f&&(e?(this.#l(f),this.#e=t):location.hash.slice(1)===f&&(this.#u(),this.#e=null)),this.#c([t],n,r,o=>this[`before_${c}`](o,u),o=>this[`on_${c}`](o,u)),this.#c(u,n,r,o=>this[`before_${c}d`](o,t),o=>this[`on_${c}d`](o,t))}toggle(t){h(t).forEach(e=>this.#s(e,!["active","activating"].includes(e.getAttribute("state"))))}activate(t){h(t).forEach(e=>this.#s(e,!0))}deactivate(t){h(t).forEach(e=>this.#s(e,!1))}};return A(S);})();
1
+ var Toggle=(()=>{var d=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var m=(s,t)=>{for(var i in t)d(s,i,{get:t[i],enumerable:!0})},w=(s,t,i,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of _(t))!E.call(s,a)&&a!==i&&d(s,a,{get:()=>t[a],enumerable:!(e=y(t,a))||e.enumerable});return s};var A=s=>w(d({},"__esModule",{value:!0}),s);var S={};m(S,{default:()=>l});var v=Symbol(),k=Symbol(),x=s=>{try{return s instanceof Element?s:document.querySelector(s)}catch{return}},h=s=>{if(s==null)return[];if(s instanceof Element)return[s];if(s instanceof NodeList||s instanceof HTMLCollection)return[...s];if(Array.isArray(s))return s.flatMap(h);try{return[...document.querySelectorAll(s)]}catch{return[]}},b=s=>x(s)?.[v],p=(s,t)=>(s&&(s[v]=t),s),g=(s,t)=>{if(!s)return s;let i=s[k]??=new Set;for(let[e,a]of Object.entries(t)){if(e in s&&!i.has(e)){console.warn(`\u0418\u043C\u044F "${e}" \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`,s);continue}Object.defineProperty(s,e,{value:a,writable:!0,configurable:!0,enumerable:!1}),i.add(e)}return s};var l=class s{#t={};#a={};#n=new WeakMap;#r=new Map;#o=[];#e=null;static find=b;get params(){return this.#t}clone(t){return new s({...this.#t,...this.#a,...t,parent:this})}constructor(t){t={duration:0,trigger:"[trigger]",target:null,allow_interrupt:!1,action:"click",anchor:!1,keep_history:!1,group:!1,before_activate:()=>{},on_activate:()=>{},before_deactivate:()=>{},on_deactivate:()=>{},before_activated:()=>{},on_activated:()=>{},before_deactivated:()=>{},on_deactivated:()=>{},before_init:()=>{},on_init:()=>{},...t},t.keep_history&&(t.anchor=!0);for(let[e,a]of Object.entries(t))typeof a=="function"&&e!="target"?(this[e]=a.bind(this),this.#a[e]=a):this.#t[e]=a;this.before_init(this.#t);let i=e=>e.hasAttribute("state")||e.setAttribute("state","inactive");for(let e of h(this.#t.trigger)){p(e,this),this.#o.push(e),g(e,{toggle:()=>this.toggle(e),activate:()=>this.activate(e),deactivate:()=>this.deactivate(e)}),i(e),this.#s(e).forEach(i);let a=this.#h(e);a&&this.#r.set(a,e),this.#t.action=="hover"?(e.addEventListener("mouseenter",()=>this.activate(e)),e.addEventListener("mouseleave",()=>this.deactivate(e))):e.addEventListener(this.#t.action,()=>this.toggle(e))}this.#t.anchor&&(this.#c(),this.#t.keep_history&&window.addEventListener("hashchange",()=>this.#c())),this.on_init(this.#t)}#s(t){let i=this.#t.target;return typeof i=="function"&&(i=i(t)),i??=t.getAttribute("target"),h(i)}#h(t){if(!this.#t.anchor)return null;if(t.id)return t.id;let i=this.#s(t);return i.length===1&&i[0].id?i[0].id:null}#u(t){let i="#"+t;location.hash!==i&&(this.#t.keep_history?history.pushState(null,"",i):history.replaceState(null,"",i))}#f(){if(!location.hash)return;let t=location.pathname+location.search;this.#t.keep_history?history.pushState(null,"",t):history.replaceState(null,"",t)}#c(){let t=this.#r.get(location.hash.slice(1));t?this.activate(t):this.#t.keep_history&&this.#e&&(this.deactivate(this.#e),this.#e=null)}#l(t,i,e,a,c){t.forEach(r=>(a(r),clearTimeout(this.#n.get(r)))),requestAnimationFrame(()=>{t.forEach(r=>r.setAttribute("state",i)),requestAnimationFrame(()=>{let r=setTimeout(()=>t.forEach(o=>(o.setAttribute("state",e),c(o))),this.#t.duration*1e3);t.forEach(o=>this.#n.set(o,r))})})}#i(t,i){let e=t.getAttribute("state")??"inactive",a=this.#t.allow_interrupt;if(!(i?e=="inactive"||a&&e=="deactivating":e=="active"||a&&e=="activating"))return;let c=i?"activate":"deactivate",r=i?"activating":"deactivating",o=i?"active":"inactive",u=this.#s(t);i&&this.#t.group&&this.#o.filter(n=>n!==t&&["active","activating"].includes(n.getAttribute("state"))).forEach(n=>this.#i(n,!1));let f=this.#h(t);f&&(i?(this.#u(f),this.#e=t):location.hash.slice(1)===f&&(this.#f(),this.#e=null)),this.#l([t],r,o,n=>this[`before_${c}`](n,u),n=>this[`on_${c}`](n,u)),this.#l(u,r,o,n=>this[`before_${c}d`](n,t),n=>this[`on_${c}d`](n,t))}toggle(t){h(t).forEach(i=>{let e=!["active","activating"].includes(i.getAttribute("state"));(e||this.#t.group!="radio")&&this.#i(i,e)})}activate(t){h(t).forEach(i=>this.#i(i,!0))}deactivate(t){h(t).forEach(i=>this.#i(i,!1))}};return A(S);})();
2
2
  if(typeof Toggle!=="undefined"&&Toggle&&Toggle.default)globalThis.Toggle=Toggle.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cat-of-summer/st-script",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Standalone JS classes/components (Modal, App, Typograf , …), shipped as ESM and IIFE/CDN builds.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -23,7 +23,6 @@
23
23
  "prepack": "node scripts/build.mjs"
24
24
  },
25
25
  "publishConfig": {
26
- "registry": "https://registry.npmjs.org",
27
26
  "access": "public"
28
27
  },
29
28
  "devDependencies": {