import{ref as a}from"vue";import{defineStore as w}from"pinia";import{b as y,k as C}from"../server.mjs";import"klona";import"defu";import"#internal/nuxt/paths";const L=w("contact",()=>{const{locale:p}=y(),{$axios:i}=C(),n=a({}),o=a(!1),r=a(!0),m=a(!1);let c=a(),f=a(1),l=a();const u=a([]);async function d(s,e){o.value=!0;try{let t=new FormData;if(t.append("name",s.name),t.append("phone",`+966${s.phone}`),t.append("email",s.email),t.append("message",s.message),(await i.post("contact",t)).status>=200){o.value=!1,n.value=void 0;const v=await import("mosha-vue-toastify"),{createToast:h}=v;h(p.value=="ar"?"تم التواصل بنجاح ":"Communication was successful",{toastBackgroundColor:"#00A0B4",position:"top-right",type:"success",transition:"bounce",showIcon:"true",timeout:3e3}),e({values:{email:"",name:"",message:""},errors:{}})}}catch(t){t.response&&(o.value=!1,n.value=t.response.data.errors)}}async function g(s){try{const e=await i.get("questions",{params:{page:s}});e.status>=200&&(r.value=!1,u.value=[...u.value,...e.data.data],c.value=e.data.meta.total,l.value=e.data.meta.per_page)}catch(e){e.response&&(r.value=!1)}}return{errors:n,isLoading:o,pendingState:m,isLoading2:r,getContact:d,questions:u,page:f,total:c,per_page:l,getQuestions:g}});export{L as u};
