/*! selectize.js - v0.13.0 | https://github.com/selectize/selectize.js | Apache License (v2) */ !function(e,t){"function"==typeof define&&define.amd?define("sifter",t):"object"==typeof exports?module.exports=t():e.Sifter=t()}(this,function(){function e(e,t){this.items=e,this.settings=t||{diacritics:!0}}e.prototype.tokenize=function(e){if(!(e=a(String(e||"").toLowerCase()))||!e.length)return[];for(var t,n,i=[],o=e.split(/ +/),s=0,r=o.length;s/g,">").replace(/"/g,""")},escape_replace=function(e){return(e+"").replace(/\$/g,"$$$$")},hook={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}}},once=function(e){var t=!1;return function(){t||(t=!0,e.apply(this,arguments))}},debounce=function(n,i){var o;return function(){var e=this,t=arguments;window.clearTimeout(o),o=window.setTimeout(function(){n.apply(e,t)},i)}},debounce_events=function(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])},watchChildEvent=function(n,e,t,i){n.on(e,t,function(e){for(var t=e.target;t&&t.parentNode!==n[0];)t=t.parentNode;return e.currentTarget=t,i.apply(this,[e])})},getSelection=function(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},transferStyles=function(e,t,n){var i,o,s={};if(n)for(i=0,o=n.length;i").css({position:"absolute",width:"auto",padding:0,whiteSpace:"pre"}),$("
").css({position:"absolute",width:0,height:0,overflow:"hidden"}).append(Selectize.$testInput).appendTo("body")),Selectize.$testInput.text(e),transferStyles(t,Selectize.$testInput,["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"]),Selectize.$testInput.width()):0},autoGrow=function(r){function e(e,t){var n,i,o,s;t=t||{},(e=e||window.event||{}).metaKey||e.altKey||!t.force&&!1===r.data("grow")||(i=r.val(),e.type&&"keydown"===e.type.toLowerCase()&&(o=48<=(n=e.keyCode)&&n<=57||65<=n&&n<=90||96<=n&&n<=111||186<=n&&n<=222||32===n,n===KEY_DELETE||n===KEY_BACKSPACE?(t=getSelection(r[0])).length?i=i.substring(0,t.start)+i.substring(t.start+t.length):n===KEY_BACKSPACE&&t.start?i=i.substring(0,t.start-1)+i.substring(t.start+1):n===KEY_DELETE&&void 0!==t.start&&(i=i.substring(0,t.start)+i.substring(t.start+1)):o&&(o=e.shiftKey,s=String.fromCharCode(e.keyCode),i+=s=o?s.toUpperCase():s.toLowerCase())),s=r.attr("placeholder"),!i&&s&&(i=s),(i=measureString(i,r)+4)!==a&&(a=i,r.width(i),r.triggerHandler("resize")))}var a=null;r.on("keydown keyup update blur",e),e()},domToString=function(e){var t=document.createElement("div");return t.appendChild(e.cloneNode(!0)),t.innerHTML},logError=function(e,t){t=t||{};console.error("Selectize: "+e),t.explanation&&(console.group&&console.group(),console.error(t.explanation),console.group&&console.groupEnd())},Selectize=function(e,t){var n,i,o=this,s=e[0];s.selectize=o;var r=window.getComputedStyle&&window.getComputedStyle(s,null);if(r=(r=r?r.getPropertyValue("direction"):s.currentStyle&&s.currentStyle.direction)||e.parents("[dir]:first").attr("dir")||"",$.extend(o,{order:0,settings:t,$input:e,tabIndex:e.attr("tabindex")||"",tagType:"select"===s.tagName.toLowerCase()?TAG_SELECT:TAG_INPUT,rtl:/rtl/i.test(r),eventNS:".selectize"+ ++Selectize.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:debounce(o.onSearchChange,t.loadThrottle)}),o.sifter=new Sifter(this.options,{diacritics:t.diacritics}),o.settings.options){for(n=0,i=o.settings.options.length;n").addClass(n.wrapperClass).addClass(l).addClass(a),c=$("
").addClass(n.inputClass).addClass("items").appendTo(p),d=$('').appendTo(c).attr("tabindex",r.is(":disabled")?"-1":t.tabIndex),u=$(n.dropdownParent||p),h=$("
").addClass(n.dropdownClass).addClass(a).hide().appendTo(u),a=$("
").addClass(n.dropdownContentClass).appendTo(h);(u=r.attr("id"))&&(d.attr("id",u+"-selectized"),$("label[for='"+u+"']").attr("for",u+"-selectized")),t.settings.copyClassesToDropdown&&h.addClass(l),p.css({width:r[0].style.width}),t.plugins.names.length&&(e="plugin-"+t.plugins.names.join(" plugin-"),p.addClass(e),h.addClass(e)),(null===n.maxItems||1[data-selectable]",function(e){e.stopImmediatePropagation()}),h.on("mouseenter","[data-selectable]",function(){return t.onOptionHover.apply(t,arguments)}),h.on("mousedown click","[data-selectable]",function(){return t.onOptionSelect.apply(t,arguments)}),watchChildEvent(c,"mousedown","*:not(input)",function(){return t.onItemSelect.apply(t,arguments)}),autoGrow(d),c.on({mousedown:function(){return t.onMouseDown.apply(t,arguments)},click:function(){return t.onClick.apply(t,arguments)}}),d.on({mousedown:function(e){e.stopPropagation()},keydown:function(){return t.onKeyDown.apply(t,arguments)},keyup:function(){return t.onKeyUp.apply(t,arguments)},keypress:function(){return t.onKeyPress.apply(t,arguments)},resize:function(){t.positionDropdown.apply(t,[])},blur:function(){return t.onBlur.apply(t,arguments)},focus:function(){return t.ignoreBlur=!1,t.onFocus.apply(t,arguments)},paste:function(){return t.onPaste.apply(t,arguments)}}),s.on("keydown"+i,function(e){t.isCmdDown=e[IS_MAC?"metaKey":"ctrlKey"],t.isCtrlDown=e[IS_MAC?"altKey":"ctrlKey"],t.isShiftDown=e.shiftKey}),s.on("keyup"+i,function(e){e.keyCode===KEY_CTRL&&(t.isCtrlDown=!1),e.keyCode===KEY_SHIFT&&(t.isShiftDown=!1),e.keyCode===KEY_CMD&&(t.isCmdDown=!1)}),s.on("mousedown"+i,function(e){if(t.isFocused){if(e.target===t.$dropdown[0]||e.target.parentNode===t.$dropdown[0])return!1;t.$control.has(e.target).length||e.target===t.$control[0]||t.blur(e.target)}}),o.on(["scroll"+i,"resize"+i].join(" "),function(){t.isOpen&&t.positionDropdown.apply(t,arguments)}),o.on("mousemove"+i,function(){t.ignoreHover=!1}),this.revertSettings={$children:r.children().detach(),tabindex:r.attr("tabindex")},r.attr("tabindex",-1).hide().after(t.$wrapper),$.isArray(n.items)&&(t.setValue(n.items),delete n.items),SUPPORTS_VALIDITY_API&&r.on("invalid"+i,function(e){e.preventDefault(),t.isInvalid=!0,t.refreshState()}),t.updateOriginalInput(),t.refreshItems(),t.refreshState(),t.updatePlaceholder(),t.isSetup=!0,r.is(":disabled")&&t.disable(),t.on("change",this.onChange),r.data("selectize",t),r.addClass("selectized"),t.trigger("initialize"),!0===n.preload&&t.onSearchChange("")},setupTemplates:function(){var n=this.settings.labelField,i=this.settings.optgroupLabelField,e={optgroup:function(e){return'
'+e.html+"
"},optgroup_header:function(e,t){return'
'+t(e[i])+"
"},option:function(e,t){return'
'+t(e[n])+"
"},item:function(e,t){return'
'+t(e[n])+"
"},option_create:function(e,t){return'
Add '+t(e.input)+"
"}};this.settings.render=$.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",dropdown_item_activate:"onDropdownItemActivate",dropdown_item_deactivate:"onDropdownItemDeactivate"};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();$(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=$.trim(e).split(o.settings.splitOn),n=0,i=t.length;n=this.settings.maxItems},updateOriginalInput:function(e){var t,n,i,o,s=this;if(e=e||{},s.tagType===TAG_SELECT){for(i=[],t=0,n=s.items.length;t'+escape_html(o)+"");i.length||this.$input.attr("multiple")||i.push(''),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],e=this.buffer||this.$control[0];0===t?e.insertBefore(n,e.firstChild):e.insertBefore(n,e.childNodes[t]),this.setCaret(t+1)},deleteSelection:function(e){var t,n,i,o,s,r,a=this,l=e&&e.keyCode===KEY_BACKSPACE?-1:1,p=getSelection(a.$control_input[0]);if(a.$activeOption&&!a.settings.hideSelected&&(o=a.getAdjacentOption(a.$activeOption,-1).attr("data-value")),i=[],a.$activeItems.length){for(r=a.$control.children(".active:"+(0
'+e.title+'×
'}},e),n.setup=(t=n.setup,function(){t.apply(n,arguments),n.$dropdown_header=$(e.html(e)),n.$dropdown.prepend(n.$dropdown_header)})}),Selectize.define("optgroup_columns",function(r){var i,a=this;r=$.extend({equalizeWidth:!0,equalizeHeight:!0},r),this.getAdjacentOption=function(e,t){var n=e.closest("[data-group]").find("[data-selectable]"),t=n.index(e)+t;return 0<=t&&t
',e=e.firstChild,n.body.appendChild(e),t=l.width=e.offsetWidth-e.clientWidth,n.body.removeChild(e)),t};(r.equalizeHeight||r.equalizeWidth)&&(hook.after(this,"positionDropdown",e),hook.after(this,"refreshOptions",e))}),Selectize.define("remove_button",function(e){e=$.extend({label:"×",title:"Remove",className:"remove",append:!0},e);var s,t,n,i,r;"single"===this.settings.mode?function(o,t){t.className="remove-single";var n,s=o,r=''+t.label+"";o.setup=(n=s.setup,function(){var e,i;t.append&&(e=$(s.$input.context).attr("id"),$("#"+e),i=s.settings.render.item,s.settings.render.item=function(e){return t=i.apply(o,arguments),n=r,$("").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):(i=s=this,r=''+t.label+"",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){if(e.preventDefault(),!i.isLocked){e=$(e.currentTarget).parent();return i.setActiveItem(e),i.deleteSelection()&&i.setCaret(i.items.length),!1}})}))}),Selectize.define("restore_on_backspace",function(n){var i,e=this;n.text=n.text||function(e){return e[this.settings.labelField]},this.onKeyDown=(i=e.onKeyDown,function(e){var t;return e.keyCode===KEY_BACKSPACE&&""===this.$control_input.val()&&!this.$activeItems.length&&0<=(t=this.caretPos-1)&&t