wulf.js 1.9.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +124 -78
- package/changelog.md +105 -0
- package/dist/focus-trap.esm.js +245 -126
- package/dist/focus-trap.esm.js.map +3 -3
- package/dist/focus-trap.global.js +247 -128
- package/dist/focus-trap.global.js.map +3 -3
- package/dist/focus-trap.global.min.js +4 -4
- package/dist/focus-trap.global.min.js.map +4 -4
- package/dist/index.esm.js +2434 -905
- package/dist/index.esm.js.map +4 -4
- package/dist/index.global.js +2436 -907
- package/dist/index.global.js.map +4 -4
- package/dist/index.global.min.js +4 -4
- package/dist/index.global.min.js.map +4 -4
- package/dist/mask.css +1 -1
- package/dist/mask.css.map +2 -2
- package/dist/mask.esm.js +746 -346
- package/dist/mask.esm.js.map +3 -3
- package/dist/mask.global.js +748 -348
- package/dist/mask.global.js.map +3 -3
- package/dist/mask.global.min.js +4 -4
- package/dist/mask.global.min.js.map +4 -4
- package/dist/mask.layered.css +1 -0
- package/dist/mask.layered.css.map +7 -0
- package/dist/masonry.css +1 -1
- package/dist/masonry.css.map +2 -2
- package/dist/masonry.esm.js +341 -114
- package/dist/masonry.esm.js.map +3 -3
- package/dist/masonry.global.js +343 -116
- package/dist/masonry.global.js.map +3 -3
- package/dist/masonry.global.min.js +4 -4
- package/dist/masonry.global.min.js.map +4 -4
- package/dist/masonry.layered.css +1 -0
- package/dist/masonry.layered.css.map +7 -0
- package/dist/scroll.css +1 -1
- package/dist/scroll.css.map +2 -2
- package/dist/scroll.esm.js +524 -153
- package/dist/scroll.esm.js.map +3 -3
- package/dist/scroll.global.js +526 -155
- package/dist/scroll.global.js.map +3 -3
- package/dist/scroll.global.min.js +4 -4
- package/dist/scroll.global.min.js.map +4 -4
- package/dist/scroll.layered.css +1 -0
- package/dist/scroll.layered.css.map +7 -0
- package/dist/shortcut.esm.js +209 -46
- package/dist/shortcut.esm.js.map +3 -3
- package/dist/shortcut.global.js +211 -48
- package/dist/shortcut.global.js.map +3 -3
- package/dist/shortcut.global.min.js +2 -2
- package/dist/shortcut.global.min.js.map +4 -4
- package/dist/toast.css +1 -1
- package/dist/toast.css.map +2 -2
- package/dist/toast.esm.js +590 -160
- package/dist/toast.esm.js.map +3 -3
- package/dist/toast.global.js +592 -162
- package/dist/toast.global.js.map +3 -3
- package/dist/toast.global.min.js +4 -4
- package/dist/toast.global.min.js.map +4 -4
- package/dist/toast.layered.css +1 -0
- package/dist/toast.layered.css.map +7 -0
- package/dist/types/common/dom.d.ts +38 -0
- package/dist/types/focus-trap/FocusTrap.d.ts +15 -5
- package/dist/types/focus-trap/types.d.ts +2 -2
- package/dist/types/index.d.ts +10 -0
- package/dist/types/mask/AmountEngine.d.ts +1 -0
- package/dist/types/mask/BaseInputMask.d.ts +24 -0
- package/dist/types/mask/InputAmountMask.d.ts +3 -0
- package/dist/types/mask/InputEmailMask.d.ts +16 -1
- package/dist/types/mask/InputMask.d.ts +1 -0
- package/dist/types/mask/MaskEngine.d.ts +4 -0
- package/dist/types/masonry/Masonry.d.ts +10 -3
- package/dist/types/scroll/ScrollBlock.d.ts +31 -3
- package/dist/types/scroll/types.d.ts +13 -1
- package/dist/types/shortcut/ShortcutFormatter.d.ts +6 -0
- package/dist/types/shortcut/ShortcutManager.d.ts +5 -0
- package/dist/types/toast/Toast.d.ts +4 -0
- package/dist/types/toast/ToastInstance.d.ts +22 -10
- package/dist/types/toast/ToastManager.d.ts +37 -4
- package/dist/types/toast/i18n/types.d.ts +2 -0
- package/dist/types/toast/types.d.ts +14 -2
- package/package.json +20 -5
package/dist/index.global.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`+
|
|
1
|
+
"use strict";var __WulfIIFE=(()=>{var wt=Object.defineProperty;var _t=Object.getOwnPropertyDescriptor;var jt=Object.getOwnPropertyNames;var Yt=Object.prototype.hasOwnProperty;var et=(u,t)=>{for(var e in t)wt(u,e,{get:t[e],enumerable:!0})},Xt=(u,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of jt(t))!Yt.call(u,s)&&s!==e&&wt(u,s,{get:()=>t[s],enumerable:!(i=_t(t,s))||i.enumerable});return u};var Zt=u=>Xt(wt({},"__esModule",{value:!0}),u);var ue={};et(ue,{AmountEngine:()=>q,AuditableComponent:()=>N,BaseInputMask:()=>O,EmailEngine:()=>J,FocusTrap:()=>Ot,InputAmountMask:()=>rt,InputEmailMask:()=>at,InputMask:()=>st,LayoutEngine:()=>W,LocalizedComponent:()=>x,Mask:()=>At,MaskEngine:()=>G,MaskHistory:()=>V,MaskKeyboard:()=>Z,Masonry:()=>Lt,Scroll:()=>It,ScrollBlock:()=>Q,Shortcut:()=>Ht,ShortcutFormatter:()=>D,ShortcutManager:()=>B,Toast:()=>Pt,ToastInstance:()=>nt,ToastManager:()=>_,WulfFocusTrap:()=>X,WulfMasonry:()=>U,WulfShortcut:()=>B,WulfToast:()=>j,createI18nManager:()=>z,default:()=>St,getDeepActiveElement:()=>bt,getSafeWulfNamespace:()=>R,isImeComposing:()=>H,parseCssDurationMs:()=>Tt,prefersReducedMotion:()=>ot,resolveMaskConstructorArgs:()=>$,safeCssEscape:()=>ct,safeMove:()=>it,waitForAnimations:()=>ht});var At={};et(At,{AmountEngine:()=>q,BaseInputMask:()=>O,EmailEngine:()=>J,InputAmountMask:()=>rt,InputEmailMask:()=>at,InputMask:()=>st,Mask:()=>Ft,MaskEngine:()=>G,MaskHistory:()=>V,MaskKeyboard:()=>Z,default:()=>St,resolveMaskConstructorArgs:()=>$});function R(){if(typeof window>"u")return null;let u=window,t=u.Wulf;if(!t||typeof t!="object"||typeof Node<"u"&&t instanceof Node||typeof HTMLCollection<"u"&&t instanceof HTMLCollection){let e={};return u.Wulf=e,e}return t}function ct(u){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(u):String(u).replace(/["\\\u0000-\u001F\u007F]/g,"\\$&")}function bt(u){if(typeof document>"u")return null;let t=(u??document).activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t&&typeof t.focus=="function"?t:null}function it(u,t,e=null){let i=u.moveBefore;if(typeof i=="function"&&t.isConnected&&u.isConnected&&typeof u.getRootNode=="function"&&typeof t.getRootNode=="function"&&u.getRootNode()===t.getRootNode())try{i.call(u,t,e);return}catch{}u.insertBefore(t,e)}function H(u){return!!(u.isComposing||u.key==="Process"||u.key==="Enter"&&u.keyCode===229)}function Tt(u,t=300,e=6e4){let i=Number.isFinite(t)&&t>=0?Math.min(t,e):300;if(typeof u=="number")return Number.isFinite(u)&&u>=0?Math.min(u,e):i;if(typeof u=="string"){let s=u.split(","),n=-1;for(let o of s){let r=/^\+?(\d+(?:\.\d+)?|\.\d+)(ms|s)?$/i.exec(o.trim());if(r){let a=parseFloat(r[1]);if(Number.isFinite(a)&&a>=0){let l=r[2]?.toLowerCase()==="s"?a*1e3:a;l>n&&(n=l)}}}if(n>=0)return Math.min(n,e)}return i}function ot(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function ht(u,t,e){let i=Number.isFinite(t)?Math.min(t,6e4):300;if(e?.aborted||i<=0||ot())return Promise.resolve();let s=typeof u.getAnimations=="function"?u.getAnimations().filter(n=>{if(n.playState!=="running")return!1;let o=n.effect?.getComputedTiming?.();return o?Number.isFinite(o.endTime):!0}):[];return s.length===0?Promise.resolve():new Promise(n=>{let o=!1,r=null,a=()=>{o||(o=!0,r!==null&&(clearTimeout(r),r=null),e?.removeEventListener("abort",a),n())};e?.addEventListener("abort",a,{once:!0}),r=setTimeout(a,i),Promise.allSettled(s.map(l=>l.finished)).then(a)})}var N=class{getAuditDisableHint(){return"Passez { audit: false } dans les options pour d\xE9sactiver cet avertissement"}runAuditWarning(t=!0){if(!t)return[];let e=this.audit();return e.length>0&&typeof console<"u"&&typeof console.warn=="function"&&console.warn(`[${this.getAuditPrefix()}] Audit d'accessibilit\xE9 \u2014 ${e.length} contrainte(s) manquante(s) sur ${this.getAuditTargetLabel()} :
|
|
2
|
+
`+e.map(i=>` - ${i}`).join(`
|
|
3
3
|
`)+`
|
|
4
|
-
(${this.getAuditDisableHint()})`),t}checkAriaIdReferences(i,t,e){let s=i.getAttribute(t)?.trim();if(!s)return!1;let n=i.ownerDocument||document,r=s.split(/\s+/).filter(Boolean),o=r.length>0&&r.every(a=>!!n.getElementById(a));return o||e.push(`Attribut ${t}="${s}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`),o}};function R(d,i,t){return i&&typeof i=="object"&&"tagName"in i&&i.tagName==="INPUT"?{wrapper:d||null,input:i,options:t||{}}:{wrapper:null,input:d,options:i&&typeof i=="object"&&!("tagName"in i)?i:{}}}var x=class extends C{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,n="";e!==s?n=this.extractRawSnippet(this.input.value.slice(e,s)):n=this.getRawValue(),n&&t.clipboardData&&(t.preventDefault(),t.clipboardData.setData("text/plain",n))};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:n,input:r,options:o}=R(t,e,s);if(!r||typeof r!="object"||r.nodeType!==1||r.tagName!=="INPUT")throw new Error(`[${new.target.name||"InputMask"}] input (HTMLInputElement) est requis.`);this.input=r;let a=this.input.getAttribute("data-mask-create-wrapper")==="true",l=!!(o.createWrapper??a),h=n;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"),p=this.getAttr("data-mask-select-on-focus")==="true",f=this.getAttr("data-mask-copy-raw")==="true",m=this.getAttr("data-mask-align")||this.getAttr("data-align"),g=this.getAttr("data-mask-audit"),{disabled:b,align:v,...w}=o,E=b!==void 0?b:!!u,y=o.audit??(g!==null?g!=="false":!0),T=this.input.type==="password";this.options={...w,createWrapper:l,showMaskOnFocus:o.showMaskOnFocus??c??!1,selectAllOnFocus:o.selectAllOnFocus??p??!1,copyRaw:T?!1:o.copyRaw??f??!1,disabled:E,align:v??(m||void 0),emitNativeInput:o.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(n){let r=String(n??"");e.set.call(this,r),!s.isDestroyed&&s.onNativeValueSet(r)},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(),n=this.checkAriaIdReferences(this.input,"aria-labelledby",t),r=!!this.input.closest("label"),o=!!(this.input.labels&&this.input.labels.length>0),a=!1;this.input.id&&typeof CSS<"u"&&typeof CSS.escape=="function"?a=!!e.querySelector(`label[for="${CSS.escape(this.input.id)}"]`):this.input.id&&(a=!!e.querySelector(`label[for="${this.input.id}"]`)),!s&&!n&&!r&&!o&&!a&&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 It={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()}},P=class d{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={...It,...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 d(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 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="",e=!0;for(let s=0;s<this.pattern.length;s++){let n=this.pattern[s],r=!1;n==="\\"&&s+1<this.pattern.length&&(r=!0,s++,n=this.pattern[s]);let o=r?void 0:this.tokens[n];o?(e=!1,this.slots.push({char:n,isStatic:!1,isPrefix:!1,token:o,placeholder:this.placeholderChar}),t+=this.placeholderChar):(this.slots.push({char:n,isStatic:!0,isPrefix:e,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(i){if(this.subEngines.length<=1)return this;let t=String(i??""),e=this.subEngines.filter(a=>{let l=a.getPrefix();return l.length>0&&t.toLowerCase().startsWith(l.trim().toLowerCase())}),s=e.length>0?e:this.subEngines,n=[...s].sort((a,l)=>l.getEditableCount()-a.getEditableCount())[0],o=(n?n.extractRaw(t):t).length;for(let a of s)if(a.getEditableCount()>=o)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(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 r=this.selectEngine(i);if(r!==this)return r.extractRaw(i)}let t=String(i??"");if(!t)return"";let e="",s=0,n=0;if(this.prefixSlotsCount>0){for(;s<t.length&&(t[s]===" "||t[s]===" ");)s++;let r=0;for(;s<t.length&&r<this.prefixSlotsCount;){let o=this.slots[r].char,a=t[s];if(a.toUpperCase()===o.toUpperCase())s++,r++;else if(o===" "&&a!==" ")r++;else break}n=this.prefixSlotsCount}for(;s<t.length&&n<this.slots.length;){let r=this.slots[n],o=t[s];if(r.isStatic)o.toUpperCase()===r.char.toUpperCase()&&s++,n++;else if(r.token&&r.token.pattern.test(o)){let a=r.token.transform?r.token.transform(o):o;this.autoLowercase&&!r.token.transform&&(a=a.toLowerCase()),e+=a,s++,n++}else this.strict?s++:(e+=this.autoLowercase?o.toLowerCase():o,s++,n++)}if(!this.strict&&s<t.length){let r=t.slice(s);e+=this.autoLowercase?r.toLowerCase():r}return e}format(i){if(this.subEngines.length>0){let r=this.selectEngine(i);if(r!==this)return r.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="",n=0;for(let r=0;r<this.slots.length;r++){let o=this.slots[r];if(o.isStatic){let a=n<e.length,l=n===0&&!!o.isPrefix,h=n>0&&n===e.length;if(a||l||h)s+=o.char;else break}else if(n<e.length){let a=e[n],l=o.token?.transform?o.token.transform(a):a;this.autoLowercase&&!o.token?.transform&&(l=l.toLowerCase()),s+=l,n++}else break}if(!this.strict&&n<e.length){let r=e.substring(n);s+=this.autoLowercase?r.toLowerCase():r}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,n=String(i??""),r=String(e??"");if(t<=0||!r)return s;let a=this.extractRaw(n.slice(0,t)).length;if(a===0)return Math.max(s,Math.min(this.getNextEditablePosition(0),r.length));let l=0,h=r.length;for(let c=0;c<r.length&&c<this.slots.length;c++)if(!this.slots[c].isStatic&&(l++,l===a)){h=c+1;break}for(;h<r.length&&this.slots[h]&&this.slots[h].isStatic;)h++;return Math.max(s,Math.min(h,r.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 D=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 V=class{constructor(i){this.delegate=i}handleKeyDown(i){let t=this.delegate.getInput(),e=this.delegate.getEngine(),s=this.delegate.getHistory(),n=e.getPrefixLength(),r=t.selectionStart??0,o=t.selectionEnd??r;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(r);let a=i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey,l=o>r;if(a&&!l){let u=e.getSlots(),p=r<u.length&&u[r].isStatic&&u[r].char===i.key,f=r>0&&r-1<u.length&&u[r-1].isStatic&&u[r-1].char===i.key;if(p||f){i.preventDefault();let g=p?r:r-1,b=e.getNextEditablePosition(g+1);this.delegate.applyMask(t.value,b,!0);return}let m=-1;for(let g=r;g<u.length;g++)if(u[g].isStatic){u[g].char===i.key&&(m=g);break}if(m!==-1){i.preventDefault();let g=m-1;for(;g>=n&&!u[g].isStatic;)g--;g++;let b=m-g,v=t.value.slice(g,r);if(u.slice(g,m).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(m),st=t.value.slice(0,g)+T+k,S=e.getNextEditablePosition(m+1);this.delegate.applyMask(st,S,!0);return}let E=e.getNextEditablePosition(m+1);this.delegate.applyMask(t.value,E,!0);return}}if(a&&e.isStrict()){let u=e.getEditableCount();if(u>0){let p=e.extractRaw(t.value),f=u-p.length;if(o>r){let m=e.extractRaw(t.value.slice(r,o));f=u-(p.length-m.length)}if(f<=0){i.preventDefault();return}}}if(o>r){if(i.key==="Backspace"||i.key==="Delete"){i.preventDefault();let u=t.value,p=u.slice(0,r)+u.slice(o);this.delegate.applyMask(p,Math.max(n,r));return}return}if(i.key==="ArrowLeft"&&!i.shiftKey&&r<=n){i.preventDefault(),t.setSelectionRange(n,n);return}if(i.key==="Home"&&!i.shiftKey){i.preventDefault(),t.setSelectionRange(n,n);return}if(i.key==="Backspace"&&r<=n){i.preventDefault(),t.setSelectionRange(n,n);return}if(i.key==="Delete"&&r<n){i.preventDefault(),t.setSelectionRange(n,n);return}if(i.key==="Backspace"&&(i.ctrlKey||i.altKey||i.metaKey)){if(i.preventDefault(),r<=n){t.setSelectionRange(n,n);return}let u=r-1;for(;u>=n&&e.isSeparatorAt(u);)u--;for(;u>=n&&!e.isSeparatorAt(u);)u--;let p=Math.max(n,u+1),f=t.value,m=f.slice(0,p)+f.slice(r);this.delegate.applyMask(m,p);return}if(i.key==="Delete"&&(i.ctrlKey||i.altKey||i.metaKey)){i.preventDefault();let u=t.value;if(r>=u.length)return;let p=r;for(;p<u.length&&e.isSeparatorAt(p);)p++;for(;p<u.length&&!e.isSeparatorAt(p);)p++;for(;p<u.length&&e.isSeparatorAt(p);)p++;let f=p,m=u.slice(0,r)+u.slice(f);this.delegate.applyMask(m,r);return}if(i.key==="Backspace"&&r>n){if(e.isSeparatorAt(r-1)){i.preventDefault();let u=r-1;for(;u>n&&e.isSeparatorAt(u-1);)u--;if(u>n){let p=t.value,f=p.slice(0,u-1)+p.slice(r);this.delegate.applyMask(f,u-1)}else this.delegate.applyMask("",n)}return}if(i.key==="Delete"&&r<t.value.length){if(e.isSeparatorAt(r)){i.preventDefault();let u=r;for(;u<t.value.length&&e.isSeparatorAt(u);)u++;if(u<t.value.length){let p=t.value,f=p.slice(0,u)+p.slice(u+1);this.delegate.applyMask(f,r)}}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 U=class extends x{constructor(t,e,s){let n=R(t,e,s),r=n.wrapper,o=n.input,a=n.options,l=r?.getAttribute("data-mask")||o?.getAttribute("data-mask"),h=a.mask||l||"";typeof h=="string"&&h.includes("|")&&(h=h.split("|").map(y=>y.trim()));let c=a.placeholderChar||r?.getAttribute("data-mask-placeholder")||o?.getAttribute("data-mask-placeholder")||"_",u=r?.hasAttribute("data-disabled")||o?.hasAttribute("data-disabled"),p=r?.getAttribute("data-mask-strict")||o?.getAttribute("data-mask-strict"),f=r?.getAttribute("data-mask-auto-lowercase")==="true"||o?.getAttribute("data-mask-auto-lowercase")==="true",m=r?.getAttribute("data-mask-infer-inputmode")??o?.getAttribute("data-mask-infer-inputmode"),g=a.inferInputMode??(m!==null?m!=="false":!0),{disabled:b,...v}=a,w=b!==void 0?b:u?!0:!h||Array.isArray(h)&&h.length===0,E={...v,mask:h,placeholderChar:c,strict:a.strict??(p!==null?p!=="false":!0),autoLowercase:a.autoLowercase??f??!1,disabled:w,resetHistoryOnMaskChange:a.resetHistoryOnMaskChange??!1,inferInputMode:g,onInput:a.onInput||a.oninput,onChange:a.onChange||a.onchange,onComplete:a.onComplete||a.oncomplete};super(r,o,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 D,this.engine=new P(this.options.mask||"",{placeholderChar:this.options.placeholderChar,tokens:this.options.tokens,strict:this.options.strict,autoLowercase:this.options.autoLowercase}),this.syncInferredInputMode(),this.keyboard=new V({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(),n=!!this.input.getAttribute("aria-placeholder")?.trim();return!e&&!s&&!n&&!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 P.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,n=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(""),n&&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),n&&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 n=e.includes("|")?e.split("|").map(r=>r.trim()):e;this.setMask(n)}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(),n=this.input.selectionStart??0,r=this.input.selectionEnd??n,o=Math.max(0,e-s.length);if(r>n){let a=this.engine.extractRaw(this.input.value.slice(n,r));o=Math.max(0,e-(s.length-a.length))}o<=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 r=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,r),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 n=this.engine.getPrefixLength(),r=this.input.selectionStart??0,o=this.input.selectionEnd??r,a=this.input.value,l=this.engine.getEditableCount(),h=this.getRawValue(),u=this.engine.getPrefix().replace(/[\s.-]+/g,"").toUpperCase(),p=s.replace(/[\s.-]+/g,"").toUpperCase(),f=u.length>0&&p.startsWith(u),m=a.slice(0,Math.max(n,r)).replace(/[\s.-]+/g,"").toUpperCase(),g=m.length>=2&&p.startsWith(m),b=Math.max(n,r),v=Math.max(n,o);(f||g)&&(b=0,v=a.length);let w=Math.max(0,l-h.length);if(b!==v){let T=this.engine.extractRaw(a.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===a.length?(E=s,y=s.length):(E=a.slice(0,b)+s+a.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(),n=s.length>t.length?s.substring(t.length):"";this.ghost.textContent="";let r=document.createElement("span");r.className="mask-ghost-typed",r.textContent=t;let o=document.createElement("span");o.className="mask-ghost-remaining",o.textContent=n,this.ghost.appendChild(r),this.ghost.appendChild(o),this.ghost.scrollLeft=this.input.scrollLeft}applyMask(t,e,s=!1){if(this.options.disabled||this.isApplyingMask)return;this.isApplyingMask=!0;let n="",r=!1;try{n=this.engine.format(t);let o=this.engine.getRemainingMask(n);this.input.value=n,this.lastInternalRemainingMask=o,this.wrapper.setAttribute("data-mask",o),this.updateGhost(n);let a=this.engine.getPrefixLength(),l;if(s||this.isUndoingRedoing)l=Math.max(a,Math.min(e,n.length));else{let h=this.engine.mapCursorPosition(t,e,n);l=Math.max(a,h)}this.input.setSelectionRange(l,l),r=this.isComplete(),this.wrapper.classList.toggle("is-complete",r),!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 n=this.options.disabled?s:this.getRawValue(),r=this.options.disabled?0:this.engine.getEditableCount(),o=this.isComplete(),a={value:s,rawValue:n,isComplete:o,totalSlots:r,filledSlots:this.options.disabled?s.length:n.length},l=this.options.onInput||this.options.oninput;l&&l(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;o&&(c&&c(a),this.input.dispatchEvent(new CustomEvent("mask:complete",{bubbles:!0,detail:a})))}}finally{this.isNotifying=!1}}}};var B=class d{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,n=t.indexOf(s);n===-1&&(n=t.search(/[,.]/));let r="",o=null,a=!1;return n!==-1?(r=t.substring(0,n).replace(/\D/g,""),this.options.decimals>0&&(a=!0,o=t.substring(n+1).replace(/\D/g,"").slice(0,this.options.decimals))):r=t.replace(/\D/g,""),r.length>1&&(r=r.replace(/^0+/,"")||"0"),{isNegative:e,integerPart:r,decimalPart:o,hasDecimal:a}}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),n=s.replace(/\D/g,"").length,r=this.options.decimals>0&&/[,.]/.test(s),{isNegative:o,integerPart:a,decimalPart:l,hasDecimal:h}=this.parse(i),c=l,u=h;if(e&&this.options.decimals>0&&(a||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))),o&&!a&&!c&&!u&&this.options.allowNegative){let S="-",H=1;return this.options.currency&&(this.options.currencyPosition==="prefix"?(S=`${this.options.currency} -`,H=S.length):(S=`- ${this.options.currency}`,H=1)),{formatted:S,rawNumber:null,rawValue:"-",cursor:H,isValid:!0}}if(!a&&!c&&!u)return{formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0};let f=(a||"0").replace(/\B(?=(\d{3})+(?!\d))/g,this.options.thousandSeparator);u&&this.options.decimals>0&&(f+=this.options.decimalSeparator+(c??"")),o&&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=(o?"-":"")+(a||"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 S=w;S<m.length;S++){let H=m[S];if(H===this.options.currency.trim()[0]&&this.options.currencyPosition==="suffix")break;if(/\d/.test(H)?(E++,T=S+1):H===this.options.decimalSeparator&&(y=!0,T=S+1),r){if(y&&E>=n){w=S+1;break}}else if(E>=n){w=S+1;break}}n>0&&E<n&&T>w&&(w=T);let k=this.options.currency&&this.options.currencyPosition==="prefix"?this.options.currency.length+1:0,st=this.options.currency&&this.options.currencyPosition==="suffix"?Math.max(0,m.length-this.options.currency.length-1):m.length;return w=Math.max(k,Math.min(w,Math.max(k,st))),{formatted:m,rawNumber:b,rawValue:g,cursor:w,isValid:v}}static format(i,t={}){let e=new d(t),s=typeof i=="number"?i.toString():i;return e.format(s).formatted}escapeRegExp(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}};var Z=class extends x{constructor(t,e,s){let n=R(t,e,s),r=n.wrapper,o=n.input,a=n.options,l=r?.getAttribute("data-mask-pad-decimals")==="true"||o?.getAttribute("data-mask-pad-decimals")==="true",h=o?.getAttribute("data-mask-align")||o?.getAttribute("data-align")||r?.getAttribute("data-mask-align")||r?.getAttribute("data-align"),c={align:a.align??h??"right",padDecimalsOnBlur:a.padDecimalsOnBlur??l??!1,...a};super(r,o,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 D,this.engine=new B(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 B.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 n=this.input.value,r=n[e-1];if(r===this.engine.options.thousandSeparator||r===" "){t.preventDefault();let o=Math.max(0,e-2),a=n.slice(0,o)+n.slice(e);this.applyAmount(a,o);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 n=this.input.value,r=n[e];if(r===this.engine.options.thousandSeparator||r===" "){t.preventDefault();let o=n.slice(0,e)+n.slice(e+2);this.applyAmount(o,e);return}if(this.options.currency&&this.options.currencyPosition==="suffix"){let o=n.length-this.options.currency.length-1;if(e>=o){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,n=this.options.currency;if(n){if(this.options.currencyPosition==="prefix"){let r=n.length+1;t<r&&this.input.setSelectionRange(r,r)}else if(this.options.currencyPosition==="suffix"){let r=Math.max(0,s.length-n.length-1);t>r&&this.input.setSelectionRange(r,r)}}}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 Y=class Y{constructor(i={}){this.defaultDomain=null;this.defaultTld="__";this.domains=i.domains&&i.domains.length>0?i.domains:Y.DEFAULT_DOMAINS,this.tlds=i.tlds&&i.tlds.length>0?i.tlds.map(t=>t.trim().replace(/^\./,"")).filter(Boolean):[...Y.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):[...Y.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 n=s.toLowerCase();return this.domains.filter(r=>r.toLowerCase().startsWith(n)&&r.toLowerCase()!==n)}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("@"),n=e.substring(0,s),r=e.substring(s+1);if(e.indexOf("@",s+1)!==-1)return{full:e,remaining:"",matchedDomain:null,isHintOnly:!1};let o=this.getMatchingDomains(i);if(o.length>0){let f=(t%o.length+o.length)%o.length,m=o[f],g=r.toLowerCase(),b=m.substring(g.length);return{full:`${n}@${m}`,remaining:b,matchedDomain:m,isHintOnly:!1}}if(r.length===0||r.startsWith("."))return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let a=r.toLowerCase();if(this.domains.some(f=>f.toLowerCase()===a))return{full:i,remaining:"",matchedDomain:r,isHintOnly:!1};let l=r.lastIndexOf(".");if(l===-1){if(!this.defaultTld)return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let f=this.defaultTld.includes("_"),m=`.${this.defaultTld}`,g=`${r}.${this.defaultTld}`;return{full:f?i:`${n}@${g}`,remaining:m,matchedDomain:f?null:g,isHintOnly:f}}let h=r.substring(0,l),c=r.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 f=`${h}.${this.defaultTld}`;return{full:`${n}@${f}`,remaining:this.defaultTld,matchedDomain:f,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(),p=this.getMatchingTlds(c);if(p.length>0){let f=(t%p.length+p.length)%p.length,m=p[f],g=m.substring(u.length),b=`${h}.${m}`;return{full:`${n}@${b}`,remaining:g,matchedDomain:b,isHintOnly:!1}}if(this.defaultTld&&this.defaultTld.includes("_")&&c.length<this.defaultTld.length){let f=this.defaultTld.substring(c.length);if(f.includes("_"))return{full:i,remaining:f,matchedDomain:null,isHintOnly:!0}}return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1}}};Y.DEFAULT_DOMAINS=["gmail.com","outlook.com","orange.fr","free.fr","sfr.fr","yahoo.com","hotmail.com","icloud.com","laposte.net","proton.me"],Y.DEFAULT_TLDS=["com","fr","net","org","eu","io","co","info","biz","me","tv","fi","be","ch","ca","uk","de","es","it"];var z=Y;var J=class extends x{constructor(t,e,s){let n=R(t,e,s),r=n.wrapper,o=n.input,a=n.options,l=r?.getAttribute("data-mask-cycle-suggestions")==="true"||o?.getAttribute("data-mask-cycle-suggestions")==="true",h=r?.getAttribute("data-mask-auto-lowercase")==="true"||o?.getAttribute("data-mask-auto-lowercase")==="true",c=r?.getAttribute("data-mask-aria-autocomplete")??o?.getAttribute("data-mask-aria-autocomplete"),u=a.setAriaAutocomplete??(c!==null?c!=="false":!0),p=r?.getAttribute("data-mask-tlds")??o?.getAttribute("data-mask-tlds"),f=a.tlds??(p?p.split(",").map(v=>v.trim()).filter(Boolean):void 0),m=r?.getAttribute("data-mask-default-tld")??o?.getAttribute("data-mask-default-tld"),g=a.defaultTld!==void 0?a.defaultTld:m!==null?m==="false"||m==="none"?null:m==="true"?!0:m:void 0,b={completeOnTab:!0,completeOnArrowRight:!0,completeOnEnter:!0,cycleSuggestions:a.cycleSuggestions??l??!1,autoLowercase:a.autoLowercase??h??!1,setAriaAutocomplete:u,...a,...f!==void 0?{tlds:f}:{},...g!==void 0?{defaultTld:g}:{}};super(r,o,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 z(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 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 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,n=(this.input.selectionStart??0)===this.input.value.length,r=this.input.value.length>0;if(this.options.cycleSuggestions&&e&&r&&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"&&e&&r&&this.options.completeOnTab){t.preventDefault(),this.acceptSuggestion();return}if(t.key==="Enter"&&e&&r&&this.options.completeOnEnter){t.preventDefault(),this.acceptSuggestion();return}if(t.key==="ArrowRight"&&e&&r&&n&&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 kt={BaseInputMask:x,InputMask:U,MaskEngine:P,MaskHistory:D,MaskKeyboard:V,AmountEngine:B,InputAmountMask:Z,EmailEngine:z,InputEmailMask:J};if(typeof window<"u"){let d=window,i=d.Wulf||{};d.Wulf=i,i.Mask=kt}var ut=U;var pt={};$(pt,{LocalizedComponent:()=>A,Scroll:()=>St,ScrollBlock:()=>K,createI18nManager:()=>O,default:()=>Ot,scrollEn:()=>dt,scrollFr:()=>ct,scrollI18n:()=>tt});var A=class extends C{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 at(d){return d.trim().toLowerCase().replace(/_/g,"-")}function Dt(d){let i=d.indexOf("-");return i>0?d.slice(0,i):null}function Q(d,i){if(!i)return d;for(let t of Object.keys(i))i[t]!==void 0&&(d[t]=i[t]);return d}function O(d,i){let t=at(d),e={};for(let[a,l]of Object.entries(i))e[at(a)]={...l};let s=t,n={...e},r={};function o(){let a=[],l=n[s];l&&a.push(l);let h=Dt(s);return h&&n[h]&&a.push(n[h]),a}return{setLocale(a){a&&a.trim()&&(s=at(a))},getLocale(){return s},registerLocale(a,l){if(!a||!a.trim()||!l)return;let h=at(a);n[h]=Q({...n[h]||{}},l)},setI18n(a){a&&(r=Q({...r},a))},t(a,l){if(l&&l[a]!==void 0)return String(l[a]);if(r[a]!==void 0)return String(r[a]);for(let c of o())if(c[a]!==void 0)return String(c[a]);let h=n[t]||e[t];return h&&h[a]!==void 0?String(h[a]):String(a)},getAll(a){let l={},h=n[t]||e[t];Q(l,h);let c=o().reverse();for(let u of c)Q(l,u);return Q(l,r),Q(l,a),l},reset(){s=t,r={},n={};for(let[a,l]of Object.entries(e))n[a]={...l}}}}var ct={viewport:"Zone de contenu d\xE9filable",verticalThumb:"D\xE9filement vertical",horizontalThumb:"D\xE9filement horizontal"};var dt={viewport:"Scrollable content area",verticalThumb:"Vertical scroll",horizontalThumb:"Horizontal scroll"};var tt=O("fr",{fr:ct,en:dt});var Et=0,K=class extends A{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||(Et+=1,this.viewport.id=`wulf-scrollblock-vp-${Et}`,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",n=>{n.preventDefault(),n.stopPropagation(),this.isDragging=!0,this.dragAxis=s,this.dragPointerId=n.pointerId,this.dragStartPos=s==="y"?n.clientY:n.clientX,this.dragStartScroll=s==="y"?this.viewport.scrollTop:this.viewport.scrollLeft,e.setPointerCapture(n.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",n=>{if(n.target===e)return;n.preventDefault();let r=t.getBoundingClientRect(),o=s==="y"?n.clientY-r.top:n.clientX-r.left,a=s==="y"?r.height:r.width,l=s==="y"?this.viewport.clientHeight:this.viewport.clientWidth,h=s==="y"?this.viewport.scrollHeight:this.viewport.scrollWidth,u=o/a*(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,n=e?this.trackY:this.trackX,r=e?this.thumbY:this.thumbX;if(!n||!r)return;let o=e?n.clientHeight:n.clientWidth,a=e?r.clientHeight:r.clientWidth,l=e?this.viewport.clientHeight:this.viewport.clientWidth,c=(e?this.viewport.scrollHeight:this.viewport.scrollWidth)-l,u=o-a;if(u<=0||c<=0)return;let p=c/u,f=this.dragStartScroll+s*p;e?this.viewport.scrollTop=Math.max(0,Math.min(c,f)):this.viewport.scrollLeft=Math.max(0,Math.min(c,f))}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:n,clientHeight:r,clientWidth:o}=this.viewport,a=Math.max(0,s-r),l=Math.max(0,n-o),h=a>0?t/a:0,c=l>0?e/l:0;this.options.onScroll({top:t,left:e,maxTop:a,maxLeft:l,progressY:Math.round(h*100),progressX:Math.round(c*100)});let u=this.options.edgeThreshold;if(a>0){let p=t>=a-u,f=t<=u;p&&!this.atBottom&&this.options.onTotalScroll("bottom"),f&&!this.atTop&&this.options.onTotalScrollBack("top"),this.atBottom=p,this.atTop=f}if(l>0){let p=e>=l-u,f=e<=u;p&&!this.atRight&&this.options.onTotalScroll("right"),f&&!this.atLeft&&this.options.onTotalScrollBack("left"),this.atRight=p,this.atLeft=f}this.options.autoHide&&!this.options.alwaysVisible&&(this.root.classList.add("is-scrolling"),this.scheduleAutoHide())}syncThumbs(){let{scrollTop:t,scrollLeft:e,scrollHeight:s,scrollWidth:n,clientHeight:r,clientWidth:o}=this.viewport;if(this.thumbY&&this.trackY){let a=s-r,l=this.trackY.clientHeight,h=this.thumbY.clientHeight,c=l-h;if(a>0&&c>0){let u=t/a,p=Math.max(0,Math.min(c,u*c));this.thumbY.style.transform=`translate3d(0, ${p}px, 0)`,this.thumbY.setAttribute("aria-valuenow",String(Math.round(u*100)))}}if(this.thumbX&&this.trackX){let a=n-o,l=this.trackX.clientWidth,h=this.thumbX.clientWidth,c=l-h;if(a>0&&c>0){let u=e/a,p=Math.max(0,Math.min(c,u*c));this.thumbX.style.transform=`translate3d(${p}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:n}=this.viewport,r=t>e,o=s>n;if(this.root.classList.toggle("has-scroll-y",r),this.root.classList.toggle("has-scroll-x",o),r||o?this.viewport.setAttribute("tabindex","0"):this.viewport.removeAttribute("tabindex"),this.trackY&&this.thumbY&&r){let a=this.trackY.clientHeight,l=Math.max(this.options.minThumbSize,a*(e/t));this.thumbY.style.height=`${l}px`}if(this.trackX&&this.thumbX&&o){let a=this.trackX.clientWidth,l=Math.max(this.options.minThumbSize,a*(n/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,n=typeof t=="object"&&t!==null&&!(t instanceof HTMLElement)?t.smooth:void 0,o=(e?.smooth??n??!0)&&!s?"smooth":"auto",a=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=a;break;case"left":c=0;break;case"right":c=l;break;default:{if(/^-?\d+(\.\d+)?%$/.test(t.trim())){let p=Math.max(0,Math.min(100,parseFloat(t.trim())))/100;this.options.axis==="x"?c=l*p:this.options.axis==="both"?(h=a*p,c=l*p):h=a*p;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(a,h)):void 0,left:c!==void 0?Math.max(0,Math.min(l,c)):void 0,behavior:o})}audit(){let t=[],e=this.checkAriaIdReferences(this.viewport,"aria-labelledby",t),s=this.checkAriaIdReferences(this.root,"aria-labelledby",t),n=e||s,r=this.root.getAttribute("aria-label")?.trim(),o=!this.wasAriaLabelInferred&&!!this.viewport.getAttribute("aria-label")?.trim();return!this.hasExplicitAriaLabel&&!o&&!r&&!n&&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")}};K._i18n=tt,K.i18n=tt;var St={ScrollBlock:K,i18n:tt};var Ot=K;if(typeof window<"u"){let d=window,i=d.Wulf||{};d.Wulf=i,i.Scroll=St}var gt={};$(gt,{LayoutEngine:()=>G,LocalizedComponent:()=>A,Masonry:()=>F,createI18nManager:()=>O,default:()=>Ht,masonryEn:()=>ft,masonryFr:()=>mt,masonryI18n:()=>et});var G=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 n=i.querySelector(e);if(n){let o=n.getBoundingClientRect().width;if(o>0)return o}let r=parseFloat(e);if(!isNaN(r)&&r>0)return e.endsWith("%")?i.getBoundingClientRect().width*r/100:r}if(e instanceof HTMLElement){let n=e.getBoundingClientRect().width;if(n>0)return n}if(t){let n=t.getBoundingClientRect().width;if(n>0)return n}let s=i.getBoundingClientRect().width;return s>0?s:200}static getItemSpan(i,t,e,s){let n=i.getAttribute("data-masonry-span")||i.dataset.masonrySpan;if(n){let o=parseInt(n,10);if(!isNaN(o)&&o>0)return Math.min(s,o)}let r=i.className.match(/(?:^|\s)(?:span|col-span)-(\d+)(?:\s|$)/);if(r&&r[1]){let o=parseInt(r[1],10);if(!isNaN(o)&&o>0)return Math.min(s,o)}return 1}static calculate(i,t,e){let n=i.getBoundingClientRect().width,{x:r,y:o}=this.parseGutter(e.gutter);if(n<=0||t.length===0)return{cols:1,colWidth:n,gutterX:r,gutterY:o,containerHeight:0,containerWidth:n,positions:[]};let a=t[0]||null,l=this.resolveColumnWidth(i,a,e.columnWidth),h=Math.floor((n+r)/(l+r));h=Math.max(1,h),!e.columnWidth&&h>1&&(l=(n-(h-1)*r)/h);let c=e.fitWidth?h*l+(h-1)*r:void 0,u=new Array(h).fill(0),p=[],f=t.map(v=>{let w=v.getBoundingClientRect().height;return w>0?w:50}),m=0;for(let v=0;v<t.length;v++){let w=t[v],E=f[v],y=this.getItemSpan(w,l,r,h),T=0,k=0;if(e.horizontalOrder){m+y>h&&(m=0),T=m;let M=0;for(let L=0;L<y;L++)u[T+L]>M&&(M=u[T+L]);k=M,m=(T+y)%h}else if(y===1){let M=u[0];T=0;for(let L=1;L<h;L++)u[L]<M&&(M=u[L],T=L);k=M}else{let M=1/0;T=0;for(let L=0;L<=h-y;L++){let rt=0;for(let ot=0;ot<y;ot++)u[L+ot]>rt&&(rt=u[L+ot]);rt<M&&(M=rt,T=L)}k=M}let st=y*l+(y-1)*r,S=T*(l+r);p.push({element:w,x:S,y:k,width:st,height:E,column:T,span:y});let H=k+E+o;for(let M=0;M<y;M++)u[T+M]=H}let g=0;for(let v=0;v<h;v++)u[v]>g&&(g=u[v]);let b=Math.max(0,g>0?g-o:0);return{cols:h,colWidth:l,gutterX:r,gutterY:o,containerHeight:b,containerWidth:n,fittedWidth:c,positions:p}}};var mt={gallery:"Galerie en grille asym\xE9trique"};var ft={gallery:"Masonry grid gallery"};var et=O("fr",{fr:mt,en:ft});var F=class extends A{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 n=document.querySelector(t);if(!n)throw new Error(`[Wulf.Masonry] Conteneur introuvable pour le s\xE9lecteur : "${t}"`);this.root=n}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 n=s.contentRect.width;Math.abs(n-t)>=1&&(t=n,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 n=()=>{this.pendingImageListeners=this.pendingImageListeners.filter(r=>r.handler!==n),this.isDestroyed||this.scheduleLayout()};this.pendingImageListeners.push({img:e,handler:n}),e.addEventListener("load",n,{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=G.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 n=0;n<t.positions.length;n++){let r=t.positions[n],o=r.element;if(s){let a=Number((r.width/t.containerWidth*100).toFixed(4));o.style.setProperty("--wulf-masonry-w",`${a}%`)}else o.style.setProperty("--wulf-masonry-w",`${r.width}px`);o.style.setProperty("--wulf-masonry-x",`${r.x}px`),o.style.setProperty("--wulf-masonry-y",`${r.y}px`),e>0?o.style.transitionDelay=`${n*e}ms`:o.style.removeProperty("transition-delay"),o.classList.remove("wulf-masonry-item--hidden"),this.options.onItemPlaced(o,r)}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 n of e)n.classList.add("wulf-masonry-item","wulf-masonry-item--hidden"),s.appendChild(n);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,n=document.createDocumentFragment();for(let r of e)r.classList.add("wulf-masonry-item","wulf-masonry-item--hidden"),n.appendChild(r);this.root.insertBefore(n,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 r of e)r.classList.add("wulf-masonry-item--hidden");let s=typeof this.options.transitionDuration=="number"?this.options.transitionDuration:300;if(s<=0){for(let r of e)r.parentElement===this.root&&(this.itemResizeObserver&&this.itemResizeObserver.unobserve(r),this.root.removeChild(r));this.reloadItems(),this.layout();return}let n=window.setTimeout(()=>{if(this.removeTimers.delete(n),!this.isDestroyed){for(let r of e)r.parentElement===this.root&&(this.itemResizeObserver&&this.itemResizeObserver.unobserve(r),this.root.removeChild(r));this.reloadItems(),this.layout()}},s);this.removeTimers.add(n)}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 n=Array.from(this.root.querySelectorAll("img")).filter(r=>!r.hasAttribute("alt")&&r.getAttribute("aria-hidden")!=="true");return n.length>0&&t.push(`${n.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=[]}}};F._i18n=et,F.i18n=et;var Ht=F;if(typeof window<"u"){let d=window,i=d.Wulf||{};d.Wulf=i,i.Masonry=Object.assign(F,{Masonry:F,LayoutEngine:G,i18n:et})}var yt={};$(yt,{LocalizedComponent:()=>A,Toast:()=>N,ToastInstance:()=>nt,ToastManager:()=>it,createI18nManager:()=>O,default:()=>Pt,toastEn:()=>vt,toastFr:()=>bt,toastI18n:()=>q});var bt={closeButton:"Fermer la notification"};var vt={closeButton:"Close notification"};var q=O("fr",{fr:bt,en:vt});var Rt=1,nt=class extends C{constructor(t,e){super();this._isClosed=!1;this.timerId=null;this.remainingTime=0;this.timerStartTime=0;this.isPaused=!1;this.id=`wulf-toast-${Rt++}`,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 n=this.options.duration===void 0?4e3:this.options.duration;typeof n=="number"&&n>0&&n<5e3&&t.push(`Dur\xE9e d'affichage trop courte (duration: ${n}ms) : pr\xE9voyez au moins 5000ms ou duration: false pour laisser le temps de lecture aux utilisateurs (WCAG 2.2.1).`);let r=this.options.closable??!0;return(n===!1||typeof n=="number"&&n<=0)&&!r&&!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 r=document.createElement("span");r.className=`wulf-toast-icon ${this.options.icon.trim()}`,r.setAttribute("aria-hidden","true"),t.appendChild(r)}let s=document.createElement("div");if(s.className="wulf-toast-content",this.options.title&&this.options.title.trim()!==""){let r=document.createElement("div");r.className="wulf-toast-title",this.appendTextWithLineBreaks(r,this.options.title),s.appendChild(r)}if(this.options.message&&this.options.message.trim()!==""){let r=document.createElement("div");r.className="wulf-toast-message",this.appendTextWithLineBreaks(r,this.options.message),s.appendChild(r)}if(t.appendChild(s),this.options.closable??!0){let r=document.createElement("button");r.type="button",r.className="wulf-toast-close",r.setAttribute("aria-label",q.t("closeButton",this.options.i18n)),r.setAttribute("tabindex","0");let o=document.createElement("span");o.className="wulf-toast-close-icon",o.setAttribute("aria-hidden","true"),o.textContent="\xD7",r.appendChild(o),r.addEventListener("click",a=>{a.stopPropagation(),this.close("close-button")}),t.appendChild(r)}return t}appendTextWithLineBreaks(t,e){e.split(/\r\n|\r|\n/).forEach((n,r)=>{r>0&&t.appendChild(document.createElement("br")),t.appendChild(document.createTextNode(n))})}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 n=()=>{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)n();else if(e)window.setTimeout(n,90);else{let o=!1,a=null,l=()=>{o||(o=!0,a!==null&&(window.clearTimeout(a),a=null),this.element.removeEventListener("animationend",l),this.element.removeEventListener("transitionend",l),n())};this.element.addEventListener("animationend",l,{once:!0}),this.element.addEventListener("transitionend",l,{once:!0}),a=window.setTimeout(l,300)}}))}};var X=class X{constructor(){this.containers=new Map;this.activeToasts=new Map;this.replaceTokens=new Map;this.pendingReplacements=new Set}static getInstance(){return X.instance||(X.instance=new X),X.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 n=[...e],r=(this.replaceTokens.get(t)||0)+1;this.replaceTokens.set(t,r),this.pendingReplacements.add(t);let o=n.map(a=>a.close("replace",!0));Promise.all(o).then(()=>{this.pendingReplacements.delete(t),this.replaceTokens.get(t)===r&&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 n=e.length-s+1,r=e.splice(0,n);for(let o of r)o.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(n){console.error("[Wulf.Toast] Erreur dans le callback onOpen:",n)}i.startTimer()}remove(i,t){let e=i.options.position||"top-right",s=this.activeToasts.get(e);if(s){let n=s.indexOf(i);if(n!==-1&&s.splice(n,1),s.length===0&&!this.pendingReplacements.has(e)){let r=this.containers.get(e);r&&(!r.firstChild||r.children.length===0)&&(r.parentNode&&r.parentNode.removeChild(r),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 n of s)t.push(n.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}};X.instance=null;var it=X;var N=class extends A{audit(){return[]}getAuditPrefix(){return"Wulf.Toast"}getAuditTargetLabel(){return"Toast"}static show(i={}){let t=it.getInstance(),e=new nt(i,(s,n)=>{t.remove(s,n)});return t.add(e),e}static clearAll(i){return it.getInstance().clearAll(i)}};N._i18n=q,N.i18n=q;var Pt=N;if(typeof window<"u"){let d=window,i=d.Wulf||{};d.Wulf=i,i.Toast=Object.assign(N,{Toast:N,i18n:q})}var wt={};$(wt,{FocusTrap:()=>W,default:()=>W});var Bt=["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(","),_=[],W=class extends C{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)}"]`)),n=s.find(r=>r.checked);return n?t===n:t===s[0]}return!0}getFocusableElements(){return Array.from(this.element.querySelectorAll(Bt)).filter(e=>this.isFocusable(e))}activate(){if(this.active)return this;let t=_[_.length-1];return t&&t.pause(),this.active=!0,this.paused=!1,_.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=_.indexOf(this);t!==-1&&_.splice(t,1);let e=_[_.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 r=this.element.getAttribute("aria-label")?.trim(),o=this.checkAriaIdReferences(this.element,"aria-labelledby",t);return!r&&!o&&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],n=e[e.length-1],r=document.activeElement;!t.shiftKey&&(r===n||!this.element.contains(r))?(t.preventDefault(),s.focus()):t.shiftKey&&(r===s||!this.element.contains(r))&&(t.preventDefault(),n.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 d=window,i=d.Wulf||{};d.Wulf=i,i.FocusTrap=Object.assign(W,{FocusTrap:W})}var Tt={};$(Tt,{ShortcutFormatter:()=>I,ShortcutManager:()=>j,default:()=>j});var I=class d{static isApple(){if(typeof navigator>"u")return!1;let i=navigator.userAgentData;if(i&&typeof i.platform=="string"){let s=i.platform.toLowerCase();if(s.includes("mac")||s.includes("ios"))return!0}let t=(navigator.platform||"").toLowerCase();if(t.includes("mac")||t.includes("iphone")||t.includes("ipad")||t.includes("ipod"))return!0;let e=(navigator.userAgent||"").toLowerCase();return e.includes("macintosh")||e.includes("mac os x")||e.includes("ipad")||e.includes("iphone")}static normalizeKeyName(i){let t=i.trim().toLowerCase();switch(t){case"esc":return"escape";case"return":return"enter";case"space":case"spacebar":return" ";case"del":return"delete";case"ins":return"insert";case"up":return"arrowup";case"down":return"arrowdown";case"left":return"arrowleft";case"right":return"arrowright";default:return t}}static parseCombo(i,t=d.isApple()){let e=i.trim();if(!e)return[];let s=e.split(/\s+/),n=[];for(let r of s){let o=[],a="";for(let f=0;f<r.length;f++){let m=r[f];m==="+"?a===""&&o.length>0?o.push("+"):a!==""&&(o.push(a),a=""):a+=m}a!==""&&o.push(a);let l=!1,h=!1,c=!1,u=!1,p="";for(let f of o){let m=f.trim().toLowerCase();m==="ctrl"||m==="control"?l=!0:m==="alt"||m==="option"||m==="opt"?h=!0:m==="shift"||m==="maj"?c=!0:m==="cmd"||m==="command"||m==="meta"||m==="win"||m==="super"?u=!0:m==="mod"||m==="$mod"?t?u=!0:l=!0:p=d.normalizeKeyName(f)}n.push({ctrl:l,alt:h,shift:c,meta:u,key:p})}return n}static format(i,t=d.isApple()){let e=d.parseCombo(i,t);return e.length===0?i:e.map(n=>{let r=[];if(t){n.ctrl&&r.push("\u2303"),n.alt&&r.push("\u2325"),n.shift&&r.push("\u21E7"),n.meta&&r.push("\u2318");let o=d.formatKeyDisplay(n.key,!0);return r.push(o),r.join("")}else{n.ctrl&&r.push("Ctrl"),n.alt&&r.push("Alt"),n.shift&&r.push("Shift"),n.meta&&r.push("Win");let o=d.formatKeyDisplay(n.key,!1);return r.push(o),r.join("+")}}).join(" ")}static toAriaKeyShortcuts(i,t=d.isApple()){return d.parseCombo(i,t).map(s=>{let n=[];return s.ctrl&&n.push("Control"),s.alt&&n.push("Alt"),s.shift&&n.push("Shift"),s.meta&&n.push("Meta"),n.push(d.formatKeyDisplay(s.key,!1)),n.join("+")}).join(" ")}static formatKeyDisplay(i,t){if(!i)return"";switch(i.toLowerCase()){case"escape":return t?"\u238B":"Esc";case"enter":return t?"\u21A9":"Enter";case" ":return t?"\u2423":"Space";case"tab":return t?"\u21E5":"Tab";case"backspace":return t?"\u232B":"Backspace";case"delete":return t?"\u2326":"Suppr";case"arrowup":return"\u2191";case"arrowdown":return"\u2193";case"arrowleft":return"\u2190";case"arrowright":return"\u2192";default:return i.length===1?i.toUpperCase():i.charAt(0).toUpperCase()+i.slice(1)}}};var j=class d{constructor(i){this.shortcuts=new Map;this.scopeStack=[];this.sequenceBuffer=[];this.sequenceTimer=null;this.isListening=!0;this.boundListener=null;this.idCounter=0;this.options={defaultScope:i?.defaultScope||"global",sequenceTimeout:i?.sequenceTimeout??800,target:i?.target||(typeof window<"u"?window:{}),onError:i?.onError},this.scopeStack=[this.options.defaultScope],this.initListener()}static isEditable(i){if(!i||typeof i.tagName!="string")return!1;let t=i,e=t.tagName.toUpperCase();if(e==="INPUT"){let n=t.type?.toLowerCase()||"text";return!["button","checkbox","radio","submit","reset","range","color","file","image"].includes(n)}if(e==="TEXTAREA"||e==="SELECT"||t.isContentEditable||t.getAttribute("contenteditable")==="true"||t.getAttribute("contenteditable")==="plaintext-only")return!0;let s=t.getAttribute("role");return s==="textbox"||s==="searchbox"}bind(i){let t=Array.isArray(i)?i:[i],e=[];for(let s of t){if(!s.combo||typeof s.handler!="function")continue;let n=`wulf_shortcut_${++this.idCounter}`,r=I.parseCombo(s.combo),o=r.length>1,a=I.format(s.combo),l={...s,id:n,scope:s.scope||"global",category:s.category||"G\xE9n\xE9ral",allowInEditable:s.allowInEditable??!1,preventDefault:s.preventDefault??!0,stopPropagation:s.stopPropagation??!0,priority:s.priority??0,formattedCombo:a,normalizedSteps:r,isSequence:o};this.shortcuts.set(n,l),e.push(n)}return()=>{for(let s of e)this.shortcuts.delete(s)}}unbind(i,t){let e=I.format(i);for(let[s,n]of this.shortcuts.entries())(n.formattedCombo===e||n.combo.trim().toLowerCase()===i.trim().toLowerCase())&&(!t||n.scope===t)&&this.shortcuts.delete(s)}pushScope(i){i&&typeof i=="string"&&(this.scopeStack.push(i),this.clearSequenceBuffer())}popScope(i){if(this.scopeStack.length<=1)return this.scopeStack[0];if(i){if(this.getScope()===i){let e=this.scopeStack.pop();return this.clearSequenceBuffer(),e}return}let t=this.scopeStack.pop();return this.clearSequenceBuffer(),t}setScope(i){this.scopeStack=[i||this.options.defaultScope],this.clearSequenceBuffer()}getScope(){return this.scopeStack[this.scopeStack.length-1]||this.options.defaultScope}getScopeStack(){return[...this.scopeStack]}pause(){this.isListening=!1,this.clearSequenceBuffer()}resume(){this.isListening=!0}isActive(){return this.isListening}getRegistry(i){let t=[];for(let e of this.shortcuts.values())(!i||e.scope===i||e.scope==="*")&&t.push({...e});return t}attachAria(i,t){if(i&&typeof i.setAttribute=="function"){let e=I.toAriaKeyShortcuts(t);i.setAttribute("aria-keyshortcuts",e)}}static format(i,t){return I.format(i,t)}destroy(){this.pause(),this.removeListener(),this.shortcuts.clear(),this.scopeStack=[],this.clearSequenceBuffer()}initListener(){if(typeof window>"u"||!this.options.target)return;this.boundListener=t=>this.handleKeyDown(t);let i=this.options.target;typeof i.addEventListener=="function"&&i.addEventListener("keydown",this.boundListener,!1)}removeListener(){if(this.boundListener&&this.options.target){let i=this.options.target;typeof i.removeEventListener=="function"&&i.removeEventListener("keydown",this.boundListener,!1),this.boundListener=null}}handleKeyDown(i){if(!this.isListening)return;let t=(i.key||"").toLowerCase();if(["control","alt","shift","meta"].includes(t))return;let e=this.getScope(),s=d.isEditable(i.target),n={ctrl:i.ctrlKey,alt:i.altKey,shift:i.shiftKey,meta:i.metaKey,key:I.normalizeKeyName(i.key||"")},r=Date.now();if(this.sequenceBuffer.length>0){let c=this.sequenceBuffer[this.sequenceBuffer.length-1];r-c.timestamp>this.options.sequenceTimeout&&this.clearSequenceBuffer()}let o=this.getActiveShortcuts(e,s),a=[...this.sequenceBuffer.map(c=>c.step),n],l=this.findMatchingSequence(o,a);if(l){this.clearSequenceBuffer(),this.executeShortcut(l,i,e,!0);return}if(this.isPrefixOfAnySequence(o,a)){this.sequenceBuffer.push({step:n,timestamp:r}),this.resetSequenceTimer(),i.key.length===1&&!i.ctrlKey&&!i.altKey&&!i.metaKey&&!s&&i.preventDefault();return}this.clearSequenceBuffer();let h=this.findMatchingChord(o,n,i);h&&this.executeShortcut(h,i,e,!1)}getActiveShortcuts(i,t){let e=[];for(let s of this.shortcuts.values())s.scope!==i&&s.scope!=="*"||t&&!s.allowInEditable||e.push(s);return e.sort((s,n)=>(n.priority??0)-(s.priority??0))}stepMatches(i,t,e){return i.ctrl!==t.ctrl||i.alt!==t.alt||i.meta!==t.meta||!(i.key===t.key||e&&i.key===e.key.toLowerCase())?!1:!!(i.shift===t.shift||!i.shift&&t.shift&&e&&e.key===i.key)}findMatchingChord(i,t,e){for(let s of i){if(s.isSequence||s.normalizedSteps.length!==1)continue;let n=s.normalizedSteps[0];if(this.stepMatches(n,t,e))return s}return null}findMatchingSequence(i,t){for(let e of i){if(!e.isSequence||e.normalizedSteps.length!==t.length)continue;let s=!0;for(let n=0;n<t.length;n++)if(!this.stepMatches(e.normalizedSteps[n],t[n])){s=!1;break}if(s)return e}return null}isPrefixOfAnySequence(i,t){for(let e of i){if(!e.isSequence||e.normalizedSteps.length<=t.length)continue;let s=!0;for(let n=0;n<t.length;n++)if(!this.stepMatches(e.normalizedSteps[n],t[n])){s=!1;break}if(s)return!0}return!1}executeShortcut(i,t,e,s){i.preventDefault&&t.preventDefault(),i.stopPropagation&&t.stopPropagation();let n={combo:i.combo,formattedCombo:i.formattedCombo,scope:e,target:t.target,isSequence:s};try{i.handler(t,n)}catch(r){this.options.onError?this.options.onError(r instanceof Error?r:new Error(String(r)),i.combo):console.error(`[Wulf.Shortcut] Erreur lors de l'ex\xE9cution du raccourci "${i.combo}":`,r)}}resetSequenceTimer(){this.sequenceTimer&&clearTimeout(this.sequenceTimer),this.sequenceTimer=setTimeout(()=>{this.clearSequenceBuffer()},this.options.sequenceTimeout)}clearSequenceBuffer(){this.sequenceBuffer=[],this.sequenceTimer&&(clearTimeout(this.sequenceTimer),this.sequenceTimer=null)}};return Ct(Ft);})();
|
|
5
|
-
if (typeof window !== "undefined") {
|
|
4
|
+
(${this.getAuditDisableHint()})`),e}checkAriaIdReferences(t,e,i){let s=t.getAttribute(e)?.trim();if(!s)return!1;let n=t.ownerDocument||document,o=typeof t.getRootNode=="function"?t.getRootNode():n,r=s.split(/\s+/).filter(Boolean),a=r.length>0&&r.every(l=>!!(typeof ShadowRoot<"u"&&o instanceof ShadowRoot?o.getElementById(l):n.getElementById(l)));return a||i.push(`Attribut ${e}="${s}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`),a}};var vt=new Set(["left","right","center"]);function $(u,t,e){return t&&typeof t=="object"&&"tagName"in t&&t.tagName==="INPUT"?{wrapper:u||null,input:t,options:e||{}}:{wrapper:null,input:u,options:t&&typeof t=="object"&&!("tagName"in t)?t:{}}}var O=class extends N{wrapper;input;options;ghost=null;isWrapperCreated=!1;wasWrapperFallbackStyled=!1;wasAlignSet=!1;hadInitialDataAlign=!1;isDestroyed=!1;isFocused=!1;isDispatchingNativeInput=!1;lastTrackedValue="";nativeValueDescriptor=null;onCutHandler=()=>{};onFormResetHandler;mutationObserver=null;focusSelectTimerId=null;abortController=new AbortController;constructor(t,e,i){super();let{wrapper:s,input:n,options:o}=$(t,e,i);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",a=!!(o.createWrapper??r),l=s;if(!l&&a){let M=this.input.ownerDocument||document,v=M.createElement("span");v.className="wulf-mask-wrapper",this.input.parentNode&&this.input.parentNode.insertBefore(v,this.input),it(v,this.input,null);let k=M.defaultView||(typeof window<"u"?window:null);(!v.isConnected||!k||k.getComputedStyle(v).display!=="inline-grid")&&(v.style.display="inline-grid",v.style.gridTemplateColumns="1fr",v.style.gridTemplateRows="1fr",v.style.verticalAlign="middle",v.style.boxSizing="border-box",v.style.position="relative",this.input.style.gridArea="1 / 1 / 2 / 2",this.input.style.boxSizing="border-box",this.wasWrapperFallbackStyled=!0),l=v,this.isWrapperCreated=!0}if(!l)throw new Error(`[${new.target.name||"InputMask"}] wrapper (HTMLElement) et input (HTMLInputElement) sont requis, ou activez l'option createWrapper: true.`);this.wrapper=l,this.normalizeInputType();let d=this.getAttr("data-mask-focus-only")==="true",c=this.hasAttr("data-disabled"),h=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"),m=f&&vt.has(f)?f:null;this.hadInitialDataAlign=this.wrapper.hasAttribute("data-align");let g=this.getAttr("data-mask-audit"),{disabled:b,align:I,...y}=o,E=I&&vt.has(I)?I:void 0,T=b!==void 0?b:!!c,A=o.audit??(g!==null?g!=="false":!0),w=this.isPasswordInput();this.options={...y,createWrapper:a,showMaskOnFocus:o.showMaskOnFocus??d??!1,selectAllOnFocus:o.selectAllOnFocus??h??!1,copyRaw:w?!1:o.copyRaw??p??!1,disabled:T,align:E??(m||void 0),emitNativeInput:o.emitNativeInput??!0,audit:A},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(){let{signal:t}=this.abortController;this.input.addEventListener("copy",this.onBaseCopy,{signal:t}),this.input.addEventListener("focus",this.onBaseFocus,{signal:t}),this.input.addEventListener("blur",this.onBaseBlur,{signal:t})}onBaseCopy=t=>{if(!this.options.copyRaw||this.options.disabled||this.input.type==="password")return;let e=this.input.selectionStart??0,i=this.input.selectionEnd??e,s="";e!==i?s=this.extractRawSnippet(this.input.value.slice(e,i)):s=this.getRawValue(),s&&t.clipboardData&&(t.preventDefault(),t.clipboardData.setData("text/plain",s))};extractRawSnippet(t){return t}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))};onBaseBlur=()=>{this.isFocused=!1,this.isPasswordInput()&&(this.lastTrackedValue="",this.clearGhost(),this.wrapper.removeAttribute("data-mask"))};initMutationObserver(){if(typeof MutationObserver>"u")return;this.mutationObserver=new MutationObserver(e=>{for(let i of e)i.type==="attributes"&&i.attributeName&&this.handleAttributeMutation(i.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","type"]};this.mutationObserver.observe(this.wrapper,t),this.input!==this.wrapper&&this.mutationObserver.observe(this.input,t)}isPasswordInput(){return(this.input.type||"").toLowerCase()==="password"}computePasswordDigest(t){let e=2166136261;for(let i=0;i<t.length;i++)e^=t.charCodeAt(i),e=Math.imul(e,16777619);return`__pwd:${(e>>>0).toString(36)}:${t.length}`}setAlign(t){let e=t&&vt.has(t)?t:null,i=e||void 0,s=this.wrapper.getAttribute("data-align"),n=e?this.wrapper.classList.contains(`align-${e}`):!this.wrapper.classList.contains("align-left")&&!this.wrapper.classList.contains("align-right")&&!this.wrapper.classList.contains("align-center");this.options.align===i&&s===e&&n||(this.options.align=i,this.wrapper.classList.remove("align-left","align-right","align-center"),e?(this.wrapper.classList.add(`align-${e}`),this.wasAlignSet=!0,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(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.isPasswordInput()?!1:this.getAttr("data-mask-copy-raw")==="true";else if(t==="type")this.isPasswordInput()&&(this.options.copyRaw=!1,this.lastTrackedValue="",this.clearGhost(),this.wrapper.removeAttribute("data-mask"),this.onPasswordModeDetected());else if(t==="data-mask-align"||t==="data-align"){let e=this.getAttr("data-mask-align")||this.getAttr("data-align"),i=e&&vt.has(e)?e:null;i!==(this.options.align??null)&&this.setAlign(i)}}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();let e=this.input.ownerDocument||document;this.ghost=e.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");let i=e.defaultView||(typeof window<"u"?window:null);(!this.wrapper.isConnected||!i||i.getComputedStyle(this.ghost).pointerEvents!=="none")&&(this.ghost.style.gridArea="1 / 1 / 2 / 2",this.ghost.style.pointerEvents="none"),this.syncGhostStyles()}setGhostContent(...t){if(this.ghost){if(typeof this.ghost.replaceChildren=="function")this.ghost.replaceChildren(...t);else{this.ghost.textContent="";for(let e of t)this.ghost.appendChild(typeof e=="string"?document.createTextNode(e):e)}this.wrapper.classList.toggle("has-visible-ghost",t.length>0)}}clearGhost(){this.setGhostContent()}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",i=t.textAlign;i==="right"?this.ghost.style.justifyContent="right":i==="left"?this.ghost.style.justifyContent="left":i==="center"?this.ghost.style.justifyContent="center":i==="end"?this.ghost.style.justifyContent=e?"left":"right":this.ghost.style.justifyContent=e?"right":"left"}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;!this.isPasswordInput()&&t&&typeof t.setValue=="function"&&t.setValue(this.lastTrackedValue),this.lastTrackedValue=this.isPasswordInput()?"":this.input.value,this.input.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))}finally{this.isDispatchingNativeInput=!1}}}onScroll=()=>{this.ghost&&(this.ghost.scrollLeft=this.input.scrollLeft)};hookValueProperty(){try{let t=HTMLInputElement.prototype,e=Object.getOwnPropertyDescriptor(t,"value");if(!e||!e.set||!e.get)return;this.nativeValueDescriptor=e;let i=this;Object.defineProperty(this.input,"value",{get(){return e.get.call(this)},set(s){let n=String(s??"");e.set.call(this,n),!i.isDestroyed&&i.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,i=typeof this.input.getRootNode=="function"?this.input.getRootNode():e,s=typeof ShadowRoot<"u"&&i instanceof ShadowRoot?i:e,n=this.input.getAttribute("aria-label")?.trim(),o=this.checkAriaIdReferences(this.input,"aria-labelledby",t),r=!!this.input.closest("label"),a=!!(this.input.labels&&this.input.labels.length>0),l=!1;if(this.input.id)try{l=!!s.querySelector(`label[for="${ct(this.input.id)}"]`)}catch{l=!1}!n&&!o&&!r&&!a&&!l&&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 d=this.getSpecificAuditWarnings();return t.push(...d),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[]}onPasswordModeDetected(){}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.focusSelectTimerId!==null&&(clearTimeout(this.focusSelectTimerId),this.focusSelectTimerId=null),this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),this.abortController.abort(),this.lastTrackedValue="",this.unhookValueProperty(),this.ghost&&(this.ghost.remove(),this.ghost=null),this.isWrapperCreated&&this.wrapper?(this.wasWrapperFallbackStyled&&(this.input.style.gridArea="",this.input.style.boxSizing=""),this.wrapper.parentElement?it(this.wrapper.parentElement,this.input,this.wrapper):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.wasAlignSet&&!this.hadInitialDataAlign&&this.wrapper.removeAttribute("data-align"),this.wasAlignSet&&this.wrapper.classList.remove("align-left","align-right","align-center"),this.wrapper.classList.remove("is-complete","is-focused","mask-focus-only","has-selection","has-ghost","has-visible-ghost")))}};var Jt={9:{pattern:/[0-9]/},a:{pattern:/[a-zA-Z]/},A:{pattern:/[a-zA-Z]/,transform:u=>u.toUpperCase()},"*":{pattern:/[a-zA-Z0-9]/},"#":{pattern:/[a-zA-Z0-9]/,transform:u=>u.toUpperCase()}},G=class u{pattern;patterns=[];subEngines=[];activeEngine=null;placeholderChar;tokens;slots=[];fullMaskTemplate="";prefixSlotsCount=0;prefixString="";strict=!0;autoLowercase=!1;constructor(t,e={}){let i=e||{},s=String(i.placeholderChar||"_");this.placeholderChar=Array.from(s)[0]||"_";let n=Object.create(null);for(let[o,r]of Object.entries(Jt))n[o]=r;if(i.tokens&&typeof i.tokens=="object")for(let[o,r]of Object.entries(i.tokens))o!=="__proto__"&&o!=="constructor"&&o!=="prototype"&&r&&(n[o]=r);this.tokens=n,this.strict=i.strict!==!1,this.autoLowercase=i.autoLowercase??!1,this.pattern="",this.compile(t)}static format(t,e,i={}){return!e||Array.isArray(e)&&e.length===0?t??"":new u(e,i||{}).format(t??"")}compile(t){if(t!==void 0&&(Array.isArray(t)?(this.patterns=t.slice(0,32).map(s=>String(s??"").slice(0,512)),this.pattern=this.patterns[0]||""):(this.patterns=[],this.pattern=String(t??"").slice(0,512))),this.patterns.length>0)return this.subEngines=this.patterns.map(s=>new u(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 e="",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&&Object.hasOwn(this.tokens,n)?this.tokens[n]:void 0;r?(i=!1,this.slots.push({char:n,isStatic:!1,isPrefix:!1,token:r,placeholder:this.placeholderChar}),e+=this.placeholderChar):(this.slots.push({char:n,isStatic:!0,isPrefix:i,placeholder:n}),e+=n)}this.fullMaskTemplate=e,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(t){if(this.subEngines.length<=1)return this;let e=String(t??""),i=this.subEngines.filter(a=>{let l=a.getPrefix();return l.length>0&&e.toLowerCase().startsWith(l.trim().toLowerCase())}),s=i.length>0?i:this.subEngines,n=s.toSorted((a,l)=>l.getEditableCount()-a.getEditableCount())[0],r=(n?n.extractRaw(e):e).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(t=>t.getEditableCount())):this.activeEngine?this.activeEngine.getEditableCount():this.slots.filter(t=>!t.isStatic).length}isNumericOnly(){if(this.subEngines.length>0)return this.subEngines.every(i=>i.isNumericOnly());let e=(this.activeEngine?this.activeEngine.slots:this.slots).filter(i=>!i.isStatic);return e.length===0?!1:e.every(i=>i.char==="9"||i.token&&i.token.pattern.test("0")&&!i.token.pattern.test("a")&&!i.token.pattern.test("Z"))}setStrict(t){this.strict=t;for(let e of this.subEngines)e.setStrict(t)}setAutoLowercase(t){this.autoLowercase=t;for(let e of this.subEngines)e.setAutoLowercase(t)}isStrict(){return this.strict}extractRaw(t){if(this.subEngines.length>0){let r=this.selectEngine(t);if(r!==this)return r.extractRaw(t)}let e=Math.max(4096,this.slots.length*4),i=String(t??"").slice(0,e);if(!i)return"";let s="",n=0,o=0;if(this.prefixSlotsCount>0){for(;n<i.length&&(i[n]===" "||i[n]===" ");)n++;let r=0;for(;n<i.length&&r<this.prefixSlotsCount;){let a=this.slots[r].char,l=i[n];if(l.toUpperCase()===a.toUpperCase())n++,r++;else if(a===" "&&l!==" ")r++;else break}o=this.prefixSlotsCount}for(;n<i.length&&o<this.slots.length;){let r=this.slots[o],a=i[n];if(r.isStatic)a.toUpperCase()===r.char.toUpperCase()&&n++,o++;else if(r.token&&r.token.pattern.test(a)){let l=r.token.transform?r.token.transform(a):a;this.autoLowercase&&!r.token.transform&&(l=l.toLowerCase()),s+=l,n++,o++}else this.strict?n++:(s+=this.autoLowercase?a.toLowerCase():a,n++,o++)}if(!this.strict&&n<i.length){let r=i.slice(n);s+=this.autoLowercase?r.toLowerCase():r}return s}format(t){if(this.subEngines.length>0){let r=this.selectEngine(t);if(r!==this)return r.format(t)}let e=Math.max(4096,this.slots.length*4),i=String(t??"").slice(0,e);if(!this.slots.length)return i;let s=this.extractRaw(i);if(s.length===0)return this.prefixString;let n="",o=0;for(let r=0;r<this.slots.length;r++){let a=this.slots[r];if(a.isStatic){let l=o<s.length,d=o===0&&!!a.isPrefix,c=o>0&&o===s.length;if(l||d||c)n+=a.char;else break}else if(o<s.length){let l=s[o],d=a.token?.transform?a.token.transform(l):l;this.autoLowercase&&!a.token?.transform&&(d=d.toLowerCase()),n+=d,o++}else break}if(!this.strict&&o<s.length){let r=s.substring(o);n+=this.autoLowercase?r.toLowerCase():r}return n}getRemainingMask(t){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getRemainingMask(t):this.fullMaskTemplate?t.length>=this.fullMaskTemplate.length?t:t+this.fullMaskTemplate.substring(t.length):""}mapCursorPosition(t,e,i){if(this.activeEngine&&this.activeEngine!==this)return this.activeEngine.mapCursorPosition(t,e,i);let s=this.prefixSlotsCount,n=String(t??""),o=String(i??"");if(e<=0||!o)return s;let a=this.extractRaw(n.slice(0,e)).length;if(a===0)return Math.max(s,Math.min(this.getNextEditablePosition(0),o.length));let l=0,d=o.length;for(let c=0;c<o.length&&c<this.slots.length;c++)if(!this.slots[c].isStatic&&(l++,l===a)){d=c+1;break}for(;d<o.length&&this.slots[d]&&this.slots[d].isStatic;)d++;return Math.max(s,Math.min(d,o.length))}isSeparatorAt(t){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.isSeparatorAt(t):t>=0&&t<this.slots.length?this.slots[t].isStatic:!1}getNextEditablePosition(t){if(this.activeEngine&&this.activeEngine!==this)return this.activeEngine.getNextEditablePosition(t);let e=Math.max(0,t);for(let i=e;i<this.slots.length;i++)if(!this.slots[i].isStatic)return i;return this.slots.length}getSlotAt(t){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getSlotAt(t):this.slots[t]}getSlots(){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getSlots():this.slots}};var V=class{stack=[];index=-1;maxDepth;constructor(t=50){this.maxDepth=t}push(t,e){let i=this.getCurrent();if(i&&i.raw===t){i.cursor=e;return}this.stack=this.stack.slice(0,this.index+1),this.stack.push({raw:t,cursor:e}),this.stack.length>this.maxDepth&&this.stack.shift(),this.index=this.stack.length-1}updateCurrentCursor(t){let e=this.getCurrent();e&&(e.cursor=t)}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 Z=class{delegate;constructor(t){this.delegate=t}handleKeyDown(t){if(H(t))return;let e=this.delegate.getInput(),i=this.delegate.getEngine(),s=this.delegate.getHistory(),n=i.getPrefixLength(),o=e.selectionStart??0,r=e.selectionEnd??o;if((t.ctrlKey||t.metaKey)&&(t.key==="z"||t.key==="Z")&&!t.shiftKey){t.preventDefault(),this.delegate.undo();return}if((t.ctrlKey||t.metaKey)&&(t.key==="y"||t.key==="Y")||(t.ctrlKey||t.metaKey)&&t.shiftKey&&(t.key==="z"||t.key==="Z")){t.preventDefault(),this.delegate.redo();return}s.updateCurrentCursor(o);let a=t.key.length===1&&!t.ctrlKey&&!t.metaKey&&!t.altKey,l=r>o;if(a&&!l){let h=i.getSlots(),p=o<h.length&&h[o].isStatic&&h[o].char===t.key,f=o>0&&o-1<h.length&&h[o-1].isStatic&&h[o-1].char===t.key;if(p||f){t.preventDefault();let g=p?o:o-1,b=i.getNextEditablePosition(g+1);this.delegate.applyMask(e.value,b,!0);return}let m=-1;for(let g=o;g<h.length;g++)if(h[g].isStatic){h[g].char===t.key&&(m=g);break}if(m!==-1){t.preventDefault();let g=m-1;for(;g>=n&&!h[g].isStatic;)g--;g++;let b=m-g,I=e.value.slice(g,o);if(h.slice(g,m).every(T=>!T.token||T.token.pattern.test("0"))&&b>I.length&&I.length>0){let T=b-I.length,A="0".repeat(T)+I,w=e.value.slice(m),M=e.value.slice(0,g)+A+w,v=i.getNextEditablePosition(m+1);this.delegate.applyMask(M,v,!0);return}let E=i.getNextEditablePosition(m+1);this.delegate.applyMask(e.value,E,!0);return}}if(a&&i.isStrict()){let h=i.getEditableCount();if(h>0){let p=i.extractRaw(e.value),f=h-p.length;if(r>o){let m=i.extractRaw(e.value.slice(o,r));f=h-(p.length-m.length)}if(f<=0){t.preventDefault();return}}}if(r>o){if(t.key==="Backspace"||t.key==="Delete"){t.preventDefault();let h=e.value,p=h.slice(0,o)+h.slice(r);this.delegate.applyMask(p,Math.max(n,o));return}return}if(t.key==="ArrowLeft"&&!t.shiftKey&&o<=n){t.preventDefault(),e.setSelectionRange(n,n);return}if(t.key==="Home"&&n>0&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey&&!t.altKey){t.preventDefault(),e.setSelectionRange(n,n);return}if(t.key==="Backspace"&&o<=n){t.preventDefault(),e.setSelectionRange(n,n);return}if(t.key==="Delete"&&o<n){t.preventDefault(),e.setSelectionRange(n,n);return}if(t.key==="Backspace"&&(t.ctrlKey||t.altKey||t.metaKey)){if(t.preventDefault(),o<=n){e.setSelectionRange(n,n);return}let h=o-1;for(;h>=n&&i.isSeparatorAt(h);)h--;for(;h>=n&&!i.isSeparatorAt(h);)h--;let p=Math.max(n,h+1),f=e.value,m=f.slice(0,p)+f.slice(o);this.delegate.applyMask(m,p);return}if(t.key==="Delete"&&(t.ctrlKey||t.altKey||t.metaKey)){t.preventDefault();let h=e.value;if(o>=h.length)return;let p=o;for(;p<h.length&&i.isSeparatorAt(p);)p++;for(;p<h.length&&!i.isSeparatorAt(p);)p++;for(;p<h.length&&i.isSeparatorAt(p);)p++;let f=p,m=h.slice(0,o)+h.slice(f);this.delegate.applyMask(m,o);return}if(t.key==="Backspace"&&o>n){if(i.isSeparatorAt(o-1)){t.preventDefault();let h=o-1;for(;h>n&&i.isSeparatorAt(h-1);)h--;if(h>n){let p=e.value,f=p.slice(0,h-1)+p.slice(o);this.delegate.applyMask(f,h-1)}else this.delegate.applyMask("",n)}return}if(t.key==="Delete"&&o<e.value.length){if(i.isSeparatorAt(o)){t.preventDefault();let h=o;for(;h<e.value.length&&i.isSeparatorAt(h);)h++;if(h<e.value.length){let p=e.value,f=p.slice(0,h)+p.slice(h+1);this.delegate.applyMask(f,o)}}return}}handleKeyUp(t){let e=this.delegate.getInput(),i=this.delegate.getHistory();(t.key==="ArrowLeft"||t.key==="ArrowRight"||t.key==="Home")&&!t.shiftKey&&this.delegate.enforceMinCursor(),i.updateCurrentCursor(e.selectionStart??0)}};var st=class extends O{engine;history;keyboard;isComposing=!1;isUndoingRedoing=!1;isMouseDown=!1;isApplyingMask=!1;lastValue="";lastInternalRemainingMask="";isNotifying=!1;hasPendingNotification=!1;onChangeNativeHandler=()=>{};wasInputModeInferred=!1;cutTimerId=null;pasteTimerId=null;resetTimerId=null;constructor(t,e,i){let s=$(t,e,i),n=s.wrapper,o=s.input,r=s.options,a=n?.getAttribute("data-mask")||o?.getAttribute("data-mask"),l=r.mask||a||"";typeof l=="string"&&l.includes("|")&&(l=l.split("|").map(E=>E.trim()));let d=r.placeholderChar||n?.getAttribute("data-mask-placeholder")||o?.getAttribute("data-mask-placeholder")||"_",c=n?.hasAttribute("data-disabled")||o?.hasAttribute("data-disabled"),h=n?.getAttribute("data-mask-strict")||o?.getAttribute("data-mask-strict"),p=n?.getAttribute("data-mask-auto-lowercase")==="true"||o?.getAttribute("data-mask-auto-lowercase")==="true",f=n?.getAttribute("data-mask-infer-inputmode")??o?.getAttribute("data-mask-infer-inputmode"),m=r.inferInputMode??(f!==null?f!=="false":!0),{disabled:g,...b}=r,I=g!==void 0?g:c?!0:!l||Array.isArray(l)&&l.length===0,y={...b,mask:l,placeholderChar:d,strict:r.strict??(h!==null?h!=="false":!0),autoLowercase:r.autoLowercase??p??!1,disabled:I,resetHistoryOnMaskChange:r.resetHistoryOnMaskChange??!1,inferInputMode:m,onInput:r.onInput||r.oninput,onChange:r.onChange||r.onchange,onComplete:r.onComplete||r.oncomplete};super(n,o,y),this.history=new V,this.engine=new G(this.options.mask||"",{placeholderChar:this.options.placeholderChar,tokens:this.options.tokens,strict:this.options.strict,autoLowercase:this.options.autoLowercase}),this.syncInferredInputMode(),this.keyboard=new Z({getInput:()=>this.input,getEngine:()=>this.engine,getHistory:()=>this.history,applyMask:(E,T,A)=>this.applyMask(E,T,A),undo:()=>this.undo(),redo:()=>this.redo(),enforceMinCursor:()=>this.enforceMinCursor()}),this.bindEvents(),this.lastValue=this.isPasswordInput()?this.computePasswordDigest(this.input.value):this.input.value,this.syncInitialValue(),this.runAuditWarning(this.options.audit)}getSpecificAuditWarnings(){let t=[],e=[],i=this.checkAriaIdReferences(this.input,"aria-describedby",e),s=!!this.input.getAttribute("placeholder")?.trim(),n=!!this.input.getAttribute("aria-placeholder")?.trim();return!i&&!s&&!n&&!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)}onPasswordModeDetected(){this.history.clear(),this.lastValue="",this.lastInternalRemainingMask="",this.lastTrackedValue="",this.clearGhost(),this.wrapper.removeAttribute("data-mask")}static format(t,e,i={}){return G.format(t,e,i)}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.clearGhost(),this.checkValueChange()):this.applyMask(this.input.value,this.input.selectionStart??this.input.value.length),this.syncInferredInputMode()}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 e=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,e)}},0)},this.onChangeNativeHandler=()=>{this.isDestroyed||this.checkValueChange()};let{signal:t}=this.abortController;this.input.addEventListener("beforeinput",this.onBeforeInput,{signal:t}),this.input.addEventListener("input",this.handleInput,{signal:t}),this.input.addEventListener("keydown",this.onKeyDown,{signal:t}),this.input.addEventListener("paste",this.onPaste,{signal:t}),this.input.addEventListener("focus",this.onFocus,{signal:t}),this.input.addEventListener("blur",this.onBlur,{signal:t}),this.input.addEventListener("click",this.onClick,{signal:t}),this.input.addEventListener("keyup",this.onKeyUp,{signal:t}),this.input.addEventListener("select",this.onSelect,{signal:t}),this.input.addEventListener("mousedown",this.onMouseDown,{signal:t}),window.addEventListener("mouseup",this.onMouseUp,{signal:t}),this.input.addEventListener("compositionstart",this.onCompositionStart,{signal:t}),this.input.addEventListener("compositionend",this.onCompositionEnd,{signal:t}),this.input.addEventListener("scroll",this.onScroll,{passive:!0,signal:t}),this.input.addEventListener("cut",this.onCutHandler,{signal:t}),this.input.addEventListener("change",this.onChangeNativeHandler,{signal:t}),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,{signal:t}))}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.wasInputModeInferred&&this.input.getAttribute("inputmode")==="numeric"&&this.input.removeAttribute("inputmode"),this.history.clear(),this.lastValue="",this.lastInternalRemainingMask="",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 i=typeof e=="boolean"?e:e&&typeof e=="object"&&e.strict!==void 0?e.strict:this.options.strict,s=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=i,this.engine.setStrict(i??!0),this.engine.compile(""),s&&this.history.clear(),this.setDisabled(!0),this.syncInferredInputMode();return}this.options.mask=t,this.options.strict=i,this.engine.setStrict(i??!0),this.engine.compile(t),s&&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 i=Array.isArray(this.options.mask)?this.options.mask.join("|"):this.options.mask||"";if(e===i)return;if(e){let s=e.includes("|")?e.split("|").map(n=>n.trim()):e;this.setMask(s)}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.setAutoLowercase(this.options.autoLowercase),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,i=t!==e;this.wrapper.classList.toggle("has-selection",i)}onBeforeInput(t){if(!this.options.disabled&&!this.isComposing&&this.engine.isStrict()&&!(t.inputType==="insertFromPaste"||t.inputType==="insertReplacementText")&&t.inputType&&t.inputType.startsWith("insert")){let e=this.engine.getEditableCount();if(e>0){let i=this.getRawValue(),s=this.input.selectionStart??0,n=this.input.selectionEnd??s,o=Math.max(0,e-i.length);if(n>s){let r=this.engine.extractRaw(this.input.value.slice(s,n));o=Math.max(0,e-(i.length-r.length))}o<=0&&t.preventDefault()}}}handleInput(t){if(this.isDispatchingNativeInput||this.isComposing)return;let e=!!(this.options.onInput||this.options.oninput),i=this.isPasswordInput()?this.computePasswordDigest(this.input.value):this.input.value;if(e&&i!==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){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 i=(t.clipboardData?.getData("text")||"").slice(0,4096).trim();if(!i)return;let s=this.engine.getPrefixLength(),n=this.input.selectionStart??0,o=this.input.selectionEnd??n,r=this.input.value,a=this.engine.getEditableCount(),l=this.getRawValue(),c=this.engine.getPrefix().replace(/[\s.-]+/g,"").toUpperCase(),h=i.replace(/[\s.-]+/g,"").toUpperCase(),p=c.length>0&&h.startsWith(c),f=r.slice(0,Math.max(s,n)).replace(/[\s.-]+/g,"").toUpperCase(),m=f.length>=2&&h.startsWith(f),g=Math.max(s,n),b=Math.max(s,o);(p||m)&&(g=0,b=r.length);let I=Math.max(0,a-l.length);if(g!==b){let T=this.engine.extractRaw(r.slice(g,b));I=Math.max(0,a-(l.length-T.length))}if(this.engine.isStrict()&&I<=0)return;let y,E;g===0&&b===r.length?(y=i,E=i.length):(y=r.slice(0,g)+i+r.slice(b),E=g+i.length),this.applyMask(y,E),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(){if(this.wrapper.classList.remove("is-focused","has-selection"),this.isPasswordInput()){this.history.clear(),this.lastValue="",this.lastInternalRemainingMask="",this.lastTrackedValue="",this.clearGhost(),this.wrapper.removeAttribute("data-mask");return}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,i=this.input.selectionEnd??e;e===i&&e<t&&this.input.setSelectionRange(t,t)}updateGhost(t){if(!this.ghost)return;if(this.options.disabled||this.isPasswordInput()){this.clearGhost();return}let e=!t||t===this.engine.getPrefix();if(this.shouldHideGhostForPlaceholder(e)){this.clearGhost();return}let i=this.engine.getFullMaskTemplate(),s=i.length>t.length?i.substring(t.length):"",n=this.input.ownerDocument||document,o=n.createElement("span");o.className="mask-ghost-typed",o.textContent=t;let r=n.createElement("span");r.className="mask-ghost-remaining",r.textContent=s,this.setGhostContent(o,r),this.ghost.scrollLeft=this.input.scrollLeft}applyMask(t,e,i=!1){if(this.options.disabled||this.isApplyingMask)return;this.isApplyingMask=!0;let s="",n=!1;try{s=this.engine.format(t);let o=this.engine.getRemainingMask(s),r=this.isPasswordInput();this.input.value=s,r?(this.lastInternalRemainingMask="",this.wrapper.removeAttribute("data-mask"),this.clearGhost()):(this.lastInternalRemainingMask=o,this.wrapper.setAttribute("data-mask",o),this.updateGhost(s));let a=this.engine.getPrefixLength(),l;if(i||this.isUndoingRedoing)l=Math.max(a,Math.min(e,s.length));else{let d=this.engine.mapCursorPosition(t,e,s);l=Math.max(a,d)}this.input.setSelectionRange(l,l),n=this.isComplete(),this.wrapper.classList.toggle("is-complete",n),r?(this.options.copyRaw=!1,this.history.clear()):this.isUndoingRedoing||this.history.push(this.getRawValue(),l)}finally{this.isApplyingMask=!1}this.checkValueChange()}syncInitialValue(){let t=this.isPasswordInput();if(this.options.disabled){this.wrapper.removeAttribute("data-mask"),this.clearGhost(),this.lastValue=t?this.computePasswordDigest(this.input.value):this.input.value,this.checkValueChange();return}this.syncGhostStyles();let e=this.input.value||"";if(e)this.applyMask(e,e.length);else{let i=this.engine.getPrefixLength();if(i>0)this.applyMask("",i);else{if(t)this.lastInternalRemainingMask="",this.wrapper.removeAttribute("data-mask"),this.clearGhost();else{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){let e=this.isPasswordInput(),i=this.input.value;if(!((e?this.computePasswordDigest(i):i)===this.lastValue&&!t&&!this.hasPendingNotification)){if(this.isNotifying){this.hasPendingNotification=!0;return}this.isNotifying=!0;try{let n=0,o=10;for(;((e?this.computePasswordDigest(this.input.value):this.input.value)!==this.lastValue||this.hasPendingNotification||t)&&n<o;){n++,this.hasPendingNotification=!1,t=!1;let r=this.input.value;this.lastValue=e?this.computePasswordDigest(r):r;let a=this.options.disabled?r:this.getRawValue(),l=this.options.disabled?0:this.engine.getEditableCount(),d=this.isComplete(),c={value:r,rawValue:a,isComplete:d,totalSlots:l,filledSlots:this.options.disabled?r.length:a.length},h=this.options.onInput||this.options.oninput;h&&h(r,c),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:c})),this.dispatchNativeInput();let p=this.options.onChange||this.options.onchange;p&&p(c),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:c}));let f=this.options.onComplete||this.options.oncomplete;d&&(f&&f(c),this.input.dispatchEvent(new CustomEvent("mask:complete",{bubbles:!0,detail:c})))}}finally{this.isNotifying=!1}}}};var q=class u{options;constructor(t={}){let e=t.currency??"";!e&&t.unit&&(e=t.unit);let i=e==="$"||e==="\xA3"||e==="\xA5"?"prefix":"suffix",s=t.decimals!==void 0?Number(t.decimals):2,n=Number.isFinite(s)?Math.min(20,Math.max(0,Math.floor(s))):2;this.options={currency:String(e).slice(0,32),unit:String(t.unit??e).slice(0,32),currencyPosition:t.currencyPosition??i,decimals:n,decimalSeparator:String(t.decimalSeparator??",").slice(0,4)||",",thousandSeparator:String(t.thousandSeparator??"\xA0").slice(0,4),allowNegative:t.allowNegative??!1,min:t.min??-1/0,max:t.max??1/0}}parse(t){let e=String(t??"").slice(0,512).trim(),i=!1;this.options.allowNegative&&e.includes("-")&&(i=!0),this.options.currency&&(e=e.replace(new RegExp(this.escapeRegExp(this.options.currency),"g"),"")),this.options.thousandSeparator&&(e=e.replace(new RegExp(this.escapeRegExp(this.options.thousandSeparator),"g"),"")),e=e.replace(/[\s\u00A0]/g,"");let s=this.options.decimalSeparator,n=e.indexOf(s);n===-1&&(n=e.search(/[,.]/));let o="",r=null,a=!1;return n!==-1?(o=e.substring(0,n).replace(/\D/g,""),this.options.decimals>0&&(a=!0,r=e.substring(n+1).replace(/\D/g,"").slice(0,this.options.decimals))):o=e.replace(/\D/g,""),o.length>1&&(o=o.replace(/^0+/,"")||"0"),{isNegative:i,integerPart:o,decimalPart:r,hasDecimal:a}}format(t,e=t.length,i=!1){let s=String(t??"").slice(0,512),n=Math.max(0,Math.min(e,s.length));if(!s||s.trim()===""||s===this.options.currency.trim())return{formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0};let o=s.substring(0,n),r=o.replace(/\D/g,"").length,a=this.options.decimals>0&&/[,.]/.test(o),{isNegative:l,integerPart:d,decimalPart:c,hasDecimal:h}=this.parse(s),p=c,f=h;if(i&&this.options.decimals>0&&(d||c!==null)&&(f=!0,p===null?p="0".repeat(this.options.decimals):p.length<this.options.decimals&&(p=p+"0".repeat(this.options.decimals-p.length))),l&&!d&&!p&&!f&&this.options.allowNegative){let S="-",P=1;return this.options.currency&&(this.options.currencyPosition==="prefix"?(S=`${this.options.currency} -`,P=S.length):(S=`- ${this.options.currency}`,P=1)),{formatted:S,rawNumber:null,rawValue:"-",cursor:P,isValid:!0}}if(!d&&!p&&!f)return{formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0};let g=this.formatThousands(d||"0");f&&this.options.decimals>0&&(g+=this.options.decimalSeparator+(p??"")),l&&g!=="0"&&(g="-"+g);let b=g;this.options.currency&&(this.options.currencyPosition==="prefix"?b=`${this.options.currency} ${g}`:b=`${g} ${this.options.currency}`);let I=(l?"-":"")+(d||"0")+(c?"."+c:""),y=parseFloat(I);isNaN(y)&&(y=0);let E=y>=this.options.min&&y<=this.options.max,T=0;this.options.currency&&this.options.currencyPosition==="prefix"&&(T=this.options.currency.length+1);let A=0,w=!1,M=T;for(let S=T;S<b.length;S++){let P=b[S];if(P===this.options.currency.trim()[0]&&this.options.currencyPosition==="suffix")break;if(/\d/.test(P)?(A++,M=S+1):P===this.options.decimalSeparator&&(w=!0,M=S+1),a){if(w&&A>=r){T=S+1;break}}else if(A>=r){T=S+1;break}}r>0&&A<r&&M>T&&(T=M);let v=this.options.currency&&this.options.currencyPosition==="prefix"?this.options.currency.length+1:0,k=this.options.currency&&this.options.currencyPosition==="suffix"?Math.max(0,b.length-this.options.currency.length-1):b.length;return T=Math.max(v,Math.min(T,Math.max(v,k))),{formatted:b,rawNumber:y,rawValue:I,cursor:T,isValid:E}}static format(t,e={}){let i=new u(e),s=typeof t=="number"?t.toString():t;return i.format(s).formatted}formatThousands(t){let e=this.options.thousandSeparator;if(!e||t.length<=3)return t;let i=[],s=t.length;for(;s>0;){let n=Math.max(0,s-3);i.push(t.slice(n,s)),s=n}return i.reverse().join(e)}escapeRegExp(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}};var rt=class extends O{engine;history;isUndoingRedoing=!1;isApplying=!1;isComposing=!1;lastValue="";wasInputModeInferred=!1;cutTimerId=null;resetTimerId=null;cursorTimerId=null;constructor(t,e,i){let s=$(t,e,i),n=s.wrapper,o=s.input,r=s.options,a=n?.getAttribute("data-mask-pad-decimals")==="true"||o?.getAttribute("data-mask-pad-decimals")==="true",l=o?.getAttribute("data-mask-align")||o?.getAttribute("data-align")||n?.getAttribute("data-mask-align")||n?.getAttribute("data-align"),d={align:r.align??l??"right",padDecimalsOnBlur:r.padDecimalsOnBlur??a??!1,...r};super(n,o,d),this.input.hasAttribute("inputmode")||(this.input.inputMode="decimal",this.wasInputModeInferred=!0),this.history=new V,this.engine=new q(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:"")}onPasswordModeDetected(){this.history.clear(),this.lastValue="",this.lastTrackedValue="",this.clearGhost()}static format(t,e={}){return q.format(t,e)}onNativeValueSet(t){if(this.options.disabled||this.isComposing){this.lastValue=t;return}this.applyAmount(t,t.length)}onDisabledChange(t){t?this.clearGhost():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 e=this.input.selectionStart??this.input.value.length;this.applyAmount(this.input.value,e)},0)};let{signal:t}=this.abortController;this.input.addEventListener("input",this.handleInput,{signal:t}),this.input.addEventListener("keydown",this.handleKeyDown,{signal:t}),this.input.addEventListener("blur",this.handleBlur,{signal:t}),this.input.addEventListener("focus",this.handleFocus,{signal:t}),this.input.addEventListener("click",this.handleClick,{signal:t}),this.input.addEventListener("scroll",this.onScroll,{passive:!0,signal:t}),this.input.addEventListener("cut",this.onCutHandler,{signal:t}),this.input.addEventListener("compositionstart",this.onCompositionStart,{signal:t}),this.input.addEventListener("compositionend",this.onCompositionEnd,{signal:t}),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,{signal:t}))}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 i=this.engine.format(t,e);this.setNativeValue(i.formatted),this.input.setSelectionRange(i.cursor,i.cursor);let s=this.isPasswordInput();s?(this.options.copyRaw=!1,this.history.clear(),this.clearGhost()):(this.isUndoingRedoing||this.history.push(i.rawValue,i.cursor),this.updateGhost(i));let n=s?this.computePasswordDigest(i.formatted):i.formatted;this.lastValue!==n&&(this.lastValue=n,this.notifyChange(i))}finally{this.isApplying=!1}}}updateGhost(t){if(this.ghost){if(!t.formatted){if(this.shouldHideGhostForPlaceholder(!0)){this.clearGhost();return}let e=this.options.currency?this.options.currencyPosition==="prefix"?`${this.options.currency} 0`:`0 ${this.options.currency}`:"0,00",s=(this.input.ownerDocument||document).createElement("span");s.className="mask-ghost-remaining",s.textContent=e,this.setGhostContent(s);return}this.clearGhost(),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||H(t))){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,i=this.input.selectionEnd??0;if(e===i&&e>0){let s=this.input.value,n=s[e-1];if(n===this.engine.options.thousandSeparator||n===" "){t.preventDefault();let o=Math.max(0,e-2),r=s.slice(0,o)+s.slice(e);this.applyAmount(r,o);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,i=this.input.selectionEnd??0;if(e===i&&e<this.input.value.length){let s=this.input.value,n=s[e];if(n===this.engine.options.thousandSeparator||n===" "){t.preventDefault();let o=s.slice(0,e)+s.slice(e+2);this.applyAmount(o,e);return}if(this.options.currency&&this.options.currencyPosition==="suffix"){let o=s.length-this.options.currency.length-1;if(e>=o){t.preventDefault();return}}}}(t.key==="ArrowLeft"||t.key==="ArrowRight"||t.key==="Home"||t.key==="End")&&(this.cursorTimerId!==null&&clearTimeout(this.cursorTimerId),this.cursorTimerId=window.setTimeout(()=>{this.cursorTimerId=null,this.enforceCursorBounds()},0))}}enforceCursorBounds(){if(this.isDestroyed||!this.isFocused||document.activeElement!==this.input||!this.input.value||this.options.disabled)return;let t=this.input.selectionStart??0,e=this.input.selectionEnd??0;if(t!==e)return;let i=this.input.value,s=this.options.currency;if(s){if(this.options.currencyPosition==="prefix"){let n=s.length+1;t<n&&this.input.setSelectionRange(n,n)}else if(this.options.currencyPosition==="suffix"){let n=Math.max(0,i.length-s.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.isPasswordInput()){this.history.clear(),this.lastValue="",this.lastTrackedValue="",this.clearGhost();return}if(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.cursorTimerId!==null&&(clearTimeout(this.cursorTimerId),this.cursorTimerId=null),this.wasInputModeInferred&&this.input.getAttribute("inputmode")==="decimal"&&this.input.removeAttribute("inputmode"),this.lastValue="",this.history.clear(),super.destroy())}};var J=class u{domains;tlds;suggestOnAt;defaultDomain=null;defaultTld="__";static DEFAULT_DOMAINS=["gmail.com","outlook.com","orange.fr","free.fr","sfr.fr","yahoo.com","hotmail.com","icloud.com","laposte.net","proton.me"];static DEFAULT_TLDS=["com","fr","net","org","eu","io","co","info","biz","me","tv","fi","be","ch","ca","uk","de","es","it"];constructor(t={}){this.domains=t.domains&&t.domains.length>0?t.domains:u.DEFAULT_DOMAINS,this.tlds=t.tlds&&t.tlds.length>0?t.tlds.slice(0,200).map(e=>String(e).trim().replace(/^\./,"").slice(0,32)).filter(Boolean):[...u.DEFAULT_TLDS],this.suggestOnAt=t.suggestOnAt??!0,this.setDefaultDomain(t.defaultDomain??null),this.setDefaultTld(t.defaultTld!==void 0?t.defaultTld:"__")}setDefaultDomain(t){t===!0?this.defaultDomain=this.domains.length>0?this.domains[0]:null:typeof t=="string"&&t.trim().length>0?this.defaultDomain=t.trim().replace(/^@/,""):this.defaultDomain=null}setDefaultTld(t){t===!0?this.defaultTld=this.tlds.length>0?this.tlds[0]:null:typeof t=="string"&&t.trim().length>0?this.defaultTld=t.trim().replace(/^\./,""):this.defaultTld=null}setTlds(t){this.tlds=t&&t.length>0?t.slice(0,200).map(e=>String(e).trim().replace(/^\./,"").slice(0,32)).filter(Boolean):[...u.DEFAULT_TLDS]}getMatchingTlds(t){let e=(t??"").toLowerCase();return e.length===0?[...this.tlds]:this.tlds.filter(i=>i.toLowerCase().startsWith(e)&&i.toLowerCase()!==e)}getMatchingDomains(t){let e=String(t??"").slice(0,512);if(!e.includes("@"))return this.defaultDomain?[this.defaultDomain]:[];let i=e.indexOf("@");if(e.indexOf("@",i+1)!==-1)return[];let s=e.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(t,e=0){let i=String(t??"").slice(0,512);if(!i.includes("@"))return this.defaultDomain?{full:i?`${i}@${this.defaultDomain}`:`@${this.defaultDomain}`,remaining:`@${this.defaultDomain}`,matchedDomain:this.defaultDomain,isHintOnly:!1}:{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};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,isHintOnly:!1};let r=this.getMatchingDomains(t);if(r.length>0){let f=(e%r.length+r.length)%r.length,m=r[f],g=o.toLowerCase(),b=m.substring(g.length);return{full:`${n}@${m}`,remaining:b,matchedDomain:m,isHintOnly:!1}}if(o.length===0||o.startsWith("."))return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let a=o.toLowerCase();if(this.domains.some(f=>f.toLowerCase()===a))return{full:i,remaining:"",matchedDomain:o,isHintOnly:!1};let l=o.lastIndexOf(".");if(l===-1){if(!this.defaultTld)return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let f=this.defaultTld.includes("_"),m=`.${this.defaultTld}`,g=`${o}.${this.defaultTld}`;return{full:f?i:`${n}@${g}`,remaining:m,matchedDomain:f?null:g,isHintOnly:f}}let d=o.substring(0,l),c=o.substring(l+1);if(!d||d.endsWith("."))return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};if(c.length===0){if(this.defaultTld&&!this.defaultTld.includes("_")){let f=`${d}.${this.defaultTld}`;return{full:`${n}@${f}`,remaining:this.defaultTld,matchedDomain:f,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 h=c.toLowerCase();if(this.tlds.some(f=>f.toLowerCase()===h))return{full:i,remaining:"",matchedDomain:o,isHintOnly:!1};let p=this.getMatchingTlds(c);if(p.length>0){let f=(e%p.length+p.length)%p.length,m=p[f],g=m.substring(h.length),b=`${d}.${m}`;return{full:`${n}@${b}`,remaining:g,matchedDomain:b,isHintOnly:!1}}if(this.defaultTld&&this.defaultTld.includes("_")&&c.length<this.defaultTld.length){let f=this.defaultTld.substring(c.length);if(f.includes("_"))return{full:i,remaining:f,matchedDomain:null,isHintOnly:!0}}return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1}}};var at=class extends O{engine;currentSuggestion={full:"",remaining:"",matchedDomain:null};currentSuggestionIndex=0;wasAriaAutocompleteSet=!1;wasAutocorrectSet=!1;wasAutocapitalizeSet=!1;wasSpellcheckSet=!1;wasInputModeInferred=!1;isComposing=!1;lastNotifiedValue="";srStatusEl=null;srAnnounceTimerId=null;lastAnnouncedSuggestion="";cutTimerId=null;resetTimerId=null;constructor(t,e,i){let s=$(t,e,i),n=s.wrapper,o=s.input,r=s.options,a=n?.getAttribute("data-mask-cycle-suggestions")==="true"||o?.getAttribute("data-mask-cycle-suggestions")==="true",l=n?.getAttribute("data-mask-auto-lowercase")==="true"||o?.getAttribute("data-mask-auto-lowercase")==="true",d=n?.getAttribute("data-mask-aria-autocomplete")??o?.getAttribute("data-mask-aria-autocomplete"),c=r.setAriaAutocomplete??(d!==null?d!=="false":!0),h=n?.getAttribute("data-mask-tlds")??o?.getAttribute("data-mask-tlds"),p=r.tlds??(h?h.split(",").map(b=>b.trim()).filter(Boolean):void 0),f=n?.getAttribute("data-mask-default-tld")??o?.getAttribute("data-mask-default-tld"),m=r.defaultTld!==void 0?r.defaultTld:f!==null?f==="false"||f==="none"?null:f==="true"?!0:f:void 0,g={completeOnTab:!0,completeOnArrowRight:!0,completeOnEnter:!0,cycleSuggestions:r.cycleSuggestions??a??!1,autoLowercase:r.autoLowercase??l??!1,setAriaAutocomplete:c,...r,...p!==void 0?{tlds:p}:{},...m!==void 0?{defaultTld:m}:{}};super(n,o,g),this.input.hasAttribute("inputmode")||(this.input.inputMode="email",this.wasInputModeInferred=!0),this.input.hasAttribute("autocorrect")||(this.input.setAttribute("autocorrect","off"),this.wasAutocorrectSet=!0),this.input.hasAttribute("autocapitalize")||(this.input.setAttribute("autocapitalize","none"),this.wasAutocapitalizeSet=!0),this.input.hasAttribute("spellcheck")||(this.input.setAttribute("spellcheck","false"),this.wasSpellcheckSet=!0),this.options.setAriaAutocomplete&&!this.input.hasAttribute("aria-autocomplete")&&(this.input.setAttribute("aria-autocomplete","inline"),this.wasAriaAutocompleteSet=!0),this.engine=new J(this.options),this.lastNotifiedValue=this.isPasswordInput()?"":this.input.value,this.bindEvents(),!this.options.disabled&&!this.isPasswordInput()&&this.updateSuggestion(),this.runAuditWarning(this.options.audit)}onPasswordModeDetected(){this.srAnnounceTimerId!==null&&(clearTimeout(this.srAnnounceTimerId),this.srAnnounceTimerId=null),this.lastNotifiedValue="",this.lastTrackedValue="",this.lastAnnouncedSuggestion="",this.currentSuggestion={full:"",remaining:"",matchedDomain:null},this.srStatusEl&&(this.srStatusEl.textContent=""),this.clearGhost()}onNativeValueSet(t){this.options.disabled||this.isComposing||this.isPasswordInput()||this.updateSuggestion()}onDisabledChange(t){t||this.isPasswordInput()?this.clearGhost():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.isPasswordInput())&&this.updateSuggestion()},0)};let{signal:t}=this.abortController;this.input.addEventListener("input",this.handleInput,{signal:t}),this.input.addEventListener("keydown",this.handleKeyDown,{signal:t}),this.input.addEventListener("blur",this.handleBlur,{signal:t}),this.input.addEventListener("focus",this.handleFocus,{signal:t}),this.input.addEventListener("scroll",this.onScroll,{passive:!0,signal:t}),this.input.addEventListener("cut",this.onCutHandler,{signal:t}),this.input.addEventListener("compositionstart",()=>{this.isComposing=!0},{signal:t}),this.input.addEventListener("compositionend",()=>{this.isComposing=!1,!this.isDestroyed&&!this.options.disabled&&!this.isPasswordInput()&&this.handleInput()},{signal:t}),this.input.form&&(this.onFormResetHandler=()=>{this.resetTimerId!==null&&clearTimeout(this.resetTimerId),this.resetTimerId=window.setTimeout(()=>{this.resetTimerId=null,!(this.isDestroyed||this.options.disabled||this.isPasswordInput())&&this.updateSuggestion()},0)},this.input.form.addEventListener("reset",this.onFormResetHandler,{signal:t}))}ensureSrStatusEl(){if(this.srStatusEl&&this.wrapper.contains(this.srStatusEl))return this.srStatusEl;let t=this.input.ownerDocument||(typeof document<"u"?document:null);if(!t)return null;let e=t.createElement("span");return e.className="wulf-mask-sr-status",e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),this.wrapper.appendChild(e),this.srStatusEl=e,e}scheduleSuggestionAnnouncement(t=!1){if(this.srAnnounceTimerId!==null&&(clearTimeout(this.srAnnounceTimerId),this.srAnnounceTimerId=null),!this.options.setAriaAutocomplete||!this.isFocused||this.isDestroyed||this.isPasswordInput())return;let e=this.currentSuggestion;if(!e.remaining||e.isHintOnly){this.lastAnnouncedSuggestion="",this.srStatusEl&&(this.srStatusEl.textContent="");return}let i=e.full;if(i===this.lastAnnouncedSuggestion&&!t)return;let s=()=>{if(this.srAnnounceTimerId=null,this.isDestroyed||!this.isFocused||this.isPasswordInput())return;this.lastAnnouncedSuggestion=i;let o=this.input.ownerDocument||(typeof document<"u"?document:null);if(o&&typeof o.ariaNotify=="function")try{o.ariaNotify(i,{priority:"normal"});return}catch{}let r=this.ensureSrStatusEl();r&&(r.textContent=r.textContent===i?`${i}\xA0`:i)};t?s():this.srAnnounceTimerId=window.setTimeout(s,250)}updateSuggestion(t){if(this.options.disabled||this.isPasswordInput()){this.currentSuggestion={full:"",remaining:"",matchedDomain:null},this.clearGhost();return}let e=this.input.value;if(this.currentSuggestion=this.engine.getSuggestion(e,this.currentSuggestionIndex),!this.ghost)return;if(this.shouldHideGhostForPlaceholder(e.length===0))this.clearGhost();else if(this.currentSuggestion.remaining){let s=this.input.ownerDocument||document,n=s.createElement("span");n.className="mask-ghost-typed",n.textContent=e;let o=s.createElement("span");o.className="mask-ghost-remaining",o.textContent=this.currentSuggestion.remaining,this.setGhostContent(n,o)}else this.clearGhost();this.ghost.scrollLeft=this.input.scrollLeft,t?.announce&&this.scheduleSuggestionAnnouncement(!!t.immediate);let i=this.getDetail();this.options.onInput&&this.options.onInput(i),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:i})),e!==this.lastNotifiedValue&&(this.lastNotifiedValue=e,this.dispatchNativeInput())}handleInput(t){if(!this.isDispatchingNativeInput&&!(this.options.disabled||this.isPasswordInput())&&!(this.isComposing||t&&"isComposing"in t&&t.isComposing)){if(this.options.autoLowercase){let e=this.input.selectionStart??0,i=this.input.selectionEnd??e,s=this.input.value.toLowerCase();s!==this.input.value&&(this.setNativeValue(s),this.input.setSelectionRange(e,i))}this.currentSuggestionIndex=0,this.updateSuggestion({announce:!0,immediate:!1})}}handleKeyDown(t){if(this.options.disabled||this.isPasswordInput()||H(t)||t.shiftKey||t.ctrlKey||t.altKey||t.metaKey)return;let e=!!this.currentSuggestion.remaining&&!this.currentSuggestion.isHintOnly,s=(this.input.selectionStart??0)===this.input.value.length,n=this.input.value.length>0;if(this.options.cycleSuggestions&&e&&n&&s){if(t.key==="ArrowDown"){t.preventDefault(),this.currentSuggestionIndex++,this.updateSuggestion({announce:!0,immediate:!0});return}if(t.key==="ArrowUp"){t.preventDefault(),this.currentSuggestionIndex--,this.updateSuggestion({announce:!0,immediate:!0});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&&s&&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(){if(this.wrapper.classList.remove("is-focused"),this.srAnnounceTimerId!==null&&(clearTimeout(this.srAnnounceTimerId),this.srAnnounceTimerId=null),this.lastAnnouncedSuggestion="",this.srStatusEl&&(this.srStatusEl.textContent=""),this.isPasswordInput()){this.lastNotifiedValue="",this.lastTrackedValue="",this.clearGhost();return}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(i=>i.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.srAnnounceTimerId!==null&&(clearTimeout(this.srAnnounceTimerId),this.srAnnounceTimerId=null),this.srStatusEl&&(this.srStatusEl.remove(),this.srStatusEl=null),this.lastNotifiedValue="",this.lastAnnouncedSuggestion="",this.wasInputModeInferred&&this.input.getAttribute("inputmode")==="email"&&this.input.removeAttribute("inputmode"),this.wasAriaAutocompleteSet&&this.input.getAttribute("aria-autocomplete")==="inline"&&this.input.removeAttribute("aria-autocomplete"),this.wasAutocorrectSet&&this.input.getAttribute("autocorrect")==="off"&&this.input.removeAttribute("autocorrect"),this.wasAutocapitalizeSet&&this.input.getAttribute("autocapitalize")==="none"&&this.input.removeAttribute("autocapitalize"),this.wasSpellcheckSet&&this.input.getAttribute("spellcheck")==="false"&&this.input.removeAttribute("spellcheck"),super.destroy())}};var Ft={BaseInputMask:O,InputMask:st,MaskEngine:G,MaskHistory:V,MaskKeyboard:Z,AmountEngine:q,InputAmountMask:rt,EmailEngine:J,InputEmailMask:at},Nt=R();Nt&&(Nt.Mask=Ft);var St=st;var It={};et(It,{LocalizedComponent:()=>x,Scroll:()=>zt,ScrollBlock:()=>Q,createI18nManager:()=>z,default:()=>ee,scrollEn:()=>kt,scrollFr:()=>Et,scrollI18n:()=>lt});var x=class extends N{static _i18n;static setLocale(t){this._i18n&&this._i18n.setLocale(t)}static getLocale(){return this._i18n?this._i18n.getLocale():""}static registerLocale(t,e){this._i18n&&this._i18n.registerLocale(t,e)}static setI18n(t){this._i18n&&this._i18n.setI18n(t)}static getI18n(){return this._i18n?this._i18n.getAll():{}}static resetI18n(){this._i18n&&this._i18n.reset()}static t(t,e){return this._i18n?this._i18n.t(t,e):String(t)}i18nOverrides;constructor(t){super(),this.i18nOverrides=t}t(t){let e=this.constructor;return e._i18n?e._i18n.t(t,this.i18nOverrides):String(t)}};var Qt=new Set(["__proto__","constructor","prototype"]);function dt(u){return!!u&&!Qt.has(u)}function yt(u){let t=String(u??"").trim().toLowerCase().replace(/_/g,"-");return dt(t)?t:""}function te(u){let t=u.indexOf("-"),e=t>0?u.slice(0,t):null;return e&&dt(e)?e:null}function F(u,t){if(!t||typeof t!="object")return u;for(let e of Object.keys(t))dt(String(e))&&Object.hasOwn(t,e)&&t[e]!==void 0&&(u[e]=t[e]);return u}function z(u,t){let e=yt(u)||"fr",i=Object.create(null);for(let[a,l]of Object.entries(t)){let d=yt(a);d&&(i[d]=F(Object.create(null),l))}let s=e,n=Object.create(null);for(let[a,l]of Object.entries(i))n[a]=F(Object.create(null),l);let o=Object.create(null);function r(){let a=[];if(dt(s)){let d=n[s];d&&a.push(d)}let l=te(s);return l&&n[l]&&a.push(n[l]),a}return{setLocale(a){if(a&&typeof a=="string"&&a.trim()){let l=yt(a);l&&(s=l)}},getLocale(){return s},registerLocale(a,l){if(!a||typeof a!="string"||!a.trim()||!l)return;let d=yt(a);if(!d)return;let c=F(Object.create(null),n[d]);n[d]=F(c,l)},setI18n(a){if(!a||typeof a!="object")return;let l=F(Object.create(null),o);o=F(l,a)},t(a,l){if(!dt(String(a)))return"";if(l&&typeof l=="object"&&Object.hasOwn(l,a)&&l[a]!==void 0)return String(l[a]);if(o[a]!==void 0)return String(o[a]);for(let c of r())if(c[a]!==void 0)return String(c[a]);let d=n[e]||i[e];return d&&d[a]!==void 0?String(d[a]):String(a)},getAll(a){let l={},d=n[e]||i[e];F(l,d);let c=r().reverse();for(let h of c)F(l,h);return F(l,o),F(l,a),l},reset(){s=e,o=Object.create(null),n=Object.create(null);for(let[a,l]of Object.entries(i))n[a]=F(Object.create(null),l)}}}var Et={viewport:"Zone de contenu d\xE9filable",verticalThumb:"D\xE9filement vertical",horizontalThumb:"D\xE9filement horizontal"};var kt={viewport:"Scrollable content area",verticalThumb:"Vertical scroll",horizontalThumb:"Horizontal scroll"};var lt=z("fr",{fr:Et,en:kt});var Bt=0,Q=class extends x{static _i18n=lt;static i18n=lt;root;viewport;options;createdViewport=!1;isDestroyed=!1;wasIdGenerated=!1;wasRoleInferred=!1;wasAriaLabelInferred=!1;hasExplicitAriaLabel=!1;hasRootAriaLabel=!1;propagatedRootLabel=null;lastInferredAriaLabel="";trackY;thumbY;trackX;thumbX;resizeObserver;hideTimer;scrollEndFallbackTimer;rafId=null;resizeRafId=null;abortController=new AbortController;dragAbortController;activeScrollToController;supportsScrollEnd=typeof window<"u"&&"onscrollend"in window;cachedMaxTop=0;cachedMaxLeft=0;cachedTrackHeight=0;cachedThumbHeight=0;cachedTrackWidth=0;cachedThumbWidth=0;isDragging=!1;dragAxis;dragPointerId;dragStartPos=0;dragStartScroll=0;atBottom=!1;atTop=!0;atRight=!1;atLeft=!0;boundOnScroll;boundOnScrollEnd;boundOnMouseEnter;boundOnMouseLeave;boundOnFocusIn;boundOnFocusOut;boundPointerMove;boundPointerUp;constructor(t,e){super(e?.i18n);let i=null;if(typeof t=="string")try{i=document.querySelector(t)}catch{i=null}else i=t;if(!i||!(i instanceof HTMLElement))throw new Error(`[ScrollBlock] \xC9l\xE9ment introuvable : "${t}".`);this.root=i,this.hasExplicitAriaLabel=!!(e?.ariaLabel||e?.i18n?.viewport);let s=e?.autoHideDelay,n=typeof s=="number"&&Number.isFinite(s)&&s>=0?s:1e3,o=e?.minThumbSize,r=typeof o=="number"&&Number.isFinite(o)&&o>0?o:24,a=e?.edgeThreshold,l=typeof a=="number"&&Number.isFinite(a)&&a>=0?a:10;this.options={axis:e?.axis||"y",mode:e?.mode||"custom",autoHide:e?.autoHide??!0,autoHideDelay:n,alwaysVisible:e?.alwaysVisible??!1,ariaLabel:e?.ariaLabel||this.t("viewport"),i18n:e?.i18n||{},minThumbSize:r,edgeThreshold:l,onScroll:e?.onScroll||(()=>{}),onScrollEnd:e?.onScrollEnd||(()=>{}),onTotalScroll:e?.onTotalScroll||(()=>{}),onTotalScrollBack:e?.onTotalScrollBack||(()=>{}),audit:e?.audit??!0},this.boundOnScroll=this.handleScroll.bind(this),this.boundOnScrollEnd=this.handleScrollEnd.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.mode==="native"&&this.root.classList.add("wulf-scrollblock--native"),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=Array.from(this.root.childNodes),i=document.createElement("div");i.className="wulf-scrollblock-viewport",this.root.appendChild(i);for(let s of e)it(i,s,null);return this.createdViewport=!0,i}setupAccessibility(){this.viewport.id||(Bt+=1,this.viewport.id=`wulf-scrollblock-vp-${Bt}`,this.wasIdGenerated=!0),this.viewport.hasAttribute("role")||(this.viewport.setAttribute("role","region"),this.wasRoleInferred=!0);let t=this.root.getAttribute("aria-labelledby")?.trim(),e=this.root.getAttribute("aria-label")?.trim();if(t?(this.hasRootAriaLabel=!0,!this.hasExplicitAriaLabel&&!this.viewport.hasAttribute("aria-labelledby")&&!this.viewport.hasAttribute("aria-label")&&(this.viewport.setAttribute("aria-labelledby",t),this.propagatedRootLabel="aria-labelledby")):e&&(this.hasRootAriaLabel=!0,!this.hasExplicitAriaLabel&&!this.viewport.hasAttribute("aria-label")&&!this.viewport.hasAttribute("aria-labelledby")&&(this.viewport.setAttribute("aria-label",e),this.propagatedRootLabel="aria-label")),this.hasExplicitAriaLabel&&!this.viewport.hasAttribute("aria-label"))this.viewport.setAttribute("aria-label",this.options.ariaLabel),this.lastInferredAriaLabel=this.options.ariaLabel,this.wasAriaLabelInferred=!0;else if(!this.viewport.hasAttribute("aria-label")&&!this.viewport.hasAttribute("aria-labelledby")){let i=this.t("viewport");this.viewport.setAttribute("aria-label",i),this.lastInferredAriaLabel=i,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.mode!=="native"&&((this.options.axis==="y"||this.options.axis==="both")&&(this.trackY=document.createElement("div"),this.trackY.className="wulf-scrollblock-track wulf-scrollblock-vertical",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.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")))}isRtl(){return typeof window<"u"&&window.getComputedStyle(this.viewport).direction==="rtl"}attachTrackListeners(t,e,i){let{signal:s}=this.abortController;e.addEventListener("pointerdown",n=>{if(n.button!==0)return;n.preventDefault(),n.stopPropagation(),this.dragAbortController?.abort(),this.dragAbortController=new AbortController;let o=this.dragAbortController.signal;this.isDragging=!0,this.dragAxis=i,this.dragPointerId=n.pointerId,this.dragStartPos=i==="y"?n.clientY:n.clientX,this.dragStartScroll=i==="y"?this.viewport.scrollTop:this.viewport.scrollLeft;try{e.setPointerCapture(n.pointerId)}catch{}e.classList.add("is-active"),this.root.classList.add("is-dragging"),window.addEventListener("pointermove",this.boundPointerMove,{signal:o}),window.addEventListener("pointerup",this.boundPointerUp,{signal:o}),window.addEventListener("pointercancel",this.boundPointerUp,{signal:o}),e.addEventListener("lostpointercapture",this.boundPointerUp,{signal:o})},{signal:s}),e.addEventListener("keydown",n=>{if(n.ctrlKey||n.altKey||n.metaKey)return;let o=40,r=i==="y"?Math.max(o,Math.round(this.viewport.clientHeight*.9)):Math.max(o,Math.round(this.viewport.clientWidth*.9)),a=i==="y"?this.cachedMaxTop:this.cachedMaxLeft;if(a<=0)return;let l=i==="x"&&this.isRtl(),d=i==="y"?this.viewport.scrollTop:this.viewport.scrollLeft,c=null;if(i==="y")switch(n.key){case"ArrowDown":c=d+o;break;case"ArrowUp":c=d-o;break;case"PageDown":c=d+r;break;case"PageUp":c=d-r;break;case" ":c=d+(n.shiftKey?-r:r);break;case"Home":c=0;break;case"End":c=a;break}else switch(n.key){case"ArrowRight":c=d+o;break;case"ArrowLeft":c=d-o;break;case"PageDown":c=d+(l?-r:r);break;case"PageUp":c=d+(l?r:-r);break;case" ":c=d+(n.shiftKey?l?r:-r:l?-r:r);break;case"Home":c=0;break;case"End":c=l?-a:a;break}c!==null&&(n.preventDefault(),n.stopPropagation(),this.scrollTo(i==="y"?{top:c}:{left:c},{smooth:!1}),this.syncThumbs())},{signal:s}),t.addEventListener("pointerdown",n=>{if(n.button!==0||n.target===e)return;n.preventDefault();let o=i==="x"&&this.isRtl(),r=t.getBoundingClientRect(),a=i==="y"?n.clientY-r.top:o?r.right-n.clientX:n.clientX-r.left,l=i==="y"?r.height:r.width;if(l<=0)return;let d=i==="y"?this.cachedMaxTop:this.cachedMaxLeft,c=Math.max(0,Math.min(1,a/l)),h=o?-(c*d):c*d;this.scrollTo(i==="y"?{top:h}:{left:h},{smooth:!0})},{signal:s})}setupEventListeners(){let{signal:t}=this.abortController;this.viewport.addEventListener("scroll",this.boundOnScroll,{passive:!0,signal:t}),this.supportsScrollEnd&&this.viewport.addEventListener("scrollend",this.boundOnScrollEnd,{passive:!0,signal:t}),this.options.mode!=="native"&&this.options.autoHide&&!this.options.alwaysVisible&&(this.root.addEventListener("mouseenter",this.boundOnMouseEnter,{signal:t}),this.root.addEventListener("mouseleave",this.boundOnMouseLeave,{signal:t}),this.root.addEventListener("focusin",this.boundOnFocusIn,{signal:t}),this.root.addEventListener("focusout",this.boundOnFocusOut,{signal:t}))}setupObserver(){typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>{this.isDestroyed||this.resizeRafId!==null||(this.resizeRafId=window.requestAnimationFrame(()=>{this.resizeRafId=null,this.isDestroyed||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||this.dragPointerId!==void 0&&t.pointerId!==this.dragPointerId)return;let e=this.dragAxis==="y",i=(e?t.clientY:t.clientX)-this.dragStartPos,s=e?this.cachedTrackHeight:this.cachedTrackWidth,n=e?this.cachedThumbHeight:this.cachedThumbWidth,o=e?this.cachedMaxTop:this.cachedMaxLeft,r=s-n;if(r<=0||o<=0)return;let a=o/r,l=this.dragStartScroll+i*a;e?this.viewport.scrollTop=Math.max(0,Math.min(o,l)):this.isRtl()?this.viewport.scrollLeft=Math.max(-o,Math.min(0,l)):this.viewport.scrollLeft=Math.max(0,Math.min(o,l))}handlePointerUp(t){if(this.isDragging&&!(t&&t.type!=="lostpointercapture"&&this.dragPointerId!==void 0&&t.pointerId!==this.dragPointerId)){if(this.dragPointerId!==void 0){let e=this.dragAxis==="y"?this.thumbY:this.thumbX;try{e&&e.hasPointerCapture(this.dragPointerId)&&e.releasePointerCapture(this.dragPointerId)}catch{}}this.dragAbortController?.abort(),this.dragAbortController=void 0,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()}}getScrollInfo(){let{scrollTop:t,scrollLeft:e}=this.viewport,i=this.cachedMaxTop,s=this.cachedMaxLeft,o=this.isRtl()?Math.max(0,-e):Math.max(0,e),r=i>0?Math.max(0,Math.min(1,t/i)):0,a=s>0?Math.max(0,Math.min(1,o/s)):0;return{top:t,left:e,maxTop:i,maxLeft:s,progressY:Math.round(r*100),progressX:Math.round(a*100)}}handleScroll(){this.scheduleSyncThumbs();let t=this.getScrollInfo(),{top:e,left:i,maxTop:s,maxLeft:n}=t;this.options.onScroll(t);let o=this.options.edgeThreshold;if(s>0){let r=e>=s-o,a=e<=o;r&&!this.atBottom&&this.options.onTotalScroll("bottom"),a&&!this.atTop&&this.options.onTotalScrollBack("top"),this.atBottom=r,this.atTop=a}if(n>0){let r=this.isRtl(),a=r?i>=-o:i>=n-o,l=r?i<=-n+o:i<=o;a&&!this.atRight&&this.options.onTotalScroll("right"),l&&!this.atLeft&&this.options.onTotalScrollBack("left"),this.atRight=a,this.atLeft=l}this.options.mode!=="native"&&this.options.autoHide&&!this.options.alwaysVisible&&(this.clearAutoHideTimer(),this.root.classList.add("is-scrolling"),this.supportsScrollEnd||this.scheduleAutoHide()),this.supportsScrollEnd||(this.scrollEndFallbackTimer!==void 0&&window.clearTimeout(this.scrollEndFallbackTimer),this.scrollEndFallbackTimer=window.setTimeout(()=>{this.scrollEndFallbackTimer=void 0,this.handleScrollEnd()},150))}handleScrollEnd(){this.options.onScrollEnd(this.getScrollInfo()),this.options.mode!=="native"&&this.options.autoHide&&!this.options.alwaysVisible&&this.scheduleAutoHide()}scheduleSyncThumbs(){this.options.mode==="native"||this.isDestroyed||this.rafId===null&&(this.rafId=window.requestAnimationFrame(()=>{this.rafId=null,this.isDestroyed||this.syncThumbs()}))}syncThumbs(){if(this.options.mode==="native"||this.isDestroyed)return;let{scrollTop:t,scrollLeft:e}=this.viewport;if(this.thumbY&&this.trackY){let i=this.cachedMaxTop,s=this.cachedTrackHeight-this.cachedThumbHeight;if(i>0&&s>0){let n=Math.max(0,Math.min(1,t/i)),o=Math.max(0,Math.min(s,n*s));this.thumbY.style.setProperty("--scrollblock-thumb-y",`${o}px`),this.thumbY.setAttribute("aria-valuenow",String(Math.round(n*100)))}}if(this.thumbX&&this.trackX){let i=this.cachedMaxLeft,s=this.cachedTrackWidth-this.cachedThumbWidth;if(i>0&&s>0){let n=this.isRtl(),o=n?Math.max(0,-e):Math.max(0,e),r=Math.max(0,Math.min(1,o/i)),a=Math.max(0,Math.min(s,r*s)),l=n?-a:a;this.thumbX.style.setProperty("--scrollblock-thumb-x",`${l}px`),this.thumbX.setAttribute("aria-valuenow",String(Math.round(r*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(){if(this.isDestroyed)return;this.syncAccessibilityLabels();let{scrollHeight:t,clientHeight:e,scrollWidth:i,clientWidth:s}=this.viewport,n=this.trackY?this.trackY.clientHeight:0,o=this.trackX?this.trackX.clientWidth:0,r=this.thumbY&&typeof window<"u"&&parseFloat(window.getComputedStyle(this.thumbY).minBlockSize)||0,a=this.thumbX&&typeof window<"u"&&parseFloat(window.getComputedStyle(this.thumbX).minInlineSize)||0;this.cachedMaxTop=Math.max(0,t-e),this.cachedMaxLeft=Math.max(0,i-s),this.cachedTrackHeight=n,this.cachedTrackWidth=o;let l=t>e,d=i>s,c=this.cachedThumbHeight;if(this.trackY&&this.thumbY&&l&&t>0){let p=Math.max(this.options.minThumbSize,r);c=Math.max(p,n*(e/t)),this.cachedThumbHeight=c}let h=this.cachedThumbWidth;if(this.trackX&&this.thumbX&&d&&i>0){let p=Math.max(this.options.minThumbSize,a);h=Math.max(p,o*(s/i)),this.cachedThumbWidth=h}this.root.classList.toggle("has-scroll-y",l),this.root.classList.toggle("has-scroll-x",d),l||d?this.viewport.setAttribute("tabindex","0"):this.viewport.removeAttribute("tabindex"),this.trackY&&this.thumbY&&(this.trackY.hidden=!l,l?(this.thumbY.setAttribute("tabindex","0"),this.thumbY.style.height=`${c}px`):this.thumbY.removeAttribute("tabindex")),this.trackX&&this.thumbX&&(this.trackX.hidden=!d,d?(this.thumbX.setAttribute("tabindex","0"),this.thumbX.style.width=`${h}px`):this.thumbX.removeAttribute("tabindex")),this.syncThumbs()}scrollTo(t,e){if(this.isDestroyed)return Promise.resolve();let i=typeof t=="object"&&t!==null&&!(t instanceof HTMLElement)?t.smooth:void 0,n=(e?.smooth??i??!0)&&!ot()?"smooth":"auto",o=this.isRtl(),{scrollHeight:r,clientHeight:a,scrollWidth:l,clientWidth:d,scrollTop:c,scrollLeft:h}=this.viewport,p=Math.max(0,r-a),f=Math.max(0,l-d);this.cachedMaxTop=p,this.cachedMaxLeft=f;let m,g;if(typeof t=="number")m=t;else if(typeof t=="string")switch(t){case"top":m=0;break;case"bottom":m=p;break;case"left":g=o?-f:0;break;case"right":g=o?0:f;break;default:{if(/^-?\d+(\.\d+)?%$/.test(t.trim())){let k=Math.max(0,Math.min(100,parseFloat(t.trim())))/100;this.options.axis==="x"?g=o?-f*k:f*k:this.options.axis==="both"?(m=p*k,g=o?-f*k:f*k):m=p*k;break}let v=null;try{v=this.viewport.querySelector(t)}catch{v=null}if(v){let k=this.viewport.getBoundingClientRect(),S=v.getBoundingClientRect();m=S.top-k.top+c,g=S.left-k.left+h}break}}else if(t instanceof HTMLElement){let v=this.viewport.getBoundingClientRect(),k=t.getBoundingClientRect();m=k.top-v.top+c,g=k.left-v.left+h}else typeof t=="object"&&t!==null&&(m=t.top,g=t.left);let b=m!==void 0&&Number.isFinite(m)?Math.max(0,Math.min(p,m)):void 0,I=o?-f:0,y=o?0:f,E=g!==void 0&&Number.isFinite(g)?Math.max(I,Math.min(y,g)):void 0,T=b??c,A=E??h;if(Math.abs(T-c)<=1&&Math.abs(A-h)<=1)return Promise.resolve();this.activeScrollToController?.abort();let w=new AbortController;this.activeScrollToController=w;let M=this.viewport.scrollTo({top:b,left:E,behavior:n});return M instanceof Promise?M.then(()=>{this.activeScrollToController===w&&(this.activeScrollToController=void 0)}):n!=="smooth"?(this.activeScrollToController===w&&(this.activeScrollToController=void 0),Promise.resolve()):new Promise(v=>{let k=!1,S,P,tt=()=>{k||(k=!0,S!==void 0&&window.clearTimeout(S),P!==void 0&&window.clearTimeout(P),this.activeScrollToController===w&&(this.activeScrollToController=void 0),w.abort(),v())};if(w.signal.addEventListener("abort",tt,{once:!0}),this.abortController.signal.addEventListener("abort",tt,{once:!0,signal:w.signal}),this.supportsScrollEnd)this.viewport.addEventListener("scrollend",tt,{once:!0,signal:w.signal});else{let ft=()=>{S!==void 0&&window.clearTimeout(S),S=window.setTimeout(tt,150)};this.viewport.addEventListener("scroll",ft,{passive:!0,signal:w.signal}),ft()}P=window.setTimeout(tt,2500)})}audit(){let t=[],e=this.checkAriaIdReferences(this.viewport,"aria-labelledby",t),i=this.checkAriaIdReferences(this.root,"aria-labelledby",t),s=e||i,n=this.root.getAttribute("aria-label")?.trim(),o=!this.wasAriaLabelInferred&&!!this.viewport.getAttribute("aria-label")?.trim();return!this.hasExplicitAriaLabel&&!this.hasRootAriaLabel&&!o&&!n&&!s&&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.mode!=="native"&&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.isDestroyed)if(this.isDestroyed=!0,this.clearAutoHideTimer(),this.scrollEndFallbackTimer!==void 0&&(window.clearTimeout(this.scrollEndFallbackTimer),this.scrollEndFallbackTimer=void 0),this.rafId!==null&&(window.cancelAnimationFrame(this.rafId),this.rafId=null),this.resizeRafId!==null&&(window.cancelAnimationFrame(this.resizeRafId),this.resizeRafId=null),this.activeScrollToController?.abort(),this.activeScrollToController=void 0,this.dragAbortController?.abort(),this.dragAbortController=void 0,this.abortController.abort(),this.resizeObserver&&this.resizeObserver.disconnect(),this.trackY?.remove(),this.trackX?.remove(),this.root.classList.remove("wulf-scrollblock","wulf-scrollblock--native","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;)it(this.root,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.propagatedRootLabel&&this.viewport.removeAttribute(this.propagatedRootLabel),this.wasAriaLabelInferred&&this.viewport.getAttribute("aria-label")===this.lastInferredAriaLabel&&this.viewport.removeAttribute("aria-label")}};var zt={ScrollBlock:Q,i18n:lt};var ee=Q,Vt=R();Vt&&(Vt.Scroll=zt);var Lt={};et(Lt,{LayoutEngine:()=>W,LocalizedComponent:()=>x,Masonry:()=>U,createI18nManager:()=>z,default:()=>ie,masonryEn:()=>Ct,masonryFr:()=>Mt,masonryI18n:()=>ut});var W=class{static parseGutter(t){if(typeof t=="number"){let e=Number.isFinite(t)?Math.max(0,t):0;return{x:e,y:e}}if(t&&typeof t=="object"){let e=Number(t.x),i=Number(t.y);return{x:Number.isFinite(e)?Math.max(0,e):0,y:Number.isFinite(i)?Math.max(0,i):0}}return{x:0,y:0}}static resolveColumnWidth(t,e,i){if(typeof i=="number"&&Number.isFinite(i)&&i>0)return i;if(typeof i=="string"){let n=i.trim();if(/^\d+(\.\d+)?(px|%)?$/i.test(n)){let o=parseFloat(n);if(Number.isFinite(o)&&o>0)if(n.endsWith("%")){let a=t.getBoundingClientRect().width*o/100;if(a>0)return a}else return o}else if(n){let o=null;try{o=t.querySelector(n)}catch{o=null}if(o){let a=o.getBoundingClientRect().width;if(Number.isFinite(a)&&a>0)return a}let r=parseFloat(n);if(Number.isFinite(r)&&r>0)return r}}if(i instanceof HTMLElement){let n=i.getBoundingClientRect().width;if(n>0)return n}if(e){let n=e.getBoundingClientRect().width;if(n>0)return n}let s=t.getBoundingClientRect().width;return s>0?s:200}static getItemSpan(t,e,i,s){let n=t.getAttribute("data-masonry-span")||t.dataset.masonrySpan;if(n){let o=parseInt(n,10);if(!isNaN(o)&&o>0)return Math.min(s,o)}for(let o of t.classList){let r=/^(?:span|col-span)-(\d+)$/.exec(o);if(r&&r[1]){let a=parseInt(r[1],10);if(!isNaN(a)&&a>0)return Math.min(s,a)}}return 1}static calculate(t,e,i){let n=t.getBoundingClientRect().width,{x:o,y:r}=this.parseGutter(i.gutter);if(n<=0||e.length===0)return{cols:1,colWidth:n,gutterX:o,gutterY:r,containerHeight:0,containerWidth:n,positions:[]};let a=e[0]||null,l=this.resolveColumnWidth(t,a,i.columnWidth),d=l+o,c=d>0?Math.floor((n+o)/d):1;!Number.isFinite(c)||c<1?c=1:c>1e3&&(c=1e3),!i.columnWidth&&c>1&&(l=(n-(c-1)*o)/c);let h=i.fitWidth?c*l+(c-1)*o:void 0,p=new Array(c).fill(0),f=[],m=e.map(y=>{let E=y.getBoundingClientRect().height;return E>0?E:50}),g=0;for(let y=0;y<e.length;y++){let E=e[y],T=m[y],A=this.getItemSpan(E,l,o,c),w=0,M=0;if(i.horizontalOrder){g+A>c&&(g=0),w=g;let L=0;for(let C=0;C<A;C++)p[w+C]>L&&(L=p[w+C]);M=L,g=(w+A)%c}else if(A===1){let L=p[0];w=0;for(let C=1;C<c;C++)p[C]<L&&(L=p[C],w=C);M=L}else{let L=1/0;w=0;for(let C=0;C<=c-A;C++){let mt=0;for(let gt=0;gt<A;gt++)p[C+gt]>mt&&(mt=p[C+gt]);mt<L&&(L=mt,w=C)}M=L}let v=A*l+(A-1)*o,k=typeof window<"u"&&typeof window.getComputedStyle=="function"&&window.getComputedStyle(t).direction==="rtl",S=h!==void 0?h:n,P=w*(l+o),tt=k?Math.max(0,S-P-v):P;f.push({element:E,x:tt,y:M,width:v,height:T,column:w,span:A});let ft=M+T+r;for(let L=0;L<A;L++)p[w+L]=ft}let b=0;for(let y=0;y<c;y++)p[y]>b&&(b=p[y]);let I=Math.max(0,b>0?b-r:0);return{cols:c,colWidth:l,gutterX:o,gutterY:r,containerHeight:I,containerWidth:n,fittedWidth:h,positions:f}}};var Mt={gallery:"Galerie en grille asym\xE9trique"};var Ct={gallery:"Masonry grid gallery"};var ut=z("fr",{fr:Mt,en:Ct});var U=class extends x{static _i18n=ut;static i18n=ut;root;isNativeCSSGrid=!1;_items=[];options;resizeObserver=null;itemResizeObserver=null;observedItems=new Set;observedItemHeights=new WeakMap;removingItems=new WeakSet;layoutRafId=null;isDestroyed=!1;wasRoleInferred=!1;wasAriaLabelInferred=!1;hasExplicitAriaLabel=!1;lastInferredAriaLabel="";abortController=new AbortController;watchedImages=new WeakSet;originalContainerStyles;constructor(t,e={}){if(super(e.i18n),typeof t=="string"){let s=null;try{s=document.querySelector(t)}catch{s=null}if(!s)throw new Error(`[Wulf.Masonry] Conteneur introuvable pour le s\xE9lecteur : "${t}"`);this.root=s}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 i=typeof CSS<"u"&&typeof CSS.supports=="function"&&(CSS.supports("display","grid-lanes")||CSS.supports("grid-template-rows","masonry"));this.options.useNativeCSSGrid&&i?(this.isNativeCSSGrid=!0,this.root.classList.add("wulf-masonry","wulf-masonry--native"),this.syncNativeGridVariables()):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.hasAttribute("aria-labelledby")&&(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="300ms";typeof t=="number"&&Number.isFinite(t)&&t>=0?e=`${t}ms`:typeof t=="string"&&/^\s*(?:\d+(?:\.\d+)?|\.\d+)(ms|s)\s*$/i.test(t)&&(e=t.trim()),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")&&!this.removingItems.has(e));else try{let e=this.options.itemSelector.trim(),i=e.startsWith(">")?`:scope ${e}`:e;t=Array.from(this.root.querySelectorAll(i)).filter(s=>s.parentElement===this.root&&!s.hasAttribute("data-masonry-ignore")&&!this.removingItems.has(s))}catch{t=Array.from(this.root.children).filter(e=>e instanceof HTMLElement&&!e.hasAttribute("data-masonry-ignore")&&!this.removingItems.has(e))}if(this.itemResizeObserver){let e=new Set(t);for(let i of this.observedItems)e.has(i)||(this.itemResizeObserver.unobserve(i),this.observedItems.delete(i),this.observedItemHeights.delete(i))}this._items=t;for(let e of this._items)e.classList.add("wulf-masonry-item"),this.itemResizeObserver&&!this.observedItems.has(e)&&(this.itemResizeObserver.observe(e),this.observedItems.add(e))}initObservers(){if(!this.options.resize||typeof ResizeObserver>"u")return;let t=this.root.getBoundingClientRect().width;this.resizeObserver=new ResizeObserver(e=>{for(let i of e){let s=i.contentRect.width;Math.abs(s-t)>=1&&(t=s,this.scheduleLayout())}}),this.resizeObserver.observe(this.root),this.itemResizeObserver=new ResizeObserver(e=>{let i=!1;for(let s of e){let n=s.borderBoxSize?.[0]?.blockSize??s.contentRect.height,o=this.observedItemHeights.get(s.target);(o===void 0||Math.abs(n-o)>=1)&&(this.observedItemHeights.set(s.target,n),o!==void 0&&(i=!0))}i&&this.scheduleLayout()});for(let e of this._items)this.itemResizeObserver.observe(e),this.observedItems.add(e)}syncNativeGridVariables(){let{x:t,y:e}=W.parseGutter(this.options.gutter);if(this.root.style.setProperty("--wulf-masonry-gutter-x",`${t}px`),this.root.style.setProperty("--wulf-masonry-gutter-y",`${e}px`),typeof this.options.columnWidth=="number"&&Number.isFinite(this.options.columnWidth)&&this.options.columnWidth>0)this.root.style.setProperty("--wulf-masonry-col-min",`${this.options.columnWidth}px`);else if(this.options.columnWidth instanceof HTMLElement){let i=this.options.columnWidth.getBoundingClientRect().width;i>0&&this.root.style.setProperty("--wulf-masonry-col-min",`${i}px`)}else if(typeof this.options.columnWidth=="string"&&this.options.columnWidth.trim())try{let i=this.root.querySelector(this.options.columnWidth);if(i){let s=i.getBoundingClientRect().width;s>0&&this.root.style.setProperty("--wulf-masonry-col-min",`${s}px`)}}catch{}}initImages(){if(!this.options.autoImages)return;let t=Array.from(this.root.querySelectorAll("img"));for(let e of t)if(!e.complete&&!this.watchedImages.has(e)){this.watchedImages.add(e);let i=()=>{e.addEventListener("load",()=>{this.isDestroyed||this.scheduleLayout()},{once:!0,signal:this.abortController.signal})};typeof e.decode=="function"?e.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.syncAccessibilityLabels(),this.isNativeCSSGrid){this.syncNativeGridVariables();for(let r of this._items)r.classList.remove("wulf-masonry-item--hidden");this.options.onLayout([]);return}this.root.setAttribute("aria-busy","true"),this.options.fitWidth&&this.root.classList.contains("wulf-masonry--fit-width")&&(this.root.style.width="");let t=W.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,i=typeof e=="number"&&Number.isFinite(e)&&e>0;i?this.root.style.setProperty("--wulf-masonry-stagger",`${e}ms`):this.root.style.removeProperty("--wulf-masonry-stagger");let n=!(this._items.length!==this.root.children.length)&&typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("transition-delay","calc(sibling-index() * 1ms)"),o=this.options.percentPosition&&t.containerWidth>0;for(let r=0;r<t.positions.length;r++){let a=t.positions[r],l=a.element;if(o){let d=Number((a.width/t.containerWidth*100).toFixed(4));l.style.setProperty("--wulf-masonry-w",`${d}%`)}else l.style.setProperty("--wulf-masonry-w",`${a.width}px`);l.style.setProperty("--wulf-masonry-x",`${a.x}px`),l.style.setProperty("--wulf-masonry-y",`${a.y}px`),i&&!n?l.style.setProperty("--wulf-masonry-index",String(r)):l.style.removeProperty("--wulf-masonry-index"),l.classList.remove("wulf-masonry-item--hidden"),this.observedItemHeights.set(l,a.height),this.options.onItemPlaced(l,a)}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 i=document.createDocumentFragment();for(let s of e)this.isNativeCSSGrid?s.classList.add("wulf-masonry-item"):s.classList.add("wulf-masonry-item","wulf-masonry-item--hidden"),i.appendChild(s);this.root.appendChild(i),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 i=this.root.firstChild,s=document.createDocumentFragment();for(let n of e)this.isNativeCSSGrid?n.classList.add("wulf-masonry-item"):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(t){if(this.isDestroyed)return;let e=Array.isArray(t)?t:[t];if(e.length===0)return;let i=()=>{if(!this.isDestroyed){for(let n of e)this.removingItems.delete(n),n.parentElement===this.root&&(this.itemResizeObserver&&(this.itemResizeObserver.unobserve(n),this.observedItems.delete(n),this.observedItemHeights.delete(n)),this.root.removeChild(n));this.reloadItems(),this.layout()}};for(let n of e)this.removingItems.add(n),typeof document<"u"&&document.activeElement&&n.contains(document.activeElement)&&document.activeElement.blur?.(),n.setAttribute("inert",""),n.style.transitionDelay="0ms",n.classList.add("wulf-masonry-item--hidden");let s=Tt(this.options.transitionDuration,300);if(s<=0||this.isNativeCSSGrid){i();return}this.reloadItems(),this.layout(),Promise.all(e.map(n=>ht(n,s,this.abortController.signal))).then(()=>{this.abortController.signal.aborted||i()})}audit(){let t=[],e=this.checkAriaIdReferences(this.root,"aria-labelledby",t),i=!this.wasAriaLabelInferred&&!!this.root.getAttribute("aria-label")?.trim();!this.hasExplicitAriaLabel&&!i&&!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 s=Array.from(this.root.querySelectorAll("img")).filter(n=>!n.hasAttribute("alt")&&n.getAttribute("aria-hidden")!=="true");return s.length>0&&t.push(`${s.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,this.abortController.abort(),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.root.style.removeProperty("--wulf-masonry-stagger"),this.root.style.removeProperty("--wulf-masonry-col-min"),this.root.style.removeProperty("--wulf-masonry-gutter-x"),this.root.style.removeProperty("--wulf-masonry-gutter-y"),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("--wulf-masonry-index");this._items=[]}}};var ie=U,Wt=R();Wt&&(Wt.Masonry=Object.assign(U,{Masonry:U,LayoutEngine:W,i18n:ut}));var Pt={};et(Pt,{LocalizedComponent:()=>x,Toast:()=>j,ToastInstance:()=>nt,ToastManager:()=>_,createI18nManager:()=>z,default:()=>ae,toastEn:()=>Dt,toastFr:()=>xt,toastI18n:()=>K});var xt={closeButton:"Fermer la notification",notificationsRegion:"Notifications"};var Dt={closeButton:"Close notification",notificationsRegion:"Notifications"};var K=z("fr",{fr:xt,en:Dt});var se=1,Kt=5e3;function pt(u){if(!u||typeof u!="string"||u.length>128)return!1;let t=u.trim();return!t||/[\u0000-\u001F\u007F;{}<>\\]|(?:url|image-set|-webkit-image-set|image|src|expression|attr|env)\s*\(/i.test(t)?!1:typeof CSS<"u"&&typeof CSS.supports=="function"?CSS.supports("color",t)||CSS.supports("background-color",t):!0}function ne(u){return u.slice(0,128).trim().split(/\s+/).filter(t=>/^[a-zA-Z0-9_-]+$/.test(t)&&!t.startsWith("wulf-toast")).slice(0,8).join(" ")}var nt=class extends N{id;options;element;_isClosed=!1;_isFinalized=!1;closePromise=null;timerId=null;remainingTime=0;hasDuration=!1;timerStartTime=0;isPausedByHover=!1;isPausedByFocus=!1;isPausedByVisibility=!1;isPendingFocusDismiss=!1;previousActiveElement=null;eventsAbortController=new AbortController;disposeAbortController=new AbortController;onDismissCallback;constructor(t,e){super(),this.id=`wulf-toast-${se++}`,this.options=Object.freeze({...t}),this.onDismissCallback=e,this.previousActiveElement=typeof document<"u"&&document.activeElement instanceof HTMLElement?document.activeElement:null;let i=t.duration===void 0?Kt:t.duration;typeof i=="number"&&Number.isFinite(i)&&i>0?(this.remainingTime=Math.min(i,2147483647),this.hasDuration=!0):(this.remainingTime=0,this.hasDuration=!1),this.element=this.createDOM(),this.bindEvents(),this.runAuditWarning(t.audit!==!1)}get isClosed(){return this._isClosed}getPreviousActiveElement(){return this.previousActiveElement}audit(){let t=[],e=!!(this.options.title&&this.options.title.trim().length>0),i=!!(this.options.message&&this.options.message.trim().length>0);!e&&!i&&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 s=this.options.duration===void 0?Kt:this.options.duration;typeof s=="number"&&s>0&&s<5e3&&t.push(`Dur\xE9e d'affichage trop courte (duration: ${s}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(s===!1||typeof s=="number"&&s<=0)&&!n&&t.push("Notification persistante impossible \xE0 fermer au clavier : activez closable: 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");if(t.id=this.id,t.className="wulf-toast",t.setAttribute("data-toast-role",this.options.role==="alert"?"alert":"status"),this.options.backgroundColor&&pt(this.options.backgroundColor)&&t.style.setProperty("--wulf-toast-bg",this.options.backgroundColor.trim()),this.options.titleColor&&pt(this.options.titleColor)&&t.style.setProperty("--wulf-toast-title-color",this.options.titleColor.trim()),this.options.textColor&&pt(this.options.textColor)&&t.style.setProperty("--wulf-toast-text-color",this.options.textColor.trim()),this.options.iconColor&&pt(this.options.iconColor)&&t.style.setProperty("--wulf-toast-icon-color",this.options.iconColor.trim()),this.options.closeButtonColor&&pt(this.options.closeButtonColor)&&t.style.setProperty("--wulf-toast-close-color",this.options.closeButtonColor.trim()),this.options.icon&&typeof this.options.icon=="string"&&this.options.icon.trim()!==""){let s=ne(this.options.icon);if(s){let n=document.createElement("span");n.className=`wulf-toast-icon ${s}`,n.setAttribute("aria-hidden","true"),t.appendChild(n)}}let e=document.createElement("div");if(e.className="wulf-toast-content",this.options.title&&this.options.title.trim()!==""){let s=document.createElement("div");s.className="wulf-toast-title",this.appendTextWithLineBreaks(s,this.options.title),e.appendChild(s)}if(this.options.message&&this.options.message.trim()!==""){let s=document.createElement("div");s.className="wulf-toast-message",this.appendTextWithLineBreaks(s,this.options.message),e.appendChild(s)}if(t.appendChild(e),this.options.closable??!0){let s=document.createElement("button");s.type="button",s.className="wulf-toast-close",s.setAttribute("aria-label",K.t("closeButton",this.options.i18n));let n=document.createElement("span");n.className="wulf-toast-close-icon",n.setAttribute("aria-hidden","true"),n.textContent="\xD7",s.appendChild(n),s.addEventListener("click",o=>{o.stopPropagation(),this.close("close-button")},{signal:this.eventsAbortController.signal}),t.appendChild(s)}if(this.options.progressBar&&this.remainingTime>0){t.style.setProperty("--wulf-toast-duration",`${this.remainingTime}ms`);let s=document.createElement("div");s.className="wulf-toast-progress",s.setAttribute("aria-hidden","true"),t.appendChild(s)}return t}appendTextWithLineBreaks(t,e){String(e??"").slice(0,4096).split(/\r\n|\r|\n/).slice(0,100).forEach((n,o)=>{o>0&&t.appendChild(document.createElement("br")),t.appendChild(document.createTextNode(n))})}bindEvents(){let{signal:t}=this.eventsAbortController;this.element.addEventListener("click",e=>{this.options.onClick&&this.options.onClick(this,e),this.options.closeOnClick&&this.close("toast-click")},{signal:t}),this.element.addEventListener("mouseenter",()=>this.pauseTimer("hover"),{signal:t}),this.element.addEventListener("mouseleave",()=>this.resumeTimer("hover"),{signal:t}),this.element.addEventListener("focusin",()=>this.pauseTimer("focus"),{signal:t}),this.element.addEventListener("focusout",e=>{let i=e.relatedTarget;if(!(i&&this.element.contains(i))){if(this.isPendingFocusDismiss&&!this._isClosed){this.isPendingFocusDismiss=!1,this.close("timeout");return}this.resumeTimer("focus")}},{signal:t}),this.element.addEventListener("keydown",e=>{e.key==="Escape"&&(this.options.closable??!0)&&(e.stopPropagation(),this.close("close-button"))},{signal:t}),typeof document<"u"&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.pauseTimer("visibility"):this.resumeTimer("visibility")},{signal:t})}get isPaused(){return this.isPausedByHover||this.isPausedByFocus||this.isPausedByVisibility}startTimer(){if(!(this._isClosed||this.remainingTime<=0||this.isPaused)){if(typeof document<"u"&&document.visibilityState==="hidden"){this.isPausedByVisibility=!0,this.element.classList.add("is-paused");return}this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),this.timerStartTime=performance.now(),this.timerId=window.setTimeout(()=>{if(this.timerId=null,typeof document<"u"&&this.element.contains(document.activeElement)){this.isPendingFocusDismiss=!0;return}this.close("timeout")},this.remainingTime)}}pauseTimer(t="interaction"){if(this._isClosed||!this.hasDuration||this.remainingTime<=0)return;let e=this.isPaused;if(t==="visibility"?this.isPausedByVisibility=!0:t==="focus"?this.isPausedByFocus=!0:this.isPausedByHover=!0,!e){if(this.timerId!==null){window.clearTimeout(this.timerId),this.timerId=null;let i=performance.now()-this.timerStartTime;this.remainingTime=Math.max(0,this.remainingTime-i)}this.element.classList.add("is-paused")}}resumeTimer(t="interaction"){if(!(this._isClosed||!this.hasDuration)&&(t==="visibility"?this.isPausedByVisibility=!1:t==="focus"?this.isPausedByFocus=!1:t==="hover"?this.isPausedByHover=!1:(this.isPausedByHover=!1,this.isPausedByFocus=!1),!this.isPaused)){if(this.element.classList.remove("is-paused"),this.remainingTime<=0){this.close("timeout");return}this.startTimer()}}finalizeDismiss(t){this._isFinalized||(this._isFinalized=!0,this.eventsAbortController.abort(),this.onDismissCallback&&this.onDismissCallback(this,t),this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.options.onClose&&this.options.onClose(this,t))}destroyImmediate(t="replace"){this._isClosed=!0,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),this.disposeAbortController.abort(),this.finalizeDismiss(t)}close(t="programmatic",e=!1){return this._isClosed?this.closePromise??Promise.resolve():(this._isClosed=!0,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),this.eventsAbortController.abort(),this.element.classList.add(e?"wulf-toast-hiding-fast":"wulf-toast-hiding"),ot()?(this.finalizeDismiss(t),this.closePromise=Promise.resolve(),this.closePromise):(this.closePromise=ht(this.element,e?90:300,this.disposeAbortController.signal).then(()=>{this.disposeAbortController.signal.aborted||this.finalizeDismiss(t)}),this.closePromise))}};var oe=new Set(["top-left","top-center","top-right","bottom-left","bottom-center","bottom-right"]);function $t(u){return u&&oe.has(u)?u:"top-right"}var re='button:not([disabled]), [href], [tabindex]:not([tabindex="-1"])',_=class u{static instance=null;containers=new Map;activeToasts=new Map;announcerEl=null;politeRegion=null;assertiveRegion=null;announceTimers=[];politeAnnounceTimerId=null;assertiveAnnounceTimerId=null;politeClearTimerId=null;assertiveClearTimerId=null;lastPoliteText="";lastAssertiveText="";announcerToggle=!1;isPopoverOpen(t){try{if(t.matches(":popover-open"))return!0}catch{}return t.classList.contains(":popover-open")}replaceTokens=new Map;pendingReplacements=new Set;constructor(){}static getInstance(){return u.instance||(u.instance=new u),u.instance}add(t){let e=$t(t.options.position),i=this.activeToasts.get(e);i||(i=[],this.activeToasts.set(e,i));let s=t.options.maxToasts,n=typeof s=="number"&&Number.isFinite(s)&&s>0?Math.min(50,Math.max(1,Math.floor(s))):5;if(t.options.replace&&i.length>0){let o=[...i],r=(this.replaceTokens.get(e)||0)+1;this.replaceTokens.set(e,r),this.pendingReplacements.add(e);let a=o.map(l=>l.close("replace",!0));Promise.all(a).then(()=>{if(this.pendingReplacements.delete(e),this.replaceTokens.get(e)!==r){t.destroyImmediate("replace");return}this.mountToast(t,e,n)});return}if(this.pendingReplacements.has(e)&&(this.replaceTokens.set(e,(this.replaceTokens.get(e)||0)+1),this.pendingReplacements.delete(e)),i.length>=n){let o=i.length-n+1,r=i.splice(0,o);for(let a of r)a.close("max-limit",!0)}this.mountToast(t,e,n)}mountToast(t,e,i=5){if(t.isClosed)return;let s=t.options.useTopLayer??!0,n=this.getOrCreateContainer(e,t,s),o=this.activeToasts.get(e);o||(o=[],this.activeToasts.set(e,o));let r=i+10;if(n.children.length>=r){let a=Array.from(n.children);for(let l of a){if(n.children.length<r)break;(l.classList.contains("wulf-toast-hiding")||l.classList.contains("wulf-toast-hiding-fast"))&&l.remove()}}if(s&&typeof n.showPopover=="function"&&n.getAttribute("popover")==="manual")try{let a=n;this.isPopoverOpen(n)||a.showPopover()}catch{n.removeAttribute("popover")}if(n.appendChild(t.element),o.push(t),this.announce(t),t.options.onOpen)try{t.options.onOpen(t)}catch(a){console.error("[Wulf.Toast] Erreur dans le callback onOpen:",a)}t.startTimer()}announce(t){let e=[t.options.title,t.options.message].filter(p=>typeof p=="string"&&p.trim().length>0).map(p=>p.trim());if(e.length===0)return;let i=e.join(". "),s=i.length>512?`${i.slice(0,509)}...`:i,n=t.options.role==="alert",o=document;if(typeof o.ariaNotify=="function")try{o.ariaNotify(s,{priority:n?"high":"normal"});return}catch{}let r=!this.announcerEl||!this.announcerEl.isConnected;this.ensureAnnouncer();let a=n?this.assertiveRegion:this.politeRegion;if(!a)return;n?(this.assertiveAnnounceTimerId!==null&&(window.clearTimeout(this.assertiveAnnounceTimerId),this.assertiveAnnounceTimerId=null),this.assertiveClearTimerId!==null&&(window.clearTimeout(this.assertiveClearTimerId),this.assertiveClearTimerId=null)):(this.politeAnnounceTimerId!==null&&(window.clearTimeout(this.politeAnnounceTimerId),this.politeAnnounceTimerId=null),this.politeClearTimerId!==null&&(window.clearTimeout(this.politeClearTimerId),this.politeClearTimerId=null)),a.textContent="";let l=n?this.lastAssertiveText:this.lastPoliteText,d=s;s===l?(this.announcerToggle=!this.announcerToggle,d=this.announcerToggle?`${s}\xA0`:s):this.announcerToggle=!1,n?this.lastAssertiveText=s:this.lastPoliteText=s;let c=r?120:50,h=window.setTimeout(()=>{let p=this.announceTimers.indexOf(h);if(p!==-1&&this.announceTimers.splice(p,1),n?this.assertiveAnnounceTimerId=null:this.politeAnnounceTimerId=null,a.isConnected){a.textContent=d;let f=window.setTimeout(()=>{let m=this.announceTimers.indexOf(f);m!==-1&&this.announceTimers.splice(m,1),a.isConnected&&a.textContent===d&&(a.textContent="")},4e3);this.announceTimers.push(f),n?this.assertiveClearTimerId=f:this.politeClearTimerId=f}},c);this.announceTimers.push(h),n?this.assertiveAnnounceTimerId=h:this.politeAnnounceTimerId=h}ensureAnnouncer(){if(this.announcerEl&&document.body.contains(this.announcerEl))return;let t=document.createElement("div");t.className="wulf-toast-announcer",t.setAttribute("data-wulf-toast-announcer","true");let e=document.createElement("div");e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true");let i=document.createElement("div");i.setAttribute("role","alert"),i.setAttribute("aria-live","assertive"),i.setAttribute("aria-atomic","true"),t.appendChild(e),t.appendChild(i),document.body.appendChild(t),this.announcerEl=t,this.politeRegion=e,this.assertiveRegion=i}handleFocusHandoff(t,e){if(!t.element.contains(document.activeElement))return;for(let s=e.length-1;s>=0;s--){let n=e[s];if(n===t||n.isClosed||!n.element.isConnected)continue;let o=n.element.querySelector(re);if(o){o.focus({preventScroll:!0});return}}let i=t.getPreviousActiveElement();if(i&&i.isConnected&&typeof i.focus=="function"&&!i.disabled&&!i.closest("[inert]")&&i.getAttribute("aria-hidden")!=="true")try{i.focus()}catch{}}remove(t,e){let i=$t(t.options.position),s=this.activeToasts.get(i);if(s){let n=s.indexOf(t);if(n!==-1&&s.splice(n,1),this.handleFocusHandoff(t,s),t.element.parentNode&&t.element.parentNode.removeChild(t.element),s.length===0&&!this.pendingReplacements.has(i)){let o=this.containers.get(i);o&&(!o.firstChild||o.children.length===0)&&(this.disposeContainer(o),this.containers.delete(i),this.activeToasts.delete(i))}}else t.element.parentNode&&t.element.parentNode.removeChild(t.element)}disposeContainer(t){try{let e=t;typeof e.hidePopover=="function"&&this.isPopoverOpen(t)&&e.hidePopover()}catch{}t.parentNode&&t.parentNode.removeChild(t)}clearAll(t){let e=[];if(t){this.replaceTokens.set(t,(this.replaceTokens.get(t)||0)+1),this.pendingReplacements.delete(t);let i=this.activeToasts.get(t);if(i&&i.length>0){let s=[...i];for(let n of s)e.push(n.close("programmatic"))}else{let s=this.containers.get(t);s&&(!s.firstChild||s.children.length===0)&&(this.disposeContainer(s),this.containers.delete(t),this.activeToasts.delete(t))}}else{for(let s of this.replaceTokens.keys())this.replaceTokens.set(s,(this.replaceTokens.get(s)||0)+1);this.pendingReplacements.clear();for(let s of this.announceTimers)window.clearTimeout(s);this.announceTimers=[],this.politeAnnounceTimerId=null,this.assertiveAnnounceTimerId=null,this.politeClearTimerId=null,this.assertiveClearTimerId=null;let i=new Set([...Array.from(this.containers.keys()),...Array.from(this.activeToasts.keys())]);for(let s of i)e.push(this.clearAll(s))}return Promise.all(e).then(()=>{if(!t)for(let[i,s]of Array.from(this.containers.entries()))(!s.firstChild||s.children.length===0)&&(this.disposeContainer(s),this.containers.delete(i),this.activeToasts.delete(i))})}destroy(){for(let t of this.announceTimers)window.clearTimeout(t);this.announceTimers=[];for(let t of Array.from(this.activeToasts.values()))for(let e of[...t])e.destroyImmediate("programmatic");for(let t of Array.from(this.containers.values()))this.disposeContainer(t);this.containers.clear(),this.activeToasts.clear(),this.replaceTokens.clear(),this.pendingReplacements.clear(),this.announcerEl&&(this.announcerEl.remove(),this.announcerEl=null,this.politeRegion=null,this.assertiveRegion=null),u.instance=null}getOrCreateContainer(t,e,i){let s=this.containers.get(t);return(!s||!document.body.contains(s))&&(s=document.createElement("div"),s.className=`wulf-toast-container wulf-toast-${t}`,s.setAttribute("role","region"),s.setAttribute("aria-label",K.t("notificationsRegion",e.options.i18n)),i&&typeof s.showPopover=="function"&&s.setAttribute("popover","manual"),document.body.appendChild(s),this.containers.set(t,s)),s}};var j=class extends x{static _i18n=K;static i18n=K;audit(){return[]}getAuditPrefix(){return"Wulf.Toast"}getAuditTargetLabel(){return"Toast"}static show(t={}){let e=_.getInstance(),i=new nt(t,(s,n)=>{e.remove(s,n)});return e.add(i),i}static clearAll(t){return _.getInstance().clearAll(t)}static destroy(){_.getInstance().destroy()}};var ae=j,Gt=R();Gt&&(Gt.Toast=Object.assign(j,{Toast:j,i18n:K}));var Ot={};et(Ot,{FocusTrap:()=>X,default:()=>X});var le=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])","button:not([disabled])","audio[controls]","video[controls]","details > summary:first-of-type","iframe","object","embed",'[contenteditable]:not([contenteditable="false"])','[tabindex]:not([tabindex="-1"])'].join(",");function Rt(u,t){if(!t||typeof t!="string")return null;try{return u.querySelector(t)}catch{return null}}var Y=[],X=class extends N{element;options;active=!1;paused=!1;previousActiveElement=null;inertSiblings=[];addedContainerTabIndex=!1;lastOutsidePointerDownTime=0;abortController;handleKeyDownBound;handleClickOutsideBound;handleFocusInBound;constructor(t,e={}){super();let i=typeof t=="string"?Rt(document,t):t;if(!i||!(i instanceof HTMLElement))throw new Error(`[Wulf.FocusTrap] Conteneur introuvable ou invalide : "${t}"`);this.element=i;let s=e.allowOutsideClick??!1;this.options={initialFocus:e.initialFocus!==void 0?e.initialFocus:"[data-autofocus], [autofocus]",returnFocus:e.returnFocus??!0,fallbackReturnFocus:e.fallbackReturnFocus??"",escapeDeactivates:e.escapeDeactivates??!0,allowOutsideClick:s,setInert:e.setInert??!s,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)}isNativeDialogElement(){return this.element.tagName.toLowerCase()==="dialog"}isNativeModalDialog(){if(!this.isNativeDialogElement())return!1;try{return this.element.matches(":modal")}catch{return!1}}isElementFocusableBase(t){if(!t||!t.isConnected||t.tabIndex<0||t.disabled)return!1;try{if(t.matches(":disabled"))return!1}catch{if(t.closest("fieldset[disabled]"))return!1}if(t.hasAttribute("inert")||t.closest("[inert]")||t.hidden||t.closest("[hidden]"))return!1;let e=t;if(typeof e.checkVisibility=="function"){if(!e.checkVisibility({checkOpacity:!1,checkVisibilityCSS:!0,visibilityProperty:!0}))return!1}else{if(t.style.display==="none"||t.style.visibility==="hidden")return!1;let i=window.getComputedStyle(t);if(i.display==="none"||i.visibility==="hidden"||t.offsetWidth===0&&t.offsetHeight===0&&i.position!=="fixed")return!1}return!0}isFocusable(t){if(!this.isElementFocusableBase(t))return!1;if(t instanceof HTMLInputElement&&t.type==="radio"&&t.name){let e=Array.from(this.element.querySelectorAll(`input[type="radio"][name="${ct(t.name)}"]`)).filter(s=>s.form===t.form&&this.isElementFocusableBase(s));if(e.length===0)return!1;let i=e.find(s=>s.checked);return i?t===i:t===e[0]}return!0}getFocusableElements(){return Array.from(this.element.querySelectorAll(le)).filter(e=>this.isFocusable(e))}activate(){if(this.active)return this;let t=Y[Y.length-1];t&&t.pause(),this.active=!0,this.paused=!1,Y.push(this);let e=bt(document);this.previousActiveElement=e instanceof HTMLElement?e:document.activeElement,this.options.setInert&&!this.isNativeModalDialog()&&this.applyInert(),this.abortController?.abort(),this.abortController=new AbortController;let{signal:i}=this.abortController;return document.addEventListener("keydown",this.handleKeyDownBound,{capture:!0,signal:i}),document.addEventListener("focusin",this.handleFocusInBound,{capture:!0,signal:i}),document.addEventListener("pointerdown",this.handleClickOutsideBound,{capture:!0,signal:i}),this.options.allowOutsideClick||(document.addEventListener("mousedown",this.handleClickOutsideBound,{capture:!0,signal:i}),document.addEventListener("touchstart",this.handleClickOutsideBound,{capture:!0,signal:i}),document.addEventListener("click",this.handleClickOutsideBound,{capture:!0,signal:i})),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=Y.indexOf(this);t!==-1&&Y.splice(t,1),this.abortController?.abort(),this.abortController=void 0,this.removeInert(),this.addedContainerTabIndex&&(this.element.removeAttribute("tabindex"),this.addedContainerTabIndex=!1);let e=Y[Y.length-1];return e&&e.unpause(),this.options.returnFocus&&this.restoreFocus(),this.previousActiveElement=null,this.options.onDeactivate(),this}pause(){this.paused=!0,this.removeInert()}unpause(){this.active&&Y[Y.length-1]===this&&(this.paused=!1,this.options.setInert&&!this.isNativeModalDialog()&&this.applyInert())}isActive(){return this.active&&!this.paused}audit(){let t=[],e=this.element.getAttribute("role");this.isNativeDialogElement()?(e==="dialog"&&t.push('Attribut redondant : role="dialog" est d\xE9j\xE0 implicite sur une balise native <dialog>.'),this.element.hasAttribute("aria-modal")&&t.push('Attribut redondant : <dialog> ouvert via showModal() g\xE8re nativement la modalit\xE9 sans n\xE9cessiter aria-modal="true".'),this.element.hasAttribute("open")&&!this.isNativeModalDialog()&&t.push("Dialogue non modal d\xE9tect\xE9 : pr\xE9f\xE9rez dialog.showModal() plut\xF4t que l'attribut open pour obtenir la Top Layer et l'inertie natives.")):((!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.'),(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(),o=this.checkAriaIdReferences(this.element,"aria-labelledby",t);return!n&&!o&&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()}isEventInside(t,e){return!!(e&&this.element.contains(e)||typeof t.composedPath=="function"&&t.composedPath().includes(this.element))}isInsideToastContainer(t){return!t||!(t instanceof Element)?!1:!!t.closest(".wulf-toast-container")}ensureContainerTabIndex(){this.element.getAttribute("tabindex")===null&&(this.element.setAttribute("tabindex","-1"),this.addedContainerTabIndex=!0)}handleKeyDown(t){if(!this.isActive())return;if(this.element.isConnected===!1){this.deactivate();return}if(t.key==="Escape"&&this.options.escapeDeactivates){if(H(t))return;this.isNativeModalDialog()||(t.preventDefault(),t.stopPropagation()),this.deactivate();return}if(t.key!=="Tab")return;let e=this.getFocusableElements();if(e.length===0){t.preventDefault(),this.ensureContainerTabIndex(),this.element.focus();return}let i=e[0],s=e[e.length-1],n=bt(document),o=n instanceof HTMLElement?n:document.activeElement,r=o?this.element.contains(o)||this.isEventInside(t,o):!1;!t.shiftKey&&(o===s||!r)?(t.preventDefault(),i.focus()):t.shiftKey&&(o===i||o===this.element||!r)&&(t.preventDefault(),s.focus())}handleFocusIn(t){if(!this.isActive())return;if(this.element.isConnected===!1){this.deactivate();return}let e=t.target;if(e&&!this.isInsideToastContainer(e)&&!(this.options.allowOutsideClick&&performance.now()-this.lastOutsidePointerDownTime<150)&&!this.isEventInside(t,e)){let i=this.getFocusableElements();i.length>0?i[0].focus():(this.ensureContainerTabIndex(),this.element.focus())}}handleClickOutside(t){if(!this.isActive())return;if(this.element.isConnected===!1){this.deactivate();return}let e=t.target;if(e&&!this.isEventInside(t,e)){if(this.isInsideToastContainer(e))return;if(this.options.allowOutsideClick){this.lastOutsidePointerDownTime=performance.now();return}t.preventDefault(),t.stopPropagation()}}applyInert(){this.removeInert();let t=this.element,e=new Set(["SCRIPT","STYLE","TEMPLATE","LINK","META","NOSCRIPT"]);for(;t&&t!==document.body&&t.parentElement;){let i=t.parentElement;for(let s of Array.from(i.children))s instanceof HTMLElement&&s!==t&&!e.has(s.tagName)&&!s.hasAttribute("inert")&&!s.matches(".wulf-toast-container, .wulf-toast-announcer")&&(s.setAttribute("inert",""),this.inertSiblings.push(s));t=i}}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=Rt(this.element,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.ensureContainerTabIndex(),this.element.focus())}restoreFocus(){if(this.previousActiveElement&&this.previousActiveElement.isConnected&&this.isElementFocusableBase(this.previousActiveElement)){this.previousActiveElement.focus();return}if(this.options.fallbackReturnFocus){let t=typeof this.options.fallbackReturnFocus=="string"?Rt(document,this.options.fallbackReturnFocus):this.options.fallbackReturnFocus;t&&t.isConnected&&this.isElementFocusableBase(t)&&t.focus()}}};var qt=R();qt&&(qt.FocusTrap=Object.assign(X,{FocusTrap:X}));var Ht={};et(Ht,{ShortcutFormatter:()=>D,ShortcutManager:()=>B,default:()=>B});var D=class u{static isApple(){if(typeof navigator>"u")return!1;let t=navigator.userAgentData;if(t&&typeof t.platform=="string"){let s=t.platform.toLowerCase();if(s.includes("mac")||s.includes("ios"))return!0}let e=(navigator.platform||"").toLowerCase();if(e.includes("mac")||e.includes("iphone")||e.includes("ipad")||e.includes("ipod"))return!0;let i=(navigator.userAgent||"").toLowerCase();return i.includes("macintosh")||i.includes("mac os x")||i.includes("ipad")||i.includes("iphone")}static normalizeKeyName(t){if(t===" ")return" ";let e=t.trim().toLowerCase();switch(e){case"esc":return"escape";case"return":return"enter";case"space":case"spacebar":return" ";case"plus":return"+";case"del":return"delete";case"ins":return"insert";case"up":return"arrowup";case"down":return"arrowdown";case"left":return"arrowleft";case"right":return"arrowright";default:return e}}static parseCombo(t,e=u.isApple()){if(typeof t!="string")return[];if(t===" ")return[{ctrl:!1,alt:!1,shift:!1,meta:!1,key:" "}];let i=t.slice(0,512).trim();if(!i)return[];let n=i.replace(/\b(ctrl|control|alt|option|opt|shift|maj|cmd|command|meta|win|super|mod|\$mod)\s*\+\s*/gi,"$1+").split(/\s+/).slice(0,10),o=[];for(let r of n){let a=[];if(r==="+")a.push("+");else{let f="";for(let m=0;m<r.length;m++){let g=r[m];g==="+"?f===""&&a.length>0?a.push("+"):f!==""&&(a.push(f),f=""):f+=g}f!==""&&a.push(f)}let l=!1,d=!1,c=!1,h=!1,p="";for(let f of a){let m=f.trim().toLowerCase();m==="ctrl"||m==="control"?l=!0:m==="alt"||m==="option"||m==="opt"?d=!0:m==="shift"||m==="maj"?c=!0:m==="cmd"||m==="command"||m==="meta"||m==="win"||m==="super"?h=!0:m==="mod"||m==="$mod"?e?h=!0:l=!0:p=u.normalizeKeyName(f)}o.push({ctrl:l,alt:d,shift:c,meta:h,key:p})}return o}static format(t,e=u.isApple()){let i=u.parseCombo(t,e);return i.length===0?t:i.map(n=>{let o=[];if(e){n.ctrl&&o.push("\u2303"),n.alt&&o.push("\u2325"),n.shift&&o.push("\u21E7"),n.meta&&o.push("\u2318");let r=u.formatKeyDisplay(n.key,!0);return o.push(r),o.join("")}else{n.ctrl&&o.push("Ctrl"),n.alt&&o.push("Alt"),n.shift&&o.push("Shift"),n.meta&&o.push("Win");let r=u.formatKeyDisplay(n.key,!1);return o.push(r),o.join("+")}}).join(" ")}static toAriaKeyShortcuts(t,e=u.isApple()){let i=u.parseCombo(t,e);if(i.length!==1)return"";let s=i[0],n=u.formatAriaKey(s.key);if(!n)return"";let o=[];return s.ctrl&&o.push("Control"),s.alt&&o.push("Alt"),s.shift&&o.push("Shift"),s.meta&&o.push("Meta"),o.push(n),o.join("+")}static formatAriaKey(t){if(!t)return"";switch(t.toLowerCase()){case"escape":return"Escape";case"enter":return"Enter";case" ":return"Space";case"tab":return"Tab";case"backspace":return"Backspace";case"delete":return"Delete";case"insert":return"Insert";case"home":return"Home";case"end":return"End";case"pageup":return"PageUp";case"pagedown":return"PageDown";case"arrowup":return"ArrowUp";case"arrowdown":return"ArrowDown";case"arrowleft":return"ArrowLeft";case"arrowright":return"ArrowRight";case"printscreen":return"PrintScreen";case"scrolllock":return"ScrollLock";case"numlock":return"NumLock";case"capslock":return"CapsLock";case"contextmenu":return"ContextMenu";case"+":return"Plus";default:return t.length===1?t.toUpperCase():t.charAt(0).toUpperCase()+t.slice(1)}}static formatKeyDisplay(t,e){if(!t)return"";switch(t.toLowerCase()){case"escape":return e?"\u238B":"Esc";case"enter":return e?"\u21A9":"Enter";case" ":return e?"\u2423":"Space";case"tab":return e?"\u21E5":"Tab";case"backspace":return e?"\u232B":"Backspace";case"delete":return e?"\u2326":"Suppr";case"arrowup":return"\u2191";case"arrowdown":return"\u2193";case"arrowleft":return"\u2190";case"arrowright":return"\u2192";default:return t.length===1?t.toUpperCase():t.charAt(0).toUpperCase()+t.slice(1)}}};var B=class u{options;shortcuts=new Map;scopeStack=[];sequenceBuffer=[];sequenceTimer=null;isListening=!0;boundListener=null;abortController=null;idCounter=0;constructor(t){let e=t?.sequenceTimeout,i=typeof e=="number"&&Number.isFinite(e)&&e>0?Math.min(e,1e4):800;this.options={defaultScope:t?.defaultScope||"global",sequenceTimeout:i,target:t?.target||(typeof window<"u"?window:{}),onError:t?.onError},this.scopeStack=[this.options.defaultScope],this.initListener()}static isEditable(t){if(!t||typeof t.tagName!="string")return!1;let e=t,i=e.tagName.toUpperCase();if(i==="INPUT"){let n=e.type?.toLowerCase()||"text";return!["button","checkbox","radio","submit","reset","range","color","file","image"].includes(n)}if(i==="TEXTAREA"||i==="SELECT"||e.isContentEditable||e.getAttribute("contenteditable")==="true"||e.getAttribute("contenteditable")==="plaintext-only"||e.getAttribute("contenteditable")==="")return!0;let s=e.getAttribute("role");return!!(s==="textbox"||s==="searchbox"||s==="combobox"||s==="spinbutton"||typeof e.closest=="function"&&e.closest('[contenteditable="true"], [contenteditable="plaintext-only"], [contenteditable=""], [role="textbox"], [role="searchbox"], [role="combobox"], [role="spinbutton"]'))}static isPasswordField(t){if(!t||typeof t.tagName!="string")return!1;let e=t;return e.tagName.toUpperCase()==="INPUT"&&(e.type||"").toLowerCase()==="password"}bind(t){let e=Array.isArray(t)?t:[t],i=[];for(let s of e){if(!s.combo||typeof s.handler!="function")continue;let n=`wulf_shortcut_${++this.idCounter}`,o=D.parseCombo(s.combo),r=o.length>1,a=D.format(s.combo),l={...s,id:n,scope:s.scope||"global",category:s.category||"G\xE9n\xE9ral",allowInEditable:s.allowInEditable??!1,preventDefault:s.preventDefault??!0,stopPropagation:s.stopPropagation??!0,priority:s.priority??0,formattedCombo:a,normalizedSteps:o,isSequence:r};this.shortcuts.set(n,l),i.push(n)}return()=>{for(let s of i)this.shortcuts.delete(s)}}unbind(t,e){if(typeof t!="string"||!t.trim())return;let i=D.format(t);for(let[s,n]of this.shortcuts.entries())(n.formattedCombo===i||n.combo.trim().toLowerCase()===t.trim().toLowerCase())&&(!e||n.scope===e)&&this.shortcuts.delete(s)}pushScope(t){if(t&&typeof t=="string"){if(this.scopeStack.length>=64)return;this.scopeStack.push(t),this.clearSequenceBuffer()}}popScope(t){if(this.scopeStack.length<=1)return this.scopeStack[0];if(t){if(this.getScope()===t){let i=this.scopeStack.pop();return this.clearSequenceBuffer(),i}return}let e=this.scopeStack.pop();return this.clearSequenceBuffer(),e}setScope(t){this.scopeStack=[t||this.options.defaultScope],this.clearSequenceBuffer()}getScope(){return this.scopeStack[this.scopeStack.length-1]||this.options.defaultScope}getScopeStack(){return[...this.scopeStack]}pause(){this.isListening=!1,this.clearSequenceBuffer()}resume(){this.isListening=!0}isActive(){return this.isListening}getRegistry(t){let e=[];for(let i of this.shortcuts.values())(!t||i.scope===t||i.scope==="*")&&e.push({...i});return e}attachAria(t,e){if(t&&typeof t.setAttribute=="function"){let i=D.toAriaKeyShortcuts(e);i?t.setAttribute("aria-keyshortcuts",i):typeof t.removeAttribute=="function"&&t.removeAttribute("aria-keyshortcuts")}}static format(t,e){return D.format(t,e)}destroy(){this.pause(),this.removeListener(),this.shortcuts.clear(),this.scopeStack=[],this.clearSequenceBuffer()}initListener(){if(typeof window>"u"||!this.options.target)return;this.abortController=new AbortController,this.boundListener=e=>this.handleKeyDown(e);let t=this.options.target;typeof t.addEventListener=="function"&&t.addEventListener("keydown",this.boundListener,{capture:!1,signal:this.abortController.signal})}removeListener(){if(this.abortController)this.abortController.abort(),this.abortController=null;else if(this.boundListener&&this.options.target){let t=this.options.target;typeof t.removeEventListener=="function"&&t.removeEventListener("keydown",this.boundListener,!1)}this.boundListener=null}handleKeyDown(t){if(!this.isListening||H(t))return;let e=(t.key||"").toLowerCase();if(["control","alt","shift","meta"].includes(e))return;let i=this.getScope(),s=typeof t.composedPath=="function"?t.composedPath():[],n=s.length>0?s[0]:t.target,o=u.isEditable(n)||u.isEditable(t.target),r=u.isPasswordField(n)||u.isPasswordField(t.target),a={ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey,meta:t.metaKey,key:D.normalizeKeyName(t.key||"")},l=t.timeStamp>0?t.timeStamp:typeof performance<"u"?performance.now():Date.now();if(this.sequenceBuffer.length>0){let f=this.sequenceBuffer[this.sequenceBuffer.length-1];l-f.timestamp>this.options.sequenceTimeout&&this.clearSequenceBuffer()}let d=this.getActiveShortcuts(i,o,r),c=[...this.sequenceBuffer.map(f=>f.step),a],h=this.findMatchingSequence(d,c);if(h){this.clearSequenceBuffer(),this.executeShortcut(h,t,i,!0);return}if(this.isPrefixOfAnySequence(d,c)){this.sequenceBuffer.push({step:a,timestamp:l}),this.resetSequenceTimer(),t.key.length===1&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&!o&&t.preventDefault();return}this.clearSequenceBuffer();let p=this.findMatchingChord(d,a,t);p&&this.executeShortcut(p,t,i,!1)}getActiveShortcuts(t,e,i=!1){let s=[];for(let n of this.shortcuts.values())if(!(n.scope!==t&&n.scope!=="*")&&!(e&&!n.allowInEditable)){if(i){if(n.isSequence)continue;let o=n.normalizedSteps[0];if(o&&o.key.length===1){let r=!o.ctrl&&!o.alt&&!o.meta,a=o.ctrl&&o.alt&&!o.meta||o.alt&&!o.ctrl&&!o.meta;if(r||a)continue}}s.push(n)}return s.sort((n,o)=>(o.priority??0)-(n.priority??0))}stepMatches(t,e,i){if(t.ctrl!==e.ctrl||t.alt!==e.alt||t.meta!==e.meta)return!1;let s=typeof i?.key=="string"?i.key:"";if(!(t.key===e.key||s!==""&&t.key===s.toLowerCase()))return!1;if(t.shift===e.shift)return!0;if(!t.shift&&e.shift){let o=t.key.length===1&&!/^[a-z]$/i.test(t.key);if(s!==""&&s===t.key||o&&e.key===t.key)return!0}return!1}findMatchingChord(t,e,i){for(let s of t){if(s.isSequence||s.normalizedSteps.length!==1)continue;let n=s.normalizedSteps[0];if(this.stepMatches(n,e,i))return s}return null}findMatchingSequence(t,e){for(let i of t){if(!i.isSequence||i.normalizedSteps.length!==e.length)continue;let s=!0;for(let n=0;n<e.length;n++)if(!this.stepMatches(i.normalizedSteps[n],e[n])){s=!1;break}if(s)return i}return null}isPrefixOfAnySequence(t,e){for(let i of t){if(!i.isSequence||i.normalizedSteps.length<=e.length)continue;let s=!0;for(let n=0;n<e.length;n++)if(!this.stepMatches(i.normalizedSteps[n],e[n])){s=!1;break}if(s)return!0}return!1}executeShortcut(t,e,i,s){t.preventDefault&&e.preventDefault(),t.stopPropagation&&e.stopPropagation();let n={combo:t.combo,formattedCombo:t.formattedCombo,scope:i,target:e.target,isSequence:s};try{t.handler(e,n)}catch(o){this.options.onError?this.options.onError(o instanceof Error?o:new Error(String(o)),t.combo):console.error(`[Wulf.Shortcut] Erreur lors de l'ex\xE9cution du raccourci "${t.combo}":`,o)}}resetSequenceTimer(){this.sequenceTimer&&clearTimeout(this.sequenceTimer),this.sequenceTimer=setTimeout(()=>{this.clearSequenceBuffer()},this.options.sequenceTimeout)}clearSequenceBuffer(){this.sequenceBuffer=[],this.sequenceTimer&&(clearTimeout(this.sequenceTimer),this.sequenceTimer=null)}};var Ut=R();Ut&&(Ut.Shortcut=Object.assign(B,{ShortcutManager:B,ShortcutFormatter:D}));return Zt(ue);})();
|
|
5
|
+
if (typeof window !== "undefined") { var __w = window.Wulf; if (!__w || typeof __w !== "object" || (typeof Node !== "undefined" && __w instanceof Node) || (typeof HTMLCollection !== "undefined" && __w instanceof HTMLCollection)) { __w = {}; window.Wulf = __w; } if (typeof __WulfIIFE !== "undefined" && __WulfIIFE) { for (var k in __WulfIIFE) { if (Object.hasOwn(__WulfIIFE, k) && k !== "__proto__" && k !== "constructor" && k !== "prototype" && __w[k] === undefined) { try { Object.defineProperty(__w, k, { value: __WulfIIFE[k], writable: true, configurable: true, enumerable: true }); } catch (_) { try { __w[k] = __WulfIIFE[k]; } catch (__) {} } } } } }
|
|
6
6
|
//# sourceMappingURL=index.global.min.js.map
|