"use strict";var core=require("@gem-sdk/core"),React=require("react"),productGallery=require("../common/productGallery.js"),useFilterImagesByVariant=require("./useFilterImagesByVariant.js"),helpers=require("../../../../image/common/helpers.js");const useProductGalleryGrid=e=>{let{builderPropUID:r,productImages:t,activeIndexFormFeatureImage:a,children:o,isHiddenInteraction:s,...i}=e,l=core.useCurrentDevice(),c=core.useFeaturedImageGlobal(),[u,n]=React.useState(0),y=core.useEditorMode(),{filteredProductImages:d}=useFilterImagesByVariant.useFilterImagesByVariant({productImages:t,displayByVariant:i?.displayByVariant,variantSelect:i?.variantSelect}),p=productGallery.getShapeByLayout({shape:i.shape,shapeForBottom:i.shapeForBottom,shapeFor1Col:i.shapeFor1Col,shapeFor2Col:i.shapeFor2Col,shapeForFtOnly:i.shapeForFtOnly,shapeForInsideBottom:i.shapeForInsideBottom,shapeForInside:i.shapeForInside},i.position),h=core.getResponsiveValueByScreen(i.clickOpenLightBox,l),F=productGallery.checkDisplayGalleryByWidth({shapeByLayout:p}),m=core.getResponsiveValueByScreen(F,l),B=i?.borderActive?.border!=="none",g=React.useCallback(()=>{helpers.handleSetSrcForProductImageList({builderPropUID:r,shapeByLayout:p,qualityType:i.qualityType,qualityPercent:i.qualityPercent})},[p,i.qualityPercent,i.qualityType,r]);return React.useEffect(()=>{n(a||0)},[a]),React.useEffect(()=>{let e=d?.findIndex(e=>e.id===c?.id);n(e&&e>0?e:0)},[c,d]),React.useEffect(()=>{if("edit"===y)return;let e=document?.querySelector(".grid-gallery");if(!e)return;g();let r=new ResizeObserver(()=>{g()});return r?.observe(e,{}),()=>{r?.disconnect()}},[g,r,y]),{isDisplay:m,shapeByLayout:p,imageActiveIndex:u,enableOpenLightBox:h,isEnableBorderActive:B,filteredProductImages:d}};exports.useProductGalleryGrid=useProductGalleryGrid;
