@automattic/newspack-blocks 4.23.0 → 4.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # [4.24.0](https://github.com/Automattic/newspack-blocks/compare/v4.23.0...v4.24.0) (2026-02-02)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * force alpha release ([7e6ace4](https://github.com/Automattic/newspack-blocks/commit/7e6ace4c8ae429c93556da173ef30a4c2f3cbd64))
7
+
8
+
9
+ ### Features
10
+
11
+ * add prompt_title to the modal checkout data events ([#2271](https://github.com/Automattic/newspack-blocks/issues/2271)) ([238c7e9](https://github.com/Automattic/newspack-blocks/commit/238c7e931e7168ab3d0755ad73702746418d706a))
12
+
1
13
  # [4.23.0](https://github.com/Automattic/newspack-blocks/compare/v4.22.0...v4.23.0) (2026-01-19)
2
14
 
3
15
 
@@ -1 +1 @@
1
- <?php return array('dependencies' => array(), 'version' => 'f36f5138947c45fce784');
1
+ <?php return array('dependencies' => array(), 'version' => 'a70e4a778ed885063751');
package/dist/modal.js CHANGED
@@ -1 +1 @@
1
- (()=>{"use strict";function e(e,t=!1){const o=e.querySelectorAll('button, [href], input:not([type="hidden"]), select, textarea, [tabindex]:not([tabindex="-1"])');if(0===o.length)return!1;const n=o?.[0];let c;n.focus(),t?(document.addEventListener("keydown",function(e){if(("Tab"===e.key||9===e.keyCode)&&e.shiftKey&&document.activeElement===n){const o=t.contentWindow.document,n=o.getElementById("checkout-after-success");c=null!==n?n:o.getElementById("checkout_cancel"),c.focus(),e.preventDefault()}}),document.getElementById("newspack-a11y-last-element").addEventListener("focus",()=>{n.focus()})):(c=o[o.length-1],document.addEventListener("keydown",function(e){("Tab"===e.key||9===e.keyCode)&&(e.shiftKey?document.activeElement===n&&(c.focus(),e.preventDefault()):document.activeElement===c&&(n.focus(),e.preventDefault()))}))}const t=(e,t={})=>({...t,action:e}),o=["action","action_type","amount","currency","product_id","product_type","variation_id","variation_ids","is_variable","is_grouped","child_ids","price_summary","newspack_popup_id","gate_post_id","recurrence","referrer"],n=(e,t="np_modal_checkout_interaction")=>{if("function"==typeof window.gtag&&e){const n={};for(const t of o)e[t]&&("boolean"==typeof e[t]?e[t]=e[t]?"yes":"no":"true"===e[t]?e[t]="yes":"false"===e[t]&&(e[t]="no"),n[t]=e[t].toString());window.gtag("event",t,n)}},c=e=>{if("function"!=typeof window.gtag)return;let o="opened";const{amount:c="",is_variable:a="",is_grouped:r="",price:s="",variation_id:i=""}=e,l={...e};(c||s)&&(l.amount=c||s),a&&!i&&(o="opened_variations"),r&&(o="opened_grouped");const d=t(o,l);n(d)};function a(e,t=null){const o=document.createElement("input");return o.type="hidden",o.name=e,t&&(o.value=t),o}function r(e){e.requestSubmit(e.querySelector('button[type="submit"]'))}function s(e){const t="string"==typeof e?document.getElementById(e):e;if(!t)return console.warn("No container found for checkout data"),{};let o={};if("FORM"===t.tagName){const e=new FormData(t);o=Object.fromEntries(e)}const n=t.dataset.checkout;if(!n)return console.warn("No checkout data found"),o;try{o={...o,...JSON.parse(n)}}catch(e){console.warn("Error parsing checkout data")}const c=new URL(t.ownerDocument.defaultView.location.href);return c.searchParams.get("action_type")&&(o.action_type=c.searchParams.get("action_type")),o}const i=e=>{if("function"!=typeof window.gtag)return;e=e||s("newspack_modal_checkout");const o=t("dismissed",e);n(o)},l=newspackBlocksModal.newspack_class_prefix,d="newspack_modal_checkout_iframe",u="newspack_modal_checkout_container",p=`${l}__modal`,m="newspack-blocks__modal-variation",_=`${l}__processing-payment-text`,h=newspackBlocksModal.processing_payment_messages;let y=!1,k=newspackBlocksModal.labels.checkout_modal_title,w=null;const f=e=>{e.overlayId&&window.newspackReaderActivation?.overlays&&window.newspackReaderActivation?.overlays.remove(e.overlayId),e.setAttribute("data-state","closed"),document.body.style.overflow="auto"};window.onpageshow=e=>{e.persisted&&(document.querySelectorAll(".modal-processing").forEach(e=>e.classList.remove("modal-processing")),document.querySelectorAll(".non-modal-checkout-loading").forEach(e=>e.classList.remove("non-modal-checkout-loading")),document.querySelectorAll(`.${p}-container`).forEach(e=>f(e)))};const v=new CustomEvent("checkout-closed");var g;window.newspackRAS=window.newspackRAS||[],g=()=>{const t=document.querySelector("#newspack_modal_checkout");if(!t)return;const o=t.querySelector(`.${p}__content`),n=a("modal_checkout","1"),g=o.querySelector(`.${l}__spinner`);let b=document.querySelector(".newspack-reader__account-link")?.[0];const S="600px",E=document.createElement("iframe");E.name=d,E.style.height=S,E.style.visibility="hidden";const A=e=>{M.observe(e),"none"!==g.style.display&&(g.style.display="none"),"visible"!==E.style.visibility&&(E.style.visibility="visible"),E._ready=!0};!function(e,t,o){e._ready=!1,e._readyTimer&&clearTimeout(e._readyTimer);let n=!1,c="";function a(){n||(n=!0,clearTimeout(e._readyTimer),t.call(this))}function r(){"complete"===this.readyState&&a.call(this)}function s(){e._ready=!1,o&&o(),e._readyTimer&&clearTimeout(e._readyTimer);const t=e.contentDocument||e.contentWindow?.document;t&&(t.removeEventListener("DOMContentLoaded",a),t.removeEventListener("readystatechange",r))}function i(){if(e._ready)return void s();const t=e.contentDocument||e.contentWindow?.document;t&&0!==t.URL.indexOf("about:")?"complete"===t?.readyState?a.call(t):(t.addEventListener("DOMContentLoaded",a),t.addEventListener("readystatechange",r)):e._readyTimer=setTimeout(i,10)}e._observer||(e._observer=new MutationObserver(e=>{e.forEach(e=>{"attributes"===e.type&&"src"===e.attributeName&&(n=!1,s(),i())})}),e._observer.observe(e,{attributes:!0})),e._locationObserver||(e._locationObserver=setInterval(function(){const t=e.contentDocument||e.contentWindow?.document;t&&t.URL!==c&&(c=t.URL,n=!1,s(),i())},50)),i()}(E,function(){const o=E.contentWindow?.location;if(window.newspackReaderActivation&&o?.href?.includes("order-received")){const e=window.newspackReaderActivation,t=new Proxy(new URLSearchParams(o.search),{get:(e,t)=>e.get(t)});t.email&&(e.setReaderEmail(t.email),e.setAuthenticated(!0))}const n=E?.contentDocument?.querySelector(`#${u}`);if(!n)return;const c=n.querySelector("#modal-checkout-product-details"),a=s(c),r=document.createElement("p");r.classList.add(_);let i=[];const l=()=>{i.forEach(e=>clearTimeout(e)),i=[]},d=()=>{g.style.display="none",l(),g.querySelectorAll(`.${_}`).forEach(e=>e.remove())};!function(e,t){e.checkoutCancel?t():e.addEventListener("checkout-cancel",t)}(n,()=>{C()}),function(e,t){e.checkoutPlaceOrderStart?t():e.addEventListener("checkout-place-order-start",t)}(n,e=>{var t;g.querySelectorAll(`.${_}`).forEach(e=>e.remove()),g.style.display="flex",l(),r.textContent=null!==(t=h[0]?.text)&&void 0!==t?t:"",h.slice(1).forEach(({text:t,delay:o})=>{const n=setTimeout(()=>{e.target.dispatchEvent(new CustomEvent("checkout-place-order-processing")),r.textContent=t},o);i.push(n)}),g.appendChild(r)}),function(e,t){e.checkoutPlaceOrderError?t():e.addEventListener("checkout-place-order-error",t)}(n,d),function(e,t){e.checkoutReady?t():e.addEventListener("checkout-ready",t)}(n,()=>{const e=c?.querySelector("strong");if(e&&(e.textContent=a.price_summary),t.initialErrors){const e=document.createElement("div");e.classList.add("woocommerce-error"),e.textContent=t.initialErrors,n.prepend(e),delete t.initialErrors}P(),O(k),E.contentWindow?.newspackBlocksModalCheckout?.checkout_nonce&&(t.checkout_nonce=E.contentWindow.newspackBlocksModalCheckout.checkout_nonce),A(n)}),function(e,t){e.checkoutComplete?t():e.addEventListener("checkout-complete",t)}(n,()=>{window.newspackRAS.push(["checkout_completed",a]),window?.newspackReaderActivation?.refreshNewslettersSignupModal&&window?.newspackReaderActivation?.getReader()?.email&&window.newspackReaderActivation.refreshNewslettersSignupModal(window.newspackReaderActivation.getReader().email),P("small"),O(newspackBlocksModal.labels.thankyou_modal_title),A(n),e(t.querySelector(`.${p}`)),d()}),function(e,t){e.checkoutPlaceOrderCriticalError?t():e.addEventListener("checkout-place-order-critical-error",t)}(n,()=>{var e;(e=w)&&(C(),g.style.display="none",t.initialErrors=newspackBlocksModal.labels.critical_error,e.requestSubmit(e.querySelector('button[type="submit"]')),d())})},()=>{g.style.display="flex"});const q=e=>new Promise((t,o)=>{const n=new URLSearchParams(e);n.append("action","modal_checkout_request"),fetch(newspackBlocksModal.ajax_url+"?"+n.toString()).then(e=>{e.ok||o(e),e.json().then(e=>{t(e.url)}).catch(o)}).catch(o)}),L=()=>"undefined"!=typeof newspack_ras_config&&!newspack_ras_config?.is_logged_in&&!window?.newspackReaderActivation?.getReader?.()?.authenticated&&newspackBlocksModal?.is_registration_required&&window?.newspackReaderActivation?.openAuthModal,$=t=>{const o=!newspackBlocksModal.has_unsupported_payment_gateway;o||t.preventDefault();const n=t.target;n.classList.add("modal-processing");const u=s(n);if(u.newspack_donate){const e=u.donation_frequency,t=[...n.querySelectorAll(`.donation-tier__${e}, .donation-frequency__${e}`)],o=u.donation_tier_index;let c,a;o?(c=t[o],a=u[`donation_value_${e}`]):(c=t[0],u[`donation_value_${e}_untiered`]?a=u[`donation_value_${e}_untiered`]:(a=u[`donation_value_${e}`],"other"===a&&(a=u[`donation_value_${e}_other`])));const r=s(c);for(const e in r)u[e]=r[e];u.amount=a,u.price_summary=u.summary_template.replace("{{PRICE}}",function(e,t="USD"){return parseFloat(e).toLocaleString(document.documentElement.lang,{style:"currency",currency:t,currencyDisplay:"narrowSymbol"})}(u.amount,u.currency))}u&&Object.keys(u).forEach(e=>{0===n.querySelectorAll('input[name="'+e+'"]').length&&n.prepend(a(e,u[e]))}),u.variation_id||(b=t.submitter);const p=document.querySelectorAll(`.${m}`);if(p.forEach(e=>{(L()||o)&&f(e)}),u.is_grouped||u.is_variable&&!u.variation_id){const o=[...p].find(e=>e.dataset.productId===u.product_id);if(o)return o.querySelectorAll(`form[target="${d}"]`).forEach(e=>{["after_success_behavior","after_success_url","after_success_button_label","gate_post_id","newspack_popup_id"].forEach(t=>{0===e.querySelectorAll('input[name="'+t+'"]').length&&e.prepend(a(t,u[t]))});const t=e.dataset.checkout;if(t){const o=JSON.parse(t);Object.keys(o).forEach(t=>{0===e.querySelectorAll('input[name="'+t+'"]').length&&e.prepend(a(t,o[t]))})}}),t.preventDefault(),n.classList.remove("modal-processing"),B(o),e(o,!1),y||c(u),void document.getElementById("newspack_modal_checkout").setAttribute("data-checkout",JSON.stringify(u))}if(o||L()){if(n.classList.remove("modal-processing"),y||c(u),y=!0,L()){t.preventDefault();const e=u.price_summary,n=e?`<div class="order-details-summary ${l}__box ${l}__box--text-center"><p><strong>${e}</strong></p></div>`:"",c=q(u);c.then(e=>{window.newspackReaderActivation?.setPendingCheckout?.(e)}),window.newspackReaderActivation.openAuthModal({title:newspackBlocksModal.labels.auth_modal_title,onSuccess:(e,t)=>{c.then(e=>{t?.registered&&o&&(e+=`&${newspackBlocksModal.checkout_registration_flag}=1`),o?r(R(e)):q(u).then(window.location.href=e)}).catch(e=>{console.warn("Unable to generate cart:",e),C()})},onError:()=>{C()},onDismiss:()=>{i(u),y=!1,document.getElementById("newspack_modal_checkout").removeAttribute("data-checkout")},skipSuccess:!0,skipNewslettersSignup:!0,labels:{signin:{title:newspackBlocksModal.labels.signin_modal_title},register:{title:newspackBlocksModal.labels.register_modal_title}},content:n,trigger:t.submitter,closeOnSuccess:o})}else x(),document.getElementById("newspack_modal_checkout").setAttribute("data-checkout",JSON.stringify(u));w=n}else q(u).then(e=>{window.location.href=e}),(!u.is_variable||u.variation_id)&&n.querySelectorAll("button[type=submit]:focus").forEach(e=>{e.classList.add("non-modal-checkout-loading");const t=e.innerHTML;e.innerHTML="<span>"+t+"</span>"})},R=e=>{const t=document.createElement("form");t.method="POST",t.action=e,t.target=d,t.style.display="none";const o=document.createElement("button");return o.setAttribute("type","submit"),t.appendChild(o),document.body.appendChild(t),t.addEventListener("submit",$),t},M=new ResizeObserver(e=>{if(!e||!e.length)return;if(!E.contentDocument)return;const n=e[0].contentRect;if(n){const e=.01*Math.max(document.documentElement.clientHeight,window.innerHeight||0)*90-(t.querySelector(`.${p}__header`)?.offsetHeight||0),c=n.top+n.bottom,a=Math.min(c,e);if(0===a)return void(E.style.visibility="hidden");o.style.height=a+"px",E.style.height=a+"px"}}),C=()=>{const e=E?.contentDocument?.querySelector(`#${u}`),n=e?.querySelector('input[name="after_success_url"]'),c=e?.querySelector('input[name="after_success_behavior"]'),a=document?.querySelector(".newspack-newsletters-signup-modal"),r=s(e?.querySelector("#modal-checkout-product-details"));e?.checkoutComplete||(async()=>{const e=new FormData;newspackBlocksModal.has_unsupported_payment_gateway||e.append("modal_checkout","1"),e.append("action","abandon_modal_checkout"),e.append("_wpnonce",t.checkout_nonce),t.checkout_nonce=null;try{await fetch(newspackBlocksModal.ajax_url,{method:"POST",body:e})}catch(e){console.warn("Unable to empty cart:",e)}})();const l=!(E.contentDocument&&n&&c&&e?.checkoutComplete);if((l||a)&&(g.style.display="flex",E&&o.contains(E)&&(E._ready=!1,E.src="about:blank",E.style.height=S,E.style.visibility="hidden",o.style.height=S,o.removeChild(E)),M&&M.disconnect(),document.querySelectorAll(`.${p}-container`).forEach(e=>f(e)),b&&b.focus(),document.dispatchEvent(v)),e?.checkoutComplete){const e=()=>{if(n&&c){const e=n.getAttribute("value"),t=c.getAttribute("value");"custom"===t?window.location.href=e:"referrer"===t&&window.history.back()}window?.newspackReaderActivation?.setPendingCheckout?.(),y=!1};"subscription_switch"!==r.action_type&&window?.newspackReaderActivation?.openNewslettersSignupModal?window.newspackReaderActivation.openNewslettersSignupModal({onSuccess:e,onError:e,closeOnSuccess:l}):e(),l&&(k=newspackBlocksModal.labels.checkout_modal_title,P(),O(k))}else window?.newspackReaderActivation?.setPendingCheckout?.(),i(),y=!1,document.getElementById("newspack_modal_checkout").removeAttribute("data-checkout");document.removeEventListener("keydown",D)},x=n=>{n&&(E.src=n),g.style.display="flex",B(t),o.appendChild(E),t.addEventListener("click",e=>{e.target===t&&C()}),e(t,E),document.addEventListener("keydown",D)},B=e=>{window.newspackReaderActivation?.overlays&&(e.overlayId=window.newspackReaderActivation?.overlays.add()),e.setAttribute("data-state","open"),document.body.style.overflow="hidden"},O=e=>{const o=t.querySelector(`.${p}__header h2`);o&&(o.innerText=e)},P=(e="default")=>{const o=t.querySelector(`.${p}`);o&&("small"===e?o.classList.add(`${p}--small`):o.classList.remove(`${p}--small`))};t.querySelectorAll(`.${p}__close`).forEach(e=>{e.addEventListener("click",e=>{e.preventDefault(),C()})}),document.querySelectorAll(".newspack-blocks__modal-variation").forEach(e=>{e.addEventListener("click",t=>{t.target===e&&C()}),e.querySelectorAll(`.${p}__close`).forEach(e=>{e.addEventListener("click",e=>{e.preventDefault(),C()})})});const D=e=>{"Escape"===e.key&&C()};document.querySelectorAll(".wpbnbd.wpbnbd--platform-wc, .wp-block-newspack-blocks-checkout-button, .newspack-blocks__modal-variation").forEach(e=>{e.querySelectorAll("form").forEach(e=>{newspackBlocksModal.has_unsupported_payment_gateway||e.prepend(n.cloneNode()),e.target=d,e.addEventListener("submit",$)})}),(()=>{const e=new URLSearchParams(window.location.search);if(!e.has("checkout"))return;const t=e.get("type");if("donate"===t){const t=e.get("layout"),o=e.get("frequency"),n=e.get("amount"),c=e.get("other");t&&o&&n&&((e,t,o,n=null)=>{let c;document.querySelectorAll(".wpbnbd.wpbnbd--platform-wc form").forEach(a=>{const r=a.querySelector(`input[name="donation_frequency"][value="${t}"]`);if(r)if("tiered"===e){const e=document.querySelector(`button[data-frequency-slug="${t}"]`);if(!e)return;e.click();const n=a.querySelector(`button[type="submit"][name="donation_value_${t}"][value="${o}"]`);if(!n)return;n.click()}else{const s="untiered"===e?a.querySelector(`input[name="donation_value_${t}_untiered"]`):a.querySelector(`input[name="donation_value_${t}"][value="${o}"]`);if(r&&s){if(r.checked=!0,"untiered"===e)s.value=o;else if("other"===o){s.click();const e=a.querySelector(`input[name="donation_value_${t}_other"]`);e&&n&&(e.value=n)}else s.checked=!0;c=a}}}),c&&r(c)})(t,o,n,c)}else if("checkout_button"===t){const t=e.get("product_id"),o=e.get("variation_id");t&&((e,t=null)=>{let o;if(t&&t!==e){const n=[...document.querySelectorAll(`.${m}`)].find(t=>t.dataset.productId===e);n&&n.querySelectorAll(`form[target="${d}"]`).forEach(e=>{const n=JSON.parse(e.dataset.checkout);n?.variation_id===Number(t)&&(o=e)})}else document.querySelectorAll(".wp-block-newspack-blocks-checkout-button").forEach(t=>{const n=t.querySelector("form");if(!n)return;const c=JSON.parse(n.dataset.checkout);c?.product_id===e&&(o=n)});o&&r(o)})(t,o)}else{const e=window.newspackReaderActivation?.getPendingCheckout?.();e&&r(R(e))}window.history.replaceState(null,null,window.location.pathname)})(),window.newspackOpenModalCheckout=({url:e=null,title:t=null,actionType:o=null,afterSuccess:n={},onCheckoutComplete:c=null,onClose:a=null})=>{if(k=t||newspackBlocksModal.labels.checkout_modal_title,O(k),(e=new URL(e||newspackBlocksModal.checkout_url)).searchParams.has("my_account_checkout")&&e.searchParams.delete("my_account_checkout"),e.searchParams.has("modal_checkout")||e.searchParams.set("modal_checkout","1"),o&&e.searchParams.set("action_type",o),n?.url&&e.searchParams.set("after_success_url",n.url),(n?.behavior||n?.url)&&e.searchParams.set("after_success_behavior",n.behavior||"custom"),n?.buttonLabel&&e.searchParams.set("after_success_button_label",n.buttonLabel),c){const e=({detail:{action:e,data:t}})=>{"checkout_completed"===e&&c(t)};window.newspackRAS.push(t=>{t.on("activity",e);const o=()=>{t.off("activity",e),document.removeEventListener("checkout-closed",o)};document.addEventListener("checkout-closed",o)})}if(a){const e=()=>{a(),document.removeEventListener("checkout-closed",e)};document.addEventListener("checkout-closed",e)}x(e.toString())},window.newspackCloseModalCheckout=C},"undefined"!=typeof document&&("complete"!==document.readyState&&"interactive"!==document.readyState?document.addEventListener("DOMContentLoaded",g):g())})();
1
+ (()=>{"use strict";function e(e,t=!1){const o=e.querySelectorAll('button, [href], input:not([type="hidden"]), select, textarea, [tabindex]:not([tabindex="-1"])');if(0===o.length)return!1;const n=o?.[0];let c;n.focus(),t?(document.addEventListener("keydown",function(e){if(("Tab"===e.key||9===e.keyCode)&&e.shiftKey&&document.activeElement===n){const o=t.contentWindow.document,n=o.getElementById("checkout-after-success");c=null!==n?n:o.getElementById("checkout_cancel"),c.focus(),e.preventDefault()}}),document.getElementById("newspack-a11y-last-element").addEventListener("focus",()=>{n.focus()})):(c=o[o.length-1],document.addEventListener("keydown",function(e){("Tab"===e.key||9===e.keyCode)&&(e.shiftKey?document.activeElement===n&&(c.focus(),e.preventDefault()):document.activeElement===c&&(n.focus(),e.preventDefault()))}))}const t=(e,t={})=>({...t,action:e}),o=["action","action_type","amount","currency","product_id","product_type","variation_id","variation_ids","is_variable","is_grouped","child_ids","price_summary","newspack_popup_id","prompt_title","gate_post_id","recurrence","referrer"],n=(e,t="np_modal_checkout_interaction")=>{if("function"==typeof window.gtag&&e){const n={};for(const t of o)e[t]&&("boolean"==typeof e[t]?e[t]=e[t]?"yes":"no":"true"===e[t]?e[t]="yes":"false"===e[t]&&(e[t]="no"),n[t]=e[t].toString());window.gtag("event",t,n)}},c=e=>{if("function"!=typeof window.gtag)return;let o="opened";const{amount:c="",is_variable:a="",is_grouped:r="",price:s="",variation_id:i=""}=e,l={...e};(c||s)&&(l.amount=c||s),a&&!i&&(o="opened_variations"),r&&(o="opened_grouped");const d=t(o,l);n(d)};function a(e,t=null){const o=document.createElement("input");return o.type="hidden",o.name=e,t&&(o.value=t),o}function r(e){e.requestSubmit(e.querySelector('button[type="submit"]'))}function s(e){const t="string"==typeof e?document.getElementById(e):e;if(!t)return console.warn("No container found for checkout data"),{};let o={};if("FORM"===t.tagName){const e=new FormData(t);o=Object.fromEntries(e)}const n=t.dataset.checkout;if(!n)return console.warn("No checkout data found"),o;try{o={...o,...JSON.parse(n)}}catch(e){console.warn("Error parsing checkout data")}const c=new URL(t.ownerDocument.defaultView.location.href);return c.searchParams.get("action_type")&&(o.action_type=c.searchParams.get("action_type")),o}const i=e=>{if("function"!=typeof window.gtag)return;e=e||s("newspack_modal_checkout");const o=t("dismissed",e);n(o)},l=newspackBlocksModal.newspack_class_prefix,d="newspack_modal_checkout_iframe",u="newspack_modal_checkout_container",p=`${l}__modal`,m="newspack-blocks__modal-variation",_=`${l}__processing-payment-text`,h=newspackBlocksModal.processing_payment_messages;let y=!1,k=newspackBlocksModal.labels.checkout_modal_title,w=null;const f=e=>{e.overlayId&&window.newspackReaderActivation?.overlays&&window.newspackReaderActivation?.overlays.remove(e.overlayId),e.setAttribute("data-state","closed"),document.body.style.overflow="auto"};window.onpageshow=e=>{e.persisted&&(document.querySelectorAll(".modal-processing").forEach(e=>e.classList.remove("modal-processing")),document.querySelectorAll(".non-modal-checkout-loading").forEach(e=>e.classList.remove("non-modal-checkout-loading")),document.querySelectorAll(`.${p}-container`).forEach(e=>f(e)))};const v=new CustomEvent("checkout-closed");var g;window.newspackRAS=window.newspackRAS||[],g=()=>{const t=document.querySelector("#newspack_modal_checkout");if(!t)return;const o=t.querySelector(`.${p}__content`),n=a("modal_checkout","1"),g=o.querySelector(`.${l}__spinner`);let b=document.querySelector(".newspack-reader__account-link")?.[0];const S="600px",E=document.createElement("iframe");E.name=d,E.style.height=S,E.style.visibility="hidden";const A=e=>{M.observe(e),"none"!==g.style.display&&(g.style.display="none"),"visible"!==E.style.visibility&&(E.style.visibility="visible"),E._ready=!0};!function(e,t,o){e._ready=!1,e._readyTimer&&clearTimeout(e._readyTimer);let n=!1,c="";function a(){n||(n=!0,clearTimeout(e._readyTimer),t.call(this))}function r(){"complete"===this.readyState&&a.call(this)}function s(){e._ready=!1,o&&o(),e._readyTimer&&clearTimeout(e._readyTimer);const t=e.contentDocument||e.contentWindow?.document;t&&(t.removeEventListener("DOMContentLoaded",a),t.removeEventListener("readystatechange",r))}function i(){if(e._ready)return void s();const t=e.contentDocument||e.contentWindow?.document;t&&0!==t.URL.indexOf("about:")?"complete"===t?.readyState?a.call(t):(t.addEventListener("DOMContentLoaded",a),t.addEventListener("readystatechange",r)):e._readyTimer=setTimeout(i,10)}e._observer||(e._observer=new MutationObserver(e=>{e.forEach(e=>{"attributes"===e.type&&"src"===e.attributeName&&(n=!1,s(),i())})}),e._observer.observe(e,{attributes:!0})),e._locationObserver||(e._locationObserver=setInterval(function(){const t=e.contentDocument||e.contentWindow?.document;t&&t.URL!==c&&(c=t.URL,n=!1,s(),i())},50)),i()}(E,function(){const o=E.contentWindow?.location;if(window.newspackReaderActivation&&o?.href?.includes("order-received")){const e=window.newspackReaderActivation,t=new Proxy(new URLSearchParams(o.search),{get:(e,t)=>e.get(t)});t.email&&(e.setReaderEmail(t.email),e.setAuthenticated(!0))}const n=E?.contentDocument?.querySelector(`#${u}`);if(!n)return;const c=n.querySelector("#modal-checkout-product-details"),a=s(c),r=document.createElement("p");r.classList.add(_);let i=[];const l=()=>{i.forEach(e=>clearTimeout(e)),i=[]},d=()=>{g.style.display="none",l(),g.querySelectorAll(`.${_}`).forEach(e=>e.remove())};!function(e,t){e.checkoutCancel?t():e.addEventListener("checkout-cancel",t)}(n,()=>{C()}),function(e,t){e.checkoutPlaceOrderStart?t():e.addEventListener("checkout-place-order-start",t)}(n,e=>{var t;g.querySelectorAll(`.${_}`).forEach(e=>e.remove()),g.style.display="flex",l(),r.textContent=null!==(t=h[0]?.text)&&void 0!==t?t:"",h.slice(1).forEach(({text:t,delay:o})=>{const n=setTimeout(()=>{e.target.dispatchEvent(new CustomEvent("checkout-place-order-processing")),r.textContent=t},o);i.push(n)}),g.appendChild(r)}),function(e,t){e.checkoutPlaceOrderError?t():e.addEventListener("checkout-place-order-error",t)}(n,d),function(e,t){e.checkoutReady?t():e.addEventListener("checkout-ready",t)}(n,()=>{const e=c?.querySelector("strong");if(e&&(e.textContent=a.price_summary),t.initialErrors){const e=document.createElement("div");e.classList.add("woocommerce-error"),e.textContent=t.initialErrors,n.prepend(e),delete t.initialErrors}P(),O(k),E.contentWindow?.newspackBlocksModalCheckout?.checkout_nonce&&(t.checkout_nonce=E.contentWindow.newspackBlocksModalCheckout.checkout_nonce),A(n)}),function(e,t){e.checkoutComplete?t():e.addEventListener("checkout-complete",t)}(n,()=>{window.newspackRAS.push(["checkout_completed",a]),window?.newspackReaderActivation?.refreshNewslettersSignupModal&&window?.newspackReaderActivation?.getReader()?.email&&window.newspackReaderActivation.refreshNewslettersSignupModal(window.newspackReaderActivation.getReader().email),P("small"),O(newspackBlocksModal.labels.thankyou_modal_title),A(n),e(t.querySelector(`.${p}`)),d()}),function(e,t){e.checkoutPlaceOrderCriticalError?t():e.addEventListener("checkout-place-order-critical-error",t)}(n,()=>{var e;(e=w)&&(C(),g.style.display="none",t.initialErrors=newspackBlocksModal.labels.critical_error,e.requestSubmit(e.querySelector('button[type="submit"]')),d())})},()=>{g.style.display="flex"});const q=e=>new Promise((t,o)=>{const n=new URLSearchParams(e);n.append("action","modal_checkout_request"),fetch(newspackBlocksModal.ajax_url+"?"+n.toString()).then(e=>{e.ok||o(e),e.json().then(e=>{t(e.url)}).catch(o)}).catch(o)}),L=()=>"undefined"!=typeof newspack_ras_config&&!newspack_ras_config?.is_logged_in&&!window?.newspackReaderActivation?.getReader?.()?.authenticated&&newspackBlocksModal?.is_registration_required&&window?.newspackReaderActivation?.openAuthModal,$=t=>{const o=!newspackBlocksModal.has_unsupported_payment_gateway;o||t.preventDefault();const n=t.target;n.classList.add("modal-processing");const u=s(n);if(u.newspack_donate){const e=u.donation_frequency,t=[...n.querySelectorAll(`.donation-tier__${e}, .donation-frequency__${e}`)],o=u.donation_tier_index;let c,a;o?(c=t[o],a=u[`donation_value_${e}`]):(c=t[0],u[`donation_value_${e}_untiered`]?a=u[`donation_value_${e}_untiered`]:(a=u[`donation_value_${e}`],"other"===a&&(a=u[`donation_value_${e}_other`])));const r=s(c);for(const e in r)u[e]=r[e];u.amount=a,u.price_summary=u.summary_template.replace("{{PRICE}}",function(e,t="USD"){return parseFloat(e).toLocaleString(document.documentElement.lang,{style:"currency",currency:t,currencyDisplay:"narrowSymbol"})}(u.amount,u.currency))}u&&Object.keys(u).forEach(e=>{0===n.querySelectorAll('input[name="'+e+'"]').length&&n.prepend(a(e,u[e]))}),u.variation_id||(b=t.submitter);const p=document.querySelectorAll(`.${m}`);if(p.forEach(e=>{(L()||o)&&f(e)}),u.is_grouped||u.is_variable&&!u.variation_id){const o=[...p].find(e=>e.dataset.productId===u.product_id);if(o)return o.querySelectorAll(`form[target="${d}"]`).forEach(e=>{["after_success_behavior","after_success_url","after_success_button_label","gate_post_id","newspack_popup_id","prompt_title"].forEach(t=>{0===e.querySelectorAll('input[name="'+t+'"]').length&&e.prepend(a(t,u[t]))});const t=e.dataset.checkout;if(t){const o=JSON.parse(t);Object.keys(o).forEach(t=>{0===e.querySelectorAll('input[name="'+t+'"]').length&&e.prepend(a(t,o[t]))})}}),t.preventDefault(),n.classList.remove("modal-processing"),B(o),e(o,!1),y||c(u),void document.getElementById("newspack_modal_checkout").setAttribute("data-checkout",JSON.stringify(u))}if(o||L()){if(n.classList.remove("modal-processing"),y||c(u),y=!0,L()){t.preventDefault();const e=u.price_summary,n=e?`<div class="order-details-summary ${l}__box ${l}__box--text-center"><p><strong>${e}</strong></p></div>`:"",c=q(u);c.then(e=>{window.newspackReaderActivation?.setPendingCheckout?.(e)}),window.newspackReaderActivation.openAuthModal({title:newspackBlocksModal.labels.auth_modal_title,onSuccess:(e,t)=>{c.then(e=>{t?.registered&&o&&(e+=`&${newspackBlocksModal.checkout_registration_flag}=1`),o?r(R(e)):q(u).then(window.location.href=e)}).catch(e=>{console.warn("Unable to generate cart:",e),C()})},onError:()=>{C()},onDismiss:()=>{i(u),y=!1,document.getElementById("newspack_modal_checkout").removeAttribute("data-checkout")},skipSuccess:!0,skipNewslettersSignup:!0,labels:{signin:{title:newspackBlocksModal.labels.signin_modal_title},register:{title:newspackBlocksModal.labels.register_modal_title}},content:n,trigger:t.submitter,closeOnSuccess:o})}else x(),document.getElementById("newspack_modal_checkout").setAttribute("data-checkout",JSON.stringify(u));w=n}else q(u).then(e=>{window.location.href=e}),(!u.is_variable||u.variation_id)&&n.querySelectorAll("button[type=submit]:focus").forEach(e=>{e.classList.add("non-modal-checkout-loading");const t=e.innerHTML;e.innerHTML="<span>"+t+"</span>"})},R=e=>{const t=document.createElement("form");t.method="POST",t.action=e,t.target=d,t.style.display="none";const o=document.createElement("button");return o.setAttribute("type","submit"),t.appendChild(o),document.body.appendChild(t),t.addEventListener("submit",$),t},M=new ResizeObserver(e=>{if(!e||!e.length)return;if(!E.contentDocument)return;const n=e[0].contentRect;if(n){const e=.01*Math.max(document.documentElement.clientHeight,window.innerHeight||0)*90-(t.querySelector(`.${p}__header`)?.offsetHeight||0),c=n.top+n.bottom,a=Math.min(c,e);if(0===a)return void(E.style.visibility="hidden");o.style.height=a+"px",E.style.height=a+"px"}}),C=()=>{const e=E?.contentDocument?.querySelector(`#${u}`),n=e?.querySelector('input[name="after_success_url"]'),c=e?.querySelector('input[name="after_success_behavior"]'),a=document?.querySelector(".newspack-newsletters-signup-modal"),r=s(e?.querySelector("#modal-checkout-product-details"));e?.checkoutComplete||(async()=>{const e=new FormData;newspackBlocksModal.has_unsupported_payment_gateway||e.append("modal_checkout","1"),e.append("action","abandon_modal_checkout"),e.append("_wpnonce",t.checkout_nonce),t.checkout_nonce=null;try{await fetch(newspackBlocksModal.ajax_url,{method:"POST",body:e})}catch(e){console.warn("Unable to empty cart:",e)}})();const l=!(E.contentDocument&&n&&c&&e?.checkoutComplete);if((l||a)&&(g.style.display="flex",E&&o.contains(E)&&(E._ready=!1,E.src="about:blank",E.style.height=S,E.style.visibility="hidden",o.style.height=S,o.removeChild(E)),M&&M.disconnect(),document.querySelectorAll(`.${p}-container`).forEach(e=>f(e)),b&&b.focus(),document.dispatchEvent(v)),e?.checkoutComplete){const e=()=>{if(n&&c){const e=n.getAttribute("value"),t=c.getAttribute("value");"custom"===t?window.location.href=e:"referrer"===t&&window.history.back()}window?.newspackReaderActivation?.setPendingCheckout?.(),y=!1};"subscription_switch"!==r.action_type&&window?.newspackReaderActivation?.openNewslettersSignupModal?window.newspackReaderActivation.openNewslettersSignupModal({onSuccess:e,onError:e,closeOnSuccess:l}):e(),l&&(k=newspackBlocksModal.labels.checkout_modal_title,P(),O(k))}else window?.newspackReaderActivation?.setPendingCheckout?.(),i(),y=!1,document.getElementById("newspack_modal_checkout").removeAttribute("data-checkout");document.removeEventListener("keydown",D)},x=n=>{n&&(E.src=n),g.style.display="flex",B(t),o.appendChild(E),t.addEventListener("click",e=>{e.target===t&&C()}),e(t,E),document.addEventListener("keydown",D)},B=e=>{window.newspackReaderActivation?.overlays&&(e.overlayId=window.newspackReaderActivation?.overlays.add()),e.setAttribute("data-state","open"),document.body.style.overflow="hidden"},O=e=>{const o=t.querySelector(`.${p}__header h2`);o&&(o.innerText=e)},P=(e="default")=>{const o=t.querySelector(`.${p}`);o&&("small"===e?o.classList.add(`${p}--small`):o.classList.remove(`${p}--small`))};t.querySelectorAll(`.${p}__close`).forEach(e=>{e.addEventListener("click",e=>{e.preventDefault(),C()})}),document.querySelectorAll(".newspack-blocks__modal-variation").forEach(e=>{e.addEventListener("click",t=>{t.target===e&&C()}),e.querySelectorAll(`.${p}__close`).forEach(e=>{e.addEventListener("click",e=>{e.preventDefault(),C()})})});const D=e=>{"Escape"===e.key&&C()};document.querySelectorAll(".wpbnbd.wpbnbd--platform-wc, .wp-block-newspack-blocks-checkout-button, .newspack-blocks__modal-variation").forEach(e=>{e.querySelectorAll("form").forEach(e=>{newspackBlocksModal.has_unsupported_payment_gateway||e.prepend(n.cloneNode()),e.target=d,e.addEventListener("submit",$)})}),(()=>{const e=new URLSearchParams(window.location.search);if(!e.has("checkout"))return;const t=e.get("type");if("donate"===t){const t=e.get("layout"),o=e.get("frequency"),n=e.get("amount"),c=e.get("other");t&&o&&n&&((e,t,o,n=null)=>{let c;document.querySelectorAll(".wpbnbd.wpbnbd--platform-wc form").forEach(a=>{const r=a.querySelector(`input[name="donation_frequency"][value="${t}"]`);if(r)if("tiered"===e){const e=document.querySelector(`button[data-frequency-slug="${t}"]`);if(!e)return;e.click();const n=a.querySelector(`button[type="submit"][name="donation_value_${t}"][value="${o}"]`);if(!n)return;n.click()}else{const s="untiered"===e?a.querySelector(`input[name="donation_value_${t}_untiered"]`):a.querySelector(`input[name="donation_value_${t}"][value="${o}"]`);if(r&&s){if(r.checked=!0,"untiered"===e)s.value=o;else if("other"===o){s.click();const e=a.querySelector(`input[name="donation_value_${t}_other"]`);e&&n&&(e.value=n)}else s.checked=!0;c=a}}}),c&&r(c)})(t,o,n,c)}else if("checkout_button"===t){const t=e.get("product_id"),o=e.get("variation_id");t&&((e,t=null)=>{let o;if(t&&t!==e){const n=[...document.querySelectorAll(`.${m}`)].find(t=>t.dataset.productId===e);n&&n.querySelectorAll(`form[target="${d}"]`).forEach(e=>{const n=JSON.parse(e.dataset.checkout);n?.variation_id===Number(t)&&(o=e)})}else document.querySelectorAll(".wp-block-newspack-blocks-checkout-button").forEach(t=>{const n=t.querySelector("form");if(!n)return;const c=JSON.parse(n.dataset.checkout);c?.product_id===e&&(o=n)});o&&r(o)})(t,o)}else{const e=window.newspackReaderActivation?.getPendingCheckout?.();e&&r(R(e))}window.history.replaceState(null,null,window.location.pathname)})(),window.newspackOpenModalCheckout=({url:e=null,title:t=null,actionType:o=null,afterSuccess:n={},onCheckoutComplete:c=null,onClose:a=null})=>{if(k=t||newspackBlocksModal.labels.checkout_modal_title,O(k),(e=new URL(e||newspackBlocksModal.checkout_url)).searchParams.has("my_account_checkout")&&e.searchParams.delete("my_account_checkout"),e.searchParams.has("modal_checkout")||e.searchParams.set("modal_checkout","1"),o&&e.searchParams.set("action_type",o),n?.url&&e.searchParams.set("after_success_url",n.url),(n?.behavior||n?.url)&&e.searchParams.set("after_success_behavior",n.behavior||"custom"),n?.buttonLabel&&e.searchParams.set("after_success_button_label",n.buttonLabel),c){const e=({detail:{action:e,data:t}})=>{"checkout_completed"===e&&c(t)};window.newspackRAS.push(t=>{t.on("activity",e);const o=()=>{t.off("activity",e),document.removeEventListener("checkout-closed",o)};document.addEventListener("checkout-closed",o)})}if(a){const e=()=>{a(),document.removeEventListener("checkout-closed",e)};document.addEventListener("checkout-closed",e)}x(e.toString())},window.newspackCloseModalCheckout=C},"undefined"!=typeof document&&("complete"!==document.readyState&&"interactive"!==document.readyState?document.addEventListener("DOMContentLoaded",g):g())})();
@@ -1 +1 @@
1
- <?php return array('dependencies' => array(), 'version' => '5ad0fd2d2cb957581c5f');
1
+ <?php return array('dependencies' => array(), 'version' => '6a2115d099f500aa1a7a');
@@ -1 +1 @@
1
- (()=>{"use strict";const e=(e,t={})=>({...t,action:e}),t=["action","action_type","amount","currency","product_id","product_type","variation_id","variation_ids","is_variable","is_grouped","child_ids","price_summary","newspack_popup_id","gate_post_id","recurrence","referrer"],o=(e,o="np_modal_checkout_interaction")=>{if("function"==typeof window.gtag&&e){const c={};for(const o of t)e[o]&&("boolean"==typeof e[o]?e[o]=e[o]?"yes":"no":"true"===e[o]?e[o]="yes":"false"===e[o]&&(e[o]="no"),c[o]=e[o].toString());window.gtag("event",o,c)}};function c(e){"undefined"!=typeof document&&"function"==typeof e&&("complete"!==document.readyState&&"interactive"!==document.readyState?document.addEventListener("DOMContentLoaded",e):e())}function n(e){const t="string"==typeof e?document.getElementById(e):e;if(!t)return console.warn("No container found for checkout data"),{};let o={};if("FORM"===t.tagName){const e=new FormData(t);o=Object.fromEntries(e)}const c=t.dataset.checkout;if(!c)return console.warn("No checkout data found"),o;try{o={...o,...JSON.parse(c)}}catch(e){console.warn("Error parsing checkout data")}const n=new URL(t.ownerDocument.defaultView.location.href);return n.searchParams.get("action_type")&&(o.action_type=n.searchParams.get("action_type")),o}const i=(t="continue")=>{if("function"!=typeof window.gtag)return;const{action_type:c,amount:i,currency:r,product_id:s,product_type:a,recurrence:d,referrer:u,variation_id:l="",gate_post_id:p="",newspack_popup_id:_=""}=n("modal-checkout-product-details"),h={action_type:c,amount:i,currency:r,product_id:s,product_type:a,recurrence:d,referrer:u};l&&(h.variation_id=l),p&&(h.gate_post_id=p),_&&(h.newspack_popup_id=_);const m=e(t,h);o(m)};var r;r=jQuery,c(()=>{if(!r)return void console.warn("jQuery is not available.");const t=document.querySelector("#newspack_modal_checkout_container"),s=newspackBlocksModalCheckout.newspack_class_prefix,a=new CustomEvent("checkout-ready"),d=new CustomEvent("checkout-complete"),u=new CustomEvent("checkout-cancel"),l=new CustomEvent("checkout-place-order-start"),p=new CustomEvent("checkout-place-order-success"),_=new CustomEvent("checkout-place-order-error"),h=new CustomEvent("checkout-place-order-critical-error");function m(){r(".woocommerce-notices-wrapper").empty(),r(`.woocommerce-NoticeGroup-checkout, .${s}__inline-error, .woocommerce-error, .woocommerce-message, .wc-block-components-notice-banner`).remove()}function f(i=!0){t.checkoutReady=!0,t.dispatchEvent(a),i&&c(function(){if("function"!=typeof window.gtag)return;const t=n("modal-checkout-product-details"),c=e("loaded",t);o(c)})}if(newspackBlocksModalCheckout.is_checkout_complete)(()=>{if("function"!=typeof window.gtag)return;const t=n("modal-checkout-product-details"),c=e("form_submission_success",t);o(c)})(),t&&(t.checkoutComplete=!0,t.dispatchEvent(d));else{function g(){r("#wcpay-express-checkout-button-separator, #wc-stripe-payment-request-button-separator, #wc-stripe-express-checkout-button-separator").after('<div class="newspack-ui__word-divider">'+newspackBlocksModalCheckout.divider_text+"</div>");let c=[];const a=r("form.checkout"),d=r("#checkout_cancel");if(d.length&&d.on("click",function(){t.dispatchEvent(u)}),!a.length)return console.warn("Checkout form is not available"),void f();const g=r("form.modal_checkout_coupon"),w=r("form.modal_checkout_nyp"),v=r("#checkout_continue"),b=r("#customer_details"),y=r("#after_customer_details"),C=r(".newspack-wcsg--wrapper");function E(){const e=r('input[name="payment_method"]:checked').val();r(".wc_payment_method").removeClass("selected"),r(".wc_payment_method.payment_method_"+e).addClass("selected")}r('input[name="payment_method"]').change(E),r(document).on("payment_method_selected",E),r(document).on("updated_checkout",E),E();let x=!1;function M(){let e;if(r.ajax({url:newspackBlocksModalCheckout.ajax_url,method:"POST",async:!1,data:{action:"get_cart_total"},success:t=>{e=t}}),e)return e}if(a.on("checkout_place_order",function(){x||(x=!0,t.dispatchEvent(l))}),function(e,t){e.checkoutPlaceOrderProcessing?t():e.addEventListener("checkout-place-order-processing",t)}(t,function(){x&&(a.is(".processing")||(x=!1,t.dispatchEvent(_)))}),a.on("checkout_place_order_success",function(){x=!1,t.dispatchEvent(p)}),r(document.body).on("checkout_error",function(e,o){x&&(x=!1,o&&o.indexOf(newspackBlocksModalCheckout.labels.critical_error)>=0?t.dispatchEvent(h):t.dispatchEvent(_))}),a.on("update_checkout",function(){x&&(x=!1,t.dispatchEvent(_))}),r(document).on("updated_checkout",function(){r("#payment .wc_payment_methods").length?r("#after_customer_details > h3").show():r("#after_customer_details > h3").hide()}),r(document).on("updated_checkout",function(){const e=r(".order-review-wrapper");if(!e.length)return;const t=e.find("table");t.is(".empty")?e.addClass("hidden"):(t.unblock(),e.removeClass("hidden"));const o=r("#after_customer_details").hasClass("transaction-details-expanded"),c=r(".payment_methods");if(c.length){const t=e.clone();o&&r('[id="order_review_heading"]',t).attr("aria-expanded","true"),r(".order-review-wrapper").remove(),c.after(t)}else o||e.find("#order_review_heading").trigger("click")}),r(document).on("click","#order_review_heading",function(){r(this).attr("aria-expanded",function(e,t){return"false"===t?"true":"false"}),r("#after_customer_details").toggleClass("transaction-details-expanded")}),r(document).on("updated_checkout",function(){let e=newspackBlocksModalCheckout.labels.complete_button;if(e){if(r("#place_order").has(r("span.cart-price"))){const t=r("<div>"+e+"</div>");t.find(".cart-price").html(M,function(){return this.childNodes}),e=t.html()}r("#place_order").html(e),r("#place_order_clone").html(e)}}),C.length){const e=C.find(".newspack-wcsg--gift-toggle input"),t=C.find(".newspack-wcsg--gift-email");e.on("change",function(){e.is(":checked")?t.addClass("visible"):t.removeClass("visible")})}function $(e){a.find(".input-text, select, input:checkbox").trigger("validate").trigger("blur");let t=!1;const o=[],c=e=>{const c=r("#"+e.data("id")+"_field");if(c?.length){t||(t=c);const o=c.find(".woocommerce-error");o.length&&o.remove(),c.addClass("woocommerce-invalid").removeClass("woocommerce-valid"),c.append(`<span class="${s}__inline-error">`+e.text()+"</span>"),e.remove()}else e.is("li")||(e=r("<li />").append(e)),o.push(e)};if(m(),0!==e.trimStart().indexOf("<")?c(r("<li />").append(e)):e.includes("<li")?r(e).find("li").each(function(){c(r(this))}):c(r(e)),o.length){t=!1;const e=r('<div class="woocommerce-NoticeGroup woocommerce-NoticeGroup-checkout"/>').append(r('<ul class="woocommerce-error" role="alert" />').append(o));a.prepend(e),e.get(0).scrollIntoView({behavior:"smooth"})}t?.length&&(window.scroll({top:t.offset().top-100,left:0,behavior:"smooth"}),t.find("input.input-text, select, input:checkbox").trigger("focus")),P(a),r(document.body).trigger("update_checkout"),r(document.body).trigger("checkout_error",[e])}function O(e){e.preventDefault(),e.stopImmediatePropagation(),B(),i("continue")}function N(e){const t=window.newspack_grecaptcha||{};if(m(),r("#checkout_details").remove(),e)a.attr("data-skip-recaptcha","1"),a.append('<input name="is_validation_only" type="hidden" value="1" />'),"v3"===t?.version&&t.destroy(a.get()),g.length&&g.hide(),w.length&&w.hide(),b.show(),y.hide(),b.find("input").first().focus(),c=function(e,t){const o=r._data(e,"events");return o?t?o[t]||[]:o:[]}(a[0],"submit").slice(0),c.forEach(e=>{a.off("submit",e.handler)}),a.on("submit",O);else{a.removeAttr("data-skip-recaptcha");const e=a.find('[name="is_validation_only"]');if(e.length&&e.remove(),t?.render){a.data("newspack-recaptcha","newspack_modal_checkout");const e=()=>{m(),a.get(0).scrollIntoView({behavior:"smooth"})},o=e=>$(e);t.render(a.get(),e,o),r(document).on("updated_checkout",()=>t.render(a.get(),e,o)),r(document.body).on("checkout_error",()=>t.render(a.get(),e,o))}g.length&&g.show(),w.length&&w.show(),b.hide(),y.show(),function(){r("#checkout_details").remove();const e={};a.serializeArray().forEach(t=>{e[t.name]=t.value});const t=`${newspackBlocksModalCheckout.newspack_class_prefix}__font--xs`,o=[];o.push('<div class="billing-details">'),o.push("<h3>"+newspackBlocksModalCheckout.labels.billing_details+"</h3>"),(e.billing_first_name||e.billing_last_name)&&o.push(`<p class="${t}">`+e.billing_first_name+" "+e.billing_last_name+"</p>"),e.billing_company&&o.push(`<p class="${t}">`+e.billing_company+"</p>");let c="";if((e.billing_address_1||e.billing_address_2)&&(c=`<p class="${t}">`,e.billing_address_1&&(c+=e.billing_address_1),e.billing_address_2&&(c+=" "+e.billing_address_2),c+="<br>",e.billing_city&&(c+=e.billing_city),e.billing_state&&(c+=", "+e.billing_state),e.billing_postcode&&(c+=" "+e.billing_postcode),c+="<br>",e.billing_country&&(c+=e.billing_country)),o.push(c),e.billing_email&&o.push(`<p class="${t}">`+e.billing_email+"</p>"),o.push("</div>"),e.hasOwnProperty("shipping_address_1")){o.push('<div class="shipping-details">'),o.push("<h3>"+newspackBlocksModalCheckout.labels.shipping_details+"</h3>");let n="";e.ship_to_different_address?(n=`<p class="${t}">`,e.shipping_address_1&&(n+=e.shipping_address_1),e.shipping_address_2&&(n+=" "+e.shipping_address_2),n+="<br>",e.shipping_city&&(n+=e.shipping_city),e.shipping_state&&(n+=", "+e.shipping_state),e.shipping_postcode&&(n+=" "+e.shipping_postcode),n+="<br>",e.shipping_country&&(n+=e.shipping_country)):n=c,o.push(n),o.push("</div>")}e.hasOwnProperty("newspack_wcsg_is_gift")&&e.hasOwnProperty("wcsg_gift_recipients_email")&&e.newspack_wcsg_is_gift&&e.wcsg_gift_recipients_email&&(o.push('<div class="gift-details">'),o.push("<h3>"+newspackBlocksModalCheckout.labels.gift_recipient+"</h3>"),o.push(`<p class="${t}">`+e.wcsg_gift_recipients_email+"</p>")),r(".order-details-summary").after('<div id="checkout_details">'+o.join("")+"</div>")}(),a.off("submit",O),c.forEach(e=>{a.on("submit",e.handler)}),k()}a.triggerHandler("editing_details",[e]),window.scroll({top:0,left:0,behavior:"smooth"})}function B(e=!1,t=()=>{}){if(!L(a))return console.warn("Unable to block the form"),t(),!1;m();const o=a.find(".woocommerce-NoticeGroup.woocommerce-NoticeGroup-checkout");o.length&&o.remove();const c=["save_user_in_woopay"],n=a.serializeArray().filter(e=>!c.includes(e.name));n.push({name:"woocommerce_checkout_update_totals",value:"1"}),r.ajax({type:"POST",url:wc_checkout_params.checkout_url,data:n,dataType:"html",success:o=>{let c;try{c=JSON.parse(o)}catch(e){c={messages:'<div class="woocommerce-error">'+wc_checkout_params.i18n_checkout_error+"</div>"}}e||!0!==c.reload?(P(a),c.messages?e||(c.messages?$(c.messages):$(`<div class="${s}__inline-error">`+wc_checkout_params.i18n_checkout_error+"</div>")):(N(!1),r._data(a[0],"events")?.click?.some(e=>"#checkout_edit_billing"===e.selector)||a.on("click","#checkout_edit_billing",function(e){e.preventDefault(),N(!0),i("back")})),t(c)):window.location.reload()},error:(o,c,n)=>{let i="";e||(i='<div class="woocommerce-error">'+(n||wc_checkout_params.i18n_checkout_error)+"</div>",$(i)),t({messages:i})}})}function L(e){return!e.is(".modal-processing")&&(e.find("button[type=submit]").each((e,t)=>{r(t).attr("disabled",!0)}),e.addClass("modal-processing"),!0)}function P(e){return!!e.is(".modal-processing")&&(e.find("button[type=submit]").each((e,t)=>{r(t).attr("disabled",!1)}),e.removeClass("modal-processing"),!0)}v.length?(N(!0),C.length?f():B(!0,f)):f(),g.length&&(g.on("submit",function(e){if(e.preventDefault(),!L(g))return!1;const t={security:wc_checkout_params.apply_coupon_nonce,coupon_code:g.find('input[name="coupon_code"]').val()};r.ajax({type:"POST",url:wc_checkout_params.wc_ajax_url.toString().replace("%%endpoint%%","apply_coupon"),data:t,dataType:"html",success:e=>{if(m(),g.find(".result").remove(),e){const o=e.includes("error");g.append(`<p class="result ${s}__helper-text ${o?s+"__inline-error":""}">`+r(e).text()+"</p>"),o?(g.find('input[name="coupon_code"]').focus(),g.find('h3, input[name="coupon_code"]').addClass("newspack-ui__field-error")):(g.find('input[name="coupon_code"]').focus(),g.find('h3, input[name="coupon_code"]').removeClass("newspack-ui__field-error")),r(document.body).trigger("applied_coupon_in_checkout",[t.coupon_code]),r(document.body).trigger("update_checkout",{update_shipping_method:!1})}},complete:()=>{P(g)}})}),r(document.body).on("removed_coupon_in_checkout",()=>{m(),g.find(".result").remove(),g.find('input[name="coupon_code"]').val("").focus()})),w.length&&w.on("submit",function(e){if(e.preventDefault(),!L(w))return!1;const t=w.find('input[name="price"]');t.attr("disabled",!0);const o={_ajax_nonce:newspackBlocksModalCheckout.nyp_nonce,action:"process_name_your_price_request",price:w.find('input[name="price"]').val(),product_id:w.find('input[name="product_id"]').val(),newspack_checkout_name_your_price:w.find('input[name="newspack_checkout_name_your_price"]').val()};r.ajax({type:"POST",url:newspackBlocksModalCheckout.ajax_url,data:o,success:({success:e,data:t})=>{m(),w.find(".result").remove(),w.append(`<p class="result ${s}__helper-text ${e?"":s+"__inline-error"}">`+t.message+"</p>"),e?w.find('h3, input[name="price"]').removeClass("newspack-ui__field-error"):(w.find('input[name="price"]').focus(),w.find('h3, input[name="price"]').addClass("newspack-ui__field-error")),r(document.body).trigger("update_checkout",{update_shipping_method:!1})},complete:()=>{P(w),t.attr("disabled",!1),t.focus()}})}),a.on("click","#place_order",function(){(()=>{if("function"!=typeof window.gtag)return;const t=n("modal-checkout-product-details"),c=e("form_submission",t);o(c)})()});const S=function(){if(!t)return;const e="data-newspack-error-handled",o=o=>{o.hasAttribute(e)||(o.setAttribute(e,"true"),r(o).addClass(`${s}__notice ${s}__notice--error`),t.dispatchEvent(_),o.scrollIntoView({behavior:"smooth",block:"center"}))},c=e=>!!e.classList?.contains("woocommerce-error")||!(!e.classList?.contains("wc-block-components-notice-banner")||!e.classList?.contains("is-error")),n=new MutationObserver(e=>{for(const t of e)for(const e of t.addedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;if(c(e))return void o(e);const t=e.querySelector?.(".woocommerce-error, .wc-block-components-notice-banner.is-error");if(t)return void o(t)}});return n.observe(t,{childList:!0,subtree:!0}),n}();if(S){const e=()=>S.disconnect();t.addEventListener("checkout-complete",e),t.addEventListener("checkout-cancel",e),window.addEventListener("beforeunload",e)}}g()}function k(){const e=r("#newspack_subscription_terms_confirmation, #newspack_subscription_confirmation");if(e.length){const t=r("form.checkout"),o=t.find("button#place_order, button#place_order_clone");function c(){const t=e.is(":checked");o.each((e,o)=>{r(o).attr("disabled",!t)})}c(),e.on("change",c),t.on("submit",function(t){if(!e.is(":checked"))return t.preventDefault(),t.stopPropagation(),!1})}}r(document.body).on("updated_checkout payment_method_selected checkout_error",k),r(document).ready(k),r(document.body).on("checkout_error",function(){const e=r(".woocommerce-NoticeGroup-checkout, .woocommerce-notices-wrapper");e.length&&e.each((e,t)=>r(t).addClass(`${s}__notice ${s}__notice--error`));const t=r("#checkout_error_back");t.length&&t.on("click",e=>{e.preventDefault(),parent.newspackCloseModalCheckout()}),f(!1)}),document.addEventListener("keydown",function(e){"Escape"===e.key&&parent.newspackCloseModalCheckout()}),newspackBlocksModalCheckout.is_error&&r(document.body).trigger("checkout_error")})})();
1
+ (()=>{"use strict";const e=(e,t={})=>({...t,action:e}),t=["action","action_type","amount","currency","product_id","product_type","variation_id","variation_ids","is_variable","is_grouped","child_ids","price_summary","newspack_popup_id","prompt_title","gate_post_id","recurrence","referrer"],o=(e,o="np_modal_checkout_interaction")=>{if("function"==typeof window.gtag&&e){const c={};for(const o of t)e[o]&&("boolean"==typeof e[o]?e[o]=e[o]?"yes":"no":"true"===e[o]?e[o]="yes":"false"===e[o]&&(e[o]="no"),c[o]=e[o].toString());window.gtag("event",o,c)}};function c(e){"undefined"!=typeof document&&"function"==typeof e&&("complete"!==document.readyState&&"interactive"!==document.readyState?document.addEventListener("DOMContentLoaded",e):e())}function n(e){const t="string"==typeof e?document.getElementById(e):e;if(!t)return console.warn("No container found for checkout data"),{};let o={};if("FORM"===t.tagName){const e=new FormData(t);o=Object.fromEntries(e)}const c=t.dataset.checkout;if(!c)return console.warn("No checkout data found"),o;try{o={...o,...JSON.parse(c)}}catch(e){console.warn("Error parsing checkout data")}const n=new URL(t.ownerDocument.defaultView.location.href);return n.searchParams.get("action_type")&&(o.action_type=n.searchParams.get("action_type")),o}const i=(t="continue")=>{if("function"!=typeof window.gtag)return;const{action_type:c,amount:i,currency:r,product_id:s,product_type:a,recurrence:d,referrer:u,variation_id:l="",gate_post_id:p="",newspack_popup_id:_="",prompt_title:h=""}=n("modal-checkout-product-details"),m={action_type:c,amount:i,currency:r,product_id:s,product_type:a,recurrence:d,referrer:u};l&&(m.variation_id=l),p&&(m.gate_post_id=p),_&&(m.newspack_popup_id=_),h&&(m.prompt_title=h);const f=e(t,m);o(f)};var r;r=jQuery,c(()=>{if(!r)return void console.warn("jQuery is not available.");const t=document.querySelector("#newspack_modal_checkout_container"),s=newspackBlocksModalCheckout.newspack_class_prefix,a=new CustomEvent("checkout-ready"),d=new CustomEvent("checkout-complete"),u=new CustomEvent("checkout-cancel"),l=new CustomEvent("checkout-place-order-start"),p=new CustomEvent("checkout-place-order-success"),_=new CustomEvent("checkout-place-order-error"),h=new CustomEvent("checkout-place-order-critical-error");function m(){r(".woocommerce-notices-wrapper").empty(),r(`.woocommerce-NoticeGroup-checkout, .${s}__inline-error, .woocommerce-error, .woocommerce-message, .wc-block-components-notice-banner`).remove()}function f(i=!0){t.checkoutReady=!0,t.dispatchEvent(a),i&&c(function(){if("function"!=typeof window.gtag)return;const t=n("modal-checkout-product-details"),c=e("loaded",t);o(c)})}if(newspackBlocksModalCheckout.is_checkout_complete)(()=>{if("function"!=typeof window.gtag)return;const t=n("modal-checkout-product-details"),c=e("form_submission_success",t);o(c)})(),t&&(t.checkoutComplete=!0,t.dispatchEvent(d));else{function g(){r("#wcpay-express-checkout-button-separator, #wc-stripe-payment-request-button-separator, #wc-stripe-express-checkout-button-separator").after('<div class="newspack-ui__word-divider">'+newspackBlocksModalCheckout.divider_text+"</div>");let c=[];const a=r("form.checkout"),d=r("#checkout_cancel");if(d.length&&d.on("click",function(){t.dispatchEvent(u)}),!a.length)return console.warn("Checkout form is not available"),void f();const g=r("form.modal_checkout_coupon"),w=r("form.modal_checkout_nyp"),v=r("#checkout_continue"),b=r("#customer_details"),y=r("#after_customer_details"),C=r(".newspack-wcsg--wrapper");function E(){const e=r('input[name="payment_method"]:checked').val();r(".wc_payment_method").removeClass("selected"),r(".wc_payment_method.payment_method_"+e).addClass("selected")}r('input[name="payment_method"]').change(E),r(document).on("payment_method_selected",E),r(document).on("updated_checkout",E),E();let x=!1;function M(){let e;if(r.ajax({url:newspackBlocksModalCheckout.ajax_url,method:"POST",async:!1,data:{action:"get_cart_total"},success:t=>{e=t}}),e)return e}if(a.on("checkout_place_order",function(){x||(x=!0,t.dispatchEvent(l))}),function(e,t){e.checkoutPlaceOrderProcessing?t():e.addEventListener("checkout-place-order-processing",t)}(t,function(){x&&(a.is(".processing")||(x=!1,t.dispatchEvent(_)))}),a.on("checkout_place_order_success",function(){x=!1,t.dispatchEvent(p)}),r(document.body).on("checkout_error",function(e,o){x&&(x=!1,o&&o.indexOf(newspackBlocksModalCheckout.labels.critical_error)>=0?t.dispatchEvent(h):t.dispatchEvent(_))}),a.on("update_checkout",function(){x&&(x=!1,t.dispatchEvent(_))}),r(document).on("updated_checkout",function(){r("#payment .wc_payment_methods").length?r("#after_customer_details > h3").show():r("#after_customer_details > h3").hide()}),r(document).on("updated_checkout",function(){const e=r(".order-review-wrapper");if(!e.length)return;const t=e.find("table");t.is(".empty")?e.addClass("hidden"):(t.unblock(),e.removeClass("hidden"));const o=r("#after_customer_details").hasClass("transaction-details-expanded"),c=r(".payment_methods");if(c.length){const t=e.clone();o&&r('[id="order_review_heading"]',t).attr("aria-expanded","true"),r(".order-review-wrapper").remove(),c.after(t)}else o||e.find("#order_review_heading").trigger("click")}),r(document).on("click","#order_review_heading",function(){r(this).attr("aria-expanded",function(e,t){return"false"===t?"true":"false"}),r("#after_customer_details").toggleClass("transaction-details-expanded")}),r(document).on("updated_checkout",function(){let e=newspackBlocksModalCheckout.labels.complete_button;if(e){if(r("#place_order").has(r("span.cart-price"))){const t=r("<div>"+e+"</div>");t.find(".cart-price").html(M,function(){return this.childNodes}),e=t.html()}r("#place_order").html(e),r("#place_order_clone").html(e)}}),C.length){const e=C.find(".newspack-wcsg--gift-toggle input"),t=C.find(".newspack-wcsg--gift-email");e.on("change",function(){e.is(":checked")?t.addClass("visible"):t.removeClass("visible")})}function $(e){a.find(".input-text, select, input:checkbox").trigger("validate").trigger("blur");let t=!1;const o=[],c=e=>{const c=r("#"+e.data("id")+"_field");if(c?.length){t||(t=c);const o=c.find(".woocommerce-error");o.length&&o.remove(),c.addClass("woocommerce-invalid").removeClass("woocommerce-valid"),c.append(`<span class="${s}__inline-error">`+e.text()+"</span>"),e.remove()}else e.is("li")||(e=r("<li />").append(e)),o.push(e)};if(m(),0!==e.trimStart().indexOf("<")?c(r("<li />").append(e)):e.includes("<li")?r(e).find("li").each(function(){c(r(this))}):c(r(e)),o.length){t=!1;const e=r('<div class="woocommerce-NoticeGroup woocommerce-NoticeGroup-checkout"/>').append(r('<ul class="woocommerce-error" role="alert" />').append(o));a.prepend(e),e.get(0).scrollIntoView({behavior:"smooth"})}t?.length&&(window.scroll({top:t.offset().top-100,left:0,behavior:"smooth"}),t.find("input.input-text, select, input:checkbox").trigger("focus")),P(a),r(document.body).trigger("update_checkout"),r(document.body).trigger("checkout_error",[e])}function O(e){e.preventDefault(),e.stopImmediatePropagation(),B(),i("continue")}function N(e){const t=window.newspack_grecaptcha||{};if(m(),r("#checkout_details").remove(),e)a.attr("data-skip-recaptcha","1"),a.append('<input name="is_validation_only" type="hidden" value="1" />'),"v3"===t?.version&&t.destroy(a.get()),g.length&&g.hide(),w.length&&w.hide(),b.show(),y.hide(),b.find("input").first().focus(),c=function(e,t){const o=r._data(e,"events");return o?t?o[t]||[]:o:[]}(a[0],"submit").slice(0),c.forEach(e=>{a.off("submit",e.handler)}),a.on("submit",O);else{a.removeAttr("data-skip-recaptcha");const e=a.find('[name="is_validation_only"]');if(e.length&&e.remove(),t?.render){a.data("newspack-recaptcha","newspack_modal_checkout");const e=()=>{m(),a.get(0).scrollIntoView({behavior:"smooth"})},o=e=>$(e);t.render(a.get(),e,o),r(document).on("updated_checkout",()=>t.render(a.get(),e,o)),r(document.body).on("checkout_error",()=>t.render(a.get(),e,o))}g.length&&g.show(),w.length&&w.show(),b.hide(),y.show(),function(){r("#checkout_details").remove();const e={};a.serializeArray().forEach(t=>{e[t.name]=t.value});const t=`${newspackBlocksModalCheckout.newspack_class_prefix}__font--xs`,o=[];o.push('<div class="billing-details">'),o.push("<h3>"+newspackBlocksModalCheckout.labels.billing_details+"</h3>"),(e.billing_first_name||e.billing_last_name)&&o.push(`<p class="${t}">`+e.billing_first_name+" "+e.billing_last_name+"</p>"),e.billing_company&&o.push(`<p class="${t}">`+e.billing_company+"</p>");let c="";if((e.billing_address_1||e.billing_address_2)&&(c=`<p class="${t}">`,e.billing_address_1&&(c+=e.billing_address_1),e.billing_address_2&&(c+=" "+e.billing_address_2),c+="<br>",e.billing_city&&(c+=e.billing_city),e.billing_state&&(c+=", "+e.billing_state),e.billing_postcode&&(c+=" "+e.billing_postcode),c+="<br>",e.billing_country&&(c+=e.billing_country)),o.push(c),e.billing_email&&o.push(`<p class="${t}">`+e.billing_email+"</p>"),o.push("</div>"),e.hasOwnProperty("shipping_address_1")){o.push('<div class="shipping-details">'),o.push("<h3>"+newspackBlocksModalCheckout.labels.shipping_details+"</h3>");let n="";e.ship_to_different_address?(n=`<p class="${t}">`,e.shipping_address_1&&(n+=e.shipping_address_1),e.shipping_address_2&&(n+=" "+e.shipping_address_2),n+="<br>",e.shipping_city&&(n+=e.shipping_city),e.shipping_state&&(n+=", "+e.shipping_state),e.shipping_postcode&&(n+=" "+e.shipping_postcode),n+="<br>",e.shipping_country&&(n+=e.shipping_country)):n=c,o.push(n),o.push("</div>")}e.hasOwnProperty("newspack_wcsg_is_gift")&&e.hasOwnProperty("wcsg_gift_recipients_email")&&e.newspack_wcsg_is_gift&&e.wcsg_gift_recipients_email&&(o.push('<div class="gift-details">'),o.push("<h3>"+newspackBlocksModalCheckout.labels.gift_recipient+"</h3>"),o.push(`<p class="${t}">`+e.wcsg_gift_recipients_email+"</p>")),r(".order-details-summary").after('<div id="checkout_details">'+o.join("")+"</div>")}(),a.off("submit",O),c.forEach(e=>{a.on("submit",e.handler)}),k()}a.triggerHandler("editing_details",[e]),window.scroll({top:0,left:0,behavior:"smooth"})}function B(e=!1,t=()=>{}){if(!L(a))return console.warn("Unable to block the form"),t(),!1;m();const o=a.find(".woocommerce-NoticeGroup.woocommerce-NoticeGroup-checkout");o.length&&o.remove();const c=["save_user_in_woopay"],n=a.serializeArray().filter(e=>!c.includes(e.name));n.push({name:"woocommerce_checkout_update_totals",value:"1"}),r.ajax({type:"POST",url:wc_checkout_params.checkout_url,data:n,dataType:"html",success:o=>{let c;try{c=JSON.parse(o)}catch(e){c={messages:'<div class="woocommerce-error">'+wc_checkout_params.i18n_checkout_error+"</div>"}}e||!0!==c.reload?(P(a),c.messages?e||(c.messages?$(c.messages):$(`<div class="${s}__inline-error">`+wc_checkout_params.i18n_checkout_error+"</div>")):(N(!1),r._data(a[0],"events")?.click?.some(e=>"#checkout_edit_billing"===e.selector)||a.on("click","#checkout_edit_billing",function(e){e.preventDefault(),N(!0),i("back")})),t(c)):window.location.reload()},error:(o,c,n)=>{let i="";e||(i='<div class="woocommerce-error">'+(n||wc_checkout_params.i18n_checkout_error)+"</div>",$(i)),t({messages:i})}})}function L(e){return!e.is(".modal-processing")&&(e.find("button[type=submit]").each((e,t)=>{r(t).attr("disabled",!0)}),e.addClass("modal-processing"),!0)}function P(e){return!!e.is(".modal-processing")&&(e.find("button[type=submit]").each((e,t)=>{r(t).attr("disabled",!1)}),e.removeClass("modal-processing"),!0)}v.length?(N(!0),C.length?f():B(!0,f)):f(),g.length&&(g.on("submit",function(e){if(e.preventDefault(),!L(g))return!1;const t={security:wc_checkout_params.apply_coupon_nonce,coupon_code:g.find('input[name="coupon_code"]').val()};r.ajax({type:"POST",url:wc_checkout_params.wc_ajax_url.toString().replace("%%endpoint%%","apply_coupon"),data:t,dataType:"html",success:e=>{if(m(),g.find(".result").remove(),e){const o=e.includes("error");g.append(`<p class="result ${s}__helper-text ${o?s+"__inline-error":""}">`+r(e).text()+"</p>"),o?(g.find('input[name="coupon_code"]').focus(),g.find('h3, input[name="coupon_code"]').addClass("newspack-ui__field-error")):(g.find('input[name="coupon_code"]').focus(),g.find('h3, input[name="coupon_code"]').removeClass("newspack-ui__field-error")),r(document.body).trigger("applied_coupon_in_checkout",[t.coupon_code]),r(document.body).trigger("update_checkout",{update_shipping_method:!1})}},complete:()=>{P(g)}})}),r(document.body).on("removed_coupon_in_checkout",()=>{m(),g.find(".result").remove(),g.find('input[name="coupon_code"]').val("").focus()})),w.length&&w.on("submit",function(e){if(e.preventDefault(),!L(w))return!1;const t=w.find('input[name="price"]');t.attr("disabled",!0);const o={_ajax_nonce:newspackBlocksModalCheckout.nyp_nonce,action:"process_name_your_price_request",price:w.find('input[name="price"]').val(),product_id:w.find('input[name="product_id"]').val(),newspack_checkout_name_your_price:w.find('input[name="newspack_checkout_name_your_price"]').val()};r.ajax({type:"POST",url:newspackBlocksModalCheckout.ajax_url,data:o,success:({success:e,data:t})=>{m(),w.find(".result").remove(),w.append(`<p class="result ${s}__helper-text ${e?"":s+"__inline-error"}">`+t.message+"</p>"),e?w.find('h3, input[name="price"]').removeClass("newspack-ui__field-error"):(w.find('input[name="price"]').focus(),w.find('h3, input[name="price"]').addClass("newspack-ui__field-error")),r(document.body).trigger("update_checkout",{update_shipping_method:!1})},complete:()=>{P(w),t.attr("disabled",!1),t.focus()}})}),a.on("click","#place_order",function(){(()=>{if("function"!=typeof window.gtag)return;const t=n("modal-checkout-product-details"),c=e("form_submission",t);o(c)})()});const S=function(){if(!t)return;const e="data-newspack-error-handled",o=o=>{o.hasAttribute(e)||(o.setAttribute(e,"true"),r(o).addClass(`${s}__notice ${s}__notice--error`),t.dispatchEvent(_),o.scrollIntoView({behavior:"smooth",block:"center"}))},c=e=>!!e.classList?.contains("woocommerce-error")||!(!e.classList?.contains("wc-block-components-notice-banner")||!e.classList?.contains("is-error")),n=new MutationObserver(e=>{for(const t of e)for(const e of t.addedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;if(c(e))return void o(e);const t=e.querySelector?.(".woocommerce-error, .wc-block-components-notice-banner.is-error");if(t)return void o(t)}});return n.observe(t,{childList:!0,subtree:!0}),n}();if(S){const e=()=>S.disconnect();t.addEventListener("checkout-complete",e),t.addEventListener("checkout-cancel",e),window.addEventListener("beforeunload",e)}}g()}function k(){const e=r("#newspack_subscription_terms_confirmation, #newspack_subscription_confirmation");if(e.length){const t=r("form.checkout"),o=t.find("button#place_order, button#place_order_clone");function c(){const t=e.is(":checked");o.each((e,o)=>{r(o).attr("disabled",!t)})}c(),e.on("change",c),t.on("submit",function(t){if(!e.is(":checked"))return t.preventDefault(),t.stopPropagation(),!1})}}r(document.body).on("updated_checkout payment_method_selected checkout_error",k),r(document).ready(k),r(document.body).on("checkout_error",function(){const e=r(".woocommerce-NoticeGroup-checkout, .woocommerce-notices-wrapper");e.length&&e.each((e,t)=>r(t).addClass(`${s}__notice ${s}__notice--error`));const t=r("#checkout_error_back");t.length&&t.on("click",e=>{e.preventDefault(),parent.newspackCloseModalCheckout()}),f(!1)}),document.addEventListener("keydown",function(e){"Escape"===e.key&&parent.newspackCloseModalCheckout()}),newspackBlocksModalCheckout.is_error&&r(document.body).trigger("checkout_error")})})();
@@ -1488,10 +1488,14 @@ final class Modal_Checkout {
1488
1488
  if ( self::is_modal_checkout() ) {
1489
1489
  $params = [ 'modal_checkout' => 1 ];
1490
1490
  $newspack_popup_id = filter_input( INPUT_GET, 'newspack_popup_id', FILTER_SANITIZE_NUMBER_INT );
1491
+ $prompt_title = filter_input( INPUT_GET, 'prompt_title', FILTER_SANITIZE_SPECIAL_CHARS );
1491
1492
  $gate_post_id = filter_input( INPUT_GET, 'gate_post_id', FILTER_SANITIZE_NUMBER_INT );
1492
1493
  if ( $newspack_popup_id ) {
1493
1494
  $params['newspack_popup_id'] = $newspack_popup_id;
1494
1495
  }
1496
+ if ( $prompt_title ) {
1497
+ $params['prompt_title'] = $prompt_title;
1498
+ }
1495
1499
  if ( $gate_post_id ) {
1496
1500
  $params['gate_post_id'] = $gate_post_id;
1497
1501
  }
@@ -371,15 +371,19 @@ final class Checkout_Data {
371
371
  */
372
372
  $gate_post_id = null;
373
373
  $newspack_popup_id = null;
374
+ $prompt_title = null;
374
375
  if ( $order ) {
375
376
  $gate_post_id = $order->get_meta( '_gate_post_id' );
376
377
  $newspack_popup_id = $order->get_meta( '_newspack_popup_id' );
378
+ $prompt_title = $order->get_meta( '_prompt_title' );
377
379
  } elseif ( $cart_item ) {
378
380
  $gate_post_id = $cart_item['gate_post_id'] ?? null;
379
381
  $newspack_popup_id = $cart_item['newspack_popup_id'] ?? null;
382
+ $prompt_title = $cart_item['prompt_title'] ?? null;
380
383
  } else {
381
384
  $gate_post_id = filter_input( INPUT_GET, 'gate_post_id', FILTER_SANITIZE_NUMBER_INT );
382
385
  $newspack_popup_id = filter_input( INPUT_GET, 'newspack_popup_id', FILTER_SANITIZE_NUMBER_INT );
386
+ $prompt_title = filter_input( INPUT_GET, 'prompt_title', FILTER_SANITIZE_SPECIAL_CHARS );
383
387
  }
384
388
  if ( $gate_post_id ) {
385
389
  $data['gate_post_id'] = $gate_post_id;
@@ -387,6 +391,9 @@ final class Checkout_Data {
387
391
  if ( $newspack_popup_id ) {
388
392
  $data['newspack_popup_id'] = $newspack_popup_id;
389
393
  }
394
+ if ( $prompt_title ) {
395
+ $data['prompt_title'] = $prompt_title;
396
+ }
390
397
 
391
398
  /**
392
399
  * Filters the checkout data.
@@ -2,7 +2,7 @@ msgid ""
2
2
  msgstr ""
3
3
  "Project-Id-Version: Newspack Blocks\n"
4
4
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/project\n"
5
- "POT-Creation-Date: 2026-01-07T21:28:53+00:00\n"
5
+ "POT-Creation-Date: 2026-01-20T14:14:14+00:00\n"
6
6
  "PO-Revision-Date: 2024-08-30 08:45-0700\n"
7
7
  "Last-Translator: \n"
8
8
  "Language-Team: \n"
@@ -132,14 +132,14 @@ msgid "Close window"
132
132
  msgstr ""
133
133
 
134
134
  #. translators: %s: Site name.
135
- #: includes/class-modal-checkout.php:1511
135
+ #: includes/class-modal-checkout.php:1515
136
136
  #, php-format
137
137
  msgid ""
138
138
  "You're already a subscriber! You can only have one active subscription at a "
139
139
  "time. Thank you for supporting %s."
140
140
  msgstr ""
141
141
 
142
- #: includes/class-modal-checkout.php:1522
142
+ #: includes/class-modal-checkout.php:1526
143
143
  msgid ""
144
144
  "You're already a subscriber! You can only have one subscription at a time. "
145
145
  "If you wish to renew an expired subscription, please sign in and visit the "
@@ -148,98 +148,98 @@ msgstr ""
148
148
 
149
149
  #. translators: 1: Checkout button confirmation text. 2: Order total.
150
150
  #. translators: 1 is the name of the item. 2 is the price of the item.
151
- #: includes/class-modal-checkout.php:1646
151
+ #: includes/class-modal-checkout.php:1650
152
152
  #: includes/modal-checkout/class-checkout-data.php:68
153
153
  #, php-format
154
154
  msgid "%1$s: %2$s"
155
155
  msgstr ""
156
156
 
157
- #: includes/class-modal-checkout.php:2005
157
+ #: includes/class-modal-checkout.php:2009
158
158
  msgid "Billing details"
159
159
  msgstr ""
160
160
 
161
- #: includes/class-modal-checkout.php:2006
161
+ #: includes/class-modal-checkout.php:2010
162
162
  msgid "Shipping details"
163
163
  msgstr ""
164
164
 
165
- #: includes/class-modal-checkout.php:2007
165
+ #: includes/class-modal-checkout.php:2011
166
166
  msgid "Gift recipient"
167
167
  msgstr ""
168
168
 
169
- #: includes/class-modal-checkout.php:2008
170
- #: includes/class-modal-checkout.php:2009
171
- #: includes/class-modal-checkout.php:2010
169
+ #: includes/class-modal-checkout.php:2012
170
+ #: includes/class-modal-checkout.php:2013
171
+ #: includes/class-modal-checkout.php:2014
172
172
  msgid "Complete your transaction"
173
173
  msgstr ""
174
174
 
175
- #: includes/class-modal-checkout.php:2011
175
+ #: includes/class-modal-checkout.php:2015
176
176
  msgctxt "Login modal title when logged out user attempts to checkout."
177
177
  msgid "Sign in to complete transaction"
178
178
  msgstr ""
179
179
 
180
- #: includes/class-modal-checkout.php:2016
180
+ #: includes/class-modal-checkout.php:2020
181
181
  msgctxt "Login modal title when unregistered user attempts to checkout"
182
182
  msgid "Register to complete transaction"
183
183
  msgstr ""
184
184
 
185
- #: includes/class-modal-checkout.php:2021
185
+ #: includes/class-modal-checkout.php:2025
186
186
  msgid "Continue browsing"
187
187
  msgstr ""
188
188
 
189
- #: includes/class-modal-checkout.php:2022
189
+ #: includes/class-modal-checkout.php:2026
190
190
  msgid "This donation is a gift"
191
191
  msgstr ""
192
192
 
193
- #: includes/class-modal-checkout.php:2027
193
+ #: includes/class-modal-checkout.php:2031
194
194
  msgid "This purchase is a gift"
195
195
  msgstr ""
196
196
 
197
- #: includes/class-modal-checkout.php:2029
197
+ #: includes/class-modal-checkout.php:2033
198
198
  msgid "Complete transaction"
199
199
  msgstr ""
200
200
 
201
- #: includes/class-modal-checkout.php:2030
201
+ #: includes/class-modal-checkout.php:2034
202
202
  msgid "Purchase"
203
203
  msgstr ""
204
204
 
205
- #: includes/class-modal-checkout.php:2031
205
+ #: includes/class-modal-checkout.php:2035
206
206
  msgid "Edit billing information"
207
207
  msgstr ""
208
208
 
209
- #: includes/class-modal-checkout.php:2032 dist/editor.js:29
209
+ #: includes/class-modal-checkout.php:2036 dist/editor.js:29
210
210
  #: src/blocks/checkout-button/edit.js:192
211
211
  msgid "Cancel"
212
212
  msgstr ""
213
213
 
214
- #: includes/class-modal-checkout.php:2033
214
+ #: includes/class-modal-checkout.php:2037
215
215
  msgid "Transaction successful"
216
216
  msgstr ""
217
217
 
218
- #: includes/class-modal-checkout.php:2034
218
+ #: includes/class-modal-checkout.php:2038
219
219
  msgid ""
220
220
  "Your contribution directly funds our work. If you're moved to do so, you can "
221
221
  "opt to pay more than the standard rate."
222
222
  msgstr ""
223
223
 
224
- #: includes/class-modal-checkout.php:2035
224
+ #: includes/class-modal-checkout.php:2039
225
225
  msgid "Thank you for your generosity! We couldn't do this without you!"
226
226
  msgstr ""
227
227
 
228
- #: includes/class-modal-checkout.php:2036
228
+ #: includes/class-modal-checkout.php:2040
229
229
  msgid "Increase your support"
230
230
  msgstr ""
231
231
 
232
- #: includes/class-modal-checkout.php:2037
232
+ #: includes/class-modal-checkout.php:2041
233
233
  #: src/modal-checkout/templates/form-coupon.php:20
234
234
  msgid "Apply"
235
235
  msgstr ""
236
236
 
237
- #: includes/class-modal-checkout.php:2038
237
+ #: includes/class-modal-checkout.php:2042
238
238
  msgid "We ran into a problem processing this request. Please try again."
239
239
  msgstr ""
240
240
 
241
241
  #. Translators: %s is the site name.
242
- #: includes/class-modal-checkout.php:2175
242
+ #: includes/class-modal-checkout.php:2179
243
243
  #, php-format
244
244
  msgid ""
245
245
  "Thank you for supporting %s. Your transaction was completed successfully."
@@ -2,7 +2,7 @@ msgid ""
2
2
  msgstr ""
3
3
  "Project-Id-Version: Newspack Blocks 1.0.0-alpha.20\n"
4
4
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/project\n"
5
- "POT-Creation-Date: 2026-01-07T21:28:53+00:00\n"
5
+ "POT-Creation-Date: 2026-01-20T14:14:14+00:00\n"
6
6
  "PO-Revision-Date: 2025-08-12T14:56:45+00:00\n"
7
7
  "Last-Translator: \n"
8
8
  "Language-Team: \n"
@@ -124,14 +124,14 @@ msgid "Close window"
124
124
  msgstr ""
125
125
 
126
126
  #. translators: %s: Site name.
127
- #: includes/class-modal-checkout.php:1511
127
+ #: includes/class-modal-checkout.php:1515
128
128
  #, php-format
129
129
  msgid ""
130
130
  "You're already a subscriber! You can only have one active subscription at a "
131
131
  "time. Thank you for supporting %s."
132
132
  msgstr ""
133
133
 
134
- #: includes/class-modal-checkout.php:1522
134
+ #: includes/class-modal-checkout.php:1526
135
135
  msgid ""
136
136
  "You're already a subscriber! You can only have one subscription at a time. "
137
137
  "If you wish to renew an expired subscription, please sign in and visit the "
@@ -140,98 +140,98 @@ msgstr ""
140
140
 
141
141
  #. translators: 1: Checkout button confirmation text. 2: Order total.
142
142
  #. translators: 1 is the name of the item. 2 is the price of the item.
143
- #: includes/class-modal-checkout.php:1646
143
+ #: includes/class-modal-checkout.php:1650
144
144
  #: includes/modal-checkout/class-checkout-data.php:68
145
145
  #, php-format
146
146
  msgid "%1$s: %2$s"
147
147
  msgstr ""
148
148
 
149
- #: includes/class-modal-checkout.php:2005
149
+ #: includes/class-modal-checkout.php:2009
150
150
  msgid "Billing details"
151
151
  msgstr ""
152
152
 
153
- #: includes/class-modal-checkout.php:2006
153
+ #: includes/class-modal-checkout.php:2010
154
154
  msgid "Shipping details"
155
155
  msgstr ""
156
156
 
157
- #: includes/class-modal-checkout.php:2007
157
+ #: includes/class-modal-checkout.php:2011
158
158
  msgid "Gift recipient"
159
159
  msgstr ""
160
160
 
161
- #: includes/class-modal-checkout.php:2008
162
- #: includes/class-modal-checkout.php:2009
163
- #: includes/class-modal-checkout.php:2010
161
+ #: includes/class-modal-checkout.php:2012
162
+ #: includes/class-modal-checkout.php:2013
163
+ #: includes/class-modal-checkout.php:2014
164
164
  msgid "Complete your transaction"
165
165
  msgstr ""
166
166
 
167
- #: includes/class-modal-checkout.php:2011
167
+ #: includes/class-modal-checkout.php:2015
168
168
  msgctxt "Login modal title when logged out user attempts to checkout."
169
169
  msgid "Sign in to complete transaction"
170
170
  msgstr ""
171
171
 
172
- #: includes/class-modal-checkout.php:2016
172
+ #: includes/class-modal-checkout.php:2020
173
173
  msgctxt "Login modal title when unregistered user attempts to checkout"
174
174
  msgid "Register to complete transaction"
175
175
  msgstr ""
176
176
 
177
- #: includes/class-modal-checkout.php:2021
177
+ #: includes/class-modal-checkout.php:2025
178
178
  msgid "Continue browsing"
179
179
  msgstr ""
180
180
 
181
- #: includes/class-modal-checkout.php:2022
181
+ #: includes/class-modal-checkout.php:2026
182
182
  msgid "This donation is a gift"
183
183
  msgstr ""
184
184
 
185
- #: includes/class-modal-checkout.php:2027
185
+ #: includes/class-modal-checkout.php:2031
186
186
  msgid "This purchase is a gift"
187
187
  msgstr ""
188
188
 
189
- #: includes/class-modal-checkout.php:2029
189
+ #: includes/class-modal-checkout.php:2033
190
190
  msgid "Complete transaction"
191
191
  msgstr ""
192
192
 
193
- #: includes/class-modal-checkout.php:2030
193
+ #: includes/class-modal-checkout.php:2034
194
194
  msgid "Purchase"
195
195
  msgstr ""
196
196
 
197
- #: includes/class-modal-checkout.php:2031
197
+ #: includes/class-modal-checkout.php:2035
198
198
  msgid "Edit billing information"
199
199
  msgstr ""
200
200
 
201
- #: includes/class-modal-checkout.php:2032 dist/editor.js:29
201
+ #: includes/class-modal-checkout.php:2036 dist/editor.js:29
202
202
  #: src/blocks/checkout-button/edit.js:192
203
203
  msgid "Cancel"
204
204
  msgstr ""
205
205
 
206
- #: includes/class-modal-checkout.php:2033
206
+ #: includes/class-modal-checkout.php:2037
207
207
  msgid "Transaction successful"
208
208
  msgstr ""
209
209
 
210
- #: includes/class-modal-checkout.php:2034
210
+ #: includes/class-modal-checkout.php:2038
211
211
  msgid ""
212
212
  "Your contribution directly funds our work. If you're moved to do so, you can "
213
213
  "opt to pay more than the standard rate."
214
214
  msgstr ""
215
215
 
216
- #: includes/class-modal-checkout.php:2035
216
+ #: includes/class-modal-checkout.php:2039
217
217
  msgid "Thank you for your generosity! We couldn't do this without you!"
218
218
  msgstr ""
219
219
 
220
- #: includes/class-modal-checkout.php:2036
220
+ #: includes/class-modal-checkout.php:2040
221
221
  msgid "Increase your support"
222
222
  msgstr ""
223
223
 
224
- #: includes/class-modal-checkout.php:2037
224
+ #: includes/class-modal-checkout.php:2041
225
225
  #: src/modal-checkout/templates/form-coupon.php:20
226
226
  msgid "Apply"
227
227
  msgstr ""
228
228
 
229
- #: includes/class-modal-checkout.php:2038
229
+ #: includes/class-modal-checkout.php:2042
230
230
  msgid "We ran into a problem processing this request. Please try again."
231
231
  msgstr ""
232
232
 
233
233
  #. Translators: %s is the site name.
234
- #: includes/class-modal-checkout.php:2175
234
+ #: includes/class-modal-checkout.php:2179
235
235
  #, php-format
236
236
  msgid ""
237
237
  "Thank you for supporting %s. Your transaction was completed successfully."