text: !function(t,e){"function"==typeof define&&define.amd?define("sifter",e):"object"==typeof exports?module.exports=e():t.Sifter=e()}(this,(function(){var t=function(t,e){this.items=t,this.settings=e||{diacritics:!0}};t.prototype.tokenize=function(t){if(!(t=s(String(t||"").toLowerCase()))||!t.length)return[];var e,i,n,r,l=[],h=t.split(/ +/);for(e=0,i=h.length;e<i;e++){if(n=o(h[e]),this.settings.diacritics)for(r in a)a.hasOwnProperty(r)&&(n=n.replace(new RegExp(r,"g"),a[r]));l.push({string:h[e],regex:new RegExp(n,"i")})}return l},t.prototype.iterator=function(t,e){(r(t)?Array.prototype.forEach||function(t){for(var e=0,i=this.length;e<i;e++)t(this[e],e,this)}:function(t){for(var e in this)this.hasOwnProperty(e)&&t(this[e],e,this)}).apply(t,[e])},t.prototype.getScoreFunction=function(t,e){var i,s,o,r;t=this.prepareSearch(t,e),s=t.tokens,i=t.options.fields,o=s.length,r=t.options.nesting;var a,l=function(t,e){var i,n;return t?-1===(n=(t=String(t||"")).search(e.regex))?0:(i=e.string.length/t.length,0===n&&(i+=.5),i):0},h=(a=i.length)?1===a?function(t,e){return l(n(e,i[0],r),t)}:function(t,e){for(var s=0,o=0;s<a;s++)o+=l(n(e,i[s],r),t);return o/a}:function(){return 0};return o?1===o?function(t){return h(s[0],t)}:"and"===t.options.conjunction?function(t){for(var e,i=0,n=0;i<o;i++){if((e=h(s[i],t))<=0)return 0;n+=e}return n/o}:function(t){for(var e=0,i=0;e<o;e++)i+=h(s[e],t);return i/o}:function(){return 0}},t.prototype.getSortFunction=function(t,i){var s,o,r,a,l,h,p,u,c,d,g;if(g=!(t=(r=this).prepareSearch(t,i)).query&&i.sort_empty||i.sort,c=function(t,e){return"$score"===t?e.score:n(r.items[e.id],t,i.nesting)},l=[],g)for(s=0,o=g.length;s<o;s++)(t.query||"$score"!==g[s].field)&&l.push(g[s]);if(t.query){for(d=!0,s=0,o=l.length;s<o;s++)if("$score"===l[s].field){d=!1;break}d&&l.unshift({field:"$score",direction:"desc"})}else for(s=0,o=l.length;s<o;s++)if("$score"===l[s].field){l.splice(s,1);break}for(u=[],s=0,o=l.length;s<o;s++)u.push("desc"===l[s].direction?-1:1);return(h=l.length)?1===h?(a=l[0].field,p=u[0],function(t,i){return p*e(c(a,t),c(a,i))}):function(t,i){var n,s,o;for(n=0;n<h;n++)if(o=l[n].field,s=u[n]*e(c(o,t),c(o,i)))return s;return 0}:null},t.prototype.prepareSearch=function(t,e){if("object"==typeof t)return t;var n=(e=i({},e)).fields,s=e.sort,o=e.sort_empty;return n&&!r(n)&&(e.fields=[n]),s&&!r(s)&&(e.sort=[s]),o&&!r(o)&&(e.sort_empty=[o]),{options:e,query:String(t||"").toLowerCase(),tokens:this.tokenize(t),total:0,items:[]}},t.prototype.search=function(t,e){var i,n,s,o;return n=this.prepareSearch(t,e),e=n.options,t=n.query,o=e.score||this.getScoreFunction(n),t.length?this.iterator(this.items,(function(t,s){i=o(t),(!1===e.filter||i>0)&&n.items.push({score:i,id:s})})):this.iterator(this.items,(function(t,e){n.items.push({score:1,id:e})})),(s=this.getSortFunction(n,e))&&n.items.sort(s),n.total=n.items.length,"number"==typeof e.limit&&(n.items=n.items.slice(0,e.limit)),n};var e=function(t,e){return"number"==typeof t&&"number"==typeof e?t>e?1:t<e?-1:0:(t=l(String(t||"")))>(e=l(String(e||"")))?1:e>t?-1:0},i=function(t,e){var i,n,s,o;for(i=1,n=arguments.length;i<n;i++)if(o=arguments[i])for(s in o)o.hasOwnProperty(s)&&(t[s]=o[s]);return t},n=function(t,e,i){if(t&&e){if(!i)return t[e];for(var n=e.split(".");n.length&&(t=t[n.shift()]););return t}},s=function(t){return(t+"").replace(/^\s+|\s+$|/g,"")},o=function(t){return(t+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")},r=Array.isArray||"undefined"!=typeof $&&$.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},a={a:"[aḀḁĂăÂâǍǎȺⱥȦȧẠạÄäÀàÁáĀāÃãÅåąĄÃąĄ]",b:"[b␢βΒB฿𐌁ᛒ]",c:"[cĆćĈĉČčĊċC̄c̄ÇçḈḉȻȼƇƈɕᴄＣｃ]",d:"[dĎďḊḋḐḑḌḍḒḓḎḏĐđD̦d̦ƉɖƊɗƋƌᵭᶁᶑȡᴅＤｄð]",e:"[eÉéÈèÊêḘḙĚěĔĕẼẽḚḛẺẻĖėËëĒēȨȩĘęᶒɆɇȄȅẾếỀềỄễỂểḜḝḖḗḔḕȆȇẸẹỆệⱸᴇＥｅɘǝƏƐε]",f:"[fƑƒḞḟ]",g:"[gɢ₲ǤǥĜĝĞğĢģƓɠĠġ]",h:"[hĤĥĦħḨḩẖẖḤḥḢḣɦʰǶƕ]",i:"[iÍíÌìĬĭÎîǏǐÏïḮḯĨĩĮįĪīỈỉȈȉȊȋỊịḬḭƗɨɨ̆ᵻᶖİiIıɪＩｉ]",j:"[jȷĴĵɈɉʝɟʲ]",k:"[kƘƙꝀꝁḰḱǨǩḲḳḴḵκϰ₭]",l:"[lŁłĽľĻļĹĺḶḷḸḹḼḽḺḻĿŀȽƚⱠⱡⱢɫɬᶅɭȴʟＬｌ]",n:"[nŃńǸǹŇňÑñṄṅŅņṆṇṊṋṈṉN̈n̈ƝɲȠƞᵰᶇɳȵɴＮｎŊŋ]",o:"[oØøÖöÓóÒòÔôǑǒŐőŎŏȮȯỌọƟɵƠơỎỏŌōÕõǪǫȌȍՕօ]",p:"[pṔṕṖṗⱣᵽƤƥᵱ]",q:"[qꝖꝗʠɊɋꝘꝙq̃]",r:"[rŔŕɌɍŘřŖŗṘṙȐȑȒȓṚṛⱤɽ]",s:"[sŚśṠṡṢṣꞨꞩŜŝŠšŞşȘșS̈s̈]",t:"[tŤťṪṫŢţṬṭƮʈȚțṰṱṮṯƬƭ]",u:"[uŬŭɄʉỤụÜüÚúÙùÛûǓǔŰűŬŭƯưỦủŪūŨũŲųȔȕ∪]",v:"[vṼṽṾṿƲʋꝞꝟⱱʋ]",w:"[wẂẃẀẁŴŵẄẅẆẇẈẉ]",x:"[xẌẍẊẋχ]",y:"[yÝýỲỳŶŷŸÿỸỹẎẏỴỵɎɏƳƴ]",z:"[zŹźẐẑŽžŻżẒẓẔẕƵƶ]"},l=function(){var t,e,i,n,s="",o={};for(i in a)if(a.hasOwnProperty(i))for(s+=n=a[i].substring(2,a[i].length-1),t=0,e=n.length;t<e;t++)o[n.charAt(t)]=i;var r=new RegExp("["+s+"]","g");return function(t){return t.replace(r,(function(t){return o[t]})).toLowerCase()}}();return t})),function(t,e){"function"==typeof define&&define.amd?define("microplugin",e):"object"==typeof exports?module.exports=e():t.MicroPlugin=e()}(this,(function(){var t={mixin:function(t){t.plugins={},t.prototype.initializePlugins=function(t){var i,n,s,o=[];if(this.plugins={names:[],settings:{},requested:{},loaded:{}},e.isArray(t))for(i=0,n=t.length;i<n;i++)"string"==typeof t[i]?o.push(t[i]):(this.plugins.settings[t[i].name]=t[i].options,o.push(t[i].name));else if(t)for(s in t)t.hasOwnProperty(s)&&(this.plugins.settings[s]=t[s],o.push(s));for(;o.length;)this.require(o.shift())},t.prototype.loadPlugin=function(e){var i=this.plugins,n=t.plugins[e];if(!t.plugins.hasOwnProperty(e))throw new Error('Unable to find "'+e+'" plugin');i.requested[e]=!0,i.loaded[e]=n.fn.apply(this,[this.plugins.settings[e]||{}]),i.names.push(e)},t.prototype.require=function(t){var e=this.plugins;if(!this.plugins.loaded.hasOwnProperty(t)){if(e.requested[t])throw new Error('Plugin has circular dependency ("'+t+'")');this.loadPlugin(t)}return e.loaded[t]},t.define=function(e,i){t.plugins[e]={name:e,fn:i}}}},e={isArray:Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}};return t})),function(t,e){"function"==typeof define&&define.amd?define("selectize",["jquery","sifter","microplugin"],e):"object"==typeof exports?module.exports=e(require("jquery"),require("sifter"),require("microplugin")):t.Selectize=e(t.jQuery,t.Sifter,t.MicroPlugin)}(this,(function(t,e,i){"use strict";var n=function(t,e){if("string"!=typeof e||e.length){var i="string"==typeof e?new RegExp(e,"i"):e,n=function(t){var e=0;if(3===t.nodeType){var s=t.data.search(i);if(s>=0&&t.data.length>0){var o=t.data.match(i),r=document.createElement("span");r.className="highlight";var a=t.splitText(s),l=(a.splitText(o[0].length),a.cloneNode(!0));r.appendChild(l),a.parentNode.replaceChild(r,a),e=1}}else if(1===t.nodeType&&t.childNodes&&!/(script|style)/i.test(t.tagName)&&("highlight"!==t.className||"SPAN"!==t.tagName))for(var h=0;h<t.childNodes.length;++h)h+=n(t.childNodes[h]);return e};return t.each((function(){n(this)}))}};t.fn.removeHighlight=function(){return this.find("span.highlight").each((function(){this.parentNode.firstChild.nodeName;var t=this.parentNode;t.replaceChild(this.firstChild,this),t.normalize()})).end()};var s=function(){};s.prototype={on:function(t,e){this._events=this._events||{},this._events[t]=this._events[t]||[],this._events[t].push(e)},off:function(t,e){var i=arguments.length;return 0===i?delete this._events:1===i?delete this._events[t]:(this._events=this._events||{},void(t in this._events!=!1&&this._events[t].splice(this._events[t].indexOf(e),1)))},trigger:function(t){if(this._events=this._events||{},t in this._events!=!1)for(var e=0;e<this._events[t].length;e++)this._events[t][e].apply(this,Array.prototype.slice.call(arguments,1))}},s.mixin=function(t){for(var e=["on","off","trigger"],i=0;i<e.length;i++)t.prototype[e[i]]=s.prototype[e[i]]};var o=/Mac/.test(navigator.userAgent),r=o?91:17,a=o?18:17,l=!/android/i.test(window.navigator.userAgent)&&!!document.createElement("input").validity,h=function(t){return void 0!==t},p=function(t){return null==t?null:"boolean"==typeof t?t?"1":"0":t+""},u=function(t){return(t+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},c={before:function(t,e,i){var n=t[e];t[e]=function(){return i.apply(t,arguments),n.apply(t,arguments)}},after:function(t,e,i){var n=t[e];t[e]=function(){var e=n.apply(t,arguments);return i.apply(t,arguments),e}}},d=function(t){var e=!1;return function(){e||(e=!0,t.apply(this,arguments))}},g=function(t,e,i){var n,s=t.trigger,o={};for(n in t.trigger=function(){var i=arguments[0];if(-1===e.indexOf(i))return s.apply(t,arguments);o[i]=arguments},i.apply(t,[]),t.trigger=s,o)o.hasOwnProperty(n)&&s.apply(t,o[n])},f=function(t){var e={};if("selectionStart"in t)e.start=t.selectionStart,e.length=t.selectionEnd-e.start;else if(document.selection){t.focus();var i=document.selection.createRange(),n=document.selection.createRange().text.length;i.moveStart("character",-t.value.length),e.start=i.text.length-n,e.length=n}return e},v=function(e){var i=null,n=function(n,s){var o,r,a,l,h,p,u,c,d,g;(s=s||{},(n=n||window.event||{}).metaKey||n.altKey)||(s.force||!1!==e.data("grow"))&&(o=e.val(),n.type&&"keydown"===n.type.toLowerCase()&&(a=(r=n.keyCode)>=48&&r<=57||r>=65&&r<=90||r>=96&&r<=111||r>=186&&r<=222||32===r,46===r||8===r?(c=f(e[0])).length?o=o.substring(0,c.start)+o.substring(c.start+c.length):8===r&&c.start?o=o.substring(0,c.start-1)+o.substring(c.start+1):46===r&&void 0!==c.start&&(o=o.substring(0,c.start)+o.substring(c.start+1)):a&&(p=n.shiftKey,u=String.fromCharCode(n.keyCode),o+=u=p?u.toUpperCase():u.toLowerCase())),l=e.attr("placeholder"),!o&&l&&(o=l),g=e,(h=((d=o)?(m.$testInput||(m.$testInput=t("<span />").css({position:"absolute",top:-99999,left:-99999,width:"auto",padding:0,whiteSpace:"pre"}).appendTo("body")),m.$testInput.text(d),function(t,e,i){var n,s,o={};if(i)for(n=0,s=i.length;n<s;n++)o[i[n]]=t.css(i[n]);else o=t.css();e.css(o)}(g,m.$testInput,["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"]),m.$testInput.width()):0)+4)!==i&&(i=h,e.width(h),e.triggerHandler("resize")))};e.on("keydown keyup update blur",n),n()},m=function(i,n){var s,o,r,a;(a=i[0]).selectize=this;var l,h,p,u=window.getComputedStyle&&window.getComputedStyle(a,null);if(r=(r=u?u.getPropertyValue("direction"):a.currentStyle&&a.currentStyle.direction)||i.parents("[dir]:first").attr("dir")||"",t.extend(this,{order:0,settings:n,$input:i,tabIndex:i.attr("tabindex")||"",tagType:"select"===a.tagName.toLowerCase()?1:2,rtl:/rtl/i.test(r),eventNS:".selectize"+ ++m.count,highlightedValue:null,isBlurring:!1,isOpen:!1,isDisabled:!1,isRequired:i.is("[required]"),isInvalid:!1,isLocked:!1,isFocused:!1,isInputHidden:!1,isSetup:!1,isShiftDown:!1,isCmdDown:!1,isCtrlDown:!1,ignoreFocus:!1,ignoreBlur:!1,ignoreHover:!1,hasOptions:!1,currentResults:null,lastValue:"",caretPos:0,loading:0,loadedSearches:{},$activeOption:null,$activeItems:[],optgroups:{},options:{},userOptions:{},items:[],renderCache:{},onSearchChange:null===n.loadThrottle?this.onSearchChange:(l=this.onSearchChange,h=n.loadThrottle,function(){var t=this,e=arguments;window.clearTimeout(p),p=window.setTimeout((function(){l.apply(t,e)}),h)})}),this.sifter=new e(this.options,{diacritics:n.diacritics}),this.settings.options){for(s=0,o=this.settings.options.length;s<o;s++)this.registerOption(this.settings.options[s]);delete this.settings.options}if(this.settings.optgroups){for(s=0,o=this.settings.optgroups.length;s<o;s++)this.registerOptionGroup(this.settings.optgroups[s]);delete this.settings.optgroups}this.settings.mode=this.settings.mode||(1===this.settings.maxItems?"single":"multi"),"boolean"!=typeof this.settings.hideSelected&&(this.settings.hideSelected="multi"===this.settings.mode),this.initializePlugins(this.settings.plugins),this.setupCallbacks(),this.setupTemplates(),this.setup()};return s.mixin(m),void 0!==i?i.mixin(m):function(t,e){e||(e={});console.error("Selectize: "+t),e.explanation&&(console.group&&console.group(),console.error(e.explanation),console.group&&console.groupEnd())}("Dependency MicroPlugin is missing",{explanation:'Make sure you either: (1) are using the "standalone" version of Selectize, or (2) require MicroPlugin before you load Selectize.'}),t.extend(m.prototype,{setup:function(){var e,i,n,s,h,p,u,c,d,g,f,m,y,w,O=this,$=O.settings,C=O.eventNS,b=t(window),x=t(document),S=O.$input;if(u=O.settings.mode,c=S.attr("class")||"",e=t("<div>").addClass($.wrapperClass).addClass(c).addClass(u),i=t("<div>").addClass($.inputClass).addClass("items").appendTo(e),n=t('<input type="text" autocomplete="off" />').appendTo(i).attr("tabindex",S.is(":disabled")?"-1":O.tabIndex),p=t($.dropdownParent||e),s=t("<div>").addClass($.dropdownClass).addClass(u).hide().appendTo(p),h=t("<div>").addClass($.dropdownContentClass).appendTo(s),(g=S.attr("id"))&&(n.attr("id",g+"-selectized"),t("label[for='"+g+"']").attr("for",g+"-selectized")),O.settings.copyClassesToDropdown&&s.addClass(c),e.css({width:S[0].style.width}),O.plugins.names.length&&(d="plugin-"+O.plugins.names.join(" plugin-"),e.addClass(d),s.addClass(d)),(null===$.maxItems||$.maxItems>1)&&1===O.tagType&&S.attr("multiple","multiple"),O.settings.placeholder&&n.attr("placeholder",$.placeholder),!O.settings.splitOn&&O.settings.delimiter){var I=O.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");O.settings.splitOn=new RegExp("\\s*"+I+"+\\s*")}S.attr("autocorrect")&&n.attr("autocorrect",S.attr("autocorrect")),S.attr("autocapitalize")&&n.attr("autocapitalize",S.attr("autocapitalize")),n[0].type=S[0].type,O.$wrapper=e,O.$control=i,O.$control_input=n,O.$dropdown=s,O.$dropdown_content=h,s.on("mouseenter mousedown click","[data-disabled]>[data-selectable]",(function(t){t.stopImmediatePropagation()})),s.on("mouseenter","[data-selectable]",(function(){return O.onOptionHover.apply(O,arguments)})),s.on("mousedown click","[data-selectable]",(function(){return O.onOptionSelect.apply(O,arguments)})),m="mousedown",y="*:not(input)",w=function(){return O.onItemSelect.apply(O,arguments)},(f=i).on(m,y,(function(t){for(var e=t.target;e&&e.parentNode!==f[0];)e=e.parentNode;return t.currentTarget=e,w.apply(this,[t])})),v(n),i.on({mousedown:function(){return O.onMouseDown.apply(O,arguments)},click:function(){return O.onClick.apply(O,arguments)}}),n.on({mousedown:function(t){t.stopPropagation()},keydown:function(){return O.onKeyDown.apply(O,arguments)},keyup:function(){return O.onKeyUp.apply(O,arguments)},keypress:function(){return O.onKeyPress.apply(O,arguments)},resize:function(){O.positionDropdown.apply(O,[])},blur:function(){return O.onBlur.apply(O,arguments)},focus:function(){return O.ignoreBlur=!1,O.onFocus.apply(O,arguments)},paste:function(){return O.onPaste.apply(O,arguments)}}),x.on("keydown"+C,(function(t){O.isCmdDown=t[o?"metaKey":"ctrlKey"],O.isCtrlDown=t[o?"altKey":"ctrlKey"],O.isShiftDown=t.shiftKey})),x.on("keyup"+C,(function(t){t.keyCode===a&&(O.isCtrlDown=!1),16===t.keyCode&&(O.isShiftDown=!1),t.keyCode===r&&(O.isCmdDown=!1)})),x.on("mousedown"+C,(function(t){if(O.isFocused){if(t.target===O.$dropdown[0]||t.target.parentNode===O.$dropdown[0])return!1;O.$control.has(t.target).length||t.target===O.$control[0]||O.blur(t.target)}})),b.on(["scroll"+C,"resize"+C].join(" "),(function(){O.isOpen&&O.positionDropdown.apply(O,arguments)})),b.on("mousemove"+C,(function(){O.ignoreHover=!1})),this.revertSettings={$children:S.children().detach(),tabindex:S.attr("tabindex")},S.attr("tabindex",-1).hide().after(O.$wrapper),t.isArray($.items)&&(O.setValue($.items),delete $.items),l&&S.on("invalid"+C,(function(t){t.preventDefault(),O.isInvalid=!0,O.refreshState()})),O.updateOriginalInput(),O.refreshItems(),O.refreshState(),O.updatePlaceholder(),O.isSetup=!0,S.is(":disabled")&&O.disable(),O.on("change",this.onChange),S.data("selectize",O),S.addClass("selectized"),O.trigger("initialize"),!0===$.preload&&O.onSearchChange("")},setupTemplates:function(){var e=this.settings.labelField,i=this.settings.optgroupLabelField,n={optgroup:function(t){return'<div class="optgroup">'+t.html+"</div>"},optgroup_header:function(t,e){return'<div class="optgroup-header">'+e(t[i])+"</div>"},option:function(t,i){return'<div class="option">'+i(t[e])+"</div>"},item:function(t,i){return'<div class="item">'+i(t[e])+"</div>"},option_create:function(t,e){return'<div class="create">Add <strong>'+e(t.input)+"</strong>&hellip;</div>"}};this.settings.render=t.extend({},n,this.settings.render)},setupCallbacks:function(){var t,e,i={initialize:"onInitialize",change:"onChange",item_add:"onItemAdd",item_remove:"onItemRemove",clear:"onClear",option_add:"onOptionAdd",option_remove:"onOptionRemove",option_clear:"onOptionClear",optgroup_add:"onOptionGroupAdd",optgroup_remove:"onOptionGroupRemove",optgroup_clear:"onOptionGroupClear",dropdown_open:"onDropdownOpen",dropdown_close:"onDropdownClose",type:"onType",load:"onLoad",focus:"onFocus",blur:"onBlur"};for(t in i)i.hasOwnProperty(t)&&(e=this.settings[i[t]])&&this.on(t,e)},onClick:function(t){this.isFocused&&this.isOpen||(this.focus(),t.preventDefault())},onMouseDown:function(e){var i=this,n=e.isDefaultPrevented();t(e.target);if(i.isFocused){if(e.target!==i.$control_input[0])return"single"===i.settings.mode?i.isOpen?i.close():i.open():n||i.setActiveItem(null),!1}else n||window.setTimeout((function(){i.focus()}),0)},onChange:function(){this.$input.trigger("change")},onPaste:function(e){var i=this;i.isFull()||i.isInputHidden||i.isLocked?e.preventDefault():i.settings.splitOn&&setTimeout((function(){var e=i.$control_input.val();if(e.match(i.settings.splitOn))for(var n=t.trim(e).split(i.settings.splitOn),s=0,o=n.length;s<o;s++)i.createItem(n[s])}),0)},onKeyPress:function(t){if(this.isLocked)return t&&t.preventDefault();var e=String.fromCharCode(t.keyCode||t.which);return this.settings.create&&"multi"===this.settings.mode&&e===this.settings.delimiter?(this.createItem(),t.preventDefault(),!1):void 0},onKeyDown:function(t){t.target,this.$control_input[0];if(this.isLocked)9!==t.keyCode&&t.preventDefault();else{switch(t.keyCode){case 65:if(this.isCmdDown)return void this.selectAll();break;case 27:return void(this.isOpen&&(t.preventDefault(),t.stopPropagation(),this.close()));case 78:if(!t.ctrlKey||t.altKey)break;case 40:if(!this.isOpen&&this.hasOptions)this.open();else if(this.$activeOption){this.ignoreHover=!0;var e=this.getAdjacentOption(this.$activeOption,1);e.length&&this.setActiveOption(e,!0,!0)}return void t.preventDefault();case 80:if(!t.ctrlKey||t.altKey)break;case 38:if(this.$activeOption){this.ignoreHover=!0;var i=this.getAdjacentOption(this.$activeOption,-1);i.length&&this.setActiveOption(i,!0,!0)}return void t.preventDefault();case 13:return void(this.isOpen&&this.$activeOption&&(this.onOptionSelect({currentTarget:this.$activeOption}),t.preventDefault()));case 37:return void this.advanceSelection(-1,t);case 39:return void this.advanceSelection(1,t);case 9:return this.settings.selectOnTab&&this.isOpen&&this.$activeOption&&(this.onOptionSelect({currentTarget:this.$activeOption}),this.isFull()||t.preventDefault()),void(this.settings.create&&this.createItem()&&t.preventDefault());case 8:case 46:return void this.deleteSelection(t)}!this.isFull()&&!this.isInputHidden||(o?t.metaKey:t.ctrlKey)||t.preventDefault()}},onKeyUp:function(t){if(this.isLocked)return t&&t.preventDefault();var e=this.$control_input.val()||"";this.lastValue!==e&&(this.lastValue=e,this.onSearchChange(e),this.refreshOptions(),this.trigger("type",e))},onSearchChange:function(t){var e=this,i=e.settings.load;i&&(e.loadedSearches.hasOwnProperty(t)||(e.loadedSearches[t]=!0,e.load((function(n){i.apply(e,[t,n])}))))},onFocus:function(t){var e=this.isFocused;if(this.isDisabled)return this.blur(),t&&t.preventDefault(),!1;this.ignoreFocus||(this.isFocused=!0,"focus"===this.settings.preload&&this.onSearchChange(""),e||this.trigger("focus"),this.$activeItems.length||(this.showInput(),this.setActiveItem(null),this.refreshOptions(!!this.settings.openOnFocus)),this.refreshState())},onBlur:function(t,e){var i=this;if(i.isFocused&&(i.isFocused=!1,!i.ignoreFocus)){if(!i.ignoreBlur&&document.activeElement===i.$dropdown_content[0])return i.ignoreBlur=!0,void i.onFocus(t);var n=function(){i.close(),i.setTextboxValue(""),i.setActiveItem(null),i.setActiveOption(null),i.setCaret(i.items.length),i.refreshState(),e&&e.focus&&e.focus(),i.isBlurring=!1,i.ignoreFocus=!1,i.trigger("blur")};i.isBlurring=!0,i.ignoreFocus=!0,i.settings.create&&i.settings.createOnBlur?i.createItem(null,!1,n):n()}},onOptionHover:function(t){this.ignoreHover||this.setActiveOption(t.currentTarget,!1)},onOptionSelect:function(e){var i,n,s=this;e.preventDefault&&(e.preventDefault(),e.stopPropagation()),(n=t(e.currentTarget)).hasClass("create")?s.createItem(null,(function(){s.settings.closeAfterSelect&&s.close()})):void 0!==(i=n.attr("data-value"))&&(s.lastQuery=null,s.setTextboxValue(""),s.addItem(i),s.settings.closeAfterSelect?s.close():!s.settings.hideSelected&&e.type&&/mouse/.test(e.type)&&s.setActiveOption(s.getOption(i)))},onItemSelect:function(t){this.isLocked||"multi"===this.settings.mode&&(t.preventDefault(),this.setActiveItem(t.currentTarget,t))},load:function(t){var e=this,i=e.$wrapper.addClass(e.settings.loadingClass);e.loading++,t.apply(e,[function(t){e.loading=Math.max(e.loading-1,0),t&&t.length&&(e.addOption(t),e.refreshOptions(e.isFocused&&!e.isInputHidden)),e.loading||i.removeClass(e.settings.loadingClass),e.trigger("load",t)}])},setTextboxValue:function(t){var e=this.$control_input;e.val()!==t&&(e.val(t).triggerHandler("update"),this.lastValue=t)},getValue:function(){return 1===this.tagType&&this.$input.attr("multiple")?this.items:this.items.join(this.settings.delimiter)},setValue:function(t,e){g(this,e?[]:["change"],(function(){this.clear(e),this.addItems(t,e)}))},setActiveItem:function(e,i){var n,s,o,r,a,l,h,p;if("single"!==this.settings.mode){if(!(e=t(e)).length)return t(this.$activeItems).removeClass("active"),this.$activeItems=[],void(this.isFocused&&this.showInput());if("mousedown"===(n=i&&i.type.toLowerCase())&&this.isShiftDown&&this.$activeItems.length){for(p=this.$control.children(".active:last"),(r=Array.prototype.indexOf.apply(this.$control[0].childNodes,[p[0]]))>(a=Array.prototype.indexOf.apply(this.$control[0].childNodes,[e[0]]))&&(h=r,r=a,a=h),s=r;s<=a;s++)l=this.$control[0].childNodes[s],-1===this.$activeItems.indexOf(l)&&(t(l).addClass("active"),this.$activeItems.push(l));i.preventDefault()}else"mousedown"===n&&this.isCtrlDown||"keydown"===n&&this.isShiftDown?e.hasClass("active")?(o=this.$activeItems.indexOf(e[0]),this.$activeItems.splice(o,1),e.removeClass("active")):this.$activeItems.push(e.addClass("active")[0]):(t(this.$activeItems).removeClass("active"),this.$activeItems=[e.addClass("active")[0]]);this.hideInput(),this.isFocused||this.focus()}},setActiveOption:function(e,i,n){var s,o,r,a,l;this.$activeOption&&this.$activeOption.removeClass("active"),this.$activeOption=null,(e=t(e)).length&&(this.$activeOption=e.addClass("active"),!i&&h(i)||(s=this.$dropdown_content.height(),o=this.$activeOption.outerHeight(!0),i=this.$dropdown_content.scrollTop()||0,a=r=this.$activeOption.offset().top-this.$dropdown_content.offset().top+i,l=r-s+o,r+o>s+i?this.$dropdown_content.stop().animate({scrollTop:l},n?this.settings.scrollDuration:0):r<i&&this.$dropdown_content.stop().animate({scrollTop:a},n?this.settings.scrollDuration:0)))},selectAll:function(){"single"!==this.settings.mode&&(this.$activeItems=Array.prototype.slice.apply(this.$control.children(":not(input)").addClass("active")),this.$activeItems.length&&(this.hideInput(),this.close()),this.focus())},hideInput:function(){this.setTextboxValue(""),this.$control_input.css({opacity:0,position:"absolute",left:this.rtl?1e4:-1e4}),this.isInputHidden=!0},showInput:function(){this.$control_input.css({opacity:1,position:"relative",left:0}),this.isInputHidden=!1},focus:function(){var t=this;t.isDisabled||(t.ignoreFocus=!0,t.$control_input[0].focus(),window.setTimeout((function(){t.ignoreFocus=!1,t.onFocus()}),0))},blur:function(t){this.$control_input[0].blur(),this.onBlur(null,t)},getScoreFunction:function(t){return this.sifter.getScoreFunction(t,this.getSearchOptions())},getSearchOptions:function(){var t=this.settings,e=t.sortField;return"string"==typeof e&&(e=[{field:e}]),{fields:t.searchField,conjunction:t.searchConjunction,sort:e,nesting:t.nesting}},search:function(e){var i,n,s,o=this.settings,r=this.getSearchOptions();if(o.score&&"function"!=typeof(s=this.settings.score.apply(this,[e])))throw new Error('Selectize "score" setting must be a function that returns a function');if(e!==this.lastQuery?(this.lastQuery=e,n=this.sifter.search(e,t.extend(r,{score:s})),this.currentResults=n):n=t.extend(!0,{},this.currentResults),o.hideSelected)for(i=n.items.length-1;i>=0;i--)-1!==this.items.indexOf(p(n.items[i].id))&&n.items.splice(i,1);return n},refreshOptions:function(e){var i,s,o,r,a,l,h,u,c,d,g,f,v,m,y,w;void 0===e&&(e=!0);var O,$,C=this,b=t.trim(C.$control_input.val()),x=C.search(b),S=C.$dropdown_content,I=C.$activeOption&&p(C.$activeOption.attr("data-value"));for(r=x.items.length,"number"==typeof C.settings.maxOptions&&(r=Math.min(r,C.settings.maxOptions)),a={},l=[],i=0;i<r;i++)for(h=C.options[x.items[i].id],u=C.render("option",h),c=h[C.settings.optgroupField]||"",s=0,o=(d=t.isArray(c)?c:[c])&&d.length;s<o;s++)c=d[s],C.optgroups.hasOwnProperty(c)||(c=""),a.hasOwnProperty(c)||(a[c]=document.createDocumentFragment(),l.push(c)),a[c].appendChild(u);for(this.settings.lockOptgroupOrder&&l.sort((function(t,e){return(C.optgroups[t].$order||0)-(C.optgroups[e].$order||0)})),g=document.createDocumentFragment(),i=0,r=l.length;i<r;i++)c=l[i],C.optgroups.hasOwnProperty(c)&&a[c].childNodes.length?((f=document.createDocumentFragment()).appendChild(C.render("optgroup_header",C.optgroups[c])),f.appendChild(a[c]),g.appendChild(C.render("optgroup",t.extend({},C.optgroups[c],{html:(O=f,$=void 0,$=document.createElement("div"),$.appendChild(O.cloneNode(!0)),$.innerHTML),dom:f})))):g.appendChild(a[c]);if(S.html(g),C.settings.highlight&&(S.removeHighlight(),x.query.length&&x.tokens.length))for(i=0,r=x.tokens.length;i<r;i++)n(S,x.tokens[i].regex);if(!C.settings.hideSelected)for(i=0,r=C.items.length;i<r;i++)C.getOption(C.items[i]).addClass("selected");(v=C.canCreate(b))&&(S.prepend(C.render("option_create",{input:b})),w=t(S[0].childNodes[0])),C.hasOptions=x.items.length>0||v,C.hasOptions?(x.items.length>0?((y=I&&C.getOption(I))&&y.length?m=y:"single"===C.settings.mode&&C.items.length&&(m=C.getOption(C.items[0])),m&&m.length||(m=w&&!C.settings.addPrecedence?C.getAdjacentOption(w,1):S.find("[data-selectable]:first"))):m=w,C.setActiveOption(m),e&&!C.isOpen&&C.open()):(C.setActiveOption(null),e&&C.isOpen&&C.close())},addOption:function(e){var i,n,s;if(t.isArray(e))for(i=0,n=e.length;i<n;i++)this.addOption(e[i]);else(s=this.registerOption(e))&&(this.userOptions[s]=!0,this.lastQuery=null,this.trigger("option_add",s,e))},registerOption:function(t){var e=p(t[this.settings.valueField]);return null!=e&&!this.options.hasOwnProperty(e)&&(t.$order=t.$order||++this.order,this.options[e]=t,e)},registerOptionGroup:function(t){var e=p(t[this.settings.optgroupValueField]);return!!e&&(t.$order=t.$order||++this.order,this.optgroups[e]=t,e)},addOptionGroup:function(t,e){e[this.settings.optgroupValueField]=t,(t=this.registerOptionGroup(e))&&this.trigger("optgroup_add",t,e)},removeOptionGroup:function(t){this.optgroups.hasOwnProperty(t)&&(delete this.optgroups[t],this.renderCache={},this.trigger("optgroup_remove",t))},clearOptionGroups:function(){this.optgroups={},this.renderCache={},this.trigger("optgroup_clear")},updateOption:function(e,i){var n,s,o,r,a,l,h;if(e=p(e),o=p(i[this.settings.valueField]),null!==e&&this.options.hasOwnProperty(e)){if("string"!=typeof o)throw new Error("Value must be set in option data");h=this.options[e].$order,o!==e&&(delete this.options[e],-1!==(r=this.items.indexOf(e))&&this.items.splice(r,1,o)),i.$order=i.$order||h,this.options[o]=i,a=this.renderCache.item,l=this.renderCache.option,a&&(delete a[e],delete a[o]),l&&(delete l[e],delete l[o]),-1!==this.items.indexOf(o)&&(n=this.getItem(e),s=t(this.render("item",i)),n.hasClass("active")&&s.addClass("active"),n.replaceWith(s)),this.lastQuery=null,this.isOpen&&this.refreshOptions(!1)}},removeOption:function(t,e){t=p(t);var i=this.renderCache.item,n=this.renderCache.option;i&&delete i[t],n&&delete n[t],delete this.userOptions[t],delete this.options[t],this.lastQuery=null,this.trigger("option_remove",t),this.removeItem(t,e)},clearOptions:function(){var e=this;e.loadedSearches={},e.userOptions={},e.renderCache={};var i=e.options;t.each(e.options,(function(t,n){-1==e.items.indexOf(t)&&delete i[t]})),e.options=e.sifter.items=i,e.lastQuery=null,e.trigger("option_clear")},getOption:function(t){return this.getElementWithValue(t,this.$dropdown_content.find("[data-selectable]"))},getAdjacentOption:function(e,i){var n=this.$dropdown.find("[data-selectable]"),s=n.index(e)+i;return s>=0&&s<n.length?n.eq(s):t()},getElementWithValue:function(e,i){if(null!=(e=p(e)))for(var n=0,s=i.length;n<s;n++)if(i[n].getAttribute("data-value")===e)return t(i[n]);return t()},getItem:function(t){return this.getElementWithValue(t,this.$control.children())},addItems:function(e,i){this.buffer=document.createDocumentFragment();for(var n=this.$control[0].childNodes,s=0;s<n.length;s++)this.buffer.appendChild(n[s]);for(var o=t.isArray(e)?e:[e],r=(s=0,o.length);s<r;s++)this.isPending=s<r-1,this.addItem(o[s],i);var a=this.$control[0];a.insertBefore(this.buffer,a.firstChild),this.buffer=null},addItem:function(e,i){g(this,i?[]:["change"],(function(){var n,s,o,r,a,l=this.settings.mode;e=p(e),-1===this.items.indexOf(e)?this.options.hasOwnProperty(e)&&("single"===l&&this.clear(i),"multi"===l&&this.isFull()||(n=t(this.render("item",this.options[e])),a=this.isFull(),this.items.splice(this.caretPos,0,e),this.insertAtCaret(n),(!this.isPending||!a&&this.isFull())&&this.refreshState(),this.isSetup&&(o=this.$dropdown_content.find("[data-selectable]"),this.isPending||(s=this.getOption(e),r=this.getAdjacentOption(s,1).attr("data-value"),this.refreshOptions(this.isFocused&&"single"!==l),r&&this.setActiveOption(this.getOption(r))),!o.length||this.isFull()?this.close():this.isPending||this.positionDropdown(),this.updatePlaceholder(),this.trigger("item_add",e,n),this.isPending||this.updateOriginalInput({silent:i})))):"single"===l&&this.close()}))},removeItem:function(e,i){var n,s,o;n=e instanceof t?e:this.getItem(e),e=p(n.attr("data-value")),-1!==(s=this.items.indexOf(e))&&(n.remove(),n.hasClass("active")&&(o=this.$activeItems.indexOf(n[0]),this.$activeItems.splice(o,1)),this.items.splice(s,1),this.lastQuery=null,!this.settings.persist&&this.userOptions.hasOwnProperty(e)&&this.removeOption(e,i),s<this.caretPos&&this.setCaret(this.caretPos-1),this.refreshState(),this.updatePlaceholder(),this.updateOriginalInput({silent:i}),this.positionDropdown(),this.trigger("item_remove",e,n))},createItem:function(e,i){var n=this,s=n.caretPos;e=e||t.trim(n.$control_input.val()||"");var o=arguments[arguments.length-1];if("function"!=typeof o&&(o=function(){}),"boolean"!=typeof i&&(i=!0),!n.canCreate(e))return o(),!1;n.lock();var r="function"==typeof n.settings.create?this.settings.create:function(t){var e={};return e[n.settings.labelField]=t,e[n.settings.valueField]=t,e},a=d((function(t){if(n.unlock(),!t||"object"!=typeof t)return o();var e=p(t[n.settings.valueField]);if("string"!=typeof e)return o();n.setTextboxValue(""),n.addOption(t),n.setCaret(s),n.addItem(e),n.refreshOptions(i&&"single"!==n.settings.mode),o(t)})),l=r.apply(this,[e,a]);return void 0!==l&&a(l),!0},refreshItems:function(){this.lastQuery=null,this.isSetup&&this.addItem(this.items),this.refreshState(),this.updateOriginalInput()},refreshState:function(){this.refreshValidityState(),this.refreshClasses()},refreshValidityState:function(){if(!this.isRequired)return!1;var t=!this.items.length;this.isInvalid=t,this.$control_input.prop("required",t),this.$input.prop("required",!t)},refreshClasses:function(){var e=this.isFull(),i=this.isLocked;this.$wrapper.toggleClass("rtl",this.rtl),this.$control.toggleClass("focus",this.isFocused).toggleClass("disabled",this.isDisabled).toggleClass("required",this.isRequired).toggleClass("invalid",this.isInvalid).toggleClass("locked",i).toggleClass("full",e).toggleClass("not-full",!e).toggleClass("input-active",this.isFocused&&!this.isInputHidden).toggleClass("dropdown-active",this.isOpen).toggleClass("has-options",!t.isEmptyObject(this.options)).toggleClass("has-items",this.items.length>0),this.$control_input.data("grow",!e&&!i)},isFull:function(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems},updateOriginalInput:function(t){var e,i,n,s;if(t=t||{},1===this.tagType){for(n=[],e=0,i=this.items.length;e<i;e++)s=this.options[this.items[e]][this.settings.labelField]||"",n.push('<option value="'+u(this.items[e])+'" selected="selected">'+u(s)+"</option>");n.length||this.$input.attr("multiple")||n.push('<option value="" selected="selected"></option>'),this.$input.html(n.join(""))}else this.$input.val(this.getValue()),this.$input.attr("value",this.$input.val());this.isSetup&&(t.silent||this.trigger("change",this.$input.val()))},updatePlaceholder:function(){if(this.settings.placeholder){var t=this.$control_input;this.items.length?t.removeAttr("placeholder"):t.attr("placeholder",this.settings.placeholder),t.triggerHandler("update",{force:!0})}},open:function(){this.isLocked||this.isOpen||"multi"===this.settings.mode&&this.isFull()||(this.focus(),this.isOpen=!0,this.refreshState(),this.$dropdown.css({visibility:"hidden",display:"block"}),this.positionDropdown(),this.$dropdown.css({visibility:"visible"}),this.trigger("dropdown_open",this.$dropdown))},close:function(){var t=this.isOpen;"single"===this.settings.mode&&this.items.length&&(this.hideInput(),this.isBlurring||this.$control_input.blur()),this.isOpen=!1,this.$dropdown.hide(),this.setActiveOption(null),this.refreshState(),t&&this.trigger("dropdown_close",this.$dropdown)},positionDropdown:function(){var t=this.$control,e="body"===this.settings.dropdownParent?t.offset():t.position();e.top+=t.outerHeight(!0),this.$dropdown.css({width:t[0].getBoundingClientRect().width,top:e.top,left:e.left})},clear:function(t){this.items.length&&(this.$control.children(":not(input)").remove(),this.items=[],this.lastQuery=null,this.setCaret(0),this.setActiveItem(null),this.updatePlaceholder(),this.updateOriginalInput({silent:t}),this.refreshState(),this.showInput(),this.trigger("clear"))},insertAtCaret:function(t){var e=Math.min(this.caretPos,this.items.length),i=t[0],n=this.buffer||this.$control[0];0===e?n.insertBefore(i,n.firstChild):n.insertBefore(i,n.childNodes[e]),this.setCaret(e+1)},deleteSelection:function(e){var i,n,s,o,r,a,l,h,p;if(s=e&&8===e.keyCode?-1:1,o=f(this.$control_input[0]),this.$activeOption&&!this.settings.hideSelected&&(l=this.getAdjacentOption(this.$activeOption,-1).attr("data-value")),r=[],this.$activeItems.length){for(p=this.$control.children(".active:"+(s>0?"last":"first")),a=this.$control.children(":not(input)").index(p),s>0&&a++,i=0,n=this.$activeItems.length;i<n;i++)r.push(t(this.$activeItems[i]).attr("data-value"));e&&(e.preventDefault(),e.stopPropagation())}else(this.isFocused||"single"===this.settings.mode)&&this.items.length&&(s<0&&0===o.start&&0===o.length?r.push(this.items[this.caretPos-1]):s>0&&o.start===this.$control_input.val().length&&r.push(this.items[this.caretPos]));if(!r.length||"function"==typeof this.settings.onDelete&&!1===this.settings.onDelete.apply(this,[r]))return!1;for(void 0!==a&&this.setCaret(a);r.length;)this.removeItem(r.pop());return this.showInput(),this.positionDropdown(),this.refreshOptions(!0),l&&(h=this.getOption(l)).length&&this.setActiveOption(h),!0},advanceSelection:function(t,e){var i,n,s,o,r;0!==t&&(this.rtl&&(t*=-1),i=t>0?"last":"first",n=f(this.$control_input[0]),this.isFocused&&!this.isInputHidden?(o=this.$control_input.val().length,(t<0?0===n.start&&0===n.length:n.start===o)&&!o&&this.advanceCaret(t,e)):(r=this.$control.children(".active:"+i)).length&&(s=this.$control.children(":not(input)").index(r),this.setActiveItem(null),this.setCaret(t>0?s+1:s)))},advanceCaret:function(t,e){var i,n;0!==t&&(i=t>0?"next":"prev",this.isShiftDown?(n=this.$control_input[i]()).length&&(this.hideInput(),this.setActiveItem(n),e&&e.preventDefault()):this.setCaret(this.caretPos+t))},setCaret:function(e){var i,n,s,o;if(e="single"===this.settings.mode?this.items.length:Math.max(0,Math.min(this.items.length,e)),!this.isPending)for(i=0,n=(s=this.$control.children(":not(input)")).length;i<n;i++)o=t(s[i]).detach(),i<e?this.$control_input.before(o):this.$control.append(o);this.caretPos=e},lock:function(){this.close(),this.isLocked=!0,this.refreshState()},unlock:function(){this.isLocked=!1,this.refreshState()},disable:function(){this.$input.prop("disabled",!0),this.$control_input.prop("disabled",!0).prop("tabindex",-1),this.isDisabled=!0,this.lock()},enable:function(){this.$input.prop("disabled",!1),this.$control_input.prop("disabled",!1).prop("tabindex",this.tabIndex),this.isDisabled=!1,this.unlock()},destroy:function(){var e=this.eventNS,i=this.revertSettings;this.trigger("destroy"),this.off(),this.$wrapper.remove(),this.$dropdown.remove(),this.$input.html("").append(i.$children).removeAttr("tabindex").removeClass("selectized").attr({tabindex:i.tabindex}).show(),this.$control_input.removeData("grow"),this.$input.removeData("selectize"),0==--m.count&&m.$testInput&&(m.$testInput.remove(),m.$testInput=void 0),t(window).off(e),t(document).off(e),t(document.body).off(e),delete this.$input[0].selectize},render:function(e,i){var n,s,o="",r=!1;return"option"!==e&&"item"!==e||(r=!!(n=p(i[this.settings.valueField]))),r&&(h(this.renderCache[e])||(this.renderCache[e]={}),this.renderCache[e].hasOwnProperty(n))?this.renderCache[e][n]:(o=t(this.settings.render[e].apply(this,[i,u])),"option"===e||"option_create"===e?i[this.settings.disabledField]||o.attr("data-selectable",""):"optgroup"===e&&(s=i[this.settings.optgroupValueField]||"",o.attr("data-group",s),i[this.settings.disabledField]&&o.attr("data-disabled","")),"option"!==e&&"item"!==e||o.attr("data-value",n||""),r&&(this.renderCache[e][n]=o[0]),o[0])},clearCache:function(t){void 0===t?this.renderCache={}:delete this.renderCache[t]},canCreate:function(t){if(!this.settings.create)return!1;var e=this.settings.createFilter;return t.length&&("function"!=typeof e||e.apply(this,[t]))&&("string"!=typeof e||new RegExp(e).test(t))&&(!(e instanceof RegExp)||e.test(t))}}),m.count=0,m.defaults={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:!1,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,maxOptions:1e3,maxItems:null,hideSelected:null,addPrecedence:!1,selectOnTab:!1,preload:!1,allowEmptyOption:!1,closeAfterSelect:!1,scrollDuration:60,loadThrottle:300,loadingClass:"loading",dataAttr:"data-data",optgroupField:"optgroup",valueField:"value",labelField:"text",disabledField:"disabled",optgroupLabelField:"label",optgroupValueField:"value",lockOptgroupOrder:!1,sortField:"$order",searchField:["text"],searchConjunction:"and",mode:null,wrapperClass:"selectize-control",inputClass:"selectize-input",dropdownClass:"selectize-dropdown",dropdownContentClass:"selectize-dropdown-content",dropdownParent:null,copyClassesToDropdown:!0,render:{}},t.fn.selectize=function(e){var i=t.fn.selectize.defaults,n=t.extend({},i,e),s=n.dataAttr,o=n.labelField,r=n.valueField,a=n.disabledField,l=n.optgroupField,h=n.optgroupLabelField,u=n.optgroupValueField;return this.each((function(){if(!this.selectize){var c=t(this),d=this.tagName.toLowerCase(),g=c.attr("placeholder")||c.attr("data-placeholder");g||n.allowEmptyOption||(g=c.children('option[value=""]').text());var f={placeholder:g,options:[],optgroups:[],items:[]};"select"===d?function(e,i){var c,d,g,f,v=i.options,m={},y=function(t){var e=s&&t.attr(s);return"string"==typeof e&&e.length?JSON.parse(e):null},w=function(e,s){e=t(e);var h=p(e.val());if(h||n.allowEmptyOption)if(m.hasOwnProperty(h)){if(s){var u=m[h][l];u?t.isArray(u)?u.push(s):m[h][l]=[u,s]:m[h][l]=s}}else{var c=y(e)||{};c[o]=c[o]||e.text(),c[r]=c[r]||h,c[a]=c[a]||e.prop("disabled"),c[l]=c[l]||s,m[h]=c,v.push(c),e.is(":selected")&&i.items.push(h)}},O=function(e){var n,s,o,r,l;for((o=(e=t(e)).attr("label"))&&((r=y(e)||{})[h]=o,r[u]=o,r[a]=e.prop("disabled"),i.optgroups.push(r)),n=0,s=(l=t("option",e)).length;n<s;n++)w(l[n],o)};for(i.maxItems=e.attr("multiple")?null:1,c=0,d=(f=e.children()).length;c<d;c++)"optgroup"===(g=f[c].tagName.toLowerCase())?O(f[c]):"option"===g&&w(f[c])}(c,f):function(e,i){var a,l,h,p,u=e.attr(s);if(u)for(i.options=JSON.parse(u),a=0,l=i.options.length;a<l;a++)i.items.push(i.options[a][r]);else{var c=t.trim(e.val()||"");if(!n.allowEmptyOption&&!c.length)return;for(a=0,l=(h=c.split(n.delimiter)).length;a<l;a++)(p={})[o]=h[a],p[r]=h[a],i.options.push(p);i.items=h}}(c,f),new m(c,t.extend(!0,{},i,f,e))}}))},t.fn.selectize.defaults=m.defaults,t.fn.selectize.support={validity:l},m.define("drag_drop",(function(e){if(!t.fn.sortable)throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');if("multi"===this.settings.mode){var i,n=this;n.lock=(i=n.lock,function(){var t=n.$control.data("sortable");return t&&t.disable(),i.apply(n,arguments)}),n.unlock=function(){var t=n.unlock;return function(){var e=n.$control.data("sortable");return e&&e.enable(),t.apply(n,arguments)}}(),n.setup=function(){var e=n.setup;return function(){e.apply(this,arguments);var i=n.$control.sortable({items:"[data-value]",forcePlaceholderSize:!0,disabled:n.isLocked,start:function(t,e){e.placeholder.css("width",e.helper.css("width")),i.css({overflow:"visible"})},stop:function(){i.css({overflow:"hidden"});var e=n.$activeItems?n.$activeItems.slice():null,s=[];i.children("[data-value]").each((function(){s.push(t(this).attr("data-value"))})),n.setValue(s),n.setActiveItem(e)}})}}()}})),m.define("dropdown_header",(function(e){var i,n=this;e=t.extend({title:"Untitled",headerClass:"selectize-dropdown-header",titleRowClass:"selectize-dropdown-header-title",labelClass:"selectize-dropdown-header-label",closeClass:"selectize-dropdown-header-close",html:function(t){return'<div class="'+t.headerClass+'"><div class="'+t.titleRowClass+'"><span class="'+t.labelClass+'">'+t.title+'</span><a href="javascript:void(0)" class="'+t.closeClass+'">&times;</a></div></div>'}},e),n.setup=(i=n.setup,function(){i.apply(n,arguments),n.$dropdown_header=t(e.html(e)),n.$dropdown.prepend(n.$dropdown_header)})})),m.define("optgroup_columns",(function(e){var i,n=this;e=t.extend({equalizeWidth:!0,equalizeHeight:!0},e),this.getAdjacentOption=function(e,i){var n=e.closest("[data-group]").find("[data-selectable]"),s=n.index(e)+i;return s>=0&&s<n.length?n.eq(s):t()},this.onKeyDown=(i=n.onKeyDown,function(t){var e,s,o,r;return!this.isOpen||37!==t.keyCode&&39!==t.keyCode?i.apply(this,arguments):(n.ignoreHover=!0,e=(r=this.$activeOption.closest("[data-group]")).find("[data-selectable]").index(this.$activeOption),void((s=(o=(r=37===t.keyCode?r.prev("[data-group]"):r.next("[data-group]")).find("[data-selectable]")).eq(Math.min(o.length-1,e))).length&&this.setActiveOption(s)))});var s=function(){var t,e=s.width,i=document;return void 0===e&&((t=i.createElement("div")).innerHTML='<div style="width:50px;height:50px;position:absolute;left:-50px;top:-50px;overflow:auto;"><div style="width:1px;height:100px;"></div></div>',t=t.firstChild,i.body.appendChild(t),e=s.width=t.offsetWidth-t.clientWidth,i.body.removeChild(t)),e},o=function(){var i,o,r,a,l,h,p;if((o=(p=t("[data-group]",n.$dropdown_content)).length)&&n.$dropdown_content.width()){if(e.equalizeHeight){for(r=0,i=0;i<o;i++)r=Math.max(r,p.eq(i).height());p.css({height:r})}e.equalizeWidth&&(h=n.$dropdown_content.innerWidth()-s(),a=Math.round(h/o),p.css({width:a}),o>1&&(l=h-a*(o-1),p.eq(o-1).css({width:l})))}};(e.equalizeHeight||e.equalizeWidth)&&(c.after(this,"positionDropdown",o),c.after(this,"refreshOptions",o))})),m.define("remove_button",(function(e){e=t.extend({label:"&times;",title:"Remove",className:"remove",append:!0},e);"single"!==this.settings.mode?function(e,i){var n,s=e,o='<a href="javascript:void(0)" class="'+i.className+'" tabindex="-1" title="'+u(i.title)+'">'+i.label+"</a>",r=function(t,e){var i=t.search(/(<\/[^>]+>\s*)$/);return t.substring(0,i)+e+t.substring(i)};e.setup=(n=s.setup,function(){if(i.append){var a=s.settings.render.item;s.settings.render.item=function(t){return r(a.apply(e,arguments),o)}}n.apply(e,arguments),e.$control.on("click","."+i.className,(function(e){if(e.preventDefault(),!s.isLocked){var i=t(e.currentTarget).parent();s.setActiveItem(i),s.deleteSelection()&&s.setCaret(s.items.length)}}))})}(this,e):function(e,i){i.className="remove-single";var n,s=e,o='<a href="javascript:void(0)" class="'+i.className+'" tabindex="-1" title="'+u(i.title)+'">'+i.label+"</a>",r=function(e,i){return t("<span>").append(e).append(i)};e.setup=(n=s.setup,function(){if(i.append){var a=t(s.$input.context).attr("id"),l=(t("#"+a),s.settings.render.item);s.settings.render.item=function(t){return r(l.apply(e,arguments),o)}}n.apply(e,arguments),e.$control.on("click","."+i.className,(function(t){t.preventDefault(),s.isLocked||s.clear()}))})}(this,e)})),m.define("restore_on_backspace",(function(t){var e,i=this;t.text=t.text||function(t){return t[this.settings.labelField]},this.onKeyDown=(e=i.onKeyDown,function(i){var n,s;return 8===i.keyCode&&""===this.$control_input.val()&&!this.$activeItems.length&&(n=this.caretPos-1)>=0&&n<this.items.length?(s=this.options[this.items[n]],this.deleteSelection(i)&&(this.setTextboxValue(t.text.apply(this,[s])),this.refreshOptions(!0)),void i.preventDefault()):e.apply(this,arguments)})})),m}));