bitboss-ui 0.2.44 → 0.2.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/dist/index101.js +2 -2
  2. package/dist/index103.js +2 -2
  3. package/dist/index109.js +1 -1
  4. package/dist/index11.js +2 -2
  5. package/dist/index111.js +4 -4
  6. package/dist/index113.js +1 -1
  7. package/dist/index116.js +1 -1
  8. package/dist/index117.js +1 -1
  9. package/dist/index118.js +1 -1
  10. package/dist/index119.js +1 -1
  11. package/dist/index125.js +1 -1
  12. package/dist/index126.js +1 -1
  13. package/dist/index131.js +2 -2
  14. package/dist/index15.js +7 -7
  15. package/dist/index17.js +8 -8
  16. package/dist/index19.js +3 -3
  17. package/dist/index197.js +235 -3
  18. package/dist/index197.js.map +1 -1
  19. package/dist/index198.js +366 -33
  20. package/dist/index198.js.map +1 -1
  21. package/dist/index199.js +134 -6
  22. package/dist/index199.js.map +1 -1
  23. package/dist/index200.js +1 -1
  24. package/dist/index201.js +18 -15
  25. package/dist/index201.js.map +1 -1
  26. package/dist/index202.js +2 -16
  27. package/dist/index202.js.map +1 -1
  28. package/dist/index203.js +2 -19
  29. package/dist/index203.js.map +1 -1
  30. package/dist/index204.js +172 -18
  31. package/dist/index204.js.map +1 -1
  32. package/dist/index205.js +23 -29
  33. package/dist/index205.js.map +1 -1
  34. package/dist/index206.js +373 -8
  35. package/dist/index206.js.map +1 -1
  36. package/dist/index207.js +2 -2
  37. package/dist/index207.js.map +1 -1
  38. package/dist/index208.js +4 -2
  39. package/dist/index208.js.map +1 -1
  40. package/dist/index209.js +3 -2
  41. package/dist/index209.js.map +1 -1
  42. package/dist/index21.js +2 -2
  43. package/dist/index210.js +3 -2
  44. package/dist/index210.js.map +1 -1
  45. package/dist/index211.js +2 -368
  46. package/dist/index211.js.map +1 -1
  47. package/dist/index212.js +13 -131
  48. package/dist/index212.js.map +1 -1
  49. package/dist/index213.js +14 -172
  50. package/dist/index213.js.map +1 -1
  51. package/dist/index214.js +20 -23
  52. package/dist/index214.js.map +1 -1
  53. package/dist/index215.js +27 -371
  54. package/dist/index215.js.map +1 -1
  55. package/dist/index216.js +8 -235
  56. package/dist/index216.js.map +1 -1
  57. package/dist/index217.js +2 -4
  58. package/dist/index217.js.map +1 -1
  59. package/dist/index218.js +3 -10
  60. package/dist/index218.js.map +1 -1
  61. package/dist/index219.js +35 -2
  62. package/dist/index219.js.map +1 -1
  63. package/dist/index220.js +6 -3
  64. package/dist/index220.js.map +1 -1
  65. package/dist/index221.js +10 -3
  66. package/dist/index221.js.map +1 -1
  67. package/dist/index222.js +9 -6
  68. package/dist/index222.js.map +1 -1
  69. package/dist/index223.js +120 -16
  70. package/dist/index223.js.map +1 -1
  71. package/dist/index224.js +6 -9
  72. package/dist/index224.js.map +1 -1
  73. package/dist/index225.js +16 -120
  74. package/dist/index225.js.map +1 -1
  75. package/dist/index226.js +72 -428
  76. package/dist/index226.js.map +1 -1
  77. package/dist/index227.js +5 -88
  78. package/dist/index227.js.map +1 -1
  79. package/dist/index228.js +2 -200
  80. package/dist/index228.js.map +1 -1
  81. package/dist/index229.js +2 -2
  82. package/dist/index230.js +2 -6
  83. package/dist/index230.js.map +1 -1
  84. package/dist/index231.js +2 -2
  85. package/dist/index232.js +117 -2
  86. package/dist/index232.js.map +1 -1
  87. package/dist/index233.js +106 -2
  88. package/dist/index233.js.map +1 -1
  89. package/dist/index234.js +2 -2
  90. package/dist/index234.js.map +1 -1
  91. package/dist/index235.js +4 -2
  92. package/dist/index235.js.map +1 -1
  93. package/dist/index236.js +224 -2
  94. package/dist/index236.js.map +1 -1
  95. package/dist/index237.js +258 -2
  96. package/dist/index237.js.map +1 -1
  97. package/dist/index238.js +68 -116
  98. package/dist/index238.js.map +1 -1
  99. package/dist/index239.js +159 -105
  100. package/dist/index239.js.map +1 -1
  101. package/dist/index240.js +1 -81
  102. package/dist/index240.js.map +1 -1
  103. package/dist/index241.js +5 -69
  104. package/dist/index241.js.map +1 -1
  105. package/dist/index242.js +2 -160
  106. package/dist/index242.js.map +1 -1
  107. package/dist/index243.js +4 -1
  108. package/dist/index243.js.map +1 -1
  109. package/dist/index244.js +2 -5
  110. package/dist/index244.js.map +1 -1
  111. package/dist/index245.js +2 -2
  112. package/dist/index245.js.map +1 -1
  113. package/dist/index246.js +2 -4
  114. package/dist/index246.js.map +1 -1
  115. package/dist/index247.js +430 -219
  116. package/dist/index247.js.map +1 -1
  117. package/dist/index248.js +83 -252
  118. package/dist/index248.js.map +1 -1
  119. package/dist/index249.js +200 -2
  120. package/dist/index249.js.map +1 -1
  121. package/dist/index25.js +2 -2
  122. package/dist/index254.js +1 -1
  123. package/dist/index255.js +2 -2
  124. package/dist/index29.js +3 -3
  125. package/dist/index31.js +34 -34
  126. package/dist/index31.js.map +1 -1
  127. package/dist/index33.js +1 -1
  128. package/dist/index35.js +2 -2
  129. package/dist/index47.js +1 -1
  130. package/dist/index49.js +1 -1
  131. package/dist/index65.js +5 -5
  132. package/dist/index69.js +2 -2
  133. package/dist/index72.js +1 -1
  134. package/dist/index75.js +1 -1
  135. package/dist/index77.js +1 -1
  136. package/dist/index79.js +4 -4
  137. package/dist/style.css +1 -1
  138. package/package.json +1 -1
package/dist/index31.js CHANGED
@@ -1,30 +1,30 @@
1
- import { defineComponent as Ne, ref as v, computed as V, onMounted as $e, onBeforeUnmount as De, watch as X, openBlock as g, createElementBlock as h, normalizeClass as I, renderSlot as b, createElementVNode as O, Fragment as L, renderList as P, toDisplayString as F, createBlock as ie, withModifiers as B, withCtx as Le, createTextVNode as ee, createCommentVNode as se, withDirectives as Fe, vModelDynamic as Me, Teleport as Ae, normalizeStyle as qe, createVNode as Je, mergeProps as Re, nextTick as le } from "vue";
1
+ import { defineComponent as Ne, ref as v, computed as w, onMounted as $e, onBeforeUnmount as De, watch as X, openBlock as g, createElementBlock as h, normalizeClass as I, renderSlot as b, createElementVNode as V, Fragment as L, renderList as P, toDisplayString as F, createBlock as ie, withModifiers as B, withCtx as Le, createTextVNode as ee, createCommentVNode as se, withDirectives as Fe, vModelDynamic as Me, Teleport as Ae, normalizeStyle as qe, createVNode as Je, mergeProps as Re, nextTick as le } from "vue";
2
2
  import ze from "./index115.js";
3
3
  import "./index158.js";
4
4
  import He from "./index119.js";
5
5
  import "./index185.js";
6
- import { autoUpdate as Pe, computePosition as Ue, flip as je, shift as Qe } from "./index211.js";
6
+ import { autoUpdate as Pe, computePosition as Ue, flip as je, shift as Qe } from "./index198.js";
7
7
  import { deepEqual as re } from "./index123.js";
8
- import { head as te } from "./index219.js";
8
+ import { head as te } from "./index211.js";
9
9
  import { isNotNil as E } from "./index124.js";
10
- import { last as We } from "./index207.js";
10
+ import { last as We } from "./index203.js";
11
11
  import { useItemText as Ke } from "./index125.js";
12
12
  import { useItemValue as Ye } from "./index126.js";
13
13
  import { wait as J } from "./index122.js";
