"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),core=require("@gem-sdk/core"),useTranslateValue=require("./useTranslateValue.js"),useIntersectionObserver=require("./useIntersectionObserver.js"),helpers=require("../common/helpers.js"),animationManager=require("../common/animation-manager.js");const useHeroBanner=(e,t,r)=>{let{hoverEffect:a,hoverEffectScale:n,background:s}=e||{},{link:u,enableParallax:l}=t||{},i=Number(t?.speedParallax)||0,[o,c]=React.useState(0),[g,d]=React.useState(null),[m,p]=React.useState(null),[R,f]=React.useState(""),v=React.useRef(null),[B,b]=useIntersectionObserver.default(),{translateValue:x}=useTranslateValue.useTranslateValue({containerBoundingClientRect:g,backgroundBoundingClientRect:m,speed:i}),M=core.getResponsiveValueByScreen(t?.layout,r),q=helpers.getResponsiveSetting(s||{}),y=l&&Number(t?.speedParallax||0)>0&&q[r]?.type==="image"||!1,S=()=>{a&&y&&f(`${R} scale(${n||"100%"})`)},V=()=>{a&&y&&f(`translateY(${x}px)`)},j=e=>{u?.link&&!e?.srcElement?.closest("a")&&window.open(u?.link,u.target)};React.useEffect(()=>{y?f(`translateY(${x}px)`):f("")},[x,y]);let H=React.useCallback(()=>{if(!y||0===i||!b)return;let e=Number(window.scrollY.toFixed(0));o!==e&&(d(B?.current?B?.current?.getBoundingClientRect():null),p(v?.current?v?.current?.getBoundingClientRect():null),c(e))},[o,b,y,i,B,v]),T=core.getBgVideoByDevice(s,r),h=React.useMemo(()=>!!(T?.videoHtml5&&"html5"===T.videoType),[T]);return React.useEffect(()=>(animationManager.default.register(H),()=>{animationManager.default.unregister(H)}),[H]),React.useEffect(()=>(animationManager.default.register(H),()=>{animationManager.default.unregister(H)}),[H]),{onMouseEnterParallax:S,onMouseLeaveParallax:V,bgRef:v,transform:R,elementRef:B,dataVideo:T,isShowVideoHtml5:h,openLinkBanner:j,layoutResponsive:M}};exports.default=useHeroBanner,exports.useHeroBanner=useHeroBanner;
