"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}=e,{isEditMode:o}=core.useRenderMode(),c=React.useRef(null),m=core.useCurrentDevice(),n=React.useCallback(e=>{if(!c.current)return;let r=c.current.getSwiper();r&&r.thumbs.swiper?.realIndex===void 0&&e&&(r.thumbs.swiper=e,r.thumbs.init(),r.thumbs.update(!0),r.update())},[]),g={...r,...t},{isShowCarousel:I,featureImageHeight:p,featureWrapperImage:y,onClickFeatureArrow:j,activeIndexFromFeatureImage:x,setOnClickFeatureArrow:P,onHandleLoadedFeatureImage:C,setActiveIndexFromFeatureImage:h}=useFeatureImageWithGallery.useFeatureImageWithGallery(e);if(s?.[0]?.id==="noImageError"&&o)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:d});let{ftImageGalleryClasses:F,imageGalleryWrapperClasses:R}=getProductImagesClassName.getProductImagesClassName(e),{wrapperFeaturedImageStyle:G,featureImageStyle:b,galleryImageStyle:f}=getProductImagesStyles.getProductImagesStyles(g,{gallery:s,featureImageHeight:p}),v=JSON.stringify(g?.position)+m+I;return jsxRuntime.jsxs("div",{className:core.cls("gp-grid gp-w-full gp-relative"),style:G,children:[jsxRuntime.jsxs("div",{className:F,style:b,children:[i,jsxRuntime.jsx(ProductFeaturedImageCarousel.default,{ref:c,imgRef:y,productImages:s,...g,onHandleClick:(e,r)=>u(e||"",r),onHandleLoaded:C,onHandleUpdateActiveIndex:h,onClickArrow:e=>P(e),builderPropUID:a?.uid,builderPropsClass:`gp-product-images-feature-${a?.uid}`})]}),s.length>1&&jsxRuntime.jsx("div",{className:R,style:f,children:I?jsxRuntime.jsx(GalleryCarousel.default,{productImages:s,position:g?.position,...g,builderPropUID:a?.uid,onHandleClick:(e,r)=>u(e||"",r),onSwiperReady:n,activeIndexFormFeatureImage:x,priorityFeatureImage:l,onClickFeatureArrow:j,builderPropsClass:`gp-product-images-gallery-${a?.uid}`}):jsxRuntime.jsx(ProductGalleryGrid.default,{productImages:s,...g,builderPropUID:a?.uid,onHandleClick:(e,r)=>u(e||"",r),activeIndexFromFeatureImage:x,isHiddenInteraction:!0})})]},v)};exports.default=FeatureImageWithGallery;
