@automattic/newspack-blocks 1.69.0 → 1.70.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/.cache/babel/361f8dd5ae7703fe3972fcd6c5829188.json.gz +0 -0
- package/.cache/babel/6576303929ca1ea8e2c37c6bde278067.json.gz +0 -0
- package/.cache/babel/8bb7b96e12530d769c0fdf208bd68ba2.json.gz +0 -0
- package/.cache/babel/a4f1c74990ed908a9c8973d09c64c685.json.gz +0 -0
- package/.cache/babel/b097ee531eaf61b5821f9c41aaaa369c.json.gz +0 -0
- package/CHANGELOG.md +26 -0
- package/dist/donateStreamlined.asset.php +1 -1
- package/dist/donateStreamlined.js +1 -1
- package/dist/editor.asset.php +1 -1
- package/dist/editor.js +1 -1
- package/includes/class-newspack-blocks.php +59 -18
- package/newspack-blocks.php +2 -2
- package/package.json +5 -5
- package/src/blocks/carousel/edit.js +3 -19
- package/src/blocks/carousel/index.js +1 -1
- package/src/blocks/carousel/view.php +29 -18
- package/src/blocks/homepage-articles/block.json +15 -2
- package/src/blocks/homepage-articles/edit.js +3 -18
- package/src/blocks/homepage-articles/utils.ts +4 -4
- package/src/blocks/homepage-articles/view.php +14 -0
- package/src/components/query-controls.js +50 -32
- package/src/types/index.d.ts +1 -1
- package/vendor/autoload.php +1 -1
- package/vendor/composer/autoload_real.php +4 -4
- package/vendor/composer/autoload_static.php +2 -2
- package/vendor/composer/installed.php +2 -2
- package/.cache/babel/3807c3306deecdbdb91968cb3c978235.json.gz +0 -0
- package/.cache/babel/5ac50f37a9913d9f63c8751f5c415ba4.json.gz +0 -0
- package/.cache/babel/900ca42963bd0a74c1498a6d1212d82f.json.gz +0 -0
- package/.cache/babel/e452902bef688c901938b578c6834c50.json.gz +0 -0
- package/.cache/babel/f7fd26614549b5cbb31416d632c38ccd.json.gz +0 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
# [1.70.0](https://github.com/Automattic/newspack-blocks/compare/v1.69.0...v1.70.0) (2023-06-19)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **checkout-button:** overlay class for modal stacking ([#1461](https://github.com/Automattic/newspack-blocks/issues/1461)) ([594095b](https://github.com/Automattic/newspack-blocks/commit/594095b02f957ccb974c0c40ea9e76685ae32844))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **checkout-button:** front-end product variation selection ([#1459](https://github.com/Automattic/newspack-blocks/issues/1459)) ([a978160](https://github.com/Automattic/newspack-blocks/commit/a978160c3e453b60bf9bcd92ad53c9b6c39fb23b))
|
|
12
|
+
* **modal-checkout:** always use donation billing fields ([#1463](https://github.com/Automattic/newspack-blocks/issues/1463)) ([ab176bf](https://github.com/Automattic/newspack-blocks/commit/ab176bfebf6c5a12c8bf1fde3ba52db4c1f9454d))
|
|
13
|
+
|
|
14
|
+
# [1.70.0-alpha.1](https://github.com/Automattic/newspack-blocks/compare/v1.69.0...v1.70.0-alpha.1) (2023-06-08)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **checkout-button:** overlay class for modal stacking ([#1461](https://github.com/Automattic/newspack-blocks/issues/1461)) ([594095b](https://github.com/Automattic/newspack-blocks/commit/594095b02f957ccb974c0c40ea9e76685ae32844))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* **checkout-button:** front-end product variation selection ([#1459](https://github.com/Automattic/newspack-blocks/issues/1459)) ([a978160](https://github.com/Automattic/newspack-blocks/commit/a978160c3e453b60bf9bcd92ad53c9b6c39fb23b))
|
|
25
|
+
* **modal-checkout:** always use donation billing fields ([#1463](https://github.com/Automattic/newspack-blocks/issues/1463)) ([ab176bf](https://github.com/Automattic/newspack-blocks/commit/ab176bfebf6c5a12c8bf1fde3ba52db4c1f9454d))
|
|
26
|
+
|
|
1
27
|
# [1.69.0](https://github.com/Automattic/newspack-blocks/compare/v1.68.2...v1.69.0) (2023-06-05)
|
|
2
28
|
|
|
3
29
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<?php return array('dependencies' => array('wp-i18n', 'wp-polyfill'), 'version' => '
|
|
1
|
+
<?php return array('dependencies' => array('wp-i18n', 'wp-polyfill'), 'version' => 'd53eb14a66bfb0ab4123800b45a03e52');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var e={7597:(e,t)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}var n,o="https://js.stripe.com/v3",a=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,i="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",u=null,c=function(e){return null!==u||(u=new Promise((function(t,r){if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(i),window.Stripe)t(window.Stripe);else try{var n=function(){for(var e=document.querySelectorAll('script[src^="'.concat(o,'"]')),t=0;t<e.length;t++){var r=e[t];if(a.test(r.src))return r}return null}();n&&e?console.warn(i):n||(n=function(e){var t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",r=document.createElement("script");r.src="".concat(o).concat(t);var n=document.head||document.body;if(!n)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return n.appendChild(r),r}(e)),n.addEventListener("load",(function(){window.Stripe?t(window.Stripe):r(new Error("Stripe.js not available"))})),n.addEventListener("error",(function(){r(new Error("Failed to load Stripe.js"))}))}catch(u){return void r(u)}else t(null)}))),u},s=function(e,t,r){if(null===e)return null;var n=e.apply(void 0,t);return function(e,t){e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",version:"1.53.0",startTime:t})}(n,r),n},l=function(e){var t="invalid load parameters; expected object of shape\n\n {advancedFraudSignals: boolean}\n\nbut received\n\n ".concat(JSON.stringify(e),"\n");if(null===e||"object"!==r(e))throw new Error(t);if(1===Object.keys(e).length&&"boolean"==typeof e.advancedFraudSignals)return e;throw new Error(t)},p=!1,f=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];p=!0;var o=Date.now();return c(n).then((function(e){return s(e,t,o)}))};f.setLoadParameters=function(e){if(p&&n){var t=l(e);if(Object.keys(t).reduce((function(t,r){var o;return t&&e[r]===(null===(o=n)||void 0===o?void 0:o[r])}),!0))return}if(p)throw new Error("You cannot change load parameters after calling loadStripe");n=l(e)},t.loadStripe=f},7894:(e,t,r)=>{e.exports=r(7597)},5666:e=>{var t=function(e){"use strict";var t,r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(T){s=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var a=t&&t.prototype instanceof h?t:h,i=Object.create(a.prototype),u=new P(n||[]);return o(i,"_invoke",{value:E(e,r,u)}),i}function p(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(T){return{type:"throw",arg:T}}}e.wrap=l;var f="suspendedStart",d="executing",m="completed",y={};function h(){}function v(){}function b(){}var w={};s(w,i,(function(){return this}));var g=Object.getPrototypeOf,x=g&&g(g(q([])));x&&x!==r&&n.call(x,i)&&(w=x);var _=b.prototype=h.prototype=Object.create(w);function k(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function r(o,a,i,u){var c=p(e[o],e,a);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,i,u)}),(function(e){r("throw",e,i,u)})):t.resolve(l).then((function(e){s.value=e,i(s)}),(function(e){return r("throw",e,i,u)}))}u(c.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return a=a?a.then(o,o):o()}})}function E(e,t,r){var n=f;return function(o,a){if(n===d)throw new Error("Generator is already running");if(n===m){if("throw"===o)throw a;return R()}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var u=j(i,r);if(u){if(u===y)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===f)throw n=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=d;var c=p(e,t,r);if("normal"===c.type){if(n=r.done?m:"suspendedYield",c.arg===y)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n=m,r.method="throw",r.arg=c.arg)}}}function j(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,j(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=p(o,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,y;var i=a.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function q(e){if(e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}return{next:R}}function R(){return{value:t,done:!0}}return v.prototype=b,o(_,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:v,configurable:!0}),v.displayName=s(b,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,s(e,c,"GeneratorFunction")),e.prototype=Object.create(_),e},e.awrap=function(e){return{__await:e}},k(S.prototype),s(S.prototype,u,(function(){return this})),e.AsyncIterator=S,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new S(l(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},k(_),s(_,c,"Generator"),s(_,i,(function(){return this})),s(_,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=q,P.prototype={constructor:P,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(L),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return u.type="throw",u.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],u=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(c&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,y):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),L(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:q(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},e}(e.exports);try{regeneratorRuntime=t}catch(r){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={exports:{}};return e[n](a,a.exports,r),a.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{"use strict";function e(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(r){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?t(Object(o),!0).forEach((function(t){e(r,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}))}return r}function a(e,t,r,n,o,a,i){try{var u=e[a](i),c=u.value}catch(s){return void r(s)}u.done?t(c):Promise.resolve(c).then(n,o)}function i(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function u(e){a(i,n,o,u,c,"next",e)}function c(e){a(i,n,o,u,c,"throw",e)}u(void 0)}))}}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function c(e,t){if(e){if("string"==typeof e)return u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(e,t):void 0}}function s(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||c(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}r.r(n),r.d(n,{processStreamlinedElements:()=>S});const l=window.wp.i18n;var p=r(7894);r(5666);function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a=[],_n=!0,i=!1;try{for(r=r.call(e);!(_n=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);_n=!0);}catch(u){i=!0,o=u}finally{try{_n||null==r.return||r.return()}finally{if(i)throw o}}return a}}(e,t)||c(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var __=l.__,d=function(e,t){var r,n={};r=e.email,/\S+@\S+/.test(r)||(n.email=__("Email address is invalid.","newspack-blocks"));var o=t.minimumDonation;return o&&parseFloat(e.amount)<o&&(n.amount=(0,l.sprintf)(__("Amount must be at least %d.","newspack-blocks"),o)),0===e.full_name.length&&(n.amount=__("Full name should be provided.","newspack-blocks")),n},m=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"error";t.innerHTML="",e.forEach((function(e){if(e){var n=document.createElement("div");n.classList.add("type-".concat(r)),n.innerHTML=e,t.appendChild(n)}})),"success"===r&&t.parentElement&&t.parentElement.replaceWith(t)},y=function(e){var t=e.closest("[data-streamlined-config]"),r=null==t?void 0:t.getAttribute("data-streamlined-config");if(!r)return{};var n=f(JSON.parse(r),12),o=n[0],a=n[1],i=n[2],u=n[3],c=n[4],s=n[5],l=n[6],p=n[7],d=n[8],m=n[9],y=n[10],h=n[11];return{currency:o.toLowerCase(),currencySymbol:a,siteName:i,isCurrencyZeroDecimal:u,countryCode:c,frequencies:s,feeMultiplier:parseFloat(l),feeStatic:parseFloat(p),stripePublishableKey:d,paymentRequestType:m,captchaSiteKey:y,minimumDonation:parseFloat(h)}},h=function(e){var t=Object.fromEntries(new FormData(e)),r="donation_value_".concat(t.donation_frequency);return t.amount=t[r],"other"===t.amount&&(t.amount=t["".concat(r,"_other")]),t.amount||(t.amount=t["".concat(r,"_untiered")]),t.cid&&"string"==typeof t.cid&&0===t.cid.indexOf("CLIENT_ID")&&(t.cid=document.cookie.split("; ").reduce((function(e,t){var r=t.split("=");return e[r[0]]=r[1],e}),{})["newspack-cid"]),t},v=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{convertToSubunit:!1},r=t.convertToSubunit,n=y(e),o=h(e),a=o.amount,i=void 0===a?"0":a,u=o.agree_to_pay_fees,c=function(e){return r?e*(n.isCurrencyZeroDecimal?1:100):e},s=0;return u&&(s=c(w(e)||0)),c(parseFloat(i))+s},b=function(e){var t=y(e),r=h(e).donation_frequency,n=t.frequencies[r];return{label:"".concat(t.siteName," (").concat(n,")"),amount:v(e,{convertToSubunit:!0})}},w=function(e){var t=y(e),r=t.feeMultiplier,n=t.feeStatic;if(void 0===r||void 0===n||isNaN(r)||isNaN(n))return 0;var o=h(e).amount;return function(e,t,r){return parseFloat(((e+r)/(100-t)*100-e).toFixed(2))}(parseFloat(o),r,n)},g=function(){var e=i(regeneratorRuntime.mark((function e(t,r){var n,o=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=o.length>2&&void 0!==o[2]?o[2]:"POST",e.abrupt("return",fetch("/wp-json/newspack-blocks/v1".concat(t),{method:n,headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}).then(function(){var e=i(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:if(r=e.sent,!t.ok){e.next=5;break}return e.abrupt("return",r);case 5:return e.abrupt("return",{error:r});case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 2:case"end":return e.stop()}}),e)})));return function(_x,t){return e.apply(this,arguments)}}(),x=function(e,t){var r=(0,l.sprintf)(__("Your payment has been processed. Thank you for your contribution! You will receive a confirmation email at %s.","newspack-blocks"),e);m([r],t,"success")},_=l.__,k=function(e){return s(e.querySelectorAll("input[data-is-additional-field]")).map((function(e){return{name:e.name,value:e.value}}))},S=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document;return s(e.querySelectorAll(".stripe-payment")).forEach(function(){var e=i(regeneratorRuntime.mark((function e(t){var r,n,a,u,c,s,l,f,S,E,j,O,L,P,q,R,T,F;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c=!1,s=t.closest("form"),l=t.querySelector(".stripe-payment__messages"),s&&l){e.next=5;break}return e.abrupt("return");case 5:f=t.closest(".wpbnbd"),S="newspackPaymentFlowComplete-".concat((null==f?void 0:f.id)||""),E=y(s),j=function(){return t.classList.add("stripe-payment--disabled")},(O=function(){return t.classList.remove("stripe-payment--disabled")})(),L=function(){if(!c){var e=t.querySelector(".stripe-payment__inputs.stripe-payment--hidden");e&&(e.classList.remove("stripe-payment--hidden"),c=!0)}},P=function(){var e=i(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,r){var n=window.grecaptcha;if(!n)return e("");null!=n&&n.ready&&t||r(_("Error loading the reCaptcha library.","newspack-blocks")),n.ready(i(regeneratorRuntime.mark((function o(){var a;return regeneratorRuntime.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.prev=0,o.next=3,n.execute(t,{action:"submit"});case 3:return a=o.sent,o.abrupt("return",e(a));case 7:o.prev=7,o.t0=o.catch(0),r(o.t0);case 10:case"end":return o.stop()}}),o,null,[[0,7]])}))))})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),q=function(){var e=i(regeneratorRuntime.mark((function e(t){var n,a,i,u,c,p,f,d,y,b,w,j,L,q,R,T,F,A=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=A.length>1&&void 0!==A[1]?A[1]:void 0,u=A.length>2&&void 0!==A[2]?A[2]:{},r){e.next=4;break}return e.abrupt("return");case 4:if(!(c=null==E?void 0:E.captchaSiteKey)){e.next=17;break}return e.prev=6,e.next=9,P(c);case 9:p=e.sent,e.next=17;break;case 12:return e.prev=12,e.t0=e.catch(6),f=e.t0 instanceof Error?e.t0.message:_("Error processing captcha request.","newspack-blocks"),m([f],l),e.abrupt("return",{error:!0});case 17:return d=h(s),y=s.closest("amp-layout.newspack-popup"),b=y&&y.hasAttribute("amp-access")?y.getAttribute("amp-access"):null,w=k(s),j=o({captchaToken:p,stripe_tokenization_method:i?null===(n=i.card)||void 0===n?void 0:n.tokenization_method:"card",stripe_source_id:t.id,amount:v(s),email:d.email,full_name:d.full_name,frequency:d.donation_frequency,newsletter_opt_in:Boolean(d.newsletter_opt_in),newspack_popup_id:d.newspack_popup_id,_wp_http_referer:d._wp_http_referer,clientId:d.cid,origin:b,additional_fields:w},u),e.next=24,g("/donate",j);case 24:if(L=e.sent,200===(null===(a=L.data)||void 0===a?void 0:a.status)||!L.message){e.next=28;break}return m([L.message],l),e.abrupt("return",{error:!0});case 28:if(!L.error){e.next=31;break}return m([L.error],l),e.abrupt("return",{error:!0});case 31:if(q=function(e){return m([e],l),O(),window.dispatchEvent(new Event(S)),{error:!0}},!L.client_secret){e.next=55;break}return e.next=35,r.confirmCardPayment(L.client_secret);case 35:if(!(R=e.sent).error){e.next=40;break}return e.abrupt("return",q(R.error.message));case 40:if("succeeded"!==R.paymentIntent.status){e.next=44;break}x(j.email,l),e.next=55;break;case 44:if("requires_action"!==R.paymentIntent.status){e.next=54;break}return e.next=47,r.confirmCardPayment(L.client_secret);case 47:if(T=e.sent,!(F=T.error)){e.next=51;break}return e.abrupt("return",q(F.message));case 51:x(j.email,l),e.next=55;break;case 54:return e.abrupt("return",q(_("Something went wrong with the payment. Please try again later.","newspack-blocks")));case 55:return"success"===L.status&&x(j.email,l),window.dispatchEvent(new Event(S)),e.abrupt("return",{});case 58:case"end":return e.stop()}}),e,null,[[6,12]])})));return function(t){return e.apply(this,arguments)}}(),R=function(){var e=i(regeneratorRuntime.mark((function e(){var o,c,l,f;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,p.loadStripe)(E.stripePublishableKey);case 2:if(r=e.sent){e.next=5;break}return e.abrupt("return");case 5:if(o=t.querySelector(".stripe-payment__card")){e.next=8;break}return e.abrupt("return");case 8:return c=r.elements(),(n=c.create("card")).mount(o),a=r.paymentRequest({country:E.countryCode,currency:E.currency,total:b(s),requestPayerName:!0,requestPayerEmail:!0}),e.next=14,a.canMakePayment();case 14:if(!e.sent){e.next=28;break}if(a.on("source",function(){var e=i(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,q(t.source,u,{email:t.payerEmail,full_name:t.payerName});case 2:r=e.sent,t.complete(null!=r&&r.error?"fail":"success");case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),a.on("token",function(){var e=i(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:u=t.token;case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),s.addEventListener("change",(function(){a.update({total:b(s)})})),l=c.create("paymentRequestButton",{paymentRequest:a,style:{paymentRequestButton:{type:E.paymentRequestType,height:"46px"}}}),f=t.querySelector(".stripe-payment__request-button")){e.next=23;break}return e.abrupt("return");case 23:l.mount(f),f.classList.remove("stripe-payment--hidden"),setTimeout((function(){f.classList.remove("stripe-payment__request-button--invisible")}),0),e.next=29;break;case 28:L();case 29:t.classList.remove("stripe-payment--invisible");case 30:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),new IntersectionObserver((function(e){e[0].isIntersecting&&R()})).observe(t),(T=t.querySelector('button[type="submit"]'))&&(T.onclick=function(e){c||(e.preventDefault(),L())}),(F=function(){var e=t.querySelector("#stripe-fees-amount");if(e){var r=Object.fromEntries(new FormData(s)),n=w(s);if(0===n){var o=t.querySelector("#stripe-fees-amount-container");o&&(o.style.display="none")}"string"==typeof r.donation_frequency&&(e.innerHTML="(".concat(E.currencySymbol).concat(n.toFixed(2)," ").concat(E.frequencies[r.donation_frequency].toLowerCase(),")"))}})(),s.addEventListener("change",F),s.addEventListener("submit",function(){var e=i(regeneratorRuntime.mark((function e(t){var o,a,i,u,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r){e.next=2;break}return e.abrupt("return");case 2:if(t.preventDefault(),j(),m([_("Processing payment…","newspack-blocks")],l,"info"),a=h(s),!((i=Object.values(d(a,E))).length>0)){e.next=11;break}return m(i,l),O(),e.abrupt("return");case 11:return u=function(e){e.message&&i.push(e.message),m(i,l),O()},e.next=14,r.createSource(n,{type:"card",owner:{name:a.full_name,email:a.email}});case 14:if(!(c=e.sent).error){e.next=18;break}return u(c.error),e.abrupt("return");case 18:return e.next=20,q(c.source);case 20:null!==(o=window.newspackReaderActivation)&&void 0!==o&&o.refreshAuthentication&&window.newspackReaderActivation.refreshAuthentication();case 21:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}());case 23:case"end":return e.stop()}}),e)})));return function(_x){return e.apply(this,arguments)}}())};S()})();var o=window;for(var a in n)o[a]=n[a];n.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})})();
|
|
1
|
+
(()=>{var e={7597:(e,t)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}var n,o="https://js.stripe.com/v3",a=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,i="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",u=null,c=function(e){return null!==u||(u=new Promise((function(t,r){if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(i),window.Stripe)t(window.Stripe);else try{var n=function(){for(var e=document.querySelectorAll('script[src^="'.concat(o,'"]')),t=0;t<e.length;t++){var r=e[t];if(a.test(r.src))return r}return null}();n&&e?console.warn(i):n||(n=function(e){var t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",r=document.createElement("script");r.src="".concat(o).concat(t);var n=document.head||document.body;if(!n)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return n.appendChild(r),r}(e)),n.addEventListener("load",(function(){window.Stripe?t(window.Stripe):r(new Error("Stripe.js not available"))})),n.addEventListener("error",(function(){r(new Error("Failed to load Stripe.js"))}))}catch(u){return void r(u)}else t(null)}))),u},s=function(e,t,r){if(null===e)return null;var n=e.apply(void 0,t);return function(e,t){e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",version:"1.54.0",startTime:t})}(n,r),n},l=function(e){var t="invalid load parameters; expected object of shape\n\n {advancedFraudSignals: boolean}\n\nbut received\n\n ".concat(JSON.stringify(e),"\n");if(null===e||"object"!==r(e))throw new Error(t);if(1===Object.keys(e).length&&"boolean"==typeof e.advancedFraudSignals)return e;throw new Error(t)},p=!1,f=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];p=!0;var o=Date.now();return c(n).then((function(e){return s(e,t,o)}))};f.setLoadParameters=function(e){if(p&&n){var t=l(e);if(Object.keys(t).reduce((function(t,r){var o;return t&&e[r]===(null===(o=n)||void 0===o?void 0:o[r])}),!0))return}if(p)throw new Error("You cannot change load parameters after calling loadStripe");n=l(e)},t.loadStripe=f},7894:(e,t,r)=>{e.exports=r(7597)},5666:e=>{var t=function(e){"use strict";var t,r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(T){s=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var a=t&&t.prototype instanceof h?t:h,i=Object.create(a.prototype),u=new P(n||[]);return o(i,"_invoke",{value:E(e,r,u)}),i}function p(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(T){return{type:"throw",arg:T}}}e.wrap=l;var f="suspendedStart",d="executing",m="completed",y={};function h(){}function v(){}function b(){}var w={};s(w,i,(function(){return this}));var g=Object.getPrototypeOf,x=g&&g(g(q([])));x&&x!==r&&n.call(x,i)&&(w=x);var _=b.prototype=h.prototype=Object.create(w);function k(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function r(o,a,i,u){var c=p(e[o],e,a);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,i,u)}),(function(e){r("throw",e,i,u)})):t.resolve(l).then((function(e){s.value=e,i(s)}),(function(e){return r("throw",e,i,u)}))}u(c.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return a=a?a.then(o,o):o()}})}function E(e,t,r){var n=f;return function(o,a){if(n===d)throw new Error("Generator is already running");if(n===m){if("throw"===o)throw a;return R()}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var u=j(i,r);if(u){if(u===y)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===f)throw n=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=d;var c=p(e,t,r);if("normal"===c.type){if(n=r.done?m:"suspendedYield",c.arg===y)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n=m,r.method="throw",r.arg=c.arg)}}}function j(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,j(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=p(o,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,y;var i=a.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function q(e){if(e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}return{next:R}}function R(){return{value:t,done:!0}}return v.prototype=b,o(_,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:v,configurable:!0}),v.displayName=s(b,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,s(e,c,"GeneratorFunction")),e.prototype=Object.create(_),e},e.awrap=function(e){return{__await:e}},k(S.prototype),s(S.prototype,u,(function(){return this})),e.AsyncIterator=S,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new S(l(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},k(_),s(_,c,"Generator"),s(_,i,(function(){return this})),s(_,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=q,P.prototype={constructor:P,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(L),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return u.type="throw",u.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],u=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(c&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,y):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),L(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:q(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},e}(e.exports);try{regeneratorRuntime=t}catch(r){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={exports:{}};return e[n](a,a.exports,r),a.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{"use strict";function e(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(r){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?t(Object(o),!0).forEach((function(t){e(r,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}))}return r}function a(e,t,r,n,o,a,i){try{var u=e[a](i),c=u.value}catch(s){return void r(s)}u.done?t(c):Promise.resolve(c).then(n,o)}function i(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function u(e){a(i,n,o,u,c,"next",e)}function c(e){a(i,n,o,u,c,"throw",e)}u(void 0)}))}}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function c(e,t){if(e){if("string"==typeof e)return u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(e,t):void 0}}function s(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||c(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}r.r(n),r.d(n,{processStreamlinedElements:()=>S});const l=window.wp.i18n;var p=r(7894);r(5666);function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a=[],_n=!0,i=!1;try{for(r=r.call(e);!(_n=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);_n=!0);}catch(u){i=!0,o=u}finally{try{_n||null==r.return||r.return()}finally{if(i)throw o}}return a}}(e,t)||c(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var __=l.__,d=function(e,t){var r,n={};r=e.email,/\S+@\S+/.test(r)||(n.email=__("Email address is invalid.","newspack-blocks"));var o=t.minimumDonation;return o&&parseFloat(e.amount)<o&&(n.amount=(0,l.sprintf)(__("Amount must be at least %d.","newspack-blocks"),o)),0===e.full_name.length&&(n.amount=__("Full name should be provided.","newspack-blocks")),n},m=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"error";t.innerHTML="",e.forEach((function(e){if(e){var n=document.createElement("div");n.classList.add("type-".concat(r)),n.innerHTML=e,t.appendChild(n)}})),"success"===r&&t.parentElement&&t.parentElement.replaceWith(t)},y=function(e){var t=e.closest("[data-streamlined-config]"),r=null==t?void 0:t.getAttribute("data-streamlined-config");if(!r)return{};var n=f(JSON.parse(r),12),o=n[0],a=n[1],i=n[2],u=n[3],c=n[4],s=n[5],l=n[6],p=n[7],d=n[8],m=n[9],y=n[10],h=n[11];return{currency:o.toLowerCase(),currencySymbol:a,siteName:i,isCurrencyZeroDecimal:u,countryCode:c,frequencies:s,feeMultiplier:parseFloat(l),feeStatic:parseFloat(p),stripePublishableKey:d,paymentRequestType:m,captchaSiteKey:y,minimumDonation:parseFloat(h)}},h=function(e){var t=Object.fromEntries(new FormData(e)),r="donation_value_".concat(t.donation_frequency);return t.amount=t[r],"other"===t.amount&&(t.amount=t["".concat(r,"_other")]),t.amount||(t.amount=t["".concat(r,"_untiered")]),t.cid&&"string"==typeof t.cid&&0===t.cid.indexOf("CLIENT_ID")&&(t.cid=document.cookie.split("; ").reduce((function(e,t){var r=t.split("=");return e[r[0]]=r[1],e}),{})["newspack-cid"]),t},v=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{convertToSubunit:!1},r=t.convertToSubunit,n=y(e),o=h(e),a=o.amount,i=void 0===a?"0":a,u=o.agree_to_pay_fees,c=function(e){return r?e*(n.isCurrencyZeroDecimal?1:100):e},s=0;return u&&(s=c(w(e)||0)),c(parseFloat(i))+s},b=function(e){var t=y(e),r=h(e).donation_frequency,n=t.frequencies[r];return{label:"".concat(t.siteName," (").concat(n,")"),amount:v(e,{convertToSubunit:!0})}},w=function(e){var t=y(e),r=t.feeMultiplier,n=t.feeStatic;if(void 0===r||void 0===n||isNaN(r)||isNaN(n))return 0;var o=h(e).amount;return function(e,t,r){return parseFloat(((e+r)/(100-t)*100-e).toFixed(2))}(parseFloat(o),r,n)},g=function(){var e=i(regeneratorRuntime.mark((function e(t,r){var n,o=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=o.length>2&&void 0!==o[2]?o[2]:"POST",e.abrupt("return",fetch("/wp-json/newspack-blocks/v1".concat(t),{method:n,headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}).then(function(){var e=i(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:if(r=e.sent,!t.ok){e.next=5;break}return e.abrupt("return",r);case 5:return e.abrupt("return",{error:r});case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 2:case"end":return e.stop()}}),e)})));return function(_x,t){return e.apply(this,arguments)}}(),x=function(e,t){var r=(0,l.sprintf)(__("Your payment has been processed. Thank you for your contribution! You will receive a confirmation email at %s.","newspack-blocks"),e);m([r],t,"success")},_=l.__,k=function(e){return s(e.querySelectorAll("input[data-is-additional-field]")).map((function(e){return{name:e.name,value:e.value}}))},S=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document;return s(e.querySelectorAll(".stripe-payment")).forEach(function(){var e=i(regeneratorRuntime.mark((function e(t){var r,n,a,u,c,s,l,f,S,E,j,O,L,P,q,R,T,F;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c=!1,s=t.closest("form"),l=t.querySelector(".stripe-payment__messages"),s&&l){e.next=5;break}return e.abrupt("return");case 5:f=t.closest(".wpbnbd"),S="newspackPaymentFlowComplete-".concat((null==f?void 0:f.id)||""),E=y(s),j=function(){return t.classList.add("stripe-payment--disabled")},(O=function(){return t.classList.remove("stripe-payment--disabled")})(),L=function(){if(!c){var e=t.querySelector(".stripe-payment__inputs.stripe-payment--hidden");e&&(e.classList.remove("stripe-payment--hidden"),c=!0)}},P=function(){var e=i(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,r){var n=window.grecaptcha;if(!n)return e("");null!=n&&n.ready&&t||r(_("Error loading the reCaptcha library.","newspack-blocks")),n.ready(i(regeneratorRuntime.mark((function o(){var a;return regeneratorRuntime.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.prev=0,o.next=3,n.execute(t,{action:"submit"});case 3:return a=o.sent,o.abrupt("return",e(a));case 7:o.prev=7,o.t0=o.catch(0),r(o.t0);case 10:case"end":return o.stop()}}),o,null,[[0,7]])}))))})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),q=function(){var e=i(regeneratorRuntime.mark((function e(t){var n,a,i,u,c,p,f,d,y,b,w,j,L,q,R,T,F,A=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=A.length>1&&void 0!==A[1]?A[1]:void 0,u=A.length>2&&void 0!==A[2]?A[2]:{},r){e.next=4;break}return e.abrupt("return");case 4:if(!(c=null==E?void 0:E.captchaSiteKey)){e.next=17;break}return e.prev=6,e.next=9,P(c);case 9:p=e.sent,e.next=17;break;case 12:return e.prev=12,e.t0=e.catch(6),f=e.t0 instanceof Error?e.t0.message:_("Error processing captcha request.","newspack-blocks"),m([f],l),e.abrupt("return",{error:!0});case 17:return d=h(s),y=s.closest("amp-layout.newspack-popup"),b=y&&y.hasAttribute("amp-access")?y.getAttribute("amp-access"):null,w=k(s),j=o({captchaToken:p,stripe_tokenization_method:i?null===(n=i.card)||void 0===n?void 0:n.tokenization_method:"card",stripe_source_id:t.id,amount:v(s),email:d.email,full_name:d.full_name,frequency:d.donation_frequency,newsletter_opt_in:Boolean(d.newsletter_opt_in),newspack_popup_id:d.newspack_popup_id,_wp_http_referer:d._wp_http_referer,clientId:d.cid,origin:b,additional_fields:w},u),e.next=24,g("/donate",j);case 24:if(L=e.sent,200===(null===(a=L.data)||void 0===a?void 0:a.status)||!L.message){e.next=28;break}return m([L.message],l),e.abrupt("return",{error:!0});case 28:if(!L.error){e.next=31;break}return m([L.error],l),e.abrupt("return",{error:!0});case 31:if(q=function(e){return m([e],l),O(),window.dispatchEvent(new Event(S)),{error:!0}},!L.client_secret){e.next=55;break}return e.next=35,r.confirmCardPayment(L.client_secret);case 35:if(!(R=e.sent).error){e.next=40;break}return e.abrupt("return",q(R.error.message));case 40:if("succeeded"!==R.paymentIntent.status){e.next=44;break}x(j.email,l),e.next=55;break;case 44:if("requires_action"!==R.paymentIntent.status){e.next=54;break}return e.next=47,r.confirmCardPayment(L.client_secret);case 47:if(T=e.sent,!(F=T.error)){e.next=51;break}return e.abrupt("return",q(F.message));case 51:x(j.email,l),e.next=55;break;case 54:return e.abrupt("return",q(_("Something went wrong with the payment. Please try again later.","newspack-blocks")));case 55:return"success"===L.status&&x(j.email,l),window.dispatchEvent(new Event(S)),e.abrupt("return",{});case 58:case"end":return e.stop()}}),e,null,[[6,12]])})));return function(t){return e.apply(this,arguments)}}(),R=function(){var e=i(regeneratorRuntime.mark((function e(){var o,c,l,f;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,p.loadStripe)(E.stripePublishableKey);case 2:if(r=e.sent){e.next=5;break}return e.abrupt("return");case 5:if(o=t.querySelector(".stripe-payment__card")){e.next=8;break}return e.abrupt("return");case 8:return c=r.elements(),(n=c.create("card")).mount(o),a=r.paymentRequest({country:E.countryCode,currency:E.currency,total:b(s),requestPayerName:!0,requestPayerEmail:!0}),e.next=14,a.canMakePayment();case 14:if(!e.sent){e.next=28;break}if(a.on("source",function(){var e=i(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,q(t.source,u,{email:t.payerEmail,full_name:t.payerName});case 2:r=e.sent,t.complete(null!=r&&r.error?"fail":"success");case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),a.on("token",function(){var e=i(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:u=t.token;case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),s.addEventListener("change",(function(){a.update({total:b(s)})})),l=c.create("paymentRequestButton",{paymentRequest:a,style:{paymentRequestButton:{type:E.paymentRequestType,height:"46px"}}}),f=t.querySelector(".stripe-payment__request-button")){e.next=23;break}return e.abrupt("return");case 23:l.mount(f),f.classList.remove("stripe-payment--hidden"),setTimeout((function(){f.classList.remove("stripe-payment__request-button--invisible")}),0),e.next=29;break;case 28:L();case 29:t.classList.remove("stripe-payment--invisible");case 30:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),new IntersectionObserver((function(e){e[0].isIntersecting&&R()})).observe(t),(T=t.querySelector('button[type="submit"]'))&&(T.onclick=function(e){c||(e.preventDefault(),L())}),(F=function(){var e=t.querySelector("#stripe-fees-amount");if(e){var r=Object.fromEntries(new FormData(s)),n=w(s);if(0===n){var o=t.querySelector("#stripe-fees-amount-container");o&&(o.style.display="none")}"string"==typeof r.donation_frequency&&(e.innerHTML="(".concat(E.currencySymbol).concat(n.toFixed(2)," ").concat(E.frequencies[r.donation_frequency].toLowerCase(),")"))}})(),s.addEventListener("change",F),s.addEventListener("submit",function(){var e=i(regeneratorRuntime.mark((function e(t){var o,a,i,u,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r){e.next=2;break}return e.abrupt("return");case 2:if(t.preventDefault(),j(),m([_("Processing payment…","newspack-blocks")],l,"info"),a=h(s),!((i=Object.values(d(a,E))).length>0)){e.next=11;break}return m(i,l),O(),e.abrupt("return");case 11:return u=function(e){e.message&&i.push(e.message),m(i,l),O()},e.next=14,r.createSource(n,{type:"card",owner:{name:a.full_name,email:a.email}});case 14:if(!(c=e.sent).error){e.next=18;break}return u(c.error),e.abrupt("return");case 18:return e.next=20,q(c.source);case 20:null!==(o=window.newspackReaderActivation)&&void 0!==o&&o.refreshAuthentication&&window.newspackReaderActivation.refreshAuthentication();case 21:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}());case 23:case"end":return e.stop()}}),e)})));return function(_x){return e.apply(this,arguments)}}())};S()})();var o=window;for(var a in n)o[a]=n[a];n.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})})();
|
package/dist/editor.asset.php
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'wp-a11y', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-escape-html', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-keycodes', 'wp-polyfill', 'wp-primitives', 'wp-url'), 'version' => '
|
|
1
|
+
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'wp-a11y', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-escape-html', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-keycodes', 'wp-polyfill', 'wp-primitives', 'wp-url'), 'version' => '8588ab44171a104a4eb5bc9550ea50fa');
|