woocommerce-paypal-payments/assets/ppcp-applepay-js-boot-admin.js

1 line
No EOL
83 KiB
JavaScript

(()=>{"use strict";var t={4744:t=>{var e=function(t){return function(t){return!!t&&"object"==typeof t}(t)&&!function(t){var e=Object.prototype.toString.call(t);return"[object RegExp]"===e||"[object Date]"===e||function(t){return t.$$typeof===n}(t)}(t)},n="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function r(t,e){return!1!==e.clone&&e.isMergeableObject(t)?u((n=t,Array.isArray(n)?[]:{}),t,e):t;var n}function o(t,e,n){return t.concat(e).map(function(t){return r(t,n)})}function i(t){return Object.keys(t).concat(function(t){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter(function(e){return Object.propertyIsEnumerable.call(t,e)}):[]}(t))}function a(t,e){try{return e in t}catch(t){return!1}}function u(t,n,c){(c=c||{}).arrayMerge=c.arrayMerge||o,c.isMergeableObject=c.isMergeableObject||e,c.cloneUnlessOtherwiseSpecified=r;var s=Array.isArray(n);return s===Array.isArray(t)?s?c.arrayMerge(t,n,c):function(t,e,n){var o={};return n.isMergeableObject(t)&&i(t).forEach(function(e){o[e]=r(t[e],n)}),i(e).forEach(function(i){(function(t,e){return a(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))})(t,i)||(a(t,i)&&n.isMergeableObject(e[i])?o[i]=function(t,e){if(!e.customMerge)return u;var n=e.customMerge(t);return"function"==typeof n?n:u}(i,n)(t[i],e[i],n):o[i]=r(e[i],n))}),o}(t,n,c):r(n,c)}u.all=function(t,e){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(t,n){return u(t,n,e)},{})};var c=u;t.exports=c}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,n),i.exports}function r(t,e){void 0===e&&(e=Promise),function(t,e){if("object"!=typeof t||null===t)throw new Error("Expected an options object.");var n=t.environment;if(n&&"production"!==n&&"sandbox"!==n)throw new Error('The `environment` option must be either "production" or "sandbox".');if(void 0!==e&&"function"!=typeof e)throw new Error("Expected PromisePonyfill to be a function.")}(t,e);var n=t.url,r=t.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==r&&"object"!=typeof r)throw new Error("Expected attributes to be an object.");return new e(function(t,e){if("undefined"==typeof document)return t();var o,i,a,u;i=(o={url:n,attributes:r,onSuccess:function(){return t()},onError:function(){var t=new Error('The script "'.concat(n,'" failed to load. Check the HTTP status code and response body in DevTools to learn more.'));return e(t)}}).onSuccess,a=o.onError,u=function(t,e){void 0===e&&(e={});var n=document.createElement("script");return n.src=t,Object.keys(e).forEach(function(t){n.setAttribute(t,e[t]),"data-csp-nonce"===t&&n.setAttribute("nonce",e["data-csp-nonce"])}),n}(o.url,o.attributes),u.onerror=a,u.onload=i,document.head.insertBefore(u,document.head.firstElementChild)})}function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}function i(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,u=[],c=!0,s=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=i.call(n)).done)&&(u.push(r.value),u.length!==e);c=!0);}catch(t){s=!0,o=t}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw o}}return u}}(t,e)||u(t,e)||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.")}()}function a(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=u(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var _n=0,r=function(){};return{s:r,n:function(){return _n>=t.length?{done:!0}:{done:!1,value:t[_n++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return i=t.done,t},e:function(t){a=!0,o=t},f:function(){try{i||null==n.return||n.return()}finally{if(a)throw o}}}}function u(t,e){if(t){if("string"==typeof t)return c(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(t,e):void 0}}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function s(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,l(r.key),r)}}function l(t){var e=function(t){if("object"!=o(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==o(e)?e:e+""}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),"function"==typeof SuppressedError&&SuppressedError;var p=function(){return t=function t(){var e=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.paypal=null,this.buttons=new Map,this.messages=new Map,this.renderEventName="ppcp-render",document.ppcpWidgetBuilderStatus=function(){console.log({buttons:e.buttons,messages:e.messages})},jQuery(document).off(this.renderEventName).on(this.renderEventName,function(){e.renderAll()})},(e=[{key:"setPaypal",value:function(t){this.paypal=t,jQuery(document).trigger("ppcp-paypal-loaded",t)}},{key:"registerButtons",value:function(t,e){t=this.sanitizeWrapper(t),this.buttons.set(this.toKey(t),{wrapper:t,options:e})}},{key:"renderButtons",value:function(t){t=this.sanitizeWrapper(t);var e=this.toKey(t);if(this.buttons.has(e)&&!this.hasRendered(t)){var n=this.buttons.get(e),r=this.paypal.Buttons(n.options);if(r.isEligible()){var o=this.buildWrapperTarget(t);o&&(r.hasReturned()?r.resume():r.render(o))}else this.buttons.delete(e)}}},{key:"renderAllButtons",value:function(){var t,e=a(this.buttons);try{for(e.s();!(t=e.n()).done;){var n=i(t.value,1)[0];this.renderButtons(n)}}catch(t){e.e(t)}finally{e.f()}}},{key:"registerMessages",value:function(t,e){this.messages.set(t,{wrapper:t,options:e})}},{key:"renderMessages",value:function(t){var e=this;if(this.messages.has(t)){var n=this.messages.get(t);if(this.hasRendered(t))document.querySelector(t).setAttribute("data-pp-amount",n.options.amount);else{var r=this.paypal.Messages(n.options);r.render(n.wrapper),setTimeout(function(){e.hasRendered(t)||r.render(n.wrapper)},100)}}}},{key:"renderAllMessages",value:function(){var t,e=a(this.messages);try{for(e.s();!(t=e.n()).done;){var n=i(t.value,2),r=n[0];n[1],this.renderMessages(r)}}catch(t){e.e(t)}finally{e.f()}}},{key:"renderAll",value:function(){this.renderAllButtons(),this.renderAllMessages()}},{key:"hasRendered",value:function(t){var e=t;if(Array.isArray(t)){e=t[0];var n,r=a(t.slice(1));try{for(r.s();!(n=r.n()).done;)e+=" .item-"+n.value}catch(t){r.e(t)}finally{r.f()}}var o=document.querySelector(e);return o&&o.hasChildNodes()}},{key:"sanitizeWrapper",value:function(t){return Array.isArray(t)&&1===(t=t.filter(function(t){return!!t})).length&&(t=t[0]),t}},{key:"buildWrapperTarget",value:function(t){var e=t;if(Array.isArray(t)){var n=jQuery(t[0]);if(!n.length)return;var r="item-"+t[1],o=n.find("."+r);o.length||(o=jQuery('<div class="'.concat(r,'"></div>')),n.append(o)),e=o.get(0)}return jQuery(e).length?e:null}},{key:"toKey",value:function(t){return Array.isArray(t)?JSON.stringify(t):t}}])&&s(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();window.widgetBuilder=window.widgetBuilder||new p;const f=window.widgetBuilder;function h(t){return h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},h(t)}function y(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,d(r.key),r)}}function d(t){var e=function(t){if("object"!=h(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=h(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==h(e)?e:e+""}function v(t,e,n){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,n)}function b(t,e){return t.get(g(t,e))}function m(t,e,n){return t.set(g(t,e),n),n}function g(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}var w=new WeakMap,k=new WeakMap,S=new WeakMap,P=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),v(this,w,""),v(this,k,!1),v(this,S,null);for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];n.length&&m(w,this,"[".concat(n.join(" | "),"]"))},e=[{key:"enabled",set:function(t){m(k,this,t)}},{key:"log",value:function(){if(b(k,this)){for(var t,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];(t=console).log.apply(t,[b(w,this)].concat(n))}}},{key:"error",value:function(){for(var t,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];(t=console).error.apply(t,[b(w,this)].concat(n))}},{key:"group",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;b(k,this)&&(t&&!b(S,this)||(console.groupEnd(),m(S,this,null)),t&&(console.group(t),m(S,this,t)))}}],e&&y(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),j=n(4744),O=n.n(j);function _(t){return _="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_(t)}function C(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,E(r.key),r)}}function E(t){var e=function(t){if("object"!=_(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=_(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==_(e)?e:e+""}const A=function(){return t=function t(e){var n=e.selector,r=e.apiConfig,o=e.methodName,i=void 0===o?"":o;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.apiConfig=r,this.defaultAttributes={},this.buttonConfig={},this.ppcpConfig={},this.isDynamic=!0,this.methodName=i,this.methodSlug=this.methodName.toLowerCase().replace(/[^a-z]+/g,""),this.selector=n,this.wrapper=n,this.domWrapper=null},(e=[{key:"createNewWrapper",value:function(){var t=document.createElement("div"),e=this.selector.replace("#",""),n="ppcp-preview-button ppcp-button-apm ppcp-button-".concat(this.methodSlug);return t.setAttribute("id",e),t.setAttribute("class",n),t}},{key:"setDynamic",value:function(t){return this.isDynamic=t,this}},{key:"setButtonConfig",value:function(t){return this.buttonConfig=O()(this.defaultAttributes,t),this.buttonConfig.button.wrapper=this.selector,this}},{key:"setPpcpConfig",value:function(t){return this.ppcpConfig=O()({},t),this}},{key:"dynamicPreviewConfig",value:function(t,e){}},{key:"createButton",value:function(t){throw new Error('The "createButton" method must be implemented by the derived class')}},{key:"render",value:function(){var t=this;if(this.isDynamic||this.buttonConfig.is_enabled){if(this.domWrapper)this._emptyWrapper(),this._showWrapper();else{if(!this.wrapper)return void console.error("Skip render, button is not configured yet");this.domWrapper=this.createNewWrapper(),this._insertWrapper()}this.isVisible=!0;var e=O()({},this.buttonConfig),n=this.isDynamic?O()({},this.ppcpConfig):{};e.button.wrapper=this.selector,this.dynamicPreviewConfig(e,n);var r=e.button.wrapper.replace(/^#/,"");if(r===this.ppcpConfig.button.wrapper.replace(/^#/,""))throw new Error('[APM Preview Button] Infinite loop detected. Provide different selectors for the button/ppcp wrapper elements! Selector: "#'.concat(r,'"'));this.createButton(e),setTimeout(function(){return t._showWrapper()})}}},{key:"remove",value:function(){this.isVisible=!1,this.domWrapper&&(this._hideWrapper(),this._emptyWrapper())}},{key:"_showWrapper",value:function(){this.domWrapper.style.display=""}},{key:"_hideWrapper",value:function(){this.domWrapper.style.display="none"}},{key:"_emptyWrapper",value:function(){this.domWrapper.innerHTML=""}},{key:"_insertWrapper",value:function(){var t=document.querySelector(this.wrapper);t.parentNode.insertBefore(this.domWrapper,t.nextSibling)}}])&&C(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function M(t){return M="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},M(t)}function T(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,B(r.key),r)}}function B(t){var e=function(t){if("object"!=M(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=M(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==M(e)?e:e+""}function I(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(I=function(){return!!t})()}function x(){return x="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=W(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}},x.apply(null,arguments)}function W(t){return W=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},W(t)}function D(t,e){return D=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},D(t,e)}function R(t,e){return t.get(N(t,e))}function N(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}var G=new WeakMap,q=function(t){function e(t){var n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e,n){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,n)}(n=function(t,e,n){return e=W(e),function(t,e){if(e&&("object"==M(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,I()?Reflect.construct(e,n||[],W(t).constructor):e.apply(t,n))}(this,e,[t]),G,void 0),n.selector="".concat(t.selector,"Dummy"),n.label=t.label||"Not Available",n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&D(t,e)}(e,t),n=e,r=[{key:"createNewWrapper",value:function(){var t,n,r,o=(t=e,n=this,"function"==typeof(r=x(W(1&3?t.prototype:t),"createNewWrapper",n))?function(t){return r.apply(n,t)}:r)([]);return o.classList.add("ppcp-button-apm","ppcp-button-dummy"),o}},{key:"createButton",value:function(t){var e,n,r,o;null===(e=R(G,this))||void 0===e||e.remove(),r=G,o=document.createElement("div"),r.set(N(r,this),o),R(G,this).innerHTML='<div class="reason">'.concat(this.label,"</div>"),this._applyStyles(null===(n=this.ppcpConfig)||void 0===n||null===(n=n.button)||void 0===n?void 0:n.style),this.domWrapper.appendChild(R(G,this))}},{key:"_applyStyles",value:function(t){this.domWrapper.classList.remove("ppcp-button-pill","ppcp-button-rect"),this.domWrapper.classList.add("ppcp-button-".concat(t.shape)),t.height&&(this.domWrapper.style.height="".concat(t.height,"px"))}}],r&&T(n.prototype,r),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r}(A);function L(t){return L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},L(t)}function F(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function z(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?F(Object(n),!0).forEach(function(e){Q(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):F(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function Q(t,e,n){return(e=Y(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function U(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function V(){var t,e,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var c=r&&r.prototype instanceof u?r:u,s=Object.create(c.prototype);return H(s,"_invoke",function(n,r,o){var i,u,c,s=0,l=o||[],p=!1,f={p:0,n:0,v:t,a:h,f:h.bind(t,4),d:function(e,n){return i=e,u=0,c=t,f.n=n,a}};function h(n,r){for(u=n,c=r,e=0;!p&&s&&!o&&e<l.length;e++){var o,i=l[e],h=f.p,y=i[2];n>3?(o=y===r)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=h&&((o=n<2&&h<i[1])?(u=0,f.v=r,f.n=i[1]):h<y&&(o=n<3||i[0]>r||r>y)&&(i[4]=n,i[5]=r,f.n=y,u=0))}if(o||n>1)return a;throw p=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(p&&1===l&&h(l,y),u=l,c=y;(e=u<2?t:c)||!p;){i||(u?u<3?(u>1&&(f.n=-1),h(u,c)):f.n=c:f.v=c);try{if(s=2,i){if(u||(o="next"),e=i[o]){if(!(e=e.call(i,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,u<2&&(u=0)}else 1===u&&(e=i.return)&&e.call(i),u<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=t}else if((e=(p=f.n<0)?c:n.call(r,f))!==a)break}catch(e){i=t,u=1,c=e}finally{s=1}}return{value:e,done:p}}}(n,o,i),!0),s}var a={};function u(){}function c(){}function s(){}e=Object.getPrototypeOf;var l=[][r]?e(e([][r]())):(H(e={},r,function(){return this}),e),p=s.prototype=u.prototype=Object.create(l);function f(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,H(t,o,"GeneratorFunction")),t.prototype=Object.create(p),t}return c.prototype=s,H(p,"constructor",s),H(s,"constructor",c),c.displayName="GeneratorFunction",H(s,o,"GeneratorFunction"),H(p),H(p,o,"Generator"),H(p,r,function(){return this}),H(p,"toString",function(){return"[object Generator]"}),(V=function(){return{w:i,m:f}})()}function H(t,e,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}H=function(t,e,n,r){function i(e,n){H(t,e,function(t){return this._invoke(e,n,t)})}e?o?o(t,e,{value:n,enumerable:!r,configurable:!r,writable:!r}):t[e]=n:(i("next",0),i("throw",1),i("return",2))},H(t,e,n,r)}function $(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,o)}function J(t){return function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function a(t){$(i,r,o,a,u,"next",t)}function u(t){$(i,r,o,a,u,"throw",t)}a(void 0)})}}function K(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Y(r.key),r)}}function Y(t){var e=function(t){if("object"!=L(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=L(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==L(e)?e:e+""}function X(t,e,n){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,n)}function Z(t,e){return t.get(et(t,e))}function tt(t,e,n){return t.set(et(t,e),n),n}function et(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}var nt=new WeakMap,rt=new WeakMap,ot=new WeakMap,it=function(){return t=function t(e){var n,r,o,i,a,u=this,c=e.methodName,s=e.buttonConfig,l=e.defaultAttributes;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),X(this,nt,void 0),X(this,rt,void 0),X(this,ot,void 0),this.methodName=c,this.buttonConfig=s,this.defaultAttributes=l,this.isEnabled=!0,this.buttons={},this.apiConfig=null,this.apiError="",tt(nt,this,new P(this.methodName,"preview-manager")),Z(nt,this).enabled=!0,tt(ot,this,new Promise(function(t){tt(rt,u,t)})),this.bootstrap=this.bootstrap.bind(this),this.renderPreview=this.renderPreview.bind(this),this._configureAllButtons=(n=this._configureAllButtons.bind(this),r={timeoutId:null,args:null},i=function(){r.timeoutId&&(n.apply(null,r.args||[]),o())},a=function(){o();for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];r.args=e,r.timeoutId=window.setTimeout(i,100)},a.cancel=o=function(){r.timeoutId&&window.clearTimeout(r.timeoutId),r.timeoutId=null,r.args=null},a.flush=i,a),this.registerEventListeners()},e=[{key:"fetchConfig",value:(o=J(V().m(function t(e){return V().w(function(t){for(;;)switch(t.n){case 0:throw new Error('The "fetchConfig" method must be implemented by the derived class');case 1:return t.a(2)}},t)})),function(_x){return o.apply(this,arguments)})},{key:"createButtonInstance",value:function(t){throw new Error('The "createButtonInstance" method must be implemented by the derived class')}},{key:"createDummyButtonInstance",value:function(t){return new q({selector:t,label:this.apiError,methodName:this.methodName})}},{key:"registerEventListeners",value:function(){jQuery(document).one("DOMContentLoaded",this.bootstrap),jQuery(document).on("ppcp_paypal_render_preview",this.renderPreview),jQuery(document).on("ppcp_paypal_render_preview_".concat(this.methodName),this.renderPreview)}},{key:"log",value:function(t){for(var e,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];(e=Z(nt,this)).log.apply(e,[t].concat(r))}},{key:"error",value:function(t){for(var e,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];(e=Z(nt,this)).error.apply(e,[t].concat(r))}},{key:"isDynamic",value:function(){return!!document.querySelector('[data-ppcp-apm-name="'.concat(this.methodName,'"]'))}},{key:"bootstrap",value:(n=J(V().m(function t(){var e,n,o,i,a,u,c=this;return V().w(function(t){for(;;)switch(t.p=t.n){case 0:if(n=1e4,o=200,null!==(e=this.buttonConfig)&&void 0!==e&&e.sdk_url&&f){t.n=1;break}return this.error("Button could not be configured."),t.a(2);case 1:if(window.PayPalCommerceGatewaySettings){t.n=2;break}return this.error("PayPal settings are not fully loaded. Please clear the cache and reload the page."),t.a(2);case 2:return i=function(t,e,n){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];clearInterval(n),r?t():e("Timeout while waiting for widgetBuilder.paypal")},a=new Promise(function(t,e){var r=0,a=setInterval(function(){f.paypal?i(t,e,a):r>=n&&i(t,e,a,!1),r+=o},o)}),u=r({url:this.buttonConfig.sdk_url}),t.n=3,Promise.all([u,a]).catch(function(t){console.log("Failed to load ".concat(c.methodName," dependencies:"),t)});case 3:return t.p=3,t.n=4,this.fetchConfig(f.paypal);case 4:this.apiConfig=t.v,t.n=6;break;case 5:t.p=5,t.v,this.apiConfig=null;case 6:return t.n=7,Z(rt,this).call(this);case 7:tt(ot,this,null);case 8:return t.a(2)}},t,this,[[3,5]])})),function(){return n.apply(this,arguments)})},{key:"renderPreview",value:function(t,e){var n=e.button.wrapper;n?this.shouldInsertPreviewButton(n)?this.buttons[n]?this._configureButton(n,e):this._addButton(n,e):this.log("Skip preview rendering for this preview-box",n):this.error("Button did not provide a wrapper ID",e)}},{key:"shouldInsertPreviewButton",value:function(t){var e,n=null!==(e=document.querySelector(t).closest(".ppcp-preview").dataset.ppcpPreviewBlock)&&void 0!==e?e:"all";return"all"===n||this.methodName===n}},{key:"_configureButton",value:function(t,e){this.log("configureButton",t,e),this.buttons[t].setDynamic(this.isDynamic()).setPpcpConfig(e).render()}},{key:"_configureAllButtons",value:function(t){var e=this;this.log("configureAllButtons",t),Object.entries(this.buttons).forEach(function(n){var r,o=function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,u=[],c=!0,s=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=i.call(n)).done)&&(u.push(r.value),u.length!==e);c=!0);}catch(t){s=!0,o=t}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw o}}return u}}(t,e)||function(t,e){if(t){if("string"==typeof t)return U(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?U(t,e):void 0}}(t,e)||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.")}()}(n,2),i=o[0],a=o[1],u=null===(r=t.button)||void 0===r?void 0:r.wrapper;u&&a.wrapper!==u||e._configureButton(i,z(z({},t),{},{button:z(z({},t.button),{},{wrapper:a.wrapper})}))})}},{key:"_addButton",value:function(t,e){var n=this;this.log("addButton",t,e);var r=function(){var r;n.buttons[t]||(n.log("createButton.new",t),(r=n.apiConfig&&"object"===L(n.apiConfig)?n.createButtonInstance(t):n.createDummyButtonInstance(t)).setButtonConfig(n.buttonConfig),n.buttons[t]=r),n._configureButton(t,e)};Z(ot,this)?Z(ot,this).then(r):r()}},{key:"renderButtons",value:function(){return this.isEnabled?Object.values(this.buttons).forEach(function(t){return t.render()}):Object.values(this.buttons).forEach(function(t){return t.remove()}),this}},{key:"enable",value:function(){return this.isEnabled||(this.isEnabled=!0,this.renderButtons()),this}},{key:"disable",value:function(){return this.isEnabled||(this.isEnabled=!1,this.renderButtons()),this}}],e&&K(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n,o}();const at=it;function ut(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function ct(t){var e,n=[],r=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return ut(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ut(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var _n=0,r=function(){};return{s:r,n:function(){return _n>=t.length?{done:!0}:{done:!1,value:t[_n++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return i=t.done,t},e:function(t){a=!0,o=t},f:function(){try{i||null==n.return||n.return()}finally{if(a)throw o}}}}(t);try{for(r.s();!(e=r.n()).done;){var o=e.value,i=o.contactField,a=void 0===i?null:i,u=o.code,c=void 0===u?null:u,s=o.message,l=a?new ApplePayError(c,a,void 0===s?null:s):new ApplePayError(c);n.push(l)}}catch(t){r.e(t)}finally{r.f()}return n}function st(t){return st="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},st(t)}function lt(){var t,e,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var c=r&&r.prototype instanceof u?r:u,s=Object.create(c.prototype);return pt(s,"_invoke",function(n,r,o){var i,u,c,s=0,l=o||[],p=!1,f={p:0,n:0,v:t,a:h,f:h.bind(t,4),d:function(e,n){return i=e,u=0,c=t,f.n=n,a}};function h(n,r){for(u=n,c=r,e=0;!p&&s&&!o&&e<l.length;e++){var o,i=l[e],h=f.p,y=i[2];n>3?(o=y===r)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=h&&((o=n<2&&h<i[1])?(u=0,f.v=r,f.n=i[1]):h<y&&(o=n<3||i[0]>r||r>y)&&(i[4]=n,i[5]=r,f.n=y,u=0))}if(o||n>1)return a;throw p=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(p&&1===l&&h(l,y),u=l,c=y;(e=u<2?t:c)||!p;){i||(u?u<3?(u>1&&(f.n=-1),h(u,c)):f.n=c:f.v=c);try{if(s=2,i){if(u||(o="next"),e=i[o]){if(!(e=e.call(i,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,u<2&&(u=0)}else 1===u&&(e=i.return)&&e.call(i),u<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=t}else if((e=(p=f.n<0)?c:n.call(r,f))!==a)break}catch(e){i=t,u=1,c=e}finally{s=1}}return{value:e,done:p}}}(n,o,i),!0),s}var a={};function u(){}function c(){}function s(){}e=Object.getPrototypeOf;var l=[][r]?e(e([][r]())):(pt(e={},r,function(){return this}),e),p=s.prototype=u.prototype=Object.create(l);function f(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,pt(t,o,"GeneratorFunction")),t.prototype=Object.create(p),t}return c.prototype=s,pt(p,"constructor",s),pt(s,"constructor",c),c.displayName="GeneratorFunction",pt(s,o,"GeneratorFunction"),pt(p),pt(p,o,"Generator"),pt(p,r,function(){return this}),pt(p,"toString",function(){return"[object Generator]"}),(lt=function(){return{w:i,m:f}})()}function pt(t,e,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}pt=function(t,e,n,r){function i(e,n){pt(t,e,function(t){return this._invoke(e,n,t)})}e?o?o(t,e,{value:n,enumerable:!r,configurable:!r,writable:!r}):t[e]=n:(i("next",0),i("throw",1),i("return",2))},pt(t,e,n,r)}function ft(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,o)}function ht(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,yt(r.key),r)}}function yt(t){var e=function(t){if("object"!=st(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=st(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==st(e)?e:e+""}var dt=function(){return t=function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.url=e,this.nonce=n},e=[{key:"validate",value:(n=lt().m(function t(e){var n,r,o;return lt().w(function(t){for(;;)switch(t.n){case 0:return n=new FormData(e),t.n=1,fetch(this.url,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify({nonce:this.nonce,form_encoded:new URLSearchParams(n).toString()})});case 1:return r=t.v,t.n=2,r.json();case 2:if((o=t.v).success){t.n=4;break}if(o.data.refresh&&jQuery(document.body).trigger("update_checkout"),!o.data.errors){t.n=3;break}return t.a(2,o.data.errors);case 3:throw Error(o.data.message);case 4:return t.a(2,[])}},t,this)}),r=function(){var t=this,e=arguments;return new Promise(function(r,o){var i=n.apply(t,e);function a(t){ft(i,r,o,a,u,"next",t)}function u(t){ft(i,r,o,a,u,"throw",t)}a(void 0)})},function(_x){return r.apply(this,arguments)})}],e&&ht(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n,r}();function vt(t){return vt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},vt(t)}function bt(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,mt(r.key),r)}}function mt(t){var e=function(t){if("object"!=vt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=vt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==vt(e)?e:e+""}const gt=function(){return t=function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.genericErrorText=e,this.wrapper=n},e=[{key:"genericError",value:function(){this.clear(),this.message(this.genericErrorText)}},{key:"appendPreparedErrorMessageElement",value:function(t){this._getMessageContainer().replaceWith(t)}},{key:"message",value:function(t){this._addMessage(t),this._scrollToMessages()}},{key:"messages",value:function(t){var e=this;t.forEach(function(t){return e._addMessage(t)}),this._scrollToMessages()}},{key:"currentHtml",value:function(){return this._getMessageContainer().outerHTML}},{key:"_addMessage",value:function(t){if("undefined"!=typeof String&&!vt(String)||0===t.length)throw new Error("A new message text must be a non-empty string.");var e=this._getMessageContainer(),n=this._prepareMessageElement(t);e.appendChild(n)}},{key:"_scrollToMessages",value:function(){jQuery.scroll_to_notices(jQuery(".woocommerce-error"))}},{key:"_getMessageContainer",value:function(){var t=document.querySelector("ul.woocommerce-error");return null===t&&((t=document.createElement("ul")).setAttribute("class","woocommerce-error"),t.setAttribute("role","alert"),jQuery(this.wrapper).prepend(t)),t}},{key:"_prepareMessageElement",value:function(t){var e=document.createElement("li");return e.innerHTML=t,e}},{key:"clear",value:function(){jQuery(".woocommerce-error, .woocommerce-message").remove()}}],e&&bt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function wt(t){return wt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wt(t)}function kt(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return St(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?St(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var _n=0,r=function(){};return{s:r,n:function(){return _n>=t.length?{done:!0}:{done:!1,value:t[_n++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return i=t.done,t},e:function(t){a=!0,o=t},f:function(){try{i||null==n.return||n.return()}finally{if(a)throw o}}}}function St(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Pt(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,jt(r.key),r)}}function jt(t){var e=function(t){if("object"!=wt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=wt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==wt(e)?e:e+""}var Ot=function(){return t=function t(e,n){var r=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.selector=e,this.selectorInContainer=n,this.containers=[],this.reloadContainers(),jQuery(window).resize(function(){r.refresh()}).resize(),jQuery(document).on("ppcp-smart-buttons-init",function(){r.refresh()}),jQuery(document).on("ppcp-shown ppcp-hidden ppcp-enabled ppcp-disabled",function(t,e){r.refresh(),setTimeout(r.refresh.bind(r),200)}),new MutationObserver(this.observeElementsCallback.bind(this)).observe(document.body,{childList:!0,subtree:!0})},(e=[{key:"observeElementsCallback",value:function(t,e){var n,r=this.selector+", .widget_shopping_cart, .widget_shopping_cart_content",o=!1,i=kt(t);try{for(i.s();!(n=i.n()).done;){var a=n.value;"childList"===a.type&&a.addedNodes.forEach(function(t){t.matches&&t.matches(r)&&(o=!0)})}}catch(t){i.e(t)}finally{i.f()}o&&(this.reloadContainers(),this.refresh())}},{key:"reloadContainers",value:function(){var t=this;jQuery(this.selector).each(function(e,n){var r=jQuery(n).parent();t.containers.some(function(t){return t.is(r)})||t.containers.push(r)})}},{key:"refresh",value:function(){var t,e=this,n=kt(this.containers);try{var r=function(){var n=t.value,r=jQuery(n),o=r.width();r.removeClass("ppcp-width-500 ppcp-width-300 ppcp-width-min"),o>=500?r.addClass("ppcp-width-500"):o>=300?r.addClass("ppcp-width-300"):r.addClass("ppcp-width-min");var i=r.children(":visible").first();r.find(e.selectorInContainer).each(function(t,e){var n=jQuery(e);if(n.is(i))return n.css("margin-top","0px"),!0;var r=n.height(),o=Math.max(11,Math.round(.3*r));n.css("margin-top","".concat(o,"px"))})};for(n.s();!(t=n.n()).done;)r()}catch(t){n.e(t)}finally{n.f()}}}])&&Pt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),_t="ppcp-gateway",Ct={Cart:"cart",Checkout:"checkout",BlockCart:"cart-block",BlockCheckout:"checkout-block",Product:"product",MiniCart:"mini-cart",PayNow:"pay-now",Preview:"preview",Blocks:["cart-block","checkout-block"],Gateways:["checkout","pay-now"]};function Et(t){return Et="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Et(t)}function At(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function Mt(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?At(Object(n),!0).forEach(function(e){Tt(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):At(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function Tt(t,e,n){return(e=function(t){var e=function(t){if("object"!=Et(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Et(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Et(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var Bt=Object.freeze({INVALIDATE:"ppcp_invalidate_methods",RENDER:"ppcp_render_method",REDRAW:"ppcp_redraw_method"});function It(t){return Object.values(Bt).includes(t)}function xt(t){var e=t.event,n=t.paymentMethod,r=void 0===n?"":n,o=t.callback;if(!It(e))throw new Error("Invalid event: ".concat(e));var i=r?"".concat(e,"-").concat(r):e;document.body.addEventListener(i,o)}var Wt=function(t){return"string"==typeof t?document.querySelector(t):t};function Dt(t){return Dt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Dt(t)}function Rt(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return Nt(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Nt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var _n=0,r=function(){};return{s:r,n:function(){return _n>=t.length?{done:!0}:{done:!1,value:t[_n++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return i=t.done,t},e:function(t){a=!0,o=t},f:function(){try{i||null==n.return||n.return()}finally{if(a)throw o}}}}function Nt(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Gt(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,zt(r.key),r)}}function qt(t,e,n){Lt(t,e),e.set(t,n)}function Lt(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function Ft(t,e,n){return(e=zt(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function zt(t){var e=function(t){if("object"!=Dt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Dt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Dt(e)?e:e+""}function Qt(t,e){return t.get(Vt(t,e))}function Ut(t,e,n){return t.set(Vt(t,e),n),n}function Vt(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}var Ht=new WeakMap,$t=new WeakMap,Jt=new WeakMap,Kt=new WeakMap,Yt=new WeakMap,Xt=new WeakMap,Zt=new WeakMap,te=new WeakMap,ee=new WeakMap,ne=new WeakMap,re=new WeakMap,oe=new WeakMap,ie=new WeakMap,ae=new WeakMap,ue=new WeakMap,ce=new WeakMap,se=new WeakMap,le=new WeakSet,pe=function(){return t=function t(e){var n,r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,c=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Lt(this,r=le),r.add(this),qt(this,Ht,void 0),qt(this,$t,!1),qt(this,Jt,!1),qt(this,Kt,void 0),qt(this,Yt,void 0),qt(this,Xt,void 0),qt(this,Zt,[]),qt(this,te,void 0),qt(this,ee,void 0),qt(this,ne,void 0),qt(this,re,void 0),qt(this,oe,void 0),qt(this,ie,null),qt(this,ae,!0),qt(this,ue,!0),qt(this,ce,null),qt(this,se,[]),this.methodId===t.methodId)throw new Error("Cannot initialize the PaymentButton base class");i||(i={});var l=!(null===(n=i)||void 0===n||!n.is_debug),p=this.methodId.replace(/^ppcp?-/,"");Ut(Kt,this,e),Ut(te,this,i),Ut(ee,this,a),Ut(ne,this,o),Ut(re,this,u),Ut(oe,this,c),this.onClick=s,Ut(Ht,this,new P(p,e)),l&&(Qt(Ht,this).enabled=!0,function(t,e){window.ppcpPaymentButtonList=window.ppcpPaymentButtonList||{};var n=window.ppcpPaymentButtonList;n[t]=n[t]||[],n[t].push(e)}(p,this)),Ut(Yt,this,this.constructor.getWrappers(Qt(te,this),Qt(ee,this))),this.applyButtonStyles(Qt(te,this)),this.registerValidationRules(Vt(le,this,fe).bind(this),Vt(le,this,he).bind(this)),function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:".ppcp-button-apm",n=e;if(!window.ppcpApmButtons){if(t&&t.button){var r=t.button.wrapper;jQuery(r).children('div[class^="item-"]').length>0&&(e+=", ".concat(r,' div[class^="item-"]'),n+=', div[class^="item-"]')}window.ppcpApmButtons=new Ot(e,n)}}(Qt(ee,this)),this.initEventListeners()},e=[{key:"methodId",get:function(){return this.constructor.methodId}},{key:"cssClass",get:function(){return this.constructor.cssClass}},{key:"isInitialized",get:function(){return Qt($t,this)}},{key:"context",get:function(){return Qt(Kt,this)}},{key:"buttonConfig",get:function(){return Qt(te,this)}},{key:"ppcpConfig",get:function(){return Qt(ee,this)}},{key:"externalHandler",get:function(){return Qt(ne,this)||{}}},{key:"contextHandler",get:function(){return Qt(re,this)||{}}},{key:"requiresShipping",get:function(){return"function"==typeof this.contextHandler.shippingAllowed&&this.contextHandler.shippingAllowed()}},{key:"wrappers",get:function(){return Qt(Yt,this)}},{key:"style",get:function(){return Ct.MiniCart===this.context?Qt(Xt,this).MiniCart:Qt(Xt,this).Default}},{key:"wrapperId",get:function(){return Ct.MiniCart===this.context?this.wrappers.MiniCart:this.isSeparateGateway?this.wrappers.Gateway:Ct.Blocks.includes(this.context)?this.wrappers.Block:this.wrappers.Default}},{key:"isInsideClassicGateway",get:function(){return Ct.Gateways.includes(this.context)}},{key:"isSeparateGateway",get:function(){return Qt(te,this).is_wc_gateway_enabled&&this.isInsideClassicGateway}},{key:"isCurrentGateway",get:function(){if(!this.isInsideClassicGateway)return!0;var t,e=(t=document.querySelector('input[name="payment_method"]:checked'))?t.value:null;return this.isSeparateGateway?this.methodId===e:_t===e}},{key:"isPreview",get:function(){return Ct.Preview===this.context}},{key:"isEligible",get:function(){return Qt(ie,this)},set:function(t){t!==Qt(ie,this)&&(Ut(ie,this,t),this.triggerRedraw())}},{key:"isVisible",get:function(){return Qt(ae,this)},set:function(t){Qt(ae,this)!==t&&(Ut(ae,this,t),this.triggerRedraw())}},{key:"isEnabled",get:function(){return Qt(ue,this)},set:function(t){Qt(ue,this)!==t&&(Ut(ue,this,t),this.triggerRedraw())}},{key:"wrapperElement",get:function(){return document.getElementById(this.wrapperId)}},{key:"ppcpButtonWrapperSelector",get:function(){var t,e;return Ct.Blocks.includes(this.context)?null:this.context===Ct.MiniCart?null===(e=this.ppcpConfig)||void 0===e||null===(e=e.button)||void 0===e?void 0:e.mini_cart_wrapper:null===(t=this.ppcpConfig)||void 0===t||null===(t=t.button)||void 0===t?void 0:t.wrapper}},{key:"isPresent",get:function(){return this.wrapperElement instanceof HTMLElement}},{key:"isButtonAttached",get:function(){if(!Qt(ce,this))return!1;for(var t=Qt(ce,this).parentElement;null!==(e=t)&&void 0!==e&&e.parentElement;){var e;if("BODY"===t.tagName)return!0;t=t.parentElement}return!1}},{key:"log",value:function(){var t;(t=Qt(Ht,this)).log.apply(t,arguments)}},{key:"error",value:function(){var t;(t=Qt(Ht,this)).error.apply(t,arguments)}},{key:"logGroup",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;Qt(Ht,this).group(t)}},{key:"registerValidationRules",value:function(t,e){}},{key:"validateConfiguration",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=Rt(Qt(se,this));try{for(n.s();!(t=n.n()).done;){var r=t.value,o=r.check();if(r.shouldPass&&o)return!0;if(!r.shouldPass&&o)return!e&&r.errorMessage&&this.error(r.errorMessage),!1}}catch(t){n.e(t)}finally{n.f()}return!0}},{key:"applyButtonStyles",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;e||(e=this.ppcpConfig),Ut(Xt,this,this.constructor.getStyles(t,e)),this.isInitialized&&this.triggerRedraw()}},{key:"configure",value:function(){}},{key:"init",value:function(){Ut($t,this,!0)}},{key:"reinit",value:function(){Ut($t,this,!1),Ut(ie,this,!1)}},{key:"triggerRedraw",value:function(){this.showPaymentGateway(),function(t){var e=t.event,n=t.paymentMethod,r=void 0===n?"":n;if(!It(e))throw new Error("Invalid event: ".concat(e));var o=r?"".concat(e,"-").concat(r):e;document.body.dispatchEvent(new Event(o))}({event:Bt.REDRAW,paymentMethod:this.methodId})}},{key:"syncProductButtonsState",value:function(){var t,e=document.querySelector(this.ppcpButtonWrapperSelector);e&&(this.isVisible=function(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)}(e),this.isEnabled=!((t=Wt(e))&&jQuery(t).hasClass("ppcp-disabled")))}},{key:"initEventListeners",value:function(){var t=this;if(xt({event:Bt.REDRAW,paymentMethod:this.methodId,callback:function(){return t.refresh()}}),this.isInsideClassicGateway){var e=this.isSeparateGateway?this.methodId:_t;xt({event:Bt.INVALIDATE,callback:function(){return t.isVisible=!1}}),xt({event:Bt.RENDER,paymentMethod:e,callback:function(){return t.isVisible=!0}})}this.context===Ct.Product&&(jQuery(document).on("ppcp-shown ppcp-hidden ppcp-enabled ppcp-disabled",function(e,n){jQuery(n.selector).is(t.ppcpButtonWrapperSelector)&&t.syncProductButtonsState()}),this.syncProductButtonsState())}},{key:"refresh",value:function(){this.isPresent&&(this.isEligible?(this.applyWrapperStyles(),this.isEligible&&this.isCurrentGateway&&this.isVisible&&(this.isButtonAttached||(this.log("refresh.addButton"),this.addButton()))):this.wrapperElement.style.display="none")}},{key:"showPaymentGateway",value:function(){if(!Qt(Jt,this)&&this.isSeparateGateway&&this.isEligible){var t='style[data-hide-gateway="'.concat(this.methodId,'"]'),e="#".concat(this.wrappers.Default),n=document.querySelector(".wc_payment_method.payment_method_".concat(this.methodId));document.querySelectorAll(t).forEach(function(t){return t.remove()}),"none"!==n.style.display&&""!==n.style.display||(n.style.display="block"),document.querySelectorAll(e).forEach(function(t){return t.remove()}),this.log("Show gateway"),Ut(Jt,this,!0),this.isVisible=this.isCurrentGateway}}},{key:"applyWrapperStyles",value:function(){var t,e,n=this.wrapperElement;if(n){var r,o=this.style,i=o.shape,a=o.height,u=Rt(Qt(Zt,this));try{for(u.s();!(r=u.n()).done;){var c=r.value;n.classList.remove(c)}}catch(t){u.e(t)}finally{u.f()}Ut(Zt,this,[]);var s=["ppcp-button-".concat(i),"ppcp-button-apm",this.cssClass];(t=n.classList).add.apply(t,s),(e=Qt(Zt,this)).push.apply(e,s),a&&(n.style.height="".concat(a,"px")),n.style.display=this.isVisible?"block":"none";var l=this.context===Ct.Product?"form.cart":null;!function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=Wt(t);r&&(e?(jQuery(r).removeClass("ppcp-disabled").off("mouseup").find("> *").css("pointer-events",""),function(t,e){jQuery(document).trigger("ppcp-enabled",{handler:"ButtonsDisabler.setEnabled",action:"enable",selector:t,element:e})}(t,r)):(jQuery(r).addClass("ppcp-disabled").on("mouseup",function(t){if(t.stopImmediatePropagation(),n){var e=jQuery(n);e.find(".single_add_to_cart_button").hasClass("disabled")&&e.find(":submit").trigger("click")}}).find("> *").css("pointer-events","none"),function(t,e){jQuery(document).trigger("ppcp-disabled",{handler:"ButtonsDisabler.setEnabled",action:"disable",selector:t,element:e})}(t,r)))}(n,this.isEnabled,l)}}},{key:"addButton",value:function(){throw new Error("Must be implemented by the child class")}},{key:"insertButton",value:function(t){if(this.isPresent){var e=this.wrapperElement;Qt(ce,this)&&this.removeButton(),this.log("insertButton",t),Ut(ce,this,t),e.appendChild(Qt(ce,this))}}},{key:"removeButton",value:function(){if(this.isPresent&&Qt(ce,this)){this.log("removeButton");try{this.wrapperElement.removeChild(Qt(ce,this))}catch(t){}Ut(ce,this,null)}}}],n=[{key:"createButton",value:function(t,e,n,r,o,i){var a,u=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null,c=(a="__ppcpPBInstances",document.body[a]||Object.defineProperty(document.body,a,{value:new Map,enumerable:!1,writable:!1,configurable:!1}),document.body[a]),s="".concat(this.methodId,".").concat(t);if(!c.has(s)){var l=new this(t,e,n,r,o,i,u);c.set(s,l)}return c.get(s)}},{key:"getWrappers",value:function(t,e){throw new Error("Must be implemented in the child class")}},{key:"getStyles",value:function(t,e){throw new Error("Must be implemented in the child class")}}],e&&Gt(t.prototype,e),n&&Gt(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n}();function fe(t,e){Qt(se,this).push({check:t,errorMessage:e,shouldPass:!1})}function he(t){Qt(se,this).push({check:t,shouldPass:!0})}function ye(t){return ye="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ye(t)}function de(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return ve(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ve(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var _n=0,r=function(){};return{s:r,n:function(){return _n>=t.length?{done:!0}:{done:!1,value:t[_n++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return i=t.done,t},e:function(t){a=!0,o=t},f:function(){try{i||null==n.return||n.return()}finally{if(a)throw o}}}}function ve(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function be(){var t,e,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var c=r&&r.prototype instanceof u?r:u,s=Object.create(c.prototype);return me(s,"_invoke",function(n,r,o){var i,u,c,s=0,l=o||[],p=!1,f={p:0,n:0,v:t,a:h,f:h.bind(t,4),d:function(e,n){return i=e,u=0,c=t,f.n=n,a}};function h(n,r){for(u=n,c=r,e=0;!p&&s&&!o&&e<l.length;e++){var o,i=l[e],h=f.p,y=i[2];n>3?(o=y===r)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=h&&((o=n<2&&h<i[1])?(u=0,f.v=r,f.n=i[1]):h<y&&(o=n<3||i[0]>r||r>y)&&(i[4]=n,i[5]=r,f.n=y,u=0))}if(o||n>1)return a;throw p=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(p&&1===l&&h(l,y),u=l,c=y;(e=u<2?t:c)||!p;){i||(u?u<3?(u>1&&(f.n=-1),h(u,c)):f.n=c:f.v=c);try{if(s=2,i){if(u||(o="next"),e=i[o]){if(!(e=e.call(i,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,u<2&&(u=0)}else 1===u&&(e=i.return)&&e.call(i),u<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=t}else if((e=(p=f.n<0)?c:n.call(r,f))!==a)break}catch(e){i=t,u=1,c=e}finally{s=1}}return{value:e,done:p}}}(n,o,i),!0),s}var a={};function u(){}function c(){}function s(){}e=Object.getPrototypeOf;var l=[][r]?e(e([][r]())):(me(e={},r,function(){return this}),e),p=s.prototype=u.prototype=Object.create(l);function f(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,me(t,o,"GeneratorFunction")),t.prototype=Object.create(p),t}return c.prototype=s,me(p,"constructor",s),me(s,"constructor",c),c.displayName="GeneratorFunction",me(s,o,"GeneratorFunction"),me(p),me(p,o,"Generator"),me(p,r,function(){return this}),me(p,"toString",function(){return"[object Generator]"}),(be=function(){return{w:i,m:f}})()}function me(t,e,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}me=function(t,e,n,r){function i(e,n){me(t,e,function(t){return this._invoke(e,n,t)})}e?o?o(t,e,{value:n,enumerable:!r,configurable:!r,writable:!r}):t[e]=n:(i("next",0),i("throw",1),i("return",2))},me(t,e,n,r)}function ge(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,o)}function we(t){return function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function a(t){ge(i,r,o,a,u,"next",t)}function u(t){ge(i,r,o,a,u,"throw",t)}a(void 0)})}}function ke(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function Se(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ke(Object(n),!0).forEach(function(e){Te(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ke(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function Pe(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Be(r.key),r)}}function je(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(je=function(){return!!t})()}function Oe(t,e,n,r){var o=_e(Ce(1&r?t.prototype:t),e,n);return 2&r&&"function"==typeof o?function(t){return o.apply(n,t)}:o}function _e(){return _e="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=Ce(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}},_e.apply(null,arguments)}function Ce(t){return Ce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ce(t)}function Ee(t,e){return Ee=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ee(t,e)}function Ae(t,e,n){Me(t,e),e.set(t,n)}function Me(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function Te(t,e,n){return(e=Be(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Be(t){var e=function(t){if("object"!=ye(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=ye(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ye(e)?e:e+""}function Ie(t,e){return t.get(We(t,e))}function xe(t,e,n){return t.set(We(t,e),n),n}function We(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}Ft(pe,"methodId","generic"),Ft(pe,"cssClass","");var De=new WeakMap,Re=new WeakMap,Ne=new WeakMap,Ge=new WeakMap,qe=new WeakMap,Le=new WeakMap,Fe=new WeakMap,ze=new WeakMap,Qe=new WeakMap,Ue=new WeakMap,Ve=new WeakSet,He=function(t){function e(t,n,r,o,i,a){var u,c,s;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),u=function(t,e,n){return e=Ce(e),function(t,e){if(e&&("object"==ye(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,je()?Reflect.construct(e,n||[],Ce(t).constructor):e.apply(t,n))}(this,e,[t,n,r,o,i,a]),Me(c=u,s=Ve),s.add(c),Ae(u,De,null),Ae(u,Re,[]),Ae(u,Ne,[]),Ae(u,Ge,null),Ae(u,qe,null),Ae(u,Le,null),Ae(u,Fe,{}),Ae(u,ze,0),Ae(u,Qe,1e3),Ae(u,Ue,null),u.init=u.init.bind(u),u.onPaymentAuthorized=u.onPaymentAuthorized.bind(u),u.onButtonClick=u.onButtonClick.bind(u),xe(Fe,u,{quantity:null,items:[]}),u.log("Create instance"),u}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Ee(t,e)}(e,t),n=e,r=[{key:"requiresShipping",get:function(){var t;return!!Oe(e,"requiresShipping",this,1)&&!(null===(t=this.buttonConfig.product)||void 0===t||!t.needShipping)&&(Ct.Checkout!==this.context||this.shouldUpdateButtonWithFormData)}},{key:"transactionInfo",get:function(){return Ie(qe,this)},set:function(t){xe(qe,this,t),this.refresh()}},{key:"nonce",get:function(){var t=document.getElementById("woocommerce-process-checkout-nonce");return(null==t?void 0:t.value)||this.buttonConfig.nonce}},{key:"registerValidationRules",value:function(t,e){var n=this;e(function(){return n.isPreview}),t(function(){return!Ie(Le,n)},"No API configuration - missing configure() call?"),t(function(){return!Ie(qe,n)},"No transactionInfo - missing configure() call?"),t(function(){var t;return(null===(t=n.buttonAttributes)||void 0===t?void 0:t.height)&&isNaN(parseInt(n.buttonAttributes.height))},"Invalid height in buttonAttributes"),t(function(){var t;return(null===(t=n.buttonAttributes)||void 0===t?void 0:t.borderRadius)&&isNaN(parseInt(n.buttonAttributes.borderRadius))},"Invalid borderRadius in buttonAttributes"),t(function(){var t;return!(null!==(t=n.contextHandler)&&void 0!==t&&t.validateContext())},"Invalid context handler.")}},{key:"configure",value:function(t,e){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};Ie(ze,this)||xe(ze,this,Date.now()),null!=r&&r.height&&null!=r&&r.borderRadius&&xe(Ue,this,Se({},r));var o=null!=r&&r.height?r:Ie(Ue,this);if(Date.now()-Ie(ze,this)>Ie(Qe,this))return this.log("ApplePay: Timeout waiting for buttonAttributes - proceeding with initialization"),xe(Le,this,t),xe(qe,this,e),this.buttonAttributes=o||r,void this.init();null!=o&&o.height&&null!=o&&o.borderRadius?(xe(ze,this,0),xe(Le,this,t),xe(qe,this,e),this.buttonAttributes=o,this.init()):setTimeout(function(){return n.configure(t,e,r)},100)}},{key:"init",value:function(){this.isInitialized||this.validateConfiguration()&&(Oe(e,"init",this,3)([]),this.checkEligibility())}},{key:"reinit",value:(a=we(be().m(function t(){var n=this;return be().w(function(t){for(;;)switch(t.n){case 0:if(this.validateConfiguration(!0)){t.n=1;break}return t.a(2);case 1:return t.n=2,this.contextHandler.transactionInfo().then(function(t){n.transactionInfo=t}).catch(function(t){console.error("Failed to get transaction info:",t)});case 2:Oe(e,"reinit",this,3)([]),this.init();case 3:return t.a(2)}},t,this)})),function(){return a.apply(this,arguments)})},{key:"checkEligibility",value:function(){if(this.isPreview)this.isEligible=!0;else try{var t;if(null===(t=window.ApplePaySession)||void 0===t||!t.canMakePayments())return void(this.isEligible=!1);this.isEligible=!!Ie(Le,this).isEligible}catch(t){this.isEligible=!1}}},{key:"applePaySession",value:function(t){this.log("applePaySession",t);var e=new ApplePaySession(4,t);return this.requiresShipping&&(e.onshippingmethodselected=this.onShippingMethodSelected(e),e.onshippingcontactselected=this.onShippingContactSelected(e)),e.onvalidatemerchant=this.onValidateMerchant(e),e.onpaymentauthorized=this.onPaymentAuthorized(e),e.begin(),e}},{key:"applyWrapperStyles",value:function(){var t,n;Oe(e,"applyWrapperStyles",this,3)([]);var r=this.wrapperElement;if(r){var o=null!==(t=this.buttonAttributes)&&void 0!==t&&t.height||null!==(n=this.buttonAttributes)&&void 0!==n&&n.borderRadius?this.buttonAttributes:Ie(Ue,this),i=null!=o&&o.height?parseInt(o.height,10):48;isNaN(i)?(r.style.setProperty("--apple-pay-button-height","".concat(48,"px")),r.style.height="".concat(48,"px")):(r.style.setProperty("--apple-pay-button-height","".concat(i,"px")),r.style.height="".concat(i,"px"));var a=null!=o&&o.borderRadius?parseInt(o.borderRadius,10):4;isNaN(a)||(r.style.borderRadius="".concat(a,"px"))}}},{key:"addButton",value:function(){var t,e,n=this,r=this.style,o=r.color,i=r.type,a=r.language;null!==(t=this.buttonAttributes)&&void 0!==t&&t.height||null===(e=Ie(Ue,this))||void 0===e||!e.height||(this.buttonAttributes=Se({},Ie(Ue,this)));var u=document.createElement("apple-pay-button");u.id="apple-"+this.wrapperId,u.setAttribute("buttonstyle",o),u.setAttribute("type",i),u.setAttribute("locale",a),u.style.display="block",u.addEventListener("click",function(t){t.preventDefault(),n.onButtonClick()}),this.insertButton(u)}},{key:"onButtonClick",value:(i=we(be().m(function t(){var e,n,r,o,i,a,u,c;return be().w(function(t){for(;;)switch(t.p=t.n){case 0:if(this.log("onButtonClick"),e=this.paymentRequest(),window.ppcpFundingSource="apple_pay",Ct.Checkout!==this.context){t.n=6;break}n="form.woocommerce-checkout",r=new gt(PayPalCommerceGateway.labels.error.generic,document.querySelector(".woocommerce-notices-wrapper"));try{o=new FormData(document.querySelector(n)),xe(De,this,Object.fromEntries(o.entries())),this.updateRequestDataWithForm(e)}catch(t){console.error(t)}if(this.log("=== paymentRequest",e),i=this.applePaySession(e),!(a=PayPalCommerceGateway.early_checkout_validation_enabled?new dt(PayPalCommerceGateway.ajax.validate_checkout.endpoint,PayPalCommerceGateway.ajax.validate_checkout.nonce):null)){t.n=5;break}return t.p=1,t.n=2,a.validate(document.querySelector(n));case 2:if(!((u=t.v).length>0)){t.n=3;break}return r.messages(u),jQuery(document.body).trigger("checkout_error",[r.currentHtml()]),i.abort(),t.a(2);case 3:t.n=5;break;case 4:t.p=4,c=t.v,console.error(c);case 5:return t.a(2);case 6:this.applePaySession(e);case 7:return t.a(2)}},t,this,[[1,4]])})),function(){return i.apply(this,arguments)})},{key:"shouldUpdateButtonWithFormData",get:function(){var t;return Ct.Checkout===this.context&&"use_applepay"===(null===(t=this.buttonConfig)||void 0===t||null===(t=t.preferences)||void 0===t?void 0:t.checkout_data_mode)}},{key:"shouldCompletePaymentWithContextHandler",get:function(){return!this.contextHandler.shippingAllowed()||Ct.Checkout===this.context&&!this.shouldUpdateButtonWithFormData}},{key:"updateRequestDataWithForm",value:function(t){if(this.shouldUpdateButtonWithFormData&&(t.billingContact=this.fillBillingContact(Ie(De,this)),this.requiresShipping)){t.shippingContact=this.fillShippingContact(Ie(De,this));var e=this.transactionInfo.chosenShippingMethods[0];t.shippingMethods=[];var n,r=de(this.transactionInfo.shippingPackages);try{for(r.s();!(n=r.n()).done;){var o=n.value;if(e===o.id){var i={label:o.label,detail:"",amount:o.cost_str,identifier:o.id};xe(Ne,this,i),t.shippingMethods.push(i);break}}}catch(t){r.e(t)}finally{r.f()}var a,u=de(this.transactionInfo.shippingPackages);try{for(u.s();!(a=u.n()).done;){var c=a.value;e!==c.id&&t.shippingMethods.push({label:c.label,detail:"",amount:c.cost_str,identifier:c.id})}}catch(t){u.e(t)}finally{u.f()}xe(Ge,this,t),this.log("=== paymentRequest.shippingMethods",t.shippingMethods)}}},{key:"paymentRequest",value:function(){var t=Ie(Le,this),e=this.buttonConfig,n={countryCode:t.countryCode,merchantCapabilities:t.merchantCapabilities,supportedNetworks:t.supportedNetworks,requiredShippingContactFields:["postalAddress","email","phone"],requiredBillingContactFields:["postalAddress"]};this.requiresShipping||(this.shouldCompletePaymentWithContextHandler?n.requiredShippingContactFields=[]:n.requiredShippingContactFields=["email","phone"]);var r=Object.assign({},n);return r.currencyCode=e.shop.currencyCode,r.total={label:e.shop.totalLabel,type:"final",amount:this.transactionInfo.totalPrice},r}},{key:"refreshProductContextData",value:function(){var t;Ct.Product===this.context&&(Ie(Fe,this).quantity=null===(t=document.querySelector("input.qty"))||void 0===t?void 0:t.value,Ie(Fe,this).items=this.contextHandler.products(),this.log("Products updated",Ie(Fe,this)))}},{key:"adminValidation",value:function(t){fetch(this.buttonConfig.ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({action:"ppcp_validate","woocommerce-process-checkout-nonce":this.nonce,validation:t}).toString()})}},{key:"onValidateMerchant",value:function(t){var e=this;return function(n){e.log("onvalidatemerchant call"),f.paypal.Applepay().validateMerchant({validationUrl:n.validationURL}).then(function(n){t.completeMerchantValidation(n.merchantSession),e.adminValidation(!0)}).catch(function(n){console.error(n),e.adminValidation(!1),e.log("onvalidatemerchant session abort"),t.abort()})}}},{key:"onShippingMethodSelected",value:function(t){var e=this;this.log("onshippingmethodselected",this.buttonConfig.ajax_url);var n=this.buttonConfig.ajax_url;return function(r){e.log("onshippingmethodselected call");var o=e.getShippingMethodData(r);jQuery.ajax({url:n,method:"POST",data:o,success:function(n){e.log("onshippingmethodselected ok");var o=n.data;!1===n.success&&(o.errors=ct(o.errors)),xe(Ne,e,r.shippingMethod),o.newShippingMethods=o.newShippingMethods.sort(function(t){return t.label===Ie(Ne,e).label?-1:1}),!1===n.success&&(o.errors=ct(o.errors)),t.completeShippingMethodSelection(o)},error:function(n,r,o){e.log("onshippingmethodselected error",r),console.warn(r,o),t.abort()}})}}},{key:"onShippingContactSelected",value:function(t){var e=this;this.log("onshippingcontactselected",this.buttonConfig.ajax_url);var n=this.buttonConfig.ajax_url;return function(r){e.log("onshippingcontactselected call");var o=e.getShippingContactData(r);jQuery.ajax({url:n,method:"POST",data:o,success:function(n){e.log("onshippingcontactselected ok");var o=n.data;xe(Re,e,r.shippingContact),!1===n.success&&(o.errors=ct(o.errors)),o.newShippingMethods&&xe(Ne,e,o.newShippingMethods[0]),t.completeShippingContactSelection(o)},error:function(n,r,o){e.log("onshippingcontactselected error",r),console.warn(r,o),t.abort()}})}}},{key:"getShippingContactData",value:function(t){var e=this.buttonConfig.product.id;switch(this.refreshProductContextData(),this.context){case Ct.Product:return{action:"ppcp_update_shipping_contact",product_id:e,products:JSON.stringify(Ie(Fe,this).items),caller_page:"productDetail",product_quantity:Ie(Fe,this).quantity,simplified_contact:t.shippingContact,need_shipping:this.requiresShipping,"woocommerce-process-checkout-nonce":this.nonce};case Ct.Cart:case Ct.Checkout:case Ct.BlockCart:case Ct.BlockCheckout:case Ct.MiniCart:return{action:"ppcp_update_shipping_contact",simplified_contact:t.shippingContact,caller_page:"cart",need_shipping:this.requiresShipping,"woocommerce-process-checkout-nonce":this.nonce}}}},{key:"getShippingMethodData",value:function(t){var e,n,r,o,i,a,u=this.buttonConfig.product.id;switch(this.refreshProductContextData(),this.context){case Ct.Product:return{action:"ppcp_update_shipping_method",shipping_method:t.shippingMethod,simplified_contact:this.hasValidContactInfo(Ie(Re,this))?Ie(Re,this):null!==(e=null===(n=Ie(Ge,this))||void 0===n?void 0:n.shippingContact)&&void 0!==e?e:null===(r=Ie(Ge,this))||void 0===r?void 0:r.billingContact,product_id:u,products:JSON.stringify(Ie(Fe,this).items),caller_page:"productDetail",product_quantity:Ie(Fe,this).quantity,"woocommerce-process-checkout-nonce":this.nonce};case Ct.Cart:case Ct.Checkout:case Ct.BlockCart:case Ct.BlockCheckout:case Ct.MiniCart:return{action:"ppcp_update_shipping_method",shipping_method:t.shippingMethod,simplified_contact:this.hasValidContactInfo(Ie(Re,this))?Ie(Re,this):null!==(o=null===(i=Ie(Ge,this))||void 0===i?void 0:i.shippingContact)&&void 0!==o?o:null===(a=Ie(Ge,this))||void 0===a?void 0:a.billingContact,caller_page:"cart","woocommerce-process-checkout-nonce":this.nonce}}}},{key:"onPaymentAuthorized",value:function(t){var e=this;return this.log("onpaymentauthorized"),function(){var n=we(be().m(function n(r){var o,i,a,u,c,s,l,p;return be().w(function(n){for(;;)switch(n.p=n.n){case 0:return e.log("onpaymentauthorized call"),o=function(){var t=we(be().m(function t(n){return be().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,o){try{var i,a=n.billing_contact||Ie(Ge,e).billingContact,u=n.shipping_contact||Ie(Ge,e).shippingContact,c=Ie(Ne,e)||(Ie(Ge,e).shippingMethods||[])[0],s={action:"ppcp_create_order",caller_page:e.context,product_id:null!==(i=e.buttonConfig.product.id)&&void 0!==i?i:null,products:JSON.stringify(Ie(Fe,e).items),product_quantity:Ie(Fe,e).quantity,shipping_contact:u,billing_contact:a,token:r.payment.token,shipping_method:c,"woocommerce-process-checkout-nonce":e.nonce,funding_source:"applepay",_wp_http_referer:"/?wc-ajax=update_order_review",paypal_order_id:n.paypal_order_id};e.log("onpaymentauthorized request",e.buttonConfig.ajax_url,n),jQuery.ajax({url:e.buttonConfig.ajax_url,method:"POST",data:s,complete:function(){e.log("onpaymentauthorized complete")},success:function(n){e.log("onpaymentauthorized ok"),t(n)},error:function(t,n,r){e.log("onpaymentauthorized error",n),o(new Error(r))}})}catch(t){e.error("onpaymentauthorized catch",t)}}))},t)}));return function(e){return t.apply(this,arguments)}}(),n.n=1,e.contextHandler.createOrder();case 1:return i=n.v,e.log("onpaymentauthorized paypal order ID",i,r.payment.token,r.payment.billingContact),n.p=2,n.n=3,f.paypal.Applepay().confirmOrder({orderId:i,token:r.payment.token,billingContact:r.payment.billingContact});case 3:if(a=n.v,e.log("onpaymentauthorized confirmOrderResponse",a),!a||!a.approveApplePayPayment){n.n=13;break}if("APPROVED"!==a.approveApplePayPayment.status){n.n=11;break}if(n.p=4,!e.shouldCompletePaymentWithContextHandler){n.n=6;break}return u=!1,n.n=5,e.contextHandler.approveOrder({orderID:i},{restart:function(){return new Promise(function(t){u=!0,t()})},order:{get:function(){return new Promise(function(t){t(null)})}}});case 5:u?(e.error("onpaymentauthorized approveOrder FAIL"),t.completePayment(ApplePaySession.STATUS_FAILURE),t.abort()):(e.log("onpaymentauthorized approveOrder OK"),t.completePayment(ApplePaySession.STATUS_SUCCESS)),n.n=8;break;case 6:return c={billing_contact:r.payment.billingContact,shipping_contact:r.payment.shippingContact,paypal_order_id:i},n.n=7,o(c);case 7:"success"===(s=n.v).result?(t.completePayment(ApplePaySession.STATUS_SUCCESS),window.location.href=s.redirect):t.completePayment(ApplePaySession.STATUS_FAILURE);case 8:n.n=10;break;case 9:n.p=9,l=n.v,t.completePayment(ApplePaySession.STATUS_FAILURE),t.abort(),console.error(l);case 10:n.n=12;break;case 11:console.error("Error status is not APPROVED"),t.completePayment(ApplePaySession.STATUS_FAILURE);case 12:n.n=14;break;case 13:console.error("Invalid confirmOrderResponse"),t.completePayment(ApplePaySession.STATUS_FAILURE);case 14:n.n=16;break;case 15:n.p=15,p=n.v,console.error("Error confirming order with applepay token",p),t.completePayment(ApplePaySession.STATUS_FAILURE),t.abort();case 16:return n.a(2)}},n,null,[[4,9],[2,15]])}));return function(_x){return n.apply(this,arguments)}}()}},{key:"fillBillingContact",value:function(t){return We(Ve,this,$e).call(this,t,"billing","")}},{key:"fillShippingContact",value:function(t){return null!=t&&t.shipping_first_name?We(Ve,this,$e).call(this,t,"shipping","billing"):this.fillBillingContact(t)}},{key:"hasValidContactInfo",value:function(t){return Array.isArray(t)?t.length>0:Object.keys(t||{}).length>0}}],o=[{key:"getWrappers",value:function(t,e){var n,r,o;return function(){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",o=function(t){return t.replace(/^#/,"")};return{Default:o(arguments.length>0&&void 0!==arguments[0]?arguments[0]:""),SmartButton:o(e),Block:o(n),Gateway:o(r),MiniCart:o(t)}}((null==t||null===(n=t.button)||void 0===n?void 0:n.wrapper)||"",(null==t||null===(r=t.button)||void 0===r?void 0:r.mini_cart_wrapper)||"",(null==e||null===(o=e.button)||void 0===o?void 0:o.wrapper)||"","ppc-button-applepay-container","ppc-button-ppcp-applepay")}},{key:"getStyles",value:function(t,e){var n=(null==t?void 0:t.button)||{},r={color:n.color,lang:n.lang,type:n.type},o={style:r,mini_cart_style:r};return function(t,e){return{Default:Mt(Mt({},t.style),e.style),MiniCart:Mt(Mt({},t.mini_cart_style),e.mini_cart_style)}}((null==e?void 0:e.button)||{},o)}}],r&&Pe(n.prototype,r),o&&Pe(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o,i,a}(pe);function $e(t,e,n){t&&"object"===ye(t)||(t={});var r=function(r){return t["".concat(e,"_").concat(r)]||t["".concat(n,"_").concat(r)]||""};return{givenName:r("first_name"),familyName:r("last_name"),emailAddress:r("email"),phoneNumber:r("phone"),addressLines:[r("address_1"),r("address_2")],locality:r("city"),postalCode:r("postcode"),countryCode:r("country"),administrativeArea:r("state")}}Te(He,"methodId","ppcp-applepay"),Te(He,"cssClass","ppcp-button-applepay");const Je=He;function Ke(t){return Ke="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ke(t)}function Ye(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Xe(r.key),r)}}function Xe(t){var e=function(t){if("object"!=Ke(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Ke(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ke(e)?e:e+""}function Ze(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Ze=function(){return!!t})()}function tn(t){return tn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},tn(t)}function en(t,e){return en=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},en(t,e)}function nn(t,e){return t.get(rn(t,e))}function rn(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}var on=new WeakMap,an=function(t){function e(t){var n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e,n){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,n)}(n=function(t,e,n){return e=tn(e),function(t,e){if(e&&("object"==Ke(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Ze()?Reflect.construct(e,n||[],tn(t).constructor):e.apply(t,n))}(this,e,[t]),on,null),n.selector="".concat(t.selector,"ApplePay"),n.defaultAttributes={button:{type:"pay",color:"black",lang:"en"}},n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&en(t,e)}(e,t),n=e,(r=[{key:"createButton",value:function(t){var e,n;nn(on,this)||(e=on,n=new Je("preview",null,t,this.ppcpConfig),e.set(rn(e,this),n)),nn(on,this).configure(this.apiConfig,null),nn(on,this).applyButtonStyles(t,this.ppcpConfig),nn(on,this).reinit()}},{key:"dynamicPreviewConfig",value:function(t,e){var n;t.button.wrapper=t.button.wrapper.replace(/^#/,""),e.button&&(t.button.type=e.button.style.type,t.button.color=e.button.style.color,t.button.lang=(null===(n=e.button.style)||void 0===n?void 0:n.lang)||e.button.style.language)}}])&&Ye(n.prototype,r),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r}(A);function un(t){return un="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},un(t)}function cn(){var t,e,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var c=r&&r.prototype instanceof u?r:u,s=Object.create(c.prototype);return sn(s,"_invoke",function(n,r,o){var i,u,c,s=0,l=o||[],p=!1,f={p:0,n:0,v:t,a:h,f:h.bind(t,4),d:function(e,n){return i=e,u=0,c=t,f.n=n,a}};function h(n,r){for(u=n,c=r,e=0;!p&&s&&!o&&e<l.length;e++){var o,i=l[e],h=f.p,y=i[2];n>3?(o=y===r)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=h&&((o=n<2&&h<i[1])?(u=0,f.v=r,f.n=i[1]):h<y&&(o=n<3||i[0]>r||r>y)&&(i[4]=n,i[5]=r,f.n=y,u=0))}if(o||n>1)return a;throw p=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(p&&1===l&&h(l,y),u=l,c=y;(e=u<2?t:c)||!p;){i||(u?u<3?(u>1&&(f.n=-1),h(u,c)):f.n=c:f.v=c);try{if(s=2,i){if(u||(o="next"),e=i[o]){if(!(e=e.call(i,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,u<2&&(u=0)}else 1===u&&(e=i.return)&&e.call(i),u<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=t}else if((e=(p=f.n<0)?c:n.call(r,f))!==a)break}catch(e){i=t,u=1,c=e}finally{s=1}}return{value:e,done:p}}}(n,o,i),!0),s}var a={};function u(){}function c(){}function s(){}e=Object.getPrototypeOf;var l=[][r]?e(e([][r]())):(sn(e={},r,function(){return this}),e),p=s.prototype=u.prototype=Object.create(l);function f(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,sn(t,o,"GeneratorFunction")),t.prototype=Object.create(p),t}return c.prototype=s,sn(p,"constructor",s),sn(s,"constructor",c),c.displayName="GeneratorFunction",sn(s,o,"GeneratorFunction"),sn(p),sn(p,o,"Generator"),sn(p,r,function(){return this}),sn(p,"toString",function(){return"[object Generator]"}),(cn=function(){return{w:i,m:f}})()}function sn(t,e,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}sn=function(t,e,n,r){function i(e,n){sn(t,e,function(t){return this._invoke(e,n,t)})}e?o?o(t,e,{value:n,enumerable:!r,configurable:!r,writable:!r}):t[e]=n:(i("next",0),i("throw",1),i("return",2))},sn(t,e,n,r)}function ln(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,o)}function pn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,fn(r.key),r)}}function fn(t){var e=function(t){if("object"!=un(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=un(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==un(e)?e:e+""}function hn(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(hn=function(){return!!t})()}function yn(t){return yn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},yn(t)}function dn(t,e){return dn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},dn(t,e)}var vn=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e,n){return e=yn(e),function(t,e){if(e&&("object"==un(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,hn()?Reflect.construct(e,n||[],yn(t).constructor):e.apply(t,n))}(this,e,[{methodName:"ApplePay",buttonConfig:window.wc_ppcp_applepay_admin}])}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&dn(t,e)}(e,t),n=e,r=[{key:"fetchConfig",value:(o=cn().m(function t(e){var n,r;return cn().w(function(t){for(;;)switch(t.n){case 0:if(r=null==e||null===(n=e.Applepay())||void 0===n?void 0:n.config){t.n=1;break}return this.error("configuration object cannot be retrieved from PayPal"),t.a(2,{});case 1:return t.n=2,r();case 2:return t.a(2,t.v)}},t,this)}),i=function(){var t=this,e=arguments;return new Promise(function(n,r){var i=o.apply(t,e);function a(t){ln(i,n,r,a,u,"next",t)}function u(t){ln(i,n,r,a,u,"throw",t)}a(void 0)})},function(_x){return i.apply(this,arguments)})},{key:"createButtonInstance",value:function(t){return new an({selector:t,apiConfig:this.apiConfig,methodName:this.methodName})}}],r&&pn(n.prototype,r),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o,i}(at);vn.instance||(vn.instance=new vn),vn.instance})();