kosmio 0.1.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,3468 @@
1
+ import { jsx as a, jsxs as M, Fragment as xt } from "react/jsx-runtime";
2
+ import { forwardRef as te, useContext as Pe, createContext as Me, Children as rt, isValidElement as Re, useState as K, useId as Be, useRef as ee, useEffect as j, cloneElement as ot, useMemo as Z, useCallback as X, Fragment as Nt } from "react";
3
+ import { c as V } from "./classNames-CcykAxZN.js";
4
+ import { useTranslation as ce } from "react-i18next";
5
+ import { b as _e, u as st, e as it, d as kt, c as Ye } from "./ViewportContext-z-ZwlTIZ.js";
6
+ import { createPortal as at } from "react-dom";
7
+ import { r as Ct, d as St, s as Tt } from "./shortcuts-n31uRPcv.js";
8
+ import { b as Le } from "./offlineWriteQueue-C31IjyB_.js";
9
+ const Ne = {
10
+ start: "kosmio-text-align-start",
11
+ center: "kosmio-text-align-center",
12
+ end: "kosmio-text-align-end",
13
+ left: "kosmio-text-align-left",
14
+ right: "kosmio-text-align-right",
15
+ justify: "kosmio-text-align-justify"
16
+ }, wt = {
17
+ 1: "t-color-1",
18
+ 2: "t-color-2",
19
+ 3: "t-color-3"
20
+ }, Et = {
21
+ 1: "t-color-d1",
22
+ 2: "t-color-d2",
23
+ 3: "t-color-d3"
24
+ }, At = {
25
+ xxxl: "text-xxxl",
26
+ xxl: "text-xxl",
27
+ xl: "text-xl",
28
+ lg: "text-lg",
29
+ md: "text-md",
30
+ sm: "text-sm",
31
+ xs: "text-xs",
32
+ xxs: "text-xxs"
33
+ }, Lt = {
34
+ default: "text-font-default",
35
+ main: "text-font-main",
36
+ mono: "text-font-mono"
37
+ }, It = {
38
+ regular: "text-weight-regular",
39
+ medium: "text-weight-medium",
40
+ semibold: "text-weight-semibold",
41
+ bold: "text-weight-bold"
42
+ }, Dt = {
43
+ none: "text-leading-none",
44
+ tight: "text-leading-tight",
45
+ normal: "text-leading-normal",
46
+ relaxed: "text-leading-relaxed"
47
+ };
48
+ function zt(e, t) {
49
+ if (t == null || t === "") return;
50
+ const n = String(t);
51
+ return n.startsWith("var(") ? n : n.startsWith("--") ? `var(${n})` : `var(--kosmio-${e}-${n})`;
52
+ }
53
+ function Ot(e) {
54
+ return typeof e == "string" && (e.startsWith("var(") || e.startsWith("--"));
55
+ }
56
+ function pe(e, t, n = "") {
57
+ if (e == null || e === "") return "";
58
+ const r = t[e];
59
+ return r || (typeof e == "string" && n && e.startsWith(n) ? e : "");
60
+ }
61
+ function $t(e) {
62
+ return e ? pe(e, Ne, "kosmio-text-align-") : "";
63
+ }
64
+ function Ft({ left: e, center: t, right: n }) {
65
+ return t ? Ne.center : n ? Ne.right : e ? Ne.left : "";
66
+ }
67
+ function lt(e, t, n, r) {
68
+ return V(
69
+ pe(e, Lt, "text-font-"),
70
+ pe(t, It, "text-weight-"),
71
+ pe(n, At, "text-"),
72
+ pe(r, Dt, "text-leading-")
73
+ );
74
+ }
75
+ function He(e, t, n, r) {
76
+ const {
77
+ font: s = "default",
78
+ fontSize: o,
79
+ fontColor: i,
80
+ weight: l,
81
+ lineHeight: u,
82
+ as: d
83
+ } = e ?? {}, h = t ?? d, m = n ?? i, c = lt(s, l, o, u), y = te(function({
84
+ className: v,
85
+ ...x
86
+ }, C) {
87
+ return /* @__PURE__ */ a(
88
+ q,
89
+ {
90
+ ref: C,
91
+ as: h,
92
+ color: m,
93
+ ...x,
94
+ className: V(c, r, v)
95
+ }
96
+ );
97
+ });
98
+ return y.defaultPropsConfig = {
99
+ typoStyle: e,
100
+ as: h,
101
+ color: m,
102
+ className: r
103
+ }, y;
104
+ }
105
+ function vr(e = []) {
106
+ return e.map((t) => {
107
+ if (Array.isArray(t)) {
108
+ const [n, r, s] = t;
109
+ return He(n, void 0, r, s);
110
+ }
111
+ return He(t);
112
+ });
113
+ }
114
+ function Pt(e, t) {
115
+ if (e == null || Ot(e)) return "";
116
+ const r = (t ? Et : wt)[e];
117
+ return r || (t && typeof e == "string" && e.startsWith("t-color-") && !e.startsWith("t-color-d") ? e.replace("t-color-", "t-color-d") : typeof e == "string" && e.startsWith("t-color-") ? e : "");
118
+ }
119
+ const q = te(function({
120
+ as: t = "p",
121
+ color: n,
122
+ dynamic: r = !1,
123
+ size: s = "",
124
+ font: o = "",
125
+ weight: i,
126
+ lineHeight: l = "",
127
+ align: u,
128
+ left: d = !1,
129
+ center: h = !1,
130
+ right: m = !1,
131
+ inline: c = !1,
132
+ ellipsis: y = !1,
133
+ elipsis: b = !1,
134
+ className: v = "",
135
+ style: x,
136
+ children: C,
137
+ ...p
138
+ }, A) {
139
+ const N = t, k = lt(o, i, s, l), f = $t(u), g = Pt(n, r), S = g ? void 0 : zt("color", n), L = y || b, T = u ? "" : Ft({ left: d, center: h, right: m }), Y = {
140
+ ...S ? { "--kosmio-text-color": S } : {}
141
+ };
142
+ return /* @__PURE__ */ a(
143
+ N,
144
+ {
145
+ ref: A,
146
+ className: V(
147
+ "kosmio-text text",
148
+ k,
149
+ f,
150
+ g,
151
+ S && "kosmio-text-colored",
152
+ T,
153
+ c && "kosmio-text-inline text-inline",
154
+ L && "kosmio-text-ellipsis text-elipsis",
155
+ v
156
+ ),
157
+ style: {
158
+ ...Y,
159
+ ...x
160
+ },
161
+ ...p,
162
+ children: C
163
+ }
164
+ );
165
+ }), Mt = {
166
+ plain: "",
167
+ primary: "kosmio-button-primary primary",
168
+ searchFilter: "searchbar-filter",
169
+ searchAdd: "kosmio-button-primary primary searchbar-add"
170
+ }, Ge = (e) => e === "a", Rt = te(function({
171
+ as: t = "button",
172
+ variant: n = "plain",
173
+ danger: r = !1,
174
+ active: s = !0,
175
+ showTooltip: o = !1,
176
+ tooltipText: i = "",
177
+ tooltipDirection: l = "right",
178
+ className: u = "",
179
+ type: d,
180
+ disabled: h = !1,
181
+ onClick: m,
182
+ ...c
183
+ }, y) {
184
+ const b = t, v = Mt[n] ?? n, x = l === "left" ? "left" : "right", C = i || (typeof c["aria-label"] == "string" ? c["aria-label"] : ""), p = V(
185
+ "kosmio-button custom-button",
186
+ v,
187
+ r && "kosmio-button-danger danger",
188
+ s && "kosmio-button-active active",
189
+ o && `kosmio-button-tooltip tooltip tooltip-${x}`,
190
+ u
191
+ );
192
+ return /* @__PURE__ */ a(
193
+ b,
194
+ {
195
+ ref: y,
196
+ className: p,
197
+ onClick: (N) => {
198
+ if (h && Ge(t)) {
199
+ N.preventDefault();
200
+ return;
201
+ }
202
+ m?.(N);
203
+ },
204
+ ...o ? { "data-tooltip": C } : {},
205
+ ...Ge(t) ? {
206
+ "aria-disabled": h || void 0,
207
+ tabIndex: h ? -1 : c.tabIndex
208
+ } : {
209
+ type: d ?? "button",
210
+ disabled: h
211
+ },
212
+ ...c
213
+ }
214
+ );
215
+ });
216
+ function xr({
217
+ variant: e = "plain",
218
+ text: t,
219
+ icon: n,
220
+ iconPosition: r = "start",
221
+ onClick: s,
222
+ tooltipText: o,
223
+ className: i = "",
224
+ danger: l = !1,
225
+ ...u
226
+ }) {
227
+ const d = u["aria-label"] ?? (typeof t == "string" ? t : void 0), h = n ? /* @__PURE__ */ a("span", { className: "kosmio-action-button-icon", children: n }) : null;
228
+ return /* @__PURE__ */ M(
229
+ Rt,
230
+ {
231
+ variant: e,
232
+ onClick: s,
233
+ "aria-label": d,
234
+ showTooltip: !!o,
235
+ tooltipText: o,
236
+ className: `kosmio-action-button ${i}`.trim(),
237
+ danger: l,
238
+ ...u,
239
+ children: [
240
+ r === "start" ? h : null,
241
+ t ? /* @__PURE__ */ a(q, { as: "span", size: "sm", children: t }) : null,
242
+ r === "end" ? h : null
243
+ ]
244
+ }
245
+ );
246
+ }
247
+ const Bt = {
248
+ default: "kosmio-icon icon dynamic-theme",
249
+ static: "kosmio-icon icon static-theme",
250
+ reversed: "kosmio-icon icon reversed-theme",
251
+ reversedDynamic: "kosmio-icon icon reversed-dynamic-theme",
252
+ accent: "kosmio-icon icon accent-theme",
253
+ invalid: "kosmio-icon icon invalid"
254
+ }, _t = {
255
+ xs: "kosmio-icon-size-xs icon-size-xs",
256
+ sm: "kosmio-icon-size-sm icon-size-sm",
257
+ md: "kosmio-icon-size-md icon-size-md",
258
+ xmd: "kosmio-icon-size-xmd icon-size-xmd",
259
+ lg: "kosmio-icon-size-lg icon-size-lg",
260
+ xl: "kosmio-icon-size-xl icon-size-xl",
261
+ xxl: "kosmio-icon-size-xxl icon-size-xxl",
262
+ xxxl: "kosmio-icon-size-xxxl icon-size-xxxl"
263
+ }, fe = te(function({
264
+ src: t,
265
+ variant: n = "default",
266
+ size: r,
267
+ className: s = "",
268
+ alt: o = "",
269
+ decorative: i = !1,
270
+ style: l,
271
+ ...u
272
+ }, d) {
273
+ const h = Bt[n] ?? n, m = _t[r];
274
+ return typeof t == "string" && t.endsWith(".svg") && n !== "static" ? /* @__PURE__ */ a(
275
+ "span",
276
+ {
277
+ ref: d,
278
+ className: V(h, m, "kosmio-icon-mask icon-mask", s),
279
+ role: i ? void 0 : "img",
280
+ "aria-label": i ? void 0 : o,
281
+ "aria-hidden": i || void 0,
282
+ style: {
283
+ "--kosmio-icon-url": `url("${t}")`,
284
+ "--icon-url": `url("${t}")`,
285
+ ...l
286
+ },
287
+ ...u
288
+ }
289
+ ) : /* @__PURE__ */ a(
290
+ "img",
291
+ {
292
+ ref: d,
293
+ className: V(h, m, s),
294
+ src: t,
295
+ alt: i ? "" : o,
296
+ "aria-hidden": i || void 0,
297
+ style: l,
298
+ ...u
299
+ }
300
+ );
301
+ }), ct = Me({
302
+ icons: {},
303
+ defaultVariant: "default"
304
+ });
305
+ function qt(e, t, n) {
306
+ return t ?? (e.alt != null ? e.alt : e.altKey ? n(e.altKey) : "");
307
+ }
308
+ function Nr({ icons: e = {}, defaultVariant: t = "default", children: n }) {
309
+ return /* @__PURE__ */ a(ct.Provider, { value: { icons: e, defaultVariant: t }, children: n });
310
+ }
311
+ function Vt() {
312
+ return Pe(ct);
313
+ }
314
+ function ut({
315
+ name: e,
316
+ size: t,
317
+ variant: n,
318
+ alt: r,
319
+ decorative: s = !1,
320
+ ...o
321
+ }) {
322
+ const { t: i } = ce(), { icons: l, defaultVariant: u } = Vt(), d = l?.[e];
323
+ return d ? /* @__PURE__ */ a(
324
+ fe,
325
+ {
326
+ src: d.src,
327
+ size: t ?? d.size,
328
+ variant: n ?? d.variant ?? u,
329
+ alt: s ? "" : qt(d, r, i),
330
+ decorative: s,
331
+ ...o
332
+ }
333
+ ) : null;
334
+ }
335
+ function kr({
336
+ id: e,
337
+ title: t = "forms.shared.actionFormTitle",
338
+ picture: n = null,
339
+ type: r = "short-form",
340
+ buildActions: s = null,
341
+ actions: o = []
342
+ }) {
343
+ return {
344
+ id: e,
345
+ title: t,
346
+ picture: n,
347
+ type: r,
348
+ buildActions: s,
349
+ actions: o
350
+ };
351
+ }
352
+ function Yt(e, t, n) {
353
+ return e ? typeof e.buildActions == "function" ? e.buildActions(t, n) ?? [] : Array.isArray(e.actions) && e.actions.length > 0 ? e.actions : Array.isArray(t?.actions) ? t.actions : [] : [];
354
+ }
355
+ function Cr(e = null, t = []) {
356
+ return {
357
+ context: e,
358
+ actions: t
359
+ };
360
+ }
361
+ function Sr({
362
+ actions: e,
363
+ context: t,
364
+ formName: n,
365
+ getForm: r,
366
+ resolveActions: s = Yt
367
+ }) {
368
+ const { t: o } = ce(), { form: i, formAction: l, formObject: u, openForm: d, setAdvancedForm: h, closeForm: m } = _e(), y = typeof r == "function" ? r(n ?? i, l) : null, b = u ?? null, v = t ?? b?.context ?? b ?? null, x = Array.isArray(e) ? e : s(y, b, {
369
+ openForm: d,
370
+ setAdvancedForm: h,
371
+ closeForm: m,
372
+ context: v,
373
+ t: o
374
+ });
375
+ return /* @__PURE__ */ a("form", { className: "full-view column-left actions-form", children: /* @__PURE__ */ a("div", { className: "full-view column-left", children: x.map((C, p) => {
376
+ const {
377
+ label: A,
378
+ icon: N,
379
+ iconName: k,
380
+ iconVariant: f,
381
+ onClick: g,
382
+ color: S,
383
+ disabled: L
384
+ } = C ?? {}, T = typeof A == "function" ? A(v) : A, Y = typeof L == "function" ? L(v) : !!L, z = o(T);
385
+ return z ? /* @__PURE__ */ M(
386
+ "button",
387
+ {
388
+ className: `actions-form-option ${S || ""}`.trim(),
389
+ disabled: Y,
390
+ onClick: (_) => {
391
+ _.preventDefault(), !Y && g?.(v);
392
+ },
393
+ children: [
394
+ k ? /* @__PURE__ */ a(ut, { name: k, alt: z }) : null,
395
+ !k && N ? /* @__PURE__ */ a(fe, { src: N, alt: z, variant: f ?? "reversedDynamic" }) : null,
396
+ /* @__PURE__ */ a(q, { as: "p", size: "xs", dynamic: !0, color: 2, className: "select-sheet-label", children: z })
397
+ ]
398
+ },
399
+ `${T}-${p}`
400
+ ) : null;
401
+ }) }) });
402
+ }
403
+ function Ht({ className: e = "", label: t = "", onClick: n, style: r, ...s }) {
404
+ return /* @__PURE__ */ a(
405
+ "button",
406
+ {
407
+ type: "button",
408
+ className: V("kosmio-backdrop", e),
409
+ "aria-hidden": t ? void 0 : "true",
410
+ "aria-label": t || void 0,
411
+ onClick: n,
412
+ style: r,
413
+ tabIndex: t ? void 0 : -1,
414
+ ...s
415
+ }
416
+ );
417
+ }
418
+ function Tr({ children: e, className: t = "", ...n }) {
419
+ return /* @__PURE__ */ a("div", { className: V("kosmio-card card", t), ...n, children: e });
420
+ }
421
+ function Gt(e = 0) {
422
+ const t = e * 45;
423
+ return {
424
+ "--motion-row-delay": `${t}ms`,
425
+ opacity: 0,
426
+ animationName: "motion-row-appear",
427
+ animationDuration: "360ms",
428
+ animationDelay: `${t}ms`,
429
+ animationTimingFunction: "cubic-bezier(0.22, 1, 0.36, 1)",
430
+ animationFillMode: "forwards",
431
+ willChange: "transform, opacity"
432
+ };
433
+ }
434
+ function wr({ children: e }) {
435
+ return rt.map(e, (t, n) => Re(t) ? /* @__PURE__ */ a("div", { className: "full-w", style: Gt(n), children: t }, t.key ?? n) : t);
436
+ }
437
+ const Xt = {
438
+ plain: "",
439
+ custom: "customCheckbox-input"
440
+ }, jt = te(function({
441
+ variant: t = "plain",
442
+ className: n = "",
443
+ containerClassName: r = "",
444
+ labelClassName: s = "",
445
+ markClassName: o = "",
446
+ textClassName: i = "",
447
+ label: l,
448
+ checked: u,
449
+ onChange: d,
450
+ onCheckedChange: h,
451
+ ...m
452
+ }, c) {
453
+ const y = Xt[t] ?? t, b = (v) => {
454
+ d?.(v), h?.(v.target.checked, v);
455
+ };
456
+ return /* @__PURE__ */ M(q, { className: V(r, s), as: "label", children: [
457
+ /* @__PURE__ */ a("input", { ref: c, type: "checkbox", className: V(y, n), checked: u, onChange: b, ...m }),
458
+ o ? /* @__PURE__ */ a("span", { className: o }) : null,
459
+ l ? /* @__PURE__ */ a(q, { className: i, as: "span", children: l }) : null
460
+ ] });
461
+ }), Wt = te(function({ className: t = "", type: n = "button", disabled: r = !1, children: s, ...o }, i) {
462
+ return /* @__PURE__ */ a(
463
+ "button",
464
+ {
465
+ ref: i,
466
+ type: n,
467
+ className: V("kosmio-clickable", t),
468
+ disabled: r,
469
+ ...o,
470
+ children: s
471
+ }
472
+ );
473
+ });
474
+ function Er({ titleBox: e, children: t, className: n = "", defaultExpanded: r = !0 }) {
475
+ const [s, o] = K(r), i = Be(), l = typeof e == "function" ? e(s) : e;
476
+ return /* @__PURE__ */ M("div", { className: `collapsible-box full-w ${s ? "is-expanded" : "is-collapsed"} ${n}`.trim(), children: [
477
+ /* @__PURE__ */ a(
478
+ Wt,
479
+ {
480
+ type: "button",
481
+ className: "flex full-w row-left collapsible-box-trigger",
482
+ onClick: () => o((u) => !u),
483
+ "aria-expanded": s,
484
+ "aria-controls": i,
485
+ children: l
486
+ }
487
+ ),
488
+ /* @__PURE__ */ a("div", { id: i, className: "collapsible-box-content flex full-w column-left", children: t })
489
+ ] });
490
+ }
491
+ function Ar({ title: e, children: t, className: n = "", defaultExpanded: r = !0 }) {
492
+ const [s, o] = K(r), i = Be();
493
+ return /* @__PURE__ */ M("div", { className: `collapsible-card ${s ? "is-expanded" : "is-collapsed"} ${n}`.trim(), children: [
494
+ /* @__PURE__ */ M(
495
+ "button",
496
+ {
497
+ type: "button",
498
+ className: "card-title spaced collapsible-card-trigger",
499
+ onClick: () => o((l) => !l),
500
+ "aria-expanded": s,
501
+ "aria-controls": i,
502
+ children: [
503
+ /* @__PURE__ */ a(q, { as: "span", size: "xs", color: 3, children: e }),
504
+ /* @__PURE__ */ a("span", { className: "collapsible-card-chevron", "aria-hidden": "true" })
505
+ ]
506
+ }
507
+ ),
508
+ /* @__PURE__ */ M("div", { id: i, className: "collapsible-card-content flex full-w column-left", children: [
509
+ /* @__PURE__ */ a("span", { className: "card-divider full-w divider" }),
510
+ /* @__PURE__ */ a("div", { className: "card-content full-w", children: t })
511
+ ] })
512
+ ] });
513
+ }
514
+ function Qt(e) {
515
+ if (e)
516
+ return e.size === "0px" ? "none" : `${e.size} solid ${e.color}`;
517
+ }
518
+ function Kt(e, t) {
519
+ if (t == null || t === "") return;
520
+ const n = String(t);
521
+ return n.startsWith("var(") ? n : n.startsWith("--") ? `var(${n})` : `var(--kosmio-${e}-${n})`;
522
+ }
523
+ function Ut(e, t) {
524
+ if (!e) return t;
525
+ const n = {
526
+ "--kosmio-container-background": e.backgroundColor,
527
+ "--kosmio-container-border": Qt(e.borderStyle),
528
+ "--kosmio-container-padding": e.padding,
529
+ "--kosmio-container-radius": e.radii,
530
+ "--kosmio-container-color": Kt("color", e.typoStyle?.fontColor),
531
+ ...t
532
+ };
533
+ return Object.keys(n).forEach((r) => {
534
+ (n[r] == null || n[r] === "") && delete n[r];
535
+ }), n;
536
+ }
537
+ const Jt = te(function({
538
+ as: t,
539
+ containerStyle: n,
540
+ children: r,
541
+ className: s = "",
542
+ style: o,
543
+ ...i
544
+ }, l) {
545
+ const u = t ?? n?.typoStyle?.as ?? "div";
546
+ return /* @__PURE__ */ a(
547
+ u,
548
+ {
549
+ ref: l,
550
+ className: V("kosmio-container kosmio-card card", s),
551
+ style: Ut(n, o),
552
+ ...i,
553
+ children: r
554
+ }
555
+ );
556
+ });
557
+ function Xe(e, t, n) {
558
+ const r = t ?? e?.typoStyle?.as ?? "div", s = te(function({
559
+ className: i,
560
+ ...l
561
+ }, u) {
562
+ return /* @__PURE__ */ a(
563
+ Jt,
564
+ {
565
+ ref: u,
566
+ as: r,
567
+ containerStyle: e,
568
+ className: V(n, i),
569
+ ...l
570
+ }
571
+ );
572
+ });
573
+ return s.defaultPropsConfig = { containerStyle: e, as: r, className: n }, s;
574
+ }
575
+ function Lr(e = []) {
576
+ return e.map((t) => {
577
+ if (Array.isArray(t)) {
578
+ const [n, r, s] = t;
579
+ return Xe(n, r, s);
580
+ }
581
+ return Xe(t);
582
+ });
583
+ }
584
+ const Ir = te(function({
585
+ icon: t,
586
+ label: n,
587
+ compact: r = !1,
588
+ className: s = "",
589
+ type: o = "button",
590
+ children: i,
591
+ ...l
592
+ }, u) {
593
+ return /* @__PURE__ */ a(
594
+ "button",
595
+ {
596
+ ref: u,
597
+ type: o,
598
+ className: V("kosmio-floating-action-button", r && "is-compact", s),
599
+ "aria-label": n,
600
+ title: n,
601
+ ...l,
602
+ children: t ? /* @__PURE__ */ a("span", { className: "kosmio-floating-action-button-icon", children: t }) : i
603
+ }
604
+ );
605
+ }), Dr = te(function({
606
+ icon: t,
607
+ title: n,
608
+ subtitle: r,
609
+ selectedLabel: s,
610
+ isSelectable: o = !0,
611
+ isSelected: i = !1,
612
+ className: l = "",
613
+ disabled: u = !1,
614
+ onClick: d,
615
+ ...h
616
+ }, m) {
617
+ const c = u || !o || !d;
618
+ return /* @__PURE__ */ M(
619
+ "button",
620
+ {
621
+ ref: m,
622
+ type: "button",
623
+ className: V(
624
+ "kosmio-selection-button selection-button",
625
+ i && "is-selected",
626
+ !o && "is-not-selectable",
627
+ l
628
+ ),
629
+ "aria-current": i ? "true" : void 0,
630
+ disabled: c,
631
+ onClick: c ? void 0 : d,
632
+ ...h,
633
+ children: [
634
+ t ? /* @__PURE__ */ a("span", { className: "flex-center", children: t }) : null,
635
+ /* @__PURE__ */ M("span", { className: "column-left", children: [
636
+ /* @__PURE__ */ a(q, { as: "span", size: "xs", elipsis: !0, left: !0, children: n }),
637
+ r ? /* @__PURE__ */ a(q, { as: "span", size: "xxs", color: 3, left: !0, dynamic: !0, elipsis: !0, children: r }) : null
638
+ ] }),
639
+ i && s ? /* @__PURE__ */ a(q, { as: "span", size: "xxs", color: 3, left: !0, dynamic: !0, children: s }) : null
640
+ ]
641
+ }
642
+ );
643
+ });
644
+ function zr({
645
+ children: e,
646
+ minColumnWidth: t = 150,
647
+ maxColumns: n,
648
+ gap: r = 10,
649
+ padding: s = 10,
650
+ className: o = "",
651
+ staggerMs: i = 50,
652
+ maxStaggerMs: l = 1e3,
653
+ ...u
654
+ }) {
655
+ const d = ee(null), [h, m] = K(null);
656
+ j(() => {
657
+ const y = () => {
658
+ if (!d.current) return;
659
+ const b = d.current.offsetWidth;
660
+ let v = Math.floor((b + r) / (t + r));
661
+ n && (v = Math.min(v, n)), m(Math.max(v, 1));
662
+ };
663
+ return y(), window.addEventListener("resize", y), () => window.removeEventListener("resize", y);
664
+ }, [t, n, r]);
665
+ const c = {
666
+ gridTemplateColumns: `repeat(${h ?? 1}, 1fr)`,
667
+ gap: `${r}px`,
668
+ padding: `${s}px`
669
+ };
670
+ return /* @__PURE__ */ a("div", { ref: d, className: `kosmio-grid ${o}`.trim(), style: c, ...u, children: h == null ? null : rt.map(e, (y, b) => {
671
+ if (!Re(y)) return y;
672
+ const v = b % h, x = Math.floor(b / h), C = Math.min((x + v) * i, l), p = y.props?.style || {};
673
+ return ot(y, {
674
+ "data-grid-index": b,
675
+ "data-grid-columns": h,
676
+ style: {
677
+ ...p,
678
+ "--kosmio-motion-delay": `${C}ms`
679
+ }
680
+ });
681
+ }) });
682
+ }
683
+ const je = {
684
+ xxs: { closed: "-2px", open: "-1px", size: "xs" },
685
+ xs: { closed: "-2px", open: "-1px" },
686
+ sm: { closed: "-2px", open: "-1px" },
687
+ md: { closed: "-2px", open: "-1px" },
688
+ xmd: { closed: "-3px", open: "-1px" },
689
+ lg: { closed: "-3px", open: "-1px" },
690
+ xl: { closed: "-4px", open: "-2px" },
691
+ xxl: { closed: "-5px", open: "-2px" },
692
+ xxxl: { closed: "-8px", open: "-4px" }
693
+ };
694
+ function Zt({ colored: e = !1, size: t = "xs", isOpen: n = !1, className: r = "", style: s = {}, ...o }) {
695
+ const i = je[t] ?? je.xs, l = i.size ?? t;
696
+ return /* @__PURE__ */ a(
697
+ "span",
698
+ {
699
+ className: V(
700
+ "kosmio-icon-chevron icon-chevron",
701
+ `kosmio-icon-size-${l}`,
702
+ `icon-size-${l}`,
703
+ n && "is-open",
704
+ e && "colored",
705
+ r
706
+ ),
707
+ style: {
708
+ "--kosmio-icon-chevron-closed-shift": i.closed,
709
+ "--kosmio-icon-chevron-open-shift": i.open,
710
+ "--icon-chevron-closed-shift": i.closed,
711
+ "--icon-chevron-open-shift": i.open,
712
+ ...s
713
+ },
714
+ "aria-hidden": "true",
715
+ ...o
716
+ }
717
+ );
718
+ }
719
+ const en = {
720
+ plain: "",
721
+ custom: "customInput",
722
+ search: "searchbar-input"
723
+ }, tn = te(function({
724
+ variant: t = "plain",
725
+ className: n = "",
726
+ format: r,
727
+ isValid: s,
728
+ onChange: o,
729
+ onValueChange: i,
730
+ ...l
731
+ }, u) {
732
+ const d = en[t] ?? t, h = (c) => {
733
+ if (!r || c === "")
734
+ return !0;
735
+ if (r instanceof RegExp)
736
+ return r.lastIndex = 0, r.test(c);
737
+ try {
738
+ return new RegExp(r).test(c);
739
+ } catch {
740
+ return !0;
741
+ }
742
+ }, m = (c) => {
743
+ const y = c.target.value;
744
+ h(y) && (typeof s == "function" && !s(y, c) || (o?.(c), i?.(y, c)));
745
+ };
746
+ return /* @__PURE__ */ a(
747
+ "input",
748
+ {
749
+ ref: u,
750
+ className: `${V(d, n)} form-field`,
751
+ onChange: m,
752
+ ...l
753
+ }
754
+ );
755
+ });
756
+ function nn({
757
+ option: e,
758
+ selected: t = !1,
759
+ onSelect: n,
760
+ renderIcon: r,
761
+ className: s = ""
762
+ }) {
763
+ const o = e?.label ?? e?.value ?? "", i = e?.icon, l = e?.iconName, u = e?.iconVariant ?? "default", d = e?.iconSize ?? "xl", h = e?.className ?? "", m = (y) => {
764
+ n?.(e, y);
765
+ }, c = r?.(e);
766
+ return /* @__PURE__ */ M("button", { type: "button", className: V("card column gap20 enum-option", t && "is-selected", h, s), "aria-pressed": t, onClick: m, children: [
767
+ c ?? (!l && i ? /* @__PURE__ */ a(fe, { src: i, alt: o, variant: u, size: d }) : null),
768
+ /* @__PURE__ */ a(q, { className: "enum-option-label", as: "span", size: "sm", children: o })
769
+ ] });
770
+ }
771
+ const rn = (e) => typeof e == "string" || typeof e == "number", We = (e) => rn(e) ? { value: e } : e && typeof e == "object" && "value" in e ? e : null;
772
+ function on(e) {
773
+ return Array.isArray(e) ? e.map(We).filter(Boolean) : !e || typeof e != "object" ? [] : Object.values(e).map(We).filter(Boolean);
774
+ }
775
+ function Qe(e, t, n) {
776
+ const r = e(t);
777
+ return r === t ? n : r;
778
+ }
779
+ function sn({
780
+ enumValues: e = [],
781
+ selectedValue: t = null,
782
+ onValueChange: n,
783
+ translationKeyPrefix: r = "",
784
+ getIcon: s,
785
+ getLabel: o,
786
+ renderIcon: i,
787
+ translate: l,
788
+ isOptionVisible: u = () => !0,
789
+ className: d = "",
790
+ optionClassName: h = "",
791
+ ariaLabel: m
792
+ }) {
793
+ const { t: c } = ce(), y = Z(() => {
794
+ const b = l ?? c;
795
+ return on(e).filter((x) => u(x.value, x)).map((x) => {
796
+ const C = String(x.label ?? x.value), p = typeof o == "function" ? o(x.value, b, x) : x.labelKey ? Qe(b, x.labelKey, C) : x.label != null ? x.label : r ? Qe(b, `${r}.${x.value}`, C) : C;
797
+ return {
798
+ ...x,
799
+ value: x.value,
800
+ label: p,
801
+ icon: x.icon ?? (typeof s == "function" ? s(x.value, x) : void 0),
802
+ iconName: x.iconName
803
+ };
804
+ });
805
+ }, [e, s, o, c, u, l, r]);
806
+ return /* @__PURE__ */ a("div", { className: V("enum-selector-grid", d), role: "radiogroup", "aria-label": m, children: y.map((b) => /* @__PURE__ */ a(
807
+ nn,
808
+ {
809
+ option: b,
810
+ selected: String(t) === String(b.value),
811
+ onSelect: () => n?.(b.value, b),
812
+ renderIcon: i,
813
+ className: h
814
+ },
815
+ String(b.value)
816
+ )) });
817
+ }
818
+ function Or({
819
+ label: e,
820
+ checked: t = !1,
821
+ onChange: n,
822
+ required: r = !1,
823
+ className: s = "",
824
+ labelClassName: o = "",
825
+ fieldClassName: i = "",
826
+ disabled: l = !1,
827
+ requiredLabel: u = "Required"
828
+ }) {
829
+ return /* @__PURE__ */ a("div", { className: `form-field customCheckbox ${s}`, children: /* @__PURE__ */ a(jt, { variant: "custom", checked: t, onCheckedChange: n, required: r, disabled: l, className: i, containerClassName: `gap5 center ${o}`, markClassName: "", label: e ? /* @__PURE__ */ M(xt, { children: [
830
+ e,
831
+ r && /* @__PURE__ */ a(q, { className: "form-field-required-text", as: "span", children: u })
832
+ ] }) : null }) });
833
+ }
834
+ const an = te(function({
835
+ label: t,
836
+ placeholder: n = "",
837
+ value: r,
838
+ onChange: s,
839
+ type: o = "text",
840
+ required: i,
841
+ validations: l = {},
842
+ className: u = "",
843
+ labelClassName: d = "",
844
+ fieldClassName: h = "",
845
+ invalid: m = !1,
846
+ invalidLabel: c = "",
847
+ requiredLabel: y = "Required",
848
+ format: b,
849
+ isValid: v,
850
+ onKeyDown: x,
851
+ ...C
852
+ }, p) {
853
+ const A = l.required ?? i, N = {
854
+ ...l,
855
+ required: A
856
+ }, k = r == null || String(r).trim().length === 0;
857
+ return /* @__PURE__ */ M("div", { className: `form-field-container gap5 ${m ? "invalid" : ""} ${u}`, children: [
858
+ t && /* @__PURE__ */ M(q, { className: `form-field-label row-left ${d}`.trim(), as: "label", size: "xxs", children: [
859
+ t,
860
+ A && /* @__PURE__ */ a(q, { className: V("form-field-required-text", k && "empty"), as: "span", children: y })
861
+ ] }),
862
+ /* @__PURE__ */ a(tn, { ref: p, variant: "custom", type: o, placeholder: n, value: r, onValueChange: s, onKeyDown: x, "aria-invalid": m, format: b, isValid: v, ...N, ...C, className: `${h}` }),
863
+ m && c ? /* @__PURE__ */ a(q, { as: "p", size: "xxs", className: "form-field-warning-text", left: !0, children: c }) : null
864
+ ] });
865
+ }), dt = Me(null);
866
+ function Ee() {
867
+ const e = Pe(dt);
868
+ if (!e)
869
+ throw new Error("Select components must be used inside SelectRoot");
870
+ return e;
871
+ }
872
+ function ln() {
873
+ const {
874
+ variantClass: e,
875
+ className: t,
876
+ disabled: n,
877
+ required: r,
878
+ isOpen: s,
879
+ hasValue: o,
880
+ displayLabel: i,
881
+ triggerRef: l,
882
+ forwardedRef: u,
883
+ toggleOpen: d,
884
+ open: h
885
+ } = Ee();
886
+ return /* @__PURE__ */ M(
887
+ "button",
888
+ {
889
+ ref: (c) => {
890
+ if (l.current = c, typeof u == "function") {
891
+ u(c);
892
+ return;
893
+ }
894
+ u && (u.current = c);
895
+ },
896
+ type: "button",
897
+ className: V(
898
+ e,
899
+ t,
900
+ "form-field",
901
+ "select-trigger",
902
+ !o && "placeholder"
903
+ ),
904
+ onClick: () => {
905
+ n || d();
906
+ },
907
+ onKeyDown: (c) => {
908
+ n || ((c.key === "Enter" || c.key === " ") && (c.preventDefault(), d()), c.key === "ArrowDown" && (c.preventDefault(), h()));
909
+ },
910
+ "aria-expanded": s,
911
+ "aria-haspopup": "listbox",
912
+ "aria-controls": "select-overlay-listbox",
913
+ "aria-disabled": n,
914
+ "aria-required": r,
915
+ "aria-placeholder": o ? void 0 : i,
916
+ disabled: n,
917
+ children: [
918
+ /* @__PURE__ */ a("span", { className: "select-trigger-label", children: i }),
919
+ /* @__PURE__ */ a(Zt, { size: "xs", isOpen: s })
920
+ ]
921
+ }
922
+ );
923
+ }
924
+ function ft({
925
+ label: e,
926
+ selected: t = !1,
927
+ className: n = "",
928
+ mobile: r = !1,
929
+ onClick: s
930
+ }) {
931
+ return /* @__PURE__ */ a(
932
+ "button",
933
+ {
934
+ type: "button",
935
+ role: "option",
936
+ "aria-selected": t,
937
+ className: V(
938
+ r ? "sheet-option" : "select-option",
939
+ t && "is-selected",
940
+ n
941
+ ),
942
+ onClick: s,
943
+ children: /* @__PURE__ */ a(
944
+ q,
945
+ {
946
+ as: "span",
947
+ size: "sm",
948
+ className: r ? "sheet-label" : "select-option-label",
949
+ dynamic: !0,
950
+ color: t ? 1 : 3,
951
+ children: e
952
+ }
953
+ )
954
+ }
955
+ );
956
+ }
957
+ function cn() {
958
+ const {
959
+ listboxId: e,
960
+ position: t,
961
+ options: n,
962
+ overlayRef: r,
963
+ currentValue: s,
964
+ handleSelect: o,
965
+ searchable: i,
966
+ searchTerm: l,
967
+ setSearchTerm: u,
968
+ searchIcon: d,
969
+ searchLabel: h,
970
+ emptyLabel: m
971
+ } = Ee();
972
+ return /* @__PURE__ */ a(
973
+ "div",
974
+ {
975
+ ref: r,
976
+ className: V("select-dropdown", "is-open", t.placement === "top" && "is-top"),
977
+ style: {
978
+ left: `${t.left}px`,
979
+ top: `${t.top}px`,
980
+ width: `${t.width}px`
981
+ },
982
+ children: /* @__PURE__ */ M("div", { className: "select-dropdown-panel", children: [
983
+ i ? /* @__PURE__ */ a("div", { className: "select-searchbar-wrap", children: /* @__PURE__ */ M("div", { className: "select-searchbar", children: [
984
+ /* @__PURE__ */ a(
985
+ "input",
986
+ {
987
+ type: "text",
988
+ className: "searchbar-input form-field",
989
+ value: l,
990
+ onChange: (c) => u(c.target.value),
991
+ placeholder: h
992
+ }
993
+ ),
994
+ d ? /* @__PURE__ */ a("span", { className: "select-search-icon", children: d }) : null
995
+ ] }) }) : null,
996
+ /* @__PURE__ */ a("div", { className: "select-dropdown-list", role: "listbox", id: e, children: n.length === 0 ? /* @__PURE__ */ a(q, { as: "p", size: "xs", center: !0, className: "select-empty-state", dynamic: !0, color: 3, children: m }) : n.map((c) => {
997
+ const y = String(c.value) === String(s);
998
+ return /* @__PURE__ */ a(
999
+ ft,
1000
+ {
1001
+ label: c.label,
1002
+ selected: y,
1003
+ className: c.className,
1004
+ onClick: () => o(c.value)
1005
+ },
1006
+ String(c.value)
1007
+ );
1008
+ }) })
1009
+ ] })
1010
+ }
1011
+ );
1012
+ }
1013
+ function un(e) {
1014
+ return e ? Array.from(
1015
+ e.querySelectorAll(
1016
+ 'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])'
1017
+ )
1018
+ ).filter((t) => !t.hasAttribute("disabled") && t.getAttribute("aria-hidden") !== "true") : [];
1019
+ }
1020
+ function dn({
1021
+ enabled: e = !0,
1022
+ initialFocusRef: t,
1023
+ onEnterKeyDown: n,
1024
+ onEscapeKeyDown: r,
1025
+ restoreFocus: s = !0,
1026
+ rootRef: o,
1027
+ trapFocus: i = !1,
1028
+ useCapture: l = !1
1029
+ } = {}) {
1030
+ j(() => {
1031
+ if (!e || typeof document > "u") return;
1032
+ const u = document.activeElement, d = o?.current, h = t?.current;
1033
+ requestAnimationFrame(() => {
1034
+ if (h?.focus) {
1035
+ h.focus();
1036
+ return;
1037
+ }
1038
+ d?.focus?.();
1039
+ });
1040
+ const m = (c) => {
1041
+ if (c.key === "Escape") {
1042
+ r?.(c);
1043
+ return;
1044
+ }
1045
+ if (c.key === "Enter") {
1046
+ n?.(c);
1047
+ return;
1048
+ }
1049
+ if (!i || c.key !== "Tab") return;
1050
+ const y = un(o?.current);
1051
+ if (y.length === 0) {
1052
+ c.preventDefault(), o?.current?.focus?.();
1053
+ return;
1054
+ }
1055
+ const b = y[0], v = y[y.length - 1], x = document.activeElement;
1056
+ if (c.shiftKey && x === b) {
1057
+ c.preventDefault(), v.focus();
1058
+ return;
1059
+ }
1060
+ !c.shiftKey && x === v && (c.preventDefault(), b.focus());
1061
+ };
1062
+ return document.addEventListener("keydown", m, l), () => {
1063
+ document.removeEventListener("keydown", m, l), s && u?.focus && u.focus();
1064
+ };
1065
+ }, [e, t, n, r, s, o, i, l]);
1066
+ }
1067
+ function mt({
1068
+ className: e = "",
1069
+ backdropLabel: t = "",
1070
+ backdropStyle: n,
1071
+ closing: r = !1,
1072
+ centerContent: s = !0,
1073
+ initialFocusRef: o,
1074
+ onBackdropClick: i,
1075
+ onEnterKeyDown: l,
1076
+ onEscapeKeyDown: u,
1077
+ portal: d = !1,
1078
+ portalTarget: h,
1079
+ restoreFocus: m = !0,
1080
+ trapFocus: c = !1,
1081
+ useKeyboardCapture: y = !1,
1082
+ children: b,
1083
+ ...v
1084
+ }) {
1085
+ const x = ee(null);
1086
+ dn({
1087
+ initialFocusRef: o,
1088
+ onEnterKeyDown: l,
1089
+ onEscapeKeyDown: u,
1090
+ rootRef: x,
1091
+ restoreFocus: m,
1092
+ trapFocus: c,
1093
+ useCapture: y
1094
+ });
1095
+ const C = /* @__PURE__ */ M(
1096
+ "div",
1097
+ {
1098
+ ref: x,
1099
+ className: V("kosmio-overlay", r && "is-closing", s && "kosmio-overlay-centered", e),
1100
+ tabIndex: -1,
1101
+ ...v,
1102
+ children: [
1103
+ /* @__PURE__ */ a(Ht, { className: "kosmio-backdrop-animated", label: t, onClick: i, style: n }),
1104
+ /* @__PURE__ */ a("div", { className: V("kosmio-overlay-content", s && "kosmio-overlay-content-centered"), children: b })
1105
+ ]
1106
+ }
1107
+ );
1108
+ if (!d) return C;
1109
+ const p = h ?? (typeof document > "u" ? null : document.body);
1110
+ return p ? at(C, p) : null;
1111
+ }
1112
+ const fn = '[data-no-form-drag="true"]', de = {
1113
+ backdropFade: 0.55,
1114
+ backdropMinOpacity: 0.18,
1115
+ closeDistance: 140,
1116
+ closeOffset: 48,
1117
+ closeVelocity: 0.55
1118
+ }, be = {
1119
+ active: !1,
1120
+ engaged: !1,
1121
+ mode: null,
1122
+ source: null,
1123
+ pointerId: null,
1124
+ startX: 0,
1125
+ startY: 0,
1126
+ startTime: 0
1127
+ };
1128
+ function mn(e) {
1129
+ if (!(e instanceof HTMLElement)) return !1;
1130
+ const { overflowY: t } = window.getComputedStyle(e);
1131
+ return ["auto", "scroll", "overlay"].includes(t) && e.scrollHeight > e.clientHeight + 1;
1132
+ }
1133
+ function hn(e, t) {
1134
+ if (!(e instanceof HTMLElement) || !(t instanceof HTMLElement) || e.closest(fn)) return !1;
1135
+ let n = e;
1136
+ for (; n && n !== t; ) {
1137
+ if (mn(n) && n.scrollTop > 0) return !1;
1138
+ n = n.parentElement;
1139
+ }
1140
+ return !0;
1141
+ }
1142
+ function ve(e) {
1143
+ return e?.[0] ?? null;
1144
+ }
1145
+ function he(e, t, n) {
1146
+ const r = Number.parseFloat(e.getPropertyValue(t));
1147
+ return Number.isFinite(r) ? r : n;
1148
+ }
1149
+ function Ke(e) {
1150
+ if (!(e instanceof HTMLElement)) return de;
1151
+ const t = window.getComputedStyle(e);
1152
+ return {
1153
+ backdropFade: he(t, "--kosmio-sheet-backdrop-drag-fade", de.backdropFade),
1154
+ backdropMinOpacity: he(t, "--kosmio-sheet-backdrop-min-opacity", de.backdropMinOpacity),
1155
+ closeDistance: he(t, "--kosmio-sheet-close-distance", de.closeDistance),
1156
+ closeOffset: he(t, "--kosmio-sheet-close-offset", de.closeOffset),
1157
+ closeVelocity: he(t, "--kosmio-sheet-close-velocity", de.closeVelocity)
1158
+ };
1159
+ }
1160
+ function pn({
1161
+ canStartContentDrag: e = hn,
1162
+ closing: t = !1,
1163
+ containerRef: n,
1164
+ dragZoneRef: r,
1165
+ enableContentDrag: s = !0,
1166
+ isMobile: o = !1,
1167
+ onDragDismiss: i,
1168
+ onRequestClose: l,
1169
+ scrollRef: u,
1170
+ showDragHandle: d = !0
1171
+ } = {}) {
1172
+ const [h, m] = K(0), [c, y] = K(!1), [b, v] = K(!1), [x, C] = K(!1), p = ee(be), A = X(() => {
1173
+ p.current = be, y(!1), v(!1), C(!1), m(0);
1174
+ }, []), N = X(({ clientX: O, clientY: B, pointerId: D = null, mode: I, target: w, source: $ }) => {
1175
+ !o || t || x || $ === "content" && (!s || !e(w, n.current)) || (p.current = {
1176
+ active: !0,
1177
+ engaged: $ === "handle",
1178
+ mode: I,
1179
+ source: $,
1180
+ pointerId: D,
1181
+ startX: O,
1182
+ startY: B,
1183
+ startTime: performance.now()
1184
+ }, I === "pointer" && D != null && n.current?.setPointerCapture?.(D), y($ === "handle"), v(!1), C(!1));
1185
+ }, [e, t, n, s, x, o]), k = X(({ clientX: O, clientY: B, preventDefault: D }) => {
1186
+ const I = p.current;
1187
+ if (!I.active || t || x) return;
1188
+ const w = B - I.startY, $ = O - I.startX;
1189
+ if (!I.engaged) {
1190
+ if (I.source !== "handle") {
1191
+ if (w < -6 || Math.abs($) > Math.abs(w)) {
1192
+ p.current = be, y(!1);
1193
+ return;
1194
+ }
1195
+ if (w <= 6) return;
1196
+ }
1197
+ p.current = {
1198
+ ...I,
1199
+ engaged: !0
1200
+ }, y(!0);
1201
+ }
1202
+ if (D?.(), w <= 0) {
1203
+ m(0);
1204
+ return;
1205
+ }
1206
+ Math.abs($) > w || m(w);
1207
+ }, [t, x]), f = X(({ clientY: O, pointerId: B = null }) => {
1208
+ const D = p.current;
1209
+ if (!D.active || D.mode === "pointer" && D.pointerId !== B) return;
1210
+ D.mode === "pointer" && B != null && n.current?.releasePointerCapture?.(B), p.current = be, y(!1);
1211
+ const I = Math.max(0, O - D.startY), w = Math.max(performance.now() - D.startTime, 1), $ = I / w, F = Ke(n.current);
1212
+ if (I >= F.closeDistance || $ >= F.closeVelocity) {
1213
+ C(!0), v(!1), m((n.current?.offsetHeight ?? I) + F.closeOffset);
1214
+ return;
1215
+ }
1216
+ v(!0), m(0);
1217
+ }, [n]), g = X((O, B) => {
1218
+ O.pointerType !== "touch" && N({
1219
+ clientX: O.clientX,
1220
+ clientY: O.clientY,
1221
+ pointerId: O.pointerId,
1222
+ mode: "pointer",
1223
+ target: O.target,
1224
+ source: B
1225
+ });
1226
+ }, [N]), S = X((O) => {
1227
+ const B = p.current;
1228
+ B.mode !== "pointer" || B.pointerId !== O.pointerId || k({
1229
+ clientX: O.clientX,
1230
+ clientY: O.clientY,
1231
+ preventDefault: O.cancelable ? () => O.preventDefault() : void 0
1232
+ });
1233
+ }, [k]), L = X((O) => {
1234
+ f({
1235
+ clientY: O.clientY,
1236
+ pointerId: O.pointerId
1237
+ });
1238
+ }, [f]), T = X(() => {
1239
+ if (x) {
1240
+ A(), (i ?? l)?.();
1241
+ return;
1242
+ }
1243
+ b && v(!1);
1244
+ }, [b, x, i, l, A]);
1245
+ j(() => {
1246
+ (t || !o) && A();
1247
+ }, [t, o, A]), j(() => {
1248
+ if (!o) return;
1249
+ const O = r.current, B = u.current, D = n.current;
1250
+ if (!O && d || !B || !D) return;
1251
+ const I = (E) => {
1252
+ const H = ve(E.touches);
1253
+ H && N({
1254
+ clientX: H.clientX,
1255
+ clientY: H.clientY,
1256
+ mode: "touch",
1257
+ target: E.target,
1258
+ source: "handle"
1259
+ });
1260
+ }, w = (E) => {
1261
+ const H = ve(E.touches);
1262
+ H && N({
1263
+ clientX: H.clientX,
1264
+ clientY: H.clientY,
1265
+ mode: "touch",
1266
+ target: E.target,
1267
+ source: "content"
1268
+ });
1269
+ }, $ = (E) => {
1270
+ if (p.current.mode !== "touch") return;
1271
+ const J = ve(E.touches);
1272
+ J && k({
1273
+ clientX: J.clientX,
1274
+ clientY: J.clientY,
1275
+ preventDefault: E.cancelable ? () => E.preventDefault() : void 0
1276
+ });
1277
+ }, F = (E) => {
1278
+ const H = p.current;
1279
+ if (H.mode !== "touch") return;
1280
+ const J = ve(E.changedTouches);
1281
+ f({
1282
+ clientY: J?.clientY ?? H.startY
1283
+ });
1284
+ };
1285
+ return d && O?.addEventListener("touchstart", I, { passive: !0 }), B.addEventListener("touchstart", w, { passive: !0 }), D.addEventListener("touchmove", $, { passive: !1 }), D.addEventListener("touchend", F), D.addEventListener("touchcancel", F), () => {
1286
+ d && O?.removeEventListener("touchstart", I), B.removeEventListener("touchstart", w), D.removeEventListener("touchmove", $), D.removeEventListener("touchend", F), D.removeEventListener("touchcancel", F);
1287
+ };
1288
+ }, [
1289
+ N,
1290
+ t,
1291
+ n,
1292
+ r,
1293
+ f,
1294
+ o,
1295
+ u,
1296
+ d,
1297
+ k
1298
+ ]);
1299
+ const Y = n.current?.offsetHeight ?? 1, z = Ke(n.current), _ = o ? Math.min(h / Y, 1) : 0, P = o && (c || b || x) ? {
1300
+ "--kosmio-overlay-backdrop-opacity": Math.max(z.backdropMinOpacity, 1 - _ * z.backdropFade)
1301
+ } : void 0, W = o && (c || b || x || h > 0) ? {
1302
+ transform: `translate3d(0, ${h}px, 0)`,
1303
+ transition: c ? "none" : "transform var(--kosmio-sheet-drag-settle-duration) ease-out"
1304
+ } : void 0;
1305
+ return {
1306
+ backdropStyle: P,
1307
+ dragging: c,
1308
+ gestureClosing: x,
1309
+ handlePointerDown: g,
1310
+ handlePointerEnd: L,
1311
+ handlePointerMove: S,
1312
+ handleTransitionEnd: T,
1313
+ sheetStyle: W
1314
+ };
1315
+ }
1316
+ const gn = "transform", yn = "kosmio-slide-up";
1317
+ function bn(e, t) {
1318
+ if (e) {
1319
+ if (typeof e == "function") {
1320
+ e(t);
1321
+ return;
1322
+ }
1323
+ e.current = t;
1324
+ }
1325
+ }
1326
+ const vn = te(function({
1327
+ isMobile: t = !1,
1328
+ closing: n = !1,
1329
+ className: r = "",
1330
+ backdropLabel: s = "",
1331
+ feedbackState: o = "",
1332
+ beforeScrollContent: i = null,
1333
+ showDragHandle: l = !0,
1334
+ enableContentDrag: u = !0,
1335
+ canStartContentDrag: d,
1336
+ initialFocusRef: h,
1337
+ onRequestClose: m,
1338
+ onDragDismiss: c,
1339
+ onAnimationEnd: y,
1340
+ onEscapeKeyDown: b,
1341
+ onTransitionEnd: v,
1342
+ portal: x = !1,
1343
+ portalTarget: C,
1344
+ restoreFocus: p,
1345
+ trapFocus: A,
1346
+ children: N,
1347
+ ...k
1348
+ }, f) {
1349
+ const [g, S] = K(!0), L = ee(null), T = ee(null), Y = ee(null), {
1350
+ backdropStyle: z,
1351
+ dragging: _,
1352
+ gestureClosing: P,
1353
+ handlePointerDown: W,
1354
+ handlePointerEnd: O,
1355
+ handlePointerMove: B,
1356
+ handleTransitionEnd: D,
1357
+ sheetStyle: I
1358
+ } = pn({
1359
+ canStartContentDrag: d,
1360
+ closing: n,
1361
+ containerRef: L,
1362
+ dragZoneRef: T,
1363
+ enableContentDrag: u,
1364
+ isMobile: t,
1365
+ onDragDismiss: c,
1366
+ onRequestClose: m,
1367
+ scrollRef: Y,
1368
+ showDragHandle: l
1369
+ }), w = (E) => {
1370
+ L.current = E, bn(f, E);
1371
+ }, $ = (E) => {
1372
+ if (E.target !== E.currentTarget || E.propertyName !== gn) {
1373
+ v?.(E);
1374
+ return;
1375
+ }
1376
+ D(), v?.(E);
1377
+ }, F = (E) => {
1378
+ E.target === E.currentTarget && E.animationName === yn && S(!1), y?.(E);
1379
+ };
1380
+ return j(() => {
1381
+ n || S(!0);
1382
+ }, [n]), j(() => {
1383
+ _ && S(!1);
1384
+ }, [_]), /* @__PURE__ */ a(
1385
+ mt,
1386
+ {
1387
+ className: "kosmio-sheet-layer",
1388
+ closing: n || P,
1389
+ backdropLabel: s,
1390
+ backdropStyle: z,
1391
+ centerContent: !1,
1392
+ initialFocusRef: h,
1393
+ onBackdropClick: m,
1394
+ onEscapeKeyDown: b,
1395
+ portal: x,
1396
+ portalTarget: C,
1397
+ restoreFocus: p,
1398
+ trapFocus: A,
1399
+ children: /* @__PURE__ */ M(
1400
+ "div",
1401
+ {
1402
+ ...k,
1403
+ ref: w,
1404
+ className: V(
1405
+ "kosmio-sheet",
1406
+ r,
1407
+ g && "is-entering",
1408
+ _ && "is-dragging",
1409
+ P && "is-gesture-closing",
1410
+ o && `is-feedback-${o}`
1411
+ ),
1412
+ onClick: (E) => E.stopPropagation(),
1413
+ onAnimationEnd: F,
1414
+ onTransitionEnd: $,
1415
+ onPointerMove: B,
1416
+ onPointerUp: O,
1417
+ onPointerCancel: O,
1418
+ style: I,
1419
+ children: [
1420
+ o ? /* @__PURE__ */ a("div", { className: V("kosmio-sheet-feedback", `is-${o}`), "aria-hidden": "true" }) : null,
1421
+ i,
1422
+ l && t ? /* @__PURE__ */ a(
1423
+ "div",
1424
+ {
1425
+ className: "kosmio-sheet-drag-zone",
1426
+ onPointerDown: (E) => W(E, "handle"),
1427
+ ref: T,
1428
+ role: "presentation",
1429
+ children: /* @__PURE__ */ a("div", { className: "kosmio-sheet-drag-handle", "aria-hidden": "true" })
1430
+ }
1431
+ ) : null,
1432
+ /* @__PURE__ */ a("div", { className: "kosmio-sheet-scroll", onPointerDown: (E) => W(E, "content"), ref: Y, children: N })
1433
+ ]
1434
+ }
1435
+ )
1436
+ }
1437
+ );
1438
+ });
1439
+ function xn() {
1440
+ const {
1441
+ isClosing: e,
1442
+ isMobile: t,
1443
+ listboxId: n,
1444
+ closeImmediately: r,
1445
+ requestClose: s,
1446
+ options: o,
1447
+ overlayRef: i,
1448
+ currentValue: l,
1449
+ handleSelect: u,
1450
+ placeholder: d,
1451
+ displayLabel: h,
1452
+ searchable: m,
1453
+ searchTerm: c,
1454
+ setSearchTerm: y,
1455
+ searchIcon: b,
1456
+ searchLabel: v,
1457
+ emptyLabel: x,
1458
+ closeLabel: C
1459
+ } = Ee(), p = d ?? h;
1460
+ return /* @__PURE__ */ a(
1461
+ vn,
1462
+ {
1463
+ ref: i,
1464
+ isMobile: t,
1465
+ closing: e,
1466
+ className: "select-sheet",
1467
+ backdropLabel: C,
1468
+ onRequestClose: s,
1469
+ onDragDismiss: r,
1470
+ portal: !0,
1471
+ role: "dialog",
1472
+ "aria-modal": "true",
1473
+ "aria-labelledby": `${n}-title`,
1474
+ trapFocus: !0,
1475
+ children: /* @__PURE__ */ M("div", { className: "select-sheet-body", children: [
1476
+ /* @__PURE__ */ a("div", { className: "select-sheet-header", children: /* @__PURE__ */ a(q, { as: "p", size: "sm", dynamic: !0, color: 1, id: `${n}-title`, children: p }) }),
1477
+ m ? /* @__PURE__ */ a("div", { className: "select-searchbar-wrap select-sheet-searchbar-wrap", children: /* @__PURE__ */ M("div", { className: "select-searchbar", children: [
1478
+ /* @__PURE__ */ a(
1479
+ "input",
1480
+ {
1481
+ type: "text",
1482
+ className: "searchbar-input form-field",
1483
+ value: c,
1484
+ onChange: (A) => y(A.target.value),
1485
+ placeholder: v
1486
+ }
1487
+ ),
1488
+ b ? /* @__PURE__ */ a("span", { className: "select-search-icon", children: b }) : null
1489
+ ] }) }) : null,
1490
+ /* @__PURE__ */ a("div", { className: "select-sheet-list", role: "listbox", id: n, children: o.length === 0 ? /* @__PURE__ */ a(q, { as: "p", size: "xs", center: !0, className: "select-empty-state", dynamic: !0, color: 3, children: x }) : o.map((A) => {
1491
+ const N = String(A.value) === String(l);
1492
+ return /* @__PURE__ */ a(
1493
+ ft,
1494
+ {
1495
+ label: A.label,
1496
+ selected: N,
1497
+ className: A.className,
1498
+ mobile: !0,
1499
+ onClick: () => u(A.value)
1500
+ },
1501
+ String(A.value)
1502
+ );
1503
+ }) })
1504
+ ] })
1505
+ }
1506
+ );
1507
+ }
1508
+ function Nn() {
1509
+ const { isOpen: e, isMobile: t } = Ee();
1510
+ return e ? t ? /* @__PURE__ */ a(xn, {}) : typeof document > "u" ? null : at(/* @__PURE__ */ a(cn, {}), document.body) : null;
1511
+ }
1512
+ const kn = {
1513
+ plain: "",
1514
+ custom: "customSelect"
1515
+ }, Cn = "(max-width: 768px)", xe = 5, Ue = 12, Ie = 230, Sn = 150;
1516
+ function Tn(e) {
1517
+ return typeof e == "object" && e !== null ? {
1518
+ value: e.value,
1519
+ label: e.label,
1520
+ className: e.className ?? ""
1521
+ } : {
1522
+ value: e,
1523
+ label: e,
1524
+ className: ""
1525
+ };
1526
+ }
1527
+ const wn = te(function({
1528
+ variant: t = "plain",
1529
+ className: n = "",
1530
+ options: r = [],
1531
+ searchable: s = !1,
1532
+ placeholder: o,
1533
+ value: i,
1534
+ defaultValue: l = "",
1535
+ disabled: u = !1,
1536
+ required: d = !1,
1537
+ onChange: h,
1538
+ onValueChange: m,
1539
+ name: c,
1540
+ searchIcon: y = null,
1541
+ searchLabel: b = "Search",
1542
+ emptyLabel: v = "No results",
1543
+ closeLabel: x = "Close",
1544
+ selectOptionLabel: C = "Select option"
1545
+ }, p) {
1546
+ const A = kn[t] ?? t, N = ee(null), k = i !== void 0, [f, g] = K(l), [S, L] = K(!1), [T, Y] = K(!1), [z, _] = K(!1), [P, W] = K({
1547
+ left: 0,
1548
+ top: 0,
1549
+ width: 0,
1550
+ placement: "bottom",
1551
+ maxHeight: Ie
1552
+ }), [O, B] = K(""), D = Be(), I = ee(null), w = ee(null), $ = Z(() => r.map(Tn), [r]), F = Z(() => {
1553
+ const G = O.trim().toLowerCase();
1554
+ return !s || G.length === 0 ? $ : $.filter(
1555
+ (Q) => String(Q.label).toLowerCase().includes(G)
1556
+ );
1557
+ }, [$, O, s]), E = k ? i : f, H = o != null && String(o).trim() !== "" ? o : C, re = $.find(
1558
+ (G) => String(G.value) === String(E)
1559
+ )?.label ?? H, oe = E != null && String(E).trim() !== "";
1560
+ j(() => () => {
1561
+ w.current && window.clearTimeout(w.current);
1562
+ }, []), j(() => {
1563
+ const G = window.matchMedia(Cn), Q = () => _(G.matches);
1564
+ return Q(), typeof G.addEventListener == "function" ? (G.addEventListener("change", Q), () => G.removeEventListener("change", Q)) : (G.addListener(Q), () => G.removeListener(Q));
1565
+ }, []), j(() => {
1566
+ if (!S || z)
1567
+ return;
1568
+ const G = () => {
1569
+ const Q = N.current?.getBoundingClientRect();
1570
+ if (!Q)
1571
+ return;
1572
+ const se = window.innerHeight, R = Math.max(0, Q.top - Ue - xe), U = Math.max(
1573
+ 0,
1574
+ se - Q.bottom - Ue - xe
1575
+ ), ne = U < Ie && R > U, le = ne ? "top" : "bottom", ue = Math.max(
1576
+ 120,
1577
+ Math.min(Ie, ne ? R : U)
1578
+ );
1579
+ W({
1580
+ left: Q.left,
1581
+ top: ne ? Q.top - xe : Q.bottom + xe,
1582
+ width: Q.width,
1583
+ placement: le,
1584
+ maxHeight: ue
1585
+ });
1586
+ };
1587
+ return G(), window.addEventListener("resize", G), window.addEventListener("scroll", G, !0), () => {
1588
+ window.removeEventListener("resize", G), window.removeEventListener("scroll", G, !0);
1589
+ };
1590
+ }, [z, S]), j(() => {
1591
+ if (!S || T) {
1592
+ B("");
1593
+ return;
1594
+ }
1595
+ const G = (se) => {
1596
+ const R = se.target;
1597
+ z && R instanceof Element && R.closest(".select-sheet") || N.current?.contains(se.target) || I.current?.contains(se.target) || ie();
1598
+ }, Q = (se) => {
1599
+ se.key === "Escape" && (ie(), N.current?.focus());
1600
+ };
1601
+ return document.addEventListener("mousedown", G), document.addEventListener("touchstart", G), document.addEventListener("keydown", Q), () => {
1602
+ document.removeEventListener("mousedown", G), document.removeEventListener("touchstart", G), document.removeEventListener("keydown", Q);
1603
+ };
1604
+ }, [T, z, S, D]);
1605
+ const ge = (G) => {
1606
+ k || g(G);
1607
+ const Q = {
1608
+ target: { name: c, value: G },
1609
+ currentTarget: { name: c, value: G }
1610
+ };
1611
+ h?.(Q), m?.(G, Q);
1612
+ }, me = () => {
1613
+ w.current && (window.clearTimeout(w.current), w.current = null), Y(!1), L(!1);
1614
+ }, ie = () => {
1615
+ if (!(!S || T)) {
1616
+ if (!z) {
1617
+ me();
1618
+ return;
1619
+ }
1620
+ Y(!0), w.current = window.setTimeout(() => {
1621
+ w.current = null, me();
1622
+ }, Sn);
1623
+ }
1624
+ }, ae = () => {
1625
+ w.current && (window.clearTimeout(w.current), w.current = null), Y(!1), L(!0);
1626
+ }, Ae = {
1627
+ className: n,
1628
+ closeImmediately: me,
1629
+ currentValue: E,
1630
+ disabled: u,
1631
+ displayLabel: re,
1632
+ filteredOptions: F,
1633
+ forwardedRef: p,
1634
+ handleSelect: (G) => {
1635
+ ge(G), ie(), N.current?.focus();
1636
+ },
1637
+ hasValue: oe,
1638
+ isClosing: T,
1639
+ isMobile: z,
1640
+ isOpen: S,
1641
+ listboxId: D,
1642
+ open: ae,
1643
+ options: F,
1644
+ overlayRef: I,
1645
+ placeholder: H,
1646
+ position: P,
1647
+ requestClose: ie,
1648
+ required: d,
1649
+ searchIcon: y,
1650
+ searchLabel: b,
1651
+ searchable: s,
1652
+ searchTerm: O,
1653
+ setSearchTerm: B,
1654
+ emptyLabel: v,
1655
+ closeLabel: x,
1656
+ toggleOpen: () => {
1657
+ if (S) {
1658
+ ie();
1659
+ return;
1660
+ }
1661
+ ae();
1662
+ },
1663
+ triggerRef: N,
1664
+ variantClass: A
1665
+ };
1666
+ return /* @__PURE__ */ a(dt.Provider, { value: Ae, children: /* @__PURE__ */ M("div", { className: V("select-field", S && "is-open", z && "is-mobile"), children: [
1667
+ /* @__PURE__ */ a(ln, {}),
1668
+ /* @__PURE__ */ a(Nn, {})
1669
+ ] }) });
1670
+ });
1671
+ function $e({
1672
+ label: e,
1673
+ placeholder: t,
1674
+ value: n,
1675
+ defaultValue: r = "",
1676
+ onChange: s,
1677
+ options: o = [],
1678
+ searchable: i = !1,
1679
+ required: l = !1,
1680
+ className: u = "",
1681
+ labelClassName: d = "",
1682
+ fieldClassName: h = "",
1683
+ requiredLabel: m = "Required",
1684
+ selectOptionLabel: c = "Select option",
1685
+ searchIcon: y = null,
1686
+ searchLabel: b,
1687
+ emptyLabel: v,
1688
+ closeLabel: x
1689
+ }) {
1690
+ const C = n ?? r, p = t ?? c, A = C == null || String(C).trim().length === 0;
1691
+ return /* @__PURE__ */ M("div", { className: `form-field-container ${u}`.trim(), children: [
1692
+ e && /* @__PURE__ */ M(q, { className: `form-field-label ${d}`.trim(), as: "label", size: "xxs", children: [
1693
+ e,
1694
+ l && /* @__PURE__ */ a(q, { className: V("form-field-required-text", A && "empty"), as: "span", children: m })
1695
+ ] }),
1696
+ /* @__PURE__ */ a(wn, { variant: "custom", value: C, onValueChange: s, required: l, placeholder: p, options: o, searchable: i, className: `${h} ${C ? "" : "placeholder"}`, searchIcon: y, searchLabel: b, emptyLabel: v, closeLabel: x, selectOptionLabel: c })
1697
+ ] });
1698
+ }
1699
+ function ht({ children: e, text: t, color: n, className: r = "", ...s }) {
1700
+ const o = e ?? t;
1701
+ return /* @__PURE__ */ a(
1702
+ q,
1703
+ {
1704
+ as: "span",
1705
+ className: `kosmio-tag tag ${r}`.trim(),
1706
+ size: "xxs",
1707
+ style: n ? { "--kosmio-tag-color": n, "--tag-color": n } : void 0,
1708
+ ...s,
1709
+ children: o
1710
+ }
1711
+ );
1712
+ }
1713
+ function $r({ children: e, text: t, color: n = "#5a95ad", className: r = "", ...s }) {
1714
+ return /* @__PURE__ */ a(ht, { color: n, className: `color-tag text-inline ${r}`.trim(), ...s, children: e ?? t });
1715
+ }
1716
+ const En = (e) => /* @__PURE__ */ a(q, { className: "tag generatorInput-chip", as: "p", size: "sm", children: e }), An = (e) => e === "Backspace" || e === "Delete", Je = (e, t, n) => typeof e == "function" ? e(t, n) : Re(e) ? ot(e, {
1717
+ text: t,
1718
+ index: n
1719
+ }) : En(t);
1720
+ function Ln({
1721
+ label: e,
1722
+ placeholder: t = "",
1723
+ value: n,
1724
+ defaultValue: r = [],
1725
+ onChange: s,
1726
+ onGeneratedChange: o,
1727
+ component: i = /* @__PURE__ */ a(ht, {}),
1728
+ className: l = "",
1729
+ labelClassName: u = "",
1730
+ fieldClassName: d = "",
1731
+ inputClassName: h = "",
1732
+ disabled: m = !1,
1733
+ onKeyDown: c,
1734
+ ...y
1735
+ }) {
1736
+ const [b, v] = K(""), [x, C] = K(() => Array.isArray(r) ? r : []), p = ee(null), A = Array.isArray(n), N = A ? n : x, k = (T) => {
1737
+ A || C(T), s?.(T), o?.({
1738
+ texts: T,
1739
+ components: T.map((Y, z) => Je(i, Y, z))
1740
+ });
1741
+ }, f = () => {
1742
+ if (m) return;
1743
+ const T = b.trim();
1744
+ T && (k([...N, T]), v(""));
1745
+ }, g = () => {
1746
+ m || N.length === 0 || k(N.slice(0, -1));
1747
+ }, S = Z(() => N.map((T, Y) => {
1748
+ const z = Je(i, T, Y), _ = `${T}-${Y}`;
1749
+ return typeof z == "string" || typeof z == "number" ? /* @__PURE__ */ a(q, { className: "tag generatorInput-chip", as: "span", size: "xxs", children: String(z) }, _) : /* @__PURE__ */ a(Nt, { children: z }, _);
1750
+ }), [N, i]), L = (T) => {
1751
+ T.key === "Enter" ? (T.preventDefault(), f()) : An(T.key) && b.length === 0 && (T.preventDefault(), g()), c?.(T);
1752
+ };
1753
+ return /* @__PURE__ */ M("div", { className: V("form-field-container gap5", l), children: [
1754
+ e && /* @__PURE__ */ a(q, { className: V("form-field-label row-left", u), as: "label", size: "xxs", children: e }),
1755
+ /* @__PURE__ */ M("div", { className: V("generatorInput-container form-field", d, m && "generatorInput-disabled"), onMouseDown: (T) => {
1756
+ T.target !== p.current && T.preventDefault(), p.current?.focus();
1757
+ }, children: [
1758
+ S,
1759
+ /* @__PURE__ */ a("input", { ref: p, type: "text", value: b, placeholder: N.length === 0 ? t : "", onChange: (T) => v(T.target.value), onKeyDown: L, className: V("generatorInput-input", h), disabled: m, ...y })
1760
+ ] })
1761
+ ] });
1762
+ }
1763
+ const Te = "__default_group__";
1764
+ function Ze(e) {
1765
+ return String(e ?? "").toLowerCase().trim();
1766
+ }
1767
+ function Fe(e, t) {
1768
+ const n = Number(e);
1769
+ return Number.isFinite(n) ? n : t;
1770
+ }
1771
+ function qe(e = {}) {
1772
+ return e?.params && typeof e.params == "object" ? e.params : e?.param && typeof e.param == "object" ? e.param : {};
1773
+ }
1774
+ function In(e = {}, t = Number.MAX_SAFE_INTEGER) {
1775
+ const n = qe(e), r = n.group ?? e.group;
1776
+ if (typeof r == "string" && r.trim())
1777
+ return {
1778
+ name: r.trim(),
1779
+ order: Fe(n.groupIndex ?? e.groupIndex, t)
1780
+ };
1781
+ if (r && typeof r == "object") {
1782
+ const s = r.name ?? r.key ?? r.id;
1783
+ return {
1784
+ name: typeof s == "string" && s.trim() ? s.trim() : Te,
1785
+ order: Fe(r.index, t)
1786
+ };
1787
+ }
1788
+ return {
1789
+ name: Te,
1790
+ order: t
1791
+ };
1792
+ }
1793
+ function Dn(e) {
1794
+ if (e == null || e === "") return "";
1795
+ if (typeof e == "string") {
1796
+ const t = e.trim();
1797
+ if (!t) return "";
1798
+ if (/^\d{4}-\d{2}-\d{2}/.test(t)) return t.slice(0, 10);
1799
+ const n = new Date(t);
1800
+ return Number.isNaN(n.getTime()) ? t : [
1801
+ n.getFullYear(),
1802
+ String(n.getMonth() + 1).padStart(2, "0"),
1803
+ String(n.getDate()).padStart(2, "0")
1804
+ ].join("-");
1805
+ }
1806
+ return e instanceof Date && !Number.isNaN(e.getTime()) ? [
1807
+ e.getFullYear(),
1808
+ String(e.getMonth() + 1).padStart(2, "0"),
1809
+ String(e.getDate()).padStart(2, "0")
1810
+ ].join("-") : "";
1811
+ }
1812
+ function zn(e = {}) {
1813
+ const t = qe(e);
1814
+ return {
1815
+ values: t.enum ?? e.enum ?? [],
1816
+ i18nPath: t.enumI18nPath ?? e.enumI18nPath ?? t.enumPath ?? e.enumPath ?? null
1817
+ };
1818
+ }
1819
+ function On(e, t) {
1820
+ return Array.isArray(e.values) ? e.values.map((n) => {
1821
+ if (n && typeof n == "object") {
1822
+ const i = n.value ?? n.id ?? n.key;
1823
+ if (i == null) return null;
1824
+ const l = e.i18nPath && n.label == null ? t(`${e.i18nPath}.${i}`) : null;
1825
+ return {
1826
+ ...n,
1827
+ value: String(i),
1828
+ label: n.label ?? (l === `${e.i18nPath}.${i}` ? String(i) : l)
1829
+ };
1830
+ }
1831
+ const r = String(n ?? "");
1832
+ if (!r) return null;
1833
+ const s = e.i18nPath != null ? t(`${e.i18nPath}.${r}`) : r, o = `${e.i18nPath}.${r}`;
1834
+ return {
1835
+ value: r,
1836
+ label: s === o ? r : s
1837
+ };
1838
+ }).filter(Boolean) : [];
1839
+ }
1840
+ function Fr({
1841
+ modelProperties: e,
1842
+ form: t,
1843
+ onChange: n,
1844
+ optionsMap: r = {},
1845
+ customRenderers: s = {},
1846
+ onlyFields: o = null,
1847
+ mode: i = "create",
1848
+ i18nPath: l = null,
1849
+ groupI18nPath: u = null
1850
+ }) {
1851
+ const { t: d } = ce(), h = e?.fields ?? {}, m = {
1852
+ requiredLabel: d("forms.shared.required"),
1853
+ selectOptionLabel: d("forms.shared.selectOption"),
1854
+ searchLabel: d("common.actions.search"),
1855
+ emptyLabel: d("common.messages.info.noResultMessage"),
1856
+ closeLabel: d("common.actions.close")
1857
+ }, c = (f) => i === "edit" ? f.editable : f.writable, y = (f) => {
1858
+ if (!l) return f;
1859
+ const g = `${l}.${f}`, S = d(g);
1860
+ return S === g ? f : S;
1861
+ }, b = (f) => {
1862
+ if (!f || f === Te) return null;
1863
+ if (!u) return f;
1864
+ const g = `${u}.${f}`, S = d(g);
1865
+ return S === g ? f : S;
1866
+ }, v = (f, g, S) => {
1867
+ const L = Ze(S);
1868
+ if (L === "number") {
1869
+ const T = g === "" || g == null ? null : Number(g);
1870
+ n(f, Number.isNaN(T) ? null : T);
1871
+ return;
1872
+ }
1873
+ if (L === "boolean" || L === "bool") {
1874
+ n(f, !!g);
1875
+ return;
1876
+ }
1877
+ n(f, g);
1878
+ }, x = (f) => f.iconName ? /* @__PURE__ */ a(ut, { name: f.iconName, alt: f.label, variant: f.iconVariant, size: f.iconSize ?? "xl" }) : null, C = Object.entries(h).map(([f, g], S) => ({
1879
+ name: f,
1880
+ meta: g,
1881
+ position: S
1882
+ })).filter(({ name: f, meta: g }) => !(!c(g) || o && !o.includes(f))).map((f) => {
1883
+ const g = qe(f.meta), S = In(f.meta, f.position);
1884
+ return {
1885
+ ...f,
1886
+ fieldIndex: Fe(g.index ?? f.meta?.index, f.position),
1887
+ groupName: S.name,
1888
+ groupIndex: S.order
1889
+ };
1890
+ }).sort((f, g) => f.groupIndex !== g.groupIndex ? f.groupIndex - g.groupIndex : f.groupName !== g.groupName ? String(f.groupName).localeCompare(String(g.groupName)) : f.fieldIndex !== g.fieldIndex ? f.fieldIndex - g.fieldIndex : f.position - g.position), p = [], A = /* @__PURE__ */ new Map();
1891
+ for (const f of C) {
1892
+ const g = String(f.groupName);
1893
+ if (!A.has(g)) {
1894
+ const L = {
1895
+ key: g,
1896
+ name: f.groupName,
1897
+ index: f.groupIndex,
1898
+ fields: []
1899
+ };
1900
+ A.set(g, L), p.push(L);
1901
+ }
1902
+ const S = A.get(g);
1903
+ S.index = Math.min(S.index, f.groupIndex), S.fields.push(f);
1904
+ }
1905
+ const N = p.some((f) => f.name !== Te), k = ({ name: f, meta: g }) => {
1906
+ const S = t?.[f], L = Ze(g?.type), T = y(f), Y = zn(g), z = On(Y, d), _ = Array.isArray(r[f]) && r[f].length > 0 ? r[f] : z;
1907
+ return s[f] ? /* @__PURE__ */ a("div", { children: s[f]({
1908
+ value: S,
1909
+ onChange: (P) => n(f, P),
1910
+ meta: g,
1911
+ name: f,
1912
+ label: T
1913
+ }) }, f) : L === "string" || L === "number" || L === "date" ? /* @__PURE__ */ a(
1914
+ an,
1915
+ {
1916
+ label: T,
1917
+ placeholder: T,
1918
+ type: L === "string" ? void 0 : L,
1919
+ value: L === "date" ? Dn(S) : S ?? "",
1920
+ required: g.required,
1921
+ requiredLabel: m.requiredLabel,
1922
+ onChange: (P) => v(f, P, L)
1923
+ },
1924
+ f
1925
+ ) : L === "boolean" || L === "bool" ? /* @__PURE__ */ M(q, { className: "row-left", as: "label", children: [
1926
+ /* @__PURE__ */ a("input", { type: "checkbox", checked: !!S, onChange: (P) => v(f, P.target.checked, L) }),
1927
+ T
1928
+ ] }, f) : L.endsWith("[]") ? /* @__PURE__ */ a(
1929
+ Ln,
1930
+ {
1931
+ label: T,
1932
+ placeholder: T,
1933
+ value: Array.isArray(S) ? S : [],
1934
+ onChange: (P) => n(f, P),
1935
+ component: (P, W) => /* @__PURE__ */ a(q, { className: "tag", as: "p", children: P }, `${P}-${W}`)
1936
+ },
1937
+ f
1938
+ ) : L === "object" ? /* @__PURE__ */ a(
1939
+ $e,
1940
+ {
1941
+ label: T,
1942
+ placeholder: T,
1943
+ options: r[f] || [],
1944
+ value: S ?? "",
1945
+ required: g.required,
1946
+ onChange: (P) => n(f, P),
1947
+ searchable: !0,
1948
+ ...m
1949
+ },
1950
+ f
1951
+ ) : L === "enum" ? z.length > 6 ? /* @__PURE__ */ a(
1952
+ $e,
1953
+ {
1954
+ label: T,
1955
+ placeholder: T,
1956
+ options: z,
1957
+ value: S ?? "",
1958
+ required: g.required,
1959
+ onChange: (P) => n(f, P),
1960
+ searchable: !0,
1961
+ ...m
1962
+ },
1963
+ f
1964
+ ) : /* @__PURE__ */ M("div", { className: "column-left gap5", children: [
1965
+ T && /* @__PURE__ */ M(q, { className: "form-field-label row-left", as: "label", size: "xxs", children: [
1966
+ T,
1967
+ g.required && /* @__PURE__ */ a(q, { className: "form-field-required-text", as: "span", children: d("forms.shared.required") })
1968
+ ] }),
1969
+ /* @__PURE__ */ a(
1970
+ sn,
1971
+ {
1972
+ enumValues: _,
1973
+ selectedValue: S ?? "",
1974
+ onValueChange: (P) => n(f, P),
1975
+ ariaLabel: T,
1976
+ className: "form-enum-selector",
1977
+ renderIcon: x
1978
+ }
1979
+ )
1980
+ ] }, f) : null;
1981
+ };
1982
+ return N ? /* @__PURE__ */ a("div", { className: "full-view column-left gap20", children: p.map((f) => {
1983
+ const g = b(f.name);
1984
+ return /* @__PURE__ */ M("div", { className: "form-section", children: [
1985
+ g && /* @__PURE__ */ a(q, { as: "p", size: "xxs", children: g }),
1986
+ /* @__PURE__ */ a("div", { className: "section-fields", children: f.fields.map(k) })
1987
+ ] }, f.key);
1988
+ }) }) : /* @__PURE__ */ a("div", { className: "column-left gap10 form-section", children: C.map(k) });
1989
+ }
1990
+ function Pr({ className: e = "", ...t }) {
1991
+ return /* @__PURE__ */ a("div", { className: `kosmio-loader ${e}`.trim(), role: "status", ...t });
1992
+ }
1993
+ function Mr({
1994
+ children: e,
1995
+ restoreFocus: t = !0,
1996
+ role: n = "dialog",
1997
+ trapFocus: r = !0,
1998
+ ...s
1999
+ }) {
2000
+ return /* @__PURE__ */ a(mt, { ...s, "aria-modal": "true", restoreFocus: t, role: n, trapFocus: r, children: e });
2001
+ }
2002
+ function Rr({
2003
+ children: e,
2004
+ className: t = "full-view flex column-left gap20",
2005
+ formLauncher: n,
2006
+ showOperationsShortcut: r = !1,
2007
+ showContentCard: s = !0,
2008
+ fullsize: o = !1
2009
+ }) {
2010
+ const { clearFormLauncher: i, setFormLauncher: l, setShowOperationsShortcut: u } = st();
2011
+ return j(() => {
2012
+ if (n !== void 0)
2013
+ return n ? l(n) : i(), () => i();
2014
+ }, [i, n, l]), j(() => (u(r), () => u(!1)), [u, r]), /* @__PURE__ */ a("main", { className: V("page page-container", o && "fullsize", s && "page-content", t), children: e });
2015
+ }
2016
+ const $n = {
2017
+ plain: "searchbar",
2018
+ full: "full-w searchbar"
2019
+ }, et = te(function({
2020
+ variant: t = "full",
2021
+ className: n = "",
2022
+ placeholder: r = "Search",
2023
+ value: s,
2024
+ onChange: o,
2025
+ onValueChange: i,
2026
+ onSearch: l,
2027
+ onKeyDown: u,
2028
+ searchButtonType: d = "button",
2029
+ searchButtonLabel: h,
2030
+ searchIcon: m = null,
2031
+ inputRef: c,
2032
+ ...y
2033
+ }, b) {
2034
+ const v = $n[t] ?? t, x = (p) => {
2035
+ o?.(p), i?.(p.target.value, p);
2036
+ }, C = () => {
2037
+ l?.(s ?? "");
2038
+ };
2039
+ return /* @__PURE__ */ M("div", { ref: b, className: V(v, n, "pointer"), children: [
2040
+ /* @__PURE__ */ a(
2041
+ "input",
2042
+ {
2043
+ ref: c,
2044
+ type: "text",
2045
+ className: "searchbar-input form-field",
2046
+ placeholder: r,
2047
+ value: s,
2048
+ onChange: x,
2049
+ onKeyDown: (p) => {
2050
+ p.key === "Enter" && (p.preventDefault(), l?.(p.currentTarget.value)), u?.(p);
2051
+ },
2052
+ ...y
2053
+ }
2054
+ ),
2055
+ /* @__PURE__ */ a(
2056
+ "button",
2057
+ {
2058
+ type: d,
2059
+ className: "searchbar-button",
2060
+ onClick: C,
2061
+ "aria-label": h || r,
2062
+ children: m
2063
+ }
2064
+ )
2065
+ ] });
2066
+ });
2067
+ function De(e = "") {
2068
+ if (!e) return "/";
2069
+ const t = e.trim();
2070
+ return t === "/" ? "/" : t.replace(/\/+$/, "") || "/";
2071
+ }
2072
+ class we {
2073
+ constructor({
2074
+ id: t,
2075
+ name: n,
2076
+ label: r,
2077
+ url: s,
2078
+ to: o,
2079
+ path: i,
2080
+ routeKey: l,
2081
+ activeRoutes: u,
2082
+ icon: d,
2083
+ iconSelected: h,
2084
+ iconName: m,
2085
+ iconSelectedName: c,
2086
+ badge: y,
2087
+ className: b,
2088
+ active: v,
2089
+ isActive: x,
2090
+ onClick: C
2091
+ } = {}) {
2092
+ this.id = t ?? o ?? s ?? i ?? l ?? n, this.name = n, this.label = r ?? n, this.url = s, this.to = o ?? s, this.path = i, this.routeKey = l, this.activeRoutes = u ?? (l ? [l] : []), this.icon = d, this.iconSelected = h, this.iconName = m, this.iconSelectedName = c, this.badge = y, this.className = b, this.active = v, this.isActive = x, this.onClick = C;
2093
+ }
2094
+ matches(t) {
2095
+ return typeof this.active == "boolean" ? this.active : typeof this.isActive == "function" ? !!this.isActive(De(t), this) : this.path ? De(this.path) === De(t) : !1;
2096
+ }
2097
+ static from(t = {}) {
2098
+ return t instanceof we ? t : new we(t);
2099
+ }
2100
+ }
2101
+ function Fn(e = "") {
2102
+ if (!e) return "/";
2103
+ const t = e.trim();
2104
+ return t === "/" ? "/" : t.replace(/\/+$/, "") || "/";
2105
+ }
2106
+ function Pn(e) {
2107
+ return e || (typeof globalThis < "u" && globalThis.location?.pathname ? globalThis.location.pathname : "/");
2108
+ }
2109
+ function Br({
2110
+ navItems: e = [],
2111
+ NavItemComponent: t,
2112
+ className: n = "",
2113
+ pathname: r
2114
+ }) {
2115
+ const s = Fn(Pn(r));
2116
+ return t ? /* @__PURE__ */ a("nav", { className: n, children: e.map((o, i) => {
2117
+ const l = we.from(o), u = l.matches(s);
2118
+ return /* @__PURE__ */ a("div", { className: "full-w", children: /* @__PURE__ */ a(t, { navItem: l, active: u }) }, l.id ?? i);
2119
+ }) }) : null;
2120
+ }
2121
+ function _r(e, t) {
2122
+ return { color: e, size: t };
2123
+ }
2124
+ function qr(e, t, n, r, s) {
2125
+ return { fontSize: e, fontColor: t, weight: n, lineHeight: r, as: s };
2126
+ }
2127
+ function Vr(e, t, n, r, s) {
2128
+ return {
2129
+ borderStyle: e,
2130
+ typoStyle: t,
2131
+ backgroundColor: n,
2132
+ padding: r,
2133
+ radii: s
2134
+ };
2135
+ }
2136
+ function Mn({ active: e, direction: t, sortAscIcon: n, sortDescIcon: r }) {
2137
+ return e ? t === "asc" ? n ?? /* @__PURE__ */ a("span", { className: "sort-icon sort-icon-asc", "aria-hidden": "true" }) : r ?? /* @__PURE__ */ a("span", { className: "sort-icon sort-icon-desc", "aria-hidden": "true" }) : null;
2138
+ }
2139
+ function Rn({ columns: e, sortConfig: t, requestSort: n, sortAscIcon: r, sortDescIcon: s }) {
2140
+ return /* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: e.map((o) => {
2141
+ const i = t.key === o.key, l = o.headerClassName ?? o.className ?? "";
2142
+ return /* @__PURE__ */ a(
2143
+ "th",
2144
+ {
2145
+ onClick: () => n(o.key, o.sortable),
2146
+ className: `${o.sortable ? "th-sortable" : ""} ${l}`.trim(),
2147
+ style: {
2148
+ cursor: o.sortable ? "pointer" : "default",
2149
+ width: o.width || "auto"
2150
+ },
2151
+ children: /* @__PURE__ */ M(q, { size: "md", className: "row gap5", as: "span", color: 1, dynamic: !1, children: [
2152
+ o.header,
2153
+ /* @__PURE__ */ a(
2154
+ Mn,
2155
+ {
2156
+ active: i,
2157
+ direction: t.direction,
2158
+ sortAscIcon: r,
2159
+ sortDescIcon: s
2160
+ }
2161
+ )
2162
+ ] })
2163
+ },
2164
+ o.key
2165
+ );
2166
+ }) }) });
2167
+ }
2168
+ function pt({ icon: e = null }) {
2169
+ return /* @__PURE__ */ a("div", { className: "flex-center", children: e ?? /* @__PURE__ */ a("span", { className: "table-empty-cell-icon", "aria-hidden": "true" }) });
2170
+ }
2171
+ function Bn({ row: e, getValue: t, renderEmpty: n = /* @__PURE__ */ a(pt, {}) }) {
2172
+ const r = t(e);
2173
+ return r == null || r === "" ? n : /* @__PURE__ */ a("div", { className: "full-w flex-center gap10 overflow-x-none", children: /* @__PURE__ */ a(q, { as: "p", size: "sm", color: 1, dynamic: !0, className: "text-inline", children: r }) });
2174
+ }
2175
+ function Yr({ row: e, getIconName: t, getIconSrc: n, getAlt: r, getValue: s, renderIcon: o, size: i = "xmd" }) {
2176
+ const l = t?.(e), u = l ? null : n?.(e), d = r?.(e) ?? "";
2177
+ return /* @__PURE__ */ M("div", { className: "full-w flex gap10", children: [
2178
+ l && typeof o == "function" ? o({ name: l, alt: d, size: i, row: e }) : null,
2179
+ !l && u ? /* @__PURE__ */ a(fe, { src: u, alt: d, size: i }) : null,
2180
+ /* @__PURE__ */ a(q, { as: "p", size: "xs", color: 2, dynamic: !0, className: "text-inline", children: s(e) })
2181
+ ] });
2182
+ }
2183
+ function _n({ col: e, row: t }) {
2184
+ return e.cell ? e.cell(t) ?? /* @__PURE__ */ a(pt, {}) : /* @__PURE__ */ a(
2185
+ Bn,
2186
+ {
2187
+ row: t,
2188
+ getValue: (n) => {
2189
+ const r = e.accessor ? e.accessor(n) : n[e.key];
2190
+ return Array.isArray(r) && r.length === 0 ? null : r;
2191
+ }
2192
+ }
2193
+ );
2194
+ }
2195
+ function qn({
2196
+ row: e,
2197
+ rowKey: t,
2198
+ idx: n,
2199
+ columns: r,
2200
+ striped: s,
2201
+ isSelected: o,
2202
+ conditionalRowClassName: i,
2203
+ hasInteractiveRows: l,
2204
+ rowHandlers: u
2205
+ }) {
2206
+ const d = s && n % 2 === 0 ? "row-even" : "row-odd", h = typeof i == "function" && i(e, n) || "";
2207
+ return /* @__PURE__ */ a(
2208
+ "tr",
2209
+ {
2210
+ className: `${d} ${o ? "row-selected" : ""} ${h}`,
2211
+ style: {
2212
+ cursor: l ? "pointer" : "default",
2213
+ ...Ct({ index: n })
2214
+ },
2215
+ onClick: u.onClick,
2216
+ onDoubleClick: u.onDoubleClick,
2217
+ onContextMenu: u.onContextMenu,
2218
+ children: r.map((m) => {
2219
+ const c = m.cellClassName ?? m.className ?? "";
2220
+ return /* @__PURE__ */ a(
2221
+ "td",
2222
+ {
2223
+ className: c,
2224
+ style: { width: m.width || "auto" },
2225
+ children: _n({ col: m, row: e })
2226
+ },
2227
+ m.key
2228
+ );
2229
+ })
2230
+ },
2231
+ t
2232
+ );
2233
+ }
2234
+ function Vn({
2235
+ sortedData: e,
2236
+ columns: t,
2237
+ getRowKey: n,
2238
+ striped: r,
2239
+ conditionalRowClassName: s,
2240
+ getRowHandlers: o,
2241
+ hasInteractiveRows: i
2242
+ }) {
2243
+ return /* @__PURE__ */ a("tbody", { children: e.map((l, u) => {
2244
+ const d = n(l, u), h = o(l, d);
2245
+ return /* @__PURE__ */ a(
2246
+ qn,
2247
+ {
2248
+ row: l,
2249
+ rowKey: d,
2250
+ idx: u,
2251
+ columns: t,
2252
+ striped: r,
2253
+ isSelected: h.isSelected,
2254
+ conditionalRowClassName: s,
2255
+ hasInteractiveRows: i,
2256
+ rowHandlers: h
2257
+ },
2258
+ d
2259
+ );
2260
+ }) });
2261
+ }
2262
+ function Yn({ data: e, columns: t, initialSort: n }) {
2263
+ const [r, s] = K(n), o = (l, u) => {
2264
+ u && s((d) => ({
2265
+ key: l,
2266
+ direction: d.key === l && d.direction === "asc" ? "desc" : "asc"
2267
+ }));
2268
+ }, i = Z(() => {
2269
+ if (!r.key) return e;
2270
+ const l = t.find((d) => d.key === r.key);
2271
+ if (!l) return e;
2272
+ const u = (d) => l.accessor ? l.accessor(d) : d[l.key];
2273
+ return [...e].sort((d, h) => {
2274
+ const m = u(d), c = u(h);
2275
+ return m == null && c != null ? -1 : m != null && c == null ? 1 : m == null && c == null ? 0 : m < c ? r.direction === "asc" ? -1 : 1 : m > c ? r.direction === "asc" ? 1 : -1 : 0;
2276
+ });
2277
+ }, [t, e, r]);
2278
+ return {
2279
+ sortConfig: r,
2280
+ requestSort: o,
2281
+ sortedData: i
2282
+ };
2283
+ }
2284
+ function Hn({
2285
+ sortedData: e,
2286
+ getRowKey: t,
2287
+ tableRef: n,
2288
+ onRowClick: r,
2289
+ onSelectedClick: s,
2290
+ onDeselect: o,
2291
+ onSelectionChange: i,
2292
+ onRowRightClick: l,
2293
+ onEnterRow: u,
2294
+ selectOnRightClick: d = !0,
2295
+ enableKeyboardNav: h = !0,
2296
+ rowShortcuts: m = []
2297
+ }) {
2298
+ const [c, y] = K(null), b = ee(null), v = ee(!1), x = typeof u == "function";
2299
+ j(() => {
2300
+ const N = (k) => {
2301
+ n.current && (k.target.closest(".floating-row-menu") || k.target.closest(".mobile-form-launcher") || n.current.contains(k.target) || (y(null), i?.(null, null), o?.()));
2302
+ };
2303
+ return document.addEventListener("mousedown", N), () => document.removeEventListener("mousedown", N);
2304
+ }, [o, i, n]), j(() => () => clearTimeout(b.current), []), j(() => {
2305
+ c == null || e.some((k, f) => t(k, f) === c) || (y(null), i?.(null, null), o?.());
2306
+ }, [t, o, i, c, e]);
2307
+ const C = X(
2308
+ (N) => {
2309
+ if (N == null) return -1;
2310
+ for (let k = 0; k < e.length; k += 1)
2311
+ if (t(e[k], k) === N) return k;
2312
+ return -1;
2313
+ },
2314
+ [t, e]
2315
+ ), p = X(
2316
+ (N) => {
2317
+ if (!e.length) return;
2318
+ const k = Math.max(0, Math.min(N, e.length - 1)), f = e[k], g = t(f, k);
2319
+ y(g), i?.(f, g), r?.(f);
2320
+ },
2321
+ [t, r, i, e]
2322
+ );
2323
+ return j(() => {
2324
+ if (!h) return;
2325
+ const N = (k) => {
2326
+ if (St(k.target)) return;
2327
+ if (k.key === "ArrowDown") {
2328
+ if (!e.length) return;
2329
+ if (k.preventDefault(), c == null) {
2330
+ p(0);
2331
+ return;
2332
+ }
2333
+ const L = C(c);
2334
+ p(L < 0 ? 0 : L + 1);
2335
+ return;
2336
+ }
2337
+ if (k.key === "ArrowUp") {
2338
+ if (!e.length) return;
2339
+ if (k.preventDefault(), c == null) {
2340
+ p(e.length - 1);
2341
+ return;
2342
+ }
2343
+ const L = C(c);
2344
+ p(L < 0 ? e.length - 1 : L - 1);
2345
+ return;
2346
+ }
2347
+ if (k.key === "Enter") {
2348
+ if (!x || c == null) return;
2349
+ k.preventDefault();
2350
+ const L = C(c), T = e[L];
2351
+ if (!T) return;
2352
+ u(T, k);
2353
+ return;
2354
+ }
2355
+ if (c == null || !Array.isArray(m) || m.length === 0)
2356
+ return;
2357
+ const f = C(c), g = e[f];
2358
+ if (!g) return;
2359
+ const S = m.find((L) => L?.enabled === !1 ? !1 : Tt(k, L));
2360
+ S && (S.preventDefault !== !1 && k.preventDefault(), S.stopPropagation && k.stopPropagation(), S.onTrigger?.(g, k));
2361
+ };
2362
+ return window.addEventListener("keydown", N), () => window.removeEventListener("keydown", N);
2363
+ }, [
2364
+ h,
2365
+ x,
2366
+ C,
2367
+ u,
2368
+ m,
2369
+ p,
2370
+ c,
2371
+ e
2372
+ ]), {
2373
+ selectedKey: c,
2374
+ getRowHandlers: (N, k) => {
2375
+ const f = c === k;
2376
+ return {
2377
+ isSelected: f,
2378
+ onClick: (g) => {
2379
+ if (v.current) {
2380
+ v.current = !1;
2381
+ return;
2382
+ }
2383
+ if (f) {
2384
+ if (!x) {
2385
+ s?.(N, g);
2386
+ return;
2387
+ }
2388
+ clearTimeout(b.current);
2389
+ const S = { clientX: g.clientX, clientY: g.clientY };
2390
+ b.current = setTimeout(() => {
2391
+ s?.(N, S);
2392
+ }, 200);
2393
+ return;
2394
+ }
2395
+ y(k), i?.(N, k), r?.(N, g);
2396
+ },
2397
+ onDoubleClick: (g) => {
2398
+ g.preventDefault(), g.stopPropagation(), clearTimeout(b.current), v.current = !0, u?.(N, g);
2399
+ },
2400
+ onContextMenu: (g) => {
2401
+ g.preventDefault(), d && !f && (y(k), i?.(N, k)), l?.(N, g);
2402
+ }
2403
+ };
2404
+ }
2405
+ };
2406
+ }
2407
+ function Gn({
2408
+ data: e = [],
2409
+ columns: t = [],
2410
+ initialSort: n = {
2411
+ key: null,
2412
+ direction: "asc"
2413
+ },
2414
+ getRowKey: r = (g, S) => S,
2415
+ striped: s = !0,
2416
+ className: o = "",
2417
+ conditionalRowClassName: i,
2418
+ onRowClick: l,
2419
+ onSelectedClick: u,
2420
+ onDeselect: d,
2421
+ onSelectionChange: h,
2422
+ onRowRightClick: m,
2423
+ selectOnRightClick: c = !0,
2424
+ onEnterRow: y,
2425
+ enableKeyboardNav: b = !0,
2426
+ hasActiveSearch: v = !1,
2427
+ isLoading: x = !1,
2428
+ sourceDataCount: C = null,
2429
+ rowShortcuts: p = [],
2430
+ sortAscIcon: A,
2431
+ sortDescIcon: N,
2432
+ emptyState: k = null,
2433
+ noResultsState: f = null
2434
+ }) {
2435
+ const g = ee(null), { sortConfig: S, requestSort: L, sortedData: T } = Yn({
2436
+ data: e,
2437
+ columns: t,
2438
+ initialSort: n
2439
+ }), { getRowHandlers: Y } = Hn({
2440
+ sortedData: T,
2441
+ getRowKey: r,
2442
+ tableRef: g,
2443
+ onRowClick: l,
2444
+ onSelectedClick: u,
2445
+ onDeselect: d,
2446
+ onSelectionChange: h,
2447
+ onRowRightClick: m,
2448
+ onEnterRow: y,
2449
+ selectOnRightClick: c,
2450
+ enableKeyboardNav: b,
2451
+ rowShortcuts: p
2452
+ }), z = typeof C == "number" ? C > 0 : null, _ = !x && !e.length, P = _ && (z === !0 || !!v), W = _ && !P, O = !!(l || u), B = {
2453
+ className: o,
2454
+ columns: t,
2455
+ data: e,
2456
+ hasActiveSearch: v,
2457
+ sourceDataCount: C
2458
+ }, D = (I) => typeof I == "function" ? I(B) : I;
2459
+ return /* @__PURE__ */ a("div", { className: `full-w table-shell ${o}`.trim(), ref: g, children: x ? null : P ? D(f) : W ? D(k) : /* @__PURE__ */ a("div", { className: "table-scroll full-w", children: /* @__PURE__ */ M("table", { className: "table", children: [
2460
+ /* @__PURE__ */ a(
2461
+ Rn,
2462
+ {
2463
+ columns: t,
2464
+ sortConfig: S,
2465
+ requestSort: L,
2466
+ sortAscIcon: A,
2467
+ sortDescIcon: N
2468
+ }
2469
+ ),
2470
+ /* @__PURE__ */ a(
2471
+ Vn,
2472
+ {
2473
+ sortedData: T,
2474
+ columns: t,
2475
+ getRowKey: r,
2476
+ striped: s,
2477
+ conditionalRowClassName: i,
2478
+ getRowHandlers: Y,
2479
+ hasInteractiveRows: O
2480
+ }
2481
+ )
2482
+ ] }) }) });
2483
+ }
2484
+ function tt(e, t = 300) {
2485
+ const [n, r] = K(e);
2486
+ return j(() => {
2487
+ const s = setTimeout(() => r(e), t);
2488
+ return () => clearTimeout(s);
2489
+ }, [e, t]), n;
2490
+ }
2491
+ const ke = "default", gt = "global", yt = Me(null);
2492
+ function Ce(e = "", t = e) {
2493
+ return { query: e, debouncedQuery: t };
2494
+ }
2495
+ function Hr({ children: e, resetKey: t }) {
2496
+ const [n, r] = K({});
2497
+ j(() => {
2498
+ r({});
2499
+ }, [t]);
2500
+ const s = X((u = ke, d) => {
2501
+ r((h) => {
2502
+ const m = h[u] ?? Ce();
2503
+ return m.query === d ? h : {
2504
+ ...h,
2505
+ [u]: {
2506
+ ...m,
2507
+ query: d
2508
+ }
2509
+ };
2510
+ });
2511
+ }, []), o = X((u = ke, d) => {
2512
+ r((h) => {
2513
+ const m = h[u] ?? Ce();
2514
+ return m.debouncedQuery === d ? h : {
2515
+ ...h,
2516
+ [u]: {
2517
+ ...m,
2518
+ debouncedQuery: d
2519
+ }
2520
+ };
2521
+ });
2522
+ }, []), i = X((u = ke) => {
2523
+ r((d) => ({
2524
+ ...d,
2525
+ [u]: Ce()
2526
+ }));
2527
+ }, []), l = Z(
2528
+ () => ({
2529
+ searchByScope: n,
2530
+ setQuery: s,
2531
+ setDebouncedQuery: o,
2532
+ clearQuery: i
2533
+ }),
2534
+ [i, n, o, s]
2535
+ );
2536
+ return /* @__PURE__ */ a(yt.Provider, { value: l, children: e });
2537
+ }
2538
+ function bt(e = ke, { debounceMs: t = 250 } = {}) {
2539
+ const n = Pe(yt), [r, s] = K(""), o = tt(r, t), i = n?.searchByScope?.[e] ?? Ce(), l = n ? i.query : r, u = n ? i.debouncedQuery : o, d = tt(l, t);
2540
+ j(() => {
2541
+ n && n.setDebouncedQuery(e, d);
2542
+ }, [n, d, e]);
2543
+ const h = X(
2544
+ (c) => {
2545
+ if (n) {
2546
+ n.setQuery(e, c);
2547
+ return;
2548
+ }
2549
+ s(c);
2550
+ },
2551
+ [n, e]
2552
+ ), m = X(() => {
2553
+ if (n) {
2554
+ n.clearQuery(e);
2555
+ return;
2556
+ }
2557
+ s("");
2558
+ }, [n, e]);
2559
+ return {
2560
+ query: l,
2561
+ debouncedQuery: u,
2562
+ setQuery: h,
2563
+ clearQuery: m
2564
+ };
2565
+ }
2566
+ function Xn({ text: e, onClick: t, className: n, ariaLabel: r }) {
2567
+ return /* @__PURE__ */ a("button", { type: "button", className: n, onClick: t, "aria-label": r, children: e });
2568
+ }
2569
+ function jn({
2570
+ options: e = [],
2571
+ selectedOption: t,
2572
+ onChangeOption: n,
2573
+ setData: r,
2574
+ onQueryChange: s,
2575
+ initialQuery: o = "",
2576
+ filters: i = !0,
2577
+ addButton: l = !0,
2578
+ buttonName: u = "common.actions.add",
2579
+ enableCtrlF: d = !1,
2580
+ translate: h,
2581
+ isMobile: m = !1,
2582
+ onAdd: c,
2583
+ searchIcon: y = null,
2584
+ renderActionButton: b = Xn,
2585
+ searchScope: v
2586
+ }) {
2587
+ const { t: x } = ce(), C = ee(null), p = h ?? x, A = Z(() => e.find((I) => I.value === t) ?? e[0] ?? null, [e, t]), N = A?.value ?? "", k = A?.data ?? [], f = v ?? N, { query: g, debouncedQuery: S, setQuery: L } = bt(f), T = Z(() => A ? A.searchKeys?.length ? A.searchKeys : ["name", "label"] : ["name", "label"], [A]), Y = X(
2588
+ (D, I) => {
2589
+ if (!I) return !0;
2590
+ const w = I.toLowerCase();
2591
+ for (const $ of T) {
2592
+ const F = D?.[$];
2593
+ if (F != null && String(F).toLowerCase().includes(w)) return !0;
2594
+ }
2595
+ for (const $ of Object.values(D || {}))
2596
+ if (typeof $ == "string" && $.toLowerCase().includes(w)) return !0;
2597
+ return !1;
2598
+ },
2599
+ [T]
2600
+ ), z = ee({ key: "", query: "", length: -1 }), _ = X(
2601
+ (D) => {
2602
+ if (!A || typeof r != "function") return;
2603
+ const I = (D ?? "").trim(), w = Array.isArray(k) ? k : [], $ = I ? w.filter((H) => Y(H, I)) : w, F = { key: N, query: I, length: $.length }, E = z.current;
2604
+ E.key === F.key && E.query === F.query && E.length === F.length || (z.current = F, r($));
2605
+ },
2606
+ [A, k, N, Y, r]
2607
+ ), P = X(() => {
2608
+ typeof c == "function" && c(A);
2609
+ }, [A, c]);
2610
+ j(() => {
2611
+ o && L(o);
2612
+ }, [o, L]), j(() => {
2613
+ if (!A || typeof r != "function" || g.trim() !== "") return;
2614
+ const D = Array.isArray(k) ? k : [], I = { key: N, query: "", length: D.length }, w = z.current;
2615
+ w.key === I.key && w.query === I.query && w.length === I.length || (z.current = I, r(D));
2616
+ }, [g, A, k, N, r]), j(() => {
2617
+ _(S);
2618
+ }, [S, N, _]), j(() => {
2619
+ s?.(g);
2620
+ }, [g, s]), j(() => {
2621
+ if (!d) return;
2622
+ const D = (I) => {
2623
+ const w = I.target, $ = w?.tagName?.toLowerCase(), F = $ === "input" || $ === "textarea" || $ === "select" || w?.isContentEditable;
2624
+ if ((I.ctrlKey || I.metaKey) && I.key.toLowerCase() === "f") {
2625
+ I.preventDefault(), C.current?.focus(), C.current?.select();
2626
+ return;
2627
+ }
2628
+ !F && I.key.toLowerCase() === "n" && (I.preventDefault(), P());
2629
+ };
2630
+ return window.addEventListener("keydown", D), () => window.removeEventListener("keydown", D);
2631
+ }, [d, P]);
2632
+ const W = p("common.shortcuts.add"), O = p("common.shortcuts.filters"), B = A?.addFormName && l ? b({
2633
+ variant: "primary",
2634
+ text: p(u),
2635
+ iconName: "actionAdd",
2636
+ alt: p("common.messages.addIconAlt"),
2637
+ onClick: P,
2638
+ ariaLabel: p(u),
2639
+ tooltipDirection: "left",
2640
+ tooltipText: p("common.shortcuts.tooltip", {
2641
+ label: p(u),
2642
+ shortcut: W
2643
+ }),
2644
+ className: m ? "full-w" : "searchbar-add"
2645
+ }) : null;
2646
+ return m ? /* @__PURE__ */ M("div", { className: "full-w flex column gap5", children: [
2647
+ /* @__PURE__ */ a(
2648
+ et,
2649
+ {
2650
+ variant: "full",
2651
+ value: g,
2652
+ placeholder: p("common.actions.search"),
2653
+ searchButtonLabel: p("common.actions.search"),
2654
+ searchIcon: y,
2655
+ onValueChange: L,
2656
+ onSearch: _,
2657
+ inputRef: C
2658
+ }
2659
+ ),
2660
+ B
2661
+ ] }) : /* @__PURE__ */ M("div", { className: "searchbar-container flex row gap10", children: [
2662
+ e.length > 1 && /* @__PURE__ */ a(
2663
+ $e,
2664
+ {
2665
+ value: A?.value || "",
2666
+ onChange: (D) => n?.(D),
2667
+ options: e.map(({ value: D, label: I }) => ({ value: D, label: I })),
2668
+ placeholder: p("common.messages.selectDataset"),
2669
+ requiredLabel: p("forms.shared.required"),
2670
+ selectOptionLabel: p("forms.shared.selectOption"),
2671
+ className: "searchbar-select"
2672
+ }
2673
+ ),
2674
+ /* @__PURE__ */ a(
2675
+ et,
2676
+ {
2677
+ variant: "full",
2678
+ value: g,
2679
+ placeholder: p("common.actions.search"),
2680
+ searchButtonLabel: p("common.actions.search"),
2681
+ searchIcon: y,
2682
+ onValueChange: L,
2683
+ onSearch: _,
2684
+ inputRef: C
2685
+ }
2686
+ ),
2687
+ i ? b({
2688
+ text: p("common.actions.filters"),
2689
+ iconName: "actionFilter",
2690
+ alt: p("common.messages.filterIconAlt"),
2691
+ ariaLabel: p("common.actions.filters"),
2692
+ tooltipDirection: "left",
2693
+ tooltipText: p("common.shortcuts.tooltip", {
2694
+ label: p("common.actions.filters"),
2695
+ shortcut: O
2696
+ }),
2697
+ className: "searchbar-filter"
2698
+ }) : null
2699
+ ] });
2700
+ }
2701
+ function Wn({ x: e, y: t, row: n, actions: r = [], onClose: s }) {
2702
+ if (!n) return null;
2703
+ const o = (u) => {
2704
+ u.stopPropagation();
2705
+ }, i = e > window.innerWidth / 2 ? "100%" : "0%", l = t > window.innerHeight / 2 ? "100%" : "0%";
2706
+ return /* @__PURE__ */ a("div", { className: "floating-row-menu", onClick: o, style: {
2707
+ position: "fixed",
2708
+ top: t + 4,
2709
+ left: e + 4,
2710
+ "--origin-x": i,
2711
+ "--origin-y": l
2712
+ }, children: /* @__PURE__ */ a("div", { className: "floating-row-menu-card", children: r.map(({
2713
+ label: u,
2714
+ icon: d,
2715
+ iconName: h,
2716
+ renderIcon: m,
2717
+ onClick: c,
2718
+ color: y,
2719
+ shortcut: b,
2720
+ disabled: v
2721
+ }, x) => {
2722
+ const C = typeof u == "function" ? u(n) : u, p = typeof v == "function" ? v(n) : !!v;
2723
+ return C ? /* @__PURE__ */ M("button", { type: "button", className: `menu-item ${y || ""}`, disabled: p, onClick: () => {
2724
+ p || (c?.(n), s?.());
2725
+ }, children: [
2726
+ /* @__PURE__ */ a(q, { as: "p", className: "full-w", children: C }),
2727
+ typeof m == "function" ? m({ icon: d, iconName: h, row: n }) : null,
2728
+ !m && d ? /* @__PURE__ */ a(fe, { src: d, decorative: !0 }) : null,
2729
+ b && /* @__PURE__ */ a("div", { className: "shortcut", children: /* @__PURE__ */ a(q, { as: "p", children: b }) })
2730
+ ] }, C || x) : null;
2731
+ }) }) });
2732
+ }
2733
+ function Qn({ text: e, onClick: t, className: n, ariaLabel: r }) {
2734
+ return /* @__PURE__ */ a("button", { type: "button", className: n, onClick: t, "aria-label": r, children: e });
2735
+ }
2736
+ function Kn({
2737
+ id: e,
2738
+ table_name: t = null,
2739
+ addFormName: n,
2740
+ searchKeys: r,
2741
+ columns: s,
2742
+ initialData: o = [],
2743
+ isLoading: i = !1,
2744
+ buttonName: l = "common.actions.add",
2745
+ onRowClick: u,
2746
+ onRowRightClick: d,
2747
+ onSelectedClick: h,
2748
+ onDeselect: m,
2749
+ onSelectionChange: c,
2750
+ onEnterRow: y,
2751
+ rowShortcuts: b = [],
2752
+ includeHeader: v = !0,
2753
+ emptyState: x,
2754
+ noResultsState: C,
2755
+ conditionalRowClassName: p,
2756
+ translate: A,
2757
+ renderActionButton: N = Qn,
2758
+ searchIcon: k = null,
2759
+ searchScope: f,
2760
+ includePageSearchbar: g = !1,
2761
+ useGlobalSearch: S = !1
2762
+ }) {
2763
+ const { t: L } = ce(), { openForm: T } = _e(), { isMobile: Y } = it(), z = A ?? L, _ = S ? gt : f ?? e, { debouncedQuery: P } = bt(_), W = v && !g && !S, O = P ?? "", B = [
2764
+ {
2765
+ value: e,
2766
+ label: z(t),
2767
+ data: o || [],
2768
+ addFormName: n,
2769
+ searchKeys: r
2770
+ }
2771
+ ], D = () => {
2772
+ n && T(n, "add");
2773
+ }, I = z("common.shortcuts.add"), w = Z(() => r?.length ? r : ["name", "label"], [r]), $ = Z(() => {
2774
+ const F = Array.isArray(o) ? o : [], E = O.trim().toLowerCase();
2775
+ return E ? F.filter((H) => {
2776
+ for (const J of w) {
2777
+ const re = H?.[J];
2778
+ if (re != null && String(re).toLowerCase().includes(E)) return !0;
2779
+ }
2780
+ for (const J of Object.values(H || {}))
2781
+ if (typeof J == "string" && J.toLowerCase().includes(E)) return !0;
2782
+ return !1;
2783
+ }) : F;
2784
+ }, [o, w, O]);
2785
+ return /* @__PURE__ */ M("div", { className: "full-view flex column-left gap10 table-crud", children: [
2786
+ W && /* @__PURE__ */ a(
2787
+ jn,
2788
+ {
2789
+ options: B,
2790
+ buttonName: l,
2791
+ enableCtrlF: !0,
2792
+ filters: !1,
2793
+ isMobile: Y,
2794
+ onAdd: D,
2795
+ searchIcon: k,
2796
+ renderActionButton: N,
2797
+ searchScope: _
2798
+ }
2799
+ ),
2800
+ /* @__PURE__ */ M("div", { className: "page-content column-left full-view gap20", children: [
2801
+ v && !Y && /* @__PURE__ */ M("div", { className: "flex row full-w", children: [
2802
+ t && /* @__PURE__ */ a(q, { size: "xl", children: z(t) }),
2803
+ /* @__PURE__ */ a("div", { className: "full-w row-right", children: n ? N({
2804
+ variant: "primary",
2805
+ text: z(l),
2806
+ iconName: "actionAdd",
2807
+ alt: z("common.messages.addIconAlt"),
2808
+ onClick: D,
2809
+ ariaLabel: z(l),
2810
+ tooltipDirection: "left",
2811
+ tooltipText: z("common.shortcuts.tooltip", {
2812
+ label: z(l),
2813
+ shortcut: I
2814
+ }),
2815
+ className: "searchbar-add"
2816
+ }) : null })
2817
+ ] }),
2818
+ /* @__PURE__ */ a(
2819
+ Gn,
2820
+ {
2821
+ data: $,
2822
+ columns: s.filter(Boolean),
2823
+ isLoading: i,
2824
+ onRowClick: u,
2825
+ onRowRightClick: d,
2826
+ onSelectedClick: h,
2827
+ onDeselect: m,
2828
+ onSelectionChange: c,
2829
+ conditionalRowClassName: p,
2830
+ onEnterRow: y,
2831
+ hasActiveSearch: !!O.trim(),
2832
+ sourceDataCount: Array.isArray(o) ? o.length : 0,
2833
+ rowShortcuts: b,
2834
+ emptyState: x,
2835
+ noResultsState: C
2836
+ }
2837
+ )
2838
+ ] })
2839
+ ] });
2840
+ }
2841
+ const ze = (e) => e != null && Object.prototype.hasOwnProperty.call(e, "archived") && !!e?.archived;
2842
+ function Un({
2843
+ id: e,
2844
+ table_name: t,
2845
+ addFormName: n,
2846
+ optionsFormName: r,
2847
+ searchKeys: s,
2848
+ columns: o,
2849
+ initialData: i = [],
2850
+ isLoading: l = !1,
2851
+ buttonName: u = "common.actions.add",
2852
+ mainAction: d,
2853
+ desktopMenuActions: h = [],
2854
+ onEditRow: m,
2855
+ onToggleArchiveRow: c,
2856
+ onDeleteRow: y,
2857
+ allowArchive: b = !0,
2858
+ allowDelete: v = !0,
2859
+ openMobileMenu: x,
2860
+ conditionalRowClassName: C,
2861
+ rowShortcuts: p = [],
2862
+ fillAvailableHeight: A = !1,
2863
+ includeHeader: N = !0,
2864
+ translate: k,
2865
+ createActionsPayload: f = (W, O) => ({ row: W, actions: O }),
2866
+ TableCRUDComponent: g = Kn,
2867
+ renderActionButton: S,
2868
+ searchIcon: L = null,
2869
+ emptyState: T,
2870
+ noResultsState: Y,
2871
+ searchScope: z,
2872
+ includePageSearchbar: _ = !1,
2873
+ useGlobalSearch: P = !1
2874
+ }) {
2875
+ const { t: W } = ce(), { isMobile: O } = it(), { openConfirm: B } = kt(), { openFormLauncher: D, setFormLauncher: I } = st(), w = k ?? W, [$, F] = K({
2876
+ visible: !1,
2877
+ x: 0,
2878
+ y: 0,
2879
+ row: null
2880
+ }), E = () => F({ visible: !1, x: 0, y: 0, row: null }), H = X(
2881
+ (R) => {
2882
+ if (!b || typeof c != "function") return;
2883
+ const ne = ze(R);
2884
+ if (!v) {
2885
+ B?.({
2886
+ title: w("common.messages.confirm.title"),
2887
+ message: w(ne ? "common.messages.confirm.unarchiveItem" : "common.messages.confirm.archiveItem"),
2888
+ confirmText: w(ne ? "common.actions.unarchive" : "common.actions.archive"),
2889
+ cancelText: w("common.actions.cancel"),
2890
+ danger: !1,
2891
+ onConfirm: () => c(R)
2892
+ });
2893
+ return;
2894
+ }
2895
+ c(R);
2896
+ },
2897
+ [b, v, c, B, w]
2898
+ ), J = X(
2899
+ (R) => {
2900
+ !v || typeof y != "function" || B?.({
2901
+ title: w("common.messages.confirm.title"),
2902
+ message: w("common.messages.confirm.deleteItem"),
2903
+ confirmText: w("common.actions.delete"),
2904
+ cancelText: w("common.actions.cancel"),
2905
+ danger: !0,
2906
+ onConfirm: () => y(R)
2907
+ });
2908
+ },
2909
+ [v, y, B, w]
2910
+ ), re = Z(() => {
2911
+ const R = [];
2912
+ return typeof m == "function" && R.push({
2913
+ label: w("common.actions.edit"),
2914
+ onClick: m,
2915
+ shortcut: "E"
2916
+ }), b && typeof c == "function" && R.push({
2917
+ label: (U) => ze(U) ? w("common.actions.unarchive") : w("common.actions.archive"),
2918
+ onClick: H,
2919
+ shortcut: "T"
2920
+ }), v && typeof y == "function" && R.push({
2921
+ label: w("common.actions.delete"),
2922
+ onClick: J,
2923
+ shortcut: "Del"
2924
+ }), R;
2925
+ }, [
2926
+ b,
2927
+ v,
2928
+ y,
2929
+ m,
2930
+ c,
2931
+ H,
2932
+ J,
2933
+ w
2934
+ ]), oe = Z(
2935
+ () => [...h, ...re],
2936
+ [h, re]
2937
+ ), ge = Z(() => {
2938
+ const R = [];
2939
+ return typeof m == "function" && R.push({ keys: "e", onTrigger: m }), b && typeof c == "function" && R.push({ keys: "t", onTrigger: H }), v && typeof y == "function" && R.push({ keys: ["delete", "backspace"], onTrigger: J }), R;
2940
+ }, [
2941
+ b,
2942
+ v,
2943
+ y,
2944
+ m,
2945
+ c,
2946
+ H,
2947
+ J
2948
+ ]), me = Z(
2949
+ () => p.length > 0 ? p : ge,
2950
+ [p, ge]
2951
+ ), ie = Z(() => (R, U) => {
2952
+ const ne = typeof C == "function" && C(R, U) || "", le = ze(R) ? "row-archived" : "";
2953
+ return [ne, le].filter(Boolean).join(" ");
2954
+ }, [C]);
2955
+ j(() => {
2956
+ E();
2957
+ }, [i]);
2958
+ const ae = Z(() => n ? Ye({
2959
+ group: n,
2960
+ action: "add",
2961
+ iconName: "actionAddFill",
2962
+ labelKey: u
2963
+ }) : null, [n, u]), ye = X(
2964
+ (R) => !R || !r || oe.length === 0 ? ae : Ye({
2965
+ group: r,
2966
+ action: "options",
2967
+ payload: f(R, oe),
2968
+ iconName: "actionMenuFill",
2969
+ labelKey: "common.actions.menu",
2970
+ variant: "options"
2971
+ }),
2972
+ [f, ae, r, oe]
2973
+ );
2974
+ j(() => {
2975
+ I(ae);
2976
+ }, [ae, I]);
2977
+ const Ve = () => {
2978
+ $.visible && E();
2979
+ }, Ae = (R, U) => {
2980
+ if ($.visible && $.row?.id === R?.id) {
2981
+ E();
2982
+ return;
2983
+ }
2984
+ if ($.visible && E(), O) {
2985
+ d?.(R, U);
2986
+ return;
2987
+ }
2988
+ if (!oe.length) return;
2989
+ const le = Math.min(U.clientX, window.innerWidth - 240), ue = Math.min(U.clientY, window.innerHeight - 200);
2990
+ F({ visible: !0, x: le, y: ue, row: R });
2991
+ }, G = (R, U) => {
2992
+ if (U.preventDefault(), $.visible && E(), O) {
2993
+ const ue = ye(R);
2994
+ if (ue?.type === "options") {
2995
+ D(ue);
2996
+ return;
2997
+ }
2998
+ x?.(R, U);
2999
+ return;
3000
+ }
3001
+ if (!oe.length) return;
3002
+ const ne = Math.min(U.clientX, window.innerWidth - 240), le = Math.min(U.clientY, window.innerHeight - 200);
3003
+ F({ visible: !0, x: ne, y: le, row: R });
3004
+ }, Q = (R, U) => {
3005
+ $.visible && E(), d?.(R, U);
3006
+ }, se = X(
3007
+ (R) => {
3008
+ I(ye(R));
3009
+ },
3010
+ [ye, I]
3011
+ );
3012
+ return /* @__PURE__ */ M(
3013
+ "div",
3014
+ {
3015
+ className: `full-view column-left responsive-table ${A ? "table-fill-available" : ""}`.trim(),
3016
+ style: { position: "relative" },
3017
+ children: [
3018
+ /* @__PURE__ */ a(
3019
+ g,
3020
+ {
3021
+ id: e,
3022
+ table_name: t,
3023
+ addFormName: n,
3024
+ searchKeys: s,
3025
+ columns: o,
3026
+ initialData: i,
3027
+ isLoading: l,
3028
+ buttonName: u,
3029
+ onRowClick: Ve,
3030
+ onSelectedClick: Ae,
3031
+ onDeselect: E,
3032
+ onSelectionChange: se,
3033
+ onRowRightClick: G,
3034
+ onEnterRow: Q,
3035
+ rowShortcuts: me,
3036
+ includeHeader: N,
3037
+ conditionalRowClassName: ie,
3038
+ renderActionButton: S,
3039
+ searchIcon: L,
3040
+ emptyState: T,
3041
+ noResultsState: Y,
3042
+ searchScope: P ? gt : z ?? e,
3043
+ includePageSearchbar: _ || P,
3044
+ useGlobalSearch: P
3045
+ }
3046
+ ),
3047
+ !O && $.visible && $.row && oe.length > 0 && /* @__PURE__ */ a(
3048
+ Wn,
3049
+ {
3050
+ x: $.x,
3051
+ y: $.y,
3052
+ row: $.row,
3053
+ actions: oe,
3054
+ onClose: E
3055
+ }
3056
+ )
3057
+ ]
3058
+ }
3059
+ );
3060
+ }
3061
+ const Jn = { data: [], isLoading: !1, error: null, refetch: null }, Zn = { archived: "all" }, er = (e) => e && typeof e.toJSON == "function" ? e.toJSON() : e, tr = (e) => e, nr = (e) => e?.id, rr = (e) => e ?? null, or = (e) => !!e;
3062
+ function sr({
3063
+ crud: e,
3064
+ permissionScope: t,
3065
+ formGroupName: n,
3066
+ setFormObject: r,
3067
+ setAdvancedForm: s,
3068
+ staticData: o,
3069
+ listArchivedReq: i = Zn,
3070
+ normalizeItem: l = er,
3071
+ transformData: u = tr,
3072
+ getRowId: d = nr,
3073
+ disableMutations: h = !1,
3074
+ resolveFormGroupName: m = rr,
3075
+ hasForm: c = or
3076
+ }) {
3077
+ const y = !!t?.create, b = !!t?.edit, v = !!t?.archive, x = !!t?.unarchive, C = !!t?.listArchived, p = !!t?.delete, A = Array.isArray(o), N = m(n), k = c(N, "add") ? N : null, f = c(N, "edit") ? N : null, g = c(N, "options") ? N : null, S = Z(() => {
3078
+ if (C)
3079
+ return i;
3080
+ }, [C, i]), L = A || !e?.useList ? Jn : e.useList(S), { data: T = [], isLoading: Y = !1, error: z = null, refetch: _ = null } = L, P = e?.useDelete ? e.useDelete() : null, W = e?.useArchive ? e.useArchive() : null, O = e?.useUnarchive ? e.useUnarchive() : null, B = Z(() => {
3081
+ const F = A ? o : T, E = Array.isArray(F) ? F.map((H) => l(H)) : [];
3082
+ return u(E);
3083
+ }, [A, T, o, l, u]), D = X(
3084
+ (F) => {
3085
+ !b || !f || (r?.(F), s?.(f, "edit", F));
3086
+ },
3087
+ [b, f, s, r]
3088
+ ), I = X(
3089
+ (F) => {
3090
+ if (!(!g && !f)) {
3091
+ if (r?.(F), g) {
3092
+ s?.(g, "options", F);
3093
+ return;
3094
+ }
3095
+ s?.(f, "edit", F);
3096
+ }
3097
+ },
3098
+ [f, g, s, r]
3099
+ ), w = X(
3100
+ (F) => {
3101
+ if (h) return;
3102
+ const E = d(F);
3103
+ if (E) {
3104
+ if (F?.archived) {
3105
+ if (!x) return;
3106
+ O?.mutate(
3107
+ { pathParams: { id: E } },
3108
+ { onSuccess: (H) => {
3109
+ Le(H) || _?.();
3110
+ } }
3111
+ );
3112
+ return;
3113
+ }
3114
+ v && W?.mutate(
3115
+ { pathParams: { id: E } },
3116
+ { onSuccess: (H) => {
3117
+ Le(H) || _?.();
3118
+ } }
3119
+ );
3120
+ }
3121
+ },
3122
+ [
3123
+ W,
3124
+ v,
3125
+ x,
3126
+ h,
3127
+ d,
3128
+ _,
3129
+ O
3130
+ ]
3131
+ ), $ = X(
3132
+ (F) => {
3133
+ if (h || !p) return;
3134
+ const E = d(F);
3135
+ E && P?.mutate(
3136
+ { pathParams: { id: E } },
3137
+ { onSuccess: (H) => {
3138
+ Le(H) || _?.();
3139
+ } }
3140
+ );
3141
+ },
3142
+ [p, P, h, d, _]
3143
+ );
3144
+ return {
3145
+ data: B,
3146
+ isLoading: Y,
3147
+ error: z,
3148
+ addFormName: y ? k : null,
3149
+ optionFormName: g,
3150
+ openMobileMenu: I,
3151
+ onEditRow: b ? D : void 0,
3152
+ onToggleArchiveRow: v || x ? w : void 0,
3153
+ onDeleteRow: p ? $ : void 0,
3154
+ allowArchive: v || x,
3155
+ allowDelete: p,
3156
+ permissions: {
3157
+ canCreate: y,
3158
+ canEdit: b,
3159
+ canArchive: v,
3160
+ canUnarchive: x,
3161
+ canListArchived: C,
3162
+ canDelete: p
3163
+ }
3164
+ };
3165
+ }
3166
+ function Gr({
3167
+ id: e,
3168
+ tableName: t,
3169
+ crud: n,
3170
+ permissionScope: r,
3171
+ formGroupName: s,
3172
+ columns: o,
3173
+ searchKeys: i,
3174
+ buttonName: l = "common.actions.add",
3175
+ mainAction: u,
3176
+ desktopMenuActions: d = [],
3177
+ listArchivedReq: h,
3178
+ normalizeItem: m,
3179
+ transformData: c,
3180
+ getRowId: y,
3181
+ staticData: b,
3182
+ disableMutations: v = !1,
3183
+ fillAvailableHeight: x = !1,
3184
+ useGlobalSearch: C = !0,
3185
+ useEntityTableActions: p = sr,
3186
+ ResponsiveTableComponent: A = Un,
3187
+ resolveFormGroupName: N,
3188
+ hasForm: k,
3189
+ addFormName: f,
3190
+ optionsFormName: g,
3191
+ openMobileMenu: S,
3192
+ onEditRow: L,
3193
+ onToggleArchiveRow: T,
3194
+ onDeleteRow: Y,
3195
+ allowArchive: z,
3196
+ allowDelete: _,
3197
+ ...P
3198
+ }) {
3199
+ const { setAdvancedForm: W, setFormObject: O } = _e();
3200
+ if (typeof p != "function")
3201
+ throw new Error("EntityTable requires a useEntityTableActions hook.");
3202
+ const {
3203
+ data: B,
3204
+ isLoading: D,
3205
+ addFormName: I,
3206
+ optionFormName: w,
3207
+ openMobileMenu: $,
3208
+ onEditRow: F,
3209
+ onToggleArchiveRow: E,
3210
+ onDeleteRow: H,
3211
+ allowArchive: J,
3212
+ allowDelete: re
3213
+ } = p({
3214
+ crud: n,
3215
+ permissionScope: r,
3216
+ formGroupName: s,
3217
+ setFormObject: O,
3218
+ setAdvancedForm: W,
3219
+ staticData: b,
3220
+ listArchivedReq: h,
3221
+ normalizeItem: m,
3222
+ transformData: c,
3223
+ getRowId: y,
3224
+ disableMutations: v,
3225
+ resolveFormGroupName: N,
3226
+ hasForm: k
3227
+ });
3228
+ return /* @__PURE__ */ a("div", { className: "full-w column-left", children: /* @__PURE__ */ a(
3229
+ A,
3230
+ {
3231
+ ...P,
3232
+ id: e,
3233
+ table_name: t,
3234
+ addFormName: f ?? I,
3235
+ optionsFormName: g ?? w,
3236
+ buttonName: l,
3237
+ searchKeys: i,
3238
+ columns: o,
3239
+ initialData: B,
3240
+ isLoading: D,
3241
+ openMobileMenu: S ?? $,
3242
+ onEditRow: L ?? F,
3243
+ onToggleArchiveRow: T ?? E,
3244
+ onDeleteRow: Y ?? H,
3245
+ allowArchive: z ?? J,
3246
+ allowDelete: _ ?? re,
3247
+ mainAction: u,
3248
+ desktopMenuActions: d,
3249
+ fillAvailableHeight: x,
3250
+ useGlobalSearch: C
3251
+ }
3252
+ ) });
3253
+ }
3254
+ function ir(e, t, n) {
3255
+ return t ?? (e.alt != null ? e.alt : e.altKey && n ? n(e.altKey) : e.altKey ?? "");
3256
+ }
3257
+ function Xr(e, t) {
3258
+ return function({ name: r, size: s, variant: o, alt: i, decorative: l = !1, translateAlt: u, ...d }) {
3259
+ const h = e[r];
3260
+ return h ? /* @__PURE__ */ a(
3261
+ fe,
3262
+ {
3263
+ src: h.src,
3264
+ size: s ?? h.size,
3265
+ variant: o ?? h.variant ?? t,
3266
+ alt: l ? "" : ir(h, i, u),
3267
+ decorative: l,
3268
+ ...d
3269
+ }
3270
+ ) : null;
3271
+ };
3272
+ }
3273
+ const vt = "formDrafts", Se = (e) => e != null && typeof e == "object" && !Array.isArray(e), Oe = () => {
3274
+ if (typeof window > "u") return {};
3275
+ try {
3276
+ const e = window.localStorage.getItem(vt);
3277
+ if (!e) return {};
3278
+ const t = JSON.parse(e);
3279
+ return Se(t) ? t : {};
3280
+ } catch {
3281
+ return {};
3282
+ }
3283
+ }, nt = (e) => {
3284
+ if (!(typeof window > "u"))
3285
+ try {
3286
+ window.localStorage.setItem(vt, JSON.stringify(e));
3287
+ } catch {
3288
+ }
3289
+ };
3290
+ function jr(e, t) {
3291
+ const [n, r] = K(() => {
3292
+ const o = typeof t == "function" ? t() : t;
3293
+ if (!e) return o;
3294
+ const l = Oe()?.[e];
3295
+ return !Se(o) || !Se(l) ? o : { ...o, ...l };
3296
+ });
3297
+ j(() => {
3298
+ if (!e || !Se(n)) return;
3299
+ const o = Oe();
3300
+ nt({
3301
+ ...o,
3302
+ [e]: n
3303
+ });
3304
+ }, [e, n]);
3305
+ const s = X(() => {
3306
+ if (!e) return;
3307
+ const o = Oe();
3308
+ e in o && (delete o[e], nt(o));
3309
+ }, [e]);
3310
+ return { form: n, setForm: r, clearDraft: s };
3311
+ }
3312
+ function ar(e) {
3313
+ if (e == null || e === "") return null;
3314
+ if (typeof e != "object") return String(e);
3315
+ const t = e.id ?? e.value ?? e.ids?.[0] ?? null;
3316
+ return t == null || t === "" ? null : String(t);
3317
+ }
3318
+ function lr(e = {}) {
3319
+ return String(e?.type ?? "").toLowerCase() === "object";
3320
+ }
3321
+ function cr(e) {
3322
+ return e == null ? !1 : typeof e == "string" ? e.trim().length > 0 : !0;
3323
+ }
3324
+ function ur(e, t, n = {}) {
3325
+ const r = new e(n).toJSON(), s = t?.fields ?? {};
3326
+ for (const [o, i] of Object.entries(s))
3327
+ lr(i) && (r[o] = ar(r[o]));
3328
+ return r;
3329
+ }
3330
+ function Wr(e, t, n = {}) {
3331
+ const r = {};
3332
+ for (const [s, o] of Object.entries(n ?? {}))
3333
+ cr(o) && (r[s] = o);
3334
+ return ur(e, t, r);
3335
+ }
3336
+ function Qr({
3337
+ id: e,
3338
+ form: t = null,
3339
+ title: n,
3340
+ iconName: r = null,
3341
+ picture: s = null,
3342
+ type: o = "short-form",
3343
+ ...i
3344
+ }) {
3345
+ return {
3346
+ id: e,
3347
+ form: t,
3348
+ title: n,
3349
+ iconName: r,
3350
+ picture: s,
3351
+ type: o,
3352
+ ...i
3353
+ };
3354
+ }
3355
+ function Kr(e = {}) {
3356
+ return e;
3357
+ }
3358
+ function Ur({
3359
+ id: e,
3360
+ form: t = null,
3361
+ title: n = "forms.shared.actionFormTitle",
3362
+ picture: r = null,
3363
+ type: s = "short-form",
3364
+ buildActions: o = null,
3365
+ actions: i = [],
3366
+ ...l
3367
+ }) {
3368
+ return {
3369
+ id: e,
3370
+ form: t,
3371
+ title: n,
3372
+ picture: r,
3373
+ type: s,
3374
+ buildActions: o,
3375
+ actions: i,
3376
+ ...l
3377
+ };
3378
+ }
3379
+ function Jr(e = {}) {
3380
+ return {
3381
+ forms: e,
3382
+ getForm: (o, i = "default") => !o || o === "none" || !i || i === "none" ? null : e?.[o]?.[i] ?? null,
3383
+ getFormGroup: (o) => !o || o === "none" ? null : e?.[o] ?? null,
3384
+ getFormID: (o, i = "default") => !o || o === "none" || !i || i === "none" ? null : e?.[o]?.[i]?.id ?? null,
3385
+ getFormGroupActions: (o) => !o || o === "none" ? [] : Object.keys(e?.[o] ?? {})
3386
+ };
3387
+ }
3388
+ export {
3389
+ qr as $,
3390
+ xr as A,
3391
+ Ht as B,
3392
+ Tr as C,
3393
+ Mr as D,
3394
+ pt as E,
3395
+ Ir as F,
3396
+ gt as G,
3397
+ wn as H,
3398
+ fe as I,
3399
+ Dr as J,
3400
+ vn as K,
3401
+ Pr as L,
3402
+ Br as M,
3403
+ we as N,
3404
+ mt as O,
3405
+ Rr as P,
3406
+ Vn as Q,
3407
+ Un as R,
3408
+ et as S,
3409
+ Gn as T,
3410
+ Kn as U,
3411
+ Rn as V,
3412
+ qn as W,
3413
+ Hr as X,
3414
+ ht as Y,
3415
+ q as Z,
3416
+ Bn as _,
3417
+ Sr as a,
3418
+ Fr as a0,
3419
+ kr as a1,
3420
+ Wr as a2,
3421
+ Cr as a3,
3422
+ Xe as a4,
3423
+ Lr as a5,
3424
+ Jr as a6,
3425
+ Xr as a7,
3426
+ lt as a8,
3427
+ He as a9,
3428
+ vr as aa,
3429
+ Ur as ab,
3430
+ Qr as ac,
3431
+ Kr as ad,
3432
+ ur as ae,
3433
+ Yt as af,
3434
+ tt as ag,
3435
+ sr as ah,
3436
+ jr as ai,
3437
+ Vt as aj,
3438
+ dn as ak,
3439
+ pn as al,
3440
+ bt as am,
3441
+ Hn as an,
3442
+ Yn as ao,
3443
+ wr as b,
3444
+ _r as c,
3445
+ Rt as d,
3446
+ jt as e,
3447
+ Wt as f,
3448
+ Er as g,
3449
+ Ar as h,
3450
+ $r as i,
3451
+ Jt as j,
3452
+ Vr as k,
3453
+ Gr as l,
3454
+ nn as m,
3455
+ sn as n,
3456
+ Wn as o,
3457
+ Or as p,
3458
+ an as q,
3459
+ $e as r,
3460
+ jn as s,
3461
+ Ln as t,
3462
+ zr as u,
3463
+ Zt as v,
3464
+ ut as w,
3465
+ Nr as x,
3466
+ Yr as y,
3467
+ tn as z
3468
+ };