(()=>{const randomRange=(t,i)=>Math.random()*(i-t)+t,t=[{front:"#52A7DD",back:"#2287BD"},{front:"#f07178",back:"#c04148"},{front:"#ffcb6b",back:"#cf9b3b"}];function Confetto(i,s){this.options=s,this.randomModifier=randomRange(0,99),this.color=t[Math.floor(randomRange(0,t.length))],this.dimensions={x:randomRange(8,16),y:randomRange(8,14)},this.position={x:randomRange(i.width/2,i.width/2),y:randomRange(i.height/2,i.height/2)},this.rotation=randomRange(0,2*Math.PI),this.scale={x:1,y:1},this.velocity=((t,i)=>{const s=randomRange(t[0],t[1]),o=i[1]-i[0]+1;let e=i[1]-Math.abs(randomRange(0,o)+randomRange(0,o)-o);return e>=i[1]-1&&(e+=Math.random()<.25?randomRange(1,3):0),{x:s,y:-e}})([-9,9],[6,11])}function Sequin(i,s){this.options=s,this.color=t[Math.floor(randomRange(0,t.length))].back,this.radius=randomRange(1,2),this.position={x:randomRange(i.width/2,i.width/2),y:randomRange(i.height/2,i.height/2)},this.velocity={x:randomRange(-6,6),y:randomRange(-8,-12)}}Confetto.prototype.update=function(){this.velocity.x-=this.velocity.x*this.options.dragConfetti,this.velocity.y=Math.min(this.velocity.y+this.options.gravityConfetti,this.options.terminalVelocity),this.velocity.x+=Math.random()>.5?Math.random():-Math.random(),this.position.x+=this.velocity.x,this.position.y+=this.velocity.y,this.scale.y=Math.cos(.09*(this.position.y+this.randomModifier))},Sequin.prototype.update=function(){this.velocity.x-=this.velocity.x*this.options.dragSequins,this.velocity.y=this.velocity.y+this.options.gravitySequins,this.position.x+=this.velocity.x,this.position.y+=this.velocity.y};class Confetti extends HTMLElement{constructor(){super(),this.canvas=null,this.confetti=[],this.sequins=[],this.options={confettiCount:55,sequinCount:30,gravityConfetti:.25,gravitySequins:.35,dragConfetti:.025,dragSequins:.02,terminalVelocity:4}}connectedCallback(){this.style="display: block; position: relative;",this.canvas=globalThis.document.createElement("canvas"),this.canvas.id="confetti-container-canvas-🎉",this.ctx=this.canvas.getContext("2d"),this.canvas.width=this.offsetWidth,this.canvas.height=this.offsetHeight,this.canvas.style="pointer-events: none; position: absolute; top:0; left: 0; width: 100%; height: 100%; z-index: 1000; image-rendering: crisp-edges;",this.prepend(this.canvas)}static get observedAttributes(){return["popped"]}attributeChangedCallback(t,i,s){const o=globalThis.matchMedia("(prefers-reduced-motion: reduce)").matches;"popped"===t&&null===i&&!o?this.popConfetti():o&&this.removeAttribute("popped")}popConfetti(){for(let t=0;t<this.options.confettiCount;t++)this.confetti.push(new Confetto(this.canvas,this.options));for(let t=0;t<this.options.sequinCount;t++)this.sequins.push(new Sequin(this.canvas,this.options));this.render()}render(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.confetti.forEach(((t,i)=>{let s=t.dimensions.x*t.scale.x,o=t.dimensions.y*t.scale.y;this.ctx.translate(t.position.x,t.position.y),this.ctx.rotate(t.rotation),t.update(),this.ctx.fillStyle=t.scale.y>0?t.color.front:t.color.back,this.ctx.fillRect(-s/2,-o/2,s,o),this.ctx.setTransform(1,0,0,1,0,0)})),this.sequins.forEach(((t,i)=>{this.ctx.translate(t.position.x,t.position.y),t.update(),this.ctx.fillStyle=t.color,this.ctx.beginPath(),this.ctx.arc(0,0,t.radius,0,2*Math.PI),this.ctx.fill(),this.ctx.setTransform(1,0,0,1,0,0)})),this.confetti.forEach(((t,i)=>{t.position.y-25>=this.canvas.height&&this.confetti.splice(i,1)})),this.sequins.forEach(((t,i)=>{t.position.y-25>=this.canvas.height&&this.sequins.splice(i,1)})),this.sequins.length||this.confetti.length?globalThis.requestAnimationFrame(this.render.bind(this)):this.removeAttribute("popped")}}globalThis.customElements&&globalThis.customElements.define&&customElements.define("confetti-container",Confetti)})();