(()=>{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 a=0;a<o.length;a++){var i=o[a];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=i.key,n=void 0,n=function(t,o){if("object"!==e(t)||null===t)return t;var a=t[Symbol.toPrimitive];if(void 0!==a){var i=a.call(t,o||"default");if("object"!==e(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===o?String:Number)(t)}(r,"string"),"symbol"===e(n)?n:String(n)),i)}var r,n}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,a,i;return o=e,(a=[{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,o){t.push($(o).find("form").serialize())})),$.ajax({type:"POST",cache:!1,url:BWidget.routes.save_widgets_sidebar,data:{items:t,sidebar_id:e.data("id")},beforeSend:function(){Botble.showNotice("info",BotbleVariables.languages.notices_msg.processing_request)},success:function(t){t.error?Botble.showError(t.message):(e.find("ul").html(t.data),Botble.callScroll($(".list-page-select-widget")),Botble.initResources(),Botble.initMediaIntegrate(),Botble.showSuccess(t.message))},error:function(e){Botble.handleError(e)},complete:function(){e.find(".widget_save i").remove()}})}};e.forEach((function(e,o){Sortable.create(document.getElementById("wrap-widget-"+(o+1)),{sort:0!==o,group:e,delay:0,disabled:!1,store:null,animation:150,handle:".widget-handle",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"))}})}));var o=$("#wrap-widgets");o.on("click",".widget-control-delete",(function(e){e.preventDefault();var t=$(e.currentTarget),o=t.closest("li");t.addClass("button-loading"),$.ajax({type:"POST",cache:!1,url:BWidget.routes.delete,data:{_method:"DELETE",widget_id:o.data("id"),position:o.data("position"),sidebar_id:t.closest(".sidebar-item").data("id")},beforeSend:function(){Botble.showNotice("info",BotbleVariables.languages.notices_msg.processing_request)},success:function(e){e.error?Botble.showError(e.message):(Botble.showSuccess(e.message),o.fadeOut().remove())},error:function(e){Botble.handleError(e)},complete:function(){o.find(".widget-control-delete").removeClass("button-loading")}})})),o.on("click","#added-widget .widget-handle",(function(e){var t=$(e.currentTarget);t.closest("li").find(".widget-content").slideToggle(300),t.find(".fa").toggleClass("fa-caret-up"),t.find(".fa").toggleClass("fa-caret-down")})),o.on("click","#added-widget .sidebar-header",(function(e){var t=$(e.currentTarget);t.closest(".sidebar-area").find("> ul").slideToggle(300),t.find(".fa").toggleClass("fa-caret-up"),t.find(".fa").toggleClass("fa-caret-down")})),o.on("click",".widget_save",(function(e){e.preventDefault();var o=$(e.currentTarget);o.addClass("button-loading"),t(o.closest(".sidebar-item"))})),Botble.callScroll($(".list-page-select-widget"))}}])&&t(o.prototype,a),i&&t(o,i),Object.defineProperty(o,"prototype",{writable:!1}),e}();$(document).ready((function(){(new o).init()}))})();