wulf.js 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/README.md +217 -11
  2. package/changelog.md +60 -0
  3. package/dist/anchor.esm.js +9 -0
  4. package/dist/anchor.esm.js.map +7 -0
  5. package/dist/anchor.global.js +695 -0
  6. package/dist/anchor.global.js.map +7 -0
  7. package/dist/anchor.global.min.js +6 -0
  8. package/dist/anchor.global.min.js.map +7 -0
  9. package/dist/autosize.css +1 -0
  10. package/dist/autosize.css.map +7 -0
  11. package/dist/autosize.esm.js +10 -0
  12. package/dist/autosize.esm.js.map +7 -0
  13. package/dist/autosize.global.js +657 -0
  14. package/dist/autosize.global.js.map +7 -0
  15. package/dist/autosize.global.min.js +6 -0
  16. package/dist/autosize.global.min.js.map +7 -0
  17. package/dist/autosize.layered.css +1 -0
  18. package/dist/autosize.layered.css.map +7 -0
  19. package/dist/chunks/chunk-22AIMRD5.js +119 -0
  20. package/dist/chunks/chunk-22AIMRD5.js.map +7 -0
  21. package/dist/chunks/chunk-5N2IRGDM.js +766 -0
  22. package/dist/chunks/chunk-5N2IRGDM.js.map +7 -0
  23. package/dist/chunks/chunk-72FVCNNZ.js +863 -0
  24. package/dist/chunks/chunk-72FVCNNZ.js.map +7 -0
  25. package/dist/chunks/chunk-AXZYYW7H.js +865 -0
  26. package/dist/chunks/chunk-AXZYYW7H.js.map +7 -0
  27. package/dist/chunks/chunk-CM3SBIVQ.js +1116 -0
  28. package/dist/chunks/chunk-CM3SBIVQ.js.map +7 -0
  29. package/dist/chunks/chunk-H4GRLGQ3.js +578 -0
  30. package/dist/chunks/chunk-H4GRLGQ3.js.map +7 -0
  31. package/dist/chunks/chunk-ITRU2RFV.js +1195 -0
  32. package/dist/chunks/chunk-ITRU2RFV.js.map +7 -0
  33. package/dist/chunks/chunk-NLUQZEL4.js +1029 -0
  34. package/dist/chunks/chunk-NLUQZEL4.js.map +7 -0
  35. package/dist/chunks/chunk-QV46A7FV.js +197 -0
  36. package/dist/chunks/chunk-QV46A7FV.js.map +7 -0
  37. package/dist/chunks/chunk-SXLUXN6W.js +612 -0
  38. package/dist/chunks/chunk-SXLUXN6W.js.map +7 -0
  39. package/dist/chunks/chunk-T2H4EJCW.js +621 -0
  40. package/dist/chunks/chunk-T2H4EJCW.js.map +7 -0
  41. package/dist/chunks/chunk-TILLYEF2.js +6044 -0
  42. package/dist/chunks/chunk-TILLYEF2.js.map +7 -0
  43. package/dist/chunks/chunk-VJO22BAT.js +72 -0
  44. package/dist/chunks/chunk-VJO22BAT.js.map +7 -0
  45. package/dist/chunks/chunk-ZGUU6DMM.js +77 -0
  46. package/dist/chunks/chunk-ZGUU6DMM.js.map +7 -0
  47. package/dist/focus-trap.esm.js +6 -536
  48. package/dist/focus-trap.esm.js.map +3 -3
  49. package/dist/focus-trap.global.js +260 -87
  50. package/dist/focus-trap.global.js.map +3 -3
  51. package/dist/focus-trap.global.min.js +4 -4
  52. package/dist/focus-trap.global.min.js.map +4 -4
  53. package/dist/index.esm.js +79 -10069
  54. package/dist/index.esm.js.map +4 -4
  55. package/dist/index.global.js +4192 -355
  56. package/dist/index.global.js.map +4 -4
  57. package/dist/index.global.min.js +6 -3
  58. package/dist/index.global.min.js.map +4 -4
  59. package/dist/mask.esm.js +16 -6094
  60. package/dist/mask.esm.js.map +4 -4
  61. package/dist/mask.global.js +44 -55
  62. package/dist/mask.global.js.map +3 -3
  63. package/dist/mask.global.min.js +3 -3
  64. package/dist/mask.global.min.js.map +4 -4
  65. package/dist/masonry.esm.js +15 -1067
  66. package/dist/masonry.esm.js.map +4 -4
  67. package/dist/masonry.global.js +229 -148
  68. package/dist/masonry.global.js.map +3 -3
  69. package/dist/masonry.global.min.js +4 -4
  70. package/dist/masonry.global.min.js.map +4 -4
  71. package/dist/scroll.css +1 -1
  72. package/dist/scroll.css.map +2 -2
  73. package/dist/scroll.esm.js +14 -1175
  74. package/dist/scroll.esm.js.map +3 -3
  75. package/dist/scroll.global.js +171 -88
  76. package/dist/scroll.global.js.map +3 -3
  77. package/dist/scroll.global.min.js +3 -3
  78. package/dist/scroll.global.min.js.map +4 -4
  79. package/dist/scroll.layered.css +1 -1
  80. package/dist/scroll.layered.css.map +2 -2
  81. package/dist/shortcut.esm.js +6 -741
  82. package/dist/shortcut.esm.js.map +4 -4
  83. package/dist/shortcut.global.js +225 -58
  84. package/dist/shortcut.global.js.map +3 -3
  85. package/dist/shortcut.global.min.js +8 -2
  86. package/dist/shortcut.global.min.js.map +4 -4
  87. package/dist/size-report.json +319 -0
  88. package/dist/sortable.css +1 -0
  89. package/dist/sortable.css.map +7 -0
  90. package/dist/sortable.esm.js +22 -0
  91. package/dist/sortable.esm.js.map +7 -0
  92. package/dist/sortable.global.js +1477 -0
  93. package/dist/sortable.global.js.map +7 -0
  94. package/dist/sortable.global.min.js +6 -0
  95. package/dist/sortable.global.min.js.map +7 -0
  96. package/dist/sortable.layered.css +1 -0
  97. package/dist/sortable.layered.css.map +7 -0
  98. package/dist/sri-manifest.json +64 -0
  99. package/dist/toast.css +1 -1
  100. package/dist/toast.css.map +2 -2
  101. package/dist/toast.esm.js +19 -1129
  102. package/dist/toast.esm.js.map +3 -3
  103. package/dist/toast.global.js +386 -104
  104. package/dist/toast.global.js.map +3 -3
  105. package/dist/toast.global.min.js +4 -4
  106. package/dist/toast.global.min.js.map +4 -4
  107. package/dist/toast.layered.css +1 -1
  108. package/dist/toast.layered.css.map +2 -2
  109. package/dist/types/anchor/Anchor.d.ts +41 -0
  110. package/dist/types/anchor/index.d.ts +3 -0
  111. package/dist/types/anchor/types.d.ts +115 -0
  112. package/dist/types/autosize/Autosize.d.ts +71 -0
  113. package/dist/types/autosize/index.d.ts +3 -0
  114. package/dist/types/autosize/types.d.ts +66 -0
  115. package/dist/types/common/AuditableComponent.d.ts +1 -1
  116. package/dist/types/common/dom.d.ts +5 -0
  117. package/dist/types/common/registry.d.ts +40 -0
  118. package/dist/types/focus-trap/FocusTrap.d.ts +8 -3
  119. package/dist/types/index.d.ts +13 -1
  120. package/dist/types/mask/paste.d.ts +2 -5
  121. package/dist/types/masonry/Masonry.d.ts +2 -0
  122. package/dist/types/scroll/ScrollBlock.d.ts +2 -0
  123. package/dist/types/scroll/types.d.ts +6 -0
  124. package/dist/types/shortcut/ShortcutManager.d.ts +16 -3
  125. package/dist/types/shortcut/types.d.ts +5 -0
  126. package/dist/types/sortable/Sortable.d.ts +75 -0
  127. package/dist/types/sortable/i18n/en.d.ts +2 -0
  128. package/dist/types/sortable/i18n/fr.d.ts +2 -0
  129. package/dist/types/sortable/i18n/index.d.ts +9 -0
  130. package/dist/types/sortable/i18n/types.d.ts +15 -0
  131. package/dist/types/sortable/index.d.ts +4 -0
  132. package/dist/types/sortable/types.d.ts +112 -0
  133. package/dist/types/toast/Toast.d.ts +6 -1
  134. package/dist/types/toast/ToastInstance.d.ts +7 -0
  135. package/dist/types/toast/ToastManager.d.ts +4 -2
  136. package/dist/types/toast/types.d.ts +27 -1
  137. package/dist/types/undo/UndoManager.d.ts +112 -0
  138. package/dist/types/undo/i18n/en.d.ts +2 -0
  139. package/dist/types/undo/i18n/fr.d.ts +2 -0
  140. package/dist/types/undo/i18n/index.d.ts +9 -0
  141. package/dist/types/undo/i18n/types.d.ts +6 -0
  142. package/dist/types/undo/index.d.ts +5 -0
  143. package/dist/types/undo/types.d.ts +106 -0
  144. package/dist/undo.esm.js +23 -0
  145. package/dist/undo.esm.js.map +7 -0
  146. package/dist/undo.global.js +1029 -0
  147. package/dist/undo.global.js.map +7 -0
  148. package/dist/undo.global.min.js +6 -0
  149. package/dist/undo.global.min.js.map +7 -0
  150. package/package.json +54 -5
