Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tom-select

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tom-select - npm Package Compare versions

Comparing version 1.4.3 to 1.5.0

.config/eleventy.csp.js

14

.config/eleventy.js
module.exports = function(eleventyConfig) {

@@ -11,3 +12,15 @@ // Aliases are in relation to the _includes folder

const csp_plugin = require('./eleventy.csp.js');
eleventyConfig.addPlugin(csp_plugin,{
csp:{
'default-src': ["'self'"],
'img-src': ['https://*','data:'],
'style-src': ["'self'",'unpkg.com','cdnjs.cloudflare.com'],
'script-src': ["'self' 'unsafe-inline'"], // unsafe-inline needed for esm imports
'font-src': ["'self'",'cdnjs.cloudflare.com'],
'connect-src': ['api.github.com','whatcms.org','api.reddit.com'],
}
});
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");

@@ -54,2 +67,3 @@ eleventyConfig.addPlugin(syntaxHighlight);

let markdownIt = require('markdown-it');

@@ -56,0 +70,0 @@

19

.config/rollup.config.js

@@ -5,4 +5,2 @@ import resolve from '@rollup/plugin-node-resolve'; // so Rollup can find `node_modules`

import { terser } from 'rollup-plugin-terser';
import bundleSize from '@atomico/rollup-plugin-sizes';
import visualizer from 'rollup-plugin-visualizer';
import pkg from '../package.json';

@@ -52,2 +50,14 @@ import path from 'path';

// cjs
configs.push({
input: path.resolve(__dirname,'../src/tom-select.complete.ts'),
output:{
dir: path.resolve(__dirname,'../build/cjs'),
format: 'cjs',
preserveModules: true,
sourcemap: true,
banner: banner,
},
plugins:[babel_config,resolve_config]
});

@@ -90,7 +100,2 @@

commonjs(),
bundleSize(),
visualizer({
sourcemap: true,
filename: `stats/${config.output.file}.html`,
})
];

@@ -97,0 +102,0 @@

@@ -29,1 +29,6 @@ ---

- Device: [e.g. iPhone6]
<!--
Thanks for taking the time to submit your bug report,
anbd don't forget to star our repo!
/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -13,6 +13,10 @@ */

