$((function(){var e=$(".alert.alert-warning");e.length>0&&_.map(e,(function(e){var t=localStorage.getItem("storage-alerts");if(t=t?JSON.parse(t):{},$(e).data("alert-id")){if(t[$(e).data("alert-id")])return void $(e).alert("close");$(e).removeClass("hidden")}})),e.on("closed.bs.alert",(function(e){var t=$(e.target).data("alert-id");if(t){var a=localStorage.getItem("storage-alerts");(a=a?JSON.parse(a):{})[t]=!0,localStorage.setItem("storage-alerts",JSON.stringify(a))}}));var t=!1;$(document).on("click",".download-template",(function(e){if(e.preventDefault(),!t){var a=$(e.currentTarget),r=a.data("extension"),o=a.html();$.ajax({url:a.data("url"),method:"POST",data:{extension:r},xhrFields:{responseType:"blob"},beforeSend:function(){a.html(a.data("downloading")),a.addClass("text-secondary"),t=!0},success:function(e){var t=document.createElement("a"),r=window.URL.createObjectURL(e);t.href=r,t.download=a.data("filename"),document.body.append(t),t.click(),t.remove(),window.URL.revokeObjectURL(r)},error:function(e){Botble.handleError(e)},complete:function(){setTimeout((function(){a.html(o),a.removeClass("text-secondary"),t=!1}),2e3)}})}})),$(document).on("submit",".form-import-data",(function(e){e.preventDefault();var t=$(this),a=new FormData(t.get(0)),r=t.find("button[type=submit]"),o=$("#imported-message"),n=$("#imported-listing"),s=$(".show-errors"),l=$("#failure-template").html();$(".main-form-message").addClass("hidden"),o.addClass("hidden"),o.html(""),n.html(""),$httpClient.make().withButtonLoading(r).withLoading(t).post(t.attr("action"),a).then((function(e){var a=e.data;Botble.showSuccess(a.message),o.removeClass().addClass("alert alert-success").html(a.message),t.trigger("reset")})).catch((function(e){var t=e.response.data.data,a="";t&&t.failures&&_.map(t.failures,(function(e){a+=l.replace("__row__",e.row).replace("__attribute__",e.attribute).replace("__errors__",e.errors.join(", "))})),t&&t.total_failed?(t.total_success?$class="alert alert-warning":$class="alert alert-danger",s.removeClass("hidden")):s.addClass("hidden"),a&&n.removeClass("hidden").html(a)})).finally((function(){$(".main-form-message").removeClass("hidden")}))}))}));