(function(){var n,i,t,r,u=function(n,t){return function(){return n.apply(t,arguments)}},f=function(n,t){function r(){this.constructor=n}for(var i in t)e.call(t,i)&&(n[i]=t[i]);return r.prototype=t.prototype,n.prototype=new r,n.__super__=t.prototype,n},e={}.hasOwnProperty;(r=function(){function n(){this.options_index=0;this.parsed=[]}return n.prototype.add_node=function(n){return"OPTGROUP"===n.nodeName.toUpperCase()?this.add_group(n):this.add_option(n)},n.prototype.add_group=function(n){var i,t,u,f,e,r;for(i=this.parsed.length,this.parsed.push({array_index:i,group:!0,label:n.label,title:n.title?n.title:void 0,children:0,disabled:n.disabled,classes:n.className}),r=[],t=0,u=(e=n.childNodes).length;t<u;t++)f=e[t],r.push(this.add_option(f,i,n.disabled));return r},n.prototype.add_option=function(n,t,i){if("OPTION"===n.nodeName.toUpperCase())return""!==n.text?(null!=t&&(this.parsed[t].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:n.value,text:n.text,html:n.innerHTML,title:n.title?n.title:void 0,selected:n.selected,disabled:!0===i?i:n.disabled,group_array_index:t,group_label:null!=t?this.parsed[t].label:null,classes:n.className,style:n.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1},n}()).select_to_array=function(n){var u,t,f,i,e;for(i=new r,t=0,f=(e=n.childNodes).length;t<f;t++)u=e[t],i.add_node(u);return i.parsed};i=function(){function n(t,i){this.form_field=t;this.options=null!=i?i:{};this.label_click_handler=u(this.label_click_handler,this);n.browser_is_supported()&&(this.is_multiple=this.form_field.multiple,this.set_default_text(),this.set_default_values(),this.setup(),this.set_up_html(),this.register_observers(),this.on_ready())}return n.prototype.set_default_values=function(){return this.click_test_action=function(n){return function(t){return n.test_active_click(t)}}(this),this.activate_action=function(n){return function(t){return n.activate_field(t)}}(this),this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.is_rtl=this.options.rtl||/\bchosen-rtl\b/.test(this.form_field.className),this.allow_single_deselect=null!=this.options.allow_single_deselect&&null!=this.form_field.options[0]&&""===this.form_field.options[0].text&&this.options.allow_single_deselect,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.enable_split_word_search=null==this.options.enable_split_word_search||this.options.enable_split_word_search,this.group_search=null==this.options.group_search||this.options.group_search,this.search_contains=this.options.search_contains||!1,this.single_backstroke_delete=null==this.options.single_backstroke_delete||this.options.single_backstroke_delete,this.max_selected_options=this.options.max_selected_options||Infinity,this.inherit_select_classes=this.options.inherit_select_classes||!1,this.display_selected_options=null==this.options.display_selected_options||this.options.display_selected_options,this.display_disabled_options=null==this.options.display_disabled_options||this.options.display_disabled_options,this.include_group_label_in_selected=this.options.include_group_label_in_selected||!1,this.max_shown_results=this.options.max_shown_results||Number.POSITIVE_INFINITY,this.case_sensitive_search=this.options.case_sensitive_search||!1,this.hide_results_on_select=null==this.options.hide_results_on_select||this.options.hide_results_on_select},n.prototype.set_default_text=function(){return this.default_text=this.form_field.getAttribute("data-placeholder")?this.form_field.getAttribute("data-placeholder"):this.is_multiple?this.options.placeholder_text_multiple||this.options.placeholder_text||n.default_multiple_text:this.options.placeholder_text_single||this.options.placeholder_text||n.default_single_text,this.default_text=this.escape_html(this.default_text),this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||n.default_no_result_text},n.prototype.choice_label=function(n){return this.include_group_label_in_selected&&null!=n.group_label?"<b class='group-name'>"+n.group_label+"<\/b>"+n.html:n.html},n.prototype.mouse_enter=function(){return this.mouse_on_container=!0},n.prototype.mouse_leave=function(){return this.mouse_on_container=!1},n.prototype.input_focus=function(){if(this.is_multiple){if(!this.active_field)return setTimeout(function(n){return function(){return n.container_mousedown()}}(this),50)}else if(!this.active_field)return this.activate_field()},n.prototype.input_blur=function(){if(!this.mouse_on_container)return this.active_field=!1,setTimeout(function(n){return function(){return n.blur_test()}}(this),100)},n.prototype.label_click_handler=function(n){return this.is_multiple?this.container_mousedown(n):this.activate_field()},n.prototype.results_option_build=function(n){var r,t,u,i,e,o,f;for(r="",f=0,i=0,e=(o=this.results_data).length;i<e&&(t=o[i],u="",""!==(u=t.group?this.result_add_group(t):this.result_add_option(t))&&(f++,r+=u),(null!=n?n.first:void 0)&&(t.selected&&this.is_multiple?this.choice_build(t):t.selected&&!this.is_multiple&&this.single_set_selected_text(this.choice_label(t))),!(f>=this.max_shown_results));i++);return r},n.prototype.result_add_option=function(n){var t,i;return n.search_match&&this.include_option_in_results(n)?(t=[],n.disabled||n.selected&&this.is_multiple||t.push("active-result"),!n.disabled||n.selected&&this.is_multiple||t.push("disabled-result"),n.selected&&t.push("result-selected"),null!=n.group_array_index&&t.push("group-option"),""!==n.classes&&t.push(n.classes),i=document.createElement("li"),i.className=t.join(" "),i.style.cssText=n.style,i.setAttribute("data-option-array-index",n.array_index),i.innerHTML=n.highlighted_html||n.html,n.title&&(i.title=n.title),this.outerHTML(i)):""},n.prototype.result_add_group=function(n){var i,t;return(n.search_match||n.group_match)&&n.active_options>0?((i=[]).push("group-result"),n.classes&&i.push(n.classes),t=document.createElement("li"),t.className=i.join(" "),t.innerHTML=n.highlighted_html||this.escape_html(n.label),n.title&&(t.title=n.title),this.outerHTML(t)):""},n.prototype.results_update_field=function(){if(this.set_default_text(),this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.results_build(),this.results_showing)return this.winnow_results()},n.prototype.reset_single_select_options=function(){var n,i,r,u,t;for(t=[],n=0,i=(r=this.results_data).length;n<i;n++)(u=r[n]).selected?t.push(u.selected=!1):t.push(void 0);return t},n.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},n.prototype.results_search=function(){return this.results_showing?this.winnow_results():this.results_show()},n.prototype.winnow_results=function(){var s,h,f,c,n,l,t,a,v,e,i,o,r,y,u;for(this.no_results_clear(),e=0,s=(t=this.get_search_text()).replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),v=this.get_search_regex(s),f=0,c=(a=this.results_data).length;f<c;f++)(n=a[f]).search_match=!1,i=null,o=null,n.highlighted_html="",this.include_option_in_results(n)&&(n.group&&(n.group_match=!1,n.active_options=0),null!=n.group_array_index&&this.results_data[n.group_array_index]&&(0===(i=this.results_data[n.group_array_index]).active_options&&i.search_match&&(e+=1),i.active_options+=1),u=n.group?n.label:n.text,n.group&&!this.group_search||(o=this.search_string_match(u,v),n.search_match=null!=o,n.search_match&&!n.group&&(e+=1),n.search_match?(t.length&&(r=o.index,l=u.slice(0,r),h=u.slice(r,r+t.length),y=u.slice(r+t.length),n.highlighted_html=this.escape_html(l)+"<em>"+this.escape_html(h)+"<\/em>"+this.escape_html(y)),null!=i&&(i.group_match=!0)):null!=n.group_array_index&&this.results_data[n.group_array_index].search_match&&(n.search_match=!0)));return this.result_clear_highlight(),e<1&&t.length?(this.update_results_content(""),this.no_results(t)):(this.update_results_content(this.results_option_build()),this.winnow_results_set_highlight())},n.prototype.get_search_regex=function(n){var i,t;return t=this.search_contains?n:"(^|\\s|\\b)"+n+"[^\\s]*",this.enable_split_word_search||this.search_contains||(t="^"+t),i=this.case_sensitive_search?"":"i",new RegExp(t,i)},n.prototype.search_string_match=function(n,t){var i;return i=t.exec(n),!this.search_contains&&(null!=i?i[1]:void 0)&&(i.index+=1),i},n.prototype.choices_count=function(){var n,t,i;if(null!=this.selected_option_count)return this.selected_option_count;for(this.selected_option_count=0,n=0,t=(i=this.form_field.options).length;n<t;n++)i[n].selected&&(this.selected_option_count+=1);return this.selected_option_count},n.prototype.choices_click=function(n){if(n.preventDefault(),this.activate_field(),!this.results_showing&&!this.is_disabled)return this.results_show()},n.prototype.keydown_checker=function(n){var i,t;switch(t=null!=(i=n.which)?i:n.keyCode,this.search_field_scale(),8!==t&&this.pending_backstroke&&this.clear_backstroke(),t){case 8:this.backstroke_length=this.get_search_field_value().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(n);this.mouse_on_container=!1;break;case 13:case 27:this.results_showing&&n.preventDefault();break;case 32:this.disable_search&&n.preventDefault();break;case 38:n.preventDefault();this.keyup_arrow();break;case 40:n.preventDefault();this.keydown_arrow()}},n.prototype.keyup_checker=function(n){var t,i;switch(i=null!=(t=n.which)?t:n.keyCode,this.search_field_scale(),i){case 8:this.is_multiple&&this.backstroke_length<1&&this.choices_count()>0?this.keydown_backstroke():this.pending_backstroke||(this.result_clear_highlight(),this.results_search());break;case 13:n.preventDefault();this.results_showing&&this.result_select(n);break;case 27:this.results_showing&&this.results_hide();break;case 9:case 16:case 17:case 18:case 38:case 40:case 91:break;default:this.results_search()}},n.prototype.clipboard_event_checker=function(){if(!this.is_disabled)return setTimeout(function(n){return function(){return n.results_search()}}(this),50)},n.prototype.container_width=function(){return null!=this.options.width?this.options.width:this.form_field.offsetWidth+"px"},n.prototype.include_option_in_results=function(n){return!(this.is_multiple&&!this.display_selected_options&&n.selected)&&!(!this.display_disabled_options&&n.disabled)&&!n.empty},n.prototype.search_results_touchstart=function(n){return this.touch_started=!0,this.search_results_mouseover(n)},n.prototype.search_results_touchmove=function(n){return this.touch_started=!1,this.search_results_mouseout(n)},n.prototype.search_results_touchend=function(n){if(this.touch_started)return this.search_results_mouseup(n)},n.prototype.outerHTML=function(n){var t;return n.outerHTML?n.outerHTML:((t=document.createElement("div")).appendChild(n),t.innerHTML)},n.prototype.get_single_html=function(){return'<a class="chosen-single chosen-default">\n  <input class="chosen-search-input" type="text" autocomplete="off" />\n  <span>'+this.default_text+'<\/span>\n  <div><b><\/b><\/div>\n<\/a>\n<div class="chosen-drop">\n  <div class="chosen-search">\n  <\/div>\n  <ul class="chosen-results"><\/ul>\n<\/div>'},n.prototype.get_multi_html=function(){return'<ul class="chosen-choices">\n  <li class="search-field">\n    <input class="chosen-search-input" type="text" autocomplete="off" value="'+this.default_text+'" />\n  <\/li>\n<\/ul>\n<div class="chosen-drop">\n  <ul class="chosen-results"><\/ul>\n<\/div>'},n.prototype.get_no_results_html=function(n){return'<li class="no-results">\n  '+this.results_none_found+" <span>"+this.escape_html(n)+"<\/span>\n<\/li>"},n.browser_is_supported=function(){return"Microsoft Internet Explorer"===window.navigator.appName?document.documentMode>=8:!(/iP(od|hone)/i.test(window.navigator.userAgent)||/IEMobile/i.test(window.navigator.userAgent)||/Windows Phone/i.test(window.navigator.userAgent)||/BlackBerry/i.test(window.navigator.userAgent)||/BB10/i.test(window.navigator.userAgent)||/Android.*Mobile/i.test(window.navigator.userAgent))},n.default_multiple_text="Select Some Options",n.default_single_text="Select an Option",n.default_no_result_text="No results match",n}();(n=jQuery).fn.extend({chosen:function(r){return i.browser_is_supported()?this.each(function(){var u,i;i=(u=n(this)).data("chosen");"destroy"!==r?i instanceof t||u.data("chosen",new t(this,r)):i instanceof t&&i.destroy()}):this}});t=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return f(t,i),t.prototype.setup=function(){return this.form_field_jq=n(this.form_field),this.current_selectedIndex=this.form_field.selectedIndex},t.prototype.set_up_html=function(){var t,i;return(t=["chosen-container"]).push("chosen-container-"+(this.is_multiple?"multi":"single")),this.inherit_select_classes&&this.form_field.className&&t.push(this.form_field.className),this.is_rtl&&t.push("chosen-rtl"),i={"class":t.join(" "),title:this.form_field.title},this.form_field.id.length&&(i.id=this.form_field.id.replace(/[^\w]/g,"_")+"_chosen"),this.container=n("<div />",i),this.container.width(this.container_width()),this.is_multiple?this.container.html(this.get_multi_html()):this.container.html(this.get_single_html()),this.form_field_jq.hide().after(this.container),this.dropdown=this.container.find("div.chosen-drop").first(),this.search_field=this.container.find("input").first(),this.search_results=this.container.find("ul.chosen-results").first(),this.search_field_scale(),this.search_no_results=this.container.find("li.no-results").first(),this.is_multiple?(this.search_choices=this.container.find("ul.chosen-choices").first(),this.search_container=this.container.find("li.search-field").first()):(this.search_container=this.container.find("div.chosen-search").first(),this.selected_item=this.container.find(".chosen-single").first()),this.results_build(),this.set_tab_index(),this.set_label_behavior()},t.prototype.on_ready=function(){return this.form_field_jq.trigger("chosen:ready",{chosen:this})},t.prototype.register_observers=function(){return this.container.on("touchstart.chosen",function(n){return function(t){n.container_mousedown(t)}}(this)),this.container.on("touchend.chosen",function(n){return function(t){n.container_mouseup(t)}}(this)),this.container.on("mousedown.chosen",function(n){return function(t){n.container_mousedown(t)}}(this)),this.container.on("mouseup.chosen",function(n){return function(t){n.container_mouseup(t)}}(this)),this.container.on("mouseenter.chosen",function(n){return function(t){n.mouse_enter(t)}}(this)),this.container.on("mouseleave.chosen",function(n){return function(t){n.mouse_leave(t)}}(this)),this.search_results.on("mouseup.chosen",function(n){return function(t){n.search_results_mouseup(t)}}(this)),this.search_results.on("mouseover.chosen",function(n){return function(t){n.search_results_mouseover(t)}}(this)),this.search_results.on("mouseout.chosen",function(n){return function(t){n.search_results_mouseout(t)}}(this)),this.search_results.on("mousewheel.chosen DOMMouseScroll.chosen",function(n){return function(t){n.search_results_mousewheel(t)}}(this)),this.search_results.on("touchstart.chosen",function(n){return function(t){n.search_results_touchstart(t)}}(this)),this.search_results.on("touchmove.chosen",function(n){return function(t){n.search_results_touchmove(t)}}(this)),this.search_results.on("touchend.chosen",function(n){return function(t){n.search_results_touchend(t)}}(this)),this.form_field_jq.on("chosen:updated.chosen",function(n){return function(t){n.results_update_field(t)}}(this)),this.form_field_jq.on("chosen:activate.chosen",function(n){return function(t){n.activate_field(t)}}(this)),this.form_field_jq.on("chosen:open.chosen",function(n){return function(t){n.container_mousedown(t)}}(this)),this.form_field_jq.on("chosen:close.chosen",function(n){return function(t){n.close_field(t)}}(this)),this.search_field.on("blur.chosen",function(n){return function(t){n.input_blur(t)}}(this)),this.search_field.on("keyup.chosen",function(n){return function(t){n.keyup_checker(t)}}(this)),this.search_field.on("keydown.chosen",function(n){return function(t){n.keydown_checker(t)}}(this)),this.search_field.on("focus.chosen",function(n){return function(t){n.input_focus(t)}}(this)),this.search_field.on("cut.chosen",function(n){return function(t){n.clipboard_event_checker(t)}}(this)),this.search_field.on("paste.chosen",function(n){return function(t){n.clipboard_event_checker(t)}}(this)),this.is_multiple?this.search_choices.on("click.chosen",function(n){return function(t){n.choices_click(t)}}(this)):this.container.on("click.chosen",function(n){n.preventDefault()})},t.prototype.destroy=function(){return n(this.container[0].ownerDocument).off("click.chosen",this.click_test_action),this.form_field_label.length>0&&this.form_field_label.off("click.chosen"),this.search_field[0].tabIndex&&(this.form_field_jq[0].tabIndex=this.search_field[0].tabIndex),this.container.remove(),this.form_field_jq.removeData("chosen"),this.form_field_jq.show()},t.prototype.search_field_disabled=function(){return this.is_disabled=this.form_field.disabled||this.form_field_jq.parents("fieldset").is(":disabled"),this.container.toggleClass("chosen-disabled",this.is_disabled),this.search_field[0].disabled=this.is_disabled,this.is_multiple||this.selected_item.off("focus.chosen",this.activate_field),this.is_disabled?this.close_field():this.is_multiple?void 0:this.selected_item.on("focus.chosen",this.activate_field)},t.prototype.container_mousedown=function(t){var i;if(!this.is_disabled)return!t||"mousedown"!==(i=t.type)&&"touchstart"!==i||this.results_showing||t.preventDefault(),null!=t&&n(t.target).hasClass("search-choice-close")?void 0:(this.active_field?this.is_multiple||!t||n(t.target)[0]!==this.selected_item[0]&&!n(t.target).parents("a.chosen-single").length||(t.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),n(this.container[0].ownerDocument).on("click.chosen",this.click_test_action),this.results_show()),this.activate_field())},t.prototype.container_mouseup=function(n){if("ABBR"===n.target.nodeName&&!this.is_disabled)return this.results_reset(n)},t.prototype.search_results_mousewheel=function(n){var t;if(n.originalEvent&&(t=n.originalEvent.deltaY||-n.originalEvent.wheelDelta||n.originalEvent.detail),null!=t)return n.preventDefault(),"DOMMouseScroll"===n.type&&(t*=40),this.search_results.scrollTop(t+this.search_results.scrollTop())},t.prototype.blur_test=function(){if(!this.active_field&&this.container.hasClass("chosen-container-active"))return this.close_field()},t.prototype.close_field=function(){return n(this.container[0].ownerDocument).off("click.chosen",this.click_test_action),this.active_field=!1,this.results_hide(),this.container.removeClass("chosen-container-active"),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale(),this.search_field.blur()},t.prototype.activate_field=function(){if(!this.is_disabled)return this.container.addClass("chosen-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.focus()},t.prototype.test_active_click=function(t){var i;return(i=n(t.target).closest(".chosen-container")).length&&this.container[0]===i[0]?this.active_field=!0:this.close_field()},t.prototype.results_build=function(){return this.parsing=!0,this.selected_option_count=null,this.results_data=r.select_to_array(this.form_field),this.is_multiple?this.search_choices.find("li.search-choice").remove():this.is_multiple||(this.single_set_selected_text(),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?(this.search_field[0].readOnly=!0,this.container.addClass("chosen-container-single-nosearch")):(this.search_field[0].readOnly=!1,this.container.removeClass("chosen-container-single-nosearch"))),this.update_results_content(this.results_option_build({first:!0})),this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.parsing=!1},t.prototype.result_do_highlight=function(n){var r,t,i,f,u;if(n.length){if(this.result_clear_highlight(),this.result_highlight=n,this.result_highlight.addClass("highlighted"),i=parseInt(this.search_results.css("maxHeight"),10),u=this.search_results.scrollTop(),f=i+u,t=this.result_highlight.position().top+this.search_results.scrollTop(),(r=t+this.result_highlight.outerHeight())>=f)return this.search_results.scrollTop(r-i>0?r-i:0);if(t<u)return this.search_results.scrollTop(t)}},t.prototype.result_clear_highlight=function(){return this.result_highlight&&this.result_highlight.removeClass("highlighted"),this.result_highlight=null},t.prototype.results_show=function(){return this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.is_multiple||this.search_container.append(this.search_field),this.container.addClass("chosen-with-drop"),this.results_showing=!0,this.search_field.focus(),this.search_field.val(this.get_search_field_value()),this.winnow_results(),this.form_field_jq.trigger("chosen:showing_dropdown",{chosen:this}))},t.prototype.update_results_content=function(n){return this.search_results.html(n)},t.prototype.results_hide=function(){return this.results_showing&&(this.result_clear_highlight(),this.is_multiple||(this.selected_item.prepend(this.search_field),this.search_field.focus()),this.container.removeClass("chosen-with-drop"),this.form_field_jq.trigger("chosen:hiding_dropdown",{chosen:this})),this.results_showing=!1},t.prototype.set_tab_index=function(){var n;if(this.form_field.tabIndex)return n=this.form_field.tabIndex,this.form_field.tabIndex=-1,this.search_field[0].tabIndex=n},t.prototype.set_label_behavior=function(){if(this.form_field_label=this.form_field_jq.parents("label"),!this.form_field_label.length&&this.form_field.id.length&&(this.form_field_label=n("label[for='"+this.form_field.id+"']")),this.form_field_label.length>0)return this.form_field_label.on("click.chosen",this.label_click_handler)},t.prototype.show_search_field_default=function(){return this.is_multiple&&this.choices_count()<1&&!this.active_field?(this.search_field.val(this.default_text),this.search_field.addClass("default")):(this.search_field.val(""),this.search_field.removeClass("default"))},t.prototype.search_results_mouseup=function(t){var i;if((i=n(t.target).hasClass("active-result")?n(t.target):n(t.target).parents(".active-result").first()).length)return this.result_highlight=i,this.result_select(t),this.search_field.focus()},t.prototype.search_results_mouseover=function(t){var i;if(i=n(t.target).hasClass("active-result")?n(t.target):n(t.target).parents(".active-result").first())return this.result_do_highlight(i)},t.prototype.search_results_mouseout=function(t){if(n(t.target).hasClass("active-result")||n(t.target).parents(".active-result").first())return this.result_clear_highlight()},t.prototype.choice_build=function(t){var i,r;return i=n("<li />",{"class":"search-choice"}).html("<span>"+this.choice_label(t)+"<\/span>"),t.disabled?i.addClass("search-choice-disabled"):((r=n("<a />",{"class":"search-choice-close","data-option-array-index":t.array_index})).on("click.chosen",function(n){return function(t){return n.choice_destroy_link_click(t)}}(this)),i.append(r)),this.search_container.before(i)},t.prototype.choice_destroy_link_click=function(t){if(t.preventDefault(),t.stopPropagation(),!this.is_disabled)return this.choice_destroy(n(t.target))},t.prototype.choice_destroy=function(n){if(this.result_deselect(n[0].getAttribute("data-option-array-index")))return this.active_field?this.search_field.focus():this.show_search_field_default(),this.is_multiple&&this.choices_count()>0&&this.get_search_field_value().length<1&&this.results_hide(),n.parents("li").first().remove(),this.search_field_scale()},t.prototype.results_reset=function(){if(this.reset_single_select_options(),this.form_field.options[0].selected=!0,this.single_set_selected_text(),this.show_search_field_default(),this.results_reset_cleanup(),this.trigger_form_field_change(),this.active_field)return this.results_hide()},t.prototype.results_reset_cleanup=function(){return this.current_selectedIndex=this.form_field.selectedIndex,this.selected_item.find("abbr").remove()},t.prototype.result_select=function(n){var i,t;if(this.result_highlight)return i=this.result_highlight,this.result_clear_highlight(),this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.is_multiple?i.removeClass("active-result"):this.reset_single_select_options(),i.addClass("result-selected"),t=this.results_data[i[0].getAttribute("data-option-array-index")],t.selected=!0,this.form_field.options[t.options_index].selected=!0,this.selected_option_count=null,this.search_field.val(""),this.is_multiple?this.choice_build(t):this.single_set_selected_text(this.choice_label(t)),this.is_multiple&&(!this.hide_results_on_select||n.metaKey||n.ctrlKey)?this.winnow_results():(this.results_hide(),this.show_search_field_default()),(this.is_multiple||this.form_field.selectedIndex!==this.current_selectedIndex)&&this.trigger_form_field_change({selected:this.form_field.options[t.options_index].value}),this.current_selectedIndex=this.form_field.selectedIndex,n.preventDefault(),this.search_field_scale())},t.prototype.single_set_selected_text=function(n){return null==n&&(n=this.default_text),n===this.default_text?this.selected_item.addClass("chosen-default"):(this.single_deselect_control_build(),this.selected_item.removeClass("chosen-default")),this.selected_item.find("span").html(n)},t.prototype.result_deselect=function(n){var t;return t=this.results_data[n],!this.form_field.options[t.options_index].disabled&&(t.selected=!1,this.form_field.options[t.options_index].selected=!1,this.selected_option_count=null,this.result_clear_highlight(),this.results_showing&&this.winnow_results(),this.trigger_form_field_change({deselected:this.form_field.options[t.options_index].value}),this.search_field_scale(),!0)},t.prototype.single_deselect_control_build=function(){if(this.allow_single_deselect)return this.selected_item.find("abbr").length||this.selected_item.find("span").first().after('<abbr class="search-choice-close"><\/abbr>'),this.selected_item.addClass("chosen-single-with-deselect")},t.prototype.get_search_field_value=function(){return this.search_field.val()},t.prototype.get_search_text=function(){return n.trim(this.get_search_field_value())},t.prototype.escape_html=function(t){return n("<div/>").text(t).html()},t.prototype.winnow_results_set_highlight=function(){var t,n;if(n=this.is_multiple?[]:this.search_results.find(".result-selected.active-result"),null!=(t=n.length?n.first():this.search_results.find(".active-result").first()))return this.result_do_highlight(t)},t.prototype.no_results=function(n){var t;return t=this.get_no_results_html(n),this.search_results.append(t),this.form_field_jq.trigger("chosen:no_results",{chosen:this})},t.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},t.prototype.keydown_arrow=function(){var n;return this.results_showing&&this.result_highlight?(n=this.result_highlight.nextAll("li.active-result").first())?this.result_do_highlight(n):void 0:this.results_show()},t.prototype.keyup_arrow=function(){var n;return this.results_showing||this.is_multiple?this.result_highlight?(n=this.result_highlight.prevAll("li.active-result")).length?this.result_do_highlight(n.first()):(this.choices_count()>0&&this.results_hide(),this.result_clear_highlight()):void 0:this.results_show()},t.prototype.keydown_backstroke=function(){var n;return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.find("a").first()),this.clear_backstroke()):(n=this.search_container.siblings("li.search-choice").last()).length&&!n.hasClass("search-choice-disabled")?(this.pending_backstroke=n,this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClass("search-choice-focus")):void 0},t.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),this.pending_backstroke=null},t.prototype.search_field_scale=function(){var t,i,f,e,u,o,r;if(this.is_multiple){for(u={position:"absolute",left:"-1000px",top:"-1000px",display:"none",whiteSpace:"pre"},i=0,f=(o=["fontSize","fontStyle","fontWeight","fontFamily","lineHeight","textTransform","letterSpacing"]).length;i<f;i++)u[e=o[i]]=this.search_field.css(e);return(t=n("<div />").css(u)).text(this.get_search_field_value()),n("body").append(t),r=t.width()+25,t.remove(),this.container.is(":visible")&&(r=Math.min(this.container.outerWidth()-10,r)),this.search_field.width(r)}},t.prototype.trigger_form_field_change=function(n){return this.form_field_jq.trigger("input",n),this.form_field_jq.trigger("change",n)},t}()}).call(this)