(()=>{"use strict";!function(i,e,a){var n=function(i){return i.preventDefault()},t=function(e){var a=this,n=i(e),t=0;a.init=function(){n.on("click",".is-mega",(function(){a.flush(i(this)),a.depends()})),n.on("mouseup",".menu-item-bar",(function(){clearTimeout(t),t=setTimeout((function(){a.depends()}),50)})),n.on("change",".is-width",(function(){var e=i(this),a=e.val(),n=e.closest(".ayyash-mega-menu");n.find(".mega-depend-width").toggleClass("hidden","custom"!==a),n.find(".mega-depend-position").toggleClass("hidden","full"===a)})),i(".is-width").trigger("change"),a.depends()},a.depends=function(){n.find(".is-mega").each((function(){a.flush(i(this))})),i("li",n).removeClass("active-mega-column").removeClass("active-sub-mega-column");var e=i(".active-mega-menu",n).nextUntil(".menu-item-depth-0","li");e.closest("li.menu-item-depth-1").addClass("active-mega-column"),e.closest("li:not(.menu-item-depth-1)").addClass("active-sub-mega-column")},a.flush=function(i){var e=i.is(":checked"),a=i.closest("li");a.toggleClass("active-mega-menu",e),a.find(".field-mega-width").toggleClass("hidden",!e)},a.init()};i.fn.ayyashMegamenu=function(){return this.each((function(){new t(this)}))},i(a).ready((function(){var t,c,o,s,d,l,h,u,r,f,m,g,v;i("#menu-to-edit").ayyashMegamenu(),l=i("#icon-dialog"),h=i("#icon-overlay"),u=l.find("#icon-insert"),r=l.find("#icon-load"),f=l.find("#icon-search"),m=i(e).height()<500?parseInt(i(e).height()):500,g=!1,v=!1,l.dialog({dialogClass:"wp-dialog ayyash-icon-dialog",width:1e3,height:m,closeOnEscape:!0,autoOpen:!1,create:function(){i(".ui-dialog-titlebar-close").addClass("ui-button")},open:function(){r.height(m-210),h.show()},close:function(){g=!1,h.hide()},resize:function(i,e){r.height(parseInt(e.size.height)-210)}}),i(a).on("click",".pick-icon[data-name]",(function(e){n(e);var a=i(this);a.is(".active-icon")?(a.removeClass("active-icon"),g=!1):(a.addClass("active-icon").siblings().removeClass("active-icon"),g=a.data("name"))})),f.keyup((function(){if(v){d||(d=r.find("a"));var e=i(this).val();if(e){var a=new RegExp(e,"i");d.each((function(){var e=i(this);e.data("name").search(a)<0?e.hide():e.show()}))}else d.show()}})),u.click((function(i){if(n(i),v&&g){var e=s.data("label").replace("%s",g.replace("ti-","").replace("-"," "));s.removeClass("hidden"),s.html('<span class="ayyash-icon '.concat(g,'" aria-label="').concat(e,'"></span>')),s.next(".ayyash-icon-add").data("icon",g),o.val(g).trigger("keyup"),t.removeClass("hidden"),l.dialog("close")}})),i(a.body).on("click",".ayyash-icon-add",(function(e){n(e),c=i(this).parent(),s=c.find(".icon-preview"),t=c.find(".icon-remove"),o=c.find(".icon-value"),l.dialog("open"),!1===v?i.ajax({type:"POST",url:ajaxurl,data:{action:"ayyash-icons"},success:function(e){r.html(e),r.find('[data-name="'+i(this).data("icon")+'"]').addClass("active-icon"),v=!0}}):(r.find("a").removeClass("active-icon"),r.find('[data-name="'+i(this).data("icon")+'"]').addClass("active-icon"))})),i(a.body).on("click",".icon-remove",(function(e){n(e);var a=i(this),t=a.parent();t.find(".icon-preview").empty().addClass("hidden"),t.find(".ayyash-icon-add").data("icon",""),t.find(".icon-value").val(""),a.addClass("hidden")})),h.click((function(i){n(i),h.hide(),l.dialog("close")}))}))}(jQuery,window,document)})();