"use strict";(globalThis.webpackChunkultimate_cursor=globalThis.webpackChunkultimate_cursor||[]).push([[885],{9885(e,t,i){i.d(t,{default:()=>l});var n=i(1609),r=i(790);class o{lifeSpan;initialLifeSpan;velocity;position;baseDimension;fillColor;strokeColor;constructor(e,t,i={}){this.initialLifeSpan=Math.floor(60*Math.random()+60),this.lifeSpan=this.initialLifeSpan,this.velocity={x:(Math.random()<.5?-1:1)*(Math.random()/10),y:-1*Math.random()-.4},this.position={x:e,y:t},this.baseDimension=i.bubbleSize||4,this.fillColor=i.bubbleFillColor||"#e6f1f7",this.strokeColor=i.bubbleStrokeColor||"#3a92c5"}update(e){this.position.x+=this.velocity.x,this.position.y+=this.velocity.y,this.velocity.x+=2*(Math.random()<.5?-1:1)/75,this.velocity.y-=Math.random()/600,this.lifeSpan--;const t=.2+(this.initialLifeSpan-this.lifeSpan)/this.initialLifeSpan;e.fillStyle=this.fillColor,e.strokeStyle=this.strokeColor,e.beginPath(),e.arc(this.position.x-this.baseDimension/2*t,this.position.y-this.baseDimension/2,this.baseDimension*t,0,2*Math.PI),e.stroke(),e.fill(),e.closePath()}}const l=({wrapperElement:e,props:t})=>{const{bubbleSize:i,bubbleFillColor:l,bubbleStrokeColor:s}=t||{},h=(0,n.useRef)(null),u=(0,n.useRef)([]),c=(0,n.useRef)({x:0,y:0}),a=(0,n.useRef)(null),[b,f]=(0,n.useState)({width:0,height:0}),d=(0,n.useRef)({bubbleSize:i,bubbleFillColor:l,bubbleStrokeColor:s});(0,n.useEffect)(()=>{t&&(d.current={bubbleSize:t.bubbleSize,bubbleFillColor:t.bubbleFillColor,bubbleStrokeColor:t.bubbleStrokeColor})},[t]),(0,n.useEffect)(()=>{const t=()=>{f(e?{width:e.clientWidth,height:e.clientHeight}:{width:window.innerWidth,height:window.innerHeight})};return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[e]),(0,n.useEffect)(()=>{if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;const t=h.current;if(!t)return;const i=t.getContext("2d");if(!i)return;const n=e=>{if(e.touches.length>0)for(let t=0;t<e.touches.length;t++)l(e.touches[t].clientX,e.touches[t].clientY)},r=t=>{if(e){const i=e.getBoundingClientRect();c.current.x=t.clientX-i.left,c.current.y=t.clientY-i.top}else c.current.x=t.clientX,c.current.y=t.clientY;l(c.current.x,c.current.y)},l=(e,t)=>{u.current.push(new o(e,t,d.current))},s=()=>{(()=>{if(0!==u.current.length){i.clearRect(0,0,t.width,t.height);for(let e=0;e<u.current.length;e++)u.current[e].update(i);for(let e=u.current.length-1;e>=0;e--)u.current[e].lifeSpan<0&&u.current.splice(e,1);0===u.current.length&&i.clearRect(0,0,t.width,t.height)}})(),a.current=requestAnimationFrame(s)},b=e||document.body;return b.addEventListener("mousemove",r),b.addEventListener("touchmove",n,{passive:!0}),b.addEventListener("touchstart",n,{passive:!0}),s(),()=>{a.current&&(cancelAnimationFrame(a.current),a.current=null),u.current=[],b.removeEventListener("mousemove",r),b.removeEventListener("touchmove",n),b.removeEventListener("touchstart",n)}},[e,b]);const p={position:e?"absolute":"fixed",top:0,left:0,pointerEvents:"none",width:b.width,height:b.height};return(0,r.jsx)("canvas",{ref:h,style:p,width:b.width,height:b.height})}}}]);