wulf.js 2.0.1 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +240 -4
  2. package/changelog.md +37 -0
  3. package/dist/focus-trap.esm.js +110 -37
  4. package/dist/focus-trap.esm.js.map +2 -2
  5. package/dist/focus-trap.global.js +110 -37
  6. package/dist/focus-trap.global.js.map +2 -2
  7. package/dist/focus-trap.global.min.js +2 -2
  8. package/dist/focus-trap.global.min.js.map +3 -3
  9. package/dist/index.esm.js +3370 -337
  10. package/dist/index.esm.js.map +4 -4
  11. package/dist/index.global.js +3370 -337
  12. package/dist/index.global.js.map +4 -4
  13. package/dist/index.global.min.js +2 -2
  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 +2826 -171
  18. package/dist/mask.esm.js.map +4 -4
  19. package/dist/mask.global.js +2816 -161
  20. package/dist/mask.global.js.map +4 -4
  21. package/dist/mask.global.min.js +2 -2
  22. package/dist/mask.global.min.js.map +4 -4
  23. package/dist/mask.layered.css +1 -1
  24. package/dist/mask.layered.css.map +2 -2
  25. package/dist/masonry.esm.js +175 -69
  26. package/dist/masonry.esm.js.map +2 -2
  27. package/dist/masonry.global.js +175 -69
  28. package/dist/masonry.global.js.map +2 -2
  29. package/dist/masonry.global.min.js +3 -3
  30. package/dist/masonry.global.min.js.map +3 -3
  31. package/dist/scroll.css +1 -1
  32. package/dist/scroll.css.map +2 -2
  33. package/dist/scroll.esm.js +132 -40
  34. package/dist/scroll.esm.js.map +2 -2
  35. package/dist/scroll.global.js +132 -40
  36. package/dist/scroll.global.js.map +2 -2
  37. package/dist/scroll.global.min.js +2 -2
  38. package/dist/scroll.global.min.js.map +3 -3
  39. package/dist/scroll.layered.css +1 -1
  40. package/dist/scroll.layered.css.map +2 -2
  41. package/dist/shortcut.esm.js +182 -22
  42. package/dist/shortcut.esm.js.map +3 -3
  43. package/dist/shortcut.global.js +182 -22
  44. package/dist/shortcut.global.js.map +3 -3
  45. package/dist/shortcut.global.min.js +4 -1
  46. package/dist/shortcut.global.min.js.map +4 -4
  47. package/dist/toast.css +1 -1
  48. package/dist/toast.css.map +2 -2
  49. package/dist/toast.esm.js +116 -19
  50. package/dist/toast.esm.js.map +2 -2
  51. package/dist/toast.global.js +116 -19
  52. package/dist/toast.global.js.map +2 -2
  53. package/dist/toast.global.min.js +3 -3
  54. package/dist/toast.global.min.js.map +3 -3
  55. package/dist/toast.layered.css +1 -1
  56. package/dist/toast.layered.css.map +2 -2
  57. package/dist/types/common/AuditableComponent.d.ts +3 -3
  58. package/dist/types/common/dom.d.ts +5 -0
  59. package/dist/types/focus-trap/FocusTrap.d.ts +5 -2
  60. package/dist/types/mask/AmountEngine.d.ts +8 -0
  61. package/dist/types/mask/BaseInputMask.d.ts +18 -0
  62. package/dist/types/mask/DateUTCEngine.d.ts +187 -0
  63. package/dist/types/mask/InputAmountMask.d.ts +5 -0
  64. package/dist/types/mask/InputDateUTCMask.d.ts +110 -0
  65. package/dist/types/mask/InputEmailMask.d.ts +7 -0
  66. package/dist/types/mask/InputMask.d.ts +7 -5
  67. package/dist/types/mask/MaskEngine.d.ts +39 -7
  68. package/dist/types/mask/index.d.ts +12 -6
  69. package/dist/types/mask/paste.d.ts +15 -0
  70. package/dist/types/mask/types.d.ts +27 -2
  71. package/dist/types/masonry/Masonry.d.ts +2 -0
  72. package/dist/types/scroll/ScrollBlock.d.ts +2 -0
  73. package/dist/types/shortcut/ShortcutManager.d.ts +14 -3
  74. package/dist/types/toast/ToastManager.d.ts +2 -0
  75. package/package.json +1 -1
