import{ref as a}from"vue";import{defineStore as t}from"pinia";import{k as e,b as i}from"./server.mjs";const o=t("car",(()=>{const{$axios:t}=e(),o=a({}),{locale:s,t:r}=i(),c=a(),d=a(),n=a([]),u=a([]),l=a(!0),p=a(!0),m=a(!1),v=a(!0),g=a(!1);let f=a(),y=a(1),w=a(),h=a();async function _(a){const e=await t.get("user/car",{params:{device_ip:a}});e.status>=200&&(v.value=!1,u.value=e.data.data)}return{errors:o,getCar:async function(a){const e=await t.get(`car/${a}`);e.status>=200&&(c.value=e.data.data,l.value=!1),setTimeout((()=>{l.value=!0}),500)},getCarBySlug:async function(a){const e=await t.get(`car/${a}`);e.status>=200&&(c.value=e.data.data,l.value=!1),setTimeout((()=>{l.value=!0}),500)},getSearchCars:async function(a,e){m.value=!0;const i=await t.get("car/search",{params:{page:a,model_id:"object"==typeof e.model_id?[...e.model_id]:[e.model_id],brand_id:"object"==typeof e.model_id?[...e.brand_id]:[e.brand_id],car_id:"object"==typeof e.model_id?[...e.car_id]:[e.car_id],min_price:e.min_price,max_price:e.max_price}});i.status>=200&&(0==i.data.data.length?n.value=[]:n.value=[...n.value,...i.data.data],p.value=!1,m.value=!1,f.value=i.data.meta.total,w.value=i.data.meta.per_page,h.value=i.data.meta.to)},filteredCar:n,isLoading:l,pendingState:g,isLoading2:p,isLoading3:m,gePrices:async function(){const a=await t.get("prices");a.status>=200&&(v.value=!1,d.value=a.data)},prices:d,itemsPerPage:h,isLoading4:v,AddFav:async function(a,e,i=!1,o=""){if((await t.post("add-favorite-withoutauth",{car_id:a,device_ip:o})).status>=200){const a=await import("mosha-vue-toastify"),{createToast:t}=a;t(r(e?"wishlist1":"wishlist2"),{toastBackgroundColor:"#00A0B4",position:"top-right",type:"success",transition:"bounce",showIcon:"true",timeout:3e3}),i&&_(o)}},page:y,per_page:w,total:f,car:c,getFav:_,favsArr:u}}));export{o as J};
