"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@gem-sdk/core"),t=require("./common/common.js"),r=require("./components/feature-gallery/FeatureImageWithGallery.liquid.js"),i=require("./components/gallery-carousel/GalleryCarousel.liquid.js"),s=require("./components/gallery-grid/GalleryGrid.liquid.js"),a=require("../../../helpers.js"),o=require("./common/productGallery.js"),l=require("./composables/getProductImagesClassName.js"),d=require("./composables/getProductImagesStyles.js"),u=require("@gem-sdk/system"),p=require("./common/getBorderActiveCss.js"),n=require("../../helpers/function.js");exports.default=c=>{let g=t.setDefaultWhenUndefineSetting(c),{setting:m,styles:f,builderProps:y,style:$}=g,{rawChildren:S,pageContext:I}=c,{enableLazyLoadImage:h}=I??{},q={...m,...f},j=`
    {
      "id":${JSON.stringify(y?.uid)},
      "pageContext": ${JSON.stringify(a.filterPageContext(I))},
      "setting":${JSON.stringify(m)},
      "styles":${JSON.stringify(f)},
      "productUrl":{{product.url | json | escape}},
      "product":{{product | json | escape}},
      "collectionUrl": {{ collection.url | json | escape }},
      "collection": {{ collection | json | escape}}
    }
  `,v=u.createAttr({"section-id":"{{section.id}}","data-id":`${y?.uid}`}),{isOnlyFeatureAllDevices:C,isRenderGalleryGrid:F}=t.getConditionRenderGalleryImages(q?.position,m?.type),L=F?{}:u.createAttr({"data-only-image":u.LiquidIf("product.media.size > 1","false","true")}),{wrapperClasses:P,productImagesGalleryClasses:O}=l.getProductImagesClassName(c),D=u.createClass({"gp-grid gp-w-full !gp-m-0 gp-relative":!0}),b=u.createClass({"gp-w-full !gp-m-0 gp-relative":!0}),{wrapContainerStyle:G,wrapContainerStyleOnlyOneImage:z,galleryImageStyle:A}=d.getProductImagesStyles(q),N=o.getShapeByLayout({shape:q.shape,shapeForBottom:q.shapeForBottom,shapeFor1Col:q.shapeFor1Col,shapeFor2Col:q.shapeFor2Col,shapeForFtOnly:q.shapeForFtOnly,shapeForInsideBottom:q.shapeForInsideBottom??o.sizeSettingDefaultForNewLayout,shapeForInside:q.shapeForInside??o.sizeSettingDefaultForNewLayout},q.position),_=t.getStyleInsideLayout(q.position,N,q?.spacing),B=()=>e.template`
      ${e.WrapRenderChildren({uid:y?.uid||"",customProps:S?.[0].customProps},S?.map(t=>{if(t)return e.template`${e.RenderChildren({...t,isInsideProductImage:!0,imageData:{imageShape:f?.ftShape,imageAlign:f?.align,imageLayout:f?.position},dotData:{dotSize:m?.ftDotSize,dotGapToCarousel:m?.ftDotGapToCarousel,dotStyle:m?.ftDotStyle}})}`}))}
    `;return e.template`
  ${u.If(m?.borderActive?.border!=="none",u.LiquidIf("product.media.size > 1",`<style>${p.getBorderActiveCss({settings:q,uid:y?.uid,type:"Liquid"})}</style>`),"")}
  ${u.Liquid(`
    {% assign featured_image = product.featured_image %}
    ${u.LiquidIf("variant != null and variant.featured_image != null","{% assign featured_image = variant.featured_image %}")}
  `)}
    <gp-product-images
      gp-data='${j}'
      ${{...v}}
      style="${{...$}}"
      class="${P}"
    >
      <div
        class="${u.LiquidIf("product.media.size > 1",`${D}`,`${b}`)}"
        style="${u.LiquidIf("product.media.size > 1",n.getStyleOfObject(G),n.getStyleOfObject(z))}"
      >
        ${r.default({builderPropUID:`gp-carousel-${y?.uid}`,...q,children:B(),enableLazyLoadImage:h})}
        ${u.If(!C,e.template`
      <div
        class="${O}"
        style="${n.getStyleOfObject(A)}"
        ${{...L}}
      >
        ${u.LiquidIf("product.media.size > 1",i.default({builderPropUID:`gp-gallery-${y?.uid}`,...q,enableLazyLoadImage:h}))}
        ${u.If(F,s.default({builderPropUID:y?.uid,wrapperStyle:{..._},children:B(),...q,enableLazyLoadImage:h}))}
      </div>
    `)}
      </div>
    </gp-product-images>
    ${u.If(e.isLocalEnv,`<script ${a.getSettingPreloadData('class="gps-link" delay',"src")}="{{ 'gp-product-images-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${a.getSettingPreloadData('class="gps-link" delay',"src")}="${e.baseAssetURL}/assets-v2/gp-product-images-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
  `};
