!function(i,a){function t(){a.BaseGateway.call(this,wc_stripe_googlepay_product_params),window.addEventListener("hashchange",this.hashchange.bind(this))}(t.prototype=i.extend({},a.BaseGateway.prototype,a.ProductGateway.prototype,a.GooglePay.prototype)).initialize=function(){if(!i(this.container).length)return setTimeout(this.initialize.bind(this),1e3);a.ProductGateway.call(this),this.createPaymentsClient(),this.isReadyToPay().then(function(){i(document.body).on("change",'[name="quantity"]',this.maybe_calculate_cart.bind(this)),i(this.container).show(),i(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.maybe_calculate_cart=function(){if(this.disable_payment_button(),this.is_variable_product()){if(!this.variable_product_selected())return;var t=this.get_product_data();if(t&&t.variation&&!t.variation.is_in_stock)return}this.cart_calculation().then(function(t){this.enable_payment_button()}.bind(this))["catch"](function(){this.enable_payment_button()}.bind(this))},t.prototype.found_variation=function(){a.ProductGateway.prototype.found_variation.apply(this,arguments),this.can_pay&&this.maybe_calculate_cart()},t.prototype.cart_calculation=function(){return a.ProductGateway.prototype.cart_calculation.apply(this,arguments).then(function(t){this.update_from_cart_calculation(t)}.bind(this))},t.prototype.create_button=function(){var t=document.querySelectorAll(".wc-stripe-googlepay-product-container");t&&1<t.length?(this.$button&&this.$button.remove(),i.each(t,function(t,a){var e=i(this.paymentsClient.createButton(this.get_button_options()));e.addClass("gpay-button-container"),this.is_rectangle_button()&&e.find("button").removeClass("new_style"),i(a).append(e)}.bind(this)),this.$button=i(".wc-stripe-googlepay-product-container").find(".gpay-button-container")):(a.GooglePay.prototype.create_button.apply(this,arguments),i("#wc-stripe-googlepay-container").append(this.$button)),this.is_variable_product()&&(this.variable_product_selected()?this.enable_payment_button():this.disable_payment_button())},t.prototype.get_button=function(){return this.$button.find("button")},t.prototype.start=function(){0<this.get_quantity()?(this.needs_shipping()||this.add_to_cart(),a.GooglePay.prototype.start.apply(this,arguments)):this.submit_error(this.params.messages.invalid_amount)},t.prototype.update_payment_data=function(t){return a.GooglePay.prototype.update_payment_data.call(this,t,this.get_add_to_cart_data())},a.product_gateways.push(new t)}(jQuery,wc_stripe);