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