!function(C){"use strict";var n=function(e,t){this.options=t,this.$element=C(e),this.$container=C("
",{class:"ms-container"}),this.$selectableContainer=C("
",{class:"ms-selectable"}),this.$selectionContainer=C("
",{class:"ms-selection"}),this.$selectableUl=C("
    ",{class:"ms-list",tabindex:"-1"}),this.$selectionUl=C("
      ",{class:"ms-list",tabindex:"-1"}),this.scrollTo=0,this.elemsSelector="li:visible:not(.ms-optgroup-label,.ms-optgroup-container,."+t.disabledClass+")"};n.prototype={constructor:n,init:function(){var e=this,t=this.$element;if(0===t.next(".ms-container").length){t.css({position:"absolute",left:"-9999px"}),t.attr("id",t.attr("id")?t.attr("id"):Math.ceil(1e3*Math.random())+"multiselect"),this.$container.attr("id","ms-"+t.attr("id")),this.$container.addClass(e.options.cssClass),t.find("option").each(function(){e.generateLisFromOption(this)}),this.$selectionUl.find(".ms-optgroup-label").hide(),e.options.selectableHeader&&e.$selectableContainer.append(e.options.selectableHeader),e.$selectableContainer.append(e.$selectableUl),e.options.selectableFooter&&e.$selectableContainer.append(e.options.selectableFooter),e.options.selectionHeader&&e.$selectionContainer.append(e.options.selectionHeader),e.$selectionContainer.append(e.$selectionUl),e.options.selectionFooter&&e.$selectionContainer.append(e.options.selectionFooter),e.$container.append(e.$selectableContainer),e.$container.append(e.$selectionContainer),t.after(e.$container),e.activeMouse(e.$selectableUl),e.activeKeyboard(e.$selectableUl);var s=e.options.dblClick?"dblclick":"click";e.$selectableUl.on(s,".ms-elem-selectable",function(){e.select(C(this).data("ms-value"))}),e.$selectionUl.on(s,".ms-elem-selection",function(){e.deselect(C(this).data("ms-value"))}),e.activeMouse(e.$selectionUl),e.activeKeyboard(e.$selectionUl),t.on("focus",function(){e.$selectableUl.focus()})}var l=t.find("option:selected").map(function(){return C(this).val()}).get();e.select(l,"init"),"function"==typeof e.options.afterInit&&e.options.afterInit.call(this,this.$container)},generateLisFromOption:function(e,t,s){for(var l=this,i=l.$element,n="",o=C(e),a=0;a"+l.escapeHTML(o.text())+""),d=c.clone(),h=o.val(),p=l.sanitize(h);c.data("ms-value",h).addClass("ms-elem-selectable").attr("id",p+"-selectable"),d.data("ms-value",h).addClass("ms-elem-selection").attr("id",p+"-selection").hide(),(o.prop("disabled")||i.prop("disabled"))&&(d.addClass(l.options.disabledClass),c.addClass(l.options.disabledClass));var f=o.parent("optgroup");if(0
    ";v=C(g),b=C(g),v.attr("id","optgroup-selectable-"+m),b.attr("id","optgroup-selection-"+m),v.append(C($)),b.append(C($)),l.options.selectableOptgroup&&(v.find(".ms-optgroup-label").on("click",function(){var e=f.children(":not(:selected, :disabled)").map(function(){return C(this).val()}).get();l.select(e)}),b.find(".ms-optgroup-label").on("click",function(){var e=f.children(":selected:not(:disabled)").map(function(){return C(this).val()}).get();l.deselect(e)})),l.$selectableUl.append(v),l.$selectionUl.append(b)}t=null==t?v.find("ul").children().length:t+1,c.insertAt(t,v.children()),d.insertAt(t,b.children())}else t=null==t?l.$selectableUl.children().length:t,c.insertAt(t,l.$selectableUl),d.insertAt(t,l.$selectionUl)},addOption:function(e){var i=this;void 0!==e.value&&null!==e.value&&(e=[e]),C.each(e,function(e,t){if(void 0!==t.value&&null!==t.value&&0===i.$element.find("option[value='"+t.value+"']").length){var s=C('"),l=(e=parseInt(void 0===t.index?i.$element.children().length:t.index),null==t.nested?i.$element:C("optgroup[label='"+t.nested+"']"));s.insertAt(e,l),i.generateLisFromOption(s.get(0),e,t.nested)}})},escapeHTML:function(e){return C("
    ").text(e).html()},activeKeyboard:function(s){var l=this;s.on("focus",function(){C(this).addClass("ms-focus")}).on("blur",function(){C(this).removeClass("ms-focus")}).on("keydown",function(e){switch(e.which){case 40:case 38:return e.preventDefault(),e.stopPropagation(),void l.moveHighlight(C(this),38===e.which?-1:1);case 37:case 39:return e.preventDefault(),e.stopPropagation(),void l.switchList(s);case 9:if(l.$element.is("[tabindex]")){e.preventDefault();var t=parseInt(l.$element.attr("tabindex"),10);return t=e.shiftKey?t-1:t+1,void C('[tabindex="'+t+'"]').focus()}e.shiftKey&&l.$element.trigger("focus")}if(-1