*/
function highlight(element, pattern) {
if (typeof pattern === 'string' && !pattern.length) return;
var regex = typeof pattern === 'string' ? new RegExp(pattern, 'i') : pattern;
function highlight(element, regex) {
if (regex === null) return; // convet string to regex
if (typeof regex === 'string') {
if (!regex.length) return;
regex = new RegExp(regex, 'i');
}
var highlight = function highlight(node) {

@@ -19,0 +23,0 @@ var skip = 0; // Wrap matching part of text node with highlighting <span>, e.g.

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -135,27 +135,40 @@ */

*/
tokenize(query, respect_word_boundaries) {
tokenize(query, options) {
query = String(query || '').toLowerCase().trim();
if (!query || !query.length) return [];
var i, n, regex, letter;
var letter;
var tokens = [];
var words = query.split(/ +/);
var words = query.split(/\s+/);
const field_regex = new RegExp('^(' + options.fields.map(escape_regex).join('|') + ')\:(.*)$');
words.forEach(word => {
let field_match;
let field = null;
let regex = null; // look for "field:query" tokens
for (i = 0, n = words.length; i < n; i++) {
regex = escape_regex(words[i]);
if (options.fields.length > 1 && (field_match = word.match(field_regex))) {
field = field_match[1];
word = field_match[2];
}
if (this.settings.diacritics) {
for (letter in DIACRITICS) {
if (DIACRITICS.hasOwnProperty(letter)) {
regex = regex.replace(new RegExp(letter, 'g'), DIACRITICS[letter]);
if (word.length > 0) {
regex = escape_regex(word);
if (this.settings.diacritics) {
for (letter in DIACRITICS) {
if (DIACRITICS.hasOwnProperty(letter)) {
regex = regex.replace(new RegExp(letter, 'g'), DIACRITICS[letter]);
}
}
}
if (options.respect_word_boundaries) regex = "\\b" + regex;
regex = new RegExp(regex, 'i');
}
if (respect_word_boundaries) regex = "\\b" + regex;
tokens.push({
string: words[i],
regex: new RegExp(regex, 'i')
string: word,
regex: regex,
field: field
});
}
});
return tokens;

@@ -258,4 +271,16 @@ }

return function (token, data) {
for (var i = 0, sum = 0; i < field_count; i++) {
sum += scoreValue(getattr(data, fields[i], nesting), token);
var sum = 0; // is the token specific to a field?
if (token.field) {
const field = getattr(data, token.field, nesting);
if (!token.regex && field) {
sum += 0.1;
} else {
sum += scoreValue(field, token);
}
} else {
fields.forEach(field => {
sum += scoreValue(getattr(data, field, nesting), token);
});
}

@@ -417,3 +442,3 @@

query: String(query || '').toLowerCase(),
tokens: this.tokenize(query, options.respect_word_boundaries),
tokens: this.tokenize(query, options),
total: 0,

@@ -420,0 +445,0 @@ items: []

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -80,9 +80,4 @@ */

this.inputId = getId(input, 'tomselect-' + instance_i);
this.isRequired = input.required; // debounce user defined load() if loadThrottle > 0
this.isRequired = input.required; // search system
if (this.settings.load && this.settings.loadThrottle) {
this.settings.load = loadDebounce(this.settings.load, this.settings.loadThrottle);
} // search system
this.sifter = new Sifter(this.options, {

@@ -159,3 +154,3 @@ diacritics: this.settings.diacritics

addClasses(dropdown, settings.dropdownClass, inputMode);
dropdown_content = getDom(`<div style="scroll-behavior: smooth;" role="listbox" id="${listboxId}" tabindex="-1">`);
dropdown_content = getDom(`<div role="listbox" id="${listboxId}" tabindex="-1">`);
addClasses(dropdown_content, settings.dropdownContentClass);

@@ -233,2 +228,8 @@ dropdown.append(dropdown_content);

self.settings.splitOn = new RegExp('\\s*' + delimiterEscaped + '+\\s*');
} // debounce user defined load() if loadThrottle > 0
// after initializePlugins() so plugins can create/modify user defined loaders
if (this.settings.load && this.settings.loadThrottle) {
this.settings.load = loadDebounce(this.settings.load, this.settings.loadThrottle);
}

@@ -411,3 +412,3 @@

'dropdown': () => {
return '<div style="display:none"></div>';
return '<div></div>';
}

@@ -619,2 +620,4 @@ };

self.onOptionSelect(e, self.activeOption);
preventDefault(e); // if the option_create=null, the dropdown might be closed
} else if (self.settings.create && self.createItem()) {
preventDefault(e);

@@ -637,13 +640,15 @@ }

case KEY_TAB:
if (self.settings.selectOnTab && self.isOpen && self.activeOption) {
self.tab_key = true;
self.onOptionSelect(e, self.activeOption); // prevent default [tab] behaviour of jump to the next field
// if select isFull, then the dropdown won't be open and [tab] will work normally
if (self.settings.selectOnTab) {
if (self.isOpen && self.activeOption) {
self.tab_key = true;
self.onOptionSelect(e, self.activeOption); // prevent default [tab] behaviour of jump to the next field
// if select isFull, then the dropdown won't be open and [tab] will work normally
preventDefault(e);
self.tab_key = false;
}
preventDefault(e);
self.tab_key = false;
}
if (self.settings.create && self.createItem()) {
preventDefault(e);
if (self.settings.create && self.createItem()) {
preventDefault(e);
}
}

@@ -831,16 +836,25 @@

self.loading++;
fn.call(self, value, function (options, optgroups) {
self.loading = Math.max(self.loading - 1, 0);
self.lastQuery = null;
self.clearActiveOption(); // when new results load, focus should be on first option
const callback = self.loadCallback.bind(self);
fn.call(self, value, callback);
}
/**
* Invoked by the user-provided option provider
*
*/
self.setupOptions(options, optgroups);
self.refreshOptions(self.isFocused && !self.isInputHidden);
if (!self.loading) {
removeClasses(self.wrapper, self.settings.loadingClass);
}
loadCallback(options, optgroups) {
const self = this;
self.loading = Math.max(self.loading - 1, 0);
self.lastQuery = null;
self.clearActiveOption(); // when new results load, focus should be on first option
self.trigger('load', options, optgroups);
});
self.setupOptions(options, optgroups);
self.refreshOptions(self.isFocused && !self.isInputHidden);
if (!self.loading) {
removeClasses(self.wrapper, self.settings.loadingClass);
}
self.trigger('load', options, optgroups);
}

@@ -1319,4 +1333,4 @@ /**

let group_options = document.createDocumentFragment();
group_options.appendChild(self.render('optgroup_header', self.optgroups[optgroup]));
group_options.appendChild(groups[optgroup]);
group_options.append(self.render('optgroup_header', self.optgroups[optgroup]));
group_options.append(groups[optgroup]);
let group_html = self.render('optgroup', {

@@ -1326,5 +1340,5 @@ group: self.optgroups[optgroup],

});
html.appendChild(group_html);
html.append(group_html);
} else {
html.appendChild(groups[optgroup]);
html.append(groups[optgroup]);
}

@@ -1334,3 +1348,3 @@ }

self.dropdown_content.innerHTML = '';
self.dropdown_content.appendChild(html); // highlight matching terms inline
self.dropdown_content.append(html); // highlight matching terms inline

@@ -1406,3 +1420,3 @@ if (self.settings.highlight) {

if (triggerDropdown && self.isOpen) {
self.close();
self.close(false); // if create_option=null, we wan't the dropdown to close but not reset the textbox value
}

@@ -2001,2 +2015,3 @@ }

if (self.items.indexOf(option.value) == -1) {
option.selected = false;
option.removeAttribute('selected');

@@ -2016,2 +2031,3 @@ }

option.selected = true;
setAttr(option, {

@@ -2063,6 +2079,8 @@ selected: 'true'

close() {
close(setTextboxValue = true) {
var self = this;
var trigger = self.isOpen;
var trigger = self.isOpen; // before blur() to prevent form onchange event
if (setTextboxValue) self.setTextboxValue();
if (self.settings.mode === 'single' && self.items.length) {

@@ -2087,3 +2105,2 @@ self.hideInput(); // Do not trigger blur while inside a blur event,

self.refreshState();
self.setTextboxValue();
if (trigger) self.trigger('dropdown_close', self.dropdown);

@@ -2090,0 +2107,0 @@ }

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -10,56 +10,60 @@ */

e(t,(e=>{if(e in s._events!=!1)for(let t of s._events[e])t.apply(s,i)}))}}var i=function(e,t){return"number"==typeof e&&"number"==typeof t?e>t?1:e<t?-1:0:(e=o(String(e||"")))>(t=o(String(t||"")))?1:t>e?-1:0},s=function(e,t,i){if(e&&t){if(!i)return e[t]
for(var s=t.split(".");s.length&&(e=e[s.shift()]););return e}},n={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ŹźẐẑŽžŻżẒẓẔẕƵƶ]"},o=function(){var e,t,i,s,o="",r={}
for(i in n)if(n.hasOwnProperty(i))for(o+=s=n[i].substring(2,n[i].length-1),e=0,t=s.length;e<t;e++)r[s.charAt(e)]=i
var l=new RegExp("["+o+"]","g")
return function(e){return e.replace(l,(function(e){return r[e]})).toLowerCase()}}()
class r{constructor(e,t){this.items=void 0,this.settings=void 0,this.items=e,this.settings=t||{diacritics:!0}}tokenize(e,t){if(!(e=String(e||"").toLowerCase().trim())||!e.length)return[]
var i,s,o,r,l=[],a=e.split(/ +/)
for(i=0,s=a.length;i<s;i++){if(o=(a[i]+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1"),this.settings.diacritics)for(r in n)n.hasOwnProperty(r)&&(o=o.replace(new RegExp(r,"g"),n[r]))
t&&(o="\\b"+o),l.push({string:a[i],regex:new RegExp(o,"i")})}return l}iterator(e,t){(Array.isArray(e)?Array.prototype.forEach||function(e){for(var t=0,i=this.length;t<i;t++)e(this[t],t,this)}:function(e){for(var t in this)this.hasOwnProperty(t)&&e(this[t],t,this)}).apply(e,[t])}getScoreFunction(e,t){var i,n,o,r,l
l=this.prepareSearch(e,t),n=l.tokens,i=l.options.fields,o=n.length,r=l.options.nesting
for(var s=t.split(".");s.length&&(e=e[s.shift()]););return e}},n=function(e){return(e+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")},r={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ŹźẐẑŽžŻżẒẓẔẕƵƶ]"},o=function(){var e,t,i,s,n="",o={}
for(i in r)if(r.hasOwnProperty(i))for(n+=s=r[i].substring(2,r[i].length-1),e=0,t=s.length;e<t;e++)o[s.charAt(e)]=i
var l=new RegExp("["+n+"]","g")
return function(e){return e.replace(l,(function(e){return o[e]})).toLowerCase()}}()
class l{constructor(e,t){this.items=void 0,this.settings=void 0,this.items=e,this.settings=t||{diacritics:!0}}tokenize(e,t){if(!(e=String(e||"").toLowerCase().trim())||!e.length)return[]
var i,s=[],o=e.split(/\s+/)
const l=new RegExp("^("+t.fields.map(n).join("|")+"):(.*)$")
return o.forEach((e=>{let o,a=null,d=null
if(t.fields.length>1&&(o=e.match(l))&&(a=o[1],e=o[2]),e.length>0){if(d=n(e),this.settings.diacritics)for(i in r)r.hasOwnProperty(i)&&(d=d.replace(new RegExp(i,"g"),r[i]))
t.respect_word_boundaries&&(d="\\b"+d),d=new RegExp(d,"i")}s.push({string:e,regex:d,field:a})})),s}iterator(e,t){(Array.isArray(e)?Array.prototype.forEach||function(e){for(var t=0,i=this.length;t<i;t++)e(this[t],t,this)}:function(e){for(var t in this)this.hasOwnProperty(t)&&e(this[t],t,this)}).apply(e,[t])}getScoreFunction(e,t){var i,n,r,o,l
l=this.prepareSearch(e,t),n=l.tokens,i=l.options.fields,r=n.length,o=l.options.nesting
var a,d=function(e,t){var i,s
return e?-1===(s=(e=String(e||"")).search(t.regex))?0:(i=t.string.length/e.length,0===s&&(i+=.5),i):0},p=(a=i.length)?1===a?function(e,t){return d(s(t,i[0],r),e)}:function(e,t){for(var n=0,o=0;n<a;n++)o+=d(s(t,i[n],r),e)
return o/a}:function(){return 0}
return o?1===o?function(e){return p(n[0],e)}:"and"===l.options.conjunction?function(e){for(var t,i=0,s=0;i<o;i++){if((t=p(n[i],e))<=0)return 0
s+=t}return s/o}:function(e){for(var t=0,i=0;t<o;t++)i+=p(n[t],e)
return i/o}:function(){return 0}}getSortFunction(e,t){var n,o,r,l,a,d,p,c,u,h,g
if(g=!(e=(r=this).prepareSearch(e,t)).query&&t.sort_empty||t.sort,u=function(e,i){return"$score"===e?i.score:s(r.items[i.id],e,t.nesting)},a=[],g)for(n=0,o=g.length;n<o;n++)(e.query||"$score"!==g[n].field)&&a.push(g[n])
if(e.query){for(h=!0,n=0,o=a.length;n<o;n++)if("$score"===a[n].field){h=!1
break}h&&a.unshift({field:"$score",direction:"desc"})}else for(n=0,o=a.length;n<o;n++)if("$score"===a[n].field){a.splice(n,1)
break}for(c=[],n=0,o=a.length;n<o;n++)c.push("desc"===a[n].direction?-1:1)
return(d=a.length)?1===d?(l=a[0].field,p=c[0],function(e,t){return p*i(u(l,e),u(l,t))}):function(e,t){var s,n,o
for(s=0;s<d;s++)if(o=a[s].field,n=c[s]*i(u(o,e),u(o,t)))return n
return e?-1===(s=(e=String(e||"")).search(t.regex))?0:(i=t.string.length/e.length,0===s&&(i+=.5),i):0},p=(a=i.length)?1===a?function(e,t){return d(s(t,i[0],o),e)}:function(e,t){var n=0
if(e.field){const i=s(t,e.field,o)
!e.regex&&i?n+=.1:n+=d(i,e)}else i.forEach((i=>{n+=d(s(t,i,o),e)}))
return n/a}:function(){return 0}
return r?1===r?function(e){return p(n[0],e)}:"and"===l.options.conjunction?function(e){for(var t,i=0,s=0;i<r;i++){if((t=p(n[i],e))<=0)return 0
s+=t}return s/r}:function(e){for(var t=0,i=0;t<r;t++)i+=p(n[t],e)
return i/r}:function(){return 0}}getSortFunction(e,t){var n,r,o,l,a,d,p,c,u,h,g
if(g=!(e=(o=this).prepareSearch(e,t)).query&&t.sort_empty||t.sort,u=function(e,i){return"$score"===e?i.score:s(o.items[i.id],e,t.nesting)},a=[],g)for(n=0,r=g.length;n<r;n++)(e.query||"$score"!==g[n].field)&&a.push(g[n])
if(e.query){for(h=!0,n=0,r=a.length;n<r;n++)if("$score"===a[n].field){h=!1
break}h&&a.unshift({field:"$score",direction:"desc"})}else for(n=0,r=a.length;n<r;n++)if("$score"===a[n].field){a.splice(n,1)
break}for(c=[],n=0,r=a.length;n<r;n++)c.push("desc"===a[n].direction?-1:1)
return(d=a.length)?1===d?(l=a[0].field,p=c[0],function(e,t){return p*i(u(l,e),u(l,t))}):function(e,t){var s,n,r
for(s=0;s<d;s++)if(r=a[s].field,n=c[s]*i(u(r,e),u(r,t)))return n
return 0}:null}prepareSearch(e,t){if("object"==typeof e)return e
var i=(t=Object.assign({},t)).fields,s=t.sort,n=t.sort_empty
return i&&!Array.isArray(i)&&(t.fields=[i]),s&&!Array.isArray(s)&&(t.sort=[s]),n&&!Array.isArray(n)&&(t.sort_empty=[n]),{options:t,query:String(e||"").toLowerCase(),tokens:this.tokenize(e,t.respect_word_boundaries),total:0,items:[]}}search(e,t){var i,s,n,o,r=this
return s=this.prepareSearch(e,t),t=s.options,e=s.query,o=t.score||r.getScoreFunction(s),e.length?r.iterator(r.items,(function(e,n){i=o(e),(!1===t.filter||i>0)&&s.items.push({score:i,id:n})})):r.iterator(r.items,(function(e,t){s.items.push({score:1,id:t})})),(n=r.getSortFunction(s,t))&&s.items.sort(n),s.total=s.items.length,"number"==typeof t.limit&&(s.items=s.items.slice(0,t.limit)),s}}function l(e,t){if("string"!=typeof t||t.length){var i="string"==typeof t?new RegExp(t,"i"):t
!function e(t){var s=0
if(3===t.nodeType){var n=t.data.search(i)
if(n>=0&&t.data.length>0){var o=t.data.match(i),r=document.createElement("span")
r.className="highlight"
var l=t.splitText(n)
l.splitText(o[0].length)
return i&&!Array.isArray(i)&&(t.fields=[i]),s&&!Array.isArray(s)&&(t.sort=[s]),n&&!Array.isArray(n)&&(t.sort_empty=[n]),{options:t,query:String(e||"").toLowerCase(),tokens:this.tokenize(e,t),total:0,items:[]}}search(e,t){var i,s,n,r,o=this
return s=this.prepareSearch(e,t),t=s.options,e=s.query,r=t.score||o.getScoreFunction(s),e.length?o.iterator(o.items,(function(e,n){i=r(e),(!1===t.filter||i>0)&&s.items.push({score:i,id:n})})):o.iterator(o.items,(function(e,t){s.items.push({score:1,id:t})})),(n=o.getSortFunction(s,t))&&s.items.sort(n),s.total=s.items.length,"number"==typeof t.limit&&(s.items=s.items.slice(0,t.limit)),s}}function a(e,t){if(null!==t){if("string"==typeof t){if(!t.length)return
t=new RegExp(t,"i")}!function e(i){var s=0
if(3===i.nodeType){var n=i.data.search(t)
if(n>=0&&i.data.length>0){var r=i.data.match(t),o=document.createElement("span")
o.className="highlight"
var l=i.splitText(n)
l.splitText(r[0].length)
var a=l.cloneNode(!0)
r.appendChild(a),l.parentNode.replaceChild(r,l),s=1}}else if(1===t.nodeType&&t.childNodes&&!/(script|style)/i.test(t.tagName)&&("highlight"!==t.className||"SPAN"!==t.tagName))for(var d=0;d<t.childNodes.length;++d)d+=e(t.childNodes[d])
return s}(e)}}const a="undefined"!=typeof navigator&&/Mac/.test(navigator.userAgent)?"metaKey":"ctrlKey"
var d={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:null,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,shouldOpen:null,maxOptions:50,maxItems:null,hideSelected:null,duplicates:!1,addPrecedence:!1,selectOnTab:!1,preload:null,allowEmptyOption:!1,closeAfterSelect:!1,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,placeholder:null,hidePlaceholder:null,shouldLoad:function(e){return e.length>0},render:{}}
function p(e){return null==e?null:"boolean"==typeof e?e?"1":"0":e+""}function c(e){return(e+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function u(e,t,i){var s,n=e.trigger,o={}
o.appendChild(a),l.parentNode.replaceChild(o,l),s=1}}else if(1===i.nodeType&&i.childNodes&&!/(script|style)/i.test(i.tagName)&&("highlight"!==i.className||"SPAN"!==i.tagName))for(var d=0;d<i.childNodes.length;++d)d+=e(i.childNodes[d])
return s}(e)}}const d="undefined"!=typeof navigator&&/Mac/.test(navigator.userAgent)?"metaKey":"ctrlKey"
var p={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:null,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,shouldOpen:null,maxOptions:50,maxItems:null,hideSelected:null,duplicates:!1,addPrecedence:!1,selectOnTab:!1,preload:null,allowEmptyOption:!1,closeAfterSelect:!1,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,placeholder:null,hidePlaceholder:null,shouldLoad:function(e){return e.length>0},render:{}}
function c(e){return null==e?null:"boolean"==typeof e?e?"1":"0":e+""}function u(e){return(e+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function h(e,t,i){var s,n=e.trigger,r={}
for(s in e.trigger=function(){var i=arguments[0]
if(-1===t.indexOf(i))return n.apply(e,arguments)
o[i]=arguments},i.apply(e,[]),e.trigger=n,o)n.apply(e,o[s])}function h(e,t=!1){e&&(e.preventDefault(),t&&e.stopPropagation())}function g(e,t,i,s){e.addEventListener(t,i,s)}function f(e,t){return!!t&&(!!t[e]&&1===(t.altKey?1:0)+(t.ctrlKey?1:0)+(t.shiftKey?1:0)+(t.metaKey?1:0))}function v(e,t){const i=e.getAttribute("id")
return i||(e.setAttribute("id",t),t)}function m(e){if(e.jquery)return e[0]
r[i]=arguments},i.apply(e,[]),e.trigger=n,r)n.apply(e,r[s])}function g(e,t=!1){e&&(e.preventDefault(),t&&e.stopPropagation())}function f(e,t,i,s){e.addEventListener(t,i,s)}function v(e,t){return!!t&&(!!t[e]&&1===(t.altKey?1:0)+(t.ctrlKey?1:0)+(t.shiftKey?1:0)+(t.metaKey?1:0))}function m(e,t){const i=e.getAttribute("id")
return i||(e.setAttribute("id",t),t)}function y(e){if(e.jquery)return e[0]
if(e instanceof HTMLElement)return e
if(e.indexOf("<")>-1){let t=document.createElement("div")
return t.innerHTML=e.trim(),t.firstChild}return document.querySelector(e)}function y(e,t){var i=document.createEvent("HTMLEvents")
i.initEvent(t,!0,!1),e.dispatchEvent(i)}function O(e,t){Object.assign(e.style,t)}function b(e,...t){var i=I(t);(e=C(e)).map((e=>{i.map((t=>{e.classList.add(t)}))}))}function w(e,...t){var i=I(t);(e=C(e)).map((e=>{i.map((t=>{e.classList.remove(t)}))}))}function I(e){var t=[]
return t.innerHTML=e.trim(),t.firstChild}return document.querySelector(e)}function O(e,t){var i=document.createEvent("HTMLEvents")
i.initEvent(t,!0,!1),e.dispatchEvent(i)}function b(e,t){Object.assign(e.style,t)}function w(e,...t){var i=C(t);(e=A(e)).map((e=>{i.map((t=>{e.classList.add(t)}))}))}function I(e,...t){var i=C(t);(e=A(e)).map((e=>{i.map((t=>{e.classList.remove(t)}))}))}function C(e){var t=[]
for(let i of e)"string"==typeof i&&(i=i.trim().split(/[\11\12\14\15\40]/)),Array.isArray(i)&&(t=t.concat(i))
return t.filter(Boolean)}function C(e){return Array.isArray(e)||(e=[e]),e}function A(e,t,i){if(!i||i.contains(e))for(;e&&e.matches;){if(e.matches(t))return e
e=e.parentNode}}function _(e,t){return t>0?e[e.length-1]:e[0]}function S(e,t){if(!e)return-1
return t.filter(Boolean)}function A(e){return Array.isArray(e)||(e=[e]),e}function _(e,t,i){if(!i||i.contains(e))for(;e&&e.matches;){if(e.matches(t))return e
e=e.parentNode}}function S(e,t){return t>0?e[e.length-1]:e[0]}function x(e,t){if(!e)return-1
t=t||e.nodeName
for(var i=0;e=e.previousElementSibling;)e.matches(t)&&i++
return i}function x(e,t){for(const i in t)e.setAttribute(i,t[i])}var F=0
class P extends(function(e){return e.plugins={},class extends e{static define(t,i){e.plugins[t]={name:t,fn:i}}initializePlugins(e){var t,i,s,n=this,o=[]
if(n.plugins={names:[],settings:{},requested:{},loaded:{}},Array.isArray(e))for(t=0,i=e.length;t<i;t++)"string"==typeof e[t]?o.push(e[t]):(n.plugins.settings[e[t].name]=e[t].options,o.push(e[t].name))
else if(e)for(s in e)e.hasOwnProperty(s)&&(n.plugins.settings[s]=e[s],o.push(s))
for(;o.length;)n.require(o.shift())}loadPlugin(t){var i=this,s=i.plugins,n=e.plugins[t]
return i}function F(e,t){for(const i in t)e.setAttribute(i,t[i])}var P=0
class k extends(function(e){return e.plugins={},class extends e{static define(t,i){e.plugins[t]={name:t,fn:i}}initializePlugins(e){var t,i,s,n=this,r=[]
if(n.plugins={names:[],settings:{},requested:{},loaded:{}},Array.isArray(e))for(t=0,i=e.length;t<i;t++)"string"==typeof e[t]?r.push(e[t]):(n.plugins.settings[e[t].name]=e[t].options,r.push(e[t].name))
else if(e)for(s in e)e.hasOwnProperty(s)&&(n.plugins.settings[s]=e[s],r.push(s))
for(;r.length;)n.require(r.shift())}loadPlugin(t){var i=this,s=i.plugins,n=e.plugins[t]
if(!e.plugins.hasOwnProperty(t))throw new Error('Unable to find "'+t+'" plugin')

@@ -69,69 +73,70 @@ s.requested[t]=!0,s.loaded[t]=n.fn.apply(i,[i.plugins.settings[t]||{}]),s.names.push(t)}require(e){var t=this,i=t.plugins

t.loadPlugin(e)}return i.loaded[e]}}}(t)){constructor(e,t){var i
super(),this.control_input=void 0,this.wrapper=void 0,this.dropdown=void 0,this.control=void 0,this.dropdown_content=void 0,this.order=0,this.settings=void 0,this.input=void 0,this.tabIndex=void 0,this.is_select_tag=void 0,this.rtl=void 0,this.inputId=void 0,this._destroy=void 0,this.sifter=void 0,this.tab_key=!1,this.isOpen=!1,this.isDisabled=!1,this.isRequired=void 0,this.isInvalid=!1,this.isLocked=!1,this.isFocused=!1,this.isInputHidden=!1,this.isSetup=!1,this.ignoreFocus=!1,this.ignoreBlur=!1,this.hasOptions=!1,this.currentResults=null,this.lastValue="",this.caretPos=0,this.loading=0,this.loadedSearches={},this.activeOption=null,this.activeItems=[],this.optgroups={},this.options={},this.options_i=0,this.userOptions={},this.items=[],this.renderCache={item:{},option:{}},F++
var s,n,o,l=m(e)
if(l.tomselect)throw new Error("Tom Select already initialized on this element")
l.tomselect=this,i=(window.getComputedStyle&&window.getComputedStyle(l,null)).getPropertyValue("direction"),this.settings=function(e,t){var i=Object.assign({},d,t),s=i.dataAttr,n=i.labelField,o=i.valueField,r=i.disabledField,l=i.optgroupField,a=i.optgroupLabelField,c=i.optgroupValueField,u=e.tagName.toLowerCase(),h=e.getAttribute("placeholder")||e.getAttribute("data-placeholder")
super(),this.control_input=void 0,this.wrapper=void 0,this.dropdown=void 0,this.control=void 0,this.dropdown_content=void 0,this.order=0,this.settings=void 0,this.input=void 0,this.tabIndex=void 0,this.is_select_tag=void 0,this.rtl=void 0,this.inputId=void 0,this._destroy=void 0,this.sifter=void 0,this.tab_key=!1,this.isOpen=!1,this.isDisabled=!1,this.isRequired=void 0,this.isInvalid=!1,this.isLocked=!1,this.isFocused=!1,this.isInputHidden=!1,this.isSetup=!1,this.ignoreFocus=!1,this.ignoreBlur=!1,this.hasOptions=!1,this.currentResults=null,this.lastValue="",this.caretPos=0,this.loading=0,this.loadedSearches={},this.activeOption=null,this.activeItems=[],this.optgroups={},this.options={},this.options_i=0,this.userOptions={},this.items=[],this.renderCache={item:{},option:{}},P++
var s=y(e)
if(s.tomselect)throw new Error("Tom Select already initialized on this element")
s.tomselect=this,i=(window.getComputedStyle&&window.getComputedStyle(s,null)).getPropertyValue("direction"),this.settings=function(e,t){var i=Object.assign({},p,t),s=i.dataAttr,n=i.labelField,r=i.valueField,o=i.disabledField,l=i.optgroupField,a=i.optgroupLabelField,d=i.optgroupValueField,u=e.tagName.toLowerCase(),h=e.getAttribute("placeholder")||e.getAttribute("data-placeholder")
if(!h&&!i.allowEmptyOption){let t=e.querySelector('option[value=""]')
t&&(h=t.textContent)}var g={placeholder:h,options:[],optgroups:[],items:[],maxItems:null}
return"select"===u?(()=>{var t,d=g.options,u={},h=1,f=e=>{var t=Object.assign({},e.dataset),i=s&&t[s]
return"string"==typeof i&&i.length&&(t=Object.assign(t,JSON.parse(i))),t},v=(e,t)=>{var s=p(e.value)
return"select"===u?(()=>{var t,p=g.options,u={},h=1,f=e=>{var t=Object.assign({},e.dataset),i=s&&t[s]
return"string"==typeof i&&i.length&&(t=Object.assign(t,JSON.parse(i))),t},v=(e,t)=>{var s=c(e.value)
if(s||i.allowEmptyOption)if(u.hasOwnProperty(s)){if(t){var a=u[s][l]
a?Array.isArray(a)?a.push(t):u[s][l]=[a,t]:u[s][l]=t}}else{var c=f(e)
c[n]=c[n]||e.textContent,c[o]=c[o]||s,c[r]=c[r]||e.disabled,c[l]=c[l]||t,c.$option=e,u[s]=c,d.push(c),e.selected&&g.items.push(s)}},m=e=>{var t,i;(i=f(e))[a]=i[a]||e.getAttribute("label")||"",i[c]=i[c]||h++,i[r]=i[r]||e.disabled,g.optgroups.push(i),t=i[c]
a?Array.isArray(a)?a.push(t):u[s][l]=[a,t]:u[s][l]=t}}else{var d=f(e)
d[n]=d[n]||e.textContent,d[r]=d[r]||s,d[o]=d[o]||e.disabled,d[l]=d[l]||t,d.$option=e,u[s]=d,p.push(d),e.selected&&g.items.push(s)}},m=e=>{var t,i;(i=f(e))[a]=i[a]||e.getAttribute("label")||"",i[d]=i[d]||h++,i[o]=i[o]||e.disabled,g.optgroups.push(i),t=i[d]
for(const i of e.children)v(i,t)}
g.maxItems=e.hasAttribute("multiple")?null:1
for(const i of e.children)"optgroup"===(t=i.tagName.toLowerCase())?m(i):"option"===t&&v(i)})():(()=>{var t,r,l=e.getAttribute(s)
for(const i of e.children)"optgroup"===(t=i.tagName.toLowerCase())?m(i):"option"===t&&v(i)})():(()=>{var t,o,l=e.getAttribute(s)
if(l){g.options=JSON.parse(l)
for(const e of g.options)g.items.push(e[o])}else{var a=e.value.trim()||""
for(const e of g.options)g.items.push(e[r])}else{var a=e.value.trim()||""
if(!i.allowEmptyOption&&!a.length)return
t=a.split(i.delimiter)
for(const e of t)(r={})[n]=e,r[o]=e,g.options.push(r)
g.items=t}})(),Object.assign({},d,g,t)}(l,t),this.input=l,this.tabIndex=l.tabIndex||0,this.is_select_tag="select"===l.tagName.toLowerCase(),this.rtl=/rtl/i.test(i),this.inputId=v(l,"tomselect-"+F),this.isRequired=l.required,this.settings.load&&this.settings.loadThrottle&&(this.settings.load=(s=this.settings.load,n=this.settings.loadThrottle,function(e,t){var i=this
o&&(i.loading=Math.max(i.loading-1,0)),clearTimeout(o),o=setTimeout((function(){o=null,i.loadedSearches[e]=!0,s.call(i,e,t)}),n)})),this.sifter=new r(this.options,{diacritics:this.settings.diacritics}),this.setupOptions(this.settings.options,this.settings.optgroups),delete this.settings.optgroups,delete this.settings.options,this.settings.mode=this.settings.mode||(1===this.settings.maxItems?"single":"multi"),"boolean"!=typeof this.settings.hideSelected&&(this.settings.hideSelected="multi"===this.settings.mode),"boolean"!=typeof this.settings.hidePlaceholder&&(this.settings.hidePlaceholder="multi"!==this.settings.mode)
var a=this.settings.createFilter
"function"!=typeof a&&("string"==typeof a&&(a=new RegExp(a)),a instanceof RegExp?this.settings.createFilter=e=>a.test(e):this.settings.createFilter=()=>!0),this.initializePlugins(this.settings.plugins),this.setupCallbacks(),this.setupTemplates(),this.setup()}setup(){var e,t,i,s,n,o,r,l,a,d=this,p=d.settings,c=d.input
const u={passive:!0},f=d.inputId+"-ts-dropdown"
if(o=d.settings.mode,r=c.getAttribute("class")||"",b(e=m("<div>"),p.wrapperClass,r,o),b(t=m('<div class="items">'),p.inputClass),e.append(t),b(s=d.render("dropdown"),p.dropdownClass,o),b(n=m(`<div style="scroll-behavior: smooth;" role="listbox" id="${f}" tabindex="-1">`),p.dropdownContentClass),s.append(n),m(p.dropdownParent||e).appendChild(s),p.controlInput)i=m(p.controlInput)
else{i=m('<input type="text" autocomplete="off" size="1" />')
for(const e of["autocorrect","autocapitalize","autocomplete"])c.getAttribute(e)&&x(i,{[e]:c.getAttribute(e)})}p.controlInput||(i.tabIndex=c.disabled?-1:d.tabIndex,t.appendChild(i)),x(i,{role:"combobox",haspopup:"listbox","aria-expanded":"false","aria-controls":f}),a=v(i,d.inputId+"-tomselected")
let y="label[for='"+function(e){return e.replace(/['"\\]/g,"\\$&")}(d.inputId)+"']",O=document.querySelector(y)
if(O){x(O,{for:a}),x(n,{"aria-labelledby":v(O,d.inputId+"-ts-label")})}if(d.settings.copyClassesToDropdown&&b(s,r),e.style.width=c.style.width,d.plugins.names.length&&(l="plugin-"+d.plugins.names.join(" plugin-"),b([e,s],l)),(null===p.maxItems||p.maxItems>1)&&d.is_select_tag&&x(c,{multiple:"multiple"}),d.settings.placeholder&&x(i,{placeholder:p.placeholder}),!d.settings.splitOn&&d.settings.delimiter){var w=d.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")
d.settings.splitOn=new RegExp("\\s*"+w+"+\\s*")}d.control=t,d.control_input=i,d.wrapper=e,d.dropdown=s,d.dropdown_content=n,d.control_input.type=c.type,g(s,"mouseenter",(e=>{var t=A(e.target,"[data-selectable]",s)
if(t)return d.onOptionHover(e,t)}),{capture:!0}),g(t,"mousedown",(e=>{if(e.target==i)return d.clearActiveItems(),e.stopPropagation(),void d.inputState()
var s=A(e.target,"."+d.settings.itemClass,t)
return s?d.onItemSelect(e,s):d.onMouseDown(e)})),g(t,"click",(e=>d.onClick(e))),g(i,"keydown",(e=>d.onKeyDown(e))),g(i,"keyup",(e=>d.onKeyUp(e))),g(i,"keypress",(e=>d.onKeyPress(e))),g(i,"resize",(()=>d.positionDropdown()),u),g(i,"blur",(e=>d.onBlur(e))),g(i,"focus",(e=>{d.ignoreBlur=!1,d.onFocus(e)})),g(i,"paste",(e=>d.onPaste(e)))
var I=e=>{var t=A(e.target,"[data-selectable]",d.dropdown)
for(const e of t)(o={})[n]=e,o[r]=e,g.options.push(o)
g.items=t}})(),Object.assign({},p,g,t)}(s,t),this.input=s,this.tabIndex=s.tabIndex||0,this.is_select_tag="select"===s.tagName.toLowerCase(),this.rtl=/rtl/i.test(i),this.inputId=m(s,"tomselect-"+P),this.isRequired=s.required,this.sifter=new l(this.options,{diacritics:this.settings.diacritics}),this.setupOptions(this.settings.options,this.settings.optgroups),delete this.settings.optgroups,delete this.settings.options,this.settings.mode=this.settings.mode||(1===this.settings.maxItems?"single":"multi"),"boolean"!=typeof this.settings.hideSelected&&(this.settings.hideSelected="multi"===this.settings.mode),"boolean"!=typeof this.settings.hidePlaceholder&&(this.settings.hidePlaceholder="multi"!==this.settings.mode)
var n=this.settings.createFilter
"function"!=typeof n&&("string"==typeof n&&(n=new RegExp(n)),n instanceof RegExp?this.settings.createFilter=e=>n.test(e):this.settings.createFilter=()=>!0),this.initializePlugins(this.settings.plugins),this.setupCallbacks(),this.setupTemplates(),this.setup()}setup(){var e,t,i,s,n,r,o,l,a,d=this,p=d.settings,c=d.input
const u={passive:!0},h=d.inputId+"-ts-dropdown"
if(r=d.settings.mode,o=c.getAttribute("class")||"",w(e=y("<div>"),p.wrapperClass,o,r),w(t=y('<div class="items">'),p.inputClass),e.append(t),w(s=d.render("dropdown"),p.dropdownClass,r),w(n=y(`<div role="listbox" id="${h}" tabindex="-1">`),p.dropdownContentClass),s.append(n),y(p.dropdownParent||e).appendChild(s),p.controlInput)i=y(p.controlInput)
else{i=y('<input type="text" autocomplete="off" size="1" />')
for(const e of["autocorrect","autocapitalize","autocomplete"])c.getAttribute(e)&&F(i,{[e]:c.getAttribute(e)})}p.controlInput||(i.tabIndex=c.disabled?-1:d.tabIndex,t.appendChild(i)),F(i,{role:"combobox",haspopup:"listbox","aria-expanded":"false","aria-controls":h}),a=m(i,d.inputId+"-tomselected")
let v="label[for='"+function(e){return e.replace(/['"\\]/g,"\\$&")}(d.inputId)+"']",O=document.querySelector(v)
if(O){F(O,{for:a}),F(n,{"aria-labelledby":m(O,d.inputId+"-ts-label")})}if(d.settings.copyClassesToDropdown&&w(s,o),e.style.width=c.style.width,d.plugins.names.length&&(l="plugin-"+d.plugins.names.join(" plugin-"),w([e,s],l)),(null===p.maxItems||p.maxItems>1)&&d.is_select_tag&&F(c,{multiple:"multiple"}),d.settings.placeholder&&F(i,{placeholder:p.placeholder}),!d.settings.splitOn&&d.settings.delimiter){var b=d.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")
d.settings.splitOn=new RegExp("\\s*"+b+"+\\s*")}var I,C,A
this.settings.load&&this.settings.loadThrottle&&(this.settings.load=(I=this.settings.load,C=this.settings.loadThrottle,function(e,t){var i=this
A&&(i.loading=Math.max(i.loading-1,0)),clearTimeout(A),A=setTimeout((function(){A=null,i.loadedSearches[e]=!0,I.call(i,e,t)}),C)})),d.control=t,d.control_input=i,d.wrapper=e,d.dropdown=s,d.dropdown_content=n,d.control_input.type=c.type,f(s,"mouseenter",(e=>{var t=_(e.target,"[data-selectable]",s)
if(t)return d.onOptionHover(e,t)}),{capture:!0}),f(t,"mousedown",(e=>{if(e.target==i)return d.clearActiveItems(),e.stopPropagation(),void d.inputState()
var s=_(e.target,"."+d.settings.itemClass,t)
return s?d.onItemSelect(e,s):d.onMouseDown(e)})),f(t,"click",(e=>d.onClick(e))),f(i,"keydown",(e=>d.onKeyDown(e))),f(i,"keyup",(e=>d.onKeyUp(e))),f(i,"keypress",(e=>d.onKeyPress(e))),f(i,"resize",(()=>d.positionDropdown()),u),f(i,"blur",(e=>d.onBlur(e))),f(i,"focus",(e=>{d.ignoreBlur=!1,d.onFocus(e)})),f(i,"paste",(e=>d.onPaste(e)))
var S=e=>{var t=_(e.target,"[data-selectable]",d.dropdown)
if(!t&&!d.wrapper.contains(e.target))return d.isFocused&&d.blur(),void d.inputState()
h(e,!0),t&&d.onOptionSelect(e,t)},C=()=>{d.isOpen&&d.positionDropdown()}
g(document,"mousedown",I),g(window,"sroll",C,u),g(window,"resize",C,u),d._destroy=()=>{document.removeEventListener("mousedown",I),window.removeEventListener("sroll",C),window.removeEventListener("resize",C)},this.revertSettings={innerHTML:c.innerHTML,tabIndex:c.tabIndex},c.tabIndex=-1,x(c,{hidden:"hidden"}),c.insertAdjacentElement("afterend",d.wrapper),d.setValue(p.items),delete p.items,g(c,"invalid",(e=>{h(e),d.isInvalid||(d.isInvalid=!0,d.refreshState())})),d.updateOriginalInput(),d.refreshItems(),d.refreshState(),d.inputState(),d.isSetup=!0,c.disabled&&d.disable(),d.on("change",this.onChange),b(c,"tomselected"),d.trigger("initialize"),!0===p.preload&&d.load("")}setupOptions(e=[],t=[]){for(const t of e)this.registerOption(t)
g(e,!0),t&&d.onOptionSelect(e,t)},x=()=>{d.isOpen&&d.positionDropdown()}
f(document,"mousedown",S),f(window,"sroll",x,u),f(window,"resize",x,u),d._destroy=()=>{document.removeEventListener("mousedown",S),window.removeEventListener("sroll",x),window.removeEventListener("resize",x)},this.revertSettings={innerHTML:c.innerHTML,tabIndex:c.tabIndex},c.tabIndex=-1,F(c,{hidden:"hidden"}),c.insertAdjacentElement("afterend",d.wrapper),d.setValue(p.items),delete p.items,f(c,"invalid",(e=>{g(e),d.isInvalid||(d.isInvalid=!0,d.refreshState())})),d.updateOriginalInput(),d.refreshItems(),d.refreshState(),d.inputState(),d.isSetup=!0,c.disabled&&d.disable(),d.on("change",this.onChange),w(c,"tomselected"),d.trigger("initialize"),!0===p.preload&&d.load("")}setupOptions(e=[],t=[]){for(const t of e)this.registerOption(t)
for(const e of t)this.registerOptionGroup(e)}setupTemplates(){var e=this,t=e.settings.labelField,i=e.settings.optgroupLabelField,s={optgroup:(e,t)=>{let i=document.createElement("div")
return i.className="optgroup",i.appendChild(e.options),i},optgroup_header:(e,t)=>'<div class="optgroup-header">'+t(e[i])+"</div>",option:(e,i)=>"<div>"+i(e[t])+"</div>",item:(e,i)=>"<div>"+i(e[t])+"</div>",option_create:(e,t)=>'<div class="create">Add <strong>'+t(e.input)+"</strong>&hellip;</div>",no_results:(e,t)=>'<div class="no-results">No results found</div>',loading:(e,t)=>'<div class="spinner"></div>',not_loading:()=>{},dropdown:()=>'<div style="display:none"></div>'}
return i.className="optgroup",i.appendChild(e.options),i},optgroup_header:(e,t)=>'<div class="optgroup-header">'+t(e[i])+"</div>",option:(e,i)=>"<div>"+i(e[t])+"</div>",item:(e,i)=>"<div>"+i(e[t])+"</div>",option_create:(e,t)=>'<div class="create">Add <strong>'+t(e.input)+"</strong>&hellip;</div>",no_results:(e,t)=>'<div class="no-results">No results found</div>',loading:(e,t)=>'<div class="spinner"></div>',not_loading:()=>{},dropdown:()=>"<div></div>"}
e.settings.render=Object.assign({},s,e.settings.render)}setupCallbacks(){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)}onClick(e){var t=this
t.isFocused&&t.isOpen||(t.focus(),h(e))}onMouseDown(e){var t=this
t.isFocused&&t.isOpen||(t.focus(),g(e))}onMouseDown(e){var t=this
if(t.isFocused)return"single"!==t.settings.mode&&t.setActiveItem(),t.open(),!1
setTimeout((()=>t.focus()),0)}onChange(){y(this.input,"input"),y(this.input,"change")}onPaste(e){var t=this
t.isFull()||t.isInputHidden||t.isLocked?h(e):t.settings.splitOn&&setTimeout((()=>{var e=t.inputValue()
setTimeout((()=>t.focus()),0)}onChange(){O(this.input,"input"),O(this.input,"change")}onPaste(e){var t=this
t.isFull()||t.isInputHidden||t.isLocked?g(e):t.settings.splitOn&&setTimeout((()=>{var e=t.inputValue()
if(e.match(t.settings.splitOn)){var i=e.trim().split(t.settings.splitOn)
for(const e of i)t.createItem(e)}}),0)}onKeyPress(e){var t=this
if(!t.isLocked){var i=String.fromCharCode(e.keyCode||e.which)
return t.settings.create&&"multi"===t.settings.mode&&i===t.settings.delimiter?(t.createItem(),void h(e)):void 0}h(e)}onKeyDown(e){var t=this
if(t.isLocked)9!==e.keyCode&&h(e)
else{switch(e.keyCode){case 65:if(f(a,e))return void t.selectAll()
return t.settings.create&&"multi"===t.settings.mode&&i===t.settings.delimiter?(t.createItem(),void g(e)):void 0}g(e)}onKeyDown(e){var t=this
if(t.isLocked)9!==e.keyCode&&g(e)
else{switch(e.keyCode){case 65:if(v(d,e))return void t.selectAll()
break
case 27:return t.isOpen&&(h(e,!0),t.close()),void t.clearActiveItems()
case 27:return t.isOpen&&(g(e,!0),t.close()),void t.clearActiveItems()
case 40:if(!t.isOpen&&t.hasOptions)t.open()
else if(t.activeOption){let e=t.getAdjacent(t.activeOption,1)
e&&t.setActiveOption(e)}return void h(e)
e&&t.setActiveOption(e)}return void g(e)
case 38:if(t.activeOption){let e=t.getAdjacent(t.activeOption,-1)
e&&t.setActiveOption(e)}return void h(e)
case 13:return void(t.isOpen&&t.activeOption&&(t.onOptionSelect(e,t.activeOption),h(e)))
e&&t.setActiveOption(e)}return void g(e)
case 13:return void(t.isOpen&&t.activeOption?(t.onOptionSelect(e,t.activeOption),g(e)):t.settings.create&&t.createItem()&&g(e))
case 37:return void t.advanceSelection(-1,e)
case 39:return void t.advanceSelection(1,e)
case 9:return t.settings.selectOnTab&&t.isOpen&&t.activeOption&&(t.tab_key=!0,t.onOptionSelect(e,t.activeOption),h(e),t.tab_key=!1),void(t.settings.create&&t.createItem()&&h(e))
case 8:case 46:return void t.deleteSelection(e)}t.isInputHidden&&!f(a,e)&&h(e)}}onKeyUp(e){var t=this
if(t.isLocked)h(e)
case 9:return void(t.settings.selectOnTab&&(t.isOpen&&t.activeOption&&(t.tab_key=!0,t.onOptionSelect(e,t.activeOption),g(e),t.tab_key=!1),t.settings.create&&t.createItem()&&g(e)))
case 8:case 46:return void t.deleteSelection(e)}t.isInputHidden&&!v(d,e)&&g(e)}}onKeyUp(e){var t=this
if(t.isLocked)g(e)
else{var i=t.inputValue()
t.lastValue!==i&&(t.lastValue=i,t.settings.shouldLoad.call(t,i)&&t.load(i),t.refreshOptions(),t.trigger("type",i))}}onFocus(e){var t=this,i=t.isFocused
if(t.isDisabled)return t.blur(),void h(e)
if(t.isDisabled)return t.blur(),void g(e)
t.ignoreFocus||(t.isFocused=!0,"focus"===t.settings.preload&&t.load(""),i||t.trigger("focus"),t.activeItems.length||(t.showInput(),t.setActiveItem(),t.refreshOptions(!!t.settings.openOnFocus)),t.refreshState())}onBlur(e){var t=this

@@ -142,42 +147,47 @@ if(t.isFocused){if(t.isFocused=!1,t.ignoreFocus=!1,!t.ignoreBlur&&document.activeElement===t.dropdown_content)return t.ignoreBlur=!0,void t.onFocus(e)

t&&(t.parentElement&&t.parentElement.matches("[data-disabled]")||(t.classList.contains("create")?s.createItem(null,!0,(()=>{s.settings.closeAfterSelect&&s.close()})):void 0!==(i=t.dataset.value)&&(s.lastQuery=null,s.addItem(i),s.settings.closeAfterSelect?s.close():!s.settings.hideSelected&&e.type&&/mouse/.test(e.type)&&s.setActiveOption(s.getOption(i)))))}onItemSelect(e,t){var i=this
i.isLocked||"multi"===i.settings.mode&&(h(e),i.setActiveItem(t,e))}load(e){var t=this,i=t.settings.load
i&&(t.loadedSearches.hasOwnProperty(e)||(b(t.wrapper,t.settings.loadingClass),t.loading++,i.call(t,e,(function(e,i){t.loading=Math.max(t.loading-1,0),t.lastQuery=null,t.clearActiveOption(),t.setupOptions(e,i),t.refreshOptions(t.isFocused&&!t.isInputHidden),t.loading||w(t.wrapper,t.settings.loadingClass),t.trigger("load",e,i)}))))}onSearchChange(e){this.load(e)}setTextboxValue(e=""){var t=this.control_input
t.value!==e&&(t.value=e,y(t,"update"),this.lastValue=e)}getValue(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}setValue(e,t){u(this,t?[]:["change"],(()=>{this.clear(t),this.addItems(e,t)}))}setMaxItems(e){0===e&&(e=null),this.settings.maxItems=e,this.refreshState()}setActiveItem(e,t){var i,s,n,o,r,l,d=this
if("single"!==d.settings.mode){if(!e)return d.clearActiveItems(),void(d.isFocused&&d.showInput())
if("mousedown"===(i=t&&t.type.toLowerCase())&&f("shiftKey",t)&&d.activeItems.length){for(l=d.getLastActive(),(n=Array.prototype.indexOf.call(d.control.children,l))>(o=Array.prototype.indexOf.call(d.control.children,e))&&(r=n,n=o,o=r),s=n;s<=o;s++)e=d.control.children[s],-1===d.activeItems.indexOf(e)&&d.setActiveItemClass(e)
h(t)}else"mousedown"===i&&f(a,t)||"keydown"===i&&f("shiftKey",t)?e.classList.contains("active")?d.removeActiveItem(e):d.setActiveItemClass(e):(d.clearActiveItems(),d.setActiveItemClass(e))
d.hideInput(),d.isFocused||d.focus()}}setActiveItemClass(e){var t=this.control.querySelector(".last-active")
t&&w(t,"last-active"),b(e,"active last-active"),-1==this.activeItems.indexOf(e)&&this.activeItems.push(e)}removeActiveItem(e){var t=this.activeItems.indexOf(e)
this.activeItems.splice(t,1),w(e,"active")}clearActiveItems(){w(this.activeItems,"active"),this.activeItems=[]}setActiveOption(e){var t,i,s
i.isLocked||"multi"===i.settings.mode&&(g(e),i.setActiveItem(t,e))}load(e){var t=this,i=t.settings.load
if(!i)return
if(t.loadedSearches.hasOwnProperty(e))return
w(t.wrapper,t.settings.loadingClass),t.loading++
const s=t.loadCallback.bind(t)
i.call(t,e,s)}loadCallback(e,t){const i=this
i.loading=Math.max(i.loading-1,0),i.lastQuery=null,i.clearActiveOption(),i.setupOptions(e,t),i.refreshOptions(i.isFocused&&!i.isInputHidden),i.loading||I(i.wrapper,i.settings.loadingClass),i.trigger("load",e,t)}onSearchChange(e){this.load(e)}setTextboxValue(e=""){var t=this.control_input
t.value!==e&&(t.value=e,O(t,"update"),this.lastValue=e)}getValue(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}setValue(e,t){h(this,t?[]:["change"],(()=>{this.clear(t),this.addItems(e,t)}))}setMaxItems(e){0===e&&(e=null),this.settings.maxItems=e,this.refreshState()}setActiveItem(e,t){var i,s,n,r,o,l,a=this
if("single"!==a.settings.mode){if(!e)return a.clearActiveItems(),void(a.isFocused&&a.showInput())
if("mousedown"===(i=t&&t.type.toLowerCase())&&v("shiftKey",t)&&a.activeItems.length){for(l=a.getLastActive(),(n=Array.prototype.indexOf.call(a.control.children,l))>(r=Array.prototype.indexOf.call(a.control.children,e))&&(o=n,n=r,r=o),s=n;s<=r;s++)e=a.control.children[s],-1===a.activeItems.indexOf(e)&&a.setActiveItemClass(e)
g(t)}else"mousedown"===i&&v(d,t)||"keydown"===i&&v("shiftKey",t)?e.classList.contains("active")?a.removeActiveItem(e):a.setActiveItemClass(e):(a.clearActiveItems(),a.setActiveItemClass(e))
a.hideInput(),a.isFocused||a.focus()}}setActiveItemClass(e){var t=this.control.querySelector(".last-active")
t&&I(t,"last-active"),w(e,"active last-active"),-1==this.activeItems.indexOf(e)&&this.activeItems.push(e)}removeActiveItem(e){var t=this.activeItems.indexOf(e)
this.activeItems.splice(t,1),I(e,"active")}clearActiveItems(){I(this.activeItems,"active"),this.activeItems=[]}setActiveOption(e){var t,i,s
if(e===this.activeOption)return
if(this.clearActiveOption(),!e)return
this.activeOption=e,x(this.control_input,{"aria-activedescendant":e.getAttribute("id")}),x(e,{"aria-selected":"true"}),b(e,"active"),t=this.dropdown_content.clientHeight
this.activeOption=e,F(this.control_input,{"aria-activedescendant":e.getAttribute("id")}),F(e,{"aria-selected":"true"}),w(e,"active"),t=this.dropdown_content.clientHeight
let n=this.dropdown_content.scrollTop||0
i=this.activeOption.offsetHeight,(s=this.activeOption.getBoundingClientRect().top-this.dropdown_content.getBoundingClientRect().top+n)+i>t+n?this.dropdown_content.scrollTop=s-t+i:s<n&&(this.dropdown_content.scrollTop=s)}clearActiveOption(){this.activeOption&&(w(this.activeOption,"active"),this.activeOption.removeAttribute("aria-selected")),this.activeOption=null,this.control_input.removeAttribute("aria-activedescendant")}selectAll(){"single"!==this.settings.mode&&(this.activeItems=this.controlChildren(),this.activeItems.length&&(b(this.activeItems,"active"),this.hideInput(),this.close()),this.focus())}inputState(){var e=this
e.settings.controlInput||(e.activeItems.length>0||!e.isFocused&&this.settings.hidePlaceholder&&e.items.length>0?(e.setTextboxValue(),e.isInputHidden=!0,b(e.wrapper,"input-hidden")):(e.isInputHidden=!1,w(e.wrapper,"input-hidden")))}hideInput(){this.inputState()}showInput(){this.inputState()}inputValue(){return this.control_input.value.trim()}focus(){var e=this
i=this.activeOption.offsetHeight,(s=this.activeOption.getBoundingClientRect().top-this.dropdown_content.getBoundingClientRect().top+n)+i>t+n?this.dropdown_content.scrollTop=s-t+i:s<n&&(this.dropdown_content.scrollTop=s)}clearActiveOption(){this.activeOption&&(I(this.activeOption,"active"),this.activeOption.removeAttribute("aria-selected")),this.activeOption=null,this.control_input.removeAttribute("aria-activedescendant")}selectAll(){"single"!==this.settings.mode&&(this.activeItems=this.controlChildren(),this.activeItems.length&&(w(this.activeItems,"active"),this.hideInput(),this.close()),this.focus())}inputState(){var e=this
e.settings.controlInput||(e.activeItems.length>0||!e.isFocused&&this.settings.hidePlaceholder&&e.items.length>0?(e.setTextboxValue(),e.isInputHidden=!0,w(e.wrapper,"input-hidden")):(e.isInputHidden=!1,I(e.wrapper,"input-hidden")))}hideInput(){this.inputState()}showInput(){this.inputState()}inputValue(){return this.control_input.value.trim()}focus(){var e=this
e.isDisabled||(e.ignoreFocus=!0,e.control_input.focus(),setTimeout((()=>{e.ignoreFocus=!1,e.onFocus()}),0))}blur(){this.control_input.blur(),this.onBlur(null)}getScoreFunction(e){return this.sifter.getScoreFunction(e,this.getSearchOptions())}getSearchOptions(){var e,t=this.settings
return"string"==typeof t.sortField&&(e=[{field:t.sortField}]),{fields:t.searchField,conjunction:t.searchConjunction,sort:e,nesting:t.nesting}}search(e){var t,i,s,n=this,o=n.settings,r=this.getSearchOptions()
if(o.score&&"function"!=typeof(s=n.settings.score.call(n,e)))throw new Error('Tom Select "score" setting must be a function that returns a function')
if(e!==n.lastQuery?(n.lastQuery=e,i=n.sifter.search(e,Object.assign(r,{score:s})),n.currentResults=i):i=Object.assign({},n.currentResults),o.hideSelected)for(t=i.items.length-1;t>=0;t--)-1!==n.items.indexOf(p(i.items[t].id))&&i.items.splice(t,1)
return i}refreshOptions(e=!0){var t,i,s,n,o,r,a,d,c,u,h,g,f,v=this,m=v.inputValue(),y=v.search(m),O=v.activeOption&&p(v.activeOption.dataset.value),b=v.settings.shouldOpen||!1
for(n=y.items.length,"number"==typeof v.settings.maxOptions&&(n=Math.min(n,v.settings.maxOptions)),n>0&&(b=!0),g={},o=[],t=0;t<n;t++){let e=v.options[y.items[t].id],n=p(e[v.settings.valueField]),l=v.getOption(n)
for(l||(l=v.render("option",e)),v.settings.hideSelected||l.classList.toggle("selected",v.items.includes(n)),r=e[v.settings.optgroupField]||"",i=0,s=(a=Array.isArray(r)?r:[r])&&a.length;i<s;i++)r=a[i],v.optgroups.hasOwnProperty(r)||(r=""),g.hasOwnProperty(r)||(g[r]=document.createDocumentFragment(),o.push(r)),i>0&&(l=l.cloneNode(!0),w(l,"active"),l.removeAttribute("aria-selected")),g[r].appendChild(l)}for(r of(this.settings.lockOptgroupOrder&&o.sort(((e,t)=>(v.optgroups[e]&&v.optgroups[e].$order||0)-(v.optgroups[t]&&v.optgroups[t].$order||0))),d=document.createDocumentFragment(),o))if(v.optgroups.hasOwnProperty(r)&&g[r].children.length){let e=document.createDocumentFragment()
e.appendChild(v.render("optgroup_header",v.optgroups[r])),e.appendChild(g[r])
let t=v.render("optgroup",{group:v.optgroups[r],options:e})
d.appendChild(t)}else d.appendChild(g[r])
if(v.dropdown_content.innerHTML="",v.dropdown_content.appendChild(d),v.settings.highlight&&(v.dropdown_content,f=document.querySelectorAll("span.highlight"),Array.prototype.forEach.call(f,(function(e,t){var i=e.parentNode
i.replaceChild(e.firstChild,e),i.normalize()})),y.query.length&&y.tokens.length))for(const e of y.tokens)l(v.dropdown_content,e.regex)
var I=e=>{let t=v.render(e,{input:m})
return"string"==typeof t.sortField&&(e=[{field:t.sortField}]),{fields:t.searchField,conjunction:t.searchConjunction,sort:e,nesting:t.nesting}}search(e){var t,i,s,n=this,r=n.settings,o=this.getSearchOptions()
if(r.score&&"function"!=typeof(s=n.settings.score.call(n,e)))throw new Error('Tom Select "score" setting must be a function that returns a function')
if(e!==n.lastQuery?(n.lastQuery=e,i=n.sifter.search(e,Object.assign(o,{score:s})),n.currentResults=i):i=Object.assign({},n.currentResults),r.hideSelected)for(t=i.items.length-1;t>=0;t--)-1!==n.items.indexOf(c(i.items[t].id))&&i.items.splice(t,1)
return i}refreshOptions(e=!0){var t,i,s,n,r,o,l,d,p,u,h,g,f,v=this,m=v.inputValue(),y=v.search(m),O=v.activeOption&&c(v.activeOption.dataset.value),b=v.settings.shouldOpen||!1
for(n=y.items.length,"number"==typeof v.settings.maxOptions&&(n=Math.min(n,v.settings.maxOptions)),n>0&&(b=!0),g={},r=[],t=0;t<n;t++){let e=v.options[y.items[t].id],n=c(e[v.settings.valueField]),a=v.getOption(n)
for(a||(a=v.render("option",e)),v.settings.hideSelected||a.classList.toggle("selected",v.items.includes(n)),o=e[v.settings.optgroupField]||"",i=0,s=(l=Array.isArray(o)?o:[o])&&l.length;i<s;i++)o=l[i],v.optgroups.hasOwnProperty(o)||(o=""),g.hasOwnProperty(o)||(g[o]=document.createDocumentFragment(),r.push(o)),i>0&&(a=a.cloneNode(!0),I(a,"active"),a.removeAttribute("aria-selected")),g[o].appendChild(a)}for(o of(this.settings.lockOptgroupOrder&&r.sort(((e,t)=>(v.optgroups[e]&&v.optgroups[e].$order||0)-(v.optgroups[t]&&v.optgroups[t].$order||0))),d=document.createDocumentFragment(),r))if(v.optgroups.hasOwnProperty(o)&&g[o].children.length){let e=document.createDocumentFragment()
e.append(v.render("optgroup_header",v.optgroups[o])),e.append(g[o])
let t=v.render("optgroup",{group:v.optgroups[o],options:e})
d.append(t)}else d.append(g[o])
if(v.dropdown_content.innerHTML="",v.dropdown_content.append(d),v.settings.highlight&&(v.dropdown_content,f=document.querySelectorAll("span.highlight"),Array.prototype.forEach.call(f,(function(e,t){var i=e.parentNode
i.replaceChild(e.firstChild,e),i.normalize()})),y.query.length&&y.tokens.length))for(const e of y.tokens)a(v.dropdown_content,e.regex)
var w=e=>{let t=v.render(e,{input:m})
return t&&(b=!0,v.dropdown_content.insertBefore(t,v.dropdown_content.firstChild)),t}
if(v.settings.shouldLoad.call(v,m)?v.loading?I("loading"):0===y.items.length&&I("no_results"):I("not_loading"),(c=v.canCreate(m))&&(h=I("option_create")),v.hasOptions=y.items.length>0||c,b){if(y.items.length>0){if(!(u=O&&v.getOption(O))||!v.dropdown_content.contains(u)){let e=0
if(v.settings.shouldLoad.call(v,m)?v.loading?w("loading"):0===y.items.length&&w("no_results"):w("not_loading"),(p=v.canCreate(m))&&(h=w("option_create")),v.hasOptions=y.items.length>0||p,b){if(y.items.length>0){if(!(u=O&&v.getOption(O))||!v.dropdown_content.contains(u)){let e=0
h&&!v.settings.addPrecedence&&(e=1),u=v.selectable()[e]}}else u=h
v.setActiveOption(u),e&&!v.isOpen&&v.open()}else v.clearActiveOption(),e&&v.isOpen&&v.close()}selectable(){return this.dropdown_content.querySelectorAll("[data-selectable]")}addOption(e){var t,i=this
v.setActiveOption(u),e&&!v.isOpen&&v.open()}else v.clearActiveOption(),e&&v.isOpen&&v.close(!1)}selectable(){return this.dropdown_content.querySelectorAll("[data-selectable]")}addOption(e){var t,i=this
if(Array.isArray(e))for(const t of e)i.addOption(t)
else(t=i.registerOption(e))&&(i.userOptions[t]=!0,i.lastQuery=null,i.trigger("option_add",t,e))}registerOption(e){var t=p(e[this.settings.valueField])
return null!==t&&!this.options.hasOwnProperty(t)&&(e.$order=e.$order||++this.order,e.$id=this.inputId+"-opt-"+this.options_i++,this.options[t]=e,t)}registerOptionGroup(e){var t=p(e[this.settings.optgroupValueField])
else(t=i.registerOption(e))&&(i.userOptions[t]=!0,i.lastQuery=null,i.trigger("option_add",t,e))}registerOption(e){var t=c(e[this.settings.valueField])
return null!==t&&!this.options.hasOwnProperty(t)&&(e.$order=e.$order||++this.order,e.$id=this.inputId+"-opt-"+this.options_i++,this.options[t]=e,t)}registerOptionGroup(e){var t=c(e[this.settings.optgroupValueField])
return null!==t&&(e.$order=e.$order||++this.order,this.optgroups[t]=e,t)}addOptionGroup(e,t){var i
t[this.settings.optgroupValueField]=e,(i=this.registerOptionGroup(t))&&this.trigger("optgroup_add",i,t)}removeOptionGroup(e){this.optgroups.hasOwnProperty(e)&&(delete this.optgroups[e],this.clearCache(),this.trigger("optgroup_remove",e))}clearOptionGroups(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")}updateOption(e,t){var i,s,n,o,r,l,a,d=this
if(e=p(e),n=p(t[d.settings.valueField]),null!==e&&d.options.hasOwnProperty(e)){if("string"!=typeof n)throw new Error("Value must be set in option data")
a=d.options[e].$order,n!==e&&(delete d.options[e],-1!==(o=d.items.indexOf(e))&&d.items.splice(o,1,n)),t.$order=t.$order||a,d.options[n]=t,r=d.renderCache.item,l=d.renderCache.option,r&&(delete r[e],delete r[n]),l&&(delete l[e],delete l[n]),-1!==d.items.indexOf(n)&&(i=d.getItem(e),s=d.render("item",t),i.classList.contains("active")&&b(s,"active"),i.parentNode.insertBefore(s,i),i.remove()),d.lastQuery=null,d.isOpen&&d.refreshOptions(!1)}}removeOption(e,t){var i=this
e=p(e)
t[this.settings.optgroupValueField]=e,(i=this.registerOptionGroup(t))&&this.trigger("optgroup_add",i,t)}removeOptionGroup(e){this.optgroups.hasOwnProperty(e)&&(delete this.optgroups[e],this.clearCache(),this.trigger("optgroup_remove",e))}clearOptionGroups(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")}updateOption(e,t){var i,s,n,r,o,l,a,d=this
if(e=c(e),n=c(t[d.settings.valueField]),null!==e&&d.options.hasOwnProperty(e)){if("string"!=typeof n)throw new Error("Value must be set in option data")
a=d.options[e].$order,n!==e&&(delete d.options[e],-1!==(r=d.items.indexOf(e))&&d.items.splice(r,1,n)),t.$order=t.$order||a,d.options[n]=t,o=d.renderCache.item,l=d.renderCache.option,o&&(delete o[e],delete o[n]),l&&(delete l[e],delete l[n]),-1!==d.items.indexOf(n)&&(i=d.getItem(e),s=d.render("item",t),i.classList.contains("active")&&w(s,"active"),i.parentNode.insertBefore(s,i),i.remove()),d.lastQuery=null,d.isOpen&&d.refreshOptions(!1)}}removeOption(e,t){var i=this
e=c(e)
var s=i.renderCache.item,n=i.renderCache.option

@@ -189,3 +199,3 @@ s&&delete s[e],n&&delete n[e],delete i.userOptions[e],delete i.options[e],i.lastQuery=null,i.trigger("option_remove",e),i.removeItem(e,t)}clearOptions(){this.loadedSearches={},this.userOptions={},this.clearCache()

if(e){s="item"==i?this.controlChildren():this.dropdown_content.querySelectorAll("[data-selectable]")
for(let i=0;i<s.length;i++)if(s[i]==e)return t>0?s[i+1]:s[i-1]}}getElementWithValue(e,t){if(null!==(e=p(e)))for(const i of t){let t=i
for(let i=0;i<s.length;i++)if(s[i]==e)return t>0?s[i+1]:s[i-1]}}getElementWithValue(e,t){if(null!==(e=c(e)))for(const i of t){let t=i
if(t.getAttribute("data-value")===e)return t}}getItem(e){return this.getElementWithValue(e,this.control.children)}addItems(e,t){var i=this

@@ -197,14 +207,14 @@ i.buffer=document.createDocumentFragment()

var n=i.control
n.insertBefore(i.buffer,n.firstChild),i.buffer=null}addItem(e,t){u(this,t?[]:["change"],(()=>{var i,s,n=this,o=n.settings.mode
if(e=p(e),(-1===n.items.indexOf(e)||("single"===o&&n.close(),"single"!==o&&n.settings.duplicates))&&n.options.hasOwnProperty(e)&&("single"===o&&n.clear(t),"multi"!==o||!n.isFull())){if(i=n.render("item",n.options[e]),n.control.contains(i)&&(i=i.cloneNode(!0)),s=n.isFull(),n.items.splice(n.caretPos,0,e),n.insertAtCaret(i),n.isSetup){let s=n.selectable()
n.insertBefore(i.buffer,n.firstChild),i.buffer=null}addItem(e,t){h(this,t?[]:["change"],(()=>{var i,s,n=this,r=n.settings.mode
if(e=c(e),(-1===n.items.indexOf(e)||("single"===r&&n.close(),"single"!==r&&n.settings.duplicates))&&n.options.hasOwnProperty(e)&&("single"===r&&n.clear(t),"multi"!==r||!n.isFull())){if(i=n.render("item",n.options[e]),n.control.contains(i)&&(i=i.cloneNode(!0)),s=n.isFull(),n.items.splice(n.caretPos,0,e),n.insertAtCaret(i),n.isSetup){let s=n.selectable()
if(!n.isPending){let t=n.getOption(e),i=n.getAdjacent(t,1)
n.refreshOptions(n.isFocused&&"single"!==o),i&&n.setActiveOption(i)}!s.length||n.isFull()?n.close():n.isPending||n.positionDropdown(),n.trigger("item_add",e,i),n.isPending||n.updateOriginalInput({silent:t})}(!n.isPending||!s&&n.isFull())&&n.refreshState()}}))}removeItem(e,t){var i,s,n=this,o=n.getItem(e)
o&&(e=p(o.dataset.value),-1!==(i=n.items.indexOf(e))&&(o.remove(),o.classList.contains("active")&&(s=n.activeItems.indexOf(o),n.activeItems.splice(s,1),w(o,"active")),n.items.splice(i,1),n.lastQuery=null,!n.settings.persist&&n.userOptions.hasOwnProperty(e)&&n.removeOption(e,t),i<n.caretPos&&n.setCaret(n.caretPos-1),n.updateOriginalInput({silent:t}),n.refreshState(),n.positionDropdown(),n.trigger("item_remove",e,o)))}createItem(e,t=!0,i){var s,n=this,o=n.caretPos
n.refreshOptions(n.isFocused&&"single"!==r),i&&n.setActiveOption(i)}!s.length||n.isFull()?n.close():n.isPending||n.positionDropdown(),n.trigger("item_add",e,i),n.isPending||n.updateOriginalInput({silent:t})}(!n.isPending||!s&&n.isFull())&&n.refreshState()}}))}removeItem(e,t){var i,s,n=this,r=n.getItem(e)
r&&(e=c(r.dataset.value),-1!==(i=n.items.indexOf(e))&&(r.remove(),r.classList.contains("active")&&(s=n.activeItems.indexOf(r),n.activeItems.splice(s,1),I(r,"active")),n.items.splice(i,1),n.lastQuery=null,!n.settings.persist&&n.userOptions.hasOwnProperty(e)&&n.removeOption(e,t),i<n.caretPos&&n.setCaret(n.caretPos-1),n.updateOriginalInput({silent:t}),n.refreshState(),n.positionDropdown(),n.trigger("item_remove",e,r)))}createItem(e,t=!0,i){var s,n=this,r=n.caretPos
if(e=e||n.inputValue(),"function"!=typeof i&&(i=()=>{}),!n.canCreate(e))return i(),!1
n.lock()
var r=!1,l=e=>{if(n.unlock(),!e||"object"!=typeof e)return i()
var s=p(e[n.settings.valueField])
var o=!1,l=e=>{if(n.unlock(),!e||"object"!=typeof e)return i()
var s=c(e[n.settings.valueField])
if("string"!=typeof s)return i()
n.setTextboxValue(),n.addOption(e),n.setCaret(o),n.addItem(s),n.refreshOptions(t&&"single"!==n.settings.mode),i(e),r=!0}
return s="function"==typeof n.settings.create?n.settings.create.call(this,e,l):{[n.settings.labelField]:e,[n.settings.valueField]:e},r||l(s),!0}refreshItems(){var e=this
n.setTextboxValue(),n.addOption(e),n.setCaret(r),n.addItem(s),n.refreshOptions(t&&"single"!==n.settings.mode),i(e),o=!0}
return s="function"==typeof n.settings.create?n.settings.create.call(this,e,l):{[n.settings.labelField]:e,[n.settings.valueField]:e},o||l(s),!0}refreshItems(){var e=this
e.lastQuery=null,e.isSetup&&e.addItems(e.items),e.updateOriginalInput(),e.refreshState()}refreshState(){var e=this

@@ -219,32 +229,32 @@ e.refreshValidityState()

e.isInvalid=t,e.control_input.required=t,this.isRequired&&(e.input.required=!t)}}isFull(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems}updateOriginalInput(e={}){var t,i,s=this
if(s.is_select_tag)for(s.input.querySelectorAll("option[selected]").forEach((e=>{-1==s.items.indexOf(e.value)&&e.removeAttribute("selected")})),t=s.items.length-1;t>=0;t--){var n
if(s.is_select_tag)for(s.input.querySelectorAll("option[selected]").forEach((e=>{-1==s.items.indexOf(e.value)&&(e.selected=!1,e.removeAttribute("selected"))})),t=s.items.length-1;t>=0;t--){var n
if(i=s.items[t],!(n=s.options[i].$option)){const e=s.options[i][s.settings.labelField]||""
n=m('<option value="'+c(i)+'">'+c(e)+"</option>"),s.options[i].$option=n}x(n,{selected:"true"}),s.input.prepend(n)}else s.input.value=s.getValue()
n=y('<option value="'+u(i)+'">'+u(e)+"</option>"),s.options[i].$option=n}n.selected=!0,F(n,{selected:"true"}),s.input.prepend(n)}else s.input.value=s.getValue()
s.isSetup&&(e.silent||s.trigger("change",s.getValue()))}open(){var e=this
e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.isOpen=!0,x(e.control_input,{"aria-expanded":"true"}),e.refreshState(),O(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),O(e.dropdown,{visibility:"visible",display:"block"}),e.focus(),e.trigger("dropdown_open",e.dropdown))}close(){var e=this,t=e.isOpen
"single"===e.settings.mode&&e.items.length&&(e.hideInput(),e.tab_key||e.blur()),e.isOpen=!1,x(e.control_input,{"aria-expanded":"false"}),O(e.dropdown,{display:"none"}),e.clearActiveOption(),e.refreshState(),e.setTextboxValue(),t&&e.trigger("dropdown_close",e.dropdown)}positionDropdown(){if("body"===this.settings.dropdownParent){var e=this.control,t=e.getBoundingClientRect(),i=e.offsetHeight+t.top+window.scrollY,s=t.left+window.scrollX
O(this.dropdown,{width:t.width+"px",top:i+"px",left:s+"px"})}}clear(e){var t=this
e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.isOpen=!0,F(e.control_input,{"aria-expanded":"true"}),e.refreshState(),b(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),b(e.dropdown,{visibility:"visible",display:"block"}),e.focus(),e.trigger("dropdown_open",e.dropdown))}close(e=!0){var t=this,i=t.isOpen
e&&t.setTextboxValue(),"single"===t.settings.mode&&t.items.length&&(t.hideInput(),t.tab_key||t.blur()),t.isOpen=!1,F(t.control_input,{"aria-expanded":"false"}),b(t.dropdown,{display:"none"}),t.clearActiveOption(),t.refreshState(),i&&t.trigger("dropdown_close",t.dropdown)}positionDropdown(){if("body"===this.settings.dropdownParent){var e=this.control,t=e.getBoundingClientRect(),i=e.offsetHeight+t.top+window.scrollY,s=t.left+window.scrollX
b(this.dropdown,{width:t.width+"px",top:i+"px",left:s+"px"})}}clear(e){var t=this
if(t.items.length){var i=t.controlChildren()
for(const e of i)e.remove()
t.items=[],t.lastQuery=null,t.setCaret(0),t.setActiveItem(),t.updateOriginalInput({silent:e}),t.refreshState(),t.showInput(),t.trigger("clear")}}insertAtCaret(e){var t=this,i=Math.min(t.caretPos,t.items.length),s=t.buffer||t.control
0===i?s.insertBefore(e,s.firstChild):s.insertBefore(e,s.children[i]),t.setCaret(i+1)}deleteSelection(e){var t,i,s,n,o,r=this
if(t=e&&8===e.keyCode?-1:1,i={start:(o=r.control_input).selectionStart,length:o.selectionEnd-o.selectionStart},s=[],r.activeItems.length){n=S(_(r.activeItems,t)),t>0&&n++
for(const e of r.activeItems)s.push(e.dataset.value)}else(r.isFocused||"single"===r.settings.mode)&&r.items.length&&(t<0&&0===i.start&&0===i.length?s.push(r.items[r.caretPos-1]):t>0&&i.start===r.inputValue().length&&s.push(r.items[r.caretPos]))
if(!s.length||"function"==typeof r.settings.onDelete&&!1===r.settings.onDelete.call(r,s,e))return!1
for(h(e,!0),void 0!==n&&r.setCaret(n);s.length;)r.removeItem(s.pop())
return r.showInput(),r.positionDropdown(),r.refreshOptions(!1),!0}advanceSelection(e,t){var i,s,n,o=this
o.rtl&&(e*=-1),o.inputValue().length||(f(a,t)||f("shiftKey",t)?(n=(s=o.getLastActive(e))?s.classList.contains("active")?o.getAdjacent(s,e,"item"):s:e>0?o.control_input.nextElementSibling:o.control_input.previousElementSibling)&&(n.classList.contains("active")&&o.removeActiveItem(s),o.setActiveItemClass(n)):o.isFocused&&!o.activeItems.length?o.setCaret(o.caretPos+e):(s=o.getLastActive(e))&&(i=S(s),o.setCaret(e>0?i+1:i),o.setActiveItem()))}getLastActive(e){let t=this.control.querySelector(".last-active")
0===i?s.insertBefore(e,s.firstChild):s.insertBefore(e,s.children[i]),t.setCaret(i+1)}deleteSelection(e){var t,i,s,n,r,o=this
if(t=e&&8===e.keyCode?-1:1,i={start:(r=o.control_input).selectionStart,length:r.selectionEnd-r.selectionStart},s=[],o.activeItems.length){n=x(S(o.activeItems,t)),t>0&&n++
for(const e of o.activeItems)s.push(e.dataset.value)}else(o.isFocused||"single"===o.settings.mode)&&o.items.length&&(t<0&&0===i.start&&0===i.length?s.push(o.items[o.caretPos-1]):t>0&&i.start===o.inputValue().length&&s.push(o.items[o.caretPos]))
if(!s.length||"function"==typeof o.settings.onDelete&&!1===o.settings.onDelete.call(o,s,e))return!1
for(g(e,!0),void 0!==n&&o.setCaret(n);s.length;)o.removeItem(s.pop())
return o.showInput(),o.positionDropdown(),o.refreshOptions(!1),!0}advanceSelection(e,t){var i,s,n,r=this
r.rtl&&(e*=-1),r.inputValue().length||(v(d,t)||v("shiftKey",t)?(n=(s=r.getLastActive(e))?s.classList.contains("active")?r.getAdjacent(s,e,"item"):s:e>0?r.control_input.nextElementSibling:r.control_input.previousElementSibling)&&(n.classList.contains("active")&&r.removeActiveItem(s),r.setActiveItemClass(n)):r.isFocused&&!r.activeItems.length?r.setCaret(r.caretPos+e):(s=r.getLastActive(e))&&(i=x(s),r.setCaret(e>0?i+1:i),r.setActiveItem()))}getLastActive(e){let t=this.control.querySelector(".last-active")
if(t)return t
var i=this.control.querySelectorAll(".active")
return i?_(i,e):void 0}setCaret(e){var t=this
return i?S(i,e):void 0}setCaret(e){var t=this
"single"===t.settings.mode||t.settings.controlInput?e=t.items.length:(e=Math.max(0,Math.min(t.items.length,e)))==t.caretPos||t.isPending||t.controlChildren().forEach(((i,s)=>{s<e?t.control_input.insertAdjacentElement("beforebegin",i):t.control.appendChild(i)})),t.caretPos=e}controlChildren(){return Array.from(this.control.getElementsByClassName(this.settings.itemClass))}lock(){this.close(),this.isLocked=!0,this.refreshState()}unlock(){this.isLocked=!1,this.refreshState()}disable(){var e=this
e.input.disabled=!0,e.control_input.disabled=!0,e.control_input.tabIndex=-1,e.isDisabled=!0,e.lock()}enable(){var e=this
e.input.disabled=!1,e.control_input.disabled=!1,e.control_input.tabIndex=e.tabIndex,e.isDisabled=!1,e.unlock()}destroy(){var e=this,t=e.revertSettings
e.trigger("destroy"),e.off(),e.wrapper.remove(),e.dropdown.remove(),e.input.innerHTML=t.innerHTML,e.input.tabIndex=t.tabIndex,w(e.input,"tomselected"),e.input.removeAttribute("hidden"),e.input.required=this.isRequired,e._destroy(),delete e.input.tomselect}render(e,t){var i,s,n=this
if(("option"===e||"item"===e)&&(i=p(t[n.settings.valueField]),n.renderCache[e].hasOwnProperty(i)))return n.renderCache[e][i]
var o=n.settings.render[e]
return"function"!=typeof o?null:(s=o.call(this,t,c))?(s=m(s),"option"===e||"option_create"===e?t[n.settings.disabledField]?x(s,{"aria-disabled":"true"}):x(s,{"data-selectable":""}):"optgroup"===e&&(x(s,{"data-group":t.group[n.settings.optgroupValueField]}),t.group[n.settings.disabledField]&&x(s,{"data-disabled":""})),"option"!==e&&"item"!==e||(x(s,{"data-value":i}),"item"===e?b(s,n.settings.itemClass):(b(s,n.settings.optionClass),x(s,{role:"option",id:t.$id})),n.renderCache[e][i]=s),s):s}clearCache(e){void 0===e?this.renderCache={item:{},option:{}}:this.renderCache[e]={}}canCreate(e){return this.settings.create&&e.length&&this.settings.createFilter.call(this,e)}hook(e,t,i){var s=this,n=s[t]
s[t]=function(){var t,o
return"after"===e&&(t=n.apply(s,arguments)),o=i.apply(s,arguments),"instead"===e?o:("before"===e&&(t=n.apply(s,arguments)),t)}}}return P}))
e.trigger("destroy"),e.off(),e.wrapper.remove(),e.dropdown.remove(),e.input.innerHTML=t.innerHTML,e.input.tabIndex=t.tabIndex,I(e.input,"tomselected"),e.input.removeAttribute("hidden"),e.input.required=this.isRequired,e._destroy(),delete e.input.tomselect}render(e,t){var i,s,n=this
if(("option"===e||"item"===e)&&(i=c(t[n.settings.valueField]),n.renderCache[e].hasOwnProperty(i)))return n.renderCache[e][i]
var r=n.settings.render[e]
return"function"!=typeof r?null:(s=r.call(this,t,u))?(s=y(s),"option"===e||"option_create"===e?t[n.settings.disabledField]?F(s,{"aria-disabled":"true"}):F(s,{"data-selectable":""}):"optgroup"===e&&(F(s,{"data-group":t.group[n.settings.optgroupValueField]}),t.group[n.settings.disabledField]&&F(s,{"data-disabled":""})),"option"!==e&&"item"!==e||(F(s,{"data-value":i}),"item"===e?w(s,n.settings.itemClass):(w(s,n.settings.optionClass),F(s,{role:"option",id:t.$id})),n.renderCache[e][i]=s),s):s}clearCache(e){void 0===e?this.renderCache={item:{},option:{}}:this.renderCache[e]={}}canCreate(e){return this.settings.create&&e.length&&this.settings.createFilter.call(this,e)}hook(e,t,i){var s=this,n=s[t]
s[t]=function(){var t,r
return"after"===e&&(t=n.apply(s,arguments)),r=i.apply(s,arguments),"instead"===e?r:("before"===e&&(t=n.apply(s,arguments)),t)}}}return k}))
var tomSelect=function(e,t){return new TomSelect(e,t)}
//# sourceMappingURL=tom-select.base.min.js.map
/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -9,50 +9,54 @@ */

