UNPKG

230 kBJavaScriptView Raw
1(function webpackUniversalModuleDefinition(root, factory) {
2 if (typeof exports === "object" && typeof module === "object") module.exports = factory(); else if (typeof define === "function" && define.amd) define([], factory); else {
3 var a = factory();
4 for (var i in a) (typeof exports === "object" ? exports : root)[i] = a[i];
5 }
6})(window, (function() {
7 return function() {
8 "use strict";
9 var __webpack_require__ = {};
10 !function() {
11 __webpack_require__.d = function(exports, definition) {
12 for (var key in definition) {
13 if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
14 Object.defineProperty(exports, key, {
15 enumerable: true,
16 get: definition[key]
17 });
18 }
19 }
20 };
21 }();
22 !function() {
23 __webpack_require__.o = function(obj, prop) {
24 return Object.prototype.hasOwnProperty.call(obj, prop);
25 };
26 }();
27 !function() {
28 __webpack_require__.r = function(exports) {
29 if (typeof Symbol !== "undefined" && Symbol.toStringTag) {
30 Object.defineProperty(exports, Symbol.toStringTag, {
31 value: "Module"
32 });
33 }
34 Object.defineProperty(exports, "__esModule", {
35 value: true
36 });
37 };
38 }();
39 var __webpack_exports__ = {};
40 __webpack_require__.r(__webpack_exports__);
41 __webpack_require__.d(__webpack_exports__, {
42 AnimatableColor: function() {
43 return AnimatableColor;
44 },
45 AnimatableGradient: function() {
46 return AnimatableGradient;
47 },
48 AnimatableGradientColor: function() {
49 return AnimatableGradientColor;
50 },
51 AnimationOptions: function() {
52 return AnimationOptions;
53 },
54 Attract: function() {
55 return Attract;
56 },
57 Background: function() {
58 return Background;
59 },
60 BackgroundMask: function() {
61 return BackgroundMask;
62 },
63 BackgroundMaskCover: function() {
64 return BackgroundMaskCover;
65 },
66 Bounce: function() {
67 return Bounce;
68 },
69 Bubble: function() {
70 return Bubble;
71 },
72 BubbleBase: function() {
73 return BubbleBase;
74 },
75 BubbleDiv: function() {
76 return BubbleDiv;
77 },
78 Canvas: function() {
79 return Canvas;
80 },
81 Circle: function() {
82 return Circle;
83 },
84 CircleWarp: function() {
85 return CircleWarp;
86 },
87 ClickEvent: function() {
88 return ClickEvent;
89 },
90 Collisions: function() {
91 return Collisions;
92 },
93 CollisionsOverlap: function() {
94 return CollisionsOverlap;
95 },
96 ColorAnimation: function() {
97 return ColorAnimation;
98 },
99 Connect: function() {
100 return Connect;
101 },
102 ConnectLinks: function() {
103 return ConnectLinks;
104 },
105 Container: function() {
106 return Container;
107 },
108 Destroy: function() {
109 return Destroy;
110 },
111 DivEvent: function() {
112 return DivEvent;
113 },
114 Engine: function() {
115 return Engine;
116 },
117 EventListeners: function() {
118 return EventListeners;
119 },
120 Events: function() {
121 return Events;
122 },
123 ExternalInteractorBase: function() {
124 return ExternalInteractorBase;
125 },
126 FrameManager: function() {
127 return FrameManager;
128 },
129 FullScreen: function() {
130 return FullScreen;
131 },
132 Grab: function() {
133 return Grab;
134 },
135 GrabLinks: function() {
136 return GrabLinks;
137 },
138 GradientAngle: function() {
139 return GradientAngle;
140 },
141 GradientAngleAnimation: function() {
142 return GradientAngleAnimation;
143 },
144 GradientColorOpacity: function() {
145 return GradientColorOpacity;
146 },
147 GradientColorOpacityAnimation: function() {
148 return GradientColorOpacityAnimation;
149 },
150 HoverEvent: function() {
151 return HoverEvent;
152 },
153 HslAnimation: function() {
154 return HslAnimation;
155 },
156 InteractionManager: function() {
157 return InteractionManager;
158 },
159 Interactivity: function() {
160 return Interactivity;
161 },
162 Life: function() {
163 return Life;
164 },
165 LifeDelay: function() {
166 return LifeDelay;
167 },
168 LifeDuration: function() {
169 return LifeDuration;
170 },
171 Light: function() {
172 return Light;
173 },
174 LightArea: function() {
175 return LightArea;
176 },
177 LightGradient: function() {
178 return LightGradient;
179 },
180 LightShadow: function() {
181 return LightShadow;
182 },
183 Links: function() {
184 return Links;
185 },
186 LinksShadow: function() {
187 return LinksShadow;
188 },
189 LinksTriangle: function() {
190 return LinksTriangle;
191 },
192 Loader: function() {
193 return Loader;
194 },
195 Main: function() {
196 return Engine;
197 },
198 ManualParticle: function() {
199 return ManualParticle;
200 },
201 Modes: function() {
202 return Modes;
203 },
204 Motion: function() {
205 return Motion;
206 },
207 MotionReduce: function() {
208 return MotionReduce;
209 },
210 Move: function() {
211 return Move;
212 },
213 MoveAngle: function() {
214 return MoveAngle;
215 },
216 MoveAttract: function() {
217 return MoveAttract;
218 },
219 MoveGravity: function() {
220 return MoveGravity;
221 },
222 MovePath: function() {
223 return MovePath;
224 },
225 MovePathDelay: function() {
226 return MovePathDelay;
227 },
228 MoveTrail: function() {
229 return MoveTrail;
230 },
231 Opacity: function() {
232 return Opacity;
233 },
234 OpacityAnimation: function() {
235 return OpacityAnimation;
236 },
237 Options: function() {
238 return Options;
239 },
240 OptionsColor: function() {
241 return OptionsColor;
242 },
243 Orbit: function() {
244 return Orbit;
245 },
246 OrbitRotation: function() {
247 return OrbitRotation;
248 },
249 OutModes: function() {
250 return OutModes;
251 },
252 Parallax: function() {
253 return Parallax;
254 },
255 Particle: function() {
256 return Particle;
257 },
258 Particles: function() {
259 return Particles;
260 },
261 ParticlesBounce: function() {
262 return ParticlesBounce;
263 },
264 ParticlesBounceFactor: function() {
265 return ParticlesBounceFactor;
266 },
267 ParticlesDensity: function() {
268 return ParticlesDensity;
269 },
270 ParticlesInteractorBase: function() {
271 return ParticlesInteractorBase;
272 },
273 ParticlesNumber: function() {
274 return ParticlesNumber;
275 },
276 ParticlesOptions: function() {
277 return ParticlesOptions;
278 },
279 ParticlesRepulse: function() {
280 return ParticlesRepulse;
281 },
282 Plugins: function() {
283 return Plugins;
284 },
285 Point: function() {
286 return Point;
287 },
288 Push: function() {
289 return Push;
290 },
291 QuadTree: function() {
292 return QuadTree;
293 },
294 Range: function() {
295 return Range;
296 },
297 Rectangle: function() {
298 return Rectangle;
299 },
300 Remove: function() {
301 return Remove;
302 },
303 Repulse: function() {
304 return Repulse;
305 },
306 RepulseBase: function() {
307 return RepulseBase;
308 },
309 RepulseDiv: function() {
310 return RepulseDiv;
311 },
312 Responsive: function() {
313 return Responsive;
314 },
315 Retina: function() {
316 return Retina;
317 },
318 Roll: function() {
319 return Roll;
320 },
321 RollLight: function() {
322 return RollLight;
323 },
324 Rotate: function() {
325 return Rotate;
326 },
327 RotateAnimation: function() {
328 return RotateAnimation;
329 },
330 Shadow: function() {
331 return Shadow;
332 },
333 Shape: function() {
334 return Shape;
335 },
336 Size: function() {
337 return Size;
338 },
339 SizeAnimation: function() {
340 return SizeAnimation;
341 },
342 Slow: function() {
343 return Slow;
344 },
345 Spin: function() {
346 return Spin;
347 },
348 Split: function() {
349 return Split;
350 },
351 SplitFactor: function() {
352 return SplitFactor;
353 },
354 SplitRate: function() {
355 return SplitRate;
356 },
357 Stroke: function() {
358 return Stroke;
359 },
360 Theme: function() {
361 return Theme;
362 },
363 ThemeDefault: function() {
364 return ThemeDefault;
365 },
366 Tilt: function() {
367 return Tilt;
368 },
369 TiltAnimation: function() {
370 return TiltAnimation;
371 },
372 Trail: function() {
373 return Trail;
374 },
375 Twinkle: function() {
376 return Twinkle;
377 },
378 TwinkleValues: function() {
379 return TwinkleValues;
380 },
381 ValueWithRandom: function() {
382 return ValueWithRandom;
383 },
384 Vector: function() {
385 return Vector;
386 },
387 Vector3d: function() {
388 return Vector3d;
389 },
390 Wobble: function() {
391 return Wobble;
392 },
393 ZIndex: function() {
394 return ZIndex;
395 },
396 alterHsl: function() {
397 return alterHsl;
398 },
399 animate: function() {
400 return animate;
401 },
402 areBoundsInside: function() {
403 return areBoundsInside;
404 },
405 arrayRandomIndex: function() {
406 return arrayRandomIndex;
407 },
408 calcEasing: function() {
409 return calcEasing;
410 },
411 calcExactPositionOrRandomFromSize: function() {
412 return calcExactPositionOrRandomFromSize;
413 },
414 calcExactPositionOrRandomFromSizeRanged: function() {
415 return calcExactPositionOrRandomFromSizeRanged;
416 },
417 calcPositionFromSize: function() {
418 return calcPositionFromSize;
419 },
420 calcPositionOrRandomFromSize: function() {
421 return calcPositionOrRandomFromSize;
422 },
423 calcPositionOrRandomFromSizeRanged: function() {
424 return calcPositionOrRandomFromSizeRanged;
425 },
426 calculateBounds: function() {
427 return calculateBounds;
428 },
429 cancelAnimation: function() {
430 return cancelAnimation;
431 },
432 circleBounce: function() {
433 return circleBounce;
434 },
435 circleBounceDataFromParticle: function() {
436 return circleBounceDataFromParticle;
437 },
438 clamp: function() {
439 return clamp;
440 },
441 clear: function() {
442 return clear;
443 },
444 collisionVelocity: function() {
445 return collisionVelocity;
446 },
447 colorMix: function() {
448 return colorMix;
449 },
450 colorToHsl: function() {
451 return colorToHsl;
452 },
453 colorToRgb: function() {
454 return colorToRgb;
455 },
456 deepExtend: function() {
457 return deepExtend;
458 },
459 divMode: function() {
460 return divMode;
461 },
462 divModeExecute: function() {
463 return divModeExecute;
464 },
465 drawConnectLine: function() {
466 return drawConnectLine;
467 },
468 drawEllipse: function() {
469 return drawEllipse;
470 },
471 drawGrabLine: function() {
472 return drawGrabLine;
473 },
474 drawLine: function() {
475 return drawLine;
476 },
477 drawParticle: function() {
478 return drawParticle;
479 },
480 drawParticlePlugin: function() {
481 return drawParticlePlugin;
482 },
483 drawPlugin: function() {
484 return drawPlugin;
485 },
486 drawShape: function() {
487 return drawShape;
488 },
489 drawShapeAfterEffect: function() {
490 return drawShapeAfterEffect;
491 },
492 drawTriangle: function() {
493 return drawTriangle;
494 },
495 generatedAttribute: function() {
496 return generatedAttribute;
497 },
498 getDistance: function() {
499 return getDistance;
500 },
501 getDistances: function() {
502 return getDistances;
503 },
504 getHslAnimationFromHsl: function() {
505 return getHslAnimationFromHsl;
506 },
507 getHslFromAnimation: function() {
508 return getHslFromAnimation;
509 },
510 getLinkColor: function() {
511 return getLinkColor;
512 },
513 getLinkRandomColor: function() {
514 return getLinkRandomColor;
515 },
516 getParticleBaseVelocity: function() {
517 return getParticleBaseVelocity;
518 },
519 getParticleDirectionAngle: function() {
520 return getParticleDirectionAngle;
521 },
522 getRandomRgbColor: function() {
523 return getRandomRgbColor;
524 },
525 getRangeMax: function() {
526 return getRangeMax;
527 },
528 getRangeMin: function() {
529 return getRangeMin;
530 },
531 getRangeValue: function() {
532 return getRangeValue;
533 },
534 getStyleFromHsl: function() {
535 return getStyleFromHsl;
536 },
537 getStyleFromHsv: function() {
538 return getStyleFromHsv;
539 },
540 getStyleFromRgb: function() {
541 return getStyleFromRgb;
542 },
543 getValue: function() {
544 return getValue;
545 },
546 gradient: function() {
547 return gradient;
548 },
549 hslToHsv: function() {
550 return hslToHsv;
551 },
552 hslToRgb: function() {
553 return hslToRgb;
554 },
555 hslaToHsva: function() {
556 return hslaToHsva;
557 },
558 hslaToRgba: function() {
559 return hslaToRgba;
560 },
561 hsvToHsl: function() {
562 return hsvToHsl;
563 },
564 hsvToRgb: function() {
565 return hsvToRgb;
566 },
567 hsvaToHsla: function() {
568 return hsvaToHsla;
569 },
570 hsvaToRgba: function() {
571 return hsvaToRgba;
572 },
573 isDivModeEnabled: function() {
574 return isDivModeEnabled;
575 },
576 isInArray: function() {
577 return isInArray;
578 },
579 isPointInside: function() {
580 return isPointInside;
581 },
582 isSsr: function() {
583 return isSsr;
584 },
585 itemFromArray: function() {
586 return itemFromArray;
587 },
588 loadContainerOptions: function() {
589 return loadContainerOptions;
590 },
591 loadFont: function() {
592 return loadFont;
593 },
594 loadParticlesOptions: function() {
595 return loadParticlesOptions;
596 },
597 midColorValue: function() {
598 return midColorValue;
599 },
600 mix: function() {
601 return mix;
602 },
603 mouseDownEvent: function() {
604 return mouseDownEvent;
605 },
606 mouseLeaveEvent: function() {
607 return mouseLeaveEvent;
608 },
609 mouseMoveEvent: function() {
610 return mouseMoveEvent;
611 },
612 mouseOutEvent: function() {
613 return mouseOutEvent;
614 },
615 mouseUpEvent: function() {
616 return mouseUpEvent;
617 },
618 noPolygonDataLoaded: function() {
619 return noPolygonDataLoaded;
620 },
621 noPolygonFound: function() {
622 return noPolygonFound;
623 },
624 paintBase: function() {
625 return paintBase;
626 },
627 randomColorValue: function() {
628 return randomColorValue;
629 },
630 randomInRange: function() {
631 return randomInRange;
632 },
633 rectBounce: function() {
634 return rectBounce;
635 },
636 resizeEvent: function() {
637 return resizeEvent;
638 },
639 rgbToHsl: function() {
640 return rgbToHsl;
641 },
642 rgbToHsv: function() {
643 return rgbToHsv;
644 },
645 rgbaToHsva: function() {
646 return rgbaToHsva;
647 },
648 setRangeValue: function() {
649 return setRangeValue;
650 },
651 singleDivModeExecute: function() {
652 return singleDivModeExecute;
653 },
654 stringToAlpha: function() {
655 return stringToAlpha;
656 },
657 stringToRgb: function() {
658 return stringToRgb;
659 },
660 touchCancelEvent: function() {
661 return touchCancelEvent;
662 },
663 touchEndEvent: function() {
664 return touchEndEvent;
665 },
666 touchMoveEvent: function() {
667 return touchMoveEvent;
668 },
669 touchStartEvent: function() {
670 return touchStartEvent;
671 },
672 tsParticles: function() {
673 return tsParticles;
674 },
675 visibilityChangeEvent: function() {
676 return visibilityChangeEvent;
677 }
678 });
679 var __classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
680 if (kind === "m") throw new TypeError("Private method is not writable");
681 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
682 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
683 return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
684 value;
685 };
686 var __classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
687 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
688 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
689 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
690 };
691 var _EventDispatcher_listeners;
692 class EventDispatcher {
693 constructor() {
694 _EventDispatcher_listeners.set(this, void 0);
695 __classPrivateFieldSet(this, _EventDispatcher_listeners, new Map, "f");
696 }
697 addEventListener(type, listener) {
698 var _a;
699 this.removeEventListener(type, listener);
700 if (!__classPrivateFieldGet(this, _EventDispatcher_listeners, "f").get(type)) {
701 __classPrivateFieldGet(this, _EventDispatcher_listeners, "f").set(type, []);
702 }
703 (_a = __classPrivateFieldGet(this, _EventDispatcher_listeners, "f").get(type)) === null || _a === void 0 ? void 0 : _a.push(listener);
704 }
705 removeEventListener(type, listener) {
706 const arr = __classPrivateFieldGet(this, _EventDispatcher_listeners, "f").get(type);
707 if (!arr) {
708 return;
709 }
710 const length = arr.length, idx = arr.indexOf(listener);
711 if (idx < 0) {
712 return;
713 }
714 if (length === 1) {
715 __classPrivateFieldGet(this, _EventDispatcher_listeners, "f").delete(type);
716 } else {
717 arr.splice(idx, 1);
718 }
719 }
720 removeAllEventListeners(type) {
721 if (!type) {
722 __classPrivateFieldSet(this, _EventDispatcher_listeners, new Map, "f");
723 } else {
724 __classPrivateFieldGet(this, _EventDispatcher_listeners, "f").delete(type);
725 }
726 }
727 dispatchEvent(type, args) {
728 var _a;
729 (_a = __classPrivateFieldGet(this, _EventDispatcher_listeners, "f").get(type)) === null || _a === void 0 ? void 0 : _a.forEach((handler => handler(args)));
730 }
731 hasEventListener(type) {
732 return !!__classPrivateFieldGet(this, _EventDispatcher_listeners, "f").get(type);
733 }
734 }
735 _EventDispatcher_listeners = new WeakMap;
736 class Vector {
737 constructor(xOrCoords, y) {
738 if (typeof xOrCoords !== "number" && xOrCoords) {
739 this.x = xOrCoords.x;
740 this.y = xOrCoords.y;
741 } else if (xOrCoords !== undefined && y !== undefined) {
742 this.x = xOrCoords;
743 this.y = y;
744 } else {
745 throw new Error("tsParticles - Vector not initialized correctly");
746 }
747 }
748 static clone(source) {
749 return Vector.create(source.x, source.y);
750 }
751 static create(x, y) {
752 return new Vector(x, y);
753 }
754 static get origin() {
755 return Vector.create(0, 0);
756 }
757 get angle() {
758 return Math.atan2(this.y, this.x);
759 }
760 set angle(angle) {
761 this.updateFromAngle(angle, this.length);
762 }
763 get length() {
764 return Math.sqrt(this.getLengthSq());
765 }
766 set length(length) {
767 this.updateFromAngle(this.angle, length);
768 }
769 add(v) {
770 return Vector.create(this.x + v.x, this.y + v.y);
771 }
772 addTo(v) {
773 this.x += v.x;
774 this.y += v.y;
775 }
776 sub(v) {
777 return Vector.create(this.x - v.x, this.y - v.y);
778 }
779 subFrom(v) {
780 this.x -= v.x;
781 this.y -= v.y;
782 }
783 mult(n) {
784 return Vector.create(this.x * n, this.y * n);
785 }
786 multTo(n) {
787 this.x *= n;
788 this.y *= n;
789 }
790 div(n) {
791 return Vector.create(this.x / n, this.y / n);
792 }
793 divTo(n) {
794 this.x /= n;
795 this.y /= n;
796 }
797 distanceTo(v) {
798 return this.sub(v).length;
799 }
800 getLengthSq() {
801 return this.x ** 2 + this.y ** 2;
802 }
803 distanceToSq(v) {
804 return this.sub(v).getLengthSq();
805 }
806 manhattanDistanceTo(v) {
807 return Math.abs(v.x - this.x) + Math.abs(v.y - this.y);
808 }
809 copy() {
810 return Vector.clone(this);
811 }
812 setTo(v) {
813 this.x = v.x;
814 this.y = v.y;
815 }
816 rotate(angle) {
817 return Vector.create(this.x * Math.cos(angle) - this.y * Math.sin(angle), this.x * Math.sin(angle) + this.y * Math.cos(angle));
818 }
819 updateFromAngle(angle, length) {
820 this.x = Math.cos(angle) * length;
821 this.y = Math.sin(angle) * length;
822 }
823 }
824 function clamp(num, min, max) {
825 return Math.min(Math.max(num, min), max);
826 }
827 function mix(comp1, comp2, weight1, weight2) {
828 return Math.floor((comp1 * weight1 + comp2 * weight2) / (weight1 + weight2));
829 }
830 function randomInRange(r) {
831 const max = getRangeMax(r);
832 let min = getRangeMin(r);
833 if (max === min) {
834 min = 0;
835 }
836 return Math.random() * (max - min) + min;
837 }
838 function getRangeValue(value) {
839 return typeof value === "number" ? value : randomInRange(value);
840 }
841 function getRangeMin(value) {
842 return typeof value === "number" ? value : value.min;
843 }
844 function getRangeMax(value) {
845 return typeof value === "number" ? value : value.max;
846 }
847 function setRangeValue(source, value) {
848 if (source === value || value === undefined && typeof source === "number") {
849 return source;
850 }
851 const min = getRangeMin(source), max = getRangeMax(source);
852 return value !== undefined ? {
853 min: Math.min(min, value),
854 max: Math.max(max, value)
855 } : setRangeValue(min, max);
856 }
857 function getValue(options) {
858 const random = options.random, {enable: enable, minimumValue: minimumValue} = typeof random === "boolean" ? {
859 enable: random,
860 minimumValue: 0
861 } : random;
862 return enable ? getRangeValue(setRangeValue(options.value, minimumValue)) : getRangeValue(options.value);
863 }
864 function getDistances(pointA, pointB) {
865 const dx = pointA.x - pointB.x, dy = pointA.y - pointB.y;
866 return {
867 dx: dx,
868 dy: dy,
869 distance: Math.sqrt(dx * dx + dy * dy)
870 };
871 }
872 function getDistance(pointA, pointB) {
873 return getDistances(pointA, pointB).distance;
874 }
875 function getParticleDirectionAngle(direction, position, center) {
876 if (typeof direction === "number") {
877 return direction * Math.PI / 180;
878 } else {
879 switch (direction) {
880 case "top":
881 return -Math.PI / 2;
882
883 case "top-right":
884 return -Math.PI / 4;
885
886 case "right":
887 return 0;
888
889 case "bottom-right":
890 return Math.PI / 4;
891
892 case "bottom":
893 return Math.PI / 2;
894
895 case "bottom-left":
896 return 3 * Math.PI / 4;
897
898 case "left":
899 return Math.PI;
900
901 case "top-left":
902 return -3 * Math.PI / 4;
903
904 case "inside":
905 return Math.atan2(center.y - position.y, center.x - position.x);
906
907 case "outside":
908 return Math.atan2(position.y - center.y, position.x - center.x);
909
910 case "none":
911 default:
912 return Math.random() * Math.PI * 2;
913 }
914 }
915 }
916 function getParticleBaseVelocity(direction) {
917 const baseVelocity = Vector.origin;
918 baseVelocity.length = 1;
919 baseVelocity.angle = direction;
920 return baseVelocity;
921 }
922 function collisionVelocity(v1, v2, m1, m2) {
923 return Vector.create(v1.x * (m1 - m2) / (m1 + m2) + v2.x * 2 * m2 / (m1 + m2), v1.y);
924 }
925 function calcEasing(value, type) {
926 switch (type) {
927 case "ease-out-quad":
928 return 1 - (1 - value) ** 2;
929
930 case "ease-out-cubic":
931 return 1 - (1 - value) ** 3;
932
933 case "ease-out-quart":
934 return 1 - (1 - value) ** 4;
935
936 case "ease-out-quint":
937 return 1 - (1 - value) ** 5;
938
939 case "ease-out-expo":
940 return value === 1 ? 1 : 1 - Math.pow(2, -10 * value);
941
942 case "ease-out-sine":
943 return Math.sin(value * Math.PI / 2);
944
945 case "ease-out-back":
946 {
947 const c1 = 1.70158, c3 = c1 + 1;
948 return 1 + c3 * Math.pow(value - 1, 3) + c1 * Math.pow(value - 1, 2);
949 }
950
951 case "ease-out-circ":
952 return Math.sqrt(1 - Math.pow(value - 1, 2));
953
954 default:
955 return value;
956 }
957 }
958 function calcPositionFromSize(data) {
959 var _a, _b;
960 return ((_a = data.position) === null || _a === void 0 ? void 0 : _a.x) !== undefined && ((_b = data.position) === null || _b === void 0 ? void 0 : _b.y) !== undefined ? {
961 x: data.position.x * data.size.width / 100,
962 y: data.position.y * data.size.height / 100
963 } : undefined;
964 }
965 function calcPositionOrRandomFromSize(data) {
966 var _a, _b, _c, _d;
967 return {
968 x: ((_b = (_a = data.position) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : Math.random() * 100) * data.size.width / 100,
969 y: ((_d = (_c = data.position) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : Math.random() * 100) * data.size.height / 100
970 };
971 }
972 function calcPositionOrRandomFromSizeRanged(data) {
973 var _a, _b;
974 const position = {
975 x: ((_a = data.position) === null || _a === void 0 ? void 0 : _a.x) !== undefined ? getRangeValue(data.position.x) : undefined,
976 y: ((_b = data.position) === null || _b === void 0 ? void 0 : _b.y) !== undefined ? getRangeValue(data.position.y) : undefined
977 };
978 return calcPositionOrRandomFromSize({
979 size: data.size,
980 position: position
981 });
982 }
983 function calcExactPositionOrRandomFromSize(data) {
984 var _a, _b, _c, _d;
985 return {
986 x: (_b = (_a = data.position) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : Math.random() * data.size.width,
987 y: (_d = (_c = data.position) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : Math.random() * data.size.height
988 };
989 }
990 function calcExactPositionOrRandomFromSizeRanged(data) {
991 var _a, _b;
992 const position = {
993 x: ((_a = data.position) === null || _a === void 0 ? void 0 : _a.x) !== undefined ? getRangeValue(data.position.x) : undefined,
994 y: ((_b = data.position) === null || _b === void 0 ? void 0 : _b.y) !== undefined ? getRangeValue(data.position.y) : undefined
995 };
996 return calcExactPositionOrRandomFromSize({
997 size: data.size,
998 position: position
999 });
1000 }
1001 class OptionsColor {
1002 constructor() {
1003 this.value = "";
1004 }
1005 static create(source, data) {
1006 const color = new OptionsColor;
1007 color.load(source);
1008 if (data !== undefined) {
1009 if (typeof data === "string" || data instanceof Array) {
1010 color.load({
1011 value: data
1012 });
1013 } else {
1014 color.load(data);
1015 }
1016 }
1017 return color;
1018 }
1019 load(data) {
1020 if ((data === null || data === void 0 ? void 0 : data.value) === undefined) {
1021 return;
1022 }
1023 this.value = data.value;
1024 }
1025 }
1026 class Background {
1027 constructor() {
1028 this.color = new OptionsColor;
1029 this.color.value = "";
1030 this.image = "";
1031 this.position = "";
1032 this.repeat = "";
1033 this.size = "";
1034 this.opacity = 1;
1035 }
1036 load(data) {
1037 if (!data) {
1038 return;
1039 }
1040 if (data.color !== undefined) {
1041 this.color = OptionsColor.create(this.color, data.color);
1042 }
1043 if (data.image !== undefined) {
1044 this.image = data.image;
1045 }
1046 if (data.position !== undefined) {
1047 this.position = data.position;
1048 }
1049 if (data.repeat !== undefined) {
1050 this.repeat = data.repeat;
1051 }
1052 if (data.size !== undefined) {
1053 this.size = data.size;
1054 }
1055 if (data.opacity !== undefined) {
1056 this.opacity = data.opacity;
1057 }
1058 }
1059 }
1060 class BackgroundMaskCover {
1061 constructor() {
1062 this.color = new OptionsColor;
1063 this.color.value = "#fff";
1064 this.opacity = 1;
1065 }
1066 load(data) {
1067 if (!data) {
1068 return;
1069 }
1070 if (data.color !== undefined) {
1071 this.color = OptionsColor.create(this.color, data.color);
1072 }
1073 if (data.opacity !== undefined) {
1074 this.opacity = data.opacity;
1075 }
1076 }
1077 }
1078 class BackgroundMask {
1079 constructor() {
1080 this.composite = "destination-out";
1081 this.cover = new BackgroundMaskCover;
1082 this.enable = false;
1083 }
1084 load(data) {
1085 if (!data) {
1086 return;
1087 }
1088 if (data.composite !== undefined) {
1089 this.composite = data.composite;
1090 }
1091 if (data.cover !== undefined) {
1092 const cover = data.cover;
1093 const color = typeof data.cover === "string" ? {
1094 color: data.cover
1095 } : data.cover;
1096 this.cover.load(cover.color !== undefined ? cover : {
1097 color: color
1098 });
1099 }
1100 if (data.enable !== undefined) {
1101 this.enable = data.enable;
1102 }
1103 }
1104 }
1105 class FullScreen {
1106 constructor() {
1107 this.enable = true;
1108 this.zIndex = 0;
1109 }
1110 load(data) {
1111 if (!data) {
1112 return;
1113 }
1114 if (data.enable !== undefined) {
1115 this.enable = data.enable;
1116 }
1117 if (data.zIndex !== undefined) {
1118 this.zIndex = data.zIndex;
1119 }
1120 }
1121 }
1122 class ClickEvent {
1123 constructor() {
1124 this.enable = false;
1125 this.mode = [];
1126 }
1127 load(data) {
1128 if (!data) {
1129 return;
1130 }
1131 if (data.enable !== undefined) {
1132 this.enable = data.enable;
1133 }
1134 if (data.mode !== undefined) {
1135 this.mode = data.mode;
1136 }
1137 }
1138 }
1139 class DivEvent {
1140 constructor() {
1141 this.selectors = [];
1142 this.enable = false;
1143 this.mode = [];
1144 this.type = "circle";
1145 }
1146 get elementId() {
1147 return this.ids;
1148 }
1149 set elementId(value) {
1150 this.ids = value;
1151 }
1152 get el() {
1153 return this.elementId;
1154 }
1155 set el(value) {
1156 this.elementId = value;
1157 }
1158 get ids() {
1159 return this.selectors instanceof Array ? this.selectors.map((t => t.replace("#", ""))) : this.selectors.replace("#", "");
1160 }
1161 set ids(value) {
1162 this.selectors = value instanceof Array ? value.map((t => `#${t}`)) : `#${value}`;
1163 }
1164 load(data) {
1165 var _a, _b;
1166 if (!data) {
1167 return;
1168 }
1169 const ids = (_b = (_a = data.ids) !== null && _a !== void 0 ? _a : data.elementId) !== null && _b !== void 0 ? _b : data.el;
1170 if (ids !== undefined) {
1171 this.ids = ids;
1172 }
1173 if (data.selectors !== undefined) {
1174 this.selectors = data.selectors;
1175 }
1176 if (data.enable !== undefined) {
1177 this.enable = data.enable;
1178 }
1179 if (data.mode !== undefined) {
1180 this.mode = data.mode;
1181 }
1182 if (data.type !== undefined) {
1183 this.type = data.type;
1184 }
1185 }
1186 }
1187 class Parallax {
1188 constructor() {
1189 this.enable = false;
1190 this.force = 2;
1191 this.smooth = 10;
1192 }
1193 load(data) {
1194 if (!data) {
1195 return;
1196 }
1197 if (data.enable !== undefined) {
1198 this.enable = data.enable;
1199 }
1200 if (data.force !== undefined) {
1201 this.force = data.force;
1202 }
1203 if (data.smooth !== undefined) {
1204 this.smooth = data.smooth;
1205 }
1206 }
1207 }
1208 class HoverEvent {
1209 constructor() {
1210 this.enable = false;
1211 this.mode = [];
1212 this.parallax = new Parallax;
1213 }
1214 load(data) {
1215 if (!data) {
1216 return;
1217 }
1218 if (data.enable !== undefined) {
1219 this.enable = data.enable;
1220 }
1221 if (data.mode !== undefined) {
1222 this.mode = data.mode;
1223 }
1224 this.parallax.load(data.parallax);
1225 }
1226 }
1227 class Events {
1228 constructor() {
1229 this.onClick = new ClickEvent;
1230 this.onDiv = new DivEvent;
1231 this.onHover = new HoverEvent;
1232 this.resize = true;
1233 }
1234 get onclick() {
1235 return this.onClick;
1236 }
1237 set onclick(value) {
1238 this.onClick = value;
1239 }
1240 get ondiv() {
1241 return this.onDiv;
1242 }
1243 set ondiv(value) {
1244 this.onDiv = value;
1245 }
1246 get onhover() {
1247 return this.onHover;
1248 }
1249 set onhover(value) {
1250 this.onHover = value;
1251 }
1252 load(data) {
1253 var _a, _b, _c;
1254 if (!data) {
1255 return;
1256 }
1257 this.onClick.load((_a = data.onClick) !== null && _a !== void 0 ? _a : data.onclick);
1258 const onDiv = (_b = data.onDiv) !== null && _b !== void 0 ? _b : data.ondiv;
1259 if (onDiv !== undefined) {
1260 if (onDiv instanceof Array) {
1261 this.onDiv = onDiv.map((div => {
1262 const tmp = new DivEvent;
1263 tmp.load(div);
1264 return tmp;
1265 }));
1266 } else {
1267 this.onDiv = new DivEvent;
1268 this.onDiv.load(onDiv);
1269 }
1270 }
1271 this.onHover.load((_c = data.onHover) !== null && _c !== void 0 ? _c : data.onhover);
1272 if (data.resize !== undefined) {
1273 this.resize = data.resize;
1274 }
1275 }
1276 }
1277 class Attract {
1278 constructor() {
1279 this.distance = 200;
1280 this.duration = .4;
1281 this.easing = "ease-out-quad";
1282 this.factor = 1;
1283 this.maxSpeed = 50;
1284 this.speed = 1;
1285 }
1286 load(data) {
1287 if (!data) {
1288 return;
1289 }
1290 if (data.distance !== undefined) {
1291 this.distance = data.distance;
1292 }
1293 if (data.duration !== undefined) {
1294 this.duration = data.duration;
1295 }
1296 if (data.easing !== undefined) {
1297 this.easing = data.easing;
1298 }
1299 if (data.factor !== undefined) {
1300 this.factor = data.factor;
1301 }
1302 if (data.maxSpeed !== undefined) {
1303 this.maxSpeed = data.maxSpeed;
1304 }
1305 if (data.speed !== undefined) {
1306 this.speed = data.speed;
1307 }
1308 }
1309 }
1310 class Bounce {
1311 constructor() {
1312 this.distance = 200;
1313 }
1314 load(data) {
1315 if (!data) {
1316 return;
1317 }
1318 if (data.distance !== undefined) {
1319 this.distance = data.distance;
1320 }
1321 }
1322 }
1323 class BubbleBase {
1324 constructor() {
1325 this.distance = 200;
1326 this.duration = .4;
1327 this.mix = false;
1328 }
1329 load(data) {
1330 if (!data) {
1331 return;
1332 }
1333 if (data.distance !== undefined) {
1334 this.distance = data.distance;
1335 }
1336 if (data.duration !== undefined) {
1337 this.duration = data.duration;
1338 }
1339 if (data.mix !== undefined) {
1340 this.mix = data.mix;
1341 }
1342 if (data.opacity !== undefined) {
1343 this.opacity = data.opacity;
1344 }
1345 if (data.color !== undefined) {
1346 if (data.color instanceof Array) {
1347 this.color = data.color.map((s => OptionsColor.create(undefined, s)));
1348 } else {
1349 if (this.color instanceof Array) {
1350 this.color = new OptionsColor;
1351 }
1352 this.color = OptionsColor.create(this.color, data.color);
1353 }
1354 }
1355 if (data.size !== undefined) {
1356 this.size = data.size;
1357 }
1358 }
1359 }
1360 class BubbleDiv extends BubbleBase {
1361 constructor() {
1362 super();
1363 this.selectors = [];
1364 }
1365 get ids() {
1366 return this.selectors instanceof Array ? this.selectors.map((t => t.replace("#", ""))) : this.selectors.replace("#", "");
1367 }
1368 set ids(value) {
1369 this.selectors = value instanceof Array ? value.map((t => `#${t}`)) : `#${value}`;
1370 }
1371 load(data) {
1372 super.load(data);
1373 if (!data) {
1374 return;
1375 }
1376 if (data.ids !== undefined) {
1377 this.ids = data.ids;
1378 }
1379 if (data.selectors !== undefined) {
1380 this.selectors = data.selectors;
1381 }
1382 }
1383 }
1384 class Bubble extends BubbleBase {
1385 load(data) {
1386 super.load(data);
1387 if (!data) {
1388 return;
1389 }
1390 if (data.divs instanceof Array) {
1391 this.divs = data.divs.map((s => {
1392 const tmp = new BubbleDiv;
1393 tmp.load(s);
1394 return tmp;
1395 }));
1396 } else {
1397 if (this.divs instanceof Array || !this.divs) {
1398 this.divs = new BubbleDiv;
1399 }
1400 this.divs.load(data.divs);
1401 }
1402 }
1403 }
1404 class ConnectLinks {
1405 constructor() {
1406 this.opacity = .5;
1407 }
1408 load(data) {
1409 if (!(data !== undefined && data.opacity !== undefined)) {
1410 return;
1411 }
1412 if (data.opacity !== undefined) {
1413 this.opacity = data.opacity;
1414 }
1415 }
1416 }
1417 class Connect {
1418 constructor() {
1419 this.distance = 80;
1420 this.links = new ConnectLinks;
1421 this.radius = 60;
1422 }
1423 get line_linked() {
1424 return this.links;
1425 }
1426 set line_linked(value) {
1427 this.links = value;
1428 }
1429 get lineLinked() {
1430 return this.links;
1431 }
1432 set lineLinked(value) {
1433 this.links = value;
1434 }
1435 load(data) {
1436 var _a, _b;
1437 if (!data) {
1438 return;
1439 }
1440 if (data.distance !== undefined) {
1441 this.distance = data.distance;
1442 }
1443 this.links.load((_b = (_a = data.links) !== null && _a !== void 0 ? _a : data.lineLinked) !== null && _b !== void 0 ? _b : data.line_linked);
1444 if (data.radius !== undefined) {
1445 this.radius = data.radius;
1446 }
1447 }
1448 }
1449 class GrabLinks {
1450 constructor() {
1451 this.blink = false;
1452 this.consent = false;
1453 this.opacity = 1;
1454 }
1455 load(data) {
1456 if (!data) {
1457 return;
1458 }
1459 if (data.blink !== undefined) {
1460 this.blink = data.blink;
1461 }
1462 if (data.color !== undefined) {
1463 this.color = OptionsColor.create(this.color, data.color);
1464 }
1465 if (data.consent !== undefined) {
1466 this.consent = data.consent;
1467 }
1468 if (data.opacity !== undefined) {
1469 this.opacity = data.opacity;
1470 }
1471 }
1472 }
1473 class Grab {
1474 constructor() {
1475 this.distance = 100;
1476 this.links = new GrabLinks;
1477 }
1478 get line_linked() {
1479 return this.links;
1480 }
1481 set line_linked(value) {
1482 this.links = value;
1483 }
1484 get lineLinked() {
1485 return this.links;
1486 }
1487 set lineLinked(value) {
1488 this.links = value;
1489 }
1490 load(data) {
1491 var _a, _b;
1492 if (!data) {
1493 return;
1494 }
1495 if (data.distance !== undefined) {
1496 this.distance = data.distance;
1497 }
1498 this.links.load((_b = (_a = data.links) !== null && _a !== void 0 ? _a : data.lineLinked) !== null && _b !== void 0 ? _b : data.line_linked);
1499 }
1500 }
1501 class LightGradient {
1502 constructor() {
1503 this.start = new OptionsColor;
1504 this.stop = new OptionsColor;
1505 this.start.value = "#ffffff";
1506 this.stop.value = "#000000";
1507 }
1508 load(data) {
1509 if (!data) {
1510 return;
1511 }
1512 this.start = OptionsColor.create(this.start, data.start);
1513 this.stop = OptionsColor.create(this.stop, data.stop);
1514 }
1515 }
1516 class LightArea {
1517 constructor() {
1518 this.gradient = new LightGradient;
1519 this.radius = 1e3;
1520 }
1521 load(data) {
1522 if (!data) {
1523 return;
1524 }
1525 this.gradient.load(data.gradient);
1526 if (data.radius !== undefined) {
1527 this.radius = data.radius;
1528 }
1529 }
1530 }
1531 class LightShadow {
1532 constructor() {
1533 this.color = new OptionsColor;
1534 this.color.value = "#000000";
1535 this.length = 2e3;
1536 }
1537 load(data) {
1538 if (!data) {
1539 return;
1540 }
1541 this.color = OptionsColor.create(this.color, data.color);
1542 if (data.length !== undefined) {
1543 this.length = data.length;
1544 }
1545 }
1546 }
1547 class Light {
1548 constructor() {
1549 this.area = new LightArea;
1550 this.shadow = new LightShadow;
1551 }
1552 load(data) {
1553 if (!data) {
1554 return;
1555 }
1556 this.area.load(data.area);
1557 this.shadow.load(data.shadow);
1558 }
1559 }
1560 class Push {
1561 constructor() {
1562 this.default = true;
1563 this.groups = [];
1564 this.quantity = 4;
1565 }
1566 get particles_nb() {
1567 return this.quantity;
1568 }
1569 set particles_nb(value) {
1570 this.quantity = value;
1571 }
1572 load(data) {
1573 var _a;
1574 if (!data) {
1575 return;
1576 }
1577 if (data.default !== undefined) {
1578 this.default = data.default;
1579 }
1580 if (data.groups !== undefined) {
1581 this.groups = data.groups.map((t => t));
1582 }
1583 if (!this.groups.length) {
1584 this.default = true;
1585 }
1586 const quantity = (_a = data.quantity) !== null && _a !== void 0 ? _a : data.particles_nb;
1587 if (quantity !== undefined) {
1588 this.quantity = quantity;
1589 }
1590 }
1591 }
1592 class Remove {
1593 constructor() {
1594 this.quantity = 2;
1595 }
1596 get particles_nb() {
1597 return this.quantity;
1598 }
1599 set particles_nb(value) {
1600 this.quantity = value;
1601 }
1602 load(data) {
1603 var _a;
1604 if (!data) {
1605 return;
1606 }
1607 const quantity = (_a = data.quantity) !== null && _a !== void 0 ? _a : data.particles_nb;
1608 if (quantity !== undefined) {
1609 this.quantity = quantity;
1610 }
1611 }
1612 }
1613 class RepulseBase {
1614 constructor() {
1615 this.distance = 200;
1616 this.duration = .4;
1617 this.factor = 100;
1618 this.speed = 1;
1619 this.maxSpeed = 50;
1620 this.easing = "ease-out-quad";
1621 }
1622 load(data) {
1623 if (!data) {
1624 return;
1625 }
1626 if (data.distance !== undefined) {
1627 this.distance = data.distance;
1628 }
1629 if (data.duration !== undefined) {
1630 this.duration = data.duration;
1631 }
1632 if (data.easing !== undefined) {
1633 this.easing = data.easing;
1634 }
1635 if (data.factor !== undefined) {
1636 this.factor = data.factor;
1637 }
1638 if (data.speed !== undefined) {
1639 this.speed = data.speed;
1640 }
1641 if (data.maxSpeed !== undefined) {
1642 this.maxSpeed = data.maxSpeed;
1643 }
1644 }
1645 }
1646 class RepulseDiv extends RepulseBase {
1647 constructor() {
1648 super();
1649 this.selectors = [];
1650 }
1651 get ids() {
1652 if (this.selectors instanceof Array) {
1653 return this.selectors.map((t => t.replace("#", "")));
1654 } else {
1655 return this.selectors.replace("#", "");
1656 }
1657 }
1658 set ids(value) {
1659 if (value instanceof Array) {
1660 this.selectors = value.map((() => `#${value}`));
1661 } else {
1662 this.selectors = `#${value}`;
1663 }
1664 }
1665 load(data) {
1666 super.load(data);
1667 if (!data) {
1668 return;
1669 }
1670 if (data.ids !== undefined) {
1671 this.ids = data.ids;
1672 }
1673 if (data.selectors !== undefined) {
1674 this.selectors = data.selectors;
1675 }
1676 }
1677 }
1678 class Repulse extends RepulseBase {
1679 load(data) {
1680 super.load(data);
1681 if (!data) {
1682 return;
1683 }
1684 if (data.divs instanceof Array) {
1685 this.divs = data.divs.map((s => {
1686 const tmp = new RepulseDiv;
1687 tmp.load(s);
1688 return tmp;
1689 }));
1690 } else {
1691 if (this.divs instanceof Array || !this.divs) {
1692 this.divs = new RepulseDiv;
1693 }
1694 this.divs.load(data.divs);
1695 }
1696 }
1697 }
1698 class Slow {
1699 constructor() {
1700 this.factor = 3;
1701 this.radius = 200;
1702 }
1703 get active() {
1704 return false;
1705 }
1706 set active(_value) {}
1707 load(data) {
1708 if (!data) {
1709 return;
1710 }
1711 if (data.factor !== undefined) {
1712 this.factor = data.factor;
1713 }
1714 if (data.radius !== undefined) {
1715 this.radius = data.radius;
1716 }
1717 }
1718 }
1719 class Trail {
1720 constructor() {
1721 this.delay = 1;
1722 this.pauseOnStop = false;
1723 this.quantity = 1;
1724 }
1725 load(data) {
1726 if (!data) {
1727 return;
1728 }
1729 if (data.delay !== undefined) {
1730 this.delay = data.delay;
1731 }
1732 if (data.quantity !== undefined) {
1733 this.quantity = data.quantity;
1734 }
1735 if (data.particles !== undefined) {
1736 this.particles = deepExtend({}, data.particles);
1737 }
1738 if (data.pauseOnStop !== undefined) {
1739 this.pauseOnStop = data.pauseOnStop;
1740 }
1741 }
1742 }
1743 class Modes {
1744 constructor() {
1745 this.attract = new Attract;
1746 this.bounce = new Bounce;
1747 this.bubble = new Bubble;
1748 this.connect = new Connect;
1749 this.grab = new Grab;
1750 this.light = new Light;
1751 this.push = new Push;
1752 this.remove = new Remove;
1753 this.repulse = new Repulse;
1754 this.slow = new Slow;
1755 this.trail = new Trail;
1756 }
1757 load(data) {
1758 if (!data) {
1759 return;
1760 }
1761 this.attract.load(data.attract);
1762 this.bubble.load(data.bubble);
1763 this.connect.load(data.connect);
1764 this.grab.load(data.grab);
1765 this.light.load(data.light);
1766 this.push.load(data.push);
1767 this.remove.load(data.remove);
1768 this.repulse.load(data.repulse);
1769 this.slow.load(data.slow);
1770 this.trail.load(data.trail);
1771 }
1772 }
1773 class Interactivity {
1774 constructor() {
1775 this.detectsOn = "window";
1776 this.events = new Events;
1777 this.modes = new Modes;
1778 }
1779 get detect_on() {
1780 return this.detectsOn;
1781 }
1782 set detect_on(value) {
1783 this.detectsOn = value;
1784 }
1785 load(data) {
1786 var _a, _b, _c;
1787 if (!data) {
1788 return;
1789 }
1790 const detectsOn = (_a = data.detectsOn) !== null && _a !== void 0 ? _a : data.detect_on;
1791 if (detectsOn !== undefined) {
1792 this.detectsOn = detectsOn;
1793 }
1794 this.events.load(data.events);
1795 this.modes.load(data.modes);
1796 if (((_c = (_b = data.modes) === null || _b === void 0 ? void 0 : _b.slow) === null || _c === void 0 ? void 0 : _c.active) === true) {
1797 if (this.events.onHover.mode instanceof Array) {
1798 if (this.events.onHover.mode.indexOf("slow") < 0) {
1799 this.events.onHover.mode.push("slow");
1800 }
1801 } else if (this.events.onHover.mode !== "slow") {
1802 this.events.onHover.mode = [ this.events.onHover.mode, "slow" ];
1803 }
1804 }
1805 }
1806 }
1807 class ManualParticle {
1808 load(data) {
1809 var _a, _b;
1810 if (!data) {
1811 return;
1812 }
1813 if (data.position !== undefined) {
1814 this.position = {
1815 x: (_a = data.position.x) !== null && _a !== void 0 ? _a : 50,
1816 y: (_b = data.position.y) !== null && _b !== void 0 ? _b : 50
1817 };
1818 }
1819 if (data.options !== undefined) {
1820 this.options = deepExtend({}, data.options);
1821 }
1822 }
1823 }
1824 class MotionReduce {
1825 constructor() {
1826 this.factor = 4;
1827 this.value = true;
1828 }
1829 load(data) {
1830 if (!data) {
1831 return;
1832 }
1833 if (data.factor !== undefined) {
1834 this.factor = data.factor;
1835 }
1836 if (data.value !== undefined) {
1837 this.value = data.value;
1838 }
1839 }
1840 }
1841 class Motion {
1842 constructor() {
1843 this.disable = false;
1844 this.reduce = new MotionReduce;
1845 }
1846 load(data) {
1847 if (!data) {
1848 return;
1849 }
1850 if (data.disable !== undefined) {
1851 this.disable = data.disable;
1852 }
1853 this.reduce.load(data.reduce);
1854 }
1855 }
1856 class Responsive {
1857 constructor() {
1858 this.maxWidth = Infinity;
1859 this.options = {};
1860 this.mode = "canvas";
1861 }
1862 load(data) {
1863 if (!data) {
1864 return;
1865 }
1866 if (data.maxWidth !== undefined) {
1867 this.maxWidth = data.maxWidth;
1868 }
1869 if (data.mode !== undefined) {
1870 if (data.mode === "screen") {
1871 this.mode = "screen";
1872 } else {
1873 this.mode = "canvas";
1874 }
1875 }
1876 if (data.options !== undefined) {
1877 this.options = deepExtend({}, data.options);
1878 }
1879 }
1880 }
1881 class ThemeDefault {
1882 constructor() {
1883 this.auto = false;
1884 this.mode = "any";
1885 this.value = false;
1886 }
1887 load(data) {
1888 if (!data) {
1889 return;
1890 }
1891 if (data.auto !== undefined) {
1892 this.auto = data.auto;
1893 }
1894 if (data.mode !== undefined) {
1895 this.mode = data.mode;
1896 }
1897 if (data.value !== undefined) {
1898 this.value = data.value;
1899 }
1900 }
1901 }
1902 class Theme {
1903 constructor() {
1904 this.name = "";
1905 this.default = new ThemeDefault;
1906 }
1907 load(data) {
1908 if (!data) {
1909 return;
1910 }
1911 if (data.name !== undefined) {
1912 this.name = data.name;
1913 }
1914 this.default.load(data.default);
1915 if (data.options !== undefined) {
1916 this.options = deepExtend({}, data.options);
1917 }
1918 }
1919 }
1920 var Options_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
1921 if (kind === "m") throw new TypeError("Private method is not writable");
1922 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
1923 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
1924 return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
1925 value;
1926 };
1927 var Options_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
1928 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
1929 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
1930 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1931 };
1932 var _Options_instances, _Options_engine, _Options_findDefaultTheme;
1933 class Options {
1934 constructor(engine) {
1935 _Options_instances.add(this);
1936 _Options_engine.set(this, void 0);
1937 Options_classPrivateFieldSet(this, _Options_engine, engine, "f");
1938 this.autoPlay = true;
1939 this.background = new Background;
1940 this.backgroundMask = new BackgroundMask;
1941 this.fullScreen = new FullScreen;
1942 this.detectRetina = true;
1943 this.duration = 0;
1944 this.fpsLimit = 120;
1945 this.interactivity = new Interactivity;
1946 this.manualParticles = [];
1947 this.motion = new Motion;
1948 this.particles = loadParticlesOptions();
1949 this.pauseOnBlur = true;
1950 this.pauseOnOutsideViewport = true;
1951 this.responsive = [];
1952 this.style = {};
1953 this.themes = [];
1954 this.zLayers = 100;
1955 }
1956 get fps_limit() {
1957 return this.fpsLimit;
1958 }
1959 set fps_limit(value) {
1960 this.fpsLimit = value;
1961 }
1962 get retina_detect() {
1963 return this.detectRetina;
1964 }
1965 set retina_detect(value) {
1966 this.detectRetina = value;
1967 }
1968 get backgroundMode() {
1969 return this.fullScreen;
1970 }
1971 set backgroundMode(value) {
1972 this.fullScreen.load(value);
1973 }
1974 load(data) {
1975 var _a, _b, _c, _d, _e;
1976 if (!data) {
1977 return;
1978 }
1979 if (data.preset !== undefined) {
1980 if (data.preset instanceof Array) {
1981 for (const preset of data.preset) {
1982 this.importPreset(preset);
1983 }
1984 } else {
1985 this.importPreset(data.preset);
1986 }
1987 }
1988 if (data.autoPlay !== undefined) {
1989 this.autoPlay = data.autoPlay;
1990 }
1991 const detectRetina = (_a = data.detectRetina) !== null && _a !== void 0 ? _a : data.retina_detect;
1992 if (detectRetina !== undefined) {
1993 this.detectRetina = detectRetina;
1994 }
1995 if (data.duration !== undefined) {
1996 this.duration = data.duration;
1997 }
1998 const fpsLimit = (_b = data.fpsLimit) !== null && _b !== void 0 ? _b : data.fps_limit;
1999 if (fpsLimit !== undefined) {
2000 this.fpsLimit = fpsLimit;
2001 }
2002 if (data.pauseOnBlur !== undefined) {
2003 this.pauseOnBlur = data.pauseOnBlur;
2004 }
2005 if (data.pauseOnOutsideViewport !== undefined) {
2006 this.pauseOnOutsideViewport = data.pauseOnOutsideViewport;
2007 }
2008 if (data.zLayers !== undefined) {
2009 this.zLayers = data.zLayers;
2010 }
2011 this.background.load(data.background);
2012 const fullScreen = (_c = data.fullScreen) !== null && _c !== void 0 ? _c : data.backgroundMode;
2013 if (typeof fullScreen === "boolean") {
2014 this.fullScreen.enable = fullScreen;
2015 } else {
2016 this.fullScreen.load(fullScreen);
2017 }
2018 this.backgroundMask.load(data.backgroundMask);
2019 this.interactivity.load(data.interactivity);
2020 if (data.manualParticles !== undefined) {
2021 this.manualParticles = data.manualParticles.map((t => {
2022 const tmp = new ManualParticle;
2023 tmp.load(t);
2024 return tmp;
2025 }));
2026 }
2027 this.motion.load(data.motion);
2028 this.particles.load(data.particles);
2029 this.style = deepExtend(this.style, data.style);
2030 Options_classPrivateFieldGet(this, _Options_engine, "f").plugins.loadOptions(this, data);
2031 if (data.responsive !== undefined) {
2032 for (const responsive of data.responsive) {
2033 const optResponsive = new Responsive;
2034 optResponsive.load(responsive);
2035 this.responsive.push(optResponsive);
2036 }
2037 }
2038 this.responsive.sort(((a, b) => a.maxWidth - b.maxWidth));
2039 if (data.themes !== undefined) {
2040 for (const theme of data.themes) {
2041 const optTheme = new Theme;
2042 optTheme.load(theme);
2043 this.themes.push(optTheme);
2044 }
2045 }
2046 this.defaultDarkTheme = (_d = Options_classPrivateFieldGet(this, _Options_instances, "m", _Options_findDefaultTheme).call(this, "dark")) === null || _d === void 0 ? void 0 : _d.name;
2047 this.defaultLightTheme = (_e = Options_classPrivateFieldGet(this, _Options_instances, "m", _Options_findDefaultTheme).call(this, "light")) === null || _e === void 0 ? void 0 : _e.name;
2048 }
2049 setTheme(name) {
2050 if (name) {
2051 const chosenTheme = this.themes.find((theme => theme.name === name));
2052 if (chosenTheme) {
2053 this.load(chosenTheme.options);
2054 }
2055 } else {
2056 const mediaMatch = typeof matchMedia !== "undefined" && matchMedia("(prefers-color-scheme: dark)"), clientDarkMode = mediaMatch && mediaMatch.matches, defaultTheme = Options_classPrivateFieldGet(this, _Options_instances, "m", _Options_findDefaultTheme).call(this, clientDarkMode ? "dark" : "light");
2057 if (defaultTheme) {
2058 this.load(defaultTheme.options);
2059 }
2060 }
2061 }
2062 setResponsive(width, pxRatio, defaultOptions) {
2063 this.load(defaultOptions);
2064 const responsiveOptions = this.responsive.find((t => t.mode === "screen" && screen ? t.maxWidth * pxRatio > screen.availWidth : t.maxWidth * pxRatio > width));
2065 this.load(responsiveOptions === null || responsiveOptions === void 0 ? void 0 : responsiveOptions.options);
2066 return responsiveOptions === null || responsiveOptions === void 0 ? void 0 : responsiveOptions.maxWidth;
2067 }
2068 importPreset(preset) {
2069 this.load(Options_classPrivateFieldGet(this, _Options_engine, "f").plugins.getPreset(preset));
2070 }
2071 }
2072 _Options_engine = new WeakMap, _Options_instances = new WeakSet, _Options_findDefaultTheme = function _Options_findDefaultTheme(mode) {
2073 var _a;
2074 return (_a = this.themes.find((theme => theme.default.value && theme.default.mode === mode))) !== null && _a !== void 0 ? _a : this.themes.find((theme => theme.default.value && theme.default.mode === "any"));
2075 };
2076 class ColorAnimation {
2077 constructor() {
2078 this.count = 0;
2079 this.enable = false;
2080 this.offset = 0;
2081 this.speed = 1;
2082 this.sync = true;
2083 }
2084 load(data) {
2085 if (!data) {
2086 return;
2087 }
2088 if (data.count !== undefined) {
2089 this.count = setRangeValue(data.count);
2090 }
2091 if (data.enable !== undefined) {
2092 this.enable = data.enable;
2093 }
2094 if (data.offset !== undefined) {
2095 this.offset = setRangeValue(data.offset);
2096 }
2097 if (data.speed !== undefined) {
2098 this.speed = setRangeValue(data.speed);
2099 }
2100 if (data.sync !== undefined) {
2101 this.sync = data.sync;
2102 }
2103 }
2104 }
2105 class HslAnimation {
2106 constructor() {
2107 this.h = new ColorAnimation;
2108 this.s = new ColorAnimation;
2109 this.l = new ColorAnimation;
2110 }
2111 load(data) {
2112 if (!data) {
2113 return;
2114 }
2115 this.h.load(data.h);
2116 this.s.load(data.s);
2117 this.l.load(data.l);
2118 }
2119 }
2120 class AnimatableColor extends OptionsColor {
2121 constructor() {
2122 super();
2123 this.animation = new HslAnimation;
2124 }
2125 static create(source, data) {
2126 const color = new AnimatableColor;
2127 color.load(source);
2128 if (data !== undefined) {
2129 if (typeof data === "string" || data instanceof Array) {
2130 color.load({
2131 value: data
2132 });
2133 } else {
2134 color.load(data);
2135 }
2136 }
2137 return color;
2138 }
2139 load(data) {
2140 super.load(data);
2141 if (!data) {
2142 return;
2143 }
2144 const colorAnimation = data.animation;
2145 if (colorAnimation !== undefined) {
2146 if (colorAnimation.enable !== undefined) {
2147 this.animation.h.load(colorAnimation);
2148 } else {
2149 this.animation.load(data.animation);
2150 }
2151 }
2152 }
2153 }
2154 class AnimatableGradient {
2155 constructor() {
2156 this.angle = new GradientAngle;
2157 this.colors = [];
2158 this.type = "random";
2159 }
2160 load(data) {
2161 if (!data) {
2162 return;
2163 }
2164 this.angle.load(data.angle);
2165 if (data.colors !== undefined) {
2166 this.colors = data.colors.map((s => {
2167 const tmp = new AnimatableGradientColor;
2168 tmp.load(s);
2169 return tmp;
2170 }));
2171 }
2172 if (data.type !== undefined) {
2173 this.type = data.type;
2174 }
2175 }
2176 }
2177 class GradientAngle {
2178 constructor() {
2179 this.value = 0;
2180 this.animation = new GradientAngleAnimation;
2181 this.direction = "clockwise";
2182 }
2183 load(data) {
2184 if (!data) {
2185 return;
2186 }
2187 this.animation.load(data.animation);
2188 if (data.value !== undefined) {
2189 this.value = data.value;
2190 }
2191 if (data.direction !== undefined) {
2192 this.direction = data.direction;
2193 }
2194 }
2195 }
2196 class GradientColorOpacity {
2197 constructor() {
2198 this.value = 0;
2199 this.animation = new GradientColorOpacityAnimation;
2200 }
2201 load(data) {
2202 if (!data) {
2203 return;
2204 }
2205 this.animation.load(data.animation);
2206 if (data.value !== undefined) {
2207 this.value = setRangeValue(data.value);
2208 }
2209 }
2210 }
2211 class AnimatableGradientColor {
2212 constructor() {
2213 this.stop = 0;
2214 this.value = new AnimatableColor;
2215 }
2216 load(data) {
2217 if (!data) {
2218 return;
2219 }
2220 if (data.stop !== undefined) {
2221 this.stop = data.stop;
2222 }
2223 this.value = AnimatableColor.create(this.value, data.value);
2224 if (data.opacity !== undefined) {
2225 this.opacity = new GradientColorOpacity;
2226 if (typeof data.opacity === "number") {
2227 this.opacity.value = data.opacity;
2228 } else {
2229 this.opacity.load(data.opacity);
2230 }
2231 }
2232 }
2233 }
2234 class GradientAngleAnimation {
2235 constructor() {
2236 this.count = 0;
2237 this.enable = false;
2238 this.speed = 0;
2239 this.sync = false;
2240 }
2241 load(data) {
2242 if (!data) {
2243 return;
2244 }
2245 if (data.count !== undefined) {
2246 this.count = setRangeValue(data.count);
2247 }
2248 if (data.enable !== undefined) {
2249 this.enable = data.enable;
2250 }
2251 if (data.speed !== undefined) {
2252 this.speed = setRangeValue(data.speed);
2253 }
2254 if (data.sync !== undefined) {
2255 this.sync = data.sync;
2256 }
2257 }
2258 }
2259 class GradientColorOpacityAnimation {
2260 constructor() {
2261 this.count = 0;
2262 this.enable = false;
2263 this.speed = 0;
2264 this.sync = false;
2265 this.startValue = "random";
2266 }
2267 load(data) {
2268 if (!data) {
2269 return;
2270 }
2271 if (data.count !== undefined) {
2272 this.count = setRangeValue(data.count);
2273 }
2274 if (data.enable !== undefined) {
2275 this.enable = data.enable;
2276 }
2277 if (data.speed !== undefined) {
2278 this.speed = setRangeValue(data.speed);
2279 }
2280 if (data.sync !== undefined) {
2281 this.sync = data.sync;
2282 }
2283 if (data.startValue !== undefined) {
2284 this.startValue = data.startValue;
2285 }
2286 }
2287 }
2288 class CollisionsOverlap {
2289 constructor() {
2290 this.enable = true;
2291 this.retries = 0;
2292 }
2293 load(data) {
2294 if (!data) {
2295 return;
2296 }
2297 if (data.enable !== undefined) {
2298 this.enable = data.enable;
2299 }
2300 if (data.retries !== undefined) {
2301 this.retries = data.retries;
2302 }
2303 }
2304 }
2305 class Random {
2306 constructor() {
2307 this.enable = false;
2308 this.minimumValue = 0;
2309 }
2310 load(data) {
2311 if (!data) {
2312 return;
2313 }
2314 if (data.enable !== undefined) {
2315 this.enable = data.enable;
2316 }
2317 if (data.minimumValue !== undefined) {
2318 this.minimumValue = data.minimumValue;
2319 }
2320 }
2321 }
2322 class ValueWithRandom {
2323 constructor() {
2324 this.random = new Random;
2325 this.value = 0;
2326 }
2327 load(data) {
2328 if (!data) {
2329 return;
2330 }
2331 if (typeof data.random === "boolean") {
2332 this.random.enable = data.random;
2333 } else {
2334 this.random.load(data.random);
2335 }
2336 if (data.value !== undefined) {
2337 this.value = setRangeValue(data.value, this.random.enable ? this.random.minimumValue : undefined);
2338 }
2339 }
2340 }
2341 class ParticlesBounceFactor extends ValueWithRandom {
2342 constructor() {
2343 super();
2344 this.random.minimumValue = .1;
2345 this.value = 1;
2346 }
2347 }
2348 class ParticlesBounce {
2349 constructor() {
2350 this.horizontal = new ParticlesBounceFactor;
2351 this.vertical = new ParticlesBounceFactor;
2352 }
2353 load(data) {
2354 if (!data) {
2355 return;
2356 }
2357 this.horizontal.load(data.horizontal);
2358 this.vertical.load(data.vertical);
2359 }
2360 }
2361 class Collisions {
2362 constructor() {
2363 this.bounce = new ParticlesBounce;
2364 this.enable = false;
2365 this.mode = "bounce";
2366 this.overlap = new CollisionsOverlap;
2367 }
2368 load(data) {
2369 if (!data) {
2370 return;
2371 }
2372 this.bounce.load(data.bounce);
2373 if (data.enable !== undefined) {
2374 this.enable = data.enable;
2375 }
2376 if (data.mode !== undefined) {
2377 this.mode = data.mode;
2378 }
2379 this.overlap.load(data.overlap);
2380 }
2381 }
2382 class SplitFactor extends ValueWithRandom {
2383 constructor() {
2384 super();
2385 this.value = 3;
2386 }
2387 }
2388 class SplitRate extends ValueWithRandom {
2389 constructor() {
2390 super();
2391 this.value = {
2392 min: 4,
2393 max: 9
2394 };
2395 }
2396 }
2397 class Split {
2398 constructor() {
2399 this.count = 1;
2400 this.factor = new SplitFactor;
2401 this.rate = new SplitRate;
2402 this.sizeOffset = true;
2403 }
2404 load(data) {
2405 if (!data) {
2406 return;
2407 }
2408 if (data.count !== undefined) {
2409 this.count = data.count;
2410 }
2411 this.factor.load(data.factor);
2412 this.rate.load(data.rate);
2413 if (data.particles !== undefined) {
2414 this.particles = deepExtend({}, data.particles);
2415 }
2416 if (data.sizeOffset !== undefined) {
2417 this.sizeOffset = data.sizeOffset;
2418 }
2419 }
2420 }
2421 class Destroy {
2422 constructor() {
2423 this.mode = "none";
2424 this.split = new Split;
2425 }
2426 load(data) {
2427 if (!data) {
2428 return;
2429 }
2430 if (data.mode !== undefined) {
2431 this.mode = data.mode;
2432 }
2433 this.split.load(data.split);
2434 }
2435 }
2436 class LifeDelay extends ValueWithRandom {
2437 constructor() {
2438 super();
2439 this.sync = false;
2440 }
2441 load(data) {
2442 if (!data) {
2443 return;
2444 }
2445 super.load(data);
2446 if (data.sync !== undefined) {
2447 this.sync = data.sync;
2448 }
2449 }
2450 }
2451 class LifeDuration extends ValueWithRandom {
2452 constructor() {
2453 super();
2454 this.random.minimumValue = 1e-4;
2455 this.sync = false;
2456 }
2457 load(data) {
2458 if (!data) {
2459 return;
2460 }
2461 super.load(data);
2462 if (data.sync !== undefined) {
2463 this.sync = data.sync;
2464 }
2465 }
2466 }
2467 class Life {
2468 constructor() {
2469 this.count = 0;
2470 this.delay = new LifeDelay;
2471 this.duration = new LifeDuration;
2472 }
2473 load(data) {
2474 if (!data) {
2475 return;
2476 }
2477 if (data.count !== undefined) {
2478 this.count = data.count;
2479 }
2480 this.delay.load(data.delay);
2481 this.duration.load(data.duration);
2482 }
2483 }
2484 class LinksShadow {
2485 constructor() {
2486 this.blur = 5;
2487 this.color = new OptionsColor;
2488 this.color.value = "#000";
2489 this.enable = false;
2490 }
2491 load(data) {
2492 if (!data) {
2493 return;
2494 }
2495 if (data.blur !== undefined) {
2496 this.blur = data.blur;
2497 }
2498 this.color = OptionsColor.create(this.color, data.color);
2499 if (data.enable !== undefined) {
2500 this.enable = data.enable;
2501 }
2502 }
2503 }
2504 class LinksTriangle {
2505 constructor() {
2506 this.enable = false;
2507 this.frequency = 1;
2508 }
2509 load(data) {
2510 if (!data) {
2511 return;
2512 }
2513 if (data.color !== undefined) {
2514 this.color = OptionsColor.create(this.color, data.color);
2515 }
2516 if (data.enable !== undefined) {
2517 this.enable = data.enable;
2518 }
2519 if (data.frequency !== undefined) {
2520 this.frequency = data.frequency;
2521 }
2522 if (data.opacity !== undefined) {
2523 this.opacity = data.opacity;
2524 }
2525 }
2526 }
2527 class Links {
2528 constructor() {
2529 this.blink = false;
2530 this.color = new OptionsColor;
2531 this.color.value = "#fff";
2532 this.consent = false;
2533 this.distance = 100;
2534 this.enable = false;
2535 this.frequency = 1;
2536 this.opacity = 1;
2537 this.shadow = new LinksShadow;
2538 this.triangles = new LinksTriangle;
2539 this.width = 1;
2540 this.warp = false;
2541 }
2542 load(data) {
2543 if (!data) {
2544 return;
2545 }
2546 if (data.id !== undefined) {
2547 this.id = data.id;
2548 }
2549 if (data.blink !== undefined) {
2550 this.blink = data.blink;
2551 }
2552 this.color = OptionsColor.create(this.color, data.color);
2553 if (data.consent !== undefined) {
2554 this.consent = data.consent;
2555 }
2556 if (data.distance !== undefined) {
2557 this.distance = data.distance;
2558 }
2559 if (data.enable !== undefined) {
2560 this.enable = data.enable;
2561 }
2562 if (data.frequency !== undefined) {
2563 this.frequency = data.frequency;
2564 }
2565 if (data.opacity !== undefined) {
2566 this.opacity = data.opacity;
2567 }
2568 this.shadow.load(data.shadow);
2569 this.triangles.load(data.triangles);
2570 if (data.width !== undefined) {
2571 this.width = data.width;
2572 }
2573 if (data.warp !== undefined) {
2574 this.warp = data.warp;
2575 }
2576 }
2577 }
2578 class MoveAngle {
2579 constructor() {
2580 this.offset = 0;
2581 this.value = 90;
2582 }
2583 load(data) {
2584 if (!data) {
2585 return;
2586 }
2587 if (data.offset !== undefined) {
2588 this.offset = setRangeValue(data.offset);
2589 }
2590 if (data.value !== undefined) {
2591 this.value = setRangeValue(data.value);
2592 }
2593 }
2594 }
2595 class MoveAttract {
2596 constructor() {
2597 this.distance = 200;
2598 this.enable = false;
2599 this.rotate = {
2600 x: 3e3,
2601 y: 3e3
2602 };
2603 }
2604 get rotateX() {
2605 return this.rotate.x;
2606 }
2607 set rotateX(value) {
2608 this.rotate.x = value;
2609 }
2610 get rotateY() {
2611 return this.rotate.y;
2612 }
2613 set rotateY(value) {
2614 this.rotate.y = value;
2615 }
2616 load(data) {
2617 var _a, _b, _c, _d;
2618 if (!data) {
2619 return;
2620 }
2621 if (data.distance !== undefined) {
2622 this.distance = setRangeValue(data.distance);
2623 }
2624 if (data.enable !== undefined) {
2625 this.enable = data.enable;
2626 }
2627 const rotateX = (_b = (_a = data.rotate) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : data.rotateX;
2628 if (rotateX !== undefined) {
2629 this.rotate.x = rotateX;
2630 }
2631 const rotateY = (_d = (_c = data.rotate) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : data.rotateY;
2632 if (rotateY !== undefined) {
2633 this.rotate.y = rotateY;
2634 }
2635 }
2636 }
2637 class MoveGravity {
2638 constructor() {
2639 this.acceleration = 9.81;
2640 this.enable = false;
2641 this.inverse = false;
2642 this.maxSpeed = 50;
2643 }
2644 load(data) {
2645 if (!data) {
2646 return;
2647 }
2648 if (data.acceleration !== undefined) {
2649 this.acceleration = setRangeValue(data.acceleration);
2650 }
2651 if (data.enable !== undefined) {
2652 this.enable = data.enable;
2653 }
2654 if (data.inverse !== undefined) {
2655 this.inverse = data.inverse;
2656 }
2657 if (data.maxSpeed !== undefined) {
2658 this.maxSpeed = setRangeValue(data.maxSpeed);
2659 }
2660 }
2661 }
2662 class MovePathDelay extends ValueWithRandom {
2663 constructor() {
2664 super();
2665 }
2666 }
2667 class MovePath {
2668 constructor() {
2669 this.clamp = true;
2670 this.delay = new MovePathDelay;
2671 this.enable = false;
2672 this.options = {};
2673 }
2674 load(data) {
2675 if (!data) {
2676 return;
2677 }
2678 if (data.clamp !== undefined) {
2679 this.clamp = data.clamp;
2680 }
2681 this.delay.load(data.delay);
2682 if (data.enable !== undefined) {
2683 this.enable = data.enable;
2684 }
2685 this.generator = data.generator;
2686 if (data.options) {
2687 this.options = deepExtend(this.options, data.options);
2688 }
2689 }
2690 }
2691 class MoveTrail {
2692 constructor() {
2693 this.enable = false;
2694 this.length = 10;
2695 this.fillColor = new OptionsColor;
2696 this.fillColor.value = "#000000";
2697 }
2698 load(data) {
2699 if (!data) {
2700 return;
2701 }
2702 if (data.enable !== undefined) {
2703 this.enable = data.enable;
2704 }
2705 this.fillColor = OptionsColor.create(this.fillColor, data.fillColor);
2706 if (data.length !== undefined) {
2707 this.length = data.length;
2708 }
2709 }
2710 }
2711 class OutModes {
2712 constructor() {
2713 this.default = "out";
2714 }
2715 load(data) {
2716 var _a, _b, _c, _d;
2717 if (!data) {
2718 return;
2719 }
2720 if (data.default !== undefined) {
2721 this.default = data.default;
2722 }
2723 this.bottom = (_a = data.bottom) !== null && _a !== void 0 ? _a : data.default;
2724 this.left = (_b = data.left) !== null && _b !== void 0 ? _b : data.default;
2725 this.right = (_c = data.right) !== null && _c !== void 0 ? _c : data.default;
2726 this.top = (_d = data.top) !== null && _d !== void 0 ? _d : data.default;
2727 }
2728 }
2729 class Spin {
2730 constructor() {
2731 this.acceleration = 0;
2732 this.enable = false;
2733 }
2734 load(data) {
2735 if (!data) {
2736 return;
2737 }
2738 if (data.acceleration !== undefined) {
2739 this.acceleration = setRangeValue(data.acceleration);
2740 }
2741 if (data.enable !== undefined) {
2742 this.enable = data.enable;
2743 }
2744 this.position = data.position ? deepExtend({}, data.position) : undefined;
2745 }
2746 }
2747 class Move {
2748 constructor() {
2749 this.angle = new MoveAngle;
2750 this.attract = new MoveAttract;
2751 this.center = {
2752 x: 50,
2753 y: 50,
2754 radius: 0
2755 };
2756 this.decay = 0;
2757 this.distance = {};
2758 this.direction = "none";
2759 this.drift = 0;
2760 this.enable = false;
2761 this.gravity = new MoveGravity;
2762 this.path = new MovePath;
2763 this.outModes = new OutModes;
2764 this.random = false;
2765 this.size = false;
2766 this.speed = 2;
2767 this.spin = new Spin;
2768 this.straight = false;
2769 this.trail = new MoveTrail;
2770 this.vibrate = false;
2771 this.warp = false;
2772 }
2773 get collisions() {
2774 return false;
2775 }
2776 set collisions(value) {}
2777 get bounce() {
2778 return this.collisions;
2779 }
2780 set bounce(value) {
2781 this.collisions = value;
2782 }
2783 get out_mode() {
2784 return this.outMode;
2785 }
2786 set out_mode(value) {
2787 this.outMode = value;
2788 }
2789 get outMode() {
2790 return this.outModes.default;
2791 }
2792 set outMode(value) {
2793 this.outModes.default = value;
2794 }
2795 get noise() {
2796 return this.path;
2797 }
2798 set noise(value) {
2799 this.path = value;
2800 }
2801 load(data) {
2802 var _a, _b, _c;
2803 if (!data) {
2804 return;
2805 }
2806 if (data.angle !== undefined) {
2807 if (typeof data.angle === "number") {
2808 this.angle.value = data.angle;
2809 } else {
2810 this.angle.load(data.angle);
2811 }
2812 }
2813 this.attract.load(data.attract);
2814 this.center = deepExtend(this.center, data.center);
2815 if (data.decay !== undefined) {
2816 this.decay = data.decay;
2817 }
2818 if (data.direction !== undefined) {
2819 this.direction = data.direction;
2820 }
2821 if (data.distance !== undefined) {
2822 this.distance = typeof data.distance === "number" ? {
2823 horizontal: data.distance,
2824 vertical: data.distance
2825 } : deepExtend({}, data.distance);
2826 }
2827 if (data.drift !== undefined) {
2828 this.drift = setRangeValue(data.drift);
2829 }
2830 if (data.enable !== undefined) {
2831 this.enable = data.enable;
2832 }
2833 this.gravity.load(data.gravity);
2834 const outMode = (_a = data.outMode) !== null && _a !== void 0 ? _a : data.out_mode;
2835 if (data.outModes !== undefined || outMode !== undefined) {
2836 if (typeof data.outModes === "string" || data.outModes === undefined && outMode !== undefined) {
2837 this.outModes.load({
2838 default: (_b = data.outModes) !== null && _b !== void 0 ? _b : outMode
2839 });
2840 } else {
2841 this.outModes.load(data.outModes);
2842 }
2843 }
2844 this.path.load((_c = data.path) !== null && _c !== void 0 ? _c : data.noise);
2845 if (data.random !== undefined) {
2846 this.random = data.random;
2847 }
2848 if (data.size !== undefined) {
2849 this.size = data.size;
2850 }
2851 if (data.speed !== undefined) {
2852 this.speed = setRangeValue(data.speed);
2853 }
2854 this.spin.load(data.spin);
2855 if (data.straight !== undefined) {
2856 this.straight = data.straight;
2857 }
2858 this.trail.load(data.trail);
2859 if (data.vibrate !== undefined) {
2860 this.vibrate = data.vibrate;
2861 }
2862 if (data.warp !== undefined) {
2863 this.warp = data.warp;
2864 }
2865 }
2866 }
2867 class AnimationOptions {
2868 constructor() {
2869 this.count = 0;
2870 this.enable = false;
2871 this.speed = 1;
2872 this.sync = false;
2873 }
2874 load(data) {
2875 if (!data) {
2876 return;
2877 }
2878 if (data.count !== undefined) {
2879 this.count = setRangeValue(data.count);
2880 }
2881 if (data.enable !== undefined) {
2882 this.enable = data.enable;
2883 }
2884 if (data.speed !== undefined) {
2885 this.speed = setRangeValue(data.speed);
2886 }
2887 if (data.sync !== undefined) {
2888 this.sync = data.sync;
2889 }
2890 }
2891 }
2892 class OpacityAnimation extends AnimationOptions {
2893 constructor() {
2894 super();
2895 this.destroy = "none";
2896 this.enable = false;
2897 this.speed = 2;
2898 this.startValue = "random";
2899 this.sync = false;
2900 }
2901 get opacity_min() {
2902 return this.minimumValue;
2903 }
2904 set opacity_min(value) {
2905 this.minimumValue = value;
2906 }
2907 load(data) {
2908 var _a;
2909 if (!data) {
2910 return;
2911 }
2912 super.load(data);
2913 if (data.destroy !== undefined) {
2914 this.destroy = data.destroy;
2915 }
2916 if (data.enable !== undefined) {
2917 this.enable = data.enable;
2918 }
2919 this.minimumValue = (_a = data.minimumValue) !== null && _a !== void 0 ? _a : data.opacity_min;
2920 if (data.speed !== undefined) {
2921 this.speed = data.speed;
2922 }
2923 if (data.startValue !== undefined) {
2924 this.startValue = data.startValue;
2925 }
2926 if (data.sync !== undefined) {
2927 this.sync = data.sync;
2928 }
2929 }
2930 }
2931 class Opacity extends ValueWithRandom {
2932 constructor() {
2933 super();
2934 this.animation = new OpacityAnimation;
2935 this.random.minimumValue = .1;
2936 this.value = 1;
2937 }
2938 get anim() {
2939 return this.animation;
2940 }
2941 set anim(value) {
2942 this.animation = value;
2943 }
2944 load(data) {
2945 var _a;
2946 if (!data) {
2947 return;
2948 }
2949 super.load(data);
2950 const animation = (_a = data.animation) !== null && _a !== void 0 ? _a : data.anim;
2951 if (animation !== undefined) {
2952 this.animation.load(animation);
2953 this.value = setRangeValue(this.value, this.animation.enable ? this.animation.minimumValue : undefined);
2954 }
2955 }
2956 }
2957 class OrbitRotation extends ValueWithRandom {
2958 constructor() {
2959 super();
2960 this.value = 45;
2961 this.random.enable = false;
2962 this.random.minimumValue = 0;
2963 }
2964 load(data) {
2965 if (data === undefined) {
2966 return;
2967 }
2968 super.load(data);
2969 }
2970 }
2971 class Orbit {
2972 constructor() {
2973 this.animation = new AnimationOptions;
2974 this.enable = false;
2975 this.opacity = 1;
2976 this.rotation = new OrbitRotation;
2977 this.width = 1;
2978 }
2979 load(data) {
2980 if (!data) {
2981 return;
2982 }
2983 this.animation.load(data.animation);
2984 this.rotation.load(data.rotation);
2985 if (data.enable !== undefined) {
2986 this.enable = data.enable;
2987 }
2988 if (data.opacity !== undefined) {
2989 this.opacity = setRangeValue(data.opacity);
2990 }
2991 if (data.width !== undefined) {
2992 this.width = setRangeValue(data.width);
2993 }
2994 if (data.radius !== undefined) {
2995 this.radius = setRangeValue(data.radius);
2996 }
2997 if (data.color !== undefined) {
2998 this.color = OptionsColor.create(this.color, data.color);
2999 }
3000 }
3001 }
3002 class ParticlesDensity {
3003 constructor() {
3004 this.enable = false;
3005 this.area = 800;
3006 this.factor = 1e3;
3007 }
3008 get value_area() {
3009 return this.area;
3010 }
3011 set value_area(value) {
3012 this.area = value;
3013 }
3014 load(data) {
3015 var _a;
3016 if (!data) {
3017 return;
3018 }
3019 if (data.enable !== undefined) {
3020 this.enable = data.enable;
3021 }
3022 const area = (_a = data.area) !== null && _a !== void 0 ? _a : data.value_area;
3023 if (area !== undefined) {
3024 this.area = area;
3025 }
3026 if (data.factor !== undefined) {
3027 this.factor = data.factor;
3028 }
3029 }
3030 }
3031 class ParticlesNumber {
3032 constructor() {
3033 this.density = new ParticlesDensity;
3034 this.limit = 0;
3035 this.value = 100;
3036 }
3037 get max() {
3038 return this.limit;
3039 }
3040 set max(value) {
3041 this.limit = value;
3042 }
3043 load(data) {
3044 var _a;
3045 if (!data) {
3046 return;
3047 }
3048 this.density.load(data.density);
3049 const limit = (_a = data.limit) !== null && _a !== void 0 ? _a : data.max;
3050 if (limit !== undefined) {
3051 this.limit = limit;
3052 }
3053 if (data.value !== undefined) {
3054 this.value = data.value;
3055 }
3056 }
3057 }
3058 class ParticlesRepulse extends ValueWithRandom {
3059 constructor() {
3060 super();
3061 this.enabled = false;
3062 this.distance = 1;
3063 this.duration = 1;
3064 this.factor = 1;
3065 this.speed = 1;
3066 }
3067 load(data) {
3068 super.load(data);
3069 if (!data) {
3070 return;
3071 }
3072 if (data.enabled !== undefined) {
3073 this.enabled = data.enabled;
3074 }
3075 if (data.distance !== undefined) {
3076 this.distance = setRangeValue(data.distance);
3077 }
3078 if (data.duration !== undefined) {
3079 this.duration = setRangeValue(data.duration);
3080 }
3081 if (data.factor !== undefined) {
3082 this.factor = setRangeValue(data.factor);
3083 }
3084 if (data.speed !== undefined) {
3085 this.speed = setRangeValue(data.speed);
3086 }
3087 }
3088 }
3089 class RollLight {
3090 constructor() {
3091 this.enable = false;
3092 this.value = 0;
3093 }
3094 load(data) {
3095 if (!data) {
3096 return;
3097 }
3098 if (data.enable !== undefined) {
3099 this.enable = data.enable;
3100 }
3101 if (data.value !== undefined) {
3102 this.value = setRangeValue(data.value);
3103 }
3104 }
3105 }
3106 class Roll {
3107 constructor() {
3108 this.darken = new RollLight;
3109 this.enable = false;
3110 this.enlighten = new RollLight;
3111 this.mode = "vertical";
3112 this.speed = 25;
3113 }
3114 load(data) {
3115 if (!data) {
3116 return;
3117 }
3118 if (data.backColor !== undefined) {
3119 this.backColor = OptionsColor.create(this.backColor, data.backColor);
3120 }
3121 this.darken.load(data.darken);
3122 if (data.enable !== undefined) {
3123 this.enable = data.enable;
3124 }
3125 this.enlighten.load(data.enlighten);
3126 if (data.mode !== undefined) {
3127 this.mode = data.mode;
3128 }
3129 if (data.speed !== undefined) {
3130 this.speed = setRangeValue(data.speed);
3131 }
3132 }
3133 }
3134 class RotateAnimation {
3135 constructor() {
3136 this.enable = false;
3137 this.speed = 0;
3138 this.sync = false;
3139 }
3140 load(data) {
3141 if (!data) {
3142 return;
3143 }
3144 if (data.enable !== undefined) {
3145 this.enable = data.enable;
3146 }
3147 if (data.speed !== undefined) {
3148 this.speed = setRangeValue(data.speed);
3149 }
3150 if (data.sync !== undefined) {
3151 this.sync = data.sync;
3152 }
3153 }
3154 }
3155 class Rotate extends ValueWithRandom {
3156 constructor() {
3157 super();
3158 this.animation = new RotateAnimation;
3159 this.direction = "clockwise";
3160 this.path = false;
3161 this.value = 0;
3162 }
3163 load(data) {
3164 if (!data) {
3165 return;
3166 }
3167 super.load(data);
3168 if (data.direction !== undefined) {
3169 this.direction = data.direction;
3170 }
3171 this.animation.load(data.animation);
3172 if (data.path !== undefined) {
3173 this.path = data.path;
3174 }
3175 }
3176 }
3177 class Shadow {
3178 constructor() {
3179 this.blur = 0;
3180 this.color = new OptionsColor;
3181 this.enable = false;
3182 this.offset = {
3183 x: 0,
3184 y: 0
3185 };
3186 this.color.value = "#000";
3187 }
3188 load(data) {
3189 if (!data) {
3190 return;
3191 }
3192 if (data.blur !== undefined) {
3193 this.blur = data.blur;
3194 }
3195 this.color = OptionsColor.create(this.color, data.color);
3196 if (data.enable !== undefined) {
3197 this.enable = data.enable;
3198 }
3199 if (data.offset === undefined) {
3200 return;
3201 }
3202 if (data.offset.x !== undefined) {
3203 this.offset.x = data.offset.x;
3204 }
3205 if (data.offset.y !== undefined) {
3206 this.offset.y = data.offset.y;
3207 }
3208 }
3209 }
3210 class Shape {
3211 constructor() {
3212 this.options = {};
3213 this.type = "circle";
3214 }
3215 get image() {
3216 var _a;
3217 return (_a = this.options["image"]) !== null && _a !== void 0 ? _a : this.options["images"];
3218 }
3219 set image(value) {
3220 this.options["image"] = value;
3221 this.options["images"] = value;
3222 }
3223 get custom() {
3224 return this.options;
3225 }
3226 set custom(value) {
3227 this.options = value;
3228 }
3229 get images() {
3230 return this.image;
3231 }
3232 set images(value) {
3233 this.image = value;
3234 }
3235 get stroke() {
3236 return [];
3237 }
3238 set stroke(_value) {}
3239 get character() {
3240 var _a;
3241 return (_a = this.options["character"]) !== null && _a !== void 0 ? _a : this.options["char"];
3242 }
3243 set character(value) {
3244 this.options["character"] = value;
3245 this.options["char"] = value;
3246 }
3247 get polygon() {
3248 var _a;
3249 return (_a = this.options["polygon"]) !== null && _a !== void 0 ? _a : this.options["star"];
3250 }
3251 set polygon(value) {
3252 this.options["polygon"] = value;
3253 this.options["star"] = value;
3254 }
3255 load(data) {
3256 var _a, _b, _c;
3257 if (!data) {
3258 return;
3259 }
3260 const options = (_a = data.options) !== null && _a !== void 0 ? _a : data.custom;
3261 if (options !== undefined) {
3262 for (const shape in options) {
3263 const item = options[shape];
3264 if (item) {
3265 this.options[shape] = deepExtend((_b = this.options[shape]) !== null && _b !== void 0 ? _b : {}, item);
3266 }
3267 }
3268 }
3269 this.loadShape(data.character, "character", "char", true);
3270 this.loadShape(data.polygon, "polygon", "star", false);
3271 this.loadShape((_c = data.image) !== null && _c !== void 0 ? _c : data.images, "image", "images", true);
3272 if (data.type !== undefined) {
3273 this.type = data.type;
3274 }
3275 }
3276 loadShape(item, mainKey, altKey, altOverride) {
3277 var _a, _b, _c, _d;
3278 if (item === undefined) {
3279 return;
3280 }
3281 if (item instanceof Array) {
3282 if (!(this.options[mainKey] instanceof Array)) {
3283 this.options[mainKey] = [];
3284 if (!this.options[altKey] || altOverride) {
3285 this.options[altKey] = [];
3286 }
3287 }
3288 this.options[mainKey] = deepExtend((_a = this.options[mainKey]) !== null && _a !== void 0 ? _a : [], item);
3289 if (!this.options[altKey] || altOverride) {
3290 this.options[altKey] = deepExtend((_b = this.options[altKey]) !== null && _b !== void 0 ? _b : [], item);
3291 }
3292 } else {
3293 if (this.options[mainKey] instanceof Array) {
3294 this.options[mainKey] = {};
3295 if (!this.options[altKey] || altOverride) {
3296 this.options[altKey] = {};
3297 }
3298 }
3299 this.options[mainKey] = deepExtend((_c = this.options[mainKey]) !== null && _c !== void 0 ? _c : {}, item);
3300 if (!this.options[altKey] || altOverride) {
3301 this.options[altKey] = deepExtend((_d = this.options[altKey]) !== null && _d !== void 0 ? _d : {}, item);
3302 }
3303 }
3304 }
3305 }
3306 class SizeAnimation extends AnimationOptions {
3307 constructor() {
3308 super();
3309 this.destroy = "none";
3310 this.enable = false;
3311 this.speed = 5;
3312 this.startValue = "random";
3313 this.sync = false;
3314 }
3315 get size_min() {
3316 return this.minimumValue;
3317 }
3318 set size_min(value) {
3319 this.minimumValue = value;
3320 }
3321 load(data) {
3322 var _a;
3323 super.load(data);
3324 if (!data) {
3325 return;
3326 }
3327 if (data.destroy !== undefined) {
3328 this.destroy = data.destroy;
3329 }
3330 if (data.enable !== undefined) {
3331 this.enable = data.enable;
3332 }
3333 this.minimumValue = (_a = data.minimumValue) !== null && _a !== void 0 ? _a : data.size_min;
3334 if (data.speed !== undefined) {
3335 this.speed = data.speed;
3336 }
3337 if (data.startValue !== undefined) {
3338 this.startValue = data.startValue;
3339 }
3340 if (data.sync !== undefined) {
3341 this.sync = data.sync;
3342 }
3343 }
3344 }
3345 class Size extends ValueWithRandom {
3346 constructor() {
3347 super();
3348 this.animation = new SizeAnimation;
3349 this.random.minimumValue = 1;
3350 this.value = 3;
3351 }
3352 get anim() {
3353 return this.animation;
3354 }
3355 set anim(value) {
3356 this.animation = value;
3357 }
3358 load(data) {
3359 var _a;
3360 super.load(data);
3361 if (!data) {
3362 return;
3363 }
3364 const animation = (_a = data.animation) !== null && _a !== void 0 ? _a : data.anim;
3365 if (animation !== undefined) {
3366 this.animation.load(animation);
3367 this.value = setRangeValue(this.value, this.animation.enable ? this.animation.minimumValue : undefined);
3368 }
3369 }
3370 }
3371 class Stroke {
3372 constructor() {
3373 this.width = 0;
3374 }
3375 load(data) {
3376 if (!data) {
3377 return;
3378 }
3379 if (data.color !== undefined) {
3380 this.color = AnimatableColor.create(this.color, data.color);
3381 }
3382 if (data.width !== undefined) {
3383 this.width = data.width;
3384 }
3385 if (data.opacity !== undefined) {
3386 this.opacity = data.opacity;
3387 }
3388 }
3389 }
3390 class TiltAnimation {
3391 constructor() {
3392 this.enable = false;
3393 this.speed = 0;
3394 this.sync = false;
3395 }
3396 load(data) {
3397 if (!data) {
3398 return;
3399 }
3400 if (data.enable !== undefined) {
3401 this.enable = data.enable;
3402 }
3403 if (data.speed !== undefined) {
3404 this.speed = setRangeValue(data.speed);
3405 }
3406 if (data.sync !== undefined) {
3407 this.sync = data.sync;
3408 }
3409 }
3410 }
3411 class Tilt extends ValueWithRandom {
3412 constructor() {
3413 super();
3414 this.animation = new TiltAnimation;
3415 this.direction = "clockwise";
3416 this.enable = false;
3417 this.value = 0;
3418 }
3419 load(data) {
3420 super.load(data);
3421 if (!data) {
3422 return;
3423 }
3424 this.animation.load(data.animation);
3425 if (data.direction !== undefined) {
3426 this.direction = data.direction;
3427 }
3428 if (data.enable !== undefined) {
3429 this.enable = data.enable;
3430 }
3431 }
3432 }
3433 class TwinkleValues {
3434 constructor() {
3435 this.enable = false;
3436 this.frequency = .05;
3437 this.opacity = 1;
3438 }
3439 load(data) {
3440 if (!data) {
3441 return;
3442 }
3443 if (data.color !== undefined) {
3444 this.color = OptionsColor.create(this.color, data.color);
3445 }
3446 if (data.enable !== undefined) {
3447 this.enable = data.enable;
3448 }
3449 if (data.frequency !== undefined) {
3450 this.frequency = data.frequency;
3451 }
3452 if (data.opacity !== undefined) {
3453 this.opacity = setRangeValue(data.opacity);
3454 }
3455 }
3456 }
3457 class Twinkle {
3458 constructor() {
3459 this.lines = new TwinkleValues;
3460 this.particles = new TwinkleValues;
3461 }
3462 load(data) {
3463 if (!data) {
3464 return;
3465 }
3466 this.lines.load(data.lines);
3467 this.particles.load(data.particles);
3468 }
3469 }
3470 class Wobble {
3471 constructor() {
3472 this.distance = 5;
3473 this.enable = false;
3474 this.speed = 50;
3475 }
3476 load(data) {
3477 if (!data) {
3478 return;
3479 }
3480 if (data.distance !== undefined) {
3481 this.distance = setRangeValue(data.distance);
3482 }
3483 if (data.enable !== undefined) {
3484 this.enable = data.enable;
3485 }
3486 if (data.speed !== undefined) {
3487 this.speed = setRangeValue(data.speed);
3488 }
3489 }
3490 }
3491 class ZIndex extends ValueWithRandom {
3492 constructor() {
3493 super();
3494 this.opacityRate = 1;
3495 this.sizeRate = 1;
3496 this.velocityRate = 1;
3497 }
3498 load(data) {
3499 super.load(data);
3500 if (!data) {
3501 return;
3502 }
3503 if (data.opacityRate !== undefined) {
3504 this.opacityRate = data.opacityRate;
3505 }
3506 if (data.sizeRate !== undefined) {
3507 this.sizeRate = data.sizeRate;
3508 }
3509 if (data.velocityRate !== undefined) {
3510 this.velocityRate = data.velocityRate;
3511 }
3512 }
3513 }
3514 class ParticlesOptions {
3515 constructor() {
3516 this.bounce = new ParticlesBounce;
3517 this.collisions = new Collisions;
3518 this.color = new AnimatableColor;
3519 this.color.value = "#fff";
3520 this.destroy = new Destroy;
3521 this.gradient = [];
3522 this.groups = {};
3523 this.life = new Life;
3524 this.links = new Links;
3525 this.move = new Move;
3526 this.number = new ParticlesNumber;
3527 this.opacity = new Opacity;
3528 this.orbit = new Orbit;
3529 this.reduceDuplicates = false;
3530 this.repulse = new ParticlesRepulse;
3531 this.roll = new Roll;
3532 this.rotate = new Rotate;
3533 this.shadow = new Shadow;
3534 this.shape = new Shape;
3535 this.size = new Size;
3536 this.stroke = new Stroke;
3537 this.tilt = new Tilt;
3538 this.twinkle = new Twinkle;
3539 this.wobble = new Wobble;
3540 this.zIndex = new ZIndex;
3541 }
3542 get line_linked() {
3543 return this.links;
3544 }
3545 set line_linked(value) {
3546 this.links = value;
3547 }
3548 get lineLinked() {
3549 return this.links;
3550 }
3551 set lineLinked(value) {
3552 this.links = value;
3553 }
3554 load(data) {
3555 var _a, _b, _c, _d, _e, _f, _g, _h;
3556 if (!data) {
3557 return;
3558 }
3559 this.bounce.load(data.bounce);
3560 this.color.load(AnimatableColor.create(this.color, data.color));
3561 this.destroy.load(data.destroy);
3562 this.life.load(data.life);
3563 const links = (_b = (_a = data.links) !== null && _a !== void 0 ? _a : data.lineLinked) !== null && _b !== void 0 ? _b : data.line_linked;
3564 if (links !== undefined) {
3565 this.links.load(links);
3566 }
3567 if (data.groups !== undefined) {
3568 for (const group in data.groups) {
3569 const item = data.groups[group];
3570 if (item !== undefined) {
3571 this.groups[group] = deepExtend((_c = this.groups[group]) !== null && _c !== void 0 ? _c : {}, item);
3572 }
3573 }
3574 }
3575 this.move.load(data.move);
3576 this.number.load(data.number);
3577 this.opacity.load(data.opacity);
3578 this.orbit.load(data.orbit);
3579 if (data.reduceDuplicates !== undefined) {
3580 this.reduceDuplicates = data.reduceDuplicates;
3581 }
3582 this.repulse.load(data.repulse);
3583 this.roll.load(data.roll);
3584 this.rotate.load(data.rotate);
3585 this.shape.load(data.shape);
3586 this.size.load(data.size);
3587 this.shadow.load(data.shadow);
3588 this.tilt.load(data.tilt);
3589 this.twinkle.load(data.twinkle);
3590 this.wobble.load(data.wobble);
3591 this.zIndex.load(data.zIndex);
3592 const collisions = (_e = (_d = data.move) === null || _d === void 0 ? void 0 : _d.collisions) !== null && _e !== void 0 ? _e : (_f = data.move) === null || _f === void 0 ? void 0 : _f.bounce;
3593 if (collisions !== undefined) {
3594 this.collisions.enable = collisions;
3595 }
3596 this.collisions.load(data.collisions);
3597 const strokeToLoad = (_g = data.stroke) !== null && _g !== void 0 ? _g : (_h = data.shape) === null || _h === void 0 ? void 0 : _h.stroke;
3598 if (strokeToLoad) {
3599 if (strokeToLoad instanceof Array) {
3600 this.stroke = strokeToLoad.map((s => {
3601 const tmp = new Stroke;
3602 tmp.load(s);
3603 return tmp;
3604 }));
3605 } else {
3606 if (this.stroke instanceof Array) {
3607 this.stroke = new Stroke;
3608 }
3609 this.stroke.load(strokeToLoad);
3610 }
3611 }
3612 const gradientToLoad = data.gradient;
3613 if (gradientToLoad) {
3614 if (gradientToLoad instanceof Array) {
3615 this.gradient = gradientToLoad.map((s => {
3616 const tmp = new AnimatableGradient;
3617 tmp.load(s);
3618 return tmp;
3619 }));
3620 } else {
3621 if (this.gradient instanceof Array) {
3622 this.gradient = new AnimatableGradient;
3623 }
3624 this.gradient.load(gradientToLoad);
3625 }
3626 }
3627 }
3628 }
3629 function rectSideBounce(pSide, pOtherSide, rectSide, rectOtherSide, velocity, factor) {
3630 const res = {
3631 bounced: false
3632 };
3633 if (pOtherSide.min < rectOtherSide.min || pOtherSide.min > rectOtherSide.max || pOtherSide.max < rectOtherSide.min || pOtherSide.max > rectOtherSide.max) {
3634 return res;
3635 }
3636 if (pSide.max >= rectSide.min && pSide.max <= (rectSide.max + rectSide.min) / 2 && velocity > 0 || pSide.min <= rectSide.max && pSide.min > (rectSide.max + rectSide.min) / 2 && velocity < 0) {
3637 res.velocity = velocity * -factor;
3638 res.bounced = true;
3639 }
3640 return res;
3641 }
3642 function checkSelector(element, selectors) {
3643 if (!(selectors instanceof Array)) {
3644 return element.matches(selectors);
3645 }
3646 for (const selector of selectors) {
3647 if (element.matches(selector)) {
3648 return true;
3649 }
3650 }
3651 return false;
3652 }
3653 function isSsr() {
3654 return typeof window === "undefined" || !window || typeof window.document === "undefined" || !window.document;
3655 }
3656 function animate() {
3657 return isSsr() ? callback => setTimeout(callback) : callback => (window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || window.setTimeout)(callback);
3658 }
3659 function cancelAnimation() {
3660 return isSsr() ? handle => clearTimeout(handle) : handle => (window.cancelAnimationFrame || window.webkitCancelRequestAnimationFrame || window.mozCancelRequestAnimationFrame || window.oCancelRequestAnimationFrame || window.msCancelRequestAnimationFrame || window.clearTimeout)(handle);
3661 }
3662 function isInArray(value, array) {
3663 return value === array || array instanceof Array && array.indexOf(value) > -1;
3664 }
3665 async function loadFont(font, weight) {
3666 try {
3667 await document.fonts.load(`${weight !== null && weight !== void 0 ? weight : "400"} 36px '${font !== null && font !== void 0 ? font : "Verdana"}'`);
3668 } catch (_a) {}
3669 }
3670 function arrayRandomIndex(array) {
3671 return Math.floor(Math.random() * array.length);
3672 }
3673 function itemFromArray(array, index, useIndex = true) {
3674 const fixedIndex = index !== undefined && useIndex ? index % array.length : arrayRandomIndex(array);
3675 return array[fixedIndex];
3676 }
3677 function isPointInside(point, size, offset, radius, direction) {
3678 return areBoundsInside(calculateBounds(point, radius !== null && radius !== void 0 ? radius : 0), size, offset, direction);
3679 }
3680 function areBoundsInside(bounds, size, offset, direction) {
3681 let inside = true;
3682 if (!direction || direction === "bottom") {
3683 inside = bounds.top < size.height + offset.x;
3684 }
3685 if (inside && (!direction || direction === "left")) {
3686 inside = bounds.right > offset.x;
3687 }
3688 if (inside && (!direction || direction === "right")) {
3689 inside = bounds.left < size.width + offset.y;
3690 }
3691 if (inside && (!direction || direction === "top")) {
3692 inside = bounds.bottom > offset.y;
3693 }
3694 return inside;
3695 }
3696 function calculateBounds(point, radius) {
3697 return {
3698 bottom: point.y + radius,
3699 left: point.x - radius,
3700 right: point.x + radius,
3701 top: point.y - radius
3702 };
3703 }
3704 function deepExtend(destination, ...sources) {
3705 for (const source of sources) {
3706 if (source === undefined || source === null) {
3707 continue;
3708 }
3709 if (typeof source !== "object") {
3710 destination = source;
3711 continue;
3712 }
3713 const sourceIsArray = Array.isArray(source);
3714 if (sourceIsArray && (typeof destination !== "object" || !destination || !Array.isArray(destination))) {
3715 destination = [];
3716 } else if (!sourceIsArray && (typeof destination !== "object" || !destination || Array.isArray(destination))) {
3717 destination = {};
3718 }
3719 for (const key in source) {
3720 if (key === "__proto__") {
3721 continue;
3722 }
3723 const sourceDict = source, value = sourceDict[key], isObject = typeof value === "object", destDict = destination;
3724 destDict[key] = isObject && Array.isArray(value) ? value.map((v => deepExtend(destDict[key], v))) : deepExtend(destDict[key], value);
3725 }
3726 }
3727 return destination;
3728 }
3729 function isDivModeEnabled(mode, divs) {
3730 return divs instanceof Array ? !!divs.find((t => t.enable && isInArray(mode, t.mode))) : isInArray(mode, divs.mode);
3731 }
3732 function divModeExecute(mode, divs, callback) {
3733 if (divs instanceof Array) {
3734 for (const div of divs) {
3735 const divMode = div.mode, divEnabled = div.enable;
3736 if (divEnabled && isInArray(mode, divMode)) {
3737 singleDivModeExecute(div, callback);
3738 }
3739 }
3740 } else {
3741 const divMode = divs.mode, divEnabled = divs.enable;
3742 if (divEnabled && isInArray(mode, divMode)) {
3743 singleDivModeExecute(divs, callback);
3744 }
3745 }
3746 }
3747 function singleDivModeExecute(div, callback) {
3748 const selectors = div.selectors;
3749 if (selectors instanceof Array) {
3750 for (const selector of selectors) {
3751 callback(selector, div);
3752 }
3753 } else {
3754 callback(selectors, div);
3755 }
3756 }
3757 function divMode(divs, element) {
3758 if (!element || !divs) {
3759 return;
3760 }
3761 if (divs instanceof Array) {
3762 return divs.find((d => checkSelector(element, d.selectors)));
3763 } else if (checkSelector(element, divs.selectors)) {
3764 return divs;
3765 }
3766 }
3767 function circleBounceDataFromParticle(p) {
3768 return {
3769 position: p.getPosition(),
3770 radius: p.getRadius(),
3771 mass: p.getMass(),
3772 velocity: p.velocity,
3773 factor: Vector.create(getValue(p.options.bounce.horizontal), getValue(p.options.bounce.vertical))
3774 };
3775 }
3776 function circleBounce(p1, p2) {
3777 const {x: xVelocityDiff, y: yVelocityDiff} = p1.velocity.sub(p2.velocity), [pos1, pos2] = [ p1.position, p2.position ], {dx: xDist, dy: yDist} = getDistances(pos2, pos1);
3778 if (xVelocityDiff * xDist + yVelocityDiff * yDist < 0) {
3779 return;
3780 }
3781 const angle = -Math.atan2(yDist, xDist), m1 = p1.mass, m2 = p2.mass, u1 = p1.velocity.rotate(angle), u2 = p2.velocity.rotate(angle), v1 = collisionVelocity(u1, u2, m1, m2), v2 = collisionVelocity(u2, u1, m1, m2), vFinal1 = v1.rotate(-angle), vFinal2 = v2.rotate(-angle);
3782 p1.velocity.x = vFinal1.x * p1.factor.x;
3783 p1.velocity.y = vFinal1.y * p1.factor.y;
3784 p2.velocity.x = vFinal2.x * p2.factor.x;
3785 p2.velocity.y = vFinal2.y * p2.factor.y;
3786 }
3787 function rectBounce(particle, divBounds) {
3788 const pPos = particle.getPosition(), size = particle.getRadius(), bounds = calculateBounds(pPos, size);
3789 const resH = rectSideBounce({
3790 min: bounds.left,
3791 max: bounds.right
3792 }, {
3793 min: bounds.top,
3794 max: bounds.bottom
3795 }, {
3796 min: divBounds.left,
3797 max: divBounds.right
3798 }, {
3799 min: divBounds.top,
3800 max: divBounds.bottom
3801 }, particle.velocity.x, getValue(particle.options.bounce.horizontal));
3802 if (resH.bounced) {
3803 if (resH.velocity !== undefined) {
3804 particle.velocity.x = resH.velocity;
3805 }
3806 if (resH.position !== undefined) {
3807 particle.position.x = resH.position;
3808 }
3809 }
3810 const resV = rectSideBounce({
3811 min: bounds.top,
3812 max: bounds.bottom
3813 }, {
3814 min: bounds.left,
3815 max: bounds.right
3816 }, {
3817 min: divBounds.top,
3818 max: divBounds.bottom
3819 }, {
3820 min: divBounds.left,
3821 max: divBounds.right
3822 }, particle.velocity.y, getValue(particle.options.bounce.vertical));
3823 if (resV.bounced) {
3824 if (resV.velocity !== undefined) {
3825 particle.velocity.y = resV.velocity;
3826 }
3827 if (resV.position !== undefined) {
3828 particle.position.y = resV.position;
3829 }
3830 }
3831 }
3832 function loadOptions(options, ...sourceOptionsArr) {
3833 for (const sourceOptions of sourceOptionsArr) {
3834 options.load(sourceOptions);
3835 }
3836 }
3837 function loadContainerOptions(engine, ...sourceOptionsArr) {
3838 const options = new Options(engine);
3839 loadOptions(options, ...sourceOptionsArr);
3840 return options;
3841 }
3842 function loadParticlesOptions(...sourceOptionsArr) {
3843 const options = new ParticlesOptions;
3844 loadOptions(options, ...sourceOptionsArr);
3845 return options;
3846 }
3847 const generatedAttribute = "generated";
3848 const randomColorValue = "random";
3849 const midColorValue = "mid";
3850 const touchEndEvent = "touchend";
3851 const mouseDownEvent = "mousedown";
3852 const mouseUpEvent = "mouseup";
3853 const mouseMoveEvent = "mousemove";
3854 const touchStartEvent = "touchstart";
3855 const touchMoveEvent = "touchmove";
3856 const mouseLeaveEvent = "mouseleave";
3857 const mouseOutEvent = "mouseout";
3858 const touchCancelEvent = "touchcancel";
3859 const resizeEvent = "resize";
3860 const visibilityChangeEvent = "visibilitychange";
3861 const noPolygonDataLoaded = "No polygon data loaded.";
3862 const noPolygonFound = "No polygon found, you need to specify SVG url in config.";
3863 function hue2rgb(p, q, t) {
3864 let tCalc = t;
3865 if (tCalc < 0) {
3866 tCalc += 1;
3867 }
3868 if (tCalc > 1) {
3869 tCalc -= 1;
3870 }
3871 if (tCalc < 1 / 6) {
3872 return p + (q - p) * 6 * tCalc;
3873 }
3874 if (tCalc < 1 / 2) {
3875 return q;
3876 }
3877 if (tCalc < 2 / 3) {
3878 return p + (q - p) * (2 / 3 - tCalc) * 6;
3879 }
3880 return p;
3881 }
3882 function stringToRgba(input) {
3883 if (input.startsWith("rgb")) {
3884 const regex = /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([\d.]+)\s*)?\)/i;
3885 const result = regex.exec(input);
3886 return result ? {
3887 a: result.length > 4 ? parseFloat(result[5]) : 1,
3888 b: parseInt(result[3], 10),
3889 g: parseInt(result[2], 10),
3890 r: parseInt(result[1], 10)
3891 } : undefined;
3892 } else if (input.startsWith("hsl")) {
3893 const regex = /hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([\d.]+)\s*)?\)/i;
3894 const result = regex.exec(input);
3895 return result ? hslaToRgba({
3896 a: result.length > 4 ? parseFloat(result[5]) : 1,
3897 h: parseInt(result[1], 10),
3898 l: parseInt(result[3], 10),
3899 s: parseInt(result[2], 10)
3900 }) : undefined;
3901 } else if (input.startsWith("hsv")) {
3902 const regex = /hsva?\(\s*(\d+)°\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([\d.]+)\s*)?\)/i;
3903 const result = regex.exec(input);
3904 return result ? hsvaToRgba({
3905 a: result.length > 4 ? parseFloat(result[5]) : 1,
3906 h: parseInt(result[1], 10),
3907 s: parseInt(result[2], 10),
3908 v: parseInt(result[3], 10)
3909 }) : undefined;
3910 } else {
3911 const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i;
3912 const hexFixed = input.replace(shorthandRegex, ((_m, r, g, b, a) => r + r + g + g + b + b + (a !== undefined ? a + a : "")));
3913 const regex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i;
3914 const result = regex.exec(hexFixed);
3915 return result ? {
3916 a: result[4] !== undefined ? parseInt(result[4], 16) / 255 : 1,
3917 b: parseInt(result[3], 16),
3918 g: parseInt(result[2], 16),
3919 r: parseInt(result[1], 16)
3920 } : undefined;
3921 }
3922 }
3923 function colorToRgb(input, index, useIndex = true) {
3924 var _a, _b, _c;
3925 if (input === undefined) {
3926 return;
3927 }
3928 const color = typeof input === "string" ? {
3929 value: input
3930 } : input;
3931 let res;
3932 if (typeof color.value === "string") {
3933 res = color.value === randomColorValue ? getRandomRgbColor() : stringToRgb(color.value);
3934 } else {
3935 if (color.value instanceof Array) {
3936 const colorSelected = itemFromArray(color.value, index, useIndex);
3937 res = colorToRgb({
3938 value: colorSelected
3939 });
3940 } else {
3941 const colorValue = color.value, rgbColor = (_a = colorValue.rgb) !== null && _a !== void 0 ? _a : color.value;
3942 if (rgbColor.r !== undefined) {
3943 res = rgbColor;
3944 } else {
3945 const hslColor = (_b = colorValue.hsl) !== null && _b !== void 0 ? _b : color.value;
3946 if (hslColor.h !== undefined && hslColor.l !== undefined) {
3947 res = hslToRgb(hslColor);
3948 } else {
3949 const hsvColor = (_c = colorValue.hsv) !== null && _c !== void 0 ? _c : color.value;
3950 if (hsvColor.h !== undefined && hsvColor.v !== undefined) {
3951 res = hsvToRgb(hsvColor);
3952 }
3953 }
3954 }
3955 }
3956 }
3957 return res;
3958 }
3959 function colorToHsl(color, index, useIndex = true) {
3960 const rgb = colorToRgb(color, index, useIndex);
3961 return rgb !== undefined ? rgbToHsl(rgb) : undefined;
3962 }
3963 function rgbToHsl(color) {
3964 const r1 = color.r / 255, g1 = color.g / 255, b1 = color.b / 255;
3965 const max = Math.max(r1, g1, b1), min = Math.min(r1, g1, b1);
3966 const res = {
3967 h: 0,
3968 l: (max + min) / 2,
3969 s: 0
3970 };
3971 if (max !== min) {
3972 res.s = res.l < .5 ? (max - min) / (max + min) : (max - min) / (2 - max - min);
3973 res.h = r1 === max ? (g1 - b1) / (max - min) : res.h = g1 === max ? 2 + (b1 - r1) / (max - min) : 4 + (r1 - g1) / (max - min);
3974 }
3975 res.l *= 100;
3976 res.s *= 100;
3977 res.h *= 60;
3978 if (res.h < 0) {
3979 res.h += 360;
3980 }
3981 return res;
3982 }
3983 function stringToAlpha(input) {
3984 var _a;
3985 return (_a = stringToRgba(input)) === null || _a === void 0 ? void 0 : _a.a;
3986 }
3987 function stringToRgb(input) {
3988 return stringToRgba(input);
3989 }
3990 function hslToRgb(hsl) {
3991 const result = {
3992 b: 0,
3993 g: 0,
3994 r: 0
3995 }, hslPercent = {
3996 h: hsl.h / 360,
3997 l: hsl.l / 100,
3998 s: hsl.s / 100
3999 };
4000 if (hslPercent.s === 0) {
4001 result.b = hslPercent.l;
4002 result.g = hslPercent.l;
4003 result.r = hslPercent.l;
4004 } else {
4005 const q = hslPercent.l < .5 ? hslPercent.l * (1 + hslPercent.s) : hslPercent.l + hslPercent.s - hslPercent.l * hslPercent.s, p = 2 * hslPercent.l - q;
4006 result.r = hue2rgb(p, q, hslPercent.h + 1 / 3);
4007 result.g = hue2rgb(p, q, hslPercent.h);
4008 result.b = hue2rgb(p, q, hslPercent.h - 1 / 3);
4009 }
4010 result.r = Math.floor(result.r * 255);
4011 result.g = Math.floor(result.g * 255);
4012 result.b = Math.floor(result.b * 255);
4013 return result;
4014 }
4015 function hslaToRgba(hsla) {
4016 const rgbResult = hslToRgb(hsla);
4017 return {
4018 a: hsla.a,
4019 b: rgbResult.b,
4020 g: rgbResult.g,
4021 r: rgbResult.r
4022 };
4023 }
4024 function hslToHsv(hsl) {
4025 const l = hsl.l / 100, sl = hsl.s / 100, v = l + sl * Math.min(l, 1 - l), sv = !v ? 0 : 2 * (1 - l / v);
4026 return {
4027 h: hsl.h,
4028 s: sv * 100,
4029 v: v * 100
4030 };
4031 }
4032 function hslaToHsva(hsla) {
4033 const hsvResult = hslToHsv(hsla);
4034 return {
4035 a: hsla.a,
4036 h: hsvResult.h,
4037 s: hsvResult.s,
4038 v: hsvResult.v
4039 };
4040 }
4041 function hsvToHsl(hsv) {
4042 const v = hsv.v / 100, sv = hsv.s / 100, l = v * (1 - sv / 2), sl = l === 0 || l === 1 ? 0 : (v - l) / Math.min(l, 1 - l);
4043 return {
4044 h: hsv.h,
4045 l: l * 100,
4046 s: sl * 100
4047 };
4048 }
4049 function hsvaToHsla(hsva) {
4050 const hslResult = hsvToHsl(hsva);
4051 return {
4052 a: hsva.a,
4053 h: hslResult.h,
4054 l: hslResult.l,
4055 s: hslResult.s
4056 };
4057 }
4058 function hsvToRgb(hsv) {
4059 const result = {
4060 b: 0,
4061 g: 0,
4062 r: 0
4063 }, hsvPercent = {
4064 h: hsv.h / 60,
4065 s: hsv.s / 100,
4066 v: hsv.v / 100
4067 };
4068 const c = hsvPercent.v * hsvPercent.s, x = c * (1 - Math.abs(hsvPercent.h % 2 - 1));
4069 let tempRgb;
4070 if (hsvPercent.h >= 0 && hsvPercent.h <= 1) {
4071 tempRgb = {
4072 r: c,
4073 g: x,
4074 b: 0
4075 };
4076 } else if (hsvPercent.h > 1 && hsvPercent.h <= 2) {
4077 tempRgb = {
4078 r: x,
4079 g: c,
4080 b: 0
4081 };
4082 } else if (hsvPercent.h > 2 && hsvPercent.h <= 3) {
4083 tempRgb = {
4084 r: 0,
4085 g: c,
4086 b: x
4087 };
4088 } else if (hsvPercent.h > 3 && hsvPercent.h <= 4) {
4089 tempRgb = {
4090 r: 0,
4091 g: x,
4092 b: c
4093 };
4094 } else if (hsvPercent.h > 4 && hsvPercent.h <= 5) {
4095 tempRgb = {
4096 r: x,
4097 g: 0,
4098 b: c
4099 };
4100 } else if (hsvPercent.h > 5 && hsvPercent.h <= 6) {
4101 tempRgb = {
4102 r: c,
4103 g: 0,
4104 b: x
4105 };
4106 }
4107 if (tempRgb) {
4108 const m = hsvPercent.v - c;
4109 result.r = Math.floor((tempRgb.r + m) * 255);
4110 result.g = Math.floor((tempRgb.g + m) * 255);
4111 result.b = Math.floor((tempRgb.b + m) * 255);
4112 }
4113 return result;
4114 }
4115 function hsvaToRgba(hsva) {
4116 const rgbResult = hsvToRgb(hsva);
4117 return {
4118 a: hsva.a,
4119 b: rgbResult.b,
4120 g: rgbResult.g,
4121 r: rgbResult.r
4122 };
4123 }
4124 function rgbToHsv(rgb) {
4125 const rgbPercent = {
4126 r: rgb.r / 255,
4127 g: rgb.g / 255,
4128 b: rgb.b / 255
4129 }, xMax = Math.max(rgbPercent.r, rgbPercent.g, rgbPercent.b), xMin = Math.min(rgbPercent.r, rgbPercent.g, rgbPercent.b), v = xMax, c = xMax - xMin;
4130 let h = 0;
4131 if (v === rgbPercent.r) {
4132 h = 60 * ((rgbPercent.g - rgbPercent.b) / c);
4133 } else if (v === rgbPercent.g) {
4134 h = 60 * (2 + (rgbPercent.b - rgbPercent.r) / c);
4135 } else if (v === rgbPercent.b) {
4136 h = 60 * (4 + (rgbPercent.r - rgbPercent.g) / c);
4137 }
4138 const s = !v ? 0 : c / v;
4139 return {
4140 h: h,
4141 s: s * 100,
4142 v: v * 100
4143 };
4144 }
4145 function rgbaToHsva(rgba) {
4146 const hsvResult = rgbToHsv(rgba);
4147 return {
4148 a: rgba.a,
4149 h: hsvResult.h,
4150 s: hsvResult.s,
4151 v: hsvResult.v
4152 };
4153 }
4154 function getRandomRgbColor(min) {
4155 const fixedMin = min !== null && min !== void 0 ? min : 0;
4156 return {
4157 b: Math.floor(randomInRange(setRangeValue(fixedMin, 256))),
4158 g: Math.floor(randomInRange(setRangeValue(fixedMin, 256))),
4159 r: Math.floor(randomInRange(setRangeValue(fixedMin, 256)))
4160 };
4161 }
4162 function getStyleFromRgb(color, opacity) {
4163 return `rgba(${color.r}, ${color.g}, ${color.b}, ${opacity !== null && opacity !== void 0 ? opacity : 1})`;
4164 }
4165 function getStyleFromHsl(color, opacity) {
4166 return `hsla(${color.h}, ${color.s}%, ${color.l}%, ${opacity !== null && opacity !== void 0 ? opacity : 1})`;
4167 }
4168 function getStyleFromHsv(color, opacity) {
4169 return getStyleFromHsl(hsvToHsl(color), opacity);
4170 }
4171 function colorMix(color1, color2, size1, size2) {
4172 let rgb1 = color1, rgb2 = color2;
4173 if (rgb1.r === undefined) {
4174 rgb1 = hslToRgb(color1);
4175 }
4176 if (rgb2.r === undefined) {
4177 rgb2 = hslToRgb(color2);
4178 }
4179 return {
4180 b: mix(rgb1.b, rgb2.b, size1, size2),
4181 g: mix(rgb1.g, rgb2.g, size1, size2),
4182 r: mix(rgb1.r, rgb2.r, size1, size2)
4183 };
4184 }
4185 function getLinkColor(p1, p2, linkColor) {
4186 var _a, _b;
4187 if (linkColor === randomColorValue) {
4188 return getRandomRgbColor();
4189 } else if (linkColor === "mid") {
4190 const sourceColor = (_a = p1.getFillColor()) !== null && _a !== void 0 ? _a : p1.getStrokeColor(), destColor = (_b = p2 === null || p2 === void 0 ? void 0 : p2.getFillColor()) !== null && _b !== void 0 ? _b : p2 === null || p2 === void 0 ? void 0 : p2.getStrokeColor();
4191 if (sourceColor && destColor && p2) {
4192 return colorMix(sourceColor, destColor, p1.getRadius(), p2.getRadius());
4193 } else {
4194 const hslColor = sourceColor !== null && sourceColor !== void 0 ? sourceColor : destColor;
4195 if (hslColor) {
4196 return hslToRgb(hslColor);
4197 }
4198 }
4199 } else {
4200 return linkColor;
4201 }
4202 }
4203 function getLinkRandomColor(optColor, blink, consent) {
4204 const color = typeof optColor === "string" ? optColor : optColor.value;
4205 if (color === randomColorValue) {
4206 if (consent) {
4207 return colorToRgb({
4208 value: color
4209 });
4210 } else if (blink) {
4211 return randomColorValue;
4212 } else {
4213 return midColorValue;
4214 }
4215 } else {
4216 return colorToRgb({
4217 value: color
4218 });
4219 }
4220 }
4221 function getHslFromAnimation(animation) {
4222 return animation !== undefined ? {
4223 h: animation.h.value,
4224 s: animation.s.value,
4225 l: animation.l.value
4226 } : undefined;
4227 }
4228 function getHslAnimationFromHsl(hsl, animationOptions, reduceFactor) {
4229 const resColor = {
4230 h: {
4231 enable: false,
4232 value: hsl.h
4233 },
4234 s: {
4235 enable: false,
4236 value: hsl.s
4237 },
4238 l: {
4239 enable: false,
4240 value: hsl.l
4241 }
4242 };
4243 if (animationOptions) {
4244 setColorAnimation(resColor.h, animationOptions.h, reduceFactor);
4245 setColorAnimation(resColor.s, animationOptions.s, reduceFactor);
4246 setColorAnimation(resColor.l, animationOptions.l, reduceFactor);
4247 }
4248 return resColor;
4249 }
4250 function setColorAnimation(colorValue, colorAnimation, reduceFactor) {
4251 colorValue.enable = colorAnimation.enable;
4252 if (colorValue.enable) {
4253 colorValue.velocity = getRangeValue(colorAnimation.speed) / 100 * reduceFactor;
4254 if (colorAnimation.sync) {
4255 return;
4256 }
4257 colorValue.status = 0;
4258 colorValue.velocity *= Math.random();
4259 if (colorValue.value) {
4260 colorValue.value *= Math.random();
4261 }
4262 } else {
4263 colorValue.velocity = 0;
4264 }
4265 }
4266 function drawLine(context, begin, end) {
4267 context.beginPath();
4268 context.moveTo(begin.x, begin.y);
4269 context.lineTo(end.x, end.y);
4270 context.closePath();
4271 }
4272 function drawTriangle(context, p1, p2, p3) {
4273 context.beginPath();
4274 context.moveTo(p1.x, p1.y);
4275 context.lineTo(p2.x, p2.y);
4276 context.lineTo(p3.x, p3.y);
4277 context.closePath();
4278 }
4279 function paintBase(context, dimension, baseColor) {
4280 context.save();
4281 context.fillStyle = baseColor !== null && baseColor !== void 0 ? baseColor : "rgba(0,0,0,0)";
4282 context.fillRect(0, 0, dimension.width, dimension.height);
4283 context.restore();
4284 }
4285 function clear(context, dimension) {
4286 context.clearRect(0, 0, dimension.width, dimension.height);
4287 }
4288 function drawConnectLine(context, width, lineStyle, begin, end) {
4289 context.save();
4290 drawLine(context, begin, end);
4291 context.lineWidth = width;
4292 context.strokeStyle = lineStyle;
4293 context.stroke();
4294 context.restore();
4295 }
4296 function gradient(context, p1, p2, opacity) {
4297 const gradStop = Math.floor(p2.getRadius() / p1.getRadius()), color1 = p1.getFillColor(), color2 = p2.getFillColor();
4298 if (!color1 || !color2) {
4299 return;
4300 }
4301 const sourcePos = p1.getPosition(), destPos = p2.getPosition(), midRgb = colorMix(color1, color2, p1.getRadius(), p2.getRadius()), grad = context.createLinearGradient(sourcePos.x, sourcePos.y, destPos.x, destPos.y);
4302 grad.addColorStop(0, getStyleFromHsl(color1, opacity));
4303 grad.addColorStop(gradStop > 1 ? 1 : gradStop, getStyleFromRgb(midRgb, opacity));
4304 grad.addColorStop(1, getStyleFromHsl(color2, opacity));
4305 return grad;
4306 }
4307 function drawGrabLine(context, width, begin, end, colorLine, opacity) {
4308 context.save();
4309 drawLine(context, begin, end);
4310 context.strokeStyle = getStyleFromRgb(colorLine, opacity);
4311 context.lineWidth = width;
4312 context.stroke();
4313 context.restore();
4314 }
4315 function drawParticle(container, context, particle, delta, colorStyles, backgroundMask, composite, radius, opacity, shadow) {
4316 var _a, _b, _c, _d;
4317 const pos = particle.getPosition(), tiltOptions = particle.options.tilt, rollOptions = particle.options.roll;
4318 context.save();
4319 if (tiltOptions.enable || rollOptions.enable) {
4320 const roll = rollOptions.enable && particle.roll, tilt = tiltOptions.enable && particle.tilt, rollHorizontal = roll && (rollOptions.mode === "horizontal" || rollOptions.mode === "both"), rollVertical = roll && (rollOptions.mode === "vertical" || rollOptions.mode === "both");
4321 context.setTransform(rollHorizontal ? Math.cos(particle.roll.angle) : 1, tilt ? Math.cos(particle.tilt.value) * particle.tilt.cosDirection : 0, tilt ? Math.sin(particle.tilt.value) * particle.tilt.sinDirection : 0, rollVertical ? Math.sin(particle.roll.angle) : 1, pos.x, pos.y);
4322 } else {
4323 context.translate(pos.x, pos.y);
4324 }
4325 context.beginPath();
4326 const angle = ((_b = (_a = particle.rotate) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0) + (particle.options.rotate.path ? particle.velocity.angle : 0);
4327 if (angle !== 0) {
4328 context.rotate(angle);
4329 }
4330 if (backgroundMask) {
4331 context.globalCompositeOperation = composite;
4332 }
4333 const shadowColor = particle.shadowColor;
4334 if (shadow.enable && shadowColor) {
4335 context.shadowBlur = shadow.blur;
4336 context.shadowColor = getStyleFromRgb(shadowColor);
4337 context.shadowOffsetX = shadow.offset.x;
4338 context.shadowOffsetY = shadow.offset.y;
4339 }
4340 if (colorStyles.fill) {
4341 context.fillStyle = colorStyles.fill;
4342 }
4343 const stroke = particle.stroke;
4344 context.lineWidth = (_c = particle.strokeWidth) !== null && _c !== void 0 ? _c : 0;
4345 if (colorStyles.stroke) {
4346 context.strokeStyle = colorStyles.stroke;
4347 }
4348 drawShape(container, context, particle, radius, opacity, delta);
4349 if (((_d = stroke === null || stroke === void 0 ? void 0 : stroke.width) !== null && _d !== void 0 ? _d : 0) > 0) {
4350 context.stroke();
4351 }
4352 if (particle.close) {
4353 context.closePath();
4354 }
4355 if (particle.fill) {
4356 context.fill();
4357 }
4358 context.restore();
4359 context.save();
4360 if (tiltOptions.enable && particle.tilt) {
4361 context.setTransform(1, Math.cos(particle.tilt.value) * particle.tilt.cosDirection, Math.sin(particle.tilt.value) * particle.tilt.sinDirection, 1, pos.x, pos.y);
4362 } else {
4363 context.translate(pos.x, pos.y);
4364 }
4365 if (angle !== 0) {
4366 context.rotate(angle);
4367 }
4368 if (backgroundMask) {
4369 context.globalCompositeOperation = composite;
4370 }
4371 drawShapeAfterEffect(container, context, particle, radius, opacity, delta);
4372 context.restore();
4373 }
4374 function drawShape(container, context, particle, radius, opacity, delta) {
4375 if (!particle.shape) {
4376 return;
4377 }
4378 const drawer = container.drawers.get(particle.shape);
4379 if (!drawer) {
4380 return;
4381 }
4382 drawer.draw(context, particle, radius, opacity, delta, container.retina.pixelRatio);
4383 }
4384 function drawShapeAfterEffect(container, context, particle, radius, opacity, delta) {
4385 if (!particle.shape) {
4386 return;
4387 }
4388 const drawer = container.drawers.get(particle.shape);
4389 if (!(drawer === null || drawer === void 0 ? void 0 : drawer.afterEffect)) {
4390 return;
4391 }
4392 drawer.afterEffect(context, particle, radius, opacity, delta, container.retina.pixelRatio);
4393 }
4394 function drawPlugin(context, plugin, delta) {
4395 if (!plugin.draw) {
4396 return;
4397 }
4398 context.save();
4399 plugin.draw(context, delta);
4400 context.restore();
4401 }
4402 function drawParticlePlugin(context, plugin, particle, delta) {
4403 if (!plugin.drawParticle) {
4404 return;
4405 }
4406 context.save();
4407 plugin.drawParticle(context, particle, delta);
4408 context.restore();
4409 }
4410 function drawEllipse(context, particle, fillColorValue, radius, opacity, width, rotation, start, end) {
4411 if (width <= 0) {
4412 return;
4413 }
4414 const pos = particle.getPosition();
4415 if (fillColorValue) {
4416 context.strokeStyle = getStyleFromHsl(fillColorValue, opacity);
4417 }
4418 context.lineWidth = width;
4419 const rotationRadian = rotation * Math.PI / 180;
4420 context.beginPath();
4421 context.ellipse(pos.x, pos.y, radius / 2, radius * 2, rotationRadian, start, end);
4422 context.stroke();
4423 }
4424 function alterHsl(color, type, value) {
4425 return {
4426 h: color.h,
4427 s: color.s,
4428 l: color.l + (type === "darken" ? -1 : 1) * value
4429 };
4430 }
4431 class Canvas {
4432 constructor(container) {
4433 this.container = container;
4434 this.size = {
4435 height: 0,
4436 width: 0
4437 };
4438 this.context = null;
4439 this.generatedCanvas = false;
4440 }
4441 init() {
4442 this.resize();
4443 this.initStyle();
4444 this.initCover();
4445 this.initTrail();
4446 this.initBackground();
4447 this.paint();
4448 }
4449 loadCanvas(canvas) {
4450 var _a;
4451 if (this.generatedCanvas) {
4452 (_a = this.element) === null || _a === void 0 ? void 0 : _a.remove();
4453 }
4454 this.generatedCanvas = canvas.dataset && generatedAttribute in canvas.dataset ? canvas.dataset[generatedAttribute] === "true" : this.generatedCanvas;
4455 this.element = canvas;
4456 this.originalStyle = deepExtend({}, this.element.style);
4457 this.size.height = canvas.offsetHeight;
4458 this.size.width = canvas.offsetWidth;
4459 this.context = this.element.getContext("2d");
4460 this.container.retina.init();
4461 this.initBackground();
4462 }
4463 destroy() {
4464 var _a;
4465 if (this.generatedCanvas) {
4466 (_a = this.element) === null || _a === void 0 ? void 0 : _a.remove();
4467 }
4468 this.draw((ctx => {
4469 clear(ctx, this.size);
4470 }));
4471 }
4472 paint() {
4473 const options = this.container.actualOptions;
4474 this.draw((ctx => {
4475 if (options.backgroundMask.enable && options.backgroundMask.cover) {
4476 clear(ctx, this.size);
4477 this.paintBase(this.coverColorStyle);
4478 } else {
4479 this.paintBase();
4480 }
4481 }));
4482 }
4483 clear() {
4484 const options = this.container.actualOptions, trail = options.particles.move.trail;
4485 if (options.backgroundMask.enable) {
4486 this.paint();
4487 } else if (trail.enable && trail.length > 0 && this.trailFillColor) {
4488 this.paintBase(getStyleFromRgb(this.trailFillColor, 1 / trail.length));
4489 } else {
4490 this.draw((ctx => {
4491 clear(ctx, this.size);
4492 }));
4493 }
4494 }
4495 async windowResize() {
4496 if (!this.element) {
4497 return;
4498 }
4499 this.resize();
4500 const container = this.container, needsRefresh = container.updateActualOptions();
4501 container.particles.setDensity();
4502 for (const [, plugin] of container.plugins) {
4503 if (plugin.resize !== undefined) {
4504 plugin.resize();
4505 }
4506 }
4507 if (needsRefresh) {
4508 await container.refresh();
4509 }
4510 }
4511 resize() {
4512 if (!this.element) {
4513 return;
4514 }
4515 const container = this.container, pxRatio = container.retina.pixelRatio, size = container.canvas.size, newSize = {
4516 width: this.element.offsetWidth * pxRatio,
4517 height: this.element.offsetHeight * pxRatio
4518 };
4519 if (newSize.height === size.height && newSize.width === size.width && newSize.height === this.element.height && newSize.width === this.element.width) {
4520 return;
4521 }
4522 const oldSize = Object.assign({}, size);
4523 this.element.width = size.width = this.element.offsetWidth * pxRatio;
4524 this.element.height = size.height = this.element.offsetHeight * pxRatio;
4525 if (this.container.started) {
4526 this.resizeFactor = {
4527 width: size.width / oldSize.width,
4528 height: size.height / oldSize.height
4529 };
4530 }
4531 }
4532 drawConnectLine(p1, p2) {
4533 this.draw((ctx => {
4534 var _a;
4535 const lineStyle = this.lineStyle(p1, p2);
4536 if (!lineStyle) {
4537 return;
4538 }
4539 const pos1 = p1.getPosition(), pos2 = p2.getPosition();
4540 drawConnectLine(ctx, (_a = p1.retina.linksWidth) !== null && _a !== void 0 ? _a : this.container.retina.linksWidth, lineStyle, pos1, pos2);
4541 }));
4542 }
4543 drawGrabLine(particle, lineColor, opacity, mousePos) {
4544 const container = this.container;
4545 this.draw((ctx => {
4546 var _a;
4547 const beginPos = particle.getPosition();
4548 drawGrabLine(ctx, (_a = particle.retina.linksWidth) !== null && _a !== void 0 ? _a : container.retina.linksWidth, beginPos, mousePos, lineColor, opacity);
4549 }));
4550 }
4551 drawParticle(particle, delta) {
4552 var _a, _b, _c, _d, _e, _f;
4553 if (particle.spawning || particle.destroyed) {
4554 return;
4555 }
4556 const radius = particle.getRadius();
4557 if (radius <= 0) {
4558 return;
4559 }
4560 const pfColor = particle.getFillColor(), psColor = (_a = particle.getStrokeColor()) !== null && _a !== void 0 ? _a : pfColor;
4561 if (!pfColor && !psColor) {
4562 return;
4563 }
4564 let [fColor, sColor] = this.getPluginParticleColors(particle);
4565 if (!fColor || !sColor) {
4566 if (!fColor) {
4567 fColor = pfColor ? pfColor : undefined;
4568 }
4569 if (!sColor) {
4570 sColor = psColor ? psColor : undefined;
4571 }
4572 }
4573 const options = this.container.actualOptions, zIndexOptions = particle.options.zIndex, zOpacityFactor = (1 - particle.zIndexFactor) ** zIndexOptions.opacityRate, opacity = (_d = (_b = particle.bubble.opacity) !== null && _b !== void 0 ? _b : (_c = particle.opacity) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : 1, strokeOpacity = (_f = (_e = particle.stroke) === null || _e === void 0 ? void 0 : _e.opacity) !== null && _f !== void 0 ? _f : opacity, zOpacity = opacity * zOpacityFactor, zStrokeOpacity = strokeOpacity * zOpacityFactor;
4574 const colorStyles = {
4575 fill: fColor ? getStyleFromHsl(fColor, zOpacity) : undefined
4576 };
4577 colorStyles.stroke = sColor ? getStyleFromHsl(sColor, zStrokeOpacity) : colorStyles.fill;
4578 this.draw((ctx => {
4579 const zSizeFactor = (1 - particle.zIndexFactor) ** zIndexOptions.sizeRate, container = this.container;
4580 for (const updater of container.particles.updaters) {
4581 if (updater.beforeDraw) {
4582 updater.beforeDraw(particle);
4583 }
4584 if (updater.getColorStyles) {
4585 const {fill: fill, stroke: stroke} = updater.getColorStyles(particle, ctx, radius, zOpacity);
4586 if (fill) {
4587 colorStyles.fill = fill;
4588 }
4589 if (stroke) {
4590 colorStyles.stroke = stroke;
4591 }
4592 }
4593 }
4594 drawParticle(container, ctx, particle, delta, colorStyles, options.backgroundMask.enable, options.backgroundMask.composite, radius * zSizeFactor, zOpacity, particle.options.shadow);
4595 for (const updater of container.particles.updaters) {
4596 if (updater.afterDraw) {
4597 updater.afterDraw(particle);
4598 }
4599 }
4600 }));
4601 }
4602 drawPlugin(plugin, delta) {
4603 this.draw((ctx => {
4604 drawPlugin(ctx, plugin, delta);
4605 }));
4606 }
4607 drawParticlePlugin(plugin, particle, delta) {
4608 this.draw((ctx => {
4609 drawParticlePlugin(ctx, plugin, particle, delta);
4610 }));
4611 }
4612 initBackground() {
4613 const options = this.container.actualOptions, background = options.background, element = this.element, elementStyle = element === null || element === void 0 ? void 0 : element.style;
4614 if (!elementStyle) {
4615 return;
4616 }
4617 if (background.color) {
4618 const color = colorToRgb(background.color);
4619 elementStyle.backgroundColor = color ? getStyleFromRgb(color, background.opacity) : "";
4620 } else {
4621 elementStyle.backgroundColor = "";
4622 }
4623 elementStyle.backgroundImage = background.image || "";
4624 elementStyle.backgroundPosition = background.position || "";
4625 elementStyle.backgroundRepeat = background.repeat || "";
4626 elementStyle.backgroundSize = background.size || "";
4627 }
4628 draw(cb) {
4629 if (!this.context) {
4630 return;
4631 }
4632 return cb(this.context);
4633 }
4634 initCover() {
4635 const options = this.container.actualOptions, cover = options.backgroundMask.cover, color = cover.color, coverRgb = colorToRgb(color);
4636 if (coverRgb) {
4637 const coverColor = {
4638 r: coverRgb.r,
4639 g: coverRgb.g,
4640 b: coverRgb.b,
4641 a: cover.opacity
4642 };
4643 this.coverColorStyle = getStyleFromRgb(coverColor, coverColor.a);
4644 }
4645 }
4646 initTrail() {
4647 const options = this.container.actualOptions, trail = options.particles.move.trail, fillColor = colorToRgb(trail.fillColor);
4648 if (fillColor) {
4649 const trail = options.particles.move.trail;
4650 this.trailFillColor = {
4651 r: fillColor.r,
4652 g: fillColor.g,
4653 b: fillColor.b,
4654 a: 1 / trail.length
4655 };
4656 }
4657 }
4658 getPluginParticleColors(particle) {
4659 let fColor, sColor;
4660 for (const [, plugin] of this.container.plugins) {
4661 if (!fColor && plugin.particleFillColor) {
4662 fColor = colorToHsl(plugin.particleFillColor(particle));
4663 }
4664 if (!sColor && plugin.particleStrokeColor) {
4665 sColor = colorToHsl(plugin.particleStrokeColor(particle));
4666 }
4667 if (fColor && sColor) {
4668 break;
4669 }
4670 }
4671 return [ fColor, sColor ];
4672 }
4673 initStyle() {
4674 const element = this.element, options = this.container.actualOptions;
4675 if (!element) {
4676 return;
4677 }
4678 const originalStyle = this.originalStyle;
4679 if (options.fullScreen.enable) {
4680 this.originalStyle = deepExtend({}, element.style);
4681 element.style.setProperty("position", "fixed", "important");
4682 element.style.setProperty("z-index", options.fullScreen.zIndex.toString(10), "important");
4683 element.style.setProperty("top", "0", "important");
4684 element.style.setProperty("left", "0", "important");
4685 element.style.setProperty("width", "100%", "important");
4686 element.style.setProperty("height", "100%", "important");
4687 } else if (originalStyle) {
4688 element.style.position = originalStyle.position;
4689 element.style.zIndex = originalStyle.zIndex;
4690 element.style.top = originalStyle.top;
4691 element.style.left = originalStyle.left;
4692 element.style.width = originalStyle.width;
4693 element.style.height = originalStyle.height;
4694 }
4695 for (const key in options.style) {
4696 if (!key || !options.style) {
4697 continue;
4698 }
4699 const value = options.style[key];
4700 if (!value) {
4701 continue;
4702 }
4703 element.style.setProperty(key, value, "important");
4704 }
4705 }
4706 paintBase(baseColor) {
4707 this.draw((ctx => {
4708 paintBase(ctx, this.size, baseColor);
4709 }));
4710 }
4711 lineStyle(p1, p2) {
4712 return this.draw((ctx => {
4713 const options = this.container.actualOptions, connectOptions = options.interactivity.modes.connect;
4714 return gradient(ctx, p1, p2, connectOptions.links.opacity);
4715 }));
4716 }
4717 }
4718 function manageListener(element, event, handler, add, options) {
4719 if (add) {
4720 let addOptions = {
4721 passive: true
4722 };
4723 if (typeof options === "boolean") {
4724 addOptions.capture = options;
4725 } else if (options !== undefined) {
4726 addOptions = options;
4727 }
4728 element.addEventListener(event, handler, addOptions);
4729 } else {
4730 const removeOptions = options;
4731 element.removeEventListener(event, handler, removeOptions);
4732 }
4733 }
4734 class EventListeners {
4735 constructor(container) {
4736 this.container = container;
4737 this.canPush = true;
4738 this.mouseMoveHandler = e => this.mouseTouchMove(e);
4739 this.touchStartHandler = e => this.mouseTouchMove(e);
4740 this.touchMoveHandler = e => this.mouseTouchMove(e);
4741 this.touchEndHandler = () => this.mouseTouchFinish();
4742 this.mouseLeaveHandler = () => this.mouseTouchFinish();
4743 this.touchCancelHandler = () => this.mouseTouchFinish();
4744 this.touchEndClickHandler = e => this.mouseTouchClick(e);
4745 this.mouseUpHandler = e => this.mouseTouchClick(e);
4746 this.mouseDownHandler = () => this.mouseDown();
4747 this.visibilityChangeHandler = () => this.handleVisibilityChange();
4748 this.themeChangeHandler = e => this.handleThemeChange(e);
4749 this.oldThemeChangeHandler = e => this.handleThemeChange(e);
4750 this.resizeHandler = () => this.handleWindowResize();
4751 }
4752 addListeners() {
4753 this.manageListeners(true);
4754 }
4755 removeListeners() {
4756 this.manageListeners(false);
4757 }
4758 manageListeners(add) {
4759 var _a;
4760 const container = this.container, options = container.actualOptions, detectType = options.interactivity.detectsOn;
4761 let mouseLeaveTmpEvent = mouseLeaveEvent;
4762 if (detectType === "window") {
4763 container.interactivity.element = window;
4764 mouseLeaveTmpEvent = mouseOutEvent;
4765 } else if (detectType === "parent" && container.canvas.element) {
4766 const canvasEl = container.canvas.element;
4767 container.interactivity.element = (_a = canvasEl.parentElement) !== null && _a !== void 0 ? _a : canvasEl.parentNode;
4768 } else {
4769 container.interactivity.element = container.canvas.element;
4770 }
4771 const mediaMatch = !isSsr() && typeof matchMedia !== "undefined" && matchMedia("(prefers-color-scheme: dark)");
4772 if (mediaMatch) {
4773 if (mediaMatch.addEventListener !== undefined) {
4774 manageListener(mediaMatch, "change", this.themeChangeHandler, add);
4775 } else if (mediaMatch.addListener !== undefined) {
4776 if (add) {
4777 mediaMatch.addListener(this.oldThemeChangeHandler);
4778 } else {
4779 mediaMatch.removeListener(this.oldThemeChangeHandler);
4780 }
4781 }
4782 }
4783 const interactivityEl = container.interactivity.element;
4784 if (!interactivityEl) {
4785 return;
4786 }
4787 const html = interactivityEl;
4788 if (options.interactivity.events.onHover.enable || options.interactivity.events.onClick.enable) {
4789 manageListener(interactivityEl, mouseMoveEvent, this.mouseMoveHandler, add);
4790 manageListener(interactivityEl, touchStartEvent, this.touchStartHandler, add);
4791 manageListener(interactivityEl, touchMoveEvent, this.touchMoveHandler, add);
4792 if (!options.interactivity.events.onClick.enable) {
4793 manageListener(interactivityEl, touchEndEvent, this.touchEndHandler, add);
4794 } else {
4795 manageListener(interactivityEl, touchEndEvent, this.touchEndClickHandler, add);
4796 manageListener(interactivityEl, mouseUpEvent, this.mouseUpHandler, add);
4797 manageListener(interactivityEl, mouseDownEvent, this.mouseDownHandler, add);
4798 }
4799 manageListener(interactivityEl, mouseLeaveTmpEvent, this.mouseLeaveHandler, add);
4800 manageListener(interactivityEl, touchCancelEvent, this.touchCancelHandler, add);
4801 }
4802 if (container.canvas.element) {
4803 container.canvas.element.style.pointerEvents = html === container.canvas.element ? "initial" : "none";
4804 }
4805 if (options.interactivity.events.resize) {
4806 if (typeof ResizeObserver !== "undefined") {
4807 if (this.resizeObserver && !add) {
4808 if (container.canvas.element) {
4809 this.resizeObserver.unobserve(container.canvas.element);
4810 }
4811 this.resizeObserver.disconnect();
4812 delete this.resizeObserver;
4813 } else if (!this.resizeObserver && add && container.canvas.element) {
4814 this.resizeObserver = new ResizeObserver((entries => {
4815 const entry = entries.find((e => e.target === container.canvas.element));
4816 if (!entry) {
4817 return;
4818 }
4819 this.handleWindowResize();
4820 }));
4821 this.resizeObserver.observe(container.canvas.element);
4822 }
4823 } else {
4824 manageListener(window, resizeEvent, this.resizeHandler, add);
4825 }
4826 }
4827 if (document) {
4828 manageListener(document, visibilityChangeEvent, this.visibilityChangeHandler, add, false);
4829 }
4830 }
4831 handleWindowResize() {
4832 if (this.resizeTimeout) {
4833 clearTimeout(this.resizeTimeout);
4834 delete this.resizeTimeout;
4835 }
4836 this.resizeTimeout = setTimeout((async () => {
4837 var _a;
4838 return (_a = this.container.canvas) === null || _a === void 0 ? void 0 : _a.windowResize();
4839 }), 500);
4840 }
4841 handleVisibilityChange() {
4842 const container = this.container, options = container.actualOptions;
4843 this.mouseTouchFinish();
4844 if (!options.pauseOnBlur) {
4845 return;
4846 }
4847 if (document === null || document === void 0 ? void 0 : document.hidden) {
4848 container.pageHidden = true;
4849 container.pause();
4850 } else {
4851 container.pageHidden = false;
4852 if (container.getAnimationStatus()) {
4853 container.play(true);
4854 } else {
4855 container.draw(true);
4856 }
4857 }
4858 }
4859 mouseDown() {
4860 const interactivity = this.container.interactivity;
4861 if (interactivity) {
4862 const mouse = interactivity.mouse;
4863 mouse.clicking = true;
4864 mouse.downPosition = mouse.position;
4865 }
4866 }
4867 mouseTouchMove(e) {
4868 var _a, _b, _c, _d, _e, _f, _g;
4869 const container = this.container, options = container.actualOptions;
4870 if (!((_a = container.interactivity) === null || _a === void 0 ? void 0 : _a.element)) {
4871 return;
4872 }
4873 container.interactivity.mouse.inside = true;
4874 let pos;
4875 const canvas = container.canvas.element;
4876 if (e.type.startsWith("mouse")) {
4877 this.canPush = true;
4878 const mouseEvent = e;
4879 if (container.interactivity.element === window) {
4880 if (canvas) {
4881 const clientRect = canvas.getBoundingClientRect();
4882 pos = {
4883 x: mouseEvent.clientX - clientRect.left,
4884 y: mouseEvent.clientY - clientRect.top
4885 };
4886 }
4887 } else if (options.interactivity.detectsOn === "parent") {
4888 const source = mouseEvent.target;
4889 const target = mouseEvent.currentTarget;
4890 const canvasEl = container.canvas.element;
4891 if (source && target && canvasEl) {
4892 const sourceRect = source.getBoundingClientRect();
4893 const targetRect = target.getBoundingClientRect();
4894 const canvasRect = canvasEl.getBoundingClientRect();
4895 pos = {
4896 x: mouseEvent.offsetX + 2 * sourceRect.left - (targetRect.left + canvasRect.left),
4897 y: mouseEvent.offsetY + 2 * sourceRect.top - (targetRect.top + canvasRect.top)
4898 };
4899 } else {
4900 pos = {
4901 x: (_b = mouseEvent.offsetX) !== null && _b !== void 0 ? _b : mouseEvent.clientX,
4902 y: (_c = mouseEvent.offsetY) !== null && _c !== void 0 ? _c : mouseEvent.clientY
4903 };
4904 }
4905 } else {
4906 if (mouseEvent.target === container.canvas.element) {
4907 pos = {
4908 x: (_d = mouseEvent.offsetX) !== null && _d !== void 0 ? _d : mouseEvent.clientX,
4909 y: (_e = mouseEvent.offsetY) !== null && _e !== void 0 ? _e : mouseEvent.clientY
4910 };
4911 }
4912 }
4913 } else {
4914 this.canPush = e.type !== "touchmove";
4915 const touchEvent = e;
4916 const lastTouch = touchEvent.touches[touchEvent.touches.length - 1];
4917 const canvasRect = canvas === null || canvas === void 0 ? void 0 : canvas.getBoundingClientRect();
4918 pos = {
4919 x: lastTouch.clientX - ((_f = canvasRect === null || canvasRect === void 0 ? void 0 : canvasRect.left) !== null && _f !== void 0 ? _f : 0),
4920 y: lastTouch.clientY - ((_g = canvasRect === null || canvasRect === void 0 ? void 0 : canvasRect.top) !== null && _g !== void 0 ? _g : 0)
4921 };
4922 }
4923 const pxRatio = container.retina.pixelRatio;
4924 if (pos) {
4925 pos.x *= pxRatio;
4926 pos.y *= pxRatio;
4927 }
4928 container.interactivity.mouse.position = pos;
4929 container.interactivity.status = mouseMoveEvent;
4930 }
4931 mouseTouchFinish() {
4932 const interactivity = this.container.interactivity;
4933 if (!interactivity) {
4934 return;
4935 }
4936 const mouse = interactivity.mouse;
4937 delete mouse.position;
4938 delete mouse.clickPosition;
4939 delete mouse.downPosition;
4940 interactivity.status = mouseLeaveEvent;
4941 mouse.inside = false;
4942 mouse.clicking = false;
4943 }
4944 mouseTouchClick(e) {
4945 const container = this.container, options = container.actualOptions, mouse = container.interactivity.mouse;
4946 mouse.inside = true;
4947 let handled = false;
4948 const mousePosition = mouse.position;
4949 if (!mousePosition || !options.interactivity.events.onClick.enable) {
4950 return;
4951 }
4952 for (const [, plugin] of container.plugins) {
4953 if (!plugin.clickPositionValid) {
4954 continue;
4955 }
4956 handled = plugin.clickPositionValid(mousePosition);
4957 if (handled) {
4958 break;
4959 }
4960 }
4961 if (!handled) {
4962 this.doMouseTouchClick(e);
4963 }
4964 mouse.clicking = false;
4965 }
4966 doMouseTouchClick(e) {
4967 const container = this.container, options = container.actualOptions;
4968 if (this.canPush) {
4969 const mousePos = container.interactivity.mouse.position;
4970 if (!mousePos) {
4971 return;
4972 }
4973 container.interactivity.mouse.clickPosition = {
4974 x: mousePos.x,
4975 y: mousePos.y
4976 };
4977 container.interactivity.mouse.clickTime = (new Date).getTime();
4978 const onClick = options.interactivity.events.onClick;
4979 if (onClick.mode instanceof Array) {
4980 for (const mode of onClick.mode) {
4981 this.handleClickMode(mode);
4982 }
4983 } else {
4984 this.handleClickMode(onClick.mode);
4985 }
4986 }
4987 if (e.type === "touchend") {
4988 setTimeout((() => this.mouseTouchFinish()), 500);
4989 }
4990 }
4991 handleThemeChange(e) {
4992 const mediaEvent = e, themeName = mediaEvent.matches ? this.container.options.defaultDarkTheme : this.container.options.defaultLightTheme, theme = this.container.options.themes.find((theme => theme.name === themeName));
4993 if (theme && theme.default.auto) {
4994 this.container.loadTheme(themeName);
4995 }
4996 }
4997 handleClickMode(mode) {
4998 this.container.handleClickMode(mode);
4999 }
5000 }
5001 class FrameManager {
5002 constructor(container) {
5003 this.container = container;
5004 }
5005 async nextFrame(timestamp) {
5006 var _a;
5007 try {
5008 const container = this.container;
5009 if (container.lastFrameTime !== undefined && timestamp < container.lastFrameTime + 1e3 / container.fpsLimit) {
5010 container.draw(false);
5011 return;
5012 }
5013 (_a = container.lastFrameTime) !== null && _a !== void 0 ? _a : container.lastFrameTime = timestamp;
5014 const deltaValue = timestamp - container.lastFrameTime, delta = {
5015 value: deltaValue,
5016 factor: 60 * deltaValue / 1e3
5017 };
5018 container.lifeTime += delta.value;
5019 container.lastFrameTime = timestamp;
5020 if (deltaValue > 1e3) {
5021 container.draw(false);
5022 return;
5023 }
5024 await container.particles.draw(delta);
5025 if (container.duration > 0 && container.lifeTime > container.duration) {
5026 container.destroy();
5027 return;
5028 }
5029 if (container.getAnimationStatus()) {
5030 container.draw(false);
5031 }
5032 } catch (e) {
5033 console.error("tsParticles error in animation loop", e);
5034 }
5035 }
5036 }
5037 var InteractionManager_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
5038 if (kind === "m") throw new TypeError("Private method is not writable");
5039 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5040 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5041 return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
5042 value;
5043 };
5044 var InteractionManager_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
5045 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
5046 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5047 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5048 };
5049 var _InteractionManager_engine;
5050 class InteractionManager {
5051 constructor(engine, container) {
5052 this.container = container;
5053 _InteractionManager_engine.set(this, void 0);
5054 InteractionManager_classPrivateFieldSet(this, _InteractionManager_engine, engine, "f");
5055 this.externalInteractors = [];
5056 this.particleInteractors = [];
5057 this.init();
5058 }
5059 init() {
5060 const interactors = InteractionManager_classPrivateFieldGet(this, _InteractionManager_engine, "f").plugins.getInteractors(this.container, true);
5061 this.externalInteractors = [];
5062 this.particleInteractors = [];
5063 for (const interactor of interactors) {
5064 switch (interactor.type) {
5065 case 0:
5066 this.externalInteractors.push(interactor);
5067 break;
5068
5069 case 1:
5070 this.particleInteractors.push(interactor);
5071 break;
5072 }
5073 }
5074 }
5075 async externalInteract(delta) {
5076 for (const interactor of this.externalInteractors) {
5077 if (interactor.isEnabled()) {
5078 await interactor.interact(delta);
5079 }
5080 }
5081 }
5082 async particlesInteract(particle, delta) {
5083 for (const interactor of this.externalInteractors) {
5084 interactor.reset(particle);
5085 }
5086 for (const interactor of this.particleInteractors) {
5087 if (interactor.isEnabled(particle)) {
5088 await interactor.interact(particle, delta);
5089 }
5090 }
5091 }
5092 handleClickMode(mode) {
5093 for (const interactor of this.externalInteractors) {
5094 if (interactor.handleClickMode) {
5095 interactor.handleClickMode(mode);
5096 }
5097 }
5098 }
5099 }
5100 _InteractionManager_engine = new WeakMap;
5101 class Vector3d extends Vector {
5102 constructor(xOrCoords, y, z) {
5103 super(xOrCoords, y);
5104 if (typeof xOrCoords !== "number" && xOrCoords) {
5105 this.z = xOrCoords.z;
5106 } else if (z !== undefined) {
5107 this.z = z;
5108 } else {
5109 throw new Error("tsParticles - Vector not initialized correctly");
5110 }
5111 }
5112 static clone(source) {
5113 return Vector3d.create(source.x, source.y, source.z);
5114 }
5115 static create(x, y, z) {
5116 return new Vector3d(x, y, z);
5117 }
5118 static get origin() {
5119 return Vector3d.create(0, 0, 0);
5120 }
5121 add(v) {
5122 return v instanceof Vector3d ? Vector3d.create(this.x + v.x, this.y + v.y, this.z + v.z) : super.add(v);
5123 }
5124 addTo(v) {
5125 super.addTo(v);
5126 if (v instanceof Vector3d) {
5127 this.z += v.z;
5128 }
5129 }
5130 sub(v) {
5131 return v instanceof Vector3d ? Vector3d.create(this.x - v.x, this.y - v.y, this.z - v.z) : super.sub(v);
5132 }
5133 subFrom(v) {
5134 super.subFrom(v);
5135 if (v instanceof Vector3d) {
5136 this.z -= v.z;
5137 }
5138 }
5139 mult(n) {
5140 return Vector3d.create(this.x * n, this.y * n, this.z * n);
5141 }
5142 multTo(n) {
5143 super.multTo(n);
5144 this.z *= n;
5145 }
5146 div(n) {
5147 return Vector3d.create(this.x / n, this.y / n, this.z / n);
5148 }
5149 divTo(n) {
5150 super.divTo(n);
5151 this.z /= n;
5152 }
5153 copy() {
5154 return Vector3d.clone(this);
5155 }
5156 setTo(v) {
5157 super.setTo(v);
5158 const v3d = v;
5159 if (v3d.z !== undefined) {
5160 this.z = v3d.z;
5161 }
5162 }
5163 }
5164 var Particle_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
5165 if (kind === "m") throw new TypeError("Private method is not writable");
5166 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5167 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5168 return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
5169 value;
5170 };
5171 var Particle_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
5172 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
5173 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5174 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5175 };
5176 var _Particle_engine;
5177 const fixOutMode = data => {
5178 if (!(isInArray(data.outMode, data.checkModes) || isInArray(data.outMode, data.checkModes))) {
5179 return;
5180 }
5181 if (data.coord > data.maxCoord - data.radius * 2) {
5182 data.setCb(-data.radius);
5183 } else if (data.coord < data.radius * 2) {
5184 data.setCb(data.radius);
5185 }
5186 };
5187 class Particle {
5188 constructor(engine, id, container, position, overrideOptions, group) {
5189 var _a, _b, _c, _d, _e, _f, _g;
5190 this.id = id;
5191 this.container = container;
5192 this.group = group;
5193 _Particle_engine.set(this, void 0);
5194 Particle_classPrivateFieldSet(this, _Particle_engine, engine, "f");
5195 this.fill = true;
5196 this.close = true;
5197 this.lastPathTime = 0;
5198 this.destroyed = false;
5199 this.unbreakable = false;
5200 this.splitCount = 0;
5201 this.misplaced = false;
5202 this.retina = {
5203 maxDistance: {}
5204 };
5205 this.outType = "normal";
5206 this.ignoresResizeRatio = true;
5207 const pxRatio = container.retina.pixelRatio, mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(mainOptions.particles);
5208 const shapeType = particlesOptions.shape.type, reduceDuplicates = particlesOptions.reduceDuplicates;
5209 this.shape = shapeType instanceof Array ? itemFromArray(shapeType, this.id, reduceDuplicates) : shapeType;
5210 if (overrideOptions === null || overrideOptions === void 0 ? void 0 : overrideOptions.shape) {
5211 if (overrideOptions.shape.type) {
5212 const overrideShapeType = overrideOptions.shape.type;
5213 this.shape = overrideShapeType instanceof Array ? itemFromArray(overrideShapeType, this.id, reduceDuplicates) : overrideShapeType;
5214 }
5215 const shapeOptions = new Shape;
5216 shapeOptions.load(overrideOptions.shape);
5217 if (this.shape) {
5218 this.shapeData = this.loadShapeData(shapeOptions, reduceDuplicates);
5219 }
5220 } else {
5221 this.shapeData = this.loadShapeData(particlesOptions.shape, reduceDuplicates);
5222 }
5223 if (overrideOptions !== undefined) {
5224 particlesOptions.load(overrideOptions);
5225 }
5226 if (((_a = this.shapeData) === null || _a === void 0 ? void 0 : _a.particles) !== undefined) {
5227 particlesOptions.load((_b = this.shapeData) === null || _b === void 0 ? void 0 : _b.particles);
5228 }
5229 this.fill = (_d = (_c = this.shapeData) === null || _c === void 0 ? void 0 : _c.fill) !== null && _d !== void 0 ? _d : this.fill;
5230 this.close = (_f = (_e = this.shapeData) === null || _e === void 0 ? void 0 : _e.close) !== null && _f !== void 0 ? _f : this.close;
5231 this.options = particlesOptions;
5232 this.pathDelay = getValue(this.options.move.path.delay) * 1e3;
5233 const zIndexValue = getRangeValue(this.options.zIndex.value);
5234 container.retina.initParticle(this);
5235 const sizeOptions = this.options.size, sizeRange = sizeOptions.value;
5236 this.size = {
5237 enable: sizeOptions.animation.enable,
5238 value: getRangeValue(sizeOptions.value) * container.retina.pixelRatio,
5239 max: getRangeMax(sizeRange) * pxRatio,
5240 min: getRangeMin(sizeRange) * pxRatio,
5241 loops: 0,
5242 maxLoops: getRangeValue(sizeOptions.animation.count)
5243 };
5244 const sizeAnimation = sizeOptions.animation;
5245 if (sizeAnimation.enable) {
5246 this.size.status = 0;
5247 switch (sizeAnimation.startValue) {
5248 case "min":
5249 this.size.value = this.size.min;
5250 this.size.status = 0;
5251 break;
5252
5253 case "random":
5254 this.size.value = randomInRange(this.size) * pxRatio;
5255 this.size.status = Math.random() >= .5 ? 0 : 1;
5256 break;
5257
5258 case "max":
5259 default:
5260 this.size.value = this.size.max;
5261 this.size.status = 1;
5262 break;
5263 }
5264 this.size.velocity = ((_g = this.retina.sizeAnimationSpeed) !== null && _g !== void 0 ? _g : container.retina.sizeAnimationSpeed) / 100 * container.retina.reduceFactor;
5265 if (!sizeAnimation.sync) {
5266 this.size.velocity *= Math.random();
5267 }
5268 }
5269 this.bubble = {
5270 inRange: false
5271 };
5272 this.position = this.calcPosition(container, position, clamp(zIndexValue, 0, container.zLayers));
5273 this.initialPosition = this.position.copy();
5274 const canvasSize = container.canvas.size, moveCenterPerc = this.options.move.center;
5275 this.moveCenter = {
5276 x: canvasSize.width * moveCenterPerc.x / 100,
5277 y: canvasSize.height * moveCenterPerc.y / 100,
5278 radius: this.options.move.center.radius
5279 };
5280 this.direction = getParticleDirectionAngle(this.options.move.direction, this.position, this.moveCenter);
5281 switch (this.options.move.direction) {
5282 case "inside":
5283 this.outType = "inside";
5284 break;
5285
5286 case "outside":
5287 this.outType = "outside";
5288 break;
5289 }
5290 this.initialVelocity = this.calculateVelocity();
5291 this.velocity = this.initialVelocity.copy();
5292 this.moveDecay = 1 - getRangeValue(this.options.move.decay);
5293 const gravityOptions = this.options.move.gravity;
5294 this.gravity = {
5295 enable: gravityOptions.enable,
5296 acceleration: getRangeValue(gravityOptions.acceleration),
5297 inverse: gravityOptions.inverse
5298 };
5299 this.offset = Vector.origin;
5300 const particles = container.particles;
5301 particles.needsSort = particles.needsSort || particles.lastZIndex < this.position.z;
5302 particles.lastZIndex = this.position.z;
5303 this.zIndexFactor = this.position.z / container.zLayers;
5304 this.sides = 24;
5305 let drawer = container.drawers.get(this.shape);
5306 if (!drawer) {
5307 drawer = Particle_classPrivateFieldGet(this, _Particle_engine, "f").plugins.getShapeDrawer(this.shape);
5308 if (drawer) {
5309 container.drawers.set(this.shape, drawer);
5310 }
5311 }
5312 if (drawer === null || drawer === void 0 ? void 0 : drawer.loadShape) {
5313 drawer === null || drawer === void 0 ? void 0 : drawer.loadShape(this);
5314 }
5315 const sideCountFunc = drawer === null || drawer === void 0 ? void 0 : drawer.getSidesCount;
5316 if (sideCountFunc) {
5317 this.sides = sideCountFunc(this);
5318 }
5319 this.life = this.loadLife();
5320 this.spawning = this.life.delay > 0;
5321 this.shadowColor = colorToRgb(this.options.shadow.color);
5322 for (const updater of container.particles.updaters) {
5323 if (updater.init) {
5324 updater.init(this);
5325 }
5326 }
5327 for (const mover of container.particles.movers) {
5328 if (mover.init) {
5329 mover.init(this);
5330 }
5331 }
5332 if (drawer && drawer.particleInit) {
5333 drawer.particleInit(container, this);
5334 }
5335 for (const [, plugin] of container.plugins) {
5336 if (plugin.particleCreated) {
5337 plugin.particleCreated(this);
5338 }
5339 }
5340 }
5341 isVisible() {
5342 return !this.destroyed && !this.spawning && this.isInsideCanvas();
5343 }
5344 isInsideCanvas() {
5345 const radius = this.getRadius(), canvasSize = this.container.canvas.size;
5346 return this.position.x >= -radius && this.position.y >= -radius && this.position.y <= canvasSize.height + radius && this.position.x <= canvasSize.width + radius;
5347 }
5348 draw(delta) {
5349 const container = this.container;
5350 for (const [, plugin] of container.plugins) {
5351 container.canvas.drawParticlePlugin(plugin, this, delta);
5352 }
5353 container.canvas.drawParticle(this, delta);
5354 }
5355 getPosition() {
5356 return {
5357 x: this.position.x + this.offset.x,
5358 y: this.position.y + this.offset.y,
5359 z: this.position.z
5360 };
5361 }
5362 getRadius() {
5363 var _a;
5364 return (_a = this.bubble.radius) !== null && _a !== void 0 ? _a : this.size.value;
5365 }
5366 getMass() {
5367 return this.getRadius() ** 2 * Math.PI / 2;
5368 }
5369 getFillColor() {
5370 var _a, _b;
5371 const color = (_a = this.bubble.color) !== null && _a !== void 0 ? _a : getHslFromAnimation(this.color);
5372 if (color && this.roll && (this.backColor || this.roll.alter)) {
5373 const backFactor = this.options.roll.mode === "both" ? 2 : 1, backSum = this.options.roll.mode === "horizontal" ? Math.PI / 2 : 0, rolled = Math.floor((((_b = this.roll.angle) !== null && _b !== void 0 ? _b : 0) + backSum) / (Math.PI / backFactor)) % 2;
5374 if (rolled) {
5375 if (this.backColor) {
5376 return this.backColor;
5377 }
5378 if (this.roll.alter) {
5379 return alterHsl(color, this.roll.alter.type, this.roll.alter.value);
5380 }
5381 }
5382 }
5383 return color;
5384 }
5385 getStrokeColor() {
5386 var _a, _b;
5387 return (_b = (_a = this.bubble.color) !== null && _a !== void 0 ? _a : getHslFromAnimation(this.strokeColor)) !== null && _b !== void 0 ? _b : this.getFillColor();
5388 }
5389 destroy(override) {
5390 this.destroyed = true;
5391 this.bubble.inRange = false;
5392 if (this.unbreakable) {
5393 return;
5394 }
5395 this.destroyed = true;
5396 this.bubble.inRange = false;
5397 for (const [, plugin] of this.container.plugins) {
5398 if (plugin.particleDestroyed) {
5399 plugin.particleDestroyed(this, override);
5400 }
5401 }
5402 if (override) {
5403 return;
5404 }
5405 const destroyOptions = this.options.destroy;
5406 if (destroyOptions.mode === "split") {
5407 this.split();
5408 }
5409 }
5410 reset() {
5411 if (this.opacity) {
5412 this.opacity.loops = 0;
5413 }
5414 this.size.loops = 0;
5415 }
5416 split() {
5417 const splitOptions = this.options.destroy.split;
5418 if (splitOptions.count >= 0 && this.splitCount++ > splitOptions.count) {
5419 return;
5420 }
5421 const rate = getValue(splitOptions.rate);
5422 for (let i = 0; i < rate; i++) {
5423 this.container.particles.addSplitParticle(this);
5424 }
5425 }
5426 calcPosition(container, position, zIndex, tryCount = 0) {
5427 var _a, _b, _c, _d;
5428 for (const [, plugin] of container.plugins) {
5429 const pluginPos = plugin.particlePosition !== undefined ? plugin.particlePosition(position, this) : undefined;
5430 if (pluginPos !== undefined) {
5431 return Vector3d.create(pluginPos.x, pluginPos.y, zIndex);
5432 }
5433 }
5434 const canvasSize = container.canvas.size, exactPosition = calcExactPositionOrRandomFromSize({
5435 size: canvasSize,
5436 position: position
5437 }), pos = Vector3d.create(exactPosition.x, exactPosition.y, zIndex), radius = this.getRadius(), outModes = this.options.move.outModes, fixHorizontal = outMode => {
5438 fixOutMode({
5439 outMode: outMode,
5440 checkModes: [ "bounce", "bounce-horizontal" ],
5441 coord: pos.x,
5442 maxCoord: container.canvas.size.width,
5443 setCb: value => pos.x += value,
5444 radius: radius
5445 });
5446 }, fixVertical = outMode => {
5447 fixOutMode({
5448 outMode: outMode,
5449 checkModes: [ "bounce", "bounce-vertical" ],
5450 coord: pos.y,
5451 maxCoord: container.canvas.size.height,
5452 setCb: value => pos.y += value,
5453 radius: radius
5454 });
5455 };
5456 fixHorizontal((_a = outModes.left) !== null && _a !== void 0 ? _a : outModes.default);
5457 fixHorizontal((_b = outModes.right) !== null && _b !== void 0 ? _b : outModes.default);
5458 fixVertical((_c = outModes.top) !== null && _c !== void 0 ? _c : outModes.default);
5459 fixVertical((_d = outModes.bottom) !== null && _d !== void 0 ? _d : outModes.default);
5460 if (this.checkOverlap(pos, tryCount)) {
5461 return this.calcPosition(container, undefined, zIndex, tryCount + 1);
5462 }
5463 return pos;
5464 }
5465 checkOverlap(pos, tryCount = 0) {
5466 const collisionsOptions = this.options.collisions, radius = this.getRadius();
5467 if (!collisionsOptions.enable) {
5468 return false;
5469 }
5470 const overlapOptions = collisionsOptions.overlap;
5471 if (overlapOptions.enable) {
5472 return false;
5473 }
5474 const retries = overlapOptions.retries;
5475 if (retries >= 0 && tryCount > retries) {
5476 throw new Error("Particle is overlapping and can't be placed");
5477 }
5478 let overlaps = false;
5479 for (const particle of this.container.particles.array) {
5480 if (getDistance(pos, particle.position) < radius + particle.getRadius()) {
5481 overlaps = true;
5482 break;
5483 }
5484 }
5485 return overlaps;
5486 }
5487 calculateVelocity() {
5488 const baseVelocity = getParticleBaseVelocity(this.direction);
5489 const res = baseVelocity.copy();
5490 const moveOptions = this.options.move;
5491 if (moveOptions.direction === "inside" || moveOptions.direction === "outside") {
5492 return res;
5493 }
5494 const rad = Math.PI / 180 * getRangeValue(moveOptions.angle.value);
5495 const radOffset = Math.PI / 180 * getRangeValue(moveOptions.angle.offset);
5496 const range = {
5497 left: radOffset - rad / 2,
5498 right: radOffset + rad / 2
5499 };
5500 if (!moveOptions.straight) {
5501 res.angle += randomInRange(setRangeValue(range.left, range.right));
5502 }
5503 if (moveOptions.random && typeof moveOptions.speed === "number") {
5504 res.length *= Math.random();
5505 }
5506 return res;
5507 }
5508 loadShapeData(shapeOptions, reduceDuplicates) {
5509 const shapeData = shapeOptions.options[this.shape];
5510 if (shapeData) {
5511 return deepExtend({}, shapeData instanceof Array ? itemFromArray(shapeData, this.id, reduceDuplicates) : shapeData);
5512 }
5513 }
5514 loadLife() {
5515 const container = this.container, particlesOptions = this.options, lifeOptions = particlesOptions.life, life = {
5516 delay: container.retina.reduceFactor ? getRangeValue(lifeOptions.delay.value) * (lifeOptions.delay.sync ? 1 : Math.random()) / container.retina.reduceFactor * 1e3 : 0,
5517 delayTime: 0,
5518 duration: container.retina.reduceFactor ? getRangeValue(lifeOptions.duration.value) * (lifeOptions.duration.sync ? 1 : Math.random()) / container.retina.reduceFactor * 1e3 : 0,
5519 time: 0,
5520 count: particlesOptions.life.count
5521 };
5522 if (life.duration <= 0) {
5523 life.duration = -1;
5524 }
5525 if (life.count <= 0) {
5526 life.count = -1;
5527 }
5528 return life;
5529 }
5530 }
5531 _Particle_engine = new WeakMap;
5532 class Point {
5533 constructor(position, particle) {
5534 this.position = position;
5535 this.particle = particle;
5536 }
5537 }
5538 class Range {
5539 constructor(x, y) {
5540 this.position = {
5541 x: x,
5542 y: y
5543 };
5544 }
5545 }
5546 class Circle extends Range {
5547 constructor(x, y, radius) {
5548 super(x, y);
5549 this.radius = radius;
5550 }
5551 contains(point) {
5552 return getDistance(point, this.position) <= this.radius;
5553 }
5554 intersects(range) {
5555 const rect = range, circle = range, pos1 = this.position, pos2 = range.position, xDist = Math.abs(pos2.x - pos1.x), yDist = Math.abs(pos2.y - pos1.y), r = this.radius;
5556 if (circle.radius !== undefined) {
5557 const rSum = r + circle.radius, dist = Math.sqrt(xDist * xDist + yDist + yDist);
5558 return rSum > dist;
5559 } else if (rect.size !== undefined) {
5560 const w = rect.size.width, h = rect.size.height, edges = Math.pow(xDist - w, 2) + Math.pow(yDist - h, 2);
5561 if (xDist > r + w || yDist > r + h) {
5562 return false;
5563 }
5564 if (xDist <= w || yDist <= h) {
5565 return true;
5566 }
5567 return edges <= r * r;
5568 }
5569 return false;
5570 }
5571 }
5572 class Rectangle extends Range {
5573 constructor(x, y, width, height) {
5574 super(x, y);
5575 this.size = {
5576 height: height,
5577 width: width
5578 };
5579 }
5580 contains(point) {
5581 const w = this.size.width, h = this.size.height, pos = this.position;
5582 return point.x >= pos.x && point.x <= pos.x + w && point.y >= pos.y && point.y <= pos.y + h;
5583 }
5584 intersects(range) {
5585 const rect = range, circle = range, w = this.size.width, h = this.size.height, pos1 = this.position, pos2 = range.position;
5586 if (circle.radius !== undefined) {
5587 return circle.intersects(this);
5588 }
5589 if (!rect.size) {
5590 return false;
5591 }
5592 const size2 = rect.size, w2 = size2.width, h2 = size2.height;
5593 return pos2.x < pos1.x + w && pos2.x + w2 > pos1.x && pos2.y < pos1.y + h && pos2.y + h2 > pos1.y;
5594 }
5595 }
5596 class CircleWarp extends Circle {
5597 constructor(x, y, radius, canvasSize) {
5598 super(x, y, radius);
5599 this.canvasSize = canvasSize;
5600 this.canvasSize = Object.assign({}, canvasSize);
5601 }
5602 contains(point) {
5603 if (super.contains(point)) {
5604 return true;
5605 }
5606 const posNE = {
5607 x: point.x - this.canvasSize.width,
5608 y: point.y
5609 };
5610 if (super.contains(posNE)) {
5611 return true;
5612 }
5613 const posSE = {
5614 x: point.x - this.canvasSize.width,
5615 y: point.y - this.canvasSize.height
5616 };
5617 if (super.contains(posSE)) {
5618 return true;
5619 }
5620 const posSW = {
5621 x: point.x,
5622 y: point.y - this.canvasSize.height
5623 };
5624 return super.contains(posSW);
5625 }
5626 intersects(range) {
5627 if (super.intersects(range)) {
5628 return true;
5629 }
5630 const rect = range, circle = range, newPos = {
5631 x: range.position.x - this.canvasSize.width,
5632 y: range.position.y - this.canvasSize.height
5633 };
5634 if (circle.radius !== undefined) {
5635 const biggerCircle = new Circle(newPos.x, newPos.y, circle.radius * 2);
5636 return super.intersects(biggerCircle);
5637 } else if (rect.size !== undefined) {
5638 const rectSW = new Rectangle(newPos.x, newPos.y, rect.size.width * 2, rect.size.height * 2);
5639 return super.intersects(rectSW);
5640 }
5641 return false;
5642 }
5643 }
5644 class QuadTree {
5645 constructor(rectangle, capacity) {
5646 this.rectangle = rectangle;
5647 this.capacity = capacity;
5648 this.points = [];
5649 this.divided = false;
5650 }
5651 insert(point) {
5652 var _a, _b, _c, _d, _e;
5653 if (!this.rectangle.contains(point.position)) {
5654 return false;
5655 }
5656 if (this.points.length < this.capacity) {
5657 this.points.push(point);
5658 return true;
5659 }
5660 if (!this.divided) {
5661 this.subdivide();
5662 }
5663 return (_e = ((_a = this.northEast) === null || _a === void 0 ? void 0 : _a.insert(point)) || ((_b = this.northWest) === null || _b === void 0 ? void 0 : _b.insert(point)) || ((_c = this.southEast) === null || _c === void 0 ? void 0 : _c.insert(point)) || ((_d = this.southWest) === null || _d === void 0 ? void 0 : _d.insert(point))) !== null && _e !== void 0 ? _e : false;
5664 }
5665 queryCircle(position, radius) {
5666 return this.query(new Circle(position.x, position.y, radius));
5667 }
5668 queryCircleWarp(position, radius, containerOrSize) {
5669 const container = containerOrSize, size = containerOrSize;
5670 return this.query(new CircleWarp(position.x, position.y, radius, container.canvas !== undefined ? container.canvas.size : size));
5671 }
5672 queryRectangle(position, size) {
5673 return this.query(new Rectangle(position.x, position.y, size.width, size.height));
5674 }
5675 query(range, found) {
5676 var _a, _b, _c, _d;
5677 const res = found !== null && found !== void 0 ? found : [];
5678 if (!range.intersects(this.rectangle)) {
5679 return [];
5680 }
5681 for (const p of this.points) {
5682 if (!range.contains(p.position) && getDistance(range.position, p.position) > p.particle.getRadius()) {
5683 continue;
5684 }
5685 res.push(p.particle);
5686 }
5687 if (this.divided) {
5688 (_a = this.northEast) === null || _a === void 0 ? void 0 : _a.query(range, res);
5689 (_b = this.northWest) === null || _b === void 0 ? void 0 : _b.query(range, res);
5690 (_c = this.southEast) === null || _c === void 0 ? void 0 : _c.query(range, res);
5691 (_d = this.southWest) === null || _d === void 0 ? void 0 : _d.query(range, res);
5692 }
5693 return res;
5694 }
5695 subdivide() {
5696 const x = this.rectangle.position.x, y = this.rectangle.position.y, w = this.rectangle.size.width, h = this.rectangle.size.height, capacity = this.capacity;
5697 this.northEast = new QuadTree(new Rectangle(x, y, w / 2, h / 2), capacity);
5698 this.northWest = new QuadTree(new Rectangle(x + w / 2, y, w / 2, h / 2), capacity);
5699 this.southEast = new QuadTree(new Rectangle(x, y + h / 2, w / 2, h / 2), capacity);
5700 this.southWest = new QuadTree(new Rectangle(x + w / 2, y + h / 2, w / 2, h / 2), capacity);
5701 this.divided = true;
5702 }
5703 }
5704 var Particles_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
5705 if (kind === "m") throw new TypeError("Private method is not writable");
5706 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5707 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5708 return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
5709 value;
5710 };
5711 var Particles_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
5712 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
5713 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5714 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5715 };
5716 var _Particles_engine;
5717 class Particles {
5718 constructor(engine, container) {
5719 this.container = container;
5720 _Particles_engine.set(this, void 0);
5721 Particles_classPrivateFieldSet(this, _Particles_engine, engine, "f");
5722 this.nextId = 0;
5723 this.array = [];
5724 this.zArray = [];
5725 this.limit = 0;
5726 this.needsSort = false;
5727 this.lastZIndex = 0;
5728 this.freqs = {
5729 links: new Map,
5730 triangles: new Map
5731 };
5732 this.interactionManager = new InteractionManager(Particles_classPrivateFieldGet(this, _Particles_engine, "f"), container);
5733 const canvasSize = this.container.canvas.size;
5734 this.linksColors = new Map;
5735 this.quadTree = new QuadTree(new Rectangle(-canvasSize.width / 4, -canvasSize.height / 4, canvasSize.width * 3 / 2, canvasSize.height * 3 / 2), 4);
5736 this.movers = Particles_classPrivateFieldGet(this, _Particles_engine, "f").plugins.getMovers(container, true);
5737 this.updaters = Particles_classPrivateFieldGet(this, _Particles_engine, "f").plugins.getUpdaters(container, true);
5738 }
5739 get count() {
5740 return this.array.length;
5741 }
5742 init() {
5743 var _a;
5744 const container = this.container, options = container.actualOptions;
5745 this.lastZIndex = 0;
5746 this.needsSort = false;
5747 this.freqs.links = new Map;
5748 this.freqs.triangles = new Map;
5749 let handled = false;
5750 this.updaters = Particles_classPrivateFieldGet(this, _Particles_engine, "f").plugins.getUpdaters(container, true);
5751 this.interactionManager.init();
5752 for (const [, plugin] of container.plugins) {
5753 if (plugin.particlesInitialization !== undefined) {
5754 handled = plugin.particlesInitialization();
5755 }
5756 if (handled) {
5757 break;
5758 }
5759 }
5760 this.addManualParticles();
5761 if (!handled) {
5762 for (const group in options.particles.groups) {
5763 const groupOptions = options.particles.groups[group];
5764 for (let i = this.count, j = 0; j < ((_a = groupOptions.number) === null || _a === void 0 ? void 0 : _a.value) && i < options.particles.number.value; i++,
5765 j++) {
5766 this.addParticle(undefined, groupOptions, group);
5767 }
5768 }
5769 for (let i = this.count; i < options.particles.number.value; i++) {
5770 this.addParticle();
5771 }
5772 }
5773 container.pathGenerator.init(container);
5774 }
5775 async redraw() {
5776 this.clear();
5777 this.init();
5778 await this.draw({
5779 value: 0,
5780 factor: 0
5781 });
5782 }
5783 removeAt(index, quantity = 1, group, override) {
5784 if (!(index >= 0 && index <= this.count)) {
5785 return;
5786 }
5787 let deleted = 0;
5788 for (let i = index; deleted < quantity && i < this.count; i++) {
5789 const particle = this.array[i];
5790 if (!particle || particle.group !== group) {
5791 continue;
5792 }
5793 particle.destroy(override);
5794 this.array.splice(i--, 1);
5795 const zIdx = this.zArray.indexOf(particle);
5796 this.zArray.splice(zIdx, 1);
5797 deleted++;
5798 Particles_classPrivateFieldGet(this, _Particles_engine, "f").dispatchEvent("particleRemoved", {
5799 container: this.container,
5800 data: {
5801 particle: particle
5802 }
5803 });
5804 }
5805 }
5806 remove(particle, group, override) {
5807 this.removeAt(this.array.indexOf(particle), undefined, group, override);
5808 }
5809 async update(delta) {
5810 const container = this.container, particlesToDelete = [];
5811 container.pathGenerator.update();
5812 for (const [, plugin] of container.plugins) {
5813 if (plugin.update !== undefined) {
5814 plugin.update(delta);
5815 }
5816 }
5817 for (const particle of this.array) {
5818 const resizeFactor = container.canvas.resizeFactor;
5819 if (resizeFactor && !particle.ignoresResizeRatio) {
5820 particle.position.x *= resizeFactor.width;
5821 particle.position.y *= resizeFactor.height;
5822 }
5823 particle.ignoresResizeRatio = false;
5824 particle.bubble.inRange = false;
5825 for (const [, plugin] of this.container.plugins) {
5826 if (particle.destroyed) {
5827 break;
5828 }
5829 if (plugin.particleUpdate) {
5830 plugin.particleUpdate(particle, delta);
5831 }
5832 }
5833 for (const mover of this.movers) {
5834 if (mover.isEnabled(particle)) {
5835 mover.move(particle, delta);
5836 }
5837 }
5838 if (particle.destroyed) {
5839 particlesToDelete.push(particle);
5840 continue;
5841 }
5842 this.quadTree.insert(new Point(particle.getPosition(), particle));
5843 }
5844 for (const particle of particlesToDelete) {
5845 this.remove(particle);
5846 }
5847 await this.interactionManager.externalInteract(delta);
5848 for (const particle of container.particles.array) {
5849 for (const updater of this.updaters) {
5850 updater.update(particle, delta);
5851 }
5852 if (!particle.destroyed && !particle.spawning) {
5853 await this.interactionManager.particlesInteract(particle, delta);
5854 }
5855 }
5856 delete container.canvas.resizeFactor;
5857 }
5858 async draw(delta) {
5859 const container = this.container, canvasSize = this.container.canvas.size;
5860 this.quadTree = new QuadTree(new Rectangle(-canvasSize.width / 4, -canvasSize.height / 4, canvasSize.width * 3 / 2, canvasSize.height * 3 / 2), 4);
5861 container.canvas.clear();
5862 await this.update(delta);
5863 if (this.needsSort) {
5864 this.zArray.sort(((a, b) => b.position.z - a.position.z || a.id - b.id));
5865 this.lastZIndex = this.zArray[this.zArray.length - 1].position.z;
5866 this.needsSort = false;
5867 }
5868 for (const [, plugin] of container.plugins) {
5869 container.canvas.drawPlugin(plugin, delta);
5870 }
5871 for (const p of this.zArray) {
5872 p.draw(delta);
5873 }
5874 }
5875 clear() {
5876 this.array = [];
5877 this.zArray = [];
5878 }
5879 push(nb, mouse, overrideOptions, group) {
5880 this.pushing = true;
5881 for (let i = 0; i < nb; i++) {
5882 this.addParticle(mouse === null || mouse === void 0 ? void 0 : mouse.position, overrideOptions, group);
5883 }
5884 this.pushing = false;
5885 }
5886 addParticle(position, overrideOptions, group) {
5887 const container = this.container, options = container.actualOptions, limit = options.particles.number.limit * container.density;
5888 if (limit > 0) {
5889 const countToRemove = this.count + 1 - limit;
5890 if (countToRemove > 0) {
5891 this.removeQuantity(countToRemove);
5892 }
5893 }
5894 return this.pushParticle(position, overrideOptions, group);
5895 }
5896 addSplitParticle(parent) {
5897 const splitOptions = parent.options.destroy.split;
5898 const options = loadParticlesOptions(parent.options);
5899 const factor = getValue(splitOptions.factor);
5900 options.color.load({
5901 value: {
5902 hsl: parent.getFillColor()
5903 }
5904 });
5905 if (typeof options.size.value === "number") {
5906 options.size.value /= factor;
5907 } else {
5908 options.size.value.min /= factor;
5909 options.size.value.max /= factor;
5910 }
5911 options.load(splitOptions.particles);
5912 const offset = splitOptions.sizeOffset ? setRangeValue(-parent.size.value, parent.size.value) : 0, position = {
5913 x: parent.position.x + randomInRange(offset),
5914 y: parent.position.y + randomInRange(offset)
5915 };
5916 return this.pushParticle(position, options, parent.group, (particle => {
5917 if (particle.size.value < .5) {
5918 return false;
5919 }
5920 particle.velocity.length = randomInRange(setRangeValue(parent.velocity.length, particle.velocity.length));
5921 particle.splitCount = parent.splitCount + 1;
5922 particle.unbreakable = true;
5923 setTimeout((() => {
5924 particle.unbreakable = false;
5925 }), 500);
5926 return true;
5927 }));
5928 }
5929 removeQuantity(quantity, group) {
5930 this.removeAt(0, quantity, group);
5931 }
5932 getLinkFrequency(p1, p2) {
5933 const range = setRangeValue(p1.id, p2.id), key = `${getRangeMin(range)}_${getRangeMax(range)}`;
5934 let res = this.freqs.links.get(key);
5935 if (res === undefined) {
5936 res = Math.random();
5937 this.freqs.links.set(key, res);
5938 }
5939 return res;
5940 }
5941 getTriangleFrequency(p1, p2, p3) {
5942 let [id1, id2, id3] = [ p1.id, p2.id, p3.id ];
5943 if (id1 > id2) {
5944 [id2, id1] = [ id1, id2 ];
5945 }
5946 if (id2 > id3) {
5947 [id3, id2] = [ id2, id3 ];
5948 }
5949 if (id1 > id3) {
5950 [id3, id1] = [ id1, id3 ];
5951 }
5952 const key = `${id1}_${id2}_${id3}`;
5953 let res = this.freqs.triangles.get(key);
5954 if (res === undefined) {
5955 res = Math.random();
5956 this.freqs.triangles.set(key, res);
5957 }
5958 return res;
5959 }
5960 addManualParticles() {
5961 const container = this.container, options = container.actualOptions;
5962 for (const particle of options.manualParticles) {
5963 this.addParticle(calcPositionFromSize({
5964 size: container.canvas.size,
5965 position: particle.position
5966 }), particle.options);
5967 }
5968 }
5969 setDensity() {
5970 const options = this.container.actualOptions;
5971 for (const group in options.particles.groups) {
5972 this.applyDensity(options.particles.groups[group], 0, group);
5973 }
5974 this.applyDensity(options.particles, options.manualParticles.length);
5975 }
5976 handleClickMode(mode) {
5977 this.interactionManager.handleClickMode(mode);
5978 }
5979 applyDensity(options, manualCount, group) {
5980 var _a;
5981 if (!((_a = options.number.density) === null || _a === void 0 ? void 0 : _a.enable)) {
5982 return;
5983 }
5984 const numberOptions = options.number, densityFactor = this.initDensityFactor(numberOptions.density), optParticlesNumber = numberOptions.value, optParticlesLimit = numberOptions.limit > 0 ? numberOptions.limit : optParticlesNumber, particlesNumber = Math.min(optParticlesNumber, optParticlesLimit) * densityFactor + manualCount, particlesCount = Math.min(this.count, this.array.filter((t => t.group === group)).length);
5985 this.limit = numberOptions.limit * densityFactor;
5986 if (particlesCount < particlesNumber) {
5987 this.push(Math.abs(particlesNumber - particlesCount), undefined, options, group);
5988 } else if (particlesCount > particlesNumber) {
5989 this.removeQuantity(particlesCount - particlesNumber, group);
5990 }
5991 }
5992 initDensityFactor(densityOptions) {
5993 const container = this.container;
5994 if (!container.canvas.element || !densityOptions.enable) {
5995 return 1;
5996 }
5997 const canvas = container.canvas.element, pxRatio = container.retina.pixelRatio;
5998 return canvas.width * canvas.height / (densityOptions.factor * pxRatio ** 2 * densityOptions.area);
5999 }
6000 pushParticle(position, overrideOptions, group, initializer) {
6001 try {
6002 const particle = new Particle(Particles_classPrivateFieldGet(this, _Particles_engine, "f"), this.nextId, this.container, position, overrideOptions, group);
6003 let canAdd = true;
6004 if (initializer) {
6005 canAdd = initializer(particle);
6006 }
6007 if (!canAdd) {
6008 return;
6009 }
6010 this.array.push(particle);
6011 this.zArray.push(particle);
6012 this.nextId++;
6013 Particles_classPrivateFieldGet(this, _Particles_engine, "f").dispatchEvent("particleAdded", {
6014 container: this.container,
6015 data: {
6016 particle: particle
6017 }
6018 });
6019 return particle;
6020 } catch (e) {
6021 console.warn(`error adding particle: ${e}`);
6022 return;
6023 }
6024 }
6025 }
6026 _Particles_engine = new WeakMap;
6027 class Retina {
6028 constructor(container) {
6029 this.container = container;
6030 }
6031 init() {
6032 const container = this.container, options = container.actualOptions;
6033 this.pixelRatio = !options.detectRetina || isSsr() ? 1 : window.devicePixelRatio;
6034 const motionOptions = this.container.actualOptions.motion;
6035 if (motionOptions && (motionOptions.disable || motionOptions.reduce.value)) {
6036 if (isSsr() || typeof matchMedia === "undefined" || !matchMedia) {
6037 this.reduceFactor = 1;
6038 } else {
6039 const mediaQuery = matchMedia("(prefers-reduced-motion: reduce)");
6040 if (mediaQuery) {
6041 this.handleMotionChange(mediaQuery);
6042 const handleChange = () => {
6043 this.handleMotionChange(mediaQuery);
6044 container.refresh().catch((() => {}));
6045 };
6046 if (mediaQuery.addEventListener !== undefined) {
6047 mediaQuery.addEventListener("change", handleChange);
6048 } else if (mediaQuery.addListener !== undefined) {
6049 mediaQuery.addListener(handleChange);
6050 }
6051 }
6052 }
6053 } else {
6054 this.reduceFactor = 1;
6055 }
6056 const ratio = this.pixelRatio;
6057 if (container.canvas.element) {
6058 const element = container.canvas.element;
6059 container.canvas.size.width = element.offsetWidth * ratio;
6060 container.canvas.size.height = element.offsetHeight * ratio;
6061 }
6062 const particles = options.particles;
6063 this.attractDistance = getRangeValue(particles.move.attract.distance) * ratio;
6064 this.linksDistance = particles.links.distance * ratio;
6065 this.linksWidth = particles.links.width * ratio;
6066 this.sizeAnimationSpeed = getRangeValue(particles.size.animation.speed) * ratio;
6067 this.maxSpeed = getRangeValue(particles.move.gravity.maxSpeed) * ratio;
6068 const modes = options.interactivity.modes;
6069 this.connectModeDistance = modes.connect.distance * ratio;
6070 this.connectModeRadius = modes.connect.radius * ratio;
6071 this.grabModeDistance = modes.grab.distance * ratio;
6072 this.repulseModeDistance = modes.repulse.distance * ratio;
6073 this.bounceModeDistance = modes.bounce.distance * ratio;
6074 this.attractModeDistance = modes.attract.distance * ratio;
6075 this.slowModeRadius = modes.slow.radius * ratio;
6076 this.bubbleModeDistance = modes.bubble.distance * ratio;
6077 if (modes.bubble.size) {
6078 this.bubbleModeSize = modes.bubble.size * ratio;
6079 }
6080 }
6081 initParticle(particle) {
6082 const options = particle.options, ratio = this.pixelRatio, moveDistance = options.move.distance, props = particle.retina;
6083 props.attractDistance = getRangeValue(options.move.attract.distance) * ratio;
6084 props.linksDistance = options.links.distance * ratio;
6085 props.linksWidth = options.links.width * ratio;
6086 props.moveDrift = getRangeValue(options.move.drift) * ratio;
6087 props.moveSpeed = getRangeValue(options.move.speed) * ratio;
6088 props.sizeAnimationSpeed = getRangeValue(options.size.animation.speed) * ratio;
6089 const maxDistance = props.maxDistance;
6090 maxDistance.horizontal = moveDistance.horizontal !== undefined ? moveDistance.horizontal * ratio : undefined;
6091 maxDistance.vertical = moveDistance.vertical !== undefined ? moveDistance.vertical * ratio : undefined;
6092 props.maxSpeed = getRangeValue(options.move.gravity.maxSpeed) * ratio;
6093 }
6094 handleMotionChange(mediaQuery) {
6095 const options = this.container.actualOptions;
6096 if (mediaQuery.matches) {
6097 const motion = options.motion;
6098 this.reduceFactor = motion.disable ? 0 : motion.reduce.value ? 1 / motion.reduce.factor : 1;
6099 } else {
6100 this.reduceFactor = 1;
6101 }
6102 }
6103 }
6104 var Container_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
6105 if (kind === "m") throw new TypeError("Private method is not writable");
6106 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
6107 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6108 return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
6109 value;
6110 };
6111 var Container_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
6112 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
6113 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
6114 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6115 };
6116 var _Container_engine;
6117 class Container {
6118 constructor(engine, id, sourceOptions) {
6119 this.id = id;
6120 _Container_engine.set(this, void 0);
6121 Container_classPrivateFieldSet(this, _Container_engine, engine, "f");
6122 this.fpsLimit = 120;
6123 this.duration = 0;
6124 this.lifeTime = 0;
6125 this.firstStart = true;
6126 this.started = false;
6127 this.destroyed = false;
6128 this.paused = true;
6129 this.lastFrameTime = 0;
6130 this.zLayers = 100;
6131 this.pageHidden = false;
6132 this._sourceOptions = sourceOptions;
6133 this._initialSourceOptions = sourceOptions;
6134 this.retina = new Retina(this);
6135 this.canvas = new Canvas(this);
6136 this.particles = new Particles(Container_classPrivateFieldGet(this, _Container_engine, "f"), this);
6137 this.drawer = new FrameManager(this);
6138 this.pathGenerator = {
6139 generate: p => {
6140 const v = p.velocity.copy();
6141 v.angle += v.length * Math.PI / 180;
6142 return v;
6143 },
6144 init: () => {},
6145 update: () => {}
6146 };
6147 this.interactivity = {
6148 mouse: {
6149 clicking: false,
6150 inside: false
6151 }
6152 };
6153 this.plugins = new Map;
6154 this.drawers = new Map;
6155 this.density = 1;
6156 this._options = loadContainerOptions(Container_classPrivateFieldGet(this, _Container_engine, "f"));
6157 this.actualOptions = loadContainerOptions(Container_classPrivateFieldGet(this, _Container_engine, "f"));
6158 this.eventListeners = new EventListeners(this);
6159 if (typeof IntersectionObserver !== "undefined" && IntersectionObserver) {
6160 this.intersectionObserver = new IntersectionObserver((entries => this.intersectionManager(entries)));
6161 }
6162 Container_classPrivateFieldGet(this, _Container_engine, "f").dispatchEvent("containerBuilt", {
6163 container: this
6164 });
6165 }
6166 get options() {
6167 return this._options;
6168 }
6169 get sourceOptions() {
6170 return this._sourceOptions;
6171 }
6172 play(force) {
6173 const needsUpdate = this.paused || force;
6174 if (this.firstStart && !this.actualOptions.autoPlay) {
6175 this.firstStart = false;
6176 return;
6177 }
6178 if (this.paused) {
6179 this.paused = false;
6180 }
6181 if (needsUpdate) {
6182 for (const [, plugin] of this.plugins) {
6183 if (plugin.play) {
6184 plugin.play();
6185 }
6186 }
6187 }
6188 Container_classPrivateFieldGet(this, _Container_engine, "f").dispatchEvent("containerPlay", {
6189 container: this
6190 });
6191 this.draw(needsUpdate || false);
6192 }
6193 pause() {
6194 if (this.drawAnimationFrame !== undefined) {
6195 cancelAnimation()(this.drawAnimationFrame);
6196 delete this.drawAnimationFrame;
6197 }
6198 if (this.paused) {
6199 return;
6200 }
6201 for (const [, plugin] of this.plugins) {
6202 if (plugin.pause) {
6203 plugin.pause();
6204 }
6205 }
6206 if (!this.pageHidden) {
6207 this.paused = true;
6208 }
6209 Container_classPrivateFieldGet(this, _Container_engine, "f").dispatchEvent("containerPaused", {
6210 container: this
6211 });
6212 }
6213 draw(force) {
6214 let refreshTime = force;
6215 this.drawAnimationFrame = animate()((async timestamp => {
6216 if (refreshTime) {
6217 this.lastFrameTime = undefined;
6218 refreshTime = false;
6219 }
6220 await this.drawer.nextFrame(timestamp);
6221 }));
6222 }
6223 getAnimationStatus() {
6224 return !this.paused && !this.pageHidden;
6225 }
6226 setNoise(noiseOrGenerator, init, update) {
6227 this.setPath(noiseOrGenerator, init, update);
6228 }
6229 setPath(pathOrGenerator, init, update) {
6230 var _a, _b, _c;
6231 if (!pathOrGenerator) {
6232 return;
6233 }
6234 if (typeof pathOrGenerator === "function") {
6235 this.pathGenerator.generate = pathOrGenerator;
6236 if (init) {
6237 this.pathGenerator.init = init;
6238 }
6239 if (update) {
6240 this.pathGenerator.update = update;
6241 }
6242 } else {
6243 const oldGenerator = this.pathGenerator;
6244 this.pathGenerator = pathOrGenerator;
6245 (_a = this.pathGenerator).generate || (_a.generate = oldGenerator.generate);
6246 (_b = this.pathGenerator).init || (_b.init = oldGenerator.init);
6247 (_c = this.pathGenerator).update || (_c.update = oldGenerator.update);
6248 }
6249 }
6250 destroy() {
6251 this.stop();
6252 this.canvas.destroy();
6253 for (const [, drawer] of this.drawers) {
6254 if (drawer.destroy) {
6255 drawer.destroy(this);
6256 }
6257 }
6258 for (const key of this.drawers.keys()) {
6259 this.drawers.delete(key);
6260 }
6261 this.destroyed = true;
6262 Container_classPrivateFieldGet(this, _Container_engine, "f").dispatchEvent("containerDestroyed", {
6263 container: this
6264 });
6265 }
6266 exportImg(callback) {
6267 this.exportImage(callback);
6268 }
6269 exportImage(callback, type, quality) {
6270 var _a;
6271 return (_a = this.canvas.element) === null || _a === void 0 ? void 0 : _a.toBlob(callback, type !== null && type !== void 0 ? type : "image/png", quality);
6272 }
6273 exportConfiguration() {
6274 return JSON.stringify(this.actualOptions, undefined, 2);
6275 }
6276 refresh() {
6277 this.stop();
6278 return this.start();
6279 }
6280 reset() {
6281 this._options = loadContainerOptions(Container_classPrivateFieldGet(this, _Container_engine, "f"));
6282 return this.refresh();
6283 }
6284 stop() {
6285 if (!this.started) {
6286 return;
6287 }
6288 this.firstStart = true;
6289 this.started = false;
6290 this.eventListeners.removeListeners();
6291 this.pause();
6292 this.particles.clear();
6293 this.canvas.clear();
6294 if (this.interactivity.element instanceof HTMLElement && this.intersectionObserver) {
6295 this.intersectionObserver.unobserve(this.interactivity.element);
6296 }
6297 for (const [, plugin] of this.plugins) {
6298 if (plugin.stop) {
6299 plugin.stop();
6300 }
6301 }
6302 for (const key of this.plugins.keys()) {
6303 this.plugins.delete(key);
6304 }
6305 this.particles.linksColors = new Map;
6306 delete this.particles.grabLineColor;
6307 delete this.particles.linksColor;
6308 this._sourceOptions = this._options;
6309 Container_classPrivateFieldGet(this, _Container_engine, "f").dispatchEvent("containerStopped", {
6310 container: this
6311 });
6312 }
6313 async loadTheme(name) {
6314 this.currentTheme = name;
6315 await this.refresh();
6316 }
6317 async start() {
6318 if (this.started) {
6319 return;
6320 }
6321 await this.init();
6322 this.started = true;
6323 this.eventListeners.addListeners();
6324 if (this.interactivity.element instanceof HTMLElement && this.intersectionObserver) {
6325 this.intersectionObserver.observe(this.interactivity.element);
6326 }
6327 for (const [, plugin] of this.plugins) {
6328 if (plugin.startAsync !== undefined) {
6329 await plugin.startAsync();
6330 } else if (plugin.start !== undefined) {
6331 plugin.start();
6332 }
6333 }
6334 Container_classPrivateFieldGet(this, _Container_engine, "f").dispatchEvent("containerStarted", {
6335 container: this
6336 });
6337 this.play();
6338 }
6339 addClickHandler(callback) {
6340 const el = this.interactivity.element;
6341 if (!el) {
6342 return;
6343 }
6344 const clickOrTouchHandler = (e, pos, radius) => {
6345 if (this.destroyed) {
6346 return;
6347 }
6348 const pxRatio = this.retina.pixelRatio, posRetina = {
6349 x: pos.x * pxRatio,
6350 y: pos.y * pxRatio
6351 }, particles = this.particles.quadTree.queryCircle(posRetina, radius * pxRatio);
6352 callback(e, particles);
6353 };
6354 const clickHandler = e => {
6355 if (this.destroyed) {
6356 return;
6357 }
6358 const mouseEvent = e, pos = {
6359 x: mouseEvent.offsetX || mouseEvent.clientX,
6360 y: mouseEvent.offsetY || mouseEvent.clientY
6361 };
6362 clickOrTouchHandler(e, pos, 1);
6363 };
6364 const touchStartHandler = () => {
6365 if (this.destroyed) {
6366 return;
6367 }
6368 touched = true;
6369 touchMoved = false;
6370 };
6371 const touchMoveHandler = () => {
6372 if (this.destroyed) {
6373 return;
6374 }
6375 touchMoved = true;
6376 };
6377 const touchEndHandler = e => {
6378 var _a, _b, _c;
6379 if (this.destroyed) {
6380 return;
6381 }
6382 if (touched && !touchMoved) {
6383 const touchEvent = e;
6384 let lastTouch = touchEvent.touches[touchEvent.touches.length - 1];
6385 if (!lastTouch) {
6386 lastTouch = touchEvent.changedTouches[touchEvent.changedTouches.length - 1];
6387 if (!lastTouch) {
6388 return;
6389 }
6390 }
6391 const canvasRect = (_a = this.canvas.element) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect(), pos = {
6392 x: lastTouch.clientX - ((_b = canvasRect === null || canvasRect === void 0 ? void 0 : canvasRect.left) !== null && _b !== void 0 ? _b : 0),
6393 y: lastTouch.clientY - ((_c = canvasRect === null || canvasRect === void 0 ? void 0 : canvasRect.top) !== null && _c !== void 0 ? _c : 0)
6394 };
6395 clickOrTouchHandler(e, pos, Math.max(lastTouch.radiusX, lastTouch.radiusY));
6396 }
6397 touched = false;
6398 touchMoved = false;
6399 };
6400 const touchCancelHandler = () => {
6401 if (this.destroyed) {
6402 return;
6403 }
6404 touched = false;
6405 touchMoved = false;
6406 };
6407 let touched = false;
6408 let touchMoved = false;
6409 el.addEventListener("click", clickHandler);
6410 el.addEventListener("touchstart", touchStartHandler);
6411 el.addEventListener("touchmove", touchMoveHandler);
6412 el.addEventListener("touchend", touchEndHandler);
6413 el.addEventListener("touchcancel", touchCancelHandler);
6414 }
6415 handleClickMode(mode) {
6416 this.particles.handleClickMode(mode);
6417 for (const [, plugin] of this.plugins) {
6418 if (plugin.handleClickMode) {
6419 plugin.handleClickMode(mode);
6420 }
6421 }
6422 }
6423 updateActualOptions() {
6424 this.actualOptions.responsive = [];
6425 const newMaxWidth = this.actualOptions.setResponsive(this.canvas.size.width, this.retina.pixelRatio, this._options);
6426 this.actualOptions.setTheme(this.currentTheme);
6427 if (this.responsiveMaxWidth != newMaxWidth) {
6428 this.responsiveMaxWidth = newMaxWidth;
6429 return true;
6430 }
6431 return false;
6432 }
6433 async init() {
6434 const shapes = Container_classPrivateFieldGet(this, _Container_engine, "f").plugins.getSupportedShapes();
6435 for (const type of shapes) {
6436 const drawer = Container_classPrivateFieldGet(this, _Container_engine, "f").plugins.getShapeDrawer(type);
6437 if (drawer) {
6438 this.drawers.set(type, drawer);
6439 }
6440 }
6441 this._options = loadContainerOptions(Container_classPrivateFieldGet(this, _Container_engine, "f"), this._initialSourceOptions, this.sourceOptions);
6442 this.actualOptions = loadContainerOptions(Container_classPrivateFieldGet(this, _Container_engine, "f"), this._options);
6443 this.retina.init();
6444 this.canvas.init();
6445 this.updateActualOptions();
6446 this.canvas.initBackground();
6447 this.canvas.resize();
6448 this.zLayers = this.actualOptions.zLayers;
6449 this.duration = getRangeValue(this.actualOptions.duration);
6450 this.lifeTime = 0;
6451 this.fpsLimit = this.actualOptions.fpsLimit > 0 ? this.actualOptions.fpsLimit : 120;
6452 const availablePlugins = Container_classPrivateFieldGet(this, _Container_engine, "f").plugins.getAvailablePlugins(this);
6453 for (const [id, plugin] of availablePlugins) {
6454 this.plugins.set(id, plugin);
6455 }
6456 for (const [, drawer] of this.drawers) {
6457 if (drawer.init) {
6458 await drawer.init(this);
6459 }
6460 }
6461 for (const [, plugin] of this.plugins) {
6462 if (plugin.init) {
6463 plugin.init(this.actualOptions);
6464 } else if (plugin.initAsync !== undefined) {
6465 await plugin.initAsync(this.actualOptions);
6466 }
6467 }
6468 const pathOptions = this.actualOptions.particles.move.path;
6469 if (pathOptions.generator) {
6470 this.setPath(Container_classPrivateFieldGet(this, _Container_engine, "f").plugins.getPathGenerator(pathOptions.generator));
6471 }
6472 Container_classPrivateFieldGet(this, _Container_engine, "f").dispatchEvent("containerInit", {
6473 container: this
6474 });
6475 this.particles.init();
6476 this.particles.setDensity();
6477 for (const [, plugin] of this.plugins) {
6478 if (plugin.particlesSetup !== undefined) {
6479 plugin.particlesSetup();
6480 }
6481 }
6482 Container_classPrivateFieldGet(this, _Container_engine, "f").dispatchEvent("particlesSetup", {
6483 container: this
6484 });
6485 }
6486 intersectionManager(entries) {
6487 if (!this.actualOptions.pauseOnOutsideViewport) {
6488 return;
6489 }
6490 for (const entry of entries) {
6491 if (entry.target !== this.interactivity.element) {
6492 continue;
6493 }
6494 if (entry.isIntersecting) {
6495 this.play();
6496 } else {
6497 this.pause();
6498 }
6499 }
6500 }
6501 }
6502 _Container_engine = new WeakMap;
6503 var Loader_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
6504 if (kind === "m") throw new TypeError("Private method is not writable");
6505 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
6506 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6507 return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
6508 value;
6509 };
6510 var Loader_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
6511 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
6512 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
6513 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6514 };
6515 var _Loader_engine;
6516 function fetchError(statusCode) {
6517 console.error(`Error tsParticles - fetch status: ${statusCode}`);
6518 console.error("Error tsParticles - File config not found");
6519 }
6520 class Loader {
6521 constructor(engine) {
6522 _Loader_engine.set(this, void 0);
6523 Loader_classPrivateFieldSet(this, _Loader_engine, engine, "f");
6524 }
6525 dom() {
6526 return Loader_classPrivateFieldGet(this, _Loader_engine, "f").domArray;
6527 }
6528 domItem(index) {
6529 const dom = this.dom();
6530 const item = dom[index];
6531 if (item && !item.destroyed) {
6532 return item;
6533 }
6534 dom.splice(index, 1);
6535 }
6536 async loadOptions(params) {
6537 var _a, _b, _c;
6538 const tagId = (_a = params.tagId) !== null && _a !== void 0 ? _a : `tsparticles${Math.floor(Math.random() * 1e4)}`, {options: options, index: index} = params;
6539 let domContainer = (_b = params.element) !== null && _b !== void 0 ? _b : document.getElementById(tagId);
6540 if (!domContainer) {
6541 domContainer = document.createElement("div");
6542 domContainer.id = tagId;
6543 (_c = document.querySelector("body")) === null || _c === void 0 ? void 0 : _c.append(domContainer);
6544 }
6545 const currentOptions = options instanceof Array ? itemFromArray(options, index) : options, dom = this.dom(), oldIndex = dom.findIndex((v => v.id === tagId));
6546 if (oldIndex >= 0) {
6547 const old = this.domItem(oldIndex);
6548 if (old && !old.destroyed) {
6549 old.destroy();
6550 dom.splice(oldIndex, 1);
6551 }
6552 }
6553 let canvasEl;
6554 if (domContainer.tagName.toLowerCase() === "canvas") {
6555 canvasEl = domContainer;
6556 canvasEl.dataset[generatedAttribute] = "false";
6557 } else {
6558 const existingCanvases = domContainer.getElementsByTagName("canvas");
6559 if (existingCanvases.length) {
6560 canvasEl = existingCanvases[0];
6561 canvasEl.dataset[generatedAttribute] = "false";
6562 } else {
6563 canvasEl = document.createElement("canvas");
6564 canvasEl.dataset[generatedAttribute] = "true";
6565 canvasEl.style.width = "100%";
6566 canvasEl.style.height = "100%";
6567 domContainer.appendChild(canvasEl);
6568 }
6569 }
6570 const newItem = new Container(Loader_classPrivateFieldGet(this, _Loader_engine, "f"), tagId, currentOptions);
6571 if (oldIndex >= 0) {
6572 dom.splice(oldIndex, 0, newItem);
6573 } else {
6574 dom.push(newItem);
6575 }
6576 newItem.canvas.loadCanvas(canvasEl);
6577 await newItem.start();
6578 return newItem;
6579 }
6580 async loadRemoteOptions(params) {
6581 const {url: jsonUrl, index: index} = params, url = jsonUrl instanceof Array ? itemFromArray(jsonUrl, index) : jsonUrl;
6582 if (!url) {
6583 return;
6584 }
6585 const response = await fetch(url);
6586 if (!response.ok) {
6587 fetchError(response.status);
6588 return;
6589 }
6590 const data = await response.json();
6591 return this.loadOptions({
6592 tagId: params.tagId,
6593 element: params.element,
6594 index: index,
6595 options: data
6596 });
6597 }
6598 load(tagId, options, index) {
6599 const params = {
6600 index: index
6601 };
6602 if (typeof tagId === "string") {
6603 params.tagId = tagId;
6604 } else {
6605 params.options = tagId;
6606 }
6607 if (typeof options === "number") {
6608 params.index = options !== null && options !== void 0 ? options : params.index;
6609 } else {
6610 params.options = options !== null && options !== void 0 ? options : params.options;
6611 }
6612 return this.loadOptions(params);
6613 }
6614 async set(id, domContainer, options, index) {
6615 const params = {
6616 index: index
6617 };
6618 if (typeof id === "string") {
6619 params.tagId = id;
6620 } else {
6621 params.element = id;
6622 }
6623 if (domContainer instanceof HTMLElement) {
6624 params.element = domContainer;
6625 } else {
6626 params.options = domContainer;
6627 }
6628 if (typeof options === "number") {
6629 params.index = options;
6630 } else {
6631 params.options = options !== null && options !== void 0 ? options : params.options;
6632 }
6633 return this.loadOptions(params);
6634 }
6635 async loadJSON(tagId, jsonUrl, index) {
6636 let url, id;
6637 if (typeof jsonUrl === "number" || jsonUrl === undefined) {
6638 url = tagId;
6639 } else {
6640 id = tagId;
6641 url = jsonUrl;
6642 }
6643 return this.loadRemoteOptions({
6644 tagId: id,
6645 url: url,
6646 index: index
6647 });
6648 }
6649 async setJSON(id, domContainer, jsonUrl, index) {
6650 let url, newId, newIndex, element;
6651 if (id instanceof HTMLElement) {
6652 element = id;
6653 url = domContainer;
6654 newIndex = jsonUrl;
6655 } else {
6656 newId = id;
6657 element = domContainer;
6658 url = jsonUrl;
6659 newIndex = index;
6660 }
6661 return this.loadRemoteOptions({
6662 tagId: newId,
6663 url: url,
6664 index: newIndex,
6665 element: element
6666 });
6667 }
6668 setOnClickHandler(callback) {
6669 const dom = this.dom();
6670 if (!dom.length) {
6671 throw new Error("Can only set click handlers after calling tsParticles.load() or tsParticles.loadJSON()");
6672 }
6673 for (const domItem of dom) {
6674 domItem.addClickHandler(callback);
6675 }
6676 }
6677 addEventListener(type, listener) {
6678 Loader_classPrivateFieldGet(this, _Loader_engine, "f").eventDispatcher.addEventListener(type, listener);
6679 }
6680 removeEventListener(type, listener) {
6681 Loader_classPrivateFieldGet(this, _Loader_engine, "f").eventDispatcher.removeEventListener(type, listener);
6682 }
6683 dispatchEvent(type, args) {
6684 Loader_classPrivateFieldGet(this, _Loader_engine, "f").eventDispatcher.dispatchEvent(type, args);
6685 }
6686 }
6687 _Loader_engine = new WeakMap;
6688 var Plugins_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
6689 if (kind === "m") throw new TypeError("Private method is not writable");
6690 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
6691 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6692 return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
6693 value;
6694 };
6695 var _Plugins_engine;
6696 class Plugins {
6697 constructor(engine) {
6698 _Plugins_engine.set(this, void 0);
6699 Plugins_classPrivateFieldSet(this, _Plugins_engine, engine, "f");
6700 this.plugins = [];
6701 this.interactorsInitializers = new Map;
6702 this.moversInitializers = new Map;
6703 this.updatersInitializers = new Map;
6704 this.interactors = new Map;
6705 this.movers = new Map;
6706 this.updaters = new Map;
6707 this.presets = new Map;
6708 this.drawers = new Map;
6709 this.pathGenerators = new Map;
6710 }
6711 getPlugin(plugin) {
6712 return this.plugins.find((t => t.id === plugin));
6713 }
6714 addPlugin(plugin) {
6715 if (!this.getPlugin(plugin.id)) {
6716 this.plugins.push(plugin);
6717 }
6718 }
6719 getAvailablePlugins(container) {
6720 const res = new Map;
6721 for (const plugin of this.plugins) {
6722 if (!plugin.needsPlugin(container.actualOptions)) {
6723 continue;
6724 }
6725 res.set(plugin.id, plugin.getPlugin(container));
6726 }
6727 return res;
6728 }
6729 loadOptions(options, sourceOptions) {
6730 for (const plugin of this.plugins) {
6731 plugin.loadOptions(options, sourceOptions);
6732 }
6733 }
6734 getPreset(preset) {
6735 return this.presets.get(preset);
6736 }
6737 addPreset(presetKey, options, override = false) {
6738 if (override || !this.getPreset(presetKey)) {
6739 this.presets.set(presetKey, options);
6740 }
6741 }
6742 getShapeDrawer(type) {
6743 return this.drawers.get(type);
6744 }
6745 addShapeDrawer(type, drawer) {
6746 if (!this.getShapeDrawer(type)) {
6747 this.drawers.set(type, drawer);
6748 }
6749 }
6750 getSupportedShapes() {
6751 return this.drawers.keys();
6752 }
6753 getPathGenerator(type) {
6754 return this.pathGenerators.get(type);
6755 }
6756 addPathGenerator(type, pathGenerator) {
6757 if (!this.getPathGenerator(type)) {
6758 this.pathGenerators.set(type, pathGenerator);
6759 }
6760 }
6761 getInteractors(container, force = false) {
6762 let res = this.interactors.get(container);
6763 if (!res || force) {
6764 res = [ ...this.interactorsInitializers.values() ].map((t => t(container)));
6765 this.interactors.set(container, res);
6766 }
6767 return res;
6768 }
6769 addInteractor(name, initInteractor) {
6770 this.interactorsInitializers.set(name, initInteractor);
6771 }
6772 getUpdaters(container, force = false) {
6773 let res = this.updaters.get(container);
6774 if (!res || force) {
6775 res = [ ...this.updatersInitializers.values() ].map((t => t(container)));
6776 this.updaters.set(container, res);
6777 }
6778 return res;
6779 }
6780 addParticleUpdater(name, initUpdater) {
6781 this.updatersInitializers.set(name, initUpdater);
6782 }
6783 getMovers(container, force = false) {
6784 let res = this.movers.get(container);
6785 if (!res || force) {
6786 res = [ ...this.moversInitializers.values() ].map((t => t(container)));
6787 this.movers.set(container, res);
6788 }
6789 return res;
6790 }
6791 addParticleMover(name, initMover) {
6792 this.moversInitializers.set(name, initMover);
6793 }
6794 }
6795 _Plugins_engine = new WeakMap;
6796 var engine_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
6797 if (kind === "m") throw new TypeError("Private method is not writable");
6798 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
6799 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6800 return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
6801 value;
6802 };
6803 var engine_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
6804 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
6805 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
6806 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6807 };
6808 var _Engine_initialized, _Engine_loader;
6809 class Engine {
6810 constructor() {
6811 _Engine_initialized.set(this, void 0);
6812 _Engine_loader.set(this, void 0);
6813 this.domArray = [];
6814 this.eventDispatcher = new EventDispatcher;
6815 engine_classPrivateFieldSet(this, _Engine_initialized, false, "f");
6816 engine_classPrivateFieldSet(this, _Engine_loader, new Loader(this), "f");
6817 this.plugins = new Plugins(this);
6818 }
6819 init() {
6820 if (!engine_classPrivateFieldGet(this, _Engine_initialized, "f")) {
6821 engine_classPrivateFieldSet(this, _Engine_initialized, true, "f");
6822 }
6823 }
6824 async loadFromArray(tagId, options, index) {
6825 return engine_classPrivateFieldGet(this, _Engine_loader, "f").load(tagId, options, index);
6826 }
6827 async load(tagId, options) {
6828 return engine_classPrivateFieldGet(this, _Engine_loader, "f").load(tagId, options);
6829 }
6830 async set(id, element, options) {
6831 return engine_classPrivateFieldGet(this, _Engine_loader, "f").set(id, element, options);
6832 }
6833 async loadJSON(tagId, pathConfigJson, index) {
6834 return engine_classPrivateFieldGet(this, _Engine_loader, "f").loadJSON(tagId, pathConfigJson, index);
6835 }
6836 async setJSON(id, element, pathConfigJson, index) {
6837 return engine_classPrivateFieldGet(this, _Engine_loader, "f").setJSON(id, element, pathConfigJson, index);
6838 }
6839 setOnClickHandler(callback) {
6840 engine_classPrivateFieldGet(this, _Engine_loader, "f").setOnClickHandler(callback);
6841 }
6842 dom() {
6843 return engine_classPrivateFieldGet(this, _Engine_loader, "f").dom();
6844 }
6845 domItem(index) {
6846 return engine_classPrivateFieldGet(this, _Engine_loader, "f").domItem(index);
6847 }
6848 async refresh() {
6849 for (const instance of this.dom()) {
6850 await instance.refresh();
6851 }
6852 }
6853 async addShape(shape, drawer, init, afterEffect, destroy) {
6854 let customDrawer;
6855 if (typeof drawer === "function") {
6856 customDrawer = {
6857 afterEffect: afterEffect,
6858 destroy: destroy,
6859 draw: drawer,
6860 init: init
6861 };
6862 } else {
6863 customDrawer = drawer;
6864 }
6865 this.plugins.addShapeDrawer(shape, customDrawer);
6866 await this.refresh();
6867 }
6868 async addPreset(preset, options, override = false) {
6869 this.plugins.addPreset(preset, options, override);
6870 await this.refresh();
6871 }
6872 async addPlugin(plugin) {
6873 this.plugins.addPlugin(plugin);
6874 await this.refresh();
6875 }
6876 async addPathGenerator(name, generator) {
6877 this.plugins.addPathGenerator(name, generator);
6878 await this.refresh();
6879 }
6880 async addInteractor(name, interactorInitializer) {
6881 this.plugins.addInteractor(name, interactorInitializer);
6882 await this.refresh();
6883 }
6884 async addMover(name, moverInitializer) {
6885 this.plugins.addParticleMover(name, moverInitializer);
6886 await this.refresh();
6887 }
6888 async addParticleUpdater(name, updaterInitializer) {
6889 this.plugins.addParticleUpdater(name, updaterInitializer);
6890 await this.refresh();
6891 }
6892 addEventListener(type, listener) {
6893 engine_classPrivateFieldGet(this, _Engine_loader, "f").addEventListener(type, listener);
6894 }
6895 removeEventListener(type, listener) {
6896 engine_classPrivateFieldGet(this, _Engine_loader, "f").removeEventListener(type, listener);
6897 }
6898 dispatchEvent(type, args) {
6899 engine_classPrivateFieldGet(this, _Engine_loader, "f").dispatchEvent(type, args);
6900 }
6901 }
6902 _Engine_initialized = new WeakMap, _Engine_loader = new WeakMap;
6903 class ExternalInteractorBase {
6904 constructor(container) {
6905 this.container = container;
6906 this.type = 0;
6907 }
6908 }
6909 class ParticlesInteractorBase {
6910 constructor(container) {
6911 this.container = container;
6912 this.type = 1;
6913 }
6914 }
6915 const tsParticles = new Engine;
6916 tsParticles.init();
6917 return __webpack_exports__;
6918 }();
6919}));
\No newline at end of file