14
- import { when as Ze } from "./index217.js";
15
- import { offset as Ge } from "./index215.js";
14
+ import { when as Ze } from "./index208.js";
15
+ import { offset as Ge } from "./index206.js";
16
16
  const Xe = { class: "bb-base-select__input-container" }, el = ["id", "autocomplete", "autofocus", "disabled", "placeholder", "readonly"], ll = {
17
17
  key: 0,
18
18
  class: "bb-base-select__loading-container"
19
19
  }, tl = {
20
20
  key: 1,
21
21
  class: "bb-base-select__no-data-container"
22
- }, al = ["id", "aria-selected"], nl = { class: "bb-base-select-option__content" }, ol = { class: "bb-base-select-option__text" }, ul = { class: "bb-base-select__chevron" }, il = /* @__PURE__ */ O("svg", {
22
+ }, al = ["id", "aria-selected"], nl = { class: "bb-base-select-option__content" }, ol = { class: "bb-base-select-option__text" }, ul = { class: "bb-base-select__chevron" }, il = /* @__PURE__ */ V("svg", {
23
23
  fill: "none",
24
24
  viewBox: "0 0 16 8",
25
25
  xmlns: "http://www.w3.org/2000/svg"
26
26
  }, [
27
- /* @__PURE__ */ O("path", {
27
+ /* @__PURE__ */ V("path", {
28
28
  "clip-rule": "evenodd",
29
29
  d: "M0.851779 0.225802C0.90403 0.173418 0.966103 0.131858 1.03444 0.1035C1.10278 0.0751431 1.17604 0.0605469 1.25003 0.0605469C1.32402 0.0605469 1.39728 0.0751431 1.46562 0.1035C1.53396 0.131858 1.59603 0.173418 1.64828 0.225802L8.00003 6.57868L14.3518 0.225802C14.4041 0.173503 14.4662 0.132017 14.5345 0.103713C14.6028 0.0754093 14.6761 0.0608414 14.75 0.0608414C14.824 0.0608414 14.8972 0.0754093 14.9656 0.103713C15.0339 0.132017 15.096 0.173503 15.1483 0.225802C15.2006 0.278101 15.2421 0.340189 15.2704 0.408521C15.2987 0.476852 15.3132 0.55009 15.3132 0.624052C15.3132 0.698014 15.2987 0.771252 15.2704 0.839584C15.2421 0.907916 15.2006 0.970003 15.1483 1.0223L8.39828 7.7723C8.34603 7.82469 8.28395 7.86625 8.21562 7.8946C8.14728 7.92296 8.07402 7.93756 8.00003 7.93756C7.92604 7.93756 7.85278 7.92296 7.78444 7.8946C7.7161 7.86625 7.65403 7.82469 7.60178 7.7723L0.851779 1.0223C0.799395 0.970051 0.757835 0.907978 0.729477 0.83964C0.70112 0.771302 0.686523 0.69804 0.686523 0.624052C0.686523 0.550064 0.70112 0.476803 0.729477 0.408464C0.757835 0.340126 0.799395 0.278053 0.851779 0.225802Z",
30
30
  fill: "currentColor",
@@ -70,7 +70,7 @@ const Xe = { class: "bb-base-select__input-container" }, el = ["id", "autocomple
70
70
  const e = de, f = ce;
71
71
  if (e.multiple && !Array.isArray(e.modelValue))
72
72
  throw new Error('Multiple is set to "true" but modelValue is not an array.');
73
- const S = v(null), N = v(null), d = v(null), T = v(null), u = v(""), fe = V(() => s.value.length ? "" : e.placeholder), c = v(0), ve = e.transitionDuration / 1e3 + "s";
73
+ const S = v(null), N = v(null), d = v(null), T = v(null), u = v(""), fe = w(() => s.value.length ? "" : e.placeholder), c = v(0), ve = e.transitionDuration / 1e3 + "s";
74
74
  let ae;
75
75
  $e(async () => {
76
76
  e.debug && console.log("Calling onMounted"), N.value && d.value && (ae = Pe(
@@ -87,7 +87,7 @@ const Xe = { class: "bb-base-select__input-container" }, el = ["id", "autocomple
87
87
  }), De(() => {
88
88
  e.debug && console.log("Calling onBeforeUnMount"), ae();
89
89
  });
90
- const ne = v([]), m = v([]), C = v([]), { getItemText: me } = Ke(), { getItemValue: pe } = Ye(), ge = V(() => ne.value.map((l, a) => {
90
+ const ne = v([]), m = v([]), C = v([]), { getItemText: me } = Ke(), { getItemValue: pe } = Ye(), ge = w(() => ne.value.map((l, a) => {
91
91
  e.debug && console.log("Mapping items in internalOptions", { item: l });
92
92
  const t = me(l, e.itemText), n = pe(l, e.itemValue);
93
93
  if (n === void 0)
@@ -104,7 +104,7 @@ const Xe = { class: "bb-base-select__input-container" }, el = ["id", "autocomple
104
104
  text: t,
105
105
  value: n
106
106
  };
107
- })), y = V(() => {
107
+ })), y = w(() => {
108
108
  let l = ge.value.reduce(
109
109
  (n, o) => (n[o.id] = o, n),
110
110
  {}
@@ -127,7 +127,7 @@ const Xe = { class: "bb-base-select__input-container" }, el = ["id", "autocomple
127
127
  index: o
128
128
  })
129
129
  );
130
- }), w = V(() => {
130
+ }), O = w(() => {
131
131
  e.debug && console.log("Computing filtered options");
132
132
  let l = [];
133
133
  return u.value && !s.value.some(
@@ -151,7 +151,7 @@ const Xe = { class: "bb-base-select__input-container" }, el = ["id", "autocomple
151
151
  ...a,
152
152
  focused: _.value === t
153
153
  }));
154
- }), R = V(
154
+ }), R = w(
155
155
  () => y.value.reduce(
156
156
  (l, a) => ({
157
157
  ...l,
@@ -159,7 +159,7 @@ const Xe = { class: "bb-base-select__input-container" }, el = ["id", "autocomple
159
159
  }),
160
160
  {}
161
161
  )
162
- ), p = V(() => {
162
+ ), p = w(() => {
163
163
  if (e.debug && console.log("Computing optionsIndexedByValue"), e.matchStrategy === "string") {
164
164
  let l = y.value.reduce(
165
165
  (a, t) => (a[t.jsonValue] = t, a),
@@ -181,7 +181,7 @@ const Xe = { class: "bb-base-select__input-container" }, el = ["id", "autocomple
181
181
  };
182
182
  } else
183
183
  throw new Error("No match strategy has been defined");
184
- }), be = V(() => {
184
+ }), be = w(() => {
185
185
  if (e.debug && console.log("Computing modelValueIndexed"), e.matchStrategy === "string") {
186
186
  let l = {};
187
187
  return [].concat(e.modelValue).forEach((a, t) => {
@@ -199,7 +199,7 @@ const Xe = { class: "bb-base-select__input-container" }, el = ["id", "autocomple
199
199
  };
200
200
  } else
201
201
  throw new Error("No match strategy has been defined");
202
- }), s = V(() => (e.debug && console.log("Computing selectedOptions"), [].concat(e.modelValue).reduce((l, a) => {
202
+ }), s = w(() => (e.debug && console.log("Computing selectedOptions"), [].concat(e.modelValue).reduce((l, a) => {
203
203
  const t = p.value.get(a);
204
204
  return t && l.push(t), l;
205
205
  }, []))), M = (l) => {
@@ -345,7 +345,7 @@ const Xe = { class: "bb-base-select__input-container" }, el = ["id", "autocomple
345
345
  }
346
346
  }, Oe = (l) => f("change", l), Ce = (l) => {
347
347
  e.debug && console.log("Running onInputInput"), f("input", l), u.value === "" && (e.multiple || f("update:modelValue", null)), typeof e.items == "function" && Te();
348
- }, r = v(null), _ = V(() => Number.isInteger(r.value) && r.value ? (r.value === -1 && (r.value = w.value.length - 1), r.value % w.value.length) : r.value), i = v(null), ke = async () => {
348
+ }, r = v(null), _ = w(() => Number.isInteger(r.value) && r.value ? r.value % O.value.length : r.value), i = v(null), ke = async () => {
349
349
  var l;
350
350
  if (r.value !== null ? r.value = r.value % y.value.length : r.value = 0, await le(), _.value !== null) {
351
351
  const a = (l = d.value) == null ? void 0 : l.querySelector(
@@ -381,7 +381,7 @@ const Xe = { class: "bb-base-select__input-container" }, el = ["id", "autocomple
381
381
  if (l.preventDefault(), c.value)
382
382
  return;
383
383
  if (i.value = null, k.value) {
384
- if (!w.value.length)
384
+ if (!O.value.length)
385
385
  return;
386
386
  _e();
387
387
  } else
@@ -393,7 +393,7 @@ const Xe = { class: "bb-base-select__input-container" }, el = ["id", "autocomple
393
393
  if (l.preventDefault(), c.value)
394
394
  return;
395
395
  if (i.value = null, k.value) {
396
- if (!w.value.length)
396
+ if (!O.value.length)
397
397
  return;
398
398
  ke();
399
399
  } else
@@ -437,12 +437,12 @@ const Xe = { class: "bb-base-select__input-container" }, el = ["id", "autocomple
437
437
  if (l.preventDefault(), c.value)
438
438
  return;
439
439
  if (!k.value)
440
- w.value.length && s.value.length && (r.value = te(s.value).index), await D();
440
+ O.value.length && s.value.length && (r.value = te(s.value).index), await D();
441
441
  else if (_.value !== null) {
442
- if (w.value[_.value].disabled)
442
+ if (O.value[_.value].disabled)
443
443
  return;
444
444
  e.multiple || await A(), M(
445
- w.value[_.value]
445
+ O.value[_.value]
446
446
  );
447
447
  } else if (e.addOptions) {
448
448
  if (e.itemText || e.itemValue) {
@@ -511,7 +511,7 @@ const Xe = { class: "bb-base-select__input-container" }, el = ["id", "autocomple
511
511
  }, Be = Ze(
512
512
  (l) => typeof l != "string",
513
513
  JSON.stringify
514
- ), Ee = V(() => [].concat(e.modelValue).map((l) => {
514
+ ), Ee = w(() => [].concat(e.modelValue).map((l) => {
515
515
  const a = Be(l);
516
516
  return {
517
517
  disabled: e.disabled,
@@ -534,13 +534,13 @@ const Xe = { class: "bb-base-select__input-container" }, el = ["id", "autocomple
534
534
  onClick: xe
535
535
  }, [
536
536
  b(l.$slots, "prepend-outer"),
537
- O("span", {
537
+ V("span", {
538
538
  ref_key: "innerContainer",
539
539
  ref: N,
540
540
  class: "bb-base-select__inner-container"
541
541
  }, [
542
542
  b(l.$slots, "prepend"),
543
- O("span", Xe, [
543
+ V("span", Xe, [
544
544
  l.multiple ? (g(), h(L, { key: 0 }, [
545
545
  l.comma ? (g(!0), h(L, { key: 0 }, P(s.value, (t, n) => (g(), h("span", {
546
546
  key: t.id,
@@ -578,7 +578,7 @@ const Xe = { class: "bb-base-select__input-container" }, el = ["id", "autocomple
578
578
  _: 2
579
579
  }, 1032, ["class", "text", "onClick:clear"]))), 128))
580
580
  ], 64)) : se("", !0),
581
- Fe(O("input", {
581
+ Fe(V("input", {
582
582
  id: l.id,
583
583
  ref_key: "input",
584
584
  ref: T,
@@ -599,7 +599,7 @@ const Xe = { class: "bb-base-select__input-container" }, el = ["id", "autocomple
599
599
  [Me, u.value]
600
600
  ]),
601
601
  (g(), ie(Ae, { to: "body" }, [
602
- O("span", {
602
+ V("span", {
603
603
  ref_key: "optionsContainer",
604
604
  ref: d,
605
605
  class: I({
@@ -614,22 +614,22 @@ const Xe = { class: "bb-base-select__input-container" }, el = ["id", "autocomple
614
614
  tabindex: -1
615
615
  }, [
616
616
  b(l.$slots, "options:prepend"),
617
- !w.value.length && c.value ? (g(), h("span", ll, [
617
+ !O.value.length && c.value ? (g(), h("span", ll, [
618
618
  b(l.$slots, "loading", { query: u.value }, () => [
619
619
  ee(F(l.loadingText), 1)
620
620
  ])
621
- ])) : w.value.length ? se("", !0) : (g(), h("span", tl, [
621
+ ])) : O.value.length ? se("", !0) : (g(), h("span", tl, [
622
622
  b(l.$slots, "no-data", { query: u.value }, () => [
623
623
  ee(F(l.noDataText), 1)
624
624
  ])
625
625
  ])),
626
- (g(!0), h(L, null, P(w.value, (t) => (g(), h(L, {
626
+ (g(!0), h(L, null, P(O.value, (t) => (g(), h(L, {
627
627
  key: t.id
628
628
  }, [
629
629
  b(l.$slots, "option:prepend", {
630
630
  item: t.original
631
631
  }),
632
- O("span", {
632
+ V("span", {
633
633
  id: t.id,
634
634
  "aria-selected": t.selected,
635
635
  class: I({
@@ -653,8 +653,8 @@ const Xe = { class: "bb-base-select__input-container" }, el = ["id", "autocomple
653
653
  text: t.text,
654
654
  value: t.value
655
655
  }, () => [
656
- O("span", nl, [
657
- O("span", ol, F(t.text), 1)
656
+ V("span", nl, [
657
+ V("span", ol, F(t.text), 1)
658
658
  ])
659
659
  ])
660
660
  ], 10, al),
@@ -666,7 +666,7 @@ const Xe = { class: "bb-base-select__input-container" }, el = ["id", "autocomple
666
666
  ], 6)
667
667
  ]))
668
668
  ]),
669
- O("span", ul, [
669
+ V("span", ul, [
670
670
  b(l.$slots, "chevron", {
671
671
  loading: !!c.value,
672
672
  shown: k.value
@@ -1 +1 @@
1
- {"version":3,"file":"index31.js","sources":["../src/components/BaseSelect/BaseSelect.vue"],"sourcesContent":["<template>\n\t<span\n\t\tref=\"outerContainer\"\n\t\t:class=\"{\n\t\t\t'bb-base-select': true,\n\t\t\t'bb-base-select--active': active,\n\t\t\t'bb-base-select--loading': loading,\n\t\t\t'bb-base-select--disabled': disabled,\n\t\t\t'bb-base-select--errors': hasErrors,\n\t\t\t'bb-base-select--readonly': readonly,\n\t\t}\"\n\t\t@click=\"onOuterContainerClick\"\n\t>\n\t\t<slot name=\"prepend-outer\"></slot>\n\t\t<span ref=\"innerContainer\" class=\"bb-base-select__inner-container\">\n\t\t\t<slot name=\"prepend\"></slot>\n\t\t\t<span class=\"bb-base-select__input-container\">\n\t\t\t\t<template v-if=\"multiple\">\n\t\t\t\t\t<template v-if=\"comma\">\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tv-for=\"(option, index) in selectedOptions\"\n\t\t\t\t\t\t\t:key=\"option.id\"\n\t\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t\t'bb-base-select__selected': true,\n\t\t\t\t\t\t\t\t'bb-base-select__selected--comma': true,\n\t\t\t\t\t\t\t\t'bb-base-select__selected--focused':\n\t\t\t\t\t\t\t\t\tindex === selectedOptionsFocusedIndex,\n\t\t\t\t\t\t\t}\"\n\t\t\t\t\t\t\t>{{ option.text\n\t\t\t\t\t\t\t}}{{ index < selectedOptions.length - 1 ? ',' : '' }}</span\n\t\t\t\t\t\t>\n\t\t\t\t\t</template>\n\t\t\t\t\t<template v-else>\n\t\t\t\t\t\t<BbChip\n\t\t\t\t\t\t\tv-for=\"(option, index) in selectedOptions\"\n\t\t\t\t\t\t\t:key=\"option.id\"\n\t\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t\t'bb-base-select__selected': true,\n\t\t\t\t\t\t\t\t'bb-base-select__selected--chip': true,\n\t\t\t\t\t\t\t\t'bb-base-select__selected--focused':\n\t\t\t\t\t\t\t\t\tindex === selectedOptionsFocusedIndex,\n\t\t\t\t\t\t\t}\"\n\t\t\t\t\t\t\t:clearable=\"true\"\n\t\t\t\t\t\t\t:text=\"option.text\"\n\t\t\t\t\t\t\t@click:clear.stop=\"onOptionSelected(option)\"\n\t\t\t\t\t\t\t><slot\n\t\t\t\t\t\t\t\t:disabled=\"option.disabled\"\n\t\t\t\t\t\t\t\t:has-errors=\"hasErrors\"\n\t\t\t\t\t\t\t\t:index=\"option.index\"\n\t\t\t\t\t\t\t\t:item=\"option.original\"\n\t\t\t\t\t\t\t\t:loading=\"!!loading\"\n\t\t\t\t\t\t\t\t:manual=\"option.manual\"\n\t\t\t\t\t\t\t\tname=\"chip\"\n\t\t\t\t\t\t\t\t:selected=\"option.selected\"\n\t\t\t\t\t\t\t\t:text=\"option.text\"\n\t\t\t\t\t\t\t\t:value=\"option.value\"\n\t\t\t\t\t\t\t\t>{{ option.text }}</slot\n\t\t\t\t\t\t\t></BbChip\n\t\t\t\t\t\t>\n\t\t\t\t\t</template>\n\t\t\t\t</template>\n\n\t\t\t\t<input\n\t\t\t\t\t:id=\"id\"\n\t\t\t\t\tref=\"input\"\n\t\t\t\t\tv-model=\"query\"\n\t\t\t\t\t:autocomplete=\"autocomplete\"\n\t\t\t\t\t:autofocus=\"autofocus\"\n\t\t\t\t\t:class=\"'bb-base-select__text-input'\"\n\t\t\t\t\t:disabled=\"disabled\"\n\t\t\t\t\t:placeholder=\"computedPlaceholder\"\n\t\t\t\t\t:readonly=\"readonly || !allowWriting\"\n\t\t\t\t\t:type=\"'text'\"\n\t\t\t\t\t@blur.stop=\"onInputBlur\"\n\t\t\t\t\t@change.stop=\"onInputChange\"\n\t\t\t\t\t@focus.stop=\"onInputFocus\"\n\t\t\t\t\t@input.stop=\"onInputInput\"\n\t\t\t\t\t@keydown.stop=\"onInputKeyDown\"\n\t\t\t\t/>\n\t\t\t\t<teleport to=\"body\">\n\t\t\t\t\t<span\n\t\t\t\t\t\tref=\"optionsContainer\"\n\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t'bb-base-select__options-container': true,\n\t\t\t\t\t\t\t'bb-base-select__options-container--shown': shown,\n\t\t\t\t\t\t\t'bb-base-select__options-container--showing': showing,\n\t\t\t\t\t\t\t'bb-base-select__options-container--hiding': hiding,\n\t\t\t\t\t\t\t'bb-base-select__options-container--hidden': hidden,\n\t\t\t\t\t\t}\"\n\t\t\t\t\t\t:role=\"'listbox'\"\n\t\t\t\t\t\t:style=\"{ transitionDuration }\"\n\t\t\t\t\t\t:tabindex=\"-1\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<slot name=\"options:prepend\"></slot>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tv-if=\"!filteredOptions.length && loading\"\n\t\t\t\t\t\t\tclass=\"bb-base-select__loading-container\"\n\t\t\t\t\t\t\t><slot :name=\"'loading'\" :query=\"query\">{{\n\t\t\t\t\t\t\t\tloadingText\n\t\t\t\t\t\t\t}}</slot></span\n\t\t\t\t\t\t>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tv-else-if=\"!filteredOptions.length\"\n\t\t\t\t\t\t\tclass=\"bb-base-select__no-data-container\"\n\t\t\t\t\t\t\t><slot :name=\"'no-data'\" :query=\"query\">{{\n\t\t\t\t\t\t\t\tnoDataText\n\t\t\t\t\t\t\t}}</slot></span\n\t\t\t\t\t\t>\n\t\t\t\t\t\t<template v-for=\"option in filteredOptions\" :key=\"option.id\">\n\t\t\t\t\t\t\t<slot :item=\"option.original\" name=\"option:prepend\"></slot>\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t:id=\"option.id\"\n\t\t\t\t\t\t\t\t:aria-selected=\"option.selected\"\n\t\t\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t\t\t'bb-base-select-option': true,\n\t\t\t\t\t\t\t\t\t'bb-base-select-option--selected': option.selected,\n\t\t\t\t\t\t\t\t\t'bb-base-select-option--focused': option.focused,\n\t\t\t\t\t\t\t\t\t'bb-base-select-option--disabled': option.disabled,\n\t\t\t\t\t\t\t\t}\"\n\t\t\t\t\t\t\t\t:role=\"'option'\"\n\t\t\t\t\t\t\t\t@click.stop=\"onOptionClicked\"\n\t\t\t\t\t\t\t\t><slot\n\t\t\t\t\t\t\t\t\t:disabled=\"option.disabled\"\n\t\t\t\t\t\t\t\t\t:focused=\"option.focused\"\n\t\t\t\t\t\t\t\t\t:has-errors=\"hasErrors\"\n\t\t\t\t\t\t\t\t\t:index=\"option.index\"\n\t\t\t\t\t\t\t\t\t:item=\"option.original\"\n\t\t\t\t\t\t\t\t\t:loading=\"!!loading\"\n\t\t\t\t\t\t\t\t\t:manual=\"option.manual\"\n\t\t\t\t\t\t\t\t\tname=\"option\"\n\t\t\t\t\t\t\t\t\t:selected=\"option.selected\"\n\t\t\t\t\t\t\t\t\t:text=\"option.text\"\n\t\t\t\t\t\t\t\t\t:value=\"option.value\"\n\t\t\t\t\t\t\t\t\t><span class=\"bb-base-select-option__content\"\n\t\t\t\t\t\t\t\t\t\t><span class=\"bb-base-select-option__text\">{{\n\t\t\t\t\t\t\t\t\t\t\toption.text\n\t\t\t\t\t\t\t\t\t\t}}</span></span\n\t\t\t\t\t\t\t\t\t></slot\n\t\t\t\t\t\t\t\t></span\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<slot :item=\"option.original\" name=\"option:append\"></slot>\n\t\t\t\t\t\t</template>\n\t\t\t\t\t\t<slot name=\"options:append\"></slot>\n\t\t\t\t\t</span>\n\t\t\t\t</teleport>\n\t\t\t</span>\n\t\t\t<span class=\"bb-base-select__chevron\">\n\t\t\t\t<slot :loading=\"!!loading\" name=\"chevron\" :shown=\"shown\">\n\t\t\t\t\t<svg\n\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\tviewBox=\"0 0 16 8\"\n\t\t\t\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<path\n\t\t\t\t\t\t\tclip-rule=\"evenodd\"\n\t\t\t\t\t\t\td=\"M0.851779 0.225802C0.90403 0.173418 0.966103 0.131858 1.03444 0.1035C1.10278 0.0751431 1.17604 0.0605469 1.25003 0.0605469C1.32402 0.0605469 1.39728 0.0751431 1.46562 0.1035C1.53396 0.131858 1.59603 0.173418 1.64828 0.225802L8.00003 6.57868L14.3518 0.225802C14.4041 0.173503 14.4662 0.132017 14.5345 0.103713C14.6028 0.0754093 14.6761 0.0608414 14.75 0.0608414C14.824 0.0608414 14.8972 0.0754093 14.9656 0.103713C15.0339 0.132017 15.096 0.173503 15.1483 0.225802C15.2006 0.278101 15.2421 0.340189 15.2704 0.408521C15.2987 0.476852 15.3132 0.55009 15.3132 0.624052C15.3132 0.698014 15.2987 0.771252 15.2704 0.839584C15.2421 0.907916 15.2006 0.970003 15.1483 1.0223L8.39828 7.7723C8.34603 7.82469 8.28395 7.86625 8.21562 7.8946C8.14728 7.92296 8.07402 7.93756 8.00003 7.93756C7.92604 7.93756 7.85278 7.92296 7.78444 7.8946C7.7161 7.86625 7.65403 7.82469 7.60178 7.7723L0.851779 1.0223C0.799395 0.970051 0.757835 0.907978 0.729477 0.83964C0.70112 0.771302 0.686523 0.69804 0.686523 0.624052C0.686523 0.550064 0.70112 0.476803 0.729477 0.408464C0.757835 0.340126 0.799395 0.278053 0.851779 0.225802Z\"\n\t\t\t\t\t\t\tfill=\"currentColor\"\n\t\t\t\t\t\t\tfill-rule=\"evenodd\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</svg>\n\t\t\t\t</slot>\n\t\t\t</span>\n\t\t\t<slot v-if=\"!loading\" name=\"append\"></slot>\n\t\t\t<span\n\t\t\t\tv-else\n\t\t\t\t:class=\"{\n\t\t\t\t\t'bb-base-select__spinner': true,\n\t\t\t\t\t'bb-base-select__spinner--loading': loading,\n\t\t\t\t}\"\n\t\t\t\t><slot :loading=\"!!loading\" :name=\"'spinner'\"\n\t\t\t\t\t><BbSpinner :size=\"'sm'\" /></slot\n\t\t\t></span>\n\t\t</span>\n\t\t<slot name=\"append-outer\"></slot>\n\t\t<input v-for=\"input in hiddenInputs\" :key=\"input.value\" v-bind=\"input\" />\n\t</span>\n</template>\n\n<script setup lang=\"ts\" generic=\"T = any\">\nimport BbChip from '../BbChip/BbChip.vue';\nimport BbSpinner from '../BbSpinner/BbSpinner.vue';\nimport {\n\tautoUpdate,\n\tcomputePosition,\n\tflip,\n\toffset,\n\tshift,\n} from '@floating-ui/dom';\nimport {\n\tcomputed,\n\tnextTick,\n\tonBeforeUnmount,\n\tonMounted,\n\tref,\n\twatch,\n} from 'vue';\nimport { deepEqual } from 'fast-equals';\nimport { head } from '@/utilities/functions/head';\nimport { isNotNil } from '@/utilities/functions/isNotNil';\nimport { last } from '@/utilities/functions/last';\nimport { useItemText } from '@/composables/useItemText';\nimport { useItemValue } from '@/composables/useItemValue';\nimport { wait } from '@/utilities/functions/wait';\nimport { waitFor } from '@/utilities/functions/waitFor';\nimport { when } from '@/utilities/functions/when';\nimport type { ComputedRef, HTMLAttributes, InputHTMLAttributes } from 'vue';\nimport type { NestedKeyOf } from '@/types/NestedKeyOf';\n\nexport type BaseSelectProps<T> = {\n\t/**\n\t * Allows typing into the input.\n\t */\n\tallowWriting?: boolean;\n\n\t/**\n\t * Guides to the browser as to the type of information expected in the field.\n\t */\n\tautocomplete?: InputHTMLAttributes['autocomplete'];\n\n\t/**\n\t * Sets autofocus on page load.\n\t */\n\tautofocus?: InputHTMLAttributes['autofocus'];\n\t/**\n\t * Logs messages for debugging purposes.\n\t */\n\tdebug?: boolean;\n\n\t/**\n\t * Defines an array of dependencies that will trigger actions in the component upon change.\n\t */\n\tdependencies?: any[];\n\n\t/**\n\t * Timeout used to debounce response to changes to dependencies.\n\t */\n\tdepsDebounceTime?: number;\n\n\t/**\n\t * Disables the component\n\t */\n\tdisabled?: boolean;\n\n\t/**\n\t * If coherence is enforce the input cannot have a modelValue the is incoherent with its current items.\n\t *\n\t * e.g. You cannot set v-model to a user that is not present in the items passed.\n\t *\n\t * modelValue will be reset upon incoherence.\n\t */\n\tenforceCoherence?: boolean;\n\n\t/**\n\t * Define if the component should be in an error state.\n\t * It usually attaches a CSS class for styling purposes.\n\t */\n\thasErrors?: boolean;\n\n\t/**\n\t * The identifier of the component.\n\t */\n\tid?: HTMLAttributes['id'];\n\n\t/**\n\t * String displayed while items are being loaded.\n\t */\n\tloadingText?: string;\n\n\t/**\n\t * Defines the strategy used to understand whether an option has been selected.\n\t * `string` is 40% faster but relies on property order.\n\t * `equality` is more reliable but is slower.\n\t */\n\tmatchStrategy?: 'string' | 'equality';\n\n\t/**\n\t * Timeout used to debounce response to changes to modelValue.\n\t */\n\tmodelValueDebounceTime?: number;\n\n\t/**\n\t * Allows the selection of multiple items.\n\t */\n\tmultiple?: boolean;\n\n\t/**\n\t * Defines the name of the input.\n\t */\n\tname?: InputHTMLAttributes['name'];\n\n\t/**\n\t * String displayed when there are no items to display.\n\t */\n\tnoDataText?: string;\n\n\t/**\n\t * String displayed when there's no data.\n\t */\n\tplaceholder?: InputHTMLAttributes['placeholder'];\n\n\t/**\n\t * Sets the input in a readonly state.\n\t */\n\treadonly?: InputHTMLAttributes['readonly'];\n\n\t/**\n\t * How long the transition has to last in milliseconds\n\t */\n\ttransitionDuration?: number;\n\t/**\n\t * Used to retrieve items can be an array or a function.\n\t */\n\titems:\n\t\t| T[]\n\t\t| ((query: string, prefill: boolean, modelValue: any) => Promise<T[]>)\n\t\t| ((query: string, prefill: boolean, modelValue: any) => T[]);\n\n\t/**\n\t * Defines a path that returns a property of the object to use as text or a function that returns a string\n\t */\n\titemText?: T extends object\n\t\t? NestedKeyOf<T> | ((item: T) => string)\n\t\t: ((item: T) => string) | undefined;\n\n\t/**\n\t * Defines a path that returns a property of the object to use as value or a function that returns any value\n\t */\n\titemValue?: T extends object\n\t\t? NestedKeyOf<T> | ((item: T) => string)\n\t\t: ((item: T) => any) | undefined;\n\t/**\n\t * Used by v-model. Can be any serializable type.\n\t */\n\tmodelValue: any;\n\n\t/**\n\t * Allows the user to add options to the list by\n\t * inserting text in the input and pressing ENTER.\n\t * The value and text of the option generated is a\n\t * string equal to what has been inserted.\n\t */\n\taddOptions?: boolean;\n\t/**\n\t * Sets the display model for selected values to a list\n\t * of comma separated string. In this mode the user\n\t * cannot deselect an option by pressing the close button.\n\t */\n\tcomma?: boolean;\n\t/**\n\t * Defines how the filtering should work.\n\t * In any case options are always filtered by the text displayed but\n\t * they can also take into account other properties of the\n\t * passed elements when this property is a string or an array of string.\n\t * E.g. items could be a list of users and you can filter users by email or phone by passing `['email', 'phone']`\n\t * You can also pass false to not filter anything or a function for more granular control.\n\t *\n\t */\n\tfilterBy?:\n\t\t| string\n\t\t| string[]\n\t\t| false\n\t\t| ((value: any, item: T) => boolean)\n\t\t| null;\n\t/**\n\t * Defines the prefill strategy for the input. By default the input will prefill\n\t * on focus. It can also always prefill with `true` and only prefill on search with `false`.\n\t */\n\tprefill?: boolean | 'focus';\n\t/**\n\t * Time to wait when the users stops writing in the input before querying data.\n\t * Especially useful when searching live data on big datasets.\n\t */\n\tqueryDebounceTime?: number;\n\t/**\n\t * If `true` when in multiple selection, reset the query immediately\n\t * upon selecting an option. By default the query is\n\t * not reset until focus is lost so the user can search\n\t * for \"Cath\" and select \"Cathy\" and then write more to\n\t * search for \"Catherine\"\n\t */\n\tresetQueryOnOptionSelected?: boolean;\n\t/**\n\t * Adds a stash to accumulate selected values. Especially\n\t * useful when searching in a big database of items.\n\t * E.g. if you search for \"John\" and then search for \"Richard\"\n\t * you either always return the previous items or you stash them passing `true` to this option.\n\t */\n\tstash?: boolean;\n\t/**\n\t * Pass `true` if the dropdown is not updating following movement in the UI, like in modals. Very expensive so use with care.\n\t */\n\tupdateOnAnimationFrame?: boolean;\n};\n\nexport type BaseOption<T> = {\n\tid: string;\n\tjsonValue: string;\n\tmanual: boolean;\n\toriginal: T;\n\ttext: string;\n\tvalue: any;\n\tdisabled: boolean;\n};\n\nexport type Option<T> = BaseOption<T> & {\n\tindex: number;\n\tselected: boolean;\n};\n\nexport type FilteredOption<T> = Option<T> & {\n\tfocused: boolean;\n};\n\nexport type BaseSelectEvents = {\n\t(e: 'blur', event: FocusEvent): void;\n\t(e: 'change', event: Event): void;\n\t(e: 'click', event: MouseEvent): void;\n\t(e: 'focus', event: FocusEvent): void;\n\t(e: 'inactive'): void;\n\t(e: 'input', event: Event): void;\n\t(e: 'update:modelValue', value: any): void;\n};\n\nexport type BaseSelectSlots<T> = {\n\t'prepend-outer'?: (props: {}) => any;\n\tprepend?: (props: {}) => any;\n\t'options:prepend'?: (props: {}) => any;\n\tloading?: (props: { query: string }) => any;\n\t'no-data'?: (props: { query: string }) => any;\n\t'option:prepend'?: (props: { item: T }) => any;\n\tchip?: (props: {\n\t\tdisabled: boolean;\n\t\thasErrors?: boolean;\n\t\tindex: number;\n\t\titem: T;\n\t\tloading: boolean;\n\t\tmanual: boolean;\n\t\tselected: boolean;\n\t\ttext: string;\n\t\tvalue: any;\n\t}) => any;\n\toption?: (props: {\n\t\tdisabled: boolean;\n\t\tfocused: boolean;\n\t\thasErrors?: boolean;\n\t\tindex: number;\n\t\titem: T;\n\t\tloading: boolean;\n\t\tmanual: boolean;\n\t\tselected: boolean;\n\t\ttext: string;\n\t\tvalue: any;\n\t}) => any;\n\t'option:append'?: (props: { item: T }) => any;\n\t'options:append'?: (props: {}) => any;\n\tchevron?: (props: { loading: boolean; shown: boolean }) => any;\n\tappend?: (props: {}) => any;\n\tspinner?: (props: { loading: boolean }) => any;\n\t'append-outer'?: (props: {}) => any;\n};\n\nconst props = withDefaults(defineProps<BaseSelectProps<T>>(), {\n\tallowWriting: true,\n\tdepsDebounceTime: 0,\n\tfilterBy: () => [],\n\tloadingText: 'Caricamento...',\n\tmatchStrategy: 'string',\n\tmodelValueDebounceTime: 0,\n\tnoDataText: 'Nessun elemento da visualizzare',\n\tprefill: 'focus',\n\tqueryDebounceTime: 500,\n\ttransitionDuration: 200,\n\tupdateOnAnimationFrame: false,\n});\n\nconst emit = defineEmits<BaseSelectEvents>();\n\ndefineSlots<BaseSelectSlots<T>>();\n\nif (props.multiple && !Array.isArray(props.modelValue)) {\n\tthrow new Error('Multiple is set to \"true\" but modelValue is not an array.');\n}\n\nconst outerContainer = ref<HTMLElement | null>(null);\nconst innerContainer = ref<HTMLElement | null>(null);\nconst optionsContainer = ref<HTMLElement | null>(null);\nconst input = ref<HTMLElement | null>(null);\nconst query = ref<string>('');\nconst computedPlaceholder = computed(() => {\n\tif (selectedOptions.value.length) return '';\n\telse return props.placeholder;\n});\n/**\n * Use a number accumulator because if the fn takes 5 seconds\n * and after 2 seconds another search is run\n * When the first returns the second is still out for 2 seconds\n * and we want to track them both.\n * Debounce will not be enough.\n */\nconst loading = ref(0);\nconst transitionDuration = props.transitionDuration / 1000 + 's';\nlet cleanUpPositioning: () => void;\n\nonMounted(async () => {\n\tif (props.debug) console.log('Calling onMounted');\n\n\tif (innerContainer.value && optionsContainer.value) {\n\t\tcleanUpPositioning = autoUpdate(\n\t\t\tinnerContainer.value,\n\t\t\toptionsContainer.value,\n\t\t\tdisplayOptions,\n\t\t\t{\n\t\t\t\tancestorResize: true,\n\t\t\t\tancestorScroll: true,\n\t\t\t\tanimationFrame: props.updateOnAnimationFrame,\n\t\t\t\telementResize: true,\n\t\t\t}\n\t\t);\n\t}\n});\nonBeforeUnmount(() => {\n\tif (props.debug) console.log('Calling onBeforeUnMount');\n\tcleanUpPositioning();\n});\n\nconst internalItems = ref<T[]>([]);\nconst stash = ref<BaseOption<T>[]>([]);\nconst manualItems = ref<BaseOption<T>[]>([]);\nconst { getItemText } = useItemText();\nconst { getItemValue } = useItemValue();\n\nconst internalOptions = computed<BaseOption<T>[]>(() => {\n\treturn internalItems.value.map((item: any, _) => {\n\t\tif (props.debug) console.log('Mapping items in internalOptions', { item });\n\t\tconst text = getItemText(item, props.itemText as any);\n\t\tconst value = getItemValue(item, props.itemValue);\n\n\t\t// Undefined is not JSONable\n\t\tif (value === undefined)\n\t\t\tthrow new Error(\n\t\t\t\t'The result of extracting \"value\" from option was undefined. Affected item is ' +\n\t\t\t\t\tJSON.stringify(item) +\n\t\t\t\t\t' please check itemValue property is correct.'\n\t\t\t);\n\n\t\tconst jsonValue = JSON.stringify(value);\n\t\treturn {\n\t\t\tdisabled: !!item.disabled,\n\t\t\tid: 'option_' + jsonValue.replace(/\\W/g, '_'),\n\t\t\tjsonValue,\n\t\t\tmanual: false,\n\t\t\toriginal: item,\n\t\t\ttext,\n\t\t\tvalue,\n\t\t};\n\t});\n});\n\nconst options = computed<Option<T>[]>(() => {\n\tlet fromOptions = internalOptions.value.reduce(\n\t\t(acc: { [key: string]: BaseOption<T> }, curr: BaseOption<T>) => {\n\t\t\tacc[curr.id] = curr;\n\t\t\treturn acc;\n\t\t},\n\t\t{}\n\t);\n\tconst withManual: { [key: string]: BaseOption<T> } = manualItems.value.reduce(\n\t\t(acc, curr) => {\n\t\t\tif (!acc[curr.id]) acc[curr.id] = curr as any;\n\t\t\treturn acc;\n\t\t},\n\t\tfromOptions\n\t);\n\tconst withStash: { [key: string]: BaseOption<T> } = stash.value.reduce(\n\t\t(acc, curr) => {\n\t\t\tif (!acc[curr.id]) acc[curr.id] = curr as any;\n\t\t\treturn acc;\n\t\t},\n\t\twithManual\n\t);\n\tif (props.debug)\n\t\tconsole.log('Computing options in options', {\n\t\t\tfromOptions,\n\t\t\twithManual,\n\t\t\twithStash,\n\t\t});\n\treturn Object.values(withStash).map<Option<T>>(\n\t\t(option: BaseOption<T>, index) => {\n\t\t\treturn {\n\t\t\t\t...option,\n\t\t\t\tselected: isNotNil(modelValueIndexed.value.get(option.value)),\n\t\t\t\tindex,\n\t\t\t};\n\t\t}\n\t);\n});\n\n/**\n * Filter options to be displayed based on the current query.\n * If no query is used or when query is set from the inside (after a selection) display all possible options\n */\nconst filteredOptions = computed<FilteredOption<T>[]>(() => {\n\tif (props.debug) console.log('Computing filtered options');\n\tlet base = [];\n\t/** Only filter when a value is being searched not when the query is fully set on a selected option text */\n\tif (\n\t\tquery.value &&\n\t\t!selectedOptions.value.some(\n\t\t\t(option: Option<T>) => option.text === query.value\n\t\t)\n\t) {\n\t\tbase = options.value.filter((item: Option<T>) => {\n\t\t\tlet matchedAnything = false;\n\t\t\tif (!props.filterBy) return true;\n\t\t\telse if (typeof props.filterBy === 'function')\n\t\t\t\tmatchedAnything = props.filterBy(item.value, item.original);\n\t\t\telse if (props.filterBy.length) {\n\t\t\t\tconst keys = ([] as string[]).concat(props.filterBy);\n\t\t\t\tfor (let index = 0; index < keys.length; index++) {\n\t\t\t\t\tconst propName = keys[index];\n\t\t\t\t\tmatchedAnything =\n\t\t\t\t\t\tmatchedAnything ||\n\t\t\t\t\t\t((item.original as any)[propName] &&\n\t\t\t\t\t\t\t(item.original as any)[propName]\n\t\t\t\t\t\t\t\t.toLowerCase()\n\t\t\t\t\t\t\t\t.includes(query.value.toLowerCase()));\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn (\n\t\t\t\tmatchedAnything ||\n\t\t\t\titem.text.toLowerCase().includes(query.value.toLowerCase())\n\t\t\t);\n\t\t});\n\t\t/** Otherwise defaul;t to the whole set of options */\n\t} else base = options.value;\n\t/** This is done here so that only visible options are highlighted */\n\treturn base.map((option: Option<T>, index) => ({\n\t\t...option,\n\t\tfocused: normalizedFocusedIndex.value === index,\n\t}));\n});\n\n/**\n * Indexes options by id for retrieval\n */\n\nconst optionsIndexedById = computed<{\n\t[key: string]: Option<T>;\n}>(() =>\n\toptions.value.reduce(\n\t\t(acc, curr) => ({\n\t\t\t...acc,\n\t\t\t[curr.id]: curr,\n\t\t}),\n\t\t{}\n\t)\n);\n\n/**\n * Indexes options by their value\n * (using JSON to circumvent identical objects not being equal in JS)\n */\nconst optionsIndexedByValue = computed(() => {\n\tif (props.debug) console.log('Computing optionsIndexedByValue');\n\tif (props.matchStrategy === 'string') {\n\t\tlet indexed = options.value.reduce(\n\t\t\t(acc: { [key: string]: Option<T> }, curr: Option<T>) => {\n\t\t\t\tacc[curr.jsonValue] = curr;\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t\treturn {\n\t\t\tget: (key: any) => {\n\t\t\t\treturn indexed[JSON.stringify(key)];\n\t\t\t},\n\t\t};\n\t} else if (props.matchStrategy === 'equality') {\n\t\tlet indexed: [any, Option<T>][] = options.value.map((option) => [\n\t\t\toption.value,\n\t\t\toption,\n\t\t]);\n\n\t\treturn {\n\t\t\tget: (key: any) => {\n\t\t\t\treturn indexed.find((pairs) => deepEqual(pairs[0], key))?.[1];\n\t\t\t},\n\t\t};\n\t} else {\n\t\tthrow new Error('No match strategy has been defined');\n\t}\n});\n\n/**\n * Indexes modelValue to a map so when can easily know which values are selected\n * (using JSON to circumvent identical object not being equal in JS)\n */\nconst modelValueIndexed = computed(() => {\n\tif (props.debug) console.log('Computing modelValueIndexed');\n\tif (props.matchStrategy === 'string') {\n\t\tlet map: { [key: string]: number } = {};\n\t\t[].concat(props.modelValue).forEach((value: any, index: number) => {\n\t\t\tmap[JSON.stringify(value)] = index;\n\t\t});\n\t\treturn {\n\t\t\tget: (value: any) => map[JSON.stringify(value)],\n\t\t};\n\t} else if (props.matchStrategy === 'equality') {\n\t\tconst map = []\n\t\t\t.concat(props.modelValue)\n\t\t\t.filter(isNotNil)\n\t\t\t.map((value, index) => [value, index]);\n\n\t\treturn {\n\t\t\tget: (key: any) => {\n\t\t\t\treturn map.find((pairs) => deepEqual(pairs[0], key))?.[1];\n\t\t\t},\n\t\t};\n\t} else {\n\t\tthrow new Error('No match strategy has been defined');\n\t}\n});\n\n/**\n * For every item in modelValue find the linked option if it exists.\n * This is used to display chips.\n */\nconst selectedOptions = computed(() => {\n\tif (props.debug) console.log('Computing selectedOptions');\n\treturn [].concat(props.modelValue).reduce((acc: Option<T>[], curr: any) => {\n\t\tconst linkedOption = optionsIndexedByValue.value.get(curr);\n\t\tif (linkedOption) acc.push(linkedOption);\n\t\treturn acc;\n\t}, []);\n});\n\n/**\n * When selecting an option split behavior based on single or multiple selection\n */\nconst onOptionSelected = (option: Option<T>) => {\n\tif (props.debug) console.log('Running onOptionSelected', { option });\n\tlet valueToEmit;\n\tfocusedIndex.value = option.index;\n\t/**\n\t * For single selection:\n\t * If the option was already selected - restore the value to default, clean the stash, manual items, and query.\n\t * If the option was not selected - use its value, save the option in the stash and display it's text as query\n\t * The stash is used to remove the complexity of stashing items when searching for identifying information,\n\t * like searching an address would not return the option that was used to selected a previous address in another country.\n\t * Or when searching users by username would not return the previous ones.\n\t * We save it so the user hasn't to.\n\t */\n\tif (!props.multiple) {\n\t\tif (option.selected) {\n\t\t\tif (option.manual) {\n\t\t\t\tif (props.debug)\n\t\t\t\t\tconsole.log('onOptionSelected: inside single > selected > manual');\n\t\t\t\tmanualItems.value = manualItems.value.filter(\n\t\t\t\t\t(current: any) => current.id !== option.id\n\t\t\t\t);\n\t\t\t}\n\t\t\tvalueToEmit = null;\n\t\t\tif (props.stash) {\n\t\t\t\tif (props.debug)\n\t\t\t\t\tconsole.log('onOptionSelected: inside single > selected > stash');\n\t\t\t\tstash.value = [];\n\t\t\t}\n\t\t\tquery.value = '';\n\t\t} else {\n\t\t\tif (props.debug)\n\t\t\t\tconsole.log('onOptionSelected: inside single > not selected');\n\t\t\tvalueToEmit = option.value;\n\t\t\tif (props.stash) {\n\t\t\t\tif (props.debug)\n\t\t\t\t\tconsole.log('onOptionSelected: inside single > not selected > stash');\n\t\t\t\tstash.value = [option as any];\n\t\t\t}\n\t\t\tquery.value = option.text;\n\t\t}\n\t\t/**\n\t\t * For multiple selection\n\t\t * If the option was selected remove it from modelValue, if it is a mnaual iutem also remove it from there.\n\t\t * In the stash we can search for the id of the option.\n\t\t * If the option was not selected we can just add it to modelValue and the stash.\n\t\t */\n\t} else {\n\t\tif (option.selected) {\n\t\t\tif (option.manual) {\n\t\t\t\tif (props.debug)\n\t\t\t\t\tconsole.log('onOptionSelected: inside multiple > selected > manual');\n\t\t\t\tmanualItems.value = manualItems.value.filter(\n\t\t\t\t\t(current: any) => current.id !== option.id\n\t\t\t\t);\n\t\t\t}\n\t\t\tvalueToEmit = props.modelValue.filter(\n\t\t\t\t(value: any) => JSON.stringify(value) !== option.jsonValue\n\t\t\t);\n\t\t\tif (props.stash) {\n\t\t\t\tif (props.debug)\n\t\t\t\t\tconsole.log('onOptionSelected: inside multiple > selected > stash');\n\t\t\t\tstash.value = stash.value.filter((stashed) => stashed.id !== option.id);\n\t\t\t}\n\t\t} else {\n\t\t\tif (props.debug)\n\t\t\t\tconsole.log('onOptionSelected: inside multiple > not selected');\n\t\t\tvalueToEmit = props.modelValue.concat(option.value);\n\t\t\tif (props.stash) {\n\t\t\t\tif (props.debug)\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t'onOptionSelected: inside multiple > not selected > stash'\n\t\t\t\t\t);\n\t\t\t\tstash.value = stash.value.concat(option as any);\n\t\t\t}\n\t\t}\n\t\tif (props.resetQueryOnOptionSelected) {\n\t\t\tif (props.debug) console.log('onOptionSelected: resetting query');\n\t\t\tquery.value = '';\n\t\t}\n\t}\n\temit('update:modelValue', valueToEmit);\n};\n\nconst getOptions = async ({ prefill = false }) => {\n\tif (props.debug) console.log('running getOptions');\n\tlet items: T[] = [];\n\tif (Array.isArray(props.items)) {\n\t\titems = props.items;\n\t} else {\n\t\tif (typeof props.items === 'function') {\n\t\t\tloading.value++;\n\t\t\titems = await props.items(query.value, prefill, props.modelValue);\n\t\t\tloading.value--;\n\t\t}\n\t}\n\tinternalItems.value = items as any;\n};\n\n/**\n * Add an option to the manual items and then reset the query\n */\nconst addOption = () => {\n\tif (props.debug) console.log('running addOption');\n\tconst text = query.value;\n\tconst value = query.value;\n\tconst jsonValue = JSON.stringify(value);\n\tconst option = {\n\t\ttext,\n\t\tvalue,\n\t\tjsonValue,\n\t\tid: 'option_' + jsonValue.replace(/\\W/g, '_'),\n\t\toriginal: value,\n\t\tmanual: true,\n\t\tdisabled: false,\n\t};\n\tmanualItems.value = manualItems.value.concat(option as any);\n\tquery.value = '';\n};\n\n/**\n * It should prefill if asked, or\n * when single if modelValue is not null\n * when multiple if modelValue is not empty\n */\nconst shouldPrefill =\n\tprops.prefill === true ||\n\t(!props.multiple && isNotNil(props.modelValue)) ||\n\t(props.multiple && !!props.modelValue.length);\n/**\n * When modelValue changes split behavior for single and multiple selection:\n */\nlet modelValueTimeout: ReturnType<typeof setTimeout>;\nlet hasRunOnce = false;\nwatch(\n\t() => props.modelValue,\n\t(current, previous) => {\n\t\tif (props.debug) console.log('running watch.modelValue');\n\t\tif (modelValueTimeout) clearTimeout(modelValueTimeout);\n\t\tmodelValueTimeout = setTimeout(\n\t\t\tasync () => {\n\t\t\t\t/**\n\t\t\t\t * For single selection if the value is already in the option (most likely you are using\n\t\t\t\t * static items) just use it.\n\t\t\t\t * If the value is not in the options try searching for it (outside dependencies may fix it).\n\t\t\t\t * If at last the value cannot be found even after searching\n\t\t\t\t * reset value to the default value when coherence is enforced\n\t\t\t\t * or at least do not display the old query\n\t\t\t\t */\n\t\t\t\tif (!props.multiple) {\n\t\t\t\t\tif (props.debug) console.log('watch.modelValue >> single');\n\t\t\t\t\tlet found = optionsIndexedByValue.value.get(props.modelValue);\n\t\t\t\t\tif (\n\t\t\t\t\t\t(!found && isNotNil(props.modelValue)) ||\n\t\t\t\t\t\tprevious === undefined\n\t\t\t\t\t) {\n\t\t\t\t\t\tif (props.debug)\n\t\t\t\t\t\t\tconsole.log('watch.modelValue >> not found line 895');\n\t\t\t\t\t\tconst currentQuery = query.value;\n\t\t\t\t\t\tquery.value = '';\n\t\t\t\t\t\tawait getOptions({ prefill: true });\n\t\t\t\t\t\tquery.value = currentQuery;\n\t\t\t\t\t}\n\t\t\t\t\tfound = optionsIndexedByValue.value.get(props.modelValue);\n\t\t\t\t\tif (found) {\n\t\t\t\t\t\tif (props.debug) console.log('watch.modelValue >> found');\n\t\t\t\t\t\tquery.value = found.text;\n\t\t\t\t\t\tif (props.debug) console.log('watch.modelValue assigned to query');\n\t\t\t\t\t\tif (props.stash) {\n\t\t\t\t\t\t\tstash.value = [found as any];\n\t\t\t\t\t\t\tif (props.debug)\n\t\t\t\t\t\t\t\tconsole.log('watch.modelValue assigned to stash');\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (props.debug) console.log('watch.modelValue end of found');\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (props.enforceCoherence && isNotNil(current)) {\n\t\t\t\t\t\t\tif (props.debug)\n\t\t\t\t\t\t\t\tconsole.log('watch.modelValue >> not found line 911');\n\t\t\t\t\t\t\tquery.value = '';\n\t\t\t\t\t\t\tif (props.stash) {\n\t\t\t\t\t\t\t\tstash.value = [];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\temit('update:modelValue', null);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tquery.value = '';\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t/**\n\t\t\t\t\t * For multiple selection if every value is already in the options (most likely you are using\n\t\t\t\t\t * static items) just use them.\n\t\t\t\t\t * If not all the values are in the current options or is prefilling try searching (outside depencencies may fix the situation).\n\t\t\t\t\t * If the values are still not in the available options and coherence is enforced\n\t\t\t\t\t * discard the ones that are invalid.\n\t\t\t\t\t *\n\t\t\t\t\t */\n\t\t\t\t} else {\n\t\t\t\t\tif (!Array.isArray(props.modelValue)) {\n\t\t\t\t\t\tthrow new Error('props.modelValue is not an array.');\n\t\t\t\t\t}\n\t\t\t\t\tlet allFound = props.modelValue.every((value: any) =>\n\t\t\t\t\t\toptionsIndexedByValue.value.get(value)\n\t\t\t\t\t);\n\t\t\t\t\tif (!allFound || previous === undefined) {\n\t\t\t\t\t\tawait getOptions({ prefill: true });\n\t\t\t\t\t\tallFound = props.modelValue.every((value: any) =>\n\t\t\t\t\t\t\toptionsIndexedByValue.value.get(value)\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (allFound) {\n\t\t\t\t\t\tif (props.stash) {\n\t\t\t\t\t\t\tstash.value = props.modelValue.map(\n\t\t\t\t\t\t\t\t(value: any) => optionsIndexedByValue.value.get(value)!\n\t\t\t\t\t\t\t) as any;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlet coherentStash: Option<T>[] = [];\n\t\t\t\t\t\tconst coherent = current.filter((value: any) => {\n\t\t\t\t\t\t\tlet found = optionsIndexedByValue.value.get(value);\n\t\t\t\t\t\t\tif (found) coherentStash.push(found);\n\t\t\t\t\t\t\treturn found;\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (props.stash) {\n\t\t\t\t\t\t\tstash.value = coherentStash as any;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (props.enforceCoherence) {\n\t\t\t\t\t\t\temit('update:modelValue', coherent);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tshouldPrefill ? 0 : props.modelValueDebounceTime\n\t\t);\n\t},\n\t// Prefill when asked or when items are static\n\t{ immediate: shouldPrefill, deep: true }\n);\n\n/**\n * This is triggered to refresh static items whenever the passed array changes.\n * If the parent defines an array in the template this is triggered\n * at every render so we take counter measures\n * Even if the entire array changes all the previously selected values are still in the stash.\n */\nwatch(\n\t() => props.items,\n\tasync (current, previous) => {\n\t\tif (\n\t\t\ttypeof current === 'function' ||\n\t\t\t// Circumvent arrays defined in the template by the parent\n\t\t\tJSON.stringify(current) !== JSON.stringify(previous)\n\t\t) {\n\t\t\tif (props.debug) console.log('watch.items');\n\t\t\tawait getOptions({ prefill: false });\n\t\t\tif (props.multiple) {\n\t\t\t\tconst allFound = props.modelValue.every((value: any) =>\n\t\t\t\t\toptionsIndexedByValue.value.get(value)\n\t\t\t\t);\n\n\t\t\t\tif (!allFound) {\n\t\t\t\t\tif (props.enforceCoherence) {\n\t\t\t\t\t\tconst coherent = props.modelValue.filter((value: any) => {\n\t\t\t\t\t\t\tlet found = optionsIndexedByValue.value.get(value);\n\t\t\t\t\t\t\treturn found;\n\t\t\t\t\t\t});\n\t\t\t\t\t\temit('update:modelValue', coherent);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlet found = optionsIndexedByValue.value.get(props.modelValue);\n\t\t\t\tif (!found && props.enforceCoherence && isNotNil(props.modelValue)) {\n\t\t\t\t\temit('update:modelValue', null);\n\t\t\t\t}\n\t\t\t\tfocusedIndex.value = null;\n\t\t\t}\n\t\t}\n\t}\n);\n\n/**\n * When dependencies change\n * If the input has not been prefilled yet just return\n * Check dependencies are the same by value and not reference\n * Otherwise we search again for options as they might be different base on dependencies.\n * If coherence is enforced we set the state accordingly\n */\nlet depsTimeout: ReturnType<typeof setTimeout>;\nwatch(\n\t() => props.dependencies,\n\t(current, previous) => {\n\t\tif (!shouldPrefill && props.prefill === 'focus' && isFirstFocus) {\n\t\t\treturn;\n\t\t}\n\t\t// Circumvent array defined in the template by the parent\n\t\tif (JSON.stringify(current) === JSON.stringify(previous)) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (depsTimeout) clearTimeout(depsTimeout);\n\t\tdepsTimeout = setTimeout(async () => {\n\t\t\tif (JSON.stringify(current) !== JSON.stringify(previous)) {\n\t\t\t\t// Only reset the stash if we are going to enforce coherence\n\t\t\t\tif (props.enforceCoherence) {\n\t\t\t\t\tif (props.stash) {\n\t\t\t\t\t\tstash.value = [];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Momentarily reset query\n\t\t\t\tlet currentQuery = query.value;\n\t\t\t\tquery.value = '';\n\t\t\t\tawait getOptions({ prefill: true });\n\t\t\t\tquery.value = currentQuery;\n\t\t\t\tif (!props.multiple) {\n\t\t\t\t\tlet found = optionsIndexedByValue.value.get(props.modelValue);\n\t\t\t\t\tif (!found && props.enforceCoherence && isNotNil(props.modelValue)) {\n\t\t\t\t\t\tquery.value = '';\n\t\t\t\t\t\tif (props.stash) {\n\t\t\t\t\t\t\tstash.value = [];\n\t\t\t\t\t\t}\n\t\t\t\t\t\temit('update:modelValue', null);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tlet allFound = props.modelValue.every((value: any) =>\n\t\t\t\t\t\toptionsIndexedByValue.value.get(value)\n\t\t\t\t\t);\n\t\t\t\t\tif (!allFound && props.enforceCoherence) {\n\t\t\t\t\t\tlet coherentStash: Option<T>[] = [];\n\t\t\t\t\t\tconst coherent = props.modelValue.filter((value: any) => {\n\t\t\t\t\t\t\tlet found = optionsIndexedByValue.value.get(value);\n\t\t\t\t\t\t\tif (found) coherentStash.push(found);\n\t\t\t\t\t\t\treturn found;\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (props.stash) {\n\t\t\t\t\t\t\tstash.value = coherentStash as any;\n\t\t\t\t\t\t}\n\t\t\t\t\t\temit('update:modelValue', coherent);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}, props.depsDebounceTime);\n\t},\n\t{ deep: true }\n);\n\n/**\n * This is used to position the option container.\n * When the linked item (outerContainer) updates its position\n * this is rerun by floating-UI\n */\nconst displayOptions = () => {\n\tif (props.debug) console.log('Running display options');\n\tif (innerContainer.value && optionsContainer.value) {\n\t\tcomputePosition(innerContainer.value, optionsContainer.value, {\n\t\t\tplacement: 'bottom',\n\t\t\tmiddleware: [offset(6), flip(), shift()],\n\t\t}).then((data) => {\n\t\t\tif (optionsContainer.value) {\n\t\t\t\toptionsContainer.value.style.left = `${data.x}px`;\n\t\t\t\toptionsContainer.value.style.top = `${data.y}px`;\n\t\t\t\toptionsContainer.value.style.width = `${innerContainer.value?.offsetWidth}px`;\n\t\t\t}\n\t\t});\n\t}\n};\n/**\n * We need the transitions because elements must be hidden and shown\n * to accessibility tools when they are fully closed or fully open,\n * while still being animated for sighted users.\n */\n\n// Option panel is open\nconst shown = ref(false);\n// Option panel is opening\nconst showing = ref(false);\n// option panel is closing\nconst hiding = ref(false);\n// Option panel il closed\nconst hidden = ref(true);\n\nconst open = async () => {\n\thidden.value = false;\n\tshowing.value = true;\n\tawait wait(props.transitionDuration);\n\tshowing.value = false;\n\tshown.value = true;\n};\n\nconst close = async () => {\n\tshown.value = false;\n\thiding.value = true;\n\tawait wait(props.transitionDuration);\n\thiding.value = false;\n\thidden.value = true;\n};\n\n/**\n * Applies a class when the user is inside this whole component.\n * We cannot use focus within as it doesn't work for elements that are teleported.\n * Also we cannot use the <input/> if we phisically move focus to the options so\n * we track it manually.\n */\nconst active = ref(false);\n\n/**\n * When the focus goes to the input we select the current text\n * so the user can replace or delete it.\n * On top of that if the prefill strategy is to prefill on first focus and options\n * weren't already retrieved by the watcher on mount, we do that\n */\nlet isFirstFocus = true;\nconst onInputFocus = async (event: FocusEvent) => {\n\tif (props.debug) console.log('Running onInputFocus');\n\temit('focus', event);\n\tactive.value = true;\n\tdocument.addEventListener('click', onClickOutside);\n\tdocument.addEventListener('focusin', onFocusOutside);\n\tif (input.value instanceof HTMLInputElement) input.value.select();\n\tif (props.prefill === 'focus' && isFirstFocus && !shouldPrefill) {\n\t\tawait getOptions({ prefill: true });\n\t\tisFirstFocus = false;\n\t}\n};\n\nconst onFocusOutside = async (event: FocusEvent) => {\n\tif (props.debug) console.log('Running onFocusOutside');\n\tif (event.target instanceof Node) {\n\t\tif (outerContainer.value && optionsContainer.value) {\n\t\t\tif (\n\t\t\t\t!outerContainer.value.contains(event.target) &&\n\t\t\t\t!optionsContainer.value.contains(event.target)\n\t\t\t) {\n\t\t\t\tclose();\n\t\t\t\temit('inactive');\n\t\t\t\tdocument.removeEventListener('focusin', onFocusOutside);\n\t\t\t\tactive.value = false;\n\t\t\t\tif (props.multiple) {\n\t\t\t\t\tawait wait(500);\n\t\t\t\t\tquery.value = '';\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n};\n\n/**\n * On single selection restore the query that might be partially altered by the user.\n * Input can blur either by clicking outside or clicking on an option.\n * We do nothing if the user has selected an option. And we restore the\n * query to its text if the user has moved focus\n */\nconst onInputBlur = async (event: FocusEvent) => {\n\tif (props.debug) console.log('Running onInputBlur');\n\temit('blur', event);\n\tif (!props.multiple) {\n\t\tconst currentModelValue = props.modelValue;\n\t\tawait nextTick();\n\t\tawait wait(300);\n\t\tif (outerContainer.value && optionsContainer.value) {\n\t\t\tconst active = document.activeElement;\n\t\t\tif (\n\t\t\t\t!outerContainer.value.contains(active) &&\n\t\t\t\t!optionsContainer.value.contains(active)\n\t\t\t) {\n\t\t\t\tconst found = optionsIndexedByValue.value.get(props.modelValue);\n\t\t\t\tif (found) {\n\t\t\t\t\tquery.value = found.text;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n};\n\nconst onInputChange = (event: Event) => emit('change', event);\n\n/**\n * Search at every input by the user.\n * When the user deletes the query unselect the current option\n */\nconst onInputInput = (event: Event) => {\n\tif (props.debug) console.log('Running onInputInput');\n\temit('input', event);\n\tif (query.value === '') {\n\t\tif (!props.multiple) {\n\t\t\temit('update:modelValue', null);\n\t\t}\n\t}\n\tif (typeof props.items === 'function') {\n\t\tsearchByQuery();\n\t}\n};\n\n// This is the vertical index used to highlight options in the container\nconst focusedIndex = ref<number | null>(null);\n/**\n * Normalize the index using the displayed options so we can start over when reaching the end.\n * Please watch out for the side effect it is used to avoid the\n * complexity of using modulo over negative numbers\n */\nconst normalizedFocusedIndex: ComputedRef<number | null> = computed(() => {\n\tif (Number.isInteger(focusedIndex.value) && focusedIndex.value) {\n\t\tif (focusedIndex.value === -1) {\n\t\t\tfocusedIndex.value = filteredOptions.value.length - 1;\n\t\t}\n\t\treturn focusedIndex.value % filteredOptions.value.length;\n\t}\n\treturn focusedIndex.value;\n});\n\n// This is the horizontal index used to highlight selected options\nconst selectedOptionsFocusedIndex = ref<number | null>(null);\n\n/**\n * Increment the focusIndex and wait for it to be normalized.\n * If the index corresponds to an option scroll it into view\n */\nconst focusOnNextOption = async () => {\n if (focusedIndex.value !== null) {\n focusedIndex.value = focusedIndex.value % options.value.length;\n } else {\n focusedIndex.value = 0;\n }\n\tawait nextTick();\n\tif (normalizedFocusedIndex.value !== null) {\n\t\tconst foundOption = optionsContainer.value?.querySelector(\n\t\t\t`#${options.value[normalizedFocusedIndex.value].id}`\n\t\t);\n\t\tif (foundOption instanceof HTMLElement)\n\t\t\tfoundOption.scrollIntoView({\n\t\t\t\tbehavior: 'smooth',\n\t\t\t\tblock: 'nearest',\n\t\t\t\tinline: 'start',\n\t\t\t});\n\t}\n};\n\n/**\n * Decrement the focusIndex and wait for it to be normalized.\n * If the index corresponds to an option scroll it into view\n */\nconst focusOnPreviousOption = async () => {\n if (focusedIndex.value !== null) {\n focusedIndex.value =\n focusedIndex.value === 0\n ? options.value.length - 1\n : focusedIndex.value - 1;\n } else focusedIndex.value = options.value.length - 1;\n\tawait nextTick();\n\tif (normalizedFocusedIndex.value !== null) {\n\t\tconst foundOption = optionsContainer.value?.querySelector(\n\t\t\t`#${options.value[normalizedFocusedIndex.value].id}`\n\t\t);\n\t\tif (foundOption instanceof HTMLElement)\n\t\t\tfoundOption.scrollIntoView({\n\t\t\t\tbehavior: 'smooth',\n\t\t\t\tblock: 'nearest',\n\t\t\t\tinline: 'start',\n\t\t\t});\n\t}\n};\n\n/**\n * This is handled separately from input because it has a lot to do with user\n * interaction and control characters than it has with the query.\n */\nconst onInputKeyDown = async (event: KeyboardEvent) => {\n\tif (props.readonly || props.disabled) {\n\t\tevent.preventDefault();\n\t\treturn;\n\t}\n\tswitch (event.key) {\n\t\t/**\n\t\t * On arrow prevent the page from scrolling.\n\t\t * Reset horizontal focus\n\t\t * When the panel is open\n\t\t * - Focus on the previous option\n\t\t * When the panel is closed\n\t\t * - focus on the first selected option\n\t\t */\n\t\tcase 'ArrowUp':\n\t\t\t{\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif (loading.value) return;\n\t\t\t\tselectedOptionsFocusedIndex.value = null;\n\t\t\t\tif (shown.value) {\n\t\t\t\t\tif (!filteredOptions.value.length) return;\n\t\t\t\t\tfocusOnPreviousOption();\n\t\t\t\t} else {\n\t\t\t\t\tif (selectedOptions.value.length) {\n\t\t\t\t\t\tfocusedIndex.value = head(selectedOptions.value).index;\n\t\t\t\t\t}\n\t\t\t\t\tawait open();\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t/**\n\t\t * On arrow prevent the page from scrolling.\n\t\t * Reset horizontal focus\n\t\t * When the panel is open\n\t\t * - Focus on the previous option\n\t\t * When the panel is closed\n\t\t * - focus on the first selected option\n\t\t */\n\t\tcase 'ArrowDown':\n\t\t\t{\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif (loading.value) return;\n\t\t\t\tselectedOptionsFocusedIndex.value = null;\n\t\t\t\tif (shown.value) {\n\t\t\t\t\tif (!filteredOptions.value.length) return;\n\t\t\t\t\tfocusOnNextOption();\n\t\t\t\t} else {\n\t\t\t\t\tif (selectedOptions.value.length) {\n\t\t\t\t\t\tfocusedIndex.value = head(selectedOptions.value).index;\n\t\t\t\t\t}\n\t\t\t\t\tawait open();\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t/**\n\t\t * When moving horizontally\n\t\t * Cycle from rightmost, next, or input focus.\n\t\t * If the focus lands on an option align the vertical focus as well\n\t\t */\n\t\tcase 'ArrowLeft':\n\t\t\t{\n\t\t\t\tif (loading.value) return;\n\t\t\t\tif (!query.value) {\n\t\t\t\t\tif (selectedOptions.value.length) {\n\t\t\t\t\t\tif (selectedOptionsFocusedIndex.value === null) {\n\t\t\t\t\t\t\tselectedOptionsFocusedIndex.value =\n\t\t\t\t\t\t\t\tselectedOptions.value.length - 1;\n\t\t\t\t\t\t} else if (selectedOptionsFocusedIndex.value > 0) {\n\t\t\t\t\t\t\tselectedOptionsFocusedIndex.value--;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tselectedOptionsFocusedIndex.value = null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (selectedOptionsFocusedIndex.value !== null) {\n\t\t\t\t\t\t\tlet linkedOption =\n\t\t\t\t\t\t\t\tselectedOptions.value[selectedOptionsFocusedIndex.value];\n\t\t\t\t\t\t\tlet foundOption = optionsContainer.value?.querySelector(\n\t\t\t\t\t\t\t\t`#${linkedOption.id}`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (foundOption) {\n\t\t\t\t\t\t\t\tfoundOption.scrollIntoView({\n\t\t\t\t\t\t\t\t\tbehavior: 'smooth',\n\t\t\t\t\t\t\t\t\tblock: 'nearest',\n\t\t\t\t\t\t\t\t\tinline: 'start',\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tfocusedIndex.value =\n\t\t\t\t\t\t\t\t\toptionsIndexedById.value[\n\t\t\t\t\t\t\t\t\t\tselectedOptions.value[selectedOptionsFocusedIndex.value].id\n\t\t\t\t\t\t\t\t\t].index;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t/**\n\t\t * When moving horizontally\n\t\t * Cycle from leftmost, next, or input focus.\n\t\t * If the focus lands on an option align the vertical focus as well\n\t\t */\n\t\tcase 'ArrowRight':\n\t\t\t{\n\t\t\t\tif (loading.value) return;\n\t\t\t\tif (!query.value) {\n\t\t\t\t\tif (selectedOptions.value.length) {\n\t\t\t\t\t\tif (selectedOptionsFocusedIndex.value === null) {\n\t\t\t\t\t\t\tselectedOptionsFocusedIndex.value = 0;\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\tselectedOptionsFocusedIndex.value <\n\t\t\t\t\t\t\tselectedOptions.value.length - 1\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tselectedOptionsFocusedIndex.value++;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tselectedOptionsFocusedIndex.value = null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (selectedOptionsFocusedIndex.value !== null) {\n\t\t\t\t\t\t\tlet linkedOption =\n\t\t\t\t\t\t\t\tselectedOptions.value[selectedOptionsFocusedIndex.value];\n\t\t\t\t\t\t\tlet foundOption = optionsContainer.value?.querySelector(\n\t\t\t\t\t\t\t\t`#${linkedOption.id}`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (foundOption) {\n\t\t\t\t\t\t\t\tfoundOption.scrollIntoView({\n\t\t\t\t\t\t\t\t\tbehavior: 'smooth',\n\t\t\t\t\t\t\t\t\tblock: 'nearest',\n\t\t\t\t\t\t\t\t\tinline: 'start',\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tfocusedIndex.value =\n\t\t\t\t\t\t\t\t\toptionsIndexedById.value[\n\t\t\t\t\t\t\t\t\t\tselectedOptions.value[selectedOptionsFocusedIndex.value].id\n\t\t\t\t\t\t\t\t\t].index;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t/**\n\t\t * If the panel is closed focus on the first selected option.\n\t\t * If the panel was already open select/deselect the currently focused option\n\t\t * and close the panel of single selection is enabled\n\t\t */\n\t\tcase 'Enter':\n\t\t\t{\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif (loading.value) return;\n\t\t\t\tif (!shown.value) {\n\t\t\t\t\tif (filteredOptions.value.length) {\n\t\t\t\t\t\tif (selectedOptions.value.length) {\n\t\t\t\t\t\t\tfocusedIndex.value = head(selectedOptions.value).index;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tawait open();\n\t\t\t\t} else {\n\t\t\t\t\tif (normalizedFocusedIndex.value !== null) {\n\t\t\t\t\t\tif (filteredOptions.value[normalizedFocusedIndex.value].disabled)\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\tif (!props.multiple) {\n\t\t\t\t\t\t\tawait close();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonOptionSelected(\n\t\t\t\t\t\t\tfilteredOptions.value[normalizedFocusedIndex.value]\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (props.addOptions) {\n\t\t\t\t\t\t\tif (props.itemText || props.itemValue) {\n\t\t\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t\t\t`Adding an option for mapped items is not supported. You can't create an option while passing \"item-text\" or \"item-value\".`\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\taddOption();\n\t\t\t\t\t\t\tconst added = last(manualItems.value);\n\t\t\t\t\t\t\tonOptionSelected(optionsIndexedById.value[added.id]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t/**\n\t\t * When moving away from the component reset focus both vertically and horizontally\n\t\t */\n\t\tcase 'Tab':\n\t\tcase 'Escape':\n\t\t\t{\n\t\t\t\tif (shown.value) {\n\t\t\t\t\tawait close();\n\t\t\t\t}\n\t\t\t\temit('inactive');\n\t\t\t\tselectedOptionsFocusedIndex.value = null;\n\t\t\t\tfocusedIndex.value = null;\n\t\t\t}\n\t\t\tbreak;\n\t\t// Prevent shift from opening the panel\n\t\tcase 'Shift':\n\t\t\t{\n\t\t\t\tif (loading.value) return;\n\t\t\t}\n\t\t\tbreak;\n\t\t/**\n\t\t * Delete behavior is different when query is empty\n\t\t * If query is empty\n\t\t * If no chip is selected - select rightmost chip\n\t\t * If a chip is selected - deselect that option\n\t\t * If any option remains move focus to that or reset\n\t\t */\n\t\tcase 'Backspace':\n\t\t\t{\n\t\t\t\tif (loading.value) return;\n\t\t\t\tif (!query.value) {\n\t\t\t\t\tif (selectedOptions.value.length) {\n\t\t\t\t\t\tif (selectedOptionsFocusedIndex.value === null) {\n\t\t\t\t\t\t\tselectedOptionsFocusedIndex.value =\n\t\t\t\t\t\t\t\tselectedOptions.value.length - 1;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonOptionSelected(\n\t\t\t\t\t\t\t\tselectedOptions.value[selectedOptionsFocusedIndex.value]\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (selectedOptions.value.length) {\n\t\t\t\t\t\t\t\tselectedOptionsFocusedIndex.value = Math.max(\n\t\t\t\t\t\t\t\t\tMath.min(\n\t\t\t\t\t\t\t\t\t\tselectedOptionsFocusedIndex.value,\n\t\t\t\t\t\t\t\t\t\tselectedOptions.value.length - 2\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t0\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tselectedOptionsFocusedIndex.value = null;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tawait open();\n\t\t\t}\n\t\t\tbreak;\n\t\t/**\n\t\t * Open the panel on writing and reset horizontal focus\n\t\t */\n\t\tdefault:\n\t\t\t{\n\t\t\t\tselectedOptionsFocusedIndex.value = null;\n\t\t\t\tfocusedIndex.value = null;\n\t\t\t\tawait open();\n\t\t\t}\n\t\t\tbreak;\n\t}\n};\n\n/**\n * Triggered on input when items is a function.\n */\n\nlet timeout: ReturnType<typeof setTimeout>;\nconst searchByQuery = () => {\n\tif (timeout) clearTimeout(timeout);\n\ttimeout = setTimeout(async () => {\n\t\ttry {\n\t\t\tawait getOptions({ prefill: false });\n\t\t} catch (error) {\n\t\t\tconsole.error(error);\n\t\t}\n\t}, props.queryDebounceTime);\n};\n\n/**\n * When clicking on the outside container seamlessly move focus to the input and open the panel\n */\nconst onOuterContainerClick = (event: MouseEvent) => {\n\temit('click', event);\n\tif (props.disabled || props.readonly) return;\n\tif (input.value instanceof HTMLElement) {\n\t\tinput.value.focus();\n\t}\n\topen();\n};\n\n/**\n * When an option is clicked wait for it to bubble to the option container to avoid slot event problems.\n * Select / deselect the option and then move focus to the input.\n * If it is single selection mode close the panel\n */\nconst onOptionClicked = (event: Event) => {\n\tif (event.currentTarget instanceof HTMLElement) {\n\t\tif (event.currentTarget.classList.contains('bb-base-select-option')) {\n\t\t\tconst option = optionsIndexedById.value[event.currentTarget.id];\n\t\t\tif (option.disabled) return;\n\t\t\tonOptionSelected(option);\n\t\t\tif (input.value instanceof HTMLInputElement) {\n\t\t\t\tinput.value.focus();\n\t\t\t}\n\t\t\tif (!props.multiple) close();\n\t\t}\n\t}\n};\n\n/**\n * On click outside of the container close the panel, remove active state.\n * In multiple selection clear query after a timeout\n */\nconst onClickOutside = async (event: Event) => {\n\tif (event.target instanceof Node) {\n\t\tif (outerContainer.value) {\n\t\t\tif (!outerContainer.value.contains(event.target)) {\n\t\t\t\tclose();\n\t\t\t\temit('inactive');\n\t\t\t\tdocument.removeEventListener('click', onClickOutside);\n\t\t\t\tactive.value = false;\n\t\t\t\tif (props.multiple) {\n\t\t\t\t\tawait wait(500);\n\t\t\t\t\tquery.value = '';\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n};\n\n/**\n * When using this component for submission we add a bunch of hidden\n * inputs so the submitted inputs are on par with v-model\n */\n/**\n * This is used to keep the value compatible to common html expected values.\n * Convert to string everything that's not but do not double encode strings\n */\nconst makeInputValue = when(\n\t(item: unknown) => typeof item !== 'string',\n\tJSON.stringify\n);\n\nconst hiddenInputs = computed(() => {\n\treturn [].concat(props.modelValue).map((current) => {\n\t\tconst value = makeInputValue(current);\n\t\treturn {\n\t\t\tdisabled: props.disabled,\n\t\t\tname: props.name,\n\t\t\ttype: 'hidden',\n\t\t\tvalue: value,\n\t\t};\n\t});\n});\n</script>\n<style lang=\"postcss\">\n@import '@/assets/css/BaseSelect';\n</style>\n"],"names":["props","__props","emit","__emit","outerContainer","ref","innerContainer","optionsContainer","input","query","computedPlaceholder","computed","selectedOptions","loading","transitionDuration","cleanUpPositioning","onMounted","autoUpdate","displayOptions","onBeforeUnmount","internalItems","stash","manualItems","getItemText","useItemText","getItemValue","useItemValue","internalOptions","item","_","text","value","jsonValue","options","fromOptions","acc","curr","withManual","withStash","option","index","isNotNil","modelValueIndexed","filteredOptions","base","matchedAnything","keys","propName","normalizedFocusedIndex","optionsIndexedById","optionsIndexedByValue","indexed","key","_a","pairs","deepEqual","map","linkedOption","onOptionSelected","valueToEmit","focusedIndex","current","stashed","getOptions","prefill","items","addOption","shouldPrefill","modelValueTimeout","watch","previous","allFound","coherentStash","coherent","found","currentQuery","depsTimeout","isFirstFocus","computePosition","offset","flip","shift","data","shown","showing","hiding","hidden","open","wait","close","active","onInputFocus","event","onClickOutside","onFocusOutside","onInputBlur","nextTick","onInputChange","onInputInput","searchByQuery","selectedOptionsFocusedIndex","focusOnNextOption","foundOption","focusOnPreviousOption","onInputKeyDown","head","_b","added","last","timeout","error","onOuterContainerClick","onOptionClicked","makeInputValue","when","hiddenInputs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6cA,UAAMA,IAAQC,IAcRC,IAAOC;AAIb,QAAIH,EAAM,YAAY,CAAC,MAAM,QAAQA,EAAM,UAAU;AAC9C,YAAA,IAAI,MAAM,2DAA2D;AAGtE,UAAAI,IAAiBC,EAAwB,IAAI,GAC7CC,IAAiBD,EAAwB,IAAI,GAC7CE,IAAmBF,EAAwB,IAAI,GAC/CG,IAAQH,EAAwB,IAAI,GACpCI,IAAQJ,EAAY,EAAE,GACtBK,KAAsBC,EAAS,MAChCC,EAAgB,MAAM,SAAe,KAC7BZ,EAAM,WAClB,GAQKa,IAAUR,EAAI,CAAC,GACfS,KAAqBd,EAAM,qBAAqB,MAAO;AACzD,QAAAe;AAEJ,IAAAC,GAAU,YAAY;AACrB,MAAIhB,EAAM,SAAO,QAAQ,IAAI,mBAAmB,GAE5CM,EAAe,SAASC,EAAiB,UACvBQ,KAAAE;AAAA,QACpBX,EAAe;AAAA,QACfC,EAAiB;AAAA,QACjBW;AAAA,QACA;AAAA,UACC,gBAAgB;AAAA,UAChB,gBAAgB;AAAA,UAChB,gBAAgBlB,EAAM;AAAA,UACtB,eAAe;AAAA,QAChB;AAAA,MAAA;AAA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AAOD,MAAiB;AAC1C,UAAAA,EAAM,kBAAkB,QACvBxF,EAAe,SACd,CAACA,EAAe,MAAM,SAASwF,EAAM,MAAM,GAAG;AAC3C,QAAAH,KACNvF,EAAK,UAAU,GACN,SAAA,oBAAoB,SAAS2F,EAAc,GACpDH,EAAO,QAAQ,IACX1F,EAAM,aACT,MAAMwF,EAAK,GAAG,GACd/E,EAAM,QAAQ;AAEf;AAAA,MACD;AAAA,IAEF,GAWKwG,KAAiBC;AAAA,MACtB,CAACtF,MAAkB,OAAOA,KAAS;AAAA,MACnC,KAAK;AAAA,IAAA,GAGAuF,KAAexG,EAAS,MACtB,CAAA,EAAG,OAAOX,EAAM,UAAU,EAAE,IAAI,CAAC6D,MAAY;AAC7C,YAAA9B,IAAQkF,GAAepD,CAAO;AAC7B,aAAA;AAAA,QACN,UAAU7D,EAAM;AAAA,QAChB,MAAMA,EAAM;AAAA,QACZ,MAAM;AAAA,QACN,OAAA+B;AAAA,MAAA;AAAA,IACD,CACA,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index31.js","sources":["../src/components/BaseSelect/BaseSelect.vue"],"sourcesContent":["<template>\n\t<span\n\t\tref=\"outerContainer\"\n\t\t:class=\"{\n\t\t\t'bb-base-select': true,\n\t\t\t'bb-base-select--active': active,\n\t\t\t'bb-base-select--loading': loading,\n\t\t\t'bb-base-select--disabled': disabled,\n\t\t\t'bb-base-select--errors': hasErrors,\n\t\t\t'bb-base-select--readonly': readonly,\n\t\t}\"\n\t\t@click=\"onOuterContainerClick\"\n\t>\n\t\t<slot name=\"prepend-outer\"></slot>\n\t\t<span ref=\"innerContainer\" class=\"bb-base-select__inner-container\">\n\t\t\t<slot name=\"prepend\"></slot>\n\t\t\t<span class=\"bb-base-select__input-container\">\n\t\t\t\t<template v-if=\"multiple\">\n\t\t\t\t\t<template v-if=\"comma\">\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tv-for=\"(option, index) in selectedOptions\"\n\t\t\t\t\t\t\t:key=\"option.id\"\n\t\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t\t'bb-base-select__selected': true,\n\t\t\t\t\t\t\t\t'bb-base-select__selected--comma': true,\n\t\t\t\t\t\t\t\t'bb-base-select__selected--focused':\n\t\t\t\t\t\t\t\t\tindex === selectedOptionsFocusedIndex,\n\t\t\t\t\t\t\t}\"\n\t\t\t\t\t\t\t>{{ option.text\n\t\t\t\t\t\t\t}}{{ index < selectedOptions.length - 1 ? ',' : '' }}</span\n\t\t\t\t\t\t>\n\t\t\t\t\t</template>\n\t\t\t\t\t<template v-else>\n\t\t\t\t\t\t<BbChip\n\t\t\t\t\t\t\tv-for=\"(option, index) in selectedOptions\"\n\t\t\t\t\t\t\t:key=\"option.id\"\n\t\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t\t'bb-base-select__selected': true,\n\t\t\t\t\t\t\t\t'bb-base-select__selected--chip': true,\n\t\t\t\t\t\t\t\t'bb-base-select__selected--focused':\n\t\t\t\t\t\t\t\t\tindex === selectedOptionsFocusedIndex,\n\t\t\t\t\t\t\t}\"\n\t\t\t\t\t\t\t:clearable=\"true\"\n\t\t\t\t\t\t\t:text=\"option.text\"\n\t\t\t\t\t\t\t@click:clear.stop=\"onOptionSelected(option)\"\n\t\t\t\t\t\t\t><slot\n\t\t\t\t\t\t\t\t:disabled=\"option.disabled\"\n\t\t\t\t\t\t\t\t:has-errors=\"hasErrors\"\n\t\t\t\t\t\t\t\t:index=\"option.index\"\n\t\t\t\t\t\t\t\t:item=\"option.original\"\n\t\t\t\t\t\t\t\t:loading=\"!!loading\"\n\t\t\t\t\t\t\t\t:manual=\"option.manual\"\n\t\t\t\t\t\t\t\tname=\"chip\"\n\t\t\t\t\t\t\t\t:selected=\"option.selected\"\n\t\t\t\t\t\t\t\t:text=\"option.text\"\n\t\t\t\t\t\t\t\t:value=\"option.value\"\n\t\t\t\t\t\t\t\t>{{ option.text }}</slot\n\t\t\t\t\t\t\t></BbChip\n\t\t\t\t\t\t>\n\t\t\t\t\t</template>\n\t\t\t\t</template>\n\n\t\t\t\t<input\n\t\t\t\t\t:id=\"id\"\n\t\t\t\t\tref=\"input\"\n\t\t\t\t\tv-model=\"query\"\n\t\t\t\t\t:autocomplete=\"autocomplete\"\n\t\t\t\t\t:autofocus=\"autofocus\"\n\t\t\t\t\t:class=\"'bb-base-select__text-input'\"\n\t\t\t\t\t:disabled=\"disabled\"\n\t\t\t\t\t:placeholder=\"computedPlaceholder\"\n\t\t\t\t\t:readonly=\"readonly || !allowWriting\"\n\t\t\t\t\t:type=\"'text'\"\n\t\t\t\t\t@blur.stop=\"onInputBlur\"\n\t\t\t\t\t@change.stop=\"onInputChange\"\n\t\t\t\t\t@focus.stop=\"onInputFocus\"\n\t\t\t\t\t@input.stop=\"onInputInput\"\n\t\t\t\t\t@keydown.stop=\"onInputKeyDown\"\n\t\t\t\t/>\n\t\t\t\t<teleport to=\"body\">\n\t\t\t\t\t<span\n\t\t\t\t\t\tref=\"optionsContainer\"\n\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t'bb-base-select__options-container': true,\n\t\t\t\t\t\t\t'bb-base-select__options-container--shown': shown,\n\t\t\t\t\t\t\t'bb-base-select__options-container--showing': showing,\n\t\t\t\t\t\t\t'bb-base-select__options-container--hiding': hiding,\n\t\t\t\t\t\t\t'bb-base-select__options-container--hidden': hidden,\n\t\t\t\t\t\t}\"\n\t\t\t\t\t\t:role=\"'listbox'\"\n\t\t\t\t\t\t:style=\"{ transitionDuration }\"\n\t\t\t\t\t\t:tabindex=\"-1\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<slot name=\"options:prepend\"></slot>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tv-if=\"!filteredOptions.length && loading\"\n\t\t\t\t\t\t\tclass=\"bb-base-select__loading-container\"\n\t\t\t\t\t\t\t><slot :name=\"'loading'\" :query=\"query\">{{\n\t\t\t\t\t\t\t\tloadingText\n\t\t\t\t\t\t\t}}</slot></span\n\t\t\t\t\t\t>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tv-else-if=\"!filteredOptions.length\"\n\t\t\t\t\t\t\tclass=\"bb-base-select__no-data-container\"\n\t\t\t\t\t\t\t><slot :name=\"'no-data'\" :query=\"query\">{{\n\t\t\t\t\t\t\t\tnoDataText\n\t\t\t\t\t\t\t}}</slot></span\n\t\t\t\t\t\t>\n\t\t\t\t\t\t<template v-for=\"option in filteredOptions\" :key=\"option.id\">\n\t\t\t\t\t\t\t<slot :item=\"option.original\" name=\"option:prepend\"></slot>\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t:id=\"option.id\"\n\t\t\t\t\t\t\t\t:aria-selected=\"option.selected\"\n\t\t\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t\t\t'bb-base-select-option': true,\n\t\t\t\t\t\t\t\t\t'bb-base-select-option--selected': option.selected,\n\t\t\t\t\t\t\t\t\t'bb-base-select-option--focused': option.focused,\n\t\t\t\t\t\t\t\t\t'bb-base-select-option--disabled': option.disabled,\n\t\t\t\t\t\t\t\t}\"\n\t\t\t\t\t\t\t\t:role=\"'option'\"\n\t\t\t\t\t\t\t\t@click.stop=\"onOptionClicked\"\n\t\t\t\t\t\t\t\t><slot\n\t\t\t\t\t\t\t\t\t:disabled=\"option.disabled\"\n\t\t\t\t\t\t\t\t\t:focused=\"option.focused\"\n\t\t\t\t\t\t\t\t\t:has-errors=\"hasErrors\"\n\t\t\t\t\t\t\t\t\t:index=\"option.index\"\n\t\t\t\t\t\t\t\t\t:item=\"option.original\"\n\t\t\t\t\t\t\t\t\t:loading=\"!!loading\"\n\t\t\t\t\t\t\t\t\t:manual=\"option.manual\"\n\t\t\t\t\t\t\t\t\tname=\"option\"\n\t\t\t\t\t\t\t\t\t:selected=\"option.selected\"\n\t\t\t\t\t\t\t\t\t:text=\"option.text\"\n\t\t\t\t\t\t\t\t\t:value=\"option.value\"\n\t\t\t\t\t\t\t\t\t><span class=\"bb-base-select-option__content\"\n\t\t\t\t\t\t\t\t\t\t><span class=\"bb-base-select-option__text\">{{\n\t\t\t\t\t\t\t\t\t\t\toption.text\n\t\t\t\t\t\t\t\t\t\t}}</span></span\n\t\t\t\t\t\t\t\t\t></slot\n\t\t\t\t\t\t\t\t></span\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<slot :item=\"option.original\" name=\"option:append\"></slot>\n\t\t\t\t\t\t</template>\n\t\t\t\t\t\t<slot name=\"options:append\"></slot>\n\t\t\t\t\t</span>\n\t\t\t\t</teleport>\n\t\t\t</span>\n\t\t\t<span class=\"bb-base-select__chevron\">\n\t\t\t\t<slot :loading=\"!!loading\" name=\"chevron\" :shown=\"shown\">\n\t\t\t\t\t<svg\n\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\tviewBox=\"0 0 16 8\"\n\t\t\t\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<path\n\t\t\t\t\t\t\tclip-rule=\"evenodd\"\n\t\t\t\t\t\t\td=\"M0.851779 0.225802C0.90403 0.173418 0.966103 0.131858 1.03444 0.1035C1.10278 0.0751431 1.17604 0.0605469 1.25003 0.0605469C1.32402 0.0605469 1.39728 0.0751431 1.46562 0.1035C1.53396 0.131858 1.59603 0.173418 1.64828 0.225802L8.00003 6.57868L14.3518 0.225802C14.4041 0.173503 14.4662 0.132017 14.5345 0.103713C14.6028 0.0754093 14.6761 0.0608414 14.75 0.0608414C14.824 0.0608414 14.8972 0.0754093 14.9656 0.103713C15.0339 0.132017 15.096 0.173503 15.1483 0.225802C15.2006 0.278101 15.2421 0.340189 15.2704 0.408521C15.2987 0.476852 15.3132 0.55009 15.3132 0.624052C15.3132 0.698014 15.2987 0.771252 15.2704 0.839584C15.2421 0.907916 15.2006 0.970003 15.1483 1.0223L8.39828 7.7723C8.34603 7.82469 8.28395 7.86625 8.21562 7.8946C8.14728 7.92296 8.07402 7.93756 8.00003 7.93756C7.92604 7.93756 7.85278 7.92296 7.78444 7.8946C7.7161 7.86625 7.65403 7.82469 7.60178 7.7723L0.851779 1.0223C0.799395 0.970051 0.757835 0.907978 0.729477 0.83964C0.70112 0.771302 0.686523 0.69804 0.686523 0.624052C0.686523 0.550064 0.70112 0.476803 0.729477 0.408464C0.757835 0.340126 0.799395 0.278053 0.851779 0.225802Z\"\n\t\t\t\t\t\t\tfill=\"currentColor\"\n\t\t\t\t\t\t\tfill-rule=\"evenodd\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</svg>\n\t\t\t\t</slot>\n\t\t\t</span>\n\t\t\t<slot v-if=\"!loading\" name=\"append\"></slot>\n\t\t\t<span\n\t\t\t\tv-else\n\t\t\t\t:class=\"{\n\t\t\t\t\t'bb-base-select__spinner': true,\n\t\t\t\t\t'bb-base-select__spinner--loading': loading,\n\t\t\t\t}\"\n\t\t\t\t><slot :loading=\"!!loading\" :name=\"'spinner'\"\n\t\t\t\t\t><BbSpinner :size=\"'sm'\" /></slot\n\t\t\t></span>\n\t\t</span>\n\t\t<slot name=\"append-outer\"></slot>\n\t\t<input v-for=\"input in hiddenInputs\" :key=\"input.value\" v-bind=\"input\" />\n\t</span>\n</template>\n\n<script setup lang=\"ts\" generic=\"T = any\">\nimport BbChip from '../BbChip/BbChip.vue';\nimport BbSpinner from '../BbSpinner/BbSpinner.vue';\nimport {\n\tautoUpdate,\n\tcomputePosition,\n\tflip,\n\toffset,\n\tshift,\n} from '@floating-ui/dom';\nimport {\n\tcomputed,\n\tnextTick,\n\tonBeforeUnmount,\n\tonMounted,\n\tref,\n\twatch,\n} from 'vue';\nimport { deepEqual } from 'fast-equals';\nimport { head } from '@/utilities/functions/head';\nimport { isNotNil } from '@/utilities/functions/isNotNil';\nimport { last } from '@/utilities/functions/last';\nimport { useItemText } from '@/composables/useItemText';\nimport { useItemValue } from '@/composables/useItemValue';\nimport { wait } from '@/utilities/functions/wait';\nimport { waitFor } from '@/utilities/functions/waitFor';\nimport { when } from '@/utilities/functions/when';\nimport type { ComputedRef, HTMLAttributes, InputHTMLAttributes } from 'vue';\nimport type { NestedKeyOf } from '@/types/NestedKeyOf';\n\nexport type BaseSelectProps<T> = {\n\t/**\n\t * Allows typing into the input.\n\t */\n\tallowWriting?: boolean;\n\n\t/**\n\t * Guides to the browser as to the type of information expected in the field.\n\t */\n\tautocomplete?: InputHTMLAttributes['autocomplete'];\n\n\t/**\n\t * Sets autofocus on page load.\n\t */\n\tautofocus?: InputHTMLAttributes['autofocus'];\n\t/**\n\t * Logs messages for debugging purposes.\n\t */\n\tdebug?: boolean;\n\n\t/**\n\t * Defines an array of dependencies that will trigger actions in the component upon change.\n\t */\n\tdependencies?: any[];\n\n\t/**\n\t * Timeout used to debounce response to changes to dependencies.\n\t */\n\tdepsDebounceTime?: number;\n\n\t/**\n\t * Disables the component\n\t */\n\tdisabled?: boolean;\n\n\t/**\n\t * If coherence is enforce the input cannot have a modelValue the is incoherent with its current items.\n\t *\n\t * e.g. You cannot set v-model to a user that is not present in the items passed.\n\t *\n\t * modelValue will be reset upon incoherence.\n\t */\n\tenforceCoherence?: boolean;\n\n\t/**\n\t * Define if the component should be in an error state.\n\t * It usually attaches a CSS class for styling purposes.\n\t */\n\thasErrors?: boolean;\n\n\t/**\n\t * The identifier of the component.\n\t */\n\tid?: HTMLAttributes['id'];\n\n\t/**\n\t * String displayed while items are being loaded.\n\t */\n\tloadingText?: string;\n\n\t/**\n\t * Defines the strategy used to understand whether an option has been selected.\n\t * `string` is 40% faster but relies on property order.\n\t * `equality` is more reliable but is slower.\n\t */\n\tmatchStrategy?: 'string' | 'equality';\n\n\t/**\n\t * Timeout used to debounce response to changes to modelValue.\n\t */\n\tmodelValueDebounceTime?: number;\n\n\t/**\n\t * Allows the selection of multiple items.\n\t */\n\tmultiple?: boolean;\n\n\t/**\n\t * Defines the name of the input.\n\t */\n\tname?: InputHTMLAttributes['name'];\n\n\t/**\n\t * String displayed when there are no items to display.\n\t */\n\tnoDataText?: string;\n\n\t/**\n\t * String displayed when there's no data.\n\t */\n\tplaceholder?: InputHTMLAttributes['placeholder'];\n\n\t/**\n\t * Sets the input in a readonly state.\n\t */\n\treadonly?: InputHTMLAttributes['readonly'];\n\n\t/**\n\t * How long the transition has to last in milliseconds\n\t */\n\ttransitionDuration?: number;\n\t/**\n\t * Used to retrieve items can be an array or a function.\n\t */\n\titems:\n\t\t| T[]\n\t\t| ((query: string, prefill: boolean, modelValue: any) => Promise<T[]>)\n\t\t| ((query: string, prefill: boolean, modelValue: any) => T[]);\n\n\t/**\n\t * Defines a path that returns a property of the object to use as text or a function that returns a string\n\t */\n\titemText?: T extends object\n\t\t? NestedKeyOf<T> | ((item: T) => string)\n\t\t: ((item: T) => string) | undefined;\n\n\t/**\n\t * Defines a path that returns a property of the object to use as value or a function that returns any value\n\t */\n\titemValue?: T extends object\n\t\t? NestedKeyOf<T> | ((item: T) => string)\n\t\t: ((item: T) => any) | undefined;\n\t/**\n\t * Used by v-model. Can be any serializable type.\n\t */\n\tmodelValue: any;\n\n\t/**\n\t * Allows the user to add options to the list by\n\t * inserting text in the input and pressing ENTER.\n\t * The value and text of the option generated is a\n\t * string equal to what has been inserted.\n\t */\n\taddOptions?: boolean;\n\t/**\n\t * Sets the display model for selected values to a list\n\t * of comma separated string. In this mode the user\n\t * cannot deselect an option by pressing the close button.\n\t */\n\tcomma?: boolean;\n\t/**\n\t * Defines how the filtering should work.\n\t * In any case options are always filtered by the text displayed but\n\t * they can also take into account other properties of the\n\t * passed elements when this property is a string or an array of string.\n\t * E.g. items could be a list of users and you can filter users by email or phone by passing `['email', 'phone']`\n\t * You can also pass false to not filter anything or a function for more granular control.\n\t *\n\t */\n\tfilterBy?:\n\t\t| string\n\t\t| string[]\n\t\t| false\n\t\t| ((value: any, item: T) => boolean)\n\t\t| null;\n\t/**\n\t * Defines the prefill strategy for the input. By default the input will prefill\n\t * on focus. It can also always prefill with `true` and only prefill on search with `false`.\n\t */\n\tprefill?: boolean | 'focus';\n\t/**\n\t * Time to wait when the users stops writing in the input before querying data.\n\t * Especially useful when searching live data on big datasets.\n\t */\n\tqueryDebounceTime?: number;\n\t/**\n\t * If `true` when in multiple selection, reset the query immediately\n\t * upon selecting an option. By default the query is\n\t * not reset until focus is lost so the user can search\n\t * for \"Cath\" and select \"Cathy\" and then write more to\n\t * search for \"Catherine\"\n\t */\n\tresetQueryOnOptionSelected?: boolean;\n\t/**\n\t * Adds a stash to accumulate selected values. Especially\n\t * useful when searching in a big database of items.\n\t * E.g. if you search for \"John\" and then search for \"Richard\"\n\t * you either always return the previous items or you stash them passing `true` to this option.\n\t */\n\tstash?: boolean;\n\t/**\n\t * Pass `true` if the dropdown is not updating following movement in the UI, like in modals. Very expensive so use with care.\n\t */\n\tupdateOnAnimationFrame?: boolean;\n};\n\nexport type BaseOption<T> = {\n\tid: string;\n\tjsonValue: string;\n\tmanual: boolean;\n\toriginal: T;\n\ttext: string;\n\tvalue: any;\n\tdisabled: boolean;\n};\n\nexport type Option<T> = BaseOption<T> & {\n\tindex: number;\n\tselected: boolean;\n};\n\nexport type FilteredOption<T> = Option<T> & {\n\tfocused: boolean;\n};\n\nexport type BaseSelectEvents = {\n\t(e: 'blur', event: FocusEvent): void;\n\t(e: 'change', event: Event): void;\n\t(e: 'click', event: MouseEvent): void;\n\t(e: 'focus', event: FocusEvent): void;\n\t(e: 'inactive'): void;\n\t(e: 'input', event: Event): void;\n\t(e: 'update:modelValue', value: any): void;\n};\n\nexport type BaseSelectSlots<T> = {\n\t'prepend-outer'?: (props: {}) => any;\n\tprepend?: (props: {}) => any;\n\t'options:prepend'?: (props: {}) => any;\n\tloading?: (props: { query: string }) => any;\n\t'no-data'?: (props: { query: string }) => any;\n\t'option:prepend'?: (props: { item: T }) => any;\n\tchip?: (props: {\n\t\tdisabled: boolean;\n\t\thasErrors?: boolean;\n\t\tindex: number;\n\t\titem: T;\n\t\tloading: boolean;\n\t\tmanual: boolean;\n\t\tselected: boolean;\n\t\ttext: string;\n\t\tvalue: any;\n\t}) => any;\n\toption?: (props: {\n\t\tdisabled: boolean;\n\t\tfocused: boolean;\n\t\thasErrors?: boolean;\n\t\tindex: number;\n\t\titem: T;\n\t\tloading: boolean;\n\t\tmanual: boolean;\n\t\tselected: boolean;\n\t\ttext: string;\n\t\tvalue: any;\n\t}) => any;\n\t'option:append'?: (props: { item: T }) => any;\n\t'options:append'?: (props: {}) => any;\n\tchevron?: (props: { loading: boolean; shown: boolean }) => any;\n\tappend?: (props: {}) => any;\n\tspinner?: (props: { loading: boolean }) => any;\n\t'append-outer'?: (props: {}) => any;\n};\n\nconst props = withDefaults(defineProps<BaseSelectProps<T>>(), {\n\tallowWriting: true,\n\tdepsDebounceTime: 0,\n\tfilterBy: () => [],\n\tloadingText: 'Caricamento...',\n\tmatchStrategy: 'string',\n\tmodelValueDebounceTime: 0,\n\tnoDataText: 'Nessun elemento da visualizzare',\n\tprefill: 'focus',\n\tqueryDebounceTime: 500,\n\ttransitionDuration: 200,\n\tupdateOnAnimationFrame: false,\n});\n\nconst emit = defineEmits<BaseSelectEvents>();\n\ndefineSlots<BaseSelectSlots<T>>();\n\nif (props.multiple && !Array.isArray(props.modelValue)) {\n\tthrow new Error('Multiple is set to \"true\" but modelValue is not an array.');\n}\n\nconst outerContainer = ref<HTMLElement | null>(null);\nconst innerContainer = ref<HTMLElement | null>(null);\nconst optionsContainer = ref<HTMLElement | null>(null);\nconst input = ref<HTMLElement | null>(null);\nconst query = ref<string>('');\nconst computedPlaceholder = computed(() => {\n\tif (selectedOptions.value.length) return '';\n\telse return props.placeholder;\n});\n/**\n * Use a number accumulator because if the fn takes 5 seconds\n * and after 2 seconds another search is run\n * When the first returns the second is still out for 2 seconds\n * and we want to track them both.\n * Debounce will not be enough.\n */\nconst loading = ref(0);\nconst transitionDuration = props.transitionDuration / 1000 + 's';\nlet cleanUpPositioning: () => void;\n\nonMounted(async () => {\n\tif (props.debug) console.log('Calling onMounted');\n\n\tif (innerContainer.value && optionsContainer.value) {\n\t\tcleanUpPositioning = autoUpdate(\n\t\t\tinnerContainer.value,\n\t\t\toptionsContainer.value,\n\t\t\tdisplayOptions,\n\t\t\t{\n\t\t\t\tancestorResize: true,\n\t\t\t\tancestorScroll: true,\n\t\t\t\tanimationFrame: props.updateOnAnimationFrame,\n\t\t\t\telementResize: true,\n\t\t\t}\n\t\t);\n\t}\n});\nonBeforeUnmount(() => {\n\tif (props.debug) console.log('Calling onBeforeUnMount');\n\tcleanUpPositioning();\n});\n\nconst internalItems = ref<T[]>([]);\nconst stash = ref<BaseOption<T>[]>([]);\nconst manualItems = ref<BaseOption<T>[]>([]);\nconst { getItemText } = useItemText();\nconst { getItemValue } = useItemValue();\n\nconst internalOptions = computed<BaseOption<T>[]>(() => {\n\treturn internalItems.value.map((item: any, _) => {\n\t\tif (props.debug) console.log('Mapping items in internalOptions', { item });\n\t\tconst text = getItemText(item, props.itemText as any);\n\t\tconst value = getItemValue(item, props.itemValue);\n\n\t\t// Undefined is not JSONable\n\t\tif (value === undefined)\n\t\t\tthrow new Error(\n\t\t\t\t'The result of extracting \"value\" from option was undefined. Affected item is ' +\n\t\t\t\t\tJSON.stringify(item) +\n\t\t\t\t\t' please check itemValue property is correct.'\n\t\t\t);\n\n\t\tconst jsonValue = JSON.stringify(value);\n\t\treturn {\n\t\t\tdisabled: !!item.disabled,\n\t\t\tid: 'option_' + jsonValue.replace(/\\W/g, '_'),\n\t\t\tjsonValue,\n\t\t\tmanual: false,\n\t\t\toriginal: item,\n\t\t\ttext,\n\t\t\tvalue,\n\t\t};\n\t});\n});\n\nconst options = computed<Option<T>[]>(() => {\n\tlet fromOptions = internalOptions.value.reduce(\n\t\t(acc: { [key: string]: BaseOption<T> }, curr: BaseOption<T>) => {\n\t\t\tacc[curr.id] = curr;\n\t\t\treturn acc;\n\t\t},\n\t\t{}\n\t);\n\tconst withManual: { [key: string]: BaseOption<T> } = manualItems.value.reduce(\n\t\t(acc, curr) => {\n\t\t\tif (!acc[curr.id]) acc[curr.id] = curr as any;\n\t\t\treturn acc;\n\t\t},\n\t\tfromOptions\n\t);\n\tconst withStash: { [key: string]: BaseOption<T> } = stash.value.reduce(\n\t\t(acc, curr) => {\n\t\t\tif (!acc[curr.id]) acc[curr.id] = curr as any;\n\t\t\treturn acc;\n\t\t},\n\t\twithManual\n\t);\n\tif (props.debug)\n\t\tconsole.log('Computing options in options', {\n\t\t\tfromOptions,\n\t\t\twithManual,\n\t\t\twithStash,\n\t\t});\n\treturn Object.values(withStash).map<Option<T>>(\n\t\t(option: BaseOption<T>, index) => {\n\t\t\treturn {\n\t\t\t\t...option,\n\t\t\t\tselected: isNotNil(modelValueIndexed.value.get(option.value)),\n\t\t\t\tindex,\n\t\t\t};\n\t\t}\n\t);\n});\n\n/**\n * Filter options to be displayed based on the current query.\n * If no query is used or when query is set from the inside (after a selection) display all possible options\n */\nconst filteredOptions = computed<FilteredOption<T>[]>(() => {\n\tif (props.debug) console.log('Computing filtered options');\n\tlet base = [];\n\t/** Only filter when a value is being searched not when the query is fully set on a selected option text */\n\tif (\n\t\tquery.value &&\n\t\t!selectedOptions.value.some(\n\t\t\t(option: Option<T>) => option.text === query.value\n\t\t)\n\t) {\n\t\tbase = options.value.filter((item: Option<T>) => {\n\t\t\tlet matchedAnything = false;\n\t\t\tif (!props.filterBy) return true;\n\t\t\telse if (typeof props.filterBy === 'function')\n\t\t\t\tmatchedAnything = props.filterBy(item.value, item.original);\n\t\t\telse if (props.filterBy.length) {\n\t\t\t\tconst keys = ([] as string[]).concat(props.filterBy);\n\t\t\t\tfor (let index = 0; index < keys.length; index++) {\n\t\t\t\t\tconst propName = keys[index];\n\t\t\t\t\tmatchedAnything =\n\t\t\t\t\t\tmatchedAnything ||\n\t\t\t\t\t\t((item.original as any)[propName] &&\n\t\t\t\t\t\t\t(item.original as any)[propName]\n\t\t\t\t\t\t\t\t.toLowerCase()\n\t\t\t\t\t\t\t\t.includes(query.value.toLowerCase()));\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn (\n\t\t\t\tmatchedAnything ||\n\t\t\t\titem.text.toLowerCase().includes(query.value.toLowerCase())\n\t\t\t);\n\t\t});\n\t\t/** Otherwise defaul;t to the whole set of options */\n\t} else base = options.value;\n\t/** This is done here so that only visible options are highlighted */\n\treturn base.map((option: Option<T>, index) => ({\n\t\t...option,\n\t\tfocused: normalizedFocusedIndex.value === index,\n\t}));\n});\n\n/**\n * Indexes options by id for retrieval\n */\n\nconst optionsIndexedById = computed<{\n\t[key: string]: Option<T>;\n}>(() =>\n\toptions.value.reduce(\n\t\t(acc, curr) => ({\n\t\t\t...acc,\n\t\t\t[curr.id]: curr,\n\t\t}),\n\t\t{}\n\t)\n);\n\n/**\n * Indexes options by their value\n * (using JSON to circumvent identical objects not being equal in JS)\n */\nconst optionsIndexedByValue = computed(() => {\n\tif (props.debug) console.log('Computing optionsIndexedByValue');\n\tif (props.matchStrategy === 'string') {\n\t\tlet indexed = options.value.reduce(\n\t\t\t(acc: { [key: string]: Option<T> }, curr: Option<T>) => {\n\t\t\t\tacc[curr.jsonValue] = curr;\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t\treturn {\n\t\t\tget: (key: any) => {\n\t\t\t\treturn indexed[JSON.stringify(key)];\n\t\t\t},\n\t\t};\n\t} else if (props.matchStrategy === 'equality') {\n\t\tlet indexed: [any, Option<T>][] = options.value.map((option) => [\n\t\t\toption.value,\n\t\t\toption,\n\t\t]);\n\n\t\treturn {\n\t\t\tget: (key: any) => {\n\t\t\t\treturn indexed.find((pairs) => deepEqual(pairs[0], key))?.[1];\n\t\t\t},\n\t\t};\n\t} else {\n\t\tthrow new Error('No match strategy has been defined');\n\t}\n});\n\n/**\n * Indexes modelValue to a map so when can easily know which values are selected\n * (using JSON to circumvent identical object not being equal in JS)\n */\nconst modelValueIndexed = computed(() => {\n\tif (props.debug) console.log('Computing modelValueIndexed');\n\tif (props.matchStrategy === 'string') {\n\t\tlet map: { [key: string]: number } = {};\n\t\t[].concat(props.modelValue).forEach((value: any, index: number) => {\n\t\t\tmap[JSON.stringify(value)] = index;\n\t\t});\n\t\treturn {\n\t\t\tget: (value: any) => map[JSON.stringify(value)],\n\t\t};\n\t} else if (props.matchStrategy === 'equality') {\n\t\tconst map = []\n\t\t\t.concat(props.modelValue)\n\t\t\t.filter(isNotNil)\n\t\t\t.map((value, index) => [value, index]);\n\n\t\treturn {\n\t\t\tget: (key: any) => {\n\t\t\t\treturn map.find((pairs) => deepEqual(pairs[0], key))?.[1];\n\t\t\t},\n\t\t};\n\t} else {\n\t\tthrow new Error('No match strategy has been defined');\n\t}\n});\n\n/**\n * For every item in modelValue find the linked option if it exists.\n * This is used to display chips.\n */\nconst selectedOptions = computed(() => {\n\tif (props.debug) console.log('Computing selectedOptions');\n\treturn [].concat(props.modelValue).reduce((acc: Option<T>[], curr: any) => {\n\t\tconst linkedOption = optionsIndexedByValue.value.get(curr);\n\t\tif (linkedOption) acc.push(linkedOption);\n\t\treturn acc;\n\t}, []);\n});\n\n/**\n * When selecting an option split behavior based on single or multiple selection\n */\nconst onOptionSelected = (option: Option<T>) => {\n\tif (props.debug) console.log('Running onOptionSelected', { option });\n\tlet valueToEmit;\n\tfocusedIndex.value = option.index;\n\t/**\n\t * For single selection:\n\t * If the option was already selected - restore the value to default, clean the stash, manual items, and query.\n\t * If the option was not selected - use its value, save the option in the stash and display it's text as query\n\t * The stash is used to remove the complexity of stashing items when searching for identifying information,\n\t * like searching an address would not return the option that was used to selected a previous address in another country.\n\t * Or when searching users by username would not return the previous ones.\n\t * We save it so the user hasn't to.\n\t */\n\tif (!props.multiple) {\n\t\tif (option.selected) {\n\t\t\tif (option.manual) {\n\t\t\t\tif (props.debug)\n\t\t\t\t\tconsole.log('onOptionSelected: inside single > selected > manual');\n\t\t\t\tmanualItems.value = manualItems.value.filter(\n\t\t\t\t\t(current: any) => current.id !== option.id\n\t\t\t\t);\n\t\t\t}\n\t\t\tvalueToEmit = null;\n\t\t\tif (props.stash) {\n\t\t\t\tif (props.debug)\n\t\t\t\t\tconsole.log('onOptionSelected: inside single > selected > stash');\n\t\t\t\tstash.value = [];\n\t\t\t}\n\t\t\tquery.value = '';\n\t\t} else {\n\t\t\tif (props.debug)\n\t\t\t\tconsole.log('onOptionSelected: inside single > not selected');\n\t\t\tvalueToEmit = option.value;\n\t\t\tif (props.stash) {\n\t\t\t\tif (props.debug)\n\t\t\t\t\tconsole.log('onOptionSelected: inside single > not selected > stash');\n\t\t\t\tstash.value = [option as any];\n\t\t\t}\n\t\t\tquery.value = option.text;\n\t\t}\n\t\t/**\n\t\t * For multiple selection\n\t\t * If the option was selected remove it from modelValue, if it is a mnaual iutem also remove it from there.\n\t\t * In the stash we can search for the id of the option.\n\t\t * If the option was not selected we can just add it to modelValue and the stash.\n\t\t */\n\t} else {\n\t\tif (option.selected) {\n\t\t\tif (option.manual) {\n\t\t\t\tif (props.debug)\n\t\t\t\t\tconsole.log('onOptionSelected: inside multiple > selected > manual');\n\t\t\t\tmanualItems.value = manualItems.value.filter(\n\t\t\t\t\t(current: any) => current.id !== option.id\n\t\t\t\t);\n\t\t\t}\n\t\t\tvalueToEmit = props.modelValue.filter(\n\t\t\t\t(value: any) => JSON.stringify(value) !== option.jsonValue\n\t\t\t);\n\t\t\tif (props.stash) {\n\t\t\t\tif (props.debug)\n\t\t\t\t\tconsole.log('onOptionSelected: inside multiple > selected > stash');\n\t\t\t\tstash.value = stash.value.filter((stashed) => stashed.id !== option.id);\n\t\t\t}\n\t\t} else {\n\t\t\tif (props.debug)\n\t\t\t\tconsole.log('onOptionSelected: inside multiple > not selected');\n\t\t\tvalueToEmit = props.modelValue.concat(option.value);\n\t\t\tif (props.stash) {\n\t\t\t\tif (props.debug)\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t'onOptionSelected: inside multiple > not selected > stash'\n\t\t\t\t\t);\n\t\t\t\tstash.value = stash.value.concat(option as any);\n\t\t\t}\n\t\t}\n\t\tif (props.resetQueryOnOptionSelected) {\n\t\t\tif (props.debug) console.log('onOptionSelected: resetting query');\n\t\t\tquery.value = '';\n\t\t}\n\t}\n\temit('update:modelValue', valueToEmit);\n};\n\nconst getOptions = async ({ prefill = false }) => {\n\tif (props.debug) console.log('running getOptions');\n\tlet items: T[] = [];\n\tif (Array.isArray(props.items)) {\n\t\titems = props.items;\n\t} else {\n\t\tif (typeof props.items === 'function') {\n\t\t\tloading.value++;\n\t\t\titems = await props.items(query.value, prefill, props.modelValue);\n\t\t\tloading.value--;\n\t\t}\n\t}\n\tinternalItems.value = items as any;\n};\n\n/**\n * Add an option to the manual items and then reset the query\n */\nconst addOption = () => {\n\tif (props.debug) console.log('running addOption');\n\tconst text = query.value;\n\tconst value = query.value;\n\tconst jsonValue = JSON.stringify(value);\n\tconst option = {\n\t\ttext,\n\t\tvalue,\n\t\tjsonValue,\n\t\tid: 'option_' + jsonValue.replace(/\\W/g, '_'),\n\t\toriginal: value,\n\t\tmanual: true,\n\t\tdisabled: false,\n\t};\n\tmanualItems.value = manualItems.value.concat(option as any);\n\tquery.value = '';\n};\n\n/**\n * It should prefill if asked, or\n * when single if modelValue is not null\n * when multiple if modelValue is not empty\n */\nconst shouldPrefill =\n\tprops.prefill === true ||\n\t(!props.multiple && isNotNil(props.modelValue)) ||\n\t(props.multiple && !!props.modelValue.length);\n/**\n * When modelValue changes split behavior for single and multiple selection:\n */\nlet modelValueTimeout: ReturnType<typeof setTimeout>;\nlet hasRunOnce = false;\nwatch(\n\t() => props.modelValue,\n\t(current, previous) => {\n\t\tif (props.debug) console.log('running watch.modelValue');\n\t\tif (modelValueTimeout) clearTimeout(modelValueTimeout);\n\t\tmodelValueTimeout = setTimeout(\n\t\t\tasync () => {\n\t\t\t\t/**\n\t\t\t\t * For single selection if the value is already in the option (most likely you are using\n\t\t\t\t * static items) just use it.\n\t\t\t\t * If the value is not in the options try searching for it (outside dependencies may fix it).\n\t\t\t\t * If at last the value cannot be found even after searching\n\t\t\t\t * reset value to the default value when coherence is enforced\n\t\t\t\t * or at least do not display the old query\n\t\t\t\t */\n\t\t\t\tif (!props.multiple) {\n\t\t\t\t\tif (props.debug) console.log('watch.modelValue >> single');\n\t\t\t\t\tlet found = optionsIndexedByValue.value.get(props.modelValue);\n\t\t\t\t\tif (\n\t\t\t\t\t\t(!found && isNotNil(props.modelValue)) ||\n\t\t\t\t\t\tprevious === undefined\n\t\t\t\t\t) {\n\t\t\t\t\t\tif (props.debug)\n\t\t\t\t\t\t\tconsole.log('watch.modelValue >> not found line 895');\n\t\t\t\t\t\tconst currentQuery = query.value;\n\t\t\t\t\t\tquery.value = '';\n\t\t\t\t\t\tawait getOptions({ prefill: true });\n\t\t\t\t\t\tquery.value = currentQuery;\n\t\t\t\t\t}\n\t\t\t\t\tfound = optionsIndexedByValue.value.get(props.modelValue);\n\t\t\t\t\tif (found) {\n\t\t\t\t\t\tif (props.debug) console.log('watch.modelValue >> found');\n\t\t\t\t\t\tquery.value = found.text;\n\t\t\t\t\t\tif (props.debug) console.log('watch.modelValue assigned to query');\n\t\t\t\t\t\tif (props.stash) {\n\t\t\t\t\t\t\tstash.value = [found as any];\n\t\t\t\t\t\t\tif (props.debug)\n\t\t\t\t\t\t\t\tconsole.log('watch.modelValue assigned to stash');\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (props.debug) console.log('watch.modelValue end of found');\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (props.enforceCoherence && isNotNil(current)) {\n\t\t\t\t\t\t\tif (props.debug)\n\t\t\t\t\t\t\t\tconsole.log('watch.modelValue >> not found line 911');\n\t\t\t\t\t\t\tquery.value = '';\n\t\t\t\t\t\t\tif (props.stash) {\n\t\t\t\t\t\t\t\tstash.value = [];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\temit('update:modelValue', null);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tquery.value = '';\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t/**\n\t\t\t\t\t * For multiple selection if every value is already in the options (most likely you are using\n\t\t\t\t\t * static items) just use them.\n\t\t\t\t\t * If not all the values are in the current options or is prefilling try searching (outside depencencies may fix the situation).\n\t\t\t\t\t * If the values are still not in the available options and coherence is enforced\n\t\t\t\t\t * discard the ones that are invalid.\n\t\t\t\t\t *\n\t\t\t\t\t */\n\t\t\t\t} else {\n\t\t\t\t\tif (!Array.isArray(props.modelValue)) {\n\t\t\t\t\t\tthrow new Error('props.modelValue is not an array.');\n\t\t\t\t\t}\n\t\t\t\t\tlet allFound = props.modelValue.every((value: any) =>\n\t\t\t\t\t\toptionsIndexedByValue.value.get(value)\n\t\t\t\t\t);\n\t\t\t\t\tif (!allFound || previous === undefined) {\n\t\t\t\t\t\tawait getOptions({ prefill: true });\n\t\t\t\t\t\tallFound = props.modelValue.every((value: any) =>\n\t\t\t\t\t\t\toptionsIndexedByValue.value.get(value)\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (allFound) {\n\t\t\t\t\t\tif (props.stash) {\n\t\t\t\t\t\t\tstash.value = props.modelValue.map(\n\t\t\t\t\t\t\t\t(value: any) => optionsIndexedByValue.value.get(value)!\n\t\t\t\t\t\t\t) as any;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlet coherentStash: Option<T>[] = [];\n\t\t\t\t\t\tconst coherent = current.filter((value: any) => {\n\t\t\t\t\t\t\tlet found = optionsIndexedByValue.value.get(value);\n\t\t\t\t\t\t\tif (found) coherentStash.push(found);\n\t\t\t\t\t\t\treturn found;\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (props.stash) {\n\t\t\t\t\t\t\tstash.value = coherentStash as any;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (props.enforceCoherence) {\n\t\t\t\t\t\t\temit('update:modelValue', coherent);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tshouldPrefill ? 0 : props.modelValueDebounceTime\n\t\t);\n\t},\n\t// Prefill when asked or when items are static\n\t{ immediate: shouldPrefill, deep: true }\n);\n\n/**\n * This is triggered to refresh static items whenever the passed array changes.\n * If the parent defines an array in the template this is triggered\n * at every render so we take counter measures\n * Even if the entire array changes all the previously selected values are still in the stash.\n */\nwatch(\n\t() => props.items,\n\tasync (current, previous) => {\n\t\tif (\n\t\t\ttypeof current === 'function' ||\n\t\t\t// Circumvent arrays defined in the template by the parent\n\t\t\tJSON.stringify(current) !== JSON.stringify(previous)\n\t\t) {\n\t\t\tif (props.debug) console.log('watch.items');\n\t\t\tawait getOptions({ prefill: false });\n\t\t\tif (props.multiple) {\n\t\t\t\tconst allFound = props.modelValue.every((value: any) =>\n\t\t\t\t\toptionsIndexedByValue.value.get(value)\n\t\t\t\t);\n\n\t\t\t\tif (!allFound) {\n\t\t\t\t\tif (props.enforceCoherence) {\n\t\t\t\t\t\tconst coherent = props.modelValue.filter((value: any) => {\n\t\t\t\t\t\t\tlet found = optionsIndexedByValue.value.get(value);\n\t\t\t\t\t\t\treturn found;\n\t\t\t\t\t\t});\n\t\t\t\t\t\temit('update:modelValue', coherent);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlet found = optionsIndexedByValue.value.get(props.modelValue);\n\t\t\t\tif (!found && props.enforceCoherence && isNotNil(props.modelValue)) {\n\t\t\t\t\temit('update:modelValue', null);\n\t\t\t\t}\n\t\t\t\tfocusedIndex.value = null;\n\t\t\t}\n\t\t}\n\t}\n);\n\n/**\n * When dependencies change\n * If the input has not been prefilled yet just return\n * Check dependencies are the same by value and not reference\n * Otherwise we search again for options as they might be different base on dependencies.\n * If coherence is enforced we set the state accordingly\n */\nlet depsTimeout: ReturnType<typeof setTimeout>;\nwatch(\n\t() => props.dependencies,\n\t(current, previous) => {\n\t\tif (!shouldPrefill && props.prefill === 'focus' && isFirstFocus) {\n\t\t\treturn;\n\t\t}\n\t\t// Circumvent array defined in the template by the parent\n\t\tif (JSON.stringify(current) === JSON.stringify(previous)) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (depsTimeout) clearTimeout(depsTimeout);\n\t\tdepsTimeout = setTimeout(async () => {\n\t\t\tif (JSON.stringify(current) !== JSON.stringify(previous)) {\n\t\t\t\t// Only reset the stash if we are going to enforce coherence\n\t\t\t\tif (props.enforceCoherence) {\n\t\t\t\t\tif (props.stash) {\n\t\t\t\t\t\tstash.value = [];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Momentarily reset query\n\t\t\t\tlet currentQuery = query.value;\n\t\t\t\tquery.value = '';\n\t\t\t\tawait getOptions({ prefill: true });\n\t\t\t\tquery.value = currentQuery;\n\t\t\t\tif (!props.multiple) {\n\t\t\t\t\tlet found = optionsIndexedByValue.value.get(props.modelValue);\n\t\t\t\t\tif (!found && props.enforceCoherence && isNotNil(props.modelValue)) {\n\t\t\t\t\t\tquery.value = '';\n\t\t\t\t\t\tif (props.stash) {\n\t\t\t\t\t\t\tstash.value = [];\n\t\t\t\t\t\t}\n\t\t\t\t\t\temit('update:modelValue', null);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tlet allFound = props.modelValue.every((value: any) =>\n\t\t\t\t\t\toptionsIndexedByValue.value.get(value)\n\t\t\t\t\t);\n\t\t\t\t\tif (!allFound && props.enforceCoherence) {\n\t\t\t\t\t\tlet coherentStash: Option<T>[] = [];\n\t\t\t\t\t\tconst coherent = props.modelValue.filter((value: any) => {\n\t\t\t\t\t\t\tlet found = optionsIndexedByValue.value.get(value);\n\t\t\t\t\t\t\tif (found) coherentStash.push(found);\n\t\t\t\t\t\t\treturn found;\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (props.stash) {\n\t\t\t\t\t\t\tstash.value = coherentStash as any;\n\t\t\t\t\t\t}\n\t\t\t\t\t\temit('update:modelValue', coherent);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}, props.depsDebounceTime);\n\t},\n\t{ deep: true }\n);\n\n/**\n * This is used to position the option container.\n * When the linked item (outerContainer) updates its position\n * this is rerun by floating-UI\n */\nconst displayOptions = () => {\n\tif (props.debug) console.log('Running display options');\n\tif (innerContainer.value && optionsContainer.value) {\n\t\tcomputePosition(innerContainer.value, optionsContainer.value, {\n\t\t\tplacement: 'bottom',\n\t\t\tmiddleware: [offset(6), flip(), shift()],\n\t\t}).then((data) => {\n\t\t\tif (optionsContainer.value) {\n\t\t\t\toptionsContainer.value.style.left = `${data.x}px`;\n\t\t\t\toptionsContainer.value.style.top = `${data.y}px`;\n\t\t\t\toptionsContainer.value.style.width = `${innerContainer.value?.offsetWidth}px`;\n\t\t\t}\n\t\t});\n\t}\n};\n/**\n * We need the transitions because elements must be hidden and shown\n * to accessibility tools when they are fully closed or fully open,\n * while still being animated for sighted users.\n */\n\n// Option panel is open\nconst shown = ref(false);\n// Option panel is opening\nconst showing = ref(false);\n// option panel is closing\nconst hiding = ref(false);\n// Option panel il closed\nconst hidden = ref(true);\n\nconst open = async () => {\n\thidden.value = false;\n\tshowing.value = true;\n\tawait wait(props.transitionDuration);\n\tshowing.value = false;\n\tshown.value = true;\n};\n\nconst close = async () => {\n\tshown.value = false;\n\thiding.value = true;\n\tawait wait(props.transitionDuration);\n\thiding.value = false;\n\thidden.value = true;\n};\n\n/**\n * Applies a class when the user is inside this whole component.\n * We cannot use focus within as it doesn't work for elements that are teleported.\n * Also we cannot use the <input/> if we phisically move focus to the options so\n * we track it manually.\n */\nconst active = ref(false);\n\n/**\n * When the focus goes to the input we select the current text\n * so the user can replace or delete it.\n * On top of that if the prefill strategy is to prefill on first focus and options\n * weren't already retrieved by the watcher on mount, we do that\n */\nlet isFirstFocus = true;\nconst onInputFocus = async (event: FocusEvent) => {\n\tif (props.debug) console.log('Running onInputFocus');\n\temit('focus', event);\n\tactive.value = true;\n\tdocument.addEventListener('click', onClickOutside);\n\tdocument.addEventListener('focusin', onFocusOutside);\n\tif (input.value instanceof HTMLInputElement) input.value.select();\n\tif (props.prefill === 'focus' && isFirstFocus && !shouldPrefill) {\n\t\tawait getOptions({ prefill: true });\n\t\tisFirstFocus = false;\n\t}\n};\n\nconst onFocusOutside = async (event: FocusEvent) => {\n\tif (props.debug) console.log('Running onFocusOutside');\n\tif (event.target instanceof Node) {\n\t\tif (outerContainer.value && optionsContainer.value) {\n\t\t\tif (\n\t\t\t\t!outerContainer.value.contains(event.target) &&\n\t\t\t\t!optionsContainer.value.contains(event.target)\n\t\t\t) {\n\t\t\t\tclose();\n\t\t\t\temit('inactive');\n\t\t\t\tdocument.removeEventListener('focusin', onFocusOutside);\n\t\t\t\tactive.value = false;\n\t\t\t\tif (props.multiple) {\n\t\t\t\t\tawait wait(500);\n\t\t\t\t\tquery.value = '';\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n};\n\n/**\n * On single selection restore the query that might be partially altered by the user.\n * Input can blur either by clicking outside or clicking on an option.\n * We do nothing if the user has selected an option. And we restore the\n * query to its text if the user has moved focus\n */\nconst onInputBlur = async (event: FocusEvent) => {\n\tif (props.debug) console.log('Running onInputBlur');\n\temit('blur', event);\n\tif (!props.multiple) {\n\t\tconst currentModelValue = props.modelValue;\n\t\tawait nextTick();\n\t\tawait wait(300);\n\t\tif (outerContainer.value && optionsContainer.value) {\n\t\t\tconst active = document.activeElement;\n\t\t\tif (\n\t\t\t\t!outerContainer.value.contains(active) &&\n\t\t\t\t!optionsContainer.value.contains(active)\n\t\t\t) {\n\t\t\t\tconst found = optionsIndexedByValue.value.get(props.modelValue);\n\t\t\t\tif (found) {\n\t\t\t\t\tquery.value = found.text;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n};\n\nconst onInputChange = (event: Event) => emit('change', event);\n\n/**\n * Search at every input by the user.\n * When the user deletes the query unselect the current option\n */\nconst onInputInput = (event: Event) => {\n\tif (props.debug) console.log('Running onInputInput');\n\temit('input', event);\n\tif (query.value === '') {\n\t\tif (!props.multiple) {\n\t\t\temit('update:modelValue', null);\n\t\t}\n\t}\n\tif (typeof props.items === 'function') {\n\t\tsearchByQuery();\n\t}\n};\n\n// This is the vertical index used to highlight options in the container\nconst focusedIndex = ref<number | null>(null);\n/**\n * Normalize the index using the displayed options so we can start over when reaching the end.\n * Please watch out for the side effect it is used to avoid the\n * complexity of using modulo over negative numbers\n */\nconst normalizedFocusedIndex: ComputedRef<number | null> = computed(() => {\n\tif (Number.isInteger(focusedIndex.value) && focusedIndex.value) {\n\t\treturn focusedIndex.value % filteredOptions.value.length;\n\t}\n\treturn focusedIndex.value;\n});\n\n// This is the horizontal index used to highlight selected options\nconst selectedOptionsFocusedIndex = ref<number | null>(null);\n\n/**\n * Increment the focusIndex and wait for it to be normalized.\n * If the index corresponds to an option scroll it into view\n */\nconst focusOnNextOption = async () => {\n if (focusedIndex.value !== null) {\n focusedIndex.value = focusedIndex.value % options.value.length;\n } else {\n focusedIndex.value = 0;\n }\n\tawait nextTick();\n\tif (normalizedFocusedIndex.value !== null) {\n\t\tconst foundOption = optionsContainer.value?.querySelector(\n\t\t\t`#${options.value[normalizedFocusedIndex.value].id}`\n\t\t);\n\t\tif (foundOption instanceof HTMLElement)\n\t\t\tfoundOption.scrollIntoView({\n\t\t\t\tbehavior: 'smooth',\n\t\t\t\tblock: 'nearest',\n\t\t\t\tinline: 'start',\n\t\t\t});\n\t}\n};\n\n/**\n * Decrement the focusIndex and wait for it to be normalized.\n * If the index corresponds to an option scroll it into view\n */\nconst focusOnPreviousOption = async () => {\n if (focusedIndex.value !== null) {\n focusedIndex.value =\n focusedIndex.value === 0\n ? options.value.length - 1\n : focusedIndex.value - 1;\n } else focusedIndex.value = options.value.length - 1;\n\tawait nextTick();\n\tif (normalizedFocusedIndex.value !== null) {\n\t\tconst foundOption = optionsContainer.value?.querySelector(\n\t\t\t`#${options.value[normalizedFocusedIndex.value].id}`\n\t\t);\n\t\tif (foundOption instanceof HTMLElement)\n\t\t\tfoundOption.scrollIntoView({\n\t\t\t\tbehavior: 'smooth',\n\t\t\t\tblock: 'nearest',\n\t\t\t\tinline: 'start',\n\t\t\t});\n\t}\n};\n\n/**\n * This is handled separately from input because it has a lot to do with user\n * interaction and control characters than it has with the query.\n */\nconst onInputKeyDown = async (event: KeyboardEvent) => {\n\tif (props.readonly || props.disabled) {\n\t\tevent.preventDefault();\n\t\treturn;\n\t}\n\tswitch (event.key) {\n\t\t/**\n\t\t * On arrow prevent the page from scrolling.\n\t\t * Reset horizontal focus\n\t\t * When the panel is open\n\t\t * - Focus on the previous option\n\t\t * When the panel is closed\n\t\t * - focus on the first selected option\n\t\t */\n\t\tcase 'ArrowUp':\n\t\t\t{\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif (loading.value) return;\n\t\t\t\tselectedOptionsFocusedIndex.value = null;\n\t\t\t\tif (shown.value) {\n\t\t\t\t\tif (!filteredOptions.value.length) return;\n\t\t\t\t\tfocusOnPreviousOption();\n\t\t\t\t} else {\n\t\t\t\t\tif (selectedOptions.value.length) {\n\t\t\t\t\t\tfocusedIndex.value = head(selectedOptions.value).index;\n\t\t\t\t\t}\n\t\t\t\t\tawait open();\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t/**\n\t\t * On arrow prevent the page from scrolling.\n\t\t * Reset horizontal focus\n\t\t * When the panel is open\n\t\t * - Focus on the previous option\n\t\t * When the panel is closed\n\t\t * - focus on the first selected option\n\t\t */\n\t\tcase 'ArrowDown':\n\t\t\t{\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif (loading.value) return;\n\t\t\t\tselectedOptionsFocusedIndex.value = null;\n\t\t\t\tif (shown.value) {\n\t\t\t\t\tif (!filteredOptions.value.length) return;\n\t\t\t\t\tfocusOnNextOption();\n\t\t\t\t} else {\n\t\t\t\t\tif (selectedOptions.value.length) {\n\t\t\t\t\t\tfocusedIndex.value = head(selectedOptions.value).index;\n\t\t\t\t\t}\n\t\t\t\t\tawait open();\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t/**\n\t\t * When moving horizontally\n\t\t * Cycle from rightmost, next, or input focus.\n\t\t * If the focus lands on an option align the vertical focus as well\n\t\t */\n\t\tcase 'ArrowLeft':\n\t\t\t{\n\t\t\t\tif (loading.value) return;\n\t\t\t\tif (!query.value) {\n\t\t\t\t\tif (selectedOptions.value.length) {\n\t\t\t\t\t\tif (selectedOptionsFocusedIndex.value === null) {\n\t\t\t\t\t\t\tselectedOptionsFocusedIndex.value =\n\t\t\t\t\t\t\t\tselectedOptions.value.length - 1;\n\t\t\t\t\t\t} else if (selectedOptionsFocusedIndex.value > 0) {\n\t\t\t\t\t\t\tselectedOptionsFocusedIndex.value--;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tselectedOptionsFocusedIndex.value = null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (selectedOptionsFocusedIndex.value !== null) {\n\t\t\t\t\t\t\tlet linkedOption =\n\t\t\t\t\t\t\t\tselectedOptions.value[selectedOptionsFocusedIndex.value];\n\t\t\t\t\t\t\tlet foundOption = optionsContainer.value?.querySelector(\n\t\t\t\t\t\t\t\t`#${linkedOption.id}`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (foundOption) {\n\t\t\t\t\t\t\t\tfoundOption.scrollIntoView({\n\t\t\t\t\t\t\t\t\tbehavior: 'smooth',\n\t\t\t\t\t\t\t\t\tblock: 'nearest',\n\t\t\t\t\t\t\t\t\tinline: 'start',\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tfocusedIndex.value =\n\t\t\t\t\t\t\t\t\toptionsIndexedById.value[\n\t\t\t\t\t\t\t\t\t\tselectedOptions.value[selectedOptionsFocusedIndex.value].id\n\t\t\t\t\t\t\t\t\t].index;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t/**\n\t\t * When moving horizontally\n\t\t * Cycle from leftmost, next, or input focus.\n\t\t * If the focus lands on an option align the vertical focus as well\n\t\t */\n\t\tcase 'ArrowRight':\n\t\t\t{\n\t\t\t\tif (loading.value) return;\n\t\t\t\tif (!query.value) {\n\t\t\t\t\tif (selectedOptions.value.length) {\n\t\t\t\t\t\tif (selectedOptionsFocusedIndex.value === null) {\n\t\t\t\t\t\t\tselectedOptionsFocusedIndex.value = 0;\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\tselectedOptionsFocusedIndex.value <\n\t\t\t\t\t\t\tselectedOptions.value.length - 1\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tselectedOptionsFocusedIndex.value++;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tselectedOptionsFocusedIndex.value = null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (selectedOptionsFocusedIndex.value !== null) {\n\t\t\t\t\t\t\tlet linkedOption =\n\t\t\t\t\t\t\t\tselectedOptions.value[selectedOptionsFocusedIndex.value];\n\t\t\t\t\t\t\tlet foundOption = optionsContainer.value?.querySelector(\n\t\t\t\t\t\t\t\t`#${linkedOption.id}`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (foundOption) {\n\t\t\t\t\t\t\t\tfoundOption.scrollIntoView({\n\t\t\t\t\t\t\t\t\tbehavior: 'smooth',\n\t\t\t\t\t\t\t\t\tblock: 'nearest',\n\t\t\t\t\t\t\t\t\tinline: 'start',\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tfocusedIndex.value =\n\t\t\t\t\t\t\t\t\toptionsIndexedById.value[\n\t\t\t\t\t\t\t\t\t\tselectedOptions.value[selectedOptionsFocusedIndex.value].id\n\t\t\t\t\t\t\t\t\t].index;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t/**\n\t\t * If the panel is closed focus on the first selected option.\n\t\t * If the panel was already open select/deselect the currently focused option\n\t\t * and close the panel of single selection is enabled\n\t\t */\n\t\tcase 'Enter':\n\t\t\t{\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif (loading.value) return;\n\t\t\t\tif (!shown.value) {\n\t\t\t\t\tif (filteredOptions.value.length) {\n\t\t\t\t\t\tif (selectedOptions.value.length) {\n\t\t\t\t\t\t\tfocusedIndex.value = head(selectedOptions.value).index;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tawait open();\n\t\t\t\t} else {\n\t\t\t\t\tif (normalizedFocusedIndex.value !== null) {\n\t\t\t\t\t\tif (filteredOptions.value[normalizedFocusedIndex.value].disabled)\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\tif (!props.multiple) {\n\t\t\t\t\t\t\tawait close();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonOptionSelected(\n\t\t\t\t\t\t\tfilteredOptions.value[normalizedFocusedIndex.value]\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (props.addOptions) {\n\t\t\t\t\t\t\tif (props.itemText || props.itemValue) {\n\t\t\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t\t\t`Adding an option for mapped items is not supported. You can't create an option while passing \"item-text\" or \"item-value\".`\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\taddOption();\n\t\t\t\t\t\t\tconst added = last(manualItems.value);\n\t\t\t\t\t\t\tonOptionSelected(optionsIndexedById.value[added.id]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t/**\n\t\t * When moving away from the component reset focus both vertically and horizontally\n\t\t */\n\t\tcase 'Tab':\n\t\tcase 'Escape':\n\t\t\t{\n\t\t\t\tif (shown.value) {\n\t\t\t\t\tawait close();\n\t\t\t\t}\n\t\t\t\temit('inactive');\n\t\t\t\tselectedOptionsFocusedIndex.value = null;\n\t\t\t\tfocusedIndex.value = null;\n\t\t\t}\n\t\t\tbreak;\n\t\t// Prevent shift from opening the panel\n\t\tcase 'Shift':\n\t\t\t{\n\t\t\t\tif (loading.value) return;\n\t\t\t}\n\t\t\tbreak;\n\t\t/**\n\t\t * Delete behavior is different when query is empty\n\t\t * If query is empty\n\t\t * If no chip is selected - select rightmost chip\n\t\t * If a chip is selected - deselect that option\n\t\t * If any option remains move focus to that or reset\n\t\t */\n\t\tcase 'Backspace':\n\t\t\t{\n\t\t\t\tif (loading.value) return;\n\t\t\t\tif (!query.value) {\n\t\t\t\t\tif (selectedOptions.value.length) {\n\t\t\t\t\t\tif (selectedOptionsFocusedIndex.value === null) {\n\t\t\t\t\t\t\tselectedOptionsFocusedIndex.value =\n\t\t\t\t\t\t\t\tselectedOptions.value.length - 1;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonOptionSelected(\n\t\t\t\t\t\t\t\tselectedOptions.value[selectedOptionsFocusedIndex.value]\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (selectedOptions.value.length) {\n\t\t\t\t\t\t\t\tselectedOptionsFocusedIndex.value = Math.max(\n\t\t\t\t\t\t\t\t\tMath.min(\n\t\t\t\t\t\t\t\t\t\tselectedOptionsFocusedIndex.value,\n\t\t\t\t\t\t\t\t\t\tselectedOptions.value.length - 2\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t0\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tselectedOptionsFocusedIndex.value = null;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tawait open();\n\t\t\t}\n\t\t\tbreak;\n\t\t/**\n\t\t * Open the panel on writing and reset horizontal focus\n\t\t */\n\t\tdefault:\n\t\t\t{\n\t\t\t\tselectedOptionsFocusedIndex.value = null;\n\t\t\t\tfocusedIndex.value = null;\n\t\t\t\tawait open();\n\t\t\t}\n\t\t\tbreak;\n\t}\n};\n\n/**\n * Triggered on input when items is a function.\n */\n\nlet timeout: ReturnType<typeof setTimeout>;\nconst searchByQuery = () => {\n\tif (timeout) clearTimeout(timeout);\n\ttimeout = setTimeout(async () => {\n\t\ttry {\n\t\t\tawait getOptions({ prefill: false });\n\t\t} catch (error) {\n\t\t\tconsole.error(error);\n\t\t}\n\t}, props.queryDebounceTime);\n};\n\n/**\n * When clicking on the outside container seamlessly move focus to the input and open the panel\n */\nconst onOuterContainerClick = (event: MouseEvent) => {\n\temit('click', event);\n\tif (props.disabled || props.readonly) return;\n\tif (input.value instanceof HTMLElement) {\n\t\tinput.value.focus();\n\t}\n\topen();\n};\n\n/**\n * When an option is clicked wait for it to bubble to the option container to avoid slot event problems.\n * Select / deselect the option and then move focus to the input.\n * If it is single selection mode close the panel\n */\nconst onOptionClicked = (event: Event) => {\n\tif (event.currentTarget instanceof HTMLElement) {\n\t\tif (event.currentTarget.classList.contains('bb-base-select-option')) {\n\t\t\tconst option = optionsIndexedById.value[event.currentTarget.id];\n\t\t\tif (option.disabled) return;\n\t\t\tonOptionSelected(option);\n\t\t\tif (input.value instanceof HTMLInputElement) {\n\t\t\t\tinput.value.focus();\n\t\t\t}\n\t\t\tif (!props.multiple) close();\n\t\t}\n\t}\n};\n\n/**\n * On click outside of the container close the panel, remove active state.\n * In multiple selection clear query after a timeout\n */\nconst onClickOutside = async (event: Event) => {\n\tif (event.target instanceof Node) {\n\t\tif (outerContainer.value) {\n\t\t\tif (!outerContainer.value.contains(event.target)) {\n\t\t\t\tclose();\n\t\t\t\temit('inactive');\n\t\t\t\tdocument.removeEventListener('click', onClickOutside);\n\t\t\t\tactive.value = false;\n\t\t\t\tif (props.multiple) {\n\t\t\t\t\tawait wait(500);\n\t\t\t\t\tquery.value = '';\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n};\n\n/**\n * When using this component for submission we add a bunch of hidden\n * inputs so the submitted inputs are on par with v-model\n */\n/**\n * This is used to keep the value compatible to common html expected values.\n * Convert to string everything that's not but do not double encode strings\n */\nconst makeInputValue = when(\n\t(item: unknown) => typeof item !== 'string',\n\tJSON.stringify\n);\n\nconst hiddenInputs = computed(() => {\n\treturn [].concat(props.modelValue).map((current) => {\n\t\tconst value = makeInputValue(current);\n\t\treturn {\n\t\t\tdisabled: props.disabled,\n\t\t\tname: props.name,\n\t\t\ttype: 'hidden',\n\t\t\tvalue: value,\n\t\t};\n\t});\n});\n</script>\n<style lang=\"postcss\">\n@import '@/assets/css/BaseSelect';\n</style>\n"],"names":["props","__props","emit","__emit","outerContainer","ref","innerContainer","optionsContainer","input","query","computedPlaceholder","computed","selectedOptions","loading","transitionDuration","cleanUpPositioning","onMounted","autoUpdate","displayOptions","onBeforeUnmount","internalItems","stash","manualItems","getItemText","useItemText","getItemValue","useItemValue","internalOptions","item","_","text","value","jsonValue","options","fromOptions","acc","curr","withManual","withStash","option","index","isNotNil","modelValueIndexed","filteredOptions","base","matchedAnything","keys","propName","normalizedFocusedIndex","optionsIndexedById","optionsIndexedByValue","indexed","key","_a","pairs","deepEqual","map","linkedOption","onOptionSelected","valueToEmit","focusedIndex","current","stashed","getOptions","prefill","items","addOption","shouldPrefill","modelValueTimeout","watch","previous","allFound","coherentStash","coherent","found","currentQuery","depsTimeout","isFirstFocus","computePosition","offset","flip","shift","data","shown","showing","hiding","hidden","open","wait","close","active","onInputFocus","event","onClickOutside","onFocusOutside","onInputBlur","nextTick","onInputChange","onInputInput","searchByQuery","selectedOptionsFocusedIndex","focusOnNextOption","foundOption","focusOnPreviousOption","onInputKeyDown","head","_b","added","last","timeout","error","onOuterContainerClick","onOptionClicked","makeInputValue","when","hiddenInputs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6cA,UAAMA,IAAQC,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