'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("@gem-sdk/core"),s=require("next/dynamic"),r=require("react"),a=require("../common/helpers.js"),l=require("@gem-sdk/system"),o=require("../common/attrs.js"),i=require("../common/styles.js"),u=require("../common/classes.js"),c=require("../../image/components/NextImage.js");const m=s(()=>Promise.resolve().then(function(){return require("./HTML5Embed.js")})),d=s(()=>Promise.resolve().then(function(){return require("./LiteVimeoEmbed.js")})),n=s(()=>Promise.resolve().then(function(){return require("./LiteYouTubeEmbed.js")}));exports.default=({className:s,setting:y,style:p,builderAttrs:g,builderProps:b,advanced:j,children:f})=>{let V=t.useEditorMode(),{youtubeUrl:q="",vimeoUrl:x="",html5Url:k,autoplay:S=!1,loopVideo:v=!1,controls:h=!1,mute:I,poster:z,startTime:C,endTime:N}=y??{},{cssClass:F}=j??{},P=z?.src,R=a.getAspectRatioSettings(y?.ratioOptions,y?.aspectRatio),E=l.createAttr({...o.getAttr({uid:b?.uid||""})}),L=l.createStyle({...i.getStyle(y,p)}),M=l.createStyle({...i.getYoutubeStyle(R)}),T=l.createStyle({...i.getVimeoStyle(R)}),A=l.createStyle({...i.getHtml5Style(R)}),U=l.createStyle({...i.getFallBackImageStyle(y?.aspectRatio)}),Y=l.createClass({...u.getFallbackImageClasses()}),$=l.createClass({...u.getClasses({className:s,builderProps:b,isInstantLP:"edit"!==V,advancedCssClass:F})}),w=r.useMemo(()=>{switch(y?.type){case"youtube":{let t=a.getYoutubeVideoId(q);if(!a.youtubeVideoRegex.test(q)||!t)return e.jsx(c.default,{src:a.fallbackImageVideoUrl,alt:"Fallback video",className:Y,style:U});let s="";return v&&(s+=`&loop=1&playlist=${t}`),C&&(s+=`&start=${a.parseTimeVideo(C)}`),N&&(s+=`&end=${a.parseTimeVideo(N)}`),e.jsx(n,{id:t,autoplay:S,title:"Video",controls:h,params:s,adNetwork:!1,noCookie:!0,muted:!I,thumbnail:P,lazy:y.lazy??!0,poster:z,preload:z?.preload,style:M})}case"vimeo":{let t=a.getVimeoVideoId(x);if(!t)return e.jsx(c.default,{src:a.fallbackImageVideoUrl,alt:"Fallback video",className:Y,style:U});return e.jsx(d,{muted:!I,loop:v,controls:h,thumbnail:P,autoplay:S,lazy:y.lazy??!0,id:t,title:"Video",aspectRatio:R,poster:z,vimeoStyleIframe:T})}case"html5":if(!k)return e.jsx(c.default,{src:a.fallbackImageVideoUrl,alt:"Fallback video",className:Y,style:U});return e.jsx(m,{muted:!I,loop:v,controls:h,autoplay:S,src:k,thumbnail:P,title:"Video",lazy:y.lazy??!0,isVideoComponent:!0,style:A,poster:z})}},[R,S,v,I,h,x,q,k,N,C,y?.type,y?.lazy,P,T,M,A,U,Y,z]);return e.jsxs("div",{...g,...E,className:$,style:L,children:[w,f]})};
