super-select-react 0.9.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.
@@ -0,0 +1,2410 @@
1
+ import { Children as e, Fragment as t, isValidElement as n, useCallback as r, useEffect as i, useId as a, useMemo as o, useRef as s, useState as c } from "react";
2
+ import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
3
+ //#region src/utils/cx.ts
4
+ function f(...e) {
5
+ return e.filter(Boolean).join(" ");
6
+ }
7
+ //#endregion
8
+ //#region src/modal-select/CloseButton.tsx
9
+ function p({ className: e, style: t, disabled: n, tabIndex: r, title: i, onClick: a, customization: o }) {
10
+ let s = o?.classNamePrefix ?? "super-select", c = s.length > 0 ? `${s}__` : "";
11
+ return /* @__PURE__ */ u("button", {
12
+ type: "button",
13
+ className: f(`${c}btn-close`, e),
14
+ style: t,
15
+ disabled: n,
16
+ onClick: a,
17
+ tabIndex: r,
18
+ title: i,
19
+ children: /* @__PURE__ */ u("span", {
20
+ className: `${c}visually-hidden`,
21
+ children: o?.content ?? /* @__PURE__ */ u(l, { children: "×" })
22
+ })
23
+ });
24
+ }
25
+ //#endregion
26
+ //#region src/modal-select/Modal.tsx
27
+ function m({ customization: e, headerContent: t, footerContent: n, children: a, open: o, className: c, ref: l, ...m }) {
28
+ let h = e?.classNamePrefix ?? "super-select", g = h.length > 0 ? `${h}__` : "", _ = s(null), { onClose: v, onCancel: y, onClick: b, ...x } = m, S = e?.closeButton?.component ?? p, C = r((e) => {
29
+ if (_.current = e, l) {
30
+ if (typeof l == "function") {
31
+ l(e);
32
+ return;
33
+ }
34
+ l.current = e;
35
+ }
36
+ }, [l]);
37
+ i(() => {
38
+ let e = _.current;
39
+ e && (o && !e.open && e.showModal(), !o && e.open && e.close());
40
+ }, [o]);
41
+ let w = r(() => {
42
+ let e = _.current;
43
+ e?.open && e.close();
44
+ }, []);
45
+ return /* @__PURE__ */ u("dialog", {
46
+ ...x,
47
+ ref: C,
48
+ "aria-modal": "true",
49
+ onClose: v,
50
+ onCancel: (e) => {
51
+ y && (e.preventDefault(), y());
52
+ },
53
+ onClick: b,
54
+ className: f(`${g}modal`, `${g}border-0`, `${g}bg-transparent`, `${g}fade`, o ? `${g}show` : void 0, o ? `${g}d-block` : void 0, c),
55
+ children: /* @__PURE__ */ u("div", {
56
+ className: f(`${g}modal-dialog`, `${g}modal-dialog-scrollable`, e?.dialog?.className),
57
+ style: e?.dialog?.style,
58
+ children: /* @__PURE__ */ d("div", {
59
+ className: f(`${g}modal-content`, e?.content?.className),
60
+ style: e?.content?.style,
61
+ children: [
62
+ /* @__PURE__ */ d("div", {
63
+ className: f(`${g}modal-header`, e?.header?.className),
64
+ style: e?.header?.style,
65
+ children: [t, /* @__PURE__ */ u(S, {
66
+ className: e?.closeButton?.className,
67
+ style: e?.closeButton?.style,
68
+ title: e?.closeButton?.title,
69
+ onClick: w,
70
+ tabIndex: -1,
71
+ customization: {
72
+ classNamePrefix: h,
73
+ content: e?.closeButton?.content
74
+ }
75
+ })]
76
+ }),
77
+ /* @__PURE__ */ u("div", {
78
+ className: f(`${g}modal-body`, e?.body?.className),
79
+ style: e?.body?.style,
80
+ children: a
81
+ }),
82
+ n && /* @__PURE__ */ u("div", {
83
+ className: f(`${g}modal-footer`, e?.footer?.className),
84
+ style: e?.footer?.style,
85
+ children: n
86
+ })
87
+ ]
88
+ })
89
+ })
90
+ });
91
+ }
92
+ //#endregion
93
+ //#region src/option-list-select/EmptyIndicator.tsx
94
+ var h = "−", g = "↻";
95
+ function _({ className: e, style: t, onRetry: n, customization: r }) {
96
+ let i = r?.classNamePrefix ?? "super-select", a = i.length > 0 ? `${i}__` : "";
97
+ return /* @__PURE__ */ d("div", {
98
+ className: f(`${a}alert`, `${a}alert-info`, n && `${a}alert-dismissible`, e),
99
+ style: t,
100
+ children: [
101
+ r?.content ?? /* @__PURE__ */ u("span", {
102
+ "aria-hidden": !0,
103
+ children: h
104
+ }),
105
+ " ",
106
+ n && /* @__PURE__ */ u("button", {
107
+ type: "button",
108
+ className: f(`${a}btn`, `${a}btn-outline-secondary`, `${a}btn-sm`, r?.retryButton?.className),
109
+ style: r?.retryButton?.style,
110
+ title: r?.retryButton?.title,
111
+ onClick: n,
112
+ children: r?.retryButton?.content ?? g
113
+ })
114
+ ]
115
+ });
116
+ }
117
+ //#endregion
118
+ //#region src/option-list-select/MoreIndicator.tsx
119
+ var v = "+";
120
+ function y({ className: e, style: t, disabled: n, onLoadMore: r, customization: i }) {
121
+ let a = i?.classNamePrefix ?? "super-select", o = a.length > 0 ? `${a}__` : "";
122
+ return r ? /* @__PURE__ */ u("button", {
123
+ type: "button",
124
+ className: f(`${o}btn`, `${o}btn-outline-secondary`, `${o}btn-sm`, e, i?.loadMoreButton?.className),
125
+ style: t || i?.loadMoreButton?.style ? {
126
+ ...t,
127
+ ...i?.loadMoreButton?.style
128
+ } : void 0,
129
+ title: i?.loadMoreButton?.title,
130
+ onClick: r,
131
+ disabled: n,
132
+ children: i?.loadMoreButton?.content ?? v
133
+ }) : /* @__PURE__ */ u("div", {
134
+ className: f(`${o}text-body-secondary`, `${o}overflow-indicator`, e, i?.overflowIndicator?.className),
135
+ style: t || i?.overflowIndicator?.style ? {
136
+ ...t,
137
+ ...i?.overflowIndicator?.style
138
+ } : void 0,
139
+ title: i?.overflowIndicator?.title,
140
+ children: i?.overflowIndicator?.content ?? /* @__PURE__ */ u(l, { children: "…" })
141
+ });
142
+ }
143
+ //#endregion
144
+ //#region src/utils/normalizeSelectValue.ts
145
+ function b(e) {
146
+ return Array.isArray(e) ? e.map(String) : typeof e == "string" && e.length > 0 ? [e] : typeof e == "number" ? [String(e)] : [];
147
+ }
148
+ //#endregion
149
+ //#region src/option-list-select/OptionListInput.tsx
150
+ function x({ autoComplete: e, autoFocus: t, className: n, disabled: r, form: l, id: p, multiple: m, name: h, required: g, style: _, tabIndex: v, title: y, options: x, value: C, onValueChange: w, onOptionClick: T, onOptionKeyDown: E, indicator: D, customization: O, ref: k, ...A }) {
151
+ let j = O?.classNamePrefix ?? "super-select", M = j.length > 0 ? `${j}__` : "", N = s(null), [P, F] = c(void 0), I = a(), L = o(() => x.find((e) => e.hidden) ? x.filter((e) => !e.hidden) : x, [x]), R = o(() => S(L), [L]), z = o(() => R.length > 1 ? R.flatMap((e) => e.options) : L, [R, L]), B = o(() => {
152
+ let e = b(C);
153
+ return m ? e : e.slice(0, 1);
154
+ }, [m, C]), V = o(() => new Set(B), [B]), H = o(() => z.find((e) => !e.disabled)?.value, [z]), ee = o(() => {
155
+ if (!(v === void 0 || v === -1)) return m ? H : z.find((e) => V.has(e.value) && !e.disabled)?.value ?? H;
156
+ }, [
157
+ H,
158
+ m,
159
+ z,
160
+ V,
161
+ v
162
+ ]), U = o(() => new Set(z.map((e) => e.value)), [z]), W = o(() => h ? B.filter((e) => !U.has(e)) : [], [
163
+ U,
164
+ h,
165
+ B
166
+ ]), te = o(() => {
167
+ if (t) return z.find((e) => !(r || e.disabled))?.value;
168
+ }, [
169
+ t,
170
+ r,
171
+ z
172
+ ]), ne = o(() => z.find((e) => e.value === P && !e.disabled)?.value || z.find((e) => V.has(e.value) && !e.disabled)?.value || H, [
173
+ H,
174
+ P,
175
+ z,
176
+ V
177
+ ]);
178
+ i(() => {
179
+ !ne || P === void 0 || N.current?.scrollIntoView({ block: "nearest" });
180
+ }, [ne, P]);
181
+ let re = (e) => {
182
+ r || w(m ? B.includes(e) ? B.filter((t) => t !== e) : [...B, e] : [e]);
183
+ }, G = m ? h : h ?? `option-list-${I}`, K = A["aria-label"] ?? h;
184
+ return /* @__PURE__ */ d("fieldset", {
185
+ ref: k,
186
+ ...A,
187
+ id: p,
188
+ role: m ? "group" : "radiogroup",
189
+ "aria-label": K,
190
+ "aria-disabled": r || void 0,
191
+ "aria-required": g || void 0,
192
+ disabled: r,
193
+ className: f(`${M}list-group`, n),
194
+ style: _,
195
+ title: y,
196
+ tabIndex: -1,
197
+ children: [
198
+ R.map((t, n) => /* @__PURE__ */ d("div", { children: [t.label ? /* @__PURE__ */ u("div", {
199
+ className: f(`${M}list-group-item`, `${M}list-group-item-secondary`, O?.groupHeader?.className),
200
+ style: O?.groupHeader?.style,
201
+ children: t.label
202
+ }) : null, t.options.map((t) => {
203
+ let n = V.has(t.value), i = r || t.disabled;
204
+ return /* @__PURE__ */ d("label", {
205
+ ref: (e) => {
206
+ t.value === ne ? N.current = e : N.current === e && (N.current = null);
207
+ },
208
+ className: f(`${M}list-group-item`, `${M}list-group-item-action`, n ? `${M}active` : void 0, t.value === ne ? `${M}focus-ring` : void 0, i ? `${M}disabled` : void 0, O?.optionItem?.className),
209
+ style: O?.optionItem?.style,
210
+ onClick: () => {
211
+ i || F(t.value);
212
+ },
213
+ children: [/* @__PURE__ */ u("input", {
214
+ type: m ? "checkbox" : "radio",
215
+ name: G,
216
+ value: t.value,
217
+ checked: n,
218
+ disabled: i,
219
+ form: l,
220
+ autoComplete: e,
221
+ autoFocus: t.value === te,
222
+ tabIndex: v === void 0 ? void 0 : v === -1 ? -1 : t.value === ee ? v : -1,
223
+ onClick: T,
224
+ onKeyDown: E,
225
+ onChange: () => re(t.value),
226
+ onFocus: () => {
227
+ i || F(t.value);
228
+ },
229
+ className: f(`${M}form-check-input`, `${M}me-1`)
230
+ }), /* @__PURE__ */ u("span", {
231
+ className: `${M}form-check-label`,
232
+ children: t.children ?? t.label
233
+ })]
234
+ }, t.value);
235
+ })] }, t.label || `group-${n}`)),
236
+ W.map((e) => /* @__PURE__ */ u("input", {
237
+ type: "hidden",
238
+ name: h,
239
+ value: e,
240
+ form: l,
241
+ disabled: r
242
+ }, `hidden-selected-${e}`)),
243
+ D ? /* @__PURE__ */ u("div", {
244
+ className: f(`${M}list-group-item`),
245
+ children: D
246
+ }) : null
247
+ ]
248
+ });
249
+ }
250
+ function S(e) {
251
+ let t = [], n;
252
+ for (let r of e) {
253
+ let e = r.groupLabel ?? "";
254
+ if (n && n.label === e) {
255
+ n.options.push(r);
256
+ continue;
257
+ }
258
+ if (n = t.find((t) => t.label === e), n) {
259
+ n.options.push(r);
260
+ continue;
261
+ }
262
+ n = {
263
+ label: e,
264
+ options: [r]
265
+ }, t.push(n);
266
+ }
267
+ return t;
268
+ }
269
+ //#endregion
270
+ //#region src/utils/PendingIndicator.tsx
271
+ var C = "⏳", w = 150;
272
+ function T({ className: e, style: t, title: n, inline: r, content: a, customization: o }) {
273
+ let s = o?.classNamePrefix ?? "super-select", d = s.length > 0 ? `${s}__` : "", p = r ? "span" : "div", [m, h] = c(!1);
274
+ return i(() => {
275
+ let e = window.setTimeout(() => h(!0), w);
276
+ return () => window.clearTimeout(e);
277
+ }, []), /* @__PURE__ */ u(p, {
278
+ className: f(`${d}spinner-border`, `${d}spinner-border-sm`, `${d}fade`, m ? `${d}show` : void 0, e),
279
+ style: t,
280
+ title: n,
281
+ role: "status",
282
+ children: /* @__PURE__ */ u("span", {
283
+ className: `${d}visually-hidden`,
284
+ children: a ?? /* @__PURE__ */ u(l, { children: C })
285
+ })
286
+ });
287
+ }
288
+ //#endregion
289
+ //#region src/option-list-select/SearchInput.tsx
290
+ function E({ className: e, style: t, search: n, onSearchChange: r, isSearching: i, disabled: a, ref: o, onKeyDown: s, customization: c }) {
291
+ let l = c?.classNamePrefix ?? "super-select", p = l.length > 0 ? `${l}__` : "", m = c?.pendingIndicator?.component ?? T;
292
+ return /* @__PURE__ */ d("div", {
293
+ className: f(`${p}input-group`, e),
294
+ style: t,
295
+ children: [/* @__PURE__ */ u("input", {
296
+ ref: o,
297
+ type: "search",
298
+ value: n ?? "",
299
+ onChange: (e) => r(e.target.value),
300
+ onKeyDown: s,
301
+ className: `${p}form-control`,
302
+ disabled: a,
303
+ placeholder: c?.placeholder,
304
+ title: c?.title,
305
+ "aria-label": c?.title
306
+ }), i && /* @__PURE__ */ u("div", {
307
+ className: `${p}input-group-text`,
308
+ children: /* @__PURE__ */ u(m, {
309
+ inline: !0,
310
+ className: c?.pendingIndicator?.className,
311
+ style: c?.pendingIndicator?.style,
312
+ title: c?.pendingIndicator?.title,
313
+ content: c?.pendingIndicator?.content,
314
+ customization: c ? { classNamePrefix: l } : void 0
315
+ })
316
+ })]
317
+ });
318
+ }
319
+ //#endregion
320
+ //#region src/option-source/OptionCache.ts
321
+ var D = class {
322
+ defaultQueryData;
323
+ cacheByValue = /* @__PURE__ */ new Map();
324
+ getAll() {
325
+ let e = /* @__PURE__ */ new Map();
326
+ if (this.defaultQueryData) for (let t of this.defaultQueryData.options) e.set(t.value, t);
327
+ for (let t of this.cacheByValue.values()) e.set(t.value, t);
328
+ return Array.from(e.values());
329
+ }
330
+ getByValue(e) {
331
+ let t = this.cacheByValue.get(e);
332
+ return !t && this.defaultQueryData && (t = this.defaultQueryData.options.find((t) => t.value === e)), t;
333
+ }
334
+ hasDefault() {
335
+ return !!this.defaultQueryData;
336
+ }
337
+ getByPageQuery(e) {
338
+ if (!this.defaultQueryData || e && (e.search || e.offset && e.offset > 0 || e.after)) return;
339
+ let t = this.defaultQueryData.options, n = this.defaultQueryData.hasMore;
340
+ if (e?.limit !== void 0) {
341
+ if (this.defaultQueryData.limit !== void 0 && this.defaultQueryData.limit < e.limit) return;
342
+ e.limit < t.length && (t = t.slice(0, e.limit), n = !0);
343
+ }
344
+ return {
345
+ options: t,
346
+ hasMore: n
347
+ };
348
+ }
349
+ tryResolveValues(e) {
350
+ if (!e || this.cacheByValue.size === 0 && !this.defaultQueryData) return {
351
+ options: void 0,
352
+ missingValues: e
353
+ };
354
+ let t = [], n = [];
355
+ for (let r of e) {
356
+ let e = this.getByValue(r);
357
+ e ? t.push(e) : n.push(r);
358
+ }
359
+ return {
360
+ options: t,
361
+ missingValues: n
362
+ };
363
+ }
364
+ set(e) {
365
+ if (e) for (let t of e) {
366
+ if (this.cacheByValue.size >= 1e3) break;
367
+ this.cacheByValue.set(t.value, t);
368
+ }
369
+ }
370
+ setQueryResult(e, t) {
371
+ return (!t || !t.search && !t.offset && !t.after) && e.options && e.options.length > 0 ? (this.defaultQueryData = {
372
+ options: e.options,
373
+ hasMore: e.hasMore,
374
+ limit: t?.limit
375
+ }, !0) : !1;
376
+ }
377
+ clear() {
378
+ this.defaultQueryData = void 0, this.cacheByValue.clear();
379
+ }
380
+ }, O = class {
381
+ fetcher;
382
+ runChain = Promise.resolve();
383
+ pendingQueryRuns = [];
384
+ constructor(e) {
385
+ this.fetcher = e;
386
+ }
387
+ fetch(e) {
388
+ let t = e?.signal, n = {
389
+ ...e,
390
+ values: e?.values ? [...e.values] : void 0
391
+ };
392
+ for (let e = 0; e < this.pendingQueryRuns.length; e++) {
393
+ let r = this.pendingQueryRuns[e], i = r.query.values, a = n.values, o = !1;
394
+ if (i === a) o = !0;
395
+ else if (i && a && i.length === a.length) {
396
+ o = !0;
397
+ for (let e = 0; e < i.length; e++) if (i[e] !== a[e]) {
398
+ o = !1;
399
+ break;
400
+ }
401
+ }
402
+ if (r.query.search === n.search && r.query.offset === n.offset && r.query.after === n.after && r.query.limit === n.limit && o) return this.createSubscriberPromise(r, n, t);
403
+ let s = !!r.query.values && !r.query.search && r.query.offset === void 0 && r.query.after === void 0 && r.query.limit === void 0, c = !!n.values && !n.search && n.offset === void 0 && n.after === void 0 && n.limit === void 0;
404
+ if ((e > 0 || !r.started) && s && c) {
405
+ let e = Array.from(/* @__PURE__ */ new Set([...r.query.values, ...n.values]));
406
+ return e.length !== r.query.values.length && (r.query = { values: e }), this.createSubscriberPromise(r, n, t);
407
+ }
408
+ }
409
+ let r = new AbortController(), i = {
410
+ query: n,
411
+ promise: Promise.resolve({ options: [] }),
412
+ abortController: r,
413
+ subscribers: /* @__PURE__ */ new Set(),
414
+ started: !1
415
+ }, a = this.runSequentially(() => (i.started = !0, this.fetcher({
416
+ ...i.query,
417
+ signal: r.signal
418
+ })));
419
+ i.promise = a, this.pendingQueryRuns.push(i);
420
+ let o = () => {
421
+ let e = this.pendingQueryRuns.findIndex((e) => e.promise === a);
422
+ e >= 0 && this.pendingQueryRuns.splice(e, 1);
423
+ };
424
+ return a.then(o, o), this.createSubscriberPromise(i, n, t);
425
+ }
426
+ createSubscriberPromise(e, t, n) {
427
+ let r = {
428
+ query: t,
429
+ signal: n,
430
+ aborted: !1
431
+ };
432
+ e.subscribers.add(r);
433
+ let i, a = new Promise((t, a) => {
434
+ if (n) {
435
+ if (i = () => {
436
+ r.aborted = !0, this.abortUnderlyingRequestIfUnused(e), a(new DOMException("The operation was aborted.", "AbortError"));
437
+ }, n.aborted) {
438
+ i();
439
+ return;
440
+ }
441
+ n.addEventListener("abort", i, { once: !0 });
442
+ }
443
+ });
444
+ return (n ? Promise.race([e.promise, a]) : e.promise).then((e) => this.filterResultForSubscriber(e, r.query)).finally(() => {
445
+ e.subscribers.delete(r), n && i && n.removeEventListener("abort", i), this.abortUnderlyingRequestIfUnused(e);
446
+ });
447
+ }
448
+ filterResultForSubscriber(e, t) {
449
+ if (!t.values || t.search || t.offset !== void 0 || t.after !== void 0 || t.limit !== void 0) return e;
450
+ let n = new Set(t.values), r = new Map(t.values.map((e, t) => [e, t]));
451
+ return {
452
+ ...e,
453
+ options: e.options.filter((e) => n.has(e.value)).sort((e, t) => (r.get(e.value) ?? 0) - (r.get(t.value) ?? 0))
454
+ };
455
+ }
456
+ abortUnderlyingRequestIfUnused(e) {
457
+ if (e.subscribers.size === 0) {
458
+ e.abortController.abort();
459
+ return;
460
+ }
461
+ Array.from(e.subscribers).every((e) => e.aborted) && e.abortController.abort();
462
+ }
463
+ runSequentially(e) {
464
+ let t = this.runChain.then(e, e);
465
+ return this.runChain = t.then(() => void 0, () => void 0), t;
466
+ }
467
+ }, k = class extends Error {
468
+ userMessage;
469
+ code;
470
+ httpStatus;
471
+ constructor(e, t) {
472
+ super(e, { cause: t?.cause }), this.name = "OptionSourceError", this.userMessage = t?.userMessage, this.code = t?.code, this.httpStatus = t?.httpStatus, this.cause = t?.cause;
473
+ }
474
+ };
475
+ function A(e) {
476
+ return e instanceof k ? !0 : !(!e || typeof e != "object" || "message" in e && typeof e.message != "string" && e.message !== void 0 || "userMessage" in e && typeof e.userMessage != "string" && e.userMessage !== void 0 || "code" in e && typeof e.code != "string" && e.code !== void 0 || "httpStatus" in e && typeof e.httpStatus != "number" && e.httpStatus !== void 0);
477
+ }
478
+ var j = "An error occurred fetching options";
479
+ function M(e) {
480
+ if (e instanceof k) return e;
481
+ if (!e) return new k(j);
482
+ if (typeof e == "string") return new k(e);
483
+ if (typeof e != "object") return new k(j);
484
+ if ("name" in e && e.name === "AbortError") return e;
485
+ let t;
486
+ t = "message" in e && typeof e.message == "string" ? e.message ?? j : j;
487
+ let n;
488
+ if (A(e) ? n = e : (n = {}, "userMessage" in e && typeof e.userMessage == "string" && (n.userMessage = e.userMessage), "code" in e && typeof e.code == "string" && (n.code = e.code), "httpStatus" in e && typeof e.httpStatus == "number" && (n.httpStatus = e.httpStatus), "cause" in e && (n.cause = e.cause)), n.httpStatus && !n.code) {
489
+ let e;
490
+ n.httpStatus === 401 ? e = "unauthorized" : n.httpStatus === 403 ? e = "forbidden" : n.httpStatus === 404 ? e = "not-found" : n.httpStatus === 408 ? e = "timeout" : n.httpStatus === 429 ? e = "rate-limited" : n.httpStatus >= 500 && n.httpStatus <= 599 && (e = "server"), e && (n = {
491
+ ...n,
492
+ code: e
493
+ });
494
+ }
495
+ return e instanceof Error && (!n.cause || e.cause === n.cause) && (n = {
496
+ ...n,
497
+ cause: e
498
+ }), new k(t, n);
499
+ }
500
+ //#endregion
501
+ //#region src/option-source/OptionSource.ts
502
+ var N = class e {
503
+ innerFetcher;
504
+ fetcher;
505
+ cache;
506
+ constructor(e) {
507
+ this.innerFetcher = e.fetch, this.fetcher = new O(this.innerFetcher), this.cache = e.noCache ? void 0 : new D();
508
+ }
509
+ async getOptionPage(e) {
510
+ if (this.cache) {
511
+ let t = this.cache.getByPageQuery(e);
512
+ if (t) return {
513
+ ...t,
514
+ nextPage: this.createFetchNextPage(t, e)
515
+ };
516
+ }
517
+ try {
518
+ let t = await this.fetcher.fetch(e);
519
+ return this.cache && this.cache.setQueryResult(t, e), {
520
+ ...t,
521
+ nextPage: this.createFetchNextPage(t, e)
522
+ };
523
+ } catch (e) {
524
+ throw M(e);
525
+ }
526
+ }
527
+ createFetchNextPage(e, t) {
528
+ if (!e || e.hasMore !== !0) return;
529
+ let n = (t?.offset ?? 0) + e.options.length, r = e.options.length > 0 ? e.options[e.options.length - 1] : void 0, i = {
530
+ search: t?.search,
531
+ offset: n,
532
+ after: r,
533
+ limit: t?.limit
534
+ };
535
+ return (e) => this.getOptionPage({
536
+ ...i,
537
+ limit: e?.limit ?? i.limit,
538
+ signal: e?.signal
539
+ });
540
+ }
541
+ async resolveValues(e, t) {
542
+ if (!e || e.length === 0) return [];
543
+ let n = Array.from(new Set(e)), r = n, i;
544
+ if (this.cache) {
545
+ if (!this.cache.hasDefault()) try {
546
+ let e = await this.fetcher.fetch({ signal: t });
547
+ this.cache.setQueryResult(e, void 0);
548
+ } catch (e) {
549
+ if (t?.aborted) throw M(e);
550
+ }
551
+ let { options: e, missingValues: n } = this.cache.tryResolveValues(r);
552
+ e && (i = e, r = n);
553
+ }
554
+ let a = [];
555
+ if (r && r.length > 0) {
556
+ let e = new Set(r), n = {
557
+ values: r,
558
+ signal: t
559
+ };
560
+ for (; e.size > 0;) {
561
+ let i;
562
+ try {
563
+ i = await this.fetcher.fetch(n);
564
+ } catch (e) {
565
+ throw M(e);
566
+ }
567
+ let o = i.options, s = 0;
568
+ for (let t of o) e.delete(t.value) && (a.push(t), s++);
569
+ if (i.hasMore !== !0 || s === 0) break;
570
+ n = {
571
+ values: r,
572
+ offset: (n.offset ?? 0) + o.length,
573
+ after: o[o.length - 1],
574
+ signal: t
575
+ };
576
+ }
577
+ this.cache && this.cache.set(a);
578
+ }
579
+ let o = new Map([...i ?? [], ...a].map((e) => [e.value, e]));
580
+ return n.flatMap((e) => {
581
+ let t = o.get(e);
582
+ return t ? [t] : [];
583
+ });
584
+ }
585
+ getCachedOptions() {
586
+ return this.cache?.getAll();
587
+ }
588
+ clearCache() {
589
+ this.cache?.clear();
590
+ }
591
+ withNoCache() {
592
+ return this.cache ? new e({
593
+ fetch: this.innerFetcher,
594
+ noCache: !0
595
+ }) : this;
596
+ }
597
+ };
598
+ //#endregion
599
+ //#region src/option-source/createOptionSource.ts
600
+ function P(e) {
601
+ if (typeof e == "function") return new N({ fetch: e });
602
+ if (F(e)) return e;
603
+ if (I(e)) return new N(e);
604
+ throw Error("Invalid option source init.");
605
+ }
606
+ function F(e) {
607
+ return !e || typeof e != "object" ? !1 : "getOptionPage" in e && typeof e.getOptionPage == "function" && "resolveValues" in e && typeof e.resolveValues == "function";
608
+ }
609
+ function I(e) {
610
+ return !e || typeof e != "object" ? !1 : "fetch" in e && typeof e.fetch == "function";
611
+ }
612
+ //#endregion
613
+ //#region src/utils/mergeOptions.ts
614
+ function L(e, t) {
615
+ let n = [], r = /* @__PURE__ */ new Set();
616
+ for (let t of e) r.has(t.value) || (r.add(t.value), n.push(t));
617
+ for (let e of t) r.has(e.value) || (r.add(e.value), n.push(e));
618
+ return n;
619
+ }
620
+ //#endregion
621
+ //#region src/option-list-select/useOptionListController.ts
622
+ var R = 2, z = 250;
623
+ function B({ optionSource: e, staticOptions: t, searchMatcher: n, maxAdditionalPages: a = R, value: l, defaultValue: u, multiple: d, isOptionListActive: f = !0 }) {
624
+ let p = f && !!e, m = l !== void 0, [h, g] = c(() => {
625
+ let e = b(m ? l : u);
626
+ return d ? e : e.slice(0, 1);
627
+ }), _ = o(() => {
628
+ let e = b(m ? l : h);
629
+ return d ? e : e.slice(0, 1);
630
+ }, [
631
+ m,
632
+ d,
633
+ h,
634
+ l
635
+ ]), [v, y] = c(""), [x, S] = c(() => p ? "" : void 0), [C, w] = c({
636
+ items: [],
637
+ result: void 0,
638
+ error: void 0,
639
+ isPending: p,
640
+ additionalPagesLoaded: 0,
641
+ lastAttemptedQuery: p ? {
642
+ search: void 0,
643
+ initiatedBySearch: !1
644
+ } : void 0
645
+ }), [T, E] = c(0), [D, O] = c(() => [..._]), [k, A] = c({
646
+ key: "",
647
+ options: [],
648
+ error: void 0
649
+ }), [j, N] = c(!1), P = s(void 0), F = s(void 0), I = s(void 0), B = s(/* @__PURE__ */ new Map()), V = s({
650
+ isOptionListActive: f,
651
+ optionSource: e
652
+ }), U = o(() => JSON.stringify(_), [_]), W = f && !!e && x === void 0 && C.result === void 0 && C.error === void 0, te = !W && !C.isPending && C.error === void 0, ne = C.error !== void 0, re = r((e) => {
653
+ let t = d ? e : e.slice(0, 1);
654
+ m || g(t);
655
+ }, [m, d]);
656
+ i(() => {
657
+ let t = V.current, n = f !== t.isOptionListActive, r = e !== t.optionSource;
658
+ if (!n && !r) return;
659
+ V.current = {
660
+ isOptionListActive: f,
661
+ optionSource: e
662
+ }, (!f || r) && (P.current?.abort(), P.current = void 0, F.current?.abort(), F.current = void 0);
663
+ let i = !1;
664
+ return queueMicrotask(() => {
665
+ if (!i) {
666
+ if (!f) {
667
+ w((e) => ({
668
+ ...e,
669
+ isPending: !1
670
+ }));
671
+ return;
672
+ }
673
+ if (y(""), O(_), S(""), e) {
674
+ w((e) => ({
675
+ ...e,
676
+ items: [],
677
+ result: void 0,
678
+ error: void 0,
679
+ isPending: !0,
680
+ additionalPagesLoaded: 0,
681
+ lastAttemptedQuery: {
682
+ search: void 0,
683
+ initiatedBySearch: !1
684
+ }
685
+ }));
686
+ return;
687
+ }
688
+ w((e) => ({
689
+ ...e,
690
+ error: void 0,
691
+ isPending: !1
692
+ }));
693
+ }
694
+ }), () => {
695
+ i = !0;
696
+ };
697
+ }, [
698
+ f,
699
+ e,
700
+ _
701
+ ]), i(() => {
702
+ if (!f || v === x) return;
703
+ let t = window.setTimeout(() => {
704
+ e && (w((e) => ({
705
+ ...e,
706
+ isPending: !0,
707
+ error: void 0,
708
+ lastAttemptedQuery: {
709
+ search: v || void 0,
710
+ initiatedBySearch: !0
711
+ }
712
+ })), E((e) => e + 1)), S(v);
713
+ }, z);
714
+ return () => {
715
+ window.clearTimeout(t);
716
+ };
717
+ }, [
718
+ x,
719
+ f,
720
+ e,
721
+ v
722
+ ]), i(() => {
723
+ if (!f || !e || x === void 0) return;
724
+ let t = !1;
725
+ P.current?.abort();
726
+ let n = new AbortController();
727
+ P.current = n;
728
+ let r = x ? {
729
+ search: x,
730
+ signal: n.signal
731
+ } : { signal: n.signal };
732
+ return e.getOptionPage(r).then((e) => {
733
+ t || w((t) => ({
734
+ ...t,
735
+ items: e.options,
736
+ result: e,
737
+ error: void 0,
738
+ isPending: !1,
739
+ additionalPagesLoaded: 0
740
+ }));
741
+ }).catch((e) => {
742
+ t || n.signal.aborted || w((t) => ({
743
+ ...t,
744
+ items: [],
745
+ result: void 0,
746
+ isPending: !1,
747
+ error: M(e)
748
+ }));
749
+ }), () => {
750
+ t = !0, n.abort(), P.current === n && (P.current = void 0);
751
+ };
752
+ }, [
753
+ x,
754
+ f,
755
+ e,
756
+ T
757
+ ]);
758
+ let G = r((e) => {
759
+ O((e) => {
760
+ if (_.length === 0) return e;
761
+ let t = [...e], n = new Set(e);
762
+ for (let e of _) n.has(e) || (n.add(e), t.push(e));
763
+ return t;
764
+ }), y(e);
765
+ }, [_]), K = r(() => {
766
+ !e || !f || (w((e) => ({
767
+ ...e,
768
+ items: [],
769
+ result: void 0,
770
+ error: void 0,
771
+ isPending: !0,
772
+ additionalPagesLoaded: 0,
773
+ lastAttemptedQuery: {
774
+ search: x,
775
+ initiatedBySearch: !!e.lastAttemptedQuery?.initiatedBySearch
776
+ }
777
+ })), E((e) => e + 1), S((e) => e ?? ""));
778
+ }, [
779
+ x,
780
+ f,
781
+ e
782
+ ]), ie = !!C.result?.nextPage && C.additionalPagesLoaded < a && C.items.length > 0 && te && !C.isPending, q = !!C.result?.nextPage && C.items.length > 0 && te, J = r(() => {
783
+ if (!C.result?.nextPage || !ie || C.isPending) return;
784
+ w((e) => ({
785
+ ...e,
786
+ isPending: !0,
787
+ lastAttemptedQuery: {
788
+ search: x,
789
+ initiatedBySearch: !1
790
+ }
791
+ })), F.current?.abort();
792
+ let e = new AbortController();
793
+ F.current = e, C.result.nextPage({ signal: e.signal }).then((t) => {
794
+ F.current === e && w((e) => ({
795
+ ...e,
796
+ items: [...e.items, ...t.options],
797
+ result: t,
798
+ additionalPagesLoaded: e.additionalPagesLoaded + 1,
799
+ error: void 0,
800
+ isPending: !1
801
+ }));
802
+ }).catch((t) => {
803
+ e.signal.aborted || F.current !== e || w((e) => ({
804
+ ...e,
805
+ error: M(t),
806
+ isPending: !1
807
+ }));
808
+ }).finally(() => {
809
+ F.current === e && (F.current = void 0);
810
+ });
811
+ }, [
812
+ ie,
813
+ x,
814
+ C.isPending,
815
+ C.result
816
+ ]);
817
+ i(() => {
818
+ let e = /* @__PURE__ */ new Map();
819
+ for (let n of t) e.has(n.value) || e.set(n.value, n);
820
+ B.current = e;
821
+ }, [e, t]);
822
+ let ae = x ?? "", oe = o(() => H(t.find((e) => e.hidden) ? t.filter((e) => !e.hidden) : t, ae, n), [
823
+ ae,
824
+ n,
825
+ t
826
+ ]), Y = o(() => {
827
+ if (!e) return oe;
828
+ let t = C.items.find((e) => e.hidden) ? C.items.filter((e) => !e.hidden) : C.items;
829
+ return L(oe, t);
830
+ }, [
831
+ oe,
832
+ e,
833
+ C.items
834
+ ]);
835
+ i(() => {
836
+ if (!(!e || Y.length === 0)) for (let e of Y) B.current.has(e.value) || B.current.set(e.value, e);
837
+ }, [e, Y]), i(() => {
838
+ if (!e || _.length === 0) return;
839
+ let t = !1;
840
+ I.current?.abort();
841
+ let n = new AbortController();
842
+ I.current = n;
843
+ let r = JSON.stringify(_), i = B.current, a = /* @__PURE__ */ new Map();
844
+ for (let e of _) {
845
+ let t = i.get(e);
846
+ t && a.set(e, t);
847
+ }
848
+ let o = _.filter((e) => !a.has(e));
849
+ if (o.length === 0) {
850
+ I.current = void 0, queueMicrotask(() => {
851
+ t || (N(!1), A({
852
+ key: r,
853
+ options: _.map((e) => a.get(e)).filter((e) => e !== void 0),
854
+ error: void 0
855
+ }));
856
+ });
857
+ return;
858
+ }
859
+ return queueMicrotask(() => {
860
+ N(!0);
861
+ }), e.resolveValues(o, n.signal).then((e) => {
862
+ if (t) return;
863
+ let n = new Map(e.map((e) => [e.value, e]));
864
+ for (let t of e) i.set(t.value, t);
865
+ let o = _.map((e) => a.get(e) ?? n.get(e)).filter((e) => e !== void 0), s = _.filter((e) => !n.has(e)).filter((e) => !a.has(e));
866
+ N(!1), A({
867
+ key: r,
868
+ options: o,
869
+ error: s.length > 0 ? M(/* @__PURE__ */ Error()) : void 0
870
+ });
871
+ }).catch((e) => {
872
+ t || n.signal.aborted || (N(!1), A({
873
+ key: r,
874
+ options: [],
875
+ error: M(e)
876
+ }));
877
+ }), () => {
878
+ t = !0, n.abort(), I.current === n && (I.current = void 0);
879
+ };
880
+ }, [e, _]);
881
+ let X = o(() => {
882
+ if (e) return _.length === 0 || k.key !== U ? [] : k.options;
883
+ let n = new Map(t.map((e) => [e.value, e]));
884
+ return _.map((e) => n.get(e) || {
885
+ value: e,
886
+ label: "",
887
+ disabled: !1
888
+ });
889
+ }, [
890
+ e,
891
+ k.key,
892
+ k.options,
893
+ _,
894
+ U,
895
+ t
896
+ ]), Z = o(() => {
897
+ if (ne) return C.error ?? M();
898
+ }, [ne, C.error]), se = ae.trim().length > 0 && !(C.isPending && C.lastAttemptedQuery?.initiatedBySearch), Q = o(() => {
899
+ if (D.length === 0) return [];
900
+ let e = new Set(D), t = /* @__PURE__ */ new Map();
901
+ for (let n of Y) e.has(n.value) && t.set(n.value, n);
902
+ for (let n of X) e.has(n.value) && t.set(n.value, n);
903
+ return D.map((e) => t.get(e)).filter((e) => e !== void 0);
904
+ }, [
905
+ X,
906
+ D,
907
+ Y
908
+ ]), ce = o(() => Z && (C.lastAttemptedQuery?.initiatedBySearch || Y.length === 0) ? [] : ee(Y, D, e ? Q : void 0, se), [
909
+ se,
910
+ e,
911
+ Z,
912
+ C.lastAttemptedQuery?.initiatedBySearch,
913
+ Q,
914
+ D,
915
+ Y
916
+ ]), le = o(() => {
917
+ if (!(!e || _.length === 0 || k.key !== U || k.error === void 0)) return k.error;
918
+ }, [
919
+ e,
920
+ k.error,
921
+ k.key,
922
+ _.length,
923
+ U
924
+ ]), ue = f && !!e && (W || C.isPending), $ = ue && !!C.lastAttemptedQuery?.initiatedBySearch, de = !!e && _.length > 0 && j;
925
+ return i(() => () => {
926
+ P.current?.abort(), F.current?.abort(), I.current?.abort();
927
+ }, []), {
928
+ searchValue: v,
929
+ selectedValues: _,
930
+ options: ce,
931
+ isOptionsPending: ue,
932
+ isSearching: $,
933
+ isResolveValuesPending: de,
934
+ optionsError: Z,
935
+ resolveValuesError: le,
936
+ canLoadMore: ie,
937
+ hasMore: q,
938
+ handleSelectedValuesChange: re,
939
+ handleSearchChange: G,
940
+ handleRetryOptions: e ? K : void 0,
941
+ handleLoadMore: J
942
+ };
943
+ }
944
+ function V(e, t) {
945
+ let n = t.trim().toLowerCase();
946
+ return n ? e.label.toLowerCase().includes(n) : !0;
947
+ }
948
+ function H(e, t, n) {
949
+ return t.trim() ? n ? e.filter((e) => n(e, t)) : e.filter((e) => V(e, t)) : e;
950
+ }
951
+ function ee(e, t, n, r) {
952
+ if (!t || t.length === 0 || r) return e;
953
+ let i = new Set(t), a = e.filter((e) => i.has(e.value)), o = new Set(a.map((e) => e.value)), s = [];
954
+ for (let e of n ?? []) !i.has(e.value) || o.has(e.value) || (o.add(e.value), s.push(e));
955
+ let c = e.filter((e) => !o.has(e.value));
956
+ return a.length === 0 && s.length === 0 ? e : [
957
+ ...a,
958
+ ...s,
959
+ ...c
960
+ ];
961
+ }
962
+ //#endregion
963
+ //#region src/utils/createSyntheticEvent.ts
964
+ function U(e) {
965
+ let { value: t, disabled: n, ...r } = e;
966
+ return {
967
+ addEventListener: () => void 0,
968
+ removeEventListener: () => void 0,
969
+ dispatchEvent: () => !0,
970
+ ...W(t),
971
+ disabled: n ?? !1,
972
+ ...r
973
+ };
974
+ }
975
+ function W(e) {
976
+ let t, n = [];
977
+ typeof e == "string" ? (t = e, n.push({
978
+ value: e,
979
+ label: "",
980
+ selected: !0,
981
+ disabled: !1
982
+ })) : Array.isArray(e) ? (t = e[0] ?? "", n.push(...e.map((e) => ({
983
+ value: e,
984
+ label: "",
985
+ selected: !0,
986
+ disabled: !1
987
+ })))) : t = "";
988
+ let r = Object.assign(n, {
989
+ selectedIndex: n.length > 0 ? 0 : -1,
990
+ item: (e) => n[e] ?? null,
991
+ namedItem: () => null,
992
+ length: n.length,
993
+ [Symbol.iterator]: n[Symbol.iterator].bind(n)
994
+ });
995
+ return {
996
+ value: t,
997
+ selectedOptions: r
998
+ };
999
+ }
1000
+ function te(e) {
1001
+ return G("change", e);
1002
+ }
1003
+ function ne(e, t) {
1004
+ let n = G("input", e), r = {
1005
+ ...n.nativeEvent,
1006
+ data: t.data,
1007
+ dataTransfer: null,
1008
+ detail: 0,
1009
+ inputType: "insertText",
1010
+ isComposing: !1,
1011
+ view: null,
1012
+ which: 0,
1013
+ getTargetRanges: () => [],
1014
+ initUIEvent: () => void 0
1015
+ };
1016
+ return {
1017
+ ...n,
1018
+ nativeEvent: r,
1019
+ data: t.data
1020
+ };
1021
+ }
1022
+ function re(e) {
1023
+ return G("invalid", e);
1024
+ }
1025
+ function G(e, t) {
1026
+ let n = e, r = !1, i = !0, a = !0, o = {
1027
+ get type() {
1028
+ return n;
1029
+ },
1030
+ currentTarget: t,
1031
+ target: t,
1032
+ get cancelable() {
1033
+ return a;
1034
+ },
1035
+ get defaultPrevented() {
1036
+ return r;
1037
+ },
1038
+ preventDefault() {
1039
+ r = !0;
1040
+ },
1041
+ get bubbles() {
1042
+ return i;
1043
+ },
1044
+ stopPropagation() {
1045
+ i = !1;
1046
+ },
1047
+ eventPhase: Event.NONE,
1048
+ isTrusted: !0,
1049
+ timeStamp: Date.now(),
1050
+ get cancelBubble() {
1051
+ return !i;
1052
+ },
1053
+ set cancelBubble(e) {
1054
+ i = !e;
1055
+ },
1056
+ composed: !1,
1057
+ get returnValue() {
1058
+ return !r;
1059
+ },
1060
+ set returnValue(e) {
1061
+ r = !e;
1062
+ },
1063
+ srcElement: t,
1064
+ composedPath() {
1065
+ return [t];
1066
+ },
1067
+ initEvent(e, t, r) {
1068
+ n = e, i = t ?? !1, a = r ?? !0;
1069
+ },
1070
+ stopImmediatePropagation() {
1071
+ i = !1;
1072
+ },
1073
+ AT_TARGET: Event.AT_TARGET,
1074
+ BUBBLING_PHASE: Event.BUBBLING_PHASE,
1075
+ CAPTURING_PHASE: Event.CAPTURING_PHASE,
1076
+ NONE: Event.NONE
1077
+ };
1078
+ return {
1079
+ get type() {
1080
+ return n;
1081
+ },
1082
+ currentTarget: t,
1083
+ target: t,
1084
+ get cancelable() {
1085
+ return a;
1086
+ },
1087
+ get defaultPrevented() {
1088
+ return r;
1089
+ },
1090
+ preventDefault() {
1091
+ r = !0;
1092
+ },
1093
+ get bubbles() {
1094
+ return i;
1095
+ },
1096
+ stopPropagation() {
1097
+ i = !1;
1098
+ },
1099
+ eventPhase: Event.NONE,
1100
+ isTrusted: !0,
1101
+ timeStamp: o.timeStamp,
1102
+ nativeEvent: o,
1103
+ isDefaultPrevented() {
1104
+ return r;
1105
+ },
1106
+ isPropagationStopped() {
1107
+ return !i;
1108
+ },
1109
+ persist: () => void 0
1110
+ };
1111
+ }
1112
+ function K(e, t) {
1113
+ let n = Object.create(e);
1114
+ return Object.defineProperties(n, {
1115
+ currentTarget: { get() {
1116
+ return t;
1117
+ } },
1118
+ target: { get() {
1119
+ return t;
1120
+ } }
1121
+ }), n;
1122
+ }
1123
+ function ie(e, t) {
1124
+ let n = {};
1125
+ for (let r of Object.keys(t)) {
1126
+ let i = t[r];
1127
+ typeof i == "function" && (n[r] = ((t) => {
1128
+ i(K(t, e));
1129
+ }));
1130
+ }
1131
+ return n;
1132
+ }
1133
+ //#endregion
1134
+ //#region src/utils/ErrorIndicator.tsx
1135
+ var q = "⚠", J = "↻";
1136
+ function ae({ className: e, style: t, message: n, inline: r, onRetry: i, customization: a }) {
1137
+ let o = a?.classNamePrefix ?? "super-select", s = o.length > 0 ? `${o}__` : "";
1138
+ return /* @__PURE__ */ d(r ? "span" : "div", {
1139
+ className: f(`${s}alert`, `${s}alert-danger`, i && `${s}alert-dismissible`, r && `${s}d-block`, e),
1140
+ style: t,
1141
+ children: [
1142
+ a?.icon ?? /* @__PURE__ */ u("span", {
1143
+ "aria-hidden": !!n,
1144
+ children: q
1145
+ }),
1146
+ " ",
1147
+ n && /* @__PURE__ */ u(l, { children: n }),
1148
+ " ",
1149
+ i && /* @__PURE__ */ u("button", {
1150
+ type: "button",
1151
+ className: f(`${s}btn`, `${s}btn-outline-secondary`, `${s}btn-sm`, a?.retryButton?.className),
1152
+ style: a?.retryButton?.style,
1153
+ title: a?.retryButton?.title,
1154
+ onClick: i,
1155
+ children: a?.retryButton?.content ?? J
1156
+ })
1157
+ ]
1158
+ });
1159
+ }
1160
+ //#endregion
1161
+ //#region src/utils/FormResetListener.tsx
1162
+ function oe({ form: e, onReset: t }) {
1163
+ let n = s(null);
1164
+ return i(() => {
1165
+ let e = n.current?.form, r = e?.ownerDocument.defaultView;
1166
+ if (!e || !r) return;
1167
+ let i = (n) => {
1168
+ n.target === e && !n.defaultPrevented && t();
1169
+ };
1170
+ return r.addEventListener("reset", i), () => r.removeEventListener("reset", i);
1171
+ }, [e, t]), /* @__PURE__ */ u("input", {
1172
+ ref: n,
1173
+ type: "hidden",
1174
+ form: e
1175
+ });
1176
+ }
1177
+ //#endregion
1178
+ //#region src/utils/parseChildOptions.ts
1179
+ function Y(e) {
1180
+ return X(e, /* @__PURE__ */ new Set());
1181
+ }
1182
+ function X(r, i) {
1183
+ let a = [];
1184
+ for (let o of e.toArray(r)) if (n(o)) {
1185
+ if (o.type === t) {
1186
+ let e = o;
1187
+ a.push(...X(e.props.children, i));
1188
+ continue;
1189
+ }
1190
+ if (o.type === "option") {
1191
+ let e = o, t = se(e.props.children), n = e.props.value === void 0 ? t : String(e.props.value);
1192
+ if (i.has(n)) continue;
1193
+ i.add(n);
1194
+ let r = e.props.label === void 0 ? t : String(e.props.label), s = e.props, c = Object.entries(s).reduce((e, [t, n]) => (!t.startsWith("data-") || n === void 0 || (e[t.slice(5)] = n), e), {}), l = e.props.data === void 0 ? Object.keys(c).length > 0 ? c : void 0 : {
1195
+ ...c,
1196
+ value: e.props.data
1197
+ };
1198
+ a.push({
1199
+ value: n,
1200
+ label: r,
1201
+ children: Z(e.props.children) ? e.props.children : void 0,
1202
+ disabled: !!e.props.disabled,
1203
+ hidden: !!e.props.hidden,
1204
+ data: l
1205
+ });
1206
+ continue;
1207
+ }
1208
+ if (o.type === "optgroup") {
1209
+ let t = o, n = String(t.props.label ?? ""), r = e.toArray(t.props.children);
1210
+ for (let e of r) {
1211
+ let t = X(e, i);
1212
+ for (let e of t) e.groupLabel = n, a.push(e);
1213
+ }
1214
+ }
1215
+ }
1216
+ return a;
1217
+ }
1218
+ function Z(e) {
1219
+ return e == null || typeof e == "boolean" || typeof e == "string" || typeof e == "number" ? !1 : Array.isArray(e) ? e.some((e) => Z(e)) : !0;
1220
+ }
1221
+ function se(e) {
1222
+ return e == null || typeof e == "boolean" ? "" : typeof e == "string" ? e : typeof e == "number" ? String(e) : Array.isArray(e) ? e.map((e) => se(e)).join("") : n(e) ? se(e.props.children) : "";
1223
+ }
1224
+ //#endregion
1225
+ //#region src/modal-select/ModalSelectButton.tsx
1226
+ function Q({ ref: e, customization: t, children: n, className: r, ...i }) {
1227
+ let a = t?.classNamePrefix ?? "super-select", o = a.length > 0 ? `${a}__` : "";
1228
+ return /* @__PURE__ */ u("button", {
1229
+ ref: e,
1230
+ type: "button",
1231
+ className: f(`${o}form-select`, `${o}text-start`, r),
1232
+ ...i,
1233
+ children: n
1234
+ });
1235
+ }
1236
+ //#endregion
1237
+ //#region src/modal-select/OkButton.tsx
1238
+ var ce = "✓";
1239
+ function le({ className: e, style: t, disabled: n, title: r, onClick: i, customization: a }) {
1240
+ let o = a?.classNamePrefix ?? "super-select", s = o.length > 0 ? `${o}__` : "";
1241
+ return /* @__PURE__ */ u("button", {
1242
+ type: "button",
1243
+ className: f(`${s}btn`, `${s}btn-secondary`, e),
1244
+ style: t,
1245
+ onClick: i,
1246
+ disabled: n,
1247
+ title: r,
1248
+ children: a?.content ?? ce
1249
+ });
1250
+ }
1251
+ //#endregion
1252
+ //#region src/modal-select/SelectedContent.tsx
1253
+ function ue({ customization: e, selectedOptions: t, className: n, style: r }) {
1254
+ let i = e?.classNamePrefix ?? "super-select", a = i.length > 0 ? `${i}__` : "";
1255
+ return t.length > 1 ? /* @__PURE__ */ u("ul", {
1256
+ className: f(`${a}list-inline`, `${a}d-inline`, n),
1257
+ style: r,
1258
+ children: t.map((e) => /* @__PURE__ */ u("li", {
1259
+ className: `${a}list-inline-item`,
1260
+ children: e.children ?? e.label
1261
+ }, e.value))
1262
+ }) : /* @__PURE__ */ u("span", {
1263
+ className: n,
1264
+ style: r,
1265
+ children: t[0]?.children ?? t[0]?.label ?? e?.placeholder ?? ""
1266
+ });
1267
+ }
1268
+ //#endregion
1269
+ //#region src/modal-select/ModalSelect.tsx
1270
+ function $({ optionSource: e, children: t, customization: n, ref: i, multiple: a, disabled: p, required: m, value: h, defaultValue: g, name: _, id: v, form: y, autoFocus: x, autoComplete: S, onInput: C, onInvalid: w, onChange: E, onValueChange: D, className: O, style: k, ...A }) {
1271
+ let [j, M] = c(!1), [N, P] = c(!1), F = o(() => Y(t), [t]), I = h !== void 0, L = s(g), R = B({
1272
+ optionSource: e,
1273
+ staticOptions: F,
1274
+ searchMatcher: n?.searchMatcher,
1275
+ maxAdditionalPages: n?.maxAdditionalPages,
1276
+ value: h,
1277
+ defaultValue: g,
1278
+ multiple: a,
1279
+ isOptionListActive: j
1280
+ }), z = r(() => {
1281
+ p || M(!0);
1282
+ }, [p]), V = r(() => {
1283
+ M(!1);
1284
+ }, []), H = r(() => {
1285
+ if (I) return;
1286
+ let e = b(L.current);
1287
+ R.handleSelectedValuesChange(a ? e : e.slice(0, 1)), P(!1);
1288
+ }, [
1289
+ R,
1290
+ I,
1291
+ a,
1292
+ P
1293
+ ]), ee = r((e) => {
1294
+ if (p) return;
1295
+ R.handleSelectedValuesChange(e), (!m || e.length > 0) && P(!1);
1296
+ let t = U({
1297
+ id: v,
1298
+ name: _,
1299
+ value: a ? e : e[0] ?? "",
1300
+ multiple: a,
1301
+ disabled: p,
1302
+ required: m
1303
+ });
1304
+ C && C(ne(t, { data: "" })), E && E(te(t)), D && D(a ? e : e[0] ?? "");
1305
+ }, [
1306
+ R,
1307
+ p,
1308
+ v,
1309
+ a,
1310
+ _,
1311
+ E,
1312
+ C,
1313
+ D,
1314
+ m,
1315
+ P
1316
+ ]), W = r((e) => {
1317
+ let t = Array.from(e.currentTarget.selectedOptions).map((e) => e?.value ?? ""), n = a ? t : t.length > 0 ? [t[0] ?? ""] : e.currentTarget.value === "" ? [] : [e.currentTarget.value];
1318
+ ee(n);
1319
+ }, [ee, a]), G = o(() => {
1320
+ if (R.selectedValues.length === 0) return [];
1321
+ let e = /* @__PURE__ */ new Map();
1322
+ for (let t of F) e.has(t.value) || e.set(t.value, t);
1323
+ for (let t of R.options) e.set(t.value, t);
1324
+ let t = R.selectedValues.map((t) => e.get(t)).filter((e) => e !== void 0);
1325
+ return t.length > 0 ? t : de(R.selectedValues, F);
1326
+ }, [
1327
+ R.options,
1328
+ R.selectedValues,
1329
+ F
1330
+ ]), K = o(() => U({
1331
+ id: v,
1332
+ name: _,
1333
+ value: a ? R.selectedValues : R.selectedValues[0] ?? "",
1334
+ multiple: a,
1335
+ disabled: p,
1336
+ required: m
1337
+ }), [
1338
+ R.selectedValues,
1339
+ p,
1340
+ v,
1341
+ a,
1342
+ _,
1343
+ m
1344
+ ]), q = {
1345
+ ...A,
1346
+ size: void 0
1347
+ }, J = A["aria-label"], X = A["aria-labelledby"] ?? (J ? void 0 : v), Z = ie(K, q), se = r((e) => {
1348
+ z(), Z.onClick?.(e);
1349
+ }, [z, Z]), ce = r((e) => {
1350
+ e.preventDefault(), P(!0), w && w(re(K));
1351
+ }, [
1352
+ K,
1353
+ w,
1354
+ P
1355
+ ]), le = N && !!m && R.selectedValues.length === 0, $ = n?.classNamePrefix ?? "super-select", pe = $.length > 0 ? `${$}__` : "", me = o(() => F.find((e) => e.value === "")?.label, [F]), he = n?.modalSelectButton?.selectedContent?.placeholder ?? me, ge = G.length > 0, _e = !!R.resolveValuesError, ve = _e || le, ye = n?.errorIndicator?.component ?? ae, be = n?.pendingIndicator?.component ?? T, xe = n?.modalSelectButton?.component ?? Q, Se = n?.modalSelectButton?.selectedContent?.component ?? ue;
1356
+ return /* @__PURE__ */ d(l, { children: [
1357
+ /* @__PURE__ */ u(xe, {
1358
+ ...q,
1359
+ ...Z,
1360
+ id: v,
1361
+ autoFocus: x,
1362
+ "aria-haspopup": "dialog",
1363
+ "aria-expanded": j,
1364
+ "aria-busy": R.isResolveValuesPending || void 0,
1365
+ "aria-invalid": ve || void 0,
1366
+ disabled: p,
1367
+ className: f(p ? `${pe}disabled` : void 0, ve ? `${pe}is-invalid` : void 0, O, n?.modalSelectButton?.className),
1368
+ style: k && n?.modalSelectButton?.style ? {
1369
+ ...k,
1370
+ ...n.modalSelectButton.style
1371
+ } : k ?? n?.modalSelectButton?.style,
1372
+ onClick: se,
1373
+ ref: i,
1374
+ customization: { classNamePrefix: $ },
1375
+ children: _e && R.resolveValuesError ? /* @__PURE__ */ u(ye, {
1376
+ inline: !0,
1377
+ className: n?.errorIndicator?.className,
1378
+ style: n?.errorIndicator?.style,
1379
+ error: R.resolveValuesError,
1380
+ message: R.resolveValuesError.userMessage ?? n?.errorIndicator?.defaultMessage,
1381
+ customization: {
1382
+ classNamePrefix: $,
1383
+ icon: n?.errorIndicator?.icon
1384
+ }
1385
+ }) : R.isResolveValuesPending ? /* @__PURE__ */ u(be, {
1386
+ inline: !0,
1387
+ className: n?.pendingIndicator?.className,
1388
+ style: n?.pendingIndicator?.style,
1389
+ title: n?.pendingIndicator?.title,
1390
+ content: n?.pendingIndicator?.content,
1391
+ customization: { classNamePrefix: $ }
1392
+ }) : /* @__PURE__ */ u(Se, {
1393
+ selectedOptions: G,
1394
+ className: f(!ge || _e ? `${pe}text-body-secondary` : void 0, n?.modalSelectButton?.selectedContent?.className),
1395
+ style: n?.modalSelectButton?.selectedContent?.style,
1396
+ customization: {
1397
+ classNamePrefix: $,
1398
+ placeholder: he
1399
+ }
1400
+ })
1401
+ }),
1402
+ /* @__PURE__ */ u(fe, {
1403
+ customization: n,
1404
+ isOpen: j,
1405
+ dir: A.dir,
1406
+ lang: A.lang,
1407
+ ariaLabel: J,
1408
+ ariaLabelledBy: X,
1409
+ onClose: V,
1410
+ searchValue: R.searchValue,
1411
+ onSearchChange: R.handleSearchChange,
1412
+ options: R.options,
1413
+ selectedValues: R.selectedValues,
1414
+ multiple: a,
1415
+ isOptionsPending: R.isOptionsPending,
1416
+ isSearching: R.isSearching,
1417
+ isResolveValuesPending: R.isResolveValuesPending,
1418
+ onRefresh: R.handleRetryOptions,
1419
+ optionsError: R.optionsError,
1420
+ onOptionListChange: W,
1421
+ canLoadMore: R.canLoadMore,
1422
+ hasMore: R.hasMore,
1423
+ onLoadMore: R.handleLoadMore
1424
+ }),
1425
+ _ || m ? /* @__PURE__ */ u("select", {
1426
+ name: _,
1427
+ form: y,
1428
+ autoComplete: S,
1429
+ ...A,
1430
+ required: m,
1431
+ disabled: p,
1432
+ onInvalid: ce,
1433
+ multiple: a,
1434
+ value: a ? R.selectedValues : R.selectedValues[0] ?? "",
1435
+ onChange: () => void 0,
1436
+ "aria-hidden": !0,
1437
+ hidden: !0,
1438
+ tabIndex: -1,
1439
+ className: `${pe}visually-hidden`,
1440
+ children: R.selectedValues.map((e) => /* @__PURE__ */ u("option", {
1441
+ value: e,
1442
+ children: e
1443
+ }, e))
1444
+ }) : null,
1445
+ I ? null : /* @__PURE__ */ u(oe, {
1446
+ form: y,
1447
+ onReset: H
1448
+ })
1449
+ ] });
1450
+ }
1451
+ function de(e, t) {
1452
+ if (e.length === 0) return [];
1453
+ let n = new Map(t.map((e) => [e.value, e]));
1454
+ return e.map((e) => n.get(e)).filter((e) => e !== void 0);
1455
+ }
1456
+ function fe({ customization: e, isOpen: t, dir: n, lang: a, ariaLabel: c, ariaLabelledBy: l, onClose: d, searchValue: f, onSearchChange: p, options: h, selectedValues: g, multiple: v, isOptionsPending: S, isSearching: C, isResolveValuesPending: w, onRefresh: D, optionsError: O, onOptionListChange: k, canLoadMore: A, onLoadMore: j, hasMore: M }) {
1457
+ let N = e?.classNamePrefix ?? "super-select", P = N.length > 0 ? `${N}__` : "", F = e?.searchInput?.component ?? E, I = e?.modal?.okButton?.component ?? le, L = e?.modal?.component ?? m, R = e?.optionListInput?.component ?? x, z = e?.errorIndicator?.component ?? ae, B = e?.emptyIndicator?.component ?? _, V = e?.moreIndicator?.component ?? y, H = e?.pendingIndicator?.component ?? T, ee = s(null), W = s(!1), ne = !!C, re = !!(S || w), G = o(() => {
1458
+ let e = b(g);
1459
+ return v ? e : e.slice(0, 1);
1460
+ }, [v, g]), K = h.length > 0, ie = re, q = O, J = !!q, oe = !J && !ie && !K, Y = !J && !ie && !oe && !!M;
1461
+ i(() => {
1462
+ if (!t) return;
1463
+ let e = ee.current;
1464
+ if (!e) return;
1465
+ let n = window.setTimeout(() => {
1466
+ e.focus();
1467
+ }, 0);
1468
+ return () => {
1469
+ window.clearTimeout(n);
1470
+ };
1471
+ }, [t]);
1472
+ let X = r((e) => {
1473
+ if (e.shiftKey || e.ctrlKey || e.altKey || e.metaKey) return;
1474
+ if (e.key === "Enter") {
1475
+ e.preventDefault();
1476
+ return;
1477
+ }
1478
+ let t = e.key === "ArrowDown" ? 1 : e.key === "ArrowUp" ? -1 : 0;
1479
+ if (!t) return;
1480
+ let n = e.currentTarget.closest([
1481
+ `.${P}modal-content`,
1482
+ "[class*='modal-content']",
1483
+ "[class*='modal-body']",
1484
+ "dialog",
1485
+ "[role='dialog']",
1486
+ "[aria-modal='true']"
1487
+ ].join(",")) ?? e.currentTarget.parentElement;
1488
+ if (!n) return;
1489
+ let r = n.querySelector([
1490
+ "[role='listbox']",
1491
+ "[role='radiogroup']",
1492
+ "[role='group']",
1493
+ "fieldset",
1494
+ "[class*='modal-body']"
1495
+ ].join(",")) ?? n, i = Array.from(r.querySelectorAll([
1496
+ "input[type='radio']:not(:disabled):not([tabindex='-1'])",
1497
+ "input[type='checkbox']:not(:disabled):not([tabindex='-1'])",
1498
+ "[role='radio']:not([aria-disabled='true']):not([tabindex='-1'])",
1499
+ "[role='checkbox']:not([aria-disabled='true']):not([tabindex='-1'])",
1500
+ "[role='option']:not([aria-disabled='true']):not([tabindex='-1'])"
1501
+ ].join(","))).filter((e) => {
1502
+ if (e.hidden || e.getAttribute("aria-hidden") === "true") return !1;
1503
+ let t = window.getComputedStyle(e);
1504
+ return t.display !== "none" && t.visibility !== "hidden";
1505
+ }), a = t > 0 ? i[0] : i[i.length - 1];
1506
+ a && (e.preventDefault(), a.focus());
1507
+ }, [P]), Z = r((e) => {
1508
+ if (k(e), !v) {
1509
+ if (W.current) {
1510
+ W.current = !1;
1511
+ return;
1512
+ }
1513
+ d();
1514
+ }
1515
+ }, [
1516
+ v,
1517
+ d,
1518
+ k
1519
+ ]), se = r((e) => {
1520
+ let t = v ? e : e.slice(0, 1), n = U({
1521
+ value: v ? t : t[0] ?? "",
1522
+ multiple: v
1523
+ });
1524
+ Z(te(n));
1525
+ }, [Z, v]), Q = r((e) => {
1526
+ if (v || e.detail <= 0) return;
1527
+ W.current = !1;
1528
+ let t = e.currentTarget, n;
1529
+ n = "checked" in t && typeof t.checked == "boolean" ? t.checked : "selected" in t && typeof t.selected == "boolean" ? t.selected : !1, n && d();
1530
+ }, [v, d]), ce = r((e) => {
1531
+ if (!v) {
1532
+ if (e.key === "ArrowDown" || e.key === "ArrowUp" || e.key === "ArrowLeft" || e.key === "ArrowRight") {
1533
+ W.current = !0;
1534
+ return;
1535
+ }
1536
+ if (W.current = !1, e.key === "Enter" || e.key === " " || e.key === "Spacebar") {
1537
+ let t = e.currentTarget, n;
1538
+ n = "checked" in t && typeof t.checked == "boolean" ? t.checked : "selected" in t && typeof t.selected == "boolean" ? t.selected : !1, n && (e.preventDefault(), e.stopPropagation(), d());
1539
+ }
1540
+ }
1541
+ }, [v, d]), ue;
1542
+ return ue = ie ? /* @__PURE__ */ u(H, {
1543
+ inline: !0,
1544
+ className: e?.pendingIndicator?.className,
1545
+ style: e?.pendingIndicator?.style,
1546
+ title: e?.pendingIndicator?.title,
1547
+ content: e?.pendingIndicator?.content,
1548
+ customization: { classNamePrefix: N }
1549
+ }) : J ? /* @__PURE__ */ u(z, {
1550
+ className: e?.errorIndicator?.className,
1551
+ style: e?.errorIndicator?.style,
1552
+ error: q,
1553
+ message: q?.userMessage ?? e?.errorIndicator?.defaultMessage,
1554
+ onRetry: D,
1555
+ customization: {
1556
+ classNamePrefix: N,
1557
+ icon: e?.errorIndicator?.icon,
1558
+ retryButton: e?.errorIndicator?.retryButton
1559
+ }
1560
+ }) : oe ? /* @__PURE__ */ u(B, {
1561
+ className: e?.emptyIndicator?.className,
1562
+ style: e?.emptyIndicator?.style,
1563
+ onRetry: D,
1564
+ customization: {
1565
+ classNamePrefix: N,
1566
+ content: e?.emptyIndicator?.content,
1567
+ retryButton: e?.emptyIndicator?.retryButton
1568
+ }
1569
+ }) : Y ? /* @__PURE__ */ u(V, {
1570
+ onLoadMore: A ? j : void 0,
1571
+ className: e?.moreIndicator?.className,
1572
+ style: e?.moreIndicator?.style,
1573
+ disabled: re,
1574
+ customization: {
1575
+ classNamePrefix: N,
1576
+ loadMoreButton: e?.moreIndicator?.loadMoreButton,
1577
+ overflowIndicator: e?.moreIndicator?.overflowIndicator
1578
+ }
1579
+ }) : void 0, /* @__PURE__ */ u(L, {
1580
+ open: t,
1581
+ dir: n,
1582
+ lang: a,
1583
+ "aria-label": c,
1584
+ "aria-labelledby": l,
1585
+ "aria-busy": S || w || void 0,
1586
+ className: e?.modal?.className,
1587
+ style: e?.modal?.style,
1588
+ customization: {
1589
+ classNamePrefix: N,
1590
+ dialog: e?.modal?.dialog,
1591
+ content: e?.modal?.content,
1592
+ header: e?.modal?.header,
1593
+ body: e?.modal?.body,
1594
+ footer: e?.modal?.footer,
1595
+ closeButton: e?.modal?.closeButton
1596
+ },
1597
+ onClose: () => {
1598
+ d();
1599
+ },
1600
+ onCancel: d,
1601
+ onClick: (e) => {
1602
+ e.target === e.currentTarget && d();
1603
+ },
1604
+ headerContent: /* @__PURE__ */ u(F, {
1605
+ ref: ee,
1606
+ className: e?.searchInput?.className,
1607
+ style: e?.searchInput?.style,
1608
+ search: f,
1609
+ onSearchChange: (e) => p(e ?? ""),
1610
+ onKeyDown: X,
1611
+ isSearching: ne,
1612
+ customization: {
1613
+ classNamePrefix: N,
1614
+ placeholder: e?.searchInput?.placeholder,
1615
+ title: e?.searchInput?.title,
1616
+ pendingIndicator: {
1617
+ className: e?.pendingIndicator?.className,
1618
+ style: e?.pendingIndicator?.style,
1619
+ title: e?.pendingIndicator?.title,
1620
+ content: e?.pendingIndicator?.content,
1621
+ component: e?.pendingIndicator?.component
1622
+ }
1623
+ }
1624
+ }),
1625
+ footerContent: v ? /* @__PURE__ */ u(I, {
1626
+ className: e?.modal?.okButton?.className,
1627
+ style: e?.modal?.okButton?.style,
1628
+ title: e?.modal?.okButton?.title,
1629
+ onClick: d,
1630
+ customization: {
1631
+ classNamePrefix: N,
1632
+ content: e?.modal?.okButton?.content
1633
+ }
1634
+ }) : void 0,
1635
+ children: /* @__PURE__ */ u(R, {
1636
+ options: h,
1637
+ value: G,
1638
+ onValueChange: se,
1639
+ multiple: v,
1640
+ form: "",
1641
+ onKeyDown: (e) => {
1642
+ if (e.key === "Enter" && e.preventDefault(), e.key === "ArrowDown" || e.key === "ArrowUp" || e.key === "ArrowLeft" || e.key === "ArrowRight") {
1643
+ W.current = !0;
1644
+ return;
1645
+ }
1646
+ W.current = !1;
1647
+ },
1648
+ onOptionClick: Q,
1649
+ onOptionKeyDown: ce,
1650
+ customization: {
1651
+ classNamePrefix: N,
1652
+ optionItem: e?.optionListInput?.optionItem,
1653
+ groupHeader: e?.optionListInput?.groupHeader
1654
+ },
1655
+ className: e?.optionListInput?.className,
1656
+ style: e?.optionListInput?.style,
1657
+ "aria-busy": re,
1658
+ indicator: ue
1659
+ })
1660
+ });
1661
+ }
1662
+ //#endregion
1663
+ //#region src/option-list-select/OptionList.tsx
1664
+ function pe({ searchInput: e, optionList: t, className: n, customization: r, ref: i, children: a, ...o }) {
1665
+ let s = r?.classNamePrefix ?? "super-select";
1666
+ return /* @__PURE__ */ d("div", {
1667
+ ref: i,
1668
+ ...o,
1669
+ className: f(s, n),
1670
+ children: [
1671
+ e,
1672
+ t,
1673
+ a
1674
+ ]
1675
+ });
1676
+ }
1677
+ //#endregion
1678
+ //#region src/option-list-select/OptionListSelect.tsx
1679
+ function me({ optionSource: e, children: t, customization: n, ref: i, onBlur: a, onFocus: c, onClick: l, onMouseDown: p, onMouseUp: m, onPointerDown: h, onPointerUp: g, onContextMenu: v, onKeyDown: S, onKeyUp: C, onBeforeInput: w, onSelect: D, onCompositionStart: O, onCompositionUpdate: k, onCompositionEnd: A, onChange: j, onInput: M, onInvalid: N, onValueChange: P, className: F, style: I, ...L }) {
1680
+ let R = o(() => Y(t), [t]), z = s(null), V = n?.searchInput?.component ?? E, H = n?.classNamePrefix ?? "super-select", ee = H.length > 0 ? `${H}__` : "", { multiple: W, disabled: G, value: K, defaultValue: q } = L, J = K !== void 0, X = s(q), Z = B({
1681
+ optionSource: e,
1682
+ staticOptions: R,
1683
+ searchMatcher: n?.searchMatcher,
1684
+ maxAdditionalPages: n?.maxAdditionalPages,
1685
+ value: K,
1686
+ defaultValue: q,
1687
+ multiple: W
1688
+ }), se = r((e) => {
1689
+ if (i) {
1690
+ if (typeof i == "function") {
1691
+ i(e);
1692
+ return;
1693
+ }
1694
+ i.current = e;
1695
+ }
1696
+ }, [i]), Q = o(() => W ? Z.selectedValues : Z.selectedValues.slice(0, 1), [Z.selectedValues, W]), ce = r(() => {
1697
+ if (!J) {
1698
+ let e = b(X.current);
1699
+ Z.handleSelectedValuesChange(W ? e : e.slice(0, 1));
1700
+ }
1701
+ }, [
1702
+ Z,
1703
+ J,
1704
+ W
1705
+ ]), le = r((e) => {
1706
+ e.preventDefault(), N && N(re(U({
1707
+ id: L.id,
1708
+ name: L.name,
1709
+ value: W ? Q : Q[0] ?? "",
1710
+ multiple: W,
1711
+ disabled: G,
1712
+ required: L.required
1713
+ })));
1714
+ }, [
1715
+ G,
1716
+ W,
1717
+ N,
1718
+ L,
1719
+ Q
1720
+ ]), ue = o(() => U({
1721
+ id: L.id,
1722
+ name: L.name,
1723
+ value: W ? Q : Q[0] ?? "",
1724
+ multiple: W,
1725
+ disabled: G,
1726
+ required: L.required
1727
+ }), [
1728
+ G,
1729
+ W,
1730
+ L.id,
1731
+ L.name,
1732
+ L.required,
1733
+ Q
1734
+ ]), $ = {
1735
+ ...L,
1736
+ value: void 0,
1737
+ defaultValue: void 0,
1738
+ size: void 0
1739
+ }, de = $, fe = ie(ue, {
1740
+ ...$,
1741
+ onFocus: c,
1742
+ onBlur: a,
1743
+ onClick: l,
1744
+ onMouseDown: p,
1745
+ onMouseUp: m,
1746
+ onPointerDown: h,
1747
+ onPointerUp: g,
1748
+ onContextMenu: v,
1749
+ onKeyDown: S,
1750
+ onKeyUp: C,
1751
+ onBeforeInput: w,
1752
+ onSelect: D,
1753
+ onCompositionStart: O,
1754
+ onCompositionUpdate: k,
1755
+ onCompositionEnd: A
1756
+ }), me = !!e, he = Z.isOptionsPending || Z.isResolveValuesPending, ge = Z.options.length > 0, _e = Z.optionsError, ve = !!_e, ye = he, be = !ve && !ye && !ge, xe = !ve && !ye && !be && !!Z.hasMore, Se = G || he, Ce = n?.optionList?.component ?? pe, we = n?.optionListInput?.component ?? x, Te = n?.errorIndicator?.component ?? ae, Ee = n?.emptyIndicator?.component ?? _, De = n?.moreIndicator?.component ?? y, Oe = n?.pendingIndicator?.component ?? T, ke;
1757
+ ke = ye ? /* @__PURE__ */ u(Oe, {
1758
+ inline: !0,
1759
+ className: n?.pendingIndicator?.className,
1760
+ style: n?.pendingIndicator?.style,
1761
+ title: n?.pendingIndicator?.title,
1762
+ content: n?.pendingIndicator?.content,
1763
+ customization: { classNamePrefix: H }
1764
+ }) : ve ? /* @__PURE__ */ u(Te, {
1765
+ className: n?.errorIndicator?.className,
1766
+ style: n?.errorIndicator?.style,
1767
+ error: _e,
1768
+ message: _e?.userMessage ?? n?.errorIndicator?.defaultMessage,
1769
+ onRetry: Z.handleRetryOptions,
1770
+ customization: {
1771
+ classNamePrefix: H,
1772
+ icon: n?.errorIndicator?.icon,
1773
+ retryButton: n?.errorIndicator?.retryButton
1774
+ }
1775
+ }) : be ? /* @__PURE__ */ u(Ee, {
1776
+ className: n?.emptyIndicator?.className,
1777
+ style: n?.emptyIndicator?.style,
1778
+ onRetry: Z.handleRetryOptions,
1779
+ customization: {
1780
+ classNamePrefix: H,
1781
+ content: n?.emptyIndicator?.content,
1782
+ retryButton: n?.emptyIndicator?.retryButton
1783
+ }
1784
+ }) : xe ? /* @__PURE__ */ u(De, {
1785
+ onLoadMore: Z.canLoadMore ? Z.handleLoadMore : void 0,
1786
+ className: n?.moreIndicator?.className,
1787
+ style: n?.moreIndicator?.style,
1788
+ disabled: Se,
1789
+ customization: {
1790
+ classNamePrefix: H,
1791
+ loadMoreButton: n?.moreIndicator?.loadMoreButton,
1792
+ overflowIndicator: n?.moreIndicator?.overflowIndicator
1793
+ }
1794
+ }) : void 0;
1795
+ let Ae = r((e) => {
1796
+ let t = W ? e : e.slice(0, 1);
1797
+ Z.handleSelectedValuesChange(t);
1798
+ let n = U({
1799
+ id: L.id,
1800
+ name: L.name,
1801
+ multiple: W,
1802
+ disabled: G,
1803
+ required: L.required,
1804
+ value: W ? t : t[0] ?? ""
1805
+ });
1806
+ M && M(ne(n, { data: "" })), j && j(te(n)), P && P(W ? t : t[0] ?? "");
1807
+ }, [
1808
+ Z,
1809
+ G,
1810
+ W,
1811
+ j,
1812
+ M,
1813
+ P,
1814
+ L
1815
+ ]), je = r((e) => {
1816
+ if (e.shiftKey || e.ctrlKey || e.altKey || e.metaKey) return;
1817
+ let t = e.key === "ArrowDown" ? 1 : e.key === "ArrowUp" ? -1 : 0;
1818
+ if (!t) return;
1819
+ let n = z.current;
1820
+ if (!n) return;
1821
+ let r = n.querySelector([
1822
+ "[role='listbox']",
1823
+ "[role='radiogroup']",
1824
+ "[role='group']",
1825
+ "fieldset",
1826
+ "[class*='list-group']"
1827
+ ].join(",")) ?? n, i = Array.from(r.querySelectorAll([
1828
+ "input[type='radio']:not(:disabled):not([tabindex='-1'])",
1829
+ "input[type='checkbox']:not(:disabled):not([tabindex='-1'])",
1830
+ "[role='radio']:not([aria-disabled='true']):not([tabindex='-1'])",
1831
+ "[role='checkbox']:not([aria-disabled='true']):not([tabindex='-1'])",
1832
+ "[role='option']:not([aria-disabled='true']):not([tabindex='-1'])"
1833
+ ].join(","))).filter((e) => {
1834
+ if (e.hidden || e.getAttribute("aria-hidden") === "true") return !1;
1835
+ let t = window.getComputedStyle(e);
1836
+ return t.display !== "none" && t.visibility !== "hidden";
1837
+ }), a = t > 0 ? i[0] : i[i.length - 1];
1838
+ a && (e.preventDefault(), a.focus());
1839
+ }, []);
1840
+ return /* @__PURE__ */ d(Ce, {
1841
+ ref: z,
1842
+ className: f(n?.optionList?.className, F),
1843
+ style: I && n?.optionList?.style ? {
1844
+ ...I,
1845
+ ...n.optionList.style
1846
+ } : I ?? n?.optionList?.style,
1847
+ "aria-label": L["aria-label"] ?? L.name,
1848
+ dir: L.dir,
1849
+ lang: L.lang,
1850
+ customization: { classNamePrefix: H },
1851
+ searchInput: me ? /* @__PURE__ */ u(V, {
1852
+ className: n?.searchInput?.className,
1853
+ style: n?.searchInput?.style,
1854
+ search: Z.searchValue,
1855
+ onSearchChange: (e) => Z.handleSearchChange(e ?? ""),
1856
+ onKeyDown: je,
1857
+ disabled: G,
1858
+ isSearching: Z.isSearching,
1859
+ customization: {
1860
+ classNamePrefix: H,
1861
+ placeholder: n?.searchInput?.placeholder,
1862
+ title: n?.searchInput?.title,
1863
+ pendingIndicator: {
1864
+ className: n?.pendingIndicator?.className,
1865
+ style: n?.pendingIndicator?.style,
1866
+ title: n?.pendingIndicator?.title,
1867
+ content: n?.pendingIndicator?.content,
1868
+ component: n?.pendingIndicator?.component
1869
+ }
1870
+ }
1871
+ }) : void 0,
1872
+ optionList: /* @__PURE__ */ u(we, {
1873
+ ...de,
1874
+ ...fe,
1875
+ ref: se,
1876
+ id: L.id,
1877
+ name: L.name,
1878
+ multiple: W,
1879
+ disabled: G,
1880
+ required: L.required,
1881
+ form: L.form,
1882
+ autoComplete: L.autoComplete,
1883
+ autoFocus: L.autoFocus,
1884
+ tabIndex: L.tabIndex,
1885
+ title: L.title,
1886
+ options: Z.options,
1887
+ value: Q,
1888
+ onValueChange: Ae,
1889
+ className: n?.optionListInput?.className,
1890
+ style: n?.optionListInput?.style,
1891
+ customization: {
1892
+ classNamePrefix: H,
1893
+ optionItem: n?.optionListInput?.optionItem,
1894
+ groupHeader: n?.optionListInput?.groupHeader
1895
+ },
1896
+ "aria-busy": he,
1897
+ indicator: ke
1898
+ }),
1899
+ children: [L.required ? /* @__PURE__ */ u("input", {
1900
+ type: "checkbox",
1901
+ checked: Q.length > 0,
1902
+ required: !0,
1903
+ disabled: G,
1904
+ form: L.form,
1905
+ tabIndex: -1,
1906
+ "aria-hidden": !0,
1907
+ onChange: () => void 0,
1908
+ onInvalid: le,
1909
+ hidden: !0,
1910
+ className: `${ee}visually-hidden`
1911
+ }) : null, J ? null : /* @__PURE__ */ u(oe, {
1912
+ form: L.form,
1913
+ onReset: ce
1914
+ })]
1915
+ });
1916
+ }
1917
+ //#endregion
1918
+ //#region src/toggle-button-select/ToggleButtonInput.tsx
1919
+ function he({ autoComplete: e, autoFocus: t, className: n, customization: r, disabled: i, form: a, id: s, multiple: c, name: l, onValueToggle: p, options: m, value: h, required: g, style: _, tabIndex: v, title: y, ref: b, ...x }) {
1920
+ let S = r?.classNamePrefix ?? "super-select", C = S.length > 0 ? `${S}__` : "", w = o(() => new Set(h), [h]), T = o(() => m.find((e) => e.hidden) ? m.filter((e) => !e.hidden) : m, [m]), E = o(() => {
1921
+ if (t) return T.find((e) => !(i || e.disabled))?.value;
1922
+ }, [
1923
+ t,
1924
+ i,
1925
+ T
1926
+ ]), D = o(() => ge(T), [T]), O = x["aria-label"] ?? l;
1927
+ return /* @__PURE__ */ u("fieldset", {
1928
+ ref: b,
1929
+ ...x,
1930
+ id: s,
1931
+ disabled: i,
1932
+ role: c ? "group" : "radiogroup",
1933
+ "aria-disabled": i || void 0,
1934
+ "aria-required": g || void 0,
1935
+ "aria-label": O,
1936
+ className: f(S, `${C}btn-toolbar`, n),
1937
+ style: _,
1938
+ title: y,
1939
+ tabIndex: v,
1940
+ children: D.map(({ label: t, options: n }) => /* @__PURE__ */ u("div", {
1941
+ className: f(`${C}btn-group`, r?.buttonGroup?.className),
1942
+ style: r?.buttonGroup?.style,
1943
+ children: n.map((t) => {
1944
+ let n = w.has(t.value), o = i || t.disabled, s = c ? "checkbox" : "radio";
1945
+ return /* @__PURE__ */ d("label", {
1946
+ className: f(`${C}btn`, `${C}btn-outline-secondary`, n && `${C}active`, o && `${C}disabled`, r?.button?.className),
1947
+ style: r?.button?.style,
1948
+ children: [/* @__PURE__ */ u("input", {
1949
+ value: t.value,
1950
+ className: `${C}btn-check`,
1951
+ checked: n,
1952
+ autoComplete: e,
1953
+ autoFocus: t.value === E,
1954
+ disabled: o,
1955
+ form: a,
1956
+ name: l,
1957
+ type: s,
1958
+ onChange: () => p(t.value),
1959
+ onClick: (e) => {
1960
+ c || !n || o || (e.preventDefault(), window.setTimeout(() => {
1961
+ p(t.value);
1962
+ }, 0));
1963
+ }
1964
+ }), /* @__PURE__ */ u("span", { children: t.children ?? t.label })]
1965
+ }, t.value);
1966
+ })
1967
+ }, t))
1968
+ });
1969
+ }
1970
+ function ge(e) {
1971
+ let t = [], n;
1972
+ for (let r of e) {
1973
+ let e = r.groupLabel ?? "";
1974
+ if (n && n.label === e) {
1975
+ n.options.push(r);
1976
+ continue;
1977
+ }
1978
+ if (n = t.find((t) => t.label === e), n) {
1979
+ n.options.push(r);
1980
+ continue;
1981
+ }
1982
+ n = {
1983
+ label: e,
1984
+ options: [r]
1985
+ }, t.push(n);
1986
+ }
1987
+ return t;
1988
+ }
1989
+ //#endregion
1990
+ //#region src/toggle-button-select/ToggleButtonSelect.tsx
1991
+ function _e({ autoComplete: e, autoFocus: t, children: n, className: i, customization: f, defaultValue: p, disabled: m, form: h, id: g, multiple: _, name: v, required: y, style: x, tabIndex: S, title: C, value: w, onChange: T, onInput: E, onValueChange: D, onInvalid: O, ref: k, ...A }) {
1992
+ let j = o(() => Y(n), [n]), M = w !== void 0, N = s(p), [P, F] = c(() => {
1993
+ let e = b(M ? w : p);
1994
+ return _ ? e : e.slice(0, 1);
1995
+ }), I = o(() => M ? b(w) : P, [
1996
+ P,
1997
+ M,
1998
+ w
1999
+ ]), L = a(), R = _ ? v : v ?? `_toggle-button-select-${L}`, z = f?.classNamePrefix ?? "super-select", B = z.length > 0 ? `${z}__` : "", V = r((e) => U({
2000
+ id: g,
2001
+ name: v,
2002
+ multiple: _,
2003
+ disabled: m,
2004
+ required: y,
2005
+ value: _ ? e : e[0]
2006
+ }), [
2007
+ g,
2008
+ v,
2009
+ _,
2010
+ y,
2011
+ m
2012
+ ]), H = r((e) => {
2013
+ e.preventDefault(), O && O(re(V(I)));
2014
+ }, [
2015
+ V,
2016
+ O,
2017
+ I
2018
+ ]), ee = r(() => {
2019
+ if (!M) {
2020
+ let e = b(N.current);
2021
+ F(_ ? e : e.slice(0, 1));
2022
+ }
2023
+ }, [M, _]), W = r((e) => {
2024
+ if (m) return;
2025
+ let t;
2026
+ t = _ ? I.includes(e) ? I.filter((t) => t !== e) : [...I, e] : I.includes(e) ? [] : [e], M || F(t);
2027
+ let n = V(t);
2028
+ E && E(ne(n, { data: "" })), T && T(te(n)), D && D(_ ? t : t[0] ?? "");
2029
+ }, [
2030
+ V,
2031
+ m,
2032
+ M,
2033
+ _,
2034
+ T,
2035
+ E,
2036
+ D,
2037
+ I
2038
+ ]), G = !!y, K = f?.component ?? he, q = {
2039
+ ...A,
2040
+ size: void 0
2041
+ }, J = q, ae = ie(V(I), q);
2042
+ return /* @__PURE__ */ d(l, { children: [
2043
+ /* @__PURE__ */ u(K, {
2044
+ ...J,
2045
+ ...ae,
2046
+ autoComplete: e,
2047
+ autoFocus: t,
2048
+ className: i,
2049
+ customization: f,
2050
+ disabled: m,
2051
+ form: h,
2052
+ id: g,
2053
+ multiple: _,
2054
+ name: R,
2055
+ value: I,
2056
+ onValueToggle: W,
2057
+ options: j,
2058
+ required: y,
2059
+ style: x,
2060
+ tabIndex: S,
2061
+ title: C,
2062
+ ref: k
2063
+ }),
2064
+ G ? /* @__PURE__ */ u("input", {
2065
+ type: "checkbox",
2066
+ checked: I.length > 0,
2067
+ required: !0,
2068
+ disabled: m,
2069
+ form: h,
2070
+ tabIndex: -1,
2071
+ "aria-hidden": !0,
2072
+ hidden: !0,
2073
+ onChange: () => void 0,
2074
+ onInvalid: H,
2075
+ className: `${B}visually-hidden`
2076
+ }) : null,
2077
+ M ? null : /* @__PURE__ */ u(oe, {
2078
+ form: h,
2079
+ onReset: ee
2080
+ })
2081
+ ] });
2082
+ }
2083
+ //#endregion
2084
+ //#region src/utils/Fallback.tsx
2085
+ function ve({ "aria-busy": e, "aria-describedby": t, "aria-label": n, "aria-labelledby": r, accessKey: i, children: a, className: o, dir: s, hidden: c, id: l, lang: d, style: p, tabIndex: m, title: h, customization: g }) {
2086
+ let _ = g?.classNamePrefix ?? "super-select", v = _.length > 0 ? `${_}__` : "";
2087
+ return /* @__PURE__ */ u("div", {
2088
+ id: l,
2089
+ "aria-busy": e,
2090
+ "aria-describedby": t,
2091
+ "aria-label": n,
2092
+ "aria-labelledby": r,
2093
+ accessKey: i,
2094
+ className: f(`${v}list-group`, o),
2095
+ dir: s,
2096
+ hidden: c,
2097
+ lang: d,
2098
+ style: p,
2099
+ tabIndex: m,
2100
+ title: h,
2101
+ children: /* @__PURE__ */ u("div", {
2102
+ className: `${v}list-group-item`,
2103
+ children: a
2104
+ })
2105
+ });
2106
+ }
2107
+ //#endregion
2108
+ //#region src/SuperSelect.tsx
2109
+ function ye({ mode: e, optionSource: t, customization: n, ref: a, children: p, multiple: m, disabled: h, required: g, value: _, defaultValue: v, onChange: y, onInvalid: x, onValueChange: S, className: C, style: w, ...E }) {
2110
+ let D = typeof e == "function" ? void 0 : e, O = typeof e == "function" ? e : void 0, k = !!t && (!!O || D !== void 0 && !Se(D)), [A, j] = c(0), N = o(() => ({
2111
+ optionSource: t,
2112
+ retryCount: A,
2113
+ shouldLoadOptions: k
2114
+ }), [
2115
+ A,
2116
+ t,
2117
+ k
2118
+ ]), [P, F] = c(() => k ? Ee(N) : we);
2119
+ i(() => {
2120
+ if (!t || !k) return;
2121
+ let e = new AbortController(), n = !1;
2122
+ return Promise.resolve().then(() => {
2123
+ if (!(n || e.signal.aborted)) return F(Ee(N)), t.getOptionPage({ signal: e.signal });
2124
+ }).then((t) => {
2125
+ !t || n || e.signal.aborted || F({
2126
+ loadKey: N,
2127
+ options: t.options,
2128
+ hasMore: !!t.hasMore,
2129
+ isPending: !1,
2130
+ error: void 0
2131
+ });
2132
+ }).catch((t) => {
2133
+ n || e.signal.aborted || F({
2134
+ loadKey: N,
2135
+ options: [],
2136
+ hasMore: !1,
2137
+ isPending: !1,
2138
+ error: M(t)
2139
+ });
2140
+ }), () => {
2141
+ n = !0, e.abort();
2142
+ };
2143
+ }, [
2144
+ t,
2145
+ N,
2146
+ k
2147
+ ]);
2148
+ let I = o(() => Y(p), [p]), R = we;
2149
+ k && (R = P.loadKey === N ? P : Ee(N));
2150
+ let z = o(() => L(I, R.options), [R.options, I]), B = o(() => {
2151
+ if (D) return D;
2152
+ if (O) {
2153
+ let e = O({
2154
+ options: z,
2155
+ hasMore: R.hasMore,
2156
+ multiple: !!m,
2157
+ disabled: !!h,
2158
+ required: !!g,
2159
+ optionSource: t,
2160
+ error: R.error
2161
+ });
2162
+ if (e) return e;
2163
+ }
2164
+ return "modal";
2165
+ }, [
2166
+ h,
2167
+ z,
2168
+ O,
2169
+ m,
2170
+ t,
2171
+ D,
2172
+ g,
2173
+ R.error,
2174
+ R.hasMore
2175
+ ]), V = _ !== void 0, H = s(v), [ee, W] = c(void 0), [te, ne] = c(0), G = r((e) => {
2176
+ let t = Array.from(e.currentTarget.selectedOptions).map((e) => e?.value ?? ""), n = [];
2177
+ m && t.length > 0 ? n = t : e.currentTarget.value && e.currentTarget.value.length > 0 && (n = [e.currentTarget.value]), V || W(m ? n : n[0] ?? ""), S && S(m ? n : n[0] ?? ""), y && y(e);
2178
+ }, [
2179
+ V,
2180
+ m,
2181
+ y,
2182
+ S
2183
+ ]), K = k && !R.isPending && R.error === void 0 && (!Se(B) || !R.hasMore), ie = t && Se(B) && !K ? t : void 0, q = K ? Ce(p, I, R.options) : p, J = ee === void 0 ? v : ee, X = o(() => {
2184
+ let e = b(V ? _ : J);
2185
+ return m ? e : e.slice(0, 1);
2186
+ }, [
2187
+ J,
2188
+ V,
2189
+ m,
2190
+ _
2191
+ ]), Z = r(() => {
2192
+ j((e) => e + 1);
2193
+ }, []), se = r(() => {
2194
+ V || (W(H.current), ne((e) => e + 1));
2195
+ }, [V]), Q = n?.classNamePrefix ?? "super-select", ce = Q.length > 0 ? `${Q}__` : "", le = n?.fallback?.component ?? ve, ue = n?.pendingIndicator?.component ?? T, $ = n?.errorIndicator?.component ?? ae, de = f(C, n?.fallback?.className), fe = w && n?.fallback?.style ? {
2196
+ ...w,
2197
+ ...n.fallback.style
2198
+ } : w ?? n?.fallback?.style, pe;
2199
+ k && R.isPending ? pe = /* @__PURE__ */ u(ue, {
2200
+ inline: !0,
2201
+ className: n?.pendingIndicator?.className,
2202
+ style: n?.pendingIndicator?.style,
2203
+ title: n?.pendingIndicator?.title,
2204
+ content: n?.pendingIndicator?.content,
2205
+ customization: { classNamePrefix: Q }
2206
+ }) : k && R.error && (pe = /* @__PURE__ */ u($, {
2207
+ className: n?.errorIndicator?.className,
2208
+ style: n?.errorIndicator?.style,
2209
+ error: R.error,
2210
+ message: R.error.userMessage ?? n?.errorIndicator?.defaultMessage,
2211
+ onRetry: Z,
2212
+ customization: {
2213
+ classNamePrefix: Q,
2214
+ icon: n?.errorIndicator?.icon,
2215
+ retryButton: n?.errorIndicator?.retryButton
2216
+ }
2217
+ }));
2218
+ let me = E.name && X.length > 0 ? m ? X.map((e, t) => /* @__PURE__ */ u("input", {
2219
+ type: "hidden",
2220
+ name: E.name,
2221
+ value: e,
2222
+ form: E.form,
2223
+ disabled: h
2224
+ }, `super-select-async-hidden-value-${e}-${t}`)) : /* @__PURE__ */ u("input", {
2225
+ type: "hidden",
2226
+ name: E.name,
2227
+ value: X[0] ?? "",
2228
+ form: E.form,
2229
+ disabled: h
2230
+ }) : null;
2231
+ return pe ? /* @__PURE__ */ d(l, { children: [
2232
+ /* @__PURE__ */ u(le, {
2233
+ id: E.id,
2234
+ "aria-busy": R.isPending || void 0,
2235
+ "aria-describedby": E["aria-describedby"],
2236
+ "aria-label": E["aria-label"],
2237
+ "aria-labelledby": E["aria-labelledby"],
2238
+ accessKey: E.accessKey,
2239
+ className: de,
2240
+ dir: E.dir,
2241
+ hidden: E.hidden,
2242
+ lang: E.lang,
2243
+ style: fe,
2244
+ tabIndex: E.tabIndex,
2245
+ title: E.title,
2246
+ customization: { classNamePrefix: Q },
2247
+ children: pe
2248
+ }),
2249
+ me,
2250
+ g ? /* @__PURE__ */ u("select", {
2251
+ required: !0,
2252
+ disabled: h,
2253
+ form: E.form,
2254
+ multiple: m,
2255
+ value: m ? X : X[0] ?? "",
2256
+ onChange: () => void 0,
2257
+ onInvalid: (e) => {
2258
+ e.preventDefault(), x && x(re(U({
2259
+ id: E.id,
2260
+ name: E.name,
2261
+ value: m ? X : X[0] ?? "",
2262
+ multiple: m,
2263
+ disabled: h,
2264
+ required: g
2265
+ })));
2266
+ },
2267
+ "aria-hidden": !0,
2268
+ tabIndex: -1,
2269
+ className: `${ce}visually-hidden`,
2270
+ children: X.map((e) => /* @__PURE__ */ u("option", {
2271
+ value: e,
2272
+ children: e
2273
+ }, e))
2274
+ }) : null,
2275
+ V ? null : /* @__PURE__ */ u(oe, {
2276
+ form: E.form,
2277
+ onReset: se
2278
+ })
2279
+ ] }) : /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u(be, {
2280
+ ref: a,
2281
+ ...E,
2282
+ mode: B,
2283
+ className: C,
2284
+ style: w,
2285
+ multiple: m,
2286
+ disabled: h,
2287
+ required: g,
2288
+ value: _,
2289
+ defaultValue: V ? void 0 : J,
2290
+ onChange: G,
2291
+ onInvalid: x,
2292
+ optionSource: ie,
2293
+ customization: n,
2294
+ children: q
2295
+ }, te), V ? null : /* @__PURE__ */ u(oe, {
2296
+ form: E.form,
2297
+ onReset: se
2298
+ })] });
2299
+ }
2300
+ function be({ mode: e, onChange: t, optionSource: n, customization: r, children: i, ref: a, ...o }) {
2301
+ let s = r?.classNamePrefix ?? "super-select";
2302
+ if (e === "option-list") return /* @__PURE__ */ u(me, {
2303
+ ref: a,
2304
+ ...o,
2305
+ onChange: t,
2306
+ optionSource: n,
2307
+ customization: r,
2308
+ children: i
2309
+ });
2310
+ if (e === "toggle-button") return /* @__PURE__ */ u(_e, {
2311
+ ref: a,
2312
+ ...o,
2313
+ className: r?.toggleButtonInput?.className ?? o.className,
2314
+ style: o.style && r?.toggleButtonInput?.style ? {
2315
+ ...o.style,
2316
+ ...r.toggleButtonInput.style
2317
+ } : o.style ?? r?.toggleButtonInput?.style,
2318
+ onChange: t,
2319
+ customization: r ? {
2320
+ classNamePrefix: s,
2321
+ ...r.toggleButtonInput
2322
+ } : void 0,
2323
+ children: i
2324
+ });
2325
+ if (e === "native") {
2326
+ let e = s.length > 0 ? `${s}__` : "", n = r?.selectInput?.component ?? xe, c = r?.selectInput?.className ?? o.className;
2327
+ return n === xe && (c = f(`${e}form-select`, c)), /* @__PURE__ */ u(n, {
2328
+ ref: a,
2329
+ ...o,
2330
+ className: c,
2331
+ style: o.style && r?.selectInput?.style ? {
2332
+ ...o.style,
2333
+ ...r.selectInput.style
2334
+ } : o.style ?? r?.selectInput?.style,
2335
+ onChange: t,
2336
+ children: i
2337
+ });
2338
+ }
2339
+ return /* @__PURE__ */ u($, {
2340
+ ref: a,
2341
+ ...o,
2342
+ onChange: t,
2343
+ optionSource: n,
2344
+ customization: r,
2345
+ children: i
2346
+ });
2347
+ }
2348
+ function xe({ ref: e, ...t }) {
2349
+ return /* @__PURE__ */ u("select", {
2350
+ ref: e,
2351
+ ...t
2352
+ });
2353
+ }
2354
+ function Se(e) {
2355
+ return e === "modal" || e === "option-list";
2356
+ }
2357
+ function Ce(t, n, r) {
2358
+ if (r.length === 0) return t;
2359
+ let i = [], a = new Set(n.map((e) => e.value));
2360
+ for (let e of r) a.has(e.value) || (a.add(e.value), i.push(e));
2361
+ if (i.length === 0) return t;
2362
+ let o = [], s = 0, c = 0;
2363
+ for (; s < i.length;) {
2364
+ let e = i[s], t = e.groupLabel;
2365
+ if (!t) {
2366
+ o.push(/* @__PURE__ */ u("option", {
2367
+ value: e.value,
2368
+ disabled: e.disabled,
2369
+ hidden: e.hidden,
2370
+ label: e.label,
2371
+ children: e.children ?? e.label
2372
+ }, `super-select-async-option-${c}-${e.value}`)), s += 1, c += 1;
2373
+ continue;
2374
+ }
2375
+ let n = [];
2376
+ for (; s < i.length && i[s].groupLabel === t;) n.push(i[s]), s += 1, c += 1;
2377
+ o.push(/* @__PURE__ */ u("optgroup", {
2378
+ label: t,
2379
+ children: n.map((e, t) => /* @__PURE__ */ u("option", {
2380
+ value: e.value,
2381
+ disabled: e.disabled,
2382
+ hidden: e.hidden,
2383
+ label: e.label,
2384
+ children: e.children ?? e.label
2385
+ }, `super-select-async-group-option-${c}-${t}-${e.value}`))
2386
+ }, `super-select-async-group-${c}-${t}`));
2387
+ }
2388
+ if (!t) return o;
2389
+ let l = e.toArray(t);
2390
+ return l.length === 0 ? o : [...l, ...o];
2391
+ }
2392
+ var we = {
2393
+ options: [],
2394
+ hasMore: !1,
2395
+ isPending: !1,
2396
+ error: void 0
2397
+ }, Te = {
2398
+ options: [],
2399
+ hasMore: !1,
2400
+ isPending: !0,
2401
+ error: void 0
2402
+ };
2403
+ function Ee(e) {
2404
+ return {
2405
+ ...Te,
2406
+ loadKey: e
2407
+ };
2408
+ }
2409
+ //#endregion
2410
+ export { p as CloseButton, _ as EmptyIndicator, ae as ErrorIndicator, ve as Fallback, m as Modal, $ as ModalSelect, Q as ModalSelectButton, y as MoreIndicator, le as OkButton, pe as OptionList, x as OptionListInput, me as OptionListSelect, N as OptionSource, k as OptionSourceError, T as PendingIndicator, E as SearchInput, ue as SelectedContent, ye as SuperSelect, he as ToggleButtonInput, _e as ToggleButtonSelect, M as convertToOptionSourceError, P as createOptionSource, A as isOptionSourceErrorLike };