"use strict";(self.webpackChunkelement_web=self.webpackChunkelement_web||[]).push([[6358],{"./src/effects/confetti/index.ts"(t,e,i){i.d(e,{default:()=>a});var s=i("../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/esm/defineProperty.js");function n(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?n(Object(i),!0).forEach(function(e){(0,s.A)(t,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):n(Object(i)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))})}return t}const o={maxCount:150,speed:3,frameInterval:15,alpha:1,gradient:!1};class a{constructor(t){(0,s.A)(this,"options",void 0),(0,s.A)(this,"context",null),(0,s.A)(this,"supportsAnimationFrame",window.requestAnimationFrame),(0,s.A)(this,"colors",["rgba(30,144,255,","rgba(107,142,35,","rgba(255,215,0,","rgba(255,192,203,","rgba(106,90,205,","rgba(173,216,230,","rgba(238,130,238,","rgba(152,251,152,","rgba(70,130,180,","rgba(244,164,96,","rgba(210,105,30,","rgba(220,20,60,"]),(0,s.A)(this,"lastFrameTime",Date.now()),(0,s.A)(this,"particles",[]),(0,s.A)(this,"waveAngle",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,this.runAnimation(),e&&window.setTimeout(this.stop,e)}),(0,s.A)(this,"stop",async()=>{this.isRunning=!1}),(0,s.A)(this,"resetParticle",(t,e,i)=>(t.color=this.colors[Math.random()*this.colors.length|0]+(this.options.alpha+")"),this.options.gradient?t.color2=this.colors[Math.random()*this.colors.length|0]+(this.options.alpha+")"):t.color2=t.color,t.x=Math.random()*e,t.y=Math.random()*-i,t.diameter=10*Math.random()+5,t.tilt=-10*Math.random(),t.tiltAngleIncrement=.07*Math.random()+.05,t.tiltAngle=Math.random()*Math.PI,t)),(0,s.A)(this,"runAnimation",()=>{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{const t=Date.now(),e=t-this.lastFrameTime;(!this.supportsAnimationFrame||e>this.options.frameInterval)&&(this.context.clearRect(0,0,this.context.canvas.width,this.context.canvas.height),this.updateParticles(),this.drawParticles(this.context),this.lastFrameTime=t-e%this.options.frameInterval),requestAnimationFrame(this.runAnimation)}}),(0,s.A)(this,"drawParticles",t=>{if(!this.context||!this.context.canvas)return;let e,i,s;for(const n of this.particles){if(this.context.beginPath(),t.lineWidth=n.diameter,i=n.x+n.tilt,e=i+n.diameter/2,s=n.y+n.tilt+n.diameter/2,this.options.gradient){const r=t.createLinearGradient(e,n.y,i,s);r.addColorStop(0,n.color),r.addColorStop(1,n.color2),t.strokeStyle=r}else t.strokeStyle=n.color;t.moveTo(e,n.y),t.lineTo(i,s),t.stroke()}}),(0,s.A)(this,"updateParticles",()=>{if(!this.context||!this.context.canvas)return;const t=this.context.canvas.width,e=this.context.canvas.height;let i;this.waveAngle+=.01;for(let s=0;s<this.particles.length;s++)i=this.particles[s],!this.isRunning&&i.y<-15?i.y=e+100:(i.tiltAngle+=i.tiltAngleIncrement,i.x+=Math.sin(this.waveAngle)-.5,i.y+=.5*(Math.cos(this.waveAngle)+i.diameter+this.options.speed),i.tilt=15*Math.sin(i.tiltAngle)),(i.x>t+20||i.x<-20||i.y>e)&&(this.isRunning&&this.particles.length<=this.options.maxCount?this.resetParticle(i,t,e):(this.particles.splice(s,1),s--))}),this.options=r(r({},o),t)}}}}]);
//# sourceMappingURL=6358.js.map