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