1import{d as ge,e as Z,P as he,s as r,p as w,w as xe,x as ye,L as Ee,o as _,j as _e,D as G,k as J,c as T,l as X,T as ee,M as O,K as te,n as Se,q as s,u as A,t as b,F as Ie,A as ke,a as Le,a6 as Te,g as Me}from"./vue-i18n.BDY-6aG9.js";import"./data.Cik2lkiY.js";import{u as De,i as Ce,t as S}from"../app.rZ24jbPK.js";import"./intlify.BySaHZEQ.js";import"./plugin-vue_export-helper.DlAUqK2U.js";import"./vendor-deps.45xamTTr.js";import"./blog-data.DOIrR1N7.js";const Ne=["onKeydown"],Fe=["aria-label"],Re={class:"exit-intent-header"},Ve={class:"exit-intent-title"},Oe={class:"exit-intent-benefits",role:"list"},Ae={class:"exit-intent-foot"},Ue={class:"exit-intent-social-proof"},ze=10080*60*1e3,ne="exit-intent-title",Ye=ge({__name:"ExitIntentModal",setup(Be){const o=Z({isVisible:!1,hasTriggered:!1}),m=De(),{t:u,locale:M}=he(),a=r(null),g=r(null),l=r(!1),h=r(!1),U=r(!1),z=r(!1),p=r(!1),c=r(null),n=Z({timerMet:!1,scrollDepthMet:!1,mobileDeepScroll:!1,mobileReturn:!1});let x=0,D=()=>{},C=e=>{},N=()=>{},F=()=>{},R=()=>{},V=0;const I={session:"exit-intent-session-shown",timestamp:"exit-intent-last-shown"},ie=w(()=>u("exitIntent.copy.buttonNote")),B={myfitnesspal:"MyFitnessPal","lose-it":"Lose It","carb-manager":"Carb Manager","weight-watchers":"WeightWatchers",weightwatchers:"WeightWatchers",macrofactor:"MacroFactor",cronometer:"Cronometer",lifesum:"Lifesum",fitbit:"Fitbit","cal-ai":"Cal AI",yazio:"YAZIO",noom:"Noom",simple:"Simple"},k=w(()=>{const e=m.path.toLowerCase();if(e.includes("calculator")||e.includes("calorie-counter"))return{key:"calculator",app:""};if(e.includes("cancel")){const t=Object.keys(B).find(i=>e.includes(i));if(t)return{key:"cancel",app:B[t]}}return{key:"default",app:""}}),oe=w(()=>u(`exitIntent.copy.${k.value.key}Heading`,{app:k.value.app})),se=w(()=>u(`exitIntent.copy.${k.value.key}Body`,{app:k.value.app})),ae=w(()=>["trial","scans","tools","voice"].map(e=>u(`exitIntent.benefits.${e}`)));function H(){l.value=typeof window<"u"&&window.matchMedia("(pointer: coarse)").matches||typeof window<"u"&&window.innerWidth<=768}function $(){if(!(typeof window>"u"))try{h.value=window.localStorage.getItem("exit-intent-debug")==="true"}catch(e){console.warn("[ExitIntent] Unable to read debug flag",e),h.value=!1}}function K(){if(typeof window>"u")return;const e=new URLSearchParams(window.location.search);U.value=e.get("exit-intent")==="off"}function q(){if(typeof window>"u")return;const e=window.location.hostname;z.value=e==="localhost"||e==="127.0.0.1"}function W(){if(!(typeof window>"u")){try{p.value=window.sessionStorage.getItem(I.session)==="true"}catch(e){console.warn("[ExitIntent] Unable to read session flag",e),p.value=!1}try{const e=window.localStorage.getItem(I.timestamp);if(e){const t=Number.parseInt(e,10);c.value=Number.isNaN(t)?null:t}else c.value=null}catch(e){console.warn("[ExitIntent] Unable to read snooze timestamp",e),c.value=null}o.hasTriggered=p.value}}function le(){if(p.value=!0,!(typeof window>"u"))try{window.sessionStorage.setItem(I.session,"true")}catch(e){console.warn("[ExitIntent] Unable to persist session flag",e)}}function j(){if(c.value=Date.now(),!(typeof window>
1"u"))try{window.localStorage.setItem(I.timestamp,String(c.value))}catch(e){console.warn("[ExitIntent] Unable to persist snooze timestamp",e)}}function re(){return c.value?Date.now()-c.value<ze:!1}const ue=w(()=>{const t=Ce.global.messages.value[M.value];return!!t&&"exitIntent"in t});function ce(){return l.value?n.timerMet||n.mobileDeepScroll&&n.mobileReturn:n.timerMet||n.scrollDepthMet}function de(){x&&window.clearTimeout(x),x=window.setTimeout(()=>{n.timerMet=!0},l.value?3e4:2e4)}function P(){n.timerMet=!1,n.scrollDepthMet=!1,n.mobileDeepScroll=!1,n.mobileReturn=!1,de()}function y(e){if(typeof document>"u")return;const t=document.documentElement;e?t.classList.add("exit-intent-active"):t.classList.remove("exit-intent-active")}function d(e,t=!1){o.isVisible||z.value&&!t||!t&&(o.hasTriggered||U.value)||!t&&m.path.includes("/calories-nutrition/")||ue.value&&(!t&&(p.value||re()||!ce()&&!h.value)||(t||le(),o.hasTriggered=!0,o.isVisible=!0,g.value=document.activeElement instanceof HTMLElement?document.activeElement:null,y(!0),Me(()=>{fe(),me()}),S("exit_funnel_triggered",{route:m.path,locale:M.value,device:l.value?"mobile":"desktop",reason:e}),S("exit_offer_shown",{route:m.path,reason:e})))}function fe(){var e;(e=a.value)==null||e.focus()}function L(){g.value&&typeof g.value.focus=="function"&&g.value.focus(),g.value=null}function Y(){if(!a.value)return[];const e=["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'];return Array.from(a.value.querySelectorAll(e.join(",")))}function me(){if(!a.value)return;if(!Y().length){a.value.setAttribute("tabindex","-1"),a.value.focus();return}}function pe(e){if(!a.value)return;const t=Y();if(!t.length){e.preventDefault();return}const i=t[0],v=t[t.length-1],f=document.activeElement;e.shiftKey?f===i||!a.value.contains(f)?v.focus():(t[t.indexOf(f)-1]||v).focus():f===v?i.focus():(t[t.indexOf(f)+1]||i).focus()}function E(e){o.isVisible&&(o.isVisible=!1,y(!1),j(),S("exit_offer_dismissed",{method:e}),L())}function ve(){S("exit_offer_accept",{platform:"referral"}),S("download_app_referral",{store:"referral_link",source:"exit_intent_modal",page_path:m.path,language:M.value}),j(),window.open("https://refer.nutriscan.app/8Jgz/nov9jd5k","_blank","noopener"),o.isVisible=!1,y(!1),L()}function we(){D=()=>{const e=document.documentElement,t=e.scrollTop||document.body.scrollTop||0,i=e.scrollHeight-e.clientHeight;if(!l.value)i>0&&t/i>=.4&&(n.scrollDepthMet=!0);else{!n.mobileDeepScroll&&t>600&&(n.mobileDeepScroll=!0);const v=V-t,f=e.clientHeight*.25;n.mobileDeepScroll&&v>150&&t<=f&&(n.mobileReturn=!0,d("mobile-scroll"))}V=t},C=e=>{!l.value&&e.clientY<=0&&d("mouse-leave")},N=()=>{document.visibilityState==="hidden"&&d("visibility-hidden")},F=()=>{d("before-unload")},R=()=>{l.value&&d("back-navigation")},window.addEventListener("scroll",D,{passive:!0}),document.addEventListener("mouseleave",C),document.addEventListener("visibilitychange",N),window.addEventListener("beforeunload",F),window.addEventListener("popstate",R)}function be(){window.removeEventListener("scroll",D),document.removeEventListener("mouseleave",C),document.removeEventListener("visibilitychange",N),window.removeEventListener("beforeunload",F),window.removeEventListener("popstate",R)}function Q(){o.isVisible=!1,o.hasTriggered=p.value,L(),y(!1),H(),q(),K(),$(),W(),P(),h.value&&window.setTimeout(()=>d("debug",!0),350)}return xe(()=>m.path,()=>{typeof window>"u"||Q()}),ye(()=>{H(),q(),K(),$(),W(),P(),we(),V=window.scrollY||0,h.value&&window.setTimeout(()=>d("debug",!0),300),window.__exitIntent={reset:()=>{console.log("[ExitIntent] manual reset requested via console helper."),Q()},close:()=>{console.log("[ExitIntent] close requested via console helper."),E("external")}}}),Ee(()=>{be(),x&&window.clearTimeout(x),L(),y(!1),delete window.__exitIntent}),(e,t)=>(_(),_e(Te,{to:"body"},[G(ee,{name:"exit-intent-fade"},{default:J(()=>[o.isVisible?(_(),T("div",{key:0,class:"exit-intent-overlay",onClick:t[0]||(t[0]=i=>E("overlay"))})):X("",!0)]),_:1}),G(ee,{name:l.value?"exit-sheet-slide":"exit-modal-scale"},{default:J(()=>
1[o.isVisible?(_(),T("div",{key:0,ref_key:"modalRef",ref:a,class:Se(["exit-intent-container",{"is-mobile":l.value}]),role:"dialog",tabindex:"-1","aria-modal":"true","aria-labelledby":ne,onKeydown:[t[3]||(t[3]=O(()=>{},["self","stop"])),t[4]||(t[4]=te(O(i=>E("esc"),["prevent","stop"]),["esc"])),te(O(pe,["prevent"]),["tab"])]},[s("button",{type:"button",class:"exit-intent-close","aria-label":A(u)("exitIntent.actions.close"),onClick:t[1]||(t[1]=i=>E("close"))},[...t[5]||(t[5]=[s("span",{"aria-hidden":"true"},"Ã",-1)])],8,Fe),s("header",Re,[s("h1",{id:ne,class:"exit-intent-heading"},b(oe.value),1),s("p",Ve,b(se.value),1)]),s("ul",Oe,[(_(!0),T(Ie,null,ke(ae.value,i=>(_(),T("li",{key:i},[t[6]||(t[6]=s("span",{class:"exit-intent-tick","aria-hidden":"true"},null,-1)),Le(b(i),1)]))),128))]),s("div",Ae,[s("p",Ue,b(ie.value),1),s("button",{type:"button",class:"exit-intent-primary exit-intent-primary--cta","data-cta":"exit-offer",onClick:ve},b(A(u)("exitIntent.actions.claimTrial")),1),s("button",{type:"button",class:"exit-intent-dismiss",onClick:t[2]||(t[2]=i=>E("no-thanks"))},b(A(u)("exitIntent.actions.dismiss")),1)])],42,Ne)):X("",!0)]),_:1},8,["name"])]))}});export{Ye as default};
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.