@@ -23,8 +23,11 @@ var __WulfIIFE = (() => {
23
23
  __export(index_exports, {
24
24
  AmountEngine: () => AmountEngine,
25
25
  BaseInputMask: () => BaseInputMask,
26
+ DATE_UTC_PRESETS: () => DATE_UTC_PRESETS,
27
+ DateUTCEngine: () => DateUTCEngine,
26
28
  EmailEngine: () => EmailEngine,
27
29
  InputAmountMask: () => InputAmountMask,
30
+ InputDateUTCMask: () => InputDateUTCMask,
28
31
  InputEmailMask: () => InputEmailMask,
29
32
  InputMask: () => InputMask,
30
33
  Mask: () => Mask,
@@ -32,7 +35,8 @@ var __WulfIIFE = (() => {
32
35
  MaskHistory: () => MaskHistory,
33
36
  MaskKeyboard: () => MaskKeyboard,
34
37
  default: () => index_default,
35
- resolveMaskConstructorArgs: () => resolveMaskConstructorArgs
38
+ sanitizePastedText: () => sanitizePastedText,
39
+ stripBidiAndInvisibles: () => stripBidiAndInvisibles
36
40
  });
37
41
 
38
42
  // src/common/dom.ts
@@ -53,6 +57,18 @@ var __WulfIIFE = (() => {
53
57
  }
54
58
  return String(value).replace(/["\\\u0000-\u001F\u007F]/g, "\\$&");
55
59
  }
60
+ function stripBidiAndInvisibles(raw, maxLength = 4096) {
61
+ const safeLimit = Math.max(0, maxLength);
62
+ return String(raw ?? "").slice(0, safeLimit).replace(/[\u061C\u200B-\u200F\u202A-\u202E\u2066-\u2069\uFEFF]/g, "");
63
+ }
64
+ function getDeepActiveElement(root) {
65
+ if (typeof document === "undefined") return null;
66
+ let active = (root ?? document).activeElement;
67
+ while (active && active.shadowRoot && active.shadowRoot.activeElement) {
68
+ active = active.shadowRoot.activeElement;
69
+ }
70
+ return active && typeof active.focus === "function" ? active : null;
71
+ }
56
72
  function safeMove(parent, node, referenceNode = null) {
57
73
  const moveBefore = parent.moveBefore;
58
74
  if (typeof moveBefore === "function" && node.isConnected && parent.isConnected && typeof parent.getRootNode === "function" && typeof node.getRootNode === "function" && parent.getRootNode() === node.getRootNode()) {
@@ -95,27 +111,48 @@ var __WulfIIFE = (() => {
95
111
  return warnings;
96
112
  }
97
113
  /**
98
- * Vérifie si un attribut de référence d'IDs ARIA (ex: aria-labelledby, aria-describedby)
99
- * pointe vers des éléments réellement présents dans le document.
114
+ * Vérifie si un attribut de référence d'IDs ARIA (ex: aria-labelledby, aria-describedby, aria-errormessage)
115
+ * pointe vers des éléments réellement présents dans le document (et optionnellement non vides).
100
116
  */
101
- checkAriaIdReferences(element, attrName, warnings) {
117
+ checkAriaIdReferences(element, attrName, warnings, requireNonEmptyText = false) {
102
118
  const rawValue = element.getAttribute(attrName)?.trim();
103
119
  if (!rawValue) return false;
104
120
  const doc = element.ownerDocument || document;
105
121
  const root = typeof element.getRootNode === "function" ? element.getRootNode() : doc;
106
122
  const ids = rawValue.split(/\s+/).filter(Boolean);
107
- const isValid = ids.length > 0 && ids.every(
108
- (id) => Boolean(typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root.getElementById(id) : doc.getElementById(id))
123
+ const targets = ids.map(
124
+ (id) => typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root.getElementById(id) : doc.getElementById(id)
109
125
  );
110
- if (!isValid) {
126
+ const allFound = ids.length > 0 && targets.every((el) => Boolean(el));
127
+ if (!allFound) {
111
128
  warnings.push(
112
129
  `Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`
113
130
  );
131
+ return false;
132
+ }
133
+ if (requireNonEmptyText) {
134
+ const hasNonEmptyText = targets.some((el) => {
135
+ if (!el) return false;
136
+ const text = el.textContent?.trim() || el.getAttribute("aria-label")?.trim() || "";
137
+ return text.length > 0;
138
+ });
139
+ if (!hasNonEmptyText) {
140
+ warnings.push(
141
+ `Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible ne contient aucun texte accessible.`
142
+ );
143
+ return false;
144
+ }
114
145
  }
115
- return isValid;
146
+ return true;
116
147
  }
117
148
  };
118
149
 
150
+ // src/mask/paste.ts
151
+ var MAX_PASTE_LENGTH = 4096;
152
+ function sanitizePastedText(raw, maxLength = MAX_PASTE_LENGTH) {
153
+ return stripBidiAndInvisibles(raw, maxLength).replace(/[\u00A0\u202F\u2007]/g, " ").replace(/[\u2013\u2014\u2212]/g, "-").trim();
154
+ }
155
+
119
156
  // src/mask/BaseInputMask.ts
120
157
  var VALID_ALIGNS = /* @__PURE__ */ new Set(["left", "right", "center"]);
121
158
  function resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, maybeOptions) {
@@ -153,6 +190,7 @@ var __WulfIIFE = (() => {
153
190
  };
154
191
  onFormResetHandler;
155
192
  mutationObserver = null;
193
+ resizeObserver = null;
156
194
  focusSelectTimerId = null;
157
195
  abortController = new AbortController();
158
196
  constructor(targetOrWrapper, inputOrOptions, maybeOptions) {
@@ -168,7 +206,7 @@ var __WulfIIFE = (() => {
168
206
  if (!effectiveWrapper && shouldCreateWrapper) {
169
207
  const doc = this.input.ownerDocument || document;
170
208
  const span = doc.createElement("span");
171
- span.className = "wulf-mask-wrapper";
209
+ span.className = "wulf-mask-wrapper wulf-mask-wrapper--auto";
172
210
  if (this.input.parentNode) {
173
211
  this.input.parentNode.insertBefore(span, this.input);
174
212
  }
@@ -198,21 +236,24 @@ var __WulfIIFE = (() => {
198
236
  const dataDisabled = this.hasAttr("data-disabled");
199
237
  const dataSelectAll = this.getAttr("data-mask-select-on-focus") === "true";
200
238
  const dataCopyRaw = this.getAttr("data-mask-copy-raw") === "true";
239
+ const dataSensitive = this.getAttr("data-mask-sensitive") === "true";
201
240
  const rawDataAlign = this.getAttr("data-mask-align") || this.getAttr("data-align");
202
241
  const dataAlign = rawDataAlign && VALID_ALIGNS.has(rawDataAlign) ? rawDataAlign : null;
203
242
  this.hadInitialDataAlign = this.wrapper.hasAttribute("data-align");
204
243
  const dataAudit = this.getAttr("data-mask-audit");
205
- const { disabled: optDisabled, align: optAlign, ...otherOptions } = options;
244
+ const { disabled: optDisabled, align: optAlign, sensitive: optSensitive, ...otherOptions } = options;
206
245
  const validOptAlign = optAlign && VALID_ALIGNS.has(optAlign) ? optAlign : void 0;
207
246
  const resolvedDisabled = optDisabled !== void 0 ? optDisabled : dataDisabled ? true : false;
208
247
  const resolvedAudit = options.audit ?? (dataAudit !== null ? dataAudit !== "false" : true);
209
- const isPassword = this.isPasswordInput();
248
+ const resolvedSensitive = Boolean(optSensitive ?? dataSensitive);
249
+ const isSensitive = this.isPasswordInput() || resolvedSensitive;
210
250
  this.options = {
211
251
  ...otherOptions,
212
252
  createWrapper: shouldCreateWrapper,
213
253
  showMaskOnFocus: options.showMaskOnFocus ?? dataFocusOnly ?? false,
214
254
  selectAllOnFocus: options.selectAllOnFocus ?? dataSelectAll ?? false,
215
- copyRaw: isPassword ? false : options.copyRaw ?? dataCopyRaw ?? false,
255
+ copyRaw: isSensitive ? false : options.copyRaw ?? dataCopyRaw ?? false,
256
+ sensitive: resolvedSensitive,
216
257
  disabled: resolvedDisabled,
217
258
  align: validOptAlign ?? (dataAlign || void 0),
218
259
  emitNativeInput: options.emitNativeInput ?? true,
@@ -267,7 +308,7 @@ var __WulfIIFE = (() => {
267
308
  this.input.addEventListener("blur", this.onBaseBlur, { signal });
268
309
  }
269
310
  onBaseCopy = (e) => {
270
- if (!this.options.copyRaw || this.options.disabled || this.input.type === "password") return;
311
+ if (!this.options.copyRaw || this.options.disabled || this.isSensitiveField()) return;
271
312
  const start = this.input.selectionStart ?? 0;
272
313
  const end = this.input.selectionEnd ?? start;
273
314
  let textToCopy = "";
@@ -287,6 +328,30 @@ var __WulfIIFE = (() => {
287
328
  extractRawSnippet(snippet) {
288
329
  return snippet;
289
330
  }
331
+ /**
332
+ * Extrait de manière compatible le texte brut du presse-papier lors d'un événement paste.
333
+ */
334
+ getClipboardPlainText(e) {
335
+ if (!e.clipboardData) return "";
336
+ return e.clipboardData.getData("text") || e.clipboardData.getData("text/plain") || "";
337
+ }
338
+ /**
339
+ * Applique l'hygiène Unicode O(N) puis le hook optionnel transformPaste de façon sécurisée et bornée.
340
+ */
341
+ preparePastedText(rawClipboard, maxLength = MAX_PASTE_LENGTH) {
342
+ const sanitized = sanitizePastedText(rawClipboard, maxLength);
343
+ if (typeof this.options.transformPaste !== "function") {
344
+ return sanitized;
345
+ }
346
+ try {
347
+ const transformed = this.options.transformPaste(sanitized);
348
+ if (typeof transformed === "string") {
349
+ return sanitizePastedText(transformed, maxLength);
350
+ }
351
+ } catch {
352
+ }
353
+ return sanitized;
354
+ }
290
355
  onBaseFocus = () => {
291
356
  this.isFocused = true;
292
357
  if (this.options.selectAllOnFocus && this.input.value.length > 0) {
@@ -295,7 +360,7 @@ var __WulfIIFE = (() => {
295
360
  }
296
361
  this.focusSelectTimerId = window.setTimeout(() => {
297
362
  this.focusSelectTimerId = null;
298
- if (!this.isDestroyed && document.activeElement === this.input) {
363
+ if (!this.isDestroyed && getDeepActiveElement(this.input.ownerDocument) === this.input) {
299
364
  this.input.select();
300
365
  }
301
366
  }, 0);
@@ -303,7 +368,7 @@ var __WulfIIFE = (() => {
303
368
  };
304
369
  onBaseBlur = () => {
305
370
  this.isFocused = false;
306
- if (this.isPasswordInput()) {
371
+ if (this.isSensitiveField()) {
307
372
  this.lastTrackedValue = "";
308
373
  this.clearGhost();
309
374
  this.wrapper.removeAttribute("data-mask");
@@ -330,11 +395,14 @@ var __WulfIIFE = (() => {
330
395
  "data-mask-strict",
331
396
  "data-mask-select-on-focus",
332
397
  "data-mask-copy-raw",
398
+ "data-mask-sensitive",
333
399
  "data-mask-pad-decimals",
334
400
  "data-mask-auto-lowercase",
335
401
  "data-mask-cycle-suggestions",
336
402
  "data-mask-default-tld",
337
403
  "data-mask-tlds",
404
+ "data-mask-format",
405
+ "data-mask-utc-indicator",
338
406
  "data-disabled",
339
407
  "data-mask-align",
340
408
  "data-align",
@@ -353,6 +421,12 @@ var __WulfIIFE = (() => {
353
421
  isPasswordInput() {
354
422
  return (this.input.type || "").toLowerCase() === "password";
355
423
  }
424
+ /**
425
+ * Indique si le champ relève du sanctuaire confidentiel (type="password" ou option sensitive: true).
426
+ */
427
+ isSensitiveField() {
428
+ return this.isPasswordInput() || Boolean(this.options.sensitive);
429
+ }
356
430
  /**
357
431
  * Calcule une empreinte non réversible pour détecter les changements sans conserver de secret en RAM.
358
432
  */
@@ -407,9 +481,19 @@ var __WulfIIFE = (() => {
407
481
  } else if (attrName === "data-mask-select-on-focus") {
408
482
  this.options.selectAllOnFocus = this.getAttr("data-mask-select-on-focus") === "true";
409
483
  } else if (attrName === "data-mask-copy-raw") {
410
- this.options.copyRaw = this.isPasswordInput() ? false : this.getAttr("data-mask-copy-raw") === "true";
484
+ this.options.copyRaw = this.isSensitiveField() ? false : this.getAttr("data-mask-copy-raw") === "true";
485
+ } else if (attrName === "data-mask-sensitive") {
486
+ const nextSensitive = this.getAttr("data-mask-sensitive") === "true";
487
+ this.options.sensitive = nextSensitive;
488
+ if (this.isSensitiveField()) {
489
+ this.options.copyRaw = false;
490
+ this.lastTrackedValue = "";
491
+ this.clearGhost();
492
+ this.wrapper.removeAttribute("data-mask");
493
+ this.onPasswordModeDetected();
494
+ }
411
495
  } else if (attrName === "type") {
412
- if (this.isPasswordInput()) {
496
+ if (this.isSensitiveField()) {
413
497
  this.options.copyRaw = false;
414
498
  this.lastTrackedValue = "";
415
499
  this.clearGhost();
@@ -460,6 +544,24 @@ var __WulfIIFE = (() => {
460
544
  this.ghost.style.pointerEvents = "none";
461
545
  }
462
546
  this.syncGhostStyles();
547
+ if (typeof ResizeObserver !== "undefined") {
548
+ this.resizeObserver?.disconnect();
549
+ this.resizeObserver = new ResizeObserver(() => {
550
+ if (!this.isDestroyed) {
551
+ this.syncGhostStyles();
552
+ }
553
+ });
554
+ this.resizeObserver.observe(this.input);
555
+ }
556
+ const docWithFonts = doc;
557
+ if (docWithFonts.fonts?.ready && typeof docWithFonts.fonts.ready.then === "function") {
558
+ docWithFonts.fonts.ready.then(() => {
559
+ if (!this.isDestroyed) {
560
+ this.syncGhostStyles();
561
+ }
562
+ }).catch(() => {
563
+ });
564
+ }
463
565
  }
464
566
  /**
465
567
  * Met à jour atomiquement le contenu du conteneur fantôme et synchronise .has-visible-ghost.
@@ -496,6 +598,10 @@ var __WulfIIFE = (() => {
496
598
  this.ghost.style.fontWeight = style.fontWeight;
497
599
  this.ghost.style.fontStyle = style.fontStyle;
498
600
  this.ghost.style.letterSpacing = style.letterSpacing;
601
+ this.ghost.style.wordSpacing = style.wordSpacing;
602
+ this.ghost.style.textIndent = style.textIndent;
603
+ this.ghost.style.fontKerning = style.fontKerning;
604
+ this.ghost.style.fontVariantNumeric = style.fontVariantNumeric;
499
605
  this.ghost.style.lineHeight = style.lineHeight;
500
606
  this.ghost.style.paddingTop = style.paddingTop;
501
607
  this.ghost.style.paddingBottom = style.paddingBottom;
@@ -547,11 +653,12 @@ var __WulfIIFE = (() => {
547
653
  if (this.options.emitNativeInput === false) return;
548
654
  this.isDispatchingNativeInput = true;
549
655
  try {
656
+ const isSensitive = this.isSensitiveField();
550
657
  const tracker = this.input._valueTracker;
551
- if (!this.isPasswordInput() && tracker && typeof tracker.setValue === "function") {
658
+ if (!isSensitive && tracker && typeof tracker.setValue === "function") {
552
659
  tracker.setValue(this.lastTrackedValue);
553
660
  }
554
- this.lastTrackedValue = this.isPasswordInput() ? "" : this.input.value;
661
+ this.lastTrackedValue = isSensitive ? "" : this.input.value;
555
662
  this.input.dispatchEvent(new Event("input", { bubbles: true, cancelable: false }));
556
663
  } finally {
557
664
  this.isDispatchingNativeInput = false;
@@ -669,6 +776,37 @@ var __WulfIIFE = (() => {
669
776
  getRawValue() {
670
777
  return this.input.value;
671
778
  }
779
+ /**
780
+ * Vérifie qu'un élément <label> possède un nom accessible non vide,
781
+ * en ignorant le texte éventuel des contrôles enfants (<input>, <select>, <textarea>, <button>).
782
+ */
783
+ hasAccessibleLabelText(labelEl) {
784
+ if (!labelEl) return false;
785
+ const ariaLabel = labelEl.getAttribute("aria-label")?.trim();
786
+ if (ariaLabel) return true;
787
+ const collectText = (node) => {
788
+ if (node.nodeType === 3) {
789
+ return node.textContent || "";
790
+ }
791
+ if (node.nodeType === 1) {
792
+ const el = node;
793
+ const tag = el.tagName;
794
+ if (tag === "INPUT" || tag === "SELECT" || tag === "TEXTAREA" || tag === "BUTTON") {
795
+ return "";
796
+ }
797
+ if (el.getAttribute("aria-hidden") === "true") {
798
+ return "";
799
+ }
800
+ let acc = "";
801
+ for (let i = 0; i < el.childNodes.length; i++) {
802
+ acc += collectText(el.childNodes[i]);
803
+ }
804
+ return acc;
805
+ }
806
+ return "";
807
+ };
808
+ return collectText(labelEl).trim().length > 0;
809
+ }
672
810
  /**
673
811
  * Vérifie la conformité d'accessibilité WAI-ARIA du champ de saisie (étiquetage, format attendu)
674
812
  * et retourne la liste des contraintes manquantes.
@@ -679,23 +817,39 @@ var __WulfIIFE = (() => {
679
817
  const root = typeof this.input.getRootNode === "function" ? this.input.getRootNode() : doc;
680
818
  const labelRoot = typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root : doc;
681
819
  const ariaLabel = this.input.getAttribute("aria-label")?.trim();
682
- const hasValidLabelledby = this.checkAriaIdReferences(this.input, "aria-labelledby", warnings);
683
- const hasWrappingLabel = Boolean(this.input.closest("label"));
684
- const hasNativeLabels = Boolean(this.input.labels && this.input.labels.length > 0);
820
+ const hasValidLabelledby = this.checkAriaIdReferences(this.input, "aria-labelledby", warnings, true);
821
+ const wrappingLabel = this.input.closest("label");
822
+ const hasWrappingLabel = this.hasAccessibleLabelText(wrappingLabel);
823
+ const hasNativeLabels = Boolean(
824
+ this.input.labels && Array.from(this.input.labels).some((lbl) => this.hasAccessibleLabelText(lbl))
825
+ );
685
826
  let hasExplicitLabelFor = false;
686
827
  if (this.input.id) {
687
828
  try {
688
- hasExplicitLabelFor = Boolean(labelRoot.querySelector(`label[for="${safeCssEscape(this.input.id)}"]`));
829
+ const explicitLabel = labelRoot.querySelector(`label[for="${safeCssEscape(this.input.id)}"]`);
830
+ hasExplicitLabelFor = this.hasAccessibleLabelText(explicitLabel);
689
831
  } catch {
690
832
  hasExplicitLabelFor = false;
691
833
  }
692
834
  }
693
835
  if (!ariaLabel && !hasValidLabelledby && !hasWrappingLabel && !hasNativeLabels && !hasExplicitLabelFor) {
694
836
  warnings.push(
695
- `\xC9tiquetage accessible manquant : associez un <label for="id"> (ou d\xE9finissez aria-label / aria-labelledby) sur l'input (WCAG 4.1.2).`
837
+ `\xC9tiquetage accessible manquant : associez un <label for="id"> non vide (ou d\xE9finissez aria-label / aria-labelledby) sur l'input (WCAG 4.1.2).`
696
838
  );
697
839
  }
698
- this.checkAriaIdReferences(this.input, "aria-describedby", warnings);
840
+ this.checkAriaIdReferences(this.input, "aria-describedby", warnings, true);
841
+ if (this.input.hasAttribute("aria-errormessage")) {
842
+ this.checkAriaIdReferences(this.input, "aria-errormessage", warnings, true);
843
+ }
844
+ const rawTabIndex = this.input.getAttribute("tabindex");
845
+ if (rawTabIndex !== null) {
846
+ const parsedTabIndex = Number.parseInt(rawTabIndex, 10);
847
+ if (Number.isFinite(parsedTabIndex) && parsedTabIndex > 0) {
848
+ warnings.push(
849
+ `Attribut tabindex="${rawTabIndex}" positif d\xE9tect\xE9 : \xE9vitez les tabindex > 0 qui perturbent l'ordre de tabulation naturel (WCAG 2.4.3).`
850
+ );
851
+ }
852
+ }
699
853
  const extraWarnings = this.getSpecificAuditWarnings();
700
854
  warnings.push(...extraWarnings);
701
855
  return warnings;
@@ -734,6 +888,10 @@ var __WulfIIFE = (() => {
734
888
  this.mutationObserver.disconnect();
735
889
  this.mutationObserver = null;
736
890
  }
891
+ if (this.resizeObserver) {
892
+ this.resizeObserver.disconnect();
893
+ this.resizeObserver = null;
894
+ }
737
895
  this.abortController.abort();
738
896
  this.lastTrackedValue = "";
739
897
  this.unhookValueProperty();
@@ -774,6 +932,7 @@ var __WulfIIFE = (() => {
774
932
  };
775
933
 
776
934
  // src/mask/MaskEngine.ts
935
+ var SEGMENT_SEPARATORS = /* @__PURE__ */ new Set(["/", "-", ".", ":"]);
777
936
  var DEFAULT_TOKENS = {
778
937
  "9": { pattern: /[0-9]/ },
779
938
  "a": { pattern: /[a-zA-Z]/ },
@@ -784,6 +943,8 @@ var __WulfIIFE = (() => {
784
943
  var MaskEngine = class _MaskEngine {
785
944
  pattern;
786
945
  patterns = [];
946
+ patternResolver = null;
947
+ lastResolvedKey = "";
787
948
  subEngines = [];
788
949
  activeEngine = null;
789
950
  placeholderChar;
@@ -820,7 +981,7 @@ var __WulfIIFE = (() => {
820
981
  * Fonction statique utilitaire permettant un formatage direct sans instanciation manuelle.
821
982
  *
822
983
  * @param value Valeur à formater (brute ou partiellement formatée)
823
- * @param pattern Masque à appliquer (ex: "99 99 99 99 99" ou tableau de masques)
984
+ * @param pattern Masque à appliquer (ex: "99 99 99 99 99", tableau de masques ou résolveur dynamique)
824
985
  * @param options Options facultatives (placeholderChar, tokens, strict, autoLowercase)
825
986
  * @returns La valeur formatée selon le masque
826
987
  */
@@ -830,17 +991,69 @@ var __WulfIIFE = (() => {
830
991
  return engine.format(value ?? "");
831
992
  }
832
993
  /**
833
- * Analyse le ou les gabarits statiques et compile la liste des slots.
994
+ * Indique si le gabarit repose sur une fonction résolveuse dynamique.
995
+ */
996
+ isDynamicPattern() {
997
+ return this.patternResolver !== null;
998
+ }
999
+ /**
1000
+ * Résout et compile si besoin le gabarit dynamique pour la valeur fournie (avec mémoïsation).
1001
+ */
1002
+ resolveForValue(input) {
1003
+ if (!this.patternResolver) return false;
1004
+ let resolved;
1005
+ try {
1006
+ resolved = this.patternResolver(String(input ?? "").slice(0, 4096));
1007
+ } catch {
1008
+ return false;
1009
+ }
1010
+ let normalized;
1011
+ let key;
1012
+ if (Array.isArray(resolved)) {
1013
+ normalized = resolved.slice(0, 32).map((p) => String(p ?? "").slice(0, 512));
1014
+ key = "A:" + normalized.join("\0");
1015
+ } else if (typeof resolved === "string") {
1016
+ normalized = resolved.slice(0, 512);
1017
+ key = "S:" + normalized;
1018
+ } else {
1019
+ return false;
1020
+ }
1021
+ if (key === this.lastResolvedKey) {
1022
+ return false;
1023
+ }
1024
+ this.lastResolvedKey = key;
1025
+ this.compileStatic(normalized);
1026
+ return true;
1027
+ }
1028
+ /**
1029
+ * Analyse le ou les gabarits (statiques ou résolus dynamiquement) et compile la liste des slots.
834
1030
  */
835
1031
  compile(newPattern) {
1032
+ if (typeof newPattern === "function") {
1033
+ this.patternResolver = newPattern;
1034
+ this.lastResolvedKey = "";
1035
+ this.resolveForValue("");
1036
+ return this.slots;
1037
+ }
836
1038
  if (newPattern !== void 0) {
837
- if (Array.isArray(newPattern)) {
838
- this.patterns = newPattern.slice(0, 32).map((p) => String(p ?? "").slice(0, 512));
839
- this.pattern = this.patterns[0] || "";
840
- } else {
841
- this.patterns = [];
842
- this.pattern = String(newPattern ?? "").slice(0, 512);
843
- }
1039
+ this.patternResolver = null;
1040
+ this.lastResolvedKey = "";
1041
+ return this.compileStatic(newPattern);
1042
+ }
1043
+ if (this.patternResolver) {
1044
+ this.lastResolvedKey = "";
1045
+ this.resolveForValue("");
1046
+ return this.slots;
1047
+ }
1048
+ return this.compileStatic(this.patterns.length > 0 ? this.patterns : this.pattern);
1049
+ }
1050
+ compileStatic(newPattern) {
1051
+ if (Array.isArray(newPattern)) {
1052
+ this.patterns = newPattern.slice(0, 32).map((p) => String(p ?? "").slice(0, 512));
1053
+ this.pattern = this.patterns[0] || "";
1054
+ } else {
1055
+ this.patterns = [];
1056
+ this.pattern = String(newPattern ?? "").slice(0, 512);
844
1057
  }
845
1058
  if (this.patterns.length > 0) {
846
1059
  this.subEngines = this.patterns.map((p) => new _MaskEngine(p, {
@@ -872,14 +1085,15 @@ var __WulfIIFE = (() => {
872
1085
  const token = !isEscaped && Object.hasOwn(this.tokens, char) ? this.tokens[char] : void 0;
873
1086
  if (token) {
874
1087
  isPrefixMode = false;
1088
+ const slotPlaceholder = token.placeholder ? Array.from(String(token.placeholder))[0] || this.placeholderChar : this.placeholderChar;
875
1089
  this.slots.push({
876
1090
  char,
877
1091
  isStatic: false,
878
1092
  isPrefix: false,
879
1093
  token,
880
- placeholder: this.placeholderChar
1094
+ placeholder: slotPlaceholder
881
1095
  });
882
- templateBuilder += this.placeholderChar;
1096
+ templateBuilder += slotPlaceholder;
883
1097
  } else {
884
1098
  this.slots.push({
885
1099
  char,
@@ -947,13 +1161,29 @@ var __WulfIIFE = (() => {
947
1161
  return this.activeEngine ? this.activeEngine.getFullMaskTemplate() : this.fullMaskTemplate;
948
1162
  }
949
1163
  /**
950
- * Nombre total de positions éditables dans le masque.
1164
+ * Nombre total de positions éditables du sous-moteur actif (pour isComplete et detail.totalSlots).
951
1165
  */
952
- getEditableCount() {
1166
+ getActiveEditableCount() {
1167
+ if (this.subEngines.length > 0) {
1168
+ const target = this.activeEngine ?? this.subEngines[0];
1169
+ return target.getActiveEditableCount();
1170
+ }
1171
+ return this.activeEngine ? this.activeEngine.getActiveEditableCount() : this.slots.filter((s) => !s.isStatic).length;
1172
+ }
1173
+ /**
1174
+ * Capacité maximale de positions éditables parmi les gabarits configurés (pour le blocage de frappe / collage).
1175
+ */
1176
+ getMaxEditableCount() {
953
1177
  if (this.subEngines.length > 0) {
954
- return Math.max(...this.subEngines.map((e) => e.getEditableCount()));
1178
+ return Math.max(...this.subEngines.map((e) => e.getMaxEditableCount()));
955
1179
  }
956
- return this.activeEngine ? this.activeEngine.getEditableCount() : this.slots.filter((s) => !s.isStatic).length;
1180
+ return this.getActiveEditableCount();
1181
+ }
1182
+ /**
1183
+ * Capacité maximale totale de positions éditables dans le masque (alias rétrocompatible de getMaxEditableCount).
1184
+ */
1185
+ getEditableCount() {
1186
+ return this.getMaxEditableCount();
957
1187
  }
958
1188
  /**
959
1189
  * Indique si tous les emplacements éditables du masque acceptent exclusivement des chiffres numériques.
@@ -991,15 +1221,199 @@ var __WulfIIFE = (() => {
991
1221
  isStrict() {
992
1222
  return this.strict;
993
1223
  }
1224
+ /**
1225
+ * Normalise une chaîne issue du presse-papier en alignant et complétant à gauche par '0'
1226
+ * les segments numériques courts lorsque la structure correspond sans ambiguïté au gabarit.
1227
+ * N'altère jamais extractRaw() ni la saisie clavier.
1228
+ */
1229
+ normalizePastedValue(pasted) {
1230
+ const rawPasted = String(pasted ?? "");
1231
+ if (!rawPasted) return rawPasted;
1232
+ this.resolveForValue(rawPasted);
1233
+ if (this.subEngines.length > 0) {
1234
+ const lowerPasted = rawPasted.toLowerCase();
1235
+ const withMatchingPrefix = this.subEngines.filter((e) => {
1236
+ const p = e.getPrefix();
1237
+ return p.length > 0 && lowerPasted.startsWith(p.trim().toLowerCase());
1238
+ });
1239
+ const candidates = withMatchingPrefix.length > 0 ? withMatchingPrefix : this.subEngines;
1240
+ let firstMatch = null;
1241
+ for (const eng of candidates) {
1242
+ const res = eng.tryNormalizeSegments(rawPasted);
1243
+ if (res.matched) {
1244
+ if (res.exactSegmentCount) {
1245
+ return res.normalized;
1246
+ }
1247
+ if (firstMatch === null) {
1248
+ firstMatch = res.normalized;
1249
+ }
1250
+ }
1251
+ }
1252
+ return firstMatch !== null ? firstMatch : rawPasted;
1253
+ }
1254
+ return this.tryNormalizeSegments(rawPasted).normalized;
1255
+ }
1256
+ tryNormalizeSegments(pasted) {
1257
+ const fail = { matched: false, normalized: pasted, exactSegmentCount: false };
1258
+ if (!this.strict || this.slots.length === 0 || !pasted) {
1259
+ return fail;
1260
+ }
1261
+ let rest = pasted;
1262
+ if (this.prefixSlotsCount > 0) {
1263
+ let inputIdx = 0;
1264
+ while (inputIdx < pasted.length && (pasted[inputIdx] === " " || pasted[inputIdx] === " ")) {
1265
+ inputIdx++;
1266
+ }
1267
+ let pIdx = 0;
1268
+ while (inputIdx < pasted.length && pIdx < this.prefixSlotsCount) {
1269
+ const pChar = this.slots[pIdx].char;
1270
+ const inChar = pasted[inputIdx];
1271
+ if (inChar.toUpperCase() === pChar.toUpperCase()) {
1272
+ inputIdx++;
1273
+ pIdx++;
1274
+ } else if (pChar === " " && inChar !== " ") {
1275
+ pIdx++;
1276
+ } else {
1277
+ break;
1278
+ }
1279
+ }
1280
+ if (pIdx === this.prefixSlotsCount) {
1281
+ rest = pasted.slice(inputIdx);
1282
+ }
1283
+ }
1284
+ if (!rest) {
1285
+ return fail;
1286
+ }
1287
+ const segments = [];
1288
+ const separators = [];
1289
+ let currentSeg = [];
1290
+ let currentSep = "";
1291
+ let hasTrailingStatic = false;
1292
+ for (let i = this.prefixSlotsCount; i < this.slots.length; i++) {
1293
+ const slot = this.slots[i];
1294
+ if (slot.isStatic) {
1295
+ if (currentSeg.length > 0) {
1296
+ segments.push(currentSeg);
1297
+ currentSeg = [];
1298
+ currentSep = slot.char;
1299
+ } else {
1300
+ currentSep += slot.char;
1301
+ }
1302
+ } else {
1303
+ if (currentSep.length > 0) {
1304
+ separators.push(currentSep);
1305
+ currentSep = "";
1306
+ }
1307
+ currentSeg.push(slot);
1308
+ }
1309
+ }
1310
+ if (currentSeg.length > 0) {
1311
+ segments.push(currentSeg);
1312
+ } else if (currentSep.length > 0) {
1313
+ hasTrailingStatic = true;
1314
+ }
1315
+ if (hasTrailingStatic || segments.length < 2 || separators.length !== segments.length - 1) {
1316
+ return fail;
1317
+ }
1318
+ const coreSeps = [];
1319
+ for (const sep of separators) {
1320
+ const core = sep.trim();
1321
+ if (core.length !== 1 || !SEGMENT_SEPARATORS.has(core)) {
1322
+ return fail;
1323
+ }
1324
+ coreSeps.push(core);
1325
+ }
1326
+ const parts = [];
1327
+ const foundSeps = [];
1328
+ let blockStart = 0;
1329
+ for (let i = 0; i < rest.length; i++) {
1330
+ const ch = rest[i];
1331
+ if (SEGMENT_SEPARATORS.has(ch)) {
1332
+ parts.push(rest.slice(blockStart, i).trim());
1333
+ foundSeps.push(ch);
1334
+ blockStart = i + 1;
1335
+ }
1336
+ }
1337
+ parts.push(rest.slice(blockStart).trim());
1338
+ if (foundSeps.length === 0 || foundSeps.length > coreSeps.length) {
1339
+ return fail;
1340
+ }
1341
+ if (parts.length !== foundSeps.length + 1 || parts.length > segments.length || parts.some((p) => p.length === 0)) {
1342
+ return fail;
1343
+ }
1344
+ const matchesMaskOrder = foundSeps.every((sep, idx) => sep === coreSeps[idx]);
1345
+ const isHomogeneous = foundSeps.every((sep) => sep === foundSeps[0]);
1346
+ if (!matchesMaskOrder && !isHomogeneous) {
1347
+ return fail;
1348
+ }
1349
+ const exactSegmentCount = parts.length === segments.length;
1350
+ const paddedParts = [];
1351
+ for (let i = 0; i < parts.length; i++) {
1352
+ const part = parts[i];
1353
+ const segSlots = segments[i];
1354
+ if (part.length > segSlots.length) {
1355
+ return fail;
1356
+ }
1357
+ const isNumericSeg = segSlots.every(
1358
+ (s) => Boolean(s.token && s.token.pattern.test("0") && !s.token.pattern.test("a") && !s.token.pattern.test("Z"))
1359
+ );
1360
+ if (isNumericSeg) {
1361
+ const isClosedBySep = i < parts.length - 1;
1362
+ const isTerminalTwoDigitEligible = i === parts.length - 1 && exactSegmentCount && segments.length <= 3 && segSlots.length === 2;
1363
+ const shouldPad = part.length < segSlots.length && (isClosedBySep || isTerminalTwoDigitEligible);
1364
+ const offset = shouldPad ? segSlots.length - part.length : 0;
1365
+ for (let k = 0; k < part.length; k++) {
1366
+ const ch = part[k];
1367
+ if (ch < "0" || ch > "9" || !segSlots[offset + k].token.pattern.test(ch)) {
1368
+ return fail;
1369
+ }
1370
+ }
1371
+ paddedParts.push(shouldPad ? "0".repeat(segSlots.length - part.length) + part : part);
1372
+ } else {
1373
+ if (part.length !== segSlots.length) {
1374
+ return fail;
1375
+ }
1376
+ for (let k = 0; k < part.length; k++) {
1377
+ if (!segSlots[k].token || !segSlots[k].token.pattern.test(part[k])) {
1378
+ return fail;
1379
+ }
1380
+ }
1381
+ paddedParts.push(part);
1382
+ }
1383
+ }
1384
+ let normalized = this.prefixSlotsCount > 0 ? this.prefixString : "";
1385
+ for (let i = 0; i < paddedParts.length; i++) {
1386
+ if (i > 0) {
1387
+ normalized += separators[i - 1];
1388
+ }
1389
+ normalized += paddedParts[i];
1390
+ }
1391
+ return {
1392
+ matched: true,
1393
+ normalized,
1394
+ exactSegmentCount
1395
+ };
1396
+ }
1397
+ /**
1398
+ * Filtre et extrait les caractères éditables sans déclencher de ré-évaluation dynamique du gabarit.
1399
+ * Utile pour mesurer une sélection partielle ou mapper le curseur sans effet de bord.
1400
+ */
1401
+ extractRawForCurrentPattern(input) {
1402
+ return this.extractRawInternal(input);
1403
+ }
994
1404
  /**
995
1405
  * Filtre et extrait uniquement les caractères éditables valides d'une chaîne.
996
1406
  * Gère intelligemment la présence ou l'absence des séparateurs statiques et du préfixe.
997
1407
  */
998
1408
  extractRaw(input) {
1409
+ this.resolveForValue(input);
1410
+ return this.extractRawInternal(input);
1411
+ }
1412
+ extractRawInternal(input) {
999
1413
  if (this.subEngines.length > 0) {
1000
1414
  const engine = this.selectEngine(input);
1001
1415
  if (engine !== this) {
1002
- return engine.extractRaw(input);
1416
+ return engine.extractRawInternal(input);
1003
1417
  }
1004
1418
  }
1005
1419
  const maxInputLen = Math.max(4096, this.slots.length * 4);
@@ -1066,6 +1480,7 @@ var __WulfIIFE = (() => {
1066
1480
  * Si aucune donnée éditable n'est présente, retourne le préfixe statique fixe s'il existe.
1067
1481
  */
1068
1482
  format(rawValue) {
1483
+ this.resolveForValue(rawValue);
1069
1484
  if (this.subEngines.length > 0) {
1070
1485
  const engine = this.selectEngine(rawValue);
1071
1486
  if (engine !== this) {
@@ -1075,7 +1490,7 @@ var __WulfIIFE = (() => {
1075
1490
  const maxInputLen = Math.max(4096, this.slots.length * 4);
1076
1491
  const rawStr = String(rawValue ?? "").slice(0, maxInputLen);
1077
1492
  if (!this.slots.length) return rawStr;
1078
- const cleanRaw = this.extractRaw(rawStr);
1493
+ const cleanRaw = this.extractRawInternal(rawStr);
1079
1494
  if (cleanRaw.length === 0) {
1080
1495
  return this.prefixString;
1081
1496
  }
@@ -1137,7 +1552,7 @@ var __WulfIIFE = (() => {
1137
1552
  const safeInput = String(inputValue ?? "");
1138
1553
  const safeFormatted = String(formatted ?? "");
1139
1554
  if (inputCursor <= 0 || !safeFormatted) return minPos;
1140
- const rawBeforeCursor = this.extractRaw(safeInput.slice(0, inputCursor));
1555
+ const rawBeforeCursor = this.extractRawInternal(safeInput.slice(0, inputCursor));
1141
1556
  const targetRawCount = rawBeforeCursor.length;
1142
1557
  if (targetRawCount === 0) {
1143
1558
  return Math.max(minPos, Math.min(this.getNextEditablePosition(0), safeFormatted.length));
@@ -1320,10 +1735,25 @@ var __WulfIIFE = (() => {
1320
1735
  if (isPrintableChar && !hasSelection) {
1321
1736
  const slots = engine.getSlots();
1322
1737
  const isAlreadyOnSep = cursor < slots.length && slots[cursor].isStatic && slots[cursor].char === e.key;
1323
- const isJustAfterSep = cursor > 0 && cursor - 1 < slots.length && slots[cursor - 1].isStatic && slots[cursor - 1].char === e.key;
1738
+ let justAfterSepIdx = -1;
1739
+ if (cursor > 0 && cursor - 1 < slots.length) {
1740
+ if (slots[cursor - 1].isStatic && slots[cursor - 1].char === e.key) {
1741
+ justAfterSepIdx = cursor - 1;
1742
+ } else {
1743
+ let k = cursor - 1;
1744
+ while (k >= minPos && slots[k].isStatic) {
1745
+ if (slots[k].char === e.key) {
1746
+ justAfterSepIdx = k;
1747
+ break;
1748
+ }
1749
+ k--;
1750
+ }
1751
+ }
1752
+ }
1753
+ const isJustAfterSep = justAfterSepIdx !== -1;
1324
1754
  if (isAlreadyOnSep || isJustAfterSep) {
1325
1755
  e.preventDefault();
1326
- const baseIdx = isAlreadyOnSep ? cursor : cursor - 1;
1756
+ const baseIdx = isAlreadyOnSep ? cursor : justAfterSepIdx;
1327
1757
  const nextEditable = engine.getNextEditablePosition(baseIdx + 1);
1328
1758
  this.delegate.applyMask(input.value, nextEditable, true);
1329
1759
  return;
@@ -1346,7 +1776,7 @@ var __WulfIIFE = (() => {
1346
1776
  segStart++;
1347
1777
  const segLength = nextSepIdx - segStart;
1348
1778
  const currentSegVal = input.value.slice(segStart, cursor);
1349
- const isNumericSegment = slots.slice(segStart, nextSepIdx).every((s) => !s.token || s.token.pattern.test("0"));
1779
+ const isNumericSegment = slots.slice(segStart, nextSepIdx).every((s) => Boolean(s.token && s.token.pattern.test("0") && !s.token.pattern.test("a") && !s.token.pattern.test("Z")));
1350
1780
  if (isNumericSegment && segLength > currentSegVal.length && currentSegVal.length > 0) {
1351
1781
  const missingCount = segLength - currentSegVal.length;
1352
1782
  const paddedSeg = "0".repeat(missingCount) + currentSegVal;
@@ -1362,19 +1792,27 @@ var __WulfIIFE = (() => {
1362
1792
  }
1363
1793
  }
1364
1794
  if (isPrintableChar && engine.isStrict()) {
1365
- const totalSlots = engine.getEditableCount();
1795
+ const isDynamic = engine.isDynamicPattern();
1796
+ const currentRaw = engine.extractRaw(input.value);
1797
+ const selectedRaw = selectionEnd > cursor ? engine.extractRawForCurrentPattern(input.value.slice(cursor, selectionEnd)) : "";
1798
+ if (isDynamic) {
1799
+ const candidate = input.value.slice(0, cursor) + e.key + input.value.slice(selectionEnd);
1800
+ engine.resolveForValue(candidate);
1801
+ }
1802
+ const totalSlots = engine.getMaxEditableCount();
1366
1803
  if (totalSlots > 0) {
1367
- const currentRaw = engine.extractRaw(input.value);
1368
- let availableCapacity = totalSlots - currentRaw.length;
1369
- if (selectionEnd > cursor) {
1370
- const selectedRaw = engine.extractRaw(input.value.slice(cursor, selectionEnd));
1371
- availableCapacity = totalSlots - (currentRaw.length - selectedRaw.length);
1372
- }
1804
+ const availableCapacity = totalSlots - (currentRaw.length - selectedRaw.length);
1373
1805
  if (availableCapacity <= 0) {
1806
+ if (isDynamic) {
1807
+ engine.resolveForValue(input.value);
1808
+ }
1374
1809
  e.preventDefault();
1375
1810
  return;
1376
1811
  }
1377
1812
  }
1813
+ if (isDynamic) {
1814
+ engine.resolveForValue(input.value);
1815
+ }
1378
1816
  }
1379
1817
  if (selectionEnd > cursor) {
1380
1818
  if (e.key === "Backspace" || e.key === "Delete") {
@@ -1513,6 +1951,7 @@ var __WulfIIFE = (() => {
1513
1951
  cutTimerId = null;
1514
1952
  pasteTimerId = null;
1515
1953
  resetTimerId = null;
1954
+ lastInputType = "";
1516
1955
  constructor(targetOrWrapper, inputOrOptions, options) {
1517
1956
  const args = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, options);
1518
1957
  const wrap = args.wrapper;
@@ -1563,20 +2002,26 @@ var __WulfIIFE = (() => {
1563
2002
  enforceMinCursor: () => this.enforceMinCursor()
1564
2003
  });
1565
2004
  this.bindEvents();
1566
- this.lastValue = this.isPasswordInput() ? this.computePasswordDigest(this.input.value) : this.input.value;
2005
+ this.lastValue = this.isSensitiveField() ? this.computePasswordDigest(this.input.value) : this.input.value;
1567
2006
  this.syncInitialValue();
1568
2007
  this.runAuditWarning(this.options.audit);
1569
2008
  }
1570
2009
  getSpecificAuditWarnings() {
1571
2010
  const warnings = [];
1572
2011
  const describedbyWarnings = [];
1573
- const hasValidDescribedby = this.checkAriaIdReferences(this.input, "aria-describedby", describedbyWarnings);
2012
+ const hasValidDescribedby = this.checkAriaIdReferences(this.input, "aria-describedby", describedbyWarnings, true);
1574
2013
  const hasPlaceholder = Boolean(this.input.getAttribute("placeholder")?.trim());
1575
2014
  const hasAriaPlaceholder = Boolean(this.input.getAttribute("aria-placeholder")?.trim());
1576
- if (!hasValidDescribedby && !hasPlaceholder && !hasAriaPlaceholder && !this.options.disabled) {
1577
- warnings.push(
1578
- "Indication du format attendu manquante : d\xE9finissez aria-describedby, placeholder ou aria-placeholder pour informer les technologies d'assistance (WCAG 3.3.2)."
1579
- );
2015
+ if (!hasValidDescribedby && !hasAriaPlaceholder && !this.options.disabled) {
2016
+ if (hasPlaceholder) {
2017
+ warnings.push(
2018
+ "Indication du format attendu fragile : l'attribut placeholder seul dispara\xEEt \xE0 la saisie et est masqu\xE9 par le gabarit fant\xF4me ; utilisez aria-describedby ou aria-placeholder (WCAG 3.3.2)."
2019
+ );
2020
+ } else {
2021
+ warnings.push(
2022
+ "Indication du format attendu manquante : d\xE9finissez aria-describedby ou aria-placeholder pour informer les technologies d'assistance (WCAG 3.3.2)."
2023
+ );
2024
+ }
1580
2025
  }
1581
2026
  return warnings;
1582
2027
  }
@@ -1595,7 +2040,7 @@ var __WulfIIFE = (() => {
1595
2040
  * Formate statiquement une valeur selon un masque donné sans nécessiter d'élément DOM.
1596
2041
  *
1597
2042
  * @param value Valeur à formater (ex: "0123456789")
1598
- * @param mask Gabarit de masque (ex: "99 99 99 99 99")
2043
+ * @param mask Gabarit de masque (ex: "99 99 99 99 99", tableau ou résolveur dynamique)
1599
2044
  * @param options Options facultatives du masque (tokens, placeholderChar, strict, etc.)
1600
2045
  * @returns Valeur formatée (ex: "01 23 45 67 89")
1601
2046
  */
@@ -1606,7 +2051,8 @@ var __WulfIIFE = (() => {
1606
2051
  if (this.options.disabled) {
1607
2052
  this.checkValueChange();
1608
2053
  } else {
1609
- this.applyMask(strVal, strVal.length);
2054
+ const transformed = this.applyTransformInput(strVal, "programmatic", "");
2055
+ this.applyMask(transformed, transformed.length);
1610
2056
  }
1611
2057
  }
1612
2058
  onDisabledChange(disabled) {
@@ -1783,10 +2229,13 @@ var __WulfIIFE = (() => {
1783
2229
  super.handleAttributeMutation(attrName);
1784
2230
  if (attrName === "data-mask") {
1785
2231
  const rawAttr = this.getAttr("data-mask");
2232
+ if (rawAttr === null && (this.isSensitiveField() || typeof this.options.mask === "function")) {
2233
+ return;
2234
+ }
1786
2235
  if (rawAttr === this.lastInternalRemainingMask) {
1787
2236
  return;
1788
2237
  }
1789
- const currentMaskStr = Array.isArray(this.options.mask) ? this.options.mask.join("|") : this.options.mask || "";
2238
+ const currentMaskStr = typeof this.options.mask === "function" ? "" : Array.isArray(this.options.mask) ? this.options.mask.join("|") : this.options.mask || "";
1790
2239
  if (rawAttr === currentMaskStr) {
1791
2240
  return;
1792
2241
  }
@@ -1808,6 +2257,19 @@ var __WulfIIFE = (() => {
1808
2257
  this.updateGhost(this.input.value);
1809
2258
  }
1810
2259
  }
2260
+ applyTransformInput(value, source, inputType) {
2261
+ if (typeof this.options.transformInput !== "function") {
2262
+ return value;
2263
+ }
2264
+ try {
2265
+ const res = this.options.transformInput(value, { source, inputType });
2266
+ if (typeof res === "string") {
2267
+ return source === "paste" ? sanitizePastedText(res, 4096) : stripBidiAndInvisibles(res, 4096);
2268
+ }
2269
+ } catch {
2270
+ }
2271
+ return value;
2272
+ }
1811
2273
  /**
1812
2274
  * Affecte une nouvelle valeur manuellement (formatée ou brute).
1813
2275
  */
@@ -1818,7 +2280,8 @@ var __WulfIIFE = (() => {
1818
2280
  this.checkValueChange();
1819
2281
  return;
1820
2282
  }
1821
- this.applyMask(safeVal, safeVal.length);
2283
+ const transformed = this.applyTransformInput(safeVal, "programmatic", "");
2284
+ this.applyMask(transformed, transformed.length);
1822
2285
  }
1823
2286
  /**
1824
2287
  * Retourne la valeur brute sans séparateurs.
@@ -1827,12 +2290,14 @@ var __WulfIIFE = (() => {
1827
2290
  return this.engine.extractRaw(this.input.value);
1828
2291
  }
1829
2292
  /**
1830
- * Indique si tous les emplacements éditables sont renseignés.
2293
+ * Indique si tous les emplacements éditables du gabarit actif sont renseignés.
1831
2294
  */
1832
2295
  isComplete() {
1833
2296
  if (this.options.disabled) return true;
1834
2297
  const raw = this.getRawValue();
1835
- return raw.length >= this.engine.getEditableCount();
2298
+ const activeSlots = this.engine.getActiveEditableCount();
2299
+ if (activeSlots === 0) return true;
2300
+ return raw.length >= activeSlots;
1836
2301
  }
1837
2302
  /**
1838
2303
  * Callback d'écoute directe ou getter/setter pour onInput.
@@ -1878,32 +2343,45 @@ var __WulfIIFE = (() => {
1878
2343
  this.wrapper.classList.toggle("has-selection", hasSelection);
1879
2344
  }
1880
2345
  onBeforeInput(e) {
2346
+ this.lastInputType = e.inputType || "";
1881
2347
  if (this.options.disabled) return;
1882
2348
  if (this.isComposing) return;
1883
2349
  if (!this.engine.isStrict()) return;
1884
2350
  if (e.inputType === "insertFromPaste" || e.inputType === "insertReplacementText") return;
1885
2351
  if (e.inputType && e.inputType.startsWith("insert")) {
1886
- const totalSlots = this.engine.getEditableCount();
2352
+ const currentVal = this.input.value;
2353
+ const isDynamic = this.engine.isDynamicPattern();
2354
+ const currentRaw = this.engine.extractRaw(currentVal);
2355
+ const start = this.input.selectionStart ?? 0;
2356
+ const end = this.input.selectionEnd ?? start;
2357
+ const selectedRaw = end > start ? this.engine.extractRawForCurrentPattern(currentVal.slice(start, end)) : "";
2358
+ if (isDynamic) {
2359
+ const candidate = currentVal.slice(0, start) + (e.data ?? "") + currentVal.slice(end);
2360
+ this.engine.resolveForValue(candidate);
2361
+ }
2362
+ const totalSlots = this.engine.getMaxEditableCount();
1887
2363
  if (totalSlots > 0) {
1888
- const currentRaw = this.getRawValue();
1889
- const start = this.input.selectionStart ?? 0;
1890
- const end = this.input.selectionEnd ?? start;
1891
- let availableCapacity = Math.max(0, totalSlots - currentRaw.length);
1892
- if (end > start) {
1893
- const selectedRaw = this.engine.extractRaw(this.input.value.slice(start, end));
1894
- availableCapacity = Math.max(0, totalSlots - (currentRaw.length - selectedRaw.length));
1895
- }
2364
+ const availableCapacity = Math.max(0, totalSlots - (currentRaw.length - selectedRaw.length));
1896
2365
  if (availableCapacity <= 0) {
2366
+ if (isDynamic) {
2367
+ this.engine.resolveForValue(currentVal);
2368
+ }
1897
2369
  e.preventDefault();
2370
+ return;
1898
2371
  }
1899
2372
  }
2373
+ if (isDynamic) {
2374
+ this.engine.resolveForValue(currentVal);
2375
+ }
1900
2376
  }
1901
2377
  }
1902
2378
  handleInput(e) {
1903
2379
  if (this.isDispatchingNativeInput) return;
1904
2380
  if (this.isComposing) return;
2381
+ const inputType = e?.inputType || this.lastInputType || "";
2382
+ this.lastInputType = "";
1905
2383
  const hasOnInput = Boolean(this.options.onInput || this.options.oninput);
1906
- const currentComparison = this.isPasswordInput() ? this.computePasswordDigest(this.input.value) : this.input.value;
2384
+ const currentComparison = this.isSensitiveField() ? this.computePasswordDigest(this.input.value) : this.input.value;
1907
2385
  if (hasOnInput && currentComparison !== this.lastValue) {
1908
2386
  this.checkValueChange();
1909
2387
  }
@@ -1911,17 +2389,20 @@ var __WulfIIFE = (() => {
1911
2389
  this.checkValueChange();
1912
2390
  return;
1913
2391
  }
2392
+ const rawInputVal = this.input.value;
2393
+ const oldCursor = this.input.selectionStart ?? rawInputVal.length;
2394
+ const transformedVal = this.applyTransformInput(rawInputVal, "input", inputType);
2395
+ const effectiveCursor = transformedVal !== rawInputVal ? oldCursor >= rawInputVal.length ? transformedVal.length : Math.min(oldCursor, transformedVal.length) : oldCursor;
1914
2396
  const prevState = this.history.getCurrent();
1915
- const totalSlots = this.engine.getEditableCount();
2397
+ const newRaw = this.engine.extractRaw(transformedVal);
2398
+ const totalSlots = this.engine.getMaxEditableCount();
1916
2399
  if (totalSlots > 0 && this.engine.isStrict() && prevState && prevState.raw.length >= totalSlots) {
1917
- const newRaw = this.engine.extractRaw(this.input.value);
1918
2400
  if (newRaw.length > totalSlots) {
1919
2401
  this.applyMask(prevState.raw, prevState.cursor);
1920
2402
  return;
1921
2403
  }
1922
2404
  }
1923
- const oldCursor = this.input.selectionStart ?? this.input.value.length;
1924
- this.applyMask(this.input.value, oldCursor);
2405
+ this.applyMask(transformedVal, effectiveCursor);
1925
2406
  this.checkSelection();
1926
2407
  }
1927
2408
  onKeyDown(e) {
@@ -1946,15 +2427,15 @@ var __WulfIIFE = (() => {
1946
2427
  }
1947
2428
  e.preventDefault();
1948
2429
  this.history.updateCurrentCursor(this.input.selectionStart ?? 0);
1949
- const rawPasted = (e.clipboardData?.getData("text") || "").slice(0, 4096);
1950
- const pastedText = rawPasted.trim();
2430
+ const preparedText = this.preparePastedText(this.getClipboardPlainText(e), 4096);
2431
+ const pastedText = this.applyTransformInput(preparedText, "paste", "insertFromPaste");
1951
2432
  if (!pastedText) return;
1952
2433
  const minPos = this.engine.getPrefixLength();
1953
2434
  const selStart = this.input.selectionStart ?? 0;
1954
2435
  const selEnd = this.input.selectionEnd ?? selStart;
1955
2436
  const currentVal = this.input.value;
1956
- const totalSlots = this.engine.getEditableCount();
1957
2437
  const currentRaw = this.getRawValue();
2438
+ const totalSlots = this.engine.getMaxEditableCount();
1958
2439
  const prefix = this.engine.getPrefix();
1959
2440
  const cleanPrefix = prefix.replace(/[\s.-]+/g, "").toUpperCase();
1960
2441
  const cleanPasted = pastedText.replace(/[\s.-]+/g, "").toUpperCase();
@@ -1969,17 +2450,38 @@ var __WulfIIFE = (() => {
1969
2450
  }
1970
2451
  let availableCapacity = Math.max(0, totalSlots - currentRaw.length);
1971
2452
  if (effectiveStart !== effectiveEnd) {
1972
- const selectedRaw = this.engine.extractRaw(currentVal.slice(effectiveStart, effectiveEnd));
2453
+ const selectedRaw = this.engine.extractRawForCurrentPattern(currentVal.slice(effectiveStart, effectiveEnd));
1973
2454
  availableCapacity = Math.max(0, totalSlots - (currentRaw.length - selectedRaw.length));
1974
2455
  }
1975
- if (this.engine.isStrict() && availableCapacity <= 0) {
1976
- return;
2456
+ const normalizedPasted = this.engine.normalizePastedValue(pastedText);
2457
+ const activeSlots = this.engine.getActiveEditableCount();
2458
+ const isCurrentComplete = activeSlots > 0 && currentRaw.length >= activeSlots;
2459
+ if (this.engine.isStrict() && (availableCapacity <= 0 || selStart === selEnd && isCurrentComplete)) {
2460
+ const pastedRawLen = this.engine.extractRaw(normalizedPasted).length;
2461
+ const targetMaxSlots = this.engine.getMaxEditableCount();
2462
+ if (selStart === selEnd && targetMaxSlots > 0 && pastedRawLen === targetMaxSlots && (availableCapacity <= 0 || pastedRawLen > availableCapacity)) {
2463
+ effectiveStart = 0;
2464
+ effectiveEnd = currentVal.length;
2465
+ } else if (availableCapacity <= 0) {
2466
+ this.engine.resolveForValue(currentVal);
2467
+ return;
2468
+ } else {
2469
+ this.engine.resolveForValue(currentVal);
2470
+ }
1977
2471
  }
1978
2472
  let combined;
1979
2473
  let newCursorPos;
1980
2474
  if (effectiveStart === 0 && effectiveEnd === currentVal.length) {
1981
- combined = pastedText;
1982
- newCursorPos = pastedText.length;
2475
+ combined = normalizedPasted;
2476
+ newCursorPos = normalizedPasted.length;
2477
+ } else if (currentRaw.length === 0 && effectiveStart === minPos && effectiveEnd === currentVal.length) {
2478
+ if (minPos > 0 && normalizedPasted.toUpperCase().startsWith(prefix.toUpperCase())) {
2479
+ combined = normalizedPasted;
2480
+ newCursorPos = normalizedPasted.length;
2481
+ } else {
2482
+ combined = currentVal.slice(0, effectiveStart) + normalizedPasted;
2483
+ newCursorPos = combined.length;
2484
+ }
1983
2485
  } else {
1984
2486
  combined = currentVal.slice(0, effectiveStart) + pastedText + currentVal.slice(effectiveEnd);
1985
2487
  newCursorPos = effectiveStart + pastedText.length;
@@ -1998,7 +2500,7 @@ var __WulfIIFE = (() => {
1998
2500
  }
1999
2501
  onBlur() {
2000
2502
  this.wrapper.classList.remove("is-focused", "has-selection");
2001
- if (this.isPasswordInput()) {
2503
+ if (this.isSensitiveField()) {
2002
2504
  this.history.clear();
2003
2505
  this.lastValue = "";
2004
2506
  this.lastInternalRemainingMask = "";
@@ -2059,7 +2561,7 @@ var __WulfIIFE = (() => {
2059
2561
  // ==========================================================================
2060
2562
  updateGhost(formatted) {
2061
2563
  if (!this.ghost) return;
2062
- if (this.options.disabled || this.isPasswordInput()) {
2564
+ if (this.options.disabled || this.isSensitiveField()) {
2063
2565
  this.clearGhost();
2064
2566
  return;
2065
2567
  }
@@ -2087,10 +2589,13 @@ var __WulfIIFE = (() => {
2087
2589
  let isCompleted = false;
2088
2590
  try {
2089
2591
  formatted = this.engine.format(rawOrPartial);
2592
+ if (this.engine.isDynamicPattern()) {
2593
+ this.syncInferredInputMode();
2594
+ }
2090
2595
  const remainingMask = this.engine.getRemainingMask(formatted);
2091
- const isPwd = this.isPasswordInput();
2092
- this.input.value = formatted;
2093
- if (isPwd) {
2596
+ const isSensitive = this.isSensitiveField();
2597
+ this.setNativeValue(formatted);
2598
+ if (isSensitive) {
2094
2599
  this.lastInternalRemainingMask = "";
2095
2600
  this.wrapper.removeAttribute("data-mask");
2096
2601
  this.clearGhost();
@@ -2110,7 +2615,7 @@ var __WulfIIFE = (() => {
2110
2615
  this.input.setSelectionRange(safeCursor, safeCursor);
2111
2616
  isCompleted = this.isComplete();
2112
2617
  this.wrapper.classList.toggle("is-complete", isCompleted);
2113
- if (isPwd) {
2618
+ if (isSensitive) {
2114
2619
  this.options.copyRaw = false;
2115
2620
  this.history.clear();
2116
2621
  } else if (!this.isUndoingRedoing) {
@@ -2122,24 +2627,25 @@ var __WulfIIFE = (() => {
2122
2627
  this.checkValueChange();
2123
2628
  }
2124
2629
  syncInitialValue() {
2125
- const isPwd = this.isPasswordInput();
2630
+ const isSensitive = this.isSensitiveField();
2126
2631
  if (this.options.disabled) {
2127
2632
  this.wrapper.removeAttribute("data-mask");
2128
2633
  this.clearGhost();
2129
- this.lastValue = isPwd ? this.computePasswordDigest(this.input.value) : this.input.value;
2634
+ this.lastValue = isSensitive ? this.computePasswordDigest(this.input.value) : this.input.value;
2130
2635
  this.checkValueChange();
2131
2636
  return;
2132
2637
  }
2133
2638
  this.syncGhostStyles();
2134
2639
  const initialVal = this.input.value || "";
2135
2640
  if (initialVal) {
2136
- this.applyMask(initialVal, initialVal.length);
2641
+ const transformed = this.applyTransformInput(initialVal, "programmatic", "");
2642
+ this.applyMask(transformed, transformed.length);
2137
2643
  } else {
2138
2644
  const minPos = this.engine.getPrefixLength();
2139
2645
  if (minPos > 0) {
2140
2646
  this.applyMask("", minPos);
2141
2647
  } else {
2142
- if (!isPwd) {
2648
+ if (!isSensitive) {
2143
2649
  this.history.push("", 0);
2144
2650
  const fullTemplate = this.engine.getFullMaskTemplate();
2145
2651
  this.lastInternalRemainingMask = fullTemplate;
@@ -2159,9 +2665,9 @@ var __WulfIIFE = (() => {
2159
2665
  * Gère de manière sûre la réentrance pour permettre d'appeler setMask() directement dans le callback.
2160
2666
  */
2161
2667
  checkValueChange(forceNotify = false) {
2162
- const isPwd = this.isPasswordInput();
2668
+ const initialSensitive = this.isSensitiveField();
2163
2669
  const currentVal = this.input.value;
2164
- const currentComparison = isPwd ? this.computePasswordDigest(currentVal) : currentVal;
2670
+ const currentComparison = initialSensitive ? this.computePasswordDigest(currentVal) : currentVal;
2165
2671
  if (currentComparison === this.lastValue && !forceNotify && !this.hasPendingNotification) {
2166
2672
  return;
2167
2673
  }
@@ -2172,15 +2678,16 @@ var __WulfIIFE = (() => {
2172
2678
  this.isNotifying = true;
2173
2679
  try {
2174
2680
  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) {
2681
+ const MAX_NOTIFICATION_ITERATIONS4 = 10;
2682
+ while (((this.isSensitiveField() ? this.computePasswordDigest(this.input.value) : this.input.value) !== this.lastValue || this.hasPendingNotification || forceNotify) && iterations < MAX_NOTIFICATION_ITERATIONS4) {
2177
2683
  iterations++;
2178
2684
  this.hasPendingNotification = false;
2179
2685
  forceNotify = false;
2686
+ const sensitiveNow = this.isSensitiveField();
2180
2687
  const valToNotify = this.input.value;
2181
- this.lastValue = isPwd ? this.computePasswordDigest(valToNotify) : valToNotify;
2688
+ this.lastValue = sensitiveNow ? this.computePasswordDigest(valToNotify) : valToNotify;
2182
2689
  const raw = this.options.disabled ? valToNotify : this.getRawValue();
2183
- const totalSlots = this.options.disabled ? 0 : this.engine.getEditableCount();
2690
+ const totalSlots = this.options.disabled ? 0 : this.engine.getActiveEditableCount();
2184
2691
  const isComplete = this.isComplete();
2185
2692
  const detail = {
2186
2693
  value: valToNotify,
@@ -2189,23 +2696,24 @@ var __WulfIIFE = (() => {
2189
2696
  totalSlots,
2190
2697
  filledSlots: this.options.disabled ? valToNotify.length : raw.length
2191
2698
  };
2699
+ const allowBubble = !sensitiveNow;
2192
2700
  const onInputCb = this.options.onInput || this.options.oninput;
2193
2701
  if (onInputCb) {
2194
2702
  onInputCb(valToNotify, detail);
2195
2703
  }
2196
- this.input.dispatchEvent(new CustomEvent("mask:input", { bubbles: true, detail }));
2704
+ this.input.dispatchEvent(new CustomEvent("mask:input", { bubbles: allowBubble, detail }));
2197
2705
  this.dispatchNativeInput();
2198
2706
  const onChangeCb = this.options.onChange || this.options.onchange;
2199
2707
  if (onChangeCb) {
2200
2708
  onChangeCb(detail);
2201
2709
  }
2202
- this.input.dispatchEvent(new CustomEvent("mask:change", { bubbles: true, detail }));
2710
+ this.input.dispatchEvent(new CustomEvent("mask:change", { bubbles: allowBubble, detail }));
2203
2711
  const onCompleteCb = this.options.onComplete || this.options.oncomplete;
2204
2712
  if (isComplete) {
2205
2713
  if (onCompleteCb) {
2206
2714
  onCompleteCb(detail);
2207
2715
  }
2208
- this.input.dispatchEvent(new CustomEvent("mask:complete", { bubbles: true, detail }));
2716
+ this.input.dispatchEvent(new CustomEvent("mask:complete", { bubbles: allowBubble, detail }));
2209
2717
  }
2210
2718
  }
2211
2719
  } finally {
@@ -2238,6 +2746,47 @@ var __WulfIIFE = (() => {
2238
2746
  max: options.max ?? Infinity
2239
2747
  };
2240
2748
  }
2749
+ /**
2750
+ * Normalise un texte collé uniquement lorsque le séparateur décimal vs milliers
2751
+ * est mathématiquement non ambigu :
2752
+ * - coexistence de ',' et '.' (le séparateur le plus à droite, s'il est unique, est la décimale),
2753
+ * - répétition (>= 2) d'un unique séparateur (il s'agit alors de séparateurs de milliers).
2754
+ * Un séparateur unique isolé (ex: "1,234") reste inchangé pour respecter la locale configurée.
2755
+ */
2756
+ normalizePastedValue(pasted) {
2757
+ const str = sanitizePastedText(pasted, 512);
2758
+ if (!str) return "";
2759
+ let commaCount = 0;
2760
+ let dotCount = 0;
2761
+ let lastCommaIdx = -1;
2762
+ let lastDotIdx = -1;
2763
+ for (let i = 0; i < str.length; i++) {
2764
+ const ch = str[i];
2765
+ if (ch === ",") {
2766
+ commaCount++;
2767
+ lastCommaIdx = i;
2768
+ } else if (ch === ".") {
2769
+ dotCount++;
2770
+ lastDotIdx = i;
2771
+ }
2772
+ }
2773
+ if (commaCount > 0 && dotCount > 0) {
2774
+ const decChar = lastCommaIdx > lastDotIdx ? "," : ".";
2775
+ const decCount = decChar === "," ? commaCount : dotCount;
2776
+ if (decCount !== 1) {
2777
+ return str;
2778
+ }
2779
+ const thousandChar = decChar === "," ? "." : ",";
2780
+ return str.split(thousandChar).join("").replace(decChar, this.options.decimalSeparator);
2781
+ }
2782
+ if (commaCount >= 2 && dotCount === 0) {
2783
+ return str.split(",").join("");
2784
+ }
2785
+ if (dotCount >= 2 && commaCount === 0) {
2786
+ return str.split(".").join("");
2787
+ }
2788
+ return str;
2789
+ }
2241
2790
  /**
2242
2791
  * Analyse et nettoie une saisie utilisateur pour extraire ses composantes numériques.
2243
2792
  */
@@ -2428,12 +2977,15 @@ var __WulfIIFE = (() => {
2428
2977
  };
2429
2978
 
2430
2979
  // src/mask/InputAmountMask.ts
2980
+ var MAX_NOTIFICATION_ITERATIONS = 10;
2431
2981
  var InputAmountMask = class extends BaseInputMask {
2432
2982
  engine;
2433
2983
  history;
2434
2984
  isUndoingRedoing = false;
2435
2985
  isApplying = false;
2436
2986
  isComposing = false;
2987
+ isNotifying = false;
2988
+ hasPendingNotification = false;
2437
2989
  lastValue = "";
2438
2990
  wasInputModeInferred = false;
2439
2991
  cutTimerId = null;
@@ -2493,7 +3045,7 @@ var __WulfIIFE = (() => {
2493
3045
  }
2494
3046
  onNativeValueSet(strVal) {
2495
3047
  if (this.options.disabled || this.isComposing) {
2496
- this.lastValue = strVal;
3048
+ this.lastValue = this.isSensitiveField() ? this.computePasswordDigest(strVal) : strVal;
2497
3049
  return;
2498
3050
  }
2499
3051
  this.applyAmount(strVal, strVal.length);
@@ -2508,6 +3060,7 @@ var __WulfIIFE = (() => {
2508
3060
  bindEvents() {
2509
3061
  this.handleInput = this.handleInput.bind(this);
2510
3062
  this.handleKeyDown = this.handleKeyDown.bind(this);
3063
+ this.handlePaste = this.handlePaste.bind(this);
2511
3064
  this.handleBlur = this.handleBlur.bind(this);
2512
3065
  this.handleFocus = this.handleFocus.bind(this);
2513
3066
  this.handleClick = this.handleClick.bind(this);
@@ -2527,6 +3080,7 @@ var __WulfIIFE = (() => {
2527
3080
  const { signal } = this.abortController;
2528
3081
  this.input.addEventListener("input", this.handleInput, { signal });
2529
3082
  this.input.addEventListener("keydown", this.handleKeyDown, { signal });
3083
+ this.input.addEventListener("paste", this.handlePaste, { signal });
2530
3084
  this.input.addEventListener("blur", this.handleBlur, { signal });
2531
3085
  this.input.addEventListener("focus", this.handleFocus, { signal });
2532
3086
  this.input.addEventListener("click", this.handleClick, { signal });
@@ -2561,12 +3115,13 @@ var __WulfIIFE = (() => {
2561
3115
  applyAmount(val, cursor) {
2562
3116
  if (this.isApplying || this.options.disabled) return;
2563
3117
  this.isApplying = true;
3118
+ let result = null;
2564
3119
  try {
2565
- const result = this.engine.format(val, cursor);
3120
+ result = this.engine.format(val, cursor);
2566
3121
  this.setNativeValue(result.formatted);
2567
3122
  this.input.setSelectionRange(result.cursor, result.cursor);
2568
- const isPwd = this.isPasswordInput();
2569
- if (isPwd) {
3123
+ const isSensitive = this.isSensitiveField();
3124
+ if (isSensitive) {
2570
3125
  this.options.copyRaw = false;
2571
3126
  this.history.clear();
2572
3127
  this.clearGhost();
@@ -2576,17 +3131,19 @@ var __WulfIIFE = (() => {
2576
3131
  }
2577
3132
  this.updateGhost(result);
2578
3133
  }
2579
- const nextComparison = isPwd ? this.computePasswordDigest(result.formatted) : result.formatted;
2580
- if (this.lastValue !== nextComparison) {
2581
- this.lastValue = nextComparison;
2582
- this.notifyChange(result);
2583
- }
2584
3134
  } finally {
2585
3135
  this.isApplying = false;
2586
3136
  }
3137
+ if (result) {
3138
+ this.checkValueChange(result);
3139
+ }
2587
3140
  }
2588
3141
  updateGhost(result) {
2589
3142
  if (!this.ghost) return;
3143
+ if (this.options.disabled || this.isSensitiveField()) {
3144
+ this.clearGhost();
3145
+ return;
3146
+ }
2590
3147
  if (!result.formatted) {
2591
3148
  if (this.shouldHideGhostForPlaceholder(true)) {
2592
3149
  this.clearGhost();
@@ -2610,6 +3167,18 @@ var __WulfIIFE = (() => {
2610
3167
  const cur = this.input.selectionStart ?? rawVal.length;
2611
3168
  this.applyAmount(rawVal, cur);
2612
3169
  }
3170
+ handlePaste(e) {
3171
+ if (this.options.disabled) return;
3172
+ e.preventDefault();
3173
+ this.history.updateCurrentCursor(this.input.selectionStart ?? 0);
3174
+ const prepared = this.preparePastedText(this.getClipboardPlainText(e), 512);
3175
+ if (!prepared) return;
3176
+ const normalized = this.engine.normalizePastedValue(prepared);
3177
+ const start = this.input.selectionStart ?? this.input.value.length;
3178
+ const end = this.input.selectionEnd ?? start;
3179
+ const combined = this.input.value.slice(0, start) + normalized + this.input.value.slice(end);
3180
+ this.applyAmount(combined, start + normalized.length);
3181
+ }
2613
3182
  handleKeyDown(e) {
2614
3183
  if (this.options.disabled || isImeComposing(e)) return;
2615
3184
  if ((e.ctrlKey || e.metaKey) && (e.key === "z" || e.key === "Z")) {
@@ -2674,7 +3243,9 @@ var __WulfIIFE = (() => {
2674
3243
  }
2675
3244
  }
2676
3245
  enforceCursorBounds() {
2677
- if (this.isDestroyed || !this.isFocused || document.activeElement !== this.input || !this.input.value || this.options.disabled) return;
3246
+ if (this.isDestroyed || !this.isFocused || getDeepActiveElement(this.input.ownerDocument) !== this.input || !this.input.value || this.options.disabled) {
3247
+ return;
3248
+ }
2678
3249
  const start = this.input.selectionStart ?? 0;
2679
3250
  const end = this.input.selectionEnd ?? 0;
2680
3251
  if (start !== end) return;
@@ -2705,7 +3276,7 @@ var __WulfIIFE = (() => {
2705
3276
  }
2706
3277
  handleBlur() {
2707
3278
  this.wrapper.classList.remove("is-focused");
2708
- if (this.isPasswordInput()) {
3279
+ if (this.isSensitiveField()) {
2709
3280
  this.history.clear();
2710
3281
  this.lastValue = "";
2711
3282
  this.lastTrackedValue = "";
@@ -2724,7 +3295,7 @@ var __WulfIIFE = (() => {
2724
3295
  if (this.options.onChange) {
2725
3296
  this.options.onChange(detail);
2726
3297
  }
2727
- this.input.dispatchEvent(new CustomEvent("mask:change", { bubbles: true, detail }));
3298
+ this.input.dispatchEvent(new CustomEvent("mask:change", { bubbles: !this.isSensitiveField(), detail }));
2728
3299
  }
2729
3300
  handleAttributeMutation(attrName) {
2730
3301
  super.handleAttributeMutation(attrName);
@@ -2734,6 +3305,34 @@ var __WulfIIFE = (() => {
2734
3305
  this.updateGhost(this.engine.format(this.input.value));
2735
3306
  }
2736
3307
  }
3308
+ checkValueChange(initialResult) {
3309
+ const initialSensitive = this.isSensitiveField();
3310
+ const initialComparison = initialSensitive ? this.computePasswordDigest(this.input.value) : this.input.value;
3311
+ if (initialComparison === this.lastValue && !this.hasPendingNotification) {
3312
+ return;
3313
+ }
3314
+ if (this.isNotifying) {
3315
+ this.hasPendingNotification = true;
3316
+ return;
3317
+ }
3318
+ this.isNotifying = true;
3319
+ try {
3320
+ let iterations = 0;
3321
+ let nextResult = initialResult;
3322
+ while (((this.isSensitiveField() ? this.computePasswordDigest(this.input.value) : this.input.value) !== this.lastValue || this.hasPendingNotification) && iterations < MAX_NOTIFICATION_ITERATIONS) {
3323
+ iterations++;
3324
+ this.hasPendingNotification = false;
3325
+ const sensitiveNow = this.isSensitiveField();
3326
+ const currentVal = this.input.value;
3327
+ this.lastValue = sensitiveNow ? this.computePasswordDigest(currentVal) : currentVal;
3328
+ const res = nextResult ?? this.engine.format(currentVal);
3329
+ nextResult = void 0;
3330
+ this.notifyChange(res);
3331
+ }
3332
+ } finally {
3333
+ this.isNotifying = false;
3334
+ }
3335
+ }
2737
3336
  notifyChange(result) {
2738
3337
  const detail = {
2739
3338
  value: result.formatted,
@@ -2744,7 +3343,7 @@ var __WulfIIFE = (() => {
2744
3343
  if (this.options.onInput) {
2745
3344
  this.options.onInput(detail);
2746
3345
  }
2747
- this.input.dispatchEvent(new CustomEvent("mask:input", { bubbles: true, detail }));
3346
+ this.input.dispatchEvent(new CustomEvent("mask:input", { bubbles: !this.isSensitiveField(), detail }));
2748
3347
  this.dispatchNativeInput();
2749
3348
  }
2750
3349
  undo() {
@@ -2787,11 +3386,53 @@ var __WulfIIFE = (() => {
2787
3386
  isValid() {
2788
3387
  return this.getDetail().isValid;
2789
3388
  }
3389
+ getSpecificAuditWarnings() {
3390
+ const warnings = [];
3391
+ const currencyOrUnit = (this.options.currency || this.options.unit || "").trim();
3392
+ if (!currencyOrUnit || this.options.disabled) {
3393
+ return warnings;
3394
+ }
3395
+ const describedbyWarnings = [];
3396
+ const hasValidDescribedby = this.checkAriaIdReferences(this.input, "aria-describedby", describedbyWarnings, true);
3397
+ const hasAriaPlaceholder = Boolean(this.input.getAttribute("aria-placeholder")?.trim());
3398
+ if (hasValidDescribedby || hasAriaPlaceholder) {
3399
+ return warnings;
3400
+ }
3401
+ const doc = this.input.ownerDocument || document;
3402
+ const root = typeof this.input.getRootNode === "function" ? this.input.getRootNode() : doc;
3403
+ const labelRoot = typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root : doc;
3404
+ let labelTexts = this.input.getAttribute("aria-label") || "";
3405
+ const labelledBy = this.input.getAttribute("aria-labelledby")?.trim();
3406
+ if (labelledBy) {
3407
+ for (const id of labelledBy.split(/\s+/).filter(Boolean)) {
3408
+ const target = typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root.getElementById(id) : doc.getElementById(id);
3409
+ if (target?.textContent) labelTexts += " " + target.textContent;
3410
+ }
3411
+ }
3412
+ const wrapping = this.input.closest("label");
3413
+ if (wrapping?.textContent) labelTexts += " " + wrapping.textContent;
3414
+ if (this.input.id) {
3415
+ try {
3416
+ const explicit = labelRoot.querySelector(`label[for="${safeCssEscape(this.input.id)}"]`);
3417
+ if (explicit?.textContent) labelTexts += " " + explicit.textContent;
3418
+ } catch {
3419
+ }
3420
+ }
3421
+ const norm = labelTexts.toLowerCase();
3422
+ const token = currencyOrUnit.toLowerCase();
3423
+ const hasCurrencyAlias = norm.includes(token) || token === "\u20AC" && (norm.includes("euro") || norm.includes("eur")) || token === "$" && (norm.includes("dollar") || norm.includes("usd")) || token === "\xA3" && (norm.includes("livre") || norm.includes("pound") || norm.includes("gbp"));
3424
+ if (!hasCurrencyAlias) {
3425
+ warnings.push(
3426
+ `Devise/unit\xE9 "${currencyOrUnit}" non expos\xE9e aux technologies d'assistance quand le champ est vide (le fant\xF4me est aria-hidden="true") : mentionnez-la dans le <label>, aria-label ou aria-describedby (WCAG 3.3.2).`
3427
+ );
3428
+ }
3429
+ return warnings;
3430
+ }
2790
3431
  setValue(val) {
2791
3432
  const str = val !== null && val !== void 0 ? String(val) : "";
2792
3433
  if (this.options.disabled) {
2793
3434
  this.setNativeValue(str);
2794
- this.lastValue = str;
3435
+ this.lastValue = this.isSensitiveField() ? this.computePasswordDigest(str) : str;
2795
3436
  } else {
2796
3437
  this.applyAmount(str, str.length);
2797
3438
  }
@@ -2860,7 +3501,8 @@ var __WulfIIFE = (() => {
2860
3501
  "it"
2861
3502
  ];
2862
3503
  constructor(options = {}) {
2863
- this.domains = options.domains && options.domains.length > 0 ? options.domains : _EmailEngine.DEFAULT_DOMAINS;
3504
+ const customDomains = Array.isArray(options.domains) ? options.domains.slice(0, 500).map((d) => String(d ?? "").trim().slice(0, 253)).filter(Boolean) : [];
3505
+ this.domains = customDomains.length > 0 ? customDomains : _EmailEngine.DEFAULT_DOMAINS;
2864
3506
  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];
2865
3507
  this.suggestOnAt = options.suggestOnAt ?? true;
2866
3508
  this.setDefaultDomain(options.defaultDomain ?? null);
@@ -2873,7 +3515,7 @@ var __WulfIIFE = (() => {
2873
3515
  if (domain === true) {
2874
3516
  this.defaultDomain = this.domains.length > 0 ? this.domains[0] : null;
2875
3517
  } else if (typeof domain === "string" && domain.trim().length > 0) {
2876
- this.defaultDomain = domain.trim().replace(/^@/, "");
3518
+ this.defaultDomain = domain.trim().replace(/^@/, "").slice(0, 253) || null;
2877
3519
  } else {
2878
3520
  this.defaultDomain = null;
2879
3521
  }
@@ -2885,7 +3527,7 @@ var __WulfIIFE = (() => {
2885
3527
  if (tld === true) {
2886
3528
  this.defaultTld = this.tlds.length > 0 ? this.tlds[0] : null;
2887
3529
  } else if (typeof tld === "string" && tld.trim().length > 0) {
2888
- this.defaultTld = tld.trim().replace(/^\./, "");
3530
+ this.defaultTld = tld.trim().replace(/^\./, "").slice(0, 32) || null;
2889
3531
  } else {
2890
3532
  this.defaultTld = null;
2891
3533
  }
@@ -3044,11 +3686,16 @@ var __WulfIIFE = (() => {
3044
3686
  };
3045
3687
 
3046
3688
  // src/mask/InputEmailMask.ts
3689
+ var MAX_NOTIFICATION_ITERATIONS2 = 10;
3047
3690
  var InputEmailMask = class extends BaseInputMask {
3048
3691
  engine;
3049
3692
  currentSuggestion = { full: "", remaining: "", matchedDomain: null };
3050
3693
  currentSuggestionIndex = 0;
3694
+ hadInitialAriaAutocomplete = false;
3051
3695
  wasAriaAutocompleteSet = false;
3696
+ isSuggestionDismissed = false;
3697
+ isNotifying = false;
3698
+ hasPendingNotification = false;
3052
3699
  wasAutocorrectSet = false;
3053
3700
  wasAutocapitalizeSet = false;
3054
3701
  wasSpellcheckSet = false;
@@ -3101,46 +3748,73 @@ var __WulfIIFE = (() => {
3101
3748
  this.input.setAttribute("spellcheck", "false");
3102
3749
  this.wasSpellcheckSet = true;
3103
3750
  }
3104
- if (this.options.setAriaAutocomplete && !this.input.hasAttribute("aria-autocomplete")) {
3105
- this.input.setAttribute("aria-autocomplete", "inline");
3106
- this.wasAriaAutocompleteSet = true;
3107
- }
3751
+ this.hadInitialAriaAutocomplete = this.input.hasAttribute("aria-autocomplete");
3752
+ this.syncAriaAutocomplete();
3108
3753
  this.engine = new EmailEngine(this.options);
3109
- this.lastNotifiedValue = this.isPasswordInput() ? "" : this.input.value;
3754
+ this.lastNotifiedValue = this.isSensitiveField() ? "" : this.input.value;
3110
3755
  this.bindEvents();
3111
- if (!this.options.disabled && !this.isPasswordInput()) {
3756
+ if (!this.options.disabled && !this.isSensitiveField()) {
3112
3757
  this.updateSuggestion();
3113
3758
  }
3114
3759
  this.runAuditWarning(this.options.audit);
3115
3760
  }
3116
- onPasswordModeDetected() {
3117
- if (this.srAnnounceTimerId !== null) {
3118
- clearTimeout(this.srAnnounceTimerId);
3119
- this.srAnnounceTimerId = null;
3761
+ syncAriaAutocomplete() {
3762
+ const canSuggest = Boolean(
3763
+ this.options.setAriaAutocomplete && !this.options.disabled && !this.isSensitiveField() && !this.isDestroyed
3764
+ );
3765
+ if (!this.hadInitialAriaAutocomplete) {
3766
+ if (canSuggest) {
3767
+ if (!this.input.hasAttribute("aria-autocomplete")) {
3768
+ this.input.setAttribute("aria-autocomplete", "inline");
3769
+ this.wasAriaAutocompleteSet = true;
3770
+ }
3771
+ } else if (this.wasAriaAutocompleteSet) {
3772
+ if (this.input.getAttribute("aria-autocomplete") === "inline") {
3773
+ this.input.removeAttribute("aria-autocomplete");
3774
+ }
3775
+ this.wasAriaAutocompleteSet = false;
3776
+ }
3120
3777
  }
3121
- this.lastNotifiedValue = "";
3778
+ const doc = this.input.ownerDocument || (typeof document !== "undefined" ? document : null);
3779
+ const hasAriaNotify = Boolean(doc && typeof doc.ariaNotify === "function");
3780
+ if (canSuggest && !hasAriaNotify) {
3781
+ this.ensureSrStatusEl();
3782
+ } else if (!canSuggest && this.srStatusEl) {
3783
+ this.srStatusEl.remove();
3784
+ this.srStatusEl = null;
3785
+ }
3786
+ }
3787
+ onPasswordModeDetected() {
3788
+ if (this.srAnnounceTimerId !== null) {
3789
+ clearTimeout(this.srAnnounceTimerId);
3790
+ this.srAnnounceTimerId = null;
3791
+ }
3792
+ this.lastNotifiedValue = "";
3122
3793
  this.lastTrackedValue = "";
3123
3794
  this.lastAnnouncedSuggestion = "";
3124
3795
  this.currentSuggestion = { full: "", remaining: "", matchedDomain: null };
3125
- if (this.srStatusEl) {
3126
- this.srStatusEl.textContent = "";
3127
- }
3796
+ this.syncAriaAutocomplete();
3128
3797
  this.clearGhost();
3129
3798
  }
3130
3799
  onNativeValueSet(_strVal) {
3131
- if (this.options.disabled || this.isComposing || this.isPasswordInput()) return;
3800
+ if (this.options.disabled || this.isComposing || this.isSensitiveField()) return;
3801
+ this.isSuggestionDismissed = false;
3132
3802
  this.updateSuggestion();
3133
3803
  }
3134
3804
  onDisabledChange(disabled) {
3135
- if (disabled || this.isPasswordInput()) {
3805
+ this.syncAriaAutocomplete();
3806
+ if (disabled || this.isSensitiveField()) {
3807
+ this.currentSuggestion = { full: "", remaining: "", matchedDomain: null };
3136
3808
  this.clearGhost();
3137
3809
  } else {
3810
+ this.isSuggestionDismissed = false;
3138
3811
  this.updateSuggestion();
3139
3812
  }
3140
3813
  }
3141
3814
  bindEvents() {
3142
3815
  this.handleInput = this.handleInput.bind(this);
3143
3816
  this.handleKeyDown = this.handleKeyDown.bind(this);
3817
+ this.handlePaste = this.handlePaste.bind(this);
3144
3818
  this.handleBlur = this.handleBlur.bind(this);
3145
3819
  this.handleFocus = this.handleFocus.bind(this);
3146
3820
  this.onCutHandler = () => {
@@ -3149,13 +3823,14 @@ var __WulfIIFE = (() => {
3149
3823
  }
3150
3824
  this.cutTimerId = window.setTimeout(() => {
3151
3825
  this.cutTimerId = null;
3152
- if (this.isDestroyed || this.options.disabled || this.isPasswordInput()) return;
3826
+ if (this.isDestroyed || this.options.disabled || this.isSensitiveField()) return;
3153
3827
  this.updateSuggestion();
3154
3828
  }, 0);
3155
3829
  };
3156
3830
  const { signal } = this.abortController;
3157
3831
  this.input.addEventListener("input", this.handleInput, { signal });
3158
3832
  this.input.addEventListener("keydown", this.handleKeyDown, { signal });
3833
+ this.input.addEventListener("paste", this.handlePaste, { signal });
3159
3834
  this.input.addEventListener("blur", this.handleBlur, { signal });
3160
3835
  this.input.addEventListener("focus", this.handleFocus, { signal });
3161
3836
  this.input.addEventListener("scroll", this.onScroll, { passive: true, signal });
@@ -3165,7 +3840,7 @@ var __WulfIIFE = (() => {
3165
3840
  }, { signal });
3166
3841
  this.input.addEventListener("compositionend", () => {
3167
3842
  this.isComposing = false;
3168
- if (!this.isDestroyed && !this.options.disabled && !this.isPasswordInput()) {
3843
+ if (!this.isDestroyed && !this.options.disabled && !this.isSensitiveField()) {
3169
3844
  this.handleInput();
3170
3845
  }
3171
3846
  }, { signal });
@@ -3176,7 +3851,7 @@ var __WulfIIFE = (() => {
3176
3851
  }
3177
3852
  this.resetTimerId = window.setTimeout(() => {
3178
3853
  this.resetTimerId = null;
3179
- if (this.isDestroyed || this.options.disabled || this.isPasswordInput()) return;
3854
+ if (this.isDestroyed || this.options.disabled || this.isSensitiveField()) return;
3180
3855
  this.updateSuggestion();
3181
3856
  }, 0);
3182
3857
  };
@@ -3202,7 +3877,7 @@ var __WulfIIFE = (() => {
3202
3877
  clearTimeout(this.srAnnounceTimerId);
3203
3878
  this.srAnnounceTimerId = null;
3204
3879
  }
3205
- if (!this.options.setAriaAutocomplete || !this.isFocused || this.isDestroyed || this.isPasswordInput()) {
3880
+ if (!this.options.setAriaAutocomplete || !this.isFocused || this.isDestroyed || this.isSensitiveField()) {
3206
3881
  return;
3207
3882
  }
3208
3883
  const suggestion = this.currentSuggestion;
@@ -3219,7 +3894,7 @@ var __WulfIIFE = (() => {
3219
3894
  }
3220
3895
  const run = () => {
3221
3896
  this.srAnnounceTimerId = null;
3222
- if (this.isDestroyed || !this.isFocused || this.isPasswordInput()) return;
3897
+ if (this.isDestroyed || !this.isFocused || this.isSensitiveField()) return;
3223
3898
  this.lastAnnouncedSuggestion = textToAnnounce;
3224
3899
  const doc = this.input.ownerDocument || (typeof document !== "undefined" ? document : null);
3225
3900
  const docWithAriaNotify = doc;
@@ -3242,13 +3917,13 @@ var __WulfIIFE = (() => {
3242
3917
  }
3243
3918
  }
3244
3919
  updateSuggestion(announceOptions) {
3245
- if (this.options.disabled || this.isPasswordInput()) {
3920
+ if (this.options.disabled || this.isSensitiveField()) {
3246
3921
  this.currentSuggestion = { full: "", remaining: "", matchedDomain: null };
3247
3922
  this.clearGhost();
3248
3923
  return;
3249
3924
  }
3250
3925
  const val = this.input.value;
3251
- this.currentSuggestion = this.engine.getSuggestion(val, this.currentSuggestionIndex);
3926
+ this.currentSuggestion = this.isSuggestionDismissed ? { full: val, remaining: "", matchedDomain: null } : this.engine.getSuggestion(val, this.currentSuggestionIndex);
3252
3927
  if (!this.ghost) return;
3253
3928
  if (this.shouldHideGhostForPlaceholder(val.length === 0)) {
3254
3929
  this.clearGhost();
@@ -3268,19 +3943,39 @@ var __WulfIIFE = (() => {
3268
3943
  if (announceOptions?.announce) {
3269
3944
  this.scheduleSuggestionAnnouncement(Boolean(announceOptions.immediate));
3270
3945
  }
3271
- const detail = this.getDetail();
3272
- if (this.options.onInput) {
3273
- this.options.onInput(detail);
3946
+ this.notifyValueChange();
3947
+ }
3948
+ notifyValueChange() {
3949
+ if (this.isNotifying) {
3950
+ this.hasPendingNotification = true;
3951
+ return;
3274
3952
  }
3275
- this.input.dispatchEvent(new CustomEvent("mask:input", { bubbles: true, detail }));
3276
- if (val !== this.lastNotifiedValue) {
3277
- this.lastNotifiedValue = val;
3278
- this.dispatchNativeInput();
3953
+ this.isNotifying = true;
3954
+ try {
3955
+ let iterations = 0;
3956
+ do {
3957
+ iterations++;
3958
+ this.hasPendingNotification = false;
3959
+ const sensitiveNow = this.isSensitiveField();
3960
+ const allowBubble = !sensitiveNow;
3961
+ const valNow = this.input.value;
3962
+ const detail = this.getDetail();
3963
+ if (this.options.onInput) {
3964
+ this.options.onInput(detail);
3965
+ }
3966
+ this.input.dispatchEvent(new CustomEvent("mask:input", { bubbles: allowBubble, detail }));
3967
+ if (valNow !== this.lastNotifiedValue) {
3968
+ this.lastNotifiedValue = sensitiveNow ? "" : valNow;
3969
+ this.dispatchNativeInput();
3970
+ }
3971
+ } while (this.hasPendingNotification && iterations < MAX_NOTIFICATION_ITERATIONS2);
3972
+ } finally {
3973
+ this.isNotifying = false;
3279
3974
  }
3280
3975
  }
3281
3976
  handleInput(e) {
3282
3977
  if (this.isDispatchingNativeInput) return;
3283
- if (this.options.disabled || this.isPasswordInput()) return;
3978
+ if (this.options.disabled || this.isSensitiveField()) return;
3284
3979
  if (this.isComposing || e && "isComposing" in e && e.isComposing) return;
3285
3980
  if (this.options.autoLowercase) {
3286
3981
  const start = this.input.selectionStart ?? 0;
@@ -3291,16 +3986,60 @@ var __WulfIIFE = (() => {
3291
3986
  this.input.setSelectionRange(start, end);
3292
3987
  }
3293
3988
  }
3989
+ this.isSuggestionDismissed = false;
3294
3990
  this.currentSuggestionIndex = 0;
3295
3991
  this.updateSuggestion({ announce: true, immediate: false });
3296
3992
  }
3993
+ handlePaste(e) {
3994
+ if (this.options.disabled || this.isSensitiveField()) return;
3995
+ const raw = this.getClipboardPlainText(e);
3996
+ const prepared = this.preparePastedText(raw, 512);
3997
+ if (prepared === raw) {
3998
+ return;
3999
+ }
4000
+ e.preventDefault();
4001
+ const start = this.input.selectionStart ?? this.input.value.length;
4002
+ const end = this.input.selectionEnd ?? start;
4003
+ const before = this.input.value.slice(0, start);
4004
+ const after = this.input.value.slice(end);
4005
+ const expected = before + prepared + after;
4006
+ const finalExpected = this.options.autoLowercase ? expected.toLowerCase() : expected;
4007
+ if (typeof document !== "undefined" && getDeepActiveElement(this.input.ownerDocument) === this.input && typeof document.execCommand === "function") {
4008
+ try {
4009
+ const execOk = document.execCommand("insertText", false, prepared);
4010
+ if (execOk && this.input.value === finalExpected) {
4011
+ return;
4012
+ }
4013
+ } catch {
4014
+ }
4015
+ }
4016
+ this.setNativeValue(expected);
4017
+ const nextCursor = start + prepared.length;
4018
+ this.input.setSelectionRange(nextCursor, nextCursor);
4019
+ this.handleInput();
4020
+ }
3297
4021
  handleKeyDown(e) {
3298
- if (this.options.disabled || this.isPasswordInput() || isImeComposing(e)) return;
4022
+ if (this.options.disabled || this.isSensitiveField() || isImeComposing(e)) return;
3299
4023
  if (e.shiftKey || e.ctrlKey || e.altKey || e.metaKey) return;
3300
4024
  const hasSuggestion = Boolean(this.currentSuggestion.remaining) && !this.currentSuggestion.isHintOnly;
3301
4025
  const cursor = this.input.selectionStart ?? 0;
3302
4026
  const isAtEnd = cursor === this.input.value.length;
3303
4027
  const isNotEmpty = this.input.value.length > 0;
4028
+ if (e.key === "Escape" && hasSuggestion) {
4029
+ e.preventDefault();
4030
+ this.isSuggestionDismissed = true;
4031
+ this.currentSuggestion = { full: this.input.value, remaining: "", matchedDomain: null };
4032
+ if (this.srAnnounceTimerId !== null) {
4033
+ clearTimeout(this.srAnnounceTimerId);
4034
+ this.srAnnounceTimerId = null;
4035
+ }
4036
+ this.lastAnnouncedSuggestion = "";
4037
+ if (this.srStatusEl) {
4038
+ this.srStatusEl.textContent = "";
4039
+ }
4040
+ this.clearGhost();
4041
+ return;
4042
+ }
3304
4043
  if (this.options.cycleSuggestions && hasSuggestion && isNotEmpty && isAtEnd) {
3305
4044
  if (e.key === "ArrowDown") {
3306
4045
  e.preventDefault();
@@ -3335,7 +4074,9 @@ var __WulfIIFE = (() => {
3335
4074
  * Valide et applique la suggestion courante dans le champ natif.
3336
4075
  */
3337
4076
  acceptSuggestion() {
3338
- if (!this.currentSuggestion.remaining || this.currentSuggestion.isHintOnly || this.options.disabled || this.input.value.length === 0) return false;
4077
+ if (!this.currentSuggestion.remaining || this.currentSuggestion.isHintOnly || this.options.disabled || this.isSensitiveField() || this.input.value.length === 0) {
4078
+ return false;
4079
+ }
3339
4080
  const completed = this.currentSuggestion.full;
3340
4081
  this.setNativeValue(completed);
3341
4082
  this.input.setSelectionRange(completed.length, completed.length);
@@ -3345,8 +4086,9 @@ var __WulfIIFE = (() => {
3345
4086
  if (this.options.onChange) {
3346
4087
  this.options.onChange(detail);
3347
4088
  }
3348
- this.input.dispatchEvent(new CustomEvent("mask:change", { bubbles: true, detail }));
3349
- this.input.dispatchEvent(new CustomEvent("mask:complete", { bubbles: true, detail }));
4089
+ const allowBubble = !this.isSensitiveField();
4090
+ this.input.dispatchEvent(new CustomEvent("mask:change", { bubbles: allowBubble, detail }));
4091
+ this.input.dispatchEvent(new CustomEvent("mask:complete", { bubbles: allowBubble, detail }));
3350
4092
  return true;
3351
4093
  }
3352
4094
  /**
@@ -3373,6 +4115,7 @@ var __WulfIIFE = (() => {
3373
4115
  }
3374
4116
  handleFocus() {
3375
4117
  this.wrapper.classList.add("is-focused");
4118
+ this.isSuggestionDismissed = false;
3376
4119
  this.syncGhostStyles();
3377
4120
  this.updateSuggestion();
3378
4121
  }
@@ -3386,7 +4129,7 @@ var __WulfIIFE = (() => {
3386
4129
  if (this.srStatusEl) {
3387
4130
  this.srStatusEl.textContent = "";
3388
4131
  }
3389
- if (this.isPasswordInput()) {
4132
+ if (this.isSensitiveField()) {
3390
4133
  this.lastNotifiedValue = "";
3391
4134
  this.lastTrackedValue = "";
3392
4135
  this.clearGhost();
@@ -3397,7 +4140,7 @@ var __WulfIIFE = (() => {
3397
4140
  if (this.options.onChange) {
3398
4141
  this.options.onChange(detail);
3399
4142
  }
3400
- this.input.dispatchEvent(new CustomEvent("mask:change", { bubbles: true, detail }));
4143
+ this.input.dispatchEvent(new CustomEvent("mask:change", { bubbles: !this.isSensitiveField(), detail }));
3401
4144
  }
3402
4145
  handleAttributeMutation(attrName) {
3403
4146
  super.handleAttributeMutation(attrName);
@@ -3424,6 +4167,7 @@ var __WulfIIFE = (() => {
3424
4167
  }
3425
4168
  setValue(val) {
3426
4169
  const str = val !== null && val !== void 0 ? String(val) : "";
4170
+ this.isSuggestionDismissed = false;
3427
4171
  this.setNativeValue(str);
3428
4172
  this.updateSuggestion();
3429
4173
  }
@@ -3466,6 +4210,1912 @@ var __WulfIIFE = (() => {
3466
4210
  }
3467
4211
  };
3468
4212
 
4213
+ // src/mask/DateUTCEngine.ts
4214
+ var DATE_UTC_PRESETS = {
4215
+ iso: { format: "YYYY-MM-DD HH:mm:ss" },
4216
+ "iso-t": { format: "YYYY-MM-DD\\THH:mm:ss" },
4217
+ fr: {
4218
+ format: "DD/MM/YYYY HH:mm",
4219
+ placeholderTokens: { DD: "jj", MM: "mm", YYYY: "aaaa", HH: "hh", mm: "mm" }
4220
+ },
4221
+ "fr-sec": {
4222
+ format: "DD/MM/YYYY HH:mm:ss",
4223
+ placeholderTokens: { DD: "jj", MM: "mm", YYYY: "aaaa", HH: "hh", mm: "mm", ss: "ss" }
4224
+ },
4225
+ us: { format: "MM/DD/YYYY HH:mm" },
4226
+ "us-12h": { format: "MM/DD/YYYY hh:mm A" },
4227
+ uk: { format: "DD/MM/YYYY HH:mm" },
4228
+ no: { format: "DD/MM-YYYY HH:mm" },
4229
+ cz: { format: "DD. MM. YYYY HH:mm" },
4230
+ de: { format: "DD.MM.YYYY HH:mm" },
4231
+ jp: { format: "YYYY/MM/DD HH:mm" }
4232
+ };
4233
+ var DEFAULT_PLACEHOLDERS = {
4234
+ YYYY: "YYYY",
4235
+ MM: "MM",
4236
+ DD: "DD",
4237
+ HH: "HH",
4238
+ hh: "hh",
4239
+ mm: "mm",
4240
+ ss: "ss",
4241
+ A: "AM"
4242
+ };
4243
+ var TOKEN_DEFS = [
4244
+ { token: "YYYY", length: 4 },
4245
+ { token: "MM", length: 2 },
4246
+ { token: "DD", length: 2 },
4247
+ { token: "HH", length: 2 },
4248
+ { token: "hh", length: 2 },
4249
+ { token: "mm", length: 2 },
4250
+ { token: "ss", length: 2 },
4251
+ { token: "A", length: 2 }
4252
+ ];
4253
+ var MAX_FORMAT_LENGTH = 128;
4254
+ var MAX_INPUT_LENGTH = 512;
4255
+ var DATE_SEPARATORS = /* @__PURE__ */ new Set(["/", "-", ".", ":", " ", "T", "t"]);
4256
+ var TIME_TOKEN_KINDS = /* @__PURE__ */ new Set(["HH", "hh", "mm", "ss", "A"]);
4257
+ function isAsciiDigit(ch) {
4258
+ return ch >= "0" && ch <= "9";
4259
+ }
4260
+ function parseAsciiInt(str) {
4261
+ let val = 0;
4262
+ for (let i = 0; i < str.length; i++) {
4263
+ const code = str.charCodeAt(i);
4264
+ if (code < 48 || code > 57) return NaN;
4265
+ val = val * 10 + (code - 48);
4266
+ }
4267
+ return str.length > 0 ? val : NaN;
4268
+ }
4269
+ function normalizeSegmentPlaceholder(raw, length, fallback) {
4270
+ const graphemes = Array.from(raw || fallback);
4271
+ const fb = Array.from(fallback);
4272
+ while (graphemes.length < length) {
4273
+ graphemes.push(fb[graphemes.length] || fb[fb.length - 1] || "_");
4274
+ }
4275
+ return graphemes.slice(0, length).join("");
4276
+ }
4277
+ var DateUTCEngine = class _DateUTCEngine {
4278
+ formatSpec = "YYYY-MM-DD HH:mm";
4279
+ customPlaceholders = {};
4280
+ slots = [];
4281
+ segments = [];
4282
+ fullTemplate = "";
4283
+ prefixSlotsCount = 0;
4284
+ prefixString = "";
4285
+ editableCount = 0;
4286
+ hasMeridiemFlag = false;
4287
+ utcIndicator = " UTC";
4288
+ includeMilliseconds = false;
4289
+ convertPastedOffset = true;
4290
+ defaultTimeOnDateOnly = false;
4291
+ minTs = null;
4292
+ maxTs = null;
4293
+ constructor(options = {}) {
4294
+ this.updateOptions(options);
4295
+ }
4296
+ /**
4297
+ * Formate statiquement une date (Date, timestamp ms, ISO ou chaîne) selon les options données.
4298
+ */
4299
+ static format(value, options = {}) {
4300
+ const engine = new _DateUTCEngine(options);
4301
+ return engine.formatFromValue(value);
4302
+ }
4303
+ updateOptions(options = {}) {
4304
+ if (options.utcIndicator !== void 0) {
4305
+ this.utcIndicator = options.utcIndicator === false ? false : String(options.utcIndicator).slice(0, 32);
4306
+ }
4307
+ if (options.includeMilliseconds !== void 0) {
4308
+ this.includeMilliseconds = Boolean(options.includeMilliseconds);
4309
+ }
4310
+ if (options.convertPastedOffset !== void 0) {
4311
+ this.convertPastedOffset = options.convertPastedOffset !== false;
4312
+ }
4313
+ if (options.defaultTimeOnDateOnly !== void 0) {
4314
+ this.defaultTimeOnDateOnly = options.defaultTimeOnDateOnly;
4315
+ }
4316
+ if (options.min !== void 0) {
4317
+ this.minTs = this.normalizeBoundary(options.min);
4318
+ }
4319
+ if (options.max !== void 0) {
4320
+ this.maxTs = this.normalizeBoundary(options.max);
4321
+ }
4322
+ if (options.placeholderTokens !== void 0) {
4323
+ this.customPlaceholders = options.placeholderTokens || {};
4324
+ }
4325
+ if (options.format !== void 0 || this.slots.length === 0) {
4326
+ this.compile(options.format ?? this.formatSpec, options.placeholderTokens);
4327
+ }
4328
+ }
4329
+ setFormat(format, placeholderTokens) {
4330
+ if (placeholderTokens !== void 0) {
4331
+ this.customPlaceholders = placeholderTokens;
4332
+ }
4333
+ this.compile(format, this.customPlaceholders);
4334
+ }
4335
+ setUtcIndicator(indicator) {
4336
+ this.utcIndicator = indicator === false ? false : String(indicator).slice(0, 32);
4337
+ }
4338
+ getUtcIndicator() {
4339
+ return this.utcIndicator;
4340
+ }
4341
+ getFormat() {
4342
+ return this.formatSpec;
4343
+ }
4344
+ getFullTemplate() {
4345
+ return this.fullTemplate;
4346
+ }
4347
+ getGhostRemaining(formatted) {
4348
+ const suffix = this.utcIndicator ? this.utcIndicator : "";
4349
+ if (formatted.length >= this.fullTemplate.length) {
4350
+ return suffix;
4351
+ }
4352
+ return this.fullTemplate.slice(formatted.length) + suffix;
4353
+ }
4354
+ getPrefix() {
4355
+ return this.prefixString;
4356
+ }
4357
+ getPrefixLength() {
4358
+ return this.prefixSlotsCount;
4359
+ }
4360
+ getEditableCount() {
4361
+ return this.editableCount;
4362
+ }
4363
+ hasMeridiem() {
4364
+ return this.hasMeridiemFlag;
4365
+ }
4366
+ isNumericOnly() {
4367
+ return !this.hasMeridiemFlag;
4368
+ }
4369
+ getSegments() {
4370
+ return this.segments;
4371
+ }
4372
+ getSlots() {
4373
+ return this.slots;
4374
+ }
4375
+ isSeparatorAt(idx) {
4376
+ return idx >= 0 && idx < this.slots.length && this.slots[idx].isStatic;
4377
+ }
4378
+ getNextEditablePosition(fromIdx) {
4379
+ const start = Math.max(0, fromIdx);
4380
+ for (let i = start; i < this.slots.length; i++) {
4381
+ if (!this.slots[i].isStatic) return i;
4382
+ }
4383
+ return this.slots.length;
4384
+ }
4385
+ compile(format, overridePlaceholders) {
4386
+ const rawSpec = String(format || "YYYY-MM-DD HH:mm").trim().slice(0, MAX_FORMAT_LENGTH) || "YYYY-MM-DD HH:mm";
4387
+ this.formatSpec = rawSpec;
4388
+ const preset = Object.hasOwn(DATE_UTC_PRESETS, rawSpec) ? DATE_UTC_PRESETS[rawSpec] : null;
4389
+ const pattern = preset ? preset.format : rawSpec;
4390
+ const mergedPlaceholders = /* @__PURE__ */ Object.create(null);
4391
+ if (preset?.placeholderTokens) {
4392
+ for (const [k, v] of Object.entries(preset.placeholderTokens)) {
4393
+ if (Object.hasOwn(DEFAULT_PLACEHOLDERS, k) && typeof v === "string") {
4394
+ mergedPlaceholders[k] = v;
4395
+ }
4396
+ }
4397
+ }
4398
+ const sourceOverrides = overridePlaceholders !== void 0 ? overridePlaceholders : this.customPlaceholders;
4399
+ if (sourceOverrides && typeof sourceOverrides === "object") {
4400
+ for (const [k, v] of Object.entries(sourceOverrides)) {
4401
+ if (Object.hasOwn(DEFAULT_PLACEHOLDERS, k) && typeof v === "string") {
4402
+ mergedPlaceholders[k] = v;
4403
+ }
4404
+ }
4405
+ }
4406
+ this.slots = [];
4407
+ this.segments = [];
4408
+ this.hasMeridiemFlag = false;
4409
+ let template = "";
4410
+ let isPrefixMode = true;
4411
+ let i = 0;
4412
+ while (i < pattern.length) {
4413
+ const ch = pattern[i];
4414
+ if (ch === "\\" && i + 1 < pattern.length) {
4415
+ const lit = pattern[i + 1];
4416
+ this.slots.push({
4417
+ char: lit,
4418
+ isStatic: true,
4419
+ isPrefix: isPrefixMode,
4420
+ segmentIndex: -1,
4421
+ charIndexInSegment: -1,
4422
+ placeholder: lit
4423
+ });
4424
+ template += lit;
4425
+ i += 2;
4426
+ continue;
4427
+ }
4428
+ let matchedToken = null;
4429
+ for (const def of TOKEN_DEFS) {
4430
+ if (pattern.startsWith(def.token, i)) {
4431
+ matchedToken = def;
4432
+ break;
4433
+ }
4434
+ }
4435
+ if (matchedToken) {
4436
+ isPrefixMode = false;
4437
+ const { token, length } = matchedToken;
4438
+ if (token === "A") {
4439
+ this.hasMeridiemFlag = true;
4440
+ }
4441
+ const phRaw = mergedPlaceholders[token] ?? DEFAULT_PLACEHOLDERS[token];
4442
+ const ph = normalizeSegmentPlaceholder(phRaw, length, DEFAULT_PLACEHOLDERS[token]);
4443
+ const phChars = Array.from(ph);
4444
+ const segIdx = this.segments.length;
4445
+ const start = this.slots.length;
4446
+ for (let k = 0; k < length; k++) {
4447
+ this.slots.push({
4448
+ char: token === "A" ? "A" : "9",
4449
+ isStatic: false,
4450
+ isPrefix: false,
4451
+ segmentIndex: segIdx,
4452
+ charIndexInSegment: k,
4453
+ tokenKind: token,
4454
+ placeholder: phChars[k] || "_"
4455
+ });
4456
+ }
4457
+ this.segments.push({
4458
+ kind: token,
4459
+ start,
4460
+ end: start + length,
4461
+ length,
4462
+ placeholder: ph,
4463
+ followingSeparator: ""
4464
+ });
4465
+ template += ph;
4466
+ i += token.length;
4467
+ } else {
4468
+ this.slots.push({
4469
+ char: ch,
4470
+ isStatic: true,
4471
+ isPrefix: isPrefixMode,
4472
+ segmentIndex: -1,
4473
+ charIndexInSegment: -1,
4474
+ placeholder: ch
4475
+ });
4476
+ template += ch;
4477
+ i++;
4478
+ }
4479
+ }
4480
+ this.fullTemplate = template;
4481
+ this.editableCount = this.slots.filter((s) => !s.isStatic).length;
4482
+ this.prefixSlotsCount = 0;
4483
+ this.prefixString = "";
4484
+ for (const slot of this.slots) {
4485
+ if (slot.isPrefix) {
4486
+ this.prefixSlotsCount++;
4487
+ this.prefixString += slot.char;
4488
+ } else {
4489
+ break;
4490
+ }
4491
+ }
4492
+ for (let s = 0; s < this.segments.length; s++) {
4493
+ const seg = this.segments[s];
4494
+ let sep = "";
4495
+ for (let pos = seg.end; pos < this.slots.length && this.slots[pos].isStatic; pos++) {
4496
+ sep += this.slots[pos].char;
4497
+ }
4498
+ seg.followingSeparator = sep;
4499
+ }
4500
+ }
4501
+ /**
4502
+ * Extrait linéairement les caractères bruts valides alignés sur les slots.
4503
+ */
4504
+ extractRaw(input, expandSingleMeridiem = false) {
4505
+ const str = String(input ?? "").slice(0, MAX_INPUT_LENGTH);
4506
+ if (!str || this.slots.length === 0) return "";
4507
+ let raw = "";
4508
+ let inputIdx = 0;
4509
+ let slotIdx = 0;
4510
+ if (this.prefixSlotsCount > 0) {
4511
+ while (inputIdx < str.length && (str[inputIdx] === " " || str[inputIdx] === " ")) {
4512
+ inputIdx++;
4513
+ }
4514
+ let pIdx = 0;
4515
+ while (inputIdx < str.length && pIdx < this.prefixSlotsCount) {
4516
+ const pChar = this.slots[pIdx].char;
4517
+ const inChar = str[inputIdx];
4518
+ if (inChar.toUpperCase() === pChar.toUpperCase()) {
4519
+ inputIdx++;
4520
+ pIdx++;
4521
+ } else if (pChar === " " && inChar !== " ") {
4522
+ pIdx++;
4523
+ } else {
4524
+ break;
4525
+ }
4526
+ }
4527
+ slotIdx = this.prefixSlotsCount;
4528
+ }
4529
+ while (inputIdx < str.length && slotIdx < this.slots.length) {
4530
+ const slot = this.slots[slotIdx];
4531
+ const ch = str[inputIdx];
4532
+ if (slot.isStatic) {
4533
+ if (ch.toUpperCase() === slot.char.toUpperCase()) {
4534
+ inputIdx++;
4535
+ slotIdx++;
4536
+ } else {
4537
+ slotIdx++;
4538
+ }
4539
+ continue;
4540
+ }
4541
+ if (slot.tokenKind === "A") {
4542
+ const upper = ch.toUpperCase();
4543
+ if (slot.charIndexInSegment === 0) {
4544
+ if (upper === "A" || upper === "P") {
4545
+ raw += upper;
4546
+ inputIdx++;
4547
+ slotIdx++;
4548
+ const nextCh = inputIdx < str.length ? str[inputIdx].toUpperCase() : "";
4549
+ if (nextCh === "M") {
4550
+ raw += "M";
4551
+ inputIdx++;
4552
+ slotIdx++;
4553
+ } else if (expandSingleMeridiem) {
4554
+ raw += "M";
4555
+ slotIdx++;
4556
+ }
4557
+ } else {
4558
+ inputIdx++;
4559
+ }
4560
+ } else {
4561
+ if (upper === "M") {
4562
+ raw += "M";
4563
+ inputIdx++;
4564
+ slotIdx++;
4565
+ } else if (expandSingleMeridiem) {
4566
+ raw += "M";
4567
+ slotIdx++;
4568
+ } else {
4569
+ inputIdx++;
4570
+ }
4571
+ }
4572
+ continue;
4573
+ }
4574
+ if (isAsciiDigit(ch)) {
4575
+ raw += ch;
4576
+ inputIdx++;
4577
+ slotIdx++;
4578
+ } else {
4579
+ inputIdx++;
4580
+ }
4581
+ }
4582
+ return raw;
4583
+ }
4584
+ /**
4585
+ * Formate une saisie (brute ou partiellement formatée) selon le gabarit configuré.
4586
+ */
4587
+ format(input, expandSingleMeridiem = false) {
4588
+ if (this.slots.length === 0) return String(input ?? "").slice(0, MAX_INPUT_LENGTH);
4589
+ const cleanRaw = this.extractRaw(input, expandSingleMeridiem);
4590
+ if (cleanRaw.length === 0) {
4591
+ return this.prefixString;
4592
+ }
4593
+ let formatted = "";
4594
+ let rawIdx = 0;
4595
+ for (let i = 0; i < this.slots.length; i++) {
4596
+ const slot = this.slots[i];
4597
+ if (slot.isStatic) {
4598
+ const hasRemainingRaw = rawIdx < cleanRaw.length;
4599
+ const isPrefix = rawIdx === 0 && slot.isPrefix;
4600
+ const isCompletedSegmentTrailingSep = rawIdx > 0 && rawIdx === cleanRaw.length;
4601
+ if (hasRemainingRaw || isPrefix || isCompletedSegmentTrailingSep) {
4602
+ formatted += slot.char;
4603
+ } else {
4604
+ break;
4605
+ }
4606
+ } else if (rawIdx < cleanRaw.length) {
4607
+ formatted += cleanRaw[rawIdx];
4608
+ rawIdx++;
4609
+ } else {
4610
+ break;
4611
+ }
4612
+ }
4613
+ return formatted;
4614
+ }
4615
+ /**
4616
+ * Analyse complète de la saisie courante : formatage, complétude, validité calendaire UTC, Date & ISO.
4617
+ */
4618
+ analyze(input, expandSingleMeridiem = false) {
4619
+ const cleanRaw = this.extractRaw(input, expandSingleMeridiem);
4620
+ const formatted = this.formatFromCleanRaw(cleanRaw);
4621
+ const totalSlots = this.editableCount;
4622
+ const filledSlots = cleanRaw.length;
4623
+ const isComplete = totalSlots > 0 && filledSlots >= totalSlots;
4624
+ const extracted = this.extractSegmentValues(cleanRaw);
4625
+ const parts = extracted.parts;
4626
+ let date = null;
4627
+ let isoString = null;
4628
+ let timestamp = null;
4629
+ let isValid = false;
4630
+ if (isComplete && extracted.allSegmentsPresent) {
4631
+ const resolvedHour = this.resolveHour24(extracted);
4632
+ if (resolvedHour !== null) {
4633
+ const candidate = {
4634
+ year: parts.year,
4635
+ month: parts.month,
4636
+ day: parts.day,
4637
+ hour: resolvedHour,
4638
+ minute: parts.minute ?? 0,
4639
+ second: parts.second ?? 0
4640
+ };
4641
+ const strictDate = this.buildStrictUTCDate(candidate);
4642
+ if (strictDate) {
4643
+ const ts = strictDate.getTime();
4644
+ const inMin = this.minTs === null || ts >= this.minTs;
4645
+ const inMax = this.maxTs === null || ts <= this.maxTs;
4646
+ if (inMin && inMax) {
4647
+ date = strictDate;
4648
+ timestamp = ts;
4649
+ isoString = this.formatDateToISO(strictDate);
4650
+ isValid = true;
4651
+ }
4652
+ }
4653
+ }
4654
+ }
4655
+ return {
4656
+ formatted,
4657
+ rawValue: isoString || "",
4658
+ isoString,
4659
+ date,
4660
+ timestamp,
4661
+ parts,
4662
+ isComplete,
4663
+ isValid,
4664
+ totalSlots,
4665
+ filledSlots
4666
+ };
4667
+ }
4668
+ /**
4669
+ * Calcule la nouvelle position du curseur en préservant le nombre de caractères bruts avant lui.
4670
+ */
4671
+ mapCursorPosition(inputValue, inputCursor, formatted) {
4672
+ const minPos = this.prefixSlotsCount;
4673
+ const safeInput = String(inputValue ?? "");
4674
+ const safeFormatted = String(formatted ?? "");
4675
+ if (inputCursor <= 0 || !safeFormatted) return minPos;
4676
+ const rawBeforeCursor = this.extractRaw(safeInput.slice(0, inputCursor), false);
4677
+ const targetRawCount = rawBeforeCursor.length;
4678
+ if (targetRawCount === 0) {
4679
+ return Math.max(minPos, Math.min(this.getNextEditablePosition(0), safeFormatted.length));
4680
+ }
4681
+ let currentRawCount = 0;
4682
+ let targetPos = safeFormatted.length;
4683
+ for (let i = 0; i < safeFormatted.length && i < this.slots.length; i++) {
4684
+ if (!this.slots[i].isStatic) {
4685
+ currentRawCount++;
4686
+ if (currentRawCount === targetRawCount) {
4687
+ targetPos = i + 1;
4688
+ break;
4689
+ }
4690
+ }
4691
+ }
4692
+ while (targetPos < safeFormatted.length && this.slots[targetPos] && this.slots[targetPos].isStatic) {
4693
+ targetPos++;
4694
+ }
4695
+ return Math.max(minPos, Math.min(targetPos, safeFormatted.length));
4696
+ }
4697
+ /**
4698
+ * Gère la frappe d'un séparateur au clavier segment par segment (ex: '5' + '/' -> '05/', '5' + '.' -> '05. ').
4699
+ * Résout atomiquement les séparateurs composites ('DD. MM. YYYY HH:mm') sans jamais dédoubler l'espace.
4700
+ */
4701
+ tryHandleSeparatorKey(currentValue, cursor, key) {
4702
+ const none = { handled: false, formatted: currentValue, cursor };
4703
+ if (!key || key.length !== 1) return none;
4704
+ if (cursor < this.slots.length && this.slots[cursor].isStatic && this.separatorMatchesKey(this.slots[cursor].char, key)) {
4705
+ const nextEditable = this.getNextEditablePosition(cursor + 1);
4706
+ const formatted = this.format(currentValue);
4707
+ return { handled: true, formatted, cursor: Math.min(nextEditable, formatted.length) };
4708
+ }
4709
+ if (cursor > this.prefixSlotsCount && cursor - 1 < this.slots.length && this.slots[cursor - 1].isStatic) {
4710
+ let k = cursor - 1;
4711
+ while (k >= this.prefixSlotsCount && this.slots[k].isStatic) {
4712
+ if (this.separatorMatchesKey(this.slots[k].char, key)) {
4713
+ const nextEditable = this.getNextEditablePosition(k + 1);
4714
+ const formatted = this.format(currentValue);
4715
+ return { handled: true, formatted, cursor: Math.min(nextEditable, formatted.length) };
4716
+ }
4717
+ k--;
4718
+ }
4719
+ }
4720
+ let segIdx = -1;
4721
+ for (let i = 0; i < this.segments.length; i++) {
4722
+ const seg2 = this.segments[i];
4723
+ if (cursor >= seg2.start && cursor <= seg2.end) {
4724
+ segIdx = i;
4725
+ break;
4726
+ }
4727
+ }
4728
+ if (segIdx === -1) return none;
4729
+ const seg = this.segments[segIdx];
4730
+ if (!seg.followingSeparator) return none;
4731
+ if (!this.followingSeparatorMatchesKey(seg.followingSeparator, key)) {
4732
+ return none;
4733
+ }
4734
+ const rawInSeg = currentValue.slice(seg.start, Math.min(cursor, seg.end)).replace(/\D/g, "");
4735
+ if (seg.kind !== "YYYY" && seg.kind !== "A" && rawInSeg.length > 0 && rawInSeg.length < seg.length) {
4736
+ const paddedSeg = "0".repeat(seg.length - rawInSeg.length) + rawInSeg;
4737
+ const tail = currentValue.slice(Math.min(currentValue.length, seg.end));
4738
+ const candidate = currentValue.slice(0, seg.start) + paddedSeg + seg.followingSeparator + tail;
4739
+ const formatted = this.format(candidate);
4740
+ const nextEditable = this.getNextEditablePosition(seg.end);
4741
+ return { handled: true, formatted, cursor: Math.min(nextEditable, formatted.length) };
4742
+ }
4743
+ if (cursor === seg.end) {
4744
+ const formatted = this.format(currentValue);
4745
+ const nextEditable = this.getNextEditablePosition(seg.end);
4746
+ return { handled: true, formatted, cursor: Math.min(nextEditable, formatted.length) };
4747
+ }
4748
+ return none;
4749
+ }
4750
+ /**
4751
+ * Formate un Date, timestamp numérique, ISO string ou valeur partielle vers le gabarit configuré.
4752
+ * Immunisé contre Invalid Date et NaN.
4753
+ */
4754
+ formatFromValue(value) {
4755
+ if (value === null || value === void 0) return this.prefixString;
4756
+ if (value instanceof Date) {
4757
+ if (Number.isNaN(value.getTime())) return this.prefixString;
4758
+ return this.formatPartsToTemplate(this.dateToUTCParts(value));
4759
+ }
4760
+ if (typeof value === "number") {
4761
+ if (!Number.isFinite(value)) return this.prefixString;
4762
+ const d = new Date(value);
4763
+ if (Number.isNaN(d.getTime())) return this.prefixString;
4764
+ return this.formatPartsToTemplate(this.dateToUTCParts(d));
4765
+ }
4766
+ const str = String(value).slice(0, MAX_INPUT_LENGTH).trim();
4767
+ if (!str) return this.prefixString;
4768
+ const pasted = this.parsePasted(str);
4769
+ if (pasted.matched) {
4770
+ return pasted.formatted;
4771
+ }
4772
+ if (pasted.rejected) {
4773
+ return this.prefixString;
4774
+ }
4775
+ return this.format(str, true);
4776
+ }
4777
+ /**
4778
+ * Formate une chaîne issue d'une affectation native (input.value = '...') sans altérer la frappe
4779
+ * en cours par le parseur segmenté (seul un ISO 8601 complet avec horaire est reconnu).
4780
+ */
4781
+ formatFromNativeValue(strVal) {
4782
+ const str = String(strVal ?? "").slice(0, MAX_INPUT_LENGTH);
4783
+ if (!str) return this.prefixString;
4784
+ const trimmed = str.trim();
4785
+ if (trimmed.length >= 16) {
4786
+ const iso = this.parseISO8601Linear(trimmed);
4787
+ if (iso && !iso.dateOnly) {
4788
+ const res = this.parsePasted(trimmed);
4789
+ if (res.matched) return res.formatted;
4790
+ }
4791
+ }
4792
+ return this.format(str, false);
4793
+ }
4794
+ /**
4795
+ * Parse universellement une chaîne collée en O(N) :
4796
+ * 1) ISO 8601 (YYYY-MM-DD[T| ]HH:mm[:ss][.sss][Z|±HH:MM], date seule)
4797
+ * 2) Format configuré de l'instance avec tolérance des segments courts (ex: 2/3/2026 9:5)
4798
+ */
4799
+ parsePasted(rawText) {
4800
+ const fail = { matched: false, formatted: "", cursor: 0 };
4801
+ const rejected = { matched: false, rejected: true, formatted: "", cursor: 0 };
4802
+ const text = String(rawText ?? "").slice(0, MAX_INPUT_LENGTH).trim();
4803
+ if (!text || this.segments.length === 0) return fail;
4804
+ const looksLikeIso = text.length >= 10 && isAsciiDigit(text[0]) && isAsciiDigit(text[1]) && isAsciiDigit(text[2]) && isAsciiDigit(text[3]) && text[4] === "-" && isAsciiDigit(text[5]) && isAsciiDigit(text[6]) && text[7] === "-" && isAsciiDigit(text[8]) && isAsciiDigit(text[9]);
4805
+ const iso = this.parseISO8601Linear(text);
4806
+ if (iso) {
4807
+ if (iso.dateOnly) {
4808
+ return this.formatDateOnlyMatch(
4809
+ { year: iso.year, month: iso.month, day: iso.day },
4810
+ rejected
4811
+ );
4812
+ }
4813
+ if (iso.offsetMinutes !== null && iso.offsetMinutes !== 0 && !this.convertPastedOffset) {
4814
+ return rejected;
4815
+ }
4816
+ const baseDate = this.buildStrictUTCDate({
4817
+ year: iso.year,
4818
+ month: iso.month,
4819
+ day: iso.day,
4820
+ hour: iso.hour,
4821
+ minute: iso.minute,
4822
+ second: iso.second
4823
+ });
4824
+ if (!baseDate) return rejected;
4825
+ let targetDate = baseDate;
4826
+ let offsetConverted;
4827
+ if (iso.offsetMinutes !== null && iso.offsetMinutes !== 0) {
4828
+ const utcMs = baseDate.getTime() - iso.offsetMinutes * 6e4;
4829
+ targetDate = new Date(utcMs);
4830
+ if (Number.isNaN(targetDate.getTime())) return rejected;
4831
+ offsetConverted = {
4832
+ original: text,
4833
+ offsetMinutes: iso.offsetMinutes,
4834
+ utcIso: this.formatDateToISO(targetDate)
4835
+ };
4836
+ }
4837
+ const formatted = this.formatPartsToTemplate(this.dateToUTCParts(targetDate));
4838
+ return {
4839
+ matched: true,
4840
+ formatted,
4841
+ cursor: formatted.length,
4842
+ offsetConverted
4843
+ };
4844
+ }
4845
+ if (looksLikeIso && text.length > 10 && (text[10] === "T" || text[10] === "t" || this.segments[0]?.kind !== "YYYY")) {
4846
+ return rejected;
4847
+ }
4848
+ return this.parseConfiguredFormatLinear(text);
4849
+ }
4850
+ /**
4851
+ * Formate une date UTC valide dans la locale demandée via Intl.DateTimeFormat (aperçu miroir).
4852
+ */
4853
+ formatLocal(date, locale, intlOptions) {
4854
+ if (!date || Number.isNaN(date.getTime())) return null;
4855
+ try {
4856
+ const opts = intlOptions || {
4857
+ dateStyle: "short",
4858
+ timeStyle: "medium"
4859
+ };
4860
+ return new Intl.DateTimeFormat(locale, opts).format(date);
4861
+ } catch {
4862
+ return null;
4863
+ }
4864
+ }
4865
+ // ==========================================================================
4866
+ // Helpers internes purs
4867
+ // ==========================================================================
4868
+ normalizeBoundary(val) {
4869
+ if (val === null || val === void 0) return null;
4870
+ if (val instanceof Date) {
4871
+ const t = val.getTime();
4872
+ return Number.isNaN(t) ? null : t;
4873
+ }
4874
+ if (typeof val === "number") {
4875
+ return Number.isFinite(val) ? val : null;
4876
+ }
4877
+ const str = String(val).slice(0, MAX_INPUT_LENGTH).trim();
4878
+ if (!str) return null;
4879
+ const iso = this.parseISO8601Linear(str);
4880
+ if (iso) {
4881
+ const d = this.buildStrictUTCDate({
4882
+ year: iso.year,
4883
+ month: iso.month,
4884
+ day: iso.day,
4885
+ hour: iso.hour,
4886
+ minute: iso.minute,
4887
+ second: iso.second
4888
+ });
4889
+ if (!d) return null;
4890
+ const offsetMs = iso.offsetMinutes ? iso.offsetMinutes * 6e4 : 0;
4891
+ return d.getTime() - offsetMs;
4892
+ }
4893
+ const res = this.analyze(str, true);
4894
+ return res.timestamp;
4895
+ }
4896
+ separatorMatchesKey(sepChar, key) {
4897
+ if (sepChar === key) return true;
4898
+ if ((sepChar === "T" || sepChar === "t") && (key === "T" || key === "t" || key === " ")) {
4899
+ return true;
4900
+ }
4901
+ return false;
4902
+ }
4903
+ followingSeparatorMatchesKey(followingSep, key) {
4904
+ let hasNonSpace = false;
4905
+ for (let i = 0; i < followingSep.length; i++) {
4906
+ if (followingSep[i] !== " ") {
4907
+ hasNonSpace = true;
4908
+ break;
4909
+ }
4910
+ }
4911
+ for (let i = 0; i < followingSep.length; i++) {
4912
+ const ch = followingSep[i];
4913
+ if (hasNonSpace && ch === " ") {
4914
+ continue;
4915
+ }
4916
+ if (this.separatorMatchesKey(ch, key)) return true;
4917
+ }
4918
+ return false;
4919
+ }
4920
+ formatFromCleanRaw(cleanRaw) {
4921
+ if (this.slots.length === 0) return "";
4922
+ if (cleanRaw.length === 0) return this.prefixString;
4923
+ let formatted = "";
4924
+ let rawIdx = 0;
4925
+ for (let i = 0; i < this.slots.length; i++) {
4926
+ const slot = this.slots[i];
4927
+ if (slot.isStatic) {
4928
+ const hasRemainingRaw = rawIdx < cleanRaw.length;
4929
+ const isPrefix = rawIdx === 0 && slot.isPrefix;
4930
+ const isCompletedSegmentTrailingSep = rawIdx > 0 && rawIdx === cleanRaw.length;
4931
+ if (hasRemainingRaw || isPrefix || isCompletedSegmentTrailingSep) {
4932
+ formatted += slot.char;
4933
+ } else {
4934
+ break;
4935
+ }
4936
+ } else if (rawIdx < cleanRaw.length) {
4937
+ formatted += cleanRaw[rawIdx];
4938
+ rawIdx++;
4939
+ } else {
4940
+ break;
4941
+ }
4942
+ }
4943
+ return formatted;
4944
+ }
4945
+ extractSegmentValues(cleanRaw) {
4946
+ const parts = {};
4947
+ let hour12;
4948
+ let meridiem;
4949
+ let rawOffset = 0;
4950
+ let allPresent = true;
4951
+ for (const seg of this.segments) {
4952
+ if (rawOffset + seg.length > cleanRaw.length) {
4953
+ allPresent = false;
4954
+ break;
4955
+ }
4956
+ const chunk = cleanRaw.slice(rawOffset, rawOffset + seg.length);
4957
+ rawOffset += seg.length;
4958
+ switch (seg.kind) {
4959
+ case "YYYY":
4960
+ parts.year = parseAsciiInt(chunk);
4961
+ break;
4962
+ case "MM":
4963
+ parts.month = parseAsciiInt(chunk);
4964
+ break;
4965
+ case "DD":
4966
+ parts.day = parseAsciiInt(chunk);
4967
+ break;
4968
+ case "HH":
4969
+ parts.hour = parseAsciiInt(chunk);
4970
+ break;
4971
+ case "hh":
4972
+ hour12 = parseAsciiInt(chunk);
4973
+ break;
4974
+ case "mm":
4975
+ parts.minute = parseAsciiInt(chunk);
4976
+ break;
4977
+ case "ss":
4978
+ parts.second = parseAsciiInt(chunk);
4979
+ break;
4980
+ case "A":
4981
+ if (chunk === "AM" || chunk === "PM") {
4982
+ meridiem = chunk;
4983
+ } else {
4984
+ allPresent = false;
4985
+ }
4986
+ break;
4987
+ }
4988
+ }
4989
+ if (parts.year === void 0 || parts.month === void 0 || parts.day === void 0) {
4990
+ allPresent = false;
4991
+ }
4992
+ if (parts.hour === void 0 && hour12 === void 0) {
4993
+ allPresent = false;
4994
+ }
4995
+ if (allPresent && hour12 !== void 0) {
4996
+ const resolved = this.resolveHour24({ parts, hour12, meridiem });
4997
+ if (resolved !== null) {
4998
+ parts.hour = resolved;
4999
+ }
5000
+ }
5001
+ return { parts, hour12, meridiem, allSegmentsPresent: allPresent };
5002
+ }
5003
+ resolveHour24(extracted) {
5004
+ if (extracted.hour12 !== void 0) {
5005
+ const h12 = extracted.hour12;
5006
+ if (h12 < 1 || h12 > 12 || !extracted.meridiem) return null;
5007
+ if (extracted.meridiem === "AM") {
5008
+ return h12 === 12 ? 0 : h12;
5009
+ }
5010
+ return h12 === 12 ? 12 : h12 + 12;
5011
+ }
5012
+ if (extracted.parts.hour !== void 0) {
5013
+ return extracted.parts.hour >= 0 && extracted.parts.hour <= 23 ? extracted.parts.hour : null;
5014
+ }
5015
+ return null;
5016
+ }
5017
+ /**
5018
+ * Validation calendaire stricte sans rollover ni piège Date.UTC(0..99).
5019
+ */
5020
+ buildStrictUTCDate(parts) {
5021
+ const { year, month, day, hour, minute, second } = parts;
5022
+ if (!Number.isInteger(year) || year < 1 || year > 9999 || !Number.isInteger(month) || month < 1 || month > 12 || !Number.isInteger(day) || day < 1 || day > 31 || !Number.isInteger(hour) || hour < 0 || hour > 23 || !Number.isInteger(minute) || minute < 0 || minute > 59 || !Number.isInteger(second) || second < 0 || second > 59) {
5023
+ return null;
5024
+ }
5025
+ const d = /* @__PURE__ */ new Date(0);
5026
+ d.setUTCFullYear(year, month - 1, day);
5027
+ d.setUTCHours(hour, minute, second, 0);
5028
+ if (d.getUTCFullYear() !== year || d.getUTCMonth() !== month - 1 || d.getUTCDate() !== day || d.getUTCHours() !== hour || d.getUTCMinutes() !== minute || d.getUTCSeconds() !== second) {
5029
+ return null;
5030
+ }
5031
+ return d;
5032
+ }
5033
+ dateToUTCParts(d) {
5034
+ return {
5035
+ year: d.getUTCFullYear(),
5036
+ month: d.getUTCMonth() + 1,
5037
+ day: d.getUTCDate(),
5038
+ hour: d.getUTCHours(),
5039
+ minute: d.getUTCMinutes(),
5040
+ second: d.getUTCSeconds()
5041
+ };
5042
+ }
5043
+ formatDateToISO(d) {
5044
+ const y = String(d.getUTCFullYear()).padStart(4, "0");
5045
+ const m = String(d.getUTCMonth() + 1).padStart(2, "0");
5046
+ const day = String(d.getUTCDate()).padStart(2, "0");
5047
+ const h = String(d.getUTCHours()).padStart(2, "0");
5048
+ const min = String(d.getUTCMinutes()).padStart(2, "0");
5049
+ const s = String(d.getUTCSeconds()).padStart(2, "0");
5050
+ if (this.includeMilliseconds) {
5051
+ const ms = String(d.getUTCMilliseconds()).padStart(3, "0");
5052
+ return `${y}-${m}-${day}T${h}:${min}:${s}.${ms}Z`;
5053
+ }
5054
+ return `${y}-${m}-${day}T${h}:${min}:${s}Z`;
5055
+ }
5056
+ formatPartsToTemplate(parts) {
5057
+ let raw = "";
5058
+ for (const seg of this.segments) {
5059
+ switch (seg.kind) {
5060
+ case "YYYY":
5061
+ raw += String(parts.year).padStart(4, "0").slice(-4);
5062
+ break;
5063
+ case "MM":
5064
+ raw += String(parts.month).padStart(2, "0");
5065
+ break;
5066
+ case "DD":
5067
+ raw += String(parts.day).padStart(2, "0");
5068
+ break;
5069
+ case "HH":
5070
+ raw += String(parts.hour).padStart(2, "0");
5071
+ break;
5072
+ case "hh": {
5073
+ const h12 = parts.hour % 12 === 0 ? 12 : parts.hour % 12;
5074
+ raw += String(h12).padStart(2, "0");
5075
+ break;
5076
+ }
5077
+ case "mm":
5078
+ raw += String(parts.minute).padStart(2, "0");
5079
+ break;
5080
+ case "ss":
5081
+ raw += String(parts.second).padStart(2, "0");
5082
+ break;
5083
+ case "A":
5084
+ raw += parts.hour >= 12 ? "PM" : "AM";
5085
+ break;
5086
+ }
5087
+ }
5088
+ return this.formatFromCleanRaw(raw);
5089
+ }
5090
+ formatDateOnlyMatch(dateParts, fail) {
5091
+ const check = this.buildStrictUTCDate({
5092
+ year: dateParts.year,
5093
+ month: dateParts.month,
5094
+ day: dateParts.day,
5095
+ hour: 0,
5096
+ minute: 0,
5097
+ second: 0
5098
+ });
5099
+ if (!check) return fail;
5100
+ if (typeof this.defaultTimeOnDateOnly === "string" && this.defaultTimeOnDateOnly.trim()) {
5101
+ const parsedTime = this.parseDefaultTime(this.defaultTimeOnDateOnly.trim());
5102
+ if (parsedTime) {
5103
+ const formatted2 = this.formatPartsToTemplate({
5104
+ ...dateParts,
5105
+ hour: parsedTime.hour,
5106
+ minute: parsedTime.minute,
5107
+ second: parsedTime.second
5108
+ });
5109
+ return { matched: true, formatted: formatted2, cursor: formatted2.length };
5110
+ }
5111
+ }
5112
+ let rawDate = "";
5113
+ for (const seg of this.segments) {
5114
+ if (TIME_TOKEN_KINDS.has(seg.kind)) break;
5115
+ if (seg.kind === "YYYY") rawDate += String(dateParts.year).padStart(4, "0");
5116
+ else if (seg.kind === "MM") rawDate += String(dateParts.month).padStart(2, "0");
5117
+ else if (seg.kind === "DD") rawDate += String(dateParts.day).padStart(2, "0");
5118
+ }
5119
+ if (!rawDate) return fail;
5120
+ const formatted = this.formatFromCleanRaw(rawDate);
5121
+ return { matched: true, formatted, cursor: formatted.length };
5122
+ }
5123
+ parseDefaultTime(timeStr) {
5124
+ const parts = timeStr.split(":");
5125
+ if (parts.length < 2 || parts.length > 3) return null;
5126
+ const hour = parseAsciiInt(parts[0]);
5127
+ const minute = parseAsciiInt(parts[1]);
5128
+ const second = parts.length === 3 ? parseAsciiInt(parts[2]) : 0;
5129
+ if (Number.isNaN(hour) || hour < 0 || hour > 23 || Number.isNaN(minute) || minute < 0 || minute > 59 || Number.isNaN(second) || second < 0 || second > 59) {
5130
+ return null;
5131
+ }
5132
+ return { hour, minute, second };
5133
+ }
5134
+ /**
5135
+ * Parseur ISO 8601 strict en complexité linéaire O(N) sans regex à backtracking.
5136
+ */
5137
+ parseISO8601Linear(str) {
5138
+ if (str.length < 10) return null;
5139
+ for (const idx of [0, 1, 2, 3, 5, 6, 8, 9]) {
5140
+ if (!isAsciiDigit(str[idx])) return null;
5141
+ }
5142
+ if (str[4] !== "-" || str[7] !== "-") return null;
5143
+ const year = parseAsciiInt(str.slice(0, 4));
5144
+ const month = parseAsciiInt(str.slice(5, 7));
5145
+ const day = parseAsciiInt(str.slice(8, 10));
5146
+ if (str.length === 10) {
5147
+ return { year, month, day, hour: 0, minute: 0, second: 0, dateOnly: true, offsetMinutes: null };
5148
+ }
5149
+ let pos = 10;
5150
+ if (str[pos] !== "T" && str[pos] !== "t" && str[pos] !== " ") return null;
5151
+ pos++;
5152
+ if (pos + 5 > str.length) return null;
5153
+ if (!isAsciiDigit(str[pos]) || !isAsciiDigit(str[pos + 1]) || str[pos + 2] !== ":" || !isAsciiDigit(str[pos + 3]) || !isAsciiDigit(str[pos + 4])) {
5154
+ return null;
5155
+ }
5156
+ const hour = parseAsciiInt(str.slice(pos, pos + 2));
5157
+ const minute = parseAsciiInt(str.slice(pos + 3, pos + 5));
5158
+ pos += 5;
5159
+ let second = 0;
5160
+ if (pos < str.length && str[pos] === ":") {
5161
+ pos++;
5162
+ if (pos + 2 > str.length || !isAsciiDigit(str[pos]) || !isAsciiDigit(str[pos + 1])) return null;
5163
+ second = parseAsciiInt(str.slice(pos, pos + 2));
5164
+ pos += 2;
5165
+ }
5166
+ if (pos < str.length && str[pos] === ".") {
5167
+ pos++;
5168
+ const fracStart = pos;
5169
+ while (pos < str.length && isAsciiDigit(str[pos])) {
5170
+ pos++;
5171
+ }
5172
+ if (pos === fracStart) return null;
5173
+ }
5174
+ let offsetMinutes = null;
5175
+ if (pos < str.length) {
5176
+ while (pos < str.length && str[pos] === " ") pos++;
5177
+ if (pos < str.length) {
5178
+ const tzChar = str[pos];
5179
+ if (tzChar === "Z" || tzChar === "z") {
5180
+ offsetMinutes = 0;
5181
+ pos++;
5182
+ } else if (tzChar === "+" || tzChar === "-") {
5183
+ const sign = tzChar === "-" ? -1 : 1;
5184
+ pos++;
5185
+ if (pos + 2 > str.length || !isAsciiDigit(str[pos]) || !isAsciiDigit(str[pos + 1])) return null;
5186
+ const offH = parseAsciiInt(str.slice(pos, pos + 2));
5187
+ pos += 2;
5188
+ let offM = 0;
5189
+ if (pos < str.length) {
5190
+ if (str[pos] === ":") pos++;
5191
+ if (pos + 2 > str.length || !isAsciiDigit(str[pos]) || !isAsciiDigit(str[pos + 1])) return null;
5192
+ offM = parseAsciiInt(str.slice(pos, pos + 2));
5193
+ pos += 2;
5194
+ }
5195
+ if (offH > 14 || offM > 59 || offH === 14 && offM !== 0) {
5196
+ return null;
5197
+ }
5198
+ offsetMinutes = sign * (offH * 60 + offM);
5199
+ } else if (str.slice(pos).toUpperCase() === "UTC") {
5200
+ offsetMinutes = 0;
5201
+ pos = str.length;
5202
+ } else {
5203
+ return null;
5204
+ }
5205
+ }
5206
+ }
5207
+ if (pos !== str.length) return null;
5208
+ return { year, month, day, hour, minute, second, dateOnly: false, offsetMinutes };
5209
+ }
5210
+ /**
5211
+ * Parseur segmenté O(N) aligné sur le gabarit configuré de l'instance.
5212
+ * Tolère les segments courts (ex: 2/3/2026 9:5 ou 2. 3. 2026 9:5 ou 2/3-2026 9:5 pm)
5213
+ * sans deviner sur les dates ambiguës (03/04/2026 suit strictement l'ordre configuré).
5214
+ */
5215
+ parseConfiguredFormatLinear(text) {
5216
+ const fail = { matched: false, formatted: "", cursor: 0 };
5217
+ let cleaned = text;
5218
+ if (cleaned.toUpperCase().endsWith(" UTC")) {
5219
+ cleaned = cleaned.slice(0, -4).trim();
5220
+ } else if (cleaned.length > 2 && (cleaned.endsWith("Z") || cleaned.endsWith("z")) && isAsciiDigit(cleaned[cleaned.length - 2])) {
5221
+ cleaned = cleaned.slice(0, -1).trim();
5222
+ }
5223
+ if (this.prefixString && cleaned.toLowerCase().startsWith(this.prefixString.trim().toLowerCase())) {
5224
+ cleaned = cleaned.slice(this.prefixString.trim().length).trim();
5225
+ }
5226
+ const tokens = [];
5227
+ let start = -1;
5228
+ for (let i = 0; i < cleaned.length; i++) {
5229
+ const ch = cleaned[i];
5230
+ if (DATE_SEPARATORS.has(ch)) {
5231
+ if (start !== -1) {
5232
+ tokens.push(cleaned.slice(start, i));
5233
+ start = -1;
5234
+ }
5235
+ } else {
5236
+ if (start === -1) start = i;
5237
+ }
5238
+ }
5239
+ if (start !== -1) {
5240
+ tokens.push(cleaned.slice(start));
5241
+ }
5242
+ if (tokens.length === 0 || tokens.length > this.segments.length) return fail;
5243
+ let dateSegCount = 0;
5244
+ for (const seg of this.segments) {
5245
+ if (TIME_TOKEN_KINDS.has(seg.kind)) break;
5246
+ dateSegCount++;
5247
+ }
5248
+ const rawParts = [];
5249
+ let yearVal;
5250
+ let monthVal;
5251
+ let dayVal;
5252
+ for (let i = 0; i < tokens.length; i++) {
5253
+ const tok = tokens[i];
5254
+ const seg = this.segments[i];
5255
+ if (seg.kind === "A") {
5256
+ const up = tok.toUpperCase();
5257
+ if (up === "AM" || up === "A") rawParts.push("AM");
5258
+ else if (up === "PM" || up === "P") rawParts.push("PM");
5259
+ else return fail;
5260
+ continue;
5261
+ }
5262
+ for (let k = 0; k < tok.length; k++) {
5263
+ if (!isAsciiDigit(tok[k])) return fail;
5264
+ }
5265
+ if (seg.kind === "YYYY") {
5266
+ if (tok.length !== 4) return fail;
5267
+ yearVal = parseAsciiInt(tok);
5268
+ rawParts.push(tok);
5269
+ } else {
5270
+ if (tok.length < 1 || tok.length > 2) return fail;
5271
+ const padded = tok.length === 1 ? "0" + tok : tok;
5272
+ const val = parseAsciiInt(padded);
5273
+ if (seg.kind === "MM") monthVal = val;
5274
+ if (seg.kind === "DD") dayVal = val;
5275
+ rawParts.push(padded);
5276
+ }
5277
+ }
5278
+ if (tokens.length === dateSegCount && yearVal !== void 0 && monthVal !== void 0 && dayVal !== void 0) {
5279
+ return this.formatDateOnlyMatch({ year: yearVal, month: monthVal, day: dayVal }, fail);
5280
+ }
5281
+ const minRequired = this.segments.length;
5282
+ if (tokens.length < minRequired) {
5283
+ const hasMinDateAndHourMin = dateSegCount > 0 && tokens.length >= dateSegCount + 2 && this.segments[dateSegCount + 1]?.kind === "mm";
5284
+ if (!hasMinDateAndHourMin) return fail;
5285
+ }
5286
+ const formatted = this.formatFromCleanRaw(rawParts.join(""));
5287
+ return {
5288
+ matched: true,
5289
+ formatted,
5290
+ cursor: formatted.length
5291
+ };
5292
+ }
5293
+ };
5294
+
5295
+ // src/mask/InputDateUTCMask.ts
5296
+ var MAX_NOTIFICATION_ITERATIONS3 = 10;
5297
+ var InputDateUTCMask = class extends BaseInputMask {
5298
+ engine;
5299
+ history;
5300
+ isComposing = false;
5301
+ isUndoingRedoing = false;
5302
+ isMouseDown = false;
5303
+ isApplying = false;
5304
+ isNotifying = false;
5305
+ hasPendingNotification = false;
5306
+ lastValue = "";
5307
+ lastValueLength = 0;
5308
+ lastInputType = "";
5309
+ inferredInputModeValue = null;
5310
+ wasAutocorrectSet = false;
5311
+ wasAutocapitalizeSet = false;
5312
+ wasSpellcheckSet = false;
5313
+ cutTimerId = null;
5314
+ pasteTimerId = null;
5315
+ resetTimerId = null;
5316
+ constructor(targetOrWrapper, inputOrOptions, options) {
5317
+ const args = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, options);
5318
+ const wrap = args.wrapper;
5319
+ const inp = args.input;
5320
+ const opts = args.options;
5321
+ const attrFormat = wrap?.getAttribute("data-mask-format") || inp?.getAttribute("data-mask-format") || void 0;
5322
+ const attrUtcIndicator = wrap?.getAttribute("data-mask-utc-indicator") ?? inp?.getAttribute("data-mask-utc-indicator");
5323
+ const attrInfer = wrap?.getAttribute("data-mask-infer-inputmode") ?? inp?.getAttribute("data-mask-infer-inputmode");
5324
+ const resolvedUtcIndicator = opts.utcIndicator !== void 0 ? opts.utcIndicator : attrUtcIndicator !== null ? attrUtcIndicator === "false" || attrUtcIndicator === "none" ? false : attrUtcIndicator : " UTC";
5325
+ const resolvedOptions = {
5326
+ ...opts,
5327
+ format: opts.format ?? attrFormat ?? "YYYY-MM-DD HH:mm",
5328
+ utcIndicator: resolvedUtcIndicator,
5329
+ includeMilliseconds: opts.includeMilliseconds ?? false,
5330
+ convertPastedOffset: opts.convertPastedOffset ?? true,
5331
+ defaultTimeOnDateOnly: opts.defaultTimeOnDateOnly ?? false,
5332
+ inferInputMode: opts.inferInputMode ?? (attrInfer !== null ? attrInfer !== "false" : true),
5333
+ onInput: opts.onInput || opts.oninput,
5334
+ onChange: opts.onChange || opts.onchange,
5335
+ onComplete: opts.onComplete || opts.oncomplete
5336
+ };
5337
+ super(wrap, inp, resolvedOptions);
5338
+ this.history = new MaskHistory();
5339
+ this.engine = new DateUTCEngine(this.options);
5340
+ if (!this.input.hasAttribute("autocorrect")) {
5341
+ this.input.setAttribute("autocorrect", "off");
5342
+ this.wasAutocorrectSet = true;
5343
+ }
5344
+ if (!this.input.hasAttribute("autocapitalize")) {
5345
+ this.input.setAttribute("autocapitalize", "none");
5346
+ this.wasAutocapitalizeSet = true;
5347
+ }
5348
+ if (!this.input.hasAttribute("spellcheck")) {
5349
+ this.input.setAttribute("spellcheck", "false");
5350
+ this.wasSpellcheckSet = true;
5351
+ }
5352
+ this.syncInferredInputMode();
5353
+ this.bindEvents();
5354
+ this.lastValue = this.isSensitiveField() ? this.computePasswordDigest(this.input.value) : this.input.value;
5355
+ this.syncInitialValue();
5356
+ this.runAuditWarning(this.options.audit);
5357
+ }
5358
+ /**
5359
+ * Formate statiquement une date (Date, timestamp ms, ISO ou chaîne) sans DOM.
5360
+ */
5361
+ static format(value, options = {}) {
5362
+ return DateUTCEngine.format(value, options);
5363
+ }
5364
+ getSpecificAuditWarnings() {
5365
+ const warnings = [];
5366
+ const describedbyWarnings = [];
5367
+ const hasValidDescribedby = this.checkAriaIdReferences(this.input, "aria-describedby", describedbyWarnings, true);
5368
+ const hasPlaceholder = Boolean(this.input.getAttribute("placeholder")?.trim());
5369
+ const hasAriaPlaceholder = Boolean(this.input.getAttribute("aria-placeholder")?.trim());
5370
+ if (!hasValidDescribedby && !hasAriaPlaceholder && !this.options.disabled) {
5371
+ if (hasPlaceholder) {
5372
+ warnings.push(
5373
+ `Indication du format UTC fragile : placeholder seul dispara\xEEt \xE0 la saisie et l'indicateur UTC fant\xF4me est aria-hidden="true" ; d\xE9finissez aria-describedby ou aria-placeholder (WCAG 3.3.2).`
5374
+ );
5375
+ } else {
5376
+ warnings.push(
5377
+ "Indication du format UTC attendu manquante : d\xE9finissez aria-describedby ou aria-placeholder pour informer les technologies d'assistance du format et du r\xE9f\xE9rentiel UTC (WCAG 3.3.2)."
5378
+ );
5379
+ }
5380
+ }
5381
+ return warnings;
5382
+ }
5383
+ extractRawSnippet(snippet) {
5384
+ if (!snippet) return "";
5385
+ if (snippet === this.input.value && this.isValid()) {
5386
+ return this.getRawValue();
5387
+ }
5388
+ return this.engine.extractRaw(snippet, false);
5389
+ }
5390
+ onPasswordModeDetected() {
5391
+ this.history.clear();
5392
+ this.lastValue = "";
5393
+ this.lastValueLength = 0;
5394
+ this.lastTrackedValue = "";
5395
+ this.clearGhost();
5396
+ }
5397
+ onNativeValueSet(strVal) {
5398
+ if (this.options.disabled) {
5399
+ this.checkValueChange(false);
5400
+ } else {
5401
+ const formatted = this.engine.formatFromNativeValue(strVal);
5402
+ this.applyFormatted(formatted, formatted.length, false);
5403
+ }
5404
+ }
5405
+ onDisabledChange(disabled) {
5406
+ if (disabled) {
5407
+ this.wrapper.classList.remove("is-complete", "has-selection");
5408
+ this.clearGhost();
5409
+ this.checkValueChange(false);
5410
+ } else {
5411
+ const formatted = this.engine.formatFromValue(this.input.value);
5412
+ this.applyFormatted(formatted, this.input.selectionStart ?? formatted.length, false);
5413
+ }
5414
+ this.syncInferredInputMode();
5415
+ }
5416
+ handleAttributeMutation(attrName) {
5417
+ super.handleAttributeMutation(attrName);
5418
+ if (attrName === "data-mask-format") {
5419
+ const newFormat = this.getAttr("data-mask-format");
5420
+ if (newFormat && newFormat !== this.engine.getFormat()) {
5421
+ this.setFormat(newFormat);
5422
+ }
5423
+ } else if (attrName === "data-mask-utc-indicator") {
5424
+ const attrInd = this.getAttr("data-mask-utc-indicator");
5425
+ const indicator = attrInd === null || attrInd === "false" || attrInd === "none" ? false : attrInd;
5426
+ this.setUtcIndicator(indicator);
5427
+ } else if (attrName === "placeholder") {
5428
+ this.updateGhost(this.input.value);
5429
+ }
5430
+ }
5431
+ bindEvents() {
5432
+ this.onBeforeInput = this.onBeforeInput.bind(this);
5433
+ this.handleInput = this.handleInput.bind(this);
5434
+ this.onKeyDown = this.onKeyDown.bind(this);
5435
+ this.onPaste = this.onPaste.bind(this);
5436
+ this.onFocus = this.onFocus.bind(this);
5437
+ this.onBlur = this.onBlur.bind(this);
5438
+ this.onClick = this.onClick.bind(this);
5439
+ this.onKeyUp = this.onKeyUp.bind(this);
5440
+ this.onSelect = this.onSelect.bind(this);
5441
+ this.onMouseDown = this.onMouseDown.bind(this);
5442
+ this.onMouseUp = this.onMouseUp.bind(this);
5443
+ this.onCompositionStart = this.onCompositionStart.bind(this);
5444
+ this.onCompositionEnd = this.onCompositionEnd.bind(this);
5445
+ this.onCutHandler = () => {
5446
+ if (this.cutTimerId !== null) clearTimeout(this.cutTimerId);
5447
+ this.cutTimerId = window.setTimeout(() => {
5448
+ this.cutTimerId = null;
5449
+ if (this.isDestroyed) return;
5450
+ if (this.options.disabled) {
5451
+ this.checkValueChange(false);
5452
+ } else {
5453
+ const cur = this.input.selectionStart ?? this.input.value.length;
5454
+ this.applyFormatted(this.input.value, cur, false);
5455
+ }
5456
+ }, 0);
5457
+ };
5458
+ const onChangeNative = () => {
5459
+ if (this.isDestroyed) return;
5460
+ this.checkValueChange(true, true);
5461
+ };
5462
+ const { signal } = this.abortController;
5463
+ this.input.addEventListener("beforeinput", this.onBeforeInput, { signal });
5464
+ this.input.addEventListener("input", this.handleInput, { signal });
5465
+ this.input.addEventListener("keydown", this.onKeyDown, { signal });
5466
+ this.input.addEventListener("paste", this.onPaste, { signal });
5467
+ this.input.addEventListener("focus", this.onFocus, { signal });
5468
+ this.input.addEventListener("blur", this.onBlur, { signal });
5469
+ this.input.addEventListener("click", this.onClick, { signal });
5470
+ this.input.addEventListener("keyup", this.onKeyUp, { signal });
5471
+ this.input.addEventListener("select", this.onSelect, { signal });
5472
+ this.input.addEventListener("mousedown", this.onMouseDown, { signal });
5473
+ window.addEventListener("mouseup", this.onMouseUp, { signal });
5474
+ this.input.addEventListener("compositionstart", this.onCompositionStart, { signal });
5475
+ this.input.addEventListener("compositionend", this.onCompositionEnd, { signal });
5476
+ this.input.addEventListener("scroll", this.onScroll, { passive: true, signal });
5477
+ this.input.addEventListener("cut", this.onCutHandler, { signal });
5478
+ this.input.addEventListener("change", onChangeNative, { signal });
5479
+ if (this.input.form) {
5480
+ this.onFormResetHandler = () => {
5481
+ if (this.resetTimerId !== null) clearTimeout(this.resetTimerId);
5482
+ this.resetTimerId = window.setTimeout(() => {
5483
+ this.resetTimerId = null;
5484
+ if (this.isDestroyed) return;
5485
+ if (this.options.disabled) {
5486
+ this.checkValueChange(false);
5487
+ } else {
5488
+ this.syncInitialValue();
5489
+ }
5490
+ }, 0);
5491
+ };
5492
+ this.input.form.addEventListener("reset", this.onFormResetHandler, { signal });
5493
+ }
5494
+ }
5495
+ syncInferredInputMode() {
5496
+ if (this.options.inferInputMode === false) return;
5497
+ if (this.options.disabled) {
5498
+ if (this.inferredInputModeValue && this.input.getAttribute("inputmode") === this.inferredInputModeValue) {
5499
+ this.input.removeAttribute("inputmode");
5500
+ }
5501
+ this.inferredInputModeValue = null;
5502
+ return;
5503
+ }
5504
+ const desired = this.engine.isNumericOnly() ? "numeric" : "text";
5505
+ const currentAttr = this.input.getAttribute("inputmode");
5506
+ if (!currentAttr || this.inferredInputModeValue === currentAttr) {
5507
+ this.input.inputMode = desired;
5508
+ this.inferredInputModeValue = desired;
5509
+ }
5510
+ }
5511
+ // ==========================================================================
5512
+ // API Publique
5513
+ // ==========================================================================
5514
+ getDetail() {
5515
+ const result = this.engine.analyze(this.input.value, false);
5516
+ return {
5517
+ ...result,
5518
+ value: this.options.disabled ? this.input.value : result.formatted
5519
+ };
5520
+ }
5521
+ getRawValue() {
5522
+ if (this.options.disabled) return this.input.value;
5523
+ return this.getDetail().rawValue;
5524
+ }
5525
+ getISOString() {
5526
+ return this.getDetail().isoString;
5527
+ }
5528
+ getDate() {
5529
+ return this.getDetail().date;
5530
+ }
5531
+ getTimestamp() {
5532
+ return this.getDetail().timestamp;
5533
+ }
5534
+ getParts() {
5535
+ return this.getDetail().parts;
5536
+ }
5537
+ /**
5538
+ * Progressive Enhancement Baseline : retourne un Temporal.Instant natif si supporté par le navigateur,
5539
+ * sinon null (zéro polyfill externe).
5540
+ */
5541
+ getTemporalInstant() {
5542
+ const ts = this.getTimestamp();
5543
+ if (ts === null) return null;
5544
+ const globalTemporal = globalThis.Temporal;
5545
+ if (globalTemporal?.Instant && typeof globalTemporal.Instant.fromEpochMilliseconds === "function") {
5546
+ try {
5547
+ return globalTemporal.Instant.fromEpochMilliseconds(ts);
5548
+ } catch {
5549
+ return null;
5550
+ }
5551
+ }
5552
+ return null;
5553
+ }
5554
+ isComplete() {
5555
+ if (this.options.disabled) return true;
5556
+ return this.getDetail().isComplete;
5557
+ }
5558
+ isValid() {
5559
+ if (this.options.disabled) return true;
5560
+ return this.getDetail().isValid;
5561
+ }
5562
+ setValue(val) {
5563
+ if (this.options.disabled) {
5564
+ const str = val instanceof Date ? Number.isNaN(val.getTime()) ? "" : this.engine.formatDateToISO(val) : val !== null && val !== void 0 ? String(val) : "";
5565
+ this.setNativeValue(str);
5566
+ this.checkValueChange(false);
5567
+ return;
5568
+ }
5569
+ const formatted = this.engine.formatFromValue(val);
5570
+ this.applyFormatted(formatted, formatted.length, true);
5571
+ }
5572
+ /**
5573
+ * Remplit l'instant UTC courant.
5574
+ */
5575
+ setNow() {
5576
+ this.setValue(/* @__PURE__ */ new Date());
5577
+ }
5578
+ /**
5579
+ * Convertit la date UTC saisie vers la locale demandée via Intl.DateTimeFormat (aperçu sans widget).
5580
+ */
5581
+ formatLocal(locale, intlOptions) {
5582
+ return this.engine.formatLocal(this.getDate(), locale, intlOptions);
5583
+ }
5584
+ /**
5585
+ * Change dynamiquement le format (preset ou chaîne de tokens) et reconvertit la date courante si elle est valide.
5586
+ */
5587
+ setFormat(format, placeholderTokens) {
5588
+ const currentDate = this.getDate();
5589
+ this.options.format = format;
5590
+ if (placeholderTokens !== void 0) {
5591
+ this.options.placeholderTokens = placeholderTokens;
5592
+ }
5593
+ this.engine.setFormat(format, placeholderTokens);
5594
+ this.syncInferredInputMode();
5595
+ if (this.options.disabled) {
5596
+ this.clearGhost();
5597
+ return;
5598
+ }
5599
+ if (currentDate) {
5600
+ const formatted = this.engine.formatFromValue(currentDate);
5601
+ this.applyFormatted(formatted, formatted.length, true);
5602
+ } else {
5603
+ const formatted = this.engine.format(this.input.value, false);
5604
+ this.applyFormatted(formatted, Math.min(this.input.selectionStart ?? formatted.length, formatted.length), false);
5605
+ }
5606
+ }
5607
+ setUtcIndicator(indicator) {
5608
+ this.options.utcIndicator = indicator;
5609
+ this.engine.setUtcIndicator(indicator);
5610
+ this.updateGhost(this.input.value);
5611
+ }
5612
+ undo() {
5613
+ if (this.options.disabled) return;
5614
+ const state = this.history.undo();
5615
+ if (state) {
5616
+ this.isUndoingRedoing = true;
5617
+ try {
5618
+ this.applyFormatted(this.engine.format(state.raw, false), state.cursor, true);
5619
+ } finally {
5620
+ this.isUndoingRedoing = false;
5621
+ }
5622
+ }
5623
+ }
5624
+ redo() {
5625
+ if (this.options.disabled) return;
5626
+ const state = this.history.redo();
5627
+ if (state) {
5628
+ this.isUndoingRedoing = true;
5629
+ try {
5630
+ this.applyFormatted(this.engine.format(state.raw, false), state.cursor, true);
5631
+ } finally {
5632
+ this.isUndoingRedoing = false;
5633
+ }
5634
+ }
5635
+ }
5636
+ destroy() {
5637
+ if (this.isDestroyed) return;
5638
+ if (this.cutTimerId !== null) {
5639
+ clearTimeout(this.cutTimerId);
5640
+ this.cutTimerId = null;
5641
+ }
5642
+ if (this.pasteTimerId !== null) {
5643
+ clearTimeout(this.pasteTimerId);
5644
+ this.pasteTimerId = null;
5645
+ }
5646
+ if (this.resetTimerId !== null) {
5647
+ clearTimeout(this.resetTimerId);
5648
+ this.resetTimerId = null;
5649
+ }
5650
+ if (this.inferredInputModeValue && this.input.getAttribute("inputmode") === this.inferredInputModeValue) {
5651
+ this.input.removeAttribute("inputmode");
5652
+ }
5653
+ if (this.wasAutocorrectSet) this.input.removeAttribute("autocorrect");
5654
+ if (this.wasAutocapitalizeSet) this.input.removeAttribute("autocapitalize");
5655
+ if (this.wasSpellcheckSet) this.input.removeAttribute("spellcheck");
5656
+ this.history.clear();
5657
+ this.lastValue = "";
5658
+ this.lastValueLength = 0;
5659
+ super.destroy();
5660
+ }
5661
+ // ==========================================================================
5662
+ // Événements DOM & Clavier
5663
+ // ==========================================================================
5664
+ checkSelection() {
5665
+ if (this.options.disabled) return;
5666
+ const start = this.input.selectionStart ?? 0;
5667
+ const end = this.input.selectionEnd ?? start;
5668
+ this.wrapper.classList.toggle("has-selection", start !== end);
5669
+ }
5670
+ onBeforeInput(e) {
5671
+ this.lastInputType = e.inputType || "";
5672
+ if (this.options.disabled || this.isComposing) return;
5673
+ if (e.inputType === "insertFromPaste" || e.inputType === "insertReplacementText") return;
5674
+ if (e.inputType && e.inputType.startsWith("insert")) {
5675
+ const totalSlots = this.engine.getEditableCount();
5676
+ if (totalSlots > 0) {
5677
+ const currentRaw = this.engine.extractRaw(this.input.value, false);
5678
+ const start = this.input.selectionStart ?? 0;
5679
+ const end = this.input.selectionEnd ?? start;
5680
+ let available = Math.max(0, totalSlots - currentRaw.length);
5681
+ if (end > start) {
5682
+ const selectedRaw = this.engine.extractRaw(this.input.value.slice(start, end), false);
5683
+ available = Math.max(0, totalSlots - (currentRaw.length - selectedRaw.length));
5684
+ }
5685
+ if (available <= 0) {
5686
+ e.preventDefault();
5687
+ }
5688
+ }
5689
+ }
5690
+ }
5691
+ handleInput(e) {
5692
+ if (this.isDispatchingNativeInput || this.isComposing) return;
5693
+ if (this.options.disabled) {
5694
+ this.checkValueChange(false);
5695
+ return;
5696
+ }
5697
+ const inputType = e?.inputType || this.lastInputType || "";
5698
+ this.lastInputType = "";
5699
+ const val = this.input.value;
5700
+ const cursor = this.input.selectionStart ?? val.length;
5701
+ const prevState = this.history.getCurrent();
5702
+ const totalSlots = this.engine.getEditableCount();
5703
+ const isShorter = inputType.startsWith("delete") || !this.isSensitiveField() && val.length < this.lastValueLength;
5704
+ const newRawNoExpand = this.engine.extractRaw(val, false);
5705
+ if (totalSlots > 0 && prevState && prevState.raw.length >= totalSlots && newRawNoExpand.length > totalSlots) {
5706
+ const prevFormatted = this.engine.format(prevState.raw, false);
5707
+ this.applyFormatted(prevFormatted, prevState.cursor, true);
5708
+ return;
5709
+ }
5710
+ let candidate = val;
5711
+ let expandMeridiem = !isShorter;
5712
+ if (isShorter && this.engine.hasMeridiem()) {
5713
+ for (const seg of this.engine.getSegments()) {
5714
+ if (seg.kind === "A" && val.length >= seg.start + 1 && val.length < seg.end) {
5715
+ candidate = val.slice(0, seg.start) + val.slice(seg.start + 1);
5716
+ expandMeridiem = false;
5717
+ break;
5718
+ }
5719
+ }
5720
+ }
5721
+ this.applyFormatted(candidate, cursor, false, expandMeridiem);
5722
+ this.checkSelection();
5723
+ }
5724
+ onKeyDown(e) {
5725
+ if (this.options.disabled || isImeComposing(e)) return;
5726
+ const cursor = this.input.selectionStart ?? 0;
5727
+ const selectionEnd = this.input.selectionEnd ?? cursor;
5728
+ const minPos = this.engine.getPrefixLength();
5729
+ if ((e.ctrlKey || e.metaKey) && (e.key === "z" || e.key === "Z") && !e.shiftKey) {
5730
+ e.preventDefault();
5731
+ this.undo();
5732
+ return;
5733
+ }
5734
+ if ((e.ctrlKey || e.metaKey) && (e.key === "y" || e.key === "Y") || (e.ctrlKey || e.metaKey) && e.shiftKey && (e.key === "z" || e.key === "Z")) {
5735
+ e.preventDefault();
5736
+ this.redo();
5737
+ return;
5738
+ }
5739
+ this.history.updateCurrentCursor(cursor);
5740
+ const isPrintable = e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey;
5741
+ const hasSelection = selectionEnd > cursor;
5742
+ if (isPrintable && !hasSelection) {
5743
+ const sepResult = this.engine.tryHandleSeparatorKey(this.input.value, cursor, e.key);
5744
+ if (sepResult.handled) {
5745
+ e.preventDefault();
5746
+ this.applyFormatted(sepResult.formatted, sepResult.cursor, true);
5747
+ return;
5748
+ }
5749
+ if (this.engine.hasMeridiem()) {
5750
+ for (const seg of this.engine.getSegments()) {
5751
+ if (seg.kind === "A" && cursor >= seg.start && cursor <= seg.end) {
5752
+ const up = e.key.toUpperCase();
5753
+ if (up === "A" || up === "P") {
5754
+ e.preventDefault();
5755
+ const meridiem = up === "A" ? "AM" : "PM";
5756
+ const val = this.input.value;
5757
+ const updated = val.slice(0, seg.start) + meridiem + val.slice(Math.min(val.length, seg.end));
5758
+ this.applyFormatted(updated, seg.end, true);
5759
+ return;
5760
+ }
5761
+ }
5762
+ }
5763
+ }
5764
+ const totalSlots = this.engine.getEditableCount();
5765
+ if (totalSlots > 0 && this.engine.extractRaw(this.input.value, false).length >= totalSlots) {
5766
+ e.preventDefault();
5767
+ return;
5768
+ }
5769
+ }
5770
+ if (hasSelection) {
5771
+ if (e.key === "Backspace" || e.key === "Delete") {
5772
+ e.preventDefault();
5773
+ const val = this.input.value;
5774
+ const updated = val.slice(0, cursor) + val.slice(selectionEnd);
5775
+ this.applyFormatted(updated, Math.max(minPos, cursor), false);
5776
+ return;
5777
+ }
5778
+ return;
5779
+ }
5780
+ if (e.key === "ArrowLeft" && !e.shiftKey && cursor <= minPos) {
5781
+ e.preventDefault();
5782
+ this.input.setSelectionRange(minPos, minPos);
5783
+ return;
5784
+ }
5785
+ if (e.key === "Home" && minPos > 0 && !e.shiftKey && !e.ctrlKey && !e.metaKey && !e.altKey) {
5786
+ e.preventDefault();
5787
+ this.input.setSelectionRange(minPos, minPos);
5788
+ return;
5789
+ }
5790
+ if (e.key === "Backspace" && cursor <= minPos) {
5791
+ e.preventDefault();
5792
+ this.input.setSelectionRange(minPos, minPos);
5793
+ return;
5794
+ }
5795
+ if (e.key === "Delete" && cursor < minPos) {
5796
+ e.preventDefault();
5797
+ this.input.setSelectionRange(minPos, minPos);
5798
+ return;
5799
+ }
5800
+ if (e.key === "Backspace" && this.engine.hasMeridiem()) {
5801
+ for (const seg of this.engine.getSegments()) {
5802
+ if (seg.kind === "A" && cursor > seg.start && cursor <= seg.end) {
5803
+ e.preventDefault();
5804
+ const val = this.input.value;
5805
+ const updated = val.slice(0, seg.start) + val.slice(Math.min(val.length, seg.end));
5806
+ this.applyFormatted(updated, seg.start, true);
5807
+ return;
5808
+ }
5809
+ }
5810
+ }
5811
+ if (e.key === "Backspace" && (e.ctrlKey || e.altKey || e.metaKey)) {
5812
+ e.preventDefault();
5813
+ if (cursor <= minPos) {
5814
+ this.input.setSelectionRange(minPos, minPos);
5815
+ return;
5816
+ }
5817
+ let i = cursor - 1;
5818
+ while (i >= minPos && this.engine.isSeparatorAt(i)) i--;
5819
+ while (i >= minPos && !this.engine.isSeparatorAt(i)) i--;
5820
+ const startPos = Math.max(minPos, i + 1);
5821
+ const val = this.input.value;
5822
+ this.applyFormatted(val.slice(0, startPos) + val.slice(cursor), startPos, true);
5823
+ return;
5824
+ }
5825
+ if (e.key === "Delete" && (e.ctrlKey || e.altKey || e.metaKey)) {
5826
+ e.preventDefault();
5827
+ const val = this.input.value;
5828
+ if (cursor >= val.length) return;
5829
+ let i = cursor;
5830
+ while (i < val.length && this.engine.isSeparatorAt(i)) i++;
5831
+ while (i < val.length && !this.engine.isSeparatorAt(i)) i++;
5832
+ while (i < val.length && this.engine.isSeparatorAt(i)) i++;
5833
+ this.applyFormatted(val.slice(0, cursor) + val.slice(i), cursor, true);
5834
+ return;
5835
+ }
5836
+ if (e.key === "Backspace" && cursor > minPos && this.engine.isSeparatorAt(cursor - 1)) {
5837
+ e.preventDefault();
5838
+ let targetPos = cursor - 1;
5839
+ while (targetPos > minPos && this.engine.isSeparatorAt(targetPos - 1)) {
5840
+ targetPos--;
5841
+ }
5842
+ if (targetPos > minPos) {
5843
+ const val = this.input.value;
5844
+ this.applyFormatted(val.slice(0, targetPos - 1) + val.slice(cursor), targetPos - 1, false);
5845
+ } else {
5846
+ this.applyFormatted("", minPos, true);
5847
+ }
5848
+ return;
5849
+ }
5850
+ if (e.key === "Delete" && cursor < this.input.value.length && this.engine.isSeparatorAt(cursor)) {
5851
+ e.preventDefault();
5852
+ let targetPos = cursor;
5853
+ while (targetPos < this.input.value.length && this.engine.isSeparatorAt(targetPos)) {
5854
+ targetPos++;
5855
+ }
5856
+ if (targetPos < this.input.value.length) {
5857
+ const val = this.input.value;
5858
+ this.applyFormatted(val.slice(0, targetPos) + val.slice(targetPos + 1), cursor, true);
5859
+ }
5860
+ }
5861
+ }
5862
+ onPaste(e) {
5863
+ if (this.options.disabled) {
5864
+ if (this.pasteTimerId !== null) clearTimeout(this.pasteTimerId);
5865
+ this.pasteTimerId = window.setTimeout(() => {
5866
+ this.pasteTimerId = null;
5867
+ if (!this.isDestroyed) this.checkValueChange(false);
5868
+ }, 0);
5869
+ return;
5870
+ }
5871
+ e.preventDefault();
5872
+ this.history.updateCurrentCursor(this.input.selectionStart ?? 0);
5873
+ const pastedText = this.preparePastedText(this.getClipboardPlainText(e), 512);
5874
+ if (!pastedText) return;
5875
+ const minPos = this.engine.getPrefixLength();
5876
+ const selStart = this.input.selectionStart ?? 0;
5877
+ const selEnd = this.input.selectionEnd ?? selStart;
5878
+ const currentVal = this.input.value;
5879
+ const totalSlots = this.engine.getEditableCount();
5880
+ const currentRaw = this.engine.extractRaw(currentVal, false);
5881
+ const isGlobalOrEmpty = currentRaw.length === 0 || selStart <= minPos && selEnd >= currentVal.length || selStart === selEnd;
5882
+ if (isGlobalOrEmpty) {
5883
+ const parsed = this.engine.parsePasted(pastedText);
5884
+ if (parsed.matched) {
5885
+ this.applyFormatted(parsed.formatted, parsed.cursor, true);
5886
+ if (parsed.offsetConverted && this.options.onOffsetConverted) {
5887
+ try {
5888
+ this.options.onOffsetConverted(parsed.offsetConverted);
5889
+ } catch {
5890
+ }
5891
+ }
5892
+ this.checkSelection();
5893
+ return;
5894
+ }
5895
+ if (parsed.rejected) {
5896
+ return;
5897
+ }
5898
+ }
5899
+ let available = Math.max(0, totalSlots - currentRaw.length);
5900
+ if (selEnd > selStart) {
5901
+ const selectedRaw = this.engine.extractRaw(currentVal.slice(selStart, selEnd), false);
5902
+ available = Math.max(0, totalSlots - (currentRaw.length - selectedRaw.length));
5903
+ }
5904
+ if (available <= 0) return;
5905
+ const effectiveStart = Math.max(minPos, selStart);
5906
+ const effectiveEnd = Math.max(minPos, selEnd);
5907
+ const combined = currentVal.slice(0, effectiveStart) + pastedText + currentVal.slice(effectiveEnd);
5908
+ this.applyFormatted(combined, effectiveStart + pastedText.length, false, true);
5909
+ this.checkSelection();
5910
+ }
5911
+ onFocus() {
5912
+ this.syncGhostStyles();
5913
+ this.wrapper.classList.add("is-focused");
5914
+ if (!this.options.disabled && !this.isMouseDown) {
5915
+ this.enforceMinCursor();
5916
+ }
5917
+ this.updateGhost(this.input.value);
5918
+ this.checkSelection();
5919
+ }
5920
+ onBlur() {
5921
+ this.wrapper.classList.remove("is-focused", "has-selection");
5922
+ if (this.isSensitiveField()) {
5923
+ this.onPasswordModeDetected();
5924
+ return;
5925
+ }
5926
+ this.updateGhost(this.input.value);
5927
+ this.checkValueChange(false, true);
5928
+ }
5929
+ onClick() {
5930
+ if (!this.options.disabled) {
5931
+ this.enforceMinCursor();
5932
+ }
5933
+ this.history.updateCurrentCursor(this.input.selectionStart ?? 0);
5934
+ this.checkSelection();
5935
+ }
5936
+ onKeyUp(e) {
5937
+ if (!this.options.disabled) {
5938
+ if ((e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "Home") && !e.shiftKey) {
5939
+ this.enforceMinCursor();
5940
+ }
5941
+ this.history.updateCurrentCursor(this.input.selectionStart ?? 0);
5942
+ }
5943
+ this.checkSelection();
5944
+ }
5945
+ onSelect() {
5946
+ this.history.updateCurrentCursor(this.input.selectionStart ?? 0);
5947
+ this.checkSelection();
5948
+ }
5949
+ onMouseDown() {
5950
+ this.isMouseDown = true;
5951
+ }
5952
+ onMouseUp() {
5953
+ this.isMouseDown = false;
5954
+ this.checkSelection();
5955
+ }
5956
+ onCompositionStart() {
5957
+ this.isComposing = true;
5958
+ }
5959
+ onCompositionEnd() {
5960
+ this.isComposing = false;
5961
+ if (this.options.disabled) return;
5962
+ const cur = this.input.selectionStart ?? this.input.value.length;
5963
+ this.applyFormatted(this.input.value, cur, false, true);
5964
+ this.checkSelection();
5965
+ }
5966
+ enforceMinCursor() {
5967
+ const minPos = this.engine.getPrefixLength();
5968
+ if (minPos <= 0) return;
5969
+ const start = this.input.selectionStart ?? 0;
5970
+ const end = this.input.selectionEnd ?? start;
5971
+ if (start !== end) return;
5972
+ if (start < minPos) {
5973
+ this.input.setSelectionRange(minPos, minPos);
5974
+ }
5975
+ }
5976
+ // ==========================================================================
5977
+ // Synchronisation & Notifications
5978
+ // ==========================================================================
5979
+ updateGhost(formatted) {
5980
+ if (!this.ghost) return;
5981
+ if (this.options.disabled || this.isSensitiveField()) {
5982
+ this.clearGhost();
5983
+ return;
5984
+ }
5985
+ const isCleanEmpty = !formatted || formatted === this.engine.getPrefix();
5986
+ if (this.shouldHideGhostForPlaceholder(isCleanEmpty)) {
5987
+ this.clearGhost();
5988
+ return;
5989
+ }
5990
+ const remaining = this.engine.getGhostRemaining(formatted);
5991
+ const doc = this.input.ownerDocument || document;
5992
+ const spanTyped = doc.createElement("span");
5993
+ spanTyped.className = "mask-ghost-typed";
5994
+ spanTyped.textContent = formatted;
5995
+ const spanRemaining = doc.createElement("span");
5996
+ spanRemaining.className = "mask-ghost-remaining";
5997
+ spanRemaining.textContent = remaining;
5998
+ this.setGhostContent(spanTyped, spanRemaining);
5999
+ this.ghost.scrollLeft = this.input.scrollLeft;
6000
+ }
6001
+ applyFormatted(rawOrPartial, cursorPosition, forceExactCursor = false, expandSingleMeridiem = false) {
6002
+ if (this.options.disabled || this.isApplying) return;
6003
+ this.isApplying = true;
6004
+ try {
6005
+ const formatted = this.engine.format(rawOrPartial, expandSingleMeridiem);
6006
+ const isSensitive = this.isSensitiveField();
6007
+ this.setNativeValue(formatted);
6008
+ if (isSensitive) {
6009
+ this.clearGhost();
6010
+ } else {
6011
+ this.updateGhost(formatted);
6012
+ }
6013
+ const minPos = this.engine.getPrefixLength();
6014
+ let safeCursor;
6015
+ if (forceExactCursor || this.isUndoingRedoing) {
6016
+ safeCursor = Math.max(minPos, Math.min(cursorPosition, formatted.length));
6017
+ } else {
6018
+ safeCursor = Math.max(minPos, this.engine.mapCursorPosition(rawOrPartial, cursorPosition, formatted));
6019
+ }
6020
+ this.input.setSelectionRange(safeCursor, safeCursor);
6021
+ const analysis = this.engine.analyze(formatted, false);
6022
+ this.wrapper.classList.toggle("is-complete", analysis.isComplete);
6023
+ if (isSensitive) {
6024
+ this.options.copyRaw = false;
6025
+ this.lastValueLength = 0;
6026
+ this.history.clear();
6027
+ } else {
6028
+ this.lastValueLength = formatted.length;
6029
+ if (!this.isUndoingRedoing) {
6030
+ this.history.push(this.engine.extractRaw(formatted, false), safeCursor);
6031
+ }
6032
+ }
6033
+ } finally {
6034
+ this.isApplying = false;
6035
+ }
6036
+ this.checkValueChange(false);
6037
+ }
6038
+ syncInitialValue() {
6039
+ const isSensitive = this.isSensitiveField();
6040
+ if (this.options.disabled) {
6041
+ this.clearGhost();
6042
+ this.lastValue = isSensitive ? this.computePasswordDigest(this.input.value) : this.input.value;
6043
+ this.lastValueLength = isSensitive ? 0 : this.input.value.length;
6044
+ this.checkValueChange(false);
6045
+ return;
6046
+ }
6047
+ this.syncGhostStyles();
6048
+ const initialVal = this.input.value || "";
6049
+ if (initialVal) {
6050
+ const formatted = this.engine.formatFromValue(initialVal);
6051
+ this.applyFormatted(formatted, formatted.length, true);
6052
+ } else {
6053
+ const minPos = this.engine.getPrefixLength();
6054
+ if (minPos > 0) {
6055
+ this.applyFormatted("", minPos, true);
6056
+ } else {
6057
+ if (!isSensitive) {
6058
+ this.history.push("", 0);
6059
+ this.updateGhost("");
6060
+ } else {
6061
+ this.clearGhost();
6062
+ }
6063
+ this.checkValueChange(false);
6064
+ }
6065
+ }
6066
+ }
6067
+ checkValueChange(forceNotify = false, emitChangeEvent = false) {
6068
+ const initialSensitive = this.isSensitiveField();
6069
+ const currentVal = this.input.value;
6070
+ const currentComparison = initialSensitive ? this.computePasswordDigest(currentVal) : currentVal;
6071
+ if (currentComparison === this.lastValue && !forceNotify && !this.hasPendingNotification) {
6072
+ if (emitChangeEvent) {
6073
+ const allowBubble = !initialSensitive;
6074
+ const detail = this.getDetail();
6075
+ const onChangeCb = this.options.onChange || this.options.onchange;
6076
+ if (onChangeCb) onChangeCb(detail);
6077
+ this.input.dispatchEvent(new CustomEvent("mask:change", { bubbles: allowBubble, detail }));
6078
+ }
6079
+ return;
6080
+ }
6081
+ if (this.isNotifying) {
6082
+ this.hasPendingNotification = true;
6083
+ return;
6084
+ }
6085
+ this.isNotifying = true;
6086
+ try {
6087
+ let iterations = 0;
6088
+ while (((this.isSensitiveField() ? this.computePasswordDigest(this.input.value) : this.input.value) !== this.lastValue || this.hasPendingNotification || forceNotify) && iterations < MAX_NOTIFICATION_ITERATIONS3) {
6089
+ iterations++;
6090
+ this.hasPendingNotification = false;
6091
+ forceNotify = false;
6092
+ const sensitiveNow = this.isSensitiveField();
6093
+ const allowBubble = !sensitiveNow;
6094
+ const valToNotify = this.input.value;
6095
+ this.lastValue = sensitiveNow ? this.computePasswordDigest(valToNotify) : valToNotify;
6096
+ this.lastValueLength = sensitiveNow ? 0 : valToNotify.length;
6097
+ const detail = this.getDetail();
6098
+ const onInputCb = this.options.onInput || this.options.oninput;
6099
+ if (onInputCb) onInputCb(detail);
6100
+ this.input.dispatchEvent(new CustomEvent("mask:input", { bubbles: allowBubble, detail }));
6101
+ this.dispatchNativeInput();
6102
+ if (emitChangeEvent) {
6103
+ const onChangeCb = this.options.onChange || this.options.onchange;
6104
+ if (onChangeCb) onChangeCb(detail);
6105
+ this.input.dispatchEvent(new CustomEvent("mask:change", { bubbles: allowBubble, detail }));
6106
+ }
6107
+ if (detail.isComplete) {
6108
+ const onCompleteCb = this.options.onComplete || this.options.oncomplete;
6109
+ if (onCompleteCb) onCompleteCb(detail);
6110
+ this.input.dispatchEvent(new CustomEvent("mask:complete", { bubbles: allowBubble, detail }));
6111
+ }
6112
+ }
6113
+ } finally {
6114
+ this.isNotifying = false;
6115
+ }
6116
+ }
6117
+ };
6118
+
3469
6119
  // src/mask/index.ts
3470
6120
  var Mask = {
3471
6121
  BaseInputMask,
@@ -3476,7 +6126,12 @@ var __WulfIIFE = (() => {
3476
6126
  AmountEngine,
3477
6127
  InputAmountMask,
3478
6128
  EmailEngine,
3479
- InputEmailMask
6129
+ InputEmailMask,
6130
+ DateUTCEngine,
6131
+ DATE_UTC_PRESETS,
6132
+ InputDateUTCMask,
6133
+ sanitizePastedText,
6134
+ stripBidiAndInvisibles
3480
6135
  };
3481
6136
  var wulfNamespace = getSafeWulfNamespace();
3482
6137
  if (wulfNamespace) {