import{makeStyleResponsive as e,cls as a,template as i}from"@gem-sdk/core";import{getAspectRatio as t,getPaddingBottomByShapeSetting as r,getSrcImage as s}from"../../common/common.js";import{checkRenderFeaturedCarousel as d,getZoomImageClass as o,getZoomLenClass as u,getVideoHeight as m}from"../../common/productFeaturedImage.js";import l from"../../../../../video/components/HTML5Embed.liquid.js";import p from"../../../../../image/components/Modal3d.liquid.js";import g from"../../../../../image/components/NextImage.liquid.js";import n from"../../../../../image/components/Video.liquid.js";import{getStyleOfObject as c}from"../../../../helpers/function.js";import{getProductImagesStyles as f}from"../../composables/getProductImagesStyles.js";import{getProductImagesClassName as h}from"../../composables/getProductImagesClassName.js";import{getProductImagesAttr as y}from"../../composables/getProductImagesAttr.js";import{If as M,LiquidIf as _,LiquidFor as w,Liquid as v,createStyle as b}from"@gem-sdk/system";import $ from"../../../../../carousel-v3/components/root/Carousel.liquid.js";import I from"../../../../../carousel-v3/components/item/CarouselItem.liquid.js";let x=({builderPropUID:x,children:q,enableLazyLoadImage:S,...z})=>{let{featuredImageCarouselClasses:j,galleryItemClasses:L,featuredCarouselItemClasses:P}=h({...z,builderProps:{uid:x}}),{featuredImageCarouselStyle:R,featureImageStyle:T,featureImageCarouselOnlyOneImageStyle:W,featureImageOnlyOneImageStyle:C,featureImageCarouselItemStyle:N}=f(z),{featuredImageCarouselSettingAttrs:k}=y(z),E=t(z.ftShape),O=M("other"==z.hoverEffect,_("product.media.size > 1","group-hover:gp-opacity-0")),A=()=>`
    {% case featureMedia.media_type %}
      {% when 'image' %}
        ${F()}
      {% when 'external_video' %}
        {% assign mediaSourceVideo = featureMedia | external_video_url %}
        ${V()}
      {% when 'video' %}
        {% assign mediaSourceVideo = featureMedia.sources.last.url %}
        ${H()}
      {% when 'model' %}
        ${D()}
      {% else %}
        ${G()}
    {% endcase %}
    `,D=()=>p({src:_("featureMedia.sources.first.url contains '.glb'","{{ featureMedia.sources.first.url }}","{{featureMedia.sources.last.url}}"),alt:"{{featureMedia.preview_image.alt}}",poster:"{{featureMedia.preview_image.src | product_img_url: '1024x1024'}}",cameraControls:!0,arStatus:"not-presenting",style:{width:"100%"},aspectRatio:E}),V=()=>n({src:"{{mediaSourceVideo}}",alt:"{{featureMedia.alt | escape}}",autoplay:!1,allowfullscreen:!0,controls:!0,style:{width:"100%",height:"100%"},aspectRatio:E}),H=()=>{let a=b({...m({ftLayout:z?.ftLayout,ftShape:z?.ftShape}),...e("objf",z?.ftLayout)}),i=b({...m({ftLayout:z?.ftLayout,ftShape:z?.ftShape})});return l({src:"{{mediaSourceVideo}}",title:"{{featureMedia.alt | escape}}",autoplay:!1,controls:!0,thumbnail:"{{featureMedia.preview_image.src | product_img_url: '1024x1024'}}",isCheckLoaded:!0,wrapperStyles:i,poster:{altText:"{{featureMedia.alt | escape}}"},style:{width:"100%","max-height":"100%",...a},className:"gp-invisible"})},F=()=>i`
      ${B(a("gp-w-full gp-transition-opacity",O,"{{shouldHidden}}"))}
      ${M(z?.hoverEffect!=="none",`<div class="${a("zoom-element !gp-max-w-none",o())}">
            ${B("image-zoom",!0)}
          </div>`," ")}
      ${M(z?.hoverEffect=="zoom"&&z?.zoomType=="glasses",`<div class="${a("zoom-lens-element",u())}" style="opacity: 0; background-image: url('{{ featureMedia.src | img_url: "1024x1024"}}')"></div>`," ")}
    `,B=(e,a)=>i`
    {% assign src = featureMedia.src %}
    ${M(a&&"other"==z.hoverEffect,`{% assign media_length = product.media | size %}
      {% assign other_image_index = ${z.otherImage} | plus: 0 %}
      {% if other_image_index >= media_length %}
        {% assign other_image_index = media_length | minus: 1 %}
      {% endif %}
      {% assign otherImage = product.media[other_image_index] %}
      ${_("otherImage.media_type != 'image'","{% assign src = otherImage.preview_image.src %}","{% assign src = otherImage.src %}")}
    `)}
    ${g({srcIsLiquidCode:!0,src:_("src != null",s("src"),"https://cdn.shopify.com/s/assets/no-image-2048-5e88c1b20e087fb7bbe9a3771824e743c244f437e4f8ba93bbf7b11b53f7824c_large.gif"),id:_("featureMedia != null","{{featureMedia.id}}"),width:"{{featureMedia.width}}",height:"{{featureMedia.height}}",alt:"{{featureMedia.alt | escape}}",srcset:`${s("src")}`,baseSrc:"{{src | image_url}}",sizes:"(max-width: 768px) 50vw, 100vw",setting:{layout:z?.ftLayout,aspectRatio:E,qualityType:z?.qualityType,qualityPercent:z?.qualityPercent},priority:z?.preload,className:`gp-w-full gp-h-full gp-absolute gp-top-0 gp-left-0 featured-image-only gp-cursor-pointer !gp-rounded-none ${e??""}`,enableLazyLoadImage:S})}`,G=()=>i`
    ${g({srcIsLiquidCode:!0,src:"https://cdn.shopify.com/s/assets/no-image-2048-5e88c1b20e087fb7bbe9a3771824e743c244f437e4f8ba93bbf7b11b53f7824c_large.gif",alt:"No Image",sizes:"(max-width: 768px) 50vw, 100vw",setting:{layout:z?.ftLayout,aspectRatio:E,qualityType:z?.qualityType,qualityPercent:z?.qualityPercent},priority:z?.preload,className:"gp-w-full gp-h-full gp-absolute gp-top-0 gp-left-0 featured-image-only gp-cursor-pointer !gp-rounded-none",enableLazyLoadImage:S})}`,J=r(z.ftShape),K=d(z),Q="gp-featured-image-wrapper",U=_("product.media.size > 0",`{% assign largestRatio = 0 %}
      ${w("featureMedia in product.media",`
          ${_("featureMedia.media_type == 'video' and featureMedia.preview_image",`{% assign height = featureMedia.preview_image.height | times: 1.0 %}
            {% assign width = featureMedia.preview_image.width | times: 1.0 %}`,`{% assign height = featureMedia.height | times: 1.0 %}
            {% assign width = featureMedia.width | times: 1.0 %}`)}
          {% assign ratio = height | divided_by: width %}
          ${_("ratio > largestRatio","{% assign largestRatio = ratio %}")}
        `)}
      ${w("featureMedia in product.media",`${_("featureMedia.media_type == 'image'",`${w("image in product.images",_("image.src == featureMedia.src","{% assign imageID = image.id %}{% break %}"))}`,"{% assign imageID = '' %}")}
        
    ${v(`{% assign productImageWidth = 0 %}
    {% case featureMedia.media_type %}
      {% when 'image' %}
        {% assign productImageWidth = featureMedia.width %}
      {% else %}
        {% assign productImageWidth = featureMedia.preview_image.width %}
    {% endcase %}`)}
    ${I({id:"{{section.id}}-{{imageID}}",contentType:"productImage",className:`${L("gp-ft-image-item !gp-min-w-full !gp-max-w-full ")}`,parentId:`ft-${x}-{{section.id}}-{{product.id}}`,style:N,customStyle:{width:"{{productImageWidth}}px"},children:`
      <div
        class="gp-w-full gp-relative ${_("featureMedia == null or featureMedia.media_type == 'image'","{{ 'gp-h-0' }}","{{ 'gp-h-full !gp-pb-0' }}")}"
        style="${c(e("pb",J))} ${_("featureMedia.media_type == 'video' or featureMedia.media_type == 'external_video'","{{ 'display: flex; align-items: center; justify-content: center' }}")}"
      >
        ${A()}
      </div>
      `})}`)}
    `,g({src:"https://cdn.shopify.com/s/assets/no-image-2048-5e88c1b20e087fb7bbe9a3771824e743c244f437e4f8ba93bbf7b11b53f7824c_large.gif",id:"noImageError",width:"480",height:"480",alt:"no image",priority:z?.preload,setting:{layout:z?.ftLayout,aspectRatio:E,qualityType:z?.qualityType,qualityPercent:z?.qualityPercent},style:{height:"100%"},className:"gp-w-full featured-image-only !gp-rounded-none",customLazyload:!0,enableLazyLoadImage:S}));return v(`
    {% capture featureImageOnlyOne %}
      ${v(`
        {% assign featureMedia = variant.featured_media %}
        {% unless featureMedia %}
        {% assign featureMedia = product.featured_media %}
        {% endunless %}
        ${_("product.media.size > 1",(()=>{switch(z?.preDisplay){case"1st-images":return`
          {% assign featureMedia = product.media.first %}
        `;case"1st-3d-mode":return w("media in product.media",_("media.media_type == 'model'","{% assign featureMedia = media %}{% break %}"));case"1st-video":return w("media in product.media",_("media.media_type == 'video' or media.media_type == 'external_video'","{% assign featureMedia = media %}{% break %}"));default:return`
          {% assign featureMedia = variant.featured_media %}
          {% unless featureMedia %}
          {% assign featureMedia = product.featured_media %}
          {% endunless %}
        `}})())}
        {% assign largestRatio = 0 %}
        {% assign height = featureMedia.height | times: 1.0 %}
        {% assign width = featureMedia.width | times: 1.0 %}
        {% assign ratio = height | divided_by: width %}
        ${_("ratio > largestRatio","{% assign largestRatio = ratio %}")}
        {% assign productImageWidth = 0 %}
        {% case featureMedia.media_type %}
          {% when 'image' %}
            {% assign productImageWidth = featureMedia.width %}
          {% else %}
            {% assign productImageWidth = featureMedia.preview_image.width %}
        {% endcase %}
        ${_("featureMedia == null","{% assign productImageWidth = 1600 %}")}
        <div
          class='gp-feature-image-carousel gp-feature-image-only'
          style="${c(T)}"
        >
          <div
            class="gp-relative"
            style="${c(C)}"
          >
            ${q}
            <div
              type="gp-feature-image-only"
              product-id="{{product.id}}"
              product-media="{{product.media.size}}"
              class="${P(Q)}"
              style="${c(W)}"
            >
              <div
                class="gp-w-full gp-relative ${_("featureMedia == null or featureMedia.media_type == 'image'","{{ 'gp-h-0' }}","{{ 'gp-h-full !gp-pb-0' }}")}"
                style="${c(e("pb",J))} ${_("featureMedia.media_type == 'video' or featureMedia.media_type == 'external_video'","{{ 'display: flex; align-items: center; justify-content: center' }}")}"
              >
                ${A()}
              </div>
            </div>
          </div>
        </div>
      `)}
    {% endcapture %}
    ${_("product.media.size > 1",`
        ${M(K,`
      ${$({builderProps:{uid:x},rootId:`ft-${x}-{{section.id}}-{{product.id}}`,conditionAppendJs:"product.media.size > 1",wrapperClass:Q,rootClass:`${j}`,rootAttrs:{type:"gp-feature-image-carousel","product-id":"{{product.id}}","product-media":"{{product.media.size}}"},isHiddenArrowWhenDisabled:!0,setting:k,rootStyles:T,styles:R,style:{playSpeed:600},disableMarginAuto:!0,children:U,productBadgeLiquid:q||""})}
    `," ")}
        ${M(!K,"{{ featureImageOnlyOne }}"," ")}
      `,"{{ featureImageOnlyOne }}")}
  `)};export{x as default};
