(function(c){"function"===typeof define&&define.amd?define(["jquery","./core","./widget","./position"],c):c(jQuery)})(function(c){return c.widget("ui.menu",{version:"1.11.4",defaultElement:"<ul>",delay:300,options:{icons:{submenu:"ui-icon-carat-1-e"},items:"> *",menus:"ul",position:{my:"left-1 top",at:"right top"},role:"menu",blur:null,focus:null,select:null},_create:function(){this.activeMenu=this.element;this.mouseHandled=!1;this.element.uniqueId().addClass("ui-menu ui-widget ui-widget-content").toggleClass("ui-menu-icons",
!!this.element.find(".ui-icon").length).attr({role:this.options.role,tabIndex:0});this.options.disabled&&this.element.addClass("ui-state-disabled").attr("aria-disabled","true");this._on({"mousedown .ui-menu-item":function(a){a.preventDefault()},"click .ui-menu-item":function(a){var b=c(a.target);!this.mouseHandled&&b.not(".ui-state-disabled").length&&(this.select(a),a.isPropagationStopped()||(this.mouseHandled=!0),b.has(".ui-menu").length?this.expand(a):!this.element.is(":focus")&&c(this.document[0].activeElement).closest(".ui-menu").length&&
(this.element.trigger("focus",[!0]),this.active&&1===this.active.parents(".ui-menu").length&&clearTimeout(this.timer)))},"mouseenter .ui-menu-item":function(a){if(!this.previousFilter){var b=c(a.currentTarget);b.siblings(".ui-state-active").removeClass("ui-state-active");this.focus(a,b)}},mouseleave:"collapseAll","mouseleave .ui-menu":"collapseAll",focus:function(a,b){var d=this.active||this.element.find(this.options.items).eq(0);b||this.focus(a,d)},blur:function(a){this._delay(function(){c.contains(this.element[0],
this.document[0].activeElement)||this.collapseAll(a)})},keydown:"_keydown"});this.refresh();this._on(this.document,{click:function(a){this._closeOnDocumentClick(a)&&this.collapseAll(a);this.mouseHandled=!1}})},_destroy:function(){this.element.removeAttr("aria-activedescendant").find(".ui-menu").addBack().removeClass("ui-menu ui-widget ui-widget-content ui-menu-icons ui-front").removeAttr("role").removeAttr("tabIndex").removeAttr("aria-labelledby").removeAttr("aria-expanded").removeAttr("aria-hidden").removeAttr("aria-disabled").removeUniqueId().show();
this.element.find(".ui-menu-item").removeClass("ui-menu-item").removeAttr("role").removeAttr("aria-disabled").removeUniqueId().removeClass("ui-state-hover").removeAttr("tabIndex").removeAttr("role").removeAttr("aria-haspopup").children().each(function(){var a=c(this);a.data("ui-menu-submenu-carat")&&a.remove()});this.element.find(".ui-menu-divider").removeClass("ui-menu-divider ui-widget-content")},_keydown:function(a){var b,d,e,f=!0;switch(a.keyCode){case c.ui.keyCode.PAGE_UP:this.previousPage(a);
break;case c.ui.keyCode.PAGE_DOWN:this.nextPage(a);break;case c.ui.keyCode.HOME:this._move("first","first",a);break;case c.ui.keyCode.END:this._move("last","last",a);break;case c.ui.keyCode.UP:this.previous(a);break;case c.ui.keyCode.DOWN:this.next(a);break;case c.ui.keyCode.LEFT:this.collapse(a);break;case c.ui.keyCode.RIGHT:this.active&&!this.active.is(".ui-state-disabled")&&this.expand(a);break;case c.ui.keyCode.ENTER:case c.ui.keyCode.SPACE:this._activate(a);break;case c.ui.keyCode.ESCAPE:this.collapse(a);
break;default:f=!1,b=this.previousFilter||"",d=String.fromCharCode(a.keyCode),e=!1,clearTimeout(this.filterTimer),d===b?e=!0:d=b+d,b=this._filterMenuItems(d),b=e&&-1!==b.index(this.active.next())?this.active.nextAll(".ui-menu-item"):b,b.length||(d=String.fromCharCode(a.keyCode),b=this._filterMenuItems(d)),b.length?(this.focus(a,b),this.previousFilter=d,this.filterTimer=this._delay(function(){delete this.previousFilter},1E3)):delete this.previousFilter}f&&a.preventDefault()},_activate:function(a){this.active.is(".ui-state-disabled")||
(this.active.is("[aria-haspopup='true']")?this.expand(a):this.select(a))},refresh:function(){var a,b=this,d=this.options.icons.submenu;a=this.element.find(this.options.menus);this.element.toggleClass("ui-menu-icons",!!this.element.find(".ui-icon").length);a.filter(":not(.ui-menu)").addClass("ui-menu ui-widget ui-widget-content ui-front").hide().attr({role:this.options.role,"aria-hidden":"true","aria-expanded":"false"}).each(function(){var a=c(this),b=a.parent(),g=c("<span>").addClass("ui-menu-icon ui-icon "+
d).data("ui-menu-submenu-carat",!0);b.attr("aria-haspopup","true").prepend(g);a.attr("aria-labelledby",b.attr("id"))});a=a.add(this.element).find(this.options.items);a.not(".ui-menu-item").each(function(){var a=c(this);b._isDivider(a)&&a.addClass("ui-widget-content ui-menu-divider")});a.not(".ui-menu-item, .ui-menu-divider").addClass("ui-menu-item").uniqueId().attr({tabIndex:-1,role:this._itemRole()});a.filter(".ui-state-disabled").attr("aria-disabled","true");this.active&&!c.contains(this.element[0],
this.active[0])&&this.blur()},_itemRole:function(){return{menu:"menuitem",listbox:"option"}[this.options.role]},_setOption:function(a,b){"icons"===a&&this.element.find(".ui-menu-icon").removeClass(this.options.icons.submenu).addClass(b.submenu);"disabled"===a&&this.element.toggleClass("ui-state-disabled",!!b).attr("aria-disabled",b);this._super(a,b)},focus:function(a,b){var d;this.blur(a,a&&"focus"===a.type);this._scrollIntoView(b);this.active=b.first();d=this.active.addClass("ui-state-focus").removeClass("ui-state-active");
this.options.role&&this.element.attr("aria-activedescendant",d.attr("id"));this.active.parent().closest(".ui-menu-item").addClass("ui-state-active");a&&"keydown"===a.type?this._close():this.timer=this._delay(function(){this._close()},this.delay);d=b.children(".ui-menu");d.length&&a&&/^mouse/.test(a.type)&&this._startOpening(d);this.activeMenu=b.parent();this._trigger("focus",a,{item:b})},_scrollIntoView:function(a){var b,d,e;this._hasScroll()&&(b=parseFloat(c.css(this.activeMenu[0],"borderTopWidth"))||
0,d=parseFloat(c.css(this.activeMenu[0],"paddingTop"))||0,b=a.offset().top-this.activeMenu.offset().top-b-d,d=this.activeMenu.scrollTop(),e=this.activeMenu.height(),a=a.outerHeight(),0>b?this.activeMenu.scrollTop(d+b):b+a>e&&this.activeMenu.scrollTop(d+b-e+a))},blur:function(a,b){b||clearTimeout(this.timer);this.active&&(this.active.removeClass("ui-state-focus"),this.active=null,this._trigger("blur",a,{item:this.active}))},_startOpening:function(a){clearTimeout(this.timer);"true"===a.attr("aria-hidden")&&
(this.timer=this._delay(function(){this._close();this._open(a)},this.delay))},_open:function(a){var b=c.extend({of:this.active},this.options.position);clearTimeout(this.timer);this.element.find(".ui-menu").not(a.parents(".ui-menu")).hide().attr("aria-hidden","true");a.show().removeAttr("aria-hidden").attr("aria-expanded","true").position(b)},collapseAll:function(a,b){clearTimeout(this.timer);this.timer=this._delay(function(){var d=b?this.element:c(a&&a.target).closest(this.element.find(".ui-menu"));
d.length||(d=this.element);this._close(d);this.blur(a);this.activeMenu=d},this.delay)},_close:function(a){a||(a=this.active?this.active.parent():this.element);a.find(".ui-menu").hide().attr("aria-hidden","true").attr("aria-expanded","false").end().find(".ui-state-active").not(".ui-state-focus").removeClass("ui-state-active")},_closeOnDocumentClick:function(a){return!c(a.target).closest(".ui-menu").length},_isDivider:function(a){return!/[^\-\u2014\u2013\s]/.test(a.text())},collapse:function(a){var b=
this.active&&this.active.parent().closest(".ui-menu-item",this.element);b&&b.length&&(this._close(),this.focus(a,b))},expand:function(a){var b=this.active&&this.active.children(".ui-menu ").find(this.options.items).first();b&&b.length&&(this._open(b.parent()),this._delay(function(){this.focus(a,b)}))},next:function(a){this._move("next","first",a)},previous:function(a){this._move("prev","last",a)},isFirstItem:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},isLastItem:function(){return this.active&&
!this.active.nextAll(".ui-menu-item").length},_move:function(a,b,d){var c;this.active&&(c="first"===a||"last"===a?this.active["first"===a?"prevAll":"nextAll"](".ui-menu-item").eq(-1):this.active[a+"All"](".ui-menu-item").eq(0));c&&c.length&&this.active||(c=this.activeMenu.find(this.options.items)[b]());this.focus(d,c)},nextPage:function(a){var b,d,e;this.active?this.isLastItem()||(this._hasScroll()?(d=this.active.offset().top,e=this.element.height(),this.active.nextAll(".ui-menu-item").each(function(){b=
c(this);return 0>b.offset().top-d-e}),this.focus(a,b)):this.focus(a,this.activeMenu.find(this.options.items)[this.active?"last":"first"]())):this.next(a)},previousPage:function(a){var b,d,e;this.active?this.isFirstItem()||(this._hasScroll()?(d=this.active.offset().top,e=this.element.height(),this.active.prevAll(".ui-menu-item").each(function(){b=c(this);return 0<b.offset().top-d+e}),this.focus(a,b)):this.focus(a,this.activeMenu.find(this.options.items).first())):this.next(a)},_hasScroll:function(){return this.element.outerHeight()<
this.element.prop("scrollHeight")},select:function(a){this.active=this.active||c(a.target).closest(".ui-menu-item");var b={item:this.active};this.active.has(".ui-menu").length||this.collapseAll(a,!0);this._trigger("select",a,b)},_filterMenuItems:function(a){a=a.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&");var b=new RegExp("^"+a,"i");return this.activeMenu.find(this.options.items).filter(".ui-menu-item").filter(function(){return b.test(c.trim(c(this).text()))})}})});