e in this._events!=!1&&this._events[e].splice(this._events[e].indexOf(i),1)})):this._events={}}trigger(t,...i){var s=this
e(t,(e=>{if(e in s._events!=!1)for(let t of s._events[e])t.apply(s,i)}))}}var i=function(e,t){return"number"==typeof e&&"number"==typeof t?e>t?1:e<t?-1:0:(e=o(String(e||"")))>(t=o(String(t||"")))?1:t>e?-1:0},s=function(e,t,i){if(e&&t){if(!i)return e[t]
for(var s=t.split(".");s.length&&(e=e[s.shift()]););return e}},n={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ŹźẐẑŽžŻżẒẓẔẕƵƶ]"},o=function(){var e,t,i,s,o="",r={}
for(i in n)if(n.hasOwnProperty(i))for(o+=s=n[i].substring(2,n[i].length-1),e=0,t=s.length;e<t;e++)r[s.charAt(e)]=i
var a=new RegExp("["+o+"]","g")
e(t,(e=>{if(e in s._events!=!1)for(let t of s._events[e])t.apply(s,i)}))}}var i=function(e,t){return"number"==typeof e&&"number"==typeof t?e>t?1:e<t?-1:0:(e=r(String(e||"")))>(t=r(String(t||"")))?1:t>e?-1:0},s=function(e,t,i){if(e&&t){if(!i)return e[t]
for(var s=t.split(".");s.length&&(e=e[s.shift()]););return e}},n=function(e){return(e+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")},o={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ŹźẐẑŽžŻżẒẓẔẕƵƶ]"},r=function(){var e,t,i,s,n="",r={}
for(i in o)if(o.hasOwnProperty(i))for(n+=s=o[i].substring(2,o[i].length-1),e=0,t=s.length;e<t;e++)r[s.charAt(e)]=i
var a=new RegExp("["+n+"]","g")
return function(e){return e.replace(a,(function(e){return r[e]})).toLowerCase()}}()
class r{constructor(e,t){this.items=void 0,this.settings=void 0,this.items=e,this.settings=t||{diacritics:!0}}tokenize(e,t){if(!(e=String(e||"").toLowerCase().trim())||!e.length)return[]
var i,s,o,r,a=[],l=e.split(/ +/)
for(i=0,s=l.length;i<s;i++){if(o=(l[i]+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1"),this.settings.diacritics)for(r in n)n.hasOwnProperty(r)&&(o=o.replace(new RegExp(r,"g"),n[r]))
t&&(o="\\b"+o),a.push({string:l[i],regex:new RegExp(o,"i")})}return a}iterator(e,t){(Array.isArray(e)?Array.prototype.forEach||function(e){for(var t=0,i=this.length;t<i;t++)e(this[t],t,this)}:function(e){for(var t in this)this.hasOwnProperty(t)&&e(this[t],t,this)}).apply(e,[t])}getScoreFunction(e,t){var i,n,o,r,a
class a{constructor(e,t){this.items=void 0,this.settings=void 0,this.items=e,this.settings=t||{diacritics:!0}}tokenize(e,t){if(!(e=String(e||"").toLowerCase().trim())||!e.length)return[]
var i,s=[],r=e.split(/\s+/)
const a=new RegExp("^("+t.fields.map(n).join("|")+"):(.*)$")
return r.forEach((e=>{let r,l=null,d=null
if(t.fields.length>1&&(r=e.match(a))&&(l=r[1],e=r[2]),e.length>0){if(d=n(e),this.settings.diacritics)for(i in o)o.hasOwnProperty(i)&&(d=d.replace(new RegExp(i,"g"),o[i]))
t.respect_word_boundaries&&(d="\\b"+d),d=new RegExp(d,"i")}s.push({string:e,regex:d,field:l})})),s}iterator(e,t){(Array.isArray(e)?Array.prototype.forEach||function(e){for(var t=0,i=this.length;t<i;t++)e(this[t],t,this)}:function(e){for(var t in this)this.hasOwnProperty(t)&&e(this[t],t,this)}).apply(e,[t])}getScoreFunction(e,t){var i,n,o,r,a
a=this.prepareSearch(e,t),n=a.tokens,i=a.options.fields,o=n.length,r=a.options.nesting
var l,d=function(e,t){var i,s
return e?-1===(s=(e=String(e||"")).search(t.regex))?0:(i=t.string.length/e.length,0===s&&(i+=.5),i):0},p=(l=i.length)?1===l?function(e,t){return d(s(t,i[0],r),e)}:function(e,t){for(var n=0,o=0;n<l;n++)o+=d(s(t,i[n],r),e)
return o/l}:function(){return 0}
return o?1===o?function(e){return p(n[0],e)}:"and"===a.options.conjunction?function(e){for(var t,i=0,s=0;i<o;i++){if((t=p(n[i],e))<=0)return 0
s+=t}return s/o}:function(e){for(var t=0,i=0;t<o;t++)i+=p(n[t],e)
return i/o}:function(){return 0}}getSortFunction(e,t){var n,o,r,a,l,d,p,c,u,h,g
return e?-1===(s=(e=String(e||"")).search(t.regex))?0:(i=t.string.length/e.length,0===s&&(i+=.5),i):0},c=(l=i.length)?1===l?function(e,t){return d(s(t,i[0],r),e)}:function(e,t){var n=0
if(e.field){const i=s(t,e.field,r)
!e.regex&&i?n+=.1:n+=d(i,e)}else i.forEach((i=>{n+=d(s(t,i,r),e)}))
return n/l}:function(){return 0}
return o?1===o?function(e){return c(n[0],e)}:"and"===a.options.conjunction?function(e){for(var t,i=0,s=0;i<o;i++){if((t=c(n[i],e))<=0)return 0
s+=t}return s/o}:function(e){for(var t=0,i=0;t<o;t++)i+=c(n[t],e)
return i/o}:function(){return 0}}getSortFunction(e,t){var n,o,r,a,l,d,c,p,u,h,g
if(g=!(e=(r=this).prepareSearch(e,t)).query&&t.sort_empty||t.sort,u=function(e,i){return"$score"===e?i.score:s(r.items[i.id],e,t.nesting)},l=[],g)for(n=0,o=g.length;n<o;n++)(e.query||"$score"!==g[n].field)&&l.push(g[n])
if(e.query){for(h=!0,n=0,o=l.length;n<o;n++)if("$score"===l[n].field){h=!1
break}h&&l.unshift({field:"$score",direction:"desc"})}else for(n=0,o=l.length;n<o;n++)if("$score"===l[n].field){l.splice(n,1)
break}for(c=[],n=0,o=l.length;n<o;n++)c.push("desc"===l[n].direction?-1:1)
return(d=l.length)?1===d?(a=l[0].field,p=c[0],function(e,t){return p*i(u(a,e),u(a,t))}):function(e,t){var s,n,o
for(s=0;s<d;s++)if(o=l[s].field,n=c[s]*i(u(o,e),u(o,t)))return n
break}for(p=[],n=0,o=l.length;n<o;n++)p.push("desc"===l[n].direction?-1:1)
return(d=l.length)?1===d?(a=l[0].field,c=p[0],function(e,t){return c*i(u(a,e),u(a,t))}):function(e,t){var s,n,o
for(s=0;s<d;s++)if(o=l[s].field,n=p[s]*i(u(o,e),u(o,t)))return n
return 0}:null}prepareSearch(e,t){if("object"==typeof e)return e
var i=(t=Object.assign({},t)).fields,s=t.sort,n=t.sort_empty
return i&&!Array.isArray(i)&&(t.fields=[i]),s&&!Array.isArray(s)&&(t.sort=[s]),n&&!Array.isArray(n)&&(t.sort_empty=[n]),{options:t,query:String(e||"").toLowerCase(),tokens:this.tokenize(e,t.respect_word_boundaries),total:0,items:[]}}search(e,t){var i,s,n,o,r=this
return s=this.prepareSearch(e,t),t=s.options,e=s.query,o=t.score||r.getScoreFunction(s),e.length?r.iterator(r.items,(function(e,n){i=o(e),(!1===t.filter||i>0)&&s.items.push({score:i,id:n})})):r.iterator(r.items,(function(e,t){s.items.push({score:1,id:t})})),(n=r.getSortFunction(s,t))&&s.items.sort(n),s.total=s.items.length,"number"==typeof t.limit&&(s.items=s.items.slice(0,t.limit)),s}}function a(e,t){if("string"!=typeof t||t.length){var i="string"==typeof t?new RegExp(t,"i"):t
!function e(t){var s=0
if(3===t.nodeType){var n=t.data.search(i)
if(n>=0&&t.data.length>0){var o=t.data.match(i),r=document.createElement("span")
return i&&!Array.isArray(i)&&(t.fields=[i]),s&&!Array.isArray(s)&&(t.sort=[s]),n&&!Array.isArray(n)&&(t.sort_empty=[n]),{options:t,query:String(e||"").toLowerCase(),tokens:this.tokenize(e,t),total:0,items:[]}}search(e,t){var i,s,n,o,r=this
return s=this.prepareSearch(e,t),t=s.options,e=s.query,o=t.score||r.getScoreFunction(s),e.length?r.iterator(r.items,(function(e,n){i=o(e),(!1===t.filter||i>0)&&s.items.push({score:i,id:n})})):r.iterator(r.items,(function(e,t){s.items.push({score:1,id:t})})),(n=r.getSortFunction(s,t))&&s.items.sort(n),s.total=s.items.length,"number"==typeof t.limit&&(s.items=s.items.slice(0,t.limit)),s}}function l(e,t){if(null!==t){if("string"==typeof t){if(!t.length)return
t=new RegExp(t,"i")}!function e(i){var s=0
if(3===i.nodeType){var n=i.data.search(t)
if(n>=0&&i.data.length>0){var o=i.data.match(t),r=document.createElement("span")
r.className="highlight"
var a=t.splitText(n)
var a=i.splitText(n)
a.splitText(o[0].length)
var l=a.cloneNode(!0)
r.appendChild(l),a.parentNode.replaceChild(r,a),s=1}}else if(1===t.nodeType&&t.childNodes&&!/(script|style)/i.test(t.tagName)&&("highlight"!==t.className||"SPAN"!==t.tagName))for(var d=0;d<t.childNodes.length;++d)d+=e(t.childNodes[d])
return s}(e)}}const l="undefined"!=typeof navigator&&/Mac/.test(navigator.userAgent)?"metaKey":"ctrlKey"
var d={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:null,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,shouldOpen:null,maxOptions:50,maxItems:null,hideSelected:null,duplicates:!1,addPrecedence:!1,selectOnTab:!1,preload:null,allowEmptyOption:!1,closeAfterSelect:!1,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,placeholder:null,hidePlaceholder:null,shouldLoad:function(e){return e.length>0},render:{}}
function p(e){return null==e?null:"boolean"==typeof e?e?"1":"0":e+""}function c(e){return(e+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function u(e,t,i){var s,n=e.trigger,o={}
r.appendChild(l),a.parentNode.replaceChild(r,a),s=1}}else if(1===i.nodeType&&i.childNodes&&!/(script|style)/i.test(i.tagName)&&("highlight"!==i.className||"SPAN"!==i.tagName))for(var d=0;d<i.childNodes.length;++d)d+=e(i.childNodes[d])
return s}(e)}}const d="undefined"!=typeof navigator&&/Mac/.test(navigator.userAgent)?"metaKey":"ctrlKey"
var c={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:null,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,shouldOpen:null,maxOptions:50,maxItems:null,hideSelected:null,duplicates:!1,addPrecedence:!1,selectOnTab:!1,preload:null,allowEmptyOption:!1,closeAfterSelect:!1,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,placeholder:null,hidePlaceholder:null,shouldLoad:function(e){return e.length>0},render:{}}
function p(e){return null==e?null:"boolean"==typeof e?e?"1":"0":e+""}function u(e){return(e+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function h(e,t,i){var s,n=e.trigger,o={}
for(s in e.trigger=function(){var i=arguments[0]
if(-1===t.indexOf(i))return n.apply(e,arguments)
o[i]=arguments},i.apply(e,[]),e.trigger=n,o)n.apply(e,o[s])}function h(e,t=!1){e&&(e.preventDefault(),t&&e.stopPropagation())}function g(e,t,i,s){e.addEventListener(t,i,s)}function f(e,t){return!!t&&(!!t[e]&&1===(t.altKey?1:0)+(t.ctrlKey?1:0)+(t.shiftKey?1:0)+(t.metaKey?1:0))}function v(e,t){const i=e.getAttribute("id")
return i||(e.setAttribute("id",t),t)}function m(e,t){var i=Object.assign({},d,t),s=i.dataAttr,n=i.labelField,o=i.valueField,r=i.disabledField,a=i.optgroupField,l=i.optgroupLabelField,c=i.optgroupValueField,u=e.tagName.toLowerCase(),h=e.getAttribute("placeholder")||e.getAttribute("data-placeholder")
o[i]=arguments},i.apply(e,[]),e.trigger=n,o)n.apply(e,o[s])}function g(e,t=!1){e&&(e.preventDefault(),t&&e.stopPropagation())}function f(e,t,i,s){e.addEventListener(t,i,s)}function v(e,t){return!!t&&(!!t[e]&&1===(t.altKey?1:0)+(t.ctrlKey?1:0)+(t.shiftKey?1:0)+(t.metaKey?1:0))}function m(e,t){const i=e.getAttribute("id")
return i||(e.setAttribute("id",t),t)}function y(e,t){var i=Object.assign({},c,t),s=i.dataAttr,n=i.labelField,o=i.valueField,r=i.disabledField,a=i.optgroupField,l=i.optgroupLabelField,d=i.optgroupValueField,u=e.tagName.toLowerCase(),h=e.getAttribute("placeholder")||e.getAttribute("data-placeholder")
if(!h&&!i.allowEmptyOption){let t=e.querySelector('option[value=""]')
t&&(h=t.textContent)}var g={placeholder:h,options:[],optgroups:[],items:[],maxItems:null}
return"select"===u?(()=>{var t,d=g.options,u={},h=1,f=e=>{var t=Object.assign({},e.dataset),i=s&&t[s]
return"select"===u?(()=>{var t,c=g.options,u={},h=1,f=e=>{var t=Object.assign({},e.dataset),i=s&&t[s]
return"string"==typeof i&&i.length&&(t=Object.assign(t,JSON.parse(i))),t},v=(e,t)=>{var s=p(e.value)
if(s||i.allowEmptyOption)if(u.hasOwnProperty(s)){if(t){var l=u[s][a]
l?Array.isArray(l)?l.push(t):u[s][a]=[l,t]:u[s][a]=t}}else{var c=f(e)
c[n]=c[n]||e.textContent,c[o]=c[o]||s,c[r]=c[r]||e.disabled,c[a]=c[a]||t,c.$option=e,u[s]=c,d.push(c),e.selected&&g.items.push(s)}},m=e=>{var t,i;(i=f(e))[l]=i[l]||e.getAttribute("label")||"",i[c]=i[c]||h++,i[r]=i[r]||e.disabled,g.optgroups.push(i),t=i[c]
l?Array.isArray(l)?l.push(t):u[s][a]=[l,t]:u[s][a]=t}}else{var d=f(e)
d[n]=d[n]||e.textContent,d[o]=d[o]||s,d[r]=d[r]||e.disabled,d[a]=d[a]||t,d.$option=e,u[s]=d,c.push(d),e.selected&&g.items.push(s)}},m=e=>{var t,i;(i=f(e))[l]=i[l]||e.getAttribute("label")||"",i[d]=i[d]||h++,i[r]=i[r]||e.disabled,g.optgroups.push(i),t=i[d]
for(const i of e.children)v(i,t)}

@@ -66,14 +70,14 @@ g.maxItems=e.hasAttribute("multiple")?null:1

for(const e of t)(r={})[n]=e,r[o]=e,g.options.push(r)
g.items=t}})(),Object.assign({},d,g,t)}function y(e){if(e.jquery)return e[0]
g.items=t}})(),Object.assign({},c,g,t)}function O(e){if(e.jquery)return e[0]
if(e instanceof HTMLElement)return e
if(e.indexOf("<")>-1){let t=document.createElement("div")
return t.innerHTML=e.trim(),t.firstChild}return document.querySelector(e)}function O(e,t){var i=document.createEvent("HTMLEvents")
i.initEvent(t,!0,!1),e.dispatchEvent(i)}function b(e,t){Object.assign(e.style,t)}function w(e,...t){var i=C(t);(e=_(e)).map((e=>{i.map((t=>{e.classList.add(t)}))}))}function I(e,...t){var i=C(t);(e=_(e)).map((e=>{i.map((t=>{e.classList.remove(t)}))}))}function C(e){var t=[]
return t.innerHTML=e.trim(),t.firstChild}return document.querySelector(e)}function b(e,t){var i=document.createEvent("HTMLEvents")
i.initEvent(t,!0,!1),e.dispatchEvent(i)}function w(e,t){Object.assign(e.style,t)}function I(e,...t){var i=_(t);(e=A(e)).map((e=>{i.map((t=>{e.classList.add(t)}))}))}function C(e,...t){var i=_(t);(e=A(e)).map((e=>{i.map((t=>{e.classList.remove(t)}))}))}function _(e){var t=[]
for(let i of e)"string"==typeof i&&(i=i.trim().split(/[\11\12\14\15\40]/)),Array.isArray(i)&&(t=t.concat(i))
return t.filter(Boolean)}function _(e){return Array.isArray(e)||(e=[e]),e}function A(e,t,i){if(!i||i.contains(e))for(;e&&e.matches;){if(e.matches(t))return e
e=e.parentNode}}function S(e,t){return t>0?e[e.length-1]:e[0]}function x(e,t){if(!e)return-1
return t.filter(Boolean)}function A(e){return Array.isArray(e)||(e=[e]),e}function S(e,t,i){if(!i||i.contains(e))for(;e&&e.matches;){if(e.matches(t))return e
e=e.parentNode}}function x(e,t){return t>0?e[e.length-1]:e[0]}function k(e,t){if(!e)return-1
t=t||e.nodeName
for(var i=0;e=e.previousElementSibling;)e.matches(t)&&i++
return i}function k(e,t){for(const i in t)e.setAttribute(i,t[i])}var F=0
class L extends(function(e){return e.plugins={},class extends e{static define(t,i){e.plugins[t]={name:t,fn:i}}initializePlugins(e){var t,i,s,n=this,o=[]
return i}function F(e,t){for(const i in t)e.setAttribute(i,t[i])}var L=0
class P extends(function(e){return e.plugins={},class extends e{static define(t,i){e.plugins[t]={name:t,fn:i}}initializePlugins(e){var t,i,s,n=this,o=[]
if(n.plugins={names:[],settings:{},requested:{},loaded:{}},Array.isArray(e))for(t=0,i=e.length;t<i;t++)"string"==typeof e[t]?o.push(e[t]):(n.plugins.settings[e[t].name]=e[t].options,o.push(e[t].name))

@@ -86,53 +90,54 @@ else if(e)for(s in e)e.hasOwnProperty(s)&&(n.plugins.settings[s]=e[s],o.push(s))

t.loadPlugin(e)}return i.loaded[e]}}}(t)){constructor(e,t){var i
super(),this.control_input=void 0,this.wrapper=void 0,this.dropdown=void 0,this.control=void 0,this.dropdown_content=void 0,this.order=0,this.settings=void 0,this.input=void 0,this.tabIndex=void 0,this.is_select_tag=void 0,this.rtl=void 0,this.inputId=void 0,this._destroy=void 0,this.sifter=void 0,this.tab_key=!1,this.isOpen=!1,this.isDisabled=!1,this.isRequired=void 0,this.isInvalid=!1,this.isLocked=!1,this.isFocused=!1,this.isInputHidden=!1,this.isSetup=!1,this.ignoreFocus=!1,this.ignoreBlur=!1,this.hasOptions=!1,this.currentResults=null,this.lastValue="",this.caretPos=0,this.loading=0,this.loadedSearches={},this.activeOption=null,this.activeItems=[],this.optgroups={},this.options={},this.options_i=0,this.userOptions={},this.items=[],this.renderCache={item:{},option:{}},F++
var s,n,o,a=y(e)
if(a.tomselect)throw new Error("Tom Select already initialized on this element")
a.tomselect=this,i=(window.getComputedStyle&&window.getComputedStyle(a,null)).getPropertyValue("direction"),this.settings=m(a,t),this.input=a,this.tabIndex=a.tabIndex||0,this.is_select_tag="select"===a.tagName.toLowerCase(),this.rtl=/rtl/i.test(i),this.inputId=v(a,"tomselect-"+F),this.isRequired=a.required,this.settings.load&&this.settings.loadThrottle&&(this.settings.load=(s=this.settings.load,n=this.settings.loadThrottle,function(e,t){var i=this
o&&(i.loading=Math.max(i.loading-1,0)),clearTimeout(o),o=setTimeout((function(){o=null,i.loadedSearches[e]=!0,s.call(i,e,t)}),n)})),this.sifter=new r(this.options,{diacritics:this.settings.diacritics}),this.setupOptions(this.settings.options,this.settings.optgroups),delete this.settings.optgroups,delete this.settings.options,this.settings.mode=this.settings.mode||(1===this.settings.maxItems?"single":"multi"),"boolean"!=typeof this.settings.hideSelected&&(this.settings.hideSelected="multi"===this.settings.mode),"boolean"!=typeof this.settings.hidePlaceholder&&(this.settings.hidePlaceholder="multi"!==this.settings.mode)
var l=this.settings.createFilter
"function"!=typeof l&&("string"==typeof l&&(l=new RegExp(l)),l instanceof RegExp?this.settings.createFilter=e=>l.test(e):this.settings.createFilter=()=>!0),this.initializePlugins(this.settings.plugins),this.setupCallbacks(),this.setupTemplates(),this.setup()}setup(){var e,t,i,s,n,o,r,a,l,d=this,p=d.settings,c=d.input
const u={passive:!0},f=d.inputId+"-ts-dropdown"
if(o=d.settings.mode,r=c.getAttribute("class")||"",w(e=y("<div>"),p.wrapperClass,r,o),w(t=y('<div class="items">'),p.inputClass),e.append(t),w(s=d.render("dropdown"),p.dropdownClass,o),w(n=y(`<div style="scroll-behavior: smooth;" role="listbox" id="${f}" tabindex="-1">`),p.dropdownContentClass),s.append(n),y(p.dropdownParent||e).appendChild(s),p.controlInput)i=y(p.controlInput)
else{i=y('<input type="text" autocomplete="off" size="1" />')
for(const e of["autocorrect","autocapitalize","autocomplete"])c.getAttribute(e)&&k(i,{[e]:c.getAttribute(e)})}p.controlInput||(i.tabIndex=c.disabled?-1:d.tabIndex,t.appendChild(i)),k(i,{role:"combobox",haspopup:"listbox","aria-expanded":"false","aria-controls":f}),l=v(i,d.inputId+"-tomselected")
let m="label[for='"+function(e){return e.replace(/['"\\]/g,"\\$&")}(d.inputId)+"']",O=document.querySelector(m)
if(O){k(O,{for:l}),k(n,{"aria-labelledby":v(O,d.inputId+"-ts-label")})}if(d.settings.copyClassesToDropdown&&w(s,r),e.style.width=c.style.width,d.plugins.names.length&&(a="plugin-"+d.plugins.names.join(" plugin-"),w([e,s],a)),(null===p.maxItems||p.maxItems>1)&&d.is_select_tag&&k(c,{multiple:"multiple"}),d.settings.placeholder&&k(i,{placeholder:p.placeholder}),!d.settings.splitOn&&d.settings.delimiter){var b=d.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")
d.settings.splitOn=new RegExp("\\s*"+b+"+\\s*")}d.control=t,d.control_input=i,d.wrapper=e,d.dropdown=s,d.dropdown_content=n,d.control_input.type=c.type,g(s,"mouseenter",(e=>{var t=A(e.target,"[data-selectable]",s)
if(t)return d.onOptionHover(e,t)}),{capture:!0}),g(t,"mousedown",(e=>{if(e.target==i)return d.clearActiveItems(),e.stopPropagation(),void d.inputState()
var s=A(e.target,"."+d.settings.itemClass,t)
return s?d.onItemSelect(e,s):d.onMouseDown(e)})),g(t,"click",(e=>d.onClick(e))),g(i,"keydown",(e=>d.onKeyDown(e))),g(i,"keyup",(e=>d.onKeyUp(e))),g(i,"keypress",(e=>d.onKeyPress(e))),g(i,"resize",(()=>d.positionDropdown()),u),g(i,"blur",(e=>d.onBlur(e))),g(i,"focus",(e=>{d.ignoreBlur=!1,d.onFocus(e)})),g(i,"paste",(e=>d.onPaste(e)))
var I=e=>{var t=A(e.target,"[data-selectable]",d.dropdown)
super(),this.control_input=void 0,this.wrapper=void 0,this.dropdown=void 0,this.control=void 0,this.dropdown_content=void 0,this.order=0,this.settings=void 0,this.input=void 0,this.tabIndex=void 0,this.is_select_tag=void 0,this.rtl=void 0,this.inputId=void 0,this._destroy=void 0,this.sifter=void 0,this.tab_key=!1,this.isOpen=!1,this.isDisabled=!1,this.isRequired=void 0,this.isInvalid=!1,this.isLocked=!1,this.isFocused=!1,this.isInputHidden=!1,this.isSetup=!1,this.ignoreFocus=!1,this.ignoreBlur=!1,this.hasOptions=!1,this.currentResults=null,this.lastValue="",this.caretPos=0,this.loading=0,this.loadedSearches={},this.activeOption=null,this.activeItems=[],this.optgroups={},this.options={},this.options_i=0,this.userOptions={},this.items=[],this.renderCache={item:{},option:{}},L++
var s=O(e)
if(s.tomselect)throw new Error("Tom Select already initialized on this element")
s.tomselect=this,i=(window.getComputedStyle&&window.getComputedStyle(s,null)).getPropertyValue("direction"),this.settings=y(s,t),this.input=s,this.tabIndex=s.tabIndex||0,this.is_select_tag="select"===s.tagName.toLowerCase(),this.rtl=/rtl/i.test(i),this.inputId=m(s,"tomselect-"+L),this.isRequired=s.required,this.sifter=new a(this.options,{diacritics:this.settings.diacritics}),this.setupOptions(this.settings.options,this.settings.optgroups),delete this.settings.optgroups,delete this.settings.options,this.settings.mode=this.settings.mode||(1===this.settings.maxItems?"single":"multi"),"boolean"!=typeof this.settings.hideSelected&&(this.settings.hideSelected="multi"===this.settings.mode),"boolean"!=typeof this.settings.hidePlaceholder&&(this.settings.hidePlaceholder="multi"!==this.settings.mode)
var n=this.settings.createFilter
"function"!=typeof n&&("string"==typeof n&&(n=new RegExp(n)),n instanceof RegExp?this.settings.createFilter=e=>n.test(e):this.settings.createFilter=()=>!0),this.initializePlugins(this.settings.plugins),this.setupCallbacks(),this.setupTemplates(),this.setup()}setup(){var e,t,i,s,n,o,r,a,l,d=this,c=d.settings,p=d.input
const u={passive:!0},h=d.inputId+"-ts-dropdown"
if(o=d.settings.mode,r=p.getAttribute("class")||"",I(e=O("<div>"),c.wrapperClass,r,o),I(t=O('<div class="items">'),c.inputClass),e.append(t),I(s=d.render("dropdown"),c.dropdownClass,o),I(n=O(`<div role="listbox" id="${h}" tabindex="-1">`),c.dropdownContentClass),s.append(n),O(c.dropdownParent||e).appendChild(s),c.controlInput)i=O(c.controlInput)
else{i=O('<input type="text" autocomplete="off" size="1" />')
for(const e of["autocorrect","autocapitalize","autocomplete"])p.getAttribute(e)&&F(i,{[e]:p.getAttribute(e)})}c.controlInput||(i.tabIndex=p.disabled?-1:d.tabIndex,t.appendChild(i)),F(i,{role:"combobox",haspopup:"listbox","aria-expanded":"false","aria-controls":h}),l=m(i,d.inputId+"-tomselected")
let v="label[for='"+function(e){return e.replace(/['"\\]/g,"\\$&")}(d.inputId)+"']",y=document.querySelector(v)
if(y){F(y,{for:l}),F(n,{"aria-labelledby":m(y,d.inputId+"-ts-label")})}if(d.settings.copyClassesToDropdown&&I(s,r),e.style.width=p.style.width,d.plugins.names.length&&(a="plugin-"+d.plugins.names.join(" plugin-"),I([e,s],a)),(null===c.maxItems||c.maxItems>1)&&d.is_select_tag&&F(p,{multiple:"multiple"}),d.settings.placeholder&&F(i,{placeholder:c.placeholder}),!d.settings.splitOn&&d.settings.delimiter){var b=d.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")
d.settings.splitOn=new RegExp("\\s*"+b+"+\\s*")}var w,C,_
this.settings.load&&this.settings.loadThrottle&&(this.settings.load=(w=this.settings.load,C=this.settings.loadThrottle,function(e,t){var i=this
_&&(i.loading=Math.max(i.loading-1,0)),clearTimeout(_),_=setTimeout((function(){_=null,i.loadedSearches[e]=!0,w.call(i,e,t)}),C)})),d.control=t,d.control_input=i,d.wrapper=e,d.dropdown=s,d.dropdown_content=n,d.control_input.type=p.type,f(s,"mouseenter",(e=>{var t=S(e.target,"[data-selectable]",s)
if(t)return d.onOptionHover(e,t)}),{capture:!0}),f(t,"mousedown",(e=>{if(e.target==i)return d.clearActiveItems(),e.stopPropagation(),void d.inputState()
var s=S(e.target,"."+d.settings.itemClass,t)
return s?d.onItemSelect(e,s):d.onMouseDown(e)})),f(t,"click",(e=>d.onClick(e))),f(i,"keydown",(e=>d.onKeyDown(e))),f(i,"keyup",(e=>d.onKeyUp(e))),f(i,"keypress",(e=>d.onKeyPress(e))),f(i,"resize",(()=>d.positionDropdown()),u),f(i,"blur",(e=>d.onBlur(e))),f(i,"focus",(e=>{d.ignoreBlur=!1,d.onFocus(e)})),f(i,"paste",(e=>d.onPaste(e)))
var A=e=>{var t=S(e.target,"[data-selectable]",d.dropdown)
if(!t&&!d.wrapper.contains(e.target))return d.isFocused&&d.blur(),void d.inputState()
h(e,!0),t&&d.onOptionSelect(e,t)},C=()=>{d.isOpen&&d.positionDropdown()}
g(document,"mousedown",I),g(window,"sroll",C,u),g(window,"resize",C,u),d._destroy=()=>{document.removeEventListener("mousedown",I),window.removeEventListener("sroll",C),window.removeEventListener("resize",C)},this.revertSettings={innerHTML:c.innerHTML,tabIndex:c.tabIndex},c.tabIndex=-1,k(c,{hidden:"hidden"}),c.insertAdjacentElement("afterend",d.wrapper),d.setValue(p.items),delete p.items,g(c,"invalid",(e=>{h(e),d.isInvalid||(d.isInvalid=!0,d.refreshState())})),d.updateOriginalInput(),d.refreshItems(),d.refreshState(),d.inputState(),d.isSetup=!0,c.disabled&&d.disable(),d.on("change",this.onChange),w(c,"tomselected"),d.trigger("initialize"),!0===p.preload&&d.load("")}setupOptions(e=[],t=[]){for(const t of e)this.registerOption(t)
g(e,!0),t&&d.onOptionSelect(e,t)},x=()=>{d.isOpen&&d.positionDropdown()}
f(document,"mousedown",A),f(window,"sroll",x,u),f(window,"resize",x,u),d._destroy=()=>{document.removeEventListener("mousedown",A),window.removeEventListener("sroll",x),window.removeEventListener("resize",x)},this.revertSettings={innerHTML:p.innerHTML,tabIndex:p.tabIndex},p.tabIndex=-1,F(p,{hidden:"hidden"}),p.insertAdjacentElement("afterend",d.wrapper),d.setValue(c.items),delete c.items,f(p,"invalid",(e=>{g(e),d.isInvalid||(d.isInvalid=!0,d.refreshState())})),d.updateOriginalInput(),d.refreshItems(),d.refreshState(),d.inputState(),d.isSetup=!0,p.disabled&&d.disable(),d.on("change",this.onChange),I(p,"tomselected"),d.trigger("initialize"),!0===c.preload&&d.load("")}setupOptions(e=[],t=[]){for(const t of e)this.registerOption(t)
for(const e of t)this.registerOptionGroup(e)}setupTemplates(){var e=this,t=e.settings.labelField,i=e.settings.optgroupLabelField,s={optgroup:(e,t)=>{let i=document.createElement("div")
return i.className="optgroup",i.appendChild(e.options),i},optgroup_header:(e,t)=>'<div class="optgroup-header">'+t(e[i])+"</div>",option:(e,i)=>"<div>"+i(e[t])+"</div>",item:(e,i)=>"<div>"+i(e[t])+"</div>",option_create:(e,t)=>'<div class="create">Add <strong>'+t(e.input)+"</strong>&hellip;</div>",no_results:(e,t)=>'<div class="no-results">No results found</div>',loading:(e,t)=>'<div class="spinner"></div>',not_loading:()=>{},dropdown:()=>'<div style="display:none"></div>'}
return i.className="optgroup",i.appendChild(e.options),i},optgroup_header:(e,t)=>'<div class="optgroup-header">'+t(e[i])+"</div>",option:(e,i)=>"<div>"+i(e[t])+"</div>",item:(e,i)=>"<div>"+i(e[t])+"</div>",option_create:(e,t)=>'<div class="create">Add <strong>'+t(e.input)+"</strong>&hellip;</div>",no_results:(e,t)=>'<div class="no-results">No results found</div>',loading:(e,t)=>'<div class="spinner"></div>',not_loading:()=>{},dropdown:()=>"<div></div>"}
e.settings.render=Object.assign({},s,e.settings.render)}setupCallbacks(){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)}onClick(e){var t=this
t.isFocused&&t.isOpen||(t.focus(),h(e))}onMouseDown(e){var t=this
t.isFocused&&t.isOpen||(t.focus(),g(e))}onMouseDown(e){var t=this
if(t.isFocused)return"single"!==t.settings.mode&&t.setActiveItem(),t.open(),!1
setTimeout((()=>t.focus()),0)}onChange(){O(this.input,"input"),O(this.input,"change")}onPaste(e){var t=this
t.isFull()||t.isInputHidden||t.isLocked?h(e):t.settings.splitOn&&setTimeout((()=>{var e=t.inputValue()
setTimeout((()=>t.focus()),0)}onChange(){b(this.input,"input"),b(this.input,"change")}onPaste(e){var t=this
t.isFull()||t.isInputHidden||t.isLocked?g(e):t.settings.splitOn&&setTimeout((()=>{var e=t.inputValue()
if(e.match(t.settings.splitOn)){var i=e.trim().split(t.settings.splitOn)
for(const e of i)t.createItem(e)}}),0)}onKeyPress(e){var t=this
if(!t.isLocked){var i=String.fromCharCode(e.keyCode||e.which)
return t.settings.create&&"multi"===t.settings.mode&&i===t.settings.delimiter?(t.createItem(),void h(e)):void 0}h(e)}onKeyDown(e){var t=this
if(t.isLocked)9!==e.keyCode&&h(e)
else{switch(e.keyCode){case 65:if(f(l,e))return void t.selectAll()
return t.settings.create&&"multi"===t.settings.mode&&i===t.settings.delimiter?(t.createItem(),void g(e)):void 0}g(e)}onKeyDown(e){var t=this
if(t.isLocked)9!==e.keyCode&&g(e)
else{switch(e.keyCode){case 65:if(v(d,e))return void t.selectAll()
break
case 27:return t.isOpen&&(h(e,!0),t.close()),void t.clearActiveItems()
case 27:return t.isOpen&&(g(e,!0),t.close()),void t.clearActiveItems()
case 40:if(!t.isOpen&&t.hasOptions)t.open()
else if(t.activeOption){let e=t.getAdjacent(t.activeOption,1)
e&&t.setActiveOption(e)}return void h(e)
e&&t.setActiveOption(e)}return void g(e)
case 38:if(t.activeOption){let e=t.getAdjacent(t.activeOption,-1)
e&&t.setActiveOption(e)}return void h(e)
case 13:return void(t.isOpen&&t.activeOption&&(t.onOptionSelect(e,t.activeOption),h(e)))
e&&t.setActiveOption(e)}return void g(e)
case 13:return void(t.isOpen&&t.activeOption?(t.onOptionSelect(e,t.activeOption),g(e)):t.settings.create&&t.createItem()&&g(e))
case 37:return void t.advanceSelection(-1,e)
case 39:return void t.advanceSelection(1,e)
case 9:return t.settings.selectOnTab&&t.isOpen&&t.activeOption&&(t.tab_key=!0,t.onOptionSelect(e,t.activeOption),h(e),t.tab_key=!1),void(t.settings.create&&t.createItem()&&h(e))
case 8:case 46:return void t.deleteSelection(e)}t.isInputHidden&&!f(l,e)&&h(e)}}onKeyUp(e){var t=this
if(t.isLocked)h(e)
case 9:return void(t.settings.selectOnTab&&(t.isOpen&&t.activeOption&&(t.tab_key=!0,t.onOptionSelect(e,t.activeOption),g(e),t.tab_key=!1),t.settings.create&&t.createItem()&&g(e)))
case 8:case 46:return void t.deleteSelection(e)}t.isInputHidden&&!v(d,e)&&g(e)}}onKeyUp(e){var t=this
if(t.isLocked)g(e)
else{var i=t.inputValue()
t.lastValue!==i&&(t.lastValue=i,t.settings.shouldLoad.call(t,i)&&t.load(i),t.refreshOptions(),t.trigger("type",i))}}onFocus(e){var t=this,i=t.isFocused
if(t.isDisabled)return t.blur(),void h(e)
if(t.isDisabled)return t.blur(),void g(e)
t.ignoreFocus||(t.isFocused=!0,"focus"===t.settings.preload&&t.load(""),i||t.trigger("focus"),t.activeItems.length||(t.showInput(),t.setActiveItem(),t.refreshOptions(!!t.settings.openOnFocus)),t.refreshState())}onBlur(e){var t=this

@@ -143,17 +148,22 @@ if(t.isFocused){if(t.isFocused=!1,t.ignoreFocus=!1,!t.ignoreBlur&&document.activeElement===t.dropdown_content)return t.ignoreBlur=!0,void t.onFocus(e)

t&&(t.parentElement&&t.parentElement.matches("[data-disabled]")||(t.classList.contains("create")?s.createItem(null,!0,(()=>{s.settings.closeAfterSelect&&s.close()})):void 0!==(i=t.dataset.value)&&(s.lastQuery=null,s.addItem(i),s.settings.closeAfterSelect?s.close():!s.settings.hideSelected&&e.type&&/mouse/.test(e.type)&&s.setActiveOption(s.getOption(i)))))}onItemSelect(e,t){var i=this
i.isLocked||"multi"===i.settings.mode&&(h(e),i.setActiveItem(t,e))}load(e){var t=this,i=t.settings.load
i&&(t.loadedSearches.hasOwnProperty(e)||(w(t.wrapper,t.settings.loadingClass),t.loading++,i.call(t,e,(function(e,i){t.loading=Math.max(t.loading-1,0),t.lastQuery=null,t.clearActiveOption(),t.setupOptions(e,i),t.refreshOptions(t.isFocused&&!t.isInputHidden),t.loading||I(t.wrapper,t.settings.loadingClass),t.trigger("load",e,i)}))))}onSearchChange(e){this.load(e)}setTextboxValue(e=""){var t=this.control_input
t.value!==e&&(t.value=e,O(t,"update"),this.lastValue=e)}getValue(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}setValue(e,t){u(this,t?[]:["change"],(()=>{this.clear(t),this.addItems(e,t)}))}setMaxItems(e){0===e&&(e=null),this.settings.maxItems=e,this.refreshState()}setActiveItem(e,t){var i,s,n,o,r,a,d=this
if("single"!==d.settings.mode){if(!e)return d.clearActiveItems(),void(d.isFocused&&d.showInput())
if("mousedown"===(i=t&&t.type.toLowerCase())&&f("shiftKey",t)&&d.activeItems.length){for(a=d.getLastActive(),(n=Array.prototype.indexOf.call(d.control.children,a))>(o=Array.prototype.indexOf.call(d.control.children,e))&&(r=n,n=o,o=r),s=n;s<=o;s++)e=d.control.children[s],-1===d.activeItems.indexOf(e)&&d.setActiveItemClass(e)
h(t)}else"mousedown"===i&&f(l,t)||"keydown"===i&&f("shiftKey",t)?e.classList.contains("active")?d.removeActiveItem(e):d.setActiveItemClass(e):(d.clearActiveItems(),d.setActiveItemClass(e))
d.hideInput(),d.isFocused||d.focus()}}setActiveItemClass(e){var t=this.control.querySelector(".last-active")
t&&I(t,"last-active"),w(e,"active last-active"),-1==this.activeItems.indexOf(e)&&this.activeItems.push(e)}removeActiveItem(e){var t=this.activeItems.indexOf(e)
this.activeItems.splice(t,1),I(e,"active")}clearActiveItems(){I(this.activeItems,"active"),this.activeItems=[]}setActiveOption(e){var t,i,s
i.isLocked||"multi"===i.settings.mode&&(g(e),i.setActiveItem(t,e))}load(e){var t=this,i=t.settings.load
if(!i)return
if(t.loadedSearches.hasOwnProperty(e))return
I(t.wrapper,t.settings.loadingClass),t.loading++
const s=t.loadCallback.bind(t)
i.call(t,e,s)}loadCallback(e,t){const i=this
i.loading=Math.max(i.loading-1,0),i.lastQuery=null,i.clearActiveOption(),i.setupOptions(e,t),i.refreshOptions(i.isFocused&&!i.isInputHidden),i.loading||C(i.wrapper,i.settings.loadingClass),i.trigger("load",e,t)}onSearchChange(e){this.load(e)}setTextboxValue(e=""){var t=this.control_input
t.value!==e&&(t.value=e,b(t,"update"),this.lastValue=e)}getValue(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}setValue(e,t){h(this,t?[]:["change"],(()=>{this.clear(t),this.addItems(e,t)}))}setMaxItems(e){0===e&&(e=null),this.settings.maxItems=e,this.refreshState()}setActiveItem(e,t){var i,s,n,o,r,a,l=this
if("single"!==l.settings.mode){if(!e)return l.clearActiveItems(),void(l.isFocused&&l.showInput())
if("mousedown"===(i=t&&t.type.toLowerCase())&&v("shiftKey",t)&&l.activeItems.length){for(a=l.getLastActive(),(n=Array.prototype.indexOf.call(l.control.children,a))>(o=Array.prototype.indexOf.call(l.control.children,e))&&(r=n,n=o,o=r),s=n;s<=o;s++)e=l.control.children[s],-1===l.activeItems.indexOf(e)&&l.setActiveItemClass(e)
g(t)}else"mousedown"===i&&v(d,t)||"keydown"===i&&v("shiftKey",t)?e.classList.contains("active")?l.removeActiveItem(e):l.setActiveItemClass(e):(l.clearActiveItems(),l.setActiveItemClass(e))
l.hideInput(),l.isFocused||l.focus()}}setActiveItemClass(e){var t=this.control.querySelector(".last-active")
t&&C(t,"last-active"),I(e,"active last-active"),-1==this.activeItems.indexOf(e)&&this.activeItems.push(e)}removeActiveItem(e){var t=this.activeItems.indexOf(e)
this.activeItems.splice(t,1),C(e,"active")}clearActiveItems(){C(this.activeItems,"active"),this.activeItems=[]}setActiveOption(e){var t,i,s
if(e===this.activeOption)return
if(this.clearActiveOption(),!e)return
this.activeOption=e,k(this.control_input,{"aria-activedescendant":e.getAttribute("id")}),k(e,{"aria-selected":"true"}),w(e,"active"),t=this.dropdown_content.clientHeight
this.activeOption=e,F(this.control_input,{"aria-activedescendant":e.getAttribute("id")}),F(e,{"aria-selected":"true"}),I(e,"active"),t=this.dropdown_content.clientHeight
let n=this.dropdown_content.scrollTop||0
i=this.activeOption.offsetHeight,(s=this.activeOption.getBoundingClientRect().top-this.dropdown_content.getBoundingClientRect().top+n)+i>t+n?this.dropdown_content.scrollTop=s-t+i:s<n&&(this.dropdown_content.scrollTop=s)}clearActiveOption(){this.activeOption&&(I(this.activeOption,"active"),this.activeOption.removeAttribute("aria-selected")),this.activeOption=null,this.control_input.removeAttribute("aria-activedescendant")}selectAll(){"single"!==this.settings.mode&&(this.activeItems=this.controlChildren(),this.activeItems.length&&(w(this.activeItems,"active"),this.hideInput(),this.close()),this.focus())}inputState(){var e=this
e.settings.controlInput||(e.activeItems.length>0||!e.isFocused&&this.settings.hidePlaceholder&&e.items.length>0?(e.setTextboxValue(),e.isInputHidden=!0,w(e.wrapper,"input-hidden")):(e.isInputHidden=!1,I(e.wrapper,"input-hidden")))}hideInput(){this.inputState()}showInput(){this.inputState()}inputValue(){return this.control_input.value.trim()}focus(){var e=this
i=this.activeOption.offsetHeight,(s=this.activeOption.getBoundingClientRect().top-this.dropdown_content.getBoundingClientRect().top+n)+i>t+n?this.dropdown_content.scrollTop=s-t+i:s<n&&(this.dropdown_content.scrollTop=s)}clearActiveOption(){this.activeOption&&(C(this.activeOption,"active"),this.activeOption.removeAttribute("aria-selected")),this.activeOption=null,this.control_input.removeAttribute("aria-activedescendant")}selectAll(){"single"!==this.settings.mode&&(this.activeItems=this.controlChildren(),this.activeItems.length&&(I(this.activeItems,"active"),this.hideInput(),this.close()),this.focus())}inputState(){var e=this
e.settings.controlInput||(e.activeItems.length>0||!e.isFocused&&this.settings.hidePlaceholder&&e.items.length>0?(e.setTextboxValue(),e.isInputHidden=!0,I(e.wrapper,"input-hidden")):(e.isInputHidden=!1,C(e.wrapper,"input-hidden")))}hideInput(){this.inputState()}showInput(){this.inputState()}inputValue(){return this.control_input.value.trim()}focus(){var e=this
e.isDisabled||(e.ignoreFocus=!0,e.control_input.focus(),setTimeout((()=>{e.ignoreFocus=!1,e.onFocus()}),0))}blur(){this.control_input.blur(),this.onBlur(null)}getScoreFunction(e){return this.sifter.getScoreFunction(e,this.getSearchOptions())}getSearchOptions(){var e,t=this.settings

@@ -163,10 +173,10 @@ return"string"==typeof t.sortField&&(e=[{field:t.sortField}]),{fields:t.searchField,conjunction:t.searchConjunction,sort:e,nesting:t.nesting}}search(e){var t,i,s,n=this,o=n.settings,r=this.getSearchOptions()

if(e!==n.lastQuery?(n.lastQuery=e,i=n.sifter.search(e,Object.assign(r,{score:s})),n.currentResults=i):i=Object.assign({},n.currentResults),o.hideSelected)for(t=i.items.length-1;t>=0;t--)-1!==n.items.indexOf(p(i.items[t].id))&&i.items.splice(t,1)
return i}refreshOptions(e=!0){var t,i,s,n,o,r,l,d,c,u,h,g,f,v=this,m=v.inputValue(),y=v.search(m),O=v.activeOption&&p(v.activeOption.dataset.value),b=v.settings.shouldOpen||!1
for(n=y.items.length,"number"==typeof v.settings.maxOptions&&(n=Math.min(n,v.settings.maxOptions)),n>0&&(b=!0),g={},o=[],t=0;t<n;t++){let e=v.options[y.items[t].id],n=p(e[v.settings.valueField]),a=v.getOption(n)
for(a||(a=v.render("option",e)),v.settings.hideSelected||a.classList.toggle("selected",v.items.includes(n)),r=e[v.settings.optgroupField]||"",i=0,s=(l=Array.isArray(r)?r:[r])&&l.length;i<s;i++)r=l[i],v.optgroups.hasOwnProperty(r)||(r=""),g.hasOwnProperty(r)||(g[r]=document.createDocumentFragment(),o.push(r)),i>0&&(a=a.cloneNode(!0),I(a,"active"),a.removeAttribute("aria-selected")),g[r].appendChild(a)}for(r of(this.settings.lockOptgroupOrder&&o.sort(((e,t)=>(v.optgroups[e]&&v.optgroups[e].$order||0)-(v.optgroups[t]&&v.optgroups[t].$order||0))),d=document.createDocumentFragment(),o))if(v.optgroups.hasOwnProperty(r)&&g[r].children.length){let e=document.createDocumentFragment()
e.appendChild(v.render("optgroup_header",v.optgroups[r])),e.appendChild(g[r])
return i}refreshOptions(e=!0){var t,i,s,n,o,r,a,d,c,u,h,g,f,v=this,m=v.inputValue(),y=v.search(m),O=v.activeOption&&p(v.activeOption.dataset.value),b=v.settings.shouldOpen||!1
for(n=y.items.length,"number"==typeof v.settings.maxOptions&&(n=Math.min(n,v.settings.maxOptions)),n>0&&(b=!0),g={},o=[],t=0;t<n;t++){let e=v.options[y.items[t].id],n=p(e[v.settings.valueField]),l=v.getOption(n)
for(l||(l=v.render("option",e)),v.settings.hideSelected||l.classList.toggle("selected",v.items.includes(n)),r=e[v.settings.optgroupField]||"",i=0,s=(a=Array.isArray(r)?r:[r])&&a.length;i<s;i++)r=a[i],v.optgroups.hasOwnProperty(r)||(r=""),g.hasOwnProperty(r)||(g[r]=document.createDocumentFragment(),o.push(r)),i>0&&(l=l.cloneNode(!0),C(l,"active"),l.removeAttribute("aria-selected")),g[r].appendChild(l)}for(r of(this.settings.lockOptgroupOrder&&o.sort(((e,t)=>(v.optgroups[e]&&v.optgroups[e].$order||0)-(v.optgroups[t]&&v.optgroups[t].$order||0))),d=document.createDocumentFragment(),o))if(v.optgroups.hasOwnProperty(r)&&g[r].children.length){let e=document.createDocumentFragment()
e.append(v.render("optgroup_header",v.optgroups[r])),e.append(g[r])
let t=v.render("optgroup",{group:v.optgroups[r],options:e})
d.appendChild(t)}else d.appendChild(g[r])
if(v.dropdown_content.innerHTML="",v.dropdown_content.appendChild(d),v.settings.highlight&&(v.dropdown_content,f=document.querySelectorAll("span.highlight"),Array.prototype.forEach.call(f,(function(e,t){var i=e.parentNode
i.replaceChild(e.firstChild,e),i.normalize()})),y.query.length&&y.tokens.length))for(const e of y.tokens)a(v.dropdown_content,e.regex)
d.append(t)}else d.append(g[r])
if(v.dropdown_content.innerHTML="",v.dropdown_content.append(d),v.settings.highlight&&(v.dropdown_content,f=document.querySelectorAll("span.highlight"),Array.prototype.forEach.call(f,(function(e,t){var i=e.parentNode
i.replaceChild(e.firstChild,e),i.normalize()})),y.query.length&&y.tokens.length))for(const e of y.tokens)l(v.dropdown_content,e.regex)
var w=e=>{let t=v.render(e,{input:m})

@@ -176,3 +186,3 @@ return t&&(b=!0,v.dropdown_content.insertBefore(t,v.dropdown_content.firstChild)),t}

h&&!v.settings.addPrecedence&&(e=1),u=v.selectable()[e]}}else u=h
v.setActiveOption(u),e&&!v.isOpen&&v.open()}else v.clearActiveOption(),e&&v.isOpen&&v.close()}selectable(){return this.dropdown_content.querySelectorAll("[data-selectable]")}addOption(e){var t,i=this
v.setActiveOption(u),e&&!v.isOpen&&v.open()}else v.clearActiveOption(),e&&v.isOpen&&v.close(!1)}selectable(){return this.dropdown_content.querySelectorAll("[data-selectable]")}addOption(e){var t,i=this
if(Array.isArray(e))for(const t of e)i.addOption(t)

@@ -184,3 +194,3 @@ else(t=i.registerOption(e))&&(i.userOptions[t]=!0,i.lastQuery=null,i.trigger("option_add",t,e))}registerOption(e){var t=p(e[this.settings.valueField])

if(e=p(e),n=p(t[d.settings.valueField]),null!==e&&d.options.hasOwnProperty(e)){if("string"!=typeof n)throw new Error("Value must be set in option data")
l=d.options[e].$order,n!==e&&(delete d.options[e],-1!==(o=d.items.indexOf(e))&&d.items.splice(o,1,n)),t.$order=t.$order||l,d.options[n]=t,r=d.renderCache.item,a=d.renderCache.option,r&&(delete r[e],delete r[n]),a&&(delete a[e],delete a[n]),-1!==d.items.indexOf(n)&&(i=d.getItem(e),s=d.render("item",t),i.classList.contains("active")&&w(s,"active"),i.parentNode.insertBefore(s,i),i.remove()),d.lastQuery=null,d.isOpen&&d.refreshOptions(!1)}}removeOption(e,t){var i=this
l=d.options[e].$order,n!==e&&(delete d.options[e],-1!==(o=d.items.indexOf(e))&&d.items.splice(o,1,n)),t.$order=t.$order||l,d.options[n]=t,r=d.renderCache.item,a=d.renderCache.option,r&&(delete r[e],delete r[n]),a&&(delete a[e],delete a[n]),-1!==d.items.indexOf(n)&&(i=d.getItem(e),s=d.render("item",t),i.classList.contains("active")&&I(s,"active"),i.parentNode.insertBefore(s,i),i.remove()),d.lastQuery=null,d.isOpen&&d.refreshOptions(!1)}}removeOption(e,t){var i=this
e=p(e)

@@ -200,7 +210,7 @@ var s=i.renderCache.item,n=i.renderCache.option

var n=i.control
n.insertBefore(i.buffer,n.firstChild),i.buffer=null}addItem(e,t){u(this,t?[]:["change"],(()=>{var i,s,n=this,o=n.settings.mode
n.insertBefore(i.buffer,n.firstChild),i.buffer=null}addItem(e,t){h(this,t?[]:["change"],(()=>{var i,s,n=this,o=n.settings.mode
if(e=p(e),(-1===n.items.indexOf(e)||("single"===o&&n.close(),"single"!==o&&n.settings.duplicates))&&n.options.hasOwnProperty(e)&&("single"===o&&n.clear(t),"multi"!==o||!n.isFull())){if(i=n.render("item",n.options[e]),n.control.contains(i)&&(i=i.cloneNode(!0)),s=n.isFull(),n.items.splice(n.caretPos,0,e),n.insertAtCaret(i),n.isSetup){let s=n.selectable()
if(!n.isPending){let t=n.getOption(e),i=n.getAdjacent(t,1)
n.refreshOptions(n.isFocused&&"single"!==o),i&&n.setActiveOption(i)}!s.length||n.isFull()?n.close():n.isPending||n.positionDropdown(),n.trigger("item_add",e,i),n.isPending||n.updateOriginalInput({silent:t})}(!n.isPending||!s&&n.isFull())&&n.refreshState()}}))}removeItem(e,t){var i,s,n=this,o=n.getItem(e)
o&&(e=p(o.dataset.value),-1!==(i=n.items.indexOf(e))&&(o.remove(),o.classList.contains("active")&&(s=n.activeItems.indexOf(o),n.activeItems.splice(s,1),I(o,"active")),n.items.splice(i,1),n.lastQuery=null,!n.settings.persist&&n.userOptions.hasOwnProperty(e)&&n.removeOption(e,t),i<n.caretPos&&n.setCaret(n.caretPos-1),n.updateOriginalInput({silent:t}),n.refreshState(),n.positionDropdown(),n.trigger("item_remove",e,o)))}createItem(e,t=!0,i){var s,n=this,o=n.caretPos
o&&(e=p(o.dataset.value),-1!==(i=n.items.indexOf(e))&&(o.remove(),o.classList.contains("active")&&(s=n.activeItems.indexOf(o),n.activeItems.splice(s,1),C(o,"active")),n.items.splice(i,1),n.lastQuery=null,!n.settings.persist&&n.userOptions.hasOwnProperty(e)&&n.removeOption(e,t),i<n.caretPos&&n.setCaret(n.caretPos-1),n.updateOriginalInput({silent:t}),n.refreshState(),n.positionDropdown(),n.trigger("item_remove",e,o)))}createItem(e,t=!0,i){var s,n=this,o=n.caretPos
if(e=e||n.inputValue(),"function"!=typeof i&&(i=()=>{}),!n.canCreate(e))return i(),!1

@@ -222,9 +232,9 @@ n.lock()

e.isInvalid=t,e.control_input.required=t,this.isRequired&&(e.input.required=!t)}}isFull(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems}updateOriginalInput(e={}){var t,i,s=this
if(s.is_select_tag)for(s.input.querySelectorAll("option[selected]").forEach((e=>{-1==s.items.indexOf(e.value)&&e.removeAttribute("selected")})),t=s.items.length-1;t>=0;t--){var n
if(s.is_select_tag)for(s.input.querySelectorAll("option[selected]").forEach((e=>{-1==s.items.indexOf(e.value)&&(e.selected=!1,e.removeAttribute("selected"))})),t=s.items.length-1;t>=0;t--){var n
if(i=s.items[t],!(n=s.options[i].$option)){const e=s.options[i][s.settings.labelField]||""
n=y('<option value="'+c(i)+'">'+c(e)+"</option>"),s.options[i].$option=n}k(n,{selected:"true"}),s.input.prepend(n)}else s.input.value=s.getValue()
n=O('<option value="'+u(i)+'">'+u(e)+"</option>"),s.options[i].$option=n}n.selected=!0,F(n,{selected:"true"}),s.input.prepend(n)}else s.input.value=s.getValue()
s.isSetup&&(e.silent||s.trigger("change",s.getValue()))}open(){var e=this
e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.isOpen=!0,k(e.control_input,{"aria-expanded":"true"}),e.refreshState(),b(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),b(e.dropdown,{visibility:"visible",display:"block"}),e.focus(),e.trigger("dropdown_open",e.dropdown))}close(){var e=this,t=e.isOpen
"single"===e.settings.mode&&e.items.length&&(e.hideInput(),e.tab_key||e.blur()),e.isOpen=!1,k(e.control_input,{"aria-expanded":"false"}),b(e.dropdown,{display:"none"}),e.clearActiveOption(),e.refreshState(),e.setTextboxValue(),t&&e.trigger("dropdown_close",e.dropdown)}positionDropdown(){if("body"===this.settings.dropdownParent){var e=this.control,t=e.getBoundingClientRect(),i=e.offsetHeight+t.top+window.scrollY,s=t.left+window.scrollX
b(this.dropdown,{width:t.width+"px",top:i+"px",left:s+"px"})}}clear(e){var t=this
e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.isOpen=!0,F(e.control_input,{"aria-expanded":"true"}),e.refreshState(),w(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),w(e.dropdown,{visibility:"visible",display:"block"}),e.focus(),e.trigger("dropdown_open",e.dropdown))}close(e=!0){var t=this,i=t.isOpen
e&&t.setTextboxValue(),"single"===t.settings.mode&&t.items.length&&(t.hideInput(),t.tab_key||t.blur()),t.isOpen=!1,F(t.control_input,{"aria-expanded":"false"}),w(t.dropdown,{display:"none"}),t.clearActiveOption(),t.refreshState(),i&&t.trigger("dropdown_close",t.dropdown)}positionDropdown(){if("body"===this.settings.dropdownParent){var e=this.control,t=e.getBoundingClientRect(),i=e.offsetHeight+t.top+window.scrollY,s=t.left+window.scrollX
w(this.dropdown,{width:t.width+"px",top:i+"px",left:s+"px"})}}clear(e){var t=this
if(t.items.length){var i=t.controlChildren()

@@ -234,24 +244,24 @@ for(const e of i)e.remove()

0===i?s.insertBefore(e,s.firstChild):s.insertBefore(e,s.children[i]),t.setCaret(i+1)}deleteSelection(e){var t,i,s,n,o,r=this
if(t=e&&8===e.keyCode?-1:1,i={start:(o=r.control_input).selectionStart,length:o.selectionEnd-o.selectionStart},s=[],r.activeItems.length){n=x(S(r.activeItems,t)),t>0&&n++
if(t=e&&8===e.keyCode?-1:1,i={start:(o=r.control_input).selectionStart,length:o.selectionEnd-o.selectionStart},s=[],r.activeItems.length){n=k(x(r.activeItems,t)),t>0&&n++
for(const e of r.activeItems)s.push(e.dataset.value)}else(r.isFocused||"single"===r.settings.mode)&&r.items.length&&(t<0&&0===i.start&&0===i.length?s.push(r.items[r.caretPos-1]):t>0&&i.start===r.inputValue().length&&s.push(r.items[r.caretPos]))
if(!s.length||"function"==typeof r.settings.onDelete&&!1===r.settings.onDelete.call(r,s,e))return!1
for(h(e,!0),void 0!==n&&r.setCaret(n);s.length;)r.removeItem(s.pop())
for(g(e,!0),void 0!==n&&r.setCaret(n);s.length;)r.removeItem(s.pop())
return r.showInput(),r.positionDropdown(),r.refreshOptions(!1),!0}advanceSelection(e,t){var i,s,n,o=this
o.rtl&&(e*=-1),o.inputValue().length||(f(l,t)||f("shiftKey",t)?(n=(s=o.getLastActive(e))?s.classList.contains("active")?o.getAdjacent(s,e,"item"):s:e>0?o.control_input.nextElementSibling:o.control_input.previousElementSibling)&&(n.classList.contains("active")&&o.removeActiveItem(s),o.setActiveItemClass(n)):o.isFocused&&!o.activeItems.length?o.setCaret(o.caretPos+e):(s=o.getLastActive(e))&&(i=x(s),o.setCaret(e>0?i+1:i),o.setActiveItem()))}getLastActive(e){let t=this.control.querySelector(".last-active")
o.rtl&&(e*=-1),o.inputValue().length||(v(d,t)||v("shiftKey",t)?(n=(s=o.getLastActive(e))?s.classList.contains("active")?o.getAdjacent(s,e,"item"):s:e>0?o.control_input.nextElementSibling:o.control_input.previousElementSibling)&&(n.classList.contains("active")&&o.removeActiveItem(s),o.setActiveItemClass(n)):o.isFocused&&!o.activeItems.length?o.setCaret(o.caretPos+e):(s=o.getLastActive(e))&&(i=k(s),o.setCaret(e>0?i+1:i),o.setActiveItem()))}getLastActive(e){let t=this.control.querySelector(".last-active")
if(t)return t
var i=this.control.querySelectorAll(".active")
return i?S(i,e):void 0}setCaret(e){var t=this
return i?x(i,e):void 0}setCaret(e){var t=this
"single"===t.settings.mode||t.settings.controlInput?e=t.items.length:(e=Math.max(0,Math.min(t.items.length,e)))==t.caretPos||t.isPending||t.controlChildren().forEach(((i,s)=>{s<e?t.control_input.insertAdjacentElement("beforebegin",i):t.control.appendChild(i)})),t.caretPos=e}controlChildren(){return Array.from(this.control.getElementsByClassName(this.settings.itemClass))}lock(){this.close(),this.isLocked=!0,this.refreshState()}unlock(){this.isLocked=!1,this.refreshState()}disable(){var e=this
e.input.disabled=!0,e.control_input.disabled=!0,e.control_input.tabIndex=-1,e.isDisabled=!0,e.lock()}enable(){var e=this
e.input.disabled=!1,e.control_input.disabled=!1,e.control_input.tabIndex=e.tabIndex,e.isDisabled=!1,e.unlock()}destroy(){var e=this,t=e.revertSettings
e.trigger("destroy"),e.off(),e.wrapper.remove(),e.dropdown.remove(),e.input.innerHTML=t.innerHTML,e.input.tabIndex=t.tabIndex,I(e.input,"tomselected"),e.input.removeAttribute("hidden"),e.input.required=this.isRequired,e._destroy(),delete e.input.tomselect}render(e,t){var i,s,n=this
e.trigger("destroy"),e.off(),e.wrapper.remove(),e.dropdown.remove(),e.input.innerHTML=t.innerHTML,e.input.tabIndex=t.tabIndex,C(e.input,"tomselected"),e.input.removeAttribute("hidden"),e.input.required=this.isRequired,e._destroy(),delete e.input.tomselect}render(e,t){var i,s,n=this
if(("option"===e||"item"===e)&&(i=p(t[n.settings.valueField]),n.renderCache[e].hasOwnProperty(i)))return n.renderCache[e][i]
var o=n.settings.render[e]
return"function"!=typeof o?null:(s=o.call(this,t,c))?(s=y(s),"option"===e||"option_create"===e?t[n.settings.disabledField]?k(s,{"aria-disabled":"true"}):k(s,{"data-selectable":""}):"optgroup"===e&&(k(s,{"data-group":t.group[n.settings.optgroupValueField]}),t.group[n.settings.disabledField]&&k(s,{"data-disabled":""})),"option"!==e&&"item"!==e||(k(s,{"data-value":i}),"item"===e?w(s,n.settings.itemClass):(w(s,n.settings.optionClass),k(s,{role:"option",id:t.$id})),n.renderCache[e][i]=s),s):s}clearCache(e){void 0===e?this.renderCache={item:{},option:{}}:this.renderCache[e]={}}canCreate(e){return this.settings.create&&e.length&&this.settings.createFilter.call(this,e)}hook(e,t,i){var s=this,n=s[t]
return"function"!=typeof o?null:(s=o.call(this,t,u))?(s=O(s),"option"===e||"option_create"===e?t[n.settings.disabledField]?F(s,{"aria-disabled":"true"}):F(s,{"data-selectable":""}):"optgroup"===e&&(F(s,{"data-group":t.group[n.settings.optgroupValueField]}),t.group[n.settings.disabledField]&&F(s,{"data-disabled":""})),"option"!==e&&"item"!==e||(F(s,{"data-value":i}),"item"===e?I(s,n.settings.itemClass):(I(s,n.settings.optionClass),F(s,{role:"option",id:t.$id})),n.renderCache[e][i]=s),s):s}clearCache(e){void 0===e?this.renderCache={item:{},option:{}}:this.renderCache[e]={}}canCreate(e){return this.settings.create&&e.length&&this.settings.createFilter.call(this,e)}hook(e,t,i){var s=this,n=s[t]
s[t]=function(){var t,o
return"after"===e&&(t=n.apply(s,arguments)),o=i.apply(s,arguments),"instead"===e?o:("before"===e&&(t=n.apply(s,arguments)),t)}}}return L.define("change_listener",(function(e){var t=this,i=!1
g(t.input,"change",(()=>{if(i)i=!1
return"after"===e&&(t=n.apply(s,arguments)),o=i.apply(s,arguments),"instead"===e?o:("before"===e&&(t=n.apply(s,arguments)),t)}}}return P.define("change_listener",(function(e){var t=this,i=!1
f(t.input,"change",(()=>{if(i)i=!1
else{i=!0
var e=m(t.input,{})
t.setupOptions(e.options,e.optgroups),t.setValue(e.items)}}))})),L.define("checkbox_options",(function(e){var t=this,i=t.onOptionSelect
var e=y(t.input,{})
t.setupOptions(e.options,e.optgroups),t.setValue(e.items)}}))})),P.define("checkbox_options",(function(e){var t=this,i=t.onOptionSelect
t.settings.hideSelected=!1

@@ -261,10 +271,10 @@ var s=function(e){var t=e.querySelector("input")

t.hook("after","setupTemplates",(()=>{var e=t.settings.render.option
t.settings.render.option=function(i){var s=y(e.apply(t,arguments)),n=document.createElement("input")
n.addEventListener("click",(function(e){h(e)})),n.type="checkbox"
t.settings.render.option=function(i){var s=O(e.apply(t,arguments)),n=document.createElement("input")
n.addEventListener("click",(function(e){g(e)})),n.type="checkbox"
var o=p(i[t.settings.valueField])
return t.items.indexOf(o)>-1&&(n.checked=!0),s.prepend(n),s}})),t.on("item_remove",(e=>{var i=t.getOption(e)
i&&(i.classList.remove("selected"),s(i))})),t.hook("instead","onOptionSelect",(function(e,s){return s.classList.contains("selected")?(s.classList.remove("selected"),t.removeItem(s.dataset.value),t.refreshOptions(),void h(e,!0)):i.apply(t,arguments)})),t.hook("after","onOptionSelect",((e,t)=>{s(t)}))})),L.define("clear_button",(function(e){var t=this
e=Object.assign({className:"clear-button",title:"Clear All",html:e=>`<div class="${e.className}" title="${e.title}">&times;</div>`},e),t.hook("after","setup",(()=>{var i=y(e.html(e))
i&&(i.classList.remove("selected"),s(i))})),t.hook("instead","onOptionSelect",(function(e,s){return s.classList.contains("selected")?(s.classList.remove("selected"),t.removeItem(s.dataset.value),t.refreshOptions(),void g(e,!0)):i.apply(t,arguments)})),t.hook("after","onOptionSelect",((e,t)=>{s(t)}))})),P.define("clear_button",(function(e){var t=this
e=Object.assign({className:"clear-button",title:"Clear All",html:e=>`<div class="${e.className}" title="${e.title}">&times;</div>`},e),t.hook("after","setup",(()=>{var i=O(e.html(e))
i.addEventListener("click",(e=>{for(;t.items.length>0;)t.removeItem(t.items[0],!0)
t.updateOriginalInput(),e.preventDefault(),e.stopPropagation()})),t.control.appendChild(i)}))})),L.define("drag_drop",(function(e){var t=this
t.updateOriginalInput(),e.preventDefault(),e.stopPropagation()})),t.control.appendChild(i)}))})),P.define("drag_drop",(function(e){var t=this
if(!$.fn.sortable)throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".')

@@ -276,8 +286,8 @@ if("multi"===t.settings.mode){var i=t.lock,s=t.unlock

var i=[]
e.children("[data-value]").each((function(){i.push($(this).attr("data-value"))})),t.setValue(i)}})}))}})),L.define("dropdown_header",(function(e){var t=this
e=Object.assign({title:"Untitled",headerClass:"dropdown-header",titleRowClass:"dropdown-header-title",labelClass:"dropdown-header-label",closeClass:"dropdown-header-close",html:e=>'<div class="'+e.headerClass+'"><div class="'+e.titleRowClass+'"><span class="'+e.labelClass+'">'+e.title+'</span><a class="'+e.closeClass+'">&times;</a></div></div>'},e),t.hook("after","setup",(()=>{var i=y(e.html(e)),s=i.querySelector("."+e.closeClass)
s&&s.addEventListener("click",(e=>{h(e,!0),t.close()})),t.dropdown.insertBefore(i,t.dropdown.firstChild)}))})),L.define("dropdown_input",(function(){var e=this,t=e.settings.controlInput||'<input type="text" autocomplete="off" class="dropdown-input" />'
t=y(t),e.settings.placeholder&&k(t,{placeholder:e.settings.placeholder}),e.settings.controlInput=t,e.settings.shouldOpen=!0,e.hook("after","setup",(()=>{k(e.wrapper,{tabindex:e.input.disabled?"-1":e.tabIndex}),g(e.wrapper,"keypress",(t=>{if(!e.control.contains(t.target)&&!e.dropdown.contains(t.target))switch(t.keyCode){case 13:return void e.onClick(t)}}))
let i=y('<div class="dropdown-input-wrap">')
i.appendChild(t),e.dropdown.insertBefore(i,e.dropdown.firstChild)}))})),L.define("input_autogrow",(function(){var e=this
e.children("[data-value]").each((function(){i.push($(this).attr("data-value"))})),t.setValue(i)}})}))}})),P.define("dropdown_header",(function(e){var t=this
e=Object.assign({title:"Untitled",headerClass:"dropdown-header",titleRowClass:"dropdown-header-title",labelClass:"dropdown-header-label",closeClass:"dropdown-header-close",html:e=>'<div class="'+e.headerClass+'"><div class="'+e.titleRowClass+'"><span class="'+e.labelClass+'">'+e.title+'</span><a class="'+e.closeClass+'">&times;</a></div></div>'},e),t.hook("after","setup",(()=>{var i=O(e.html(e)),s=i.querySelector("."+e.closeClass)
s&&s.addEventListener("click",(e=>{g(e,!0),t.close()})),t.dropdown.insertBefore(i,t.dropdown.firstChild)}))})),P.define("dropdown_input",(function(){var e=this,t=e.settings.controlInput||'<input type="text" autocomplete="off" class="dropdown-input" />'
t=O(t),e.settings.placeholder&&F(t,{placeholder:e.settings.placeholder}),e.settings.controlInput=t,e.settings.shouldOpen=!0,e.hook("after","setup",(()=>{F(e.wrapper,{tabindex:e.input.disabled?"-1":e.tabIndex}),f(e.wrapper,"keypress",(t=>{if(!e.control.contains(t.target)&&!e.dropdown.contains(t.target))switch(t.keyCode){case 13:return void e.onClick(t)}}))
let i=O('<div class="dropdown-input-wrap">')
i.appendChild(t),e.dropdown.insertBefore(i,e.dropdown.firstChild)}))})),P.define("input_autogrow",(function(){var e=this
e.hook("after","setup",(()=>{var t=document.createElement("span"),i=e.control_input

@@ -287,16 +297,16 @@ t.style.cssText="position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ",e.wrapper.appendChild(t)

var s=()=>{e.items.length>0?(t.textContent=i.value,i.style.width=t.clientWidth+"px"):i.style.width=""}
s(),e.on("update item_add item_remove",s),g(i,"input",s),g(i,"keyup",s),g(i,"blur",s),g(i,"update",s)}))})),L.define("no_backspace_delete",(function(){var e=this,t=e.deleteSelection
this.hook("instead","deleteSelection",(function(){return!!e.activeItems.length&&t.apply(e,arguments)}))})),L.define("no_active_items",(function(e){this.hook("instead","setActiveItem",(()=>{})),this.hook("instead","selectAll",(()=>{}))})),L.define("optgroup_columns",(function(){var e=this,t=e.onKeyDown
s(),e.on("update item_add item_remove",s),f(i,"input",s),f(i,"keyup",s),f(i,"blur",s),f(i,"update",s)}))})),P.define("no_backspace_delete",(function(){var e=this,t=e.deleteSelection
this.hook("instead","deleteSelection",(function(){return!!e.activeItems.length&&t.apply(e,arguments)}))})),P.define("no_active_items",(function(e){this.hook("instead","setActiveItem",(()=>{})),this.hook("instead","selectAll",(()=>{}))})),P.define("optgroup_columns",(function(){var e=this,t=e.onKeyDown
e.hook("instead","onKeyDown",(function(i){var s,n,o,r
if(!e.isOpen||37!==i.keyCode&&39!==i.keyCode)return t.apply(e,arguments)
r=A(e.activeOption,"[data-group]"),s=x(e.activeOption,"[data-selectable]"),(r=37===i.keyCode?r.previousSibling:r.nextSibling)&&(n=(o=r.querySelectorAll("[data-selectable]"))[Math.min(o.length-1,s)])&&e.setActiveOption(n)}))})),L.define("remove_button",(function(e){e=Object.assign({label:"&times;",title:"Remove",className:"remove",append:!0},e)
r=S(e.activeOption,"[data-group]"),s=k(e.activeOption,"[data-selectable]"),(r=37===i.keyCode?r.previousSibling:r.nextSibling)&&(n=(o=r.querySelectorAll("[data-selectable]"))[Math.min(o.length-1,s)])&&e.setActiveOption(n)}))})),P.define("remove_button",(function(e){e=Object.assign({label:"&times;",title:"Remove",className:"remove",append:!0},e)
var t=this
if(e.append){var i='<a href="javascript:void(0)" class="'+e.className+'" tabindex="-1" title="'+c(e.title)+'">'+e.label+"</a>"
if(e.append){var i='<a href="javascript:void(0)" class="'+e.className+'" tabindex="-1" title="'+u(e.title)+'">'+e.label+"</a>"
t.hook("after","setupTemplates",(()=>{var e=t.settings.render.item
t.settings.render.item=function(){var s=y(e.apply(t,arguments)),n=y(i)
return s.appendChild(n),g(n,"mousedown",(e=>{h(e,!0)})),g(n,"click",(e=>{if(h(e,!0),!t.isLocked){var i=s.dataset.value
t.removeItem(i),t.refreshOptions(!1)}})),s}}))}})),L.define("restore_on_backspace",(function(e){var t=this
t.settings.render.item=function(){var s=O(e.apply(t,arguments)),n=O(i)
return s.appendChild(n),f(n,"mousedown",(e=>{g(e,!0)})),f(n,"click",(e=>{if(g(e,!0),!t.isLocked){var i=s.dataset.value
t.removeItem(i),t.refreshOptions(!1)}})),s}}))}})),P.define("restore_on_backspace",(function(e){var t=this
e.text=e.text||function(e){return e[t.settings.labelField]},t.on("item_remove",(function(i){if(""===t.control_input.value.trim()){var s=t.options[i]
s&&t.setTextboxValue(e.text.call(t,s))}}))})),L}))
s&&t.setTextboxValue(e.text.call(t,s))}}))})),P}))
var tomSelect=function(e,t){return new TomSelect(e,t)}
//# sourceMappingURL=tom-select.complete.min.js.map
/**
* Tom Select v1.4.3
* Tom Select v1.5.0
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -9,15 +9,19 @@ */

