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
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- var Wulf = (() => {
2
+ var __WulfIIFE = (() => {
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -311,7 +311,8 @@ var Wulf = (() => {
311
311
  "data-disabled",
312
312
  "data-mask-align",
313
313
  "data-align",
314
- "placeholder"
314
+ "placeholder",
315
+ "type"
315
316
  ]
316
317
  };
317
318
  this.mutationObserver.observe(this.wrapper, config);
@@ -359,7 +360,12 @@ var Wulf = (() => {
359
360
  } else if (attrName === "data-mask-select-on-focus") {
360
361
  this.options.selectAllOnFocus = this.getAttr("data-mask-select-on-focus") === "true";
361
362
  } else if (attrName === "data-mask-copy-raw") {
362
- this.options.copyRaw = this.getAttr("data-mask-copy-raw") === "true";
363
+ this.options.copyRaw = this.input.type === "password" ? false : this.getAttr("data-mask-copy-raw") === "true";
364
+ } else if (attrName === "type") {
365
+ if (this.input.type === "password") {
366
+ this.options.copyRaw = false;
367
+ this.onPasswordModeDetected();
368
+ }
363
369
  } else if (attrName === "data-mask-align" || attrName === "data-align") {
364
370
  const align = this.getAttr("data-mask-align") || this.getAttr("data-align");
365
371
  if (align !== (this.options.align ?? null)) {
@@ -614,6 +620,11 @@ var Wulf = (() => {
614
620
  getSpecificAuditWarnings() {
615
621
  return [];
616
622
  }
623
+ /**
624
+ * Crochet appelé lorsque l'input bascule dynamiquement en type="password" (ex: toggle afficher/masquer).
625
+ */
626
+ onPasswordModeDetected() {
627
+ }
617
628
  /**
618
629
  * Supprime les éléments fantômes, restaure les propriétés et nettoie les attributs.
619
630
  */
@@ -698,11 +709,11 @@ var Wulf = (() => {
698
709
  compile(newPattern) {
699
710
  if (newPattern !== void 0) {
700
711
  if (Array.isArray(newPattern)) {
701
- this.patterns = [...newPattern];
712
+ this.patterns = newPattern.slice(0, 32).map((p) => String(p ?? "").slice(0, 512));
702
713
  this.pattern = this.patterns[0] || "";
703
714
  } else {
704
715
  this.patterns = [];
705
- this.pattern = newPattern;
716
+ this.pattern = String(newPattern ?? "").slice(0, 512);
706
717
  }
707
718
  }
708
719
  if (this.patterns.length > 0) {
@@ -853,7 +864,8 @@ var Wulf = (() => {
853
864
  return engine.extractRaw(input);
854
865
  }
855
866
  }
856
- const str = String(input ?? "");
867
+ const maxInputLen = Math.max(4096, this.slots.length * 4);
868
+ const str = String(input ?? "").slice(0, maxInputLen);
857
869
  if (!str) return "";
858
870
  let raw = "";
859
871
  let inputIdx = 0;
@@ -922,7 +934,8 @@ var Wulf = (() => {
922
934
  return engine.format(rawValue);
923
935
  }
924
936
  }
925
- const rawStr = String(rawValue ?? "");
937
+ const maxInputLen = Math.max(4096, this.slots.length * 4);
938
+ const rawStr = String(rawValue ?? "").slice(0, maxInputLen);
926
939
  if (!this.slots.length) return rawStr;
927
940
  const cleanRaw = this.extractRaw(rawStr);
928
941
  if (cleanRaw.length === 0) {
@@ -1425,6 +1438,9 @@ var Wulf = (() => {
1425
1438
  extractRawSnippet(snippet) {
1426
1439
  return this.engine.extractRaw(snippet);
1427
1440
  }
1441
+ onPasswordModeDetected() {
1442
+ this.history.clear();
1443
+ }
1428
1444
  /**
1429
1445
  * Formate statiquement une valeur selon un masque donné sans nécessiter d'élément DOM.
1430
1446
  *
@@ -1793,7 +1809,7 @@ var Wulf = (() => {
1793
1809
  }
1794
1810
  e.preventDefault();
1795
1811
  this.history.updateCurrentCursor(this.input.selectionStart ?? 0);
1796
- const rawPasted = e.clipboardData?.getData("text") || "";
1812
+ const rawPasted = (e.clipboardData?.getData("text") || "").slice(0, 4096);
1797
1813
  const pastedText = rawPasted.trim();
1798
1814
  if (!pastedText) return;
1799
1815
  const minPos = this.engine.getPrefixLength();
@@ -1945,7 +1961,10 @@ var Wulf = (() => {
1945
1961
  this.input.setSelectionRange(safeCursor, safeCursor);
1946
1962
  isCompleted = this.isComplete();
1947
1963
  this.wrapper.classList.toggle("is-complete", isCompleted);
1948
- if (!this.isUndoingRedoing && this.input.type !== "password") {
1964
+ if (this.input.type === "password") {
1965
+ this.options.copyRaw = false;
1966
+ this.history.clear();
1967
+ } else if (!this.isUndoingRedoing) {
1949
1968
  this.history.push(this.getRawValue(), safeCursor);
1950
1969
  }
1951
1970
  } finally {
@@ -1996,7 +2015,10 @@ var Wulf = (() => {
1996
2015
  }
1997
2016
  this.isNotifying = true;
1998
2017
  try {
1999
- while (this.input.value !== this.lastValue || this.hasPendingNotification || forceNotify) {
2018
+ let iterations = 0;
2019
+ const MAX_NOTIFICATION_ITERATIONS = 10;
2020
+ while ((this.input.value !== this.lastValue || this.hasPendingNotification || forceNotify) && iterations < MAX_NOTIFICATION_ITERATIONS) {
2021
+ iterations++;
2000
2022
  this.hasPendingNotification = false;
2001
2023
  forceNotify = false;
2002
2024
  const valToNotify = this.input.value;
@@ -2044,13 +2066,15 @@ var Wulf = (() => {
2044
2066
  currency = options.unit;
2045
2067
  }
2046
2068
  const defaultPosition = currency === "$" || currency === "\xA3" || currency === "\xA5" ? "prefix" : "suffix";
2069
+ const rawDecimals = options.decimals !== void 0 ? Number(options.decimals) : 2;
2070
+ const safeDecimals = Number.isFinite(rawDecimals) ? Math.min(20, Math.max(0, Math.floor(rawDecimals))) : 2;
2047
2071
  this.options = {
2048
- currency,
2049
- unit: options.unit ?? currency,
2072
+ currency: String(currency).slice(0, 32),
2073
+ unit: String(options.unit ?? currency).slice(0, 32),
2050
2074
  currencyPosition: options.currencyPosition ?? defaultPosition,
2051
- decimals: options.decimals !== void 0 ? Math.max(0, options.decimals) : 2,
2052
- decimalSeparator: options.decimalSeparator ?? ",",
2053
- thousandSeparator: options.thousandSeparator ?? "\xA0",
2075
+ decimals: safeDecimals,
2076
+ decimalSeparator: String(options.decimalSeparator ?? ",").slice(0, 4) || ",",
2077
+ thousandSeparator: String(options.thousandSeparator ?? "\xA0").slice(0, 4),
2054
2078
  // Espace insécable
2055
2079
  allowNegative: options.allowNegative ?? false,
2056
2080
  min: options.min ?? -Infinity,
@@ -2061,7 +2085,7 @@ var Wulf = (() => {
2061
2085
  * Analyse et nettoie une saisie utilisateur pour extraire ses composantes numériques.
2062
2086
  */
2063
2087
  parse(input) {
2064
- let str = input.trim();
2088
+ let str = String(input ?? "").slice(0, 512).trim();
2065
2089
  let isNegative = false;
2066
2090
  if (this.options.allowNegative && str.includes("-")) {
2067
2091
  isNegative = true;
@@ -2102,7 +2126,9 @@ var Wulf = (() => {
2102
2126
  * @param rawCursor Position actuelle du curseur dans l'input natif
2103
2127
  */
2104
2128
  format(input, rawCursor = input.length, padDecimals = false) {
2105
- if (!input || input.trim() === "" || input === this.options.currency.trim()) {
2129
+ const safeInput = String(input ?? "").slice(0, 512);
2130
+ const safeRawCursor = Math.max(0, Math.min(rawCursor, safeInput.length));
2131
+ if (!safeInput || safeInput.trim() === "" || safeInput === this.options.currency.trim()) {
2106
2132
  return {
2107
2133
  formatted: "",
2108
2134
  rawNumber: null,
@@ -2111,10 +2137,10 @@ var Wulf = (() => {
2111
2137
  isValid: true
2112
2138
  };
2113
2139
  }
2114
- const prefixBeforeCursor = input.substring(0, rawCursor);
2140
+ const prefixBeforeCursor = safeInput.substring(0, safeRawCursor);
2115
2141
  const digitsBeforeCursor = prefixBeforeCursor.replace(/\D/g, "").length;
2116
2142
  const hadDecimalBeforeCursor = this.options.decimals > 0 && /[,.]/.test(prefixBeforeCursor);
2117
- const { isNegative, integerPart, decimalPart, hasDecimal } = this.parse(input);
2143
+ const { isNegative, integerPart, decimalPart, hasDecimal } = this.parse(safeInput);
2118
2144
  let effectiveDecimal = decimalPart;
2119
2145
  let effectiveHasDecimal = hasDecimal;
2120
2146
  if (padDecimals && this.options.decimals > 0 && (integerPart || decimalPart !== null)) {
@@ -2154,7 +2180,7 @@ var Wulf = (() => {
2154
2180
  isValid: true
2155
2181
  };
2156
2182
  }
2157
- const formattedInteger = (integerPart || "0").replace(/\B(?=(\d{3})+(?!\d))/g, this.options.thousandSeparator);
2183
+ const formattedInteger = this.formatThousands(integerPart || "0");
2158
2184
  let numberCore = formattedInteger;
2159
2185
  if (effectiveHasDecimal && this.options.decimals > 0) {
2160
2186
  numberCore += this.options.decimalSeparator + (effectiveDecimal ?? "");
@@ -2227,6 +2253,18 @@ var Wulf = (() => {
2227
2253
  const str = typeof value === "number" ? value.toString() : value;
2228
2254
  return engine.format(str).formatted;
2229
2255
  }
2256
+ formatThousands(digits) {
2257
+ const sep = this.options.thousandSeparator;
2258
+ if (!sep || digits.length <= 3) return digits;
2259
+ const parts = [];
2260
+ let i = digits.length;
2261
+ while (i > 0) {
2262
+ const start = Math.max(0, i - 3);
2263
+ parts.push(digits.slice(start, i));
2264
+ i = start;
2265
+ }
2266
+ return parts.reverse().join(sep);
2267
+ }
2230
2268
  escapeRegExp(string) {
2231
2269
  return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2232
2270
  }
@@ -2277,6 +2315,9 @@ var Wulf = (() => {
2277
2315
  if (!p.integerPart && !p.decimalPart) return "";
2278
2316
  return (p.isNegative ? "-" : "") + (p.integerPart || "0") + (p.decimalPart ? "." + p.decimalPart : "");
2279
2317
  }
2318
+ onPasswordModeDetected() {
2319
+ this.history.clear();
2320
+ }
2280
2321
  /**
2281
2322
  * Formate statiquement une valeur sans nécessiter d'élément DOM.
2282
2323
  */
@@ -2354,7 +2395,10 @@ var Wulf = (() => {
2354
2395
  const result = this.engine.format(val, cursor);
2355
2396
  this.setNativeValue(result.formatted);
2356
2397
  this.input.setSelectionRange(result.cursor, result.cursor);
2357
- if (!this.isUndoingRedoing && this.input.type !== "password") {
2398
+ if (this.input.type === "password") {
2399
+ this.options.copyRaw = false;
2400
+ this.history.clear();
2401
+ } else if (!this.isUndoingRedoing) {
2358
2402
  this.history.push(result.rawValue, result.cursor);
2359
2403
  }
2360
2404
  this.updateGhost(result);
@@ -2648,7 +2692,7 @@ var Wulf = (() => {
2648
2692
  * Retourne l'ensemble des domaines correspondant à la saisie courante.
2649
2693
  */
2650
2694
  getMatchingDomains(input) {
2651
- const val = input ?? "";
2695
+ const val = String(input ?? "").slice(0, 512);
2652
2696
  if (!val.includes("@")) {
2653
2697
  return this.defaultDomain ? [this.defaultDomain] : [];
2654
2698
  }
@@ -2670,7 +2714,7 @@ var Wulf = (() => {
2670
2714
  * @param matchIndex Index de la suggestion à sélectionner si plusieurs domaines/TLD correspondent (permet le cyclage)
2671
2715
  */
2672
2716
  getSuggestion(input, matchIndex = 0) {
2673
- const val = input ?? "";
2717
+ const val = String(input ?? "").slice(0, 512);
2674
2718
  if (!val.includes("@")) {
2675
2719
  if (this.defaultDomain) {
2676
2720
  return {
@@ -3190,35 +3234,49 @@ var Wulf = (() => {
3190
3234
  };
3191
3235
 
3192
3236
  // src/common/i18n.ts
3237
+ var FORBIDDEN_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
3238
+ function isSafeKey(key) {
3239
+ return Boolean(key) && !FORBIDDEN_KEYS.has(key);
3240
+ }
3193
3241
  function normalizeLocaleCode(locale) {
3194
- return locale.trim().toLowerCase().replace(/_/g, "-");
3242
+ const norm = String(locale ?? "").trim().toLowerCase().replace(/_/g, "-");
3243
+ return isSafeKey(norm) ? norm : "";
3195
3244
  }
3196
3245
  function getPrimaryLanguage(normalizedLocale) {
3197
3246
  const dashIndex = normalizedLocale.indexOf("-");
3198
- return dashIndex > 0 ? normalizedLocale.slice(0, dashIndex) : null;
3247
+ const primary = dashIndex > 0 ? normalizedLocale.slice(0, dashIndex) : null;
3248
+ return primary && isSafeKey(primary) ? primary : null;
3199
3249
  }
3200
3250
  function assignDefined(target, source) {
3201
- if (!source) return target;
3251
+ if (!source || typeof source !== "object") return target;
3202
3252
  for (const key of Object.keys(source)) {
3203
- if (source[key] !== void 0) {
3253
+ if (isSafeKey(String(key)) && Object.prototype.hasOwnProperty.call(source, key) && source[key] !== void 0) {
3204
3254
  target[key] = source[key];
3205
3255
  }
3206
3256
  }
3207
3257
  return target;
3208
3258
  }
3209
3259
  function createI18nManager(defaultLocale, locales) {
3210
- const fallbackLocale = normalizeLocaleCode(defaultLocale);
3211
- const initialLocales = {};
3260
+ const fallbackLocale = normalizeLocaleCode(defaultLocale) || "fr";
3261
+ const initialLocales = /* @__PURE__ */ Object.create(null);
3212
3262
  for (const [loc, dict] of Object.entries(locales)) {
3213
- initialLocales[normalizeLocaleCode(loc)] = { ...dict };
3263
+ const norm = normalizeLocaleCode(loc);
3264
+ if (norm) {
3265
+ initialLocales[norm] = assignDefined(/* @__PURE__ */ Object.create(null), dict);
3266
+ }
3214
3267
  }
3215
3268
  let currentLocale = fallbackLocale;
3216
- let activeLocales = { ...initialLocales };
3217
- let globalOverrides = {};
3269
+ let activeLocales = /* @__PURE__ */ Object.create(null);
3270
+ for (const [loc, dict] of Object.entries(initialLocales)) {
3271
+ activeLocales[loc] = assignDefined(/* @__PURE__ */ Object.create(null), dict);
3272
+ }
3273
+ let globalOverrides = /* @__PURE__ */ Object.create(null);
3218
3274
  function resolveActiveDictionaries() {
3219
3275
  const dicts = [];
3220
- const exact = activeLocales[currentLocale];
3221
- if (exact) dicts.push(exact);
3276
+ if (isSafeKey(currentLocale)) {
3277
+ const exact = activeLocales[currentLocale];
3278
+ if (exact) dicts.push(exact);
3279
+ }
3222
3280
  const primary = getPrimaryLanguage(currentLocale);
3223
3281
  if (primary && activeLocales[primary]) {
3224
3282
  dicts.push(activeLocales[primary]);
@@ -3227,24 +3285,33 @@ var Wulf = (() => {
3227
3285
  }
3228
3286
  return {
3229
3287
  setLocale(locale) {
3230
- if (locale && locale.trim()) {
3231
- currentLocale = normalizeLocaleCode(locale);
3288
+ if (locale && typeof locale === "string" && locale.trim()) {
3289
+ const norm = normalizeLocaleCode(locale);
3290
+ if (norm) {
3291
+ currentLocale = norm;
3292
+ }
3232
3293
  }
3233
3294
  },
3234
3295
  getLocale() {
3235
3296
  return currentLocale;
3236
3297
  },
3237
3298
  registerLocale(locale, translations) {
3238
- if (!locale || !locale.trim() || !translations) return;
3299
+ if (!locale || typeof locale !== "string" || !locale.trim() || !translations) return;
3239
3300
  const norm = normalizeLocaleCode(locale);
3240
- activeLocales[norm] = assignDefined({ ...activeLocales[norm] || {} }, translations);
3301
+ if (!norm) return;
3302
+ const base = assignDefined(/* @__PURE__ */ Object.create(null), activeLocales[norm]);
3303
+ activeLocales[norm] = assignDefined(base, translations);
3241
3304
  },
3242
3305
  setI18n(overrides) {
3243
- if (!overrides) return;
3244
- globalOverrides = assignDefined({ ...globalOverrides }, overrides);
3306
+ if (!overrides || typeof overrides !== "object") return;
3307
+ const base = assignDefined(/* @__PURE__ */ Object.create(null), globalOverrides);
3308
+ globalOverrides = assignDefined(base, overrides);
3245
3309
  },
3246
3310
  t(key, instanceOverride) {
3247
- if (instanceOverride && instanceOverride[key] !== void 0) {
3311
+ if (!isSafeKey(String(key))) {
3312
+ return "";
3313
+ }
3314
+ if (instanceOverride && typeof instanceOverride === "object" && Object.prototype.hasOwnProperty.call(instanceOverride, key) && instanceOverride[key] !== void 0) {
3248
3315
  return String(instanceOverride[key]);
3249
3316
  }
3250
3317
  if (globalOverrides[key] !== void 0) {
@@ -3275,10 +3342,10 @@ var Wulf = (() => {
3275
3342
  },
3276
3343
  reset() {
3277
3344
  currentLocale = fallbackLocale;
3278
- globalOverrides = {};
3279
- activeLocales = {};
3345
+ globalOverrides = /* @__PURE__ */ Object.create(null);
3346
+ activeLocales = /* @__PURE__ */ Object.create(null);
3280
3347
  for (const [loc, dict] of Object.entries(initialLocales)) {
3281
- activeLocales[loc] = { ...dict };
3348
+ activeLocales[loc] = assignDefined(/* @__PURE__ */ Object.create(null), dict);
3282
3349
  }
3283
3350
  }
3284
3351
  };
@@ -3322,21 +3389,36 @@ var Wulf = (() => {
3322
3389
  this.atTop = true;
3323
3390
  this.atRight = false;
3324
3391
  this.atLeft = true;
3325
- const resolvedElement = typeof element === "string" ? document.querySelector(element) : element;
3326
- if (!resolvedElement) {
3392
+ let resolvedElement = null;
3393
+ if (typeof element === "string") {
3394
+ try {
3395
+ resolvedElement = document.querySelector(element);
3396
+ } catch {
3397
+ resolvedElement = null;
3398
+ }
3399
+ } else {
3400
+ resolvedElement = element;
3401
+ }
3402
+ if (!resolvedElement || !(resolvedElement instanceof HTMLElement)) {
3327
3403
  throw new Error(`[ScrollBlock] \xC9l\xE9ment introuvable : "${element}".`);
3328
3404
  }
3329
3405
  this.root = resolvedElement;
3330
3406
  this.hasExplicitAriaLabel = Boolean(options?.ariaLabel || options?.i18n?.viewport);
3407
+ const rawDelay = options?.autoHideDelay;
3408
+ const safeAutoHideDelay = typeof rawDelay === "number" && Number.isFinite(rawDelay) && rawDelay >= 0 ? rawDelay : 1e3;
3409
+ const rawMinThumb = options?.minThumbSize;
3410
+ const safeMinThumbSize = typeof rawMinThumb === "number" && Number.isFinite(rawMinThumb) && rawMinThumb > 0 ? rawMinThumb : 24;
3411
+ const rawEdge = options?.edgeThreshold;
3412
+ const safeEdgeThreshold = typeof rawEdge === "number" && Number.isFinite(rawEdge) && rawEdge >= 0 ? rawEdge : 10;
3331
3413
  this.options = {
3332
3414
  axis: options?.axis || "y",
3333
3415
  autoHide: options?.autoHide ?? true,
3334
- autoHideDelay: options?.autoHideDelay ?? 1e3,
3416
+ autoHideDelay: safeAutoHideDelay,
3335
3417
  alwaysVisible: options?.alwaysVisible ?? false,
3336
3418
  ariaLabel: options?.ariaLabel || this.t("viewport"),
3337
3419
  i18n: options?.i18n || {},
3338
- minThumbSize: options?.minThumbSize ?? 24,
3339
- edgeThreshold: options?.edgeThreshold ?? 10,
3420
+ minThumbSize: safeMinThumbSize,
3421
+ edgeThreshold: safeEdgeThreshold,
3340
3422
  onScroll: options?.onScroll || (() => {
3341
3423
  }),
3342
3424
  onTotalScroll: options?.onTotalScroll || (() => {
@@ -3774,8 +3856,8 @@ var Wulf = (() => {
3774
3856
  targetLeft = target.left;
3775
3857
  }
3776
3858
  this.viewport.scrollTo({
3777
- top: targetTop !== void 0 ? Math.max(0, Math.min(maxTop, targetTop)) : void 0,
3778
- left: targetLeft !== void 0 ? Math.max(0, Math.min(maxLeft, targetLeft)) : void 0,
3859
+ top: targetTop !== void 0 && Number.isFinite(targetTop) ? Math.max(0, Math.min(maxTop, targetTop)) : void 0,
3860
+ left: targetLeft !== void 0 && Number.isFinite(targetLeft) ? Math.max(0, Math.min(maxLeft, targetLeft)) : void 0,
3779
3861
  behavior
3780
3862
  });
3781
3863
  }
@@ -3891,12 +3973,15 @@ var Wulf = (() => {
3891
3973
  */
3892
3974
  static parseGutter(gutterOption) {
3893
3975
  if (typeof gutterOption === "number") {
3894
- return { x: Math.max(0, gutterOption), y: Math.max(0, gutterOption) };
3976
+ const v = Number.isFinite(gutterOption) ? Math.max(0, gutterOption) : 0;
3977
+ return { x: v, y: v };
3895
3978
  }
3896
3979
  if (gutterOption && typeof gutterOption === "object") {
3980
+ const rawX = Number(gutterOption.x);
3981
+ const rawY = Number(gutterOption.y);
3897
3982
  return {
3898
- x: Math.max(0, Number(gutterOption.x) || 0),
3899
- y: Math.max(0, Number(gutterOption.y) || 0)
3983
+ x: Number.isFinite(rawX) ? Math.max(0, rawX) : 0,
3984
+ y: Number.isFinite(rawY) ? Math.max(0, rawY) : 0
3900
3985
  };
3901
3986
  }
3902
3987
  return { x: 0, y: 0 };
@@ -3905,22 +3990,37 @@ var Wulf = (() => {
3905
3990
  * Résout la largeur effective d'une colonne en pixels.
3906
3991
  */
3907
3992
  static resolveColumnWidth(container, firstItem, columnWidthOption) {
3908
- if (typeof columnWidthOption === "number" && columnWidthOption > 0) {
3993
+ if (typeof columnWidthOption === "number" && Number.isFinite(columnWidthOption) && columnWidthOption > 0) {
3909
3994
  return columnWidthOption;
3910
3995
  }
3911
3996
  if (typeof columnWidthOption === "string") {
3912
- const el = container.querySelector(columnWidthOption);
3913
- if (el) {
3914
- const w = el.getBoundingClientRect().width;
3915
- if (w > 0) return w;
3916
- }
3917
- const parsed = parseFloat(columnWidthOption);
3918
- if (!isNaN(parsed) && parsed > 0) {
3919
- if (columnWidthOption.endsWith("%")) {
3920
- const containerW2 = container.getBoundingClientRect().width;
3921
- return containerW2 * parsed / 100;
3997
+ const trimmed = columnWidthOption.trim();
3998
+ if (/^\d+(\.\d+)?(px|%)?$/i.test(trimmed)) {
3999
+ const parsed = parseFloat(trimmed);
4000
+ if (Number.isFinite(parsed) && parsed > 0) {
4001
+ if (trimmed.endsWith("%")) {
4002
+ const containerW2 = container.getBoundingClientRect().width;
4003
+ const resolvedPct = containerW2 * parsed / 100;
4004
+ if (resolvedPct > 0) return resolvedPct;
4005
+ } else {
4006
+ return parsed;
4007
+ }
4008
+ }
4009
+ } else if (trimmed) {
4010
+ let el = null;
4011
+ try {
4012
+ el = container.querySelector(trimmed);
4013
+ } catch {
4014
+ el = null;
4015
+ }
4016
+ if (el) {
4017
+ const w = el.getBoundingClientRect().width;
4018
+ if (Number.isFinite(w) && w > 0) return w;
4019
+ }
4020
+ const parsed = parseFloat(trimmed);
4021
+ if (Number.isFinite(parsed) && parsed > 0) {
4022
+ return parsed;
3922
4023
  }
3923
- return parsed;
3924
4024
  }
3925
4025
  }
3926
4026
  if (columnWidthOption instanceof HTMLElement) {
@@ -3974,8 +4074,13 @@ var Wulf = (() => {
3974
4074
  }
3975
4075
  const firstItem = items[0] || null;
3976
4076
  let colWidth = this.resolveColumnWidth(container, firstItem, options.columnWidth);
3977
- let cols = Math.floor((containerWidth + gutterX) / (colWidth + gutterX));
3978
- cols = Math.max(1, cols);
4077
+ const denom = colWidth + gutterX;
4078
+ let cols = denom > 0 ? Math.floor((containerWidth + gutterX) / denom) : 1;
4079
+ if (!Number.isFinite(cols) || cols < 1) {
4080
+ cols = 1;
4081
+ } else if (cols > 1e3) {
4082
+ cols = 1e3;
4083
+ }
3979
4084
  if (!options.columnWidth && cols > 1) {
3980
4085
  colWidth = (containerWidth - (cols - 1) * gutterX) / cols;
3981
4086
  }
@@ -4104,7 +4209,12 @@ var Wulf = (() => {
4104
4209
  this.removeTimers = /* @__PURE__ */ new Set();
4105
4210
  this.pendingImageListeners = [];
4106
4211
  if (typeof target === "string") {
4107
- const el = document.querySelector(target);
4212
+ let el = null;
4213
+ try {
4214
+ el = document.querySelector(target);
4215
+ } catch {
4216
+ el = null;
4217
+ }
4108
4218
  if (!el) {
4109
4219
  throw new Error(`[Wulf.Masonry] Conteneur introuvable pour le s\xE9lecteur : "${target}"`);
4110
4220
  }
@@ -4192,7 +4302,12 @@ var Wulf = (() => {
4192
4302
  */
4193
4303
  applyTransitionDuration() {
4194
4304
  const dur = this.options.transitionDuration;
4195
- const durValue = typeof dur === "number" ? `${dur}ms` : dur;
4305
+ let durValue = "300ms";
4306
+ if (typeof dur === "number" && Number.isFinite(dur) && dur >= 0) {
4307
+ durValue = `${dur}ms`;
4308
+ } else if (typeof dur === "string" && /^\s*\d+(\.\d+)?(ms|s)\s*$/i.test(dur)) {
4309
+ durValue = dur.trim();
4310
+ }
4196
4311
  this.root.style.setProperty("--wulf-masonry-duration", durValue);
4197
4312
  }
4198
4313
  /**
@@ -4538,6 +4653,13 @@ var Wulf = (() => {
4538
4653
 
4539
4654
  // src/toast/ToastInstance.ts
4540
4655
  var nextToastId = 1;
4656
+ function isSafeCssValue(val) {
4657
+ if (!val || typeof val !== "string" || val.length > 128) return false;
4658
+ return !/[;{}<>\\]|url\s*\(/i.test(val);
4659
+ }
4660
+ function sanitizeIconClasses(icon) {
4661
+ return icon.trim().split(/\s+/).filter((token) => /^[a-zA-Z0-9_-]+$/.test(token) && !token.startsWith("wulf-toast")).slice(0, 8).join(" ");
4662
+ }
4541
4663
  var ToastInstance = class extends AuditableComponent {
4542
4664
  constructor(options, onDismiss) {
4543
4665
  super();
@@ -4607,26 +4729,29 @@ var Wulf = (() => {
4607
4729
  el.setAttribute("role", role);
4608
4730
  el.setAttribute("aria-live", role === "alert" ? "assertive" : "polite");
4609
4731
  el.setAttribute("aria-atomic", "true");
4610
- if (this.options.backgroundColor) {
4611
- el.style.setProperty("--wulf-toast-bg", this.options.backgroundColor);
4732
+ if (this.options.backgroundColor && isSafeCssValue(this.options.backgroundColor)) {
4733
+ el.style.setProperty("--wulf-toast-bg", this.options.backgroundColor.trim());
4612
4734
  }
4613
- if (this.options.titleColor) {
4614
- el.style.setProperty("--wulf-toast-title-color", this.options.titleColor);
4735
+ if (this.options.titleColor && isSafeCssValue(this.options.titleColor)) {
4736
+ el.style.setProperty("--wulf-toast-title-color", this.options.titleColor.trim());
4615
4737
  }
4616
- if (this.options.textColor) {
4617
- el.style.setProperty("--wulf-toast-text-color", this.options.textColor);
4738
+ if (this.options.textColor && isSafeCssValue(this.options.textColor)) {
4739
+ el.style.setProperty("--wulf-toast-text-color", this.options.textColor.trim());
4618
4740
  }
4619
- if (this.options.iconColor) {
4620
- el.style.setProperty("--wulf-toast-icon-color", this.options.iconColor);
4741
+ if (this.options.iconColor && isSafeCssValue(this.options.iconColor)) {
4742
+ el.style.setProperty("--wulf-toast-icon-color", this.options.iconColor.trim());
4621
4743
  }
4622
- if (this.options.closeButtonColor) {
4623
- el.style.setProperty("--wulf-toast-close-color", this.options.closeButtonColor);
4744
+ if (this.options.closeButtonColor && isSafeCssValue(this.options.closeButtonColor)) {
4745
+ el.style.setProperty("--wulf-toast-close-color", this.options.closeButtonColor.trim());
4624
4746
  }
4625
- if (this.options.icon && this.options.icon.trim() !== "") {
4626
- const iconContainer = document.createElement("span");
4627
- iconContainer.className = `wulf-toast-icon ${this.options.icon.trim()}`;
4628
- iconContainer.setAttribute("aria-hidden", "true");
4629
- el.appendChild(iconContainer);
4747
+ if (this.options.icon && typeof this.options.icon === "string" && this.options.icon.trim() !== "") {
4748
+ const safeIcon = sanitizeIconClasses(this.options.icon);
4749
+ if (safeIcon) {
4750
+ const iconContainer = document.createElement("span");
4751
+ iconContainer.className = `wulf-toast-icon ${safeIcon}`;
4752
+ iconContainer.setAttribute("aria-hidden", "true");
4753
+ el.appendChild(iconContainer);
4754
+ }
4630
4755
  }
4631
4756
  const content = document.createElement("div");
4632
4757
  content.className = "wulf-toast-content";
@@ -4661,14 +4786,22 @@ var Wulf = (() => {
4661
4786
  });
4662
4787
  el.appendChild(closeBtn);
4663
4788
  }
4789
+ if (this.options.progressBar && this.remainingTime > 0) {
4790
+ el.style.setProperty("--wulf-toast-duration", `${this.remainingTime}ms`);
4791
+ const progressBar = document.createElement("div");
4792
+ progressBar.className = "wulf-toast-progress";
4793
+ progressBar.setAttribute("aria-hidden", "true");
4794
+ el.appendChild(progressBar);
4795
+ }
4664
4796
  return el;
4665
4797
  }
4666
4798
  /**
4667
4799
  * Injection de texte sécurisée gérant nativement les retours à la ligne (\n et \r\n).
4668
- * Utilise document.createTextNode et des éléments <br> créés proprement.
4800
+ * Utilise document.createTextNode et des éléments <br> créés proprement (plafonné contre le DoS DOM).
4669
4801
  */
4670
4802
  appendTextWithLineBreaks(container, text) {
4671
- const lines = text.split(/\r\n|\r|\n/);
4803
+ const safeText = String(text ?? "").slice(0, 4096);
4804
+ const lines = safeText.split(/\r\n|\r|\n/).slice(0, 100);
4672
4805
  lines.forEach((line, index) => {
4673
4806
  if (index > 0) {
4674
4807
  container.appendChild(document.createElement("br"));
@@ -4715,6 +4848,7 @@ var Wulf = (() => {
4715
4848
  const elapsed = Date.now() - this.timerStartTime;
4716
4849
  this.remainingTime = Math.max(0, this.remainingTime - elapsed);
4717
4850
  this.isPaused = true;
4851
+ this.element.classList.add("is-paused");
4718
4852
  }
4719
4853
  /**
4720
4854
  * Reprend le compte à rebours
@@ -4722,6 +4856,7 @@ var Wulf = (() => {
4722
4856
  resumeTimer() {
4723
4857
  if (this._isClosed || this.remainingTime <= 0 || !this.isPaused) return;
4724
4858
  this.isPaused = false;
4859
+ this.element.classList.remove("is-paused");
4725
4860
  this.startTimer();
4726
4861
  }
4727
4862
  /**
@@ -4798,6 +4933,17 @@ var Wulf = (() => {
4798
4933
  };
4799
4934
 
4800
4935
  // src/toast/ToastManager.ts
4936
+ var VALID_POSITIONS = /* @__PURE__ */ new Set([
4937
+ "top-left",
4938
+ "top-center",
4939
+ "top-right",
4940
+ "bottom-left",
4941
+ "bottom-center",
4942
+ "bottom-right"
4943
+ ]);
4944
+ function normalizePosition(pos) {
4945
+ return pos && VALID_POSITIONS.has(pos) ? pos : "top-right";
4946
+ }
4801
4947
  var _ToastManager = class _ToastManager {
4802
4948
  constructor() {
4803
4949
  this.containers = /* @__PURE__ */ new Map();
@@ -4815,7 +4961,7 @@ var Wulf = (() => {
4815
4961
  * Ajoute et affiche une notification Toast.
4816
4962
  */
4817
4963
  add(toast) {
4818
- const position = toast.options.position || "top-right";
4964
+ const position = normalizePosition(toast.options.position);
4819
4965
  let list = this.activeToasts.get(position);
4820
4966
  if (!list) {
4821
4967
  list = [];
@@ -4832,11 +4978,12 @@ var Wulf = (() => {
4832
4978
  if (this.replaceTokens.get(position) !== token) {
4833
4979
  return;
4834
4980
  }
4835
- this.mountToast(toast, position);
4981
+ this.mountToast(toast, position, 5);
4836
4982
  });
4837
4983
  return;
4838
4984
  }
4839
- const maxToasts = typeof toast.options.maxToasts === "number" && toast.options.maxToasts > 0 ? toast.options.maxToasts : 5;
4985
+ const rawMax = toast.options.maxToasts;
4986
+ const maxToasts = typeof rawMax === "number" && Number.isFinite(rawMax) && rawMax > 0 ? Math.min(50, Math.max(1, Math.floor(rawMax))) : 5;
4840
4987
  if (list.length >= maxToasts) {
4841
4988
  const countToRemove = list.length - maxToasts + 1;
4842
4989
  const oldestItems = list.splice(0, countToRemove);
@@ -4844,18 +4991,28 @@ var Wulf = (() => {
4844
4991
  item.close("max-limit", true);
4845
4992
  }
4846
4993
  }
4847
- this.mountToast(toast, position);
4994
+ this.mountToast(toast, position, maxToasts);
4848
4995
  }
4849
4996
  /**
4850
4997
  * Insère l'élément toast dans le DOM et déclenche les callbacks et compteurs.
4851
4998
  */
4852
- mountToast(toast, position) {
4999
+ mountToast(toast, position, maxToasts = 5) {
4853
5000
  const container = this.getOrCreateContainer(position);
4854
5001
  let list = this.activeToasts.get(position);
4855
5002
  if (!list) {
4856
5003
  list = [];
4857
5004
  this.activeToasts.set(position, list);
4858
5005
  }
5006
+ const maxDomNodes = maxToasts + 10;
5007
+ if (container.children.length >= maxDomNodes) {
5008
+ const children = Array.from(container.children);
5009
+ for (const child of children) {
5010
+ if (container.children.length < maxDomNodes) break;
5011
+ if (child.classList.contains("wulf-toast-hiding") || child.classList.contains("wulf-toast-hiding-fast")) {
5012
+ child.remove();
5013
+ }
5014
+ }
5015
+ }
4859
5016
  container.appendChild(toast.element);
4860
5017
  list.push(toast);
4861
5018
  if (toast.options.onOpen) {
@@ -4871,7 +5028,7 @@ var Wulf = (() => {
4871
5028
  * Retire une notification de la pile et nettoie le conteneur s'il est vide.
4872
5029
  */
4873
5030
  remove(toast, _reason) {
4874
- const position = toast.options.position || "top-right";
5031
+ const position = normalizePosition(toast.options.position);
4875
5032
  const list = this.activeToasts.get(position);
4876
5033
  if (list) {
4877
5034
  const index = list.indexOf(toast);
@@ -5013,12 +5170,29 @@ var Wulf = (() => {
5013
5170
  "select:not([disabled])",
5014
5171
  "textarea:not([disabled])",
5015
5172
  "button:not([disabled])",
5173
+ "audio[controls]",
5174
+ "video[controls]",
5175
+ "details > summary:first-of-type",
5016
5176
  "iframe",
5017
5177
  "object",
5018
5178
  "embed",
5019
- '[contenteditable="true"]',
5179
+ '[contenteditable]:not([contenteditable="false"])',
5020
5180
  '[tabindex]:not([tabindex="-1"])'
5021
5181
  ].join(",");
5182
+ function safeCssEscape(value) {
5183
+ if (typeof CSS !== "undefined" && typeof CSS.escape === "function") {
5184
+ return CSS.escape(value);
5185
+ }
5186
+ return String(value).replace(/["\\]/g, "\\$&");
5187
+ }
5188
+ function safeQuerySelector(root, selector) {
5189
+ if (!selector || typeof selector !== "string") return null;
5190
+ try {
5191
+ return root.querySelector(selector);
5192
+ } catch {
5193
+ return null;
5194
+ }
5195
+ }
5022
5196
  var trapStack = [];
5023
5197
  var FocusTrap = class extends AuditableComponent {
5024
5198
  constructor(target, options = {}) {
@@ -5030,7 +5204,7 @@ var Wulf = (() => {
5030
5204
  // Sentinelles anti-fuite de focus
5031
5205
  this.startSentinel = null;
5032
5206
  this.endSentinel = null;
5033
- const el = typeof target === "string" ? document.querySelector(target) : target;
5207
+ const el = typeof target === "string" ? safeQuerySelector(document, target) : target;
5034
5208
  if (!el || !(el instanceof HTMLElement)) {
5035
5209
  throw new Error(`[Wulf.FocusTrap] Conteneur introuvable ou invalide : "${target}"`);
5036
5210
  }
@@ -5070,7 +5244,7 @@ var Wulf = (() => {
5070
5244
  }
5071
5245
  if (el instanceof HTMLInputElement && el.type === "radio" && el.name) {
5072
5246
  const group = Array.from(
5073
- this.element.querySelectorAll(`input[type="radio"][name="${CSS.escape(el.name)}"]`)
5247
+ this.element.querySelectorAll(`input[type="radio"][name="${safeCssEscape(el.name)}"]`)
5074
5248
  );
5075
5249
  const checked = group.find((r) => r.checked);
5076
5250
  if (checked) {
@@ -5107,6 +5281,7 @@ var Wulf = (() => {
5107
5281
  document.addEventListener("keydown", this.handleKeyDownBound, true);
5108
5282
  document.addEventListener("focusin", this.handleFocusInBound, true);
5109
5283
  if (!this.options.allowOutsideClick) {
5284
+ document.addEventListener("pointerdown", this.handleClickOutsideBound, true);
5110
5285
  document.addEventListener("mousedown", this.handleClickOutsideBound, true);
5111
5286
  document.addEventListener("touchstart", this.handleClickOutsideBound, true);
5112
5287
  }
@@ -5132,6 +5307,7 @@ var Wulf = (() => {
5132
5307
  }
5133
5308
  document.removeEventListener("keydown", this.handleKeyDownBound, true);
5134
5309
  document.removeEventListener("focusin", this.handleFocusInBound, true);
5310
+ document.removeEventListener("pointerdown", this.handleClickOutsideBound, true);
5135
5311
  document.removeEventListener("mousedown", this.handleClickOutsideBound, true);
5136
5312
  document.removeEventListener("touchstart", this.handleClickOutsideBound, true);
5137
5313
  this.removeSentinels();
@@ -5201,8 +5377,34 @@ var Wulf = (() => {
5201
5377
  this.deactivate();
5202
5378
  }
5203
5379
  // --- Implémentation interne ---
5380
+ isEventInside(e, target) {
5381
+ if (target && this.element.contains(target)) {
5382
+ return true;
5383
+ }
5384
+ if (typeof e.composedPath === "function") {
5385
+ const path = e.composedPath();
5386
+ if (path.includes(this.element)) {
5387
+ return true;
5388
+ }
5389
+ }
5390
+ return false;
5391
+ }
5392
+ applySentinelStyles(el) {
5393
+ const s = el.style;
5394
+ s.position = "fixed";
5395
+ s.top = "0";
5396
+ s.left = "0";
5397
+ s.opacity = "0";
5398
+ s.pointerEvents = "none";
5399
+ s.width = "0";
5400
+ s.height = "0";
5401
+ }
5204
5402
  handleKeyDown(e) {
5205
5403
  if (!this.isActive()) return;
5404
+ if (this.element.isConnected === false) {
5405
+ this.deactivate();
5406
+ return;
5407
+ }
5206
5408
  if (e.key === "Escape" && this.options.escapeDeactivates) {
5207
5409
  e.preventDefault();
5208
5410
  e.stopPropagation();
@@ -5232,6 +5434,10 @@ var Wulf = (() => {
5232
5434
  }
5233
5435
  handleFocusIn(e) {
5234
5436
  if (!this.isActive()) return;
5437
+ if (this.element.isConnected === false) {
5438
+ this.deactivate();
5439
+ return;
5440
+ }
5235
5441
  const target = e.target;
5236
5442
  if (!target) return;
5237
5443
  if (target === this.startSentinel) {
@@ -5252,7 +5458,7 @@ var Wulf = (() => {
5252
5458
  }
5253
5459
  return;
5254
5460
  }
5255
- if (!this.element.contains(target)) {
5461
+ if (!this.isEventInside(e, target)) {
5256
5462
  const focusables = this.getFocusableElements();
5257
5463
  if (focusables.length > 0) {
5258
5464
  focusables[0].focus();
@@ -5266,8 +5472,12 @@ var Wulf = (() => {
5266
5472
  }
5267
5473
  handleClickOutside(e) {
5268
5474
  if (!this.isActive()) return;
5475
+ if (this.element.isConnected === false) {
5476
+ this.deactivate();
5477
+ return;
5478
+ }
5269
5479
  const target = e.target;
5270
- if (target && !this.element.contains(target)) {
5480
+ if (target && !this.isEventInside(e, target)) {
5271
5481
  e.preventDefault();
5272
5482
  e.stopPropagation();
5273
5483
  }
@@ -5278,14 +5488,14 @@ var Wulf = (() => {
5278
5488
  this.startSentinel.setAttribute("tabindex", "0");
5279
5489
  this.startSentinel.setAttribute("aria-hidden", "true");
5280
5490
  this.startSentinel.className = "wulf-sentinel-start";
5281
- this.startSentinel.style.cssText = "position:fixed;top:0;left:0;opacity:0;pointer-events:none;width:0;height:0;";
5491
+ this.applySentinelStyles(this.startSentinel);
5282
5492
  }
5283
5493
  if (!this.endSentinel) {
5284
5494
  this.endSentinel = document.createElement("span");
5285
5495
  this.endSentinel.setAttribute("tabindex", "0");
5286
5496
  this.endSentinel.setAttribute("aria-hidden", "true");
5287
5497
  this.endSentinel.className = "wulf-sentinel-end";
5288
- this.endSentinel.style.cssText = "position:fixed;top:0;left:0;opacity:0;pointer-events:none;width:0;height:0;";
5498
+ this.applySentinelStyles(this.endSentinel);
5289
5499
  }
5290
5500
  if (this.element.parentNode) {
5291
5501
  this.element.parentNode.insertBefore(this.startSentinel, this.element);
@@ -5323,7 +5533,7 @@ var Wulf = (() => {
5323
5533
  if (this.options.initialFocus === false) return;
5324
5534
  let targetEl = null;
5325
5535
  if (typeof this.options.initialFocus === "string") {
5326
- targetEl = this.element.querySelector(this.options.initialFocus);
5536
+ targetEl = safeQuerySelector(this.element, this.options.initialFocus);
5327
5537
  } else if (this.options.initialFocus instanceof HTMLElement) {
5328
5538
  targetEl = this.options.initialFocus;
5329
5539
  }
@@ -5347,7 +5557,7 @@ var Wulf = (() => {
5347
5557
  return;
5348
5558
  }
5349
5559
  if (this.options.fallbackReturnFocus) {
5350
- const fallback = typeof this.options.fallbackReturnFocus === "string" ? document.querySelector(this.options.fallbackReturnFocus) : this.options.fallbackReturnFocus;
5560
+ const fallback = typeof this.options.fallbackReturnFocus === "string" ? safeQuerySelector(document, this.options.fallbackReturnFocus) : this.options.fallbackReturnFocus;
5351
5561
  if (fallback && fallback.isConnected) {
5352
5562
  fallback.focus();
5353
5563
  }
@@ -5430,11 +5640,14 @@ var Wulf = (() => {
5430
5640
  * et retourne la liste des étapes normalisées nécessaires au déclenchement.
5431
5641
  */
5432
5642
  static parseCombo(combo, isApple = _ShortcutFormatter.isApple()) {
5433
- const trimmed = combo.trim();
5643
+ if (typeof combo !== "string") {
5644
+ return [];
5645
+ }
5646
+ const trimmed = combo.slice(0, 512).trim();
5434
5647
  if (!trimmed) {
5435
5648
  return [];
5436
5649
  }
5437
- const stepsRaw = trimmed.split(/\s+/);
5650
+ const stepsRaw = trimmed.split(/\s+/).slice(0, 10);
5438
5651
  const steps = [];
5439
5652
  for (const rawStep of stepsRaw) {
5440
5653
  const tokens = [];
@@ -5604,15 +5817,33 @@ var Wulf = (() => {
5604
5817
  if (tagName === "TEXTAREA" || tagName === "SELECT") {
5605
5818
  return true;
5606
5819
  }
5607
- if (el.isContentEditable || el.getAttribute("contenteditable") === "true" || el.getAttribute("contenteditable") === "plaintext-only") {
5820
+ if (el.isContentEditable || el.getAttribute("contenteditable") === "true" || el.getAttribute("contenteditable") === "plaintext-only" || el.getAttribute("contenteditable") === "") {
5608
5821
  return true;
5609
5822
  }
5610
5823
  const role = el.getAttribute("role");
5611
5824
  if (role === "textbox" || role === "searchbox") {
5612
5825
  return true;
5613
5826
  }
5827
+ if (typeof el.closest === "function") {
5828
+ const editableAncestor = el.closest(
5829
+ '[contenteditable="true"], [contenteditable="plaintext-only"], [contenteditable=""], [role="textbox"], [role="searchbox"]'
5830
+ );
5831
+ if (editableAncestor) {
5832
+ return true;
5833
+ }
5834
+ }
5614
5835
  return false;
5615
5836
  }
5837
+ /**
5838
+ * Vérifie si la cible est un champ de mot de passe (sanctuaire anti-keylogging).
5839
+ */
5840
+ static isPasswordField(target) {
5841
+ if (!target || typeof target.tagName !== "string") {
5842
+ return false;
5843
+ }
5844
+ const el = target;
5845
+ return el.tagName.toUpperCase() === "INPUT" && (el.type || "").toLowerCase() === "password";
5846
+ }
5616
5847
  /**
5617
5848
  * Enregistre un ou plusieurs raccourcis clavier.
5618
5849
  * Retourne une fonction de nettoyage pour désenregistrer immédiatement.
@@ -5669,6 +5900,9 @@ var Wulf = (() => {
5669
5900
  */
5670
5901
  pushScope(scope) {
5671
5902
  if (scope && typeof scope === "string") {
5903
+ if (this.scopeStack.length >= 64) {
5904
+ return;
5905
+ }
5672
5906
  this.scopeStack.push(scope);
5673
5907
  this.clearSequenceBuffer();
5674
5908
  }
@@ -5797,7 +6031,10 @@ var Wulf = (() => {
5797
6031
  return;
5798
6032
  }
5799
6033
  const currentScope = this.getScope();
5800
- const isEditable = _ShortcutManager.isEditable(event.target);
6034
+ const composed = typeof event.composedPath === "function" ? event.composedPath() : [];
6035
+ const actualTarget = composed.length > 0 ? composed[0] : event.target;
6036
+ const isEditable = _ShortcutManager.isEditable(actualTarget) || _ShortcutManager.isEditable(event.target);
6037
+ const isPasswordInput = _ShortcutManager.isPasswordField(actualTarget) || _ShortcutManager.isPasswordField(event.target);
5801
6038
  const currentStep = {
5802
6039
  ctrl: event.ctrlKey,
5803
6040
  alt: event.altKey,
@@ -5812,7 +6049,7 @@ var Wulf = (() => {
5812
6049
  this.clearSequenceBuffer();
5813
6050
  }
5814
6051
  }
5815
- const activeCandidates = this.getActiveShortcuts(currentScope, isEditable);
6052
+ const activeCandidates = this.getActiveShortcuts(currentScope, isEditable, isPasswordInput);
5816
6053
  const proposedSequence = [...this.sequenceBuffer.map((b) => b.step), currentStep];
5817
6054
  const matchingSequence = this.findMatchingSequence(activeCandidates, proposedSequence);
5818
6055
  if (matchingSequence) {
@@ -5834,7 +6071,7 @@ var Wulf = (() => {
5834
6071
  this.executeShortcut(matchingChord, event, currentScope, false);
5835
6072
  }
5836
6073
  }
5837
- getActiveShortcuts(currentScope, isEditable) {
6074
+ getActiveShortcuts(currentScope, isEditable, isPasswordInput = false) {
5838
6075
  const list = [];
5839
6076
  for (const shortcut of this.shortcuts.values()) {
5840
6077
  if (shortcut.scope !== currentScope && shortcut.scope !== "*") {
@@ -5843,6 +6080,15 @@ var Wulf = (() => {
5843
6080
  if (isEditable && !shortcut.allowInEditable) {
5844
6081
  continue;
5845
6082
  }
6083
+ if (isPasswordInput) {
6084
+ if (shortcut.isSequence) {
6085
+ continue;
6086
+ }
6087
+ const firstStep = shortcut.normalizedSteps[0];
6088
+ if (firstStep && firstStep.key.length === 1 && !firstStep.ctrl && !firstStep.alt && !firstStep.meta) {
6089
+ continue;
6090
+ }
6091
+ }
5846
6092
  list.push(shortcut);
5847
6093
  }
5848
6094
  return list.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
@@ -5951,7 +6197,18 @@ var Wulf = (() => {
5951
6197
  }
5952
6198
  }
5953
6199
  };
6200
+
6201
+ // src/shortcut/index.ts
6202
+ if (typeof window !== "undefined") {
6203
+ const win = window;
6204
+ const wulfNamespace = win.Wulf || {};
6205
+ win.Wulf = wulfNamespace;
6206
+ wulfNamespace.Shortcut = Object.assign(ShortcutManager, {
6207
+ ShortcutManager,
6208
+ ShortcutFormatter
6209
+ });
6210
+ }
5954
6211
  return __toCommonJS(index_exports);
5955
6212
  })();
5956
- if (typeof window !== "undefined") { window.Wulf = window.Wulf || {}; if (typeof Wulf !== "undefined" && Wulf) { var targets = ["Mask", "Scroll", "Masonry", "Toast", "FocusTrap", "Shortcut"]; for (var i = 0; i < targets.length; i++) { var t = targets[i]; if (Wulf[t] && window.Wulf[t] !== Wulf[t]) { try { Object.defineProperty(window.Wulf, t, { value: Wulf[t], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[t] = Wulf[t]; } catch (__) {} } } } for (var k in Wulf) { if (window.Wulf[k] === undefined) { try { Object.defineProperty(window.Wulf, k, { value: Wulf[k], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[k] = Wulf[k]; } catch (__) {} } } } } }
6213
+ if (typeof window !== "undefined") { window.Wulf = window.Wulf || {}; if (typeof __WulfIIFE !== "undefined" && __WulfIIFE) { for (var k in __WulfIIFE) { if (Object.prototype.hasOwnProperty.call(__WulfIIFE, k) && k !== "__proto__" && k !== "constructor" && k !== "prototype" && window.Wulf[k] === undefined) { try { Object.defineProperty(window.Wulf, k, { value: __WulfIIFE[k], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[k] = __WulfIIFE[k]; } catch (__) {} } } } } }
5957
6214
  //# sourceMappingURL=index.global.js.map