import{ab as i,bi as c,aM as g,dt as m,du as h,dv as p}from"./index-5b69f37f-1740456180783.js";const o=e=>{if(e===null)return null;const s=Object.assign({},e);return Object.keys(s).forEach(r=>s[r]=typeof e[r]=="object"?o(e[r]):e[r]),Array.isArray(e)?(s.length=e.length,Array.from(s)):s},d=e=>i.post("/edu-app/material/queryPage",{data:e}),T=e=>i.post("/edu-app/material/favorite",{data:e}),v=e=>i.post("/edu-app/material/remove",{requestType:"form",data:e}),M=e=>i.post("/edu-app/lessonCourseware/save",{data:e}),j=e=>i.post("/edu-app/material/save",{data:e}),L=e=>i.post("/edu-app/material/updateAll",{data:e}),S=e=>i.post("/edu-app/material/removeMusic",{data:e}),b=e=>i.post("/edu-app/materialTag/page",{data:e}),y=c("catch-store",{state:()=>({bookVersionList:[],musicTypeList:[],subjectList:[],musicInstrumentList:[],subjectInstruemnts:[],musicTagTree:[],materialTags:[]}),getters:{getBookVersion(){return this.bookVersionList},getMusicCategories(){return this.musicTypeList},getMusicInstruments(){return this.musicInstrumentList},getAllMusicCategories(){return[{name:"全部",id:null},...this.musicTypeList]},getSubjectList(){return this.subjectList},getSubjectAllList(){return[{name:"全部",id:null},...this.subjectList]},getEnableSubjects(){const e=[];return this.subjectList.forEach(s=>{if(s.enableFlag){const{instruments:r,...t}=s;if(r&&r.length>0){const n=[];r==null||r.forEach(a=>{a.enableFlag&&n.push(a)}),n.length>0&&e.push({...t,instruments:n})}}}),e},getSubjectInstruments(){return[{name:"全部",id:null,label:"全部",value:null},...this.subjectInstruemnts]},getSubjectInstrumentOnly(){return this.subjectInstruemnts},getMusicTagTree(){return this.musicTagTree},getMaterialTags(){return this.materialTags},getAllMaterialTags(){return[{label:"全部",value:null},...this.materialTags]}},actions:{setBookVersion(e){this.bookVersionList=e},setMusicCategories(e){this.musicTypeList=e},setSubjects(e){this.subjectList=e},setSubjectInstruemnts(e){this.subjectInstruemnts=e},setMusicInstruments(e){this.musicInstrumentList=e},setMusicTagTree(e){this.musicTagTree=e},setMaterialTags(e){this.materialTags=e},async getSubjects(){try{if(this.getSubjectList&&this.getSubjectList.length>0)return Promise.resolve();const{data:e}=await g({delFlag:0,page:1,rows:999}),s=e||[],r=[];return s.forEach(t=>{if(t.instruments&&t.instruments.length>0){t.value=t.id,t.label=t.name,t.instruments.forEach(a=>{a.label=a.name,a.value=a.id});const n={value:t.id,label:t.name,id:t.id,name:t.name,instruments:[]};t.instruments&&(t.instruments.length==1?(n.value=t.instruments[0].id,n.label=t.instruments[0].name,n.id=t.id,n.name=t.name):t.instruments.length>1&&t.instruments.forEach(a=>{a.label=a.name,a.value=a.id,n.instruments.push({label:a.name,value:a.id,id:a.id,name:a.name})})),r.push(n)}}),this.setSubjects(s.filter(t=>t.instruments&&t.instruments.length>0)||0),this.setSubjectInstruemnts(r||[]),Promise.resolve()}catch(e){return Promise.reject(e)}},getEnableSingleAllSubjects(e){e=e||[];const s=[];this.getSubjectList.forEach(t=>{const n=o(t);Array.isArray(n.instruments)&&n.instruments.forEach(a=>{e.includes(a.id)&&(a.enableFlag=!0,n.enableFlag=!0)}),s.push(n)});const r=[];return s.forEach(t=>{if(t.enableFlag){const{instruments:n,...a}=t,u=[];n==null||n.forEach(l=>{l.enableFlag&&u.push(l)}),u.length>0&&r.push({...a,instruments:u})}}),r},async getMusicSheetCategory(e=!1){try{if(this.getMusicCategories&&this.getMusicCategories.length>0&&!e)return Promise.resolve();const{data:s}=await m({enable:!0,page:1,rows:999});return this.setMusicCategories(s.rows||[]),Promise.resolve()}catch(s){return Promise.reject(s)}},async getMusicInstrument(){try{if(this.getMusicInstruments&&this.getMusicInstruments.length>0)return Promise.resolve();const{data:e}=await h({enableFlag:!0});return console.log(e,"data"),this.setMusicInstruments(e||[]),Promise.resolve()}catch(e){return Promise.reject(e)}},async getMusicTagTreeApi(){try{if(this.getMusicTagTree&&this.getMusicTagTree.length>0)return Promise.resolve();const{data:e}=await p(),s=e||[];return this.setMusicTagTree(s||[]),Promise.resolve()}catch(e){return Promise.reject(e)}},async getMaterialTagsApi(){try{if(this.getMaterialTags&&this.getMaterialTags.length>0)return Promise.resolve();const{data:e}=await b({page:1,rows:100}),s=e.rows||[],r=[];return s.forEach(t=>{r.push({label:t.name,value:t.id})}),this.setMaterialTags(r||[]),Promise.resolve()}catch(e){return Promise.reject(e)}}}});export{S as a,L as b,v as c,o as d,j as e,T as f,b as g,M as h,d as m,y as u};
