(()=>{function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(t,o){for(var r=0;r<o.length;r++){var n=o[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(a=n.key,c=void 0,c=function(t,o){if("object"!==e(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,o||"default");if("object"!==e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===o?String:Number)(t)}(a,"string"),"symbol"===e(c)?c:String(c)),n)}var a,c}var o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var o,r,n;return o=e,(r=[{key:"init",value:function(){var e=$("#table-backups");e.on("click",".deleteDialog",(function(e){e.preventDefault(),$(".delete-crud-entry").data("section",$(e.currentTarget).data("section")),$(".modal-confirm-delete").modal("show")})),e.on("click",".restoreBackup",(function(e){e.preventDefault(),$("#restore-backup-button").data("section",$(e.currentTarget).data("section")),$("#restore-backup-modal").modal("show")})),$(".delete-crud-entry").on("click",(function(t){t.preventDefault(),$(".modal-confirm-delete").modal("hide");var o=$(t.currentTarget).data("section");$.ajax({url:o,type:"POST",data:{_method:"DELETE"},success:function(t){t.error?Botble.showError(t.message):(e.find("tbody tr").length<=1&&e.load(window.location.href+" #table-backups > *"),e.find('a[data-section="'+o+'"]').closest("tr").remove(),Botble.showSuccess(t.message))},error:function(e){Botble.handleError(e)}})})),$("#restore-backup-button").on("click",(function(e){e.preventDefault();var t=$(e.currentTarget);t.addClass("button-loading"),$.ajax({url:t.data("section"),type:"GET",success:function(e){t.removeClass("button-loading"),t.closest(".modal").modal("hide"),e.error?Botble.showError(e.message):(Botble.showSuccess(e.message),window.location.reload())},error:function(e){t.removeClass("button-loading"),Botble.handleError(e)}})})),$(document).on("click","#generate_backup",(function(e){e.preventDefault(),$("#name").val(""),$("#description").val(""),$("#create-backup-modal").modal("show")})),$("#create-backup-modal").on("click","#create-backup-button",(function(t){t.preventDefault();var o=$(t.currentTarget);o.addClass("button-loading");var r=$("#name").val(),n=$("#description").val(),a=!1;""!==r&&null!==r||(a=!0,Botble.showError("Backup name is required!")),a?o.removeClass("button-loading"):$.ajax({url:$("div[data-route-create]").data("route-create"),type:"POST",data:{name:r,description:n},success:function(t){o.removeClass("button-loading"),o.closest(".modal").modal("hide"),t.error?Botble.showError(t.message):(e.find(".no-backup-row").remove(),e.find("tbody").append(t.data),Botble.showSuccess(t.message))},error:function(e){o.removeClass("button-loading"),Botble.handleError(e)}})}))}}])&&t(o.prototype,r),n&&t(o,n),Object.defineProperty(o,"prototype",{writable:!1}),e}();$(document).ready((function(){(new o).init()}))})();