class FollowObject{constructor(t,i,e={}){this.container=t,this.object=t.querySelector(i),this.mouseX=0,this.mouseY=0,this.objectX=0,this.objectY=0,this.isVisible=!1,this.options={useOpacity:e.useOpacity||!1,initialOpacity:e.initialOpacity||0,hoverOpacity:e.hoverOpacity||1},this.objectWidth=0,this.objectHeight=0,this.container.addEventListener("mousemove",this.handleMouseMove.bind(this)),this.container.addEventListener("mouseenter",this.handleMouseEnter.bind(this)),this.container.addEventListener("mouseleave",this.handleMouseLeave.bind(this)),this.container.addEventListener("mousedown",this.handleMouseDown.bind(this)),this.container.addEventListener("mouseup",this.handleMouseUp.bind(this)),this.animate=this.animate.bind(this),this.init(),requestAnimationFrame(this.animate)}init(){this.options.useOpacity&&(this.object.style.opacity=this.options.initialOpacity),this.objectWidth=this.object.offsetWidth,this.objectHeight=this.object.offsetHeight}handleMouseMove(t){let i=this.container.getBoundingClientRect();this.mouseX=t.clientX-i.left,this.mouseY=t.clientY-i.top}handleMouseEnter(){this.isVisible=!0,this.options.useOpacity&&(this.object.style.opacity=this.options.hoverOpacity)}handleMouseLeave(){this.isVisible=!1,this.options.useOpacity&&(this.object.style.opacity=this.options.initialOpacity)}handleMouseDown(){this.container.classList.add("mouseclick-wrapper"),this.object.classList.add("mouseclick-obj")}handleMouseUp(){this.container.classList.remove("mouseclick-wrapper"),this.object.classList.remove("mouseclick-obj")}animate(){let t=this.mouseX-this.objectWidth/2-this.objectX,i=this.mouseY-this.objectHeight/2-this.objectY;this.objectX+=.1*t,this.objectY+=.1*i,this.objectX=Math.max(-this.objectWidth/2,Math.min(this.objectX,this.container.clientWidth-this.objectWidth/2)),this.objectY=Math.max(-this.objectHeight/2,Math.min(this.objectY,this.container.clientHeight-this.objectHeight/2)),this.object.style.left=`${this.objectX}px`,this.object.style.top=`${this.objectY}px`,requestAnimationFrame(this.animate)}}let GSCustomCursors=document.querySelectorAll("[data-custom-cursor]");GSCustomCursors.forEach(t=>{let i=JSON.parse(t.getAttribute("data-custom-cursor")),e=i.selector||"[data-custom-cursor-object]",s=i.opacity||!1;e&&new FollowObject(t,e,{useOpacity:s})});