import{jsx as r,Fragment as o,jsxs as t}from"react/jsx-runtime";import{isEmptyChildren as e,ProductProvider as d}from"@gem-sdk/core";import i from"../../../grid/components/ChildrenDroppable.js";import m from"../../../common/components/Loading.js";import"react";import c from"../../../grid/components/row/Row.js";import{If as n}from"@gem-sdk/system";import s from"next/dynamic";import{useProductSetting as l}from"./hook/useProductSetting.js";import{getData as p}from"./common/helpers.js";let ProductNotFound=s(()=>import("../ProductNotFound.js"),{loading:m}),Product=s=>{let{builderProps:u,children:a,setting:h,style:f,builderAttrs:g}=s,{isAuto:P}=h??{},{isLoading:j,isProductPage:b,isProductNotFound:y,showProductNotFound:k,errorLoadProduct:x,product:A,isEditor:F,productProviderData:N,setShowProductNotFound:v}=l(s),{rowSetting:w,rowStyles:C}=p(s),D=!y;if(b&&P)return r(o,{children:e(a)?r(i,{}):a});let S=()=>r(o,{children:n(k,r(ProductNotFound,{builderAttrs:g,productSrc:"PickProduct",onClose:()=>v(!1),children:a}))}),E=()=>r(o,{children:j?r(m,{}):r(o,{children:x?t("div",{children:["Error: ",x?.message]}):A?r(d,{...N,children:r(c,{builderProps:u,builderAttrs:g,style:f,styles:C,setting:w,customAttrs:F?{"data-product-id":A?.baseID?.replace("gid://shopify/Product/","")??""}:void 0,children:e(a)?r(i,{}):a})}):null})});return r(o,{children:n(D,E(),S())})};export{Product as default};
