"use strict";var e=require("@gem-sdk/core"),t=require("react");exports.useProductSetting=r=>{let{setting:a}=r,{productSetting:u,quantity:d,readOnly:o,isSyncProduct:i}=a??{},s=e.usePageType(),c=e.usePageStore(e=>e.dynamicProduct),n=e.usePageStore(e=>e.publicStoreFrontData),{isEditMode:P,isPreviewSharePageMode:S}=e.useRenderMode(),l=u?.productId??"latest",g=u?.productStatus=="dynamic"?{...u,...c}:u,h=g?.initialVariantId,m=g?.initialVariantBaseId,p=t.useMemo(()=>e.hasPublicStoreFrontData(n)?e.createStoreFrontFetcher(n):void 0,[n]),{data:y,isLoading:F,error:M}=e.useProductQuery(l,{revalidateOnMount:P||S},p),[v,D]=t.useState(!0),I=(M||!y&&!F)&&P,b=t.useMemo(()=>({product:y,initialVariantId:h,initialVariantBaseId:m,quantity:d,readOnly:o,isSyncProduct:i,key:`uid-${y?.id}-${h??""}`,hasPreSelected:u?.hasPreSelected}),[m,h,i,y,u?.hasPreSelected,d,o]);return{forceProductSetting:g,isProductPage:"PRODUCT"===s,isProductNotFound:I,showProductNotFound:v,isLoading:F,product:y,errorLoadProduct:M,isEditor:P,productProviderData:b,setShowProductNotFound:D}};
