"use strict";(globalThis.webpackChunkwordpress_particles=globalThis.webpackChunkwordpress_particles||[]).push([[3775],{3775:(i,t,e)=>{e.r(t),e.d(t,{loadInfectionPlugin:()=>f});var n=e(3290);class o{constructor(){this.color=new n.Oz,this.color.value="#ff0000",this.radius=0,this.rate=1}load(i){void 0!==i&&(void 0!==i.color&&(this.color=n.Oz.create(this.color,i.color)),this.duration=i.duration,this.infectedStage=i.infectedStage,void 0!==i.radius&&(this.radius=i.radius),void 0!==i.rate&&(this.rate=i.rate))}}class c{constructor(){this.cure=!1,this.delay=0,this.enable=!1,this.infections=0,this.stages=[]}load(i){void 0!==i&&(void 0!==i.cure&&(this.cure=i.cure),void 0!==i.delay&&(this.delay=i.delay),void 0!==i.enable&&(this.enable=i.enable),void 0!==i.infections&&(this.infections=i.infections),void 0!==i.stages&&(this.stages=i.stages.map((i=>{const t=new o;return t.load(i),t}))))}}class a{constructor(i){this.container=i}startInfection(i,t){const e=this.container.actualOptions;e.infection&&i.infection&&(t>e.infection.stages.length||t<0||(i.infection.delay=0,i.infection.delayStage=t))}updateInfection(i,t){const e=this.container.actualOptions.infection;if(!e||!i.infection)return;const n=e.stages,o=n.length;if(void 0!==i.infection.delay&&void 0!==i.infection.delayStage){const n=i.infection.delayStage;if(n>o||n<0)return;i.infection.delay>=1e3*e.delay?(i.infection.stage=n,i.infection.time=0,delete i.infection.delay,delete i.infection.delayStage):i.infection.delay+=t}else delete i.infection.delay,delete i.infection.delayStage;if(void 0!==i.infection.stage&&void 0!==i.infection.time){const e=n[i.infection.stage];void 0!==e.duration&&e.duration>=0&&i.infection.time>1e3*e.duration?this.nextInfectionStage(i):i.infection.time+=t}else delete i.infection.stage,delete i.infection.time}updateInfectionStage(i,t){const e=this.container.actualOptions;e.infection&&i.infection&&(t>e.infection.stages.length||t<0||void 0!==i.infection.stage&&i.infection.stage>t||(i.infection.stage=t,i.infection.time=0))}nextInfectionStage(i){const t=this.container.actualOptions;if(!t.infection||!i.infection)return;const e=t.infection.stages.length;if(!(e<=0||void 0===i.infection.stage)&&(i.infection.time=0,e<=++i.infection.stage)){if(t.infection.cure)return delete i.infection.stage,void delete i.infection.time;i.infection.stage=0,i.infection.time=0}}}class s{constructor(i){this.container=i,this.container.infecter=new a(this.container)}particleFillColor(i){const t=this.container.actualOptions;if(!i.infection||!t.infection)return;const e=i.infection.stage,n=t.infection.stages;return void 0!==e?n[e].color:void 0}particleStrokeColor(i){return this.particleFillColor(i)}particlesSetup(){var i;const t=this.container.actualOptions;if(t.infection)for(let e=0;e<t.infection.infections;e++){const t=this.container.particles.array.filter((i=>{const t=i;return t.infection||(t.infection={}),void 0===t.infection.stage})),e=(0,n.c8)(t);null===(i=this.container.infecter)||void 0===i||i.startInfection(e,0)}}}class l extends n.$S{constructor(i){super(i)}clear(){}init(){}async interact(i,t){var e,o,c,a,s;const l=this.container.infecter;if(!l)return;if(l.updateInfection(i,t.value),void 0===(null===(e=i.infection)||void 0===e?void 0:e.stage))return;const r=this.container,f=r.actualOptions.infection;if(!(null==f?void 0:f.enable)||f.stages.length<1)return;const d=f.stages[i.infection.stage],u=r.retina.pixelRatio,g=2*i.getRadius()+d.radius*u,v=i.getPosition(),h=null!==(o=d.infectedStage)&&void 0!==o?o:i.infection.stage,p=r.particles.quadTree.queryCircle(v,g),y=d.rate,S=p.length;for(const t of p){const e=t;if(!(e===i||e.destroyed||e.spawning||void 0!==(null===(c=e.infection)||void 0===c?void 0:c.stage)&&e.infection.stage===i.infection.stage)&&(0,n.sZ)()<y/S)if(void 0===(null===(a=e.infection)||void 0===a?void 0:a.stage))l.startInfection(e,h);else if(e.infection.stage<i.infection.stage)l.updateInfectionStage(e,h);else if(e.infection.stage>i.infection.stage){const t=f.stages[e.infection.stage],n=null!==(s=null==t?void 0:t.infectedStage)&&void 0!==s?s:e.infection.stage;l.updateInfectionStage(i,n)}}}isEnabled(){var i,t,e;return null!==(e=null===(t=null===(i=this.container.actualOptions)||void 0===i?void 0:i.infection)||void 0===t?void 0:t.enable)&&void 0!==e&&e}reset(){}}class r{constructor(){this.id="infection"}getPlugin(i){return new s(i)}loadOptions(i,t){if(!this.needsPlugin(t))return;let e=i.infection;void 0===(null==e?void 0:e.load)&&(i.infection=e=new c),e.load(null==t?void 0:t.infection)}needsPlugin(i){var t,e;return null!==(e=null===(t=null==i?void 0:i.infection)||void 0===t?void 0:t.enable)&&void 0!==e&&e}}async function f(i){const t=new r;await i.addPlugin(t),await i.addInteractor("particlesInfection",(i=>new l(i)))}}}]);