'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:g,iframeClass:y,wrapperClass:p,title:b,pageContext:f}=c,{preload:C}=g||{},{videoId:h,paramsImp:j,posterUrl:x,iframeSrc:v}=a.getYoutubeParams(c),{iframe:S,intervalPlay:q,warmConnections:Y,isVideoStarted:w,videoDuration:N,addIframe:B}=u.default(c,j,h),I=l.createClass({...o.getButtonYoutubeClasses(S)}),k=l.createClass({...o.getImageYoutubeClasses()}),M=l.createClass({...o.getArticleYoutubeClasses(C&&m||!1,p)}),P=l.createClass({...o.getIframeYoutubeClasses(y)}),E=l.createStyle({...i.getIframeYoutubeStyle(d)}),T=l.createStyle({...i.getArticleYoutubeStyle(d,x)}),V=l.createClass({...o.getYoutubeContentClasses()});return e.jsxs("article",{"aria-hidden":!0,className:M,"data-title":b,style:T,onPointerOver:Y,onClick:B,children:[e.jsx(s.default,{src:x,alt:g?.altText,title:g?.imageTitle,priority:m&&C,pageContext:f,className:k,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"})]})}),S&&(()=>{if(c.isHeroBanner&&a.isSettingLoop(j))return e.jsx(r,{videoId:h,title:b,iframeClassName:P,style:E,className:V,opts:{host:"https://www.youtube-nocookie.com",playerVars:{autoplay:1,state:1,controls:0,mute:1,...a.covertStrParamsToObj(j)}},onReady:e=>{if(e.target.playVideo(),N.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;w.current||(t.playVideo(),w.current=!0,q(e)),0===e.data&&(N.current=t.getCurrentTime(),t.playVideo(),q(e))}});let t=e.jsx("iframe",{className:P,style:E,title:b,frameBorder:"0",allow:"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,src:v});return c.isHeroBanner?e.jsx("div",{className:V,children:t}):t})()]})};
