import{useRef as e,useMemo as t}from"react";import{useCurrentDevice as i,useEditorMode as r,usePageType as n,getBgVideoByDevice as o,isEmptyChildren as l,getResponsiveValue as s}from"@gem-sdk/core";import{createClass as u}from"@gem-sdk/system";import{useInView as c}from"../../common/hooks/useInView.js";let m=m=>{let{setting:d,styles:g,children:h,maxWidthWithEmptyChildren:p,builderAttrs:a}=m,{isSection:f,lazy:y,layout:P,blockAlignment:w}=d??{},{background:T}=g??{},k=i(),S=r(),C=n(),R=o(T,k),b=e(null),v=t(()=>l(h),[h]),x=e=>{b.current&&(clearTimeout(b.current),b.current=null);let t=e?.getBoundingClientRect().height;e.style.height=`${t||500}px`,e.style.overflow="hidden"},A=e=>{b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{e.style.height="",e.style.overflow="",b.current=null},1500)},[E,H]=c({initialInView:!y,triggerOnce:!0,skip:!f,onChange:(e,t)=>{t&&t instanceof HTMLElement&&"edit"===S&&(e?A(t):x(t))}}),O=t(()=>!H&&"edit"==S&&"POST_PURCHASE"!==C,[H,S,C]),V=t(()=>"edit"!==S&&y&&!H,[H,y,S]),I=u({...()=>{let e=p&&v&&"edit"===S;if(!e)return{};let t=s(P,"display"),i=t[k];return{width:"fit"===i?"fit-content":"400px"}},"gp-content-visibility-hidden":V});return{ref:E,isRowEmpty:v,bgVideo:R,rowClassEditorOnly:I,isRenderPlaceholderViewBox:O,builderAttrs:a,children:h,isPostPurchase:"POST_PURCHASE"===C,postPurchaseVerticalAlign:()=>({desktop:w,tablet:w,mobile:w})}};export{m as useRowSettings};
