import{useState as e,useRef as t,useEffect as r}from"react";import{isSettingLoop as a}from"../common/helpers.js";let o=(o,l,n)=>{let{lazy:u,autoplay:c,isHeroBanner:i,thumbnail:s}=o,[m,d]=e(!1),[p,F]=e(!u&&(!s||!!c)),f=t(!1),x=t(0),b=t();return r(()=>()=>{b.current&&(clearInterval(b.current),f.current=!1)},[n,l]),{iframe:p,addIframe:()=>{p||F(!0)},intervalPlay:e=>{let t=e.target;if(t&&i&&a(l)&&x.current>0){let e=parseFloat((x.current/100*5).toFixed(2));clearInterval(b.current),b.current=setInterval(()=>{let r=parseFloat(t.getCurrentTime().toFixed(2)),a=parseFloat((x.current-r).toFixed(2));a<=parseFloat((1.5*e).toFixed(2))&&t.seekTo(0)},1e3*e)}},warmConnections:()=>{m||d(!0)},isVideoStarted:f,videoDuration:x}};export{o as default,o as useLiteYoutubeEmbed};
