@tsparticles/stencil 4.2.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { R as RangeType, c as checkDistance, s as squareExp, a as isNull, b as setRangeValue, h as hMin, d as hMax, l as lMin, e as lMax, f as sMin, g as sMax, j as isString, k as isArray, m as deepExtend, P as PixelMode, O as OutMode, M as MoveDirection, n as isNumber, o as isObject, L as LimitMode, p as executeOnSingleOrMultiple, q as isBoolean, r as itemFromArray, u as defaultOpacity, v as randomColorValue, A as AlterType, w as lFactor, x as half, y as double, z as hPhase, B as rgbMax, C as getRandomInRange, D as identity, E as defaultRgbMin, F as maxNits, G as sextuple, H as triple, I as phaseNumerator, J as sNormalizedOffset, K as originPoint, N as minimumSize, Q as defaultCompositeValue, S as minStrokeWidth, T as defaultZoom, U as zIndexFactorOffset, V as defaultTransformValue, W as safeMutationObserver, X as generatedAttribute, Y as cloneStyle, Z as safeMatchMedia, _ as getFullScreenStyle, $ as safeDocument, a0 as millisecondsToSeconds, a1 as manageListener, a2 as visibilityChangeEvent, a3 as resizeEvent, a4 as Vector3d, a5 as EventType, a6 as defaultAngle, a7 as defaultTransform, a8 as defaultRetryCount, a9 as tryCountIncrement, aa as getParticleBaseVelocity, ab as randomInRangeValue, ac as getRandom, ad as OutModeDirection, ae as clamp, af as minZ, ag as getPosition, ah as getParticleDirectionAngle, ai as ParticleOutType, aj as Vector, ak as getRangeValue, al as calcExactPositionOrRandomFromSize, am as itemFromSingleOrMultiple, an as isInArray, ao as doublePI, ap as degToRad, aq as spatialHashGridCellSize, ar as minLimit, as as minCount, at as getLogger, au as minIndex, av as defaultRemoveQuantity, aw as defaultDensityFactor, ax as deleteCount, ay as countOffset, az as one, aA as defaultRatio, aB as defaultReduceFactor, aC as animate, aD as defaultFpsLimit, aE as minFpsLimit, aF as cancelAnimation, aG as defaultFps } from './index-aPxdqzSw.js';
1
+ import { R as RangeType, c as checkDistance, s as squareExp, a as isNull, b as setRangeValue, h as hMin, d as hMax, l as lMin, e as lMax, f as sMin, g as sMax, j as isString, k as isArray, m as deepExtend, P as PixelMode, O as OutMode, M as MoveDirection, n as isNumber, o as isObject, L as LimitMode, p as executeOnSingleOrMultiple, q as isBoolean, r as itemFromArray, u as defaultOpacity, v as randomColorValue, A as AlterType, w as lFactor, x as half, y as double, z as hPhase, B as rgbMax, C as getRandomInRange, D as identity, E as defaultRgbMin, F as maxNits, G as sextuple, H as triple, I as phaseNumerator, J as sNormalizedOffset, K as originPoint, N as DrawLayer, Q as minimumSize, S as defaultCompositeValue, T as minStrokeWidth, U as defaultZoom, V as getLogger, W as zIndexFactorOffset, X as defaultTransformValue, Y as safeMutationObserver, Z as generatedAttribute, _ as cloneStyle, $ as safeMatchMedia, a0 as getFullScreenStyle, a1 as safeDocument, a2 as millisecondsToSeconds, a3 as manageListener, a4 as visibilityChangeEvent, a5 as resizeEvent, a6 as Vector3d, a7 as EventType, a8 as defaultAngle, a9 as defaultTransform, aa as defaultRetryCount, ab as tryCountIncrement, ac as getParticleBaseVelocity, ad as randomInRangeValue, ae as getRandom, af as OutModeDirection, ag as clamp, ah as minZ, ai as getPosition, aj as getParticleDirectionAngle, ak as ParticleOutType, al as Vector, am as calcExactPositionOrRandomFromSize, an as getRangeValue, ao as itemFromSingleOrMultiple, ap as isInArray, aq as doublePI, ar as degToRad, as as spatialHashGridCellSize, at as minLimit, au as minCount, av as minIndex, aw as defaultRemoveQuantity, ax as defaultDensityFactor, ay as deleteCount, az as countOffset, aA as one, aB as defaultRatio, aC as defaultReduceFactor, aD as animate, aE as defaultFpsLimit, aF as minFpsLimit, aG as cancelAnimation, aH as defaultFps } from './index-D4tjp3z_.js';
2
2
 
