!function(e,a){function t(){a.BaseGateway.call(this,wc_stripe_applepay_product_params),this.old_qty=this.get_quantity()}(t.prototype=e.extend({},a.BaseGateway.prototype,a.ProductGateway.prototype,a.ApplePay.prototype)).initialize=function(){e(".wc_stripe_product_payment_methods "+this.container).length?(this.container=".wc_stripe_product_payment_methods "+this.container,a.ProductGateway.call(this),a.ApplePay.prototype.initialize.call(this)):setTimeout(this.initialize.bind(this),1e3)},t.prototype.canMakePayment=function(){a.ApplePay.prototype.canMakePayment.call(this).then(function(){e(document.body).on("change",'[name="quantity"]',this.maybe_calculate_cart.bind(this)),e(this.container).parent().parent().addClass("active"),this.is_variable_product()?this.variable_product_selected()?this.cart_calculation(this.get_product_data().variation.variation_id):this.disable_payment_button():this.cart_calculation()}.bind(this))},t.prototype.cart_calculation=function(){return a.ProductGateway.prototype.cart_calculation.apply(this,arguments).then(function(t){this.update_from_cart_calculation(t),this.payment_request_options.requestShipping!==t.needsShipping&&a.ApplePay.prototype.initialize.call(this)}.bind(this))},t.prototype.start=function(t){0===this.get_quantity()?(t.preventDefault(),this.submit_error(this.params.messages.invalid_amount)):(this.needs_shipping()||this.add_to_cart(),a.ApplePay.prototype.start.apply(this,arguments))},t.prototype.append_button=function(){var t=document.querySelectorAll(".wc-stripe-applepay-container");t&&1<t.length?(e.each(t,function(t,a){e(a).empty(),e(a).append(this.$button.clone(!0))}.bind(this)),this.$button=e(".wc-stripe-applepay-container").find("button")):e("#wc-stripe-applepay-container").append(this.$button)},t.prototype.maybe_calculate_cart=function(){this.disable_payment_button(),this.old_qty=this.get_quantity(),this.is_variable_product()&&!this.variable_product_selected()||this.cart_calculation().then(function(){this.is_variable_product()?(this.createPaymentRequest(),a.ApplePay.prototype.canMakePayment.apply(this,arguments).then(function(){this.enable_payment_button()}.bind(this))):this.enable_payment_button()}.bind(this))},t.prototype.found_variation=function(t){a.ProductGateway.prototype.found_variation.apply(this,arguments),this.can_pay&&this.maybe_calculate_cart()},a.product_gateways.push(new t)}(jQuery,wc_stripe);