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