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
package/dist/mask.esm.js CHANGED
@@ -1,3 +1,38 @@
1
+ // src/common/dom.ts
2
+ function getSafeWulfNamespace() {
3
+ if (typeof window === "undefined") return null;
4
+ const win = window;
5
+ const existing = win.Wulf;
6
+ if (!existing || typeof existing !== "object" || typeof Node !== "undefined" && existing instanceof Node || typeof HTMLCollection !== "undefined" && existing instanceof HTMLCollection) {
7
+ const fresh = {};
8
+ win.Wulf = fresh;
9
+ return fresh;
10
+ }
11
+ return existing;
12
+ }
13
+ function safeCssEscape(value) {
14
+ if (typeof CSS !== "undefined" && typeof CSS.escape === "function") {
15
+ return CSS.escape(value);
16
+ }
17
+ return String(value).replace(/["\\\u0000-\u001F\u007F]/g, "\\$&");
18
+ }
19
+ function safeMove(parent, node, referenceNode = null) {
20
+ const moveBefore = parent.moveBefore;
21
+ if (typeof moveBefore === "function" && node.isConnected && parent.isConnected && typeof parent.getRootNode === "function" && typeof node.getRootNode === "function" && parent.getRootNode() === node.getRootNode()) {
22
+ try {
23
+ moveBefore.call(parent, node, referenceNode);
24
+ return;
25
+ } catch {
26
+ }
27
+ }
28
+ parent.insertBefore(node, referenceNode);
29
+ }
30
+ function isImeComposing(event) {
31
+ return Boolean(
32
+ event.isComposing || event.key === "Process" || event.key === "Enter" && event.keyCode === 229
33
+ );
34
+ }
35
+
1
36
  // src/common/AuditableComponent.ts
2
37
  var AuditableComponent = class {
3
38
  /**
@@ -30,8 +65,11 @@ var AuditableComponent = class {
30
65
  const rawValue = element.getAttribute(attrName)?.trim();
31
66
  if (!rawValue) return false;
32
67
  const doc = element.ownerDocument || document;
68
+ const root = typeof element.getRootNode === "function" ? element.getRootNode() : doc;
33
69
  const ids = rawValue.split(/\s+/).filter(Boolean);
34
- const isValid = ids.length > 0 && ids.every((id) => Boolean(doc.getElementById(id)));
70
+ const isValid = ids.length > 0 && ids.every(
71
+ (id) => Boolean(typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root.getElementById(id) : doc.getElementById(id))
72
+ );
35
73
  if (!isValid) {
36
74
  warnings.push(
37
75
  `Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`
@@ -42,6 +80,7 @@ var AuditableComponent = class {
42
80
  };
43
81
 
44
82
  // src/mask/BaseInputMask.ts
83
+ var VALID_ALIGNS = /* @__PURE__ */ new Set(["left", "right", "center"]);
45
84
  function resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, maybeOptions) {
46
85
  const isSecondArgInput = Boolean(
47
86
  inputOrOptions && typeof inputOrOptions === "object" && "tagName" in inputOrOptions && inputOrOptions.tagName === "INPUT"
@@ -60,59 +99,27 @@ function resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, maybeOption
60
99
  };
61
100
  }
62
101
  var BaseInputMask = class extends AuditableComponent {
102
+ wrapper;
103
+ input;
104
+ options;
105
+ ghost = null;
106
+ isWrapperCreated = false;
107
+ wasWrapperFallbackStyled = false;
108
+ wasAlignSet = false;
109
+ hadInitialDataAlign = false;
110
+ isDestroyed = false;
111
+ isFocused = false;
112
+ isDispatchingNativeInput = false;
113
+ lastTrackedValue = "";
114
+ nativeValueDescriptor = null;
115
+ onCutHandler = () => {
116
+ };
117
+ onFormResetHandler;
118
+ mutationObserver = null;
119
+ focusSelectTimerId = null;
120
+ abortController = new AbortController();
63
121
  constructor(targetOrWrapper, inputOrOptions, maybeOptions) {
64
122
  super();
65
- this.ghost = null;
66
- this.isWrapperCreated = false;
67
- this.isDestroyed = false;
68
- this.isFocused = false;
69
- this.isDispatchingNativeInput = false;
70
- this.lastTrackedValue = "";
71
- this.nativeValueDescriptor = null;
72
- this.onCutHandler = () => {
73
- };
74
- this.mutationObserver = null;
75
- this.focusSelectTimerId = null;
76
- this.onBaseCopy = (e) => {
77
- if (!this.options.copyRaw || this.options.disabled || this.input.type === "password") return;
78
- const start = this.input.selectionStart ?? 0;
79
- const end = this.input.selectionEnd ?? start;
80
- let textToCopy = "";
81
- if (start !== end) {
82
- textToCopy = this.extractRawSnippet(this.input.value.slice(start, end));
83
- } else {
84
- textToCopy = this.getRawValue();
85
- }
86
- if (textToCopy && e.clipboardData) {
87
- e.preventDefault();
88
- e.clipboardData.setData("text/plain", textToCopy);
89
- }
90
- };
91
- this.onBaseFocus = () => {
92
- this.isFocused = true;
93
- if (this.options.selectAllOnFocus && this.input.value.length > 0) {
94
- if (this.focusSelectTimerId !== null) {
95
- clearTimeout(this.focusSelectTimerId);
96
- }
97
- this.focusSelectTimerId = window.setTimeout(() => {
98
- this.focusSelectTimerId = null;
99
- if (!this.isDestroyed && document.activeElement === this.input) {
100
- this.input.select();
101
- }
102
- }, 0);
103
- }
104
- };
105
- this.onBaseBlur = () => {
106
- this.isFocused = false;
107
- };
108
- /**
109
- * Synchronise le défilement horizontal du ghost avec celui du champ d'entrée natif.
110
- */
111
- this.onScroll = () => {
112
- if (this.ghost) {
113
- this.ghost.scrollLeft = this.input.scrollLeft;
114
- }
115
- };
116
123
  const { wrapper: providedWrapper, input, options } = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, maybeOptions);
117
124
  if (!input || typeof input !== "object" || input.nodeType !== 1 || input.tagName !== "INPUT") {
118
125
  throw new Error(`[${new.target.name || "InputMask"}] input (HTMLInputElement) est requis.`);
@@ -122,20 +129,26 @@ var BaseInputMask = class extends AuditableComponent {
122
129
  const shouldCreateWrapper = Boolean(options.createWrapper ?? dataCreateWrapper);
123
130
  let effectiveWrapper = providedWrapper;
124
131
  if (!effectiveWrapper && shouldCreateWrapper) {
125
- const span = document.createElement("span");
132
+ const doc = this.input.ownerDocument || document;
133
+ const span = doc.createElement("span");
126
134
  span.className = "wulf-mask-wrapper";
127
- span.style.display = "inline-grid";
128
- span.style.gridTemplateColumns = "1fr";
129
- span.style.gridTemplateRows = "1fr";
130
- span.style.verticalAlign = "middle";
131
- span.style.boxSizing = "border-box";
132
- span.style.position = "relative";
133
135
  if (this.input.parentNode) {
134
136
  this.input.parentNode.insertBefore(span, this.input);
135
137
  }
136
- span.appendChild(this.input);
137
- this.input.style.gridArea = "1 / 1 / 2 / 2";
138
- this.input.style.boxSizing = "border-box";
138
+ safeMove(span, this.input, null);
139
+ const view = doc.defaultView || (typeof window !== "undefined" ? window : null);
140
+ const needsFallbackStyles = !span.isConnected || !view || view.getComputedStyle(span).display !== "inline-grid";
141
+ if (needsFallbackStyles) {
142
+ span.style.display = "inline-grid";
143
+ span.style.gridTemplateColumns = "1fr";
144
+ span.style.gridTemplateRows = "1fr";
145
+ span.style.verticalAlign = "middle";
146
+ span.style.boxSizing = "border-box";
147
+ span.style.position = "relative";
148
+ this.input.style.gridArea = "1 / 1 / 2 / 2";
149
+ this.input.style.boxSizing = "border-box";
150
+ this.wasWrapperFallbackStyled = true;
151
+ }
139
152
  effectiveWrapper = span;
140
153
  this.isWrapperCreated = true;
141
154
  }
@@ -148,12 +161,15 @@ var BaseInputMask = class extends AuditableComponent {
148
161
  const dataDisabled = this.hasAttr("data-disabled");
149
162
  const dataSelectAll = this.getAttr("data-mask-select-on-focus") === "true";
150
163
  const dataCopyRaw = this.getAttr("data-mask-copy-raw") === "true";
151
- const dataAlign = this.getAttr("data-mask-align") || this.getAttr("data-align");
164
+ const rawDataAlign = this.getAttr("data-mask-align") || this.getAttr("data-align");
165
+ const dataAlign = rawDataAlign && VALID_ALIGNS.has(rawDataAlign) ? rawDataAlign : null;
166
+ this.hadInitialDataAlign = this.wrapper.hasAttribute("data-align");
152
167
  const dataAudit = this.getAttr("data-mask-audit");
153
168
  const { disabled: optDisabled, align: optAlign, ...otherOptions } = options;
169
+ const validOptAlign = optAlign && VALID_ALIGNS.has(optAlign) ? optAlign : void 0;
154
170
  const resolvedDisabled = optDisabled !== void 0 ? optDisabled : dataDisabled ? true : false;
155
171
  const resolvedAudit = options.audit ?? (dataAudit !== null ? dataAudit !== "false" : true);
156
- const isPassword = this.input.type === "password";
172
+ const isPassword = this.isPasswordInput();
157
173
  this.options = {
158
174
  ...otherOptions,
159
175
  createWrapper: shouldCreateWrapper,
@@ -161,7 +177,7 @@ var BaseInputMask = class extends AuditableComponent {
161
177
  selectAllOnFocus: options.selectAllOnFocus ?? dataSelectAll ?? false,
162
178
  copyRaw: isPassword ? false : options.copyRaw ?? dataCopyRaw ?? false,
163
179
  disabled: resolvedDisabled,
164
- align: optAlign ?? (dataAlign || void 0),
180
+ align: validOptAlign ?? (dataAlign || void 0),
165
181
  emitNativeInput: options.emitNativeInput ?? true,
166
182
  audit: resolvedAudit
167
183
  };
@@ -208,16 +224,54 @@ var BaseInputMask = class extends AuditableComponent {
208
224
  * Attache les écouteurs de base pour focus/blur, copie brute et sélection.
209
225
  */
210
226
  bindBaseEvents() {
211
- this.input.addEventListener("copy", this.onBaseCopy);
212
- this.input.addEventListener("focus", this.onBaseFocus);
213
- this.input.addEventListener("blur", this.onBaseBlur);
227
+ const { signal } = this.abortController;
228
+ this.input.addEventListener("copy", this.onBaseCopy, { signal });
229
+ this.input.addEventListener("focus", this.onBaseFocus, { signal });
230
+ this.input.addEventListener("blur", this.onBaseBlur, { signal });
214
231
  }
232
+ onBaseCopy = (e) => {
233
+ if (!this.options.copyRaw || this.options.disabled || this.input.type === "password") return;
234
+ const start = this.input.selectionStart ?? 0;
235
+ const end = this.input.selectionEnd ?? start;
236
+ let textToCopy = "";
237
+ if (start !== end) {
238
+ textToCopy = this.extractRawSnippet(this.input.value.slice(start, end));
239
+ } else {
240
+ textToCopy = this.getRawValue();
241
+ }
242
+ if (textToCopy && e.clipboardData) {
243
+ e.preventDefault();
244
+ e.clipboardData.setData("text/plain", textToCopy);
245
+ }
246
+ };
215
247
  /**
216
248
  * Extrait la valeur brute d'un extrait de chaîne sélectionné.
217
249
  */
218
250
  extractRawSnippet(snippet) {
219
251
  return snippet;
220
252
  }
253
+ onBaseFocus = () => {
254
+ this.isFocused = true;
255
+ if (this.options.selectAllOnFocus && this.input.value.length > 0) {
256
+ if (this.focusSelectTimerId !== null) {
257
+ clearTimeout(this.focusSelectTimerId);
258
+ }
259
+ this.focusSelectTimerId = window.setTimeout(() => {
260
+ this.focusSelectTimerId = null;
261
+ if (!this.isDestroyed && document.activeElement === this.input) {
262
+ this.input.select();
263
+ }
264
+ }, 0);
265
+ }
266
+ };
267
+ onBaseBlur = () => {
268
+ this.isFocused = false;
269
+ if (this.isPasswordInput()) {
270
+ this.lastTrackedValue = "";
271
+ this.clearGhost();
272
+ this.wrapper.removeAttribute("data-mask");
273
+ }
274
+ };
221
275
  /**
222
276
  * Initialise l'observation des modifications dynamiques des attributs data-* et placeholder.
223
277
  */
@@ -247,7 +301,8 @@ var BaseInputMask = class extends AuditableComponent {
247
301
  "data-disabled",
248
302
  "data-mask-align",
249
303
  "data-align",
250
- "placeholder"
304
+ "placeholder",
305
+ "type"
251
306
  ]
252
307
  };
253
308
  this.mutationObserver.observe(this.wrapper, config);
@@ -255,21 +310,41 @@ var BaseInputMask = class extends AuditableComponent {
255
310
  this.mutationObserver.observe(this.input, config);
256
311
  }
257
312
  }
313
+ /**
314
+ * Indique si le champ natif sous-jacent est de type mot de passe.
315
+ */
316
+ isPasswordInput() {
317
+ return (this.input.type || "").toLowerCase() === "password";
318
+ }
319
+ /**
320
+ * Calcule une empreinte non réversible pour détecter les changements sans conserver de secret en RAM.
321
+ */
322
+ computePasswordDigest(val) {
323
+ let hash = 2166136261;
324
+ for (let i = 0; i < val.length; i++) {
325
+ hash ^= val.charCodeAt(i);
326
+ hash = Math.imul(hash, 16777619);
327
+ }
328
+ return `__pwd:${(hash >>> 0).toString(36)}:${val.length}`;
329
+ }
258
330
  /**
259
331
  * Modifie dynamiquement l'alignement du champ et du masque fantôme.
260
332
  */
261
333
  setAlign(align) {
262
- const targetAlign = align || void 0;
334
+ const normalized = align && VALID_ALIGNS.has(align) ? align : null;
335
+ const targetAlign = normalized || void 0;
263
336
  const currentAttr = this.wrapper.getAttribute("data-align");
264
- if (this.options.align === targetAlign && currentAttr === (align || null)) {
337
+ 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");
338
+ if (this.options.align === targetAlign && currentAttr === normalized && hasExpectedClass) {
265
339
  return;
266
340
  }
267
341
  this.options.align = targetAlign;
268
342
  this.wrapper.classList.remove("align-left", "align-right", "align-center");
269
- if (align) {
270
- this.wrapper.classList.add(`align-${align}`);
271
- if (this.wrapper.getAttribute("data-align") !== align) {
272
- this.wrapper.setAttribute("data-align", align);
343
+ if (normalized) {
344
+ this.wrapper.classList.add(`align-${normalized}`);
345
+ this.wasAlignSet = true;
346
+ if (this.wrapper.getAttribute("data-align") !== normalized) {
347
+ this.wrapper.setAttribute("data-align", normalized);
273
348
  }
274
349
  } else {
275
350
  if (this.wrapper.hasAttribute("data-align")) {
@@ -295,9 +370,18 @@ var BaseInputMask = class extends AuditableComponent {
295
370
  } else if (attrName === "data-mask-select-on-focus") {
296
371
  this.options.selectAllOnFocus = this.getAttr("data-mask-select-on-focus") === "true";
297
372
  } else if (attrName === "data-mask-copy-raw") {
298
- this.options.copyRaw = this.getAttr("data-mask-copy-raw") === "true";
373
+ this.options.copyRaw = this.isPasswordInput() ? false : this.getAttr("data-mask-copy-raw") === "true";
374
+ } else if (attrName === "type") {
375
+ if (this.isPasswordInput()) {
376
+ this.options.copyRaw = false;
377
+ this.lastTrackedValue = "";
378
+ this.clearGhost();
379
+ this.wrapper.removeAttribute("data-mask");
380
+ this.onPasswordModeDetected();
381
+ }
299
382
  } else if (attrName === "data-mask-align" || attrName === "data-align") {
300
- const align = this.getAttr("data-mask-align") || this.getAttr("data-align");
383
+ const rawAlign = this.getAttr("data-mask-align") || this.getAttr("data-align");
384
+ const align = rawAlign && VALID_ALIGNS.has(rawAlign) ? rawAlign : null;
301
385
  if (align !== (this.options.align ?? null)) {
302
386
  this.setAlign(align);
303
387
  }
@@ -325,15 +409,42 @@ var BaseInputMask = class extends AuditableComponent {
325
409
  if (existing) {
326
410
  existing.remove();
327
411
  }
328
- this.ghost = document.createElement("div");
412
+ const doc = this.input.ownerDocument || document;
413
+ this.ghost = doc.createElement("div");
329
414
  this.ghost.className = "mask-ghost";
330
415
  this.ghost.setAttribute("aria-hidden", "true");
331
416
  this.ghost.style.display = "flex";
332
417
  this.ghost.style.alignItems = "center";
333
418
  this.wrapper.appendChild(this.ghost);
334
419
  this.wrapper.classList.add("has-ghost");
420
+ const view = doc.defaultView || (typeof window !== "undefined" ? window : null);
421
+ if (!this.wrapper.isConnected || !view || view.getComputedStyle(this.ghost).pointerEvents !== "none") {
422
+ this.ghost.style.gridArea = "1 / 1 / 2 / 2";
423
+ this.ghost.style.pointerEvents = "none";
424
+ }
335
425
  this.syncGhostStyles();
336
426
  }
427
+ /**
428
+ * Met à jour atomiquement le contenu du conteneur fantôme et synchronise .has-visible-ghost.
429
+ */
430
+ setGhostContent(...nodes) {
431
+ if (!this.ghost) return;
432
+ if (typeof this.ghost.replaceChildren === "function") {
433
+ this.ghost.replaceChildren(...nodes);
434
+ } else {
435
+ this.ghost.textContent = "";
436
+ for (const n of nodes) {
437
+ this.ghost.appendChild(typeof n === "string" ? document.createTextNode(n) : n);
438
+ }
439
+ }
440
+ this.wrapper.classList.toggle("has-visible-ghost", nodes.length > 0);
441
+ }
442
+ /**
443
+ * Vide atomiquement le conteneur fantôme et rétablit l'affichage du placeholder natif.
444
+ */
445
+ clearGhost() {
446
+ this.setGhostContent();
447
+ }
337
448
  /**
338
449
  * Clone fidèlement la géométrie typographique et les espacements de l'input natif
339
450
  * sur le conteneur fantôme pour garantir un alignement sub-pixel absolu quel que soit
@@ -366,12 +477,17 @@ var BaseInputMask = class extends AuditableComponent {
366
477
  this.ghost.style.textAlign = style.textAlign;
367
478
  this.ghost.style.direction = style.direction;
368
479
  const isRtl = style.direction === "rtl" || this.input.getAttribute("dir") === "rtl" || this.wrapper.getAttribute("dir") === "rtl";
369
- if (style.textAlign === "right" || style.textAlign === "end" || isRtl && style.textAlign !== "left" && style.textAlign !== "center") {
370
- this.ghost.style.justifyContent = "flex-end";
371
- } else if (style.textAlign === "center") {
480
+ const textAlign = style.textAlign;
481
+ if (textAlign === "right") {
482
+ this.ghost.style.justifyContent = "right";
483
+ } else if (textAlign === "left") {
484
+ this.ghost.style.justifyContent = "left";
485
+ } else if (textAlign === "center") {
372
486
  this.ghost.style.justifyContent = "center";
487
+ } else if (textAlign === "end") {
488
+ this.ghost.style.justifyContent = isRtl ? "left" : "right";
373
489
  } else {
374
- this.ghost.style.justifyContent = "flex-start";
490
+ this.ghost.style.justifyContent = isRtl ? "right" : "left";
375
491
  }
376
492
  }
377
493
  /**
@@ -395,15 +511,23 @@ var BaseInputMask = class extends AuditableComponent {
395
511
  this.isDispatchingNativeInput = true;
396
512
  try {
397
513
  const tracker = this.input._valueTracker;
398
- if (tracker && typeof tracker.setValue === "function") {
514
+ if (!this.isPasswordInput() && tracker && typeof tracker.setValue === "function") {
399
515
  tracker.setValue(this.lastTrackedValue);
400
516
  }
401
- this.lastTrackedValue = this.input.value;
517
+ this.lastTrackedValue = this.isPasswordInput() ? "" : this.input.value;
402
518
  this.input.dispatchEvent(new Event("input", { bubbles: true, cancelable: false }));
403
519
  } finally {
404
520
  this.isDispatchingNativeInput = false;
405
521
  }
406
522
  }
523
+ /**
524
+ * Synchronise le défilement horizontal du ghost avec celui du champ d'entrée natif.
525
+ */
526
+ onScroll = () => {
527
+ if (this.ghost) {
528
+ this.ghost.scrollLeft = this.input.scrollLeft;
529
+ }
530
+ };
407
531
  /**
408
532
  * Intercepte les modifications directes de la propriété input.value (ex: input.value = '').
409
533
  */
@@ -515,15 +639,19 @@ var BaseInputMask = class extends AuditableComponent {
515
639
  audit() {
516
640
  const warnings = [];
517
641
  const doc = this.input.ownerDocument || document;
642
+ const root = typeof this.input.getRootNode === "function" ? this.input.getRootNode() : doc;
643
+ const labelRoot = typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root : doc;
518
644
  const ariaLabel = this.input.getAttribute("aria-label")?.trim();
519
645
  const hasValidLabelledby = this.checkAriaIdReferences(this.input, "aria-labelledby", warnings);
520
646
  const hasWrappingLabel = Boolean(this.input.closest("label"));
521
647
  const hasNativeLabels = Boolean(this.input.labels && this.input.labels.length > 0);
522
648
  let hasExplicitLabelFor = false;
523
- if (this.input.id && typeof CSS !== "undefined" && typeof CSS.escape === "function") {
524
- hasExplicitLabelFor = Boolean(doc.querySelector(`label[for="${CSS.escape(this.input.id)}"]`));
525
- } else if (this.input.id) {
526
- hasExplicitLabelFor = Boolean(doc.querySelector(`label[for="${this.input.id}"]`));
649
+ if (this.input.id) {
650
+ try {
651
+ hasExplicitLabelFor = Boolean(labelRoot.querySelector(`label[for="${safeCssEscape(this.input.id)}"]`));
652
+ } catch {
653
+ hasExplicitLabelFor = false;
654
+ }
527
655
  }
528
656
  if (!ariaLabel && !hasValidLabelledby && !hasWrappingLabel && !hasNativeLabels && !hasExplicitLabelFor) {
529
657
  warnings.push(
@@ -550,6 +678,11 @@ var BaseInputMask = class extends AuditableComponent {
550
678
  getSpecificAuditWarnings() {
551
679
  return [];
552
680
  }
681
+ /**
682
+ * Crochet appelé lorsque l'input bascule dynamiquement en type="password" (ex: toggle afficher/masquer).
683
+ */
684
+ onPasswordModeDetected() {
685
+ }
553
686
  /**
554
687
  * Supprime les éléments fantômes, restaure les propriétés et nettoie les attributs.
555
688
  */
@@ -564,25 +697,41 @@ var BaseInputMask = class extends AuditableComponent {
564
697
  this.mutationObserver.disconnect();
565
698
  this.mutationObserver = null;
566
699
  }
567
- this.input.removeEventListener("copy", this.onBaseCopy);
568
- this.input.removeEventListener("focus", this.onBaseFocus);
569
- this.input.removeEventListener("blur", this.onBaseBlur);
700
+ this.abortController.abort();
701
+ this.lastTrackedValue = "";
570
702
  this.unhookValueProperty();
571
703
  if (this.ghost) {
572
704
  this.ghost.remove();
573
705
  this.ghost = null;
574
706
  }
575
707
  if (this.isWrapperCreated && this.wrapper) {
576
- this.input.style.gridArea = "";
577
- this.input.style.boxSizing = "";
578
- if (this.wrapper.parentNode) {
708
+ if (this.wasWrapperFallbackStyled) {
709
+ this.input.style.gridArea = "";
710
+ this.input.style.boxSizing = "";
711
+ }
712
+ if (this.wrapper.parentElement) {
713
+ safeMove(this.wrapper.parentElement, this.input, this.wrapper);
714
+ } else if (this.wrapper.parentNode) {
579
715
  this.wrapper.parentNode.insertBefore(this.input, this.wrapper);
580
716
  }
581
717
  this.wrapper.remove();
582
718
  } else if (this.wrapper) {
583
719
  this.wrapper.removeAttribute("data-mask");
584
720
  this.wrapper.removeAttribute("data-disabled");
585
- this.wrapper.classList.remove("is-complete", "is-focused", "mask-focus-only", "has-selection", "has-ghost");
721
+ if (this.wasAlignSet && !this.hadInitialDataAlign) {
722
+ this.wrapper.removeAttribute("data-align");
723
+ }
724
+ if (this.wasAlignSet) {
725
+ this.wrapper.classList.remove("align-left", "align-right", "align-center");
726
+ }
727
+ this.wrapper.classList.remove(
728
+ "is-complete",
729
+ "is-focused",
730
+ "mask-focus-only",
731
+ "has-selection",
732
+ "has-ghost",
733
+ "has-visible-ghost"
734
+ );
586
735
  }
587
736
  }
588
737
  };
@@ -596,19 +745,34 @@ var DEFAULT_TOKENS = {
596
745
  "#": { pattern: /[a-zA-Z0-9]/, transform: (c) => c.toUpperCase() }
597
746
  };
598
747
  var MaskEngine = class _MaskEngine {
748
+ pattern;
749
+ patterns = [];
750
+ subEngines = [];
751
+ activeEngine = null;
752
+ placeholderChar;
753
+ tokens;
754
+ slots = [];
755
+ fullMaskTemplate = "";
756
+ prefixSlotsCount = 0;
757
+ prefixString = "";
758
+ strict = true;
759
+ autoLowercase = false;
599
760
  constructor(pattern, options = {}) {
600
- this.patterns = [];
601
- this.subEngines = [];
602
- this.activeEngine = null;
603
- this.slots = [];
604
- this.fullMaskTemplate = "";
605
- this.prefixSlotsCount = 0;
606
- this.prefixString = "";
607
- this.strict = true;
608
- this.autoLowercase = false;
609
761
  const opts = options || {};
610
- this.placeholderChar = opts.placeholderChar || "_";
611
- this.tokens = { ...DEFAULT_TOKENS, ...opts.tokens || {} };
762
+ const rawPlaceholder = String(opts.placeholderChar || "_");
763
+ this.placeholderChar = Array.from(rawPlaceholder)[0] || "_";
764
+ const tokenMap = /* @__PURE__ */ Object.create(null);
765
+ for (const [k, v] of Object.entries(DEFAULT_TOKENS)) {
766
+ tokenMap[k] = v;
767
+ }
768
+ if (opts.tokens && typeof opts.tokens === "object") {
769
+ for (const [k, v] of Object.entries(opts.tokens)) {
770
+ if (k !== "__proto__" && k !== "constructor" && k !== "prototype" && v) {
771
+ tokenMap[k] = v;
772
+ }
773
+ }
774
+ }
775
+ this.tokens = tokenMap;
612
776
  this.strict = opts.strict !== false;
613
777
  this.autoLowercase = opts.autoLowercase ?? false;
614
778
  this.pattern = "";
@@ -634,11 +798,11 @@ var MaskEngine = class _MaskEngine {
634
798
  compile(newPattern) {
635
799
  if (newPattern !== void 0) {
636
800
  if (Array.isArray(newPattern)) {
637
- this.patterns = [...newPattern];
801
+ this.patterns = newPattern.slice(0, 32).map((p) => String(p ?? "").slice(0, 512));
638
802
  this.pattern = this.patterns[0] || "";
639
803
  } else {
640
804
  this.patterns = [];
641
- this.pattern = newPattern;
805
+ this.pattern = String(newPattern ?? "").slice(0, 512);
642
806
  }
643
807
  }
644
808
  if (this.patterns.length > 0) {
@@ -668,7 +832,7 @@ var MaskEngine = class _MaskEngine {
668
832
  i++;
669
833
  char = this.pattern[i];
670
834
  }
671
- const token = !isEscaped ? this.tokens[char] : void 0;
835
+ const token = !isEscaped && Object.hasOwn(this.tokens, char) ? this.tokens[char] : void 0;
672
836
  if (token) {
673
837
  isPrefixMode = false;
674
838
  this.slots.push({
@@ -715,7 +879,7 @@ var MaskEngine = class _MaskEngine {
715
879
  return p.length > 0 && trimmed.toLowerCase().startsWith(p.trim().toLowerCase());
716
880
  });
717
881
  const candidates = withMatchingPrefix.length > 0 ? withMatchingPrefix : this.subEngines;
718
- const maxCandidate = [...candidates].sort((a, b) => b.getEditableCount() - a.getEditableCount())[0];
882
+ const maxCandidate = candidates.toSorted((a, b) => b.getEditableCount() - a.getEditableCount())[0];
719
883
  const raw = maxCandidate ? maxCandidate.extractRaw(trimmed) : trimmed;
720
884
  const rawLen = raw.length;
721
885
  for (const eng of candidates) {
@@ -771,6 +935,18 @@ var MaskEngine = class _MaskEngine {
771
935
  */
772
936
  setStrict(strict) {
773
937
  this.strict = strict;
938
+ for (const sub of this.subEngines) {
939
+ sub.setStrict(strict);
940
+ }
941
+ }
942
+ /**
943
+ * Active ou désactive dynamiquement la mise en minuscules automatique.
944
+ */
945
+ setAutoLowercase(autoLowercase) {
946
+ this.autoLowercase = autoLowercase;
947
+ for (const sub of this.subEngines) {
948
+ sub.setAutoLowercase(autoLowercase);
949
+ }
774
950
  }
775
951
  /**
776
952
  * Indique si le masque est en mode strict.
@@ -789,7 +965,8 @@ var MaskEngine = class _MaskEngine {
789
965
  return engine.extractRaw(input);
790
966
  }
791
967
  }
792
- const str = String(input ?? "");
968
+ const maxInputLen = Math.max(4096, this.slots.length * 4);
969
+ const str = String(input ?? "").slice(0, maxInputLen);
793
970
  if (!str) return "";
794
971
  let raw = "";
795
972
  let inputIdx = 0;
@@ -858,7 +1035,8 @@ var MaskEngine = class _MaskEngine {
858
1035
  return engine.format(rawValue);
859
1036
  }
860
1037
  }
861
- const rawStr = String(rawValue ?? "");
1038
+ const maxInputLen = Math.max(4096, this.slots.length * 4);
1039
+ const rawStr = String(rawValue ?? "").slice(0, maxInputLen);
862
1040
  if (!this.slots.length) return rawStr;
863
1041
  const cleanRaw = this.extractRaw(rawStr);
864
1042
  if (cleanRaw.length === 0) {
@@ -993,9 +1171,10 @@ var MaskEngine = class _MaskEngine {
993
1171
 
994
1172
  // src/mask/MaskHistory.ts
995
1173
  var MaskHistory = class {
1174
+ stack = [];
1175
+ index = -1;
1176
+ maxDepth;
996
1177
  constructor(maxDepth = 50) {
997
- this.stack = [];
998
- this.index = -1;
999
1178
  this.maxDepth = maxDepth;
1000
1179
  }
1001
1180
  /**
@@ -1073,6 +1252,7 @@ var MaskHistory = class {
1073
1252
 
1074
1253
  // src/mask/MaskKeyboard.ts
1075
1254
  var MaskKeyboard = class {
1255
+ delegate;
1076
1256
  constructor(delegate) {
1077
1257
  this.delegate = delegate;
1078
1258
  }
@@ -1080,6 +1260,7 @@ var MaskKeyboard = class {
1080
1260
  * Analyse et traite l'événement keydown de l'input.
1081
1261
  */
1082
1262
  handleKeyDown(e) {
1263
+ if (isImeComposing(e)) return;
1083
1264
  const input = this.delegate.getInput();
1084
1265
  const engine = this.delegate.getEngine();
1085
1266
  const history = this.delegate.getHistory();
@@ -1173,7 +1354,7 @@ var MaskKeyboard = class {
1173
1354
  input.setSelectionRange(minPos, minPos);
1174
1355
  return;
1175
1356
  }
1176
- if (e.key === "Home" && !e.shiftKey) {
1357
+ if (e.key === "Home" && minPos > 0 && !e.shiftKey && !e.ctrlKey && !e.metaKey && !e.altKey) {
1177
1358
  e.preventDefault();
1178
1359
  input.setSelectionRange(minPos, minPos);
1179
1360
  return;
@@ -1278,6 +1459,23 @@ var MaskKeyboard = class {
1278
1459
 
1279
1460
  // src/mask/InputMask.ts
1280
1461
  var InputMask = class extends BaseInputMask {
1462
+ engine;
1463
+ history;
1464
+ keyboard;
1465
+ isComposing = false;
1466
+ isUndoingRedoing = false;
1467
+ isMouseDown = false;
1468
+ isApplyingMask = false;
1469
+ lastValue = "";
1470
+ lastInternalRemainingMask = "";
1471
+ isNotifying = false;
1472
+ hasPendingNotification = false;
1473
+ onChangeNativeHandler = () => {
1474
+ };
1475
+ wasInputModeInferred = false;
1476
+ cutTimerId = null;
1477
+ pasteTimerId = null;
1478
+ resetTimerId = null;
1281
1479
  constructor(targetOrWrapper, inputOrOptions, options) {
1282
1480
  const args = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, options);
1283
1481
  const wrap = args.wrapper;
@@ -1310,20 +1508,6 @@ var InputMask = class extends BaseInputMask {
1310
1508
  onComplete: opts.onComplete || opts.oncomplete
1311
1509
  };
1312
1510
  super(wrap, inp, resolvedOptions);
1313
- this.isComposing = false;
1314
- this.isUndoingRedoing = false;
1315
- this.isMouseDown = false;
1316
- this.isApplyingMask = false;
1317
- this.lastValue = "";
1318
- this.lastInternalRemainingMask = "";
1319
- this.isNotifying = false;
1320
- this.hasPendingNotification = false;
1321
- this.onChangeNativeHandler = () => {
1322
- };
1323
- this.wasInputModeInferred = false;
1324
- this.cutTimerId = null;
1325
- this.pasteTimerId = null;
1326
- this.resetTimerId = null;
1327
1511
  this.history = new MaskHistory();
1328
1512
  this.engine = new MaskEngine(this.options.mask || "", {
1329
1513
  placeholderChar: this.options.placeholderChar,
@@ -1342,16 +1526,17 @@ var InputMask = class extends BaseInputMask {
1342
1526
  enforceMinCursor: () => this.enforceMinCursor()
1343
1527
  });
1344
1528
  this.bindEvents();
1345
- this.lastValue = this.input.value;
1529
+ this.lastValue = this.isPasswordInput() ? this.computePasswordDigest(this.input.value) : this.input.value;
1346
1530
  this.syncInitialValue();
1347
1531
  this.runAuditWarning(this.options.audit);
1348
1532
  }
1349
1533
  getSpecificAuditWarnings() {
1350
1534
  const warnings = [];
1351
- const hasDescribedby = Boolean(this.input.getAttribute("aria-describedby")?.trim());
1535
+ const describedbyWarnings = [];
1536
+ const hasValidDescribedby = this.checkAriaIdReferences(this.input, "aria-describedby", describedbyWarnings);
1352
1537
  const hasPlaceholder = Boolean(this.input.getAttribute("placeholder")?.trim());
1353
1538
  const hasAriaPlaceholder = Boolean(this.input.getAttribute("aria-placeholder")?.trim());
1354
- if (!hasDescribedby && !hasPlaceholder && !hasAriaPlaceholder && !this.options.disabled) {
1539
+ if (!hasValidDescribedby && !hasPlaceholder && !hasAriaPlaceholder && !this.options.disabled) {
1355
1540
  warnings.push(
1356
1541
  "Indication du format attendu manquante : d\xE9finissez aria-describedby, placeholder ou aria-placeholder pour informer les technologies d'assistance (WCAG 3.3.2)."
1357
1542
  );
@@ -1361,6 +1546,14 @@ var InputMask = class extends BaseInputMask {
1361
1546
  extractRawSnippet(snippet) {
1362
1547
  return this.engine.extractRaw(snippet);
1363
1548
  }
1549
+ onPasswordModeDetected() {
1550
+ this.history.clear();
1551
+ this.lastValue = "";
1552
+ this.lastInternalRemainingMask = "";
1553
+ this.lastTrackedValue = "";
1554
+ this.clearGhost();
1555
+ this.wrapper.removeAttribute("data-mask");
1556
+ }
1364
1557
  /**
1365
1558
  * Formate statiquement une valeur selon un masque donné sans nécessiter d'élément DOM.
1366
1559
  *
@@ -1383,11 +1576,12 @@ var InputMask = class extends BaseInputMask {
1383
1576
  if (disabled) {
1384
1577
  this.wrapper.removeAttribute("data-mask");
1385
1578
  this.wrapper.classList.remove("is-complete", "has-selection");
1386
- if (this.ghost) this.ghost.textContent = "";
1579
+ this.clearGhost();
1387
1580
  this.checkValueChange();
1388
1581
  } else {
1389
1582
  this.applyMask(this.input.value, this.input.selectionStart ?? this.input.value.length);
1390
1583
  }
1584
+ this.syncInferredInputMode();
1391
1585
  }
1392
1586
  /**
1393
1587
  * Associe les écouteurs d'événements nécessaires.
@@ -1424,22 +1618,23 @@ var InputMask = class extends BaseInputMask {
1424
1618
  if (this.isDestroyed) return;
1425
1619
  this.checkValueChange();
1426
1620
  };
1427
- this.input.addEventListener("beforeinput", this.onBeforeInput);
1428
- this.input.addEventListener("input", this.handleInput);
1429
- this.input.addEventListener("keydown", this.onKeyDown);
1430
- this.input.addEventListener("paste", this.onPaste);
1431
- this.input.addEventListener("focus", this.onFocus);
1432
- this.input.addEventListener("blur", this.onBlur);
1433
- this.input.addEventListener("click", this.onClick);
1434
- this.input.addEventListener("keyup", this.onKeyUp);
1435
- this.input.addEventListener("select", this.onSelect);
1436
- this.input.addEventListener("mousedown", this.onMouseDown);
1437
- window.addEventListener("mouseup", this.onMouseUp);
1438
- this.input.addEventListener("compositionstart", this.onCompositionStart);
1439
- this.input.addEventListener("compositionend", this.onCompositionEnd);
1440
- this.input.addEventListener("scroll", this.onScroll);
1441
- this.input.addEventListener("cut", this.onCutHandler);
1442
- this.input.addEventListener("change", this.onChangeNativeHandler);
1621
+ const { signal } = this.abortController;
1622
+ this.input.addEventListener("beforeinput", this.onBeforeInput, { signal });
1623
+ this.input.addEventListener("input", this.handleInput, { signal });
1624
+ this.input.addEventListener("keydown", this.onKeyDown, { signal });
1625
+ this.input.addEventListener("paste", this.onPaste, { signal });
1626
+ this.input.addEventListener("focus", this.onFocus, { signal });
1627
+ this.input.addEventListener("blur", this.onBlur, { signal });
1628
+ this.input.addEventListener("click", this.onClick, { signal });
1629
+ this.input.addEventListener("keyup", this.onKeyUp, { signal });
1630
+ this.input.addEventListener("select", this.onSelect, { signal });
1631
+ this.input.addEventListener("mousedown", this.onMouseDown, { signal });
1632
+ window.addEventListener("mouseup", this.onMouseUp, { signal });
1633
+ this.input.addEventListener("compositionstart", this.onCompositionStart, { signal });
1634
+ this.input.addEventListener("compositionend", this.onCompositionEnd, { signal });
1635
+ this.input.addEventListener("scroll", this.onScroll, { passive: true, signal });
1636
+ this.input.addEventListener("cut", this.onCutHandler, { signal });
1637
+ this.input.addEventListener("change", this.onChangeNativeHandler, { signal });
1443
1638
  if (this.input.form) {
1444
1639
  this.onFormResetHandler = () => {
1445
1640
  if (this.resetTimerId !== null) clearTimeout(this.resetTimerId);
@@ -1453,7 +1648,7 @@ var InputMask = class extends BaseInputMask {
1453
1648
  }
1454
1649
  }, 0);
1455
1650
  };
1456
- this.input.form.addEventListener("reset", this.onFormResetHandler);
1651
+ this.input.form.addEventListener("reset", this.onFormResetHandler, { signal });
1457
1652
  }
1458
1653
  }
1459
1654
  /**
@@ -1490,29 +1685,12 @@ var InputMask = class extends BaseInputMask {
1490
1685
  clearTimeout(this.resetTimerId);
1491
1686
  this.resetTimerId = null;
1492
1687
  }
1493
- this.input.removeEventListener("beforeinput", this.onBeforeInput);
1494
- this.input.removeEventListener("input", this.handleInput);
1495
- this.input.removeEventListener("keydown", this.onKeyDown);
1496
- this.input.removeEventListener("paste", this.onPaste);
1497
- this.input.removeEventListener("focus", this.onFocus);
1498
- this.input.removeEventListener("blur", this.onBlur);
1499
- this.input.removeEventListener("click", this.onClick);
1500
- this.input.removeEventListener("keyup", this.onKeyUp);
1501
- this.input.removeEventListener("select", this.onSelect);
1502
- this.input.removeEventListener("mousedown", this.onMouseDown);
1503
- window.removeEventListener("mouseup", this.onMouseUp);
1504
- this.input.removeEventListener("compositionstart", this.onCompositionStart);
1505
- this.input.removeEventListener("compositionend", this.onCompositionEnd);
1506
- this.input.removeEventListener("scroll", this.onScroll);
1507
- this.input.removeEventListener("cut", this.onCutHandler);
1508
- this.input.removeEventListener("change", this.onChangeNativeHandler);
1509
- if (this.input.form && this.onFormResetHandler) {
1510
- this.input.form.removeEventListener("reset", this.onFormResetHandler);
1511
- }
1512
1688
  if (this.wasInputModeInferred && this.input.getAttribute("inputmode") === "numeric") {
1513
1689
  this.input.removeAttribute("inputmode");
1514
1690
  }
1515
1691
  this.history.clear();
1692
+ this.lastValue = "";
1693
+ this.lastInternalRemainingMask = "";
1516
1694
  super.destroy();
1517
1695
  }
1518
1696
  /**
@@ -1586,6 +1764,7 @@ var InputMask = class extends BaseInputMask {
1586
1764
  this.setStrict(strictVal !== "false");
1587
1765
  } else if (attrName === "data-mask-auto-lowercase") {
1588
1766
  this.options.autoLowercase = this.getAttr("data-mask-auto-lowercase") === "true";
1767
+ this.engine.setAutoLowercase(this.options.autoLowercase);
1589
1768
  this.engine.compile(this.options.mask || "");
1590
1769
  this.applyMask(this.input.value, this.input.selectionStart ?? this.input.value.length);
1591
1770
  } else if (attrName === "placeholder") {
@@ -1665,7 +1844,7 @@ var InputMask = class extends BaseInputMask {
1665
1844
  if (this.options.disabled) return;
1666
1845
  if (this.isComposing) return;
1667
1846
  if (!this.engine.isStrict()) return;
1668
- if (e.inputType === "insertFromPaste") return;
1847
+ if (e.inputType === "insertFromPaste" || e.inputType === "insertReplacementText") return;
1669
1848
  if (e.inputType && e.inputType.startsWith("insert")) {
1670
1849
  const totalSlots = this.engine.getEditableCount();
1671
1850
  if (totalSlots > 0) {
@@ -1687,7 +1866,8 @@ var InputMask = class extends BaseInputMask {
1687
1866
  if (this.isDispatchingNativeInput) return;
1688
1867
  if (this.isComposing) return;
1689
1868
  const hasOnInput = Boolean(this.options.onInput || this.options.oninput);
1690
- if (hasOnInput && this.input.value !== this.lastValue) {
1869
+ const currentComparison = this.isPasswordInput() ? this.computePasswordDigest(this.input.value) : this.input.value;
1870
+ if (hasOnInput && currentComparison !== this.lastValue) {
1691
1871
  this.checkValueChange();
1692
1872
  }
1693
1873
  if (this.options.disabled) {
@@ -1729,7 +1909,7 @@ var InputMask = class extends BaseInputMask {
1729
1909
  }
1730
1910
  e.preventDefault();
1731
1911
  this.history.updateCurrentCursor(this.input.selectionStart ?? 0);
1732
- const rawPasted = e.clipboardData?.getData("text") || "";
1912
+ const rawPasted = (e.clipboardData?.getData("text") || "").slice(0, 4096);
1733
1913
  const pastedText = rawPasted.trim();
1734
1914
  if (!pastedText) return;
1735
1915
  const minPos = this.engine.getPrefixLength();
@@ -1781,8 +1961,14 @@ var InputMask = class extends BaseInputMask {
1781
1961
  }
1782
1962
  onBlur() {
1783
1963
  this.wrapper.classList.remove("is-focused", "has-selection");
1784
- if (this.input.type === "password") {
1964
+ if (this.isPasswordInput()) {
1785
1965
  this.history.clear();
1966
+ this.lastValue = "";
1967
+ this.lastInternalRemainingMask = "";
1968
+ this.lastTrackedValue = "";
1969
+ this.clearGhost();
1970
+ this.wrapper.removeAttribute("data-mask");
1971
+ return;
1786
1972
  }
1787
1973
  this.updateGhost(this.input.value);
1788
1974
  }
@@ -1836,26 +2022,25 @@ var InputMask = class extends BaseInputMask {
1836
2022
  // ==========================================================================
1837
2023
  updateGhost(formatted) {
1838
2024
  if (!this.ghost) return;
1839
- if (this.options.disabled) {
1840
- this.ghost.textContent = "";
2025
+ if (this.options.disabled || this.isPasswordInput()) {
2026
+ this.clearGhost();
1841
2027
  return;
1842
2028
  }
1843
2029
  const isCleanEmpty = !formatted || formatted === this.engine.getPrefix();
1844
2030
  if (this.shouldHideGhostForPlaceholder(isCleanEmpty)) {
1845
- this.ghost.textContent = "";
2031
+ this.clearGhost();
1846
2032
  return;
1847
2033
  }
1848
2034
  const fullTemplate = this.engine.getFullMaskTemplate();
1849
2035
  const rest = fullTemplate.length > formatted.length ? fullTemplate.substring(formatted.length) : "";
1850
- this.ghost.textContent = "";
1851
- const spanTyped = document.createElement("span");
2036
+ const doc = this.input.ownerDocument || document;
2037
+ const spanTyped = doc.createElement("span");
1852
2038
  spanTyped.className = "mask-ghost-typed";
1853
2039
  spanTyped.textContent = formatted;
1854
- const spanRemaining = document.createElement("span");
2040
+ const spanRemaining = doc.createElement("span");
1855
2041
  spanRemaining.className = "mask-ghost-remaining";
1856
2042
  spanRemaining.textContent = rest;
1857
- this.ghost.appendChild(spanTyped);
1858
- this.ghost.appendChild(spanRemaining);
2043
+ this.setGhostContent(spanTyped, spanRemaining);
1859
2044
  this.ghost.scrollLeft = this.input.scrollLeft;
1860
2045
  }
1861
2046
  applyMask(rawOrPartial, cursorPosition, forceExactCursor = false) {
@@ -1866,10 +2051,17 @@ var InputMask = class extends BaseInputMask {
1866
2051
  try {
1867
2052
  formatted = this.engine.format(rawOrPartial);
1868
2053
  const remainingMask = this.engine.getRemainingMask(formatted);
2054
+ const isPwd = this.isPasswordInput();
1869
2055
  this.input.value = formatted;
1870
- this.lastInternalRemainingMask = remainingMask;
1871
- this.wrapper.setAttribute("data-mask", remainingMask);
1872
- this.updateGhost(formatted);
2056
+ if (isPwd) {
2057
+ this.lastInternalRemainingMask = "";
2058
+ this.wrapper.removeAttribute("data-mask");
2059
+ this.clearGhost();
2060
+ } else {
2061
+ this.lastInternalRemainingMask = remainingMask;
2062
+ this.wrapper.setAttribute("data-mask", remainingMask);
2063
+ this.updateGhost(formatted);
2064
+ }
1873
2065
  const minPos = this.engine.getPrefixLength();
1874
2066
  let safeCursor;
1875
2067
  if (forceExactCursor || this.isUndoingRedoing) {
@@ -1881,7 +2073,10 @@ var InputMask = class extends BaseInputMask {
1881
2073
  this.input.setSelectionRange(safeCursor, safeCursor);
1882
2074
  isCompleted = this.isComplete();
1883
2075
  this.wrapper.classList.toggle("is-complete", isCompleted);
1884
- if (!this.isUndoingRedoing && this.input.type !== "password") {
2076
+ if (isPwd) {
2077
+ this.options.copyRaw = false;
2078
+ this.history.clear();
2079
+ } else if (!this.isUndoingRedoing) {
1885
2080
  this.history.push(this.getRawValue(), safeCursor);
1886
2081
  }
1887
2082
  } finally {
@@ -1890,10 +2085,11 @@ var InputMask = class extends BaseInputMask {
1890
2085
  this.checkValueChange();
1891
2086
  }
1892
2087
  syncInitialValue() {
2088
+ const isPwd = this.isPasswordInput();
1893
2089
  if (this.options.disabled) {
1894
2090
  this.wrapper.removeAttribute("data-mask");
1895
- if (this.ghost) this.ghost.textContent = "";
1896
- this.lastValue = this.input.value;
2091
+ this.clearGhost();
2092
+ this.lastValue = isPwd ? this.computePasswordDigest(this.input.value) : this.input.value;
1897
2093
  this.checkValueChange();
1898
2094
  return;
1899
2095
  }
@@ -1906,13 +2102,17 @@ var InputMask = class extends BaseInputMask {
1906
2102
  if (minPos > 0) {
1907
2103
  this.applyMask("", minPos);
1908
2104
  } else {
1909
- if (this.input.type !== "password") {
2105
+ if (!isPwd) {
1910
2106
  this.history.push("", 0);
2107
+ const fullTemplate = this.engine.getFullMaskTemplate();
2108
+ this.lastInternalRemainingMask = fullTemplate;
2109
+ this.wrapper.setAttribute("data-mask", fullTemplate);
2110
+ this.updateGhost("");
2111
+ } else {
2112
+ this.lastInternalRemainingMask = "";
2113
+ this.wrapper.removeAttribute("data-mask");
2114
+ this.clearGhost();
1911
2115
  }
1912
- const fullTemplate = this.engine.getFullMaskTemplate();
1913
- this.lastInternalRemainingMask = fullTemplate;
1914
- this.wrapper.setAttribute("data-mask", fullTemplate);
1915
- this.updateGhost("");
1916
2116
  this.checkValueChange();
1917
2117
  }
1918
2118
  }
@@ -1922,8 +2122,10 @@ var InputMask = class extends BaseInputMask {
1922
2122
  * Gère de manière sûre la réentrance pour permettre d'appeler setMask() directement dans le callback.
1923
2123
  */
1924
2124
  checkValueChange(forceNotify = false) {
2125
+ const isPwd = this.isPasswordInput();
1925
2126
  const currentVal = this.input.value;
1926
- if (currentVal === this.lastValue && !forceNotify && !this.hasPendingNotification) {
2127
+ const currentComparison = isPwd ? this.computePasswordDigest(currentVal) : currentVal;
2128
+ if (currentComparison === this.lastValue && !forceNotify && !this.hasPendingNotification) {
1927
2129
  return;
1928
2130
  }
1929
2131
  if (this.isNotifying) {
@@ -1932,11 +2134,14 @@ var InputMask = class extends BaseInputMask {
1932
2134
  }
1933
2135
  this.isNotifying = true;
1934
2136
  try {
1935
- while (this.input.value !== this.lastValue || this.hasPendingNotification || forceNotify) {
2137
+ let iterations = 0;
2138
+ const MAX_NOTIFICATION_ITERATIONS = 10;
2139
+ while (((isPwd ? this.computePasswordDigest(this.input.value) : this.input.value) !== this.lastValue || this.hasPendingNotification || forceNotify) && iterations < MAX_NOTIFICATION_ITERATIONS) {
2140
+ iterations++;
1936
2141
  this.hasPendingNotification = false;
1937
2142
  forceNotify = false;
1938
2143
  const valToNotify = this.input.value;
1939
- this.lastValue = valToNotify;
2144
+ this.lastValue = isPwd ? this.computePasswordDigest(valToNotify) : valToNotify;
1940
2145
  const raw = this.options.disabled ? valToNotify : this.getRawValue();
1941
2146
  const totalSlots = this.options.disabled ? 0 : this.engine.getEditableCount();
1942
2147
  const isComplete = this.isComplete();
@@ -1974,19 +2179,22 @@ var InputMask = class extends BaseInputMask {
1974
2179
 
1975
2180
  // src/mask/AmountEngine.ts
1976
2181
  var AmountEngine = class _AmountEngine {
2182
+ options;
1977
2183
  constructor(options = {}) {
1978
2184
  let currency = options.currency ?? "";
1979
2185
  if (!currency && options.unit) {
1980
2186
  currency = options.unit;
1981
2187
  }
1982
2188
  const defaultPosition = currency === "$" || currency === "\xA3" || currency === "\xA5" ? "prefix" : "suffix";
2189
+ const rawDecimals = options.decimals !== void 0 ? Number(options.decimals) : 2;
2190
+ const safeDecimals = Number.isFinite(rawDecimals) ? Math.min(20, Math.max(0, Math.floor(rawDecimals))) : 2;
1983
2191
  this.options = {
1984
- currency,
1985
- unit: options.unit ?? currency,
2192
+ currency: String(currency).slice(0, 32),
2193
+ unit: String(options.unit ?? currency).slice(0, 32),
1986
2194
  currencyPosition: options.currencyPosition ?? defaultPosition,
1987
- decimals: options.decimals !== void 0 ? Math.max(0, options.decimals) : 2,
1988
- decimalSeparator: options.decimalSeparator ?? ",",
1989
- thousandSeparator: options.thousandSeparator ?? "\xA0",
2195
+ decimals: safeDecimals,
2196
+ decimalSeparator: String(options.decimalSeparator ?? ",").slice(0, 4) || ",",
2197
+ thousandSeparator: String(options.thousandSeparator ?? "\xA0").slice(0, 4),
1990
2198
  // Espace insécable
1991
2199
  allowNegative: options.allowNegative ?? false,
1992
2200
  min: options.min ?? -Infinity,
@@ -1997,7 +2205,7 @@ var AmountEngine = class _AmountEngine {
1997
2205
  * Analyse et nettoie une saisie utilisateur pour extraire ses composantes numériques.
1998
2206
  */
1999
2207
  parse(input) {
2000
- let str = input.trim();
2208
+ let str = String(input ?? "").slice(0, 512).trim();
2001
2209
  let isNegative = false;
2002
2210
  if (this.options.allowNegative && str.includes("-")) {
2003
2211
  isNegative = true;
@@ -2038,7 +2246,9 @@ var AmountEngine = class _AmountEngine {
2038
2246
  * @param rawCursor Position actuelle du curseur dans l'input natif
2039
2247
  */
2040
2248
  format(input, rawCursor = input.length, padDecimals = false) {
2041
- if (!input || input.trim() === "" || input === this.options.currency.trim()) {
2249
+ const safeInput = String(input ?? "").slice(0, 512);
2250
+ const safeRawCursor = Math.max(0, Math.min(rawCursor, safeInput.length));
2251
+ if (!safeInput || safeInput.trim() === "" || safeInput === this.options.currency.trim()) {
2042
2252
  return {
2043
2253
  formatted: "",
2044
2254
  rawNumber: null,
@@ -2047,10 +2257,10 @@ var AmountEngine = class _AmountEngine {
2047
2257
  isValid: true
2048
2258
  };
2049
2259
  }
2050
- const prefixBeforeCursor = input.substring(0, rawCursor);
2260
+ const prefixBeforeCursor = safeInput.substring(0, safeRawCursor);
2051
2261
  const digitsBeforeCursor = prefixBeforeCursor.replace(/\D/g, "").length;
2052
2262
  const hadDecimalBeforeCursor = this.options.decimals > 0 && /[,.]/.test(prefixBeforeCursor);
2053
- const { isNegative, integerPart, decimalPart, hasDecimal } = this.parse(input);
2263
+ const { isNegative, integerPart, decimalPart, hasDecimal } = this.parse(safeInput);
2054
2264
  let effectiveDecimal = decimalPart;
2055
2265
  let effectiveHasDecimal = hasDecimal;
2056
2266
  if (padDecimals && this.options.decimals > 0 && (integerPart || decimalPart !== null)) {
@@ -2090,7 +2300,7 @@ var AmountEngine = class _AmountEngine {
2090
2300
  isValid: true
2091
2301
  };
2092
2302
  }
2093
- const formattedInteger = (integerPart || "0").replace(/\B(?=(\d{3})+(?!\d))/g, this.options.thousandSeparator);
2303
+ const formattedInteger = this.formatThousands(integerPart || "0");
2094
2304
  let numberCore = formattedInteger;
2095
2305
  if (effectiveHasDecimal && this.options.decimals > 0) {
2096
2306
  numberCore += this.options.decimalSeparator + (effectiveDecimal ?? "");
@@ -2163,6 +2373,18 @@ var AmountEngine = class _AmountEngine {
2163
2373
  const str = typeof value === "number" ? value.toString() : value;
2164
2374
  return engine.format(str).formatted;
2165
2375
  }
2376
+ formatThousands(digits) {
2377
+ const sep = this.options.thousandSeparator;
2378
+ if (!sep || digits.length <= 3) return digits;
2379
+ const parts = [];
2380
+ let i = digits.length;
2381
+ while (i > 0) {
2382
+ const start = Math.max(0, i - 3);
2383
+ parts.push(digits.slice(start, i));
2384
+ i = start;
2385
+ }
2386
+ return parts.reverse().join(sep);
2387
+ }
2166
2388
  escapeRegExp(string) {
2167
2389
  return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2168
2390
  }
@@ -2170,6 +2392,16 @@ var AmountEngine = class _AmountEngine {
2170
2392
 
2171
2393
  // src/mask/InputAmountMask.ts
2172
2394
  var InputAmountMask = class extends BaseInputMask {
2395
+ engine;
2396
+ history;
2397
+ isUndoingRedoing = false;
2398
+ isApplying = false;
2399
+ isComposing = false;
2400
+ lastValue = "";
2401
+ wasInputModeInferred = false;
2402
+ cutTimerId = null;
2403
+ resetTimerId = null;
2404
+ cursorTimerId = null;
2173
2405
  constructor(targetOrWrapper, inputOrOptions, options) {
2174
2406
  const args = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, options);
2175
2407
  const wrap = args.wrapper;
@@ -2183,13 +2415,10 @@ var InputAmountMask = class extends BaseInputMask {
2183
2415
  ...opts
2184
2416
  };
2185
2417
  super(wrap, inp, resolvedOptions);
2186
- this.isUndoingRedoing = false;
2187
- this.isApplying = false;
2188
- this.isComposing = false;
2189
- this.lastValue = "";
2190
- this.cutTimerId = null;
2191
- this.resetTimerId = null;
2192
- this.input.inputMode = "decimal";
2418
+ if (!this.input.hasAttribute("inputmode")) {
2419
+ this.input.inputMode = "decimal";
2420
+ this.wasInputModeInferred = true;
2421
+ }
2193
2422
  this.history = new MaskHistory();
2194
2423
  this.engine = new AmountEngine(this.options);
2195
2424
  this.bindEvents();
@@ -2213,6 +2442,12 @@ var InputAmountMask = class extends BaseInputMask {
2213
2442
  if (!p.integerPart && !p.decimalPart) return "";
2214
2443
  return (p.isNegative ? "-" : "") + (p.integerPart || "0") + (p.decimalPart ? "." + p.decimalPart : "");
2215
2444
  }
2445
+ onPasswordModeDetected() {
2446
+ this.history.clear();
2447
+ this.lastValue = "";
2448
+ this.lastTrackedValue = "";
2449
+ this.clearGhost();
2450
+ }
2216
2451
  /**
2217
2452
  * Formate statiquement une valeur sans nécessiter d'élément DOM.
2218
2453
  */
@@ -2227,7 +2462,9 @@ var InputAmountMask = class extends BaseInputMask {
2227
2462
  this.applyAmount(strVal, strVal.length);
2228
2463
  }
2229
2464
  onDisabledChange(disabled) {
2230
- if (!disabled) {
2465
+ if (disabled) {
2466
+ this.clearGhost();
2467
+ } else {
2231
2468
  this.applyAmount(this.input.value, this.input.selectionStart ?? this.input.value.length);
2232
2469
  }
2233
2470
  }
@@ -2250,15 +2487,16 @@ var InputAmountMask = class extends BaseInputMask {
2250
2487
  this.applyAmount(this.input.value, cur);
2251
2488
  }, 0);
2252
2489
  };
2253
- this.input.addEventListener("input", this.handleInput);
2254
- this.input.addEventListener("keydown", this.handleKeyDown);
2255
- this.input.addEventListener("blur", this.handleBlur);
2256
- this.input.addEventListener("focus", this.handleFocus);
2257
- this.input.addEventListener("click", this.handleClick);
2258
- this.input.addEventListener("scroll", this.onScroll);
2259
- this.input.addEventListener("cut", this.onCutHandler);
2260
- this.input.addEventListener("compositionstart", this.onCompositionStart);
2261
- this.input.addEventListener("compositionend", this.onCompositionEnd);
2490
+ const { signal } = this.abortController;
2491
+ this.input.addEventListener("input", this.handleInput, { signal });
2492
+ this.input.addEventListener("keydown", this.handleKeyDown, { signal });
2493
+ this.input.addEventListener("blur", this.handleBlur, { signal });
2494
+ this.input.addEventListener("focus", this.handleFocus, { signal });
2495
+ this.input.addEventListener("click", this.handleClick, { signal });
2496
+ this.input.addEventListener("scroll", this.onScroll, { passive: true, signal });
2497
+ this.input.addEventListener("cut", this.onCutHandler, { signal });
2498
+ this.input.addEventListener("compositionstart", this.onCompositionStart, { signal });
2499
+ this.input.addEventListener("compositionend", this.onCompositionEnd, { signal });
2262
2500
  if (this.input.form) {
2263
2501
  this.onFormResetHandler = () => {
2264
2502
  if (this.resetTimerId !== null) {
@@ -2271,7 +2509,7 @@ var InputAmountMask = class extends BaseInputMask {
2271
2509
  this.applyAmount(this.input.value, this.input.value.length);
2272
2510
  }, 0);
2273
2511
  };
2274
- this.input.form.addEventListener("reset", this.onFormResetHandler);
2512
+ this.input.form.addEventListener("reset", this.onFormResetHandler, { signal });
2275
2513
  }
2276
2514
  }
2277
2515
  onCompositionStart() {
@@ -2290,12 +2528,20 @@ var InputAmountMask = class extends BaseInputMask {
2290
2528
  const result = this.engine.format(val, cursor);
2291
2529
  this.setNativeValue(result.formatted);
2292
2530
  this.input.setSelectionRange(result.cursor, result.cursor);
2293
- if (!this.isUndoingRedoing && this.input.type !== "password") {
2294
- this.history.push(result.rawValue, result.cursor);
2531
+ const isPwd = this.isPasswordInput();
2532
+ if (isPwd) {
2533
+ this.options.copyRaw = false;
2534
+ this.history.clear();
2535
+ this.clearGhost();
2536
+ } else {
2537
+ if (!this.isUndoingRedoing) {
2538
+ this.history.push(result.rawValue, result.cursor);
2539
+ }
2540
+ this.updateGhost(result);
2295
2541
  }
2296
- this.updateGhost(result);
2297
- if (this.lastValue !== result.formatted) {
2298
- this.lastValue = result.formatted;
2542
+ const nextComparison = isPwd ? this.computePasswordDigest(result.formatted) : result.formatted;
2543
+ if (this.lastValue !== nextComparison) {
2544
+ this.lastValue = nextComparison;
2299
2545
  this.notifyChange(result);
2300
2546
  }
2301
2547
  } finally {
@@ -2306,18 +2552,18 @@ var InputAmountMask = class extends BaseInputMask {
2306
2552
  if (!this.ghost) return;
2307
2553
  if (!result.formatted) {
2308
2554
  if (this.shouldHideGhostForPlaceholder(true)) {
2309
- this.ghost.textContent = "";
2555
+ this.clearGhost();
2310
2556
  return;
2311
2557
  }
2312
2558
  const hint = this.options.currency ? this.options.currencyPosition === "prefix" ? `${this.options.currency} 0` : `0 ${this.options.currency}` : "0,00";
2313
- this.ghost.textContent = "";
2314
- const span = document.createElement("span");
2559
+ const doc = this.input.ownerDocument || document;
2560
+ const span = doc.createElement("span");
2315
2561
  span.className = "mask-ghost-remaining";
2316
2562
  span.textContent = hint;
2317
- this.ghost.appendChild(span);
2563
+ this.setGhostContent(span);
2318
2564
  return;
2319
2565
  }
2320
- this.ghost.textContent = "";
2566
+ this.clearGhost();
2321
2567
  this.ghost.scrollLeft = this.input.scrollLeft;
2322
2568
  }
2323
2569
  handleInput() {
@@ -2328,7 +2574,7 @@ var InputAmountMask = class extends BaseInputMask {
2328
2574
  this.applyAmount(rawVal, cur);
2329
2575
  }
2330
2576
  handleKeyDown(e) {
2331
- if (this.options.disabled) return;
2577
+ if (this.options.disabled || isImeComposing(e)) return;
2332
2578
  if ((e.ctrlKey || e.metaKey) && (e.key === "z" || e.key === "Z")) {
2333
2579
  e.preventDefault();
2334
2580
  if (e.shiftKey) this.redo();
@@ -2380,10 +2626,18 @@ var InputAmountMask = class extends BaseInputMask {
2380
2626
  }
2381
2627
  }
2382
2628
  }
2383
- setTimeout(() => this.enforceCursorBounds(), 0);
2629
+ if (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "Home" || e.key === "End") {
2630
+ if (this.cursorTimerId !== null) {
2631
+ clearTimeout(this.cursorTimerId);
2632
+ }
2633
+ this.cursorTimerId = window.setTimeout(() => {
2634
+ this.cursorTimerId = null;
2635
+ this.enforceCursorBounds();
2636
+ }, 0);
2637
+ }
2384
2638
  }
2385
2639
  enforceCursorBounds() {
2386
- if (!this.input.value || this.options.disabled) return;
2640
+ if (this.isDestroyed || !this.isFocused || document.activeElement !== this.input || !this.input.value || this.options.disabled) return;
2387
2641
  const start = this.input.selectionStart ?? 0;
2388
2642
  const end = this.input.selectionEnd ?? 0;
2389
2643
  if (start !== end) return;
@@ -2414,8 +2668,12 @@ var InputAmountMask = class extends BaseInputMask {
2414
2668
  }
2415
2669
  handleBlur() {
2416
2670
  this.wrapper.classList.remove("is-focused");
2417
- if (this.input.type === "password") {
2671
+ if (this.isPasswordInput()) {
2418
2672
  this.history.clear();
2673
+ this.lastValue = "";
2674
+ this.lastTrackedValue = "";
2675
+ this.clearGhost();
2676
+ return;
2419
2677
  }
2420
2678
  if (this.options.padDecimalsOnBlur && !this.options.disabled && this.input.value.trim().length > 0) {
2421
2679
  const paddedResult = this.engine.format(this.input.value, this.input.value.length, true);
@@ -2511,30 +2769,62 @@ var InputAmountMask = class extends BaseInputMask {
2511
2769
  clearTimeout(this.resetTimerId);
2512
2770
  this.resetTimerId = null;
2513
2771
  }
2514
- this.input.removeEventListener("input", this.handleInput);
2515
- this.input.removeEventListener("keydown", this.handleKeyDown);
2516
- this.input.removeEventListener("blur", this.handleBlur);
2517
- this.input.removeEventListener("focus", this.handleFocus);
2518
- this.input.removeEventListener("click", this.handleClick);
2519
- this.input.removeEventListener("scroll", this.onScroll);
2520
- this.input.removeEventListener("cut", this.onCutHandler);
2521
- this.input.removeEventListener("compositionstart", this.onCompositionStart);
2522
- this.input.removeEventListener("compositionend", this.onCompositionEnd);
2523
- if (this.input.form && this.onFormResetHandler) {
2524
- this.input.form.removeEventListener("reset", this.onFormResetHandler);
2772
+ if (this.cursorTimerId !== null) {
2773
+ clearTimeout(this.cursorTimerId);
2774
+ this.cursorTimerId = null;
2525
2775
  }
2776
+ if (this.wasInputModeInferred && this.input.getAttribute("inputmode") === "decimal") {
2777
+ this.input.removeAttribute("inputmode");
2778
+ }
2779
+ this.lastValue = "";
2526
2780
  this.history.clear();
2527
2781
  super.destroy();
2528
2782
  }
2529
2783
  };
2530
2784
 
2531
2785
  // src/mask/EmailEngine.ts
2532
- var _EmailEngine = class _EmailEngine {
2786
+ var EmailEngine = class _EmailEngine {
2787
+ domains;
2788
+ tlds;
2789
+ suggestOnAt;
2790
+ defaultDomain = null;
2791
+ defaultTld = "__";
2792
+ static DEFAULT_DOMAINS = [
2793
+ "gmail.com",
2794
+ "outlook.com",
2795
+ "orange.fr",
2796
+ "free.fr",
2797
+ "sfr.fr",
2798
+ "yahoo.com",
2799
+ "hotmail.com",
2800
+ "icloud.com",
2801
+ "laposte.net",
2802
+ "proton.me"
2803
+ ];
2804
+ static DEFAULT_TLDS = [
2805
+ "com",
2806
+ "fr",
2807
+ "net",
2808
+ "org",
2809
+ "eu",
2810
+ "io",
2811
+ "co",
2812
+ "info",
2813
+ "biz",
2814
+ "me",
2815
+ "tv",
2816
+ "fi",
2817
+ "be",
2818
+ "ch",
2819
+ "ca",
2820
+ "uk",
2821
+ "de",
2822
+ "es",
2823
+ "it"
2824
+ ];
2533
2825
  constructor(options = {}) {
2534
- this.defaultDomain = null;
2535
- this.defaultTld = "__";
2536
2826
  this.domains = options.domains && options.domains.length > 0 ? options.domains : _EmailEngine.DEFAULT_DOMAINS;
2537
- this.tlds = options.tlds && options.tlds.length > 0 ? options.tlds.map((t) => t.trim().replace(/^\./, "")).filter(Boolean) : [..._EmailEngine.DEFAULT_TLDS];
2827
+ 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];
2538
2828
  this.suggestOnAt = options.suggestOnAt ?? true;
2539
2829
  this.setDefaultDomain(options.defaultDomain ?? null);
2540
2830
  this.setDefaultTld(options.defaultTld !== void 0 ? options.defaultTld : "__");
@@ -2567,7 +2857,7 @@ var _EmailEngine = class _EmailEngine {
2567
2857
  * Définit ou modifie la liste des extensions (TLD) proposées par ordre de priorité.
2568
2858
  */
2569
2859
  setTlds(tlds) {
2570
- this.tlds = tlds && tlds.length > 0 ? tlds.map((t) => t.trim().replace(/^\./, "")).filter(Boolean) : [..._EmailEngine.DEFAULT_TLDS];
2860
+ this.tlds = tlds && tlds.length > 0 ? tlds.slice(0, 200).map((t) => String(t).trim().replace(/^\./, "").slice(0, 32)).filter(Boolean) : [..._EmailEngine.DEFAULT_TLDS];
2571
2861
  }
2572
2862
  /**
2573
2863
  * Retourne l'ensemble des extensions (TLD) correspondant au fragment saisi après le dernier point,
@@ -2584,7 +2874,7 @@ var _EmailEngine = class _EmailEngine {
2584
2874
  * Retourne l'ensemble des domaines correspondant à la saisie courante.
2585
2875
  */
2586
2876
  getMatchingDomains(input) {
2587
- const val = input ?? "";
2877
+ const val = String(input ?? "").slice(0, 512);
2588
2878
  if (!val.includes("@")) {
2589
2879
  return this.defaultDomain ? [this.defaultDomain] : [];
2590
2880
  }
@@ -2606,7 +2896,7 @@ var _EmailEngine = class _EmailEngine {
2606
2896
  * @param matchIndex Index de la suggestion à sélectionner si plusieurs domaines/TLD correspondent (permet le cyclage)
2607
2897
  */
2608
2898
  getSuggestion(input, matchIndex = 0) {
2609
- const val = input ?? "";
2899
+ const val = String(input ?? "").slice(0, 512);
2610
2900
  if (!val.includes("@")) {
2611
2901
  if (this.defaultDomain) {
2612
2902
  return {
@@ -2638,22 +2928,22 @@ var _EmailEngine = class _EmailEngine {
2638
2928
  };
2639
2929
  }
2640
2930
  if (domainPart.length === 0 || domainPart.startsWith(".")) {
2641
- return { full: input, remaining: "", matchedDomain: null, isHintOnly: false };
2931
+ return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
2642
2932
  }
2643
2933
  const lowerDomain = domainPart.toLowerCase();
2644
2934
  if (this.domains.some((d) => d.toLowerCase() === lowerDomain)) {
2645
- return { full: input, remaining: "", matchedDomain: domainPart, isHintOnly: false };
2935
+ return { full: val, remaining: "", matchedDomain: domainPart, isHintOnly: false };
2646
2936
  }
2647
2937
  const lastDotIndex = domainPart.lastIndexOf(".");
2648
2938
  if (lastDotIndex === -1) {
2649
2939
  if (!this.defaultTld) {
2650
- return { full: input, remaining: "", matchedDomain: null, isHintOnly: false };
2940
+ return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
2651
2941
  }
2652
2942
  const isHint = this.defaultTld.includes("_");
2653
2943
  const remaining = `.${this.defaultTld}`;
2654
2944
  const fullDomain = `${domainPart}.${this.defaultTld}`;
2655
2945
  return {
2656
- full: isHint ? input : `${localPart}@${fullDomain}`,
2946
+ full: isHint ? val : `${localPart}@${fullDomain}`,
2657
2947
  remaining,
2658
2948
  matchedDomain: isHint ? null : fullDomain,
2659
2949
  isHintOnly: isHint
@@ -2662,7 +2952,7 @@ var _EmailEngine = class _EmailEngine {
2662
2952
  const hostPart = domainPart.substring(0, lastDotIndex);
2663
2953
  const tldPart = domainPart.substring(lastDotIndex + 1);
2664
2954
  if (!hostPart || hostPart.endsWith(".")) {
2665
- return { full: input, remaining: "", matchedDomain: null, isHintOnly: false };
2955
+ return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
2666
2956
  }
2667
2957
  if (tldPart.length === 0) {
2668
2958
  if (this.defaultTld && !this.defaultTld.includes("_")) {
@@ -2676,15 +2966,18 @@ var _EmailEngine = class _EmailEngine {
2676
2966
  }
2677
2967
  if (this.defaultTld && this.defaultTld.includes("_")) {
2678
2968
  return {
2679
- full: input,
2969
+ full: val,
2680
2970
  remaining: this.defaultTld,
2681
2971
  matchedDomain: null,
2682
2972
  isHintOnly: true
2683
2973
  };
2684
2974
  }
2685
- return { full: input, remaining: "", matchedDomain: null, isHintOnly: false };
2975
+ return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
2686
2976
  }
2687
2977
  const lowerTld = tldPart.toLowerCase();
2978
+ if (this.tlds.some((t) => t.toLowerCase() === lowerTld)) {
2979
+ return { full: val, remaining: "", matchedDomain: domainPart, isHintOnly: false };
2980
+ }
2688
2981
  const matchingTlds = this.getMatchingTlds(tldPart);
2689
2982
  if (matchingTlds.length > 0) {
2690
2983
  const safeTldIndex = (matchIndex % matchingTlds.length + matchingTlds.length) % matchingTlds.length;
@@ -2702,53 +2995,34 @@ var _EmailEngine = class _EmailEngine {
2702
2995
  const remaining = this.defaultTld.substring(tldPart.length);
2703
2996
  if (remaining.includes("_")) {
2704
2997
  return {
2705
- full: input,
2998
+ full: val,
2706
2999
  remaining,
2707
3000
  matchedDomain: null,
2708
3001
  isHintOnly: true
2709
3002
  };
2710
3003
  }
2711
3004
  }
2712
- return { full: input, remaining: "", matchedDomain: null, isHintOnly: false };
3005
+ return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
2713
3006
  }
2714
3007
  };
2715
- _EmailEngine.DEFAULT_DOMAINS = [
2716
- "gmail.com",
2717
- "outlook.com",
2718
- "orange.fr",
2719
- "free.fr",
2720
- "sfr.fr",
2721
- "yahoo.com",
2722
- "hotmail.com",
2723
- "icloud.com",
2724
- "laposte.net",
2725
- "proton.me"
2726
- ];
2727
- _EmailEngine.DEFAULT_TLDS = [
2728
- "com",
2729
- "fr",
2730
- "net",
2731
- "org",
2732
- "eu",
2733
- "io",
2734
- "co",
2735
- "info",
2736
- "biz",
2737
- "me",
2738
- "tv",
2739
- "fi",
2740
- "be",
2741
- "ch",
2742
- "ca",
2743
- "uk",
2744
- "de",
2745
- "es",
2746
- "it"
2747
- ];
2748
- var EmailEngine = _EmailEngine;
2749
3008
 
2750
3009
  // src/mask/InputEmailMask.ts
2751
3010
  var InputEmailMask = class extends BaseInputMask {
3011
+ engine;
3012
+ currentSuggestion = { full: "", remaining: "", matchedDomain: null };
3013
+ currentSuggestionIndex = 0;
3014
+ wasAriaAutocompleteSet = false;
3015
+ wasAutocorrectSet = false;
3016
+ wasAutocapitalizeSet = false;
3017
+ wasSpellcheckSet = false;
3018
+ wasInputModeInferred = false;
3019
+ isComposing = false;
3020
+ lastNotifiedValue = "";
3021
+ srStatusEl = null;
3022
+ srAnnounceTimerId = null;
3023
+ lastAnnouncedSuggestion = "";
3024
+ cutTimerId = null;
3025
+ resetTimerId = null;
2752
3026
  constructor(targetOrWrapper, inputOrOptions, options) {
2753
3027
  const args = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, options);
2754
3028
  const wrap = args.wrapper;
@@ -2774,30 +3048,55 @@ var InputEmailMask = class extends BaseInputMask {
2774
3048
  ...resolvedDefaultTld !== void 0 ? { defaultTld: resolvedDefaultTld } : {}
2775
3049
  };
2776
3050
  super(wrap, inp, resolvedOptions);
2777
- this.currentSuggestion = { full: "", remaining: "", matchedDomain: null };
2778
- this.currentSuggestionIndex = 0;
2779
- this.wasAriaAutocompleteSet = false;
2780
- this.cutTimerId = null;
2781
- this.resetTimerId = null;
2782
- this.input.inputMode = "email";
3051
+ if (!this.input.hasAttribute("inputmode")) {
3052
+ this.input.inputMode = "email";
3053
+ this.wasInputModeInferred = true;
3054
+ }
3055
+ if (!this.input.hasAttribute("autocorrect")) {
3056
+ this.input.setAttribute("autocorrect", "off");
3057
+ this.wasAutocorrectSet = true;
3058
+ }
3059
+ if (!this.input.hasAttribute("autocapitalize")) {
3060
+ this.input.setAttribute("autocapitalize", "none");
3061
+ this.wasAutocapitalizeSet = true;
3062
+ }
3063
+ if (!this.input.hasAttribute("spellcheck")) {
3064
+ this.input.setAttribute("spellcheck", "false");
3065
+ this.wasSpellcheckSet = true;
3066
+ }
2783
3067
  if (this.options.setAriaAutocomplete && !this.input.hasAttribute("aria-autocomplete")) {
2784
3068
  this.input.setAttribute("aria-autocomplete", "inline");
2785
3069
  this.wasAriaAutocompleteSet = true;
2786
3070
  }
2787
3071
  this.engine = new EmailEngine(this.options);
3072
+ this.lastNotifiedValue = this.isPasswordInput() ? "" : this.input.value;
2788
3073
  this.bindEvents();
2789
- if (!this.options.disabled) {
3074
+ if (!this.options.disabled && !this.isPasswordInput()) {
2790
3075
  this.updateSuggestion();
2791
3076
  }
2792
3077
  this.runAuditWarning(this.options.audit);
2793
3078
  }
3079
+ onPasswordModeDetected() {
3080
+ if (this.srAnnounceTimerId !== null) {
3081
+ clearTimeout(this.srAnnounceTimerId);
3082
+ this.srAnnounceTimerId = null;
3083
+ }
3084
+ this.lastNotifiedValue = "";
3085
+ this.lastTrackedValue = "";
3086
+ this.lastAnnouncedSuggestion = "";
3087
+ this.currentSuggestion = { full: "", remaining: "", matchedDomain: null };
3088
+ if (this.srStatusEl) {
3089
+ this.srStatusEl.textContent = "";
3090
+ }
3091
+ this.clearGhost();
3092
+ }
2794
3093
  onNativeValueSet(_strVal) {
2795
- if (this.options.disabled) return;
3094
+ if (this.options.disabled || this.isComposing || this.isPasswordInput()) return;
2796
3095
  this.updateSuggestion();
2797
3096
  }
2798
3097
  onDisabledChange(disabled) {
2799
- if (disabled) {
2800
- if (this.ghost) this.ghost.textContent = "";
3098
+ if (disabled || this.isPasswordInput()) {
3099
+ this.clearGhost();
2801
3100
  } else {
2802
3101
  this.updateSuggestion();
2803
3102
  }
@@ -2813,16 +3112,26 @@ var InputEmailMask = class extends BaseInputMask {
2813
3112
  }
2814
3113
  this.cutTimerId = window.setTimeout(() => {
2815
3114
  this.cutTimerId = null;
2816
- if (this.isDestroyed || this.options.disabled) return;
3115
+ if (this.isDestroyed || this.options.disabled || this.isPasswordInput()) return;
2817
3116
  this.updateSuggestion();
2818
3117
  }, 0);
2819
3118
  };
2820
- this.input.addEventListener("input", this.handleInput);
2821
- this.input.addEventListener("keydown", this.handleKeyDown);
2822
- this.input.addEventListener("blur", this.handleBlur);
2823
- this.input.addEventListener("focus", this.handleFocus);
2824
- this.input.addEventListener("scroll", this.onScroll);
2825
- this.input.addEventListener("cut", this.onCutHandler);
3119
+ const { signal } = this.abortController;
3120
+ this.input.addEventListener("input", this.handleInput, { signal });
3121
+ this.input.addEventListener("keydown", this.handleKeyDown, { signal });
3122
+ this.input.addEventListener("blur", this.handleBlur, { signal });
3123
+ this.input.addEventListener("focus", this.handleFocus, { signal });
3124
+ this.input.addEventListener("scroll", this.onScroll, { passive: true, signal });
3125
+ this.input.addEventListener("cut", this.onCutHandler, { signal });
3126
+ this.input.addEventListener("compositionstart", () => {
3127
+ this.isComposing = true;
3128
+ }, { signal });
3129
+ this.input.addEventListener("compositionend", () => {
3130
+ this.isComposing = false;
3131
+ if (!this.isDestroyed && !this.options.disabled && !this.isPasswordInput()) {
3132
+ this.handleInput();
3133
+ }
3134
+ }, { signal });
2826
3135
  if (this.input.form) {
2827
3136
  this.onFormResetHandler = () => {
2828
3137
  if (this.resetTimerId !== null) {
@@ -2830,47 +3139,112 @@ var InputEmailMask = class extends BaseInputMask {
2830
3139
  }
2831
3140
  this.resetTimerId = window.setTimeout(() => {
2832
3141
  this.resetTimerId = null;
2833
- if (this.isDestroyed || this.options.disabled) return;
3142
+ if (this.isDestroyed || this.options.disabled || this.isPasswordInput()) return;
2834
3143
  this.updateSuggestion();
2835
3144
  }, 0);
2836
3145
  };
2837
- this.input.form.addEventListener("reset", this.onFormResetHandler);
3146
+ this.input.form.addEventListener("reset", this.onFormResetHandler, { signal });
2838
3147
  }
2839
3148
  }
2840
- updateSuggestion() {
2841
- if (this.options.disabled) {
2842
- if (this.ghost) this.ghost.textContent = "";
3149
+ ensureSrStatusEl() {
3150
+ if (this.srStatusEl && this.wrapper.contains(this.srStatusEl)) {
3151
+ return this.srStatusEl;
3152
+ }
3153
+ const doc = this.input.ownerDocument || (typeof document !== "undefined" ? document : null);
3154
+ if (!doc) return null;
3155
+ const status = doc.createElement("span");
3156
+ status.className = "wulf-mask-sr-status";
3157
+ status.setAttribute("aria-live", "polite");
3158
+ status.setAttribute("aria-atomic", "true");
3159
+ this.wrapper.appendChild(status);
3160
+ this.srStatusEl = status;
3161
+ return status;
3162
+ }
3163
+ scheduleSuggestionAnnouncement(immediate = false) {
3164
+ if (this.srAnnounceTimerId !== null) {
3165
+ clearTimeout(this.srAnnounceTimerId);
3166
+ this.srAnnounceTimerId = null;
3167
+ }
3168
+ if (!this.options.setAriaAutocomplete || !this.isFocused || this.isDestroyed || this.isPasswordInput()) {
3169
+ return;
3170
+ }
3171
+ const suggestion = this.currentSuggestion;
3172
+ if (!suggestion.remaining || suggestion.isHintOnly) {
3173
+ this.lastAnnouncedSuggestion = "";
3174
+ if (this.srStatusEl) {
3175
+ this.srStatusEl.textContent = "";
3176
+ }
3177
+ return;
3178
+ }
3179
+ const textToAnnounce = suggestion.full;
3180
+ if (textToAnnounce === this.lastAnnouncedSuggestion && !immediate) {
3181
+ return;
3182
+ }
3183
+ const run = () => {
3184
+ this.srAnnounceTimerId = null;
3185
+ if (this.isDestroyed || !this.isFocused || this.isPasswordInput()) return;
3186
+ this.lastAnnouncedSuggestion = textToAnnounce;
3187
+ const doc = this.input.ownerDocument || (typeof document !== "undefined" ? document : null);
3188
+ const docWithAriaNotify = doc;
3189
+ if (docWithAriaNotify && typeof docWithAriaNotify.ariaNotify === "function") {
3190
+ try {
3191
+ docWithAriaNotify.ariaNotify(textToAnnounce, { priority: "normal" });
3192
+ return;
3193
+ } catch {
3194
+ }
3195
+ }
3196
+ const statusEl = this.ensureSrStatusEl();
3197
+ if (statusEl) {
3198
+ statusEl.textContent = statusEl.textContent === textToAnnounce ? `${textToAnnounce}\xA0` : textToAnnounce;
3199
+ }
3200
+ };
3201
+ if (immediate) {
3202
+ run();
3203
+ } else {
3204
+ this.srAnnounceTimerId = window.setTimeout(run, 250);
3205
+ }
3206
+ }
3207
+ updateSuggestion(announceOptions) {
3208
+ if (this.options.disabled || this.isPasswordInput()) {
3209
+ this.currentSuggestion = { full: "", remaining: "", matchedDomain: null };
3210
+ this.clearGhost();
2843
3211
  return;
2844
3212
  }
2845
3213
  const val = this.input.value;
2846
3214
  this.currentSuggestion = this.engine.getSuggestion(val, this.currentSuggestionIndex);
2847
3215
  if (!this.ghost) return;
2848
3216
  if (this.shouldHideGhostForPlaceholder(val.length === 0)) {
2849
- this.ghost.textContent = "";
3217
+ this.clearGhost();
2850
3218
  } else if (this.currentSuggestion.remaining) {
2851
- this.ghost.textContent = "";
2852
- const spanTyped = document.createElement("span");
3219
+ const doc = this.input.ownerDocument || document;
3220
+ const spanTyped = doc.createElement("span");
2853
3221
  spanTyped.className = "mask-ghost-typed";
2854
3222
  spanTyped.textContent = val;
2855
- const spanRemaining = document.createElement("span");
3223
+ const spanRemaining = doc.createElement("span");
2856
3224
  spanRemaining.className = "mask-ghost-remaining";
2857
3225
  spanRemaining.textContent = this.currentSuggestion.remaining;
2858
- this.ghost.appendChild(spanTyped);
2859
- this.ghost.appendChild(spanRemaining);
3226
+ this.setGhostContent(spanTyped, spanRemaining);
2860
3227
  } else {
2861
- this.ghost.textContent = "";
3228
+ this.clearGhost();
2862
3229
  }
2863
3230
  this.ghost.scrollLeft = this.input.scrollLeft;
3231
+ if (announceOptions?.announce) {
3232
+ this.scheduleSuggestionAnnouncement(Boolean(announceOptions.immediate));
3233
+ }
2864
3234
  const detail = this.getDetail();
2865
3235
  if (this.options.onInput) {
2866
3236
  this.options.onInput(detail);
2867
3237
  }
2868
3238
  this.input.dispatchEvent(new CustomEvent("mask:input", { bubbles: true, detail }));
2869
- this.dispatchNativeInput();
3239
+ if (val !== this.lastNotifiedValue) {
3240
+ this.lastNotifiedValue = val;
3241
+ this.dispatchNativeInput();
3242
+ }
2870
3243
  }
2871
- handleInput() {
3244
+ handleInput(e) {
2872
3245
  if (this.isDispatchingNativeInput) return;
2873
- if (this.options.disabled) return;
3246
+ if (this.options.disabled || this.isPasswordInput()) return;
3247
+ if (this.isComposing || e && "isComposing" in e && e.isComposing) return;
2874
3248
  if (this.options.autoLowercase) {
2875
3249
  const start = this.input.selectionStart ?? 0;
2876
3250
  const end = this.input.selectionEnd ?? start;
@@ -2881,10 +3255,11 @@ var InputEmailMask = class extends BaseInputMask {
2881
3255
  }
2882
3256
  }
2883
3257
  this.currentSuggestionIndex = 0;
2884
- this.updateSuggestion();
3258
+ this.updateSuggestion({ announce: true, immediate: false });
2885
3259
  }
2886
3260
  handleKeyDown(e) {
2887
- if (this.options.disabled) return;
3261
+ if (this.options.disabled || this.isPasswordInput() || isImeComposing(e)) return;
3262
+ if (e.shiftKey || e.ctrlKey || e.altKey || e.metaKey) return;
2888
3263
  const hasSuggestion = Boolean(this.currentSuggestion.remaining) && !this.currentSuggestion.isHintOnly;
2889
3264
  const cursor = this.input.selectionStart ?? 0;
2890
3265
  const isAtEnd = cursor === this.input.value.length;
@@ -2893,13 +3268,13 @@ var InputEmailMask = class extends BaseInputMask {
2893
3268
  if (e.key === "ArrowDown") {
2894
3269
  e.preventDefault();
2895
3270
  this.currentSuggestionIndex++;
2896
- this.updateSuggestion();
3271
+ this.updateSuggestion({ announce: true, immediate: true });
2897
3272
  return;
2898
3273
  }
2899
3274
  if (e.key === "ArrowUp") {
2900
3275
  e.preventDefault();
2901
3276
  this.currentSuggestionIndex--;
2902
- this.updateSuggestion();
3277
+ this.updateSuggestion({ announce: true, immediate: true });
2903
3278
  return;
2904
3279
  }
2905
3280
  }
@@ -2966,6 +3341,20 @@ var InputEmailMask = class extends BaseInputMask {
2966
3341
  }
2967
3342
  handleBlur() {
2968
3343
  this.wrapper.classList.remove("is-focused");
3344
+ if (this.srAnnounceTimerId !== null) {
3345
+ clearTimeout(this.srAnnounceTimerId);
3346
+ this.srAnnounceTimerId = null;
3347
+ }
3348
+ this.lastAnnouncedSuggestion = "";
3349
+ if (this.srStatusEl) {
3350
+ this.srStatusEl.textContent = "";
3351
+ }
3352
+ if (this.isPasswordInput()) {
3353
+ this.lastNotifiedValue = "";
3354
+ this.lastTrackedValue = "";
3355
+ this.clearGhost();
3356
+ return;
3357
+ }
2969
3358
  this.updateSuggestion();
2970
3359
  const detail = this.getDetail();
2971
3360
  if (this.options.onChange) {
@@ -3011,18 +3400,31 @@ var InputEmailMask = class extends BaseInputMask {
3011
3400
  clearTimeout(this.resetTimerId);
3012
3401
  this.resetTimerId = null;
3013
3402
  }
3014
- this.input.removeEventListener("input", this.handleInput);
3015
- this.input.removeEventListener("keydown", this.handleKeyDown);
3016
- this.input.removeEventListener("blur", this.handleBlur);
3017
- this.input.removeEventListener("focus", this.handleFocus);
3018
- this.input.removeEventListener("scroll", this.onScroll);
3019
- this.input.removeEventListener("cut", this.onCutHandler);
3020
- if (this.input.form && this.onFormResetHandler) {
3021
- this.input.form.removeEventListener("reset", this.onFormResetHandler);
3403
+ if (this.srAnnounceTimerId !== null) {
3404
+ clearTimeout(this.srAnnounceTimerId);
3405
+ this.srAnnounceTimerId = null;
3406
+ }
3407
+ if (this.srStatusEl) {
3408
+ this.srStatusEl.remove();
3409
+ this.srStatusEl = null;
3410
+ }
3411
+ this.lastNotifiedValue = "";
3412
+ this.lastAnnouncedSuggestion = "";
3413
+ if (this.wasInputModeInferred && this.input.getAttribute("inputmode") === "email") {
3414
+ this.input.removeAttribute("inputmode");
3022
3415
  }
3023
3416
  if (this.wasAriaAutocompleteSet && this.input.getAttribute("aria-autocomplete") === "inline") {
3024
3417
  this.input.removeAttribute("aria-autocomplete");
3025
3418
  }
3419
+ if (this.wasAutocorrectSet && this.input.getAttribute("autocorrect") === "off") {
3420
+ this.input.removeAttribute("autocorrect");
3421
+ }
3422
+ if (this.wasAutocapitalizeSet && this.input.getAttribute("autocapitalize") === "none") {
3423
+ this.input.removeAttribute("autocapitalize");
3424
+ }
3425
+ if (this.wasSpellcheckSet && this.input.getAttribute("spellcheck") === "false") {
3426
+ this.input.removeAttribute("spellcheck");
3427
+ }
3026
3428
  super.destroy();
3027
3429
  }
3028
3430
  };
@@ -3039,10 +3441,8 @@ var Mask = {
3039
3441
  EmailEngine,
3040
3442
  InputEmailMask
3041
3443
  };
3042
- if (typeof window !== "undefined") {
3043
- const win = window;
3044
- const wulfNamespace = win.Wulf || {};
3045
- win.Wulf = wulfNamespace;
3444
+ var wulfNamespace = getSafeWulfNamespace();
3445
+ if (wulfNamespace) {
3046
3446
  wulfNamespace.Mask = Mask;
3047
3447
  }
3048
3448
  var index_default = InputMask;