mishlohim.pushNotifications=function(){function f(){i||($(function(){r()}),i=!0)}function e(n){const u="=".repeat((4-n.length%4)%4),f=(n+u).replace(/\-/g,"+").replace(/_/g,"/"),i=window.atob(f),r=new Uint8Array(i.length);for(var t=0;t<i.length;++t)r[t]=i.charCodeAt(t);return r}function o(){t.pushManager.getSubscription().then(function(t){n=!(t===null);n||s()})}function s(){const i=e(u);t.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:i}).then(function(t){c(t);r(t);n=!0}).catch(function(n){console.log("Failed to subscribe the user: ",n)})}function h(n,t,i){var u=typeof t=="string"?t:Object.keys(t).map(function(n){return encodeURIComponent(n)+"="+encodeURIComponent(t[n])}).join("&"),r=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");return r.open("POST",n),r.onreadystatechange=function(){r.readyState>3&&r.status===200&&i(r.responseText)},r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r.setRequestHeader("Content-Type","application/json"),r.send(u),r}function c(n){if(n){var t=Cookies.get("zapum_v1"),i=l(t),r={Subscription:n,UserAgent:navigator.userAgent,SiteId:3,Fingerprint:i};h(mishlohim.settings.zap360BaseUrl+"api/push/subscribe",JSON.stringify(r),function(n){console.log(n)})}}function l(n){try{var t=JSON.parse(n),i=t.GUID}catch(r){return null}return i}function r(){try{a().then(function(n){if(n!==null){var t=new Date;t.setTime(t.getTime()+2592e6);Cookies.set("zap_push",JSON.stringify(n),{expires:t,path:"/",sameSite:"None",secure:!0})}else Cookies.remove("zap_push",{path:"/"})})}catch(n){console.log("getsub failed")}}function a(){return navigator.serviceWorker.getRegistration("https://"+location.host+"/scripts/shared/notifications/").then(function(n){return n.pushManager.getSubscription().then(function(n){return n})}).catch(function(n){console.log(n)})}const u="BAVIs-xeRG-sDP3s2L6ltf8deCMeh83Rkox-DPcB6lIUpXs_my-ZP6A7XVMqvlTwKHTPLgmuzmaSe2HF5_gzqm8";var n=!1,t=null,i=!1;return"serviceWorker"in navigator&&"PushManager"in window&&Notification&&Notification.permission!=="denied"&&Notification.requestPermission().then(function(n){n!=="denied"&&navigator.serviceWorker.register("/scripts/shared/notifications/sw.js").then(function(n){t=n;o();n.update()}).catch(function(n){console.error("Service Worker Error",n);var t="Service Worker Error: "+n;mishlohim.logger.logErrorToServer(t,!0)})}),{init:function(){f()}}}();mishlohim.pushNotifications.init()