"use strict";(self.webpackChunkelement_web=self.webpackChunkelement_web||[]).push([[3197],{"./src/effects/rainfall/index.ts":(t,e,i)=>{i.d(e,{default:()=>c});var s=i("./node_modules/@babel/runtime/helpers/esm/defineProperty.js"),n=i("./src/utils/arrays.ts");function o(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,s)}return i}function r(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?o(Object(i),!0).forEach(function(e){(0,s.A)(t,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):o(Object(i)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))})}return t}const h={maxCount:600,speed:12};class c{constructor(t){(0,s.A)(this,"options",void 0),(0,s.A)(this,"context",null),(0,s.A)(this,"particles",[]),(0,s.A)(this,"lastAnimationTime",0),(0,s.A)(this,"isRunning",!1),(0,s.A)(this,"start",async(t,e=3e3)=>{if(!t)return;this.context=t.getContext("2d"),this.particles=[];const i=this.options.maxCount;for(;this.particles.length<i;)this.particles.push(this.resetParticle({},t.width,t.height));this.isRunning=!0,requestAnimationFrame(this.renderLoop),e&&window.setTimeout(this.stop,e)}),(0,s.A)(this,"stop",async()=>{this.isRunning=!1}),(0,s.A)(this,"resetParticle",(t,e,i)=>(t.x=Math.random()*e,t.y=Math.random()*-i,t.width=1.5*Math.random(),t.height=15*t.width+4,t.speed=Math.random()*this.options.speed*4/5+this.options.speed,t)),(0,s.A)(this,"renderLoop",()=>{if(this.context&&this.context.canvas)if(0===this.particles.length)this.context.clearRect(0,0,this.context.canvas.width,this.context.canvas.height);else{(Date.now()-this.lastAnimationTime>=15||!this.lastAnimationTime)&&(this.context.clearRect(0,0,this.context.canvas.width,this.context.canvas.height),this.lastAnimationTime=Date.now(),this.animateAndRenderRaindrops()),requestAnimationFrame(this.renderLoop)}}),(0,s.A)(this,"animateAndRenderRaindrops",()=>{if(!this.context||!this.context.canvas)return;const t=this.context.canvas.height;for(const e of(0,n.PF)(this.particles)){e.y+=e.speed,this.context.save(),this.context.beginPath(),this.context.rect(e.x,e.y,e.width,e.height),this.context.fillStyle="#5dadec",this.context.fill(),this.context.closePath(),this.context.restore();const i=2*t;if(e.y>t+i){const t=this.particles.indexOf(e);this.particles.splice(t,1)}}}),this.options=r(r({},h),t)}}}}]);
//# sourceMappingURL=3197.js.map