$(document).ready((function(){$(".service-item").on("change",(function(){var e=[];$(".service-item:checked").each((function(t,o){e[t]=$(o).val()})),$("body").css("cursor","progress"),$(".custom-checkbox label").css("cursor","progress");var t=$(document).find(".payment-checkout-btn");t.prop("disabled",!0);var o=$(document).find('.payment-checkout-form .list_payment_method input[name="payment_method"]:checked').val();$.ajax({type:"GET",cache:!1,url:"/ajax/calculate-amount",data:{room_id:$("input[name=room_id]").val(),start_date:$("input[name=start_date]").val(),end_date:$("input[name=end_date]").val(),services:e},success:function(e){var a=e.error,n=e.data;a||($(".total-amount-text").text(n.total_amount),$("input[name=amount]").val(n.amount_raw),$(".amount-text").text(n.sub_total),$(".discount-text").text(n.discount_amount),$(".tax-text").text(n.tax_amount)),$("body").css("cursor","default"),$(".custom-checkbox label").css("cursor","pointer"),$(".payment-checkout-form .list_payment_method").load(window.location.href+" .payment-checkout-form .list_payment_method > *",(function(){t.prop("disabled",!1),$(document).find('.payment-checkout-form .list_payment_method input[value="'+o+'"]').prop("checked",!0).trigger("change")}))},error:function(){$("body").css("cursor","default"),$(".custom-checkbox label").css("cursor","pointer")}})})),$(".create-customer").on("change",'input[name="register_customer"]',(function(e){$formCreate=$(".form-create-customer-password"),e.target.checked?$formCreate.removeClass("d-none"):$formCreate.addClass("d-none")}));var e=function(){var e=[];$(".service-item:checked").each((function(t,o){e[t]=$(o).val()}));var t=$(document).find(".payment-checkout-btn");t.prop("disabled",!0);var o=$(document).find('.payment-checkout-form .list_payment_method input[name="payment_method"]:checked').val();$.ajax({url:"/ajax/calculate-amount",type:"GET",data:{room_id:$("input[name=room_id]").val(),start_date:$("input[name=start_date]").val(),end_date:$("input[name=end_date]").val(),services:e},success:function(e){var a,n=e.error,r=e.message,c=e.data;if(n)RiorelaxTheme.showError(r);else{$(".total-amount-text").text(c.total_amount),$("input[name=amount]").val(c.amount_raw),$(".amount-text").text(c.sub_total),$(".discount-text").text(c.discount_amount),$(".tax-text").text(c.tax_amount),$(".payment-checkout-form .list_payment_method").load(window.location.href+" .payment-checkout-form .list_payment_method > *",(function(){t.prop("disabled",!1),$(document).find('.payment-checkout-form .list_payment_method input[value="'+o+'"]').prop("checked",!0).trigger("change")}));var u=$(".order-detail-box").data("refresh-url");$.ajax({url:u,type:"GET",data:{coupon_code:null!==(a=$("input[name=coupon_hidden]").val())&&void 0!==a?a:$("input[name=coupon_code]").val()},success:function(e){var t=e.error,o=e.message,a=e.data;t?RiorelaxTheme.showError(o):$(".order-detail-box").html(a)},error:function(e){RiorelaxTheme.handleError(e)}})}},error:function(e){RiorelaxTheme.handleError(e)}})};$(document).on("click",".toggle-coupon-form",(function(){return $(document).find(".coupon-form").toggle("fast")})).on("click",".apply-coupon-code",(function(t){t.preventDefault();var o=$(t.currentTarget);$.ajax({url:o.data("url"),type:"POST",headers:{"X-CSRF-TOKEN":$('meta[name="csrf-token"]').attr("content")},data:{coupon_code:$("input[name=coupon_code]").val()},beforeSend:function(){o.addClass("button-loading")},success:function(t){var o=t.error,a=t.message;o?RiorelaxTheme.showError(a):(RiorelaxTheme.showSuccess(a),e())},error:function(e){RiorelaxTheme.handleError(e)},complete:function(){o.removeClass("button-loading")}})})).on("click",".remove-coupon-code",(function(t){t.preventDefault();var o=$(t.currentTarget);$.ajax({url:o.data("url"),type:"POST",headers:{"X-CSRF-TOKEN":$('meta[name="csrf-token"]').attr("content")},beforeSend:function(){o.addClass("button-loading")},success:function(t){var o=t.message;t.error?RiorelaxTheme.showError(o):(RiorelaxTheme.showSuccess(o),e())},error:function(e){RiorelaxTheme.handleError(e)},complete:function(){o.removeClass("button-loading")}})}))}));