3
3
  class BaseRange {
4
4
  position;
@@ -204,6 +204,8 @@ class AnimatableColor extends OptionsColor {
204
204
 
205
205
  class Background extends OptionLoader {
206
206
  color;
207
+ draw;
208
+ element;
207
209
  image = "";
208
210
  opacity = 1;
209
211
  position = "";
@@ -218,6 +220,8 @@ class Background extends OptionLoader {
218
220
  if (data.color !== undefined) {
219
221
  this.color = OptionsColor.create(this.color, data.color);
220
222
  }
223
+ loadProperty(this, "element", data.element);
224
+ loadProperty(this, "draw", data.draw);
221
225
  loadProperty(this, "image", data.image);
222
226
  loadProperty(this, "position", data.position);
223
227
  loadProperty(this, "repeat", data.repeat);
@@ -753,7 +757,7 @@ class Options extends OptionLoader {
753
757
  }
754
758
  }
755
759
 
756
- const styleCache = new Map(), maxStyleCacheSize = 2000, rgbFixedPrecision = 2, hslFixedPrecision = 2, sdrReferenceWhiteNits = 203;
760
+ const styleCache = new Map(), maxStyleCacheSize = 2000, rgbFixedPrecision = 2, hslFixedPrecision = 2, hdrRgbFixedPrecision = 4, hdrHslFixedPrecision = 4, sdrReferenceWhiteNits = 203;
757
761
  function getCachedStyle(key, generator) {
758
762
  let cached = styleCache.get(key);
759
763
  if (!cached) {
@@ -882,19 +886,20 @@ function hslChannel(temp1, temp2, temp3) {
882
886
  }
883
887
  return temp1;
884
888
  }
885
- function hslToRgb(hsl) {
889
+ function hslToRgbFloat(hsl) {
886
890
  const h = ((hsl.h % hMax) + hMax) % hMax, s = Math.max(sMin, Math.min(sMax, hsl.s)), l = Math.max(lMin, Math.min(lMax, hsl.l)), hNormalized = h / hMax, sNormalized = s / sMax, lNormalized = l / lMax;
887
891
  if (s === sMin) {
888
- const grayscaleValue = Math.round(lNormalized * rgbMax);
892
+ const grayscaleValue = lNormalized * rgbMax;
889
893
  return { r: grayscaleValue, g: grayscaleValue, b: grayscaleValue };
890
894
  }
891
895
  const temp1 = lNormalized < half
892
896
  ? lNormalized * (sNormalizedOffset + sNormalized)
893
897
  : lNormalized + sNormalized - lNormalized * sNormalized, temp2 = double * lNormalized - temp1, phaseThird = phaseNumerator / triple, red = Math.min(rgbMax, rgbMax * hslChannel(temp2, temp1, hNormalized + phaseThird)), green = Math.min(rgbMax, rgbMax * hslChannel(temp2, temp1, hNormalized)), blue = Math.min(rgbMax, rgbMax * hslChannel(temp2, temp1, hNormalized - phaseThird));
894
- return { r: Math.round(red), g: Math.round(green), b: Math.round(blue) };
898
+ return { r: red, g: green, b: blue };
895
899
  }
896
- function getRandomRgbColor(min) {
897
- const fixedMin = defaultRgbMin, fixedMax = rgbMax + identity, getRgbInRangeValue = () => Math.floor(getRandomInRange(fixedMin, fixedMax));
900
+ function getRandomRgbColor(min, hdr) {
901
+ const fixedMin = defaultRgbMin;
902
+ const fixedMax = rgbMax + identity, getRgbInRangeValue = () => Math.floor(getRandomInRange(fixedMin, fixedMax));
898
903
  return {
899
904
  b: getRgbInRangeValue(),
900
905
  g: getRgbInRangeValue(),
@@ -902,7 +907,7 @@ function getRandomRgbColor(min) {
902
907
  };
903
908
  }
904
909
  function getStyleFromRgb(color, hdr, opacity) {
905
- const op = opacity ?? defaultOpacity, key = `rgb-${color.r.toFixed(rgbFixedPrecision)}-${color.g.toFixed(rgbFixedPrecision)}-${color.b.toFixed(rgbFixedPrecision)}-${hdr ? "hdr" : "sdr"}-${op.toString()}`;
910
+ const rgbPrecision = hdr ? hdrRgbFixedPrecision : rgbFixedPrecision, op = opacity ?? defaultOpacity, key = `rgb-${color.r.toFixed(rgbPrecision)}-${color.g.toFixed(rgbPrecision)}-${color.b.toFixed(rgbPrecision)}-${hdr ? "hdr" : "sdr"}-${op.toString()}`;
906
911
  return getCachedStyle(key, () => (hdr ? getHdrStyleFromRgb(color, opacity) : getSdrStyleFromRgb(color, opacity)));
907
912
  }
908
913
  function getHdrStyleFromRgb(color, opacity, peakNits = maxNits) {
@@ -913,9 +918,9 @@ function getSdrStyleFromRgb(color, opacity) {
913
918
  return `rgba(${color.r.toString()}, ${color.g.toString()}, ${color.b.toString()}, ${(opacity ?? defaultOpacity).toString()})`;
914
919
  }
915
920
  function getStyleFromHsl(color, hdr, opacity) {
916
- const op = opacity ?? defaultOpacity, key = `hsl-${color.h.toFixed(hslFixedPrecision)}-${color.s.toFixed(hslFixedPrecision)}-${color.l.toFixed(hslFixedPrecision)}-${hdr ? "hdr" : "sdr"}-${op.toString()}`;
921
+ const hslPrecision = hdr ? hdrHslFixedPrecision : hslFixedPrecision, op = opacity ?? defaultOpacity, key = `hsl-${color.h.toFixed(hslPrecision)}-${color.s.toFixed(hslPrecision)}-${color.l.toFixed(hslPrecision)}-${hdr ? "hdr" : "sdr"}-${op.toString()}`;
917
922
  return getCachedStyle(key, () => hdr
918
- ? getStyleFromRgb(hslToRgb(color), true, opacity)
923
+ ? getStyleFromRgb(hslToRgbFloat(color), true, opacity)
919
924
  : `hsla(${color.h.toString()}, ${color.s.toString()}%, ${color.l.toString()}%, ${op.toString()})`);
920
925
  }
921
926
  function getHslFromAnimation(animation) {
@@ -943,10 +948,10 @@ function setTransformValue(factor, newFactor, key) {
943
948
  }
944
949
  }
945
950
  class RenderManager {
951
+ #backgroundElement;
952
+ #backgroundWarnings;
946
953
  #canvasClearPlugins;
947
954
  #canvasManager;
948
- #canvasPaintPlugins;
949
- #clearDrawPlugins;
950
955
  #colorPlugins;
951
956
  #container;
952
957
  #context;
@@ -954,9 +959,7 @@ class RenderManager {
954
959
  #drawParticlePlugins;
955
960
  #drawParticlesCleanupPlugins;
956
961
  #drawParticlesSetupPlugins;
957
- #drawPlugins;
958
- #drawSettingsCleanupPlugins;
959
- #drawSettingsSetupPlugins;
962
+ #layers;
960
963
  #pluginManager;
961
964
  #postDrawUpdaters;
962
965
  #preDrawUpdaters;
@@ -968,18 +971,25 @@ class RenderManager {
968
971
  this.#container = container;
969
972
  this.#canvasManager = canvasManager;
970
973
  this.#context = null;
974
+ this.#backgroundElement = null;
975
+ this.#backgroundWarnings = new Set();
971
976
  this.#preDrawUpdaters = [];
972
977
  this.#postDrawUpdaters = [];
973
- this.#colorPlugins = [];
974
978
  this.#canvasClearPlugins = [];
975
- this.#canvasPaintPlugins = [];
976
- this.#clearDrawPlugins = [];
979
+ this.#colorPlugins = [];
977
980
  this.#drawParticlePlugins = [];
978
981
  this.#drawParticlesCleanupPlugins = [];
979
982
  this.#drawParticlesSetupPlugins = [];
980
- this.#drawPlugins = [];
981
- this.#drawSettingsSetupPlugins = [];
982
- this.#drawSettingsCleanupPlugins = [];
983
+ this.#layers = {
984
+ 0: [],
985
+ 1: [],
986
+ 2: [],
987
+ 3: [],
988
+ 4: [],
989
+ 5: [],
990
+ 6: [],
991
+ 7: [],
992
+ };
983
993
  }
984
994
  get settings() {
985
995
  return this.#contextSettings;
@@ -993,32 +1003,38 @@ class RenderManager {
993
1003
  });
994
1004
  }
995
1005
  clear() {
996
- let pluginHandled = false;
997
1006
  for (const plugin of this.#canvasClearPlugins) {
998
- pluginHandled = plugin.canvasClear?.() ?? false;
999
- if (pluginHandled) {
1000
- break;
1007
+ if (plugin.canvasClear?.() ?? false) {
1008
+ return;
1001
1009
  }
1002
1010
  }
1003
- if (pluginHandled) {
1004
- return;
1011
+ for (const layer of Object.values(DrawLayer)) {
1012
+ if (typeof layer === "number") {
1013
+ for (const plugin of this.#getLayerPlugins(layer)) {
1014
+ if (plugin.canvasClear?.() ?? false) {
1015
+ return;
1016
+ }
1017
+ }
1018
+ }
1005
1019
  }
1006
1020
  this.canvasClear();
1007
1021
  }
1008
1022
  destroy() {
1009
1023
  this.stop();
1024
+ this.#backgroundElement = null;
1025
+ this.#backgroundWarnings.clear();
1010
1026
  this.#preDrawUpdaters = [];
1011
1027
  this.#postDrawUpdaters = [];
1012
- this.#colorPlugins = [];
1013
1028
  this.#canvasClearPlugins = [];
1014
- this.#canvasPaintPlugins = [];
1015
- this.#clearDrawPlugins = [];
1029
+ this.#colorPlugins = [];
1016
1030
  this.#drawParticlePlugins = [];
1017
1031
  this.#drawParticlesCleanupPlugins = [];
1018
1032
  this.#drawParticlesSetupPlugins = [];
1019
- this.#drawPlugins = [];
1020
- this.#drawSettingsSetupPlugins = [];
1021
- this.#drawSettingsCleanupPlugins = [];
1033
+ for (const layer of Object.values(DrawLayer)) {
1034
+ if (typeof layer === "number") {
1035
+ this.#layers[layer] = [];
1036
+ }
1037
+ }
1022
1038
  }
1023
1039
  draw(cb) {
1024
1040
  const ctx = this.#context;
@@ -1075,21 +1091,40 @@ class RenderManager {
1075
1091
  });
1076
1092
  }
1077
1093
  drawParticles(delta) {
1078
- const { particles } = this.#container;
1094
+ const { particles, actualOptions } = this.#container;
1079
1095
  this.clear();
1080
1096
  particles.update(delta);
1081
1097
  this.draw(ctx => {
1082
- for (const plugin of this.#drawSettingsSetupPlugins) {
1098
+ const width = this.#canvasManager.size.width, height = this.#canvasManager.size.height;
1099
+ if (this.#backgroundElement) {
1100
+ try {
1101
+ ctx.drawImage(this.#backgroundElement, originPoint.x, originPoint.y, width, height);
1102
+ }
1103
+ catch {
1104
+ this.#warnOnce("background-element-draw-error", "Error drawing background element onto canvas");
1105
+ }
1106
+ }
1107
+ const background = actualOptions.background;
1108
+ if (background.draw) {
1109
+ try {
1110
+ background.draw(ctx, delta);
1111
+ }
1112
+ catch {
1113
+ this.#warnOnce("background-draw-error", "Error in background.draw callback");
1114
+ }
1115
+ }
1116
+ for (const plugin of this.#getLayerPlugins(DrawLayer.BackgroundMask)) {
1117
+ plugin.canvasPaint?.();
1118
+ }
1119
+ for (const plugin of this.#getLayerPlugins(DrawLayer.CanvasSetup)) {
1083
1120
  plugin.drawSettingsSetup?.(ctx, delta);
1084
1121
  }
1085
- for (const plugin of this.#drawPlugins) {
1122
+ for (const plugin of this.#getLayerPlugins(DrawLayer.PluginContent)) {
1086
1123
  plugin.draw?.(ctx, delta);
1087
1124
  }
1088
1125
  particles.drawParticles(delta);
1089
- for (const plugin of this.#clearDrawPlugins) {
1126
+ for (const plugin of this.#getLayerPlugins(DrawLayer.CanvasCleanup)) {
1090
1127
  plugin.clearDraw?.(ctx, delta);
1091
- }
1092
- for (const plugin of this.#drawSettingsCleanupPlugins) {
1093
1128
  plugin.drawSettingsCleanup?.(ctx, delta);
1094
1129
  }
1095
1130
  });
@@ -1097,29 +1132,24 @@ class RenderManager {
1097
1132
  init() {
1098
1133
  this.initUpdaters();
1099
1134
  this.initPlugins();
1135
+ this.#resolveBackgroundElement();
1100
1136
  this.paint();
1101
1137
  }
1102
1138
  initPlugins() {
1103
- this.#colorPlugins = [];
1104
1139
  this.#canvasClearPlugins = [];
1105
- this.#canvasPaintPlugins = [];
1106
- this.#clearDrawPlugins = [];
1140
+ this.#colorPlugins = [];
1107
1141
  this.#drawParticlePlugins = [];
1108
1142
  this.#drawParticlesSetupPlugins = [];
1109
1143
  this.#drawParticlesCleanupPlugins = [];
1110
- this.#drawPlugins = [];
1111
- this.#drawSettingsSetupPlugins = [];
1112
- this.#drawSettingsCleanupPlugins = [];
1144
+ for (const layer of Object.values(DrawLayer)) {
1145
+ if (typeof layer === "number") {
1146
+ this.#layers[layer] = [];
1147
+ }
1148
+ }
1113
1149
  for (const plugin of this.#container.plugins) {
1114
1150
  if (plugin.particleFillColor ?? plugin.particleStrokeColor) {
1115
1151
  this.#colorPlugins.push(plugin);
1116
1152
  }
1117
- if (plugin.canvasClear) {
1118
- this.#canvasClearPlugins.push(plugin);
1119
- }
1120
- if (plugin.canvasPaint) {
1121
- this.#canvasPaintPlugins.push(plugin);
1122
- }
1123
1153
  if (plugin.drawParticle) {
1124
1154
  this.#drawParticlePlugins.push(plugin);
1125
1155
  }
@@ -1129,17 +1159,20 @@ class RenderManager {
1129
1159
  if (plugin.drawParticleCleanup) {
1130
1160
  this.#drawParticlesCleanupPlugins.push(plugin);
1131
1161
  }
1132
- if (plugin.draw) {
1133
- this.#drawPlugins.push(plugin);
1162
+ if (plugin.canvasClear) {
1163
+ this.#canvasClearPlugins.push(plugin);
1164
+ }
1165
+ if (plugin.canvasPaint) {
1166
+ this.#getLayerPlugins(DrawLayer.BackgroundMask).push(plugin);
1134
1167
  }
1135
1168
  if (plugin.drawSettingsSetup) {
1136
- this.#drawSettingsSetupPlugins.push(plugin);
1169
+ this.#getLayerPlugins(DrawLayer.CanvasSetup).push(plugin);
1137
1170
  }
1138
- if (plugin.drawSettingsCleanup) {
1139
- this.#drawSettingsCleanupPlugins.push(plugin);
1171
+ if (plugin.draw) {
1172
+ this.#getLayerPlugins(DrawLayer.PluginContent).push(plugin);
1140
1173
  }
1141
- if (plugin.clearDraw) {
1142
- this.#clearDrawPlugins.push(plugin);
1174
+ if (plugin.clearDraw ?? plugin.drawSettingsCleanup) {
1175
+ this.#getLayerPlugins(DrawLayer.CanvasCleanup).push(plugin);
1143
1176
  }
1144
1177
  }
1145
1178
  }
@@ -1157,7 +1190,7 @@ class RenderManager {
1157
1190
  }
1158
1191
  paint() {
1159
1192
  let handled = false;
1160
- for (const plugin of this.#canvasPaintPlugins) {
1193
+ for (const plugin of this.#getLayerPlugins(DrawLayer.BackgroundMask)) {
1161
1194
  handled = plugin.canvasPaint?.() ?? false;
1162
1195
  if (handled) {
1163
1196
  break;
@@ -1330,6 +1363,9 @@ class RenderManager {
1330
1363
  }
1331
1364
  drawer.beforeDraw(data);
1332
1365
  }
1366
+ #getLayerPlugins(layer) {
1367
+ return this.#layers[layer];
1368
+ }
1333
1369
  #getPluginParticleColors(particle) {
1334
1370
  let fColor, sColor;
1335
1371
  for (const plugin of this.#colorPlugins) {
@@ -1347,6 +1383,39 @@ class RenderManager {
1347
1383
  this.#reusablePluginColors[sColorIndex] = sColor;
1348
1384
  return this.#reusablePluginColors;
1349
1385
  }
1386
+ #resolveBackgroundElement() {
1387
+ const background = this.#container.actualOptions.background;
1388
+ this.#backgroundElement = null;
1389
+ if (!background.element) {
1390
+ return;
1391
+ }
1392
+ if (typeof background.element === "string") {
1393
+ if (typeof document !== "undefined") {
1394
+ const node = document.querySelector(background.element);
1395
+ if (node instanceof HTMLCanvasElement || node instanceof HTMLVideoElement || node instanceof HTMLImageElement) {
1396
+ this.#backgroundElement = node;
1397
+ }
1398
+ else if (node) {
1399
+ this.#warnOnce("background-element-not-supported", `Background element "${background.element}" is not a supported drawable element (canvas, video, or img)`);
1400
+ }
1401
+ else {
1402
+ this.#warnOnce("background-element-not-found", `Background element selector "${background.element}" not found`);
1403
+ }
1404
+ }
1405
+ }
1406
+ else if (background.element instanceof HTMLCanvasElement ||
1407
+ background.element instanceof OffscreenCanvas ||
1408
+ background.element instanceof HTMLVideoElement ||
1409
+ background.element instanceof HTMLImageElement) {
1410
+ this.#backgroundElement = background.element;
1411
+ }
1412
+ }
1413
+ #warnOnce(key, message) {
1414
+ if (!this.#backgroundWarnings.has(key)) {
1415
+ this.#backgroundWarnings.add(key);
1416
+ getLogger().warning(message);
1417
+ }
1418
+ }
1350
1419
  }
1351
1420
 
1352
1421
  const transferredCanvases = new WeakMap(), getTransferredCanvas = (canvas) => {
@@ -1923,7 +1992,6 @@ function runParticleCreatedPlugins(container, particle) {
1923
1992
  }
1924
1993
  class Particle {
1925
1994
  backColor;
1926
- bubble;
1927
1995
  destroyed;
1928
1996
  direction;
1929
1997
  effect;
@@ -1957,7 +2025,6 @@ class Particle {
1957
2025
  shapeData;
1958
2026
  sides;
1959
2027
  size;
1960
- slow;
1961
2028
  spawning;
1962
2029
  strokeColor;
1963
2030
  strokeOpacity;
@@ -1979,18 +2046,25 @@ class Particle {
1979
2046
  d: 1,
1980
2047
  };
1981
2048
  #container;
2049
+ #modifiers = [];
1982
2050
  #pluginManager;
1983
2051
  constructor(pluginManager, container) {
1984
2052
  this.#pluginManager = pluginManager;
1985
2053
  this.#container = container;
1986
2054
  }
2055
+ addModifier(modifier) {
2056
+ this.#modifiers.push(modifier);
2057
+ this.#modifiers.sort((a, b) => a.priority - b.priority);
2058
+ }
2059
+ clearModifiers() {
2060
+ this.#modifiers.length = 0;
2061
+ }
1987
2062
  destroy(override) {
1988
2063
  if (this.unbreakable || this.destroyed) {
1989
2064
  return;
1990
2065
  }
1991
2066
  this.destroyed = true;
1992
- this.bubble.inRange = false;
1993
- this.slow.inRange = false;
2067
+ this.clearModifiers();
1994
2068
  const container = this.#container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined;
1995
2069
  shapeDrawer?.particleDestroy?.(this);
1996
2070
  for (const plugin of container.particleDestroyedPlugins) {
@@ -2012,13 +2086,16 @@ class Particle {
2012
2086
  return this.rotation + (this.pathRotation ? this.velocity.angle : defaultAngle);
2013
2087
  }
2014
2088
  getFillColor() {
2015
- return this.#getRollColor(this.bubble.color ?? getHslFromAnimation(this.fillColor));
2089
+ return this.#getRollColor(this.#applyModifiers(getHslFromAnimation(this.fillColor), m => m.fillColor));
2016
2090
  }
2017
2091
  getMass() {
2018
2092
  return this.getRadius() ** squareExp * Math.PI * half;
2019
2093
  }
2094
+ getModifier(id) {
2095
+ return this.#modifiers.find(m => m.id === id);
2096
+ }
2020
2097
  getOpacity() {
2021
- const zIndexOptions = this.options.zIndex, zIndexFactor = zIndexFactorOffset - this.zIndexFactor, zOpacityFactor = zIndexFactor ** zIndexOptions.opacityRate, opacity = this.bubble.opacity ?? getRangeValue(this.opacity?.value ?? defaultOpacity), fillOpacity = this.fillOpacity ?? defaultOpacity, strokeOpacity = this.strokeOpacity ?? defaultOpacity;
2098
+ const zIndexOptions = this.options.zIndex, zIndexFactor = zIndexFactorOffset - this.zIndexFactor, zOpacityFactor = zIndexFactor ** zIndexOptions.opacityRate, baseOpacity = getRangeValue(this.opacity?.value ?? defaultOpacity), modifierOpacity = this.#applyModifiers(undefined, m => m.opacity), opacity = modifierOpacity ?? baseOpacity, fillOpacity = this.fillOpacity ?? defaultOpacity, strokeOpacity = this.strokeOpacity ?? defaultOpacity;
2022
2099
  this.#cachedOpacityData.fillOpacity = opacity * fillOpacity * zOpacityFactor;
2023
2100
  this.#cachedOpacityData.opacity = opacity * zOpacityFactor;
2024
2101
  this.#cachedOpacityData.strokeOpacity = opacity * strokeOpacity * zOpacityFactor;
@@ -2031,7 +2108,7 @@ class Particle {
2031
2108
  return this.#cachedPosition;
2032
2109
  }
2033
2110
  getRadius() {
2034
- return this.bubble.radius ?? this.size.value;
2111
+ return this.#applyModifiers(this.size.value, m => m.radius);
2035
2112
  }
2036
2113
  getRotateData() {
2037
2114
  const angle = this.getAngle();
@@ -2040,7 +2117,7 @@ class Particle {
2040
2117
  return this.#cachedRotateData;
2041
2118
  }
2042
2119
  getStrokeColor() {
2043
- return this.#getRollColor(this.bubble.color ?? getHslFromAnimation(this.strokeColor));
2120
+ return this.#getRollColor(this.#applyModifiers(getHslFromAnimation(this.strokeColor), m => m.strokeColor));
2044
2121
  }
2045
2122
  getTransformData(externalTransform) {
2046
2123
  const rotateData = this.getRotateData(), rotating = this.isRotating;
@@ -2060,13 +2137,6 @@ class Particle {
2060
2137
  this.options = resolveParticleOptions(this, container, this.#pluginManager, overrideOptions);
2061
2138
  container.retina.initParticle(this);
2062
2139
  runUpdaterPreInit(container.particleUpdaters, this);
2063
- this.bubble = {
2064
- inRange: false,
2065
- };
2066
- this.slow = {
2067
- inRange: false,
2068
- factor: 1,
2069
- };
2070
2140
  this.#initPosition(position);
2071
2141
  this.initialVelocity = this.#calculateVelocity();
2072
2142
  this.velocity = this.initialVelocity.copy();
@@ -2106,11 +2176,29 @@ class Particle {
2106
2176
  isVisible() {
2107
2177
  return !this.destroyed && !this.spawning && this.isInsideCanvas();
2108
2178
  }
2179
+ removeModifier(id) {
2180
+ const idx = this.#modifiers.findIndex(m => m.id === id);
2181
+ if (idx >= defaultAngle) {
2182
+ this.#modifiers.splice(idx, identity);
2183
+ }
2184
+ }
2109
2185
  reset() {
2110
2186
  for (const updater of this.#container.particleUpdaters) {
2111
2187
  updater.reset?.(this);
2112
2188
  }
2113
2189
  }
2190
+ #applyModifiers(base, getter) {
2191
+ let value = base;
2192
+ for (const mod of this.#modifiers) {
2193
+ if (mod.enabled) {
2194
+ const override = getter(mod);
2195
+ if (override !== undefined) {
2196
+ value = override;
2197
+ }
2198
+ }
2199
+ }
2200
+ return value;
2201
+ }
2114
2202
  #calcPosition(position, zIndex) {
2115
2203
  let tryCount = defaultRetryCount, posVec = position ? Vector3d.create(position.x, position.y, zIndex) : undefined;
2116
2204
  const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size;
@@ -308,29 +308,27 @@ function deepExtend(destination, ...sources) {
308
308
  }
309
309
  }
310
310
  else if (!isObject(destination) || Array.isArray(destination)) {
311
- destination = {};
311
+ destination = Object.create(null);
312
312
  }
313
- const sourceKeys = Object.keys(source), dangerousKeys = new Set(["__proto__", "constructor", "prototype"]), hasNested = sourceKeys.some(k => {
313
+ const sourceKeys = Object.keys(source), hasNested = sourceKeys.some(k => {
314
314
  const v = source[k];
315
315
  return isObject(v) || Array.isArray(v);
316
316
  });
317
317
  if (!hasNested) {
318
318
  const sourceDict = source, destDict = destination;
319
319
  for (const key of sourceKeys) {
320
- if (dangerousKeys.has(key)) {
320
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
321
321
  continue;
322
322
  }
323
- if (key in sourceDict) {
324
- const v = sourceDict[key];
325
- if (v !== undefined) {
326
- destDict[key] = v;
327
- }
323
+ const v = sourceDict[key];
324
+ if (v !== undefined) {
325
+ destDict[key] = v;
328
326
  }
329
327
  }
330
328
  continue;
331
329
  }
332
330
  for (const key of sourceKeys) {
333
- if (dangerousKeys.has(key)) {
331
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
334
332
  continue;
335
333
  }
336
334
  const sourceDict = source, destDict = destination, value = sourceDict[key];
@@ -746,7 +744,7 @@ class Engine {
746
744
  return this.#domArray;
747
745
  }
748
746
  get version() {
749
- return "4.2.0";
747
+ return "4.3.0";
750
748
  }
751
749
  addEventListener(type, listener) {
752
750
  this.#eventDispatcher.addEventListener(type, listener);
@@ -781,7 +779,7 @@ class Engine {
781
779
  if (typeof HTMLElement !== "undefined" && params.element instanceof HTMLElement) {
782
780
  domSourceElement = params.element;
783
781
  }
784
- const { Container } = await import('./Container-BWWTh10Z.js'), id = params.id ?? domSourceElement?.id ?? `tsparticles${Math.floor(getRandom() * loadRandomFactor).toString()}`, { index, url } = params, options = url ? await getDataFromUrl({ fallback: params.options, url, index }) : params.options, currentOptions = itemFromSingleOrMultiple(options, index), { items } = this, oldIndex = items.findIndex(v => v.id.description === id), newItem = new Container({
782
+ const { Container } = await import('./Container-DDWU1Sve.js'), id = params.id ?? domSourceElement?.id ?? `tsparticles${Math.floor(getRandom() * loadRandomFactor).toString()}`, { index, url } = params, options = url ? await getDataFromUrl({ fallback: params.options, url, index }) : params.options, currentOptions = itemFromSingleOrMultiple(options, index), { items } = this, oldIndex = items.findIndex(v => v.id.description === id), newItem = new Container({
785
783
  dispatchCallback: (eventType, args) => {
786
784
  this.dispatchEvent(eventType, args);
787
785
  },
@@ -906,6 +904,18 @@ var AnimationStatus;
906
904
  AnimationStatus["decreasing"] = "decreasing";
907
905
  })(AnimationStatus || (AnimationStatus = {}));
908
906
 
907
+ var DrawLayer;
908
+ (function (DrawLayer) {
909
+ DrawLayer[DrawLayer["BackgroundElement"] = 0] = "BackgroundElement";
910
+ DrawLayer[DrawLayer["BackgroundDraw"] = 1] = "BackgroundDraw";
911
+ DrawLayer[DrawLayer["BackgroundMask"] = 2] = "BackgroundMask";
912
+ DrawLayer[DrawLayer["CanvasSetup"] = 3] = "CanvasSetup";
913
+ DrawLayer[DrawLayer["PluginContent"] = 4] = "PluginContent";
914
+ DrawLayer[DrawLayer["Particles"] = 5] = "Particles";
915
+ DrawLayer[DrawLayer["CanvasCleanup"] = 6] = "CanvasCleanup";
916
+ DrawLayer[DrawLayer["Foreground"] = 7] = "Foreground";
917
+ })(DrawLayer || (DrawLayer = {}));
918
+
909
919
  const tsParticles = initEngine();
910
920
 
911
921
  let initialized = false;
@@ -946,4 +956,4 @@ async function waitForParticlesEngineInitialization() {
946
956
  await (initPromise !== null && initPromise !== void 0 ? initPromise : Promise.resolve());
947
957
  }
948
958
 
949
- export { safeDocument as $, AlterType as A, rgbMax as B, getRandomInRange as C, identity as D, defaultRgbMin as E, maxNits as F, sextuple as G, triple as H, phaseNumerator as I, sNormalizedOffset as J, originPoint as K, LimitMode as L, MoveDirection as M, minimumSize as N, OutMode as O, PixelMode as P, defaultCompositeValue as Q, RangeType as R, minStrokeWidth as S, defaultZoom as T, zIndexFactorOffset as U, defaultTransformValue as V, safeMutationObserver as W, generatedAttribute as X, cloneStyle as Y, safeMatchMedia as Z, getFullScreenStyle as _, isNull as a, millisecondsToSeconds as a0, manageListener as a1, visibilityChangeEvent as a2, resizeEvent as a3, Vector3d as a4, EventType as a5, defaultAngle as a6, defaultTransform as a7, defaultRetryCount as a8, tryCountIncrement as a9, defaultRatio as aA, defaultReduceFactor as aB, animate as aC, defaultFpsLimit as aD, minFpsLimit as aE, cancelAnimation as aF, defaultFps as aG, isParticlesEngineInitialized as aH, waitForParticlesEngineInitialization as aI, getParticleBaseVelocity as aa, randomInRangeValue as ab, getRandom as ac, OutModeDirection as ad, clamp as ae, minZ as af, getPosition as ag, getParticleDirectionAngle as ah, ParticleOutType as ai, Vector as aj, getRangeValue as ak, calcExactPositionOrRandomFromSize as al, itemFromSingleOrMultiple as am, isInArray as an, doublePI as ao, degToRad as ap, spatialHashGridCellSize as aq, minLimit as ar, minCount as as, getLogger as at, minIndex as au, defaultRemoveQuantity as av, defaultDensityFactor as aw, deleteCount as ax, countOffset as ay, one as az, setRangeValue as b, checkDistance as c, hMax as d, lMax as e, sMin as f, sMax as g, hMin as h, initParticlesEngine as i, isString as j, isArray as k, lMin as l, deepExtend as m, isNumber as n, isObject as o, executeOnSingleOrMultiple as p, isBoolean as q, itemFromArray as r, squareExp as s, tsParticles as t, defaultOpacity as u, randomColorValue as v, lFactor as w, half as x, double as y, hPhase as z };
959
+ export { safeMatchMedia as $, AlterType as A, rgbMax as B, getRandomInRange as C, identity as D, defaultRgbMin as E, maxNits as F, sextuple as G, triple as H, phaseNumerator as I, sNormalizedOffset as J, originPoint as K, LimitMode as L, MoveDirection as M, DrawLayer as N, OutMode as O, PixelMode as P, minimumSize as Q, RangeType as R, defaultCompositeValue as S, minStrokeWidth as T, defaultZoom as U, getLogger as V, zIndexFactorOffset as W, defaultTransformValue as X, safeMutationObserver as Y, generatedAttribute as Z, cloneStyle as _, isNull as a, getFullScreenStyle as a0, safeDocument as a1, millisecondsToSeconds as a2, manageListener as a3, visibilityChangeEvent as a4, resizeEvent as a5, Vector3d as a6, EventType as a7, defaultAngle as a8, defaultTransform as a9, one as aA, defaultRatio as aB, defaultReduceFactor as aC, animate as aD, defaultFpsLimit as aE, minFpsLimit as aF, cancelAnimation as aG, defaultFps as aH, isParticlesEngineInitialized as aI, waitForParticlesEngineInitialization as aJ, defaultRetryCount as aa, tryCountIncrement as ab, getParticleBaseVelocity as ac, randomInRangeValue as ad, getRandom as ae, OutModeDirection as af, clamp as ag, minZ as ah, getPosition as ai, getParticleDirectionAngle as aj, ParticleOutType as ak, Vector as al, calcExactPositionOrRandomFromSize as am, getRangeValue as an, itemFromSingleOrMultiple as ao, isInArray as ap, doublePI as aq, degToRad as ar, spatialHashGridCellSize as as, minLimit as at, minCount as au, minIndex as av, defaultRemoveQuantity as aw, defaultDensityFactor as ax, deleteCount as ay, countOffset as az, setRangeValue as b, checkDistance as c, hMax as d, lMax as e, sMin as f, sMax as g, hMin as h, initParticlesEngine as i, isString as j, isArray as k, lMin as l, deepExtend as m, isNumber as n, isObject as o, executeOnSingleOrMultiple as p, isBoolean as q, itemFromArray as r, squareExp as s, tsParticles as t, defaultOpacity as u, randomColorValue as v, lFactor as w, half as x, double as y, hPhase as z };
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- export { i as initParticlesEngine, aH as isParticlesEngineInitialized, aI as waitForParticlesEngineInitialization } from './index-aPxdqzSw.js';
1
+ export { i as initParticlesEngine, aI as isParticlesEngineInitialized, aJ as waitForParticlesEngineInitialization } from './index-D4tjp3z_.js';
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, c as createEvent, h } from './index-PhwiK2_P.js';
2
- import { i as initParticlesEngine, t as tsParticles } from './index-aPxdqzSw.js';
2
+ import { i as initParticlesEngine, t as tsParticles } from './index-D4tjp3z_.js';
3
3
 
4
4
  const StencilParticles = class {
5
5
  constructor(hostRef) {
@@ -1 +1 @@
1
- export{i as initParticlesEngine,aH as isParticlesEngineInitialized,aI as waitForParticlesEngineInitialization}from"./p-FNL2LsWF.js";
1
+ export{i as initParticlesEngine,aI as isParticlesEngineInitialized,aJ as waitForParticlesEngineInitialization}from"./p-DGXyew8u.js";
@@ -1 +1 @@
1
- import{r as t,c as i,h as s}from"./p-PhwiK2_P.js";import{i as e,t as n}from"./p-FNL2LsWF.js";const a=class{constructor(s){t(this,s),this.particlesLoaded=i(this,"particlesLoaded"),this.renderId=0}async componentDidLoad(){await this.loadParticles(++this.renderId)}disconnectedCallback(){var t;this.renderId++,null===(t=this.container)||void 0===t||t.destroy(),this.container=void 0}async onPropsChange(){await this.loadParticles(++this.renderId)}async onThemeChange(){var t,i;this.container&&(null===(i=(t=this.container).loadTheme)||void 0===i||i.call(t,this.theme))}async loadParticles(t){var i,s,a;if(null===(i=this.container)||void 0===i||i.destroy(),!this.containerElement)return void console.warn("[stencil-particles] container element not available yet");let o;try{if(this.init&&await e(this.init),!this.options&&!this.url)return void console.warn("[stencil-particles] neither options nor url provided");const t=Object.assign(Object.assign({element:this.containerElement},this.containerId?{id:this.containerId}:{}),this.options?{options:this.options}:{url:this.url});o=await n.load(t)}catch(t){return void console.error("[stencil-particles] load failed",t)}t===this.renderId?(this.container=o,this.particlesLoaded.emit(o),o&&this.theme&&(null===(a=(s=o).loadTheme)||void 0===a||a.call(s,this.theme))):null==o||o.destroy()}render(){return s("div",{key:"f5fe33d147a1a606a75fe0d1ee385bacaf0e0b7d",id:this.containerId,ref:t=>{this.containerElement=t},style:{width:"100%",height:"100%"}})}static get watchers(){return{options:[{onPropsChange:0}],url:[{onPropsChange:0}],init:[{onPropsChange:0}],containerId:[{onPropsChange:0}],theme:[{onThemeChange:0}]}}};export{a as stencil_particles}
1
+ import{r as t,c as i,h as s}from"./p-PhwiK2_P.js";import{i as e,t as n}from"./p-DGXyew8u.js";const a=class{constructor(s){t(this,s),this.particlesLoaded=i(this,"particlesLoaded"),this.renderId=0}async componentDidLoad(){await this.loadParticles(++this.renderId)}disconnectedCallback(){var t;this.renderId++,null===(t=this.container)||void 0===t||t.destroy(),this.container=void 0}async onPropsChange(){await this.loadParticles(++this.renderId)}async onThemeChange(){var t,i;this.container&&(null===(i=(t=this.container).loadTheme)||void 0===i||i.call(t,this.theme))}async loadParticles(t){var i,s,a;if(null===(i=this.container)||void 0===i||i.destroy(),!this.containerElement)return void console.warn("[stencil-particles] container element not available yet");let o;try{if(this.init&&await e(this.init),!this.options&&!this.url)return void console.warn("[stencil-particles] neither options nor url provided");const t=Object.assign(Object.assign({element:this.containerElement},this.containerId?{id:this.containerId}:{}),this.options?{options:this.options}:{url:this.url});o=await n.load(t)}catch(t){return void console.error("[stencil-particles] load failed",t)}t===this.renderId?(this.container=o,this.particlesLoaded.emit(o),o&&this.theme&&(null===(a=(s=o).loadTheme)||void 0===a||a.call(s,this.theme))):null==o||o.destroy()}render(){return s("div",{key:"f5fe33d147a1a606a75fe0d1ee385bacaf0e0b7d",id:this.containerId,ref:t=>{this.containerElement=t},style:{width:"100%",height:"100%"}})}static get watchers(){return{options:[{onPropsChange:0}],url:[{onPropsChange:0}],init:[{onPropsChange:0}],containerId:[{onPropsChange:0}],theme:[{onThemeChange:0}]}}};export{a as stencil_particles}
@@ -0,0 +1 @@
1
+ const t="generated",n="source-over",e="resize",s="visibilitychange",a=100,i=.5,r=1e3,o={x:0,y:0,z:0},c={a:1,b:0,c:0,d:1},u="random",h=2,f=2*Math.PI,l=60,d="true",p="false",g="canvas",w=0,m=2,M=100,v=1,y=1,b=1,E=255,P=360,x=100,A=100,L=0,S=0,k=60,z=1,C=0,D=1,O=1,T=120,_=0,F=1,j=1,B=0,$=0,H=1,q=0,I=0,R=1,U=1,G=0,J=1,K=0,N=1,V=0,W=400,Z=3,Q=6,X=1,Y=1,tt=0,nt=1;var et;function st(t){return"z"in t?t.z:o.z}!function(t){t.bottom="bottom",t.bottomLeft="bottom-left",t.bottomRight="bottom-right",t.left="left",t.none="none",t.right="right",t.top="top",t.topLeft="top-left",t.topRight="top-right",t.outside="outside",t.inside="inside"}(et||(et={}));class at{x;y;z;constructor(t=o.x,n=o.y,e=o.z){this.x=t,this.y=n,this.z=e}static get origin(){return at.create(o.x,o.y,o.z)}get angle(){return Math.atan2(this.y,this.x)}set angle(t){this.#t(t,this.length)}get length(){return Math.sqrt(this.getLengthSq())}set length(t){this.#t(this.angle,t)}static clone(t){return at.create(t.x,t.y,st(t))}static create(t,n,e){return"number"==typeof t?new at(t,n??o.y,e??o.z):new at(t.x,t.y,st(t))}add(t){return at.create(this.x+t.x,this.y+t.y,this.z+st(t))}addTo(t){this.x+=t.x,this.y+=t.y,this.z+=st(t)}copy(){return at.clone(this)}div(t){return at.create(this.x/t,this.y/t,this.z/t)}getLengthSq(){return this.x**2+this.y**2}mult(t){return at.create(this.x*t,this.y*t,this.z*t)}multTo(t){this.x*=t,this.y*=t,this.z*=t}normalize(){const t=this.length;0!=t&&this.multTo(1/t)}rotate(t){return at.create(this.x*Math.cos(t)-this.y*Math.sin(t),this.x*Math.sin(t)+this.y*Math.cos(t),o.z)}setTo(t){this.x=t.x,this.y=t.y,this.z=st(t)}sub(t){return at.create(this.x-t.x,this.y-t.y,this.z-st(t))}subFrom(t){this.x-=t.x,this.y-=t.y,this.z-=st(t)}#t(t,n){this.x=Math.cos(t)*n,this.y=Math.sin(t)*n}}class it extends at{constructor(t=o.x,n=o.y){super(t,n,o.z)}static get origin(){return it.create(o.x,o.y)}static clone(t){return it.create(t.x,t.y)}static create(t,n){return"number"==typeof t?new it(t,n??o.y):new it(t.x,t.y)}}function rt(t){return"boolean"==typeof t}function ot(t){return"string"==typeof t}function ct(t){return"number"==typeof t}function ut(t){return"object"==typeof t&&null!==t}function ht(t){return Array.isArray(t)}function ft(t){return null==t}const lt=Math.PI/180;let dt=Math.random;function pt(){return Mt(dt(),0,1-Number.EPSILON)}function gt(t,n){return pt()*(n-t)+t}function wt(t){return requestAnimationFrame(t)}function mt(t){cancelAnimationFrame(t)}function Mt(t,n,e){return Math.min(Math.max(t,n),e)}function vt(t){const n=Et(t);let e=bt(t);return n===e&&(e=0),gt(e,n)}function yt(t){return ct(t)?t:vt(t)}function bt(t){return ct(t)?t:t.min}function Et(t){return ct(t)?t:t.max}function Pt(t,n){if(t===n||void 0===n&&ct(t))return t;const e=bt(t),s=Et(t);return void 0!==n?{min:Math.min(e,n),max:Math.max(s,n)}:Pt(e,s)}function xt(t,n,e){return function(t,n){const e=t.x-n.x,s=t.y-n.y;return e*e+s*s}(t,n)<=e*e}function At(t){return t*lt}function Lt(t,n,e){if(ct(t))return At(t);switch(t){case et.top:return.5*-Math.PI;case et.topRight:return.25*-Math.PI;case et.right:return 0;case et.bottomRight:return.25*Math.PI;case et.bottom:return.5*Math.PI;case et.bottomLeft:return.75*Math.PI;case et.left:return Math.PI;case et.topLeft:return.75*-Math.PI;case et.inside:return Math.atan2(e.y-n.y,e.x-n.x);case et.outside:return Math.atan2(n.y-e.y,n.x-e.x);default:return pt()*f}}function St(t){const n=it.origin;return n.length=1,n.angle=t,n}function kt(t){const{position:n,size:e}=t;return{x:n?.x??pt()*e.width,y:n?.y??pt()*e.height}}var zt,Ct;function Dt(){return globalThis.document}function Ot(t){if("undefined"!=typeof matchMedia)return matchMedia(t)}function Tt(t){if("undefined"!=typeof MutationObserver)return new MutationObserver(t)}function _t(t,n){return t===n||ht(n)&&n.includes(t)}function Ft(t,n,e=!0){return t[void 0!==n&&e?n%t.length:Math.floor(pt()*t.length)]}function jt(t,...n){for(const e of n){if(ft(e))continue;if(!ut(e)){t=e;continue}Array.isArray(e)?Array.isArray(t)||(t=[]):ut(t)&&!Array.isArray(t)||(t=Object.create(null));const n=Object.keys(e);if(n.some((t=>{const n=e[t];return ut(n)||Array.isArray(n)})))for(const s of n){if("__proto__"===s||"constructor"===s||"prototype"===s)continue;const n=t,a=e[s];n[s]=Array.isArray(a)?a.map((t=>jt(void 0,t))):jt(n[s],a)}else{const s=e,a=t;for(const t of n){if("__proto__"===t||"constructor"===t||"prototype"===t)continue;const n=s[t];void 0!==n&&(a[t]=n)}}}return t}function Bt(t,n){return ht(t)?t.map(((t,e)=>n(t,e))):n(t,0)}function $t(t,n,e){return ht(t)?Ft(t,n,e):t}function Ht(t,n){return function(t,n){if(t.mode!==Ct.percent){const{mode:n,...e}=t;return e}return"x"in t?{x:t.x/a*n.width,y:t.y/a*n.height}:{width:t.width/a*n.width,height:t.height/a*n.height}}(t,n)}function qt(t){const n=Dt().createElement("div").style;for(const e in t){const s=t[e];if(!(e in t)||ft(s))continue;const a=t.getPropertyValue?.(s);if(!a)continue;const i=t.getPropertyPriority?.(s);i?n.setProperty(s,a,i):n.setProperty(s,a)}return n}let It,Rt;function Ut(t){if(It!==t||!Rt){It=t;const n=Dt().createElement("div").style,e=10,s={width:"100%",height:"100%",margin:"0",padding:"0",borderWidth:"0",position:"fixed",zIndex:t.toString(e),"z-index":t.toString(e),top:"0",left:"0","pointer-events":"none"};for(const t in s){const e=s[t];void 0!==e&&n.setProperty(t,e)}Rt=n}return Rt}function Gt(t,n,e,s,a){if(s){let s={passive:!0};rt(a)?s.capture=a:void 0!==a&&(s=a),t.addEventListener(n,e,s)}else t.removeEventListener(n,e,a)}async function Jt(t,n,e,s=!1){let a=n.get(t);if(!a||s){const s=await Promise.all([...e.entries()].map((([n,e])=>e(t).then((t=>[n,t])))));a=new Map(s),n.set(t,a)}return a}!function(t){t.bottom="bottom",t.left="left",t.right="right",t.top="top"}(zt||(zt={})),function(t){t.precise="precise",t.percent="percent"}(Ct||(Ct={}));class Kt{#n;constructor(){this.#n=new Map}addEventListener(t,n){this.removeEventListener(t,n);let e=this.#n.get(t);e||(e=[],this.#n.set(t,e)),e.push(n)}dispatchEvent(t,n){const e=this.#n.get(t);e?.forEach((t=>{t(n)}))}hasEventListener(t){return!!this.#n.get(t)}removeAllEventListeners(t){t?this.#n.delete(t):this.#n=new Map}removeEventListener(t,n){const e=this.#n.get(t);if(!e)return;const s=e.length,a=e.indexOf(n);a<0||(1===s?this.#n.delete(t):e.splice(a,1))}}var Nt;!function(t){t.configAdded="configAdded",t.containerInit="containerInit",t.particlesSetup="particlesSetup",t.containerStarted="containerStarted",t.containerStopped="containerStopped",t.containerDestroyed="containerDestroyed",t.containerPaused="containerPaused",t.containerPlay="containerPlay",t.containerBuilt="containerBuilt",t.particleAdded="particleAdded",t.particleDestroyed="particleDestroyed",t.particleRemoved="particleRemoved"}(Nt||(Nt={}));class Vt{colorManagers=new Map;easingFunctions=new Map;effectDrawers=new Map;initializers={effects:new Map,shapes:new Map,updaters:new Map};palettes=new Map;plugins=[];presets=new Map;shapeDrawers=new Map;updaters=new Map;#e=new Set;#s=new Map;#a;#i=new Set;#r=!1;#o=!1;#c=new Set;constructor(t){this.#a=t}get configs(){const t={};for(const[n,e]of this.#s)t[n]=e;return t}addColorManager(t,n){this.colorManagers.set(t,n)}addConfig(t){const n=t.key??t.name??"default";this.#s.set(n,t),this.#a.dispatchEvent(Nt.configAdded,{data:{name:n,config:t}})}addEasing(t,n){this.easingFunctions.get(t)||this.easingFunctions.set(t,n)}addEffect(t,n){this.initializers.effects.set(t,n)}addPalette(t,n){this.palettes.set(t,n)}addParticleUpdater(t,n){this.initializers.updaters.set(t,n)}addPlugin(t){this.getPlugin(t.id)||this.plugins.push(t)}addPreset(t,n,e=!1){!e&&this.getPreset(t)||this.presets.set(t,n)}addShape(t,n){for(const e of t)this.initializers.shapes.set(e,n)}clearPlugins(t){this.effectDrawers.delete(t),this.shapeDrawers.delete(t),this.updaters.delete(t)}getEasing(t){return this.easingFunctions.get(t)??(t=>t)}getEffectDrawers(t,n=!1){return Jt(t,this.effectDrawers,this.initializers.effects,n)}getPalette(t){return this.palettes.get(t)}getPlugin(t){return this.plugins.find((n=>n.id===t))}getPreset(t){return this.presets.get(t)}async getShapeDrawers(t,n=!1){return Jt(t,this.shapeDrawers,this.initializers.shapes,n)}async getUpdaters(t,n=!1){return async function(t,n,e,s=!1){let a=n.get(t);return a&&!s||(a=await Promise.all([...e.values()].map((n=>n(t)))),n.set(t,a)),a}(t,this.updaters,this.initializers.updaters,n)}async init(){if(!this.#r&&!this.#o){this.#o=!0,this.#i=new Set,this.#e=new Set(this.#c);try{for(const t of this.#e)await this.#u(t,this.#i,this.#e)}finally{this.#c.clear(),this.#o=!1,this.#r=!0}}}loadParticlesOptions(t,n,...e){const s=this.updaters.get(t);s&&s.forEach((t=>t.loadOptions?.(n,...e)))}async register(...t){if(this.#r)throw new Error("Register plugins can only be done before calling tsParticles.load()");for(const n of t)this.#o?await this.#u(n,this.#i,this.#e):this.#c.add(n)}async#u(t,n,e){n.has(t)||(n.add(t),e.add(t),await t(this.#a))}}const Wt=t=>(...n)=>{t(...n)},Zt={debug:Wt(console.debug),error:(t,...n)=>{console.error(`tsParticles - Error - ${t}`,...n)},info:Wt(console.info),log:Wt(console.log),trace:Wt(console.trace),verbose:Wt(console.log),warning:Wt(console.warn)};function Qt(){return Zt}const Xt="100%";var Yt,tn,nn,en,sn,an,rn,on,cn,un,hn,fn;!function(t){t.circle="circle",t.rectangle="rectangle"}(Yt||(Yt={})),function(t){t.clockwise="clockwise",t.counterClockwise="counter-clockwise",t.random="random"}(tn||(tn={})),function(t){t.auto="auto",t.increase="increase",t.decrease="decrease",t.random="random"}(nn||(nn={})),function(t){t.delete="delete",t.wait="wait"}(en||(en={})),function(t){t.bounce="bounce",t.none="none",t.out="out",t.destroy="destroy",t.split="split"}(sn||(sn={})),function(t){t.darken="darken",t.enlighten="enlighten"}(an||(an={})),function(t){t.none="none",t.max="max",t.min="min"}(rn||(rn={})),function(t){t.linear="linear",t.radial="radial",t.random="random"}(on||(on={})),function(t){t.normal="normal",t.inside="inside",t.outside="outside"}(cn||(cn={})),function(t){t.max="max",t.min="min",t.random="random"}(un||(un={})),function(t){t.increasing="increasing",t.decreasing="decreasing"}(hn||(hn={})),function(t){t[t.BackgroundElement=0]="BackgroundElement",t[t.BackgroundDraw=1]="BackgroundDraw",t[t.BackgroundMask=2]="BackgroundMask",t[t.CanvasSetup=3]="CanvasSetup",t[t.PluginContent=4]="PluginContent",t[t.Particles=5]="Particles",t[t.CanvasCleanup=6]="CanvasCleanup",t[t.Foreground=7]="Foreground"}(fn||(fn={}));const ln=new class{pluginManager=new Vt(this);#h=[];#f=new Kt;#r=!1;get items(){return this.#h}get version(){return"4.3.0"}addEventListener(t,n){this.#f.addEventListener(t,n)}checkVersion(t){if(this.version!==t)throw new Error(`The tsParticles version is different from the loaded plugins version. Engine version: ${this.version}. Plugin version: ${t}`)}dispatchEvent(t,n){this.#f.dispatchEvent(t,n)}async init(){this.#r||(await this.pluginManager.init(),this.#r=!0)}item(t){const n=this.items,e=n[t];if(!e?.destroyed)return e;n.splice(t,1)}async load(n){let e;await this.init(),"undefined"!=typeof HTMLElement&&n.element instanceof HTMLElement&&(e=n.element);const{Container:s}=await import("./p-mhMhZKxL.js"),a=n.id??e?.id??`tsparticles${Math.floor(1e4*pt()).toString()}`,{index:i,url:r}=n,o=r?await async function(t){const n=$t(t.url,t.index);if(!n)return t.fallback;const e=await fetch(n);return e.ok?await e.json():(Qt().error(`${e.status.toString()} while retrieving config file`),t.fallback)}({fallback:n.options,url:r,index:i}):n.options,c=$t(o,i),{items:u}=this,h=u.findIndex((t=>t.id.description===a)),f=new s({dispatchCallback:(t,n)=>{this.dispatchEvent(t,n)},id:a,onDestroy:t=>{if(!t)return;const n=this.items,e=n.indexOf(f);e>=0&&n.splice(e,1)},pluginManager:this.pluginManager,sourceOptions:c});if(h>=0){const t=this.item(h),n=t?1:0;t&&!t.destroyed&&t.destroy(!1),u.splice(h,n,f)}else u.push(f);const l="undefined"!=typeof OffscreenCanvas&&n.element instanceof OffscreenCanvas?n.element:(n=>{const e=Dt();let s;if(n instanceof HTMLCanvasElement||n.tagName.toLowerCase()===g)s=n,s.dataset[t]??=p,s.dataset[t]===d&&(s.style.width||=Xt,s.style.height||=Xt,s.style.pointerEvents="none",s.style.setProperty("pointer-events","none"));else{const a=n.getElementsByTagName(g).item(0);a?(s=a,s.dataset[t]=p):(s=e.createElement(g),s.dataset[t]=d,n.appendChild(s)),s.style.width||=Xt,s.style.height||=Xt,s.style.pointerEvents="none",s.style.setProperty("pointer-events","none")}return s})(((n,e)=>{const s=Dt();let a=e??s.getElementById(n);return a||(a=s.createElement("canvas"),a.id=n,a.dataset[t]=d,s.body.append(a),a)})(a,e));return f.canvas.loadCanvas(l),await f.start(),f}async refresh(t=!0){t&&await Promise.all(this.items.map((t=>t.refresh())))}removeEventListener(t,n){this.#f.removeEventListener(t,n)}};let dn,pn,gn=!1;async function wn(t){if(!gn)if(dn){if(pn!==t)throw new Error("initParticlesEngine callback must be stable across the app lifecycle.");await dn}else pn=t,dn=(async()=>{t&&await t(ln),"function"==typeof ln.init&&await ln.init(),gn=!0})().catch((t=>{throw dn=void 0,pn=void 0,gn=!1,t})),await dn}function mn(){return gn}async function Mn(){await(null!=dn?dn:Promise.resolve())}export{Ot as $,an as A,E as B,gt as C,J as D,tt as E,W as F,Q as G,Z as H,Y as I,X as J,o as K,en as L,et as M,fn as N,sn as O,Ct as P,C as Q,Yt as R,n as S,K as T,nt as U,Qt as V,D as W,z as X,Tt as Y,t as Z,qt as _,ft as a,Ut as a0,Dt as a1,r as a2,Gt as a3,s as a4,e as a5,at as a6,Nt as a7,G as a8,c as a9,F as aA,y as aB,b as aC,wt as aD,T as aE,_ as aF,mt as aG,l as aH,mn as aI,Mn as aJ,w as aa,j as ab,St as ac,vt as ad,pt as ae,zt as af,Mt as ag,B as ah,Ht as ai,Lt as aj,cn as ak,it as al,kt as am,yt as an,$t as ao,_t as ap,f as aq,At as ar,M as as,$ as at,q as au,I as av,v as aw,R as ax,U as ay,H as az,Pt as b,xt as c,P as d,A as e,S as f,x as g,L as h,wn as i,ot as j,ht as k,V as l,jt as m,ct as n,ut as o,Bt as p,rt as q,Ft as r,m as s,ln as t,O as u,u as v,N as w,i as x,h as y,k as z}