e in this._events!=!1&&this._events[e].splice(this._events[e].indexOf(i),1)})):this._events={}}trigger(t,...i){var s=this
e(t,(e=>{if(e in s._events!=!1)for(let t of s._events[e])t.apply(s,i)}))}}var i=function(e,t){return"number"==typeof e&&"number"==typeof t?e>t?1:e<t?-1:0:(e=o(String(e||"")))>(t=o(String(t||"")))?1:t>e?-1:0},s=function(e,t,i){if(e&&t){if(!i)return e[t]
for(var s=t.split(".");s.length&&(e=e[s.shift()]););return e}},n={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ŹźẐẑŽžŻżẒẓẔẕƵƶ]"},o=function(){var e,t,i,s,o="",r={}
for(i in n)if(n.hasOwnProperty(i))for(o+=s=n[i].substring(2,n[i].length-1),e=0,t=s.length;e<t;e++)r[s.charAt(e)]=i
var a=new RegExp("["+o+"]","g")
e(t,(e=>{if(e in s._events!=!1)for(let t of s._events[e])t.apply(s,i)}))}}var i=function(e,t){return"number"==typeof e&&"number"==typeof t?e>t?1:e<t?-1:0:(e=r(String(e||"")))>(t=r(String(t||"")))?1:t>e?-1:0},s=function(e,t,i){if(e&&t){if(!i)return e[t]
for(var s=t.split(".");s.length&&(e=e[s.shift()]););return e}},n=function(e){return(e+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")},o={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ŹźẐẑŽžŻżẒẓẔẕƵƶ]"},r=function(){var e,t,i,s,n="",r={}
for(i in o)if(o.hasOwnProperty(i))for(n+=s=o[i].substring(2,o[i].length-1),e=0,t=s.length;e<t;e++)r[s.charAt(e)]=i
var a=new RegExp("["+n+"]","g")
return function(e){return e.replace(a,(function(e){return r[e]})).toLowerCase()}}()
class r{constructor(e,t){this.items=void 0,this.settings=void 0,this.items=e,this.settings=t||{diacritics:!0}}tokenize(e,t){if(!(e=String(e||"").toLowerCase().trim())||!e.length)return[]
var i,s,o,r,a=[],l=e.split(/ +/)
for(i=0,s=l.length;i<s;i++){if(o=(l[i]+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1"),this.settings.diacritics)for(r in n)n.hasOwnProperty(r)&&(o=o.replace(new RegExp(r,"g"),n[r]))
t&&(o="\\b"+o),a.push({string:l[i],regex:new RegExp(o,"i")})}return a}iterator(e,t){(Array.isArray(e)?Array.prototype.forEach||function(e){for(var t=0,i=this.length;t<i;t++)e(this[t],t,this)}:function(e){for(var t in this)this.hasOwnProperty(t)&&e(this[t],t,this)}).apply(e,[t])}getScoreFunction(e,t){var i,n,o,r,a
class a{constructor(e,t){this.items=void 0,this.settings=void 0,this.items=e,this.settings=t||{diacritics:!0}}tokenize(e,t){if(!(e=String(e||"").toLowerCase().trim())||!e.length)return[]
var i,s=[],r=e.split(/\s+/)
const a=new RegExp("^("+t.fields.map(n).join("|")+"):(.*)$")
return r.forEach((e=>{let r,l=null,d=null
if(t.fields.length>1&&(r=e.match(a))&&(l=r[1],e=r[2]),e.length>0){if(d=n(e),this.settings.diacritics)for(i in o)o.hasOwnProperty(i)&&(d=d.replace(new RegExp(i,"g"),o[i]))
t.respect_word_boundaries&&(d="\\b"+d),d=new RegExp(d,"i")}s.push({string:e,regex:d,field:l})})),s}iterator(e,t){(Array.isArray(e)?Array.prototype.forEach||function(e){for(var t=0,i=this.length;t<i;t++)e(this[t],t,this)}:function(e){for(var t in this)this.hasOwnProperty(t)&&e(this[t],t,this)}).apply(e,[t])}getScoreFunction(e,t){var i,n,o,r,a
a=this.prepareSearch(e,t),n=a.tokens,i=a.options.fields,o=n.length,r=a.options.nesting
var l,d=function(e,t){var i,s
return e?-1===(s=(e=String(e||"")).search(t.regex))?0:(i=t.string.length/e.length,0===s&&(i+=.5),i):0},p=(l=i.length)?1===l?function(e,t){return d(s(t,i[0],r),e)}:function(e,t){for(var n=0,o=0;n<l;n++)o+=d(s(t,i[n],r),e)
return o/l}:function(){return 0}
return e?-1===(s=(e=String(e||"")).search(t.regex))?0:(i=t.string.length/e.length,0===s&&(i+=.5),i):0},p=(l=i.length)?1===l?function(e,t){return d(s(t,i[0],r),e)}:function(e,t){var n=0
if(e.field){const i=s(t,e.field,r)
!e.regex&&i?n+=.1:n+=d(i,e)}else i.forEach((i=>{n+=d(s(t,i,r),e)}))
return n/l}:function(){return 0}
return o?1===o?function(e){return p(n[0],e)}:"and"===a.options.conjunction?function(e){for(var t,i=0,s=0;i<o;i++){if((t=p(n[i],e))<=0)return 0

@@ -34,30 +38,30 @@ s+=t}return s/o}:function(e){for(var t=0,i=0;t<o;t++)i+=p(n[t],e)

var i=(t=Object.assign({},t)).fields,s=t.sort,n=t.sort_empty
return i&&!Array.isArray(i)&&(t.fields=[i]),s&&!Array.isArray(s)&&(t.sort=[s]),n&&!Array.isArray(n)&&(t.sort_empty=[n]),{options:t,query:String(e||"").toLowerCase(),tokens:this.tokenize(e,t.respect_word_boundaries),total:0,items:[]}}search(e,t){var i,s,n,o,r=this
return s=this.prepareSearch(e,t),t=s.options,e=s.query,o=t.score||r.getScoreFunction(s),e.length?r.iterator(r.items,(function(e,n){i=o(e),(!1===t.filter||i>0)&&s.items.push({score:i,id:n})})):r.iterator(r.items,(function(e,t){s.items.push({score:1,id:t})})),(n=r.getSortFunction(s,t))&&s.items.sort(n),s.total=s.items.length,"number"==typeof t.limit&&(s.items=s.items.slice(0,t.limit)),s}}function a(e,t){if("string"!=typeof t||t.length){var i="string"==typeof t?new RegExp(t,"i"):t
!function e(t){var s=0
if(3===t.nodeType){var n=t.data.search(i)
if(n>=0&&t.data.length>0){var o=t.data.match(i),r=document.createElement("span")
return i&&!Array.isArray(i)&&(t.fields=[i]),s&&!Array.isArray(s)&&(t.sort=[s]),n&&!Array.isArray(n)&&(t.sort_empty=[n]),{options:t,query:String(e||"").toLowerCase(),tokens:this.tokenize(e,t),total:0,items:[]}}search(e,t){var i,s,n,o,r=this
return s=this.prepareSearch(e,t),t=s.options,e=s.query,o=t.score||r.getScoreFunction(s),e.length?r.iterator(r.items,(function(e,n){i=o(e),(!1===t.filter||i>0)&&s.items.push({score:i,id:n})})):r.iterator(r.items,(function(e,t){s.items.push({score:1,id:t})})),(n=r.getSortFunction(s,t))&&s.items.sort(n),s.total=s.items.length,"number"==typeof t.limit&&(s.items=s.items.slice(0,t.limit)),s}}function l(e,t){if(null!==t){if("string"==typeof t){if(!t.length)return
t=new RegExp(t,"i")}!function e(i){var s=0
if(3===i.nodeType){var n=i.data.search(t)
if(n>=0&&i.data.length>0){var o=i.data.match(t),r=document.createElement("span")
r.className="highlight"
var a=t.splitText(n)
var a=i.splitText(n)
a.splitText(o[0].length)
var l=a.cloneNode(!0)
r.appendChild(l),a.parentNode.replaceChild(r,a),s=1}}else if(1===t.nodeType&&t.childNodes&&!/(script|style)/i.test(t.tagName)&&("highlight"!==t.className||"SPAN"!==t.tagName))for(var d=0;d<t.childNodes.length;++d)d+=e(t.childNodes[d])
return s}(e)}}const l="undefined"!=typeof navigator&&/Mac/.test(navigator.userAgent)?"metaKey":"ctrlKey"
var d={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:null,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,shouldOpen:null,maxOptions:50,maxItems:null,hideSelected:null,duplicates:!1,addPrecedence:!1,selectOnTab:!1,preload:null,allowEmptyOption:!1,closeAfterSelect:!1,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,placeholder:null,hidePlaceholder:null,shouldLoad:function(e){return e.length>0},render:{}}
function p(e){return null==e?null:"boolean"==typeof e?e?"1":"0":e+""}function c(e){return(e+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function u(e,t,i){var s,n=e.trigger,o={}
r.appendChild(l),a.parentNode.replaceChild(r,a),s=1}}else if(1===i.nodeType&&i.childNodes&&!/(script|style)/i.test(i.tagName)&&("highlight"!==i.className||"SPAN"!==i.tagName))for(var d=0;d<i.childNodes.length;++d)d+=e(i.childNodes[d])
return s}(e)}}const d="undefined"!=typeof navigator&&/Mac/.test(navigator.userAgent)?"metaKey":"ctrlKey"
var p={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:null,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,shouldOpen:null,maxOptions:50,maxItems:null,hideSelected:null,duplicates:!1,addPrecedence:!1,selectOnTab:!1,preload:null,allowEmptyOption:!1,closeAfterSelect:!1,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,placeholder:null,hidePlaceholder:null,shouldLoad:function(e){return e.length>0},render:{}}
function c(e){return null==e?null:"boolean"==typeof e?e?"1":"0":e+""}function u(e){return(e+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function h(e,t,i){var s,n=e.trigger,o={}
for(s in e.trigger=function(){var i=arguments[0]
if(-1===t.indexOf(i))return n.apply(e,arguments)
o[i]=arguments},i.apply(e,[]),e.trigger=n,o)n.apply(e,o[s])}function h(e,t=!1){e&&(e.preventDefault(),t&&e.stopPropagation())}function g(e,t,i,s){e.addEventListener(t,i,s)}function f(e,t){return!!t&&(!!t[e]&&1===(t.altKey?1:0)+(t.ctrlKey?1:0)+(t.shiftKey?1:0)+(t.metaKey?1:0))}function v(e,t){const i=e.getAttribute("id")
return i||(e.setAttribute("id",t),t)}function m(e){if(e.jquery)return e[0]
o[i]=arguments},i.apply(e,[]),e.trigger=n,o)n.apply(e,o[s])}function g(e,t=!1){e&&(e.preventDefault(),t&&e.stopPropagation())}function f(e,t,i,s){e.addEventListener(t,i,s)}function v(e,t){return!!t&&(!!t[e]&&1===(t.altKey?1:0)+(t.ctrlKey?1:0)+(t.shiftKey?1:0)+(t.metaKey?1:0))}function m(e,t){const i=e.getAttribute("id")
return i||(e.setAttribute("id",t),t)}function y(e){if(e.jquery)return e[0]
if(e instanceof HTMLElement)return e
if(e.indexOf("<")>-1){let t=document.createElement("div")
return t.innerHTML=e.trim(),t.firstChild}return document.querySelector(e)}function y(e,t){var i=document.createEvent("HTMLEvents")
i.initEvent(t,!0,!1),e.dispatchEvent(i)}function O(e,t){Object.assign(e.style,t)}function b(e,...t){var i=I(t);(e=C(e)).map((e=>{i.map((t=>{e.classList.add(t)}))}))}function w(e,...t){var i=I(t);(e=C(e)).map((e=>{i.map((t=>{e.classList.remove(t)}))}))}function I(e){var t=[]
return t.innerHTML=e.trim(),t.firstChild}return document.querySelector(e)}function O(e,t){var i=document.createEvent("HTMLEvents")
i.initEvent(t,!0,!1),e.dispatchEvent(i)}function b(e,t){Object.assign(e.style,t)}function w(e,...t){var i=C(t);(e=A(e)).map((e=>{i.map((t=>{e.classList.add(t)}))}))}function I(e,...t){var i=C(t);(e=A(e)).map((e=>{i.map((t=>{e.classList.remove(t)}))}))}function C(e){var t=[]
for(let i of e)"string"==typeof i&&(i=i.trim().split(/[\11\12\14\15\40]/)),Array.isArray(i)&&(t=t.concat(i))
return t.filter(Boolean)}function C(e){return Array.isArray(e)||(e=[e]),e}function A(e,t,i){if(!i||i.contains(e))for(;e&&e.matches;){if(e.matches(t))return e
e=e.parentNode}}function _(e,t){return t>0?e[e.length-1]:e[0]}function S(e,t){if(!e)return-1
return t.filter(Boolean)}function A(e){return Array.isArray(e)||(e=[e]),e}function _(e,t,i){if(!i||i.contains(e))for(;e&&e.matches;){if(e.matches(t))return e
e=e.parentNode}}function S(e,t){return t>0?e[e.length-1]:e[0]}function x(e,t){if(!e)return-1
t=t||e.nodeName
for(var i=0;e=e.previousElementSibling;)e.matches(t)&&i++
return i}function x(e,t){for(const i in t)e.setAttribute(i,t[i])}var F=0
class k extends(function(e){return e.plugins={},class extends e{static define(t,i){e.plugins[t]={name:t,fn:i}}initializePlugins(e){var t,i,s,n=this,o=[]
return i}function F(e,t){for(const i in t)e.setAttribute(i,t[i])}var k=0
class P extends(function(e){return e.plugins={},class extends e{static define(t,i){e.plugins[t]={name:t,fn:i}}initializePlugins(e){var t,i,s,n=this,o=[]
if(n.plugins={names:[],settings:{},requested:{},loaded:{}},Array.isArray(e))for(t=0,i=e.length;t<i;t++)"string"==typeof e[t]?o.push(e[t]):(n.plugins.settings[e[t].name]=e[t].options,o.push(e[t].name))

@@ -70,13 +74,13 @@ else if(e)for(s in e)e.hasOwnProperty(s)&&(n.plugins.settings[s]=e[s],o.push(s))

t.loadPlugin(e)}return i.loaded[e]}}}(t)){constructor(e,t){var i
super(),this.control_input=void 0,this.wrapper=void 0,this.dropdown=void 0,this.control=void 0,this.dropdown_content=void 0,this.order=0,this.settings=void 0,this.input=void 0,this.tabIndex=void 0,this.is_select_tag=void 0,this.rtl=void 0,this.inputId=void 0,this._destroy=void 0,this.sifter=void 0,this.tab_key=!1,this.isOpen=!1,this.isDisabled=!1,this.isRequired=void 0,this.isInvalid=!1,this.isLocked=!1,this.isFocused=!1,this.isInputHidden=!1,this.isSetup=!1,this.ignoreFocus=!1,this.ignoreBlur=!1,this.hasOptions=!1,this.currentResults=null,this.lastValue="",this.caretPos=0,this.loading=0,this.loadedSearches={},this.activeOption=null,this.activeItems=[],this.optgroups={},this.options={},this.options_i=0,this.userOptions={},this.items=[],this.renderCache={item:{},option:{}},F++
var s,n,o,a=m(e)
if(a.tomselect)throw new Error("Tom Select already initialized on this element")
a.tomselect=this,i=(window.getComputedStyle&&window.getComputedStyle(a,null)).getPropertyValue("direction"),this.settings=function(e,t){var i=Object.assign({},d,t),s=i.dataAttr,n=i.labelField,o=i.valueField,r=i.disabledField,a=i.optgroupField,l=i.optgroupLabelField,c=i.optgroupValueField,u=e.tagName.toLowerCase(),h=e.getAttribute("placeholder")||e.getAttribute("data-placeholder")
super(),this.control_input=void 0,this.wrapper=void 0,this.dropdown=void 0,this.control=void 0,this.dropdown_content=void 0,this.order=0,this.settings=void 0,this.input=void 0,this.tabIndex=void 0,this.is_select_tag=void 0,this.rtl=void 0,this.inputId=void 0,this._destroy=void 0,this.sifter=void 0,this.tab_key=!1,this.isOpen=!1,this.isDisabled=!1,this.isRequired=void 0,this.isInvalid=!1,this.isLocked=!1,this.isFocused=!1,this.isInputHidden=!1,this.isSetup=!1,this.ignoreFocus=!1,this.ignoreBlur=!1,this.hasOptions=!1,this.currentResults=null,this.lastValue="",this.caretPos=0,this.loading=0,this.loadedSearches={},this.activeOption=null,this.activeItems=[],this.optgroups={},this.options={},this.options_i=0,this.userOptions={},this.items=[],this.renderCache={item:{},option:{}},k++
var s=y(e)
if(s.tomselect)throw new Error("Tom Select already initialized on this element")
s.tomselect=this,i=(window.getComputedStyle&&window.getComputedStyle(s,null)).getPropertyValue("direction"),this.settings=function(e,t){var i=Object.assign({},p,t),s=i.dataAttr,n=i.labelField,o=i.valueField,r=i.disabledField,a=i.optgroupField,l=i.optgroupLabelField,d=i.optgroupValueField,u=e.tagName.toLowerCase(),h=e.getAttribute("placeholder")||e.getAttribute("data-placeholder")
if(!h&&!i.allowEmptyOption){let t=e.querySelector('option[value=""]')
t&&(h=t.textContent)}var g={placeholder:h,options:[],optgroups:[],items:[],maxItems:null}
return"select"===u?(()=>{var t,d=g.options,u={},h=1,f=e=>{var t=Object.assign({},e.dataset),i=s&&t[s]
return"string"==typeof i&&i.length&&(t=Object.assign(t,JSON.parse(i))),t},v=(e,t)=>{var s=p(e.value)
return"select"===u?(()=>{var t,p=g.options,u={},h=1,f=e=>{var t=Object.assign({},e.dataset),i=s&&t[s]
return"string"==typeof i&&i.length&&(t=Object.assign(t,JSON.parse(i))),t},v=(e,t)=>{var s=c(e.value)
if(s||i.allowEmptyOption)if(u.hasOwnProperty(s)){if(t){var l=u[s][a]
l?Array.isArray(l)?l.push(t):u[s][a]=[l,t]:u[s][a]=t}}else{var c=f(e)
c[n]=c[n]||e.textContent,c[o]=c[o]||s,c[r]=c[r]||e.disabled,c[a]=c[a]||t,c.$option=e,u[s]=c,d.push(c),e.selected&&g.items.push(s)}},m=e=>{var t,i;(i=f(e))[l]=i[l]||e.getAttribute("label")||"",i[c]=i[c]||h++,i[r]=i[r]||e.disabled,g.optgroups.push(i),t=i[c]
l?Array.isArray(l)?l.push(t):u[s][a]=[l,t]:u[s][a]=t}}else{var d=f(e)
d[n]=d[n]||e.textContent,d[o]=d[o]||s,d[r]=d[r]||e.disabled,d[a]=d[a]||t,d.$option=e,u[s]=d,p.push(d),e.selected&&g.items.push(s)}},m=e=>{var t,i;(i=f(e))[l]=i[l]||e.getAttribute("label")||"",i[d]=i[d]||h++,i[r]=i[r]||e.disabled,g.optgroups.push(i),t=i[d]
for(const i of e.children)v(i,t)}

@@ -90,50 +94,51 @@ g.maxItems=e.hasAttribute("multiple")?null:1

for(const e of t)(r={})[n]=e,r[o]=e,g.options.push(r)
g.items=t}})(),Object.assign({},d,g,t)}(a,t),this.input=a,this.tabIndex=a.tabIndex||0,this.is_select_tag="select"===a.tagName.toLowerCase(),this.rtl=/rtl/i.test(i),this.inputId=v(a,"tomselect-"+F),this.isRequired=a.required,this.settings.load&&this.settings.loadThrottle&&(this.settings.load=(s=this.settings.load,n=this.settings.loadThrottle,function(e,t){var i=this
o&&(i.loading=Math.max(i.loading-1,0)),clearTimeout(o),o=setTimeout((function(){o=null,i.loadedSearches[e]=!0,s.call(i,e,t)}),n)})),this.sifter=new r(this.options,{diacritics:this.settings.diacritics}),this.setupOptions(this.settings.options,this.settings.optgroups),delete this.settings.optgroups,delete this.settings.options,this.settings.mode=this.settings.mode||(1===this.settings.maxItems?"single":"multi"),"boolean"!=typeof this.settings.hideSelected&&(this.settings.hideSelected="multi"===this.settings.mode),"boolean"!=typeof this.settings.hidePlaceholder&&(this.settings.hidePlaceholder="multi"!==this.settings.mode)
var l=this.settings.createFilter
"function"!=typeof l&&("string"==typeof l&&(l=new RegExp(l)),l instanceof RegExp?this.settings.createFilter=e=>l.test(e):this.settings.createFilter=()=>!0),this.initializePlugins(this.settings.plugins),this.setupCallbacks(),this.setupTemplates(),this.setup()}setup(){var e,t,i,s,n,o,r,a,l,d=this,p=d.settings,c=d.input
const u={passive:!0},f=d.inputId+"-ts-dropdown"
if(o=d.settings.mode,r=c.getAttribute("class")||"",b(e=m("<div>"),p.wrapperClass,r,o),b(t=m('<div class="items">'),p.inputClass),e.append(t),b(s=d.render("dropdown"),p.dropdownClass,o),b(n=m(`<div style="scroll-behavior: smooth;" role="listbox" id="${f}" tabindex="-1">`),p.dropdownContentClass),s.append(n),m(p.dropdownParent||e).appendChild(s),p.controlInput)i=m(p.controlInput)
else{i=m('<input type="text" autocomplete="off" size="1" />')
for(const e of["autocorrect","autocapitalize","autocomplete"])c.getAttribute(e)&&x(i,{[e]:c.getAttribute(e)})}p.controlInput||(i.tabIndex=c.disabled?-1:d.tabIndex,t.appendChild(i)),x(i,{role:"combobox",haspopup:"listbox","aria-expanded":"false","aria-controls":f}),l=v(i,d.inputId+"-tomselected")
let y="label[for='"+function(e){return e.replace(/['"\\]/g,"\\$&")}(d.inputId)+"']",O=document.querySelector(y)
if(O){x(O,{for:l}),x(n,{"aria-labelledby":v(O,d.inputId+"-ts-label")})}if(d.settings.copyClassesToDropdown&&b(s,r),e.style.width=c.style.width,d.plugins.names.length&&(a="plugin-"+d.plugins.names.join(" plugin-"),b([e,s],a)),(null===p.maxItems||p.maxItems>1)&&d.is_select_tag&&x(c,{multiple:"multiple"}),d.settings.placeholder&&x(i,{placeholder:p.placeholder}),!d.settings.splitOn&&d.settings.delimiter){var w=d.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")
d.settings.splitOn=new RegExp("\\s*"+w+"+\\s*")}d.control=t,d.control_input=i,d.wrapper=e,d.dropdown=s,d.dropdown_content=n,d.control_input.type=c.type,g(s,"mouseenter",(e=>{var t=A(e.target,"[data-selectable]",s)
if(t)return d.onOptionHover(e,t)}),{capture:!0}),g(t,"mousedown",(e=>{if(e.target==i)return d.clearActiveItems(),e.stopPropagation(),void d.inputState()
var s=A(e.target,"."+d.settings.itemClass,t)
return s?d.onItemSelect(e,s):d.onMouseDown(e)})),g(t,"click",(e=>d.onClick(e))),g(i,"keydown",(e=>d.onKeyDown(e))),g(i,"keyup",(e=>d.onKeyUp(e))),g(i,"keypress",(e=>d.onKeyPress(e))),g(i,"resize",(()=>d.positionDropdown()),u),g(i,"blur",(e=>d.onBlur(e))),g(i,"focus",(e=>{d.ignoreBlur=!1,d.onFocus(e)})),g(i,"paste",(e=>d.onPaste(e)))
var I=e=>{var t=A(e.target,"[data-selectable]",d.dropdown)
g.items=t}})(),Object.assign({},p,g,t)}(s,t),this.input=s,this.tabIndex=s.tabIndex||0,this.is_select_tag="select"===s.tagName.toLowerCase(),this.rtl=/rtl/i.test(i),this.inputId=m(s,"tomselect-"+k),this.isRequired=s.required,this.sifter=new a(this.options,{diacritics:this.settings.diacritics}),this.setupOptions(this.settings.options,this.settings.optgroups),delete this.settings.optgroups,delete this.settings.options,this.settings.mode=this.settings.mode||(1===this.settings.maxItems?"single":"multi"),"boolean"!=typeof this.settings.hideSelected&&(this.settings.hideSelected="multi"===this.settings.mode),"boolean"!=typeof this.settings.hidePlaceholder&&(this.settings.hidePlaceholder="multi"!==this.settings.mode)
var n=this.settings.createFilter
"function"!=typeof n&&("string"==typeof n&&(n=new RegExp(n)),n instanceof RegExp?this.settings.createFilter=e=>n.test(e):this.settings.createFilter=()=>!0),this.initializePlugins(this.settings.plugins),this.setupCallbacks(),this.setupTemplates(),this.setup()}setup(){var e,t,i,s,n,o,r,a,l,d=this,p=d.settings,c=d.input
const u={passive:!0},h=d.inputId+"-ts-dropdown"
if(o=d.settings.mode,r=c.getAttribute("class")||"",w(e=y("<div>"),p.wrapperClass,r,o),w(t=y('<div class="items">'),p.inputClass),e.append(t),w(s=d.render("dropdown"),p.dropdownClass,o),w(n=y(`<div role="listbox" id="${h}" tabindex="-1">`),p.dropdownContentClass),s.append(n),y(p.dropdownParent||e).appendChild(s),p.controlInput)i=y(p.controlInput)
else{i=y('<input type="text" autocomplete="off" size="1" />')
for(const e of["autocorrect","autocapitalize","autocomplete"])c.getAttribute(e)&&F(i,{[e]:c.getAttribute(e)})}p.controlInput||(i.tabIndex=c.disabled?-1:d.tabIndex,t.appendChild(i)),F(i,{role:"combobox",haspopup:"listbox","aria-expanded":"false","aria-controls":h}),l=m(i,d.inputId+"-tomselected")
let v="label[for='"+function(e){return e.replace(/['"\\]/g,"\\$&")}(d.inputId)+"']",O=document.querySelector(v)
if(O){F(O,{for:l}),F(n,{"aria-labelledby":m(O,d.inputId+"-ts-label")})}if(d.settings.copyClassesToDropdown&&w(s,r),e.style.width=c.style.width,d.plugins.names.length&&(a="plugin-"+d.plugins.names.join(" plugin-"),w([e,s],a)),(null===p.maxItems||p.maxItems>1)&&d.is_select_tag&&F(c,{multiple:"multiple"}),d.settings.placeholder&&F(i,{placeholder:p.placeholder}),!d.settings.splitOn&&d.settings.delimiter){var b=d.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")
d.settings.splitOn=new RegExp("\\s*"+b+"+\\s*")}var I,C,A
this.settings.load&&this.settings.loadThrottle&&(this.settings.load=(I=this.settings.load,C=this.settings.loadThrottle,function(e,t){var i=this
A&&(i.loading=Math.max(i.loading-1,0)),clearTimeout(A),A=setTimeout((function(){A=null,i.loadedSearches[e]=!0,I.call(i,e,t)}),C)})),d.control=t,d.control_input=i,d.wrapper=e,d.dropdown=s,d.dropdown_content=n,d.control_input.type=c.type,f(s,"mouseenter",(e=>{var t=_(e.target,"[data-selectable]",s)
if(t)return d.onOptionHover(e,t)}),{capture:!0}),f(t,"mousedown",(e=>{if(e.target==i)return d.clearActiveItems(),e.stopPropagation(),void d.inputState()
var s=_(e.target,"."+d.settings.itemClass,t)
return s?d.onItemSelect(e,s):d.onMouseDown(e)})),f(t,"click",(e=>d.onClick(e))),f(i,"keydown",(e=>d.onKeyDown(e))),f(i,"keyup",(e=>d.onKeyUp(e))),f(i,"keypress",(e=>d.onKeyPress(e))),f(i,"resize",(()=>d.positionDropdown()),u),f(i,"blur",(e=>d.onBlur(e))),f(i,"focus",(e=>{d.ignoreBlur=!1,d.onFocus(e)})),f(i,"paste",(e=>d.onPaste(e)))
var S=e=>{var t=_(e.target,"[data-selectable]",d.dropdown)
if(!t&&!d.wrapper.contains(e.target))return d.isFocused&&d.blur(),void d.inputState()
h(e,!0),t&&d.onOptionSelect(e,t)},C=()=>{d.isOpen&&d.positionDropdown()}
g(document,"mousedown",I),g(window,"sroll",C,u),g(window,"resize",C,u),d._destroy=()=>{document.removeEventListener("mousedown",I),window.removeEventListener("sroll",C),window.removeEventListener("resize",C)},this.revertSettings={innerHTML:c.innerHTML,tabIndex:c.tabIndex},c.tabIndex=-1,x(c,{hidden:"hidden"}),c.insertAdjacentElement("afterend",d.wrapper),d.setValue(p.items),delete p.items,g(c,"invalid",(e=>{h(e),d.isInvalid||(d.isInvalid=!0,d.refreshState())})),d.updateOriginalInput(),d.refreshItems(),d.refreshState(),d.inputState(),d.isSetup=!0,c.disabled&&d.disable(),d.on("change",this.onChange),b(c,"tomselected"),d.trigger("initialize"),!0===p.preload&&d.load("")}setupOptions(e=[],t=[]){for(const t of e)this.registerOption(t)
g(e,!0),t&&d.onOptionSelect(e,t)},x=()=>{d.isOpen&&d.positionDropdown()}
f(document,"mousedown",S),f(window,"sroll",x,u),f(window,"resize",x,u),d._destroy=()=>{document.removeEventListener("mousedown",S),window.removeEventListener("sroll",x),window.removeEventListener("resize",x)},this.revertSettings={innerHTML:c.innerHTML,tabIndex:c.tabIndex},c.tabIndex=-1,F(c,{hidden:"hidden"}),c.insertAdjacentElement("afterend",d.wrapper),d.setValue(p.items),delete p.items,f(c,"invalid",(e=>{g(e),d.isInvalid||(d.isInvalid=!0,d.refreshState())})),d.updateOriginalInput(),d.refreshItems(),d.refreshState(),d.inputState(),d.isSetup=!0,c.disabled&&d.disable(),d.on("change",this.onChange),w(c,"tomselected"),d.trigger("initialize"),!0===p.preload&&d.load("")}setupOptions(e=[],t=[]){for(const t of e)this.registerOption(t)
for(const e of t)this.registerOptionGroup(e)}setupTemplates(){var e=this,t=e.settings.labelField,i=e.settings.optgroupLabelField,s={optgroup:(e,t)=>{let i=document.createElement("div")
return i.className="optgroup",i.appendChild(e.options),i},optgroup_header:(e,t)=>'<div class="optgroup-header">'+t(e[i])+"</div>",option:(e,i)=>"<div>"+i(e[t])+"</div>",item:(e,i)=>"<div>"+i(e[t])+"</div>",option_create:(e,t)=>'<div class="create">Add <strong>'+t(e.input)+"</strong>&hellip;</div>",no_results:(e,t)=>'<div class="no-results">No results found</div>',loading:(e,t)=>'<div class="spinner"></div>',not_loading:()=>{},dropdown:()=>'<div style="display:none"></div>'}
return i.className="optgroup",i.appendChild(e.options),i},optgroup_header:(e,t)=>'<div class="optgroup-header">'+t(e[i])+"</div>",option:(e,i)=>"<div>"+i(e[t])+"</div>",item:(e,i)=>"<div>"+i(e[t])+"</div>",option_create:(e,t)=>'<div class="create">Add <strong>'+t(e.input)+"</strong>&hellip;</div>",no_results:(e,t)=>'<div class="no-results">No results found</div>',loading:(e,t)=>'<div class="spinner"></div>',not_loading:()=>{},dropdown:()=>"<div></div>"}
e.settings.render=Object.assign({},s,e.settings.render)}setupCallbacks(){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)}onClick(e){var t=this
t.isFocused&&t.isOpen||(t.focus(),h(e))}onMouseDown(e){var t=this
t.isFocused&&t.isOpen||(t.focus(),g(e))}onMouseDown(e){var t=this
if(t.isFocused)return"single"!==t.settings.mode&&t.setActiveItem(),t.open(),!1
setTimeout((()=>t.focus()),0)}onChange(){y(this.input,"input"),y(this.input,"change")}onPaste(e){var t=this
t.isFull()||t.isInputHidden||t.isLocked?h(e):t.settings.splitOn&&setTimeout((()=>{var e=t.inputValue()
setTimeout((()=>t.focus()),0)}onChange(){O(this.input,"input"),O(this.input,"change")}onPaste(e){var t=this
t.isFull()||t.isInputHidden||t.isLocked?g(e):t.settings.splitOn&&setTimeout((()=>{var e=t.inputValue()
if(e.match(t.settings.splitOn)){var i=e.trim().split(t.settings.splitOn)
for(const e of i)t.createItem(e)}}),0)}onKeyPress(e){var t=this
if(!t.isLocked){var i=String.fromCharCode(e.keyCode||e.which)
return t.settings.create&&"multi"===t.settings.mode&&i===t.settings.delimiter?(t.createItem(),void h(e)):void 0}h(e)}onKeyDown(e){var t=this
if(t.isLocked)9!==e.keyCode&&h(e)
else{switch(e.keyCode){case 65:if(f(l,e))return void t.selectAll()
return t.settings.create&&"multi"===t.settings.mode&&i===t.settings.delimiter?(t.createItem(),void g(e)):void 0}g(e)}onKeyDown(e){var t=this
if(t.isLocked)9!==e.keyCode&&g(e)
else{switch(e.keyCode){case 65:if(v(d,e))return void t.selectAll()
break
case 27:return t.isOpen&&(h(e,!0),t.close()),void t.clearActiveItems()
case 27:return t.isOpen&&(g(e,!0),t.close()),void t.clearActiveItems()
case 40:if(!t.isOpen&&t.hasOptions)t.open()
else if(t.activeOption){let e=t.getAdjacent(t.activeOption,1)
e&&t.setActiveOption(e)}return void h(e)
e&&t.setActiveOption(e)}return void g(e)
case 38:if(t.activeOption){let e=t.getAdjacent(t.activeOption,-1)
e&&t.setActiveOption(e)}return void h(e)
case 13:return void(t.isOpen&&t.activeOption&&(t.onOptionSelect(e,t.activeOption),h(e)))
e&&t.setActiveOption(e)}return void g(e)
case 13:return void(t.isOpen&&t.activeOption?(t.onOptionSelect(e,t.activeOption),g(e)):t.settings.create&&t.createItem()&&g(e))
case 37:return void t.advanceSelection(-1,e)
case 39:return void t.advanceSelection(1,e)
case 9:return t.settings.selectOnTab&&t.isOpen&&t.activeOption&&(t.tab_key=!0,t.onOptionSelect(e,t.activeOption),h(e),t.tab_key=!1),void(t.settings.create&&t.createItem()&&h(e))
case 8:case 46:return void t.deleteSelection(e)}t.isInputHidden&&!f(l,e)&&h(e)}}onKeyUp(e){var t=this
if(t.isLocked)h(e)
case 9:return void(t.settings.selectOnTab&&(t.isOpen&&t.activeOption&&(t.tab_key=!0,t.onOptionSelect(e,t.activeOption),g(e),t.tab_key=!1),t.settings.create&&t.createItem()&&g(e)))
case 8:case 46:return void t.deleteSelection(e)}t.isInputHidden&&!v(d,e)&&g(e)}}onKeyUp(e){var t=this
if(t.isLocked)g(e)
else{var i=t.inputValue()
t.lastValue!==i&&(t.lastValue=i,t.settings.shouldLoad.call(t,i)&&t.load(i),t.refreshOptions(),t.trigger("type",i))}}onFocus(e){var t=this,i=t.isFocused
if(t.isDisabled)return t.blur(),void h(e)
if(t.isDisabled)return t.blur(),void g(e)
t.ignoreFocus||(t.isFocused=!0,"focus"===t.settings.preload&&t.load(""),i||t.trigger("focus"),t.activeItems.length||(t.showInput(),t.setActiveItem(),t.refreshOptions(!!t.settings.openOnFocus)),t.refreshState())}onBlur(e){var t=this

@@ -144,42 +149,47 @@ if(t.isFocused){if(t.isFocused=!1,t.ignoreFocus=!1,!t.ignoreBlur&&document.activeElement===t.dropdown_content)return t.ignoreBlur=!0,void t.onFocus(e)

t&&(t.parentElement&&t.parentElement.matches("[data-disabled]")||(t.classList.contains("create")?s.createItem(null,!0,(()=>{s.settings.closeAfterSelect&&s.close()})):void 0!==(i=t.dataset.value)&&(s.lastQuery=null,s.addItem(i),s.settings.closeAfterSelect?s.close():!s.settings.hideSelected&&e.type&&/mouse/.test(e.type)&&s.setActiveOption(s.getOption(i)))))}onItemSelect(e,t){var i=this
i.isLocked||"multi"===i.settings.mode&&(h(e),i.setActiveItem(t,e))}load(e){var t=this,i=t.settings.load
i&&(t.loadedSearches.hasOwnProperty(e)||(b(t.wrapper,t.settings.loadingClass),t.loading++,i.call(t,e,(function(e,i){t.loading=Math.max(t.loading-1,0),t.lastQuery=null,t.clearActiveOption(),t.setupOptions(e,i),t.refreshOptions(t.isFocused&&!t.isInputHidden),t.loading||w(t.wrapper,t.settings.loadingClass),t.trigger("load",e,i)}))))}onSearchChange(e){this.load(e)}setTextboxValue(e=""){var t=this.control_input
t.value!==e&&(t.value=e,y(t,"update"),this.lastValue=e)}getValue(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}setValue(e,t){u(this,t?[]:["change"],(()=>{this.clear(t),this.addItems(e,t)}))}setMaxItems(e){0===e&&(e=null),this.settings.maxItems=e,this.refreshState()}setActiveItem(e,t){var i,s,n,o,r,a,d=this
if("single"!==d.settings.mode){if(!e)return d.clearActiveItems(),void(d.isFocused&&d.showInput())
if("mousedown"===(i=t&&t.type.toLowerCase())&&f("shiftKey",t)&&d.activeItems.length){for(a=d.getLastActive(),(n=Array.prototype.indexOf.call(d.control.children,a))>(o=Array.prototype.indexOf.call(d.control.children,e))&&(r=n,n=o,o=r),s=n;s<=o;s++)e=d.control.children[s],-1===d.activeItems.indexOf(e)&&d.setActiveItemClass(e)
h(t)}else"mousedown"===i&&f(l,t)||"keydown"===i&&f("shiftKey",t)?e.classList.contains("active")?d.removeActiveItem(e):d.setActiveItemClass(e):(d.clearActiveItems(),d.setActiveItemClass(e))
d.hideInput(),d.isFocused||d.focus()}}setActiveItemClass(e){var t=this.control.querySelector(".last-active")
t&&w(t,"last-active"),b(e,"active last-active"),-1==this.activeItems.indexOf(e)&&this.activeItems.push(e)}removeActiveItem(e){var t=this.activeItems.indexOf(e)
this.activeItems.splice(t,1),w(e,"active")}clearActiveItems(){w(this.activeItems,"active"),this.activeItems=[]}setActiveOption(e){var t,i,s
i.isLocked||"multi"===i.settings.mode&&(g(e),i.setActiveItem(t,e))}load(e){var t=this,i=t.settings.load
if(!i)return
if(t.loadedSearches.hasOwnProperty(e))return
w(t.wrapper,t.settings.loadingClass),t.loading++
const s=t.loadCallback.bind(t)
i.call(t,e,s)}loadCallback(e,t){const i=this
i.loading=Math.max(i.loading-1,0),i.lastQuery=null,i.clearActiveOption(),i.setupOptions(e,t),i.refreshOptions(i.isFocused&&!i.isInputHidden),i.loading||I(i.wrapper,i.settings.loadingClass),i.trigger("load",e,t)}onSearchChange(e){this.load(e)}setTextboxValue(e=""){var t=this.control_input
t.value!==e&&(t.value=e,O(t,"update"),this.lastValue=e)}getValue(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}setValue(e,t){h(this,t?[]:["change"],(()=>{this.clear(t),this.addItems(e,t)}))}setMaxItems(e){0===e&&(e=null),this.settings.maxItems=e,this.refreshState()}setActiveItem(e,t){var i,s,n,o,r,a,l=this
if("single"!==l.settings.mode){if(!e)return l.clearActiveItems(),void(l.isFocused&&l.showInput())
if("mousedown"===(i=t&&t.type.toLowerCase())&&v("shiftKey",t)&&l.activeItems.length){for(a=l.getLastActive(),(n=Array.prototype.indexOf.call(l.control.children,a))>(o=Array.prototype.indexOf.call(l.control.children,e))&&(r=n,n=o,o=r),s=n;s<=o;s++)e=l.control.children[s],-1===l.activeItems.indexOf(e)&&l.setActiveItemClass(e)
g(t)}else"mousedown"===i&&v(d,t)||"keydown"===i&&v("shiftKey",t)?e.classList.contains("active")?l.removeActiveItem(e):l.setActiveItemClass(e):(l.clearActiveItems(),l.setActiveItemClass(e))
l.hideInput(),l.isFocused||l.focus()}}setActiveItemClass(e){var t=this.control.querySelector(".last-active")
t&&I(t,"last-active"),w(e,"active last-active"),-1==this.activeItems.indexOf(e)&&this.activeItems.push(e)}removeActiveItem(e){var t=this.activeItems.indexOf(e)
this.activeItems.splice(t,1),I(e,"active")}clearActiveItems(){I(this.activeItems,"active"),this.activeItems=[]}setActiveOption(e){var t,i,s
if(e===this.activeOption)return
if(this.clearActiveOption(),!e)return
this.activeOption=e,x(this.control_input,{"aria-activedescendant":e.getAttribute("id")}),x(e,{"aria-selected":"true"}),b(e,"active"),t=this.dropdown_content.clientHeight
this.activeOption=e,F(this.control_input,{"aria-activedescendant":e.getAttribute("id")}),F(e,{"aria-selected":"true"}),w(e,"active"),t=this.dropdown_content.clientHeight
let n=this.dropdown_content.scrollTop||0
i=this.activeOption.offsetHeight,(s=this.activeOption.getBoundingClientRect().top-this.dropdown_content.getBoundingClientRect().top+n)+i>t+n?this.dropdown_content.scrollTop=s-t+i:s<n&&(this.dropdown_content.scrollTop=s)}clearActiveOption(){this.activeOption&&(w(this.activeOption,"active"),this.activeOption.removeAttribute("aria-selected")),this.activeOption=null,this.control_input.removeAttribute("aria-activedescendant")}selectAll(){"single"!==this.settings.mode&&(this.activeItems=this.controlChildren(),this.activeItems.length&&(b(this.activeItems,"active"),this.hideInput(),this.close()),this.focus())}inputState(){var e=this
e.settings.controlInput||(e.activeItems.length>0||!e.isFocused&&this.settings.hidePlaceholder&&e.items.length>0?(e.setTextboxValue(),e.isInputHidden=!0,b(e.wrapper,"input-hidden")):(e.isInputHidden=!1,w(e.wrapper,"input-hidden")))}hideInput(){this.inputState()}showInput(){this.inputState()}inputValue(){return this.control_input.value.trim()}focus(){var e=this
i=this.activeOption.offsetHeight,(s=this.activeOption.getBoundingClientRect().top-this.dropdown_content.getBoundingClientRect().top+n)+i>t+n?this.dropdown_content.scrollTop=s-t+i:s<n&&(this.dropdown_content.scrollTop=s)}clearActiveOption(){this.activeOption&&(I(this.activeOption,"active"),this.activeOption.removeAttribute("aria-selected")),this.activeOption=null,this.control_input.removeAttribute("aria-activedescendant")}selectAll(){"single"!==this.settings.mode&&(this.activeItems=this.controlChildren(),this.activeItems.length&&(w(this.activeItems,"active"),this.hideInput(),this.close()),this.focus())}inputState(){var e=this
e.settings.controlInput||(e.activeItems.length>0||!e.isFocused&&this.settings.hidePlaceholder&&e.items.length>0?(e.setTextboxValue(),e.isInputHidden=!0,w(e.wrapper,"input-hidden")):(e.isInputHidden=!1,I(e.wrapper,"input-hidden")))}hideInput(){this.inputState()}showInput(){this.inputState()}inputValue(){return this.control_input.value.trim()}focus(){var e=this
e.isDisabled||(e.ignoreFocus=!0,e.control_input.focus(),setTimeout((()=>{e.ignoreFocus=!1,e.onFocus()}),0))}blur(){this.control_input.blur(),this.onBlur(null)}getScoreFunction(e){return this.sifter.getScoreFunction(e,this.getSearchOptions())}getSearchOptions(){var e,t=this.settings
return"string"==typeof t.sortField&&(e=[{field:t.sortField}]),{fields:t.searchField,conjunction:t.searchConjunction,sort:e,nesting:t.nesting}}search(e){var t,i,s,n=this,o=n.settings,r=this.getSearchOptions()
if(o.score&&"function"!=typeof(s=n.settings.score.call(n,e)))throw new Error('Tom Select "score" setting must be a function that returns a function')
if(e!==n.lastQuery?(n.lastQuery=e,i=n.sifter.search(e,Object.assign(r,{score:s})),n.currentResults=i):i=Object.assign({},n.currentResults),o.hideSelected)for(t=i.items.length-1;t>=0;t--)-1!==n.items.indexOf(p(i.items[t].id))&&i.items.splice(t,1)
return i}refreshOptions(e=!0){var t,i,s,n,o,r,l,d,c,u,h,g,f,v=this,m=v.inputValue(),y=v.search(m),O=v.activeOption&&p(v.activeOption.dataset.value),b=v.settings.shouldOpen||!1
for(n=y.items.length,"number"==typeof v.settings.maxOptions&&(n=Math.min(n,v.settings.maxOptions)),n>0&&(b=!0),g={},o=[],t=0;t<n;t++){let e=v.options[y.items[t].id],n=p(e[v.settings.valueField]),a=v.getOption(n)
for(a||(a=v.render("option",e)),v.settings.hideSelected||a.classList.toggle("selected",v.items.includes(n)),r=e[v.settings.optgroupField]||"",i=0,s=(l=Array.isArray(r)?r:[r])&&l.length;i<s;i++)r=l[i],v.optgroups.hasOwnProperty(r)||(r=""),g.hasOwnProperty(r)||(g[r]=document.createDocumentFragment(),o.push(r)),i>0&&(a=a.cloneNode(!0),w(a,"active"),a.removeAttribute("aria-selected")),g[r].appendChild(a)}for(r of(this.settings.lockOptgroupOrder&&o.sort(((e,t)=>(v.optgroups[e]&&v.optgroups[e].$order||0)-(v.optgroups[t]&&v.optgroups[t].$order||0))),d=document.createDocumentFragment(),o))if(v.optgroups.hasOwnProperty(r)&&g[r].children.length){let e=document.createDocumentFragment()
e.appendChild(v.render("optgroup_header",v.optgroups[r])),e.appendChild(g[r])
if(e!==n.lastQuery?(n.lastQuery=e,i=n.sifter.search(e,Object.assign(r,{score:s})),n.currentResults=i):i=Object.assign({},n.currentResults),o.hideSelected)for(t=i.items.length-1;t>=0;t--)-1!==n.items.indexOf(c(i.items[t].id))&&i.items.splice(t,1)
return i}refreshOptions(e=!0){var t,i,s,n,o,r,a,d,p,u,h,g,f,v=this,m=v.inputValue(),y=v.search(m),O=v.activeOption&&c(v.activeOption.dataset.value),b=v.settings.shouldOpen||!1
for(n=y.items.length,"number"==typeof v.settings.maxOptions&&(n=Math.min(n,v.settings.maxOptions)),n>0&&(b=!0),g={},o=[],t=0;t<n;t++){let e=v.options[y.items[t].id],n=c(e[v.settings.valueField]),l=v.getOption(n)
for(l||(l=v.render("option",e)),v.settings.hideSelected||l.classList.toggle("selected",v.items.includes(n)),r=e[v.settings.optgroupField]||"",i=0,s=(a=Array.isArray(r)?r:[r])&&a.length;i<s;i++)r=a[i],v.optgroups.hasOwnProperty(r)||(r=""),g.hasOwnProperty(r)||(g[r]=document.createDocumentFragment(),o.push(r)),i>0&&(l=l.cloneNode(!0),I(l,"active"),l.removeAttribute("aria-selected")),g[r].appendChild(l)}for(r of(this.settings.lockOptgroupOrder&&o.sort(((e,t)=>(v.optgroups[e]&&v.optgroups[e].$order||0)-(v.optgroups[t]&&v.optgroups[t].$order||0))),d=document.createDocumentFragment(),o))if(v.optgroups.hasOwnProperty(r)&&g[r].children.length){let e=document.createDocumentFragment()
e.append(v.render("optgroup_header",v.optgroups[r])),e.append(g[r])
let t=v.render("optgroup",{group:v.optgroups[r],options:e})
d.appendChild(t)}else d.appendChild(g[r])
if(v.dropdown_content.innerHTML="",v.dropdown_content.appendChild(d),v.settings.highlight&&(v.dropdown_content,f=document.querySelectorAll("span.highlight"),Array.prototype.forEach.call(f,(function(e,t){var i=e.parentNode
i.replaceChild(e.firstChild,e),i.normalize()})),y.query.length&&y.tokens.length))for(const e of y.tokens)a(v.dropdown_content,e.regex)
var I=e=>{let t=v.render(e,{input:m})
d.append(t)}else d.append(g[r])
if(v.dropdown_content.innerHTML="",v.dropdown_content.append(d),v.settings.highlight&&(v.dropdown_content,f=document.querySelectorAll("span.highlight"),Array.prototype.forEach.call(f,(function(e,t){var i=e.parentNode
i.replaceChild(e.firstChild,e),i.normalize()})),y.query.length&&y.tokens.length))for(const e of y.tokens)l(v.dropdown_content,e.regex)
var w=e=>{let t=v.render(e,{input:m})
return t&&(b=!0,v.dropdown_content.insertBefore(t,v.dropdown_content.firstChild)),t}
if(v.settings.shouldLoad.call(v,m)?v.loading?I("loading"):0===y.items.length&&I("no_results"):I("not_loading"),(c=v.canCreate(m))&&(h=I("option_create")),v.hasOptions=y.items.length>0||c,b){if(y.items.length>0){if(!(u=O&&v.getOption(O))||!v.dropdown_content.contains(u)){let e=0
if(v.settings.shouldLoad.call(v,m)?v.loading?w("loading"):0===y.items.length&&w("no_results"):w("not_loading"),(p=v.canCreate(m))&&(h=w("option_create")),v.hasOptions=y.items.length>0||p,b){if(y.items.length>0){if(!(u=O&&v.getOption(O))||!v.dropdown_content.contains(u)){let e=0
h&&!v.settings.addPrecedence&&(e=1),u=v.selectable()[e]}}else u=h
v.setActiveOption(u),e&&!v.isOpen&&v.open()}else v.clearActiveOption(),e&&v.isOpen&&v.close()}selectable(){return this.dropdown_content.querySelectorAll("[data-selectable]")}addOption(e){var t,i=this
v.setActiveOption(u),e&&!v.isOpen&&v.open()}else v.clearActiveOption(),e&&v.isOpen&&v.close(!1)}selectable(){return this.dropdown_content.querySelectorAll("[data-selectable]")}addOption(e){var t,i=this
if(Array.isArray(e))for(const t of e)i.addOption(t)
else(t=i.registerOption(e))&&(i.userOptions[t]=!0,i.lastQuery=null,i.trigger("option_add",t,e))}registerOption(e){var t=p(e[this.settings.valueField])
return null!==t&&!this.options.hasOwnProperty(t)&&(e.$order=e.$order||++this.order,e.$id=this.inputId+"-opt-"+this.options_i++,this.options[t]=e,t)}registerOptionGroup(e){var t=p(e[this.settings.optgroupValueField])
else(t=i.registerOption(e))&&(i.userOptions[t]=!0,i.lastQuery=null,i.trigger("option_add",t,e))}registerOption(e){var t=c(e[this.settings.valueField])
return null!==t&&!this.options.hasOwnProperty(t)&&(e.$order=e.$order||++this.order,e.$id=this.inputId+"-opt-"+this.options_i++,this.options[t]=e,t)}registerOptionGroup(e){var t=c(e[this.settings.optgroupValueField])
return null!==t&&(e.$order=e.$order||++this.order,this.optgroups[t]=e,t)}addOptionGroup(e,t){var i
t[this.settings.optgroupValueField]=e,(i=this.registerOptionGroup(t))&&this.trigger("optgroup_add",i,t)}removeOptionGroup(e){this.optgroups.hasOwnProperty(e)&&(delete this.optgroups[e],this.clearCache(),this.trigger("optgroup_remove",e))}clearOptionGroups(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")}updateOption(e,t){var i,s,n,o,r,a,l,d=this
if(e=p(e),n=p(t[d.settings.valueField]),null!==e&&d.options.hasOwnProperty(e)){if("string"!=typeof n)throw new Error("Value must be set in option data")
l=d.options[e].$order,n!==e&&(delete d.options[e],-1!==(o=d.items.indexOf(e))&&d.items.splice(o,1,n)),t.$order=t.$order||l,d.options[n]=t,r=d.renderCache.item,a=d.renderCache.option,r&&(delete r[e],delete r[n]),a&&(delete a[e],delete a[n]),-1!==d.items.indexOf(n)&&(i=d.getItem(e),s=d.render("item",t),i.classList.contains("active")&&b(s,"active"),i.parentNode.insertBefore(s,i),i.remove()),d.lastQuery=null,d.isOpen&&d.refreshOptions(!1)}}removeOption(e,t){var i=this
e=p(e)
if(e=c(e),n=c(t[d.settings.valueField]),null!==e&&d.options.hasOwnProperty(e)){if("string"!=typeof n)throw new Error("Value must be set in option data")
l=d.options[e].$order,n!==e&&(delete d.options[e],-1!==(o=d.items.indexOf(e))&&d.items.splice(o,1,n)),t.$order=t.$order||l,d.options[n]=t,r=d.renderCache.item,a=d.renderCache.option,r&&(delete r[e],delete r[n]),a&&(delete a[e],delete a[n]),-1!==d.items.indexOf(n)&&(i=d.getItem(e),s=d.render("item",t),i.classList.contains("active")&&w(s,"active"),i.parentNode.insertBefore(s,i),i.remove()),d.lastQuery=null,d.isOpen&&d.refreshOptions(!1)}}removeOption(e,t){var i=this
e=c(e)
var s=i.renderCache.item,n=i.renderCache.option

@@ -191,3 +201,3 @@ s&&delete s[e],n&&delete n[e],delete i.userOptions[e],delete i.options[e],i.lastQuery=null,i.trigger("option_remove",e),i.removeItem(e,t)}clearOptions(){this.loadedSearches={},this.userOptions={},this.clearCache()

if(e){s="item"==i?this.controlChildren():this.dropdown_content.querySelectorAll("[data-selectable]")
for(let i=0;i<s.length;i++)if(s[i]==e)return t>0?s[i+1]:s[i-1]}}getElementWithValue(e,t){if(null!==(e=p(e)))for(const i of t){let t=i
for(let i=0;i<s.length;i++)if(s[i]==e)return t>0?s[i+1]:s[i-1]}}getElementWithValue(e,t){if(null!==(e=c(e)))for(const i of t){let t=i
if(t.getAttribute("data-value")===e)return t}}getItem(e){return this.getElementWithValue(e,this.control.children)}addItems(e,t){var i=this

@@ -199,11 +209,11 @@ i.buffer=document.createDocumentFragment()

var n=i.control
n.insertBefore(i.buffer,n.firstChild),i.buffer=null}addItem(e,t){u(this,t?[]:["change"],(()=>{var i,s,n=this,o=n.settings.mode
if(e=p(e),(-1===n.items.indexOf(e)||("single"===o&&n.close(),"single"!==o&&n.settings.duplicates))&&n.options.hasOwnProperty(e)&&("single"===o&&n.clear(t),"multi"!==o||!n.isFull())){if(i=n.render("item",n.options[e]),n.control.contains(i)&&(i=i.cloneNode(!0)),s=n.isFull(),n.items.splice(n.caretPos,0,e),n.insertAtCaret(i),n.isSetup){let s=n.selectable()
n.insertBefore(i.buffer,n.firstChild),i.buffer=null}addItem(e,t){h(this,t?[]:["change"],(()=>{var i,s,n=this,o=n.settings.mode
if(e=c(e),(-1===n.items.indexOf(e)||("single"===o&&n.close(),"single"!==o&&n.settings.duplicates))&&n.options.hasOwnProperty(e)&&("single"===o&&n.clear(t),"multi"!==o||!n.isFull())){if(i=n.render("item",n.options[e]),n.control.contains(i)&&(i=i.cloneNode(!0)),s=n.isFull(),n.items.splice(n.caretPos,0,e),n.insertAtCaret(i),n.isSetup){let s=n.selectable()
if(!n.isPending){let t=n.getOption(e),i=n.getAdjacent(t,1)
n.refreshOptions(n.isFocused&&"single"!==o),i&&n.setActiveOption(i)}!s.length||n.isFull()?n.close():n.isPending||n.positionDropdown(),n.trigger("item_add",e,i),n.isPending||n.updateOriginalInput({silent:t})}(!n.isPending||!s&&n.isFull())&&n.refreshState()}}))}removeItem(e,t){var i,s,n=this,o=n.getItem(e)
o&&(e=p(o.dataset.value),-1!==(i=n.items.indexOf(e))&&(o.remove(),o.classList.contains("active")&&(s=n.activeItems.indexOf(o),n.activeItems.splice(s,1),w(o,"active")),n.items.splice(i,1),n.lastQuery=null,!n.settings.persist&&n.userOptions.hasOwnProperty(e)&&n.removeOption(e,t),i<n.caretPos&&n.setCaret(n.caretPos-1),n.updateOriginalInput({silent:t}),n.refreshState(),n.positionDropdown(),n.trigger("item_remove",e,o)))}createItem(e,t=!0,i){var s,n=this,o=n.caretPos
o&&(e=c(o.dataset.value),-1!==(i=n.items.indexOf(e))&&(o.remove(),o.classList.contains("active")&&(s=n.activeItems.indexOf(o),n.activeItems.splice(s,1),I(o,"active")),n.items.splice(i,1),n.lastQuery=null,!n.settings.persist&&n.userOptions.hasOwnProperty(e)&&n.removeOption(e,t),i<n.caretPos&&n.setCaret(n.caretPos-1),n.updateOriginalInput({silent:t}),n.refreshState(),n.positionDropdown(),n.trigger("item_remove",e,o)))}createItem(e,t=!0,i){var s,n=this,o=n.caretPos
if(e=e||n.inputValue(),"function"!=typeof i&&(i=()=>{}),!n.canCreate(e))return i(),!1
n.lock()
var r=!1,a=e=>{if(n.unlock(),!e||"object"!=typeof e)return i()
var s=p(e[n.settings.valueField])
var s=c(e[n.settings.valueField])
if("string"!=typeof s)return i()

@@ -221,9 +231,9 @@ n.setTextboxValue(),n.addOption(e),n.setCaret(o),n.addItem(s),n.refreshOptions(t&&"single"!==n.settings.mode),i(e),r=!0}

e.isInvalid=t,e.control_input.required=t,this.isRequired&&(e.input.required=!t)}}isFull(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems}updateOriginalInput(e={}){var t,i,s=this
if(s.is_select_tag)for(s.input.querySelectorAll("option[selected]").forEach((e=>{-1==s.items.indexOf(e.value)&&e.removeAttribute("selected")})),t=s.items.length-1;t>=0;t--){var n
if(s.is_select_tag)for(s.input.querySelectorAll("option[selected]").forEach((e=>{-1==s.items.indexOf(e.value)&&(e.selected=!1,e.removeAttribute("selected"))})),t=s.items.length-1;t>=0;t--){var n
if(i=s.items[t],!(n=s.options[i].$option)){const e=s.options[i][s.settings.labelField]||""
n=m('<option value="'+c(i)+'">'+c(e)+"</option>"),s.options[i].$option=n}x(n,{selected:"true"}),s.input.prepend(n)}else s.input.value=s.getValue()
n=y('<option value="'+u(i)+'">'+u(e)+"</option>"),s.options[i].$option=n}n.selected=!0,F(n,{selected:"true"}),s.input.prepend(n)}else s.input.value=s.getValue()
s.isSetup&&(e.silent||s.trigger("change",s.getValue()))}open(){var e=this
e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.isOpen=!0,x(e.control_input,{"aria-expanded":"true"}),e.refreshState(),O(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),O(e.dropdown,{visibility:"visible",display:"block"}),e.focus(),e.trigger("dropdown_open",e.dropdown))}close(){var e=this,t=e.isOpen
"single"===e.settings.mode&&e.items.length&&(e.hideInput(),e.tab_key||e.blur()),e.isOpen=!1,x(e.control_input,{"aria-expanded":"false"}),O(e.dropdown,{display:"none"}),e.clearActiveOption(),e.refreshState(),e.setTextboxValue(),t&&e.trigger("dropdown_close",e.dropdown)}positionDropdown(){if("body"===this.settings.dropdownParent){var e=this.control,t=e.getBoundingClientRect(),i=e.offsetHeight+t.top+window.scrollY,s=t.left+window.scrollX
O(this.dropdown,{width:t.width+"px",top:i+"px",left:s+"px"})}}clear(e){var t=this
e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.isOpen=!0,F(e.control_input,{"aria-expanded":"true"}),e.refreshState(),b(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),b(e.dropdown,{visibility:"visible",display:"block"}),e.focus(),e.trigger("dropdown_open",e.dropdown))}close(e=!0){var t=this,i=t.isOpen
e&&t.setTextboxValue(),"single"===t.settings.mode&&t.items.length&&(t.hideInput(),t.tab_key||t.blur()),t.isOpen=!1,F(t.control_input,{"aria-expanded":"false"}),b(t.dropdown,{display:"none"}),t.clearActiveOption(),t.refreshState(),i&&t.trigger("dropdown_close",t.dropdown)}positionDropdown(){if("body"===this.settings.dropdownParent){var e=this.control,t=e.getBoundingClientRect(),i=e.offsetHeight+t.top+window.scrollY,s=t.left+window.scrollX
b(this.dropdown,{width:t.width+"px",top:i+"px",left:s+"px"})}}clear(e){var t=this
if(t.items.length){var i=t.controlChildren()

@@ -233,33 +243,33 @@ for(const e of i)e.remove()

0===i?s.insertBefore(e,s.firstChild):s.insertBefore(e,s.children[i]),t.setCaret(i+1)}deleteSelection(e){var t,i,s,n,o,r=this
if(t=e&&8===e.keyCode?-1:1,i={start:(o=r.control_input).selectionStart,length:o.selectionEnd-o.selectionStart},s=[],r.activeItems.length){n=S(_(r.activeItems,t)),t>0&&n++
if(t=e&&8===e.keyCode?-1:1,i={start:(o=r.control_input).selectionStart,length:o.selectionEnd-o.selectionStart},s=[],r.activeItems.length){n=x(S(r.activeItems,t)),t>0&&n++
for(const e of r.activeItems)s.push(e.dataset.value)}else(r.isFocused||"single"===r.settings.mode)&&r.items.length&&(t<0&&0===i.start&&0===i.length?s.push(r.items[r.caretPos-1]):t>0&&i.start===r.inputValue().length&&s.push(r.items[r.caretPos]))
if(!s.length||"function"==typeof r.settings.onDelete&&!1===r.settings.onDelete.call(r,s,e))return!1
for(h(e,!0),void 0!==n&&r.setCaret(n);s.length;)r.removeItem(s.pop())
for(g(e,!0),void 0!==n&&r.setCaret(n);s.length;)r.removeItem(s.pop())
return r.showInput(),r.positionDropdown(),r.refreshOptions(!1),!0}advanceSelection(e,t){var i,s,n,o=this
o.rtl&&(e*=-1),o.inputValue().length||(f(l,t)||f("shiftKey",t)?(n=(s=o.getLastActive(e))?s.classList.contains("active")?o.getAdjacent(s,e,"item"):s:e>0?o.control_input.nextElementSibling:o.control_input.previousElementSibling)&&(n.classList.contains("active")&&o.removeActiveItem(s),o.setActiveItemClass(n)):o.isFocused&&!o.activeItems.length?o.setCaret(o.caretPos+e):(s=o.getLastActive(e))&&(i=S(s),o.setCaret(e>0?i+1:i),o.setActiveItem()))}getLastActive(e){let t=this.control.querySelector(".last-active")
o.rtl&&(e*=-1),o.inputValue().length||(v(d,t)||v("shiftKey",t)?(n=(s=o.getLastActive(e))?s.classList.contains("active")?o.getAdjacent(s,e,"item"):s:e>0?o.control_input.nextElementSibling:o.control_input.previousElementSibling)&&(n.classList.contains("active")&&o.removeActiveItem(s),o.setActiveItemClass(n)):o.isFocused&&!o.activeItems.length?o.setCaret(o.caretPos+e):(s=o.getLastActive(e))&&(i=x(s),o.setCaret(e>0?i+1:i),o.setActiveItem()))}getLastActive(e){let t=this.control.querySelector(".last-active")
if(t)return t
var i=this.control.querySelectorAll(".active")
return i?_(i,e):void 0}setCaret(e){var t=this
return i?S(i,e):void 0}setCaret(e){var t=this
"single"===t.settings.mode||t.settings.controlInput?e=t.items.length:(e=Math.max(0,Math.min(t.items.length,e)))==t.caretPos||t.isPending||t.controlChildren().forEach(((i,s)=>{s<e?t.control_input.insertAdjacentElement("beforebegin",i):t.control.appendChild(i)})),t.caretPos=e}controlChildren(){return Array.from(this.control.getElementsByClassName(this.settings.itemClass))}lock(){this.close(),this.isLocked=!0,this.refreshState()}unlock(){this.isLocked=!1,this.refreshState()}disable(){var e=this
e.input.disabled=!0,e.control_input.disabled=!0,e.control_input.tabIndex=-1,e.isDisabled=!0,e.lock()}enable(){var e=this
e.input.disabled=!1,e.control_input.disabled=!1,e.control_input.tabIndex=e.tabIndex,e.isDisabled=!1,e.unlock()}destroy(){var e=this,t=e.revertSettings
e.trigger("destroy"),e.off(),e.wrapper.remove(),e.dropdown.remove(),e.input.innerHTML=t.innerHTML,e.input.tabIndex=t.tabIndex,w(e.input,"tomselected"),e.input.removeAttribute("hidden"),e.input.required=this.isRequired,e._destroy(),delete e.input.tomselect}render(e,t){var i,s,n=this
if(("option"===e||"item"===e)&&(i=p(t[n.settings.valueField]),n.renderCache[e].hasOwnProperty(i)))return n.renderCache[e][i]
e.trigger("destroy"),e.off(),e.wrapper.remove(),e.dropdown.remove(),e.input.innerHTML=t.innerHTML,e.input.tabIndex=t.tabIndex,I(e.input,"tomselected"),e.input.removeAttribute("hidden"),e.input.required=this.isRequired,e._destroy(),delete e.input.tomselect}render(e,t){var i,s,n=this
if(("option"===e||"item"===e)&&(i=c(t[n.settings.valueField]),n.renderCache[e].hasOwnProperty(i)))return n.renderCache[e][i]
var o=n.settings.render[e]
return"function"!=typeof o?null:(s=o.call(this,t,c))?(s=m(s),"option"===e||"option_create"===e?t[n.settings.disabledField]?x(s,{"aria-disabled":"true"}):x(s,{"data-selectable":""}):"optgroup"===e&&(x(s,{"data-group":t.group[n.settings.optgroupValueField]}),t.group[n.settings.disabledField]&&x(s,{"data-disabled":""})),"option"!==e&&"item"!==e||(x(s,{"data-value":i}),"item"===e?b(s,n.settings.itemClass):(b(s,n.settings.optionClass),x(s,{role:"option",id:t.$id})),n.renderCache[e][i]=s),s):s}clearCache(e){void 0===e?this.renderCache={item:{},option:{}}:this.renderCache[e]={}}canCreate(e){return this.settings.create&&e.length&&this.settings.createFilter.call(this,e)}hook(e,t,i){var s=this,n=s[t]
return"function"!=typeof o?null:(s=o.call(this,t,u))?(s=y(s),"option"===e||"option_create"===e?t[n.settings.disabledField]?F(s,{"aria-disabled":"true"}):F(s,{"data-selectable":""}):"optgroup"===e&&(F(s,{"data-group":t.group[n.settings.optgroupValueField]}),t.group[n.settings.disabledField]&&F(s,{"data-disabled":""})),"option"!==e&&"item"!==e||(F(s,{"data-value":i}),"item"===e?w(s,n.settings.itemClass):(w(s,n.settings.optionClass),F(s,{role:"option",id:t.$id})),n.renderCache[e][i]=s),s):s}clearCache(e){void 0===e?this.renderCache={item:{},option:{}}:this.renderCache[e]={}}canCreate(e){return this.settings.create&&e.length&&this.settings.createFilter.call(this,e)}hook(e,t,i){var s=this,n=s[t]
s[t]=function(){var t,o
return"after"===e&&(t=n.apply(s,arguments)),o=i.apply(s,arguments),"instead"===e?o:("before"===e&&(t=n.apply(s,arguments)),t)}}}return k.define("dropdown_input",(function(){var e=this,t=e.settings.controlInput||'<input type="text" autocomplete="off" class="dropdown-input" />'
t=m(t),e.settings.placeholder&&x(t,{placeholder:e.settings.placeholder}),e.settings.controlInput=t,e.settings.shouldOpen=!0,e.hook("after","setup",(()=>{x(e.wrapper,{tabindex:e.input.disabled?"-1":e.tabIndex}),g(e.wrapper,"keypress",(t=>{if(!e.control.contains(t.target)&&!e.dropdown.contains(t.target))switch(t.keyCode){case 13:return void e.onClick(t)}}))
let i=m('<div class="dropdown-input-wrap">')
i.appendChild(t),e.dropdown.insertBefore(i,e.dropdown.firstChild)}))})),k.define("no_backspace_delete",(function(){var e=this,t=e.deleteSelection
this.hook("instead","deleteSelection",(function(){return!!e.activeItems.length&&t.apply(e,arguments)}))})),k.define("remove_button",(function(e){e=Object.assign({label:"&times;",title:"Remove",className:"remove",append:!0},e)
return"after"===e&&(t=n.apply(s,arguments)),o=i.apply(s,arguments),"instead"===e?o:("before"===e&&(t=n.apply(s,arguments)),t)}}}return P.define("dropdown_input",(function(){var e=this,t=e.settings.controlInput||'<input type="text" autocomplete="off" class="dropdown-input" />'
t=y(t),e.settings.placeholder&&F(t,{placeholder:e.settings.placeholder}),e.settings.controlInput=t,e.settings.shouldOpen=!0,e.hook("after","setup",(()=>{F(e.wrapper,{tabindex:e.input.disabled?"-1":e.tabIndex}),f(e.wrapper,"keypress",(t=>{if(!e.control.contains(t.target)&&!e.dropdown.contains(t.target))switch(t.keyCode){case 13:return void e.onClick(t)}}))
let i=y('<div class="dropdown-input-wrap">')
i.appendChild(t),e.dropdown.insertBefore(i,e.dropdown.firstChild)}))})),P.define("no_backspace_delete",(function(){var e=this,t=e.deleteSelection
this.hook("instead","deleteSelection",(function(){return!!e.activeItems.length&&t.apply(e,arguments)}))})),P.define("remove_button",(function(e){e=Object.assign({label:"&times;",title:"Remove",className:"remove",append:!0},e)
var t=this
if(e.append){var i='<a href="javascript:void(0)" class="'+e.className+'" tabindex="-1" title="'+c(e.title)+'">'+e.label+"</a>"
if(e.append){var i='<a href="javascript:void(0)" class="'+e.className+'" tabindex="-1" title="'+u(e.title)+'">'+e.label+"</a>"
t.hook("after","setupTemplates",(()=>{var e=t.settings.render.item
t.settings.render.item=function(){var s=m(e.apply(t,arguments)),n=m(i)
return s.appendChild(n),g(n,"mousedown",(e=>{h(e,!0)})),g(n,"click",(e=>{if(h(e,!0),!t.isLocked){var i=s.dataset.value
t.removeItem(i),t.refreshOptions(!1)}})),s}}))}})),k.define("restore_on_backspace",(function(e){var t=this
t.settings.render.item=function(){var s=y(e.apply(t,arguments)),n=y(i)
return s.appendChild(n),f(n,"mousedown",(e=>{g(e,!0)})),f(n,"click",(e=>{if(g(e,!0),!t.isLocked){var i=s.dataset.value
t.removeItem(i),t.refreshOptions(!1)}})),s}}))}})),P.define("restore_on_backspace",(function(e){var t=this
e.text=e.text||function(e){return e[t.settings.labelField]},t.on("item_remove",(function(i){if(""===t.control_input.value.trim()){var s=t.options[i]
s&&t.setTextboxValue(e.text.call(t,s))}}))})),k}))
s&&t.setTextboxValue(e.text.call(t,s))}}))})),P}))
var tomSelect=function(e,t){return new TomSelect(e,t)}
//# sourceMappingURL=tom-select.popular.min.js.map

