tsparticles
Version:
Easily create highly customizable particle, confetti and fireworks animations and use them as animated backgrounds for your website. Ready to use components available also for React, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Riot.js, Inferno.
2 lines • 21.5 kB
JavaScript
/*! tsParticles v1.42.2 by Matteo Bruni */
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var i in n)("object"==typeof exports?exports:t)[i]=n[i]}}(window,(function(){return function(){"use strict";var t,e,n,i,o,r={},s={};function a(t){var e=s[t];if(void 0!==e)return e.exports;var n=s[t]={exports:{}};return r[t](n,n.exports,a),n.exports}a.m=r,t=[],a.O=function(e,n,i,o){if(!n){var r=1/0;for(c=0;c<t.length;c++){n=t[c][0],i=t[c][1],o=t[c][2];for(var s=!0,l=0;l<n.length;l++)(!1&o||r>=o)&&Object.keys(a.O).every((function(t){return a.O[t](n[l])}))?n.splice(l--,1):(s=!1,o<r&&(r=o));if(s){t.splice(c--,1);var h=i();void 0!==h&&(e=h)}}return e}o=o||0;for(var c=t.length;c>0&&t[c-1][2]>o;c--)t[c]=t[c-1];t[c]=[n,i,o]},a.F={},a.E=function(t){Object.keys(a.F).map((function(e){a.F[e](t)}))},n=Object.getPrototypeOf?function(t){return Object.getPrototypeOf(t)}:function(t){return t.__proto__},a.t=function(t,i){if(1&i&&(t=this(t)),8&i)return t;if("object"==typeof t&&t){if(4&i&&t.__esModule)return t;if(16&i&&"function"==typeof t.then)return t}var o=Object.create(null);a.r(o);var r={};e=e||[null,n({}),n([]),n(n)];for(var s=2&i&&t;"object"==typeof s&&!~e.indexOf(s);s=n(s))Object.getOwnPropertyNames(s).forEach((function(e){r[e]=function(){return t[e]}}));return r.default=function(){return t},a.d(o,r),o},a.d=function(t,e){for(var n in e)a.o(e,n)&&!a.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},a.f={},a.e=function(t){return Promise.all(Object.keys(a.f).reduce((function(e,n){return a.f[n](t,e),e}),[]))},a.u=function(t){return"tsparticles.pathseg.min.js"},a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i={},o="tsparticles:",a.l=function(t,e,n,r){if(i[t])i[t].push(e);else{var s,l;if(void 0!==n)for(var h=document.getElementsByTagName("script"),c=0;c<h.length;c++){var u=h[c];if(u.getAttribute("src")==t||u.getAttribute("data-webpack")==o+n){s=u;break}}s||(l=!0,(s=document.createElement("script")).charset="utf-8",s.timeout=120,a.nc&&s.setAttribute("nonce",a.nc),s.setAttribute("data-webpack",o+n),s.src=t),i[t]=[e];var d=function(e,n){s.onerror=s.onload=null,clearTimeout(p);var o=i[t];if(delete i[t],s.parentNode&&s.parentNode.removeChild(s),o&&o.forEach((function(t){return t(n)})),e)return e(n)},p=setTimeout(d.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=d.bind(null,s.onerror),s.onload=d.bind(null,s.onload),l&&document.head.appendChild(s)}},a.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},function(){var t;a.g.importScripts&&(t=a.g.location+"");var e=a.g.document;if(!t&&e&&(e.currentScript&&(t=e.currentScript.src),!t)){var n=e.getElementsByTagName("script");n.length&&(t=n[n.length-1].src)}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),a.p=t}(),function(){var t={475:0,143:0};a.f.j=function(e,n){var i=a.o(t,e)?t[e]:void 0;if(0!==i)if(i)n.push(i[2]);else{var o=new Promise((function(n,o){i=t[e]=[n,o]}));n.push(i[2]=o);var r=a.p+a.u(e),s=new Error;a.l(r,(function(n){if(a.o(t,e)&&(0!==(i=t[e])&&(t[e]=void 0),i)){var o=n&&("load"===n.type?"missing":n.type),r=n&&n.target&&n.target.src;s.message="Loading chunk "+e+" failed.\n("+o+": "+r+")",s.name="ChunkLoadError",s.type=o,s.request=r,i[1](s)}}),"chunk-"+e,e)}},a.F.j=function(e){if(!a.o(t,e)||void 0===t[e]){t[e]=null;var n=document.createElement("link");a.nc&&n.setAttribute("nonce",a.nc),n.rel="prefetch",n.as="script",n.href=a.p+a.u(e),document.head.appendChild(n)}},a.O.j=function(e){return 0===t[e]};var e=function(e,n){var i,o,r=n[0],s=n[1],l=n[2],h=0;if(r.some((function(e){return 0!==t[e]}))){for(i in s)a.o(s,i)&&(a.m[i]=s[i]);if(l)var c=l(a)}for(e&&e(n);h<r.length;h++)o=r[h],a.o(t,o)&&t[o]&&t[o][0](),t[o]=0;return a.O(c)},n=window.webpackChunktsparticles=window.webpackChunktsparticles||[];n.forEach(e.bind(null,0)),n.push=e.bind(null,n.push.bind(n))}(),a.O(0,[475],(function(){a.E(404)}),5);var l={};a.r(l),a.d(l,{loadPolygonMaskPlugin:function(){return G}});class h{constructor(){this.value="#fff"}static create(t,e){const n=new h;return n.load(t),void 0!==e&&("string"==typeof e||e instanceof Array?n.load({value:e}):n.load(e)),n}load(t){void 0!==(null==t?void 0:t.value)&&(this.value=t.value)}}class c{}c.generatedAttribute="generated",c.randomColorValue="random",c.midColorValue="mid",c.touchEndEvent="touchend",c.mouseDownEvent="mousedown",c.mouseUpEvent="mouseup",c.mouseMoveEvent="mousemove",c.touchStartEvent="touchstart",c.touchMoveEvent="touchmove",c.mouseLeaveEvent="mouseleave",c.mouseOutEvent="mouseout",c.touchCancelEvent="touchcancel",c.resizeEvent="resize",c.visibilityChangeEvent="visibilitychange",c.noPolygonDataLoaded="No polygon data loaded.",c.noPolygonFound="No polygon found, you need to specify SVG url in config.";new WeakMap;new WeakMap;class u{constructor(t,e){let n,i;if(void 0===e){if("number"==typeof t)throw new Error("tsParticles - Vector not initialized correctly");const e=t;[n,i]=[e.x,e.y]}else[n,i]=[t,e];this.x=n,this.y=i}static clone(t){return u.create(t.x,t.y)}static create(t,e){return new u(t,e)}static get origin(){return u.create(0,0)}get angle(){return Math.atan2(this.y,this.x)}set angle(t){this.updateFromAngle(t,this.length)}get length(){return Math.sqrt(this.x**2+this.y**2)}set length(t){this.updateFromAngle(this.angle,t)}add(t){return u.create(this.x+t.x,this.y+t.y)}addTo(t){this.x+=t.x,this.y+=t.y}sub(t){return u.create(this.x-t.x,this.y-t.y)}subFrom(t){this.x-=t.x,this.y-=t.y}mult(t){return u.create(this.x*t,this.y*t)}multTo(t){this.x*=t,this.y*=t}div(t){return u.create(this.x/t,this.y/t)}divTo(t){this.x/=t,this.y/=t}distanceTo(t){return this.sub(t).length}getLengthSq(){return this.x**2+this.y**2}distanceToSq(t){return this.sub(t).getLengthSq()}manhattanDistanceTo(t){return Math.abs(t.x-this.x)+Math.abs(t.y-this.y)}copy(){return u.clone(this)}setTo(t){this.x=t.x,this.y=t.y}rotate(t){return u.create(this.x*Math.cos(t)-this.y*Math.sin(t),this.x*Math.sin(t)+this.y*Math.cos(t))}updateFromAngle(t,e){this.x=Math.cos(t)*e,this.y=Math.sin(t)*e}}new WeakMap,new WeakSet;new WeakMap;new WeakMap;new WeakMap;function d(t){const e=f(t);let n=p(t);return e===n&&(n=0),Math.random()*(e-n)+n}function p(t){return"number"==typeof t?t:t.min}function f(t){return"number"==typeof t?t:t.max}function v(t,e){if(t===e||void 0===e&&"number"==typeof t)return t;const n=p(t),i=f(t);return void 0!==e?{min:Math.min(n,e),max:Math.max(i,e)}:v(n,i)}function y(t,e){const n=t.x-e.x,i=t.y-e.y;return{dx:n,dy:i,distance:Math.sqrt(n*n+i*i)}}function g(){return"undefined"==typeof window||!window||void 0===window.document||!window.document}function w(t,e,n=!0){return t[void 0!==e&&n?e%t.length:function(t){return Math.floor(Math.random()*t.length)}(t)]}function m(t,...e){for(const n of e){if(null==n)continue;if("object"!=typeof n){t=n;continue}const e=Array.isArray(n);!e||"object"==typeof t&&t&&Array.isArray(t)?e||"object"==typeof t&&t&&!Array.isArray(t)||(t={}):t=[];for(const e in n){if("__proto__"===e)continue;const i=n[e],o="object"==typeof i,r=t;r[e]=o&&Array.isArray(i)?i.map((t=>m(r[e],t))):m(r[e],i)}}return t}function b(t,e,n){let i=n;return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}function x(t){if(t.startsWith("rgb")){const e=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([\d.]+)\s*)?\)/i.exec(t);return e?{a:e.length>4?parseFloat(e[5]):1,b:parseInt(e[3],10),g:parseInt(e[2],10),r:parseInt(e[1],10)}:void 0}if(t.startsWith("hsl")){const e=/hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([\d.]+)\s*)?\)/i.exec(t);return e?function(t){const e=E(t);return{a:t.a,b:e.b,g:e.g,r:e.r}}({a:e.length>4?parseFloat(e[5]):1,h:parseInt(e[1],10),l:parseInt(e[3],10),s:parseInt(e[2],10)}):void 0}if(t.startsWith("hsv")){const e=/hsva?\(\s*(\d+)°\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([\d.]+)\s*)?\)/i.exec(t);return e?function(t){const e=T(t);return{a:t.a,b:e.b,g:e.g,r:e.r}}({a:e.length>4?parseFloat(e[5]):1,h:parseInt(e[1],10),s:parseInt(e[2],10),v:parseInt(e[3],10)}):void 0}{const e=/^#?([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i,n=t.replace(e,((t,e,n,i,o)=>e+e+n+n+i+i+(void 0!==o?o+o:""))),i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i.exec(n);return i?{a:void 0!==i[4]?parseInt(i[4],16)/255:1,b:parseInt(i[3],16),g:parseInt(i[2],16),r:parseInt(i[1],16)}:void 0}}function P(t,e,n=!0){var i,o,r;if(void 0===t)return;const s="string"==typeof t?{value:t}:t;let a;if("string"==typeof s.value)a=s.value===c.randomColorValue?A():function(t){return x(t)}(s.value);else if(s.value instanceof Array){a=P({value:w(s.value,e,n)})}else{const t=s.value,e=null!==(i=t.rgb)&&void 0!==i?i:s.value;if(void 0!==e.r)a=e;else{const e=null!==(o=t.hsl)&&void 0!==o?o:s.value;if(void 0!==e.h&&void 0!==e.l)a=E(e);else{const e=null!==(r=t.hsv)&&void 0!==r?r:s.value;void 0!==e.h&&void 0!==e.v&&(a=T(e))}}}return a}function E(t){const e={b:0,g:0,r:0},n={h:t.h/360,l:t.l/100,s:t.s/100};if(0===n.s)e.b=n.l,e.g=n.l,e.r=n.l;else{const t=n.l<.5?n.l*(1+n.s):n.l+n.s-n.l*n.s,i=2*n.l-t;e.r=b(i,t,n.h+1/3),e.g=b(i,t,n.h),e.b=b(i,t,n.h-1/3)}return e.r=Math.floor(255*e.r),e.g=Math.floor(255*e.g),e.b=Math.floor(255*e.b),e}function T(t){const e={b:0,g:0,r:0},n=t.h/60,i=t.s/100,o=t.v/100,r=o*i,s=r*(1-Math.abs(n%2-1));let a;if(n>=0&&n<=1?a={r:r,g:s,b:0}:n>1&&n<=2?a={r:s,g:r,b:0}:n>2&&n<=3?a={r:0,g:r,b:s}:n>3&&n<=4?a={r:0,g:s,b:r}:n>4&&n<=5?a={r:s,g:0,b:r}:n>5&&n<=6&&(a={r:r,g:0,b:s}),a){const t=o-r;e.r=Math.floor(255*(a.r+t)),e.g=Math.floor(255*(a.g+t)),e.b=Math.floor(255*(a.b+t))}return e}function A(t){const e=null!=t?t:0;return{b:Math.floor(d(v(e,256))),g:Math.floor(d(v(e,256))),r:Math.floor(d(v(e,256)))}}function S(t,e){return`rgba(${t.r}, ${t.g}, ${t.b}, ${null!=e?e:1})`}new WeakMap;class _{constructor(){this.color=new h,this.width=.5,this.opacity=1}load(t){var e;t&&(this.color=h.create(this.color,t.color),"string"==typeof this.color.value&&(this.opacity=null!==(e=function(t){var e;return null===(e=x(t))||void 0===e?void 0:e.a}(this.color.value))&&void 0!==e?e:this.opacity),void 0!==t.opacity&&(this.opacity=t.opacity),void 0!==t.width&&(this.width=t.width))}}class M{constructor(){this.enable=!1,this.stroke=new _}get lineWidth(){return this.stroke.width}set lineWidth(t){this.stroke.width=t}get lineColor(){return this.stroke.color}set lineColor(t){this.stroke.color=h.create(this.stroke.color,t)}load(t){var e;if(!t)return;void 0!==t.enable&&(this.enable=t.enable);const n=null!==(e=t.stroke)&&void 0!==e?e:{color:t.lineColor,width:t.lineWidth};this.stroke.load(n)}}class O{constructor(){this.arrangement="one-per-point"}load(t){t&&void 0!==t.arrangement&&(this.arrangement=t.arrangement)}}class k{constructor(){this.path=[],this.size={height:0,width:0}}load(t){t&&(void 0!==t.path&&(this.path=t.path),void 0!==t.size&&(void 0!==t.size.width&&(this.size.width=t.size.width),void 0!==t.size.height&&(this.size.height=t.size.height)))}}class I{constructor(){this.radius=10,this.type="path"}load(t){t&&(void 0!==t.radius&&(this.radius=t.radius),void 0!==t.type&&(this.type=t.type))}}class R{constructor(){this.draw=new M,this.enable=!1,this.inline=new O,this.move=new I,this.scale=1,this.type="none"}get inlineArrangement(){return this.inline.arrangement}set inlineArrangement(t){this.inline.arrangement=t}load(t){var e;if(!t)return;this.draw.load(t.draw);const n=null!==(e=t.inline)&&void 0!==e?e:{arrangement:t.inlineArrangement};void 0!==n&&this.inline.load(n),this.move.load(t.move),void 0!==t.scale&&(this.scale=t.scale),void 0!==t.type&&(this.type=t.type),void 0!==t.enable?this.enable=t.enable:this.enable="none"!==this.type,void 0!==t.url&&(this.url=t.url),void 0!==t.data&&("string"==typeof t.data?this.data=t.data:(this.data=new k,this.data.load(t.data))),void 0!==t.position&&(this.position=m({},t.position))}}function C(t,e,n){const i=P(n.color);if(i){t.beginPath(),t.moveTo(e[0].x,e[0].y);for(const n of e)t.lineTo(n.x,n.y);t.closePath(),t.strokeStyle=S(i),t.lineWidth=n.width,t.stroke()}}function L(t,e,n,i){t.translate(i.x,i.y);const o=P(n.color);o&&(t.strokeStyle=S(o,n.opacity),t.lineWidth=n.width,t.stroke(e))}function j(t,e,n){const{dx:i,dy:o}=y(n,t),{dx:r,dy:s}=y(e,t),a=(i*r+o*s)/(r**2+s**2),l={x:t.x+r*a,y:t.x+s*a,isOnSegment:a>=0&&a<=1};return a<0?(l.x=t.x,l.y=t.y):a>1&&(l.x=e.x,l.y=e.y),l}function B(t,e,n){const{dx:i,dy:o}=y(t,e),r=Math.atan2(o,i),s=u.create(Math.sin(r),-Math.cos(r)),a=2*(n.x*s.x+n.y*s.y);s.multTo(a),n.subFrom(s)}class H{constructor(t){this.container=t,this.dimension={height:0,width:0},this.path2DSupported=!!window.Path2D,this.options=new R,this.polygonMaskMoveRadius=this.options.move.radius*t.retina.pixelRatio}async initAsync(t){this.options.load(null==t?void 0:t.polygon);const e=this.options;this.polygonMaskMoveRadius=e.move.radius*this.container.retina.pixelRatio,e.enable&&await this.initRawData()}resize(){const t=this.container,e=this.options;e.enable&&"none"!==e.type&&(this.redrawTimeout&&clearTimeout(this.redrawTimeout),this.redrawTimeout=window.setTimeout((async()=>{await this.initRawData(!0),await t.particles.redraw()}),250))}stop(){delete this.raw,delete this.paths}particlesInitialization(){const t=this.options;return!(!t.enable||"inline"!==t.type||"one-per-point"!==t.inline.arrangement&&"per-point"!==t.inline.arrangement)&&(this.drawPoints(),!0)}particlePosition(t){var e,n;if(this.options.enable&&(null!==(n=null===(e=this.raw)||void 0===e?void 0:e.length)&&void 0!==n?n:0)>0)return m({},t||this.randomPoint())}particleBounce(t,e,n){return this.polygonBounce(t,e,n)}clickPositionValid(t){const e=this.options;return e.enable&&"none"!==e.type&&"inline"!==e.type&&this.checkInsidePolygon(t)}draw(t){var e;if(!(null===(e=this.paths)||void 0===e?void 0:e.length))return;const n=this.options,i=n.draw;if(!n.enable||!i.enable)return;const o=this.raw;for(const e of this.paths){const n=e.path2d,r=this.path2DSupported;t&&(r&&n&&this.offset?L(t,n,i.stroke,this.offset):o&&C(t,o,i.stroke))}}polygonBounce(t,e,n){const i=this.options;if(!this.raw||!i.enable||"top"!==n)return!1;if("inside"===i.type||"outside"===i.type){let e,n,i;const o=t.getPosition(),r=t.getRadius();for(let s=0,a=this.raw.length-1;s<this.raw.length;a=s++){const l=this.raw[s],h=this.raw[a];e=j(l,h,o);const c=y(o,e);if([n,i]=[c.dx,c.dy],c.distance<r)return B(l,h,t.velocity),!0}if(e&&void 0!==n&&void 0!==i&&!this.checkInsidePolygon(o)){const n={x:1,y:1};return t.position.x>=e.x&&(n.x=-1),t.position.y>=e.y&&(n.y=-1),t.position.x=e.x+2*r*n.x,t.position.y=e.y+2*r*n.y,t.velocity.mult(-1),!0}}else if("inline"===i.type&&t.initialPosition){if((o=t.initialPosition,r=t.getPosition(),y(o,r).distance)>this.polygonMaskMoveRadius)return t.velocity.x=t.velocity.y/2-t.velocity.x,t.velocity.y=t.velocity.x/2-t.velocity.y,!0}var o,r;return!1}checkInsidePolygon(t){var e,n;const i=this.container,o=this.options;if(!o.enable||"none"===o.type||"inline"===o.type)return!0;if(!this.raw)throw new Error(c.noPolygonFound);const r=i.canvas.size,s=null!==(e=null==t?void 0:t.x)&&void 0!==e?e:Math.random()*r.width,a=null!==(n=null==t?void 0:t.y)&&void 0!==n?n:Math.random()*r.height;let l=!1;for(let t=0,e=this.raw.length-1;t<this.raw.length;e=t++){const n=this.raw[t],i=this.raw[e];n.y>a!=i.y>a&&s<(i.x-n.x)*(a-n.y)/(i.y-n.y)+n.x&&(l=!l)}return"inside"===o.type?l:"outside"===o.type&&!l}parseSvgPath(t,e){var n,i,o;const r=null!=e&&e;if(void 0!==this.paths&&!r)return this.raw;const s=this.container,a=this.options,l=(new DOMParser).parseFromString(t,"image/svg+xml"),h=l.getElementsByTagName("svg")[0];let c=h.getElementsByTagName("path");c.length||(c=l.getElementsByTagName("path")),this.paths=[];for(let t=0;t<c.length;t++){const e=c.item(t);e&&this.paths.push({element:e,length:e.getTotalLength()})}const u=s.retina.pixelRatio,d=a.scale/u;this.dimension.width=parseFloat(null!==(n=h.getAttribute("width"))&&void 0!==n?n:"0")*d,this.dimension.height=parseFloat(null!==(i=h.getAttribute("height"))&&void 0!==i?i:"0")*d;const p=null!==(o=a.position)&&void 0!==o?o:{x:50,y:50};return this.offset={x:s.canvas.size.width*p.x/(100*u)-this.dimension.width/2,y:s.canvas.size.height*p.y/(100*u)-this.dimension.height/2},function(t,e,n){var i;const o=[];for(const r of t){const t=r.element.pathSegList,s=null!==(i=null==t?void 0:t.numberOfItems)&&void 0!==i?i:0,a={x:0,y:0};for(let i=0;i<s;i++){const r=null==t?void 0:t.getItem(i),s=window.SVGPathSeg;switch(null==r?void 0:r.pathSegType){case s.PATHSEG_MOVETO_ABS:case s.PATHSEG_LINETO_ABS:case s.PATHSEG_CURVETO_CUBIC_ABS:case s.PATHSEG_CURVETO_QUADRATIC_ABS:case s.PATHSEG_ARC_ABS:case s.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:case s.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:{const t=r;a.x=t.x,a.y=t.y;break}case s.PATHSEG_LINETO_HORIZONTAL_ABS:a.x=r.x;break;case s.PATHSEG_LINETO_VERTICAL_ABS:a.y=r.y;break;case s.PATHSEG_LINETO_REL:case s.PATHSEG_MOVETO_REL:case s.PATHSEG_CURVETO_CUBIC_REL:case s.PATHSEG_CURVETO_QUADRATIC_REL:case s.PATHSEG_ARC_REL:case s.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:case s.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:{const t=r;a.x+=t.x,a.y+=t.y;break}case s.PATHSEG_LINETO_HORIZONTAL_REL:a.x+=r.x;break;case s.PATHSEG_LINETO_VERTICAL_REL:a.y+=r.y;break;case s.PATHSEG_UNKNOWN:case s.PATHSEG_CLOSEPATH:continue}o.push({x:a.x*e+n.x,y:a.y*e+n.y})}}return o}(this.paths,d,this.offset)}async downloadSvgPath(t,e){const n=this.options,i=t||n.url,o=null!=e&&e;if(!i||void 0!==this.paths&&!o)return this.raw;const r=await fetch(i);if(!r.ok)throw new Error("tsParticles Error - Error occurred during polygon mask download");return this.parseSvgPath(await r.text(),e)}drawPoints(){if(this.raw)for(const t of this.raw)this.container.particles.addParticle({x:t.x,y:t.y})}randomPoint(){const t=this.container,e=this.options;let n;if("inline"===e.type)switch(e.inline.arrangement){case"random-point":n=this.getRandomPoint();break;case"random-length":n=this.getRandomPointByLength();break;case"equidistant":n=this.getEquidistantPointByIndex(t.particles.count);break;case"one-per-point":case"per-point":default:n=this.getPointByIndex(t.particles.count)}else n={x:Math.random()*t.canvas.size.width,y:Math.random()*t.canvas.size.height};return this.checkInsidePolygon(n)?n:this.randomPoint()}getRandomPoint(){if(!this.raw||!this.raw.length)throw new Error(c.noPolygonDataLoaded);const t=w(this.raw);return{x:t.x,y:t.y}}getRandomPointByLength(){var t,e,n;const i=this.options;if(!this.raw||!this.raw.length||!(null===(t=this.paths)||void 0===t?void 0:t.length))throw new Error(c.noPolygonDataLoaded);const o=w(this.paths),r=Math.floor(Math.random()*o.length)+1,s=o.element.getPointAtLength(r);return{x:s.x*i.scale+((null===(e=this.offset)||void 0===e?void 0:e.x)||0),y:s.y*i.scale+((null===(n=this.offset)||void 0===n?void 0:n.y)||0)}}getEquidistantPointByIndex(t){var e,n,i,o,r,s,a;const l=this.container.actualOptions,h=this.options;if(!this.raw||!this.raw.length||!(null===(e=this.paths)||void 0===e?void 0:e.length))throw new Error(c.noPolygonDataLoaded);let u,d=0;const p=this.paths.reduce(((t,e)=>t+e.length),0)/l.particles.number.value;for(const e of this.paths){const n=p*t-d;if(n<=e.length){u=e.element.getPointAtLength(n);break}d+=e.length}return{x:(null!==(n=null==u?void 0:u.x)&&void 0!==n?n:0)*h.scale+(null!==(o=null===(i=this.offset)||void 0===i?void 0:i.x)&&void 0!==o?o:0),y:(null!==(r=null==u?void 0:u.y)&&void 0!==r?r:0)*h.scale+(null!==(a=null===(s=this.offset)||void 0===s?void 0:s.y)&&void 0!==a?a:0)}}getPointByIndex(t){if(!this.raw||!this.raw.length)throw new Error(c.noPolygonDataLoaded);const e=this.raw[t%this.raw.length];return{x:e.x,y:e.y}}createPath2D(){var t,e;const n=this.options;if(this.path2DSupported&&(null===(t=this.paths)||void 0===t?void 0:t.length))for(const t of this.paths){const i=null===(e=t.element)||void 0===e?void 0:e.getAttribute("d");if(i){const e=new Path2D(i),o=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGMatrix(),r=new Path2D,s=o.scale(n.scale);r.addPath?(r.addPath(e,s),t.path2d=r):delete t.path2d}else delete t.path2d;!t.path2d&&this.raw&&(t.path2d=new Path2D,t.path2d.moveTo(this.raw[0].x,this.raw[0].y),this.raw.forEach(((e,n)=>{var i;n>0&&(null===(i=t.path2d)||void 0===i||i.lineTo(e.x,e.y))})),t.path2d.closePath())}}async initRawData(t){const e=this.options;if(e.url)this.raw=await this.downloadSvgPath(e.url,t);else if(e.data){const n=e.data;let i;if("string"!=typeof n){const t=n.path instanceof Array?n.path.map((t=>`<path d="${t}" />`)).join(""):`<path d="${n.path}" />`;i=`<svg ${'xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"'} width="${n.size.width}" height="${n.size.height}">${t}</svg>`}else i=n;this.raw=this.parseSvgPath(i,t)}this.createPath2D()}}class D{constructor(){this.id="polygonMask"}getPlugin(t){return new H(t)}needsPlugin(t){var e,n,i;return null!==(n=null===(e=null==t?void 0:t.polygon)||void 0===e?void 0:e.enable)&&void 0!==n?n:void 0!==(null===(i=null==t?void 0:t.polygon)||void 0===i?void 0:i.type)&&"none"!==t.polygon.type}loadOptions(t,e){if(!this.needsPlugin(e))return;const n=t;let i=n.polygon;void 0===(null==i?void 0:i.load)&&(n.polygon=i=new R),i.load(null==e?void 0:e.polygon)}}async function G(t){g()||"SVGPathSeg"in window||await a.e(404).then(a.t.bind(a,167,23));const e=new D;await t.addPlugin(e)}return l=a.O(l)}()}));