@@ -1,6 +1,6 @@
1
- "use strict";var __WulfIIFE=(()=>{var A=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var H=(r,e)=>{for(var t in e)A(r,t,{get:e[t],enumerable:!0})},j=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of F(e))!D.call(r,i)&&i!==t&&A(r,i,{get:()=>e[i],enumerable:!(n=_(e,i))||n.enumerable});return r};var $=r=>j(A({},"__esModule",{value:!0}),r);var Y={};H(Y,{LocalizedComponent:()=>b,Toast:()=>T,ToastInstance:()=>I,ToastManager:()=>g,createI18nManager:()=>E,default:()=>U,toastEn:()=>M,toastFr:()=>L,toastI18n:()=>f});function S(){if(typeof window>"u")return null;let r=window,e=r.Wulf;if(!e||typeof e!="object"||typeof Node<"u"&&e instanceof Node||typeof HTMLCollection<"u"&&e instanceof HTMLCollection){let t={};return r.Wulf=t,t}return e}function x(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function N(r,e,t){let n=Number.isFinite(e)?Math.min(e,6e4):300;if(t?.aborted||n<=0||x())return Promise.resolve();let i=typeof r.getAnimations=="function"?r.getAnimations().filter(s=>{if(s.playState!=="running")return!1;let l=s.effect?.getComputedTiming?.();return l?Number.isFinite(l.endTime):!0}):[];return i.length===0?Promise.resolve():new Promise(s=>{let l=!1,c=null,o=()=>{l||(l=!0,c!==null&&(clearTimeout(c),c=null),t?.removeEventListener("abort",o),s())};t?.addEventListener("abort",o,{once:!0}),c=setTimeout(o,n),Promise.allSettled(i.map(a=>a.finished)).then(o)})}var z=new Set(["__proto__","constructor","prototype"]);function y(r){return!!r&&!z.has(r)}function w(r){let e=String(r??"").trim().toLowerCase().replace(/_/g,"-");return y(e)?e:""}function W(r){let e=r.indexOf("-"),t=e>0?r.slice(0,e):null;return t&&y(t)?t:null}function m(r,e){if(!e||typeof e!="object")return r;for(let t of Object.keys(e))y(String(t))&&Object.hasOwn(e,t)&&e[t]!==void 0&&(r[t]=e[t]);return r}function E(r,e){let t=w(r)||"fr",n=Object.create(null);for(let[o,a]of Object.entries(e)){let u=w(o);u&&(n[u]=m(Object.create(null),a))}let i=t,s=Object.create(null);for(let[o,a]of Object.entries(n))s[o]=m(Object.create(null),a);let l=Object.create(null);function c(){let o=[];if(y(i)){let u=s[i];u&&o.push(u)}let a=W(i);return a&&s[a]&&o.push(s[a]),o}return{setLocale(o){if(o&&typeof o=="string"&&o.trim()){let a=w(o);a&&(i=a)}},getLocale(){return i},registerLocale(o,a){if(!o||typeof o!="string"||!o.trim()||!a)return;let u=w(o);if(!u)return;let d=m(Object.create(null),s[u]);s[u]=m(d,a)},setI18n(o){if(!o||typeof o!="object")return;let a=m(Object.create(null),l);l=m(a,o)},t(o,a){if(!y(String(o)))return"";if(a&&typeof a=="object"&&Object.hasOwn(a,o)&&a[o]!==void 0)return String(a[o]);if(l[o]!==void 0)return String(l[o]);for(let d of c())if(d[o]!==void 0)return String(d[o]);let u=s[t]||n[t];return u&&u[o]!==void 0?String(u[o]):String(o)},getAll(o){let a={},u=s[t]||n[t];m(a,u);let d=c().reverse();for(let p of d)m(a,p);return m(a,l),m(a,o),a},reset(){i=t,l=Object.create(null),s=Object.create(null);for(let[o,a]of Object.entries(n))s[o]=m(Object.create(null),a)}}}var v=class{getAuditDisableHint(){return"Passez { audit: false } dans les options pour d\xE9sactiver cet avertissement"}runAuditWarning(e=!0){if(!e)return[];let t=this.audit();return t.length>0&&typeof console<"u"&&typeof console.warn=="function"&&console.warn(`[${this.getAuditPrefix()}] Audit d'accessibilit\xE9 \u2014 ${t.length} contrainte(s) manquante(s) sur ${this.getAuditTargetLabel()} :
2
- `+t.map(n=>` - ${n}`).join(`
1
+ "use strict";var __WulfIIFE=(()=>{var L=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var J=Object.prototype.hasOwnProperty;var Q=(a,e)=>{for(var t in e)L(a,t,{get:e[t],enumerable:!0})},X=(a,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Z(e))!J.call(a,i)&&i!==t&&L(a,i,{get:()=>e[i],enumerable:!(s=q(e,i))||s.enumerable});return a};var ee=a=>X(L({},"__esModule",{value:!0}),a);var le={};Q(le,{LocalizedComponent:()=>v,Toast:()=>P,ToastInstance:()=>A,ToastManager:()=>T,createI18nManager:()=>M,default:()=>ae,isSafeCssValue:()=>C,toastEn:()=>S,toastFr:()=>k,toastI18n:()=>m});var te=new Set(["__proto__","constructor","prototype"]);function w(a){return!!a&&!te.has(a)}function E(a){let e=String(a??"").trim().toLowerCase().replace(/_/g,"-");return w(e)?e:""}function ie(a){let e=a.indexOf("-"),t=e>0?a.slice(0,e):null;return t&&w(t)?t:null}function p(a,e){if(!e||typeof e!="object")return a;for(let t of Object.keys(e))w(String(t))&&Object.hasOwn(e,t)&&e[t]!==void 0&&(a[t]=e[t]);return a}function M(a,e){let t=E(a)||"fr",s=Object.create(null);for(let[r,l]of Object.entries(e)){let u=E(r);u&&(s[u]=p(Object.create(null),l))}let i=t,n=Object.create(null);for(let[r,l]of Object.entries(s))n[r]=p(Object.create(null),l);let o=Object.create(null);function c(){let r=[];if(w(i)){let u=n[i];u&&r.push(u)}let l=ie(i);return l&&n[l]&&r.push(n[l]),r}return{setLocale(r){if(r&&typeof r=="string"&&r.trim()){let l=E(r);l&&(i=l)}},getLocale(){return i},registerLocale(r,l){if(!r||typeof r!="string"||!r.trim()||!l)return;let u=E(r);if(!u)return;let d=p(Object.create(null),n[u]);n[u]=p(d,l)},setI18n(r){if(!r||typeof r!="object")return;let l=p(Object.create(null),o);o=p(l,r)},t(r,l){if(!w(String(r)))return"";if(l&&typeof l=="object"&&Object.hasOwn(l,r)&&l[r]!==void 0)return String(l[r]);if(o[r]!==void 0)return String(o[r]);for(let d of c())if(d[r]!==void 0)return String(d[r]);let u=n[t]||s[t];return u&&u[r]!==void 0?String(u[r]):String(r)},getAll(r){let l={},u=n[t]||s[t];p(l,u);let d=c().reverse();for(let f of d)p(l,f);return p(l,o),p(l,r),l},reset(){i=t,o=Object.create(null),n=Object.create(null);for(let[r,l]of Object.entries(s))n[r]=p(Object.create(null),l)}}}var b=class{getAuditDisableHint(){return"Passez { audit: false } dans les options pour d\xE9sactiver cet avertissement"}runAuditWarning(e=!0){if(!e)return[];let t=this.audit();return t.length>0&&typeof console<"u"&&typeof console.warn=="function"&&console.warn(`[${this.getAuditPrefix()}] Audit d'accessibilit\xE9 \u2014 ${t.length} contrainte(s) manquante(s) sur ${this.getAuditTargetLabel()} :
2
+ `+t.map(s=>` - ${s}`).join(`
3
3
  `)+`
4
- (${this.getAuditDisableHint()})`),t}checkAriaIdReferences(e,t,n,i=!1){let s=e.getAttribute(t)?.trim();if(!s)return!1;let l=e.ownerDocument||document,c=typeof e.getRootNode=="function"?e.getRootNode():l,o=s.split(/\s+/).filter(Boolean),a=o.map(d=>typeof ShadowRoot<"u"&&c instanceof ShadowRoot?c.getElementById(d):l.getElementById(d));return o.length>0&&a.every(d=>!!d)?i&&!a.some(p=>p?(p.textContent?.trim()||p.getAttribute("aria-label")?.trim()||"").length>0:!1)?(n.push(`Attribut ${t}="${s}" invalide : l'\xE9l\xE9ment cible ne contient aucun texte accessible.`),!1):!0:(n.push(`Attribut ${t}="${s}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`),!1)}};var b=class extends v{static _i18n;static setLocale(e){this._i18n&&this._i18n.setLocale(e)}static getLocale(){return this._i18n?this._i18n.getLocale():""}static registerLocale(e,t){this._i18n&&this._i18n.registerLocale(e,t)}static setI18n(e){this._i18n&&this._i18n.setI18n(e)}static getI18n(){return this._i18n?this._i18n.getAll():{}}static resetI18n(){this._i18n&&this._i18n.reset()}static t(e,t){return this._i18n?this._i18n.t(e,t):String(e)}i18nOverrides;constructor(e){super(),this.i18nOverrides=e}t(e){let t=this.constructor;return t._i18n?t._i18n.t(e,this.i18nOverrides):String(e)}};var L={closeButton:"Fermer la notification",notificationsRegion:"Notifications"};var M={closeButton:"Close notification",notificationsRegion:"Notifications"};var f=E("fr",{fr:L,en:M});var V=1,O=5e3;function C(r){if(!r||typeof r!="string"||r.length>128)return!1;let e=r.trim();return!e||/[\u0000-\u001F\u007F;{}<>\\]|(?:url|image-set|-webkit-image-set|image|src|expression|attr|env)\s*\(/i.test(e)?!1:typeof CSS<"u"&&typeof CSS.supports=="function"?CSS.supports("color",e)||CSS.supports("background-color",e):!0}function q(r){return r.slice(0,128).trim().split(/\s+/).filter(e=>/^[a-zA-Z0-9_-]+$/.test(e)&&!e.startsWith("wulf-toast")).slice(0,8).join(" ")}var I=class extends v{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(e,t){super(),this.id=`wulf-toast-${V++}`,this.options=Object.freeze({...e}),this.onDismissCallback=t,this.previousActiveElement=typeof document<"u"&&document.activeElement instanceof HTMLElement?document.activeElement:null;let n=e.duration===void 0?O:e.duration;typeof n=="number"&&Number.isFinite(n)&&n>0?(this.remainingTime=Math.min(n,2147483647),this.hasDuration=!0):(this.remainingTime=0,this.hasDuration=!1),this.element=this.createDOM(),this.bindEvents(),this.runAuditWarning(e.audit!==!1)}get isClosed(){return this._isClosed}getPreviousActiveElement(){return this.previousActiveElement}audit(){let e=[],t=!!(this.options.title&&this.options.title.trim().length>0),n=!!(this.options.message&&this.options.message.trim().length>0);!t&&!n&&e.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 i=this.options.duration===void 0?O:this.options.duration;typeof i=="number"&&i>0&&i<5e3&&e.push(`Dur\xE9e d'affichage trop courte (duration: ${i}ms) : pr\xE9voyez au moins 5000ms ou duration: false pour laisser le temps de lecture aux utilisateurs (WCAG 2.2.1).`);let s=this.options.closable??!0;return(i===!1||typeof i=="number"&&i<=0)&&!s&&e.push("Notification persistante impossible \xE0 fermer au clavier : activez closable: true lorsque duration est d\xE9sactiv\xE9 (WCAG 2.1.1)."),e}getAuditPrefix(){return"Wulf.Toast"}getAuditTargetLabel(){return`#${this.id}`}createDOM(){let e=document.createElement("div");if(e.id=this.id,e.className="wulf-toast",e.setAttribute("data-toast-role",this.options.role==="alert"?"alert":"status"),this.options.backgroundColor&&C(this.options.backgroundColor)&&e.style.setProperty("--wulf-toast-bg",this.options.backgroundColor.trim()),this.options.titleColor&&C(this.options.titleColor)&&e.style.setProperty("--wulf-toast-title-color",this.options.titleColor.trim()),this.options.textColor&&C(this.options.textColor)&&e.style.setProperty("--wulf-toast-text-color",this.options.textColor.trim()),this.options.iconColor&&C(this.options.iconColor)&&e.style.setProperty("--wulf-toast-icon-color",this.options.iconColor.trim()),this.options.closeButtonColor&&C(this.options.closeButtonColor)&&e.style.setProperty("--wulf-toast-close-color",this.options.closeButtonColor.trim()),this.options.icon&&typeof this.options.icon=="string"&&this.options.icon.trim()!==""){let i=q(this.options.icon);if(i){let s=document.createElement("span");s.className=`wulf-toast-icon ${i}`,s.setAttribute("aria-hidden","true"),e.appendChild(s)}}let t=document.createElement("div");if(t.className="wulf-toast-content",this.options.title&&this.options.title.trim()!==""){let i=document.createElement("div");i.className="wulf-toast-title",this.appendTextWithLineBreaks(i,this.options.title),t.appendChild(i)}if(this.options.message&&this.options.message.trim()!==""){let i=document.createElement("div");i.className="wulf-toast-message",this.appendTextWithLineBreaks(i,this.options.message),t.appendChild(i)}if(e.appendChild(t),this.options.closable??!0){let i=document.createElement("button");i.type="button",i.className="wulf-toast-close",i.setAttribute("aria-label",f.t("closeButton",this.options.i18n));let s=document.createElement("span");s.className="wulf-toast-close-icon",s.setAttribute("aria-hidden","true"),s.textContent="\xD7",i.appendChild(s),i.addEventListener("click",l=>{l.stopPropagation(),this.close("close-button")},{signal:this.eventsAbortController.signal}),e.appendChild(i)}if(this.options.progressBar&&this.remainingTime>0){e.style.setProperty("--wulf-toast-duration",`${this.remainingTime}ms`);let i=document.createElement("div");i.className="wulf-toast-progress",i.setAttribute("aria-hidden","true"),e.appendChild(i)}return e}appendTextWithLineBreaks(e,t){String(t??"").slice(0,4096).split(/\r\n|\r|\n/).slice(0,100).forEach((s,l)=>{l>0&&e.appendChild(document.createElement("br")),e.appendChild(document.createTextNode(s))})}bindEvents(){let{signal:e}=this.eventsAbortController;this.element.addEventListener("click",t=>{this.options.onClick&&this.options.onClick(this,t),this.options.closeOnClick&&this.close("toast-click")},{signal:e}),this.element.addEventListener("mouseenter",()=>this.pauseTimer("hover"),{signal:e}),this.element.addEventListener("mouseleave",()=>this.resumeTimer("hover"),{signal:e}),this.element.addEventListener("focusin",()=>this.pauseTimer("focus"),{signal:e}),this.element.addEventListener("focusout",t=>{let n=t.relatedTarget;if(!(n&&this.element.contains(n))){if(this.isPendingFocusDismiss&&!this._isClosed){this.isPendingFocusDismiss=!1,this.close("timeout");return}this.resumeTimer("focus")}},{signal:e}),this.element.addEventListener("keydown",t=>{t.key==="Escape"&&(this.options.closable??!0)&&(t.stopPropagation(),this.close("close-button"))},{signal:e}),typeof document<"u"&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.pauseTimer("visibility"):this.resumeTimer("visibility")},{signal:e})}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(e="interaction"){if(this._isClosed||!this.hasDuration||this.remainingTime<=0)return;let t=this.isPaused;if(e==="visibility"?this.isPausedByVisibility=!0:e==="focus"?this.isPausedByFocus=!0:this.isPausedByHover=!0,!t){if(this.timerId!==null){window.clearTimeout(this.timerId),this.timerId=null;let n=performance.now()-this.timerStartTime;this.remainingTime=Math.max(0,this.remainingTime-n)}this.element.classList.add("is-paused")}}resumeTimer(e="interaction"){if(!(this._isClosed||!this.hasDuration)&&(e==="visibility"?this.isPausedByVisibility=!1:e==="focus"?this.isPausedByFocus=!1:e==="hover"?(this.isPausedByHover=!1,typeof document<"u"&&this.element.contains(document.activeElement)&&(this.isPausedByFocus=!0)):(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(e){this._isFinalized||(this._isFinalized=!0,this.eventsAbortController.abort(),this.onDismissCallback&&this.onDismissCallback(this,e),this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.options.onClose&&this.options.onClose(this,e))}destroyImmediate(e="replace"){this._isClosed=!0,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),this.disposeAbortController.abort(),this.finalizeDismiss(e)}close(e="programmatic",t=!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(t?"wulf-toast-hiding-fast":"wulf-toast-hiding"),x()?(this.finalizeDismiss(e),this.closePromise=Promise.resolve(),this.closePromise):(this.closePromise=N(this.element,t?90:300,this.disposeAbortController.signal).then(()=>{this.disposeAbortController.signal.aborted||this.finalizeDismiss(e)}),this.closePromise))}};var K=new Set(["top-left","top-center","top-right","bottom-left","bottom-center","bottom-right"]);function k(r){return r&&K.has(r)?r:"top-right"}var G='button:not([disabled]), [href], [tabindex]:not([tabindex="-1"])',g=class r{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(e){try{if(e.matches(":popover-open"))return!0}catch{}return e.classList.contains(":popover-open")}replaceTokens=new Map;pendingReplacements=new Set;constructor(){}static getInstance(){return r.instance||(r.instance=new r),r.instance}add(e){let t=k(e.options.position),n=this.activeToasts.get(t);n||(n=[],this.activeToasts.set(t,n));let i=e.options.maxToasts,s=typeof i=="number"&&Number.isFinite(i)&&i>0?Math.min(50,Math.max(1,Math.floor(i))):5;if(e.options.replace&&n.length>0){let l=[...n],c=(this.replaceTokens.get(t)||0)+1;this.replaceTokens.set(t,c),this.pendingReplacements.add(t);let o=l.map(a=>a.close("replace",!0));Promise.all(o).then(()=>{if(this.pendingReplacements.delete(t),this.replaceTokens.get(t)!==c){e.destroyImmediate("replace");return}this.mountToast(e,t,s)});return}if(this.pendingReplacements.has(t)&&(this.replaceTokens.set(t,(this.replaceTokens.get(t)||0)+1),this.pendingReplacements.delete(t)),n.length>=s){let l=n.length-s+1,c=n.splice(0,l);for(let o of c)o.close("max-limit",!0)}this.mountToast(e,t,s)}mountToast(e,t,n=5){if(e.isClosed)return;let i=e.options.useTopLayer??!0,s=this.getOrCreateContainer(t,e,i),l=this.activeToasts.get(t);l||(l=[],this.activeToasts.set(t,l));let c=n+10;if(s.children.length>=c){let o=Array.from(s.children);for(let a of o){if(s.children.length<c)break;(a.classList.contains("wulf-toast-hiding")||a.classList.contains("wulf-toast-hiding-fast"))&&a.remove()}}if(i&&typeof s.showPopover=="function"&&s.getAttribute("popover")==="manual")try{let o=s;this.isPopoverOpen(s)||o.showPopover()}catch{s.removeAttribute("popover")}if(s.appendChild(e.element),l.push(e),this.announce(e),e.options.onOpen)try{e.options.onOpen(e)}catch(o){console.error("[Wulf.Toast] Erreur dans le callback onOpen:",o)}e.startTimer()}announce(e){let t=[e.options.title,e.options.message].filter(h=>typeof h=="string"&&h.trim().length>0).map(h=>h.trim());if(t.length===0)return;let n=t.join(". "),i=n.length>512?`${n.slice(0,509)}...`:n,s=e.options.role==="alert",l=document;if(typeof l.ariaNotify=="function")try{l.ariaNotify(i,{priority:s?"high":"normal"});return}catch{}let c=!this.announcerEl||!this.announcerEl.isConnected;this.ensureAnnouncer();let o=s?this.assertiveRegion:this.politeRegion;if(!o)return;s?(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)),o.textContent="";let a=s?this.lastAssertiveText:this.lastPoliteText,u=i;i===a?(this.announcerToggle=!this.announcerToggle,u=this.announcerToggle?`${i}\xA0`:i):this.announcerToggle=!1,s?this.lastAssertiveText=i:this.lastPoliteText=i;let d=c?120:50,p=window.setTimeout(()=>{let h=this.announceTimers.indexOf(p);if(h!==-1&&this.announceTimers.splice(h,1),s?this.assertiveAnnounceTimerId=null:this.politeAnnounceTimerId=null,o.isConnected){o.textContent=u;let P=window.setTimeout(()=>{let R=this.announceTimers.indexOf(P);R!==-1&&this.announceTimers.splice(R,1),o.isConnected&&o.textContent===u&&(o.textContent="")},4e3);this.announceTimers.push(P),s?this.assertiveClearTimerId=P:this.politeClearTimerId=P}},d);this.announceTimers.push(p),s?this.assertiveAnnounceTimerId=p:this.politeAnnounceTimerId=p}ensureAnnouncer(){if(this.announcerEl&&document.body.contains(this.announcerEl))return;let e=document.createElement("div");e.className="wulf-toast-announcer",e.setAttribute("data-wulf-toast-announcer","true");let t=document.createElement("div");t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true");let n=document.createElement("div");n.setAttribute("role","alert"),n.setAttribute("aria-live","assertive"),n.setAttribute("aria-atomic","true"),e.appendChild(t),e.appendChild(n),document.body.appendChild(e),this.announcerEl=e,this.politeRegion=t,this.assertiveRegion=n}handleFocusHandoff(e,t){if(!e.element.contains(document.activeElement))return;for(let i=t.length-1;i>=0;i--){let s=t[i];if(s===e||s.isClosed||!s.element.isConnected)continue;let l=s.element.querySelector(G);if(l){l.focus({preventScroll:!0});return}}let n=e.getPreviousActiveElement();if(n&&n.isConnected&&typeof n.focus=="function"&&!n.disabled&&!n.closest("[inert]")&&n.getAttribute("aria-hidden")!=="true")try{n.focus()}catch{}}remove(e,t){let n=k(e.options.position),i=this.activeToasts.get(n);if(i){let s=i.indexOf(e);if(s!==-1&&i.splice(s,1),this.handleFocusHandoff(e,i),e.element.parentNode&&e.element.parentNode.removeChild(e.element),i.length===0&&!this.pendingReplacements.has(n)){let l=this.containers.get(n);l&&(!l.firstChild||l.children.length===0)&&(this.disposeContainer(l),this.containers.delete(n),this.activeToasts.delete(n))}}else e.element.parentNode&&e.element.parentNode.removeChild(e.element)}disposeContainer(e){try{let t=e;typeof t.hidePopover=="function"&&this.isPopoverOpen(e)&&t.hidePopover()}catch{}e.parentNode&&e.parentNode.removeChild(e)}clearAll(e){let t=[];if(e){this.replaceTokens.set(e,(this.replaceTokens.get(e)||0)+1),this.pendingReplacements.delete(e);let n=this.activeToasts.get(e);if(n&&n.length>0){let i=[...n];for(let s of i)t.push(s.close("programmatic"))}else{let i=this.containers.get(e);i&&(!i.firstChild||i.children.length===0)&&(this.disposeContainer(i),this.containers.delete(e),this.activeToasts.delete(e))}}else{for(let i of this.replaceTokens.keys())this.replaceTokens.set(i,(this.replaceTokens.get(i)||0)+1);this.pendingReplacements.clear();for(let i of this.announceTimers)window.clearTimeout(i);this.announceTimers=[],this.politeAnnounceTimerId=null,this.assertiveAnnounceTimerId=null,this.politeClearTimerId=null,this.assertiveClearTimerId=null;let n=new Set([...Array.from(this.containers.keys()),...Array.from(this.activeToasts.keys())]);for(let i of n)t.push(this.clearAll(i))}return Promise.all(t).then(()=>{if(!e)for(let[n,i]of Array.from(this.containers.entries()))(!i.firstChild||i.children.length===0)&&(this.disposeContainer(i),this.containers.delete(n),this.activeToasts.delete(n))})}destroy(){for(let e of this.announceTimers)window.clearTimeout(e);this.announceTimers=[];for(let e of Array.from(this.activeToasts.values()))for(let t of[...e])t.destroyImmediate("programmatic");for(let e of Array.from(this.containers.values()))this.disposeContainer(e);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),r.instance=null}getOrCreateContainer(e,t,n){let i=this.containers.get(e);return(!i||!document.body.contains(i))&&(i=document.createElement("div"),i.className=`wulf-toast-container wulf-toast-${e}`,i.setAttribute("role","region"),i.setAttribute("aria-label",f.t("notificationsRegion",t.options.i18n)),n&&typeof i.showPopover=="function"&&i.setAttribute("popover","manual"),document.body.appendChild(i),this.containers.set(e,i)),i}};var T=class extends b{static _i18n=f;static i18n=f;audit(){return[]}getAuditPrefix(){return"Wulf.Toast"}getAuditTargetLabel(){return"Toast"}static show(e={}){let t=g.getInstance(),n=new I(e,(i,s)=>{t.remove(i,s)});return t.add(n),n}static clearAll(e){return g.getInstance().clearAll(e)}static destroy(){g.getInstance().destroy()}};var U=T,B=S();B&&(B.Toast=Object.assign(T,{Toast:T,i18n:f}));return $(Y);})();
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 (__) {} } } } } }
4
+ (${this.getAuditDisableHint()})`),t}checkAriaIdReferences(e,t,s,i=!1){let n=e.getAttribute(t)?.trim();if(!n)return!1;let o=e.ownerDocument||document,c=typeof e.getRootNode=="function"?e.getRootNode():o,r=n.split(/\s+/).filter(Boolean),l=r.map(d=>typeof ShadowRoot<"u"&&c instanceof ShadowRoot?c.getElementById(d):o.getElementById(d));return r.length>0&&l.every(d=>!!d)?i&&!l.some(f=>f?(f.textContent?.trim()||f.getAttribute("aria-label")?.trim()||"").length>0:!1)?(s.push(`Attribut ${t}="${n}" invalide : l'\xE9l\xE9ment cible ne contient aucun texte accessible.`),!1):!0:(s.push(`Attribut ${t}="${n}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`),!1)}};var v=class extends b{static _i18n;static setLocale(e){this._i18n&&this._i18n.setLocale(e)}static getLocale(){return this._i18n?this._i18n.getLocale():""}static registerLocale(e,t){this._i18n&&this._i18n.registerLocale(e,t)}static setI18n(e){this._i18n&&this._i18n.setI18n(e)}static getI18n(){return this._i18n?this._i18n.getAll():{}}static resetI18n(){this._i18n&&this._i18n.reset()}static t(e,t){return this._i18n?this._i18n.t(e,t):String(e)}i18nOverrides;constructor(e){super(),this.i18nOverrides=e}t(e){let t=this.constructor;return t._i18n?t._i18n.t(e,this.i18nOverrides):String(e)}};var k={closeButton:"Fermer la notification",notificationsRegion:"Notifications"};var S={closeButton:"Close notification",notificationsRegion:"Notifications"};var m=M("fr",{fr:k,en:S});function g(a,e=4096){let t=Math.max(0,e);return String(a??"").slice(0,t).replace(/[\u061C\u200B-\u200F\u202A-\u202E\u2066-\u2069\uFEFF]/g,"")}function y(a){if(typeof document>"u")return null;let e=(a??document).activeElement;for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e&&typeof e.focus=="function"?e:null}function O(a){return!!(a.isComposing||a.key==="Process"||a.key==="Enter"&&a.keyCode===229)}function R(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function D(a,e,t){let s=Number.isFinite(e)?Math.min(e,6e4):300;if(t?.aborted||s<=0||R())return Promise.resolve();let i=typeof a.getAnimations=="function"?a.getAnimations().filter(n=>{if(n.playState!=="running")return!1;let o=n.effect?.getComputedTiming?.();return o?Number.isFinite(o.endTime):!0}):[];return i.length===0?Promise.resolve():new Promise(n=>{let o=!1,c=null,r=()=>{o||(o=!0,c!==null&&(clearTimeout(c),c=null),t?.removeEventListener("abort",r),n())};t?.addEventListener("abort",r,{once:!0}),c=setTimeout(r,s),Promise.allSettled(i.map(l=>l.finished)).then(r)})}var ne=1,H=5e3,se=/^(?:#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})|(?:rgb|rgba|hsl|hsla|oklch|oklab|lch|lab)\(\s*(?:[+-]?(?:\d+\.?\d*|\.\d+)(?:%|deg|rad|grad|turn)?|none)(?:\s*[,/\s]\s*(?:[+-]?(?:\d+\.?\d*|\.\d+)(?:%|deg|rad|grad|turn)?|none)){2,3}\s*\)|[a-z]{3,20})$/i;function C(a){if(!a||typeof a!="string"||a.length>128)return!1;let e=a.trim();return!e||/[\u0000-\u001F\u007F;{}<>\\]|(?:url|image-set|-webkit-image-set|image|src|expression|attr|env|var)\s*\(/i.test(e)?!1:typeof CSS<"u"&&typeof CSS.supports=="function"?CSS.supports("color",e)||CSS.supports("background-color",e):se.test(e)}function oe(a){return a.slice(0,128).trim().split(/\s+/).filter(e=>/^[a-zA-Z0-9_-]+$/.test(e)&&!e.startsWith("wulf-toast")).slice(0,8).join(" ")}var A=class extends b{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;actionPending=!1;previousActiveElement=null;eventsAbortController=new AbortController;disposeAbortController=new AbortController;onDismissCallback;constructor(e,t){if(super(),typeof document>"u")throw new Error("[Wulf.Toast] Impossible d'instancier une notification Toast sans environnement DOM (document).");this.id=`wulf-toast-${ne++}`,this.options=Object.freeze({...e}),this.onDismissCallback=t,this.previousActiveElement=y();let s=e.duration===void 0?H:e.duration;typeof s=="number"&&Number.isFinite(s)&&s>0?(this.remainingTime=Math.min(s,2147483647),this.hasDuration=!0):(this.remainingTime=0,this.hasDuration=!1),this.element=this.createDOM(),this.bindEvents(),this.runAuditWarning(e.audit!==!1)}get isClosed(){return this._isClosed}getPreviousActiveElement(){return this.previousActiveElement}audit(){let e=[],t=!!(this.options.title&&this.options.title.trim().length>0),s=!!(this.options.message&&this.options.message.trim().length>0);!t&&!s&&e.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 i=this.options.duration===void 0?H:this.options.duration;typeof i=="number"&&i>0&&i<5e3&&e.push(`Dur\xE9e d'affichage trop courte (duration: ${i}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(i===!1||typeof i=="number"&&i<=0)&&!n&&e.push("Notification persistante impossible \xE0 fermer au clavier : activez closable: true lorsque duration est d\xE9sactiv\xE9 (WCAG 2.1.1)."),this.options.action&&(g(String(this.options.action.label??""),128).trim()||e.push("Bouton d'action invalide : action.label doit contenir un texte non vide (WCAG 4.1.2).")),e}getAuditPrefix(){return"Wulf.Toast"}getAuditTargetLabel(){return`#${this.id}`}createDOM(){let e=document.createElement("div");if(e.id=this.id,e.className="wulf-toast",e.setAttribute("data-toast-role",this.options.role==="alert"?"alert":"status"),this.options.backgroundColor&&C(this.options.backgroundColor)&&e.style.setProperty("--wulf-toast-bg",this.options.backgroundColor.trim()),this.options.titleColor&&C(this.options.titleColor)&&e.style.setProperty("--wulf-toast-title-color",this.options.titleColor.trim()),this.options.textColor&&C(this.options.textColor)&&e.style.setProperty("--wulf-toast-text-color",this.options.textColor.trim()),this.options.iconColor&&C(this.options.iconColor)&&e.style.setProperty("--wulf-toast-icon-color",this.options.iconColor.trim()),this.options.closeButtonColor&&C(this.options.closeButtonColor)&&e.style.setProperty("--wulf-toast-close-color",this.options.closeButtonColor.trim()),this.options.icon&&typeof this.options.icon=="string"&&this.options.icon.trim()!==""){let o=oe(this.options.icon);if(o){let c=document.createElement("span");c.className=`wulf-toast-icon ${o}`,c.setAttribute("aria-hidden","true"),e.appendChild(c)}}let t=document.createElement("div"),s=!!(this.options.onClick||this.options.closeOnClick);if(t.className=s?"wulf-toast-content wulf-toast-content--interactive":"wulf-toast-content",s&&(t.setAttribute("role","button"),t.setAttribute("tabindex","0"),t.addEventListener("keydown",o=>{O(o)||(o.key==="Enter"?(o.preventDefault(),o.stopPropagation(),t.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0}))):o.key===" "&&(o.preventDefault(),o.stopPropagation()))},{signal:this.eventsAbortController.signal}),t.addEventListener("keyup",o=>{o.key===" "&&(o.preventDefault(),o.stopPropagation(),t.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0})))},{signal:this.eventsAbortController.signal})),this.options.title&&this.options.title.trim()!==""){let o=document.createElement("div");o.className="wulf-toast-title",this.appendTextWithLineBreaks(o,this.options.title),t.appendChild(o)}if(this.options.message&&this.options.message.trim()!==""){let o=document.createElement("div");o.className="wulf-toast-message",this.appendTextWithLineBreaks(o,this.options.message),t.appendChild(o)}e.appendChild(t);let i=this.options.action;if(i&&typeof i.onClick=="function"){let o=g(String(i.label??""),128).trim();if(o){let c=document.createElement("button");if(c.type="button",c.className="wulf-toast-action",c.textContent=o,typeof i.ariaLabel=="string"){let l=g(i.ariaLabel,256).trim();l&&c.setAttribute("aria-label",l)}let r=()=>{this.actionPending=!1,this._isClosed||(c.disabled=!1,c.removeAttribute("aria-busy"))};c.addEventListener("click",l=>{if(l.stopPropagation(),this._isClosed||this.actionPending)return;this.actionPending=!0,c.disabled=!0,c.setAttribute("aria-busy","true");let u=i.closeOnClick!==!1;try{let d=i.onClick(this,l);d&&typeof d.then=="function"?d.then(()=>{u&&!this._isClosed?this.close("action"):r()},f=>{console.error("[Wulf.Toast] Erreur dans action.onClick:",f),r()}):u&&!this._isClosed?this.close("action"):r()}catch(d){console.error("[Wulf.Toast] Erreur dans action.onClick:",d),r()}},{signal:this.eventsAbortController.signal}),e.appendChild(c)}}if(this.options.closable??!0){let o=document.createElement("button");o.type="button",o.className="wulf-toast-close",o.setAttribute("aria-label",m.t("closeButton",this.options.i18n));let c=document.createElement("span");c.className="wulf-toast-close-icon",c.setAttribute("aria-hidden","true"),c.textContent="\xD7",o.appendChild(c),o.addEventListener("click",r=>{r.stopPropagation(),this.close("close-button")},{signal:this.eventsAbortController.signal}),e.appendChild(o)}if(this.options.progressBar&&this.remainingTime>0){e.style.setProperty("--wulf-toast-duration",`${this.remainingTime}ms`);let o=document.createElement("div");o.className="wulf-toast-progress",o.setAttribute("aria-hidden","true"),e.appendChild(o)}return e}appendTextWithLineBreaks(e,t){g(String(t??""),4096).split(/\r\n|\r|\n/).slice(0,100).forEach((n,o)=>{o>0&&e.appendChild(document.createElement("br")),e.appendChild(document.createTextNode(n))})}bindEvents(){let{signal:e}=this.eventsAbortController;this.element.addEventListener("click",t=>{if(this.options.onClick)try{this.options.onClick(this,t)}catch(s){console.error("[Wulf.Toast] Erreur dans le callback onClick:",s)}this.options.closeOnClick&&this.close("toast-click")},{signal:e}),this.element.addEventListener("mouseenter",()=>this.pauseTimer("hover"),{signal:e}),this.element.addEventListener("mouseleave",()=>this.resumeTimer("hover"),{signal:e}),this.element.addEventListener("focusin",()=>this.pauseTimer("focus"),{signal:e}),this.element.addEventListener("focusout",t=>{let s=t.relatedTarget;if(!(s&&this.element.contains(s))){if(this.isPendingFocusDismiss&&!this._isClosed){this.isPendingFocusDismiss=!1,this.close("timeout");return}this.resumeTimer("focus")}},{signal:e}),this.element.addEventListener("keydown",t=>{if(t.key==="Escape"&&(this.options.closable??!0)){if(O(t))return;t.stopPropagation(),this.close("close-button")}},{signal:e}),typeof document<"u"&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.pauseTimer("visibility"):this.resumeTimer("visibility")},{signal:e})}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&&(typeof window<"u"&&window.clearTimeout(this.timerId),this.timerId=null),!(typeof window>"u")&&(this.timerStartTime=typeof performance<"u"?performance.now():Date.now(),this.timerId=window.setTimeout(()=>{this.timerId=null;let e=y();if(e&&this.element.contains(e)){this.isPendingFocusDismiss=!0;return}this.close("timeout")},this.remainingTime))}}pauseTimer(e="interaction"){if(this._isClosed||!this.hasDuration||this.remainingTime<=0)return;let t=this.isPaused;if(e==="visibility"?this.isPausedByVisibility=!0:e==="focus"?this.isPausedByFocus=!0:this.isPausedByHover=!0,!t){if(this.timerId!==null){typeof window<"u"&&window.clearTimeout(this.timerId),this.timerId=null;let i=(typeof performance<"u"?performance.now():Date.now())-this.timerStartTime;this.remainingTime=Math.max(0,this.remainingTime-i)}this.element.classList.add("is-paused")}}resumeTimer(e="interaction"){if(!(this._isClosed||!this.hasDuration)){if(e==="visibility")this.isPausedByVisibility=!1;else if(e==="focus")this.isPausedByFocus=!1;else if(e==="hover"){this.isPausedByHover=!1;let t=y();t&&this.element.contains(t)&&(this.isPausedByFocus=!0)}else this.isPausedByHover=!1,this.isPausedByFocus=!1;if(!this.isPaused){if(this.element.classList.remove("is-paused"),this.remainingTime<=0){this.close("timeout");return}this.startTimer()}}}finalizeDismiss(e){if(!this._isFinalized&&(this._isFinalized=!0,this.eventsAbortController.abort(),this.onDismissCallback&&this.onDismissCallback(this,e),this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.options.onClose))try{this.options.onClose(this,e)}catch(t){console.error("[Wulf.Toast] Erreur dans le callback onClose:",t)}}destroyImmediate(e="replace"){this._isClosed=!0,this.timerId!==null&&(typeof window<"u"&&window.clearTimeout(this.timerId),this.timerId=null),this.disposeAbortController.abort(),this.finalizeDismiss(e)}close(e="programmatic",t=!1){return this._isClosed?this.closePromise??Promise.resolve():(this._isClosed=!0,this.timerId!==null&&(typeof window<"u"&&window.clearTimeout(this.timerId),this.timerId=null),this.eventsAbortController.abort(),this.element.classList.add(t?"wulf-toast-hiding-fast":"wulf-toast-hiding"),R()?(this.finalizeDismiss(e),this.closePromise=Promise.resolve(),this.closePromise):(this.closePromise=D(this.element,t?90:300,this.disposeAbortController.signal).then(()=>{this.disposeAbortController.signal.aborted||this.finalizeDismiss(e)}),this.closePromise))}};var ke=Symbol.for("wulf.focusTrap.stack.v1"),W=Symbol.for("wulf.toast.manager.v1"),j=Symbol.for("wulf.toast.containers.v1"),$=Symbol.for("wulf.toast.announcers.v1");function _(){return typeof globalThis>"u"?null:globalThis}function z(){let a=_();return a?a[W]??null:null}function B(a){let e=_();e&&(e[W]=a)}function x(a){if(typeof WeakSet>"u")return null;let e=_();if(!e)return null;let t=e[a];return t instanceof WeakSet||(t=new WeakSet,e[a]=t),t}function K(a){x(j)?.add(a)}function N(a){x(j)?.delete(a)}function V(a){x($)?.add(a)}function G(a){x($)?.delete(a)}var Y=new Set(["top-left","top-center","top-right","bottom-left","bottom-center","bottom-right"]);function U(a){return a&&Y.has(a)?a:"top-right"}var re='button:not([disabled]), [href], [tabindex]:not([tabindex="-1"])',T=class a{containers=new Map;containerBaseLabels=new WeakMap;activeToasts=new Map;announcerEl=null;politeRegion=null;assertiveRegion=null;announceTimers=[];politeAnnounceTimerId=null;assertiveAnnounceTimerId=null;politeClearTimerId=null;assertiveClearTimerId=null;lastPoliteText="";lastAssertiveText="";announcerToggle=!1;isPopoverOpen(e){try{if(e.matches(":popover-open"))return!0}catch{}return e.classList.contains(":popover-open")}replaceTokens=new Map;pendingReplacements=new Set;constructor(){}static getInstance(){let e=z();return e||(e=new a,B(e)),e}getContainerKey(e,t){return`${e}:${t?"top":"fixed"}`}add(e){if(typeof document>"u"||typeof window>"u")return;let t=U(e.options.position),s=this.activeToasts.get(t);s||(s=[],this.activeToasts.set(t,s));let i=e.options.maxToasts,n=typeof i=="number"&&Number.isFinite(i)&&i>0?Math.min(50,Math.max(1,Math.floor(i))):5;if(e.options.replace&&s.length>0){let o=[...s],c=(this.replaceTokens.get(t)||0)+1;this.replaceTokens.set(t,c),this.pendingReplacements.add(t);let r=o.map(l=>l.close("replace",!0));Promise.all(r).then(()=>{if(this.pendingReplacements.delete(t),this.replaceTokens.get(t)!==c){e.destroyImmediate("replace");return}this.mountToast(e,t,n)});return}if(this.pendingReplacements.has(t)&&(this.replaceTokens.set(t,(this.replaceTokens.get(t)||0)+1),this.pendingReplacements.delete(t)),s.length>=n){let o=s.length-n+1,c=s.splice(0,o);for(let r of c)r.close("max-limit",!0)}this.mountToast(e,t,n)}mountToast(e,t,s=5){if(e.isClosed||typeof document>"u")return;let i=e.options.useTopLayer??!0,n=this.getOrCreateContainer(t,e,i),o=this.activeToasts.get(t);o||(o=[],this.activeToasts.set(t,o));let c=s+10;if(n.children.length>=c){let r=Array.from(n.children);for(let l of r){if(n.children.length<c)break;(l.classList.contains("wulf-toast-hiding")||l.classList.contains("wulf-toast-hiding-fast"))&&l.remove()}}if(i&&typeof n.showPopover=="function"&&n.getAttribute("popover")==="manual")try{let r=n;this.isPopoverOpen(n)||r.showPopover()}catch{n.removeAttribute("popover")}if(n.appendChild(e.element),o.push(e),this.announce(e),e.options.onOpen)try{e.options.onOpen(e)}catch(r){console.error("[Wulf.Toast] Erreur dans le callback onOpen:",r)}e.startTimer()}announce(e){if(typeof document>"u"||typeof window>"u")return;let t=[e.options.title,e.options.message].filter(h=>typeof h=="string"&&h.trim().length>0).map(h=>g(h,512).trim()).filter(Boolean);if(t.length===0)return;let s=t.join(". "),i=s.length>512?`${s.slice(0,509)}...`:s,n=e.options.role==="alert",o=document;if(typeof o.ariaNotify=="function")try{o.ariaNotify(i,{priority:n?"high":"normal"});return}catch{}let c=!this.announcerEl||!this.announcerEl.isConnected;this.ensureAnnouncer();let r=n?this.assertiveRegion:this.politeRegion;if(!r)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)),r.textContent="";let l=n?this.lastAssertiveText:this.lastPoliteText,u=i;i===l?(this.announcerToggle=!this.announcerToggle,u=this.announcerToggle?`${i}\xA0`:i):this.announcerToggle=!1,n?this.lastAssertiveText=i:this.lastPoliteText=i;let d=c?120:50,f=window.setTimeout(()=>{let h=this.announceTimers.indexOf(f);if(h!==-1&&this.announceTimers.splice(h,1),n?this.assertiveAnnounceTimerId=null:this.politeAnnounceTimerId=null,r.isConnected){r.textContent=u;let I=window.setTimeout(()=>{let F=this.announceTimers.indexOf(I);F!==-1&&this.announceTimers.splice(F,1),r.isConnected&&r.textContent===u&&(r.textContent="")},4e3);this.announceTimers.push(I),n?this.assertiveClearTimerId=I:this.politeClearTimerId=I}},d);this.announceTimers.push(f),n?this.assertiveAnnounceTimerId=f:this.politeAnnounceTimerId=f}ensureAnnouncer(){if(typeof document>"u"||!document.body||this.announcerEl&&document.body.contains(this.announcerEl))return;let e=document.createElement("div");e.className="wulf-toast-announcer",e.setAttribute("data-wulf-toast-announcer","true"),V(e);let t=document.createElement("div");t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true");let s=document.createElement("div");s.setAttribute("role","alert"),s.setAttribute("aria-live","assertive"),s.setAttribute("aria-atomic","true"),e.appendChild(t),e.appendChild(s),document.body.appendChild(e),this.announcerEl=e,this.politeRegion=t,this.assertiveRegion=s}handleFocusHandoff(e,t){let s=y();if(!s||!e.element.contains(s))return;for(let n=t.length-1;n>=0;n--){let o=t[n];if(o===e||o.isClosed||!o.element.isConnected)continue;let c=o.element.querySelector(re);if(c){c.focus({preventScroll:!0});return}}let i=e.getPreviousActiveElement();if(i&&i.isConnected&&typeof i.focus=="function"&&!i.disabled&&!i.hidden&&!i.closest("[hidden]")&&!i.closest("[inert]")&&i.getAttribute("aria-hidden")!=="true"&&(i.tabIndex>=0||i.getAttribute("tabindex")!==null)){let n=i;if(typeof n.checkVisibility=="function"&&!n.checkVisibility({checkOpacity:!1,checkVisibilityCSS:!0,visibilityProperty:!0}))return;try{i.focus()}catch{}}}remove(e,t){let s=U(e.options.position),i=this.activeToasts.get(s),n=e.options.useTopLayer??!0,o=this.getContainerKey(s,n),c=e.element.parentElement;if(i){let r=i.indexOf(e);r!==-1&&i.splice(r,1),this.handleFocusHandoff(e,i),e.element.parentNode&&e.element.parentNode.removeChild(e.element);let l=this.containers.get(o)||(c instanceof HTMLElement?c:void 0);if(l&&(!l.firstChild||l.children.length===0)){for(let[u,d]of Array.from(this.containers.entries()))d===l&&this.containers.delete(u);this.disposeContainer(l),this.syncContainerRegionLabels()}if(i.length===0&&!this.pendingReplacements.has(s)){for(let u of[!0,!1]){let d=this.getContainerKey(s,u),f=this.containers.get(d);f&&(!f.firstChild||f.children.length===0)&&(this.disposeContainer(f),this.containers.delete(d))}this.activeToasts.delete(s),this.syncContainerRegionLabels()}}else e.element.parentNode&&e.element.parentNode.removeChild(e.element)}disposeContainer(e){N(e);try{let t=e;typeof t.hidePopover=="function"&&this.isPopoverOpen(e)&&t.hidePopover()}catch{}e.parentNode&&e.parentNode.removeChild(e)}clearAll(e){if(typeof document>"u"||typeof window>"u")return Promise.resolve();let t=[];if(e){this.replaceTokens.set(e,(this.replaceTokens.get(e)||0)+1),this.pendingReplacements.delete(e);let s=this.activeToasts.get(e);if(s&&s.length>0){let i=[...s];for(let n of i)t.push(n.close("programmatic"))}else{let i=!1;for(let n of[!0,!1]){let o=this.getContainerKey(e,n),c=this.containers.get(o);c&&(!c.firstChild||c.children.length===0)&&(this.disposeContainer(c),this.containers.delete(o),i=!0)}this.activeToasts.delete(e),i&&this.syncContainerRegionLabels()}}else{for(let i of this.replaceTokens.keys())this.replaceTokens.set(i,(this.replaceTokens.get(i)||0)+1);this.pendingReplacements.clear();for(let i of this.announceTimers)window.clearTimeout(i);this.announceTimers=[],this.politeAnnounceTimerId=null,this.assertiveAnnounceTimerId=null,this.politeClearTimerId=null,this.assertiveClearTimerId=null;let s=new Set(Array.from(this.activeToasts.keys()));for(let i of this.containers.keys()){let n=i.slice(0,i.lastIndexOf(":"));Y.has(n)&&s.add(n)}for(let i of s)t.push(this.clearAll(i))}return Promise.all(t).then(()=>{if(!e){for(let[s,i]of Array.from(this.containers.entries()))(!i.firstChild||i.children.length===0)&&(this.disposeContainer(i),this.containers.delete(s));this.activeToasts.clear(),this.syncContainerRegionLabels()}})}destroy(){if(typeof window<"u")for(let e of this.announceTimers)window.clearTimeout(e);this.announceTimers=[],this.politeAnnounceTimerId=null,this.assertiveAnnounceTimerId=null,this.politeClearTimerId=null,this.assertiveClearTimerId=null;for(let e of Array.from(this.activeToasts.values()))for(let t of[...e])t.destroyImmediate("programmatic");for(let e of Array.from(this.containers.values()))this.disposeContainer(e);this.containers.clear(),this.activeToasts.clear(),this.replaceTokens.clear(),this.pendingReplacements.clear(),this.announcerEl&&(G(this.announcerEl),this.announcerEl.remove(),this.announcerEl=null,this.politeRegion=null,this.assertiveRegion=null),B(null)}syncContainerRegionLabels(){let e=this.containers.size>1;for(let[t,s]of this.containers.entries()){let i=this.containerBaseLabels.get(s)||m.t("notificationsRegion"),n=t.slice(0,t.lastIndexOf(":"));s.setAttribute("aria-label",e?`${i} (${n})`:i)}}getOrCreateContainer(e,t,s){let i=this.getContainerKey(e,s),n=this.containers.get(i);if(!n||!document.body.contains(n)){n&&N(n),n=document.createElement("div"),n.className=`wulf-toast-container wulf-toast-${e}`,n.setAttribute("role","region");let o=m.t("notificationsRegion",t.options.i18n);this.containerBaseLabels.set(n,o),n.setAttribute("aria-label",o),s&&typeof n.showPopover=="function"&&n.setAttribute("popover","manual"),K(n),document.body.appendChild(n),this.containers.set(i,n),this.syncContainerRegionLabels()}return n}};var P=class a extends v{static _i18n=m;static i18n=m;audit(){return[]}getAuditPrefix(){return"Wulf.Toast"}getAuditTargetLabel(){return"Toast"}static show(e={}){let t=T.getInstance(),s=new A(e,(i,n)=>{t.remove(i,n)});return t.add(s),s}static async promise(e,t){let s=(r,l)=>{let u;if(typeof r=="function")try{u=r(l)}catch(d){return console.error("[Wulf.Toast] Erreur lors de la r\xE9solution du message Toast.promise:",d),{}}else u=r;return typeof u=="string"?{message:u}:u&&typeof u=="object"?{...u}:{}},i=t.baseOptions?{...t.baseOptions}:{},n=s(t.loading,void 0),o=a.show({...i,duration:!1,closable:!0,role:"status",...n,replace:!1}),c=typeof e=="function"?Promise.resolve().then(()=>e()):Promise.resolve(e);try{let r=await c;await o.close("replace",!0);let l=s(t.success,r);return a.show({...i,role:"status",...l,replace:!1}),r}catch(r){await o.close("replace",!0);let l=s(t.error,r);throw a.show({...i,role:"alert",...l,replace:!1}),r}}static clearAll(e){return T.getInstance().clearAll(e)}static destroy(){T.getInstance().destroy()}};var ae=P;return ee(le);})();
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; } var __set = function(obj, key, val) { try { Object.defineProperty(obj, key, { value: val, writable: true, configurable: true, enumerable: true }); } catch (_) { try { obj[key] = val; } catch (__) {} } }; if (typeof __WulfIIFE !== "undefined" && __WulfIIFE) { var __e = __WulfIIFE; var __skip = ["__proto__","constructor","prototype"]; for (var k in __e) { if (Object.hasOwn(__e, k) && __skip.indexOf(k) === -1 && __w[k] === undefined) { __set(__w, k, __e[k]); } } if (__e.Toast) __set(__w, "Toast", Object.assign(__e.Toast, { Toast: __e.Toast, ToastInstance: __e.ToastInstance, ToastManager: __e.ToastManager, i18n: __e.toastI18n })); }}
6
6
  //# sourceMappingURL=toast.global.min.js.map