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