tom-select
Advanced tools
Comparing version 1.0.0-b.3 to 1.0.0-rc.1
@@ -1,3 +0,3 @@ | ||
/*! tom-select.js - v1.0.0-b.3 | https://github.com/orchidjs/tom-select | Apache License (v2) */ | ||
/*! tom-select.js - v1.0.0-rc.1 | https://github.com/orchidjs/tom-select | 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(/ +/),r=0,s=o.length;r<s;r++){if(t=l(o[r]),this.settings.diacritics)for(n in u)u.hasOwnProperty(n)&&(t=t.replace(new RegExp(n,"g"),u[n]));i.push({string:o[r],regex:new RegExp(t,"i")})}return i},e.prototype.iterator=function(e,t){var n=s(e)?Array.prototype.forEach||function(e){for(var t=0,n=this.length;t<n;t++)e(this[t],t,this)}:function(e){for(var t in this)this.hasOwnProperty(t)&&e(this[t],t,this)};n.apply(e,[t])},e.prototype.getScoreFunction=function(e,t){var o,r,s,a;e=this.prepareSearch(e,t),r=e.tokens,o=e.options.fields,s=r.length,a=e.options.nesting;function l(e,t){var n,i;return!e||-1===(i=(e=String(e||"")).search(t.regex))?0:(n=t.string.length/e.length,0===i&&(n+=.5),n)}var u,c=(u=o.length)?1===u?function(e,t){return l(f(t,o[0],a),e)}:function(e,t){for(var n=0,i=0;n<u;n++)i+=l(f(t,o[n],a),e);return i/u}:function(){return 0};return s?1===s?function(e){return c(r[0],e)}:"and"===e.options.conjunction?function(e){for(var t,n=0,i=0;n<s;n++){if((t=c(r[n],e))<=0)return 0;i+=t}return i/s}:function(e){for(var t=0,n=0;t<s;t++)n+=c(r[t],e);return n/s}:function(){return 0}},e.prototype.getSortFunction=function(e,n){var t,i,o,r,s,a,l,u=this,c=!(e=u.prepareSearch(e,n)).query&&n.sort_empty||n.sort,p=function(e,t){return"$score"===e?t.score:f(u.items[t.id],e,n.nesting)},d=[];if(c)for(t=0,i=c.length;t<i;t++)!e.query&&"$score"===c[t].field||d.push(c[t]);if(e.query){for(l=!0,t=0,i=d.length;t<i;t++)if("$score"===d[t].field){l=!1;break}l&&d.unshift({field:"$score",direction:"desc"})}else for(t=0,i=d.length;t<i;t++)if("$score"===d[t].field){d.splice(t,1);break}for(a=[],t=0,i=d.length;t<i;t++)a.push("desc"===d[t].direction?-1:1);return(r=d.length)?1===r?(o=d[0].field,s=a[0],function(e,t){return s*h(p(o,e),p(o,t))}):function(e,t){for(var n,i,o=0;o<r;o++)if(i=d[o].field,n=a[o]*h(p(i,e),p(i,t)))return n;return 0}:null},e.prototype.prepareSearch=function(e,t){if("object"==typeof e)return e;var n=(t=r({},t)).fields,i=t.sort,o=t.sort_empty;return n&&!s(n)&&(t.fields=[n]),i&&!s(i)&&(t.sort=[i]),o&&!s(o)&&(t.sort_empty=[o]),{options:t,query:String(e||"").toLowerCase(),tokens:this.tokenize(e),total:0,items:[]}},e.prototype.search=function(e,n){var i,t,o,r=this,s=this.prepareSearch(e,n);return n=s.options,e=s.query,o=n.score||r.getScoreFunction(s),e.length?r.iterator(r.items,function(e,t){i=o(e),(!1===n.filter||0<i)&&s.items.push({score:i,id:t})}):r.iterator(r.items,function(e,t){s.items.push({score:1,id:t})}),(t=r.getSortFunction(s,n))&&s.items.sort(t),s.total=s.items.length,"number"==typeof n.limit&&(s.items=s.items.slice(0,n.limit)),s};var h=function(e,t){return"number"==typeof e&&"number"==typeof t?t<e?1:e<t?-1:0:(e=n(String(e||"")),(t=n(String(t||"")))<e?1:e<t?-1:0)},r=function(e,t){for(var n,i,o=1,r=arguments.length;o<r;o++)if(i=arguments[o])for(n in i)i.hasOwnProperty(n)&&(e[n]=i[n]);return e},f=function(e,t,n){if(e&&t){if(!n)return e[t];for(var i=t.split(".");i.length&&(e=e[i.shift()]););return e}},a=function(e){return(e+"").replace(/^\s+|\s+$|/g,"")},l=function(e){return(e+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")},s=Array.isArray||"undefined"!=typeof $&&$.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},u={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 e,t,n,i,o="",r={};for(n in u)if(u.hasOwnProperty(n))for(o+=i=u[n].substring(2,u[n].length-1),e=0,t=i.length;e<t;e++)r[i.charAt(e)]=n;var s=new RegExp("["+o+"]","g");return function(e){return e.replace(s,function(e){return r[e]}).toLowerCase()}}();return e}),function(e,t){"function"==typeof define&&define.amd?define("microplugin",t):"object"==typeof exports?module.exports=t():e.MicroPlugin=t()}(this,function(){var e={mixin:function(i){i.plugins={},i.prototype.initializePlugins=function(e){var t,n,i,o=[];if(this.plugins={names:[],settings:{},requested:{},loaded:{}},r.isArray(e))for(t=0,n=e.length;t<n;t++)"string"==typeof e[t]?o.push(e[t]):(this.plugins.settings[e[t].name]=e[t].options,o.push(e[t].name));else if(e)for(i in e)e.hasOwnProperty(i)&&(this.plugins.settings[i]=e[i],o.push(i));for(;o.length;)this.require(o.shift())},i.prototype.loadPlugin=function(e){var t=this.plugins,n=i.plugins[e];if(!i.plugins.hasOwnProperty(e))throw new Error('Unable to find "'+e+'" plugin');t.requested[e]=!0,t.loaded[e]=n.fn.apply(this,[this.plugins.settings[e]||{}]),t.names.push(e)},i.prototype.require=function(e){var t=this.plugins;if(!this.plugins.loaded.hasOwnProperty(e)){if(t.requested[e])throw new Error('Plugin has circular dependency ("'+e+'")');this.loadPlugin(e)}return t.loaded[e]},i.define=function(e,t){i.plugins[e]={name:e,fn:t}}}},r={isArray:Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}};return e}),function(e,t){"function"==typeof define&&define.amd?define("tomselect",["sifter","microplugin"],t):"object"==typeof exports?module.exports=t(require("sifter"),require("microplugin")):e.TomSelect=t(e.Sifter,e.MicroPlugin)}(this,function(a,e){"use strict";function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(r){var s=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}();return function(){var e,t,n,i,o=p(r);return t=s?(e=p(this).constructor,Reflect.construct(o,arguments,e)):o.apply(this,arguments),n=this,!(i=t)||"object"!==l(i)&&"function"!=typeof i?c(n):i}}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function r(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return s(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function d(){}d.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))}};function h(e){return(e+"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function f(t,n,e){var i,o=t.trigger,r={};for(i in t.trigger=function(){var e=arguments[0];if(-1===n.indexOf(e))return o.apply(t,arguments);r[e]=arguments},e.apply(t,[]),t.trigger=o,r)r.hasOwnProperty(i)&&o.apply(t,r[i])}function g(e,t){var n=document.createEvent("HTMLEvents");n.initEvent(t,!0,!1),e.dispatchEvent(n)}function v(t,n){Object.keys(n).forEach(function(e){t.style[e]=n[e]})}function x(e){var t=C.apply(null,arguments);e=A(e);for(var n,i=0;i<e.length;i++){(n=e[i].classList).add.apply(n,r(t))}}function F(e){var t=C.apply(null,arguments);e=A(e);for(var n,i=0;i<e.length;i++){(n=e[i].classList).remove.apply(n,r(t))}}function O(n,e,i,o){for(var t=e.split(/\s/),r=function(e){var t=S(e.target,i,n);t&&(e.delegateTarget=t,o.call(t,e))},s=0;s<t.length;s++)n.addEventListener(t[s],r,!0)}function m(e,t){if(!e)return-1;t=t||e.nodeName;for(var n=0;e=e.previousElementSibling;)e.matches(t)&&n++;return n}var t=/Mac/.test(navigator.userAgent),y=t?18:17,b=t?"metaKey":"ctrlKey",w=function(u,e){var t,c=Object.assign({},_.defaults,e),p=c.dataAttr,d=c.labelField,h=c.valueField,f=c.disabledField,g=c.optgroupField,v=c.optgroupLabelField,m=c.optgroupValueField,n=u.tagName.toLowerCase(),i=u.getAttribute("placeholder")||u.getAttribute("data-placeholder");i||c.allowEmptyOption||(t=u.querySelector('option[value=""]'))&&(i=t.textContent);var y={placeholder:i,options:[],optgroups:[],items:[]};return("select"===n?function(){function s(e){var t=Object.assign({},e.dataset),n=p&&t[p];return"string"==typeof n&&n.length&&(t=Object.assign(t,JSON.parse(n))),t}function a(e,t){var n,i,o=P(e.value);(o||c.allowEmptyOption)&&(l.hasOwnProperty(o)?t&&((n=l[o][g])?Array.isArray(n)?n.push(t):l[o][g]=[n,t]:l[o][g]=t):((i=s(e))[d]=i[d]||e.textContent,i[h]=i[h]||o,i[f]=i[f]||e.disabled,i[g]=i[g]||t,l[o]=i,r.push(i),e.selected&&y.items.push(o)))}var e,t,n,i,r=y.options,l={};for(y.maxItems=u.hasAttribute("multiple")?null:1,e=0,t=(i=u.children).length;e<t;e++)"optgroup"===(n=i[e].tagName.toLowerCase())?function(e){var t,n=e.getAttribute("label");n&&((t=s(e))[v]=n,t[m]=n,t[f]=e.disabled,y.optgroups.push(t));for(var i,o=0,r=(i=e.children).length;o<r;o++)a(i[o],n)}(i[e]):"option"===n&&a(i[e])}:function(){var e,t,n,i,o=u.getAttribute(p);if(o)for(y.options=JSON.parse(o),e=0,t=y.options.length;e<t;e++)y.items.push(y.options[e][h]);else{var r=u.value.trim()||"";if(!c.allowEmptyOption&&!r.length)return;for(e=0,t=(n=r.split(c.delimiter)).length;e<t;e++)(i={})[d]=n[e],i[h]=n[e],y.options.push(i);y.items=n}})(),Object.assign({},_.defaults,y,e)},P=function(e){return null==e?null:"boolean"==typeof e?e?"1":"0":e+""},k=function(e){if(e.jquery)return e[0];if(e instanceof HTMLElement)return e;if(-1<e.indexOf("<")){var t=document.createElement("div");return t.innerHTML=e.trim(),t.firstChild}return document.querySelector(e)},C=function(){for(var e=[],t=1;t<arguments.length;t++){var n=arguments[t];"string"==typeof n&&(n=n.trim().split(/[\11\12\14\15\40]/)),Array.isArray(n)&&(e=e.concat(n))}return e.filter(Boolean)},A=function(e){return Array.isArray(e)||(e=[e]),e},S=function(e,t,n){for(;e&&e.matches;){if(e.matches(t))return e;if(e==n)break;e=e.parentNode}},I=function(e,t){return 0<t?e[e.length-1]:e[0]},_=function(){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(s,d);var e,t,n,r=u(s);function s(e,t){var n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s);var i=c(n=r.call(this));if((e=k(e)).tomselect)throw new Error("Tom Select already initialized on this element");e.tomselect=i,t=w(e,t);var o=(window.getComputedStyle&&window.getComputedStyle(e,null)).getPropertyValue("direction");return Object.assign(i,{order:0,settings:t,input:e,tabIndex:e.getAttribute("tabindex")||"",is_select_tag:"select"===e.tagName.toLowerCase(),rtl:/rtl/i.test(o),highlightedValue:null,isBlurring:!1,isOpen:!1,isDisabled:!1,isRequired:e.required,isInvalid:!1,isLocked:!1,isFocused:!1,isInputHidden:!1,isSetup:!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:{item:{},option:{}}}),i.settings.load&&i.settings.loadThrottle&&(i.settings.load=i.loadDebounce(i.settings.load,i.settings.loadThrottle)),i.sifter=new a(n.options,{diacritics:t.diacritics}),i.setupOptions(i.settings.options,i.settings.optgroups),delete i.settings.optgroups,delete i.settings.options,i.settings.mode=i.settings.mode||(1===i.settings.maxItems?"single":"multi"),"boolean"!=typeof i.settings.hideSelected&&(i.settings.hideSelected="multi"===i.settings.mode),"string"==typeof i.settings.createFilter&&(i.settings.createFilter=new RegExp(i.settings.createFilter)),i.initializePlugins(i.settings.plugins),i.setupCallbacks(),i.setupTemplates(),i.setup(),n}return e=s,(t=[{key:"setup",value:function(){var n,e,t,i,o,r,s,a,l=this,u=l.settings,c=l.input,p=l.settings.mode,d=c.getAttribute("class")||"",h=k("<div>");if(x(h,u.wrapperClass,d,p),n=k('<div class="items">'),x(n,u.inputClass),h.append(n),t=l.render("dropdown"),x(t,u.dropdownClass,p),i=k('<div style="scroll-behavior: smooth;">'),x(i,u.dropdownContentClass),t.append(i),k(u.dropdownParent||h).appendChild(t),u.controlInput)e=k(u.controlInput);else{e=k('<input type="text" autocomplete="off" />');for(var f=["autocorrect","autocapitalize","autocomplete"],g=0;g<f.length;g++){var v=f[g];c.getAttribute(v)&&e.setAttribute(v,c.getAttribute(v))}}u.controlInput||(e.setAttribute("tabindex",c.disabled?"-1":l.tabIndex),n.appendChild(e)),(r=c.getAttribute("id"))&&(e.setAttribute("id",r+"-tomselected"),(s=document.querySelector("label[for='"+r+"']"))&&s.setAttribute("for",r+"-tomselected")),l.settings.copyClassesToDropdown&&x(t,d),h.style.width=c.style.width,l.plugins.names.length&&(o="plugin-"+l.plugins.names.join(" plugin-"),x([h,t],o)),(null===u.maxItems||1<u.maxItems)&&l.is_select_tag&&c.setAttribute("multiple","multiple"),l.settings.placeholder&&e.setAttribute("placeholder",u.placeholder),!l.settings.splitOn&&l.settings.delimiter&&(a=l.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),l.settings.splitOn=new RegExp("\\s*"+a+"+\\s*")),e.type=c.type,l.control=n,l.control_input=e,l.wrapper=h,l.dropdown=t,l.dropdown_content=i,O(t,"mouseenter","[data-selectable]",function(){return l.onOptionHover.apply(l,arguments)}),O(t,"mousedown","[data-selectable]",function(){return l.onOptionSelect.apply(l,arguments)}),n.addEventListener("mousedown",function(e){var t=S(e.target,"."+l.settings.itemClass,n);return t?(e.delegateTarget=t,l.onItemSelect.call(l,e)):l.onMouseDown.call(l,e)}),n.addEventListener("click",function(){return l.onClick.apply(l,arguments)}),e.addEventListener("mousedown",function(e){e.stopPropagation()}),e.addEventListener("keydown",function(){return l.onKeyDown.apply(l,arguments)}),e.addEventListener("keyup",function(){return l.onKeyUp.apply(l,arguments)}),e.addEventListener("keypress",function(){return l.onKeyPress.apply(l,arguments)}),e.addEventListener("resize",function(){l.positionDropdown.apply(l,[])}),e.addEventListener("blur",function(){return l.onBlur.apply(l,arguments)}),e.addEventListener("focus",function(){return l.ignoreBlur=!1,l.onFocus.apply(l,arguments)}),e.addEventListener("paste",function(){return l.onPaste.apply(l,arguments)});function m(e){if(l.isFocused){if(S(e.target,"."+l.settings.wrapperClass,l.wrapper))return!1;l.blur(e.target)}}function y(){l.isOpen&&l.positionDropdown.apply(l,arguments)}function b(){l.ignoreHover=!1}document.addEventListener("mousedown",m),window.addEventListener("sroll",y),window.addEventListener("resize",y),window.addEventListener("mousemove",b),l._destroy=function(){document.removeEventListener("mousedown",m),window.removeEventListener("mousemove",b),window.removeEventListener("sroll",y),window.removeEventListener("resize",y)};for(var w=[];0<c.children.length;)w.push(c.children[0]),c.children[0].remove();this.revertSettings={children:w,tabindex:c.getAttribute("tabindex")},c.setAttribute("tabindex",-1),c.setAttribute("hidden","hidden"),c.insertAdjacentElement("afterend",l.wrapper),l.setValue(u.items),delete u.items,l.supportsValidity()&&c.addEventListener("invalid",function(e){e.preventDefault(),l.isInvalid=!0,l.refreshState()}),l.updateOriginalInput(),l.refreshItems(),l.refreshState(),l.isSetup=!0,c.disabled&&l.disable(),l.on("change",this.onChange),x(c,"tomselected"),l.trigger("initialize"),!0===u.preload&&l.onSearchChange("")}},{key:"supportsValidity",value:function(){return!/android/i.test(window.navigator.userAgent)&&!!document.createElement("input").validity}},{key:"setupOptions",value:function(e,t){var n,i;for(t=t||[],n=0,i=(e=e||[]).length;n<i;n++)this.registerOption(e[n]);for(n=0,i=t.length;n<i;n++)this.registerOptionGroup(t[n])}},{key:"setupTemplates",value:function(){var n=this.settings.labelField,i=this.settings.optgroupLabelField,e={optgroup:function(e,t){var n=document.createElement("div");return n.className="optgroup",n.appendChild(e.options),n},optgroup_header:function(e,t){return'<div class="optgroup-header">'+t(e[i])+"</div>"},option:function(e,t){return"<div>"+t(e[n])+"</div>"},item:function(e,t){return"<div>"+t(e[n])+"</div>"},option_create:function(e,t){return'<div class="create">Add <strong>'+t(e.input)+"</strong>…</div>"},no_results:function(){return'<div class="no-results">No results found</div>'},loading:function(){return'<div class="spinner"></div>'},dropdown:function(){return'<div style="display:none"></div>'}};this.settings.render=Object.assign({},e,this.settings.render)}},{key:"setupCallbacks",value: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)(t=this.settings[n[e]])&&this.on(e,t)}},{key:"onClick",value:function(e){this.isFocused&&this.isOpen||(this.focus(),e.preventDefault())}},{key:"onMouseDown",value:function(e){var t=this;if(t.isFocused){if(e.target!==t.control_input)return"single"===t.settings.mode?t.isOpen?t.close():t.open():t.setActiveItem(null),!1}else window.setTimeout(function(){t.focus()},0)}},{key:"onChange",value:function(){g(this.input,"change")}},{key:"onPaste",value:function(e){var o=this;o.isFull()||o.isInputHidden||o.isLocked?e.preventDefault():o.settings.splitOn&&setTimeout(function(){var e=o.inputValue();if(e.match(o.settings.splitOn))for(var t=e.trim().split(o.settings.splitOn),n=0,i=t.length;n<i;n++)o.createItem(t[n])},0)}},{key:"onKeyPress",value: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}},{key:"onKeyDown",value:function(e){e.target,this.control_input;var t,n,i=this;if(i.isLocked)9!==e.keyCode&&e.preventDefault();else{switch(e.keyCode){case 65:if(i.isKeyDown(y,e))return void i.selectAll();break;case 27:return void(i.isOpen&&(e.preventDefault(),e.stopPropagation(),i.close()));case 40:return!i.isOpen&&i.hasOptions?i.open():i.activeOption&&(i.ignoreHover=!0,(t=i.getAdjacent(i.activeOption,1))&&i.setActiveOption(t,!0)),void e.preventDefault();case 38:return i.activeOption&&(i.ignoreHover=!0,(n=i.getAdjacent(i.activeOption,-1))&&i.setActiveOption(n,!0)),void e.preventDefault();case 13:return void(i.isOpen&&i.activeOption&&(i.onOptionSelect({delegateTarget: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({delegateTarget:i.activeOption}),e.preventDefault()),void(i.settings.create&&i.createItem()&&e.preventDefault());case 8:case 46:return void i.deleteSelection(e)}!i.isInputHidden||i.isKeyDown(y,e)||e.preventDefault()}}},{key:"onKeyUp",value:function(e){var t=this;if(t.isLocked)return e&&e.preventDefault();var n=t.inputValue();t.lastValue!==n&&(t.lastValue=n,t.onSearchChange(n),t.refreshOptions(),t.trigger("type",n))}},{key:"onSearchChange",value: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])})))}},{key:"onFocus",value: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())}},{key:"onBlur",value:function(e,t){var n=this;if(n.isFocused){if(n.isFocused=!1,n.ignoreFocus=!1,!n.ignoreBlur&&document.activeElement===n.dropdown_content)return n.ignoreBlur=!0,void n.onFocus(e);var i=function(){n.close(),n.setActiveItem(null),n.setActiveOption(null),n.setCaret(n.items.length),n.refreshState(),t&&t.focus&&t.focus(),n.isBlurring=!1,n.trigger("blur")};n.isBlurring=!0,n.settings.create&&n.settings.createOnBlur?n.createItem(null,!1,i):i()}}},{key:"onOptionHover",value:function(e){this.ignoreHover||this.setActiveOption(e.delegateTarget,!1)}},{key:"onOptionSelect",value:function(e){var t,n=this;e.preventDefault&&(e.preventDefault(),e.stopPropagation());var i=e.delegateTarget;i&&(i.parentNode&&i.parentNode.matches("[data-disabled]")||(i.classList.contains("create")?n.createItem(null,function(){n.settings.closeAfterSelect&&n.close()}):void 0!==(t=i.dataset.value)&&(n.lastQuery=null,n.addItem(t),n.settings.closeAfterSelect?n.close():!n.settings.hideSelected&&e.type&&/mouse/.test(e.type)&&n.setActiveOption(n.getOption(t)))))}},{key:"onItemSelect",value:function(e){this.isLocked||"multi"===this.settings.mode&&(e.preventDefault(),this.setActiveItem(e.delegateTarget,e))}},{key:"load",value:function(e){var n=this;x(n.wrapper,n.settings.loadingClass),n.loading++,e.call(n,function(e,t){n.loading=Math.max(n.loading-1,0),n.lastQuery=null,n.setupOptions(e,t),n.refreshOptions(n.isFocused&&!n.isInputHidden),n.loading||F(n.wrapper,n.settings.loadingClass),n.trigger("load",e)})}},{key:"loadDebounce",value:function(n,i){var o;return function(){var e=this,t=arguments;o&&(e.loading=Math.max(e.loading-1,0)),window.clearTimeout(o),o=window.setTimeout(function(){o=null,n.apply(e,t)},i)}}},{key:"setTextboxValue",value:function(e){var t=this.control_input;t.value!==e&&(t.value=e,g(t,"update"),this.lastValue=e)}},{key:"getValue",value:function(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}},{key:"setValue",value:function(e,t){f(this,t?[]:["change"],function(){this.clear(t),this.addItems(e,t)})}},{key:"setActiveItem",value:function(e,t){var n,i,o,r,s,a;if("single"!==this.settings.mode){if(!e)return F(this.activeItems,"active"),this.activeItems=[],void(this.isFocused&&this.showInput());if("mousedown"===(n=t&&t.type.toLowerCase())&&this.isKeyDown(16,t)&&this.activeItems.length){for(a=this.getLastActive(),o=Array.prototype.indexOf.call(this.control.children,a),(r=Array.prototype.indexOf.call(this.control.children,e))<o&&(s=o,o=r,r=s),i=o;i<=r;i++)e=this.control.children[i],-1===this.activeItems.indexOf(e)&&this.setActiveItemClass(e);t.preventDefault()}else"mousedown"===n&&this.isKeyDown(y,t)||"keydown"===n&&this.isKeyDown(16,t)?e.classList.contains("active")?this.removeActiveItem(e):this.setActiveItemClass(e):(F(this.activeItems,"active"),this.activeItems=[],this.setActiveItemClass(e));this.hideInput(),this.isFocused||this.focus()}}},{key:"setActiveItemClass",value:function(e){var t=this.control.querySelector(".last-active");t&&F(t,"last-active"),x(e,"active last-active"),-1==this.activeItems.indexOf(e)&&this.activeItems.push(e)}},{key:"removeActiveItem",value:function(e){var t=this.activeItems.indexOf(e);this.activeItems.splice(t,1),F(e,"active")}},{key:"setActiveOption",value:function(e,t){var n,i,o;e!==this.activeOption&&(this.activeOption&&F(this.activeOption,"active"),this.activeOption=null,e&&(this.activeOption=e,x(e,"active"),!t&&void 0!==t||(n=this.dropdown_content.clientHeight,t=this.dropdown_content.scrollTop||0,i=this.activeOption.offsetHeight,n+t<(o=this.activeOption.getBoundingClientRect().top-this.dropdown_content.getBoundingClientRect().top+t)+i?this.dropdown_content.scrollTop=o-n+i:o<t&&(this.dropdown_content.scrollTop=o))))}},{key:"selectAll",value:function(){"single"!==this.settings.mode&&(this.activeItems=this.controlChildren(),this.activeItems.length&&(x(this.activeItems,"active"),this.hideInput(),this.close()),this.focus())}},{key:"hideInput",value:function(){this.settings.controlInput||(this.setTextboxValue(""),v(this.control_input,{opacity:0,position:"absolute",left:(this.rtl?1e4:-1e4)+"px"}),this.isInputHidden=!0)}},{key:"showInput",value:function(){this.settings.controlInput||(v(this.control_input,{opacity:1,position:"relative",left:0}),this.isInputHidden=!1)}},{key:"inputValue",value:function(){return this.control_input.value.trim()}},{key:"focus",value:function(){var e=this;e.isDisabled||(e.ignoreFocus=!0,e.control_input.focus(),window.setTimeout(function(){e.ignoreFocus=!1,e.onFocus()},0))}},{key:"blur",value:function(e){this.control_input.blur(),this.onBlur(null,e)}},{key:"getScoreFunction",value:function(e){return this.sifter.getScoreFunction(e,this.getSearchOptions())}},{key:"getSearchOptions",value: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}}},{key:"search",value:function(e){var t,n,i,o=this,r=o.settings,s=this.getSearchOptions();if(r.score&&"function"!=typeof(i=o.settings.score.call(this,e)))throw new Error('Tom Select "score" setting must be a function that returns a function');if(e!==o.lastQuery?(o.lastQuery=e,n=o.sifter.search(e,Object.assign(s,{score:i})),o.currentResults=n):n=Object.assign({},o.currentResults),r.hideSelected)for(t=n.items.length-1;0<=t;t--)-1!==o.items.indexOf(P(n.items[t].id))&&n.items.splice(t,1);return n}},{key:"refreshOptions",value:function(e){var t,n,i,o,r,s;void 0===e&&(e=!0);var a,l,u,c=this,p=c.inputValue(),d=c.search(p),h=c.activeOption&&P(c.activeOption.dataset.value),f=!1,g=d.items.length;for("number"==typeof c.settings.maxOptions&&(g=Math.min(g,c.settings.maxOptions)),0<g&&(f=!0),n={},i=[],t=0;t<g;t++)for(var v,m=c.options[d.items[t].id],y=P(m[c.settings.valueField]),b=(b=c.getOption(y))||c.render("option",m),w=m[c.settings.optgroupField]||"",O=0,k=(v=Array.isArray(w)?w:[w])&&v.length;O<k;O++)w=v[O],c.optgroups.hasOwnProperty(w)||(w=""),n.hasOwnProperty(w)||(n[w]=document.createDocumentFragment(),i.push(w)),0<O&&(b=b.cloneNode(!0),F(b,"active")),n[w].appendChild(b);for(this.settings.lockOptgroupOrder&&i.sort(function(e,t){return(c.optgroups[e].$order||0)-(c.optgroups[t].$order||0)}),o=document.createDocumentFragment(),t=0,g=i.length;t<g;t++){w=i[t],c.optgroups.hasOwnProperty(w)&&n[w].children.length?((a=document.createDocumentFragment()).appendChild(c.render("optgroup_header",c.optgroups[w])),a.appendChild(n[w]),l=c.render("optgroup",{group:c.optgroups[w],options:a}),o.appendChild(l)):o.appendChild(n[w])}if(c.dropdown_content.innerHTML="",c.dropdown_content.appendChild(o),c.settings.highlight&&(c.dropdown_content,u=document.querySelectorAll("span.highlight"),Array.prototype.forEach.call(u,function(e,t){var n=e.parentNode;n.replaceChild(e.firstChild,e),n.normalize()}),d.query.length&&d.tokens.length))for(t=0,g=d.tokens.length;t<g;t++)!function(e,t){var u,n;"string"==typeof t&&!t.length||(u="string"==typeof t?new RegExp(t,"i"):t,n=function e(t){var n=0;if(3===t.nodeType){var i,o,r,s,a=t.data.search(u);0<=a&&0<t.data.length&&(i=t.data.match(u),(o=document.createElement("span")).className="highlight",(r=t.splitText(a)).splitText(i[0].length),s=r.cloneNode(!0),o.appendChild(s),r.parentNode.replaceChild(o,r),n=1)}else if(1===t.nodeType&&t.childNodes&&!/(script|style)/i.test(t.tagName)&&("highlight"!==t.className||"SPAN"!==t.tagName))for(var l=0;l<t.childNodes.length;++l)l+=e(t.childNodes[l]);return n},n(e))}(c.dropdown_content,d.tokens[t].regex);if(!c.settings.hideSelected)for(t=0,g=c.items.length;t<g;t++){var C=c.getOption(c.items[t]);C&&x(C,"selected")}function A(e){f=!0;var t=c.render(e,{input:p});return c.dropdown_content.insertBefore(t,c.dropdown_content.firstChild),t}var S,I,_;c.loading?A("loading"):0===d.items.length&&c.settings.render.no_results&&p.length&&A("no_results"),(r=c.canCreate(p))&&(s=A("option_create")),c.hasOptions=0<d.items.length||r,f?(_=0<d.items.length?(I=h&&c.getOption(h))&&c.dropdown_content.contains(I)?I:"single"===c.settings.mode&&c.items.length?c.getOption(c.items[0]):(S=0,s&&!c.settings.addPrecedence&&(S=1),c.selectable()[S]):s,c.setActiveOption(_),e&&!c.isOpen&&c.open()):(c.setActiveOption(null),e&&c.isOpen&&c.close())}},{key:"selectable",value:function(){return this.dropdown_content.querySelectorAll("[data-selectable]")}},{key:"addOption",value:function(e){var t,n,i,o=this;if(Array.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))}},{key:"registerOption",value:function(e){var t=P(e[this.settings.valueField]);return null!=t&&!this.options.hasOwnProperty(t)&&(e.$order=e.$order||++this.order,this.options[t]=e,t)}},{key:"registerOptionGroup",value:function(e){var t=P(e[this.settings.optgroupValueField]);return!!t&&(e.$order=e.$order||++this.order,this.optgroups[t]=e,t)}},{key:"addOptionGroup",value:function(e,t){t[this.settings.optgroupValueField]=e,(e=this.registerOptionGroup(t))&&this.trigger("optgroup_add",e,t)}},{key:"removeOptionGroup",value:function(e){this.optgroups.hasOwnProperty(e)&&(delete this.optgroups[e],this.clearCache(),this.trigger("optgroup_remove",e))}},{key:"clearOptionGroups",value:function(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")}},{key:"updateOption",value:function(e,t){var n,i,o,r,s,a,l,u=this;if(e=P(e),o=P(t[u.settings.valueField]),null!==e&&u.options.hasOwnProperty(e)){if("string"!=typeof o)throw new Error("Value must be set in option data");l=u.options[e].$order,o!==e&&(delete u.options[e],-1!==(r=u.items.indexOf(e))&&u.items.splice(r,1,o)),t.$order=t.$order||l,u.options[o]=t,s=u.renderCache.item,a=u.renderCache.option,s&&(delete s[e],delete s[o]),a&&(delete a[e],delete a[o]),-1!==u.items.indexOf(o)&&(n=u.getItem(e),i=u.render("item",t),n.classList.contains("active")&&x(i,"active"),n.parentNode.insertBefore(i,n),n.remove()),u.lastQuery=null,u.isOpen&&u.refreshOptions(!1)}}},{key:"removeOption",value:function(e,t){var n=this;e=P(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)}},{key:"clearOptions",value:function(){this.loadedSearches={},this.userOptions={},this.clearCache();var e={};for(var t in this.options)this.options.hasOwnProperty(t)&&0<=this.items.indexOf(t)&&(e[t]=this.options[t]);this.options=this.sifter.items=e,this.lastQuery=null,this.trigger("option_clear")}},{key:"getOption",value:function(e){return this.renderCache.option.hasOwnProperty(e)?this.renderCache.option[e]:this.getElementWithValue(e,this.selectable())}},{key:"getAdjacent",value:function(e,t,n){var i=2<arguments.length&&void 0!==n?n:"option";if(e){var o=this.settings.optionClass,r=this.dropdown;"item"==i&&(r=this.control,o=this.settings.itemClass);for(var s=r.querySelectorAll("."+o),a=0;a<s.length;a++)if(s[a]==e)return 0<t?s[a+1]:s[a-1]}}},{key:"getElementWithValue",value:function(e,t){if(null!=(e=P(e)))for(var n=0,i=t.length;n<i;n++)if(t[n].getAttribute("data-value")===e)return t[n]}},{key:"getItem",value:function(e){return this.getElementWithValue(e,this.control.children)}},{key:"addItems",value:function(e,t){this.buffer=document.createDocumentFragment();for(var n=this.control.children,i=0;i<n.length;i++)this.buffer.appendChild(n[i]);for(var o=Array.isArray(e)?e:[e],i=0,r=o.length;i<r;i++)this.isPending=i<r-1,this.addItem(o[i],t);var s=this.control;s.insertBefore(this.buffer,s.firstChild),this.buffer=null}},{key:"addItem",value:function(a,l){f(this,l?[]:["change"],function(){var e,t,n,i,o,r=this,s=r.settings.mode;a=P(a),(-1===r.items.indexOf(a)||("single"===s&&r.close(),"single"!==s&&r.settings.duplicates))&&r.options.hasOwnProperty(a)&&("single"===s&&r.clear(l),"multi"===s&&r.isFull()||(o=r.render("item",r.options[a]),this.control.contains(o)&&(o=o.cloneNode(!0)),e=r.isFull(),r.items.splice(r.caretPos,0,a),r.insertAtCaret(o),r.isPending&&(e||!r.isFull())||r.refreshState(),r.isSetup&&(t=r.selectable(),r.isPending||(n=r.getOption(a),i=r.getAdjacent(n,1),r.refreshOptions(r.isFocused&&"single"!==s),i&&r.setActiveOption(i)),!t.length||r.isFull()?r.close():r.isPending||r.positionDropdown(),r.trigger("item_add",a,o),r.isPending||r.updateOriginalInput({silent:l}))))})}},{key:"removeItem",value:function(e,t){var n,i,o=this.getItem(e);o&&(e=P(o.dataset.value),-1!==(n=this.items.indexOf(e))&&(o.remove(),o.classList.contains("active")&&(i=this.activeItems.indexOf(o),this.activeItems.splice(i,1),F(o,"active")),this.items.splice(n,1),this.lastQuery=null,!this.settings.persist&&this.userOptions.hasOwnProperty(e)&&this.removeOption(e,t),n<this.caretPos&&this.setCaret(this.caretPos-1),this.refreshState(),this.updateOriginalInput({silent:t}),this.positionDropdown(),this.trigger("item_remove",e,o)))}},{key:"createItem",value:function(e,n){var t,i=this,o=i.caretPos;e=e||i.inputValue();var r=arguments[arguments.length-1];if("function"!=typeof r&&(r=function(){}),"boolean"!=typeof n&&(n=!0),!i.canCreate(e))return r(),!1;i.lock();function s(e){if(i.unlock(),!e||"object"!==l(e))return r();var t=P(e[i.settings.valueField]);if("string"!=typeof t)return r();i.setTextboxValue(""),i.addOption(e),i.setCaret(o),i.addItem(t),i.refreshOptions(n&&"single"!==i.settings.mode),r(e),a=!0}var a=!1;return"function"==typeof i.settings.create?t=i.settings.create.apply(this,[e,s]):((t={})[i.settings.labelField]=e,t[i.settings.valueField]=e),a||s(t),!0}},{key:"refreshItems",value:function(){this.lastQuery=null,this.isSetup&&this.addItem(this.items),this.refreshState(),this.updateOriginalInput()}},{key:"refreshState",value:function(){var e=this;e.refreshValidityState();var t=e.isFull(),n=e.isLocked;e.wrapper.classList.toggle("rtl",e.rtl);var i,o=e.control.classList;o.toggle("focus",e.isFocused),o.toggle("disabled",e.isDisabled),o.toggle("required",e.isRequired),o.toggle("invalid",e.isInvalid),o.toggle("locked",n),o.toggle("full",t),o.toggle("not-full",!t),o.toggle("input-active",e.isFocused&&!e.isInputHidden),o.toggle("dropdown-active",e.isOpen),o.toggle("has-options",(i=e.options,0===Object.keys(i).length)),o.toggle("has-items",0<e.items.length)}},{key:"refreshValidityState",value:function(){if(!this.isRequired)return!1;var e=!this.items.length;this.isInvalid=e,this.control_input.required=e,this.input.required=!e}},{key:"isFull",value:function(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems}},{key:"updateOriginalInput",value:function(e){var t,n,i,o,r=this;if(e=e||{},r.is_select_tag){for(i=[],t=0,n=r.items.length;t<n;t++)o=r.options[r.items[t]][r.settings.labelField]||"",i.push('<option value="'+h(r.items[t])+'" selected="selected">'+h(o)+"</option>");i.length||this.input.hasAttribute("multiple")||i.push('<option value="" selected="selected"></option>'),r.input.innerHTML=i.join("")}else r.input.value=r.getValue(),r.input.setAttribute("value",r.input.value);r.isSetup&&(e.silent||r.trigger("change",r.input.value))}},{key:"open",value:function(){var e=this;e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.focus(),e.isOpen=!0,e.refreshState(),v(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),v(e.dropdown,{visibility:"visible",display:"block"}),e.trigger("dropdown_open",e.dropdown))}},{key:"close",value:function(){var e=this,t=e.isOpen;"single"===e.settings.mode&&e.items.length&&(e.hideInput(),e.isBlurring||e.blur()),e.isOpen=!1,v(e.dropdown,{display:"none"}),e.setActiveOption(null),e.refreshState(),t&&e.trigger("dropdown_close",e.dropdown)}},{key:"positionDropdown",value:function(){var e,t,n,i;"body"===this.settings.dropdownParent&&(t=(e=this.control).getBoundingClientRect(),n=e.offsetHeight+t.top+window.scrollY,i=t.left+window.scrollX,v(this.dropdown,{width:t.width+"px",top:n+"px",left:i+"px"}))}},{key:"clear",value:function(e){if(this.items.length){for(var t=this.controlChildren(),n=0;n<t.length;n++)t[n].remove();this.items=[],this.lastQuery=null,this.setCaret(0),this.setActiveItem(null),this.updateOriginalInput({silent:e}),this.refreshState(),this.showInput(),this.trigger("clear")}}},{key:"insertAtCaret",value:function(e){var t=Math.min(this.caretPos,this.items.length),n=this.buffer||this.control;0===t?n.insertBefore(e,n.firstChild):n.insertBefore(e,n.children[t]),this.setCaret(t+1)}},{key:"deleteSelection",value:function(e){var t,n,i,o,r,s=this,a=e&&8===e.keyCode?-1:1,l={start:(r=s.control_input).selectionStart,length:r.selectionEnd-r.selectionStart},u=[];if(s.activeItems.length){for(o=I(s.activeItems,a),i=m(o),0<a&&i++,t=0,n=s.activeItems.length;t<n;t++)u.push(s.activeItems[t].dataset.value);e&&(e.preventDefault(),e.stopPropagation())}else(s.isFocused||"single"===s.settings.mode)&&s.items.length&&(a<0&&0===l.start&&0===l.length?u.push(s.items[s.caretPos-1]):0<a&&l.start===s.inputValue().length&&u.push(s.items[s.caretPos]));if(!u.length||"function"==typeof s.settings.onDelete&&!1===s.settings.onDelete.apply(s,[u,e]))return!1;for(void 0!==i&&s.setCaret(i);u.length;)s.removeItem(u.pop());return s.showInput(),s.positionDropdown(),s.refreshOptions(!1),!0}},{key:"advanceSelection",value:function(e,t){var n,i,o;0!==e&&(this.rtl&&(e*=-1),this.isKeyDown(y,t)||this.isKeyDown(16,t)?(i=this.getLastActive(e),(o=this.getAdjacent(i,e,"item"))&&(o.classList.contains("active")&&this.removeActiveItem(i),this.setActiveItemClass(o))):this.isFocused&&!this.isInputHidden?this.inputValue().length||this.setCaret(this.caretPos+e):(i=this.getLastActive(e))&&(n=m(i),this.setCaret(0<e?n+1:n),this.setActiveItem(null)))}},{key:"getLastActive",value:function(e){var t=this.control.querySelector(".last-active");return t||function(e,t,n){var i=e.querySelectorAll(t);if(i)return I(i,n)}(this.control,".active",e)}},{key:"setCaret",value:function(e){var t=this;if(e="single"===t.settings.mode||t.settings.controlInput?t.items.length:Math.max(0,Math.min(t.items.length,e)),!t.settings.controlInput&&!t.isPending)for(var n,i=this.controlChildren(),o=i.length,r=0;r<o;r++)n=i[r],r<e?t.control_input.insertAdjacentElement("beforebegin",n):t.control.appendChild(n);t.caretPos=e}},{key:"controlChildren",value:function(){return Array.prototype.filter.call(this.control.children,function(e){return"INPUT"!==e.nodeName})}},{key:"lock",value:function(){this.close(),this.isLocked=!0,this.refreshState()}},{key:"unlock",value:function(){this.isLocked=!1,this.refreshState()}},{key:"disable",value:function(){this.input.disabled=!0,this.control_input.disabled=!0,this.control_input.tabIndex=-1,this.isDisabled=!0,this.lock()}},{key:"enable",value:function(){this.input.disabled=!1,this.control_input.disabled=!1,this.control_input.tabIndex=this.tabIndex,this.isDisabled=!1,this.unlock()}},{key:"destroy",value:function(){var e=this.revertSettings;this.trigger("destroy"),this.off(),this.wrapper.remove(),this.dropdown.remove(),this.input.innerHTML="",e.tabindex?this.input.setAttribute("tabindex",e.tabindex):this.input.removeAttribute("tabindex"),F(this.input,"tomselected"),this.input.removeAttribute("hidden");for(var t=0;t<e.children.length;t++)this.input.appendChild(e.children[t]);this._destroy(),delete this.input.tomselect}},{key:"render",value:function(e,t){var n,i,o="",r=this;return"option"!==e&&"item"!==e||(n=P(t[r.settings.valueField]),!r.renderCache[e].hasOwnProperty(n))?(o=k(r.settings.render[e].apply(this,[t,h])),"option"===e||"option_create"===e?t[r.settings.disabledField]||o.setAttribute("data-selectable",""):"optgroup"===e&&(i=t.group[r.settings.optgroupValueField],o.setAttribute("data-group",i),t.group[r.settings.disabledField]&&o.setAttribute("data-disabled","")),"option"!==e&&"item"!==e||(o.setAttribute("data-value",n),x(o,"item"===e?r.settings.itemClass:r.settings.optionClass),r.renderCache[e][n]=o),o):r.renderCache[e][n]}},{key:"clearCache",value:function(e){void 0===e?this.renderCache={item:{},option:{}}:this.renderCache[e]={}}},{key:"canCreate",value:function(e){if(!this.settings.create)return!1;var t=this.settings.createFilter;return e.length&&("function"!=typeof t||t.call(this,e))&&(!(t instanceof RegExp)||t.test(e))}},{key:"isKeyDown",value:function(e,t){return!!t&&(!t.altKey&&((!t[b]||!t.shiftKey)&&(!(e!=y||!t[b])||!(16!=e||!t.shiftKey))))}},{key:"hook",value:function(n,e,i){var o=this,r=o[e];o[e]=function(){var e,t;return"after"===n&&(e=r.apply(o,arguments)),t=i.apply(o,arguments),"instead"===n?t:("before"===n&&(e=r.apply(o,arguments)),e)}}}])&&i(e.prototype,t),n&&i(e,n),s}();if(void 0===e)throw'Dependency MicroPlugin is missing. Make sure you either: (1) are using the "complete" version of Tom Select, or (2) require MicroPlugin before you load Tom Select.';return e.mixin(_),_.count=0,_.defaults={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:!1,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,maxOptions:50,maxItems:null,hideSelected:null,duplicates:!1,addPrecedence:!1,selectOnTab:!1,preload:!1,allowEmptyOption:!1,closeAfterSelect:!1,scrollDuration:60,loadThrottle:300,loadingClass:"loading",dataAttr:null,optgroupField:"optgroup",valueField:"value",labelField:"text",disabledField:"disabled",optgroupLabelField:"label",optgroupValueField:"value",lockOptgroupOrder:!1,sortField:"$order",searchField:["text"],searchConjunction:"and",mode:null,wrapperClass:"ts-control",inputClass:"ts-input",dropdownClass:"ts-dropdown",dropdownContentClass:"ts-dropdown-content",itemClass:"item",optionClass:"option",dropdownParent:null,controlInput:null,copyClassesToDropdown:!0,render:{}},_.define("change_listener",function(e){var t=this,n=!1;t.input.addEventListener("change",function(){var e;n?n=!1:(n=!0,e=w(t.input,{}),t.setupOptions(e.options,e.optgroups),t.setValue(e.items))})}),_.define("drag_drop",function(e){if(!$.fn.sortable)throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');var t,n,i;"multi"===this.settings.mode&&(n=(t=this).lock,i=t.unlock,t.hook("instead","lock",function(){var e=t.control.dataset.sortable;return e&&e.disable(),n.apply(t,arguments)}),t.hook("instead","unlock",function(){var e=t.control.dataset.sortable;return e&&e.enable(),i.apply(t,arguments)}),t.hook("after","setup",function(){var n=$(t.control).sortable({items:"[data-value]",forcePlaceholderSize:!0,disabled:t.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=[];n.children("[data-value]").each(function(){e.push($(this).attr("data-value"))}),t.setValue(e)}})}))}),_.define("dropdown_header",function(t){var n=this;t=Object.assign({title:"Untitled",headerClass:"dropdown-header",titleRowClass:"dropdown-header-title",labelClass:"dropdown-header-label",closeClass:"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>'}},t),n.hook("after","setup",function(){var e=k(t.html(t));n.dropdown.insertBefore(e,n.dropdown.firstChild)})}),_.define("input_autogrow",function(e){var a=this;a.hook("after","setup",function(){var e=document.createElement("span"),t=this.control_input;e.style.position="absolute",e.style.top="-99999px",e.style.left="-99999px",e.style.width="auto",e.style.padding=0,e.style.whiteSpace="pre",a.wrapper.appendChild(e);for(var n=["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"],i=0,o=n.length;i<o;i++){var r=n[i];e.style[r]=t.style[r]}function s(){e.textContent=t.value,t.style.width=e.clientWidth+"px"}t.addEventListener("input",s),t.addEventListener("keyup",s),t.addEventListener("blur",s),t.addEventListener("update",s)})}),_.define("no_backspace_delete",function(e){this.hook("instead","setActiveItem",function(){}),this.hook("instead","selectAll",function(){}),this.hook("instead","deleteSelection",function(){})}),_.define("optgroup_columns",function(e){var r=this,s=r.onKeyDown;r.hook("instead","onKeyDown",function(e){var t,n,i,o;return!r.isOpen||37!==e.keyCode&&39!==e.keyCode?s.apply(r,arguments):(r.ignoreHover=!0,o=S(r.activeOption,"[data-group]"),t=m(r.activeOption,"[data-selectable]"),void((o=37===e.keyCode?o.previousSibling:o.nextSibling)&&(n=(i=o.querySelectorAll("[data-selectable]"))[Math.min(i.length-1,t)])&&r.setActiveOption(n)))})}),_.define("remove_button",function(e){e=Object.assign({label:"×",title:"Remove",className:"remove",append:!0},e);var i,o=this;e.append&&(i='<a href="javascript:void(0)" class="'+e.className+'" tabindex="-1" title="'+h(e.title)+'">'+e.label+"</a>",o.hook("after","setupTemplates",function(){var t=o.settings.render.item;o.settings.render.item=function(){var n=k(t.apply(o,arguments)),e=k(i);return n.appendChild(e),e.addEventListener("mousedown",function(e){e.preventDefault(),e.stopPropagation()}),e.addEventListener("click",function(e){var t;e.preventDefault(),e.stopPropagation(),"single"!==o.settings.mode&&e.stopPropagation(),o.isLocked||(t=n.dataset.value,o.removeItem(t),o.refreshOptions(!1))}),n}}))}),_.define("restore_on_backspace",function(i){var o=this;i.text=i.text||function(e){return e[o.settings.labelField]};var r=o.onKeyDown;o.hook("instead","onKeyDown",function(e){var t,n;return 8===e.keyCode&&""===o.control_input.value&&!o.activeItems.length&&0<=(t=o.caretPos-1)&&t<o.items.length?(n=o.options[o.items[t]],o.deleteSelection(e)&&(o.setTextboxValue(i.text.call(o,n)),o.refreshOptions(!0)),void e.preventDefault()):r.apply(o,arguments)})}),_});var tomSelect=function(e,t){return new TomSelect(e,t)}; | ||
!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,t){if(!(e=l(String(e||"").toLowerCase()))||!e.length)return[];for(var n,i,o=[],r=e.split(/ +/),s=0,a=r.length;s<a;s++){if(n=u(r[s]),this.settings.diacritics)for(i in c)c.hasOwnProperty(i)&&(n=n.replace(new RegExp(i,"g"),c[i]));t&&(n="\\b"+n),o.push({string:r[s],regex:new RegExp(n,"i")})}return o},e.prototype.iterator=function(e,t){var n=s(e)?Array.prototype.forEach||function(e){for(var t=0,n=this.length;t<n;t++)e(this[t],t,this)}:function(e){for(var t in this)this.hasOwnProperty(t)&&e(this[t],t,this)};n.apply(e,[t])},e.prototype.getScoreFunction=function(e,t){var o,r,s,a;e=this.prepareSearch(e,t),r=e.tokens,o=e.options.fields,s=r.length,a=e.options.nesting;function l(e,t){var n,i;return!e||-1===(i=(e=String(e||"")).search(t.regex))?0:(n=t.string.length/e.length,0===i&&(n+=.5),n)}var u,c=(u=o.length)?1===u?function(e,t){return l(f(t,o[0],a),e)}:function(e,t){for(var n=0,i=0;n<u;n++)i+=l(f(t,o[n],a),e);return i/u}:function(){return 0};return s?1===s?function(e){return c(r[0],e)}:"and"===e.options.conjunction?function(e){for(var t,n=0,i=0;n<s;n++){if((t=c(r[n],e))<=0)return 0;i+=t}return i/s}:function(e){for(var t=0,n=0;t<s;t++)n+=c(r[t],e);return n/s}:function(){return 0}},e.prototype.getSortFunction=function(e,n){var t,i,o,r,s,a,l,u=this,c=!(e=u.prepareSearch(e,n)).query&&n.sort_empty||n.sort,p=function(e,t){return"$score"===e?t.score:f(u.items[t.id],e,n.nesting)},d=[];if(c)for(t=0,i=c.length;t<i;t++)!e.query&&"$score"===c[t].field||d.push(c[t]);if(e.query){for(l=!0,t=0,i=d.length;t<i;t++)if("$score"===d[t].field){l=!1;break}l&&d.unshift({field:"$score",direction:"desc"})}else for(t=0,i=d.length;t<i;t++)if("$score"===d[t].field){d.splice(t,1);break}for(a=[],t=0,i=d.length;t<i;t++)a.push("desc"===d[t].direction?-1:1);return(r=d.length)?1===r?(o=d[0].field,s=a[0],function(e,t){return s*h(p(o,e),p(o,t))}):function(e,t){for(var n,i,o=0;o<r;o++)if(i=d[o].field,n=a[o]*h(p(i,e),p(i,t)))return n;return 0}:null},e.prototype.prepareSearch=function(e,t){if("object"==typeof e)return e;var n=(t=r({},t)).fields,i=t.sort,o=t.sort_empty;return n&&!s(n)&&(t.fields=[n]),i&&!s(i)&&(t.sort=[i]),o&&!s(o)&&(t.sort_empty=[o]),{options:t,query:String(e||"").toLowerCase(),tokens:this.tokenize(e,t.respect_word_boundaries),total:0,items:[]}},e.prototype.search=function(e,n){var i,t,o,r=this,s=this.prepareSearch(e,n);return n=s.options,e=s.query,o=n.score||r.getScoreFunction(s),e.length?r.iterator(r.items,function(e,t){i=o(e),(!1===n.filter||0<i)&&s.items.push({score:i,id:t})}):r.iterator(r.items,function(e,t){s.items.push({score:1,id:t})}),(t=r.getSortFunction(s,n))&&s.items.sort(t),s.total=s.items.length,"number"==typeof n.limit&&(s.items=s.items.slice(0,n.limit)),s};var h=function(e,t){return"number"==typeof e&&"number"==typeof t?t<e?1:e<t?-1:0:(e=n(String(e||"")),(t=n(String(t||"")))<e?1:e<t?-1:0)},r=function(e,t){for(var n,i,o=1,r=arguments.length;o<r;o++)if(i=arguments[o])for(n in i)i.hasOwnProperty(n)&&(e[n]=i[n]);return e},f=function(e,t,n){if(e&&t){if(!n)return e[t];for(var i=t.split(".");i.length&&(e=e[i.shift()]););return e}},l=function(e){return(e+"").replace(/^\s+|\s+$|/g,"")},u=function(e){return(e+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")},s=Array.isArray||"undefined"!=typeof $&&$.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},c={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 e,t,n,i,o="",r={};for(n in c)if(c.hasOwnProperty(n))for(o+=i=c[n].substring(2,c[n].length-1),e=0,t=i.length;e<t;e++)r[i.charAt(e)]=n;var s=new RegExp("["+o+"]","g");return function(e){return e.replace(s,function(e){return r[e]}).toLowerCase()}}();return e}),function(e,t){"function"==typeof define&&define.amd?define("microplugin",t):"object"==typeof exports?module.exports=t():e.MicroPlugin=t()}(this,function(){var e={mixin:function(i){i.plugins={},i.prototype.initializePlugins=function(e){var t,n,i,o=[];if(this.plugins={names:[],settings:{},requested:{},loaded:{}},r.isArray(e))for(t=0,n=e.length;t<n;t++)"string"==typeof e[t]?o.push(e[t]):(this.plugins.settings[e[t].name]=e[t].options,o.push(e[t].name));else if(e)for(i in e)e.hasOwnProperty(i)&&(this.plugins.settings[i]=e[i],o.push(i));for(;o.length;)this.require(o.shift())},i.prototype.loadPlugin=function(e){var t=this.plugins,n=i.plugins[e];if(!i.plugins.hasOwnProperty(e))throw new Error('Unable to find "'+e+'" plugin');t.requested[e]=!0,t.loaded[e]=n.fn.apply(this,[this.plugins.settings[e]||{}]),t.names.push(e)},i.prototype.require=function(e){var t=this.plugins;if(!this.plugins.loaded.hasOwnProperty(e)){if(t.requested[e])throw new Error('Plugin has circular dependency ("'+e+'")');this.loadPlugin(e)}return t.loaded[e]},i.define=function(e,t){i.plugins[e]={name:e,fn:t}}}},r={isArray:Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}};return e}),function(e,t){"function"==typeof define&&define.amd?define("tomselect",["sifter","microplugin"],t):"object"==typeof exports?module.exports=t(require("sifter"),require("microplugin")):e.TomSelect=t(e.Sifter,e.MicroPlugin)}(this,function(a,e){"use strict";function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(r){var s=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}();return function(){var e,t,n,i,o=p(r);return t=s?(e=p(this).constructor,Reflect.construct(o,arguments,e)):o.apply(this,arguments),n=this,!(i=t)||"object"!==l(i)&&"function"!=typeof i?c(n):i}}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function r(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return s(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function d(){}d.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))}};function h(e){return(e+"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function f(t,n,e){var i,o=t.trigger,r={};for(i in t.trigger=function(){var e=arguments[0];if(-1===n.indexOf(e))return o.apply(t,arguments);r[e]=arguments},e.apply(t,[]),t.trigger=o,r)r.hasOwnProperty(i)&&o.apply(t,r[i])}function g(e,t){var n=document.createEvent("HTMLEvents");n.initEvent(t,!0,!1),e.dispatchEvent(n)}function v(t,n){Object.keys(n).forEach(function(e){t.style[e]=n[e]})}function x(e){var t=b.apply(null,arguments);e=w(e);for(var n,i=0;i<e.length;i++){(n=e[i].classList).add.apply(n,r(t))}}function F(e){var t=b.apply(null,arguments);e=w(e);for(var n,i=0;i<e.length;i++){(n=e[i].classList).remove.apply(n,r(t))}}function O(n,e,i,o){for(var t=e.split(/\s/),r=function(e){var t=C(e.target,i,n);t&&(e.delegateTarget=t,o.call(t,e))},s=0;s<t.length;s++)n.addEventListener(t[s],r,!0)}function m(e,t){if(!e)return-1;t=t||e.nodeName;for(var n=0;e=e.previousElementSibling;)e.matches(t)&&n++;return n}var y=function(u,e){var t,c=Object.assign({},S.defaults,e),p=c.dataAttr,d=c.labelField,h=c.valueField,f=c.disabledField,g=c.optgroupField,v=c.optgroupLabelField,m=c.optgroupValueField,n=u.tagName.toLowerCase(),i=u.getAttribute("placeholder")||u.getAttribute("data-placeholder");i||c.allowEmptyOption||(t=u.querySelector('option[value=""]'))&&(i=t.textContent);var y={placeholder:i,options:[],optgroups:[],items:[]};return("select"===n?function(){function s(e){var t=Object.assign({},e.dataset),n=p&&t[p];return"string"==typeof n&&n.length&&(t=Object.assign(t,JSON.parse(n))),t}function a(e,t){var n,i,o=P(e.value);(o||c.allowEmptyOption)&&(l.hasOwnProperty(o)?t&&((n=l[o][g])?Array.isArray(n)?n.push(t):l[o][g]=[n,t]:l[o][g]=t):((i=s(e))[d]=i[d]||e.textContent,i[h]=i[h]||o,i[f]=i[f]||e.disabled,i[g]=i[g]||t,l[o]=i,r.push(i),e.selected&&y.items.push(o)))}var e,t,n,i,r=y.options,l={};for(y.maxItems=u.hasAttribute("multiple")?null:1,e=0,t=(i=u.children).length;e<t;e++)"optgroup"===(n=i[e].tagName.toLowerCase())?function(e){var t,n=e.getAttribute("label");n&&((t=s(e))[v]=n,t[m]=n,t[f]=e.disabled,y.optgroups.push(t));for(var i,o=0,r=(i=e.children).length;o<r;o++)a(i[o],n)}(i[e]):"option"===n&&a(i[e])}:function(){var e,t,n,i,o=u.getAttribute(p);if(o)for(y.options=JSON.parse(o),e=0,t=y.options.length;e<t;e++)y.items.push(y.options[e][h]);else{var r=u.value.trim()||"";if(!c.allowEmptyOption&&!r.length)return;for(e=0,t=(n=r.split(c.delimiter)).length;e<t;e++)(i={})[d]=n[e],i[h]=n[e],y.options.push(i);y.items=n}})(),Object.assign({},S.defaults,y,e)},P=function(e){return null==e?null:"boolean"==typeof e?e?"1":"0":e+""},k=function(e){if(e.jquery)return e[0];if(e instanceof HTMLElement)return e;if(-1<e.indexOf("<")){var t=document.createElement("div");return t.innerHTML=e.trim(),t.firstChild}return document.querySelector(e)},b=function(){for(var e=[],t=1;t<arguments.length;t++){var n=arguments[t];"string"==typeof n&&(n=n.trim().split(/[\11\12\14\15\40]/)),Array.isArray(n)&&(e=e.concat(n))}return e.filter(Boolean)},w=function(e){return Array.isArray(e)||(e=[e]),e},C=function(e,t,n){for(;e&&e.matches;){if(e.matches(t))return e;if(e==n)break;e=e.parentNode}},A=function(e,t){return 0<t?e[e.length-1]:e[0]},S=function(){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(s,d);var e,t,n,r=u(s);function s(e,t){var n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s);var i=c(n=r.call(this));if((e=k(e)).tomselect)throw new Error("Tom Select already initialized on this element");e.tomselect=i,t=y(e,t);var o=(window.getComputedStyle&&window.getComputedStyle(e,null)).getPropertyValue("direction");return Object.assign(i,{order:0,settings:t,input:e,tabIndex:e.getAttribute("tabindex")||"",is_select_tag:"select"===e.tagName.toLowerCase(),rtl:/rtl/i.test(o),highlightedValue:null,isBlurring:!1,isOpen:!1,isDisabled:!1,isRequired:e.required,isInvalid:!1,isLocked:!1,isFocused:!1,isInputHidden:!1,isSetup:!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:{item:{},option:{}}}),i.settings.load&&i.settings.loadThrottle&&(i.settings.load=i.loadDebounce(i.settings.load,i.settings.loadThrottle)),i.sifter=new a(n.options,{diacritics:t.diacritics}),i.setupOptions(i.settings.options,i.settings.optgroups),delete i.settings.optgroups,delete i.settings.options,i.settings.mode=i.settings.mode||(1===i.settings.maxItems?"single":"multi"),"boolean"!=typeof i.settings.hideSelected&&(i.settings.hideSelected="multi"===i.settings.mode),"string"==typeof i.settings.createFilter&&(i.settings.createFilter=new RegExp(i.settings.createFilter)),i.initializePlugins(i.settings.plugins),i.setupCallbacks(),i.setupTemplates(),i.setup(),n}return e=s,(t=[{key:"setup",value:function(){var n,e,t,i,o,r,s,a,l=this,u=l.settings,c=l.input,p=l.settings.mode,d=c.getAttribute("class")||"",h=k("<div>");if(x(h,u.wrapperClass,d,p),n=k('<div class="items">'),x(n,u.inputClass),h.append(n),t=l.render("dropdown"),x(t,u.dropdownClass,p),i=k('<div style="scroll-behavior: smooth;">'),x(i,u.dropdownContentClass),t.append(i),k(u.dropdownParent||h).appendChild(t),u.controlInput)e=k(u.controlInput);else{e=k('<input type="text" autocomplete="off" />');for(var f=["autocorrect","autocapitalize","autocomplete"],g=0;g<f.length;g++){var v=f[g];c.getAttribute(v)&&e.setAttribute(v,c.getAttribute(v))}}u.controlInput||(e.setAttribute("tabindex",c.disabled?"-1":l.tabIndex),n.appendChild(e)),(r=c.getAttribute("id"))&&(e.setAttribute("id",r+"-tomselected"),(s=document.querySelector("label[for='"+r+"']"))&&s.setAttribute("for",r+"-tomselected")),l.settings.copyClassesToDropdown&&x(t,d),h.style.width=c.style.width,l.plugins.names.length&&(o="plugin-"+l.plugins.names.join(" plugin-"),x([h,t],o)),(null===u.maxItems||1<u.maxItems)&&l.is_select_tag&&c.setAttribute("multiple","multiple"),l.settings.placeholder&&e.setAttribute("placeholder",u.placeholder),!l.settings.splitOn&&l.settings.delimiter&&(a=l.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),l.settings.splitOn=new RegExp("\\s*"+a+"+\\s*")),e.type=c.type,l.control=n,l.control_input=e,l.wrapper=h,l.dropdown=t,l.dropdown_content=i,O(t,"mouseenter","[data-selectable]",function(){return l.onOptionHover.apply(l,arguments)}),O(t,"mousedown","[data-selectable]",function(){return l.onOptionSelect.apply(l,arguments)}),n.addEventListener("mousedown",function(e){var t=C(e.target,"."+l.settings.itemClass,n);return t?(e.delegateTarget=t,l.onItemSelect.call(l,e)):l.onMouseDown.call(l,e)}),n.addEventListener("click",function(){return l.onClick.apply(l,arguments)}),e.addEventListener("mousedown",function(e){e.stopPropagation()}),e.addEventListener("keydown",function(){return l.onKeyDown.apply(l,arguments)}),e.addEventListener("keyup",function(){return l.onKeyUp.apply(l,arguments)}),e.addEventListener("keypress",function(){return l.onKeyPress.apply(l,arguments)}),e.addEventListener("resize",function(){l.positionDropdown.apply(l,[])}),e.addEventListener("blur",function(){return l.onBlur.apply(l,arguments)}),e.addEventListener("focus",function(){return l.ignoreBlur=!1,l.onFocus.apply(l,arguments)}),e.addEventListener("paste",function(){return l.onPaste.apply(l,arguments)});function m(e){if(l.isFocused){if(C(e.target,"."+l.settings.wrapperClass,l.wrapper))return!1;l.blur(e.target)}}function y(){l.isOpen&&l.positionDropdown.apply(l,arguments)}function b(){l.ignoreHover=!1}document.addEventListener("mousedown",m),window.addEventListener("sroll",y),window.addEventListener("resize",y),window.addEventListener("mousemove",b),l._destroy=function(){document.removeEventListener("mousedown",m),window.removeEventListener("mousemove",b),window.removeEventListener("sroll",y),window.removeEventListener("resize",y)};for(var w=[];0<c.children.length;)w.push(c.children[0]),c.children[0].remove();this.revertSettings={children:w,tabindex:c.getAttribute("tabindex")},c.setAttribute("tabindex",-1),c.setAttribute("hidden","hidden"),c.insertAdjacentElement("afterend",l.wrapper),l.setValue(u.items),delete u.items,l.supportsValidity()&&c.addEventListener("invalid",function(e){e.preventDefault(),l.isInvalid=!0,l.refreshState()}),l.updateOriginalInput(),l.refreshItems(),l.refreshState(),l.isSetup=!0,c.disabled&&l.disable(),l.on("change",this.onChange),x(c,"tomselected"),l.trigger("initialize"),!0===u.preload&&l.onSearchChange("")}},{key:"supportsValidity",value:function(){return!/android/i.test(window.navigator.userAgent)&&!!document.createElement("input").validity}},{key:"setupOptions",value:function(e,t){var n,i;for(t=t||[],n=0,i=(e=e||[]).length;n<i;n++)this.registerOption(e[n]);for(n=0,i=t.length;n<i;n++)this.registerOptionGroup(t[n])}},{key:"setupTemplates",value:function(){var n=this.settings.labelField,i=this.settings.optgroupLabelField,e={optgroup:function(e,t){var n=document.createElement("div");return n.className="optgroup",n.appendChild(e.options),n},optgroup_header:function(e,t){return'<div class="optgroup-header">'+t(e[i])+"</div>"},option:function(e,t){return"<div>"+t(e[n])+"</div>"},item:function(e,t){return"<div>"+t(e[n])+"</div>"},option_create:function(e,t){return'<div class="create">Add <strong>'+t(e.input)+"</strong>…</div>"},no_results:function(){return'<div class="no-results">No results found</div>'},loading:function(){return'<div class="spinner"></div>'},dropdown:function(){return'<div style="display:none"></div>'}};this.settings.render=Object.assign({},e,this.settings.render)}},{key:"setupCallbacks",value: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)(t=this.settings[n[e]])&&this.on(e,t)}},{key:"onClick",value:function(e){this.isFocused&&this.isOpen||(this.focus(),e.preventDefault())}},{key:"onMouseDown",value:function(e){var t=this;if(t.isFocused){if(e.target!==t.control_input)return"single"===t.settings.mode?t.isOpen?t.close():t.open():t.setActiveItem(null),!1}else window.setTimeout(function(){t.focus()},0)}},{key:"onChange",value:function(){g(this.input,"change")}},{key:"onPaste",value:function(e){var o=this;o.isFull()||o.isInputHidden||o.isLocked?e.preventDefault():o.settings.splitOn&&setTimeout(function(){var e=o.inputValue();if(e.match(o.settings.splitOn))for(var t=e.trim().split(o.settings.splitOn),n=0,i=t.length;n<i;n++)o.createItem(t[n])},0)}},{key:"onKeyPress",value: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}},{key:"onKeyDown",value:function(e){e.target,this.control_input;var t,n,i=this;if(i.isLocked)9!==e.keyCode&&e.preventDefault();else{switch(e.keyCode){case 65:if(i.isKeyDown(17,e))return void i.selectAll();break;case 27:return void(i.isOpen&&(e.preventDefault(),e.stopPropagation(),i.close()));case 40:return!i.isOpen&&i.hasOptions?i.open():i.activeOption&&(i.ignoreHover=!0,(t=i.getAdjacent(i.activeOption,1))&&i.setActiveOption(t,!0)),void e.preventDefault();case 38:return i.activeOption&&(i.ignoreHover=!0,(n=i.getAdjacent(i.activeOption,-1))&&i.setActiveOption(n,!0)),void e.preventDefault();case 13:return void(i.isOpen&&i.activeOption&&(i.onOptionSelect({delegateTarget: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({delegateTarget:i.activeOption}),e.preventDefault()),void(i.settings.create&&i.createItem()&&e.preventDefault());case 8:case 46:return void i.deleteSelection(e)}!i.isInputHidden||i.isKeyDown(17,e)||e.preventDefault()}}},{key:"onKeyUp",value:function(e){var t=this;if(t.isLocked)return e&&e.preventDefault();var n=t.inputValue();t.lastValue!==n&&(t.lastValue=n,t.onSearchChange(n),t.refreshOptions(),t.trigger("type",n))}},{key:"onSearchChange",value: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])})))}},{key:"onFocus",value: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())}},{key:"onBlur",value:function(e,t){var n=this;if(n.isFocused){if(n.isFocused=!1,n.ignoreFocus=!1,!n.ignoreBlur&&document.activeElement===n.dropdown_content)return n.ignoreBlur=!0,void n.onFocus(e);var i=function(){n.close(),n.setActiveItem(null),n.setActiveOption(null),n.setCaret(n.items.length),n.refreshState(),t&&t.focus&&t.focus(),n.isBlurring=!1,n.trigger("blur")};n.isBlurring=!0,n.settings.create&&n.settings.createOnBlur?n.createItem(null,!1,i):i()}}},{key:"onOptionHover",value:function(e){this.ignoreHover||this.setActiveOption(e.delegateTarget,!1)}},{key:"onOptionSelect",value:function(e){var t,n=this;e.preventDefault&&(e.preventDefault(),e.stopPropagation());var i=e.delegateTarget;i&&(i.parentNode&&i.parentNode.matches("[data-disabled]")||(i.classList.contains("create")?n.createItem(null,function(){n.settings.closeAfterSelect&&n.close()}):void 0!==(t=i.dataset.value)&&(n.lastQuery=null,n.addItem(t),n.settings.closeAfterSelect?n.close():!n.settings.hideSelected&&e.type&&/mouse/.test(e.type)&&n.setActiveOption(n.getOption(t)))))}},{key:"onItemSelect",value:function(e){this.isLocked||"multi"===this.settings.mode&&(e.preventDefault(),this.setActiveItem(e.delegateTarget,e))}},{key:"load",value:function(e){var n=this;x(n.wrapper,n.settings.loadingClass),n.loading++,e.call(n,function(e,t){n.loading=Math.max(n.loading-1,0),n.lastQuery=null,n.setupOptions(e,t),n.refreshOptions(n.isFocused&&!n.isInputHidden),n.loading||F(n.wrapper,n.settings.loadingClass),n.trigger("load",e)})}},{key:"loadDebounce",value:function(n,i){var o;return function(){var e=this,t=arguments;o&&(e.loading=Math.max(e.loading-1,0)),window.clearTimeout(o),o=window.setTimeout(function(){o=null,n.apply(e,t)},i)}}},{key:"setTextboxValue",value:function(e){var t=this.control_input;t.value!==e&&(t.value=e,g(t,"update"),this.lastValue=e)}},{key:"getValue",value:function(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}},{key:"setValue",value:function(e,t){f(this,t?[]:["change"],function(){this.clear(t),this.addItems(e,t)})}},{key:"setActiveItem",value:function(e,t){var n,i,o,r,s,a;if("single"!==this.settings.mode){if(!e)return F(this.activeItems,"active"),this.activeItems=[],void(this.isFocused&&this.showInput());if("mousedown"===(n=t&&t.type.toLowerCase())&&this.isKeyDown(16,t)&&this.activeItems.length){for(a=this.getLastActive(),o=Array.prototype.indexOf.call(this.control.children,a),(r=Array.prototype.indexOf.call(this.control.children,e))<o&&(s=o,o=r,r=s),i=o;i<=r;i++)e=this.control.children[i],-1===this.activeItems.indexOf(e)&&this.setActiveItemClass(e);t.preventDefault()}else"mousedown"===n&&this.isKeyDown(17,t)||"keydown"===n&&this.isKeyDown(16,t)?e.classList.contains("active")?this.removeActiveItem(e):this.setActiveItemClass(e):(F(this.activeItems,"active"),this.activeItems=[],this.setActiveItemClass(e));this.hideInput(),this.isFocused||this.focus()}}},{key:"setActiveItemClass",value:function(e){var t=this.control.querySelector(".last-active");t&&F(t,"last-active"),x(e,"active last-active"),-1==this.activeItems.indexOf(e)&&this.activeItems.push(e)}},{key:"removeActiveItem",value:function(e){var t=this.activeItems.indexOf(e);this.activeItems.splice(t,1),F(e,"active")}},{key:"setActiveOption",value:function(e,t){var n,i,o;e!==this.activeOption&&(this.activeOption&&F(this.activeOption,"active"),this.activeOption=null,e&&(this.activeOption=e,x(e,"active"),!t&&void 0!==t||(n=this.dropdown_content.clientHeight,t=this.dropdown_content.scrollTop||0,i=this.activeOption.offsetHeight,n+t<(o=this.activeOption.getBoundingClientRect().top-this.dropdown_content.getBoundingClientRect().top+t)+i?this.dropdown_content.scrollTop=o-n+i:o<t&&(this.dropdown_content.scrollTop=o))))}},{key:"selectAll",value:function(){"single"!==this.settings.mode&&(this.activeItems=this.controlChildren(),this.activeItems.length&&(x(this.activeItems,"active"),this.hideInput(),this.close()),this.focus())}},{key:"hideInput",value:function(){this.settings.controlInput||(this.setTextboxValue(""),v(this.control_input,{opacity:0,position:"absolute",left:(this.rtl?1e4:-1e4)+"px"}),this.isInputHidden=!0)}},{key:"showInput",value:function(){this.settings.controlInput||(v(this.control_input,{opacity:1,position:"relative",left:0}),this.isInputHidden=!1)}},{key:"inputValue",value:function(){return this.control_input.value.trim()}},{key:"focus",value:function(){var e=this;e.isDisabled||(e.ignoreFocus=!0,e.control_input.focus(),window.setTimeout(function(){e.ignoreFocus=!1,e.onFocus()},0))}},{key:"blur",value:function(e){this.control_input.blur(),this.onBlur(null,e)}},{key:"getScoreFunction",value:function(e){return this.sifter.getScoreFunction(e,this.getSearchOptions())}},{key:"getSearchOptions",value: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}}},{key:"search",value:function(e){var t,n,i,o=this,r=o.settings,s=this.getSearchOptions();if(r.score&&"function"!=typeof(i=o.settings.score.call(this,e)))throw new Error('Tom Select "score" setting must be a function that returns a function');if(e!==o.lastQuery?(o.lastQuery=e,n=o.sifter.search(e,Object.assign(s,{score:i})),o.currentResults=n):n=Object.assign({},o.currentResults),r.hideSelected)for(t=n.items.length-1;0<=t;t--)-1!==o.items.indexOf(P(n.items[t].id))&&n.items.splice(t,1);return n}},{key:"refreshOptions",value:function(e){var t,n,i,o,r,s;void 0===e&&(e=!0);var a,l,u,c=this,p=c.inputValue(),d=c.search(p),h=c.activeOption&&P(c.activeOption.dataset.value),f=!1,g=d.items.length;for("number"==typeof c.settings.maxOptions&&(g=Math.min(g,c.settings.maxOptions)),0<g&&(f=!0),n={},i=[],t=0;t<g;t++)for(var v,m=c.options[d.items[t].id],y=P(m[c.settings.valueField]),b=(b=c.getOption(y))||c.render("option",m),w=m[c.settings.optgroupField]||"",O=0,k=(v=Array.isArray(w)?w:[w])&&v.length;O<k;O++)w=v[O],c.optgroups.hasOwnProperty(w)||(w=""),n.hasOwnProperty(w)||(n[w]=document.createDocumentFragment(),i.push(w)),0<O&&(b=b.cloneNode(!0),F(b,"active")),n[w].appendChild(b);for(this.settings.lockOptgroupOrder&&i.sort(function(e,t){return(c.optgroups[e].$order||0)-(c.optgroups[t].$order||0)}),o=document.createDocumentFragment(),t=0,g=i.length;t<g;t++){w=i[t],c.optgroups.hasOwnProperty(w)&&n[w].children.length?((a=document.createDocumentFragment()).appendChild(c.render("optgroup_header",c.optgroups[w])),a.appendChild(n[w]),l=c.render("optgroup",{group:c.optgroups[w],options:a}),o.appendChild(l)):o.appendChild(n[w])}if(c.dropdown_content.innerHTML="",c.dropdown_content.appendChild(o),c.settings.highlight&&(c.dropdown_content,u=document.querySelectorAll("span.highlight"),Array.prototype.forEach.call(u,function(e,t){var n=e.parentNode;n.replaceChild(e.firstChild,e),n.normalize()}),d.query.length&&d.tokens.length))for(t=0,g=d.tokens.length;t<g;t++)!function(e,t){var u,n;"string"==typeof t&&!t.length||(u="string"==typeof t?new RegExp(t,"i"):t,n=function e(t){var n=0;if(3===t.nodeType){var i,o,r,s,a=t.data.search(u);0<=a&&0<t.data.length&&(i=t.data.match(u),(o=document.createElement("span")).className="highlight",(r=t.splitText(a)).splitText(i[0].length),s=r.cloneNode(!0),o.appendChild(s),r.parentNode.replaceChild(o,r),n=1)}else if(1===t.nodeType&&t.childNodes&&!/(script|style)/i.test(t.tagName)&&("highlight"!==t.className||"SPAN"!==t.tagName))for(var l=0;l<t.childNodes.length;++l)l+=e(t.childNodes[l]);return n},n(e))}(c.dropdown_content,d.tokens[t].regex);if(!c.settings.hideSelected)for(t=0,g=c.items.length;t<g;t++){var C=c.getOption(c.items[t]);C&&x(C,"selected")}function A(e){f=!0;var t=c.render(e,{input:p});return c.dropdown_content.insertBefore(t,c.dropdown_content.firstChild),t}var S,I,_;c.loading?A("loading"):0===d.items.length&&c.settings.render.no_results&&p.length&&A("no_results"),(r=c.canCreate(p))&&(s=A("option_create")),c.hasOptions=0<d.items.length||r,f?(_=0<d.items.length?(I=h&&c.getOption(h))&&c.dropdown_content.contains(I)?I:"single"===c.settings.mode&&c.items.length?c.getOption(c.items[0]):(S=0,s&&!c.settings.addPrecedence&&(S=1),c.selectable()[S]):s,c.setActiveOption(_),e&&!c.isOpen&&c.open()):(c.setActiveOption(null),e&&c.isOpen&&c.close())}},{key:"selectable",value:function(){return this.dropdown_content.querySelectorAll("[data-selectable]")}},{key:"addOption",value:function(e){var t,n,i,o=this;if(Array.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))}},{key:"registerOption",value:function(e){var t=P(e[this.settings.valueField]);return null!=t&&!this.options.hasOwnProperty(t)&&(e.$order=e.$order||++this.order,this.options[t]=e,t)}},{key:"registerOptionGroup",value:function(e){var t=P(e[this.settings.optgroupValueField]);return!!t&&(e.$order=e.$order||++this.order,this.optgroups[t]=e,t)}},{key:"addOptionGroup",value:function(e,t){t[this.settings.optgroupValueField]=e,(e=this.registerOptionGroup(t))&&this.trigger("optgroup_add",e,t)}},{key:"removeOptionGroup",value:function(e){this.optgroups.hasOwnProperty(e)&&(delete this.optgroups[e],this.clearCache(),this.trigger("optgroup_remove",e))}},{key:"clearOptionGroups",value:function(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")}},{key:"updateOption",value:function(e,t){var n,i,o,r,s,a,l,u=this;if(e=P(e),o=P(t[u.settings.valueField]),null!==e&&u.options.hasOwnProperty(e)){if("string"!=typeof o)throw new Error("Value must be set in option data");l=u.options[e].$order,o!==e&&(delete u.options[e],-1!==(r=u.items.indexOf(e))&&u.items.splice(r,1,o)),t.$order=t.$order||l,u.options[o]=t,s=u.renderCache.item,a=u.renderCache.option,s&&(delete s[e],delete s[o]),a&&(delete a[e],delete a[o]),-1!==u.items.indexOf(o)&&(n=u.getItem(e),i=u.render("item",t),n.classList.contains("active")&&x(i,"active"),n.parentNode.insertBefore(i,n),n.remove()),u.lastQuery=null,u.isOpen&&u.refreshOptions(!1)}}},{key:"removeOption",value:function(e,t){var n=this;e=P(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)}},{key:"clearOptions",value:function(){this.loadedSearches={},this.userOptions={},this.clearCache();var e={};for(var t in this.options)this.options.hasOwnProperty(t)&&0<=this.items.indexOf(t)&&(e[t]=this.options[t]);this.options=this.sifter.items=e,this.lastQuery=null,this.trigger("option_clear")}},{key:"getOption",value:function(e){return this.renderCache.option.hasOwnProperty(e)?this.renderCache.option[e]:this.getElementWithValue(e,this.selectable())}},{key:"getAdjacent",value:function(e,t,n){var i=2<arguments.length&&void 0!==n?n:"option";if(e){var o=this.settings.optionClass,r=this.dropdown;"item"==i&&(r=this.control,o=this.settings.itemClass);for(var s=r.querySelectorAll("."+o),a=0;a<s.length;a++)if(s[a]==e)return 0<t?s[a+1]:s[a-1]}}},{key:"getElementWithValue",value:function(e,t){if(null!=(e=P(e)))for(var n=0,i=t.length;n<i;n++)if(t[n].getAttribute("data-value")===e)return t[n]}},{key:"getItem",value:function(e){return this.getElementWithValue(e,this.control.children)}},{key:"addItems",value:function(e,t){this.buffer=document.createDocumentFragment();for(var n=this.control.children,i=0;i<n.length;i++)this.buffer.appendChild(n[i]);for(var o=Array.isArray(e)?e:[e],i=0,r=o.length;i<r;i++)this.isPending=i<r-1,this.addItem(o[i],t);var s=this.control;s.insertBefore(this.buffer,s.firstChild),this.buffer=null}},{key:"addItem",value:function(a,l){f(this,l?[]:["change"],function(){var e,t,n,i,o,r=this,s=r.settings.mode;a=P(a),(-1===r.items.indexOf(a)||("single"===s&&r.close(),"single"!==s&&r.settings.duplicates))&&r.options.hasOwnProperty(a)&&("single"===s&&r.clear(l),"multi"===s&&r.isFull()||(o=r.render("item",r.options[a]),this.control.contains(o)&&(o=o.cloneNode(!0)),e=r.isFull(),r.items.splice(r.caretPos,0,a),r.insertAtCaret(o),r.isPending&&(e||!r.isFull())||r.refreshState(),r.isSetup&&(t=r.selectable(),r.isPending||(n=r.getOption(a),i=r.getAdjacent(n,1),r.refreshOptions(r.isFocused&&"single"!==s),i&&r.setActiveOption(i)),!t.length||r.isFull()?r.close():r.isPending||r.positionDropdown(),r.trigger("item_add",a,o),r.isPending||r.updateOriginalInput({silent:l}))))})}},{key:"removeItem",value:function(e,t){var n,i,o=this.getItem(e);o&&(e=P(o.dataset.value),-1!==(n=this.items.indexOf(e))&&(o.remove(),o.classList.contains("active")&&(i=this.activeItems.indexOf(o),this.activeItems.splice(i,1),F(o,"active")),this.items.splice(n,1),this.lastQuery=null,!this.settings.persist&&this.userOptions.hasOwnProperty(e)&&this.removeOption(e,t),n<this.caretPos&&this.setCaret(this.caretPos-1),this.refreshState(),this.updateOriginalInput({silent:t}),this.positionDropdown(),this.trigger("item_remove",e,o)))}},{key:"createItem",value:function(e,n){var t,i=this,o=i.caretPos;e=e||i.inputValue();var r=arguments[arguments.length-1];if("function"!=typeof r&&(r=function(){}),"boolean"!=typeof n&&(n=!0),!i.canCreate(e))return r(),!1;i.lock();function s(e){if(i.unlock(),!e||"object"!==l(e))return r();var t=P(e[i.settings.valueField]);if("string"!=typeof t)return r();i.setTextboxValue(""),i.addOption(e),i.setCaret(o),i.addItem(t),i.refreshOptions(n&&"single"!==i.settings.mode),r(e),a=!0}var a=!1;return"function"==typeof i.settings.create?t=i.settings.create.apply(this,[e,s]):((t={})[i.settings.labelField]=e,t[i.settings.valueField]=e),a||s(t),!0}},{key:"refreshItems",value:function(){this.lastQuery=null,this.isSetup&&this.addItem(this.items),this.refreshState(),this.updateOriginalInput()}},{key:"refreshState",value:function(){var e=this;e.refreshValidityState();var t=e.isFull(),n=e.isLocked;e.wrapper.classList.toggle("rtl",e.rtl);var i,o=e.control.classList;o.toggle("focus",e.isFocused),o.toggle("disabled",e.isDisabled),o.toggle("required",e.isRequired),o.toggle("invalid",e.isInvalid),o.toggle("locked",n),o.toggle("full",t),o.toggle("not-full",!t),o.toggle("input-active",e.isFocused&&!e.isInputHidden),o.toggle("dropdown-active",e.isOpen),o.toggle("has-options",(i=e.options,0===Object.keys(i).length)),o.toggle("has-items",0<e.items.length)}},{key:"refreshValidityState",value:function(){if(!this.isRequired)return!1;var e=!this.items.length;this.isInvalid=e,this.control_input.required=e,this.input.required=!e}},{key:"isFull",value:function(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems}},{key:"updateOriginalInput",value:function(e){var t,n,i,o,r=this;if(e=e||{},r.is_select_tag){for(i=[],t=0,n=r.items.length;t<n;t++)o=r.options[r.items[t]][r.settings.labelField]||"",i.push('<option value="'+h(r.items[t])+'" selected="selected">'+h(o)+"</option>");i.length||this.input.hasAttribute("multiple")||i.push('<option value="" selected="selected"></option>'),r.input.innerHTML=i.join("")}else r.input.value=r.getValue(),r.input.setAttribute("value",r.input.value);r.isSetup&&(e.silent||r.trigger("change",r.input.value))}},{key:"open",value:function(){var e=this;e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.focus(),e.isOpen=!0,e.refreshState(),v(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),v(e.dropdown,{visibility:"visible",display:"block"}),e.trigger("dropdown_open",e.dropdown))}},{key:"close",value:function(){var e=this,t=e.isOpen;"single"===e.settings.mode&&e.items.length&&(e.hideInput(),e.isBlurring||e.blur()),e.isOpen=!1,v(e.dropdown,{display:"none"}),e.setActiveOption(null),e.refreshState(),t&&e.trigger("dropdown_close",e.dropdown)}},{key:"positionDropdown",value:function(){var e,t,n,i;"body"===this.settings.dropdownParent&&(t=(e=this.control).getBoundingClientRect(),n=e.offsetHeight+t.top+window.scrollY,i=t.left+window.scrollX,v(this.dropdown,{width:t.width+"px",top:n+"px",left:i+"px"}))}},{key:"clear",value:function(e){if(this.items.length){for(var t=this.controlChildren(),n=0;n<t.length;n++)t[n].remove();this.items=[],this.lastQuery=null,this.setCaret(0),this.setActiveItem(null),this.updateOriginalInput({silent:e}),this.refreshState(),this.showInput(),this.trigger("clear")}}},{key:"insertAtCaret",value:function(e){var t=Math.min(this.caretPos,this.items.length),n=this.buffer||this.control;0===t?n.insertBefore(e,n.firstChild):n.insertBefore(e,n.children[t]),this.setCaret(t+1)}},{key:"deleteSelection",value:function(e){var t,n,i,o,r,s=this,a=e&&8===e.keyCode?-1:1,l={start:(r=s.control_input).selectionStart,length:r.selectionEnd-r.selectionStart},u=[];if(s.activeItems.length){for(o=A(s.activeItems,a),i=m(o),0<a&&i++,t=0,n=s.activeItems.length;t<n;t++)u.push(s.activeItems[t].dataset.value);e&&(e.preventDefault(),e.stopPropagation())}else(s.isFocused||"single"===s.settings.mode)&&s.items.length&&(a<0&&0===l.start&&0===l.length?u.push(s.items[s.caretPos-1]):0<a&&l.start===s.inputValue().length&&u.push(s.items[s.caretPos]));if(!u.length||"function"==typeof s.settings.onDelete&&!1===s.settings.onDelete.apply(s,[u,e]))return!1;for(void 0!==i&&s.setCaret(i);u.length;)s.removeItem(u.pop());return s.showInput(),s.positionDropdown(),s.refreshOptions(!1),!0}},{key:"advanceSelection",value:function(e,t){var n,i,o;0!==e&&(this.rtl&&(e*=-1),this.isKeyDown(17,t)||this.isKeyDown(16,t)?(i=this.getLastActive(e),(o=this.getAdjacent(i,e,"item"))&&(o.classList.contains("active")&&this.removeActiveItem(i),this.setActiveItemClass(o))):this.isFocused&&!this.isInputHidden?this.inputValue().length||this.setCaret(this.caretPos+e):(i=this.getLastActive(e))&&(n=m(i),this.setCaret(0<e?n+1:n),this.setActiveItem(null)))}},{key:"getLastActive",value:function(e){var t=this.control.querySelector(".last-active");return t||function(e,t,n){var i=e.querySelectorAll(t);if(i)return A(i,n)}(this.control,".active",e)}},{key:"setCaret",value:function(e){var t=this;if(e="single"===t.settings.mode||t.settings.controlInput?t.items.length:Math.max(0,Math.min(t.items.length,e)),!t.settings.controlInput&&!t.isPending)for(var n,i=this.controlChildren(),o=i.length,r=0;r<o;r++)n=i[r],r<e?t.control_input.insertAdjacentElement("beforebegin",n):t.control.appendChild(n);t.caretPos=e}},{key:"controlChildren",value:function(){return Array.prototype.filter.call(this.control.children,function(e){return"INPUT"!==e.nodeName})}},{key:"lock",value:function(){this.close(),this.isLocked=!0,this.refreshState()}},{key:"unlock",value:function(){this.isLocked=!1,this.refreshState()}},{key:"disable",value:function(){this.input.disabled=!0,this.control_input.disabled=!0,this.control_input.tabIndex=-1,this.isDisabled=!0,this.lock()}},{key:"enable",value:function(){this.input.disabled=!1,this.control_input.disabled=!1,this.control_input.tabIndex=this.tabIndex,this.isDisabled=!1,this.unlock()}},{key:"destroy",value:function(){var e=this.revertSettings;this.trigger("destroy"),this.off(),this.wrapper.remove(),this.dropdown.remove(),this.input.innerHTML="",e.tabindex?this.input.setAttribute("tabindex",e.tabindex):this.input.removeAttribute("tabindex"),F(this.input,"tomselected"),this.input.removeAttribute("hidden");for(var t=0;t<e.children.length;t++)this.input.appendChild(e.children[t]);this._destroy(),delete this.input.tomselect}},{key:"render",value:function(e,t){var n,i,o="",r=this;return"option"!==e&&"item"!==e||(n=P(t[r.settings.valueField]),!r.renderCache[e].hasOwnProperty(n))?(o=k(r.settings.render[e].apply(this,[t,h])),"option"===e||"option_create"===e?t[r.settings.disabledField]||o.setAttribute("data-selectable",""):"optgroup"===e&&(i=t.group[r.settings.optgroupValueField],o.setAttribute("data-group",i),t.group[r.settings.disabledField]&&o.setAttribute("data-disabled","")),"option"!==e&&"item"!==e||(o.setAttribute("data-value",n),x(o,"item"===e?r.settings.itemClass:r.settings.optionClass),r.renderCache[e][n]=o),o):r.renderCache[e][n]}},{key:"clearCache",value:function(e){void 0===e?this.renderCache={item:{},option:{}}:this.renderCache[e]={}}},{key:"canCreate",value:function(e){if(!this.settings.create)return!1;var t=this.settings.createFilter;return e.length&&("function"!=typeof t||t.call(this,e))&&(!(t instanceof RegExp)||t.test(e))}},{key:"isKeyDown",value:function(e,t){return!!t&&(!t.altKey&&((!t.ctrlKey||!t.shiftKey)&&(!(17!=e||!t.ctrlKey)||!(16!=e||!t.shiftKey))))}},{key:"hook",value:function(n,e,i){var o=this,r=o[e];o[e]=function(){var e,t;return"after"===n&&(e=r.apply(o,arguments)),t=i.apply(o,arguments),"instead"===n?t:("before"===n&&(e=r.apply(o,arguments)),e)}}}])&&i(e.prototype,t),n&&i(e,n),s}();if(void 0===e)throw'Dependency MicroPlugin is missing. Make sure you either: (1) are using the "complete" version of Tom Select, or (2) require MicroPlugin before you load Tom Select.';return e.mixin(S),S.count=0,S.defaults={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:!1,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,maxOptions:50,maxItems:null,hideSelected:null,duplicates:!1,addPrecedence:!1,selectOnTab:!1,preload:!1,allowEmptyOption:!1,closeAfterSelect:!1,scrollDuration:60,loadThrottle:300,loadingClass:"loading",dataAttr:null,optgroupField:"optgroup",valueField:"value",labelField:"text",disabledField:"disabled",optgroupLabelField:"label",optgroupValueField:"value",lockOptgroupOrder:!1,sortField:"$order",searchField:["text"],searchConjunction:"and",mode:null,wrapperClass:"ts-control",inputClass:"ts-input",dropdownClass:"ts-dropdown",dropdownContentClass:"ts-dropdown-content",itemClass:"item",optionClass:"option",dropdownParent:null,controlInput:null,copyClassesToDropdown:!0,render:{}},S.define("change_listener",function(e){var t=this,n=!1;t.input.addEventListener("change",function(){var e;n?n=!1:(n=!0,e=y(t.input,{}),t.setupOptions(e.options,e.optgroups),t.setValue(e.items))})}),S.define("drag_drop",function(e){if(!$.fn.sortable)throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');var t,n,i;"multi"===this.settings.mode&&(n=(t=this).lock,i=t.unlock,t.hook("instead","lock",function(){var e=t.control.dataset.sortable;return e&&e.disable(),n.apply(t,arguments)}),t.hook("instead","unlock",function(){var e=t.control.dataset.sortable;return e&&e.enable(),i.apply(t,arguments)}),t.hook("after","setup",function(){var n=$(t.control).sortable({items:"[data-value]",forcePlaceholderSize:!0,disabled:t.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=[];n.children("[data-value]").each(function(){e.push($(this).attr("data-value"))}),t.setValue(e)}})}))}),S.define("dropdown_header",function(t){var n=this;t=Object.assign({title:"Untitled",headerClass:"dropdown-header",titleRowClass:"dropdown-header-title",labelClass:"dropdown-header-label",closeClass:"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>'}},t),n.hook("after","setup",function(){var e=k(t.html(t));n.dropdown.insertBefore(e,n.dropdown.firstChild)})}),S.define("input_autogrow",function(e){var a=this;a.hook("after","setup",function(){var e=document.createElement("span"),t=this.control_input;e.style.position="absolute",e.style.top="-99999px",e.style.left="-99999px",e.style.width="auto",e.style.padding=0,e.style.whiteSpace="pre",a.wrapper.appendChild(e);for(var n=["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"],i=0,o=n.length;i<o;i++){var r=n[i];e.style[r]=t.style[r]}function s(){e.textContent=t.value,t.style.width=e.clientWidth+"px"}t.addEventListener("input",s),t.addEventListener("keyup",s),t.addEventListener("blur",s),t.addEventListener("update",s)})}),S.define("no_backspace_delete",function(e){this.hook("instead","setActiveItem",function(){}),this.hook("instead","selectAll",function(){}),this.hook("instead","deleteSelection",function(){})}),S.define("optgroup_columns",function(e){var r=this,s=r.onKeyDown;r.hook("instead","onKeyDown",function(e){var t,n,i,o;return!r.isOpen||37!==e.keyCode&&39!==e.keyCode?s.apply(r,arguments):(r.ignoreHover=!0,o=C(r.activeOption,"[data-group]"),t=m(r.activeOption,"[data-selectable]"),void((o=37===e.keyCode?o.previousSibling:o.nextSibling)&&(n=(i=o.querySelectorAll("[data-selectable]"))[Math.min(i.length-1,t)])&&r.setActiveOption(n)))})}),S.define("remove_button",function(e){e=Object.assign({label:"×",title:"Remove",className:"remove",append:!0},e);var i,o=this;e.append&&(i='<a href="javascript:void(0)" class="'+e.className+'" tabindex="-1" title="'+h(e.title)+'">'+e.label+"</a>",o.hook("after","setupTemplates",function(){var t=o.settings.render.item;o.settings.render.item=function(){var n=k(t.apply(o,arguments)),e=k(i);return n.appendChild(e),e.addEventListener("mousedown",function(e){e.preventDefault(),e.stopPropagation()}),e.addEventListener("click",function(e){var t;e.preventDefault(),e.stopPropagation(),"single"!==o.settings.mode&&e.stopPropagation(),o.isLocked||(t=n.dataset.value,o.removeItem(t),o.refreshOptions(!1))}),n}}))}),S.define("restore_on_backspace",function(i){var o=this;i.text=i.text||function(e){return e[o.settings.labelField]};var r=o.onKeyDown;o.hook("instead","onKeyDown",function(e){var t,n;return 8===e.keyCode&&""===o.control_input.value&&!o.activeItems.length&&0<=(t=o.caretPos-1)&&t<o.items.length?(n=o.options[o.items[t]],o.deleteSelection(e)&&(o.setTextboxValue(i.text.call(o,n)),o.refreshOptions(!0)),void e.preventDefault()):r.apply(o,arguments)})}),S});var tomSelect=function(e,t){return new TomSelect(e,t)}; |
@@ -1,3 +0,3 @@ | ||
/*! tom-select.js - v1.0.0-b.3 | https://github.com/orchidjs/tom-select | Apache License (v2) */ | ||
/*! tom-select.js - v1.0.0-rc.1 | https://github.com/orchidjs/tom-select | Apache License (v2) */ | ||
!function(e,t){"function"==typeof define&&define.amd?define(["sifter","microplugin"],t):"object"==typeof exports?module.exports=t(require("sifter"),require("microplugin")):e.TomSelect=t(e.Sifter,e.MicroPlugin)}(this,function(a,e){"use strict";function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(s){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}();return function(){var e,t,n,i,o=p(s);return t=r?(e=p(this).constructor,Reflect.construct(o,arguments,e)):o.apply(this,arguments),n=this,!(i=t)||"object"!==l(i)&&"function"!=typeof i?c(n):i}}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function d(){}d.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))}};function h(e){return(e+"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function g(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 f(e,t){var n=document.createEvent("HTMLEvents");n.initEvent(t,!0,!1),e.dispatchEvent(n)}function v(t,n){Object.keys(n).forEach(function(e){t.style[e]=n[e]})}function x(e){var t=C.apply(null,arguments);e=I(e);for(var n,i=0;i<e.length;i++){(n=e[i].classList).add.apply(n,s(t))}}function F(e){var t=C.apply(null,arguments);e=I(e);for(var n,i=0;i<e.length;i++){(n=e[i].classList).remove.apply(n,s(t))}}function w(n,e,i,o){for(var t=e.split(/\s/),s=function(e){var t=A(e.target,i,n);t&&(e.delegateTarget=t,o.call(t,e))},r=0;r<t.length;r++)n.addEventListener(t[r],s,!0)}function m(e,t){if(!e)return-1;t=t||e.nodeName;for(var n=0;e=e.previousElementSibling;)e.matches(t)&&n++;return n}var t=/Mac/.test(navigator.userAgent),y=t?18:17,b=t?"metaKey":"ctrlKey",O=function(u,e){var t,c=Object.assign({},S.defaults,e),p=c.dataAttr,d=c.labelField,h=c.valueField,g=c.disabledField,f=c.optgroupField,v=c.optgroupLabelField,m=c.optgroupValueField,n=u.tagName.toLowerCase(),i=u.getAttribute("placeholder")||u.getAttribute("data-placeholder");i||c.allowEmptyOption||(t=u.querySelector('option[value=""]'))&&(i=t.textContent);var y={placeholder:i,options:[],optgroups:[],items:[]};return("select"===n?function(){function r(e){var t=Object.assign({},e.dataset),n=p&&t[p];return"string"==typeof n&&n.length&&(t=Object.assign(t,JSON.parse(n))),t}function a(e,t){var n,i,o=D(e.value);(o||c.allowEmptyOption)&&(l.hasOwnProperty(o)?t&&((n=l[o][f])?Array.isArray(n)?n.push(t):l[o][f]=[n,t]:l[o][f]=t):((i=r(e))[d]=i[d]||e.textContent,i[h]=i[h]||o,i[g]=i[g]||e.disabled,i[f]=i[f]||t,l[o]=i,s.push(i),e.selected&&y.items.push(o)))}var e,t,n,i,s=y.options,l={};for(y.maxItems=u.hasAttribute("multiple")?null:1,e=0,t=(i=u.children).length;e<t;e++)"optgroup"===(n=i[e].tagName.toLowerCase())?function(e){var t,n=e.getAttribute("label");n&&((t=r(e))[v]=n,t[m]=n,t[g]=e.disabled,y.optgroups.push(t));for(var i,o=0,s=(i=e.children).length;o<s;o++)a(i[o],n)}(i[e]):"option"===n&&a(i[e])}:function(){var e,t,n,i,o=u.getAttribute(p);if(o)for(y.options=JSON.parse(o),e=0,t=y.options.length;e<t;e++)y.items.push(y.options[e][h]);else{var s=u.value.trim()||"";if(!c.allowEmptyOption&&!s.length)return;for(e=0,t=(n=s.split(c.delimiter)).length;e<t;e++)(i={})[d]=n[e],i[h]=n[e],y.options.push(i);y.items=n}})(),Object.assign({},S.defaults,y,e)},D=function(e){return null==e?null:"boolean"==typeof e?e?"1":"0":e+""},k=function(e){if(e.jquery)return e[0];if(e instanceof HTMLElement)return e;if(-1<e.indexOf("<")){var t=document.createElement("div");return t.innerHTML=e.trim(),t.firstChild}return document.querySelector(e)},C=function(){for(var e=[],t=1;t<arguments.length;t++){var n=arguments[t];"string"==typeof n&&(n=n.trim().split(/[\11\12\14\15\40]/)),Array.isArray(n)&&(e=e.concat(n))}return e.filter(Boolean)},I=function(e){return Array.isArray(e)||(e=[e]),e},A=function(e,t,n){for(;e&&e.matches;){if(e.matches(t))return e;if(e==n)break;e=e.parentNode}},_=function(e,t){return 0<t?e[e.length-1]:e[0]},S=function(){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(r,d);var e,t,n,s=u(r);function r(e,t){var n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r);var i=c(n=s.call(this));if((e=k(e)).tomselect)throw new Error("Tom Select already initialized on this element");e.tomselect=i,t=O(e,t);var o=(window.getComputedStyle&&window.getComputedStyle(e,null)).getPropertyValue("direction");return Object.assign(i,{order:0,settings:t,input:e,tabIndex:e.getAttribute("tabindex")||"",is_select_tag:"select"===e.tagName.toLowerCase(),rtl:/rtl/i.test(o),highlightedValue:null,isBlurring:!1,isOpen:!1,isDisabled:!1,isRequired:e.required,isInvalid:!1,isLocked:!1,isFocused:!1,isInputHidden:!1,isSetup:!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:{item:{},option:{}}}),i.settings.load&&i.settings.loadThrottle&&(i.settings.load=i.loadDebounce(i.settings.load,i.settings.loadThrottle)),i.sifter=new a(n.options,{diacritics:t.diacritics}),i.setupOptions(i.settings.options,i.settings.optgroups),delete i.settings.optgroups,delete i.settings.options,i.settings.mode=i.settings.mode||(1===i.settings.maxItems?"single":"multi"),"boolean"!=typeof i.settings.hideSelected&&(i.settings.hideSelected="multi"===i.settings.mode),"string"==typeof i.settings.createFilter&&(i.settings.createFilter=new RegExp(i.settings.createFilter)),i.initializePlugins(i.settings.plugins),i.setupCallbacks(),i.setupTemplates(),i.setup(),n}return e=r,(t=[{key:"setup",value:function(){var n,e,t,i,o,s,r,a,l=this,u=l.settings,c=l.input,p=l.settings.mode,d=c.getAttribute("class")||"",h=k("<div>");if(x(h,u.wrapperClass,d,p),n=k('<div class="items">'),x(n,u.inputClass),h.append(n),t=l.render("dropdown"),x(t,u.dropdownClass,p),i=k('<div style="scroll-behavior: smooth;">'),x(i,u.dropdownContentClass),t.append(i),k(u.dropdownParent||h).appendChild(t),u.controlInput)e=k(u.controlInput);else{e=k('<input type="text" autocomplete="off" />');for(var g=["autocorrect","autocapitalize","autocomplete"],f=0;f<g.length;f++){var v=g[f];c.getAttribute(v)&&e.setAttribute(v,c.getAttribute(v))}}u.controlInput||(e.setAttribute("tabindex",c.disabled?"-1":l.tabIndex),n.appendChild(e)),(s=c.getAttribute("id"))&&(e.setAttribute("id",s+"-tomselected"),(r=document.querySelector("label[for='"+s+"']"))&&r.setAttribute("for",s+"-tomselected")),l.settings.copyClassesToDropdown&&x(t,d),h.style.width=c.style.width,l.plugins.names.length&&(o="plugin-"+l.plugins.names.join(" plugin-"),x([h,t],o)),(null===u.maxItems||1<u.maxItems)&&l.is_select_tag&&c.setAttribute("multiple","multiple"),l.settings.placeholder&&e.setAttribute("placeholder",u.placeholder),!l.settings.splitOn&&l.settings.delimiter&&(a=l.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),l.settings.splitOn=new RegExp("\\s*"+a+"+\\s*")),e.type=c.type,l.control=n,l.control_input=e,l.wrapper=h,l.dropdown=t,l.dropdown_content=i,w(t,"mouseenter","[data-selectable]",function(){return l.onOptionHover.apply(l,arguments)}),w(t,"mousedown","[data-selectable]",function(){return l.onOptionSelect.apply(l,arguments)}),n.addEventListener("mousedown",function(e){var t=A(e.target,"."+l.settings.itemClass,n);return t?(e.delegateTarget=t,l.onItemSelect.call(l,e)):l.onMouseDown.call(l,e)}),n.addEventListener("click",function(){return l.onClick.apply(l,arguments)}),e.addEventListener("mousedown",function(e){e.stopPropagation()}),e.addEventListener("keydown",function(){return l.onKeyDown.apply(l,arguments)}),e.addEventListener("keyup",function(){return l.onKeyUp.apply(l,arguments)}),e.addEventListener("keypress",function(){return l.onKeyPress.apply(l,arguments)}),e.addEventListener("resize",function(){l.positionDropdown.apply(l,[])}),e.addEventListener("blur",function(){return l.onBlur.apply(l,arguments)}),e.addEventListener("focus",function(){return l.ignoreBlur=!1,l.onFocus.apply(l,arguments)}),e.addEventListener("paste",function(){return l.onPaste.apply(l,arguments)});function m(e){if(l.isFocused){if(A(e.target,"."+l.settings.wrapperClass,l.wrapper))return!1;l.blur(e.target)}}function y(){l.isOpen&&l.positionDropdown.apply(l,arguments)}function b(){l.ignoreHover=!1}document.addEventListener("mousedown",m),window.addEventListener("sroll",y),window.addEventListener("resize",y),window.addEventListener("mousemove",b),l._destroy=function(){document.removeEventListener("mousedown",m),window.removeEventListener("mousemove",b),window.removeEventListener("sroll",y),window.removeEventListener("resize",y)};for(var O=[];0<c.children.length;)O.push(c.children[0]),c.children[0].remove();this.revertSettings={children:O,tabindex:c.getAttribute("tabindex")},c.setAttribute("tabindex",-1),c.setAttribute("hidden","hidden"),c.insertAdjacentElement("afterend",l.wrapper),l.setValue(u.items),delete u.items,l.supportsValidity()&&c.addEventListener("invalid",function(e){e.preventDefault(),l.isInvalid=!0,l.refreshState()}),l.updateOriginalInput(),l.refreshItems(),l.refreshState(),l.isSetup=!0,c.disabled&&l.disable(),l.on("change",this.onChange),x(c,"tomselected"),l.trigger("initialize"),!0===u.preload&&l.onSearchChange("")}},{key:"supportsValidity",value:function(){return!/android/i.test(window.navigator.userAgent)&&!!document.createElement("input").validity}},{key:"setupOptions",value:function(e,t){var n,i;for(t=t||[],n=0,i=(e=e||[]).length;n<i;n++)this.registerOption(e[n]);for(n=0,i=t.length;n<i;n++)this.registerOptionGroup(t[n])}},{key:"setupTemplates",value:function(){var n=this.settings.labelField,i=this.settings.optgroupLabelField,e={optgroup:function(e,t){var n=document.createElement("div");return n.className="optgroup",n.appendChild(e.options),n},optgroup_header:function(e,t){return'<div class="optgroup-header">'+t(e[i])+"</div>"},option:function(e,t){return"<div>"+t(e[n])+"</div>"},item:function(e,t){return"<div>"+t(e[n])+"</div>"},option_create:function(e,t){return'<div class="create">Add <strong>'+t(e.input)+"</strong>…</div>"},no_results:function(){return'<div class="no-results">No results found</div>'},loading:function(){return'<div class="spinner"></div>'},dropdown:function(){return'<div style="display:none"></div>'}};this.settings.render=Object.assign({},e,this.settings.render)}},{key:"setupCallbacks",value: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)(t=this.settings[n[e]])&&this.on(e,t)}},{key:"onClick",value:function(e){this.isFocused&&this.isOpen||(this.focus(),e.preventDefault())}},{key:"onMouseDown",value:function(e){var t=this;if(t.isFocused){if(e.target!==t.control_input)return"single"===t.settings.mode?t.isOpen?t.close():t.open():t.setActiveItem(null),!1}else window.setTimeout(function(){t.focus()},0)}},{key:"onChange",value:function(){f(this.input,"change")}},{key:"onPaste",value:function(e){var o=this;o.isFull()||o.isInputHidden||o.isLocked?e.preventDefault():o.settings.splitOn&&setTimeout(function(){var e=o.inputValue();if(e.match(o.settings.splitOn))for(var t=e.trim().split(o.settings.splitOn),n=0,i=t.length;n<i;n++)o.createItem(t[n])},0)}},{key:"onKeyPress",value: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}},{key:"onKeyDown",value:function(e){e.target,this.control_input;var t,n,i=this;if(i.isLocked)9!==e.keyCode&&e.preventDefault();else{switch(e.keyCode){case 65:if(i.isKeyDown(y,e))return void i.selectAll();break;case 27:return void(i.isOpen&&(e.preventDefault(),e.stopPropagation(),i.close()));case 40:return!i.isOpen&&i.hasOptions?i.open():i.activeOption&&(i.ignoreHover=!0,(t=i.getAdjacent(i.activeOption,1))&&i.setActiveOption(t,!0)),void e.preventDefault();case 38:return i.activeOption&&(i.ignoreHover=!0,(n=i.getAdjacent(i.activeOption,-1))&&i.setActiveOption(n,!0)),void e.preventDefault();case 13:return void(i.isOpen&&i.activeOption&&(i.onOptionSelect({delegateTarget: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({delegateTarget:i.activeOption}),e.preventDefault()),void(i.settings.create&&i.createItem()&&e.preventDefault());case 8:case 46:return void i.deleteSelection(e)}!i.isInputHidden||i.isKeyDown(y,e)||e.preventDefault()}}},{key:"onKeyUp",value:function(e){var t=this;if(t.isLocked)return e&&e.preventDefault();var n=t.inputValue();t.lastValue!==n&&(t.lastValue=n,t.onSearchChange(n),t.refreshOptions(),t.trigger("type",n))}},{key:"onSearchChange",value: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])})))}},{key:"onFocus",value: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())}},{key:"onBlur",value:function(e,t){var n=this;if(n.isFocused){if(n.isFocused=!1,n.ignoreFocus=!1,!n.ignoreBlur&&document.activeElement===n.dropdown_content)return n.ignoreBlur=!0,void n.onFocus(e);var i=function(){n.close(),n.setActiveItem(null),n.setActiveOption(null),n.setCaret(n.items.length),n.refreshState(),t&&t.focus&&t.focus(),n.isBlurring=!1,n.trigger("blur")};n.isBlurring=!0,n.settings.create&&n.settings.createOnBlur?n.createItem(null,!1,i):i()}}},{key:"onOptionHover",value:function(e){this.ignoreHover||this.setActiveOption(e.delegateTarget,!1)}},{key:"onOptionSelect",value:function(e){var t,n=this;e.preventDefault&&(e.preventDefault(),e.stopPropagation());var i=e.delegateTarget;i&&(i.parentNode&&i.parentNode.matches("[data-disabled]")||(i.classList.contains("create")?n.createItem(null,function(){n.settings.closeAfterSelect&&n.close()}):void 0!==(t=i.dataset.value)&&(n.lastQuery=null,n.addItem(t),n.settings.closeAfterSelect?n.close():!n.settings.hideSelected&&e.type&&/mouse/.test(e.type)&&n.setActiveOption(n.getOption(t)))))}},{key:"onItemSelect",value:function(e){this.isLocked||"multi"===this.settings.mode&&(e.preventDefault(),this.setActiveItem(e.delegateTarget,e))}},{key:"load",value:function(e){var n=this;x(n.wrapper,n.settings.loadingClass),n.loading++,e.call(n,function(e,t){n.loading=Math.max(n.loading-1,0),n.lastQuery=null,n.setupOptions(e,t),n.refreshOptions(n.isFocused&&!n.isInputHidden),n.loading||F(n.wrapper,n.settings.loadingClass),n.trigger("load",e)})}},{key:"loadDebounce",value:function(n,i){var o;return function(){var e=this,t=arguments;o&&(e.loading=Math.max(e.loading-1,0)),window.clearTimeout(o),o=window.setTimeout(function(){o=null,n.apply(e,t)},i)}}},{key:"setTextboxValue",value:function(e){var t=this.control_input;t.value!==e&&(t.value=e,f(t,"update"),this.lastValue=e)}},{key:"getValue",value:function(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}},{key:"setValue",value:function(e,t){g(this,t?[]:["change"],function(){this.clear(t),this.addItems(e,t)})}},{key:"setActiveItem",value:function(e,t){var n,i,o,s,r,a;if("single"!==this.settings.mode){if(!e)return F(this.activeItems,"active"),this.activeItems=[],void(this.isFocused&&this.showInput());if("mousedown"===(n=t&&t.type.toLowerCase())&&this.isKeyDown(16,t)&&this.activeItems.length){for(a=this.getLastActive(),o=Array.prototype.indexOf.call(this.control.children,a),(s=Array.prototype.indexOf.call(this.control.children,e))<o&&(r=o,o=s,s=r),i=o;i<=s;i++)e=this.control.children[i],-1===this.activeItems.indexOf(e)&&this.setActiveItemClass(e);t.preventDefault()}else"mousedown"===n&&this.isKeyDown(y,t)||"keydown"===n&&this.isKeyDown(16,t)?e.classList.contains("active")?this.removeActiveItem(e):this.setActiveItemClass(e):(F(this.activeItems,"active"),this.activeItems=[],this.setActiveItemClass(e));this.hideInput(),this.isFocused||this.focus()}}},{key:"setActiveItemClass",value:function(e){var t=this.control.querySelector(".last-active");t&&F(t,"last-active"),x(e,"active last-active"),-1==this.activeItems.indexOf(e)&&this.activeItems.push(e)}},{key:"removeActiveItem",value:function(e){var t=this.activeItems.indexOf(e);this.activeItems.splice(t,1),F(e,"active")}},{key:"setActiveOption",value:function(e,t){var n,i,o;e!==this.activeOption&&(this.activeOption&&F(this.activeOption,"active"),this.activeOption=null,e&&(this.activeOption=e,x(e,"active"),!t&&void 0!==t||(n=this.dropdown_content.clientHeight,t=this.dropdown_content.scrollTop||0,i=this.activeOption.offsetHeight,n+t<(o=this.activeOption.getBoundingClientRect().top-this.dropdown_content.getBoundingClientRect().top+t)+i?this.dropdown_content.scrollTop=o-n+i:o<t&&(this.dropdown_content.scrollTop=o))))}},{key:"selectAll",value:function(){"single"!==this.settings.mode&&(this.activeItems=this.controlChildren(),this.activeItems.length&&(x(this.activeItems,"active"),this.hideInput(),this.close()),this.focus())}},{key:"hideInput",value:function(){this.settings.controlInput||(this.setTextboxValue(""),v(this.control_input,{opacity:0,position:"absolute",left:(this.rtl?1e4:-1e4)+"px"}),this.isInputHidden=!0)}},{key:"showInput",value:function(){this.settings.controlInput||(v(this.control_input,{opacity:1,position:"relative",left:0}),this.isInputHidden=!1)}},{key:"inputValue",value:function(){return this.control_input.value.trim()}},{key:"focus",value:function(){var e=this;e.isDisabled||(e.ignoreFocus=!0,e.control_input.focus(),window.setTimeout(function(){e.ignoreFocus=!1,e.onFocus()},0))}},{key:"blur",value:function(e){this.control_input.blur(),this.onBlur(null,e)}},{key:"getScoreFunction",value:function(e){return this.sifter.getScoreFunction(e,this.getSearchOptions())}},{key:"getSearchOptions",value: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}}},{key:"search",value:function(e){var t,n,i,o=this,s=o.settings,r=this.getSearchOptions();if(s.score&&"function"!=typeof(i=o.settings.score.call(this,e)))throw new Error('Tom Select "score" setting must be a function that returns a function');if(e!==o.lastQuery?(o.lastQuery=e,n=o.sifter.search(e,Object.assign(r,{score:i})),o.currentResults=n):n=Object.assign({},o.currentResults),s.hideSelected)for(t=n.items.length-1;0<=t;t--)-1!==o.items.indexOf(D(n.items[t].id))&&n.items.splice(t,1);return n}},{key:"refreshOptions",value:function(e){var t,n,i,o,s,r;void 0===e&&(e=!0);var a,l,u,c=this,p=c.inputValue(),d=c.search(p),h=c.activeOption&&D(c.activeOption.dataset.value),g=!1,f=d.items.length;for("number"==typeof c.settings.maxOptions&&(f=Math.min(f,c.settings.maxOptions)),0<f&&(g=!0),n={},i=[],t=0;t<f;t++)for(var v,m=c.options[d.items[t].id],y=D(m[c.settings.valueField]),b=(b=c.getOption(y))||c.render("option",m),O=m[c.settings.optgroupField]||"",w=0,k=(v=Array.isArray(O)?O:[O])&&v.length;w<k;w++)O=v[w],c.optgroups.hasOwnProperty(O)||(O=""),n.hasOwnProperty(O)||(n[O]=document.createDocumentFragment(),i.push(O)),0<w&&(b=b.cloneNode(!0),F(b,"active")),n[O].appendChild(b);for(this.settings.lockOptgroupOrder&&i.sort(function(e,t){return(c.optgroups[e].$order||0)-(c.optgroups[t].$order||0)}),o=document.createDocumentFragment(),t=0,f=i.length;t<f;t++){O=i[t],c.optgroups.hasOwnProperty(O)&&n[O].children.length?((a=document.createDocumentFragment()).appendChild(c.render("optgroup_header",c.optgroups[O])),a.appendChild(n[O]),l=c.render("optgroup",{group:c.optgroups[O],options:a}),o.appendChild(l)):o.appendChild(n[O])}if(c.dropdown_content.innerHTML="",c.dropdown_content.appendChild(o),c.settings.highlight&&(c.dropdown_content,u=document.querySelectorAll("span.highlight"),Array.prototype.forEach.call(u,function(e,t){var n=e.parentNode;n.replaceChild(e.firstChild,e),n.normalize()}),d.query.length&&d.tokens.length))for(t=0,f=d.tokens.length;t<f;t++)!function(e,t){var u,n;"string"==typeof t&&!t.length||(u="string"==typeof t?new RegExp(t,"i"):t,n=function e(t){var n=0;if(3===t.nodeType){var i,o,s,r,a=t.data.search(u);0<=a&&0<t.data.length&&(i=t.data.match(u),(o=document.createElement("span")).className="highlight",(s=t.splitText(a)).splitText(i[0].length),r=s.cloneNode(!0),o.appendChild(r),s.parentNode.replaceChild(o,s),n=1)}else if(1===t.nodeType&&t.childNodes&&!/(script|style)/i.test(t.tagName)&&("highlight"!==t.className||"SPAN"!==t.tagName))for(var l=0;l<t.childNodes.length;++l)l+=e(t.childNodes[l]);return n},n(e))}(c.dropdown_content,d.tokens[t].regex);if(!c.settings.hideSelected)for(t=0,f=c.items.length;t<f;t++){var C=c.getOption(c.items[t]);C&&x(C,"selected")}function I(e){g=!0;var t=c.render(e,{input:p});return c.dropdown_content.insertBefore(t,c.dropdown_content.firstChild),t}var A,_,S;c.loading?I("loading"):0===d.items.length&&c.settings.render.no_results&&p.length&&I("no_results"),(s=c.canCreate(p))&&(r=I("option_create")),c.hasOptions=0<d.items.length||s,g?(S=0<d.items.length?(_=h&&c.getOption(h))&&c.dropdown_content.contains(_)?_:"single"===c.settings.mode&&c.items.length?c.getOption(c.items[0]):(A=0,r&&!c.settings.addPrecedence&&(A=1),c.selectable()[A]):r,c.setActiveOption(S),e&&!c.isOpen&&c.open()):(c.setActiveOption(null),e&&c.isOpen&&c.close())}},{key:"selectable",value:function(){return this.dropdown_content.querySelectorAll("[data-selectable]")}},{key:"addOption",value:function(e){var t,n,i,o=this;if(Array.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))}},{key:"registerOption",value:function(e){var t=D(e[this.settings.valueField]);return null!=t&&!this.options.hasOwnProperty(t)&&(e.$order=e.$order||++this.order,this.options[t]=e,t)}},{key:"registerOptionGroup",value:function(e){var t=D(e[this.settings.optgroupValueField]);return!!t&&(e.$order=e.$order||++this.order,this.optgroups[t]=e,t)}},{key:"addOptionGroup",value:function(e,t){t[this.settings.optgroupValueField]=e,(e=this.registerOptionGroup(t))&&this.trigger("optgroup_add",e,t)}},{key:"removeOptionGroup",value:function(e){this.optgroups.hasOwnProperty(e)&&(delete this.optgroups[e],this.clearCache(),this.trigger("optgroup_remove",e))}},{key:"clearOptionGroups",value:function(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")}},{key:"updateOption",value:function(e,t){var n,i,o,s,r,a,l,u=this;if(e=D(e),o=D(t[u.settings.valueField]),null!==e&&u.options.hasOwnProperty(e)){if("string"!=typeof o)throw new Error("Value must be set in option data");l=u.options[e].$order,o!==e&&(delete u.options[e],-1!==(s=u.items.indexOf(e))&&u.items.splice(s,1,o)),t.$order=t.$order||l,u.options[o]=t,r=u.renderCache.item,a=u.renderCache.option,r&&(delete r[e],delete r[o]),a&&(delete a[e],delete a[o]),-1!==u.items.indexOf(o)&&(n=u.getItem(e),i=u.render("item",t),n.classList.contains("active")&&x(i,"active"),n.parentNode.insertBefore(i,n),n.remove()),u.lastQuery=null,u.isOpen&&u.refreshOptions(!1)}}},{key:"removeOption",value:function(e,t){var n=this;e=D(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)}},{key:"clearOptions",value:function(){this.loadedSearches={},this.userOptions={},this.clearCache();var e={};for(var t in this.options)this.options.hasOwnProperty(t)&&0<=this.items.indexOf(t)&&(e[t]=this.options[t]);this.options=this.sifter.items=e,this.lastQuery=null,this.trigger("option_clear")}},{key:"getOption",value:function(e){return this.renderCache.option.hasOwnProperty(e)?this.renderCache.option[e]:this.getElementWithValue(e,this.selectable())}},{key:"getAdjacent",value:function(e,t,n){var i=2<arguments.length&&void 0!==n?n:"option";if(e){var o=this.settings.optionClass,s=this.dropdown;"item"==i&&(s=this.control,o=this.settings.itemClass);for(var r=s.querySelectorAll("."+o),a=0;a<r.length;a++)if(r[a]==e)return 0<t?r[a+1]:r[a-1]}}},{key:"getElementWithValue",value:function(e,t){if(null!=(e=D(e)))for(var n=0,i=t.length;n<i;n++)if(t[n].getAttribute("data-value")===e)return t[n]}},{key:"getItem",value:function(e){return this.getElementWithValue(e,this.control.children)}},{key:"addItems",value:function(e,t){this.buffer=document.createDocumentFragment();for(var n=this.control.children,i=0;i<n.length;i++)this.buffer.appendChild(n[i]);for(var o=Array.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;r.insertBefore(this.buffer,r.firstChild),this.buffer=null}},{key:"addItem",value:function(a,l){g(this,l?[]:["change"],function(){var e,t,n,i,o,s=this,r=s.settings.mode;a=D(a),(-1===s.items.indexOf(a)||("single"===r&&s.close(),"single"!==r&&s.settings.duplicates))&&s.options.hasOwnProperty(a)&&("single"===r&&s.clear(l),"multi"===r&&s.isFull()||(o=s.render("item",s.options[a]),this.control.contains(o)&&(o=o.cloneNode(!0)),e=s.isFull(),s.items.splice(s.caretPos,0,a),s.insertAtCaret(o),s.isPending&&(e||!s.isFull())||s.refreshState(),s.isSetup&&(t=s.selectable(),s.isPending||(n=s.getOption(a),i=s.getAdjacent(n,1),s.refreshOptions(s.isFocused&&"single"!==r),i&&s.setActiveOption(i)),!t.length||s.isFull()?s.close():s.isPending||s.positionDropdown(),s.trigger("item_add",a,o),s.isPending||s.updateOriginalInput({silent:l}))))})}},{key:"removeItem",value:function(e,t){var n,i,o=this.getItem(e);o&&(e=D(o.dataset.value),-1!==(n=this.items.indexOf(e))&&(o.remove(),o.classList.contains("active")&&(i=this.activeItems.indexOf(o),this.activeItems.splice(i,1),F(o,"active")),this.items.splice(n,1),this.lastQuery=null,!this.settings.persist&&this.userOptions.hasOwnProperty(e)&&this.removeOption(e,t),n<this.caretPos&&this.setCaret(this.caretPos-1),this.refreshState(),this.updateOriginalInput({silent:t}),this.positionDropdown(),this.trigger("item_remove",e,o)))}},{key:"createItem",value:function(e,n){var t,i=this,o=i.caretPos;e=e||i.inputValue();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();function r(e){if(i.unlock(),!e||"object"!==l(e))return s();var t=D(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),a=!0}var a=!1;return"function"==typeof i.settings.create?t=i.settings.create.apply(this,[e,r]):((t={})[i.settings.labelField]=e,t[i.settings.valueField]=e),a||r(t),!0}},{key:"refreshItems",value:function(){this.lastQuery=null,this.isSetup&&this.addItem(this.items),this.refreshState(),this.updateOriginalInput()}},{key:"refreshState",value:function(){var e=this;e.refreshValidityState();var t=e.isFull(),n=e.isLocked;e.wrapper.classList.toggle("rtl",e.rtl);var i,o=e.control.classList;o.toggle("focus",e.isFocused),o.toggle("disabled",e.isDisabled),o.toggle("required",e.isRequired),o.toggle("invalid",e.isInvalid),o.toggle("locked",n),o.toggle("full",t),o.toggle("not-full",!t),o.toggle("input-active",e.isFocused&&!e.isInputHidden),o.toggle("dropdown-active",e.isOpen),o.toggle("has-options",(i=e.options,0===Object.keys(i).length)),o.toggle("has-items",0<e.items.length)}},{key:"refreshValidityState",value:function(){if(!this.isRequired)return!1;var e=!this.items.length;this.isInvalid=e,this.control_input.required=e,this.input.required=!e}},{key:"isFull",value:function(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems}},{key:"updateOriginalInput",value:function(e){var t,n,i,o,s=this;if(e=e||{},s.is_select_tag){for(i=[],t=0,n=s.items.length;t<n;t++)o=s.options[s.items[t]][s.settings.labelField]||"",i.push('<option value="'+h(s.items[t])+'" selected="selected">'+h(o)+"</option>");i.length||this.input.hasAttribute("multiple")||i.push('<option value="" selected="selected"></option>'),s.input.innerHTML=i.join("")}else s.input.value=s.getValue(),s.input.setAttribute("value",s.input.value);s.isSetup&&(e.silent||s.trigger("change",s.input.value))}},{key:"open",value:function(){var e=this;e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.focus(),e.isOpen=!0,e.refreshState(),v(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),v(e.dropdown,{visibility:"visible",display:"block"}),e.trigger("dropdown_open",e.dropdown))}},{key:"close",value:function(){var e=this,t=e.isOpen;"single"===e.settings.mode&&e.items.length&&(e.hideInput(),e.isBlurring||e.blur()),e.isOpen=!1,v(e.dropdown,{display:"none"}),e.setActiveOption(null),e.refreshState(),t&&e.trigger("dropdown_close",e.dropdown)}},{key:"positionDropdown",value:function(){var e,t,n,i;"body"===this.settings.dropdownParent&&(t=(e=this.control).getBoundingClientRect(),n=e.offsetHeight+t.top+window.scrollY,i=t.left+window.scrollX,v(this.dropdown,{width:t.width+"px",top:n+"px",left:i+"px"}))}},{key:"clear",value:function(e){if(this.items.length){for(var t=this.controlChildren(),n=0;n<t.length;n++)t[n].remove();this.items=[],this.lastQuery=null,this.setCaret(0),this.setActiveItem(null),this.updateOriginalInput({silent:e}),this.refreshState(),this.showInput(),this.trigger("clear")}}},{key:"insertAtCaret",value:function(e){var t=Math.min(this.caretPos,this.items.length),n=this.buffer||this.control;0===t?n.insertBefore(e,n.firstChild):n.insertBefore(e,n.children[t]),this.setCaret(t+1)}},{key:"deleteSelection",value:function(e){var t,n,i,o,s,r=this,a=e&&8===e.keyCode?-1:1,l={start:(s=r.control_input).selectionStart,length:s.selectionEnd-s.selectionStart},u=[];if(r.activeItems.length){for(o=_(r.activeItems,a),i=m(o),0<a&&i++,t=0,n=r.activeItems.length;t<n;t++)u.push(r.activeItems[t].dataset.value);e&&(e.preventDefault(),e.stopPropagation())}else(r.isFocused||"single"===r.settings.mode)&&r.items.length&&(a<0&&0===l.start&&0===l.length?u.push(r.items[r.caretPos-1]):0<a&&l.start===r.inputValue().length&&u.push(r.items[r.caretPos]));if(!u.length||"function"==typeof r.settings.onDelete&&!1===r.settings.onDelete.apply(r,[u,e]))return!1;for(void 0!==i&&r.setCaret(i);u.length;)r.removeItem(u.pop());return r.showInput(),r.positionDropdown(),r.refreshOptions(!1),!0}},{key:"advanceSelection",value:function(e,t){var n,i,o;0!==e&&(this.rtl&&(e*=-1),this.isKeyDown(y,t)||this.isKeyDown(16,t)?(i=this.getLastActive(e),(o=this.getAdjacent(i,e,"item"))&&(o.classList.contains("active")&&this.removeActiveItem(i),this.setActiveItemClass(o))):this.isFocused&&!this.isInputHidden?this.inputValue().length||this.setCaret(this.caretPos+e):(i=this.getLastActive(e))&&(n=m(i),this.setCaret(0<e?n+1:n),this.setActiveItem(null)))}},{key:"getLastActive",value:function(e){var t=this.control.querySelector(".last-active");return t||function(e,t,n){var i=e.querySelectorAll(t);if(i)return _(i,n)}(this.control,".active",e)}},{key:"setCaret",value:function(e){var t=this;if(e="single"===t.settings.mode||t.settings.controlInput?t.items.length:Math.max(0,Math.min(t.items.length,e)),!t.settings.controlInput&&!t.isPending)for(var n,i=this.controlChildren(),o=i.length,s=0;s<o;s++)n=i[s],s<e?t.control_input.insertAdjacentElement("beforebegin",n):t.control.appendChild(n);t.caretPos=e}},{key:"controlChildren",value:function(){return Array.prototype.filter.call(this.control.children,function(e){return"INPUT"!==e.nodeName})}},{key:"lock",value:function(){this.close(),this.isLocked=!0,this.refreshState()}},{key:"unlock",value:function(){this.isLocked=!1,this.refreshState()}},{key:"disable",value:function(){this.input.disabled=!0,this.control_input.disabled=!0,this.control_input.tabIndex=-1,this.isDisabled=!0,this.lock()}},{key:"enable",value:function(){this.input.disabled=!1,this.control_input.disabled=!1,this.control_input.tabIndex=this.tabIndex,this.isDisabled=!1,this.unlock()}},{key:"destroy",value:function(){var e=this.revertSettings;this.trigger("destroy"),this.off(),this.wrapper.remove(),this.dropdown.remove(),this.input.innerHTML="",e.tabindex?this.input.setAttribute("tabindex",e.tabindex):this.input.removeAttribute("tabindex"),F(this.input,"tomselected"),this.input.removeAttribute("hidden");for(var t=0;t<e.children.length;t++)this.input.appendChild(e.children[t]);this._destroy(),delete this.input.tomselect}},{key:"render",value:function(e,t){var n,i,o="",s=this;return"option"!==e&&"item"!==e||(n=D(t[s.settings.valueField]),!s.renderCache[e].hasOwnProperty(n))?(o=k(s.settings.render[e].apply(this,[t,h])),"option"===e||"option_create"===e?t[s.settings.disabledField]||o.setAttribute("data-selectable",""):"optgroup"===e&&(i=t.group[s.settings.optgroupValueField],o.setAttribute("data-group",i),t.group[s.settings.disabledField]&&o.setAttribute("data-disabled","")),"option"!==e&&"item"!==e||(o.setAttribute("data-value",n),x(o,"item"===e?s.settings.itemClass:s.settings.optionClass),s.renderCache[e][n]=o),o):s.renderCache[e][n]}},{key:"clearCache",value:function(e){void 0===e?this.renderCache={item:{},option:{}}:this.renderCache[e]={}}},{key:"canCreate",value:function(e){if(!this.settings.create)return!1;var t=this.settings.createFilter;return e.length&&("function"!=typeof t||t.call(this,e))&&(!(t instanceof RegExp)||t.test(e))}},{key:"isKeyDown",value:function(e,t){return!!t&&(!t.altKey&&((!t[b]||!t.shiftKey)&&(!(e!=y||!t[b])||!(16!=e||!t.shiftKey))))}},{key:"hook",value:function(n,e,i){var o=this,s=o[e];o[e]=function(){var e,t;return"after"===n&&(e=s.apply(o,arguments)),t=i.apply(o,arguments),"instead"===n?t:("before"===n&&(e=s.apply(o,arguments)),e)}}}])&&i(e.prototype,t),n&&i(e,n),r}();if(void 0===e)throw'Dependency MicroPlugin is missing. Make sure you either: (1) are using the "complete" version of Tom Select, or (2) require MicroPlugin before you load Tom Select.';return e.mixin(S),S.count=0,S.defaults={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:!1,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,maxOptions:50,maxItems:null,hideSelected:null,duplicates:!1,addPrecedence:!1,selectOnTab:!1,preload:!1,allowEmptyOption:!1,closeAfterSelect:!1,scrollDuration:60,loadThrottle:300,loadingClass:"loading",dataAttr:null,optgroupField:"optgroup",valueField:"value",labelField:"text",disabledField:"disabled",optgroupLabelField:"label",optgroupValueField:"value",lockOptgroupOrder:!1,sortField:"$order",searchField:["text"],searchConjunction:"and",mode:null,wrapperClass:"ts-control",inputClass:"ts-input",dropdownClass:"ts-dropdown",dropdownContentClass:"ts-dropdown-content",itemClass:"item",optionClass:"option",dropdownParent:null,controlInput:null,copyClassesToDropdown:!0,render:{}},S.define("change_listener",function(e){var t=this,n=!1;t.input.addEventListener("change",function(){var e;n?n=!1:(n=!0,e=O(t.input,{}),t.setupOptions(e.options,e.optgroups),t.setValue(e.items))})}),S.define("drag_drop",function(e){if(!$.fn.sortable)throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');var t,n,i;"multi"===this.settings.mode&&(n=(t=this).lock,i=t.unlock,t.hook("instead","lock",function(){var e=t.control.dataset.sortable;return e&&e.disable(),n.apply(t,arguments)}),t.hook("instead","unlock",function(){var e=t.control.dataset.sortable;return e&&e.enable(),i.apply(t,arguments)}),t.hook("after","setup",function(){var n=$(t.control).sortable({items:"[data-value]",forcePlaceholderSize:!0,disabled:t.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=[];n.children("[data-value]").each(function(){e.push($(this).attr("data-value"))}),t.setValue(e)}})}))}),S.define("dropdown_header",function(t){var n=this;t=Object.assign({title:"Untitled",headerClass:"dropdown-header",titleRowClass:"dropdown-header-title",labelClass:"dropdown-header-label",closeClass:"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>'}},t),n.hook("after","setup",function(){var e=k(t.html(t));n.dropdown.insertBefore(e,n.dropdown.firstChild)})}),S.define("input_autogrow",function(e){var a=this;a.hook("after","setup",function(){var e=document.createElement("span"),t=this.control_input;e.style.position="absolute",e.style.top="-99999px",e.style.left="-99999px",e.style.width="auto",e.style.padding=0,e.style.whiteSpace="pre",a.wrapper.appendChild(e);for(var n=["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"],i=0,o=n.length;i<o;i++){var s=n[i];e.style[s]=t.style[s]}function r(){e.textContent=t.value,t.style.width=e.clientWidth+"px"}t.addEventListener("input",r),t.addEventListener("keyup",r),t.addEventListener("blur",r),t.addEventListener("update",r)})}),S.define("no_backspace_delete",function(e){this.hook("instead","setActiveItem",function(){}),this.hook("instead","selectAll",function(){}),this.hook("instead","deleteSelection",function(){})}),S.define("optgroup_columns",function(e){var s=this,r=s.onKeyDown;s.hook("instead","onKeyDown",function(e){var t,n,i,o;return!s.isOpen||37!==e.keyCode&&39!==e.keyCode?r.apply(s,arguments):(s.ignoreHover=!0,o=A(s.activeOption,"[data-group]"),t=m(s.activeOption,"[data-selectable]"),void((o=37===e.keyCode?o.previousSibling:o.nextSibling)&&(n=(i=o.querySelectorAll("[data-selectable]"))[Math.min(i.length-1,t)])&&s.setActiveOption(n)))})}),S.define("remove_button",function(e){e=Object.assign({label:"×",title:"Remove",className:"remove",append:!0},e);var i,o=this;e.append&&(i='<a href="javascript:void(0)" class="'+e.className+'" tabindex="-1" title="'+h(e.title)+'">'+e.label+"</a>",o.hook("after","setupTemplates",function(){var t=o.settings.render.item;o.settings.render.item=function(){var n=k(t.apply(o,arguments)),e=k(i);return n.appendChild(e),e.addEventListener("mousedown",function(e){e.preventDefault(),e.stopPropagation()}),e.addEventListener("click",function(e){var t;e.preventDefault(),e.stopPropagation(),"single"!==o.settings.mode&&e.stopPropagation(),o.isLocked||(t=n.dataset.value,o.removeItem(t),o.refreshOptions(!1))}),n}}))}),S.define("restore_on_backspace",function(i){var o=this;i.text=i.text||function(e){return e[o.settings.labelField]};var s=o.onKeyDown;o.hook("instead","onKeyDown",function(e){var t,n;return 8===e.keyCode&&""===o.control_input.value&&!o.activeItems.length&&0<=(t=o.caretPos-1)&&t<o.items.length?(n=o.options[o.items[t]],o.deleteSelection(e)&&(o.setTextboxValue(i.text.call(o,n)),o.refreshOptions(!0)),void e.preventDefault()):s.apply(o,arguments)})}),S});var tomSelect=function(e,t){return new TomSelect(e,t)}; | ||
!function(e,t){"function"==typeof define&&define.amd?define(["sifter","microplugin"],t):"object"==typeof exports?module.exports=t(require("sifter"),require("microplugin")):e.TomSelect=t(e.Sifter,e.MicroPlugin)}(this,function(a,e){"use strict";function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(s){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}();return function(){var e,t,i,n,o=p(s);return t=r?(e=p(this).constructor,Reflect.construct(o,arguments,e)):o.apply(this,arguments),i=this,!(n=t)||"object"!==l(n)&&"function"!=typeof n?c(i):n}}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return r(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function d(){}d.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 i=arguments.length;return 0===i?delete this._events:1===i?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))}};function h(e){return(e+"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function g(t,i,e){var n,o=t.trigger,s={};for(n in t.trigger=function(){var e=arguments[0];if(-1===i.indexOf(e))return o.apply(t,arguments);s[e]=arguments},e.apply(t,[]),t.trigger=o,s)s.hasOwnProperty(n)&&o.apply(t,s[n])}function f(e,t){var i=document.createEvent("HTMLEvents");i.initEvent(t,!0,!1),e.dispatchEvent(i)}function v(t,i){Object.keys(i).forEach(function(e){t.style[e]=i[e]})}function x(e){var t=b.apply(null,arguments);e=O(e);for(var i,n=0;n<e.length;n++){(i=e[n].classList).add.apply(i,s(t))}}function F(e){var t=b.apply(null,arguments);e=O(e);for(var i,n=0;n<e.length;n++){(i=e[n].classList).remove.apply(i,s(t))}}function w(i,e,n,o){for(var t=e.split(/\s/),s=function(e){var t=C(e.target,n,i);t&&(e.delegateTarget=t,o.call(t,e))},r=0;r<t.length;r++)i.addEventListener(t[r],s,!0)}function m(e,t){if(!e)return-1;t=t||e.nodeName;for(var i=0;e=e.previousElementSibling;)e.matches(t)&&i++;return i}var y=function(u,e){var t,c=Object.assign({},A.defaults,e),p=c.dataAttr,d=c.labelField,h=c.valueField,g=c.disabledField,f=c.optgroupField,v=c.optgroupLabelField,m=c.optgroupValueField,i=u.tagName.toLowerCase(),n=u.getAttribute("placeholder")||u.getAttribute("data-placeholder");n||c.allowEmptyOption||(t=u.querySelector('option[value=""]'))&&(n=t.textContent);var y={placeholder:n,options:[],optgroups:[],items:[]};return("select"===i?function(){function r(e){var t=Object.assign({},e.dataset),i=p&&t[p];return"string"==typeof i&&i.length&&(t=Object.assign(t,JSON.parse(i))),t}function a(e,t){var i,n,o=D(e.value);(o||c.allowEmptyOption)&&(l.hasOwnProperty(o)?t&&((i=l[o][f])?Array.isArray(i)?i.push(t):l[o][f]=[i,t]:l[o][f]=t):((n=r(e))[d]=n[d]||e.textContent,n[h]=n[h]||o,n[g]=n[g]||e.disabled,n[f]=n[f]||t,l[o]=n,s.push(n),e.selected&&y.items.push(o)))}var e,t,i,n,s=y.options,l={};for(y.maxItems=u.hasAttribute("multiple")?null:1,e=0,t=(n=u.children).length;e<t;e++)"optgroup"===(i=n[e].tagName.toLowerCase())?function(e){var t,i=e.getAttribute("label");i&&((t=r(e))[v]=i,t[m]=i,t[g]=e.disabled,y.optgroups.push(t));for(var n,o=0,s=(n=e.children).length;o<s;o++)a(n[o],i)}(n[e]):"option"===i&&a(n[e])}:function(){var e,t,i,n,o=u.getAttribute(p);if(o)for(y.options=JSON.parse(o),e=0,t=y.options.length;e<t;e++)y.items.push(y.options[e][h]);else{var s=u.value.trim()||"";if(!c.allowEmptyOption&&!s.length)return;for(e=0,t=(i=s.split(c.delimiter)).length;e<t;e++)(n={})[d]=i[e],n[h]=i[e],y.options.push(n);y.items=i}})(),Object.assign({},A.defaults,y,e)},D=function(e){return null==e?null:"boolean"==typeof e?e?"1":"0":e+""},k=function(e){if(e.jquery)return e[0];if(e instanceof HTMLElement)return e;if(-1<e.indexOf("<")){var t=document.createElement("div");return t.innerHTML=e.trim(),t.firstChild}return document.querySelector(e)},b=function(){for(var e=[],t=1;t<arguments.length;t++){var i=arguments[t];"string"==typeof i&&(i=i.trim().split(/[\11\12\14\15\40]/)),Array.isArray(i)&&(e=e.concat(i))}return e.filter(Boolean)},O=function(e){return Array.isArray(e)||(e=[e]),e},C=function(e,t,i){for(;e&&e.matches;){if(e.matches(t))return e;if(e==i)break;e=e.parentNode}},I=function(e,t){return 0<t?e[e.length-1]:e[0]},A=function(){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(r,d);var e,t,i,s=u(r);function r(e,t){var i;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r);var n=c(i=s.call(this));if((e=k(e)).tomselect)throw new Error("Tom Select already initialized on this element");e.tomselect=n,t=y(e,t);var o=(window.getComputedStyle&&window.getComputedStyle(e,null)).getPropertyValue("direction");return Object.assign(n,{order:0,settings:t,input:e,tabIndex:e.getAttribute("tabindex")||"",is_select_tag:"select"===e.tagName.toLowerCase(),rtl:/rtl/i.test(o),highlightedValue:null,isBlurring:!1,isOpen:!1,isDisabled:!1,isRequired:e.required,isInvalid:!1,isLocked:!1,isFocused:!1,isInputHidden:!1,isSetup:!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:{item:{},option:{}}}),n.settings.load&&n.settings.loadThrottle&&(n.settings.load=n.loadDebounce(n.settings.load,n.settings.loadThrottle)),n.sifter=new a(i.options,{diacritics:t.diacritics}),n.setupOptions(n.settings.options,n.settings.optgroups),delete n.settings.optgroups,delete n.settings.options,n.settings.mode=n.settings.mode||(1===n.settings.maxItems?"single":"multi"),"boolean"!=typeof n.settings.hideSelected&&(n.settings.hideSelected="multi"===n.settings.mode),"string"==typeof n.settings.createFilter&&(n.settings.createFilter=new RegExp(n.settings.createFilter)),n.initializePlugins(n.settings.plugins),n.setupCallbacks(),n.setupTemplates(),n.setup(),i}return e=r,(t=[{key:"setup",value:function(){var i,e,t,n,o,s,r,a,l=this,u=l.settings,c=l.input,p=l.settings.mode,d=c.getAttribute("class")||"",h=k("<div>");if(x(h,u.wrapperClass,d,p),i=k('<div class="items">'),x(i,u.inputClass),h.append(i),t=l.render("dropdown"),x(t,u.dropdownClass,p),n=k('<div style="scroll-behavior: smooth;">'),x(n,u.dropdownContentClass),t.append(n),k(u.dropdownParent||h).appendChild(t),u.controlInput)e=k(u.controlInput);else{e=k('<input type="text" autocomplete="off" />');for(var g=["autocorrect","autocapitalize","autocomplete"],f=0;f<g.length;f++){var v=g[f];c.getAttribute(v)&&e.setAttribute(v,c.getAttribute(v))}}u.controlInput||(e.setAttribute("tabindex",c.disabled?"-1":l.tabIndex),i.appendChild(e)),(s=c.getAttribute("id"))&&(e.setAttribute("id",s+"-tomselected"),(r=document.querySelector("label[for='"+s+"']"))&&r.setAttribute("for",s+"-tomselected")),l.settings.copyClassesToDropdown&&x(t,d),h.style.width=c.style.width,l.plugins.names.length&&(o="plugin-"+l.plugins.names.join(" plugin-"),x([h,t],o)),(null===u.maxItems||1<u.maxItems)&&l.is_select_tag&&c.setAttribute("multiple","multiple"),l.settings.placeholder&&e.setAttribute("placeholder",u.placeholder),!l.settings.splitOn&&l.settings.delimiter&&(a=l.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),l.settings.splitOn=new RegExp("\\s*"+a+"+\\s*")),e.type=c.type,l.control=i,l.control_input=e,l.wrapper=h,l.dropdown=t,l.dropdown_content=n,w(t,"mouseenter","[data-selectable]",function(){return l.onOptionHover.apply(l,arguments)}),w(t,"mousedown","[data-selectable]",function(){return l.onOptionSelect.apply(l,arguments)}),i.addEventListener("mousedown",function(e){var t=C(e.target,"."+l.settings.itemClass,i);return t?(e.delegateTarget=t,l.onItemSelect.call(l,e)):l.onMouseDown.call(l,e)}),i.addEventListener("click",function(){return l.onClick.apply(l,arguments)}),e.addEventListener("mousedown",function(e){e.stopPropagation()}),e.addEventListener("keydown",function(){return l.onKeyDown.apply(l,arguments)}),e.addEventListener("keyup",function(){return l.onKeyUp.apply(l,arguments)}),e.addEventListener("keypress",function(){return l.onKeyPress.apply(l,arguments)}),e.addEventListener("resize",function(){l.positionDropdown.apply(l,[])}),e.addEventListener("blur",function(){return l.onBlur.apply(l,arguments)}),e.addEventListener("focus",function(){return l.ignoreBlur=!1,l.onFocus.apply(l,arguments)}),e.addEventListener("paste",function(){return l.onPaste.apply(l,arguments)});function m(e){if(l.isFocused){if(C(e.target,"."+l.settings.wrapperClass,l.wrapper))return!1;l.blur(e.target)}}function y(){l.isOpen&&l.positionDropdown.apply(l,arguments)}function b(){l.ignoreHover=!1}document.addEventListener("mousedown",m),window.addEventListener("sroll",y),window.addEventListener("resize",y),window.addEventListener("mousemove",b),l._destroy=function(){document.removeEventListener("mousedown",m),window.removeEventListener("mousemove",b),window.removeEventListener("sroll",y),window.removeEventListener("resize",y)};for(var O=[];0<c.children.length;)O.push(c.children[0]),c.children[0].remove();this.revertSettings={children:O,tabindex:c.getAttribute("tabindex")},c.setAttribute("tabindex",-1),c.setAttribute("hidden","hidden"),c.insertAdjacentElement("afterend",l.wrapper),l.setValue(u.items),delete u.items,l.supportsValidity()&&c.addEventListener("invalid",function(e){e.preventDefault(),l.isInvalid=!0,l.refreshState()}),l.updateOriginalInput(),l.refreshItems(),l.refreshState(),l.isSetup=!0,c.disabled&&l.disable(),l.on("change",this.onChange),x(c,"tomselected"),l.trigger("initialize"),!0===u.preload&&l.onSearchChange("")}},{key:"supportsValidity",value:function(){return!/android/i.test(window.navigator.userAgent)&&!!document.createElement("input").validity}},{key:"setupOptions",value:function(e,t){var i,n;for(t=t||[],i=0,n=(e=e||[]).length;i<n;i++)this.registerOption(e[i]);for(i=0,n=t.length;i<n;i++)this.registerOptionGroup(t[i])}},{key:"setupTemplates",value:function(){var i=this.settings.labelField,n=this.settings.optgroupLabelField,e={optgroup:function(e,t){var i=document.createElement("div");return i.className="optgroup",i.appendChild(e.options),i},optgroup_header:function(e,t){return'<div class="optgroup-header">'+t(e[n])+"</div>"},option:function(e,t){return"<div>"+t(e[i])+"</div>"},item:function(e,t){return"<div>"+t(e[i])+"</div>"},option_create:function(e,t){return'<div class="create">Add <strong>'+t(e.input)+"</strong>…</div>"},no_results:function(){return'<div class="no-results">No results found</div>'},loading:function(){return'<div class="spinner"></div>'},dropdown:function(){return'<div style="display:none"></div>'}};this.settings.render=Object.assign({},e,this.settings.render)}},{key:"setupCallbacks",value:function(){var e,t,i={initialize:"onInitialize",change:"onChange",item_add:"onItemAdd",item_remove:"onItemRemove",clear:"onClear",option_add:"onOptionAdd",option_remove:"onOptionRemove",option_clear:"onOptionClear",optgroup_add:"onOptionGroupAdd",optgroup_remove:"onOptionGroupRemove",optgroup_clear:"onOptionGroupClear",dropdown_open:"onDropdownOpen",dropdown_close:"onDropdownClose",type:"onType",load:"onLoad",focus:"onFocus",blur:"onBlur"};for(e in i)(t=this.settings[i[e]])&&this.on(e,t)}},{key:"onClick",value:function(e){this.isFocused&&this.isOpen||(this.focus(),e.preventDefault())}},{key:"onMouseDown",value:function(e){var t=this;if(t.isFocused){if(e.target!==t.control_input)return"single"===t.settings.mode?t.isOpen?t.close():t.open():t.setActiveItem(null),!1}else window.setTimeout(function(){t.focus()},0)}},{key:"onChange",value:function(){f(this.input,"change")}},{key:"onPaste",value:function(e){var o=this;o.isFull()||o.isInputHidden||o.isLocked?e.preventDefault():o.settings.splitOn&&setTimeout(function(){var e=o.inputValue();if(e.match(o.settings.splitOn))for(var t=e.trim().split(o.settings.splitOn),i=0,n=t.length;i<n;i++)o.createItem(t[i])},0)}},{key:"onKeyPress",value: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}},{key:"onKeyDown",value:function(e){e.target,this.control_input;var t,i,n=this;if(n.isLocked)9!==e.keyCode&&e.preventDefault();else{switch(e.keyCode){case 65:if(n.isKeyDown(17,e))return void n.selectAll();break;case 27:return void(n.isOpen&&(e.preventDefault(),e.stopPropagation(),n.close()));case 40:return!n.isOpen&&n.hasOptions?n.open():n.activeOption&&(n.ignoreHover=!0,(t=n.getAdjacent(n.activeOption,1))&&n.setActiveOption(t,!0)),void e.preventDefault();case 38:return n.activeOption&&(n.ignoreHover=!0,(i=n.getAdjacent(n.activeOption,-1))&&n.setActiveOption(i,!0)),void e.preventDefault();case 13:return void(n.isOpen&&n.activeOption&&(n.onOptionSelect({delegateTarget:n.activeOption}),e.preventDefault()));case 37:return void n.advanceSelection(-1,e);case 39:return void n.advanceSelection(1,e);case 9:return n.settings.selectOnTab&&n.isOpen&&n.activeOption&&(n.onOptionSelect({delegateTarget:n.activeOption}),e.preventDefault()),void(n.settings.create&&n.createItem()&&e.preventDefault());case 8:case 46:return void n.deleteSelection(e)}!n.isInputHidden||n.isKeyDown(17,e)||e.preventDefault()}}},{key:"onKeyUp",value:function(e){var t=this;if(t.isLocked)return e&&e.preventDefault();var i=t.inputValue();t.lastValue!==i&&(t.lastValue=i,t.onSearchChange(i),t.refreshOptions(),t.trigger("type",i))}},{key:"onSearchChange",value:function(t){var i=this,n=i.settings.load;n&&(i.loadedSearches.hasOwnProperty(t)||(i.loadedSearches[t]=!0,i.load(function(e){n.apply(i,[t,e])})))}},{key:"onFocus",value:function(e){var t=this,i=t.isFocused;if(t.isDisabled)return t.blur(),e&&e.preventDefault(),!1;t.ignoreFocus||(t.isFocused=!0,"focus"===t.settings.preload&&t.onSearchChange(""),i||t.trigger("focus"),t.activeItems.length||(t.showInput(),t.setActiveItem(null),t.refreshOptions(!!t.settings.openOnFocus)),t.refreshState())}},{key:"onBlur",value:function(e,t){var i=this;if(i.isFocused){if(i.isFocused=!1,i.ignoreFocus=!1,!i.ignoreBlur&&document.activeElement===i.dropdown_content)return i.ignoreBlur=!0,void i.onFocus(e);var n=function(){i.close(),i.setActiveItem(null),i.setActiveOption(null),i.setCaret(i.items.length),i.refreshState(),t&&t.focus&&t.focus(),i.isBlurring=!1,i.trigger("blur")};i.isBlurring=!0,i.settings.create&&i.settings.createOnBlur?i.createItem(null,!1,n):n()}}},{key:"onOptionHover",value:function(e){this.ignoreHover||this.setActiveOption(e.delegateTarget,!1)}},{key:"onOptionSelect",value:function(e){var t,i=this;e.preventDefault&&(e.preventDefault(),e.stopPropagation());var n=e.delegateTarget;n&&(n.parentNode&&n.parentNode.matches("[data-disabled]")||(n.classList.contains("create")?i.createItem(null,function(){i.settings.closeAfterSelect&&i.close()}):void 0!==(t=n.dataset.value)&&(i.lastQuery=null,i.addItem(t),i.settings.closeAfterSelect?i.close():!i.settings.hideSelected&&e.type&&/mouse/.test(e.type)&&i.setActiveOption(i.getOption(t)))))}},{key:"onItemSelect",value:function(e){this.isLocked||"multi"===this.settings.mode&&(e.preventDefault(),this.setActiveItem(e.delegateTarget,e))}},{key:"load",value:function(e){var i=this;x(i.wrapper,i.settings.loadingClass),i.loading++,e.call(i,function(e,t){i.loading=Math.max(i.loading-1,0),i.lastQuery=null,i.setupOptions(e,t),i.refreshOptions(i.isFocused&&!i.isInputHidden),i.loading||F(i.wrapper,i.settings.loadingClass),i.trigger("load",e)})}},{key:"loadDebounce",value:function(i,n){var o;return function(){var e=this,t=arguments;o&&(e.loading=Math.max(e.loading-1,0)),window.clearTimeout(o),o=window.setTimeout(function(){o=null,i.apply(e,t)},n)}}},{key:"setTextboxValue",value:function(e){var t=this.control_input;t.value!==e&&(t.value=e,f(t,"update"),this.lastValue=e)}},{key:"getValue",value:function(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}},{key:"setValue",value:function(e,t){g(this,t?[]:["change"],function(){this.clear(t),this.addItems(e,t)})}},{key:"setActiveItem",value:function(e,t){var i,n,o,s,r,a;if("single"!==this.settings.mode){if(!e)return F(this.activeItems,"active"),this.activeItems=[],void(this.isFocused&&this.showInput());if("mousedown"===(i=t&&t.type.toLowerCase())&&this.isKeyDown(16,t)&&this.activeItems.length){for(a=this.getLastActive(),o=Array.prototype.indexOf.call(this.control.children,a),(s=Array.prototype.indexOf.call(this.control.children,e))<o&&(r=o,o=s,s=r),n=o;n<=s;n++)e=this.control.children[n],-1===this.activeItems.indexOf(e)&&this.setActiveItemClass(e);t.preventDefault()}else"mousedown"===i&&this.isKeyDown(17,t)||"keydown"===i&&this.isKeyDown(16,t)?e.classList.contains("active")?this.removeActiveItem(e):this.setActiveItemClass(e):(F(this.activeItems,"active"),this.activeItems=[],this.setActiveItemClass(e));this.hideInput(),this.isFocused||this.focus()}}},{key:"setActiveItemClass",value:function(e){var t=this.control.querySelector(".last-active");t&&F(t,"last-active"),x(e,"active last-active"),-1==this.activeItems.indexOf(e)&&this.activeItems.push(e)}},{key:"removeActiveItem",value:function(e){var t=this.activeItems.indexOf(e);this.activeItems.splice(t,1),F(e,"active")}},{key:"setActiveOption",value:function(e,t){var i,n,o;e!==this.activeOption&&(this.activeOption&&F(this.activeOption,"active"),this.activeOption=null,e&&(this.activeOption=e,x(e,"active"),!t&&void 0!==t||(i=this.dropdown_content.clientHeight,t=this.dropdown_content.scrollTop||0,n=this.activeOption.offsetHeight,i+t<(o=this.activeOption.getBoundingClientRect().top-this.dropdown_content.getBoundingClientRect().top+t)+n?this.dropdown_content.scrollTop=o-i+n:o<t&&(this.dropdown_content.scrollTop=o))))}},{key:"selectAll",value:function(){"single"!==this.settings.mode&&(this.activeItems=this.controlChildren(),this.activeItems.length&&(x(this.activeItems,"active"),this.hideInput(),this.close()),this.focus())}},{key:"hideInput",value:function(){this.settings.controlInput||(this.setTextboxValue(""),v(this.control_input,{opacity:0,position:"absolute",left:(this.rtl?1e4:-1e4)+"px"}),this.isInputHidden=!0)}},{key:"showInput",value:function(){this.settings.controlInput||(v(this.control_input,{opacity:1,position:"relative",left:0}),this.isInputHidden=!1)}},{key:"inputValue",value:function(){return this.control_input.value.trim()}},{key:"focus",value:function(){var e=this;e.isDisabled||(e.ignoreFocus=!0,e.control_input.focus(),window.setTimeout(function(){e.ignoreFocus=!1,e.onFocus()},0))}},{key:"blur",value:function(e){this.control_input.blur(),this.onBlur(null,e)}},{key:"getScoreFunction",value:function(e){return this.sifter.getScoreFunction(e,this.getSearchOptions())}},{key:"getSearchOptions",value: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}}},{key:"search",value:function(e){var t,i,n,o=this,s=o.settings,r=this.getSearchOptions();if(s.score&&"function"!=typeof(n=o.settings.score.call(this,e)))throw new Error('Tom Select "score" setting must be a function that returns a function');if(e!==o.lastQuery?(o.lastQuery=e,i=o.sifter.search(e,Object.assign(r,{score:n})),o.currentResults=i):i=Object.assign({},o.currentResults),s.hideSelected)for(t=i.items.length-1;0<=t;t--)-1!==o.items.indexOf(D(i.items[t].id))&&i.items.splice(t,1);return i}},{key:"refreshOptions",value:function(e){var t,i,n,o,s,r;void 0===e&&(e=!0);var a,l,u,c=this,p=c.inputValue(),d=c.search(p),h=c.activeOption&&D(c.activeOption.dataset.value),g=!1,f=d.items.length;for("number"==typeof c.settings.maxOptions&&(f=Math.min(f,c.settings.maxOptions)),0<f&&(g=!0),i={},n=[],t=0;t<f;t++)for(var v,m=c.options[d.items[t].id],y=D(m[c.settings.valueField]),b=(b=c.getOption(y))||c.render("option",m),O=m[c.settings.optgroupField]||"",w=0,k=(v=Array.isArray(O)?O:[O])&&v.length;w<k;w++)O=v[w],c.optgroups.hasOwnProperty(O)||(O=""),i.hasOwnProperty(O)||(i[O]=document.createDocumentFragment(),n.push(O)),0<w&&(b=b.cloneNode(!0),F(b,"active")),i[O].appendChild(b);for(this.settings.lockOptgroupOrder&&n.sort(function(e,t){return(c.optgroups[e].$order||0)-(c.optgroups[t].$order||0)}),o=document.createDocumentFragment(),t=0,f=n.length;t<f;t++){O=n[t],c.optgroups.hasOwnProperty(O)&&i[O].children.length?((a=document.createDocumentFragment()).appendChild(c.render("optgroup_header",c.optgroups[O])),a.appendChild(i[O]),l=c.render("optgroup",{group:c.optgroups[O],options:a}),o.appendChild(l)):o.appendChild(i[O])}if(c.dropdown_content.innerHTML="",c.dropdown_content.appendChild(o),c.settings.highlight&&(c.dropdown_content,u=document.querySelectorAll("span.highlight"),Array.prototype.forEach.call(u,function(e,t){var i=e.parentNode;i.replaceChild(e.firstChild,e),i.normalize()}),d.query.length&&d.tokens.length))for(t=0,f=d.tokens.length;t<f;t++)!function(e,t){var u,i;"string"==typeof t&&!t.length||(u="string"==typeof t?new RegExp(t,"i"):t,i=function e(t){var i=0;if(3===t.nodeType){var n,o,s,r,a=t.data.search(u);0<=a&&0<t.data.length&&(n=t.data.match(u),(o=document.createElement("span")).className="highlight",(s=t.splitText(a)).splitText(n[0].length),r=s.cloneNode(!0),o.appendChild(r),s.parentNode.replaceChild(o,s),i=1)}else if(1===t.nodeType&&t.childNodes&&!/(script|style)/i.test(t.tagName)&&("highlight"!==t.className||"SPAN"!==t.tagName))for(var l=0;l<t.childNodes.length;++l)l+=e(t.childNodes[l]);return i},i(e))}(c.dropdown_content,d.tokens[t].regex);if(!c.settings.hideSelected)for(t=0,f=c.items.length;t<f;t++){var C=c.getOption(c.items[t]);C&&x(C,"selected")}function I(e){g=!0;var t=c.render(e,{input:p});return c.dropdown_content.insertBefore(t,c.dropdown_content.firstChild),t}var A,_,S;c.loading?I("loading"):0===d.items.length&&c.settings.render.no_results&&p.length&&I("no_results"),(s=c.canCreate(p))&&(r=I("option_create")),c.hasOptions=0<d.items.length||s,g?(S=0<d.items.length?(_=h&&c.getOption(h))&&c.dropdown_content.contains(_)?_:"single"===c.settings.mode&&c.items.length?c.getOption(c.items[0]):(A=0,r&&!c.settings.addPrecedence&&(A=1),c.selectable()[A]):r,c.setActiveOption(S),e&&!c.isOpen&&c.open()):(c.setActiveOption(null),e&&c.isOpen&&c.close())}},{key:"selectable",value:function(){return this.dropdown_content.querySelectorAll("[data-selectable]")}},{key:"addOption",value:function(e){var t,i,n,o=this;if(Array.isArray(e))for(t=0,i=e.length;t<i;t++)o.addOption(e[t]);else(n=o.registerOption(e))&&(o.userOptions[n]=!0,o.lastQuery=null,o.trigger("option_add",n,e))}},{key:"registerOption",value:function(e){var t=D(e[this.settings.valueField]);return null!=t&&!this.options.hasOwnProperty(t)&&(e.$order=e.$order||++this.order,this.options[t]=e,t)}},{key:"registerOptionGroup",value:function(e){var t=D(e[this.settings.optgroupValueField]);return!!t&&(e.$order=e.$order||++this.order,this.optgroups[t]=e,t)}},{key:"addOptionGroup",value:function(e,t){t[this.settings.optgroupValueField]=e,(e=this.registerOptionGroup(t))&&this.trigger("optgroup_add",e,t)}},{key:"removeOptionGroup",value:function(e){this.optgroups.hasOwnProperty(e)&&(delete this.optgroups[e],this.clearCache(),this.trigger("optgroup_remove",e))}},{key:"clearOptionGroups",value:function(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")}},{key:"updateOption",value:function(e,t){var i,n,o,s,r,a,l,u=this;if(e=D(e),o=D(t[u.settings.valueField]),null!==e&&u.options.hasOwnProperty(e)){if("string"!=typeof o)throw new Error("Value must be set in option data");l=u.options[e].$order,o!==e&&(delete u.options[e],-1!==(s=u.items.indexOf(e))&&u.items.splice(s,1,o)),t.$order=t.$order||l,u.options[o]=t,r=u.renderCache.item,a=u.renderCache.option,r&&(delete r[e],delete r[o]),a&&(delete a[e],delete a[o]),-1!==u.items.indexOf(o)&&(i=u.getItem(e),n=u.render("item",t),i.classList.contains("active")&&x(n,"active"),i.parentNode.insertBefore(n,i),i.remove()),u.lastQuery=null,u.isOpen&&u.refreshOptions(!1)}}},{key:"removeOption",value:function(e,t){var i=this;e=D(e);var n=i.renderCache.item,o=i.renderCache.option;n&&delete n[e],o&&delete o[e],delete i.userOptions[e],delete i.options[e],i.lastQuery=null,i.trigger("option_remove",e),i.removeItem(e,t)}},{key:"clearOptions",value:function(){this.loadedSearches={},this.userOptions={},this.clearCache();var e={};for(var t in this.options)this.options.hasOwnProperty(t)&&0<=this.items.indexOf(t)&&(e[t]=this.options[t]);this.options=this.sifter.items=e,this.lastQuery=null,this.trigger("option_clear")}},{key:"getOption",value:function(e){return this.renderCache.option.hasOwnProperty(e)?this.renderCache.option[e]:this.getElementWithValue(e,this.selectable())}},{key:"getAdjacent",value:function(e,t,i){var n=2<arguments.length&&void 0!==i?i:"option";if(e){var o=this.settings.optionClass,s=this.dropdown;"item"==n&&(s=this.control,o=this.settings.itemClass);for(var r=s.querySelectorAll("."+o),a=0;a<r.length;a++)if(r[a]==e)return 0<t?r[a+1]:r[a-1]}}},{key:"getElementWithValue",value:function(e,t){if(null!=(e=D(e)))for(var i=0,n=t.length;i<n;i++)if(t[i].getAttribute("data-value")===e)return t[i]}},{key:"getItem",value:function(e){return this.getElementWithValue(e,this.control.children)}},{key:"addItems",value:function(e,t){this.buffer=document.createDocumentFragment();for(var i=this.control.children,n=0;n<i.length;n++)this.buffer.appendChild(i[n]);for(var o=Array.isArray(e)?e:[e],n=0,s=o.length;n<s;n++)this.isPending=n<s-1,this.addItem(o[n],t);var r=this.control;r.insertBefore(this.buffer,r.firstChild),this.buffer=null}},{key:"addItem",value:function(a,l){g(this,l?[]:["change"],function(){var e,t,i,n,o,s=this,r=s.settings.mode;a=D(a),(-1===s.items.indexOf(a)||("single"===r&&s.close(),"single"!==r&&s.settings.duplicates))&&s.options.hasOwnProperty(a)&&("single"===r&&s.clear(l),"multi"===r&&s.isFull()||(o=s.render("item",s.options[a]),this.control.contains(o)&&(o=o.cloneNode(!0)),e=s.isFull(),s.items.splice(s.caretPos,0,a),s.insertAtCaret(o),s.isPending&&(e||!s.isFull())||s.refreshState(),s.isSetup&&(t=s.selectable(),s.isPending||(i=s.getOption(a),n=s.getAdjacent(i,1),s.refreshOptions(s.isFocused&&"single"!==r),n&&s.setActiveOption(n)),!t.length||s.isFull()?s.close():s.isPending||s.positionDropdown(),s.trigger("item_add",a,o),s.isPending||s.updateOriginalInput({silent:l}))))})}},{key:"removeItem",value:function(e,t){var i,n,o=this.getItem(e);o&&(e=D(o.dataset.value),-1!==(i=this.items.indexOf(e))&&(o.remove(),o.classList.contains("active")&&(n=this.activeItems.indexOf(o),this.activeItems.splice(n,1),F(o,"active")),this.items.splice(i,1),this.lastQuery=null,!this.settings.persist&&this.userOptions.hasOwnProperty(e)&&this.removeOption(e,t),i<this.caretPos&&this.setCaret(this.caretPos-1),this.refreshState(),this.updateOriginalInput({silent:t}),this.positionDropdown(),this.trigger("item_remove",e,o)))}},{key:"createItem",value:function(e,i){var t,n=this,o=n.caretPos;e=e||n.inputValue();var s=arguments[arguments.length-1];if("function"!=typeof s&&(s=function(){}),"boolean"!=typeof i&&(i=!0),!n.canCreate(e))return s(),!1;n.lock();function r(e){if(n.unlock(),!e||"object"!==l(e))return s();var t=D(e[n.settings.valueField]);if("string"!=typeof t)return s();n.setTextboxValue(""),n.addOption(e),n.setCaret(o),n.addItem(t),n.refreshOptions(i&&"single"!==n.settings.mode),s(e),a=!0}var a=!1;return"function"==typeof n.settings.create?t=n.settings.create.apply(this,[e,r]):((t={})[n.settings.labelField]=e,t[n.settings.valueField]=e),a||r(t),!0}},{key:"refreshItems",value:function(){this.lastQuery=null,this.isSetup&&this.addItem(this.items),this.refreshState(),this.updateOriginalInput()}},{key:"refreshState",value:function(){var e=this;e.refreshValidityState();var t=e.isFull(),i=e.isLocked;e.wrapper.classList.toggle("rtl",e.rtl);var n,o=e.control.classList;o.toggle("focus",e.isFocused),o.toggle("disabled",e.isDisabled),o.toggle("required",e.isRequired),o.toggle("invalid",e.isInvalid),o.toggle("locked",i),o.toggle("full",t),o.toggle("not-full",!t),o.toggle("input-active",e.isFocused&&!e.isInputHidden),o.toggle("dropdown-active",e.isOpen),o.toggle("has-options",(n=e.options,0===Object.keys(n).length)),o.toggle("has-items",0<e.items.length)}},{key:"refreshValidityState",value:function(){if(!this.isRequired)return!1;var e=!this.items.length;this.isInvalid=e,this.control_input.required=e,this.input.required=!e}},{key:"isFull",value:function(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems}},{key:"updateOriginalInput",value:function(e){var t,i,n,o,s=this;if(e=e||{},s.is_select_tag){for(n=[],t=0,i=s.items.length;t<i;t++)o=s.options[s.items[t]][s.settings.labelField]||"",n.push('<option value="'+h(s.items[t])+'" selected="selected">'+h(o)+"</option>");n.length||this.input.hasAttribute("multiple")||n.push('<option value="" selected="selected"></option>'),s.input.innerHTML=n.join("")}else s.input.value=s.getValue(),s.input.setAttribute("value",s.input.value);s.isSetup&&(e.silent||s.trigger("change",s.input.value))}},{key:"open",value:function(){var e=this;e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.focus(),e.isOpen=!0,e.refreshState(),v(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),v(e.dropdown,{visibility:"visible",display:"block"}),e.trigger("dropdown_open",e.dropdown))}},{key:"close",value:function(){var e=this,t=e.isOpen;"single"===e.settings.mode&&e.items.length&&(e.hideInput(),e.isBlurring||e.blur()),e.isOpen=!1,v(e.dropdown,{display:"none"}),e.setActiveOption(null),e.refreshState(),t&&e.trigger("dropdown_close",e.dropdown)}},{key:"positionDropdown",value:function(){var e,t,i,n;"body"===this.settings.dropdownParent&&(t=(e=this.control).getBoundingClientRect(),i=e.offsetHeight+t.top+window.scrollY,n=t.left+window.scrollX,v(this.dropdown,{width:t.width+"px",top:i+"px",left:n+"px"}))}},{key:"clear",value:function(e){if(this.items.length){for(var t=this.controlChildren(),i=0;i<t.length;i++)t[i].remove();this.items=[],this.lastQuery=null,this.setCaret(0),this.setActiveItem(null),this.updateOriginalInput({silent:e}),this.refreshState(),this.showInput(),this.trigger("clear")}}},{key:"insertAtCaret",value:function(e){var t=Math.min(this.caretPos,this.items.length),i=this.buffer||this.control;0===t?i.insertBefore(e,i.firstChild):i.insertBefore(e,i.children[t]),this.setCaret(t+1)}},{key:"deleteSelection",value:function(e){var t,i,n,o,s,r=this,a=e&&8===e.keyCode?-1:1,l={start:(s=r.control_input).selectionStart,length:s.selectionEnd-s.selectionStart},u=[];if(r.activeItems.length){for(o=I(r.activeItems,a),n=m(o),0<a&&n++,t=0,i=r.activeItems.length;t<i;t++)u.push(r.activeItems[t].dataset.value);e&&(e.preventDefault(),e.stopPropagation())}else(r.isFocused||"single"===r.settings.mode)&&r.items.length&&(a<0&&0===l.start&&0===l.length?u.push(r.items[r.caretPos-1]):0<a&&l.start===r.inputValue().length&&u.push(r.items[r.caretPos]));if(!u.length||"function"==typeof r.settings.onDelete&&!1===r.settings.onDelete.apply(r,[u,e]))return!1;for(void 0!==n&&r.setCaret(n);u.length;)r.removeItem(u.pop());return r.showInput(),r.positionDropdown(),r.refreshOptions(!1),!0}},{key:"advanceSelection",value:function(e,t){var i,n,o;0!==e&&(this.rtl&&(e*=-1),this.isKeyDown(17,t)||this.isKeyDown(16,t)?(n=this.getLastActive(e),(o=this.getAdjacent(n,e,"item"))&&(o.classList.contains("active")&&this.removeActiveItem(n),this.setActiveItemClass(o))):this.isFocused&&!this.isInputHidden?this.inputValue().length||this.setCaret(this.caretPos+e):(n=this.getLastActive(e))&&(i=m(n),this.setCaret(0<e?i+1:i),this.setActiveItem(null)))}},{key:"getLastActive",value:function(e){var t=this.control.querySelector(".last-active");return t||function(e,t,i){var n=e.querySelectorAll(t);if(n)return I(n,i)}(this.control,".active",e)}},{key:"setCaret",value:function(e){var t=this;if(e="single"===t.settings.mode||t.settings.controlInput?t.items.length:Math.max(0,Math.min(t.items.length,e)),!t.settings.controlInput&&!t.isPending)for(var i,n=this.controlChildren(),o=n.length,s=0;s<o;s++)i=n[s],s<e?t.control_input.insertAdjacentElement("beforebegin",i):t.control.appendChild(i);t.caretPos=e}},{key:"controlChildren",value:function(){return Array.prototype.filter.call(this.control.children,function(e){return"INPUT"!==e.nodeName})}},{key:"lock",value:function(){this.close(),this.isLocked=!0,this.refreshState()}},{key:"unlock",value:function(){this.isLocked=!1,this.refreshState()}},{key:"disable",value:function(){this.input.disabled=!0,this.control_input.disabled=!0,this.control_input.tabIndex=-1,this.isDisabled=!0,this.lock()}},{key:"enable",value:function(){this.input.disabled=!1,this.control_input.disabled=!1,this.control_input.tabIndex=this.tabIndex,this.isDisabled=!1,this.unlock()}},{key:"destroy",value:function(){var e=this.revertSettings;this.trigger("destroy"),this.off(),this.wrapper.remove(),this.dropdown.remove(),this.input.innerHTML="",e.tabindex?this.input.setAttribute("tabindex",e.tabindex):this.input.removeAttribute("tabindex"),F(this.input,"tomselected"),this.input.removeAttribute("hidden");for(var t=0;t<e.children.length;t++)this.input.appendChild(e.children[t]);this._destroy(),delete this.input.tomselect}},{key:"render",value:function(e,t){var i,n,o="",s=this;return"option"!==e&&"item"!==e||(i=D(t[s.settings.valueField]),!s.renderCache[e].hasOwnProperty(i))?(o=k(s.settings.render[e].apply(this,[t,h])),"option"===e||"option_create"===e?t[s.settings.disabledField]||o.setAttribute("data-selectable",""):"optgroup"===e&&(n=t.group[s.settings.optgroupValueField],o.setAttribute("data-group",n),t.group[s.settings.disabledField]&&o.setAttribute("data-disabled","")),"option"!==e&&"item"!==e||(o.setAttribute("data-value",i),x(o,"item"===e?s.settings.itemClass:s.settings.optionClass),s.renderCache[e][i]=o),o):s.renderCache[e][i]}},{key:"clearCache",value:function(e){void 0===e?this.renderCache={item:{},option:{}}:this.renderCache[e]={}}},{key:"canCreate",value:function(e){if(!this.settings.create)return!1;var t=this.settings.createFilter;return e.length&&("function"!=typeof t||t.call(this,e))&&(!(t instanceof RegExp)||t.test(e))}},{key:"isKeyDown",value:function(e,t){return!!t&&(!t.altKey&&((!t.ctrlKey||!t.shiftKey)&&(!(17!=e||!t.ctrlKey)||!(16!=e||!t.shiftKey))))}},{key:"hook",value:function(i,e,n){var o=this,s=o[e];o[e]=function(){var e,t;return"after"===i&&(e=s.apply(o,arguments)),t=n.apply(o,arguments),"instead"===i?t:("before"===i&&(e=s.apply(o,arguments)),e)}}}])&&n(e.prototype,t),i&&n(e,i),r}();if(void 0===e)throw'Dependency MicroPlugin is missing. Make sure you either: (1) are using the "complete" version of Tom Select, or (2) require MicroPlugin before you load Tom Select.';return e.mixin(A),A.count=0,A.defaults={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:!1,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,maxOptions:50,maxItems:null,hideSelected:null,duplicates:!1,addPrecedence:!1,selectOnTab:!1,preload:!1,allowEmptyOption:!1,closeAfterSelect:!1,scrollDuration:60,loadThrottle:300,loadingClass:"loading",dataAttr:null,optgroupField:"optgroup",valueField:"value",labelField:"text",disabledField:"disabled",optgroupLabelField:"label",optgroupValueField:"value",lockOptgroupOrder:!1,sortField:"$order",searchField:["text"],searchConjunction:"and",mode:null,wrapperClass:"ts-control",inputClass:"ts-input",dropdownClass:"ts-dropdown",dropdownContentClass:"ts-dropdown-content",itemClass:"item",optionClass:"option",dropdownParent:null,controlInput:null,copyClassesToDropdown:!0,render:{}},A.define("change_listener",function(e){var t=this,i=!1;t.input.addEventListener("change",function(){var e;i?i=!1:(i=!0,e=y(t.input,{}),t.setupOptions(e.options,e.optgroups),t.setValue(e.items))})}),A.define("drag_drop",function(e){if(!$.fn.sortable)throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');var t,i,n;"multi"===this.settings.mode&&(i=(t=this).lock,n=t.unlock,t.hook("instead","lock",function(){var e=t.control.dataset.sortable;return e&&e.disable(),i.apply(t,arguments)}),t.hook("instead","unlock",function(){var e=t.control.dataset.sortable;return e&&e.enable(),n.apply(t,arguments)}),t.hook("after","setup",function(){var i=$(t.control).sortable({items:"[data-value]",forcePlaceholderSize:!0,disabled:t.isLocked,start:function(e,t){t.placeholder.css("width",t.helper.css("width")),i.css({overflow:"visible"})},stop:function(){i.css({overflow:"hidden"});var e=[];i.children("[data-value]").each(function(){e.push($(this).attr("data-value"))}),t.setValue(e)}})}))}),A.define("dropdown_header",function(t){var i=this;t=Object.assign({title:"Untitled",headerClass:"dropdown-header",titleRowClass:"dropdown-header-title",labelClass:"dropdown-header-label",closeClass:"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>'}},t),i.hook("after","setup",function(){var e=k(t.html(t));i.dropdown.insertBefore(e,i.dropdown.firstChild)})}),A.define("input_autogrow",function(e){var a=this;a.hook("after","setup",function(){var e=document.createElement("span"),t=this.control_input;e.style.position="absolute",e.style.top="-99999px",e.style.left="-99999px",e.style.width="auto",e.style.padding=0,e.style.whiteSpace="pre",a.wrapper.appendChild(e);for(var i=["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"],n=0,o=i.length;n<o;n++){var s=i[n];e.style[s]=t.style[s]}function r(){e.textContent=t.value,t.style.width=e.clientWidth+"px"}t.addEventListener("input",r),t.addEventListener("keyup",r),t.addEventListener("blur",r),t.addEventListener("update",r)})}),A.define("no_backspace_delete",function(e){this.hook("instead","setActiveItem",function(){}),this.hook("instead","selectAll",function(){}),this.hook("instead","deleteSelection",function(){})}),A.define("optgroup_columns",function(e){var s=this,r=s.onKeyDown;s.hook("instead","onKeyDown",function(e){var t,i,n,o;return!s.isOpen||37!==e.keyCode&&39!==e.keyCode?r.apply(s,arguments):(s.ignoreHover=!0,o=C(s.activeOption,"[data-group]"),t=m(s.activeOption,"[data-selectable]"),void((o=37===e.keyCode?o.previousSibling:o.nextSibling)&&(i=(n=o.querySelectorAll("[data-selectable]"))[Math.min(n.length-1,t)])&&s.setActiveOption(i)))})}),A.define("remove_button",function(e){e=Object.assign({label:"×",title:"Remove",className:"remove",append:!0},e);var n,o=this;e.append&&(n='<a href="javascript:void(0)" class="'+e.className+'" tabindex="-1" title="'+h(e.title)+'">'+e.label+"</a>",o.hook("after","setupTemplates",function(){var t=o.settings.render.item;o.settings.render.item=function(){var i=k(t.apply(o,arguments)),e=k(n);return i.appendChild(e),e.addEventListener("mousedown",function(e){e.preventDefault(),e.stopPropagation()}),e.addEventListener("click",function(e){var t;e.preventDefault(),e.stopPropagation(),"single"!==o.settings.mode&&e.stopPropagation(),o.isLocked||(t=i.dataset.value,o.removeItem(t),o.refreshOptions(!1))}),i}}))}),A.define("restore_on_backspace",function(n){var o=this;n.text=n.text||function(e){return e[o.settings.labelField]};var s=o.onKeyDown;o.hook("instead","onKeyDown",function(e){var t,i;return 8===e.keyCode&&""===o.control_input.value&&!o.activeItems.length&&0<=(t=o.caretPos-1)&&t<o.items.length?(i=o.options[o.items[t]],o.deleteSelection(e)&&(o.setTextboxValue(n.text.call(o,i)),o.refreshOptions(!0)),void e.preventDefault()):s.apply(o,arguments)})}),A});var tomSelect=function(e,t){return new TomSelect(e,t)}; |
@@ -19,12 +19,12 @@ --- | ||
```shell | ||
$ yarn test | ||
$ npm test | ||
``` | ||
### Local environment | ||
Runing ```yarn start``` on your repo will start a web server allowing you to view a local copy of tom-select.js.org. | ||
Runing ```npm start``` on your repo will start a web server allowing you to view a local copy of tom-select.js.org. | ||
```shell | ||
$ yarn start | ||
$ npm start | ||
``` | ||
Once started, you can run all the examples at `http://localhost:8000/`. |
@@ -5,7 +5,8 @@ | ||
<a href="https://github.com/orchidjs/tom-select" class="m-1 d-inline-block"><img alt="GitHub forks" src="https://img.shields.io/github/forks/orchidjs/tom-select?label=Github%20forks&style=for-the-badge&color=007ec6"></a> | ||
<a href="https://www.npmjs.com/package/tom-select" class="m-1 d-inline-block"><img alt="npmjs.org" style="height:28px" src="https://img.shields.io/npm/v/tom-select.svg?style=for-the-badge&color=007ec6"></a> | ||
<a href="https://travis-ci.org/orchidjs/tom-select" class="m-1 d-inline-block"><img alt="Travis.org" style="height:28px" src="https://img.shields.io/travis/orchidjs/tom-select?style=for-the-badge"></a> | ||
<a href="https://coveralls.io/github/orchidjs/tom-select" class="m-1 d-inline-block"><img alt="Coveralls Coverage" style="height:28px" src="https://img.shields.io/coveralls/github/orchidjs/tom-select?color=4c1&style=for-the-badge"></a> | ||
<a href="https://github.com/orchidjs/tom-select/issues" class="m-1 d-inline-block"><img alt="GitHub Issues" style="height:28px" src="https://img.shields.io/github/issues/orchidjs/tom-select?style=for-the-badge"></a> | ||
<a href="https://github.com/orchidjs/tom-select" class="m-1 d-inline-block"><img alt="GitHub forks" src="https://img.shields.io/github/forks/orchidjs/tom-select?label=Github%20forks&style=&color=007ec6"></a> | ||
<a href="https://www.npmjs.com/package/tom-select" class="m-1 d-inline-block"><img alt="npmjs.org" src="https://img.shields.io/npm/v/tom-select.svg?style=&color=007ec6"></a> | ||
<a href="https://travis-ci.org/orchidjs/tom-select" class="m-1 d-inline-block"><img alt="Travis.org" src="https://img.shields.io/travis/orchidjs/tom-select?style="></a> | ||
<a href="https://coveralls.io/github/orchidjs/tom-select" class="m-1 d-inline-block"><img alt="Coveralls Coverage" src="https://img.shields.io/coveralls/github/orchidjs/tom-select?color=4c1&style="></a> | ||
<a href="https://github.com/orchidjs/tom-select/issues" class="m-1 d-inline-block"><img alt="GitHub Issues" src="https://img.shields.io/github/issues/orchidjs/tom-select?style="></a> | ||
<a href="https://automate.browserstack.com/public-build/QXZ2Z2JUaUlSV2REcHRZYzIzQThxemRnNXNQZ0c3Lzh3d01FWE4vSk1oMD0tLVFFTGlUdmxaMWNIL3hCTUJXZk1qanc9PQ==--f7c82c941ca5c14a22f826b97bc02da17c071d5e"><img src='https://automate.browserstack.com/badge.svg?badge_key=QXZ2Z2JUaUlSV2REcHRZYzIzQThxemRnNXNQZ0c3Lzh3d01FWE4vSk1oMD0tLVFFTGlUdmxaMWNIL3hCTUJXZk1qanc9PQ==--f7c82c941ca5c14a22f826b97bc02da17c071d5e'/></a> | ||
</div> | ||
@@ -62,23 +63,24 @@ | ||
<script> | ||
var options = {}; | ||
tomSelect('#tom-select-it',options); | ||
var config = {}; | ||
tomSelect('#tom-select-it',config); | ||
</script> | ||
``` | ||
The available options are [documented here](docs). | ||
Available configuration settings are [documented here](docs) | ||
## Installation and files | ||
## Installation | ||
All pre-built files needed to use Tom Select can be found in the ["dist"](https://github.com/orchidjs/tom-select/tree/master/dist) folder | ||
All pre-built files needed to use Tom Select can be found in the "dist" folder from each of these sources: | ||
<!--and at [cdnjs](https://cdnjs.com/libraries/selectize.js). --> | ||
- ```npm i tom-select``` | ||
- [GitHub](https://github.com/orchidjs/tom-select/tree/master/dist) | ||
- [jsDelivr](https://www.jsdelivr.com/package/npm/tom-select?path=dist) | ||
- [**JavaScript**](https://github.com/orchidjs/tom-select/tree/master/dist/js) | ||
- [tom-select.complete.js](https://github.com/orchidjs/tom-select/tree/master/dist/js/tom-select.complete.js) — Includes dependencies and plugins | ||
- [tom-select.js](https://github.com/orchidjs/tom-select/tree/master/dist/js/tom-select.js) — Does not include sifter or microplugin | ||
- **Themes** | ||
- [CSS](https://github.com/orchidjs/tom-select/tree/master/dist/css) — Compiled themes | ||
- [SCSS](https://github.com/orchidjs/tom-select/tree/master/dist/scss) — Uncompiled theme sources | ||
## Files | ||
- [tom-select.complete.js](https://github.com/orchidjs/tom-select/tree/master/dist/js/tom-select.complete.js) — Includes dependencies and plugins | ||
- [tom-select.js](https://github.com/orchidjs/tom-select/tree/master/dist/js/tom-select.js) — Does not include sifter or microplugin | ||
- [CSS](https://github.com/orchidjs/tom-select/tree/master/dist/css) — Compiled themes | ||
- [SCSS](https://github.com/orchidjs/tom-select/tree/master/dist/scss) — Uncompiled theme sources | ||
@@ -92,3 +94,3 @@ | ||
# dependencies | ||
yarn install --production=false | ||
npm install | ||
@@ -95,0 +97,0 @@ # build tom-select |
@@ -9,8 +9,10 @@ var fs = require('fs'); | ||
grunt.loadNpmTasks('grunt-contrib-copy'); | ||
grunt.loadNpmTasks('grunt-contrib-sass'); | ||
grunt.loadNpmTasks('grunt-contrib-watch'); | ||
grunt.loadNpmTasks('grunt-replace'); | ||
require('load-grunt-tasks')(grunt); //babel | ||
const sass = require('node-sass'); | ||
require('load-grunt-tasks')(grunt); //babel, sass | ||
grunt.registerTask('default', [ | ||
@@ -140,3 +142,4 @@ 'clean:pre', | ||
var files_js = [ | ||
'src/contrib/*.js', | ||
'src/contrib/highlight.js', | ||
'src/contrib/microevent.js', | ||
'src/*.js', | ||
@@ -151,3 +154,3 @@ '!src/.wrapper.js', | ||
var files_js_dependencies = [ | ||
'node_modules/sifter/sifter.js', | ||
'src/contrib/sifter.js', | ||
'node_modules/microplugin/src/microplugin.js', | ||
@@ -245,2 +248,3 @@ ]; | ||
options:{ | ||
implementation: sass, | ||
style:'expanded', | ||
@@ -247,0 +251,0 @@ }, |
module.exports = function(config) { | ||
// workaround for https://github.com/karma-runner/karma-sauce-launcher/issues/40 | ||
var saucelabsBatchID = Number(process.env.SAUCELABS_BATCH) - 1; | ||
var saucelabsConcurrency = 4; | ||
var saucelabsBrowsers = [ | ||
// mobile | ||
{platform: 'OS X 10.10', browserName: 'iPhone', version: '8.1'}, | ||
//{platform: 'OS X 10.10 ', browserName: 'iPhone', version: '6.0'}, | ||
{platform: 'OS X 10.10', browserName: 'iPad', version: '8.1'}, | ||
//{platform: 'OS X 10.10', browserName: 'iPad', version: '6.0'}, | ||
{platform: 'Linux', browserName: 'android', version: '4.4'}, | ||
{platform: 'Linux', browserName: 'android', version: '4.3'}, | ||
// desktop (safari) | ||
{platform: 'OS X 10.8', browserName: 'safari', version: 6}, | ||
{platform: 'OS X 10.9', browserName: 'safari', version: 7}, | ||
{platform: 'OS X 10.10', browserName: 'safari', version: 8}, | ||
// desktop (chrome) | ||
{platform: 'OS X 10.10', browserName: 'chrome', version: 39}, | ||
{platform: 'OS X 10.10', browserName: 'chrome', version: 38}, | ||
{platform: 'OS X 10.10', browserName: 'chrome', version: 37}, | ||
{platform: 'Windows 7', browserName: 'chrome', version: 39}, | ||
{platform: 'Windows 7', browserName: 'chrome', version: 38}, | ||
{platform: 'Windows 7', browserName: 'chrome', version: 37}, | ||
// desktop (firefox) | ||
{platform: 'Windows 7', browserName: 'firefox', version: 35}, | ||
{platform: 'Windows 8', browserName: 'firefox', version: 35}, | ||
{platform: 'OS X 10.10', browserName: 'firefox', version: 34}, | ||
{platform: 'OS X 10.10', browserName: 'firefox', version: 33}, | ||
{platform: 'OS X 10.10', browserName: 'firefox', version: 32}, | ||
// desktop (internet explorer) | ||
{platform: 'Windows 8', browserName: 'iexplore', version: 10}, | ||
{platform: 'Windows 8.1', browserName: 'iexplore', version: 11}, | ||
{platform: 'Windows 7', browserName: 'iexplore', version: 9} | ||
]; | ||
var customLaunchers = {}; | ||
if (process.env.TARGET === 'saucelabs') { | ||
saucelabsBrowsers = saucelabsBrowsers.slice(saucelabsBatchID * saucelabsConcurrency, saucelabsBatchID * saucelabsConcurrency + saucelabsConcurrency); | ||
if (!saucelabsBrowsers.length) process.exit(0); | ||
} | ||
if (process.env.TARGET === 'browserstack') { | ||
var customLaunchers = {}; | ||
saucelabsBrowsers.forEach(function(browser, i) { | ||
browser.base = 'SauceLabs'; | ||
customLaunchers['SL_' + i] = browser; | ||
}); | ||
// define browsers | ||
// https://www.browserstack.com/automate/capabilities | ||
customLaunchers = { | ||
customLaunchers['HeadlessFirefox'] = { | ||
base: 'Firefox', | ||
flags: [ | ||
'-headless', | ||
] | ||
}; | ||
// ios | ||
bs_ios_ffox:{ | ||
base: 'BrowserStack', | ||
os : 'OS X', | ||
os_version : 'Catalina', | ||
browser : 'Firefox', | ||
browser_version : 'latest', | ||
}, | ||
customLaunchers['HeadlessChrome'] = { | ||
base: 'ChromeHeadless', | ||
flags: [ | ||
'--disable-translate', | ||
'--disable-extensions', | ||
'--remote-debugging-port=9223' | ||
] | ||
}; | ||
bs_ios_safari13:{ | ||
base: 'BrowserStack', | ||
os : 'OS X', | ||
os_version : 'Catalina', | ||
browser : 'Safari', | ||
browser_version : 'latest', | ||
}, | ||
bs_ios_safari12:{ | ||
base: 'BrowserStack', | ||
os : 'OS X', | ||
os_version : 'Mojave', | ||
browser : 'Safari', | ||
browser_version : 'latest', | ||
}, | ||
bs_ios_safari11:{ | ||
base: 'BrowserStack', | ||
os : 'OS X', | ||
os_version : 'High Sierra', | ||
browser : 'Safari', | ||
browser_version : 'latest', | ||
}, | ||
iphone11:{ | ||
base: 'BrowserStack', | ||
os: 'iOS', | ||
os_version: '14', | ||
device: 'iPhone 11', | ||
browser: 'iPhone', | ||
real_mobile: 'true', | ||
}, | ||
// win | ||
bs_win10_edge:{ | ||
base: 'BrowserStack', | ||
os : 'Windows', | ||
os_version : '10', | ||
browser : 'Edge', | ||
browser_version : 'latest', | ||
}, | ||
bs_win8_edge:{ | ||
base: 'BrowserStack', | ||
os : 'Windows', | ||
os_version : '8.1', | ||
browser : 'Edge', | ||
browser_version : '80', | ||
}, | ||
bs_win7_edge:{ | ||
base: 'BrowserStack', | ||
os : 'Windows', | ||
os_version : '7', | ||
browser : 'Edge', | ||
browser_version : '80.0', | ||
}, | ||
// android | ||
bs_android:{ | ||
base: 'BrowserStack', | ||
os : 'Android', | ||
os_version : '10.0', | ||
device : 'Samsung Galaxy S20', | ||
real_mobile : 'true', | ||
browser : 'Android', | ||
}, | ||
}; | ||
}else{ | ||
customLaunchers['HeadlessFirefox'] = { | ||
base: 'Firefox', | ||
flags: [ | ||
'-headless', | ||
] | ||
}; | ||
customLaunchers['HeadlessChrome'] = { | ||
base: 'ChromeHeadless', | ||
flags: [ | ||
'--disable-translate', | ||
'--disable-extensions', | ||
'--remote-debugging-port=9223' | ||
] | ||
}; | ||
} | ||
var targets = { | ||
'saucelabs': Object.keys(customLaunchers), | ||
'browserstack': Object.keys(customLaunchers), | ||
'HeadlessFirefox': ['HeadlessFirefox'], | ||
@@ -72,22 +118,17 @@ 'HeadlessChrome': ['HeadlessChrome'] | ||
if( process.env.TRAVIS_CI ){ | ||
if( process.env.TARGET === 'saucelabs' ){ | ||
reporters = ['saucelabs', 'mocha'] | ||
}else{ | ||
reporters = ['mocha', 'coverage', 'coveralls'] | ||
} | ||
reporters = ['mocha', 'coverage', 'coveralls'] | ||
} | ||
var browsers = targets[process.env.TARGET || 'HeadlessFirefox']; | ||
if (process.env.BROWSERS) { | ||
if( process.env.BROWSERS ){ | ||
browsers = process.env.BROWSERS.split(','); | ||
} | ||
config.set({ | ||
frameworks: ['mocha', 'chai'], | ||
files: [ | ||
//'build/css/tom-select.default.css', | ||
'build/css/tom-select.default.css', | ||
'node_modules/jquery/dist/jquery.js', | ||
'node_modules/microplugin/src/microplugin.js', | ||
'node_modules/sifter/sifter.js', | ||
'node_modules/syn/dist/global/syn.js', | ||
@@ -112,3 +153,2 @@ 'test/support/*.js', | ||
preprocessors: { | ||
'src/**/*.js': ['coverage'], | ||
'src/*.js': ['coverage'] | ||
@@ -120,22 +160,15 @@ }, | ||
}, | ||
sauceLabs: { | ||
recordVideo: false, | ||
startConnect: true, | ||
browserStack: { | ||
tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER, | ||
build: process.env.TRAVIS_BUILD_NUMBER, | ||
testName: process.env.COMMIT_MESSAGE, | ||
tags: ['tom-select', 'test'] | ||
project: process.env.TRAVIS_CI ? 'tom-select': '', | ||
name: process.env.TRAVIS_CI ? 'tom-select': '', | ||
}, | ||
customLaunchers: customLaunchers, | ||
reporters: reporters, | ||
port: 8888, | ||
colors: true, | ||
captureTimeout: 0, | ||
logLevel: config.LOG_INFO, | ||
browsers: browsers, | ||
browserDisconnectTolerance: 2, | ||
browserDisconnectTimeout: 10000, | ||
browserNoActivityTimeout: 120000, | ||
singleRun: true | ||
}); | ||
}; |
@@ -16,3 +16,3 @@ { | ||
"homepage": "https://tom-select.js.org", | ||
"version": "1.0.0-b.3", | ||
"version": "1.0.0-rc.1", | ||
"author": "Josh Schmidt (https://github.com/oyejorge)", | ||
@@ -28,4 +28,3 @@ "contributors": [ | ||
"dependencies": { | ||
"microplugin": "0.0.3", | ||
"sifter": "^0.5.4" | ||
"microplugin": "0.0.3" | ||
}, | ||
@@ -50,3 +49,2 @@ "devDependencies": { | ||
"grunt-contrib-copy": "^1.0.0", | ||
"grunt-contrib-sass": "^2.0.0", | ||
"grunt-contrib-uglify": "^5.0.0", | ||
@@ -56,5 +54,7 @@ "grunt-contrib-watch": "1.x", | ||
"grunt-replace": "^1.0.1", | ||
"grunt-sass": "^3.1.0", | ||
"grunt-shell": "^3.0.1", | ||
"jquery": "^3.5.1", | ||
"karma": "^5.1.1", | ||
"karma-browserstack-launcher": "^1.6.0", | ||
"karma-chai": "^0.1.0", | ||
@@ -68,6 +68,6 @@ "karma-chrome-launcher": "^3.1.0", | ||
"karma-safari-launcher": "^1.0.0", | ||
"karma-sauce-launcher": "^4.1.5", | ||
"load-grunt-tasks": "^5.1.0", | ||
"markdown-it-anchor": "^5.3.0", | ||
"mocha": "^8.1.1", | ||
"node-sass": "^4.14.1", | ||
"syn": "^0.15.0" | ||
@@ -74,0 +74,0 @@ }, |
@@ -6,8 +6,8 @@ <p align="center"> | ||
<p align="center"> | ||
<a href="https://github.com/orchidjs/tom-select"><img alt="GitHub forks" src="https://img.shields.io/github/forks/orchidjs/tom-select?label=Github%20forks&style=for-the-badge&color=007ec6"></a> | ||
<a href="https://www.npmjs.com/package/tom-select"><img alt="npmjs.org" style="height:28px" src="https://img.shields.io/npm/v/tom-select.svg?style=for-the-badge&color=007ec6"></a> | ||
<a href="https://travis-ci.org/orchidjs/tom-select"><img alt="Travis.org" style="height:28px" src="https://img.shields.io/travis/orchidjs/tom-select?style=for-the-badge"></a> | ||
<a href="https://coveralls.io/github/orchidjs/tom-select"><img alt="Coveralls Coverage" style="height:28px" src="https://img.shields.io/coveralls/github/orchidjs/tom-select?color=4c1&style=for-the-badge"></a> | ||
<a href="https://github.com/orchidjs/tom-select/issues"><img alt="GitHub Issues" style="height:28px" src="https://img.shields.io/github/issues/orchidjs/tom-select?style=for-the-badge"></a> | ||
</p> | ||
<a href="https://github.com/orchidjs/tom-select" class="m-1 d-inline-block"><img alt="GitHub forks" src="https://img.shields.io/github/forks/orchidjs/tom-select?label=Github%20forks&style=&color=007ec6"></a> | ||
<a href="https://www.npmjs.com/package/tom-select" class="m-1 d-inline-block"><img alt="npmjs.org" src="https://img.shields.io/npm/v/tom-select.svg?style=&color=007ec6"></a> | ||
<a href="https://travis-ci.org/orchidjs/tom-select" class="m-1 d-inline-block"><img alt="Travis.org" src="https://img.shields.io/travis/orchidjs/tom-select?style="></a> | ||
<a href="https://coveralls.io/github/orchidjs/tom-select" class="m-1 d-inline-block"><img alt="Coveralls Coverage" src="https://img.shields.io/coveralls/github/orchidjs/tom-select?color=4c1&style="></a> | ||
<a href="https://github.com/orchidjs/tom-select/issues" class="m-1 d-inline-block"><img alt="GitHub Issues" src="https://img.shields.io/github/issues/orchidjs/tom-select?style="></a> | ||
<a href="https://automate.browserstack.com/public-build/QXZ2Z2JUaUlSV2REcHRZYzIzQThxemRnNXNQZ0c3Lzh3d01FWE4vSk1oMD0tLVFFTGlUdmxaMWNIL3hCTUJXZk1qanc9PQ==--f7c82c941ca5c14a22f826b97bc02da17c071d5e"><img src='https://automate.browserstack.com/badge.svg?badge_key=QXZ2Z2JUaUlSV2REcHRZYzIzQThxemRnNXNQZ0c3Lzh3d01FWE4vSk1oMD0tLVFFTGlUdmxaMWNIL3hCTUJXZk1qanc9PQ==--f7c82c941ca5c14a22f826b97bc02da17c071d5e'/></a></p> | ||
@@ -19,6 +19,3 @@ | ||
### Browser Support | ||
[![Sauce Test Status](https://saucelabs.com/browser-matrix/tom-select.svg)](https://saucelabs.com/u/tom-select) (coming soon) | ||
### Features | ||
@@ -48,19 +45,21 @@ | ||
The available options are [documented here](https://tom-select.js.org/docs). | ||
Available configuration settings are [documented here](https://tom-select.js.org/docs) | ||
## Installation and files | ||
## Installation | ||
All pre-built files needed to use Tom Select can be found in the ["dist"](https://github.com/orchidjs/tom-select/tree/master/dist) folder | ||
All pre-built files needed to use Tom Select can be found in the "dist" folder via any of these sources: | ||
<!--and at [cdnjs](https://cdnjs.com/libraries/selectize.js). --> | ||
- ```npm i tom-select``` | ||
- [GitHub](https://github.com/orchidjs/tom-select/tree/master/dist) | ||
- [jsDelivr](https://www.jsdelivr.com/package/npm/tom-select?path=dist) | ||
- [**JavaScript**](https://github.com/orchidjs/tom-select/tree/master/dist/js) | ||
- [tom-select.complete.js](https://github.com/orchidjs/tom-select/tree/master/dist/js/tom-select.complete.js) — Includes dependencies and plugins | ||
- [tom-select.js](https://github.com/orchidjs/tom-select/tree/master/dist/js/tom-select.js) — Does not include sifter or microplugin | ||
- **Themes** | ||
- [CSS](https://github.com/orchidjs/tom-select/tree/master/dist/css) — Compiled themes | ||
- [SCSS](https://github.com/orchidjs/tom-select/tree/master/dist/scss) — Uncompiled theme sources | ||
## Files | ||
- [tom-select.complete.js](https://github.com/orchidjs/tom-select/tree/master/dist/js/tom-select.complete.js) — Includes dependencies and plugins | ||
- [tom-select.js](https://github.com/orchidjs/tom-select/tree/master/dist/js/tom-select.js) — Does not include sifter or microplugin | ||
- [CSS](https://github.com/orchidjs/tom-select/tree/master/dist/css) — Compiled themes | ||
- [SCSS](https://github.com/orchidjs/tom-select/tree/master/dist/scss) — Uncompiled theme sources | ||
## License | ||
@@ -67,0 +66,0 @@ |
@@ -1,3 +0,1 @@ | ||
const IS_MAC = /Mac/.test(navigator.userAgent); | ||
const KEY_A = 65; | ||
@@ -14,5 +12,3 @@ const KEY_COMMA = 188; | ||
const KEY_SHIFT = 16; | ||
const KEY_CTRL = IS_MAC ? 18 : 17; | ||
const KEY_CTRL = 17; | ||
const KEY_TAB = 9; | ||
const KEY_CTRL_NAME = IS_MAC ? 'metaKey' : 'ctrlKey'; |
@@ -2452,7 +2452,7 @@ | ||
// if [ctrl+shift], return false | ||
if( evt[KEY_CTRL_NAME] && evt.shiftKey ){ | ||
if( evt.ctrlKey && evt.shiftKey ){ | ||
return false; | ||
} | ||
if( key_code == KEY_CTRL && evt[KEY_CTRL_NAME] ){ | ||
if( key_code == KEY_CTRL && evt.ctrlKey ){ | ||
return true; | ||
@@ -2459,0 +2459,0 @@ } |
@@ -869,2 +869,19 @@ | ||
let keys = ['shift','ctrl','alt']; | ||
for( key in keys){ | ||
key = keys[key]; | ||
syn.type('['+key+']', test.instance.control_input, function(evt) { | ||
console.log('key press',key,'keycode',last_keydown.keyCode); | ||
console.log('shiftKey',last_keydown.shiftKey); | ||
console.log('ctrlKey',last_keydown.ctrlKey); | ||
console.log('altKey',last_keydown.altKey); | ||
console.log('metaKey',last_keydown.metaKey); | ||
syn.type('['+key+'-up]', test.instance.control_input); | ||
}); | ||
} | ||
it_n('should return false if [alt] is pressed', function() { | ||
@@ -871,0 +888,0 @@ syn.type('[alt]', test.instance.control_input, function(evt) { |
@@ -191,3 +191,3 @@ | ||
var optgroup = parentMatch(test.instance.activeOption,'[data-group]'); | ||
var optgroup = test.instance.activeOption.parentNode; | ||
expect(optgroup.dataset.group).to.be.equal('audi'); | ||
@@ -198,3 +198,3 @@ | ||
var optgroup = parentMatch(test.instance.activeOption,'[data-group]'); | ||
var optgroup = test.instance.activeOption.parentNode; | ||
expect(optgroup.dataset.group).to.be.equal('chevrolet'); | ||
@@ -201,0 +201,0 @@ |
@@ -84,12 +84,14 @@ (function() { | ||
describe('<input type="number">', function() { | ||
it_n('should complete without exceptions', function(done) { | ||
var test = setup_test('<input type="number">', {}); | ||
window.setTimeout(function() { | ||
assert.equal(test.instance.control_input.getAttribute('type'), 'number'); | ||
done(); | ||
}, 0); | ||
assert.equal(test.instance.control_input.getAttribute('type'), 'number'); | ||
done(); | ||
}); | ||
}); | ||
describe('<select>', function() { | ||
@@ -234,10 +236,10 @@ it_n('should complete without exceptions', function() { | ||
test.instance.refreshOptions(true); | ||
window.setTimeout(function() { | ||
$(test.instance.dropdown).find('[data-value]').each(function(i, el) { | ||
order_actual.push($(el).attr('data-value')); | ||
}); | ||
expect(order_actual).to.eql(order_expected); | ||
done(); | ||
}, 0); | ||
$(test.instance.dropdown).find('[data-value]').each(function(i, el) { | ||
order_actual.push($(el).attr('data-value')); | ||
}); | ||
expect(order_actual).to.eql(order_expected); | ||
done(); | ||
}); | ||
@@ -251,7 +253,7 @@ it_n('should respect option disabled flag', function (done) { | ||
test.instance.refreshOptions(true); | ||
window.setTimeout(function() { | ||
expect($(test.instance.dropdown).find('.option')).to.has.length(2); | ||
expect($(test.instance.dropdown).find('[data-selectable]')).to.has.length(1); | ||
done(); | ||
}, 0); | ||
expect($(test.instance.dropdown).find('.option')).to.has.length(2); | ||
expect($(test.instance.dropdown).find('[data-selectable]')).to.has.length(1); | ||
done(); | ||
}); | ||
@@ -348,7 +350,5 @@ describe('getValue()', function() { | ||
window.setTimeout(function() { | ||
expect(test.instance.control.classList.contains('invalid')). | ||
to.be.true; | ||
done(); | ||
}, 250); | ||
expect(test.instance.control.classList.contains('invalid')).to.be.true; | ||
done(); | ||
}); | ||
@@ -444,3 +444,3 @@ | ||
done(); | ||
}, 0); | ||
}, 5); | ||
}); | ||
@@ -471,3 +471,3 @@ }); | ||
done(); | ||
}, 0); | ||
}, 5); | ||
}); | ||
@@ -531,4 +531,5 @@ }); | ||
}); | ||
})(); |
@@ -10,7 +10,10 @@ window.expect = chai.expect; | ||
var test_number = 0; | ||
var $current_test_label = $('<h1 style="white-space:nowrap;overflow:hidden"></h1>').prependTo(sandbox); | ||
$('<div style="position:absolute;top:0;left:0;right:0;bottom:0;z-index:10000">').prependTo(sandbox); | ||
var teardownLast = function(){ | ||
if( window.test_last ){ | ||
window.test_last.instance.destroy(); | ||
window.test_last.$select.remove(); | ||
window.test_last.$html.remove(); | ||
//sandbox.innerHTML = ''; | ||
@@ -33,2 +36,3 @@ window.test_last = null; | ||
var $html = $(html).appendTo(sandbox); | ||
@@ -65,5 +69,20 @@ var $select = $html.find('.setup-here'); | ||
var it_n = function(){ | ||
arguments[0] = (test_number++) + ' - ' + arguments[0]; | ||
it.apply( this, arguments); | ||
var it_n = function(label,orig_func){ | ||
var new_func; | ||
label = (test_number++) + ' - ' + label | ||
if( orig_func.length > 0 ){ | ||
new_func = function(done){ | ||
$current_test_label.text(label); | ||
return orig_func.call(this,done); | ||
}; | ||
}else{ | ||
new_func = function(){ | ||
$current_test_label.text(label); | ||
return orig_func.call(this); | ||
}; | ||
} | ||
it.call( this, label, new_func ); | ||
} | ||
@@ -70,0 +89,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Sorry, the diff of this file is not supported yet
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
1651695
1
28438
39
110
69
- Removedsifter@^0.5.4
- Removedansicolors@0.2.1(transitive)
- Removedasync@2.6.4(transitive)
- Removedcardinal@1.0.0(transitive)
- Removedcsv-parse@4.16.3(transitive)
- Removedesprima@3.0.0(transitive)
- Removedhumanize@0.0.9(transitive)
- Removedlodash@4.17.21(transitive)
- Removedminimist@0.0.10(transitive)
- Removedoptimist@0.6.1(transitive)
- Removedredeyed@1.0.1(transitive)
- Removedsifter@0.5.4(transitive)
- Removedwordwrap@0.0.3(transitive)