@dakataa/crud-react 1.0.4 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,286 +1,719 @@
1
- var Dt = Object.defineProperty;
2
- var Lt = (e, t, n) => t in e ? Dt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var ee = (e, t, n) => Lt(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { jsx as s, Fragment as k, jsxs as _ } from "react/jsx-runtime";
5
- import * as Be from "react";
6
- import S, { memo as W, useContext as jt, useState as $, useEffect as v, forwardRef as ie, useRef as R, useImperativeHandle as je, useReducer as xt, use as kt, Suspense as Rt } from "react";
7
- import xe, { convertObjectToURLSearchParams as nt, RequestBodyType as Mt, convertURLSearchParamsToObject as vt, convertFormDataToObject as Ft, Method as It } from "@dakataa/requester";
8
- import "@dakataa/crud-theme/scss/theme.scss";
9
- import { generatePath as Vt, UNSAFE_RouteContext as $t, matchPath as Ke, useNavigate as Ut, useParams as Bt, Link as z, useLocation as Kt, useSearchParams as Ht } from "react-router";
10
- import { createPortal as wt } from "react-dom";
11
- import Yt from "lottie-web/build/player/esm/lottie.min.js";
12
- import * as He from "@popperjs/core";
13
- class ke {
14
- constructor(t = 0, n, r) {
15
- ee(this, "code");
16
- ee(this, "detail");
17
- ee(this, "trace");
18
- this.code = t, this.detail = n, this.trace = r;
1
+ import { jsx as r, jsxs as C, Fragment as A } from "react/jsx-runtime";
2
+ import K, { convertObjectToURLSearchParams as Sn, convertURLSearchParamsToObject as pt, convertFormDataToObject as Be, Method as $e, InterceptEvent as Ne, RequestBodyType as ht } from "@dakataa/requester";
3
+ import * as ae from "react";
4
+ import v, { useState as R, memo as X, useEffect as N, forwardRef as de, useRef as S, useImperativeHandle as ue, useReducer as W, useId as Ce, useCallback as kn, Fragment as Se, createElement as et, Children as Dn, createRef as Rn } from "react";
5
+ import { createPortal as Tn } from "react-dom";
6
+ import In from "lottie-web/build/player/esm/lottie.min.js";
7
+ import * as tt from "@popperjs/core";
8
+ class gt {
9
+ code;
10
+ detail;
11
+ trace;
12
+ constructor(t = 0, n, o) {
13
+ this.code = t, this.detail = n, this.trace = o;
19
14
  }
20
15
  }
21
- class Q extends ke {
22
- constructor(n, r, o) {
23
- super(0, r, o);
24
- ee(this, "status", 400);
25
- this.status = n;
16
+ class qe extends gt {
17
+ status = 400;
18
+ constructor(t, n, o) {
19
+ super(0, n, o), this.status = t;
26
20
  }
27
21
  }
28
- class Wt extends Be.Component {
29
- constructor(n) {
30
- super(n);
31
- ee(this, "promiseRejectionHandler", (n) => {
32
- n.reason instanceof ke && this.setState({
33
- ...this.state,
34
- hasError: !0,
35
- error: n.reason
36
- });
37
- });
38
- this.state = {
22
+ const bt = ae.createContext(void 0);
23
+ function yt() {
24
+ return ae.useContext(bt);
25
+ }
26
+ function jn({ ...e }) {
27
+ const [t, n] = R(!1);
28
+ return /* @__PURE__ */ r(bt.Provider, { value: { defaultPrevented: t, setPreventDefault: n }, children: e.children });
29
+ }
30
+ class Fn extends ae.Component {
31
+ constructor(t) {
32
+ super(t), this.state = {
39
33
  hasError: !1,
40
34
  error: null
41
35
  };
42
36
  }
37
+ promiseRejectionHandler = (t) => {
38
+ (this.props.preventDefault || this.props.defaultPrevented) && this.props.parentErrorBoundaryContext?.setPreventDefault(!0), !this.props.defaultPrevented && (t.type === "unhandledrejection" && (t.reason === void 0 || typeof t.reason == "string") || this.setState({
39
+ ...this.state,
40
+ hasError: !0,
41
+ error: t.reason
42
+ }));
43
+ };
43
44
  componentDidMount() {
44
45
  window.addEventListener("unhandledrejection", this.promiseRejectionHandler);
45
46
  }
46
47
  componentWillUnmount() {
47
48
  window.removeEventListener("unhandledrejection", this.promiseRejectionHandler);
48
49
  }
49
- static getDerivedStateFromError(n) {
50
- return n instanceof Error && (n = new Q(0, n.message)), {
50
+ static getDerivedStateFromError(t) {
51
+ return t instanceof Error && (t = new qe(0, t.message)), {
51
52
  hasError: !0,
52
- error: n
53
+ error: t
53
54
  };
54
55
  }
55
- componentDidCatch(n, r) {
56
+ componentDidCatch(t, n) {
57
+ console.log("error", t);
58
+ }
59
+ componentDidUpdate(t, n, o) {
60
+ this.state.error?.detail !== n.error?.detail && this.state.hasError && !this.props.defaultPrevented && this.props.fallback instanceof Function && this.props.fallback(this.state.error);
56
61
  }
57
62
  render() {
58
- return this.state.hasError ? Be.cloneElement(
63
+ return this.state.hasError && !this.props.defaultPrevented && this.props.fallback && ae.isValidElement(this.props.fallback) ? ae.cloneElement(
59
64
  this.props.fallback,
60
65
  {
61
- error: this.state.error
66
+ error: this.state.error,
67
+ children: this.props.children
62
68
  }
63
69
  ) : this.props.children;
64
70
  }
65
71
  }
66
- const qt = W(({ children: e }) => /* @__PURE__ */ s(k, { children: e })), zt = W(({ error: e }) => (e ?? (e = new Q(404, "Page not found.")), /* @__PURE__ */ s(qt, { children: /* @__PURE__ */ s("main", { children: /* @__PURE__ */ _("div", { className: "content d-flex flex-column", children: [
67
- /* @__PURE__ */ s("h1", { className: "display-1", children: e.status || "Error" }),
68
- /* @__PURE__ */ s("p", { className: "text-secondary", children: e.detail }),
69
- /* @__PURE__ */ s("br", {}),
70
- /* @__PURE__ */ s("div", { children: /* @__PURE__ */ s("a", { className: "btn btn-primary", href: "#", children: "Back to home" }) })
71
- ] }) }) }))), Jt = ({ children: e }) => /* @__PURE__ */ s(k, { children: e }), B = W(({ name: e, children: t, data: n, parent: r, render: o }) => (t = S.Children.toArray((o ? o(n, r) : t) || []).map((a) => (S.isValidElement(a) && a.type === Jt && (a = S.cloneElement(a, { children: r })), a)), /* @__PURE__ */ s(k, { children: t }))), V = W(({ name: e, content: t, children: n, data: r }) => {
72
- const o = S.Children.toArray(t).find((u) => S.isValidElement(u) && u.type === B && u.props.name === e);
73
- let a = null;
74
- o && S.isValidElement(o) && (a = S.cloneElement(o, { parent: n, data: r }));
75
- const c = S.Children.toArray(n).filter((u) => S.isValidElement(u) && u.type !== B);
76
- return /* @__PURE__ */ s(k, { children: a || (c.length ? c : n) });
77
- }), _e = (e) => e.replaceAll(new RegExp("{(.*?)}", "gi"), ":$1"), Y = (e, t) => e ? Vt(_e(e.path), { ...e.defaults || {}, ...t }) : "#", Qt = () => jt($t).matches.pop(), we = "actions", rt = S.createContext(null);
78
- function Re() {
79
- const e = S.useContext(rt), t = () => {
80
- if (Array.isArray(e))
81
- return e;
82
- }, n = (a, c, u) => {
83
- var h;
84
- return (h = t()) == null ? void 0 : h.filter((i) => i.entity === a && i.name === c && (u === void 0 || i.namespace === u)).shift();
85
- }, r = (a) => {
86
- var c;
87
- return (c = t()) == null ? void 0 : c.find((u) => {
88
- var h;
89
- return ((h = u.route) == null ? void 0 : h.path) && Ke(_e(u.route.path), a);
90
- });
72
+ const Mn = ({ children: e, ...t }) => {
73
+ const n = yt();
74
+ return /* @__PURE__ */ r(Fn, { ...t, defaultPrevented: n?.defaultPrevented || !1, children: e });
75
+ }, vt = ({ children: e, ...t }) => {
76
+ const n = yt();
77
+ return /* @__PURE__ */ r(jn, { children: /* @__PURE__ */ r(Mn, { ...t, parentErrorBoundaryContext: n, children: e }) });
78
+ }, Et = X(({ children: e }) => /* @__PURE__ */ r("div", { className: "crud", children: e })), Un = X(({ error: e }) => /* @__PURE__ */ r(Et, { children: /* @__PURE__ */ r("main", { children: /* @__PURE__ */ C("div", { className: "content d-flex flex-column", children: [
79
+ /* @__PURE__ */ r("h1", { className: "display-1", children: e?.status || e.name || "Error" }),
80
+ /* @__PURE__ */ r("p", { className: "text-secondary", children: e?.detail || "Unknown Error" }),
81
+ /* @__PURE__ */ r("br", {}),
82
+ /* @__PURE__ */ r("div", { children: /* @__PURE__ */ r("a", { className: "btn btn-primary", href: "#", children: "Back to home" }) })
83
+ ] }) }) }));
84
+ var Ct = /* @__PURE__ */ ((e) => (e.PROD = "prod", e.DEV = "dev", e.TEST = "test", e))(Ct || {});
85
+ const _t = v.createContext({
86
+ env: "prod"
87
+ /* PROD */
88
+ });
89
+ function ee() {
90
+ return v.useContext(_t);
91
+ }
92
+ function Vn({ config: e, ...t }) {
93
+ const n = ee();
94
+ return /* @__PURE__ */ r(_t.Provider, { value: {
95
+ ...n || {},
96
+ ...e
97
+ }, children: t.children });
98
+ }
99
+ window.history.pushState = new Proxy(window.history.pushState, {
100
+ apply: (e, t, n) => {
101
+ e.apply(t, n), window.dispatchEvent(new Event("pushstate"));
102
+ }
103
+ });
104
+ window.history.replaceState = new Proxy(window.history.replaceState, {
105
+ apply: (e, t, n) => {
106
+ e.apply(t, n), window.dispatchEvent(new Event("replacestate"));
107
+ }
108
+ });
109
+ const nt = "actions", xt = v.createContext(void 0);
110
+ function j() {
111
+ const e = v.useContext(xt);
112
+ if (!e)
113
+ throw new Error("UseActions must be used in ActionProvider");
114
+ const t = ee(), { actions: n, location: o } = e, s = (d, g, h) => n?.filter((x) => x.entity === d && x.name === g && (h === void 0 || x.namespace === h)).shift(), i = (d) => {
115
+ if (n)
116
+ return n.find((g) => g.route?.path && b(g.route.path, d)) ?? null;
117
+ }, a = (d) => {
118
+ const g = i(d);
119
+ if (!g)
120
+ return g;
121
+ const h = b(g.route?.path || "", d);
122
+ return {
123
+ action: g,
124
+ parameters: h?.params,
125
+ query: h?.query
126
+ };
127
+ }, c = (d) => d.replaceAll(new RegExp("{(.*?)}", "gi"), ":$1"), u = (d, g, h) => l(c(d), g, h), m = (d, g, h) => d ? u(d.path, { ...d.defaults || {}, ...g }, h) : "#", p = (d) => {
128
+ const g = s(d.action.entity, d.action.name, d.action.namespace);
129
+ return m(g?.route, d.parameters, d.query);
130
+ }, f = (d, g, h) => m(d, g, h), y = (d) => (t.link?.prefix && (d = "/" + t.link.prefix.replaceAll(new RegExp("^/|/$", "g"), "") + d), d), E = (d) => (t.link?.prefix && (d = d.replace(new RegExp("^/" + t.link.prefix.replace(new RegExp("^/"), "") + "(/)?"), "/")), d), _ = (d, g) => {
131
+ try {
132
+ g ? history.replaceState(null, "", d) : history.pushState(null, "", d);
133
+ } catch {
134
+ window.location.assign(d);
135
+ }
136
+ }, b = (d, g) => {
137
+ const h = new URL(g, o.origin), x = E(h.pathname), P = "^" + d.replace(new RegExp("/[{:](\\w+)}?", "g"), "[/]?(?<$1>[^/]+)?").replace("*", ".*") + "$";
138
+ if (!new RegExp(P, "giu").test(x))
139
+ return null;
140
+ const k = x.matchAll(new RegExp(P, "giu"))?.next().value?.groups, F = pt(h.searchParams);
141
+ return {
142
+ pathname: x,
143
+ params: k,
144
+ query: F,
145
+ pattern: d
146
+ };
147
+ }, l = (d, g, h) => {
148
+ const x = d.replaceAll(new RegExp("[{:](\\w+)}?", "g"), (O, k) => {
149
+ const F = g?.[k];
150
+ return F !== void 0 && delete g?.[k], F ?? "";
151
+ }).replace(new RegExp("/$", "g"), ""), P = new URL(x, o.origin);
152
+ return Sn(h || {}).entries().forEach(([O, k]) => {
153
+ P.searchParams.set(O, k);
154
+ }), y(P.pathname + P.search);
91
155
  };
92
156
  return {
93
- getAction: n,
94
- getActionByPath: r,
95
- getOnClickActionByPath: (a) => {
96
- const c = () => {
97
- var i;
98
- const u = r(a);
99
- if (!u)
100
- throw new Q(404, "Page not found.");
101
- const h = Ke(_e(((i = u.route) == null ? void 0 : i.path) || ""), a);
102
- return {
103
- action: u,
104
- parameters: h == null ? void 0 : h.params
105
- };
106
- };
107
- return new Promise((u, h) => {
108
- let i = 0;
109
- const m = () => {
110
- if (i > 10)
111
- throw new Q(500, "Cannot load routes");
112
- if (e)
113
- return u(c());
114
- setTimeout(m, 200), i++;
115
- };
116
- m();
117
- });
118
- }
157
+ getAction: s,
158
+ getActionByPath: i,
159
+ getOnClickActionByPath: a,
160
+ navigate: _,
161
+ actions: n,
162
+ location: o,
163
+ matchPath: b,
164
+ generateRoute: m,
165
+ generateRoutePath: u,
166
+ crudToReactPathPattern: c,
167
+ generateActionLink: p,
168
+ generateLink: f,
169
+ generatePath: l,
170
+ internalToExternalPath: y,
171
+ externalToInternalPath: E
119
172
  };
120
173
  }
121
- function Gt(e) {
174
+ function Nt(e) {
122
175
  let t = null;
123
176
  try {
124
- const o = sessionStorage.getItem(we);
125
- t = JSON.parse(atob(o || ""));
177
+ const a = sessionStorage.getItem(nt);
178
+ t = JSON.parse(atob(a || ""));
126
179
  } catch {
127
180
  }
128
- const [n, r] = $(t);
129
- return v(() => {
130
- t || ce().get("/_crud/actions", {}).then((o) => {
131
- o.status === 200 && o.getData().then((a) => {
132
- sessionStorage.setItem(we, btoa(JSON.stringify(a))), r(a);
133
- });
134
- }).catch((o) => {
135
- console.log("error", o);
181
+ const [n, o] = R(t), [s, i] = R(new URL(document.location.href));
182
+ return N(() => {
183
+ const a = (() => {
184
+ i(new URL(document.location.href));
185
+ });
186
+ return window.addEventListener("pushstate", a), window.addEventListener("replacestate", a), window.addEventListener("popstate", a), () => {
187
+ window.removeEventListener("pushstate", a), window.removeEventListener("replacestate", a), window.removeEventListener("popstate", a);
188
+ };
189
+ }, []), N(() => {
190
+ t || le().get({ url: "/_crud/actions" }).then(({ status: a, data: c }) => {
191
+ a === 200 && (sessionStorage.setItem(nt, btoa(JSON.stringify(c))), o(c));
192
+ }).catch((a) => {
193
+ console.log("error", a);
136
194
  }).finally(() => {
137
195
  });
138
- }, []), /* @__PURE__ */ s(rt.Provider, { value: n, children: e.children });
196
+ }, []), /* @__PURE__ */ r(xt.Provider, { value: {
197
+ actions: n,
198
+ location: s,
199
+ setLocation: i
200
+ }, children: e.children });
139
201
  }
140
- const st = S.createContext(null);
141
- function Me() {
142
- const e = S.useContext(st);
202
+ function To(e) {
203
+ return (t) => /* @__PURE__ */ r(Nt, { children: /* @__PURE__ */ r(e, { ...t }) });
204
+ }
205
+ var w = /* @__PURE__ */ ((e) => (e.Form = "form", e.Input = "input", e.Money = "money", e.Hidden = "hidden", e.Number = "number", e.Text = "text", e.Tel = "tel", e.Checkbox = "checkbox", e.Radio = "radio", e.Integer = "integer", e.Password = "password", e.Email = "email", e.Choice = "choice", e.Enum = "enum", e.Entity = "entity", e.Collection = "collection", e.Repeated = "repeated", e.Datetime = "datetime", e.Date = "date", e.Time = "time", e.Currency = "currency", e.Language = "language", e.Birthday = "birthday", e))(w || {});
206
+ const wt = v.createContext(void 0);
207
+ function me() {
208
+ const e = v.useContext(wt);
143
209
  if (!e)
144
210
  throw new Error("useForm must be used in Form");
145
211
  return e;
146
212
  }
147
- const ve = (e, t = null) => (e.replace(/[\[\]]/gi, "_").replace(/_+/gi, "_").replace(/([a-zA-Z])(?=[A-Z])/g, "$1_") + (t ?? "")).toLowerCase(), ot = ie(({
213
+ const _e = (e, t = null) => (e?.replace(/[\[\]]/gi, "_").replace(/_+/gi, "_").replace(/([a-zA-Z])(?=[A-Z])/g, "$1_") + (t ?? "")).toLowerCase(), At = de(({
148
214
  id: e,
149
215
  children: t,
150
216
  data: n,
151
- onError: r,
152
- onBeforeSubmit: o,
153
- onSubmit: a,
154
- onReset: c,
155
- ...u
156
- }, h) => {
157
- const i = R(null), m = {
217
+ onError: o,
218
+ onBeforeSubmit: s,
219
+ onSubmit: i,
220
+ onReset: a,
221
+ ...c
222
+ }, u) => {
223
+ const m = S(null), p = {
158
224
  response: null,
159
225
  constraints: {},
160
226
  errors: {}
161
- }, f = {
162
- getFormData: () => new FormData(i.current || void 0),
163
- setFormData: (d) => {
164
- var p;
165
- [...((p = i.current) == null ? void 0 : p.elements) || []].forEach((C) => {
166
- const N = d.get(C.name);
167
- switch (C.tagName.toLowerCase()) {
227
+ }, f = (l, d) => {
228
+ const g = m.current?.elements.namedItem(l);
229
+ if (!g) {
230
+ console.warn("Cannot Set Value on missing Form Element with name: " + l);
231
+ return;
232
+ }
233
+ if (!(g instanceof HTMLInputElement))
234
+ throw new Error("Cannot Set Value on missing Form Element with name: " + l);
235
+ switch (g.type) {
236
+ case w.Checkbox:
237
+ case w.Radio: {
238
+ d !== null && !(d instanceof Array) && (d = [d]), d?.includes(g.value) && (g.checked = !0);
239
+ break;
240
+ }
241
+ default:
242
+ if (d instanceof Array)
243
+ throw new Error("Invalid Value");
244
+ g.value = d || "";
245
+ }
246
+ }, y = {
247
+ getFormData: () => new FormData(m.current || void 0),
248
+ setFormData: (l) => {
249
+ [...m.current?.elements || []].forEach((d) => {
250
+ const g = l.get(d.name);
251
+ switch (d.tagName.toLowerCase()) {
168
252
  case "select": {
169
- C.multiple ? [...C.options].forEach((A) => {
170
- A.selected = d.getAll(C.name).includes(A.value);
171
- }) : C.value = N;
253
+ d.multiple ? [...d.options].forEach((h) => {
254
+ h.selected = l.getAll(d.name).includes(h.value);
255
+ }) : d.value = g;
172
256
  break;
173
257
  }
174
258
  default:
175
- switch (C.type) {
259
+ switch (d.type) {
176
260
  case "checkbox":
177
- C.checked = !!N;
261
+ d.checked = !!g;
178
262
  break;
179
263
  default:
180
- C.value = N;
264
+ d.value = g;
181
265
  break;
182
266
  }
183
267
  }
184
268
  });
185
269
  },
186
- setErrors: (d) => {
187
- const [, p] = b;
188
- p({ action: "errors", payload: d });
270
+ setValue: f,
271
+ setValues: (l) => {
272
+ Object.keys(l).map((d) => f(d, l[d]));
273
+ },
274
+ setErrors: (l) => {
275
+ const [, d] = _;
276
+ d({ action: "errors", payload: l });
189
277
  },
190
278
  reset: () => {
191
- var d;
192
- (d = i.current) == null || d.reset();
279
+ m.current?.reset();
193
280
  },
194
- submit: () => {
195
- var d;
196
- return (d = i.current) == null ? void 0 : d.requestSubmit();
197
- }
281
+ success: () => {
282
+ const [, l] = _;
283
+ l({ action: "success", payload: !0 });
284
+ },
285
+ submit: () => m.current?.requestSubmit()
198
286
  };
199
- je(h, () => f), v(() => {
200
- const d = () => {
201
- c && c();
202
- }, p = i == null ? void 0 : i.current;
203
- return p == null || p.addEventListener("reset", d), () => {
204
- p == null || p.removeEventListener("reset", d);
287
+ ue(u, () => y), N(() => {
288
+ const l = () => {
289
+ a && a();
290
+ }, d = m?.current;
291
+ return d?.addEventListener("reset", l), () => {
292
+ d?.removeEventListener("reset", l);
205
293
  };
206
294
  }, []);
207
- const l = (d, p) => {
208
- const C = f.getFormData();
209
- for (const N of p)
210
- if (!N.isValid(C.get(d) || null))
211
- return { valid: !1, message: N.getMessage() };
295
+ const E = (l, d) => {
296
+ const g = y.getFormData();
297
+ for (const h of d)
298
+ if (!h.isValid(g.get(l) || null))
299
+ return { valid: !1, message: h.getMessage() };
212
300
  return { valid: !0, message: null };
213
- }, b = xt((d, p) => {
214
- const { action: C, payload: N } = p;
215
- switch (C) {
301
+ }, _ = W((l, d) => {
302
+ const { action: g, payload: h } = d;
303
+ switch (g) {
216
304
  case "constraints": {
217
- const { name: A, constraints: P } = N;
305
+ const { name: x, constraints: P } = h;
218
306
  return {
219
- ...d,
307
+ ...l,
220
308
  constraints: {
221
- ...d.constraints || {},
222
- [A]: P
309
+ ...l.constraints || {},
310
+ [x]: P
223
311
  }
224
312
  };
225
313
  }
226
314
  case "validate": {
227
- const { valid: A, message: P } = l(N, d.constraints[N] || []), D = d.errors || {}, y = N;
228
- return A ? delete D[y] : D[y] = [...D[y] || [], { message: P || "Error" }], Object.keys(D).length ? {
229
- ...d,
230
- errors: D
231
- } : d;
315
+ const { valid: x, message: P } = E(h, l.constraints[h] || []), L = l.errors || {}, O = h;
316
+ return x ? delete L[O] : L[O] = [...L[O] || [], { message: P || "Error" }], Object.keys(L).length ? {
317
+ ...l,
318
+ errors: L
319
+ } : l;
232
320
  }
233
321
  case "response":
234
322
  return {
235
- ...d,
236
- response: N
323
+ ...l,
324
+ response: h
237
325
  };
238
326
  case "errors":
239
327
  return {
240
- ...d,
241
- errors: N || []
328
+ ...l,
329
+ errors: h || []
242
330
  };
243
331
  case "error": {
244
- const A = { ...d.errors, ...N };
332
+ const x = { ...l.errors, ...h };
245
333
  return {
246
- ...d,
247
- errors: A
334
+ ...l,
335
+ errors: x
248
336
  };
249
337
  }
338
+ case "success":
339
+ return {
340
+ ...l,
341
+ success: h
342
+ };
250
343
  }
251
- return d;
252
- }, m), E = (d) => {
253
- d.preventDefault();
254
- const [p, C] = b;
255
- let N = {};
256
- for (const [P, D] of Object.entries(p.constraints)) {
257
- const { valid: y, message: O } = l(P, D);
258
- y || (N[P] = [O]);
344
+ return l;
345
+ }, p), b = (l) => {
346
+ l.preventDefault();
347
+ const [d, g] = _;
348
+ let h = {};
349
+ for (const [P, L] of Object.entries(d.constraints)) {
350
+ const { valid: O, message: k } = E(P, L);
351
+ O || (h[P] = [k]);
259
352
  }
260
- if (Object.values(N).length) {
261
- C({ action: "errors", payload: N });
353
+ if (Object.values(h).length) {
354
+ g({ action: "errors", payload: h });
262
355
  return;
263
356
  }
264
- const A = new FormData((i == null ? void 0 : i.current) || void 0);
265
- if (o && o(A), a) {
266
- a(A);
357
+ const x = new FormData(m?.current || void 0);
358
+ if (s && s(x), i) {
359
+ i(x);
267
360
  return;
268
361
  }
269
362
  };
270
- return /* @__PURE__ */ s(st.Provider, { value: [b, h, i], children: /* @__PURE__ */ s("form", { id: e, ref: i, onSubmit: E, ...u, children: t }) });
271
- }), Zt = ({
363
+ return /* @__PURE__ */ r(wt.Provider, { value: [_, u, m], children: /* @__PURE__ */ r("form", { id: e, ref: m, onSubmit: b, ...c, children: t }) });
364
+ }), Pt = ({
365
+ icon: e,
366
+ preloader: t,
367
+ rightIcon: n,
368
+ children: o,
369
+ preload: s = !1
370
+ }) => /* @__PURE__ */ C(A, { children: [
371
+ s ? t || /* @__PURE__ */ r(A, { children: "*" }) : e,
372
+ o,
373
+ n
374
+ ] }), Lt = v.createContext(void 0), Ot = () => v.useContext(Lt), St = v.createContext(void 0), Bn = () => v.useContext(St), $n = ({ loader: e, children: t }) => {
375
+ const n = Ce();
376
+ return /* @__PURE__ */ r(St.Provider, { value: e || n, children: t });
377
+ }, qn = ({ children: e }) => {
378
+ const [t, n] = W((i, a) => {
379
+ const [c, u] = a;
380
+ return {
381
+ ...i,
382
+ [c]: u
383
+ };
384
+ }, {}), o = (i) => {
385
+ n([i, !0]);
386
+ }, s = (i) => {
387
+ n([i, !1]);
388
+ };
389
+ return /* @__PURE__ */ r(Lt.Provider, { value: {
390
+ loaders: t,
391
+ startLoading: o,
392
+ stopLoading: s,
393
+ isLoading: (i) => t[i] ?? !1
394
+ }, children: e });
395
+ }, fe = de(({
396
+ children: e,
397
+ type: t,
398
+ form: n,
399
+ ...o
400
+ }, s) => {
401
+ const { isLoading: i } = Ot() || {}, a = Bn() || n || "form", c = t === "submit" && i?.(a);
402
+ return /* @__PURE__ */ r("button", { disabled: c, form: n, ...o, ref: s, children: /* @__PURE__ */ r(Pt, { preload: c, ...o, children: e }) });
403
+ }), kt = v.createContext("");
404
+ function Dt() {
405
+ return v.useContext(kt);
406
+ }
407
+ function Hn({ namespace: e, ...t }) {
408
+ return /* @__PURE__ */ r(kt.Provider, { value: e, children: t.children });
409
+ }
410
+ const Rt = v.createContext(void 0);
411
+ function Kn({ children: e }) {
412
+ const [t, n] = W((o, { key: s, context: i }) => (o = { ...o }, i ? o[s] = i : delete o[s], o), {});
413
+ return /* @__PURE__ */ r(Rt.Provider, { value: {
414
+ set: (o, s) => n({ key: o, context: s }),
415
+ get: (o) => t[o] || null,
416
+ unset: (o) => {
417
+ n({ key: o });
418
+ }
419
+ }, children: e });
420
+ }
421
+ function Gn() {
422
+ const e = v.useContext(Rt);
423
+ if (!e)
424
+ throw new Error("UseCurrentActionCollection must be used in CurrentActionCollectionProvider");
425
+ return e;
426
+ }
427
+ const Tt = v.createContext(void 0);
428
+ function te() {
429
+ const e = v.useContext(Tt);
430
+ if (!e)
431
+ throw new Error("UseCurrentAction must be used in CurrentActionProvider");
432
+ return e;
433
+ }
434
+ function It({ action: e, name: t, ref: n, ...o }) {
435
+ const { getAction: s } = j(), { set: i, unset: a } = Gn();
436
+ t ??= [e.action.entity, e.action.name, e.action.namespace].join("-");
437
+ const c = s(e.action.entity, e.action.name, e.action.namespace);
438
+ if (!c)
439
+ throw console.log("Invalid Action", e), new Error("Invalid Current Action");
440
+ e = {
441
+ ...e,
442
+ action: c
443
+ };
444
+ const u = () => {
445
+ p(Date.now());
446
+ };
447
+ ue(n, () => ({
448
+ refresh: u
449
+ }), []);
450
+ const [m, p] = R(1), [f, y] = R(e), E = {
451
+ action: f,
452
+ setAction: y,
453
+ refresh: u
454
+ };
455
+ return N(() => {
456
+ y({ ...e, query: { ...e.query, _ts: m } });
457
+ }, [m]), N(() => {
458
+ y(e);
459
+ }, [JSON.stringify(e)]), N(() => (i(t, E), () => {
460
+ a(t);
461
+ }), []), /* @__PURE__ */ r(Tt.Provider, { value: E, children: /* @__PURE__ */ r(Hn, { namespace: f.action.namespace || "", children: o.children }) });
462
+ }
463
+ const Io = ({ path: e, preloader: t }) => {
464
+ if (!K.namespace[Ze])
465
+ throw new gt(500, "Invalid Configuration.");
466
+ const { link: n } = ee(), { getOnClickActionByPath: o, actions: s } = j(), [i, a] = R(void 0);
467
+ return e ??= n?.path ?? location.pathname + location.search, n?.prefix && (e = e.replace(new RegExp("^/" + n.prefix.replace(new RegExp("^/"), "") + "(/)?"), "/")), N(() => {
468
+ a(o(e));
469
+ }, [e, JSON.stringify(s)]), N(() => {
470
+ if (i === null)
471
+ throw new qe(404, "Not Found");
472
+ }, [i]), i === void 0 ? t ?? /* @__PURE__ */ r(A, { children: "Loading" }) : i === null ? null : /* @__PURE__ */ r(It, { action: i, children: /* @__PURE__ */ r(Ft, { children: /* @__PURE__ */ r(xn, { view: i.action.name }) }) });
473
+ }, jt = v.createContext(null);
474
+ function ne() {
475
+ return v.useContext(jt);
476
+ }
477
+ const Yn = ({
478
+ path: e,
479
+ method: t,
480
+ body: n,
481
+ bodyType: o,
482
+ loadOnInit: s = !0
483
+ }) => {
484
+ const i = S(s), { navigate: a, externalToInternalPath: c, internalToExternalPath: u } = j(), [m, p] = R(), f = S(null), [y, E] = R(1), _ = JSON.stringify(n instanceof FormData ? Be(n) : n);
485
+ e = c(e);
486
+ const b = kn(() => {
487
+ if (!i.current) {
488
+ i.current = !0;
489
+ return;
490
+ }
491
+ return f.current = new AbortController(), le().fetch({
492
+ url: e,
493
+ method: t || $e.GET,
494
+ body: n,
495
+ signal: f.current?.signal
496
+ }).then(({ data: d, response: g }) => {
497
+ if (g.redirected && !["cors"].includes(g.type)) {
498
+ const h = u(new URL(g.url).pathname);
499
+ a(h);
500
+ return;
501
+ }
502
+ if (p({ data: d, response: g }), [401, 403, 404, 500].includes(g.status))
503
+ throw new qe(g.status, g.statusText || "Error", d);
504
+ }).finally(() => {
505
+ }), () => {
506
+ i.current = s;
507
+ };
508
+ }, [y, e, _, o, t]);
509
+ N(() => () => {
510
+ l(), i.current = s;
511
+ }, []), N(() => {
512
+ b();
513
+ }, [y, e, _, o, t]);
514
+ const l = () => {
515
+ f.current?.abort("canceled"), f.current = null;
516
+ };
517
+ return {
518
+ url: e,
519
+ status: m?.response.status || 0,
520
+ results: m?.data,
521
+ response: m?.response,
522
+ refresh: () => {
523
+ E(Date.now());
524
+ },
525
+ cancel: l
526
+ };
527
+ }, Wn = ({
528
+ action: e,
529
+ loadOnInit: t = !0
530
+ }) => {
531
+ const { generateActionLink: n } = j(), o = n(e);
532
+ return Yn({ path: o, method: e.method, body: e.body, bodyType: e.bodyType, loadOnInit: t });
533
+ }, Ft = ({ suspense: e, children: t }) => {
534
+ const { action: n } = te(), { generateActionLink: o } = j(), s = ne(), i = o(n);
535
+ if (s?.url === i)
536
+ return t;
537
+ const a = Wn({
538
+ action: n
539
+ });
540
+ return e ??= /* @__PURE__ */ r(A, { children: "Data Loading" }), /* @__PURE__ */ r(jt.Provider, { value: a, children: e && !a?.results ? e : t });
541
+ };
542
+ function Mt(e) {
543
+ return (t) => /* @__PURE__ */ r(Ft, { children: /* @__PURE__ */ r(e, { ...t }) });
544
+ }
545
+ const jo = (e) => {
546
+ const t = new RegExp("(?<=.)[^@\\n](?=[^@\\n]*?@)|(?:(?<=@.)|(?!^)\\G(?=[^@\\n]*$)).(?=.*[^@\\n]\\.)", "i");
547
+ return e.replace(t, "*");
548
+ }, ke = (e) => e.replace(new RegExp("^.{1,1}"), (t) => t.toUpperCase()), zn = (e) => {
549
+ let t = e?.replace(new RegExp("[-_]", "gi"), " ").split(new RegExp("(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])"));
550
+ if (!t?.length)
551
+ return null;
552
+ const n = t.shift(), o = t.pop();
553
+ return t = t.map((s) => s.toLowerCase()), n && t.unshift(ke(n)), o && t.push(ke(o)), t.join(" ");
554
+ }, Jn = ({ children: e }) => /* @__PURE__ */ r(A, { children: e }), Ut = v.createContext(void 0);
555
+ function Qn() {
556
+ return v.useContext(Ut);
557
+ }
558
+ const U = X(({ view: e, prefix: t, namespace: n, children: o, props: s, data: i }) => {
559
+ const { templates: a } = ee(), c = Qn(), [u, m] = R(1), p = S(Jn);
560
+ n ??= Dt(), e instanceof Array || (e = [e]), e = e.map((b) => b.split(/[._]/).filter((l) => l).map((l) => ke(l)).join(""));
561
+ const f = [
562
+ ...e.map((b) => ["crud", n, t, b].filter((l) => l).join("/") + ".tsx"),
563
+ ...e.map((b) => ["crud", "general", t, b].filter((l) => l).join("/") + ".tsx")
564
+ ], [y, E, _] = f.reduce((b, l) => {
565
+ if (b)
566
+ return b;
567
+ const [, d] = Object.entries(a ?? {}).filter(([h]) => h.endsWith(l)).shift() || [], g = c?.template === l && c?.isImported;
568
+ return d !== void 0 ? [l, g, d] : null;
569
+ }, null) || [!1, void 0];
570
+ return N(() => {
571
+ if (!E) {
572
+ if (_ === void 0)
573
+ return () => {
574
+ };
575
+ _().then((b) => {
576
+ p.current = b.default, m(u + 1);
577
+ });
578
+ }
579
+ }, []), E || !y ? o : /* @__PURE__ */ r(Ut.Provider, { value: {
580
+ template: y,
581
+ parent: o,
582
+ data: i,
583
+ view: e,
584
+ namespace: n,
585
+ isImported: !!_
586
+ }, children: /* @__PURE__ */ r(p.current, { ...s }) });
587
+ }), D = ({ children: e, domain: t, properties: n, ...o }) => typeof e != "string" ? null : (n ??= {}, Object.keys(n).forEach((s) => {
588
+ e = e?.replaceAll(new RegExp(":" + s, "g"), n[s]?.toString() || "");
589
+ }), e = e?.replaceAll(new RegExp(":w+", "g"), ""), /* @__PURE__ */ r(
590
+ U,
591
+ {
592
+ view: "Translation",
593
+ props: { ...o, domain: t, properties: n },
594
+ children: e
595
+ }
596
+ )), Vt = v.createContext(void 0);
597
+ function Zn() {
598
+ return v.useContext(Vt);
599
+ }
600
+ function Xn({ id: e, view: t, children: n }) {
601
+ return /* @__PURE__ */ r(Vt.Provider, { value: { id: e, view: t }, children: n });
602
+ }
603
+ const Fo = ({
604
+ name: e,
605
+ optional: t
606
+ // Stop throwing error when Form View is missing.
607
+ }) => {
608
+ const { form: n } = B(), o = e ? n?.children?.[e] : n;
609
+ if (!o) {
610
+ if (t)
611
+ return null;
612
+ throw new Error("Missing Provided Form View to Form Group" + (e ? ": " + e : ""));
613
+ }
614
+ return /* @__PURE__ */ r(re, { view: o, children: /* @__PURE__ */ r(pe, {}) });
615
+ }, Bt = v.createContext(void 0), $t = () => v.useContext(Bt), Mo = ({ children: e, ...t }) => /* @__PURE__ */ r(Bt.Provider, { value: t, children: e }), De = ({
616
+ view: e,
617
+ className: t
618
+ }) => {
619
+ const o = $t()?.label || e.label || zn(e.name || "") || "", s = ["checkbox", "radio"].includes(e.type || "input");
620
+ return /* @__PURE__ */ r(A, { children: s ? /* @__PURE__ */ r(
621
+ "label",
622
+ {
623
+ className: t ?? "form-check-label",
624
+ htmlFor: e.id || _e(e.full_name || ""),
625
+ ...e.label_attr && (e.label_attr instanceof Function ? e.label_attr() : e.label_attr),
626
+ children: /* @__PURE__ */ r(D, { children: o })
627
+ }
628
+ ) : /* @__PURE__ */ r(
629
+ "label",
630
+ {
631
+ className: t ?? "form-label",
632
+ ...e.label_attr && (e.label_attr instanceof Function ? e.label_attr() : e.label_attr),
633
+ children: /* @__PURE__ */ r(D, { children: o })
634
+ }
635
+ ) });
636
+ }, er = ({
637
+ name: e
638
+ }) => {
639
+ const { form: t } = B(), n = e ? t.children?.[e] : t;
640
+ if (!n)
641
+ throw new Error("Missing Form View for FormField" + (e ? ": " + e : ""));
642
+ return /* @__PURE__ */ r(A, { children: n.help && /* @__PURE__ */ r(
643
+ "div",
644
+ {
645
+ className: "form-text",
646
+ ...n.help_attr && (n.help_attr instanceof Function ? n.help_attr() : n.help_attr),
647
+ children: n.help
648
+ }
649
+ ) });
650
+ }, qt = ({ view: e, choice: t }) => {
651
+ const n = t.label instanceof Function ? t.label(t) : t.label;
652
+ return /* @__PURE__ */ r(
653
+ "option",
654
+ {
655
+ value: t.value || n,
656
+ ...t.attr && (t.attr instanceof Function ? t.attr(t) : t.attr),
657
+ children: /* @__PURE__ */ r(D, { children: n })
658
+ }
659
+ );
660
+ }, tr = ({ view: e, group: t }) => /* @__PURE__ */ r("optgroup", { label: t.label, children: Object.values(t.choices).map((n, o) => /* @__PURE__ */ r(qt, { view: e, choice: n }, o)) }), Re = ({
661
+ view: e,
662
+ choice: t,
663
+ choiceValueTransform: n,
664
+ choiceLabelTransform: o
665
+ }) => {
666
+ const s = e.full_name, i = n ? n(t) : t.value, a = o ? o(t) : t.label || i, c = _e(s || "", i), u = {
667
+ ...(e.label_attr instanceof Function ? e.label_attr() : e.label_attr) || {}
668
+ }, m = {
669
+ id: c,
670
+ ...(e.choice_attr instanceof Function ? e.choice_attr(e) : e.choice_attr) || {}
671
+ }, p = e.checked instanceof Function ? e.checked(i) : e.checked;
672
+ return /* @__PURE__ */ C(A, { children: [
673
+ /* @__PURE__ */ r(
674
+ "input",
675
+ {
676
+ defaultValue: i,
677
+ type: e?.multiple ? "checkbox" : "radio",
678
+ defaultChecked: e?.data?.includes(i),
679
+ name: (s || "") + (e?.multiple ? "[]" : ""),
680
+ id: c,
681
+ className: "form-check-input",
682
+ ...m,
683
+ checked: p
684
+ }
685
+ ),
686
+ /* @__PURE__ */ r(
687
+ "label",
688
+ {
689
+ htmlFor: m.id,
690
+ className: "form-check-label",
691
+ ...u,
692
+ children: /* @__PURE__ */ r(D, { children: a })
693
+ }
694
+ )
695
+ ] });
696
+ }, nr = ({ view: e, group: t, ...n }) => /* @__PURE__ */ C("div", { className: "form-group", children: [
697
+ /* @__PURE__ */ r("label", { className: "form-label", children: t.label }),
698
+ Object.values(t.choices).map((o, s) => /* @__PURE__ */ r(Re, { view: e, choice: o, ...n }, s))
699
+ ] }), rr = ({
272
700
  view: e,
273
701
  constraints: t,
274
702
  className: n,
275
- onChange: r,
276
- choiceValueTransform: o,
277
- choiceLabelTransform: a,
278
- ...c
703
+ onChange: o,
704
+ choiceValueTransform: s,
705
+ choiceLabelTransform: i
279
706
  }) => {
280
707
  t = t || [];
281
- const [[u, h], i] = Me(), m = R(null), l = !!((u == null ? void 0 : u.errors[e.full_name]) || []).length, b = btoa(encodeURIComponent(e.full_name + JSON.stringify(e.data)));
282
- v(() => {
283
- h({
708
+ const a = e.full_name, [[c, u], m] = me(), f = !!(c?.errors[a || ""] || []).length, y = {
709
+ ...(e.attr instanceof Function ? e.attr() : e.attr) || {}
710
+ }, E = btoa(encodeURIComponent(e.full_name + JSON.stringify(e.data))), _ = [
711
+ ...(y.class || "").split(" ") || [],
712
+ ...(n || "").split(" ") || [],
713
+ ...f ? ["is-invalid"] : []
714
+ ];
715
+ N(() => {
716
+ u({
284
717
  action: "constraints",
285
718
  payload: {
286
719
  name: e.full_name,
@@ -288,404 +721,654 @@ const ve = (e, t = null) => (e.replace(/[\[\]]/gi, "_").replace(/_+/gi, "_").rep
288
721
  }
289
722
  });
290
723
  }, []);
291
- const E = (d) => {
292
- h({ action: "validate", payload: e.full_name }), r && r(d);
724
+ const b = (l) => {
725
+ u({ action: "validate", payload: e.full_name }), o && o(l);
293
726
  };
294
- return e != null && e.expanded ? /* @__PURE__ */ s(k, { children: Object.values(e.choices || []).map(
295
- (d, p) => {
296
- var D;
297
- const C = ve(e.full_name, p), N = o ? o(d) : d.value, A = a ? a(d) : d.label || N, P = {
298
- id: C,
299
- ...(e == null ? void 0 : e.choice_attr) && ((e == null ? void 0 : e.choice_attr) instanceof Function ? e == null ? void 0 : e.choice_attr(d) : e == null ? void 0 : e.choice_attr)
300
- };
301
- return /* @__PURE__ */ _(
302
- "div",
727
+ return e?.expanded ? /* @__PURE__ */ C(A, { children: [
728
+ typeof e.placeholder == "string" && /* @__PURE__ */ r(A, { children: /* @__PURE__ */ r(
729
+ Re,
730
+ {
731
+ view: e,
732
+ choice: { label: e.placeholder, value: null }
733
+ }
734
+ ) }),
735
+ Object.values(e.choices || []).map(
736
+ (l, d) => /* @__PURE__ */ r(Se, { children: l.choices !== void 0 ? /* @__PURE__ */ r(
737
+ nr,
303
738
  {
304
- className: "form-check",
305
- children: [
306
- /* @__PURE__ */ s(
307
- "input",
308
- {
309
- ref: m,
310
- defaultValue: N,
311
- type: e != null && e.multiple ? "checkbox" : "radio",
312
- defaultChecked: (D = e == null ? void 0 : e.data) == null ? void 0 : D.includes(N),
313
- name: (e == null ? void 0 : e.full_name) + "[]",
314
- id: C,
315
- className: "form-check-input",
316
- ...P,
317
- onChange: (y) => {
318
- var O, M;
319
- return E({
320
- value: (e != null && e.multiple ? (O = i == null ? void 0 : i.current) == null ? void 0 : O.getFormData().getAll(e == null ? void 0 : e.full_name) : (M = i == null ? void 0 : i.current) == null ? void 0 : M.getFormData().get(e == null ? void 0 : e.full_name)) || y.target.value,
321
- targetValue: y.target.value,
322
- checked: y.target.checked
323
- });
324
- }
325
- },
326
- b
327
- ),
328
- /* @__PURE__ */ s(
329
- "label",
330
- {
331
- htmlFor: P.id,
332
- className: "form-check-label",
333
- children: A
334
- }
335
- )
336
- ]
337
- },
338
- p
339
- );
340
- }
341
- ) }) : /* @__PURE__ */ s(k, { children: /* @__PURE__ */ _(
739
+ view: e,
740
+ group: l,
741
+ choiceLabelTransform: i,
742
+ choiceValueTransform: s
743
+ }
744
+ ) : /* @__PURE__ */ r("div", { className: "form-check", ...y, children: /* @__PURE__ */ r(
745
+ Re,
746
+ {
747
+ view: e,
748
+ choice: l,
749
+ choiceLabelTransform: i,
750
+ choiceValueTransform: s
751
+ }
752
+ ) }) }, d)
753
+ )
754
+ ] }) : /* @__PURE__ */ C(
342
755
  "select",
343
756
  {
344
- ref: m,
345
- name: e.full_name,
757
+ name: a,
346
758
  multiple: e.multiple,
347
- "aria-invalid": l,
348
- onChange: (d) => {
349
- var p, C;
350
- return E({
351
- value: (e.multiple ? (p = i == null ? void 0 : i.current) == null ? void 0 : p.getFormData().getAll(e.full_name) : (C = i == null ? void 0 : i.current) == null ? void 0 : C.getFormData().get(e.full_name)) || d.target.value
352
- });
353
- },
354
- className: [...(n || "").split(" ") || [], "form-control", ...l ? ["is-invalid"] : []].join(" "),
759
+ "aria-invalid": f,
760
+ onChange: (l) => b({
761
+ value: (e.multiple ? m?.current?.getFormData().getAll(a) : m?.current?.getFormData().get(a)) || l.target.value
762
+ }),
763
+ className: [..._, "form-select"].join(" "),
355
764
  ...e.attr && (e.attr instanceof Function ? e.attr() : e.attr),
356
765
  defaultValue: e.data,
357
766
  children: [
358
- e.placeholder && /* @__PURE__ */ s("option", { value: "", children: e.placeholder }),
359
- Object.values(e.choices || []).map(
360
- (d, p) => /* @__PURE__ */ s(
361
- "option",
362
- {
363
- value: d.value || d.label,
364
- ...e.choice_attr && (e.choice_attr instanceof Function ? e.choice_attr(d) : e.choice_attr),
365
- children: d.label
366
- },
367
- p
368
- )
369
- )
767
+ e.placeholder && /* @__PURE__ */ r("option", { value: "", children: /* @__PURE__ */ r(D, { children: e.placeholder }) }),
768
+ Object.values(e.choices || []).map((l, d) => /* @__PURE__ */ r(Se, { children: l.choices !== void 0 ? /* @__PURE__ */ r(tr, { view: e, group: l }) : /* @__PURE__ */ r(qt, { view: e, choice: l }) }, d))
370
769
  ]
371
770
  },
372
- b
373
- ) });
374
- }, at = ({ name: e, className: t }) => {
375
- const [[n]] = Me(), r = (n == null ? void 0 : n.errors[e]) || [];
376
- return r.length ? /* @__PURE__ */ s("div", { className: t, children: r.map((o, a) => /* @__PURE__ */ s("span", { children: o.message }, a)) }) : /* @__PURE__ */ s(k, {});
377
- }, Ne = (e) => e.toLowerCase().replace(new RegExp("^.{1,1}"), (t) => t.toUpperCase()), Xt = (e) => {
378
- let t = e.replace(new RegExp("[-_]", "gi"), " ").split(new RegExp("(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])"));
379
- const n = t.shift(), r = t.pop();
380
- return t = t.map((o) => o.toLowerCase()), n && t.unshift(Ne(n)), r && t.push(Ne(r)), t.join(" ");
381
- }, en = ({
382
- view: e,
383
- children: t,
384
- className: n
385
- }) => {
386
- const r = (c, u = null) => c.replace(/[\[\]]/gi, "_").replace(/_+/gi, "_") + (u && u), o = e.label || Xt(e.name), a = ["checkbox", "radio"].includes(e.type || "input");
387
- return /* @__PURE__ */ _(
388
- "div",
389
- {
390
- className: [...(n == null ? void 0 : n.split(" ")) || [], "mb-3", a && "form-check"].filter((c) => c).join(" "),
391
- ...e.attr && (e.attr instanceof Function ? e.attr() : e.attr),
392
- children: [
393
- !a && /* @__PURE__ */ s(
394
- "label",
395
- {
396
- className: "form-label",
397
- ...e.label_attr && (e.label_attr instanceof Function ? e.label_attr() : e.label_attr),
398
- children: o
399
- }
400
- ),
401
- t,
402
- a && /* @__PURE__ */ s(
403
- "label",
404
- {
405
- className: "form-check-label",
406
- htmlFor: e.id || r(e.full_name),
407
- ...e.label_attr && (e.label_attr instanceof Function ? e.label_attr() : e.label_attr),
408
- children: o
409
- }
410
- ),
411
- /* @__PURE__ */ s(at, { name: e.full_name, className: "invalid-feedback" }),
412
- e.help && /* @__PURE__ */ s(
413
- "div",
414
- {
415
- className: "form-help",
416
- ...e.help_attr && (e.help_attr instanceof Function ? e.help_attr() : e.help_attr),
417
- children: e.help
418
- }
419
- )
420
- ]
421
- }
771
+ E
422
772
  );
423
- }, tn = ({
773
+ }, or = ({
424
774
  view: e,
425
775
  constraints: t,
426
- className: n,
427
- onChange: r
776
+ onChange: n,
777
+ ref: o
428
778
  }) => {
429
- const [[o, a]] = Me(), c = R(null), u = (o == null ? void 0 : o.errors[e.full_name]) || [];
430
- v(() => {
779
+ const s = e.full_name, [[i, a]] = me(), c = i?.errors[s || ""] || [];
780
+ N(() => {
431
781
  a({
432
782
  action: "constraints",
433
783
  payload: {
434
- name: e.full_name,
784
+ name: s,
435
785
  constraints: t || []
436
786
  }
437
787
  });
438
788
  }, []);
439
- const h = (l) => {
440
- a({ action: "validate", payload: e.full_name }), r && r(l);
441
- }, m = ["checkbox", "radio"].includes(e.type) ? "form-check-input" : "form-control", f = btoa(encodeURIComponent(e.full_name + JSON.stringify(e.data)));
442
- return /* @__PURE__ */ s(k, { children: /* @__PURE__ */ s(
789
+ const u = (l) => {
790
+ a({ action: "validate", payload: s }), n && n(l);
791
+ }, p = ["checkbox", "radio"].includes(e.type) ? "form-check-input" : "form-control", f = btoa(encodeURIComponent(s + JSON.stringify(e.data))), y = (e.attr instanceof Function ? e.attr() : e.attr) || {}, E = $t();
792
+ let _ = e.type, b = e.data;
793
+ if ([w.Date, w.Birthday, w.Datetime].includes(_)) {
794
+ const l = b?.date ? new Date(b.date) : null;
795
+ if (l) {
796
+ const d = l.getTimezoneOffset() * 6e4;
797
+ b = new Date(l.getTime() - d).toISOString().split("T").shift();
798
+ }
799
+ _ = _ === w.Datetime ? "datetime-local" : "date";
800
+ }
801
+ return /* @__PURE__ */ r(A, { children: /* @__PURE__ */ r(
443
802
  "input",
444
803
  {
445
- ref: c,
446
- id: e.id || ve(e.full_name),
447
- name: e.full_name,
448
- type: e.type,
449
- defaultValue: e.data,
450
- "aria-invalid": !u.length,
451
- onKeyUp: (l) => h({ value: l.target.value }),
452
- onChange: (l) => h({ value: l.target.value }),
453
- className: [m, ...u.length ? ["is-invalid"] : []].join(" "),
454
- defaultChecked: e == null ? void 0 : e.checked,
455
- ...e.attr && (e.attr instanceof Function ? e.attr() : e.attr)
804
+ ref: o,
805
+ id: e.id,
806
+ name: s,
807
+ type: _,
808
+ defaultValue: b,
809
+ "aria-invalid": !c.length,
810
+ onInput: (l) => {
811
+ y.onChange instanceof Function && y.onChange(l), !l.defaultPrevented && u({ value: l.target.value });
812
+ },
813
+ className: E?.className || [
814
+ p,
815
+ E?.size ? "form-control-" + E.size : null,
816
+ E?.extraClassName,
817
+ ...c.length ? ["is-invalid"] : []
818
+ ].filter((l) => l).join(" "),
819
+ defaultChecked: e?.checked,
820
+ placeholder: E?.placeholder || e?.placeholder || void 0,
821
+ ...y,
822
+ ...y.inputmode === "decimal" && { step: "any" }
456
823
  },
457
824
  f
458
825
  ) });
459
- }, nn = ({
826
+ }, Ht = v.createContext({
827
+ requests: []
828
+ });
829
+ function sr(e) {
830
+ const t = v.useContext(Ht);
831
+ if (t === void 0)
832
+ throw new Error("UseLoaderIndicator must be within DataLoaderIndicatorProvider");
833
+ const { requests: n } = t, { matchPath: o, getActionByPath: s, generateActionLink: i } = j();
834
+ let a = null;
835
+ if (e) {
836
+ const u = s(e?.toString() ?? "");
837
+ if (u) {
838
+ const m = pt(new URL(e, location.origin).searchParams), { params: p } = o(u.route?.path || "", e) ?? { params: void 0 };
839
+ a = i({ action: u, parameters: p, query: m });
840
+ }
841
+ }
842
+ return {
843
+ isLoading: a ? !!n.filter((u) => u.url === a).length : !1
844
+ };
845
+ }
846
+ function ir({ ...e }) {
847
+ const [t, n] = W((o, s) => {
848
+ const { action: i, requestId: a, url: c } = s, u = new URL(c), m = u.toString().replace(u.origin, "");
849
+ switch (o = { requests: o.requests.filter((p) => p.requestId !== a) }, i) {
850
+ case "cancel":
851
+ case "complete":
852
+ break;
853
+ default:
854
+ o.requests.push({ url: m, requestId: a }), o = { requests: o.requests };
855
+ }
856
+ return o;
857
+ }, { requests: [] });
858
+ return N(() => {
859
+ const o = K.on(Ne.PRE_REQUEST, (a, c, u) => {
860
+ n({ action: "load", requestId: a, url: c.toString() });
861
+ }), s = K.on(Ne.POST_RESPONSE, (a, c, u, m) => {
862
+ n({ action: "complete", requestId: a, url: u.toString() });
863
+ }), i = K.on(Ne.ERROR, (a, c, u, m) => {
864
+ n({ action: "cancel", requestId: a, url: u.toString() });
865
+ });
866
+ return () => {
867
+ K.off(o).off(s).off(i);
868
+ };
869
+ }, []), /* @__PURE__ */ r(Ht.Provider, { value: t, children: e.children });
870
+ }
871
+ const M = ({ to: e, children: t, onClick: n, ...o }) => {
872
+ const { navigate: s } = j(), i = S(null), [a, c] = R(!1), { isLoading: u } = sr(e?.toString()), m = (f) => {
873
+ if (u) {
874
+ f.preventDefault(), f.stopPropagation();
875
+ return;
876
+ }
877
+ c(!0), n && n(f), !f.defaultPrevented && e && (f.preventDefault(), s(e.toString()));
878
+ };
879
+ return N(() => {
880
+ a && (u || c(!1));
881
+ }, [u]), N(() => (i?.current?.addEventListener("click", m), () => {
882
+ i?.current?.removeEventListener("click", m);
883
+ }), [e, n]), /* @__PURE__ */ r("a", { ref: i, href: e, ...o, children: /* @__PURE__ */ r(Pt, { preload: a && u, ...o, children: t }) });
884
+ }, Kt = v.createContext(void 0), Gt = () => {
885
+ const e = v.useContext(Kt);
886
+ if (!e)
887
+ throw new Error("UseCollection must be used within a Collection");
888
+ return e;
889
+ }, ar = ({
460
890
  view: e
461
- }) => /* @__PURE__ */ s(en, { className: "mb-3", view: e, children: (() => {
891
+ }) => {
892
+ const t = Object.keys(e.children || []), [n, o] = W((c, u) => {
893
+ const { action: m, value: p } = u;
894
+ switch (m) {
895
+ case "delete": {
896
+ if (p && typeof p != "string")
897
+ throw new Error("Invalid value. Should be a string.");
898
+ c = [...c.filter((f) => f !== p)];
899
+ break;
900
+ }
901
+ case "set": {
902
+ if (!(p instanceof Array))
903
+ throw new Error("Invalid value. Should be a array.");
904
+ c = p;
905
+ break;
906
+ }
907
+ default: {
908
+ if (p && typeof p != "string")
909
+ throw new Error("Invalid value. Should be a string.");
910
+ const f = Math.floor(Math.random() * Date.now());
911
+ c = [...c, f.toString()];
912
+ }
913
+ }
914
+ return c;
915
+ }, t), s = !!e.prototype, i = () => o({ action: "add" }), a = (c) => {
916
+ o({ action: "delete", value: c });
917
+ };
918
+ return N(() => {
919
+ o({ action: "set", value: t });
920
+ }, [JSON.stringify(t)]), /* @__PURE__ */ r(Kt.Provider, { value: {
921
+ addItem: i,
922
+ removeItem: a,
923
+ items: n,
924
+ isPrototype: s
925
+ }, children: /* @__PURE__ */ C(
926
+ U,
927
+ {
928
+ prefix: "modify/form",
929
+ view: [...e.block_prefixes || [], e.name + ".collection"],
930
+ children: [
931
+ /* @__PURE__ */ r(cr, {}),
932
+ s && /* @__PURE__ */ r(
933
+ M,
934
+ {
935
+ onClick: () => i(),
936
+ className: "btn btn-outline-primary btn-sm",
937
+ children: "+ Add"
938
+ }
939
+ )
940
+ ]
941
+ },
942
+ e.full_name
943
+ ) });
944
+ }, cr = () => {
945
+ const { items: e } = Gt(), { form: t } = B(), n = !!t.prototype, o = (s, i) => {
946
+ if (s.prototype_name) {
947
+ const a = s.full_name?.replace("__name__", s.prototype_name || "") || "", c = (s.id || _e(a)).replace("__name__", s.prototype_name || ""), u = s.label?.replace("__name__label__", i.toString()) || "";
948
+ s.full_name = a, s.id = c, s.label = s.label?.replace("__name__label__", u), Object.keys(s.children || {}).map((m, p) => {
949
+ const f = s.children?.[m];
950
+ f !== void 0 && (f.prototype_name || (f.prototype_name = s.prototype_name, o(f, p)));
951
+ }, {});
952
+ }
953
+ };
954
+ return /* @__PURE__ */ r(A, { children: e.map((s, i) => {
955
+ const a = JSON.parse(JSON.stringify(t.children?.[s] ?? (t.prototype || t)));
956
+ return a ? (t.children?.[s] === void 0 && (a.prototype_name = s), o(a, i), /* @__PURE__ */ r(lr, { index: i, view: a, isPrototype: n })) : null;
957
+ }) });
958
+ }, Yt = v.createContext(void 0), Uo = () => {
959
+ const e = v.useContext(Yt);
960
+ if (!e)
961
+ throw new Error("UseCollectionItem must be used within a CollectionItem");
962
+ return e;
963
+ }, lr = ({ view: e, index: t, isPrototype: n }) => {
964
+ const { removeItem: o } = Gt(), { form: s } = Qt() || { form: e }, i = e.prototype_name || e.name || "";
965
+ return /* @__PURE__ */ r(re, { view: e, allowDuplicates: n, children: /* @__PURE__ */ r(Yt.Provider, { value: { index: t, removeItem: () => o(i) }, children: /* @__PURE__ */ r(
966
+ U,
967
+ {
968
+ prefix: "modify/form",
969
+ view: [...e.block_prefixes || [], s.name + ".item"],
970
+ children: /* @__PURE__ */ C("div", { className: "mb-3", children: [
971
+ /* @__PURE__ */ r(zt, { view: e }),
972
+ n && /* @__PURE__ */ r(
973
+ M,
974
+ {
975
+ to: "#",
976
+ onClick: () => o(i),
977
+ className: "btn btn-outline-danger btn-sm",
978
+ children: /* @__PURE__ */ r(D, { children: "Delete" })
979
+ }
980
+ )
981
+ ] })
982
+ }
983
+ ) }) });
984
+ }, rt = ({ view: e, ref: t }) => {
462
985
  switch (e.type) {
463
- case "entity":
464
- case "choice":
465
- case "collection":
466
- case "enum":
467
- return /* @__PURE__ */ s(Zt, { view: e });
986
+ case w.Entity:
987
+ case w.Choice:
988
+ case w.Currency:
989
+ case w.Language:
990
+ case w.Enum:
991
+ return /* @__PURE__ */ r(rr, { view: e });
992
+ case w.Collection:
993
+ return /* @__PURE__ */ r(ar, { view: e });
994
+ case w.Hidden:
995
+ case w.Input:
996
+ case w.Money:
997
+ case w.Text:
998
+ case w.Tel:
999
+ case w.Checkbox:
1000
+ case w.Radio:
1001
+ case w.Integer:
1002
+ case w.Number:
1003
+ case w.Password:
1004
+ case w.Datetime:
1005
+ case w.Date:
1006
+ case w.Birthday:
1007
+ case w.Time:
1008
+ case w.Email:
1009
+ return /* @__PURE__ */ r(or, { view: e, ref: t });
1010
+ case w.Repeated:
1011
+ case w.Form:
1012
+ return /* @__PURE__ */ r(pe, {});
468
1013
  default:
469
- return /* @__PURE__ */ s(tn, { view: e });
470
- }
471
- })() }), Ye = ({ children: e }) => /* @__PURE__ */ s(k, { children: e }), G = W(({ namespace: e, view: t, prefix: n, children: r, props: o, data: a }) => {
472
- t = t.split(/[._]/).map((b) => Ne(b)).join("");
473
- const c = /* @__PURE__ */ Object.assign({}), u = ["crud", e, n, t].filter((b) => b).join("/") + ".tsx", [h, i] = Object.entries(c).filter(([b, E]) => b.endsWith(u)).shift() || [], [m, f] = $(1), l = R(Ye);
474
- return v(() => {
475
- if (i === void 0)
476
- return () => {
477
- };
478
- i().then((b) => {
479
- l.current = b.default, f(m + 1);
1014
+ throw new Error("Invalid view type: " + e.type);
1015
+ }
1016
+ }, ot = ({ name: e, options: t, ref: n }) => {
1017
+ const { form: o } = B(), s = e ? o.children?.[e] : o;
1018
+ if (!s)
1019
+ throw new Error("Missing Form View for FormField" + (e ? ": " + e : ""));
1020
+ const i = { ...s, ...t || {} };
1021
+ return e !== void 0 ? /* @__PURE__ */ r(re, { view: i, children: /* @__PURE__ */ r(rt, { view: i, ref: n }) }) : /* @__PURE__ */ r(A, { children: /* @__PURE__ */ r(rt, { view: i, ref: n }) });
1022
+ }, Wt = ({ name: e, className: t }) => {
1023
+ const [[n]] = me() || {};
1024
+ e = e instanceof Array ? e : [e];
1025
+ const o = [].concat(...e.map((s) => n?.errors[s] || []));
1026
+ return o.length ? /* @__PURE__ */ r("div", { className: t, children: /* @__PURE__ */ r("ul", { className: "mb-0", children: o.map((s, i) => /* @__PURE__ */ r("li", { children: s.message }, i)) }) }) : null;
1027
+ }, dr = ({ name: e, className: t }) => {
1028
+ const { form: n, getRootViewContext: o } = B(), s = e ? (e instanceof Array ? e : [e]).map((i) => {
1029
+ const a = i ? n.children?.[i] : n;
1030
+ if (!a)
1031
+ throw new Error("Missing Form View for FormError: " + (i || ""));
1032
+ return a;
1033
+ }) : [n];
1034
+ return N(() => {
1035
+ s.forEach((i) => {
1036
+ i.full_name && o().setRenderedError(i.full_name);
480
1037
  });
481
- }, []), /* @__PURE__ */ s(l.current, { ...o, view: t, controller: e, viewName: t, data: a, parent: r, children: (!i || l.current !== Ye) && r });
482
- }), Fe = W(({ view: e, namespace: t, name: n }) => e && /* @__PURE__ */ s(
483
- G,
484
- {
485
- namespace: t,
486
- view: n || e.name || "form",
487
- prefix: "modify/form",
488
- data: e,
489
- children: Object.keys(e.children || []).length ? Object.values(e.children || []).map((r) => /* @__PURE__ */ s(Fe, { namespace: t, view: r }, r.id)) : /* @__PURE__ */ s(nn, { view: e }, e.id)
490
- },
491
- e.id
492
- )), ct = ({ icon: e, rightIcon: t, rightIconProps: n, children: r, preload: o = !1 }) => /* @__PURE__ */ s(k, { children: r && r }), me = ie(({
493
- children: e,
494
- preload: t,
495
- ...n
496
- }, r) => /* @__PURE__ */ s("button", { disabled: t, ...n, ref: r, children: /* @__PURE__ */ s(ct, { preload: t, ...n, children: e }) })), rn = S.createContext(null);
497
- function sn() {
498
- return S.useContext(rn);
1038
+ }, []), /* @__PURE__ */ r(Wt, { name: s.map((i) => i.full_name || ""), className: t });
1039
+ }, zt = ({
1040
+ view: e,
1041
+ className: t,
1042
+ size: n,
1043
+ type: o
1044
+ }) => {
1045
+ const s = [w.Checkbox, w.Radio].includes(e.type);
1046
+ return e.type = o || e.type, /* @__PURE__ */ r(A, { children: e.type === w.Hidden ? /* @__PURE__ */ r(ot, {}) : /* @__PURE__ */ C(
1047
+ "div",
1048
+ {
1049
+ className: [...t?.split(" ") || [s ? "form-check" : "mb-3"]].filter((i) => i).join(" "),
1050
+ ...e.attr && (e.attr instanceof Function ? e.attr() : e.attr),
1051
+ children: [
1052
+ !s && /* @__PURE__ */ r(De, { view: e }),
1053
+ /* @__PURE__ */ r(ot, { size: n }),
1054
+ s && /* @__PURE__ */ r(De, { view: e }),
1055
+ /* @__PURE__ */ r(dr, { className: "invalid-feedback" }),
1056
+ /* @__PURE__ */ r(er, {})
1057
+ ]
1058
+ }
1059
+ ) });
1060
+ }, pe = X(() => {
1061
+ const e = Ce(), { form: t } = B();
1062
+ return /* @__PURE__ */ r(Xn, { id: e, view: t, children: /* @__PURE__ */ r(
1063
+ U,
1064
+ {
1065
+ view: [(t.name || "form") + "Field", ...t.block_prefixes || []],
1066
+ prefix: "modify/form",
1067
+ data: t,
1068
+ children: [w.Form, w.Repeated].includes(t?.type) ? Object.values(t.children || []).map((n, o) => /* @__PURE__ */ r(Se, { children: /* @__PURE__ */ r(re, { view: n, children: /* @__PURE__ */ r(pe, {}) }, o) }, o)) : /* @__PURE__ */ r(A, { children: /* @__PURE__ */ r(zt, { view: t }) })
1069
+ }
1070
+ ) });
1071
+ }), ur = () => /* @__PURE__ */ r(pe, {}), mr = ({ className: e }) => {
1072
+ const [[t]] = me() || {}, { getRootViewContext: n, getParentViewContext: o, getElements: s } = B(), a = (() => {
1073
+ let u = Object.keys(s?.() || []), m = o?.() || null;
1074
+ for (; m !== null; )
1075
+ u = [
1076
+ ...u,
1077
+ ...Object.keys(m.getElements?.() || [])
1078
+ ], m = m.getParentViewContext();
1079
+ return u;
1080
+ })(), c = Object.keys(t?.errors || []).filter((u) => a.includes(u)).filter((u) => !n().getRenderedErrors().includes(u));
1081
+ return /* @__PURE__ */ r(Wt, { name: c, className: e });
1082
+ }, Te = v.createContext(void 0), He = () => {
1083
+ const e = v.useContext(Te);
1084
+ if (!e)
1085
+ throw new Error("UseTemplate must be used inside Template");
1086
+ return e;
1087
+ }, fr = ({ name: e, children: t }) => {
1088
+ const n = v.useContext(Te), [o, s] = W((i, a) => {
1089
+ if (a.template && a.template !== e)
1090
+ return n?.dispatch(a), i;
1091
+ const c = i[a.block] || [], u = a.element || null;
1092
+ if (a.action === "set") {
1093
+ const m = c.find((p) => p.id === a.id);
1094
+ m ? m.element = u : c.push({
1095
+ id: a.id,
1096
+ element: u
1097
+ });
1098
+ } else
1099
+ c.filter((m) => m.id === a.id).forEach((m) => {
1100
+ m.element = null;
1101
+ });
1102
+ return {
1103
+ ...i,
1104
+ [a.block]: c
1105
+ };
1106
+ }, {});
1107
+ return /* @__PURE__ */ r(Te.Provider, { value: {
1108
+ name: e,
1109
+ blocks: o,
1110
+ getBlock: (i, a) => a && a !== e ? n?.getBlock(i, a) : [...o[i] || []].pop()?.element,
1111
+ getParent: (i) => [...o[i] || []].slice(-2).shift()?.element,
1112
+ dispatch: s
1113
+ }, children: t });
1114
+ }, Jt = v.createContext(void 0), T = ({ name: e, template: t, children: n }) => {
1115
+ const { getBlock: o } = He(), s = o(e, t);
1116
+ return /* @__PURE__ */ r(Jt.Provider, { value: { name: e, children: n }, children: s === void 0 ? n : s });
1117
+ }, H = ({ name: e, template: t, children: n }) => {
1118
+ const o = Ce(), { dispatch: s } = He(), i = () => {
1119
+ s({
1120
+ id: o,
1121
+ action: "unset",
1122
+ template: t,
1123
+ block: e
1124
+ });
1125
+ };
1126
+ return N(() => (s({
1127
+ id: o,
1128
+ action: "set",
1129
+ block: e,
1130
+ template: t,
1131
+ element: n
1132
+ }), () => {
1133
+ i();
1134
+ }), [n]), N(() => () => {
1135
+ i();
1136
+ }, []), null;
1137
+ }, Vo = () => {
1138
+ const { name: e, children: t } = v.useContext(Jt) || {}, { name: n, getParent: o } = He();
1139
+ return (e ? o(e) : null) || t || null;
1140
+ };
1141
+ function xe(e, t) {
1142
+ return (n) => /* @__PURE__ */ C(fr, { name: t.name, children: [
1143
+ /* @__PURE__ */ r(e, { ...n }),
1144
+ n.children
1145
+ ] });
499
1146
  }
500
- const it = ({ entityAction: e, initParameters: t, initQueryParameters: n }) => {
501
- const { getAction: r } = Re();
502
- e = r(e.entity, e.name, e.namespace) || e;
503
- const [o, a] = $(), [c, u] = $(t || null), [h, i] = $(new URLSearchParams(n || {}));
504
- R(null), btoa(encodeURIComponent([e.entity, e.name, e.namespace, ...Object.entries(c || {}).map(([l, b]) => l + "-" + b), (h instanceof URLSearchParams ? h : nt(h)).toString()].filter((l) => l).join("."))), R({});
505
- const [m, f] = $(1);
506
- return v(() => {
507
- e && ce().get(Y(e.route, c ?? null), h).then((l) => l.getData().then((b) => {
508
- switch (l.status) {
509
- case 201:
510
- case 200: {
511
- a(b);
512
- break;
513
- }
514
- default: {
515
- const E = b;
516
- throw new Q(E.status, E.detail, E.trace);
517
- }
518
- }
519
- }));
520
- }, [JSON.stringify(c), h.toString(), m]), {
521
- results: o,
522
- setParameters: u,
523
- setQueryParameters: (l) => {
524
- i(new URLSearchParams(l));
1147
+ const Ke = v.createContext(void 0), re = ({ view: e, allowDuplicates: t, children: n }) => {
1148
+ const o = Qt(), {
1149
+ form: s,
1150
+ getParentViewContext: i,
1151
+ getElements: a,
1152
+ allowDuplicates: c,
1153
+ unsetRendered: u
1154
+ } = o || {}, m = S(a?.() || {}), p = S([]), [, f] = me(), y = Zn(), E = (l, d) => {
1155
+ const g = l ? l.split(".").reduce((h, x) => h?.children?.[x] || null, e) : e;
1156
+ g && (g.data = d, f.current?.setValue(g.full_name, d));
1157
+ }, b = {
1158
+ form: e,
1159
+ setRendered: (l, d) => {
1160
+ l.full_name && m.current[l.full_name] === void 0 && (m.current[l.full_name] = d);
525
1161
  },
526
- refresh: () => {
527
- f(m + 1);
528
- }
1162
+ unsetRendered: (l, d) => {
1163
+ l.full_name && m.current[l.full_name] === d && delete m.current[l.full_name], u?.(l, d);
1164
+ },
1165
+ canRender: (l, d) => t ? !0 : y?.view.full_name === l.full_name || o?.form.full_name === l.full_name || Object.values(m.current).includes(d),
1166
+ setValue: E,
1167
+ setValues: (l) => {
1168
+ Object.keys(l).map((d) => E(d, l[d]));
1169
+ },
1170
+ getElements: () => m.current,
1171
+ allowDuplicates: t,
1172
+ getParentViewContext: () => o || null,
1173
+ getRootViewContext: () => o?.getRootViewContext() || o || b,
1174
+ setRenderedError: (l) => {
1175
+ p.current.includes(l) || p.current.push(l);
1176
+ },
1177
+ isRenderedError: (l) => p.current.includes(l),
1178
+ getRenderedErrors: () => p.current
529
1179
  };
530
- }, Ce = W(({ children: e }) => /* @__PURE__ */ s(k, { children: e })), on = ie(({ name: e, data: t, action: n, parameters: r, onSuccess: o, onError: a, onLoad: c, children: u, embedded: h = !1 }, i) => {
531
- var P, D, y, O, M;
532
- const [m, f] = $(!1), l = Ut(), b = Y(n.route, r || {}), E = R(null), d = sn(), [p, C] = $();
533
- je(i, () => ({
534
- getData: () => p,
1180
+ return /* @__PURE__ */ r(Ke.Provider, { value: b, children: /* @__PURE__ */ r(pr, { children: n }) });
1181
+ }, pr = ({ children: e }) => {
1182
+ const t = Ce(), [n, o] = R(null), { form: s, unsetRendered: i, setRendered: a, canRender: c } = B();
1183
+ return N(() => (a?.(s, t), o(t), () => {
1184
+ i?.(s, t), o(null);
1185
+ }), []), !n || !c?.(s, n) ? /* @__PURE__ */ r(A, {}) : /* @__PURE__ */ r(A, { children: e });
1186
+ };
1187
+ function B() {
1188
+ const e = v.useContext(Ke);
1189
+ if (!e)
1190
+ throw new Error("UseFormView must be used within a FormViewProvider.");
1191
+ return e;
1192
+ }
1193
+ function Qt() {
1194
+ return v.useContext(Ke);
1195
+ }
1196
+ const hr = xe(de(({ onSuccess: e, onError: t, onLoad: n, embedded: o = !1 }, s) => {
1197
+ const { navigate: i, generateLink: a, generateActionLink: c } = j(), { action: u, setAction: m } = te(), p = c(u), [f, y] = R(null), E = S(null), _ = ne(), { startLoading: b, stopLoading: l } = Ot() || {}, d = S(null), [g, h] = R(null);
1198
+ ue(s, () => ({
535
1199
  getFormRef: () => E.current
536
1200
  }));
537
- const N = (x) => {
538
- var F, g;
539
- let L = {
540
- ...(F = x.errors) != null && F.length ? { [x.full_name]: x.errors } : {}
541
- };
542
- for (let [, T] of Object.entries((x == null ? void 0 : x.children) || []))
543
- T.children && Object.values(T.children).length ? L = { ...L, ...N(T) } : (g = T.errors) != null && g.length && (L[T.full_name] = T.errors);
544
- return L;
545
- }, A = (x) => {
546
- f(!0), ce().post(b, x, Mt.FormData).then((L) => L.getData().then((F) => [200, 201, 400].includes(L.status) ? F : Promise.reject(F))).then((L) => {
547
- var g;
548
- C(L);
549
- const F = N(L.form.modify.view);
550
- if (Object.entries(F).length) {
551
- (g = E.current) == null || g.setErrors(F);
552
- return;
553
- }
554
- o && o(L), L.redirect && !h && l(Y(L.redirect.route, { ...r || {}, ...L.redirect.parameters }));
555
- }).catch((L) => {
556
- a && a(L);
557
- }).finally(() => {
558
- f(!1);
559
- });
1201
+ const x = (O) => {
1202
+ let k = (O.errors || []).reduce((F, se) => {
1203
+ const Xe = se.origin || O.full_name || "";
1204
+ return { ...F, [Xe]: [...F[Xe] || [], se] };
1205
+ }, {});
1206
+ for (let [, F] of Object.entries(O?.children || []))
1207
+ k = { ...k, ...x(F) };
1208
+ return k;
1209
+ }, P = (O) => {
1210
+ b?.(L?.full_name || "form"), d.current = setTimeout(() => l?.(L?.full_name || "form"), 250), h(O);
560
1211
  };
561
- return v(() => {
562
- c && c();
563
- }, []), t = (d == null ? void 0 : d.results) ?? t, v(() => {
564
- C(t);
565
- }, [JSON.stringify(t)]), p && /* @__PURE__ */ _(k, { children: [
566
- Object.keys((p == null ? void 0 : p.messages) || {}).map((x, L) => /* @__PURE__ */ s("div", { className: ["alert", "alert-" + x].join(" "), children: ((p == null ? void 0 : p.messages[x]) || ["Item was saved successful."]).join(" ") }, "alert-" + x)),
567
- /* @__PURE__ */ _(ot, { id: (y = (D = (P = p == null ? void 0 : p.form) == null ? void 0 : P.modify) == null ? void 0 : D.view) == null ? void 0 : y.id, ref: E, action: b, method: "POST", onSubmit: A, children: [
568
- ((M = (O = p == null ? void 0 : p.form) == null ? void 0 : O.modify) == null ? void 0 : M.view) !== void 0 && /* @__PURE__ */ _(k, { children: [
569
- /* @__PURE__ */ s(
570
- Fe,
1212
+ N(() => {
1213
+ g && (d.current && clearTimeout(d.current), m({
1214
+ ...u,
1215
+ method: $e.POST,
1216
+ body: g,
1217
+ bodyType: ht.FormData
1218
+ }));
1219
+ }, [g ? JSON.stringify(Be(g)) : null]), N(() => {
1220
+ n && n();
1221
+ }, []), N(() => {
1222
+ const O = _?.results?.form?.modify?.view;
1223
+ if (!O)
1224
+ return;
1225
+ const k = _.results, F = x(O);
1226
+ if (y(k), l?.(O?.full_name || "form"), E.current?.setErrors(F), !O.submitted || _?.status !== 200 || Object.entries(F).length)
1227
+ return;
1228
+ E.current?.success();
1229
+ const se = () => {
1230
+ k.redirect && !o && i(a(k.redirect.route, { ...u.parameters || {}, ...k.redirect.parameters }), !0);
1231
+ };
1232
+ e ? e(k).then(() => se()) : se();
1233
+ }, [_?.results]);
1234
+ const L = f?.form?.modify?.view;
1235
+ if (L)
1236
+ return /* @__PURE__ */ r($n, { loader: L.full_name, children: /* @__PURE__ */ r(
1237
+ At,
1238
+ {
1239
+ ref: E,
1240
+ id: L.id || "form",
1241
+ name: L.name || "form",
1242
+ action: p,
1243
+ method: "POST",
1244
+ onSubmit: P,
1245
+ children: /* @__PURE__ */ r(re, { view: L, children: /* @__PURE__ */ r(T, { name: "content", children: /* @__PURE__ */ C(
1246
+ U,
571
1247
  {
572
- name: e,
573
- namespace: n.namespace,
574
- view: p.form.modify.view
1248
+ view: L.name || "form",
1249
+ prefix: "modify/form",
1250
+ data: L,
1251
+ children: [
1252
+ /* @__PURE__ */ r(T, { name: "messages", children: Object.keys(f?.messages || {}).map((O, k) => /* @__PURE__ */ r(
1253
+ "div",
1254
+ {
1255
+ className: ["alert", "alert-" + O].join(" "),
1256
+ children: (f?.messages[O] || ["Item was saved successful."]).join(" ")
1257
+ },
1258
+ "alert-" + O
1259
+ )) }),
1260
+ /* @__PURE__ */ r(mr, { className: "alert alert-danger" }),
1261
+ /* @__PURE__ */ r(ur, {}),
1262
+ /* @__PURE__ */ r(T, { name: "actions", children: /* @__PURE__ */ r(fe, { type: "submit", className: "btn btn-primary", children: /* @__PURE__ */ r(D, { children: "Save" }) }) })
1263
+ ]
575
1264
  },
576
- p.form.modify.view.id
577
- ),
578
- /* @__PURE__ */ s(at, { name: p.form.modify.view.full_name, className: "alert alert-danger" })
579
- ] }),
580
- /* @__PURE__ */ s(V, { name: "actions", content: u, data: { formRef: E }, children: /* @__PURE__ */ s(me, { type: "submit", className: "btn btn-primary", children: /* @__PURE__ */ s(Ce, { children: "Save" }) }) })
581
- ] })
582
- ] });
583
- }), lt = ie(({
1265
+ L.id || "form"
1266
+ ) }) })
1267
+ }
1268
+ ) });
1269
+ }), { name: "form" }), Zt = xe(de(({
584
1270
  children: e,
585
- open: t = !1,
586
- animation: n = "fade",
587
- backdrop: r = !0,
588
- keyboard: o = !0,
589
- size: a,
590
- onClose: c,
591
- className: u
592
- }, h) => {
593
- const [i, m] = $(t);
594
- je(h, () => ({
595
- toggle: () => m(!i),
596
- open: () => m(!0),
597
- close: () => d(),
598
- isOpen: () => i
599
- })), v(() => {
600
- m(t);
601
- }, [t]);
602
- const f = (p) => {
603
- if (o)
604
- switch (p.key) {
1271
+ ...t
1272
+ }, n) => {
1273
+ const { closeModal: o, modal: s } = Qe(), {
1274
+ open: i = !0,
1275
+ animation: a = "fade",
1276
+ backdrop: c = !0,
1277
+ keyboard: u = !0,
1278
+ size: m,
1279
+ onClose: p,
1280
+ className: f
1281
+ } = { ...t, ...s?.props || {} }, [y, E] = R(i);
1282
+ ue(n, () => ({
1283
+ toggle: () => E(!y),
1284
+ open: () => E(!0),
1285
+ close: () => g(),
1286
+ isOpen: () => y
1287
+ })), N(() => {
1288
+ E(i);
1289
+ }, [i]);
1290
+ const _ = (h) => {
1291
+ if (u)
1292
+ switch (h.key) {
605
1293
  case "Escape": {
606
- d();
1294
+ g();
607
1295
  break;
608
1296
  }
609
1297
  }
610
1298
  };
611
- v(() => {
612
- var N;
613
- if (!i)
1299
+ N(() => {
1300
+ if (!y)
614
1301
  return;
615
- const p = () => {
616
- var A;
617
- (A = l.current) == null || A.addEventListener("animationend", C);
618
- }, C = () => {
619
- var A, P, D;
620
- (A = l.current) == null || A.classList.remove(n), (P = l.current) == null || P.removeEventListener("animationstart", p), (D = l.current) == null || D.removeEventListener("animationend", C);
1302
+ const h = () => {
1303
+ b.current?.addEventListener("animationend", x);
1304
+ }, x = () => {
1305
+ b.current?.classList.remove(a), b.current?.removeEventListener("animationstart", h), b.current?.removeEventListener("animationend", x);
621
1306
  };
622
1307
  return setTimeout(() => {
623
- var A, P;
624
- (A = l.current) == null || A.classList.add("d-block", "show"), (P = b == null ? void 0 : b.current) == null || P.classList.add("show");
625
- }, n ? 100 : 0), document.addEventListener("keydown", f), (N = l.current) == null || N.addEventListener("animationstart", p), () => {
626
- var A, P;
627
- document.removeEventListener("keydown", f), (A = l.current) == null || A.removeEventListener("animationstart", p), (P = l.current) == null || P.removeEventListener("animationend", C);
1308
+ b.current?.classList.add("d-block", "show"), l?.current?.classList.add("show");
1309
+ }, a ? 100 : 0), document.addEventListener("keydown", _), b.current?.addEventListener("animationstart", h), () => {
1310
+ document.removeEventListener("keydown", _), b.current?.removeEventListener("animationstart", h), b.current?.removeEventListener("animationend", x);
628
1311
  };
629
- }, [i]);
630
- const l = R(null), b = R(null), E = () => {
631
- m(!1), c && c();
632
- }, d = () => new Promise((p, C) => {
633
- var A, P;
634
- if (!i)
635
- return p();
636
- const N = () => {
637
- var D;
638
- (D = l == null ? void 0 : l.current) == null || D.classList.remove("show", "d-block"), p(), E();
1312
+ }, [y]);
1313
+ const b = S(null), l = S(null), d = () => {
1314
+ E(!1), o?.();
1315
+ }, g = () => new Promise((h, x) => {
1316
+ if (!y)
1317
+ return h();
1318
+ const P = () => {
1319
+ b?.current?.classList.remove("show", "d-block"), h(), d();
639
1320
  };
640
- if (n) {
641
- const D = setTimeout(() => {
642
- N();
643
- }, n ? 50 : 0);
644
- (A = l.current) == null || A.addEventListener("animationstart", () => {
645
- var y, O;
646
- console.log("timeout"), clearTimeout(D), (y = l.current) == null || y.removeEventListener("animationend", N), (O = l.current) == null || O.addEventListener("animationend", N);
647
- }), (P = l.current) == null || P.classList.add(n, "close");
1321
+ if (a) {
1322
+ const L = setTimeout(() => {
1323
+ P();
1324
+ }, a ? 50 : 0);
1325
+ b.current?.addEventListener("animationstart", () => {
1326
+ clearTimeout(L), b.current?.removeEventListener("animationend", P), b.current?.addEventListener("animationend", P);
1327
+ }), b.current?.classList.add(a, "close");
648
1328
  } else
649
- N();
1329
+ P();
650
1330
  });
651
- return i && wt(/* @__PURE__ */ _(k, { children: [
652
- /* @__PURE__ */ s(
1331
+ return N(() => () => {
1332
+ p && p();
1333
+ }, []), y && Tn(/* @__PURE__ */ C(A, { children: [
1334
+ /* @__PURE__ */ r(
653
1335
  "div",
654
1336
  {
655
- ref: l,
656
- className: ["modal", a && "modal-" + a, n && n, u].filter((p) => p).join(" "),
657
- children: /* @__PURE__ */ s("div", { className: "modal-dialog modal-dialog-centered", role: "document", children: /* @__PURE__ */ _("div", { className: "modal-content", children: [
658
- /* @__PURE__ */ s(V, { name: "header", content: e, data: null, children: /* @__PURE__ */ _("div", { className: "modal-header", children: [
659
- /* @__PURE__ */ s("h5", { className: "modal-title", id: "exampleModalLabel", children: /* @__PURE__ */ s(V, { name: "title", content: e, data: null, children: "Title" }) }),
660
- /* @__PURE__ */ s("button", { onClick: d, type: "button", className: "btn-close", "aria-label": "Close" })
1337
+ ref: b,
1338
+ className: ["modal", m && "modal-" + m, a && a, f].filter((h) => h).join(" "),
1339
+ children: /* @__PURE__ */ r("div", { className: "modal-dialog modal-dialog-centered", role: "document", children: /* @__PURE__ */ C("div", { className: "modal-content", children: [
1340
+ /* @__PURE__ */ r(T, { name: "header", children: /* @__PURE__ */ C("div", { className: "modal-header", children: [
1341
+ /* @__PURE__ */ r("h5", { className: "modal-title", id: "exampleModalLabel", children: /* @__PURE__ */ r(T, { name: "title", children: "Title" }) }),
1342
+ /* @__PURE__ */ r(T, { name: "navigation", children: /* @__PURE__ */ r("nav", { children: e }) }),
1343
+ /* @__PURE__ */ r("button", { onClick: g, type: "button", className: "btn-close", "aria-label": "Close" })
661
1344
  ] }) }),
662
- /* @__PURE__ */ s("div", { className: "modal-body", children: /* @__PURE__ */ s(V, { name: "content", content: e, data: null, children: e }) }),
663
- /* @__PURE__ */ s(V, { name: "footer", content: e, data: null, children: /* @__PURE__ */ s("div", { className: "modal-footer", children: /* @__PURE__ */ s(V, { name: "actions", content: e, data: null, children: /* @__PURE__ */ s("button", { onClick: d, type: "button", className: "btn btn-secondary", children: "Close" }) }) }) })
1345
+ /* @__PURE__ */ r("div", { className: "modal-body", children: /* @__PURE__ */ r(T, { name: "content", children: e }) }),
1346
+ /* @__PURE__ */ r(T, { name: "footer", children: /* @__PURE__ */ r("div", { className: "modal-footer", children: /* @__PURE__ */ r(T, { name: "actions", children: /* @__PURE__ */ r("button", { onClick: g, type: "button", className: "btn btn-secondary", children: "Close" }) }) }) })
664
1347
  ] }) })
665
1348
  }
666
1349
  ),
667
- r && /* @__PURE__ */ s(
1350
+ c && /* @__PURE__ */ r(
668
1351
  "div",
669
1352
  {
670
- ref: b,
671
- className: ["modal-backdrop", "fade", ...n && ["show"]].filter((p) => p).join(" ")
1353
+ ref: l,
1354
+ className: ["modal-backdrop", "fade", ...a && ["show"]].filter((h) => h).join(" ")
672
1355
  }
673
1356
  )
674
1357
  ] }), document.body);
675
- }), an = ({
1358
+ }), { name: "modal" }), gr = ({
676
1359
  animationData: e,
677
1360
  path: t,
678
1361
  options: n,
679
- width: r,
680
- height: o,
681
- className: a,
682
- ...c
1362
+ width: o,
1363
+ height: s,
1364
+ className: i,
1365
+ ...a
683
1366
  }) => {
684
- const u = R(null);
685
- return v(() => {
686
- if (!u.current)
1367
+ const c = S(null);
1368
+ return N(() => {
1369
+ if (!c.current)
687
1370
  return;
688
- const h = Yt.loadAnimation({
1371
+ const u = In.loadAnimation({
689
1372
  renderer: "svg",
690
1373
  loop: !1,
691
1374
  autoplay: !0,
@@ -694,52 +1377,52 @@ const it = ({ entityAction: e, initParameters: t, initQueryParameters: n }) => {
694
1377
  },
695
1378
  animationData: e,
696
1379
  path: t,
697
- container: u.current,
1380
+ container: c.current,
698
1381
  ...n || {}
699
1382
  });
700
1383
  return () => {
701
- h.destroy();
1384
+ u.destroy();
702
1385
  };
703
- }, []), /* @__PURE__ */ s("div", { className: a, ref: u, style: { width: r, height: o } });
704
- }, ut = S.createContext(void 0);
705
- var ae = /* @__PURE__ */ ((e) => (e[e.success = 0] = "success", e[e.denied = 1] = "denied", e[e.warning = 2] = "warning", e[e.info = 3] = "info", e[e.confirm = 4] = "confirm", e))(ae || {});
706
- function dt() {
707
- const e = S.useContext(ut);
1386
+ }, []), /* @__PURE__ */ r("div", { className: i, ref: c, style: { width: o, height: s } });
1387
+ }, Xt = v.createContext(void 0);
1388
+ var Z = /* @__PURE__ */ ((e) => (e[e.success = 0] = "success", e[e.denied = 1] = "denied", e[e.warning = 2] = "warning", e[e.info = 3] = "info", e[e.confirm = 4] = "confirm", e))(Z || {});
1389
+ function Ge() {
1390
+ const e = v.useContext(Xt);
708
1391
  if (e === void 0)
709
1392
  throw new Error("UseAlert must be within AlertProvider");
710
1393
  return e;
711
1394
  }
712
- function cn(e) {
713
- var m;
714
- const [t, n] = $(), r = R(0), o = R(void 0), [a, c] = $(null);
715
- v(() => {
716
- r.current += 1;
1395
+ function en({ children: e }) {
1396
+ const [t, n] = R(), o = S(0), s = S(void 0), [i, a] = R(null);
1397
+ N(() => {
1398
+ o.current += 1;
717
1399
  }, [t]);
718
- const u = /* @__PURE__ */ Object.assign({ "/src/assets/images/alert/denied.json": () => import("./denied-CgoMpaA7.js"), "/src/assets/images/alert/info.json": () => import("./info-D-NzIEYs.js"), "/src/assets/images/alert/success.json": () => import("./success-Bu_BJcf1.js"), "/src/assets/images/alert/warning.json": () => import("./warning-B1nr7TsB.js") }), h = (f) => {
719
- var E, d;
720
- let l = {
1400
+ const c = /* @__PURE__ */ Object.assign({ "/src/assets/images/alert/denied.json": () => import("./denied-CgoMpaA7.js"), "/src/assets/images/alert/info.json": () => import("./info-D-NzIEYs.js"), "/src/assets/images/alert/success.json": () => import("./success-Bu_BJcf1.js"), "/src/assets/images/alert/warning.json": () => import("./warning-B1nr7TsB.js") }), u = () => {
1401
+ a(null), n(void 0);
1402
+ }, m = (f) => {
1403
+ let y = {
721
1404
  title: "Are you confirm?",
722
- icon: 0,
1405
+ icon: 3,
723
1406
  animation: "scale",
724
1407
  size: "auto",
725
1408
  allowClose: !1,
726
1409
  timeoutProgress: !1,
727
1410
  ...f || {}
728
1411
  };
729
- const b = {
1412
+ const E = {
730
1413
  0: "success.json",
731
1414
  1: "denied.json",
732
1415
  2: "warning.json",
733
1416
  3: "info.json",
734
1417
  4: "info.json"
735
1418
  };
736
- if (Object.hasOwn(b, l.icon)) {
737
- const p = b[l.icon], C = Object.keys(u).filter((N) => N.endsWith(p)).pop();
738
- C && u[C]().then((N) => {
739
- c(N.default);
1419
+ if (Object.hasOwn(E, y.icon)) {
1420
+ const _ = E[y.icon], b = Object.keys(c).filter((l) => l.endsWith(_)).pop();
1421
+ b && c[b]().then((l) => {
1422
+ a(l.default);
740
1423
  });
741
1424
  }
742
- !l.actions && !l.timeoutProgress && (l.actions = {
1425
+ !y.actions && !y.timeoutProgress ? y.actions = {
743
1426
  cancel: {
744
1427
  label: "Cancel",
745
1428
  classList: ["btn-outline-primary"]
@@ -747,204 +1430,442 @@ function cn(e) {
747
1430
  confirm: {
748
1431
  label: "Confirm"
749
1432
  }
750
- }), (E = o.current) != null && E.isOpen() ? (d = o.current) == null || d.close().finally(() => {
751
- n(l);
752
- }) : n(l);
753
- }, i = (f) => {
754
- var b;
755
- const l = {
1433
+ } : setTimeout(() => {
1434
+ s.current?.close().finally(u);
1435
+ }, y.timeout || 1e3), s.current?.isOpen() ? s.current?.close().finally(() => {
1436
+ n(y);
1437
+ }) : n(y);
1438
+ }, p = (f) => {
1439
+ const y = {
756
1440
  [f]: !0,
757
1441
  isConfirmed: f === "confirm",
758
1442
  isCancelled: f === "cancel",
759
1443
  isDenied: f === "deny"
760
1444
  };
761
- t != null && t.onResult && t.onResult(l), (b = o.current) == null || b.close().then(() => {
762
- c(null), n(void 0);
763
- });
1445
+ t?.onResult && t.onResult(y), s.current?.close().then(u);
764
1446
  };
765
- return /* @__PURE__ */ _(ut.Provider, { value: { open: h }, children: [
766
- e.children,
767
- t && /* @__PURE__ */ _(lt, { size: t.size, className: "modal-alert", animation: t.animation, open: !0, ref: o, children: [
768
- /* @__PURE__ */ s(B, { name: "header" }),
769
- /* @__PURE__ */ s(B, { name: "footer" }),
770
- /* @__PURE__ */ s(B, { name: "content", children: /* @__PURE__ */ _("div", { className: "d-flex flex-column align-items-center", children: [
771
- a !== null && /* @__PURE__ */ s(an, { className: "modal-alert-icon", animationData: a }),
772
- /* @__PURE__ */ s("h3", { className: "modal-alert-title", children: t.title }),
773
- !!((m = t.text) != null && m.length) && /* @__PURE__ */ s("p", { className: "modal-alert-text", children: t.text }),
774
- t.actions && /* @__PURE__ */ s("div", { className: "d-flex justify-content-center align-items-center", children: Object.keys(t.actions).map((f) => {
775
- var l, b, E;
776
- return /* @__PURE__ */ s(
777
- me,
778
- {
779
- className: "btn btn-lg mx-2 " + (((l = t.actions) == null ? void 0 : l[f].classList) ?? ["btn-primary"]).join(" "),
780
- onClick: () => i(f),
781
- children: ((E = ((b = t.actions) == null ? void 0 : b[f]) ?? null) == null ? void 0 : E.label) || f
782
- },
783
- f
784
- );
785
- }) })
786
- ] }) })
787
- ] })
1447
+ return /* @__PURE__ */ C(Xt.Provider, { value: { open: m }, children: [
1448
+ t && /* @__PURE__ */ C(
1449
+ Zt,
1450
+ {
1451
+ size: t.size,
1452
+ className: "modal-alert",
1453
+ animation: t.animation,
1454
+ open: !0,
1455
+ ref: s,
1456
+ children: [
1457
+ /* @__PURE__ */ r(H, { name: "header" }),
1458
+ /* @__PURE__ */ r(H, { name: "footer" }),
1459
+ /* @__PURE__ */ r(H, { name: "content", children: /* @__PURE__ */ C("div", { className: "d-flex flex-column align-items-center", children: [
1460
+ i !== null && /* @__PURE__ */ r(gr, { className: "modal-alert-icon", animationData: i }),
1461
+ /* @__PURE__ */ r("h3", { className: "modal-alert-title", children: t.title }),
1462
+ !!t.text?.length && /* @__PURE__ */ r("p", { className: "modal-alert-text", children: t.text }),
1463
+ t.actions && /* @__PURE__ */ r("div", { className: "d-flex justify-content-center align-items-center", children: Object.keys(t.actions).map((f) => /* @__PURE__ */ r(
1464
+ fe,
1465
+ {
1466
+ className: "btn btn-lg mx-2 " + (t.actions?.[f].classList ?? ["btn-primary"]).join(" "),
1467
+ onClick: () => p(f),
1468
+ children: (t.actions?.[f] ?? null)?.label || f
1469
+ },
1470
+ f
1471
+ )) })
1472
+ ] }) })
1473
+ ]
1474
+ },
1475
+ o.current
1476
+ ),
1477
+ e
788
1478
  ] });
789
1479
  }
790
- const ln = ({ action: e, children: t, routeParams: n, results: r }) => {
791
- const { getAction: o } = Re(), a = o(e.entity, "list", e.namespace);
792
- return /* @__PURE__ */ _("section", { className: "edit", children: [
793
- /* @__PURE__ */ _("header", { children: [
794
- /* @__PURE__ */ _("h2", { className: "title", children: [
795
- a && /* @__PURE__ */ s(z, { to: Y(a.route, n), children: "←" }),
796
- /* @__PURE__ */ s(V, { name: "title", content: t, data: r })
1480
+ function Bo(e) {
1481
+ return (t) => /* @__PURE__ */ r(en, { children: /* @__PURE__ */ r(e, { ...t }) });
1482
+ }
1483
+ const br = xe(({ children: e }) => {
1484
+ const { action: t } = te(), { getAction: n, generateLink: o } = j(), s = n(t.action.entity, "list", t.action.namespace);
1485
+ return /* @__PURE__ */ C("section", { className: "edit", children: [
1486
+ /* @__PURE__ */ C("header", { children: [
1487
+ /* @__PURE__ */ C("h2", { className: "title", children: [
1488
+ s && /* @__PURE__ */ r(M, { to: o(s.route, t.parameters), children: "←" }),
1489
+ /* @__PURE__ */ r(T, { name: "title" })
797
1490
  ] }),
798
- /* @__PURE__ */ s("nav", { children: /* @__PURE__ */ s(V, { name: "navigation", content: t, data: r }) })
1491
+ /* @__PURE__ */ r("nav", { children: /* @__PURE__ */ r(T, { name: "navigation" }) })
799
1492
  ] }),
800
- /* @__PURE__ */ s("main", { children: /* @__PURE__ */ s(V, { name: "content", content: t, data: r }) })
1493
+ /* @__PURE__ */ C("main", { children: [
1494
+ /* @__PURE__ */ r(T, { name: "content" }),
1495
+ /* @__PURE__ */ r(T, { name: "actions" })
1496
+ ] })
801
1497
  ] });
802
- }, We = ({ action: e, children: t, onSuccess: n, modal: r, props: o }) => {
803
- const a = { ...e.parameters || {}, ...Bt() }, c = R(void 0), u = R(void 0), { results: h, setParameters: i } = it({
804
- entityAction: e.action,
805
- initParameters: a
806
- }), { open: m } = dt();
807
- return v(() => {
808
- i(a);
809
- }, [JSON.stringify(a)]), v(() => {
810
- var l;
811
- (l = u.current) == null || l.open();
812
- }, [JSON.stringify(h)]), /* @__PURE__ */ _(r ? lt : ln, { ref: u, ...o, action: e, routeParams: a, children: [
813
- /* @__PURE__ */ s(B, { name: "title", children: /* @__PURE__ */ s(V, { name: "title", content: t, data: h, children: (h == null ? void 0 : h.title) || "Title" }) }),
814
- /* @__PURE__ */ s(B, { name: "navigation", children: /* @__PURE__ */ s(G, { namespace: e.action.namespace, view: "navigation", prefix: "modify", children: /* @__PURE__ */ _(V, { name: "navigation", content: t, data: h, children: [
815
- "original ",
816
- e.action.namespace
817
- ] }) }) }),
818
- /* @__PURE__ */ s(B, { name: "content", children: /* @__PURE__ */ s(G, { namespace: e.action.namespace, view: "content", prefix: "modify", children: /* @__PURE__ */ s(V, { name: "content", content: t, data: h, children: /* @__PURE__ */ s(
819
- on,
820
- {
821
- ref: c,
822
- data: h,
823
- action: e.action,
824
- onSuccess: (l) => {
825
- var E, d;
826
- (E = u.current) == null || E.close();
827
- const b = new CustomEvent("success", { detail: l });
828
- n && n(b, l), !b.defaultPrevented && m({
829
- title: "Success",
830
- text: Object.values(((d = l.messages) == null ? void 0 : d.success) ?? []).join(" ") ?? "Item was saved successful!",
831
- icon: ae.success,
832
- actions: {
833
- close: {
834
- label: "OK"
1498
+ }, { name: "modify" }), st = Mt(({ template: e, children: t, onSuccess: n, modal: o }) => {
1499
+ const { open: s } = Ge(), { closeModal: i } = Qe(), a = ne(), c = o ? Zt : e || br;
1500
+ if (a)
1501
+ return /* @__PURE__ */ C(c, { children: [
1502
+ /* @__PURE__ */ r(H, { name: "title", children: /* @__PURE__ */ r(D, { children: a?.results?.title || "Title" }) }),
1503
+ /* @__PURE__ */ r(H, { name: "navigation", children: /* @__PURE__ */ r(U, { view: "navigation", prefix: "modify" }) }),
1504
+ /* @__PURE__ */ r(H, { name: "content", children: /* @__PURE__ */ r(U, { view: "content", prefix: "modify", children: /* @__PURE__ */ r(
1505
+ hr,
1506
+ {
1507
+ onSuccess: (u) => new Promise((m, p) => {
1508
+ i();
1509
+ const f = new CustomEvent("success", { detail: u, cancelable: !0 });
1510
+ if (n && n(f, u), f.defaultPrevented)
1511
+ return p();
1512
+ s({
1513
+ title: "Success",
1514
+ text: Object.values(u.messages?.success ?? []).join(" ") ?? "Item was saved successful!",
1515
+ icon: Z.success,
1516
+ actions: {
1517
+ close: {
1518
+ label: "OK"
1519
+ }
1520
+ },
1521
+ onResult: () => {
1522
+ m();
835
1523
  }
836
- }
837
- });
838
- },
839
- onError: (l) => {
840
- m({
841
- title: l.status + " " + l.detail,
842
- text: l.detail,
843
- icon: ae.denied,
844
- actions: {
845
- close: {
846
- label: "OK"
1524
+ });
1525
+ }),
1526
+ onError: (u) => {
1527
+ s({
1528
+ title: u.status + " " + u.detail,
1529
+ text: u.detail,
1530
+ icon: Z.denied,
1531
+ actions: {
1532
+ close: {
1533
+ label: "OK"
1534
+ }
847
1535
  }
1536
+ });
1537
+ },
1538
+ onLoad: () => {
1539
+ },
1540
+ embedded: o,
1541
+ children: /* @__PURE__ */ r(H, { name: "actions" })
1542
+ }
1543
+ ) }) }),
1544
+ /* @__PURE__ */ r(H, { name: "actions", children: /* @__PURE__ */ r(
1545
+ fe,
1546
+ {
1547
+ type: "submit",
1548
+ className: "btn btn-primary",
1549
+ form: a?.results?.form?.modify?.view.full_name || "modify",
1550
+ children: /* @__PURE__ */ r(D, { children: "Submit" })
1551
+ }
1552
+ ) }),
1553
+ t
1554
+ ] });
1555
+ });
1556
+ var Ye = /* @__PURE__ */ ((e) => (e.List = "list", e.Object = "object", e.Internal = "internal", e))(Ye || {});
1557
+ const tn = v.createContext(void 0);
1558
+ function $() {
1559
+ const e = v.useContext(tn);
1560
+ if (e === void 0)
1561
+ throw new Error("UseList must be within ListProvider");
1562
+ const { data: t, onClick: n } = e, o = t?.entity?.primaryColumn, s = (t?.entity?.columns || []).filter((m) => m.visible).filter((m) => m.group !== !1), i = Object.values(t?.action || []), a = i.filter((m) => m.visibility === Ye.Object), c = s.length + (i.length ? 1 : 0), u = t?.entity?.data.items ?? [];
1563
+ return {
1564
+ data: t,
1565
+ columns: s,
1566
+ actions: i,
1567
+ objectActions: a,
1568
+ columnsTotal: c,
1569
+ primaryColumn: o,
1570
+ items: u,
1571
+ onClick: n
1572
+ };
1573
+ }
1574
+ function yr({ data: e, onClick: t, ...n }) {
1575
+ const { results: o } = ne() || {};
1576
+ return e ??= o, /* @__PURE__ */ r(tn.Provider, { value: { data: e, onClick: t }, children: n.children });
1577
+ }
1578
+ const nn = v.createContext(void 0);
1579
+ function he() {
1580
+ const e = v.useContext(nn);
1581
+ if (e === void 0)
1582
+ throw new Error("UseListItem must be within ListItemProvider");
1583
+ const { index: t } = e, { data: n, primaryColumn: o } = $();
1584
+ return {
1585
+ index: t,
1586
+ id: n?.entity?.data.items[t][o?.field || ""] ?? null,
1587
+ data: n?.entity?.data.items[t] ?? null
1588
+ };
1589
+ }
1590
+ function rn({ index: e, ...t }) {
1591
+ return /* @__PURE__ */ r(nn.Provider, { value: { index: e }, children: t.children });
1592
+ }
1593
+ const on = ({ column: e, namespace: t }) => {
1594
+ const { data: n } = he();
1595
+ return n && /* @__PURE__ */ r(U, { namespace: t, data: n, prefix: "list", view: e.field, children: n[e.field] !== void 0 && (n[e.field] instanceof Object ? n[e.field] instanceof Array ? n[e.field].join(", ") : JSON.stringify(n[e.field]) : /* @__PURE__ */ r(D, { children: n[e.field]?.toString() })) });
1596
+ }, sn = v.createContext(void 0);
1597
+ function an() {
1598
+ return v.useContext(sn);
1599
+ }
1600
+ function vr({ onClick: e, ...t }) {
1601
+ const { data: n, items: o, primaryColumn: s } = $(), i = S([]), a = o.map((l) => l[s?.field || ""] || 0), c = !!a.length && a.reduce((l, d) => l && i.current.includes(d), !0), u = n?.form?.batch?.view?.children?.method?.choices?.reduce((l, d) => {
1602
+ const g = d.label instanceof Function ? d.label(d) : d.label, h = d.value instanceof Function ? d.value() : d.value?.toString();
1603
+ return { ...l, [h]: g };
1604
+ }, {}), m = !!Object.keys(u || {}).length && s, [, p] = R(), f = (l, d = !1) => {
1605
+ const g = a[l];
1606
+ d ? i.current.push(g) : i.current = i.current.filter((h) => h !== g), p({});
1607
+ }, y = (l = !1) => {
1608
+ i.current = (l ? i.current.concat(a) : i.current.filter((d) => !a.includes(d))).filter((d, g, h) => h.indexOf(d) === g), p({});
1609
+ }, E = () => {
1610
+ i.current = [], p({});
1611
+ }, _ = (l) => {
1612
+ const d = a[l];
1613
+ return i.current.includes(d);
1614
+ }, b = (l) => new Promise((d, g) => {
1615
+ if (!i)
1616
+ return g();
1617
+ const h = n?.form.batch.view;
1618
+ if (!m || !i.current?.length)
1619
+ return g();
1620
+ const x = new FormData();
1621
+ i.current.forEach((P) => {
1622
+ x.append(`${h?.children?.ids.full_name}[]`, P.toString());
1623
+ }), x.append(h?.children?.method.full_name || "method", l), e(l, i.current, x).then(() => {
1624
+ E(), d();
1625
+ }).catch(g);
1626
+ });
1627
+ return /* @__PURE__ */ r(
1628
+ sn.Provider,
1629
+ {
1630
+ value: {
1631
+ actions: u,
1632
+ toggle: f,
1633
+ toggleAll: y,
1634
+ isSelected: _,
1635
+ isSelectedAll: c,
1636
+ executeAction: b,
1637
+ selected: i.current,
1638
+ clear: E
1639
+ },
1640
+ children: t.children
1641
+ }
1642
+ );
1643
+ }
1644
+ const cn = ({ className: e }) => {
1645
+ const { index: t } = he(), n = an();
1646
+ if (!n)
1647
+ return /* @__PURE__ */ r(A, {});
1648
+ const { actions: o, toggle: s, isSelected: i } = n;
1649
+ return Object.keys(o || {}).length > 0 && /* @__PURE__ */ r(A, { children: /* @__PURE__ */ r(
1650
+ "input",
1651
+ {
1652
+ checked: i(t),
1653
+ className: e,
1654
+ type: "checkbox",
1655
+ name: "batch",
1656
+ onChange: (a) => s(t, a.target.checked)
1657
+ }
1658
+ ) });
1659
+ }, ln = ({ column: e, namespace: t }) => /* @__PURE__ */ r(A, { children: /* @__PURE__ */ r(U, { namespace: t, data: e, prefix: "list", view: e.field + ".label", children: /* @__PURE__ */ r(D, { children: e.label }) }) }), dn = ({ children: e, action: t, className: n }) => {
1660
+ const { generateActionLink: o } = j(), { onClick: s } = $();
1661
+ return /* @__PURE__ */ r(
1662
+ M,
1663
+ {
1664
+ onClick: (i) => {
1665
+ s && s(t, i);
1666
+ },
1667
+ className: n,
1668
+ to: o(t),
1669
+ children: e ?? /* @__PURE__ */ r(D, { children: t.action.title ?? t.action.name })
1670
+ }
1671
+ );
1672
+ }, Er = ({ permission: e, children: t, id: n }) => {
1673
+ const { results: o } = ne() || {}, { id: s } = n ? { id: n } : he();
1674
+ if (!(e && !Object.values(o?.entity.acl[e] || []).map((i) => i.toString()).includes(s.toString())))
1675
+ return /* @__PURE__ */ r(A, { children: t });
1676
+ }, Cr = ({ action: e, ...t }) => {
1677
+ const { id: n } = he();
1678
+ return /* @__PURE__ */ r(A, { children: /* @__PURE__ */ r(Er, { permission: e.action.permission, children: /* @__PURE__ */ r(dn, { ...t, action: { ...e, parameters: { ...e.parameters, id: n } } }) }) });
1679
+ }, un = ({ namespace: e, routeParams: t }) => {
1680
+ const { objectActions: n } = $(), { data: o } = he();
1681
+ return o && /* @__PURE__ */ r(U, { namespace: e, data: o, prefix: "list", view: "object.actions", children: n.map((s, i) => /* @__PURE__ */ r(
1682
+ Cr,
1683
+ {
1684
+ action: { action: s, parameters: t },
1685
+ className: ["btn", "btn-sm", "mb-1", "ms-1", (s.route?.methods ?? []).includes("DELETE") ? "btn-outline-danger" : "btn-outline-secondary"].join(" ")
1686
+ },
1687
+ i
1688
+ )) });
1689
+ }, _r = ({
1690
+ routeParams: e,
1691
+ namespace: t,
1692
+ options: n,
1693
+ tableOptions: o,
1694
+ ...s
1695
+ }) => {
1696
+ const { columns: i, primaryColumn: a, objectActions: c, columnsTotal: u, items: m, data: p, onClick: f } = $(), { action: y } = te(), { options: E } = ee(), _ = {
1697
+ className: "table-responsive",
1698
+ ...s,
1699
+ ...E?.GridView || {}
1700
+ };
1701
+ return o = {
1702
+ className: "table table-striped table-hover",
1703
+ ...E?.HTMLTableElement || {},
1704
+ ...o || {}
1705
+ }, /* @__PURE__ */ r("div", { ..._, children: /* @__PURE__ */ C("table", { ...o, children: [
1706
+ /* @__PURE__ */ r("thead", { children: /* @__PURE__ */ C("tr", { children: [
1707
+ i.map((b, l) => /* @__PURE__ */ et("th", { ...b?.view?.header?.attr || {}, key: l }, /* @__PURE__ */ r(ln, { column: b, namespace: t }), b.sortable && p?.sort?.[b.field] !== void 0 && /* @__PURE__ */ r(
1708
+ M,
1709
+ {
1710
+ onClick: (d) => f && f({
1711
+ ...y,
1712
+ query: {
1713
+ ...y.query,
1714
+ sort: { [b.field]: p?.sort[b.field] ? p?.sort[b.field] === "ASC" ? "DESC" : "" : "ASC" }
848
1715
  }
849
- });
850
- },
851
- onLoad: () => {
852
- console.log("loaded");
853
- },
854
- embedded: r,
855
- parameters: a,
856
- children: r && /* @__PURE__ */ s(B, { name: "actions" })
857
- }
858
- ) }) }) }),
859
- /* @__PURE__ */ s(B, { name: "actions", children: /* @__PURE__ */ s(V, { name: "actions", content: t, data: h, children: /* @__PURE__ */ s(
860
- "button",
861
- {
862
- type: "submit",
863
- className: "btn btn-primary",
864
- onClick: () => {
865
- var l, b;
866
- return (b = (l = c.current) == null ? void 0 : l.getFormRef()) == null ? void 0 : b.submit();
867
- },
868
- children: "Submit"
869
- }
870
- ) }) })
1716
+ }, d),
1717
+ className: "btn btn-sm",
1718
+ to: "#",
1719
+ children: p.sort[b.field] ? p.sort[b.field] === "ASC" ? "⇑" : "⇓" : "⇅"
1720
+ }
1721
+ ))),
1722
+ a && c.length > 0 && /* @__PURE__ */ r("th", { className: "text-end", children: /* @__PURE__ */ r(D, { children: "Actions" }) })
1723
+ ] }) }),
1724
+ /* @__PURE__ */ r("tbody", { children: m.length ? m.map((b, l) => /* @__PURE__ */ r(rn, { index: l, children: /* @__PURE__ */ C("tr", { children: [
1725
+ i?.map(
1726
+ (d, g) => {
1727
+ const h = n?.columns?.[d.field];
1728
+ return d = {
1729
+ ...d,
1730
+ ...h instanceof Function ? h(p?.entity?.data.items[l]) : n?.columns?.[d.field]
1731
+ }, /* @__PURE__ */ et("td", { ...d?.view?.content?.attr || {}, key: g }, g === 0 && /* @__PURE__ */ r(cn, { className: "me-2" }), /* @__PURE__ */ r(on, { column: d, namespace: t }));
1732
+ }
1733
+ ),
1734
+ a && c.length > 0 && /* @__PURE__ */ r("td", { className: "text-end text-nowrap", children: /* @__PURE__ */ r(un, { routeParams: e, namespace: t }) })
1735
+ ] }) }, l)) : /* @__PURE__ */ r("tr", { children: /* @__PURE__ */ r("td", { colSpan: u, children: /* @__PURE__ */ r(D, { children: "Not results found." }) }) }) })
1736
+ ] }) });
1737
+ }, ie = ({ page: e, active: t = !1, title: n, children: o }) => {
1738
+ const { generateActionLink: s } = j(), { onClick: i } = $(), { action: a } = te(), c = {
1739
+ ...a,
1740
+ query: {
1741
+ ...a.query || {},
1742
+ page: e.toString()
1743
+ }
1744
+ }, u = s(c);
1745
+ return /* @__PURE__ */ r("li", { className: `page-item ${t ? "active" : ""}`, children: /* @__PURE__ */ r(
1746
+ M,
1747
+ {
1748
+ to: u.toString(),
1749
+ ...i && {
1750
+ onClick: (m) => {
1751
+ i(c, m);
1752
+ }
1753
+ },
1754
+ className: "page-link",
1755
+ title: n,
1756
+ children: o || e
1757
+ }
1758
+ ) });
1759
+ }, xr = () => {
1760
+ const { data: e } = $(), t = e?.entity?.data.meta, n = 1, o = t?.totalPages || 0, s = t?.page || n, i = t?.links, a = !!t?.totalPages;
1761
+ return a && /* @__PURE__ */ C("div", { className: "d-flex flex-column justiry-content-center", children: [
1762
+ /* @__PURE__ */ C("small", { className: "mb-2", children: [
1763
+ t.totalResults,
1764
+ " Results",
1765
+ a && /* @__PURE__ */ C(A, { children: [
1766
+ " - Page ",
1767
+ s,
1768
+ " of ",
1769
+ t.totalPages
1770
+ ] })
1771
+ ] }),
1772
+ a && /* @__PURE__ */ r("nav", { "aria-label": "Page navigation", className: "m-auto text-center d-inline", children: /* @__PURE__ */ C("ul", { className: "pagination pagination-sm", children: [
1773
+ s > n && /* @__PURE__ */ r(ie, { page: s - 1, title: "Go to First Page", children: "«" }),
1774
+ t.links[0] !== n && /* @__PURE__ */ C(A, { children: [
1775
+ /* @__PURE__ */ r(ie, { page: 1, active: n === s }, 1),
1776
+ /* @__PURE__ */ r("div", { className: "page-item", children: /* @__PURE__ */ r("a", { className: "page-link", children: "..." }) })
1777
+ ] }),
1778
+ (i || []).map((c, u) => /* @__PURE__ */ r(ie, { page: c, active: c === s }, u)),
1779
+ [...t.links].reverse()[0] !== o && /* @__PURE__ */ C(A, { children: [
1780
+ /* @__PURE__ */ r("div", { className: "page-item", children: /* @__PURE__ */ r("a", { className: "page-link", children: "..." }) }),
1781
+ /* @__PURE__ */ r(
1782
+ ie,
1783
+ {
1784
+ page: o,
1785
+ active: o === s
1786
+ },
1787
+ o
1788
+ )
1789
+ ] }),
1790
+ s < o && /* @__PURE__ */ r(ie, { page: t.totalPages, title: "Go to Last Page", children: "»" })
1791
+ ] }) })
871
1792
  ] });
872
- }, un = () => /* @__PURE__ */ s("div", { children: "No View Found" }), qe = ({ to: e, children: t, ...n }) => /* @__PURE__ */ s(z, { to: e, ...n, children: /* @__PURE__ */ s(ct, { ...n, children: t && t }) }), w = /* @__PURE__ */ new Map(), pe = {
1793
+ }, q = /* @__PURE__ */ new Map(), we = {
873
1794
  set(e, t, n) {
874
- w.has(e) || w.set(e, /* @__PURE__ */ new Map());
875
- const r = w.get(e);
876
- if (!r.has(t) && r.size !== 0) {
877
- console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(r.keys())[0]}.`);
1795
+ q.has(e) || q.set(e, /* @__PURE__ */ new Map());
1796
+ const o = q.get(e);
1797
+ if (!o.has(t) && o.size !== 0) {
1798
+ console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(o.keys())[0]}.`);
878
1799
  return;
879
1800
  }
880
- r.set(t, n);
1801
+ o.set(t, n);
881
1802
  },
882
1803
  get(e, t) {
883
- return w.has(e) && w.get(e).get(t) || null;
1804
+ return q.has(e) && q.get(e).get(t) || null;
884
1805
  },
885
1806
  remove(e, t) {
886
- if (!w.has(e))
1807
+ if (!q.has(e))
887
1808
  return;
888
- const n = w.get(e);
889
- n.delete(t), n.size === 0 && w.delete(e);
1809
+ const n = q.get(e);
1810
+ n.delete(t), n.size === 0 && q.delete(e);
890
1811
  }
891
- }, dn = 1e3, Ae = "transitionend", ft = (e) => (e && window.CSS && window.CSS.escape && (e = e.replace(/#([^\s"#']+)/g, (t, n) => `#${CSS.escape(n)}`)), e), fn = (e) => e == null ? `${e}` : Object.prototype.toString.call(e).match(/\s([a-z]+)/i)[1].toLowerCase(), mn = (e) => {
1812
+ }, Nr = 1e3, Ie = "transitionend", mn = (e) => (e && window.CSS && window.CSS.escape && (e = e.replace(/#([^\s"#']+)/g, (t, n) => `#${CSS.escape(n)}`)), e), wr = (e) => e == null ? `${e}` : Object.prototype.toString.call(e).match(/\s([a-z]+)/i)[1].toLowerCase(), Ar = (e) => {
892
1813
  if (!e)
893
1814
  return 0;
894
1815
  let { transitionDuration: t, transitionDelay: n } = window.getComputedStyle(e);
895
- const r = Number.parseFloat(t), o = Number.parseFloat(n);
896
- return !r && !o ? 0 : (t = t.split(",")[0], n = n.split(",")[0], (Number.parseFloat(t) + Number.parseFloat(n)) * dn);
897
- }, pn = (e) => {
898
- e.dispatchEvent(new Event(Ae));
899
- }, J = (e) => !e || typeof e != "object" ? !1 : (typeof e.jquery < "u" && (e = e[0]), typeof e.nodeType < "u"), Oe = (e) => J(e) ? e.jquery ? e[0] : e : typeof e == "string" && e.length > 0 ? document.querySelector(ft(e)) : null, mt = (e) => {
900
- if (!J(e) || e.getClientRects().length === 0)
1816
+ const o = Number.parseFloat(t), s = Number.parseFloat(n);
1817
+ return !o && !s ? 0 : (t = t.split(",")[0], n = n.split(",")[0], (Number.parseFloat(t) + Number.parseFloat(n)) * Nr);
1818
+ }, Pr = (e) => {
1819
+ e.dispatchEvent(new Event(Ie));
1820
+ }, Y = (e) => !e || typeof e != "object" ? !1 : (typeof e.jquery < "u" && (e = e[0]), typeof e.nodeType < "u"), je = (e) => Y(e) ? e.jquery ? e[0] : e : typeof e == "string" && e.length > 0 ? document.querySelector(mn(e)) : null, fn = (e) => {
1821
+ if (!Y(e) || e.getClientRects().length === 0)
901
1822
  return !1;
902
1823
  const t = getComputedStyle(e).getPropertyValue("visibility") === "visible", n = e.closest("details:not([open])");
903
1824
  if (!n)
904
1825
  return t;
905
1826
  if (n !== e) {
906
- const r = e.closest("summary");
907
- if (r && r.parentNode !== n || r === null)
1827
+ const o = e.closest("summary");
1828
+ if (o && o.parentNode !== n || o === null)
908
1829
  return !1;
909
1830
  }
910
1831
  return t;
911
- }, Se = (e) => !e || e.nodeType !== Node.ELEMENT_NODE || e.classList.contains("disabled") ? !0 : typeof e.disabled < "u" ? e.disabled : e.hasAttribute("disabled") && e.getAttribute("disabled") !== "false", ze = () => {
912
- }, pt = () => window.jQuery && !document.body.hasAttribute("data-bs-no-jquery") ? window.jQuery : null, he = [], hn = (e) => {
913
- document.readyState === "loading" ? (he.length || document.addEventListener("DOMContentLoaded", () => {
914
- for (const t of he)
1832
+ }, Fe = (e) => !e || e.nodeType !== Node.ELEMENT_NODE || e.classList.contains("disabled") ? !0 : typeof e.disabled < "u" ? e.disabled : e.hasAttribute("disabled") && e.getAttribute("disabled") !== "false", it = () => {
1833
+ }, pn = () => window.jQuery && !document.body.hasAttribute("data-bs-no-jquery") ? window.jQuery : null, Ae = [], Lr = (e) => {
1834
+ document.readyState === "loading" ? (Ae.length || document.addEventListener("DOMContentLoaded", () => {
1835
+ for (const t of Ae)
915
1836
  t();
916
- }), he.push(e)) : e();
917
- }, ne = () => document.documentElement.dir === "rtl", gn = (e) => {
918
- hn(() => {
919
- const t = pt();
1837
+ }), Ae.push(e)) : e();
1838
+ }, oe = () => document.documentElement.dir === "rtl", Or = (e) => {
1839
+ Lr(() => {
1840
+ const t = pn();
920
1841
  if (t) {
921
- const n = e.NAME, r = t.fn[n];
922
- t.fn[n] = e.jQueryInterface, t.fn[n].Constructor = e, t.fn[n].noConflict = () => (t.fn[n] = r, e.jQueryInterface);
1842
+ const n = e.NAME, o = t.fn[n];
1843
+ t.fn[n] = e.jQueryInterface, t.fn[n].Constructor = e, t.fn[n].noConflict = () => (t.fn[n] = o, e.jQueryInterface);
923
1844
  }
924
1845
  });
925
- }, Pe = (e, t = [], n = e) => typeof e == "function" ? e(...t) : n, bn = (e, t, n = !0) => {
1846
+ }, Me = (e, t = [], n = e) => typeof e == "function" ? e.call(...t) : n, Sr = (e, t, n = !0) => {
926
1847
  if (!n) {
927
- Pe(e);
1848
+ Me(e);
928
1849
  return;
929
1850
  }
930
- const o = mn(t) + 5;
931
- let a = !1;
932
- const c = ({ target: u }) => {
933
- u === t && (a = !0, t.removeEventListener(Ae, c), Pe(e));
1851
+ const s = Ar(t) + 5;
1852
+ let i = !1;
1853
+ const a = ({ target: c }) => {
1854
+ c === t && (i = !0, t.removeEventListener(Ie, a), Me(e));
934
1855
  };
935
- t.addEventListener(Ae, c), setTimeout(() => {
936
- a || pn(t);
937
- }, o);
938
- }, yn = (e, t, n, r) => {
939
- const o = e.length;
940
- let a = e.indexOf(t);
941
- return a === -1 ? !n && r ? e[o - 1] : e[0] : (a += n ? 1 : -1, r && (a = (a + o) % o), e[Math.max(0, Math.min(a, o - 1))]);
942
- }, En = /[^.]*(?=\..*)\.|.*/, _n = /\..*/, Nn = /::\d+$/, ge = {};
943
- let Je = 1;
944
- const ht = {
1856
+ t.addEventListener(Ie, a), setTimeout(() => {
1857
+ i || Pr(t);
1858
+ }, s);
1859
+ }, kr = (e, t, n, o) => {
1860
+ const s = e.length;
1861
+ let i = e.indexOf(t);
1862
+ return i === -1 ? !n && o ? e[s - 1] : e[0] : (i += n ? 1 : -1, o && (i = (i + s) % s), e[Math.max(0, Math.min(i, s - 1))]);
1863
+ }, Dr = /[^.]*(?=\..*)\.|.*/, Rr = /\..*/, Tr = /::\d+$/, Pe = {};
1864
+ let at = 1;
1865
+ const hn = {
945
1866
  mouseenter: "mouseover",
946
1867
  mouseleave: "mouseout"
947
- }, Cn = /* @__PURE__ */ new Set([
1868
+ }, Ir = /* @__PURE__ */ new Set([
948
1869
  "click",
949
1870
  "dblclick",
950
1871
  "mouseup",
@@ -992,113 +1913,113 @@ const ht = {
992
1913
  "abort",
993
1914
  "scroll"
994
1915
  ]);
995
- function gt(e, t) {
996
- return t && `${t}::${Je++}` || e.uidEvent || Je++;
1916
+ function gn(e, t) {
1917
+ return t && `${t}::${at++}` || e.uidEvent || at++;
997
1918
  }
998
- function bt(e) {
999
- const t = gt(e);
1000
- return e.uidEvent = t, ge[t] = ge[t] || {}, ge[t];
1919
+ function bn(e) {
1920
+ const t = gn(e);
1921
+ return e.uidEvent = t, Pe[t] = Pe[t] || {}, Pe[t];
1001
1922
  }
1002
- function An(e, t) {
1003
- return function n(r) {
1004
- return Ie(r, { delegateTarget: e }), n.oneOff && I.off(e, r.type, t), t.apply(e, [r]);
1923
+ function jr(e, t) {
1924
+ return function n(o) {
1925
+ return We(o, { delegateTarget: e }), n.oneOff && I.off(e, o.type, t), t.apply(e, [o]);
1005
1926
  };
1006
1927
  }
1007
- function On(e, t, n) {
1008
- return function r(o) {
1009
- const a = e.querySelectorAll(t);
1010
- for (let { target: c } = o; c && c !== this; c = c.parentNode)
1011
- for (const u of a)
1012
- if (u === c)
1013
- return Ie(o, { delegateTarget: c }), r.oneOff && I.off(e, o.type, t, n), n.apply(c, [o]);
1928
+ function Fr(e, t, n) {
1929
+ return function o(s) {
1930
+ const i = e.querySelectorAll(t);
1931
+ for (let { target: a } = s; a && a !== this; a = a.parentNode)
1932
+ for (const c of i)
1933
+ if (c === a)
1934
+ return We(s, { delegateTarget: a }), o.oneOff && I.off(e, s.type, t, n), n.apply(a, [s]);
1014
1935
  };
1015
1936
  }
1016
- function yt(e, t, n = null) {
1017
- return Object.values(e).find((r) => r.callable === t && r.delegationSelector === n);
1937
+ function yn(e, t, n = null) {
1938
+ return Object.values(e).find((o) => o.callable === t && o.delegationSelector === n);
1018
1939
  }
1019
- function Et(e, t, n) {
1020
- const r = typeof t == "string", o = r ? n : t || n;
1021
- let a = _t(e);
1022
- return Cn.has(a) || (a = e), [r, o, a];
1940
+ function vn(e, t, n) {
1941
+ const o = typeof t == "string", s = o ? n : t || n;
1942
+ let i = En(e);
1943
+ return Ir.has(i) || (i = e), [o, s, i];
1023
1944
  }
1024
- function Qe(e, t, n, r, o) {
1945
+ function ct(e, t, n, o, s) {
1025
1946
  if (typeof t != "string" || !e)
1026
1947
  return;
1027
- let [a, c, u] = Et(t, n, r);
1028
- t in ht && (c = ((E) => function(d) {
1029
- if (!d.relatedTarget || d.relatedTarget !== d.delegateTarget && !d.delegateTarget.contains(d.relatedTarget))
1030
- return E.call(this, d);
1031
- })(c));
1032
- const h = bt(e), i = h[u] || (h[u] = {}), m = yt(i, c, a ? n : null);
1033
- if (m) {
1034
- m.oneOff = m.oneOff && o;
1948
+ let [i, a, c] = vn(t, n, o);
1949
+ t in hn && (a = ((_) => function(b) {
1950
+ if (!b.relatedTarget || b.relatedTarget !== b.delegateTarget && !b.delegateTarget.contains(b.relatedTarget))
1951
+ return _.call(this, b);
1952
+ })(a));
1953
+ const u = bn(e), m = u[c] || (u[c] = {}), p = yn(m, a, i ? n : null);
1954
+ if (p) {
1955
+ p.oneOff = p.oneOff && s;
1035
1956
  return;
1036
1957
  }
1037
- const f = gt(c, t.replace(En, "")), l = a ? On(e, n, c) : An(e, c);
1038
- l.delegationSelector = a ? n : null, l.callable = c, l.oneOff = o, l.uidEvent = f, i[f] = l, e.addEventListener(u, l, a);
1958
+ const f = gn(a, t.replace(Dr, "")), y = i ? Fr(e, n, a) : jr(e, a);
1959
+ y.delegationSelector = i ? n : null, y.callable = a, y.oneOff = s, y.uidEvent = f, m[f] = y, e.addEventListener(c, y, i);
1039
1960
  }
1040
- function Te(e, t, n, r, o) {
1041
- const a = yt(t[n], r, o);
1042
- a && (e.removeEventListener(n, a, !!o), delete t[n][a.uidEvent]);
1961
+ function Ue(e, t, n, o, s) {
1962
+ const i = yn(t[n], o, s);
1963
+ i && (e.removeEventListener(n, i, !!s), delete t[n][i.uidEvent]);
1043
1964
  }
1044
- function Sn(e, t, n, r) {
1045
- const o = t[n] || {};
1046
- for (const [a, c] of Object.entries(o))
1047
- a.includes(r) && Te(e, t, n, c.callable, c.delegationSelector);
1965
+ function Mr(e, t, n, o) {
1966
+ const s = t[n] || {};
1967
+ for (const [i, a] of Object.entries(s))
1968
+ i.includes(o) && Ue(e, t, n, a.callable, a.delegationSelector);
1048
1969
  }
1049
- function _t(e) {
1050
- return e = e.replace(_n, ""), ht[e] || e;
1970
+ function En(e) {
1971
+ return e = e.replace(Rr, ""), hn[e] || e;
1051
1972
  }
1052
1973
  const I = {
1053
- on(e, t, n, r) {
1054
- Qe(e, t, n, r, !1);
1974
+ on(e, t, n, o) {
1975
+ ct(e, t, n, o, !1);
1055
1976
  },
1056
- one(e, t, n, r) {
1057
- Qe(e, t, n, r, !0);
1977
+ one(e, t, n, o) {
1978
+ ct(e, t, n, o, !0);
1058
1979
  },
1059
- off(e, t, n, r) {
1980
+ off(e, t, n, o) {
1060
1981
  if (typeof t != "string" || !e)
1061
1982
  return;
1062
- const [o, a, c] = Et(t, n, r), u = c !== t, h = bt(e), i = h[c] || {}, m = t.startsWith(".");
1063
- if (typeof a < "u") {
1064
- if (!Object.keys(i).length)
1983
+ const [s, i, a] = vn(t, n, o), c = a !== t, u = bn(e), m = u[a] || {}, p = t.startsWith(".");
1984
+ if (typeof i < "u") {
1985
+ if (!Object.keys(m).length)
1065
1986
  return;
1066
- Te(e, h, c, a, o ? n : null);
1987
+ Ue(e, u, a, i, s ? n : null);
1067
1988
  return;
1068
1989
  }
1069
- if (m)
1070
- for (const f of Object.keys(h))
1071
- Sn(e, h, f, t.slice(1));
1072
- for (const [f, l] of Object.entries(i)) {
1073
- const b = f.replace(Nn, "");
1074
- (!u || t.includes(b)) && Te(e, h, c, l.callable, l.delegationSelector);
1990
+ if (p)
1991
+ for (const f of Object.keys(u))
1992
+ Mr(e, u, f, t.slice(1));
1993
+ for (const [f, y] of Object.entries(m)) {
1994
+ const E = f.replace(Tr, "");
1995
+ (!c || t.includes(E)) && Ue(e, u, a, y.callable, y.delegationSelector);
1075
1996
  }
1076
1997
  },
1077
1998
  trigger(e, t, n) {
1078
1999
  if (typeof t != "string" || !e)
1079
2000
  return null;
1080
- const r = pt(), o = _t(t), a = t !== o;
1081
- let c = null, u = !0, h = !0, i = !1;
1082
- a && r && (c = r.Event(t, n), r(e).trigger(c), u = !c.isPropagationStopped(), h = !c.isImmediatePropagationStopped(), i = c.isDefaultPrevented());
1083
- const m = Ie(new Event(t, { bubbles: u, cancelable: !0 }), n);
1084
- return i && m.preventDefault(), h && e.dispatchEvent(m), m.defaultPrevented && c && c.preventDefault(), m;
2001
+ const o = pn(), s = En(t), i = t !== s;
2002
+ let a = null, c = !0, u = !0, m = !1;
2003
+ i && o && (a = o.Event(t, n), o(e).trigger(a), c = !a.isPropagationStopped(), u = !a.isImmediatePropagationStopped(), m = a.isDefaultPrevented());
2004
+ const p = We(new Event(t, { bubbles: c, cancelable: !0 }), n);
2005
+ return m && p.preventDefault(), u && e.dispatchEvent(p), p.defaultPrevented && a && a.preventDefault(), p;
1085
2006
  }
1086
2007
  };
1087
- function Ie(e, t = {}) {
1088
- for (const [n, r] of Object.entries(t))
2008
+ function We(e, t = {}) {
2009
+ for (const [n, o] of Object.entries(t))
1089
2010
  try {
1090
- e[n] = r;
2011
+ e[n] = o;
1091
2012
  } catch {
1092
2013
  Object.defineProperty(e, n, {
1093
2014
  configurable: !0,
1094
2015
  get() {
1095
- return r;
2016
+ return o;
1096
2017
  }
1097
2018
  });
1098
2019
  }
1099
2020
  return e;
1100
2021
  }
1101
- function Ge(e) {
2022
+ function lt(e) {
1102
2023
  if (e === "true")
1103
2024
  return !0;
1104
2025
  if (e === "false")
@@ -1115,31 +2036,31 @@ function Ge(e) {
1115
2036
  return e;
1116
2037
  }
1117
2038
  }
1118
- function be(e) {
2039
+ function Le(e) {
1119
2040
  return e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`);
1120
2041
  }
1121
- const de = {
2042
+ const ve = {
1122
2043
  setDataAttribute(e, t, n) {
1123
- e.setAttribute(`data-bs-${be(t)}`, n);
2044
+ e.setAttribute(`data-bs-${Le(t)}`, n);
1124
2045
  },
1125
2046
  removeDataAttribute(e, t) {
1126
- e.removeAttribute(`data-bs-${be(t)}`);
2047
+ e.removeAttribute(`data-bs-${Le(t)}`);
1127
2048
  },
1128
2049
  getDataAttributes(e) {
1129
2050
  if (!e)
1130
2051
  return {};
1131
- const t = {}, n = Object.keys(e.dataset).filter((r) => r.startsWith("bs") && !r.startsWith("bsConfig"));
1132
- for (const r of n) {
1133
- let o = r.replace(/^bs/, "");
1134
- o = o.charAt(0).toLowerCase() + o.slice(1, o.length), t[o] = Ge(e.dataset[r]);
2052
+ const t = {}, n = Object.keys(e.dataset).filter((o) => o.startsWith("bs") && !o.startsWith("bsConfig"));
2053
+ for (const o of n) {
2054
+ let s = o.replace(/^bs/, "");
2055
+ s = s.charAt(0).toLowerCase() + s.slice(1), t[s] = lt(e.dataset[o]);
1135
2056
  }
1136
2057
  return t;
1137
2058
  },
1138
2059
  getDataAttribute(e, t) {
1139
- return Ge(e.getAttribute(`data-bs-${be(t)}`));
2060
+ return lt(e.getAttribute(`data-bs-${Le(t)}`));
1140
2061
  }
1141
2062
  };
1142
- class Pn {
2063
+ class Ur {
1143
2064
  // Getters
1144
2065
  static get Default() {
1145
2066
  return {};
@@ -1157,50 +2078,51 @@ class Pn {
1157
2078
  return t;
1158
2079
  }
1159
2080
  _mergeConfigObj(t, n) {
1160
- const r = J(n) ? de.getDataAttribute(n, "config") : {};
2081
+ const o = Y(n) ? ve.getDataAttribute(n, "config") : {};
1161
2082
  return {
1162
2083
  ...this.constructor.Default,
1163
- ...typeof r == "object" ? r : {},
1164
- ...J(n) ? de.getDataAttributes(n) : {},
2084
+ ...typeof o == "object" ? o : {},
2085
+ ...Y(n) ? ve.getDataAttributes(n) : {},
1165
2086
  ...typeof t == "object" ? t : {}
1166
2087
  };
1167
2088
  }
1168
2089
  _typeCheckConfig(t, n = this.constructor.DefaultType) {
1169
- for (const [r, o] of Object.entries(n)) {
1170
- const a = t[r], c = J(a) ? "element" : fn(a);
1171
- if (!new RegExp(o).test(c))
2090
+ for (const [o, s] of Object.entries(n)) {
2091
+ const i = t[o], a = Y(i) ? "element" : wr(i);
2092
+ if (!new RegExp(s).test(a))
1172
2093
  throw new TypeError(
1173
- `${this.constructor.NAME.toUpperCase()}: Option "${r}" provided type "${c}" but expected type "${o}".`
2094
+ `${this.constructor.NAME.toUpperCase()}: Option "${o}" provided type "${a}" but expected type "${s}".`
1174
2095
  );
1175
2096
  }
1176
2097
  }
1177
2098
  }
1178
- const Tn = "5.3.3";
1179
- class Dn extends Pn {
2099
+ const Vr = "5.3.8";
2100
+ class Br extends Ur {
1180
2101
  constructor(t, n) {
1181
- super(), t = Oe(t), t && (this._element = t, this._config = this._getConfig(n), pe.set(this._element, this.constructor.DATA_KEY, this));
2102
+ super(), t = je(t), t && (this._element = t, this._config = this._getConfig(n), we.set(this._element, this.constructor.DATA_KEY, this));
1182
2103
  }
1183
2104
  // Public
1184
2105
  dispose() {
1185
- pe.remove(this._element, this.constructor.DATA_KEY), I.off(this._element, this.constructor.EVENT_KEY);
2106
+ we.remove(this._element, this.constructor.DATA_KEY), I.off(this._element, this.constructor.EVENT_KEY);
1186
2107
  for (const t of Object.getOwnPropertyNames(this))
1187
2108
  this[t] = null;
1188
2109
  }
1189
- _queueCallback(t, n, r = !0) {
1190
- bn(t, n, r);
2110
+ // Private
2111
+ _queueCallback(t, n, o = !0) {
2112
+ Sr(t, n, o);
1191
2113
  }
1192
2114
  _getConfig(t) {
1193
2115
  return t = this._mergeConfigObj(t, this._element), t = this._configAfterMerge(t), this._typeCheckConfig(t), t;
1194
2116
  }
1195
2117
  // Static
1196
2118
  static getInstance(t) {
1197
- return pe.get(Oe(t), this.DATA_KEY);
2119
+ return we.get(je(t), this.DATA_KEY);
1198
2120
  }
1199
2121
  static getOrCreateInstance(t, n = {}) {
1200
2122
  return this.getInstance(t) || new this(t, typeof n == "object" ? n : null);
1201
2123
  }
1202
2124
  static get VERSION() {
1203
- return Tn;
2125
+ return Vr;
1204
2126
  }
1205
2127
  static get DATA_KEY() {
1206
2128
  return `bs.${this.NAME}`;
@@ -1212,7 +2134,7 @@ class Dn extends Pn {
1212
2134
  return `${t}${this.EVENT_KEY}`;
1213
2135
  }
1214
2136
  }
1215
- const ye = (e) => {
2137
+ const Oe = (e) => {
1216
2138
  let t = e.getAttribute("data-bs-target");
1217
2139
  if (!t || t === "#") {
1218
2140
  let n = e.getAttribute("href");
@@ -1220,8 +2142,8 @@ const ye = (e) => {
1220
2142
  return null;
1221
2143
  n.includes("#") && !n.startsWith("#") && (n = `#${n.split("#")[1]}`), t = n && n !== "#" ? n.trim() : null;
1222
2144
  }
1223
- return t ? t.split(",").map((n) => ft(n)).join(",") : null;
1224
- }, U = {
2145
+ return t ? t.split(",").map((n) => mn(n)).join(",") : null;
2146
+ }, V = {
1225
2147
  find(e, t = document.documentElement) {
1226
2148
  return [].concat(...Element.prototype.querySelectorAll.call(t, e));
1227
2149
  },
@@ -1233,9 +2155,9 @@ const ye = (e) => {
1233
2155
  },
1234
2156
  parents(e, t) {
1235
2157
  const n = [];
1236
- let r = e.parentNode.closest(t);
1237
- for (; r; )
1238
- n.push(r), r = r.parentNode.closest(t);
2158
+ let o = e.parentNode.closest(t);
2159
+ for (; o; )
2160
+ n.push(o), o = o.parentNode.closest(t);
1239
2161
  return n;
1240
2162
  },
1241
2163
  prev(e, t) {
@@ -1268,28 +2190,28 @@ const ye = (e) => {
1268
2190
  "[tabindex]",
1269
2191
  '[contenteditable="true"]'
1270
2192
  ].map((n) => `${n}:not([tabindex^="-"])`).join(",");
1271
- return this.find(t, e).filter((n) => !Se(n) && mt(n));
2193
+ return this.find(t, e).filter((n) => !Fe(n) && fn(n));
1272
2194
  },
1273
2195
  getSelectorFromElement(e) {
1274
- const t = ye(e);
1275
- return t && U.findOne(t) ? t : null;
2196
+ const t = Oe(e);
2197
+ return t && V.findOne(t) ? t : null;
1276
2198
  },
1277
2199
  getElementFromSelector(e) {
1278
- const t = ye(e);
1279
- return t ? U.findOne(t) : null;
2200
+ const t = Oe(e);
2201
+ return t ? V.findOne(t) : null;
1280
2202
  },
1281
2203
  getMultipleElementsFromSelector(e) {
1282
- const t = ye(e);
1283
- return t ? U.find(t) : [];
2204
+ const t = Oe(e);
2205
+ return t ? V.find(t) : [];
1284
2206
  }
1285
- }, Ze = "dropdown", Ln = "bs.dropdown", Z = `.${Ln}`, Ve = ".data-api", jn = "Escape", Xe = "Tab", xn = "ArrowUp", et = "ArrowDown", kn = 2, Rn = `hide${Z}`, Mn = `hidden${Z}`, vn = `show${Z}`, Fn = `shown${Z}`, Nt = `click${Z}${Ve}`, Ct = `keydown${Z}${Ve}`, In = `keyup${Z}${Ve}`, te = "show", Vn = "dropup", $n = "dropend", Un = "dropstart", Bn = "dropup-center", Kn = "dropdown-center", q = '[data-bs-toggle="dropdown"]:not(.disabled):not(:disabled)', Hn = `${q}.${te}`, le = ".dropdown-menu", wn = ".navbar", Yn = ".navbar-nav", Wn = ".dropdown-menu .dropdown-item:not(.disabled):not(:disabled)", qn = ne() ? "top-end" : "top-start", zn = ne() ? "top-start" : "top-end", Jn = ne() ? "bottom-end" : "bottom-start", Qn = ne() ? "bottom-start" : "bottom-end", Gn = ne() ? "left-start" : "right-start", Zn = ne() ? "right-start" : "left-start", Xn = "top", er = "bottom", tr = {
2207
+ }, dt = "dropdown", $r = "bs.dropdown", z = `.${$r}`, ze = ".data-api", qr = "Escape", ut = "Tab", Hr = "ArrowUp", mt = "ArrowDown", Kr = 2, Gr = `hide${z}`, Yr = `hidden${z}`, Wr = `show${z}`, zr = `shown${z}`, Cn = `click${z}${ze}`, _n = `keydown${z}${ze}`, Jr = `keyup${z}${ze}`, Q = "show", Qr = "dropup", Zr = "dropend", Xr = "dropstart", eo = "dropup-center", to = "dropdown-center", G = '[data-bs-toggle="dropdown"]:not(.disabled):not(:disabled)', no = `${G}.${Q}`, ge = ".dropdown-menu", ro = ".navbar", oo = ".navbar-nav", so = ".dropdown-menu .dropdown-item:not(.disabled):not(:disabled)", io = oe() ? "top-end" : "top-start", ao = oe() ? "top-start" : "top-end", co = oe() ? "bottom-end" : "bottom-start", lo = oe() ? "bottom-start" : "bottom-end", uo = oe() ? "left-start" : "right-start", mo = oe() ? "right-start" : "left-start", fo = "top", po = "bottom", ho = {
1286
2208
  autoClose: !0,
1287
2209
  boundary: "clippingParents",
1288
2210
  display: "dynamic",
1289
2211
  offset: [0, 2],
1290
2212
  popperConfig: null,
1291
2213
  reference: "toggle"
1292
- }, nr = {
2214
+ }, go = {
1293
2215
  autoClose: "(boolean|string)",
1294
2216
  boundary: "(string|element)",
1295
2217
  display: "string",
@@ -1297,39 +2219,39 @@ const ye = (e) => {
1297
2219
  popperConfig: "(null|object|function)",
1298
2220
  reference: "(string|element|object)"
1299
2221
  };
1300
- let X = class ue extends Dn {
2222
+ let J = class be extends Br {
1301
2223
  constructor(t, n) {
1302
- super(t, n), this._popper = null, this._parent = this._element.parentNode, this._menu = U.next(this._element, le)[0] || U.prev(this._element, le)[0] || U.findOne(le, this._parent), this._inNavbar = this._detectNavbar();
2224
+ super(t, n), this._popper = null, this._parent = this._element.parentNode, this._menu = V.next(this._element, ge)[0] || V.prev(this._element, ge)[0] || V.findOne(ge, this._parent), this._inNavbar = this._detectNavbar();
1303
2225
  }
1304
2226
  // Getters
1305
2227
  static get Default() {
1306
- return tr;
2228
+ return ho;
1307
2229
  }
1308
2230
  static get DefaultType() {
1309
- return nr;
2231
+ return go;
1310
2232
  }
1311
2233
  static get NAME() {
1312
- return Ze;
2234
+ return dt;
1313
2235
  }
1314
2236
  // Public
1315
2237
  toggle() {
1316
2238
  return this._isShown() ? this.hide() : this.show();
1317
2239
  }
1318
2240
  show() {
1319
- if (Se(this._element) || this._isShown())
2241
+ if (Fe(this._element) || this._isShown())
1320
2242
  return;
1321
2243
  const t = {
1322
2244
  relatedTarget: this._element
1323
2245
  };
1324
- if (!I.trigger(this._element, vn, t).defaultPrevented) {
1325
- if (this._createPopper(), "ontouchstart" in document.documentElement && !this._parent.closest(Yn))
1326
- for (const r of [].concat(...document.body.children))
1327
- I.on(r, "mouseover", ze);
1328
- this._element.focus(), this._element.setAttribute("aria-expanded", !0), this._menu.classList.add(te), this._element.classList.add(te), I.trigger(this._element, Fn, t);
2246
+ if (!I.trigger(this._element, Wr, t).defaultPrevented) {
2247
+ if (this._createPopper(), "ontouchstart" in document.documentElement && !this._parent.closest(oo))
2248
+ for (const o of [].concat(...document.body.children))
2249
+ I.on(o, "mouseover", it);
2250
+ this._element.focus(), this._element.setAttribute("aria-expanded", !0), this._menu.classList.add(Q), this._element.classList.add(Q), I.trigger(this._element, zr, t);
1329
2251
  }
1330
2252
  }
1331
2253
  hide() {
1332
- if (Se(this._element) || !this._isShown())
2254
+ if (Fe(this._element) || !this._isShown())
1333
2255
  return;
1334
2256
  const t = {
1335
2257
  relatedTarget: this._element
@@ -1344,44 +2266,44 @@ let X = class ue extends Dn {
1344
2266
  }
1345
2267
  // Private
1346
2268
  _completeHide(t) {
1347
- if (!I.trigger(this._element, Rn, t).defaultPrevented) {
2269
+ if (!I.trigger(this._element, Gr, t).defaultPrevented) {
1348
2270
  if ("ontouchstart" in document.documentElement)
1349
- for (const r of [].concat(...document.body.children))
1350
- I.off(r, "mouseover", ze);
1351
- this._popper && this._popper.destroy(), this._menu.classList.remove(te), this._element.classList.remove(te), this._element.setAttribute("aria-expanded", "false"), de.removeDataAttribute(this._menu, "popper"), I.trigger(this._element, Mn, t);
2271
+ for (const o of [].concat(...document.body.children))
2272
+ I.off(o, "mouseover", it);
2273
+ this._popper && this._popper.destroy(), this._menu.classList.remove(Q), this._element.classList.remove(Q), this._element.setAttribute("aria-expanded", "false"), ve.removeDataAttribute(this._menu, "popper"), I.trigger(this._element, Yr, t);
1352
2274
  }
1353
2275
  }
1354
2276
  _getConfig(t) {
1355
- if (t = super._getConfig(t), typeof t.reference == "object" && !J(t.reference) && typeof t.reference.getBoundingClientRect != "function")
1356
- throw new TypeError(`${Ze.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`);
2277
+ if (t = super._getConfig(t), typeof t.reference == "object" && !Y(t.reference) && typeof t.reference.getBoundingClientRect != "function")
2278
+ throw new TypeError(`${dt.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`);
1357
2279
  return t;
1358
2280
  }
1359
2281
  _createPopper() {
1360
- if (typeof He > "u")
1361
- throw new TypeError("Bootstrap's dropdowns require Popper (https://popper.js.org)");
2282
+ if (typeof tt > "u")
2283
+ throw new TypeError("Bootstrap's dropdowns require Popper (https://popper.js.org/docs/v2/)");
1362
2284
  let t = this._element;
1363
- this._config.reference === "parent" ? t = this._parent : J(this._config.reference) ? t = Oe(this._config.reference) : typeof this._config.reference == "object" && (t = this._config.reference);
2285
+ this._config.reference === "parent" ? t = this._parent : Y(this._config.reference) ? t = je(this._config.reference) : typeof this._config.reference == "object" && (t = this._config.reference);
1364
2286
  const n = this._getPopperConfig();
1365
- this._popper = He.createPopper(t, this._menu, n);
2287
+ this._popper = tt.createPopper(t, this._menu, n);
1366
2288
  }
1367
2289
  _isShown() {
1368
- return this._menu.classList.contains(te);
2290
+ return this._menu.classList.contains(Q);
1369
2291
  }
1370
2292
  _getPlacement() {
1371
2293
  const t = this._parent;
1372
- if (t.classList.contains($n))
1373
- return Gn;
1374
- if (t.classList.contains(Un))
1375
- return Zn;
1376
- if (t.classList.contains(Bn))
1377
- return Xn;
1378
- if (t.classList.contains(Kn))
1379
- return er;
2294
+ if (t.classList.contains(Zr))
2295
+ return uo;
2296
+ if (t.classList.contains(Xr))
2297
+ return mo;
2298
+ if (t.classList.contains(eo))
2299
+ return fo;
2300
+ if (t.classList.contains(to))
2301
+ return po;
1380
2302
  const n = getComputedStyle(this._menu).getPropertyValue("--bs-position").trim() === "end";
1381
- return t.classList.contains(Vn) ? n ? zn : qn : n ? Qn : Jn;
2303
+ return t.classList.contains(Qr) ? n ? ao : io : n ? lo : co;
1382
2304
  }
1383
2305
  _detectNavbar() {
1384
- return this._element.closest(wn) !== null;
2306
+ return this._element.closest(ro) !== null;
1385
2307
  }
1386
2308
  _getOffset() {
1387
2309
  const { offset: t } = this._config;
@@ -1405,22 +2327,22 @@ let X = class ue extends Dn {
1405
2327
  }
1406
2328
  ]
1407
2329
  };
1408
- return (this._inNavbar || this._config.display === "static") && (de.setDataAttribute(this._menu, "popper", "static"), t.modifiers = [{
2330
+ return (this._inNavbar || this._config.display === "static") && (ve.setDataAttribute(this._menu, "popper", "static"), t.modifiers = [{
1409
2331
  name: "applyStyles",
1410
2332
  enabled: !1
1411
2333
  }]), {
1412
2334
  ...t,
1413
- ...Pe(this._config.popperConfig, [t])
2335
+ ...Me(this._config.popperConfig, [void 0, t])
1414
2336
  };
1415
2337
  }
1416
2338
  _selectMenuItem({ key: t, target: n }) {
1417
- const r = U.find(Wn, this._menu).filter((o) => mt(o));
1418
- r.length && yn(r, n, t === et, !r.includes(n)).focus();
2339
+ const o = V.find(so, this._menu).filter((s) => fn(s));
2340
+ o.length && kr(o, n, t === mt, !o.includes(n)).focus();
1419
2341
  }
1420
2342
  // Static
1421
2343
  static jQueryInterface(t) {
1422
2344
  return this.each(function() {
1423
- const n = ue.getOrCreateInstance(this, t);
2345
+ const n = be.getOrCreateInstance(this, t);
1424
2346
  if (typeof t == "string") {
1425
2347
  if (typeof n[t] > "u")
1426
2348
  throw new TypeError(`No method named "${t}"`);
@@ -1429,472 +2351,541 @@ let X = class ue extends Dn {
1429
2351
  });
1430
2352
  }
1431
2353
  static clearMenus(t) {
1432
- if (t.button === kn || t.type === "keyup" && t.key !== Xe)
2354
+ if (t.button === Kr || t.type === "keyup" && t.key !== ut)
1433
2355
  return;
1434
- const n = U.find(Hn);
1435
- for (const r of n) {
1436
- const o = ue.getInstance(r);
1437
- if (!o || o._config.autoClose === !1)
2356
+ const n = V.find(no);
2357
+ for (const o of n) {
2358
+ const s = be.getInstance(o);
2359
+ if (!s || s._config.autoClose === !1)
1438
2360
  continue;
1439
- const a = t.composedPath(), c = a.includes(o._menu);
1440
- if (a.includes(o._element) || o._config.autoClose === "inside" && !c || o._config.autoClose === "outside" && c || o._menu.contains(t.target) && (t.type === "keyup" && t.key === Xe || /input|select|option|textarea|form/i.test(t.target.tagName)))
2361
+ const i = t.composedPath(), a = i.includes(s._menu);
2362
+ if (i.includes(s._element) || s._config.autoClose === "inside" && !a || s._config.autoClose === "outside" && a || s._menu.contains(t.target) && (t.type === "keyup" && t.key === ut || /input|select|option|textarea|form/i.test(t.target.tagName)))
1441
2363
  continue;
1442
- const u = { relatedTarget: o._element };
1443
- t.type === "click" && (u.clickEvent = t), o._completeHide(u);
2364
+ const c = { relatedTarget: s._element };
2365
+ t.type === "click" && (c.clickEvent = t), s._completeHide(c);
1444
2366
  }
1445
2367
  }
1446
2368
  static dataApiKeydownHandler(t) {
1447
- const n = /input|textarea/i.test(t.target.tagName), r = t.key === jn, o = [xn, et].includes(t.key);
1448
- if (!o && !r || n && !r)
2369
+ const n = /input|textarea/i.test(t.target.tagName), o = t.key === qr, s = [Hr, mt].includes(t.key);
2370
+ if (!s && !o || n && !o)
1449
2371
  return;
1450
2372
  t.preventDefault();
1451
- const a = this.matches(q) ? this : U.prev(this, q)[0] || U.next(this, q)[0] || U.findOne(q, t.delegateTarget.parentNode), c = ue.getOrCreateInstance(a);
1452
- if (o) {
1453
- t.stopPropagation(), c.show(), c._selectMenuItem(t);
2373
+ const i = this.matches(G) ? this : V.prev(this, G)[0] || V.next(this, G)[0] || V.findOne(G, t.delegateTarget.parentNode), a = be.getOrCreateInstance(i);
2374
+ if (s) {
2375
+ t.stopPropagation(), a.show(), a._selectMenuItem(t);
1454
2376
  return;
1455
2377
  }
1456
- c._isShown() && (t.stopPropagation(), c.hide(), a.focus());
2378
+ a._isShown() && (t.stopPropagation(), a.hide(), i.focus());
1457
2379
  }
1458
2380
  };
1459
- I.on(document, Ct, q, X.dataApiKeydownHandler);
1460
- I.on(document, Ct, le, X.dataApiKeydownHandler);
1461
- I.on(document, Nt, X.clearMenus);
1462
- I.on(document, In, X.clearMenus);
1463
- I.on(document, Nt, q, function(e) {
1464
- e.preventDefault(), X.getOrCreateInstance(this).toggle();
2381
+ I.on(document, _n, G, J.dataApiKeydownHandler);
2382
+ I.on(document, _n, ge, J.dataApiKeydownHandler);
2383
+ I.on(document, Cn, J.clearMenus);
2384
+ I.on(document, Jr, J.clearMenus);
2385
+ I.on(document, Cn, G, function(e) {
2386
+ e.preventDefault(), J.getOrCreateInstance(this).toggle();
1465
2387
  });
1466
- gn(X);
1467
- const fe = ({ children: e, disabled: t, className: n }) => /* @__PURE__ */ s(k, { children: e }), oe = ({ children: e, ...t }) => /* @__PURE__ */ s("div", { className: "dropdown-menu", children: e }), At = ({ items: e, className: t, children: n, icon: r }) => {
1468
- const o = R(null);
1469
- v(() => {
1470
- const m = new X(o.current);
2388
+ Or(J);
2389
+ const Ee = ({ children: e, disabled: t, className: n }) => /* @__PURE__ */ r(A, { children: e }), ce = ({ children: e, ...t }) => /* @__PURE__ */ r("div", { className: "dropdown-menu", children: e }), Je = ({ className: e, children: t, autoClose: n, icon: o }) => {
2390
+ const s = S(null);
2391
+ N(() => {
2392
+ const p = new J(s.current, {
2393
+ autoClose: n ?? !0
2394
+ });
1471
2395
  return () => {
1472
- m.dispose();
2396
+ p.dispose();
1473
2397
  };
1474
2398
  }, []);
1475
- const a = S.Children.toArray(n).find((m) => S.isValidElement(m) && m.type === oe), c = S.Children.toArray(n).filter((m) => S.isValidElement(m) && m.type === qe), u = S.Children.toArray(n).find((m) => S.isValidElement(m) && m.type === fe), h = S.Children.toArray(n).filter((m) => !S.isValidElement(m) || m.type !== qe && m.type !== oe && m.type !== fe), i = S.isValidElement(u) ? u.props : {};
1476
- return /* @__PURE__ */ _("div", { className: [...(t || "").split(" "), "dropdown"].filter((m, f, l) => l.indexOf(m) === f).join(" "), children: [
1477
- /* @__PURE__ */ s(me, { ref: o, "data-bs-toggle": "dropdown", ...i, className: [...(i.className || "").split(" "), "btn", "dropdown-toggle"].filter((m, f, l) => l.indexOf(m) === f).join(" "), children: i.children ? i.children : h }),
1478
- a || /* @__PURE__ */ s(oe, { children: c })
2399
+ const i = v.Children.toArray(t).find((p) => v.isValidElement(p) && p.type === ce), a = v.Children.toArray(t).filter((p) => v.isValidElement(p) && p.type === M), c = v.Children.toArray(t).find((p) => v.isValidElement(p) && p.type === Ee), u = v.Children.toArray(t).filter((p) => !v.isValidElement(p) || p.type !== M && p.type !== ce && p.type !== Ee), m = v.isValidElement(c) ? c.props : {};
2400
+ return /* @__PURE__ */ C("div", { className: [...(e || "").split(" "), "dropdown"].filter((p, f, y) => y.indexOf(p) === f).join(" "), children: [
2401
+ /* @__PURE__ */ r(fe, { ref: s, "data-bs-toggle": "dropdown", ...m, className: [...(m.className || "").split(" ")].filter((p, f, y) => y.indexOf(p) === f).join(" "), children: m.children ? m.children : u }),
2402
+ i || /* @__PURE__ */ r(ce, { children: a })
1479
2403
  ] });
1480
- }, rr = ie(({ data: e, columns: t, options: n, onClick: r, onBatchClick: o, routeParams: a, namespace: c }, u) => {
1481
- var D, y, O, M, x, L, F;
1482
- t = (t || ((D = e == null ? void 0 : e.entity) == null ? void 0 : D.columns) || []).filter((g) => g.group !== !1);
1483
- const [, h] = $(), i = (y = e == null ? void 0 : e.entity) == null ? void 0 : y.primaryColumn, m = Object.values((e == null ? void 0 : e.action) || []), f = m.filter((g) => g.object), l = t.length + (m.length ? 1 : 0), b = ((e == null ? void 0 : e.entity.data.items) || []).map((g) => g[(i == null ? void 0 : i.field) || ""] || 0), E = R([]), d = !!b.length && b.reduce((g, T) => g && E.current.includes(T), !0), p = (x = (M = (O = e == null ? void 0 : e.form) == null ? void 0 : O.batch.view.children) == null ? void 0 : M.method) == null ? void 0 : x.choices, C = !!(p != null && p.length) && i, N = (g, T = !1) => {
1484
- T ? E.current.push(g) : E.current = E.current.filter((j) => j !== g), h({});
1485
- }, A = (g = !1) => {
1486
- E.current = (g ? E.current.concat(b) : E.current.filter((T) => !b.includes(T))).filter((T, j, K) => K.indexOf(T) === j), h({});
1487
- }, P = (g) => {
1488
- var K, H;
1489
- if (!o)
1490
- return;
1491
- const T = e == null ? void 0 : e.form.batch.view;
1492
- if (!C || !((K = E.current) != null && K.length))
1493
- return;
1494
- const j = new FormData();
1495
- E.current.forEach((re) => {
1496
- var Ue;
1497
- j.append(`${(Ue = T == null ? void 0 : T.children) == null ? void 0 : Ue.ids.full_name}[]`, re.toString());
1498
- }), j.append(((H = T == null ? void 0 : T.children) == null ? void 0 : H.method.full_name) || "method", g), o(g, E.current, j);
1499
- };
1500
- return /* @__PURE__ */ _(k, { children: [
1501
- C && /* @__PURE__ */ _("div", { className: "btn-group btn-group-sm mb-2", children: [
1502
- /* @__PURE__ */ s("label", { className: "btn btn-light", children: /* @__PURE__ */ s(
1503
- "input",
1504
- {
1505
- checked: d,
1506
- onChange: (g) => A(g.target.checked),
1507
- type: "checkbox"
1508
- }
1509
- ) }),
1510
- /* @__PURE__ */ _(At, { className: "btn-group btn-group-sm", children: [
1511
- /* @__PURE__ */ s(fe, { disabled: !E.current.length, className: "btn-light" }),
1512
- /* @__PURE__ */ s(oe, { children: (F = (L = e.form.batch.view.children) == null ? void 0 : L.method.choices) == null ? void 0 : F.map((g) => {
1513
- const T = g.value instanceof Function ? g.value() : g.value;
1514
- return /* @__PURE__ */ s(z, { to: "#", onClick: () => P(T), className: "dropdown-item", children: g.label instanceof Function ? g.label() : g.label }, T);
1515
- }) })
1516
- ] })
1517
- ] }),
1518
- /* @__PURE__ */ _("table", { className: "table table-striped table-hover table-bordered", children: [
1519
- /* @__PURE__ */ s("thead", { children: /* @__PURE__ */ _("tr", { children: [
1520
- t.map((g, T) => /* @__PURE__ */ _("th", { children: [
1521
- /* @__PURE__ */ s(G, { namespace: (e == null ? void 0 : e.entity.name) || "unknown", data: g, prefix: "list", view: g.field + ".label", children: g.label }),
1522
- g.sortable && (e == null ? void 0 : e.sort[g.field]) !== void 0 && /* @__PURE__ */ s(
1523
- z,
1524
- {
1525
- onClick: (j) => r && r({
1526
- action: {
1527
- name: "sort",
1528
- object: !1,
1529
- namespace: c,
1530
- entity: e == null ? void 0 : e.entity.name
1531
- },
1532
- parameters: { [g.field]: e != null && e.sort[g.field] ? (e == null ? void 0 : e.sort[g.field]) === "ASC" ? "DESC" : "" : "ASC" }
1533
- }, j),
1534
- className: "btn",
1535
- to: "#",
1536
- children: e.sort[g.field] ? e.sort[g.field] === "ASC" ? "⇑" : "⇓" : "⇅"
1537
- }
1538
- )
1539
- ] }, T)),
1540
- i && f.length > 0 && /* @__PURE__ */ s("th", { className: "text-end", children: "Actions" })
1541
- ] }) }),
1542
- /* @__PURE__ */ s("tbody", { children: e && (e.entity.data.items.length ? e.entity.data.items.map(
1543
- (g, T) => /* @__PURE__ */ _("tr", { children: [
1544
- t == null ? void 0 : t.map(
1545
- (j, K) => {
1546
- var H;
1547
- return /* @__PURE__ */ _("td", { children: [
1548
- K === 0 && C && /* @__PURE__ */ s(
1549
- "input",
1550
- {
1551
- checked: E.current.includes(g[i == null ? void 0 : i.field]),
1552
- className: "me-2",
1553
- type: "checkbox",
1554
- name: e.form.batch.view.full_name,
1555
- value: g[i == null ? void 0 : i.field],
1556
- onChange: (re) => N(g[i == null ? void 0 : i.field], re.target.checked)
1557
- }
1558
- ),
1559
- /* @__PURE__ */ s(G, { namespace: c || "unknown", data: g, prefix: "list", view: j.field, children: g[j.field] !== void 0 && (g[j.field] instanceof Object ? g[j.field] instanceof Array ? g[j.field].join(", ") : JSON.stringify(g[j.field]) : (H = g[j.field]) == null ? void 0 : H.toString()) })
1560
- ] }, K);
1561
- }
1562
- ),
1563
- i && f.length > 0 && /* @__PURE__ */ s("td", { className: "text-end text-nowrap", children: f.map((j, K) => {
1564
- var H;
1565
- return /* @__PURE__ */ s(
1566
- z,
1567
- {
1568
- onClick: (re) => r && r({
1569
- action: j,
1570
- parameters: {
1571
- ...a || {},
1572
- id: g[i == null ? void 0 : i.field]
1573
- }
1574
- }, re),
1575
- className: ["btn", "btn-sm", "mb-1", "ms-1", (((H = j.route) == null ? void 0 : H.methods) ?? []).includes("DELETE") ? "btn-outline-danger" : "btn-outline-secondary"].join(" "),
1576
- to: Y(j.route, {
1577
- ...a || {},
1578
- id: g[i.field]
1579
- }),
1580
- children: j.title
1581
- },
1582
- K
1583
- );
1584
- }) })
1585
- ] }, T)
1586
- ) : /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s("td", { colSpan: l, children: "Not results found." }) })) })
1587
- ] })
1588
- ] });
1589
- }), se = ({ route: e, page: t, active: n = !1, title: r, children: o }) => {
1590
- const a = new URL(document.location.href);
1591
- return a.searchParams.set("page", t.toString()), /* @__PURE__ */ s("li", { className: `page-item ${n ? "active" : ""}`, children: /* @__PURE__ */ s(
1592
- z,
1593
- {
1594
- to: a.toString(),
1595
- className: "page-link",
1596
- title: r,
1597
- children: o || t
1598
- }
1599
- ) });
1600
- }, sr = ({ meta: e }) => {
1601
- const n = e.totalPages, r = e.page || 1, o = e.links, a = !!e.totalPages;
1602
- return /* @__PURE__ */ _("div", { className: "d-flex flex-column justiry-content-center", children: [
1603
- /* @__PURE__ */ _("small", { className: "mb-2", children: [
1604
- e.totalResults,
1605
- " Results",
1606
- a && /* @__PURE__ */ _(k, { children: [
1607
- " - Page ",
1608
- r,
1609
- " of ",
1610
- e.totalPages
1611
- ] })
1612
- ] }),
1613
- a && /* @__PURE__ */ s("nav", { "aria-label": "Page navigation", className: "m-auto text-center d-inline", children: /* @__PURE__ */ _("ul", { className: "pagination pagination-sm", children: [
1614
- r > 1 && /* @__PURE__ */ s(se, { page: r - 1, title: "Go to First Page", children: "«" }),
1615
- e.links[0] !== 1 && /* @__PURE__ */ _(k, { children: [
1616
- /* @__PURE__ */ s(se, { page: 1, active: r === 1, children: 1 }, 1),
1617
- /* @__PURE__ */ s("div", { className: "page-item", children: /* @__PURE__ */ s("a", { className: "page-link", children: "..." }) })
1618
- ] }),
1619
- (o || []).map((c, u) => /* @__PURE__ */ s(se, { page: c, active: c === r }, u)),
1620
- [...e.links].reverse()[0] !== n && /* @__PURE__ */ _(k, { children: [
1621
- /* @__PURE__ */ s("div", { className: "page-item", children: /* @__PURE__ */ s("a", { className: "page-link", children: "..." }) }),
1622
- /* @__PURE__ */ s(
1623
- se,
1624
- {
1625
- page: n,
1626
- active: n === r,
1627
- children: n
1628
- },
1629
- n
1630
- )
1631
- ] }),
1632
- r < n && /* @__PURE__ */ s(se, { page: e.totalPages, title: "Go to Last Page", children: "»" })
1633
- ] }) })
1634
- ] });
1635
- }, De = (e, t = !0) => (Object.entries(e).map(([n, r]) => (t && r instanceof Object && (r = De(r)), [n, r])).filter(([, n]) => !(n instanceof Object ? Object.keys(n).length : n)).forEach(([n]) => {
2404
+ }, Ve = (e, t = !0) => (Object.entries(e).map(([n, o]) => (t && o instanceof Object && (o = Ve(o)), [n, o])).filter(([, n]) => n instanceof Object ? !Object.keys(n).length : ["", null, void 0].includes(n)).forEach(([n]) => {
1636
2405
  delete e[n];
1637
- }), e), Ot = "settings", Le = {
1638
- locale: "en"
1639
- // accessToken: null,
1640
- // user: null,
1641
- // branch: null,
1642
- // authChain: []
1643
- }, or = S.createContext(Le);
1644
- function tt(e, t) {
1645
- const n = {
1646
- ...e,
1647
- ...t
1648
- };
1649
- return sessionStorage.setItem(Ot, btoa(JSON.stringify(n))), n;
1650
- }
1651
- function ar(e) {
1652
- let t = Le;
1653
- try {
1654
- const n = sessionStorage.getItem(Ot);
1655
- t = JSON.parse(atob(n || ""));
1656
- } catch {
1657
- tt(Le, t);
1658
- }
1659
- return /* @__PURE__ */ s(or.Provider, { value: S.useReducer(tt, t), children: e.children });
1660
- }
1661
- const St = ({ children: e }) => /* @__PURE__ */ s(ir, { children: /* @__PURE__ */ s(cn, { children: /* @__PURE__ */ s(Gt, { children: /* @__PURE__ */ s(ar, { children: e }) }) }) }), Pt = S.createContext({});
1662
- function cr() {
1663
- const { setModal: e } = S.useContext(Pt);
1664
- return {
1665
- openModal: (t) => {
1666
- e && e(t);
1667
- }
1668
- };
1669
- }
1670
- function ir(e) {
1671
- const [t, n] = $(), r = R(0);
1672
- return v(() => {
1673
- r.current += 1;
1674
- }, [t]), /* @__PURE__ */ _(Pt.Provider, { value: { setModal: n }, children: [
1675
- e.children,
1676
- t && /* @__PURE__ */ s(St, { children: /* @__PURE__ */ s(
1677
- Tt,
2406
+ }), e), bo = ({ formView: e, onClick: t }) => {
2407
+ const n = (s) => {
2408
+ if (s.choices !== void 0) {
2409
+ const i = s.choices?.reduce((a, c) => [...a, ...c.choices || [c]], []).reduce((a, c) => {
2410
+ const u = c.value instanceof Function ? c.value(c) : c.value, m = c.label instanceof Function ? c.label(c) : c.label;
2411
+ return { ...a, [u]: m };
2412
+ }, {});
2413
+ return s.choices ? Object.values(s.data instanceof Object ? s.data : [s.data]).map((a) => i[a] ?? a).join(", ") : s.data;
2414
+ } else if (s.checked !== void 0)
2415
+ return s.checked ? "Yes" : "No";
2416
+ return s.data;
2417
+ }, o = Object.values(e.children || []).filter((s) => s.data !== null);
2418
+ return !!o.length && /* @__PURE__ */ r("div", { className: "filters d-flex mb-sm overflow-auto", children: o.filter((s) => s.data !== null).map((s, i) => /* @__PURE__ */ C("div", { className: "filters-item d-flex text-nowrap flex-column me-2 mb-2", children: [
2419
+ /* @__PURE__ */ r("small", { className: "mb-2", children: /* @__PURE__ */ r(D, { children: s.label }) }),
2420
+ /* @__PURE__ */ C("div", { className: "btn btn-sm btn-primary me-1 mb-1", children: [
2421
+ /* @__PURE__ */ r(D, { children: n(s) }),
2422
+ t && /* @__PURE__ */ r("span", { onClick: () => t(s.name), className: "ms-2", children: "×" })
2423
+ ] })
2424
+ ] }, i)) });
2425
+ }, yo = () => {
2426
+ const { actions: e, isSelectedAll: t, toggleAll: n, selected: o, executeAction: s, clear: i } = an() || {};
2427
+ return e && /* @__PURE__ */ C("div", { className: "btn-group btn-group-sm mb-2", children: [
2428
+ /* @__PURE__ */ r("label", { className: "btn btn-light", children: /* @__PURE__ */ r(
2429
+ "input",
1678
2430
  {
1679
- view: t.action.action.name || "list",
1680
- namespace: t.action.action.namespace || "",
1681
- props: {
1682
- action: t.action.action,
1683
- routeParams: t.action.parameters,
1684
- modal: !0,
1685
- props: t.props
1686
- }
1687
- },
1688
- r.current
1689
- ) })
2431
+ checked: t,
2432
+ onChange: (a) => n?.(a.target.checked),
2433
+ type: "checkbox"
2434
+ }
2435
+ ) }),
2436
+ !!o?.length && /* @__PURE__ */ C(Je, { className: "btn btn-sm btn-light", children: [
2437
+ /* @__PURE__ */ r(Ee, { disabled: !o?.length, className: "bg-transparent border-0", children: !!o?.length && /* @__PURE__ */ r(D, { properties: { number: o?.length }, children: ":number selected" }) }),
2438
+ /* @__PURE__ */ r(ce, { children: Object.keys(e).map((a) => /* @__PURE__ */ r(
2439
+ M,
2440
+ {
2441
+ to: "#",
2442
+ onClick: () => s?.(a),
2443
+ className: "dropdown-item",
2444
+ children: e[a]
2445
+ },
2446
+ a
2447
+ )) })
2448
+ ] }),
2449
+ !!o?.length && /* @__PURE__ */ r("button", { title: "Clear selection", onClick: i, className: "btn btn-light", children: "×" })
1690
2450
  ] });
1691
- }
1692
- const lr = W(({ action: e, embedded: t = !1 }) => {
1693
- var N, A, P, D;
1694
- const n = Kt(), [r, o] = Ht(), a = R(void 0), c = R(vt(r)), u = R(null), { openModal: h } = cr(), { open: i } = dt(), m = e.action.entity;
1695
- if (!m)
2451
+ }, vo = Mt(xe(({ embedded: e = !1, title: t, className: n, onAction: o }) => {
2452
+ const { action: s, setAction: i } = te(), { generateActionLink: a, location: c, navigate: u } = j(), m = S(null), { openModal: p } = Qe(), { open: f } = Ge(), y = s.action.entity;
2453
+ if (!y)
1696
2454
  throw new Error("Invalid Entity");
1697
- const { results: f, refresh: l, setQueryParameters: b } = it({ entityAction: e.action, initParameters: e.parameters, initQueryParameters: c.current }), E = Object.values((f == null ? void 0 : f.action) ?? []).filter((y) => !y.object && y.name !== e.action.name), d = (y) => {
1698
- y == null || y.forEach((x) => {
1699
- var L, F;
1700
- (F = (L = c.current) == null ? void 0 : L.filter) == null || delete F[x];
1701
- });
1702
- const O = {
1703
- ...c.current && c.current,
1704
- ...a.current && { sort: a.current }
1705
- }, M = nt(De(O));
1706
- t ? b(M) : o(M);
1707
- }, p = (y, O, M) => {
1708
- console.log("method", O, M), i({
2455
+ const { results: E, refresh: _ } = ne() || {}, b = Object.values(E?.action ?? []).filter((h) => h.visibility === Ye.List && h.name !== s.action.name), l = ({ newAction: h, excludeFilterParameters: x }) => {
2456
+ const P = { ...h ?? s };
2457
+ if (x?.forEach((L) => {
2458
+ delete P.query?.filter?.[L];
2459
+ }), e)
2460
+ i(P);
2461
+ else {
2462
+ const L = a(P);
2463
+ u(L);
2464
+ }
2465
+ }, d = (h, x, P) => new Promise((L, O) => {
2466
+ f({
1709
2467
  title: "Are you sure?",
1710
- icon: ae.confirm,
1711
- onResult: (x) => {
1712
- x.isConfirmed && ce().post(Y(e.action.route, e.parameters), M).catch((L) => {
1713
- console.log("error", L);
2468
+ icon: Z.confirm,
2469
+ onResult: (k) => {
2470
+ k.isConfirmed ? le().post({
2471
+ url: a(s),
2472
+ body: P,
2473
+ bodyType: ht.FormData
2474
+ }).catch((F) => {
2475
+ O();
1714
2476
  }).finally(() => {
1715
- console.log("done"), l();
1716
- });
2477
+ _?.(), L();
2478
+ }) : O();
1717
2479
  }
1718
2480
  });
1719
- }, C = (y, O) => {
1720
- switch (y.parameters !== void 0 && (y.parameters = De(y.parameters), Object.keys(y.parameters).length || (y.parameters = void 0)), y.action.name) {
1721
- case "filter": {
1722
- O == null || O.preventDefault(), c.current = y.parameters;
1723
- break;
1724
- }
1725
- case "sort": {
1726
- O == null || O.preventDefault(), a.current = y.parameters;
1727
- break;
1728
- }
1729
- case "delete": {
1730
- O == null || O.preventDefault(), i({
1731
- title: "Are you sure?",
1732
- icon: ae.confirm,
1733
- onResult: (M) => {
1734
- M.isConfirmed && ce().fetch({
1735
- url: Y(y.action.route, { ...e.parameters, ...y.parameters }),
1736
- method: It.DELETE
1737
- }).catch((x) => {
1738
- console.log("error", x);
1739
- }).finally(() => {
1740
- l();
1741
- });
1742
- }
1743
- });
1744
- return;
2481
+ }), g = (h, x) => {
2482
+ if (!o?.(h, x)) {
2483
+ switch (x?.preventDefault(), h.parameters = { ...h.parameters || {}, ...s.parameters || {} }, h.parameters = Ve(h.parameters), Object.keys(h.parameters).length || (h.parameters = void 0), h.query !== void 0 && (Object.keys(h.query).length || (h.query = void 0)), h.action.name) {
2484
+ case "list":
2485
+ return l({ newAction: h });
2486
+ case "delete": {
2487
+ f({
2488
+ title: "Are you sure?",
2489
+ icon: Z.confirm,
2490
+ onResult: (P) => {
2491
+ P.isConfirmed && le().fetch({
2492
+ url: a(h),
2493
+ method: $e.DELETE
2494
+ }).catch((L) => {
2495
+ console.log("error", L);
2496
+ }).finally(() => {
2497
+ _?.();
2498
+ });
2499
+ }
2500
+ });
2501
+ return;
2502
+ }
1745
2503
  }
1746
- default: {
1747
- t && (O == null || O.preventDefault(), h({
1748
- action: y,
2504
+ if (e) {
2505
+ p({
2506
+ action: h,
1749
2507
  props: {
2508
+ size: "lg",
1750
2509
  onClose: () => {
1751
- l();
2510
+ _?.();
1752
2511
  }
1753
2512
  }
1754
- }));
2513
+ });
1755
2514
  return;
1756
2515
  }
2516
+ l({ newAction: h });
1757
2517
  }
1758
- d();
1759
2518
  };
1760
- return v(() => {
1761
- b(r);
1762
- }, [n]), /* @__PURE__ */ s(k, { children: /* @__PURE__ */ _("section", { className: "list", children: [
1763
- /* @__PURE__ */ _("header", { className: "content-header d-md-flex mb-3 justify-content-between align-items-center", children: [
1764
- /* @__PURE__ */ s("h2", { children: f == null ? void 0 : f.title }),
1765
- /* @__PURE__ */ _("div", { className: "d-flex align-items-center", children: [
1766
- !!E.length && /* @__PURE__ */ s("div", { className: "btn-group btn-group-sm me-2", children: E.map((y, O) => /* @__PURE__ */ s(
1767
- z,
2519
+ return /* @__PURE__ */ r(yr, { data: E, onClick: g, children: /* @__PURE__ */ C("section", { className: n || "list", children: [
2520
+ /* @__PURE__ */ r(T, { name: "header", children: /* @__PURE__ */ C("header", { className: "content-header d-flex flex-column flex-md-row gap-3 mb-3 justify-content-between align-items-md-center", children: [
2521
+ /* @__PURE__ */ r(T, { name: "title", children: t !== !1 && (v.isValidElement(t) ? t : /* @__PURE__ */ r("h2", { children: /* @__PURE__ */ r(D, { children: t ?? E?.title }) })) }),
2522
+ /* @__PURE__ */ C("div", { className: "d-flex align-items-center", children: [
2523
+ /* @__PURE__ */ r(T, { name: "actions", children: !!b.length && /* @__PURE__ */ r("div", { className: "btn-group btn-group-sm me-2", children: b.map((h, x) => /* @__PURE__ */ r(
2524
+ dn,
1768
2525
  {
1769
- to: Y(y.route, e.parameters),
1770
- onClick: (M) => C({
1771
- action: y,
1772
- parameters: e.parameters
1773
- }, M),
1774
- className: "btn btn-outline-secondary",
1775
- children: y.title || y.name
2526
+ action: { ...s, action: h },
2527
+ className: "btn btn-outline-secondary"
1776
2528
  },
1777
- O
1778
- )) }),
1779
- ((N = f == null ? void 0 : f.form) == null ? void 0 : N.filter) && /* @__PURE__ */ _("div", { className: "btn-group btn-group-sm", children: [
1780
- /* @__PURE__ */ _(At, { className: "btn-group btn-group-sm", children: [
1781
- /* @__PURE__ */ s(fe, { className: "btn-outline-dark", children: /* @__PURE__ */ s(Ce, { children: "Filter" }) }),
1782
- /* @__PURE__ */ s(oe, { children: /* @__PURE__ */ s("div", { className: "filter", children: /* @__PURE__ */ _(
1783
- ot,
2529
+ x
2530
+ )) }) }),
2531
+ E?.form?.filter?.view && /* @__PURE__ */ C("div", { className: "btn-group btn-group-sm", children: [
2532
+ /* @__PURE__ */ C(Je, { autoClose: "outside", children: [
2533
+ /* @__PURE__ */ r(Ee, { className: "btn btn-sm dropdown-toggle btn-outline-dark", children: /* @__PURE__ */ r(D, { children: "Filter" }) }),
2534
+ /* @__PURE__ */ r(ce, { children: /* @__PURE__ */ r("div", { className: "filter", children: /* @__PURE__ */ C(
2535
+ At,
1784
2536
  {
1785
- id: "filter_" + ve(m),
1786
- ref: u,
1787
- onSubmit: (y) => C({
1788
- action: {
1789
- name: "filter",
1790
- object: !1,
1791
- namespace: e.action.namespace,
1792
- entity: m
1793
- },
1794
- parameters: Ft(y)
2537
+ id: "filter_" + _e(y),
2538
+ ref: m,
2539
+ onSubmit: (h) => g({
2540
+ ...s,
2541
+ query: Ve(Be(h))
1795
2542
  }),
1796
- onReset: () => C({
1797
- action: {
1798
- name: "filter",
1799
- object: !1,
1800
- namespace: e.action.namespace,
1801
- entity: m
1802
- }
2543
+ onReset: () => g({
2544
+ ...s,
2545
+ query: void 0
1803
2546
  }),
1804
2547
  children: [
1805
- ((A = f == null ? void 0 : f.form) == null ? void 0 : A.filter) && /* @__PURE__ */ s(Fe, { view: f.form.filter.view }),
1806
- /* @__PURE__ */ s("button", { className: "btn btn-primary me-2", type: "submit", children: /* @__PURE__ */ s(Ce, { children: "Submit" }) })
2548
+ E?.form?.filter && /* @__PURE__ */ r(re, { view: E.form.filter.view, children: /* @__PURE__ */ r(pe, {}) }),
2549
+ /* @__PURE__ */ r("button", { className: "btn btn-primary me-2", type: "submit", children: /* @__PURE__ */ r(D, { children: "Submit" }) })
1807
2550
  ]
1808
2551
  }
1809
2552
  ) }) })
1810
2553
  ] }),
1811
- !!Object.values(((P = c.current) == null ? void 0 : P.filter) || []).length && /* @__PURE__ */ s(me, { onClick: () => {
1812
- var y;
1813
- (y = u.current) == null || y.reset();
2554
+ c.searchParams.has("filter") && /* @__PURE__ */ r(fe, { onClick: () => {
2555
+ m.current?.reset();
1814
2556
  }, className: "btn btn-outline-dark", children: "x" })
1815
2557
  ] })
1816
2558
  ] })
1817
- ] }),
1818
- ((D = f == null ? void 0 : f.form) == null ? void 0 : D.filter) && /* @__PURE__ */ s(ur, { formView: f.form.filter.view, onClick: (y) => d([y]) }),
1819
- /* @__PURE__ */ _(G, { namespace: e.action.namespace, prefix: "modify", view: "content", data: f, children: [
1820
- /* @__PURE__ */ s("div", { className: "table-responsive", children: /* @__PURE__ */ s(
1821
- rr,
1822
- {
1823
- data: f,
1824
- onClick: C,
1825
- onBatchClick: p,
1826
- namespace: e.action.namespace,
1827
- routeParams: e.parameters
1828
- }
1829
- ) }),
1830
- f && /* @__PURE__ */ s(sr, { meta: f.entity.data.meta })
1831
- ] }, "modify")
1832
- ] }) });
1833
- }), ur = ({ formView: e, onClick: t }) => {
1834
- const n = (r) => r.choices !== void 0 ? r.choices ? Object.values(r.data instanceof Object ? r.data : [r.data]).map((o) => {
1835
- var a, c;
1836
- return ((c = (a = r.choices) == null ? void 0 : a[o]) == null ? void 0 : c.label) ?? o;
1837
- }).join(", ") : r.data : r.checked !== void 0 ? r.checked ? "Yes" : "No" : r.data;
1838
- return /* @__PURE__ */ s("div", { className: "filters d-flex mb-sm overflow-auto", children: Object.values(e.children || []).filter((r) => r.data !== null).map((r, o) => /* @__PURE__ */ _("div", { className: "filters-item d-flex text-nowrap flex-column me-2 mb-2", children: [
1839
- /* @__PURE__ */ s("small", { className: "mb-2", children: r.label }),
1840
- /* @__PURE__ */ _("div", { className: "btn btn-sm btn-primary me-1 mb-1", children: [
1841
- n(r),
1842
- t && /* @__PURE__ */ s("span", { onClick: () => t(r.name), className: "ms-2", children: "×" })
2559
+ ] }) }),
2560
+ /* @__PURE__ */ C(vr, { onClick: d, children: [
2561
+ E?.form?.filter?.view && /* @__PURE__ */ r(bo, { formView: E.form.filter.view, onClick: (h) => l({ excludeFilterParameters: [h] }) }),
2562
+ /* @__PURE__ */ r(yo, {}),
2563
+ /* @__PURE__ */ C(T, { name: "content", children: [
2564
+ /* @__PURE__ */ r(U, { prefix: "list", view: "content", data: E, children: /* @__PURE__ */ r(
2565
+ _r,
2566
+ {
2567
+ routeParams: s.parameters
2568
+ }
2569
+ ) }, "list"),
2570
+ /* @__PURE__ */ r(xr, {})
2571
+ ] })
1843
2572
  ] })
1844
- ] }, o)) });
1845
- }, dr = ({ view: e, props: t }) => {
2573
+ ] }) });
2574
+ }, { name: "list" })), Eo = ({ view: e }) => /* @__PURE__ */ C(A, { children: [
2575
+ 'View "',
2576
+ e,
2577
+ '" Not found.'
2578
+ ] }), Co = ({ view: e, props: t }) => {
1846
2579
  const n = {
1847
- add: We,
1848
- edit: We,
1849
- list: lr
2580
+ add: st,
2581
+ edit: st,
2582
+ list: vo
2583
+ }, o = Dt();
2584
+ return /* @__PURE__ */ r(U, { view: e, props: t, children: n[e] !== void 0 ? v.createElement(n[e], t) : /* @__PURE__ */ r(Eo, { view: e }) }, o + e);
2585
+ }, xn = ({ view: e, namespace: t, props: n }) => /* @__PURE__ */ r(A, { children: /* @__PURE__ */ r(Co, { view: e, props: n }) }), Nn = v.createContext({});
2586
+ function Qe() {
2587
+ const { modal: e, setModal: t } = v.useContext(Nn);
2588
+ return {
2589
+ modal: e,
2590
+ openModal: (n) => {
2591
+ t && t(n);
2592
+ },
2593
+ closeModal: () => {
2594
+ t?.(null);
2595
+ }
1850
2596
  };
1851
- if (n[e] === void 0)
1852
- throw new Q(500, "View not found");
1853
- return S.createElement(n[e] || un, t);
1854
- }, Tt = ({ view: e, namespace: t, props: n }) => /* @__PURE__ */ s(G, { namespace: t, view: e, props: n, children: /* @__PURE__ */ s(dr, { view: e, props: n }) }, t + e), fr = ({ path: e }) => {
1855
- const t = Qt();
1856
- e ?? (e = document.location.pathname.replace(new RegExp("^" + (t == null ? void 0 : t.pathnameBase) + "(/)?"), "/"));
1857
- const { getOnClickActionByPath: n } = Re(), r = kt(n(e));
1858
- if (!r)
1859
- throw new Q(404, "Missing Route");
1860
- return /* @__PURE__ */ s(
1861
- Tt,
2597
+ }
2598
+ function _o(e) {
2599
+ const [t, n] = W((m, p) => {
2600
+ const f = [...m];
2601
+ return p ? f.push(p) : f.pop(), f;
2602
+ }, []), o = t[t.length - 1] ?? null, { open: s } = Ge(), i = S(0);
2603
+ N(() => {
2604
+ i.current += 1;
2605
+ }, [o]);
2606
+ const a = {
2607
+ ...o?.props || {}
2608
+ }, c = (m) => m ? [
2609
+ m.action.action.entity,
2610
+ m.action.action.namespace,
2611
+ m.action.action.name
2612
+ ].filter((p) => p).join("-") : Date.now().toString(), u = c(o);
2613
+ return /* @__PURE__ */ C(Nn.Provider, { value: {
2614
+ modal: o,
2615
+ setModal: (m) => {
2616
+ u !== c(m) && n(m);
2617
+ }
2618
+ }, children: [
2619
+ e.children,
2620
+ o && /* @__PURE__ */ r(vt, { preventDefault: !0, fallback: (m) => {
2621
+ n(null), s({
2622
+ title: m?.detail ?? "Unknown Error",
2623
+ icon: Z.denied,
2624
+ actions: {
2625
+ close: {
2626
+ label: "OK"
2627
+ }
2628
+ }
2629
+ });
2630
+ }, children: /* @__PURE__ */ r(It, { action: o.action, children: /* @__PURE__ */ r(
2631
+ xn,
2632
+ {
2633
+ view: o.action.action.name || "list",
2634
+ props: {
2635
+ modal: !0,
2636
+ props: a
2637
+ }
2638
+ }
2639
+ ) }, u) })
2640
+ ] });
2641
+ }
2642
+ const xo = ({ children: e, config: t }) => /* @__PURE__ */ r(Vn, { config: t, children: /* @__PURE__ */ r(ir, { children: /* @__PURE__ */ r(qn, { children: /* @__PURE__ */ r(en, { children: /* @__PURE__ */ r(_o, { children: e }) }) }) }) });
2643
+ let ye = null;
2644
+ const wn = {}, Ze = "dakataa_crud", $o = ({ connection: e, templates: t }) => {
2645
+ K.namespace[Ze] = e, wn.templates = t, ye = null;
2646
+ }, le = () => (ye || (ye = K.instance({ namespace: Ze })), ye), qo = ({ children: e, config: t, errorFallback: n }) => {
2647
+ const o = Object.assign(wn.templates ?? {}, t?.templates ?? {});
2648
+ return /* @__PURE__ */ r(Nt, { children: /* @__PURE__ */ r(Kn, { children: /* @__PURE__ */ r(vt, { fallback: n ?? /* @__PURE__ */ r(Un, {}), children: /* @__PURE__ */ r(xo, { config: { ...t || { env: Ct.DEV }, templates: o }, children: e }) }) }) });
2649
+ }, No = ({ namespace: e }) => {
2650
+ const { columns: t } = $();
2651
+ return /* @__PURE__ */ r("div", { className: "card mb-3", children: /* @__PURE__ */ r("div", { className: "card-body", children: /* @__PURE__ */ C("div", { className: "d-flex flex-row gap-3 align-items-start", children: [
2652
+ /* @__PURE__ */ r(cn, {}),
2653
+ /* @__PURE__ */ r("div", { className: "d-flex flex-column flex-wrap gap-2", children: t.map((n, o) => /* @__PURE__ */ C("div", { className: "d-flex align-items-start", children: [
2654
+ /* @__PURE__ */ C("span", { className: "text-secondary me-1", children: [
2655
+ /* @__PURE__ */ r(ln, { column: n, namespace: e }),
2656
+ ":"
2657
+ ] }),
2658
+ /* @__PURE__ */ r(on, { column: n, namespace: e })
2659
+ ] }, o)) }),
2660
+ /* @__PURE__ */ r("div", { className: "ms-auto", children: /* @__PURE__ */ r(un, { namespace: e }) })
2661
+ ] }) }) });
2662
+ }, Ho = ({ itemView: e, emptyView: t, namespace: n }) => {
2663
+ const { items: o, primaryColumn: s, data: i } = $();
2664
+ return !!i && (o.length ? o.map((a, c) => /* @__PURE__ */ r(rn, { index: c, children: /* @__PURE__ */ r(
2665
+ U,
1862
2666
  {
1863
- view: r.action.name,
1864
- namespace: r.action.namespace || "",
1865
- props: { action: r }
2667
+ namespace: n,
2668
+ prefix: "list",
2669
+ view: "listItem",
2670
+ children: e || /* @__PURE__ */ r(No, { namespace: n })
2671
+ },
2672
+ i?.entity?.data.items[c][s?.field ?? ""]
2673
+ ) }, c)) : t === void 0 ? /* @__PURE__ */ r(D, { children: "No results found." }) : t);
2674
+ }, Ko = ({ name: e }) => {
2675
+ const { form: t } = B(), n = e ? t.children?.[e] : t;
2676
+ if (!n)
2677
+ throw new Error("Missing Form View for FormLabel" + (e ? ": " + e : ""));
2678
+ return /* @__PURE__ */ r(De, { view: n });
2679
+ }, wo = ({ children: e }) => /* @__PURE__ */ r(A, { children: e }), ft = X(({ name: e, children: t, parent: n, render: o }) => (t = v.Children.toArray((o ? o(n) : t) || []).map((s) => (v.isValidElement(s) && s.type === wo && (s = v.cloneElement(s, { children: n })), s)), /* @__PURE__ */ r(A, { children: t }))), Go = X(({ name: e, content: t, children: n, data: o }) => {
2680
+ const s = v.Children.toArray(t).find((c) => v.isValidElement(c) && c.type === ft && c.props.name === e);
2681
+ let i = null;
2682
+ s && v.isValidElement(s) && (i = v.cloneElement(s, { parent: n, data: o }));
2683
+ const a = v.Children.toArray(n).filter((c) => v.isValidElement(c) && c.type !== ft);
2684
+ return /* @__PURE__ */ r(A, { children: i || (a.length ? a : n) });
2685
+ }), An = v.createContext(null), Pn = ({ item: e }) => /* @__PURE__ */ r(An.Provider, { value: e, children: e.parent?.parent ? /* @__PURE__ */ r(Pn, { item: e.parent }) : e.parent?.element ? e.parent.element : e.element }), Yo = () => v.useContext(An)?.element || "Empty", Wo = ({ children: e }) => {
2686
+ const t = (c, u) => Dn.toArray(c).reduce((m, p) => {
2687
+ const f = p.props, y = (b) => b?.replace(/\/$/, ""), E = [u?.path, f?.path].filter((b) => b).map((b) => y(b)).join("/"), _ = t(f.children, { path: E, element: f.element });
2688
+ return [
2689
+ ...m,
2690
+ ..._.length ? _ : [{
2691
+ path: "/" + E,
2692
+ element: f?.element,
2693
+ parent: u
2694
+ }]
2695
+ ];
2696
+ }, []), n = S(null);
2697
+ n.current === null && (n.current = t(e));
2698
+ const { matchPath: o } = j(), s = n.current.filter((c) => c.path && o(c.path, document.location.href)).shift(), [, i] = R(document.location.href), a = () => {
2699
+ i(document.location.href);
2700
+ };
2701
+ if (N(() => (a(), window.addEventListener("locationchange", a), () => {
2702
+ window.removeEventListener("locationchange", a);
2703
+ }), []), !!s)
2704
+ return /* @__PURE__ */ r(A, { children: /* @__PURE__ */ r(Pn, { item: s }) });
2705
+ }, zo = (e) => null, Ln = v.createContext(null), Ao = () => v.useContext(Ln), Po = ({ item: e, open: t = !1 }) => {
2706
+ const n = !!e.items?.length, { location: o, generateRoute: s } = j(), i = o.pathname.replace(/(.*?)\/?$/i, "$1"), a = s(e.route), c = i.includes(a, 0), [u, m] = v.useState(c), p = Ao(), f = S(null), y = S(null), E = "collapse", _ = "collapsing", b = {
2707
+ toggle: (g) => {
2708
+ m(g !== void 0 ? g : !u);
1866
2709
  }
1867
- );
1868
- };
1869
- let Ee;
1870
- const $e = "dakataa_crud", Nr = (e) => {
1871
- xe.namespace[$e] = {
1872
- baseURL: e,
1873
- headers: {
1874
- Accept: "application/json"
2710
+ }, l = () => {
2711
+ f.current?.classList.remove(_), f.current?.classList.add(E), f.current?.classList.toggle("show", u), f.current?.style.removeProperty("height");
2712
+ }, d = () => {
2713
+ y.current && (clearTimeout(y.current), y.current = null);
2714
+ };
2715
+ return N(() => (u && p && p.toggle(!0), f.current?.addEventListener("animationstart", d), f.current?.addEventListener("transitionstart", d), f.current?.addEventListener("animationend", l), f.current?.addEventListener("transitionend", l), f.current?.style.setProperty("height", (u ? 0 : f.current?.scrollHeight) + "px"), f.current?.classList.remove("show"), f.current?.classList.remove(E), f.current?.classList.add(_), setTimeout(() => {
2716
+ f.current?.style.setProperty("height", (u ? f.current?.scrollHeight : 0) + "px");
2717
+ }, 10), y.current = setTimeout(l, 50), () => {
2718
+ d(), f.current?.removeEventListener("animationstart", d), f.current?.removeEventListener("transitionstart", d), f.current?.removeEventListener("animationend", l), f.current?.removeEventListener("transitionend", l);
2719
+ }), [u]), N(() => {
2720
+ t !== u && m(t);
2721
+ }, [t]), /* @__PURE__ */ r(Ln.Provider, { value: b, children: /* @__PURE__ */ C("nav", { className: ["item", ...u || c ? ["active"] : []].join(" "), children: [
2722
+ /* @__PURE__ */ C(
2723
+ M,
2724
+ {
2725
+ to: n ? "#" : s(e.route),
2726
+ ...e.icon && { icon: e.icon },
2727
+ ...n && {
2728
+ onClick: () => {
2729
+ m(!u);
2730
+ }
2731
+ },
2732
+ children: [
2733
+ /* @__PURE__ */ r("span", { className: "icon" }),
2734
+ /* @__PURE__ */ r("span", { className: "title", children: e.title })
2735
+ ]
2736
+ }
2737
+ ),
2738
+ n && !!e.items?.length && /* @__PURE__ */ r("nav", { ref: f, className: E, children: /* @__PURE__ */ r(On, { items: e.items }) })
2739
+ ] }) });
2740
+ }, On = ({ items: e }) => e.map(
2741
+ (t) => {
2742
+ const n = [parent, t.title].filter((o) => o).join("-").toLowerCase();
2743
+ return /* @__PURE__ */ r(Po, { item: t }, n);
2744
+ }
2745
+ ), Lo = de(({ items: e, className: t, open: n = !1 }, o) => {
2746
+ const s = S(null), [i, a] = v.useState(n);
2747
+ o = o || Rn();
2748
+ const c = {
2749
+ toggle: (u) => {
2750
+ a(u !== void 0 ? u : !i);
1875
2751
  }
1876
2752
  };
1877
- }, ce = () => (Ee || (Ee = new xe({}, $e)), Ee), Cr = () => {
1878
- if (!xe.namespace[$e])
1879
- throw new ke(500, "Invalid Configuration.");
1880
- return /* @__PURE__ */ s(St, { children: /* @__PURE__ */ s(Wt, { fallback: /* @__PURE__ */ s(zt, {}), children: /* @__PURE__ */ s(Rt, { fallback: /* @__PURE__ */ s(k, { children: "Loading" }), children: /* @__PURE__ */ s(fr, {}) }) }) });
2753
+ return ue(o, () => c), N(() => {
2754
+ document.body.classList.toggle("toggle-nav", i);
2755
+ const u = (m) => {
2756
+ s.current?.contains(m.target) || (a(!1), document.body.removeEventListener("click", u));
2757
+ };
2758
+ if (i)
2759
+ return document.body.addEventListener("click", u), () => {
2760
+ document.body.removeEventListener("click", u);
2761
+ };
2762
+ }, [i]), /* @__PURE__ */ r("nav", { ref: s, children: /* @__PURE__ */ r(On, { items: e }) });
2763
+ }), Jo = ({ children: e, ...t }) => {
2764
+ const n = S(null), [o, s] = R([]);
2765
+ return N(() => {
2766
+ le().get({
2767
+ url: "/_crud/navigation"
2768
+ }).then(({ status: i, data: a }) => {
2769
+ i === 200 && s(a);
2770
+ });
2771
+ }, []), /* @__PURE__ */ C(Et, { children: [
2772
+ /* @__PURE__ */ r("header", { children: /* @__PURE__ */ C("div", { className: "wrap", children: [
2773
+ /* @__PURE__ */ r("button", { onClick: (i) => n.current?.toggle(), className: "btn btn-mobile", children: /* @__PURE__ */ r("i", {}) }),
2774
+ /* @__PURE__ */ r("nav", { className: "first-nav", children: /* @__PURE__ */ r(M, { className: "logo", to: "/", children: "Admin" }) }),
2775
+ /* @__PURE__ */ r("nav", { className: "second-nav", children: /* @__PURE__ */ C(Je, { className: "user", children: [
2776
+ /* @__PURE__ */ r("span", { className: "initials", children: "YL" }),
2777
+ /* @__PURE__ */ r(M, { to: "#", children: "Yordan Lazarov" }),
2778
+ /* @__PURE__ */ r(M, { to: "#", children: "Logout" })
2779
+ ] }) })
2780
+ ] }) }),
2781
+ /* @__PURE__ */ C("main", { children: [
2782
+ !!o.length && /* @__PURE__ */ r("div", { className: "navigation d-print-none", children: /* @__PURE__ */ r(Lo, { ref: n, items: o }) }),
2783
+ /* @__PURE__ */ r("div", { className: "content", children: e })
2784
+ ] })
2785
+ ] });
2786
+ }, Qo = ({ currency: e, locale: t, children: n, precision: o = 2 }) => {
2787
+ const s = Intl.NumberFormat().resolvedOptions().locale, { currency: i, locale: a } = ee();
2788
+ e ??= i ?? "EUR", t ??= a ?? s;
2789
+ const c = Number(n);
2790
+ return /* @__PURE__ */ r(A, { children: !isNaN(c) && c.toLocaleString(t, { style: "currency", currency: e, minimumFractionDigits: o }) });
1881
2791
  };
1882
2792
  export {
1883
- cn as AlertProvider,
1884
- Cr as Crud,
1885
- Nr as CrudConfiguration,
1886
- St as CrudContext,
1887
- fr as CrudLoader,
1888
- G as DynamicView,
1889
- Fe as FormView,
1890
- nn as FormWidget,
1891
- rr as GridTableView,
1892
- lr as List,
1893
- ir as ModalProvider,
1894
- We as Modify,
1895
- V as TemplateBlock,
1896
- B as TemplateExtend,
1897
- dt as UseAlert,
1898
- cr as UseModal,
1899
- Tt as ViewLoader
2793
+ dn as Action,
2794
+ Nt as ActionProvider,
2795
+ Z as AlertIcon,
2796
+ en as AlertProvider,
2797
+ xe as AsTemplate,
2798
+ Wt as BaseFormFieldError,
2799
+ zt as BaseFormGroup,
2800
+ er as BaseFormHelp,
2801
+ De as BaseFormLabel,
2802
+ Et as BaseLayout,
2803
+ T as Block,
2804
+ fe as Button,
2805
+ rr as Choice,
2806
+ nr as ChoiceGroupOption,
2807
+ Re as ChoiceOption,
2808
+ ar as Collection,
2809
+ lr as CollectionItem,
2810
+ cr as CollectionList,
2811
+ Vn as ConfigProvider,
2812
+ qo as Crud,
2813
+ $o as CrudConfiguration,
2814
+ hr as CrudForm,
2815
+ Io as CrudLoader,
2816
+ xo as CrudProvider,
2817
+ le as CrudRequester,
2818
+ It as CurrentActionProvider,
2819
+ Ft as DataProvider,
2820
+ Je as Dropdown,
2821
+ Ee as DropdownButton,
2822
+ ce as DropdownContent,
2823
+ U as DynamicView,
2824
+ Ct as Environment,
2825
+ vt as ErrorBoundary,
2826
+ gt as Exception,
2827
+ H as Extend,
2828
+ At as Form,
2829
+ dr as FormError,
2830
+ ot as FormField,
2831
+ pe as FormFieldViewLoader,
2832
+ Fo as FormGroup,
2833
+ Ko as FormLabel,
2834
+ ur as FormRest,
2835
+ mr as FormRestError,
2836
+ Mo as FormSetting,
2837
+ re as FormViewProvider,
2838
+ w as FormViewTypeEnum,
2839
+ Yn as GetData,
2840
+ Wn as GetDataByAction,
2841
+ _r as GridView,
2842
+ qe as HttpException,
2843
+ or as Input,
2844
+ Er as IsListItemActionGranted,
2845
+ Cr as ItemAction,
2846
+ M as Link,
2847
+ vo as List,
2848
+ No as ListItem,
2849
+ yr as ListProvider,
2850
+ Ho as ListView,
2851
+ Jo as MainLayout,
2852
+ Zt as Modal,
2853
+ _o as ModalProvider,
2854
+ st as Modify,
2855
+ Qo as Money,
2856
+ Yo as Outlet,
2857
+ xr as Paginator,
2858
+ Vo as Parent,
2859
+ zo as Route,
2860
+ Wo as Router,
2861
+ tr as SelectGroupOption,
2862
+ qt as SelectOption,
2863
+ fr as Template,
2864
+ Go as TemplateBlock,
2865
+ ft as TemplateExtend,
2866
+ wo as TemplateParentBlock,
2867
+ D as Translation,
2868
+ j as UseActions,
2869
+ Ge as UseAlert,
2870
+ Gt as UseCollection,
2871
+ Uo as UseCollectionItem,
2872
+ ee as UseConfig,
2873
+ te as UseCurrentAction,
2874
+ Gn as UseCurrentActionCollection,
2875
+ ne as UseDataProvider,
2876
+ Qn as UseDynamicView,
2877
+ me as UseForm,
2878
+ $t as UseFormSettings,
2879
+ B as UseFormView,
2880
+ $ as UseList,
2881
+ he as UseListItem,
2882
+ Qe as UseModal,
2883
+ xn as ViewLoader,
2884
+ To as WithActionProviderContext,
2885
+ Bo as WithAlertProvider,
2886
+ Mt as WithDataProvider,
2887
+ ke as capitalize,
2888
+ jo as maskEmail,
2889
+ _e as nameToId,
2890
+ zn as titlize
1900
2891
  };