import{aa as p,K as l,S as d,L as _,M as i,V as m,U as c,P as g,a7 as h,W as f,aq as k,aZ as M,aX as C,b as R}from"./vendor-bSWkQivH.js";import{u as v}from"./index-CAMXIOZf.js";import{J as U,U as y,K as P}from"./index-Dqv5IkpS.js";import{O as D,P as V,M as $}from"./types-zo7pMMkl.js";function z(){return p($,{optimisticResponse:{markPushMessageUnread:!0},update(n,e,{variables:a}){var r,u;if(!((r=e.data)!=null&&r.markPushMessageUnread))return;let o=null;n.updateFragment({id:`${U}${(u=a==null?void 0:a.command)==null?void 0:u.messageId}`,fragment:V},s=>(o=s,s?{...s,isRead:!1}:null)),n.modify({fields:{[P]:s=>{const t=s;return o!=null&&o.isHidden?t:{totalCount:(t.totalCount??0)+1}},[y]:s=>({totalCount:(s.totalCount??0)+1})}})},refetchQueries:[D.Query.GetPushMessages]})}function B(n){const{mutate:e}=v();async function a(){await e({command:{messageId:n.value.id}})}const{mutate:o}=z();async function r(){await o({command:{messageId:n.value.id}})}async function u(){n.value.isRead?await r():await a()}return{pushMessage:n,markRead:a,markUnread:r,toggleRead:u}}const E={class:"vc-push-message__info"},H={class:"vc-push-message__date"},N=l({__name:"vc-push-message",props:{pushMessage:{},removable:{type:Boolean},size:{default:"md"}},emits:["remove"],setup(n){return(e,a)=>{const o=d("VcBadge"),r=d("VcMarkdownRender"),u=d("VcButton");return i(),_("div",{class:k(["vc-push-message",`vc-push-message--size--${e.size}`,{"vc-push-message--unread":!e.pushMessage.isRead}])},[m(o,{class:"vc-push-message__badge",color:"info",rounded:""}),c("div",E,[m(r,{class:"vc-push-message__content",src:e.pushMessage.shortMessage},null,8,["src"]),c("div",H,f(e.$d(e.pushMessage.createdDate,{key:"long",second:void 0})),1)]),e.removable?(i(),g(u,{key:0,class:"vc-push-message__button",size:"xs",color:"neutral",variant:"no-background",icon:"delete-thin",onClick:a[0]||(a[0]=s=>{e.$emit("remove"),s.stopPropagation()})})):h("",!0)],2)}}}),K=l({__name:"push-message",props:{pushMessage:{},size:{}},emits:["toggleRead"],setup(n,{emit:e}){const a=e,o=n,{pushMessage:r}=M(o),{toggleRead:u}=B(r);async function s(){await u(),a("toggleRead")}return(t,w)=>(i(),g(N,{size:t.size,"push-message":R(r),role:"button",tabindex:"0","aria-label":t.pushMessage.isRead?t.$t("push_messages.mark_as_unread"):t.$t("push_messages.mark_as_read"),title:t.pushMessage.isRead?t.$t("push_messages.mark_as_unread"):t.$t("push_messages.mark_as_read"),onClick:s,onKeypress:C(s,["enter"])},null,8,["size","push-message","aria-label","title"]))}});export{K as _};
//# sourceMappingURL=push-message.vue_vue_type_script_setup_true_lang-BSEZ4noP.js.map
