import{j as H}from"./vendor-query-Dz__kayo.js";import{r as d}from"./vendor-react-DszrpDkA.js";function _({density:b=2e4,alphaMin:y=.45,alphaMax:E=.75}){const P=d.useRef(null),w=d.useRef(),m=d.useRef([]),x=d.useRef({x:-9999,y:-9999}),f=d.useRef({w:0,h:0});return d.useEffect(()=>{const a=P.current;if(!a)return;const n=a.getContext("2d");if(!n)return;const T=["rgba(242, 80, 106, ","rgba(242, 80, 106, ","rgba(242, 80, 106, ","rgba(182, 122, 236, ","rgba(182, 122, 236, ","rgba(182, 122, 236, ","rgba(155, 81, 224, "],k=()=>{const t=window.devicePixelRatio||1,e=a.offsetWidth,o=a.offsetHeight;a.width=e*t,a.height=o*t,n.setTransform(t,0,0,t,0,0),f.current={w:e,h:o}},L=()=>{const{w:t,h:e}=f.current,o=Math.floor(t*e/b),c=E-y;m.current=Array.from({length:o},()=>({x:Math.random()*t,y:Math.random()*e,vx:(Math.random()-.5)*.25,vy:(Math.random()-.5)*.25,radius:Math.random()*5+2,color:T[Math.floor(Math.random()*T.length)],alpha:Math.random()*c+y}))},q=t=>{n.beginPath(),n.arc(t.x,t.y,t.radius,0,Math.PI*2),n.fillStyle=t.color+t.alpha+")",n.fill()},D=()=>{const t=m.current,e=x.current,o=140,c=130;for(let r=0;r<t.length;r++){for(let s=r+1;s<t.length;s++){const i=t[r].x-t[s].x,l=t[r].y-t[s].y,u=Math.sqrt(i*i+l*l);u<o&&(n.beginPath(),n.strokeStyle=`rgba(182, 122, 236, ${(1-u/o)*.38})`,n.lineWidth=1.2,n.moveTo(t[r].x,t[r].y),n.lineTo(t[s].x,t[s].y),n.stroke())}if(e.x!==-9999){const s=t[r].x-e.x,i=t[r].y-e.y,l=Math.sqrt(s*s+i*i);l<c&&(n.beginPath(),n.strokeStyle=`rgba(242, 80, 106, ${(1-l/c)*.55})`,n.lineWidth=1,n.moveTo(e.x,e.y),n.lineTo(t[r].x,t[r].y),n.stroke())}}},j=t=>{const e=x.current,{w:o,h:c}=f.current,r=110,s=.35,i=4,l=.97;if(e.x!==-9999){const M=t.x-e.x,R=t.y-e.y,h=Math.sqrt(M*M+R*R);if(h<r&&h>0){const S=(r-h)/r*s;t.vx+=M/h*S,t.vy+=R/h*S}}t.vx*=l,t.vy*=l;const u=Math.sqrt(t.vx*t.vx+t.vy*t.vy);u>i&&(t.vx=t.vx/u*i,t.vy=t.vy/u*i),t.x+=t.vx,t.y+=t.vy,(t.x<0||t.x>o)&&(t.vx*=-1),(t.y<0||t.y>c)&&(t.vy*=-1),t.x=Math.max(0,Math.min(o,t.x)),t.y=Math.max(0,Math.min(c,t.y))},z=window.matchMedia("(pointer: coarse)").matches;if(k(),L(),z){const t=setTimeout(()=>{m.current.forEach(q)},300);return()=>clearTimeout(t)}const g=()=>{const{w:t,h:e}=f.current;n.clearRect(0,0,t,e),D(),m.current.forEach(o=>{j(o),q(o)}),w.current=requestAnimationFrame(g)};let v;"requestIdleCallback"in window?v=requestIdleCallback(()=>g(),{timeout:1500}):v=setTimeout(g,200);const C=()=>{k(),L()},I=t=>{const e=a.getBoundingClientRect(),o=t.clientX-e.left,c=t.clientY-e.top,{w:r,h:s}=f.current;x.current=o>=0&&o<=r&&c>=0&&c<=s?{x:o,y:c}:{x:-9999,y:-9999}},A=()=>{x.current={x:-9999,y:-9999}};return window.addEventListener("resize",C),window.addEventListener("mousemove",I),a.addEventListener("mouseleave",A),()=>{window.removeEventListener("resize",C),window.removeEventListener("mousemove",I),a.removeEventListener("mouseleave",A),w.current&&cancelAnimationFrame(w.current),"requestIdleCallback"in window&&v!==void 0&&cancelIdleCallback(v)}},[b,y,E]),H.jsx("canvas",{ref:P,className:"absolute inset-0 w-full h-full",style:{display:"block"}})}export{_ as P};