(()=>{function e(e,t){for(var i=0;i<t.length;i++){var o=t[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}var t=function(){function t(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t)}var i,o,a;return i=t,(o=[{key:"init",value:function(){var e=[{name:"wrap-widgets",pull:"clone",put:!1}];$.each($(".sidebar-item"),(function(){e.push({name:"wrap-widgets",pull:!0,put:!0})}));var t=function(e){if(e.length>0){var t=[];$.each(e.find("li[data-id]"),(function(e,i){t.push($(i).find("form").serialize())})),$httpClient.make().post(BWidget.routes.save_widgets_sidebar,{items:t,sidebar_id:e.data("id")}).then((function(t){var i=t.data;e.find("ul").html(i.data),Botble.callScroll($(".list-page-select-widget")),Botble.initResources(),Botble.initMediaIntegrate(),Botble.initTreeCheckboxes(),Botble.showSuccess(i.message)})).finally((function(){e.find(".widget-save i").remove()}))}};e.forEach((function(e,i){Sortable.create(document.getElementById("wrap-widget-"+(i+1)),{sort:0!==i,group:e,delay:0,disabled:!1,store:null,animation:150,handle:".card-header",ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dataIdAttr:"data-id",forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,scroll:!0,scrollSensitivity:30,scrollSpeed:10,onUpdate:function(e){e.from!==e.to&&t($(e.from).closest(".sidebar-item")),t($(e.item).closest(".sidebar-item"))},onAdd:function(e){e.from!==e.to&&t($(e.from).closest(".sidebar-item")),t($(e.item).closest(".sidebar-item"))}})})),$("#wrap-widgets").on("click",".widget-control-delete",(function(e){e.preventDefault();var t=$(e.currentTarget),i=t.closest("li");Botble.showButtonLoading(t),$httpClient.make().delete(BWidget.routes.delete,{widget_id:i.data("id"),position:i.data("position"),sidebar_id:t.closest(".sidebar-item").data("id")}).then((function(e){var i=e.data;Botble.showSuccess(i.message),t.closest(".sidebar-item").find("ul").html(i.data)})).finally((function(){Botble.showButtonLoading(i.find(".widget-control-delete"))}))})).on("click",".widget-item .card-header",(function(e){var t=$(e.currentTarget);t.closest(".widget-item").find(".widget-content").slideToggle(300),t.find(".ti").hasClass("ti-chevron-up")?setTimeout((function(){t.closest(".card").toggleClass("card-no-border-bottom-radius")}),300):t.closest(".card").toggleClass("card-no-border-bottom-radius"),t.find(".ti").toggleClass("ti-chevron-down").toggleClass("ti-chevron-up")})).on("click",".sidebar-item .card-header .button-sidebar.btn-action",(function(e){var t=$(e.currentTarget);t.closest(".card").find(".card-body").slideToggle(300),t.find(".ti").toggleClass("ti-chevron-down").toggleClass("ti-chevron-up")})).on("click",".widget-save",(function(e){e.preventDefault();var i=$(e.currentTarget);Botble.showButtonLoading(i),t(i.closest(".sidebar-item"))}))}}])&&e(i.prototype,o),a&&e(i,a),Object.defineProperty(i,"prototype",{writable:!1}),t}();$((function(){(new t).init()}))})();