document.addEventListener("DOMContentLoaded",()=>{let t=document.querySelector("#sp-smart-post-back-to-top-btn");if(!t)return;let e=t.querySelector(".sp-smart-post-back-to-top-icon"),s=t.querySelector(".sp-smart-post-back-to-top-text.sp-back-to-top-text"),l=t.querySelector(".sp-smart-post-back-to-top-text.sp-go-to-bottom-text"),o=1e3*parseInt(t.dataset?.transition)||1e3,a=t.dataset?.goBottom||!1,n=t.dataset?.animation||"fade-in",r={"fade-in":"translate(0px, 0px)","slide-in-left":"translate(10px, 0px)","slide-in-right":"translate(-10px, 0px)","slide-in-up":"translate(0px, 10px)"};t.style.transition="all 0.3s ease",e.style.transition="transform 0.3s ease";let i=window.scrollY,p=null,c=t=>{s&&l&&(s.classList.add(t?"sp-hide-label":"sp-show-label"),s.classList.remove(t?"sp-show-label":"sp-hide-label"),l.classList.add(t?"sp-show-label":"sp-hide-label"),l.classList.remove(t?"sp-hide-label":"sp-show-label"))};function d(){let e=window.scrollY;e>350?(t.style.display="inline-block",t.offsetHeight,t.style.opacity="1",t.style.transform="translate(0px, 0px)"):(t.style.opacity="0",t.style.transform=r[n],setTimeout(()=>{window.scrollY<=250&&(t.style.display="none")},300))}function $(t,e=null){let s=window.scrollY,l="down"===e?document.body.scrollHeight:0,o=l-s,a=performance.now();function n(e){let l=e-a,r=Math.min(l/t,1);window.scrollTo(0,s+o*(r<.5?4*r**3:1-Math.pow(-2*r+2,3)/2)),l<t&&requestAnimationFrame(n)}requestAnimationFrame(n)}function y(e=50,s=0){return new Promise(l=>{setTimeout(()=>{let s=t.getBoundingClientRect(),o=s.top+window.scrollY+s.height,a=document.documentElement.scrollHeight;l(a-o<=e)},s+100)})}async function u(){await y(100,o)&&(p="up",e.style.transform="rotateX(0deg)",c(!1))}window.addEventListener("scroll",()=>{if(a){let t=window.scrollY;t>i?(p="down",e.style.transform="rotateX(180deg)",c(!0)):t<i&&(p="up",e.style.transform="rotateX(0deg)",c(!1)),i=t}u()}),t.addEventListener("click",t=>{t.preventDefault(),$(o,a?p:null),u()}),c(!1),d(),u();let f;window.addEventListener("scroll",()=>{f&&cancelAnimationFrame(f),f=requestAnimationFrame(d)})});