{"version":3,"file":"BackToTopButton.BdBXx72S.mjs","names":["useState","_Fragment"],"sources":["https:/framerusercontent.com/modules/TOGMv3wr2k6qqEep82Hk/t9uExaeaUZVaHis9rbYN/BackToTopButton.js"],"sourcesContent":["// Back to top button that appears when user scrolls down a certain distance\nimport{jsx as _jsx,Fragment as _Fragment}from\"react/jsx-runtime\";import{useState,useEffect,startTransition}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{motion,AnimatePresence}from\"framer-motion\";/**\n * Back to Top Button\n *\n * @framerIntrinsicWidth 60\n * @framerIntrinsicHeight 60\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function BackToTopButton(props){const{scrollDistance=300,customIcon={src:\"https://framerusercontent.com/images/GfGkADagM4KEibNcIiRUWlfrR0.jpg\",alt:\"Icon\"},iconSize=60,soundEffect=\"https://framerusercontent.com/assets/8w3IUatLX9a5JVJ6XPCVuHi94.mp3\",style}=props;const[isVisible,setIsVisible]=useState(false);const isCanvas=RenderTarget.current()===RenderTarget.canvas;useEffect(()=>{if(typeof window===\"undefined\"||isCanvas)return;let timeoutId=null;const handleScroll=()=>{if(timeoutId!==null)return;timeoutId=window.setTimeout(()=>{const scrollTop=window.scrollY;const docHeight=document.documentElement.scrollHeight-window.innerHeight;const scrollPercent=scrollTop/docHeight*100;const shouldShow=scrollPercent>=scrollDistance;startTransition(()=>setIsVisible(shouldShow));timeoutId=null;},100);};window.addEventListener(\"scroll\",handleScroll,{passive:true});handleScroll();return()=>{window.removeEventListener(\"scroll\",handleScroll);if(timeoutId!==null){clearTimeout(timeoutId);}};},[scrollDistance,isCanvas]);const scrollToTop=()=>{if(typeof window===\"undefined\")return;// Play sound effect if provided\nif(soundEffect){const audio=new Audio(soundEffect);audio.play().catch(error=>{console.warn(\"Failed to play sound:\",error);});}window.scrollTo({top:0,behavior:\"smooth\"});};return /*#__PURE__*/_jsx(_Fragment,{children:isCanvas?/*#__PURE__*/_jsx(\"button\",{onClick:scrollToTop,style:{...style,backgroundColor:\"transparent\",border:\"none\",padding:0,cursor:\"pointer\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",width:`${iconSize}px`,height:`${iconSize}px`},\"aria-label\":\"Back to top\",children:/*#__PURE__*/_jsx(\"img\",{src:customIcon.src,alt:customIcon.alt||\"Back to top icon\",style:{width:\"100%\",height:\"100%\",objectFit:\"contain\"}})}):/*#__PURE__*/_jsx(AnimatePresence,{children:isVisible&&/*#__PURE__*/_jsx(motion.button,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.2},onClick:scrollToTop,style:{...style,backgroundColor:\"transparent\",border:\"none\",padding:0,cursor:\"pointer\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",zIndex:1e3,width:`${iconSize}px`,height:`${iconSize}px`},whileHover:{scale:1.05},whileTap:{scale:.95},\"aria-label\":\"Back to top\",children:/*#__PURE__*/_jsx(\"img\",{src:customIcon.src,alt:customIcon.alt||\"Back to top icon\",style:{width:\"100%\",height:\"100%\",objectFit:\"contain\"}})})})});}addPropertyControls(BackToTopButton,{scrollDistance:{type:ControlType.Number,title:\"Show After Scroll %\",description:\"Set scroll percentage (percentage of total page height after which the button appears)\",defaultValue:20,min:0,max:100,step:5,unit:\"%\"},customIcon:{type:ControlType.ResponsiveImage,title:\"Icon Image\"},iconSize:{type:ControlType.Number,title:\"Icon Size\",defaultValue:60,min:20,max:120,step:5,unit:\"px\"},soundEffect:{type:ControlType.File,title:\"Sound Effect\",allowedFileTypes:[\"mp3\",\"wav\",\"ogg\"]}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"BackToTopButton\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"fixed\",\"framerIntrinsicWidth\":\"60\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerIntrinsicHeight\":\"60\"}},\"__FramerMetadata__\":{\"type\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