Files
owncast/static/web/_next/static/chunks/8253.5acaa79726badce3.js
2024-10-04 21:40:36 +00:00

1 line
8.6 KiB
JavaScript
Vendored

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8253],{8253:function(e,t,i){"use strict";i.r(t),i.d(t,{BrowserNotifyModal:function(){return C}});var n=i(85893),r=i(23657),o=i(56469),s=i(93879),a=i(10227),l=i(67294),c=i(61337),d=i(99677),u=i(4480),f=i(4511),h=i(28049);async function p(e,t,i){console.log("saveNotificationRegistration");let n={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channel:e,destination:t})};await fetch("".concat("/api/notifications/register","?accessToken=").concat(i),n)}async function w(e){let t=await navigator.serviceWorker.ready,i=await t.pushManager.getSubscription();return i||(i=await t.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:function(e){let t="=".repeat((4-e.length%4)%4),i=(e+t).replace(/-/g,"+").replace(/_/g,"/"),n=window.atob(i),r=new Uint8Array(n.length);for(let e=0;e<n.length;++e)r[e]=n.charCodeAt(e);return r}(e)})),JSON.stringify(i)}var v=i(38355),j=i.n(v),y=i(69583),b=i(30651),g=i(65146);let{Title:x}=r.default,m=()=>(0,n.jsx)("div",{children:"Browser notifications are not supported in your browser."}),_=()=>(0,n.jsx)("div",{children:"Browser notifications are not supported for local servers."}),N=()=>(0,n.jsxs)("div",{children:[(0,n.jsx)(x,{level:3,children:"Get notified on iOS"}),"It takes a couple extra steps to make sure you get notified when your favorite streams go live.",(0,n.jsxs)("ol",{children:[(0,n.jsxs)("li",{children:["Tap the ",(0,n.jsx)("strong",{children:"share"})," button ",(0,n.jsx)(c.default,{})," in Safari."]}),(0,n.jsxs)("li",{children:["Scroll down and tap ",(0,n.jsx)("strong",{children:"“Add to Home Screen”"})," ",(0,n.jsx)(d.Z,{}),"."]}),(0,n.jsxs)("li",{children:["Tap ",(0,n.jsx)("strong",{children:"“Add”"}),"."]}),(0,n.jsx)("li",{children:"Give this link a name and tap the new icon on your home screen"}),(0,n.jsx)("li",{children:"Come back to this screen and enable notifications."}),(0,n.jsxs)("li",{children:["Tap ",(0,n.jsx)("strong",{children:"“Allow”"})," when prompted."]})]})]}),M=e=>{let{start:t}=e;return(0,n.jsx)("div",{id:"browser-push-preview-box",className:j().pushPreview,children:(0,n.jsxs)("div",{className:j().inner,children:[(0,n.jsxs)("div",{className:j().title,children:[window.location.toString()," wants to"]}),(0,n.jsxs)("div",{className:j().permissionLine,children:[(0,n.jsx)("svg",{className:j().bell,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,n.jsx)("path",{d:"M14 12.3333V13H2V12.3333L3.33333 11V7C3.33333 4.93333 4.68667 3.11333 6.66667 2.52667C6.66667 2.46 6.66667 2.4 6.66667 2.33333C6.66667 1.97971 6.80714 1.64057 7.05719 1.39052C7.30724 1.14048 7.64638 1 8 1C8.35362 1 8.69276 1.14048 8.94281 1.39052C9.19286 1.64057 9.33333 1.97971 9.33333 2.33333C9.33333 2.4 9.33333 2.46 9.33333 2.52667C11.3133 3.11333 12.6667 4.93333 12.6667 7V11L14 12.3333ZM9.33333 13.6667C9.33333 14.0203 9.19286 14.3594 8.94281 14.6095C8.69276 14.8595 8.35362 15 8 15C7.64638 15 7.30724 14.8595 7.05719 14.6095C6.80714 14.3594 6.66667 14.0203 6.66667 13.6667",fill:"#676670"})}),(0,n.jsx)("span",{className:j().showNotificationsText,children:"Show notifications"})]}),(0,n.jsxs)("div",{className:j().buttonRow,children:[(0,n.jsx)(o.Z,{type:"primary",onClick:()=>{t()},children:"Allow"}),(0,n.jsx)("button",{type:"button",className:j().disabled,children:"Block"})]})]})})},O=()=>(0,n.jsxs)("div",{children:[(0,n.jsx)(x,{level:2,children:"Notifications are enabled"}),"To disable push notifications from ",window.location.hostname.toString()," access your browser permissions for this site and turn off notifications.",(0,n.jsx)("a",{href:"https://owncast.online/docs/notifications",children:" Learn more."})]}),k=()=>(0,n.jsxs)("div",{children:[(0,n.jsx)(x,{level:2,children:"Notifications are blocked on your device"}),"To enable push notifications from ",window.location.hostname.toString()," access your browser permissions for this site and turn on notifications. Then reload this page to apply your updated settings on this site.",(0,n.jsx)("a",{href:"https://owncast.online/docs/notifications",children:" Learn more."})]}),C=()=>{let[e,t]=(0,l.useState)(null),i=(0,u.sJ)(h.FI),r=(0,u.sJ)(h.g1),[o,c]=(0,l.useState)(!1),d=(0,g.w)()&&"granted"===Notification.permission,v=(0,g.w)()&&"denied"===Notification.permission,{notifications:x}=r,{browser:C}=x,{publicKey:B}=C,P=C.enabled&&((0,g.w)()||(0,b.rZ)());if(d)return(0,n.jsx)(O,{});if(v)return(0,n.jsx)(k,{});if((0,b.C9)()&&!(0,b.rZ)())return(0,n.jsx)(N,{});let S=async()=>{if(!(0,g.w)()||"default"===Notification.permission){c(!0);try{let e=await w(B);p("BROWSER_PUSH_NOTIFICATION",e,i),t(null)}catch(e){t("Error registering for live notifications: ".concat(e.message,". Make sure you're not inside a private browser environment or have previously disabled notifications for this stream."))}c(!1)}};return"localhost"===window.location.hostname?(0,n.jsx)(_,{}):P?(0,n.jsx)(f.SV,{fallbackRender:e=>{let{error:t,resetErrorBoundary:i}=e;return(0,n.jsx)(y.A,{componentName:"BrowserNotifyModal",message:t.message,retryFunction:i})},children:(0,n.jsxs)(s.Z,{spinning:o,children:[(0,n.jsxs)(a.Z,{className:j().description,children:["Get notified right in the browser each time this stream goes live.",(0,n.jsxs)("span",{children:[(0,n.jsx)("a",{href:"https://owncast.online/docs/notifications/#browser-notifications",children:"Learn more"}),"\xa0 about Owncast browser notifications."]})]}),(0,n.jsx)(a.Z,{children:e}),(0,n.jsx)(M,{start:()=>S()})]})}):(0,n.jsx)(m,{})}},72285:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M328 544h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8z"}},{tag:"path",attrs:{d:"M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z"}}]},name:"plus-square",theme:"outlined"}},81640:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M400 317.7h73.9V656c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V317.7H624c6.7 0 10.4-7.7 6.3-12.9L518.3 163a8 8 0 00-12.6 0l-112 141.7c-4.1 5.3-.4 13 6.3 13zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z"}}]},name:"upload",theme:"outlined"}},99677:function(e,t,i){"use strict";var n=i(64836),r=i(18698);t.Z=void 0;var o=n(i(42122)),s=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=r(e)&&"function"!=typeof e)return{default:e};var i=c(void 0);if(i&&i.has(e))return i.get(e);var n={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if("default"!==s&&({}).hasOwnProperty.call(e,s)){var a=o?Object.getOwnPropertyDescriptor(e,s):null;a&&(a.get||a.set)?Object.defineProperty(n,s,a):n[s]=e[s]}return n.default=e,i&&i.set(e,n),n}(i(67294)),a=n(i(72285)),l=n(i(3247));function c(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(c=function(e){return e?i:t})(e)}var d=s.forwardRef(function(e,t){return s.createElement(l.default,(0,o.default)((0,o.default)({},e),{},{ref:t,icon:a.default}))});t.Z=d},61337:function(e,t,i){"use strict";var n=i(64836),r=i(18698);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=n(i(42122)),s=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=r(e)&&"function"!=typeof e)return{default:e};var i=c(void 0);if(i&&i.has(e))return i.get(e);var n={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if("default"!==s&&({}).hasOwnProperty.call(e,s)){var a=o?Object.getOwnPropertyDescriptor(e,s):null;a&&(a.get||a.set)?Object.defineProperty(n,s,a):n[s]=e[s]}return n.default=e,i&&i.set(e,n),n}(i(67294)),a=n(i(81640)),l=n(i(3247));function c(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(c=function(e){return e?i:t})(e)}var d=s.forwardRef(function(e,t){return s.createElement(l.default,(0,o.default)((0,o.default)({},e),{},{ref:t,icon:a.default}))});t.default=d},38355:function(e){e.exports={description:"BrowserNotifyModal_description__G5jk5",pushPreview:"BrowserNotifyModal_pushPreview__RuEzl",inner:"BrowserNotifyModal_inner__iC07B",title:"BrowserNotifyModal_title__L6D4G",permissionLine:"BrowserNotifyModal_permissionLine__C7NWu",bell:"BrowserNotifyModal_bell__7LVGs",buttonRow:"BrowserNotifyModal_buttonRow__XcR9z",disabled:"BrowserNotifyModal_disabled__yqYtE"}}}]);