wulf.js 1.9.2 → 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 (55) hide show
  1. package/README.md +6 -0
  2. package/changelog.md +45 -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 +364 -107
  10. package/dist/index.esm.js.map +2 -2
  11. package/dist/index.global.js +366 -109
  12. package/dist/index.global.js.map +2 -2
  13. package/dist/index.global.min.js +3 -3
  14. package/dist/index.global.min.js.map +3 -3
  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 +53 -6
  34. package/dist/shortcut.esm.js.map +3 -3
  35. package/dist/shortcut.global.js +55 -8
  36. package/dist/shortcut.global.js.map +2 -2
  37. package/dist/shortcut.global.min.js +2 -2
  38. package/dist/shortcut.global.min.js.map +3 -3
  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/mask/AmountEngine.d.ts +1 -0
  49. package/dist/types/mask/BaseInputMask.d.ts +4 -0
  50. package/dist/types/mask/InputAmountMask.d.ts +1 -0
  51. package/dist/types/mask/InputMask.d.ts +1 -0
  52. package/dist/types/shortcut/ShortcutManager.d.ts +4 -0
  53. package/dist/types/toast/ToastInstance.d.ts +1 -1
  54. package/dist/types/toast/types.d.ts +5 -0
  55. package/package.json +5 -3
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
  }
@@ -5389,11 +5599,14 @@ var ShortcutFormatter = class _ShortcutFormatter {
5389
5599
  * et retourne la liste des étapes normalisées nécessaires au déclenchement.
5390
5600
  */
5391
5601
  static parseCombo(combo, isApple = _ShortcutFormatter.isApple()) {
5392
- const trimmed = combo.trim();
5602
+ if (typeof combo !== "string") {
5603
+ return [];
5604
+ }
5605
+ const trimmed = combo.slice(0, 512).trim();
5393
5606
  if (!trimmed) {
5394
5607
  return [];
5395
5608
  }
5396
- const stepsRaw = trimmed.split(/\s+/);
5609
+ const stepsRaw = trimmed.split(/\s+/).slice(0, 10);
5397
5610
  const steps = [];
5398
5611
  for (const rawStep of stepsRaw) {
5399
5612
  const tokens = [];
@@ -5563,15 +5776,33 @@ var ShortcutManager = class _ShortcutManager {
5563
5776
  if (tagName === "TEXTAREA" || tagName === "SELECT") {
5564
5777
  return true;
5565
5778
  }
5566
- if (el.isContentEditable || el.getAttribute("contenteditable") === "true" || el.getAttribute("contenteditable") === "plaintext-only") {
5779
+ if (el.isContentEditable || el.getAttribute("contenteditable") === "true" || el.getAttribute("contenteditable") === "plaintext-only" || el.getAttribute("contenteditable") === "") {
5567
5780
  return true;
5568
5781
  }
5569
5782
  const role = el.getAttribute("role");
5570
5783
  if (role === "textbox" || role === "searchbox") {
5571
5784
  return true;
5572
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
+ }
5573
5794
  return false;
5574
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
+ }
5575
5806
  /**
5576
5807
  * Enregistre un ou plusieurs raccourcis clavier.
5577
5808
  * Retourne une fonction de nettoyage pour désenregistrer immédiatement.
@@ -5628,6 +5859,9 @@ var ShortcutManager = class _ShortcutManager {
5628
5859
  */
5629
5860
  pushScope(scope) {
5630
5861
  if (scope && typeof scope === "string") {
5862
+ if (this.scopeStack.length >= 64) {
5863
+ return;
5864
+ }
5631
5865
  this.scopeStack.push(scope);
5632
5866
  this.clearSequenceBuffer();
5633
5867
  }
@@ -5756,7 +5990,10 @@ var ShortcutManager = class _ShortcutManager {
5756
5990
  return;
5757
5991
  }
5758
5992
  const currentScope = this.getScope();
5759
- const isEditable = _ShortcutManager.isEditable(event.target);
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);
5760
5997
  const currentStep = {
5761
5998
  ctrl: event.ctrlKey,
5762
5999
  alt: event.altKey,
@@ -5771,7 +6008,7 @@ var ShortcutManager = class _ShortcutManager {
5771
6008
  this.clearSequenceBuffer();
5772
6009
  }
5773
6010
  }
5774
- const activeCandidates = this.getActiveShortcuts(currentScope, isEditable);
6011
+ const activeCandidates = this.getActiveShortcuts(currentScope, isEditable, isPasswordInput);
5775
6012
  const proposedSequence = [...this.sequenceBuffer.map((b) => b.step), currentStep];
5776
6013
  const matchingSequence = this.findMatchingSequence(activeCandidates, proposedSequence);
5777
6014
  if (matchingSequence) {
@@ -5793,7 +6030,7 @@ var ShortcutManager = class _ShortcutManager {
5793
6030
  this.executeShortcut(matchingChord, event, currentScope, false);
5794
6031
  }
5795
6032
  }
5796
- getActiveShortcuts(currentScope, isEditable) {
6033
+ getActiveShortcuts(currentScope, isEditable, isPasswordInput = false) {
5797
6034
  const list = [];
5798
6035
  for (const shortcut of this.shortcuts.values()) {
5799
6036
  if (shortcut.scope !== currentScope && shortcut.scope !== "*") {
@@ -5802,6 +6039,15 @@ var ShortcutManager = class _ShortcutManager {
5802
6039
  if (isEditable && !shortcut.allowInEditable) {
5803
6040
  continue;
5804
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
+ }
5805
6051
  list.push(shortcut);
5806
6052
  }
5807
6053
  return list.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
@@ -5910,6 +6156,17 @@ var ShortcutManager = class _ShortcutManager {
5910
6156
  }
5911
6157
  }
5912
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
+ }
5913
6170
  export {
5914
6171
  AmountEngine,
5915
6172
  AuditableComponent,