treeselectjs 0.9.2 → 0.10.0

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.
@@ -1,1009 +1,1023 @@
1
- var li = Object.defineProperty;
2
- var ni = (l, e, t) => e in l ? li(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
- var c = (l, e, t) => (ni(l, typeof e != "symbol" ? e + "" : e, t), t), gt = (l, e, t) => {
4
- if (!e.has(l))
5
- throw TypeError("Cannot " + t);
6
- };
7
- var n = (l, e, t) => (gt(l, e, "read from private field"), t ? t.call(l) : e.get(l)), r = (l, e, t) => {
8
- if (e.has(l))
9
- throw TypeError("Cannot add the same private member more than once");
10
- e instanceof WeakSet ? e.add(l) : e.set(l, t);
11
- }, m = (l, e, t, s) => (gt(l, e, "write to private field"), s ? s.call(l, t) : e.set(l, t), t);
12
- var o = (l, e, t) => (gt(l, e, "access private method"), t);
13
- const It = {
14
- arrowUp: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 15l-6-6-6 6"/></svg>',
15
- arrowDown: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"/></svg>',
16
- arrowRight: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18l6-6-6-6"/></svg>',
17
- attention: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>',
18
- clear: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="15" y1="9" x2="9" y2="15"></line><line x1="9" y1="9" x2="15" y2="15"></line></svg>',
19
- cross: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>',
20
- check: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>',
21
- partialCheck: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"></line></svg>'
22
- }, O = (l, e) => {
23
- if (e.innerHTML = "", typeof l == "string")
24
- e.innerHTML = l;
25
- else {
26
- const t = l.cloneNode(!0);
27
- e.appendChild(t);
28
- }
29
- }, Pt = (l) => {
30
- const e = l ? { ...l } : {};
31
- return Object.keys(It).forEach((t) => {
32
- e[t] || (e[t] = It[t]);
33
- }), e;
34
- }, ai = (l) => l.reduce((e, { name: t }, s) => (e += t, s < l.length - 1 && (e += ", "), e), "");
35
- var T, E, D, v, ue, Dt, H, R, pe, Ht, me, Gt, G, U, N, V, fe, Mt, be, Ft, Ce, qt, ge, jt, we, $t, ke, Wt, Ee, Rt, ve, Ut, Le, zt, ye, Yt, xe, Kt, Se, Xt, _e, Jt, Ae, Zt, Te, Qt, Ne, es, z, wt;
36
- class oi {
37
- constructor({
38
- value: e,
39
- showTags: t,
40
- tagsCountText: s,
41
- clearable: i,
42
- isAlwaysOpened: a,
43
- searchable: h,
44
- placeholder: p,
45
- disabled: f,
46
- isSingleSelect: b,
47
- id: C,
48
- ariaLabel: g,
49
- iconElements: w,
50
- inputCallback: k,
51
- searchCallback: y,
52
- openCallback: I,
53
- closeCallback: W,
54
- keydownCallback: ae,
55
- focusCallback: bt,
56
- blurCallback: Ct,
57
- nameChangeCallback: oe
58
- }) {
59
- // Private methods
60
- r(this, ue);
61
- r(this, H);
62
- r(this, pe);
63
- r(this, me);
64
- r(this, G);
65
- r(this, N);
66
- r(this, fe);
67
- r(this, be);
68
- r(this, Ce);
69
- r(this, ge);
70
- r(this, we);
71
- r(this, ke);
72
- r(this, Ee);
73
- r(this, ve);
74
- r(this, Le);
75
- r(this, ye);
76
- r(this, xe);
77
- r(this, Se);
78
- r(this, _e);
79
- r(this, Ae);
80
- r(this, Te);
81
- r(this, Ne);
82
- // Emits
83
- r(this, z);
84
- // Props
85
- c(this, "value");
86
- c(this, "showTags");
87
- c(this, "tagsCountText");
88
- c(this, "clearable");
89
- c(this, "isAlwaysOpened");
90
- c(this, "searchable");
91
- c(this, "placeholder");
92
- c(this, "disabled");
93
- c(this, "isSingleSelect");
94
- c(this, "id");
95
- c(this, "ariaLabel");
96
- c(this, "iconElements");
97
- // InnerState
98
- c(this, "isOpened");
99
- c(this, "searchText");
100
- c(this, "srcElement");
101
- // PrivateInnerState
102
- r(this, T, void 0);
103
- r(this, E, void 0);
104
- r(this, D, void 0);
105
- r(this, v, void 0);
106
- // Callbacks
107
- c(this, "inputCallback");
108
- c(this, "searchCallback");
109
- c(this, "openCallback");
110
- c(this, "closeCallback");
111
- c(this, "keydownCallback");
112
- c(this, "focusCallback");
113
- c(this, "blurCallback");
114
- c(this, "nameChangeCallback");
115
- this.value = e, this.showTags = t, this.tagsCountText = s, this.searchable = h, this.placeholder = p, this.clearable = i, this.isAlwaysOpened = a, this.disabled = f, this.isSingleSelect = b, this.id = C, this.ariaLabel = g, this.iconElements = w, this.isOpened = !1, this.searchText = "", m(this, T, o(this, Ce, qt).call(this)), m(this, E, o(this, Le, zt).call(this)), m(this, D, o(this, Se, Xt).call(this)), m(this, v, null), this.inputCallback = k, this.searchCallback = y, this.openCallback = I, this.closeCallback = W, this.keydownCallback = ae, this.focusCallback = bt, this.blurCallback = Ct, this.nameChangeCallback = oe, this.srcElement = o(this, fe, Mt).call(this, n(this, T), n(this, E), n(this, D)), o(this, ue, Dt).call(this);
116
- }
117
- // Public methods
118
- focus() {
119
- setTimeout(() => n(this, E).focus(), 0);
120
- }
121
- blur() {
122
- this.isOpened && o(this, N, V).call(this), this.clearSearch(), n(this, E).blur();
123
- }
124
- updateValue(e) {
125
- this.value = e, o(this, H, R).call(this), o(this, G, U).call(this);
126
- }
127
- removeItem(e) {
128
- this.value = this.value.filter((t) => t.id !== e), o(this, z, wt).call(this), o(this, H, R).call(this), o(this, G, U).call(this);
129
- }
130
- clear() {
131
- this.value = [], o(this, z, wt).call(this), o(this, H, R).call(this), this.clearSearch();
132
- }
133
- openClose() {
134
- o(this, N, V).call(this);
135
- }
136
- clearSearch() {
137
- this.searchText = "", this.searchCallback(""), o(this, G, U).call(this);
138
- }
139
- }
140
- T = new WeakMap(), E = new WeakMap(), D = new WeakMap(), v = new WeakMap(), ue = new WeakSet(), Dt = function() {
141
- o(this, H, R).call(this), o(this, G, U).call(this), o(this, pe, Ht).call(this);
142
- }, H = new WeakSet(), R = function() {
143
- if (n(this, T).innerHTML = "", this.showTags) {
144
- n(this, T).append(...o(this, ge, jt).call(this));
145
- const e = ai(this.value);
146
- this.nameChangeCallback(e);
147
- } else {
148
- const e = o(this, ve, Ut).call(this);
149
- n(this, T).appendChild(e), this.nameChangeCallback(e.innerText);
150
- }
151
- n(this, T).appendChild(n(this, E));
152
- }, pe = new WeakSet(), Ht = function() {
153
- const e = [];
154
- n(this, D).innerHTML = "", this.clearable && e.push(o(this, _e, Jt).call(this)), this.isAlwaysOpened || e.push(o(this, Te, Qt).call(this, this.isOpened)), e.length && n(this, D).append(...e);
155
- }, me = new WeakSet(), Gt = function() {
156
- if (!this.isAlwaysOpened && n(this, v)) {
157
- const e = this.isOpened ? this.iconElements.arrowUp : this.iconElements.arrowDown;
158
- O(e, n(this, v));
159
- }
160
- }, G = new WeakSet(), U = function() {
161
- var e;
162
- (e = this.value) != null && e.length ? (n(this, E).removeAttribute("placeholder"), this.srcElement.classList.remove("treeselect-input--value-not-selected")) : (n(this, E).setAttribute("placeholder", this.placeholder), this.srcElement.classList.add("treeselect-input--value-not-selected")), this.searchable ? this.srcElement.classList.remove("treeselect-input--unsearchable") : this.srcElement.classList.add("treeselect-input--unsearchable"), this.isSingleSelect ? this.srcElement.classList.add("treeselect-input--is-single-select") : this.srcElement.classList.remove("treeselect-input--is-single-select"), n(this, E).value = this.searchText;
163
- }, N = new WeakSet(), V = function() {
164
- this.isOpened = !this.isOpened, o(this, me, Gt).call(this), this.isOpened ? this.openCallback() : this.closeCallback();
165
- }, fe = new WeakSet(), Mt = function(e, t, s) {
166
- const i = document.createElement("div");
167
- return i.classList.add("treeselect-input"), i.setAttribute("tabindex", "-1"), i.addEventListener("mousedown", (a) => o(this, be, Ft).call(this, a)), i.addEventListener("focus", () => this.focusCallback(), !0), i.addEventListener("blur", () => this.blurCallback(), !0), e.appendChild(t), i.append(e, s), i;
168
- }, be = new WeakSet(), Ft = function(e) {
169
- e.stopPropagation(), this.isOpened || o(this, N, V).call(this), this.focus();
170
- }, Ce = new WeakSet(), qt = function() {
171
- const e = document.createElement("div");
172
- return e.classList.add("treeselect-input__tags"), e;
173
- }, ge = new WeakSet(), jt = function() {
174
- return this.value.map((e) => {
175
- const t = document.createElement("div");
176
- t.classList.add("treeselect-input__tags-element"), t.setAttribute("tabindex", "-1"), t.setAttribute("tag-id", e.id.toString()), t.setAttribute("title", e.name);
177
- const s = o(this, ke, Wt).call(this, e.name), i = o(this, Ee, Rt).call(this);
178
- return t.addEventListener("mousedown", (a) => o(this, we, $t).call(this, a, e.id)), t.append(s, i), t;
179
- });
180
- }, we = new WeakSet(), $t = function(e, t) {
181
- e.preventDefault(), e.stopPropagation(), this.removeItem(t), this.focus();
182
- }, ke = new WeakSet(), Wt = function(e) {
183
- const t = document.createElement("span");
184
- return t.classList.add("treeselect-input__tags-name"), t.textContent = e, t;
185
- }, Ee = new WeakSet(), Rt = function() {
186
- const e = document.createElement("span");
187
- return e.classList.add("treeselect-input__tags-cross"), O(this.iconElements.cross, e), e;
188
- }, ve = new WeakSet(), Ut = function() {
189
- const e = document.createElement("span");
190
- if (e.classList.add("treeselect-input__tags-count"), !this.value.length)
191
- return e.textContent = "", e.setAttribute("title", ""), e;
192
- const t = this.value.length === 1 ? this.value[0].name : `${this.value.length} ${this.tagsCountText}`;
193
- return e.textContent = t, e.setAttribute("title", t), e;
194
- }, Le = new WeakSet(), zt = function() {
195
- const e = document.createElement("input");
196
- return e.classList.add("treeselect-input__edit"), this.id && e.setAttribute("id", this.id), (!this.searchable || this.disabled) && e.setAttribute("readonly", "readonly"), this.disabled && e.setAttribute("tabindex", "-1"), this.ariaLabel.length && e.setAttribute("aria-label", this.ariaLabel), e.addEventListener("keydown", (t) => o(this, ye, Yt).call(this, t)), e.addEventListener("input", (t) => o(this, xe, Kt).call(this, t, e)), e;
197
- }, ye = new WeakSet(), Yt = function(e) {
198
- e.stopPropagation();
199
- const t = e.key;
200
- t === "Backspace" && !this.searchText.length && this.value.length && !this.showTags && this.clear(), t === "Backspace" && !this.searchText.length && this.value.length && this.removeItem(this.value[this.value.length - 1].id), e.code === "Space" && (!this.searchText || !this.searchable) && o(this, N, V).call(this), (t === "Enter" || t === "ArrowDown" || t === "ArrowUp") && e.preventDefault(), this.keydownCallback(e), t !== "Tab" && this.focus();
201
- }, xe = new WeakSet(), Kt = function(e, t) {
202
- e.stopPropagation();
203
- const s = this.searchText, i = t.value.trim();
204
- if (s.length === 0 && i.length === 0) {
205
- t.value = "";
206
- return;
207
- }
208
- if (this.searchable) {
209
- const a = e.target.value;
210
- this.searchCallback(a), this.isOpened || o(this, N, V).call(this);
211
- } else
212
- t.value = "";
213
- this.searchText = t.value;
214
- }, Se = new WeakSet(), Xt = function() {
215
- const e = document.createElement("div");
216
- return e.classList.add("treeselect-input__operators"), e;
217
- }, _e = new WeakSet(), Jt = function() {
218
- const e = document.createElement("span");
219
- return e.classList.add("treeselect-input__clear"), e.setAttribute("tabindex", "-1"), O(this.iconElements.clear, e), e.addEventListener("mousedown", (t) => o(this, Ae, Zt).call(this, t)), e;
220
- }, Ae = new WeakSet(), Zt = function(e) {
221
- e.preventDefault(), e.stopPropagation(), (this.searchText.length || this.value.length) && this.clear(), this.focus();
222
- }, Te = new WeakSet(), Qt = function(e) {
223
- m(this, v, document.createElement("span")), n(this, v).classList.add("treeselect-input__arrow");
224
- const t = e ? this.iconElements.arrowUp : this.iconElements.arrowDown;
225
- return O(t, n(this, v)), n(this, v).addEventListener("mousedown", (s) => o(this, Ne, es).call(this, s)), n(this, v);
226
- }, Ne = new WeakSet(), es = function(e) {
227
- e.stopPropagation(), e.preventDefault(), this.focus(), o(this, N, V).call(this);
228
- }, z = new WeakSet(), wt = function() {
229
- this.inputCallback(this.value);
230
- };
231
- const ts = (l, e, t, s) => {
232
- di(e);
233
- const i = e.filter((a) => !a.disabled && l.some((h) => h === a.id));
234
- if (t && i.length) {
235
- i[0].checked = !0;
236
- return;
237
- }
238
- i.forEach((a) => {
239
- a.checked = !0;
240
- const h = Ot(a, e, s);
241
- a.checked = h;
242
- });
243
- }, Ot = ({ id: l, checked: e }, t, s) => {
244
- const i = t.find((h) => h.id === l);
245
- if (!i)
246
- return !1;
247
- if (s)
248
- return i.checked = i.disabled ? !1 : !!e, i.checked;
249
- const a = ss(!!e, i, t);
250
- return is(i, t), a;
251
- }, ss = (l, e, t) => {
252
- if (!e.isGroup)
253
- return e.checked = e.disabled ? !1 : !!l, e.isPartialChecked = !1, e.checked;
254
- const s = t.filter((p) => p.childOf === e.id);
255
- return !l || e.disabled || e.isPartialChecked ? (e.checked = !1, e.isPartialChecked = !1, kt(e, s, t), e.checked) : ls(s, t) ? ns(s) ? (e.checked = !1, e.isPartialChecked = !1, e.disabled = !0, e.checked) : (e.checked = !1, e.isPartialChecked = !0, s.forEach((p) => {
256
- ss(l, p, t);
257
- }), e.checked) : (e.checked = !0, e.isPartialChecked = !1, kt(e, s, t), e.checked);
258
- }, is = (l, e) => {
259
- const t = e.find((s) => s.id === l.childOf);
260
- t && (ri(t, e), is(t, e));
261
- }, ri = (l, e) => {
262
- const t = mt(l, e);
263
- if (ns(t)) {
264
- l.checked = !1, l.isPartialChecked = !1, l.disabled = !0;
265
- return;
266
- }
267
- if (ci(t)) {
268
- l.checked = !0, l.isPartialChecked = !1;
269
- return;
270
- }
271
- if (hi(t)) {
272
- l.checked = !1, l.isPartialChecked = !0;
273
- return;
274
- }
275
- l.checked = !1, l.isPartialChecked = !1;
276
- }, kt = ({ checked: l, disabled: e }, t, s) => {
277
- t.forEach((i) => {
278
- i.disabled = !!e || !!i.disabled, i.checked = !!l && !i.disabled, i.isPartialChecked = !1;
279
- const a = mt(i, s);
280
- kt({ checked: l, disabled: e }, a, s);
281
- });
282
- }, ls = (l, e) => l.some((i) => i.disabled) ? !0 : l.some((i) => {
283
- if (i.isGroup) {
284
- const a = mt(i, e);
285
- return ls(a, e);
286
- }
287
- return !1;
288
- }), ns = (l) => l.every((e) => !!e.disabled), ci = (l) => l.every((e) => !!e.checked), hi = (l) => l.some((e) => !!e.checked || !!e.isPartialChecked), di = (l) => {
289
- l.forEach((e) => {
290
- e.checked = !1, e.isPartialChecked = !1;
291
- });
292
- }, ui = (l, e, t) => {
293
- const s = { level: 0, groupId: "" }, i = as(l, e, s.groupId, s.level);
294
- return mi(i, t);
295
- }, as = (l, e, t, s) => l.reduce((i, a) => {
296
- var b;
297
- const h = !!((b = a.children) != null && b.length), p = s >= e && h, f = s > e;
298
- if (i.push({
299
- id: a.value,
300
- name: a.name,
301
- childOf: t,
302
- isGroup: h,
303
- checked: !1,
304
- isPartialChecked: !1,
305
- level: s,
306
- isClosed: p,
307
- hidden: f,
308
- disabled: a.disabled ?? !1
309
- }), h) {
310
- const C = as(a.children, e, a.value, s + 1);
311
- i.push(...C);
312
- }
313
- return i;
314
- }, []), mt = ({ id: l }, e) => e.filter((t) => t.childOf === l), pi = (l) => {
315
- const { ungroupedNodes: e, allGroupedNodes: t, allNodes: s } = l.reduce(
316
- (a, h) => (h.checked && (a.allNodes.push(h), h.isGroup ? a.allGroupedNodes.push(h) : a.ungroupedNodes.push(h)), a),
317
- {
318
- ungroupedNodes: [],
319
- allGroupedNodes: [],
320
- allNodes: []
321
- }
322
- ), i = s.filter((a) => !t.some(({ id: h }) => h === a.childOf));
323
- return { ungroupedNodes: e, groupedNodes: i, allNodes: s };
324
- }, mi = (l, e) => (l.filter((s) => !!s.disabled).forEach(
325
- ({ id: s }) => Ot({ id: s, checked: !1 }, l, e)
326
- ), l), ft = (l, { id: e, isClosed: t }) => {
327
- mt({ id: e }, l).forEach((i) => {
328
- i.hidden = t ?? !1, i.isGroup && !i.isClosed && ft(l, { id: i.id, isClosed: t });
329
- });
330
- }, fi = (l) => {
331
- l.filter((e) => e.isGroup && !e.disabled && (e.checked || e.isPartialChecked)).forEach((e) => {
332
- e.isClosed = !1, ft(l, e);
333
- });
334
- }, bi = (l, e) => {
335
- const t = Ci(l, e);
336
- l.forEach((s) => {
337
- t.some(({ id: a }) => a === s.id) ? (s.isGroup && (s.isClosed = !1, ft(l, s)), s.hidden = !1) : s.hidden = !0;
338
- });
339
- }, Ci = (l, e) => l.reduce((t, s) => {
340
- if (s.name.toLowerCase().includes(e.toLowerCase())) {
341
- if (t.push(s), s.isGroup) {
342
- const a = os(s.id, l);
343
- t.push(...a);
344
- }
345
- if (s.childOf) {
346
- const a = rs(s.childOf, l);
347
- t.push(...a);
348
- }
349
- }
350
- return t;
351
- }, []), os = (l, e) => e.reduce((t, s) => (s.childOf === l && (t.push(s), s.isGroup && t.push(...os(s.id, e))), t), []), rs = (l, e) => e.reduce((t, s) => (s.id === l && (t.push(s), s.childOf && t.push(...rs(s.childOf, e))), t), []), gi = (l) => {
352
- const { duplications: e } = l.reduce(
353
- (t, s) => (t.allItems.some((i) => i.toString() === s.id.toString()) && t.duplications.push(s.id), t.allItems.push(s.id), t),
354
- {
355
- duplications: [],
356
- allItems: []
357
- }
358
- );
359
- e.length && console.error(`Validation: You have duplicated values: ${e.join(", ")}! You should use unique values.`);
360
- }, wi = (l, e, t, s, i, a, h, p, f) => {
361
- ts(l, e, i, f), p && h && fi(e), ce(e, t, s, a);
362
- }, ce = (l, e, t, s) => {
363
- l.forEach((i) => {
364
- const a = e.querySelector(`[input-id="${i.id}"]`), h = A(a);
365
- a.checked = i.checked, ki(i, h, s), Ei(i, h), vi(i, h), Li(i, h, t), yi(i, h), Si(i, h, l), xi(i, a, t);
366
- }), _i(l, e);
367
- }, ki = (l, e, t) => {
368
- l.checked ? e.classList.add("treeselect-list__item--checked") : e.classList.remove("treeselect-list__item--checked"), Array.isArray(t) && t[0] === l.id && !l.disabled ? e.classList.add("treeselect-list__item--single-selected") : e.classList.remove("treeselect-list__item--single-selected");
369
- }, Ei = (l, e) => {
370
- l.isPartialChecked ? e.classList.add("treeselect-list__item--partial-checked") : e.classList.remove("treeselect-list__item--partial-checked");
371
- }, vi = (l, e) => {
372
- l.disabled ? e.classList.add("treeselect-list__item--disabled") : e.classList.remove("treeselect-list__item--disabled");
373
- }, Li = (l, e, t) => {
374
- if (l.isGroup) {
375
- const s = e.querySelector(".treeselect-list__item-icon"), i = l.isClosed ? t.arrowRight : t.arrowDown;
376
- O(i, s), l.isClosed ? e.classList.add("treeselect-list__item--closed") : e.classList.remove("treeselect-list__item--closed");
377
- }
378
- }, yi = (l, e) => {
379
- l.hidden ? e.classList.add("treeselect-list__item--hidden") : e.classList.remove("treeselect-list__item--hidden");
380
- }, xi = (l, e, t) => {
381
- const i = e.parentNode.querySelector(".treeselect-list__item-checkbox-icon");
382
- l.checked ? O(t.check, i) : l.isPartialChecked ? O(t.partialCheck, i) : i.innerHTML = "";
383
- }, Si = (l, e, t) => {
384
- const s = l.level === 0, i = 20, a = 5;
385
- if (s) {
386
- const h = t.some((f) => f.isGroup && f.level === l.level), p = !l.isGroup && h ? `${i}px` : `${a}px`;
387
- e.style.paddingLeft = l.isGroup ? "0" : p;
388
- } else
389
- e.style.paddingLeft = l.isGroup ? `${l.level * i}px` : `${l.level * i + i}px`;
390
- e.setAttribute("level", l.level.toString()), e.setAttribute("group", l.isGroup.toString());
391
- }, _i = (l, e) => {
392
- const t = l.some((i) => !i.hidden), s = e.querySelector(".treeselect-list__empty");
393
- t ? s.classList.add("treeselect-list__empty--hidden") : s.classList.remove("treeselect-list__empty--hidden");
394
- }, A = (l) => l.parentNode.parentNode, Bt = (l, e) => e.find((t) => t.id.toString() === l), Ai = (l) => A(l).querySelector(".treeselect-list__item-icon"), Ti = (l, e) => {
395
- e && Object.keys(e).forEach((t) => {
396
- const s = e[t];
397
- typeof s == "string" && l.setAttribute(t, s);
398
- });
399
- };
400
- var M, P, x, Y, Oe, cs, Ie, hs, Pe, ds, Be, us, Ve, ps, De, ms, K, Et, He, fs, Ge, bs, Me, Cs, X, vt, Fe, gs, qe, ws, je, ks, $e, Es, We, vs, Re, Ls, Ue, ys, ze, xs, Ye, Ss, Ke, _s, Xe, As, J, Lt, Z, yt, Je, Ts;
401
- class Ni {
402
- constructor({
403
- options: e,
404
- value: t,
405
- openLevel: s,
406
- listSlotHtmlComponent: i,
407
- emptyText: a,
408
- isSingleSelect: h,
409
- iconElements: p,
410
- showCount: f,
411
- disabledBranchNode: b,
412
- expandSelected: C,
413
- isIndependentNodes: g,
414
- inputCallback: w,
415
- arrowClickCallback: k,
416
- mouseupCallback: y
417
- }) {
418
- // Private methods
419
- r(this, Oe);
420
- r(this, Ie);
421
- r(this, Pe);
422
- r(this, Be);
423
- r(this, Ve);
424
- r(this, De);
425
- r(this, K);
426
- r(this, He);
427
- r(this, Ge);
428
- r(this, Me);
429
- r(this, X);
430
- r(this, Fe);
431
- r(this, qe);
432
- r(this, je);
433
- r(this, $e);
434
- r(this, We);
435
- r(this, Re);
436
- r(this, Ue);
437
- r(this, ze);
438
- r(this, Ye);
439
- // Actions
440
- r(this, Ke);
441
- r(this, Xe);
442
- r(this, J);
443
- r(this, Z);
444
- // Emits
445
- r(this, Je);
446
- // Props
447
- c(this, "options");
448
- c(this, "value");
449
- c(this, "openLevel");
450
- c(this, "listSlotHtmlComponent");
451
- c(this, "emptyText");
452
- c(this, "isSingleSelect");
453
- c(this, "showCount");
454
- c(this, "disabledBranchNode");
455
- c(this, "expandSelected");
456
- c(this, "isIndependentNodes");
457
- c(this, "iconElements");
458
- // InnerState
459
- c(this, "searchText");
460
- c(this, "flattedOptions");
461
- c(this, "flattedOptionsBeforeSearch");
462
- c(this, "selectedNodes");
463
- c(this, "srcElement");
464
- // Callbacks
465
- c(this, "inputCallback");
466
- c(this, "arrowClickCallback");
467
- c(this, "mouseupCallback");
468
- // PrivateInnerState
469
- r(this, M, null);
470
- r(this, P, !0);
471
- r(this, x, []);
472
- r(this, Y, !0);
473
- this.options = e, this.value = t, this.openLevel = s ?? 0, this.listSlotHtmlComponent = i ?? null, this.emptyText = a ?? "No results found...", this.isSingleSelect = h ?? !1, this.showCount = f ?? !1, this.disabledBranchNode = b ?? !1, this.expandSelected = C ?? !1, this.isIndependentNodes = g ?? !1, this.iconElements = p, this.searchText = "", this.flattedOptions = ui(this.options, this.openLevel, this.isIndependentNodes), this.flattedOptionsBeforeSearch = this.flattedOptions, this.selectedNodes = { nodes: [], groupedNodes: [], allNodes: [] }, this.srcElement = o(this, Pe, ds).call(this), this.inputCallback = w, this.arrowClickCallback = k, this.mouseupCallback = y, gi(this.flattedOptions);
474
- }
475
- // Public methods
476
- updateValue(e) {
477
- this.value = e, m(this, x, this.isSingleSelect ? this.value : []), wi(
478
- e,
479
- this.flattedOptions,
480
- this.srcElement,
481
- this.iconElements,
482
- this.isSingleSelect,
483
- n(this, x),
484
- this.expandSelected,
485
- n(this, Y),
486
- this.isIndependentNodes
487
- ), m(this, Y, !1), o(this, Z, yt).call(this);
488
- }
489
- updateSearchValue(e) {
490
- if (e === this.searchText)
491
- return;
492
- const t = this.searchText === "" && e !== "";
493
- this.searchText = e, t && (this.flattedOptionsBeforeSearch = JSON.parse(JSON.stringify(this.flattedOptions))), this.searchText === "" && (this.flattedOptions = this.flattedOptionsBeforeSearch.map((s) => {
494
- const i = this.flattedOptions.find((a) => a.id === s.id);
495
- return i.isClosed = s.isClosed, i.hidden = s.hidden, i;
496
- }), this.flattedOptionsBeforeSearch = []), this.searchText && bi(this.flattedOptions, e), ce(this.flattedOptions, this.srcElement, this.iconElements, n(this, x)), this.focusFirstListElement();
497
- }
498
- callKeyAction(e) {
499
- m(this, P, !1);
500
- const t = this.srcElement.querySelector(".treeselect-list__item--focused");
501
- if (t == null ? void 0 : t.classList.contains("treeselect-list__item--hidden"))
502
- return;
503
- const i = e.key;
504
- i === "Enter" && t && t.dispatchEvent(new Event("mousedown")), (i === "ArrowLeft" || i === "ArrowRight") && o(this, Oe, cs).call(this, t, e), (i === "ArrowDown" || i === "ArrowUp") && o(this, Ie, hs).call(this, t, i);
505
- }
506
- focusFirstListElement() {
507
- const e = "treeselect-list__item--focused", t = this.srcElement.querySelector(`.${e}`), s = Array.from(this.srcElement.querySelectorAll(".treeselect-list__item-checkbox")).filter(
508
- (a) => window.getComputedStyle(A(a)).display !== "none"
509
- );
510
- if (!s.length)
511
- return;
512
- t && t.classList.remove(e), A(s[0]).classList.add(e);
513
- }
514
- isLastFocusedElementExist() {
515
- return !!n(this, M);
516
- }
517
- }
518
- M = new WeakMap(), P = new WeakMap(), x = new WeakMap(), Y = new WeakMap(), Oe = new WeakSet(), cs = function(e, t) {
519
- if (!e)
520
- return;
521
- const s = t.key, a = e.querySelector(".treeselect-list__item-checkbox").getAttribute("input-id"), h = Bt(a, this.flattedOptions), p = e.querySelector(".treeselect-list__item-icon");
522
- s === "ArrowLeft" && !h.isClosed && h.isGroup && (p.dispatchEvent(new Event("mousedown")), t.preventDefault()), s === "ArrowRight" && h.isClosed && h.isGroup && (p.dispatchEvent(new Event("mousedown")), t.preventDefault());
523
- }, Ie = new WeakSet(), hs = function(e, t) {
524
- var i;
525
- const s = Array.from(this.srcElement.querySelectorAll(".treeselect-list__item-checkbox")).filter(
526
- (a) => window.getComputedStyle(A(a)).display !== "none"
527
- );
528
- if (s.length)
529
- if (!e)
530
- A(s[0]).classList.add("treeselect-list__item--focused");
531
- else {
532
- const a = s.findIndex(
533
- (I) => A(I).classList.contains("treeselect-list__item--focused")
534
- );
535
- A(s[a]).classList.remove("treeselect-list__item--focused");
536
- const p = t === "ArrowDown" ? a + 1 : a - 1, f = t === "ArrowDown" ? 0 : s.length - 1, b = s[p] ?? s[f], C = !s[p], g = A(b);
537
- g.classList.add("treeselect-list__item--focused");
538
- const w = this.srcElement.getBoundingClientRect(), k = g.getBoundingClientRect();
539
- if (C && t === "ArrowDown") {
540
- this.srcElement.scroll(0, 0);
541
- return;
542
- }
543
- if (C && t === "ArrowUp") {
544
- this.srcElement.scroll(0, this.srcElement.scrollHeight);
545
- return;
546
- }
547
- const y = ((i = this.listSlotHtmlComponent) == null ? void 0 : i.clientHeight) ?? 0;
548
- if (w.y + w.height < k.y + k.height + y) {
549
- this.srcElement.scroll(0, this.srcElement.scrollTop + k.height);
550
- return;
551
- }
552
- if (w.y > k.y) {
553
- this.srcElement.scroll(0, this.srcElement.scrollTop - k.height);
554
- return;
555
- }
556
- }
557
- }, Pe = new WeakSet(), ds = function() {
558
- const e = o(this, Be, us).call(this), t = o(this, K, Et).call(this, this.options);
559
- e.append(...t);
560
- const s = o(this, Ge, bs).call(this);
561
- e.append(s);
562
- const i = o(this, He, fs).call(this);
563
- return i && e.append(i), e;
564
- }, Be = new WeakSet(), us = function() {
565
- const e = document.createElement("div");
566
- return e.classList.add("treeselect-list"), this.isSingleSelect && e.classList.add("treeselect-list--single-select"), this.disabledBranchNode && e.classList.add("treeselect-list--disabled-branch-node"), e.addEventListener("mouseout", (t) => o(this, Ve, ps).call(this, t)), e.addEventListener("mousemove", () => o(this, De, ms).call(this)), e.addEventListener("mouseup", () => this.mouseupCallback(), !0), e;
567
- }, Ve = new WeakSet(), ps = function(e) {
568
- e.stopPropagation(), n(this, M) && n(this, P) && n(this, M).classList.add("treeselect-list__item--focused");
569
- }, De = new WeakSet(), ms = function() {
570
- m(this, P, !0);
571
- }, K = new WeakSet(), Et = function(e) {
572
- return e.reduce((t, s) => {
573
- var a;
574
- if ((a = s.children) != null && a.length) {
575
- const h = o(this, Me, Cs).call(this, s), p = o(this, K, Et).call(this, s.children);
576
- return h.append(...p), t.push(h), t;
577
- }
578
- const i = o(this, X, vt).call(this, s, !1);
579
- return t.push(i), t;
580
- }, []);
581
- }, He = new WeakSet(), fs = function() {
582
- if (!this.listSlotHtmlComponent)
583
- return null;
584
- const e = document.createElement("div");
585
- return e.classList.add("treeselect-list__slot"), e.appendChild(this.listSlotHtmlComponent), e;
586
- }, Ge = new WeakSet(), bs = function() {
587
- const e = document.createElement("div");
588
- e.classList.add("treeselect-list__empty"), e.setAttribute("title", this.emptyText);
589
- const t = document.createElement("span");
590
- t.classList.add("treeselect-list__empty-icon"), O(this.iconElements.attention, t);
591
- const s = document.createElement("span");
592
- return s.classList.add("treeselect-list__empty-text"), s.textContent = this.emptyText, e.append(t, s), e;
593
- }, Me = new WeakSet(), Cs = function(e) {
594
- const t = document.createElement("div");
595
- t.setAttribute("group-container-id", e.value.toString()), t.classList.add("treeselect-list__group-container");
596
- const s = o(this, X, vt).call(this, e, !0);
597
- return t.appendChild(s), t;
598
- }, X = new WeakSet(), vt = function(e, t) {
599
- const s = o(this, Fe, gs).call(this, e);
600
- if (t) {
601
- const h = o(this, We, vs).call(this);
602
- s.appendChild(h), s.classList.add("treeselect-list__item--group");
603
- }
604
- const i = o(this, Ue, ys).call(this, e), a = o(this, ze, xs).call(this, e, t);
605
- return s.append(i, a), s;
606
- }, Fe = new WeakSet(), gs = function(e) {
607
- const t = document.createElement("div");
608
- return Ti(t, e.htmlAttr), t.setAttribute("tabindex", "-1"), t.setAttribute("title", e.name), t.classList.add("treeselect-list__item"), t.addEventListener("mouseover", () => o(this, qe, ws).call(this, t), !0), t.addEventListener("mouseout", () => o(this, je, ks).call(this, t), !0), t.addEventListener("mousedown", (s) => o(this, $e, Es).call(this, s, e)), t;
609
- }, qe = new WeakSet(), ws = function(e) {
610
- n(this, P) && o(this, J, Lt).call(this, !0, e);
611
- }, je = new WeakSet(), ks = function(e) {
612
- n(this, P) && (o(this, J, Lt).call(this, !1, e), m(this, M, e));
613
- }, $e = new WeakSet(), Es = function(e, t) {
614
- var a;
615
- if (e.preventDefault(), e.stopPropagation(), (a = this.flattedOptions.find((h) => h.id === t.value)) == null ? void 0 : a.disabled)
616
- return;
617
- const i = e.target.querySelector(".treeselect-list__item-checkbox");
618
- i.checked = !i.checked, o(this, Ke, _s).call(this, i, t);
619
- }, We = new WeakSet(), vs = function() {
620
- const e = document.createElement("span");
621
- return e.setAttribute("tabindex", "-1"), e.classList.add("treeselect-list__item-icon"), O(this.iconElements.arrowDown, e), e.addEventListener("mousedown", (t) => o(this, Re, Ls).call(this, t)), e;
622
- }, Re = new WeakSet(), Ls = function(e) {
623
- e.preventDefault(), e.stopPropagation(), o(this, Xe, As).call(this, e);
624
- }, Ue = new WeakSet(), ys = function(e) {
625
- const t = document.createElement("div");
626
- t.classList.add("treeselect-list__item-checkbox-container");
627
- const s = document.createElement("span");
628
- s.classList.add("treeselect-list__item-checkbox-icon"), s.innerHTML = "";
629
- const i = document.createElement("input");
630
- return i.setAttribute("tabindex", "-1"), i.setAttribute("type", "checkbox"), i.setAttribute("input-id", e.value.toString()), i.classList.add("treeselect-list__item-checkbox"), t.append(s, i), t;
631
- }, ze = new WeakSet(), xs = function(e, t) {
632
- const s = document.createElement("label");
633
- if (s.textContent = e.name, s.classList.add("treeselect-list__item-label"), t && this.showCount) {
634
- const i = o(this, Ye, Ss).call(this, e);
635
- s.appendChild(i);
636
- }
637
- return s;
638
- }, Ye = new WeakSet(), Ss = function(e) {
639
- const t = document.createElement("span"), s = this.flattedOptions.filter((i) => i.childOf === e.value);
640
- return t.textContent = `(${s.length})`, t.classList.add("treeselect-list__item-label-counter"), t;
641
- }, Ke = new WeakSet(), _s = function(e, t) {
642
- const s = this.flattedOptions.find((i) => i.id === t.value);
643
- if (s) {
644
- if (s != null && s.isGroup && this.disabledBranchNode) {
645
- const i = Ai(e);
646
- i == null || i.dispatchEvent(new Event("mousedown"));
647
- return;
648
- }
649
- if (this.isSingleSelect) {
650
- const [i] = n(this, x);
651
- if (s.id === i)
652
- return;
653
- m(this, x, [s.id]), ts([s.id], this.flattedOptions, this.isSingleSelect, this.isIndependentNodes);
654
- } else {
655
- s.checked = e.checked;
656
- const i = Ot(s, this.flattedOptions, this.isIndependentNodes);
657
- e.checked = i;
658
- }
659
- ce(this.flattedOptions, this.srcElement, this.iconElements, n(this, x)), o(this, Je, Ts).call(this);
660
- }
661
- }, Xe = new WeakSet(), As = function(e) {
662
- var a, h;
663
- const t = (h = (a = e.target) == null ? void 0 : a.parentNode) == null ? void 0 : h.querySelector("[input-id]"), s = (t == null ? void 0 : t.getAttribute("input-id")) ?? null, i = Bt(s, this.flattedOptions);
664
- i && (i.isClosed = !i.isClosed, ft(this.flattedOptions, i), ce(this.flattedOptions, this.srcElement, this.iconElements, n(this, x)), this.arrowClickCallback());
665
- }, J = new WeakSet(), Lt = function(e, t) {
666
- const s = "treeselect-list__item--focused";
667
- if (e) {
668
- const i = Array.from(this.srcElement.querySelectorAll(`.${s}`));
669
- i.length && i.forEach((a) => a.classList.remove(s)), t.classList.add(s);
670
- } else
671
- t.classList.remove(s);
672
- }, Z = new WeakSet(), yt = function() {
673
- const { ungroupedNodes: e, groupedNodes: t, allNodes: s } = pi(this.flattedOptions);
674
- this.selectedNodes = { nodes: e, groupedNodes: t, allNodes: s };
675
- }, Je = new WeakSet(), Ts = function() {
676
- o(this, Z, yt).call(this), this.inputCallback(this.selectedNodes), this.value = this.selectedNodes.nodes.map((e) => e.id);
677
- };
678
- const Vt = ({
679
- parentHtmlContainer: l,
680
- staticList: e,
681
- appendToBody: t,
682
- isSingleSelect: s,
683
- value: i,
684
- direction: a
685
- }) => {
686
- l || console.error("Validation: parentHtmlContainer prop is required!"), e && t && console.error("Validation: You should set staticList to false if you use appendToBody!"), s && Array.isArray(i) && console.error("Validation: if you use isSingleSelect prop, you should pass a single value!"), !s && !Array.isArray(i) && console.error("Validation: you should pass an array as a value!"), a && a !== "auto" && a !== "bottom" && a !== "top" && console.error("Validation: you should pass (auto | top | bottom | undefined) as a value for the direction prop!");
687
- }, re = (l) => l.map((e) => e.id), Oi = (l) => l ? Array.isArray(l) ? l : [l] : [], Ii = (l, e) => {
688
- if (e) {
689
- const [t] = l;
690
- return t ?? null;
691
- }
692
- return l;
693
- };
694
- var d, u, F, Q, q, S, _, L, B, ee, xt, te, St, Ze, Ns, Qe, Os, et, Is, tt, Ps, st, Bs, it, Vs, se, _t, lt, Ds, nt, Hs, at, Gs, ot, Ms, ie, At, rt, Fs, j, he, le, Tt, $, de, ct, qs, ne, Nt, ht, js, dt, $s, ut, Ws, pt, Rs;
695
- class Bi {
696
- constructor({
697
- parentHtmlContainer: e,
698
- value: t,
699
- options: s,
700
- openLevel: i,
701
- appendToBody: a,
702
- alwaysOpen: h,
703
- showTags: p,
704
- tagsCountText: f,
705
- clearable: b,
706
- searchable: C,
707
- placeholder: g,
708
- grouped: w,
709
- isGroupedValue: k,
710
- listSlotHtmlComponent: y,
711
- disabled: I,
712
- emptyText: W,
713
- staticList: ae,
714
- id: bt,
715
- ariaLabel: Ct,
716
- isSingleSelect: oe,
717
- showCount: Us,
718
- disabledBranchNode: zs,
719
- direction: Ys,
720
- expandSelected: Ks,
721
- saveScrollPosition: Xs,
722
- isIndependentNodes: Js,
723
- iconElements: Zs,
724
- inputCallback: Qs,
725
- openCallback: ei,
726
- closeCallback: ti,
727
- nameChangeCallback: si,
728
- searchCallback: ii
729
- }) {
730
- r(this, ee);
731
- r(this, te);
732
- r(this, Ze);
733
- r(this, Qe);
734
- r(this, et);
735
- r(this, tt);
736
- r(this, st);
737
- r(this, it);
738
- r(this, se);
739
- r(this, lt);
740
- r(this, nt);
741
- r(this, at);
742
- r(this, ot);
743
- r(this, ie);
744
- r(this, rt);
745
- r(this, j);
746
- r(this, le);
747
- r(this, $);
748
- r(this, ct);
749
- // Emits
750
- r(this, ne);
751
- r(this, ht);
752
- r(this, dt);
753
- r(this, ut);
754
- r(this, pt);
755
- // Props
756
- c(this, "parentHtmlContainer");
757
- c(this, "value");
758
- c(this, "options");
759
- c(this, "openLevel");
760
- c(this, "appendToBody");
761
- c(this, "alwaysOpen");
762
- c(this, "showTags");
763
- c(this, "tagsCountText");
764
- c(this, "clearable");
765
- c(this, "searchable");
766
- c(this, "placeholder");
767
- c(this, "grouped");
768
- c(this, "isGroupedValue");
769
- c(this, "listSlotHtmlComponent");
770
- c(this, "disabled");
771
- c(this, "emptyText");
772
- c(this, "staticList");
773
- c(this, "id");
774
- c(this, "ariaLabel");
775
- c(this, "isSingleSelect");
776
- c(this, "showCount");
777
- c(this, "disabledBranchNode");
778
- c(this, "direction");
779
- c(this, "expandSelected");
780
- c(this, "saveScrollPosition");
781
- c(this, "isIndependentNodes");
782
- c(this, "iconElements");
783
- c(this, "inputCallback");
784
- c(this, "openCallback");
785
- c(this, "closeCallback");
786
- c(this, "nameChangeCallback");
787
- c(this, "searchCallback");
788
- // InnerState
789
- c(this, "ungroupedValue");
790
- c(this, "groupedValue");
791
- c(this, "allValue");
792
- c(this, "isListOpened");
793
- c(this, "selectedName");
794
- c(this, "srcElement");
795
- // Components
796
- r(this, d, null);
797
- r(this, u, null);
798
- // Resize props
799
- r(this, F, null);
800
- // List position scroll
801
- r(this, Q, 0);
802
- // Timer for search text
803
- r(this, q, 0);
804
- // Outside listeners
805
- r(this, S, null);
806
- r(this, _, null);
807
- r(this, L, null);
808
- r(this, B, null);
809
- Vt({
810
- parentHtmlContainer: e,
811
- value: t,
812
- staticList: ae,
813
- appendToBody: a,
814
- isSingleSelect: oe
815
- }), this.parentHtmlContainer = e, this.value = [], this.options = s ?? [], this.openLevel = i ?? 0, this.appendToBody = a ?? !1, this.alwaysOpen = !!(h && !I), this.showTags = p ?? !0, this.tagsCountText = f ?? "elements selected", this.clearable = b ?? !0, this.searchable = C ?? !0, this.placeholder = g ?? "Search...", this.grouped = w ?? !0, this.isGroupedValue = k ?? !1, this.listSlotHtmlComponent = y ?? null, this.disabled = I ?? !1, this.emptyText = W ?? "No results found...", this.staticList = !!(ae && !this.appendToBody), this.id = bt ?? "", this.ariaLabel = Ct ?? "", this.isSingleSelect = oe ?? !1, this.showCount = Us ?? !1, this.disabledBranchNode = zs ?? !1, this.direction = Ys ?? "auto", this.expandSelected = Ks ?? !1, this.saveScrollPosition = Xs ?? !0, this.isIndependentNodes = Js ?? !1, this.iconElements = Pt(Zs), this.inputCallback = Qs, this.openCallback = ei, this.closeCallback = ti, this.nameChangeCallback = si, this.searchCallback = ii, this.ungroupedValue = [], this.groupedValue = [], this.allValue = [], this.isListOpened = !1, this.selectedName = "", this.srcElement = null, o(this, ee, xt).call(this, t);
816
- }
817
- mount() {
818
- Vt({
819
- parentHtmlContainer: this.parentHtmlContainer,
820
- value: this.value,
821
- staticList: this.staticList,
822
- appendToBody: this.appendToBody,
823
- isSingleSelect: this.isSingleSelect
824
- }), this.iconElements = Pt(this.iconElements), o(this, ee, xt).call(this, this.value);
825
- }
826
- updateValue(e) {
827
- const t = Oi(e), s = n(this, d);
828
- s && (s.updateValue(t), o(this, se, _t).call(this, s == null ? void 0 : s.selectedNodes));
829
- }
830
- destroy() {
831
- this.srcElement && (o(this, ie, At).call(this), this.srcElement.innerHTML = "", this.srcElement = null, o(this, $, de).call(this, !0));
832
- }
833
- focus() {
834
- n(this, u) && n(this, u).focus();
835
- }
836
- toggleOpenClose() {
837
- n(this, u) && (n(this, u).openClose(), n(this, u).focus());
838
- }
839
- // Outside Listeners
840
- scrollWindowHandler() {
841
- this.updateListPosition();
842
- }
843
- focusWindowHandler(e) {
844
- var s, i, a;
845
- ((s = this.srcElement) == null ? void 0 : s.contains(e.target)) || ((i = n(this, d)) == null ? void 0 : i.srcElement.contains(e.target)) || ((a = n(this, u)) == null || a.blur(), o(this, $, de).call(this, !1), o(this, j, he).call(this, !1));
846
- }
847
- blurWindowHandler() {
848
- var e;
849
- (e = n(this, u)) == null || e.blur(), o(this, $, de).call(this, !1), o(this, j, he).call(this, !1);
850
- }
851
- // Update direction of the list. Support appendToBody and standard mode with absolute
852
- updateListPosition() {
853
- var y;
854
- const e = this.srcElement, t = (y = n(this, d)) == null ? void 0 : y.srcElement;
855
- if (!e || !t)
856
- return;
857
- const { height: s } = t.getBoundingClientRect(), {
858
- x: i,
859
- y: a,
860
- height: h,
861
- width: p
862
- } = e.getBoundingClientRect(), f = window.innerHeight, b = a, C = f - a - h;
863
- let g = b > C && b >= s && C < s;
864
- if (this.direction !== "auto" && (g = this.direction === "top"), this.appendToBody) {
865
- (t.style.top !== "0px" || t.style.left !== "0px") && (t.style.top = "0px", t.style.left = "0px");
866
- const I = i + window.scrollX, W = g ? a + window.scrollY - s : a + window.scrollY + h;
867
- t.style.transform = `translate(${I}px,${W}px)`, t.style.width = `${p}px`;
868
- }
869
- const w = g ? "top" : "bottom";
870
- t.getAttribute("direction") !== w && (t.setAttribute("direction", w), o(this, rt, Fs).call(this, g, this.appendToBody));
871
- }
872
- }
873
- d = new WeakMap(), u = new WeakMap(), F = new WeakMap(), Q = new WeakMap(), q = new WeakMap(), S = new WeakMap(), _ = new WeakMap(), L = new WeakMap(), B = new WeakMap(), ee = new WeakSet(), xt = function(e) {
874
- var a;
875
- this.destroy();
876
- const { container: t, list: s, input: i } = o(this, Ze, Ns).call(this);
877
- this.srcElement = t, m(this, d, s), m(this, u, i), m(this, S, this.scrollWindowHandler.bind(this)), m(this, _, this.scrollWindowHandler.bind(this)), m(this, L, this.focusWindowHandler.bind(this)), m(this, B, this.blurWindowHandler.bind(this)), this.alwaysOpen && ((a = n(this, u)) == null || a.openClose()), this.disabled ? this.srcElement.classList.add("treeselect--disabled") : this.srcElement.classList.remove("treeselect--disabled"), this.updateValue(e ?? this.value);
878
- }, te = new WeakSet(), St = function({
879
- groupedNodes: e,
880
- nodes: t,
881
- allNodes: s
882
- }) {
883
- this.ungroupedValue = t ? re(t) : [], this.groupedValue = e ? re(e) : [], this.allValue = s ? re(s) : [];
884
- let i = [];
885
- this.isIndependentNodes || this.isSingleSelect ? i = this.allValue : this.isGroupedValue ? i = this.groupedValue : i = this.ungroupedValue, this.value = Ii(i, this.isSingleSelect);
886
- }, Ze = new WeakSet(), Ns = function() {
887
- const e = this.parentHtmlContainer;
888
- e.classList.add("treeselect");
889
- const t = new Ni({
890
- value: [],
891
- // updateValue method calls in initMount method to set actual value
892
- options: this.options,
893
- openLevel: this.openLevel,
894
- listSlotHtmlComponent: this.listSlotHtmlComponent,
895
- emptyText: this.emptyText,
896
- isSingleSelect: this.isSingleSelect,
897
- showCount: this.showCount,
898
- disabledBranchNode: this.disabledBranchNode,
899
- expandSelected: this.expandSelected,
900
- isIndependentNodes: this.isIndependentNodes,
901
- iconElements: this.iconElements,
902
- inputCallback: (i) => o(this, lt, Ds).call(this, i),
903
- arrowClickCallback: () => o(this, nt, Hs).call(this),
904
- mouseupCallback: () => {
905
- var i;
906
- return (i = n(this, u)) == null ? void 0 : i.focus();
907
- }
908
- }), s = new oi({
909
- value: [],
910
- // updateValue method calls in initMount method to set actual value
911
- showTags: this.showTags,
912
- tagsCountText: this.tagsCountText,
913
- clearable: this.clearable,
914
- isAlwaysOpened: this.alwaysOpen,
915
- searchable: this.searchable,
916
- placeholder: this.placeholder,
917
- disabled: this.disabled,
918
- isSingleSelect: this.isSingleSelect,
919
- id: this.id,
920
- ariaLabel: this.ariaLabel,
921
- iconElements: this.iconElements,
922
- inputCallback: (i) => o(this, Qe, Os).call(this, i),
923
- searchCallback: (i) => o(this, tt, Ps).call(this, i),
924
- openCallback: () => o(this, ot, Ms).call(this),
925
- closeCallback: () => o(this, ie, At).call(this),
926
- keydownCallback: (i) => o(this, et, Is).call(this, i),
927
- focusCallback: () => o(this, st, Bs).call(this),
928
- blurCallback: () => o(this, it, Vs).call(this),
929
- nameChangeCallback: (i) => o(this, at, Gs).call(this, i)
930
- });
931
- return this.appendToBody && m(this, F, new ResizeObserver(() => this.updateListPosition())), e.append(s.srcElement), { container: e, list: t, input: s };
932
- }, Qe = new WeakSet(), Os = function(e) {
933
- var i, a;
934
- const t = re(e);
935
- (i = n(this, d)) == null || i.updateValue(t);
936
- const s = ((a = n(this, d)) == null ? void 0 : a.selectedNodes) ?? {};
937
- o(this, te, St).call(this, s), o(this, ne, Nt).call(this);
938
- }, et = new WeakSet(), Is = function(e) {
939
- var t;
940
- this.isListOpened && ((t = n(this, d)) == null || t.callKeyAction(e));
941
- }, tt = new WeakSet(), Ps = function(e) {
942
- n(this, q) && clearTimeout(n(this, q)), m(this, q, window.setTimeout(() => {
943
- var t;
944
- (t = n(this, d)) == null || t.updateSearchValue(e), this.updateListPosition();
945
- }, 350)), o(this, pt, Rs).call(this, e);
946
- }, st = new WeakSet(), Bs = function() {
947
- o(this, j, he).call(this, !0), n(this, L) && n(this, L) && n(this, B) && (document.addEventListener("mousedown", n(this, L), !0), document.addEventListener("focus", n(this, L), !0), window.addEventListener("blur", n(this, B)));
948
- }, it = new WeakSet(), Vs = function() {
949
- setTimeout(() => {
950
- var s, i;
951
- const e = (s = n(this, u)) == null ? void 0 : s.srcElement.contains(document.activeElement), t = (i = n(this, d)) == null ? void 0 : i.srcElement.contains(document.activeElement);
952
- !e && !t && this.blurWindowHandler();
953
- }, 1);
954
- }, se = new WeakSet(), _t = function(e) {
955
- var s;
956
- if (!e)
957
- return;
958
- let t = [];
959
- this.isIndependentNodes || this.isSingleSelect ? t = e.allNodes : this.grouped ? t = e.groupedNodes : t = e.nodes, (s = n(this, u)) == null || s.updateValue(t), o(this, te, St).call(this, e);
960
- }, lt = new WeakSet(), Ds = function(e) {
961
- var t, s, i;
962
- o(this, se, _t).call(this, e), this.isSingleSelect && !this.alwaysOpen && ((t = n(this, u)) == null || t.openClose(), (s = n(this, u)) == null || s.clearSearch()), (i = n(this, u)) == null || i.focus(), o(this, ne, Nt).call(this);
963
- }, nt = new WeakSet(), Hs = function() {
964
- var e;
965
- (e = n(this, u)) == null || e.focus(), this.updateListPosition();
966
- }, at = new WeakSet(), Gs = function(e) {
967
- this.selectedName !== e && (this.selectedName = e, o(this, ht, js).call(this));
968
- }, ot = new WeakSet(), Ms = function() {
969
- var e;
970
- this.isListOpened = !0, n(this, S) && n(this, _) && (window.addEventListener("scroll", n(this, S), !0), window.addEventListener("resize", n(this, _))), !(!n(this, d) || !this.srcElement) && (this.appendToBody ? (document.body.appendChild(n(this, d).srcElement), (e = n(this, F)) == null || e.observe(this.srcElement)) : this.srcElement.appendChild(n(this, d).srcElement), this.updateListPosition(), o(this, le, Tt).call(this, !0), o(this, ct, qs).call(this), o(this, dt, $s).call(this));
971
- }, ie = new WeakSet(), At = function() {
972
- var t;
973
- this.alwaysOpen || (this.isListOpened = !1, n(this, S) && n(this, _) && (window.removeEventListener("scroll", n(this, S), !0), window.removeEventListener("resize", n(this, _))), !n(this, d) || !this.srcElement) || !(this.appendToBody ? document.body.contains(n(this, d).srcElement) : this.srcElement.contains(n(this, d).srcElement)) || (m(this, Q, n(this, d).srcElement.scrollTop), this.appendToBody ? (document.body.removeChild(n(this, d).srcElement), (t = n(this, F)) == null || t.disconnect()) : this.srcElement.removeChild(n(this, d).srcElement), o(this, le, Tt).call(this, !1), o(this, ut, Ws).call(this));
974
- }, rt = new WeakSet(), Fs = function(e, t) {
975
- if (!n(this, d) || !n(this, u))
976
- return;
977
- const s = t ? "treeselect-list--top-to-body" : "treeselect-list--top", i = t ? "treeselect-list--bottom-to-body" : "treeselect-list--bottom";
978
- e ? (n(this, d).srcElement.classList.add(s), n(this, d).srcElement.classList.remove(i), n(this, u).srcElement.classList.add("treeselect-input--top"), n(this, u).srcElement.classList.remove("treeselect-input--bottom")) : (n(this, d).srcElement.classList.remove(s), n(this, d).srcElement.classList.add(i), n(this, u).srcElement.classList.remove("treeselect-input--top"), n(this, u).srcElement.classList.add("treeselect-input--bottom"));
979
- }, j = new WeakSet(), he = function(e) {
980
- !n(this, u) || !n(this, d) || (e ? (n(this, u).srcElement.classList.add("treeselect-input--focused"), n(this, d).srcElement.classList.add("treeselect-list--focused")) : (n(this, u).srcElement.classList.remove("treeselect-input--focused"), n(this, d).srcElement.classList.remove("treeselect-list--focused")));
981
- }, le = new WeakSet(), Tt = function(e) {
982
- var t, s, i, a;
983
- e ? (t = n(this, u)) == null || t.srcElement.classList.add("treeselect-input--opened") : (s = n(this, u)) == null || s.srcElement.classList.remove("treeselect-input--opened"), this.staticList ? (i = n(this, d)) == null || i.srcElement.classList.add("treeselect-list--static") : (a = n(this, d)) == null || a.srcElement.classList.remove("treeselect-list--static");
984
- }, $ = new WeakSet(), de = function(e) {
985
- !n(this, S) || !n(this, _) || !n(this, L) || !n(this, B) || ((!this.alwaysOpen || e) && (window.removeEventListener("scroll", n(this, S), !0), window.removeEventListener("resize", n(this, _))), document.removeEventListener("mousedown", n(this, L), !0), document.removeEventListener("focus", n(this, L), !0), window.removeEventListener("blur", n(this, B)));
986
- }, ct = new WeakSet(), qs = function() {
987
- var t, s, i;
988
- const e = (t = n(this, d)) == null ? void 0 : t.isLastFocusedElementExist();
989
- this.saveScrollPosition && e ? (s = n(this, d)) == null || s.srcElement.scroll(0, n(this, Q)) : (i = n(this, d)) == null || i.focusFirstListElement();
990
- }, ne = new WeakSet(), Nt = function() {
991
- var e;
992
- (e = this.srcElement) == null || e.dispatchEvent(new CustomEvent("input", { detail: this.value })), this.inputCallback && this.inputCallback(this.value);
993
- }, ht = new WeakSet(), js = function() {
994
- var e;
995
- (e = this.srcElement) == null || e.dispatchEvent(new CustomEvent("name-change", { detail: this.selectedName })), this.nameChangeCallback && this.nameChangeCallback(this.selectedName);
996
- }, dt = new WeakSet(), $s = function() {
997
- var e;
998
- this.alwaysOpen || ((e = this.srcElement) == null || e.dispatchEvent(new CustomEvent("open", { detail: this.value })), this.openCallback && this.openCallback(this.value));
999
- }, ut = new WeakSet(), Ws = function() {
1000
- var e;
1001
- this.alwaysOpen || ((e = this.srcElement) == null || e.dispatchEvent(new CustomEvent("close", { detail: this.value })), this.closeCallback && this.closeCallback(this.value));
1002
- }, pt = new WeakSet(), Rs = function(e) {
1003
- var s;
1004
- const t = (e == null ? void 0 : e.trim()) ?? "";
1005
- (s = this.srcElement) == null || s.dispatchEvent(new CustomEvent("search", { detail: t })), this.searchCallback && this.searchCallback(t);
1006
- };
1007
- export {
1008
- Bi as default
1009
- };
1
+ var ri = Object.defineProperty;
2
+ var ci = (l, e, t) => e in l ? ri(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
+ var c = (l, e, t) => (ci(l, typeof e != "symbol" ? e + "" : e, t), t), kt = (l, e, t) => {
4
+ if (!e.has(l))
5
+ throw TypeError("Cannot " + t);
6
+ };
7
+ var n = (l, e, t) => (kt(l, e, "read from private field"), t ? t.call(l) : e.get(l)), r = (l, e, t) => {
8
+ if (e.has(l))
9
+ throw TypeError("Cannot add the same private member more than once");
10
+ e instanceof WeakSet ? e.add(l) : e.set(l, t);
11
+ }, m = (l, e, t, s) => (kt(l, e, "write to private field"), s ? s.call(l, t) : e.set(l, t), t);
12
+ var o = (l, e, t) => (kt(l, e, "access private method"), t);
13
+ const Pt = {
14
+ arrowUp: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 15l-6-6-6 6"/></svg>',
15
+ arrowDown: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"/></svg>',
16
+ arrowRight: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18l6-6-6-6"/></svg>',
17
+ attention: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>',
18
+ clear: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="15" y1="9" x2="9" y2="15"></line><line x1="9" y1="9" x2="15" y2="15"></line></svg>',
19
+ cross: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>',
20
+ check: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>',
21
+ partialCheck: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"></line></svg>'
22
+ }, I = (l, e) => {
23
+ if (e.innerHTML = "", typeof l == "string")
24
+ e.innerHTML = l;
25
+ else {
26
+ const t = l.cloneNode(!0);
27
+ e.appendChild(t);
28
+ }
29
+ }, Bt = (l) => {
30
+ const e = l ? { ...l } : {};
31
+ return Object.keys(Pt).forEach((t) => {
32
+ e[t] || (e[t] = Pt[t]);
33
+ }), e;
34
+ }, hi = (l) => l.reduce((e, { name: t }, s) => (e += t, s < l.length - 1 && (e += ", "), e), "");
35
+ var N, E, D, v, ue, Ht, H, W, pe, Gt, me, Mt, G, U, O, V, fe, Ft, be, qt, Ce, jt, ge, Rt, ke, $t, we, Wt, Ee, Ut, ve, zt, Le, Yt, ye, Kt, xe, Xt, Se, Jt, _e, Zt, Ae, Qt, Te, es, Ne, ts, z, wt;
36
+ class di {
37
+ constructor({
38
+ value: e,
39
+ showTags: t,
40
+ tagsCountText: s,
41
+ clearable: i,
42
+ isAlwaysOpened: a,
43
+ searchable: h,
44
+ placeholder: d,
45
+ disabled: C,
46
+ isSingleSelect: f,
47
+ id: b,
48
+ ariaLabel: g,
49
+ iconElements: k,
50
+ inputCallback: w,
51
+ searchCallback: y,
52
+ openCallback: x,
53
+ closeCallback: $,
54
+ keydownCallback: ae,
55
+ focusCallback: Ct,
56
+ blurCallback: gt,
57
+ nameChangeCallback: oe
58
+ }) {
59
+ // Private methods
60
+ r(this, ue);
61
+ r(this, H);
62
+ r(this, pe);
63
+ r(this, me);
64
+ r(this, G);
65
+ r(this, O);
66
+ r(this, fe);
67
+ r(this, be);
68
+ r(this, Ce);
69
+ r(this, ge);
70
+ r(this, ke);
71
+ r(this, we);
72
+ r(this, Ee);
73
+ r(this, ve);
74
+ r(this, Le);
75
+ r(this, ye);
76
+ r(this, xe);
77
+ r(this, Se);
78
+ r(this, _e);
79
+ r(this, Ae);
80
+ r(this, Te);
81
+ r(this, Ne);
82
+ // Emits
83
+ r(this, z);
84
+ // Props
85
+ c(this, "value");
86
+ c(this, "showTags");
87
+ c(this, "tagsCountText");
88
+ c(this, "clearable");
89
+ c(this, "isAlwaysOpened");
90
+ c(this, "searchable");
91
+ c(this, "placeholder");
92
+ c(this, "disabled");
93
+ c(this, "isSingleSelect");
94
+ c(this, "id");
95
+ c(this, "ariaLabel");
96
+ c(this, "iconElements");
97
+ // InnerState
98
+ c(this, "isOpened");
99
+ c(this, "searchText");
100
+ c(this, "srcElement");
101
+ // PrivateInnerState
102
+ r(this, N, void 0);
103
+ r(this, E, void 0);
104
+ r(this, D, void 0);
105
+ r(this, v, void 0);
106
+ // Callbacks
107
+ c(this, "inputCallback");
108
+ c(this, "searchCallback");
109
+ c(this, "openCallback");
110
+ c(this, "closeCallback");
111
+ c(this, "keydownCallback");
112
+ c(this, "focusCallback");
113
+ c(this, "blurCallback");
114
+ c(this, "nameChangeCallback");
115
+ this.value = e, this.showTags = t, this.tagsCountText = s, this.searchable = h, this.placeholder = d, this.clearable = i, this.isAlwaysOpened = a, this.disabled = C, this.isSingleSelect = f, this.id = b, this.ariaLabel = g, this.iconElements = k, this.isOpened = !1, this.searchText = "", m(this, N, o(this, Ce, jt).call(this)), m(this, E, o(this, Le, Yt).call(this)), m(this, D, o(this, Se, Jt).call(this)), m(this, v, null), this.inputCallback = w, this.searchCallback = y, this.openCallback = x, this.closeCallback = $, this.keydownCallback = ae, this.focusCallback = Ct, this.blurCallback = gt, this.nameChangeCallback = oe, this.srcElement = o(this, fe, Ft).call(this, n(this, N), n(this, E), n(this, D)), o(this, ue, Ht).call(this);
116
+ }
117
+ // Public methods
118
+ focus() {
119
+ setTimeout(() => n(this, E).focus(), 0);
120
+ }
121
+ blur() {
122
+ this.isOpened && o(this, O, V).call(this), this.clearSearch(), n(this, E).blur();
123
+ }
124
+ updateValue(e) {
125
+ this.value = e, o(this, H, W).call(this), o(this, G, U).call(this);
126
+ }
127
+ removeItem(e) {
128
+ this.value = this.value.filter((t) => t.id !== e), o(this, z, wt).call(this), o(this, H, W).call(this), o(this, G, U).call(this);
129
+ }
130
+ clear() {
131
+ this.value = [], o(this, z, wt).call(this), o(this, H, W).call(this), this.clearSearch();
132
+ }
133
+ openClose() {
134
+ o(this, O, V).call(this);
135
+ }
136
+ clearSearch() {
137
+ this.searchText = "", this.searchCallback(""), o(this, G, U).call(this);
138
+ }
139
+ }
140
+ N = new WeakMap(), E = new WeakMap(), D = new WeakMap(), v = new WeakMap(), ue = new WeakSet(), Ht = function() {
141
+ o(this, H, W).call(this), o(this, G, U).call(this), o(this, pe, Gt).call(this);
142
+ }, H = new WeakSet(), W = function() {
143
+ if (n(this, N).innerHTML = "", this.showTags) {
144
+ n(this, N).append(...o(this, ge, Rt).call(this));
145
+ const e = hi(this.value);
146
+ this.nameChangeCallback(e);
147
+ } else {
148
+ const e = o(this, ve, zt).call(this);
149
+ n(this, N).appendChild(e), this.nameChangeCallback(e.innerText);
150
+ }
151
+ n(this, N).appendChild(n(this, E));
152
+ }, pe = new WeakSet(), Gt = function() {
153
+ const e = [];
154
+ n(this, D).innerHTML = "", this.clearable && e.push(o(this, _e, Zt).call(this)), this.isAlwaysOpened || e.push(o(this, Te, es).call(this, this.isOpened)), e.length && n(this, D).append(...e);
155
+ }, me = new WeakSet(), Mt = function() {
156
+ if (!this.isAlwaysOpened && n(this, v)) {
157
+ const e = this.isOpened ? this.iconElements.arrowUp : this.iconElements.arrowDown;
158
+ I(e, n(this, v));
159
+ }
160
+ }, G = new WeakSet(), U = function() {
161
+ var e;
162
+ (e = this.value) != null && e.length ? (n(this, E).removeAttribute("placeholder"), this.srcElement.classList.remove("treeselect-input--value-not-selected")) : (n(this, E).setAttribute("placeholder", this.placeholder), this.srcElement.classList.add("treeselect-input--value-not-selected")), this.searchable ? this.srcElement.classList.remove("treeselect-input--unsearchable") : this.srcElement.classList.add("treeselect-input--unsearchable"), this.isSingleSelect ? this.srcElement.classList.add("treeselect-input--is-single-select") : this.srcElement.classList.remove("treeselect-input--is-single-select"), n(this, E).value = this.searchText;
163
+ }, O = new WeakSet(), V = function() {
164
+ this.isOpened = !this.isOpened, o(this, me, Mt).call(this), this.isOpened ? this.openCallback() : this.closeCallback();
165
+ }, fe = new WeakSet(), Ft = function(e, t, s) {
166
+ const i = document.createElement("div");
167
+ return i.classList.add("treeselect-input"), i.setAttribute("tabindex", "-1"), i.addEventListener("mousedown", (a) => o(this, be, qt).call(this, a)), i.addEventListener("focus", () => this.focusCallback(), !0), i.addEventListener("blur", () => this.blurCallback(), !0), e.appendChild(t), i.append(e, s), i;
168
+ }, be = new WeakSet(), qt = function(e) {
169
+ e.stopPropagation(), this.isOpened || o(this, O, V).call(this), this.focus();
170
+ }, Ce = new WeakSet(), jt = function() {
171
+ const e = document.createElement("div");
172
+ return e.classList.add("treeselect-input__tags"), e;
173
+ }, ge = new WeakSet(), Rt = function() {
174
+ return this.value.map((e) => {
175
+ const t = document.createElement("div");
176
+ t.classList.add("treeselect-input__tags-element"), t.setAttribute("tabindex", "-1"), t.setAttribute("tag-id", e.id.toString()), t.setAttribute("title", e.name);
177
+ const s = o(this, we, Wt).call(this, e.name), i = o(this, Ee, Ut).call(this);
178
+ return t.addEventListener("mousedown", (a) => o(this, ke, $t).call(this, a, e.id)), t.append(s, i), t;
179
+ });
180
+ }, ke = new WeakSet(), $t = function(e, t) {
181
+ e.preventDefault(), e.stopPropagation(), this.removeItem(t), this.focus();
182
+ }, we = new WeakSet(), Wt = function(e) {
183
+ const t = document.createElement("span");
184
+ return t.classList.add("treeselect-input__tags-name"), t.textContent = e, t;
185
+ }, Ee = new WeakSet(), Ut = function() {
186
+ const e = document.createElement("span");
187
+ return e.classList.add("treeselect-input__tags-cross"), I(this.iconElements.cross, e), e;
188
+ }, ve = new WeakSet(), zt = function() {
189
+ const e = document.createElement("span");
190
+ if (e.classList.add("treeselect-input__tags-count"), !this.value.length)
191
+ return e.textContent = "", e.setAttribute("title", ""), e;
192
+ const t = this.value.length === 1 ? this.value[0].name : `${this.value.length} ${this.tagsCountText}`;
193
+ return e.textContent = t, e.setAttribute("title", t), e;
194
+ }, Le = new WeakSet(), Yt = function() {
195
+ const e = document.createElement("input");
196
+ return e.classList.add("treeselect-input__edit"), this.id && e.setAttribute("id", this.id), (!this.searchable || this.disabled) && e.setAttribute("readonly", "readonly"), this.disabled && e.setAttribute("tabindex", "-1"), this.ariaLabel.length && e.setAttribute("aria-label", this.ariaLabel), e.addEventListener("keydown", (t) => o(this, ye, Kt).call(this, t)), e.addEventListener("input", (t) => o(this, xe, Xt).call(this, t, e)), e;
197
+ }, ye = new WeakSet(), Kt = function(e) {
198
+ e.stopPropagation();
199
+ const t = e.key;
200
+ t === "Backspace" && !this.searchText.length && this.value.length && !this.showTags && this.clear(), t === "Backspace" && !this.searchText.length && this.value.length && this.removeItem(this.value[this.value.length - 1].id), e.code === "Space" && (!this.searchText || !this.searchable) && o(this, O, V).call(this), (t === "Enter" || t === "ArrowDown" || t === "ArrowUp") && e.preventDefault(), this.keydownCallback(e), t !== "Tab" && this.focus();
201
+ }, xe = new WeakSet(), Xt = function(e, t) {
202
+ e.stopPropagation();
203
+ const s = this.searchText, i = t.value.trim();
204
+ if (s.length === 0 && i.length === 0) {
205
+ t.value = "";
206
+ return;
207
+ }
208
+ if (this.searchable) {
209
+ const a = e.target.value;
210
+ this.searchCallback(a), this.isOpened || o(this, O, V).call(this);
211
+ } else
212
+ t.value = "";
213
+ this.searchText = t.value;
214
+ }, Se = new WeakSet(), Jt = function() {
215
+ const e = document.createElement("div");
216
+ return e.classList.add("treeselect-input__operators"), e;
217
+ }, _e = new WeakSet(), Zt = function() {
218
+ const e = document.createElement("span");
219
+ return e.classList.add("treeselect-input__clear"), e.setAttribute("tabindex", "-1"), I(this.iconElements.clear, e), e.addEventListener("mousedown", (t) => o(this, Ae, Qt).call(this, t)), e;
220
+ }, Ae = new WeakSet(), Qt = function(e) {
221
+ e.preventDefault(), e.stopPropagation(), (this.searchText.length || this.value.length) && this.clear(), this.focus();
222
+ }, Te = new WeakSet(), es = function(e) {
223
+ m(this, v, document.createElement("span")), n(this, v).classList.add("treeselect-input__arrow");
224
+ const t = e ? this.iconElements.arrowUp : this.iconElements.arrowDown;
225
+ return I(t, n(this, v)), n(this, v).addEventListener("mousedown", (s) => o(this, Ne, ts).call(this, s)), n(this, v);
226
+ }, Ne = new WeakSet(), ts = function(e) {
227
+ e.stopPropagation(), e.preventDefault(), this.focus(), o(this, O, V).call(this);
228
+ }, z = new WeakSet(), wt = function() {
229
+ this.inputCallback(this.value);
230
+ };
231
+ const ss = (l, e, t, s) => {
232
+ fi(e);
233
+ const i = e.filter((a) => !a.disabled && l.some((h) => h === a.id));
234
+ if (t && i.length) {
235
+ i[0].checked = !0;
236
+ return;
237
+ }
238
+ i.forEach((a) => {
239
+ a.checked = !0;
240
+ const h = It(a, e, s);
241
+ a.checked = h;
242
+ });
243
+ }, It = ({ id: l, checked: e }, t, s) => {
244
+ const i = t.find((h) => h.id === l);
245
+ if (!i)
246
+ return !1;
247
+ if (s)
248
+ return i.checked = i.disabled ? !1 : !!e, i.checked;
249
+ const a = is(!!e, i, t);
250
+ return ls(i, t), a;
251
+ }, is = (l, e, t) => {
252
+ if (!e.isGroup)
253
+ return e.checked = e.disabled ? !1 : !!l, e.isPartialChecked = !1, e.checked;
254
+ const s = t.filter((d) => d.childOf === e.id);
255
+ return !l || e.disabled || e.isPartialChecked ? (e.checked = !1, e.isPartialChecked = !1, Et(e, s, t), e.checked) : ns(s, t) ? as(s) ? (e.checked = !1, e.isPartialChecked = !1, e.disabled = !0, e.checked) : (e.checked = !1, e.isPartialChecked = !0, s.forEach((d) => {
256
+ is(l, d, t);
257
+ }), e.checked) : (e.checked = !0, e.isPartialChecked = !1, Et(e, s, t), e.checked);
258
+ }, ls = (l, e) => {
259
+ const t = e.find((s) => s.id === l.childOf);
260
+ t && (ui(t, e), ls(t, e));
261
+ }, ui = (l, e) => {
262
+ const t = ft(l, e);
263
+ if (as(t)) {
264
+ l.checked = !1, l.isPartialChecked = !1, l.disabled = !0;
265
+ return;
266
+ }
267
+ if (pi(t)) {
268
+ l.checked = !0, l.isPartialChecked = !1;
269
+ return;
270
+ }
271
+ if (mi(t)) {
272
+ l.checked = !1, l.isPartialChecked = !0;
273
+ return;
274
+ }
275
+ l.checked = !1, l.isPartialChecked = !1;
276
+ }, Et = ({ checked: l, disabled: e }, t, s) => {
277
+ t.forEach((i) => {
278
+ i.disabled = !!e || !!i.disabled, i.checked = !!l && !i.disabled, i.isPartialChecked = !1;
279
+ const a = ft(i, s);
280
+ Et({ checked: l, disabled: e }, a, s);
281
+ });
282
+ }, ns = (l, e) => l.some((i) => i.disabled) ? !0 : l.some((i) => {
283
+ if (i.isGroup) {
284
+ const a = ft(i, e);
285
+ return ns(a, e);
286
+ }
287
+ return !1;
288
+ }), as = (l) => l.every((e) => !!e.disabled), pi = (l) => l.every((e) => !!e.checked), mi = (l) => l.some((e) => !!e.checked || !!e.isPartialChecked), fi = (l) => {
289
+ l.forEach((e) => {
290
+ e.checked = !1, e.isPartialChecked = !1;
291
+ });
292
+ }, bi = (l, e, t) => {
293
+ const s = { level: 0, groupId: "" }, i = os(l, e, s.groupId, s.level);
294
+ return gi(i, t);
295
+ }, os = (l, e, t, s) => l.reduce((i, a) => {
296
+ var f;
297
+ const h = !!((f = a.children) != null && f.length), d = s >= e && h, C = s > e;
298
+ if (i.push({
299
+ id: a.value,
300
+ name: a.name,
301
+ childOf: t,
302
+ isGroup: h,
303
+ checked: !1,
304
+ isPartialChecked: !1,
305
+ level: s,
306
+ isClosed: d,
307
+ hidden: C,
308
+ disabled: a.disabled ?? !1
309
+ }), h) {
310
+ const b = os(a.children, e, a.value, s + 1);
311
+ i.push(...b);
312
+ }
313
+ return i;
314
+ }, []), ft = ({ id: l }, e) => e.filter((t) => t.childOf === l), Ci = (l) => {
315
+ const { ungroupedNodes: e, allGroupedNodes: t, allNodes: s } = l.reduce(
316
+ (a, h) => (h.checked && (a.allNodes.push(h), h.isGroup ? a.allGroupedNodes.push(h) : a.ungroupedNodes.push(h)), a),
317
+ {
318
+ ungroupedNodes: [],
319
+ allGroupedNodes: [],
320
+ allNodes: []
321
+ }
322
+ ), i = s.filter((a) => !t.some(({ id: h }) => h === a.childOf));
323
+ return { ungroupedNodes: e, groupedNodes: i, allNodes: s };
324
+ }, gi = (l, e) => (l.filter((s) => !!s.disabled).forEach(
325
+ ({ id: s }) => It({ id: s, checked: !1 }, l, e)
326
+ ), l), bt = (l, { id: e, isClosed: t }) => {
327
+ ft({ id: e }, l).forEach((i) => {
328
+ i.hidden = t ?? !1, i.isGroup && !i.isClosed && bt(l, { id: i.id, isClosed: t });
329
+ });
330
+ }, ki = (l) => {
331
+ l.filter((e) => e.isGroup && !e.disabled && (e.checked || e.isPartialChecked)).forEach((e) => {
332
+ e.isClosed = !1, bt(l, e);
333
+ });
334
+ }, wi = (l, e) => {
335
+ const t = Ei(l, e);
336
+ l.forEach((s) => {
337
+ t.some(({ id: a }) => a === s.id) ? (s.isGroup && (s.isClosed = !1, bt(l, s)), s.hidden = !1) : s.hidden = !0;
338
+ });
339
+ }, Ei = (l, e) => l.reduce((t, s) => {
340
+ if (s.name.toLowerCase().includes(e.toLowerCase())) {
341
+ if (t.push(s), s.isGroup) {
342
+ const a = rs(s.id, l);
343
+ t.push(...a);
344
+ }
345
+ if (s.childOf) {
346
+ const a = cs(s.childOf, l);
347
+ t.push(...a);
348
+ }
349
+ }
350
+ return t;
351
+ }, []), rs = (l, e) => e.reduce((t, s) => (s.childOf === l && (t.push(s), s.isGroup && t.push(...rs(s.id, e))), t), []), cs = (l, e) => e.reduce((t, s) => (s.id === l && (t.push(s), s.childOf && t.push(...cs(s.childOf, e))), t), []), vi = (l) => {
352
+ const { duplications: e } = l.reduce(
353
+ (t, s) => (t.allItems.some((i) => i.toString() === s.id.toString()) && t.duplications.push(s.id), t.allItems.push(s.id), t),
354
+ {
355
+ duplications: [],
356
+ allItems: []
357
+ }
358
+ );
359
+ e.length && console.error(`Validation: You have duplicated values: ${e.join(", ")}! You should use unique values.`);
360
+ }, Li = (l, e, t, s, i, a, h, d, C, f) => {
361
+ ss(l, e, i, C), d && h && ki(e), ce(e, t, s, a, f);
362
+ }, ce = (l, e, t, s, i) => {
363
+ l.forEach((a) => {
364
+ const h = e.querySelector(`[input-id="${a.id}"]`), d = T(h);
365
+ h.checked = a.checked, yi(a, d, s), xi(a, d), Si(a, d), _i(a, d, t), Ai(a, d), Ni(a, d, l, i), Ti(a, h, t);
366
+ }), Oi(l, e);
367
+ }, yi = (l, e, t) => {
368
+ l.checked ? e.classList.add("treeselect-list__item--checked") : e.classList.remove("treeselect-list__item--checked"), Array.isArray(t) && t[0] === l.id && !l.disabled ? e.classList.add("treeselect-list__item--single-selected") : e.classList.remove("treeselect-list__item--single-selected");
369
+ }, xi = (l, e) => {
370
+ l.isPartialChecked ? e.classList.add("treeselect-list__item--partial-checked") : e.classList.remove("treeselect-list__item--partial-checked");
371
+ }, Si = (l, e) => {
372
+ l.disabled ? e.classList.add("treeselect-list__item--disabled") : e.classList.remove("treeselect-list__item--disabled");
373
+ }, _i = (l, e, t) => {
374
+ if (l.isGroup) {
375
+ const s = e.querySelector(".treeselect-list__item-icon"), i = l.isClosed ? t.arrowRight : t.arrowDown;
376
+ I(i, s), l.isClosed ? e.classList.add("treeselect-list__item--closed") : e.classList.remove("treeselect-list__item--closed");
377
+ }
378
+ }, Ai = (l, e) => {
379
+ l.hidden ? e.classList.add("treeselect-list__item--hidden") : e.classList.remove("treeselect-list__item--hidden");
380
+ }, Ti = (l, e, t) => {
381
+ const i = e.parentNode.querySelector(".treeselect-list__item-checkbox-icon");
382
+ l.checked ? I(t.check, i) : l.isPartialChecked ? I(t.partialCheck, i) : i.innerHTML = "";
383
+ }, Ni = (l, e, t, s) => {
384
+ const i = l.level === 0, a = 20, h = 5;
385
+ if (i) {
386
+ const d = t.some((b) => b.isGroup && b.level === l.level), C = !l.isGroup && d ? `${a}px` : `${h}px`, f = l.isGroup ? "0" : C;
387
+ s ? e.style.paddingRight = f : e.style.paddingLeft = f;
388
+ } else {
389
+ const d = l.isGroup ? `${l.level * a}px` : `${l.level * a + a}px`;
390
+ s ? e.style.paddingRight = d : e.style.paddingLeft = d;
391
+ }
392
+ e.setAttribute("level", l.level.toString()), e.setAttribute("group", l.isGroup.toString());
393
+ }, Oi = (l, e) => {
394
+ const t = l.some((i) => !i.hidden), s = e.querySelector(".treeselect-list__empty");
395
+ t ? s.classList.add("treeselect-list__empty--hidden") : s.classList.remove("treeselect-list__empty--hidden");
396
+ }, T = (l) => l.parentNode.parentNode, Vt = (l, e) => e.find((t) => t.id.toString() === l), Ii = (l) => T(l).querySelector(".treeselect-list__item-icon"), Pi = (l, e) => {
397
+ e && Object.keys(e).forEach((t) => {
398
+ const s = e[t];
399
+ typeof s == "string" && l.setAttribute(t, s);
400
+ });
401
+ };
402
+ var M, P, S, Y, Oe, hs, Ie, ds, Pe, us, Be, ps, Ve, ms, De, fs, K, vt, He, bs, Ge, Cs, Me, gs, X, Lt, Fe, ks, qe, ws, je, Es, Re, vs, $e, Ls, We, ys, Ue, xs, ze, Ss, Ye, _s, Ke, As, Xe, Ts, J, yt, Z, xt, Je, Ns;
403
+ class Bi {
404
+ constructor({
405
+ options: e,
406
+ value: t,
407
+ openLevel: s,
408
+ listSlotHtmlComponent: i,
409
+ emptyText: a,
410
+ isSingleSelect: h,
411
+ iconElements: d,
412
+ showCount: C,
413
+ disabledBranchNode: f,
414
+ expandSelected: b,
415
+ isIndependentNodes: g,
416
+ rtl: k,
417
+ inputCallback: w,
418
+ arrowClickCallback: y,
419
+ mouseupCallback: x
420
+ }) {
421
+ // Private methods
422
+ r(this, Oe);
423
+ r(this, Ie);
424
+ r(this, Pe);
425
+ r(this, Be);
426
+ r(this, Ve);
427
+ r(this, De);
428
+ r(this, K);
429
+ r(this, He);
430
+ r(this, Ge);
431
+ r(this, Me);
432
+ r(this, X);
433
+ r(this, Fe);
434
+ r(this, qe);
435
+ r(this, je);
436
+ r(this, Re);
437
+ r(this, $e);
438
+ r(this, We);
439
+ r(this, Ue);
440
+ r(this, ze);
441
+ r(this, Ye);
442
+ // Actions
443
+ r(this, Ke);
444
+ r(this, Xe);
445
+ r(this, J);
446
+ r(this, Z);
447
+ // Emits
448
+ r(this, Je);
449
+ // Props
450
+ c(this, "options");
451
+ c(this, "value");
452
+ c(this, "openLevel");
453
+ c(this, "listSlotHtmlComponent");
454
+ c(this, "emptyText");
455
+ c(this, "isSingleSelect");
456
+ c(this, "showCount");
457
+ c(this, "disabledBranchNode");
458
+ c(this, "expandSelected");
459
+ c(this, "isIndependentNodes");
460
+ c(this, "rtl");
461
+ c(this, "iconElements");
462
+ // InnerState
463
+ c(this, "searchText");
464
+ c(this, "flattedOptions");
465
+ c(this, "flattedOptionsBeforeSearch");
466
+ c(this, "selectedNodes");
467
+ c(this, "srcElement");
468
+ // Callbacks
469
+ c(this, "inputCallback");
470
+ c(this, "arrowClickCallback");
471
+ c(this, "mouseupCallback");
472
+ // PrivateInnerState
473
+ r(this, M, null);
474
+ r(this, P, !0);
475
+ r(this, S, []);
476
+ r(this, Y, !0);
477
+ this.options = e, this.value = t, this.openLevel = s ?? 0, this.listSlotHtmlComponent = i ?? null, this.emptyText = a ?? "No results found...", this.isSingleSelect = h ?? !1, this.showCount = C ?? !1, this.disabledBranchNode = f ?? !1, this.expandSelected = b ?? !1, this.isIndependentNodes = g ?? !1, this.rtl = k ?? !1, this.iconElements = d, this.searchText = "", this.flattedOptions = bi(this.options, this.openLevel, this.isIndependentNodes), this.flattedOptionsBeforeSearch = this.flattedOptions, this.selectedNodes = { nodes: [], groupedNodes: [], allNodes: [] }, this.srcElement = o(this, Pe, us).call(this), this.inputCallback = w, this.arrowClickCallback = y, this.mouseupCallback = x, vi(this.flattedOptions);
478
+ }
479
+ // Public methods
480
+ updateValue(e) {
481
+ this.value = e, m(this, S, this.isSingleSelect ? this.value : []), Li(
482
+ e,
483
+ this.flattedOptions,
484
+ this.srcElement,
485
+ this.iconElements,
486
+ this.isSingleSelect,
487
+ n(this, S),
488
+ this.expandSelected,
489
+ n(this, Y),
490
+ this.isIndependentNodes,
491
+ this.rtl
492
+ ), m(this, Y, !1), o(this, Z, xt).call(this);
493
+ }
494
+ updateSearchValue(e) {
495
+ if (e === this.searchText)
496
+ return;
497
+ const t = this.searchText === "" && e !== "";
498
+ this.searchText = e, t && (this.flattedOptionsBeforeSearch = JSON.parse(JSON.stringify(this.flattedOptions))), this.searchText === "" && (this.flattedOptions = this.flattedOptionsBeforeSearch.map((s) => {
499
+ const i = this.flattedOptions.find((a) => a.id === s.id);
500
+ return i.isClosed = s.isClosed, i.hidden = s.hidden, i;
501
+ }), this.flattedOptionsBeforeSearch = []), this.searchText && wi(this.flattedOptions, e), ce(this.flattedOptions, this.srcElement, this.iconElements, n(this, S), this.rtl), this.focusFirstListElement();
502
+ }
503
+ callKeyAction(e) {
504
+ m(this, P, !1);
505
+ const t = this.srcElement.querySelector(".treeselect-list__item--focused");
506
+ if (t == null ? void 0 : t.classList.contains("treeselect-list__item--hidden"))
507
+ return;
508
+ const i = e.key;
509
+ i === "Enter" && t && t.dispatchEvent(new Event("mousedown")), (i === "ArrowLeft" || i === "ArrowRight") && o(this, Oe, hs).call(this, t, e), (i === "ArrowDown" || i === "ArrowUp") && o(this, Ie, ds).call(this, t, i);
510
+ }
511
+ focusFirstListElement() {
512
+ const e = "treeselect-list__item--focused", t = this.srcElement.querySelector(`.${e}`), s = Array.from(this.srcElement.querySelectorAll(".treeselect-list__item-checkbox")).filter(
513
+ (a) => window.getComputedStyle(T(a)).display !== "none"
514
+ );
515
+ if (!s.length)
516
+ return;
517
+ t && t.classList.remove(e), T(s[0]).classList.add(e);
518
+ }
519
+ isLastFocusedElementExist() {
520
+ return !!n(this, M);
521
+ }
522
+ }
523
+ M = new WeakMap(), P = new WeakMap(), S = new WeakMap(), Y = new WeakMap(), Oe = new WeakSet(), hs = function(e, t) {
524
+ if (!e)
525
+ return;
526
+ const s = t.key, a = e.querySelector(".treeselect-list__item-checkbox").getAttribute("input-id"), h = Vt(a, this.flattedOptions), d = e.querySelector(".treeselect-list__item-icon");
527
+ s === "ArrowLeft" && !h.isClosed && h.isGroup && (d.dispatchEvent(new Event("mousedown")), t.preventDefault()), s === "ArrowRight" && h.isClosed && h.isGroup && (d.dispatchEvent(new Event("mousedown")), t.preventDefault());
528
+ }, Ie = new WeakSet(), ds = function(e, t) {
529
+ var i;
530
+ const s = Array.from(this.srcElement.querySelectorAll(".treeselect-list__item-checkbox")).filter(
531
+ (a) => window.getComputedStyle(T(a)).display !== "none"
532
+ );
533
+ if (s.length)
534
+ if (!e)
535
+ T(s[0]).classList.add("treeselect-list__item--focused");
536
+ else {
537
+ const a = s.findIndex(
538
+ (x) => T(x).classList.contains("treeselect-list__item--focused")
539
+ );
540
+ T(s[a]).classList.remove("treeselect-list__item--focused");
541
+ const d = t === "ArrowDown" ? a + 1 : a - 1, C = t === "ArrowDown" ? 0 : s.length - 1, f = s[d] ?? s[C], b = !s[d], g = T(f);
542
+ g.classList.add("treeselect-list__item--focused");
543
+ const k = this.srcElement.getBoundingClientRect(), w = g.getBoundingClientRect();
544
+ if (b && t === "ArrowDown") {
545
+ this.srcElement.scroll(0, 0);
546
+ return;
547
+ }
548
+ if (b && t === "ArrowUp") {
549
+ this.srcElement.scroll(0, this.srcElement.scrollHeight);
550
+ return;
551
+ }
552
+ const y = ((i = this.listSlotHtmlComponent) == null ? void 0 : i.clientHeight) ?? 0;
553
+ if (k.y + k.height < w.y + w.height + y) {
554
+ this.srcElement.scroll(0, this.srcElement.scrollTop + w.height);
555
+ return;
556
+ }
557
+ if (k.y > w.y) {
558
+ this.srcElement.scroll(0, this.srcElement.scrollTop - w.height);
559
+ return;
560
+ }
561
+ }
562
+ }, Pe = new WeakSet(), us = function() {
563
+ const e = o(this, Be, ps).call(this), t = o(this, K, vt).call(this, this.options);
564
+ e.append(...t);
565
+ const s = o(this, Ge, Cs).call(this);
566
+ e.append(s);
567
+ const i = o(this, He, bs).call(this);
568
+ return i && e.append(i), e;
569
+ }, Be = new WeakSet(), ps = function() {
570
+ const e = document.createElement("div");
571
+ return e.classList.add("treeselect-list"), this.isSingleSelect && e.classList.add("treeselect-list--single-select"), this.disabledBranchNode && e.classList.add("treeselect-list--disabled-branch-node"), e.addEventListener("mouseout", (t) => o(this, Ve, ms).call(this, t)), e.addEventListener("mousemove", () => o(this, De, fs).call(this)), e.addEventListener("mouseup", () => this.mouseupCallback(), !0), e;
572
+ }, Ve = new WeakSet(), ms = function(e) {
573
+ e.stopPropagation(), n(this, M) && n(this, P) && n(this, M).classList.add("treeselect-list__item--focused");
574
+ }, De = new WeakSet(), fs = function() {
575
+ m(this, P, !0);
576
+ }, K = new WeakSet(), vt = function(e) {
577
+ return e.reduce((t, s) => {
578
+ var a;
579
+ if ((a = s.children) != null && a.length) {
580
+ const h = o(this, Me, gs).call(this, s), d = o(this, K, vt).call(this, s.children);
581
+ return h.append(...d), t.push(h), t;
582
+ }
583
+ const i = o(this, X, Lt).call(this, s, !1);
584
+ return t.push(i), t;
585
+ }, []);
586
+ }, He = new WeakSet(), bs = function() {
587
+ if (!this.listSlotHtmlComponent)
588
+ return null;
589
+ const e = document.createElement("div");
590
+ return e.classList.add("treeselect-list__slot"), e.appendChild(this.listSlotHtmlComponent), e;
591
+ }, Ge = new WeakSet(), Cs = function() {
592
+ const e = document.createElement("div");
593
+ e.classList.add("treeselect-list__empty"), e.setAttribute("title", this.emptyText);
594
+ const t = document.createElement("span");
595
+ t.classList.add("treeselect-list__empty-icon"), I(this.iconElements.attention, t);
596
+ const s = document.createElement("span");
597
+ return s.classList.add("treeselect-list__empty-text"), s.textContent = this.emptyText, e.append(t, s), e;
598
+ }, Me = new WeakSet(), gs = function(e) {
599
+ const t = document.createElement("div");
600
+ t.setAttribute("group-container-id", e.value.toString()), t.classList.add("treeselect-list__group-container");
601
+ const s = o(this, X, Lt).call(this, e, !0);
602
+ return t.appendChild(s), t;
603
+ }, X = new WeakSet(), Lt = function(e, t) {
604
+ const s = o(this, Fe, ks).call(this, e);
605
+ if (t) {
606
+ const h = o(this, $e, Ls).call(this);
607
+ s.appendChild(h), s.classList.add("treeselect-list__item--group");
608
+ }
609
+ const i = o(this, Ue, xs).call(this, e), a = o(this, ze, Ss).call(this, e, t);
610
+ return s.append(i, a), s;
611
+ }, Fe = new WeakSet(), ks = function(e) {
612
+ const t = document.createElement("div");
613
+ return Pi(t, e.htmlAttr), t.setAttribute("tabindex", "-1"), t.setAttribute("title", e.name), t.classList.add("treeselect-list__item"), t.addEventListener("mouseover", () => o(this, qe, ws).call(this, t), !0), t.addEventListener("mouseout", () => o(this, je, Es).call(this, t), !0), t.addEventListener("mousedown", (s) => o(this, Re, vs).call(this, s, e)), t;
614
+ }, qe = new WeakSet(), ws = function(e) {
615
+ n(this, P) && o(this, J, yt).call(this, !0, e);
616
+ }, je = new WeakSet(), Es = function(e) {
617
+ n(this, P) && (o(this, J, yt).call(this, !1, e), m(this, M, e));
618
+ }, Re = new WeakSet(), vs = function(e, t) {
619
+ var a;
620
+ if (e.preventDefault(), e.stopPropagation(), (a = this.flattedOptions.find((h) => h.id === t.value)) == null ? void 0 : a.disabled)
621
+ return;
622
+ const i = e.target.querySelector(".treeselect-list__item-checkbox");
623
+ i.checked = !i.checked, o(this, Ke, As).call(this, i, t);
624
+ }, $e = new WeakSet(), Ls = function() {
625
+ const e = document.createElement("span");
626
+ return e.setAttribute("tabindex", "-1"), e.classList.add("treeselect-list__item-icon"), I(this.iconElements.arrowDown, e), e.addEventListener("mousedown", (t) => o(this, We, ys).call(this, t)), e;
627
+ }, We = new WeakSet(), ys = function(e) {
628
+ e.preventDefault(), e.stopPropagation(), o(this, Xe, Ts).call(this, e);
629
+ }, Ue = new WeakSet(), xs = function(e) {
630
+ const t = document.createElement("div");
631
+ t.classList.add("treeselect-list__item-checkbox-container");
632
+ const s = document.createElement("span");
633
+ s.classList.add("treeselect-list__item-checkbox-icon"), s.innerHTML = "";
634
+ const i = document.createElement("input");
635
+ return i.setAttribute("tabindex", "-1"), i.setAttribute("type", "checkbox"), i.setAttribute("input-id", e.value.toString()), i.classList.add("treeselect-list__item-checkbox"), t.append(s, i), t;
636
+ }, ze = new WeakSet(), Ss = function(e, t) {
637
+ const s = document.createElement("label");
638
+ if (s.textContent = e.name, s.classList.add("treeselect-list__item-label"), t && this.showCount) {
639
+ const i = o(this, Ye, _s).call(this, e);
640
+ s.appendChild(i);
641
+ }
642
+ return s;
643
+ }, Ye = new WeakSet(), _s = function(e) {
644
+ const t = document.createElement("span"), s = this.flattedOptions.filter((i) => i.childOf === e.value);
645
+ return t.textContent = `(${s.length})`, t.classList.add("treeselect-list__item-label-counter"), t;
646
+ }, Ke = new WeakSet(), As = function(e, t) {
647
+ const s = this.flattedOptions.find((i) => i.id === t.value);
648
+ if (s) {
649
+ if (s != null && s.isGroup && this.disabledBranchNode) {
650
+ const i = Ii(e);
651
+ i == null || i.dispatchEvent(new Event("mousedown"));
652
+ return;
653
+ }
654
+ if (this.isSingleSelect) {
655
+ const [i] = n(this, S);
656
+ if (s.id === i)
657
+ return;
658
+ m(this, S, [s.id]), ss([s.id], this.flattedOptions, this.isSingleSelect, this.isIndependentNodes);
659
+ } else {
660
+ s.checked = e.checked;
661
+ const i = It(s, this.flattedOptions, this.isIndependentNodes);
662
+ e.checked = i;
663
+ }
664
+ ce(this.flattedOptions, this.srcElement, this.iconElements, n(this, S), this.rtl), o(this, Je, Ns).call(this);
665
+ }
666
+ }, Xe = new WeakSet(), Ts = function(e) {
667
+ var a, h;
668
+ const t = (h = (a = e.target) == null ? void 0 : a.parentNode) == null ? void 0 : h.querySelector("[input-id]"), s = (t == null ? void 0 : t.getAttribute("input-id")) ?? null, i = Vt(s, this.flattedOptions);
669
+ i && (i.isClosed = !i.isClosed, bt(this.flattedOptions, i), ce(this.flattedOptions, this.srcElement, this.iconElements, n(this, S), this.rtl), this.arrowClickCallback(i.id, i.isClosed));
670
+ }, J = new WeakSet(), yt = function(e, t) {
671
+ const s = "treeselect-list__item--focused";
672
+ if (e) {
673
+ const i = Array.from(this.srcElement.querySelectorAll(`.${s}`));
674
+ i.length && i.forEach((a) => a.classList.remove(s)), t.classList.add(s);
675
+ } else
676
+ t.classList.remove(s);
677
+ }, Z = new WeakSet(), xt = function() {
678
+ const { ungroupedNodes: e, groupedNodes: t, allNodes: s } = Ci(this.flattedOptions);
679
+ this.selectedNodes = { nodes: e, groupedNodes: t, allNodes: s };
680
+ }, Je = new WeakSet(), Ns = function() {
681
+ o(this, Z, xt).call(this), this.inputCallback(this.selectedNodes), this.value = this.selectedNodes.nodes.map((e) => e.id);
682
+ };
683
+ const Dt = ({
684
+ parentHtmlContainer: l,
685
+ staticList: e,
686
+ appendToBody: t,
687
+ isSingleSelect: s,
688
+ value: i,
689
+ direction: a
690
+ }) => {
691
+ l || console.error("Validation: parentHtmlContainer prop is required!"), e && t && console.error("Validation: You should set staticList to false if you use appendToBody!"), s && Array.isArray(i) && console.error("Validation: if you use isSingleSelect prop, you should pass a single value!"), !s && !Array.isArray(i) && console.error("Validation: you should pass an array as a value!"), a && a !== "auto" && a !== "bottom" && a !== "top" && console.error("Validation: you should pass (auto | top | bottom | undefined) as a value for the direction prop!");
692
+ }, re = (l) => l.map((e) => e.id), Vi = (l) => l ? Array.isArray(l) ? l : [l] : [], Di = (l, e) => {
693
+ if (e) {
694
+ const [t] = l;
695
+ return t ?? null;
696
+ }
697
+ return l;
698
+ };
699
+ var u, p, F, Q, q, _, A, L, B, ee, St, te, _t, Ze, Os, Qe, Is, et, Ps, tt, Bs, st, Vs, it, Ds, se, At, lt, Hs, nt, Gs, at, Ms, ot, Fs, ie, Tt, rt, qs, j, he, le, Nt, R, de, ct, js, ne, Ot, ht, Rs, dt, $s, ut, Ws, pt, Us, mt, zs;
700
+ class Gi {
701
+ constructor({
702
+ parentHtmlContainer: e,
703
+ value: t,
704
+ options: s,
705
+ openLevel: i,
706
+ appendToBody: a,
707
+ alwaysOpen: h,
708
+ showTags: d,
709
+ tagsCountText: C,
710
+ clearable: f,
711
+ searchable: b,
712
+ placeholder: g,
713
+ grouped: k,
714
+ isGroupedValue: w,
715
+ listSlotHtmlComponent: y,
716
+ disabled: x,
717
+ emptyText: $,
718
+ staticList: ae,
719
+ id: Ct,
720
+ ariaLabel: gt,
721
+ isSingleSelect: oe,
722
+ showCount: Ys,
723
+ disabledBranchNode: Ks,
724
+ direction: Xs,
725
+ expandSelected: Js,
726
+ saveScrollPosition: Zs,
727
+ isIndependentNodes: Qs,
728
+ rtl: ei,
729
+ iconElements: ti,
730
+ inputCallback: si,
731
+ openCallback: ii,
732
+ closeCallback: li,
733
+ nameChangeCallback: ni,
734
+ searchCallback: ai,
735
+ openCloseGroupCallback: oi
736
+ }) {
737
+ r(this, ee);
738
+ r(this, te);
739
+ r(this, Ze);
740
+ r(this, Qe);
741
+ r(this, et);
742
+ r(this, tt);
743
+ r(this, st);
744
+ r(this, it);
745
+ r(this, se);
746
+ r(this, lt);
747
+ r(this, nt);
748
+ r(this, at);
749
+ r(this, ot);
750
+ r(this, ie);
751
+ r(this, rt);
752
+ r(this, j);
753
+ r(this, le);
754
+ r(this, R);
755
+ r(this, ct);
756
+ // Emits
757
+ r(this, ne);
758
+ r(this, ht);
759
+ r(this, dt);
760
+ r(this, ut);
761
+ r(this, pt);
762
+ r(this, mt);
763
+ // Props
764
+ c(this, "parentHtmlContainer");
765
+ c(this, "value");
766
+ c(this, "options");
767
+ c(this, "openLevel");
768
+ c(this, "appendToBody");
769
+ c(this, "alwaysOpen");
770
+ c(this, "showTags");
771
+ c(this, "tagsCountText");
772
+ c(this, "clearable");
773
+ c(this, "searchable");
774
+ c(this, "placeholder");
775
+ c(this, "grouped");
776
+ c(this, "isGroupedValue");
777
+ c(this, "listSlotHtmlComponent");
778
+ c(this, "disabled");
779
+ c(this, "emptyText");
780
+ c(this, "staticList");
781
+ c(this, "id");
782
+ c(this, "ariaLabel");
783
+ c(this, "isSingleSelect");
784
+ c(this, "showCount");
785
+ c(this, "disabledBranchNode");
786
+ c(this, "direction");
787
+ c(this, "expandSelected");
788
+ c(this, "saveScrollPosition");
789
+ c(this, "isIndependentNodes");
790
+ c(this, "rtl");
791
+ c(this, "iconElements");
792
+ c(this, "inputCallback");
793
+ c(this, "openCallback");
794
+ c(this, "closeCallback");
795
+ c(this, "nameChangeCallback");
796
+ c(this, "searchCallback");
797
+ c(this, "openCloseGroupCallback");
798
+ // InnerState
799
+ c(this, "ungroupedValue");
800
+ c(this, "groupedValue");
801
+ c(this, "allValue");
802
+ c(this, "isListOpened");
803
+ c(this, "selectedName");
804
+ c(this, "srcElement");
805
+ // Components
806
+ r(this, u, null);
807
+ r(this, p, null);
808
+ // Resize props
809
+ r(this, F, null);
810
+ // List position scroll
811
+ r(this, Q, 0);
812
+ // Timer for search text
813
+ r(this, q, 0);
814
+ // Outside listeners
815
+ r(this, _, null);
816
+ r(this, A, null);
817
+ r(this, L, null);
818
+ r(this, B, null);
819
+ Dt({
820
+ parentHtmlContainer: e,
821
+ value: t,
822
+ staticList: ae,
823
+ appendToBody: a,
824
+ isSingleSelect: oe
825
+ }), this.parentHtmlContainer = e, this.value = [], this.options = s ?? [], this.openLevel = i ?? 0, this.appendToBody = a ?? !1, this.alwaysOpen = !!(h && !x), this.showTags = d ?? !0, this.tagsCountText = C ?? "elements selected", this.clearable = f ?? !0, this.searchable = b ?? !0, this.placeholder = g ?? "Search...", this.grouped = k ?? !0, this.isGroupedValue = w ?? !1, this.listSlotHtmlComponent = y ?? null, this.disabled = x ?? !1, this.emptyText = $ ?? "No results found...", this.staticList = !!(ae && !this.appendToBody), this.id = Ct ?? "", this.ariaLabel = gt ?? "", this.isSingleSelect = oe ?? !1, this.showCount = Ys ?? !1, this.disabledBranchNode = Ks ?? !1, this.direction = Xs ?? "auto", this.expandSelected = Js ?? !1, this.saveScrollPosition = Zs ?? !0, this.isIndependentNodes = Qs ?? !1, this.rtl = ei ?? !1, this.iconElements = Bt(ti), this.inputCallback = si, this.openCallback = ii, this.closeCallback = li, this.nameChangeCallback = ni, this.searchCallback = ai, this.openCloseGroupCallback = oi, this.ungroupedValue = [], this.groupedValue = [], this.allValue = [], this.isListOpened = !1, this.selectedName = "", this.srcElement = null, o(this, ee, St).call(this, t);
826
+ }
827
+ mount() {
828
+ Dt({
829
+ parentHtmlContainer: this.parentHtmlContainer,
830
+ value: this.value,
831
+ staticList: this.staticList,
832
+ appendToBody: this.appendToBody,
833
+ isSingleSelect: this.isSingleSelect
834
+ }), this.iconElements = Bt(this.iconElements), o(this, ee, St).call(this, this.value);
835
+ }
836
+ updateValue(e) {
837
+ const t = Vi(e), s = n(this, u);
838
+ s && (s.updateValue(t), o(this, se, At).call(this, s == null ? void 0 : s.selectedNodes));
839
+ }
840
+ destroy() {
841
+ this.srcElement && (o(this, ie, Tt).call(this), this.srcElement.innerHTML = "", this.srcElement = null, o(this, R, de).call(this, !0));
842
+ }
843
+ focus() {
844
+ n(this, p) && n(this, p).focus();
845
+ }
846
+ toggleOpenClose() {
847
+ n(this, p) && (n(this, p).openClose(), n(this, p).focus());
848
+ }
849
+ // Outside Listeners
850
+ scrollWindowHandler() {
851
+ this.updateListPosition();
852
+ }
853
+ focusWindowHandler(e) {
854
+ var s, i, a;
855
+ ((s = this.srcElement) == null ? void 0 : s.contains(e.target)) || ((i = n(this, u)) == null ? void 0 : i.srcElement.contains(e.target)) || ((a = n(this, p)) == null || a.blur(), o(this, R, de).call(this, !1), o(this, j, he).call(this, !1));
856
+ }
857
+ blurWindowHandler() {
858
+ var e;
859
+ (e = n(this, p)) == null || e.blur(), o(this, R, de).call(this, !1), o(this, j, he).call(this, !1);
860
+ }
861
+ // Update direction of the list. Support appendToBody and standard mode with absolute
862
+ updateListPosition() {
863
+ var y;
864
+ const e = this.srcElement, t = (y = n(this, u)) == null ? void 0 : y.srcElement;
865
+ if (!e || !t)
866
+ return;
867
+ const { height: s } = t.getBoundingClientRect(), {
868
+ x: i,
869
+ y: a,
870
+ height: h,
871
+ width: d
872
+ } = e.getBoundingClientRect(), C = window.innerHeight, f = a, b = C - a - h;
873
+ let g = f > b && f >= s && b < s;
874
+ if (this.direction !== "auto" && (g = this.direction === "top"), this.appendToBody) {
875
+ (t.style.top !== "0px" || t.style.left !== "0px") && (t.style.top = "0px", t.style.left = "0px");
876
+ const x = i + window.scrollX, $ = g ? a + window.scrollY - s : a + window.scrollY + h;
877
+ t.style.transform = `translate(${x}px,${$}px)`, t.style.width = `${d}px`;
878
+ }
879
+ const k = g ? "top" : "bottom";
880
+ t.getAttribute("direction") !== k && (t.setAttribute("direction", k), o(this, rt, qs).call(this, g, this.appendToBody));
881
+ }
882
+ }
883
+ u = new WeakMap(), p = new WeakMap(), F = new WeakMap(), Q = new WeakMap(), q = new WeakMap(), _ = new WeakMap(), A = new WeakMap(), L = new WeakMap(), B = new WeakMap(), ee = new WeakSet(), St = function(e) {
884
+ var a;
885
+ this.destroy();
886
+ const { container: t, list: s, input: i } = o(this, Ze, Os).call(this);
887
+ this.srcElement = t, m(this, u, s), m(this, p, i), m(this, _, this.scrollWindowHandler.bind(this)), m(this, A, this.scrollWindowHandler.bind(this)), m(this, L, this.focusWindowHandler.bind(this)), m(this, B, this.blurWindowHandler.bind(this)), this.alwaysOpen && ((a = n(this, p)) == null || a.openClose()), this.disabled ? this.srcElement.classList.add("treeselect--disabled") : this.srcElement.classList.remove("treeselect--disabled"), this.updateValue(e ?? this.value);
888
+ }, te = new WeakSet(), _t = function({
889
+ groupedNodes: e,
890
+ nodes: t,
891
+ allNodes: s
892
+ }) {
893
+ this.ungroupedValue = t ? re(t) : [], this.groupedValue = e ? re(e) : [], this.allValue = s ? re(s) : [];
894
+ let i = [];
895
+ this.isIndependentNodes || this.isSingleSelect ? i = this.allValue : this.isGroupedValue ? i = this.groupedValue : i = this.ungroupedValue, this.value = Di(i, this.isSingleSelect);
896
+ }, Ze = new WeakSet(), Os = function() {
897
+ const e = this.parentHtmlContainer;
898
+ e.classList.add("treeselect"), this.rtl && e.setAttribute("dir", "rtl");
899
+ const t = new Bi({
900
+ value: [],
901
+ // updateValue method calls in initMount method to set actual value
902
+ options: this.options,
903
+ openLevel: this.openLevel,
904
+ listSlotHtmlComponent: this.listSlotHtmlComponent,
905
+ emptyText: this.emptyText,
906
+ isSingleSelect: this.isSingleSelect,
907
+ showCount: this.showCount,
908
+ disabledBranchNode: this.disabledBranchNode,
909
+ expandSelected: this.expandSelected,
910
+ isIndependentNodes: this.isIndependentNodes,
911
+ rtl: this.rtl,
912
+ iconElements: this.iconElements,
913
+ inputCallback: (i) => o(this, lt, Hs).call(this, i),
914
+ arrowClickCallback: (i, a) => o(this, nt, Gs).call(this, i, a),
915
+ mouseupCallback: () => {
916
+ var i;
917
+ return (i = n(this, p)) == null ? void 0 : i.focus();
918
+ }
919
+ }), s = new di({
920
+ value: [],
921
+ // updateValue method calls in initMount method to set actual value
922
+ showTags: this.showTags,
923
+ tagsCountText: this.tagsCountText,
924
+ clearable: this.clearable,
925
+ isAlwaysOpened: this.alwaysOpen,
926
+ searchable: this.searchable,
927
+ placeholder: this.placeholder,
928
+ disabled: this.disabled,
929
+ isSingleSelect: this.isSingleSelect,
930
+ id: this.id,
931
+ ariaLabel: this.ariaLabel,
932
+ iconElements: this.iconElements,
933
+ inputCallback: (i) => o(this, Qe, Is).call(this, i),
934
+ searchCallback: (i) => o(this, tt, Bs).call(this, i),
935
+ openCallback: () => o(this, ot, Fs).call(this),
936
+ closeCallback: () => o(this, ie, Tt).call(this),
937
+ keydownCallback: (i) => o(this, et, Ps).call(this, i),
938
+ focusCallback: () => o(this, st, Vs).call(this),
939
+ blurCallback: () => o(this, it, Ds).call(this),
940
+ nameChangeCallback: (i) => o(this, at, Ms).call(this, i)
941
+ });
942
+ return this.appendToBody && m(this, F, new ResizeObserver(() => this.updateListPosition())), e.append(s.srcElement), { container: e, list: t, input: s };
943
+ }, Qe = new WeakSet(), Is = function(e) {
944
+ var i, a;
945
+ const t = re(e);
946
+ (i = n(this, u)) == null || i.updateValue(t);
947
+ const s = ((a = n(this, u)) == null ? void 0 : a.selectedNodes) ?? {};
948
+ o(this, te, _t).call(this, s), o(this, ne, Ot).call(this);
949
+ }, et = new WeakSet(), Ps = function(e) {
950
+ var t;
951
+ this.isListOpened && ((t = n(this, u)) == null || t.callKeyAction(e));
952
+ }, tt = new WeakSet(), Bs = function(e) {
953
+ n(this, q) && clearTimeout(n(this, q)), m(this, q, window.setTimeout(() => {
954
+ var t;
955
+ (t = n(this, u)) == null || t.updateSearchValue(e), this.updateListPosition();
956
+ }, 350)), o(this, pt, Us).call(this, e);
957
+ }, st = new WeakSet(), Vs = function() {
958
+ o(this, j, he).call(this, !0), n(this, L) && n(this, L) && n(this, B) && (document.addEventListener("mousedown", n(this, L), !0), document.addEventListener("focus", n(this, L), !0), window.addEventListener("blur", n(this, B)));
959
+ }, it = new WeakSet(), Ds = function() {
960
+ setTimeout(() => {
961
+ var s, i;
962
+ const e = (s = n(this, p)) == null ? void 0 : s.srcElement.contains(document.activeElement), t = (i = n(this, u)) == null ? void 0 : i.srcElement.contains(document.activeElement);
963
+ !e && !t && this.blurWindowHandler();
964
+ }, 1);
965
+ }, se = new WeakSet(), At = function(e) {
966
+ var s;
967
+ if (!e)
968
+ return;
969
+ let t = [];
970
+ this.isIndependentNodes || this.isSingleSelect ? t = e.allNodes : this.grouped ? t = e.groupedNodes : t = e.nodes, (s = n(this, p)) == null || s.updateValue(t), o(this, te, _t).call(this, e);
971
+ }, lt = new WeakSet(), Hs = function(e) {
972
+ var t, s, i;
973
+ o(this, se, At).call(this, e), this.isSingleSelect && !this.alwaysOpen && ((t = n(this, p)) == null || t.openClose(), (s = n(this, p)) == null || s.clearSearch()), (i = n(this, p)) == null || i.focus(), o(this, ne, Ot).call(this);
974
+ }, nt = new WeakSet(), Gs = function(e, t) {
975
+ var s;
976
+ (s = n(this, p)) == null || s.focus(), this.updateListPosition(), o(this, mt, zs).call(this, e, t);
977
+ }, at = new WeakSet(), Ms = function(e) {
978
+ this.selectedName !== e && (this.selectedName = e, o(this, ht, Rs).call(this));
979
+ }, ot = new WeakSet(), Fs = function() {
980
+ var e;
981
+ this.isListOpened = !0, n(this, _) && n(this, A) && (window.addEventListener("scroll", n(this, _), !0), window.addEventListener("resize", n(this, A))), !(!n(this, u) || !this.srcElement) && (this.appendToBody ? (document.body.appendChild(n(this, u).srcElement), (e = n(this, F)) == null || e.observe(this.srcElement)) : this.srcElement.appendChild(n(this, u).srcElement), this.updateListPosition(), o(this, le, Nt).call(this, !0), o(this, ct, js).call(this), o(this, dt, $s).call(this));
982
+ }, ie = new WeakSet(), Tt = function() {
983
+ var t;
984
+ this.alwaysOpen || (this.isListOpened = !1, n(this, _) && n(this, A) && (window.removeEventListener("scroll", n(this, _), !0), window.removeEventListener("resize", n(this, A))), !n(this, u) || !this.srcElement) || !(this.appendToBody ? document.body.contains(n(this, u).srcElement) : this.srcElement.contains(n(this, u).srcElement)) || (m(this, Q, n(this, u).srcElement.scrollTop), this.appendToBody ? (document.body.removeChild(n(this, u).srcElement), (t = n(this, F)) == null || t.disconnect()) : this.srcElement.removeChild(n(this, u).srcElement), o(this, le, Nt).call(this, !1), o(this, ut, Ws).call(this));
985
+ }, rt = new WeakSet(), qs = function(e, t) {
986
+ if (!n(this, u) || !n(this, p))
987
+ return;
988
+ const s = t ? "treeselect-list--top-to-body" : "treeselect-list--top", i = t ? "treeselect-list--bottom-to-body" : "treeselect-list--bottom";
989
+ e ? (n(this, u).srcElement.classList.add(s), n(this, u).srcElement.classList.remove(i), n(this, p).srcElement.classList.add("treeselect-input--top"), n(this, p).srcElement.classList.remove("treeselect-input--bottom")) : (n(this, u).srcElement.classList.remove(s), n(this, u).srcElement.classList.add(i), n(this, p).srcElement.classList.remove("treeselect-input--top"), n(this, p).srcElement.classList.add("treeselect-input--bottom"));
990
+ }, j = new WeakSet(), he = function(e) {
991
+ !n(this, p) || !n(this, u) || (e ? (n(this, p).srcElement.classList.add("treeselect-input--focused"), n(this, u).srcElement.classList.add("treeselect-list--focused")) : (n(this, p).srcElement.classList.remove("treeselect-input--focused"), n(this, u).srcElement.classList.remove("treeselect-list--focused")));
992
+ }, le = new WeakSet(), Nt = function(e) {
993
+ var t, s, i, a;
994
+ e ? (t = n(this, p)) == null || t.srcElement.classList.add("treeselect-input--opened") : (s = n(this, p)) == null || s.srcElement.classList.remove("treeselect-input--opened"), this.staticList ? (i = n(this, u)) == null || i.srcElement.classList.add("treeselect-list--static") : (a = n(this, u)) == null || a.srcElement.classList.remove("treeselect-list--static");
995
+ }, R = new WeakSet(), de = function(e) {
996
+ !n(this, _) || !n(this, A) || !n(this, L) || !n(this, B) || ((!this.alwaysOpen || e) && (window.removeEventListener("scroll", n(this, _), !0), window.removeEventListener("resize", n(this, A))), document.removeEventListener("mousedown", n(this, L), !0), document.removeEventListener("focus", n(this, L), !0), window.removeEventListener("blur", n(this, B)));
997
+ }, ct = new WeakSet(), js = function() {
998
+ var t, s, i;
999
+ const e = (t = n(this, u)) == null ? void 0 : t.isLastFocusedElementExist();
1000
+ this.saveScrollPosition && e ? (s = n(this, u)) == null || s.srcElement.scroll(0, n(this, Q)) : (i = n(this, u)) == null || i.focusFirstListElement();
1001
+ }, ne = new WeakSet(), Ot = function() {
1002
+ var e;
1003
+ (e = this.srcElement) == null || e.dispatchEvent(new CustomEvent("input", { detail: this.value })), this.inputCallback && this.inputCallback(this.value);
1004
+ }, ht = new WeakSet(), Rs = function() {
1005
+ var e;
1006
+ (e = this.srcElement) == null || e.dispatchEvent(new CustomEvent("name-change", { detail: this.selectedName })), this.nameChangeCallback && this.nameChangeCallback(this.selectedName);
1007
+ }, dt = new WeakSet(), $s = function() {
1008
+ var e;
1009
+ this.alwaysOpen || ((e = this.srcElement) == null || e.dispatchEvent(new CustomEvent("open", { detail: this.value })), this.openCallback && this.openCallback(this.value));
1010
+ }, ut = new WeakSet(), Ws = function() {
1011
+ var e;
1012
+ this.alwaysOpen || ((e = this.srcElement) == null || e.dispatchEvent(new CustomEvent("close", { detail: this.value })), this.closeCallback && this.closeCallback(this.value));
1013
+ }, pt = new WeakSet(), Us = function(e) {
1014
+ var s;
1015
+ const t = (e == null ? void 0 : e.trim()) ?? "";
1016
+ (s = this.srcElement) == null || s.dispatchEvent(new CustomEvent("search", { detail: t })), this.searchCallback && this.searchCallback(t);
1017
+ }, mt = new WeakSet(), zs = function(e, t) {
1018
+ var s;
1019
+ (s = this.srcElement) == null || s.dispatchEvent(new CustomEvent("open-close-group", { detail: { groupId: e, isClosed: t } })), this.openCloseGroupCallback && this.openCloseGroupCallback(e, t);
1020
+ };
1021
+ export {
1022
+ Gi as default
1023
+ };