/*
 =======================================================================*\
|| ###################################################################### ||
|| # vBulletin 6.2.3
|| # ------------------------------------------------------------------ # ||
|| # Copyright 2000-2026 MH Sub I, LLC dba vBulletin. All Rights Reserved.  # ||
|| # This file may not be redistributed in whole or significant part.   # ||
|| # ----------------- VBULLETIN IS NOT FREE SOFTWARE ----------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html   # ||
|| ###################################################################### ||
\*========================================================================*/
vBulletin.precache(["confirm_disable_push_all","error","no_notification_permission","push_all_disabled"],[]);
vBulletin.ready("pushnotification").then(f=>function(g,d,l,x){function m(){q().then(a=>{if(a)return new Promise((c,b)=>{n({call:"/ajax/api/pushnotification/checkIfSubscriptionIsTracked",data:r(a),success(h,y,z){e(h.istracked)},api_error(h){}}).always(()=>{c()})});e(!1)}).catch(a=>{console.error("Error during push subscription check: ",a)}).finally(()=>{t.addClass("h-hide-imp");k.removeClass("h-hide-imp")})}function u(){return(new Promise(function(a,c){const b=Notification.requestPermission(function(h){a(h)});
b&&b.then(a,c)})).then(function(a){return"granted"!==a?Promise.reject("no_notification_permission"):a})}function p(a){a&&("string"===typeof a&&(a=[a]),l.error("error",...a))}function e(a){k.toggleClass("toggle",a)}const r=f.getPushSubscriptionPayload,q=f.getExistingSubscription,v=f.subscribeUserToPush,w=f.unsubscribeUserFromPush,n=d.AJAX;if("serviceWorker"in navigator&&"PushManager"in window){var t=g(".js-push-disabled"),k=g(".js-toggle-push-notification");d=g(".js-disable-push-all");k.offon("click",
a=>{const c=!k.hasClass("toggle");c?u().then(b=>v()).then(b=>e(c)).catch(b=>p(b)):w().then(b=>e(c)).catch(b=>p(b))});d.offon("click",a=>{l.openConfirmDialogSimple({title:"warning",message:["confirm_disable_push_all"],iconType:"warning",yesPhrase:"continue",noPhrase:"cancel",onClickYes:()=>{n({call:"/ajax/api/pushnotification/deleteAllSubscriptionRecordsForUser",success(c){e(!1);l.alert("success","push_all_disabled")}})}})});d=new BroadcastChannel("vb_push_settings");g(d).on("message",a=>{a=a.originalEvent;
a.origin==location.origin&&"kill"==(a.data||{}).type&&m()});m()}}(jQuery,vBulletin,vBulletin.dialogtools,vBulletin.phrase));
