tom-select-rails 2.2.1 → 2.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tom-select-rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.complete.js +77 -39
  4. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.complete.js.map +1 -1
  5. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.js +77 -39
  6. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.js.map +1 -1
  7. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.popular.js +77 -39
  8. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.popular.js.map +1 -1
  9. data/vendor/assets/javascripts/tom-select-rails/cjs/utils.js +2 -2
  10. data/vendor/assets/javascripts/tom-select-rails/cjs/utils.js.map +1 -1
  11. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/caret_position/plugin.js +57 -8
  12. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/caret_position/plugin.js.map +1 -1
  13. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/change_listener/plugin.js +2 -2
  14. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/change_listener/plugin.js.map +1 -1
  15. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/checkbox_options/plugin.js +57 -8
  16. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/checkbox_options/plugin.js.map +1 -1
  17. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/clear_button/plugin.js +57 -8
  18. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/clear_button/plugin.js.map +1 -1
  19. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/drag_drop/plugin.js +1 -1
  20. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_header/plugin.js +57 -8
  21. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_header/plugin.js.map +1 -1
  22. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_input/plugin.js +58 -9
  23. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_input/plugin.js.map +1 -1
  24. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/input_autogrow/plugin.js +2 -2
  25. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/input_autogrow/plugin.js.map +1 -1
  26. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_active_items/plugin.js +1 -1
  27. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_backspace_delete/plugin.js +1 -1
  28. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/optgroup_columns/plugin.js +57 -8
  29. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/optgroup_columns/plugin.js.map +1 -1
  30. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/remove_button/plugin.js +58 -9
  31. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/remove_button/plugin.js.map +1 -1
  32. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/restore_on_backspace/plugin.js +1 -1
  33. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/virtual_scroll/plugin.js +57 -8
  34. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/virtual_scroll/plugin.js.map +1 -1
  35. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.complete.js +77 -39
  36. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.complete.js.map +1 -1
  37. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.js +77 -39
  38. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.js.map +1 -1
  39. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.popular.js +77 -39
  40. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.popular.js.map +1 -1
  41. data/vendor/assets/javascripts/tom-select-rails/esm/utils.js +2 -2
  42. data/vendor/assets/javascripts/tom-select-rails/esm/utils.js.map +1 -1
  43. data/vendor/assets/javascripts/tom-select-rails/js/plugins/caret_position.js +57 -8
  44. data/vendor/assets/javascripts/tom-select-rails/js/plugins/caret_position.js.map +1 -1
  45. data/vendor/assets/javascripts/tom-select-rails/js/plugins/change_listener.js +2 -2
  46. data/vendor/assets/javascripts/tom-select-rails/js/plugins/change_listener.js.map +1 -1
  47. data/vendor/assets/javascripts/tom-select-rails/js/plugins/checkbox_options.js +57 -8
  48. data/vendor/assets/javascripts/tom-select-rails/js/plugins/checkbox_options.js.map +1 -1
  49. data/vendor/assets/javascripts/tom-select-rails/js/plugins/clear_button.js +57 -8
  50. data/vendor/assets/javascripts/tom-select-rails/js/plugins/clear_button.js.map +1 -1
  51. data/vendor/assets/javascripts/tom-select-rails/js/plugins/drag_drop.js +1 -1
  52. data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_header.js +57 -8
  53. data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_header.js.map +1 -1
  54. data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_input.js +58 -9
  55. data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_input.js.map +1 -1
  56. data/vendor/assets/javascripts/tom-select-rails/js/plugins/input_autogrow.js +2 -2
  57. data/vendor/assets/javascripts/tom-select-rails/js/plugins/input_autogrow.js.map +1 -1
  58. data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_active_items.js +1 -1
  59. data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_backspace_delete.js +1 -1
  60. data/vendor/assets/javascripts/tom-select-rails/js/plugins/optgroup_columns.js +57 -8
  61. data/vendor/assets/javascripts/tom-select-rails/js/plugins/optgroup_columns.js.map +1 -1
  62. data/vendor/assets/javascripts/tom-select-rails/js/plugins/remove_button.js +58 -9
  63. data/vendor/assets/javascripts/tom-select-rails/js/plugins/remove_button.js.map +1 -1
  64. data/vendor/assets/javascripts/tom-select-rails/js/plugins/restore_on_backspace.js +1 -1
  65. data/vendor/assets/javascripts/tom-select-rails/js/plugins/virtual_scroll.js +57 -8
  66. data/vendor/assets/javascripts/tom-select-rails/js/plugins/virtual_scroll.js.map +1 -1
  67. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.js +77 -39
  68. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.js.map +1 -1
  69. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.min.js +132 -133
  70. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.min.js.map +1 -1
  71. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.js +77 -39
  72. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.js.map +1 -1
  73. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.min.js +157 -158
  74. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.min.js.map +1 -1
  75. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.js +77 -39
  76. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.js.map +1 -1
  77. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.min.js +144 -145
  78. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.min.js.map +1 -1
  79. data/vendor/assets/javascripts/tom-select-rails/types/getSettings.d.ts +2 -2
  80. data/vendor/assets/javascripts/tom-select-rails/types/tom-select.d.ts +2 -2
  81. data/vendor/assets/javascripts/tom-select-rails/types/types/core.d.ts +3 -0
  82. data/vendor/assets/javascripts/tom-select-rails/types/utils.d.ts +1 -1
  83. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.css +1 -1
  84. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.css +1 -1
  85. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.css +1 -1
  86. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.css +1 -1
  87. data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.scss +1 -1
  88. metadata +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tom Select v2.2.1
2
+ * Tom Select v2.2.2
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  */
5
5
  !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TomSelect=t()}(this,(function(){"use strict"
@@ -19,38 +19,37 @@ const i=e.substring(1)
19
19
  return d(i).forEach((function(i){let s=i.slice(0)
20
20
  s[0]=e.charAt(0)+s[0],t.push(s),s=i.slice(0),s.unshift(e.charAt(0)),t.push(s)})),t},u=[[0,65535]]
21
21
  let p,h
22
- const g={"æ":"ae","":"a","ø":"o","":"/","":"/"},f=new RegExp(Object.keys(g).join("|")+"|[̀-ͯ·ʾ]","gu"),v=(e,t="NFKD")=>e.normalize(t),m=e=>(e=>e.match(/[\u0f71-\u0f81]/)?c(e).reduce(((e,t)=>e+v(t)),""):v(e))(e).toLowerCase().replace(f,(e=>g[e]||""))
23
- const y=e=>{const t={},i=(e,i)=>{const s=t[e]||new Set,o=new RegExp("^"+n(s)+"$","iu")
22
+ const g={},f={"/":"⁄∕",0:"߀",a:"ⱥɐɑ",aa:"ꜳ",ae:"æǽǣ",ao:"",au:"",av:"ꜹꜻ",ay:"",b:"ƀɓƃ",c:"ꜿƈȼↄ",d:"đɗɖᴅƌꮷԁɦ",e:"ɛǝᴇɇ",f:"ꝼƒ",g:"ǥɠꞡᵹꝿɢ",h:"ħⱨⱶɥ",i:"ɨı",j:"ɉȷ",k:"ƙⱪꝁꝃꝅꞣ",l:"łƚɫⱡꝉꝇꞁɭ",m:"ɱɯϻ",n:"ꞥƞɲꞑᴎлԉ",o:"øǿɔɵꝋꝍᴑ",oe:"œ",oi:"ƣ",oo:"ꝏ",ou:"ȣ",p:"ƥᵽꝑꝓꝕρ",q:"ꝗꝙɋ",r:"ɍɽꝛꞧꞃ",s:"ßȿꞩꞅʂ",t:"ŧƭʈⱦꞇ",th:"þ",tz:"ꜩ",u:"ʉ",v:"ʋꝟʌ",vy:"",w:"ⱳ",y:"ƴɏỿ",z:"ƶȥɀⱬꝣ",hv:"ƕ"}
23
+ for(let e in f){let t=f[e]||""
24
+ for(let i=0;i<t.length;i++){let s=t.substring(i,i+1)
25
+ g[s]=e}}const v=new RegExp(Object.keys(g).join("|")+"|[̀-ͯ·ʾʼ]","gu"),m=(e,t="NFKD")=>e.normalize(t),y=e=>c(e).reduce(((e,t)=>e+b(t)),""),b=e=>(e=m(e).toLowerCase().replace(v,(e=>g[e]||"")),m(e,"NFC"))
26
+ const O=e=>{const t={},i=(e,i)=>{const s=t[e]||new Set,o=new RegExp("^"+n(s)+"$","iu")
24
27
  i.match(o)||(s.add(r(i)),t[e]=s)}
25
- for(let t of function*(e){for(const[t,i]of e)for(let e=t;e<=i;e++){let t=String.fromCharCode(e),i=m(t)
26
- if(i==t.toLowerCase())continue
27
- if(i.length>3)continue
28
- if(0==i.length)continue
29
- let s=v(t)
30
- v(s,"NFC")===t&&i===s||(yield{folded:i,composed:t,code_point:e})}}(e))i(t.folded,t.folded),i(t.folded,t.composed)
31
- return t},b=e=>{const t=y(e),s={}
28
+ for(let t of function*(e){for(const[t,i]of e)for(let e=t;e<=i;e++){let t=String.fromCharCode(e),i=y(t)
29
+ i!=t.toLowerCase()&&(i.length>3||0!=i.length&&(yield{folded:i,composed:t,code_point:e}))}}(e))i(t.folded,t.folded),i(t.folded,t.composed)
30
+ return t},w=e=>{const t=O(e),s={}
32
31
  let o=[]
33
32
  for(let e in t){let i=t[e]
34
33
  i&&(s[e]=n(i)),e.length>1&&o.push(r(e))}o.sort(((e,t)=>t.length-e.length))
35
34
  const l=i(o)
36
- return h=new RegExp("^"+l,"u"),s},O=(e,t=1)=>(t=Math.max(t,e.length-1),i(d(e).map((e=>((e,t=1)=>{let i=0
37
- return e=e.map((e=>(p[e]&&(i+=e.length),p[e]||e))),i>=t?s(e):""})(e,t))))),w=(e,t=!0)=>{let n=e.length>1?1:0
35
+ return h=new RegExp("^"+l,"u"),s},_=(e,t=1)=>(t=Math.max(t,e.length-1),i(d(e).map((e=>((e,t=1)=>{let i=0
36
+ return e=e.map((e=>(p[e]&&(i+=e.length),p[e]||e))),i>=t?s(e):""})(e,t))))),I=(e,t=!0)=>{let n=e.length>1?1:0
38
37
  return i(e.map((e=>{let i=[]
39
38
  const o=t?e.length():e.length()-1
40
- for(let t=0;t<o;t++)i.push(O(e.substrs[t]||"",n))
41
- return s(i)})))},_=(e,t)=>{for(const i of t){if(i.start!=e.start||i.end!=e.end)continue
39
+ for(let t=0;t<o;t++)i.push(_(e.substrs[t]||"",n))
40
+ return s(i)})))},S=(e,t)=>{for(const i of t){if(i.start!=e.start||i.end!=e.end)continue
42
41
  if(i.substrs.join("")!==e.substrs.join(""))continue
43
42
  let t=e.parts
44
43
  const s=e=>{for(const i of t){if(i.start===e.start&&i.substr===e.substr)return!1
45
44
  if(1!=e.length&&1!=i.length){if(e.start<i.start&&e.end>i.start)return!0
46
45
  if(i.start<e.start&&i.end>e.start)return!0}}return!1}
47
46
  if(!(i.parts.filter(s).length>0))return!0}return!1}
48
- class I{constructor(){this.parts=[],this.substrs=[],this.start=0,this.end=0}add(e){e&&(this.parts.push(e),this.substrs.push(e.substr),this.start=Math.min(e.start,this.start),this.end=Math.max(e.end,this.end))}last(){return this.parts[this.parts.length-1]}length(){return this.parts.length}clone(e,t){let i=new I,s=JSON.parse(JSON.stringify(this.parts)),n=s.pop()
47
+ class C{constructor(){this.parts=[],this.substrs=[],this.start=0,this.end=0}add(e){e&&(this.parts.push(e),this.substrs.push(e.substr),this.start=Math.min(e.start,this.start),this.end=Math.max(e.end,this.end))}last(){return this.parts[this.parts.length-1]}length(){return this.parts.length}clone(e,t){let i=new C,s=JSON.parse(JSON.stringify(this.parts)),n=s.pop()
49
48
  for(const e of s)i.add(e)
50
49
  let o=t.substr.substring(0,e-n.start),r=o.length
51
- return i.add({start:n.start,end:n.start+r,length:r,substr:o}),i}}const S=e=>{var t
52
- void 0===p&&(p=b(t||u)),e=m(e)
53
- let i="",s=[new I]
50
+ return i.add({start:n.start,end:n.start+r,length:r,substr:o}),i}}const A=e=>{var t
51
+ void 0===p&&(p=w(t||u)),e=y(e)
52
+ let i="",s=[new C]
54
53
  for(let t=0;t<e.length;t++){let n=e.substring(t).match(h)
55
54
  const o=e.substring(t,t+1),r=n?n[0]:null
56
55
  let l=[],a=new Set
@@ -60,32 +59,32 @@ e.add({start:t,end:t+i,length:i,substr:r}),a.add("1")}else e.add({start:t,end:t+
60
59
  else if(r){let s=e.clone(t,i)
61
60
  const n=r.length
62
61
  s.add({start:t,end:t+n,length:n,substr:r}),l.push(s)}else a.add("3")}if(l.length>0){l=l.sort(((e,t)=>e.length()-t.length()))
63
- for(let e of l)_(e,s)||s.push(e)}else if(t>0&&1==a.size&&!a.has("3")){i+=w(s,!1)
64
- let e=new I
62
+ for(let e of l)S(e,s)||s.push(e)}else if(t>0&&1==a.size&&!a.has("3")){i+=I(s,!1)
63
+ let e=new C
65
64
  const t=s[0]
66
- t&&e.add(t.last()),s=[e]}}return i+=w(s,!0),i},C=(e,t)=>{if(e)return e[t]},A=(e,t)=>{if(e){for(var i,s=t.split(".");(i=s.shift())&&(e=e[i]););return e}},x=(e,t,i)=>{var s,n
67
- return e?(e+="",null==t.regex||-1===(n=e.search(t.regex))?0:(s=t.string.length/e.length,0===n&&(s+=.5),s*i)):0},k=(e,t)=>{var i=e[t]
65
+ t&&e.add(t.last()),s=[e]}}return i+=I(s,!0),i},x=(e,t)=>{if(e)return e[t]},k=(e,t)=>{if(e){for(var i,s=t.split(".");(i=s.shift())&&(e=e[i]););return e}},F=(e,t,i)=>{var s,n
66
+ return e?(e+="",null==t.regex||-1===(n=e.search(t.regex))?0:(s=t.string.length/e.length,0===n&&(s+=.5),s*i)):0},L=(e,t)=>{var i=e[t]
68
67
  if("function"==typeof i)return i
69
- i&&!Array.isArray(i)&&(e[t]=[i])},F=(e,t)=>{if(Array.isArray(e))e.forEach(t)
70
- else for(var i in e)e.hasOwnProperty(i)&&t(e[i],i)},L=(e,t)=>"number"==typeof e&&"number"==typeof t?e>t?1:e<t?-1:0:(e=m(e+"").toLowerCase())>(t=m(t+"").toLowerCase())?1:t>e?-1:0
71
- class E{constructor(e,t){this.items=void 0,this.settings=void 0,this.items=e,this.settings=t||{diacritics:!0}}tokenize(e,t,i){if(!e||!e.length)return[]
68
+ i&&!Array.isArray(i)&&(e[t]=[i])},E=(e,t)=>{if(Array.isArray(e))e.forEach(t)
69
+ else for(var i in e)e.hasOwnProperty(i)&&t(e[i],i)},P=(e,t)=>"number"==typeof e&&"number"==typeof t?e>t?1:e<t?-1:0:(e=y(e+"").toLowerCase())>(t=y(t+"").toLowerCase())?1:t>e?-1:0
70
+ class T{constructor(e,t){this.items=void 0,this.settings=void 0,this.items=e,this.settings=t||{diacritics:!0}}tokenize(e,t,i){if(!e||!e.length)return[]
72
71
  const s=[],n=e.split(/\s+/)
73
72
  var o
74
73
  return i&&(o=new RegExp("^("+Object.keys(i).map(r).join("|")+"):(.*)$")),n.forEach((e=>{let i,n=null,l=null
75
- o&&(i=e.match(o))&&(n=i[1],e=i[2]),e.length>0&&(l=this.settings.diacritics?S(e)||null:r(e),l&&t&&(l="\\b"+l)),s.push({string:e,regex:l?new RegExp(l,"iu"):null,field:n})})),s}getScoreFunction(e,t){var i=this.prepareSearch(e,t)
74
+ o&&(i=e.match(o))&&(n=i[1],e=i[2]),e.length>0&&(l=this.settings.diacritics?A(e)||null:r(e),l&&t&&(l="\\b"+l)),s.push({string:e,regex:l?new RegExp(l,"iu"):null,field:n})})),s}getScoreFunction(e,t){var i=this.prepareSearch(e,t)
76
75
  return this._getScoreFunction(i)}_getScoreFunction(e){const t=e.tokens,i=t.length
77
76
  if(!i)return function(){return 0}
78
77
  const s=e.options.fields,n=e.weights,o=s.length,r=e.getAttrFn
79
78
  if(!o)return function(){return 1}
80
79
  const l=1===o?function(e,t){const i=s[0].field
81
- return x(r(t,i),e,n[i]||1)}:function(e,t){var i=0
80
+ return F(r(t,i),e,n[i]||1)}:function(e,t){var i=0
82
81
  if(e.field){const s=r(t,e.field)
83
- !e.regex&&s?i+=1/o:i+=x(s,e,1)}else F(n,((s,n)=>{i+=x(r(t,n),e,s)}))
82
+ !e.regex&&s?i+=1/o:i+=F(s,e,1)}else E(n,((s,n)=>{i+=F(r(t,n),e,s)}))
84
83
  return i/o}
