import{ar as E,n as k,$ as v,as as V,f as _,T,t as B}from"./app-JmgyQoR0.js";import{b as y,D as w,h as a,i as h,j as D,u,l as p,E as f,t as l,G as R,F as j,H as M,a as I,c as $,g as N,q as z,x as b,A,z as X}from"./vue-y3KLWBaS.js";import{_ as C}from"./MkReactionIcon.vue_vue_type_script_setup_true_lang-MnLL2GJr.js";const q={class:"bqxuuuey"},F={class:"reaction"},G={class:"name"},S={class:"users"},U={key:0,class:"omitted"},H=y({__name:"MkReactionsViewer.details",props:{reaction:{},users:{},count:{},emojis:{},targetElement:{}},emits:["closed"],setup(m,{emit:r}){const e=r;return(o,s)=>{const n=w("MkAvatar"),c=w("MkUserName");return a(),h(E,{ref:"tooltip","target-element":o.targetElement,"max-width":340,onClosed:s[0]||(s[0]=t=>e("closed"))},{default:D(()=>[u("div",q,[u("div",F,[p(C,{reaction:o.reaction,"custom-emojis":o.emojis,class:"icon","no-style":!0},null,8,["reaction","custom-emojis"]),u("div",G,f(o.reaction.replace("@.","")),1)]),u("div",S,[(a(!0),l(j,null,R(o.users,t=>(a(),l("div",{key:t.id,class:"user"},[p(n,{class:"avatar",user:t},null,8,["user"]),p(c,{class:"name",user:t,nowrap:!0},null,8,["user"])]))),128)),o.users.length>10?(a(),l("div",U," +"+f(o.count-10),1)):M("",!0)])])]),_:1},8,["target-element"])}}}),K=k(H,[["__scopeId","data-v-40447aef"]]),L={class:"count"},O=y({__name:"MkReactionsViewer.reaction",props:{reaction:{},count:{},isInitial:{type:Boolean},note:{}},emits:["reacted"],setup(m,{emit:r}){const e=m,o=r,s=I(),n=$(()=>!e.reaction.match(/@\w/)&&v),c=()=>{if(!n.value)return;const t=e.note.myReaction;t?_("notes/reactions/delete",{noteId:e.note.id}).then(()=>{t!==e.reaction&&_("notes/reactions/create",{noteId:e.note.id,reaction:e.reaction})}):(_("notes/reactions/create",{noteId:e.note.id,reaction:e.reaction}),o("reacted"))};return V(s,async t=>{const d=(await T("notes/reactions",{noteId:e.note.id,type:e.reaction,limit:11,_cacheKey_:e.count})).map(g=>g.user);B(K,{showing:t,reaction:e.reaction,emojis:e.note.emojis,users:d,count:e.count,targetElement:s.value},{},"closed")},100),(t,i)=>{const d=N("ripple");return t.count>0?z((a(),l("button",{key:0,ref_key:"buttonRef",ref:s,class:b(["hkzvhatu _button",{reacted:t.note.myReaction==t.reaction,canToggle:n.value,newlyAdded:!t.isInitial}]),onClick:i[0]||(i[0]=A(g=>c(),["stop"]))},[p(C,{class:"icon",reaction:t.reaction,"custom-emojis":t.note.emojis},null,8,["reaction","custom-emojis"]),u("span",L,f(t.count),1)],2)),[[d,n.value]]):M("",!0)}}}),J=k(O,[["__scopeId","data-v-e5512630"]]),P=y({__name:"MkReactionsViewer",props:{note:{}},setup(m){const r=m,e=I(),o=new Set(Object.keys(r.note.reactions)),s=$(()=>v&&v.id===r.note.userId);return(n,c)=>(a(),l("div",{ref_key:"reactionsEl",ref:e,class:b(["reactions-list swiper-no-swiping tdflqwzn",{isMe:s.value}])},[(a(!0),l(j,null,R(n.note.reactions,(t,i)=>(a(),h(J,{key:i,reaction:i,count:t,"is-initial":X(o).has(i),note:n.note,onReacted:c[0]||(c[0]=d=>e.value.scrollTo(0,0))},null,8,["reaction","count","is-initial","note"]))),128))],2))}}),Z=k(P,[["__scopeId","data-v-bd0395f5"]]);export{Z as X};
