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