import{R as n,a4 as u,a5 as g,Q as r}from"./BCLrUOBx.js";const h=()=>({products:null,allCategories:null,categoryData:null,brands:null,collections:null,shippingRules:null,searched:"",searchedSuggestion:null}),p={setProducts(s){var e,i,o,t,l,c;this.products=(e=s==null?void 0:s.data)==null?void 0:e.result,(i=s==null?void 0:s.data)!=null&&i.all_categories&&(this.allCategories=s.data.all_categories),(o=s==null?void 0:s.data)!=null&&o.category&&(this.categoryData=s.data.category),(t=s==null?void 0:s.data)!=null&&t.collections&&(this.collections=s.data.collections),(l=s==null?void 0:s.data)!=null&&l.brands&&(this.brands=s.data.brands),(c=s==null?void 0:s.data)!=null&&c.shipping&&(this.shippingRules=s.data.shipping)},updateSearch(s){this.searched=s},setSearchedSuggestion(s=null){this.searchedSuggestion=s},emptyProducts(){this.products=null},async fetchProducts(s){try{const{data:e}=await u.unAuthGet(g.api.products,s);(e==null?void 0:e.status)===200?this.setProducts(e):r({statusCode:400,message:e==null?void 0:e.message})}catch(e){r({statusCode:400,message:e.message})}}},S=n("listing",{state:h,actions:p});export{S as u};
