(()=>{var n,t;window.shiptastic=window.shiptastic||{},window.shiptastic.returns=window.shiptastic.returns||{},n=jQuery,(t=window.shiptastic).returns={params:{},init:function(){var e=t.returns;e.params=wc_shiptastic_returns_params,n(document).on("change","#add_return_shipment input.return-item-checkbox, #add_return_shipment input.qty",e.onChangeReturnForm),n(document).on("change","#add_return_shipment input.arrange_return",e.onChangeArrangement)},onChangeArrangement:function(){var e=t.returns,i=n(this).parents("form"),r=n(this);i.find('input[name="items[]"]:checked').length>0&&e.onChangeReturnForm.call(r)},onChangeReturnForm:function(){var e=t.returns,i=n(this).parents("form"),r=i.find(".wc-shiptastic-error-wrapper"),a=i.find(".button[type=submit]"),s=i.serialize();return r.find(".notice").remove(),i.addClass("loading"),i.find(":input:not(.disabled):not([type=hidden])").prop("disabled",!0),a.prop("disabled",!0).addClass("loading"),i.find(".return-shipment-costs").hide(),n.ajax({type:"POST",url:e.params.wc_ajax_url.toString().replace("%%endpoint%%","woocommerce_stc_calculate_return_costs"),data:s,dataType:"json"}).done((function(n){i.removeClass("loading"),i.find(":input:not(.disabled):not([type=hidden])").prop("disabled",!1),a.prop("disabled",!1).removeClass("loading"),i.find(".return-shipment-costs").html(n.cost_i18n).show()})).fail((function(t){i.removeClass("loading"),i.find(":input:not(.disabled):not([type=hidden])").prop("disabled",!1),a.prop("disabled",!1).removeClass("loading");try{var e=JSON.parse(t.responseText)}catch(n){e={}}n.each(e.data,(function(n,t){r.append('<p class="woocommerce-error notice">'+t.message+"</p>")})),r[0].scrollIntoView({behavior:"smooth",block:"start"})})),!1}},n(document).ready((function(){t.returns.init()})),((window.wcShiptastic=window.wcShiptastic||{}).static=window.wcShiptastic.static||{}).returns={}})();