@barkleyrei/selectize
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -1,3 +0,3 @@ | ||
/*! selectize.js - v1.0.1 | https://github.com/selectize/selectize.js | Apache License (v2) */ | ||
/*! selectize.js - v1.0.2 | https://github.com/selectize/selectize.js | Apache License (v2) */ | ||
!function(t,e){"function"==typeof define&&define.amd?define(["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(I,c,t){"use strict";I.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()};function i(){}i.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 n=arguments.length;return 0===n?delete this._events:1===n?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))}},i.mixin=function(t){for(var e=["on","off","trigger"],n=0;n<e.length;n++)t.prototype[e[n]]=i.prototype[e[n]]};function p(t){return void 0!==t}function S(t){return null==t?null:"boolean"==typeof t?t?"1":"0":t+""}function a(t){return(t+"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function n(e,n,t){var i,o=e.trigger,s={};for(i in e.trigger=function(){var t=arguments[0];if(-1===n.indexOf(t))return o.apply(e,arguments);s[t]=arguments},t.apply(e,[]),e.trigger=o,s)s.hasOwnProperty(i)&&o.apply(e,s[i])}function g(t){var e,n,i={};return"selectionStart"in t?(i.start=t.selectionStart,i.length=t.selectionEnd-i.start):document.selection&&(t.focus(),e=document.selection.createRange(),n=document.selection.createRange().text.length,e.moveStart("character",-t.value.length),i.start=e.text.length-n,i.length=n),i}function w(u){function t(t,e){var n,i,o,s,r,a,l,p,d,c;e=e||{},(t=t||window.event||{}).metaKey||t.altKey||!e.force&&!1===u.data("grow")||(c=u.val(),t.type&&"keydown"===t.type.toLowerCase()&&(i=48<=(n=t.keyCode)&&n<=57||65<=n&&n<=90||96<=n&&n<=111||186<=n&&n<=222||32===n,46===n||8===n?(l=g(u[0])).length?c=c.substring(0,l.start)+c.substring(l.start+l.length):8===n&&l.start?c=c.substring(0,l.start-1)+c.substring(l.start+1):46===n&&void 0!==l.start&&(c=c.substring(0,l.start)+c.substring(l.start+1)):i&&(r=t.shiftKey,a=String.fromCharCode(t.keyCode),c+=a=r?a.toUpperCase():a.toLowerCase())),o=u.attr("placeholder"),!c&&o&&(c=o),d=u,(s=((p=c)?(y.$testInput||(y.$testInput=I("<span />").css({position:"absolute",top:-99999,left:-99999,width:"auto",padding:0,whiteSpace:"pre"}).appendTo("body")),y.$testInput.text(p),function(t,e,n){var i,o,s={};if(n)for(i=0,o=n.length;i<o;i++)s[n[i]]=t.css(n[i]);else s=t.css();e.css(s)}(d,y.$testInput,["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"]),y.$testInput.width()):0)+4)!==h&&(h=s,u.width(s),u.triggerHandler("resize")))}var h=null;u.on("keydown keyup update blur",t),t()}var $=/Mac/.test(navigator.userAgent),b=$?91:17,x=$?18:17,F=!/android/i.test(window.navigator.userAgent)&&!!document.createElement("input").validity,y=function(t,e){var n,i,o=this,s=t[0];s.selectize=o;var r,a,l,p,d=window.getComputedStyle&&window.getComputedStyle(s,null);if(p=(p=d?d.getPropertyValue("direction"):s.currentStyle&&s.currentStyle.direction)||t.parents("[dir]:first").attr("dir")||"",I.extend(o,{order:0,settings:e,$input:t,tabIndex:t.attr("tabindex")||"",tagType:"select"===s.tagName.toLowerCase()?1:2,rtl:/rtl/i.test(p),eventNS:".selectize"+ ++y.count,highlightedValue:null,isBlurring:!1,isOpen:!1,isDisabled:!1,isRequired:t.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===e.loadThrottle?o.onSearchChange:(r=o.onSearchChange,a=e.loadThrottle,function(){var t=this,e=arguments;window.clearTimeout(l),l=window.setTimeout(function(){r.apply(t,e)},a)})}),o.sifter=new c(this.options,{diacritics:e.diacritics}),o.settings.options){for(n=0,i=o.settings.options.length;n<i;n++)o.registerOption(o.settings.options[n]);delete o.settings.options}if(o.settings.optgroups){for(n=0,i=o.settings.optgroups.length;n<i;n++)o.registerOptionGroup(o.settings.optgroups[n]);delete o.settings.optgroups}o.settings.mode=o.settings.mode||(1===o.settings.maxItems?"single":"multi"),"boolean"!=typeof o.settings.hideSelected&&(o.settings.hideSelected="multi"===o.settings.mode),o.initializePlugins(o.settings.plugins),o.setupCallbacks(),o.setupTemplates(),o.setup()};return i.mixin(y),void 0!==t?t.mixin(y):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.'}),I.extend(y.prototype,{setup:function(){var t,e,n,i,o,s,r,a=this,l=a.settings,p=a.eventNS,d=I(window),c=I(document),u=a.$input,h=a.settings.mode,g=u.attr("class")||"",f=I("<div>").addClass(l.wrapperClass).addClass(g).addClass(h),v=I("<div>").addClass(l.inputClass).addClass("items").appendTo(f),m=I('<input type="text" autocomplete="off" />').appendTo(v).attr("tabindex",u.is(":disabled")?"-1":a.tabIndex),y=I(l.dropdownParent||f),O=I("<div>").addClass(l.dropdownClass).addClass(h).hide().appendTo(y),C=I("<div>").addClass(l.dropdownContentClass).appendTo(O);(e=u.attr("id"))&&(m.attr("id",e+"-selectized"),I("label[for='"+e+"']").attr("for",e+"-selectized")),a.settings.copyClassesToDropdown&&O.addClass(g),f.css({width:u[0].style.width}),a.plugins.names.length&&(t="plugin-"+a.plugins.names.join(" plugin-"),f.addClass(t),O.addClass(t)),(null===l.maxItems||1<l.maxItems)&&1===a.tagType&&u.attr("multiple","multiple"),a.settings.placeholder&&m.attr("placeholder",l.placeholder),!a.settings.splitOn&&a.settings.delimiter&&(n=a.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),a.settings.splitOn=new RegExp("\\s*"+n+"+\\s*")),u.attr("autocorrect")&&m.attr("autocorrect",u.attr("autocorrect")),u.attr("autocapitalize")&&m.attr("autocapitalize",u.attr("autocapitalize")),m[0].type=u[0].type,a.$wrapper=f,a.$control=v,a.$control_input=m,a.$dropdown=O,a.$dropdown_content=C,O.on("mouseenter mousedown click","[data-disabled]>[data-selectable]",function(t){t.stopImmediatePropagation()}),O.on("mouseenter","[data-selectable]",function(){return a.onOptionHover.apply(a,arguments)}),O.on("mousedown click","[data-selectable]",function(){return a.onOptionSelect.apply(a,arguments)}),o="mousedown",s="*:not(input)",r=function(){return a.onItemSelect.apply(a,arguments)},(i=v).on(o,s,function(t){for(var e=t.target;e&&e.parentNode!==i[0];)e=e.parentNode;return t.currentTarget=e,r.apply(this,[t])}),w(m),v.on({mousedown:function(){return a.onMouseDown.apply(a,arguments)},click:function(){return a.onClick.apply(a,arguments)}}),m.on({mousedown:function(t){t.stopPropagation()},keydown:function(){return a.onKeyDown.apply(a,arguments)},keyup:function(){return a.onKeyUp.apply(a,arguments)},keypress:function(){return a.onKeyPress.apply(a,arguments)},resize:function(){a.positionDropdown.apply(a,[])},blur:function(){return a.onBlur.apply(a,arguments)},focus:function(){return a.ignoreBlur=!1,a.onFocus.apply(a,arguments)},paste:function(){return a.onPaste.apply(a,arguments)}}),c.on("keydown"+p,function(t){a.isCmdDown=t[$?"metaKey":"ctrlKey"],a.isCtrlDown=t[$?"altKey":"ctrlKey"],a.isShiftDown=t.shiftKey}),c.on("keyup"+p,function(t){t.keyCode===x&&(a.isCtrlDown=!1),16===t.keyCode&&(a.isShiftDown=!1),t.keyCode===b&&(a.isCmdDown=!1)}),c.on("mousedown"+p,function(t){if(a.isFocused){if(t.target===a.$dropdown[0]||t.target.parentNode===a.$dropdown[0])return!1;a.$control.has(t.target).length||t.target===a.$control[0]||a.blur(t.target)}}),d.on(["scroll"+p,"resize"+p].join(" "),function(){a.isOpen&&a.positionDropdown.apply(a,arguments)}),d.on("mousemove"+p,function(){a.ignoreHover=!1}),this.revertSettings={$children:u.children().detach(),tabindex:u.attr("tabindex")},u.attr("tabindex",-1).hide().after(a.$wrapper),I.isArray(l.items)&&(a.setValue(l.items),delete l.items),F&&u.on("invalid"+p,function(t){t.preventDefault(),a.isInvalid=!0,a.refreshState()}),a.updateOriginalInput(),a.refreshItems(),a.refreshState(),a.updatePlaceholder(),a.isSetup=!0,u.is(":disabled")&&a.disable(),a.on("change",this.onChange),u.data("selectize",a),u.addClass("selectized"),a.trigger("initialize"),!0===l.preload&&a.onSearchChange("")},setupTemplates:function(){var n=this.settings.labelField,i=this.settings.optgroupLabelField,t={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,e){return'<div class="option">'+e(t[n])+"</div>"},item:function(t,e){return'<div class="item">'+e(t[n])+"</div>"},option_create:function(t,e){return'<div class="create">Add <strong>'+e(t.input)+"</strong>…</div>"}};this.settings.render=I.extend({},t,this.settings.render)},setupCallbacks:function(){var t,e,n={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 n)n.hasOwnProperty(t)&&(e=this.settings[n[t]])&&this.on(t,e)},onClick:function(t){this.isFocused&&this.isOpen||(this.focus(),t.preventDefault())},onMouseDown:function(t){var e=this,n=t.isDefaultPrevented();I(t.target);if(e.isFocused){if(t.target!==e.$control_input[0])return"single"===e.settings.mode?e.isOpen?e.close():e.open():n||e.setActiveItem(null),!1}else n||window.setTimeout(function(){e.focus()},0)},onChange:function(){this.$input.trigger("change")},onPaste:function(t){var o=this;o.isFull()||o.isInputHidden||o.isLocked?t.preventDefault():o.settings.splitOn&&setTimeout(function(){var t=o.$control_input.val();if(t.match(o.settings.splitOn))for(var e=I.trim(t).split(o.settings.splitOn),n=0,i=e.length;n<i;n++)o.createItem(e[n])},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];var e,n,i=this;if(i.isLocked)9!==t.keyCode&&t.preventDefault();else{switch(t.keyCode){case 65:if(i.isCmdDown)return void i.selectAll();break;case 27:return void(i.isOpen&&(t.preventDefault(),t.stopPropagation(),i.close()));case 78:if(!t.ctrlKey||t.altKey)break;case 40:return!i.isOpen&&i.hasOptions?i.open():i.$activeOption&&(i.ignoreHover=!0,(e=i.getAdjacentOption(i.$activeOption,1)).length&&i.setActiveOption(e,!0,!0)),void t.preventDefault();case 80:if(!t.ctrlKey||t.altKey)break;case 38:return i.$activeOption&&(i.ignoreHover=!0,(n=i.getAdjacentOption(i.$activeOption,-1)).length&&i.setActiveOption(n,!0,!0)),void t.preventDefault();case 13:return void(i.isOpen&&i.$activeOption&&(i.onOptionSelect({currentTarget:i.$activeOption}),t.preventDefault()));case 37:return void i.advanceSelection(-1,t);case 39:return void i.advanceSelection(1,t);case 9:return i.settings.selectOnTab&&i.isOpen&&i.$activeOption&&(i.onOptionSelect({currentTarget:i.$activeOption}),i.isFull()||t.preventDefault()),void(i.settings.create&&i.createItem()&&t.preventDefault());case 8:case 46:return void i.deleteSelection(t)}!i.isFull()&&!i.isInputHidden||($?t.metaKey:t.ctrlKey)||t.preventDefault()}},onKeyUp:function(t){var e=this;if(e.isLocked)return t&&t.preventDefault();var n=e.$control_input.val()||"";e.lastValue!==n&&(e.lastValue=n,e.onSearchChange(n),e.refreshOptions(),e.trigger("type",n))},onSearchChange:function(e){var n=this,i=n.settings.load;i&&(n.loadedSearches.hasOwnProperty(e)||(n.loadedSearches[e]=!0,n.load(function(t){i.apply(n,[e,t])})))},onFocus:function(t){var e=this,n=e.isFocused;if(e.isDisabled)return e.blur(),t&&t.preventDefault(),!1;e.ignoreFocus||(e.isFocused=!0,"focus"===e.settings.preload&&e.onSearchChange(""),n||e.trigger("focus"),e.$activeItems.length||(e.showInput(),e.setActiveItem(null),e.refreshOptions(!!e.settings.openOnFocus)),e.refreshState())},onBlur:function(t,e){var n=this;if(n.isFocused&&(n.isFocused=!1,!n.ignoreFocus)){if(!n.ignoreBlur&&document.activeElement===n.$dropdown_content[0])return n.ignoreBlur=!0,void n.onFocus(t);var i=function(){n.close(),n.setTextboxValue(""),n.setActiveItem(null),n.setActiveOption(null),n.setCaret(n.items.length),n.refreshState(),e&&e.focus&&e.focus(),n.isBlurring=!1,n.ignoreFocus=!1,n.trigger("blur")};n.isBlurring=!0,n.ignoreFocus=!0,n.settings.create&&n.settings.createOnBlur?n.createItem(null,!1,i):i()}},onOptionHover:function(t){this.ignoreHover||this.setActiveOption(t.currentTarget,!1)},onOptionSelect:function(t){var e,n,i=this;t.preventDefault&&(t.preventDefault(),t.stopPropagation()),(n=I(t.currentTarget)).hasClass("create")?i.createItem(null,function(){i.settings.closeAfterSelect&&i.close()}):void 0!==(e=n.attr("data-value"))&&(i.lastQuery=null,i.setTextboxValue(""),i.addItem(e),i.settings.closeAfterSelect?i.close():!i.settings.hideSelected&&t.type&&/mouse/.test(t.type)&&i.setActiveOption(i.getOption(e)))},onItemSelect:function(t){this.isLocked||"multi"===this.settings.mode&&(t.preventDefault(),this.setActiveItem(t.currentTarget,t))},load:function(t){var e=this,n=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||n.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){n(this,e?[]:["change"],function(){this.clear(e),this.addItems(t,e)})},setActiveItem:function(t,e){var n,i,o,s,r,a,l,p,d=this;if("single"!==d.settings.mode){if(!(t=I(t)).length)return I(d.$activeItems).removeClass("active"),d.$activeItems=[],void(d.isFocused&&d.showInput());if("mousedown"===(n=e&&e.type.toLowerCase())&&d.isShiftDown&&d.$activeItems.length){for(p=d.$control.children(".active:last"),s=Array.prototype.indexOf.apply(d.$control[0].childNodes,[p[0]]),(r=Array.prototype.indexOf.apply(d.$control[0].childNodes,[t[0]]))<s&&(l=s,s=r,r=l),i=s;i<=r;i++)a=d.$control[0].childNodes[i],-1===d.$activeItems.indexOf(a)&&(I(a).addClass("active"),d.$activeItems.push(a));e.preventDefault()}else"mousedown"===n&&d.isCtrlDown||"keydown"===n&&this.isShiftDown?t.hasClass("active")?(o=d.$activeItems.indexOf(t[0]),d.$activeItems.splice(o,1),t.removeClass("active")):d.$activeItems.push(t.addClass("active")[0]):(I(d.$activeItems).removeClass("active"),d.$activeItems=[t.addClass("active")[0]]);d.hideInput(),this.isFocused||d.focus()}},setActiveOption:function(t,e,n){var i,o,s,r,a,l=this;l.$activeOption&&l.$activeOption.removeClass("active"),l.$activeOption=null,(t=I(t)).length&&(l.$activeOption=t.addClass("active"),!e&&p(e)||(i=l.$dropdown_content.height(),o=l.$activeOption.outerHeight(!0),e=l.$dropdown_content.scrollTop()||0,a=(r=s=l.$activeOption.offset().top-l.$dropdown_content.offset().top+e)-i+o,i+e<s+o?l.$dropdown_content.stop().animate({scrollTop:a},n?l.settings.scrollDuration:0):s<e&&l.$dropdown_content.stop().animate({scrollTop:r},n?l.settings.scrollDuration:0)))},selectAll:function(){var t=this;"single"!==t.settings.mode&&(t.$activeItems=Array.prototype.slice.apply(t.$control.children(":not(input)").addClass("active")),t.$activeItems.length&&(t.hideInput(),t.close()),t.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(t){var e,n,i,o=this,s=o.settings,r=this.getSearchOptions();if(s.score&&"function"!=typeof(i=o.settings.score.apply(this,[t])))throw new Error('Selectize "score" setting must be a function that returns a function');if(t!==o.lastQuery?(o.lastQuery=t,n=o.sifter.search(t,I.extend(r,{score:i})),o.currentResults=n):n=I.extend(!0,{},o.currentResults),s.hideSelected)for(e=n.items.length-1;0<=e;e--)-1!==o.items.indexOf(S(n.items[e].id))&&n.items.splice(e,1);return n},refreshOptions:function(t){var e,n,i,o,s,r,a,l,p,d,c,u,h,g,f;void 0===t&&(t=!0);var v,m,y=this,O=I.trim(y.$control_input.val()),C=y.search(O),w=y.$dropdown_content,$=y.$activeOption&&S(y.$activeOption.attr("data-value")),b=C.items.length;for("number"==typeof y.settings.maxOptions&&(b=Math.min(b,y.settings.maxOptions)),o={},s=[],e=0;e<b;e++)for(r=y.options[C.items[e].id],a=y.render("option",r),l=r[y.settings.optgroupField]||"",n=0,i=(p=I.isArray(l)?l:[l])&&p.length;n<i;n++)l=p[n],y.optgroups.hasOwnProperty(l)||(l=""),o.hasOwnProperty(l)||(o[l]=document.createDocumentFragment(),s.push(l)),o[l].appendChild(a);for(this.settings.lockOptgroupOrder&&s.sort(function(t,e){return(y.optgroups[t].$order||0)-(y.optgroups[e].$order||0)}),d=document.createDocumentFragment(),e=0,b=s.length;e<b;e++)l=s[e],y.optgroups.hasOwnProperty(l)&&o[l].childNodes.length?((c=document.createDocumentFragment()).appendChild(y.render("optgroup_header",y.optgroups[l])),c.appendChild(o[l]),d.appendChild(y.render("optgroup",I.extend({},y.optgroups[l],{html:(v=c,m=void 0,(m=document.createElement("div")).appendChild(v.cloneNode(!0)),m.innerHTML),dom:c})))):d.appendChild(o[l]);if(w.html(d),y.settings.highlight&&(w.removeHighlight(),C.query.length&&C.tokens.length))for(e=0,b=C.tokens.length;e<b;e++)!function(t,e){if("string"!=typeof e||e.length){var l="string"==typeof e?new RegExp(e,"i"):e,p=function(t){var e=0;if(3===t.nodeType){var n,i,o,s,r=t.data.search(l);0<=r&&0<t.data.length&&(n=t.data.match(l),(i=document.createElement("span")).className="highlight",(o=t.splitText(r)).splitText(n[0].length),s=o.cloneNode(!0),i.appendChild(s),o.parentNode.replaceChild(i,o),e=1)}else if(1===t.nodeType&&t.childNodes&&!/(script|style)/i.test(t.tagName)&&("highlight"!==t.className||"SPAN"!==t.tagName))for(var a=0;a<t.childNodes.length;++a)a+=p(t.childNodes[a]);return e};t.each(function(){p(this)})}}(w,C.tokens[e].regex);if(!y.settings.hideSelected)for(e=0,b=y.items.length;e<b;e++)y.getOption(y.items[e]).addClass("selected");(u=y.canCreate(O))&&(w.prepend(y.render("option_create",{input:O})),f=I(w[0].childNodes[0])),y.hasOptions=0<C.items.length||u,y.hasOptions?(0<C.items.length?((g=$&&y.getOption($))&&g.length?h=g:"single"===y.settings.mode&&y.items.length&&(h=y.getOption(y.items[0])),h&&h.length||(h=f&&!y.settings.addPrecedence?y.getAdjacentOption(f,1):w.find("[data-selectable]:first"))):h=f,y.setActiveOption(h),t&&!y.isOpen&&y.open()):(y.setActiveOption(null),t&&y.isOpen&&y.close())},addOption:function(t){var e,n,i,o=this;if(I.isArray(t))for(e=0,n=t.length;e<n;e++)o.addOption(t[e]);else(i=o.registerOption(t))&&(o.userOptions[i]=!0,o.lastQuery=null,o.trigger("option_add",i,t))},registerOption:function(t){var e=S(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=S(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(t,e){var n,i,o,s,r,a,l,p=this;if(t=S(t),o=S(e[p.settings.valueField]),null!==t&&p.options.hasOwnProperty(t)){if("string"!=typeof o)throw new Error("Value must be set in option data");l=p.options[t].$order,o!==t&&(delete p.options[t],-1!==(s=p.items.indexOf(t))&&p.items.splice(s,1,o)),e.$order=e.$order||l,p.options[o]=e,r=p.renderCache.item,a=p.renderCache.option,r&&(delete r[t],delete r[o]),a&&(delete a[t],delete a[o]),-1!==p.items.indexOf(o)&&(n=p.getItem(t),i=I(p.render("item",e)),n.hasClass("active")&&i.addClass("active"),n.replaceWith(i)),p.lastQuery=null,p.isOpen&&p.refreshOptions(!1)}},removeOption:function(t,e){var n=this;t=S(t);var i=n.renderCache.item,o=n.renderCache.option;i&&delete i[t],o&&delete o[t],delete n.userOptions[t],delete n.options[t],n.lastQuery=null,n.trigger("option_remove",t),n.removeItem(t,e)},clearOptions:function(){var n=this;n.loadedSearches={},n.userOptions={},n.renderCache={};var i=n.options;I.each(n.options,function(t,e){-1==n.items.indexOf(t)&&delete i[t]}),n.options=n.sifter.items=i,n.lastQuery=null,n.trigger("option_clear")},getOption:function(t){return this.getElementWithValue(t,this.$dropdown_content.find("[data-selectable]"))},getAdjacentOption:function(t,e){var n=this.$dropdown.find("[data-selectable]"),i=n.index(t)+e;return 0<=i&&i<n.length?n.eq(i):I()},getElementWithValue:function(t,e){if(null!=(t=S(t)))for(var n=0,i=e.length;n<i;n++)if(e[n].getAttribute("data-value")===t)return I(e[n]);return I()},getItem:function(t){return this.getElementWithValue(t,this.$control.children())},addItems:function(t,e){this.buffer=document.createDocumentFragment();for(var n=this.$control[0].childNodes,i=0;i<n.length;i++)this.buffer.appendChild(n[i]);for(var o=I.isArray(t)?t:[t],i=0,s=o.length;i<s;i++)this.isPending=i<s-1,this.addItem(o[i],e);var r=this.$control[0];r.insertBefore(this.buffer,r.firstChild),this.buffer=null},addItem:function(a,l){n(this,l?[]:["change"],function(){var t,e,n,i,o,s=this,r=s.settings.mode;a=S(a),-1===s.items.indexOf(a)?s.options.hasOwnProperty(a)&&("single"===r&&s.clear(l),"multi"===r&&s.isFull()||(t=I(s.render("item",s.options[a])),o=s.isFull(),s.items.splice(s.caretPos,0,a),s.insertAtCaret(t),s.isPending&&(o||!s.isFull())||s.refreshState(),s.isSetup&&(n=s.$dropdown_content.find("[data-selectable]"),s.isPending||(e=s.getOption(a),i=s.getAdjacentOption(e,1).attr("data-value"),s.refreshOptions(s.isFocused&&"single"!==r),i&&s.setActiveOption(s.getOption(i))),!n.length||s.isFull()?s.close():s.isPending||s.positionDropdown(),s.updatePlaceholder(),s.trigger("item_add",a,t),s.isPending||s.updateOriginalInput({silent:l})))):"single"===r&&s.close()})},removeItem:function(t,e){var n,i,o=this,s=t instanceof I?t:o.getItem(t);t=S(s.attr("data-value")),-1!==(n=o.items.indexOf(t))&&(s.remove(),s.hasClass("active")&&(i=o.$activeItems.indexOf(s[0]),o.$activeItems.splice(i,1)),o.items.splice(n,1),o.lastQuery=null,!o.settings.persist&&o.userOptions.hasOwnProperty(t)&&o.removeOption(t,e),n<o.caretPos&&o.setCaret(o.caretPos-1),o.refreshState(),o.updatePlaceholder(),o.updateOriginalInput({silent:e}),o.positionDropdown(),o.trigger("item_remove",t,s))},createItem:function(t,n){var i=this,o=i.caretPos;t=t||I.trim(i.$control_input.val()||"");var s=arguments[arguments.length-1];if("function"!=typeof s&&(s=function(){}),"boolean"!=typeof n&&(n=!0),!i.canCreate(t))return s(),!1;i.lock();var e,r,a="function"==typeof i.settings.create?this.settings.create:function(t){var e={};return e[i.settings.labelField]=t,e[i.settings.valueField]=t,e},l=(r=!(e=function(t){if(i.unlock(),!t||"object"!=typeof t)return s();var e=S(t[i.settings.valueField]);if("string"!=typeof e)return s();i.setTextboxValue(""),i.addOption(t),i.setCaret(o),i.addItem(e),i.refreshOptions(n&&"single"!==i.settings.mode),s(t)}),function(){r||(r=!0,e.apply(this,arguments))}),p=a.apply(this,[t,l]);return void 0!==p&&l(p),!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 t=this,e=t.isFull(),n=t.isLocked;t.$wrapper.toggleClass("rtl",t.rtl),t.$control.toggleClass("focus",t.isFocused).toggleClass("disabled",t.isDisabled).toggleClass("required",t.isRequired).toggleClass("invalid",t.isInvalid).toggleClass("locked",n).toggleClass("full",e).toggleClass("not-full",!e).toggleClass("input-active",t.isFocused&&!t.isInputHidden).toggleClass("dropdown-active",t.isOpen).toggleClass("has-options",!I.isEmptyObject(t.options)).toggleClass("has-items",0<t.items.length),t.$control_input.data("grow",!e&&!n)},isFull:function(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems},updateOriginalInput:function(t){var e,n,i,o,s=this;if(t=t||{},1===s.tagType){for(i=[],e=0,n=s.items.length;e<n;e++)o=s.options[s.items[e]][s.settings.labelField]||"",i.push('<option value="'+a(s.items[e])+'" selected="selected">'+a(o)+"</option>");i.length||this.$input.attr("multiple")||i.push('<option value="" selected="selected"></option>'),s.$input.html(i.join(""))}else s.$input.val(s.getValue()),s.$input.attr("value",s.$input.val());s.isSetup&&(t.silent||s.trigger("change",s.$input.val()))},updatePlaceholder:function(){var t;this.settings.placeholder&&(t=this.$control_input,this.items.length?t.removeAttr("placeholder"):t.attr("placeholder",this.settings.placeholder),t.triggerHandler("update",{force:!0}))},open:function(){var t=this;t.isLocked||t.isOpen||"multi"===t.settings.mode&&t.isFull()||(t.focus(),t.isOpen=!0,t.refreshState(),t.$dropdown.css({visibility:"hidden",display:"block"}),t.positionDropdown(),t.$dropdown.css({visibility:"visible"}),t.trigger("dropdown_open",t.$dropdown))},close:function(){var t=this,e=t.isOpen;"single"===t.settings.mode&&t.items.length&&(t.hideInput(),t.isBlurring||t.$control_input.blur()),t.isOpen=!1,t.$dropdown.hide(),t.setActiveOption(null),t.refreshState(),e&&t.trigger("dropdown_close",t.$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){var e=this;e.items.length&&(e.$control.children(":not(input)").remove(),e.items=[],e.lastQuery=null,e.setCaret(0),e.setActiveItem(null),e.updatePlaceholder(),e.updateOriginalInput({silent:t}),e.refreshState(),e.showInput(),e.trigger("clear"))},insertAtCaret:function(t){var e=Math.min(this.caretPos,this.items.length),n=t[0],i=this.buffer||this.$control[0];0===e?i.insertBefore(n,i.firstChild):i.insertBefore(n,i.childNodes[e]),this.setCaret(e+1)},deleteSelection:function(t){var e,n,i,o,s,r,a,l=this,p=t&&8===t.keyCode?-1:1,d=g(l.$control_input[0]);if(l.$activeOption&&!l.settings.hideSelected&&(s=l.getAdjacentOption(l.$activeOption,-1).attr("data-value")),i=[],l.$activeItems.length){for(a=l.$control.children(".active:"+(0<p?"last":"first")),o=l.$control.children(":not(input)").index(a),0<p&&o++,e=0,n=l.$activeItems.length;e<n;e++)i.push(I(l.$activeItems[e]).attr("data-value"));t&&(t.preventDefault(),t.stopPropagation())}else(l.isFocused||"single"===l.settings.mode)&&l.items.length&&(p<0&&0===d.start&&0===d.length?i.push(l.items[l.caretPos-1]):0<p&&d.start===l.$control_input.val().length&&i.push(l.items[l.caretPos]));if(!i.length||"function"==typeof l.settings.onDelete&&!1===l.settings.onDelete.apply(l,[i]))return!1;for(void 0!==o&&l.setCaret(o);i.length;)l.removeItem(i.pop());return l.showInput(),l.positionDropdown(),l.refreshOptions(!0),s&&(r=l.getOption(s)).length&&l.setActiveOption(r),!0},advanceSelection:function(t,e){var n,i,o,s,r,a=this;0!==t&&(a.rtl&&(t*=-1),n=0<t?"last":"first",i=g(a.$control_input[0]),a.isFocused&&!a.isInputHidden?(s=a.$control_input.val().length,(t<0?0!==i.start||0!==i.length:i.start!==s)||s||a.advanceCaret(t,e)):(r=a.$control.children(".active:"+n)).length&&(o=a.$control.children(":not(input)").index(r),a.setActiveItem(null),a.setCaret(0<t?o+1:o)))},advanceCaret:function(t,e){var n,i,o=this;0!==t&&(n=0<t?"next":"prev",o.isShiftDown?(i=o.$control_input[n]()).length&&(o.hideInput(),o.setActiveItem(i),e&&e.preventDefault()):o.setCaret(o.caretPos+t))},setCaret:function(t){var e=this;if(t="single"===e.settings.mode?e.items.length:Math.max(0,Math.min(e.items.length,t)),!e.isPending)for(var n,i=e.$control.children(":not(input)"),o=0,s=i.length;o<s;o++)n=I(i[o]).detach(),o<t?e.$control_input.before(n):e.$control.append(n);e.caretPos=t},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(){var t=this;t.$input.prop("disabled",!1),t.$control_input.prop("disabled",!1).prop("tabindex",t.tabIndex),t.isDisabled=!1,t.unlock()},destroy:function(){var t=this,e=t.eventNS,n=t.revertSettings;t.trigger("destroy"),t.off(),t.$wrapper.remove(),t.$dropdown.remove(),t.$input.html("").append(n.$children).removeAttr("tabindex").removeClass("selectized").attr({tabindex:n.tabindex}).show(),t.$control_input.removeData("grow"),t.$input.removeData("selectize"),0==--y.count&&y.$testInput&&(y.$testInput.remove(),y.$testInput=void 0),I(window).off(e),I(document).off(e),I(document.body).off(e),delete t.$input[0].selectize},render:function(t,e){var n,i,o="",s=!1,r=this;return"option"!==t&&"item"!==t||(s=!!(n=S(e[r.settings.valueField]))),s&&(p(r.renderCache[t])||(r.renderCache[t]={}),r.renderCache[t].hasOwnProperty(n))?r.renderCache[t][n]:(o=I(r.settings.render[t].apply(this,[e,a])),"option"===t||"option_create"===t?e[r.settings.disabledField]||o.attr("data-selectable",""):"optgroup"===t&&(i=e[r.settings.optgroupValueField]||"",o.attr("data-group",i),e[r.settings.disabledField]&&o.attr("data-disabled","")),"option"!==t&&"item"!==t||o.attr("data-value",n||""),s&&(r.renderCache[t][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))}}),y.count=0,y.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:{}},I.fn.selectize=function(o){function s(t,r){function a(t){var e=c&&t.attr(c);return"string"==typeof e&&e.length?JSON.parse(e):null}function l(t,e){t=I(t);var n,i,o=S(t.val());(o||d.allowEmptyOption)&&(p.hasOwnProperty(o)?e&&((n=p[o][f])?I.isArray(n)?n.push(e):p[o][f]=[n,e]:p[o][f]=e):((i=a(t)||{})[u]=i[u]||t.text(),i[h]=i[h]||o,i[g]=i[g]||t.prop("disabled"),i[f]=i[f]||e,p[o]=i,s.push(i),t.is(":selected")&&r.items.push(o)))}var e,n,i,o,s=r.options,p={};for(r.maxItems=t.attr("multiple")?null:1,e=0,n=(o=t.children()).length;e<n;e++)"optgroup"===(i=o[e].tagName.toLowerCase())?function(t){var e,n,i,o,s;for((i=(t=I(t)).attr("label"))&&((o=a(t)||{})[v]=i,o[m]=i,o[g]=t.prop("disabled"),r.optgroups.push(o)),e=0,n=(s=I("option",t)).length;e<n;e++)l(s[e],i)}(o[e]):"option"===i&&l(o[e])}var r=I.fn.selectize.defaults,d=I.extend({},r,o),c=d.dataAttr,u=d.labelField,h=d.valueField,g=d.disabledField,f=d.optgroupField,v=d.optgroupLabelField,m=d.optgroupValueField;return this.each(function(){var t,e,n,i;this.selectize||(t=I(this),e=this.tagName.toLowerCase(),(n=t.attr("placeholder")||t.attr("data-placeholder"))||d.allowEmptyOption||(n=t.children('option[value=""]').text()),("select"===e?s:function(t,e){var n,i,o,s,r=t.attr(c);if(r)for(e.options=JSON.parse(r),n=0,i=e.options.length;n<i;n++)e.items.push(e.options[n][h]);else{var a=I.trim(t.val()||"");if(!d.allowEmptyOption&&!a.length)return;for(n=0,i=(o=a.split(d.delimiter)).length;n<i;n++)(s={})[u]=o[n],s[h]=o[n],e.options.push(s);e.items=o}})(t,i={placeholder:n,options:[],optgroups:[],items:[]}),new y(t,I.extend(!0,{},r,i,o)))})},I.fn.selectize.defaults=y.defaults,I.fn.selectize.support={validity:F},y}); | ||
!function(e,t){"function"==typeof define&&define.amd?define(["jquery","sifter","microplugin"],t):"object"==typeof exports?module.exports=t(require("jquery"),require("sifter"),require("microplugin")):e.Selectize=t(e.jQuery,e.Sifter,e.MicroPlugin)}(this,function(I,c,e){"use strict";I.fn.removeHighlight=function(){return this.find("span.highlight").each(function(){this.parentNode.firstChild.nodeName;var e=this.parentNode;e.replaceChild(this.firstChild,this),e.normalize()}).end()};function i(){}i.prototype={on:function(e,t){this._events=this._events||{},this._events[e]=this._events[e]||[],this._events[e].push(t)},off:function(e,t){var n=arguments.length;return 0===n?delete this._events:1===n?delete this._events[e]:(this._events=this._events||{},void(e in this._events!=!1&&this._events[e].splice(this._events[e].indexOf(t),1)))},trigger:function(e){if(this._events=this._events||{},e in this._events!=!1)for(var t=0;t<this._events[e].length;t++)this._events[e][t].apply(this,Array.prototype.slice.call(arguments,1))}},i.mixin=function(e){for(var t=["on","off","trigger"],n=0;n<t.length;n++)e.prototype[t[n]]=i.prototype[t[n]]};function d(e){return void 0!==e}function x(e){return null==e?null:"boolean"==typeof e?e?"1":"0":e+""}function a(e){return(e+"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function n(t,n,e){var i,o=t.trigger,s={};for(i in t.trigger=function(){var e=arguments[0];if(-1===n.indexOf(e))return o.apply(t,arguments);s[e]=arguments},e.apply(t,[]),t.trigger=o,s)s.hasOwnProperty(i)&&o.apply(t,s[i])}function g(e){var t,n,i={};return"selectionStart"in e?(i.start=e.selectionStart,i.length=e.selectionEnd-i.start):document.selection&&(e.focus(),t=document.selection.createRange(),n=document.selection.createRange().text.length,t.moveStart("character",-e.value.length),i.start=t.text.length-n,i.length=n),i}function C(u){function e(e,t){var n,i,o,s,r,a,l,d,p,c;t=t||{},(e=e||window.event||{}).metaKey||e.altKey||!t.force&&!1===u.data("grow")||(c=u.val(),e.type&&"keydown"===e.type.toLowerCase()&&(i=48<=(n=e.keyCode)&&n<=57||65<=n&&n<=90||96<=n&&n<=111||186<=n&&n<=222||32===n,46===n||8===n?(l=g(u[0])).length?c=c.substring(0,l.start)+c.substring(l.start+l.length):8===n&&l.start?c=c.substring(0,l.start-1)+c.substring(l.start+1):46===n&&void 0!==l.start&&(c=c.substring(0,l.start)+c.substring(l.start+1)):i&&(r=e.shiftKey,a=String.fromCharCode(e.keyCode),c+=a=r?a.toUpperCase():a.toLowerCase())),o=u.attr("placeholder"),!c&&o&&(c=o),p=u,(s=((d=c)?(y.$testInput||(y.$testInput=I("<span />").css({position:"absolute",top:-99999,left:-99999,width:"auto",padding:0,whiteSpace:"pre"}).appendTo("body")),y.$testInput.text(d),function(e,t,n){var i,o,s={};if(n)for(i=0,o=n.length;i<o;i++)s[n[i]]=e.css(n[i]);else s=e.css();t.css(s)}(p,y.$testInput,["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"]),y.$testInput.width()):0)+4)!==h&&(h=s,u.width(s),u.triggerHandler("resize")))}var h=null;u.on("keydown keyup update blur",e),e()}var $=/Mac/.test(navigator.userAgent),b=$?91:17,S=$?18:17,_=!/android/i.test(window.navigator.userAgent)&&!!document.createElement("input").validity,t={before:function(e,t,n){var i=e[t];e[t]=function(){return n.apply(e,arguments),i.apply(e,arguments)}},after:function(t,e,n){var i=t[e];t[e]=function(){var e=i.apply(t,arguments);return n.apply(t,arguments),e}}},y=function(e,t){var n,i,o=this,s=e[0];s.selectize=o;var r,a,l,d,p=window.getComputedStyle&&window.getComputedStyle(s,null);if(d=(d=p?p.getPropertyValue("direction"):s.currentStyle&&s.currentStyle.direction)||e.parents("[dir]:first").attr("dir")||"",I.extend(o,{order:0,settings:t,$input:e,tabIndex:e.attr("tabindex")||"",tagType:"select"===s.tagName.toLowerCase()?1:2,rtl:/rtl/i.test(d),eventNS:".selectize"+ ++y.count,highlightedValue:null,isBlurring:!1,isOpen:!1,isDisabled:!1,isRequired:e.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===t.loadThrottle?o.onSearchChange:(r=o.onSearchChange,a=t.loadThrottle,function(){var e=this,t=arguments;window.clearTimeout(l),l=window.setTimeout(function(){r.apply(e,t)},a)})}),o.sifter=new c(this.options,{diacritics:t.diacritics}),o.settings.options){for(n=0,i=o.settings.options.length;n<i;n++)o.registerOption(o.settings.options[n]);delete o.settings.options}if(o.settings.optgroups){for(n=0,i=o.settings.optgroups.length;n<i;n++)o.registerOptionGroup(o.settings.optgroups[n]);delete o.settings.optgroups}o.settings.mode=o.settings.mode||(1===o.settings.maxItems?"single":"multi"),"boolean"!=typeof o.settings.hideSelected&&(o.settings.hideSelected="multi"===o.settings.mode),o.initializePlugins(o.settings.plugins),o.setupCallbacks(),o.setupTemplates(),o.setup()};return i.mixin(y),void 0!==e?e.mixin(y):function(e,t){t=t||{};console.error("Selectize: "+e),t.explanation&&(console.group&&console.group(),console.error(t.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.'}),I.extend(y.prototype,{setup:function(){var e,t,n,i,o,s,r,a=this,l=a.settings,d=a.eventNS,p=I(window),c=I(document),u=a.$input,h=a.settings.mode,g=u.attr("class")||"",f=I("<div>").addClass(l.wrapperClass).addClass(g).addClass(h),v=I("<div>").addClass(l.inputClass).addClass("items").appendTo(f),m=I('<input type="text" autocomplete="off" />').appendTo(v).attr("tabindex",u.is(":disabled")?"-1":a.tabIndex),y=I(l.dropdownParent||f),w=I("<div>").addClass(l.dropdownClass).addClass(h).hide().appendTo(y),O=I("<div>").addClass(l.dropdownContentClass).appendTo(w);(t=u.attr("id"))&&(m.attr("id",t+"-selectized"),I("label[for='"+t+"']").attr("for",t+"-selectized")),a.settings.copyClassesToDropdown&&w.addClass(g),f.css({width:u[0].style.width}),a.plugins.names.length&&(e="plugin-"+a.plugins.names.join(" plugin-"),f.addClass(e),w.addClass(e)),(null===l.maxItems||1<l.maxItems)&&1===a.tagType&&u.attr("multiple","multiple"),a.settings.placeholder&&m.attr("placeholder",l.placeholder),!a.settings.splitOn&&a.settings.delimiter&&(n=a.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),a.settings.splitOn=new RegExp("\\s*"+n+"+\\s*")),u.attr("autocorrect")&&m.attr("autocorrect",u.attr("autocorrect")),u.attr("autocapitalize")&&m.attr("autocapitalize",u.attr("autocapitalize")),m[0].type=u[0].type,a.$wrapper=f,a.$control=v,a.$control_input=m,a.$dropdown=w,a.$dropdown_content=O,w.on("mouseenter mousedown click","[data-disabled]>[data-selectable]",function(e){e.stopImmediatePropagation()}),w.on("mouseenter","[data-selectable]",function(){return a.onOptionHover.apply(a,arguments)}),w.on("mousedown click","[data-selectable]",function(){return a.onOptionSelect.apply(a,arguments)}),o="mousedown",s="*:not(input)",r=function(){return a.onItemSelect.apply(a,arguments)},(i=v).on(o,s,function(e){for(var t=e.target;t&&t.parentNode!==i[0];)t=t.parentNode;return e.currentTarget=t,r.apply(this,[e])}),C(m),v.on({mousedown:function(){return a.onMouseDown.apply(a,arguments)},click:function(){return a.onClick.apply(a,arguments)}}),m.on({mousedown:function(e){e.stopPropagation()},keydown:function(){return a.onKeyDown.apply(a,arguments)},keyup:function(){return a.onKeyUp.apply(a,arguments)},keypress:function(){return a.onKeyPress.apply(a,arguments)},resize:function(){a.positionDropdown.apply(a,[])},blur:function(){return a.onBlur.apply(a,arguments)},focus:function(){return a.ignoreBlur=!1,a.onFocus.apply(a,arguments)},paste:function(){return a.onPaste.apply(a,arguments)}}),c.on("keydown"+d,function(e){a.isCmdDown=e[$?"metaKey":"ctrlKey"],a.isCtrlDown=e[$?"altKey":"ctrlKey"],a.isShiftDown=e.shiftKey}),c.on("keyup"+d,function(e){e.keyCode===S&&(a.isCtrlDown=!1),16===e.keyCode&&(a.isShiftDown=!1),e.keyCode===b&&(a.isCmdDown=!1)}),c.on("mousedown"+d,function(e){if(a.isFocused){if(e.target===a.$dropdown[0]||e.target.parentNode===a.$dropdown[0])return!1;a.$control.has(e.target).length||e.target===a.$control[0]||a.blur(e.target)}}),p.on(["scroll"+d,"resize"+d].join(" "),function(){a.isOpen&&a.positionDropdown.apply(a,arguments)}),p.on("mousemove"+d,function(){a.ignoreHover=!1}),this.revertSettings={$children:u.children().detach(),tabindex:u.attr("tabindex")},u.attr("tabindex",-1).hide().after(a.$wrapper),I.isArray(l.items)&&(a.setValue(l.items),delete l.items),_&&u.on("invalid"+d,function(e){e.preventDefault(),a.isInvalid=!0,a.refreshState()}),a.updateOriginalInput(),a.refreshItems(),a.refreshState(),a.updatePlaceholder(),a.isSetup=!0,u.is(":disabled")&&a.disable(),a.on("change",this.onChange),u.data("selectize",a),u.addClass("selectized"),a.trigger("initialize"),!0===l.preload&&a.onSearchChange("")},setupTemplates:function(){var n=this.settings.labelField,i=this.settings.optgroupLabelField,e={optgroup:function(e){return'<div class="optgroup">'+e.html+"</div>"},optgroup_header:function(e,t){return'<div class="optgroup-header">'+t(e[i])+"</div>"},option:function(e,t){return'<div class="option">'+t(e[n])+"</div>"},item:function(e,t){return'<div class="item">'+t(e[n])+"</div>"},option_create:function(e,t){return'<div class="create">Add <strong>'+t(e.input)+"</strong>…</div>"}};this.settings.render=I.extend({},e,this.settings.render)},setupCallbacks:function(){var e,t,n={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(e in n)n.hasOwnProperty(e)&&(t=this.settings[n[e]])&&this.on(e,t)},onClick:function(e){this.isFocused&&this.isOpen||(this.focus(),e.preventDefault())},onMouseDown:function(e){var t=this,n=e.isDefaultPrevented();I(e.target);if(t.isFocused){if(e.target!==t.$control_input[0])return"single"===t.settings.mode?t.isOpen?t.close():t.open():n||t.setActiveItem(null),!1}else n||window.setTimeout(function(){t.focus()},0)},onChange:function(){this.$input.trigger("change")},onPaste:function(e){var o=this;o.isFull()||o.isInputHidden||o.isLocked?e.preventDefault():o.settings.splitOn&&setTimeout(function(){var e=o.$control_input.val();if(e.match(o.settings.splitOn))for(var t=I.trim(e).split(o.settings.splitOn),n=0,i=t.length;n<i;n++)o.createItem(t[n])},0)},onKeyPress:function(e){if(this.isLocked)return e&&e.preventDefault();var t=String.fromCharCode(e.keyCode||e.which);return this.settings.create&&"multi"===this.settings.mode&&t===this.settings.delimiter?(this.createItem(),e.preventDefault(),!1):void 0},onKeyDown:function(e){e.target,this.$control_input[0];var t,n,i=this;if(i.isLocked)9!==e.keyCode&&e.preventDefault();else{switch(e.keyCode){case 65:if(i.isCmdDown)return void i.selectAll();break;case 27:return void(i.isOpen&&(e.preventDefault(),e.stopPropagation(),i.close()));case 78:if(!e.ctrlKey||e.altKey)break;case 40:return!i.isOpen&&i.hasOptions?i.open():i.$activeOption&&(i.ignoreHover=!0,(t=i.getAdjacentOption(i.$activeOption,1)).length&&i.setActiveOption(t,!0,!0)),void e.preventDefault();case 80:if(!e.ctrlKey||e.altKey)break;case 38:return i.$activeOption&&(i.ignoreHover=!0,(n=i.getAdjacentOption(i.$activeOption,-1)).length&&i.setActiveOption(n,!0,!0)),void e.preventDefault();case 13:return void(i.isOpen&&i.$activeOption&&(i.onOptionSelect({currentTarget:i.$activeOption}),e.preventDefault()));case 37:return void i.advanceSelection(-1,e);case 39:return void i.advanceSelection(1,e);case 9:return i.settings.selectOnTab&&i.isOpen&&i.$activeOption&&(i.onOptionSelect({currentTarget:i.$activeOption}),i.isFull()||e.preventDefault()),void(i.settings.create&&i.createItem()&&e.preventDefault());case 8:case 46:return void i.deleteSelection(e)}!i.isFull()&&!i.isInputHidden||($?e.metaKey:e.ctrlKey)||e.preventDefault()}},onKeyUp:function(e){var t=this;if(t.isLocked)return e&&e.preventDefault();var n=t.$control_input.val()||"";t.lastValue!==n&&(t.lastValue=n,t.onSearchChange(n),t.refreshOptions(),t.trigger("type",n))},onSearchChange:function(t){var n=this,i=n.settings.load;i&&(n.loadedSearches.hasOwnProperty(t)||(n.loadedSearches[t]=!0,n.load(function(e){i.apply(n,[t,e])})))},onFocus:function(e){var t=this,n=t.isFocused;if(t.isDisabled)return t.blur(),e&&e.preventDefault(),!1;t.ignoreFocus||(t.isFocused=!0,"focus"===t.settings.preload&&t.onSearchChange(""),n||t.trigger("focus"),t.$activeItems.length||(t.showInput(),t.setActiveItem(null),t.refreshOptions(!!t.settings.openOnFocus)),t.refreshState())},onBlur:function(e,t){var n=this;if(n.isFocused&&(n.isFocused=!1,!n.ignoreFocus)){if(!n.ignoreBlur&&document.activeElement===n.$dropdown_content[0])return n.ignoreBlur=!0,void n.onFocus(e);var i=function(){n.close(),n.setTextboxValue(""),n.setActiveItem(null),n.setActiveOption(null),n.setCaret(n.items.length),n.refreshState(),t&&t.focus&&t.focus(),n.isBlurring=!1,n.ignoreFocus=!1,n.trigger("blur")};n.isBlurring=!0,n.ignoreFocus=!0,n.settings.create&&n.settings.createOnBlur?n.createItem(null,!1,i):i()}},onOptionHover:function(e){this.ignoreHover||this.setActiveOption(e.currentTarget,!1)},onOptionSelect:function(e){var t,n,i=this;e.preventDefault&&(e.preventDefault(),e.stopPropagation()),(n=I(e.currentTarget)).hasClass("create")?i.createItem(null,function(){i.settings.closeAfterSelect&&i.close()}):void 0!==(t=n.attr("data-value"))&&(i.lastQuery=null,i.setTextboxValue(""),i.addItem(t),i.settings.closeAfterSelect?i.close():!i.settings.hideSelected&&e.type&&/mouse/.test(e.type)&&i.setActiveOption(i.getOption(t)))},onItemSelect:function(e){this.isLocked||"multi"===this.settings.mode&&(e.preventDefault(),this.setActiveItem(e.currentTarget,e))},load:function(e){var t=this,n=t.$wrapper.addClass(t.settings.loadingClass);t.loading++,e.apply(t,[function(e){t.loading=Math.max(t.loading-1,0),e&&e.length&&(t.addOption(e),t.refreshOptions(t.isFocused&&!t.isInputHidden)),t.loading||n.removeClass(t.settings.loadingClass),t.trigger("load",e)}])},setTextboxValue:function(e){var t=this.$control_input;t.val()!==e&&(t.val(e).triggerHandler("update"),this.lastValue=e)},getValue:function(){return 1===this.tagType&&this.$input.attr("multiple")?this.items:this.items.join(this.settings.delimiter)},setValue:function(e,t){n(this,t?[]:["change"],function(){this.clear(t),this.addItems(e,t)})},setActiveItem:function(e,t){var n,i,o,s,r,a,l,d,p=this;if("single"!==p.settings.mode){if(!(e=I(e)).length)return I(p.$activeItems).removeClass("active"),p.$activeItems=[],void(p.isFocused&&p.showInput());if("mousedown"===(n=t&&t.type.toLowerCase())&&p.isShiftDown&&p.$activeItems.length){for(d=p.$control.children(".active:last"),s=Array.prototype.indexOf.apply(p.$control[0].childNodes,[d[0]]),(r=Array.prototype.indexOf.apply(p.$control[0].childNodes,[e[0]]))<s&&(l=s,s=r,r=l),i=s;i<=r;i++)a=p.$control[0].childNodes[i],-1===p.$activeItems.indexOf(a)&&(I(a).addClass("active"),p.$activeItems.push(a));t.preventDefault()}else"mousedown"===n&&p.isCtrlDown||"keydown"===n&&this.isShiftDown?e.hasClass("active")?(o=p.$activeItems.indexOf(e[0]),p.$activeItems.splice(o,1),e.removeClass("active")):p.$activeItems.push(e.addClass("active")[0]):(I(p.$activeItems).removeClass("active"),p.$activeItems=[e.addClass("active")[0]]);p.hideInput(),this.isFocused||p.focus()}},setActiveOption:function(e,t,n){var i,o,s,r,a,l=this;l.$activeOption&&l.$activeOption.removeClass("active"),l.$activeOption=null,(e=I(e)).length&&(l.$activeOption=e.addClass("active"),!t&&d(t)||(i=l.$dropdown_content.height(),o=l.$activeOption.outerHeight(!0),t=l.$dropdown_content.scrollTop()||0,a=(r=s=l.$activeOption.offset().top-l.$dropdown_content.offset().top+t)-i+o,i+t<s+o?l.$dropdown_content.stop().animate({scrollTop:a},n?l.settings.scrollDuration:0):s<t&&l.$dropdown_content.stop().animate({scrollTop:r},n?l.settings.scrollDuration:0)))},selectAll:function(){var e=this;"single"!==e.settings.mode&&(e.$activeItems=Array.prototype.slice.apply(e.$control.children(":not(input)").addClass("active")),e.$activeItems.length&&(e.hideInput(),e.close()),e.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 e=this;e.isDisabled||(e.ignoreFocus=!0,e.$control_input[0].focus(),window.setTimeout(function(){e.ignoreFocus=!1,e.onFocus()},0))},blur:function(e){this.$control_input[0].blur(),this.onBlur(null,e)},getScoreFunction:function(e){return this.sifter.getScoreFunction(e,this.getSearchOptions())},getSearchOptions:function(){var e=this.settings,t=e.sortField;return"string"==typeof t&&(t=[{field:t}]),{fields:e.searchField,conjunction:e.searchConjunction,sort:t,nesting:e.nesting}},search:function(e){var t,n,i,o=this,s=o.settings,r=this.getSearchOptions();if(s.score&&"function"!=typeof(i=o.settings.score.apply(this,[e])))throw new Error('Selectize "score" setting must be a function that returns a function');if(e!==o.lastQuery?(o.lastQuery=e,n=o.sifter.search(e,I.extend(r,{score:i})),o.currentResults=n):n=I.extend(!0,{},o.currentResults),s.hideSelected)for(t=n.items.length-1;0<=t;t--)-1!==o.items.indexOf(x(n.items[t].id))&&n.items.splice(t,1);return n},refreshOptions:function(e){var t,n,i,o,s,r,a,l,d,p,c,u,h,g,f;void 0===e&&(e=!0);var v,m,y=this,w=I.trim(y.$control_input.val()),O=y.search(w),C=y.$dropdown_content,$=y.$activeOption&&x(y.$activeOption.attr("data-value")),b=O.items.length;for("number"==typeof y.settings.maxOptions&&(b=Math.min(b,y.settings.maxOptions)),o={},s=[],t=0;t<b;t++)for(r=y.options[O.items[t].id],a=y.render("option",r),l=r[y.settings.optgroupField]||"",n=0,i=(d=I.isArray(l)?l:[l])&&d.length;n<i;n++)l=d[n],y.optgroups.hasOwnProperty(l)||(l=""),o.hasOwnProperty(l)||(o[l]=document.createDocumentFragment(),s.push(l)),o[l].appendChild(a);for(this.settings.lockOptgroupOrder&&s.sort(function(e,t){return(y.optgroups[e].$order||0)-(y.optgroups[t].$order||0)}),p=document.createDocumentFragment(),t=0,b=s.length;t<b;t++)l=s[t],y.optgroups.hasOwnProperty(l)&&o[l].childNodes.length?((c=document.createDocumentFragment()).appendChild(y.render("optgroup_header",y.optgroups[l])),c.appendChild(o[l]),p.appendChild(y.render("optgroup",I.extend({},y.optgroups[l],{html:(v=c,m=void 0,(m=document.createElement("div")).appendChild(v.cloneNode(!0)),m.innerHTML),dom:c})))):p.appendChild(o[l]);if(C.html(p),y.settings.highlight&&(C.removeHighlight(),O.query.length&&O.tokens.length))for(t=0,b=O.tokens.length;t<b;t++)!function(e,t){if("string"!=typeof t||t.length){var l="string"==typeof t?new RegExp(t,"i"):t,d=function(e){var t=0;if(3===e.nodeType){var n,i,o,s,r=e.data.search(l);0<=r&&0<e.data.length&&(n=e.data.match(l),(i=document.createElement("span")).className="highlight",(o=e.splitText(r)).splitText(n[0].length),s=o.cloneNode(!0),i.appendChild(s),o.parentNode.replaceChild(i,o),t=1)}else if(1===e.nodeType&&e.childNodes&&!/(script|style)/i.test(e.tagName)&&("highlight"!==e.className||"SPAN"!==e.tagName))for(var a=0;a<e.childNodes.length;++a)a+=d(e.childNodes[a]);return t};e.each(function(){d(this)})}}(C,O.tokens[t].regex);if(!y.settings.hideSelected)for(t=0,b=y.items.length;t<b;t++)y.getOption(y.items[t]).addClass("selected");(u=y.canCreate(w))&&(C.prepend(y.render("option_create",{input:w})),f=I(C[0].childNodes[0])),y.hasOptions=0<O.items.length||u,y.hasOptions?(0<O.items.length?((g=$&&y.getOption($))&&g.length?h=g:"single"===y.settings.mode&&y.items.length&&(h=y.getOption(y.items[0])),h&&h.length||(h=f&&!y.settings.addPrecedence?y.getAdjacentOption(f,1):C.find("[data-selectable]:first"))):h=f,y.setActiveOption(h),e&&!y.isOpen&&y.open()):(y.setActiveOption(null),e&&y.isOpen&&y.close())},addOption:function(e){var t,n,i,o=this;if(I.isArray(e))for(t=0,n=e.length;t<n;t++)o.addOption(e[t]);else(i=o.registerOption(e))&&(o.userOptions[i]=!0,o.lastQuery=null,o.trigger("option_add",i,e))},registerOption:function(e){var t=x(e[this.settings.valueField]);return null!=t&&!this.options.hasOwnProperty(t)&&(e.$order=e.$order||++this.order,this.options[t]=e,t)},registerOptionGroup:function(e){var t=x(e[this.settings.optgroupValueField]);return!!t&&(e.$order=e.$order||++this.order,this.optgroups[t]=e,t)},addOptionGroup:function(e,t){t[this.settings.optgroupValueField]=e,(e=this.registerOptionGroup(t))&&this.trigger("optgroup_add",e,t)},removeOptionGroup:function(e){this.optgroups.hasOwnProperty(e)&&(delete this.optgroups[e],this.renderCache={},this.trigger("optgroup_remove",e))},clearOptionGroups:function(){this.optgroups={},this.renderCache={},this.trigger("optgroup_clear")},updateOption:function(e,t){var n,i,o,s,r,a,l,d=this;if(e=x(e),o=x(t[d.settings.valueField]),null!==e&&d.options.hasOwnProperty(e)){if("string"!=typeof o)throw new Error("Value must be set in option data");l=d.options[e].$order,o!==e&&(delete d.options[e],-1!==(s=d.items.indexOf(e))&&d.items.splice(s,1,o)),t.$order=t.$order||l,d.options[o]=t,r=d.renderCache.item,a=d.renderCache.option,r&&(delete r[e],delete r[o]),a&&(delete a[e],delete a[o]),-1!==d.items.indexOf(o)&&(n=d.getItem(e),i=I(d.render("item",t)),n.hasClass("active")&&i.addClass("active"),n.replaceWith(i)),d.lastQuery=null,d.isOpen&&d.refreshOptions(!1)}},removeOption:function(e,t){var n=this;e=x(e);var i=n.renderCache.item,o=n.renderCache.option;i&&delete i[e],o&&delete o[e],delete n.userOptions[e],delete n.options[e],n.lastQuery=null,n.trigger("option_remove",e),n.removeItem(e,t)},clearOptions:function(){var n=this;n.loadedSearches={},n.userOptions={},n.renderCache={};var i=n.options;I.each(n.options,function(e,t){-1==n.items.indexOf(e)&&delete i[e]}),n.options=n.sifter.items=i,n.lastQuery=null,n.trigger("option_clear")},getOption:function(e){return this.getElementWithValue(e,this.$dropdown_content.find("[data-selectable]"))},getAdjacentOption:function(e,t){var n=this.$dropdown.find("[data-selectable]"),i=n.index(e)+t;return 0<=i&&i<n.length?n.eq(i):I()},getElementWithValue:function(e,t){if(null!=(e=x(e)))for(var n=0,i=t.length;n<i;n++)if(t[n].getAttribute("data-value")===e)return I(t[n]);return I()},getItem:function(e){return this.getElementWithValue(e,this.$control.children())},addItems:function(e,t){this.buffer=document.createDocumentFragment();for(var n=this.$control[0].childNodes,i=0;i<n.length;i++)this.buffer.appendChild(n[i]);for(var o=I.isArray(e)?e:[e],i=0,s=o.length;i<s;i++)this.isPending=i<s-1,this.addItem(o[i],t);var r=this.$control[0];r.insertBefore(this.buffer,r.firstChild),this.buffer=null},addItem:function(a,l){n(this,l?[]:["change"],function(){var e,t,n,i,o,s=this,r=s.settings.mode;a=x(a),-1===s.items.indexOf(a)?s.options.hasOwnProperty(a)&&("single"===r&&s.clear(l),"multi"===r&&s.isFull()||(e=I(s.render("item",s.options[a])),o=s.isFull(),s.items.splice(s.caretPos,0,a),s.insertAtCaret(e),s.isPending&&(o||!s.isFull())||s.refreshState(),s.isSetup&&(n=s.$dropdown_content.find("[data-selectable]"),s.isPending||(t=s.getOption(a),i=s.getAdjacentOption(t,1).attr("data-value"),s.refreshOptions(s.isFocused&&"single"!==r),i&&s.setActiveOption(s.getOption(i))),!n.length||s.isFull()?s.close():s.isPending||s.positionDropdown(),s.updatePlaceholder(),s.trigger("item_add",a,e),s.isPending||s.updateOriginalInput({silent:l})))):"single"===r&&s.close()})},removeItem:function(e,t){var n,i,o=this,s=e instanceof I?e:o.getItem(e);e=x(s.attr("data-value")),-1!==(n=o.items.indexOf(e))&&(s.remove(),s.hasClass("active")&&(i=o.$activeItems.indexOf(s[0]),o.$activeItems.splice(i,1)),o.items.splice(n,1),o.lastQuery=null,!o.settings.persist&&o.userOptions.hasOwnProperty(e)&&o.removeOption(e,t),n<o.caretPos&&o.setCaret(o.caretPos-1),o.refreshState(),o.updatePlaceholder(),o.updateOriginalInput({silent:t}),o.positionDropdown(),o.trigger("item_remove",e,s))},createItem:function(e,n){var i=this,o=i.caretPos;e=e||I.trim(i.$control_input.val()||"");var s=arguments[arguments.length-1];if("function"!=typeof s&&(s=function(){}),"boolean"!=typeof n&&(n=!0),!i.canCreate(e))return s(),!1;i.lock();var t,r,a="function"==typeof i.settings.create?this.settings.create:function(e){var t={};return t[i.settings.labelField]=e,t[i.settings.valueField]=e,t},l=(r=!(t=function(e){if(i.unlock(),!e||"object"!=typeof e)return s();var t=x(e[i.settings.valueField]);if("string"!=typeof t)return s();i.setTextboxValue(""),i.addOption(e),i.setCaret(o),i.addItem(t),i.refreshOptions(n&&"single"!==i.settings.mode),s(e)}),function(){r||(r=!0,t.apply(this,arguments))}),d=a.apply(this,[e,l]);return void 0!==d&&l(d),!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 e=!this.items.length;this.isInvalid=e,this.$control_input.prop("required",e),this.$input.prop("required",!e)},refreshClasses:function(){var e=this,t=e.isFull(),n=e.isLocked;e.$wrapper.toggleClass("rtl",e.rtl),e.$control.toggleClass("focus",e.isFocused).toggleClass("disabled",e.isDisabled).toggleClass("required",e.isRequired).toggleClass("invalid",e.isInvalid).toggleClass("locked",n).toggleClass("full",t).toggleClass("not-full",!t).toggleClass("input-active",e.isFocused&&!e.isInputHidden).toggleClass("dropdown-active",e.isOpen).toggleClass("has-options",!I.isEmptyObject(e.options)).toggleClass("has-items",0<e.items.length),e.$control_input.data("grow",!t&&!n)},isFull:function(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems},updateOriginalInput:function(e){var t,n,i,o,s=this;if(e=e||{},1===s.tagType){for(i=[],t=0,n=s.items.length;t<n;t++)o=s.options[s.items[t]][s.settings.labelField]||"",i.push('<option value="'+a(s.items[t])+'" selected="selected">'+a(o)+"</option>");i.length||this.$input.attr("multiple")||i.push('<option value="" selected="selected"></option>'),s.$input.html(i.join(""))}else s.$input.val(s.getValue()),s.$input.attr("value",s.$input.val());s.isSetup&&(e.silent||s.trigger("change",s.$input.val()))},updatePlaceholder:function(){var e;this.settings.placeholder&&(e=this.$control_input,this.items.length?e.removeAttr("placeholder"):e.attr("placeholder",this.settings.placeholder),e.triggerHandler("update",{force:!0}))},open:function(){var e=this;e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.focus(),e.isOpen=!0,e.refreshState(),e.$dropdown.css({visibility:"hidden",display:"block"}),e.positionDropdown(),e.$dropdown.css({visibility:"visible"}),e.trigger("dropdown_open",e.$dropdown))},close:function(){var e=this,t=e.isOpen;"single"===e.settings.mode&&e.items.length&&(e.hideInput(),e.isBlurring||e.$control_input.blur()),e.isOpen=!1,e.$dropdown.hide(),e.setActiveOption(null),e.refreshState(),t&&e.trigger("dropdown_close",e.$dropdown)},positionDropdown:function(){var e=this.$control,t="body"===this.settings.dropdownParent?e.offset():e.position();t.top+=e.outerHeight(!0),this.$dropdown.css({width:e[0].getBoundingClientRect().width,top:t.top,left:t.left})},clear:function(e){var t=this;t.items.length&&(t.$control.children(":not(input)").remove(),t.items=[],t.lastQuery=null,t.setCaret(0),t.setActiveItem(null),t.updatePlaceholder(),t.updateOriginalInput({silent:e}),t.refreshState(),t.showInput(),t.trigger("clear"))},insertAtCaret:function(e){var t=Math.min(this.caretPos,this.items.length),n=e[0],i=this.buffer||this.$control[0];0===t?i.insertBefore(n,i.firstChild):i.insertBefore(n,i.childNodes[t]),this.setCaret(t+1)},deleteSelection:function(e){var t,n,i,o,s,r,a,l=this,d=e&&8===e.keyCode?-1:1,p=g(l.$control_input[0]);if(l.$activeOption&&!l.settings.hideSelected&&(s=l.getAdjacentOption(l.$activeOption,-1).attr("data-value")),i=[],l.$activeItems.length){for(a=l.$control.children(".active:"+(0<d?"last":"first")),o=l.$control.children(":not(input)").index(a),0<d&&o++,t=0,n=l.$activeItems.length;t<n;t++)i.push(I(l.$activeItems[t]).attr("data-value"));e&&(e.preventDefault(),e.stopPropagation())}else(l.isFocused||"single"===l.settings.mode)&&l.items.length&&(d<0&&0===p.start&&0===p.length?i.push(l.items[l.caretPos-1]):0<d&&p.start===l.$control_input.val().length&&i.push(l.items[l.caretPos]));if(!i.length||"function"==typeof l.settings.onDelete&&!1===l.settings.onDelete.apply(l,[i]))return!1;for(void 0!==o&&l.setCaret(o);i.length;)l.removeItem(i.pop());return l.showInput(),l.positionDropdown(),l.refreshOptions(!0),s&&(r=l.getOption(s)).length&&l.setActiveOption(r),!0},advanceSelection:function(e,t){var n,i,o,s,r,a=this;0!==e&&(a.rtl&&(e*=-1),n=0<e?"last":"first",i=g(a.$control_input[0]),a.isFocused&&!a.isInputHidden?(s=a.$control_input.val().length,(e<0?0!==i.start||0!==i.length:i.start!==s)||s||a.advanceCaret(e,t)):(r=a.$control.children(".active:"+n)).length&&(o=a.$control.children(":not(input)").index(r),a.setActiveItem(null),a.setCaret(0<e?o+1:o)))},advanceCaret:function(e,t){var n,i,o=this;0!==e&&(n=0<e?"next":"prev",o.isShiftDown?(i=o.$control_input[n]()).length&&(o.hideInput(),o.setActiveItem(i),t&&t.preventDefault()):o.setCaret(o.caretPos+e))},setCaret:function(e){var t=this;if(e="single"===t.settings.mode?t.items.length:Math.max(0,Math.min(t.items.length,e)),!t.isPending)for(var n,i=t.$control.children(":not(input)"),o=0,s=i.length;o<s;o++)n=I(i[o]).detach(),o<e?t.$control_input.before(n):t.$control.append(n);t.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(){var e=this;e.$input.prop("disabled",!1),e.$control_input.prop("disabled",!1).prop("tabindex",e.tabIndex),e.isDisabled=!1,e.unlock()},destroy:function(){var e=this,t=e.eventNS,n=e.revertSettings;e.trigger("destroy"),e.off(),e.$wrapper.remove(),e.$dropdown.remove(),e.$input.html("").append(n.$children).removeAttr("tabindex").removeClass("selectized").attr({tabindex:n.tabindex}).show(),e.$control_input.removeData("grow"),e.$input.removeData("selectize"),0==--y.count&&y.$testInput&&(y.$testInput.remove(),y.$testInput=void 0),I(window).off(t),I(document).off(t),I(document.body).off(t),delete e.$input[0].selectize},render:function(e,t){var n,i,o="",s=!1,r=this;return"option"!==e&&"item"!==e||(s=!!(n=x(t[r.settings.valueField]))),s&&(d(r.renderCache[e])||(r.renderCache[e]={}),r.renderCache[e].hasOwnProperty(n))?r.renderCache[e][n]:(o=I(r.settings.render[e].apply(this,[t,a])),"option"===e||"option_create"===e?t[r.settings.disabledField]||o.attr("data-selectable",""):"optgroup"===e&&(i=t[r.settings.optgroupValueField]||"",o.attr("data-group",i),t[r.settings.disabledField]&&o.attr("data-disabled","")),"option"!==e&&"item"!==e||o.attr("data-value",n||""),s&&(r.renderCache[e][n]=o[0]),o[0])},clearCache:function(e){void 0===e?this.renderCache={}:delete this.renderCache[e]},canCreate:function(e){if(!this.settings.create)return!1;var t=this.settings.createFilter;return e.length&&("function"!=typeof t||t.apply(this,[e]))&&("string"!=typeof t||new RegExp(t).test(e))&&(!(t instanceof RegExp)||t.test(e))}}),y.count=0,y.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:{}},I.fn.selectize=function(o){function s(e,r){function a(e){var t=c&&e.attr(c);return"string"==typeof t&&t.length?JSON.parse(t):null}function l(e,t){e=I(e);var n,i,o=x(e.val());(o||p.allowEmptyOption)&&(d.hasOwnProperty(o)?t&&((n=d[o][f])?I.isArray(n)?n.push(t):d[o][f]=[n,t]:d[o][f]=t):((i=a(e)||{})[u]=i[u]||e.text(),i[h]=i[h]||o,i[g]=i[g]||e.prop("disabled"),i[f]=i[f]||t,d[o]=i,s.push(i),e.is(":selected")&&r.items.push(o)))}var t,n,i,o,s=r.options,d={};for(r.maxItems=e.attr("multiple")?null:1,t=0,n=(o=e.children()).length;t<n;t++)"optgroup"===(i=o[t].tagName.toLowerCase())?function(e){var t,n,i,o,s;for((i=(e=I(e)).attr("label"))&&((o=a(e)||{})[v]=i,o[m]=i,o[g]=e.prop("disabled"),r.optgroups.push(o)),t=0,n=(s=I("option",e)).length;t<n;t++)l(s[t],i)}(o[t]):"option"===i&&l(o[t])}var r=I.fn.selectize.defaults,p=I.extend({},r,o),c=p.dataAttr,u=p.labelField,h=p.valueField,g=p.disabledField,f=p.optgroupField,v=p.optgroupLabelField,m=p.optgroupValueField;return this.each(function(){var e,t,n,i;this.selectize||(e=I(this),t=this.tagName.toLowerCase(),(n=e.attr("placeholder")||e.attr("data-placeholder"))||p.allowEmptyOption||(n=e.children('option[value=""]').text()),("select"===t?s:function(e,t){var n,i,o,s,r=e.attr(c);if(r)for(t.options=JSON.parse(r),n=0,i=t.options.length;n<i;n++)t.items.push(t.options[n][h]);else{var a=I.trim(e.val()||"");if(!p.allowEmptyOption&&!a.length)return;for(n=0,i=(o=a.split(p.delimiter)).length;n<i;n++)(s={})[u]=o[n],s[h]=o[n],t.options.push(s);t.items=o}})(e,i={placeholder:n,options:[],optgroups:[],items:[]}),new y(e,I.extend(!0,{},r,i,o)))})},I.fn.selectize.defaults=y.defaults,I.fn.selectize.support={validity:_},y.define("drag_drop",function(e){if(!I.fn.sortable)throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');var i,t,n,o;"multi"===this.settings.mode&&((i=this).lock=(t=i.lock,function(){var e=i.$control.data("sortable");return e&&e.disable(),t.apply(i,arguments)}),i.unlock=(n=i.unlock,function(){var e=i.$control.data("sortable");return e&&e.enable(),n.apply(i,arguments)}),i.setup=(o=i.setup,function(){o.apply(this,arguments);var n=i.$control.sortable({items:"[data-value]",forcePlaceholderSize:!0,disabled:i.isLocked,start:function(e,t){t.placeholder.css("width",t.helper.css("width")),n.css({overflow:"visible"})},stop:function(){n.css({overflow:"hidden"});var e=i.$activeItems?i.$activeItems.slice():null,t=[];n.children("[data-value]").each(function(){t.push(I(this).attr("data-value"))}),i.setValue(t),i.setActiveItem(e)}})}))}),y.define("dropdown_header",function(e){var t,n=this;e=I.extend({title:"Untitled",headerClass:"selectize-dropdown-header",titleRowClass:"selectize-dropdown-header-title",labelClass:"selectize-dropdown-header-label",closeClass:"selectize-dropdown-header-close",html:function(e){return'<div class="'+e.headerClass+'"><div class="'+e.titleRowClass+'"><span class="'+e.labelClass+'">'+e.title+'</span><a href="javascript:void(0)" class="'+e.closeClass+'">×</a></div></div>'}},e),n.setup=(t=n.setup,function(){t.apply(n,arguments),n.$dropdown_header=I(e.html(e)),n.$dropdown.prepend(n.$dropdown_header)})}),y.define("optgroup_columns",function(a){var s,l=this;a=I.extend({equalizeWidth:!0,equalizeHeight:!0},a),this.getAdjacentOption=function(e,t){var n=e.closest("[data-group]").find("[data-selectable]"),i=n.index(e)+t;return 0<=i&&i<n.length?n.eq(i):I()},this.onKeyDown=(s=l.onKeyDown,function(e){var t,n,i,o;return!this.isOpen||37!==e.keyCode&&39!==e.keyCode?s.apply(this,arguments):(l.ignoreHover=!0,t=(o=this.$activeOption.closest("[data-group]")).find("[data-selectable]").index(this.$activeOption),void((n=(i=(o=37===e.keyCode?o.prev("[data-group]"):o.next("[data-group]")).find("[data-selectable]")).eq(Math.min(i.length-1,t))).length&&this.setActiveOption(n)))});function e(){var e,t,n,i,o,s=I("[data-group]",l.$dropdown_content),r=s.length;if(r&&l.$dropdown_content.width()){if(a.equalizeHeight){for(e=t=0;e<r;e++)t=Math.max(t,s.eq(e).height());s.css({height:t})}a.equalizeWidth&&(o=l.$dropdown_content.innerWidth()-d(),n=Math.round(o/r),s.css({width:n}),1<r&&(i=o-n*(r-1),s.eq(r-1).css({width:i})))}}var d=function(){var e,t=d.width,n=document;return void 0===t&&((e=n.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>',e=e.firstChild,n.body.appendChild(e),t=d.width=e.offsetWidth-e.clientWidth,n.body.removeChild(e)),t};(a.equalizeHeight||a.equalizeWidth)&&(t.after(this,"positionDropdown",e),t.after(this,"refreshOptions",e))}),y.define("remove_button",function(e){e=I.extend({label:"×",title:"Remove",className:"remove",append:!0},e);var s,t,n,i,r;"single"!==this.settings.mode?(i=s=this,r='<a href="javascript:void(0)" class="'+(t=e).className+'" tabindex="-1" title="'+a(t.title)+'">'+t.label+"</a>",s.setup=(n=i.setup,function(){var o;t.append&&(o=i.settings.render.item,i.settings.render.item=function(e){return t=o.apply(s,arguments),n=r,i=t.search(/(<\/[^>]+>\s*)$/),t.substring(0,i)+n+t.substring(i);var t,n,i}),n.apply(s,arguments),s.$control.on("click","."+t.className,function(e){var t;e.preventDefault(),i.isLocked||(t=I(e.currentTarget).parent(),i.setActiveItem(t),i.deleteSelection()&&i.setCaret(i.items.length))})})):function(o,t){t.className="remove-single";var n,s=o,r='<a href="javascript:void(0)" class="'+t.className+'" tabindex="-1" title="'+a(t.title)+'">'+t.label+"</a>";o.setup=(n=s.setup,function(){var e,i;t.append&&(e=I(s.$input.context).attr("id"),I("#"+e),i=s.settings.render.item,s.settings.render.item=function(e){return t=i.apply(o,arguments),n=r,I("<span>").append(t).append(n);var t,n}),n.apply(o,arguments),o.$control.on("click","."+t.className,function(e){e.preventDefault(),s.isLocked||s.clear()})})}(this,e)}),y.define("restore_on_backspace",function(i){var o,e=this;i.text=i.text||function(e){return e[this.settings.labelField]},this.onKeyDown=(o=e.onKeyDown,function(e){var t,n;return 8===e.keyCode&&""===this.$control_input.val()&&!this.$activeItems.length&&0<=(t=this.caretPos-1)&&t<this.items.length?(n=this.options[this.items[t]],this.deleteSelection(e)&&(this.setTextboxValue(i.text.apply(this,[n])),this.refreshOptions(!0)),void e.preventDefault()):o.apply(this,arguments)})}),y}); |
@@ -1,3 +0,3 @@ | ||
/*! selectize.js - v1.0.1 | https://github.com/selectize/selectize.js | Apache License (v2) */ | ||
/*! selectize.js - v1.0.2 | https://github.com/selectize/selectize.js | Apache License (v2) */ | ||
!function(t,e){"function"==typeof define&&define.amd?define("sifter",e):"object"==typeof exports?module.exports=e():t.Sifter=e()}(this,function(){function t(t,e){this.items=t,this.settings=e||{diacritics:!0}}t.prototype.tokenize=function(t){if(!(t=a(String(t||"").toLowerCase()))||!t.length)return[];for(var e,n,i=[],o=t.split(/ +/),s=0,r=o.length;s<r;s++){if(e=l(o[s]),this.settings.diacritics)for(n in p)p.hasOwnProperty(n)&&(e=e.replace(new RegExp(n,"g"),p[n]));i.push({string:o[s],regex:new RegExp(e,"i")})}return i},t.prototype.iterator=function(t,e){var n=r(t)?Array.prototype.forEach||function(t){for(var e=0,n=this.length;e<n;e++)t(this[e],e,this)}:function(t){for(var e in this)this.hasOwnProperty(e)&&t(this[e],e,this)};n.apply(t,[e])},t.prototype.getScoreFunction=function(t,e){var o,s,r,a;t=this.prepareSearch(t,e),s=t.tokens,o=t.options.fields,r=s.length,a=t.options.nesting;function l(t,e){var n,i;return!t||-1===(i=(t=String(t||"")).search(e.regex))?0:(n=e.string.length/t.length,0===i&&(n+=.5),n)}var p,u=(p=o.length)?1===p?function(t,e){return l(g(e,o[0],a),t)}:function(t,e){for(var n=0,i=0;n<p;n++)i+=l(g(e,o[n],a),t);return i/p}:function(){return 0};return r?1===r?function(t){return u(s[0],t)}:"and"===t.options.conjunction?function(t){for(var e,n=0,i=0;n<r;n++){if((e=u(s[n],t))<=0)return 0;i+=e}return i/r}:function(t){for(var e=0,n=0;e<r;e++)n+=u(s[e],t);return n/r}:function(){return 0}},t.prototype.getSortFunction=function(t,n){var e,i,o,s,r,a,l,p=this,u=!(t=p.prepareSearch(t,n)).query&&n.sort_empty||n.sort,c=function(t,e){return"$score"===t?e.score:g(p.items[e.id],t,n.nesting)},d=[];if(u)for(e=0,i=u.length;e<i;e++)!t.query&&"$score"===u[e].field||d.push(u[e]);if(t.query){for(l=!0,e=0,i=d.length;e<i;e++)if("$score"===d[e].field){l=!1;break}l&&d.unshift({field:"$score",direction:"desc"})}else for(e=0,i=d.length;e<i;e++)if("$score"===d[e].field){d.splice(e,1);break}for(a=[],e=0,i=d.length;e<i;e++)a.push("desc"===d[e].direction?-1:1);return(s=d.length)?1===s?(o=d[0].field,r=a[0],function(t,e){return r*h(c(o,t),c(o,e))}):function(t,e){for(var n,i,o=0;o<s;o++)if(i=d[o].field,n=a[o]*h(c(i,t),c(i,e)))return n;return 0}:null},t.prototype.prepareSearch=function(t,e){if("object"==typeof t)return t;var n=(e=s({},e)).fields,i=e.sort,o=e.sort_empty;return n&&!r(n)&&(e.fields=[n]),i&&!r(i)&&(e.sort=[i]),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,n){var i,e,o,s=this,r=this.prepareSearch(t,n);return n=r.options,t=r.query,o=n.score||s.getScoreFunction(r),t.length?s.iterator(s.items,function(t,e){i=o(t),(!1===n.filter||0<i)&&r.items.push({score:i,id:e})}):s.iterator(s.items,function(t,e){r.items.push({score:1,id:e})}),(e=s.getSortFunction(r,n))&&r.items.sort(e),r.total=r.items.length,"number"==typeof n.limit&&(r.items=r.items.slice(0,n.limit)),r};var h=function(t,e){return"number"==typeof t&&"number"==typeof e?e<t?1:t<e?-1:0:(t=n(String(t||"")),(e=n(String(e||"")))<t?1:t<e?-1:0)},s=function(t,e){for(var n,i,o=1,s=arguments.length;o<s;o++)if(i=arguments[o])for(n in i)i.hasOwnProperty(n)&&(t[n]=i[n]);return t},g=function(t,e,n){if(t&&e){if(!n)return t[e];for(var i=e.split(".");i.length&&(t=t[i.shift()]););return t}},a=function(t){return(t+"").replace(/^\s+|\s+$|/g,"")},l=function(t){return(t+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")},r=Array.isArray||"undefined"!=typeof $&&$.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},p={a:"[aḀḁĂăÂâǍǎȺⱥȦȧẠạÄäÀàÁáĀāÃãÅåąĄÃąĄ]",b:"[b␢βΒB฿𐌁ᛒ]",c:"[cĆćĈĉČčĊċC̄c̄ÇçḈḉȻȼƇƈɕᴄCc]",d:"[dĎďḊḋḐḑḌḍḒḓḎḏĐđD̦d̦ƉɖƊɗƋƌᵭᶁᶑȡᴅDdð]",e:"[eÉéÈèÊêḘḙĚěĔĕẼẽḚḛẺẻĖėËëĒēȨȩĘęᶒɆɇȄȅẾếỀềỄễỂểḜḝḖḗḔḕȆȇẸẹỆệⱸᴇEeɘǝƏƐε]",f:"[fƑƒḞḟ]",g:"[gɢ₲ǤǥĜĝĞğĢģƓɠĠġ]",h:"[hĤĥĦħḨḩẖẖḤḥḢḣɦʰǶƕ]",i:"[iÍíÌìĬĭÎîǏǐÏïḮḯĨĩĮįĪīỈỉȈȉȊȋỊịḬḭƗɨɨ̆ᵻᶖİiIıɪIi]",j:"[jȷĴĵɈɉʝɟʲ]",k:"[kƘƙꝀꝁḰḱǨǩḲḳḴḵκϰ₭]",l:"[lŁłĽľĻļĹĺḶḷḸḹḼḽḺḻĿŀȽƚⱠⱡⱢɫɬᶅɭȴʟLl]",n:"[nŃńǸǹŇňÑñṄṅŅņṆṇṊṋṈṉN̈n̈ƝɲȠƞᵰᶇɳȵɴNnŊŋ]",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ŹźẐẑŽžŻżẒẓẔẕƵƶ]"},n=function(){var t,e,n,i,o="",s={};for(n in p)if(p.hasOwnProperty(n))for(o+=i=p[n].substring(2,p[n].length-1),t=0,e=i.length;t<e;t++)s[i.charAt(t)]=n;var r=new RegExp("["+o+"]","g");return function(t){return t.replace(r,function(t){return s[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(i){i.plugins={},i.prototype.initializePlugins=function(t){var e,n,i,o=[];if(this.plugins={names:[],settings:{},requested:{},loaded:{}},s.isArray(t))for(e=0,n=t.length;e<n;e++)"string"==typeof t[e]?o.push(t[e]):(this.plugins.settings[t[e].name]=t[e].options,o.push(t[e].name));else if(t)for(i in t)t.hasOwnProperty(i)&&(this.plugins.settings[i]=t[i],o.push(i));for(;o.length;)this.require(o.shift())},i.prototype.loadPlugin=function(t){var e=this.plugins,n=i.plugins[t];if(!i.plugins.hasOwnProperty(t))throw new Error('Unable to find "'+t+'" plugin');e.requested[t]=!0,e.loaded[t]=n.fn.apply(this,[this.plugins.settings[t]||{}]),e.names.push(t)},i.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]},i.define=function(t,e){i.plugins[t]={name:t,fn:e}}}},s={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(S,c,t){"use strict";S.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()};function i(){}i.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 n=arguments.length;return 0===n?delete this._events:1===n?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))}},i.mixin=function(t){for(var e=["on","off","trigger"],n=0;n<e.length;n++)t.prototype[e[n]]=i.prototype[e[n]]};function p(t){return void 0!==t}function I(t){return null==t?null:"boolean"==typeof t?t?"1":"0":t+""}function a(t){return(t+"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function n(e,n,t){var i,o=e.trigger,s={};for(i in e.trigger=function(){var t=arguments[0];if(-1===n.indexOf(t))return o.apply(e,arguments);s[t]=arguments},t.apply(e,[]),e.trigger=o,s)s.hasOwnProperty(i)&&o.apply(e,s[i])}function g(t){var e,n,i={};return"selectionStart"in t?(i.start=t.selectionStart,i.length=t.selectionEnd-i.start):document.selection&&(t.focus(),e=document.selection.createRange(),n=document.selection.createRange().text.length,e.moveStart("character",-t.value.length),i.start=e.text.length-n,i.length=n),i}function C(d){function t(t,e){var n,i,o,s,r,a,l,p,u,c;e=e||{},(t=t||window.event||{}).metaKey||t.altKey||!e.force&&!1===d.data("grow")||(c=d.val(),t.type&&"keydown"===t.type.toLowerCase()&&(i=48<=(n=t.keyCode)&&n<=57||65<=n&&n<=90||96<=n&&n<=111||186<=n&&n<=222||32===n,46===n||8===n?(l=g(d[0])).length?c=c.substring(0,l.start)+c.substring(l.start+l.length):8===n&&l.start?c=c.substring(0,l.start-1)+c.substring(l.start+1):46===n&&void 0!==l.start&&(c=c.substring(0,l.start)+c.substring(l.start+1)):i&&(r=t.shiftKey,a=String.fromCharCode(t.keyCode),c+=a=r?a.toUpperCase():a.toLowerCase())),o=d.attr("placeholder"),!c&&o&&(c=o),u=d,(s=((p=c)?(y.$testInput||(y.$testInput=S("<span />").css({position:"absolute",top:-99999,left:-99999,width:"auto",padding:0,whiteSpace:"pre"}).appendTo("body")),y.$testInput.text(p),function(t,e,n){var i,o,s={};if(n)for(i=0,o=n.length;i<o;i++)s[n[i]]=t.css(n[i]);else s=t.css();e.css(s)}(u,y.$testInput,["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"]),y.$testInput.width()):0)+4)!==h&&(h=s,d.width(s),d.triggerHandler("resize")))}var h=null;d.on("keydown keyup update blur",t),t()}var $=/Mac/.test(navigator.userAgent),b=$?91:17,x=$?18:17,F=!/android/i.test(window.navigator.userAgent)&&!!document.createElement("input").validity,y=function(t,e){var n,i,o=this,s=t[0];s.selectize=o;var r,a,l,p,u=window.getComputedStyle&&window.getComputedStyle(s,null);if(p=(p=u?u.getPropertyValue("direction"):s.currentStyle&&s.currentStyle.direction)||t.parents("[dir]:first").attr("dir")||"",S.extend(o,{order:0,settings:e,$input:t,tabIndex:t.attr("tabindex")||"",tagType:"select"===s.tagName.toLowerCase()?1:2,rtl:/rtl/i.test(p),eventNS:".selectize"+ ++y.count,highlightedValue:null,isBlurring:!1,isOpen:!1,isDisabled:!1,isRequired:t.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===e.loadThrottle?o.onSearchChange:(r=o.onSearchChange,a=e.loadThrottle,function(){var t=this,e=arguments;window.clearTimeout(l),l=window.setTimeout(function(){r.apply(t,e)},a)})}),o.sifter=new c(this.options,{diacritics:e.diacritics}),o.settings.options){for(n=0,i=o.settings.options.length;n<i;n++)o.registerOption(o.settings.options[n]);delete o.settings.options}if(o.settings.optgroups){for(n=0,i=o.settings.optgroups.length;n<i;n++)o.registerOptionGroup(o.settings.optgroups[n]);delete o.settings.optgroups}o.settings.mode=o.settings.mode||(1===o.settings.maxItems?"single":"multi"),"boolean"!=typeof o.settings.hideSelected&&(o.settings.hideSelected="multi"===o.settings.mode),o.initializePlugins(o.settings.plugins),o.setupCallbacks(),o.setupTemplates(),o.setup()};return i.mixin(y),void 0!==t?t.mixin(y):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.'}),S.extend(y.prototype,{setup:function(){var t,e,n,i,o,s,r,a=this,l=a.settings,p=a.eventNS,u=S(window),c=S(document),d=a.$input,h=a.settings.mode,g=d.attr("class")||"",f=S("<div>").addClass(l.wrapperClass).addClass(g).addClass(h),v=S("<div>").addClass(l.inputClass).addClass("items").appendTo(f),m=S('<input type="text" autocomplete="off" />').appendTo(v).attr("tabindex",d.is(":disabled")?"-1":a.tabIndex),y=S(l.dropdownParent||f),O=S("<div>").addClass(l.dropdownClass).addClass(h).hide().appendTo(y),w=S("<div>").addClass(l.dropdownContentClass).appendTo(O);(e=d.attr("id"))&&(m.attr("id",e+"-selectized"),S("label[for='"+e+"']").attr("for",e+"-selectized")),a.settings.copyClassesToDropdown&&O.addClass(g),f.css({width:d[0].style.width}),a.plugins.names.length&&(t="plugin-"+a.plugins.names.join(" plugin-"),f.addClass(t),O.addClass(t)),(null===l.maxItems||1<l.maxItems)&&1===a.tagType&&d.attr("multiple","multiple"),a.settings.placeholder&&m.attr("placeholder",l.placeholder),!a.settings.splitOn&&a.settings.delimiter&&(n=a.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),a.settings.splitOn=new RegExp("\\s*"+n+"+\\s*")),d.attr("autocorrect")&&m.attr("autocorrect",d.attr("autocorrect")),d.attr("autocapitalize")&&m.attr("autocapitalize",d.attr("autocapitalize")),m[0].type=d[0].type,a.$wrapper=f,a.$control=v,a.$control_input=m,a.$dropdown=O,a.$dropdown_content=w,O.on("mouseenter mousedown click","[data-disabled]>[data-selectable]",function(t){t.stopImmediatePropagation()}),O.on("mouseenter","[data-selectable]",function(){return a.onOptionHover.apply(a,arguments)}),O.on("mousedown click","[data-selectable]",function(){return a.onOptionSelect.apply(a,arguments)}),o="mousedown",s="*:not(input)",r=function(){return a.onItemSelect.apply(a,arguments)},(i=v).on(o,s,function(t){for(var e=t.target;e&&e.parentNode!==i[0];)e=e.parentNode;return t.currentTarget=e,r.apply(this,[t])}),C(m),v.on({mousedown:function(){return a.onMouseDown.apply(a,arguments)},click:function(){return a.onClick.apply(a,arguments)}}),m.on({mousedown:function(t){t.stopPropagation()},keydown:function(){return a.onKeyDown.apply(a,arguments)},keyup:function(){return a.onKeyUp.apply(a,arguments)},keypress:function(){return a.onKeyPress.apply(a,arguments)},resize:function(){a.positionDropdown.apply(a,[])},blur:function(){return a.onBlur.apply(a,arguments)},focus:function(){return a.ignoreBlur=!1,a.onFocus.apply(a,arguments)},paste:function(){return a.onPaste.apply(a,arguments)}}),c.on("keydown"+p,function(t){a.isCmdDown=t[$?"metaKey":"ctrlKey"],a.isCtrlDown=t[$?"altKey":"ctrlKey"],a.isShiftDown=t.shiftKey}),c.on("keyup"+p,function(t){t.keyCode===x&&(a.isCtrlDown=!1),16===t.keyCode&&(a.isShiftDown=!1),t.keyCode===b&&(a.isCmdDown=!1)}),c.on("mousedown"+p,function(t){if(a.isFocused){if(t.target===a.$dropdown[0]||t.target.parentNode===a.$dropdown[0])return!1;a.$control.has(t.target).length||t.target===a.$control[0]||a.blur(t.target)}}),u.on(["scroll"+p,"resize"+p].join(" "),function(){a.isOpen&&a.positionDropdown.apply(a,arguments)}),u.on("mousemove"+p,function(){a.ignoreHover=!1}),this.revertSettings={$children:d.children().detach(),tabindex:d.attr("tabindex")},d.attr("tabindex",-1).hide().after(a.$wrapper),S.isArray(l.items)&&(a.setValue(l.items),delete l.items),F&&d.on("invalid"+p,function(t){t.preventDefault(),a.isInvalid=!0,a.refreshState()}),a.updateOriginalInput(),a.refreshItems(),a.refreshState(),a.updatePlaceholder(),a.isSetup=!0,d.is(":disabled")&&a.disable(),a.on("change",this.onChange),d.data("selectize",a),d.addClass("selectized"),a.trigger("initialize"),!0===l.preload&&a.onSearchChange("")},setupTemplates:function(){var n=this.settings.labelField,i=this.settings.optgroupLabelField,t={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,e){return'<div class="option">'+e(t[n])+"</div>"},item:function(t,e){return'<div class="item">'+e(t[n])+"</div>"},option_create:function(t,e){return'<div class="create">Add <strong>'+e(t.input)+"</strong>…</div>"}};this.settings.render=S.extend({},t,this.settings.render)},setupCallbacks:function(){var t,e,n={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 n)n.hasOwnProperty(t)&&(e=this.settings[n[t]])&&this.on(t,e)},onClick:function(t){this.isFocused&&this.isOpen||(this.focus(),t.preventDefault())},onMouseDown:function(t){var e=this,n=t.isDefaultPrevented();S(t.target);if(e.isFocused){if(t.target!==e.$control_input[0])return"single"===e.settings.mode?e.isOpen?e.close():e.open():n||e.setActiveItem(null),!1}else n||window.setTimeout(function(){e.focus()},0)},onChange:function(){this.$input.trigger("change")},onPaste:function(t){var o=this;o.isFull()||o.isInputHidden||o.isLocked?t.preventDefault():o.settings.splitOn&&setTimeout(function(){var t=o.$control_input.val();if(t.match(o.settings.splitOn))for(var e=S.trim(t).split(o.settings.splitOn),n=0,i=e.length;n<i;n++)o.createItem(e[n])},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];var e,n,i=this;if(i.isLocked)9!==t.keyCode&&t.preventDefault();else{switch(t.keyCode){case 65:if(i.isCmdDown)return void i.selectAll();break;case 27:return void(i.isOpen&&(t.preventDefault(),t.stopPropagation(),i.close()));case 78:if(!t.ctrlKey||t.altKey)break;case 40:return!i.isOpen&&i.hasOptions?i.open():i.$activeOption&&(i.ignoreHover=!0,(e=i.getAdjacentOption(i.$activeOption,1)).length&&i.setActiveOption(e,!0,!0)),void t.preventDefault();case 80:if(!t.ctrlKey||t.altKey)break;case 38:return i.$activeOption&&(i.ignoreHover=!0,(n=i.getAdjacentOption(i.$activeOption,-1)).length&&i.setActiveOption(n,!0,!0)),void t.preventDefault();case 13:return void(i.isOpen&&i.$activeOption&&(i.onOptionSelect({currentTarget:i.$activeOption}),t.preventDefault()));case 37:return void i.advanceSelection(-1,t);case 39:return void i.advanceSelection(1,t);case 9:return i.settings.selectOnTab&&i.isOpen&&i.$activeOption&&(i.onOptionSelect({currentTarget:i.$activeOption}),i.isFull()||t.preventDefault()),void(i.settings.create&&i.createItem()&&t.preventDefault());case 8:case 46:return void i.deleteSelection(t)}!i.isFull()&&!i.isInputHidden||($?t.metaKey:t.ctrlKey)||t.preventDefault()}},onKeyUp:function(t){var e=this;if(e.isLocked)return t&&t.preventDefault();var n=e.$control_input.val()||"";e.lastValue!==n&&(e.lastValue=n,e.onSearchChange(n),e.refreshOptions(),e.trigger("type",n))},onSearchChange:function(e){var n=this,i=n.settings.load;i&&(n.loadedSearches.hasOwnProperty(e)||(n.loadedSearches[e]=!0,n.load(function(t){i.apply(n,[e,t])})))},onFocus:function(t){var e=this,n=e.isFocused;if(e.isDisabled)return e.blur(),t&&t.preventDefault(),!1;e.ignoreFocus||(e.isFocused=!0,"focus"===e.settings.preload&&e.onSearchChange(""),n||e.trigger("focus"),e.$activeItems.length||(e.showInput(),e.setActiveItem(null),e.refreshOptions(!!e.settings.openOnFocus)),e.refreshState())},onBlur:function(t,e){var n=this;if(n.isFocused&&(n.isFocused=!1,!n.ignoreFocus)){if(!n.ignoreBlur&&document.activeElement===n.$dropdown_content[0])return n.ignoreBlur=!0,void n.onFocus(t);var i=function(){n.close(),n.setTextboxValue(""),n.setActiveItem(null),n.setActiveOption(null),n.setCaret(n.items.length),n.refreshState(),e&&e.focus&&e.focus(),n.isBlurring=!1,n.ignoreFocus=!1,n.trigger("blur")};n.isBlurring=!0,n.ignoreFocus=!0,n.settings.create&&n.settings.createOnBlur?n.createItem(null,!1,i):i()}},onOptionHover:function(t){this.ignoreHover||this.setActiveOption(t.currentTarget,!1)},onOptionSelect:function(t){var e,n,i=this;t.preventDefault&&(t.preventDefault(),t.stopPropagation()),(n=S(t.currentTarget)).hasClass("create")?i.createItem(null,function(){i.settings.closeAfterSelect&&i.close()}):void 0!==(e=n.attr("data-value"))&&(i.lastQuery=null,i.setTextboxValue(""),i.addItem(e),i.settings.closeAfterSelect?i.close():!i.settings.hideSelected&&t.type&&/mouse/.test(t.type)&&i.setActiveOption(i.getOption(e)))},onItemSelect:function(t){this.isLocked||"multi"===this.settings.mode&&(t.preventDefault(),this.setActiveItem(t.currentTarget,t))},load:function(t){var e=this,n=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||n.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){n(this,e?[]:["change"],function(){this.clear(e),this.addItems(t,e)})},setActiveItem:function(t,e){var n,i,o,s,r,a,l,p,u=this;if("single"!==u.settings.mode){if(!(t=S(t)).length)return S(u.$activeItems).removeClass("active"),u.$activeItems=[],void(u.isFocused&&u.showInput());if("mousedown"===(n=e&&e.type.toLowerCase())&&u.isShiftDown&&u.$activeItems.length){for(p=u.$control.children(".active:last"),s=Array.prototype.indexOf.apply(u.$control[0].childNodes,[p[0]]),(r=Array.prototype.indexOf.apply(u.$control[0].childNodes,[t[0]]))<s&&(l=s,s=r,r=l),i=s;i<=r;i++)a=u.$control[0].childNodes[i],-1===u.$activeItems.indexOf(a)&&(S(a).addClass("active"),u.$activeItems.push(a));e.preventDefault()}else"mousedown"===n&&u.isCtrlDown||"keydown"===n&&this.isShiftDown?t.hasClass("active")?(o=u.$activeItems.indexOf(t[0]),u.$activeItems.splice(o,1),t.removeClass("active")):u.$activeItems.push(t.addClass("active")[0]):(S(u.$activeItems).removeClass("active"),u.$activeItems=[t.addClass("active")[0]]);u.hideInput(),this.isFocused||u.focus()}},setActiveOption:function(t,e,n){var i,o,s,r,a,l=this;l.$activeOption&&l.$activeOption.removeClass("active"),l.$activeOption=null,(t=S(t)).length&&(l.$activeOption=t.addClass("active"),!e&&p(e)||(i=l.$dropdown_content.height(),o=l.$activeOption.outerHeight(!0),e=l.$dropdown_content.scrollTop()||0,a=(r=s=l.$activeOption.offset().top-l.$dropdown_content.offset().top+e)-i+o,i+e<s+o?l.$dropdown_content.stop().animate({scrollTop:a},n?l.settings.scrollDuration:0):s<e&&l.$dropdown_content.stop().animate({scrollTop:r},n?l.settings.scrollDuration:0)))},selectAll:function(){var t=this;"single"!==t.settings.mode&&(t.$activeItems=Array.prototype.slice.apply(t.$control.children(":not(input)").addClass("active")),t.$activeItems.length&&(t.hideInput(),t.close()),t.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(t){var e,n,i,o=this,s=o.settings,r=this.getSearchOptions();if(s.score&&"function"!=typeof(i=o.settings.score.apply(this,[t])))throw new Error('Selectize "score" setting must be a function that returns a function');if(t!==o.lastQuery?(o.lastQuery=t,n=o.sifter.search(t,S.extend(r,{score:i})),o.currentResults=n):n=S.extend(!0,{},o.currentResults),s.hideSelected)for(e=n.items.length-1;0<=e;e--)-1!==o.items.indexOf(I(n.items[e].id))&&n.items.splice(e,1);return n},refreshOptions:function(t){var e,n,i,o,s,r,a,l,p,u,c,d,h,g,f;void 0===t&&(t=!0);var v,m,y=this,O=S.trim(y.$control_input.val()),w=y.search(O),C=y.$dropdown_content,$=y.$activeOption&&I(y.$activeOption.attr("data-value")),b=w.items.length;for("number"==typeof y.settings.maxOptions&&(b=Math.min(b,y.settings.maxOptions)),o={},s=[],e=0;e<b;e++)for(r=y.options[w.items[e].id],a=y.render("option",r),l=r[y.settings.optgroupField]||"",n=0,i=(p=S.isArray(l)?l:[l])&&p.length;n<i;n++)l=p[n],y.optgroups.hasOwnProperty(l)||(l=""),o.hasOwnProperty(l)||(o[l]=document.createDocumentFragment(),s.push(l)),o[l].appendChild(a);for(this.settings.lockOptgroupOrder&&s.sort(function(t,e){return(y.optgroups[t].$order||0)-(y.optgroups[e].$order||0)}),u=document.createDocumentFragment(),e=0,b=s.length;e<b;e++)l=s[e],y.optgroups.hasOwnProperty(l)&&o[l].childNodes.length?((c=document.createDocumentFragment()).appendChild(y.render("optgroup_header",y.optgroups[l])),c.appendChild(o[l]),u.appendChild(y.render("optgroup",S.extend({},y.optgroups[l],{html:(v=c,m=void 0,(m=document.createElement("div")).appendChild(v.cloneNode(!0)),m.innerHTML),dom:c})))):u.appendChild(o[l]);if(C.html(u),y.settings.highlight&&(C.removeHighlight(),w.query.length&&w.tokens.length))for(e=0,b=w.tokens.length;e<b;e++)!function(t,e){if("string"!=typeof e||e.length){var l="string"==typeof e?new RegExp(e,"i"):e,p=function(t){var e=0;if(3===t.nodeType){var n,i,o,s,r=t.data.search(l);0<=r&&0<t.data.length&&(n=t.data.match(l),(i=document.createElement("span")).className="highlight",(o=t.splitText(r)).splitText(n[0].length),s=o.cloneNode(!0),i.appendChild(s),o.parentNode.replaceChild(i,o),e=1)}else if(1===t.nodeType&&t.childNodes&&!/(script|style)/i.test(t.tagName)&&("highlight"!==t.className||"SPAN"!==t.tagName))for(var a=0;a<t.childNodes.length;++a)a+=p(t.childNodes[a]);return e};t.each(function(){p(this)})}}(C,w.tokens[e].regex);if(!y.settings.hideSelected)for(e=0,b=y.items.length;e<b;e++)y.getOption(y.items[e]).addClass("selected");(d=y.canCreate(O))&&(C.prepend(y.render("option_create",{input:O})),f=S(C[0].childNodes[0])),y.hasOptions=0<w.items.length||d,y.hasOptions?(0<w.items.length?((g=$&&y.getOption($))&&g.length?h=g:"single"===y.settings.mode&&y.items.length&&(h=y.getOption(y.items[0])),h&&h.length||(h=f&&!y.settings.addPrecedence?y.getAdjacentOption(f,1):C.find("[data-selectable]:first"))):h=f,y.setActiveOption(h),t&&!y.isOpen&&y.open()):(y.setActiveOption(null),t&&y.isOpen&&y.close())},addOption:function(t){var e,n,i,o=this;if(S.isArray(t))for(e=0,n=t.length;e<n;e++)o.addOption(t[e]);else(i=o.registerOption(t))&&(o.userOptions[i]=!0,o.lastQuery=null,o.trigger("option_add",i,t))},registerOption:function(t){var e=I(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=I(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(t,e){var n,i,o,s,r,a,l,p=this;if(t=I(t),o=I(e[p.settings.valueField]),null!==t&&p.options.hasOwnProperty(t)){if("string"!=typeof o)throw new Error("Value must be set in option data");l=p.options[t].$order,o!==t&&(delete p.options[t],-1!==(s=p.items.indexOf(t))&&p.items.splice(s,1,o)),e.$order=e.$order||l,p.options[o]=e,r=p.renderCache.item,a=p.renderCache.option,r&&(delete r[t],delete r[o]),a&&(delete a[t],delete a[o]),-1!==p.items.indexOf(o)&&(n=p.getItem(t),i=S(p.render("item",e)),n.hasClass("active")&&i.addClass("active"),n.replaceWith(i)),p.lastQuery=null,p.isOpen&&p.refreshOptions(!1)}},removeOption:function(t,e){var n=this;t=I(t);var i=n.renderCache.item,o=n.renderCache.option;i&&delete i[t],o&&delete o[t],delete n.userOptions[t],delete n.options[t],n.lastQuery=null,n.trigger("option_remove",t),n.removeItem(t,e)},clearOptions:function(){var n=this;n.loadedSearches={},n.userOptions={},n.renderCache={};var i=n.options;S.each(n.options,function(t,e){-1==n.items.indexOf(t)&&delete i[t]}),n.options=n.sifter.items=i,n.lastQuery=null,n.trigger("option_clear")},getOption:function(t){return this.getElementWithValue(t,this.$dropdown_content.find("[data-selectable]"))},getAdjacentOption:function(t,e){var n=this.$dropdown.find("[data-selectable]"),i=n.index(t)+e;return 0<=i&&i<n.length?n.eq(i):S()},getElementWithValue:function(t,e){if(null!=(t=I(t)))for(var n=0,i=e.length;n<i;n++)if(e[n].getAttribute("data-value")===t)return S(e[n]);return S()},getItem:function(t){return this.getElementWithValue(t,this.$control.children())},addItems:function(t,e){this.buffer=document.createDocumentFragment();for(var n=this.$control[0].childNodes,i=0;i<n.length;i++)this.buffer.appendChild(n[i]);for(var o=S.isArray(t)?t:[t],i=0,s=o.length;i<s;i++)this.isPending=i<s-1,this.addItem(o[i],e);var r=this.$control[0];r.insertBefore(this.buffer,r.firstChild),this.buffer=null},addItem:function(a,l){n(this,l?[]:["change"],function(){var t,e,n,i,o,s=this,r=s.settings.mode;a=I(a),-1===s.items.indexOf(a)?s.options.hasOwnProperty(a)&&("single"===r&&s.clear(l),"multi"===r&&s.isFull()||(t=S(s.render("item",s.options[a])),o=s.isFull(),s.items.splice(s.caretPos,0,a),s.insertAtCaret(t),s.isPending&&(o||!s.isFull())||s.refreshState(),s.isSetup&&(n=s.$dropdown_content.find("[data-selectable]"),s.isPending||(e=s.getOption(a),i=s.getAdjacentOption(e,1).attr("data-value"),s.refreshOptions(s.isFocused&&"single"!==r),i&&s.setActiveOption(s.getOption(i))),!n.length||s.isFull()?s.close():s.isPending||s.positionDropdown(),s.updatePlaceholder(),s.trigger("item_add",a,t),s.isPending||s.updateOriginalInput({silent:l})))):"single"===r&&s.close()})},removeItem:function(t,e){var n,i,o=this,s=t instanceof S?t:o.getItem(t);t=I(s.attr("data-value")),-1!==(n=o.items.indexOf(t))&&(s.remove(),s.hasClass("active")&&(i=o.$activeItems.indexOf(s[0]),o.$activeItems.splice(i,1)),o.items.splice(n,1),o.lastQuery=null,!o.settings.persist&&o.userOptions.hasOwnProperty(t)&&o.removeOption(t,e),n<o.caretPos&&o.setCaret(o.caretPos-1),o.refreshState(),o.updatePlaceholder(),o.updateOriginalInput({silent:e}),o.positionDropdown(),o.trigger("item_remove",t,s))},createItem:function(t,n){var i=this,o=i.caretPos;t=t||S.trim(i.$control_input.val()||"");var s=arguments[arguments.length-1];if("function"!=typeof s&&(s=function(){}),"boolean"!=typeof n&&(n=!0),!i.canCreate(t))return s(),!1;i.lock();var e,r,a="function"==typeof i.settings.create?this.settings.create:function(t){var e={};return e[i.settings.labelField]=t,e[i.settings.valueField]=t,e},l=(r=!(e=function(t){if(i.unlock(),!t||"object"!=typeof t)return s();var e=I(t[i.settings.valueField]);if("string"!=typeof e)return s();i.setTextboxValue(""),i.addOption(t),i.setCaret(o),i.addItem(e),i.refreshOptions(n&&"single"!==i.settings.mode),s(t)}),function(){r||(r=!0,e.apply(this,arguments))}),p=a.apply(this,[t,l]);return void 0!==p&&l(p),!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 t=this,e=t.isFull(),n=t.isLocked;t.$wrapper.toggleClass("rtl",t.rtl),t.$control.toggleClass("focus",t.isFocused).toggleClass("disabled",t.isDisabled).toggleClass("required",t.isRequired).toggleClass("invalid",t.isInvalid).toggleClass("locked",n).toggleClass("full",e).toggleClass("not-full",!e).toggleClass("input-active",t.isFocused&&!t.isInputHidden).toggleClass("dropdown-active",t.isOpen).toggleClass("has-options",!S.isEmptyObject(t.options)).toggleClass("has-items",0<t.items.length),t.$control_input.data("grow",!e&&!n)},isFull:function(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems},updateOriginalInput:function(t){var e,n,i,o,s=this;if(t=t||{},1===s.tagType){for(i=[],e=0,n=s.items.length;e<n;e++)o=s.options[s.items[e]][s.settings.labelField]||"",i.push('<option value="'+a(s.items[e])+'" selected="selected">'+a(o)+"</option>");i.length||this.$input.attr("multiple")||i.push('<option value="" selected="selected"></option>'),s.$input.html(i.join(""))}else s.$input.val(s.getValue()),s.$input.attr("value",s.$input.val());s.isSetup&&(t.silent||s.trigger("change",s.$input.val()))},updatePlaceholder:function(){var t;this.settings.placeholder&&(t=this.$control_input,this.items.length?t.removeAttr("placeholder"):t.attr("placeholder",this.settings.placeholder),t.triggerHandler("update",{force:!0}))},open:function(){var t=this;t.isLocked||t.isOpen||"multi"===t.settings.mode&&t.isFull()||(t.focus(),t.isOpen=!0,t.refreshState(),t.$dropdown.css({visibility:"hidden",display:"block"}),t.positionDropdown(),t.$dropdown.css({visibility:"visible"}),t.trigger("dropdown_open",t.$dropdown))},close:function(){var t=this,e=t.isOpen;"single"===t.settings.mode&&t.items.length&&(t.hideInput(),t.isBlurring||t.$control_input.blur()),t.isOpen=!1,t.$dropdown.hide(),t.setActiveOption(null),t.refreshState(),e&&t.trigger("dropdown_close",t.$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){var e=this;e.items.length&&(e.$control.children(":not(input)").remove(),e.items=[],e.lastQuery=null,e.setCaret(0),e.setActiveItem(null),e.updatePlaceholder(),e.updateOriginalInput({silent:t}),e.refreshState(),e.showInput(),e.trigger("clear"))},insertAtCaret:function(t){var e=Math.min(this.caretPos,this.items.length),n=t[0],i=this.buffer||this.$control[0];0===e?i.insertBefore(n,i.firstChild):i.insertBefore(n,i.childNodes[e]),this.setCaret(e+1)},deleteSelection:function(t){var e,n,i,o,s,r,a,l=this,p=t&&8===t.keyCode?-1:1,u=g(l.$control_input[0]);if(l.$activeOption&&!l.settings.hideSelected&&(s=l.getAdjacentOption(l.$activeOption,-1).attr("data-value")),i=[],l.$activeItems.length){for(a=l.$control.children(".active:"+(0<p?"last":"first")),o=l.$control.children(":not(input)").index(a),0<p&&o++,e=0,n=l.$activeItems.length;e<n;e++)i.push(S(l.$activeItems[e]).attr("data-value"));t&&(t.preventDefault(),t.stopPropagation())}else(l.isFocused||"single"===l.settings.mode)&&l.items.length&&(p<0&&0===u.start&&0===u.length?i.push(l.items[l.caretPos-1]):0<p&&u.start===l.$control_input.val().length&&i.push(l.items[l.caretPos]));if(!i.length||"function"==typeof l.settings.onDelete&&!1===l.settings.onDelete.apply(l,[i]))return!1;for(void 0!==o&&l.setCaret(o);i.length;)l.removeItem(i.pop());return l.showInput(),l.positionDropdown(),l.refreshOptions(!0),s&&(r=l.getOption(s)).length&&l.setActiveOption(r),!0},advanceSelection:function(t,e){var n,i,o,s,r,a=this;0!==t&&(a.rtl&&(t*=-1),n=0<t?"last":"first",i=g(a.$control_input[0]),a.isFocused&&!a.isInputHidden?(s=a.$control_input.val().length,(t<0?0!==i.start||0!==i.length:i.start!==s)||s||a.advanceCaret(t,e)):(r=a.$control.children(".active:"+n)).length&&(o=a.$control.children(":not(input)").index(r),a.setActiveItem(null),a.setCaret(0<t?o+1:o)))},advanceCaret:function(t,e){var n,i,o=this;0!==t&&(n=0<t?"next":"prev",o.isShiftDown?(i=o.$control_input[n]()).length&&(o.hideInput(),o.setActiveItem(i),e&&e.preventDefault()):o.setCaret(o.caretPos+t))},setCaret:function(t){var e=this;if(t="single"===e.settings.mode?e.items.length:Math.max(0,Math.min(e.items.length,t)),!e.isPending)for(var n,i=e.$control.children(":not(input)"),o=0,s=i.length;o<s;o++)n=S(i[o]).detach(),o<t?e.$control_input.before(n):e.$control.append(n);e.caretPos=t},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(){var t=this;t.$input.prop("disabled",!1),t.$control_input.prop("disabled",!1).prop("tabindex",t.tabIndex),t.isDisabled=!1,t.unlock()},destroy:function(){var t=this,e=t.eventNS,n=t.revertSettings;t.trigger("destroy"),t.off(),t.$wrapper.remove(),t.$dropdown.remove(),t.$input.html("").append(n.$children).removeAttr("tabindex").removeClass("selectized").attr({tabindex:n.tabindex}).show(),t.$control_input.removeData("grow"),t.$input.removeData("selectize"),0==--y.count&&y.$testInput&&(y.$testInput.remove(),y.$testInput=void 0),S(window).off(e),S(document).off(e),S(document.body).off(e),delete t.$input[0].selectize},render:function(t,e){var n,i,o="",s=!1,r=this;return"option"!==t&&"item"!==t||(s=!!(n=I(e[r.settings.valueField]))),s&&(p(r.renderCache[t])||(r.renderCache[t]={}),r.renderCache[t].hasOwnProperty(n))?r.renderCache[t][n]:(o=S(r.settings.render[t].apply(this,[e,a])),"option"===t||"option_create"===t?e[r.settings.disabledField]||o.attr("data-selectable",""):"optgroup"===t&&(i=e[r.settings.optgroupValueField]||"",o.attr("data-group",i),e[r.settings.disabledField]&&o.attr("data-disabled","")),"option"!==t&&"item"!==t||o.attr("data-value",n||""),s&&(r.renderCache[t][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))}}),y.count=0,y.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:{}},S.fn.selectize=function(o){function s(t,r){function a(t){var e=c&&t.attr(c);return"string"==typeof e&&e.length?JSON.parse(e):null}function l(t,e){t=S(t);var n,i,o=I(t.val());(o||u.allowEmptyOption)&&(p.hasOwnProperty(o)?e&&((n=p[o][f])?S.isArray(n)?n.push(e):p[o][f]=[n,e]:p[o][f]=e):((i=a(t)||{})[d]=i[d]||t.text(),i[h]=i[h]||o,i[g]=i[g]||t.prop("disabled"),i[f]=i[f]||e,p[o]=i,s.push(i),t.is(":selected")&&r.items.push(o)))}var e,n,i,o,s=r.options,p={};for(r.maxItems=t.attr("multiple")?null:1,e=0,n=(o=t.children()).length;e<n;e++)"optgroup"===(i=o[e].tagName.toLowerCase())?function(t){var e,n,i,o,s;for((i=(t=S(t)).attr("label"))&&((o=a(t)||{})[v]=i,o[m]=i,o[g]=t.prop("disabled"),r.optgroups.push(o)),e=0,n=(s=S("option",t)).length;e<n;e++)l(s[e],i)}(o[e]):"option"===i&&l(o[e])}var r=S.fn.selectize.defaults,u=S.extend({},r,o),c=u.dataAttr,d=u.labelField,h=u.valueField,g=u.disabledField,f=u.optgroupField,v=u.optgroupLabelField,m=u.optgroupValueField;return this.each(function(){var t,e,n,i;this.selectize||(t=S(this),e=this.tagName.toLowerCase(),(n=t.attr("placeholder")||t.attr("data-placeholder"))||u.allowEmptyOption||(n=t.children('option[value=""]').text()),("select"===e?s:function(t,e){var n,i,o,s,r=t.attr(c);if(r)for(e.options=JSON.parse(r),n=0,i=e.options.length;n<i;n++)e.items.push(e.options[n][h]);else{var a=S.trim(t.val()||"");if(!u.allowEmptyOption&&!a.length)return;for(n=0,i=(o=a.split(u.delimiter)).length;n<i;n++)(s={})[d]=o[n],s[h]=o[n],e.options.push(s);e.items=o}})(t,i={placeholder:n,options:[],optgroups:[],items:[]}),new y(t,S.extend(!0,{},r,i,o)))})},S.fn.selectize.defaults=y.defaults,S.fn.selectize.support={validity:F},y}); | ||
!function(t,e){"function"==typeof define&&define.amd?define("sifter",e):"object"==typeof exports?module.exports=e():t.Sifter=e()}(this,function(){function t(t,e){this.items=t,this.settings=e||{diacritics:!0}}t.prototype.tokenize=function(t){if(!(t=a(String(t||"").toLowerCase()))||!t.length)return[];for(var e,n,i=[],o=t.split(/ +/),s=0,r=o.length;s<r;s++){if(e=l(o[s]),this.settings.diacritics)for(n in p)p.hasOwnProperty(n)&&(e=e.replace(new RegExp(n,"g"),p[n]));i.push({string:o[s],regex:new RegExp(e,"i")})}return i},t.prototype.iterator=function(t,e){var n=r(t)?Array.prototype.forEach||function(t){for(var e=0,n=this.length;e<n;e++)t(this[e],e,this)}:function(t){for(var e in this)this.hasOwnProperty(e)&&t(this[e],e,this)};n.apply(t,[e])},t.prototype.getScoreFunction=function(t,e){var o,s,r,a;t=this.prepareSearch(t,e),s=t.tokens,o=t.options.fields,r=s.length,a=t.options.nesting;function l(t,e){var n,i;return!t||-1===(i=(t=String(t||"")).search(e.regex))?0:(n=e.string.length/t.length,0===i&&(n+=.5),n)}var p,u=(p=o.length)?1===p?function(t,e){return l(g(e,o[0],a),t)}:function(t,e){for(var n=0,i=0;n<p;n++)i+=l(g(e,o[n],a),t);return i/p}:function(){return 0};return r?1===r?function(t){return u(s[0],t)}:"and"===t.options.conjunction?function(t){for(var e,n=0,i=0;n<r;n++){if((e=u(s[n],t))<=0)return 0;i+=e}return i/r}:function(t){for(var e=0,n=0;e<r;e++)n+=u(s[e],t);return n/r}:function(){return 0}},t.prototype.getSortFunction=function(t,n){var e,i,o,s,r,a,l,p=this,u=!(t=p.prepareSearch(t,n)).query&&n.sort_empty||n.sort,d=function(t,e){return"$score"===t?e.score:g(p.items[e.id],t,n.nesting)},c=[];if(u)for(e=0,i=u.length;e<i;e++)!t.query&&"$score"===u[e].field||c.push(u[e]);if(t.query){for(l=!0,e=0,i=c.length;e<i;e++)if("$score"===c[e].field){l=!1;break}l&&c.unshift({field:"$score",direction:"desc"})}else for(e=0,i=c.length;e<i;e++)if("$score"===c[e].field){c.splice(e,1);break}for(a=[],e=0,i=c.length;e<i;e++)a.push("desc"===c[e].direction?-1:1);return(s=c.length)?1===s?(o=c[0].field,r=a[0],function(t,e){return r*h(d(o,t),d(o,e))}):function(t,e){for(var n,i,o=0;o<s;o++)if(i=c[o].field,n=a[o]*h(d(i,t),d(i,e)))return n;return 0}:null},t.prototype.prepareSearch=function(t,e){if("object"==typeof t)return t;var n=(e=s({},e)).fields,i=e.sort,o=e.sort_empty;return n&&!r(n)&&(e.fields=[n]),i&&!r(i)&&(e.sort=[i]),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,n){var i,e,o,s=this,r=this.prepareSearch(t,n);return n=r.options,t=r.query,o=n.score||s.getScoreFunction(r),t.length?s.iterator(s.items,function(t,e){i=o(t),(!1===n.filter||0<i)&&r.items.push({score:i,id:e})}):s.iterator(s.items,function(t,e){r.items.push({score:1,id:e})}),(e=s.getSortFunction(r,n))&&r.items.sort(e),r.total=r.items.length,"number"==typeof n.limit&&(r.items=r.items.slice(0,n.limit)),r};var h=function(t,e){return"number"==typeof t&&"number"==typeof e?e<t?1:t<e?-1:0:(t=n(String(t||"")),(e=n(String(e||"")))<t?1:t<e?-1:0)},s=function(t,e){for(var n,i,o=1,s=arguments.length;o<s;o++)if(i=arguments[o])for(n in i)i.hasOwnProperty(n)&&(t[n]=i[n]);return t},g=function(t,e,n){if(t&&e){if(!n)return t[e];for(var i=e.split(".");i.length&&(t=t[i.shift()]););return t}},a=function(t){return(t+"").replace(/^\s+|\s+$|/g,"")},l=function(t){return(t+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")},r=Array.isArray||"undefined"!=typeof $&&$.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},p={a:"[aḀḁĂăÂâǍǎȺⱥȦȧẠạÄäÀàÁáĀāÃãÅåąĄÃąĄ]",b:"[b␢βΒB฿𐌁ᛒ]",c:"[cĆćĈĉČčĊċC̄c̄ÇçḈḉȻȼƇƈɕᴄCc]",d:"[dĎďḊḋḐḑḌḍḒḓḎḏĐđD̦d̦ƉɖƊɗƋƌᵭᶁᶑȡᴅDdð]",e:"[eÉéÈèÊêḘḙĚěĔĕẼẽḚḛẺẻĖėËëĒēȨȩĘęᶒɆɇȄȅẾếỀềỄễỂểḜḝḖḗḔḕȆȇẸẹỆệⱸᴇEeɘǝƏƐε]",f:"[fƑƒḞḟ]",g:"[gɢ₲ǤǥĜĝĞğĢģƓɠĠġ]",h:"[hĤĥĦħḨḩẖẖḤḥḢḣɦʰǶƕ]",i:"[iÍíÌìĬĭÎîǏǐÏïḮḯĨĩĮįĪīỈỉȈȉȊȋỊịḬḭƗɨɨ̆ᵻᶖİiIıɪIi]",j:"[jȷĴĵɈɉʝɟʲ]",k:"[kƘƙꝀꝁḰḱǨǩḲḳḴḵκϰ₭]",l:"[lŁłĽľĻļĹĺḶḷḸḹḼḽḺḻĿŀȽƚⱠⱡⱢɫɬᶅɭȴʟLl]",n:"[nŃńǸǹŇňÑñṄṅŅņṆṇṊṋṈṉN̈n̈ƝɲȠƞᵰᶇɳȵɴNnŊŋ]",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ŹźẐẑŽžŻżẒẓẔẕƵƶ]"},n=function(){var t,e,n,i,o="",s={};for(n in p)if(p.hasOwnProperty(n))for(o+=i=p[n].substring(2,p[n].length-1),t=0,e=i.length;t<e;t++)s[i.charAt(t)]=n;var r=new RegExp("["+o+"]","g");return function(t){return t.replace(r,function(t){return s[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(i){i.plugins={},i.prototype.initializePlugins=function(t){var e,n,i,o=[];if(this.plugins={names:[],settings:{},requested:{},loaded:{}},s.isArray(t))for(e=0,n=t.length;e<n;e++)"string"==typeof t[e]?o.push(t[e]):(this.plugins.settings[t[e].name]=t[e].options,o.push(t[e].name));else if(t)for(i in t)t.hasOwnProperty(i)&&(this.plugins.settings[i]=t[i],o.push(i));for(;o.length;)this.require(o.shift())},i.prototype.loadPlugin=function(t){var e=this.plugins,n=i.plugins[t];if(!i.plugins.hasOwnProperty(t))throw new Error('Unable to find "'+t+'" plugin');e.requested[t]=!0,e.loaded[t]=n.fn.apply(this,[this.plugins.settings[t]||{}]),e.names.push(t)},i.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]},i.define=function(t,e){i.plugins[t]={name:t,fn:e}}}},s={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(x,d,t){"use strict";x.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()};function i(){}i.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 n=arguments.length;return 0===n?delete this._events:1===n?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))}},i.mixin=function(t){for(var e=["on","off","trigger"],n=0;n<e.length;n++)t.prototype[e[n]]=i.prototype[e[n]]};function p(t){return void 0!==t}function S(t){return null==t?null:"boolean"==typeof t?t?"1":"0":t+""}function a(t){return(t+"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function n(e,n,t){var i,o=e.trigger,s={};for(i in e.trigger=function(){var t=arguments[0];if(-1===n.indexOf(t))return o.apply(e,arguments);s[t]=arguments},t.apply(e,[]),e.trigger=o,s)s.hasOwnProperty(i)&&o.apply(e,s[i])}function g(t){var e,n,i={};return"selectionStart"in t?(i.start=t.selectionStart,i.length=t.selectionEnd-i.start):document.selection&&(t.focus(),e=document.selection.createRange(),n=document.selection.createRange().text.length,e.moveStart("character",-t.value.length),i.start=e.text.length-n,i.length=n),i}function $(c){function t(t,e){var n,i,o,s,r,a,l,p,u,d;e=e||{},(t=t||window.event||{}).metaKey||t.altKey||!e.force&&!1===c.data("grow")||(d=c.val(),t.type&&"keydown"===t.type.toLowerCase()&&(i=48<=(n=t.keyCode)&&n<=57||65<=n&&n<=90||96<=n&&n<=111||186<=n&&n<=222||32===n,46===n||8===n?(l=g(c[0])).length?d=d.substring(0,l.start)+d.substring(l.start+l.length):8===n&&l.start?d=d.substring(0,l.start-1)+d.substring(l.start+1):46===n&&void 0!==l.start&&(d=d.substring(0,l.start)+d.substring(l.start+1)):i&&(r=t.shiftKey,a=String.fromCharCode(t.keyCode),d+=a=r?a.toUpperCase():a.toLowerCase())),o=c.attr("placeholder"),!d&&o&&(d=o),u=c,(s=((p=d)?(y.$testInput||(y.$testInput=x("<span />").css({position:"absolute",top:-99999,left:-99999,width:"auto",padding:0,whiteSpace:"pre"}).appendTo("body")),y.$testInput.text(p),function(t,e,n){var i,o,s={};if(n)for(i=0,o=n.length;i<o;i++)s[n[i]]=t.css(n[i]);else s=t.css();e.css(s)}(u,y.$testInput,["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"]),y.$testInput.width()):0)+4)!==h&&(h=s,c.width(s),c.triggerHandler("resize")))}var h=null;c.on("keydown keyup update blur",t),t()}var C=/Mac/.test(navigator.userAgent),b=C?91:17,I=C?18:17,_=!/android/i.test(window.navigator.userAgent)&&!!document.createElement("input").validity,e={before:function(t,e,n){var i=t[e];t[e]=function(){return n.apply(t,arguments),i.apply(t,arguments)}},after:function(e,t,n){var i=e[t];e[t]=function(){var t=i.apply(e,arguments);return n.apply(e,arguments),t}}},y=function(t,e){var n,i,o=this,s=t[0];s.selectize=o;var r,a,l,p,u=window.getComputedStyle&&window.getComputedStyle(s,null);if(p=(p=u?u.getPropertyValue("direction"):s.currentStyle&&s.currentStyle.direction)||t.parents("[dir]:first").attr("dir")||"",x.extend(o,{order:0,settings:e,$input:t,tabIndex:t.attr("tabindex")||"",tagType:"select"===s.tagName.toLowerCase()?1:2,rtl:/rtl/i.test(p),eventNS:".selectize"+ ++y.count,highlightedValue:null,isBlurring:!1,isOpen:!1,isDisabled:!1,isRequired:t.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===e.loadThrottle?o.onSearchChange:(r=o.onSearchChange,a=e.loadThrottle,function(){var t=this,e=arguments;window.clearTimeout(l),l=window.setTimeout(function(){r.apply(t,e)},a)})}),o.sifter=new d(this.options,{diacritics:e.diacritics}),o.settings.options){for(n=0,i=o.settings.options.length;n<i;n++)o.registerOption(o.settings.options[n]);delete o.settings.options}if(o.settings.optgroups){for(n=0,i=o.settings.optgroups.length;n<i;n++)o.registerOptionGroup(o.settings.optgroups[n]);delete o.settings.optgroups}o.settings.mode=o.settings.mode||(1===o.settings.maxItems?"single":"multi"),"boolean"!=typeof o.settings.hideSelected&&(o.settings.hideSelected="multi"===o.settings.mode),o.initializePlugins(o.settings.plugins),o.setupCallbacks(),o.setupTemplates(),o.setup()};return i.mixin(y),void 0!==t?t.mixin(y):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.'}),x.extend(y.prototype,{setup:function(){var t,e,n,i,o,s,r,a=this,l=a.settings,p=a.eventNS,u=x(window),d=x(document),c=a.$input,h=a.settings.mode,g=c.attr("class")||"",f=x("<div>").addClass(l.wrapperClass).addClass(g).addClass(h),v=x("<div>").addClass(l.inputClass).addClass("items").appendTo(f),m=x('<input type="text" autocomplete="off" />').appendTo(v).attr("tabindex",c.is(":disabled")?"-1":a.tabIndex),y=x(l.dropdownParent||f),w=x("<div>").addClass(l.dropdownClass).addClass(h).hide().appendTo(y),O=x("<div>").addClass(l.dropdownContentClass).appendTo(w);(e=c.attr("id"))&&(m.attr("id",e+"-selectized"),x("label[for='"+e+"']").attr("for",e+"-selectized")),a.settings.copyClassesToDropdown&&w.addClass(g),f.css({width:c[0].style.width}),a.plugins.names.length&&(t="plugin-"+a.plugins.names.join(" plugin-"),f.addClass(t),w.addClass(t)),(null===l.maxItems||1<l.maxItems)&&1===a.tagType&&c.attr("multiple","multiple"),a.settings.placeholder&&m.attr("placeholder",l.placeholder),!a.settings.splitOn&&a.settings.delimiter&&(n=a.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),a.settings.splitOn=new RegExp("\\s*"+n+"+\\s*")),c.attr("autocorrect")&&m.attr("autocorrect",c.attr("autocorrect")),c.attr("autocapitalize")&&m.attr("autocapitalize",c.attr("autocapitalize")),m[0].type=c[0].type,a.$wrapper=f,a.$control=v,a.$control_input=m,a.$dropdown=w,a.$dropdown_content=O,w.on("mouseenter mousedown click","[data-disabled]>[data-selectable]",function(t){t.stopImmediatePropagation()}),w.on("mouseenter","[data-selectable]",function(){return a.onOptionHover.apply(a,arguments)}),w.on("mousedown click","[data-selectable]",function(){return a.onOptionSelect.apply(a,arguments)}),o="mousedown",s="*:not(input)",r=function(){return a.onItemSelect.apply(a,arguments)},(i=v).on(o,s,function(t){for(var e=t.target;e&&e.parentNode!==i[0];)e=e.parentNode;return t.currentTarget=e,r.apply(this,[t])}),$(m),v.on({mousedown:function(){return a.onMouseDown.apply(a,arguments)},click:function(){return a.onClick.apply(a,arguments)}}),m.on({mousedown:function(t){t.stopPropagation()},keydown:function(){return a.onKeyDown.apply(a,arguments)},keyup:function(){return a.onKeyUp.apply(a,arguments)},keypress:function(){return a.onKeyPress.apply(a,arguments)},resize:function(){a.positionDropdown.apply(a,[])},blur:function(){return a.onBlur.apply(a,arguments)},focus:function(){return a.ignoreBlur=!1,a.onFocus.apply(a,arguments)},paste:function(){return a.onPaste.apply(a,arguments)}}),d.on("keydown"+p,function(t){a.isCmdDown=t[C?"metaKey":"ctrlKey"],a.isCtrlDown=t[C?"altKey":"ctrlKey"],a.isShiftDown=t.shiftKey}),d.on("keyup"+p,function(t){t.keyCode===I&&(a.isCtrlDown=!1),16===t.keyCode&&(a.isShiftDown=!1),t.keyCode===b&&(a.isCmdDown=!1)}),d.on("mousedown"+p,function(t){if(a.isFocused){if(t.target===a.$dropdown[0]||t.target.parentNode===a.$dropdown[0])return!1;a.$control.has(t.target).length||t.target===a.$control[0]||a.blur(t.target)}}),u.on(["scroll"+p,"resize"+p].join(" "),function(){a.isOpen&&a.positionDropdown.apply(a,arguments)}),u.on("mousemove"+p,function(){a.ignoreHover=!1}),this.revertSettings={$children:c.children().detach(),tabindex:c.attr("tabindex")},c.attr("tabindex",-1).hide().after(a.$wrapper),x.isArray(l.items)&&(a.setValue(l.items),delete l.items),_&&c.on("invalid"+p,function(t){t.preventDefault(),a.isInvalid=!0,a.refreshState()}),a.updateOriginalInput(),a.refreshItems(),a.refreshState(),a.updatePlaceholder(),a.isSetup=!0,c.is(":disabled")&&a.disable(),a.on("change",this.onChange),c.data("selectize",a),c.addClass("selectized"),a.trigger("initialize"),!0===l.preload&&a.onSearchChange("")},setupTemplates:function(){var n=this.settings.labelField,i=this.settings.optgroupLabelField,t={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,e){return'<div class="option">'+e(t[n])+"</div>"},item:function(t,e){return'<div class="item">'+e(t[n])+"</div>"},option_create:function(t,e){return'<div class="create">Add <strong>'+e(t.input)+"</strong>…</div>"}};this.settings.render=x.extend({},t,this.settings.render)},setupCallbacks:function(){var t,e,n={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 n)n.hasOwnProperty(t)&&(e=this.settings[n[t]])&&this.on(t,e)},onClick:function(t){this.isFocused&&this.isOpen||(this.focus(),t.preventDefault())},onMouseDown:function(t){var e=this,n=t.isDefaultPrevented();x(t.target);if(e.isFocused){if(t.target!==e.$control_input[0])return"single"===e.settings.mode?e.isOpen?e.close():e.open():n||e.setActiveItem(null),!1}else n||window.setTimeout(function(){e.focus()},0)},onChange:function(){this.$input.trigger("change")},onPaste:function(t){var o=this;o.isFull()||o.isInputHidden||o.isLocked?t.preventDefault():o.settings.splitOn&&setTimeout(function(){var t=o.$control_input.val();if(t.match(o.settings.splitOn))for(var e=x.trim(t).split(o.settings.splitOn),n=0,i=e.length;n<i;n++)o.createItem(e[n])},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];var e,n,i=this;if(i.isLocked)9!==t.keyCode&&t.preventDefault();else{switch(t.keyCode){case 65:if(i.isCmdDown)return void i.selectAll();break;case 27:return void(i.isOpen&&(t.preventDefault(),t.stopPropagation(),i.close()));case 78:if(!t.ctrlKey||t.altKey)break;case 40:return!i.isOpen&&i.hasOptions?i.open():i.$activeOption&&(i.ignoreHover=!0,(e=i.getAdjacentOption(i.$activeOption,1)).length&&i.setActiveOption(e,!0,!0)),void t.preventDefault();case 80:if(!t.ctrlKey||t.altKey)break;case 38:return i.$activeOption&&(i.ignoreHover=!0,(n=i.getAdjacentOption(i.$activeOption,-1)).length&&i.setActiveOption(n,!0,!0)),void t.preventDefault();case 13:return void(i.isOpen&&i.$activeOption&&(i.onOptionSelect({currentTarget:i.$activeOption}),t.preventDefault()));case 37:return void i.advanceSelection(-1,t);case 39:return void i.advanceSelection(1,t);case 9:return i.settings.selectOnTab&&i.isOpen&&i.$activeOption&&(i.onOptionSelect({currentTarget:i.$activeOption}),i.isFull()||t.preventDefault()),void(i.settings.create&&i.createItem()&&t.preventDefault());case 8:case 46:return void i.deleteSelection(t)}!i.isFull()&&!i.isInputHidden||(C?t.metaKey:t.ctrlKey)||t.preventDefault()}},onKeyUp:function(t){var e=this;if(e.isLocked)return t&&t.preventDefault();var n=e.$control_input.val()||"";e.lastValue!==n&&(e.lastValue=n,e.onSearchChange(n),e.refreshOptions(),e.trigger("type",n))},onSearchChange:function(e){var n=this,i=n.settings.load;i&&(n.loadedSearches.hasOwnProperty(e)||(n.loadedSearches[e]=!0,n.load(function(t){i.apply(n,[e,t])})))},onFocus:function(t){var e=this,n=e.isFocused;if(e.isDisabled)return e.blur(),t&&t.preventDefault(),!1;e.ignoreFocus||(e.isFocused=!0,"focus"===e.settings.preload&&e.onSearchChange(""),n||e.trigger("focus"),e.$activeItems.length||(e.showInput(),e.setActiveItem(null),e.refreshOptions(!!e.settings.openOnFocus)),e.refreshState())},onBlur:function(t,e){var n=this;if(n.isFocused&&(n.isFocused=!1,!n.ignoreFocus)){if(!n.ignoreBlur&&document.activeElement===n.$dropdown_content[0])return n.ignoreBlur=!0,void n.onFocus(t);var i=function(){n.close(),n.setTextboxValue(""),n.setActiveItem(null),n.setActiveOption(null),n.setCaret(n.items.length),n.refreshState(),e&&e.focus&&e.focus(),n.isBlurring=!1,n.ignoreFocus=!1,n.trigger("blur")};n.isBlurring=!0,n.ignoreFocus=!0,n.settings.create&&n.settings.createOnBlur?n.createItem(null,!1,i):i()}},onOptionHover:function(t){this.ignoreHover||this.setActiveOption(t.currentTarget,!1)},onOptionSelect:function(t){var e,n,i=this;t.preventDefault&&(t.preventDefault(),t.stopPropagation()),(n=x(t.currentTarget)).hasClass("create")?i.createItem(null,function(){i.settings.closeAfterSelect&&i.close()}):void 0!==(e=n.attr("data-value"))&&(i.lastQuery=null,i.setTextboxValue(""),i.addItem(e),i.settings.closeAfterSelect?i.close():!i.settings.hideSelected&&t.type&&/mouse/.test(t.type)&&i.setActiveOption(i.getOption(e)))},onItemSelect:function(t){this.isLocked||"multi"===this.settings.mode&&(t.preventDefault(),this.setActiveItem(t.currentTarget,t))},load:function(t){var e=this,n=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||n.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){n(this,e?[]:["change"],function(){this.clear(e),this.addItems(t,e)})},setActiveItem:function(t,e){var n,i,o,s,r,a,l,p,u=this;if("single"!==u.settings.mode){if(!(t=x(t)).length)return x(u.$activeItems).removeClass("active"),u.$activeItems=[],void(u.isFocused&&u.showInput());if("mousedown"===(n=e&&e.type.toLowerCase())&&u.isShiftDown&&u.$activeItems.length){for(p=u.$control.children(".active:last"),s=Array.prototype.indexOf.apply(u.$control[0].childNodes,[p[0]]),(r=Array.prototype.indexOf.apply(u.$control[0].childNodes,[t[0]]))<s&&(l=s,s=r,r=l),i=s;i<=r;i++)a=u.$control[0].childNodes[i],-1===u.$activeItems.indexOf(a)&&(x(a).addClass("active"),u.$activeItems.push(a));e.preventDefault()}else"mousedown"===n&&u.isCtrlDown||"keydown"===n&&this.isShiftDown?t.hasClass("active")?(o=u.$activeItems.indexOf(t[0]),u.$activeItems.splice(o,1),t.removeClass("active")):u.$activeItems.push(t.addClass("active")[0]):(x(u.$activeItems).removeClass("active"),u.$activeItems=[t.addClass("active")[0]]);u.hideInput(),this.isFocused||u.focus()}},setActiveOption:function(t,e,n){var i,o,s,r,a,l=this;l.$activeOption&&l.$activeOption.removeClass("active"),l.$activeOption=null,(t=x(t)).length&&(l.$activeOption=t.addClass("active"),!e&&p(e)||(i=l.$dropdown_content.height(),o=l.$activeOption.outerHeight(!0),e=l.$dropdown_content.scrollTop()||0,a=(r=s=l.$activeOption.offset().top-l.$dropdown_content.offset().top+e)-i+o,i+e<s+o?l.$dropdown_content.stop().animate({scrollTop:a},n?l.settings.scrollDuration:0):s<e&&l.$dropdown_content.stop().animate({scrollTop:r},n?l.settings.scrollDuration:0)))},selectAll:function(){var t=this;"single"!==t.settings.mode&&(t.$activeItems=Array.prototype.slice.apply(t.$control.children(":not(input)").addClass("active")),t.$activeItems.length&&(t.hideInput(),t.close()),t.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(t){var e,n,i,o=this,s=o.settings,r=this.getSearchOptions();if(s.score&&"function"!=typeof(i=o.settings.score.apply(this,[t])))throw new Error('Selectize "score" setting must be a function that returns a function');if(t!==o.lastQuery?(o.lastQuery=t,n=o.sifter.search(t,x.extend(r,{score:i})),o.currentResults=n):n=x.extend(!0,{},o.currentResults),s.hideSelected)for(e=n.items.length-1;0<=e;e--)-1!==o.items.indexOf(S(n.items[e].id))&&n.items.splice(e,1);return n},refreshOptions:function(t){var e,n,i,o,s,r,a,l,p,u,d,c,h,g,f;void 0===t&&(t=!0);var v,m,y=this,w=x.trim(y.$control_input.val()),O=y.search(w),$=y.$dropdown_content,C=y.$activeOption&&S(y.$activeOption.attr("data-value")),b=O.items.length;for("number"==typeof y.settings.maxOptions&&(b=Math.min(b,y.settings.maxOptions)),o={},s=[],e=0;e<b;e++)for(r=y.options[O.items[e].id],a=y.render("option",r),l=r[y.settings.optgroupField]||"",n=0,i=(p=x.isArray(l)?l:[l])&&p.length;n<i;n++)l=p[n],y.optgroups.hasOwnProperty(l)||(l=""),o.hasOwnProperty(l)||(o[l]=document.createDocumentFragment(),s.push(l)),o[l].appendChild(a);for(this.settings.lockOptgroupOrder&&s.sort(function(t,e){return(y.optgroups[t].$order||0)-(y.optgroups[e].$order||0)}),u=document.createDocumentFragment(),e=0,b=s.length;e<b;e++)l=s[e],y.optgroups.hasOwnProperty(l)&&o[l].childNodes.length?((d=document.createDocumentFragment()).appendChild(y.render("optgroup_header",y.optgroups[l])),d.appendChild(o[l]),u.appendChild(y.render("optgroup",x.extend({},y.optgroups[l],{html:(v=d,m=void 0,(m=document.createElement("div")).appendChild(v.cloneNode(!0)),m.innerHTML),dom:d})))):u.appendChild(o[l]);if($.html(u),y.settings.highlight&&($.removeHighlight(),O.query.length&&O.tokens.length))for(e=0,b=O.tokens.length;e<b;e++)!function(t,e){if("string"!=typeof e||e.length){var l="string"==typeof e?new RegExp(e,"i"):e,p=function(t){var e=0;if(3===t.nodeType){var n,i,o,s,r=t.data.search(l);0<=r&&0<t.data.length&&(n=t.data.match(l),(i=document.createElement("span")).className="highlight",(o=t.splitText(r)).splitText(n[0].length),s=o.cloneNode(!0),i.appendChild(s),o.parentNode.replaceChild(i,o),e=1)}else if(1===t.nodeType&&t.childNodes&&!/(script|style)/i.test(t.tagName)&&("highlight"!==t.className||"SPAN"!==t.tagName))for(var a=0;a<t.childNodes.length;++a)a+=p(t.childNodes[a]);return e};t.each(function(){p(this)})}}($,O.tokens[e].regex);if(!y.settings.hideSelected)for(e=0,b=y.items.length;e<b;e++)y.getOption(y.items[e]).addClass("selected");(c=y.canCreate(w))&&($.prepend(y.render("option_create",{input:w})),f=x($[0].childNodes[0])),y.hasOptions=0<O.items.length||c,y.hasOptions?(0<O.items.length?((g=C&&y.getOption(C))&&g.length?h=g:"single"===y.settings.mode&&y.items.length&&(h=y.getOption(y.items[0])),h&&h.length||(h=f&&!y.settings.addPrecedence?y.getAdjacentOption(f,1):$.find("[data-selectable]:first"))):h=f,y.setActiveOption(h),t&&!y.isOpen&&y.open()):(y.setActiveOption(null),t&&y.isOpen&&y.close())},addOption:function(t){var e,n,i,o=this;if(x.isArray(t))for(e=0,n=t.length;e<n;e++)o.addOption(t[e]);else(i=o.registerOption(t))&&(o.userOptions[i]=!0,o.lastQuery=null,o.trigger("option_add",i,t))},registerOption:function(t){var e=S(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=S(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(t,e){var n,i,o,s,r,a,l,p=this;if(t=S(t),o=S(e[p.settings.valueField]),null!==t&&p.options.hasOwnProperty(t)){if("string"!=typeof o)throw new Error("Value must be set in option data");l=p.options[t].$order,o!==t&&(delete p.options[t],-1!==(s=p.items.indexOf(t))&&p.items.splice(s,1,o)),e.$order=e.$order||l,p.options[o]=e,r=p.renderCache.item,a=p.renderCache.option,r&&(delete r[t],delete r[o]),a&&(delete a[t],delete a[o]),-1!==p.items.indexOf(o)&&(n=p.getItem(t),i=x(p.render("item",e)),n.hasClass("active")&&i.addClass("active"),n.replaceWith(i)),p.lastQuery=null,p.isOpen&&p.refreshOptions(!1)}},removeOption:function(t,e){var n=this;t=S(t);var i=n.renderCache.item,o=n.renderCache.option;i&&delete i[t],o&&delete o[t],delete n.userOptions[t],delete n.options[t],n.lastQuery=null,n.trigger("option_remove",t),n.removeItem(t,e)},clearOptions:function(){var n=this;n.loadedSearches={},n.userOptions={},n.renderCache={};var i=n.options;x.each(n.options,function(t,e){-1==n.items.indexOf(t)&&delete i[t]}),n.options=n.sifter.items=i,n.lastQuery=null,n.trigger("option_clear")},getOption:function(t){return this.getElementWithValue(t,this.$dropdown_content.find("[data-selectable]"))},getAdjacentOption:function(t,e){var n=this.$dropdown.find("[data-selectable]"),i=n.index(t)+e;return 0<=i&&i<n.length?n.eq(i):x()},getElementWithValue:function(t,e){if(null!=(t=S(t)))for(var n=0,i=e.length;n<i;n++)if(e[n].getAttribute("data-value")===t)return x(e[n]);return x()},getItem:function(t){return this.getElementWithValue(t,this.$control.children())},addItems:function(t,e){this.buffer=document.createDocumentFragment();for(var n=this.$control[0].childNodes,i=0;i<n.length;i++)this.buffer.appendChild(n[i]);for(var o=x.isArray(t)?t:[t],i=0,s=o.length;i<s;i++)this.isPending=i<s-1,this.addItem(o[i],e);var r=this.$control[0];r.insertBefore(this.buffer,r.firstChild),this.buffer=null},addItem:function(a,l){n(this,l?[]:["change"],function(){var t,e,n,i,o,s=this,r=s.settings.mode;a=S(a),-1===s.items.indexOf(a)?s.options.hasOwnProperty(a)&&("single"===r&&s.clear(l),"multi"===r&&s.isFull()||(t=x(s.render("item",s.options[a])),o=s.isFull(),s.items.splice(s.caretPos,0,a),s.insertAtCaret(t),s.isPending&&(o||!s.isFull())||s.refreshState(),s.isSetup&&(n=s.$dropdown_content.find("[data-selectable]"),s.isPending||(e=s.getOption(a),i=s.getAdjacentOption(e,1).attr("data-value"),s.refreshOptions(s.isFocused&&"single"!==r),i&&s.setActiveOption(s.getOption(i))),!n.length||s.isFull()?s.close():s.isPending||s.positionDropdown(),s.updatePlaceholder(),s.trigger("item_add",a,t),s.isPending||s.updateOriginalInput({silent:l})))):"single"===r&&s.close()})},removeItem:function(t,e){var n,i,o=this,s=t instanceof x?t:o.getItem(t);t=S(s.attr("data-value")),-1!==(n=o.items.indexOf(t))&&(s.remove(),s.hasClass("active")&&(i=o.$activeItems.indexOf(s[0]),o.$activeItems.splice(i,1)),o.items.splice(n,1),o.lastQuery=null,!o.settings.persist&&o.userOptions.hasOwnProperty(t)&&o.removeOption(t,e),n<o.caretPos&&o.setCaret(o.caretPos-1),o.refreshState(),o.updatePlaceholder(),o.updateOriginalInput({silent:e}),o.positionDropdown(),o.trigger("item_remove",t,s))},createItem:function(t,n){var i=this,o=i.caretPos;t=t||x.trim(i.$control_input.val()||"");var s=arguments[arguments.length-1];if("function"!=typeof s&&(s=function(){}),"boolean"!=typeof n&&(n=!0),!i.canCreate(t))return s(),!1;i.lock();var e,r,a="function"==typeof i.settings.create?this.settings.create:function(t){var e={};return e[i.settings.labelField]=t,e[i.settings.valueField]=t,e},l=(r=!(e=function(t){if(i.unlock(),!t||"object"!=typeof t)return s();var e=S(t[i.settings.valueField]);if("string"!=typeof e)return s();i.setTextboxValue(""),i.addOption(t),i.setCaret(o),i.addItem(e),i.refreshOptions(n&&"single"!==i.settings.mode),s(t)}),function(){r||(r=!0,e.apply(this,arguments))}),p=a.apply(this,[t,l]);return void 0!==p&&l(p),!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 t=this,e=t.isFull(),n=t.isLocked;t.$wrapper.toggleClass("rtl",t.rtl),t.$control.toggleClass("focus",t.isFocused).toggleClass("disabled",t.isDisabled).toggleClass("required",t.isRequired).toggleClass("invalid",t.isInvalid).toggleClass("locked",n).toggleClass("full",e).toggleClass("not-full",!e).toggleClass("input-active",t.isFocused&&!t.isInputHidden).toggleClass("dropdown-active",t.isOpen).toggleClass("has-options",!x.isEmptyObject(t.options)).toggleClass("has-items",0<t.items.length),t.$control_input.data("grow",!e&&!n)},isFull:function(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems},updateOriginalInput:function(t){var e,n,i,o,s=this;if(t=t||{},1===s.tagType){for(i=[],e=0,n=s.items.length;e<n;e++)o=s.options[s.items[e]][s.settings.labelField]||"",i.push('<option value="'+a(s.items[e])+'" selected="selected">'+a(o)+"</option>");i.length||this.$input.attr("multiple")||i.push('<option value="" selected="selected"></option>'),s.$input.html(i.join(""))}else s.$input.val(s.getValue()),s.$input.attr("value",s.$input.val());s.isSetup&&(t.silent||s.trigger("change",s.$input.val()))},updatePlaceholder:function(){var t;this.settings.placeholder&&(t=this.$control_input,this.items.length?t.removeAttr("placeholder"):t.attr("placeholder",this.settings.placeholder),t.triggerHandler("update",{force:!0}))},open:function(){var t=this;t.isLocked||t.isOpen||"multi"===t.settings.mode&&t.isFull()||(t.focus(),t.isOpen=!0,t.refreshState(),t.$dropdown.css({visibility:"hidden",display:"block"}),t.positionDropdown(),t.$dropdown.css({visibility:"visible"}),t.trigger("dropdown_open",t.$dropdown))},close:function(){var t=this,e=t.isOpen;"single"===t.settings.mode&&t.items.length&&(t.hideInput(),t.isBlurring||t.$control_input.blur()),t.isOpen=!1,t.$dropdown.hide(),t.setActiveOption(null),t.refreshState(),e&&t.trigger("dropdown_close",t.$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){var e=this;e.items.length&&(e.$control.children(":not(input)").remove(),e.items=[],e.lastQuery=null,e.setCaret(0),e.setActiveItem(null),e.updatePlaceholder(),e.updateOriginalInput({silent:t}),e.refreshState(),e.showInput(),e.trigger("clear"))},insertAtCaret:function(t){var e=Math.min(this.caretPos,this.items.length),n=t[0],i=this.buffer||this.$control[0];0===e?i.insertBefore(n,i.firstChild):i.insertBefore(n,i.childNodes[e]),this.setCaret(e+1)},deleteSelection:function(t){var e,n,i,o,s,r,a,l=this,p=t&&8===t.keyCode?-1:1,u=g(l.$control_input[0]);if(l.$activeOption&&!l.settings.hideSelected&&(s=l.getAdjacentOption(l.$activeOption,-1).attr("data-value")),i=[],l.$activeItems.length){for(a=l.$control.children(".active:"+(0<p?"last":"first")),o=l.$control.children(":not(input)").index(a),0<p&&o++,e=0,n=l.$activeItems.length;e<n;e++)i.push(x(l.$activeItems[e]).attr("data-value"));t&&(t.preventDefault(),t.stopPropagation())}else(l.isFocused||"single"===l.settings.mode)&&l.items.length&&(p<0&&0===u.start&&0===u.length?i.push(l.items[l.caretPos-1]):0<p&&u.start===l.$control_input.val().length&&i.push(l.items[l.caretPos]));if(!i.length||"function"==typeof l.settings.onDelete&&!1===l.settings.onDelete.apply(l,[i]))return!1;for(void 0!==o&&l.setCaret(o);i.length;)l.removeItem(i.pop());return l.showInput(),l.positionDropdown(),l.refreshOptions(!0),s&&(r=l.getOption(s)).length&&l.setActiveOption(r),!0},advanceSelection:function(t,e){var n,i,o,s,r,a=this;0!==t&&(a.rtl&&(t*=-1),n=0<t?"last":"first",i=g(a.$control_input[0]),a.isFocused&&!a.isInputHidden?(s=a.$control_input.val().length,(t<0?0!==i.start||0!==i.length:i.start!==s)||s||a.advanceCaret(t,e)):(r=a.$control.children(".active:"+n)).length&&(o=a.$control.children(":not(input)").index(r),a.setActiveItem(null),a.setCaret(0<t?o+1:o)))},advanceCaret:function(t,e){var n,i,o=this;0!==t&&(n=0<t?"next":"prev",o.isShiftDown?(i=o.$control_input[n]()).length&&(o.hideInput(),o.setActiveItem(i),e&&e.preventDefault()):o.setCaret(o.caretPos+t))},setCaret:function(t){var e=this;if(t="single"===e.settings.mode?e.items.length:Math.max(0,Math.min(e.items.length,t)),!e.isPending)for(var n,i=e.$control.children(":not(input)"),o=0,s=i.length;o<s;o++)n=x(i[o]).detach(),o<t?e.$control_input.before(n):e.$control.append(n);e.caretPos=t},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(){var t=this;t.$input.prop("disabled",!1),t.$control_input.prop("disabled",!1).prop("tabindex",t.tabIndex),t.isDisabled=!1,t.unlock()},destroy:function(){var t=this,e=t.eventNS,n=t.revertSettings;t.trigger("destroy"),t.off(),t.$wrapper.remove(),t.$dropdown.remove(),t.$input.html("").append(n.$children).removeAttr("tabindex").removeClass("selectized").attr({tabindex:n.tabindex}).show(),t.$control_input.removeData("grow"),t.$input.removeData("selectize"),0==--y.count&&y.$testInput&&(y.$testInput.remove(),y.$testInput=void 0),x(window).off(e),x(document).off(e),x(document.body).off(e),delete t.$input[0].selectize},render:function(t,e){var n,i,o="",s=!1,r=this;return"option"!==t&&"item"!==t||(s=!!(n=S(e[r.settings.valueField]))),s&&(p(r.renderCache[t])||(r.renderCache[t]={}),r.renderCache[t].hasOwnProperty(n))?r.renderCache[t][n]:(o=x(r.settings.render[t].apply(this,[e,a])),"option"===t||"option_create"===t?e[r.settings.disabledField]||o.attr("data-selectable",""):"optgroup"===t&&(i=e[r.settings.optgroupValueField]||"",o.attr("data-group",i),e[r.settings.disabledField]&&o.attr("data-disabled","")),"option"!==t&&"item"!==t||o.attr("data-value",n||""),s&&(r.renderCache[t][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))}}),y.count=0,y.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:{}},x.fn.selectize=function(o){function s(t,r){function a(t){var e=d&&t.attr(d);return"string"==typeof e&&e.length?JSON.parse(e):null}function l(t,e){t=x(t);var n,i,o=S(t.val());(o||u.allowEmptyOption)&&(p.hasOwnProperty(o)?e&&((n=p[o][f])?x.isArray(n)?n.push(e):p[o][f]=[n,e]:p[o][f]=e):((i=a(t)||{})[c]=i[c]||t.text(),i[h]=i[h]||o,i[g]=i[g]||t.prop("disabled"),i[f]=i[f]||e,p[o]=i,s.push(i),t.is(":selected")&&r.items.push(o)))}var e,n,i,o,s=r.options,p={};for(r.maxItems=t.attr("multiple")?null:1,e=0,n=(o=t.children()).length;e<n;e++)"optgroup"===(i=o[e].tagName.toLowerCase())?function(t){var e,n,i,o,s;for((i=(t=x(t)).attr("label"))&&((o=a(t)||{})[v]=i,o[m]=i,o[g]=t.prop("disabled"),r.optgroups.push(o)),e=0,n=(s=x("option",t)).length;e<n;e++)l(s[e],i)}(o[e]):"option"===i&&l(o[e])}var r=x.fn.selectize.defaults,u=x.extend({},r,o),d=u.dataAttr,c=u.labelField,h=u.valueField,g=u.disabledField,f=u.optgroupField,v=u.optgroupLabelField,m=u.optgroupValueField;return this.each(function(){var t,e,n,i;this.selectize||(t=x(this),e=this.tagName.toLowerCase(),(n=t.attr("placeholder")||t.attr("data-placeholder"))||u.allowEmptyOption||(n=t.children('option[value=""]').text()),("select"===e?s:function(t,e){var n,i,o,s,r=t.attr(d);if(r)for(e.options=JSON.parse(r),n=0,i=e.options.length;n<i;n++)e.items.push(e.options[n][h]);else{var a=x.trim(t.val()||"");if(!u.allowEmptyOption&&!a.length)return;for(n=0,i=(o=a.split(u.delimiter)).length;n<i;n++)(s={})[c]=o[n],s[h]=o[n],e.options.push(s);e.items=o}})(t,i={placeholder:n,options:[],optgroups:[],items:[]}),new y(t,x.extend(!0,{},r,i,o)))})},x.fn.selectize.defaults=y.defaults,x.fn.selectize.support={validity:_},y.define("drag_drop",function(t){if(!x.fn.sortable)throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');var i,e,n,o;"multi"===this.settings.mode&&((i=this).lock=(e=i.lock,function(){var t=i.$control.data("sortable");return t&&t.disable(),e.apply(i,arguments)}),i.unlock=(n=i.unlock,function(){var t=i.$control.data("sortable");return t&&t.enable(),n.apply(i,arguments)}),i.setup=(o=i.setup,function(){o.apply(this,arguments);var n=i.$control.sortable({items:"[data-value]",forcePlaceholderSize:!0,disabled:i.isLocked,start:function(t,e){e.placeholder.css("width",e.helper.css("width")),n.css({overflow:"visible"})},stop:function(){n.css({overflow:"hidden"});var t=i.$activeItems?i.$activeItems.slice():null,e=[];n.children("[data-value]").each(function(){e.push(x(this).attr("data-value"))}),i.setValue(e),i.setActiveItem(t)}})}))}),y.define("dropdown_header",function(t){var e,n=this;t=x.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+'">×</a></div></div>'}},t),n.setup=(e=n.setup,function(){e.apply(n,arguments),n.$dropdown_header=x(t.html(t)),n.$dropdown.prepend(n.$dropdown_header)})}),y.define("optgroup_columns",function(a){var s,l=this;a=x.extend({equalizeWidth:!0,equalizeHeight:!0},a),this.getAdjacentOption=function(t,e){var n=t.closest("[data-group]").find("[data-selectable]"),i=n.index(t)+e;return 0<=i&&i<n.length?n.eq(i):x()},this.onKeyDown=(s=l.onKeyDown,function(t){var e,n,i,o;return!this.isOpen||37!==t.keyCode&&39!==t.keyCode?s.apply(this,arguments):(l.ignoreHover=!0,e=(o=this.$activeOption.closest("[data-group]")).find("[data-selectable]").index(this.$activeOption),void((n=(i=(o=37===t.keyCode?o.prev("[data-group]"):o.next("[data-group]")).find("[data-selectable]")).eq(Math.min(i.length-1,e))).length&&this.setActiveOption(n)))});function t(){var t,e,n,i,o,s=x("[data-group]",l.$dropdown_content),r=s.length;if(r&&l.$dropdown_content.width()){if(a.equalizeHeight){for(t=e=0;t<r;t++)e=Math.max(e,s.eq(t).height());s.css({height:e})}a.equalizeWidth&&(o=l.$dropdown_content.innerWidth()-p(),n=Math.round(o/r),s.css({width:n}),1<r&&(i=o-n*(r-1),s.eq(r-1).css({width:i})))}}var p=function(){var t,e=p.width,n=document;return void 0===e&&((t=n.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,n.body.appendChild(t),e=p.width=t.offsetWidth-t.clientWidth,n.body.removeChild(t)),e};(a.equalizeHeight||a.equalizeWidth)&&(e.after(this,"positionDropdown",t),e.after(this,"refreshOptions",t))}),y.define("remove_button",function(t){t=x.extend({label:"×",title:"Remove",className:"remove",append:!0},t);var s,e,n,i,r;"single"!==this.settings.mode?(i=s=this,r='<a href="javascript:void(0)" class="'+(e=t).className+'" tabindex="-1" title="'+a(e.title)+'">'+e.label+"</a>",s.setup=(n=i.setup,function(){var o;e.append&&(o=i.settings.render.item,i.settings.render.item=function(t){return e=o.apply(s,arguments),n=r,i=e.search(/(<\/[^>]+>\s*)$/),e.substring(0,i)+n+e.substring(i);var e,n,i}),n.apply(s,arguments),s.$control.on("click","."+e.className,function(t){var e;t.preventDefault(),i.isLocked||(e=x(t.currentTarget).parent(),i.setActiveItem(e),i.deleteSelection()&&i.setCaret(i.items.length))})})):function(o,e){e.className="remove-single";var n,s=o,r='<a href="javascript:void(0)" class="'+e.className+'" tabindex="-1" title="'+a(e.title)+'">'+e.label+"</a>";o.setup=(n=s.setup,function(){var t,i;e.append&&(t=x(s.$input.context).attr("id"),x("#"+t),i=s.settings.render.item,s.settings.render.item=function(t){return e=i.apply(o,arguments),n=r,x("<span>").append(e).append(n);var e,n}),n.apply(o,arguments),o.$control.on("click","."+e.className,function(t){t.preventDefault(),s.isLocked||s.clear()})})}(this,t)}),y.define("restore_on_backspace",function(i){var o,t=this;i.text=i.text||function(t){return t[this.settings.labelField]},this.onKeyDown=(o=t.onKeyDown,function(t){var e,n;return 8===t.keyCode&&""===this.$control_input.val()&&!this.$activeItems.length&&0<=(e=this.caretPos-1)&&e<this.items.length?(n=this.options[this.items[e]],this.deleteSelection(t)&&(this.setTextboxValue(i.text.apply(this,[n])),this.refreshOptions(!0)),void t.preventDefault()):o.apply(this,arguments)})}),y}); |
@@ -15,3 +15,3 @@ { | ||
"description": "Selectize is a jQuery-based custom <select> UI control. Useful for tagging, contact lists, country selectors, etc.", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"author": "BarkleyREI Team. Originally Brian Reavis <brian@thirdroute.com>", | ||
@@ -18,0 +18,0 @@ "license": "(MIT OR Apache-2.0)", |
@@ -1,9 +0,4 @@ | ||
→ Selectize is looking for [new members on the maintenance team](https://github.com/selectize/selectize.js/issues/752)! | ||
# selectize.js | ||
[![NPM version](http://img.shields.io/npm/v/selectize.svg?style=flat)](https://www.npmjs.org/package/selectize) | ||
[![CDNJS version](http://img.shields.io/cdnjs/v/selectize.js.svg?style=flat)](https://cdnjs.com/libraries/selectize.js) | ||
[![Build Status](http://img.shields.io/travis/selectize/selectize.js/master.svg?style=flat)](https://travis-ci.org/selectize/selectize.js) | ||
[![Coverage Status](http://img.shields.io/coveralls/selectize/selectize.js/master.svg?style=flat)](https://coveralls.io/r/selectize/selectize.js) | ||
[![NPM version](http://img.shields.io/npm/v/@barkleyrei/selectize.svg?style=flat)](https://www.npmjs.com/package/@barkleyrei/selectize) | ||
@@ -10,0 +5,0 @@ Selectize is an extensible [jQuery](http://jquery.com/)-based custom <select> UI control. It's useful for tagging, contact lists, country selectors, and so on. It clocks in at around ~7kb (gzipped). The goal is to provide a solid & usable experience with a clean and powerful API. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1177053
83
23804
148