wulf.js 1.9.1 → 1.9.3

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 (71) hide show
  1. package/README.md +160 -21
  2. package/changelog.md +66 -0
  3. package/dist/focus-trap.esm.js +62 -9
  4. package/dist/focus-trap.esm.js.map +2 -2
  5. package/dist/focus-trap.global.js +64 -11
  6. package/dist/focus-trap.global.js.map +2 -2
  7. package/dist/focus-trap.global.min.js +3 -3
  8. package/dist/focus-trap.global.min.js.map +3 -3
  9. package/dist/index.esm.js +947 -101
  10. package/dist/index.esm.js.map +4 -4
  11. package/dist/index.global.js +949 -103
  12. package/dist/index.global.js.map +4 -4
  13. package/dist/index.global.min.js +3 -3
  14. package/dist/index.global.min.js.map +4 -4
  15. package/dist/mask.esm.js +66 -22
  16. package/dist/mask.esm.js.map +2 -2
  17. package/dist/mask.global.js +68 -24
  18. package/dist/mask.global.js.map +2 -2
  19. package/dist/mask.global.min.js +3 -3
  20. package/dist/mask.global.min.js.map +3 -3
  21. package/dist/masonry.esm.js +96 -40
  22. package/dist/masonry.esm.js.map +2 -2
  23. package/dist/masonry.global.js +98 -42
  24. package/dist/masonry.global.js.map +2 -2
  25. package/dist/masonry.global.min.js +3 -3
  26. package/dist/masonry.global.min.js.map +3 -3
  27. package/dist/scroll.esm.js +66 -28
  28. package/dist/scroll.esm.js.map +2 -2
  29. package/dist/scroll.global.js +68 -30
  30. package/dist/scroll.global.js.map +2 -2
  31. package/dist/scroll.global.min.js +4 -4
  32. package/dist/scroll.global.min.js.map +3 -3
  33. package/dist/shortcut.esm.js +631 -0
  34. package/dist/shortcut.esm.js.map +7 -0
  35. package/dist/shortcut.global.js +657 -0
  36. package/dist/shortcut.global.js.map +7 -0
  37. package/dist/shortcut.global.min.js +3 -0
  38. package/dist/shortcut.global.min.js.map +7 -0
  39. package/dist/toast.css +1 -1
  40. package/dist/toast.css.map +2 -2
  41. package/dist/toast.esm.js +109 -44
  42. package/dist/toast.esm.js.map +2 -2
  43. package/dist/toast.global.js +111 -46
  44. package/dist/toast.global.js.map +2 -2
  45. package/dist/toast.global.min.js +4 -4
  46. package/dist/toast.global.min.js.map +3 -3
  47. package/dist/types/focus-trap/FocusTrap.d.ts +2 -0
  48. package/dist/types/index.d.ts +2 -0
  49. package/dist/types/mask/AmountEngine.d.ts +1 -0
  50. package/dist/types/mask/BaseInputMask.d.ts +4 -0
  51. package/dist/types/mask/InputAmountMask.d.ts +1 -0
  52. package/dist/types/mask/InputMask.d.ts +1 -0
  53. package/dist/types/shortcut/ShortcutFormatter.d.ts +31 -0
  54. package/dist/types/shortcut/ShortcutManager.d.ts +95 -0
  55. package/dist/types/shortcut/index.d.ts +4 -0
  56. package/dist/types/shortcut/types.d.ts +101 -0
  57. package/dist/types/toast/ToastInstance.d.ts +1 -1
  58. package/dist/types/toast/types.d.ts +5 -0
  59. package/package.json +20 -11
  60. package/dist/focus-trap.cjs.js +0 -430
  61. package/dist/focus-trap.cjs.js.map +0 -7
  62. package/dist/index.cjs.js +0 -5365
  63. package/dist/index.cjs.js.map +0 -7
  64. package/dist/mask.cjs.js +0 -3086
  65. package/dist/mask.cjs.js.map +0 -7
  66. package/dist/masonry.cjs.js +0 -858
  67. package/dist/masonry.cjs.js.map +0 -7
  68. package/dist/scroll.cjs.js +0 -823
  69. package/dist/scroll.cjs.js.map +0 -7
  70. package/dist/toast.cjs.js +0 -715
  71. package/dist/toast.cjs.js.map +0 -7
package/dist/index.esm.js CHANGED
@@ -270,7 +270,8 @@ var BaseInputMask = class extends AuditableComponent {
270
270
  "data-disabled",
271
271
  "data-mask-align",
272
272
  "data-align",
273
- "placeholder"
273
+ "placeholder",
274
+ "type"
274
275
  ]
275
276
  };
276
277
  this.mutationObserver.observe(this.wrapper, config);
