import{template as e,WrapRenderChildren as o,RenderChildren as s,RenderIf as r,isLocalEnv as i,baseAssetURL as t}from"@gem-sdk/core";import{getSettingPreloadData as l}from"../../../helpers.js";import a from"../../../video/components/HTML5Embed.liquid.js";import{createClass as m,If as p}from"@gem-sdk/system";import{getYoutubeVideoId as d}from"../../../video/common/helpers.js";import n from"../../../video/components/LiteYouTubeEmbed.liquid.js";import{getAttr as c}from"./common/attrs.js";import{getClass as $}from"./common/classes.js";import{getRowStyle as f}from"./common/styles.js";import{getData as u,checkHasBackgroundVideo as g,isRenderHtmlVideo as y,isRenderYoutubeVideo as v}from"./common/helpers.js";import{getResponsiveSetting as j}from"../../../hero-banner/common/helpers.js";let Row=k=>{let{styles:h,setting:b,rawChildren:w,builderProps:E}=k,{isSection:S}=b??{},{background:C}=h??{},q=S?"section":"div",{stateData:z}=u(k),{rowStyle:A,backgroundBoxStyle:L,embedVideoStyle:N,sectionStyle:P}=f(k),{rowAttr:R}=c(k),{rowClass:T,backgroundBoxClass:V,backgroundBoxInnerClass:_,sectionClass:G,wrapperYoutubeClasses:I,iframeYoutubeClasses:M}=$(k),O=m({[T]:!0}),x=()=>{if(!g(C))return;let e=j(C||{});if(y(C))return a({uid:E?.uid,muted:!0,loop:e.desktop?.loop,controls:!1,autoplay:!0,src:"",title:"Video",className:"gp-relative",style:N});if(v(C)){let o=e?.desktop?.video??"",s=d(o)||"",r=`&loop=false&playlist=${s}&showinfo=0&rel=0&fs=0&enablejsapi=1`;return n({uid:E?.uid,id:s,autoplay:!0,title:"Video",controls:!1,params:r,adNetwork:!1,noCookie:!0,muted:!0,lazy:e?.desktop?.lazyLoad??!0,preload:!0,style:N,wrapperClass:I,iframeClass:M})}},B=()=>{if(g(C))return e`
      ${r(i,`<script ${l('class="gps-link" delay',"src")}="{{ 'gp-row-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${l('class="gps-link" delay',"src")}="${t}/assets-v2/gp-row-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
    `},H=e`
    <gp-row gp-data='${z}' ${{...R}} class="${O}" style="${A()}">
      ${p(!!x(),e`
          <div class="${V}" style="${L}">
            <div class="${_}">${x()}</div>
          </div>
        `)}

      ${o({uid:E?.uid||"",customProps:w?.[0].customProps},w?.map(e=>{if(e)return s({...e,order:b?.order,layout:b?.layout,justifyContent:b?.verticalAlign})}))}

      ${B()}
    </gp-row>
  `;return e`
    ${r(!!h?.preloadBgImage,`${r(!!C?.desktop?.image?.src,`<link rel="preload" href="${C?.desktop?.image?.src}" as="image" />`)}${r(!!C?.tablet?.image?.src,`<link rel="preload" href="${C?.tablet?.image?.src}" as="image" />`)}${r(!!C?.mobile?.image?.src,`<link rel="preload" href="${C?.mobile?.image?.src}" as="image" />`)}`)}

    ${r(!!S,"{% assign locationOrigin = request.origin | append: routes.root_url | split: '/' | join: '/' %}")}

    ${p(S,e`
        <${q}
          class="${G} ${S?l("gps-lazy"):""}"
          style="${P}"
        >
          ${H}
        </${q}>
      `,e`${H}`)}
  `};export{Row as default};
