tom-select-rails 0.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) 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 +761 -273
  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 +756 -272
  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 +753 -269
  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 +1 -1
  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 +9 -5
  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 +1 -1
  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 +12 -7
  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 +13 -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/drag_drop/plugin.js.map +1 -1
  21. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_header/plugin.js +12 -7
  22. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_header/plugin.js.map +1 -1
  23. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_input/plugin.js +12 -8
  24. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_input/plugin.js.map +1 -1
  25. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/input_autogrow/plugin.js +1 -1
  26. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/input_autogrow/plugin.js.map +1 -1
  27. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_active_items/plugin.js +1 -1
  28. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_active_items/plugin.js.map +1 -1
  29. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_backspace_delete/plugin.js +1 -1
  30. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_backspace_delete/plugin.js.map +1 -1
  31. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/optgroup_columns/plugin.js +9 -4
  32. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/optgroup_columns/plugin.js.map +1 -1
  33. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/remove_button/plugin.js +12 -7
  34. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/remove_button/plugin.js.map +1 -1
  35. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/restore_on_backspace/plugin.js +1 -1
  36. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/restore_on_backspace/plugin.js.map +1 -1
  37. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/virtual_scroll/plugin.js +16 -8
  38. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/virtual_scroll/plugin.js.map +1 -1
  39. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.complete.js +761 -273
  40. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.complete.js.map +1 -1
  41. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.js +756 -272
  42. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.js.map +1 -1
  43. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.popular.js +753 -269
  44. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.popular.js.map +1 -1
  45. data/vendor/assets/javascripts/tom-select-rails/esm/utils.js +1 -1
  46. data/vendor/assets/javascripts/tom-select-rails/esm/utils.js.map +1 -1
  47. data/vendor/assets/javascripts/tom-select-rails/js/plugins/caret_position.js +164 -160
  48. data/vendor/assets/javascripts/tom-select-rails/js/plugins/caret_position.js.map +1 -1
  49. data/vendor/assets/javascripts/tom-select-rails/js/plugins/change_listener.js +1 -1
  50. data/vendor/assets/javascripts/tom-select-rails/js/plugins/change_listener.js.map +1 -1
  51. data/vendor/assets/javascripts/tom-select-rails/js/plugins/checkbox_options.js +12 -7
  52. data/vendor/assets/javascripts/tom-select-rails/js/plugins/checkbox_options.js.map +1 -1
  53. data/vendor/assets/javascripts/tom-select-rails/js/plugins/clear_button.js +94 -89
  54. data/vendor/assets/javascripts/tom-select-rails/js/plugins/clear_button.js.map +1 -1
  55. data/vendor/assets/javascripts/tom-select-rails/js/plugins/drag_drop.js +1 -1
  56. data/vendor/assets/javascripts/tom-select-rails/js/plugins/drag_drop.js.map +1 -1
  57. data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_header.js +121 -116
  58. data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_header.js.map +1 -1
  59. data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_input.js +234 -230
  60. data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_input.js.map +1 -1
  61. data/vendor/assets/javascripts/tom-select-rails/js/plugins/input_autogrow.js +1 -1
  62. data/vendor/assets/javascripts/tom-select-rails/js/plugins/input_autogrow.js.map +1 -1
  63. data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_active_items.js +1 -1
  64. data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_active_items.js.map +1 -1
  65. data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_backspace_delete.js +1 -1
  66. data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_backspace_delete.js.map +1 -1
  67. data/vendor/assets/javascripts/tom-select-rails/js/plugins/optgroup_columns.js +112 -107
  68. data/vendor/assets/javascripts/tom-select-rails/js/plugins/optgroup_columns.js.map +1 -1
  69. data/vendor/assets/javascripts/tom-select-rails/js/plugins/remove_button.js +149 -144
  70. data/vendor/assets/javascripts/tom-select-rails/js/plugins/remove_button.js.map +1 -1
  71. data/vendor/assets/javascripts/tom-select-rails/js/plugins/restore_on_backspace.js +1 -1
  72. data/vendor/assets/javascripts/tom-select-rails/js/plugins/restore_on_backspace.js.map +1 -1
  73. data/vendor/assets/javascripts/tom-select-rails/js/plugins/virtual_scroll.js +277 -269
  74. data/vendor/assets/javascripts/tom-select-rails/js/plugins/virtual_scroll.js.map +1 -1
  75. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.js +756 -272
  76. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.js.map +1 -1
  77. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.min.js +329 -272
  78. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.min.js.map +1 -1
  79. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.js +761 -273
  80. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.js.map +1 -1
  81. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.min.js +268 -209
  82. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.min.js.map +1 -1
  83. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.js +753 -269
  84. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.js.map +1 -1
  85. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.min.js +348 -291
  86. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.min.js.map +1 -1
  87. data/vendor/assets/javascripts/tom-select-rails/types/tom-select.d.ts +6 -6
  88. data/vendor/assets/javascripts/tom-select-rails/types/types/settings.d.ts +19 -22
  89. data/vendor/assets/javascripts/tom-select-rails/types/utils.d.ts +5 -5
  90. data/vendor/assets/javascripts/tom-select-rails/types/vanilla.d.ts +2 -2
  91. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.css +41 -19
  92. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.css.map +1 -1
  93. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.min.css +1 -1
  94. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.min.css.map +1 -1
  95. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.css +61 -34
  96. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.css.map +1 -1
  97. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.min.css +1 -1
  98. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.min.css.map +1 -1
  99. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.css +39 -17
  100. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.css.map +1 -1
  101. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.css +41 -19
  102. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.css.map +1 -1
  103. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.min.css +1 -1
  104. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.min.css.map +1 -1
  105. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.min.css +1 -1
  106. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.min.css.map +1 -1
  107. data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/clear_button.scss +11 -10
  108. data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/remove_button.scss +34 -8
  109. data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.bootstrap4.scss +1 -1
  110. data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.bootstrap5.scss +20 -10
  111. data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.default.scss +1 -1
  112. data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.scss +11 -2
  113. metadata +3 -3
