(()=>{function r(e){return(r="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)}var o;(o=jQuery).fn.filetree=function(t){var n={animationSpeed:"slow",console:!1};function a(e){return e=o.extend(n,e),this.each((function(){o(this).find("li").on("click",".file-opener-i",(function(e){return e.preventDefault(),o(this).hasClass("fa-plus-square")?(o(this).addClass("fa-minus-square"),o(this).removeClass("fa-plus-square")):(o(this).addClass("fa-plus-square"),o(this).removeClass("fa-minus-square")),o(this).parent().toggleClass("closed").toggleClass("open"),!1}))}))}if("object"==r(t)||!t)return a.apply(this,arguments);e.on("error",(function(){}))},function(e){e.fn.dragScroll=function(o){function t(){var r,t,n=e(this),a=e.extend({scrollVertical:!1,scrollHorizontal:!0,cursor:null},o),s=!1;n.on({mousemove:function(o){s&&function(o,n){var s=e(n);a.scrollVertical&&s.scrollTop(s.scrollTop()+(r-o.pageY)),a.scrollHorizontal&&s.scrollLeft(s.scrollLeft()+(t-o.pageX))}(o,this)},mousedown:function(e){n.css("cursor",a.cursor?a.cursor:a.scrollVertical&&a.scrollHorizontal?"move":a.scrollVertical?"row-resize":a.scrollHorizontal?"col-resize":void 0),s=!0,r=e.pageY,t=e.pageX},mouseup:function(){s=!1,n.css("cursor","auto")},mouseleave:function(){s=!1,n.css("cursor","auto")}})}if("object"==r(o)||!o)return t.apply(this,arguments)}}(jQuery),$((function(){$(".file-tree-wrapper").dragScroll();var e=$(".tree-form-container").find(".tree-loading"),r=$(".tree-categories-container").find(".tree-loading");function o(){r.removeClass("d-none"),$(".file-tree-wrapper").filetree().removeClass("d-none").hide().slideDown("slow"),r.addClass("d-none")}function t(e){$(".tree-form-body").html(e),Botble.initResources(),Botble.handleCounterUp(),Botble.initMediaIntegrate(),(new EditorManagement).init()}function n(){var e=$(".file-tree-wrapper");$.ajax({url:e.data("url"),type:"GET",success:function(r){r.error?Botble.showError(r.message):(e.html(r.data),o(),jQuery().tooltip&&$('[data-toggle="tooltip"]').tooltip({placement:"top",boundary:"window"}))},error:function(e){Botble.handleError(e)}})}o(),$(document).on("click",".tree-categories-container .toggle-tree",(function(e){var r=$(e.currentTarget);r.hasClass("open-tree")?(r.text(r.data("collapse")),$(".tree-categories-container").find(".folder-root.closed").removeClass("closed").addClass("open")):(r.text(r.data("expand")),$(".tree-categories-container").find(".folder-root.open").removeClass("open").addClass("closed")),r.toggleClass("open-tree")})),$(document).on("click",".file-tree-wrapper .fetch-data",(function(r){r.preventDefault();var o=$(r.currentTarget);o.attr("href")?$.ajax({url:o.attr("href"),type:"GET",beforeSend:function(){e.removeClass("d-none"),$(".file-tree-wrapper").find("a.active").removeClass("active"),o.addClass("active")},success:function(e){e.error?Botble.showError(e.message):t(e.data)},error:function(e){Botble.handleError(e)},complete:function(){e.addClass("d-none")}}):($(".file-tree-wrapper").find("a.active").removeClass("active"),o.addClass("active"))})),$(document).on("click",".tree-categories-create",(function(r){var o;r.preventDefault(),o=$(r.currentTarget).attr("href"),$.ajax({url:o,type:"GET",beforeSend:function(){e.removeClass("d-none")},success:function(e){e.error?Botble.showError(e.message):t(e.data)},error:function(e){Botble.handleError(e)},complete:function(){e.addClass("d-none")}})})),$(document).on("submit",".tree-form-container form",(function(r){var o;r.preventDefault();var a=$(r.currentTarget),s=a.serializeArray(),l=null===(o=r.originalEvent)||void 0===o?void 0:o.submitter;l&&l.name&&s.push({name:l.name,value:l.value}),$.ajax({url:a.attr("action"),type:a.attr("method")||"POST",data:s,beforeSend:function(){e.removeClass("d-none")},success:function(e){e.error?Botble.showError(e.message):(Botble.showSuccess(e.message),n(),e.data&&t(e.data.form))},error:function(e){Botble.handleError(e)},complete:function(){e.addClass("d-none")}})})),$(document).on("click",".deleteDialog",(function(e){e.preventDefault();var r=$(e.currentTarget);$(".delete-crud-entry").data("section",r.data("section")),$(".modal-confirm-delete").modal("show")})),$(".delete-crud-entry").on("click",(function(e){e.preventDefault();var r=$(e.currentTarget);r.addClass("button-loading");var o=r.data("section");$.ajax({url:o,type:"DELETE",success:function(e){e.error?Botble.showError(e.message):(Botble.showSuccess(e.message),n(),$(".tree-categories-create").length&&$(".tree-categories-create").trigger("click")),r.closest(".modal").modal("hide"),r.removeClass("button-loading")},error:function(e){Botble.handleError(e),r.removeClass("button-loading")}})}))}))})();
