import{H as _,b as d,d as p}from"./bootstrap-Bz3m6YT1.js";import{_ as f,d as b}from"./currency-Dtag6qPd.js";import{n as v}from"./ns-prompt-popup-C8eAhAy7.js";import{h as x}from"./components-CDxq1sm2.js";import{_ as g}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{r as k,o as c,c as r,a as e,t as a,e as u,n as y,F as w,b as C,f as N}from"./runtime-core.esm-bundler-DzqFO6Tt.js";import"./chart-D2s_fKm5.js";import"./ns-alert-popup-B6pzDgFD.js";import"./ns-avatar-image-CIpC3xeh.js";import"./index.es-ua9LYOjR.js";const B={name:"ns-notifications",data(){return{notifications:[],visible:!1,interval:null}},components:{nsCloseButton:x},mounted(){document.addEventListener("click",this.checkClickedItem),this.interval=setInterval(()=>{this.loadNotifications()},15e3),this.loadNotifications()},unmounted(){clearInterval(this.interval)},methods:{__:f,timespan:_,nsNumberAbbreviate:b,pushNotificationIfNew(s){this.notifications.filter(i=>i.id===s.id).length>0||this.notifications.push(s)},deleteNotificationIfExists(s){const t=this.notifications.filter(i=>i.id===s.id);if(t.length>0){const i=this.notifications.indexOf(t[0]);this.notifications.splice(i,1)}},deleteAll(){Popup.show(v,{title:f("Confirm Your Action"),message:f("Would you like to clear all the notifications ?"),onAction:s=>{s&&d.delete("/api/notifications/all").subscribe(t=>{p.success(t.message).subscribe()})}})},checkClickedItem(s){let t;document.getElementById("notification-center")?t=document.getElementById("notification-center").contains(s.srcElement):t=!1;const i=document.getElementById("notification-button").contains(s.srcElement);!t&&!i&&this.visible&&(this.visible=!1)},loadNotifications(){d.get("/api/notifications").subscribe(s=>{this.notifications=s})},triggerLink(s){if(s.url!=="url")return window.open(s.url,"_blank")},closeNotice(s,t){d.delete(`/api/notifications/${t.id}`).subscribe(i=>{this.loadNotifications()}),s.stopPropagation()}}},I={id:"notificaton-wrapper"},E={key:0,class:"relative float-right"},j={class:"absolute -ml-6 -mt-8"},A={class:"bg-info-tertiary text-white w-8 h-8 rounded-full text-xs flex items-center justify-center"},L=e("i",{class:"las la-bell"},null,-1),P={key:0,class:"h-0 w-0",id:"notification-center"},V={class:"absolute left-0 top-0 sm:relative w-screen zoom-out-entrance anim-duration-300 h-5/7-screen sm:w-64 sm:h-108 flex flex-row-reverse"},z={class:"z-50 sm:rounded-lg shadow-lg h-full w-full md:mt-2 overflow-y-hidden flex flex-col"},F=e("h3",{class:"font-semibold hover:text-info-primary"},"Close",-1),H=[F],S={class:"overflow-y-auto flex flex-col flex-auto"},D=["onClick"],O={class:"flex items-center justify-between"},W={class:"font-semibold"},Y={class:"py-1 text-sm"},q={class:"flex justify-end"},G={class:"text-xs date"},J={key:0,class:"h-full w-full flex items-center justify-center"},K={class:"flex flex-col items-center"},M=e("i",{class:"las la-laugh-wink text-5xl text-primary"},null,-1),Q={class:"text-secondary text-sm"},R={class:"cursor-pointer clear-all"};function T(s,t,i,U,o,l){const h=k("ns-close-button");return c(),r("div",I,[e("div",{id:"notification-button",onClick:t[0]||(t[0]=n=>o.visible=!o.visible),class:y([o.visible?"panel-visible border-0 shadow-lg":"border panel-hidden","hover:shadow-lg hover:border-opacity-0 rounded-full h-12 w-12 cursor-pointer font-bold text-2xl justify-center items-center flex"])},[o.notifications.length>0?(c(),r("div",E,[e("div",j,[e("div",A,a(l.nsNumberAbbreviate(o.notifications.length,"abbreviate")),1)])])):u("",!0),L],2),o.visible?(c(),r("div",P,[e("div",V,[e("div",z,[e("div",{onClick:t[1]||(t[1]=n=>o.visible=!1),class:"sm:hidden p-2 cursor-pointer flex items-center justify-center border-b border-gray-200"},H),e("div",S,[(c(!0),r(w,null,C(o.notifications,n=>(c(),r("div",{key:n.id,class:"notification-card notice border-b"},[e("div",{class:"p-2 cursor-pointer",onClick:m=>l.triggerLink(n)},[e("div",O,[e("h1",W,a(n.title),1),N(h,{onClick:m=>l.closeNotice(m,n)},null,8,["onClick"])]),e("p",Y,a(n.description),1),e("div",q,[e("span",G,a(l.timespan(n.updated_at)),1)])],8,D)]))),128)),o.notifications.length===0?(c(),r("div",J,[e("div",K,[M,e("p",Q,a(l.__("Nothing to care about !")),1)])])):u("",!0)]),e("div",R,[e("h3",{onClick:t[2]||(t[2]=n=>l.deleteAll()),class:"text-sm p-2 flex items-center justify-center w-full font-semibold"},a(l.__("Clear All")),1)])])])])):u("",!0)])}const ce=g(B,[["render",T]]);export{ce as default};
