").appendTo(r.$node),new s(e,n)})}return e.mixin(i.prototype,r,{_onSelectableClick:function(e){this.trigger("selectableClicked",t(e.currentTarget))},_onRendered:function(t,e,i,n){this.$node.toggleClass(this.classes.empty,this._allDatasetsEmpty()),this.trigger("datasetRendered",e,i,n)},_onCleared:function(){this.$node.toggleClass(this.classes.empty,this._allDatasetsEmpty()),this.trigger("datasetCleared")},_propagate:function(){this.trigger.apply(this,arguments)},_allDatasetsEmpty:function(){return e.every(this.datasets,function(t){return t.isEmpty()})},_getSelectables:function(){return this.$node.find(this.selectors.selectable)},_removeCursor:function(){var t=this.getActiveSelectable();t&&t.removeClass(this.classes.cursor)},_ensureVisible:function(t){var e,i,n,r;i=(e=t.position().top)+t.outerHeight(!0),n=this.$node.scrollTop(),r=this.$node.height()+parseInt(this.$node.css("paddingTop"),10)+parseInt(this.$node.css("paddingBottom"),10),e<0?this.$node.scrollTop(n+e):r
"),e.each(this.datasets,function(t){t.destroy()})}}),i}(),l=function(){"use strict";var t=u.prototype;function i(){u.apply(this,[].slice.call(arguments,0))}return e.mixin(i.prototype,u.prototype,{open:function(){return!this._allDatasetsEmpty()&&this._show(),t.open.apply(this,[].slice.call(arguments,0))},close:function(){return this._hide(),t.close.apply(this,[].slice.call(arguments,0))},_onRendered:function(){return this._allDatasetsEmpty()?this._hide():this.isOpen()&&this._show(),t._onRendered.apply(this,[].slice.call(arguments,0))},_onCleared:function(){return this._allDatasetsEmpty()?this._hide():this.isOpen()&&this._show(),t._onCleared.apply(this,[].slice.call(arguments,0))},setLanguageDirection:function(e){return this.$node.css("ltr"===e?this.css.ltr:this.css.rtl),t.setLanguageDirection.apply(this,[].slice.call(arguments,0))},_hide:function(){this.$node.hide()},_show:function(){this.$node.css("display","block")}}),i}(),c=function(){"use strict";function i(i,r){var o,a,s,u,l,c,h,p,f,d,m;(i=i||{}).input||t.error("missing input"),i.menu||t.error("missing menu"),i.eventBus||t.error("missing event bus"),r.mixin(this),this.eventBus=i.eventBus,this.minLength=e.isNumber(i.minLength)?i.minLength:1,this.input=i.input,this.menu=i.menu,this.enabled=!0,this.active=!1,this.input.hasFocus()&&this.activate(),this.dir=this.input.getLangDir(),this._hacks(),this.menu.bind().onSync("selectableClicked",this._onSelectableClicked,this).onSync("asyncRequested",this._onAsyncRequested,this).onSync("asyncCanceled",this._onAsyncCanceled,this).onSync("asyncReceived",this._onAsyncReceived,this).onSync("datasetRendered",this._onDatasetRendered,this).onSync("datasetCleared",this._onDatasetCleared,this),o=n(this,"activate","open","_onFocused"),a=n(this,"deactivate","_onBlurred"),s=n(this,"isActive","isOpen","_onEnterKeyed"),u=n(this,"isActive","isOpen","_onTabKeyed"),l=n(this,"isActive","_onEscKeyed"),c=n(this,"isActive","open","_onUpKeyed"),h=n(this,"isActive","open","_onDownKeyed"),p=n(this,"isActive","isOpen","_onLeftKeyed"),f=n(this,"isActive","isOpen","_onRightKeyed"),d=n(this,"_openIfActive","_onQueryChanged"),m=n(this,"_openIfActive","_onWhitespaceChanged"),this.input.bind().onSync("focused",o,this).onSync("blurred",a,this).onSync("enterKeyed",s,this).onSync("tabKeyed",u,this).onSync("escKeyed",l,this).onSync("upKeyed",c,this).onSync("downKeyed",h,this).onSync("leftKeyed",p,this).onSync("rightKeyed",f,this).onSync("queryChanged",d,this).onSync("whitespaceChanged",m,this).onSync("langDirChanged",this._onLangDirChanged,this)}return e.mixin(i.prototype,{_hacks:function(){var i,n;i=this.input.$input||t("