(function(t,e){let s=e.gpos_installment.price,l=e.gpos_installment.currency,i;t('input.qty[name="quantity"]').on("change",()=>{c(s,l)}),t(".composite_data").on("wc-composite-initializing",(n,o)=>{var a=o.api;o.actions.add_action("composite_totals_changed",function(){c(a.get_composite_totals().price,l)},100,a)}),t(".variations_form").on("woocommerce_variation_has_changed",function(){const n=t(this).data("product_variations"),o=t("input.variation_id").val(),a=n.find(p=>p.variation_id==o);a&&c(a.display_price,l)}),t(".grouped_form .qty").on("change",function(){const n=[];t(".qty").each(function(o,a){n.push({product_id:t(a).attr("name").replace(/\D/g,""),qty:parseInt(t(a).val()?t(a).val():0)})}),typeof i<"u"&&i.abort(),i=t.ajax({type:"POST",url:`${e.gpos_installment.ajax_url}?action=gpos_calculate_group_product_price&_wpnonce=${e.gpos_installment.nonce}`,dataType:"json",contentType:"application/json",accept:"application/json",data:JSON.stringify(n),success:function(o){c(o.total,o.currency)}})}),document.addEventListener("gpos-platform-data-changed",async n=>{c(n.detail.amount,n.detail.currency)});function c(n,o){s=n,t('input.qty[name="quantity"]').val()&&(n=parseFloat(n)*parseFloat(t('input.qty[name="quantity"]').val())),n!==0&&(typeof i<"u"&&i.abort(),i=t.ajax({type:"POST",url:`${e.gpos_installment.ajax_url}?action=gpos_get_installment_html&_wpnonce=${e.gpos_installment.nonce}`,dataType:"json",contentType:"application/json",accept:"application/json",data:JSON.stringify({price:n,currency:o}),beforeSend:function(){t("#gpos-installment-container").block({message:"Lütfen bekleyiniz"})},success:function(a){t("#gpos-installment-div").html(a.html)},complete:function(){t("#gpos-installment-container").unblock()}}))}})(jQuery,window);
