"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),React=require("react"),Head=require("next/head"),ChildrenDroppable=require("../ChildrenDroppable.js"),HTML5Embed=require("../../../video/components/HTML5Embed.js"),helpers$1=require("../../../video/common/helpers.js"),LiteYouTubeEmbed=require("../../../video/components/LiteYouTubeEmbed.js"),system=require("@gem-sdk/system"),useRowSetting=require("../../hooks/useRowSetting.js"),attrs=require("./common/attrs.js"),classes=require("./common/classes.js"),styles=require("./common/styles.js"),helpers=require("./common/helpers.js"),core=require("@gem-sdk/core");const Row=e=>{let{styles:s,setting:t,children:r}=e,{isSection:i,as:l="div"}=t??{},{background:o}=s??{},{builderAttrs:a,bgVideo:m,isRowEmpty:n,rowClassEditorOnly:u,isRenderPlaceholderViewBox:d,isPostPurchase:c,ref:p,postPurchaseVerticalAlign:j}=useRowSetting.useRowSettings(e),{rowStyle:x,backgroundBoxStyle:y,embedVideoStyle:h,sectionStyle:R}=styles.getRowStyle({rowProps:e,isPostPurchase:c,type:"React"}),{rowAttr:g}=attrs.getAttr(e),{rowClass:b,backgroundBoxClass:v,backgroundBoxInnerClass:f,sectionClass:C,wrapperYoutubeClasses:k,iframeYoutubeClasses:q}=classes.getClass(e),E=system.createClass({[b]:!0,[u]:!0}),w=React.useMemo(()=>{if(!helpers.checkHasBackgroundVideo(o))return;if(m?.videoType==="html5"&&!m.videoHtml5||m?.videoType==="youtube"&&!m.video)return null;if(m?.videoType==="html5"&&m.videoHtml5)return jsxRuntime.jsx(HTML5Embed.default,{muted:!0,loop:m.loop,controls:!1,autoplay:!0,src:m.videoHtml5,title:"Video",className:"gp-relative",style:h});let e=m?.video??"",s=helpers$1.getYoutubeVideoId(e);if(!helpers$1.youtubeVideoRegex.test(e)||!s)return;let t=`&loop=${m?.loop?1:0}&playlist=${s}&showinfo=0&rel=0&fs=0&enablejsapi=1`;return jsxRuntime.jsx(LiteYouTubeEmbed.default,{id:s,autoplay:!0,title:"",controls:!1,params:t,adNetwork:!1,noCookie:!0,muted:!0,lazy:!1,style:h,wrapperClass:k,iframeClass:q})},[o,m,h,q,k]),H=React.Children.map(r,e=>!!core.isEmptyChildren(e)),T=jsxRuntime.jsxs("div",{ref:p,...a,...g,style:x(c),className:E,children:[!!w&&jsxRuntime.jsx("div",{className:v,style:y,children:jsxRuntime.jsx("div",{className:f,children:w})}),d?jsxRuntime.jsx(jsxRuntime.Fragment,{}):n?jsxRuntime.jsx(ChildrenDroppable.default,{}):React.Children.map(r,s=>React.isValidElement(s)?React.createElement(s.type,{hiddenEmptyCol:e.hiddenEmptyCol&&!core.isEmptyChildren(s)&&!H,...s.props,key:s.key,order:t?.order,layout:t?.layout,justifyContent:c?j():t?.verticalAlign}):null)]});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[!!s?.preloadBgImage&&jsxRuntime.jsxs(Head,{children:[!!o?.desktop?.image?.src&&jsxRuntime.jsx("link",{rel:"preload",href:o.desktop.image.src,as:"image"}),!!o?.tablet?.image?.src&&jsxRuntime.jsx("link",{rel:"preload",href:o.tablet.image.src,as:"image"}),!!o?.mobile?.image?.src&&jsxRuntime.jsx("link",{rel:"preload",href:o.mobile.image.src,as:"image"})]}),i?jsxRuntime.jsx(l,{className:C,style:R,children:T}):T]})};exports.default=Row;
