← Back
Editing: ppcp-applepay-js-boot-admin.js
(()=>{"use strict";const t={n:e=>{const n=e&&e.__esModule?()=>e.default:()=>e;return t.d(n,{a:n}),n},cw:t=>{var e;return()=>{if(t){var n=t;t=0,e={exports:{}},n.call(e.exports,e,e.exports)}return e.exports}},d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.hasOwn(t,e)};var e=t.cw(function(t,e){var n=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===r}(t)}(t)},r="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function o(t,e){return!1!==e.clone&&e.isMergeableObject(t)?c((n=t,Array.isArray(n)?[]:{}),t,e):t;var n}function i(t,e,n){return t.concat(e).map(function(t){return o(t,n)})}function a(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 u(t,e){try{return e in t}catch(t){return!1}}function c(t,e,r){(r=r||{}).arrayMerge=r.arrayMerge||i,r.isMergeableObject=r.isMergeableObject||n,r.cloneUnlessOtherwiseSpecified=o;var s=Array.isArray(e);return s===Array.isArray(t)?s?r.arrayMerge(t,e,r):function(t,e,n){var r={};return n.isMergeableObject(t)&&a(t).forEach(function(e){r[e]=o(t[e],n)}),a(e).forEach(function(i){(function(t,e){return u(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))})(t,i)||(u(t,i)&&n.isMergeableObject(e[i])?r[i]=function(t,e){if(!e.customMerge)return c;var n=e.customMerge(t);return"function"==typeof n?n:c}(i,n)(t[i],e[i],n):r[i]=o(e[i],n))}),r}(t,e,r):o(e,r)}c.all=function(t,e){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(t,n){return c(t,n,e)},{})};var s=c;t.exports=s});function n(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 r(t){return r="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},r(t)}function o(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)||a(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 i(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=a(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,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return i=t.done,t},e:function(t){u=!0,o=t},f:function(){try{i||null==n.return||n.return()}finally{if(u)throw o}}}}function a(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}}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 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,s(r.key),r)}}function s(t){var e=function(t){if("object"!=r(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==r(e)?e:e+""}"function"==typeof SuppressedError&&SuppressedError;var l=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=i(this.buttons);try{for(e.s();!(t=e.n()).done;){var n=o(t.value,1)[0];this.renderButtons(n)}}catch(t){e.e(t)}finally{e.f()}}},{key:"removeButtons",value:function(t){var e,n=i(this.buttons);try{for(n.s();!(e=n.n()).done;){var r=o(e.value,2),a=r[0],u=r[1];(Array.isArray(u.wrapper)?u.wrapper[0]:u.wrapper)===t&&this.buttons.delete(a)}}catch(t){n.e(t)}finally{n.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=i(this.messages);try{for(e.s();!(t=e.n()).done;){var n=o(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=i(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}}])&&c(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();window.widgetBuilder=window.widgetBuilder||new l;const p=window.widgetBuilder;function f(t){return f="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},f(t)}function h(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"!=f(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=f(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==f(e)?e:e+""}function d(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 v(t,e){return t.get(m(t,e))}function b(t,e,n){return t.set(m(t,e),n),n}function m(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,w=new WeakMap,k=new WeakMap,S=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),d(this,g,""),d(this,w,!1),d(this,k,null);for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];n.length&&b(g,this,"[".concat(n.join(" | "),"]"))},e=[{key:"enabled",set:function(t){b(w,this,t)}},{key:"log",value:function(){if(v(w,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,[v(g,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,[v(g,this)].concat(n))}},{key:"group",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;v(w,this)&&(t&&!v(k,this)||(console.groupEnd(),b(k,this,null)),t&&(console.group(t),b(k,this,t)))}}],e&&h(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function P(){return P.c||(P.c=t.n(e()))}function j(t){return j="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},j(t)}function O(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,_(r.key),r)}}function _(t){var e=function(t){if("object"!=j(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=j(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==j(e)?e:e+""}e();const E=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=P()()(this.defaultAttributes,t),this.buttonConfig.button.wrapper=this.selector,this}},{key:"setPpcpConfig",value:function(t){return this.ppcpConfig=P()()({},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=P()()({},this.buttonConfig),n=this.isDynamic?P()()({},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)}}])&&O(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function C(t){return C="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},C(t)}function A(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,T(r.key),r)}}function T(t){var e=function(t){if("object"!=C(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=C(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==C(e)?e:e+""}function M(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(M=function(){return!!t})()}function B(){return B="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=I(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}},B.apply(null,arguments)}function I(t){return I=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},I(t)}function x(t,e){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},x(t,e)}function W(t,e){return t.get(D(t,e))}function D(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 R=new WeakMap,N=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=I(e),function(t,e){if(e&&("object"==C(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,M()?Reflect.construct(e,n||[],I(t).constructor):e.apply(t,n))}(this,e,[t]),R,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&&x(t,e)}(e,t),n=e,r=[{key:"createNewWrapper",value:function(){var t,n,r,o=(t=e,n=this,"function"==typeof(r=B(I(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=W(R,this))||void 0===e||e.remove(),r=R,o=document.createElement("div"),r.set(D(r,this),o),W(R,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(W(R,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&&A(n.prototype,r),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r}(E);function G(t){return G="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},G(t)}function q(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 F(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?q(Object(n),!0).forEach(function(e){L(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):q(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function L(t,e,n){return(e=J(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 z(){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 Q(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]())):(Q(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,Q(t,o,"GeneratorFunction")),t.prototype=Object.create(p),t}return c.prototype=s,Q(p,"constructor",s),Q(s,"constructor",c),c.displayName="GeneratorFunction",Q(s,o,"GeneratorFunction"),Q(p),Q(p,o,"Generator"),Q(p,r,function(){return this}),Q(p,"toString",function(){return"[object Generator]"}),(z=function(){return{w:i,m:f}})()}function Q(t,e,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}Q=function(t,e,n,r){function i(e,n){Q(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))},Q(t,e,n,r)}function H(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 V(t){return function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function a(t){H(i,r,o,a,u,"next",t)}function u(t){H(i,r,o,a,u,"throw",t)}a(void 0)})}}function $(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,J(r.key),r)}}function J(t){var e=function(t){if("object"!=G(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=G(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==G(e)?e:e+""}function K(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 Y(t,e){return t.get(Z(t,e))}function X(t,e,n){return t.set(Z(t,e),n),n}function Z(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 tt=new WeakMap,et=new WeakMap,nt=new WeakMap,rt=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),K(this,tt,void 0),K(this,et,void 0),K(this,nt,void 0),this.methodName=c,this.buttonConfig=s,this.defaultAttributes=l,this.isEnabled=!0,this.buttons={},this.apiConfig=null,this.apiError="",X(tt,this,new S(this.methodName,"preview-manager")),Y(tt,this).enabled=!0,X(nt,this,new Promise(function(t){X(et,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=V(z().m(function t(e){return z().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 N({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=Y(tt,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=Y(tt,this)).error.apply(e,[t].concat(r))}},{key:"isDynamic",value:function(){return!!document.querySelector('[data-ppcp-apm-name="'.concat(this.methodName,'"]'))}},{key:"bootstrap",value:(r=V(z().m(function t(){var e,r,o,i,a,u,c=this;return z().w(function(t){for(;;)switch(t.p=t.n){case 0:if(r=1e4,o=200,null!==(e=this.buttonConfig)&&void 0!==e&&e.sdk_url&&p){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 n=0,a=setInterval(function(){p.paypal?i(t,e,a):n>=r&&i(t,e,a,!1),n+=o},o)}),u=n({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(p.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,Y(et,this).call(this);case 7:X(nt,this,null);case 8:return t.a(2)}},t,this,[[3,5]])})),function(){return r.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,F(F({},t),{},{button:F(F({},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"===G(n.apiConfig)?n.createButtonInstance(t):n.createDummyButtonInstance(t)).setButtonConfig(n.buttonConfig),n.buttons[t]=r),n._configureButton(t,e)};Y(nt,this)?Y(nt,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&&$(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,o}();const ot=rt;function it(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 at(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 it(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)?it(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 ut(t){return ut="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},ut(t)}function ct(){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 st(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]())):(st(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,st(t,o,"GeneratorFunction")),t.prototype=Object.create(p),t}return c.prototype=s,st(p,"constructor",s),st(s,"constructor",c),c.displayName="GeneratorFunction",st(s,o,"GeneratorFunction"),st(p),st(p,o,"Generator"),st(p,r,function(){return this}),st(p,"toString",function(){return"[object Generator]"}),(ct=function(){return{w:i,m:f}})()}function st(t,e,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}st=function(t,e,n,r){function i(e,n){st(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))},st(t,e,n,r)}function lt(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 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,ft(r.key),r)}}function ft(t){var e=function(t){if("object"!=ut(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=ut(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ut(e)?e:e+""}var ht=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=ct().m(function t(e){var n,r,o;return ct().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){lt(i,r,o,a,u,"next",t)}function u(t){lt(i,r,o,a,u,"throw",t)}a(void 0)})},function(_x){return r.apply(this,arguments)})}],e&&pt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n,r}();function yt(t){return yt="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},yt(t)}function dt(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,vt(r.key),r)}}function vt(t){var e=function(t){if("object"!=yt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=yt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==yt(e)?e:e+""}const bt=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&&!yt(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&&dt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function mt(t){return mt="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},mt(t)}function gt(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 wt(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)?wt(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 wt(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 kt(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,St(r.key),r)}}function St(t){var e=function(t){if("object"!=mt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=mt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==mt(e)?e:e+""}var Pt=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=gt(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=gt(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()}}}])&&kt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),jt="ppcp-gateway",Ot={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 _t(t){return _t="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(t)}function Et(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 Ct(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Et(Object(n),!0).forEach(function(e){At(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Et(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function At(t,e,n){return(e=function(t){var e=function(t){if("object"!=_t(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=_t(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==_t(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var Tt=Object.freeze({INVALIDATE:"ppcp_invalidate_methods",RENDER:"ppcp_render_method",REDRAW:"ppcp_redraw_method"});function Mt(t){return Object.values(Tt).includes(t)}function Bt(t){var e=t.event,n=t.paymentMethod,r=void 0===n?"":n,o=t.callback;if(!Mt(e))throw new Error("Invalid event: ".concat(e));var i=r?"".concat(e,"-").concat(r):e;document.body.addEventListener(i,o)}var It=function(t){return"string"==typeof t?document.querySelector(t):t};function xt(){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 Wt(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]())):(Wt(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,Wt(t,o,"GeneratorFunction")),t.prototype=Object.create(p),t}return c.prototype=s,Wt(p,"constructor",s),Wt(s,"constructor",c),c.displayName="GeneratorFunction",Wt(s,o,"GeneratorFunction"),Wt(p),Wt(p,o,"Generator"),Wt(p,r,function(){return this}),Wt(p,"toString",function(){return"[object Generator]"}),(xt=function(){return{w:i,m:f}})()}function Wt(t,e,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}Wt=function(t,e,n,r){function i(e,n){Wt(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))},Wt(t,e,n,r)}function Dt(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 Rt(t){var e=(null==t?void 0:t.message)||"unknown error";return null!=t&&t.status?"HTTP ".concat(t.status," ").concat(e):e}function Nt(){var t;return t=xt().m(function t(e,n,r){var o,i,a=arguments;return xt().w(function(t){for(;;)switch(t.p=t.n){case 0:if(o=a.length>3&&void 0!==a[3]?a[3]:"",i=a.length>4&&void 0!==a[4]?a[4]:"error",t.p=1,("error"===i||"warning"===i?console.error:console.info)("[PPCP ".concat(n,"] ").concat(r),o),null!=e&&e.endpoint){t.n=2;break}return t.a(2);case 2:return t.n=3,fetch(e.endpoint,{method:"POST",credentials:"same-origin",keepalive:!0,headers:{"Content-Type":"application/json"},body:JSON.stringify({nonce:e.nonce,tag:n,event:r,message:String(o),level:i})});case 3:t.n=5;break;case 4:t.p=4,t.v;case 5:return t.a(2)}},t,null,[[1,4]])}),Nt=function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function a(t){Dt(i,r,o,a,u,"next",t)}function u(t){Dt(i,r,o,a,u,"throw",t)}a(void 0)})},Nt.apply(this,arguments)}function Gt(t){return Gt="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},Gt(t)}function qt(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 Ft(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)?Ft(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 Ft(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 Lt(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,Ht(r.key),r)}}function Ut(t,e,n){zt(t,e),e.set(t,n)}function zt(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function Qt(t,e,n){return(e=Ht(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ht(t){var e=function(t){if("object"!=Gt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Gt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Gt(e)?e:e+""}function Vt(t,e){return t.get(Jt(t,e))}function $t(t,e,n){return t.set(Jt(t,e),n),n}function Jt(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 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 WeakMap,pe=new WeakMap,fe=new WeakMap,he=new WeakSet,ye=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),zt(this,r=he),r.add(this),Ut(this,Kt,void 0),Ut(this,Yt,!1),Ut(this,Xt,!1),Ut(this,Zt,void 0),Ut(this,te,void 0),Ut(this,ee,void 0),Ut(this,ne,[]),Ut(this,re,void 0),Ut(this,oe,void 0),Ut(this,ie,void 0),Ut(this,ae,void 0),Ut(this,ue,void 0),Ut(this,ce,null),Ut(this,se,!0),Ut(this,le,!0),Ut(this,pe,null),Ut(this,fe,[]),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?-/,"");$t(Zt,this,e),$t(re,this,i),$t(oe,this,a),$t(ie,this,o),$t(ae,this,u),$t(ue,this,c),this.onClick=s,$t(Kt,this,new S(p,e)),l&&(Vt(Kt,this).enabled=!0,function(t,e){window.ppcpPaymentButtonList=window.ppcpPaymentButtonList||{};var n=window.ppcpPaymentButtonList;n[t]=n[t]||[],n[t].push(e)}(p,this)),$t(te,this,this.constructor.getWrappers(Vt(re,this),Vt(oe,this))),this.applyButtonStyles(Vt(re,this)),this.registerValidationRules(Jt(he,this,de).bind(this),Jt(he,this,ve).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 Pt(e,n)}}(Vt(oe,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 Vt(Yt,this)}},{key:"context",get:function(){return Vt(Zt,this)}},{key:"buttonConfig",get:function(){return Vt(re,this)}},{key:"ppcpConfig",get:function(){return Vt(oe,this)}},{key:"externalHandler",get:function(){return Vt(ie,this)||{}}},{key:"contextHandler",get:function(){return Vt(ae,this)||{}}},{key:"requiresShipping",get:function(){return"function"==typeof this.contextHandler.shippingAllowed&&this.contextHandler.shippingAllowed()}},{key:"wrappers",get:function(){return Vt(te,this)}},{key:"style",get:function(){return Ot.MiniCart===this.context?Vt(ee,this).MiniCart:Vt(ee,this).Default}},{key:"wrapperId",get:function(){return Ot.MiniCart===this.context?this.wrappers.MiniCart:this.isSeparateGateway?this.wrappers.Gateway:Ot.Blocks.includes(this.context)?this.wrappers.Block:this.wrappers.Default}},{key:"isInsideClassicGateway",get:function(){return Ot.Gateways.includes(this.context)}},{key:"isSeparateGateway",get:function(){return Vt(re,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:jt===e}},{key:"isPreview",get:function(){return Ot.Preview===this.context}},{key:"isEligible",get:function(){return Vt(ce,this)},set:function(t){t!==Vt(ce,this)&&($t(ce,this,t),this.triggerRedraw())}},{key:"isVisible",get:function(){return Vt(se,this)},set:function(t){Vt(se,this)!==t&&($t(se,this,t),this.triggerRedraw())}},{key:"isEnabled",get:function(){return Vt(le,this)},set:function(t){Vt(le,this)!==t&&($t(le,this,t),this.triggerRedraw())}},{key:"wrapperElement",get:function(){return document.getElementById(this.wrapperId)}},{key:"ppcpButtonWrapperSelector",get:function(){var t,e;return Ot.Blocks.includes(this.context)?null:this.context===Ot.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(!Vt(pe,this))return!1;for(var t=Vt(pe,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=Vt(Kt,this)).log.apply(t,arguments)}},{key:"error",value:function(){var t;(t=Vt(Kt,this)).error.apply(t,arguments)}},{key:"logEvent",value:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"error";!function(_x,t,e){Nt.apply(this,arguments)}(null===(e=this.ppcpConfig)||void 0===e||null===(e=e.ajax)||void 0===e?void 0:e.frontend_log,this.methodId,t,n,r)}},{key:"logGroup",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;Vt(Kt,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=qt(Vt(fe,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),$t(ee,this,this.constructor.getStyles(t,e)),this.isInitialized&&this.triggerRedraw()}},{key:"configure",value:function(){}},{key:"init",value:function(){$t(Yt,this,!0)}},{key:"reinit",value:function(){$t(Yt,this,!1),$t(ce,this,!1)}},{key:"triggerRedraw",value:function(){this.showPaymentGateway(),function(t){var e=t.event,n=t.paymentMethod,r=void 0===n?"":n;if(!Mt(e))throw new Error("Invalid event: ".concat(e));var o=r?"".concat(e,"-").concat(r):e;document.body.dispatchEvent(new Event(o))}({event:Tt.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=It(e))&&jQuery(t).hasClass("ppcp-disabled")))}},{key:"initEventListeners",value:function(){var t=this;if(Bt({event:Tt.REDRAW,paymentMethod:this.methodId,callback:function(){return t.refresh()}}),this.isInsideClassicGateway){var e=this.isSeparateGateway?this.methodId:jt;Bt({event:Tt.INVALIDATE,callback:function(){return t.isVisible=!1}}),Bt({event:Tt.RENDER,paymentMethod:e,callback:function(){return t.isVisible=!0}})}this.context===Ot.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(!Vt(Xt,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"),$t(Xt,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=qt(Vt(ne,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()}$t(ne,this,[]);var s=["ppcp-button-".concat(i),"ppcp-button-apm",this.cssClass];(t=n.classList).add.apply(t,s),(e=Vt(ne,this)).push.apply(e,s),a&&(n.style.height="".concat(a,"px")),n.style.display=this.isVisible?"block":"none";var l=this.context===Ot.Product?"form.cart":null;!function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=It(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;Vt(pe,this)&&this.removeButton(),this.log("insertButton",t),$t(pe,this,t),e.appendChild(Vt(pe,this))}}},{key:"removeButton",value:function(){if(this.isPresent&&Vt(pe,this)){this.log("removeButton");try{this.wrapperElement.removeChild(Vt(pe,this))}catch(t){}$t(pe,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&&Lt(t.prototype,e),n&&Lt(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n}();function de(t,e){Vt(fe,this).push({check:t,errorMessage:e,shouldPass:!1})}function ve(t){Vt(fe,this).push({check:t,shouldPass:!0})}function be(t){return be="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},be(t)}function me(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 ge(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)?ge(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 ge(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 we(){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 ke(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]())):(ke(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,ke(t,o,"GeneratorFunction")),t.prototype=Object.create(p),t}return c.prototype=s,ke(p,"constructor",s),ke(s,"constructor",c),c.displayName="GeneratorFunction",ke(s,o,"GeneratorFunction"),ke(p),ke(p,o,"Generator"),ke(p,r,function(){return this}),ke(p,"toString",function(){return"[object Generator]"}),(we=function(){return{w:i,m:f}})()}function ke(t,e,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}ke=function(t,e,n,r){function i(e,n){ke(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))},ke(t,e,n,r)}function Se(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 Pe(t){return function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function a(t){Se(i,r,o,a,u,"next",t)}function u(t){Se(i,r,o,a,u,"throw",t)}a(void 0)})}}function je(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 Oe(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?je(Object(n),!0).forEach(function(e){xe(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):je(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _e(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,We(r.key),r)}}function Ee(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Ee=function(){return!!t})()}function Ce(t,e,n,r){var o=Ae(Te(1&r?t.prototype:t),e,n);return 2&r&&"function"==typeof o?function(t){return o.apply(n,t)}:o}function Ae(){return Ae="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=Te(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}},Ae.apply(null,arguments)}function Te(t){return Te=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Te(t)}function Me(t,e){return Me=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Me(t,e)}function Be(t,e,n){Ie(t,e),e.set(t,n)}function Ie(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function xe(t,e,n){return(e=We(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function We(t){var e=function(t){if("object"!=be(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=be(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==be(e)?e:e+""}function De(t,e){return t.get(Ne(t,e))}function Re(t,e,n){return t.set(Ne(t,e),n),n}function Ne(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")}Qt(ye,"methodId","generic"),Qt(ye,"cssClass","");var Ge=new WeakMap,qe=new WeakMap,Fe=new WeakMap,Le=new WeakMap,Ue=new WeakMap,ze=new WeakMap,Qe=new WeakMap,He=new WeakMap,Ve=new WeakMap,$e=new WeakMap,Je=new WeakSet,Ke=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=Te(e),function(t,e){if(e&&("object"==be(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,Ee()?Reflect.construct(e,n||[],Te(t).constructor):e.apply(t,n))}(this,e,[t,n,r,o,i,a]),Ie(c=u,s=Je),s.add(c),Be(u,Ge,null),Be(u,qe,[]),Be(u,Fe,[]),Be(u,Le,null),Be(u,Ue,null),Be(u,ze,null),Be(u,Qe,{}),Be(u,He,0),Be(u,Ve,1e3),Be(u,$e,null),u.init=u.init.bind(u),u.onPaymentAuthorized=u.onPaymentAuthorized.bind(u),u.onButtonClick=u.onButtonClick.bind(u),Re(Qe,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&&Me(t,e)}(e,t),n=e,r=[{key:"requiresShipping",get:function(){var t;return!!Ce(e,"requiresShipping",this,1)&&!(null===(t=this.buttonConfig.product)||void 0===t||!t.needShipping)&&(Ot.Checkout!==this.context||this.shouldUpdateButtonWithFormData)}},{key:"transactionInfo",get:function(){return De(Ue,this)},set:function(t){Re(Ue,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!De(ze,n)},"No API configuration - missing configure() call?"),t(function(){return!De(Ue,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]:{};De(He,this)||Re(He,this,Date.now()),null!=r&&r.height&&null!=r&&r.borderRadius&&Re($e,this,Oe({},r));var o=null!=r&&r.height?r:De($e,this);if(Date.now()-De(He,this)>De(Ve,this))return this.log("ApplePay: Timeout waiting for buttonAttributes - proceeding with initialization"),Re(ze,this,t),Re(Ue,this,e),this.buttonAttributes=o||r,void this.init();null!=o&&o.height&&null!=o&&o.borderRadius?(Re(He,this,0),Re(ze,this,t),Re(Ue,this,e),this.buttonAttributes=o,this.init()):setTimeout(function(){return n.configure(t,e,r)},100)}},{key:"init",value:function(){this.isInitialized||this.validateConfiguration()&&(Ce(e,"init",this,3)([]),this.checkEligibility())}},{key:"reinit",value:(a=Pe(we().m(function t(){var n=this;return we().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){n.logEvent("transaction-info-failed",Rt(t))});case 2:Ce(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=!!De(ze,this).isEligible}catch(t){this.isEligible=!1,this.logEvent("eligibility-check-failed",Rt(t))}}},{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;Ce(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:De($e,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=De($e,this))||void 0===e||!e.height||(this.buttonAttributes=Oe({},De($e,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=Pe(we().m(function t(){var e,n,r,o,i,a,u,c,s;return we().w(function(t){for(;;)switch(t.p=t.n){case 0:this.log("onButtonClick"),t.p=1,e=this.paymentRequest(),t.n=3;break;case 2:return t.p=2,c=t.v,this.logEvent("payment-request-failed",Rt(c)),t.a(2);case 3:if(window.ppcpFundingSource="apple_pay",Ot.Checkout!==this.context){t.n=9;break}n="form.woocommerce-checkout",r=new bt(PayPalCommerceGateway.labels.error.generic,document.querySelector(".woocommerce-notices-wrapper"));try{o=new FormData(document.querySelector(n)),Re(Ge,this,Object.fromEntries(o.entries())),this.updateRequestDataWithForm(e)}catch(t){this.logEvent("form-data-failed",Rt(t))}if(this.log("=== paymentRequest",e),i=this.applePaySession(e),!(a=PayPalCommerceGateway.early_checkout_validation_enabled?new ht(PayPalCommerceGateway.ajax.validate_checkout.endpoint,PayPalCommerceGateway.ajax.validate_checkout.nonce):null)){t.n=8;break}return t.p=4,t.n=5,a.validate(document.querySelector(n));case 5:if(!((u=t.v).length>0)){t.n=6;break}return r.messages(u),jQuery(document.body).trigger("checkout_error",[r.currentHtml()]),this.logEvent("checkout-validation-abort","errors=".concat(u.length)),i.abort(),t.a(2);case 6:t.n=8;break;case 7:return t.p=7,s=t.v,this.logEvent("form-validation-failed",Rt(s)),i.abort(),t.a(2);case 8:return t.a(2);case 9:this.applePaySession(e);case 10:return t.a(2)}},t,this,[[4,7],[1,2]])})),function(){return i.apply(this,arguments)})},{key:"shouldUpdateButtonWithFormData",get:function(){var t;return Ot.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()||Ot.Checkout===this.context&&!this.shouldUpdateButtonWithFormData}},{key:"updateRequestDataWithForm",value:function(t){if(this.shouldUpdateButtonWithFormData&&(t.billingContact=this.fillBillingContact(De(Ge,this)),this.requiresShipping)){t.shippingContact=this.fillShippingContact(De(Ge,this));var e=this.transactionInfo.chosenShippingMethods[0];t.shippingMethods=[];var n,r=me(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};Re(Fe,this,i),t.shippingMethods.push(i);break}}}catch(t){r.e(t)}finally{r.f()}var a,u=me(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()}Re(Le,this,t),this.log("=== paymentRequest.shippingMethods",t.shippingMethods)}}},{key:"paymentRequest",value:function(){var t=De(ze,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;Ot.Product===this.context&&(De(Qe,this).quantity=null===(t=document.querySelector("input.qty"))||void 0===t?void 0:t.value,De(Qe,this).items=this.contextHandler.products(),this.log("Products updated",De(Qe,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"),p.paypal.Applepay().validateMerchant({validationUrl:n.validationURL}).then(function(n){t.completeMerchantValidation(n.merchantSession),e.adminValidation(!0)}).catch(function(n){e.logEvent("merchant-validation-failed",Rt(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");try{var o=n.data;!1===n.success&&(o.errors=at(o.errors)),Re(Fe,e,r.shippingMethod),o.newShippingMethods=o.newShippingMethods.sort(function(t){return t.label===De(Fe,e).label?-1:1}),t.completeShippingMethodSelection(o)}catch(r){e.logEvent("shipping-method-invalid-response","".concat(Rt(r)," keys=").concat(Object.keys(null!=n?n:{}).join(","))),t.abort()}},error:function(n,r,o){e.logEvent("shipping-method-abort","HTTP ".concat(n.status," ").concat(r," ").concat(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");try{var o=n.data;Re(qe,e,r.shippingContact),!1===n.success&&(o.errors=at(o.errors)),o.newShippingMethods&&Re(Fe,e,o.newShippingMethods[0]),t.completeShippingContactSelection(o)}catch(r){e.logEvent("shipping-contact-invalid-response","".concat(Rt(r)," keys=").concat(Object.keys(null!=n?n:{}).join(","))),t.abort()}},error:function(n,r,o){e.logEvent("shipping-contact-abort","HTTP ".concat(n.status," ").concat(r," ").concat(o)),t.abort()}})}}},{key:"getShippingContactData",value:function(t){var e=this.buttonConfig.product.id;switch(this.refreshProductContextData(),this.context){case Ot.Product:return{action:"ppcp_update_shipping_contact",product_id:e,products:JSON.stringify(De(Qe,this).items),caller_page:"productDetail",product_quantity:De(Qe,this).quantity,simplified_contact:t.shippingContact,need_shipping:this.requiresShipping,"woocommerce-process-checkout-nonce":this.nonce};case Ot.Cart:case Ot.Checkout:case Ot.BlockCart:case Ot.BlockCheckout:case Ot.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 Ot.Product:return{action:"ppcp_update_shipping_method",shipping_method:t.shippingMethod,simplified_contact:this.hasValidContactInfo(De(qe,this))?De(qe,this):null!==(e=null===(n=De(Le,this))||void 0===n?void 0:n.shippingContact)&&void 0!==e?e:null===(r=De(Le,this))||void 0===r?void 0:r.billingContact,product_id:u,products:JSON.stringify(De(Qe,this).items),caller_page:"productDetail",product_quantity:De(Qe,this).quantity,"woocommerce-process-checkout-nonce":this.nonce};case Ot.Cart:case Ot.Checkout:case Ot.BlockCart:case Ot.BlockCheckout:case Ot.MiniCart:return{action:"ppcp_update_shipping_method",shipping_method:t.shippingMethod,simplified_contact:this.hasValidContactInfo(De(qe,this))?De(qe,this):null!==(o=null===(i=De(Le,this))||void 0===i?void 0:i.shippingContact)&&void 0!==o?o:null===(a=De(Le,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=Pe(we().m(function n(r){var o,i,a,u,c,s,l,f,h;return we().w(function(n){for(;;)switch(n.p=n.n){case 0:return e.log("onpaymentauthorized call"),o=function(){var t=Pe(we().m(function t(n){return we().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,o){try{var i,a=n.billing_contact||De(Le,e).billingContact,u=n.shipping_contact||De(Le,e).shippingContact,c=De(Fe,e)||(De(Le,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(De(Qe,e).items),product_quantity:De(Qe,e).quantity,shipping_contact:u,billing_contact:a,token:r.payment.token,shipping_method:c,"woocommerce-process-checkout-nonce":e.nonce,funding_source:"apple_pay",_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.logEvent("capture-request-failed","HTTP ".concat(t.status," ").concat(n," ").concat(r)),o(new Error(r||"HTTP ".concat(t.status," ").concat(n)))}})}catch(t){e.logEvent("capture-exception",Rt(t)),o(t)}}))},t)}));return function(e){return t.apply(this,arguments)}}(),n.p=1,n.n=2,e.contextHandler.createOrder();case 2:i=n.v,n.n=4;break;case 3:return n.p=3,l=n.v,e.logEvent("create-order-failed",Rt(l)),t.completePayment(ApplePaySession.STATUS_FAILURE),t.abort(),n.a(2);case 4:if(i){n.n=5;break}return e.logEvent("create-order-failed","no order id"),t.completePayment(ApplePaySession.STATUS_FAILURE),t.abort(),n.a(2);case 5:return e.log("onpaymentauthorized paypal order ID",i,r.payment.token,r.payment.billingContact),n.p=6,n.n=7,p.paypal.Applepay().confirmOrder({orderId:i,token:r.payment.token,billingContact:r.payment.billingContact});case 7:if(a=n.v,e.log("onpaymentauthorized confirmOrderResponse",a),!a||!a.approveApplePayPayment){n.n=17;break}if("APPROVED"!==a.approveApplePayPayment.status){n.n=15;break}if(n.p=8,!e.shouldCompletePaymentWithContextHandler){n.n=10;break}return u=!1,n.n=9,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 9:u?(e.logEvent("approve-order-failed"),t.completePayment(ApplePaySession.STATUS_FAILURE),t.abort()):(e.log("onpaymentauthorized approveOrder OK"),t.completePayment(ApplePaySession.STATUS_SUCCESS)),n.n=12;break;case 10:return c={billing_contact:r.payment.billingContact,shipping_contact:r.payment.shippingContact,paypal_order_id:i},n.n=11,o(c);case 11:"success"===(s=n.v).result?(t.completePayment(ApplePaySession.STATUS_SUCCESS),window.location.href=s.redirect):(e.logEvent("capture-failed","result=".concat(null==s?void 0:s.result)),t.completePayment(ApplePaySession.STATUS_FAILURE));case 12:n.n=14;break;case 13:n.p=13,f=n.v,e.logEvent("authorization-failed",Rt(f)),t.completePayment(ApplePaySession.STATUS_FAILURE),t.abort();case 14:n.n=16;break;case 15:e.logEvent("confirm-order-not-approved","status=".concat(a.approveApplePayPayment.status)),t.completePayment(ApplePaySession.STATUS_FAILURE);case 16:n.n=18;break;case 17:e.logEvent("confirm-order-unrecognized","keys=".concat(Object.keys(null!=a?a:{}).join(","))),t.completePayment(ApplePaySession.STATUS_FAILURE);case 18:n.n=20;break;case 19:n.p=19,h=n.v,e.logEvent("confirm-order-failed",Rt(h)),t.completePayment(ApplePaySession.STATUS_FAILURE),t.abort();case 20:return n.a(2)}},n,null,[[8,13],[6,19],[1,3]])}));return function(_x){return n.apply(this,arguments)}}()}},{key:"fillBillingContact",value:function(t){return Ne(Je,this,Ye).call(this,t,"billing","")}},{key:"fillShippingContact",value:function(t){return null!=t&&t.shipping_first_name?Ne(Je,this,Ye).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:Ct(Ct({},t.style),e.style),MiniCart:Ct(Ct({},t.mini_cart_style),e.mini_cart_style)}}((null==e?void 0:e.button)||{},o)}}],r&&_e(n.prototype,r),o&&_e(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o,i,a}(ye);function Ye(t,e,n){t&&"object"===be(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")}}xe(Ke,"methodId","ppcp-applepay"),xe(Ke,"cssClass","ppcp-button-applepay");const Xe=Ke;function Ze(t){return Ze="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},Ze(t)}function tn(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,en(r.key),r)}}function en(t){var e=function(t){if("object"!=Ze(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Ze(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ze(e)?e:e+""}function nn(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(nn=function(){return!!t})()}function rn(t){return rn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},rn(t)}function on(t,e){return on=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},on(t,e)}function an(t,e){return t.get(un(t,e))}function un(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 cn=new WeakMap,sn=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=rn(e),function(t,e){if(e&&("object"==Ze(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,nn()?Reflect.construct(e,n||[],rn(t).constructor):e.apply(t,n))}(this,e,[t]),cn,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&&on(t,e)}(e,t),n=e,(r=[{key:"createButton",value:function(t){var e,n;an(cn,this)||(e=cn,n=new Xe("preview",null,t,this.ppcpConfig),e.set(un(e,this),n)),an(cn,this).configure(this.apiConfig,null),an(cn,this).applyButtonStyles(t,this.ppcpConfig),an(cn,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)}}])&&tn(n.prototype,r),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r}(E);function ln(t){return ln="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},ln(t)}function pn(){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 fn(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]())):(fn(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,fn(t,o,"GeneratorFunction")),t.prototype=Object.create(p),t}return c.prototype=s,fn(p,"constructor",s),fn(s,"constructor",c),c.displayName="GeneratorFunction",fn(s,o,"GeneratorFunction"),fn(p),fn(p,o,"Generator"),fn(p,r,function(){return this}),fn(p,"toString",function(){return"[object Generator]"}),(pn=function(){return{w:i,m:f}})()}function fn(t,e,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}fn=function(t,e,n,r){function i(e,n){fn(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))},fn(t,e,n,r)}function hn(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 yn(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,dn(r.key),r)}}function dn(t){var e=function(t){if("object"!=ln(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=ln(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ln(e)?e:e+""}function vn(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(vn=function(){return!!t})()}function bn(t){return bn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},bn(t)}function mn(t,e){return mn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},mn(t,e)}var gn=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=bn(e),function(t,e){if(e&&("object"==ln(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,vn()?Reflect.construct(e,n||[],bn(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&&mn(t,e)}(e,t),n=e,r=[{key:"fetchConfig",value:(o=pn().m(function t(e){var n,r;return pn().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){hn(i,n,r,a,u,"next",t)}function u(t){hn(i,n,r,a,u,"throw",t)}a(void 0)})},function(_x){return i.apply(this,arguments)})},{key:"createButtonInstance",value:function(t){return new sn({selector:t,apiConfig:this.apiConfig,methodName:this.methodName})}}],r&&yn(n.prototype,r),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o,i}(ot);gn.instance||(gn.instance=new gn),gn.instance})();
Save File
Cancel