@dakataa/crud-react 1.0.4 → 1.0.7

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