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