"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),o=require("react"),M=require("react-dom"),w=require("../../../src/modules/ScienceHero/scienceHero.module.css");function S({children:l,backgroundImage:h,cursorLink:m}){const[u,x]=o.useState({x:0,y:0}),[c,a]=o.useState(!1),[g,d]=o.useState(!1),[e,f]=o.useState(null),[s,y]=o.useState(!1);o.useEffect(()=>{d(!0);const t=()=>y(window.innerWidth<=768);return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t),d(!1)}},[]),o.useEffect(()=>{if(s)return;const t=r=>{x({x:r.clientX,y:r.clientY})},i=()=>{if(c&&e){const r=document.querySelector('[data-type="hero"]');r&&f(r.getBoundingClientRect())}};return window.addEventListener("mousemove",t),window.addEventListener("scroll",i,{passive:!0}),window.addEventListener("resize",i,{passive:!0}),()=>{window.removeEventListener("mousemove",t),window.removeEventListener("scroll",i),window.removeEventListener("resize",i)}},[s,c,e]);const b=t=>{s||(f(t.currentTarget.getBoundingClientRect()),a(!0))},C=()=>{s||a(!1)},E=()=>{window.location.href=m};if(s)return n.jsx(n.Fragment,{children:l});const p=`circle(270px at ${u.x}px ${u.y}px)`,v=c&&e&&n.jsx("div",{className:w.cursorContainer,style:{position:"fixed",top:`${e.top}px`,left:`${e.left}px`,width:`${e.width}px`,height:`${e.height}px`,overflow:"hidden",cursor:"pointer"},children:n.jsx("div",{className:w.normalBackground,style:{position:"absolute",top:`${-e.top}px`,left:`${-e.left}px`,backgroundImage:`url(${h})`,clipPath:p,WebkitClipPath:p,backgroundPosition:"center"}})});return n.jsxs(n.Fragment,{children:[n.jsx("div",{"data-type":"hero",onMouseEnter:b,onMouseLeave:C,onClick:E,style:{cursor:"pointer"},children:l}),g&&v&&M.createPortal(v,document.body)]})}exports.ScienceClientCursor=S;
