1 2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5668140f-86f0-5ad4-b28a-5b45cacb4da2")}catch(e){}}(); 3import{s as e}from"./jsx-runtime-D4ePz0Hl.js";import{t}from"./react-BXH-GOAS.js";import{n}from"./i18next-BaeBzRnv.js";import{t as r}from"./utils-CjUr88hv.js";import{r as i}from"./dist-DaRpaGs2.js";import{a,d as o,m as s,n as c,o as l,p as u,r as d,t as f,u as p,v as m}from"./pushSubscription-vzO9AQ6U.js";import{i as h}from"./nectarPageBlock-Dhr05eLZ.js";import{t as g}from"./useIsLoggedIn-B87EngYs.js";var _=e(t(),1),v=()=>{let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(!1);return(0,_.useEffect)(()=>{if(typeof window>`u`)return;let e=async()=>{if(`serviceWorker`in navigator)try{t(await(s()?o():navigator.serviceWorker.getRegistration())??null)}catch(e){console.error(`Error getting service worker registration:`,e)}else console.warn(`Service Workers are not supported in this browser.`)},n=()=>{e()};return`serviceWorker`in navigator&&navigator.serviceWorker.addEventListener(`controllerchange`,n),e(),()=>{`serviceWorker`in navigator&&navigator.serviceWorker.removeEventListener(`controllerchange`,n)}},[]),(0,_.useEffect)(()=>{if(!e?.pushManager||!(`Notification`in window))return;let t=!1,n=async()=>{try{let n=await e.pushManager.getSubscription(),i=n&&await u(n);t||(r(!!(i&&Notification.permission===`granted`)),a(Notification.permission===`granted`))}catch{}};return n(),window.addEventListener(l,n),()=>{t=!0,window.removeEventListener(l,n)}},[e]),{isSubscribed:n,setIsSubscribed:r,requestPermission:()=>i?`granted`:(Notification.requestPermission().then(e=>e===`granted`?(a(!0),e):(a(!1),e)),`default`),subscribeToPush:async e=>await f(e),unsubscribeFromPush:async()=>{let e=await d();return r(!1),e},canSendPush:i}};function y(e=h.CommunityAppPushPrompt){let t=r(),o=g(),{subscribeToPush:s,unsubscribeFromPush:l,isSubscribed:u,canSendPush:d,setIsSubscribed:f}=v();async function _(){let r=p(),h=r?{...r,pageBlock:e}:void 0;if(!o)return i.error(n(`nav.push.enable.error`)),!1;if(u)try{return await m(async()=>{let e=await l();if(!e)return!1;let t=await a(e,h);return t?i.success(n(`nav.push.disable.success`)):i.error(n(`nav.push.disable.error`)),t})}catch{return i.error(n(`nav.push.disable.error`)),!1}if(!d){let e=await Notification.requestPermission();if(e!==`granted`)return e===`denied`&&i.error(n(`nav.push.enable.blocked`)),!1}try{return await m(async()=>{let e=await s(t.VAPID_PUBLIC_KEY);if(!e)return!1;let r=await c(e,h);return f(r),r?i.success(n(`nav.push.enable.success`)):i.error(n(`nav.push.enable.failed`)),r})}catch{return i.error(n(`nav.push.enable.failed`)),!1}}return{onEnable:_,isSubscribed:u}}export{y as t}; 4//# sourceMappingURL=useEnablePushNotification-BzyUZ8Er.js.map 5//# debugId=5668140f-86f0-5ad4-b28a-5b45cacb4da2
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.