   navigator.userAgent.match(/(iPad|iPhone).*Safari/)||function(){var e,t={firebase:{apiKey:"AIzaSyC7xCg9LEYqiDKkCBsjhMFg-MKTNakYuj8",authDomain:"web-alerts-1194.firebaseapp.com",databaseURL:"https://web-alerts-1194.firebaseio.com/",storageBucket:"gcm-demo-13f40.appspot.com",messagingSenderId:"370456186282"},CHANNEL:window.location.hostname,STORAGE_KEY:"uolPushNotification",LOG_PREFIX:"[NOTIFICATIONS] ",tags:["geral"],api:{subscribe:"https://push-webalert.conteudo.uol"},dependencies:["https://www.gstatic.com/firebasejs/5.10.1/firebase-app.js","https://www.gstatic.com/firebasejs/5.10.1/firebase-messaging.js","/manifest.json"],cachePriority:"",abTest:"",serviceWorker:"/service-worker.js?v1.2.0"};function n(){this.messaging=null,this.data=null}n.prototype.loadDependency=function(e,n){var o;console.info(t.LOG_PREFIX+"loading dependency: "+e),e.match(/\.css$/)?((o=document.createElement("link")).type="text/css",o.rel="stylesheet",o.href=e,document.createElement("img").src=e,n()):e.match(/\.js$/)?((o=document.createElement("script")).type="text/javascript",o.src=e,o.onload=n):e.match(/\.json$/)?(o=document.createElement("link"),document.location.pathname.match("^/resumo/?$")&&(e=document.location.pathname.match(/\/\w+/)[0]+e),o.rel="manifest",o.href=e,document.createElement("img").src=e,n()):(console.warn("invalid file: "+e),n()),o&&document.getElementsByTagName("head")[0].appendChild(o)},n.prototype.loadDependencies=function(e,t){var o=e.shift();null!=o?this.loadDependency(o,function(){n.prototype.loadDependencies(e,t)}):t instanceof Function&&t()},n.prototype.request=function(e,t,n,o){for(var i=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}],r=!1,a=0;a<i.length;a++){try{r=i[a]()}catch(e){continue}break}r.open(t||"GET",e),r.onload=function(){4===r.readyState&&(200===r.status||201===r.status?o instanceof Function&&o.call(null,r.response,r.status):(console.warn("Request error"),o instanceof Function&&o(null,r.status)))},r.onerror=function(){o instanceof Function&&o.call(null,r.response,r.status),console.warn("Request error")},r.setRequestHeader("Pragma","no-cache"),r.setRequestHeader("Cache-Control","no-cache"),"POST"!=t&&"PUT"!=t&&"DELETE"!=t||(r.setRequestHeader("Content-type","application/json"),n=JSON.stringify(n)),r.send(n||null)},n.prototype.slug=function(e){e=(e=e.replace(/^\s+|\s+$/g,"")).toLowerCase();for(var t="ãàáäâẽèéëêìíïîõòóöôùúüûñç·/_,:;",n=0,o=t.length;n<o;n++)e=e.replace(new RegExp(t.charAt(n),"g"),"aaaaaeeeeeiiiiooooouuuunc------".charAt(n));return e=e.replace(/[^a-z0-9 -]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-")},n.prototype.getBrowserVersion=function(){var e,t=navigator.userAgent,n=t.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];return/trident/i.test(n[1])?"IE "+((e=/\brv[ :]+(\d+)/g.exec(t)||[])[1]||""):"Chrome"===n[1]&&null!==(e=t.match(/\bOPR\/(\d+)/))?"Opera "+e[1]:(n=n[2]?[n[1],n[2]]:[navigator.appName,navigator.appVersion,"-?"],null!==(e=t.match(/version\/([.\d]+)/i))&&n.splice(1,1,e[1]),n.join(" "))},n.prototype.setStorage=function(e){if(!e)return!1;localStorage.setItem(t.STORAGE_KEY,JSON.stringify(e))},n.prototype.getStorage=function(){return JSON.parse(localStorage.getItem(t.STORAGE_KEY))||{}},n.prototype.getInitialData=function(e){var n="pc";return this.isMobile.any()&&this.isMobile.any().length>0&&(n=this.isMobile.any()[0].toLowerCase()),e({channel:t.CHANNEL,platform:{ismobile:!!this.isMobile.any(),device:n,browser:this.getBrowserVersion()},configs:{tags:t.tags}})},n.prototype.postData=function(n,o){this.request(t.api.subscribe+"/subscribe","POST",n,function(){e.setStorage(n),o instanceof Function&&o.call(null,n)})},n.prototype.putData=function(n,o){e.request(t.api.subscribe+"/subscribe?id="+n.subscriptionID,"PUT",n,function(){e.setStorage(n),o instanceof Function&&o(n)})},n.prototype.unsetData=function(e,n){localStorage.removeItem(t.STORAGE_KEY),this.request(t.api.subscribe+"/subscribe?id="+e,"DELETE",{id:e},function(e,t){n instanceof Function&&n(e,t)})},n.prototype.isMobile={Android:function(){return navigator.userAgent.match(/Android/i)},BlackBerry:function(){return navigator.userAgent.match(/BlackBerry/i)},iOS:function(){return navigator.userAgent.match(/iPhone|iPad|iPod/i)},Opera:function(){return navigator.userAgent.match(/Opera Mini/i)},Windows:function(){return navigator.userAgent.match(/IEMobile/i)||navigator.userAgent.match(/WPDesktop/i)},any:function(){return this.Android()||this.BlackBerry()||this.iOS()||this.Opera()||this.Windows()}},n.prototype.sendToApi=function(n,o){this.getInitialData(function(i){var r=document.cookie.match(new RegExp("(^| )_ga=([^;]+)"));i.subscriptionID=n,i.gaID=r&&r[2],e.postData(i,function(){console.info(t.LOG_PREFIX+"Subscription successful!"),console.info(t.LOG_PREFIX,i),o instanceof Function&&o(!0)})})},n.prototype.startUI=function(){this.messaging.getToken().then(function(n){n?(e.sendTokenToServer(n),localStorage.setItem(t.STORAGE_KEY+"FirstEnable",!0)):(console.info(t.LOG_PREFIX+"No Instance ID token available. Request permission to generate one."),e.requestPermission(),e.setTokenSentToServer(!1))}).catch(function(t){e.setTokenSentToServer(!1)})},n.prototype.sendTokenToServer=function(n){var o=t.LOG_PREFIX+"Notification token already sent to server so won't send it again unless it changes";e.data.subscriptionID===n&&e.isTokenSentToServer()?(console.info(o),e.sendGaToServer(),e.checkUpdate()):(console.info(t.LOG_PREFIX+"Sending token to server..."),e.data&&e.data.subscriptionID?e.data.subscriptionID!=n?e.unsetData(e.data.subscriptionID,function(){e.sendToApi(n,e.setTokenSentToServer)}):(console.info(o),e.setTokenSentToServer(!0)):e.sendToApi(n,e.setTokenSentToServer))},n.prototype.checkUpdate=function(n){var o=(((e.data||{}).configs||{}).tags||[]).slice(0);if(o){for(var i=!0,r=n||t.tags,a=r.length;a--;)-1==o.indexOf(r[a])&&(o.push(r[a]),i=!1);i||(e.data.configs.tags=o,e.putData(e.data,function(){console.info(t.LOG_PREFIX+"Theme preferences have been updated")}))}},n.prototype.isTokenSentToServer=function(){return 1==window.localStorage.getItem(t.STORAGE_KEY+"sentToServer")},n.prototype.sendGaToServer=function(){var n=window.localStorage.getItem(t.STORAGE_KEY);try{n=JSON.parse(n)}catch(e){n={}}var o=document.cookie.match(new RegExp("(^| )_ga=([^;]+)")),i=o&&o[2];return!(!i||n.gaID==i)&&(console.info(t.LOG_PREFIX+"defining/updating GA ID."),n.gaID=i,e.putData({subscriptionID:n.subscriptionID,gaID:n.gaID},function(){window.localStorage.setItem(t.STORAGE_KEY,JSON.stringify(n)),console.info(t.LOG_PREFIX+"gaID has been sent to server.")}),!0)},n.prototype.setTokenSentToServer=function(e){e?window.localStorage.setItem(t.STORAGE_KEY+"sentToServer",1):window.localStorage.setItem(t.STORAGE_KEY+"sentToServer",0)},n.prototype.requestPermission=function(){console.info(t.LOG_PREFIX+"Requesting permission..."),Notification.requestPermission().then(function(n){switch(n){case"denied":case"default":console.info(t.LOG_PREFIX+"Permission wasn't granted: ",n),e.getInitialData(function(n){e.request(t.api.subscribe+"/blocked","POST",{channel:n.channel,platform:{ismobile:!!n.platform.ismobile}})});break;default:console.info(t.LOG_PREFIX+"Notification permission granted."),e.startUI()}})},n.prototype.deleteToken=function(){e.messaging.getToken().then(function(n){e.messaging.deleteToken(n).then(function(){console.info(t.LOG_PREFIX+"Token deleted from FCM."),e.unsetData(n,function(){console.info(t.LOG_PREFIX+"Token deleted FROM API UOL")}),e.setTokenSentToServer(!1)}).catch(function(e){console.warn(t.LOG_PREFIX+"Unable to delete token. ",e)})}).catch(function(e){console.warn(t.LOG_PREFIX+"Error retrieving Instance ID token. ",e)})},n.prototype.binds=function(){e.messaging.onTokenRefresh(function(){e.messaging.getToken().then(function(n){console.info(t.LOG_PREFIX+"Token refreshed."),e.setTokenSentToServer(!1),e.sendTokenToServer(n),e.startUI()}).catch(function(e){console.warn(t.LOG_PREFIX+"Unable to retrieve refreshed token ",e)})})},n.prototype.init=function(){if("serviceWorker"in navigator==!1||"localStorage"in window==!1||"Notification"in window==!1)return!1;e=this,this.loadDependencies(t.dependencies,function(){console.info(t.LOG_PREFIX+"dependencies ready."),firebase.initializeApp(t.firebase),e.messaging=firebase.messaging();var n=function(n){navigator.serviceWorker.register(t.serviceWorker).then(function(t){n||(e.messaging.useServiceWorker(t),e.binds(),e.startUI())})};if(e.widget=document.querySelector(".uol-notifications-widget"),navigator.serviceWorker.getRegistrations().then(function(e){for(var t in e)if(e.hasOwnProperty(t)){var n=e[t];if(n.active.scriptURL.indexOf(".bol.uol.com.br/service-worker.js")>-1)continue;n.active.scriptURL.indexOf(".bol.uol.com.br/service/?loadComponent")>-1&&n.unregister()}}),e.widget){if(e.widget.getAttribute("channel-name")&&(t.CHANNEL=e.widget.getAttribute("channel-name")),e.widget.getAttribute("themes")&&(t.tags=e.widget.getAttribute("themes").split(",")),e.widget.getAttribute("service-worker-path")&&(t.serviceWorker=e.widget.getAttribute("service-worker-path")),e.widget.getAttribute("configpath")&&(t.serviceWorker+="&configpath="+e.widget.getAttribute("configpath")),e.widget.getAttribute("cachePriority")&&(t.cachePriority=e.widget.getAttribute("cachePriority"),t.abTest=e.widget.getAttribute("abTest")||"",t.serviceWorker+="&cachePriority="+encodeURI(t.cachePriority)+t.abTest),e.data=e.getStorage(),e.data&&!localStorage.getItem(t.STORAGE_KEY+"FirstEnable"))return void navigator.serviceWorker.getRegistration().then(function(t){t&&t.unregister(),e.data&&e.data.subscriptionID&&e.unsetData(e.data.subscriptionID),n(!e.widget.getAttribute("themes"))});n(!e.widget.getAttribute("themes"))}else n(!0)})},"undefined"!=typeof hevents?hevents.on("htmlReady",function(){(new n).init()}):(new n).init()}();   