"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}=t||{},l=Number(t?.speedParallax)||0,[i,o]=React.useState(0),[c,g]=React.useState(null),[d,m]=React.useState(null),[p,R]=React.useState(""),f=React.useRef(null),[v,B]=useIntersectionObserver.default(),{translateValue:b}=useTranslateValue.useTranslateValue({containerBoundingClientRect:c,backgroundBoundingClientRect:d,speed:l}),x=core.getResponsiveValueByScreen(t?.layout,r),M=helpers.getResponsiveSetting(s||{}),q=Number(t?.speedParallax||0)>0&&M[r]?.type==="image",y=()=>{a&&q&&R(`${p} scale(${n||"100%"})`)},S=()=>{a&&q&&R(`translateY(${b}px)`)},V=e=>{u?.link&&!e?.srcElement?.closest("a")&&window.open(u?.link,u.target)};React.useEffect(()=>{q?R(`translateY(${b}px)`):R("")},[b,q]);let j=React.useCallback(()=>{if(!q||0===l||!B)return;let e=Number(window.scrollY.toFixed(0));i!==e&&(g(v?.current?v?.current?.getBoundingClientRect():null),m(f?.current?f?.current?.getBoundingClientRect():null),o(e))},[i,B,q,l,v,f]),H=core.getBgVideoByDevice(s,r),T=React.useMemo(()=>!!(H?.videoHtml5&&"html5"===H.videoType),[H]);return React.useEffect(()=>(animationManager.default.register(j),()=>{animationManager.default.unregister(j)}),[j]),React.useEffect(()=>(animationManager.default.register(j),()=>{animationManager.default.unregister(j)}),[j]),{onMouseEnterParallax:y,onMouseLeaveParallax:S,bgRef:f,transform:p,elementRef:v,dataVideo:H,isShowVideoHtml5:T,openLinkBanner:V,layoutResponsive:x}};exports.default=useHeroBanner,exports.useHeroBanner=useHeroBanner;
