'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),YouTube=require("react-youtube"),helpers=require("../common/helpers.js"),NextImage=require("../../image/components/NextImage.js"),system=require("@gem-sdk/system"),classes=require("../common/classes.js"),styles=require("../common/styles.js"),useLiteYoutubeEmbed=require("../hooks/useLiteYoutubeEmbed.js");const LiteYouTubeEmbed=e=>{let t=core.useEditorMode(),s="edit"!==t,{style:a,poster:r,iframeClass:l,wrapperClass:u,title:o}=e,{preload:i}=r||{},{videoId:c,paramsImp:m,posterUrl:n,iframeSrc:y}=helpers.getYoutubeParams(e),{iframe:d,intervalPlay:b,warmConnections:g,isVideoStarted:p,videoDuration:j,addIframe:x}=useLiteYoutubeEmbed.useLiteYoutubeEmbed(e,m,c),C=i&&s,h=system.createClass({...classes.getButtonYoutubeClasses(d)}),Y=system.createClass({...classes.getImageYoutubeClasses()}),f=system.createClass({...classes.getArticleYoutubeClasses(C||!1,u)}),S=system.createClass({...classes.getIframeYoutubeClasses(l)}),R=system.createStyle({...styles.getIframeYoutubeStyle(a)}),q=system.createStyle({...styles.getArticleYoutubeStyle(a,n)}),L=system.createClass({...classes.getYoutubeContentClasses()}),N=()=>e.isHeroBanner&&helpers.isSettingLoop(m)?jsxRuntime.jsx(YouTube,{videoId:c,title:o,iframeClassName:S,style:R,className:L,opts:{host:"https://www.youtube-nocookie.com",playerVars:{autoplay:1,state:1,controls:0,mute:1,...helpers.covertStrParamsToObj(m)}},onReady:e=>{e.target.playVideo(),j.current=Math.floor(e.target.getDuration())},onStateChange:e=>{let t=e.target;p.current||(t.playVideo(),p.current=!0,b(e)),0===e.data&&(j.current=t.getCurrentTime(),t.playVideo(),b(e))}}):jsxRuntime.jsx("iframe",{className:S,style:R,title:o,frameBorder:"0",allow:"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,src:y});return jsxRuntime.jsxs("article",{"aria-hidden":!0,className:f,"data-title":o,style:q,onPointerOver:g,onClick:x,children:[jsxRuntime.jsx(NextImage.default,{src:n,alt:r?.altText,title:r?.imageTitle,priority:s&&i,enableLazyLoadImage:!0,className:Y,isDisableAspectStyle:!0}),jsxRuntime.jsx("button",{type:"button","aria-label":"Play",className:h,children:jsxRuntime.jsxs("svg",{height:"100%",version:"1.1",viewBox:"0 0 68 48",width:"100%",children:[jsxRuntime.jsx("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"}),jsxRuntime.jsx("path",{d:"M 45,24 27,14 27,34",fill:"#fff"})]})}),d&&N()]})};exports.default=LiteYouTubeEmbed;