@@ -318,7 +319,12 @@ var BaseInputMask = class extends AuditableComponent {
318
319
  } else if (attrName === "data-mask-select-on-focus") {
319
320
  this.options.selectAllOnFocus = this.getAttr("data-mask-select-on-focus") === "true";
320
321
  } else if (attrName === "data-mask-copy-raw") {
321
- this.options.copyRaw = this.getAttr("data-mask-copy-raw") === "true";
322
+ this.options.copyRaw = this.input.type === "password" ? false : this.getAttr("data-mask-copy-raw") === "true";
323
+ } else if (attrName === "type") {
324
+ if (this.input.type === "password") {
325
+ this.options.copyRaw = false;
326
+ this.onPasswordModeDetected();
327
+ }
322
328
  } else if (attrName === "data-mask-align" || attrName === "data-align") {
323
329
  const align = this.getAttr("data-mask-align") || this.getAttr("data-align");
324
330
  if (align !== (this.options.align ?? null)) {
@@ -573,6 +579,11 @@ var BaseInputMask = class extends AuditableComponent {
573
579
  getSpecificAuditWarnings() {
574
580
  return [];
575
581
  }
582
+ /**
583
+ * Crochet appelé lorsque l'input bascule dynamiquement en type="password" (ex: toggle afficher/masquer).
584
+ */
585
+ onPasswordModeDetected() {
586
+ }
576
587
  /**
577
588
  * Supprime les éléments fantômes, restaure les propriétés et nettoie les attributs.
578
589
  */
@@ -657,11 +668,11 @@ var MaskEngine = class _MaskEngine {
657
668
  compile(newPattern) {
658
669
  if (newPattern !== void 0) {
659
670
  if (Array.isArray(newPattern)) {
660
- this.patterns = [...newPattern];
671
+ this.patterns = newPattern.slice(0, 32).map((p) => String(p ?? "").slice(0, 512));
661
672
  this.pattern = this.patterns[0] || "";
662
673
  } else {
663
674
  this.patterns = [];
664
- this.pattern = newPattern;
675
+ this.pattern = String(newPattern ?? "").slice(0, 512);
665
676
  }
666
677
  }
667
678
  if (this.patterns.length > 0) {
@@ -812,7 +823,8 @@ var MaskEngine = class _MaskEngine {
812
823
  return engine.extractRaw(input);
813
824
  }
814
825
  }
815
- const str = String(input ?? "");
826
+ const maxInputLen = Math.max(4096, this.slots.length * 4);
827
+ const str = String(input ?? "").slice(0, maxInputLen);
816
828
  if (!str) return "";
817
829
  let raw = "";
818
830
  let inputIdx = 0;
@@ -881,7 +893,8 @@ var MaskEngine = class _MaskEngine {
881
893
  return engine.format(rawValue);
882
894
  }
883
895
  }
884
- const rawStr = String(rawValue ?? "");
896
+ const maxInputLen = Math.max(4096, this.slots.length * 4);
897
+ const rawStr = String(rawValue ?? "").slice(0, maxInputLen);
885
898
  if (!this.slots.length) return rawStr;
886
899
  const cleanRaw = this.extractRaw(rawStr);
887
900
  if (cleanRaw.length === 0) {
@@ -1384,6 +1397,9 @@ var InputMask = class extends BaseInputMask {
1384
1397
  extractRawSnippet(snippet) {
1385
1398
  return this.engine.extractRaw(snippet);
1386
1399
  }
1400
+ onPasswordModeDetected() {
1401
+ this.history.clear();
1402
+ }
1387
1403
  /**
1388
1404
  * Formate statiquement une valeur selon un masque donné sans nécessiter d'élément DOM.
1389
1405
  *
@@ -1752,7 +1768,7 @@ var InputMask = class extends BaseInputMask {
1752
1768
  }
1753
1769
  e.preventDefault();
1754
1770
  this.history.updateCurrentCursor(this.input.selectionStart ?? 0);
1755
- const rawPasted = e.clipboardData?.getData("text") || "";
1771
+ const rawPasted = (e.clipboardData?.getData("text") || "").slice(0, 4096);
1756
1772
  const pastedText = rawPasted.trim();
1757
1773
  if (!pastedText) return;
1758
1774
  const minPos = this.engine.getPrefixLength();
@@ -1904,7 +1920,10 @@ var InputMask = class extends BaseInputMask {
1904
1920
  this.input.setSelectionRange(safeCursor, safeCursor);
1905
1921
  isCompleted = this.isComplete();
1906
1922
  this.wrapper.classList.toggle("is-complete", isCompleted);
1907
- if (!this.isUndoingRedoing && this.input.type !== "password") {
1923
+ if (this.input.type === "password") {
1924
+ this.options.copyRaw = false;
1925
+ this.history.clear();
1926
+ } else if (!this.isUndoingRedoing) {
1908
1927
  this.history.push(this.getRawValue(), safeCursor);
1909
1928
  }
1910
1929
  } finally {
@@ -1955,7 +1974,10 @@ var InputMask = class extends BaseInputMask {
1955
1974
  }
1956
1975
  this.isNotifying = true;
1957
1976
  try {
1958
- while (this.input.value !== this.lastValue || this.hasPendingNotification || forceNotify) {
1977
+ let iterations = 0;
1978
+ const MAX_NOTIFICATION_ITERATIONS = 10;
1979
+ while ((this.input.value !== this.lastValue || this.hasPendingNotification || forceNotify) && iterations < MAX_NOTIFICATION_ITERATIONS) {
1980
+ iterations++;
1959
1981
  this.hasPendingNotification = false;
1960
1982
  forceNotify = false;
1961
1983
  const valToNotify = this.input.value;
@@ -2003,13 +2025,15 @@ var AmountEngine = class _AmountEngine {
2003
2025
  currency = options.unit;
2004
2026
  }
2005
2027
  const defaultPosition = currency === "$" || currency === "\xA3" || currency === "\xA5" ? "prefix" : "suffix";
2028
+ const rawDecimals = options.decimals !== void 0 ? Number(options.decimals) : 2;
2029
+ const safeDecimals = Number.isFinite(rawDecimals) ? Math.min(20, Math.max(0, Math.floor(rawDecimals))) : 2;
2006
2030
  this.options = {
2007
- currency,
2008
- unit: options.unit ?? currency,
2031
+ currency: String(currency).slice(0, 32),
2032
+ unit: String(options.unit ?? currency).slice(0, 32),
2009
2033
  currencyPosition: options.currencyPosition ?? defaultPosition,
2010
- decimals: options.decimals !== void 0 ? Math.max(0, options.decimals) : 2,
2011
- decimalSeparator: options.decimalSeparator ?? ",",
2012
- thousandSeparator: options.thousandSeparator ?? "\xA0",
2034
+ decimals: safeDecimals,
2035
+ decimalSeparator: String(options.decimalSeparator ?? ",").slice(0, 4) || ",",
2036
+ thousandSeparator: String(options.thousandSeparator ?? "\xA0").slice(0, 4),
2013
2037
  // Espace insécable
2014
2038
  allowNegative: options.allowNegative ?? false,
2015
2039
  min: options.min ?? -Infinity,
@@ -2020,7 +2044,7 @@ var AmountEngine = class _AmountEngine {
2020
2044
  * Analyse et nettoie une saisie utilisateur pour extraire ses composantes numériques.
2021
2045
  */
2022
2046
  parse(input) {
2023
- let str = input.trim();
2047
+ let str = String(input ?? "").slice(0, 512).trim();
2024
2048
  let isNegative = false;
2025
2049
  if (this.options.allowNegative && str.includes("-")) {
2026
2050
  isNegative = true;
@@ -2061,7 +2085,9 @@ var AmountEngine = class _AmountEngine {
2061
2085
  * @param rawCursor Position actuelle du curseur dans l'input natif
2062
2086
  */
2063
2087
  format(input, rawCursor = input.length, padDecimals = false) {
2064
- if (!input || input.trim() === "" || input === this.options.currency.trim()) {
2088
+ const safeInput = String(input ?? "").slice(0, 512);
2089
+ const safeRawCursor = Math.max(0, Math.min(rawCursor, safeInput.length));
2090
+ if (!safeInput || safeInput.trim() === "" || safeInput === this.options.currency.trim()) {
2065
2091
  return {
2066
2092
  formatted: "",
2067
2093
  rawNumber: null,
@@ -2070,10 +2096,10 @@ var AmountEngine = class _AmountEngine {
2070
2096
  isValid: true
2071
2097
  };
2072
2098
  }
2073
- const prefixBeforeCursor = input.substring(0, rawCursor);
2099
+ const prefixBeforeCursor = safeInput.substring(0, safeRawCursor);
2074
2100
  const digitsBeforeCursor = prefixBeforeCursor.replace(/\D/g, "").length;
2075
2101
  const hadDecimalBeforeCursor = this.options.decimals > 0 && /[,.]/.test(prefixBeforeCursor);
2076
- const { isNegative, integerPart, decimalPart, hasDecimal } = this.parse(input);
2102
+ const { isNegative, integerPart, decimalPart, hasDecimal } = this.parse(safeInput);
2077
2103
  let effectiveDecimal = decimalPart;
2078
2104
  let effectiveHasDecimal = hasDecimal;
2079
2105
  if (padDecimals && this.options.decimals > 0 && (integerPart || decimalPart !== null)) {
@@ -2113,7 +2139,7 @@ var AmountEngine = class _AmountEngine {
2113
2139
  isValid: true
2114
2140
  };
2115
2141
  }
2116
- const formattedInteger = (integerPart || "0").replace(/\B(?=(\d{3})+(?!\d))/g, this.options.thousandSeparator);
2142
+ const formattedInteger = this.formatThousands(integerPart || "0");
2117
2143
  let numberCore = formattedInteger;
2118
2144
  if (effectiveHasDecimal && this.options.decimals > 0) {
2119
2145
  numberCore += this.options.decimalSeparator + (effectiveDecimal ?? "");
@@ -2186,6 +2212,18 @@ var AmountEngine = class _AmountEngine {
2186
2212
  const str = typeof value === "number" ? value.toString() : value;
2187
2213
  return engine.format(str).formatted;
2188
2214
  }
2215
+ formatThousands(digits) {
2216
+ const sep = this.options.thousandSeparator;
2217
+ if (!sep || digits.length <= 3) return digits;
2218
+ const parts = [];
2219
+ let i = digits.length;
2220
+ while (i > 0) {
2221
+ const start = Math.max(0, i - 3);
2222
+ parts.push(digits.slice(start, i));
2223
+ i = start;
2224
+ }
2225
+ return parts.reverse().join(sep);
2226
+ }
2189
2227
  escapeRegExp(string) {
2190
2228
  return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2191
2229
  }
@@ -2236,6 +2274,9 @@ var InputAmountMask = class extends BaseInputMask {
2236
2274
  if (!p.integerPart && !p.decimalPart) return "";
2237
2275
  return (p.isNegative ? "-" : "") + (p.integerPart || "0") + (p.decimalPart ? "." + p.decimalPart : "");
2238
2276
  }
2277
+ onPasswordModeDetected() {
2278
+ this.history.clear();
2279
+ }
2239
2280
  /**
2240
2281
  * Formate statiquement une valeur sans nécessiter d'élément DOM.
2241
2282
  */
@@ -2313,7 +2354,10 @@ var InputAmountMask = class extends BaseInputMask {
2313
2354
  const result = this.engine.format(val, cursor);
2314
2355
  this.setNativeValue(result.formatted);
2315
2356
  this.input.setSelectionRange(result.cursor, result.cursor);
2316
- if (!this.isUndoingRedoing && this.input.type !== "password") {
2357
+ if (this.input.type === "password") {
2358
+ this.options.copyRaw = false;
2359
+ this.history.clear();
2360
+ } else if (!this.isUndoingRedoing) {
2317
2361
  this.history.push(result.rawValue, result.cursor);
2318
2362
  }
2319
2363
  this.updateGhost(result);
@@ -2607,7 +2651,7 @@ var _EmailEngine = class _EmailEngine {
2607
2651
  * Retourne l'ensemble des domaines correspondant à la saisie courante.
2608
2652
  */
2609
2653
  getMatchingDomains(input) {
2610
- const val = input ?? "";
2654
+ const val = String(input ?? "").slice(0, 512);
2611
2655
  if (!val.includes("@")) {
2612
2656
  return this.defaultDomain ? [this.defaultDomain] : [];
2613
2657
  }
@@ -2629,7 +2673,7 @@ var _EmailEngine = class _EmailEngine {
2629
2673
  * @param matchIndex Index de la suggestion à sélectionner si plusieurs domaines/TLD correspondent (permet le cyclage)
2630
2674
  */
2631
2675
  getSuggestion(input, matchIndex = 0) {
2632
- const val = input ?? "";
2676
+ const val = String(input ?? "").slice(0, 512);
2633
2677
  if (!val.includes("@")) {
2634
2678
  if (this.defaultDomain) {
2635
2679
  return {
@@ -3149,35 +3193,49 @@ var LocalizedComponent = class extends AuditableComponent {
3149
3193
  };
3150
3194
 
3151
3195
  // src/common/i18n.ts
3196
+ var FORBIDDEN_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
3197
+ function isSafeKey(key) {
3198
+ return Boolean(key) && !FORBIDDEN_KEYS.has(key);
3199
+ }
3152
3200
  function normalizeLocaleCode(locale) {
3153
- return locale.trim().toLowerCase().replace(/_/g, "-");
3201
+ const norm = String(locale ?? "").trim().toLowerCase().replace(/_/g, "-");
3202
+ return isSafeKey(norm) ? norm : "";
3154
3203
  }
3155
3204
  function getPrimaryLanguage(normalizedLocale) {
3156
3205
  const dashIndex = normalizedLocale.indexOf("-");
3157
- return dashIndex > 0 ? normalizedLocale.slice(0, dashIndex) : null;
3206
+ const primary = dashIndex > 0 ? normalizedLocale.slice(0, dashIndex) : null;
3207
+ return primary && isSafeKey(primary) ? primary : null;
3158
3208
  }
3159
3209
  function assignDefined(target, source) {
3160
- if (!source) return target;
3210
+ if (!source || typeof source !== "object") return target;
3161
3211
  for (const key of Object.keys(source)) {
3162
- if (source[key] !== void 0) {
3212
+ if (isSafeKey(String(key)) && Object.prototype.hasOwnProperty.call(source, key) && source[key] !== void 0) {
3163
3213
  target[key] = source[key];
3164
3214
  }
3165
3215
  }
3166
3216
  return target;
3167
3217
  }
3168
3218
  function createI18nManager(defaultLocale, locales) {
3169
- const fallbackLocale = normalizeLocaleCode(defaultLocale);
3170
- const initialLocales = {};
3219
+ const fallbackLocale = normalizeLocaleCode(defaultLocale) || "fr";
3220
+ const initialLocales = /* @__PURE__ */ Object.create(null);
3171
3221
  for (const [loc, dict] of Object.entries(locales)) {
3172
- initialLocales[normalizeLocaleCode(loc)] = { ...dict };
3222
+ const norm = normalizeLocaleCode(loc);
3223
+ if (norm) {
3224
+ initialLocales[norm] = assignDefined(/* @__PURE__ */ Object.create(null), dict);
3225
+ }
3173
3226
  }
3174
3227
  let currentLocale = fallbackLocale;
3175
- let activeLocales = { ...initialLocales };
3176
- let globalOverrides = {};
3228
+ let activeLocales = /* @__PURE__ */ Object.create(null);
3229
+ for (const [loc, dict] of Object.entries(initialLocales)) {
3230
+ activeLocales[loc] = assignDefined(/* @__PURE__ */ Object.create(null), dict);
3231
+ }
3232
+ let globalOverrides = /* @__PURE__ */ Object.create(null);
3177
3233
  function resolveActiveDictionaries() {
3178
3234
  const dicts = [];
3179
- const exact = activeLocales[currentLocale];
3180
- if (exact) dicts.push(exact);
3235
+ if (isSafeKey(currentLocale)) {
3236
+ const exact = activeLocales[currentLocale];
3237
+ if (exact) dicts.push(exact);
3238
+ }
3181
3239
  const primary = getPrimaryLanguage(currentLocale);
3182
3240
  if (primary && activeLocales[primary]) {
3183
3241
  dicts.push(activeLocales[primary]);
@@ -3186,24 +3244,33 @@ function createI18nManager(defaultLocale, locales) {
3186
3244
  }
3187
3245
  return {
3188
3246
  setLocale(locale) {
3189
- if (locale && locale.trim()) {
3190
- currentLocale = normalizeLocaleCode(locale);
3247
+ if (locale && typeof locale === "string" && locale.trim()) {
3248
+ const norm = normalizeLocaleCode(locale);
3249
+ if (norm) {
3250
+ currentLocale = norm;
3251
+ }
3191
3252
  }
3192
3253
  },
3193
3254
  getLocale() {
3194
3255
  return currentLocale;
3195
3256
  },
3196
3257
  registerLocale(locale, translations) {
3197
- if (!locale || !locale.trim() || !translations) return;
3258
+ if (!locale || typeof locale !== "string" || !locale.trim() || !translations) return;
3198
3259
  const norm = normalizeLocaleCode(locale);
3199
- activeLocales[norm] = assignDefined({ ...activeLocales[norm] || {} }, translations);
3260
+ if (!norm) return;
3261
+ const base = assignDefined(/* @__PURE__ */ Object.create(null), activeLocales[norm]);
3262
+ activeLocales[norm] = assignDefined(base, translations);
3200
3263
  },
3201
3264
  setI18n(overrides) {
3202
- if (!overrides) return;
3203
- globalOverrides = assignDefined({ ...globalOverrides }, overrides);
3265
+ if (!overrides || typeof overrides !== "object") return;
3266
+ const base = assignDefined(/* @__PURE__ */ Object.create(null), globalOverrides);
3267
+ globalOverrides = assignDefined(base, overrides);
3204
3268
  },
3205
3269
  t(key, instanceOverride) {
3206
- if (instanceOverride && instanceOverride[key] !== void 0) {
3270
+ if (!isSafeKey(String(key))) {
3271
+ return "";
3272
+ }
3273
+ if (instanceOverride && typeof instanceOverride === "object" && Object.prototype.hasOwnProperty.call(instanceOverride, key) && instanceOverride[key] !== void 0) {
3207
3274
  return String(instanceOverride[key]);
3208
3275
  }
3209
3276
  if (globalOverrides[key] !== void 0) {
@@ -3234,10 +3301,10 @@ function createI18nManager(defaultLocale, locales) {
3234
3301
  },
3235
3302
  reset() {
3236
3303
  currentLocale = fallbackLocale;
3237
- globalOverrides = {};
3238
- activeLocales = {};
3304
+ globalOverrides = /* @__PURE__ */ Object.create(null);
3305
+ activeLocales = /* @__PURE__ */ Object.create(null);
3239
3306
  for (const [loc, dict] of Object.entries(initialLocales)) {
3240
- activeLocales[loc] = { ...dict };
3307
+ activeLocales[loc] = assignDefined(/* @__PURE__ */ Object.create(null), dict);
3241
3308
  }
3242
3309
  }
3243
3310
  };
@@ -3281,21 +3348,36 @@ var ScrollBlock = class extends LocalizedComponent {
3281
3348
  this.atTop = true;
3282
3349
  this.atRight = false;
3283
3350
  this.atLeft = true;
3284
- const resolvedElement = typeof element === "string" ? document.querySelector(element) : element;
3285
- if (!resolvedElement) {
3351
+ let resolvedElement = null;
3352
+ if (typeof element === "string") {
3353
+ try {
3354
+ resolvedElement = document.querySelector(element);
3355
+ } catch {
3356
+ resolvedElement = null;
3357
+ }
3358
+ } else {
3359
+ resolvedElement = element;
3360
+ }
3361
+ if (!resolvedElement || !(resolvedElement instanceof HTMLElement)) {
3286
3362
  throw new Error(`[ScrollBlock] \xC9l\xE9ment introuvable : "${element}".`);
3287
3363
  }
3288
3364
  this.root = resolvedElement;
3289
3365
  this.hasExplicitAriaLabel = Boolean(options?.ariaLabel || options?.i18n?.viewport);
3366
+ const rawDelay = options?.autoHideDelay;
3367
+ const safeAutoHideDelay = typeof rawDelay === "number" && Number.isFinite(rawDelay) && rawDelay >= 0 ? rawDelay : 1e3;
3368
+ const rawMinThumb = options?.minThumbSize;
3369
+ const safeMinThumbSize = typeof rawMinThumb === "number" && Number.isFinite(rawMinThumb) && rawMinThumb > 0 ? rawMinThumb : 24;
3370
+ const rawEdge = options?.edgeThreshold;
3371
+ const safeEdgeThreshold = typeof rawEdge === "number" && Number.isFinite(rawEdge) && rawEdge >= 0 ? rawEdge : 10;
3290
3372
  this.options = {
3291
3373
  axis: options?.axis || "y",
3292
3374
  autoHide: options?.autoHide ?? true,
3293
- autoHideDelay: options?.autoHideDelay ?? 1e3,
3375
+ autoHideDelay: safeAutoHideDelay,
3294
3376
  alwaysVisible: options?.alwaysVisible ?? false,
3295
3377
  ariaLabel: options?.ariaLabel || this.t("viewport"),
3296
3378
  i18n: options?.i18n || {},
3297
- minThumbSize: options?.minThumbSize ?? 24,
3298
- edgeThreshold: options?.edgeThreshold ?? 10,
3379
+ minThumbSize: safeMinThumbSize,
3380
+ edgeThreshold: safeEdgeThreshold,
3299
3381
  onScroll: options?.onScroll || (() => {
3300
3382
  }),
3301
3383
  onTotalScroll: options?.onTotalScroll || (() => {
@@ -3733,8 +3815,8 @@ var ScrollBlock = class extends LocalizedComponent {
3733
3815
  targetLeft = target.left;
3734
3816
  }
3735
3817
  this.viewport.scrollTo({
3736
- top: targetTop !== void 0 ? Math.max(0, Math.min(maxTop, targetTop)) : void 0,
3737
- left: targetLeft !== void 0 ? Math.max(0, Math.min(maxLeft, targetLeft)) : void 0,
3818
+ top: targetTop !== void 0 && Number.isFinite(targetTop) ? Math.max(0, Math.min(maxTop, targetTop)) : void 0,
3819
+ left: targetLeft !== void 0 && Number.isFinite(targetLeft) ? Math.max(0, Math.min(maxLeft, targetLeft)) : void 0,
3738
3820
  behavior
3739
3821
  });
3740
3822
  }
@@ -3850,12 +3932,15 @@ var LayoutEngine = class {
3850
3932
  */
3851
3933
  static parseGutter(gutterOption) {
3852
3934
  if (typeof gutterOption === "number") {
3853
- return { x: Math.max(0, gutterOption), y: Math.max(0, gutterOption) };
3935
+ const v = Number.isFinite(gutterOption) ? Math.max(0, gutterOption) : 0;
3936
+ return { x: v, y: v };
3854
3937
  }
3855
3938
  if (gutterOption && typeof gutterOption === "object") {
3939
+ const rawX = Number(gutterOption.x);
3940
+ const rawY = Number(gutterOption.y);
3856
3941
  return {
3857
- x: Math.max(0, Number(gutterOption.x) || 0),
3858
- y: Math.max(0, Number(gutterOption.y) || 0)
3942
+ x: Number.isFinite(rawX) ? Math.max(0, rawX) : 0,
3943
+ y: Number.isFinite(rawY) ? Math.max(0, rawY) : 0
3859
3944
  };
3860
3945
  }
3861
3946
  return { x: 0, y: 0 };
@@ -3864,22 +3949,37 @@ var LayoutEngine = class {
3864
3949
  * Résout la largeur effective d'une colonne en pixels.
3865
3950
  */
3866
3951
  static resolveColumnWidth(container, firstItem, columnWidthOption) {
3867
- if (typeof columnWidthOption === "number" && columnWidthOption > 0) {
3952
+ if (typeof columnWidthOption === "number" && Number.isFinite(columnWidthOption) && columnWidthOption > 0) {
3868
3953
  return columnWidthOption;
3869
3954
  }
3870
3955
  if (typeof columnWidthOption === "string") {
3871
- const el = container.querySelector(columnWidthOption);
3872
- if (el) {
3873
- const w = el.getBoundingClientRect().width;
3874
- if (w > 0) return w;
3875
- }
3876
- const parsed = parseFloat(columnWidthOption);
3877
- if (!isNaN(parsed) && parsed > 0) {
3878
- if (columnWidthOption.endsWith("%")) {
3879
- const containerW2 = container.getBoundingClientRect().width;
3880
- return containerW2 * parsed / 100;
3956
+ const trimmed = columnWidthOption.trim();
3957
+ if (/^\d+(\.\d+)?(px|%)?$/i.test(trimmed)) {
3958
+ const parsed = parseFloat(trimmed);
3959
+ if (Number.isFinite(parsed) && parsed > 0) {
3960
+ if (trimmed.endsWith("%")) {
3961
+ const containerW2 = container.getBoundingClientRect().width;
3962
+ const resolvedPct = containerW2 * parsed / 100;
3963
+ if (resolvedPct > 0) return resolvedPct;
3964
+ } else {
3965
+ return parsed;
3966
+ }
3967
+ }
3968
+ } else if (trimmed) {
3969
+ let el = null;
3970
+ try {
3971
+ el = container.querySelector(trimmed);
3972
+ } catch {
3973
+ el = null;
3974
+ }
3975
+ if (el) {
3976
+ const w = el.getBoundingClientRect().width;
3977
+ if (Number.isFinite(w) && w > 0) return w;
3978
+ }
3979
+ const parsed = parseFloat(trimmed);
3980
+ if (Number.isFinite(parsed) && parsed > 0) {
3981
+ return parsed;
3881
3982
  }
3882
- return parsed;
3883
3983
  }
3884
3984
  }
3885
3985
  if (columnWidthOption instanceof HTMLElement) {
@@ -3933,8 +4033,13 @@ var LayoutEngine = class {
3933
4033
  }
3934
4034
  const firstItem = items[0] || null;
3935
4035
  let colWidth = this.resolveColumnWidth(container, firstItem, options.columnWidth);
3936
- let cols = Math.floor((containerWidth + gutterX) / (colWidth + gutterX));
3937
- cols = Math.max(1, cols);
4036
+ const denom = colWidth + gutterX;
4037
+ let cols = denom > 0 ? Math.floor((containerWidth + gutterX) / denom) : 1;
4038
+ if (!Number.isFinite(cols) || cols < 1) {
4039
+ cols = 1;
4040
+ } else if (cols > 1e3) {
4041
+ cols = 1e3;
4042
+ }
3938
4043
  if (!options.columnWidth && cols > 1) {
3939
4044
  colWidth = (containerWidth - (cols - 1) * gutterX) / cols;
3940
4045
  }
@@ -4063,7 +4168,12 @@ var Masonry = class extends LocalizedComponent {
4063
4168
  this.removeTimers = /* @__PURE__ */ new Set();
4064
4169
  this.pendingImageListeners = [];
4065
4170
  if (typeof target === "string") {
4066
- const el = document.querySelector(target);
4171
+ let el = null;
4172
+ try {
4173
+ el = document.querySelector(target);
4174
+ } catch {
4175
+ el = null;
4176
+ }
4067
4177
  if (!el) {
4068
4178
  throw new Error(`[Wulf.Masonry] Conteneur introuvable pour le s\xE9lecteur : "${target}"`);
4069
4179
  }
@@ -4151,7 +4261,12 @@ var Masonry = class extends LocalizedComponent {
4151
4261
  */
4152
4262
  applyTransitionDuration() {
4153
4263
  const dur = this.options.transitionDuration;
4154
- const durValue = typeof dur === "number" ? `${dur}ms` : dur;
4264
+ let durValue = "300ms";
4265
+ if (typeof dur === "number" && Number.isFinite(dur) && dur >= 0) {
4266
+ durValue = `${dur}ms`;
4267
+ } else if (typeof dur === "string" && /^\s*\d+(\.\d+)?(ms|s)\s*$/i.test(dur)) {
4268
+ durValue = dur.trim();
4269
+ }
4155
4270
  this.root.style.setProperty("--wulf-masonry-duration", durValue);
4156
4271
  }
4157
4272
  /**
@@ -4497,6 +4612,13 @@ var toastI18n = createI18nManager("fr", {
4497
4612
 
4498
4613
  // src/toast/ToastInstance.ts
4499
4614
  var nextToastId = 1;
4615
+ function isSafeCssValue(val) {
4616
+ if (!val || typeof val !== "string" || val.length > 128) return false;
4617
+ return !/[;{}<>\\]|url\s*\(/i.test(val);
4618
+ }
4619
+ function sanitizeIconClasses(icon) {
4620
+ return icon.trim().split(/\s+/).filter((token) => /^[a-zA-Z0-9_-]+$/.test(token) && !token.startsWith("wulf-toast")).slice(0, 8).join(" ");
4621
+ }
4500
4622
  var ToastInstance = class extends AuditableComponent {
4501
4623
  constructor(options, onDismiss) {
4502
4624
  super();
@@ -4566,26 +4688,29 @@ var ToastInstance = class extends AuditableComponent {
4566
4688
  el.setAttribute("role", role);
4567
4689
  el.setAttribute("aria-live", role === "alert" ? "assertive" : "polite");
4568
4690
  el.setAttribute("aria-atomic", "true");
4569
- if (this.options.backgroundColor) {
4570
- el.style.setProperty("--wulf-toast-bg", this.options.backgroundColor);
4691
+ if (this.options.backgroundColor && isSafeCssValue(this.options.backgroundColor)) {
4692
+ el.style.setProperty("--wulf-toast-bg", this.options.backgroundColor.trim());
4571
4693
  }
4572
- if (this.options.titleColor) {
4573
- el.style.setProperty("--wulf-toast-title-color", this.options.titleColor);
4694
+ if (this.options.titleColor && isSafeCssValue(this.options.titleColor)) {
4695
+ el.style.setProperty("--wulf-toast-title-color", this.options.titleColor.trim());
4574
4696
  }
4575
- if (this.options.textColor) {
4576
- el.style.setProperty("--wulf-toast-text-color", this.options.textColor);
4697
+ if (this.options.textColor && isSafeCssValue(this.options.textColor)) {
4698
+ el.style.setProperty("--wulf-toast-text-color", this.options.textColor.trim());
4577
4699
  }
4578
- if (this.options.iconColor) {
4579
- el.style.setProperty("--wulf-toast-icon-color", this.options.iconColor);
4700
+ if (this.options.iconColor && isSafeCssValue(this.options.iconColor)) {
4701
+ el.style.setProperty("--wulf-toast-icon-color", this.options.iconColor.trim());
4580
4702
  }
4581
- if (this.options.closeButtonColor) {
4582
- el.style.setProperty("--wulf-toast-close-color", this.options.closeButtonColor);
4703
+ if (this.options.closeButtonColor && isSafeCssValue(this.options.closeButtonColor)) {
4704
+ el.style.setProperty("--wulf-toast-close-color", this.options.closeButtonColor.trim());
4583
4705
  }
4584
- if (this.options.icon && this.options.icon.trim() !== "") {
4585
- const iconContainer = document.createElement("span");
4586
- iconContainer.className = `wulf-toast-icon ${this.options.icon.trim()}`;
4587
- iconContainer.setAttribute("aria-hidden", "true");
4588
- el.appendChild(iconContainer);
4706
+ if (this.options.icon && typeof this.options.icon === "string" && this.options.icon.trim() !== "") {
4707
+ const safeIcon = sanitizeIconClasses(this.options.icon);
4708
+ if (safeIcon) {
4709
+ const iconContainer = document.createElement("span");
4710
+ iconContainer.className = `wulf-toast-icon ${safeIcon}`;
4711
+ iconContainer.setAttribute("aria-hidden", "true");
4712
+ el.appendChild(iconContainer);
4713
+ }
4589
4714
  }
4590
4715
  const content = document.createElement("div");
4591
4716
  content.className = "wulf-toast-content";
@@ -4620,14 +4745,22 @@ var ToastInstance = class extends AuditableComponent {
4620
4745
  });
4621
4746
  el.appendChild(closeBtn);
4622
4747
  }
4748
+ if (this.options.progressBar && this.remainingTime > 0) {
4749
+ el.style.setProperty("--wulf-toast-duration", `${this.remainingTime}ms`);
4750
+ const progressBar = document.createElement("div");
4751
+ progressBar.className = "wulf-toast-progress";
4752
+ progressBar.setAttribute("aria-hidden", "true");
4753
+ el.appendChild(progressBar);
4754
+ }
4623
4755
  return el;
4624
4756
  }
4625
4757
  /**
4626
4758
  * Injection de texte sécurisée gérant nativement les retours à la ligne (\n et \r\n).
4627
- * Utilise document.createTextNode et des éléments <br> créés proprement.
4759
+ * Utilise document.createTextNode et des éléments <br> créés proprement (plafonné contre le DoS DOM).
4628
4760
  */
4629
4761
  appendTextWithLineBreaks(container, text) {
4630
- const lines = text.split(/\r\n|\r|\n/);
4762
+ const safeText = String(text ?? "").slice(0, 4096);
4763
+ const lines = safeText.split(/\r\n|\r|\n/).slice(0, 100);
4631
4764
  lines.forEach((line, index) => {
4632
4765
  if (index > 0) {
4633
4766
  container.appendChild(document.createElement("br"));
@@ -4674,6 +4807,7 @@ var ToastInstance = class extends AuditableComponent {
4674
4807
  const elapsed = Date.now() - this.timerStartTime;
4675
4808
  this.remainingTime = Math.max(0, this.remainingTime - elapsed);
4676
4809
  this.isPaused = true;
4810
+ this.element.classList.add("is-paused");
4677
4811
  }
4678
4812
  /**
4679
4813
  * Reprend le compte à rebours
@@ -4681,6 +4815,7 @@ var ToastInstance = class extends AuditableComponent {
4681
4815
  resumeTimer() {
4682
4816
  if (this._isClosed || this.remainingTime <= 0 || !this.isPaused) return;
4683
4817
  this.isPaused = false;
4818
+ this.element.classList.remove("is-paused");
4684
4819
  this.startTimer();
4685
4820
  }
4686
4821
  /**
@@ -4757,6 +4892,17 @@ var ToastInstance = class extends AuditableComponent {
4757
4892
  };
4758
4893
 
4759
4894
  // src/toast/ToastManager.ts
4895
+ var VALID_POSITIONS = /* @__PURE__ */ new Set([
4896
+ "top-left",
4897
+ "top-center",
4898
+ "top-right",
4899
+ "bottom-left",
4900
+ "bottom-center",
4901
+ "bottom-right"
4902
+ ]);
4903
+ function normalizePosition(pos) {
4904
+ return pos && VALID_POSITIONS.has(pos) ? pos : "top-right";
4905
+ }
4760
4906
  var _ToastManager = class _ToastManager {
4761
4907
  constructor() {
4762
4908
  this.containers = /* @__PURE__ */ new Map();
@@ -4774,7 +4920,7 @@ var _ToastManager = class _ToastManager {
4774
4920
  * Ajoute et affiche une notification Toast.
4775
4921
  */
4776
4922
  add(toast) {
4777
- const position = toast.options.position || "top-right";
4923
+ const position = normalizePosition(toast.options.position);
4778
4924
  let list = this.activeToasts.get(position);
4779
4925
  if (!list) {
4780
4926
  list = [];
@@ -4791,11 +4937,12 @@ var _ToastManager = class _ToastManager {
4791
4937
  if (this.replaceTokens.get(position) !== token) {
4792
4938
  return;
4793
4939
  }
4794
- this.mountToast(toast, position);
4940
+ this.mountToast(toast, position, 5);
4795
4941
  });
4796
4942
  return;
4797
4943
  }
4798
- const maxToasts = typeof toast.options.maxToasts === "number" && toast.options.maxToasts > 0 ? toast.options.maxToasts : 5;
4944
+ const rawMax = toast.options.maxToasts;
4945
+ const maxToasts = typeof rawMax === "number" && Number.isFinite(rawMax) && rawMax > 0 ? Math.min(50, Math.max(1, Math.floor(rawMax))) : 5;
4799
4946
  if (list.length >= maxToasts) {
4800
4947
  const countToRemove = list.length - maxToasts + 1;
4801
4948
  const oldestItems = list.splice(0, countToRemove);
@@ -4803,18 +4950,28 @@ var _ToastManager = class _ToastManager {
4803
4950
  item.close("max-limit", true);
4804
4951
  }
4805
4952
  }
4806
- this.mountToast(toast, position);
4953
+ this.mountToast(toast, position, maxToasts);
4807
4954
  }
4808
4955
  /**
4809
4956
  * Insère l'élément toast dans le DOM et déclenche les callbacks et compteurs.
4810
4957
  */
4811
- mountToast(toast, position) {
4958
+ mountToast(toast, position, maxToasts = 5) {
4812
4959
  const container = this.getOrCreateContainer(position);
4813
4960
  let list = this.activeToasts.get(position);
4814
4961
  if (!list) {
4815
4962
  list = [];
4816
4963
  this.activeToasts.set(position, list);
4817
4964
  }
4965
+ const maxDomNodes = maxToasts + 10;
4966
+ if (container.children.length >= maxDomNodes) {
4967
+ const children = Array.from(container.children);
4968
+ for (const child of children) {
4969
+ if (container.children.length < maxDomNodes) break;
4970
+ if (child.classList.contains("wulf-toast-hiding") || child.classList.contains("wulf-toast-hiding-fast")) {
4971
+ child.remove();
4972
+ }
4973
+ }
4974
+ }
4818
4975
  container.appendChild(toast.element);
4819
4976
  list.push(toast);
4820
4977
  if (toast.options.onOpen) {
@@ -4830,7 +4987,7 @@ var _ToastManager = class _ToastManager {
4830
4987
  * Retire une notification de la pile et nettoie le conteneur s'il est vide.
4831
4988
  */
4832
4989
  remove(toast, _reason) {
4833
- const position = toast.options.position || "top-right";
4990
+ const position = normalizePosition(toast.options.position);
4834
4991
  const list = this.activeToasts.get(position);
4835
4992
  if (list) {
4836
4993
  const index = list.indexOf(toast);
@@ -4972,12 +5129,29 @@ var FOCUSABLE_SELECTOR = [
4972
5129
  "select:not([disabled])",
4973
5130
  "textarea:not([disabled])",
4974
5131
  "button:not([disabled])",
5132
+ "audio[controls]",
5133
+ "video[controls]",
5134
+ "details > summary:first-of-type",
4975
5135
  "iframe",
4976
5136
  "object",
4977
5137
  "embed",
4978
- '[contenteditable="true"]',
5138
+ '[contenteditable]:not([contenteditable="false"])',
4979
5139
  '[tabindex]:not([tabindex="-1"])'
4980
5140
  ].join(",");
5141
+ function safeCssEscape(value) {
5142
+ if (typeof CSS !== "undefined" && typeof CSS.escape === "function") {
5143
+ return CSS.escape(value);
5144
+ }
5145
+ return String(value).replace(/["\\]/g, "\\$&");
5146
+ }
5147
+ function safeQuerySelector(root, selector) {
5148
+ if (!selector || typeof selector !== "string") return null;
5149
+ try {
5150
+ return root.querySelector(selector);
5151
+ } catch {
5152
+ return null;
5153
+ }
5154
+ }
4981
5155
  var trapStack = [];
4982
5156
  var FocusTrap = class extends AuditableComponent {
4983
5157
  constructor(target, options = {}) {
@@ -4989,7 +5163,7 @@ var FocusTrap = class extends AuditableComponent {
4989
5163
  // Sentinelles anti-fuite de focus
4990
5164
  this.startSentinel = null;
4991
5165
  this.endSentinel = null;
4992
- const el = typeof target === "string" ? document.querySelector(target) : target;
5166
+ const el = typeof target === "string" ? safeQuerySelector(document, target) : target;
4993
5167
  if (!el || !(el instanceof HTMLElement)) {
4994
5168
  throw new Error(`[Wulf.FocusTrap] Conteneur introuvable ou invalide : "${target}"`);
4995
5169
  }
@@ -5029,7 +5203,7 @@ var FocusTrap = class extends AuditableComponent {
5029
5203
  }
5030
5204
  if (el instanceof HTMLInputElement && el.type === "radio" && el.name) {
5031
5205
  const group = Array.from(
5032
- this.element.querySelectorAll(`input[type="radio"][name="${CSS.escape(el.name)}"]`)
5206
+ this.element.querySelectorAll(`input[type="radio"][name="${safeCssEscape(el.name)}"]`)
5033
5207
  );
5034
5208
  const checked = group.find((r) => r.checked);
5035
5209
  if (checked) {
@@ -5066,6 +5240,7 @@ var FocusTrap = class extends AuditableComponent {
5066
5240
  document.addEventListener("keydown", this.handleKeyDownBound, true);
5067
5241
  document.addEventListener("focusin", this.handleFocusInBound, true);
5068
5242
  if (!this.options.allowOutsideClick) {
5243
+ document.addEventListener("pointerdown", this.handleClickOutsideBound, true);
5069
5244
  document.addEventListener("mousedown", this.handleClickOutsideBound, true);
5070
5245
  document.addEventListener("touchstart", this.handleClickOutsideBound, true);
5071
5246
  }
@@ -5091,6 +5266,7 @@ var FocusTrap = class extends AuditableComponent {
5091
5266
  }
5092
5267
  document.removeEventListener("keydown", this.handleKeyDownBound, true);
5093
5268
  document.removeEventListener("focusin", this.handleFocusInBound, true);
5269
+ document.removeEventListener("pointerdown", this.handleClickOutsideBound, true);
5094
5270
  document.removeEventListener("mousedown", this.handleClickOutsideBound, true);
5095
5271
  document.removeEventListener("touchstart", this.handleClickOutsideBound, true);
5096
5272
  this.removeSentinels();
@@ -5160,8 +5336,34 @@ var FocusTrap = class extends AuditableComponent {
5160
5336
  this.deactivate();
5161
5337
  }
5162
5338
  // --- Implémentation interne ---
5339
+ isEventInside(e, target) {
5340
+ if (target && this.element.contains(target)) {
5341
+ return true;
5342
+ }
5343
+ if (typeof e.composedPath === "function") {
5344
+ const path = e.composedPath();
5345
+ if (path.includes(this.element)) {
5346
+ return true;
5347
+ }
5348
+ }
5349
+ return false;
5350
+ }
5351
+ applySentinelStyles(el) {
5352
+ const s = el.style;
5353
+ s.position = "fixed";
5354
+ s.top = "0";
5355
+ s.left = "0";
5356
+ s.opacity = "0";
5357
+ s.pointerEvents = "none";
5358
+ s.width = "0";
5359
+ s.height = "0";
5360
+ }
5163
5361
  handleKeyDown(e) {
5164
5362
  if (!this.isActive()) return;
5363
+ if (this.element.isConnected === false) {
5364
+ this.deactivate();
5365
+ return;
5366
+ }
5165
5367
  if (e.key === "Escape" && this.options.escapeDeactivates) {
5166
5368
  e.preventDefault();
5167
5369
  e.stopPropagation();
@@ -5191,6 +5393,10 @@ var FocusTrap = class extends AuditableComponent {
5191
5393
  }
5192
5394
  handleFocusIn(e) {
5193
5395
  if (!this.isActive()) return;
5396
+ if (this.element.isConnected === false) {
5397
+ this.deactivate();
5398
+ return;
5399
+ }
5194
5400
  const target = e.target;
5195
5401
  if (!target) return;
5196
5402
  if (target === this.startSentinel) {
@@ -5211,7 +5417,7 @@ var FocusTrap = class extends AuditableComponent {
5211
5417
  }
5212
5418
  return;
5213
5419
  }
5214
- if (!this.element.contains(target)) {
5420
+ if (!this.isEventInside(e, target)) {
5215
5421
  const focusables = this.getFocusableElements();
5216
5422
  if (focusables.length > 0) {
5217
5423
  focusables[0].focus();
@@ -5225,8 +5431,12 @@ var FocusTrap = class extends AuditableComponent {
5225
5431
  }
5226
5432
  handleClickOutside(e) {
5227
5433
  if (!this.isActive()) return;
5434
+ if (this.element.isConnected === false) {
5435
+ this.deactivate();
5436
+ return;
5437
+ }
5228
5438
  const target = e.target;
5229
- if (target && !this.element.contains(target)) {
5439
+ if (target && !this.isEventInside(e, target)) {
5230
5440
  e.preventDefault();
5231
5441
  e.stopPropagation();
5232
5442
  }
@@ -5237,14 +5447,14 @@ var FocusTrap = class extends AuditableComponent {
5237
5447
  this.startSentinel.setAttribute("tabindex", "0");
5238
5448
  this.startSentinel.setAttribute("aria-hidden", "true");
5239
5449
  this.startSentinel.className = "wulf-sentinel-start";
5240
- this.startSentinel.style.cssText = "position:fixed;top:0;left:0;opacity:0;pointer-events:none;width:0;height:0;";
5450
+ this.applySentinelStyles(this.startSentinel);
5241
5451
  }
5242
5452
  if (!this.endSentinel) {
5243
5453
  this.endSentinel = document.createElement("span");
5244
5454
  this.endSentinel.setAttribute("tabindex", "0");
5245
5455
  this.endSentinel.setAttribute("aria-hidden", "true");
5246
5456
  this.endSentinel.className = "wulf-sentinel-end";
5247
- this.endSentinel.style.cssText = "position:fixed;top:0;left:0;opacity:0;pointer-events:none;width:0;height:0;";
5457
+ this.applySentinelStyles(this.endSentinel);
5248
5458
  }
5249
5459
  if (this.element.parentNode) {
5250
5460
  this.element.parentNode.insertBefore(this.startSentinel, this.element);
@@ -5282,7 +5492,7 @@ var FocusTrap = class extends AuditableComponent {
5282
5492
  if (this.options.initialFocus === false) return;
5283
5493
  let targetEl = null;
5284
5494
  if (typeof this.options.initialFocus === "string") {
5285
- targetEl = this.element.querySelector(this.options.initialFocus);
5495
+ targetEl = safeQuerySelector(this.element, this.options.initialFocus);
5286
5496
  } else if (this.options.initialFocus instanceof HTMLElement) {
5287
5497
  targetEl = this.options.initialFocus;
5288
5498
  }
@@ -5306,7 +5516,7 @@ var FocusTrap = class extends AuditableComponent {
5306
5516
  return;
5307
5517
  }
5308
5518
  if (this.options.fallbackReturnFocus) {
5309
- const fallback = typeof this.options.fallbackReturnFocus === "string" ? document.querySelector(this.options.fallbackReturnFocus) : this.options.fallbackReturnFocus;
5519
+ const fallback = typeof this.options.fallbackReturnFocus === "string" ? safeQuerySelector(document, this.options.fallbackReturnFocus) : this.options.fallbackReturnFocus;
5310
5520
  if (fallback && fallback.isConnected) {
5311
5521
  fallback.focus();
5312
5522
  }
@@ -5323,6 +5533,640 @@ if (typeof window !== "undefined") {
5323
5533
  FocusTrap
5324
5534
  });
5325
5535
  }
5536
+
5537
+ // src/shortcut/index.ts
5538
+ var shortcut_exports = {};
5539
+ __export(shortcut_exports, {
5540
+ ShortcutFormatter: () => ShortcutFormatter,
5541
+ ShortcutManager: () => ShortcutManager,
5542
+ default: () => ShortcutManager
5543
+ });
5544
+
5545
+ // src/shortcut/ShortcutFormatter.ts
5546
+ var ShortcutFormatter = class _ShortcutFormatter {
5547
+ /**
5548
+ * Détecte si l'environnement d'exécution actuel est un environnement Apple (macOS / iOS / iPadOS).
5549
+ */
5550
+ static isApple() {
5551
+ if (typeof navigator === "undefined") {
5552
+ return false;
5553
+ }
5554
+ const uaData = navigator.userAgentData;
5555
+ if (uaData && typeof uaData.platform === "string") {
5556
+ const p = uaData.platform.toLowerCase();
5557
+ if (p.includes("mac") || p.includes("ios")) {
5558
+ return true;
5559
+ }
5560
+ }
5561
+ const platform = (navigator.platform || "").toLowerCase();
5562
+ if (platform.includes("mac") || platform.includes("iphone") || platform.includes("ipad") || platform.includes("ipod")) {
5563
+ return true;
5564
+ }
5565
+ const ua = (navigator.userAgent || "").toLowerCase();
5566
+ return ua.includes("macintosh") || ua.includes("mac os x") || ua.includes("ipad") || ua.includes("iphone");
5567
+ }
5568
+ /**
5569
+ * Normalise un nom de touche unitaire pour les comparaisons.
5570
+ */
5571
+ static normalizeKeyName(key) {
5572
+ const k = key.trim().toLowerCase();
5573
+ switch (k) {
5574
+ case "esc":
5575
+ return "escape";
5576
+ case "return":
5577
+ return "enter";
5578
+ case "space":
5579
+ case "spacebar":
5580
+ return " ";
5581
+ case "del":
5582
+ return "delete";
5583
+ case "ins":
5584
+ return "insert";
5585
+ case "up":
5586
+ return "arrowup";
5587
+ case "down":
5588
+ return "arrowdown";
5589
+ case "left":
5590
+ return "arrowleft";
5591
+ case "right":
5592
+ return "arrowright";
5593
+ default:
5594
+ return k;
5595
+ }
5596
+ }
5597
+ /**
5598
+ * Parse une chaîne de combinaison (ex: "Mod+K", "g i", "Shift+?", "Alt++")
5599
+ * et retourne la liste des étapes normalisées nécessaires au déclenchement.
5600
+ */
5601
+ static parseCombo(combo, isApple = _ShortcutFormatter.isApple()) {
5602
+ if (typeof combo !== "string") {
5603
+ return [];
5604
+ }
5605
+ const trimmed = combo.slice(0, 512).trim();
5606
+ if (!trimmed) {
5607
+ return [];
5608
+ }
5609
+ const stepsRaw = trimmed.split(/\s+/).slice(0, 10);
5610
+ const steps = [];
5611
+ for (const rawStep of stepsRaw) {
5612
+ const tokens = [];
5613
+ let currentToken = "";
5614
+ for (let i = 0; i < rawStep.length; i++) {
5615
+ const char = rawStep[i];
5616
+ if (char === "+") {
5617
+ if (currentToken === "" && tokens.length > 0) {
5618
+ tokens.push("+");
5619
+ } else if (currentToken !== "") {
5620
+ tokens.push(currentToken);
5621
+ currentToken = "";
5622
+ }
5623
+ } else {
5624
+ currentToken += char;
5625
+ }
5626
+ }
5627
+ if (currentToken !== "") {
5628
+ tokens.push(currentToken);
5629
+ }
5630
+ let ctrl = false;
5631
+ let alt = false;
5632
+ let shift = false;
5633
+ let meta = false;
5634
+ let mainKey = "";
5635
+ for (const token of tokens) {
5636
+ const lower = token.trim().toLowerCase();
5637
+ if (lower === "ctrl" || lower === "control") {
5638
+ ctrl = true;
5639
+ } else if (lower === "alt" || lower === "option" || lower === "opt") {
5640
+ alt = true;
5641
+ } else if (lower === "shift" || lower === "maj") {
5642
+ shift = true;
5643
+ } else if (lower === "cmd" || lower === "command" || lower === "meta" || lower === "win" || lower === "super") {
5644
+ meta = true;
5645
+ } else if (lower === "mod" || lower === "$mod") {
5646
+ if (isApple) {
5647
+ meta = true;
5648
+ } else {
5649
+ ctrl = true;
5650
+ }
5651
+ } else {
5652
+ mainKey = _ShortcutFormatter.normalizeKeyName(token);
5653
+ }
5654
+ }
5655
+ steps.push({
5656
+ ctrl,
5657
+ alt,
5658
+ shift,
5659
+ meta,
5660
+ key: mainKey
5661
+ });
5662
+ }
5663
+ return steps;
5664
+ }
5665
+ /**
5666
+ * Formate une combinaison brute en libellé soigné et lisible pour l'OS cible.
5667
+ * Ex: "Mod+Shift+P" -> macOS: "⇧⌘P", Windows: "Ctrl+Shift+P"
5668
+ * Ex: "g i" -> "g puis i" ou "g i"
5669
+ */
5670
+ static format(combo, isApple = _ShortcutFormatter.isApple()) {
5671
+ const steps = _ShortcutFormatter.parseCombo(combo, isApple);
5672
+ if (steps.length === 0) {
5673
+ return combo;
5674
+ }
5675
+ const formattedSteps = steps.map((step) => {
5676
+ const parts = [];
5677
+ if (isApple) {
5678
+ if (step.ctrl) parts.push("\u2303");
5679
+ if (step.alt) parts.push("\u2325");
5680
+ if (step.shift) parts.push("\u21E7");
5681
+ if (step.meta) parts.push("\u2318");
5682
+ const keyDisplay = _ShortcutFormatter.formatKeyDisplay(step.key, true);
5683
+ parts.push(keyDisplay);
5684
+ return parts.join("");
5685
+ } else {
5686
+ if (step.ctrl) parts.push("Ctrl");
5687
+ if (step.alt) parts.push("Alt");
5688
+ if (step.shift) parts.push("Shift");
5689
+ if (step.meta) parts.push("Win");
5690
+ const keyDisplay = _ShortcutFormatter.formatKeyDisplay(step.key, false);
5691
+ parts.push(keyDisplay);
5692
+ return parts.join("+");
5693
+ }
5694
+ });
5695
+ return formattedSteps.join(" ");
5696
+ }
5697
+ /**
5698
+ * Convertit un combo technique vers le format officiel WAI-ARIA `aria-keyshortcuts`.
5699
+ * Standard W3C : les modificateurs sont 'Control', 'Alt', 'Shift', 'Meta' et le séparateur est '+'.
5700
+ */
5701
+ static toAriaKeyShortcuts(combo, isApple = _ShortcutFormatter.isApple()) {
5702
+ const steps = _ShortcutFormatter.parseCombo(combo, isApple);
5703
+ return steps.map((step) => {
5704
+ const parts = [];
5705
+ if (step.ctrl) parts.push("Control");
5706
+ if (step.alt) parts.push("Alt");
5707
+ if (step.shift) parts.push("Shift");
5708
+ if (step.meta) parts.push("Meta");
5709
+ parts.push(_ShortcutFormatter.formatKeyDisplay(step.key, false));
5710
+ return parts.join("+");
5711
+ }).join(" ");
5712
+ }
5713
+ static formatKeyDisplay(key, isApple) {
5714
+ if (!key) return "";
5715
+ switch (key.toLowerCase()) {
5716
+ case "escape":
5717
+ return isApple ? "\u238B" : "Esc";
5718
+ case "enter":
5719
+ return isApple ? "\u21A9" : "Enter";
5720
+ case " ":
5721
+ return isApple ? "\u2423" : "Space";
5722
+ case "tab":
5723
+ return isApple ? "\u21E5" : "Tab";
5724
+ case "backspace":
5725
+ return isApple ? "\u232B" : "Backspace";
5726
+ case "delete":
5727
+ return isApple ? "\u2326" : "Suppr";
5728
+ case "arrowup":
5729
+ return "\u2191";
5730
+ case "arrowdown":
5731
+ return "\u2193";
5732
+ case "arrowleft":
5733
+ return "\u2190";
5734
+ case "arrowright":
5735
+ return "\u2192";
5736
+ default:
5737
+ return key.length === 1 ? key.toUpperCase() : key.charAt(0).toUpperCase() + key.slice(1);
5738
+ }
5739
+ }
5740
+ };
5741
+
5742
+ // src/shortcut/ShortcutManager.ts
5743
+ var ShortcutManager = class _ShortcutManager {
5744
+ constructor(options) {
5745
+ this.shortcuts = /* @__PURE__ */ new Map();
5746
+ this.scopeStack = [];
5747
+ this.sequenceBuffer = [];
5748
+ this.sequenceTimer = null;
5749
+ this.isListening = true;
5750
+ this.boundListener = null;
5751
+ this.idCounter = 0;
5752
+ this.options = {
5753
+ defaultScope: options?.defaultScope || "global",
5754
+ sequenceTimeout: options?.sequenceTimeout ?? 800,
5755
+ target: options?.target || (typeof window !== "undefined" ? window : {}),
5756
+ onError: options?.onError
5757
+ };
5758
+ this.scopeStack = [this.options.defaultScope];
5759
+ this.initListener();
5760
+ }
5761
+ /**
5762
+ * Vérifie si un élément DOM est une zone d'édition où la saisie de l'utilisateur
5763
+ * ne doit JAMAIS être interrompue ou détournée (Axiome Primordial).
5764
+ */
5765
+ static isEditable(target) {
5766
+ if (!target || typeof target.tagName !== "string") {
5767
+ return false;
5768
+ }
5769
+ const el = target;
5770
+ const tagName = el.tagName.toUpperCase();
5771
+ if (tagName === "INPUT") {
5772
+ const type = el.type?.toLowerCase() || "text";
5773
+ const nonTextTypes = ["button", "checkbox", "radio", "submit", "reset", "range", "color", "file", "image"];
5774
+ return !nonTextTypes.includes(type);
5775
+ }
5776
+ if (tagName === "TEXTAREA" || tagName === "SELECT") {
5777
+ return true;
5778
+ }
5779
+ if (el.isContentEditable || el.getAttribute("contenteditable") === "true" || el.getAttribute("contenteditable") === "plaintext-only" || el.getAttribute("contenteditable") === "") {
5780
+ return true;
5781
+ }
5782
+ const role = el.getAttribute("role");
5783
+ if (role === "textbox" || role === "searchbox") {
5784
+ return true;
5785
+ }
5786
+ if (typeof el.closest === "function") {
5787
+ const editableAncestor = el.closest(
5788
+ '[contenteditable="true"], [contenteditable="plaintext-only"], [contenteditable=""], [role="textbox"], [role="searchbox"]'
5789
+ );
5790
+ if (editableAncestor) {
5791
+ return true;
5792
+ }
5793
+ }
5794
+ return false;
5795
+ }
5796
+ /**
5797
+ * Vérifie si la cible est un champ de mot de passe (sanctuaire anti-keylogging).
5798
+ */
5799
+ static isPasswordField(target) {
5800
+ if (!target || typeof target.tagName !== "string") {
5801
+ return false;
5802
+ }
5803
+ const el = target;
5804
+ return el.tagName.toUpperCase() === "INPUT" && (el.type || "").toLowerCase() === "password";
5805
+ }
5806
+ /**
5807
+ * Enregistre un ou plusieurs raccourcis clavier.
5808
+ * Retourne une fonction de nettoyage pour désenregistrer immédiatement.
5809
+ */
5810
+ bind(definition) {
5811
+ const list = Array.isArray(definition) ? definition : [definition];
5812
+ const registeredIds = [];
5813
+ for (const def of list) {
5814
+ if (!def.combo || typeof def.handler !== "function") {
5815
+ continue;
5816
+ }
5817
+ const id = `wulf_shortcut_${++this.idCounter}`;
5818
+ const normalizedSteps = ShortcutFormatter.parseCombo(def.combo);
5819
+ const isSequence = normalizedSteps.length > 1;
5820
+ const formattedCombo = ShortcutFormatter.format(def.combo);
5821
+ const registered = {
5822
+ ...def,
5823
+ id,
5824
+ scope: def.scope || "global",
5825
+ category: def.category || "G\xE9n\xE9ral",
5826
+ allowInEditable: def.allowInEditable ?? false,
5827
+ preventDefault: def.preventDefault ?? true,
5828
+ stopPropagation: def.stopPropagation ?? true,
5829
+ priority: def.priority ?? 0,
5830
+ formattedCombo,
5831
+ normalizedSteps,
5832
+ isSequence
5833
+ };
5834
+ this.shortcuts.set(id, registered);
5835
+ registeredIds.push(id);
5836
+ }
5837
+ return () => {
5838
+ for (const id of registeredIds) {
5839
+ this.shortcuts.delete(id);
5840
+ }
5841
+ };
5842
+ }
5843
+ /**
5844
+ * Retire tous les raccourcis correspondant à une combinaison et éventuellement un scope.
5845
+ */
5846
+ unbind(combo, scope) {
5847
+ const formatted = ShortcutFormatter.format(combo);
5848
+ for (const [id, s] of this.shortcuts.entries()) {
5849
+ if (s.formattedCombo === formatted || s.combo.trim().toLowerCase() === combo.trim().toLowerCase()) {
5850
+ if (!scope || s.scope === scope) {
5851
+ this.shortcuts.delete(id);
5852
+ }
5853
+ }
5854
+ }
5855
+ }
5856
+ /**
5857
+ * Empile un nouveau scope actif (mode LIFO).
5858
+ * Seuls les raccourcis de ce scope (et les omniprésents '*') seront actifs.
5859
+ */
5860
+ pushScope(scope) {
5861
+ if (scope && typeof scope === "string") {
5862
+ if (this.scopeStack.length >= 64) {
5863
+ return;
5864
+ }
5865
+ this.scopeStack.push(scope);
5866
+ this.clearSequenceBuffer();
5867
+ }
5868
+ }
5869
+ /**
5870
+ * Dépile le scope actuel et rétablit le précédent.
5871
+ * Si un paramètre `scope` est passé, ne retire que si le scope actuel correspond.
5872
+ */
5873
+ popScope(scope) {
5874
+ if (this.scopeStack.length <= 1) {
5875
+ return this.scopeStack[0];
5876
+ }
5877
+ if (scope) {
5878
+ if (this.getScope() === scope) {
5879
+ const popped2 = this.scopeStack.pop();
5880
+ this.clearSequenceBuffer();
5881
+ return popped2;
5882
+ }
5883
+ return void 0;
5884
+ }
5885
+ const popped = this.scopeStack.pop();
5886
+ this.clearSequenceBuffer();
5887
+ return popped;
5888
+ }
5889
+ /**
5890
+ * Réinitialise brutalement la pile pour activer le scope spécifié.
5891
+ */
5892
+ setScope(scope) {
5893
+ this.scopeStack = [scope || this.options.defaultScope];
5894
+ this.clearSequenceBuffer();
5895
+ }
5896
+ /**
5897
+ * Retourne le scope actuellement actif au sommet de la pile.
5898
+ */
5899
+ getScope() {
5900
+ return this.scopeStack[this.scopeStack.length - 1] || this.options.defaultScope;
5901
+ }
5902
+ /**
5903
+ * Retourne une copie de la pile complète des scopes.
5904
+ */
5905
+ getScopeStack() {
5906
+ return [...this.scopeStack];
5907
+ }
5908
+ /**
5909
+ * Met en pause l'écoute de tous les raccourcis.
5910
+ */
5911
+ pause() {
5912
+ this.isListening = false;
5913
+ this.clearSequenceBuffer();
5914
+ }
5915
+ /**
5916
+ * Réactive l'écoute des raccourcis.
5917
+ */
5918
+ resume() {
5919
+ this.isListening = true;
5920
+ }
5921
+ /**
5922
+ * Indique si le gestionnaire est actif et à l'écoute.
5923
+ */
5924
+ isActive() {
5925
+ return this.isListening;
5926
+ }
5927
+ /**
5928
+ * Retourne le catalogue des raccourcis enregistrés (optionnellement filtré par scope).
5929
+ */
5930
+ getRegistry(scope) {
5931
+ const list = [];
5932
+ for (const shortcut of this.shortcuts.values()) {
5933
+ if (!scope || shortcut.scope === scope || shortcut.scope === "*") {
5934
+ list.push({ ...shortcut });
5935
+ }
5936
+ }
5937
+ return list;
5938
+ }
5939
+ /**
5940
+ * Associe l'attribut standard WAI-ARIA `aria-keyshortcuts` sur un élément DOM.
5941
+ */
5942
+ attachAria(element, combo) {
5943
+ if (element && typeof element.setAttribute === "function") {
5944
+ const ariaValue = ShortcutFormatter.toAriaKeyShortcuts(combo);
5945
+ element.setAttribute("aria-keyshortcuts", ariaValue);
5946
+ }
5947
+ }
5948
+ /**
5949
+ * Formate une combinaison brute selon l'OS courant ("⌘K" ou "Ctrl+K").
5950
+ */
5951
+ static format(combo, isApple) {
5952
+ return ShortcutFormatter.format(combo, isApple);
5953
+ }
5954
+ /**
5955
+ * Détruit le gestionnaire : supprime les écouteurs du DOM et vide toute la mémoire.
5956
+ */
5957
+ destroy() {
5958
+ this.pause();
5959
+ this.removeListener();
5960
+ this.shortcuts.clear();
5961
+ this.scopeStack = [];
5962
+ this.clearSequenceBuffer();
5963
+ }
5964
+ // --- Implémentation Interne ---
5965
+ initListener() {
5966
+ if (typeof window === "undefined" || !this.options.target) {
5967
+ return;
5968
+ }
5969
+ this.boundListener = (event) => this.handleKeyDown(event);
5970
+ const target = this.options.target;
5971
+ if (typeof target.addEventListener === "function") {
5972
+ target.addEventListener("keydown", this.boundListener, false);
5973
+ }
5974
+ }
5975
+ removeListener() {
5976
+ if (this.boundListener && this.options.target) {
5977
+ const target = this.options.target;
5978
+ if (typeof target.removeEventListener === "function") {
5979
+ target.removeEventListener("keydown", this.boundListener, false);
5980
+ }
5981
+ this.boundListener = null;
5982
+ }
5983
+ }
5984
+ handleKeyDown(event) {
5985
+ if (!this.isListening) {
5986
+ return;
5987
+ }
5988
+ const k = (event.key || "").toLowerCase();
5989
+ if (["control", "alt", "shift", "meta"].includes(k)) {
5990
+ return;
5991
+ }
5992
+ const currentScope = this.getScope();
5993
+ const composed = typeof event.composedPath === "function" ? event.composedPath() : [];
5994
+ const actualTarget = composed.length > 0 ? composed[0] : event.target;
5995
+ const isEditable = _ShortcutManager.isEditable(actualTarget) || _ShortcutManager.isEditable(event.target);
5996
+ const isPasswordInput = _ShortcutManager.isPasswordField(actualTarget) || _ShortcutManager.isPasswordField(event.target);
5997
+ const currentStep = {
5998
+ ctrl: event.ctrlKey,
5999
+ alt: event.altKey,
6000
+ shift: event.shiftKey,
6001
+ meta: event.metaKey,
6002
+ key: ShortcutFormatter.normalizeKeyName(event.key || "")
6003
+ };
6004
+ const now = Date.now();
6005
+ if (this.sequenceBuffer.length > 0) {
6006
+ const last = this.sequenceBuffer[this.sequenceBuffer.length - 1];
6007
+ if (now - last.timestamp > this.options.sequenceTimeout) {
6008
+ this.clearSequenceBuffer();
6009
+ }
6010
+ }
6011
+ const activeCandidates = this.getActiveShortcuts(currentScope, isEditable, isPasswordInput);
6012
+ const proposedSequence = [...this.sequenceBuffer.map((b) => b.step), currentStep];
6013
+ const matchingSequence = this.findMatchingSequence(activeCandidates, proposedSequence);
6014
+ if (matchingSequence) {
6015
+ this.clearSequenceBuffer();
6016
+ this.executeShortcut(matchingSequence, event, currentScope, true);
6017
+ return;
6018
+ }
6019
+ if (this.isPrefixOfAnySequence(activeCandidates, proposedSequence)) {
6020
+ this.sequenceBuffer.push({ step: currentStep, timestamp: now });
6021
+ this.resetSequenceTimer();
6022
+ if (event.key.length === 1 && !event.ctrlKey && !event.altKey && !event.metaKey && !isEditable) {
6023
+ event.preventDefault();
6024
+ }
6025
+ return;
6026
+ }
6027
+ this.clearSequenceBuffer();
6028
+ const matchingChord = this.findMatchingChord(activeCandidates, currentStep, event);
6029
+ if (matchingChord) {
6030
+ this.executeShortcut(matchingChord, event, currentScope, false);
6031
+ }
6032
+ }
6033
+ getActiveShortcuts(currentScope, isEditable, isPasswordInput = false) {
6034
+ const list = [];
6035
+ for (const shortcut of this.shortcuts.values()) {
6036
+ if (shortcut.scope !== currentScope && shortcut.scope !== "*") {
6037
+ continue;
6038
+ }
6039
+ if (isEditable && !shortcut.allowInEditable) {
6040
+ continue;
6041
+ }
6042
+ if (isPasswordInput) {
6043
+ if (shortcut.isSequence) {
6044
+ continue;
6045
+ }
6046
+ const firstStep = shortcut.normalizedSteps[0];
6047
+ if (firstStep && firstStep.key.length === 1 && !firstStep.ctrl && !firstStep.alt && !firstStep.meta) {
6048
+ continue;
6049
+ }
6050
+ }
6051
+ list.push(shortcut);
6052
+ }
6053
+ return list.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
6054
+ }
6055
+ stepMatches(step, eventStep, rawEvent) {
6056
+ if (step.ctrl !== eventStep.ctrl) return false;
6057
+ if (step.alt !== eventStep.alt) return false;
6058
+ if (step.meta !== eventStep.meta) return false;
6059
+ const keyMatches = step.key === eventStep.key || rawEvent && step.key === rawEvent.key.toLowerCase();
6060
+ if (!keyMatches) return false;
6061
+ if (step.shift === eventStep.shift) {
6062
+ return true;
6063
+ }
6064
+ if (!step.shift && eventStep.shift) {
6065
+ if (rawEvent && rawEvent.key === step.key) {
6066
+ return true;
6067
+ }
6068
+ }
6069
+ return false;
6070
+ }
6071
+ findMatchingChord(candidates, currentStep, rawEvent) {
6072
+ for (const candidate of candidates) {
6073
+ if (candidate.isSequence || candidate.normalizedSteps.length !== 1) {
6074
+ continue;
6075
+ }
6076
+ const step = candidate.normalizedSteps[0];
6077
+ if (this.stepMatches(step, currentStep, rawEvent)) {
6078
+ return candidate;
6079
+ }
6080
+ }
6081
+ return null;
6082
+ }
6083
+ findMatchingSequence(candidates, proposed) {
6084
+ for (const candidate of candidates) {
6085
+ if (!candidate.isSequence || candidate.normalizedSteps.length !== proposed.length) {
6086
+ continue;
6087
+ }
6088
+ let allMatch = true;
6089
+ for (let i = 0; i < proposed.length; i++) {
6090
+ if (!this.stepMatches(candidate.normalizedSteps[i], proposed[i])) {
6091
+ allMatch = false;
6092
+ break;
6093
+ }
6094
+ }
6095
+ if (allMatch) {
6096
+ return candidate;
6097
+ }
6098
+ }
6099
+ return null;
6100
+ }
6101
+ isPrefixOfAnySequence(candidates, proposed) {
6102
+ for (const candidate of candidates) {
6103
+ if (!candidate.isSequence || candidate.normalizedSteps.length <= proposed.length) {
6104
+ continue;
6105
+ }
6106
+ let prefixMatches = true;
6107
+ for (let i = 0; i < proposed.length; i++) {
6108
+ if (!this.stepMatches(candidate.normalizedSteps[i], proposed[i])) {
6109
+ prefixMatches = false;
6110
+ break;
6111
+ }
6112
+ }
6113
+ if (prefixMatches) {
6114
+ return true;
6115
+ }
6116
+ }
6117
+ return false;
6118
+ }
6119
+ executeShortcut(shortcut, event, scope, isSequence) {
6120
+ if (shortcut.preventDefault) {
6121
+ event.preventDefault();
6122
+ }
6123
+ if (shortcut.stopPropagation) {
6124
+ event.stopPropagation();
6125
+ }
6126
+ const info = {
6127
+ combo: shortcut.combo,
6128
+ formattedCombo: shortcut.formattedCombo,
6129
+ scope,
6130
+ target: event.target,
6131
+ isSequence
6132
+ };
6133
+ try {
6134
+ shortcut.handler(event, info);
6135
+ } catch (err) {
6136
+ if (this.options.onError) {
6137
+ this.options.onError(err instanceof Error ? err : new Error(String(err)), shortcut.combo);
6138
+ } else {
6139
+ console.error(`[Wulf.Shortcut] Erreur lors de l'ex\xE9cution du raccourci "${shortcut.combo}":`, err);
6140
+ }
6141
+ }
6142
+ }
6143
+ resetSequenceTimer() {
6144
+ if (this.sequenceTimer) {
6145
+ clearTimeout(this.sequenceTimer);
6146
+ }
6147
+ this.sequenceTimer = setTimeout(() => {
6148
+ this.clearSequenceBuffer();
6149
+ }, this.options.sequenceTimeout);
6150
+ }
6151
+ clearSequenceBuffer() {
6152
+ this.sequenceBuffer = [];
6153
+ if (this.sequenceTimer) {
6154
+ clearTimeout(this.sequenceTimer);
6155
+ this.sequenceTimer = null;
6156
+ }
6157
+ }
6158
+ };
6159
+
6160
+ // src/shortcut/index.ts
6161
+ if (typeof window !== "undefined") {
6162
+ const win = window;
6163
+ const wulfNamespace = win.Wulf || {};
6164
+ win.Wulf = wulfNamespace;
6165
+ wulfNamespace.Shortcut = Object.assign(ShortcutManager, {
6166
+ ShortcutManager,
6167
+ ShortcutFormatter
6168
+ });
6169
+ }
5326
6170
  export {
5327
6171
  AmountEngine,
5328
6172
  AuditableComponent,
@@ -5339,8 +6183,10 @@ export {
5339
6183
  MaskKeyboard,
5340
6184
  masonry_exports as Masonry,
5341
6185
  scroll_exports as Scroll,
6186
+ shortcut_exports as Shortcut,
5342
6187
  toast_exports as Toast,
5343
6188
  FocusTrap as WulfFocusTrap,
6189
+ ShortcutManager as WulfShortcut,
5344
6190
  createI18nManager,
5345
6191
  mask_default as default,
5346
6192
  resolveMaskConstructorArgs