85
84
  return 1===i?function(e){return l(t[0],e)}:"and"===e.options.conjunction?function(e){var s,n=0
86
85
  for(let i of t){if((s=l(i,e))<=0)return 0
87
86
  n+=s}return n/i}:function(e){var s=0
88
- return F(t,(t=>{s+=l(t,e)})),s/i}}getSortFunction(e,t){var i=this.prepareSearch(e,t)
87
+ return E(t,(t=>{s+=l(t,e)})),s/i}}getSortFunction(e,t){var i=this.prepareSearch(e,t)
89
88
  return this._getSortFunction(i)}_getSortFunction(e){var t,i=[]
90
89
  const s=this,n=e.options,o=!e.query&&n.sort_empty?n.sort_empty:n.sort
91
90
  if("function"==typeof o)return o.bind(this)
@@ -95,26 +94,26 @@ if(e.query){t=!0
95
94
  for(let e of i)if("$score"===e.field){t=!1
96
95
  break}t&&i.unshift({field:"$score",direction:"desc"})}else i=i.filter((e=>"$score"!==e.field))
97
96
  return i.length?function(e,t){var s,n
98
- for(let o of i){if(n=o.field,s=("desc"===o.direction?-1:1)*L(r(n,e),r(n,t)))return s}return 0}:null}prepareSearch(e,t){const i={}
97
+ for(let o of i){if(n=o.field,s=("desc"===o.direction?-1:1)*P(r(n,e),r(n,t)))return s}return 0}:null}prepareSearch(e,t){const i={}
99
98
  var s=Object.assign({},t)
100
- if(k(s,"sort"),k(s,"sort_empty"),s.fields){k(s,"fields")
99
+ if(L(s,"sort"),L(s,"sort_empty"),s.fields){L(s,"fields")
101
100
  const e=[]
102
- s.fields.forEach((t=>{"string"==typeof t&&(t={field:t,weight:1}),e.push(t),i[t.field]="weight"in t?t.weight:1})),s.fields=e}return{options:s,query:e.toLowerCase().trim(),tokens:this.tokenize(e,s.respect_word_boundaries,i),total:0,items:[],weights:i,getAttrFn:s.nesting?A:C}}search(e,t){var i,s,n=this
101
+ s.fields.forEach((t=>{"string"==typeof t&&(t={field:t,weight:1}),e.push(t),i[t.field]="weight"in t?t.weight:1})),s.fields=e}return{options:s,query:e.toLowerCase().trim(),tokens:this.tokenize(e,s.respect_word_boundaries,i),total:0,items:[],weights:i,getAttrFn:s.nesting?k:x}}search(e,t){var i,s,n=this
103
102
  s=this.prepareSearch(e,t),t=s.options,e=s.query
104
103
  const o=t.score||n._getScoreFunction(s)
105
- e.length?F(n.items,((e,n)=>{i=o(e),(!1===t.filter||i>0)&&s.items.push({score:i,id:n})})):F(n.items,((e,t)=>{s.items.push({score:1,id:t})}))
104
+ e.length?E(n.items,((e,n)=>{i=o(e),(!1===t.filter||i>0)&&s.items.push({score:i,id:n})})):E(n.items,((e,t)=>{s.items.push({score:1,id:t})}))
106
105
  const r=n._getSortFunction(s)
107
- return r&&s.items.sort(r),s.total=s.items.length,"number"==typeof t.limit&&(s.items=s.items.slice(0,t.limit)),s}}const P=(e,t)=>{if(Array.isArray(e))e.forEach(t)
108
- else for(var i in e)e.hasOwnProperty(i)&&t(e[i],i)},T=e=>{if(e.jquery)return e[0]
106
+ return r&&s.items.sort(r),s.total=s.items.length,"number"==typeof t.limit&&(s.items=s.items.slice(0,t.limit)),s}}const j=(e,t)=>{if(Array.isArray(e))e.forEach(t)
107
+ else for(var i in e)e.hasOwnProperty(i)&&t(e[i],i)},V=e=>{if(e.jquery)return e[0]
109
108
  if(e instanceof HTMLElement)return e
110
- if(j(e)){var t=document.createElement("template")
111
- return t.innerHTML=e.trim(),t.content.firstChild}return document.querySelector(e)},j=e=>"string"==typeof e&&e.indexOf("<")>-1,V=(e,t)=>{var i=document.createEvent("HTMLEvents")
112
- i.initEvent(t,!0,!1),e.dispatchEvent(i)},q=(e,t)=>{Object.assign(e.style,t)},D=(e,...t)=>{var i=H(t);(e=M(e)).map((e=>{i.map((t=>{e.classList.add(t)}))}))},N=(e,...t)=>{var i=H(t);(e=M(e)).map((e=>{i.map((t=>{e.classList.remove(t)}))}))},H=e=>{var t=[]
113
- return P(e,(e=>{"string"==typeof e&&(e=e.trim().split(/[\11\12\14\15\40]/)),Array.isArray(e)&&(t=t.concat(e))})),t.filter(Boolean)},M=e=>(Array.isArray(e)||(e=[e]),e),z=(e,t,i)=>{if(!i||i.contains(e))for(;e&&e.matches;){if(e.matches(t))return e
114
- e=e.parentNode}},R=(e,t=0)=>t>0?e[e.length-1]:e[0],B=(e,t)=>{if(!e)return-1
109
+ if(q(e)){var t=document.createElement("template")
110
+ return t.innerHTML=e.trim(),t.content.firstChild}return document.querySelector(e)},q=e=>"string"==typeof e&&e.indexOf("<")>-1,D=(e,t)=>{var i=document.createEvent("HTMLEvents")
111
+ i.initEvent(t,!0,!1),e.dispatchEvent(i)},N=(e,t)=>{Object.assign(e.style,t)},H=(e,...t)=>{var i=M(t);(e=R(e)).map((e=>{i.map((t=>{e.classList.add(t)}))}))},z=(e,...t)=>{var i=M(t);(e=R(e)).map((e=>{i.map((t=>{e.classList.remove(t)}))}))},M=e=>{var t=[]
112
+ return j(e,(e=>{"string"==typeof e&&(e=e.trim().split(/[\11\12\14\15\40]/)),Array.isArray(e)&&(t=t.concat(e))})),t.filter(Boolean)},R=e=>(Array.isArray(e)||(e=[e]),e),B=(e,t,i)=>{if(!i||i.contains(e))for(;e&&e.matches;){if(e.matches(t))return e
113
+ e=e.parentNode}},K=(e,t=0)=>t>0?e[e.length-1]:e[0],Q=(e,t)=>{if(!e)return-1
115
114
  t=t||e.nodeName
116
115
  for(var i=0;e=e.previousElementSibling;)e.matches(t)&&i++
117
- return i},K=(e,t)=>{P(t,((t,i)=>{null==t?e.removeAttribute(i):e.setAttribute(i,""+t)}))},Q=(e,t)=>{e.parentNode&&e.parentNode.replaceChild(t,e)},G=(e,t)=>{if(null===t)return
116
+ return i},G=(e,t)=>{j(t,((t,i)=>{null==t?e.removeAttribute(i):e.setAttribute(i,""+t)}))},U=(e,t)=>{e.parentNode&&e.parentNode.replaceChild(t,e)},J=(e,t)=>{if(null===t)return
118
117
  if("string"==typeof t){if(!t.length)return
119
118
  t=new RegExp(t,"i")}const i=e=>3===e.nodeType?(e=>{var i=e.data.match(t)
120
119
  if(i&&e.data.length>0){var s=document.createElement("span")
@@ -122,32 +121,32 @@ s.className="highlight"
122
121
  var n=e.splitText(i.index)
123
122
  n.splitText(i[0].length)
124
123
  var o=n.cloneNode(!0)
125
- return s.appendChild(o),Q(n,s),1}return 0})(e):((e=>{1!==e.nodeType||!e.childNodes||/(script|style)/i.test(e.tagName)||"highlight"===e.className&&"SPAN"===e.tagName||Array.from(e.childNodes).forEach((e=>{i(e)}))})(e),0)
126
- i(e)},U="undefined"!=typeof navigator&&/Mac/.test(navigator.userAgent)?"metaKey":"ctrlKey"
127
- var J={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,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-wrapper",controlClass:"ts-control",dropdownClass:"ts-dropdown",dropdownContentClass:"ts-dropdown-content",itemClass:"item",optionClass:"option",dropdownParent:null,controlInput:'<input type="text" autocomplete="off" size="1" />',copyClassesToDropdown:!1,placeholder:null,hidePlaceholder:null,shouldLoad:function(e){return e.length>0},render:{}}
128
- const W=e=>null==e?null:X(e),X=e=>"boolean"==typeof e?e?"1":"0":e+"",Y=e=>(e+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),Z=(e,t)=>{var i
124
+ return s.appendChild(o),U(n,s),1}return 0})(e):((e=>{1!==e.nodeType||!e.childNodes||/(script|style)/i.test(e.tagName)||"highlight"===e.className&&"SPAN"===e.tagName||Array.from(e.childNodes).forEach((e=>{i(e)}))})(e),0)
125
+ i(e)},W="undefined"!=typeof navigator&&/Mac/.test(navigator.userAgent)?"metaKey":"ctrlKey"
126
+ var X={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,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-wrapper",controlClass:"ts-control",dropdownClass:"ts-dropdown",dropdownContentClass:"ts-dropdown-content",itemClass:"item",optionClass:"option",dropdownParent:null,controlInput:'<input type="text" autocomplete="off" size="1" />',copyClassesToDropdown:!1,placeholder:null,hidePlaceholder:null,shouldLoad:function(e){return e.length>0},render:{}}
127
+ const Y=e=>null==e?null:Z(e),Z=e=>"boolean"==typeof e?e?"1":"0":e+"",ee=e=>(e+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),te=(e,t)=>{var i
129
128
  return function(s,n){var o=this
130
- i&&(o.loading=Math.max(o.loading-1,0),clearTimeout(i)),i=setTimeout((function(){i=null,o.loadedSearches[s]=!0,e.call(o,s,n)}),t)}},ee=(e,t,i)=>{var s,n=e.trigger,o={}
129
+ i&&(o.loading=Math.max(o.loading-1,0),clearTimeout(i)),i=setTimeout((function(){i=null,o.loadedSearches[s]=!0,e.call(o,s,n)}),t)}},ie=(e,t,i)=>{var s,n=e.trigger,o={}
131
130
  for(s of(e.trigger=function(){var i=arguments[0]
132
131
  if(-1===t.indexOf(i))return n.apply(e,arguments)
133
- o[i]=arguments},i.apply(e,[]),e.trigger=n,t))s in o&&n.apply(e,o[s])},te=(e,t=!1)=>{e&&(e.preventDefault(),t&&e.stopPropagation())},ie=(e,t,i,s)=>{e.addEventListener(t,i,s)},se=(e,t)=>!!t&&(!!t[e]&&1===(t.altKey?1:0)+(t.ctrlKey?1:0)+(t.shiftKey?1:0)+(t.metaKey?1:0)),ne=(e,t)=>{const i=e.getAttribute("id")
134
- return i||(e.setAttribute("id",t),t)},oe=e=>e.replace(/[\\"']/g,"\\$&"),re=(e,t)=>{t&&e.append(t)}
135
- function le(e,t){var i=Object.assign({},J,t),s=i.dataAttr,n=i.labelField,o=i.valueField,r=i.disabledField,l=i.optgroupField,a=i.optgroupLabelField,c=i.optgroupValueField,d=e.tagName.toLowerCase(),u=e.getAttribute("placeholder")||e.getAttribute("data-placeholder")
132
+ o[i]=arguments},i.apply(e,[]),e.trigger=n,t))s in o&&n.apply(e,o[s])},se=(e,t=!1)=>{e&&(e.preventDefault(),t&&e.stopPropagation())},ne=(e,t,i,s)=>{e.addEventListener(t,i,s)},oe=(e,t)=>!!t&&(!!t[e]&&1===(t.altKey?1:0)+(t.ctrlKey?1:0)+(t.shiftKey?1:0)+(t.metaKey?1:0)),re=(e,t)=>{const i=e.getAttribute("id")
133
+ return i||(e.setAttribute("id",t),t)},le=e=>e.replace(/[\\"']/g,"\\$&"),ae=(e,t)=>{t&&e.append(t)}
134
+ function ce(e,t){var i=Object.assign({},X,t),s=i.dataAttr,n=i.labelField,o=i.valueField,r=i.disabledField,l=i.optgroupField,a=i.optgroupLabelField,c=i.optgroupValueField,d=e.tagName.toLowerCase(),u=e.getAttribute("placeholder")||e.getAttribute("data-placeholder")
136
135
  if(!u&&!i.allowEmptyOption){let t=e.querySelector('option[value=""]')
137
136
  t&&(u=t.textContent)}var p,h,g,f,v,m,y={placeholder:u,options:[],optgroups:[],items:[],maxItems:null}
138
137
  return"select"===d?(h=y.options,g={},f=1,v=e=>{var t=Object.assign({},e.dataset),i=s&&t[s]
139
- return"string"==typeof i&&i.length&&(t=Object.assign(t,JSON.parse(i))),t},m=(e,t)=>{var s=W(e.value)
138
+ return"string"==typeof i&&i.length&&(t=Object.assign(t,JSON.parse(i))),t},m=(e,t)=>{var s=Y(e.value)
140
139
  if(null!=s&&(s||i.allowEmptyOption)){if(g.hasOwnProperty(s)){if(t){var a=g[s][l]
141
140
  a?Array.isArray(a)?a.push(t):g[s][l]=[a,t]:g[s][l]=t}}else{var c=v(e)
142
- 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,g[s]=c,h.push(c)}e.selected&&y.items.push(s)}},y.maxItems=e.hasAttribute("multiple")?null:1,P(e.children,(e=>{var t,i,s
143
- "optgroup"===(p=e.tagName.toLowerCase())?((s=v(t=e))[a]=s[a]||t.getAttribute("label")||"",s[c]=s[c]||f++,s[r]=s[r]||t.disabled,y.optgroups.push(s),i=s[c],P(t.children,(e=>{m(e,i)}))):"option"===p&&m(e)}))):(()=>{const t=e.getAttribute(s)
144
- if(t)y.options=JSON.parse(t),P(y.options,(e=>{y.items.push(e[o])}))
141
+ 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,g[s]=c,h.push(c)}e.selected&&y.items.push(s)}},y.maxItems=e.hasAttribute("multiple")?null:1,j(e.children,(e=>{var t,i,s
142
+ "optgroup"===(p=e.tagName.toLowerCase())?((s=v(t=e))[a]=s[a]||t.getAttribute("label")||"",s[c]=s[c]||f++,s[r]=s[r]||t.disabled,y.optgroups.push(s),i=s[c],j(t.children,(e=>{m(e,i)}))):"option"===p&&m(e)}))):(()=>{const t=e.getAttribute(s)
143
+ if(t)y.options=JSON.parse(t),j(y.options,(e=>{y.items.push(e[o])}))
145
144
  else{var r=e.value.trim()||""
146
145
  if(!i.allowEmptyOption&&!r.length)return
147
146
  const t=r.split(i.delimiter)
148
- P(t,(e=>{const t={}
149
- t[n]=e,t[o]=e,y.options.push(t)})),y.items=t}})(),Object.assign({},J,y,t)}var ae=0
150
- class ce extends(function(e){return e.plugins={},class extends e{constructor(...e){super(...e),this.plugins={names:[],settings:{},requested:{},loaded:{}}}static define(t,i){e.plugins[t]={name:t,fn:i}}initializePlugins(e){var t,i
147
+ j(t,(e=>{const t={}
148
+ t[n]=e,t[o]=e,y.options.push(t)})),y.items=t}})(),Object.assign({},X,y,t)}var de=0
149
+ class ue extends(function(e){return e.plugins={},class extends e{constructor(...e){super(...e),this.plugins={names:[],settings:{},requested:{},loaded:{}}}static define(t,i){e.plugins[t]={name:t,fn:i}}initializePlugins(e){var t,i
151
150
  const s=this,n=[]
152
151
  if(Array.isArray(e))e.forEach((e=>{"string"==typeof e?n.push(e):(s.plugins.settings[e.name]=e.options,n.push(e.name))}))
153
152
  else if(e)for(t in e)e.hasOwnProperty(t)&&(s.plugins.settings[t]=e[t],n.push(t))
@@ -156,90 +155,90 @@ if(!e.plugins.hasOwnProperty(t))throw new Error('Unable to find "'+t+'" plugin')
156
155
  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
157
156
  if(!t.plugins.loaded.hasOwnProperty(e)){if(i.requested[e])throw new Error('Plugin has circular dependency ("'+e+'")')
158
157
  t.loadPlugin(e)}return i.loaded[e]}}}(t)){constructor(e,t){var i
159
- super(),this.control_input=void 0,this.wrapper=void 0,this.dropdown=void 0,this.control=void 0,this.dropdown_content=void 0,this.focus_node=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.isOpen=!1,this.isDisabled=!1,this.isRequired=void 0,this.isInvalid=!1,this.isValid=!0,this.isLocked=!1,this.isFocused=!1,this.isInputHidden=!1,this.isSetup=!1,this.ignoreFocus=!1,this.ignoreHover=!1,this.hasOptions=!1,this.currentResults=void 0,this.lastValue="",this.caretPos=0,this.loading=0,this.loadedSearches={},this.activeOption=null,this.activeItems=[],this.optgroups={},this.options={},this.userOptions={},this.items=[],ae++
160
- var s=T(e)
158
+ super(),this.control_input=void 0,this.wrapper=void 0,this.dropdown=void 0,this.control=void 0,this.dropdown_content=void 0,this.focus_node=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.isOpen=!1,this.isDisabled=!1,this.isRequired=void 0,this.isInvalid=!1,this.isValid=!0,this.isLocked=!1,this.isFocused=!1,this.isInputHidden=!1,this.isSetup=!1,this.ignoreFocus=!1,this.ignoreHover=!1,this.hasOptions=!1,this.currentResults=void 0,this.lastValue="",this.caretPos=0,this.loading=0,this.loadedSearches={},this.activeOption=null,this.activeItems=[],this.optgroups={},this.options={},this.userOptions={},this.items=[],de++
159
+ var s=V(e)
161
160
  if(s.tomselect)throw new Error("Tom Select already initialized on this element")
162
161
  s.tomselect=this,i=(window.getComputedStyle&&window.getComputedStyle(s,null)).getPropertyValue("direction")
163
- const n=le(s,t)
164
- this.settings=n,this.input=s,this.tabIndex=s.tabIndex||0,this.is_select_tag="select"===s.tagName.toLowerCase(),this.rtl=/rtl/i.test(i),this.inputId=ne(s,"tomselect-"+ae),this.isRequired=s.required,this.sifter=new E(this.options,{diacritics:n.diacritics}),n.mode=n.mode||(1===n.maxItems?"single":"multi"),"boolean"!=typeof n.hideSelected&&(n.hideSelected="multi"===n.mode),"boolean"!=typeof n.hidePlaceholder&&(n.hidePlaceholder="multi"!==n.mode)
162
+ const n=ce(s,t)
163
+ this.settings=n,this.input=s,this.tabIndex=s.tabIndex||0,this.is_select_tag="select"===s.tagName.toLowerCase(),this.rtl=/rtl/i.test(i),this.inputId=re(s,"tomselect-"+de),this.isRequired=s.required,this.sifter=new T(this.options,{diacritics:n.diacritics}),n.mode=n.mode||(1===n.maxItems?"single":"multi"),"boolean"!=typeof n.hideSelected&&(n.hideSelected="multi"===n.mode),"boolean"!=typeof n.hidePlaceholder&&(n.hidePlaceholder="multi"!==n.mode)
165
164
  var o=n.createFilter
166
165
  "function"!=typeof o&&("string"==typeof o&&(o=new RegExp(o)),o instanceof RegExp?n.createFilter=e=>o.test(e):n.createFilter=e=>this.settings.duplicates||!this.options[e]),this.initializePlugins(n.plugins),this.setupCallbacks(),this.setupTemplates()
167
- const r=T("<div>"),l=T("<div>"),a=this._render("dropdown"),c=T('<div role="listbox" tabindex="-1">'),d=this.input.getAttribute("class")||"",u=n.mode
166
+ const r=V("<div>"),l=V("<div>"),a=this._render("dropdown"),c=V('<div role="listbox" tabindex="-1">'),d=this.input.getAttribute("class")||"",u=n.mode
168
167
  var p
169
- if(D(r,n.wrapperClass,d,u),D(l,n.controlClass),re(r,l),D(a,n.dropdownClass,u),n.copyClassesToDropdown&&D(a,d),D(c,n.dropdownContentClass),re(a,c),T(n.dropdownParent||r).appendChild(a),j(n.controlInput)){p=T(n.controlInput)
170
- F(["autocorrect","autocapitalize","autocomplete"],(e=>{s.getAttribute(e)&&K(p,{[e]:s.getAttribute(e)})})),p.tabIndex=-1,l.appendChild(p),this.focus_node=p}else n.controlInput?(p=T(n.controlInput),this.focus_node=p):(p=T("<input/>"),this.focus_node=l)
168
+ if(H(r,n.wrapperClass,d,u),H(l,n.controlClass),ae(r,l),H(a,n.dropdownClass,u),n.copyClassesToDropdown&&H(a,d),H(c,n.dropdownContentClass),ae(a,c),V(n.dropdownParent||r).appendChild(a),q(n.controlInput)){p=V(n.controlInput)
169
+ E(["autocorrect","autocapitalize","autocomplete"],(e=>{s.getAttribute(e)&&G(p,{[e]:s.getAttribute(e)})})),p.tabIndex=-1,l.appendChild(p),this.focus_node=p}else n.controlInput?(p=V(n.controlInput),this.focus_node=p):(p=V("<input/>"),this.focus_node=l)
171
170
  this.wrapper=r,this.dropdown=a,this.dropdown_content=c,this.control=l,this.control_input=p,this.setup()}setup(){const e=this,t=e.settings,i=e.control_input,s=e.dropdown,n=e.dropdown_content,o=e.wrapper,l=e.control,a=e.input,c=e.focus_node,d={passive:!0},u=e.inputId+"-ts-dropdown"
172
- K(n,{id:u}),K(c,{role:"combobox","aria-haspopup":"listbox","aria-expanded":"false","aria-controls":u})
173
- const p=ne(c,e.inputId+"-ts-control"),h="label[for='"+(e=>e.replace(/['"\\]/g,"\\$&"))(e.inputId)+"']",g=document.querySelector(h),f=e.focus.bind(e)
174
- if(g){ie(g,"click",f),K(g,{for:p})
175
- const t=ne(g,e.inputId+"-ts-label")
176
- K(c,{"aria-labelledby":t}),K(n,{"aria-labelledby":t})}if(o.style.width=a.style.width,e.plugins.names.length){const t="plugin-"+e.plugins.names.join(" plugin-")
177
- D([o,s],t)}(null===t.maxItems||t.maxItems>1)&&e.is_select_tag&&K(a,{multiple:"multiple"}),t.placeholder&&K(i,{placeholder:t.placeholder}),!t.splitOn&&t.delimiter&&(t.splitOn=new RegExp("\\s*"+r(t.delimiter)+"+\\s*")),t.load&&t.loadThrottle&&(t.load=Z(t.load,t.loadThrottle)),e.control_input.type=a.type,ie(s,"mousemove",(()=>{e.ignoreHover=!1})),ie(s,"mouseenter",(t=>{var i=z(t.target,"[data-selectable]",s)
178
- i&&e.onOptionHover(t,i)}),{capture:!0}),ie(s,"click",(t=>{const i=z(t.target,"[data-selectable]")
179
- i&&(e.onOptionSelect(t,i),te(t,!0))})),ie(l,"click",(t=>{var s=z(t.target,"[data-ts-item]",l)
180
- s&&e.onItemSelect(t,s)?te(t,!0):""==i.value&&(e.onClick(),te(t,!0))})),ie(c,"keydown",(t=>e.onKeyDown(t))),ie(i,"keypress",(t=>e.onKeyPress(t))),ie(i,"input",(t=>e.onInput(t))),ie(c,"resize",(()=>e.positionDropdown()),d),ie(c,"blur",(t=>e.onBlur(t))),ie(c,"focus",(t=>e.onFocus(t))),ie(i,"paste",(t=>e.onPaste(t)))
171
+ G(n,{id:u}),G(c,{role:"combobox","aria-haspopup":"listbox","aria-expanded":"false","aria-controls":u})
172
+ const p=re(c,e.inputId+"-ts-control"),h="label[for='"+(e=>e.replace(/['"\\]/g,"\\$&"))(e.inputId)+"']",g=document.querySelector(h),f=e.focus.bind(e)
173
+ if(g){ne(g,"click",f),G(g,{for:p})
174
+ const t=re(g,e.inputId+"-ts-label")
175
+ G(c,{"aria-labelledby":t}),G(n,{"aria-labelledby":t})}if(o.style.width=a.style.width,e.plugins.names.length){const t="plugin-"+e.plugins.names.join(" plugin-")
176
+ H([o,s],t)}(null===t.maxItems||t.maxItems>1)&&e.is_select_tag&&G(a,{multiple:"multiple"}),t.placeholder&&G(i,{placeholder:t.placeholder}),!t.splitOn&&t.delimiter&&(t.splitOn=new RegExp("\\s*"+r(t.delimiter)+"+\\s*")),t.load&&t.loadThrottle&&(t.load=te(t.load,t.loadThrottle)),e.control_input.type=a.type,ne(s,"mousemove",(()=>{e.ignoreHover=!1})),ne(s,"mouseenter",(t=>{var i=B(t.target,"[data-selectable]",s)
177
+ i&&e.onOptionHover(t,i)}),{capture:!0}),ne(s,"click",(t=>{const i=B(t.target,"[data-selectable]")
178
+ i&&(e.onOptionSelect(t,i),se(t,!0))})),ne(l,"click",(t=>{var s=B(t.target,"[data-ts-item]",l)
179
+ s&&e.onItemSelect(t,s)?se(t,!0):""==i.value&&(e.onClick(),se(t,!0))})),ne(c,"keydown",(t=>e.onKeyDown(t))),ne(i,"keypress",(t=>e.onKeyPress(t))),ne(i,"input",(t=>e.onInput(t))),ne(c,"blur",(t=>e.onBlur(t))),ne(c,"focus",(t=>e.onFocus(t))),ne(i,"paste",(t=>e.onPaste(t)))
181
180
  const v=t=>{const n=t.composedPath()[0]
182
181
  if(!o.contains(n)&&!s.contains(n))return e.isFocused&&e.blur(),void e.inputState()
183
- n==i&&e.isOpen?t.stopPropagation():te(t,!0)},m=()=>{e.isOpen&&e.positionDropdown()}
184
- ie(document,"mousedown",v),ie(window,"scroll",m,d),ie(window,"resize",m,d),this._destroy=()=>{document.removeEventListener("mousedown",v),window.removeEventListener("scroll",m),window.removeEventListener("resize",m),g&&g.removeEventListener("click",f)},this.revertSettings={innerHTML:a.innerHTML,tabIndex:a.tabIndex},a.tabIndex=-1,a.insertAdjacentElement("afterend",e.wrapper),e.sync(!1),t.items=[],delete t.optgroups,delete t.options,ie(a,"invalid",(()=>{e.isValid&&(e.isValid=!1,e.isInvalid=!0,e.refreshState())})),e.updateOriginalInput(),e.refreshItems(),e.close(!1),e.inputState(),e.isSetup=!0,a.disabled?e.disable():e.enable(),e.on("change",this.onChange),D(a,"tomselected","ts-hidden-accessible"),e.trigger("initialize"),!0===t.preload&&e.preload()}setupOptions(e=[],t=[]){this.addOptions(e),F(t,(e=>{this.registerOptionGroup(e)}))}setupTemplates(){var e=this,t=e.settings.labelField,i=e.settings.optgroupLabelField,s={optgroup:e=>{let t=document.createElement("div")
182
+ n==i&&e.isOpen?t.stopPropagation():se(t,!0)},m=()=>{e.isOpen&&e.positionDropdown()}
183
+ ne(document,"mousedown",v),ne(window,"scroll",m,d),ne(window,"resize",m,d),this._destroy=()=>{document.removeEventListener("mousedown",v),window.removeEventListener("scroll",m),window.removeEventListener("resize",m),g&&g.removeEventListener("click",f)},this.revertSettings={innerHTML:a.innerHTML,tabIndex:a.tabIndex},a.tabIndex=-1,a.insertAdjacentElement("afterend",e.wrapper),e.sync(!1),t.items=[],delete t.optgroups,delete t.options,ne(a,"invalid",(()=>{e.isValid&&(e.isValid=!1,e.isInvalid=!0,e.refreshState())})),e.updateOriginalInput(),e.refreshItems(),e.close(!1),e.inputState(),e.isSetup=!0,a.disabled?e.disable():e.enable(),e.on("change",this.onChange),H(a,"tomselected","ts-hidden-accessible"),e.trigger("initialize"),!0===t.preload&&e.preload()}setupOptions(e=[],t=[]){this.addOptions(e),E(t,(e=>{this.registerOptionGroup(e)}))}setupTemplates(){var e=this,t=e.settings.labelField,i=e.settings.optgroupLabelField,s={optgroup:e=>{let t=document.createElement("div")
185
184
  return t.className="optgroup",t.appendChild(e.options),t},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:()=>'<div class="no-results">No results found</div>',loading:()=>'<div class="spinner"></div>',not_loading:()=>{},dropdown:()=>"<div></div>"}
186
185
  e.settings.render=Object.assign({},s,e.settings.render)}setupCallbacks(){var e,t,i={initialize:"onInitialize",change:"onChange",item_add:"onItemAdd",item_remove:"onItemRemove",item_select:"onItemSelect",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"}
187
- for(e in i)(t=this.settings[i[e]])&&this.on(e,t)}sync(e=!0){const t=this,i=e?le(t.input,{delimiter:t.settings.delimiter}):t.settings
186
+ for(e in i)(t=this.settings[i[e]])&&this.on(e,t)}sync(e=!0){const t=this,i=e?ce(t.input,{delimiter:t.settings.delimiter}):t.settings
188
187
  t.setupOptions(i.options,i.optgroups),t.setValue(i.items||[],!0),t.lastQuery=null}onClick(){var e=this
189
188
  if(e.activeItems.length>0)return e.clearActiveItems(),void e.focus()
190
- e.isFocused&&e.isOpen?e.blur():e.focus()}onMouseDown(){}onChange(){V(this.input,"input"),V(this.input,"change")}onPaste(e){var t=this
191
- t.isInputHidden||t.isLocked?te(e):t.settings.splitOn&&setTimeout((()=>{var e=t.inputValue()
189
+ e.isFocused&&e.isOpen?e.blur():e.focus()}onMouseDown(){}onChange(){D(this.input,"input"),D(this.input,"change")}onPaste(e){var t=this
190
+ t.isInputHidden||t.isLocked?se(e):t.settings.splitOn&&setTimeout((()=>{var e=t.inputValue()
192
191
  if(e.match(t.settings.splitOn)){var i=e.trim().split(t.settings.splitOn)
193
- F(i,(e=>{W(e)&&(this.options[e]?t.addItem(e):t.createItem(e))}))}}),0)}onKeyPress(e){var t=this
192
+ E(i,(e=>{Y(e)&&(this.options[e]?t.addItem(e):t.createItem(e))}))}}),0)}onKeyPress(e){var t=this
194
193
  if(!t.isLocked){var i=String.fromCharCode(e.keyCode||e.which)
195
- return t.settings.create&&"multi"===t.settings.mode&&i===t.settings.delimiter?(t.createItem(),void te(e)):void 0}te(e)}onKeyDown(e){var t=this
196
- if(t.ignoreHover=!0,t.isLocked)9!==e.keyCode&&te(e)
197
- else{switch(e.keyCode){case 65:if(se(U,e)&&""==t.control_input.value)return te(e),void t.selectAll()
194
+ return t.settings.create&&"multi"===t.settings.mode&&i===t.settings.delimiter?(t.createItem(),void se(e)):void 0}se(e)}onKeyDown(e){var t=this
195
+ if(t.ignoreHover=!0,t.isLocked)9!==e.keyCode&&se(e)
196
+ else{switch(e.keyCode){case 65:if(oe(W,e)&&""==t.control_input.value)return se(e),void t.selectAll()
198
197
  break
199
- case 27:return t.isOpen&&(te(e,!0),t.close()),void t.clearActiveItems()
198
+ case 27:return t.isOpen&&(se(e,!0),t.close()),void t.clearActiveItems()
200
199
  case 40:if(!t.isOpen&&t.hasOptions)t.open()
201
200
  else if(t.activeOption){let e=t.getAdjacent(t.activeOption,1)
202
- e&&t.setActiveOption(e)}return void te(e)
201
+ e&&t.setActiveOption(e)}return void se(e)
203
202
  case 38:if(t.activeOption){let e=t.getAdjacent(t.activeOption,-1)
204
- e&&t.setActiveOption(e)}return void te(e)
205
- case 13:return void(t.canSelect(t.activeOption)?(t.onOptionSelect(e,t.activeOption),te(e)):(t.settings.create&&t.createItem()||document.activeElement==t.control_input&&t.isOpen)&&te(e))
203
+ e&&t.setActiveOption(e)}return void se(e)
204
+ case 13:return void(t.canSelect(t.activeOption)?(t.onOptionSelect(e,t.activeOption),se(e)):(t.settings.create&&t.createItem()||document.activeElement==t.control_input&&t.isOpen)&&se(e))
206
205
  case 37:return void t.advanceSelection(-1,e)
207
206
  case 39:return void t.advanceSelection(1,e)
208
- case 9:return void(t.settings.selectOnTab&&(t.canSelect(t.activeOption)&&(t.onOptionSelect(e,t.activeOption),te(e)),t.settings.create&&t.createItem()&&te(e)))
209
- case 8:case 46:return void t.deleteSelection(e)}t.isInputHidden&&!se(U,e)&&te(e)}}onInput(e){var t=this
207
+ case 9:return void(t.settings.selectOnTab&&(t.canSelect(t.activeOption)&&(t.onOptionSelect(e,t.activeOption),se(e)),t.settings.create&&t.createItem()&&se(e)))
208
+ case 8:case 46:return void t.deleteSelection(e)}t.isInputHidden&&!oe(W,e)&&se(e)}}onInput(e){var t=this
210
209
  if(!t.isLocked){var i=t.inputValue()
211
210
  t.lastValue!==i&&(t.lastValue=i,t.settings.shouldLoad.call(t,i)&&t.load(i),t.refreshOptions(),t.trigger("type",i))}}onOptionHover(e,t){this.ignoreHover||this.setActiveOption(t,!1)}onFocus(e){var t=this,i=t.isFocused
212
- if(t.isDisabled)return t.blur(),void te(e)
211
+ if(t.isDisabled)return t.blur(),void se(e)
213
212
  t.ignoreFocus||(t.isFocused=!0,"focus"===t.settings.preload&&t.preload(),i||t.trigger("focus"),t.activeItems.length||(t.showInput(),t.refreshOptions(!!t.settings.openOnFocus)),t.refreshState())}onBlur(e){if(!1!==document.hasFocus()){var t=this
214
213
  if(t.isFocused){t.isFocused=!1,t.ignoreFocus=!1
215
214
  var i=()=>{t.close(),t.setActiveItem(),t.setCaret(t.items.length),t.trigger("blur")}
216
215
  t.settings.create&&t.settings.createOnBlur?t.createItem(null,i):i()}}}onOptionSelect(e,t){var i,s=this
217
216
  t.parentElement&&t.parentElement.matches("[data-disabled]")||(t.classList.contains("create")?s.createItem(null,(()=>{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&&/click/.test(e.type)&&s.setActiveOption(t)))}canSelect(e){return!!(this.isOpen&&e&&this.dropdown_content.contains(e))}onItemSelect(e,t){var i=this
218
- return!i.isLocked&&"multi"===i.settings.mode&&(te(e),i.setActiveItem(t,e),!0)}canLoad(e){return!!this.settings.load&&!this.loadedSearches.hasOwnProperty(e)}load(e){const t=this
217
+ return!i.isLocked&&"multi"===i.settings.mode&&(se(e),i.setActiveItem(t,e),!0)}canLoad(e){return!!this.settings.load&&!this.loadedSearches.hasOwnProperty(e)}load(e){const t=this
219
218
  if(!t.canLoad(e))return
220
- D(t.wrapper,t.settings.loadingClass),t.loading++
219
+ H(t.wrapper,t.settings.loadingClass),t.loading++
221
220
  const i=t.loadCallback.bind(t)
222
221
  t.settings.load.call(t,e,i)}loadCallback(e,t){const i=this
223
- 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||N(i.wrapper,i.settings.loadingClass),i.trigger("load",e,t)}preload(){var e=this.wrapper.classList
222
+ 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||z(i.wrapper,i.settings.loadingClass),i.trigger("load",e,t)}preload(){var e=this.wrapper.classList
224
223
  e.contains("preloaded")||(e.add("preloaded"),this.load(""))}setTextboxValue(e=""){var t=this.control_input
225
- t.value!==e&&(t.value=e,V(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){ee(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,a=this
224
+ t.value!==e&&(t.value=e,D(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){ie(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,a=this
226
225
  if("single"!==a.settings.mode){if(!e)return a.clearActiveItems(),void(a.isFocused&&a.showInput())
227
- if("click"===(i=t&&t.type.toLowerCase())&&se("shiftKey",t)&&a.activeItems.length){for(l=a.getLastActive(),(n=Array.prototype.indexOf.call(a.control.children,l))>(o=Array.prototype.indexOf.call(a.control.children,e))&&(r=n,n=o,o=r),s=n;s<=o;s++)e=a.control.children[s],-1===a.activeItems.indexOf(e)&&a.setActiveItemClass(e)
228
- te(t)}else"click"===i&&se(U,t)||"keydown"===i&&se("shiftKey",t)?e.classList.contains("active")?a.removeActiveItem(e):a.setActiveItemClass(e):(a.clearActiveItems(),a.setActiveItemClass(e))
226
+ if("click"===(i=t&&t.type.toLowerCase())&&oe("shiftKey",t)&&a.activeItems.length){for(l=a.getLastActive(),(n=Array.prototype.indexOf.call(a.control.children,l))>(o=Array.prototype.indexOf.call(a.control.children,e))&&(r=n,n=o,o=r),s=n;s<=o;s++)e=a.control.children[s],-1===a.activeItems.indexOf(e)&&a.setActiveItemClass(e)
227
+ se(t)}else"click"===i&&oe(W,t)||"keydown"===i&&oe("shiftKey",t)?e.classList.contains("active")?a.removeActiveItem(e):a.setActiveItemClass(e):(a.clearActiveItems(),a.setActiveItemClass(e))
229
228
  a.hideInput(),a.isFocused||a.focus()}}setActiveItemClass(e){const t=this,i=t.control.querySelector(".last-active")
230
- i&&N(i,"last-active"),D(e,"active last-active"),t.trigger("item_select",e),-1==t.activeItems.indexOf(e)&&t.activeItems.push(e)}removeActiveItem(e){var t=this.activeItems.indexOf(e)
231
- this.activeItems.splice(t,1),N(e,"active")}clearActiveItems(){N(this.activeItems,"active"),this.activeItems=[]}setActiveOption(e,t=!0){e!==this.activeOption&&(this.clearActiveOption(),e&&(this.activeOption=e,K(this.focus_node,{"aria-activedescendant":e.getAttribute("id")}),K(e,{"aria-selected":"true"}),D(e,"active"),t&&this.scrollToOption(e)))}scrollToOption(e,t){if(!e)return
229
+ i&&z(i,"last-active"),H(e,"active last-active"),t.trigger("item_select",e),-1==t.activeItems.indexOf(e)&&t.activeItems.push(e)}removeActiveItem(e){var t=this.activeItems.indexOf(e)
230
+ this.activeItems.splice(t,1),z(e,"active")}clearActiveItems(){z(this.activeItems,"active"),this.activeItems=[]}setActiveOption(e,t=!0){e!==this.activeOption&&(this.clearActiveOption(),e&&(this.activeOption=e,G(this.focus_node,{"aria-activedescendant":e.getAttribute("id")}),G(e,{"aria-selected":"true"}),H(e,"active"),t&&this.scrollToOption(e)))}scrollToOption(e,t){if(!e)return
232
231
  const i=this.dropdown_content,s=i.clientHeight,n=i.scrollTop||0,o=e.offsetHeight,r=e.getBoundingClientRect().top-i.getBoundingClientRect().top+n
233
232
  r+o>s+n?this.scroll(r-s+o,t):r<n&&this.scroll(r,t)}scroll(e,t){const i=this.dropdown_content
234
- t&&(i.style.scrollBehavior=t),i.scrollTop=e,i.style.scrollBehavior=""}clearActiveOption(){this.activeOption&&(N(this.activeOption,"active"),K(this.activeOption,{"aria-selected":null})),this.activeOption=null,K(this.focus_node,{"aria-activedescendant":null})}selectAll(){const e=this
233
+ t&&(i.style.scrollBehavior=t),i.scrollTop=e,i.style.scrollBehavior=""}clearActiveOption(){this.activeOption&&(z(this.activeOption,"active"),G(this.activeOption,{"aria-selected":null})),this.activeOption=null,G(this.focus_node,{"aria-activedescendant":null})}selectAll(){const e=this
235
234
  if("single"===e.settings.mode)return
236
235
  const t=e.controlChildren()
237
- t.length&&(e.hideInput(),e.close(),e.activeItems=t,F(t,(t=>{e.setActiveItemClass(t)})))}inputState(){var e=this
238
- e.control.contains(e.control_input)&&(K(e.control_input,{placeholder:e.settings.placeholder}),e.activeItems.length>0||!e.isFocused&&e.settings.hidePlaceholder&&e.items.length>0?(e.setTextboxValue(),e.isInputHidden=!0):(e.settings.hidePlaceholder&&e.items.length>0&&K(e.control_input,{placeholder:""}),e.isInputHidden=!1),e.wrapper.classList.toggle("input-hidden",e.isInputHidden))}hideInput(){this.inputState()}showInput(){this.inputState()}inputValue(){return this.control_input.value.trim()}focus(){var e=this
236
+ t.length&&(e.hideInput(),e.close(),e.activeItems=t,E(t,(t=>{e.setActiveItemClass(t)})))}inputState(){var e=this
237
+ e.control.contains(e.control_input)&&(G(e.control_input,{placeholder:e.settings.placeholder}),e.activeItems.length>0||!e.isFocused&&e.settings.hidePlaceholder&&e.items.length>0?(e.setTextboxValue(),e.isInputHidden=!0):(e.settings.hidePlaceholder&&e.items.length>0&&G(e.control_input,{placeholder:""}),e.isInputHidden=!1),e.wrapper.classList.toggle("input-hidden",e.isInputHidden))}hideInput(){this.inputState()}showInput(){this.inputState()}inputValue(){return this.control_input.value.trim()}focus(){var e=this
239
238
  e.isDisabled||(e.ignoreFocus=!0,e.control_input.offsetWidth?e.control_input.focus():e.focus_node.focus(),setTimeout((()=>{e.ignoreFocus=!1,e.onFocus()}),0))}blur(){this.focus_node.blur(),this.onBlur()}getScoreFunction(e){return this.sifter.getScoreFunction(e,this.getSearchOptions())}getSearchOptions(){var e=this.settings,t=e.sortField
240
239
  return"string"==typeof e.sortField&&(t=[{field:e.sortField}]),{fields:e.searchField,conjunction:e.searchConjunction,sort:t,nesting:e.nesting}}search(e){var t,i,s=this,n=this.getSearchOptions()
241
240
  if(s.settings.score&&"function"!=typeof(i=s.settings.score.call(s,e)))throw new Error('Tom Select "score" setting must be a function that returns a function')
242
- return e!==s.lastQuery?(s.lastQuery=e,t=s.sifter.search(e,Object.assign(n,{score:i})),s.currentResults=t):t=Object.assign({},s.currentResults),s.settings.hideSelected&&(t.items=t.items.filter((e=>{let t=W(e.id)
241
+ return e!==s.lastQuery?(s.lastQuery=e,t=s.sifter.search(e,Object.assign(n,{score:i})),s.currentResults=t):t=Object.assign({},s.currentResults),s.settings.hideSelected&&(t.items=t.items.filter((e=>{let t=Y(e.id)
243
242
  return!(t&&-1!==s.items.indexOf(t))}))),t}refreshOptions(e=!0){var t,i,s,n,o,r,l,a,c,d
244
243
  const u={},p=[]
245
244
  var h=this,g=h.inputValue()
@@ -249,41 +248,41 @@ for(f&&(y=h.activeOption)&&(c=y.closest("[data-group]")),n=m.items.length,"numbe
249
248
  if(!e)continue
250
249
  let n=e.id,l=h.options[n]
251
250
  if(void 0===l)continue
252
- let a=X(n),d=h.getOption(a,!0)
251
+ let a=Z(n),d=h.getOption(a,!0)
253
252
  for(h.settings.hideSelected||d.classList.toggle("selected",h.items.includes(a)),o=l[h.settings.optgroupField]||"",i=0,s=(r=Array.isArray(o)?o:[o])&&r.length;i<s;i++){o=r[i],h.optgroups.hasOwnProperty(o)||(o="")
254
253
  let e=u[o]
255
- void 0===e&&(e=document.createDocumentFragment(),p.push(o)),i>0&&(d=d.cloneNode(!0),K(d,{id:l.$id+"-clone-"+i,"aria-selected":null}),d.classList.add("ts-cloned"),N(d,"active"),h.activeOption&&h.activeOption.dataset.value==n&&c&&c.dataset.group===o.toString()&&(y=d)),e.appendChild(d),u[o]=e}}h.settings.lockOptgroupOrder&&p.sort(((e,t)=>{const i=h.optgroups[e],s=h.optgroups[t]
256
- return(i&&i.$order||0)-(s&&s.$order||0)})),l=document.createDocumentFragment(),F(p,(e=>{let t=u[e]
254
+ void 0===e&&(e=document.createDocumentFragment(),p.push(o)),i>0&&(d=d.cloneNode(!0),G(d,{id:l.$id+"-clone-"+i,"aria-selected":null}),d.classList.add("ts-cloned"),z(d,"active"),h.activeOption&&h.activeOption.dataset.value==n&&c&&c.dataset.group===o.toString()&&(y=d)),e.appendChild(d),u[o]=e}}h.settings.lockOptgroupOrder&&p.sort(((e,t)=>{const i=h.optgroups[e],s=h.optgroups[t]
255
+ return(i&&i.$order||0)-(s&&s.$order||0)})),l=document.createDocumentFragment(),E(p,(e=>{let t=u[e]
257
256
  if(!t||!t.children.length)return
258
257
  let i=h.optgroups[e]
259
258
  if(void 0!==i){let e=document.createDocumentFragment(),s=h.render("optgroup_header",i)
260
- re(e,s),re(e,t)
259
+ ae(e,s),ae(e,t)
261
260
  let n=h.render("optgroup",{group:i,options:e})
262
- re(l,n)}else re(l,t)})),O.innerHTML="",re(O,l),h.settings.highlight&&(v=O.querySelectorAll("span.highlight"),Array.prototype.forEach.call(v,(function(e){var t=e.parentNode
263
- t.replaceChild(e.firstChild,e),t.normalize()})),m.query.length&&m.tokens.length&&F(m.tokens,(e=>{G(O,e.regex)})))
261
+ ae(l,n)}else ae(l,t)})),O.innerHTML="",ae(O,l),h.settings.highlight&&(v=O.querySelectorAll("span.highlight"),Array.prototype.forEach.call(v,(function(e){var t=e.parentNode
262
+ t.replaceChild(e.firstChild,e),t.normalize()})),m.query.length&&m.tokens.length&&E(m.tokens,(e=>{J(O,e.regex)})))
264
263
  var w=e=>{let t=h.render(e,{input:g})
265
264
  return t&&(b=!0,O.insertBefore(t,O.firstChild)),t}
266
265
  if(h.loading?w("loading"):h.settings.shouldLoad.call(h,g)?0===m.items.length&&w("no_results"):w("not_loading"),(a=h.canCreate(g))&&(d=w("option_create")),h.hasOptions=m.items.length>0||a,b){if(m.items.length>0){if(y||"single"!==h.settings.mode||null==h.items[0]||(y=h.getOption(h.items[0])),!O.contains(y)){let e=0
267
266
  d&&!h.settings.addPrecedence&&(e=1),y=h.selectable()[e]}}else d&&(y=d)
268
267
  e&&!h.isOpen&&(h.open(),h.scrollToOption(y,"auto")),h.setActiveOption(y)}else h.clearActiveOption(),e&&h.isOpen&&h.close(!1)}selectable(){return this.dropdown_content.querySelectorAll("[data-selectable]")}addOption(e,t=!1){const i=this
269
268
  if(Array.isArray(e))return i.addOptions(e,t),!1
270
- const s=W(e[i.settings.valueField])
271
- return null!==s&&!i.options.hasOwnProperty(s)&&(e.$order=e.$order||++i.order,e.$id=i.inputId+"-opt-"+e.$order,i.options[s]=e,i.lastQuery=null,t&&(i.userOptions[s]=t,i.trigger("option_add",s,e)),s)}addOptions(e,t=!1){F(e,(e=>{this.addOption(e,t)}))}registerOption(e){return this.addOption(e)}registerOptionGroup(e){var t=W(e[this.settings.optgroupValueField])
269
+ const s=Y(e[i.settings.valueField])
270
+ return null!==s&&!i.options.hasOwnProperty(s)&&(e.$order=e.$order||++i.order,e.$id=i.inputId+"-opt-"+e.$order,i.options[s]=e,i.lastQuery=null,t&&(i.userOptions[s]=t,i.trigger("option_add",s,e)),s)}addOptions(e,t=!1){E(e,(e=>{this.addOption(e,t)}))}registerOption(e){return this.addOption(e)}registerOptionGroup(e){var t=Y(e[this.settings.optgroupValueField])
272
271
  return null!==t&&(e.$order=e.$order||++this.order,this.optgroups[t]=e,t)}addOptionGroup(e,t){var i
273
272
  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){const i=this
274
273
  var s,n
275
- const o=W(e),r=W(t[i.settings.valueField])
274
+ const o=Y(e),r=Y(t[i.settings.valueField])
276
275
  if(null===o)return
277
276
  const l=i.options[o]
278
277
  if(null==l)return
279
278
  if("string"!=typeof r)throw new Error("Value must be set in option data")
280
279
  const a=i.getOption(o),c=i.getItem(o)
281
280
  if(t.$order=t.$order||l.$order,delete i.options[o],i.uncacheValue(r),i.options[r]=t,a){if(i.dropdown_content.contains(a)){const e=i._render("option",t)
282
- Q(a,e),i.activeOption===a&&i.setActiveOption(e)}a.remove()}c&&(-1!==(n=i.items.indexOf(o))&&i.items.splice(n,1,r),s=i._render("item",t),c.classList.contains("active")&&D(s,"active"),Q(c,s)),i.lastQuery=null}removeOption(e,t){const i=this
283
- e=X(e),i.uncacheValue(e),delete i.userOptions[e],delete i.options[e],i.lastQuery=null,i.trigger("option_remove",e),i.removeItem(e,t)}clearOptions(e){const t=(e||this.clearFilter).bind(this)
281
+ U(a,e),i.activeOption===a&&i.setActiveOption(e)}a.remove()}c&&(-1!==(n=i.items.indexOf(o))&&i.items.splice(n,1,r),s=i._render("item",t),c.classList.contains("active")&&H(s,"active"),U(c,s)),i.lastQuery=null}removeOption(e,t){const i=this
282
+ e=Z(e),i.uncacheValue(e),delete i.userOptions[e],delete i.options[e],i.lastQuery=null,i.trigger("option_remove",e),i.removeItem(e,t)}clearOptions(e){const t=(e||this.clearFilter).bind(this)
284
283
  this.loadedSearches={},this.userOptions={},this.clearCache()
285
284
  const i={}
286
- F(this.options,((e,s)=>{t(e,s)&&(i[s]=e)})),this.options=this.sifter.items=i,this.lastQuery=null,this.trigger("option_clear")}clearFilter(e,t){return this.items.indexOf(t)>=0}getOption(e,t=!1){const i=W(e)
285
+ E(this.options,((e,s)=>{t(e,s)&&(i[s]=e)})),this.options=this.sifter.items=i,this.lastQuery=null,this.trigger("option_clear")}clearFilter(e,t){return this.items.indexOf(t)>=0}getOption(e,t=!1){const i=Y(e)
287
286
  if(null===i)return null
288
287
  const s=this.options[i]
289
288
  if(null!=s){if(s.$div)return s.$div
@@ -292,22 +291,22 @@ if(!e)return null
292
291
  s="item"==i?this.controlChildren():this.dropdown_content.querySelectorAll("[data-selectable]")
293
292
  for(let i=0;i<s.length;i++)if(s[i]==e)return t>0?s[i+1]:s[i-1]
294
293
  return null}getItem(e){if("object"==typeof e)return e
295
- var t=W(e)
296
- return null!==t?this.control.querySelector(`[data-value="${oe(t)}"]`):null}addItems(e,t){var i=this,s=Array.isArray(e)?e:[e]
294
+ var t=Y(e)
295
+ return null!==t?this.control.querySelector(`[data-value="${le(t)}"]`):null}addItems(e,t){var i=this,s=Array.isArray(e)?e:[e]
297
296
  const n=(s=s.filter((e=>-1===i.items.indexOf(e))))[s.length-1]
298
- s.forEach((e=>{i.isPending=e!==n,i.addItem(e,t)}))}addItem(e,t){ee(this,t?[]:["change","dropdown_close"],(()=>{var i,s
299
- const n=this,o=n.settings.mode,r=W(e)
297
+ s.forEach((e=>{i.isPending=e!==n,i.addItem(e,t)}))}addItem(e,t){ie(this,t?[]:["change","dropdown_close"],(()=>{var i,s
298
+ const n=this,o=n.settings.mode,r=Y(e)
300
299
  if((!r||-1===n.items.indexOf(r)||("single"===o&&n.close(),"single"!==o&&n.settings.duplicates))&&null!==r&&n.options.hasOwnProperty(r)&&("single"===o&&n.clear(t),"multi"!==o||!n.isFull())){if(i=n._render("item",n.options[r]),n.control.contains(i)&&(i=i.cloneNode(!0)),s=n.isFull(),n.items.splice(n.caretPos,0,r),n.insertAtCaret(i),n.isSetup){if(!n.isPending&&n.settings.hideSelected){let e=n.getOption(r),t=n.getAdjacent(e,1)
301
300
  t&&n.setActiveOption(t)}n.isPending||n.settings.closeAfterSelect||n.refreshOptions(n.isFocused&&"single"!==o),0!=n.settings.closeAfterSelect&&n.isFull()?n.close():n.isPending||n.positionDropdown(),n.trigger("item_add",r,i),n.isPending||n.updateOriginalInput({silent:t})}(!n.isPending||!s&&n.isFull())&&(n.inputState(),n.refreshState())}}))}removeItem(e=null,t){const i=this
302
301
  if(!(e=i.getItem(e)))return
303
302
  var s,n
304
303
  const o=e.dataset.value
305
- s=B(e),e.remove(),e.classList.contains("active")&&(n=i.activeItems.indexOf(e),i.activeItems.splice(n,1),N(e,"active")),i.items.splice(s,1),i.lastQuery=null,!i.settings.persist&&i.userOptions.hasOwnProperty(o)&&i.removeOption(o,t),s<i.caretPos&&i.setCaret(i.caretPos-1),i.updateOriginalInput({silent:t}),i.refreshState(),i.positionDropdown(),i.trigger("item_remove",o,e)}createItem(e=null,t=(()=>{})){3===arguments.length&&(t=arguments[2]),"function"!=typeof t&&(t=()=>{})
304
+ s=Q(e),e.remove(),e.classList.contains("active")&&(n=i.activeItems.indexOf(e),i.activeItems.splice(n,1),z(e,"active")),i.items.splice(s,1),i.lastQuery=null,!i.settings.persist&&i.userOptions.hasOwnProperty(o)&&i.removeOption(o,t),s<i.caretPos&&i.setCaret(i.caretPos-1),i.updateOriginalInput({silent:t}),i.refreshState(),i.positionDropdown(),i.trigger("item_remove",o,e)}createItem(e=null,t=(()=>{})){3===arguments.length&&(t=arguments[2]),"function"!=typeof t&&(t=()=>{})
306
305
  var i,s=this,n=s.caretPos
307
306
  if(e=e||s.inputValue(),!s.canCreate(e))return t(),!1
308
307
  s.lock()
309
308
  var o=!1,r=e=>{if(s.unlock(),!e||"object"!=typeof e)return t()
310
- var i=W(e[s.settings.valueField])
309
+ var i=Y(e[s.settings.valueField])
311
310
  if("string"!=typeof i)return t()
312
311
  s.setTextboxValue(),s.addOption(e,!0),s.setCaret(n),s.addItem(i),t(e),o=!0}
313
312
  return i="function"==typeof s.settings.create?s.settings.create.call(this,e,r):{[s.settings.labelField]:e,[s.settings.valueField]:e},o||r(i),!0}refreshItems(){var e=this
@@ -322,90 +321,90 @@ e.input.validity&&(e.isValid=e.input.validity.valid,e.isInvalid=!e.isValid)}isFu
322
321
  var i,s
323
322
  const n=t.input.querySelector('option[value=""]')
324
323
  if(t.is_select_tag){const e=[],r=t.input.querySelectorAll("option:checked").length
325
- function o(i,s,o){return i||(i=T('<option value="'+Y(s)+'">'+Y(o)+"</option>")),i!=n&&t.input.append(i),e.push(i),(i!=n||r>0)&&(i.selected=!0),i}t.input.querySelectorAll("option:checked").forEach((e=>{e.selected=!1})),0==t.items.length&&"single"==t.settings.mode?o(n,"",""):t.items.forEach((n=>{if(i=t.options[n],s=i[t.settings.labelField]||"",e.includes(i.$option)){o(t.input.querySelector(`option[value="${oe(n)}"]:not(:checked)`),n,s)}else i.$option=o(i.$option,n,s)}))}else t.input.value=t.getValue()
324
+ function o(i,s,o){return i||(i=V('<option value="'+ee(s)+'">'+ee(o)+"</option>")),i!=n&&t.input.append(i),e.push(i),(i!=n||r>0)&&(i.selected=!0),i}t.input.querySelectorAll("option:checked").forEach((e=>{e.selected=!1})),0==t.items.length&&"single"==t.settings.mode?o(n,"",""):t.items.forEach((n=>{if(i=t.options[n],s=i[t.settings.labelField]||"",e.includes(i.$option)){o(t.input.querySelector(`option[value="${le(n)}"]:not(:checked)`),n,s)}else i.$option=o(i.$option,n,s)}))}else t.input.value=t.getValue()
326
325
  t.isSetup&&(e.silent||t.trigger("change",t.getValue()))}open(){var e=this
327
- e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.isOpen=!0,K(e.focus_node,{"aria-expanded":"true"}),e.refreshState(),q(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),q(e.dropdown,{visibility:"visible",display:"block"}),e.focus(),e.trigger("dropdown_open",e.dropdown))}close(e=!0){var t=this,i=t.isOpen
328
- e&&(t.setTextboxValue(),"single"===t.settings.mode&&t.items.length&&t.hideInput()),t.isOpen=!1,K(t.focus_node,{"aria-expanded":"false"}),q(t.dropdown,{display:"none"}),t.settings.hideSelected&&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
329
- q(this.dropdown,{width:t.width+"px",top:i+"px",left:s+"px"})}}clear(e){var t=this
326
+ e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.isOpen=!0,G(e.focus_node,{"aria-expanded":"true"}),e.refreshState(),N(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),N(e.dropdown,{visibility:"visible",display:"block"}),e.focus(),e.trigger("dropdown_open",e.dropdown))}close(e=!0){var t=this,i=t.isOpen
327
+ e&&(t.setTextboxValue(),"single"===t.settings.mode&&t.items.length&&t.hideInput()),t.isOpen=!1,G(t.focus_node,{"aria-expanded":"false"}),N(t.dropdown,{display:"none"}),t.settings.hideSelected&&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
328
+ N(this.dropdown,{width:t.width+"px",top:i+"px",left:s+"px"})}}clear(e){var t=this
330
329
  if(t.items.length){var i=t.controlChildren()
331
- F(i,(e=>{t.removeItem(e,!0)})),t.showInput(),e||t.updateOriginalInput(),t.trigger("clear")}}insertAtCaret(e){const t=this,i=t.caretPos,s=t.control
330
+ E(i,(e=>{t.removeItem(e,!0)})),t.showInput(),e||t.updateOriginalInput(),t.trigger("clear")}}insertAtCaret(e){const t=this,i=t.caretPos,s=t.control
332
331
  s.insertBefore(e,s.children[i]||null),t.setCaret(i+1)}deleteSelection(e){var t,i,s,n,o,r=this
333
332
  t=e&&8===e.keyCode?-1:1,i={start:(o=r.control_input).selectionStart||0,length:(o.selectionEnd||0)-(o.selectionStart||0)}
334
333
  const l=[]
335
- if(r.activeItems.length)n=R(r.activeItems,t),s=B(n),t>0&&s++,F(r.activeItems,(e=>l.push(e)))
334
+ if(r.activeItems.length)n=K(r.activeItems,t),s=Q(n),t>0&&s++,E(r.activeItems,(e=>l.push(e)))
336
335
  else if((r.isFocused||"single"===r.settings.mode)&&r.items.length){const e=r.controlChildren()
337
336
  let s
338
337
  t<0&&0===i.start&&0===i.length?s=e[r.caretPos-1]:t>0&&i.start===r.inputValue().length&&(s=e[r.caretPos]),void 0!==s&&l.push(s)}if(!r.shouldDelete(l,e))return!1
339
- for(te(e,!0),void 0!==s&&r.setCaret(s);l.length;)r.removeItem(l.pop())
338
+ for(se(e,!0),void 0!==s&&r.setCaret(s);l.length;)r.removeItem(l.pop())
340
339
  return r.showInput(),r.positionDropdown(),r.refreshOptions(!1),!0}shouldDelete(e,t){const i=e.map((e=>e.dataset.value))
341
340
  return!(!i.length||"function"==typeof this.settings.onDelete&&!1===this.settings.onDelete(i,t))}advanceSelection(e,t){var i,s,n=this
342
- n.rtl&&(e*=-1),n.inputValue().length||(se(U,t)||se("shiftKey",t)?(s=(i=n.getLastActive(e))?i.classList.contains("active")?n.getAdjacent(i,e,"item"):i:e>0?n.control_input.nextElementSibling:n.control_input.previousElementSibling)&&(s.classList.contains("active")&&n.removeActiveItem(i),n.setActiveItemClass(s)):n.moveCaret(e))}moveCaret(e){}getLastActive(e){let t=this.control.querySelector(".last-active")
341
+ n.rtl&&(e*=-1),n.inputValue().length||(oe(W,t)||oe("shiftKey",t)?(s=(i=n.getLastActive(e))?i.classList.contains("active")?n.getAdjacent(i,e,"item"):i:e>0?n.control_input.nextElementSibling:n.control_input.previousElementSibling)&&(s.classList.contains("active")&&n.removeActiveItem(i),n.setActiveItemClass(s)):n.moveCaret(e))}moveCaret(e){}getLastActive(e){let t=this.control.querySelector(".last-active")
343
342
  if(t)return t
344
343
  var i=this.control.querySelectorAll(".active")
345
- return i?R(i,e):void 0}setCaret(e){this.caretPos=this.items.length}controlChildren(){return Array.from(this.control.querySelectorAll("[data-ts-item]"))}lock(){this.isLocked=!0,this.refreshState()}unlock(){this.isLocked=!1,this.refreshState()}disable(){var e=this
344
+ return i?K(i,e):void 0}setCaret(e){this.caretPos=this.items.length}controlChildren(){return Array.from(this.control.querySelectorAll("[data-ts-item]"))}lock(){this.isLocked=!0,this.refreshState()}unlock(){this.isLocked=!1,this.refreshState()}disable(){var e=this
346
345
  e.input.disabled=!0,e.control_input.disabled=!0,e.focus_node.tabIndex=-1,e.isDisabled=!0,this.close(),e.lock()}enable(){var e=this
347
346
  e.input.disabled=!1,e.control_input.disabled=!1,e.focus_node.tabIndex=e.tabIndex,e.isDisabled=!1,e.unlock()}destroy(){var e=this,t=e.revertSettings
348
- e.trigger("destroy"),e.off(),e.wrapper.remove(),e.dropdown.remove(),e.input.innerHTML=t.innerHTML,e.input.tabIndex=t.tabIndex,N(e.input,"tomselected","ts-hidden-accessible"),e._destroy(),delete e.input.tomselect}render(e,t){var i,s
347
+ e.trigger("destroy"),e.off(),e.wrapper.remove(),e.dropdown.remove(),e.input.innerHTML=t.innerHTML,e.input.tabIndex=t.tabIndex,z(e.input,"tomselected","ts-hidden-accessible"),e._destroy(),delete e.input.tomselect}render(e,t){var i,s
349
348
  const n=this
350
349
  if("function"!=typeof this.settings.render[e])return null
351
- if(null==(s=n.settings.render[e].call(this,t,Y)))return s
352
- if(s=T(s),"option"===e||"option_create"===e?t[n.settings.disabledField]?K(s,{"aria-disabled":"true"}):K(s,{"data-selectable":""}):"optgroup"===e&&(i=t.group[n.settings.optgroupValueField],K(s,{"data-group":i}),t.group[n.settings.disabledField]&&K(s,{"data-disabled":""})),"option"===e||"item"===e){const i=X(t[n.settings.valueField])
353
- K(s,{"data-value":i}),"item"===e?(D(s,n.settings.itemClass),K(s,{"data-ts-item":""})):(D(s,n.settings.optionClass),K(s,{role:"option",id:t.$id}),t.$div=s,n.options[i]=t)}return s}_render(e,t){const i=this.render(e,t)
350
+ if(!(s=n.settings.render[e].call(this,t,ee)))return null
351
+ if(s=V(s),"option"===e||"option_create"===e?t[n.settings.disabledField]?G(s,{"aria-disabled":"true"}):G(s,{"data-selectable":""}):"optgroup"===e&&(i=t.group[n.settings.optgroupValueField],G(s,{"data-group":i}),t.group[n.settings.disabledField]&&G(s,{"data-disabled":""})),"option"===e||"item"===e){const i=Z(t[n.settings.valueField])
352
+ G(s,{"data-value":i}),"item"===e?(H(s,n.settings.itemClass),G(s,{"data-ts-item":""})):(H(s,n.settings.optionClass),G(s,{role:"option",id:t.$id}),t.$div=s,n.options[i]=t)}return s}_render(e,t){const i=this.render(e,t)
354
353
  if(null==i)throw"HTMLElement expected"
355
- return i}clearCache(){F(this.options,(e=>{e.$div&&(e.$div.remove(),delete e.$div)}))}uncacheValue(e){const t=this.getOption(e)
354
+ return i}clearCache(){E(this.options,(e=>{e.$div&&(e.$div.remove(),delete e.$div)}))}uncacheValue(e){const t=this.getOption(e)
356
355
  t&&t.remove()}canCreate(e){return this.settings.create&&e.length>0&&this.settings.createFilter.call(this,e)}hook(e,t,i){var s=this,n=s[t]
357
356
  s[t]=function(){var t,o
358
- 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 ce.define("change_listener",(function(){ie(this.input,"change",(()=>{this.sync()}))})),ce.define("checkbox_options",(function(){var e=this,t=e.onOptionSelect
357
+ 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 ue.define("change_listener",(function(){ne(this.input,"change",(()=>{this.sync()}))})),ue.define("checkbox_options",(function(){var e=this,t=e.onOptionSelect
359
358
  e.settings.hideSelected=!1
360
359
  var i=function(e){setTimeout((()=>{var t=e.querySelector("input")
361
360
  t instanceof HTMLInputElement&&(e.classList.contains("selected")?t.checked=!0:t.checked=!1)}),1)}
362
361
  e.hook("after","setupTemplates",(()=>{var t=e.settings.render.option
363
- e.settings.render.option=(i,s)=>{var n=T(t.call(e,i,s)),o=document.createElement("input")
364
- o.addEventListener("click",(function(e){te(e)})),o.type="checkbox"
365
- const r=W(i[e.settings.valueField])
362
+ e.settings.render.option=(i,s)=>{var n=V(t.call(e,i,s)),o=document.createElement("input")
363
+ o.addEventListener("click",(function(e){se(e)})),o.type="checkbox"
364
+ const r=Y(i[e.settings.valueField])
366
365
  return r&&e.items.indexOf(r)>-1&&(o.checked=!0),n.prepend(o),n}})),e.on("item_remove",(t=>{var s=e.getOption(t)
367
366
  s&&(s.classList.remove("selected"),i(s))})),e.on("item_add",(t=>{var s=e.getOption(t)
368
- s&&i(s)})),e.hook("instead","onOptionSelect",((s,n)=>{if(n.classList.contains("selected"))return n.classList.remove("selected"),e.removeItem(n.dataset.value),e.refreshOptions(),void te(s,!0)
369
- t.call(e,s,n),i(n)}))})),ce.define("clear_button",(function(e){const t=this,i=Object.assign({className:"clear-button",title:"Clear All",html:e=>`<div class="${e.className}" title="${e.title}">&#10799;</div>`},e)
370
- t.on("initialize",(()=>{var e=T(i.html(i))
371
- e.addEventListener("click",(e=>{t.isDisabled||(t.clear(),"single"===t.settings.mode&&t.settings.allowEmptyOption&&t.addItem(""),e.preventDefault(),e.stopPropagation())})),t.control.appendChild(e)}))})),ce.define("drag_drop",(function(){var e=this
367
+ s&&i(s)})),e.hook("instead","onOptionSelect",((s,n)=>{if(n.classList.contains("selected"))return n.classList.remove("selected"),e.removeItem(n.dataset.value),e.refreshOptions(),void se(s,!0)
368
+ t.call(e,s,n),i(n)}))})),ue.define("clear_button",(function(e){const t=this,i=Object.assign({className:"clear-button",title:"Clear All",html:e=>`<div class="${e.className}" title="${e.title}">&#10799;</div>`},e)
369
+ t.on("initialize",(()=>{var e=V(i.html(i))
370
+ e.addEventListener("click",(e=>{t.isDisabled||(t.clear(),"single"===t.settings.mode&&t.settings.allowEmptyOption&&t.addItem(""),e.preventDefault(),e.stopPropagation())})),t.control.appendChild(e)}))})),ue.define("drag_drop",(function(){var e=this
372
371
  if(!$.fn.sortable)throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".')
373
372
  if("multi"===e.settings.mode){var t=e.lock,i=e.unlock
374
373
  e.hook("instead","lock",(()=>{var i=$(e.control).data("sortable")
375
374
  return i&&i.disable(),t.call(e)})),e.hook("instead","unlock",(()=>{var t=$(e.control).data("sortable")
376
375
  return t&&t.enable(),i.call(e)})),e.on("initialize",(()=>{var t=$(e.control).sortable({items:"[data-value]",forcePlaceholderSize:!0,disabled:e.isLocked,start:(e,i)=>{i.placeholder.css("width",i.helper.css("width")),t.css({overflow:"visible"})},stop:()=>{t.css({overflow:"hidden"})
377
376
  var i=[]
378
- t.children("[data-value]").each((function(){this.dataset.value&&i.push(this.dataset.value)})),e.setValue(i)}})}))}})),ce.define("dropdown_header",(function(e){const t=this,i=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)
379
- t.on("initialize",(()=>{var e=T(i.html(i)),s=e.querySelector("."+i.closeClass)
380
- s&&s.addEventListener("click",(e=>{te(e,!0),t.close()})),t.dropdown.insertBefore(e,t.dropdown.firstChild)}))})),ce.define("caret_position",(function(){var e=this
377
+ t.children("[data-value]").each((function(){this.dataset.value&&i.push(this.dataset.value)})),e.setValue(i)}})}))}})),ue.define("dropdown_header",(function(e){const t=this,i=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)
378
+ t.on("initialize",(()=>{var e=V(i.html(i)),s=e.querySelector("."+i.closeClass)
379
+ s&&s.addEventListener("click",(e=>{se(e,!0),t.close()})),t.dropdown.insertBefore(e,t.dropdown.firstChild)}))})),ue.define("caret_position",(function(){var e=this
381
380
  e.hook("instead","setCaret",(t=>{"single"!==e.settings.mode&&e.control.contains(e.control_input)?(t=Math.max(0,Math.min(e.items.length,t)))==e.caretPos||e.isPending||e.controlChildren().forEach(((i,s)=>{s<t?e.control_input.insertAdjacentElement("beforebegin",i):e.control.appendChild(i)})):t=e.items.length,e.caretPos=t})),e.hook("instead","moveCaret",(t=>{if(!e.isFocused)return
382
381
  const i=e.getLastActive(t)
383
- if(i){const s=B(i)
384
- e.setCaret(t>0?s+1:s),e.setActiveItem(),N(i,"last-active")}else e.setCaret(e.caretPos+t)}))})),ce.define("dropdown_input",(function(){const e=this
385
- e.settings.shouldOpen=!0,e.hook("before","setup",(()=>{e.focus_node=e.control,D(e.control_input,"dropdown-input")
386
- const t=T('<div class="dropdown-input-wrap">')
382
+ if(i){const s=Q(i)
383
+ e.setCaret(t>0?s+1:s),e.setActiveItem(),z(i,"last-active")}else e.setCaret(e.caretPos+t)}))})),ue.define("dropdown_input",(function(){const e=this
384
+ e.settings.shouldOpen=!0,e.hook("before","setup",(()=>{e.focus_node=e.control,H(e.control_input,"dropdown-input")
385
+ const t=V('<div class="dropdown-input-wrap">')
387
386
  t.append(e.control_input),e.dropdown.insertBefore(t,e.dropdown.firstChild)
388
- const i=T('<input class="items-placeholder" tabindex="-1" />')
389
- i.placeholder=e.settings.placeholder||"",e.control.append(i)})),e.on("initialize",(()=>{e.control_input.addEventListener("keydown",(t=>{switch(t.keyCode){case 27:return e.isOpen&&(te(t,!0),e.close()),void e.clearActiveItems()
387
+ const i=V('<input class="items-placeholder" tabindex="-1" />')
388
+ i.placeholder=e.settings.placeholder||"",e.control.append(i)})),e.on("initialize",(()=>{e.control_input.addEventListener("keydown",(t=>{switch(t.keyCode){case 27:return e.isOpen&&(se(t,!0),e.close()),void e.clearActiveItems()
390
389
  case 9:e.focus_node.tabIndex=-1}return e.onKeyDown.call(e,t)})),e.on("blur",(()=>{e.focus_node.tabIndex=e.isDisabled?-1:e.tabIndex})),e.on("dropdown_open",(()=>{e.control_input.focus()}))
391
390
  const t=e.onBlur
392
- e.hook("instead","onBlur",(i=>{if(!i||i.relatedTarget!=e.control_input)return t.call(e)})),ie(e.control_input,"blur",(()=>e.onBlur())),e.hook("before","close",(()=>{e.isOpen&&e.focus_node.focus({preventScroll:!0})}))}))})),ce.define("input_autogrow",(function(){var e=this
391
+ e.hook("instead","onBlur",(i=>{if(!i||i.relatedTarget!=e.control_input)return t.call(e)})),ne(e.control_input,"blur",(()=>e.onBlur())),e.hook("before","close",(()=>{e.isOpen&&e.focus_node.focus({preventScroll:!0})}))}))})),ue.define("input_autogrow",(function(){var e=this
393
392
  e.on("initialize",(()=>{var t=document.createElement("span"),i=e.control_input
394
393
  t.style.cssText="position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ",e.wrapper.appendChild(t)
395
394
  for(const e of["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"])t.style[e]=i.style[e]
396
395
  var s=()=>{t.textContent=i.value,i.style.width=t.clientWidth+"px"}
397
- s(),e.on("update item_add item_remove",s),ie(i,"input",s),ie(i,"keyup",s),ie(i,"blur",s),ie(i,"update",s)}))})),ce.define("no_backspace_delete",(function(){var e=this,t=e.deleteSelection
398
- this.hook("instead","deleteSelection",(i=>!!e.activeItems.length&&t.call(e,i)))})),ce.define("no_active_items",(function(){this.hook("instead","setActiveItem",(()=>{})),this.hook("instead","selectAll",(()=>{}))})),ce.define("optgroup_columns",(function(){var e=this,t=e.onKeyDown
396
+ s(),e.on("update item_add item_remove",s),ne(i,"input",s),ne(i,"keyup",s),ne(i,"blur",s),ne(i,"update",s)}))})),ue.define("no_backspace_delete",(function(){var e=this,t=e.deleteSelection
397
+ this.hook("instead","deleteSelection",(i=>!!e.activeItems.length&&t.call(e,i)))})),ue.define("no_active_items",(function(){this.hook("instead","setActiveItem",(()=>{})),this.hook("instead","selectAll",(()=>{}))})),ue.define("optgroup_columns",(function(){var e=this,t=e.onKeyDown
399
398
  e.hook("instead","onKeyDown",(i=>{var s,n,o,r
400
399
  if(!e.isOpen||37!==i.keyCode&&39!==i.keyCode)return t.call(e,i)
401
- e.ignoreHover=!0,r=z(e.activeOption,"[data-group]"),s=B(e.activeOption,"[data-selectable]"),r&&(r=37===i.keyCode?r.previousSibling:r.nextSibling)&&(n=(o=r.querySelectorAll("[data-selectable]"))[Math.min(o.length-1,s)])&&e.setActiveOption(n)}))})),ce.define("remove_button",(function(e){const t=Object.assign({label:"&times;",title:"Remove",className:"remove",append:!0},e)
400
+ e.ignoreHover=!0,r=B(e.activeOption,"[data-group]"),s=Q(e.activeOption,"[data-selectable]"),r&&(r=37===i.keyCode?r.previousSibling:r.nextSibling)&&(n=(o=r.querySelectorAll("[data-selectable]"))[Math.min(o.length-1,s)])&&e.setActiveOption(n)}))})),ue.define("remove_button",(function(e){const t=Object.assign({label:"&times;",title:"Remove",className:"remove",append:!0},e)
402
401
  var i=this
403
- if(t.append){var s='<a href="javascript:void(0)" class="'+t.className+'" tabindex="-1" title="'+Y(t.title)+'">'+t.label+"</a>"
402
+ if(t.append){var s='<a href="javascript:void(0)" class="'+t.className+'" tabindex="-1" title="'+ee(t.title)+'">'+t.label+"</a>"
404
403
  i.hook("after","setupTemplates",(()=>{var e=i.settings.render.item
405
- i.settings.render.item=(t,n)=>{var o=T(e.call(i,t,n)),r=T(s)
406
- return o.appendChild(r),ie(r,"mousedown",(e=>{te(e,!0)})),ie(r,"click",(e=>{te(e,!0),i.isLocked||i.shouldDelete([o],e)&&(i.removeItem(o),i.refreshOptions(!1),i.inputState())})),o}}))}})),ce.define("restore_on_backspace",(function(e){const t=this,i=Object.assign({text:e=>e[t.settings.labelField]},e)
404
+ i.settings.render.item=(t,n)=>{var o=V(e.call(i,t,n)),r=V(s)
405
+ return o.appendChild(r),ne(r,"mousedown",(e=>{se(e,!0)})),ne(r,"click",(e=>{se(e,!0),i.isLocked||i.shouldDelete([o],e)&&(i.removeItem(o),i.refreshOptions(!1),i.inputState())})),o}}))}})),ue.define("restore_on_backspace",(function(e){const t=this,i=Object.assign({text:e=>e[t.settings.labelField]},e)
407
406
  t.on("item_remove",(function(e){if(t.isFocused&&""===t.control_input.value.trim()){var s=t.options[e]
408
- s&&t.setTextboxValue(i.text.call(t,s))}}))})),ce.define("virtual_scroll",(function(){const e=this,t=e.canLoad,i=e.clearActiveOption,s=e.loadCallback
407
+ s&&t.setTextboxValue(i.text.call(t,s))}}))})),ue.define("virtual_scroll",(function(){const e=this,t=e.canLoad,i=e.clearActiveOption,s=e.loadCallback
409
408
  var n,o,r={},l=!1,a=[]
410
409
  if(e.settings.shouldLoadMore||(e.settings.shouldLoadMore=()=>{if(n.clientHeight/(n.scrollHeight-n.scrollTop)>.9)return!0
411
410
  if(e.activeOption){var t=e.selectable()
@@ -417,6 +416,6 @@ return r[t]=!1,e}return r={},e.settings.firstUrl.call(e,t)},e.hook("instead","cl
417
416
  void 0!==i&&(o.dataset.value=i[e.settings.valueField])}}else e.clearOptions(d)
418
417
  s.call(e,t,i),l=!1})),e.hook("after","refreshOptions",(()=>{const t=e.lastValue
419
418
  var i
420
- c(t)?(i=e.render("loading_more",{query:t}))&&(i.setAttribute("data-selectable",""),o=i):t in r&&!n.querySelector(".no-results")&&(i=e.render("no_more_results",{query:t})),i&&(D(i,e.settings.optionClass),n.append(i))})),e.on("initialize",(()=>{a=Object.keys(e.options),n=e.dropdown_content,e.settings.render=Object.assign({},{loading_more:()=>'<div class="loading-more-results">Loading more results ... </div>',no_more_results:()=>'<div class="no-more-results">No more results</div>'},e.settings.render),n.addEventListener("scroll",(()=>{e.settings.shouldLoadMore.call(e)&&c(e.lastValue)&&(l||(l=!0,e.load.call(e,e.lastValue)))}))}))})),ce}))
419
+ c(t)?(i=e.render("loading_more",{query:t}))&&(i.setAttribute("data-selectable",""),o=i):t in r&&!n.querySelector(".no-results")&&(i=e.render("no_more_results",{query:t})),i&&(H(i,e.settings.optionClass),n.append(i))})),e.on("initialize",(()=>{a=Object.keys(e.options),n=e.dropdown_content,e.settings.render=Object.assign({},{loading_more:()=>'<div class="loading-more-results">Loading more results ... </div>',no_more_results:()=>'<div class="no-more-results">No more results</div>'},e.settings.render),n.addEventListener("scroll",(()=>{e.settings.shouldLoadMore.call(e)&&c(e.lastValue)&&(l||(l=!0,e.load.call(e,e.lastValue)))}))}))})),ue}))
421
420
  var tomSelect=function(e,t){return new TomSelect(e,t)}
422
421
  //# sourceMappingURL=tom-select.complete.min.js.map