"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),React=require("react"),GalleryCarousel=require("../gallery-carousel/GalleryCarousel.js"),ProductGalleryGrid=require("../child/ProductGalleryGrid.js"),ProductFeaturedImageCarousel=require("../child/ProductFeaturedImageCarousel.js"),getProductImagesStyles=require("../../composables/getProductImagesStyles.js"),getProductImagesClassName=require("../../composables/getProductImagesClassName.js"),useFeatureImageWithGallery=require("../../hooks/useFeatureImageWithGallery.js");const FeatureImageWithGallery=e=>{let{setting:r,styles:t,builderProps:a,gallery:s,onHandleClickImage:u,priorityFeatureImage:l,children:i,noDataChildren:d,isFilterByVariantEnabled:o}=e,{isEditMode:c}=core.useRenderMode(),m=React.useRef(null),n=core.useCurrentDevice(),g=React.useCallback(e=>{if(!m.current)return;let r=m.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())},[]),p={...r,...t},{isShowCarousel:I,featureImageHeight:y,featureWrapperImage:j,onClickFeatureArrow:x,activeIndexFromFeatureImage:h,setOnClickFeatureArrow:P,onHandleLoadedFeatureImage:C,setActiveIndexFromFeatureImage:F}=useFeatureImageWithGallery.useFeatureImageWithGallery(e);if(s?.[0]?.id==="noImageError"&&c)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:d});let{ftImageGalleryClasses:R,imageGalleryWrapperClasses:b}=getProductImagesClassName.getProductImagesClassName(e),{wrapperFeaturedImageStyle:G,featureImageStyle:f,galleryImageStyle:v}=getProductImagesStyles.getProductImagesStyles(p,{gallery:s,featureImageHeight:y}),q=JSON.stringify(p?.position)+n+I;return jsxRuntime.jsxs("div",{className:core.cls("gp-grid gp-w-full gp-relative"),style:G,children:[jsxRuntime.jsxs("div",{className:R,style:f,children:[i,jsxRuntime.jsx(ProductFeaturedImageCarousel.default,{ref:m,imgRef:j,productImages:s,...p,onHandleClick:(e,r)=>u(e||"",r),onHandleLoaded:C,onHandleUpdateActiveIndex:F,onClickArrow:e=>P(e),builderPropUID:a?.uid,builderPropsClass:`gp-product-images-feature-${a?.uid}`})]}),s.length>(o?0:1)&&jsxRuntime.jsx("div",{className:b,style:v,children:I?jsxRuntime.jsx(GalleryCarousel.default,{productImages:s,position:p?.position,...p,builderPropUID:a?.uid,onHandleClick:(e,r)=>u(e||"",r),onSwiperReady:g,activeIndexFormFeatureImage:h,priorityFeatureImage:l,onClickFeatureArrow:x,builderPropsClass:`gp-product-images-gallery-${a?.uid}`}):jsxRuntime.jsx(ProductGalleryGrid.default,{productImages:s,...p,builderPropUID:a?.uid,onHandleClick:(e,r)=>u(e||"",r),activeIndexFromFeatureImage:h,isHiddenInteraction:!0})})]},q)};exports.default=FeatureImageWithGallery;
