'use client';
import{jsx as o}from"react/jsx-runtime";import{usePageType as t,useShopStore as r}from"@gem-sdk/core";import{useState as e,useEffect as n,useMemo as i}from"react";import c from"../../common/components/NoDataState.js";let ProductNotFound=({collectionHandle:d,productSrc:a,builderAttrs:l,children:u})=>{let p="STATIC"===t(),f=r(o=>o.storefrontToken),y=r(o=>o.storefrontUrl),m="Collection"===a,[s,h]=e(""),[S,g]=e("get product"),[w,b]=e("");n(()=>{if(m){if(!d){h("We cannot find any collections from your Shopify store. Please try manually syncing the data from Shopify or add a new collection."),g("get collection"),b("collection");return}h("We cannot find any product of this collection from your Shopify store? Please try manually syncing the data from Shopify or add a new product to your collection."),g("get product of collection"),b("product");return}if(p&&!f){b("product"),h("We can not get your products from Shopify");return}b("product"),g("get product"),h("We cannot find any products from your Shopify store. Please try manually syncing the data from Shopify or add a new product.")},[d,m,p,f]);let C=i(()=>{if(!y)return;let o=new URL(y);return m?`${o.protocol}//${o.host}/admin/collections`:`${o.protocol}//${o.host}/admin/products`},[m,y]),T=o=>{let t=new CustomEvent("editor:sync-product",{bubbles:!0,detail:{uid:o}});window.dispatchEvent(t)};return o(c,{elementType:"primary",children:u,builderAttrs:l,title:`Can not ${S} from Shopify`,description:s,primaryBtnTitle:`Add ${w}`,secondaryBtnTitle:"Sync from Shopify",primaryBtnCb:()=>{C&&window.open(C,"_blank")},secondaryBtnCb:()=>T(l?.["data-uid"]??l?.uid)})};export{ProductNotFound as default};
