PageSourceSearch

https://receiterapia.com.br/wp-content/plugins/ai-web-push/js/ai-web-push-front.js

js receiterapia.com.br collected 2026-10-06 04:42:37 UTC 16,448 bytes, 1 lines download raw bytes

1"use strict";var __awaiter=this&&this.__awaiter||function(e,t,i,o){return new(i||(i=Promise))((function(n,s){function r(e){try{c(o.next(e))}catch(e){s(e)}}function a(e){try{c(o.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}c((o=o.apply(e,t||[])).next())}))};class AiWebPushFront{constructor(){this.firebaseConfig={apiKey:"AIzaSyCKel2XR-ZwR8tOxe1ytpmmbL_1AcfhsnQ",authDomain:"web-push-f5c68.firebaseapp.com",projectId:"web-push-f5c68",storageBucket:"web-push-f5c68.appspot.com",messagingSenderId:"33358057564",appId:"1:33358057564:web:ba785510e2df65c3d79699",measurementId:"G-CGMR7PPZGC"},this.scrollTriggered=!1,this.scrollListener=null,this.eventListeners={},this.currentSource="native_prompt"}on(e,t){this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(t)}off(e,t){const i=this.eventListeners[e];i&&(this.eventListeners[e]=i.filter((e=>e!==t)))}isDebug(){try{return"true"===localStorage.getItem("ai-web-push-debug")}catch(e){return!1}}isNotificationSupported(){return"undefined"!=typeof Notification}isMetaWebView(){const e=navigator.userAgent||"";return/(FBAN|FBAV|FB_IAB|Instagram|Messenger)/i.test(e)}isAndroidDevice(){return/Android/i.test(navigator.userAgent||"")}isLikelyPushUnsupportedContext(){const e=this.isNotificationSupported(),t="undefined"!=typeof navigator&&"serviceWorker"in navigator,i="undefined"!=typeof window&&!!window.isSecureContext;return!e||!t||!i}maybeShowWebViewExitPromptOnLoad(){if(!AI_WEB_PUSH_WEBVIEW_META_EXIT)return!1;const e="undefined"==typeof AI_WEB_PUSH_WEBVIEW_META_SHOW_MODAL||!!AI_WEB_PUSH_WEBVIEW_META_SHOW_MODAL,t="undefined"!=typeof AI_WEB_PUSH_WEBVIEW_META_AUTO_OPEN&&!!AI_WEB_PUSH_WEBVIEW_META_AUTO_OPEN;if(!e&&!t)return!1;const i=this.isMetaWebView(),o=this.isLikelyPushUnsupportedContext();return!(!i&&!o)&&(t&&i&&this.isAndroidDevice()?(this.tryAutoOpenExternally(e),!0):!!e&&(this.renderWebViewExitModal(),!0))}tryAutoOpenExternally(e){const t=window.location.href;this.emit("webview_exit_auto_attempt",{source:"webview_exit"});if(!this.tryOpenWithAndroidIntent(t,"auto"))return this.emit("webview_exit_auto_failed",{source:"webview_exit"}),void(e&&this.renderWebViewExitModal());setTimeout((()=>
1{"visible"===document.visibilityState?(this.emit("webview_exit_auto_failed",{source:"webview_exit"}),e&&this.renderWebViewExitModal()):this.emit("webview_exit_auto_success",{source:"webview_exit"})}),900)}renderWebViewExitModal(){if(document.getElementById("aiWebPushWebviewExitModal"))return;const e=AI_WEB_PUSH_WEBVIEW_META_TITLE||"Abra no navegador para continuar",t=AI_WEB_PUSH_WEBVIEW_META_MESSAGE||"Para continuar lendo esse contéudo, abra esta página no navegador.",i=AI_WEB_PUSH_WEBVIEW_META_OPEN_BUTTON||"Abrir no navegador",o='<div id="aiWebPushWebviewExitModal" style="position:fixed;inset:0;z-index:2147483647;background:rgba(0,0,0,0.8);display:flex;align-items:center;justify-content:center;padding:20px;box-sizing:border-box;">  <div style="position:relative;width:100%;max-width:420px;background:#fff;border-radius:14px;padding:24px;box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,\'Segoe UI\',Roboto,Ubuntu,sans-serif;text-align:center;">'+(AI_WEB_PUSH_WEBVIEW_META_SHOW_CLOSE_BUTTON?'<button id="aiWebPushWebviewCloseButton" type="button" aria-label="Fechar" style="position:absolute;top:8px;right:8px;width:28px;height:28px;border:none;border-radius:50%;background:transparent;color:#555;font-size:22px;line-height:1;cursor:pointer;">&times;</button>':"")+'    <h3 style="margin:0 0 12px;font-size:22px;line-height:1.3;color:#101010;">'+e+'</h3>    <p style="margin:0 0 18px;font-size:15px;line-height:1.5;color:#333;">'+t+'</p>    <button id="aiWebPushWebviewOpenButton" type="button" style="width:100%;padding:12px 16px;background:#554FFF;color:#fff;border:none;border-radius:10px;font-size:15px;font-weight:600;cursor:pointer;">'+i+'</button>    <p id="aiWebPushWebviewExitHint" style="display:none;margin:14px 0 0;font-size:13px;line-height:1.5;color:#666;">Não foi possível abrir automaticamente. Use o menu do aplicativo e escolha abrir no navegador.</p>  </div></div>';document.body.insertAdjacentHTML("beforeend",o),this.emit("webview_exit_prompt_shown",{source:"webview_exit"});const n=document.getElementById("aiWebPushWebviewOpenButton");n&&n.addEventListener("click",(()=>{this.tryOpenCurrentUrlExternally()}));const s=document.getElementById("aiWebPushWebviewCloseButton");s&&s.addEventListener("click",(()=>{this.closeWebViewExitModal()}))}closeWebViewExitModal(){const e=document.getElementById("aiWebPushWebviewExitModal");e&&e.remove(),this.emit("webview_exit_dismissed",{source:"webview_exit"})}buildIntentUrl(e){try{const t=new URL(e),i=t.protocol.replace(":","")||"https",o=(t.pathname||"/")+(t.search||"")+(t.hash||"");return"intent://"+t.host+o+"#Intent;scheme="+i+";package=com.android.chrome;S.browser_fallback_url="+encodeURIComponent(e)+";end"}catch(e){return null}}tryOpenWithAndroidIntent(e,t){if(!this.isAndroidDevice()||!this.isMetaWebView())return!1;const i=this.buildIntentUrl(e);return!!i&&("click"===t&&this.emit("webview_exit_intent_attempt",{source:"webview_exit"}),window.location.href=i,!0)}tryOpenWithWindowOpen(e){try{return!!window.open(e,"_blank","noopener,noreferrer")}catch(e){return!1}}tryOpenWithAnchor(e){try{const t=document.createElement("a");return t.href=e,t.target="_blank",t.rel="noopener noreferrer",t.style.display="none",document.body.appendChild(t),t.click(),t.remove(),!0}catch(e){return!1}}showWebviewManualFallback(e){return __awaiter(this,void 0,void 0,(function*(){const t=document.getElementById("aiWebPushWebviewExitHint");if(!t)return;let i="Não foi possível abrir automaticamente. Use o menu do aplicativo e escolha abrir no navegador.";try{navigator.clipboard&&window.isSecureContext&&(yield navigator.clipboard.writeText(e),i="Não foi possível abrir automaticamente. O link foi copiado: cole no navegador.")}catch(e){}t.textContent=i,t.style.display="block"}))}tryOpenCurrentUrlExternally(){const e=window.location.href;if(this.tryOpenWithAndroidIntent(e,"click"))return void setTimeout((()=>__awaiter(this,void 0,void 0,(function*(){if("visible"===document.visibilityState){const t=this.tryOpenWithWindowOpen(e),i=!t&&this.tryOpenWithAnchor(e);if(t||i)return void this.emit("webview_exit_open_external_success",{source:"webview_exit"});
1this.emit("webview_exit_open_external_failed",{source:"webview_exit"}),yield this.showWebviewManualFallback(e)}}))),900);const t=this.tryOpenWithWindowOpen(e),i=!t&&this.tryOpenWithAnchor(e);t||i?this.emit("webview_exit_open_external_success",{source:"webview_exit"}):(this.emit("webview_exit_open_external_failed",{source:"webview_exit"}),this.showWebviewManualFallback(e))}emit(e,t={}){this.isDebug()&&(console.groupCollapsed("%c[AI Web Push]%c "+e,"background:#554FFF;color:#fff;padding:2px 6px;border-radius:3px;font-weight:bold","color:#554FFF;font-weight:bold"),console.log("Detail:",t),console.log("dataLayer push:",{event:"ai_web_push_"+e,push_provider:"ai_web_push",push_source:t.source||""}),console.log("Timestamp:",(new Date).toISOString()),console.groupEnd());const i=this.eventListeners[e];i&&i.forEach((e=>{try{e(t)}catch(e){}}))}init(e=!1){if(this.currentSource="native_prompt",!this.isNotificationSupported())return void this.emit("browser_not_supported",{source:this.currentSource});if("granted"==Notification.permission)return void this.setupForegroundMessaging();if("denied"==Notification.permission)return;const t=localStorage.getItem("ai-web-push-modal");if(t){const e=JSON.parse(t);if("canceled"===e.value){const t=864e5;if(Date.now()-e.timestamp<t)return}if("accepted"===e.value)return}const i=this.getBrowserName();"serviceWorker"in navigator&&navigator.serviceWorker.register(AI_WEB_PUSH_SERVICE_WORKER_PATH+"firebase-messaging-sw.js",{scope:AI_WEB_PUSH_SERVICE_WORKER_PATH+"firebase-cloud-messaging-push-scope"}).then((t=>{navigator.serviceWorker.register(AI_WEB_PUSH_SERVICE_WORKER_PATH+"firebase-messaging-sw.js",{scope:AI_WEB_PUSH_SERVICE_WORKER_PATH}).then((t=>{AI_WEB_PUSH_SCROLL_TRIGGER_ENABLED&&AI_WEB_PUSH_SCROLL_PERCENTAGE>0&&!e?this.setupScrollTrigger():AI_WEB_PUSH_ALWAYS_SHOW_MODAL||["firefox","edge"].includes(i)?this.renderPushNotificationModal():this.askPermission()}),(function(e){}))}))}initOnButtonClick(){this.currentSource="native_prompt",this.isNotificationSupported()?(localStorage.getItem("ai-web-push-modal")&&localStorage.removeItem("ai-web-push-modal"),this.scrollTriggered=!1,this.cleanupScrollListener(),this.init(!0)):this.emit("browser_not_supported",{source:this.currentSource})}aiWebPushNewPush(e){this.aiWebPushNewEvent("new-user",{client:e,pid:AI_WEB_PUSH_PID,location:"web-push",landingUrl:window.location.href,referrer:document.referrer||""})}askPermission(e=!1){this.isNotificationSupported()?("custom_modal"===this.currentSource&&e&&this.emit("modal_accepted",{source:"custom_modal"}),"granted"!=Notification.permission&&(this.closeModal(!1),setTimeout((()=>{this.emit("prompt_shown",{source:this.currentSource}),Notification.requestPermission().then((e=>{if("granted"===e){this.emit("permission_granted",{source:this.currentSource}),this.setModalDismissed("accepted");const e=firebase.initializeApp(this.firebaseConfig);firebase.messaging(e).getToken({vapidKey:"BKggPEBMHnKh1IOcR6X0rZIgfCcJzfKRpSJOUHCc3vWKpN8jiMB_nd9bUW9EkNGMSlsOnTdhY9i1WwBKVDyWNEQ"}).then((e=>{this.aiWebPushNewPush(e),this.emit("subscription_success",{source:this.currentSource}),this.setupForegroundMessaging()})).catch((e=>{this.emit("subscription_error",{source:this.currentSource,error:e})}))}else this.emit("permission_denied",{source:this.currentSource}),this.closeModal()}))}),e?0:1e3*AI_WEB_PUSH_MODAL_DELAY))):this.emit("browser_not_supported",{source:this.currentSource})}aiWebPushNewEvent(e,t,i=(e=>{})){if(t){i||(i=function(e){});let o=AI_WEB_PUSH_SITE_URL+"/wp-json/ai-web-push/v1/events",n=localStorage.getItem("ai-web-push-local-id");if(!n){let e=localStorage.getItem("ld");if(e)localStorage.setItem("ai-web-push-local-id",e),n=e;else{n="";const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=e.length;for(let i=0;i<10;i++)n+=e.charAt(Math.floor(Math.random()*t));localStorage.setItem("ai-web-push-local-id",n)}}fetch(o,{method:"POST",body:JSON.stringify(Object.assign(Object.assign({event:e},t),{localId:n,device:this.getDeviceType()})),headers:{"Content-Type":"application/json"}}).then((function(e){e.json().then((e=>{i(e)}))}))}}renderPushNotificationModal(){this.currentSource="custom_modal",setTimeout((()=>{const e=window.location.hostname;let t;t=AI_WEB_PUSH_MODAL_CUSTOM_ICON&&""!==AI_WEB_PUSH_MODAL_CUSTOM_ICON.trim()?AI_WEB_PUSH_MODAL_CUSTOM_ICON:"https://www.google.com/s2/favicons?domain=https://"+e+"&sz=64";let i='<div id="aiPushNotificationModal" style="position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 2147483647; width: 360px; background: #fff; border-radius: 16px; box-shadow: 0 4px 24px rgba(0,0,0,0.15); font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, sans-serif; padding: 32px 24px 24px 24px; display: flex; flex-direction: column; align-items: center; animation: aiPushSlideDown 0.3s ease;"><style>@keyframes aiPushSlideDown {from { opacity: 0; transform: translate(-50%, -100%); }to { opacity: 1; transform: translate(-50%, 0); }}</style><div style="display: flex; align-items: center; justify-content: center; margin-bottom: 32px; width: 100%;"><img src="'+t+'" style="width: 48px; height: 48px; margin-right: 16px; border-radius: 8px; background: #f5f5f5; object-fit: cover;" alt="'+e+' icon" onerror="this.src=\'https://www.google.com/s2/favicons?domain=https://'+e+'&sz=64\'"/>
1<div style="font-size: 16px; color: #222; font-weight: 500; line-height: 1.4; text-align: left;">'+AI_WEB_PUSH_MODAL_MESSAGE+'</div></div><div style="display: flex; justify-content: center; gap: 16px; width: 100%;"><button onclick="aiWebPushFront.closeModal()" style="padding: 10px 0; width: 120px; font-size: 15px; color: #554FFF; background: transparent; border: none; border-radius: 8px; cursor: pointer; font-weight: 500; transition: background 0.2s;">'+AI_WEB_PUSH_MODAL_CANCEL+'</button><button onclick="aiWebPushFront.askPermission(true)" style="padding: 10px 0; width: 120px; font-size: 15px; color: #fff; background: #554FFF; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; transition: opacity 0.2s;">'+AI_WEB_PUSH_MODAL_ACCEPT+"</button></div></div>";document.body.insertAdjacentHTML("afterbegin",i),this.emit("modal_shown",{source:"custom_modal"});const o=document.getElementById("aiPushNotificationModal");if(o){const e=o.getElementsByTagName("button");for(let t of e)t.addEventListener("mouseover",(function(){"transparent"===this.style.background?this.style.background="#f5f5f5":this.style.opacity="0.9"})),t.addEventListener("mouseout",(function(){"#f5f5f5"===this.style.background?this.style.background="transparent":this.style.opacity="1"}))}}),1e3*AI_WEB_PUSH_MODAL_DELAY)}closeModal(e=!0){let t=document.getElementById("aiPushNotificationModal");t&&t.remove(),e&&(this.setModalDismissed("canceled"),this.emit("modal_dismissed",{source:"custom_modal"}))}setupForegroundMessaging(){return __awaiter(this,void 0,void 0,(function*(){if("serviceWorker"in navigator)try{const e=yield navigator.serviceWorker.getRegistration(AI_WEB_PUSH_SERVICE_WORKER_PATH);if(!e)return;const t=firebase.apps&&firebase.apps.length?firebase.app():firebase.initializeApp(this.firebaseConfig);firebase.messaging(t).onMessage((t=>{var i;console.log(t),(null==t?void 0:t.notification)&&(e.showNotification(t.notification.title,{body:t.notification.body,icon:t.notification.icon,data:t}),(null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.view)&&fetch(t.data.view,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}).catch((()=>{})))}))}catch(e){}}))}setModalDismissed(e){localStorage.setItem("ai-web-push-modal",JSON.stringify({value:e,timestamp:Date.now()}))}getDeviceType(){const e=navigator.userAgent,t=e.indexOf("Windows")>-1||e.indexOf("Macintosh")>-1,i=/(Android|iPhone|iPod|iPad|Windows Phone)/i.test(e),o=/(iPad|Android)/i.test(e)&&!/(Mobile)/i.test(e);return t?"desktop":i?"mobile":o?"tablet":"other"}getBrowserName(){var e;return window.opr&&["opr"].addons||window.opera||navigator.userAgent.indexOf(" OPR/")>=0?"opera":-1!=navigator.userAgent.indexOf("Firefox")?"firefox":/constructor/i.test(null===(e=window.HTMLElement)||void 0===e?void 0:e.toString())||"[object SafariRemoteNotification]"===(!window.safari||void 0!==window.safari&&window.safari.pushNotification).toString()?"safari":document.documentMode?"ie":-1!=navigator.userAgent.indexOf("Edg")?"edge":window.chrome?"chrome":(window.chrome||window.opr&&["opr"].addons||window.opera||navigator.userAgent.indexOf(" OPR/")>=0)&&window.CSS?"blink":void 0}setupScrollTrigger(){this.scrollListener=()=>{if(this.scrollTriggered)return;if((window.pageYOffset||document.documentElement.scrollTop)/(document.documentElement.scrollHeight-document.documentElement.clientHeight)*100>=AI_WEB_PUSH_SCROLL_PERCENTAGE){this.scrollTriggered=!0,this.cleanupScrollListener();const e=this.getBrowserName();AI_WEB_PUSH_ALWAYS_SHOW_MODAL||["firefox","edge"].includes(e)?this.renderPushNotificationModal():this.askPermission()}},window.addEventListener("scroll",this.scrollListener,{passive:!0})}cleanupScrollListener(){this.scrollListener&&(window.removeEventListener("scroll",this.scrollListener),this.scrollListener=null)}}const aiWebPushFront=new AiWebPushFront,aiWebPushGtmEvents=["modal_shown","modal_accepted","modal_dismissed","prompt_shown","permission_granted","permission_denied","subscription_success","subscription_error","browser_not_supported","webview_exit_prompt_shown","webview_exit_intent_attempt","webview_exit_open_external_success","webview_exit_open_external_failed","webview_exit_dismissed","webview_exit_auto_attempt","webview_exit_auto_
1success","webview_exit_auto_failed"];aiWebPushGtmEvents.forEach((e=>{aiWebPushFront.on(e,(t=>{window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"ai_web_push_"+e,push_provider:"ai_web_push",push_source:t.source||""})}))})),window.addEventListener("load",(()=>{const e=aiWebPushFront.maybeShowWebViewExitPromptOnLoad();AI_WEB_PUSH_MANUAL_INIT||e||aiWebPushFront.init()})),window.aiWebPushFront=aiWebPushFront;

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.