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