(()=>{"use strict";const e=(e,t,n={})=>!(!newspackPopupsData||!newspackPopupsData[t])&&{...newspackPopupsData[t],...n,action:e},t=(e,t="np_prompt_interaction")=>{"function"==typeof gtag&&e&>ag("event",t,e)},n=e=>{const t=e.split("_");return parseInt(t[t.length-1])},s=e=>{const t=e.currentTarget.closest(".newspack-lightbox");t&&t.contains(e.currentTarget)&&(t.style.display="none"),t.overlayId&&window.newspackReaderActivation?.overlays&&window.newspackReaderActivation.overlays.remove(t.overlayId),e.preventDefault()},r=(e,t)=>{newspack_popups_view.debug&&(window.newspack_popups_debug=window.newspack_popups_debug||{},window.newspack_popups_debug[e]=t)};window.newspackPopupsCriteria=window.newspackPopupsCriteria||{criteria:{}},window.newspackPopupsCriteria.criteria=window.newspackPopupsCriteria.criteria||{};const o=864e5,a={day:o,week:7*o,month:30*o},i=e=>{for(const n of e){const e=(t=n.criteria_id)?window.newspackPopupsCriteria.criteria[t]:window.newspackPopupsCriteria.criteria;if(e&&!e.matches(n))return!1}var t;return!0},c=(e,t=null)=>{const n=((e=null)=>{e||(e=window.location.search);const t=new URLSearchParams(e);return t.get("view_as")?t.get("view_as").split(";").reduce(((e,t)=>{const n=t.split(":");return 1===n.length?e[n[0]]=!0:e[n[0]]=n[1],e}),{}):null})(t);if(n?.segment)return n.segment;const s=[];for(const t in e)i(e[t].criteria)&&s.push({id:t,priority:e[t].priority});return s.length?(s.sort(((e,t)=>e.priority-t.priority)),s[0].id):null},p=(e,t,s,o=null)=>{const i=e.getAttribute("id");let c=!0;const p=[],d={element:e};if(!0===o||!1===o)d.override=!0,o||(c=!1,p.push("Prompt suppressed by override."));else if(s){const[r,o,d,u]=e.getAttribute("data-frequency").split(","),l=s.store.get("pageviews");if(l[u]){const e=l[u].count||0;e<=parseInt(r)&&(p.push(`Prompt displayed starting at pageview ${parseInt(r)+1}. Reader has only ${e} pageviews.`),c=!1),0e.data?.prompt_id===t&&a[u]>Date.now()-e.timestamp));0=parseInt(d)&&(p.push(`Prompt already displayed the max of ${d} times.`),c=!1)}const w=e.getAttribute("data-segments")?e.getAttribute("data-segments").split(","):null;w&&0>w.indexOf(t)&&(p.push("Reader does not match prompt’s assigned segments."),c=!1)}return d.displayed=c,0{let t;const n=new IntersectionObserver((s=>{s.forEach((s=>{s.isIntersecting?t||(t=setTimeout((()=>{e(),n.unobserve(s.target)}),250)):t&&(clearTimeout(t),t=!1)}))}),{threshold:.5});return n},u=e=>{const t=(t=null)=>{const o=newspack_popups_view?.segments||{},i=c(o);let u;r("matchingSegment",i),t&&(e=>{const t=Date.now(),n={day:{count:0,start:t},week:{count:0,start:t},month:{count:0,start:t},...e.store.get("pageviews")||{}};let s;document.body.classList.forEach((e=>{0===e.indexOf("page-id-")&&(s=parseInt(e.replace("page-id-","")))})),s&&parseInt(newspack_popups_view?.donor_landing_page)===s&&e.store.set("is_donor",!0);for(const e in n)a[e]{const r=e.getAttribute("id"),a=e.classList.contains("newspack-lightbox"),l=((e,t=!1,n=!1,s=null)=>e===((e=null)=>{e||(e=window.location.search);const t=new URLSearchParams(e);return t.get("pid")?parseInt(t.get("pid")):null})(s)||(!t||!n)&&null)(n(r),a,u);[...e.querySelectorAll(".newspack-lightbox__close, button.newspack-lightbox-overlay")].forEach((e=>{e.addEventListener("click",s)}));const w=p(e,i,t,l);if(!u&&a&&w&&(u=!0),w){const s=()=>{const t=e.getAttribute("data-delay")||0;setTimeout(i,t)},i=()=>{const r=c(o);p(e,r,t,l)&&(t?.overlays&&t.overlays.get().length?s():(e.classList.remove("hidden"),t&&((e,t)=>{d((()=>t.dispatchActivity("prompt_seen",{prompt_id:n(e.getAttribute("id"))}))).observe(e,{attributes:!0})})(e,t),a&&t?.overlays&&(e.overlayId=t.overlays.add())))};if(a)if(e.getAttribute("data-scroll")){const e=document.getElementById(`page-position-marker_${r}`);e&&d(i).observe(e)}else s();else i()}}))};newspack_popups_view.segments?(window.newspackRAS=window.newspackRAS||[],window.newspackRAS.push(t)):t()},l=s=>{s.forEach((s=>{new MutationObserver((r=>{r.forEach((r=>{"amp-access-hide"!==r.attributeName||"attributes"!==r.type||r.target.hasAttribute("amp-access-hide")||(()=>{const r=e("loaded",n(s.getAttribute("id")));t(r)})()}))})).observe(s,{attributes:!0})}))};var w;"undefined"!=typeof window&&(w=()=>{const s=[...document.querySelectorAll(".newspack-popup-container")];u(s),(s=>{"function"==typeof gtag&&(l(s),window.newspackRAS=window.newspackRAS||[],window.newspackRAS.push((n=>{n.on("activity",(({detail:{action:n,data:s}})=>{if("prompt_seen"===n){const{prompt_id:n}=s,r=e("seen",n);t(r)}}))})),(s=>{s.forEach((s=>{const r=s.querySelector(".newspack-lightbox__close"),o=[...s.querySelectorAll(".newspack-popup-container form")];if(r){const a=()=>{const r=e("dismissed",n(s.getAttribute("id")));t(r)};r.addEventListener("click",a),o.forEach((e=>{e.addEventListener("submit",(()=>r.removeEventListener("click",a)))}))}}))})(s),(s=>{s.forEach((s=>{const r=[...s.querySelectorAll(".newspack-popup-container a")],o=r=>{const o={};r.currentTarget?.href&&"#"!==r.currentTarget?.href&&(o.action_value=r.currentTarget.getAttribute("href"));const a=e("clicked",n(s.getAttribute("id")),o);t(a)};r.forEach((e=>e.addEventListener("click",o)))}))})(s),(s=>{s.forEach((s=>{const r=[...s.querySelectorAll(".newspack-popup-container form")],o=()=>{const r=e("form_submission",n(s.getAttribute("id")));t(r)};r.forEach((e=>e.addEventListener("submit",o)))}))})(s))})(s)},"undefined"!=typeof document&&("complete"!==document.readyState&&"interactive"!==document.readyState?document.addEventListener("DOMContentLoaded",w):w()))})();