import{d as S,l as r,a as e,I as h,B as m,K as f,U as F,x as T,P as w,j as I}from"./vendor.cd162bf7.js";/* empty css               *//* empty css                */import{c as E}from"./index.926ca9c5.js";import{M as x}from"./music-icon.c20abf48.js";import{I as N}from"./init-user-icon.6387573f.js";import{F as C}from"./favorite.cb69f4f9.js";import{s as n,r as y}from"./index.a9c80450.js";import{C as D}from"./index.bf04a798.js";var U="./assets/favorited.3ea1df17.svg",B="./assets/icon_share.008c9139.svg";const M="_item_xgd8z_1",P="_header_xgd8z_8",A="_mate_xgd8z_13",V="_icon_xgd8z_18",$="_info_xgd8z_23",L="_btn_xgd8z_38",O="_vip_xgd8z_46",R="_free_xgd8z_50",H="_charge_xgd8z_54",k="_footer_xgd8z_58",q="_user_xgd8z_63",G="_userIcon_xgd8z_69",K="_favorite_xgd8z_81",J="_tags_xgd8z_84",Q="_shareBtn_xgd8z_90",W="_shareMate_xgd8z_93",X="_tagDiscount_xgd8z_123";var s={item:M,header:P,mate:A,icon:V,info:$,btn:L,vip:O,free:R,charge:H,footer:k,user:q,userIcon:G,favorite:K,tags:J,shareBtn:Q,shareMate:W,tagDiscount:X};function Y(o){return typeof o=="function"||Object.prototype.toString.call(o)==="[object Object]"&&!T(o)}const Z={CHARGE:"\u70B9\u64AD",FREE:"\u514D\u8D39",VIP:"VIP"};var le=S({name:"MusicItem",props:{data:{type:Object,default:{}},onClick:{type:Function}},emits:["favorite"],setup({onClick:o,data:t},{emit:b}){const c=r(t.favorite),i=r(!1);t.titleImg+""+ +new Date;const z=async a=>{a.stopPropagation(),i.value=!0;try{await y.post("/music/sheet/favorite/"+t.id,{prefix:n.platformType==="TEACHER"?"/api-teacher":"/api-student"}),c.value=!c.value}catch{}i.value=!1,b("favorite")},l=r(!1),p=r(""),v=r(0),j=async a=>{var u,g;a.stopPropagation();try{const d=await y.post("/api-teacher/open/musicShareProfit",{data:{bizId:t.id,userId:(u=n.user.data)==null?void 0:u.userId}});let _=location.origin+`/accompany/colexiu-share.html?id=${t.id}&recomUserId=${(g=n.user.data)==null?void 0:g.userId}`;d.data.discount===1&&(_+=`&activityId=${d.data.activityId}`),v.value=d.data.discount||0,p.value=_,l.value=!0;return}catch{}};return()=>e("div",null,[e("div",{class:s.item,onClick:()=>{o==null||o(t)}},[e("header",{class:[s.header,"van-hairline--bottom"]},[e("div",{class:s.mate},[e(h,{src:t.titleImg||x,round:!0,class:s.icon},null),e("div",{class:s.info},[e("h4",{class:"van-multi-ellipsis--l2"},[t.musicSheetName]),e("p",null,[t.composer])])]),e("div",{class:s.buttons},[e(m,{class:E(s.btn,s[t.chargeType.toLocaleLowerCase()])},{default:()=>[Z[t.chargeType],e(f,{name:"arrow"},null)]})])]),e("footer",{class:s.footer},[e("div",{class:s.user},[e(h,{round:!0,src:t.addUserAvatar||N,class:s.userIcon},null),e("p",null,[t.addName]),e("div",{class:s.tags},[(t.subjectNames||"").split(",").map(a=>e(F,null,Y(a)?a:{default:()=>[a]}))])]),e("div",{class:s.icons},[n.platformType==="STUDENT"?e(m,{style:{border:"none"},onClick:z,loading:i.value},{default:()=>[e(f,{class:s.favorite,name:c.value?U:C},null)]}):e(m,{style:{border:"none"},class:s.shareBtn,onClick:j},{default:()=>[e(f,{class:s.favorite,name:B},null)]})])])]),e(w,{show:l.value,"onUpdate:show":a=>l.value=a,style:{background:"transparent"},teleport:"body"},{default:()=>[e(D,{teacherId:t.userId,shareUrl:p.value,shareType:"music"},{default:()=>[e("div",{class:s.shareMate},[v.value===1&&e("div",{class:s.tagDiscount},[I("\u4E13\u5C5E\u4F18\u60E0")]),e("img",{class:s.icon,crossorigin:"anonymous",src:t.titleImg+`@base@tag=imgScale&h=80&w=80&m=1?t=${+new Date}`||x},null),e("div",{class:s.info},[e("h4",{class:"van-multi-ellipsis--l2"},[t.musicSheetName]),e("p",null,[I("\u4F5C\u66F2\u4EBA\uFF1A"),t.composer])])])]})]})])}});export{le as I};
