//v7.7.8 2024-06-19 function _webpushrExecuteHooks(e=""){0!=WebPushr.execute_hooks&&q.forEach(function(t){t[0]==e?window.webpushr.apply(this,t):e||"debug"==t[0]||"init"==t[0]||"setup"==t[0]||window.webpushr.apply(this,t)})}function _webpushrSetCookie(e,t,o){var i=new Date;i.setTime(i.getTime()+24*o*60*60*1e3);var n="expires="+i.toUTCString();document.cookie=e+"="+t+";"+n+";path=/;SameSite=Lax"}function _webpushrGetCookie(e){var t=e+"=";if(!document.cookie)return!1;for(var o=document.cookie,i=o.split(";"),n=0;nt.getTime())return _webpushrSessionLogs("session_prev_dismissed"),WebPushr.notificationCenter=_webpushrGetLocalStorage("notification_center"),WebPushr.notificationCard=_webpushrGetLocalStorage("notification_card"),1!=WebPushr.notificationCenter.enabled&&null!=WebPushr.notificationCard&&1!=WebPushr.notificationCard.enabled||("default"==Notification.permission?_webpushrGetPrompt("get_info").then(e=>{_webpushrGetPromptDisplayTime(e),_webpushrShowEmailOptin()}):_webpushrGetPrompt("bell").then(e=>{_webpushrShowSubscriptionBell(e,Notification.permission)})),!1}return-1!=window.location.href.indexOf("http://")?"http":"serviceWorker"in navigator?"PushManager"in window?"showNotification"in ServiceWorkerRegistration.prototype?"denied"===Notification.permission?(console.warn("WEBPUSHR: Notifications are denied by the user"),_webpushrGetPrompt("bell").then(e=>{_webpushrShowSubscriptionBell(e,"denied"),_webpushrShowEmailOptin()}),_webpushrSessionLogs("session_prev_denied"),!1):"http"==WebPushr.integrationType?"http":(_wp_debug&&console.log("Webpushr: Browser supports web push notifications"),!0):(console.warn("WEBPUSHR: Notifications are not supported by this browser"),_webpushrSessionLogs("session_pushnotsupported"),!1):(console.warn("WEBPUSHR: Push notifications are not supported by this browser"),_webpushrSessionLogs("session_pushnotsupported"),!1):(console.warn("WEBPUSHR: Service workers are not supported by this browser"),_webpushrSessionLogs("session_pushnotsupported"),!1)}function _wp_registerServiceWorker(){"none"!=WebPushr.swPath?navigator.serviceWorker.register(WebPushr.swPath,{scope:WebPushr.swScope}).then(function(e){_wp_debug&&console.log("Service worker has been registered successfully!"),WebPushr.promptWrapper=document.getElementById("webpushr-prompt-wrapper"),_webpushrCheckPermission()},e=>{console.log("Failed to register primary service worker, trying to register with alternative service worker"),navigator.serviceWorker.register("/webpushr-sw.js",{scope:"/"}).then(function(e){_wp_debug&&console.log("Alternative service worker has been registered successfully!"),WebPushr.promptWrapper=document.getElementById("webpushr-prompt-wrapper"),_webpushrCheckPermission()},e=>{console.error("[SW] Service worker registration failed",e),console.warn("Cannot access service worker file. Please confirm you have service worker file at "+WebPushr.swPath)})}):_webpushrCheckPermission()}function _webpushrCheckPermission(){if(localStorage.getItem("_webpushr")||localStorage.setItem("_webpushr",JSON.stringify({})),-1!=window.location.href.indexOf("http://")||"http"==WebPushr.integrationType)return _webpushrGetCookie("_webpushrSubscriberID")?(WebPushr.endpoint=_webpushrGetCookie("_webpushrSubscriberID"),_webpushrExecuteHooks(),"undefined"!=typeof _webpushrScriptReady&&"function"==typeof _webpushrScriptReady&&_webpushrScriptReady(),void _webpushrGetPrompt("bell").then(e=>{_webpushrShowSubscriptionBell(e,"granted")})):void _webpushrGetPrompt("get_info").then(e=>{_webpushrGetPromptDisplayTime(e)});"default"==Notification.permission?(_webpushrGetPrompt("get_info").then(e=>{_webpushrGetPromptDisplayTime(e)}),_webpushrSessionLogs("session_new_to_push")):"granted"==Notification.permission&&(_wp_debug&&console.log("User has previously granted push permission"),WebPushr.welcomeNotification=0,_webpushrSessionLogs("session_subscribed"),_wpCheckSubscription(),_webpushrGetPrompt("bell").then(e=>{_webpushrShowSubscriptionBell(e,"granted"),_webpushrShowEmailOptin(),_webpushrGetCookie("_webpushrTopicInterval")||_webpushrShowTopicPreferencesOptin()}))}async function _webpushrGetPrompt(e){const t=await fetch("https://bot.webpushr.com/prompt/"+e,{body:JSON.stringify({site_id:applicationServerKey,browser:WebPushr.userBrowser}),method:"POST"});return _wp_prompt_info=await t.json(),WebPushr.notificationCenter=_webpushrGetLocalStorage("notification_center"),_webpushrSetLocalStorage("notification_center",{...WebPushr.notificationCenter,enabled:_wp_prompt_info.notification_center}),WebPushr.notificationCenter={...WebPushr.notificationCenter,enabled:_wp_prompt_info.notification_center},WebPushr.notificationCard=_webpushrGetLocalStorage("notification_card"),_webpushrSetLocalStorage("notification_card",{...WebPushr.notificationCard,enabled:_wp_prompt_info.notification_card.enabled}),WebPushr.notificationCard={...WebPushr.notificationCard,enabled:_wp_prompt_info.notification_card.enabled},_wp_prompt_info}function _webpushrNotificationPermission(){_webpushrShowPrompt(_wp_prompt_info)}function _webpushrGetPromptDisplayTime(e){_webpushrShowNotificationCenter(),_webpushrRenderCard(),"Immediately"==e.show_prompt?(_wp_debug&&console.log("Show prompt immediately"),_webpushrShowPrompt(e)):"Visits"==e.show_prompt?(_wp_debug&&console.log("Show prompt after x page views",_webpushrGetCookie("_webpushrPageViews"),+e.page_views),_webpushrGetCookie("_webpushrPageViews")>=+e.page_views?_webpushrShowPrompt(e):_webpushrSetCookie("_webpushrPageViews",+_webpushrGetCookie("_webpushrPageViews")+1,90)):"Time"==e.show_prompt&&(_wp_debug&&console.log("Show prompt after x seconds"),WebPushr.promptDelay=setTimeout(function(){_webpushrShowPrompt(e)},1e3*e.time_delay))}function _webpushrShowNotificationCenter(){1==_wp_prompt_info.notification_center&&3!=_wp_prompt_info.display_position&&(WebPushr.promptWrapper.innerHTML=_wp_prompt_info.notification_center_code,document.getElementsByTagName("popup_notifications_wrapper")[0]&&1==WebPushr.notificationCenter.enabled&&WebPushr.notificationCenter.notification_id==document.getElementsByTagName("promptnotificationicon")[0].dataset.id&&(document.getElementsByTagName("promptnotificationicon")[0].style.display="none"),_webpushrBindBellEvent(),_webpushrNotificationTimeToLocal("#webpushr-bell-optin .notification_time"))}function _webpushrShowPrompt(e){sessionStorage.getItem("_webpushrPromptAction")||(1!=e.prompt_type||_wp_is_safari?_webpushrShowCustomPrompt(e):(_wp_debug&&console.log("Show native prompt"),_webpushrRequestPermission()))}function _webpushrShowCustomPrompt(e){if(_wp_debug&&console.log("Show custom prompt"),_webpushrGetCookie("_webpushrSubscriberID"))return;let t=JSON.parse(localStorage.getItem("_webpushrPromptAction")),o=new Date;if((!t||"Dismiss"==t.action&&t.expiry{var t=new Date(e.innerText+" UTC");diffInMinutes=Math.round((new Date(Date.now())-t)/6e4),diffInMinutes<1?e.innerText="Just now":diffInMinutes<60?e.innerText=diffInMinutes+" minute"+(diffInMinutes>1?"s":"")+" ago":diffInMinutes>59&&diffInMinutes<1440?e.innerText=Math.round(diffInMinutes/60)+" hour"+(Math.round(diffInMinutes/60)>1?"s":"")+" ago":e.innerText=Math.round(diffInMinutes/1440)+" day"+(Math.round(diffInMinutes/1440)>1?"s":"")+" ago"})}function _webpushrPermissionResetInstructions(){denied_image_ele=document.getElementById("webpushrDeniedImg"),denied_image_ele&&(WebPushr.promptWrapper.className="webpushr-subscribed webpushr-notification-denied")}function _webpushrPromptAction(e){_wp_debug&&console.log("Prompt action : "+e),sessionStorage.setItem("_webpushrPromptAction",e),_webpushrPromptImpressions(e),"function"==typeof webpushrPermissionAction&&webpushrPermissionAction(e);var t=document.querySelectorAll(".webpushr-subscription-topic");if(document.getElementById("webpushr-lightbox-optin")&&document.getElementById("webpushr-lightbox-optin").remove(),clearTimeout(WebPushr.promptDelay),"Dismiss"==e){let t=new Date;expiry=t.getTime()+24*_wp_prompt_info.re_show_prompt*60*60*1e3,localStorage.setItem("_webpushrPromptAction",JSON.stringify({action:e,expiry:expiry})),_webpushrShowEmailOptin()}if("Approve"==e){for(var o=0;o{window.intlTelInput(e,{separateDialCode:!0,initialCountry:e.dataset.defaultCountry})},6e3)}}}function _webpushrEmailAction(e){if(_wp_debug&&console.log("Email optin action : "+e),"Approve"==e){if(event.preventDefault(),email_input=document.getElementById("webpushr-optin-email"),email=email_input&&email_input.value,email_input){if(email_validation=!0,email&&!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)&&(email_validation=!1),email_input.dataset.required&&!email&&(email_validation=!1),0==email_validation)return document.getElementById("webpushr-prompt-error-text").style.display="block",email_input.style.borderColor="red",email_input.focus(),email_input.select(),!1;document.getElementById("webpushr-prompt-error-text").style.display="none",email_input.style.borderColor="#ced3d8"}if(phone_input=document.getElementById("webpushr-optin-phone"),phone=phone_input&&phone_input.value,phone_input){if(phone_validation=!0,phone&&!/^\d+$/.test(phone)&&(phone_validation=!1),phone_input&&phone_input.dataset.required&&!phone&&(phone_validation=!1),0==phone_validation)return document.getElementById("prompt-phone-error-text").style.display="block",phone_input.style.borderColor="red",phone_input.focus(),phone_input.select(),!1;document.getElementById("prompt-phone-error-text").style.display="none",phone_input.style.borderColor="#ced3d8",phone=document.querySelector(".webpushr-collect-phone .iti__selected-dial-code").innerText+phone}if(!email&&!phone)return void(document.getElementById("webpushr-email-optin")&&document.getElementById("webpushr-email-optin").remove());email&&_webpushrSetLocalStorage("email",email),phone&&_webpushrSetLocalStorage("phone",phone),_webpushrSendEmailToServer(email,phone)}else _webpushrSetCookie("_webpushrEmailAction",e,_wp_prompt_info.email_optin_reshow),document.getElementById("webpushr-email-optin")&&document.getElementById("webpushr-email-optin").remove()}function _webpushrSendEmailToServer(e,t){_wp_debug&&console.log("send email form to server"),document.getElementById("webpushr-email-optin-form").style.display="none",document.getElementById("webpushr-email-form-status").style.display="flex",_webpushrSetCookie("_webpushrEmailAction","Submitted",90);var o={endpoint:_webpushrGetLocalStorage("endpoint"),site_id:applicationServerKey,email:e,phone:t,timezone:(new Date).getTimezoneOffset()};fetch("https://bot.webpushr.com/subscribe/email",{body:JSON.stringify(o),method:"POST"}).then(e=>e.text()).then(function(e){document.getElementsByTagName("webpushrPromptConatiner")[0].className+=" Slide-in-reverse",setTimeout(()=>document.getElementById("webpushr-email-optin").remove(),7e3)})}function _webpushrAssignTopicsAsAttributes(){}function _webpushrToggleEditNotificationPopup(){document.getElementsByClassName("webpushr-notification-denied")[0]&&(denied_image_ele=document.getElementById("webpushrDeniedImg"),navigator.userAgent.match(/Android/i)?denied_image_ele.src="https://webpushrapp-3744.kxcdn.com/assets/images/mobile.gif":"safari"in window?denied_image_ele.src="https://webpushrapp-3744.kxcdn.com/assets/images/safari-reset.gif":denied_image_ele.src="https://webpushrapp-3744.kxcdn.com/assets/images/allow_notifications.001-min.png"),WebPushr.promptWrapper.classList.remove("webpushr-ackn","webpushr-server-success","webpushr-server-error"),document.getElementsByTagName("promptPopup")[0].classList.toggle("promptPopup-show"),document.getElementsByTagName("prompticon3")[0].classList.toggle("promptBellLarge"),void 0!==document.getElementsByTagName("promptnotificationicon")[0]&&(document.getElementsByTagName("promptnotificationicon")[0].style.display="none",document.getElementsByTagName("prompticon3")[0].removeAttribute("style"),webpushrNotificationImg=document.querySelectorAll(".webpushr-notification-img"),webpushrNotificationImg&&webpushrNotificationImg.forEach(e=>{e.dataset.src&&(e.src=e.dataset.src)}),WebPushr.notificationCenter=_webpushrGetLocalStorage("notification_center"),_webpushrSetLocalStorage("notification_center",{...WebPushr.notificationCenter,notification_id:document.getElementsByTagName("promptnotificationicon")[0].dataset.id}),WebPushr.notificationCenter={...WebPushr.notificationCenter,notification_id:document.getElementsByTagName("promptnotificationicon")[0].dataset.id})}function _webpushrTrunNotification(e,t,o=!0){t&&(t.className+=" webpushrBtnWaiting"),fetch("https://bot.webpushr.com/subscribe/status/"+e,{body:JSON.stringify({site_id:applicationServerKey,endpoint:WebPushr.endpoint}),method:"POST"},1e3).then(e=>e.json()).then(function(e){if("success"!=e.response)throw"failed";_webpushrSetLocalStorage("bell_notification",e.status),WebPushr.promptWrapper.className="webpushr-ackn webpushr-server-success webpushr-subscribed webpushr-notification-"+e.status,document.getElementsByClassName("webpushrBtnWaiting")[0].classList.remove("webpushrBtnWaiting"),o&&setTimeout(_webpushrToggleEditNotificationPopup,500)}).catch(e=>{WebPushr.promptWrapper.className="webpushr-ackn webpushr-subscribed webpushr-server-error"})}async function _wpCheckSubscription(){const e=await navigator.serviceWorker.ready.then(e=>e.pushManager.getSubscription());if(_wp_debug&&console.log("Check subscription",e),!e)return _wp_debug&&console.log("No previous subscription found"),WebPushr.silentSubscribed=1,_webpushrPromptImpressions("resubscribed"),void _webpushrRequestPermission();_wp_debug&&console.log("Previous subscription found");const t=await _webpushrSubscribeNow(e);return"false"!=t&&(_webpushrOldEndPoint=_webpushrGetLocalStorage("endpoint"),_webpushrOldEndPoint||(_webpushrSetLocalStorage("endpoint",e.endpoint),_webpushrSetCookie("_webpushrEndPoint",e.endpoint,90),_webpushrOldEndPoint=_webpushrGetLocalStorage("endpoint")),_webpushrGetCookie("_webpushrEndPoint")||_webpushrSetCookie("_webpushrEndPoint",e.endpoint,90),_webpushrOldEndPoint!=e.endpoint?(WebPushr.execute_hooks=!1,_wp_debug&&console.log("existing user, endpoint change detected, update subscription object and last visit in database & update new endpoint in local storage"),e.old_endpoint=_webpushrOldEndPoint,localStorage.removeItem("_webpushrCustomAttribute"),_webpushrSetLocalStorage("endpoint",e.endpoint),_webpushrSetCookie("_webpushrEndPoint",e.endpoint,90),_webpushrSetCookie("_webpushrLastVisit",today,3),_webpushrSendSubscriptionToServer(e,"PUT","update")):(_webpushrLastVisit=_webpushrGetCookie("_webpushrLastVisit"),_webpushrLastVisit?void 0:(_webpushrSetCookie("_webpushrLastVisit",today,3),_wp_debug&&console.log("Send last visit update request"),localStorage.removeItem("_webpushrCustomAttribute"),WebPushr.execute_hooks=!1,_webpushrSendSubscriptionToServer(e,"PUT"))))}function _webpushrRequestPermission(){Notification.requestPermission().then(e=>{switch(e){case"default":console.log("Permission unknown");break;case"denied":console.log("Permission denied"),"function"==typeof webpushrPermissionAction&&webpushrPermissionAction("denied"),WebPushr.subscriptionButton&&(WebPushr.subscriptionButton.style.display="none",document.getElementById("webpushr-subscriber-count")&&(document.getElementById("webpushr-subscriber-count").style.display="none")),_webpushrGetPrompt("bell").then(e=>{_webpushrShowSubscriptionBell(e,"denied")}),_webpushrPermissionResetInstructions();let t=document.getElementById("webpushrSubscriptionToggleButton");t&&(t.disabled=!0,t.checked=!1),_webpushrSendSubscriptionToServer("","DELETE"),_webpushrShowEmailOptin();break;case"granted":"function"==typeof webpushrPermissionAction&&webpushrPermissionAction("granted"),WebPushr.subscriptionButton&&(WebPushr.subscriptionButton.style.display="none",document.getElementById("webpushr-subscriber-count")&&(document.getElementById("webpushr-subscriber-count").style.display="none")),_webpushrGetPrompt("bell").then(e=>{_webpushrShowSubscriptionBell(e,"granted")}),_webpushrRemoveLocalStorage("bell_notification"),localStorage.removeItem("_webpushrPromptAction"),_webpushrSubscribeNow()}WebPushr.silentSubscribed||_webpushrPromptImpressions(e)}),1==_wp_prompt_info.prompt_type&&_webpushrShowEmailOptin()}function _webpushrSubscribeNow(e=null){return new Promise((t,o)=>{navigator.serviceWorker.ready.then(function(o){o.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:_wp_urlBase64ToUint8Array(applicationServerKey)}).then(o=>{WebPushr.endpoint=o.endpoint,null==e&&(_wp_debug&&console.log("New subscriber, store in localstorage and database"),localStorage.removeItem("_webpushrCustomAttribute"),_webpushrSetLocalStorage("endpoint",o.endpoint),_webpushrSetCookie("_webpushrEndPoint",o.endpoint,90),_webpushrSetCookie("_webpushrLastVisit",today,3),_webpushrSendSubscriptionToServer(o,"POST"),t("true")),_webpushrExecuteHooks(),"undefined"!=typeof _webpushrScriptReady&&"function"==typeof _webpushrScriptReady&&_webpushrScriptReady(),t("true")}).catch(o=>{e?e.unsubscribe().then(function(e){WebPushr.silentSubscribed=1,_webpushrPromptImpressions("transfer"),_webpushrRequestPermission(),t("false")}):(console.error(o),t(o))})})})}function _wp_urlBase64ToUint8Array(e){const t="=".repeat((4-e.length%4)%4),o=(e+t).replace(/\-/g,"+").replace(/_/g,"/"),i=window.atob(o),n=new Uint8Array(i.length);for(let e=0;e0?(WebPushr.subscriptionTopics.forEach(function(e,t,o){topic_attr="Topic: "+e,$attributes={...$attributes,[topic_attr]:"true"}}),publicMethods.attributes($attributes)):WebPushr.welcomeNotification||"POST"!=i.type||_webpushrShowTopicPreferencesOptin(),"undefined"!=typeof _webpushrScriptReady&&"function"==typeof _webpushrScriptReady&&_webpushrScriptReady(),_webpushrShowEmailOptin()})}function _webpushrPromptImpressions(e){e&&(data={status:e,site_id:applicationServerKey},fetch("https://analytics.webpushr.com/impression/prompt",{body:JSON.stringify(data),method:"POST"}).then(function(e){if(e.ok)return e.text()}))}function _webpushrNotificationCardLogs(e){(document.getElementsByClassName("promptPopup-show")[0]||"bell_opened"!=e)&&(data={status:e,site_id:applicationServerKey},fetch("https://analytics.webpushr.com/notification_card/"+e,{body:JSON.stringify(data),method:"POST"}).then(function(e){if(e.ok)return e.text()}).then(function(e){}))}function _webpushrSessionLogs(e){e&&(sessionStorage.getItem("_webpushrSessionLog")||(data={status:e,site_id:applicationServerKey},fetch("https://analytics.webpushr.com/impression/session",{body:JSON.stringify(data),method:"POST"}).then(function(e){if(e.ok)return e.text()}).then(function(e){sessionStorage.setItem("_webpushrSessionLog",data.status)})))}function _webpushrDisplayPrompt(){WebPushr.optin_text&&(WebPushr.optin_text.title&&(document.getElementById("webpushr-optin-title").innerHTML=WebPushr.optin_text.title),WebPushr.optin_text.body&&(document.getElementById("webpushr-optin-body").innerHTML=WebPushr.optin_text.body),WebPushr.optin_text.allow_button&&(document.getElementById("webpushr-approve-button").innerHTML=WebPushr.optin_text.allow_button),WebPushr.optin_text.dismiss_button&&(document.getElementById("webpushr-deny-button").innerHTML=WebPushr.optin_text.dismiss_button)),document.getElementById("_prompt_overlay").style.display="block",_webpushrPromptImpressions("custom_prompt")}function _webpushrCustomPromptEvents(e){elePromptLogo=document.getElementById("webpushr-prompt-logo"),elePromptLogo&&elePromptLogo.addEventListener("load",_webpushrDisplayPrompt(),!1),eleApproveBtn=document.getElementById("webpushr-approve-button"),eleApproveBtn&&eleApproveBtn.addEventListener("click",function(){_webpushrPromptAction("Approve")}),eleDenyBtn=document.getElementById("webpushr-deny-button"),eleDenyBtn&&eleDenyBtn.addEventListener("click",function(){_webpushrPromptAction("Dismiss")}),eleCookieInfo=document.getElementById("webpushr-cookie-info"),eleCookieInfo&&eleCookieInfo.addEventListener("click",function(){return document.getElementsByTagName("cookieDiscloser")[0].className="_showCookieDiscloser",document.getElementsByTagName("webpushrPromptConatiner")[0].className="_hideWebpushrPromptConatiner",!1}),eleCookieGoback=document.getElementById("webpushr-cookie-goback"),eleCookieGoback&&eleCookieGoback.addEventListener("click",function(){return document.getElementsByTagName("cookieDiscloser")[0].className="_hideCookieDiscloser",document.getElementsByTagName("webpushrPromptConatiner")[0].className="",!1}),eleClickinfoCookie=document.getElementById("webpushr-clickinfo-cookie"),eleClickinfoCookie&&eleClickinfoCookie.addEventListener("click",function(){return ele=document.getElementById("more-info-cookie"),ele.classList.contains("_showcookiemoreinfo")?(ele.classList.remove("_showcookiemoreinfo"),document.getElementById("webpushr-clickinfo-cookie").innerText="Show cookie info"):(ele.className+=" _showcookiemoreinfo",document.getElementById("webpushr-clickinfo-cookie").innerText="Hide cookie info"),!1}),eleCookieinfoData=document.getElementById("webpushr-cookieinfo-data"),eleCookieinfoData&&eleCookieinfoData.addEventListener("click",function(){return ele=document.getElementById("more-info-storage"),ele.classList.contains("_showcookiemoreinfo")?(ele.classList.remove("_showcookiemoreinfo"),document.getElementById("webpushr-cookieinfo-data").innerText="Show data info"):(ele.className+=" _showcookiemoreinfo",document.getElementById("webpushr-cookieinfo-data").innerText="Hide data info"),!1}),eleUpdateTopicsBtn=document.getElementById("webpushr-update-topics-preferences"),eleUpdateTopicsBtn&&eleUpdateTopicsBtn.addEventListener("click",function(){_webpushrUpdateTopicsPreferences()}),_webpushrBindBellEvent()}function _webpushrBindBellEvent(){eleBellPopup=document.querySelectorAll(".webpushr-toggle-bell-popup"),eleBellPopup&&eleBellPopup.forEach(e=>{e.addEventListener("click",function(){_webpushrToggleEditNotificationPopup()})}),webpushrUnknownBtn=document.getElementById("webpushrUnknownBtn"),webpushrUnknownBtn&&webpushrUnknownBtn.addEventListener("click",function(){_webpushrPromptAction("Approve"),_webpushrToggleEditNotificationPopup()}),webpushrOffBtn=document.getElementById("webpushrOffBtn"),webpushrOffBtn&&webpushrOffBtn.addEventListener("click",function(){_webpushrTrunNotification("on",webpushrOffBtn)}),webpushrOnBtn=document.getElementById("webpushrOnBtn"),webpushrOnBtn&&webpushrOnBtn.addEventListener("click",function(){_webpushrTrunNotification("off",webpushrOnBtn)}),document.querySelectorAll(".webpushr-notification").forEach(e=>e.addEventListener("click",function(){_webpushrNotificationCardLogs("bell_notification_clicked"),popup_notification_clicked(this)}))}function popup_notification_clicked(e){let t=e,o={type:"cl",campaign_id:t.dataset.id,server:t.dataset.server,sid:t.dataset.site};t.insertAdjacentHTML("beforeend",""),fetch("https://notevents.webpushr.com/notification/lg/",{body:JSON.stringify(o),method:"POST"}).then(function(e){window.location.href=t.dataset.url})}function _webpushrShowSubscriberCount(e){const t=sessionStorage.getItem("_webpushrSubscriberCount");WebPushr.subscriptionButton.insertAdjacentHTML("afterend",'
'+t+" "+(e||"Users already subscribed")+"
")}function webpushr_display_button(){if(WebPushr.subscriptionButton=document.getElementById("webpushr-subscription-button"),button_data=WebPushr.subscriptionButton.dataset,button_style=WebPushr.subscriptionButton.style,"default"!=Notification.permission)return button_style.display="none",!1 ;document.head.insertAdjacentHTML("beforeend",''),WebPushr.subscriptionButton.innerHTML=''+(button_data.buttonText?button_data.buttonText:"Subscribe to notifications")+"","false"!==button_data.showSubscriberCount&&(sessionStorage.getItem("_webpushrSubscriberCount")?_webpushrShowSubscriberCount(button_data.subscriberCountText):fetch("https://bot.webpushr.com/get_subscriber_count/",{body:JSON.stringify({site_id:applicationServerKey,time:Date.now()}),method:"POST"}).then(function(e){if(e.ok)return e.text()}).then(function(e){sessionStorage.setItem("_webpushrSubscriberCount",e),_webpushrShowSubscriberCount(button_data.subscriberCountText)}));for(const[e,t]of Object.entries(button_data))button_style[e]=t;button_data.color&&(document.getElementById("webpushr_btn_bell_icon").style.fill=button_data.color),WebPushr.subscriptionButton.addEventListener("click",_webpushrRequestPermission)}function webpushr_display_toggle_button(){let e=document.getElementById("webpushr-subscription-toggle-button"),t=e.dataset.color?e.dataset.color:"#2c7be5";document.head.insertAdjacentHTML("beforeend",'');let o="";"default"==Notification.permission?o="":"denied"==Notification.permission?o=" disabled ":"granted"==Notification.permission&&(o="off"==_webpushrGetLocalStorage("bell_notification")?"":" checked "),e.innerHTML="';let i=document.querySelector("#webpushr-subscription-toggle-button label"),n=document.getElementById("webpushrSubscriptionToggleButton");if(i.style.transform="scale("+e.dataset.size+")",e.style.width=i.getBoundingClientRect().width+"px",e.style.height=i.getBoundingClientRect().height+"px","default"==Notification.permission)n.addEventListener("click",_webpushrRequestPermission);else if("denied"==Notification.permission){e.innerHTML+=""+(e.dataset.textWhenDenied?e.dataset.textWhenDenied:"You've blocked push notifications.")+"";let t=document.querySelector("#webpushr-subscription-toggle-button tooltip"),o=document.querySelector("#webpushr-subscription-toggle-button label");t.dataset.position=e.dataset.tooltipPosition,"left"==e.dataset.tooltipPosition?(t.style.right=o.getBoundingClientRect().width+12+"px",t.style.top="calc(50% - "+t.getBoundingClientRect().height/2+"px)"):"top"==e.dataset.tooltipPosition?(t.style.bottom=o.getBoundingClientRect().height+12+"px",t.style.top="unset"):"bottom"==e.dataset.tooltipPosition?t.style.top=o.getBoundingClientRect().height+5+"px":(t.style.left=o.getBoundingClientRect().width+12+"px",t.style.top="calc(50% - "+t.getBoundingClientRect().height/2+"px)"),o.addEventListener("mouseover",function(e){t.className="webpushr-tooltip-active"}),o.addEventListener("mouseleave",function(e){t.className="webpushr-tooltip-inactive"})}else"granted"==Notification.permission&&n.addEventListener("click",function(){1==n.checked?(webpushrOffBtn=document.getElementById("webpushrOffBtn"),_webpushrTrunNotification("on",webpushrOffBtn,!1)):(webpushrOnBtn=document.getElementById("webpushrOnBtn"),_webpushrTrunNotification("off",webpushrOnBtn,!1)),n.disabled=!0})}function _webpushrUpdateTopicsPreferences(){var e=document.querySelectorAll(".webpushr-subscription-topic");WebPushr.subscriptionTopics=[];for(var t=0;t0?(WebPushr.subscriptionTopics.forEach(function(e,t,o){topic_attr="Topic: "+e,$attributes={...$attributes,[topic_attr]:"true"}}),publicMethods.attributes($attributes)):publicMethods.attributes({"Topic: ":"None"}),_webpushrSetCookie("_webpushrTopicInterval",1,_wp_prompt_info.re_show_preferences),document.getElementById("webpushr-lightbox-optin").remove()}function _webpushrShowTopicPreferencesOptin(e=5e3){_wp_prompt_info.topics&&setTimeout(function(){WebPushr.promptWrapper.innerHTML=_wp_prompt_info.topics;var e=document.querySelectorAll(".webpushr-subscription-topic");if(selected_topics=_webpushrGetLocalStorage("topics"),selected_topics.length>0)for(var t=0;t-1?"Firefox":"safari"in window?"Safari":"Chrome",integrationType:null,swScope:null,swPath:null,deviceToken:null,applePushID:null,endpoint:null,promptInfo:null,silentSubscribed:null,welcomeNotification:1,execute_hooks:!0,subscriptionButton:!1,promptDelay:0,optin_text:"",notificationCenter:"",notificationCard:"",subscriptionTopics:[],topicPreferences:!1,promptWrapper:""},d1=new Date;today=d1.getMonth()+1+"/"+d1.getDate()+"/"+d1.getFullYear()+" 00:00";var _wp_is_safari=!1,_wp_debug=!1,publicMethods={setup:function(e){publicMethods.init(e.key,e.sw,e.scope,e.integration)},init:function(e,t,o="/",i="https"){if(WebPushr.swScope=o,WebPushr.integrationType="popup"==i?"http":"https",!WebPushr.swPath)switch(prompt_wrapper=document.createElement("div"),prompt_wrapper.setAttribute("id","webpushr-prompt-wrapper"),document.body.appendChild(prompt_wrapper),WebPushr.promptWrapper=document.getElementById("webpushr-prompt-wrapper"),console.log("Web Push Notifications powered by Webpushr"),applicationServerKey=e,WebPushr.swPath=t||"/webpushr-sw.js",_webpushrBrowserSupport()){case!0:_wp_registerServiceWorker();break;case"http":_webpushrCheckPermission()}},uid:function(e){data={uid:e,sid:WebPushr.endpoint,site_id:applicationServerKey},fetch("https://bot.webpushr.com/subscribe/uid/",{body:JSON.stringify(data),method:"POST"})},event:function(e){return _wp_debug&&console.log("Run Webpushr Custom Event hook"),e.event_name?e.event_action?(data={...e,sid:WebPushr.endpoint,site_id:applicationServerKey},void fetch("https://bot.webpushr.com/logs/event/",{body:JSON.stringify(data),method:"POST"})):console.error("Webpushr event hook: event_action is required",e):console.error("Webpushr event hook: event_name is required",e)},attributes:function(e){if(_wp_debug&&console.log("Run Custom Attribute hook"),!e)return console.error("Webpushr attributes hook: minimum of 1 attribute is required",e);localStorage.getItem("_webpushrCustomAttribute")!=JSON.stringify(e)&&(_wp_debug&&console.log("Attribute cookie not found. Send fetch request now"),data={...e,sid:WebPushr.endpoint,site_id:applicationServerKey},fetch("https://bot.webpushr.com/subscribe/attributes/",{body:JSON.stringify(data),method:"POST"}).then(function(e){if(e.ok)return e.text()}).then(function(t){t&&localStorage.setItem("_webpushrCustomAttribute",JSON.stringify(e))}))},debug:function(e){console.log("Run dubug hook"),_wp_debug=!0},fetch_id:function(e){if(!WebPushr.endpoint||!applicationServerKey)return e(!1);data={sid:WebPushr.endpoint,site_id:applicationServerKey},fetch("https://bot.webpushr.com/subscribe/getId/",{body:JSON.stringify(data),method:"POST"}).then(function(e){if(e.ok)return e.text()}).then(function(t){e(t)})},optin:function(e){WebPushr.optin_text=e}};window.webpushr=function(){publicMethods[arguments[0]].apply(this,Array.prototype.slice.call(arguments,1))},_webpushrExecuteHooks("debug"),_webpushrExecuteHooks("setup"),_webpushrExecuteHooks("init"),_webpushrExecuteHooks("optin"),window.onmessage=function(e){void 0!==_wp_prompt_info&&void 0!==_wp_prompt_info.domain_label&&_wp_prompt_info.domain_label.toLowerCase()==e.origin&&(_webpushrSetCookie("_webpushrSubscriberID",e.data,365),WebPushr.promptWrapper&&WebPushr.promptWrapper.remove(),WebPushr.endpoint=e.data)},document.getElementById("webpushr-subscription-button")&&"Safari"!=WebPushr.userBrowser&&webpushr_display_button(),document.getElementById("webpushr-subscription-toggle-button")&&"Safari"!=WebPushr.userBrowser&&webpushr_display_toggle_button();