import{l as s,n as c,o as u,p as i}from"./index-Cc987VYg.js";const r="/currencies",y=async e=>{const{data:a}=await s.get(`${r}/`,{params:e});return a},o=async()=>{const{data:e}=await s.get(`${r}/active/`);return e.data||e.results||e},d=async e=>{const{data:a}=await s.get(`${r}/${e}/`);return a.data||a},l=async e=>{const a=await s.post(`${r}/`,e);return a.data.data||a.data},v=async(e,a)=>{const n=await s.put(`${r}/${e}/`,a);return n.data.data||n.data},C=async e=>{const a=await s.post(`${r}/${e}/set_as_base/`);return a.data.data||a.data},q=async e=>{const a=await s.post(`${r}/${e}/activate/`);return a.data.data||a.data},$=async e=>{const a=await s.post(`${r}/${e}/deactivate/`);return a.data.data||a.data},t={all:["currencies"],lists:()=>[...t.all,"list"],list:e=>[...t.lists(),e],active:()=>[...t.all,"active"],base:()=>[...t.all,"base"],details:()=>[...t.all,"detail"],detail:e=>[...t.details(),e]},K=e=>c({queryKey:t.list(e),queryFn:()=>y(e),staleTime:300*1e3}),b=()=>c({queryKey:t.active(),queryFn:o,staleTime:600*1e3}),Q=(e,a=!0)=>c({queryKey:t.detail(e),queryFn:()=>d(e),enabled:a&&!!e}),w=()=>{const e=u();return i({mutationFn:a=>l(a),onSuccess:a=>{e.invalidateQueries({queryKey:t.lists()}),e.invalidateQueries({queryKey:t.active()}),a.is_base_currency&&e.invalidateQueries({queryKey:t.base()})}})},g=()=>{const e=u();return i({mutationFn:({id:a,data:n})=>v(a,n),onSuccess:(a,n)=>{e.invalidateQueries({queryKey:t.lists()}),e.invalidateQueries({queryKey:t.active()}),e.invalidateQueries({queryKey:t.detail(n.id)}),a.is_base_currency&&e.invalidateQueries({queryKey:t.base()})}})};export{b as a,o as b,q as c,$ as d,w as e,g as f,y as g,Q as h,C as s,K as u};
