Ubuntu

­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­ (()=>{"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{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 f=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('
')),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 f;const p=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;n0&&void 0!==arguments[0]?arguments[0]:null;b(P,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}(),O=n(4744),j=n.n(O);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 E(t,e){for(var n=0;n'.concat(this.label,""),this._applyStyles(null===(n=this.ppcpConfig)||void 0===n||null===(n=n.button)||void 0===n?void 0:n.style),this.domWrapper.appendChild(x(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 q(t){return q="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},q(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 z(t){for(var e=1;et.length)&&(e=t.length);for(var n=0,r=Array(e);n3?(o=y===r)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=h&&((o=n<2&&hr||r>y)&&(i[4]=n,i[5]=r,p.n=y,u=0))}if(o||n>1)return a;throw f=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&h(l,y),u=l,c=y;(e=u<2?t:c)||!f;){i||(u?u<3?(u>1&&(p.n=-1),h(u,c)):p.n=c:p.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=(f=p.n<0)?c:n.call(r,p))!==a)break}catch(e){i=t,u=1,c=e}finally{s=1}}return{value:e,done:f}}}(n,o,i),!0),s}var a={};function u(){}function c(){}function s(){}e=Object.getPrototypeOf;var l=[][r]?e(e([][r]())):(U(e={},r,function(){return this}),e),f=s.prototype=u.prototype=Object.create(l);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,U(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return c.prototype=s,U(f,"constructor",s),U(s,"constructor",c),c.displayName="GeneratorFunction",U(s,o,"GeneratorFunction"),U(f),U(f,o,"Generator"),U(f,r,function(){return this}),U(f,"toString",function(){return"[object Generator]"}),(V=function(){return{w:i,m:p}})()}function U(t,e,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}U=function(t,e,n,r){function i(e,n){U(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))},U(t,e,n,r)}function Y(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 $(t){return function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function a(t){Y(i,r,o,a,u,"next",t)}function u(t){Y(i,r,o,a,u,"throw",t)}a(void 0)})}}function J(t,e){for(var n=0;n1?n-1:0),o=1;o1?n-1:0),o=1;o3&&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(){p.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(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,X(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 F(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)?F(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"===q(n.apiConfig)?n.createButtonInstance(t):n.createDummyButtonInstance(t)).setButtonConfig(n.buttonConfig),n.buttons[t]=r),n._configureButton(t,e)};X(ot,this)?X(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&&J(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n,o}();const at=it;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(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 st(t){for(var e=1;e=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 vt(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n=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()}}}])&&bt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),wt="ppcp-gateway",Pt={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"]},St=function(t){return"string"==typeof t?document.querySelector(t):t};function kt(t){return kt="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},kt(t)}function Ot(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 jt(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)?jt(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 jt(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n1&&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),Ct(this,r=Kt),r.add(this),Et(this,Dt,void 0),Et(this,Rt,!1),Et(this,Wt,!1),Et(this,xt,void 0),Et(this,Nt,void 0),Et(this,Gt,void 0),Et(this,Lt,[]),Et(this,qt,void 0),Et(this,Qt,void 0),Et(this,zt,void 0),Et(this,Ht,void 0),Et(this,Ft,void 0),Et(this,Vt,null),Et(this,Ut,!0),Et(this,Yt,!0),Et(this,$t,null),Et(this,Jt,[]),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),f=this.methodId.replace(/^ppcp?-/,"");Bt(xt,this,e),Bt(qt,this,i),Bt(Qt,this,a),Bt(zt,this,o),Bt(Ht,this,u),Bt(Ft,this,c),this.onClick=s,Bt(Dt,this,new k(f,e)),l&&(Tt(Dt,this).enabled=!0,function(t,e){window.ppcpPaymentButtonList=window.ppcpPaymentButtonList||{};var n=window.ppcpPaymentButtonList;n[t]=n[t]||[],n[t].push(e)}(f,this)),Bt(Nt,this,this.constructor.getWrappers(Tt(qt,this),Tt(Qt,this))),this.applyButtonStyles(Tt(qt,this)),this.registerValidationRules(Mt(Kt,this,Xt).bind(this),Mt(Kt,this,te).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 gt(e,n)}}(Tt(Qt,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 Tt(Rt,this)}},{key:"context",get:function(){return Tt(xt,this)}},{key:"buttonConfig",get:function(){return Tt(qt,this)}},{key:"ppcpConfig",get:function(){return Tt(Qt,this)}},{key:"externalHandler",get:function(){return Tt(zt,this)||{}}},{key:"contextHandler",get:function(){return Tt(Ht,this)||{}}},{key:"requiresShipping",get:function(){return"function"==typeof this.contextHandler.shippingAllowed&&this.contextHandler.shippingAllowed()}},{key:"wrappers",get:function(){return Tt(Nt,this)}},{key:"style",get:function(){return Pt.MiniCart===this.context?Tt(Gt,this).MiniCart:Tt(Gt,this).Default}},{key:"wrapperId",get:function(){return Pt.MiniCart===this.context?this.wrappers.MiniCart:this.isSeparateGateway?this.wrappers.Gateway:Pt.Blocks.includes(this.context)?this.wrappers.Block:this.wrappers.Default}},{key:"isInsideClassicGateway",get:function(){return Pt.Gateways.includes(this.context)}},{key:"isSeparateGateway",get:function(){return Tt(qt,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:wt===e}},{key:"isPreview",get:function(){return Pt.Preview===this.context}},{key:"isEligible",get:function(){return Tt(Vt,this)},set:function(t){t!==Tt(Vt,this)&&(Bt(Vt,this,t),this.triggerRedraw())}},{key:"isVisible",get:function(){return Tt(Ut,this)},set:function(t){Tt(Ut,this)!==t&&(Bt(Ut,this,t),this.triggerRedraw())}},{key:"isEnabled",get:function(){return Tt(Yt,this)},set:function(t){Tt(Yt,this)!==t&&(Bt(Yt,this,t),this.triggerRedraw())}},{key:"wrapperElement",get:function(){return document.getElementById(this.wrapperId)}},{key:"ppcpButtonWrapperSelector",get:function(){var t,e;return Pt.Blocks.includes(this.context)?null:this.context===Pt.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(!Tt($t,this))return!1;for(var t=Tt($t,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=Tt(Dt,this)).log.apply(t,arguments)}},{key:"error",value:function(){var t;(t=Tt(Dt,this)).error.apply(t,arguments)}},{key:"logGroup",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;Tt(Dt,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=Ot(Tt(Jt,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),Bt(Gt,this,this.constructor.getStyles(t,e)),this.isInitialized&&this.triggerRedraw()}},{key:"configure",value:function(){}},{key:"init",value:function(){Bt(Rt,this,!0)}},{key:"reinit",value:function(){Bt(Rt,this,!1),Bt(Vt,this,!1)}},{key:"triggerRedraw",value:function(){this.showPaymentGateway(),function(t){var e=t.event,n=t.paymentMethod,r=void 0===n?"":n;if(!pt(e))throw new Error("Invalid event: ".concat(e));var o=r?"".concat(e,"-").concat(r):e;document.body.dispatchEvent(new Event(o))}({event:ft.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=St(e))&&jQuery(t).hasClass("ppcp-disabled")))}},{key:"initEventListeners",value:function(){var t=this;if(ht({event:ft.REDRAW,paymentMethod:this.methodId,callback:function(){return t.refresh()}}),this.isInsideClassicGateway){var e=this.isSeparateGateway?this.methodId:wt;ht({event:ft.INVALIDATE,callback:function(){return t.isVisible=!1}}),ht({event:ft.RENDER,paymentMethod:e,callback:function(){return t.isVisible=!0}})}this.context===Pt.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(!Tt(Wt,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"),Bt(Wt,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=Ot(Tt(Lt,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()}Bt(Lt,this,[]);var s=["ppcp-button-".concat(i),"ppcp-button-apm",this.cssClass];(t=n.classList).add.apply(t,s),(e=Tt(Lt,this)).push.apply(e,s),a&&(n.style.height="".concat(a,"px")),n.style.display=this.isVisible?"block":"none";var l=this.context===Pt.Product?"form.cart":null;!function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=St(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;Tt($t,this)&&this.removeButton(),this.log("insertButton",t),Bt($t,this,t),e.appendChild(Tt($t,this))}}},{key:"removeButton",value:function(){if(this.isPresent&&Tt($t,this)){this.log("removeButton");try{this.wrapperElement.removeChild(Tt($t,this))}catch(t){}Bt($t,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&&_t(t.prototype,e),n&&_t(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n}();function Xt(t,e){Tt(Jt,this).push({check:t,errorMessage:e,shouldPass:!1})}function te(t){Tt(Jt,this).push({check:t,shouldPass:!0})}function ee(t){return ee="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},ee(t)}function ne(t,e){for(var n=0;nt.length)&&(e=t.length);for(var n=0,r=Array(e);n1&&void 0!==arguments[1]&&arguments[1];(e=t)&&"object"===ie(e)&&(window._PpcpPayerSessionDetails=function(t){var e,n,r,o,i,a,u,c;return{email_address:t.email_address,phone:t.phone,name:{surname:null===(e=t.name)||void 0===e?void 0:e.surname,given_name:null===(n=t.name)||void 0===n?void 0:n.given_name},address:{country_code:null===(r=t.address)||void 0===r?void 0:r.country_code,address_line_1:null===(o=t.address)||void 0===o?void 0:o.address_line_1,address_line_2:null===(i=t.address)||void 0===i?void 0:i.address_line_2,admin_area_1:null===(a=t.address)||void 0===a?void 0:a.admin_area_1,admin_area_2:null===(u=t.address)||void 0===u?void 0:u.admin_area_2,postal_code:null===(c=t.address)||void 0===c?void 0:c.postal_code}}}(e)),n&&ce(t)}function le(t){return le="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},le(t)}function fe(t,e){for(var n=0;n0&&n.expires2&&void 0!==arguments[2]?arguments[2]:0;if(!this.canUseLocalStorage)throw new Error("Local storage is not available");var r=function(t,e){var n={data:t,expires:we(e)};return JSON.stringify(n)}(e,n),o=be(ke,this,je).call(this,t);localStorage.setItem(o,r)}},{key:"get",value:function(t){if(!this.canUseLocalStorage)throw new Error("Local storage is not available");var e=be(ke,this,je).call(this,t),n=ge(localStorage.getItem(e));return n?n.data:null}},{key:"clear",value:function(t){if(!this.canUseLocalStorage)throw new Error("Local storage is not available");var e=be(ke,this,je).call(this,t);localStorage.removeItem(e)}}],e&&fe(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}());Te(Me,"PAYER","payer"),Te(Me,"PAYER_TTL",900);const De=new Me;function Re(t){return Re="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},Re(t)}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 xe(s,"_invoke",function(n,r,o){var i,u,c,s=0,l=o||[],f=!1,p={p:0,n:0,v:t,a:h,f:h.bind(t,4),d:function(e,n){return i=e,u=0,c=t,p.n=n,a}};function h(n,r){for(u=n,c=r,e=0;!f&&s&&!o&&e3?(o=y===r)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=h&&((o=n<2&&hr||r>y)&&(i[4]=n,i[5]=r,p.n=y,u=0))}if(o||n>1)return a;throw f=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&h(l,y),u=l,c=y;(e=u<2?t:c)||!f;){i||(u?u<3?(u>1&&(p.n=-1),h(u,c)):p.n=c:p.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=(f=p.n<0)?c:n.call(r,p))!==a)break}catch(e){i=t,u=1,c=e}finally{s=1}}return{value:e,done:f}}}(n,o,i),!0),s}var a={};function u(){}function c(){}function s(){}e=Object.getPrototypeOf;var l=[][r]?e(e([][r]())):(xe(e={},r,function(){return this}),e),f=s.prototype=u.prototype=Object.create(l);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,xe(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return c.prototype=s,xe(f,"constructor",s),xe(s,"constructor",c),c.displayName="GeneratorFunction",xe(s,o,"GeneratorFunction"),xe(f),xe(f,o,"Generator"),xe(f,r,function(){return this}),xe(f,"toString",function(){return"[object Generator]"}),(We=function(){return{w:i,m:p}})()}function xe(t,e,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}xe=function(t,e,n,r){function i(e,n){xe(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))},xe(t,e,n,r)}function Ne(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 Ge(t){return function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function a(t){Ne(i,r,o,a,u,"next",t)}function u(t){Ne(i,r,o,a,u,"throw",t)}a(void 0)})}}function Le(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 qe(t){for(var e=1;e6&&void 0!==arguments[6]?arguments[6]:null;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Ye(u=function(t,e,n){return e=Ve(e),function(t,e){if(e&&("object"==Re(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||[],Ve(t).constructor):e.apply(t,n))}(this,e,[t,n,r,o,i,a,c]),an,null),Ye(u,un,null),Ye(u,cn,null),$e(u,"googlePayConfig",null),Ye(u,sn,0),Ye(u,ln,1e3),Ye(u,fn,null),u.init=u.init.bind(u),u.onPaymentDataChanged=u.onPaymentDataChanged.bind(u),u.onButtonClick=u.onButtonClick.bind(u),u.onClick=c,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&&Ue(t,e)}(e,t),n=e,r=[{key:"requiresShipping",get:function(){var t;return He(e,"requiresShipping",this,1)&&(null===(t=this.buttonConfig.shipping)||void 0===t?void 0:t.enabled)}},{key:"googlePayApi",get:function(){var t;return null===(t=window.google)||void 0===t||null===(t=t.payments)||void 0===t?void 0:t.api}},{key:"paymentsClient",get:function(){return Ze(an,this)}},{key:"transactionInfo",get:function(){return Ze(un,this)},set:function(t){Ke(un,this,t),this.refresh()}},{key:"registerValidationRules",value:function(t,e){var n=this;return t(function(){return!["TEST","PRODUCTION"].includes(n.buttonConfig.environment)},"Invalid environment: ".concat(this.buttonConfig.environment)),e(function(){return n.isPreview}),t(function(){return!n.googlePayConfig},"No API configuration - missing configure() call?"),t(function(){return!n.transactionInfo},"No transactionInfo - missing configure() call?"),t(function(){var t;return!(null!==(t=n.contextHandler)&&void 0!==t&&t.validateContext())},"Invalid context handler."),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"),!0}},{key:"configure",value:function(t,e){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};Ze(sn,this)||Ke(sn,this,Date.now()),null!=r&&r.height&&null!=r&&r.borderRadius&&Ke(fn,this,qe({},r));var o=null!=r&&r.height?r:Ze(fn,this);if(Date.now()-Ze(sn,this)>Ze(ln,this))return this.log("GooglePay: Timeout waiting for buttonAttributes - proceeding with initialization"),this.googlePayConfig=t,Ke(un,this,e),this.buttonAttributes=o||r,this.allowedPaymentMethods=this.googlePayConfig.allowedPaymentMethods,this.baseCardPaymentMethod=this.allowedPaymentMethods[0],void this.init();null!=o&&o.height&&null!=o&&o.borderRadius?(Ke(sn,this,0),this.googlePayConfig=t,Ke(un,this,e),this.buttonAttributes=o,this.allowedPaymentMethods=this.googlePayConfig.allowedPaymentMethods,this.baseCardPaymentMethod=this.allowedPaymentMethods[0],this.init()):setTimeout(function(){return n.configure(t,e,r)},100)}},{key:"init",value:function(){var t=this;this.isInitialized||this.validateConfiguration()&&(He(e,"init",this,3)([]),Ke(an,this,this.createPaymentsClient()),this.paymentsClient.isReadyToPay(this.buildReadyToPayRequest(this.allowedPaymentMethods,this.googlePayConfig)).then(function(e){t.log("PaymentsClient.isReadyToPay response:",e),t.isEligible=!!e.result}).catch(function(e){t.error(e),t.isEligible=!1}))}},{key:"reinit",value:function(){this.validateConfiguration(!0)&&(He(e,"reinit",this,3)([]),this.init())}},{key:"preparePaymentDataCallbacks",value:function(){var t={};return this.isPreview||this.requiresShipping&&(t.onPaymentDataChanged=this.onPaymentDataChanged),t}},{key:"createPaymentsClient",value:function(){if(!this.googlePayApi)return null;var t=this.preparePaymentDataCallbacks();return new this.googlePayApi.PaymentsClient({environment:this.buttonConfig.environment,paymentDataCallbacks:t})}},{key:"buildReadyToPayRequest",value:function(t,e){return this.log("Ready To Pay request",e,t),Object.assign({},e,{allowedPaymentMethods:t})}},{key:"addButton",value:function(){var t,n,r;if(this.paymentsClient){null!==(t=this.buttonAttributes)&&void 0!==t&&t.height||null===(n=Ze(fn,this))||void 0===n||!n.height||(this.buttonAttributes=qe({},Ze(fn,this))),this.removeButton();var o=this.baseCardPaymentMethod,i=this.style,a=i.color,u=i.type,c={buttonColor:a||"black",buttonSizeMode:"fill",buttonLocale:i.language||"en",buttonType:u||"pay",buttonRadius:parseInt(null===(r=this.buttonAttributes)||void 0===r?void 0:r.borderRadius,10),onClick:this.onButtonClick,allowedPaymentMethods:[o]},s=this.paymentsClient.createButton(c);Ke(cn,this,s),He(e,"insertButton",this,3)([s]),this.applyWrapperStyles()}}},{key:"applyWrapperStyles",value:function(){var t;He(e,"applyWrapperStyles",this,3)([]);var n=this.wrapperElement;if(n){var r=null!==(t=this.buttonAttributes)&&void 0!==t&&t.height?this.buttonAttributes:Ze(fn,this);if(null!=r&&r.height){var o=parseInt(r.height,10);isNaN(o)||(n.style.height="".concat(o,"px"),n.style.minHeight="".concat(o,"px"))}}}},{key:"removeButton",value:function(){if(this.isPresent&&Ze(cn,this)){this.log("removeButton");try{this.wrapperElement.removeChild(Ze(cn,this))}catch(t){}Ke(cn,this,null)}}},{key:"onButtonClick",value:(a=Ge(We().m(function t(){var e,n,r,o,i=this;return We().w(function(t){for(;;)switch(t.n){case 0:return this.logGroup("onButtonClick"),e=function(){var t=Ge(We().m(function t(){var e,n;return We().w(function(t){for(;;)if(0===t.n)return window.ppcpFundingSource="googlepay",null===(e=i.onClick)||void 0===e||e.call(i),n=i.paymentDataRequest(),i.log("onButtonClick: paymentDataRequest",n,i.context),t.a(2,i.paymentsClient.loadPaymentData(n).then(function(t){return i.log("loadPaymentData response:",t),t}).catch(function(t){throw i.error("loadPaymentData failed:",t),t}))},t)}));return function(){return t.apply(this,arguments)}}(),n=function(){var t=Ge(We().m(function t(){return We().w(function(t){for(;;)switch(t.n){case 0:if("function"==typeof i.contextHandler.validateForm){t.n=1;break}return t.a(2,Promise.resolve());case 1:return t.a(2,i.contextHandler.validateForm().catch(function(t){throw i.error("Form validation failed:",t),t}))}},t)}));return function(){return t.apply(this,arguments)}}(),r=function(){var t=Ge(We().m(function t(){return We().w(function(t){for(;;)switch(t.n){case 0:if("function"==typeof i.contextHandler.transactionInfo){t.n=1;break}return t.a(2,Promise.resolve());case 1:return t.a(2,i.contextHandler.transactionInfo().then(function(t){i.transactionInfo=t}).catch(function(t){throw i.error("Failed to get transaction info:",t),t}))}},t)}));return function(){return t.apply(this,arguments)}}(),t.n=1,n().then(r).then(e);case 1:if(o=t.v,this.logGroup(),o){t.n=2;break}return t.a(2);case 2:return t.a(2,this.processPayment(o))}},t,this)})),function(){return a.apply(this,arguments)})},{key:"paymentDataRequest",value:function(){var t=this.requiresShipping,e=[];return t&&e.push("SHIPPING_ADDRESS","SHIPPING_OPTION"),qe(qe({},{apiVersion:2,apiVersionMinor:0}),{},{allowedPaymentMethods:this.googlePayConfig.allowedPaymentMethods,transactionInfo:this.transactionInfo.finalObject,merchantInfo:this.googlePayConfig.merchantInfo,callbackIntents:e,emailRequired:!0,shippingAddressRequired:t,shippingOptionRequired:t,shippingAddressParameters:this.shippingAddressParameters()})}},{key:"shippingAddressParameters",value:function(){return{allowedCountryCodes:this.buttonConfig.shipping.countries,phoneNumberRequired:!0}}},{key:"onPaymentDataChanged",value:function(t){var e=this;return this.log("onPaymentDataChanged",t),new Promise(function(){var n=Ge(We().m(function n(r,o){var i,a,u,c,s,l,f,p;return We().w(function(n){for(;;)switch(n.p=n.n){case 0:return n.p=0,a={},n.n=1,new oe(e.buttonConfig.ajax.update_payment_data).update(t);case 1:if(u=n.v,c=e.transactionInfo,s=["checkout-block","checkout","cart-block","cart","mini-cart","pay-now"].includes(e.context),e.log("onPaymentDataChanged:updatedData",u),e.log("onPaymentDataChanged:transactionInfo",c),u.country_code=c.countryCode,u.currency_code=c.currencyCode,null!==(i=u.shipping_options)&&void 0!==i&&null!==(i=i.shippingOptions)&&void 0!==i&&i.length){n.n=2;break}return a.error=e.unserviceableShippingAddressError(),r(a),n.a(2);case 2:["INITIALIZE","SHIPPING_ADDRESS"].includes(t.callbackTrigger)&&(a.newShippingOptionParameters=e.sanitizeShippingOptions(u.shipping_options)),u.total&&s?(c.setTotal(u.total,u.shipping_fee),e.syncShippingOptionWithForm(null==t||null===(l=t.shippingOptionData)||void 0===l?void 0:l.id)):c.shippingFee=e.getShippingCosts(null==t||null===(f=t.shippingOptionData)||void 0===f?void 0:f.id,u.shipping_options),a.newTransactionInfo=e.calculateNewTransactionInfo(c),r(a),n.n=4;break;case 3:n.p=3,p=n.v,e.error("Error during onPaymentDataChanged:",p),o(p);case 4:return n.a(2)}},n,null,[[0,3]])}));return function(_x,t){return n.apply(this,arguments)}}())}},{key:"sanitizeShippingOptions",value:function(t){var e=t.shippingOptions.map(function(t){return{id:t.id,label:t.label,description:t.description}}),n=t.defaultSelectedOptionId;return e.some(function(t){return t.id===n})||(n=e[0].id),{defaultSelectedOptionId:n,shippingOptions:e}}},{key:"getShippingCosts",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.shippingOptions,r=void 0===n?[]:n,o=e.defaultSelectedOptionId,i=void 0===o?"":o;if(null==r||!r.length)return this.log("Cannot calculate shipping cost: No Shipping Options"),0;var a=function(t){return r.find(function(e){return e.id===t})},u=a("shipping_option_unselected"!==t&&a(t)?t:i);return Number(null==u?void 0:u.cost)||0}},{key:"unserviceableShippingAddressError",value:function(){return{reason:"SHIPPING_ADDRESS_UNSERVICEABLE",message:"Cannot ship to the selected address",intent:"SHIPPING_ADDRESS"}}},{key:"calculateNewTransactionInfo",value:function(t){return t.finalObject}},{key:"processPayment",value:(i=Ge(We().m(function t(e){var n,r,o,i,a,u,c,s,l,f,h,y,d,v=this;return We().w(function(t){for(;;)switch(t.p=t.n){case 0:return this.logGroup("processPayment"),r=rn(e),o=on(e),i=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r={transactionState:t};return(e||n)&&(r.error={intent:e,message:n}),v.log("processPaymentResponse",r),r},a=function(t){return v.error(t),i("ERROR","PAYMENT_AUTHORIZATION",t)},u=function(){var t=Ge(We().m(function t(n){var r,o,i;return We().w(function(t){for(;;)switch(t.n){case 0:return r={orderId:n,paymentMethodData:e.paymentMethodData},t.n=1,p.paypal.Googlepay().confirmOrder(r);case 1:o=t.v,v.log("confirmOrder",o),i=null==o?void 0:o.status,t.n="APPROVED"===i?2:"PAYER_ACTION_REQUIRED"===i?3:4;break;case 2:return t.a(2,"approved");case 3:return t.a(2,en);case 4:return t.a(2,tn);case 5:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}(),c=function(t){return v.log("initiatePayerAction",t),p.paypal.Googlepay().initiatePayerAction({orderId:t})},s=function(){var t=Ge(We().m(function t(e){var n;return We().w(function(t){for(;;)switch(t.n){case 0:return n=!0,v.log("approveOrder",e),t.n=1,v.contextHandler.approveOrder({orderID:e,payer:r,shippingAddress:o},{restart:function(){return new Promise(function(t){n=!1,t()})},order:{get:function(){return new Promise(function(t){t(null)})}}});case 1:return t.a(2,n)}},t)}));return function(e){return t.apply(this,arguments)}}(),De.setPayer(r),se(r),t.p=1,t.n=2,this.contextHandler.createOrder();case 2:return l=t.v,this.log("createOrder",l),t.n=3,u(l);case 3:if(f=t.v,tn!==f){t.n=4;break}n=a("TRANSACTION FAILED"),t.n=8;break;case 4:if(en!==f){t.n=6;break}return t.n=5,c(l);case 5:h=t.v,this.log("3DS verification completed",h);case 6:return t.n=7,s(l);case 7:y=t.v,n=y?i("SUCCESS"):a("FAILED TO APPROVE");case 8:t.n=10;break;case 9:t.p=9,d=t.v,n=a(d.message);case 10:return this.logGroup(),t.a(2,n)}},t,this,[[1,9]])})),function(t){return i.apply(this,arguments)})},{key:"syncShippingOptionWithForm",value:function(t){for(var e=[".woocommerce-shipping-methods",".wc-block-components-shipping-rates-control",".wc-block-components-totals-shipping"],n=t.replace(/"/g,""),r=0,o=e;r1&&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-googlepay-container","ppc-button-ppcp-googlepay")}},{key:"getStyles",value:function(t,e){var n=function(t,e){return{Default:st(st({},t.style),e.style),MiniCart:st(st({},t.mini_cart_style),e.mini_cart_style)}}((null==e?void 0:e.button)||{},(null==t?void 0:t.button)||{});return"buy"===n.MiniCart.type&&(n.MiniCart.type="pay"),n}}],r&&Qe(n.prototype,r),o&&Qe(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o,i,a}(Zt);$e(pn,"methodId","ppcp-googlepay"),$e(pn,"cssClass","google-pay");const hn=pn;function yn(t){return yn="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},yn(t)}function dn(t,e){for(var n=0;n3?(o=y===r)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=h&&((o=n<2&&hr||r>y)&&(i[4]=n,i[5]=r,p.n=y,u=0))}if(o||n>1)return a;throw f=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&h(l,y),u=l,c=y;(e=u<2?t:c)||!f;){i||(u?u<3?(u>1&&(p.n=-1),h(u,c)):p.n=c:p.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=(f=p.n<0)?c:n.call(r,p))!==a)break}catch(e){i=t,u=1,c=e}finally{s=1}}return{value:e,done:f}}}(n,o,i),!0),s}var a={};function u(){}function c(){}function s(){}e=Object.getPrototypeOf;var l=[][r]?e(e([][r]())):(En(e={},r,function(){return this}),e),f=s.prototype=u.prototype=Object.create(l);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,En(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return c.prototype=s,En(f,"constructor",s),En(s,"constructor",c),c.displayName="GeneratorFunction",En(s,o,"GeneratorFunction"),En(f),En(f,o,"Generator"),En(f,r,function(){return this}),En(f,"toString",function(){return"[object Generator]"}),(jn=function(){return{w:i,m:p}})()}function En(t,e,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}En=function(t,e,n,r){function i(e,n){En(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))},En(t,e,n,r)}function Cn(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 An(t,e){for(var n=0;n