import{a6 as p,C as l,N as d,D as _,E as i,Q as m,P as c,K as g,a3 as h,R as f,am as k,aQ as C,aM as M,u as R}from"./vendor-BGtMsOoo.js";import{u as v}from"./index-DbcF6rmZ.js";import{J as y,U as D,K as P}from"./index-CRze-aDK.js";import{O as U,P as E,M as N}from"./types-zo7pMMkl.js";function $(){return p(N,{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:`${y}${(u=a==null?void 0:a.command)==null?void 0:u.messageId}`,fragment:E},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}},[D]:s=>({totalCount:(s.totalCount??0)+1})}})},refetchQueries:[U.Query.GetPushMessages]})}function z(n){const{mutate:e}=v();async function a(){await e({command:{messageId:n.value.id}})}const{mutate:o}=$();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 B={class:"vc-push-message__info"},H={class:"vc-push-message__date"},V=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",B,[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)}}}),O=l({__name:"push-message",props:{pushMessage:{},size:{}},emits:["toggleRead"],setup(n,{emit:e}){const a=e,o=n,{pushMessage:r}=C(o),{toggleRead:u}=z(r);async function s(){await u(),a("toggleRead")}return(t,w)=>(i(),g(V,{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:M(s,["enter"])},null,8,["size","push-message","aria-label","title"]))}});export{O as _};
//# sourceMappingURL=push-message.vue_vue_type_script_setup_true_lang-CDVGgRG_.js.map
