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.
Files changed (81) hide show
  1. package/README.md +124 -78
  2. package/changelog.md +105 -0
  3. package/dist/focus-trap.esm.js +245 -126
  4. package/dist/focus-trap.esm.js.map +3 -3
  5. package/dist/focus-trap.global.js +247 -128
  6. package/dist/focus-trap.global.js.map +3 -3
  7. package/dist/focus-trap.global.min.js +4 -4
  8. package/dist/focus-trap.global.min.js.map +4 -4
  9. package/dist/index.esm.js +2434 -905
  10. package/dist/index.esm.js.map +4 -4
  11. package/dist/index.global.js +2436 -907
  12. package/dist/index.global.js.map +4 -4
  13. package/dist/index.global.min.js +4 -4
  14. package/dist/index.global.min.js.map +4 -4
  15. package/dist/mask.css +1 -1
  16. package/dist/mask.css.map +2 -2
  17. package/dist/mask.esm.js +746 -346
  18. package/dist/mask.esm.js.map +3 -3
  19. package/dist/mask.global.js +748 -348
  20. package/dist/mask.global.js.map +3 -3
  21. package/dist/mask.global.min.js +4 -4
  22. package/dist/mask.global.min.js.map +4 -4
  23. package/dist/mask.layered.css +1 -0
  24. package/dist/mask.layered.css.map +7 -0
  25. package/dist/masonry.css +1 -1
  26. package/dist/masonry.css.map +2 -2
  27. package/dist/masonry.esm.js +341 -114
  28. package/dist/masonry.esm.js.map +3 -3
  29. package/dist/masonry.global.js +343 -116
  30. package/dist/masonry.global.js.map +3 -3
  31. package/dist/masonry.global.min.js +4 -4
  32. package/dist/masonry.global.min.js.map +4 -4
  33. package/dist/masonry.layered.css +1 -0
  34. package/dist/masonry.layered.css.map +7 -0
  35. package/dist/scroll.css +1 -1
  36. package/dist/scroll.css.map +2 -2
  37. package/dist/scroll.esm.js +524 -153
  38. package/dist/scroll.esm.js.map +3 -3
  39. package/dist/scroll.global.js +526 -155
  40. package/dist/scroll.global.js.map +3 -3
  41. package/dist/scroll.global.min.js +4 -4
  42. package/dist/scroll.global.min.js.map +4 -4
  43. package/dist/scroll.layered.css +1 -0
  44. package/dist/scroll.layered.css.map +7 -0
  45. package/dist/shortcut.esm.js +209 -46
  46. package/dist/shortcut.esm.js.map +3 -3
  47. package/dist/shortcut.global.js +211 -48
  48. package/dist/shortcut.global.js.map +3 -3
  49. package/dist/shortcut.global.min.js +2 -2
  50. package/dist/shortcut.global.min.js.map +4 -4
  51. package/dist/toast.css +1 -1
  52. package/dist/toast.css.map +2 -2
  53. package/dist/toast.esm.js +590 -160
  54. package/dist/toast.esm.js.map +3 -3
  55. package/dist/toast.global.js +592 -162
  56. package/dist/toast.global.js.map +3 -3
  57. package/dist/toast.global.min.js +4 -4
  58. package/dist/toast.global.min.js.map +4 -4
  59. package/dist/toast.layered.css +1 -0
  60. package/dist/toast.layered.css.map +7 -0
  61. package/dist/types/common/dom.d.ts +38 -0
  62. package/dist/types/focus-trap/FocusTrap.d.ts +15 -5
  63. package/dist/types/focus-trap/types.d.ts +2 -2
  64. package/dist/types/index.d.ts +10 -0
  65. package/dist/types/mask/AmountEngine.d.ts +1 -0
  66. package/dist/types/mask/BaseInputMask.d.ts +24 -0
  67. package/dist/types/mask/InputAmountMask.d.ts +3 -0
  68. package/dist/types/mask/InputEmailMask.d.ts +16 -1
  69. package/dist/types/mask/InputMask.d.ts +1 -0
  70. package/dist/types/mask/MaskEngine.d.ts +4 -0
  71. package/dist/types/masonry/Masonry.d.ts +10 -3
  72. package/dist/types/scroll/ScrollBlock.d.ts +31 -3
  73. package/dist/types/scroll/types.d.ts +13 -1
  74. package/dist/types/shortcut/ShortcutFormatter.d.ts +6 -0
  75. package/dist/types/shortcut/ShortcutManager.d.ts +5 -0
  76. package/dist/types/toast/Toast.d.ts +4 -0
  77. package/dist/types/toast/ToastInstance.d.ts +22 -10
  78. package/dist/types/toast/ToastManager.d.ts +37 -4
  79. package/dist/types/toast/i18n/types.d.ts +2 -0
  80. package/dist/types/toast/types.d.ts +14 -2
  81. package/package.json +20 -5
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- var Wulf = (() => {
2
+ var __WulfIIFE = (() => {
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -35,6 +35,41 @@ var Wulf = (() => {
35
35
  resolveMaskConstructorArgs: () => resolveMaskConstructorArgs
36
36
  });
37
37
 
38
+ // src/common/dom.ts
39
+ function getSafeWulfNamespace() {
40
+ if (typeof window === "undefined") return null;
41
+ const win = window;
42
+ const existing = win.Wulf;
43
+ if (!existing || typeof existing !== "object" || typeof Node !== "undefined" && existing instanceof Node || typeof HTMLCollection !== "undefined" && existing instanceof HTMLCollection) {
44
+ const fresh = {};
45
+ win.Wulf = fresh;
46
+ return fresh;
47
+ }
48
+ return existing;
49
+ }
50
+ function safeCssEscape(value) {
51
+ if (typeof CSS !== "undefined" && typeof CSS.escape === "function") {
52
+ return CSS.escape(value);
53
+ }
54
+ return String(value).replace(/["\\\u0000-\u001F\u007F]/g, "\\$&");
55
+ }
56
+ function safeMove(parent, node, referenceNode = null) {
57
+ const moveBefore = parent.moveBefore;
58
+ if (typeof moveBefore === "function" && node.isConnected && parent.isConnected && typeof parent.getRootNode === "function" && typeof node.getRootNode === "function" && parent.getRootNode() === node.getRootNode()) {
59
+ try {
60
+ moveBefore.call(parent, node, referenceNode);
61
+ return;
62
+ } catch {
63
+ }
64
+ }
65
+ parent.insertBefore(node, referenceNode);
66
+ }
67
+ function isImeComposing(event) {
68
+ return Boolean(
69
+ event.isComposing || event.key === "Process" || event.key === "Enter" && event.keyCode === 229
70
+ );
71
+ }
72
+
38
73
  // src/common/AuditableComponent.ts
39
74
  var AuditableComponent = class {
40
75
  /**
@@ -67,8 +102,11 @@ var Wulf = (() => {
67
102
  const rawValue = element.getAttribute(attrName)?.trim();
68
103
  if (!rawValue) return false;
69
104
  const doc = element.ownerDocument || document;
105
+ const root = typeof element.getRootNode === "function" ? element.getRootNode() : doc;
70
106
  const ids = rawValue.split(/\s+/).filter(Boolean);
71
- const isValid = ids.length > 0 && ids.every((id) => Boolean(doc.getElementById(id)));
107
+ const isValid = ids.length > 0 && ids.every(
108
+ (id) => Boolean(typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root.getElementById(id) : doc.getElementById(id))
109
+ );
72
110
  if (!isValid) {
73
111
  warnings.push(
74
112
  `Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`
@@ -79,6 +117,7 @@ var Wulf = (() => {
79
117
  };
80
118
 
81
119
  // src/mask/BaseInputMask.ts
120
+ var VALID_ALIGNS = /* @__PURE__ */ new Set(["left", "right", "center"]);
82
121
  function resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, maybeOptions) {
83
122
  const isSecondArgInput = Boolean(
84
123
  inputOrOptions && typeof inputOrOptions === "object" && "tagName" in inputOrOptions && inputOrOptions.tagName === "INPUT"
@@ -97,59 +136,27 @@ var Wulf = (() => {
97
136
  };
98
137
  }
99
138
  var BaseInputMask = class extends AuditableComponent {
139
+ wrapper;
140
+ input;
141
+ options;
142
+ ghost = null;
143
+ isWrapperCreated = false;
144
+ wasWrapperFallbackStyled = false;
145
+ wasAlignSet = false;
146
+ hadInitialDataAlign = false;
147
+ isDestroyed = false;
148
+ isFocused = false;
149
+ isDispatchingNativeInput = false;
150
+ lastTrackedValue = "";
151
+ nativeValueDescriptor = null;
152
+ onCutHandler = () => {
153
+ };
154
+ onFormResetHandler;
155
+ mutationObserver = null;
156
+ focusSelectTimerId = null;
157
+ abortController = new AbortController();
100
158
  constructor(targetOrWrapper, inputOrOptions, maybeOptions) {
101
159
  super();
102
- this.ghost = null;
103
- this.isWrapperCreated = false;
104
- this.isDestroyed = false;
105
- this.isFocused = false;
106
- this.isDispatchingNativeInput = false;
107
- this.lastTrackedValue = "";
108
- this.nativeValueDescriptor = null;
109
- this.onCutHandler = () => {
110
- };
111
- this.mutationObserver = null;
112
- this.focusSelectTimerId = null;
113
- this.onBaseCopy = (e) => {
114
- if (!this.options.copyRaw || this.options.disabled || this.input.type === "password") return;
115
- const start = this.input.selectionStart ?? 0;
116
- const end = this.input.selectionEnd ?? start;
117
- let textToCopy = "";
118
- if (start !== end) {
119
- textToCopy = this.extractRawSnippet(this.input.value.slice(start, end));
120
- } else {
121
- textToCopy = this.getRawValue();
122
- }
123
- if (textToCopy && e.clipboardData) {
124
- e.preventDefault();
125
- e.clipboardData.setData("text/plain", textToCopy);
126
- }
127
- };
128
- this.onBaseFocus = () => {
129
- this.isFocused = true;
130
- if (this.options.selectAllOnFocus && this.input.value.length > 0) {
131
- if (this.focusSelectTimerId !== null) {
132
- clearTimeout(this.focusSelectTimerId);
133
- }
134
- this.focusSelectTimerId = window.setTimeout(() => {
135
- this.focusSelectTimerId = null;
136
- if (!this.isDestroyed && document.activeElement === this.input) {
137
- this.input.select();
138
- }
139
- }, 0);
140
- }
141
- };
142
- this.onBaseBlur = () => {
143
- this.isFocused = false;
144
- };
145
- /**
146
- * Synchronise le défilement horizontal du ghost avec celui du champ d'entrée natif.
147
- */
148
- this.onScroll = () => {
149
- if (this.ghost) {
150
- this.ghost.scrollLeft = this.input.scrollLeft;
151
- }
152
- };
153
160
  const { wrapper: providedWrapper, input, options } = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, maybeOptions);
154
161
  if (!input || typeof input !== "object" || input.nodeType !== 1 || input.tagName !== "INPUT") {
155
162
  throw new Error(`[${new.target.name || "InputMask"}] input (HTMLInputElement) est requis.`);
@@ -159,20 +166,26 @@ var Wulf = (() => {
159
166
  const shouldCreateWrapper = Boolean(options.createWrapper ?? dataCreateWrapper);
160
167
  let effectiveWrapper = providedWrapper;
161
168
  if (!effectiveWrapper && shouldCreateWrapper) {
162
- const span = document.createElement("span");
169
+ const doc = this.input.ownerDocument || document;
170
+ const span = doc.createElement("span");
163
171
  span.className = "wulf-mask-wrapper";
164
- span.style.display = "inline-grid";
165
- span.style.gridTemplateColumns = "1fr";
166
- span.style.gridTemplateRows = "1fr";
167
- span.style.verticalAlign = "middle";
168
- span.style.boxSizing = "border-box";
169
- span.style.position = "relative";
170
172
  if (this.input.parentNode) {
171
173
  this.input.parentNode.insertBefore(span, this.input);
172
174
  }
173
- span.appendChild(this.input);
174
- this.input.style.gridArea = "1 / 1 / 2 / 2";
175
- this.input.style.boxSizing = "border-box";
175
+ safeMove(span, this.input, null);
176
+ const view = doc.defaultView || (typeof window !== "undefined" ? window : null);
177
+ const needsFallbackStyles = !span.isConnected || !view || view.getComputedStyle(span).display !== "inline-grid";
178
+ if (needsFallbackStyles) {
179
+ span.style.display = "inline-grid";
180
+ span.style.gridTemplateColumns = "1fr";
181
+ span.style.gridTemplateRows = "1fr";
182
+ span.style.verticalAlign = "middle";
183
+ span.style.boxSizing = "border-box";
184
+ span.style.position = "relative";
185
+ this.input.style.gridArea = "1 / 1 / 2 / 2";
186
+ this.input.style.boxSizing = "border-box";
187
+ this.wasWrapperFallbackStyled = true;
188
+ }
176
189
  effectiveWrapper = span;
177
190
  this.isWrapperCreated = true;
178
191
  }
@@ -185,12 +198,15 @@ var Wulf = (() => {
185
198
  const dataDisabled = this.hasAttr("data-disabled");
186
199
  const dataSelectAll = this.getAttr("data-mask-select-on-focus") === "true";
187
200
  const dataCopyRaw = this.getAttr("data-mask-copy-raw") === "true";
188
- const dataAlign = this.getAttr("data-mask-align") || this.getAttr("data-align");
201
+ const rawDataAlign = this.getAttr("data-mask-align") || this.getAttr("data-align");
202
+ const dataAlign = rawDataAlign && VALID_ALIGNS.has(rawDataAlign) ? rawDataAlign : null;
203
+ this.hadInitialDataAlign = this.wrapper.hasAttribute("data-align");
189
204
  const dataAudit = this.getAttr("data-mask-audit");
190
205
  const { disabled: optDisabled, align: optAlign, ...otherOptions } = options;
206
+ const validOptAlign = optAlign && VALID_ALIGNS.has(optAlign) ? optAlign : void 0;
191
207
  const resolvedDisabled = optDisabled !== void 0 ? optDisabled : dataDisabled ? true : false;
192
208
  const resolvedAudit = options.audit ?? (dataAudit !== null ? dataAudit !== "false" : true);
193
- const isPassword = this.input.type === "password";
209
+ const isPassword = this.isPasswordInput();
194
210
  this.options = {
195
211
  ...otherOptions,
196
212
  createWrapper: shouldCreateWrapper,
@@ -198,7 +214,7 @@ var Wulf = (() => {
198
214
  selectAllOnFocus: options.selectAllOnFocus ?? dataSelectAll ?? false,
199
215
  copyRaw: isPassword ? false : options.copyRaw ?? dataCopyRaw ?? false,
200
216
  disabled: resolvedDisabled,
201
- align: optAlign ?? (dataAlign || void 0),
217
+ align: validOptAlign ?? (dataAlign || void 0),
202
218
  emitNativeInput: options.emitNativeInput ?? true,
203
219
  audit: resolvedAudit
204
220
  };
@@ -245,16 +261,54 @@ var Wulf = (() => {
245
261
  * Attache les écouteurs de base pour focus/blur, copie brute et sélection.
246
262
  */
247
263
  bindBaseEvents() {
248
- this.input.addEventListener("copy", this.onBaseCopy);
249
- this.input.addEventListener("focus", this.onBaseFocus);
250
- this.input.addEventListener("blur", this.onBaseBlur);
264
+ const { signal } = this.abortController;
265
+ this.input.addEventListener("copy", this.onBaseCopy, { signal });
266
+ this.input.addEventListener("focus", this.onBaseFocus, { signal });
267
+ this.input.addEventListener("blur", this.onBaseBlur, { signal });
251
268
  }
269
+ onBaseCopy = (e) => {
270
+ if (!this.options.copyRaw || this.options.disabled || this.input.type === "password") return;
271
+ const start = this.input.selectionStart ?? 0;
272
+ const end = this.input.selectionEnd ?? start;
273
+ let textToCopy = "";
274
+ if (start !== end) {
275
+ textToCopy = this.extractRawSnippet(this.input.value.slice(start, end));
276
+ } else {
277
+ textToCopy = this.getRawValue();
278
+ }
279
+ if (textToCopy && e.clipboardData) {
280
+ e.preventDefault();
281
+ e.clipboardData.setData("text/plain", textToCopy);
282
+ }
283
+ };
252
284
  /**
253
285
  * Extrait la valeur brute d'un extrait de chaîne sélectionné.
254
286
  */
255
287
  extractRawSnippet(snippet) {
256
288
  return snippet;
257
289
  }
290
+ onBaseFocus = () => {
291
+ this.isFocused = true;
292
+ if (this.options.selectAllOnFocus && this.input.value.length > 0) {
293
+ if (this.focusSelectTimerId !== null) {
294
+ clearTimeout(this.focusSelectTimerId);
295
+ }
296
+ this.focusSelectTimerId = window.setTimeout(() => {
297
+ this.focusSelectTimerId = null;
298
+ if (!this.isDestroyed && document.activeElement === this.input) {
299
+ this.input.select();
300
+ }
301
+ }, 0);
302
+ }
303
+ };
304
+ onBaseBlur = () => {
305
+ this.isFocused = false;
306
+ if (this.isPasswordInput()) {
307
+ this.lastTrackedValue = "";
308
+ this.clearGhost();
309
+ this.wrapper.removeAttribute("data-mask");
310
+ }
311
+ };
258
312
  /**
259
313
  * Initialise l'observation des modifications dynamiques des attributs data-* et placeholder.
260
314
  */
@@ -284,7 +338,8 @@ var Wulf = (() => {
284
338
  "data-disabled",
285
339
  "data-mask-align",
286
340
  "data-align",
287
- "placeholder"
341
+ "placeholder",
342
+ "type"
288
343
  ]
289
344
  };
290
345
  this.mutationObserver.observe(this.wrapper, config);
@@ -292,21 +347,41 @@ var Wulf = (() => {
292
347
  this.mutationObserver.observe(this.input, config);
293
348
  }
294
349
  }
350
+ /**
351
+ * Indique si le champ natif sous-jacent est de type mot de passe.
352
+ */
353
+ isPasswordInput() {
354
+ return (this.input.type || "").toLowerCase() === "password";
355
+ }
356
+ /**
357
+ * Calcule une empreinte non réversible pour détecter les changements sans conserver de secret en RAM.
358
+ */
359
+ computePasswordDigest(val) {
360
+ let hash = 2166136261;
361
+ for (let i = 0; i < val.length; i++) {
362
+ hash ^= val.charCodeAt(i);
363
+ hash = Math.imul(hash, 16777619);
364
+ }
365
+ return `__pwd:${(hash >>> 0).toString(36)}:${val.length}`;
366
+ }
295
367
  /**
296
368
  * Modifie dynamiquement l'alignement du champ et du masque fantôme.
297
369
  */
298
370
  setAlign(align) {
299
- const targetAlign = align || void 0;
371
+ const normalized = align && VALID_ALIGNS.has(align) ? align : null;
372
+ const targetAlign = normalized || void 0;
300
373
  const currentAttr = this.wrapper.getAttribute("data-align");
301
- if (this.options.align === targetAlign && currentAttr === (align || null)) {
374
+ const hasExpectedClass = normalized ? this.wrapper.classList.contains(`align-${normalized}`) : !this.wrapper.classList.contains("align-left") && !this.wrapper.classList.contains("align-right") && !this.wrapper.classList.contains("align-center");
375
+ if (this.options.align === targetAlign && currentAttr === normalized && hasExpectedClass) {
302
376
  return;
303
377
  }
304
378
  this.options.align = targetAlign;
305
379
  this.wrapper.classList.remove("align-left", "align-right", "align-center");
306
- if (align) {
307
- this.wrapper.classList.add(`align-${align}`);
308
- if (this.wrapper.getAttribute("data-align") !== align) {
309
- this.wrapper.setAttribute("data-align", align);
380
+ if (normalized) {
381
+ this.wrapper.classList.add(`align-${normalized}`);
382
+ this.wasAlignSet = true;
383
+ if (this.wrapper.getAttribute("data-align") !== normalized) {
384
+ this.wrapper.setAttribute("data-align", normalized);
310
385
  }
311
386
  } else {
312
387
  if (this.wrapper.hasAttribute("data-align")) {
@@ -332,9 +407,18 @@ var Wulf = (() => {
332
407
  } else if (attrName === "data-mask-select-on-focus") {
333
408
  this.options.selectAllOnFocus = this.getAttr("data-mask-select-on-focus") === "true";
334
409
  } else if (attrName === "data-mask-copy-raw") {
335
- this.options.copyRaw = this.getAttr("data-mask-copy-raw") === "true";
410
+ this.options.copyRaw = this.isPasswordInput() ? false : this.getAttr("data-mask-copy-raw") === "true";
411
+ } else if (attrName === "type") {
412
+ if (this.isPasswordInput()) {
413
+ this.options.copyRaw = false;
414
+ this.lastTrackedValue = "";
415
+ this.clearGhost();
416
+ this.wrapper.removeAttribute("data-mask");
417
+ this.onPasswordModeDetected();
418
+ }
336
419
  } else if (attrName === "data-mask-align" || attrName === "data-align") {
337
- const align = this.getAttr("data-mask-align") || this.getAttr("data-align");
420
+ const rawAlign = this.getAttr("data-mask-align") || this.getAttr("data-align");
421
+ const align = rawAlign && VALID_ALIGNS.has(rawAlign) ? rawAlign : null;
338
422
  if (align !== (this.options.align ?? null)) {
339
423
  this.setAlign(align);
340
424
  }
@@ -362,15 +446,42 @@ var Wulf = (() => {
362
446
  if (existing) {
363
447
  existing.remove();
364
448
  }
365
- this.ghost = document.createElement("div");
449
+ const doc = this.input.ownerDocument || document;
450
+ this.ghost = doc.createElement("div");
366
451
  this.ghost.className = "mask-ghost";
367
452
  this.ghost.setAttribute("aria-hidden", "true");
368
453
  this.ghost.style.display = "flex";
369
454
  this.ghost.style.alignItems = "center";
370
455
  this.wrapper.appendChild(this.ghost);
371
456
  this.wrapper.classList.add("has-ghost");
457
+ const view = doc.defaultView || (typeof window !== "undefined" ? window : null);
458
+ if (!this.wrapper.isConnected || !view || view.getComputedStyle(this.ghost).pointerEvents !== "none") {
459
+ this.ghost.style.gridArea = "1 / 1 / 2 / 2";
460
+ this.ghost.style.pointerEvents = "none";
461
+ }
372
462
  this.syncGhostStyles();
373
463
  }
464
+ /**
465
+ * Met à jour atomiquement le contenu du conteneur fantôme et synchronise .has-visible-ghost.
466
+ */
467
+ setGhostContent(...nodes) {
468
+ if (!this.ghost) return;
469
+ if (typeof this.ghost.replaceChildren === "function") {
470
+ this.ghost.replaceChildren(...nodes);
471
+ } else {
472
+ this.ghost.textContent = "";
473
+ for (const n of nodes) {
474
+ this.ghost.appendChild(typeof n === "string" ? document.createTextNode(n) : n);
475
+ }
476
+ }
477
+ this.wrapper.classList.toggle("has-visible-ghost", nodes.length > 0);
478
+ }
479
+ /**
480
+ * Vide atomiquement le conteneur fantôme et rétablit l'affichage du placeholder natif.
481
+ */
482
+ clearGhost() {
483
+ this.setGhostContent();
484
+ }
374
485
  /**
375
486
  * Clone fidèlement la géométrie typographique et les espacements de l'input natif
376
487
  * sur le conteneur fantôme pour garantir un alignement sub-pixel absolu quel que soit
@@ -403,12 +514,17 @@ var Wulf = (() => {
403
514
  this.ghost.style.textAlign = style.textAlign;
404
515
  this.ghost.style.direction = style.direction;
405
516
  const isRtl = style.direction === "rtl" || this.input.getAttribute("dir") === "rtl" || this.wrapper.getAttribute("dir") === "rtl";
406
- if (style.textAlign === "right" || style.textAlign === "end" || isRtl && style.textAlign !== "left" && style.textAlign !== "center") {
407
- this.ghost.style.justifyContent = "flex-end";
408
- } else if (style.textAlign === "center") {
517
+ const textAlign = style.textAlign;
518
+ if (textAlign === "right") {
519
+ this.ghost.style.justifyContent = "right";
520
+ } else if (textAlign === "left") {
521
+ this.ghost.style.justifyContent = "left";
522
+ } else if (textAlign === "center") {
409
523
  this.ghost.style.justifyContent = "center";
524
+ } else if (textAlign === "end") {
525
+ this.ghost.style.justifyContent = isRtl ? "left" : "right";
410
526
  } else {
411
- this.ghost.style.justifyContent = "flex-start";
527
+ this.ghost.style.justifyContent = isRtl ? "right" : "left";
412
528
  }
413
529
  }
414
530
  /**
@@ -432,15 +548,23 @@ var Wulf = (() => {
432
548
  this.isDispatchingNativeInput = true;
433
549
  try {
434
550
  const tracker = this.input._valueTracker;
435
- if (tracker && typeof tracker.setValue === "function") {
551
+ if (!this.isPasswordInput() && tracker && typeof tracker.setValue === "function") {
436
552
  tracker.setValue(this.lastTrackedValue);
437
553
  }
438
- this.lastTrackedValue = this.input.value;
554
+ this.lastTrackedValue = this.isPasswordInput() ? "" : this.input.value;
439
555
  this.input.dispatchEvent(new Event("input", { bubbles: true, cancelable: false }));
440
556
  } finally {
441
557
  this.isDispatchingNativeInput = false;
442
558
  }
443
559
  }
560
+ /**
561
+ * Synchronise le défilement horizontal du ghost avec celui du champ d'entrée natif.
562
+ */
563
+ onScroll = () => {
564
+ if (this.ghost) {
565
+ this.ghost.scrollLeft = this.input.scrollLeft;
566
+ }
567
+ };
444
568
  /**
445
569
  * Intercepte les modifications directes de la propriété input.value (ex: input.value = '').
446
570
  */
@@ -552,15 +676,19 @@ var Wulf = (() => {
552
676
  audit() {
553
677
  const warnings = [];
554
678
  const doc = this.input.ownerDocument || document;
679
+ const root = typeof this.input.getRootNode === "function" ? this.input.getRootNode() : doc;
680
+ const labelRoot = typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root : doc;
555
681
  const ariaLabel = this.input.getAttribute("aria-label")?.trim();
556
682
  const hasValidLabelledby = this.checkAriaIdReferences(this.input, "aria-labelledby", warnings);
557
683
  const hasWrappingLabel = Boolean(this.input.closest("label"));
558
684
  const hasNativeLabels = Boolean(this.input.labels && this.input.labels.length > 0);
559
685
  let hasExplicitLabelFor = false;
560
- if (this.input.id && typeof CSS !== "undefined" && typeof CSS.escape === "function") {
561
- hasExplicitLabelFor = Boolean(doc.querySelector(`label[for="${CSS.escape(this.input.id)}"]`));
562
- } else if (this.input.id) {
563
- hasExplicitLabelFor = Boolean(doc.querySelector(`label[for="${this.input.id}"]`));
686
+ if (this.input.id) {
687
+ try {
688
+ hasExplicitLabelFor = Boolean(labelRoot.querySelector(`label[for="${safeCssEscape(this.input.id)}"]`));
689
+ } catch {
690
+ hasExplicitLabelFor = false;
691
+ }
564
692
  }
565
693
  if (!ariaLabel && !hasValidLabelledby && !hasWrappingLabel && !hasNativeLabels && !hasExplicitLabelFor) {
566
694
  warnings.push(
@@ -587,6 +715,11 @@ var Wulf = (() => {
587
715
  getSpecificAuditWarnings() {
588
716
  return [];
589
717
  }
718
+ /**
719
+ * Crochet appelé lorsque l'input bascule dynamiquement en type="password" (ex: toggle afficher/masquer).
720
+ */
721
+ onPasswordModeDetected() {
722
+ }
590
723
  /**
591
724
  * Supprime les éléments fantômes, restaure les propriétés et nettoie les attributs.
592
725
  */
@@ -601,25 +734,41 @@ var Wulf = (() => {
601
734
  this.mutationObserver.disconnect();
602
735
  this.mutationObserver = null;
603
736
  }
604
- this.input.removeEventListener("copy", this.onBaseCopy);
605
- this.input.removeEventListener("focus", this.onBaseFocus);
606
- this.input.removeEventListener("blur", this.onBaseBlur);
737
+ this.abortController.abort();
738
+ this.lastTrackedValue = "";
607
739
  this.unhookValueProperty();
608
740
  if (this.ghost) {
609
741
  this.ghost.remove();
610
742
  this.ghost = null;
611
743
  }
612
744
  if (this.isWrapperCreated && this.wrapper) {
613
- this.input.style.gridArea = "";
614
- this.input.style.boxSizing = "";
615
- if (this.wrapper.parentNode) {
745
+ if (this.wasWrapperFallbackStyled) {
746
+ this.input.style.gridArea = "";
747
+ this.input.style.boxSizing = "";
748
+ }
749
+ if (this.wrapper.parentElement) {
750
+ safeMove(this.wrapper.parentElement, this.input, this.wrapper);
751
+ } else if (this.wrapper.parentNode) {
616
752
  this.wrapper.parentNode.insertBefore(this.input, this.wrapper);
617
753
  }
618
754
  this.wrapper.remove();
619
755
  } else if (this.wrapper) {
620
756
  this.wrapper.removeAttribute("data-mask");
621
757
  this.wrapper.removeAttribute("data-disabled");
622
- this.wrapper.classList.remove("is-complete", "is-focused", "mask-focus-only", "has-selection", "has-ghost");
758
+ if (this.wasAlignSet && !this.hadInitialDataAlign) {
759
+ this.wrapper.removeAttribute("data-align");
760
+ }
761
+ if (this.wasAlignSet) {
762
+ this.wrapper.classList.remove("align-left", "align-right", "align-center");
763
+ }
764
+ this.wrapper.classList.remove(
765
+ "is-complete",
766
+ "is-focused",
767
+ "mask-focus-only",
768
+ "has-selection",
769
+ "has-ghost",
770
+ "has-visible-ghost"
771
+ );
623
772
  }
624
773
  }
625
774
  };
@@ -633,19 +782,34 @@ var Wulf = (() => {
633
782
  "#": { pattern: /[a-zA-Z0-9]/, transform: (c) => c.toUpperCase() }
634
783
  };
635
784
  var MaskEngine = class _MaskEngine {
785
+ pattern;
786
+ patterns = [];
787
+ subEngines = [];
788
+ activeEngine = null;
789
+ placeholderChar;
790
+ tokens;
791
+ slots = [];
792
+ fullMaskTemplate = "";
793
+ prefixSlotsCount = 0;
794
+ prefixString = "";
795
+ strict = true;
796
+ autoLowercase = false;
636
797
  constructor(pattern, options = {}) {
637
- this.patterns = [];
638
- this.subEngines = [];
639
- this.activeEngine = null;
640
- this.slots = [];
641
- this.fullMaskTemplate = "";
642
- this.prefixSlotsCount = 0;
643
- this.prefixString = "";
644
- this.strict = true;
645
- this.autoLowercase = false;
646
798
  const opts = options || {};
647
- this.placeholderChar = opts.placeholderChar || "_";
648
- this.tokens = { ...DEFAULT_TOKENS, ...opts.tokens || {} };
799
+ const rawPlaceholder = String(opts.placeholderChar || "_");
800
+ this.placeholderChar = Array.from(rawPlaceholder)[0] || "_";
801
+ const tokenMap = /* @__PURE__ */ Object.create(null);
802
+ for (const [k, v] of Object.entries(DEFAULT_TOKENS)) {
803
+ tokenMap[k] = v;
804
+ }
805
+ if (opts.tokens && typeof opts.tokens === "object") {
806
+ for (const [k, v] of Object.entries(opts.tokens)) {
807
+ if (k !== "__proto__" && k !== "constructor" && k !== "prototype" && v) {
808
+ tokenMap[k] = v;
809
+ }
810
+ }
811
+ }
812
+ this.tokens = tokenMap;
649
813
  this.strict = opts.strict !== false;
650
814
  this.autoLowercase = opts.autoLowercase ?? false;
651
815
  this.pattern = "";
@@ -671,11 +835,11 @@ var Wulf = (() => {
671
835
  compile(newPattern) {
672
836
  if (newPattern !== void 0) {
673
837
  if (Array.isArray(newPattern)) {
674
- this.patterns = [...newPattern];
838
+ this.patterns = newPattern.slice(0, 32).map((p) => String(p ?? "").slice(0, 512));
675
839
  this.pattern = this.patterns[0] || "";
676
840
  } else {
677
841
  this.patterns = [];
678
- this.pattern = newPattern;
842
+ this.pattern = String(newPattern ?? "").slice(0, 512);
679
843
  }
680
844
  }
681
845
  if (this.patterns.length > 0) {
@@ -705,7 +869,7 @@ var Wulf = (() => {
705
869
  i++;
706
870
  char = this.pattern[i];
707
871
  }
708
- const token = !isEscaped ? this.tokens[char] : void 0;
872
+ const token = !isEscaped && Object.hasOwn(this.tokens, char) ? this.tokens[char] : void 0;
709
873
  if (token) {
710
874
  isPrefixMode = false;
711
875
  this.slots.push({
@@ -752,7 +916,7 @@ var Wulf = (() => {
752
916
  return p.length > 0 && trimmed.toLowerCase().startsWith(p.trim().toLowerCase());
753
917
  });
754
918
  const candidates = withMatchingPrefix.length > 0 ? withMatchingPrefix : this.subEngines;
755
- const maxCandidate = [...candidates].sort((a, b) => b.getEditableCount() - a.getEditableCount())[0];
919
+ const maxCandidate = candidates.toSorted((a, b) => b.getEditableCount() - a.getEditableCount())[0];
756
920
  const raw = maxCandidate ? maxCandidate.extractRaw(trimmed) : trimmed;
757
921
  const rawLen = raw.length;
758
922
  for (const eng of candidates) {
@@ -808,6 +972,18 @@ var Wulf = (() => {
808
972
  */
809
973
  setStrict(strict) {
810
974
  this.strict = strict;
975
+ for (const sub of this.subEngines) {
976
+ sub.setStrict(strict);
977
+ }
978
+ }
979
+ /**
980
+ * Active ou désactive dynamiquement la mise en minuscules automatique.
981
+ */
982
+ setAutoLowercase(autoLowercase) {
983
+ this.autoLowercase = autoLowercase;
984
+ for (const sub of this.subEngines) {
985
+ sub.setAutoLowercase(autoLowercase);
986
+ }
811
987
  }
812
988
  /**
813
989
  * Indique si le masque est en mode strict.
@@ -826,7 +1002,8 @@ var Wulf = (() => {
826
1002
  return engine.extractRaw(input);
827
1003
  }
828
1004
  }
829
- const str = String(input ?? "");
1005
+ const maxInputLen = Math.max(4096, this.slots.length * 4);
1006
+ const str = String(input ?? "").slice(0, maxInputLen);
830
1007
  if (!str) return "";
831
1008
  let raw = "";
832
1009
  let inputIdx = 0;
@@ -895,7 +1072,8 @@ var Wulf = (() => {
895
1072
  return engine.format(rawValue);
896
1073
  }
897
1074
  }
898
- const rawStr = String(rawValue ?? "");
1075
+ const maxInputLen = Math.max(4096, this.slots.length * 4);
1076
+ const rawStr = String(rawValue ?? "").slice(0, maxInputLen);
899
1077
  if (!this.slots.length) return rawStr;
900
1078
  const cleanRaw = this.extractRaw(rawStr);
901
1079
  if (cleanRaw.length === 0) {
@@ -1030,9 +1208,10 @@ var Wulf = (() => {
1030
1208
 
1031
1209
  // src/mask/MaskHistory.ts
1032
1210
  var MaskHistory = class {
1211
+ stack = [];
1212
+ index = -1;
1213
+ maxDepth;
1033
1214
  constructor(maxDepth = 50) {
1034
- this.stack = [];
1035
- this.index = -1;
1036
1215
  this.maxDepth = maxDepth;
1037
1216
  }
1038
1217
  /**
@@ -1110,6 +1289,7 @@ var Wulf = (() => {
1110
1289
 
1111
1290
  // src/mask/MaskKeyboard.ts
1112
1291
  var MaskKeyboard = class {
1292
+ delegate;
1113
1293
  constructor(delegate) {
1114
1294
  this.delegate = delegate;
1115
1295
  }
@@ -1117,6 +1297,7 @@ var Wulf = (() => {
1117
1297
  * Analyse et traite l'événement keydown de l'input.
1118
1298
  */
1119
1299
  handleKeyDown(e) {
1300
+ if (isImeComposing(e)) return;
1120
1301
  const input = this.delegate.getInput();
1121
1302
  const engine = this.delegate.getEngine();
1122
1303
  const history = this.delegate.getHistory();
@@ -1210,7 +1391,7 @@ var Wulf = (() => {
1210
1391
  input.setSelectionRange(minPos, minPos);
1211
1392
  return;
1212
1393
  }
1213
- if (e.key === "Home" && !e.shiftKey) {
1394
+ if (e.key === "Home" && minPos > 0 && !e.shiftKey && !e.ctrlKey && !e.metaKey && !e.altKey) {
1214
1395
  e.preventDefault();
1215
1396
  input.setSelectionRange(minPos, minPos);
1216
1397
  return;
@@ -1315,6 +1496,23 @@ var Wulf = (() => {
1315
1496
 
1316
1497
  // src/mask/InputMask.ts
1317
1498
  var InputMask = class extends BaseInputMask {
1499
+ engine;
1500
+ history;
1501
+ keyboard;
1502
+ isComposing = false;
1503
+ isUndoingRedoing = false;
1504
+ isMouseDown = false;
1505
+ isApplyingMask = false;
1506
+ lastValue = "";
1507
+ lastInternalRemainingMask = "";
1508
+ isNotifying = false;
1509
+ hasPendingNotification = false;
1510
+ onChangeNativeHandler = () => {
1511
+ };
1512
+ wasInputModeInferred = false;
1513
+ cutTimerId = null;
1514
+ pasteTimerId = null;
1515
+ resetTimerId = null;
1318
1516
  constructor(targetOrWrapper, inputOrOptions, options) {
1319
1517
  const args = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, options);
1320
1518
  const wrap = args.wrapper;
@@ -1347,20 +1545,6 @@ var Wulf = (() => {
1347
1545
  onComplete: opts.onComplete || opts.oncomplete
1348
1546
  };
1349
1547
  super(wrap, inp, resolvedOptions);
1350
- this.isComposing = false;
1351
- this.isUndoingRedoing = false;
1352
- this.isMouseDown = false;
1353
- this.isApplyingMask = false;
1354
- this.lastValue = "";
1355
- this.lastInternalRemainingMask = "";
1356
- this.isNotifying = false;
1357
- this.hasPendingNotification = false;
1358
- this.onChangeNativeHandler = () => {
1359
- };
1360
- this.wasInputModeInferred = false;
1361
- this.cutTimerId = null;
1362
- this.pasteTimerId = null;
1363
- this.resetTimerId = null;
1364
1548
  this.history = new MaskHistory();
1365
1549
  this.engine = new MaskEngine(this.options.mask || "", {
1366
1550
  placeholderChar: this.options.placeholderChar,
@@ -1379,16 +1563,17 @@ var Wulf = (() => {
1379
1563
  enforceMinCursor: () => this.enforceMinCursor()
1380
1564
  });
1381
1565
  this.bindEvents();
1382
- this.lastValue = this.input.value;
1566
+ this.lastValue = this.isPasswordInput() ? this.computePasswordDigest(this.input.value) : this.input.value;
1383
1567
  this.syncInitialValue();
1384
1568
  this.runAuditWarning(this.options.audit);
1385
1569
  }
1386
1570
  getSpecificAuditWarnings() {
1387
1571
  const warnings = [];
1388
- const hasDescribedby = Boolean(this.input.getAttribute("aria-describedby")?.trim());
1572
+ const describedbyWarnings = [];
1573
+ const hasValidDescribedby = this.checkAriaIdReferences(this.input, "aria-describedby", describedbyWarnings);
1389
1574
  const hasPlaceholder = Boolean(this.input.getAttribute("placeholder")?.trim());
1390
1575
  const hasAriaPlaceholder = Boolean(this.input.getAttribute("aria-placeholder")?.trim());
1391
- if (!hasDescribedby && !hasPlaceholder && !hasAriaPlaceholder && !this.options.disabled) {
1576
+ if (!hasValidDescribedby && !hasPlaceholder && !hasAriaPlaceholder && !this.options.disabled) {
1392
1577
  warnings.push(
1393
1578
  "Indication du format attendu manquante : d\xE9finissez aria-describedby, placeholder ou aria-placeholder pour informer les technologies d'assistance (WCAG 3.3.2)."
1394
1579
  );
@@ -1398,6 +1583,14 @@ var Wulf = (() => {
1398
1583
  extractRawSnippet(snippet) {
1399
1584
  return this.engine.extractRaw(snippet);
1400
1585
  }
1586
+ onPasswordModeDetected() {
1587
+ this.history.clear();
1588
+ this.lastValue = "";
1589
+ this.lastInternalRemainingMask = "";
1590
+ this.lastTrackedValue = "";
1591
+ this.clearGhost();
1592
+ this.wrapper.removeAttribute("data-mask");
1593
+ }
1401
1594
  /**
1402
1595
  * Formate statiquement une valeur selon un masque donné sans nécessiter d'élément DOM.
1403
1596
  *
@@ -1420,11 +1613,12 @@ var Wulf = (() => {
1420
1613
  if (disabled) {
1421
1614
  this.wrapper.removeAttribute("data-mask");
1422
1615
  this.wrapper.classList.remove("is-complete", "has-selection");
1423
- if (this.ghost) this.ghost.textContent = "";
1616
+ this.clearGhost();
1424
1617
  this.checkValueChange();
1425
1618
  } else {
1426
1619
  this.applyMask(this.input.value, this.input.selectionStart ?? this.input.value.length);
1427
1620
  }
1621
+ this.syncInferredInputMode();
1428
1622
  }
1429
1623
  /**
1430
1624
  * Associe les écouteurs d'événements nécessaires.
@@ -1461,22 +1655,23 @@ var Wulf = (() => {
1461
1655
  if (this.isDestroyed) return;
1462
1656
  this.checkValueChange();
1463
1657
  };
1464
- this.input.addEventListener("beforeinput", this.onBeforeInput);
1465
- this.input.addEventListener("input", this.handleInput);
1466
- this.input.addEventListener("keydown", this.onKeyDown);
1467
- this.input.addEventListener("paste", this.onPaste);
1468
- this.input.addEventListener("focus", this.onFocus);
1469
- this.input.addEventListener("blur", this.onBlur);
1470
- this.input.addEventListener("click", this.onClick);
1471
- this.input.addEventListener("keyup", this.onKeyUp);
1472
- this.input.addEventListener("select", this.onSelect);
1473
- this.input.addEventListener("mousedown", this.onMouseDown);
1474
- window.addEventListener("mouseup", this.onMouseUp);
1475
- this.input.addEventListener("compositionstart", this.onCompositionStart);
1476
- this.input.addEventListener("compositionend", this.onCompositionEnd);
1477
- this.input.addEventListener("scroll", this.onScroll);
1478
- this.input.addEventListener("cut", this.onCutHandler);
1479
- this.input.addEventListener("change", this.onChangeNativeHandler);
1658
+ const { signal } = this.abortController;
1659
+ this.input.addEventListener("beforeinput", this.onBeforeInput, { signal });
1660
+ this.input.addEventListener("input", this.handleInput, { signal });
1661
+ this.input.addEventListener("keydown", this.onKeyDown, { signal });
1662
+ this.input.addEventListener("paste", this.onPaste, { signal });
1663
+ this.input.addEventListener("focus", this.onFocus, { signal });
1664
+ this.input.addEventListener("blur", this.onBlur, { signal });
1665
+ this.input.addEventListener("click", this.onClick, { signal });
1666
+ this.input.addEventListener("keyup", this.onKeyUp, { signal });
1667
+ this.input.addEventListener("select", this.onSelect, { signal });
1668
+ this.input.addEventListener("mousedown", this.onMouseDown, { signal });
1669
+ window.addEventListener("mouseup", this.onMouseUp, { signal });
1670
+ this.input.addEventListener("compositionstart", this.onCompositionStart, { signal });
1671
+ this.input.addEventListener("compositionend", this.onCompositionEnd, { signal });
1672
+ this.input.addEventListener("scroll", this.onScroll, { passive: true, signal });
1673
+ this.input.addEventListener("cut", this.onCutHandler, { signal });
1674
+ this.input.addEventListener("change", this.onChangeNativeHandler, { signal });
1480
1675
  if (this.input.form) {
1481
1676
  this.onFormResetHandler = () => {
1482
1677
  if (this.resetTimerId !== null) clearTimeout(this.resetTimerId);
@@ -1490,7 +1685,7 @@ var Wulf = (() => {
1490
1685
  }
1491
1686
  }, 0);
1492
1687
  };
1493
- this.input.form.addEventListener("reset", this.onFormResetHandler);
1688
+ this.input.form.addEventListener("reset", this.onFormResetHandler, { signal });
1494
1689
  }
1495
1690
  }
1496
1691
  /**
@@ -1527,29 +1722,12 @@ var Wulf = (() => {
1527
1722
  clearTimeout(this.resetTimerId);
1528
1723
  this.resetTimerId = null;
1529
1724
  }
1530
- this.input.removeEventListener("beforeinput", this.onBeforeInput);
1531
- this.input.removeEventListener("input", this.handleInput);
1532
- this.input.removeEventListener("keydown", this.onKeyDown);
1533
- this.input.removeEventListener("paste", this.onPaste);
1534
- this.input.removeEventListener("focus", this.onFocus);
1535
- this.input.removeEventListener("blur", this.onBlur);
1536
- this.input.removeEventListener("click", this.onClick);
1537
- this.input.removeEventListener("keyup", this.onKeyUp);
1538
- this.input.removeEventListener("select", this.onSelect);
1539
- this.input.removeEventListener("mousedown", this.onMouseDown);
1540
- window.removeEventListener("mouseup", this.onMouseUp);
1541
- this.input.removeEventListener("compositionstart", this.onCompositionStart);
1542
- this.input.removeEventListener("compositionend", this.onCompositionEnd);
1543
- this.input.removeEventListener("scroll", this.onScroll);
1544
- this.input.removeEventListener("cut", this.onCutHandler);
1545
- this.input.removeEventListener("change", this.onChangeNativeHandler);
1546
- if (this.input.form && this.onFormResetHandler) {
1547
- this.input.form.removeEventListener("reset", this.onFormResetHandler);
1548
- }
1549
1725
  if (this.wasInputModeInferred && this.input.getAttribute("inputmode") === "numeric") {
1550
1726
  this.input.removeAttribute("inputmode");
1551
1727
  }
1552
1728
  this.history.clear();
1729
+ this.lastValue = "";
1730
+ this.lastInternalRemainingMask = "";
1553
1731
  super.destroy();
1554
1732
  }
1555
1733
  /**
@@ -1623,6 +1801,7 @@ var Wulf = (() => {
1623
1801
  this.setStrict(strictVal !== "false");
1624
1802
  } else if (attrName === "data-mask-auto-lowercase") {
1625
1803
  this.options.autoLowercase = this.getAttr("data-mask-auto-lowercase") === "true";
1804
+ this.engine.setAutoLowercase(this.options.autoLowercase);
1626
1805
  this.engine.compile(this.options.mask || "");
1627
1806
  this.applyMask(this.input.value, this.input.selectionStart ?? this.input.value.length);
1628
1807
  } else if (attrName === "placeholder") {
@@ -1702,7 +1881,7 @@ var Wulf = (() => {
1702
1881
  if (this.options.disabled) return;
1703
1882
  if (this.isComposing) return;
1704
1883
  if (!this.engine.isStrict()) return;
1705
- if (e.inputType === "insertFromPaste") return;
1884
+ if (e.inputType === "insertFromPaste" || e.inputType === "insertReplacementText") return;
1706
1885
  if (e.inputType && e.inputType.startsWith("insert")) {
1707
1886
  const totalSlots = this.engine.getEditableCount();
1708
1887
  if (totalSlots > 0) {
@@ -1724,7 +1903,8 @@ var Wulf = (() => {
1724
1903
  if (this.isDispatchingNativeInput) return;
1725
1904
  if (this.isComposing) return;
1726
1905
  const hasOnInput = Boolean(this.options.onInput || this.options.oninput);
1727
- if (hasOnInput && this.input.value !== this.lastValue) {
1906
+ const currentComparison = this.isPasswordInput() ? this.computePasswordDigest(this.input.value) : this.input.value;
1907
+ if (hasOnInput && currentComparison !== this.lastValue) {
1728
1908
  this.checkValueChange();
1729
1909
  }
1730
1910
  if (this.options.disabled) {
@@ -1766,7 +1946,7 @@ var Wulf = (() => {
1766
1946
  }
1767
1947
  e.preventDefault();
1768
1948
  this.history.updateCurrentCursor(this.input.selectionStart ?? 0);
1769
- const rawPasted = e.clipboardData?.getData("text") || "";
1949
+ const rawPasted = (e.clipboardData?.getData("text") || "").slice(0, 4096);
1770
1950
  const pastedText = rawPasted.trim();
1771
1951
  if (!pastedText) return;
1772
1952
  const minPos = this.engine.getPrefixLength();
@@ -1818,8 +1998,14 @@ var Wulf = (() => {
1818
1998
  }
1819
1999
  onBlur() {
1820
2000
  this.wrapper.classList.remove("is-focused", "has-selection");
1821
- if (this.input.type === "password") {
2001
+ if (this.isPasswordInput()) {
1822
2002
  this.history.clear();
2003
+ this.lastValue = "";
2004
+ this.lastInternalRemainingMask = "";
2005
+ this.lastTrackedValue = "";
2006
+ this.clearGhost();
2007
+ this.wrapper.removeAttribute("data-mask");
2008
+ return;
1823
2009
  }
1824
2010
  this.updateGhost(this.input.value);
1825
2011
  }
@@ -1873,26 +2059,25 @@ var Wulf = (() => {
1873
2059
  // ==========================================================================
1874
2060
  updateGhost(formatted) {
1875
2061
  if (!this.ghost) return;
1876
- if (this.options.disabled) {
1877
- this.ghost.textContent = "";
2062
+ if (this.options.disabled || this.isPasswordInput()) {
2063
+ this.clearGhost();
1878
2064
  return;
1879
2065
  }
1880
2066
  const isCleanEmpty = !formatted || formatted === this.engine.getPrefix();
1881
2067
  if (this.shouldHideGhostForPlaceholder(isCleanEmpty)) {
1882
- this.ghost.textContent = "";
2068
+ this.clearGhost();
1883
2069
  return;
1884
2070
  }
1885
2071
  const fullTemplate = this.engine.getFullMaskTemplate();
1886
2072
  const rest = fullTemplate.length > formatted.length ? fullTemplate.substring(formatted.length) : "";
1887
- this.ghost.textContent = "";
1888
- const spanTyped = document.createElement("span");
2073
+ const doc = this.input.ownerDocument || document;
2074
+ const spanTyped = doc.createElement("span");
1889
2075
  spanTyped.className = "mask-ghost-typed";
1890
2076
  spanTyped.textContent = formatted;
1891
- const spanRemaining = document.createElement("span");
2077
+ const spanRemaining = doc.createElement("span");
1892
2078
  spanRemaining.className = "mask-ghost-remaining";
1893
2079
  spanRemaining.textContent = rest;
1894
- this.ghost.appendChild(spanTyped);
1895
- this.ghost.appendChild(spanRemaining);
2080
+ this.setGhostContent(spanTyped, spanRemaining);
1896
2081
  this.ghost.scrollLeft = this.input.scrollLeft;
1897
2082
  }
1898
2083
  applyMask(rawOrPartial, cursorPosition, forceExactCursor = false) {
@@ -1903,10 +2088,17 @@ var Wulf = (() => {
1903
2088
  try {
1904
2089
  formatted = this.engine.format(rawOrPartial);
1905
2090
  const remainingMask = this.engine.getRemainingMask(formatted);
2091
+ const isPwd = this.isPasswordInput();
1906
2092
  this.input.value = formatted;
1907
- this.lastInternalRemainingMask = remainingMask;
1908
- this.wrapper.setAttribute("data-mask", remainingMask);
1909
- this.updateGhost(formatted);
2093
+ if (isPwd) {
2094
+ this.lastInternalRemainingMask = "";
2095
+ this.wrapper.removeAttribute("data-mask");
2096
+ this.clearGhost();
2097
+ } else {
2098
+ this.lastInternalRemainingMask = remainingMask;
2099
+ this.wrapper.setAttribute("data-mask", remainingMask);
2100
+ this.updateGhost(formatted);
2101
+ }
1910
2102
  const minPos = this.engine.getPrefixLength();
1911
2103
  let safeCursor;
1912
2104
  if (forceExactCursor || this.isUndoingRedoing) {
@@ -1918,7 +2110,10 @@ var Wulf = (() => {
1918
2110
  this.input.setSelectionRange(safeCursor, safeCursor);
1919
2111
  isCompleted = this.isComplete();
1920
2112
  this.wrapper.classList.toggle("is-complete", isCompleted);
1921
- if (!this.isUndoingRedoing && this.input.type !== "password") {
2113
+ if (isPwd) {
2114
+ this.options.copyRaw = false;
2115
+ this.history.clear();
2116
+ } else if (!this.isUndoingRedoing) {
1922
2117
  this.history.push(this.getRawValue(), safeCursor);
1923
2118
  }
1924
2119
  } finally {
@@ -1927,10 +2122,11 @@ var Wulf = (() => {
1927
2122
  this.checkValueChange();
1928
2123
  }
1929
2124
  syncInitialValue() {
2125
+ const isPwd = this.isPasswordInput();
1930
2126
  if (this.options.disabled) {
1931
2127
  this.wrapper.removeAttribute("data-mask");
1932
- if (this.ghost) this.ghost.textContent = "";
1933
- this.lastValue = this.input.value;
2128
+ this.clearGhost();
2129
+ this.lastValue = isPwd ? this.computePasswordDigest(this.input.value) : this.input.value;
1934
2130
  this.checkValueChange();
1935
2131
  return;
1936
2132
  }
@@ -1943,13 +2139,17 @@ var Wulf = (() => {
1943
2139
  if (minPos > 0) {
1944
2140
  this.applyMask("", minPos);
1945
2141
  } else {
1946
- if (this.input.type !== "password") {
2142
+ if (!isPwd) {
1947
2143
  this.history.push("", 0);
2144
+ const fullTemplate = this.engine.getFullMaskTemplate();
2145
+ this.lastInternalRemainingMask = fullTemplate;
2146
+ this.wrapper.setAttribute("data-mask", fullTemplate);
2147
+ this.updateGhost("");
2148
+ } else {
2149
+ this.lastInternalRemainingMask = "";
2150
+ this.wrapper.removeAttribute("data-mask");
2151
+ this.clearGhost();
1948
2152
  }
1949
- const fullTemplate = this.engine.getFullMaskTemplate();
1950
- this.lastInternalRemainingMask = fullTemplate;
1951
- this.wrapper.setAttribute("data-mask", fullTemplate);
1952
- this.updateGhost("");
1953
2153
  this.checkValueChange();
1954
2154
  }
1955
2155
  }
@@ -1959,8 +2159,10 @@ var Wulf = (() => {
1959
2159
  * Gère de manière sûre la réentrance pour permettre d'appeler setMask() directement dans le callback.
1960
2160
  */
1961
2161
  checkValueChange(forceNotify = false) {
2162
+ const isPwd = this.isPasswordInput();
1962
2163
  const currentVal = this.input.value;
1963
- if (currentVal === this.lastValue && !forceNotify && !this.hasPendingNotification) {
2164
+ const currentComparison = isPwd ? this.computePasswordDigest(currentVal) : currentVal;
2165
+ if (currentComparison === this.lastValue && !forceNotify && !this.hasPendingNotification) {
1964
2166
  return;
1965
2167
  }
1966
2168
  if (this.isNotifying) {
@@ -1969,11 +2171,14 @@ var Wulf = (() => {
1969
2171
  }
1970
2172
  this.isNotifying = true;
1971
2173
  try {
1972
- while (this.input.value !== this.lastValue || this.hasPendingNotification || forceNotify) {
2174
+ let iterations = 0;
2175
+ const MAX_NOTIFICATION_ITERATIONS = 10;
2176
+ while (((isPwd ? this.computePasswordDigest(this.input.value) : this.input.value) !== this.lastValue || this.hasPendingNotification || forceNotify) && iterations < MAX_NOTIFICATION_ITERATIONS) {
2177
+ iterations++;
1973
2178
  this.hasPendingNotification = false;
1974
2179
  forceNotify = false;
1975
2180
  const valToNotify = this.input.value;
1976
- this.lastValue = valToNotify;
2181
+ this.lastValue = isPwd ? this.computePasswordDigest(valToNotify) : valToNotify;
1977
2182
  const raw = this.options.disabled ? valToNotify : this.getRawValue();
1978
2183
  const totalSlots = this.options.disabled ? 0 : this.engine.getEditableCount();
1979
2184
  const isComplete = this.isComplete();
@@ -2011,19 +2216,22 @@ var Wulf = (() => {
2011
2216
 
2012
2217
  // src/mask/AmountEngine.ts
2013
2218
  var AmountEngine = class _AmountEngine {
2219
+ options;
2014
2220
  constructor(options = {}) {
2015
2221
  let currency = options.currency ?? "";
2016
2222
  if (!currency && options.unit) {
2017
2223
  currency = options.unit;
2018
2224
  }
2019
2225
  const defaultPosition = currency === "$" || currency === "\xA3" || currency === "\xA5" ? "prefix" : "suffix";
2226
+ const rawDecimals = options.decimals !== void 0 ? Number(options.decimals) : 2;
2227
+ const safeDecimals = Number.isFinite(rawDecimals) ? Math.min(20, Math.max(0, Math.floor(rawDecimals))) : 2;
2020
2228
  this.options = {
2021
- currency,
2022
- unit: options.unit ?? currency,
2229
+ currency: String(currency).slice(0, 32),
2230
+ unit: String(options.unit ?? currency).slice(0, 32),
2023
2231
  currencyPosition: options.currencyPosition ?? defaultPosition,
2024
- decimals: options.decimals !== void 0 ? Math.max(0, options.decimals) : 2,
2025
- decimalSeparator: options.decimalSeparator ?? ",",
2026
- thousandSeparator: options.thousandSeparator ?? "\xA0",
2232
+ decimals: safeDecimals,
2233
+ decimalSeparator: String(options.decimalSeparator ?? ",").slice(0, 4) || ",",
2234
+ thousandSeparator: String(options.thousandSeparator ?? "\xA0").slice(0, 4),
2027
2235
  // Espace insécable
2028
2236
  allowNegative: options.allowNegative ?? false,
2029
2237
  min: options.min ?? -Infinity,
@@ -2034,7 +2242,7 @@ var Wulf = (() => {
2034
2242
  * Analyse et nettoie une saisie utilisateur pour extraire ses composantes numériques.
2035
2243
  */
2036
2244
  parse(input) {
2037
- let str = input.trim();
2245
+ let str = String(input ?? "").slice(0, 512).trim();
2038
2246
  let isNegative = false;
2039
2247
  if (this.options.allowNegative && str.includes("-")) {
2040
2248
  isNegative = true;
@@ -2075,7 +2283,9 @@ var Wulf = (() => {
2075
2283
  * @param rawCursor Position actuelle du curseur dans l'input natif
2076
2284
  */
2077
2285
  format(input, rawCursor = input.length, padDecimals = false) {
2078
- if (!input || input.trim() === "" || input === this.options.currency.trim()) {
2286
+ const safeInput = String(input ?? "").slice(0, 512);
2287
+ const safeRawCursor = Math.max(0, Math.min(rawCursor, safeInput.length));
2288
+ if (!safeInput || safeInput.trim() === "" || safeInput === this.options.currency.trim()) {
2079
2289
  return {
2080
2290
  formatted: "",
2081
2291
  rawNumber: null,
@@ -2084,10 +2294,10 @@ var Wulf = (() => {
2084
2294
  isValid: true
2085
2295
  };
2086
2296
  }
2087
- const prefixBeforeCursor = input.substring(0, rawCursor);
2297
+ const prefixBeforeCursor = safeInput.substring(0, safeRawCursor);
2088
2298
  const digitsBeforeCursor = prefixBeforeCursor.replace(/\D/g, "").length;
2089
2299
  const hadDecimalBeforeCursor = this.options.decimals > 0 && /[,.]/.test(prefixBeforeCursor);
2090
- const { isNegative, integerPart, decimalPart, hasDecimal } = this.parse(input);
2300
+ const { isNegative, integerPart, decimalPart, hasDecimal } = this.parse(safeInput);
2091
2301
  let effectiveDecimal = decimalPart;
2092
2302
  let effectiveHasDecimal = hasDecimal;
2093
2303
  if (padDecimals && this.options.decimals > 0 && (integerPart || decimalPart !== null)) {
@@ -2127,7 +2337,7 @@ var Wulf = (() => {
2127
2337
  isValid: true
2128
2338
  };
2129
2339
  }
2130
- const formattedInteger = (integerPart || "0").replace(/\B(?=(\d{3})+(?!\d))/g, this.options.thousandSeparator);
2340
+ const formattedInteger = this.formatThousands(integerPart || "0");
2131
2341
  let numberCore = formattedInteger;
2132
2342
  if (effectiveHasDecimal && this.options.decimals > 0) {
2133
2343
  numberCore += this.options.decimalSeparator + (effectiveDecimal ?? "");
@@ -2200,6 +2410,18 @@ var Wulf = (() => {
2200
2410
  const str = typeof value === "number" ? value.toString() : value;
2201
2411
  return engine.format(str).formatted;
2202
2412
  }
2413
+ formatThousands(digits) {
2414
+ const sep = this.options.thousandSeparator;
2415
+ if (!sep || digits.length <= 3) return digits;
2416
+ const parts = [];
2417
+ let i = digits.length;
2418
+ while (i > 0) {
2419
+ const start = Math.max(0, i - 3);
2420
+ parts.push(digits.slice(start, i));
2421
+ i = start;
2422
+ }
2423
+ return parts.reverse().join(sep);
2424
+ }
2203
2425
  escapeRegExp(string) {
2204
2426
  return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2205
2427
  }
@@ -2207,6 +2429,16 @@ var Wulf = (() => {
2207
2429
 
2208
2430
  // src/mask/InputAmountMask.ts
2209
2431
  var InputAmountMask = class extends BaseInputMask {
2432
+ engine;
2433
+ history;
2434
+ isUndoingRedoing = false;
2435
+ isApplying = false;
2436
+ isComposing = false;
2437
+ lastValue = "";
2438
+ wasInputModeInferred = false;
2439
+ cutTimerId = null;
2440
+ resetTimerId = null;
2441
+ cursorTimerId = null;
2210
2442
  constructor(targetOrWrapper, inputOrOptions, options) {
2211
2443
  const args = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, options);
2212
2444
  const wrap = args.wrapper;
@@ -2220,13 +2452,10 @@ var Wulf = (() => {
2220
2452
  ...opts
2221
2453
  };
2222
2454
  super(wrap, inp, resolvedOptions);
2223
- this.isUndoingRedoing = false;
2224
- this.isApplying = false;
2225
- this.isComposing = false;
2226
- this.lastValue = "";
2227
- this.cutTimerId = null;
2228
- this.resetTimerId = null;
2229
- this.input.inputMode = "decimal";
2455
+ if (!this.input.hasAttribute("inputmode")) {
2456
+ this.input.inputMode = "decimal";
2457
+ this.wasInputModeInferred = true;
2458
+ }
2230
2459
  this.history = new MaskHistory();
2231
2460
  this.engine = new AmountEngine(this.options);
2232
2461
  this.bindEvents();
@@ -2250,6 +2479,12 @@ var Wulf = (() => {
2250
2479
  if (!p.integerPart && !p.decimalPart) return "";
2251
2480
  return (p.isNegative ? "-" : "") + (p.integerPart || "0") + (p.decimalPart ? "." + p.decimalPart : "");
2252
2481
  }
2482
+ onPasswordModeDetected() {
2483
+ this.history.clear();
2484
+ this.lastValue = "";
2485
+ this.lastTrackedValue = "";
2486
+ this.clearGhost();
2487
+ }
2253
2488
  /**
2254
2489
  * Formate statiquement une valeur sans nécessiter d'élément DOM.
2255
2490
  */
@@ -2264,7 +2499,9 @@ var Wulf = (() => {
2264
2499
  this.applyAmount(strVal, strVal.length);
2265
2500
  }
2266
2501
  onDisabledChange(disabled) {
2267
- if (!disabled) {
2502
+ if (disabled) {
2503
+ this.clearGhost();
2504
+ } else {
2268
2505
  this.applyAmount(this.input.value, this.input.selectionStart ?? this.input.value.length);
2269
2506
  }
2270
2507
  }
@@ -2287,15 +2524,16 @@ var Wulf = (() => {
2287
2524
  this.applyAmount(this.input.value, cur);
2288
2525
  }, 0);
2289
2526
  };
2290
- this.input.addEventListener("input", this.handleInput);
2291
- this.input.addEventListener("keydown", this.handleKeyDown);
2292
- this.input.addEventListener("blur", this.handleBlur);
2293
- this.input.addEventListener("focus", this.handleFocus);
2294
- this.input.addEventListener("click", this.handleClick);
2295
- this.input.addEventListener("scroll", this.onScroll);
2296
- this.input.addEventListener("cut", this.onCutHandler);
2297
- this.input.addEventListener("compositionstart", this.onCompositionStart);
2298
- this.input.addEventListener("compositionend", this.onCompositionEnd);
2527
+ const { signal } = this.abortController;
2528
+ this.input.addEventListener("input", this.handleInput, { signal });
2529
+ this.input.addEventListener("keydown", this.handleKeyDown, { signal });
2530
+ this.input.addEventListener("blur", this.handleBlur, { signal });
2531
+ this.input.addEventListener("focus", this.handleFocus, { signal });
2532
+ this.input.addEventListener("click", this.handleClick, { signal });
2533
+ this.input.addEventListener("scroll", this.onScroll, { passive: true, signal });
2534
+ this.input.addEventListener("cut", this.onCutHandler, { signal });
2535
+ this.input.addEventListener("compositionstart", this.onCompositionStart, { signal });
2536
+ this.input.addEventListener("compositionend", this.onCompositionEnd, { signal });
2299
2537
  if (this.input.form) {
2300
2538
  this.onFormResetHandler = () => {
2301
2539
  if (this.resetTimerId !== null) {
@@ -2308,7 +2546,7 @@ var Wulf = (() => {
2308
2546
  this.applyAmount(this.input.value, this.input.value.length);
2309
2547
  }, 0);
2310
2548
  };
2311
- this.input.form.addEventListener("reset", this.onFormResetHandler);
2549
+ this.input.form.addEventListener("reset", this.onFormResetHandler, { signal });
2312
2550
  }
2313
2551
  }
2314
2552
  onCompositionStart() {
@@ -2327,12 +2565,20 @@ var Wulf = (() => {
2327
2565
  const result = this.engine.format(val, cursor);
2328
2566
  this.setNativeValue(result.formatted);
2329
2567
  this.input.setSelectionRange(result.cursor, result.cursor);
2330
- if (!this.isUndoingRedoing && this.input.type !== "password") {
2331
- this.history.push(result.rawValue, result.cursor);
2568
+ const isPwd = this.isPasswordInput();
2569
+ if (isPwd) {
2570
+ this.options.copyRaw = false;
2571
+ this.history.clear();
2572
+ this.clearGhost();
2573
+ } else {
2574
+ if (!this.isUndoingRedoing) {
2575
+ this.history.push(result.rawValue, result.cursor);
2576
+ }
2577
+ this.updateGhost(result);
2332
2578
  }
2333
- this.updateGhost(result);
2334
- if (this.lastValue !== result.formatted) {
2335
- this.lastValue = result.formatted;
2579
+ const nextComparison = isPwd ? this.computePasswordDigest(result.formatted) : result.formatted;
2580
+ if (this.lastValue !== nextComparison) {
2581
+ this.lastValue = nextComparison;
2336
2582
  this.notifyChange(result);
2337
2583
  }
2338
2584
  } finally {
@@ -2343,18 +2589,18 @@ var Wulf = (() => {
2343
2589
  if (!this.ghost) return;
2344
2590
  if (!result.formatted) {
2345
2591
  if (this.shouldHideGhostForPlaceholder(true)) {
2346
- this.ghost.textContent = "";
2592
+ this.clearGhost();
2347
2593
  return;
2348
2594
  }
2349
2595
  const hint = this.options.currency ? this.options.currencyPosition === "prefix" ? `${this.options.currency} 0` : `0 ${this.options.currency}` : "0,00";
2350
- this.ghost.textContent = "";
2351
- const span = document.createElement("span");
2596
+ const doc = this.input.ownerDocument || document;
2597
+ const span = doc.createElement("span");
2352
2598
  span.className = "mask-ghost-remaining";
2353
2599
  span.textContent = hint;
2354
- this.ghost.appendChild(span);
2600
+ this.setGhostContent(span);
2355
2601
  return;
2356
2602
  }
2357
- this.ghost.textContent = "";
2603
+ this.clearGhost();
2358
2604
  this.ghost.scrollLeft = this.input.scrollLeft;
2359
2605
  }
2360
2606
  handleInput() {
@@ -2365,7 +2611,7 @@ var Wulf = (() => {
2365
2611
  this.applyAmount(rawVal, cur);
2366
2612
  }
2367
2613
  handleKeyDown(e) {
2368
- if (this.options.disabled) return;
2614
+ if (this.options.disabled || isImeComposing(e)) return;
2369
2615
  if ((e.ctrlKey || e.metaKey) && (e.key === "z" || e.key === "Z")) {
2370
2616
  e.preventDefault();
2371
2617
  if (e.shiftKey) this.redo();
@@ -2417,10 +2663,18 @@ var Wulf = (() => {
2417
2663
  }
2418
2664
  }
2419
2665
  }
2420
- setTimeout(() => this.enforceCursorBounds(), 0);
2666
+ if (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "Home" || e.key === "End") {
2667
+ if (this.cursorTimerId !== null) {
2668
+ clearTimeout(this.cursorTimerId);
2669
+ }
2670
+ this.cursorTimerId = window.setTimeout(() => {
2671
+ this.cursorTimerId = null;
2672
+ this.enforceCursorBounds();
2673
+ }, 0);
2674
+ }
2421
2675
  }
2422
2676
  enforceCursorBounds() {
2423
- if (!this.input.value || this.options.disabled) return;
2677
+ if (this.isDestroyed || !this.isFocused || document.activeElement !== this.input || !this.input.value || this.options.disabled) return;
2424
2678
  const start = this.input.selectionStart ?? 0;
2425
2679
  const end = this.input.selectionEnd ?? 0;
2426
2680
  if (start !== end) return;
@@ -2451,8 +2705,12 @@ var Wulf = (() => {
2451
2705
  }
2452
2706
  handleBlur() {
2453
2707
  this.wrapper.classList.remove("is-focused");
2454
- if (this.input.type === "password") {
2708
+ if (this.isPasswordInput()) {
2455
2709
  this.history.clear();
2710
+ this.lastValue = "";
2711
+ this.lastTrackedValue = "";
2712
+ this.clearGhost();
2713
+ return;
2456
2714
  }
2457
2715
  if (this.options.padDecimalsOnBlur && !this.options.disabled && this.input.value.trim().length > 0) {
2458
2716
  const paddedResult = this.engine.format(this.input.value, this.input.value.length, true);
@@ -2548,30 +2806,62 @@ var Wulf = (() => {
2548
2806
  clearTimeout(this.resetTimerId);
2549
2807
  this.resetTimerId = null;
2550
2808
  }
2551
- this.input.removeEventListener("input", this.handleInput);
2552
- this.input.removeEventListener("keydown", this.handleKeyDown);
2553
- this.input.removeEventListener("blur", this.handleBlur);
2554
- this.input.removeEventListener("focus", this.handleFocus);
2555
- this.input.removeEventListener("click", this.handleClick);
2556
- this.input.removeEventListener("scroll", this.onScroll);
2557
- this.input.removeEventListener("cut", this.onCutHandler);
2558
- this.input.removeEventListener("compositionstart", this.onCompositionStart);
2559
- this.input.removeEventListener("compositionend", this.onCompositionEnd);
2560
- if (this.input.form && this.onFormResetHandler) {
2561
- this.input.form.removeEventListener("reset", this.onFormResetHandler);
2809
+ if (this.cursorTimerId !== null) {
2810
+ clearTimeout(this.cursorTimerId);
2811
+ this.cursorTimerId = null;
2562
2812
  }
2813
+ if (this.wasInputModeInferred && this.input.getAttribute("inputmode") === "decimal") {
2814
+ this.input.removeAttribute("inputmode");
2815
+ }
2816
+ this.lastValue = "";
2563
2817
  this.history.clear();
2564
2818
  super.destroy();
2565
2819
  }
2566
2820
  };
2567
2821
 
2568
2822
  // src/mask/EmailEngine.ts
2569
- var _EmailEngine = class _EmailEngine {
2823
+ var EmailEngine = class _EmailEngine {
2824
+ domains;
2825
+ tlds;
2826
+ suggestOnAt;
2827
+ defaultDomain = null;
2828
+ defaultTld = "__";
2829
+ static DEFAULT_DOMAINS = [
2830
+ "gmail.com",
2831
+ "outlook.com",
2832
+ "orange.fr",
2833
+ "free.fr",
2834
+ "sfr.fr",
2835
+ "yahoo.com",
2836
+ "hotmail.com",
2837
+ "icloud.com",
2838
+ "laposte.net",
2839
+ "proton.me"
2840
+ ];
2841
+ static DEFAULT_TLDS = [
2842
+ "com",
2843
+ "fr",
2844
+ "net",
2845
+ "org",
2846
+ "eu",
2847
+ "io",
2848
+ "co",
2849
+ "info",
2850
+ "biz",
2851
+ "me",
2852
+ "tv",
2853
+ "fi",
2854
+ "be",
2855
+ "ch",
2856
+ "ca",
2857
+ "uk",
2858
+ "de",
2859
+ "es",
2860
+ "it"
2861
+ ];
2570
2862
  constructor(options = {}) {
2571
- this.defaultDomain = null;
2572
- this.defaultTld = "__";
2573
2863
  this.domains = options.domains && options.domains.length > 0 ? options.domains : _EmailEngine.DEFAULT_DOMAINS;
2574
- this.tlds = options.tlds && options.tlds.length > 0 ? options.tlds.map((t) => t.trim().replace(/^\./, "")).filter(Boolean) : [..._EmailEngine.DEFAULT_TLDS];
2864
+ this.tlds = options.tlds && options.tlds.length > 0 ? options.tlds.slice(0, 200).map((t) => String(t).trim().replace(/^\./, "").slice(0, 32)).filter(Boolean) : [..._EmailEngine.DEFAULT_TLDS];
2575
2865
  this.suggestOnAt = options.suggestOnAt ?? true;
2576
2866
  this.setDefaultDomain(options.defaultDomain ?? null);
2577
2867
  this.setDefaultTld(options.defaultTld !== void 0 ? options.defaultTld : "__");
@@ -2604,7 +2894,7 @@ var Wulf = (() => {
2604
2894
  * Définit ou modifie la liste des extensions (TLD) proposées par ordre de priorité.
2605
2895
  */
2606
2896
  setTlds(tlds) {
2607
- this.tlds = tlds && tlds.length > 0 ? tlds.map((t) => t.trim().replace(/^\./, "")).filter(Boolean) : [..._EmailEngine.DEFAULT_TLDS];
2897
+ this.tlds = tlds && tlds.length > 0 ? tlds.slice(0, 200).map((t) => String(t).trim().replace(/^\./, "").slice(0, 32)).filter(Boolean) : [..._EmailEngine.DEFAULT_TLDS];
2608
2898
  }
2609
2899
  /**
2610
2900
  * Retourne l'ensemble des extensions (TLD) correspondant au fragment saisi après le dernier point,
@@ -2621,7 +2911,7 @@ var Wulf = (() => {
2621
2911
  * Retourne l'ensemble des domaines correspondant à la saisie courante.
2622
2912
  */
2623
2913
  getMatchingDomains(input) {
2624
- const val = input ?? "";
2914
+ const val = String(input ?? "").slice(0, 512);
2625
2915
  if (!val.includes("@")) {
2626
2916
  return this.defaultDomain ? [this.defaultDomain] : [];
2627
2917
  }
@@ -2643,7 +2933,7 @@ var Wulf = (() => {
2643
2933
  * @param matchIndex Index de la suggestion à sélectionner si plusieurs domaines/TLD correspondent (permet le cyclage)
2644
2934
  */
2645
2935
  getSuggestion(input, matchIndex = 0) {
2646
- const val = input ?? "";
2936
+ const val = String(input ?? "").slice(0, 512);
2647
2937
  if (!val.includes("@")) {
2648
2938
  if (this.defaultDomain) {
2649
2939
  return {
@@ -2675,22 +2965,22 @@ var Wulf = (() => {
2675
2965
  };
2676
2966
  }
2677
2967
  if (domainPart.length === 0 || domainPart.startsWith(".")) {
2678
- return { full: input, remaining: "", matchedDomain: null, isHintOnly: false };
2968
+ return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
2679
2969
  }
2680
2970
  const lowerDomain = domainPart.toLowerCase();
2681
2971
  if (this.domains.some((d) => d.toLowerCase() === lowerDomain)) {
2682
- return { full: input, remaining: "", matchedDomain: domainPart, isHintOnly: false };
2972
+ return { full: val, remaining: "", matchedDomain: domainPart, isHintOnly: false };
2683
2973
  }
2684
2974
  const lastDotIndex = domainPart.lastIndexOf(".");
2685
2975
  if (lastDotIndex === -1) {
2686
2976
  if (!this.defaultTld) {
2687
- return { full: input, remaining: "", matchedDomain: null, isHintOnly: false };
2977
+ return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
2688
2978
  }
2689
2979
  const isHint = this.defaultTld.includes("_");
2690
2980
  const remaining = `.${this.defaultTld}`;
2691
2981
  const fullDomain = `${domainPart}.${this.defaultTld}`;
2692
2982
  return {
2693
- full: isHint ? input : `${localPart}@${fullDomain}`,
2983
+ full: isHint ? val : `${localPart}@${fullDomain}`,
2694
2984
  remaining,
2695
2985
  matchedDomain: isHint ? null : fullDomain,
2696
2986
  isHintOnly: isHint
@@ -2699,7 +2989,7 @@ var Wulf = (() => {
2699
2989
  const hostPart = domainPart.substring(0, lastDotIndex);
2700
2990
  const tldPart = domainPart.substring(lastDotIndex + 1);
2701
2991
  if (!hostPart || hostPart.endsWith(".")) {
2702
- return { full: input, remaining: "", matchedDomain: null, isHintOnly: false };
2992
+ return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
2703
2993
  }
2704
2994
  if (tldPart.length === 0) {
2705
2995
  if (this.defaultTld && !this.defaultTld.includes("_")) {
@@ -2713,15 +3003,18 @@ var Wulf = (() => {
2713
3003
  }
2714
3004
  if (this.defaultTld && this.defaultTld.includes("_")) {
2715
3005
  return {
2716
- full: input,
3006
+ full: val,
2717
3007
  remaining: this.defaultTld,
2718
3008
  matchedDomain: null,
2719
3009
  isHintOnly: true
2720
3010
  };
2721
3011
  }
2722
- return { full: input, remaining: "", matchedDomain: null, isHintOnly: false };
3012
+ return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
2723
3013
  }
2724
3014
  const lowerTld = tldPart.toLowerCase();
3015
+ if (this.tlds.some((t) => t.toLowerCase() === lowerTld)) {
3016
+ return { full: val, remaining: "", matchedDomain: domainPart, isHintOnly: false };
3017
+ }
2725
3018
  const matchingTlds = this.getMatchingTlds(tldPart);
2726
3019
  if (matchingTlds.length > 0) {
2727
3020
  const safeTldIndex = (matchIndex % matchingTlds.length + matchingTlds.length) % matchingTlds.length;
@@ -2739,53 +3032,34 @@ var Wulf = (() => {
2739
3032
  const remaining = this.defaultTld.substring(tldPart.length);
2740
3033
  if (remaining.includes("_")) {
2741
3034
  return {
2742
- full: input,
3035
+ full: val,
2743
3036
  remaining,
2744
3037
  matchedDomain: null,
2745
3038
  isHintOnly: true
2746
3039
  };
2747
3040
  }
2748
3041
  }
2749
- return { full: input, remaining: "", matchedDomain: null, isHintOnly: false };
3042
+ return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
2750
3043
  }
2751
3044
  };
2752
- _EmailEngine.DEFAULT_DOMAINS = [
2753
- "gmail.com",
2754
- "outlook.com",
2755
- "orange.fr",
2756
- "free.fr",
2757
- "sfr.fr",
2758
- "yahoo.com",
2759
- "hotmail.com",
2760
- "icloud.com",
2761
- "laposte.net",
2762
- "proton.me"
2763
- ];
2764
- _EmailEngine.DEFAULT_TLDS = [
2765
- "com",
2766
- "fr",
2767
- "net",
2768
- "org",
2769
- "eu",
2770
- "io",
2771
- "co",
2772
- "info",
2773
- "biz",
2774
- "me",
2775
- "tv",
2776
- "fi",
2777
- "be",
2778
- "ch",
2779
- "ca",
2780
- "uk",
2781
- "de",
2782
- "es",
2783
- "it"
2784
- ];
2785
- var EmailEngine = _EmailEngine;
2786
3045
 
2787
3046
  // src/mask/InputEmailMask.ts
2788
3047
  var InputEmailMask = class extends BaseInputMask {
3048
+ engine;
3049
+ currentSuggestion = { full: "", remaining: "", matchedDomain: null };
3050
+ currentSuggestionIndex = 0;
3051
+ wasAriaAutocompleteSet = false;
3052
+ wasAutocorrectSet = false;
3053
+ wasAutocapitalizeSet = false;
3054
+ wasSpellcheckSet = false;
3055
+ wasInputModeInferred = false;
3056
+ isComposing = false;
3057
+ lastNotifiedValue = "";
3058
+ srStatusEl = null;
3059
+ srAnnounceTimerId = null;
3060
+ lastAnnouncedSuggestion = "";
3061
+ cutTimerId = null;
3062
+ resetTimerId = null;
2789
3063
  constructor(targetOrWrapper, inputOrOptions, options) {
2790
3064
  const args = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, options);
2791
3065
  const wrap = args.wrapper;
@@ -2811,30 +3085,55 @@ var Wulf = (() => {
2811
3085
  ...resolvedDefaultTld !== void 0 ? { defaultTld: resolvedDefaultTld } : {}
2812
3086
  };
2813
3087
  super(wrap, inp, resolvedOptions);
2814
- this.currentSuggestion = { full: "", remaining: "", matchedDomain: null };
2815
- this.currentSuggestionIndex = 0;
2816
- this.wasAriaAutocompleteSet = false;
2817
- this.cutTimerId = null;
2818
- this.resetTimerId = null;
2819
- this.input.inputMode = "email";
3088
+ if (!this.input.hasAttribute("inputmode")) {
3089
+ this.input.inputMode = "email";
3090
+ this.wasInputModeInferred = true;
3091
+ }
3092
+ if (!this.input.hasAttribute("autocorrect")) {
3093
+ this.input.setAttribute("autocorrect", "off");
3094
+ this.wasAutocorrectSet = true;
3095
+ }
3096
+ if (!this.input.hasAttribute("autocapitalize")) {
3097
+ this.input.setAttribute("autocapitalize", "none");
3098
+ this.wasAutocapitalizeSet = true;
3099
+ }
3100
+ if (!this.input.hasAttribute("spellcheck")) {
3101
+ this.input.setAttribute("spellcheck", "false");
3102
+ this.wasSpellcheckSet = true;
3103
+ }
2820
3104
  if (this.options.setAriaAutocomplete && !this.input.hasAttribute("aria-autocomplete")) {
2821
3105
  this.input.setAttribute("aria-autocomplete", "inline");
2822
3106
  this.wasAriaAutocompleteSet = true;
2823
3107
  }
2824
3108
  this.engine = new EmailEngine(this.options);
3109
+ this.lastNotifiedValue = this.isPasswordInput() ? "" : this.input.value;
2825
3110
  this.bindEvents();
2826
- if (!this.options.disabled) {
3111
+ if (!this.options.disabled && !this.isPasswordInput()) {
2827
3112
  this.updateSuggestion();
2828
3113
  }
2829
3114
  this.runAuditWarning(this.options.audit);
2830
3115
  }
3116
+ onPasswordModeDetected() {
3117
+ if (this.srAnnounceTimerId !== null) {
3118
+ clearTimeout(this.srAnnounceTimerId);
3119
+ this.srAnnounceTimerId = null;
3120
+ }
3121
+ this.lastNotifiedValue = "";
3122
+ this.lastTrackedValue = "";
3123
+ this.lastAnnouncedSuggestion = "";
3124
+ this.currentSuggestion = { full: "", remaining: "", matchedDomain: null };
3125
+ if (this.srStatusEl) {
3126
+ this.srStatusEl.textContent = "";
3127
+ }
3128
+ this.clearGhost();
3129
+ }
2831
3130
  onNativeValueSet(_strVal) {
2832
- if (this.options.disabled) return;
3131
+ if (this.options.disabled || this.isComposing || this.isPasswordInput()) return;
2833
3132
  this.updateSuggestion();
2834
3133
  }
2835
3134
  onDisabledChange(disabled) {
2836
- if (disabled) {
2837
- if (this.ghost) this.ghost.textContent = "";
3135
+ if (disabled || this.isPasswordInput()) {
3136
+ this.clearGhost();
2838
3137
  } else {
2839
3138
  this.updateSuggestion();
2840
3139
  }
@@ -2850,16 +3149,26 @@ var Wulf = (() => {
2850
3149
  }
2851
3150
  this.cutTimerId = window.setTimeout(() => {
2852
3151
  this.cutTimerId = null;
2853
- if (this.isDestroyed || this.options.disabled) return;
3152
+ if (this.isDestroyed || this.options.disabled || this.isPasswordInput()) return;
2854
3153
  this.updateSuggestion();
2855
3154
  }, 0);
2856
3155
  };
2857
- this.input.addEventListener("input", this.handleInput);
2858
- this.input.addEventListener("keydown", this.handleKeyDown);
2859
- this.input.addEventListener("blur", this.handleBlur);
2860
- this.input.addEventListener("focus", this.handleFocus);
2861
- this.input.addEventListener("scroll", this.onScroll);
2862
- this.input.addEventListener("cut", this.onCutHandler);
3156
+ const { signal } = this.abortController;
3157
+ this.input.addEventListener("input", this.handleInput, { signal });
3158
+ this.input.addEventListener("keydown", this.handleKeyDown, { signal });
3159
+ this.input.addEventListener("blur", this.handleBlur, { signal });
3160
+ this.input.addEventListener("focus", this.handleFocus, { signal });
3161
+ this.input.addEventListener("scroll", this.onScroll, { passive: true, signal });
3162
+ this.input.addEventListener("cut", this.onCutHandler, { signal });
3163
+ this.input.addEventListener("compositionstart", () => {
3164
+ this.isComposing = true;
3165
+ }, { signal });
3166
+ this.input.addEventListener("compositionend", () => {
3167
+ this.isComposing = false;
3168
+ if (!this.isDestroyed && !this.options.disabled && !this.isPasswordInput()) {
3169
+ this.handleInput();
3170
+ }
3171
+ }, { signal });
2863
3172
  if (this.input.form) {
2864
3173
  this.onFormResetHandler = () => {
2865
3174
  if (this.resetTimerId !== null) {
@@ -2867,47 +3176,112 @@ var Wulf = (() => {
2867
3176
  }
2868
3177
  this.resetTimerId = window.setTimeout(() => {
2869
3178
  this.resetTimerId = null;
2870
- if (this.isDestroyed || this.options.disabled) return;
3179
+ if (this.isDestroyed || this.options.disabled || this.isPasswordInput()) return;
2871
3180
  this.updateSuggestion();
2872
3181
  }, 0);
2873
3182
  };
2874
- this.input.form.addEventListener("reset", this.onFormResetHandler);
3183
+ this.input.form.addEventListener("reset", this.onFormResetHandler, { signal });
2875
3184
  }
2876
3185
  }
2877
- updateSuggestion() {
2878
- if (this.options.disabled) {
2879
- if (this.ghost) this.ghost.textContent = "";
3186
+ ensureSrStatusEl() {
3187
+ if (this.srStatusEl && this.wrapper.contains(this.srStatusEl)) {
3188
+ return this.srStatusEl;
3189
+ }
3190
+ const doc = this.input.ownerDocument || (typeof document !== "undefined" ? document : null);
3191
+ if (!doc) return null;
3192
+ const status = doc.createElement("span");
3193
+ status.className = "wulf-mask-sr-status";
3194
+ status.setAttribute("aria-live", "polite");
3195
+ status.setAttribute("aria-atomic", "true");
3196
+ this.wrapper.appendChild(status);
3197
+ this.srStatusEl = status;
3198
+ return status;
3199
+ }
3200
+ scheduleSuggestionAnnouncement(immediate = false) {
3201
+ if (this.srAnnounceTimerId !== null) {
3202
+ clearTimeout(this.srAnnounceTimerId);
3203
+ this.srAnnounceTimerId = null;
3204
+ }
3205
+ if (!this.options.setAriaAutocomplete || !this.isFocused || this.isDestroyed || this.isPasswordInput()) {
3206
+ return;
3207
+ }
3208
+ const suggestion = this.currentSuggestion;
3209
+ if (!suggestion.remaining || suggestion.isHintOnly) {
3210
+ this.lastAnnouncedSuggestion = "";
3211
+ if (this.srStatusEl) {
3212
+ this.srStatusEl.textContent = "";
3213
+ }
3214
+ return;
3215
+ }
3216
+ const textToAnnounce = suggestion.full;
3217
+ if (textToAnnounce === this.lastAnnouncedSuggestion && !immediate) {
3218
+ return;
3219
+ }
3220
+ const run = () => {
3221
+ this.srAnnounceTimerId = null;
3222
+ if (this.isDestroyed || !this.isFocused || this.isPasswordInput()) return;
3223
+ this.lastAnnouncedSuggestion = textToAnnounce;
3224
+ const doc = this.input.ownerDocument || (typeof document !== "undefined" ? document : null);
3225
+ const docWithAriaNotify = doc;
3226
+ if (docWithAriaNotify && typeof docWithAriaNotify.ariaNotify === "function") {
3227
+ try {
3228
+ docWithAriaNotify.ariaNotify(textToAnnounce, { priority: "normal" });
3229
+ return;
3230
+ } catch {
3231
+ }
3232
+ }
3233
+ const statusEl = this.ensureSrStatusEl();
3234
+ if (statusEl) {
3235
+ statusEl.textContent = statusEl.textContent === textToAnnounce ? `${textToAnnounce}\xA0` : textToAnnounce;
3236
+ }
3237
+ };
3238
+ if (immediate) {
3239
+ run();
3240
+ } else {
3241
+ this.srAnnounceTimerId = window.setTimeout(run, 250);
3242
+ }
3243
+ }
3244
+ updateSuggestion(announceOptions) {
3245
+ if (this.options.disabled || this.isPasswordInput()) {
3246
+ this.currentSuggestion = { full: "", remaining: "", matchedDomain: null };
3247
+ this.clearGhost();
2880
3248
  return;
2881
3249
  }
2882
3250
  const val = this.input.value;
2883
3251
  this.currentSuggestion = this.engine.getSuggestion(val, this.currentSuggestionIndex);
2884
3252
  if (!this.ghost) return;
2885
3253
  if (this.shouldHideGhostForPlaceholder(val.length === 0)) {
2886
- this.ghost.textContent = "";
3254
+ this.clearGhost();
2887
3255
  } else if (this.currentSuggestion.remaining) {
2888
- this.ghost.textContent = "";
2889
- const spanTyped = document.createElement("span");
3256
+ const doc = this.input.ownerDocument || document;
3257
+ const spanTyped = doc.createElement("span");
2890
3258
  spanTyped.className = "mask-ghost-typed";
2891
3259
  spanTyped.textContent = val;
2892
- const spanRemaining = document.createElement("span");
3260
+ const spanRemaining = doc.createElement("span");
2893
3261
  spanRemaining.className = "mask-ghost-remaining";
2894
3262
  spanRemaining.textContent = this.currentSuggestion.remaining;
2895
- this.ghost.appendChild(spanTyped);
2896
- this.ghost.appendChild(spanRemaining);
3263
+ this.setGhostContent(spanTyped, spanRemaining);
2897
3264
  } else {
2898
- this.ghost.textContent = "";
3265
+ this.clearGhost();
2899
3266
  }
2900
3267
  this.ghost.scrollLeft = this.input.scrollLeft;
3268
+ if (announceOptions?.announce) {
3269
+ this.scheduleSuggestionAnnouncement(Boolean(announceOptions.immediate));
3270
+ }
2901
3271
  const detail = this.getDetail();
2902
3272
  if (this.options.onInput) {
2903
3273
  this.options.onInput(detail);
2904
3274
  }
2905
3275
  this.input.dispatchEvent(new CustomEvent("mask:input", { bubbles: true, detail }));
2906
- this.dispatchNativeInput();
3276
+ if (val !== this.lastNotifiedValue) {
3277
+ this.lastNotifiedValue = val;
3278
+ this.dispatchNativeInput();
3279
+ }
2907
3280
  }
2908
- handleInput() {
3281
+ handleInput(e) {
2909
3282
  if (this.isDispatchingNativeInput) return;
2910
- if (this.options.disabled) return;
3283
+ if (this.options.disabled || this.isPasswordInput()) return;
3284
+ if (this.isComposing || e && "isComposing" in e && e.isComposing) return;
2911
3285
  if (this.options.autoLowercase) {
2912
3286
  const start = this.input.selectionStart ?? 0;
2913
3287
  const end = this.input.selectionEnd ?? start;
@@ -2918,10 +3292,11 @@ var Wulf = (() => {
2918
3292
  }
2919
3293
  }
2920
3294
  this.currentSuggestionIndex = 0;
2921
- this.updateSuggestion();
3295
+ this.updateSuggestion({ announce: true, immediate: false });
2922
3296
  }
2923
3297
  handleKeyDown(e) {
2924
- if (this.options.disabled) return;
3298
+ if (this.options.disabled || this.isPasswordInput() || isImeComposing(e)) return;
3299
+ if (e.shiftKey || e.ctrlKey || e.altKey || e.metaKey) return;
2925
3300
  const hasSuggestion = Boolean(this.currentSuggestion.remaining) && !this.currentSuggestion.isHintOnly;
2926
3301
  const cursor = this.input.selectionStart ?? 0;
2927
3302
  const isAtEnd = cursor === this.input.value.length;
@@ -2930,13 +3305,13 @@ var Wulf = (() => {
2930
3305
  if (e.key === "ArrowDown") {
2931
3306
  e.preventDefault();
2932
3307
  this.currentSuggestionIndex++;
2933
- this.updateSuggestion();
3308
+ this.updateSuggestion({ announce: true, immediate: true });
2934
3309
  return;
2935
3310
  }
2936
3311
  if (e.key === "ArrowUp") {
2937
3312
  e.preventDefault();
2938
3313
  this.currentSuggestionIndex--;
2939
- this.updateSuggestion();
3314
+ this.updateSuggestion({ announce: true, immediate: true });
2940
3315
  return;
2941
3316
  }
2942
3317
  }
@@ -3003,6 +3378,20 @@ var Wulf = (() => {
3003
3378
  }
3004
3379
  handleBlur() {
3005
3380
  this.wrapper.classList.remove("is-focused");
3381
+ if (this.srAnnounceTimerId !== null) {
3382
+ clearTimeout(this.srAnnounceTimerId);
3383
+ this.srAnnounceTimerId = null;
3384
+ }
3385
+ this.lastAnnouncedSuggestion = "";
3386
+ if (this.srStatusEl) {
3387
+ this.srStatusEl.textContent = "";
3388
+ }
3389
+ if (this.isPasswordInput()) {
3390
+ this.lastNotifiedValue = "";
3391
+ this.lastTrackedValue = "";
3392
+ this.clearGhost();
3393
+ return;
3394
+ }
3006
3395
  this.updateSuggestion();
3007
3396
  const detail = this.getDetail();
3008
3397
  if (this.options.onChange) {
@@ -3048,18 +3437,31 @@ var Wulf = (() => {
3048
3437
  clearTimeout(this.resetTimerId);
3049
3438
  this.resetTimerId = null;
3050
3439
  }
3051
- this.input.removeEventListener("input", this.handleInput);
3052
- this.input.removeEventListener("keydown", this.handleKeyDown);
3053
- this.input.removeEventListener("blur", this.handleBlur);
3054
- this.input.removeEventListener("focus", this.handleFocus);
3055
- this.input.removeEventListener("scroll", this.onScroll);
3056
- this.input.removeEventListener("cut", this.onCutHandler);
3057
- if (this.input.form && this.onFormResetHandler) {
3058
- this.input.form.removeEventListener("reset", this.onFormResetHandler);
3440
+ if (this.srAnnounceTimerId !== null) {
3441
+ clearTimeout(this.srAnnounceTimerId);
3442
+ this.srAnnounceTimerId = null;
3443
+ }
3444
+ if (this.srStatusEl) {
3445
+ this.srStatusEl.remove();
3446
+ this.srStatusEl = null;
3447
+ }
3448
+ this.lastNotifiedValue = "";
3449
+ this.lastAnnouncedSuggestion = "";
3450
+ if (this.wasInputModeInferred && this.input.getAttribute("inputmode") === "email") {
3451
+ this.input.removeAttribute("inputmode");
3059
3452
  }
3060
3453
  if (this.wasAriaAutocompleteSet && this.input.getAttribute("aria-autocomplete") === "inline") {
3061
3454
  this.input.removeAttribute("aria-autocomplete");
3062
3455
  }
3456
+ if (this.wasAutocorrectSet && this.input.getAttribute("autocorrect") === "off") {
3457
+ this.input.removeAttribute("autocorrect");
3458
+ }
3459
+ if (this.wasAutocapitalizeSet && this.input.getAttribute("autocapitalize") === "none") {
3460
+ this.input.removeAttribute("autocapitalize");
3461
+ }
3462
+ if (this.wasSpellcheckSet && this.input.getAttribute("spellcheck") === "false") {
3463
+ this.input.removeAttribute("spellcheck");
3464
+ }
3063
3465
  super.destroy();
3064
3466
  }
3065
3467
  };
@@ -3076,14 +3478,12 @@ var Wulf = (() => {
3076
3478
  EmailEngine,
3077
3479
  InputEmailMask
3078
3480
  };
3079
- if (typeof window !== "undefined") {
3080
- const win = window;
3081
- const wulfNamespace = win.Wulf || {};
3082
- win.Wulf = wulfNamespace;
3481
+ var wulfNamespace = getSafeWulfNamespace();
3482
+ if (wulfNamespace) {
3083
3483
  wulfNamespace.Mask = Mask;
3084
3484
  }
3085
3485
  var index_default = InputMask;
3086
3486
  return __toCommonJS(index_exports);
3087
3487
  })();
3088
- if (typeof window !== "undefined") { window.Wulf = window.Wulf || {}; if (typeof Wulf !== "undefined" && Wulf) { var targets = ["Mask", "Scroll", "Masonry", "Toast", "FocusTrap", "Shortcut"]; for (var i = 0; i < targets.length; i++) { var t = targets[i]; if (Wulf[t] && window.Wulf[t] !== Wulf[t]) { try { Object.defineProperty(window.Wulf, t, { value: Wulf[t], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[t] = Wulf[t]; } catch (__) {} } } } for (var k in Wulf) { if (window.Wulf[k] === undefined) { try { Object.defineProperty(window.Wulf, k, { value: Wulf[k], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[k] = Wulf[k]; } catch (__) {} } } } } }
3488
+ 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 (__) {} } } } } }
3089
3489
  //# sourceMappingURL=mask.global.js.map