@@ -1,323 +1,380 @@
1
1
  /**
2
- * Tom Select v2.1.0
2
+ * Tom Select v2.2.1
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  */
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"
6
- function e(e,t){e.split(/\s+/).forEach((e=>{t(e)}))}class t{constructor(){this._events=void 0,this._events={}}on(t,i){e(t,(e=>{this._events[e]=this._events[e]||[],this._events[e].push(i)}))}off(t,i){var s=arguments.length
7
- 0!==s?e(t,(e=>{if(1===s)return delete this._events[e]
8
- e in this._events!=!1&&this._events[e].splice(this._events[e].indexOf(i),1)})):this._events={}}trigger(t,...i){var s=this
9
- e(t,(e=>{if(e in s._events!=!1)for(let t of s._events[e])t.apply(s,i)}))}}var i
10
- const s="[̀-ͯ·ʾ]",n=new RegExp(s,"gu")
11
- var o
12
- const r={"æ":"ae","":"a","ø":"o"},l=new RegExp(Object.keys(r).join("|"),"gu"),a=[[0,65535]],c=e=>e.normalize("NFKD").replace(n,"").toLowerCase().replace(l,(function(e){return r[e]})),d=(e,t="|")=>{if(1==e.length)return e[0]
13
- var i=1
14
- return e.forEach((e=>{i=Math.max(i,e.length)})),1==i?"["+e.join("")+"]":"(?:"+e.join(t)+")"},p=e=>{const t=e.map((e=>f(e)))
15
- return d(t)},u=e=>{if(1===e.length)return[[e]]
16
- var t=[]
17
- return u(e.substring(1)).forEach((function(i){var s=i.slice(0)
18
- s[0]=e.charAt(0)+s[0],t.push(s),(s=i.slice(0)).unshift(e.charAt(0)),t.push(s)})),t},h=e=>{void 0===o&&(o=(e=>{var t={}
19
- e.forEach((e=>{for(let s=e[0];s<=e[1];s++){let e=String.fromCharCode(s),n=c(e)
20
- if(n!=e.toLowerCase()&&!(n.length>3)){n in t||(t[n]=[n])
21
- var i=new RegExp(p(t[n]),"iu")
22
- e.match(i)||t[n].push(e)}}}))
23
- let s=Object.keys(t)
24
- for(let e=0;e<s.length;e++){const i=s[e]
25
- t[i].length<2&&delete t[i]}s=Object.keys(t).sort(((e,t)=>t.length-e.length)),i=new RegExp("("+p(s)+"[̀-ͯ·ʾ]*)","gu")
26
- var n={}
27
- return s.sort(((e,t)=>e.length-t.length)).forEach((e=>{var i=u(e).map((e=>(e=e.map((e=>t.hasOwnProperty(e)?p(t[e]):e)),d(e,""))))
28
- n[e]=d(i)})),n})(a))
29
- return e.normalize("NFKD").toLowerCase().split(i).map((e=>{const t=c(e)
30
- return""==t?"":o.hasOwnProperty(t)?o[t]:e})).join("")},g=(e,t)=>{if(e)return e[t]},v=(e,t)=>{if(e){for(var i,s=t.split(".");(i=s.shift())&&(e=e[i]););return e}},m=(e,t,i)=>{var s,n
31
- return e?-1===(n=(e+="").search(t.regex))?0:(s=t.string.length/e.length,0===n&&(s+=.5),s*i):0},f=e=>(e+"").replace(/([\$\(-\+\.\?\[-\^\{-\}])/g,"\\$1"),y=(e,t)=>{var i=e[t]
5
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).TomSelect=e()}(this,(function(){"use strict"
6
+ function t(t,e){t.split(/\s+/).forEach((t=>{e(t)}))}class e{constructor(){this._events=void 0,this._events={}}on(e,i){t(e,(t=>{const e=this._events[t]||[]
7
+ e.push(i),this._events[t]=e}))}off(e,i){var s=arguments.length
8
+ 0!==s?t(e,(t=>{if(1===s)return void delete this._events[t]
9
+ const e=this._events[t]
10
+ void 0!==e&&(e.splice(e.indexOf(i),1),this._events[t]=e)})):this._events={}}trigger(e,...i){var s=this
11
+ t(e,(t=>{const e=s._events[t]
12
+ void 0!==e&&e.forEach((t=>{t.apply(s,i)}))}))}}const i=t=>(t=t.filter(Boolean)).length<2?t[0]||"":1==l(t)?"["+t.join("")+"]":"(?:"+t.join("|")+")",s=t=>{if(!o(t))return t.join("")
13
+ let e="",i=0
14
+ const s=()=>{i>1&&(e+="{"+i+"}")}
15
+ return t.forEach(((n,o)=>{n!==t[o-1]?(s(),e+=n,i=1):i++})),s(),e},n=t=>{let e=c(t)
16
+ return i(e)},o=t=>new Set(t).size!==t.length,r=t=>(t+"").replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu,"\\$1"),l=t=>t.reduce(((t,e)=>Math.max(t,a(e))),0),a=t=>c(t).length,c=t=>Array.from(t),d=t=>{if(1===t.length)return[[t]]
17
+ let e=[]
18
+ const i=t.substring(1)
19
+ return d(i).forEach((function(i){let s=i.slice(0)
20
+ s[0]=t.charAt(0)+s[0],e.push(s),s=i.slice(0),s.unshift(t.charAt(0)),e.push(s)})),e},u=[[0,65535]]
21
+ let p,h
22
+ const g={"æ":"ae","ⱥ":"a","ø":"o","⁄":"/","∕":"/"},f=new RegExp(Object.keys(g).join("|")+"|[̀-ͯ·ʾ]","gu"),v=(t,e="NFKD")=>t.normalize(e),m=t=>(t=>t.match(/[\u0f71-\u0f81]/)?c(t).reduce(((t,e)=>t+v(e)),""):v(t))(t).toLowerCase().replace(f,(t=>g[t]||""))
23
+ const y=t=>{const e={},i=(t,i)=>{const s=e[t]||new Set,o=new RegExp("^"+n(s)+"$","iu")
24
+ i.match(o)||(s.add(r(i)),e[t]=s)}
25
+ for(let e of function*(t){for(const[e,i]of t)for(let t=e;t<=i;t++){let e=String.fromCharCode(t),i=m(e)
26
+ if(i==e.toLowerCase())continue
27
+ if(i.length>3)continue
28
+ if(0==i.length)continue
29
+ let s=v(e)
30
+ v(s,"NFC")===e&&i===s||(yield{folded:i,composed:e,code_point:t})}}(t))i(e.folded,e.folded),i(e.folded,e.composed)
31
+ return e},O=t=>{const e=y(t),s={}
32
+ let o=[]
33
+ for(let t in e){let i=e[t]
34
+ i&&(s[t]=n(i)),t.length>1&&o.push(r(t))}o.sort(((t,e)=>e.length-t.length))
35
+ const l=i(o)
36
+ return h=new RegExp("^"+l,"u"),s},b=(t,e=1)=>(e=Math.max(e,t.length-1),i(d(t).map((t=>((t,e=1)=>{let i=0
37
+ return t=t.map((t=>(p[t]&&(i+=t.length),p[t]||t))),i>=e?s(t):""})(t,e))))),w=(t,e=!0)=>{let n=t.length>1?1:0
38
+ return i(t.map((t=>{let i=[]
39
+ const o=e?t.length():t.length()-1
40
+ for(let e=0;e<o;e++)i.push(b(t.substrs[e]||"",n))
41
+ return s(i)})))},_=(t,e)=>{for(const i of e){if(i.start!=t.start||i.end!=t.end)continue
42
+ if(i.substrs.join("")!==t.substrs.join(""))continue
43
+ let e=t.parts
44
+ const s=t=>{for(const i of e){if(i.start===t.start&&i.substr===t.substr)return!1
45
+ if(1!=t.length&&1!=i.length){if(t.start<i.start&&t.end>i.start)return!0
46
+ if(i.start<t.start&&i.end>t.start)return!0}}return!1}
47
+ 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(t){t&&(this.parts.push(t),this.substrs.push(t.substr),this.start=Math.min(t.start,this.start),this.end=Math.max(t.end,this.end))}last(){return this.parts[this.parts.length-1]}length(){return this.parts.length}clone(t,e){let i=new I,s=JSON.parse(JSON.stringify(this.parts)),n=s.pop()
49
+ for(const t of s)i.add(t)
50
+ let o=e.substr.substring(0,t-n.start),r=o.length
51
+ return i.add({start:n.start,end:n.start+r,length:r,substr:o}),i}}const S=t=>{var e
52
+ void 0===p&&(p=O(e||u)),t=m(t)
53
+ let i="",s=[new I]
54
+ for(let e=0;e<t.length;e++){let n=t.substring(e).match(h)
55
+ const o=t.substring(e,e+1),r=n?n[0]:null
56
+ let l=[],a=new Set
57
+ for(const t of s){const i=t.last()
58
+ if(!i||1==i.length||i.end<=e)if(r){const i=r.length
59
+ t.add({start:e,end:e+i,length:i,substr:r}),a.add("1")}else t.add({start:e,end:e+1,length:1,substr:o}),a.add("2")
60
+ else if(r){let s=t.clone(e,i)
61
+ const n=r.length
62
+ s.add({start:e,end:e+n,length:n,substr:r}),l.push(s)}else a.add("3")}if(l.length>0){l=l.sort(((t,e)=>t.length()-e.length()))
63
+ for(let t of l)_(t,s)||s.push(t)}else if(e>0&&1==a.size&&!a.has("3")){i+=w(s,!1)
64
+ let t=new I
65
+ const e=s[0]
66
+ e&&t.add(e.last()),s=[t]}}return i+=w(s,!0),i},A=(t,e)=>{if(t)return t[e]},C=(t,e)=>{if(t){for(var i,s=e.split(".");(i=s.shift())&&(t=t[i]););return t}},x=(t,e,i)=>{var s,n
67
+ return t?(t+="",null==e.regex||-1===(n=t.search(e.regex))?0:(s=e.string.length/t.length,0===n&&(s+=.5),s*i)):0},F=(t,e)=>{var i=t[e]
32
68
  if("function"==typeof i)return i
33
- i&&!Array.isArray(i)&&(e[t]=[i])},O=(e,t)=>{if(Array.isArray(e))e.forEach(t)
34
- else for(var i in e)e.hasOwnProperty(i)&&t(e[i],i)},b=(e,t)=>"number"==typeof e&&"number"==typeof t?e>t?1:e<t?-1:0:(e=c(e+"").toLowerCase())>(t=c(t+"").toLowerCase())?1:t>e?-1:0
35
- class w{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[]
36
- const s=[],n=e.split(/\s+/)
69
+ i&&!Array.isArray(i)&&(t[e]=[i])},k=(t,e)=>{if(Array.isArray(t))t.forEach(e)
70
+ else for(var i in t)t.hasOwnProperty(i)&&e(t[i],i)},L=(t,e)=>"number"==typeof t&&"number"==typeof e?t>e?1:t<e?-1:0:(t=m(t+"").toLowerCase())>(e=m(e+"").toLowerCase())?1:e>t?-1:0
71
+ class E{constructor(t,e){this.items=void 0,this.settings=void 0,this.items=t,this.settings=e||{diacritics:!0}}tokenize(t,e,i){if(!t||!t.length)return[]
72
+ const s=[],n=t.split(/\s+/)
37
73
  var o
38
- return i&&(o=new RegExp("^("+Object.keys(i).map(f).join("|")+"):(.*)$")),n.forEach((e=>{let i,n=null,r=null
39
- o&&(i=e.match(o))&&(n=i[1],e=i[2]),e.length>0&&(r=this.settings.diacritics?h(e):f(e),t&&(r="\\b"+r)),s.push({string:e,regex:r?new RegExp(r,"iu"):null,field:n})})),s}getScoreFunction(e,t){var i=this.prepareSearch(e,t)
40
- return this._getScoreFunction(i)}_getScoreFunction(e){const t=e.tokens,i=t.length
74
+ return i&&(o=new RegExp("^("+Object.keys(i).map(r).join("|")+"):(.*)$")),n.forEach((t=>{let i,n=null,l=null
75
+ o&&(i=t.match(o))&&(n=i[1],t=i[2]),t.length>0&&(l=this.settings.diacritics?S(t)||null:r(t),l&&e&&(l="\\b"+l)),s.push({string:t,regex:l?new RegExp(l,"iu"):null,field:n})})),s}getScoreFunction(t,e){var i=this.prepareSearch(t,e)
76
+ return this._getScoreFunction(i)}_getScoreFunction(t){const e=t.tokens,i=e.length
41
77
  if(!i)return function(){return 0}
42
- const s=e.options.fields,n=e.weights,o=s.length,r=e.getAttrFn
78
+ const s=t.options.fields,n=t.weights,o=s.length,r=t.getAttrFn
43
79
  if(!o)return function(){return 1}
44
- const l=1===o?function(e,t){const i=s[0].field
45
- return m(r(t,i),e,n[i])}:function(e,t){var i=0
46
- if(e.field){const s=r(t,e.field)
47
- !e.regex&&s?i+=1/o:i+=m(s,e,1)}else O(n,((s,n)=>{i+=m(r(t,n),e,s)}))
80
+ const l=1===o?function(t,e){const i=s[0].field
81
+ return x(r(e,i),t,n[i]||1)}:function(t,e){var i=0
82
+ if(t.field){const s=r(e,t.field)
83
+ !t.regex&&s?i+=1/o:i+=x(s,t,1)}else k(n,((s,n)=>{i+=x(r(e,n),t,s)}))
48
84
  return i/o}
49
- return 1===i?function(e){return l(t[0],e)}:"and"===e.options.conjunction?function(e){for(var s,n=0,o=0;n<i;n++){if((s=l(t[n],e))<=0)return 0
50
- o+=s}return o/i}:function(e){var s=0
51
- return O(t,(t=>{s+=l(t,e)})),s/i}}getSortFunction(e,t){var i=this.prepareSearch(e,t)
52
- return this._getSortFunction(i)}_getSortFunction(e){var t,i,s
53
- const n=this,o=e.options,r=!e.query&&o.sort_empty?o.sort_empty:o.sort,l=[],a=[]
54
- if("function"==typeof r)return r.bind(this)
55
- const c=function(t,i){return"$score"===t?i.score:e.getAttrFn(n.items[i.id],t)}
56
- if(r)for(t=0,i=r.length;t<i;t++)(e.query||"$score"!==r[t].field)&&l.push(r[t])
57
- if(e.query){for(s=!0,t=0,i=l.length;t<i;t++)if("$score"===l[t].field){s=!1
58
- break}s&&l.unshift({field:"$score",direction:"desc"})}else for(t=0,i=l.length;t<i;t++)if("$score"===l[t].field){l.splice(t,1)
59
- break}for(t=0,i=l.length;t<i;t++)a.push("desc"===l[t].direction?-1:1)
60
- const d=l.length
61
- if(d){if(1===d){const e=l[0].field,t=a[0]
62
- return function(i,s){return t*b(c(e,i),c(e,s))}}return function(e,t){var i,s,n
63
- for(i=0;i<d;i++)if(n=l[i].field,s=a[i]*b(c(n,e),c(n,t)))return s
64
- return 0}}return null}prepareSearch(e,t){const i={}
65
- var s=Object.assign({},t)
66
- if(y(s,"sort"),y(s,"sort_empty"),s.fields){y(s,"fields")
67
- const e=[]
68
- 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?v:g}}search(e,t){var i,s,n=this
69
- s=this.prepareSearch(e,t),t=s.options,e=s.query
70
- const o=t.score||n._getScoreFunction(s)
71
- e.length?O(n.items,((e,n)=>{i=o(e),(!1===t.filter||i>0)&&s.items.push({score:i,id:n})})):O(n.items,((e,t)=>{s.items.push({score:1,id:t})}))
85
+ return 1===i?function(t){return l(e[0],t)}:"and"===t.options.conjunction?function(t){var s,n=0
86
+ for(let i of e){if((s=l(i,t))<=0)return 0
87
+ n+=s}return n/i}:function(t){var s=0
88
+ return k(e,(e=>{s+=l(e,t)})),s/i}}getSortFunction(t,e){var i=this.prepareSearch(t,e)
89
+ return this._getSortFunction(i)}_getSortFunction(t){var e,i=[]
90
+ const s=this,n=t.options,o=!t.query&&n.sort_empty?n.sort_empty:n.sort
91
+ if("function"==typeof o)return o.bind(this)
92
+ const r=function(e,i){return"$score"===e?i.score:t.getAttrFn(s.items[i.id],e)}
93
+ if(o)for(let e of o)(t.query||"$score"!==e.field)&&i.push(e)
94
+ if(t.query){e=!0
95
+ for(let t of i)if("$score"===t.field){e=!1
96
+ break}e&&i.unshift({field:"$score",direction:"desc"})}else i=i.filter((t=>"$score"!==t.field))
97
+ return i.length?function(t,e){var s,n
98
+ for(let o of i){if(n=o.field,s=("desc"===o.direction?-1:1)*L(r(n,t),r(n,e)))return s}return 0}:null}prepareSearch(t,e){const i={}
99
+ var s=Object.assign({},e)
100
+ if(F(s,"sort"),F(s,"sort_empty"),s.fields){F(s,"fields")
101
+ const t=[]
102
+ s.fields.forEach((e=>{"string"==typeof e&&(e={field:e,weight:1}),t.push(e),i[e.field]="weight"in e?e.weight:1})),s.fields=t}return{options:s,query:t.toLowerCase().trim(),tokens:this.tokenize(t,s.respect_word_boundaries,i),total:0,items:[],weights:i,getAttrFn:s.nesting?C:A}}search(t,e){var i,s,n=this
103
+ s=this.prepareSearch(t,e),e=s.options,t=s.query
104
+ const o=e.score||n._getScoreFunction(s)
105
+ t.length?k(n.items,((t,n)=>{i=o(t),(!1===e.filter||i>0)&&s.items.push({score:i,id:n})})):k(n.items,((t,e)=>{s.items.push({score:1,id:e})}))
72
106
  const r=n._getSortFunction(s)
73
- 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 _=e=>{if(e.jquery)return e[0]
74
- if(e instanceof HTMLElement)return e
75
- if(I(e)){let t=document.createElement("div")
76
- return t.innerHTML=e.trim(),t.firstChild}return document.querySelector(e)},I=e=>"string"==typeof e&&e.indexOf("<")>-1,S=(e,t)=>{var i=document.createEvent("HTMLEvents")
77
- i.initEvent(t,!0,!1),e.dispatchEvent(i)},A=(e,t)=>{Object.assign(e.style,t)},C=(e,...t)=>{var i=F(t);(e=k(e)).map((e=>{i.map((t=>{e.classList.add(t)}))}))},x=(e,...t)=>{var i=F(t);(e=k(e)).map((e=>{i.map((t=>{e.classList.remove(t)}))}))},F=e=>{var t=[]
78
- return O(e,(e=>{"string"==typeof e&&(e=e.trim().split(/[\11\12\14\15\40]/)),Array.isArray(e)&&(t=t.concat(e))})),t.filter(Boolean)},k=e=>(Array.isArray(e)||(e=[e]),e),L=(e,t,i)=>{if(!i||i.contains(e))for(;e&&e.matches;){if(e.matches(t))return e
79
- e=e.parentNode}},P=(e,t=0)=>t>0?e[e.length-1]:e[0],E=(e,t)=>{if(!e)return-1
80
- t=t||e.nodeName
81
- for(var i=0;e=e.previousElementSibling;)e.matches(t)&&i++
82
- return i},T=(e,t)=>{O(t,((t,i)=>{null==t?e.removeAttribute(i):e.setAttribute(i,""+t)}))},j=(e,t)=>{e.parentNode&&e.parentNode.replaceChild(t,e)},V=(e,t)=>{if(null===t)return
83
- if("string"==typeof t){if(!t.length)return
84
- t=new RegExp(t,"i")}const i=e=>3===e.nodeType?(e=>{var i=e.data.match(t)
85
- if(i&&e.data.length>0){var s=document.createElement("span")
107
+ return r&&s.items.sort(r),s.total=s.items.length,"number"==typeof e.limit&&(s.items=s.items.slice(0,e.limit)),s}}const P=(t,e)=>{if(Array.isArray(t))t.forEach(e)
108
+ else for(var i in t)t.hasOwnProperty(i)&&e(t[i],i)},T=t=>{if(t.jquery)return t[0]
109
+ if(t instanceof HTMLElement)return t
110
+ if(j(t)){var e=document.createElement("template")
111
+ return e.innerHTML=t.trim(),e.content.firstChild}return document.querySelector(t)},j=t=>"string"==typeof t&&t.indexOf("<")>-1,V=(t,e)=>{var i=document.createEvent("HTMLEvents")
112
+ i.initEvent(e,!0,!1),t.dispatchEvent(i)},$=(t,e)=>{Object.assign(t.style,e)},q=(t,...e)=>{var i=N(e);(t=H(t)).map((t=>{i.map((e=>{t.classList.add(e)}))}))},D=(t,...e)=>{var i=N(e);(t=H(t)).map((t=>{i.map((e=>{t.classList.remove(e)}))}))},N=t=>{var e=[]
113
+ return P(t,(t=>{"string"==typeof t&&(t=t.trim().split(/[\11\12\14\15\40]/)),Array.isArray(t)&&(e=e.concat(t))})),e.filter(Boolean)},H=t=>(Array.isArray(t)||(t=[t]),t),R=(t,e,i)=>{if(!i||i.contains(t))for(;t&&t.matches;){if(t.matches(e))return t
114
+ t=t.parentNode}},M=(t,e=0)=>e>0?t[t.length-1]:t[0],B=(t,e)=>{if(!t)return-1
115
+ e=e||t.nodeName
116
+ for(var i=0;t=t.previousElementSibling;)t.matches(e)&&i++
117
+ return i},z=(t,e)=>{P(e,((e,i)=>{null==e?t.removeAttribute(i):t.setAttribute(i,""+e)}))},K=(t,e)=>{t.parentNode&&t.parentNode.replaceChild(e,t)},Q=(t,e)=>{if(null===e)return
118
+ if("string"==typeof e){if(!e.length)return
119
+ e=new RegExp(e,"i")}const i=t=>3===t.nodeType?(t=>{var i=t.data.match(e)
120
+ if(i&&t.data.length>0){var s=document.createElement("span")
86
121
  s.className="highlight"
87
- var n=e.splitText(i.index)
122
+ var n=t.splitText(i.index)
88
123
  n.splitText(i[0].length)
89
124
  var o=n.cloneNode(!0)
90
- return s.appendChild(o),j(n,s),1}return 0})(e):((e=>{if(1===e.nodeType&&e.childNodes&&!/(script|style)/i.test(e.tagName)&&("highlight"!==e.className||"SPAN"!==e.tagName))for(var t=0;t<e.childNodes.length;++t)t+=i(e.childNodes[t])})(e),0)
91
- i(e)},$="undefined"!=typeof navigator&&/Mac/.test(navigator.userAgent)?"metaKey":"ctrlKey"
92
- var q={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:{}}
93
- const D=e=>null==e?null:N(e),N=e=>"boolean"==typeof e?e?"1":"0":e+"",H=e=>(e+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),R=(e,t)=>{var i
125
+ return s.appendChild(o),K(n,s),1}return 0})(t):((t=>{1!==t.nodeType||!t.childNodes||/(script|style)/i.test(t.tagName)||"highlight"===t.className&&"SPAN"===t.tagName||Array.from(t.childNodes).forEach((t=>{i(t)}))})(t),0)
126
+ i(t)},G="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(t){return t.length>0},render:{}}
128
+ const U=t=>null==t?null:W(t),W=t=>"boolean"==typeof t?t?"1":"0":t+"",X=t=>(t+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),Y=(t,e)=>{var i
94
129
  return function(s,n){var o=this
95
- 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)}},B=(e,t,i)=>{var s,n=e.trigger,o={}
96
- for(s of(e.trigger=function(){var i=arguments[0]
97
- if(-1===t.indexOf(i))return n.apply(e,arguments)
98
- o[i]=arguments},i.apply(e,[]),e.trigger=n,t))s in o&&n.apply(e,o[s])},z=(e,t=!1)=>{e&&(e.preventDefault(),t&&e.stopPropagation())},M=(e,t,i,s)=>{e.addEventListener(t,i,s)},K=(e,t)=>!!t&&(!!t[e]&&1===(t.altKey?1:0)+(t.ctrlKey?1:0)+(t.shiftKey?1:0)+(t.metaKey?1:0)),Q=(e,t)=>{const i=e.getAttribute("id")
99
- return i||(e.setAttribute("id",t),t)},G=e=>e.replace(/[\\"']/g,"\\$&"),J=(e,t)=>{t&&e.append(t)}
100
- function U(e,t){var i=Object.assign({},q,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(),p=e.getAttribute("placeholder")||e.getAttribute("data-placeholder")
101
- if(!p&&!i.allowEmptyOption){let t=e.querySelector('option[value=""]')
102
- t&&(p=t.textContent)}var u,h,g,v,m,f,y={placeholder:p,options:[],optgroups:[],items:[],maxItems:null}
103
- return"select"===d?(h=y.options,g={},v=1,m=e=>{var t=Object.assign({},e.dataset),i=s&&t[s]
104
- return"string"==typeof i&&i.length&&(t=Object.assign(t,JSON.parse(i))),t},f=(e,t)=>{var s=D(e.value)
105
- if(null!=s&&(s||i.allowEmptyOption)){if(g.hasOwnProperty(s)){if(t){var a=g[s][l]
106
- a?Array.isArray(a)?a.push(t):g[s][l]=[a,t]:g[s][l]=t}}else{var c=m(e)
107
- 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,O(e.children,(e=>{var t,i,s
108
- "optgroup"===(u=e.tagName.toLowerCase())?((s=m(t=e))[a]=s[a]||t.getAttribute("label")||"",s[c]=s[c]||v++,s[r]=s[r]||t.disabled,y.optgroups.push(s),i=s[c],O(t.children,(e=>{f(e,i)}))):"option"===u&&f(e)}))):(()=>{const t=e.getAttribute(s)
109
- if(t)y.options=JSON.parse(t),O(y.options,(e=>{y.items.push(e[o])}))
110
- else{var r=e.value.trim()||""
130
+ i&&(o.loading=Math.max(o.loading-1,0),clearTimeout(i)),i=setTimeout((function(){i=null,o.loadedSearches[s]=!0,t.call(o,s,n)}),e)}},Z=(t,e,i)=>{var s,n=t.trigger,o={}
131
+ for(s of(t.trigger=function(){var i=arguments[0]
132
+ if(-1===e.indexOf(i))return n.apply(t,arguments)
133
+ o[i]=arguments},i.apply(t,[]),t.trigger=n,e))s in o&&n.apply(t,o[s])},tt=(t,e=!1)=>{t&&(t.preventDefault(),e&&t.stopPropagation())},et=(t,e,i,s)=>{t.addEventListener(e,i,s)},it=(t,e)=>!!e&&(!!e[t]&&1===(e.altKey?1:0)+(e.ctrlKey?1:0)+(e.shiftKey?1:0)+(e.metaKey?1:0)),st=(t,e)=>{const i=t.getAttribute("id")
134
+ return i||(t.setAttribute("id",e),e)},nt=t=>t.replace(/[\\"']/g,"\\$&"),ot=(t,e)=>{e&&t.append(e)}
135
+ function rt(t,e){var i=Object.assign({},J,e),s=i.dataAttr,n=i.labelField,o=i.valueField,r=i.disabledField,l=i.optgroupField,a=i.optgroupLabelField,c=i.optgroupValueField,d=t.tagName.toLowerCase(),u=t.getAttribute("placeholder")||t.getAttribute("data-placeholder")
136
+ if(!u&&!i.allowEmptyOption){let e=t.querySelector('option[value=""]')
137
+ e&&(u=e.textContent)}var p,h,g,f,v,m,y={placeholder:u,options:[],optgroups:[],items:[],maxItems:null}
138
+ return"select"===d?(h=y.options,g={},f=1,v=t=>{var e=Object.assign({},t.dataset),i=s&&e[s]
139
+ return"string"==typeof i&&i.length&&(e=Object.assign(e,JSON.parse(i))),e},m=(t,e)=>{var s=U(t.value)
140
+ if(null!=s&&(s||i.allowEmptyOption)){if(g.hasOwnProperty(s)){if(e){var a=g[s][l]
141
+ a?Array.isArray(a)?a.push(e):g[s][l]=[a,e]:g[s][l]=e}}else{var c=v(t)
142
+ c[n]=c[n]||t.textContent,c[o]=c[o]||s,c[r]=c[r]||t.disabled,c[l]=c[l]||e,c.$option=t,g[s]=c,h.push(c)}t.selected&&y.items.push(s)}},y.maxItems=t.hasAttribute("multiple")?null:1,P(t.children,(t=>{var e,i,s
143
+ "optgroup"===(p=t.tagName.toLowerCase())?((s=v(e=t))[a]=s[a]||e.getAttribute("label")||"",s[c]=s[c]||f++,s[r]=s[r]||e.disabled,y.optgroups.push(s),i=s[c],P(e.children,(t=>{m(t,i)}))):"option"===p&&m(t)}))):(()=>{const e=t.getAttribute(s)
144
+ if(e)y.options=JSON.parse(e),P(y.options,(t=>{y.items.push(t[o])}))
145
+ else{var r=t.value.trim()||""
111
146
  if(!i.allowEmptyOption&&!r.length)return
112
- const t=r.split(i.delimiter)
113
- O(t,(e=>{const t={}
114
- t[n]=e,t[o]=e,y.options.push(t)})),y.items=t}})(),Object.assign({},q,y,t)}var W=0
115
- class X 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
+ const e=r.split(i.delimiter)
148
+ P(e,(t=>{const e={}
149
+ e[n]=t,e[o]=t,y.options.push(e)})),y.items=e}})(),Object.assign({},J,y,e)}var lt=0
150
+ class at extends(function(t){return t.plugins={},class extends t{constructor(...t){super(...t),this.plugins={names:[],settings:{},requested:{},loaded:{}}}static define(e,i){t.plugins[e]={name:e,fn:i}}initializePlugins(t){var e,i
116
151
  const s=this,n=[]
117
- if(Array.isArray(e))e.forEach((e=>{"string"==typeof e?n.push(e):(s.plugins.settings[e.name]=e.options,n.push(e.name))}))
118
- else if(e)for(t in e)e.hasOwnProperty(t)&&(s.plugins.settings[t]=e[t],n.push(t))
119
- for(;i=n.shift();)s.require(i)}loadPlugin(t){var i=this,s=i.plugins,n=e.plugins[t]
120
- if(!e.plugins.hasOwnProperty(t))throw new Error('Unable to find "'+t+'" plugin')
121
- 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
122
- if(!t.plugins.loaded.hasOwnProperty(e)){if(i.requested[e])throw new Error('Plugin has circular dependency ("'+e+'")')
123
- t.loadPlugin(e)}return i.loaded[e]}}}(t)){constructor(e,t){var i
124
- 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=[],W++
125
- var s=_(e)
152
+ if(Array.isArray(t))t.forEach((t=>{"string"==typeof t?n.push(t):(s.plugins.settings[t.name]=t.options,n.push(t.name))}))
153
+ else if(t)for(e in t)t.hasOwnProperty(e)&&(s.plugins.settings[e]=t[e],n.push(e))
154
+ for(;i=n.shift();)s.require(i)}loadPlugin(e){var i=this,s=i.plugins,n=t.plugins[e]
155
+ if(!t.plugins.hasOwnProperty(e))throw new Error('Unable to find "'+e+'" plugin')
156
+ s.requested[e]=!0,s.loaded[e]=n.fn.apply(i,[i.plugins.settings[e]||{}]),s.names.push(e)}require(t){var e=this,i=e.plugins
157
+ if(!e.plugins.loaded.hasOwnProperty(t)){if(i.requested[t])throw new Error('Plugin has circular dependency ("'+t+'")')
158
+ e.loadPlugin(t)}return i.loaded[t]}}}(e)){constructor(t,e){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=[],lt++
160
+ var s=T(t)
126
161
  if(s.tomselect)throw new Error("Tom Select already initialized on this element")
127
162
  s.tomselect=this,i=(window.getComputedStyle&&window.getComputedStyle(s,null)).getPropertyValue("direction")
128
- const n=U(s,t)
129
- 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=Q(s,"tomselect-"+W),this.isRequired=s.required,this.sifter=new w(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)
163
+ const n=rt(s,e)
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=st(s,"tomselect-"+lt),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)
130
165
  var o=n.createFilter
131
- "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()
132
- const r=_("<div>"),l=_("<div>"),a=this._render("dropdown"),c=_('<div role="listbox" tabindex="-1">'),d=this.input.getAttribute("class")||"",p=n.mode
133
- var u
134
- if(C(r,n.wrapperClass,d,p),C(l,n.controlClass),J(r,l),C(a,n.dropdownClass,p),n.copyClassesToDropdown&&C(a,d),C(c,n.dropdownContentClass),J(a,c),_(n.dropdownParent||r).appendChild(a),I(n.controlInput)){u=_(n.controlInput)
135
- O(["autocorrect","autocapitalize","autocomplete"],(e=>{s.getAttribute(e)&&T(u,{[e]:s.getAttribute(e)})})),u.tabIndex=-1,l.appendChild(u),this.focus_node=u}else n.controlInput?(u=_(n.controlInput),this.focus_node=u):(u=_("<input/>"),this.focus_node=l)
136
- this.wrapper=r,this.dropdown=a,this.dropdown_content=c,this.control=l,this.control_input=u,this.setup()}setup(){const e=this,t=e.settings,i=e.control_input,s=e.dropdown,n=e.dropdown_content,o=e.wrapper,r=e.control,l=e.input,a=e.focus_node,c={passive:!0},d=e.inputId+"-ts-dropdown"
137
- T(n,{id:d}),T(a,{role:"combobox","aria-haspopup":"listbox","aria-expanded":"false","aria-controls":d})
138
- const p=Q(a,e.inputId+"-ts-control"),u="label[for='"+(e=>e.replace(/['"\\]/g,"\\$&"))(e.inputId)+"']",h=document.querySelector(u),g=e.focus.bind(e)
139
- if(h){M(h,"click",g),T(h,{for:p})
140
- const t=Q(h,e.inputId+"-ts-label")
141
- T(a,{"aria-labelledby":t}),T(n,{"aria-labelledby":t})}if(o.style.width=l.style.width,e.plugins.names.length){const t="plugin-"+e.plugins.names.join(" plugin-")
142
- C([o,s],t)}(null===t.maxItems||t.maxItems>1)&&e.is_select_tag&&T(l,{multiple:"multiple"}),t.placeholder&&T(i,{placeholder:t.placeholder}),!t.splitOn&&t.delimiter&&(t.splitOn=new RegExp("\\s*"+f(t.delimiter)+"+\\s*")),t.load&&t.loadThrottle&&(t.load=R(t.load,t.loadThrottle)),e.control_input.type=l.type,M(s,"mouseenter",(t=>{var i=L(t.target,"[data-selectable]",s)
143
- i&&e.onOptionHover(t,i)}),{capture:!0}),M(s,"click",(t=>{const i=L(t.target,"[data-selectable]")
144
- i&&(e.onOptionSelect(t,i),z(t,!0))})),M(r,"click",(t=>{var s=L(t.target,"[data-ts-item]",r)
145
- s&&e.onItemSelect(t,s)?z(t,!0):""==i.value&&(e.onClick(),z(t,!0))})),M(a,"keydown",(t=>e.onKeyDown(t))),M(i,"keypress",(t=>e.onKeyPress(t))),M(i,"input",(t=>e.onInput(t))),M(a,"resize",(()=>e.positionDropdown()),c),M(a,"blur",(t=>e.onBlur(t))),M(a,"focus",(t=>e.onFocus(t))),M(i,"paste",(t=>e.onPaste(t)))
146
- const v=t=>{const n=t.composedPath()[0]
147
- if(!o.contains(n)&&!s.contains(n))return e.isFocused&&e.blur(),void e.inputState()
148
- n==i&&e.isOpen?t.stopPropagation():z(t,!0)},m=()=>{e.isOpen&&e.positionDropdown()},y=()=>{e.ignoreHover=!1}
149
- M(document,"mousedown",v),M(window,"scroll",m,c),M(window,"resize",m,c),M(window,"mousemove",y,c),this._destroy=()=>{document.removeEventListener("mousedown",v),window.removeEventListener("mousemove",y),window.removeEventListener("scroll",m),window.removeEventListener("resize",m),h&&h.removeEventListener("click",g)},this.revertSettings={innerHTML:l.innerHTML,tabIndex:l.tabIndex},l.tabIndex=-1,l.insertAdjacentElement("afterend",e.wrapper),e.sync(!1),t.items=[],delete t.optgroups,delete t.options,M(l,"invalid",(t=>{e.isValid&&(e.isValid=!1,e.isInvalid=!0,e.refreshState())})),e.updateOriginalInput(),e.refreshItems(),e.close(!1),e.inputState(),e.isSetup=!0,l.disabled?e.disable():e.enable(),e.on("change",this.onChange),C(l,"tomselected","ts-hidden-accessible"),e.trigger("initialize"),!0===t.preload&&e.preload()}setupOptions(e=[],t=[]){this.addOptions(e),O(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")
150
- 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>"}
151
- 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"}
152
- for(e in i)(t=this.settings[i[e]])&&this.on(e,t)}sync(e=!0){const t=this,i=e?U(t.input,{delimiter:t.settings.delimiter}):t.settings
153
- t.setupOptions(i.options,i.optgroups),t.setValue(i.items||[],!0),t.lastQuery=null}onClick(){var e=this
154
- if(e.activeItems.length>0)return e.clearActiveItems(),void e.focus()
155
- e.isFocused&&e.isOpen?e.blur():e.focus()}onMouseDown(){}onChange(){S(this.input,"input"),S(this.input,"change")}onPaste(e){var t=this
156
- t.isInputHidden||t.isLocked?z(e):t.settings.splitOn&&setTimeout((()=>{var e=t.inputValue()
157
- if(e.match(t.settings.splitOn)){var i=e.trim().split(t.settings.splitOn)
158
- O(i,(e=>{e=D(e),this.options[e]?t.addItem(e):t.createItem(e)}))}}),0)}onKeyPress(e){var t=this
159
- if(!t.isLocked){var i=String.fromCharCode(e.keyCode||e.which)
160
- return t.settings.create&&"multi"===t.settings.mode&&i===t.settings.delimiter?(t.createItem(),void z(e)):void 0}z(e)}onKeyDown(e){var t=this
161
- if(t.ignoreHover=!0,t.isLocked)9!==e.keyCode&&z(e)
162
- else{switch(e.keyCode){case 65:if(K($,e)&&""==t.control_input.value)return z(e),void t.selectAll()
166
+ "function"!=typeof o&&("string"==typeof o&&(o=new RegExp(o)),o instanceof RegExp?n.createFilter=t=>o.test(t):n.createFilter=t=>this.settings.duplicates||!this.options[t]),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
168
+ var p
169
+ if(q(r,n.wrapperClass,d,u),q(l,n.controlClass),ot(r,l),q(a,n.dropdownClass,u),n.copyClassesToDropdown&&q(a,d),q(c,n.dropdownContentClass),ot(a,c),T(n.dropdownParent||r).appendChild(a),j(n.controlInput)){p=T(n.controlInput)
170
+ k(["autocorrect","autocapitalize","autocomplete"],(t=>{s.getAttribute(t)&&z(p,{[t]:s.getAttribute(t)})})),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)
171
+ this.wrapper=r,this.dropdown=a,this.dropdown_content=c,this.control=l,this.control_input=p,this.setup()}setup(){const t=this,e=t.settings,i=t.control_input,s=t.dropdown,n=t.dropdown_content,o=t.wrapper,l=t.control,a=t.input,c=t.focus_node,d={passive:!0},u=t.inputId+"-ts-dropdown"
172
+ z(n,{id:u}),z(c,{role:"combobox","aria-haspopup":"listbox","aria-expanded":"false","aria-controls":u})
173
+ const p=st(c,t.inputId+"-ts-control"),h="label[for='"+(t=>t.replace(/['"\\]/g,"\\$&"))(t.inputId)+"']",g=document.querySelector(h),f=t.focus.bind(t)
174
+ if(g){et(g,"click",f),z(g,{for:p})
175
+ const e=st(g,t.inputId+"-ts-label")
176
+ z(c,{"aria-labelledby":e}),z(n,{"aria-labelledby":e})}if(o.style.width=a.style.width,t.plugins.names.length){const e="plugin-"+t.plugins.names.join(" plugin-")
177
+ q([o,s],e)}(null===e.maxItems||e.maxItems>1)&&t.is_select_tag&&z(a,{multiple:"multiple"}),e.placeholder&&z(i,{placeholder:e.placeholder}),!e.splitOn&&e.delimiter&&(e.splitOn=new RegExp("\\s*"+r(e.delimiter)+"+\\s*")),e.load&&e.loadThrottle&&(e.load=Y(e.load,e.loadThrottle)),t.control_input.type=a.type,et(s,"mousemove",(()=>{t.ignoreHover=!1})),et(s,"mouseenter",(e=>{var i=R(e.target,"[data-selectable]",s)
178
+ i&&t.onOptionHover(e,i)}),{capture:!0}),et(s,"click",(e=>{const i=R(e.target,"[data-selectable]")
179
+ i&&(t.onOptionSelect(e,i),tt(e,!0))})),et(l,"click",(e=>{var s=R(e.target,"[data-ts-item]",l)
180
+ s&&t.onItemSelect(e,s)?tt(e,!0):""==i.value&&(t.onClick(),tt(e,!0))})),et(c,"keydown",(e=>t.onKeyDown(e))),et(i,"keypress",(e=>t.onKeyPress(e))),et(i,"input",(e=>t.onInput(e))),et(c,"resize",(()=>t.positionDropdown()),d),et(c,"blur",(e=>t.onBlur(e))),et(c,"focus",(e=>t.onFocus(e))),et(i,"paste",(e=>t.onPaste(e)))
181
+ const v=e=>{const n=e.composedPath()[0]
182
+ if(!o.contains(n)&&!s.contains(n))return t.isFocused&&t.blur(),void t.inputState()
183
+ n==i&&t.isOpen?e.stopPropagation():tt(e,!0)},m=()=>{t.isOpen&&t.positionDropdown()}
184
+ et(document,"mousedown",v),et(window,"scroll",m,d),et(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",t.wrapper),t.sync(!1),e.items=[],delete e.optgroups,delete e.options,et(a,"invalid",(()=>{t.isValid&&(t.isValid=!1,t.isInvalid=!0,t.refreshState())})),t.updateOriginalInput(),t.refreshItems(),t.close(!1),t.inputState(),t.isSetup=!0,a.disabled?t.disable():t.enable(),t.on("change",this.onChange),q(a,"tomselected","ts-hidden-accessible"),t.trigger("initialize"),!0===e.preload&&t.preload()}setupOptions(t=[],e=[]){this.addOptions(t),k(e,(t=>{this.registerOptionGroup(t)}))}setupTemplates(){var t=this,e=t.settings.labelField,i=t.settings.optgroupLabelField,s={optgroup:t=>{let e=document.createElement("div")
185
+ return e.className="optgroup",e.appendChild(t.options),e},optgroup_header:(t,e)=>'<div class="optgroup-header">'+e(t[i])+"</div>",option:(t,i)=>"<div>"+i(t[e])+"</div>",item:(t,i)=>"<div>"+i(t[e])+"</div>",option_create:(t,e)=>'<div class="create">Add <strong>'+e(t.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
+ t.settings.render=Object.assign({},s,t.settings.render)}setupCallbacks(){var t,e,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(t in i)(e=this.settings[i[t]])&&this.on(t,e)}sync(t=!0){const e=this,i=t?rt(e.input,{delimiter:e.settings.delimiter}):e.settings
188
+ e.setupOptions(i.options,i.optgroups),e.setValue(i.items||[],!0),e.lastQuery=null}onClick(){var t=this
189
+ if(t.activeItems.length>0)return t.clearActiveItems(),void t.focus()
190
+ t.isFocused&&t.isOpen?t.blur():t.focus()}onMouseDown(){}onChange(){V(this.input,"input"),V(this.input,"change")}onPaste(t){var e=this
191
+ e.isInputHidden||e.isLocked?tt(t):e.settings.splitOn&&setTimeout((()=>{var t=e.inputValue()
192
+ if(t.match(e.settings.splitOn)){var i=t.trim().split(e.settings.splitOn)
193
+ k(i,(t=>{U(t)&&(this.options[t]?e.addItem(t):e.createItem(t))}))}}),0)}onKeyPress(t){var e=this
194
+ if(!e.isLocked){var i=String.fromCharCode(t.keyCode||t.which)
195
+ return e.settings.create&&"multi"===e.settings.mode&&i===e.settings.delimiter?(e.createItem(),void tt(t)):void 0}tt(t)}onKeyDown(t){var e=this
196
+ if(e.ignoreHover=!0,e.isLocked)9!==t.keyCode&&tt(t)
197
+ else{switch(t.keyCode){case 65:if(it(G,t)&&""==e.control_input.value)return tt(t),void e.selectAll()
163
198
  break
164
- case 27:return t.isOpen&&(z(e,!0),t.close()),void t.clearActiveItems()
165
- case 40:if(!t.isOpen&&t.hasOptions)t.open()
166
- else if(t.activeOption){let e=t.getAdjacent(t.activeOption,1)
167
- e&&t.setActiveOption(e)}return void z(e)
168
- case 38:if(t.activeOption){let e=t.getAdjacent(t.activeOption,-1)
169
- e&&t.setActiveOption(e)}return void z(e)
170
- case 13:return void(t.canSelect(t.activeOption)?(t.onOptionSelect(e,t.activeOption),z(e)):(t.settings.create&&t.createItem()||document.activeElement==t.control_input&&t.isOpen)&&z(e))
171
- case 37:return void t.advanceSelection(-1,e)
172
- case 39:return void t.advanceSelection(1,e)
173
- case 9:return void(t.settings.selectOnTab&&(t.canSelect(t.activeOption)&&(t.onOptionSelect(e,t.activeOption),z(e)),t.settings.create&&t.createItem()&&z(e)))
174
- case 8:case 46:return void t.deleteSelection(e)}t.isInputHidden&&!K($,e)&&z(e)}}onInput(e){var t=this
175
- if(!t.isLocked){var i=t.inputValue()
176
- 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
177
- if(t.isDisabled)return t.blur(),void z(e)
178
- 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
179
- if(t.isFocused){t.isFocused=!1,t.ignoreFocus=!1
180
- var i=()=>{t.close(),t.setActiveItem(),t.setCaret(t.items.length),t.trigger("blur")}
181
- t.settings.create&&t.settings.createOnBlur?t.createItem(null,!1,i):i()}}}onOptionSelect(e,t){var i,s=this
182
- 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&&/click/.test(e.type)&&s.setActiveOption(t)))}canSelect(e){return!!(this.isOpen&&e&&this.dropdown_content.contains(e))}onItemSelect(e,t){var i=this
183
- return!i.isLocked&&"multi"===i.settings.mode&&(z(e),i.setActiveItem(t,e),!0)}canLoad(e){return!!this.settings.load&&!this.loadedSearches.hasOwnProperty(e)}load(e){const t=this
184
- if(!t.canLoad(e))return
185
- C(t.wrapper,t.settings.loadingClass),t.loading++
186
- const i=t.loadCallback.bind(t)
187
- t.settings.load.call(t,e,i)}loadCallback(e,t){const i=this
188
- 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||x(i.wrapper,i.settings.loadingClass),i.trigger("load",e,t)}preload(){var e=this.wrapper.classList
189
- e.contains("preloaded")||(e.add("preloaded"),this.load(""))}setTextboxValue(e=""){var t=this.control_input
190
- t.value!==e&&(t.value=e,S(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){B(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
191
- if("single"!==a.settings.mode){if(!e)return a.clearActiveItems(),void(a.isFocused&&a.showInput())
192
- if("click"===(i=t&&t.type.toLowerCase())&&K("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)
193
- z(t)}else"click"===i&&K($,t)||"keydown"===i&&K("shiftKey",t)?e.classList.contains("active")?a.removeActiveItem(e):a.setActiveItemClass(e):(a.clearActiveItems(),a.setActiveItemClass(e))
194
- a.hideInput(),a.isFocused||a.focus()}}setActiveItemClass(e){const t=this,i=t.control.querySelector(".last-active")
195
- i&&x(i,"last-active"),C(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)
196
- this.activeItems.splice(t,1),x(e,"active")}clearActiveItems(){x(this.activeItems,"active"),this.activeItems=[]}setActiveOption(e,t=!0){e!==this.activeOption&&(this.clearActiveOption(),e&&(this.activeOption=e,T(this.focus_node,{"aria-activedescendant":e.getAttribute("id")}),T(e,{"aria-selected":"true"}),C(e,"active"),t&&this.scrollToOption(e)))}scrollToOption(e,t){if(!e)return
197
- const i=this.dropdown_content,s=i.clientHeight,n=i.scrollTop||0,o=e.offsetHeight,r=e.getBoundingClientRect().top-i.getBoundingClientRect().top+n
198
- r+o>s+n?this.scroll(r-s+o,t):r<n&&this.scroll(r,t)}scroll(e,t){const i=this.dropdown_content
199
- t&&(i.style.scrollBehavior=t),i.scrollTop=e,i.style.scrollBehavior=""}clearActiveOption(){this.activeOption&&(x(this.activeOption,"active"),T(this.activeOption,{"aria-selected":null})),this.activeOption=null,T(this.focus_node,{"aria-activedescendant":null})}selectAll(){const e=this
200
- if("single"===e.settings.mode)return
201
- const t=e.controlChildren()
202
- t.length&&(e.hideInput(),e.close(),e.activeItems=t,O(t,(t=>{e.setActiveItemClass(t)})))}inputState(){var e=this
203
- e.control.contains(e.control_input)&&(T(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&&T(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
204
- 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
205
- 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,n=this,o=this.getSearchOptions()
206
- if(n.settings.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')
207
- 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),n.settings.hideSelected)for(t=i.items.length-1;t>=0;t--){let e=D(i.items[t].id)
208
- e&&-1!==n.items.indexOf(e)&&i.items.splice(t,1)}return i}refreshOptions(e=!0){var t,i,s,n,o,r,l,a,c,d,p
209
- const u={},h=[]
210
- var g,v=this,m=v.inputValue(),f=v.search(m),y=null,b=v.settings.shouldOpen||!1,w=v.dropdown_content
211
- for(v.activeOption&&(c=v.activeOption.dataset.value,d=v.activeOption.closest("[data-group]")),n=f.items.length,"number"==typeof v.settings.maxOptions&&(n=Math.min(n,v.settings.maxOptions)),n>0&&(b=!0),t=0;t<n;t++){let e=f.items[t].id,n=v.options[e],l=v.getOption(e,!0)
212
- for(v.settings.hideSelected||l.classList.toggle("selected",v.items.includes(e)),o=n[v.settings.optgroupField]||"",i=0,s=(r=Array.isArray(o)?o:[o])&&r.length;i<s;i++)o=r[i],v.optgroups.hasOwnProperty(o)||(o=""),u.hasOwnProperty(o)||(u[o]=document.createDocumentFragment(),h.push(o)),i>0&&(l=l.cloneNode(!0),T(l,{id:n.$id+"-clone-"+i,"aria-selected":null}),l.classList.add("ts-cloned"),x(l,"active")),y||c!=e||(d?d.dataset.group===o&&(y=l):y=l),u[o].appendChild(l)}this.settings.lockOptgroupOrder&&h.sort(((e,t)=>(v.optgroups[e]&&v.optgroups[e].$order||0)-(v.optgroups[t]&&v.optgroups[t].$order||0))),l=document.createDocumentFragment(),O(h,(e=>{if(v.optgroups.hasOwnProperty(e)&&u[e].children.length){let t=document.createDocumentFragment(),i=v.render("optgroup_header",v.optgroups[e])
213
- J(t,i),J(t,u[e])
214
- let s=v.render("optgroup",{group:v.optgroups[e],options:t})
215
- J(l,s)}else J(l,u[e])})),w.innerHTML="",J(w,l),v.settings.highlight&&(g=w.querySelectorAll("span.highlight"),Array.prototype.forEach.call(g,(function(e){var t=e.parentNode
216
- t.replaceChild(e.firstChild,e),t.normalize()})),f.query.length&&f.tokens.length&&O(f.tokens,(e=>{V(w,e.regex)})))
217
- var _=e=>{let t=v.render(e,{input:m})
218
- return t&&(b=!0,w.insertBefore(t,w.firstChild)),t}
219
- if(v.loading?_("loading"):v.settings.shouldLoad.call(v,m)?0===f.items.length&&_("no_results"):_("not_loading"),(a=v.canCreate(m))&&(p=_("option_create")),v.hasOptions=f.items.length>0||a,b){if(f.items.length>0){if(!y&&"single"===v.settings.mode&&v.items.length&&(y=v.getOption(v.items[0])),!w.contains(y)){let e=0
220
- p&&!v.settings.addPrecedence&&(e=1),y=v.selectable()[e]}}else p&&(y=p)
221
- e&&!v.isOpen&&(v.open(),v.scrollToOption(y,"auto")),v.setActiveOption(y)}else v.clearActiveOption(),e&&v.isOpen&&v.close(!1)}selectable(){return this.dropdown_content.querySelectorAll("[data-selectable]")}addOption(e,t=!1){const i=this
222
- if(Array.isArray(e))return i.addOptions(e,t),!1
223
- const s=D(e[i.settings.valueField])
224
- 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){O(e,(e=>{this.addOption(e,t)}))}registerOption(e){return this.addOption(e)}registerOptionGroup(e){var t=D(e[this.settings.optgroupValueField])
225
- return null!==t&&(e.$order=e.$order||++this.order,this.optgroups[t]=e,t)}addOptionGroup(e,t){var i
226
- 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
199
+ case 27:return e.isOpen&&(tt(t,!0),e.close()),void e.clearActiveItems()
200
+ case 40:if(!e.isOpen&&e.hasOptions)e.open()
201
+ else if(e.activeOption){let t=e.getAdjacent(e.activeOption,1)
202
+ t&&e.setActiveOption(t)}return void tt(t)
203
+ case 38:if(e.activeOption){let t=e.getAdjacent(e.activeOption,-1)
204
+ t&&e.setActiveOption(t)}return void tt(t)
205
+ case 13:return void(e.canSelect(e.activeOption)?(e.onOptionSelect(t,e.activeOption),tt(t)):(e.settings.create&&e.createItem()||document.activeElement==e.control_input&&e.isOpen)&&tt(t))
206
+ case 37:return void e.advanceSelection(-1,t)
207
+ case 39:return void e.advanceSelection(1,t)
208
+ case 9:return void(e.settings.selectOnTab&&(e.canSelect(e.activeOption)&&(e.onOptionSelect(t,e.activeOption),tt(t)),e.settings.create&&e.createItem()&&tt(t)))
209
+ case 8:case 46:return void e.deleteSelection(t)}e.isInputHidden&&!it(G,t)&&tt(t)}}onInput(t){var e=this
210
+ if(!e.isLocked){var i=e.inputValue()
211
+ e.lastValue!==i&&(e.lastValue=i,e.settings.shouldLoad.call(e,i)&&e.load(i),e.refreshOptions(),e.trigger("type",i))}}onOptionHover(t,e){this.ignoreHover||this.setActiveOption(e,!1)}onFocus(t){var e=this,i=e.isFocused
212
+ if(e.isDisabled)return e.blur(),void tt(t)
213
+ e.ignoreFocus||(e.isFocused=!0,"focus"===e.settings.preload&&e.preload(),i||e.trigger("focus"),e.activeItems.length||(e.showInput(),e.refreshOptions(!!e.settings.openOnFocus)),e.refreshState())}onBlur(t){if(!1!==document.hasFocus()){var e=this
214
+ if(e.isFocused){e.isFocused=!1,e.ignoreFocus=!1
215
+ var i=()=>{e.close(),e.setActiveItem(),e.setCaret(e.items.length),e.trigger("blur")}
216
+ e.settings.create&&e.settings.createOnBlur?e.createItem(null,i):i()}}}onOptionSelect(t,e){var i,s=this
217
+ e.parentElement&&e.parentElement.matches("[data-disabled]")||(e.classList.contains("create")?s.createItem(null,(()=>{s.settings.closeAfterSelect&&s.close()})):void 0!==(i=e.dataset.value)&&(s.lastQuery=null,s.addItem(i),s.settings.closeAfterSelect&&s.close(),!s.settings.hideSelected&&t.type&&/click/.test(t.type)&&s.setActiveOption(e)))}canSelect(t){return!!(this.isOpen&&t&&this.dropdown_content.contains(t))}onItemSelect(t,e){var i=this
218
+ return!i.isLocked&&"multi"===i.settings.mode&&(tt(t),i.setActiveItem(e,t),!0)}canLoad(t){return!!this.settings.load&&!this.loadedSearches.hasOwnProperty(t)}load(t){const e=this
219
+ if(!e.canLoad(t))return
220
+ q(e.wrapper,e.settings.loadingClass),e.loading++
221
+ const i=e.loadCallback.bind(e)
222
+ e.settings.load.call(e,t,i)}loadCallback(t,e){const i=this
223
+ i.loading=Math.max(i.loading-1,0),i.lastQuery=null,i.clearActiveOption(),i.setupOptions(t,e),i.refreshOptions(i.isFocused&&!i.isInputHidden),i.loading||D(i.wrapper,i.settings.loadingClass),i.trigger("load",t,e)}preload(){var t=this.wrapper.classList
224
+ t.contains("preloaded")||(t.add("preloaded"),this.load(""))}setTextboxValue(t=""){var e=this.control_input
225
+ e.value!==t&&(e.value=t,V(e,"update"),this.lastValue=t)}getValue(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}setValue(t,e){Z(this,e?[]:["change"],(()=>{this.clear(e),this.addItems(t,e)}))}setMaxItems(t){0===t&&(t=null),this.settings.maxItems=t,this.refreshState()}setActiveItem(t,e){var i,s,n,o,r,l,a=this
226
+ if("single"!==a.settings.mode){if(!t)return a.clearActiveItems(),void(a.isFocused&&a.showInput())
227
+ if("click"===(i=e&&e.type.toLowerCase())&&it("shiftKey",e)&&a.activeItems.length){for(l=a.getLastActive(),(n=Array.prototype.indexOf.call(a.control.children,l))>(o=Array.prototype.indexOf.call(a.control.children,t))&&(r=n,n=o,o=r),s=n;s<=o;s++)t=a.control.children[s],-1===a.activeItems.indexOf(t)&&a.setActiveItemClass(t)
228
+ tt(e)}else"click"===i&&it(G,e)||"keydown"===i&&it("shiftKey",e)?t.classList.contains("active")?a.removeActiveItem(t):a.setActiveItemClass(t):(a.clearActiveItems(),a.setActiveItemClass(t))
229
+ a.hideInput(),a.isFocused||a.focus()}}setActiveItemClass(t){const e=this,i=e.control.querySelector(".last-active")
230
+ i&&D(i,"last-active"),q(t,"active last-active"),e.trigger("item_select",t),-1==e.activeItems.indexOf(t)&&e.activeItems.push(t)}removeActiveItem(t){var e=this.activeItems.indexOf(t)
231
+ this.activeItems.splice(e,1),D(t,"active")}clearActiveItems(){D(this.activeItems,"active"),this.activeItems=[]}setActiveOption(t,e=!0){t!==this.activeOption&&(this.clearActiveOption(),t&&(this.activeOption=t,z(this.focus_node,{"aria-activedescendant":t.getAttribute("id")}),z(t,{"aria-selected":"true"}),q(t,"active"),e&&this.scrollToOption(t)))}scrollToOption(t,e){if(!t)return
232
+ const i=this.dropdown_content,s=i.clientHeight,n=i.scrollTop||0,o=t.offsetHeight,r=t.getBoundingClientRect().top-i.getBoundingClientRect().top+n
233
+ r+o>s+n?this.scroll(r-s+o,e):r<n&&this.scroll(r,e)}scroll(t,e){const i=this.dropdown_content
234
+ e&&(i.style.scrollBehavior=e),i.scrollTop=t,i.style.scrollBehavior=""}clearActiveOption(){this.activeOption&&(D(this.activeOption,"active"),z(this.activeOption,{"aria-selected":null})),this.activeOption=null,z(this.focus_node,{"aria-activedescendant":null})}selectAll(){const t=this
235
+ if("single"===t.settings.mode)return
236
+ const e=t.controlChildren()
237
+ e.length&&(t.hideInput(),t.close(),t.activeItems=e,k(e,(e=>{t.setActiveItemClass(e)})))}inputState(){var t=this
238
+ t.control.contains(t.control_input)&&(z(t.control_input,{placeholder:t.settings.placeholder}),t.activeItems.length>0||!t.isFocused&&t.settings.hidePlaceholder&&t.items.length>0?(t.setTextboxValue(),t.isInputHidden=!0):(t.settings.hidePlaceholder&&t.items.length>0&&z(t.control_input,{placeholder:""}),t.isInputHidden=!1),t.wrapper.classList.toggle("input-hidden",t.isInputHidden))}hideInput(){this.inputState()}showInput(){this.inputState()}inputValue(){return this.control_input.value.trim()}focus(){var t=this
239
+ t.isDisabled||(t.ignoreFocus=!0,t.control_input.offsetWidth?t.control_input.focus():t.focus_node.focus(),setTimeout((()=>{t.ignoreFocus=!1,t.onFocus()}),0))}blur(){this.focus_node.blur(),this.onBlur()}getScoreFunction(t){return this.sifter.getScoreFunction(t,this.getSearchOptions())}getSearchOptions(){var t=this.settings,e=t.sortField
240
+ return"string"==typeof t.sortField&&(e=[{field:t.sortField}]),{fields:t.searchField,conjunction:t.searchConjunction,sort:e,nesting:t.nesting}}search(t){var e,i,s=this,n=this.getSearchOptions()
241
+ if(s.settings.score&&"function"!=typeof(i=s.settings.score.call(s,t)))throw new Error('Tom Select "score" setting must be a function that returns a function')
242
+ return t!==s.lastQuery?(s.lastQuery=t,e=s.sifter.search(t,Object.assign(n,{score:i})),s.currentResults=e):e=Object.assign({},s.currentResults),s.settings.hideSelected&&(e.items=e.items.filter((t=>{let e=U(t.id)
243
+ return!(e&&-1!==s.items.indexOf(e))}))),e}refreshOptions(t=!0){var e,i,s,n,o,r,l,a,c,d
244
+ const u={},p=[]
245
+ var h=this,g=h.inputValue()
246
+ const f=g===h.lastQuery||""==g&&null==h.lastQuery
247
+ var v,m=h.search(g),y=null,O=h.settings.shouldOpen||!1,b=h.dropdown_content
248
+ for(f&&(y=h.activeOption)&&(c=y.closest("[data-group]")),n=m.items.length,"number"==typeof h.settings.maxOptions&&(n=Math.min(n,h.settings.maxOptions)),n>0&&(O=!0),e=0;e<n;e++){let t=m.items[e]
249
+ if(!t)continue
250
+ let n=t.id,l=h.options[n]
251
+ if(void 0===l)continue
252
+ let a=W(n),d=h.getOption(a,!0)
253
+ 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
+ let t=u[o]
255
+ void 0===t&&(t=document.createDocumentFragment(),p.push(o)),i>0&&(d=d.cloneNode(!0),z(d,{id:l.$id+"-clone-"+i,"aria-selected":null}),d.classList.add("ts-cloned"),D(d,"active"),h.activeOption&&h.activeOption.dataset.value==n&&c&&c.dataset.group===o.toString()&&(y=d)),t.appendChild(d),u[o]=t}}h.settings.lockOptgroupOrder&&p.sort(((t,e)=>{const i=h.optgroups[t],s=h.optgroups[e]
256
+ return(i&&i.$order||0)-(s&&s.$order||0)})),l=document.createDocumentFragment(),k(p,(t=>{let e=u[t]
257
+ if(!e||!e.children.length)return
258
+ let i=h.optgroups[t]
259
+ if(void 0!==i){let t=document.createDocumentFragment(),s=h.render("optgroup_header",i)
260
+ ot(t,s),ot(t,e)
261
+ let n=h.render("optgroup",{group:i,options:t})
262
+ ot(l,n)}else ot(l,e)})),b.innerHTML="",ot(b,l),h.settings.highlight&&(v=b.querySelectorAll("span.highlight"),Array.prototype.forEach.call(v,(function(t){var e=t.parentNode
263
+ e.replaceChild(t.firstChild,t),e.normalize()})),m.query.length&&m.tokens.length&&k(m.tokens,(t=>{Q(b,t.regex)})))
264
+ var w=t=>{let e=h.render(t,{input:g})
265
+ return e&&(O=!0,b.insertBefore(e,b.firstChild)),e}
266
+ 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,O){if(m.items.length>0){if(y||"single"!==h.settings.mode||null==h.items[0]||(y=h.getOption(h.items[0])),!b.contains(y)){let t=0
267
+ d&&!h.settings.addPrecedence&&(t=1),y=h.selectable()[t]}}else d&&(y=d)
268
+ t&&!h.isOpen&&(h.open(),h.scrollToOption(y,"auto")),h.setActiveOption(y)}else h.clearActiveOption(),t&&h.isOpen&&h.close(!1)}selectable(){return this.dropdown_content.querySelectorAll("[data-selectable]")}addOption(t,e=!1){const i=this
269
+ if(Array.isArray(t))return i.addOptions(t,e),!1
270
+ const s=U(t[i.settings.valueField])
271
+ return null!==s&&!i.options.hasOwnProperty(s)&&(t.$order=t.$order||++i.order,t.$id=i.inputId+"-opt-"+t.$order,i.options[s]=t,i.lastQuery=null,e&&(i.userOptions[s]=e,i.trigger("option_add",s,t)),s)}addOptions(t,e=!1){k(t,(t=>{this.addOption(t,e)}))}registerOption(t){return this.addOption(t)}registerOptionGroup(t){var e=U(t[this.settings.optgroupValueField])
272
+ return null!==e&&(t.$order=t.$order||++this.order,this.optgroups[e]=t,e)}addOptionGroup(t,e){var i
273
+ e[this.settings.optgroupValueField]=t,(i=this.registerOptionGroup(e))&&this.trigger("optgroup_add",i,e)}removeOptionGroup(t){this.optgroups.hasOwnProperty(t)&&(delete this.optgroups[t],this.clearCache(),this.trigger("optgroup_remove",t))}clearOptionGroups(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")}updateOption(t,e){const i=this
227
274
  var s,n
228
- const o=D(e),r=D(t[i.settings.valueField])
275
+ const o=U(t),r=U(e[i.settings.valueField])
229
276
  if(null===o)return
230
- if(!i.options.hasOwnProperty(o))return
277
+ const l=i.options[o]
278
+ if(null==l)return
231
279
  if("string"!=typeof r)throw new Error("Value must be set in option data")
232
- const l=i.getOption(o),a=i.getItem(o)
233
- if(t.$order=t.$order||i.options[o].$order,delete i.options[o],i.uncacheValue(r),i.options[r]=t,l){if(i.dropdown_content.contains(l)){const e=i._render("option",t)
234
- j(l,e),i.activeOption===l&&i.setActiveOption(e)}l.remove()}a&&(-1!==(n=i.items.indexOf(o))&&i.items.splice(n,1,r),s=i._render("item",t),a.classList.contains("active")&&C(s,"active"),j(a,s)),i.lastQuery=null}removeOption(e,t){const i=this
235
- e=N(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)
280
+ const a=i.getOption(o),c=i.getItem(o)
281
+ if(e.$order=e.$order||l.$order,delete i.options[o],i.uncacheValue(r),i.options[r]=e,a){if(i.dropdown_content.contains(a)){const t=i._render("option",e)
282
+ K(a,t),i.activeOption===a&&i.setActiveOption(t)}a.remove()}c&&(-1!==(n=i.items.indexOf(o))&&i.items.splice(n,1,r),s=i._render("item",e),c.classList.contains("active")&&q(s,"active"),K(c,s)),i.lastQuery=null}removeOption(t,e){const i=this
283
+ t=W(t),i.uncacheValue(t),delete i.userOptions[t],delete i.options[t],i.lastQuery=null,i.trigger("option_remove",t),i.removeItem(t,e)}clearOptions(t){const e=(t||this.clearFilter).bind(this)
236
284
  this.loadedSearches={},this.userOptions={},this.clearCache()
237
285
  const i={}
238
- O(this.options,((e,s)=>{t(e,s)&&(i[s]=this.options[s])})),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=D(e)
239
- if(null!==i&&this.options.hasOwnProperty(i)){const e=this.options[i]
240
- if(e.$div)return e.$div
241
- if(t)return this._render("option",e)}return null}getAdjacent(e,t,i="option"){var s
242
- if(!e)return null
286
+ k(this.options,((t,s)=>{e(t,s)&&(i[s]=t)})),this.options=this.sifter.items=i,this.lastQuery=null,this.trigger("option_clear")}clearFilter(t,e){return this.items.indexOf(e)>=0}getOption(t,e=!1){const i=U(t)
287
+ if(null===i)return null
288
+ const s=this.options[i]
289
+ if(null!=s){if(s.$div)return s.$div
290
+ if(e)return this._render("option",s)}return null}getAdjacent(t,e,i="option"){var s
291
+ if(!t)return null
243
292
  s="item"==i?this.controlChildren():this.dropdown_content.querySelectorAll("[data-selectable]")
244
- for(let i=0;i<s.length;i++)if(s[i]==e)return t>0?s[i+1]:s[i-1]
245
- return null}getItem(e){if("object"==typeof e)return e
246
- var t=D(e)
247
- return null!==t?this.control.querySelector(`[data-value="${G(t)}"]`):null}addItems(e,t){var i=this,s=Array.isArray(e)?e:[e]
248
- for(let e=0,n=(s=s.filter((e=>-1===i.items.indexOf(e)))).length;e<n;e++)i.isPending=e<n-1,i.addItem(s[e],t)}addItem(e,t){B(this,t?[]:["change","dropdown_close"],(()=>{var i,s
249
- const n=this,o=n.settings.mode,r=D(e)
250
- 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)
251
- 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
252
- if(!(e=i.getItem(e)))return
293
+ for(let i=0;i<s.length;i++)if(s[i]==t)return e>0?s[i+1]:s[i-1]
294
+ return null}getItem(t){if("object"==typeof t)return t
295
+ var e=U(t)
296
+ return null!==e?this.control.querySelector(`[data-value="${nt(e)}"]`):null}addItems(t,e){var i=this,s=Array.isArray(t)?t:[t]
297
+ const n=(s=s.filter((t=>-1===i.items.indexOf(t))))[s.length-1]
298
+ s.forEach((t=>{i.isPending=t!==n,i.addItem(t,e)}))}addItem(t,e){Z(this,e?[]:["change","dropdown_close"],(()=>{var i,s
299
+ const n=this,o=n.settings.mode,r=U(t)
300
+ 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(e),"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 t=n.getOption(r),e=n.getAdjacent(t,1)
301
+ e&&n.setActiveOption(e)}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:e})}(!n.isPending||!s&&n.isFull())&&(n.inputState(),n.refreshState())}}))}removeItem(t=null,e){const i=this
302
+ if(!(t=i.getItem(t)))return
253
303
  var s,n
254
- const o=e.dataset.value
255
- s=E(e),e.remove(),e.classList.contains("active")&&(n=i.activeItems.indexOf(e),i.activeItems.splice(n,1),x(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=!0,i=(()=>{})){var s,n=this,o=n.caretPos
256
- if(e=e||n.inputValue(),!n.canCreate(e))return i(),!1
257
- n.lock()
258
- var r=!1,l=e=>{if(n.unlock(),!e||"object"!=typeof e)return i()
259
- var t=D(e[n.settings.valueField])
260
- if("string"!=typeof t)return i()
261
- n.setTextboxValue(),n.addOption(e,!0),n.setCaret(o),n.addItem(t),i(e),r=!0}
262
- 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
263
- e.lastQuery=null,e.isSetup&&e.addItems(e.items),e.updateOriginalInput(),e.refreshState()}refreshState(){const e=this
264
- e.refreshValidityState()
265
- const t=e.isFull(),i=e.isLocked
266
- e.wrapper.classList.toggle("rtl",e.rtl)
267
- const s=e.wrapper.classList
304
+ const o=t.dataset.value
305
+ s=B(t),t.remove(),t.classList.contains("active")&&(n=i.activeItems.indexOf(t),i.activeItems.splice(n,1),D(t,"active")),i.items.splice(s,1),i.lastQuery=null,!i.settings.persist&&i.userOptions.hasOwnProperty(o)&&i.removeOption(o,e),s<i.caretPos&&i.setCaret(i.caretPos-1),i.updateOriginalInput({silent:e}),i.refreshState(),i.positionDropdown(),i.trigger("item_remove",o,t)}createItem(t=null,e=(()=>{})){3===arguments.length&&(e=arguments[2]),"function"!=typeof e&&(e=()=>{})
306
+ var i,s=this,n=s.caretPos
307
+ if(t=t||s.inputValue(),!s.canCreate(t))return e(),!1
308
+ s.lock()
309
+ var o=!1,r=t=>{if(s.unlock(),!t||"object"!=typeof t)return e()
310
+ var i=U(t[s.settings.valueField])
311
+ if("string"!=typeof i)return e()
312
+ s.setTextboxValue(),s.addOption(t,!0),s.setCaret(n),s.addItem(i),e(t),o=!0}
313
+ return i="function"==typeof s.settings.create?s.settings.create.call(this,t,r):{[s.settings.labelField]:t,[s.settings.valueField]:t},o||r(i),!0}refreshItems(){var t=this
314
+ t.lastQuery=null,t.isSetup&&t.addItems(t.items),t.updateOriginalInput(),t.refreshState()}refreshState(){const t=this
315
+ t.refreshValidityState()
316
+ const e=t.isFull(),i=t.isLocked
317
+ t.wrapper.classList.toggle("rtl",t.rtl)
318
+ const s=t.wrapper.classList
268
319
  var n
269
- s.toggle("focus",e.isFocused),s.toggle("disabled",e.isDisabled),s.toggle("required",e.isRequired),s.toggle("invalid",!e.isValid),s.toggle("locked",i),s.toggle("full",t),s.toggle("input-active",e.isFocused&&!e.isInputHidden),s.toggle("dropdown-active",e.isOpen),s.toggle("has-options",(n=e.options,0===Object.keys(n).length)),s.toggle("has-items",e.items.length>0)}refreshValidityState(){var e=this
270
- e.input.validity&&(e.isValid=e.input.validity.valid,e.isInvalid=!e.isValid)}isFull(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems}updateOriginalInput(e={}){const t=this
320
+ s.toggle("focus",t.isFocused),s.toggle("disabled",t.isDisabled),s.toggle("required",t.isRequired),s.toggle("invalid",!t.isValid),s.toggle("locked",i),s.toggle("full",e),s.toggle("input-active",t.isFocused&&!t.isInputHidden),s.toggle("dropdown-active",t.isOpen),s.toggle("has-options",(n=t.options,0===Object.keys(n).length)),s.toggle("has-items",t.items.length>0)}refreshValidityState(){var t=this
321
+ t.input.validity&&(t.isValid=t.input.validity.valid,t.isInvalid=!t.isValid)}isFull(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems}updateOriginalInput(t={}){const e=this
271
322
  var i,s
272
- const n=t.input.querySelector('option[value=""]')
273
- if(t.is_select_tag){const e=[],r=t.input.querySelectorAll("option:checked").length
274
- function o(i,s,o){return i||(i=_('<option value="'+H(s)+'">'+H(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="${G(n)}"]:not(:checked)`),n,s)}else i.$option=o(i.$option,n,s)}))}else t.input.value=t.getValue()
275
- t.isSetup&&(e.silent||t.trigger("change",t.getValue()))}open(){var e=this
276
- e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.isOpen=!0,T(e.focus_node,{"aria-expanded":"true"}),e.refreshState(),A(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),A(e.dropdown,{visibility:"visible",display:"block"}),e.focus(),e.trigger("dropdown_open",e.dropdown))}close(e=!0){var t=this,i=t.isOpen
277
- e&&(t.setTextboxValue(),"single"===t.settings.mode&&t.items.length&&t.hideInput()),t.isOpen=!1,T(t.focus_node,{"aria-expanded":"false"}),A(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
278
- A(this.dropdown,{width:t.width+"px",top:i+"px",left:s+"px"})}}clear(e){var t=this
279
- if(t.items.length){var i=t.controlChildren()
280
- O(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
281
- s.insertBefore(e,s.children[i]),t.setCaret(i+1)}deleteSelection(e){var t,i,s,n,o,r=this
282
- t=e&&8===e.keyCode?-1:1,i={start:(o=r.control_input).selectionStart||0,length:(o.selectionEnd||0)-(o.selectionStart||0)}
323
+ const n=e.input.querySelector('option[value=""]')
324
+ if(e.is_select_tag){const t=[],r=e.input.querySelectorAll("option:checked").length
325
+ function o(i,s,o){return i||(i=T('<option value="'+X(s)+'">'+X(o)+"</option>")),i!=n&&e.input.append(i),t.push(i),(i!=n||r>0)&&(i.selected=!0),i}e.input.querySelectorAll("option:checked").forEach((t=>{t.selected=!1})),0==e.items.length&&"single"==e.settings.mode?o(n,"",""):e.items.forEach((n=>{if(i=e.options[n],s=i[e.settings.labelField]||"",t.includes(i.$option)){o(e.input.querySelector(`option[value="${nt(n)}"]:not(:checked)`),n,s)}else i.$option=o(i.$option,n,s)}))}else e.input.value=e.getValue()
326
+ e.isSetup&&(t.silent||e.trigger("change",e.getValue()))}open(){var t=this
327
+ t.isLocked||t.isOpen||"multi"===t.settings.mode&&t.isFull()||(t.isOpen=!0,z(t.focus_node,{"aria-expanded":"true"}),t.refreshState(),$(t.dropdown,{visibility:"hidden",display:"block"}),t.positionDropdown(),$(t.dropdown,{visibility:"visible",display:"block"}),t.focus(),t.trigger("dropdown_open",t.dropdown))}close(t=!0){var e=this,i=e.isOpen
328
+ t&&(e.setTextboxValue(),"single"===e.settings.mode&&e.items.length&&e.hideInput()),e.isOpen=!1,z(e.focus_node,{"aria-expanded":"false"}),$(e.dropdown,{display:"none"}),e.settings.hideSelected&&e.clearActiveOption(),e.refreshState(),i&&e.trigger("dropdown_close",e.dropdown)}positionDropdown(){if("body"===this.settings.dropdownParent){var t=this.control,e=t.getBoundingClientRect(),i=t.offsetHeight+e.top+window.scrollY,s=e.left+window.scrollX
329
+ $(this.dropdown,{width:e.width+"px",top:i+"px",left:s+"px"})}}clear(t){var e=this
330
+ if(e.items.length){var i=e.controlChildren()
331
+ k(i,(t=>{e.removeItem(t,!0)})),e.showInput(),t||e.updateOriginalInput(),e.trigger("clear")}}insertAtCaret(t){const e=this,i=e.caretPos,s=e.control
332
+ s.insertBefore(t,s.children[i]||null),e.setCaret(i+1)}deleteSelection(t){var e,i,s,n,o,r=this
333
+ e=t&&8===t.keyCode?-1:1,i={start:(o=r.control_input).selectionStart||0,length:(o.selectionEnd||0)-(o.selectionStart||0)}
283
334
  const l=[]
284
- if(r.activeItems.length)n=P(r.activeItems,t),s=E(n),t>0&&s++,O(r.activeItems,(e=>l.push(e)))
285
- else if((r.isFocused||"single"===r.settings.mode)&&r.items.length){const e=r.controlChildren()
286
- t<0&&0===i.start&&0===i.length?l.push(e[r.caretPos-1]):t>0&&i.start===r.inputValue().length&&l.push(e[r.caretPos])}if(!r.shouldDelete(l,e))return!1
287
- for(z(e,!0),void 0!==s&&r.setCaret(s);l.length;)r.removeItem(l.pop())
288
- return r.showInput(),r.positionDropdown(),r.refreshOptions(!1),!0}shouldDelete(e,t){const i=e.map((e=>e.dataset.value))
289
- return!(!i.length||"function"==typeof this.settings.onDelete&&!1===this.settings.onDelete(i,t))}advanceSelection(e,t){var i,s,n=this
290
- n.rtl&&(e*=-1),n.inputValue().length||(K($,t)||K("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")
291
- if(t)return t
335
+ if(r.activeItems.length)n=M(r.activeItems,e),s=B(n),e>0&&s++,k(r.activeItems,(t=>l.push(t)))
336
+ else if((r.isFocused||"single"===r.settings.mode)&&r.items.length){const t=r.controlChildren()
337
+ let s
338
+ e<0&&0===i.start&&0===i.length?s=t[r.caretPos-1]:e>0&&i.start===r.inputValue().length&&(s=t[r.caretPos]),void 0!==s&&l.push(s)}if(!r.shouldDelete(l,t))return!1
339
+ for(tt(t,!0),void 0!==s&&r.setCaret(s);l.length;)r.removeItem(l.pop())
340
+ return r.showInput(),r.positionDropdown(),r.refreshOptions(!1),!0}shouldDelete(t,e){const i=t.map((t=>t.dataset.value))
341
+ return!(!i.length||"function"==typeof this.settings.onDelete&&!1===this.settings.onDelete(i,e))}advanceSelection(t,e){var i,s,n=this
342
+ n.rtl&&(t*=-1),n.inputValue().length||(it(G,e)||it("shiftKey",e)?(s=(i=n.getLastActive(t))?i.classList.contains("active")?n.getAdjacent(i,t,"item"):i:t>0?n.control_input.nextElementSibling:n.control_input.previousElementSibling)&&(s.classList.contains("active")&&n.removeActiveItem(i),n.setActiveItemClass(s)):n.moveCaret(t))}moveCaret(t){}getLastActive(t){let e=this.control.querySelector(".last-active")
343
+ if(e)return e
292
344
  var i=this.control.querySelectorAll(".active")
293
- return i?P(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
294
- 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
295
- 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
296
- e.trigger("destroy"),e.off(),e.wrapper.remove(),e.dropdown.remove(),e.input.innerHTML=t.innerHTML,e.input.tabIndex=t.tabIndex,x(e.input,"tomselected","ts-hidden-accessible"),e._destroy(),delete e.input.tomselect}render(e,t){return"function"!=typeof this.settings.render[e]?null:this._render(e,t)}_render(e,t){var i,s,n=""
297
- const o=this
298
- return"option"!==e&&"item"!=e||(n=N(t[o.settings.valueField])),null==(s=o.settings.render[e].call(this,t,H))||(s=_(s),"option"===e||"option_create"===e?t[o.settings.disabledField]?T(s,{"aria-disabled":"true"}):T(s,{"data-selectable":""}):"optgroup"===e&&(i=t.group[o.settings.optgroupValueField],T(s,{"data-group":i}),t.group[o.settings.disabledField]&&T(s,{"data-disabled":""})),"option"!==e&&"item"!==e||(T(s,{"data-value":n}),"item"===e?(C(s,o.settings.itemClass),T(s,{"data-ts-item":""})):(C(s,o.settings.optionClass),T(s,{role:"option",id:t.$id}),o.options[n].$div=s))),s}clearCache(){O(this.options,((e,t)=>{e.$div&&(e.$div.remove(),delete e.$div)}))}uncacheValue(e){const t=this.getOption(e)
299
- 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]
300
- s[t]=function(){var t,o
301
- 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 X.define("caret_position",(function(){var e=this
302
- 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
303
- const i=e.getLastActive(t)
304
- if(i){const s=E(i)
305
- e.setCaret(t>0?s+1:s),e.setActiveItem(),x(i,"last-active")}else e.setCaret(e.caretPos+t)}))})),X.define("dropdown_input",(function(){const e=this
306
- e.settings.shouldOpen=!0,e.hook("before","setup",(()=>{e.focus_node=e.control,C(e.control_input,"dropdown-input")
307
- const t=_('<div class="dropdown-input-wrap">')
308
- t.append(e.control_input),e.dropdown.insertBefore(t,e.dropdown.firstChild)
309
- const i=_('<input class="items-placeholder" tabindex="-1" />')
310
- 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&&(z(t,!0),e.close()),void e.clearActiveItems()
311
- 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()}))
312
- const t=e.onBlur
313
- e.hook("instead","onBlur",(i=>{if(!i||i.relatedTarget!=e.control_input)return t.call(e)})),M(e.control_input,"blur",(()=>e.onBlur())),e.hook("before","close",(()=>{e.isOpen&&e.focus_node.focus({preventScroll:!0})}))}))})),X.define("no_backspace_delete",(function(){var e=this,t=e.deleteSelection
314
- this.hook("instead","deleteSelection",(i=>!!e.activeItems.length&&t.call(e,i)))})),X.define("remove_button",(function(e){const t=Object.assign({label:"&times;",title:"Remove",className:"remove",append:!0},e)
345
+ return i?M(i,t):void 0}setCaret(t){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 t=this
346
+ t.input.disabled=!0,t.control_input.disabled=!0,t.focus_node.tabIndex=-1,t.isDisabled=!0,this.close(),t.lock()}enable(){var t=this
347
+ t.input.disabled=!1,t.control_input.disabled=!1,t.focus_node.tabIndex=t.tabIndex,t.isDisabled=!1,t.unlock()}destroy(){var t=this,e=t.revertSettings
348
+ t.trigger("destroy"),t.off(),t.wrapper.remove(),t.dropdown.remove(),t.input.innerHTML=e.innerHTML,t.input.tabIndex=e.tabIndex,D(t.input,"tomselected","ts-hidden-accessible"),t._destroy(),delete t.input.tomselect}render(t,e){var i,s
349
+ const n=this
350
+ if("function"!=typeof this.settings.render[t])return null
351
+ if(null==(s=n.settings.render[t].call(this,e,X)))return s
352
+ if(s=T(s),"option"===t||"option_create"===t?e[n.settings.disabledField]?z(s,{"aria-disabled":"true"}):z(s,{"data-selectable":""}):"optgroup"===t&&(i=e.group[n.settings.optgroupValueField],z(s,{"data-group":i}),e.group[n.settings.disabledField]&&z(s,{"data-disabled":""})),"option"===t||"item"===t){const i=W(e[n.settings.valueField])
353
+ z(s,{"data-value":i}),"item"===t?(q(s,n.settings.itemClass),z(s,{"data-ts-item":""})):(q(s,n.settings.optionClass),z(s,{role:"option",id:e.$id}),e.$div=s,n.options[i]=e)}return s}_render(t,e){const i=this.render(t,e)
354
+ if(null==i)throw"HTMLElement expected"
355
+ return i}clearCache(){k(this.options,(t=>{t.$div&&(t.$div.remove(),delete t.$div)}))}uncacheValue(t){const e=this.getOption(t)
356
+ e&&e.remove()}canCreate(t){return this.settings.create&&t.length>0&&this.settings.createFilter.call(this,t)}hook(t,e,i){var s=this,n=s[e]
357
+ s[e]=function(){var e,o
358
+ return"after"===t&&(e=n.apply(s,arguments)),o=i.apply(s,arguments),"instead"===t?o:("before"===t&&(e=n.apply(s,arguments)),e)}}}return at.define("caret_position",(function(){var t=this
359
+ t.hook("instead","setCaret",(e=>{"single"!==t.settings.mode&&t.control.contains(t.control_input)?(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)})):e=t.items.length,t.caretPos=e})),t.hook("instead","moveCaret",(e=>{if(!t.isFocused)return
360
+ const i=t.getLastActive(e)
361
+ if(i){const s=B(i)
362
+ t.setCaret(e>0?s+1:s),t.setActiveItem(),D(i,"last-active")}else t.setCaret(t.caretPos+e)}))})),at.define("dropdown_input",(function(){const t=this
363
+ t.settings.shouldOpen=!0,t.hook("before","setup",(()=>{t.focus_node=t.control,q(t.control_input,"dropdown-input")
364
+ const e=T('<div class="dropdown-input-wrap">')
365
+ e.append(t.control_input),t.dropdown.insertBefore(e,t.dropdown.firstChild)
366
+ const i=T('<input class="items-placeholder" tabindex="-1" />')
367
+ i.placeholder=t.settings.placeholder||"",t.control.append(i)})),t.on("initialize",(()=>{t.control_input.addEventListener("keydown",(e=>{switch(e.keyCode){case 27:return t.isOpen&&(tt(e,!0),t.close()),void t.clearActiveItems()
368
+ case 9:t.focus_node.tabIndex=-1}return t.onKeyDown.call(t,e)})),t.on("blur",(()=>{t.focus_node.tabIndex=t.isDisabled?-1:t.tabIndex})),t.on("dropdown_open",(()=>{t.control_input.focus()}))
369
+ const e=t.onBlur
370
+ t.hook("instead","onBlur",(i=>{if(!i||i.relatedTarget!=t.control_input)return e.call(t)})),et(t.control_input,"blur",(()=>t.onBlur())),t.hook("before","close",(()=>{t.isOpen&&t.focus_node.focus({preventScroll:!0})}))}))})),at.define("no_backspace_delete",(function(){var t=this,e=t.deleteSelection
371
+ this.hook("instead","deleteSelection",(i=>!!t.activeItems.length&&e.call(t,i)))})),at.define("remove_button",(function(t){const e=Object.assign({label:"&times;",title:"Remove",className:"remove",append:!0},t)
315
372
  var i=this
316
- if(t.append){var s='<a href="javascript:void(0)" class="'+t.className+'" tabindex="-1" title="'+H(t.title)+'">'+t.label+"</a>"
317
- i.hook("after","setupTemplates",(()=>{var e=i.settings.render.item
318
- i.settings.render.item=(t,n)=>{var o=_(e.call(i,t,n)),r=_(s)
319
- return o.appendChild(r),M(r,"mousedown",(e=>{z(e,!0)})),M(r,"click",(e=>{z(e,!0),i.isLocked||i.shouldDelete([o],e)&&(i.removeItem(o),i.refreshOptions(!1),i.inputState())})),o}}))}})),X.define("restore_on_backspace",(function(e){const t=this,i=Object.assign({text:e=>e[t.settings.labelField]},e)
320
- t.on("item_remove",(function(e){if(t.isFocused&&""===t.control_input.value.trim()){var s=t.options[e]
321
- s&&t.setTextboxValue(i.text.call(t,s))}}))})),X}))
322
- var tomSelect=function(e,t){return new TomSelect(e,t)}
373
+ if(e.append){var s='<a href="javascript:void(0)" class="'+e.className+'" tabindex="-1" title="'+X(e.title)+'">'+e.label+"</a>"
374
+ i.hook("after","setupTemplates",(()=>{var t=i.settings.render.item
375
+ i.settings.render.item=(e,n)=>{var o=T(t.call(i,e,n)),r=T(s)
376
+ return o.appendChild(r),et(r,"mousedown",(t=>{tt(t,!0)})),et(r,"click",(t=>{tt(t,!0),i.isLocked||i.shouldDelete([o],t)&&(i.removeItem(o),i.refreshOptions(!1),i.inputState())})),o}}))}})),at.define("restore_on_backspace",(function(t){const e=this,i=Object.assign({text:t=>t[e.settings.labelField]},t)
377
+ e.on("item_remove",(function(t){if(e.isFocused&&""===e.control_input.value.trim()){var s=e.options[t]
378
+ s&&e.setTextboxValue(i.text.call(e,s))}}))})),at}))
379
+ var tomSelect=function(t,e){return new TomSelect(t,e)}
323
380
  //# sourceMappingURL=tom-select.popular.min.js.map