import{template as t,hasTranslatedLiquid as e}from"@gem-sdk/core";import{getSettingTranslatedVideoAndThumbnail as o,getAspectRatioSettings as i,getVimeoVideoId as s,vimeoVideoRegex as l,getYoutubeVideoId as m,youtubeVideoRegex as a,parseTimeVideo as r,fallbackImageVideoUrl as d}from"../common/helpers.js";import{createAttr as u,createStyle as n,createClass as c}from"@gem-sdk/system";import{getAttr as p}from"../common/attrs.js";import{getStyle as f,getYoutubeStyle as y,getVimeoStyle as b,getHtml5Style as j,getFallBackImageStyle as h}from"../common/styles.js";import{getFallbackImageClasses as k,getClasses as V}from"../common/classes.js";import $ from"./HTML5Embed.liquid.js";import v from"./LiteVimeoEmbed.liquid.js";import g from"./LiteYouTubeEmbed.liquid.js";import L from"../../image/components/NextImage.liquid.js";import{getImageSrc as N}from"../../image/common/helpers.js";let q=({className:q,setting:C,style:x,builderAttrs:z,builderProps:E,advanced:F,pageContext:I})=>{let R=o({setting:C,uid:E?.uid,pageContext:I??{}}),{youtubeUrl:w="",vimeoUrl:T="",html5Url:U,autoplay:H=!1,loopVideo:M=!1,controls:O=!1,mute:P,poster:S,startTime:Y,endTime:A,lazy:B,type:D}=R??{},{youtubeUrlTranslated:G,vimeoUrlTranslated:J}=R,K=N(S),{cssClass:Q}=F??{},W=i(R?.ratioOptions,R?.aspectRatio),X=u({...p({uid:E?.uid||""})}),Z=n({...f(R,x)}),_=n({...y(W)}),tt=n({...b(W)}),te=n({...j(W)}),to=n({...h(C?.aspectRatio)}),ti=c({...k()}),ts=c({...V({className:q,builderProps:E,isInstantLP:!1,advancedCssClass:Q})});return t`
    <div
      ${{...z}} ${{...X}} class="${ts}" style="${Z}">
      ${(()=>{switch(D){case"youtube":{let t=m(w),o=e(G);if((!a.test(w)||!t)&&!o)return L({src:d,alt:"Fallback video",className:ti,style:to});let i="";return M&&(i+=`&loop=1&playlist=${t}`),Y&&(i+=`&start=${r(Y)}`),A&&(i+=`&end=${r(A)}`),g({uid:E?.uid,id:t??"",translatedVideoUrl:o?G:"",autoplay:H,title:"Video",controls:O,params:i,adNetwork:!1,noCookie:!0,muted:!P,thumbnail:K,lazy:B??!0,poster:S,style:_})}case"vimeo":{let t=s(T),o=e(J);if((!l.test(T)||!t)&&!o)return L({src:d,alt:"Fallback video",className:ti,style:to});return v({muted:!P,loop:M,controls:O,thumbnail:K,thumbnailLink:S?.src,autoplay:H,lazy:B??!0,id:t??"",translatedVideoUrl:o?J:"",title:"Video",aspectRatio:W,poster:S,vimeoStyleIframe:tt})}case"html5":if(!U)return L({src:d,alt:"Fallback video",className:ti,style:to});return $({uid:E?.uid,muted:!P,loop:M,controls:O,autoplay:H,src:U,thumbnail:K,title:"Video",poster:S,lazy:B??!0,isVideoComponent:!0,style:te})}})()}
    </div>
  `};export{q as default};
