import{jsx as e,Fragment as r,jsxs as t}from"react/jsx-runtime";import{useRenderMode as i,useCurrentDevice as o,cls as a}from"@gem-sdk/core";import{useRef as l,useCallback as s}from"react";import d from"../gallery-carousel/GalleryCarousel.js";import m from"../child/ProductGalleryGrid.js";import u from"../child/ProductFeaturedImageCarousel.js";import{getProductImagesStyles as p}from"../../composables/getProductImagesStyles.js";import{getProductImagesClassName as n}from"../../composables/getProductImagesClassName.js";import{useFeatureImageWithGallery as c}from"../../hooks/useFeatureImageWithGallery.js";let g=g=>{let{setting:I,styles:f,builderProps:h,gallery:b,onHandleClickImage:y,priorityFeatureImage:C,children:F,noDataChildren:P,isFilterByVariantEnabled:v}=g,{isEditMode:w}=i(),j=l(null),k=o(),x=s(e=>{if(!j.current)return;let r=j.current.getSwiper();r&&r.thumbs&&r.thumbs.swiper&&r.thumbs.swiper?.realIndex===void 0&&e&&(r.thumbs.swiper=e,r.thumbs.init(),r.thumbs.update(!0),r.update())},[]),H={...I,...f},{isShowCarousel:G,featureImageHeight:N,featureWrapperImage:S,onClickFeatureArrow:U,activeIndexFromFeatureImage:A,setOnClickFeatureArrow:D,onHandleLoadedFeatureImage:R,setActiveIndexFromFeatureImage:W}=c(g);if(b?.[0]?.id==="noImageError"&&w)return e(r,{children:P});let{ftImageGalleryClasses:$,imageGalleryWrapperClasses:E}=n(g),{wrapperFeaturedImageStyle:J,featureImageStyle:L,galleryImageStyle:O}=p(H,{gallery:b,featureImageHeight:N}),q=JSON.stringify(H?.position)+k+G;return t("div",{className:a("gp-grid gp-w-full gp-relative"),style:J,children:[t("div",{className:$,style:L,children:[F,e(u,{ref:j,imgRef:S,productImages:b,...H,onHandleClick:(e,r)=>y(e||"",r),onHandleLoaded:R,onHandleUpdateActiveIndex:W,onClickArrow:e=>D(e),builderPropUID:h?.uid,builderPropsClass:`gp-product-images-feature-${h?.uid}`})]}),b.length>(v?0:1)&&e("div",{className:E,style:O,children:G?e(d,{productImages:b,position:H?.position,...H,builderPropUID:h?.uid,onHandleClick:(e,r)=>y(e||"",r),onSwiperReady:x,activeIndexFormFeatureImage:A,priorityFeatureImage:C,onClickFeatureArrow:U,builderPropsClass:`gp-product-images-gallery-${h?.uid}`}):e(m,{productImages:b,...H,builderPropUID:h?.uid,onHandleClick:(e,r)=>y(e||"",r),activeIndexFromFeatureImage:A,isHiddenInteraction:!0})})]},q)};export{g as default};
