(()=>{"use strict";var e={907(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(e){function t(){var e,n,r,i;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var o=arguments.length,a=new Array(o),u=0;u<o;u++)a[u]=arguments[u];return n=this,r=t,i=[].concat(a),r=m(r),e=function(e,t){if(t&&("object"==s(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(n,d()?Reflect.construct(r,i||[],m(n).constructor):r.apply(n,i)),_(e,"isEligible",!1),e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&y(e,t)}(t,e),n=t,r=[{key:"createExpressElement",value:function(){this.elements&&(this.expressCheckoutElement=this.elements.create("expressCheckout",this.getExpressElementOptions()),this.expressCheckoutElement.on("ready",this.onReady.bind(this)),this.expressCheckoutElement.on("loaderror",this.onLoadError.bind(this)),this.expressCheckoutElement.on("click",this.onClickElement.bind(this)),this.expressCheckoutElement.on("confirm",this.onConfirm.bind(this)),this.expressCheckoutElement.on("cancel",this.onCancel.bind(this)),this.expressCheckoutElement.on("shippingaddresschange",this.onShippingAddressChange.bind(this)),this.expressCheckoutElement.on("shippingratechange",this.onShippingRateChange.bind(this)))}},{key:"onClickElement",value:function(e){var t;this.store_attribution_values();var n={};this.params.items.reduce(function(e,t){return e+t.amount},0)===parseFloat(this.params.total_cents)&&(n.lineItems=this.params.items),null!==(t=this.expressElementOptions)&&void 0!==t&&t.shippingAddressRequired&&this.params.shipping_options.length&&(n.shippingRates=this.params.shipping_options),e.resolve(n),this.modalOpen=!0}},{key:"onReady",value:function(){}},{key:"onConfirm",value:(c=h(a().m(function e(t){var n,r,i,s,u,p,c,h,f,d,m,y,_,b,v,g,O,w;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:return n=t.billingDetails,(r=t.shippingAddress)&&(i=r.name,s=void 0===i?"":i,u=r.address,p=void 0===u?null:u,c=l(l({},!!s&&{name:s}),!!p&&{shipping_address_1:p.line1||"",shipping_address_2:p.line2||"",shipping_city:p.city||"",shipping_state:p.state||"",shipping_postcode:p.postal_code||"",shipping_country:p.country||""}),null!=n&&n.phone&&(c.shipping_phone=n.phone),this.populate_shipping_fields(c)),n&&(h=n.name,f=void 0===h?"":h,d=n.email,m=void 0===d?"":d,y=n.phone,_=void 0===y?"":y,b=n.address,v=void 0===b?null:b,g=l(l(l(l({},!!f&&{name:f}),!!v&&{billing_address_1:v.line1||"",billing_address_2:v.line2||"",billing_city:v.city||"",billing_state:v.state||"",billing_postcode:v.postal_code||"",billing_country:v.country||""}),(0,o.isEmail)(m)&&{billing_email:m}),!!_&&{billing_phone:_}),this.populate_billing_fields(g)),e.p=1,e.n=2,this.elements.submit();case 2:return e.n=3,this.stripe.createPaymentMethod({elements:this.elements});case 3:if(!(O=e.v).error){e.n=4;break}return e.a(2,this.submit_error(O.error));case 4:this.on_token_received(O.paymentMethod),e.n=6;break;case 5:return e.p=5,w=e.v,e.a(2,this.submit_error(w));case 6:return e.a(2)}},e,this,[[1,5]])})),function(e){return c.apply(this,arguments)})},{key:"onShippingAddressChange",value:(p=h(a().m(function e(t){var n,r,i,o,s,u,p,c;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:return n=t.reject,r=t.resolve,i=t.address,e.p=1,e.n=2,this.update_shipping_address({shippingAddress:i});case 2:o=e.v,s=o.newData,u=s.total,p=s.displayItems,c=s.shippingOptions,this.params.total_cents=u.amount,this.params.items=p,this.params.shipping_options=c,this.elements.update({amount:u.amount}),r(l({shippingRates:c},p.reduce(function(e,t){return e+t.amount},0)===u.amount&&{lineItems:p})),e.n=4;break;case 3:e.p=3,e.v,n();case 4:return e.a(2)}},e,this,[[1,3]])})),function(e){return p.apply(this,arguments)})},{key:"onShippingRateChange",value:(u=h(a().m(function e(t){var n,r,i,o,s,u,p,c;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:return n=t.reject,r=t.resolve,i=t.shippingRate,e.p=1,e.n=2,this.update_shipping_method({shippingOption:i});case 2:o=e.v,s=o.newData,u=s.total,p=s.displayItems,c=s.shippingOptions,this.params.total_cents=u.amount,this.params.items=p,c.length&&(this.params.shipping_options=c),this.elements.update({amount:u.amount}),r(l({shippingRates:this.params.shipping_options},p.reduce(function(e,t){return e+t.amount},0)===u.amount&&{lineItems:p})),e.n=4;break;case 3:e.p=3,e.v,n();case 4:return e.a(2)}},e,this,[[1,3]])})),function(e){return u.apply(this,arguments)})},{key:"onCancel",value:function(){this.modalOpen=!1}},{key:"isModalOpen",value:function(){return!!this.modalOpen}},{key:"mountPaymentElement",value:function(){try{this.expressCheckoutElement&&(0===(0,i.default)(this.elementSelector).find("iframe").length?(this.expressCheckoutElement.unmount(),(0,i.default)(this.elementSelector).length||this.createElementSelectorHTML(),(0,i.default)(this.elementSelector).length&&this.expressCheckoutElement.mount(this.elementSelector)):this.onReady({availablePaymentMethods:{applePay:this.isEligible}}))}catch(e){console.log("Error mounting expressCheckoutElement. ",e)}}},{key:"createElementSelectorHTML",value:function(){}},{key:"updatePaymentElement",value:function(){try{this.elements&&this.elements.update(this.get_element_options())}catch(e){console.log("Error updating expressCheckoutElement. ",e)}}},{key:"onLoadError",value:function(e){(0,i.default)(this.elementSelector).hide(),console.log("Error loading expressCheckout Element: ",e)}},{key:"get_element_options",value:function(){var e=l({currency:this.params.currency.toLowerCase(),appearance:{variables:{borderRadius:this.params.button_options.radius}}},this.params.elementOptions);return delete e.paymentMethodTypes,(this.isPaymentMode()||this.isSubscriptionMode())&&(e.amount=parseFloat(this.params.total_cents)>0?parseFloat(this.params.total_cents):100),e}},{key:"get_gateway_data",value:function(){return this.params}},{key:"isPaymentMode",value:function(){return"payment"===this.params.elementOptions.mode}},{key:"isSubscriptionMode",value:function(){return"subscription"===this.params.elementOptions.mode}},{key:"isSetupMode",value:function(){return"setup"===this.params.elementOptions.mode}},{key:"needs_shipping",value:function(){return"1"===this.params.needs_shipping||!0===this.params.needs_shipping}},{key:"get_currency",value:function(){return this.params.currency}},{key:"map_address",value:function(e){return{city:e.city,postcode:e.postal_code,state:e.state,country:e.country}}},{key:"get_form",value:function(){return(0,i.default)(this.elementSelector).closest("form")}},{key:"set_nonce",value:function(e){(0,i.default)('[name="stripe_applepay_token_key"]').length||(0,i.default)(this.elementSelector).append('<input type="hidden" name="stripe_applepay_token_key"/>'),(0,i.default)('[name="stripe_applepay_token_key"]').val(e),this.fields.set(this.gateway_id+"_token_key",e)}},{key:"onHashChange",value:function(e){var t=window.location.hash.match(/response=(.*)/);if(t)try{var n=JSON.parse(window.atob(decodeURIComponent(t[1])));n&&n.hasOwnProperty("client_secret")&&n.gateway_id===this.gateway_id&&this.modalOpen&&(history.pushState({},"",window.location.pathname),"payment_intent"===n.type?this.processPaymentIntent(n):this.processSetupIntent(n))}catch(e){}return!0}},{key:"processPaymentIntent",value:function(e){var t=this;this.stripe.confirmPayment({clientSecret:e.client_secret,redirect:"if_required",confirmParams:l({return_url:e.return_url,payment_method_data:{billing_details:e.billing_details||this.get_billing_details()}},e.confirmation_args&&e.confirmation_args)}).then(function(n){if(n.error)return t.payment_token_received=!1,t.submit_error(n.error);var r=decodeURI(e.return_url);if(r+="&"+i.default.param({_stripe_local_payment:t.gateway_id,payment_intent:n.paymentIntent.id,payment_intent_client_secret:n.paymentIntent.client_secret}),["promptpay","swish","paynow","cashapp"].includes(t.paymentMethodType)){if("requires_action"===n.paymentIntent.status)return t.get_form().unblock().removeClass("processing");if("requires_payment_method"===n.paymentIntent.status)return t.get_form().unblock().removeClass("processing"),t.submit_error({code:n.paymentIntent.last_payment_error.code})}window.location.href=r}).catch(function(e){return t.submit_error(e)})}},{key:"processSetupIntent",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this.stripe.confirmSetup(l({elements:this.elements,clientSecret:t.client_secret,redirect:"if_required"},t&&{confirmParams:l(l({},t.return_url&&{return_url:t.return_url}),{},{payment_method_data:{billing_details:this.get_billing_details()}},t.confirmParams&&t.confirmParams)})).then(function(t){if(t.error)return e.payment_token_received=!1,e.submit_error(t.error);e.setupIntent=t.setupIntent,e.payment_token_received=!0,e.set_nonce(t.setupIntent.payment_method),e.set_intent(t.setupIntent.id),e.get_form().removeClass("processing"),e.get_form().trigger("submit")}).catch(function(t){return e.submit_error(t)})}},{key:"getExpressElementOptions",value:function(){return this.expressElementOptions={buttonHeight:Math.max(40,Math.min(55,parseInt(this.params.button_options.height))),buttonType:{applePay:this.params.button_options.type},buttonTheme:{applePay:this.params.button_options.theme},paymentMethods:{applePay:"applePay"===this.type?this.params.display_rule:"never",googlePay:"googlePay"===this.type?"always":"never",amazonPay:"amazonPay"===this.type?"auto":"never",paypal:"never",klarna:"klarna"===this.type?"auto":"never",link:"link"===this.type?"auto":"never"},emailRequired:!0,phoneNumberRequired:!0,billingAddressRequired:!0,shippingAddressRequired:this.needs_shipping()},this.expressElementOptions}},{key:"triggerUpdatedCheckout",value:function(){return new Promise(function(e){(0,i.default)(document.body).one("updated_checkout",e),(0,i.default)(document.body).trigger("update_checkout",{update_shipping_method:!1})})}},{key:"populateDomFields",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in e){var n="#"+t;(0,i.default)(n).length&&(0,i.default)(n).val(e[t])}}}],r&&f(n.prototype,r),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,u,p,c}(e)};var r,i=(r=n(428))&&r.__esModule?r:{default:r},o=n(832);function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function a(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var a=r&&r.prototype instanceof p?r:p,l=Object.create(a.prototype);return u(l,"_invoke",function(n,r,i){var o,a,u,p=0,l=i||[],c=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,a=0,u=e,h.n=n,s}};function f(n,r){for(a=n,u=r,t=0;!c&&p&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,d=o[2];n>3?(i=d===r)&&(u=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(a=0,h.v=r,h.n=o[1]):f<d&&(i=n<3||o[0]>r||r>d)&&(o[4]=n,o[5]=r,h.n=d,a=0))}if(i||n>1)return s;throw c=!0,r}return function(i,l,d){if(p>1)throw TypeError("Generator is already running");for(c&&1===l&&f(l,d),a=l,u=d;(t=a<2?e:u)||!c;){o||(a?a<3?(a>1&&(h.n=-1),f(a,u)):h.n=u:h.v=u);try{if(p=2,o){if(a||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,a<2&&(a=0)}else 1===a&&(t=o.return)&&t.call(o),a<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),a=1);o=e}else if((t=(c=h.n<0)?u:n.call(r,h))!==s)break}catch(t){o=e,a=1,u=t}finally{p=1}}return{value:t,done:c}}}(n,i,o),!0),l}var s={};function p(){}function l(){}function c(){}t=Object.getPrototypeOf;var h=[][r]?t(t([][r]())):(u(t={},r,function(){return this}),t),f=c.prototype=p.prototype=Object.create(h);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,u(e,i,"GeneratorFunction")),e.prototype=Object.create(f),e}return l.prototype=c,u(f,"constructor",c),u(c,"constructor",l),l.displayName="GeneratorFunction",u(c,i,"GeneratorFunction"),u(f),u(f,i,"Generator"),u(f,r,function(){return this}),u(f,"toString",function(){return"[object Generator]"}),(a=function(){return{w:o,m:d}})()}function u(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}u=function(e,t,n,r){function o(t,n){u(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},u(e,t,n,r)}function p(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?p(Object(n),!0).forEach(function(t){_(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function c(e,t,n,r,i,o,s){try{var a=e[o](s),u=a.value}catch(e){return void n(e)}a.done?t(u):Promise.resolve(u).then(r,i)}function h(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var o=e.apply(t,n);function s(e){c(o,r,i,s,a,"next",e)}function a(e){c(o,r,i,s,a,"throw",e)}s(void 0)})}}function f(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,b(r.key),r)}}function d(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(d=function(){return!!e})()}function m(e){return m=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},m(e)}function y(e,t){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},y(e,t)}function _(e,t,n){return(t=b(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function b(e){var t=function(e){if("object"!=s(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=s(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==s(t)?t:t+""}},428(e){e.exports=window.jQuery},705(e){e.exports=window.wc_stripe},832(e){e.exports=window.wp.url}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}var r=n(705),i=a(n(428)),o=n(832),s=a(n(907));function a(e){return e&&e.__esModule?e:{default:e}}function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}function p(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof a?r:a,p=Object.create(u.prototype);return l(p,"_invoke",function(n,r,i){var o,a,u,p=0,l=i||[],c=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,a=0,u=e,h.n=n,s}};function f(n,r){for(a=n,u=r,t=0;!c&&p&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,d=o[2];n>3?(i=d===r)&&(u=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(a=0,h.v=r,h.n=o[1]):f<d&&(i=n<3||o[0]>r||r>d)&&(o[4]=n,o[5]=r,h.n=d,a=0))}if(i||n>1)return s;throw c=!0,r}return function(i,l,d){if(p>1)throw TypeError("Generator is already running");for(c&&1===l&&f(l,d),a=l,u=d;(t=a<2?e:u)||!c;){o||(a?a<3?(a>1&&(h.n=-1),f(a,u)):h.n=u:h.v=u);try{if(p=2,o){if(a||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,a<2&&(a=0)}else 1===a&&(t=o.return)&&t.call(o),a<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),a=1);o=e}else if((t=(c=h.n<0)?u:n.call(r,h))!==s)break}catch(t){o=e,a=1,u=t}finally{p=1}}return{value:t,done:c}}}(n,i,o),!0),p}var s={};function a(){}function u(){}function c(){}t=Object.getPrototypeOf;var h=[][r]?t(t([][r]())):(l(t={},r,function(){return this}),t),f=c.prototype=a.prototype=Object.create(h);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,l(e,i,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=c,l(f,"constructor",c),l(c,"constructor",u),u.displayName="GeneratorFunction",l(c,i,"GeneratorFunction"),l(f),l(f,i,"Generator"),l(f,r,function(){return this}),l(f,"toString",function(){return"[object Generator]"}),(p=function(){return{w:o,m:d}})()}function l(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}l=function(e,t,n,r){function o(t,n){l(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},l(e,t,n,r)}function c(e,t,n,r,i,o,s){try{var a=e[o](s),u=a.value}catch(e){return void n(e)}a.done?t(u):Promise.resolve(u).then(r,i)}function h(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var o=e.apply(t,n);function s(e){c(o,r,i,s,a,"next",e)}function a(e){c(o,r,i,s,a,"throw",e)}s(void 0)})}}function f(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?f(Object(n),!0).forEach(function(t){O(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):f(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function m(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,w(r.key),r)}}function y(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(y=function(){return!!e})()}function _(e,t,n,r){var i=b(v(1&r?e.prototype:e),t,n);return 2&r&&"function"==typeof i?function(e){return i.apply(n,e)}:i}function b(){return b="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=v(e)););return e}(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},b.apply(null,arguments)}function v(e){return v=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},v(e)}function g(e,t){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},g(e,t)}function O(e,t,n){return(t=w(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w(e){var t=function(e){if("object"!=u(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=u(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==u(t)?t:t+""}function k(e,t){this.container=t,this.elementSelector=".wc-stripe-applepay-button",this.expressElementOptions=null,this._oldExpressElementOptions=null,this.setupIntent=null,this.paymentMethodType=null,this.paymentElementComplete=!1,r.BaseGateway.call(this,e),r.CheckoutGateway.call(this)}k.prototype=Object.assign(k.prototype,r.BaseGateway.prototype,r.CheckoutGateway.prototype),new(function(e){function t(e,n){var r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),O(r=function(e,t,n){return t=v(t),function(e,t){if(t&&("object"==u(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,y()?Reflect.construct(t,n||[],v(e).constructor):t.apply(e,n))}(this,t,[e,n]),"isEligible",void 0),r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&g(e,t)}(t,e),n=t,r=[{key:"initialize",value:function(){this.type="applePay",this.setupEvents(),this.createExpressElement(),this.mountPaymentElement()}},{key:"setupEvents",value:function(){var e=this;(0,i.default)(document.body).on("updated_checkout",this.onUpdatedCheckout.bind(this)),(0,i.default)(document.body).on("change",'[name^="billing_"], [name^="shipping_"]',this.onAddressFieldChange.bind(this)),(0,i.default)(document.body).on("wc_stripe_applepay_payment_method_received",function(t,n){wc_stripe.CheckoutGateway.prototype.on_token_received.call(e,n)}),window.addEventListener("hashchange",this.onHashChange.bind(this))}},{key:"createElementSelectorHTML",value:function(){this.$button=(0,i.default)('<div class="wc-stripe-applepay-button" style="clear:both;min-height:40px;"></div>'),(0,i.default)("#place_order").after(this.$button)}},{key:"onClickElement",value:function(e){if(!this.is_valid_checkout())return this.submit_error(this.params.messages.terms),e.reject();_(t,"onClickElement",this,3)([e])}},{key:"onReady",value:function(e){var t=(e.availablePaymentMethods||{}).applePay,n=void 0!==t&&t;this.isEligible=n,this.isEligible?((0,i.default)(this.container).show().addClass("active"),this.trigger_payment_method_selected()):(0,i.default)(this.container).hide()}},{key:"onUpdatedCheckout",value:function(e,t){var n;t&&null!=t&&null!==(n=t.fragments)&&void 0!==n&&n[this.gateway_id]&&(this.params=d(d({},this.params),t.fragments[this.gateway_id]),this.updatePaymentElement()),this.expressCheckoutElement&&(this.isModalOpen()||JSON.stringify(this._oldExpressElementOptions)!==JSON.stringify(this.getExpressElementOptions())&&(this.expressCheckoutElement.unmount(),this.elements=this.create_stripe_elements(),this.createExpressElement()),this.mountPaymentElement())}},{key:"onAddressFieldChange",value:function(e){this._oldExpressElementOptions&&JSON.stringify(this._oldExpressElementOptions)!==JSON.stringify(this.getExpressElementOptions())&&(this.expressCheckoutElement.unmount(),this.elements=this.create_stripe_elements(),this.createExpressElement(),this.mountPaymentElement())}},{key:"on_token_received",value:(a=h(p().m(function e(t){var n=arguments;return p().w(function(e){for(;;)switch(e.n){case 0:if(wc_stripe.CheckoutGateway.prototype.on_token_received.apply(this,n),this.expressElementOptions.shippingAddressRequired&&this.maybe_set_ship_to_different(),this.fields.toFormFields({update_shipping_method:!1}),!this._updateRequired){e.n=2;break}return e.n=1,this.triggerUpdatedCheckout();case 1:this.checkout_fields_valid()&&this.get_form().trigger("submit"),e.n=3;break;case 2:this.checkout_fields_valid()&&this.get_form().trigger("submit");case 3:return e.a(2)}},e,this)})),function(e){return a.apply(this,arguments)})},{key:"getExpressElementOptions",value:function(){var e;if(this.expressElementOptions&&(this._oldExpressElementOptions=d({},this.expressElementOptions)),this.expressElementOptions=_(t,"getExpressElementOptions",this,3)([]),this.expressElementOptions.emailRequired=!(0,o.isEmail)(null!==(e=(0,i.default)("#billing_email").val())&&void 0!==e?e:""),this.expressElementOptions.phoneNumberRequired=(0,i.default)("#billing_phone").length>0&&""===(0,i.default)("#billing_phone").val(),this.expressElementOptions.shippingAddressRequired){var n=this.get_shipping_prefix();this.is_valid_address(this.get_address_object(n),n,["email","phone"])&&(this.expressElementOptions.shippingAddressRequired=!1)}var r=this.get_address_object("billing");return this.is_valid_address(r,"billing",["email"])&&(this.expressElementOptions.billingAddressRequired=!1),this._oldExpressElementOptions||(this._oldExpressElementOptions=d({},this.expressElementOptions)),this.expressElementOptions}},{key:"update_shipping_address",value:(s=h(p().m(function e(){var t=arguments;return p().w(function(e){for(;;)switch(e.n){case 0:return this._updateRequired=!0,e.n=1,wc_stripe.BaseGateway.prototype.update_shipping_address.apply(this,t);case 1:return e.a(2,e.v)}},e,this)})),function(){return s.apply(this,arguments)})},{key:"set_selected_shipping_methods",value:function(e){this.fields.set("shipping_method",e);for(var t=0,n=Object.keys(e);t<n.length;t++){var r=n[t],o=e[r],s=(0,i.default)('[name="shipping_method['.concat(r,']"][value="').concat(o,'"]'));s.length?s.prop("checked",!0):this._updateRequired=!0}}},{key:"populate_shipping_fields",value:function(e){var n=this;_(t,"populate_shipping_fields",this,3)([e]),(0,i.default)(document.body).one("updated_checkout",function(){n.populateDomFields(e)})}},{key:"populate_billing_fields",value:function(e){var n=this;_(t,"populate_billing_fields",this,3)([e]),(0,i.default)(document.body).one("updated_checkout",function(){n.populateDomFields(e)})}}],r&&m(n.prototype,r),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,s,a}((0,s.default)(k)))(wc_stripe_applepay_checkout_params,"li.payment_method_stripe_applepay"),(this.wcStripeModules=this.wcStripeModules||{}).applepayCheckout={}})();