@@ -8,3 +8,3 @@ /**

*/
export function highlight(element: any, pattern: any): void;
export function highlight(element: any, regex: any): void;
/**

@@ -11,0 +11,0 @@ * removeHighlight fn copied from highlight v5 and

@@ -56,3 +56,3 @@ /**

*/
tokenize(query: any, respect_word_boundaries: any): any[];
tokenize(query: any, options: any): any[];
/**

@@ -59,0 +59,0 @@ * Iterates over arrays and hashes.

@@ -163,2 +163,7 @@ import Sifter from './contrib/sifter.js';

/**
* Invoked by the user-provided option provider
*
*/
loadCallback(options: TomOption[], optgroups: TomOption[]): void;
/**
* @deprecated 1.1

@@ -439,3 +444,3 @@ *

*/
close(): void;
close(setTextboxValue?: boolean): void;
/**

@@ -442,0 +447,0 @@ * Calculates and applies the appropriate

document.addEventListener('DOMContentLoaded', function() {
// load syntax highlighting css async
// https://stackoverflow.com/questions/32759272/how-to-load-css-asynchronously
document.getElementById('prism-css').media='all';
/**

@@ -94,9 +98,16 @@ * show/hide offcanvas navigation

var demo = $this.closest('.demo')[0];
var codepen, codesandbox;
function getTextContent(tag){
var el = demo.querySelector(tag);
if( el ){
return el.textContent || '';
}
return '';
}
var html = `<div class="p-4">${demo.querySelector('textarea').value || ''}</div>`;
var css = demo.querySelector('style').textContent || '';
var js = demo.querySelector('script').textContent || '';
var css = getTextContent('style');
var js = getTextContent('script');
var theme = localStorage.getItem('theme') || 'bootstrap4';

@@ -103,0 +114,0 @@ var css_urls = [

@@ -17,5 +17,5 @@ {

"types": "dist/types/",
"description": "Tom Select is a versatile and dynamic <select> UI control. Framework agnostic with autocomplete and native-feeling keyboard navigation, it's useful for tagging, contact lists, country selectors, etc.",
"description": "Tom Select is a versatile and dynamic <select> UI control. Forked from Selectize.js to provide a framework agnostic autocomplete widget with native-feeling keyboard navigation, it's useful for tagging, contact lists, country selectors, etc.",
"homepage": "https://tom-select.js.org",
"version": "1.4.3",
"version": "1.5.0",
"author": "Josh Schmidt (https://github.com/oyejorge)",

@@ -33,3 +33,2 @@ "contributors": [

"@11ty/eleventy-plugin-syntaxhighlight": "^3.1.0",
"@atomico/rollup-plugin-sizes": "^1.1.4",
"@babel/core": "^7.13.1",

@@ -41,3 +40,3 @@ "@babel/plugin-proposal-class-properties": "^7.13.0",

"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^17.1.0",
"@rollup/plugin-commonjs": "^18.0.0",
"@rollup/plugin-node-resolve": "^11.2.0",

@@ -52,3 +51,3 @@ "@types/jquery": "^3.5.4",

"chai": "^4.3.0",
"cssnano": "^4.1.10",
"cssnano": "^5.0.1",
"grunt": "^1.3.0",

@@ -63,3 +62,5 @@ "grunt-cli": "^1.3.2",

"grunt-shell": "^3.0.1",
"icon-blender": "^1.0.0-alpha.3",
"jquery": "^3.6.0",
"jsdom": "^16.5.2",
"karma": "^6.1.1",

@@ -85,3 +86,2 @@ "karma-accessibility-checker": "^3.1.5",

"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-visualizer": "^4.2.0",
"syn": "^0.15.0",

@@ -88,0 +88,0 @@ "tslib": "^2.1.0",

@@ -9,6 +9,14 @@ /**

export function highlight(element, pattern) {
if (typeof pattern === 'string' && !pattern.length) return;
var regex = (typeof pattern === 'string') ? new RegExp(pattern, 'i') : pattern;
export function highlight(element, regex) {
if( regex === null ) return;
// convet string to regex
if( typeof regex === 'string' ){
if( !regex.length ) return;
regex = new RegExp(regex, 'i');
}
var highlight = function(node) {

@@ -15,0 +23,0 @@ var skip = 0;

@@ -149,25 +149,42 @@ /**

*/
tokenize(query, respect_word_boundaries) {
tokenize(query, options ) {
query = String(query || '').toLowerCase().trim();
if (!query || !query.length) return [];
var i, n, regex, letter;
var letter;
var tokens = [];
var words = query.split(/ +/);
var words = query.split(/\s+/);
for (i = 0, n = words.length; i < n; i++) {
regex = escape_regex(words[i]);
if (this.settings.diacritics) {
for (letter in DIACRITICS) {
if (DIACRITICS.hasOwnProperty(letter)) {
regex = regex.replace(new RegExp(letter, 'g'), DIACRITICS[letter]);
const field_regex = new RegExp( '^('+options.fields.map(escape_regex).join('|')+')\:(.*)$');
words.forEach((word) => {
let field_match;
let field = null;
let regex = null;
// look for "field:query" tokens
if( options.fields.length > 1 && (field_match = word.match(field_regex)) ){
field = field_match[1];
word = field_match[2];
}
if( word.length > 0 ){
regex = escape_regex(word);
if (this.settings.diacritics) {
for (letter in DIACRITICS) {
if (DIACRITICS.hasOwnProperty(letter)) {
regex = regex.replace(new RegExp(letter, 'g'), DIACRITICS[letter]);
}
}
}
if (options.respect_word_boundaries) regex = "\\b"+regex
regex = new RegExp(regex, 'i');
}
if (respect_word_boundaries) regex = "\\b"+regex
tokens.push({
string : words[i],
regex : new RegExp(regex, 'i')
string : word,
regex : regex,
field : field,
});
}
});

@@ -257,2 +274,3 @@ return tokens;

var field_count = fields.length;
if (!field_count) {

@@ -267,5 +285,21 @@ return function() { return 0; };

return function(token, data) {
for (var i = 0, sum = 0; i < field_count; i++) {
sum += scoreValue(getattr(data, fields[i], nesting), token);
var sum = 0;
// is the token specific to a field?
if( token.field ){
const field = getattr(data, token.field, nesting);
if( !token.regex && field ){
sum += 0.1;
}else{
sum += scoreValue(field, token);
}
}else{
fields.forEach((field) => {
sum += scoreValue(getattr(data, field, nesting), token);
});
}
return sum / field_count;

@@ -420,3 +454,3 @@ };

query : String(query || '').toLowerCase(),
tokens : this.tokenize(query, options.respect_word_boundaries),
tokens : this.tokenize(query, options),
total : 0,

@@ -423,0 +457,0 @@ items : []

@@ -118,7 +118,2 @@

// debounce user defined load() if loadThrottle > 0
if( this.settings.load && this.settings.loadThrottle ){
this.settings.load = loadDebounce(this.settings.load,this.settings.loadThrottle)
}
// search system

@@ -208,3 +203,3 @@ this.sifter = new Sifter(this.options, {diacritics: this.settings.diacritics});

dropdown_content = getDom(`<div style="scroll-behavior: smooth;" role="listbox" id="${listboxId}" tabindex="-1">`);
dropdown_content = getDom(`<div role="listbox" id="${listboxId}" tabindex="-1">`);
addClasses(dropdown_content, settings.dropdownContentClass);

@@ -278,2 +273,7 @@ dropdown.append(dropdown_content);

// debounce user defined load() if loadThrottle > 0
// after initializePlugins() so plugins can create/modify user defined loaders
if( this.settings.load && this.settings.loadThrottle ){
this.settings.load = loadDebounce(this.settings.load,this.settings.loadThrottle)
}

@@ -469,3 +469,3 @@

'dropdown':() => {
return '<div style="display:none"></div>';
return '<div></div>';
}

@@ -666,2 +666,6 @@ };

preventDefault(e);
// if the option_create=null, the dropdown might be closed
}else if (self.settings.create && self.createItem()) {
preventDefault(e);
}

@@ -682,14 +686,16 @@ return;

case constants.KEY_TAB:
if (self.settings.selectOnTab && self.isOpen && self.activeOption) {
self.tab_key = true;
self.onOptionSelect(e,self.activeOption);
if( self.settings.selectOnTab ){
if( self.isOpen && self.activeOption) {
self.tab_key = true;
self.onOptionSelect(e,self.activeOption);
// prevent default [tab] behaviour of jump to the next field
// if select isFull, then the dropdown won't be open and [tab] will work normally
preventDefault(e);
self.tab_key = false;
// prevent default [tab] behaviour of jump to the next field
// if select isFull, then the dropdown won't be open and [tab] will work normally
preventDefault(e);
self.tab_key = false;
}
if (self.settings.create && self.createItem()) {
preventDefault(e);
}
}
if (self.settings.create && self.createItem()) {
preventDefault(e);
}
return;

@@ -873,18 +879,25 @@

const callback = self.loadCallback.bind(self);
fn.call(self, value, callback);
}
fn.call(self, value, function(options:TomOption[], optgroups:TomOption[]){
self.loading = Math.max(self.loading - 1, 0);
self.lastQuery = null;
/**
* Invoked by the user-provided option provider
*
*/
loadCallback(options:TomOption[], optgroups:TomOption[]){
const self = this;
self.loading = Math.max(self.loading - 1, 0);
self.lastQuery = null;
self.clearActiveOption(); // when new results load, focus should be on first option
self.setupOptions(options,optgroups);
self.clearActiveOption(); // when new results load, focus should be on first option
self.setupOptions(options,optgroups);
self.refreshOptions(self.isFocused && !self.isInputHidden);
self.refreshOptions(self.isFocused && !self.isInputHidden);
if (!self.loading) {
removeClasses(self.wrapper,self.settings.loadingClass);
}
if (!self.loading) {
removeClasses(self.wrapper,self.settings.loadingClass);
}
self.trigger('load', options, optgroups);
});
self.trigger('load', options, optgroups);
}

@@ -1342,11 +1355,11 @@

let group_options = document.createDocumentFragment();
group_options.appendChild(self.render('optgroup_header', self.optgroups[optgroup]));
group_options.appendChild(groups[optgroup]);
group_options.append(self.render('optgroup_header', self.optgroups[optgroup]));
group_options.append(groups[optgroup]);
let group_html = self.render('optgroup', {group:self.optgroups[optgroup],options:group_options} );
html.appendChild(group_html);
html.append(group_html);
} else {
html.appendChild(groups[optgroup]);
html.append(groups[optgroup]);
}

@@ -1356,3 +1369,3 @@ }

self.dropdown_content.innerHTML = '';
self.dropdown_content.appendChild(html);
self.dropdown_content.append(html);

@@ -1428,3 +1441,5 @@ // highlight matching terms inline

self.clearActiveOption();
if( triggerDropdown && self.isOpen ){ self.close(); }
if( triggerDropdown && self.isOpen ){
self.close(false); // if create_option=null, we wan't the dropdown to close but not reset the textbox value
}
}

@@ -2014,2 +2029,3 @@ }

if( self.items.indexOf(option.value) == -1 ){
option.selected = false;
option.removeAttribute('selected');

@@ -2030,2 +2046,3 @@ }

option.selected = true;
setAttr(option,{selected:'true'});

@@ -2067,6 +2084,9 @@ self.input.prepend(option);

*/
close() {
close(setTextboxValue=true) {
var self = this;
var trigger = self.isOpen;
// before blur() to prevent form onchange event
if( setTextboxValue ) self.setTextboxValue();
if (self.settings.mode === 'single' && self.items.length) {

@@ -2088,3 +2108,2 @@ self.hideInput();

self.refreshState();
self.setTextboxValue();

@@ -2091,0 +2110,0 @@ if (trigger) self.trigger('dropdown_close', self.dropdown);

@@ -174,3 +174,2 @@

});

@@ -456,2 +455,31 @@

it_n('should search user defined field', function(done) {
var test = setup_test(`<select>
<option value="aa" data-fieldx="a" data-fieldy="a">a</option>
<option value="ab" data-fieldx="a" data-fieldy="b">b</option>
</select>`, {
searchField:['value','fieldx','fieldy'],
});
click(test.instance.control, function() {
syn.type('fieldx:', test.instance.control_input, function() {
assert.equal( test.instance.dropdown_content.querySelectorAll('.option').length, 2 );
test.instance.setTextboxValue();
syn.type('fieldx:a', test.instance.control_input, function() {
assert.equal( test.instance.dropdown_content.querySelectorAll('.option').length, 2 );
test.instance.setTextboxValue();
syn.type('fieldy:a', test.instance.control_input, function() {
assert.equal( test.instance.dropdown_content.querySelectorAll('.option').length, 1 );
done();
});
});
});
});
});
});

