"use strict";(self.webpackChunkelement_web=self.webpackChunkelement_web||[]).push([[716],{"./src/effects/fireworks/index.ts"(t,e,i){i.d(e,{default:()=>r});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 o(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 a={maxCount:500,gravity:.05};class r{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,"particles",[]),(0,s.A)(this,"isRunning",!1),(0,s.A)(this,"start",async(t,e=3e3)=>{t&&(this.isRunning=!0,this.context=t.getContext("2d"),this.supportsAnimationFrame.call(window,this.updateWorld),e&&window.setTimeout(this.stop,e))}),(0,s.A)(this,"updateWorld",()=>{(this.isRunning||0!==this.particles.length)&&(this.update(),this.paint(),this.supportsAnimationFrame.call(window,this.updateWorld))}),(0,s.A)(this,"update",()=>{this.particles.length<this.options.maxCount&&this.isRunning&&this.createFirework();const t=[];for(let e=0;e<this.particles.length;e++)this.move(this.particles[e])&&t.push(this.particles[e]);this.particles=t}),(0,s.A)(this,"paint",()=>{if(this.context&&this.context.canvas){this.context.globalCompositeOperation="destination-out",this.context.fillStyle="rgba(0,0,0,0.5)",this.context.fillRect(0,0,this.context.canvas.width,this.context.canvas.height),this.context.globalCompositeOperation="lighter";for(let t=0;t<this.particles.length;t++)this.drawParticle(this.particles[t])}}),(0,s.A)(this,"createFirework",()=>{if(!this.context||!this.context.canvas)return;const t=this.context.canvas.width,e=this.context.canvas.height,i=Math.random()*(t-200)+100,s=Math.random()*(e-200)+100,n=50*Math.random()+100,o="rgb("+~~(200*Math.random()+55)+","+~~(200*Math.random()+55)+","+~~(200*Math.random()+55)+")";for(let t=0;t<n;t++){const t={};t.color=o,t.w=t.h=4*Math.random()+1,t.x=i-t.w/2,t.y=s-t.h/2,t.vx=10*(Math.random()-.5),t.vy=10*(Math.random()-.5),t.alpha=.5*Math.random()+.5;const e=Math.sqrt(25-t.vx*t.vx);Math.abs(t.vy)>e&&(t.vy=t.vy>0?e:-e),this.particles.push(t)}}),(0,s.A)(this,"stop",async()=>{this.isRunning=!1}),(0,s.A)(this,"drawParticle",t=>{this.context&&this.context.canvas&&(this.context.save(),this.context.beginPath(),this.context.translate(t.x+t.w/2,t.y+t.h/2),this.context.arc(0,0,t.w,0,2*Math.PI),this.context.fillStyle=t.color,this.context.globalAlpha=t.alpha,this.context.closePath(),this.context.fill(),this.context.restore())}),(0,s.A)(this,"move",t=>(t.x+=t.vx,t.vy+=this.options.gravity,t.y+=t.vy,t.alpha-=.01,!(t.x<=-t.w||t.x>=screen.width||t.y>=screen.height||t.alpha<=0))),this.options=o(o({},a),t)}}}}]);
//# sourceMappingURL=716.js.map