import{y as r,z as n}from"./index-Bodg7xX-.js";const i=r("songs",{state:()=>({songs:[],loading:!1,error:null}),getters:{published:s=>s.songs.filter(t=>t.status==="published"),drafts:s=>s.songs.filter(t=>t.status==="draft")},actions:{async fetchSongs(){var s,t;this.loading=!0,this.error=null;try{const{data:o}=await n.get("/songs");this.songs=o.songs}catch(o){this.error=((t=(s=o.response)==null?void 0:s.data)==null?void 0:t.message)||"Failed to load songs"}finally{this.loading=!1}},async lookupSpotifyTrack(s){const{data:t}=await n.post("/songs/lookup",{spotify_url:s});return t},async createSong(s){const{data:t}=await n.post("/songs",s);return this.songs.unshift(t.song),t.song},async updateSong(s,t){const{data:o}=await n.put(`/songs/${s}`,t),a=this.songs.findIndex(e=>e.id===Number(s));return a!==-1&&(this.songs[a]=o.song),o.song},async deleteSong(s){await n.delete(`/songs/${s}`),this.songs=this.songs.filter(t=>t.id!==Number(s))},async getSong(s){const{data:t}=await n.get(`/songs/${s}`);return t.song}}});export{i as u};
