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