wulf.js 1.8.4 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -21
- package/changelog.md +76 -0
- package/dist/focus-trap.cjs.js +430 -0
- package/dist/focus-trap.cjs.js.map +7 -0
- package/dist/focus-trap.esm.js +407 -0
- package/dist/focus-trap.esm.js.map +7 -0
- package/dist/focus-trap.global.js +433 -0
- package/dist/focus-trap.global.js.map +7 -0
- package/dist/focus-trap.global.min.js +6 -0
- package/dist/focus-trap.global.min.js.map +7 -0
- package/dist/index.cjs.js +1177 -59
- package/dist/index.cjs.js.map +3 -3
- package/dist/index.esm.js +1177 -59
- package/dist/index.esm.js.map +3 -3
- package/dist/index.global.js +1177 -59
- package/dist/index.global.js.map +3 -3
- package/dist/index.global.min.js +4 -1
- package/dist/index.global.min.js.map +4 -4
- package/dist/mask.cjs.js +337 -33
- package/dist/mask.cjs.js.map +3 -3
- package/dist/mask.css +1 -1
- package/dist/mask.css.map +2 -2
- package/dist/mask.esm.js +337 -33
- package/dist/mask.esm.js.map +3 -3
- package/dist/mask.global.js +337 -33
- package/dist/mask.global.js.map +3 -3
- package/dist/mask.global.min.js +4 -1
- package/dist/mask.global.min.js.map +4 -4
- package/dist/masonry.cjs.js +296 -10
- package/dist/masonry.cjs.js.map +3 -3
- package/dist/masonry.esm.js +296 -10
- package/dist/masonry.esm.js.map +3 -3
- package/dist/masonry.global.js +296 -10
- package/dist/masonry.global.js.map +3 -3
- package/dist/masonry.global.min.js +4 -1
- package/dist/masonry.global.min.js.map +4 -4
- package/dist/scroll.cjs.js +332 -9
- package/dist/scroll.cjs.js.map +3 -3
- package/dist/scroll.esm.js +332 -9
- package/dist/scroll.esm.js.map +3 -3
- package/dist/scroll.global.js +332 -9
- package/dist/scroll.global.js.map +3 -3
- package/dist/scroll.global.min.js +4 -1
- package/dist/scroll.global.min.js.map +4 -4
- package/dist/toast.cjs.js +289 -7
- package/dist/toast.cjs.js.map +3 -3
- package/dist/toast.css +1 -1
- package/dist/toast.css.map +2 -2
- package/dist/toast.esm.js +289 -7
- package/dist/toast.esm.js.map +3 -3
- package/dist/toast.global.js +289 -7
- package/dist/toast.global.js.map +3 -3
- package/dist/toast.global.min.js +4 -1
- package/dist/toast.global.min.js.map +4 -4
- package/dist/types/common/AuditableComponent.d.ts +45 -0
- package/dist/types/common/LocalizedComponent.d.ts +54 -0
- package/dist/types/common/i18n.d.ts +39 -0
- package/dist/types/focus-trap/FocusTrap.d.ts +64 -0
- package/dist/types/focus-trap/index.d.ts +3 -0
- package/dist/types/focus-trap/types.d.ts +45 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/mask/BaseInputMask.d.ts +15 -1
- package/dist/types/mask/EmailEngine.d.ts +24 -2
- package/dist/types/mask/InputEmailMask.d.ts +8 -0
- package/dist/types/mask/InputMask.d.ts +9 -0
- package/dist/types/mask/types.d.ts +5 -2
- package/dist/types/masonry/Masonry.d.ts +18 -1
- package/dist/types/masonry/i18n/en.d.ts +2 -0
- package/dist/types/masonry/i18n/fr.d.ts +2 -0
- package/dist/types/masonry/i18n/index.d.ts +9 -0
- package/dist/types/masonry/i18n/types.d.ts +7 -0
- package/dist/types/masonry/index.d.ts +1 -0
- package/dist/types/masonry/types.d.ts +15 -5
- package/dist/types/scroll/ScrollBlock.d.ts +21 -1
- package/dist/types/scroll/i18n/en.d.ts +2 -0
- package/dist/types/scroll/i18n/fr.d.ts +2 -0
- package/dist/types/scroll/i18n/index.d.ts +9 -0
- package/dist/types/scroll/i18n/types.d.ts +11 -0
- package/dist/types/scroll/index.d.ts +2 -0
- package/dist/types/scroll/types.d.ts +9 -3
- package/dist/types/toast/Toast.d.ts +8 -1
- package/dist/types/toast/ToastInstance.d.ts +9 -1
- package/dist/types/toast/i18n/en.d.ts +2 -0
- package/dist/types/toast/i18n/fr.d.ts +2 -0
- package/dist/types/toast/i18n/index.d.ts +9 -0
- package/dist/types/toast/i18n/types.d.ts +7 -0
- package/dist/types/toast/index.d.ts +1 -0
- package/dist/types/toast/types.d.ts +12 -3
- package/package.json +9 -3
package/dist/index.global.min.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
"use strict";var Wulf=(()=>{var _=Object.defineProperty;var ot=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var at=Object.prototype.hasOwnProperty;var X=(d,e)=>{for(var t in e)_(d,t,{get:e[t],enumerable:!0})},lt=(d,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of rt(e))!at.call(d,s)&&s!==t&&_(d,s,{get:()=>e[s],enumerable:!(i=ot(e,s))||i.enumerable});return d};var ht=d=>lt(_({},"__esModule",{value:!0}),d);var gt={};X(gt,{AmountEngine:()=>O,BaseInputMask:()=>L,EmailEngine:()=>R,InputAmountMask:()=>F,InputEmailMask:()=>W,InputMask:()=>P,Mask:()=>J,MaskEngine:()=>D,MaskHistory:()=>x,MaskKeyboard:()=>H,Masonry:()=>tt,Scroll:()=>Q,Toast:()=>et,default:()=>Z,resolveMaskConstructorArgs:()=>I});var J={};X(J,{AmountEngine:()=>O,BaseInputMask:()=>L,EmailEngine:()=>R,InputAmountMask:()=>F,InputEmailMask:()=>W,InputMask:()=>P,Mask:()=>it,MaskEngine:()=>D,MaskHistory:()=>x,MaskKeyboard:()=>H,default:()=>Z,resolveMaskConstructorArgs:()=>I});function I(d,e,t){return e&&typeof e=="object"&&"tagName"in e&&e.tagName==="INPUT"?{wrapper:d||null,input:e,options:t||{}}:{wrapper:null,input:d,options:e&&typeof e=="object"&&!("tagName"in e)?e:{}}}var L=class{constructor(e,t,i){this.ghost=null;this.isWrapperCreated=!1;this.isDestroyed=!1;this.isFocused=!1;this.isDispatchingNativeInput=!1;this.lastTrackedValue="";this.nativeValueDescriptor=null;this.onCutHandler=()=>{};this.mutationObserver=null;this.onBaseCopy=e=>{if(!this.options.copyRaw||this.options.disabled||this.input.type==="password")return;let t=this.input.selectionStart??0,i=this.input.selectionEnd??t,s="";t!==i?s=this.extractRawSnippet(this.input.value.slice(t,i)):s=this.getRawValue(),s&&e.clipboardData&&(e.preventDefault(),e.clipboardData.setData("text/plain",s))};this.onBaseFocus=()=>{this.isFocused=!0,this.options.selectAllOnFocus&&this.input.value.length>0&&setTimeout(()=>{!this.isDestroyed&&document.activeElement===this.input&&this.input.select()},0)};this.onBaseBlur=()=>{this.isFocused=!1};this.onScroll=()=>{this.ghost&&(this.ghost.scrollLeft=this.input.scrollLeft)};let{wrapper:s,input:n,options:o}=I(e,t,i);if(!n||!(n instanceof HTMLElement)||n.tagName!=="INPUT")throw new Error(`[${new.target.name||"InputMask"}] input (HTMLInputElement) est requis.`);this.input=n;let r=this.input.getAttribute("data-mask-create-wrapper")==="true",a=!!(o.createWrapper??r),u=s;if(!u&&a){let b=document.createElement("span");b.className="wulf-mask-wrapper",b.style.display="inline-grid",b.style.gridTemplateColumns="1fr",b.style.gridTemplateRows="1fr",b.style.verticalAlign="middle",b.style.boxSizing="border-box",b.style.position="relative",this.input.parentNode&&this.input.parentNode.insertBefore(b,this.input),b.appendChild(this.input),this.input.style.gridArea="1 / 1 / 2 / 2",this.input.style.boxSizing="border-box",u=b,this.isWrapperCreated=!0}if(!u)throw new Error(`[${new.target.name||"InputMask"}] wrapper (HTMLElement) et input (HTMLInputElement) sont requis, ou activez l'option createWrapper: true.`);this.wrapper=u,this.normalizeInputType();let h=this.getAttr("data-mask-focus-only")==="true",c=this.hasAttr("data-disabled"),l=this.getAttr("data-mask-select-on-focus")==="true",p=this.getAttr("data-mask-copy-raw")==="true",f=this.getAttr("data-mask-align")||this.getAttr("data-align"),{disabled:m,align:g,...w}=o,v=m!==void 0?m:!!c,k=this.input.type==="password";this.options={...w,createWrapper:a,showMaskOnFocus:o.showMaskOnFocus??h??!1,selectAllOnFocus:o.selectAllOnFocus??l??!1,copyRaw:k?!1:o.copyRaw??p??!1,disabled:v,align:g??(f||void 0),emitNativeInput:o.emitNativeInput??!0},this.options.showMaskOnFocus&&this.wrapper.classList.add("mask-focus-only"),this.options.disabled&&this.wrapper.setAttribute("data-disabled","true"),this.options.align&&this.setAlign(this.options.align),this.createGhost(),this.hookValueProperty(),this.bindBaseEvents(),this.initMutationObserver()}getAttr(e){return this.input.getAttribute(e)||this.wrapper.getAttribute(e)}hasAttr(e){return this.wrapper.hasAttribute(e)||this.input.hasAttribute(e)}hasNativePlaceholder(){return!!(this.input.placeholder&&this.input.placeholder.trim().length>0)}shouldHideGhostForPlaceholder(e){return!this.isFocused&&e&&this.hasNativePlaceholder()}bindBaseEvents(){this.input.addEventListener("copy",this.onBaseCopy),this.input.addEventListener("focus",this.onBaseFocus),this.input.addEventListener("blur",this.onBaseBlur)}extractRawSnippet(e){return e}initMutationObserver(){if(typeof MutationObserver>"u")return;this.mutationObserver=new MutationObserver(t=>{for(let i of t)i.type==="attributes"&&i.attributeName&&this.handleAttributeMutation(i.attributeName)});let e={attributes:!0,attributeFilter:["data-mask","data-mask-placeholder","data-mask-focus-only","data-mask-strict","data-mask-select-on-focus","data-mask-copy-raw","data-mask-pad-decimals","data-mask-auto-lowercase","data-mask-cycle-suggestions","data-disabled","data-mask-align","data-align","placeholder"]};this.mutationObserver.observe(this.wrapper,e),this.input!==this.wrapper&&this.mutationObserver.observe(this.input,e)}setAlign(e){let t=e||void 0,i=this.wrapper.getAttribute("data-align");this.options.align===t&&i===(e||null)||(this.options.align=t,this.wrapper.classList.remove("align-left","align-right","align-center"),e?(this.wrapper.classList.add(`align-${e}`),this.wrapper.getAttribute("data-align")!==e&&this.wrapper.setAttribute("data-align",e)):this.wrapper.hasAttribute("data-align")&&this.wrapper.removeAttribute("data-align"),this.syncGhostStyles())}handleAttributeMutation(e){if(e==="data-disabled"){let t=this.hasAttr("data-disabled");t!==!!this.options.disabled&&this.setDisabled(t)}else if(e==="data-mask-focus-only"){let t=this.getAttr("data-mask-focus-only")==="true";t!==!!this.options.showMaskOnFocus&&this.setShowMaskOnFocus(t)}else if(e==="data-mask-select-on-focus")this.options.selectAllOnFocus=this.getAttr("data-mask-select-on-focus")==="true";else if(e==="data-mask-copy-raw")this.options.copyRaw=this.getAttr("data-mask-copy-raw")==="true";else if(e==="data-mask-align"||e==="data-align"){let t=this.getAttr("data-mask-align")||this.getAttr("data-align");t!==(this.options.align??null)&&this.setAlign(t)}}normalizeInputType(){let e=["number","email","date","datetime-local","month","week","time","color","file","range"];if(this.input.type&&e.includes(this.input.type.toLowerCase())){let t=this.input.type.toLowerCase();this.input.type="text",t==="number"&&(this.input.inputMode="numeric")}}createGhost(){let e=this.wrapper.querySelector(".mask-ghost");e&&e.remove(),this.ghost=document.createElement("div"),this.ghost.className="mask-ghost",this.ghost.setAttribute("aria-hidden","true"),this.ghost.style.display="flex",this.ghost.style.alignItems="center",this.wrapper.appendChild(this.ghost),this.wrapper.classList.add("has-ghost"),this.syncGhostStyles()}syncGhostStyles(){if(!this.ghost||typeof window>"u")return;let e=window.getComputedStyle(this.input);if(!e)return;this.ghost.style.fontFamily=e.fontFamily,this.ghost.style.fontSize=e.fontSize,this.ghost.style.fontWeight=e.fontWeight,this.ghost.style.fontStyle=e.fontStyle,this.ghost.style.letterSpacing=e.letterSpacing,this.ghost.style.lineHeight=e.lineHeight,this.ghost.style.paddingTop=e.paddingTop,this.ghost.style.paddingBottom=e.paddingBottom,this.ghost.style.paddingLeft=e.paddingLeft,this.ghost.style.paddingRight=e.paddingRight,this.ghost.style.borderTopWidth=e.borderTopWidth,this.ghost.style.borderBottomWidth=e.borderBottomWidth,this.ghost.style.borderLeftWidth=e.borderLeftWidth,this.ghost.style.borderRightWidth=e.borderRightWidth,this.ghost.style.borderTopStyle=e.borderTopStyle==="none"?"none":"solid",this.ghost.style.borderBottomStyle=e.borderBottomStyle==="none"?"none":"solid",this.ghost.style.borderLeftStyle=e.borderLeftStyle==="none"?"none":"solid",this.ghost.style.borderRightStyle=e.borderRightStyle==="none"?"none":"solid",this.ghost.style.borderColor="transparent",this.ghost.style.boxSizing=e.boxSizing,this.ghost.style.textAlign=e.textAlign,this.ghost.style.direction=e.direction;let t=e.direction==="rtl"||this.input.getAttribute("dir")==="rtl"||this.wrapper.getAttribute("dir")==="rtl";e.textAlign==="right"||e.textAlign==="end"||t&&e.textAlign!=="left"&&e.textAlign!=="center"?this.ghost.style.justifyContent="flex-end":e.textAlign==="center"?this.ghost.style.justifyContent="center":this.ghost.style.justifyContent="flex-start"}setNativeValue(e){this.nativeValueDescriptor&&this.nativeValueDescriptor.set?this.nativeValueDescriptor.set.call(this.input,e):this.input.value=e}dispatchNativeInput(){if(!(this.isDestroyed||typeof window>"u")&&this.options.emitNativeInput!==!1){this.isDispatchingNativeInput=!0;try{let e=this.input._valueTracker;e&&typeof e.setValue=="function"&&e.setValue(this.lastTrackedValue),this.lastTrackedValue=this.input.value,this.input.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))}finally{this.isDispatchingNativeInput=!1}}}hookValueProperty(){try{let e=HTMLInputElement.prototype,t=Object.getOwnPropertyDescriptor(e,"value");if(!t||!t.set||!t.get)return;this.nativeValueDescriptor=t;let i=this;Object.defineProperty(this.input,"value",{get(){return t.get.call(this)},set(s){let n=String(s??"");t.set.call(this,n),!i.isDestroyed&&i.onNativeValueSet(n)},configurable:!0})}catch{}}unhookValueProperty(){try{delete this.input.value}catch{}}setShowMaskOnFocus(e){this.options.showMaskOnFocus=e,this.wrapper.classList.toggle("mask-focus-only",e)}disabled(e){if(e===void 0)return!!this.options.disabled;this.setDisabled(e)}setDisabled(e){this.options.disabled=!!e,this.options.disabled?this.wrapper.setAttribute("data-disabled","true"):this.wrapper.removeAttribute("data-disabled"),this.onDisabledChange(this.options.disabled)}getWrapper(){return this.wrapper}getInput(){return this.input}getGhost(){return this.ghost}getElements(){return{wrapper:this.wrapper,input:this.input,ghost:this.ghost}}getValue(){return this.input.value}getRawValue(){return this.input.value}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),this.input.removeEventListener("copy",this.onBaseCopy),this.input.removeEventListener("focus",this.onBaseFocus),this.input.removeEventListener("blur",this.onBaseBlur),this.unhookValueProperty(),this.ghost&&(this.ghost.remove(),this.ghost=null),this.isWrapperCreated&&this.wrapper?(this.input.style.gridArea="",this.input.style.boxSizing="",this.wrapper.parentNode&&this.wrapper.parentNode.insertBefore(this.input,this.wrapper),this.wrapper.remove()):this.wrapper&&(this.wrapper.removeAttribute("data-mask"),this.wrapper.removeAttribute("data-disabled"),this.wrapper.classList.remove("is-complete","is-focused","mask-focus-only","has-selection","has-ghost")))}};var ut={9:{pattern:/[0-9]/},a:{pattern:/[a-zA-Z]/},A:{pattern:/[a-zA-Z]/,transform:d=>d.toUpperCase()},"*":{pattern:/[a-zA-Z0-9]/},"#":{pattern:/[a-zA-Z0-9]/,transform:d=>d.toUpperCase()}},D=class d{constructor(e,t={}){this.patterns=[];this.subEngines=[];this.activeEngine=null;this.slots=[];this.fullMaskTemplate="";this.prefixSlotsCount=0;this.prefixString="";this.strict=!0;this.autoLowercase=!1;let i=t||{};this.placeholderChar=i.placeholderChar||"_",this.tokens={...ut,...i.tokens||{}},this.strict=i.strict!==!1,this.autoLowercase=i.autoLowercase??!1,this.pattern="",this.compile(e)}static format(e,t,i={}){return!t||Array.isArray(t)&&t.length===0?e??"":new d(t,i||{}).format(e??"")}compile(e){if(e!==void 0&&(Array.isArray(e)?(this.patterns=[...e],this.pattern=this.patterns[0]||""):(this.patterns=[],this.pattern=e)),this.patterns.length>0)return this.subEngines=this.patterns.map(s=>new d(s,{placeholderChar:this.placeholderChar,tokens:this.tokens,strict:this.strict,autoLowercase:this.autoLowercase})),this.activeEngine=this.subEngines[0],this.slots=this.activeEngine.slots,this.fullMaskTemplate=this.activeEngine.fullMaskTemplate,this.prefixSlotsCount=this.activeEngine.prefixSlotsCount,this.prefixString=this.activeEngine.prefixString,this.slots;this.subEngines=[],this.activeEngine=null,this.slots=[];let t="",i=!0;for(let s=0;s<this.pattern.length;s++){let n=this.pattern[s],o=!1;n==="\\"&&s+1<this.pattern.length&&(o=!0,s++,n=this.pattern[s]);let r=o?void 0:this.tokens[n];r?(i=!1,this.slots.push({char:n,isStatic:!1,isPrefix:!1,token:r,placeholder:this.placeholderChar}),t+=this.placeholderChar):(this.slots.push({char:n,isStatic:!0,isPrefix:i,placeholder:n}),t+=n)}this.fullMaskTemplate=t,this.prefixSlotsCount=0,this.prefixString="";for(let s of this.slots)if(s.isPrefix)this.prefixSlotsCount++,this.prefixString+=s.char;else break;return this.slots}selectEngine(e){if(this.subEngines.length<=1)return this;let t=String(e??""),i=this.subEngines.filter(a=>{let u=a.getPrefix();return u.length>0&&t.toLowerCase().startsWith(u.trim().toLowerCase())}),s=i.length>0?i:this.subEngines,n=[...s].sort((a,u)=>u.getEditableCount()-a.getEditableCount())[0],r=(n?n.extractRaw(t):t).length;for(let a of s)if(a.getEditableCount()>=r)return this.activeEngine=a,a;return this.activeEngine=s[s.length-1],this.activeEngine}getPrefix(){return this.activeEngine?this.activeEngine.getPrefix():this.prefixString}getPrefixLength(){return this.activeEngine?this.activeEngine.getPrefixLength():this.prefixSlotsCount}getFullMaskTemplate(){return this.activeEngine?this.activeEngine.getFullMaskTemplate():this.fullMaskTemplate}getEditableCount(){return this.subEngines.length>0?Math.max(...this.subEngines.map(e=>e.getEditableCount())):this.activeEngine?this.activeEngine.getEditableCount():this.slots.filter(e=>!e.isStatic).length}isNumericOnly(){if(this.subEngines.length>0)return this.subEngines.every(i=>i.isNumericOnly());let t=(this.activeEngine?this.activeEngine.slots:this.slots).filter(i=>!i.isStatic);return t.length===0?!1:t.every(i=>i.char==="9"||i.token&&i.token.pattern.test("0")&&!i.token.pattern.test("a")&&!i.token.pattern.test("Z"))}setStrict(e){this.strict=e}isStrict(){return this.strict}extractRaw(e){if(this.subEngines.length>0){let o=this.selectEngine(e);if(o!==this)return o.extractRaw(e)}let t=String(e??"");if(!t)return"";let i="",s=0,n=0;if(this.prefixSlotsCount>0){for(;s<t.length&&(t[s]===" "||t[s]===" ");)s++;let o=0;for(;s<t.length&&o<this.prefixSlotsCount;){let r=this.slots[o].char,a=t[s];if(a.toUpperCase()===r.toUpperCase())s++,o++;else if(r===" "&&a!==" ")o++;else break}n=this.prefixSlotsCount}for(;s<t.length&&n<this.slots.length;){let o=this.slots[n],r=t[s];if(o.isStatic)r.toUpperCase()===o.char.toUpperCase()&&s++,n++;else if(o.token&&o.token.pattern.test(r)){let a=o.token.transform?o.token.transform(r):r;this.autoLowercase&&!o.token.transform&&(a=a.toLowerCase()),i+=a,s++,n++}else this.strict?s++:(i+=this.autoLowercase?r.toLowerCase():r,s++,n++)}if(!this.strict&&s<t.length){let o=t.slice(s);i+=this.autoLowercase?o.toLowerCase():o}return i}format(e){if(this.subEngines.length>0){let o=this.selectEngine(e);if(o!==this)return o.format(e)}let t=String(e??"");if(!this.slots.length)return t;let i=this.extractRaw(t);if(i.length===0)return this.prefixString;let s="",n=0;for(let o=0;o<this.slots.length;o++){let r=this.slots[o];if(r.isStatic){let a=n<i.length,u=n===0&&!!r.isPrefix,h=n>0&&n===i.length;if(a||u||h)s+=r.char;else break}else if(n<i.length){let a=i[n],u=r.token?.transform?r.token.transform(a):a;this.autoLowercase&&!r.token?.transform&&(u=u.toLowerCase()),s+=u,n++}else break}if(!this.strict&&n<i.length){let o=i.substring(n);s+=this.autoLowercase?o.toLowerCase():o}return s}getRemainingMask(e){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getRemainingMask(e):this.fullMaskTemplate?e.length>=this.fullMaskTemplate.length?e:e+this.fullMaskTemplate.substring(e.length):""}mapCursorPosition(e,t,i){if(this.activeEngine&&this.activeEngine!==this)return this.activeEngine.mapCursorPosition(e,t,i);let s=this.prefixSlotsCount,n=String(e??""),o=String(i??"");if(t<=0||!o)return s;let a=this.extractRaw(n.slice(0,t)).length;if(a===0)return Math.max(s,Math.min(this.getNextEditablePosition(0),o.length));let u=0,h=o.length;for(let c=0;c<o.length&&c<this.slots.length;c++)if(!this.slots[c].isStatic&&(u++,u===a)){h=c+1;break}for(;h<o.length&&this.slots[h]&&this.slots[h].isStatic;)h++;return Math.max(s,Math.min(h,o.length))}isSeparatorAt(e){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.isSeparatorAt(e):e>=0&&e<this.slots.length?this.slots[e].isStatic:!1}getNextEditablePosition(e){if(this.activeEngine&&this.activeEngine!==this)return this.activeEngine.getNextEditablePosition(e);let t=Math.max(0,e);for(let i=t;i<this.slots.length;i++)if(!this.slots[i].isStatic)return i;return this.slots.length}getSlotAt(e){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getSlotAt(e):this.slots[e]}getSlots(){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getSlots():this.slots}};var x=class{constructor(e=50){this.stack=[];this.index=-1;this.maxDepth=e}push(e,t){let i=this.getCurrent();if(i&&i.raw===e){i.cursor=t;return}this.stack=this.stack.slice(0,this.index+1),this.stack.push({raw:e,cursor:t}),this.stack.length>this.maxDepth&&this.stack.shift(),this.index=this.stack.length-1}updateCurrentCursor(e){let t=this.getCurrent();t&&(t.cursor=e)}undo(){return this.canUndo()?(this.index--,this.stack[this.index]):null}redo(){return this.canRedo()?(this.index++,this.stack[this.index]):null}canUndo(){return this.index>0}canRedo(){return this.index>=0&&this.index<this.stack.length-1}getCurrent(){return this.index>=0&&this.index<this.stack.length?this.stack[this.index]:null}clear(){this.stack=[],this.index=-1}};var H=class{constructor(e){this.delegate=e}handleKeyDown(e){let t=this.delegate.getInput(),i=this.delegate.getEngine(),s=this.delegate.getHistory(),n=i.getPrefixLength(),o=t.selectionStart??0,r=t.selectionEnd??o;if((e.ctrlKey||e.metaKey)&&(e.key==="z"||e.key==="Z")&&!e.shiftKey){e.preventDefault(),this.delegate.undo();return}if((e.ctrlKey||e.metaKey)&&(e.key==="y"||e.key==="Y")||(e.ctrlKey||e.metaKey)&&e.shiftKey&&(e.key==="z"||e.key==="Z")){e.preventDefault(),this.delegate.redo();return}s.updateCurrentCursor(o);let a=e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey,u=r>o;if(a&&!u){let l=i.getSlots(),p=o<l.length&&l[o].isStatic&&l[o].char===e.key,f=o>0&&o-1<l.length&&l[o-1].isStatic&&l[o-1].char===e.key;if(p||f){e.preventDefault();let g=p?o:o-1,w=i.getNextEditablePosition(g+1);this.delegate.applyMask(t.value,w,!0);return}let m=-1;for(let g=o;g<l.length;g++)if(l[g].isStatic){l[g].char===e.key&&(m=g);break}if(m!==-1){e.preventDefault();let g=m-1;for(;g>=n&&!l[g].isStatic;)g--;g++;let w=m-g,v=t.value.slice(g,o);if(l.slice(g,m).every(y=>!y.token||y.token.pattern.test("0"))&&w>v.length&&v.length>0){let y=w-v.length,E="0".repeat(y)+v,C=t.value.slice(m),Y=t.value.slice(0,g)+E+C,M=i.getNextEditablePosition(m+1);this.delegate.applyMask(Y,M,!0);return}let b=i.getNextEditablePosition(m+1);this.delegate.applyMask(t.value,b,!0);return}}if(a&&i.isStrict()){let l=i.getEditableCount();if(l>0){let p=i.extractRaw(t.value),f=l-p.length;if(r>o){let m=i.extractRaw(t.value.slice(o,r));f=l-(p.length-m.length)}if(f<=0){e.preventDefault();return}}}if(r>o){if(e.key==="Backspace"||e.key==="Delete"){e.preventDefault();let l=t.value,p=l.slice(0,o)+l.slice(r);this.delegate.applyMask(p,Math.max(n,o));return}return}if(e.key==="ArrowLeft"&&!e.shiftKey&&o<=n){e.preventDefault(),t.setSelectionRange(n,n);return}if(e.key==="Home"&&!e.shiftKey){e.preventDefault(),t.setSelectionRange(n,n);return}if(e.key==="Backspace"&&o<=n){e.preventDefault(),t.setSelectionRange(n,n);return}if(e.key==="Delete"&&o<n){e.preventDefault(),t.setSelectionRange(n,n);return}if(e.key==="Backspace"&&(e.ctrlKey||e.altKey||e.metaKey)){if(e.preventDefault(),o<=n){t.setSelectionRange(n,n);return}let l=o-1;for(;l>=n&&i.isSeparatorAt(l);)l--;for(;l>=n&&!i.isSeparatorAt(l);)l--;let p=Math.max(n,l+1),f=t.value,m=f.slice(0,p)+f.slice(o);this.delegate.applyMask(m,p);return}if(e.key==="Delete"&&(e.ctrlKey||e.altKey||e.metaKey)){e.preventDefault();let l=t.value;if(o>=l.length)return;let p=o;for(;p<l.length&&i.isSeparatorAt(p);)p++;for(;p<l.length&&!i.isSeparatorAt(p);)p++;for(;p<l.length&&i.isSeparatorAt(p);)p++;let f=p,m=l.slice(0,o)+l.slice(f);this.delegate.applyMask(m,o);return}if(e.key==="Backspace"&&o>n){if(i.isSeparatorAt(o-1)){e.preventDefault();let l=o-1;for(;l>n&&i.isSeparatorAt(l-1);)l--;if(l>n){let p=t.value,f=p.slice(0,l-1)+p.slice(o);this.delegate.applyMask(f,l-1)}else this.delegate.applyMask("",n)}return}if(e.key==="Delete"&&o<t.value.length){if(i.isSeparatorAt(o)){e.preventDefault();let l=o;for(;l<t.value.length&&i.isSeparatorAt(l);)l++;if(l<t.value.length){let p=t.value,f=p.slice(0,l)+p.slice(l+1);this.delegate.applyMask(f,o)}}return}}handleKeyUp(e){let t=this.delegate.getInput(),i=this.delegate.getHistory();(e.key==="ArrowLeft"||e.key==="ArrowRight"||e.key==="Home")&&!e.shiftKey&&this.delegate.enforceMinCursor(),i.updateCurrentCursor(t.selectionStart??0)}};var P=class extends L{constructor(t,i,s){let n=I(t,i,s),o=n.wrapper,r=n.input,a=n.options,u=o?.getAttribute("data-mask")||r?.getAttribute("data-mask"),h=a.mask||u||"";typeof h=="string"&&h.includes("|")&&(h=h.split("|").map(y=>y.trim()));let c=a.placeholderChar||o?.getAttribute("data-mask-placeholder")||r?.getAttribute("data-mask-placeholder")||"_",l=o?.hasAttribute("data-disabled")||r?.hasAttribute("data-disabled"),p=o?.getAttribute("data-mask-strict")||r?.getAttribute("data-mask-strict"),f=o?.getAttribute("data-mask-auto-lowercase")==="true"||r?.getAttribute("data-mask-auto-lowercase")==="true",m=o?.getAttribute("data-mask-infer-inputmode")??r?.getAttribute("data-mask-infer-inputmode"),g=a.inferInputMode??(m!==null?m!=="false":!0),{disabled:w,...v}=a,k=w!==void 0?w:l?!0:!h||Array.isArray(h)&&h.length===0,b={...v,mask:h,placeholderChar:c,strict:a.strict??(p!==null?p!=="false":!0),autoLowercase:a.autoLowercase??f??!1,disabled:k,resetHistoryOnMaskChange:a.resetHistoryOnMaskChange??!1,inferInputMode:g,onInput:a.onInput||a.oninput,onChange:a.onChange||a.onchange,onComplete:a.onComplete||a.oncomplete};super(o,r,b);this.isComposing=!1;this.isUndoingRedoing=!1;this.isMouseDown=!1;this.isApplyingMask=!1;this.lastValue="";this.lastInternalRemainingMask="";this.isNotifying=!1;this.hasPendingNotification=!1;this.onChangeNativeHandler=()=>{};this.wasInputModeInferred=!1;this.history=new x,this.engine=new D(this.options.mask||"",{placeholderChar:this.options.placeholderChar,tokens:this.options.tokens,strict:this.options.strict,autoLowercase:this.options.autoLowercase}),this.options.inferInputMode&&!this.input.hasAttribute("inputmode")&&this.engine.isNumericOnly()&&(this.input.inputMode="numeric",this.wasInputModeInferred=!0),this.keyboard=new H({getInput:()=>this.input,getEngine:()=>this.engine,getHistory:()=>this.history,applyMask:(y,E,C)=>this.applyMask(y,E,C),undo:()=>this.undo(),redo:()=>this.redo(),enforceMinCursor:()=>this.enforceMinCursor()}),this.bindEvents(),this.lastValue=this.input.value,this.syncInitialValue()}extractRawSnippet(t){return this.engine.extractRaw(t)}static format(t,i,s={}){return D.format(t,i,s)}onNativeValueSet(t){this.options.disabled?this.checkValueChange():this.applyMask(t,t.length)}onDisabledChange(t){t?(this.wrapper.removeAttribute("data-mask"),this.wrapper.classList.remove("is-complete","has-selection"),this.ghost&&(this.ghost.textContent=""),this.checkValueChange()):this.applyMask(this.input.value,this.input.selectionStart??this.input.value.length)}bindEvents(){this.handleInput=this.handleInput.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onPaste=this.onPaste.bind(this),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this),this.onClick=this.onClick.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onSelect=this.onSelect.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onCompositionStart=this.onCompositionStart.bind(this),this.onCompositionEnd=this.onCompositionEnd.bind(this),this.onScroll=this.onScroll.bind(this),this.onBeforeInput=this.onBeforeInput.bind(this),this.onCutHandler=()=>{setTimeout(()=>{if(!this.isDestroyed)if(this.options.disabled)this.checkValueChange();else{let t=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,t)}},0)},this.onChangeNativeHandler=()=>{this.isDestroyed||this.checkValueChange()},this.input.addEventListener("beforeinput",this.onBeforeInput),this.input.addEventListener("input",this.handleInput),this.input.addEventListener("keydown",this.onKeyDown),this.input.addEventListener("paste",this.onPaste),this.input.addEventListener("focus",this.onFocus),this.input.addEventListener("blur",this.onBlur),this.input.addEventListener("click",this.onClick),this.input.addEventListener("keyup",this.onKeyUp),this.input.addEventListener("select",this.onSelect),this.input.addEventListener("mousedown",this.onMouseDown),window.addEventListener("mouseup",this.onMouseUp),this.input.addEventListener("compositionstart",this.onCompositionStart),this.input.addEventListener("compositionend",this.onCompositionEnd),this.input.addEventListener("scroll",this.onScroll),this.input.addEventListener("cut",this.onCutHandler),this.input.addEventListener("change",this.onChangeNativeHandler),this.input.form&&(this.onFormResetHandler=()=>{setTimeout(()=>{this.isDestroyed||(this.options.disabled?this.checkValueChange():this.syncInitialValue())},0)},this.input.form.addEventListener("reset",this.onFormResetHandler))}destroy(){this.isDestroyed||(this.input.removeEventListener("beforeinput",this.onBeforeInput),this.input.removeEventListener("input",this.handleInput),this.input.removeEventListener("keydown",this.onKeyDown),this.input.removeEventListener("paste",this.onPaste),this.input.removeEventListener("focus",this.onFocus),this.input.removeEventListener("blur",this.onBlur),this.input.removeEventListener("click",this.onClick),this.input.removeEventListener("keyup",this.onKeyUp),this.input.removeEventListener("select",this.onSelect),this.input.removeEventListener("mousedown",this.onMouseDown),window.removeEventListener("mouseup",this.onMouseUp),this.input.removeEventListener("compositionstart",this.onCompositionStart),this.input.removeEventListener("compositionend",this.onCompositionEnd),this.input.removeEventListener("scroll",this.onScroll),this.input.removeEventListener("cut",this.onCutHandler),this.input.removeEventListener("change",this.onChangeNativeHandler),this.input.form&&this.onFormResetHandler&&this.input.form.removeEventListener("reset",this.onFormResetHandler),this.wasInputModeInferred&&this.input.getAttribute("inputmode")==="numeric"&&this.input.removeAttribute("inputmode"),this.history.clear(),super.destroy())}setStrict(t){this.options.strict=t,this.engine.setStrict(t),this.options.disabled||this.applyMask(this.input.value,this.input.selectionStart??this.input.value.length)}isStrict(){return this.engine.isStrict()}setMask(t,i){let s=typeof i=="boolean"?i:i&&typeof i=="object"&&i.strict!==void 0?i.strict:this.options.strict,n=i&&typeof i=="object"&&i.resetHistory!==void 0?i.resetHistory:!!this.options.resetHistoryOnMaskChange;if(!((!t||Array.isArray(t)&&t.length===0)&&this.options.disabled&&(!this.options.mask||this.options.mask===""))){if(!t||Array.isArray(t)&&t.length===0){this.options.mask="",this.options.strict=s,this.engine.setStrict(s??!0),this.engine.compile(""),n&&this.history.clear(),this.setDisabled(!0);return}this.options.mask=t,this.options.strict=s,this.engine.setStrict(s??!0),this.engine.compile(t),n&&this.history.clear(),this.setDisabled(!1)}}handleAttributeMutation(t){if(super.handleAttributeMutation(t),t==="data-mask"){let i=this.getAttr("data-mask");if(i===this.lastInternalRemainingMask)return;let s=Array.isArray(this.options.mask)?this.options.mask.join("|"):this.options.mask||"";if(i===s)return;if(i){let n=i.includes("|")?i.split("|").map(o=>o.trim()):i;this.setMask(n)}else this.setMask(null)}else if(t==="data-mask-strict"){let i=this.getAttr("data-mask-strict");this.setStrict(i!=="false")}else t==="data-mask-auto-lowercase"?(this.options.autoLowercase=this.getAttr("data-mask-auto-lowercase")==="true",this.engine.compile(this.options.mask||""),this.applyMask(this.input.value,this.input.selectionStart??this.input.value.length)):t==="placeholder"&&this.updateGhost(this.input.value)}setValue(t){let i=t!=null?String(t):"";if(this.options.disabled){this.input.value=i,this.checkValueChange();return}this.applyMask(i,i.length)}getRawValue(){return this.engine.extractRaw(this.input.value)}isComplete(){return this.options.disabled?!0:this.getRawValue().length>=this.engine.getEditableCount()}get onInput(){return this.options.onInput}set onInput(t){this.options.onInput=t}undo(){if(this.options.disabled)return;let t=this.history.undo();t&&(this.isUndoingRedoing=!0,this.applyMask(t.raw,t.cursor),this.isUndoingRedoing=!1)}redo(){if(this.options.disabled)return;let t=this.history.redo();t&&(this.isUndoingRedoing=!0,this.applyMask(t.raw,t.cursor),this.isUndoingRedoing=!1)}checkSelection(){if(this.options.disabled)return;let t=this.input.selectionStart??0,i=this.input.selectionEnd??t,s=t!==i;this.wrapper.classList.toggle("has-selection",s)}onBeforeInput(t){if(!this.options.disabled&&!this.isComposing&&this.engine.isStrict()&&t.inputType!=="insertFromPaste"&&t.inputType&&t.inputType.startsWith("insert")){let i=this.engine.getEditableCount();if(i>0){let s=this.getRawValue(),n=this.input.selectionStart??0,o=this.input.selectionEnd??n,r=Math.max(0,i-s.length);if(o>n){let a=this.engine.extractRaw(this.input.value.slice(n,o));r=Math.max(0,i-(s.length-a.length))}r<=0&&t.preventDefault()}}}handleInput(t){if(this.isDispatchingNativeInput||this.isComposing)return;if(!!(this.options.onInput||this.options.oninput)&&this.input.value!==this.lastValue&&this.checkValueChange(),this.options.disabled){this.checkValueChange();return}let s=this.history.getCurrent(),n=this.engine.getEditableCount();if(n>0&&this.engine.isStrict()&&s&&s.raw.length>=n&&this.engine.extractRaw(this.input.value).length>n){this.applyMask(s.raw,s.cursor);return}let o=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,o),this.checkSelection()}onKeyDown(t){this.options.disabled||this.keyboard.handleKeyDown(t)}onMouseDown(){this.isMouseDown=!0}onMouseUp(){this.isMouseDown=!1,this.checkSelection()}onPaste(t){if(this.options.disabled){setTimeout(()=>{this.isDestroyed||this.checkValueChange()},0);return}t.preventDefault(),this.history.updateCurrentCursor(this.input.selectionStart??0);let s=(t.clipboardData?.getData("text")||"").trim();if(!s)return;let n=this.engine.getPrefixLength(),o=this.input.selectionStart??0,r=this.input.selectionEnd??o,a=this.input.value,u=this.engine.getEditableCount(),h=this.getRawValue(),l=this.engine.getPrefix().replace(/[\s.-]+/g,"").toUpperCase(),p=s.replace(/[\s.-]+/g,"").toUpperCase(),f=l.length>0&&p.startsWith(l),m=a.slice(0,Math.max(n,o)).replace(/[\s.-]+/g,"").toUpperCase(),g=m.length>=2&&p.startsWith(m),w=Math.max(n,o),v=Math.max(n,r);(f||g)&&(w=0,v=a.length);let k=Math.max(0,u-h.length);if(w!==v){let E=this.engine.extractRaw(a.slice(w,v));k=Math.max(0,u-(h.length-E.length))}if(this.engine.isStrict()&&k<=0)return;let b,y;w===0&&v===a.length?(b=s,y=s.length):(b=a.slice(0,w)+s+a.slice(v),y=w+s.length),this.applyMask(b,y),this.checkSelection()}onFocus(){this.syncGhostStyles(),this.wrapper.classList.add("is-focused"),!this.options.disabled&&!this.isMouseDown&&this.enforceMinCursor(),this.updateGhost(this.input.value),this.checkSelection()}onBlur(){this.wrapper.classList.remove("is-focused","has-selection"),this.input.type==="password"&&this.history.clear(),this.updateGhost(this.input.value)}onClick(){this.options.disabled||this.enforceMinCursor(),this.history.updateCurrentCursor(this.input.selectionStart??0),this.checkSelection()}onKeyUp(t){this.options.disabled||this.keyboard.handleKeyUp(t),this.checkSelection()}onSelect(){this.history.updateCurrentCursor(this.input.selectionStart??0),this.checkSelection()}onCompositionStart(){this.isComposing=!0}onCompositionEnd(){if(this.isComposing=!1,this.options.disabled)return;let t=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,t),this.checkSelection()}enforceMinCursor(){let t=this.engine.getPrefixLength();if(t<=0)return;let i=this.input.selectionStart??0,s=this.input.selectionEnd??i;i===s&&i<t&&this.input.setSelectionRange(t,t)}updateGhost(t){if(!this.ghost)return;if(this.options.disabled){this.ghost.textContent="";return}let i=!t||t===this.engine.getPrefix();if(this.shouldHideGhostForPlaceholder(i)){this.ghost.textContent="";return}let s=this.engine.getFullMaskTemplate(),n=s.length>t.length?s.substring(t.length):"";this.ghost.textContent="";let o=document.createElement("span");o.className="mask-ghost-typed",o.textContent=t;let r=document.createElement("span");r.className="mask-ghost-remaining",r.textContent=n,this.ghost.appendChild(o),this.ghost.appendChild(r),this.ghost.scrollLeft=this.input.scrollLeft}applyMask(t,i,s=!1){if(this.options.disabled||this.isApplyingMask)return;this.isApplyingMask=!0;let n="",o=!1;try{n=this.engine.format(t);let r=this.engine.getRemainingMask(n);this.input.value=n,this.lastInternalRemainingMask=r,this.wrapper.setAttribute("data-mask",r),this.updateGhost(n);let a=this.engine.getPrefixLength(),u;if(s||this.isUndoingRedoing)u=Math.max(a,Math.min(i,n.length));else{let h=this.engine.mapCursorPosition(t,i,n);u=Math.max(a,h)}this.input.setSelectionRange(u,u),o=this.isComplete(),this.wrapper.classList.toggle("is-complete",o),!this.isUndoingRedoing&&this.input.type!=="password"&&this.history.push(this.getRawValue(),u)}finally{this.isApplyingMask=!1}this.checkValueChange()}syncInitialValue(){if(this.options.disabled){this.wrapper.removeAttribute("data-mask"),this.ghost&&(this.ghost.textContent=""),this.lastValue=this.input.value,this.checkValueChange();return}this.syncGhostStyles();let t=this.input.value||"";if(t)this.applyMask(t,t.length);else{let i=this.engine.getPrefixLength();if(i>0)this.applyMask("",i);else{this.input.type!=="password"&&this.history.push("",0);let s=this.engine.getFullMaskTemplate();this.lastInternalRemainingMask=s,this.wrapper.setAttribute("data-mask",s),this.updateGhost(""),this.checkValueChange()}}}checkValueChange(t=!1){if(!(this.input.value===this.lastValue&&!t&&!this.hasPendingNotification)){if(this.isNotifying){this.hasPendingNotification=!0;return}this.isNotifying=!0;try{for(;this.input.value!==this.lastValue||this.hasPendingNotification||t;){this.hasPendingNotification=!1,t=!1;let s=this.input.value;this.lastValue=s;let n=this.options.disabled?s:this.getRawValue(),o=this.options.disabled?0:this.engine.getEditableCount(),r=this.isComplete(),a={value:s,rawValue:n,isComplete:r,totalSlots:o,filledSlots:this.options.disabled?s.length:n.length},u=this.options.onInput||this.options.oninput;u&&u(s,a),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:a})),this.dispatchNativeInput();let h=this.options.onChange||this.options.onchange;h&&h(a),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:a}));let c=this.options.onComplete||this.options.oncomplete;r&&(c&&c(a),this.input.dispatchEvent(new CustomEvent("mask:complete",{bubbles:!0,detail:a})))}}finally{this.isNotifying=!1}}}};var O=class d{constructor(e={}){let t=e.currency??"";!t&&e.unit&&(t=e.unit);let i=t==="$"||t==="\xA3"||t==="\xA5"?"prefix":"suffix";this.options={currency:t,unit:e.unit??t,currencyPosition:e.currencyPosition??i,decimals:e.decimals!==void 0?Math.max(0,e.decimals):2,decimalSeparator:e.decimalSeparator??",",thousandSeparator:e.thousandSeparator??"\xA0",allowNegative:e.allowNegative??!1,min:e.min??-1/0,max:e.max??1/0}}parse(e){let t=e.trim(),i=!1;this.options.allowNegative&&t.includes("-")&&(i=!0),this.options.currency&&(t=t.replace(new RegExp(this.escapeRegExp(this.options.currency),"g"),"")),this.options.thousandSeparator&&(t=t.replace(new RegExp(this.escapeRegExp(this.options.thousandSeparator),"g"),"")),t=t.replace(/[\s\u00A0]/g,"");let s=this.options.decimalSeparator,n=t.indexOf(s);n===-1&&(n=t.search(/[,.]/));let o="",r=null,a=!1;return n!==-1?(o=t.substring(0,n).replace(/\D/g,""),this.options.decimals>0&&(a=!0,r=t.substring(n+1).replace(/\D/g,"").slice(0,this.options.decimals))):o=t.replace(/\D/g,""),o.length>1&&(o=o.replace(/^0+/,"")||"0"),{isNegative:i,integerPart:o,decimalPart:r,hasDecimal:a}}format(e,t=e.length,i=!1){if(!e||e.trim()===""||e===this.options.currency.trim())return{formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0};let s=e.substring(0,t),n=s.replace(/\D/g,"").length,o=this.options.decimals>0&&/[,.]/.test(s),{isNegative:r,integerPart:a,decimalPart:u,hasDecimal:h}=this.parse(e),c=u,l=h;if(i&&this.options.decimals>0&&(a||u!==null)&&(l=!0,c===null?c="0".repeat(this.options.decimals):c.length<this.options.decimals&&(c=c+"0".repeat(this.options.decimals-c.length))),r&&!a&&!c&&!l&&this.options.allowNegative){let M="-",A=1;return this.options.currency&&(this.options.currencyPosition==="prefix"?(M=`${this.options.currency} -`,A=M.length):(M=`- ${this.options.currency}`,A=1)),{formatted:M,rawNumber:null,rawValue:"-",cursor:A,isValid:!0}}if(!a&&!c&&!l)return{formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0};let f=(a||"0").replace(/\B(?=(\d{3})+(?!\d))/g,this.options.thousandSeparator);l&&this.options.decimals>0&&(f+=this.options.decimalSeparator+(c??"")),r&&f!=="0"&&(f="-"+f);let m=f;this.options.currency&&(this.options.currencyPosition==="prefix"?m=`${this.options.currency} ${f}`:m=`${f} ${this.options.currency}`);let g=(r?"-":"")+(a||"0")+(u?"."+u:""),w=parseFloat(g);isNaN(w)&&(w=0);let v=w>=this.options.min&&w<=this.options.max,k=0;this.options.currency&&this.options.currencyPosition==="prefix"&&(k=this.options.currency.length+1);let b=0,y=!1,E=k;for(let M=k;M<m.length;M++){let A=m[M];if(A===this.options.currency.trim()[0]&&this.options.currencyPosition==="suffix")break;if(/\d/.test(A)?(b++,E=M+1):A===this.options.decimalSeparator&&(y=!0,E=M+1),o){if(y&&b>=n){k=M+1;break}}else if(b>=n){k=M+1;break}}n>0&&b<n&&E>k&&(k=E);let C=this.options.currency&&this.options.currencyPosition==="prefix"?this.options.currency.length+1:0,Y=this.options.currency&&this.options.currencyPosition==="suffix"?Math.max(0,m.length-this.options.currency.length-1):m.length;return k=Math.max(C,Math.min(k,Math.max(C,Y))),{formatted:m,rawNumber:w,rawValue:g,cursor:k,isValid:v}}static format(e,t={}){let i=new d(t),s=typeof e=="number"?e.toString():e;return i.format(s).formatted}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}};var F=class extends L{constructor(t,i,s){let n=I(t,i,s),o=n.wrapper,r=n.input,a=n.options,u=o?.getAttribute("data-mask-pad-decimals")==="true"||r?.getAttribute("data-mask-pad-decimals")==="true",h=r?.getAttribute("data-mask-align")||r?.getAttribute("data-align")||o?.getAttribute("data-mask-align")||o?.getAttribute("data-align"),c={align:a.align??h??"right",padDecimalsOnBlur:a.padDecimalsOnBlur??u??!1,...a};super(o,r,c);this.isUndoingRedoing=!1;this.isApplying=!1;this.isComposing=!1;this.lastValue="";this.cutTimerId=null;this.resetTimerId=null;this.input.inputMode="decimal",this.history=new x,this.engine=new O(this.options),this.bindEvents(),this.input.value?this.options.disabled||this.applyAmount(this.input.value,this.input.value.length):this.updateGhost({formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0})}extractRawSnippet(t){let i=this.engine.parse(t);return!i.integerPart&&!i.decimalPart?"":(i.isNegative?"-":"")+(i.integerPart||"0")+(i.decimalPart?"."+i.decimalPart:"")}static format(t,i={}){return O.format(t,i)}onNativeValueSet(t){if(this.options.disabled||this.isComposing){this.lastValue=t;return}this.applyAmount(t,t.length)}onDisabledChange(t){t||this.applyAmount(this.input.value,this.input.selectionStart??this.input.value.length)}bindEvents(){this.handleInput=this.handleInput.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleClick=this.handleClick.bind(this),this.onCompositionStart=this.onCompositionStart.bind(this),this.onCompositionEnd=this.onCompositionEnd.bind(this),this.onCutHandler=()=>{this.cutTimerId!==null&&clearTimeout(this.cutTimerId),this.cutTimerId=window.setTimeout(()=>{if(this.cutTimerId=null,this.isDestroyed||this.options.disabled)return;let t=this.input.selectionStart??this.input.value.length;this.applyAmount(this.input.value,t)},0)},this.input.addEventListener("input",this.handleInput),this.input.addEventListener("keydown",this.handleKeyDown),this.input.addEventListener("blur",this.handleBlur),this.input.addEventListener("focus",this.handleFocus),this.input.addEventListener("click",this.handleClick),this.input.addEventListener("scroll",this.onScroll),this.input.addEventListener("cut",this.onCutHandler),this.input.addEventListener("compositionstart",this.onCompositionStart),this.input.addEventListener("compositionend",this.onCompositionEnd),this.input.form&&(this.onFormResetHandler=()=>{this.resetTimerId!==null&&clearTimeout(this.resetTimerId),this.resetTimerId=window.setTimeout(()=>{this.resetTimerId=null,!this.isDestroyed&&(this.options.disabled||this.applyAmount(this.input.value,this.input.value.length))},0)},this.input.form.addEventListener("reset",this.onFormResetHandler))}onCompositionStart(){this.isComposing=!0}onCompositionEnd(){if(this.isComposing=!1,this.options.disabled)return;let t=this.input.selectionStart??this.input.value.length;this.applyAmount(this.input.value,t)}applyAmount(t,i){if(!(this.isApplying||this.options.disabled)){this.isApplying=!0;try{let s=this.engine.format(t,i);this.setNativeValue(s.formatted),this.input.setSelectionRange(s.cursor,s.cursor),!this.isUndoingRedoing&&this.input.type!=="password"&&this.history.push(s.rawValue,s.cursor),this.updateGhost(s),this.lastValue!==s.formatted&&(this.lastValue=s.formatted,this.notifyChange(s))}finally{this.isApplying=!1}}}updateGhost(t){if(this.ghost){if(!t.formatted){if(this.shouldHideGhostForPlaceholder(!0)){this.ghost.textContent="";return}let i=this.options.currency?this.options.currencyPosition==="prefix"?`${this.options.currency} 0`:`0 ${this.options.currency}`:"0,00";this.ghost.textContent="";let s=document.createElement("span");s.className="mask-ghost-remaining",s.textContent=i,this.ghost.appendChild(s);return}this.ghost.textContent="",this.ghost.scrollLeft=this.input.scrollLeft}}handleInput(){if(this.isDispatchingNativeInput||this.options.disabled||this.isComposing)return;let t=this.input.value,i=this.input.selectionStart??t.length;this.applyAmount(t,i)}handleKeyDown(t){if(!this.options.disabled){if((t.ctrlKey||t.metaKey)&&(t.key==="z"||t.key==="Z")){t.preventDefault(),t.shiftKey?this.redo():this.undo();return}if((t.ctrlKey||t.metaKey)&&(t.key==="y"||t.key==="Y")){t.preventDefault(),this.redo();return}if(t.key==="Backspace"){let i=this.input.selectionStart??0,s=this.input.selectionEnd??0;if(i===s&&i>0){let n=this.input.value,o=n[i-1];if(o===this.engine.options.thousandSeparator||o===" "){t.preventDefault();let r=Math.max(0,i-2),a=n.slice(0,r)+n.slice(i);this.applyAmount(a,r);return}if(this.options.currency&&this.options.currencyPosition==="prefix"&&i<=this.options.currency.length+1){t.preventDefault();return}}}if(t.key==="Delete"){let i=this.input.selectionStart??0,s=this.input.selectionEnd??0;if(i===s&&i<this.input.value.length){let n=this.input.value,o=n[i];if(o===this.engine.options.thousandSeparator||o===" "){t.preventDefault();let r=n.slice(0,i)+n.slice(i+2);this.applyAmount(r,i);return}if(this.options.currency&&this.options.currencyPosition==="suffix"){let r=n.length-this.options.currency.length-1;if(i>=r){t.preventDefault();return}}}}setTimeout(()=>this.enforceCursorBounds(),0)}}enforceCursorBounds(){if(!this.input.value||this.options.disabled)return;let t=this.input.selectionStart??0,i=this.input.selectionEnd??0;if(t!==i)return;let s=this.input.value,n=this.options.currency;if(n){if(this.options.currencyPosition==="prefix"){let o=n.length+1;t<o&&this.input.setSelectionRange(o,o)}else if(this.options.currencyPosition==="suffix"){let o=Math.max(0,s.length-n.length-1);t>o&&this.input.setSelectionRange(o,o)}}}handleClick(){this.enforceCursorBounds()}handleFocus(){this.wrapper.classList.add("is-focused"),this.syncGhostStyles(),this.enforceCursorBounds(),this.updateGhost(this.engine.format(this.input.value))}handleBlur(){if(this.wrapper.classList.remove("is-focused"),this.input.type==="password"&&this.history.clear(),this.options.padDecimalsOnBlur&&!this.options.disabled&&this.input.value.trim().length>0){let i=this.engine.format(this.input.value,this.input.value.length,!0);i.formatted!==this.input.value&&(this.setNativeValue(i.formatted),this.lastValue=i.formatted)}this.updateGhost(this.engine.format(this.input.value));let t=this.getDetail();this.options.onChange&&this.options.onChange(t),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:t}))}handleAttributeMutation(t){super.handleAttributeMutation(t),t==="data-mask-pad-decimals"?this.options.padDecimalsOnBlur=this.getAttr("data-mask-pad-decimals")==="true":t==="placeholder"&&this.updateGhost(this.engine.format(this.input.value))}notifyChange(t){let i={value:t.formatted,number:t.rawNumber,rawValue:t.rawValue,isValid:t.isValid};this.options.onInput&&this.options.onInput(i),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:i})),this.dispatchNativeInput()}undo(){let t=this.history.undo();if(t){this.isUndoingRedoing=!0;try{this.applyAmount(t.raw,t.cursor)}finally{this.isUndoingRedoing=!1}}}redo(){let t=this.history.redo();if(t){this.isUndoingRedoing=!0;try{this.applyAmount(t.raw,t.cursor)}finally{this.isUndoingRedoing=!1}}}getDetail(){let t=this.engine.format(this.input.value);return{value:t.formatted,number:t.rawNumber,rawValue:t.rawValue,isValid:t.isValid}}getNumber(){return this.getDetail().number}getRawValue(){return this.getDetail().rawValue}isValid(){return this.getDetail().isValid}setValue(t){let i=t!=null?String(t):"";this.options.disabled?(this.setNativeValue(i),this.lastValue=i):this.applyAmount(i,i.length)}destroy(){this.isDestroyed||(this.cutTimerId!==null&&(clearTimeout(this.cutTimerId),this.cutTimerId=null),this.resetTimerId!==null&&(clearTimeout(this.resetTimerId),this.resetTimerId=null),this.input.removeEventListener("input",this.handleInput),this.input.removeEventListener("keydown",this.handleKeyDown),this.input.removeEventListener("blur",this.handleBlur),this.input.removeEventListener("focus",this.handleFocus),this.input.removeEventListener("click",this.handleClick),this.input.removeEventListener("scroll",this.onScroll),this.input.removeEventListener("cut",this.onCutHandler),this.input.removeEventListener("compositionstart",this.onCompositionStart),this.input.removeEventListener("compositionend",this.onCompositionEnd),this.input.form&&this.onFormResetHandler&&this.input.form.removeEventListener("reset",this.onFormResetHandler),this.history.clear(),super.destroy())}};var j=class j{constructor(e={}){this.defaultDomain=null;this.domains=e.domains&&e.domains.length>0?e.domains:j.DEFAULT_DOMAINS,this.suggestOnAt=e.suggestOnAt??!0,this.setDefaultDomain(e.defaultDomain??null)}setDefaultDomain(e){e===!0?this.defaultDomain=this.domains.length>0?this.domains[0]:null:typeof e=="string"&&e.trim().length>0?this.defaultDomain=e.trim().replace(/^@/,""):this.defaultDomain=null}getMatchingDomains(e){let t=e??"";if(!t.includes("@"))return this.defaultDomain?[this.defaultDomain]:[];let i=t.indexOf("@");if(t.indexOf("@",i+1)!==-1)return[];let s=t.substring(i+1);if(s.length===0)return this.suggestOnAt?[...this.domains]:[];let n=s.toLowerCase();return this.domains.filter(o=>o.toLowerCase().startsWith(n)&&o.toLowerCase()!==n)}getSuggestion(e,t=0){let i=e??"";if(!i.includes("@"))return this.defaultDomain?{full:i?`${i}@${this.defaultDomain}`:`@${this.defaultDomain}`,remaining:`@${this.defaultDomain}`,matchedDomain:this.defaultDomain}:{full:i,remaining:"",matchedDomain:null};let s=i.indexOf("@"),n=i.substring(0,s),o=i.substring(s+1);if(i.indexOf("@",s+1)!==-1)return{full:i,remaining:"",matchedDomain:null};let r=this.getMatchingDomains(e);if(r.length===0)return{full:e,remaining:"",matchedDomain:null};let a=(t%r.length+r.length)%r.length,u=r[a],h=o.toLowerCase(),c=u.substring(h.length);return{full:`${n}@${u}`,remaining:c,matchedDomain:u}}};j.DEFAULT_DOMAINS=["gmail.com","outlook.com","orange.fr","free.fr","sfr.fr","yahoo.com","hotmail.com","icloud.com","laposte.net","proton.me"];var R=j;var W=class extends L{constructor(t,i,s){let n=I(t,i,s),o=n.wrapper,r=n.input,a=n.options,u=o?.getAttribute("data-mask-cycle-suggestions")==="true"||r?.getAttribute("data-mask-cycle-suggestions")==="true",h=o?.getAttribute("data-mask-auto-lowercase")==="true"||r?.getAttribute("data-mask-auto-lowercase")==="true",c=o?.getAttribute("data-mask-aria-autocomplete")??r?.getAttribute("data-mask-aria-autocomplete"),l=a.setAriaAutocomplete??(c!==null?c!=="false":!0),p={completeOnTab:!0,completeOnArrowRight:!0,completeOnEnter:!0,cycleSuggestions:a.cycleSuggestions??u??!1,autoLowercase:a.autoLowercase??h??!1,setAriaAutocomplete:l,...a};super(o,r,p);this.currentSuggestion={full:"",remaining:"",matchedDomain:null};this.currentSuggestionIndex=0;this.wasAriaAutocompleteSet=!1;this.cutTimerId=null;this.resetTimerId=null;this.input.inputMode="email",this.options.setAriaAutocomplete&&!this.input.hasAttribute("aria-autocomplete")&&(this.input.setAttribute("aria-autocomplete","inline"),this.wasAriaAutocompleteSet=!0),this.engine=new R(this.options),this.bindEvents(),this.options.disabled||this.updateSuggestion()}onNativeValueSet(t){this.options.disabled||this.updateSuggestion()}onDisabledChange(t){t?this.ghost&&(this.ghost.textContent=""):this.updateSuggestion()}bindEvents(){this.handleInput=this.handleInput.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleFocus=this.handleFocus.bind(this),this.onCutHandler=()=>{this.cutTimerId!==null&&clearTimeout(this.cutTimerId),this.cutTimerId=window.setTimeout(()=>{this.cutTimerId=null,!(this.isDestroyed||this.options.disabled)&&this.updateSuggestion()},0)},this.input.addEventListener("input",this.handleInput),this.input.addEventListener("keydown",this.handleKeyDown),this.input.addEventListener("blur",this.handleBlur),this.input.addEventListener("focus",this.handleFocus),this.input.addEventListener("scroll",this.onScroll),this.input.addEventListener("cut",this.onCutHandler),this.input.form&&(this.onFormResetHandler=()=>{this.resetTimerId!==null&&clearTimeout(this.resetTimerId),this.resetTimerId=window.setTimeout(()=>{this.resetTimerId=null,!(this.isDestroyed||this.options.disabled)&&this.updateSuggestion()},0)},this.input.form.addEventListener("reset",this.onFormResetHandler))}updateSuggestion(){if(this.options.disabled){this.ghost&&(this.ghost.textContent="");return}let t=this.input.value;if(this.currentSuggestion=this.engine.getSuggestion(t,this.currentSuggestionIndex),!this.ghost)return;if(this.shouldHideGhostForPlaceholder(t.length===0))this.ghost.textContent="";else if(this.currentSuggestion.remaining){this.ghost.textContent="";let s=document.createElement("span");s.className="mask-ghost-typed",s.textContent=t;let n=document.createElement("span");n.className="mask-ghost-remaining",n.textContent=this.currentSuggestion.remaining,this.ghost.appendChild(s),this.ghost.appendChild(n)}else this.ghost.textContent="";this.ghost.scrollLeft=this.input.scrollLeft;let i=this.getDetail();this.options.onInput&&this.options.onInput(i),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:i})),this.dispatchNativeInput()}handleInput(){if(!this.isDispatchingNativeInput&&!this.options.disabled){if(this.options.autoLowercase){let t=this.input.selectionStart??0,i=this.input.selectionEnd??t,s=this.input.value.toLowerCase();s!==this.input.value&&(this.setNativeValue(s),this.input.setSelectionRange(t,i))}this.currentSuggestionIndex=0,this.updateSuggestion()}}handleKeyDown(t){if(this.options.disabled)return;let i=!!this.currentSuggestion.remaining,n=(this.input.selectionStart??0)===this.input.value.length,o=this.input.value.length>0;if(this.options.cycleSuggestions&&i&&o&&n){if(t.key==="ArrowDown"){t.preventDefault(),this.currentSuggestionIndex++,this.updateSuggestion();return}if(t.key==="ArrowUp"){t.preventDefault(),this.currentSuggestionIndex--,this.updateSuggestion();return}}if(t.key==="Tab"&&i&&o&&this.options.completeOnTab){t.preventDefault(),this.acceptSuggestion();return}if(t.key==="Enter"&&i&&o&&this.options.completeOnEnter){t.preventDefault(),this.acceptSuggestion();return}if(t.key==="ArrowRight"&&i&&o&&n&&this.options.completeOnArrowRight){t.preventDefault(),this.acceptSuggestion();return}}acceptSuggestion(){if(!this.currentSuggestion.remaining||this.options.disabled||this.input.value.length===0)return!1;let t=this.currentSuggestion.full;this.setNativeValue(t),this.input.setSelectionRange(t.length,t.length),this.currentSuggestionIndex=0,this.updateSuggestion();let i=this.getDetail();return this.options.onChange&&this.options.onChange(i),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:i})),this.input.dispatchEvent(new CustomEvent("mask:complete",{bubbles:!0,detail:i})),!0}setDefaultDomain(t){this.engine.setDefaultDomain(t),this.updateSuggestion()}handleFocus(){this.wrapper.classList.add("is-focused"),this.syncGhostStyles(),this.updateSuggestion()}handleBlur(){this.wrapper.classList.remove("is-focused"),this.updateSuggestion();let t=this.getDetail();this.options.onChange&&this.options.onChange(t),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:t}))}handleAttributeMutation(t){super.handleAttributeMutation(t),t==="data-mask-cycle-suggestions"?this.options.cycleSuggestions=this.getAttr("data-mask-cycle-suggestions")==="true":t==="data-mask-auto-lowercase"?this.options.autoLowercase=this.getAttr("data-mask-auto-lowercase")==="true":t==="placeholder"&&this.updateSuggestion()}getDetail(){return{value:this.input.value,suggestedValue:this.currentSuggestion.full,domain:this.currentSuggestion.matchedDomain}}setValue(t){let i=t!=null?String(t):"";this.setNativeValue(i),this.updateSuggestion()}destroy(){this.isDestroyed||(this.cutTimerId!==null&&(clearTimeout(this.cutTimerId),this.cutTimerId=null),this.resetTimerId!==null&&(clearTimeout(this.resetTimerId),this.resetTimerId=null),this.input.removeEventListener("input",this.handleInput),this.input.removeEventListener("keydown",this.handleKeyDown),this.input.removeEventListener("blur",this.handleBlur),this.input.removeEventListener("focus",this.handleFocus),this.input.removeEventListener("scroll",this.onScroll),this.input.removeEventListener("cut",this.onCutHandler),this.input.form&&this.onFormResetHandler&&this.input.form.removeEventListener("reset",this.onFormResetHandler),this.wasAriaAutocompleteSet&&this.input.getAttribute("aria-autocomplete")==="inline"&&this.input.removeAttribute("aria-autocomplete"),super.destroy())}};var it={BaseInputMask:L,InputMask:P,MaskEngine:D,MaskHistory:x,MaskKeyboard:H,AmountEngine:O,InputAmountMask:F,EmailEngine:R,InputEmailMask:W};if(typeof window<"u"){let d=window,e=d.Wulf||{};d.Wulf=e,e.Mask=it}var Z=P;var Q={};X(Q,{Scroll:()=>nt,ScrollBlock:()=>z,default:()=>ct});var st=0,z=class{constructor(e,t){this.createdViewport=!1;this.isDragging=!1;this.dragStartPos=0;this.dragStartScroll=0;this.atBottom=!1;this.atTop=!0;this.atRight=!1;this.atLeft=!0;let i=typeof e=="string"?document.querySelector(e):e;if(!i)throw new Error(`[ScrollBlock] \xC9l\xE9ment introuvable : "${e}".`);this.root=i,this.options={axis:t?.axis||"y",autoHide:t?.autoHide??!0,autoHideDelay:t?.autoHideDelay??1e3,alwaysVisible:t?.alwaysVisible??!1,ariaLabel:t?.ariaLabel||"Zone de contenu d\xE9filable",minThumbSize:t?.minThumbSize??24,edgeThreshold:t?.edgeThreshold??10,onScroll:t?.onScroll||(()=>{}),onTotalScroll:t?.onTotalScroll||(()=>{}),onTotalScrollBack:t?.onTotalScrollBack||(()=>{})},this.boundOnScroll=this.handleScroll.bind(this),this.boundOnMouseEnter=this.handleMouseEnter.bind(this),this.boundOnMouseLeave=this.handleMouseLeave.bind(this),this.boundOnFocusIn=this.handleFocusIn.bind(this),this.boundOnFocusOut=this.handleFocusOut.bind(this),this.boundPointerMove=this.handlePointerMove.bind(this),this.boundPointerUp=this.handlePointerUp.bind(this),this.viewport=this.setupViewport(),this.setupAccessibility(),this.setupScrollbars(),this.setupEventListeners(),this.setupObserver(),this.update()}setupViewport(){this.root.classList.add("wulf-scrollblock"),this.options.alwaysVisible&&this.root.classList.add("is-always-visible"),this.options.axis==="both"&&this.root.classList.add("has-both-axes");let e=this.root.querySelector(":scope > .wulf-scrollblock-viewport");if(e)return e;let t=document.createElement("div");for(t.className="wulf-scrollblock-viewport";this.root.firstChild;)t.appendChild(this.root.firstChild);return this.root.appendChild(t),this.createdViewport=!0,t}setupAccessibility(){this.viewport.id||(st+=1,this.viewport.id=`wulf-scrollblock-vp-${st}`),this.viewport.setAttribute("role","region"),this.viewport.setAttribute("aria-label",this.options.ariaLabel)}setupScrollbars(){(this.options.axis==="y"||this.options.axis==="both")&&(this.trackY=document.createElement("div"),this.trackY.className="wulf-scrollblock-track wulf-scrollblock-vertical",this.trackY.setAttribute("aria-hidden","true"),this.thumbY=document.createElement("div"),this.thumbY.className="wulf-scrollblock-thumb",this.thumbY.setAttribute("role","scrollbar"),this.thumbY.setAttribute("aria-orientation","vertical"),this.thumbY.setAttribute("aria-controls",this.viewport.id),this.thumbY.setAttribute("aria-valuenow","0"),this.thumbY.setAttribute("aria-valuemin","0"),this.thumbY.setAttribute("aria-valuemax","100"),this.thumbY.setAttribute("aria-label","D\xE9filement vertical"),this.trackY.appendChild(this.thumbY),this.root.appendChild(this.trackY),this.attachTrackListeners(this.trackY,this.thumbY,"y")),(this.options.axis==="x"||this.options.axis==="both")&&(this.trackX=document.createElement("div"),this.trackX.className="wulf-scrollblock-track wulf-scrollblock-horizontal",this.trackX.setAttribute("aria-hidden","true"),this.thumbX=document.createElement("div"),this.thumbX.className="wulf-scrollblock-thumb",this.thumbX.setAttribute("role","scrollbar"),this.thumbX.setAttribute("aria-orientation","horizontal"),this.thumbX.setAttribute("aria-controls",this.viewport.id),this.thumbX.setAttribute("aria-valuenow","0"),this.thumbX.setAttribute("aria-valuemin","0"),this.thumbX.setAttribute("aria-valuemax","100"),this.thumbX.setAttribute("aria-label","D\xE9filement horizontal"),this.trackX.appendChild(this.thumbX),this.root.appendChild(this.trackX),this.attachTrackListeners(this.trackX,this.thumbX,"x"))}attachTrackListeners(e,t,i){t.addEventListener("pointerdown",s=>{s.preventDefault(),s.stopPropagation(),this.isDragging=!0,this.dragAxis=i,this.dragPointerId=s.pointerId,this.dragStartPos=i==="y"?s.clientY:s.clientX,this.dragStartScroll=i==="y"?this.viewport.scrollTop:this.viewport.scrollLeft,t.setPointerCapture(s.pointerId),t.classList.add("is-active"),this.root.classList.add("is-dragging"),window.addEventListener("pointermove",this.boundPointerMove),window.addEventListener("pointerup",this.boundPointerUp),window.addEventListener("pointercancel",this.boundPointerUp)}),e.addEventListener("pointerdown",s=>{if(s.target===t)return;s.preventDefault();let n=e.getBoundingClientRect(),o=i==="y"?s.clientY-n.top:s.clientX-n.left,r=i==="y"?n.height:n.width,a=i==="y"?this.viewport.clientHeight:this.viewport.clientWidth,u=i==="y"?this.viewport.scrollHeight:this.viewport.scrollWidth,c=o/r*(u-a);this.scrollTo(i==="y"?{top:c}:{left:c},{smooth:!0})})}setupEventListeners(){this.viewport.addEventListener("scroll",this.boundOnScroll,{passive:!0}),this.options.autoHide&&!this.options.alwaysVisible&&(this.root.addEventListener("mouseenter",this.boundOnMouseEnter),this.root.addEventListener("mouseleave",this.boundOnMouseLeave),this.root.addEventListener("focusin",this.boundOnFocusIn),this.root.addEventListener("focusout",this.boundOnFocusOut))}setupObserver(){typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>{window.requestAnimationFrame(()=>this.update())}),this.resizeObserver.observe(this.root),this.resizeObserver.observe(this.viewport),this.viewport.firstElementChild&&this.resizeObserver.observe(this.viewport.firstElementChild))}handlePointerMove(e){if(!this.isDragging||!this.dragAxis)return;let t=this.dragAxis==="y",i=(t?e.clientY:e.clientX)-this.dragStartPos,s=t?this.trackY:this.trackX,n=t?this.thumbY:this.thumbX;if(!s||!n)return;let o=t?s.clientHeight:s.clientWidth,r=t?n.clientHeight:n.clientWidth,a=t?this.viewport.clientHeight:this.viewport.clientWidth,h=(t?this.viewport.scrollHeight:this.viewport.scrollWidth)-a,c=o-r;if(c<=0||h<=0)return;let l=h/c,p=this.dragStartScroll+i*l;t?this.viewport.scrollTop=Math.max(0,Math.min(h,p)):this.viewport.scrollLeft=Math.max(0,Math.min(h,p))}handlePointerUp(e){if(this.isDragging){if(this.dragPointerId!==void 0){let t=this.dragAxis==="y"?this.thumbY:this.thumbX;t&&t.hasPointerCapture(this.dragPointerId)&&t.releasePointerCapture(this.dragPointerId)}window.removeEventListener("pointermove",this.boundPointerMove),window.removeEventListener("pointerup",this.boundPointerUp),window.removeEventListener("pointercancel",this.boundPointerUp),this.isDragging=!1,this.dragAxis=void 0,this.dragPointerId=void 0,this.thumbY?.classList.remove("is-active"),this.thumbX?.classList.remove("is-active"),this.root.classList.remove("is-dragging"),this.scheduleAutoHide()}}handleScroll(){this.syncThumbs();let{scrollTop:e,scrollLeft:t,scrollHeight:i,scrollWidth:s,clientHeight:n,clientWidth:o}=this.viewport,r=Math.max(0,i-n),a=Math.max(0,s-o),u=r>0?e/r:0,h=a>0?t/a:0;this.options.onScroll({top:e,left:t,maxTop:r,maxLeft:a,progressY:Math.round(u*100),progressX:Math.round(h*100)});let c=this.options.edgeThreshold;if(r>0){let l=e>=r-c,p=e<=c;l&&!this.atBottom&&this.options.onTotalScroll("bottom"),p&&!this.atTop&&this.options.onTotalScrollBack("top"),this.atBottom=l,this.atTop=p}if(a>0){let l=t>=a-c,p=t<=c;l&&!this.atRight&&this.options.onTotalScroll("right"),p&&!this.atLeft&&this.options.onTotalScrollBack("left"),this.atRight=l,this.atLeft=p}this.options.autoHide&&!this.options.alwaysVisible&&(this.root.classList.add("is-scrolling"),this.scheduleAutoHide())}syncThumbs(){let{scrollTop:e,scrollLeft:t,scrollHeight:i,scrollWidth:s,clientHeight:n,clientWidth:o}=this.viewport;if(this.thumbY&&this.trackY){let r=i-n,a=this.trackY.clientHeight,u=this.thumbY.clientHeight,h=a-u;if(r>0&&h>0){let c=e/r,l=Math.max(0,Math.min(h,c*h));this.thumbY.style.transform=`translate3d(0, ${l}px, 0)`,this.thumbY.setAttribute("aria-valuenow",String(Math.round(c*100)))}}if(this.thumbX&&this.trackX){let r=s-o,a=this.trackX.clientWidth,u=this.thumbX.clientWidth,h=a-u;if(r>0&&h>0){let c=t/r,l=Math.max(0,Math.min(h,c*h));this.thumbX.style.transform=`translate3d(${l}px, 0, 0)`,this.thumbX.setAttribute("aria-valuenow",String(Math.round(c*100)))}}}handleMouseEnter(){this.root.classList.add("is-visible"),this.clearAutoHideTimer()}handleMouseLeave(){this.scheduleAutoHide()}handleFocusIn(){this.root.classList.add("is-visible"),this.clearAutoHideTimer()}handleFocusOut(){this.scheduleAutoHide()}clearAutoHideTimer(){this.hideTimer&&(window.clearTimeout(this.hideTimer),this.hideTimer=void 0)}scheduleAutoHide(){this.options.alwaysVisible||!this.options.autoHide||this.isDragging||(this.clearAutoHideTimer(),this.hideTimer=window.setTimeout(()=>{this.root.classList.remove("is-scrolling"),this.root.classList.remove("is-visible")},this.options.autoHideDelay))}update(){let{scrollHeight:e,clientHeight:t,scrollWidth:i,clientWidth:s}=this.viewport,n=e>t,o=i>s;if(this.root.classList.toggle("has-scroll-y",n),this.root.classList.toggle("has-scroll-x",o),n||o?this.viewport.setAttribute("tabindex","0"):this.viewport.removeAttribute("tabindex"),this.trackY&&this.thumbY&&n){let r=this.trackY.clientHeight,a=Math.max(this.options.minThumbSize,r*(t/e));this.thumbY.style.height=`${a}px`}if(this.trackX&&this.thumbX&&o){let r=this.trackX.clientWidth,a=Math.max(this.options.minThumbSize,r*(s/i));this.thumbX.style.width=`${a}px`}this.syncThumbs()}scrollTo(e,t){let i=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,s=typeof e=="object"&&e!==null&&!(e instanceof HTMLElement)?e.smooth:void 0,o=(t?.smooth??s??!0)&&!i?"smooth":"auto",r=Math.max(0,this.viewport.scrollHeight-this.viewport.clientHeight),a=Math.max(0,this.viewport.scrollWidth-this.viewport.clientWidth),u,h;if(typeof e=="number")u=e;else if(typeof e=="string")switch(e){case"top":u=0;break;case"bottom":u=r;break;case"left":h=0;break;case"right":h=a;break;default:{let c=null;try{c=this.viewport.querySelector(e)}catch{c=null}c&&(u=c.offsetTop,h=c.offsetLeft);break}}else e instanceof HTMLElement?(u=e.offsetTop,h=e.offsetLeft):typeof e=="object"&&(u=e.top,h=e.left);this.viewport.scrollTo({top:u!==void 0?Math.max(0,Math.min(r,u)):void 0,left:h!==void 0?Math.max(0,Math.min(a,h)):void 0,behavior:o})}destroy(){if(this.clearAutoHideTimer(),this.resizeObserver&&this.resizeObserver.disconnect(),this.viewport.removeEventListener("scroll",this.boundOnScroll),this.root.removeEventListener("mouseenter",this.boundOnMouseEnter),this.root.removeEventListener("mouseleave",this.boundOnMouseLeave),this.root.removeEventListener("focusin",this.boundOnFocusIn),this.root.removeEventListener("focusout",this.boundOnFocusOut),window.removeEventListener("pointermove",this.boundPointerMove),window.removeEventListener("pointerup",this.boundPointerUp),window.removeEventListener("pointercancel",this.boundPointerUp),this.trackY?.remove(),this.trackX?.remove(),this.root.classList.remove("wulf-scrollblock","has-scroll-y","has-scroll-x","has-both-axes","is-visible","is-scrolling","is-dragging","is-always-visible"),this.createdViewport&&this.viewport.parentElement===this.root){for(;this.viewport.firstChild;)this.root.insertBefore(this.viewport.firstChild,this.viewport);this.viewport.remove()}}};var nt={ScrollBlock:z};var ct=z;if(typeof window<"u"){let d=window,e=d.Wulf||{};d.Wulf=e,e.Scroll=nt}var tt={};X(tt,{LayoutEngine:()=>N,Masonry:()=>B,default:()=>pt});var N=class{static parseGutter(e){return typeof e=="number"?{x:Math.max(0,e),y:Math.max(0,e)}:e&&typeof e=="object"?{x:Math.max(0,Number(e.x)||0),y:Math.max(0,Number(e.y)||0)}:{x:0,y:0}}static resolveColumnWidth(e,t,i){if(typeof i=="number"&&i>0)return i;if(typeof i=="string"){let n=e.querySelector(i);if(n){let r=n.getBoundingClientRect().width;if(r>0)return r}let o=parseFloat(i);if(!isNaN(o)&&o>0)return i.endsWith("%")?e.getBoundingClientRect().width*o/100:o}if(i instanceof HTMLElement){let n=i.getBoundingClientRect().width;if(n>0)return n}if(t){let n=t.getBoundingClientRect().width;if(n>0)return n}let s=e.getBoundingClientRect().width;return s>0?s:200}static getItemSpan(e,t,i,s){let n=e.getAttribute("data-masonry-span")||e.dataset.masonrySpan;if(n){let r=parseInt(n,10);if(!isNaN(r)&&r>0)return Math.min(s,r)}let o=e.className.match(/(?:^|\s)(?:span|col-span)-(\d+)(?:\s|$)/);if(o&&o[1]){let r=parseInt(o[1],10);if(!isNaN(r)&&r>0)return Math.min(s,r)}return 1}static calculate(e,t,i){let n=e.getBoundingClientRect().width,{x:o,y:r}=this.parseGutter(i.gutter);if(n<=0||t.length===0)return{cols:1,colWidth:n,gutterX:o,gutterY:r,containerHeight:0,containerWidth:n,positions:[]};let a=t[0]||null,u=this.resolveColumnWidth(e,a,i.columnWidth),h=Math.floor((n+o)/(u+o));h=Math.max(1,h),!i.columnWidth&&h>1&&(u=(n-(h-1)*o)/h);let c=i.fitWidth?h*u+(h-1)*o:void 0,l=new Array(h).fill(0),p=[],f=t.map(v=>{let k=v.getBoundingClientRect().height;return k>0?k:50}),m=0;for(let v=0;v<t.length;v++){let k=t[v],b=f[v],y=this.getItemSpan(k,u,o,h),E=0,C=0;if(i.horizontalOrder){m+y>h&&(m=0),E=m;let T=0;for(let S=0;S<y;S++)l[E+S]>T&&(T=l[E+S]);C=T,m=(E+y)%h}else if(y===1){let T=l[0];E=0;for(let S=1;S<h;S++)l[S]<T&&(T=l[S],E=S);C=T}else{let T=1/0;E=0;for(let S=0;S<=h-y;S++){let $=0;for(let q=0;q<y;q++)l[S+q]>$&&($=l[S+q]);$<T&&(T=$,E=S)}C=T}let Y=y*u+(y-1)*o,M=E*(u+o);p.push({element:k,x:M,y:C,width:Y,height:b,column:E,span:y});let A=C+b+r;for(let T=0;T<y;T++)l[E+T]=A}let g=0;for(let v=0;v<h;v++)l[v]>g&&(g=l[v]);let w=Math.max(0,g>0?g-r:0);return{cols:h,colWidth:u,gutterX:o,gutterY:r,containerHeight:w,containerWidth:n,fittedWidth:c,positions:p}}};var B=class{constructor(e,t={}){this.isNativeCSSGrid=!1;this._items=[];this.resizeObserver=null;this.itemResizeObserver=null;this.layoutRafId=null;this.isDestroyed=!1;this.wasRoleInferred=!1;this.wasAriaLabelInferred=!1;this.removeTimers=new Set;this.pendingImageListeners=[];if(typeof e=="string"){let s=document.querySelector(e);if(!s)throw new Error(`[Wulf.Masonry] Conteneur introuvable pour le s\xE9lecteur : "${e}"`);this.root=s}else if(e instanceof HTMLElement)this.root=e;else throw new Error("[Wulf.Masonry] Cible invalide : fournissez un \xE9l\xE9ment HTMLElement ou un s\xE9lecteur valide.");this.originalContainerStyles={height:this.root.style.height,width:this.root.style.width},this.options={itemSelector:t.itemSelector||"> *",columnWidth:t.columnWidth??0,gutter:t.gutter??0,percentPosition:t.percentPosition!==!1,fitWidth:!!t.fitWidth,horizontalOrder:!!t.horizontalOrder,transitionDuration:t.transitionDuration!==void 0?t.transitionDuration:300,stagger:t.stagger||0,resize:t.resize!==!1,autoImages:t.autoImages!==!1,useNativeCSSGrid:t.useNativeCSSGrid!==!1,ariaRole:t.ariaRole||"region",ariaLabel:t.ariaLabel||"Galerie en grille asym\xE9trique",onLayout:t.onLayout||(()=>{}),onItemPlaced:t.onItemPlaced||(()=>{})};let i=typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("grid-template-rows","masonry");this.options.useNativeCSSGrid&&i?(this.isNativeCSSGrid=!0,this.root.classList.add("wulf-masonry","wulf-masonry--native")):this.root.classList.add("wulf-masonry"),this.initAccessibility(),this.applyTransitionDuration(),this.reloadItems(),this.initObservers(),this.initImages(),this.layout()}get items(){return[...this._items]}initAccessibility(){this.options.ariaRole&&!this.root.hasAttribute("role")&&(this.root.setAttribute("role",this.options.ariaRole),this.wasRoleInferred=!0),this.options.ariaLabel&&!this.root.hasAttribute("aria-label")&&(this.root.setAttribute("aria-label",this.options.ariaLabel),this.wasAriaLabelInferred=!0)}applyTransitionDuration(){let e=this.options.transitionDuration,t=typeof e=="number"?`${e}ms`:e;this.root.style.setProperty("--wulf-masonry-duration",t)}reloadItems(){if(this.isDestroyed)return;let e=[];if(this.options.itemSelector==="> *")e=Array.from(this.root.children).filter(t=>t instanceof HTMLElement&&!t.hasAttribute("data-masonry-ignore"));else try{e=Array.from(this.root.querySelectorAll(this.options.itemSelector)).filter(t=>t.parentElement===this.root&&!t.hasAttribute("data-masonry-ignore"))}catch{e=Array.from(this.root.children).filter(t=>t instanceof HTMLElement&&!t.hasAttribute("data-masonry-ignore"))}this._items=e;for(let t of this._items)t.classList.add("wulf-masonry-item"),this.itemResizeObserver&&this.itemResizeObserver.observe(t)}initObservers(){if(!this.options.resize||typeof ResizeObserver>"u")return;let e=this.root.getBoundingClientRect().width;this.resizeObserver=new ResizeObserver(t=>{for(let i of t){let s=i.contentRect.width;Math.abs(s-e)>=1&&(e=s,this.scheduleLayout())}}),this.resizeObserver.observe(this.root),this.itemResizeObserver=new ResizeObserver(()=>{this.scheduleLayout()});for(let t of this._items)this.itemResizeObserver.observe(t)}initImages(){if(!this.options.autoImages)return;let e=Array.from(this.root.querySelectorAll("img"));for(let t of e)if(!t.complete){let i=()=>{let s=()=>{this.pendingImageListeners=this.pendingImageListeners.filter(n=>n.handler!==s),this.isDestroyed||this.scheduleLayout()};this.pendingImageListeners.push({img:t,handler:s}),t.addEventListener("load",s,{once:!0})};typeof t.decode=="function"?t.decode().then(()=>{this.isDestroyed||this.scheduleLayout()}).catch(()=>{i()}):i()}}scheduleLayout(){this.isDestroyed||(this.layoutRafId!==null&&cancelAnimationFrame(this.layoutRafId),this.layoutRafId=requestAnimationFrame(()=>{this.layoutRafId=null,this.layout()}))}layout(){if(this.isDestroyed)return;if(this.isNativeCSSGrid){this.options.onLayout([]);return}this.root.setAttribute("aria-busy","true");let e=N.calculate(this.root,this._items,this.options);this.root.style.height=`${e.containerHeight}px`,this.options.fitWidth&&e.fittedWidth!==void 0?(this.root.style.width=`${e.fittedWidth}px`,this.root.classList.add("wulf-masonry--fit-width")):this.root.classList.remove("wulf-masonry--fit-width");let t=this.options.stagger;for(let i=0;i<e.positions.length;i++){let s=e.positions[i],n=s.element;n.style.setProperty("--wulf-masonry-w",`${s.width}px`),n.style.setProperty("--wulf-masonry-x",`${s.x}px`),n.style.setProperty("--wulf-masonry-y",`${s.y}px`),t>0?n.style.transitionDelay=`${i*t}ms`:n.style.removeProperty("transition-delay"),n.classList.remove("wulf-masonry-item--hidden"),this.options.onItemPlaced(n,s)}this.root.setAttribute("aria-busy","false"),this.options.onLayout(e.positions)}append(e){if(this.isDestroyed)return;let t=Array.isArray(e)?e:[e];if(t.length===0)return;let i=document.createDocumentFragment();for(let s of t)s.classList.add("wulf-masonry-item","wulf-masonry-item--hidden"),i.appendChild(s);this.root.appendChild(i),this.reloadItems(),this.initImages(),this.layout()}prepend(e){if(this.isDestroyed)return;let t=Array.isArray(e)?e:[e];if(t.length===0)return;let i=this.root.firstChild,s=document.createDocumentFragment();for(let n of t)n.classList.add("wulf-masonry-item","wulf-masonry-item--hidden"),s.appendChild(n);this.root.insertBefore(s,i),this.reloadItems(),this.initImages(),this.layout()}remove(e){if(this.isDestroyed)return;let t=Array.isArray(e)?e:[e];if(t.length===0)return;for(let n of t)n.classList.add("wulf-masonry-item--hidden");let i=typeof this.options.transitionDuration=="number"?this.options.transitionDuration:300;if(i<=0){for(let n of t)n.parentElement===this.root&&(this.itemResizeObserver&&this.itemResizeObserver.unobserve(n),this.root.removeChild(n));this.reloadItems(),this.layout();return}let s=window.setTimeout(()=>{if(this.removeTimers.delete(s),!this.isDestroyed){for(let n of t)n.parentElement===this.root&&(this.itemResizeObserver&&this.itemResizeObserver.unobserve(n),this.root.removeChild(n));this.reloadItems(),this.layout()}},i);this.removeTimers.add(s)}destroy(){if(!this.isDestroyed){this.isDestroyed=!0;for(let e of this.removeTimers)clearTimeout(e);this.removeTimers.clear();for(let{img:e,handler:t}of this.pendingImageListeners)e.removeEventListener("load",t);this.pendingImageListeners=[],this.layoutRafId!==null&&(cancelAnimationFrame(this.layoutRafId),this.layoutRafId=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.itemResizeObserver&&(this.itemResizeObserver.disconnect(),this.itemResizeObserver=null),this.root.classList.remove("wulf-masonry","wulf-masonry--native","wulf-masonry--fit-width"),this.root.removeAttribute("aria-busy"),this.wasRoleInferred&&this.root.getAttribute("role")===this.options.ariaRole&&this.root.removeAttribute("role"),this.wasAriaLabelInferred&&this.root.getAttribute("aria-label")===this.options.ariaLabel&&this.root.removeAttribute("aria-label"),this.root.style.removeProperty("--wulf-masonry-duration"),this.originalContainerStyles.height?this.root.style.height=this.originalContainerStyles.height:this.root.style.removeProperty("height"),this.originalContainerStyles.width?this.root.style.width=this.originalContainerStyles.width:this.root.style.removeProperty("width");for(let e of this._items)e.classList.remove("wulf-masonry-item","wulf-masonry-item--hidden"),e.style.removeProperty("--wulf-masonry-w"),e.style.removeProperty("--wulf-masonry-x"),e.style.removeProperty("--wulf-masonry-y"),e.style.removeProperty("transition-delay");this._items=[]}}};var pt=B;if(typeof window<"u"){let d=window,e=d.Wulf||{};d.Wulf=e,e.Masonry=Object.assign(B,{Masonry:B,LayoutEngine:N})}var et={};X(et,{Toast:()=>U,ToastInstance:()=>G,ToastManager:()=>K,default:()=>mt});var dt=1,G=class{constructor(e,t){this._isClosed=!1;this.timerId=null;this.remainingTime=0;this.timerStartTime=0;this.isPaused=!1;this.id=`wulf-toast-${dt++}`,this.options=Object.freeze({...e}),this.onDismissCallback=t;let i=e.duration===void 0?4e3:e.duration;typeof i=="number"&&i>0?this.remainingTime=i:this.remainingTime=0,this.element=this.createDOM(),this.bindEvents()}get isClosed(){return this._isClosed}createDOM(){let e=document.createElement("div");e.id=this.id,e.className="wulf-toast";let t=this.options.role==="alert"?"alert":"status";if(e.setAttribute("role",t),e.setAttribute("aria-live",t==="alert"?"assertive":"polite"),e.setAttribute("aria-atomic","true"),this.options.backgroundColor&&e.style.setProperty("--wulf-toast-bg",this.options.backgroundColor),this.options.titleColor&&e.style.setProperty("--wulf-toast-title-color",this.options.titleColor),this.options.textColor&&e.style.setProperty("--wulf-toast-text-color",this.options.textColor),this.options.iconColor&&e.style.setProperty("--wulf-toast-icon-color",this.options.iconColor),this.options.closeButtonColor&&e.style.setProperty("--wulf-toast-close-color",this.options.closeButtonColor),this.options.icon&&this.options.icon.trim()!==""){let n=document.createElement("span");n.className=`wulf-toast-icon ${this.options.icon.trim()}`,n.setAttribute("aria-hidden","true"),e.appendChild(n)}let i=document.createElement("div");if(i.className="wulf-toast-content",this.options.title&&this.options.title.trim()!==""){let n=document.createElement("div");n.className="wulf-toast-title",this.appendTextWithLineBreaks(n,this.options.title),i.appendChild(n)}if(this.options.message&&this.options.message.trim()!==""){let n=document.createElement("div");n.className="wulf-toast-message",this.appendTextWithLineBreaks(n,this.options.message),i.appendChild(n)}if(e.appendChild(i),this.options.closable!==void 0?this.options.closable:this.remainingTime===0||this.options.closable===!0||!0){let n=document.createElement("button");n.type="button",n.className="wulf-toast-close",n.setAttribute("aria-label","Fermer la notification"),n.setAttribute("tabindex","0");let o=document.createElement("span");o.className="wulf-toast-close-icon",o.setAttribute("aria-hidden","true"),o.textContent="\xD7",n.appendChild(o),n.addEventListener("click",r=>{r.stopPropagation(),this.close("close-button")}),e.appendChild(n)}return e}appendTextWithLineBreaks(e,t){t.split(/\r\n|\r|\n/).forEach((s,n)=>{n>0&&e.appendChild(document.createElement("br")),e.appendChild(document.createTextNode(s))})}bindEvents(){this.element.addEventListener("click",e=>{this.options.onClick&&this.options.onClick(this,e)}),this.element.addEventListener("mouseenter",()=>this.pauseTimer()),this.element.addEventListener("mouseleave",()=>this.resumeTimer()),this.element.addEventListener("focusin",()=>this.pauseTimer()),this.element.addEventListener("focusout",()=>this.resumeTimer())}startTimer(){this._isClosed||this.remainingTime<=0||(this.timerStartTime=Date.now(),this.timerId=window.setTimeout(()=>{this.close("timeout")},this.remainingTime))}pauseTimer(){if(this._isClosed||this.remainingTime<=0||this.isPaused)return;this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null);let e=Date.now()-this.timerStartTime;this.remainingTime=Math.max(0,this.remainingTime-e),this.isPaused=!0}resumeTimer(){this._isClosed||this.remainingTime<=0||!this.isPaused||(this.isPaused=!1,this.startTimer())}destroyImmediate(e="replace"){this._isClosed||(this._isClosed=!0,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.onDismissCallback&&this.onDismissCallback(this,e),this.options.onClose&&this.options.onClose(this,e))}close(e="programmatic",t=!1){return this._isClosed?Promise.resolve():(this._isClosed=!0,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),new Promise(i=>{this.element.classList.add(t?"wulf-toast-hiding-fast":"wulf-toast-hiding");let s=()=>{this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.onDismissCallback&&this.onDismissCallback(this,e),this.options.onClose&&this.options.onClose(this,e),i()};if(typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)s();else if(t)window.setTimeout(s,90);else{let o=!1,r=()=>{o||(o=!0,this.element.removeEventListener("animationend",r),this.element.removeEventListener("transitionend",r),s())};this.element.addEventListener("animationend",r,{once:!0}),this.element.addEventListener("transitionend",r,{once:!0}),window.setTimeout(r,300)}}))}};var V=class V{constructor(){this.containers=new Map;this.activeToasts=new Map;this.replaceTokens=new Map;this.pendingReplacements=new Set}static getInstance(){return V.instance||(V.instance=new V),V.instance}add(e){let t=e.options.position||"top-right",i=this.activeToasts.get(t);if(i||(i=[],this.activeToasts.set(t,i)),e.options.replace&&i.length>0){let n=[...i],o=(this.replaceTokens.get(t)||0)+1;this.replaceTokens.set(t,o),this.pendingReplacements.add(t);let r=n.map(a=>a.close("replace",!0));Promise.all(r).then(()=>{this.pendingReplacements.delete(t),this.replaceTokens.get(t)===o&&this.mountToast(e,t)});return}let s=typeof e.options.maxToasts=="number"&&e.options.maxToasts>0?e.options.maxToasts:5;if(i.length>=s){let n=i.length-s+1,o=i.splice(0,n);for(let r of o)r.close("max-limit",!0)}this.mountToast(e,t)}mountToast(e,t){let i=this.getOrCreateContainer(t),s=this.activeToasts.get(t);if(s||(s=[],this.activeToasts.set(t,s)),i.appendChild(e.element),s.push(e),e.options.onOpen)try{e.options.onOpen(e)}catch(n){console.error("[Wulf.Toast] Erreur dans le callback onOpen:",n)}e.startTimer()}remove(e,t){let i=e.options.position||"top-right",s=this.activeToasts.get(i);if(s){let n=s.indexOf(e);if(n!==-1&&s.splice(n,1),s.length===0&&!this.pendingReplacements.has(i)){let o=this.containers.get(i);o&&(!o.firstChild||o.children.length===0)&&(o.parentNode&&o.parentNode.removeChild(o),this.containers.delete(i),this.activeToasts.delete(i))}}}clearAll(e){let t=[];if(e){let i=this.activeToasts.get(e);if(i&&i.length>0){let s=[...i];for(let n of s)t.push(n.close("programmatic"))}else{let s=this.containers.get(e);s&&(!s.firstChild||s.children.length===0)&&(s.parentNode&&s.parentNode.removeChild(s),this.containers.delete(e),this.activeToasts.delete(e))}}else{let i=new Set([...Array.from(this.containers.keys()),...Array.from(this.activeToasts.keys())]);for(let s of i)t.push(this.clearAll(s))}return Promise.all(t).then(()=>{if(!e)for(let[i,s]of Array.from(this.containers.entries()))(!s.firstChild||s.children.length===0)&&(s.parentNode&&s.parentNode.removeChild(s),this.containers.delete(i),this.activeToasts.delete(i))})}getOrCreateContainer(e){let t=this.containers.get(e);return(!t||!document.body.contains(t))&&(t=document.createElement("div"),t.className=`wulf-toast-container wulf-toast-${e}`,t.setAttribute("aria-live","polite"),t.setAttribute("aria-relevant","additions removals"),document.body.appendChild(t),this.containers.set(e,t)),t}};V.instance=null;var K=V;var U=class{static show(e={}){let t=K.getInstance(),i=new G(e,(s,n)=>{t.remove(s,n)});return t.add(i),i}static clearAll(e){return K.getInstance().clearAll(e)}};var mt=U;if(typeof window<"u"){let d=window,e=d.Wulf||{};d.Wulf=e,e.Toast=U}return ht(gt);})();
|
|
1
|
+
"use strict";var Wulf=(()=>{var rt=Object.defineProperty;var kt=Object.getOwnPropertyDescriptor;var Et=Object.getOwnPropertyNames;var Lt=Object.prototype.hasOwnProperty;var _=(p,i)=>{for(var t in i)rt(p,t,{get:i[t],enumerable:!0})},Mt=(p,i,t,e)=>{if(i&&typeof i=="object"||typeof i=="function")for(let s of Et(i))!Lt.call(p,s)&&s!==t&&rt(p,s,{get:()=>i[s],enumerable:!(e=kt(i,s))||e.enumerable});return p};var At=p=>Mt(rt({},"__esModule",{value:!0}),p);var Rt={};_(Rt,{AmountEngine:()=>P,AuditableComponent:()=>I,BaseInputMask:()=>x,EmailEngine:()=>V,FocusTrap:()=>vt,InputAmountMask:()=>q,InputEmailMask:()=>j,InputMask:()=>K,LocalizedComponent:()=>S,Mask:()=>lt,MaskEngine:()=>R,MaskHistory:()=>C,MaskKeyboard:()=>W,Masonry:()=>mt,Scroll:()=>ct,Toast:()=>bt,WulfFocusTrap:()=>N,createI18nManager:()=>D,default:()=>at,resolveMaskConstructorArgs:()=>H});var lt={};_(lt,{AmountEngine:()=>P,BaseInputMask:()=>x,EmailEngine:()=>V,InputAmountMask:()=>q,InputEmailMask:()=>j,InputMask:()=>K,Mask:()=>yt,MaskEngine:()=>R,MaskHistory:()=>C,MaskKeyboard:()=>W,default:()=>at,resolveMaskConstructorArgs:()=>H});var I=class{getAuditDisableHint(){return"Passez { audit: false } dans les options pour d\xE9sactiver cet avertissement"}runAuditWarning(i=!0){if(!i)return[];let t=this.audit();return t.length>0&&typeof console<"u"&&typeof console.warn=="function"&&console.warn(`[${this.getAuditPrefix()}] Audit d'accessibilit\xE9 \u2014 ${t.length} contrainte(s) manquante(s) sur ${this.getAuditTargetLabel()} :
|
|
2
|
+
`+t.map(e=>` - ${e}`).join(`
|
|
3
|
+
`)+`
|
|
4
|
+
(${this.getAuditDisableHint()})`),t}checkAriaIdReferences(i,t,e){let s=i.getAttribute(t)?.trim();if(!s)return!1;let o=i.ownerDocument||document,n=s.split(/\s+/).filter(Boolean),a=n.length>0&&n.every(r=>!!o.getElementById(r));return a||e.push(`Attribut ${t}="${s}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`),a}};function H(p,i,t){return i&&typeof i=="object"&&"tagName"in i&&i.tagName==="INPUT"?{wrapper:p||null,input:i,options:t||{}}:{wrapper:null,input:p,options:i&&typeof i=="object"&&!("tagName"in i)?i:{}}}var x=class extends I{constructor(t,e,s){super();this.ghost=null;this.isWrapperCreated=!1;this.isDestroyed=!1;this.isFocused=!1;this.isDispatchingNativeInput=!1;this.lastTrackedValue="";this.nativeValueDescriptor=null;this.onCutHandler=()=>{};this.mutationObserver=null;this.focusSelectTimerId=null;this.onBaseCopy=t=>{if(!this.options.copyRaw||this.options.disabled||this.input.type==="password")return;let e=this.input.selectionStart??0,s=this.input.selectionEnd??e,o="";e!==s?o=this.extractRawSnippet(this.input.value.slice(e,s)):o=this.getRawValue(),o&&t.clipboardData&&(t.preventDefault(),t.clipboardData.setData("text/plain",o))};this.onBaseFocus=()=>{this.isFocused=!0,this.options.selectAllOnFocus&&this.input.value.length>0&&(this.focusSelectTimerId!==null&&clearTimeout(this.focusSelectTimerId),this.focusSelectTimerId=window.setTimeout(()=>{this.focusSelectTimerId=null,!this.isDestroyed&&document.activeElement===this.input&&this.input.select()},0))};this.onBaseBlur=()=>{this.isFocused=!1};this.onScroll=()=>{this.ghost&&(this.ghost.scrollLeft=this.input.scrollLeft)};let{wrapper:o,input:n,options:a}=H(t,e,s);if(!n||typeof n!="object"||n.nodeType!==1||n.tagName!=="INPUT")throw new Error(`[${new.target.name||"InputMask"}] input (HTMLInputElement) est requis.`);this.input=n;let r=this.input.getAttribute("data-mask-create-wrapper")==="true",l=!!(a.createWrapper??r),h=o;if(!h&&l){let k=document.createElement("span");k.className="wulf-mask-wrapper",k.style.display="inline-grid",k.style.gridTemplateColumns="1fr",k.style.gridTemplateRows="1fr",k.style.verticalAlign="middle",k.style.boxSizing="border-box",k.style.position="relative",this.input.parentNode&&this.input.parentNode.insertBefore(k,this.input),k.appendChild(this.input),this.input.style.gridArea="1 / 1 / 2 / 2",this.input.style.boxSizing="border-box",h=k,this.isWrapperCreated=!0}if(!h)throw new Error(`[${new.target.name||"InputMask"}] wrapper (HTMLElement) et input (HTMLInputElement) sont requis, ou activez l'option createWrapper: true.`);this.wrapper=h,this.normalizeInputType();let c=this.getAttr("data-mask-focus-only")==="true",u=this.hasAttr("data-disabled"),d=this.getAttr("data-mask-select-on-focus")==="true",m=this.getAttr("data-mask-copy-raw")==="true",f=this.getAttr("data-mask-align")||this.getAttr("data-align"),g=this.getAttr("data-mask-audit"),{disabled:b,align:v,...w}=a,E=b!==void 0?b:!!u,y=a.audit??(g!==null?g!=="false":!0),T=this.input.type==="password";this.options={...w,createWrapper:l,showMaskOnFocus:a.showMaskOnFocus??c??!1,selectAllOnFocus:a.selectAllOnFocus??d??!1,copyRaw:T?!1:a.copyRaw??m??!1,disabled:E,align:v??(f||void 0),emitNativeInput:a.emitNativeInput??!0,audit:y},this.options.showMaskOnFocus&&this.wrapper.classList.add("mask-focus-only"),this.options.disabled&&this.wrapper.setAttribute("data-disabled","true"),this.options.align&&this.setAlign(this.options.align),this.createGhost(),this.hookValueProperty(),this.bindBaseEvents(),this.initMutationObserver()}getAttr(t){return this.input.getAttribute(t)||this.wrapper.getAttribute(t)}hasAttr(t){return this.wrapper.hasAttribute(t)||this.input.hasAttribute(t)}hasNativePlaceholder(){return!!(this.input.placeholder&&this.input.placeholder.trim().length>0)}shouldHideGhostForPlaceholder(t){return!this.isFocused&&t&&this.hasNativePlaceholder()}bindBaseEvents(){this.input.addEventListener("copy",this.onBaseCopy),this.input.addEventListener("focus",this.onBaseFocus),this.input.addEventListener("blur",this.onBaseBlur)}extractRawSnippet(t){return t}initMutationObserver(){if(typeof MutationObserver>"u")return;this.mutationObserver=new MutationObserver(e=>{for(let s of e)s.type==="attributes"&&s.attributeName&&this.handleAttributeMutation(s.attributeName)});let t={attributes:!0,attributeFilter:["data-mask","data-mask-placeholder","data-mask-focus-only","data-mask-strict","data-mask-select-on-focus","data-mask-copy-raw","data-mask-pad-decimals","data-mask-auto-lowercase","data-mask-cycle-suggestions","data-mask-default-tld","data-mask-tlds","data-disabled","data-mask-align","data-align","placeholder"]};this.mutationObserver.observe(this.wrapper,t),this.input!==this.wrapper&&this.mutationObserver.observe(this.input,t)}setAlign(t){let e=t||void 0,s=this.wrapper.getAttribute("data-align");this.options.align===e&&s===(t||null)||(this.options.align=e,this.wrapper.classList.remove("align-left","align-right","align-center"),t?(this.wrapper.classList.add(`align-${t}`),this.wrapper.getAttribute("data-align")!==t&&this.wrapper.setAttribute("data-align",t)):this.wrapper.hasAttribute("data-align")&&this.wrapper.removeAttribute("data-align"),this.syncGhostStyles())}handleAttributeMutation(t){if(t==="data-disabled"){let e=this.hasAttr("data-disabled");e!==!!this.options.disabled&&this.setDisabled(e)}else if(t==="data-mask-focus-only"){let e=this.getAttr("data-mask-focus-only")==="true";e!==!!this.options.showMaskOnFocus&&this.setShowMaskOnFocus(e)}else if(t==="data-mask-select-on-focus")this.options.selectAllOnFocus=this.getAttr("data-mask-select-on-focus")==="true";else if(t==="data-mask-copy-raw")this.options.copyRaw=this.getAttr("data-mask-copy-raw")==="true";else if(t==="data-mask-align"||t==="data-align"){let e=this.getAttr("data-mask-align")||this.getAttr("data-align");e!==(this.options.align??null)&&this.setAlign(e)}}normalizeInputType(){let t=["number","email","date","datetime-local","month","week","time","color","file","range"];if(this.input.type&&t.includes(this.input.type.toLowerCase())){let e=this.input.type.toLowerCase();this.input.type="text",e==="number"&&(this.input.inputMode="numeric")}}createGhost(){let t=this.wrapper.querySelector(".mask-ghost");t&&t.remove(),this.ghost=document.createElement("div"),this.ghost.className="mask-ghost",this.ghost.setAttribute("aria-hidden","true"),this.ghost.style.display="flex",this.ghost.style.alignItems="center",this.wrapper.appendChild(this.ghost),this.wrapper.classList.add("has-ghost"),this.syncGhostStyles()}syncGhostStyles(){if(!this.ghost||typeof window>"u")return;let t=window.getComputedStyle(this.input);if(!t)return;this.ghost.style.fontFamily=t.fontFamily,this.ghost.style.fontSize=t.fontSize,this.ghost.style.fontWeight=t.fontWeight,this.ghost.style.fontStyle=t.fontStyle,this.ghost.style.letterSpacing=t.letterSpacing,this.ghost.style.lineHeight=t.lineHeight,this.ghost.style.paddingTop=t.paddingTop,this.ghost.style.paddingBottom=t.paddingBottom,this.ghost.style.paddingLeft=t.paddingLeft,this.ghost.style.paddingRight=t.paddingRight,this.ghost.style.borderTopWidth=t.borderTopWidth,this.ghost.style.borderBottomWidth=t.borderBottomWidth,this.ghost.style.borderLeftWidth=t.borderLeftWidth,this.ghost.style.borderRightWidth=t.borderRightWidth,this.ghost.style.borderTopStyle=t.borderTopStyle==="none"?"none":"solid",this.ghost.style.borderBottomStyle=t.borderBottomStyle==="none"?"none":"solid",this.ghost.style.borderLeftStyle=t.borderLeftStyle==="none"?"none":"solid",this.ghost.style.borderRightStyle=t.borderRightStyle==="none"?"none":"solid",this.ghost.style.borderColor="transparent",this.ghost.style.boxSizing=t.boxSizing,this.ghost.style.textAlign=t.textAlign,this.ghost.style.direction=t.direction;let e=t.direction==="rtl"||this.input.getAttribute("dir")==="rtl"||this.wrapper.getAttribute("dir")==="rtl";t.textAlign==="right"||t.textAlign==="end"||e&&t.textAlign!=="left"&&t.textAlign!=="center"?this.ghost.style.justifyContent="flex-end":t.textAlign==="center"?this.ghost.style.justifyContent="center":this.ghost.style.justifyContent="flex-start"}setNativeValue(t){this.nativeValueDescriptor&&this.nativeValueDescriptor.set?this.nativeValueDescriptor.set.call(this.input,t):this.input.value=t}dispatchNativeInput(){if(!(this.isDestroyed||typeof window>"u")&&this.options.emitNativeInput!==!1){this.isDispatchingNativeInput=!0;try{let t=this.input._valueTracker;t&&typeof t.setValue=="function"&&t.setValue(this.lastTrackedValue),this.lastTrackedValue=this.input.value,this.input.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))}finally{this.isDispatchingNativeInput=!1}}}hookValueProperty(){try{let t=HTMLInputElement.prototype,e=Object.getOwnPropertyDescriptor(t,"value");if(!e||!e.set||!e.get)return;this.nativeValueDescriptor=e;let s=this;Object.defineProperty(this.input,"value",{get(){return e.get.call(this)},set(o){let n=String(o??"");e.set.call(this,n),!s.isDestroyed&&s.onNativeValueSet(n)},configurable:!0})}catch{}}unhookValueProperty(){try{delete this.input.value}catch{}}setShowMaskOnFocus(t){this.options.showMaskOnFocus=t,this.wrapper.classList.toggle("mask-focus-only",t)}disabled(t){if(t===void 0)return!!this.options.disabled;this.setDisabled(t)}setDisabled(t){this.options.disabled=!!t,this.options.disabled?this.wrapper.setAttribute("data-disabled","true"):this.wrapper.removeAttribute("data-disabled"),this.onDisabledChange(this.options.disabled)}getWrapper(){return this.wrapper}getInput(){return this.input}getGhost(){return this.ghost}getElements(){return{wrapper:this.wrapper,input:this.input,ghost:this.ghost}}getValue(){return this.input.value}getRawValue(){return this.input.value}audit(){let t=[],e=this.input.ownerDocument||document,s=this.input.getAttribute("aria-label")?.trim(),o=this.checkAriaIdReferences(this.input,"aria-labelledby",t),n=!!this.input.closest("label"),a=!!(this.input.labels&&this.input.labels.length>0),r=!1;this.input.id&&typeof CSS<"u"&&typeof CSS.escape=="function"?r=!!e.querySelector(`label[for="${CSS.escape(this.input.id)}"]`):this.input.id&&(r=!!e.querySelector(`label[for="${this.input.id}"]`)),!s&&!o&&!n&&!a&&!r&&t.push(`\xC9tiquetage accessible manquant : associez un <label for="id"> (ou d\xE9finissez aria-label / aria-labelledby) sur l'input (WCAG 4.1.2).`),this.checkAriaIdReferences(this.input,"aria-describedby",t);let l=this.getSpecificAuditWarnings();return t.push(...l),t}getAuditPrefix(){return`Wulf.Mask.${this.constructor.name||"InputMask"}`}getAuditTargetLabel(){return this.input.id?`#${this.input.id}`:this.input.name?`input[name="${this.input.name}"]`:"<input>"}getAuditDisableHint(){return'Passez { audit: false } ou data-mask-audit="false" pour d\xE9sactiver cet avertissement'}getSpecificAuditWarnings(){return[]}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.focusSelectTimerId!==null&&(clearTimeout(this.focusSelectTimerId),this.focusSelectTimerId=null),this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),this.input.removeEventListener("copy",this.onBaseCopy),this.input.removeEventListener("focus",this.onBaseFocus),this.input.removeEventListener("blur",this.onBaseBlur),this.unhookValueProperty(),this.ghost&&(this.ghost.remove(),this.ghost=null),this.isWrapperCreated&&this.wrapper?(this.input.style.gridArea="",this.input.style.boxSizing="",this.wrapper.parentNode&&this.wrapper.parentNode.insertBefore(this.input,this.wrapper),this.wrapper.remove()):this.wrapper&&(this.wrapper.removeAttribute("data-mask"),this.wrapper.removeAttribute("data-disabled"),this.wrapper.classList.remove("is-complete","is-focused","mask-focus-only","has-selection","has-ghost")))}};var St={9:{pattern:/[0-9]/},a:{pattern:/[a-zA-Z]/},A:{pattern:/[a-zA-Z]/,transform:p=>p.toUpperCase()},"*":{pattern:/[a-zA-Z0-9]/},"#":{pattern:/[a-zA-Z0-9]/,transform:p=>p.toUpperCase()}},R=class p{constructor(i,t={}){this.patterns=[];this.subEngines=[];this.activeEngine=null;this.slots=[];this.fullMaskTemplate="";this.prefixSlotsCount=0;this.prefixString="";this.strict=!0;this.autoLowercase=!1;let e=t||{};this.placeholderChar=e.placeholderChar||"_",this.tokens={...St,...e.tokens||{}},this.strict=e.strict!==!1,this.autoLowercase=e.autoLowercase??!1,this.pattern="",this.compile(i)}static format(i,t,e={}){return!t||Array.isArray(t)&&t.length===0?i??"":new p(t,e||{}).format(i??"")}compile(i){if(i!==void 0&&(Array.isArray(i)?(this.patterns=[...i],this.pattern=this.patterns[0]||""):(this.patterns=[],this.pattern=i)),this.patterns.length>0)return this.subEngines=this.patterns.map(s=>new p(s,{placeholderChar:this.placeholderChar,tokens:this.tokens,strict:this.strict,autoLowercase:this.autoLowercase})),this.activeEngine=this.subEngines[0],this.slots=this.activeEngine.slots,this.fullMaskTemplate=this.activeEngine.fullMaskTemplate,this.prefixSlotsCount=this.activeEngine.prefixSlotsCount,this.prefixString=this.activeEngine.prefixString,this.slots;this.subEngines=[],this.activeEngine=null,this.slots=[];let t="",e=!0;for(let s=0;s<this.pattern.length;s++){let o=this.pattern[s],n=!1;o==="\\"&&s+1<this.pattern.length&&(n=!0,s++,o=this.pattern[s]);let a=n?void 0:this.tokens[o];a?(e=!1,this.slots.push({char:o,isStatic:!1,isPrefix:!1,token:a,placeholder:this.placeholderChar}),t+=this.placeholderChar):(this.slots.push({char:o,isStatic:!0,isPrefix:e,placeholder:o}),t+=o)}this.fullMaskTemplate=t,this.prefixSlotsCount=0,this.prefixString="";for(let s of this.slots)if(s.isPrefix)this.prefixSlotsCount++,this.prefixString+=s.char;else break;return this.slots}selectEngine(i){if(this.subEngines.length<=1)return this;let t=String(i??""),e=this.subEngines.filter(r=>{let l=r.getPrefix();return l.length>0&&t.toLowerCase().startsWith(l.trim().toLowerCase())}),s=e.length>0?e:this.subEngines,o=[...s].sort((r,l)=>l.getEditableCount()-r.getEditableCount())[0],a=(o?o.extractRaw(t):t).length;for(let r of s)if(r.getEditableCount()>=a)return this.activeEngine=r,r;return this.activeEngine=s[s.length-1],this.activeEngine}getPrefix(){return this.activeEngine?this.activeEngine.getPrefix():this.prefixString}getPrefixLength(){return this.activeEngine?this.activeEngine.getPrefixLength():this.prefixSlotsCount}getFullMaskTemplate(){return this.activeEngine?this.activeEngine.getFullMaskTemplate():this.fullMaskTemplate}getEditableCount(){return this.subEngines.length>0?Math.max(...this.subEngines.map(i=>i.getEditableCount())):this.activeEngine?this.activeEngine.getEditableCount():this.slots.filter(i=>!i.isStatic).length}isNumericOnly(){if(this.subEngines.length>0)return this.subEngines.every(e=>e.isNumericOnly());let t=(this.activeEngine?this.activeEngine.slots:this.slots).filter(e=>!e.isStatic);return t.length===0?!1:t.every(e=>e.char==="9"||e.token&&e.token.pattern.test("0")&&!e.token.pattern.test("a")&&!e.token.pattern.test("Z"))}setStrict(i){this.strict=i}isStrict(){return this.strict}extractRaw(i){if(this.subEngines.length>0){let n=this.selectEngine(i);if(n!==this)return n.extractRaw(i)}let t=String(i??"");if(!t)return"";let e="",s=0,o=0;if(this.prefixSlotsCount>0){for(;s<t.length&&(t[s]===" "||t[s]===" ");)s++;let n=0;for(;s<t.length&&n<this.prefixSlotsCount;){let a=this.slots[n].char,r=t[s];if(r.toUpperCase()===a.toUpperCase())s++,n++;else if(a===" "&&r!==" ")n++;else break}o=this.prefixSlotsCount}for(;s<t.length&&o<this.slots.length;){let n=this.slots[o],a=t[s];if(n.isStatic)a.toUpperCase()===n.char.toUpperCase()&&s++,o++;else if(n.token&&n.token.pattern.test(a)){let r=n.token.transform?n.token.transform(a):a;this.autoLowercase&&!n.token.transform&&(r=r.toLowerCase()),e+=r,s++,o++}else this.strict?s++:(e+=this.autoLowercase?a.toLowerCase():a,s++,o++)}if(!this.strict&&s<t.length){let n=t.slice(s);e+=this.autoLowercase?n.toLowerCase():n}return e}format(i){if(this.subEngines.length>0){let n=this.selectEngine(i);if(n!==this)return n.format(i)}let t=String(i??"");if(!this.slots.length)return t;let e=this.extractRaw(t);if(e.length===0)return this.prefixString;let s="",o=0;for(let n=0;n<this.slots.length;n++){let a=this.slots[n];if(a.isStatic){let r=o<e.length,l=o===0&&!!a.isPrefix,h=o>0&&o===e.length;if(r||l||h)s+=a.char;else break}else if(o<e.length){let r=e[o],l=a.token?.transform?a.token.transform(r):r;this.autoLowercase&&!a.token?.transform&&(l=l.toLowerCase()),s+=l,o++}else break}if(!this.strict&&o<e.length){let n=e.substring(o);s+=this.autoLowercase?n.toLowerCase():n}return s}getRemainingMask(i){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getRemainingMask(i):this.fullMaskTemplate?i.length>=this.fullMaskTemplate.length?i:i+this.fullMaskTemplate.substring(i.length):""}mapCursorPosition(i,t,e){if(this.activeEngine&&this.activeEngine!==this)return this.activeEngine.mapCursorPosition(i,t,e);let s=this.prefixSlotsCount,o=String(i??""),n=String(e??"");if(t<=0||!n)return s;let r=this.extractRaw(o.slice(0,t)).length;if(r===0)return Math.max(s,Math.min(this.getNextEditablePosition(0),n.length));let l=0,h=n.length;for(let c=0;c<n.length&&c<this.slots.length;c++)if(!this.slots[c].isStatic&&(l++,l===r)){h=c+1;break}for(;h<n.length&&this.slots[h]&&this.slots[h].isStatic;)h++;return Math.max(s,Math.min(h,n.length))}isSeparatorAt(i){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.isSeparatorAt(i):i>=0&&i<this.slots.length?this.slots[i].isStatic:!1}getNextEditablePosition(i){if(this.activeEngine&&this.activeEngine!==this)return this.activeEngine.getNextEditablePosition(i);let t=Math.max(0,i);for(let e=t;e<this.slots.length;e++)if(!this.slots[e].isStatic)return e;return this.slots.length}getSlotAt(i){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getSlotAt(i):this.slots[i]}getSlots(){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getSlots():this.slots}};var C=class{constructor(i=50){this.stack=[];this.index=-1;this.maxDepth=i}push(i,t){let e=this.getCurrent();if(e&&e.raw===i){e.cursor=t;return}this.stack=this.stack.slice(0,this.index+1),this.stack.push({raw:i,cursor:t}),this.stack.length>this.maxDepth&&this.stack.shift(),this.index=this.stack.length-1}updateCurrentCursor(i){let t=this.getCurrent();t&&(t.cursor=i)}undo(){return this.canUndo()?(this.index--,this.stack[this.index]):null}redo(){return this.canRedo()?(this.index++,this.stack[this.index]):null}canUndo(){return this.index>0}canRedo(){return this.index>=0&&this.index<this.stack.length-1}getCurrent(){return this.index>=0&&this.index<this.stack.length?this.stack[this.index]:null}clear(){this.stack=[],this.index=-1}};var W=class{constructor(i){this.delegate=i}handleKeyDown(i){let t=this.delegate.getInput(),e=this.delegate.getEngine(),s=this.delegate.getHistory(),o=e.getPrefixLength(),n=t.selectionStart??0,a=t.selectionEnd??n;if((i.ctrlKey||i.metaKey)&&(i.key==="z"||i.key==="Z")&&!i.shiftKey){i.preventDefault(),this.delegate.undo();return}if((i.ctrlKey||i.metaKey)&&(i.key==="y"||i.key==="Y")||(i.ctrlKey||i.metaKey)&&i.shiftKey&&(i.key==="z"||i.key==="Z")){i.preventDefault(),this.delegate.redo();return}s.updateCurrentCursor(n);let r=i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey,l=a>n;if(r&&!l){let u=e.getSlots(),d=n<u.length&&u[n].isStatic&&u[n].char===i.key,m=n>0&&n-1<u.length&&u[n-1].isStatic&&u[n-1].char===i.key;if(d||m){i.preventDefault();let g=d?n:n-1,b=e.getNextEditablePosition(g+1);this.delegate.applyMask(t.value,b,!0);return}let f=-1;for(let g=n;g<u.length;g++)if(u[g].isStatic){u[g].char===i.key&&(f=g);break}if(f!==-1){i.preventDefault();let g=f-1;for(;g>=o&&!u[g].isStatic;)g--;g++;let b=f-g,v=t.value.slice(g,n);if(u.slice(g,f).every(y=>!y.token||y.token.pattern.test("0"))&&b>v.length&&v.length>0){let y=b-v.length,T="0".repeat(y)+v,k=t.value.slice(f),et=t.value.slice(0,g)+T+k,L=e.getNextEditablePosition(f+1);this.delegate.applyMask(et,L,!0);return}let E=e.getNextEditablePosition(f+1);this.delegate.applyMask(t.value,E,!0);return}}if(r&&e.isStrict()){let u=e.getEditableCount();if(u>0){let d=e.extractRaw(t.value),m=u-d.length;if(a>n){let f=e.extractRaw(t.value.slice(n,a));m=u-(d.length-f.length)}if(m<=0){i.preventDefault();return}}}if(a>n){if(i.key==="Backspace"||i.key==="Delete"){i.preventDefault();let u=t.value,d=u.slice(0,n)+u.slice(a);this.delegate.applyMask(d,Math.max(o,n));return}return}if(i.key==="ArrowLeft"&&!i.shiftKey&&n<=o){i.preventDefault(),t.setSelectionRange(o,o);return}if(i.key==="Home"&&!i.shiftKey){i.preventDefault(),t.setSelectionRange(o,o);return}if(i.key==="Backspace"&&n<=o){i.preventDefault(),t.setSelectionRange(o,o);return}if(i.key==="Delete"&&n<o){i.preventDefault(),t.setSelectionRange(o,o);return}if(i.key==="Backspace"&&(i.ctrlKey||i.altKey||i.metaKey)){if(i.preventDefault(),n<=o){t.setSelectionRange(o,o);return}let u=n-1;for(;u>=o&&e.isSeparatorAt(u);)u--;for(;u>=o&&!e.isSeparatorAt(u);)u--;let d=Math.max(o,u+1),m=t.value,f=m.slice(0,d)+m.slice(n);this.delegate.applyMask(f,d);return}if(i.key==="Delete"&&(i.ctrlKey||i.altKey||i.metaKey)){i.preventDefault();let u=t.value;if(n>=u.length)return;let d=n;for(;d<u.length&&e.isSeparatorAt(d);)d++;for(;d<u.length&&!e.isSeparatorAt(d);)d++;for(;d<u.length&&e.isSeparatorAt(d);)d++;let m=d,f=u.slice(0,n)+u.slice(m);this.delegate.applyMask(f,n);return}if(i.key==="Backspace"&&n>o){if(e.isSeparatorAt(n-1)){i.preventDefault();let u=n-1;for(;u>o&&e.isSeparatorAt(u-1);)u--;if(u>o){let d=t.value,m=d.slice(0,u-1)+d.slice(n);this.delegate.applyMask(m,u-1)}else this.delegate.applyMask("",o)}return}if(i.key==="Delete"&&n<t.value.length){if(e.isSeparatorAt(n)){i.preventDefault();let u=n;for(;u<t.value.length&&e.isSeparatorAt(u);)u++;if(u<t.value.length){let d=t.value,m=d.slice(0,u)+d.slice(u+1);this.delegate.applyMask(m,n)}}return}}handleKeyUp(i){let t=this.delegate.getInput(),e=this.delegate.getHistory();(i.key==="ArrowLeft"||i.key==="ArrowRight"||i.key==="Home")&&!i.shiftKey&&this.delegate.enforceMinCursor(),e.updateCurrentCursor(t.selectionStart??0)}};var K=class extends x{constructor(t,e,s){let o=H(t,e,s),n=o.wrapper,a=o.input,r=o.options,l=n?.getAttribute("data-mask")||a?.getAttribute("data-mask"),h=r.mask||l||"";typeof h=="string"&&h.includes("|")&&(h=h.split("|").map(y=>y.trim()));let c=r.placeholderChar||n?.getAttribute("data-mask-placeholder")||a?.getAttribute("data-mask-placeholder")||"_",u=n?.hasAttribute("data-disabled")||a?.hasAttribute("data-disabled"),d=n?.getAttribute("data-mask-strict")||a?.getAttribute("data-mask-strict"),m=n?.getAttribute("data-mask-auto-lowercase")==="true"||a?.getAttribute("data-mask-auto-lowercase")==="true",f=n?.getAttribute("data-mask-infer-inputmode")??a?.getAttribute("data-mask-infer-inputmode"),g=r.inferInputMode??(f!==null?f!=="false":!0),{disabled:b,...v}=r,w=b!==void 0?b:u?!0:!h||Array.isArray(h)&&h.length===0,E={...v,mask:h,placeholderChar:c,strict:r.strict??(d!==null?d!=="false":!0),autoLowercase:r.autoLowercase??m??!1,disabled:w,resetHistoryOnMaskChange:r.resetHistoryOnMaskChange??!1,inferInputMode:g,onInput:r.onInput||r.oninput,onChange:r.onChange||r.onchange,onComplete:r.onComplete||r.oncomplete};super(n,a,E);this.isComposing=!1;this.isUndoingRedoing=!1;this.isMouseDown=!1;this.isApplyingMask=!1;this.lastValue="";this.lastInternalRemainingMask="";this.isNotifying=!1;this.hasPendingNotification=!1;this.onChangeNativeHandler=()=>{};this.wasInputModeInferred=!1;this.cutTimerId=null;this.pasteTimerId=null;this.resetTimerId=null;this.history=new C,this.engine=new R(this.options.mask||"",{placeholderChar:this.options.placeholderChar,tokens:this.options.tokens,strict:this.options.strict,autoLowercase:this.options.autoLowercase}),this.syncInferredInputMode(),this.keyboard=new W({getInput:()=>this.input,getEngine:()=>this.engine,getHistory:()=>this.history,applyMask:(y,T,k)=>this.applyMask(y,T,k),undo:()=>this.undo(),redo:()=>this.redo(),enforceMinCursor:()=>this.enforceMinCursor()}),this.bindEvents(),this.lastValue=this.input.value,this.syncInitialValue(),this.runAuditWarning(this.options.audit)}getSpecificAuditWarnings(){let t=[],e=!!this.input.getAttribute("aria-describedby")?.trim(),s=!!this.input.getAttribute("placeholder")?.trim(),o=!!this.input.getAttribute("aria-placeholder")?.trim();return!e&&!s&&!o&&!this.options.disabled&&t.push("Indication du format attendu manquante : d\xE9finissez aria-describedby, placeholder ou aria-placeholder pour informer les technologies d'assistance (WCAG 3.3.2)."),t}extractRawSnippet(t){return this.engine.extractRaw(t)}static format(t,e,s={}){return R.format(t,e,s)}onNativeValueSet(t){this.options.disabled?this.checkValueChange():this.applyMask(t,t.length)}onDisabledChange(t){t?(this.wrapper.removeAttribute("data-mask"),this.wrapper.classList.remove("is-complete","has-selection"),this.ghost&&(this.ghost.textContent=""),this.checkValueChange()):this.applyMask(this.input.value,this.input.selectionStart??this.input.value.length)}bindEvents(){this.handleInput=this.handleInput.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onPaste=this.onPaste.bind(this),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this),this.onClick=this.onClick.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onSelect=this.onSelect.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onCompositionStart=this.onCompositionStart.bind(this),this.onCompositionEnd=this.onCompositionEnd.bind(this),this.onScroll=this.onScroll.bind(this),this.onBeforeInput=this.onBeforeInput.bind(this),this.onCutHandler=()=>{this.cutTimerId!==null&&clearTimeout(this.cutTimerId),this.cutTimerId=window.setTimeout(()=>{if(this.cutTimerId=null,!this.isDestroyed)if(this.options.disabled)this.checkValueChange();else{let t=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,t)}},0)},this.onChangeNativeHandler=()=>{this.isDestroyed||this.checkValueChange()},this.input.addEventListener("beforeinput",this.onBeforeInput),this.input.addEventListener("input",this.handleInput),this.input.addEventListener("keydown",this.onKeyDown),this.input.addEventListener("paste",this.onPaste),this.input.addEventListener("focus",this.onFocus),this.input.addEventListener("blur",this.onBlur),this.input.addEventListener("click",this.onClick),this.input.addEventListener("keyup",this.onKeyUp),this.input.addEventListener("select",this.onSelect),this.input.addEventListener("mousedown",this.onMouseDown),window.addEventListener("mouseup",this.onMouseUp),this.input.addEventListener("compositionstart",this.onCompositionStart),this.input.addEventListener("compositionend",this.onCompositionEnd),this.input.addEventListener("scroll",this.onScroll),this.input.addEventListener("cut",this.onCutHandler),this.input.addEventListener("change",this.onChangeNativeHandler),this.input.form&&(this.onFormResetHandler=()=>{this.resetTimerId!==null&&clearTimeout(this.resetTimerId),this.resetTimerId=window.setTimeout(()=>{this.resetTimerId=null,!this.isDestroyed&&(this.options.disabled?this.checkValueChange():this.syncInitialValue())},0)},this.input.form.addEventListener("reset",this.onFormResetHandler))}syncInferredInputMode(){if(!this.options.inferInputMode)return;!this.options.disabled&&this.engine.isNumericOnly()?this.input.hasAttribute("inputmode")||(this.input.inputMode="numeric",this.wasInputModeInferred=!0):this.wasInputModeInferred&&this.input.getAttribute("inputmode")==="numeric"&&(this.input.removeAttribute("inputmode"),this.wasInputModeInferred=!1)}destroy(){this.isDestroyed||(this.cutTimerId!==null&&(clearTimeout(this.cutTimerId),this.cutTimerId=null),this.pasteTimerId!==null&&(clearTimeout(this.pasteTimerId),this.pasteTimerId=null),this.resetTimerId!==null&&(clearTimeout(this.resetTimerId),this.resetTimerId=null),this.input.removeEventListener("beforeinput",this.onBeforeInput),this.input.removeEventListener("input",this.handleInput),this.input.removeEventListener("keydown",this.onKeyDown),this.input.removeEventListener("paste",this.onPaste),this.input.removeEventListener("focus",this.onFocus),this.input.removeEventListener("blur",this.onBlur),this.input.removeEventListener("click",this.onClick),this.input.removeEventListener("keyup",this.onKeyUp),this.input.removeEventListener("select",this.onSelect),this.input.removeEventListener("mousedown",this.onMouseDown),window.removeEventListener("mouseup",this.onMouseUp),this.input.removeEventListener("compositionstart",this.onCompositionStart),this.input.removeEventListener("compositionend",this.onCompositionEnd),this.input.removeEventListener("scroll",this.onScroll),this.input.removeEventListener("cut",this.onCutHandler),this.input.removeEventListener("change",this.onChangeNativeHandler),this.input.form&&this.onFormResetHandler&&this.input.form.removeEventListener("reset",this.onFormResetHandler),this.wasInputModeInferred&&this.input.getAttribute("inputmode")==="numeric"&&this.input.removeAttribute("inputmode"),this.history.clear(),super.destroy())}setStrict(t){this.options.strict=t,this.engine.setStrict(t),this.options.disabled||this.applyMask(this.input.value,this.input.selectionStart??this.input.value.length)}isStrict(){return this.engine.isStrict()}setMask(t,e){let s=typeof e=="boolean"?e:e&&typeof e=="object"&&e.strict!==void 0?e.strict:this.options.strict,o=e&&typeof e=="object"&&e.resetHistory!==void 0?e.resetHistory:!!this.options.resetHistoryOnMaskChange;if(!((!t||Array.isArray(t)&&t.length===0)&&this.options.disabled&&(!this.options.mask||this.options.mask===""))){if(!t||Array.isArray(t)&&t.length===0){this.options.mask="",this.options.strict=s,this.engine.setStrict(s??!0),this.engine.compile(""),o&&this.history.clear(),this.setDisabled(!0),this.syncInferredInputMode();return}this.options.mask=t,this.options.strict=s,this.engine.setStrict(s??!0),this.engine.compile(t),o&&this.history.clear(),this.setDisabled(!1),this.syncInferredInputMode()}}handleAttributeMutation(t){if(super.handleAttributeMutation(t),t==="data-mask"){let e=this.getAttr("data-mask");if(e===this.lastInternalRemainingMask)return;let s=Array.isArray(this.options.mask)?this.options.mask.join("|"):this.options.mask||"";if(e===s)return;if(e){let o=e.includes("|")?e.split("|").map(n=>n.trim()):e;this.setMask(o)}else this.setMask(null)}else if(t==="data-mask-strict"){let e=this.getAttr("data-mask-strict");this.setStrict(e!=="false")}else t==="data-mask-auto-lowercase"?(this.options.autoLowercase=this.getAttr("data-mask-auto-lowercase")==="true",this.engine.compile(this.options.mask||""),this.applyMask(this.input.value,this.input.selectionStart??this.input.value.length)):t==="placeholder"&&this.updateGhost(this.input.value)}setValue(t){let e=t!=null?String(t):"";if(this.options.disabled){this.input.value=e,this.checkValueChange();return}this.applyMask(e,e.length)}getRawValue(){return this.engine.extractRaw(this.input.value)}isComplete(){return this.options.disabled?!0:this.getRawValue().length>=this.engine.getEditableCount()}get onInput(){return this.options.onInput}set onInput(t){this.options.onInput=t}undo(){if(this.options.disabled)return;let t=this.history.undo();t&&(this.isUndoingRedoing=!0,this.applyMask(t.raw,t.cursor),this.isUndoingRedoing=!1)}redo(){if(this.options.disabled)return;let t=this.history.redo();t&&(this.isUndoingRedoing=!0,this.applyMask(t.raw,t.cursor),this.isUndoingRedoing=!1)}checkSelection(){if(this.options.disabled)return;let t=this.input.selectionStart??0,e=this.input.selectionEnd??t,s=t!==e;this.wrapper.classList.toggle("has-selection",s)}onBeforeInput(t){if(!this.options.disabled&&!this.isComposing&&this.engine.isStrict()&&t.inputType!=="insertFromPaste"&&t.inputType&&t.inputType.startsWith("insert")){let e=this.engine.getEditableCount();if(e>0){let s=this.getRawValue(),o=this.input.selectionStart??0,n=this.input.selectionEnd??o,a=Math.max(0,e-s.length);if(n>o){let r=this.engine.extractRaw(this.input.value.slice(o,n));a=Math.max(0,e-(s.length-r.length))}a<=0&&t.preventDefault()}}}handleInput(t){if(this.isDispatchingNativeInput||this.isComposing)return;if(!!(this.options.onInput||this.options.oninput)&&this.input.value!==this.lastValue&&this.checkValueChange(),this.options.disabled){this.checkValueChange();return}let s=this.history.getCurrent(),o=this.engine.getEditableCount();if(o>0&&this.engine.isStrict()&&s&&s.raw.length>=o&&this.engine.extractRaw(this.input.value).length>o){this.applyMask(s.raw,s.cursor);return}let n=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,n),this.checkSelection()}onKeyDown(t){this.options.disabled||this.keyboard.handleKeyDown(t)}onMouseDown(){this.isMouseDown=!0}onMouseUp(){this.isMouseDown=!1,this.checkSelection()}onPaste(t){if(this.options.disabled){this.pasteTimerId!==null&&clearTimeout(this.pasteTimerId),this.pasteTimerId=window.setTimeout(()=>{this.pasteTimerId=null,this.isDestroyed||this.checkValueChange()},0);return}t.preventDefault(),this.history.updateCurrentCursor(this.input.selectionStart??0);let s=(t.clipboardData?.getData("text")||"").trim();if(!s)return;let o=this.engine.getPrefixLength(),n=this.input.selectionStart??0,a=this.input.selectionEnd??n,r=this.input.value,l=this.engine.getEditableCount(),h=this.getRawValue(),u=this.engine.getPrefix().replace(/[\s.-]+/g,"").toUpperCase(),d=s.replace(/[\s.-]+/g,"").toUpperCase(),m=u.length>0&&d.startsWith(u),f=r.slice(0,Math.max(o,n)).replace(/[\s.-]+/g,"").toUpperCase(),g=f.length>=2&&d.startsWith(f),b=Math.max(o,n),v=Math.max(o,a);(m||g)&&(b=0,v=r.length);let w=Math.max(0,l-h.length);if(b!==v){let T=this.engine.extractRaw(r.slice(b,v));w=Math.max(0,l-(h.length-T.length))}if(this.engine.isStrict()&&w<=0)return;let E,y;b===0&&v===r.length?(E=s,y=s.length):(E=r.slice(0,b)+s+r.slice(v),y=b+s.length),this.applyMask(E,y),this.checkSelection()}onFocus(){this.syncGhostStyles(),this.wrapper.classList.add("is-focused"),!this.options.disabled&&!this.isMouseDown&&this.enforceMinCursor(),this.updateGhost(this.input.value),this.checkSelection()}onBlur(){this.wrapper.classList.remove("is-focused","has-selection"),this.input.type==="password"&&this.history.clear(),this.updateGhost(this.input.value)}onClick(){this.options.disabled||this.enforceMinCursor(),this.history.updateCurrentCursor(this.input.selectionStart??0),this.checkSelection()}onKeyUp(t){this.options.disabled||this.keyboard.handleKeyUp(t),this.checkSelection()}onSelect(){this.history.updateCurrentCursor(this.input.selectionStart??0),this.checkSelection()}onCompositionStart(){this.isComposing=!0}onCompositionEnd(){if(this.isComposing=!1,this.options.disabled)return;let t=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,t),this.checkSelection()}enforceMinCursor(){let t=this.engine.getPrefixLength();if(t<=0)return;let e=this.input.selectionStart??0,s=this.input.selectionEnd??e;e===s&&e<t&&this.input.setSelectionRange(t,t)}updateGhost(t){if(!this.ghost)return;if(this.options.disabled){this.ghost.textContent="";return}let e=!t||t===this.engine.getPrefix();if(this.shouldHideGhostForPlaceholder(e)){this.ghost.textContent="";return}let s=this.engine.getFullMaskTemplate(),o=s.length>t.length?s.substring(t.length):"";this.ghost.textContent="";let n=document.createElement("span");n.className="mask-ghost-typed",n.textContent=t;let a=document.createElement("span");a.className="mask-ghost-remaining",a.textContent=o,this.ghost.appendChild(n),this.ghost.appendChild(a),this.ghost.scrollLeft=this.input.scrollLeft}applyMask(t,e,s=!1){if(this.options.disabled||this.isApplyingMask)return;this.isApplyingMask=!0;let o="",n=!1;try{o=this.engine.format(t);let a=this.engine.getRemainingMask(o);this.input.value=o,this.lastInternalRemainingMask=a,this.wrapper.setAttribute("data-mask",a),this.updateGhost(o);let r=this.engine.getPrefixLength(),l;if(s||this.isUndoingRedoing)l=Math.max(r,Math.min(e,o.length));else{let h=this.engine.mapCursorPosition(t,e,o);l=Math.max(r,h)}this.input.setSelectionRange(l,l),n=this.isComplete(),this.wrapper.classList.toggle("is-complete",n),!this.isUndoingRedoing&&this.input.type!=="password"&&this.history.push(this.getRawValue(),l)}finally{this.isApplyingMask=!1}this.checkValueChange()}syncInitialValue(){if(this.options.disabled){this.wrapper.removeAttribute("data-mask"),this.ghost&&(this.ghost.textContent=""),this.lastValue=this.input.value,this.checkValueChange();return}this.syncGhostStyles();let t=this.input.value||"";if(t)this.applyMask(t,t.length);else{let e=this.engine.getPrefixLength();if(e>0)this.applyMask("",e);else{this.input.type!=="password"&&this.history.push("",0);let s=this.engine.getFullMaskTemplate();this.lastInternalRemainingMask=s,this.wrapper.setAttribute("data-mask",s),this.updateGhost(""),this.checkValueChange()}}}checkValueChange(t=!1){if(!(this.input.value===this.lastValue&&!t&&!this.hasPendingNotification)){if(this.isNotifying){this.hasPendingNotification=!0;return}this.isNotifying=!0;try{for(;this.input.value!==this.lastValue||this.hasPendingNotification||t;){this.hasPendingNotification=!1,t=!1;let s=this.input.value;this.lastValue=s;let o=this.options.disabled?s:this.getRawValue(),n=this.options.disabled?0:this.engine.getEditableCount(),a=this.isComplete(),r={value:s,rawValue:o,isComplete:a,totalSlots:n,filledSlots:this.options.disabled?s.length:o.length},l=this.options.onInput||this.options.oninput;l&&l(s,r),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:r})),this.dispatchNativeInput();let h=this.options.onChange||this.options.onchange;h&&h(r),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:r}));let c=this.options.onComplete||this.options.oncomplete;a&&(c&&c(r),this.input.dispatchEvent(new CustomEvent("mask:complete",{bubbles:!0,detail:r})))}}finally{this.isNotifying=!1}}}};var P=class p{constructor(i={}){let t=i.currency??"";!t&&i.unit&&(t=i.unit);let e=t==="$"||t==="\xA3"||t==="\xA5"?"prefix":"suffix";this.options={currency:t,unit:i.unit??t,currencyPosition:i.currencyPosition??e,decimals:i.decimals!==void 0?Math.max(0,i.decimals):2,decimalSeparator:i.decimalSeparator??",",thousandSeparator:i.thousandSeparator??"\xA0",allowNegative:i.allowNegative??!1,min:i.min??-1/0,max:i.max??1/0}}parse(i){let t=i.trim(),e=!1;this.options.allowNegative&&t.includes("-")&&(e=!0),this.options.currency&&(t=t.replace(new RegExp(this.escapeRegExp(this.options.currency),"g"),"")),this.options.thousandSeparator&&(t=t.replace(new RegExp(this.escapeRegExp(this.options.thousandSeparator),"g"),"")),t=t.replace(/[\s\u00A0]/g,"");let s=this.options.decimalSeparator,o=t.indexOf(s);o===-1&&(o=t.search(/[,.]/));let n="",a=null,r=!1;return o!==-1?(n=t.substring(0,o).replace(/\D/g,""),this.options.decimals>0&&(r=!0,a=t.substring(o+1).replace(/\D/g,"").slice(0,this.options.decimals))):n=t.replace(/\D/g,""),n.length>1&&(n=n.replace(/^0+/,"")||"0"),{isNegative:e,integerPart:n,decimalPart:a,hasDecimal:r}}format(i,t=i.length,e=!1){if(!i||i.trim()===""||i===this.options.currency.trim())return{formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0};let s=i.substring(0,t),o=s.replace(/\D/g,"").length,n=this.options.decimals>0&&/[,.]/.test(s),{isNegative:a,integerPart:r,decimalPart:l,hasDecimal:h}=this.parse(i),c=l,u=h;if(e&&this.options.decimals>0&&(r||l!==null)&&(u=!0,c===null?c="0".repeat(this.options.decimals):c.length<this.options.decimals&&(c=c+"0".repeat(this.options.decimals-c.length))),a&&!r&&!c&&!u&&this.options.allowNegative){let L="-",O=1;return this.options.currency&&(this.options.currencyPosition==="prefix"?(L=`${this.options.currency} -`,O=L.length):(L=`- ${this.options.currency}`,O=1)),{formatted:L,rawNumber:null,rawValue:"-",cursor:O,isValid:!0}}if(!r&&!c&&!u)return{formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0};let m=(r||"0").replace(/\B(?=(\d{3})+(?!\d))/g,this.options.thousandSeparator);u&&this.options.decimals>0&&(m+=this.options.decimalSeparator+(c??"")),a&&m!=="0"&&(m="-"+m);let f=m;this.options.currency&&(this.options.currencyPosition==="prefix"?f=`${this.options.currency} ${m}`:f=`${m} ${this.options.currency}`);let g=(a?"-":"")+(r||"0")+(l?"."+l:""),b=parseFloat(g);isNaN(b)&&(b=0);let v=b>=this.options.min&&b<=this.options.max,w=0;this.options.currency&&this.options.currencyPosition==="prefix"&&(w=this.options.currency.length+1);let E=0,y=!1,T=w;for(let L=w;L<f.length;L++){let O=f[L];if(O===this.options.currency.trim()[0]&&this.options.currencyPosition==="suffix")break;if(/\d/.test(O)?(E++,T=L+1):O===this.options.decimalSeparator&&(y=!0,T=L+1),n){if(y&&E>=o){w=L+1;break}}else if(E>=o){w=L+1;break}}o>0&&E<o&&T>w&&(w=T);let k=this.options.currency&&this.options.currencyPosition==="prefix"?this.options.currency.length+1:0,et=this.options.currency&&this.options.currencyPosition==="suffix"?Math.max(0,f.length-this.options.currency.length-1):f.length;return w=Math.max(k,Math.min(w,Math.max(k,et))),{formatted:f,rawNumber:b,rawValue:g,cursor:w,isValid:v}}static format(i,t={}){let e=new p(t),s=typeof i=="number"?i.toString():i;return e.format(s).formatted}escapeRegExp(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}};var q=class extends x{constructor(t,e,s){let o=H(t,e,s),n=o.wrapper,a=o.input,r=o.options,l=n?.getAttribute("data-mask-pad-decimals")==="true"||a?.getAttribute("data-mask-pad-decimals")==="true",h=a?.getAttribute("data-mask-align")||a?.getAttribute("data-align")||n?.getAttribute("data-mask-align")||n?.getAttribute("data-align"),c={align:r.align??h??"right",padDecimalsOnBlur:r.padDecimalsOnBlur??l??!1,...r};super(n,a,c);this.isUndoingRedoing=!1;this.isApplying=!1;this.isComposing=!1;this.lastValue="";this.cutTimerId=null;this.resetTimerId=null;this.input.inputMode="decimal",this.history=new C,this.engine=new P(this.options),this.bindEvents(),this.input.value?this.options.disabled||this.applyAmount(this.input.value,this.input.value.length):this.updateGhost({formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0}),this.runAuditWarning(this.options.audit)}extractRawSnippet(t){let e=this.engine.parse(t);return!e.integerPart&&!e.decimalPart?"":(e.isNegative?"-":"")+(e.integerPart||"0")+(e.decimalPart?"."+e.decimalPart:"")}static format(t,e={}){return P.format(t,e)}onNativeValueSet(t){if(this.options.disabled||this.isComposing){this.lastValue=t;return}this.applyAmount(t,t.length)}onDisabledChange(t){t||this.applyAmount(this.input.value,this.input.selectionStart??this.input.value.length)}bindEvents(){this.handleInput=this.handleInput.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleClick=this.handleClick.bind(this),this.onCompositionStart=this.onCompositionStart.bind(this),this.onCompositionEnd=this.onCompositionEnd.bind(this),this.onCutHandler=()=>{this.cutTimerId!==null&&clearTimeout(this.cutTimerId),this.cutTimerId=window.setTimeout(()=>{if(this.cutTimerId=null,this.isDestroyed||this.options.disabled)return;let t=this.input.selectionStart??this.input.value.length;this.applyAmount(this.input.value,t)},0)},this.input.addEventListener("input",this.handleInput),this.input.addEventListener("keydown",this.handleKeyDown),this.input.addEventListener("blur",this.handleBlur),this.input.addEventListener("focus",this.handleFocus),this.input.addEventListener("click",this.handleClick),this.input.addEventListener("scroll",this.onScroll),this.input.addEventListener("cut",this.onCutHandler),this.input.addEventListener("compositionstart",this.onCompositionStart),this.input.addEventListener("compositionend",this.onCompositionEnd),this.input.form&&(this.onFormResetHandler=()=>{this.resetTimerId!==null&&clearTimeout(this.resetTimerId),this.resetTimerId=window.setTimeout(()=>{this.resetTimerId=null,!this.isDestroyed&&(this.options.disabled||this.applyAmount(this.input.value,this.input.value.length))},0)},this.input.form.addEventListener("reset",this.onFormResetHandler))}onCompositionStart(){this.isComposing=!0}onCompositionEnd(){if(this.isComposing=!1,this.options.disabled)return;let t=this.input.selectionStart??this.input.value.length;this.applyAmount(this.input.value,t)}applyAmount(t,e){if(!(this.isApplying||this.options.disabled)){this.isApplying=!0;try{let s=this.engine.format(t,e);this.setNativeValue(s.formatted),this.input.setSelectionRange(s.cursor,s.cursor),!this.isUndoingRedoing&&this.input.type!=="password"&&this.history.push(s.rawValue,s.cursor),this.updateGhost(s),this.lastValue!==s.formatted&&(this.lastValue=s.formatted,this.notifyChange(s))}finally{this.isApplying=!1}}}updateGhost(t){if(this.ghost){if(!t.formatted){if(this.shouldHideGhostForPlaceholder(!0)){this.ghost.textContent="";return}let e=this.options.currency?this.options.currencyPosition==="prefix"?`${this.options.currency} 0`:`0 ${this.options.currency}`:"0,00";this.ghost.textContent="";let s=document.createElement("span");s.className="mask-ghost-remaining",s.textContent=e,this.ghost.appendChild(s);return}this.ghost.textContent="",this.ghost.scrollLeft=this.input.scrollLeft}}handleInput(){if(this.isDispatchingNativeInput||this.options.disabled||this.isComposing)return;let t=this.input.value,e=this.input.selectionStart??t.length;this.applyAmount(t,e)}handleKeyDown(t){if(!this.options.disabled){if((t.ctrlKey||t.metaKey)&&(t.key==="z"||t.key==="Z")){t.preventDefault(),t.shiftKey?this.redo():this.undo();return}if((t.ctrlKey||t.metaKey)&&(t.key==="y"||t.key==="Y")){t.preventDefault(),this.redo();return}if(t.key==="Backspace"){let e=this.input.selectionStart??0,s=this.input.selectionEnd??0;if(e===s&&e>0){let o=this.input.value,n=o[e-1];if(n===this.engine.options.thousandSeparator||n===" "){t.preventDefault();let a=Math.max(0,e-2),r=o.slice(0,a)+o.slice(e);this.applyAmount(r,a);return}if(this.options.currency&&this.options.currencyPosition==="prefix"&&e<=this.options.currency.length+1){t.preventDefault();return}}}if(t.key==="Delete"){let e=this.input.selectionStart??0,s=this.input.selectionEnd??0;if(e===s&&e<this.input.value.length){let o=this.input.value,n=o[e];if(n===this.engine.options.thousandSeparator||n===" "){t.preventDefault();let a=o.slice(0,e)+o.slice(e+2);this.applyAmount(a,e);return}if(this.options.currency&&this.options.currencyPosition==="suffix"){let a=o.length-this.options.currency.length-1;if(e>=a){t.preventDefault();return}}}}setTimeout(()=>this.enforceCursorBounds(),0)}}enforceCursorBounds(){if(!this.input.value||this.options.disabled)return;let t=this.input.selectionStart??0,e=this.input.selectionEnd??0;if(t!==e)return;let s=this.input.value,o=this.options.currency;if(o){if(this.options.currencyPosition==="prefix"){let n=o.length+1;t<n&&this.input.setSelectionRange(n,n)}else if(this.options.currencyPosition==="suffix"){let n=Math.max(0,s.length-o.length-1);t>n&&this.input.setSelectionRange(n,n)}}}handleClick(){this.enforceCursorBounds()}handleFocus(){this.wrapper.classList.add("is-focused"),this.syncGhostStyles(),this.enforceCursorBounds(),this.updateGhost(this.engine.format(this.input.value))}handleBlur(){if(this.wrapper.classList.remove("is-focused"),this.input.type==="password"&&this.history.clear(),this.options.padDecimalsOnBlur&&!this.options.disabled&&this.input.value.trim().length>0){let e=this.engine.format(this.input.value,this.input.value.length,!0);e.formatted!==this.input.value&&(this.setNativeValue(e.formatted),this.lastValue=e.formatted)}this.updateGhost(this.engine.format(this.input.value));let t=this.getDetail();this.options.onChange&&this.options.onChange(t),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:t}))}handleAttributeMutation(t){super.handleAttributeMutation(t),t==="data-mask-pad-decimals"?this.options.padDecimalsOnBlur=this.getAttr("data-mask-pad-decimals")==="true":t==="placeholder"&&this.updateGhost(this.engine.format(this.input.value))}notifyChange(t){let e={value:t.formatted,number:t.rawNumber,rawValue:t.rawValue,isValid:t.isValid};this.options.onInput&&this.options.onInput(e),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:e})),this.dispatchNativeInput()}undo(){let t=this.history.undo();if(t){this.isUndoingRedoing=!0;try{this.applyAmount(t.raw,t.cursor)}finally{this.isUndoingRedoing=!1}}}redo(){let t=this.history.redo();if(t){this.isUndoingRedoing=!0;try{this.applyAmount(t.raw,t.cursor)}finally{this.isUndoingRedoing=!1}}}getDetail(){let t=this.engine.format(this.input.value);return{value:t.formatted,number:t.rawNumber,rawValue:t.rawValue,isValid:t.isValid}}getNumber(){return this.getDetail().number}getRawValue(){return this.getDetail().rawValue}isValid(){return this.getDetail().isValid}setValue(t){let e=t!=null?String(t):"";this.options.disabled?(this.setNativeValue(e),this.lastValue=e):this.applyAmount(e,e.length)}destroy(){this.isDestroyed||(this.cutTimerId!==null&&(clearTimeout(this.cutTimerId),this.cutTimerId=null),this.resetTimerId!==null&&(clearTimeout(this.resetTimerId),this.resetTimerId=null),this.input.removeEventListener("input",this.handleInput),this.input.removeEventListener("keydown",this.handleKeyDown),this.input.removeEventListener("blur",this.handleBlur),this.input.removeEventListener("focus",this.handleFocus),this.input.removeEventListener("click",this.handleClick),this.input.removeEventListener("scroll",this.onScroll),this.input.removeEventListener("cut",this.onCutHandler),this.input.removeEventListener("compositionstart",this.onCompositionStart),this.input.removeEventListener("compositionend",this.onCompositionEnd),this.input.form&&this.onFormResetHandler&&this.input.form.removeEventListener("reset",this.onFormResetHandler),this.history.clear(),super.destroy())}};var U=class U{constructor(i={}){this.defaultDomain=null;this.defaultTld="__";this.domains=i.domains&&i.domains.length>0?i.domains:U.DEFAULT_DOMAINS,this.tlds=i.tlds&&i.tlds.length>0?i.tlds.map(t=>t.trim().replace(/^\./,"")).filter(Boolean):[...U.DEFAULT_TLDS],this.suggestOnAt=i.suggestOnAt??!0,this.setDefaultDomain(i.defaultDomain??null),this.setDefaultTld(i.defaultTld!==void 0?i.defaultTld:"__")}setDefaultDomain(i){i===!0?this.defaultDomain=this.domains.length>0?this.domains[0]:null:typeof i=="string"&&i.trim().length>0?this.defaultDomain=i.trim().replace(/^@/,""):this.defaultDomain=null}setDefaultTld(i){i===!0?this.defaultTld=this.tlds.length>0?this.tlds[0]:null:typeof i=="string"&&i.trim().length>0?this.defaultTld=i.trim().replace(/^\./,""):this.defaultTld=null}setTlds(i){this.tlds=i&&i.length>0?i.map(t=>t.trim().replace(/^\./,"")).filter(Boolean):[...U.DEFAULT_TLDS]}getMatchingTlds(i){let t=(i??"").toLowerCase();return t.length===0?[...this.tlds]:this.tlds.filter(e=>e.toLowerCase().startsWith(t)&&e.toLowerCase()!==t)}getMatchingDomains(i){let t=i??"";if(!t.includes("@"))return this.defaultDomain?[this.defaultDomain]:[];let e=t.indexOf("@");if(t.indexOf("@",e+1)!==-1)return[];let s=t.substring(e+1);if(s.length===0)return this.suggestOnAt?[...this.domains]:[];let o=s.toLowerCase();return this.domains.filter(n=>n.toLowerCase().startsWith(o)&&n.toLowerCase()!==o)}getSuggestion(i,t=0){let e=i??"";if(!e.includes("@"))return this.defaultDomain?{full:e?`${e}@${this.defaultDomain}`:`@${this.defaultDomain}`,remaining:`@${this.defaultDomain}`,matchedDomain:this.defaultDomain,isHintOnly:!1}:{full:e,remaining:"",matchedDomain:null,isHintOnly:!1};let s=e.indexOf("@"),o=e.substring(0,s),n=e.substring(s+1);if(e.indexOf("@",s+1)!==-1)return{full:e,remaining:"",matchedDomain:null,isHintOnly:!1};let a=this.getMatchingDomains(i);if(a.length>0){let m=(t%a.length+a.length)%a.length,f=a[m],g=n.toLowerCase(),b=f.substring(g.length);return{full:`${o}@${f}`,remaining:b,matchedDomain:f,isHintOnly:!1}}if(n.length===0||n.startsWith("."))return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let r=n.toLowerCase();if(this.domains.some(m=>m.toLowerCase()===r))return{full:i,remaining:"",matchedDomain:n,isHintOnly:!1};let l=n.lastIndexOf(".");if(l===-1){if(!this.defaultTld)return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let m=this.defaultTld.includes("_"),f=`.${this.defaultTld}`,g=`${n}.${this.defaultTld}`;return{full:m?i:`${o}@${g}`,remaining:f,matchedDomain:m?null:g,isHintOnly:m}}let h=n.substring(0,l),c=n.substring(l+1);if(!h||h.endsWith("."))return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};if(c.length===0){if(this.defaultTld&&!this.defaultTld.includes("_")){let m=`${h}.${this.defaultTld}`;return{full:`${o}@${m}`,remaining:this.defaultTld,matchedDomain:m,isHintOnly:!1}}return this.defaultTld&&this.defaultTld.includes("_")?{full:i,remaining:this.defaultTld,matchedDomain:null,isHintOnly:!0}:{full:i,remaining:"",matchedDomain:null,isHintOnly:!1}}let u=c.toLowerCase(),d=this.getMatchingTlds(c);if(d.length>0){let m=(t%d.length+d.length)%d.length,f=d[m],g=f.substring(u.length),b=`${h}.${f}`;return{full:`${o}@${b}`,remaining:g,matchedDomain:b,isHintOnly:!1}}if(this.defaultTld&&this.defaultTld.includes("_")&&c.length<this.defaultTld.length){let m=this.defaultTld.substring(c.length);if(m.includes("_"))return{full:i,remaining:m,matchedDomain:null,isHintOnly:!0}}return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1}}};U.DEFAULT_DOMAINS=["gmail.com","outlook.com","orange.fr","free.fr","sfr.fr","yahoo.com","hotmail.com","icloud.com","laposte.net","proton.me"],U.DEFAULT_TLDS=["com","fr","net","org","eu","io","co","info","biz","me","tv","fi","be","ch","ca","uk","de","es","it"];var V=U;var j=class extends x{constructor(t,e,s){let o=H(t,e,s),n=o.wrapper,a=o.input,r=o.options,l=n?.getAttribute("data-mask-cycle-suggestions")==="true"||a?.getAttribute("data-mask-cycle-suggestions")==="true",h=n?.getAttribute("data-mask-auto-lowercase")==="true"||a?.getAttribute("data-mask-auto-lowercase")==="true",c=n?.getAttribute("data-mask-aria-autocomplete")??a?.getAttribute("data-mask-aria-autocomplete"),u=r.setAriaAutocomplete??(c!==null?c!=="false":!0),d=n?.getAttribute("data-mask-tlds")??a?.getAttribute("data-mask-tlds"),m=r.tlds??(d?d.split(",").map(v=>v.trim()).filter(Boolean):void 0),f=n?.getAttribute("data-mask-default-tld")??a?.getAttribute("data-mask-default-tld"),g=r.defaultTld!==void 0?r.defaultTld:f!==null?f==="false"||f==="none"?null:f==="true"?!0:f:void 0,b={completeOnTab:!0,completeOnArrowRight:!0,completeOnEnter:!0,cycleSuggestions:r.cycleSuggestions??l??!1,autoLowercase:r.autoLowercase??h??!1,setAriaAutocomplete:u,...r,...m!==void 0?{tlds:m}:{},...g!==void 0?{defaultTld:g}:{}};super(n,a,b);this.currentSuggestion={full:"",remaining:"",matchedDomain:null};this.currentSuggestionIndex=0;this.wasAriaAutocompleteSet=!1;this.cutTimerId=null;this.resetTimerId=null;this.input.inputMode="email",this.options.setAriaAutocomplete&&!this.input.hasAttribute("aria-autocomplete")&&(this.input.setAttribute("aria-autocomplete","inline"),this.wasAriaAutocompleteSet=!0),this.engine=new V(this.options),this.bindEvents(),this.options.disabled||this.updateSuggestion(),this.runAuditWarning(this.options.audit)}onNativeValueSet(t){this.options.disabled||this.updateSuggestion()}onDisabledChange(t){t?this.ghost&&(this.ghost.textContent=""):this.updateSuggestion()}bindEvents(){this.handleInput=this.handleInput.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleFocus=this.handleFocus.bind(this),this.onCutHandler=()=>{this.cutTimerId!==null&&clearTimeout(this.cutTimerId),this.cutTimerId=window.setTimeout(()=>{this.cutTimerId=null,!(this.isDestroyed||this.options.disabled)&&this.updateSuggestion()},0)},this.input.addEventListener("input",this.handleInput),this.input.addEventListener("keydown",this.handleKeyDown),this.input.addEventListener("blur",this.handleBlur),this.input.addEventListener("focus",this.handleFocus),this.input.addEventListener("scroll",this.onScroll),this.input.addEventListener("cut",this.onCutHandler),this.input.form&&(this.onFormResetHandler=()=>{this.resetTimerId!==null&&clearTimeout(this.resetTimerId),this.resetTimerId=window.setTimeout(()=>{this.resetTimerId=null,!(this.isDestroyed||this.options.disabled)&&this.updateSuggestion()},0)},this.input.form.addEventListener("reset",this.onFormResetHandler))}updateSuggestion(){if(this.options.disabled){this.ghost&&(this.ghost.textContent="");return}let t=this.input.value;if(this.currentSuggestion=this.engine.getSuggestion(t,this.currentSuggestionIndex),!this.ghost)return;if(this.shouldHideGhostForPlaceholder(t.length===0))this.ghost.textContent="";else if(this.currentSuggestion.remaining){this.ghost.textContent="";let s=document.createElement("span");s.className="mask-ghost-typed",s.textContent=t;let o=document.createElement("span");o.className="mask-ghost-remaining",o.textContent=this.currentSuggestion.remaining,this.ghost.appendChild(s),this.ghost.appendChild(o)}else this.ghost.textContent="";this.ghost.scrollLeft=this.input.scrollLeft;let e=this.getDetail();this.options.onInput&&this.options.onInput(e),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:e})),this.dispatchNativeInput()}handleInput(){if(!this.isDispatchingNativeInput&&!this.options.disabled){if(this.options.autoLowercase){let t=this.input.selectionStart??0,e=this.input.selectionEnd??t,s=this.input.value.toLowerCase();s!==this.input.value&&(this.setNativeValue(s),this.input.setSelectionRange(t,e))}this.currentSuggestionIndex=0,this.updateSuggestion()}}handleKeyDown(t){if(this.options.disabled)return;let e=!!this.currentSuggestion.remaining&&!this.currentSuggestion.isHintOnly,o=(this.input.selectionStart??0)===this.input.value.length,n=this.input.value.length>0;if(this.options.cycleSuggestions&&e&&n&&o){if(t.key==="ArrowDown"){t.preventDefault(),this.currentSuggestionIndex++,this.updateSuggestion();return}if(t.key==="ArrowUp"){t.preventDefault(),this.currentSuggestionIndex--,this.updateSuggestion();return}}if(t.key==="Tab"&&e&&n&&this.options.completeOnTab){t.preventDefault(),this.acceptSuggestion();return}if(t.key==="Enter"&&e&&n&&this.options.completeOnEnter){t.preventDefault(),this.acceptSuggestion();return}if(t.key==="ArrowRight"&&e&&n&&o&&this.options.completeOnArrowRight){t.preventDefault(),this.acceptSuggestion();return}}acceptSuggestion(){if(!this.currentSuggestion.remaining||this.currentSuggestion.isHintOnly||this.options.disabled||this.input.value.length===0)return!1;let t=this.currentSuggestion.full;this.setNativeValue(t),this.input.setSelectionRange(t.length,t.length),this.currentSuggestionIndex=0,this.updateSuggestion();let e=this.getDetail();return this.options.onChange&&this.options.onChange(e),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:e})),this.input.dispatchEvent(new CustomEvent("mask:complete",{bubbles:!0,detail:e})),!0}setDefaultDomain(t){this.engine.setDefaultDomain(t),this.updateSuggestion()}setDefaultTld(t){this.engine.setDefaultTld(t),this.updateSuggestion()}setTlds(t){this.engine.setTlds(t),this.currentSuggestionIndex=0,this.updateSuggestion()}handleFocus(){this.wrapper.classList.add("is-focused"),this.syncGhostStyles(),this.updateSuggestion()}handleBlur(){this.wrapper.classList.remove("is-focused"),this.updateSuggestion();let t=this.getDetail();this.options.onChange&&this.options.onChange(t),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:t}))}handleAttributeMutation(t){if(super.handleAttributeMutation(t),t==="data-mask-cycle-suggestions")this.options.cycleSuggestions=this.getAttr("data-mask-cycle-suggestions")==="true";else if(t==="data-mask-auto-lowercase")this.options.autoLowercase=this.getAttr("data-mask-auto-lowercase")==="true";else if(t==="data-mask-default-tld"){let e=this.getAttr("data-mask-default-tld");this.setDefaultTld(e===null||e==="false"||e==="none"?null:e==="true"?!0:e)}else if(t==="data-mask-tlds"){let e=this.getAttr("data-mask-tlds");this.setTlds(e?e.split(",").map(s=>s.trim()).filter(Boolean):null)}else t==="placeholder"&&this.updateSuggestion()}getDetail(){return{value:this.input.value,suggestedValue:this.currentSuggestion.isHintOnly?"":this.currentSuggestion.full,domain:this.currentSuggestion.matchedDomain}}setValue(t){let e=t!=null?String(t):"";this.setNativeValue(e),this.updateSuggestion()}destroy(){this.isDestroyed||(this.cutTimerId!==null&&(clearTimeout(this.cutTimerId),this.cutTimerId=null),this.resetTimerId!==null&&(clearTimeout(this.resetTimerId),this.resetTimerId=null),this.input.removeEventListener("input",this.handleInput),this.input.removeEventListener("keydown",this.handleKeyDown),this.input.removeEventListener("blur",this.handleBlur),this.input.removeEventListener("focus",this.handleFocus),this.input.removeEventListener("scroll",this.onScroll),this.input.removeEventListener("cut",this.onCutHandler),this.input.form&&this.onFormResetHandler&&this.input.form.removeEventListener("reset",this.onFormResetHandler),this.wasAriaAutocompleteSet&&this.input.getAttribute("aria-autocomplete")==="inline"&&this.input.removeAttribute("aria-autocomplete"),super.destroy())}};var yt={BaseInputMask:x,InputMask:K,MaskEngine:R,MaskHistory:C,MaskKeyboard:W,AmountEngine:P,InputAmountMask:q,EmailEngine:V,InputEmailMask:j};if(typeof window<"u"){let p=window,i=p.Wulf||{};p.Wulf=i,i.Mask=yt}var at=K;var ct={};_(ct,{LocalizedComponent:()=>S,Scroll:()=>Tt,ScrollBlock:()=>z,createI18nManager:()=>D,default:()=>It,scrollEn:()=>ht,scrollFr:()=>ut,scrollI18n:()=>J});var S=class extends I{static setLocale(i){this._i18n&&this._i18n.setLocale(i)}static getLocale(){return this._i18n?this._i18n.getLocale():""}static registerLocale(i,t){this._i18n&&this._i18n.registerLocale(i,t)}static setI18n(i){this._i18n&&this._i18n.setI18n(i)}static getI18n(){return this._i18n?this._i18n.getAll():{}}static resetI18n(){this._i18n&&this._i18n.reset()}static t(i,t){return this._i18n?this._i18n.t(i,t):String(i)}constructor(i){super(),this.i18nOverrides=i}t(i){let t=this.constructor;return t._i18n?t._i18n.t(i,this.i18nOverrides):String(i)}};function ot(p){return p.trim().toLowerCase().replace(/_/g,"-")}function xt(p){let i=p.indexOf("-");return i>0?p.slice(0,i):null}function Z(p,i){if(!i)return p;for(let t of Object.keys(i))i[t]!==void 0&&(p[t]=i[t]);return p}function D(p,i){let t=ot(p),e={};for(let[r,l]of Object.entries(i))e[ot(r)]={...l};let s=t,o={...e},n={};function a(){let r=[],l=o[s];l&&r.push(l);let h=xt(s);return h&&o[h]&&r.push(o[h]),r}return{setLocale(r){r&&r.trim()&&(s=ot(r))},getLocale(){return s},registerLocale(r,l){if(!r||!r.trim()||!l)return;let h=ot(r);o[h]=Z({...o[h]||{}},l)},setI18n(r){r&&(n=Z({...n},r))},t(r,l){if(l&&l[r]!==void 0)return String(l[r]);if(n[r]!==void 0)return String(n[r]);for(let c of a())if(c[r]!==void 0)return String(c[r]);let h=o[t]||e[t];return h&&h[r]!==void 0?String(h[r]):String(r)},getAll(r){let l={},h=o[t]||e[t];Z(l,h);let c=a().reverse();for(let u of c)Z(l,u);return Z(l,n),Z(l,r),l},reset(){s=t,n={},o={};for(let[r,l]of Object.entries(e))o[r]={...l}}}}var ut={viewport:"Zone de contenu d\xE9filable",verticalThumb:"D\xE9filement vertical",horizontalThumb:"D\xE9filement horizontal"};var ht={viewport:"Scrollable content area",verticalThumb:"Vertical scroll",horizontalThumb:"Horizontal scroll"};var J=D("fr",{fr:ut,en:ht});var wt=0,z=class extends S{constructor(t,e){super(e?.i18n);this.createdViewport=!1;this.wasIdGenerated=!1;this.wasRoleInferred=!1;this.wasAriaLabelInferred=!1;this.hasExplicitAriaLabel=!1;this.lastInferredAriaLabel="";this.isDragging=!1;this.dragStartPos=0;this.dragStartScroll=0;this.atBottom=!1;this.atTop=!0;this.atRight=!1;this.atLeft=!0;let s=typeof t=="string"?document.querySelector(t):t;if(!s)throw new Error(`[ScrollBlock] \xC9l\xE9ment introuvable : "${t}".`);this.root=s,this.hasExplicitAriaLabel=!!(e?.ariaLabel||e?.i18n?.viewport),this.options={axis:e?.axis||"y",autoHide:e?.autoHide??!0,autoHideDelay:e?.autoHideDelay??1e3,alwaysVisible:e?.alwaysVisible??!1,ariaLabel:e?.ariaLabel||this.t("viewport"),i18n:e?.i18n||{},minThumbSize:e?.minThumbSize??24,edgeThreshold:e?.edgeThreshold??10,onScroll:e?.onScroll||(()=>{}),onTotalScroll:e?.onTotalScroll||(()=>{}),onTotalScrollBack:e?.onTotalScrollBack||(()=>{}),audit:e?.audit??!0},this.boundOnScroll=this.handleScroll.bind(this),this.boundOnMouseEnter=this.handleMouseEnter.bind(this),this.boundOnMouseLeave=this.handleMouseLeave.bind(this),this.boundOnFocusIn=this.handleFocusIn.bind(this),this.boundOnFocusOut=this.handleFocusOut.bind(this),this.boundPointerMove=this.handlePointerMove.bind(this),this.boundPointerUp=this.handlePointerUp.bind(this),this.viewport=this.setupViewport(),this.setupAccessibility(),this.setupScrollbars(),this.setupEventListeners(),this.setupObserver(),this.update(),this.runAuditWarning(this.options.audit)}setupViewport(){this.root.classList.add("wulf-scrollblock"),this.options.alwaysVisible&&this.root.classList.add("is-always-visible"),this.options.axis==="both"&&this.root.classList.add("has-both-axes");let t=this.root.querySelector(":scope > .wulf-scrollblock-viewport");if(t)return t;let e=document.createElement("div");for(e.className="wulf-scrollblock-viewport";this.root.firstChild;)e.appendChild(this.root.firstChild);return this.root.appendChild(e),this.createdViewport=!0,e}setupAccessibility(){if(this.viewport.id||(wt+=1,this.viewport.id=`wulf-scrollblock-vp-${wt}`,this.wasIdGenerated=!0),this.viewport.hasAttribute("role")||(this.viewport.setAttribute("role","region"),this.wasRoleInferred=!0),!this.viewport.hasAttribute("aria-label")){let t=this.hasExplicitAriaLabel?this.options.ariaLabel:this.t("viewport");this.viewport.setAttribute("aria-label",t),this.lastInferredAriaLabel=t,this.wasAriaLabelInferred=!0}}syncAccessibilityLabels(){if(this.wasAriaLabelInferred&&!this.hasExplicitAriaLabel&&this.viewport.getAttribute("aria-label")===this.lastInferredAriaLabel){let e=this.t("viewport");this.viewport.setAttribute("aria-label",e),this.lastInferredAriaLabel=e,this.options.ariaLabel=e}this.thumbY&&this.thumbY.setAttribute("aria-label",this.t("verticalThumb")),this.thumbX&&this.thumbX.setAttribute("aria-label",this.t("horizontalThumb"))}setupScrollbars(){(this.options.axis==="y"||this.options.axis==="both")&&(this.trackY=document.createElement("div"),this.trackY.className="wulf-scrollblock-track wulf-scrollblock-vertical",this.trackY.setAttribute("aria-hidden","true"),this.thumbY=document.createElement("div"),this.thumbY.className="wulf-scrollblock-thumb",this.thumbY.setAttribute("role","scrollbar"),this.thumbY.setAttribute("aria-orientation","vertical"),this.thumbY.setAttribute("aria-controls",this.viewport.id),this.thumbY.setAttribute("aria-valuenow","0"),this.thumbY.setAttribute("aria-valuemin","0"),this.thumbY.setAttribute("aria-valuemax","100"),this.thumbY.setAttribute("aria-label",this.t("verticalThumb")),this.trackY.appendChild(this.thumbY),this.root.appendChild(this.trackY),this.attachTrackListeners(this.trackY,this.thumbY,"y")),(this.options.axis==="x"||this.options.axis==="both")&&(this.trackX=document.createElement("div"),this.trackX.className="wulf-scrollblock-track wulf-scrollblock-horizontal",this.trackX.setAttribute("aria-hidden","true"),this.thumbX=document.createElement("div"),this.thumbX.className="wulf-scrollblock-thumb",this.thumbX.setAttribute("role","scrollbar"),this.thumbX.setAttribute("aria-orientation","horizontal"),this.thumbX.setAttribute("aria-controls",this.viewport.id),this.thumbX.setAttribute("aria-valuenow","0"),this.thumbX.setAttribute("aria-valuemin","0"),this.thumbX.setAttribute("aria-valuemax","100"),this.thumbX.setAttribute("aria-label",this.t("horizontalThumb")),this.trackX.appendChild(this.thumbX),this.root.appendChild(this.trackX),this.attachTrackListeners(this.trackX,this.thumbX,"x"))}attachTrackListeners(t,e,s){e.addEventListener("pointerdown",o=>{o.preventDefault(),o.stopPropagation(),this.isDragging=!0,this.dragAxis=s,this.dragPointerId=o.pointerId,this.dragStartPos=s==="y"?o.clientY:o.clientX,this.dragStartScroll=s==="y"?this.viewport.scrollTop:this.viewport.scrollLeft,e.setPointerCapture(o.pointerId),e.classList.add("is-active"),this.root.classList.add("is-dragging"),window.addEventListener("pointermove",this.boundPointerMove),window.addEventListener("pointerup",this.boundPointerUp),window.addEventListener("pointercancel",this.boundPointerUp)}),t.addEventListener("pointerdown",o=>{if(o.target===e)return;o.preventDefault();let n=t.getBoundingClientRect(),a=s==="y"?o.clientY-n.top:o.clientX-n.left,r=s==="y"?n.height:n.width,l=s==="y"?this.viewport.clientHeight:this.viewport.clientWidth,h=s==="y"?this.viewport.scrollHeight:this.viewport.scrollWidth,u=a/r*(h-l);this.scrollTo(s==="y"?{top:u}:{left:u},{smooth:!0})})}setupEventListeners(){this.viewport.addEventListener("scroll",this.boundOnScroll,{passive:!0}),this.options.autoHide&&!this.options.alwaysVisible&&(this.root.addEventListener("mouseenter",this.boundOnMouseEnter),this.root.addEventListener("mouseleave",this.boundOnMouseLeave),this.root.addEventListener("focusin",this.boundOnFocusIn),this.root.addEventListener("focusout",this.boundOnFocusOut))}setupObserver(){typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>{window.requestAnimationFrame(()=>this.update())}),this.resizeObserver.observe(this.root),this.resizeObserver.observe(this.viewport),this.viewport.firstElementChild&&this.resizeObserver.observe(this.viewport.firstElementChild))}handlePointerMove(t){if(!this.isDragging||!this.dragAxis)return;let e=this.dragAxis==="y",s=(e?t.clientY:t.clientX)-this.dragStartPos,o=e?this.trackY:this.trackX,n=e?this.thumbY:this.thumbX;if(!o||!n)return;let a=e?o.clientHeight:o.clientWidth,r=e?n.clientHeight:n.clientWidth,l=e?this.viewport.clientHeight:this.viewport.clientWidth,c=(e?this.viewport.scrollHeight:this.viewport.scrollWidth)-l,u=a-r;if(u<=0||c<=0)return;let d=c/u,m=this.dragStartScroll+s*d;e?this.viewport.scrollTop=Math.max(0,Math.min(c,m)):this.viewport.scrollLeft=Math.max(0,Math.min(c,m))}handlePointerUp(t){if(this.isDragging){if(this.dragPointerId!==void 0){let e=this.dragAxis==="y"?this.thumbY:this.thumbX;e&&e.hasPointerCapture(this.dragPointerId)&&e.releasePointerCapture(this.dragPointerId)}window.removeEventListener("pointermove",this.boundPointerMove),window.removeEventListener("pointerup",this.boundPointerUp),window.removeEventListener("pointercancel",this.boundPointerUp),this.isDragging=!1,this.dragAxis=void 0,this.dragPointerId=void 0,this.thumbY?.classList.remove("is-active"),this.thumbX?.classList.remove("is-active"),this.root.classList.remove("is-dragging"),this.scheduleAutoHide()}}handleScroll(){this.syncThumbs();let{scrollTop:t,scrollLeft:e,scrollHeight:s,scrollWidth:o,clientHeight:n,clientWidth:a}=this.viewport,r=Math.max(0,s-n),l=Math.max(0,o-a),h=r>0?t/r:0,c=l>0?e/l:0;this.options.onScroll({top:t,left:e,maxTop:r,maxLeft:l,progressY:Math.round(h*100),progressX:Math.round(c*100)});let u=this.options.edgeThreshold;if(r>0){let d=t>=r-u,m=t<=u;d&&!this.atBottom&&this.options.onTotalScroll("bottom"),m&&!this.atTop&&this.options.onTotalScrollBack("top"),this.atBottom=d,this.atTop=m}if(l>0){let d=e>=l-u,m=e<=u;d&&!this.atRight&&this.options.onTotalScroll("right"),m&&!this.atLeft&&this.options.onTotalScrollBack("left"),this.atRight=d,this.atLeft=m}this.options.autoHide&&!this.options.alwaysVisible&&(this.root.classList.add("is-scrolling"),this.scheduleAutoHide())}syncThumbs(){let{scrollTop:t,scrollLeft:e,scrollHeight:s,scrollWidth:o,clientHeight:n,clientWidth:a}=this.viewport;if(this.thumbY&&this.trackY){let r=s-n,l=this.trackY.clientHeight,h=this.thumbY.clientHeight,c=l-h;if(r>0&&c>0){let u=t/r,d=Math.max(0,Math.min(c,u*c));this.thumbY.style.transform=`translate3d(0, ${d}px, 0)`,this.thumbY.setAttribute("aria-valuenow",String(Math.round(u*100)))}}if(this.thumbX&&this.trackX){let r=o-a,l=this.trackX.clientWidth,h=this.thumbX.clientWidth,c=l-h;if(r>0&&c>0){let u=e/r,d=Math.max(0,Math.min(c,u*c));this.thumbX.style.transform=`translate3d(${d}px, 0, 0)`,this.thumbX.setAttribute("aria-valuenow",String(Math.round(u*100)))}}}handleMouseEnter(){this.root.classList.add("is-visible"),this.clearAutoHideTimer()}handleMouseLeave(){this.scheduleAutoHide()}handleFocusIn(){this.root.classList.add("is-visible"),this.clearAutoHideTimer()}handleFocusOut(){this.scheduleAutoHide()}clearAutoHideTimer(){this.hideTimer&&(window.clearTimeout(this.hideTimer),this.hideTimer=void 0)}scheduleAutoHide(){this.options.alwaysVisible||!this.options.autoHide||this.isDragging||(this.clearAutoHideTimer(),this.hideTimer=window.setTimeout(()=>{this.root.classList.remove("is-scrolling"),this.root.classList.remove("is-visible")},this.options.autoHideDelay))}update(){this.syncAccessibilityLabels();let{scrollHeight:t,clientHeight:e,scrollWidth:s,clientWidth:o}=this.viewport,n=t>e,a=s>o;if(this.root.classList.toggle("has-scroll-y",n),this.root.classList.toggle("has-scroll-x",a),n||a?this.viewport.setAttribute("tabindex","0"):this.viewport.removeAttribute("tabindex"),this.trackY&&this.thumbY&&n){let r=this.trackY.clientHeight,l=Math.max(this.options.minThumbSize,r*(e/t));this.thumbY.style.height=`${l}px`}if(this.trackX&&this.thumbX&&a){let r=this.trackX.clientWidth,l=Math.max(this.options.minThumbSize,r*(o/s));this.thumbX.style.width=`${l}px`}this.syncThumbs()}scrollTo(t,e){let s=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,o=typeof t=="object"&&t!==null&&!(t instanceof HTMLElement)?t.smooth:void 0,a=(e?.smooth??o??!0)&&!s?"smooth":"auto",r=Math.max(0,this.viewport.scrollHeight-this.viewport.clientHeight),l=Math.max(0,this.viewport.scrollWidth-this.viewport.clientWidth),h,c;if(typeof t=="number")h=t;else if(typeof t=="string")switch(t){case"top":h=0;break;case"bottom":h=r;break;case"left":c=0;break;case"right":c=l;break;default:{if(/^-?\d+(\.\d+)?%$/.test(t.trim())){let d=Math.max(0,Math.min(100,parseFloat(t.trim())))/100;this.options.axis==="x"?c=l*d:this.options.axis==="both"?(h=r*d,c=l*d):h=r*d;break}let u=null;try{u=this.viewport.querySelector(t)}catch{u=null}u&&(h=u.offsetTop,c=u.offsetLeft);break}}else t instanceof HTMLElement?(h=t.offsetTop,c=t.offsetLeft):typeof t=="object"&&(h=t.top,c=t.left);this.viewport.scrollTo({top:h!==void 0?Math.max(0,Math.min(r,h)):void 0,left:c!==void 0?Math.max(0,Math.min(l,c)):void 0,behavior:a})}audit(){let t=[],e=this.checkAriaIdReferences(this.viewport,"aria-labelledby",t),s=this.checkAriaIdReferences(this.root,"aria-labelledby",t),o=e||s,n=this.root.getAttribute("aria-label")?.trim(),a=!this.wasAriaLabelInferred&&!!this.viewport.getAttribute("aria-label")?.trim();return!this.hasExplicitAriaLabel&&!a&&!n&&!o&&t.push("Libell\xE9 contextuel manquant : d\xE9finissez l'option ariaLabel (ou un attribut aria-label / aria-labelledby sur le conteneur) pour d\xE9crire la zone d\xE9filable (WCAG 4.1.2)."),this.options.minThumbSize<24&&t.push(`Taille minimale du curseur insuffisante (minThumbSize: ${this.options.minThumbSize}px) : utilisez au moins 24px pour respecter WCAG 2.5.8.`),t}getAuditPrefix(){return"Wulf.Scroll"}getAuditTargetLabel(){return this.root.id?`#${this.root.id}`:`<${this.root.tagName.toLowerCase()}.wulf-scrollblock>`}destroy(){if(this.clearAutoHideTimer(),this.resizeObserver&&this.resizeObserver.disconnect(),this.viewport.removeEventListener("scroll",this.boundOnScroll),this.root.removeEventListener("mouseenter",this.boundOnMouseEnter),this.root.removeEventListener("mouseleave",this.boundOnMouseLeave),this.root.removeEventListener("focusin",this.boundOnFocusIn),this.root.removeEventListener("focusout",this.boundOnFocusOut),window.removeEventListener("pointermove",this.boundPointerMove),window.removeEventListener("pointerup",this.boundPointerUp),window.removeEventListener("pointercancel",this.boundPointerUp),this.trackY?.remove(),this.trackX?.remove(),this.root.classList.remove("wulf-scrollblock","has-scroll-y","has-scroll-x","has-both-axes","is-visible","is-scrolling","is-dragging","is-always-visible"),this.createdViewport&&this.viewport.parentElement===this.root){for(;this.viewport.firstChild;)this.root.insertBefore(this.viewport.firstChild,this.viewport);this.viewport.remove()}else this.viewport.removeAttribute("tabindex"),this.wasIdGenerated&&this.viewport.removeAttribute("id"),this.wasRoleInferred&&this.viewport.getAttribute("role")==="region"&&this.viewport.removeAttribute("role"),this.wasAriaLabelInferred&&this.viewport.getAttribute("aria-label")===this.lastInferredAriaLabel&&this.viewport.removeAttribute("aria-label")}};z._i18n=J,z.i18n=J;var Tt={ScrollBlock:z,i18n:J};var It=z;if(typeof window<"u"){let p=window,i=p.Wulf||{};p.Wulf=i,i.Scroll=Tt}var mt={};_(mt,{LayoutEngine:()=>Y,LocalizedComponent:()=>S,Masonry:()=>B,createI18nManager:()=>D,default:()=>Ct,masonryEn:()=>pt,masonryFr:()=>dt,masonryI18n:()=>Q});var Y=class{static parseGutter(i){return typeof i=="number"?{x:Math.max(0,i),y:Math.max(0,i)}:i&&typeof i=="object"?{x:Math.max(0,Number(i.x)||0),y:Math.max(0,Number(i.y)||0)}:{x:0,y:0}}static resolveColumnWidth(i,t,e){if(typeof e=="number"&&e>0)return e;if(typeof e=="string"){let o=i.querySelector(e);if(o){let a=o.getBoundingClientRect().width;if(a>0)return a}let n=parseFloat(e);if(!isNaN(n)&&n>0)return e.endsWith("%")?i.getBoundingClientRect().width*n/100:n}if(e instanceof HTMLElement){let o=e.getBoundingClientRect().width;if(o>0)return o}if(t){let o=t.getBoundingClientRect().width;if(o>0)return o}let s=i.getBoundingClientRect().width;return s>0?s:200}static getItemSpan(i,t,e,s){let o=i.getAttribute("data-masonry-span")||i.dataset.masonrySpan;if(o){let a=parseInt(o,10);if(!isNaN(a)&&a>0)return Math.min(s,a)}let n=i.className.match(/(?:^|\s)(?:span|col-span)-(\d+)(?:\s|$)/);if(n&&n[1]){let a=parseInt(n[1],10);if(!isNaN(a)&&a>0)return Math.min(s,a)}return 1}static calculate(i,t,e){let o=i.getBoundingClientRect().width,{x:n,y:a}=this.parseGutter(e.gutter);if(o<=0||t.length===0)return{cols:1,colWidth:o,gutterX:n,gutterY:a,containerHeight:0,containerWidth:o,positions:[]};let r=t[0]||null,l=this.resolveColumnWidth(i,r,e.columnWidth),h=Math.floor((o+n)/(l+n));h=Math.max(1,h),!e.columnWidth&&h>1&&(l=(o-(h-1)*n)/h);let c=e.fitWidth?h*l+(h-1)*n:void 0,u=new Array(h).fill(0),d=[],m=t.map(v=>{let w=v.getBoundingClientRect().height;return w>0?w:50}),f=0;for(let v=0;v<t.length;v++){let w=t[v],E=m[v],y=this.getItemSpan(w,l,n,h),T=0,k=0;if(e.horizontalOrder){f+y>h&&(f=0),T=f;let A=0;for(let M=0;M<y;M++)u[T+M]>A&&(A=u[T+M]);k=A,f=(T+y)%h}else if(y===1){let A=u[0];T=0;for(let M=1;M<h;M++)u[M]<A&&(A=u[M],T=M);k=A}else{let A=1/0;T=0;for(let M=0;M<=h-y;M++){let st=0;for(let nt=0;nt<y;nt++)u[M+nt]>st&&(st=u[M+nt]);st<A&&(A=st,T=M)}k=A}let et=y*l+(y-1)*n,L=T*(l+n);d.push({element:w,x:L,y:k,width:et,height:E,column:T,span:y});let O=k+E+a;for(let A=0;A<y;A++)u[T+A]=O}let g=0;for(let v=0;v<h;v++)u[v]>g&&(g=u[v]);let b=Math.max(0,g>0?g-a:0);return{cols:h,colWidth:l,gutterX:n,gutterY:a,containerHeight:b,containerWidth:o,fittedWidth:c,positions:d}}};var dt={gallery:"Galerie en grille asym\xE9trique"};var pt={gallery:"Masonry grid gallery"};var Q=D("fr",{fr:dt,en:pt});var B=class extends S{constructor(t,e={}){super(e.i18n);this.isNativeCSSGrid=!1;this._items=[];this.resizeObserver=null;this.itemResizeObserver=null;this.layoutRafId=null;this.isDestroyed=!1;this.wasRoleInferred=!1;this.wasAriaLabelInferred=!1;this.hasExplicitAriaLabel=!1;this.lastInferredAriaLabel="";this.removeTimers=new Set;this.pendingImageListeners=[];if(typeof t=="string"){let o=document.querySelector(t);if(!o)throw new Error(`[Wulf.Masonry] Conteneur introuvable pour le s\xE9lecteur : "${t}"`);this.root=o}else if(t instanceof HTMLElement)this.root=t;else throw new Error("[Wulf.Masonry] Cible invalide : fournissez un \xE9l\xE9ment HTMLElement ou un s\xE9lecteur valide.");this.originalContainerStyles={height:this.root.style.height,width:this.root.style.width},this.hasExplicitAriaLabel=!!(e.ariaLabel||e.i18n?.gallery),this.options={itemSelector:e.itemSelector||"> *",columnWidth:e.columnWidth??0,gutter:e.gutter??0,percentPosition:!!e.percentPosition,fitWidth:!!e.fitWidth,horizontalOrder:!!e.horizontalOrder,transitionDuration:e.transitionDuration!==void 0?e.transitionDuration:300,stagger:e.stagger||0,resize:e.resize!==!1,autoImages:e.autoImages!==!1,useNativeCSSGrid:e.useNativeCSSGrid!==!1,ariaRole:e.ariaRole||"region",ariaLabel:e.ariaLabel||this.t("gallery"),i18n:e.i18n||{},onLayout:e.onLayout||(()=>{}),onItemPlaced:e.onItemPlaced||(()=>{}),audit:e.audit??!0};let s=typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("grid-template-rows","masonry");this.options.useNativeCSSGrid&&s?(this.isNativeCSSGrid=!0,this.root.classList.add("wulf-masonry","wulf-masonry--native")):this.root.classList.add("wulf-masonry"),this.initAccessibility(),this.applyTransitionDuration(),this.reloadItems(),this.initObservers(),this.initImages(),this.layout(),this.runAuditWarning(this.options.audit)}get items(){return[...this._items]}initAccessibility(){this.options.ariaRole&&!this.root.hasAttribute("role")&&(this.root.setAttribute("role",this.options.ariaRole),this.wasRoleInferred=!0);let t=this.hasExplicitAriaLabel?this.options.ariaLabel:this.t("gallery");t&&!this.root.hasAttribute("aria-label")&&(this.root.setAttribute("aria-label",t),this.lastInferredAriaLabel=t,this.wasAriaLabelInferred=!0)}syncAccessibilityLabels(){if(this.wasAriaLabelInferred&&!this.hasExplicitAriaLabel&&this.root.getAttribute("aria-label")===this.lastInferredAriaLabel){let e=this.t("gallery");this.root.setAttribute("aria-label",e),this.lastInferredAriaLabel=e,this.options.ariaLabel=e}}applyTransitionDuration(){let t=this.options.transitionDuration,e=typeof t=="number"?`${t}ms`:t;this.root.style.setProperty("--wulf-masonry-duration",e)}reloadItems(){if(this.isDestroyed)return;let t=[];if(this.options.itemSelector==="> *")t=Array.from(this.root.children).filter(e=>e instanceof HTMLElement&&!e.hasAttribute("data-masonry-ignore"));else try{t=Array.from(this.root.querySelectorAll(this.options.itemSelector)).filter(e=>e.parentElement===this.root&&!e.hasAttribute("data-masonry-ignore"))}catch{t=Array.from(this.root.children).filter(e=>e instanceof HTMLElement&&!e.hasAttribute("data-masonry-ignore"))}this._items=t;for(let e of this._items)e.classList.add("wulf-masonry-item"),this.itemResizeObserver&&this.itemResizeObserver.observe(e)}initObservers(){if(!this.options.resize||typeof ResizeObserver>"u")return;let t=this.root.getBoundingClientRect().width;this.resizeObserver=new ResizeObserver(e=>{for(let s of e){let o=s.contentRect.width;Math.abs(o-t)>=1&&(t=o,this.scheduleLayout())}}),this.resizeObserver.observe(this.root),this.itemResizeObserver=new ResizeObserver(()=>{this.scheduleLayout()});for(let e of this._items)this.itemResizeObserver.observe(e)}initImages(){if(!this.options.autoImages)return;let t=Array.from(this.root.querySelectorAll("img"));for(let e of t)if(!e.complete){let s=()=>{let o=()=>{this.pendingImageListeners=this.pendingImageListeners.filter(n=>n.handler!==o),this.isDestroyed||this.scheduleLayout()};this.pendingImageListeners.push({img:e,handler:o}),e.addEventListener("load",o,{once:!0})};typeof e.decode=="function"?e.decode().then(()=>{this.isDestroyed||this.scheduleLayout()}).catch(()=>{s()}):s()}}scheduleLayout(){this.isDestroyed||(this.layoutRafId!==null&&cancelAnimationFrame(this.layoutRafId),this.layoutRafId=requestAnimationFrame(()=>{this.layoutRafId=null,this.layout()}))}layout(){if(this.isDestroyed)return;if(this.syncAccessibilityLabels(),this.isNativeCSSGrid){this.options.onLayout([]);return}this.root.setAttribute("aria-busy","true");let t=Y.calculate(this.root,this._items,this.options);this.root.style.height=`${t.containerHeight}px`,this.options.fitWidth&&t.fittedWidth!==void 0?(this.root.style.width=`${t.fittedWidth}px`,this.root.classList.add("wulf-masonry--fit-width")):this.root.classList.remove("wulf-masonry--fit-width");let e=this.options.stagger,s=this.options.percentPosition&&t.containerWidth>0;for(let o=0;o<t.positions.length;o++){let n=t.positions[o],a=n.element;if(s){let r=Number((n.width/t.containerWidth*100).toFixed(4));a.style.setProperty("--wulf-masonry-w",`${r}%`)}else a.style.setProperty("--wulf-masonry-w",`${n.width}px`);a.style.setProperty("--wulf-masonry-x",`${n.x}px`),a.style.setProperty("--wulf-masonry-y",`${n.y}px`),e>0?a.style.transitionDelay=`${o*e}ms`:a.style.removeProperty("transition-delay"),a.classList.remove("wulf-masonry-item--hidden"),this.options.onItemPlaced(a,n)}this.root.setAttribute("aria-busy","false"),this.options.onLayout(t.positions)}append(t){if(this.isDestroyed)return;let e=Array.isArray(t)?t:[t];if(e.length===0)return;let s=document.createDocumentFragment();for(let o of e)o.classList.add("wulf-masonry-item","wulf-masonry-item--hidden"),s.appendChild(o);this.root.appendChild(s),this.reloadItems(),this.initImages(),this.layout()}prepend(t){if(this.isDestroyed)return;let e=Array.isArray(t)?t:[t];if(e.length===0)return;let s=this.root.firstChild,o=document.createDocumentFragment();for(let n of e)n.classList.add("wulf-masonry-item","wulf-masonry-item--hidden"),o.appendChild(n);this.root.insertBefore(o,s),this.reloadItems(),this.initImages(),this.layout()}remove(t){if(this.isDestroyed)return;let e=Array.isArray(t)?t:[t];if(e.length===0)return;for(let n of e)n.classList.add("wulf-masonry-item--hidden");let s=typeof this.options.transitionDuration=="number"?this.options.transitionDuration:300;if(s<=0){for(let n of e)n.parentElement===this.root&&(this.itemResizeObserver&&this.itemResizeObserver.unobserve(n),this.root.removeChild(n));this.reloadItems(),this.layout();return}let o=window.setTimeout(()=>{if(this.removeTimers.delete(o),!this.isDestroyed){for(let n of e)n.parentElement===this.root&&(this.itemResizeObserver&&this.itemResizeObserver.unobserve(n),this.root.removeChild(n));this.reloadItems(),this.layout()}},s);this.removeTimers.add(o)}audit(){let t=[],e=this.checkAriaIdReferences(this.root,"aria-labelledby",t),s=!this.wasAriaLabelInferred&&!!this.root.getAttribute("aria-label")?.trim();!this.hasExplicitAriaLabel&&!s&&!e&&t.push("Libell\xE9 contextuel manquant : d\xE9finissez l'option ariaLabel (ou un attribut aria-label / aria-labelledby sur le conteneur) pour qualifier la grille (WCAG 4.1.2).");let o=Array.from(this.root.querySelectorAll("img")).filter(n=>!n.hasAttribute("alt")&&n.getAttribute("aria-hidden")!=="true");return o.length>0&&t.push(`${o.length} image(s) <img> d\xE9pourvue(s) d'attribut alt : renseignez alt="description" (ou alt="" si d\xE9corative) (WCAG 1.1.1).`),t}getAuditPrefix(){return"Wulf.Masonry"}getAuditTargetLabel(){return this.root.id?`#${this.root.id}`:`<${this.root.tagName.toLowerCase()}.wulf-masonry>`}destroy(){if(!this.isDestroyed){this.isDestroyed=!0;for(let t of this.removeTimers)clearTimeout(t);this.removeTimers.clear();for(let{img:t,handler:e}of this.pendingImageListeners)t.removeEventListener("load",e);this.pendingImageListeners=[],this.layoutRafId!==null&&(cancelAnimationFrame(this.layoutRafId),this.layoutRafId=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.itemResizeObserver&&(this.itemResizeObserver.disconnect(),this.itemResizeObserver=null),this.root.classList.remove("wulf-masonry","wulf-masonry--native","wulf-masonry--fit-width"),this.root.removeAttribute("aria-busy"),this.wasRoleInferred&&this.root.getAttribute("role")===this.options.ariaRole&&this.root.removeAttribute("role"),this.wasAriaLabelInferred&&this.root.getAttribute("aria-label")===this.lastInferredAriaLabel&&this.root.removeAttribute("aria-label"),this.root.style.removeProperty("--wulf-masonry-duration"),this.originalContainerStyles.height?this.root.style.height=this.originalContainerStyles.height:this.root.style.removeProperty("height"),this.originalContainerStyles.width?this.root.style.width=this.originalContainerStyles.width:this.root.style.removeProperty("width");for(let t of this._items)t.classList.remove("wulf-masonry-item","wulf-masonry-item--hidden"),t.style.removeProperty("--wulf-masonry-w"),t.style.removeProperty("--wulf-masonry-x"),t.style.removeProperty("--wulf-masonry-y"),t.style.removeProperty("transition-delay");this._items=[]}}};B._i18n=Q,B.i18n=Q;var Ct=B;if(typeof window<"u"){let p=window,i=p.Wulf||{};p.Wulf=i,i.Masonry=Object.assign(B,{Masonry:B,LayoutEngine:Y,i18n:Q})}var bt={};_(bt,{LocalizedComponent:()=>S,Toast:()=>F,ToastInstance:()=>it,ToastManager:()=>tt,createI18nManager:()=>D,default:()=>Ot,toastEn:()=>gt,toastFr:()=>ft,toastI18n:()=>$});var ft={closeButton:"Fermer la notification"};var gt={closeButton:"Close notification"};var $=D("fr",{fr:ft,en:gt});var Dt=1,it=class extends I{constructor(t,e){super();this._isClosed=!1;this.timerId=null;this.remainingTime=0;this.timerStartTime=0;this.isPaused=!1;this.id=`wulf-toast-${Dt++}`,this.options=Object.freeze({...t}),this.onDismissCallback=e;let s=t.duration===void 0?4e3:t.duration;typeof s=="number"&&s>0?this.remainingTime=s:this.remainingTime=0,this.element=this.createDOM(),this.bindEvents(),this.runAuditWarning(t.audit!==!1)}get isClosed(){return this._isClosed}audit(){let t=[],e=!!(this.options.title&&this.options.title.trim().length>0),s=!!(this.options.message&&this.options.message.trim().length>0);!e&&!s&&t.push("Contenu textuel vide : d\xE9finissez au moins un title ou un message pour que le lecteur d'\xE9cran puisse annoncer la notification (WCAG 4.1.3).");let o=this.options.duration===void 0?4e3:this.options.duration;typeof o=="number"&&o>0&&o<5e3&&t.push(`Dur\xE9e d'affichage trop courte (duration: ${o}ms) : pr\xE9voyez au moins 5000ms ou duration: false pour laisser le temps de lecture aux utilisateurs (WCAG 2.2.1).`);let n=this.options.closable??!0;return(o===!1||typeof o=="number"&&o<=0)&&!n&&!this.options.closeOnClick&&t.push("Notification persistante impossible \xE0 fermer : activez closable: true ou closeOnClick: true lorsque duration est d\xE9sactiv\xE9 (WCAG 2.1.1)."),t}getAuditPrefix(){return"Wulf.Toast"}getAuditTargetLabel(){return`#${this.id}`}createDOM(){let t=document.createElement("div");t.id=this.id,t.className="wulf-toast";let e=this.options.role==="alert"?"alert":"status";if(t.setAttribute("role",e),t.setAttribute("aria-live",e==="alert"?"assertive":"polite"),t.setAttribute("aria-atomic","true"),this.options.backgroundColor&&t.style.setProperty("--wulf-toast-bg",this.options.backgroundColor),this.options.titleColor&&t.style.setProperty("--wulf-toast-title-color",this.options.titleColor),this.options.textColor&&t.style.setProperty("--wulf-toast-text-color",this.options.textColor),this.options.iconColor&&t.style.setProperty("--wulf-toast-icon-color",this.options.iconColor),this.options.closeButtonColor&&t.style.setProperty("--wulf-toast-close-color",this.options.closeButtonColor),this.options.icon&&this.options.icon.trim()!==""){let n=document.createElement("span");n.className=`wulf-toast-icon ${this.options.icon.trim()}`,n.setAttribute("aria-hidden","true"),t.appendChild(n)}let s=document.createElement("div");if(s.className="wulf-toast-content",this.options.title&&this.options.title.trim()!==""){let n=document.createElement("div");n.className="wulf-toast-title",this.appendTextWithLineBreaks(n,this.options.title),s.appendChild(n)}if(this.options.message&&this.options.message.trim()!==""){let n=document.createElement("div");n.className="wulf-toast-message",this.appendTextWithLineBreaks(n,this.options.message),s.appendChild(n)}if(t.appendChild(s),this.options.closable??!0){let n=document.createElement("button");n.type="button",n.className="wulf-toast-close",n.setAttribute("aria-label",$.t("closeButton",this.options.i18n)),n.setAttribute("tabindex","0");let a=document.createElement("span");a.className="wulf-toast-close-icon",a.setAttribute("aria-hidden","true"),a.textContent="\xD7",n.appendChild(a),n.addEventListener("click",r=>{r.stopPropagation(),this.close("close-button")}),t.appendChild(n)}return t}appendTextWithLineBreaks(t,e){e.split(/\r\n|\r|\n/).forEach((o,n)=>{n>0&&t.appendChild(document.createElement("br")),t.appendChild(document.createTextNode(o))})}bindEvents(){this.element.addEventListener("click",t=>{this.options.onClick&&this.options.onClick(this,t),this.options.closeOnClick&&this.close("toast-click")}),this.element.addEventListener("mouseenter",()=>this.pauseTimer()),this.element.addEventListener("mouseleave",()=>this.resumeTimer()),this.element.addEventListener("focusin",()=>this.pauseTimer()),this.element.addEventListener("focusout",()=>this.resumeTimer())}startTimer(){this._isClosed||this.remainingTime<=0||(this.timerStartTime=Date.now(),this.timerId=window.setTimeout(()=>{this.close("timeout")},this.remainingTime))}pauseTimer(){if(this._isClosed||this.remainingTime<=0||this.isPaused)return;this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null);let t=Date.now()-this.timerStartTime;this.remainingTime=Math.max(0,this.remainingTime-t),this.isPaused=!0}resumeTimer(){this._isClosed||this.remainingTime<=0||!this.isPaused||(this.isPaused=!1,this.startTimer())}destroyImmediate(t="replace"){this._isClosed||(this._isClosed=!0,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.onDismissCallback&&this.onDismissCallback(this,t),this.options.onClose&&this.options.onClose(this,t))}close(t="programmatic",e=!1){return this._isClosed?Promise.resolve():(this._isClosed=!0,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),new Promise(s=>{this.element.classList.add(e?"wulf-toast-hiding-fast":"wulf-toast-hiding");let o=()=>{this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.onDismissCallback&&this.onDismissCallback(this,t),this.options.onClose&&this.options.onClose(this,t),s()};if(typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)o();else if(e)window.setTimeout(o,90);else{let a=!1,r=null,l=()=>{a||(a=!0,r!==null&&(window.clearTimeout(r),r=null),this.element.removeEventListener("animationend",l),this.element.removeEventListener("transitionend",l),o())};this.element.addEventListener("animationend",l,{once:!0}),this.element.addEventListener("transitionend",l,{once:!0}),r=window.setTimeout(l,300)}}))}};var G=class G{constructor(){this.containers=new Map;this.activeToasts=new Map;this.replaceTokens=new Map;this.pendingReplacements=new Set}static getInstance(){return G.instance||(G.instance=new G),G.instance}add(i){let t=i.options.position||"top-right",e=this.activeToasts.get(t);if(e||(e=[],this.activeToasts.set(t,e)),i.options.replace&&e.length>0){let o=[...e],n=(this.replaceTokens.get(t)||0)+1;this.replaceTokens.set(t,n),this.pendingReplacements.add(t);let a=o.map(r=>r.close("replace",!0));Promise.all(a).then(()=>{this.pendingReplacements.delete(t),this.replaceTokens.get(t)===n&&this.mountToast(i,t)});return}let s=typeof i.options.maxToasts=="number"&&i.options.maxToasts>0?i.options.maxToasts:5;if(e.length>=s){let o=e.length-s+1,n=e.splice(0,o);for(let a of n)a.close("max-limit",!0)}this.mountToast(i,t)}mountToast(i,t){let e=this.getOrCreateContainer(t),s=this.activeToasts.get(t);if(s||(s=[],this.activeToasts.set(t,s)),e.appendChild(i.element),s.push(i),i.options.onOpen)try{i.options.onOpen(i)}catch(o){console.error("[Wulf.Toast] Erreur dans le callback onOpen:",o)}i.startTimer()}remove(i,t){let e=i.options.position||"top-right",s=this.activeToasts.get(e);if(s){let o=s.indexOf(i);if(o!==-1&&s.splice(o,1),s.length===0&&!this.pendingReplacements.has(e)){let n=this.containers.get(e);n&&(!n.firstChild||n.children.length===0)&&(n.parentNode&&n.parentNode.removeChild(n),this.containers.delete(e),this.activeToasts.delete(e))}}}clearAll(i){let t=[];if(i){let e=this.activeToasts.get(i);if(e&&e.length>0){let s=[...e];for(let o of s)t.push(o.close("programmatic"))}else{let s=this.containers.get(i);s&&(!s.firstChild||s.children.length===0)&&(s.parentNode&&s.parentNode.removeChild(s),this.containers.delete(i),this.activeToasts.delete(i))}}else{let e=new Set([...Array.from(this.containers.keys()),...Array.from(this.activeToasts.keys())]);for(let s of e)t.push(this.clearAll(s))}return Promise.all(t).then(()=>{if(!i)for(let[e,s]of Array.from(this.containers.entries()))(!s.firstChild||s.children.length===0)&&(s.parentNode&&s.parentNode.removeChild(s),this.containers.delete(e),this.activeToasts.delete(e))})}getOrCreateContainer(i){let t=this.containers.get(i);return(!t||!document.body.contains(t))&&(t=document.createElement("div"),t.className=`wulf-toast-container wulf-toast-${i}`,t.setAttribute("aria-live","polite"),t.setAttribute("aria-relevant","additions removals"),document.body.appendChild(t),this.containers.set(i,t)),t}};G.instance=null;var tt=G;var F=class extends S{audit(){return[]}getAuditPrefix(){return"Wulf.Toast"}getAuditTargetLabel(){return"Toast"}static show(i={}){let t=tt.getInstance(),e=new it(i,(s,o)=>{t.remove(s,o)});return t.add(e),e}static clearAll(i){return tt.getInstance().clearAll(i)}};F._i18n=$,F.i18n=$;var Ot=F;if(typeof window<"u"){let p=window,i=p.Wulf||{};p.Wulf=i,i.Toast=Object.assign(F,{Toast:F,i18n:$})}var vt={};_(vt,{FocusTrap:()=>N,default:()=>N});var Ht=["a[href]","area[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed",'[contenteditable="true"]','[tabindex]:not([tabindex="-1"])'].join(","),X=[],N=class extends I{constructor(t,e={}){super();this.active=!1;this.paused=!1;this.previousActiveElement=null;this.inertSiblings=[];this.startSentinel=null;this.endSentinel=null;let s=typeof t=="string"?document.querySelector(t):t;if(!s||!(s instanceof HTMLElement))throw new Error(`[Wulf.FocusTrap] Conteneur introuvable ou invalide : "${t}"`);this.element=s,this.options={initialFocus:e.initialFocus!==void 0?e.initialFocus:"[data-autofocus], [autofocus]",returnFocus:e.returnFocus??!0,fallbackReturnFocus:e.fallbackReturnFocus??"",escapeDeactivates:e.escapeDeactivates??!0,allowOutsideClick:e.allowOutsideClick??!1,setInert:e.setInert??!1,onActivate:e.onActivate??(()=>{}),onDeactivate:e.onDeactivate??(()=>{}),audit:e.audit??!0},this.handleKeyDownBound=this.handleKeyDown.bind(this),this.handleClickOutsideBound=this.handleClickOutside.bind(this),this.handleFocusInBound=this.handleFocusIn.bind(this),this.runAuditWarning(this.options.audit)}isFocusable(t){if(!t||!t.isConnected||t.disabled||t.closest("fieldset[disabled]")&&!t.closest("legend")||t.hasAttribute("inert")||t.closest("[inert]")||t.hidden||t.closest("[hidden]")||t.style.display==="none"||t.style.visibility==="hidden")return!1;let e=window.getComputedStyle(t);if(e.display==="none"||e.visibility==="hidden"||t.offsetWidth===0&&t.offsetHeight===0&&e.position!=="fixed")return!1;if(t instanceof HTMLInputElement&&t.type==="radio"&&t.name){let s=Array.from(this.element.querySelectorAll(`input[type="radio"][name="${CSS.escape(t.name)}"]`)),o=s.find(n=>n.checked);return o?t===o:t===s[0]}return!0}getFocusableElements(){return Array.from(this.element.querySelectorAll(Ht)).filter(e=>this.isFocusable(e))}activate(){if(this.active)return this;let t=X[X.length-1];return t&&t.pause(),this.active=!0,this.paused=!1,X.push(this),this.previousActiveElement=document.activeElement,this.setupSentinels(),this.options.setInert&&this.applyInert(),document.addEventListener("keydown",this.handleKeyDownBound,!0),document.addEventListener("focusin",this.handleFocusInBound,!0),this.options.allowOutsideClick||(document.addEventListener("mousedown",this.handleClickOutsideBound,!0),document.addEventListener("touchstart",this.handleClickOutsideBound,!0)),this.applyInitialFocus(),this.runAuditWarning(this.options.audit),this.options.onActivate(),this}deactivate(){if(!this.active)return this;this.active=!1,this.paused=!1;let t=X.indexOf(this);t!==-1&&X.splice(t,1);let e=X[X.length-1];return e&&e.unpause(),document.removeEventListener("keydown",this.handleKeyDownBound,!0),document.removeEventListener("focusin",this.handleFocusInBound,!0),document.removeEventListener("mousedown",this.handleClickOutsideBound,!0),document.removeEventListener("touchstart",this.handleClickOutsideBound,!0),this.removeSentinels(),this.removeInert(),this.options.returnFocus&&this.restoreFocus(),this.options.onDeactivate(),this}pause(){this.paused=!0}unpause(){this.paused=!1}isActive(){return this.active&&!this.paused}audit(){let t=[],e=this.element.getAttribute("role"),s=this.element.tagName.toLowerCase()==="dialog";!s&&(!e||!["dialog","alertdialog","menu","listbox","tree","grid"].includes(e))&&t.push('R\xF4le s\xE9mantique manquant ou inadapt\xE9 : d\xE9finissez role="dialog" (ou "alertdialog", "menu", "listbox") sur le conteneur.'),(s||e==="dialog"||e==="alertdialog")&&this.element.getAttribute("aria-modal")!=="true"&&t.push('Isolation modale manquante : d\xE9finissez aria-modal="true" sur le conteneur de dialogue (WCAG 4.1.2).');let n=this.element.getAttribute("aria-label")?.trim(),a=this.checkAriaIdReferences(this.element,"aria-labelledby",t);return!n&&!a&&t.push('Nom accessible manquant : d\xE9finissez aria-labelledby="id-titre" ou aria-label="..." sur le conteneur (WCAG 4.1.2).'),t}getAuditPrefix(){return"Wulf.FocusTrap"}getAuditTargetLabel(){return this.element.id?`#${this.element.id}`:`<${this.element.tagName.toLowerCase()}>`}destroy(){this.deactivate()}handleKeyDown(t){if(!this.isActive())return;if(t.key==="Escape"&&this.options.escapeDeactivates){t.preventDefault(),t.stopPropagation(),this.deactivate();return}if(t.key!=="Tab")return;let e=this.getFocusableElements();if(e.length===0){t.preventDefault(),this.element.getAttribute("tabindex")===null&&this.element.setAttribute("tabindex","-1"),this.element.focus();return}let s=e[0],o=e[e.length-1],n=document.activeElement;!t.shiftKey&&(n===o||!this.element.contains(n))?(t.preventDefault(),s.focus()):t.shiftKey&&(n===s||!this.element.contains(n))&&(t.preventDefault(),o.focus())}handleFocusIn(t){if(!this.isActive())return;let e=t.target;if(e){if(e===this.startSentinel){let s=this.getFocusableElements();s.length>0?s[s.length-1].focus():this.element.focus();return}if(e===this.endSentinel){let s=this.getFocusableElements();s.length>0?s[0].focus():this.element.focus();return}if(!this.element.contains(e)){let s=this.getFocusableElements();s.length>0?s[0].focus():(this.element.getAttribute("tabindex")===null&&this.element.setAttribute("tabindex","-1"),this.element.focus())}}}handleClickOutside(t){if(!this.isActive())return;let e=t.target;e&&!this.element.contains(e)&&(t.preventDefault(),t.stopPropagation())}setupSentinels(){this.startSentinel||(this.startSentinel=document.createElement("span"),this.startSentinel.setAttribute("tabindex","0"),this.startSentinel.setAttribute("aria-hidden","true"),this.startSentinel.className="wulf-sentinel-start",this.startSentinel.style.cssText="position:fixed;top:0;left:0;opacity:0;pointer-events:none;width:0;height:0;"),this.endSentinel||(this.endSentinel=document.createElement("span"),this.endSentinel.setAttribute("tabindex","0"),this.endSentinel.setAttribute("aria-hidden","true"),this.endSentinel.className="wulf-sentinel-end",this.endSentinel.style.cssText="position:fixed;top:0;left:0;opacity:0;pointer-events:none;width:0;height:0;"),this.element.parentNode&&(this.element.parentNode.insertBefore(this.startSentinel,this.element),this.element.parentNode.insertBefore(this.endSentinel,this.element.nextSibling))}removeSentinels(){this.startSentinel?.remove(),this.endSentinel?.remove(),this.startSentinel=null,this.endSentinel=null}applyInert(){this.inertSiblings=[];let t=this.element.parentElement,e=this.element;for(;t&&t!==document.body;)e=t,t=t.parentElement;t===document.body&&Array.from(document.body.children).forEach(s=>{s instanceof HTMLElement&&s!==e&&s!==this.startSentinel&&s!==this.endSentinel&&!s.hasAttribute("inert")&&(s.setAttribute("inert",""),this.inertSiblings.push(s))})}removeInert(){this.inertSiblings.forEach(t=>t.removeAttribute("inert")),this.inertSiblings=[]}applyInitialFocus(){if(this.options.initialFocus===!1)return;let t=null;if(typeof this.options.initialFocus=="string"?t=this.element.querySelector(this.options.initialFocus):this.options.initialFocus instanceof HTMLElement&&(t=this.options.initialFocus),t&&this.isFocusable(t)){t.focus();return}let e=this.getFocusableElements();e.length>0?e[0].focus():(this.element.getAttribute("tabindex")===null&&this.element.setAttribute("tabindex","-1"),this.element.focus())}restoreFocus(){if(this.previousActiveElement&&this.previousActiveElement.isConnected){this.previousActiveElement.focus();return}if(this.options.fallbackReturnFocus){let t=typeof this.options.fallbackReturnFocus=="string"?document.querySelector(this.options.fallbackReturnFocus):this.options.fallbackReturnFocus;t&&t.isConnected&&t.focus()}}};if(typeof window<"u"){let p=window,i=p.Wulf||{};p.Wulf=i,i.FocusTrap=Object.assign(N,{FocusTrap:N})}return At(Rt);})();
|
|
2
5
|
if (typeof window !== "undefined") { window.Wulf = window.Wulf || {}; if (typeof Wulf !== "undefined" && Wulf) { var targets = ["Mask", "Scroll", "Masonry", "Toast"]; for (var i = 0; i < targets.length; i++) { var t = targets[i]; if (Wulf[t] && window.Wulf[t] !== Wulf[t]) { try { Object.defineProperty(window.Wulf, t, { value: Wulf[t], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[t] = Wulf[t]; } catch (__) {} } } } for (var k in Wulf) { if (window.Wulf[k] === undefined) { try { Object.defineProperty(window.Wulf, k, { value: Wulf[k], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[k] = Wulf[k]; } catch (__) {} } } } } }
|
|
3
6
|
//# sourceMappingURL=index.global.min.js.map
|