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GnCE,KAAKE,QAAQsC,OACbxC,KAAKE,QAAQuC,YAEbzC,KAAKE,QAAQwC,UAAUZ,EAASG,EAAIH,EAASC,EAAI,EAAGD,EAASI,EAAIJ,EAASE,EAAI,GAC9EhC,KAAKE,QAAQyC,IAAI,EAAG,EAAGb,EAASC,EAAG,EAAa,EAAVN,KAAKmB,IAC3C5C,KAAKE,QAAQiB,UAAYW,EAASD,MAClC7B,KAAKE,QAAQ2C,YAAcf,EAASO,MAEpCrC,KAAKE,QAAQ4C,YACb9C,KAAKE,QAAQ6C,OACb/C,KAAKE,QAAQ8C,cAChBtD,EAAAA,EAAAA,GAAA,YAEeoC,IACZA,EAASG,GAAKH,EAASK,GACvBL,EAASM,IAAMpC,KAAKP,QAAQH,QAC5BwC,EAASI,GAAKJ,EAASM,GACvBN,EAASO,OAAS,MAEdP,EAASG,IAAMH,EAASC,GACxBD,EAASG,GAAKgB,OAAO5B,OACrBS,EAASI,GAAKe,OAAO3B,QACrBQ,EAASO,OAAS,KAjHtBrC,KAAKP,QAAOyD,EAAAA,EAAA,GAAQ9D,GAAmBK,EAC3C,E","sources":["webpack://element-web/./src/effects/fireworks/index.ts"],"sourcesContent":["/*\nCopyright 2024 New Vector Ltd.\nCopyright 2023 The Matrix.org Foundation C.I.C.\nCopyright 2020 Nurjin Jafar\nCopyright 2020 Nordeck IT + Consulting GmbH.\n\nSPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial\nPlease see LICENSE files in the repository root for full details.\n */\n\nimport type ICanvasEffect from \"../ICanvasEffect\";\n\nexport type FireworksOptions = {\n /**\n * max fireworks count\n */\n maxCount: number;\n /**\n * gravity value that firework adds to shift from it's start position\n */\n gravity: number;\n};\n\ntype FireworksParticle = {\n /**\n * color\n */\n color: string;\n /**\n * x,y are the point where the particle starts to position on canvas\n */\n x: number;\n y: number;\n /**\n * vx,vy shift values from x and y\n */\n vx: number;\n vy: number;\n /**\n * the alpha opacity of the firework particle (between 0 and 1, where 1 is opaque and 0 is invisible)\n */\n alpha: number;\n /**\n * w,h width and height\n */\n w: number;\n h: number;\n};\n\nexport const DefaultOptions: FireworksOptions = {\n maxCount: 500,\n gravity: 0.05,\n};\n\nexport default class Fireworks implements ICanvasEffect {\n private readonly options: FireworksOptions;\n\n public constructor(options: { [key: string]: any }) {\n this.options = { ...DefaultOptions, ...options };\n }\n\n private context: CanvasRenderingContext2D | null = null;\n private supportsAnimationFrame = window.requestAnimationFrame;\n private particles: Array<FireworksParticle> = [];\n public isRunning = false;\n\n public start = async (canvas: HTMLCanvasElement, timeout = 3000): Promise<void> => {\n if (!canvas) {\n return;\n }\n this.isRunning = true;\n this.context = canvas.getContext(\"2d\");\n this.supportsAnimationFrame.call(window, this.updateWorld);\n if (timeout) {\n window.setTimeout(this.stop, timeout);\n }\n };\n\n private updateWorld = (): void => {\n if (!this.isRunning && this.particles.length === 0) return;\n this.update();\n this.paint();\n this.supportsAnimationFrame.call(window, this.updateWorld);\n };\n\n private update = (): void => {\n if (this.particles.length < this.options.maxCount && this.isRunning) {\n this.createFirework();\n }\n const alive: FireworksParticle[] = [];\n for (let i = 0; i < this.particles.length; i++) {\n if (this.move(this.particles[i])) {\n alive.push(this.particles[i]);\n }\n }\n this.particles = alive;\n };\n\n private paint = (): void => {\n if (!this.context || !this.context.canvas) return;\n this.context.globalCompositeOperation = \"destination-out\";\n this.context.fillStyle = \"rgba(0,0,0,0.5)\";\n this.context.fillRect(0, 0, this.context.canvas.width, this.context.canvas.height);\n this.context.globalCompositeOperation = \"lighter\";\n for (let i = 0; i < this.particles.length; i++) {\n this.drawParticle(this.particles[i]);\n }\n };\n\n private createFirework = (): void => {\n if (!this.context || !this.context.canvas) return;\n const width = this.context.canvas.width;\n const height = this.context.canvas.height;\n const xPoint = Math.random() * (width - 200) + 100;\n const yPoint = Math.random() * (height - 200) + 100;\n const nFire = Math.random() * 50 + 100;\n const color =\n \"rgb(\" +\n ~~(Math.random() * 200 + 55) +\n \",\" +\n ~~(Math.random() * 200 + 55) +\n \",\" +\n ~~(Math.random() * 200 + 55) +\n \")\";\n for (let i = 0; i < nFire; i++) {\n const particle = <FireworksParticle>{};\n particle.color = color;\n particle.w = particle.h = Math.random() * 4 + 1;\n particle.x = xPoint - particle.w / 2;\n particle.y = yPoint - particle.h / 2;\n particle.vx = (Math.random() - 0.5) * 10;\n particle.vy = (Math.random() - 0.5) * 10;\n particle.alpha = Math.random() * 0.5 + 0.5;\n const vy = Math.sqrt(25 - particle.vx * particle.vx);\n if (Math.abs(particle.vy) > vy) {\n particle.vy = particle.vy > 0 ? vy : -vy;\n }\n this.particles.push(particle);\n }\n };\n\n public stop = async (): Promise<void> => {\n this.isRunning = false;\n };\n\n private drawParticle = (particle: FireworksParticle): void => {\n if (!this.context || !this.context.canvas) {\n return;\n }\n this.context.save();\n this.context.beginPath();\n\n this.context.translate(particle.x + particle.w / 2, particle.y + particle.h / 2);\n this.context.arc(0, 0, particle.w, 0, Math.PI * 2);\n this.context.fillStyle = particle.color;\n this.context.globalAlpha = particle.alpha;\n\n this.context.closePath();\n this.context.fill();\n this.context.restore();\n };\n\n private move = (particle: FireworksParticle): boolean => {\n particle.x += particle.vx;\n particle.vy += this.options.gravity;\n particle.y += particle.vy;\n particle.alpha -= 0.01;\n return !(\n particle.x <= -particle.w ||\n particle.x >= screen.width ||\n particle.y >= screen.height ||\n particle.alpha <= 0\n );\n };\n}\n"],"names":["DefaultOptions","maxCount","gravity","Fireworks","constructor","options","_defineProperty","window","requestAnimationFrame","async","canvas","timeout","this","isRunning","context","getContext","supportsAnimationFrame","call","updateWorld","setTimeout","stop","particles","length","update","paint","createFirework","alive","i","move","push","globalCompositeOperation","fillStyle","fillRect","width","height","drawParticle","xPoint","Math","random","yPoint","nFire","color","particle","w","h","x","y","vx","vy","alpha","sqrt","abs","save","beginPath","translate","arc","PI","globalAlpha","closePath","fill","restore","screen","_objectSpread"],"sourceRoot":""}