@@ -804,11 +832,26 @@

it_n('should remove item when backspace pressed', function(done) {
var test = setup_test('AB_Multi');
var option_before = test.instance.input.querySelector('option[value="b"]');
var select = document.createElement('select');
select.multiple = true;
select.innerHTML = '<option selected value="a">a</option>';
test.instance.addItem('a');
test.instance.addItem('b');
assert.equal( test.instance.items.length, 2 );
var option_b = document.createElement('option');
option_b.value = "b";
option_b.textContent = "b";
option_b.selected = true;
select.append(option_b);
var test = setup_test(select);
//test.instance.addItem('a');
//test.instance.addItem('b');
assert.equal( test.instance.items.length, 2 ,'items.length should = 2' );
assert.equal( Array.from(test.instance.input.options).filter(option => option.getAttribute('selected')).length, 2,'getAttribute(selected).length should = 2' );
assert.equal( Array.from(test.instance.input.options).filter(option => option.selected).length, 2,'option.selected.length should = 2' );
click(test.instance.control, function() {

@@ -820,4 +863,18 @@ syn.type('\b', test.instance.control_input, function() {

assert.equal( test.instance.items[0], 'a' );
assert.equal( option_before, option_after, 'should not remove original <option>' );
done();
assert.equal( option_b, option_after, 'should not remove original <option>' );
assert.equal( Array.from(test.instance.input.options).filter(option => option.getAttribute('selected') ).length, 1, 'getAttribute(selected).length should = 1' );
assert.equal( Array.from(test.instance.input.options).filter(option => option.selected).length, 1, 'option.selected.length should = 1' );
syn.type('\b', test.instance.control_input, function() {
var option_after = test.instance.input.querySelector('option[value="b"]');
assert.equal( test.instance.items.length, 0 );
assert.equal( option_b, option_after, 'should not remove original <option>' );
assert.equal( Array.from(test.instance.input.options).filter(option => option.getAttribute('selected') ).length, 0, 'getAttribute(selected).length should = 0' );
assert.equal( Array.from(test.instance.input.options).filter(option => option.selected).length, 0, 'option.selected.length should = 0' );
done();
});
});

@@ -863,2 +920,40 @@ });

it_n('should create item on [enter] when option_create template is null', function(done) {
var test = setup_test('AB_Multi',{
create:true,
render:{
no_results: null,
option_create: null,
}
});
click(test.instance.control, function() {
syn.type('abcd[enter]',test.instance.control_input,function(){
assert.equal( test.instance.items.length, 1);
assert.equal( test.instance.items[0], 'abcd');
done();
});
});
});
it_n('should not create item on [tab] when option_create template is null', function(done) {
var test = setup_test('AB_Multi',{
create:true,
render:{
no_results: null,
option_create: null,
}
});
click(test.instance.control, function() {
syn.type('abcd[tab]',test.instance.control_input,function(){
assert.equal( test.instance.items.length, 0);
done();
});
});
});
});

@@ -865,0 +960,0 @@

@@ -399,22 +399,25 @@

describe('<select> (custom string render)', function() {
var test;
beforeEach(function() {
test = setup_test('<select>' +
'<option value="">Select an option...</option>' +
'<option value="a">A</option>' +
'</select>', {
it_n('should render the custom option element', function(done) {
const test = setup_test(`<select>
<option value="">Select an option...</option>
<option value="a">A</option>
<optgroup>
<option value="b">B</option>
</optgroup>
</select>`, {
render: {
option: function(item, escape) {
return '<div class="option custom-option">' + escape(item.text) + '</div>'
}
},
optgroup_header: null,
}
});
});
it_n('should render the custom option element', function(done) {
test.instance.focus();
window.setTimeout(function() {
expect($(test.instance.dropdown).find('.custom-option').length).to.be.equal(1);
assert.equal( test.instance.dropdown.querySelectorAll('.custom-option').length, 2);
done();

@@ -421,0 +424,0 @@ }, 5);

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 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 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 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 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc