'use client';
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useEditorMode as r}from"@gem-sdk/core";import o from"react-youtube";import{getYoutubeParams as a,isSettingLoop as i,covertStrParamsToObj as l}from"../common/helpers.js";import s from"../../image/components/NextImage.js";import{createClass as m,createStyle as c}from"@gem-sdk/system";import{getButtonYoutubeClasses as n,getImageYoutubeClasses as p,getArticleYoutubeClasses as u,getIframeYoutubeClasses as d,getYoutubeContentClasses as y}from"../common/classes.js";import{getIframeYoutubeStyle as f,getArticleYoutubeStyle as g}from"../common/styles.js";import{useLiteYoutubeEmbed as h}from"../hooks/useLiteYoutubeEmbed.js";let LiteYouTubeEmbed=b=>{let C=r(),w="edit"!==C,{style:N,poster:j,iframeClass:k,wrapperClass:v,title:x}=b,{preload:L}=j||{},{videoId:S,paramsImp:T,posterUrl:V,iframeSrc:B}=a(b),{iframe:E,intervalPlay:I,warmConnections:M,isVideoStarted:Y,videoDuration:z,addIframe:D}=h(b,T,S),P=L&&w,A=m({...n(E)}),F=m({...p()}),H=m({...u(P||!1,v)}),O=m({...d(k)}),R=c({...f(N)}),q=c({...g(N,V)}),G=m({...y()}),J=()=>b.isHeroBanner&&i(T)?t(o,{videoId:S,title:x,iframeClassName:O,style:R,className:G,opts:{host:"https://www.youtube-nocookie.com",playerVars:{autoplay:1,state:1,controls:0,mute:1,...l(T)}},onReady:e=>{e.target.playVideo(),z.current=Math.floor(e.target.getDuration())},onStateChange:e=>{let t=e.target;Y.current||(t.playVideo(),Y.current=!0,I(e)),0===e.data&&(z.current=t.getCurrentTime(),t.playVideo(),I(e))}}):t("iframe",{className:O,style:R,title:x,frameBorder:"0",allow:"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,src:B});return e("article",{"aria-hidden":!0,className:H,"data-title":x,style:q,onPointerOver:M,onClick:D,children:[t(s,{src:V,alt:j?.altText,title:j?.imageTitle,priority:w&&L,enableLazyLoadImage:!0,className:F,isDisableAspectStyle:!0}),t("button",{type:"button","aria-label":"Play",className:A,children:e("svg",{height:"100%",version:"1.1",viewBox:"0 0 68 48",width:"100%",children:[t("path",{d:"M66.52,7.74c-0.78-2.93-2.49-5.41-5.42-6.19C55.79,.13,34,0,34,0S12.21,.13,6.9,1.55 C3.97,2.33,2.27,4.81,1.48,7.74C0.06,13.05,0,24,0,24s0.06,10.95,1.48,16.26c0.78,2.93,2.49,5.41,5.42,6.19 C12.21,47.87,34,48,34,48s21.79-0.13,27.1-1.55c2.93-0.78,4.64-3.26,5.42-6.19C67.94,34.95,68,24,68,24S67.94,13.05,66.52,7.74z",fill:"#f00"}),t("path",{d:"M 45,24 27,14 27,34",fill:"#fff"})]})}),E&&J()]})};export{LiteYouTubeEmbed as default};
