1import{q as W,x as G,u as K,o as m,g as f,a2 as Q,b as g,a as j,L as Y,H as y,f as E,t as k,l as V,z as J,m as B}from"./index-MSa8avpS.js";import{c as X}from"./ibantools-CtyiK2fp.js";function D(t){const{anchorOffset:e=0,focusOffset:s=0}=t.ownerDocument.getSelection()||{},n=Math.min(e,s),i=Math.max(e,s);return[n,i]}function ee(t,[e,s]){const n=t.ownerDocument,i=n.createRange();i.setStart(t.firstChild||t,Math.min(e,t.textContent?.length??0)),i.setEnd(t.lastChild||t,Math.min(s,t.textContent?.length??0));const a=n.getSelection();a&&(a.removeAllRanges(),a.addRange(i))}class te{constructor(e){this.element=e,this.maxLength=1/0}get value(){return this.element.innerText.replace(/\n\n$/,` 2`)}set value(e){this.element.innerHTML=e.replace(/\n$/,` 3 4`)}get selectionStart(){return D(this.element)[0]}get selectionEnd(){return D(this.element)[1]}setSelectionRange(e,s){ee(this.element,[e??0,s??0])}select(){this.setSelectionRange(0,this.value.length)}}function ne(t){const e=new te(t);return new Proxy(t,{get(s,n){if(n in e)return e[n];const i=s[n];return typeof i=="function"?i.bind(s):i},set(s,n,i,a){return Reflect.set(n in e?e:s,n,i,a)}})}const se=t=>t.isContentEditable?ne(t):t.querySelector("input,textarea")||t,q={mask:/^.*$/,preprocessors:[],postprocessors:[],plugins:[],overwriteMode:"shift"};class ie{constructor(){this.now=null,this.past=[],this.future=[]}undo(){const e=this.past.pop();e&&this.now&&(this.future.push(this.now),this.updateElement(e,"historyUndo"))}redo(){const e=this.future.pop();e&&this.now&&(this.past.push(this.now),this.updateElement(e,"historyRedo"))}updateHistory(e){if(!this.now){this.now=e;return}const s=this.now.value!==e.value,n=this.now.selection.some((i,a)=>i!==e.selection[a]);!s&&!n||(s&&(this.past.push(this.now),this.future=[]),this.now=e)}updateElement(e,s){this.now=e,this.updateElementState(e,{inputType:s,data:null})}}function ae(t,...e){return e.every(({value:s})=>s===t.value)}function $(t,...e){return e.every(({value:s,selection:n})=>s===t.value&&n[0]===t.selection[0]&&n[1]===t.selection[1])}function N({value:t,selection:e},s,n){const[i,a]=e,o=typeof n=="function"?n({value:t,selection:e}):n;return{value:t,selection:o==="replace"?[i,Math.max(i+s.length,a)]:[i,a]}}function x(t){return typeof t=="string"}function Z(t,e,s,n){let i="";for(let a=e.length;a<t.length;a++){const o=t[a]||"",l=n?.value[a]===o;if(!x(o)||o===s&&!l)return i;i+=o}return i}function O(t,e){return Array.isArray(e)?t.length===e.length&&Array.from(t).every((s,n)=>{const i=e[n]||"";return x(i)?s===i:s.match(i)}):e.test(t)}function oe(t,e,s){let n=null,i=null;const a=Array.from(t.value).reduce((l,r,c)=>{const u=Z(e,l,r,s),d=`${l}${u}`,p=e[d.length]||"";return n===null&&c>=t.selection[0]&&(n=d.length),i===null&&c>=t.selection[1]&&(i=d.length),x(p)?`${d}${p}`:r.match(p)?`${d}${r}`:u.startsWith(r)?d:l},""),o=Z(e,a,"",s);return{value:O(`${a}${o}`,e)?`${a}${o}`:a,selection:[n??a.length,i??a.length]}}function re({value:t,selection:e},s){const[n,i]=e;let a=n,o=i;const l=Array.from(t).reduce((r,c,u)=>{const d=`${r}${c}`;return n===u&&(a=r.length),i===u&&(o=r.length),d.match(s)?d:r},"");return{value:l,selection:[Math.min(a,l.length),Math.min(o,l.length)]}}function T(t,e,s=null){if(O(t.value,e))return t;const{value:n,selection:i}=Array.isArray(e)?oe(t,e,s):re(t,e);return{selection:i,value:Array.isArray(e)?n.slice(0,e.length):n}}function H(t,e){if(!Array.isArray(e))return t;const[s,n]=t.selection,i=[],a=Array.from(t.value).reduce((o,l,r)=>{const c=e[r]||"";return r===s&&i.push(o.length),r===n&&i.push(o.length),x(c)&&c===l?o:`${o}${l}`},"");return i.length<2&&i.push(...Array.from({length:2-i.length}).fill(a.length)),{value:a,selection:[i[0],i[1]]}}class R{constructor(e,s){this.maskOptions=s,this.unmaskInitialState={value:"",selection:[0,0]},this.value="",this.selection=[0,0];const n=this.getMaskExpression(e),{value:i,selection:a}=T(e,n);this.unmaskInitialState=H({value:i,selection:a},n),this.value=i,this.selection=a}addCharacters(e){const{value:s,selection:n,maskOptions:i}=this,a={value:s,selection:n},{selection:[o,l]}=N(a,e,i.overwriteMode),r=this.getMaskExpression({value:`${s.slice(0,o)}${e}${s.slice(l)}`,selection:[o+e.length,o+e.length]}),[c,u]=N(this.unmaskInitialState,e,i.overwriteMode).selection,d=`${this.unmaskInitialState.value.slice(0,c)}${e}`,p=d.length,A=T({value:`${d}${this.unmaskInitialState.value.slice(u)}`,selection:[p,p]},r,a),P=s.slice(0,o),L=T({value:d,selection:[p,p]},r,a);if(L.value===P||L.value.length<P.length&&H(L,r).value===this.unmaskInitialState.value.slice(0,c)||$(this,A))throw new Error("Invalid mask value");this.value=A.value,this.selection=A.selection}deleteCharacters(){const[e,s]=this.selection;if(e===s||!s)return;const{value:n}=this,i=this.getMaskExpression({value:`${n.slice(0,e)}${n.slice(s)}`,selection:[e,e]}),a={value:n},[o,l]=this.unmaskInitialState.selection,r=`${this.unmaskInitialState.value.slice(0,o)}${this.unmaskInitialState.value.slice(l)}`,c=T({value:r,selection:[o,o]},i,a);this.value=c.value,this.selection=c.selection}getMaskExpression(e){const{mask:s}=this.maskOptions;return typeof s=="function"?s(e):s}}class F{constructor(e){this.element=e,this.listeners=[]}listen(e,s,n){const i=s;this.element.addEventListener(e,i,n),this.listeners.push(()=>this.element.removeEventListener(e,i,n))}
4destroy(){this.listeners.forEach(e=>e())}}const h={CTRL:1,ALT:2,SHIFT:4,META:8},v={Y:89,Z:90};function S(t,e,s){return t.ctrlKey===!!(e&h.CTRL)&&t.altKey===!!(e&h.ALT)&&t.shiftKey===!!(e&h.SHIFT)&&t.metaKey===!!(e&h.META)&&t.keyCode===s}function le(t){return S(t,h.CTRL,v.Y)||S(t,h.CTRL|h.SHIFT,v.Z)||S(t,h.META|h.SHIFT,v.Z)}function ce(t){return S(t,h.CTRL,v.Z)||S(t,h.META,v.Z)}function ue({value:t,selection:e},s){const[n,i]=e;if(n!==i)return[n,i];const a=s?t.slice(n).indexOf(` 5`)+1||t.length:t.slice(0,i).lastIndexOf(` 6`)+1;return[s?n:a,s?a:i]}function de({value:t,selection:e},s){const[n,i]=e;return n!==i?[n,i]:(s?[n,i+1]:[n-1,i]).map(o=>Math.min(Math.max(o,0),t.length))}const he=/\s+$/g,pe=/^\s+/g,U=/\s/;function me({value:t,selection:e},s){const[n,i]=e;if(n!==i)return[n,i];if(s){const r=t.slice(n),[c]=r.match(pe)||[""],u=r.trimStart().search(U);return[n,u===-1?t.length:n+c.length+u]}const a=t.slice(0,i),[o]=a.match(he)||[""],l=a.trimEnd().split("").reverse().findIndex(r=>U.exec(r));return[l===-1?0:i-o.length-l,i]}function M(t=[]){return(e,...s)=>t.reduce((n,i)=>({...n,...i(n,...s)}),e)}function _(t,e){const s={...q,...e},n=M(s.preprocessors),i=M(s.postprocessors),a=typeof t=="string"?{value:t,selection:[0,0]}:t,{elementState:o}=n({elementState:a,data:""},"validation"),l=new R(o,s),{value:r,selection:c}=i(l,a);return typeof t=="string"?r:{value:r,selection:c}}function fe(){return t=>{const e=new F(t);let s=!1,n,i=t.value;return e.listen("keydown",({key:a})=>{s=a==="Unidentified"}),e.listen("beforeinput",a=>{n=a,i=t.value}),e.listen("input",a=>{s&&n.defaultPrevented&&n.inputType==="deleteContentBackward"&&a.inputType==="deleteContentBackward"&&(t.value=i)},{capture:!0}),()=>e.destroy()}}const C=" ";function ge(){let t="",e=0,s=null,n=!1;return i=>{const a=new F(i);return a.listen("beforeinput",o=>{const{value:l,selectionStart:r,selectionEnd:c}=i,u=s?.inputType==="insertText"&&s.data===C&&!l.slice(0,Number(c)).endsWith(C);o.inputType==="insertText"&&o.data===`.${C}`&&(s?.inputType==="deleteContentBackward"&&n?(i.value=t,i.setSelectionRange(e,e)):u&&i.setSelectionRange(r,r)),n=u,s=o,t=l,e=Number((u?e:c)===l.length?c:r)}),()=>a.destroy()}}const ve=[ge(),fe()];class Se extends ie{constructor(e,s){super(),this.element=e,this.maskitoOptions=s,this.isTextArea=this.element.nodeName==="TEXTAREA",this.eventListener=new F(this.element),this.options={...q,...this.maskitoOptions},this.upcomingElementState=null,this.preprocessor=M(this.options.preprocessors),this.postprocessor=M(this.options.postprocessors),this.teardowns=this.options.plugins.concat(ve).map(n=>n(this.element,this.options)),this.updateHistory(this.elementState),this.eventListener.listen("keydown",n=>{if(le(n))return n.preventDefault(),this.redo();if(ce(n))return n.preventDefault(),this.undo()}),this.eventListener.listen("beforeinput",n=>{const i=n.inputType.includes("Forward");switch(this.updateHistory(this.elementState),n.inputType){case"deleteByCut":case"deleteContentBackward":case"deleteContentForward":return this.handleDelete({event:n,isForward:i,selection:de(this.elementState,i)});case"deleteHardLineBackward":case"deleteHardLineForward":case"deleteSoftLineBackward":case"deleteSoftLineForward":return this.handleDelete({event:n,isForward:i,selection:ue(this.elementState,i),force:!0});
6case"deleteWordBackward":case"deleteWordForward":return this.handleDelete({event:n,isForward:i,selection:me(this.elementState,i)});case"historyRedo":return n.preventDefault(),this.redo();case"historyUndo":return n.preventDefault(),this.undo();case"insertCompositionText":return;case"insertLineBreak":case"insertParagraph":return this.handleEnter(n);case"insertReplacementText":return;default:return this.handleInsert(n,n.data??n.dataTransfer?.getData("text/plain")??"")}}),this.eventListener.listen("input",()=>{this.upcomingElementState&&!$(this.upcomingElementState,this.elementState)&&this.updateElementState(this.upcomingElementState),this.upcomingElementState=null},{capture:!0}),this.eventListener.listen("input",({inputType:n})=>{n!=="insertCompositionText"&&(this.ensureValueFitsMask(),this.updateHistory(this.elementState))}),this.eventListener.listen("compositionend",()=>{this.ensureValueFitsMask(),this.updateHistory(this.elementState)})}destroy(){this.eventListener.destroy(),this.teardowns.forEach(e=>e?.())}updateElementState({value:e,selection:s},n){const i=this.elementState.value;this.updateValue(e),this.updateSelectionRange(s),n&&i!==e&&this.dispatchInputEvent(n)}get elementState(){const{value:e,selectionStart:s,selectionEnd:n}=this.element;return{value:e,selection:[s??0,n??0]}}get maxLength(){const{maxLength:e}=this.element;return e===-1?1/0:e}updateSelectionRange([e,s]){const{element:n}=this;n.matches(":focus")&&(n.selectionStart!==e||n.selectionEnd!==s)&&n.setSelectionRange(e,s)}updateValue(e){(this.element.value!==e||this.element.isContentEditable)&&(this.element.value=e)}ensureValueFitsMask(){this.updateElementState(_(this.elementState,this.options),{inputType:"insertText",data:null})}dispatchInputEvent(e={inputType:"insertText",data:null}){this.element.dispatchEvent(new InputEvent("input",{...e,bubbles:!0,cancelable:!1}))}handleDelete({event:e,selection:s,isForward:n}){const i={value:this.elementState.value,selection:s},{elementState:a}=this.preprocessor({elementState:i,data:""},n?"deleteForward":"deleteBackward"),o=new R(a,this.options);o.deleteCharacters();const l=this.postprocessor(o,i);if(ae(i,a,o,l)){const[r,c]=a.selection;return e.preventDefault(),this.updateSelectionRange(n?[c,c]:[r,r])}this.upcomingElementState=l}handleInsert(e,s){const{options:n,maxLength:i,elementState:a}=this,[o,l]=a.selection,{elementState:r,data:c=s}=this.preprocessor({data:s,elementState:a},"insert"),u=new R(r,n);try{u.addCharacters(c)}catch{return e.preventDefault()}this.upcomingElementState=this.clampState(this.postprocessor(u,a)),a.value.length>=i&&o===l&&(n.overwriteMode==="replace"&&!$(this.upcomingElementState,a)?this.dispatchInputEvent({inputType:"insertText",data:s}):this.upcomingElementState=null)}handleEnter(e){(this.isTextArea||this.element.isContentEditable)&&this.handleInsert(e,` 7`)}clampState({value:e,selection:s}){const[n,i]=s,a=this.maxLength;return{value:e.slice(0,a),selection:[Math.min(n,a),Math.min(i,a)]}}}const w=new Map,b=new Map;async function z(t,e){const s=e?.elementPredicate??se;b.set(t,s);const n=await s(t);b.get(t)===s&&(w.get(t)?.destroy(),e&&w.set(t,new Se(n,e)))}const ye={unmounted:t=>{w.get(t)?.destroy(),w.delete(t),b.delete(t)},mounted:async(t,{value:e})=>z(t,e),updated:async(t,{value:e,oldValue:s})=>{e!==s&&await z(t,e)}},I=({elementState:t,data:e})=>({elementState:t,data:e?.toUpperCase()??e}),Ee={belgian_national_id:{mask:[/\d/,/\d/,".",/\d/,/\d/,".",/\d/,/\d/,"-",/\d/,/\d/,/\d/,".",/\d/,/\d/],transform:t=>t.replace(/[.-]/g,"")},italian_fiscal_code:{mask:[/[A-Za-z]/,/[A-Za-z]/,/[A-Za-z]/,/[A-Za-z]/,/[A-Za-z]/,/[A-Za-z]/,/[0-9LMNPQRSTUVlmnpqrstuv]/,/[0-9LMNPQRSTUVlmnpqrstuv]/,/[ABCDEHLMPRSTabcdehlmprst]/,/[0-9LMNPQRSTUVlmnpqrstuv]/,/[0-9LMNPQRSTUVlmnpqrstuv]/,/[A-Za-z]/,/[0-9LMNPQRSTUVlmnpqrstuv]/,/[0-9LMNPQRSTUVlmnpqrstuv]/,/[0-9LMNPQRSTUVlmnpqrstuv]/,/[A-Za-z]/],preprocessors:[I]},indian_pan:{mask:[/[A-Za-z]/,/[A-Za-z]/,/[A-Za-z]/,/[ABCFGHJLPTabcfghjlpt]/,/[A-Za-z]/,/\d/,/\d/,/\d/,/\d/,/[A-Za-z]/],preprocessors:[I]},siren:{mask:[/\d/,/\d/,/\d/," ",/\d/,/\d/,/\d/," ",/\d/,/\d/,/\d/],transform:t=>t.replace(/ /g,"")},iban:{mask:t=>{const e=(typeof t=="string"?t:t?.value??"").replace(/ /g,"").slice(0,2).toUpperCase(),{chars:s=40}=W.get(X,e,{}),n=[];for(let i=0;i<s;i++)i>0&&i%4===0&&n.push(" "),n.push(i<2?/[A-Za-z]/:/[A-Z0-9a-z]/);return n},preprocessors:[I],transform:t=>t.replace(/ /g,"")}},ke={key:0},Te=["id","name","placeholder","disabled","value"],Me={key:0,class:"input--errors input--error"},Le={__name:"InputTextMasked",props:J({id:String,name:{type:String,default:"input-formatted-text"},placeholder:{type:String,default:"..."},disabled:{type:Boolean,default:!1},mask:{type:String,required:!0},v:Object},{modelValue:{type:String},modelModifiers:{}}),emits:["update:modelValue"],setup(t){const e=G(t,"modelValue"),{t:s}=K(),n=B(()=>Ee[t.mask]),i=B(()=>e.value&&n.value?_(e.value,n.value):e.value),a=({target:l})=>e.value=n.value?.transform?.(l.value)??l.value,o=()=>t.v?.$touch();return(l,r)=>n.value?(m(),f("div",ke,[Q(j("input",Y({class:"input input--border input--radius",id:t.
7id,name:t.name,placeholder:t.placeholder,disabled:t.disabled,value:i.value},l.$attrs,{onInput:a,onBlur:o}),null,16,Te),[[g(ye),n.value]]),t.v?.$error?(m(),f("p",Me,[t.v.required?.$invalid?(m(),f(y,{key:0},[E(k(g(s)("errors.input_text_required")),1)],64)):t.v.external?.$invalid&&t.v.external.$message?(m(),f(y,{key:1},[E(k(t.v.external.$message),1)],64)):g(s)(`errors.input_${t.mask}_invalid`)?(m(),f(y,{key:2},[E(k(g(s)(`errors.input_${t.mask}_invalid`)),1)],64)):(m(),f(y,{key:3},[E(k(g(s)("errors.input_text_invalid")),1)],64))])):V("",!0)])):V("",!0)}};export{Le as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.