@luminix/core 0.0.1-beta.0 → 0.0.1-beta.2

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.
Files changed (50) hide show
  1. package/dist/contracts/Builder.d.ts +3 -2
  2. package/dist/contracts/Collection.d.ts +3 -3
  3. package/dist/contracts/ModelCollection.d.ts +1 -0
  4. package/dist/contracts/Plugin.d.ts +1 -0
  5. package/dist/contracts/PropertyBag.d.ts +4 -11
  6. package/dist/contracts/Relation/BelongsTo.d.ts +2 -1
  7. package/dist/contracts/Relation/BelongsToMany.d.ts +3 -2
  8. package/dist/contracts/Relation/HasMany.d.ts +3 -2
  9. package/dist/contracts/Relation/HasOne.d.ts +2 -1
  10. package/dist/contracts/Relation/HasOneOrMany.d.ts +2 -1
  11. package/dist/contracts/Relation/MorphMany.d.ts +3 -2
  12. package/dist/contracts/Relation/MorphOne.d.ts +2 -1
  13. package/dist/contracts/Relation/MorphOneOrMany.d.ts +2 -1
  14. package/dist/contracts/Relation/MorphTo.d.ts +2 -1
  15. package/dist/contracts/Relation/MorphToMany.d.ts +2 -1
  16. package/dist/contracts/Relation.d.ts +1 -0
  17. package/dist/core.js +1317 -1322
  18. package/dist/facades/App.d.ts +4 -3
  19. package/dist/facades/Auth.d.ts +1 -0
  20. package/dist/facades/Error.d.ts +2 -1
  21. package/dist/facades/Log.d.ts +1 -0
  22. package/dist/facades/Model.d.ts +3 -2
  23. package/dist/facades/Route.d.ts +6 -5
  24. package/dist/helpers/app.d.ts +1 -0
  25. package/dist/helpers/auth.d.ts +3 -1
  26. package/dist/helpers/collect.d.ts +1 -1
  27. package/dist/helpers/config.d.ts +1 -0
  28. package/dist/helpers/error.d.ts +1 -0
  29. package/dist/helpers/log.d.ts +1 -0
  30. package/dist/helpers/model.d.ts +1 -0
  31. package/dist/helpers/route.d.ts +1 -0
  32. package/dist/index.d.ts +11 -10
  33. package/dist/mixins/BaseModel.d.ts +1 -0
  34. package/dist/mixins/HasEvents.d.ts +2 -1
  35. package/dist/mixins/Reducible.d.ts +1 -0
  36. package/dist/support/collection.d.ts +1 -0
  37. package/dist/support/model.d.ts +1 -0
  38. package/dist/types/App.d.ts +1 -0
  39. package/dist/types/Auth.d.ts +1 -0
  40. package/dist/types/Builder.d.ts +3 -1
  41. package/dist/types/Collection.d.ts +1 -0
  42. package/dist/types/Config.d.ts +2 -1
  43. package/dist/types/Error.d.ts +3 -1
  44. package/dist/types/Event.d.ts +1 -0
  45. package/dist/types/Model.d.ts +2 -1
  46. package/dist/types/PropertyBag.d.ts +25 -0
  47. package/dist/types/Reducer.d.ts +1 -0
  48. package/dist/types/Relation.d.ts +1 -0
  49. package/dist/types/Route.d.ts +1 -0
  50. package/package.json +2 -2
package/dist/core.js CHANGED
@@ -1,179 +1,174 @@
1
- var ft = Object.defineProperty;
2
- var dt = (n, t, e) => t in n ? ft(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
- var p = (n, t, e) => (dt(n, typeof t != "symbol" ? t + "" : t, e), e), P = (n, t, e) => {
4
- if (!t.has(n))
5
- throw TypeError("Cannot " + e);
1
+ var me = Object.defineProperty;
2
+ var G = (n) => {
3
+ throw TypeError(n);
6
4
  };
7
- var o = (n, t, e) => (P(n, t, "read from private field"), e ? e.call(n) : t.get(n)), q = (n, t, e) => {
8
- if (t.has(n))
9
- throw TypeError("Cannot add the same private member more than once");
10
- t instanceof WeakSet ? t.add(n) : t.set(n, e);
11
- }, Q = (n, t, e, s) => (P(n, t, "write to private field"), s ? s.call(n, e) : t.set(n, e), e);
12
- var G = (n, t, e) => (P(n, t, "access private method"), e);
5
+ var ge = (n, e, t) => e in n ? me(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
6
+ var p = (n, e, t) => ge(n, typeof e != "symbol" ? e + "" : e, t), F = (n, e, t) => e.has(n) || G("Cannot " + t);
7
+ var o = (n, e, t) => (F(n, e, "read from private field"), t ? t.call(n) : e.get(n)), q = (n, e, t) => e.has(n) ? G("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), P = (n, e, t, r) => (F(n, e, "write to private field"), r ? r.call(n, t) : e.set(n, t), t), V = (n, e, t) => (F(n, e, "access private method"), t);
13
8
  import f from "lodash";
14
- import { produce as B, isDraftable as pt } from "immer";
15
- import K, { isAxiosError as mt } from "axios";
16
- class Y extends Error {
17
- constructor(t) {
18
- super(`[Luminix] Facade "${t}" not found`);
9
+ import { produce as B, isDraftable as ye } from "immer";
10
+ import K, { isAxiosError as we } from "axios";
11
+ class O extends Error {
12
+ constructor(e) {
13
+ super(`[Luminix] Facade "${e}" not found`);
19
14
  }
20
15
  }
21
- p(Y, "name", "FacadeNotFoundException");
22
- class gt {
23
- constructor(t) {
16
+ p(O, "name", "FacadeNotFoundException");
17
+ class be {
18
+ constructor(e) {
24
19
  p(this, "_user");
25
- this.app = t;
20
+ this.app = e;
26
21
  }
27
- attempt(t, e = !1, s) {
28
- const r = document.createElement("form");
29
- r.method = "post", r.action = this.app.make("route").url("login"), r.style.display = "none";
22
+ attempt(e, t = !1, r) {
23
+ const s = document.createElement("form");
24
+ s.method = "post", s.action = this.app.make("route").url("login"), s.style.display = "none";
30
25
  const i = this.app.make("config").get("auth.csrf");
31
26
  if (typeof i == "string") {
32
- const a = document.createElement("input");
33
- a.type = "hidden", a.name = "_token", a.value = i, r.appendChild(a);
27
+ const c = document.createElement("input");
28
+ c.type = "hidden", c.name = "_token", c.value = i, s.appendChild(c);
34
29
  }
35
- const h = document.createElement("input");
36
- h.type = "email", h.name = "email", h.value = t.email, r.appendChild(h);
37
- const l = document.createElement("input");
38
- if (l.type = "password", l.name = "password", l.value = t.password, r.appendChild(l), e) {
39
- const a = document.createElement("input");
40
- a.type = "checkbox", a.name = "remember", a.value = "1", a.checked = !0, r.appendChild(a);
30
+ const u = document.createElement("input");
31
+ u.type = "email", u.name = "email", u.value = e.email, s.appendChild(u);
32
+ const a = document.createElement("input");
33
+ if (a.type = "password", a.name = "password", a.value = e.password, s.appendChild(a), t) {
34
+ const c = document.createElement("input");
35
+ c.type = "checkbox", c.name = "remember", c.value = "1", c.checked = !0, s.appendChild(c);
41
36
  }
42
- s && r.addEventListener("submit", s), document.body.appendChild(r), r.submit();
37
+ r && s.addEventListener("submit", r), document.body.appendChild(s), s.submit();
43
38
  }
44
39
  check() {
45
40
  return !!this.app.make("config").get("auth.user");
46
41
  }
47
- logout(t) {
48
- const e = document.createElement("form");
49
- e.method = "post", e.action = this.app.make("route").url("logout"), e.style.display = "none";
50
- const s = this.app.make("config").get("auth.csrf");
51
- if (typeof s == "string") {
52
- const r = document.createElement("input");
53
- r.type = "hidden", r.name = "_token", r.value = s, e.appendChild(r);
42
+ logout(e) {
43
+ const t = document.createElement("form");
44
+ t.method = "post", t.action = this.app.make("route").url("logout"), t.style.display = "none";
45
+ const r = this.app.make("config").get("auth.csrf");
46
+ if (typeof r == "string") {
47
+ const s = document.createElement("input");
48
+ s.type = "hidden", s.name = "_token", s.value = r, t.appendChild(s);
54
49
  }
55
- document.body.appendChild(e), t && e.addEventListener("submit", t), e.submit();
50
+ document.body.appendChild(t), e && t.addEventListener("submit", e), t.submit();
56
51
  }
57
52
  user() {
58
53
  if (!this._user) {
59
- const { model: t, config: e } = this.app.make(), s = t.make("user"), r = e.get("auth.user");
60
- if (!r)
54
+ const { model: e, config: t } = this.app.make(), r = e.make("user"), s = t.get("auth.user");
55
+ if (!s)
61
56
  return null;
62
- this._user = new s(r);
57
+ this._user = new r(s);
63
58
  }
64
59
  return this._user;
65
60
  }
66
61
  id() {
67
- var t;
68
- return ((t = this.user()) == null ? void 0 : t.getKey()) || null;
62
+ var e;
63
+ return ((e = this.user()) == null ? void 0 : e.getKey()) || null;
69
64
  }
70
65
  }
71
- class yt {
72
- constructor(t) {
73
- this._debug = t;
66
+ class Ee {
67
+ constructor(e) {
68
+ this._debug = e;
74
69
  }
75
- emergency(...t) {
76
- this._debug && console.error(...t);
70
+ emergency(...e) {
71
+ this._debug && console.error(...e);
77
72
  }
78
- alert(...t) {
79
- this._debug && console.error(...t);
73
+ alert(...e) {
74
+ this._debug && console.error(...e);
80
75
  }
81
- critical(...t) {
82
- this._debug && console.error(...t);
76
+ critical(...e) {
77
+ this._debug && console.error(...e);
83
78
  }
84
- error(...t) {
85
- this._debug && console.error(...t);
79
+ error(...e) {
80
+ this._debug && console.error(...e);
86
81
  }
87
- warning(...t) {
88
- this._debug && console.warn(...t);
82
+ warning(...e) {
83
+ this._debug && console.warn(...e);
89
84
  }
90
- notice(...t) {
91
- this._debug && console.info(...t);
85
+ notice(...e) {
86
+ this._debug && console.info(...e);
92
87
  }
93
- info(...t) {
94
- this._debug && console.info(...t);
88
+ info(...e) {
89
+ this._debug && console.info(...e);
95
90
  }
96
- debug(...t) {
97
- this._debug && console.debug(...t);
91
+ debug(...e) {
92
+ this._debug && console.debug(...e);
98
93
  }
99
94
  }
100
95
  class v {
101
- constructor(t) {
96
+ constructor(e) {
102
97
  p(this, "locked", []);
103
- this.bag = t, Object.freeze(this.bag);
98
+ this.bag = e, Object.freeze(this.bag);
104
99
  }
105
- get(t, e) {
106
- return f.get(this.bag, t, e);
100
+ get(e, t) {
101
+ return f.get(this.bag, e, t);
107
102
  }
108
- set(t, e) {
109
- if (this.locked.some((s) => t.startsWith(s)))
110
- throw new Error(`Cannot set a locked path "${t}"`);
111
- if (typeof e == "object" && e !== null && this.locked.some((s) => f.has(e, s.slice(t.length + 1))))
112
- throw new Error(`Cannot set a path "${t}" that would override a locked path`);
113
- if (t === ".") {
103
+ set(e, t) {
104
+ if (this.locked.some((r) => e.startsWith(r)))
105
+ throw new Error(`Cannot set a locked path "${e}"`);
106
+ if (typeof t == "object" && t !== null && this.locked.some((r) => f.has(t, r.slice(e.length + 1))))
107
+ throw new Error(`Cannot set a path "${e}" that would override a locked path`);
108
+ if (e === ".") {
114
109
  if (this.locked.length)
115
110
  throw new Error("Cannot set the root path when there are locked paths");
116
- if (typeof e != "object" || e === null)
111
+ if (typeof t != "object" || t === null)
117
112
  throw new TypeError("Value must be an object");
118
- this.bag = B(this.bag, () => e), this.emit("change", {
119
- path: t,
120
- value: e,
113
+ this.bag = B(this.bag, () => t), this.emit("change", {
114
+ path: e,
115
+ value: t,
121
116
  type: "set"
122
117
  });
123
118
  return;
124
119
  }
125
- this.bag = B(this.bag, (s) => {
126
- f.set(s, t, e);
120
+ this.bag = B(this.bag, (r) => {
121
+ f.set(r, e, t);
127
122
  }), this.emit("change", {
128
- path: t,
129
- value: e,
123
+ path: e,
124
+ value: t,
130
125
  type: "set"
131
126
  });
132
127
  }
133
- merge(t, e) {
134
- if (typeof e != "object" || e === null)
128
+ merge(e, t) {
129
+ if (typeof t != "object" || t === null)
135
130
  throw new TypeError("Value must be an object");
136
- if (t === ".") {
137
- if (this.locked.some((r) => f.has(e, r)))
138
- throw new Error(`Cannot merge a path "${t}" that would override a locked path`);
139
- this.bag = B(this.bag, (r) => ({
140
- ...r,
141
- ...e
131
+ if (e === ".") {
132
+ if (this.locked.some((s) => f.has(t, s)))
133
+ throw new Error(`Cannot merge a path "${e}" that would override a locked path`);
134
+ this.bag = B(this.bag, (s) => ({
135
+ ...s,
136
+ ...t
142
137
  })), this.emit("change", {
143
- path: t,
144
- value: e,
138
+ path: e,
139
+ value: t,
145
140
  type: "merge"
146
141
  });
147
142
  return;
148
143
  }
149
- const s = this.get(t);
150
- if (typeof s == "object" && s !== null)
151
- return this.set(t, {
152
- ...s,
153
- ...e
144
+ const r = this.get(e);
145
+ if (typeof r == "object" && r !== null)
146
+ return this.set(e, {
147
+ ...r,
148
+ ...t
154
149
  });
155
- if (s === null || typeof s > "u")
156
- return this.set(t, e);
157
- throw new Error(`Cannot merge a non-object path "${t}"`);
158
- }
159
- has(t) {
160
- return f.has(this.bag, t);
161
- }
162
- delete(t) {
163
- if (this.locked.some((e) => t.startsWith(e)))
164
- throw new Error(`Cannot delete a locked path "${t}"`);
165
- this.bag = B(this.bag, (e) => {
166
- f.unset(e, t);
150
+ if (r === null || typeof r > "u")
151
+ return this.set(e, t);
152
+ throw new Error(`Cannot merge a non-object path "${e}"`);
153
+ }
154
+ has(e) {
155
+ return f.has(this.bag, e);
156
+ }
157
+ delete(e) {
158
+ if (this.locked.some((t) => e.startsWith(t)))
159
+ throw new Error(`Cannot delete a locked path "${e}"`);
160
+ this.bag = B(this.bag, (t) => {
161
+ f.unset(t, e);
167
162
  }), this.emit("change", {
168
- path: t,
163
+ path: e,
169
164
  value: null,
170
165
  type: "delete"
171
166
  });
172
167
  }
173
- lock(t) {
174
- if (!this.has(t))
175
- throw new Error(`Cannot lock a non-existing path "${t}"`);
176
- this.locked.push(t);
168
+ lock(e) {
169
+ if (!this.has(e))
170
+ throw new Error(`Cannot lock a non-existing path "${e}"`);
171
+ this.locked.push(e);
177
172
  }
178
173
  clone() {
179
174
  return new v(this.bag);
@@ -185,71 +180,71 @@ class v {
185
180
  return f.isEmpty(this.bag);
186
181
  }
187
182
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
188
- on(t, e) {
183
+ on(e, t) {
189
184
  return () => null;
190
185
  }
191
186
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
192
- once(t, e) {
187
+ once(e, t) {
193
188
  }
194
189
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
195
- emit(t, e) {
190
+ emit(e, t) {
196
191
  }
197
192
  }
198
193
  function A(n) {
199
- var t, e, s, r, Z;
200
- return e = class extends n {
201
- constructor(...a) {
202
- super(...a);
194
+ var e, t, r, s, i, k;
195
+ return s = class extends (t = n, e = Symbol.toStringTag, t) {
196
+ constructor(...d) {
197
+ super(...d);
198
+ q(this, i);
203
199
  q(this, r);
204
- q(this, t, void 0);
205
- p(this, s, n.name);
206
- Q(this, t, G(this, r, Z).call(this));
200
+ p(this, e, n.name);
201
+ P(this, r, V(this, i, k).call(this));
207
202
  }
208
- on(a, d) {
209
- if (typeof a != "string")
203
+ on(d, g) {
204
+ if (typeof d != "string")
210
205
  throw new TypeError("event must be a string");
211
- if (typeof d != "function")
206
+ if (typeof g != "function")
212
207
  throw new TypeError("callback must be a function");
213
- return o(this, t).on(a, d);
208
+ return o(this, r).on(d, g);
214
209
  }
215
- once(a, d) {
216
- if (typeof a != "string")
210
+ once(d, g) {
211
+ if (typeof d != "string")
217
212
  throw new TypeError("event must be a string");
218
- if (typeof d != "function")
213
+ if (typeof g != "function")
219
214
  throw new TypeError("callback must be a function");
220
- const g = o(this, t).on(a, (b) => {
221
- g(), d(b);
215
+ const b = o(this, r).on(d, (m) => {
216
+ b(), g(m);
222
217
  });
223
218
  }
224
- emit(a, d = {}) {
225
- if (typeof a != "string")
219
+ emit(d, g = {}) {
220
+ if (typeof d != "string")
226
221
  throw new TypeError("event must be a string");
227
- if (typeof d != "object")
222
+ if (typeof g != "object")
228
223
  throw new TypeError("data must be an object");
229
- o(this, t).emit(a, {
230
- ...d,
224
+ o(this, r).emit(d, {
225
+ ...g,
231
226
  source: this
232
227
  });
233
228
  }
234
- }, s = Symbol.toStringTag, t = new WeakMap(), r = new WeakSet(), Z = function() {
229
+ }, r = new WeakMap(), i = new WeakSet(), k = function() {
235
230
  return {
236
- emit(a, d) {
237
- for (let g = 0, b = this.events[a] || [], m = b.length; g < m; g++)
238
- b[g](d);
231
+ emit(d, g) {
232
+ for (let b = 0, m = this.events[d] || [], x = m.length; b < x; b++)
233
+ m[b](g);
239
234
  },
240
235
  events: {},
241
- on(a, d) {
242
- var g;
243
- return ((g = this.events)[a] || (g[a] = [])).push(d), () => {
244
- var b;
245
- this.events[a] = (b = this.events[a]) == null ? void 0 : b.filter((m) => d !== m);
236
+ on(d, g) {
237
+ var b;
238
+ return ((b = this.events)[d] || (b[d] = [])).push(g), () => {
239
+ var m;
240
+ this.events[d] = (m = this.events[d]) == null ? void 0 : m.filter((x) => g !== x);
246
241
  };
247
242
  }
248
243
  };
249
- }, p(e, "name", n.name), e;
244
+ }, p(s, "name", n.name), s;
250
245
  }
251
- function V(...n) {
252
- return n.reduce((t, e) => t.flatMap((s) => e.map((r) => [s, r].flat())));
246
+ function X(...n) {
247
+ return n.reduce((e, t) => e.flatMap((r) => t.map((s) => [r, s].flat())));
253
248
  }
254
249
  function T(n) {
255
250
  return !(typeof n != "object" || n === null || !Reflect.has(n, "constructor") || Reflect.get(n.constructor, "name") !== "Collection");
@@ -260,731 +255,732 @@ class y extends Error {
260
255
  }
261
256
  }
262
257
  p(y, "name", "MethodNotImplementedException");
263
- function c(n = [], t = j) {
258
+ function l(n = [], e = L) {
264
259
  if (!Array.isArray(n))
265
260
  throw new TypeError("collect() expects an array");
266
- return new (A(t))([...n]);
261
+ return new (A(e))([...n]);
267
262
  }
268
263
  const $ = (n) => {
269
264
  n.emit("change", {
270
265
  items: n.all()
271
266
  });
272
- }, I = (n, t) => Array.isArray(n) ? n[t] ?? null : n.get(t);
273
- var u, Ft;
274
- class j {
275
- constructor(t = []) {
276
- q(this, u, void 0);
277
- p(this, Ft, this.constructor.name);
278
- Q(this, u, t);
267
+ }, I = (n, e) => Array.isArray(n) ? n[e] ?? null : n.get(e);
268
+ var Z, z, h;
269
+ class L {
270
+ constructor(e = []) {
271
+ // static name = 'Collection';
272
+ q(this, h);
273
+ p(this, Z, "Collection");
274
+ P(this, h, e);
279
275
  }
280
276
  get items() {
281
- return [...o(this, u)];
277
+ return [...o(this, h)];
282
278
  }
283
- [Symbol.iterator]() {
284
- return o(this, u)[Symbol.iterator]();
279
+ [(z = Symbol.iterator, Z = Symbol.toStringTag, z)]() {
280
+ return o(this, h)[Symbol.iterator]();
285
281
  }
286
282
  all() {
287
- return [...o(this, u)];
283
+ return [...o(this, h)];
288
284
  }
289
- average(t) {
290
- return typeof t == "string" ? this.avg(t) : this.avg();
285
+ average(e) {
286
+ return typeof e == "string" ? this.avg(e) : this.avg();
291
287
  }
292
- avg(t) {
293
- return typeof t == "string" ? this.sum(t) / o(this, u).length : this.sum() / o(this, u).length;
288
+ avg(e) {
289
+ return typeof e == "string" ? this.sum(e) / o(this, h).length : this.sum() / o(this, h).length;
294
290
  }
295
- chunk(t) {
296
- const e = [];
297
- for (let s = 0; s < o(this, u).length; s += t)
298
- e.push(o(this, u).slice(s, s + t));
299
- return c(e.map((s) => c(s)));
291
+ chunk(e) {
292
+ const t = [];
293
+ for (let r = 0; r < o(this, h).length; r += e)
294
+ t.push(o(this, h).slice(r, r + e));
295
+ return l(t.map((r) => l(r)));
300
296
  }
301
- chunkWhile(t) {
302
- const e = [];
303
- let s = c();
304
- for (let r = 0; r < o(this, u).length; r++)
305
- t(o(this, u)[r], r, s) ? s.push(o(this, u)[r]) : (e.push(s), s = c());
306
- return s.count() > 0 && e.push(s), c(e);
297
+ chunkWhile(e) {
298
+ const t = [];
299
+ let r = l();
300
+ for (let s = 0; s < o(this, h).length; s++)
301
+ e(o(this, h)[s], s, r) ? r.push(o(this, h)[s]) : (t.push(r), r = l());
302
+ return r.count() > 0 && t.push(r), l(t);
307
303
  }
308
304
  collapse() {
309
- return c(o(this, u).flat());
305
+ return l(o(this, h).flat());
310
306
  }
311
307
  collect() {
312
- return c(o(this, u));
308
+ return l(o(this, h));
313
309
  }
314
- combine(t) {
315
- const e = {};
316
- return o(this, u).forEach((s, r) => {
317
- if (typeof s != "string")
310
+ combine(e) {
311
+ const t = {};
312
+ return o(this, h).forEach((r, s) => {
313
+ if (typeof r != "string")
318
314
  throw new TypeError("The `combine` method expects the keys to be strings");
319
- e[s] = I(t, r);
320
- }), e;
315
+ t[r] = I(e, s);
316
+ }), t;
321
317
  }
322
- concat(t) {
323
- return Array.isArray(t) ? c([...o(this, u), ...t]) : c([...o(this, u), ...t.all()]);
318
+ concat(e) {
319
+ return Array.isArray(e) ? l([...o(this, h), ...e]) : l([...o(this, h), ...e.all()]);
324
320
  }
325
- contains(t, e) {
326
- return typeof t == "function" ? o(this, u).some((s, r) => t(s, r, this)) : o(this, u).some((s) => {
327
- if (typeof e > "u")
328
- return s == t;
329
- if (typeof t != "string")
321
+ contains(e, t) {
322
+ return typeof e == "function" ? o(this, h).some((r, s) => e(r, s, this)) : o(this, h).some((r) => {
323
+ if (typeof t > "u")
324
+ return r == e;
325
+ if (typeof e != "string")
330
326
  throw new TypeError("The key must be a string");
331
- return s[t] == e;
327
+ return r[e] == t;
332
328
  });
333
329
  }
334
330
  containsOneItem() {
335
- return o(this, u).length === 1;
331
+ return o(this, h).length === 1;
336
332
  }
337
- containsStrict(t, e) {
338
- return typeof t == "function" ? o(this, u).some((s, r) => t(s, r, this)) : o(this, u).some((s) => {
339
- if (typeof e > "u")
340
- return s === t;
341
- if (typeof t != "string")
333
+ containsStrict(e, t) {
334
+ return typeof e == "function" ? o(this, h).some((r, s) => e(r, s, this)) : o(this, h).some((r) => {
335
+ if (typeof t > "u")
336
+ return r === e;
337
+ if (typeof e != "string")
342
338
  throw new TypeError("The key must be a string");
343
- return s[t] === e;
339
+ return r[e] === t;
344
340
  });
345
341
  }
346
342
  count() {
347
- return o(this, u).length;
348
- }
349
- countBy(t) {
350
- return typeof t == "function" ? o(this, u).reduce((e, s, r) => {
351
- const i = t(s, r, this);
352
- return e[i] = e[i] ? e[i] + 1 : 1, e;
353
- }, {}) : o(this, u).reduce((e, s) => {
354
- if (!["string", "number"].includes(typeof s))
343
+ return o(this, h).length;
344
+ }
345
+ countBy(e) {
346
+ return typeof e == "function" ? o(this, h).reduce((t, r, s) => {
347
+ const i = e(r, s, this);
348
+ return t[i] = t[i] ? t[i] + 1 : 1, t;
349
+ }, {}) : o(this, h).reduce((t, r) => {
350
+ if (!["string", "number"].includes(typeof r))
355
351
  throw new TypeError("The countBy method expects the items to be strings or numbers");
356
- return e[String(s)] = e[String(s)] ? e[String(s)] + 1 : 1, e;
352
+ return t[String(r)] = t[String(r)] ? t[String(r)] + 1 : 1, t;
357
353
  }, {});
358
354
  }
359
- crossJoin(...t) {
360
- return c(V(
361
- o(this, u),
362
- ...t.map((e) => Array.isArray(e) ? e : e.all())
355
+ crossJoin(...e) {
356
+ return l(X(
357
+ o(this, h),
358
+ ...e.map((t) => Array.isArray(t) ? t : t.all())
363
359
  ));
364
360
  }
365
- diff(t) {
366
- return Array.isArray(t) ? c(o(this, u).filter((e) => !t.includes(e))) : c(o(this, u).filter((e) => !t.contains(e)));
361
+ diff(e) {
362
+ return Array.isArray(e) ? l(o(this, h).filter((t) => !e.includes(t))) : l(o(this, h).filter((t) => !e.contains(t)));
367
363
  }
368
- doesntContain(t, e) {
369
- return typeof t == "function" ? o(this, u).every((s, r) => !t(s, r, this)) : o(this, u).every((s) => {
370
- if (typeof e > "u")
371
- return s != t;
372
- if (typeof t != "string")
364
+ doesntContain(e, t) {
365
+ return typeof e == "function" ? o(this, h).every((r, s) => !e(r, s, this)) : o(this, h).every((r) => {
366
+ if (typeof t > "u")
367
+ return r != e;
368
+ if (typeof e != "string")
373
369
  throw new TypeError("The key must be a string");
374
- return s[t] != e;
370
+ return r[e] != t;
375
371
  });
376
372
  }
377
373
  dump() {
378
374
  console.log(this.toArray());
379
375
  }
380
- duplicates(t) {
381
- return c(typeof t == "string" ? o(this, u).reduce((e, s, r) => (o(this, u).slice(r + 1).some((i) => i[t] == s[t]) && e.push(s[t]), e), []) : o(this, u).reduce((e, s, r) => (o(this, u).slice(r + 1).some((i) => i == s) && e.push(s), e), []));
376
+ duplicates(e) {
377
+ return l(typeof e == "string" ? o(this, h).reduce((t, r, s) => (o(this, h).slice(s + 1).some((i) => i[e] == r[e]) && t.push(r[e]), t), []) : o(this, h).reduce((t, r, s) => (o(this, h).slice(s + 1).some((i) => i == r) && t.push(r), t), []));
382
378
  }
383
- duplicatesStrict(t) {
384
- return c(typeof t == "string" ? o(this, u).reduce((e, s, r) => (o(this, u).slice(r + 1).some((i) => i[t] === s[t]) && e.push(s[t]), e), []) : o(this, u).reduce((e, s, r) => (o(this, u).slice(r + 1).some((i) => i === s) && e.push(s), e), []));
379
+ duplicatesStrict(e) {
380
+ return l(typeof e == "string" ? o(this, h).reduce((t, r, s) => (o(this, h).slice(s + 1).some((i) => i[e] === r[e]) && t.push(r[e]), t), []) : o(this, h).reduce((t, r, s) => (o(this, h).slice(s + 1).some((i) => i === r) && t.push(r), t), []));
385
381
  }
386
- each(t) {
387
- let e = 0;
388
- for (const s of this) {
389
- if (t(s, e, this) === !1)
382
+ each(e) {
383
+ let t = 0;
384
+ for (const r of this) {
385
+ if (e(r, t, this) === !1)
390
386
  break;
391
- e++;
387
+ t++;
392
388
  }
393
389
  return this;
394
390
  }
395
- eachSpread(t) {
396
- for (const e of this) {
397
- if (!Array.isArray(e) && !T(e))
391
+ eachSpread(e) {
392
+ for (const t of this) {
393
+ if (!Array.isArray(t) && !T(t))
398
394
  throw new TypeError("The items in the collection must be arrays or collections");
399
- const s = Array.isArray(e) ? e : e.all();
400
- if (t(...s) === !1)
395
+ const r = Array.isArray(t) ? t : t.all();
396
+ if (e(...r) === !1)
401
397
  break;
402
398
  }
403
399
  return this;
404
400
  }
405
- ensure(t) {
406
- const e = Array.isArray(t) ? t : [t];
407
- return o(this, u).forEach((s, r) => {
408
- if (!e.some((i) => typeof i == "string" ? typeof s === i : s instanceof i))
409
- throw new TypeError(`The item at index ${r} is not of the expected type`);
401
+ ensure(e) {
402
+ const t = Array.isArray(e) ? e : [e];
403
+ return o(this, h).forEach((r, s) => {
404
+ if (!t.some((i) => typeof i == "string" ? typeof r === i : r instanceof i))
405
+ throw new TypeError(`The item at index ${s} is not of the expected type`);
410
406
  }), this;
411
407
  }
412
- every(t) {
413
- return o(this, u).every((e, s) => t(e, s, this));
408
+ every(e) {
409
+ return o(this, h).every((t, r) => e(t, r, this));
414
410
  }
415
- except(t) {
416
- return c(o(this, u).filter((e, s) => !t.includes(s)));
411
+ except(e) {
412
+ return l(o(this, h).filter((t, r) => !e.includes(r)));
417
413
  }
418
- filter(t) {
419
- return c(o(this, u).filter((e, s) => typeof t != "function" ? !!e : t(e, s, this)));
414
+ filter(e) {
415
+ return l(o(this, h).filter((t, r) => typeof e != "function" ? !!t : e(t, r, this)));
420
416
  }
421
- first(t) {
422
- return typeof t == "function" ? o(this, u).find((e, s) => t(e, s, this)) ?? null : o(this, u)[0] ?? null;
417
+ first(e) {
418
+ return typeof e == "function" ? o(this, h).find((t, r) => e(t, r, this)) ?? null : o(this, h)[0] ?? null;
423
419
  }
424
- firstOrFail(t) {
425
- const e = this.first(t);
426
- if (e === null)
420
+ firstOrFail(e) {
421
+ const t = this.first(e);
422
+ if (t === null)
427
423
  throw new Error("No matching item found");
428
- return e;
424
+ return t;
429
425
  }
430
- firstWhere(t, e, s) {
431
- if (typeof t != "string")
432
- throw new TypeError("The key must be a string");
433
- if (typeof e > "u")
434
- return this.first((r) => !!r[t]);
435
- if (typeof s > "u")
436
- return o(this, u).find((r) => r[t] == e) ?? null;
426
+ firstWhere(e, t, r) {
437
427
  if (typeof e != "string")
428
+ throw new TypeError("The key must be a string");
429
+ if (typeof t > "u")
430
+ return this.first((s) => !!s[e]);
431
+ if (typeof r > "u")
432
+ return o(this, h).find((s) => s[e] == t) ?? null;
433
+ if (typeof t != "string")
438
434
  throw new TypeError("The operator must be a string");
439
- return s === null ? o(this, u).find((r) => r[t] === null) ?? null : o(this, u).find((r) => {
440
- switch (e) {
435
+ return r === null ? o(this, h).find((s) => s[e] === null) ?? null : o(this, h).find((s) => {
436
+ switch (t) {
441
437
  case "=":
442
- return r[t] == s;
438
+ return s[e] == r;
443
439
  case "!=":
444
- return r[t] != s;
440
+ return s[e] != r;
445
441
  case ">":
446
- return r[t] > s;
442
+ return s[e] > r;
447
443
  case "<":
448
- return r[t] < s;
444
+ return s[e] < r;
449
445
  case ">=":
450
- return r[t] >= s;
446
+ return s[e] >= r;
451
447
  case "<=":
452
- return r[t] <= s;
448
+ return s[e] <= r;
453
449
  default:
454
450
  throw new Error("Unsupported operator");
455
451
  }
456
452
  }) ?? null;
457
453
  }
458
- flatMap(t) {
459
- return c(o(this, u).flatMap((e, s) => t(e, s, this)));
454
+ flatMap(e) {
455
+ return l(o(this, h).flatMap((t, r) => e(t, r, this)));
460
456
  }
461
- forget(t) {
462
- return o(this, u).splice(t, 1), $(this), this;
457
+ forget(e) {
458
+ return o(this, h).splice(e, 1), $(this), this;
463
459
  }
464
- forPage(t, e) {
465
- return c(o(this, u).slice((t - 1) * e, t * e));
460
+ forPage(e, t) {
461
+ return l(o(this, h).slice((e - 1) * t, e * t));
466
462
  }
467
- get(t, e) {
468
- if (typeof t != "number")
463
+ get(e, t) {
464
+ if (typeof e != "number")
469
465
  throw new TypeError("The key must be a number");
470
- return typeof e > "u" ? o(this, u)[t] ?? null : typeof e == "function" ? o(this, u)[t] ?? e() : o(this, u)[t] ?? e;
471
- }
472
- groupBy(t) {
473
- const e = Array.isArray(t) ? t : [t];
474
- return o(this, u).reduce((s, r, i) => {
475
- const h = e.map((a) => {
476
- if (typeof a == "function") {
477
- const d = a(r, i, this);
466
+ return typeof t > "u" ? o(this, h)[e] ?? null : typeof t == "function" ? o(this, h)[e] ?? t() : o(this, h)[e] ?? t;
467
+ }
468
+ groupBy(e) {
469
+ const t = Array.isArray(e) ? e : [e];
470
+ return o(this, h).reduce((r, s, i) => {
471
+ const u = t.map((c) => {
472
+ if (typeof c == "function") {
473
+ const d = c(s, i, this);
478
474
  return Array.isArray(d) ? d : [d];
479
475
  }
480
- return [String(r[a])];
476
+ return [String(s[c])];
481
477
  });
482
- return V(...h).forEach((a) => {
483
- const d = Array.isArray(a) ? a.join(".") : a;
484
- f.set(s, d, [
485
- ...f.get(s, d, []),
486
- r
478
+ return X(...u).forEach((c) => {
479
+ const d = Array.isArray(c) ? c.join(".") : c;
480
+ f.set(r, d, [
481
+ ...f.get(r, d, []),
482
+ s
487
483
  ]);
488
- }), s;
484
+ }), r;
489
485
  }, {});
490
486
  }
491
- has(t) {
492
- return o(this, u).length > t;
487
+ has(e) {
488
+ return o(this, h).length > e;
493
489
  }
494
- hasAny(t) {
495
- return t.some((e) => this.has(e));
490
+ hasAny(e) {
491
+ return e.some((t) => this.has(t));
496
492
  }
497
- implode(t, e) {
498
- if (typeof e > "u") {
499
- if (typeof t != "string")
493
+ implode(e, t) {
494
+ if (typeof t > "u") {
495
+ if (typeof e != "string")
500
496
  throw new TypeError("The glue must be a string");
501
- if (!o(this, u).every((s) => ["string", "number"].includes(typeof s)))
497
+ if (!o(this, h).every((r) => ["string", "number"].includes(typeof r)))
502
498
  throw new TypeError("The items must be strings or numbers");
503
- return o(this, u).join(t);
499
+ return o(this, h).join(e);
504
500
  }
505
- if (typeof t == "function")
506
- return o(this, u).map((s, r) => t(s, r, this)).join(e);
507
- if (typeof t != "string")
501
+ if (typeof e == "function")
502
+ return o(this, h).map((r, s) => e(r, s, this)).join(t);
503
+ if (typeof e != "string")
508
504
  throw new TypeError("The key must be a string");
509
- if (!o(this, u).every((s) => typeof s == "object"))
505
+ if (!o(this, h).every((r) => typeof r == "object"))
510
506
  throw new TypeError("The items must be objects");
511
- return o(this, u).map((s) => s[t]).join(e);
507
+ return o(this, h).map((r) => r[e]).join(t);
512
508
  }
513
- intersect(t) {
514
- return Array.isArray(t) ? c(o(this, u).filter((e) => t.includes(e))) : c(o(this, u).filter((e) => t.contains(e)));
509
+ intersect(e) {
510
+ return Array.isArray(e) ? l(o(this, h).filter((t) => e.includes(t))) : l(o(this, h).filter((t) => e.contains(t)));
515
511
  }
516
512
  isEmpty() {
517
- return o(this, u).length === 0;
513
+ return o(this, h).length === 0;
518
514
  }
519
515
  isNotEmpty() {
520
516
  return !this.isEmpty();
521
517
  }
522
- join(t, e) {
523
- return typeof e > "u" ? o(this, u).join(t) : o(this, u).slice(0, -1).join(t) + e + o(this, u)[o(this, u).length - 1];
518
+ join(e, t) {
519
+ return typeof t > "u" ? o(this, h).join(e) : o(this, h).slice(0, -1).join(e) + t + o(this, h)[o(this, h).length - 1];
524
520
  }
525
- keyBy(t) {
526
- if (typeof t == "function")
527
- return o(this, u).reduce((e, s, r) => (e[t(s, r, this)] = s, e), {});
528
- if (typeof t != "string")
521
+ keyBy(e) {
522
+ if (typeof e == "function")
523
+ return o(this, h).reduce((t, r, s) => (t[e(r, s, this)] = r, t), {});
524
+ if (typeof e != "string")
529
525
  throw new TypeError("The key must be a string");
530
- return o(this, u).reduce((e, s) => (e[String(s[t])] = s, e), {});
526
+ return o(this, h).reduce((t, r) => (t[String(r[e])] = r, t), {});
531
527
  }
532
- last(t) {
533
- return typeof t == "function" ? o(this, u).toReversed().find((e, s) => t(e, s, this)) ?? null : o(this, u)[o(this, u).length - 1] ?? null;
528
+ last(e) {
529
+ return typeof e == "function" ? o(this, h).toReversed().find((t, r) => e(t, r, this)) ?? null : o(this, h)[o(this, h).length - 1] ?? null;
534
530
  }
535
- map(t) {
536
- return c(o(this, u).map((e, s) => t(e, s, this)));
531
+ map(e) {
532
+ return l(o(this, h).map((t, r) => e(t, r, this)));
537
533
  }
538
- mapInto(t) {
539
- return c(o(this, u).map((e) => new t(e)));
534
+ mapInto(e) {
535
+ return l(o(this, h).map((t) => new e(t)));
540
536
  }
541
- mapSpread(t) {
542
- return c(o(this, u).map((e) => {
543
- if (!Array.isArray(e) && !T(e))
537
+ mapSpread(e) {
538
+ return l(o(this, h).map((t) => {
539
+ if (!Array.isArray(t) && !T(t))
544
540
  throw new TypeError("The items in the collection must be arrays or collections");
545
- const s = Array.isArray(e) ? e : e.all();
546
- return t(...s);
541
+ const r = Array.isArray(t) ? t : t.all();
542
+ return e(...r);
547
543
  }));
548
544
  }
549
- mapToGroups(t) {
550
- return o(this, u).reduce((e, s, r) => {
551
- const i = t(s, r, this);
552
- return Object.entries(i).forEach(([h, l]) => {
553
- e[h] = e[h] ?? [], e[h].push(l);
554
- }), e;
545
+ mapToGroups(e) {
546
+ return o(this, h).reduce((t, r, s) => {
547
+ const i = e(r, s, this);
548
+ return Object.entries(i).forEach(([u, a]) => {
549
+ t[u] = t[u] ?? [], t[u].push(a);
550
+ }), t;
555
551
  }, {});
556
552
  }
557
- mapWithKeys(t) {
558
- return o(this, u).reduce((e, s, r) => {
559
- const i = t(s, r, this);
560
- return Object.entries(i).forEach(([h, l]) => {
561
- e[h] = l;
562
- }), e;
553
+ mapWithKeys(e) {
554
+ return o(this, h).reduce((t, r, s) => {
555
+ const i = e(r, s, this);
556
+ return Object.entries(i).forEach(([u, a]) => {
557
+ t[u] = a;
558
+ }), t;
563
559
  }, {});
564
560
  }
565
- max(t) {
566
- return typeof t == "string" ? o(this, u).reduce((e, s) => s[t] > e ? s[t] : e, o(this, u)[0][t]) : o(this, u).reduce((e, s) => s > e ? s : e, o(this, u)[0]);
561
+ max(e) {
562
+ return typeof e == "string" ? o(this, h).reduce((t, r) => r[e] > t ? r[e] : t, o(this, h)[0][e]) : o(this, h).reduce((t, r) => r > t ? r : t, o(this, h)[0]);
567
563
  }
568
- median(t) {
569
- if (typeof t == "string") {
570
- const r = this.pluck(t).sort(), i = Math.floor(r.count() / 2);
571
- return r.count() % 2 === 0 ? c([I(r, i - 1), I(r, i)]).avg() : I(r, i);
564
+ median(e) {
565
+ if (typeof e == "string") {
566
+ const s = this.pluck(e).sort(), i = Math.floor(s.count() / 2);
567
+ return s.count() % 2 === 0 ? l([I(s, i - 1), I(s, i)]).avg() : I(s, i);
572
568
  }
573
- const e = o(this, u).toSorted(), s = Math.floor(e.length / 2);
574
- return e.length % 2 === 0 ? c([e[s - 1], e[s]]).avg() : e[s] ?? null;
569
+ const t = o(this, h).toSorted(), r = Math.floor(t.length / 2);
570
+ return t.length % 2 === 0 ? l([t[r - 1], t[r]]).avg() : t[r] ?? null;
575
571
  }
576
- merge(t) {
577
- return Array.isArray(t) ? c([...o(this, u), ...t]) : c([...o(this, u), ...t.all()]);
572
+ merge(e) {
573
+ return Array.isArray(e) ? l([...o(this, h), ...e]) : l([...o(this, h), ...e.all()]);
578
574
  }
579
- min(t) {
580
- return typeof t == "string" ? o(this, u).reduce((e, s) => s[t] < e ? s[t] : e, o(this, u)[0][t]) : o(this, u).reduce((e, s) => s < e ? s : e, o(this, u)[0]);
575
+ min(e) {
576
+ return typeof e == "string" ? o(this, h).reduce((t, r) => r[e] < t ? r[e] : t, o(this, h)[0][e]) : o(this, h).reduce((t, r) => r < t ? r : t, o(this, h)[0]);
581
577
  }
582
- mode(t) {
583
- const e = typeof t == "string" ? this.filter((r) => ["number", "string"].includes(typeof r[t])).countBy((r) => r[t]) : this.countBy(), s = Math.max(...Object.values(e));
584
- return Object.entries(e).filter(([, r]) => r === s).map(([r]) => r);
578
+ mode(e) {
579
+ const t = typeof e == "string" ? this.filter((s) => ["number", "string"].includes(typeof s[e])).countBy((s) => s[e]) : this.countBy(), r = Math.max(...Object.values(t));
580
+ return Object.entries(t).filter(([, s]) => s === r).map(([s]) => s);
585
581
  }
586
- nth(t, e = 0) {
587
- return this.chunk(t).filter((s) => s.count() > e).map((s) => s.get(e));
582
+ nth(e, t = 0) {
583
+ return this.chunk(e).filter((r) => r.count() > t).map((r) => r.get(t));
588
584
  }
589
- only(t) {
590
- return c(o(this, u).filter((e, s) => t.includes(s)));
585
+ only(e) {
586
+ return l(o(this, h).filter((t, r) => e.includes(r)));
591
587
  }
592
- pad(t, e = null) {
593
- const s = o(this, u).slice();
594
- for (; s.length < Math.abs(t); )
595
- t > 0 ? s.push(e) : s.unshift(e);
596
- return c(s);
588
+ pad(e, t = null) {
589
+ const r = o(this, h).slice();
590
+ for (; r.length < Math.abs(e); )
591
+ e > 0 ? r.push(t) : r.unshift(t);
592
+ return l(r);
597
593
  }
598
- partition(t) {
594
+ partition(e) {
599
595
  return [
600
- this.filter(t),
601
- this.reject(t)
596
+ this.filter(e),
597
+ this.reject(e)
602
598
  ];
603
599
  }
604
- percentage(t, e = 2) {
600
+ percentage(e, t = 2) {
605
601
  return Math.round(
606
- 100 * (10 ^ e) * this.filter(t).count() / o(this, u).length
607
- ) / (10 ^ e);
602
+ 100 * (10 ^ t) * this.filter(e).count() / o(this, h).length
603
+ ) / (10 ^ t);
608
604
  }
609
- pipe(t) {
610
- return t(this);
605
+ pipe(e) {
606
+ return e(this);
611
607
  }
612
- pipeInto(t) {
613
- return new t(this);
608
+ pipeInto(e) {
609
+ return new e(this);
614
610
  }
615
- pipeThrough(t) {
616
- return t.reduce((e, s) => {
617
- if (!T(e) && !Array.isArray(e))
611
+ pipeThrough(e) {
612
+ return e.reduce((t, r) => {
613
+ if (!T(t) && !Array.isArray(t))
618
614
  throw new TypeError("The pipeline expects the carry to be a collection or an array");
619
- return s(
620
- T(e) ? e : c(e)
615
+ return r(
616
+ T(t) ? t : l(t)
621
617
  );
622
618
  }, this);
623
619
  }
624
- pluck(t) {
625
- return this.map((e) => e[t]);
620
+ pluck(e) {
621
+ return this.map((t) => t[e]);
626
622
  }
627
- pop(t = 1) {
628
- const e = o(this, u).splice(o(this, u).length - t, t);
629
- return $(this), t === 1 ? e[0] ?? null : c(e);
623
+ pop(e = 1) {
624
+ const t = o(this, h).splice(o(this, h).length - e, e);
625
+ return $(this), e === 1 ? t[0] ?? null : l(t);
630
626
  }
631
- prepend(t) {
632
- const e = o(this, u).unshift(t);
633
- return $(this), e;
627
+ prepend(e) {
628
+ const t = o(this, h).unshift(e);
629
+ return $(this), t;
634
630
  }
635
- pull(t) {
636
- const e = o(this, u).splice(t, 1)[0] ?? null;
637
- return $(this), e;
631
+ pull(e) {
632
+ const t = o(this, h).splice(e, 1)[0] ?? null;
633
+ return $(this), t;
638
634
  }
639
- push(...t) {
640
- const e = o(this, u).push(...t);
641
- return $(this), e;
635
+ push(...e) {
636
+ const t = o(this, h).push(...e);
637
+ return $(this), t;
642
638
  }
643
- put(t, e) {
644
- return o(this, u).splice(t, 1, e), $(this), this;
639
+ put(e, t) {
640
+ return o(this, h).splice(e, 1, t), $(this), this;
645
641
  }
646
- random(t = 1) {
647
- if (o(this, u).length < t)
642
+ random(e = 1) {
643
+ if (o(this, h).length < e)
648
644
  throw new Error("The collection has fewer items than the requested amount");
649
- const e = c(f.sampleSize(o(this, u), t));
650
- return t === 1 ? e.first() : e;
645
+ const t = l(f.sampleSize(o(this, h), e));
646
+ return e === 1 ? t.first() : t;
651
647
  }
652
- reduce(t, e = null) {
653
- return o(this, u).reduce((s, r, i) => t(s, r, i, this), e);
648
+ reduce(e, t = null) {
649
+ return o(this, h).reduce((r, s, i) => e(r, s, i, this), t);
654
650
  }
655
- reject(t) {
656
- return this.filter((e, s) => !t(e, s, this));
651
+ reject(e) {
652
+ return this.filter((t, r) => !e(t, r, this));
657
653
  }
658
- replace(t) {
659
- const e = o(this, u).slice();
660
- return Object.entries(t).forEach(([s, r]) => {
661
- e[parseInt(s)] = r;
662
- }), c(e);
654
+ replace(e) {
655
+ const t = o(this, h).slice();
656
+ return Object.entries(e).forEach(([r, s]) => {
657
+ t[parseInt(r)] = s;
658
+ }), l(t);
663
659
  }
664
660
  reverse() {
665
- return c(o(this, u).toReversed());
661
+ return l(o(this, h).toReversed());
666
662
  }
667
- search(t, e = !1) {
668
- if (typeof t != "function" || o(this, u).every((r) => typeof r == "function")) {
669
- const r = o(this, u).findIndex((i) => e ? i === t : i == t);
670
- return r === -1 ? !1 : r;
663
+ search(e, t = !1) {
664
+ if (typeof e != "function" || o(this, h).every((s) => typeof s == "function")) {
665
+ const s = o(this, h).findIndex((i) => t ? i === e : i == e);
666
+ return s === -1 ? !1 : s;
671
667
  }
672
- const s = o(this, u).findIndex((r, i) => t(r, i, this));
673
- return s === -1 ? !1 : s;
668
+ const r = o(this, h).findIndex((s, i) => e(s, i, this));
669
+ return r === -1 ? !1 : r;
674
670
  }
675
- select(t) {
676
- return this.map((e) => t.reduce((s, r) => (s[r] = e[r], s), {}));
671
+ select(e) {
672
+ return this.map((t) => e.reduce((r, s) => (r[s] = t[s], r), {}));
677
673
  }
678
- shift(t = 1) {
679
- const e = o(this, u).splice(0, t);
680
- return $(this), t === 1 ? e[0] ?? null : c(e);
674
+ shift(e = 1) {
675
+ const t = o(this, h).splice(0, e);
676
+ return $(this), e === 1 ? t[0] ?? null : l(t);
681
677
  }
682
678
  shuffle() {
683
- return c(f.shuffle(o(this, u)));
679
+ return l(f.shuffle(o(this, h)));
684
680
  }
685
- skip(t) {
686
- return c(o(this, u).slice(t));
681
+ skip(e) {
682
+ return l(o(this, h).slice(e));
687
683
  }
688
- skipUntil(t) {
689
- return typeof t == "function" ? this.skip(o(this, u).findIndex((e, s) => t(e, s, this))) : this.skip(o(this, u).findIndex((e) => e == t));
684
+ skipUntil(e) {
685
+ return typeof e == "function" ? this.skip(o(this, h).findIndex((t, r) => e(t, r, this))) : this.skip(o(this, h).findIndex((t) => t == e));
690
686
  }
691
- skipWhile(t) {
692
- return typeof t == "function" ? this.skip(o(this, u).findIndex((e, s) => !t(e, s, this))) : this.skip(o(this, u).findIndex((e) => e != t));
687
+ skipWhile(e) {
688
+ return typeof e == "function" ? this.skip(o(this, h).findIndex((t, r) => !e(t, r, this))) : this.skip(o(this, h).findIndex((t) => t != e));
693
689
  }
694
- slice(t, e) {
695
- return c(typeof e > "u" ? o(this, u).slice(t) : typeof t > "u" ? o(this, u).slice(0, e) : o(this, u).slice(t, t + e));
690
+ slice(e, t) {
691
+ return l(typeof t > "u" ? o(this, h).slice(e) : typeof e > "u" ? o(this, h).slice(0, t) : o(this, h).slice(e, e + t));
696
692
  }
697
- sliding(t, e = 1) {
698
- const s = [];
699
- for (let r = 0; r < o(this, u).length && !(r + t > o(this, u).length); r += e)
700
- s.push(o(this, u).slice(r, r + t));
701
- return c(s.map((r) => c(r)));
693
+ sliding(e, t = 1) {
694
+ const r = [];
695
+ for (let s = 0; s < o(this, h).length && !(s + e > o(this, h).length); s += t)
696
+ r.push(o(this, h).slice(s, s + e));
697
+ return l(r.map((s) => l(s)));
702
698
  }
703
- sole(t, e) {
704
- if (typeof t == "function") {
705
- const s = this.filter(t);
706
- return s.count() === 1 ? s.first() : null;
699
+ sole(e, t) {
700
+ if (typeof e == "function") {
701
+ const r = this.filter(e);
702
+ return r.count() === 1 ? r.first() : null;
707
703
  }
708
- if (typeof t == "string") {
709
- const s = this.where(t, e);
710
- return s.count() === 1 ? s.first() : null;
704
+ if (typeof e == "string") {
705
+ const r = this.where(e, t);
706
+ return r.count() === 1 ? r.first() : null;
711
707
  }
712
- return o(this, u).length === 1 ? this.first() : null;
708
+ return o(this, h).length === 1 ? this.first() : null;
713
709
  }
714
- some(...t) {
715
- return this.contains(...t);
710
+ some(...e) {
711
+ return this.contains(...e);
716
712
  }
717
- sort(t) {
718
- return c(o(this, u).toSorted(t));
713
+ sort(e) {
714
+ return l(o(this, h).toSorted(e));
719
715
  }
720
- sortBy(t, e = "asc") {
721
- if (typeof t == "function") {
722
- let s = -1;
723
- return c(o(this, u).toSorted((r, i) => (s++, t(r, s, this) - t(i, s, this))));
716
+ sortBy(e, t = "asc") {
717
+ if (typeof e == "function") {
718
+ let r = -1;
719
+ return l(o(this, h).toSorted((s, i) => (r++, e(s, r, this) - e(i, r, this))));
724
720
  }
725
- if (Array.isArray(t))
726
- return t.every((s) => Array.isArray(s)) ? c(o(this, u).toSorted((s, r) => {
727
- for (const [i, h] of t) {
728
- const l = s[i] ?? -1 / 0, a = r[i] ?? -1 / 0;
729
- if (l > a)
730
- return h === "asc" ? 1 : -1;
731
- if (l < a)
732
- return h === "asc" ? -1 : 1;
721
+ if (Array.isArray(e))
722
+ return e.every((r) => Array.isArray(r)) ? l(o(this, h).toSorted((r, s) => {
723
+ for (const [i, u] of e) {
724
+ const a = r[i] ?? -1 / 0, c = s[i] ?? -1 / 0;
725
+ if (a > c)
726
+ return u === "asc" ? 1 : -1;
727
+ if (a < c)
728
+ return u === "asc" ? -1 : 1;
733
729
  }
734
730
  return 0;
735
- })) : c(o(this, u).toSorted((s, r) => {
736
- for (const i of t) {
737
- const h = i(s, r);
738
- if (h !== 0)
739
- return h;
731
+ })) : l(o(this, h).toSorted((r, s) => {
732
+ for (const i of e) {
733
+ const u = i(r, s);
734
+ if (u !== 0)
735
+ return u;
740
736
  }
741
737
  return 0;
742
738
  }));
743
- if (typeof t != "string")
739
+ if (typeof e != "string")
744
740
  throw new TypeError("The key must be a string");
745
- return c(o(this, u).toSorted((s, r) => {
746
- const i = s[t] ?? -1 / 0, h = r[t] ?? -1 / 0;
747
- return i > h ? e === "asc" ? 1 : -1 : i < h ? e === "asc" ? -1 : 1 : 0;
741
+ return l(o(this, h).toSorted((r, s) => {
742
+ const i = r[e] ?? -1 / 0, u = s[e] ?? -1 / 0;
743
+ return i > u ? t === "asc" ? 1 : -1 : i < u ? t === "asc" ? -1 : 1 : 0;
748
744
  }));
749
745
  }
750
746
  sortDesc() {
751
- return this.sort((t, e) => t > e ? -1 : t < e ? 1 : 0);
752
- }
753
- splice(t, e, ...s) {
754
- const r = e === void 0 ? o(this, u).length : e, i = o(this, u).splice(t, r, ...s);
755
- return $(this), c(i);
756
- }
757
- split(t) {
758
- const e = [];
759
- for (let s = 0; s < t; s++) {
760
- const r = o(this, u).slice(
761
- e.flat().length,
762
- e.flat().length + Math.min(
763
- Math.ceil((o(this, u).length - e.flat().length) / (t - s)),
764
- o(this, u).length - e.flat().length
747
+ return this.sort((e, t) => e > t ? -1 : e < t ? 1 : 0);
748
+ }
749
+ splice(e, t, ...r) {
750
+ const s = t === void 0 ? o(this, h).length : t, i = o(this, h).splice(e, s, ...r);
751
+ return $(this), l(i);
752
+ }
753
+ split(e) {
754
+ const t = [];
755
+ for (let r = 0; r < e; r++) {
756
+ const s = o(this, h).slice(
757
+ t.flat().length,
758
+ t.flat().length + Math.min(
759
+ Math.ceil((o(this, h).length - t.flat().length) / (e - r)),
760
+ o(this, h).length - t.flat().length
765
761
  )
766
762
  );
767
- e.push(c(r));
763
+ t.push(l(s));
768
764
  }
769
- return c(e);
765
+ return l(t);
770
766
  }
771
- splitIn(t) {
772
- const e = Math.ceil(o(this, u).length / t);
773
- return this.chunk(e);
767
+ splitIn(e) {
768
+ const t = Math.ceil(o(this, h).length / e);
769
+ return this.chunk(t);
774
770
  }
775
- sum(t) {
776
- return typeof t == "string" ? o(this, u).reduce((e, s) => {
777
- const r = s[t];
778
- if (typeof r != "number")
779
- throw new TypeError("The items must be numbers");
780
- return e + r;
781
- }, 0) : o(this, u).reduce((e, s) => {
771
+ sum(e) {
772
+ return typeof e == "string" ? o(this, h).reduce((t, r) => {
773
+ const s = r[e];
782
774
  if (typeof s != "number")
783
775
  throw new TypeError("The items must be numbers");
784
- return e + s;
776
+ return t + s;
777
+ }, 0) : o(this, h).reduce((t, r) => {
778
+ if (typeof r != "number")
779
+ throw new TypeError("The items must be numbers");
780
+ return t + r;
785
781
  }, 0);
786
782
  }
787
- take(t) {
788
- return c(o(this, u).slice(0, t));
783
+ take(e) {
784
+ return l(o(this, h).slice(0, e));
789
785
  }
790
- takeUntil(t) {
791
- return typeof t == "function" ? this.take(o(this, u).findIndex((e, s) => t(e, s, this))) : this.take(o(this, u).findIndex((e) => e == t));
786
+ takeUntil(e) {
787
+ return typeof e == "function" ? this.take(o(this, h).findIndex((t, r) => e(t, r, this))) : this.take(o(this, h).findIndex((t) => t == e));
792
788
  }
793
- takeWhile(t) {
794
- return typeof t == "function" ? this.take(o(this, u).findIndex((e, s) => !t(e, s, this))) : this.take(o(this, u).findIndex((e) => e != t));
789
+ takeWhile(e) {
790
+ return typeof e == "function" ? this.take(o(this, h).findIndex((t, r) => !e(t, r, this))) : this.take(o(this, h).findIndex((t) => t != e));
795
791
  }
796
- tap(t) {
797
- return t(this), this;
792
+ tap(e) {
793
+ return e(this), this;
798
794
  }
799
795
  toArray() {
800
- const t = (e) => typeof e != "object" ? e : Array.isArray(e) ? e.map(t) : e && "toArray" in e && typeof e.toArray == "function" ? e.toArray() : e && "toJson" in e && typeof e.toJson == "function" ? e.toJson() : e;
801
- return o(this, u).map(t);
796
+ const e = (t) => typeof t != "object" ? t : Array.isArray(t) ? t.map(e) : t && "toArray" in t && typeof t.toArray == "function" ? t.toArray() : t && "toJson" in t && typeof t.toJson == "function" ? t.toJson() : t;
797
+ return o(this, h).map(e);
802
798
  }
803
799
  toJson() {
804
- return JSON.stringify(o(this, u));
800
+ return JSON.stringify(o(this, h));
805
801
  }
806
- transform(t) {
807
- for (const [e, s] of o(this, u).entries())
808
- o(this, u).splice(e, 1, t(s, e, this));
802
+ transform(e) {
803
+ for (const [t, r] of o(this, h).entries())
804
+ o(this, h).splice(t, 1, e(r, t, this));
809
805
  return $(this), this;
810
806
  }
811
- unique(t) {
812
- return c(typeof t == "string" ? o(this, u).filter((e, s) => !o(this, u).some((r, i) => r[t] == e[t] && i !== s)) : [...new Set(o(this, u))]);
807
+ unique(e) {
808
+ return l(typeof e == "string" ? o(this, h).filter((t, r) => !o(this, h).some((s, i) => s[e] == t[e] && i !== r)) : [...new Set(o(this, h))]);
813
809
  }
814
- uniqueStrict(t) {
815
- return c(typeof t == "string" ? o(this, u).filter((e, s) => !o(this, u).some((r, i) => r[t] === e[t] && i !== s)) : [...new Set(o(this, u))]);
810
+ uniqueStrict(e) {
811
+ return l(typeof e == "string" ? o(this, h).filter((t, r) => !o(this, h).some((s, i) => s[e] === t[e] && i !== r)) : [...new Set(o(this, h))]);
816
812
  }
817
- unless(t, e, s) {
818
- return t ? typeof s == "function" && s(this) : e(this), this;
813
+ unless(e, t, r) {
814
+ return e ? typeof r == "function" && r(this) : t(this), this;
819
815
  }
820
- unlessEmpty(t, e) {
821
- return this.whenNotEmpty(t, e);
816
+ unlessEmpty(e, t) {
817
+ return this.whenNotEmpty(e, t);
822
818
  }
823
- unlessNotEmpty(t, e) {
824
- return this.whenEmpty(t, e);
819
+ unlessNotEmpty(e, t) {
820
+ return this.whenEmpty(e, t);
825
821
  }
826
- value(t) {
827
- return o(this, u).length === 0 ? null : o(this, u)[0][t];
822
+ value(e) {
823
+ return o(this, h).length === 0 ? null : o(this, h)[0][e];
828
824
  }
829
- when(t, e, s) {
830
- return t ? e(this) : typeof s == "function" && s(this), this;
825
+ when(e, t, r) {
826
+ return e ? t(this) : typeof r == "function" && r(this), this;
831
827
  }
832
- whenEmpty(t, e) {
833
- return this.isEmpty() ? t(this) : typeof e == "function" && e(this), this;
828
+ whenEmpty(e, t) {
829
+ return this.isEmpty() ? e(this) : typeof t == "function" && t(this), this;
834
830
  }
835
- whenNotEmpty(t, e) {
836
- return this.isNotEmpty() ? t(this) : typeof e == "function" && e(this), this;
831
+ whenNotEmpty(e, t) {
832
+ return this.isNotEmpty() ? e(this) : typeof t == "function" && t(this), this;
837
833
  }
838
- where(t, e, s) {
839
- if (typeof s > "u")
840
- return c(o(this, u).filter((i) => i[t] == e));
841
- if (typeof e != "string")
834
+ where(e, t, r) {
835
+ if (typeof r > "u")
836
+ return l(o(this, h).filter((i) => i[e] == t));
837
+ if (typeof t != "string")
842
838
  throw new TypeError("The operator must be a string");
843
- if (s === null)
844
- return c(o(this, u).filter((i) => i[t] === null));
845
- const r = {
846
- "=": (i) => i[t] == s,
847
- "!=": (i) => i[t] != s,
848
- ">": (i) => i[t] > s,
849
- "<": (i) => i[t] < s,
850
- ">=": (i) => i[t] >= s,
851
- "<=": (i) => i[t] <= s
839
+ if (r === null)
840
+ return l(o(this, h).filter((i) => i[e] === null));
841
+ const s = {
842
+ "=": (i) => i[e] == r,
843
+ "!=": (i) => i[e] != r,
844
+ ">": (i) => i[e] > r,
845
+ "<": (i) => i[e] < r,
846
+ ">=": (i) => i[e] >= r,
847
+ "<=": (i) => i[e] <= r
852
848
  };
853
- if (!(e in r))
849
+ if (!(t in s))
854
850
  throw new Error("Unsupported operator");
855
- return c(o(this, u).filter((i, h) => r[e](i, h, this)));
851
+ return l(o(this, h).filter((i, u) => s[t](i, u, this)));
856
852
  }
857
- whereStrict(t, e, s) {
858
- if (typeof s > "u")
859
- return c(o(this, u).filter((i) => i[t] === e));
860
- if (typeof e != "string")
853
+ whereStrict(e, t, r) {
854
+ if (typeof r > "u")
855
+ return l(o(this, h).filter((i) => i[e] === t));
856
+ if (typeof t != "string")
861
857
  throw new TypeError("The operator must be a string");
862
- if (s === null)
863
- return c(o(this, u).filter((i) => i[t] === null));
864
- const r = {
865
- "=": (i) => i[t] === s,
866
- "!=": (i) => i[t] !== s,
867
- ">": (i) => i[t] > s,
868
- "<": (i) => i[t] < s,
869
- ">=": (i) => i[t] >= s,
870
- "<=": (i) => i[t] <= s
858
+ if (r === null)
859
+ return l(o(this, h).filter((i) => i[e] === null));
860
+ const s = {
861
+ "=": (i) => i[e] === r,
862
+ "!=": (i) => i[e] !== r,
863
+ ">": (i) => i[e] > r,
864
+ "<": (i) => i[e] < r,
865
+ ">=": (i) => i[e] >= r,
866
+ "<=": (i) => i[e] <= r
871
867
  };
872
- if (!(e in r))
868
+ if (!(t in s))
873
869
  throw new Error("Unsupported operator");
874
- return c(o(this, u).filter((i, h) => r[e](i, h, this)));
870
+ return l(o(this, h).filter((i, u) => s[t](i, u, this)));
875
871
  }
876
- whereBetween(t, [e, s]) {
877
- return c(o(this, u).filter((r) => r[t] >= e && r[t] <= s));
872
+ whereBetween(e, [t, r]) {
873
+ return l(o(this, h).filter((s) => s[e] >= t && s[e] <= r));
878
874
  }
879
- whereIn(t, e) {
880
- return c(o(this, u).filter((s) => e.includes(s[t])));
875
+ whereIn(e, t) {
876
+ return l(o(this, h).filter((r) => t.includes(r[e])));
881
877
  }
882
- whereInstanceOf(t) {
883
- return c(o(this, u).filter((e) => e instanceof t));
878
+ whereInstanceOf(e) {
879
+ return l(o(this, h).filter((t) => t instanceof e));
884
880
  }
885
- whereNotBetween(t, [e, s]) {
886
- return c(o(this, u).filter((r) => r[t] < e || r[t] > s));
881
+ whereNotBetween(e, [t, r]) {
882
+ return l(o(this, h).filter((s) => s[e] < t || s[e] > r));
887
883
  }
888
- whereNotIn(t, e) {
889
- return c(o(this, u).filter((s) => !e.includes(s[t])));
884
+ whereNotIn(e, t) {
885
+ return l(o(this, h).filter((r) => !t.includes(r[e])));
890
886
  }
891
- whereNotNull(t) {
892
- return c(o(this, u).filter((e) => e[t] !== null));
887
+ whereNotNull(e) {
888
+ return l(o(this, h).filter((t) => t[e] !== null));
893
889
  }
894
- whereNull(t) {
895
- return c(o(this, u).filter((e) => e[t] === null));
890
+ whereNull(e) {
891
+ return l(o(this, h).filter((t) => t[e] === null));
896
892
  }
897
- zip(t) {
898
- return Array.isArray(t) ? c(
899
- o(this, u).map((e, s) => [e, t[s] ?? null])
900
- ) : c(
901
- o(this, u).map((e, s) => [e, t.get(s)])
893
+ zip(e) {
894
+ return Array.isArray(e) ? l(
895
+ o(this, h).map((t, r) => [t, e[r] ?? null])
896
+ ) : l(
897
+ o(this, h).map((t, r) => [t, e.get(r)])
902
898
  );
903
899
  }
904
900
  // HasEvents methods
905
901
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
906
- on(t, e) {
902
+ on(e, t) {
907
903
  throw new y();
908
904
  }
909
905
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
910
- once(t, e) {
906
+ once(e, t) {
911
907
  throw new y();
912
908
  }
913
909
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
914
- emit(t, e) {
910
+ emit(e, t) {
915
911
  throw new y();
916
912
  }
917
913
  }
918
- Ft = Symbol.toStringTag, u = new WeakMap(), p(j, "name", "Collection");
919
- const J = A(j);
920
- class L extends j {
921
- intersect(t) {
922
- return this.filter((e) => t.some((s) => s.getKey() === e.getKey()));
914
+ h = new WeakMap();
915
+ const J = A(L);
916
+ class Q extends L {
917
+ intersect(e) {
918
+ return this.filter((t) => e.some((r) => r.getKey() === t.getKey()));
923
919
  }
924
920
  }
925
- p(L, "name", "Collection");
921
+ p(Q, "name", "Collection");
926
922
  const S = (...n) => {
927
- const t = new URLSearchParams();
928
- return n.forEach((e) => {
929
- const [, ...s] = e.split("?");
930
- new URLSearchParams(s.join("")).forEach((i, h) => {
931
- t.set(h, i);
923
+ const e = new URLSearchParams();
924
+ return n.forEach((t) => {
925
+ const [, ...r] = t.split("?");
926
+ new URLSearchParams(r.join("")).forEach((i, u) => {
927
+ e.set(u, i);
932
928
  });
933
- }), t;
929
+ }), e;
934
930
  };
935
- class z extends Error {
936
- constructor(t) {
937
- super(`[Luminix] Model "${t}" does not have a primary key`);
931
+ class ee extends Error {
932
+ constructor(e) {
933
+ super(`[Luminix] Model "${e}" does not have a primary key`);
938
934
  }
939
935
  }
940
- p(z, "name", "ModelWithoutPrimaryKeyException");
941
- const wt = A(v);
942
- class bt {
943
- constructor(t, e, s = {}) {
936
+ p(ee, "name", "ModelWithoutPrimaryKeyException");
937
+ const xe = A(v);
938
+ class _e {
939
+ constructor(e, t, r = {}) {
944
940
  p(this, "bag");
945
- this.facades = t, this.abstract = e, this.query = s, this.bag = new wt(s), this.bag.on("change", () => {
941
+ this.facades = e, this.abstract = t, this.query = r, this.bag = new xe(r), this.bag.on("change", () => {
946
942
  this.emit("change", {
947
943
  data: this.bag
948
944
  });
949
945
  });
950
946
  }
951
947
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
952
- on(t, e) {
948
+ on(e, t) {
953
949
  throw new y();
954
950
  }
955
951
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
956
- once(t, e) {
952
+ once(e, t) {
957
953
  throw new y();
958
954
  }
959
955
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
960
- emit(t, e) {
956
+ emit(e, t) {
961
957
  throw new y();
962
958
  }
963
- lock(t) {
964
- this.bag.lock(t);
959
+ lock(e) {
960
+ this.bag.lock(e);
965
961
  }
966
- whereBetween(t, e) {
967
- return this.bag.has("filters") || this.bag.set("filters", {}), this.bag.set(`filters.${f.camelCase(t)}Between`, e), this;
962
+ whereBetween(e, t) {
963
+ return this.bag.has("where") || this.bag.set("where", {}), this.bag.set(`where.${f.camelCase(e)}Between`, t), this;
968
964
  }
969
- whereNotBetween(t, e) {
970
- return this.bag.has("filters") || this.bag.set("filters", {}), this.bag.set(`filters.${f.camelCase(t)}NotBetween`, e), this;
965
+ whereNotBetween(e, t) {
966
+ return this.bag.has("where") || this.bag.set("where", {}), this.bag.set(`where.${f.camelCase(e)}NotBetween`, t), this;
971
967
  }
972
- whereNull(t) {
973
- return this.bag.has("filters") || this.bag.set("filters", {}), this.bag.set(`filters.${f.camelCase(t)}Null`, !0), this;
968
+ whereNull(e) {
969
+ return this.bag.has("where") || this.bag.set("where", {}), this.bag.set(`where.${f.camelCase(e)}Null`, !0), this;
974
970
  }
975
- whereNotNull(t) {
976
- return this.bag.has("filters") || this.bag.set("filters", {}), this.bag.set(`filters.${f.camelCase(t)}NotNull`, !0), this;
971
+ whereNotNull(e) {
972
+ return this.bag.has("where") || this.bag.set("where", {}), this.bag.set(`where.${f.camelCase(e)}NotNull`, !0), this;
977
973
  }
978
- limit(t) {
979
- return this.bag.set("per_page", t), this;
974
+ limit(e) {
975
+ return this.bag.set("per_page", e), this;
980
976
  }
981
- where(t, e, s) {
982
- if (this.bag.has("filters") || this.bag.set("filters", {}), typeof t == "function")
983
- return t(this) || this;
984
- if (typeof s > "u")
985
- return this.bag.set(`filters.${f.camelCase(t)}`, e), this;
986
- if (typeof e != "string")
987
- throw new Error(`Invalid operator ${e} provided for where clause.`);
977
+ where(e, t, r) {
978
+ if (this.bag.has("where") || this.bag.set("where", {}), typeof e == "function")
979
+ return e(this) || this;
980
+ if (typeof r > "u")
981
+ return this.bag.set(`where.${f.camelCase(e)}`, t), this;
982
+ if (typeof t != "string")
983
+ throw new Error(`Invalid operator ${t} provided for where clause.`);
988
984
  const i = {
989
985
  "=": "",
990
986
  "!=": "NotEquals",
@@ -992,165 +988,165 @@ class bt {
992
988
  ">=": "GreaterThanOrEquals",
993
989
  "<": "LessThan",
994
990
  "<=": "LessThanOrEquals"
995
- }[e] || f.upperFirst(f.camelCase(e));
996
- return this.bag.set(`filters.${f.camelCase(t)}${i}`, s), this;
991
+ }[t] || f.upperFirst(f.camelCase(t));
992
+ return this.bag.set(`where.${f.camelCase(e)}${i}`, r), this;
997
993
  }
998
- orderBy(t, e = "asc") {
999
- return this.bag.set("order_by", `${t}:${e}`), this;
994
+ orderBy(e, t = "asc") {
995
+ return this.bag.set("order_by", `${e}:${t}`), this;
1000
996
  }
1001
- searchBy(t) {
1002
- return this.bag.set("q", t), this;
997
+ searchBy(e) {
998
+ return this.bag.set("q", e), this;
1003
999
  }
1004
1000
  minified() {
1005
1001
  return this.bag.set("minified", !0), this;
1006
1002
  }
1007
- unset(t) {
1008
- return this.bag.delete(t), this;
1003
+ unset(e) {
1004
+ return this.bag.delete(e), this;
1009
1005
  }
1010
- async exec(t = 1, e) {
1006
+ async exec(e = 1, t) {
1011
1007
  try {
1012
- this.bag.set("page", t), this.emit("submit", {
1008
+ this.bag.set("page", e), this.emit("submit", {
1013
1009
  data: this.bag
1014
1010
  });
1015
- const { data: s } = await this.facades.route.call(`luminix.${this.abstract}.index`, {
1011
+ const { data: r } = await this.facades.route.call(`luminix.${this.abstract}.index`, {
1016
1012
  params: this.bag.all(),
1017
1013
  errorBag: `${this.abstract}.fetch`
1018
- }), r = this.facades.model.make(this.abstract), i = c(s.data.map((h) => {
1019
- const l = new r(h);
1020
- return l.exists = !0, this.facades.model.emit("fetch", {
1014
+ }), s = this.facades.model.make(this.abstract), i = l(r.data.map((u) => {
1015
+ const a = new s(u);
1016
+ return a.exists = !0, this.facades.model.emit("fetch", {
1021
1017
  class: this.abstract,
1022
- model: l
1023
- }), l;
1024
- }), L);
1025
- if (e) {
1026
- const [h] = e.split("?");
1018
+ model: a
1019
+ }), a;
1020
+ }), Q);
1021
+ if (t) {
1022
+ const [u] = t.split("?");
1027
1023
  return {
1028
- ...s,
1024
+ ...r,
1029
1025
  data: i,
1030
1026
  links: {
1031
- first: `${h}?${S(e, s.links.first).toString()}`,
1032
- last: `${h}?${S(e, s.links.last).toString()}`,
1033
- next: s.links.next && `${h}?${S(e, s.links.next).toString()}`,
1034
- prev: s.links.prev && `${h}?${S(e, s.links.prev).toString()}`
1027
+ first: `${u}?${S(t, r.links.first).toString()}`,
1028
+ last: `${u}?${S(t, r.links.last).toString()}`,
1029
+ next: r.links.next && `${u}?${S(t, r.links.next).toString()}`,
1030
+ prev: r.links.prev && `${u}?${S(t, r.links.prev).toString()}`
1035
1031
  },
1036
1032
  meta: {
1037
- ...s.meta,
1038
- links: s.meta.links.map((l) => ({
1039
- ...l,
1040
- url: l.url && `${h}?${S(e, l.url).toString()}`
1033
+ ...r.meta,
1034
+ links: r.meta.links.map((a) => ({
1035
+ ...a,
1036
+ url: a.url && `${u}?${S(t, a.url).toString()}`
1041
1037
  }))
1042
1038
  }
1043
1039
  };
1044
1040
  }
1045
1041
  return {
1046
- ...s,
1042
+ ...r,
1047
1043
  data: i
1048
1044
  };
1049
- } catch (s) {
1045
+ } catch (r) {
1050
1046
  throw this.emit("error", {
1051
- error: s
1052
- }), s;
1047
+ error: r
1048
+ }), r;
1053
1049
  }
1054
1050
  }
1055
- async get(t = 1, e) {
1056
- const s = await this.exec(t, e);
1051
+ async get(e = 1, t) {
1052
+ const r = await this.exec(e, t);
1057
1053
  return this.emit("success", {
1058
- response: s,
1059
- items: s.data
1060
- }), s;
1054
+ response: r,
1055
+ items: r.data
1056
+ }), r;
1061
1057
  }
1062
1058
  async first() {
1063
- const t = await this.limit(1).exec(1);
1059
+ const e = await this.limit(1).exec(1);
1064
1060
  return this.emit("success", {
1065
- response: t,
1066
- items: t.data.first()
1067
- }), t.data.first();
1061
+ response: e,
1062
+ items: e.data.first()
1063
+ }), e.data.first();
1068
1064
  }
1069
- async find(t) {
1070
- const e = this.facades.model.schema(this.abstract).primaryKey;
1071
- if (!e)
1072
- throw new z(this.abstract);
1073
- const s = await this.where(e, t).limit(1).exec(1);
1065
+ async find(e) {
1066
+ const t = this.facades.model.schema(this.abstract).primaryKey;
1067
+ if (!t)
1068
+ throw new ee(this.abstract);
1069
+ const r = await this.where(t, e).limit(1).exec(1);
1074
1070
  return this.emit("success", {
1075
- response: s,
1076
- items: s.data.sole()
1077
- }), s.data.sole();
1071
+ response: r,
1072
+ items: r.data.sole()
1073
+ }), r.data.sole();
1078
1074
  }
1079
1075
  async all() {
1080
- const t = this.facades.config.get("luminix.backend.api.max_per_page", 150), e = await this.limit(t).exec(1), s = e.meta.last_page;
1081
- if (s === 1)
1082
- return e.data;
1083
- const r = Array.from({ length: s - 1 }, (l, a) => a + 2), i = await Promise.all(
1084
- r.map((l) => this.limit(t).exec(l))
1085
- ), h = c(
1086
- i.reduce((l, a) => (l.push(...a.data), l), e.data).all(),
1087
- L
1076
+ const e = this.facades.config.get("luminix.backend.api.max_per_page", 150), t = await this.limit(e).exec(1), r = t.meta.last_page;
1077
+ if (r === 1)
1078
+ return t.data;
1079
+ const s = Array.from({ length: r - 1 }, (a, c) => c + 2), i = await Promise.all(
1080
+ s.map((a) => this.limit(e).exec(a))
1081
+ ), u = l(
1082
+ i.reduce((a, c) => (a.push(...c.data), a), t.data).all(),
1083
+ Q
1088
1084
  );
1089
1085
  return this.emit("success", {
1090
1086
  response: {
1091
- ...e,
1092
- data: h
1087
+ ...t,
1088
+ data: u
1093
1089
  },
1094
- items: h
1095
- }), h;
1090
+ items: u
1091
+ }), u;
1096
1092
  }
1097
1093
  }
1098
- const Et = A(bt);
1099
- class _ extends Error {
1100
- constructor(t) {
1101
- super(`[Luminix] Expected ${t} to be reducible.`);
1094
+ const Me = A(_e);
1095
+ class M extends Error {
1096
+ constructor(e) {
1097
+ super(`[Luminix] Expected ${e} to be reducible.`);
1102
1098
  }
1103
1099
  }
1104
- p(_, "name", "NotReducibleException");
1100
+ p(M, "name", "NotReducibleException");
1105
1101
  class E extends TypeError {
1106
- constructor(t, e = "Model") {
1107
- super(`[Luminix] "${t}" expects ${e}`);
1102
+ constructor(e, t = "Model") {
1103
+ super(`[Luminix] "${e}" expects ${t}`);
1108
1104
  }
1109
1105
  }
1110
1106
  p(E, "name", "NotModelException");
1111
- class O extends Error {
1112
- constructor(t, e, s, r) {
1113
- super(`[Luminix] Could not determine inverse relation for "${e}" in model "${t}". Please specify a relation in model "${s}" of type ${r} that points back to "${t}".`);
1107
+ class te extends Error {
1108
+ constructor(e, t, r, s) {
1109
+ super(`[Luminix] Could not determine inverse relation for "${t}" in model "${e}". Please specify a relation in model "${r}" of type ${s} that points back to "${e}".`);
1114
1110
  }
1115
1111
  }
1116
- p(O, "name", "NoInverseRelationException");
1117
- class k extends Error {
1118
- constructor(t) {
1119
- super(`[Luminix] Relation "${t}" is not supported`);
1112
+ p(te, "name", "NoInverseRelationException");
1113
+ class re extends Error {
1114
+ constructor(e) {
1115
+ super(`[Luminix] Relation "${e}" is not supported`);
1120
1116
  }
1121
1117
  }
1122
- p(k, "name", "UnsupportedRelationException");
1118
+ p(re, "name", "UnsupportedRelationException");
1123
1119
  function w(n) {
1124
1120
  return typeof n == "object" && n !== null && n.__isModel === !0;
1125
1121
  }
1126
- class F {
1127
- constructor(t, e, s, r = null) {
1122
+ class j {
1123
+ constructor(e, t, r, s = null) {
1128
1124
  p(this, "unsubscribeQuery", null);
1129
- if (this.meta = t, this.facades = e, this.parent = s, this.items = r, r !== null && !w(r) && !(T(r) && r.every(w)))
1125
+ if (this.meta = e, this.facades = t, this.parent = r, this.items = s, s !== null && !w(s) && !(T(s) && s.every(w)))
1130
1126
  throw new E("Relation.constructor()", "Model, Collection<Model> or null");
1131
1127
  }
1132
- make(t) {
1133
- const e = this.getRelated();
1134
- if (t === null || typeof t > "u") {
1128
+ make(e) {
1129
+ const t = this.getRelated();
1130
+ if (e === null || typeof e > "u") {
1135
1131
  this.set(null);
1136
1132
  return;
1137
1133
  }
1138
1134
  if (this.isSingle()) {
1139
- if (typeof t != "object" || Array.isArray(t))
1135
+ if (typeof e != "object" || Array.isArray(e))
1140
1136
  throw new TypeError("Relation.make() expects an object");
1141
- this.set(new e(t));
1137
+ this.set(new t(e));
1142
1138
  }
1143
1139
  if (this.isMultiple()) {
1144
- if (!Array.isArray(t))
1140
+ if (!Array.isArray(e))
1145
1141
  throw new TypeError("Relation.make() expects an array");
1146
- this.set(c(t.map((s) => new e(s))));
1142
+ this.set(l(e.map((r) => new t(r))));
1147
1143
  }
1148
1144
  }
1149
1145
  guessInverseRelation() {
1150
- const { relations: t } = this.getRelated().getSchema();
1146
+ const { relations: e } = this.getRelated().getSchema();
1151
1147
  if (typeof this.facades.model.guessInverseRelation != "function")
1152
- throw new _("ModelFacade");
1153
- const e = this.getType(), s = this.facades.model.guessInverseRelation({
1148
+ throw new M("ModelFacade");
1149
+ const t = this.getType(), r = this.facades.model.guessInverseRelation({
1154
1150
  HasOne: ["BelongsTo"],
1155
1151
  HasMany: ["BelongsTo"],
1156
1152
  BelongsTo: ["HasOne", "HasMany"],
@@ -1159,20 +1155,20 @@ class F {
1159
1155
  MorphOne: ["MorphTo"],
1160
1156
  MorphMany: ["MorphTo"],
1161
1157
  MorphToMany: ["MorphToMany"]
1162
- }, this.parent, e, this.getRelated());
1163
- if (!(e in s))
1164
- throw new k(e);
1165
- for (const r in t) {
1166
- const i = t[r];
1167
- if ((i.model === this.parent.getType() || ["MorphOne", "MorphMany"].includes(e)) && s[e].includes(i.type))
1168
- return r;
1169
- }
1170
- throw new O(this.parent.getType(), e, this.getRelated().getSchemaName(), s[e].join(" or "));
1171
- }
1172
- set(t) {
1173
- if (t !== null && !w(t) && !(T(t) && t.every(w)))
1158
+ }, this.parent, t, this.getRelated());
1159
+ if (!(t in r))
1160
+ throw new re(t);
1161
+ for (const s in e) {
1162
+ const i = e[s];
1163
+ if ((i.model === this.parent.getType() || ["MorphOne", "MorphMany"].includes(t)) && r[t].includes(i.type))
1164
+ return s;
1165
+ }
1166
+ throw new te(this.parent.getType(), t, this.getRelated().getSchemaName(), r[t].join(" or "));
1167
+ }
1168
+ set(e) {
1169
+ if (e !== null && !w(e) && !(T(e) && e.every(w)))
1174
1170
  throw new E("Relation.set()", "Model, Collection<Model> or null");
1175
- !this.items || w(this.items) ? this.items = t : T(t) && this.items.splice(0, this.items.count(), ...t);
1171
+ !this.items || w(this.items) ? this.items = e : T(e) && this.items.splice(0, this.items.count(), ...e);
1176
1172
  }
1177
1173
  getForeignKey() {
1178
1174
  return this.meta.foreignKey;
@@ -1190,10 +1186,10 @@ class F {
1190
1186
  return this.facades.model.make(this.meta.model);
1191
1187
  }
1192
1188
  query() {
1193
- const t = this.getRelated().query();
1194
- return this.unsubscribeQuery && this.unsubscribeQuery(), this.unsubscribeQuery = t.on("success", (e) => {
1195
- this.items = e.items;
1196
- }), t;
1189
+ const e = this.getRelated().query();
1190
+ return this.unsubscribeQuery && this.unsubscribeQuery(), this.unsubscribeQuery = e.on("success", (t) => {
1191
+ this.items = t.items;
1192
+ }), e;
1197
1193
  }
1198
1194
  isLoaded() {
1199
1195
  return this.items !== null;
@@ -1210,32 +1206,32 @@ class F {
1210
1206
  getParent() {
1211
1207
  return this.parent;
1212
1208
  }
1213
- where(...t) {
1214
- return this.query().where(...t);
1209
+ where(...e) {
1210
+ return this.query().where(...e);
1215
1211
  }
1216
- whereNull(t) {
1217
- return this.query().whereNull(t);
1212
+ whereNull(e) {
1213
+ return this.query().whereNull(e);
1218
1214
  }
1219
- whereNotNull(t) {
1220
- return this.query().whereNotNull(t);
1215
+ whereNotNull(e) {
1216
+ return this.query().whereNotNull(e);
1221
1217
  }
1222
- whereBetween(t, e) {
1223
- return this.query().whereBetween(t, e);
1218
+ whereBetween(e, t) {
1219
+ return this.query().whereBetween(e, t);
1224
1220
  }
1225
- whereNotBetween(t, e) {
1226
- return this.query().whereNotBetween(t, e);
1221
+ whereNotBetween(e, t) {
1222
+ return this.query().whereNotBetween(e, t);
1227
1223
  }
1228
- orderBy(t, e = "asc") {
1229
- return this.query().orderBy(t, e);
1224
+ orderBy(e, t = "asc") {
1225
+ return this.query().orderBy(e, t);
1230
1226
  }
1231
- searchBy(t) {
1232
- return this.query().searchBy(t);
1227
+ searchBy(e) {
1228
+ return this.query().searchBy(e);
1233
1229
  }
1234
1230
  minified() {
1235
1231
  return this.query().minified();
1236
1232
  }
1237
- limit(t) {
1238
- return this.query().limit(t);
1233
+ limit(e) {
1234
+ return this.query().limit(e);
1239
1235
  }
1240
1236
  // get(page = 1, perPage = 15, replaceLinksWith?: string): Promise<ModelPaginatedResponse>
1241
1237
  // {
@@ -1251,90 +1247,90 @@ class F {
1251
1247
  // }
1252
1248
  }
1253
1249
  class U extends Error {
1254
- constructor(t, e) {
1255
- super(`[Luminix] Attribute "${e}" in model "${t}" is not fillable`);
1250
+ constructor(e, t) {
1251
+ super(`[Luminix] Attribute "${t}" in model "${e}" is not fillable`);
1256
1252
  }
1257
1253
  }
1258
1254
  p(U, "name", "AttributeNotFillableException");
1259
1255
  class D extends Error {
1260
- constructor(t, e) {
1261
- super(`[Luminix] Model "${t}" must be persisted before calling "${e}"`);
1256
+ constructor(e, t) {
1257
+ super(`[Luminix] Model "${e}" must be persisted before calling "${t}"`);
1262
1258
  }
1263
1259
  }
1264
1260
  p(D, "name", "ModelNotPersistedException");
1265
- function xt(n, t) {
1266
- class e {
1267
- constructor(r = {}) {
1261
+ function $e(n, e) {
1262
+ class t {
1263
+ constructor(s = {}) {
1268
1264
  p(this, "_attributes", new v({}));
1269
1265
  p(this, "_original", {});
1270
1266
  p(this, "_relations", {});
1271
1267
  p(this, "_changedKeys", []);
1272
1268
  p(this, "exists", !1);
1273
- this.makeRelations(), this.makeAttributes(r);
1269
+ this.makeRelations(), this.makeAttributes(s);
1274
1270
  }
1275
- cast(r, i) {
1276
- return r == null || !i ? r : ["boolean", "bool"].includes(i) ? !!r : ["date", "datetime", "immutable_date", "immutable_datetime"].includes(i) && typeof r == "string" ? new Date(r) : ["float", "double", "integer", "int"].includes(i) || i.startsWith("decimal:") ? Number(r) : r;
1271
+ cast(s, i) {
1272
+ return s == null || !i ? s : ["boolean", "bool"].includes(i) ? !!s : ["date", "datetime", "immutable_date", "immutable_datetime"].includes(i) && typeof s == "string" ? new Date(s) : ["float", "double", "integer", "int"].includes(i) || i.startsWith("decimal:") ? Number(s) : s;
1277
1273
  }
1278
- mutate(r, i) {
1279
- return r == null || !i ? r : ["boolean", "bool"].includes(i) ? !!r : ["date", "datetime", "immutable_date", "immutable_datetime"].includes(i) && r instanceof Date ? r.toISOString() : ["float", "double", "integer", "int"].includes(i) || i.startsWith("decimal:") ? Number(r) : r;
1274
+ mutate(s, i) {
1275
+ return s == null || !i ? s : ["boolean", "bool"].includes(i) ? !!s : ["date", "datetime", "immutable_date", "immutable_datetime"].includes(i) && s instanceof Date ? s.toISOString() : ["float", "double", "integer", "int"].includes(i) || i.startsWith("decimal:") ? Number(s) : s;
1280
1276
  }
1281
1277
  makeRelations() {
1282
- const { relations: r } = n.model.schema(t);
1283
- if (this._relations = {}, !r)
1278
+ const { relations: s } = n.model.schema(e);
1279
+ if (this._relations = {}, !s)
1284
1280
  return;
1285
1281
  if (typeof n.model.relationMap != "function")
1286
- throw new _("ModelFacade");
1287
- const i = n.model.relationMap({}, t);
1288
- Object.entries(r).forEach(([h, l]) => {
1289
- const { type: a } = l, d = a in i ? i[a] : F;
1290
- this._relations[h] = new d(
1291
- { name: h, ...l },
1282
+ throw new M("ModelFacade");
1283
+ const i = n.model.relationMap({}, e);
1284
+ Object.entries(s).forEach(([u, a]) => {
1285
+ const { type: c } = a, d = c in i ? i[c] : j;
1286
+ this._relations[u] = new d(
1287
+ { name: u, ...a },
1292
1288
  n,
1293
1289
  this,
1294
1290
  null
1295
1291
  );
1296
1292
  });
1297
1293
  }
1298
- makeAttributes(r) {
1299
- const { relations: i } = n.model.schema(t), h = Object.keys(i || {}), l = f.omit(r, h);
1300
- if (this.fillable.filter((a) => !(a in l)).forEach((a) => {
1301
- l[a] = null;
1302
- }), i && Object.keys(i).forEach((a) => {
1303
- this.relation(f.camelCase(a)).make(r[a]);
1304
- }), !this.validateJsonObject(l)) {
1294
+ makeAttributes(s) {
1295
+ const { relations: i } = n.model.schema(e), u = Object.keys(i || {}), a = f.omit(s, u);
1296
+ if (this.fillable.filter((c) => !(c in a)).forEach((c) => {
1297
+ a[c] = null;
1298
+ }), i && Object.keys(i).forEach((c) => {
1299
+ this.relation(f.camelCase(c)).make(s[c]);
1300
+ }), !this.validateJsonObject(a)) {
1305
1301
  if (n.config.get("app.env", "production") === "production")
1306
- throw new TypeError(`[Luminix] Invalid attributes for model "${t}"`);
1307
- n.log.warning(`Invalid attributes for model "${t}".
1302
+ throw new TypeError(`[Luminix] Invalid attributes for model "${e}"`);
1303
+ n.log.warning(`Invalid attributes for model "${e}".
1308
1304
  This will throw an error in production.`, {
1309
- attributes: r,
1310
- abstract: t
1305
+ attributes: s,
1306
+ abstract: e
1311
1307
  });
1312
1308
  }
1313
- this._attributes = new v(l), this._original = l, this._changedKeys = [];
1309
+ this._attributes = new v(a), this._original = a, this._changedKeys = [];
1314
1310
  }
1315
1311
  makePrimaryKeyReplacer() {
1316
1312
  return {
1317
1313
  [this.primaryKey]: this.getAttribute(this.primaryKey)
1318
1314
  };
1319
1315
  }
1320
- dispatchChangeEvent(r) {
1316
+ dispatchChangeEvent(s) {
1321
1317
  this.emit("change", {
1322
- value: r
1318
+ value: s
1323
1319
  });
1324
1320
  }
1325
- dispatchCreateEvent(r) {
1321
+ dispatchCreateEvent(s) {
1326
1322
  this.emit("create", {
1327
- value: r
1323
+ value: s
1328
1324
  }), n.model.emit("create", {
1329
- class: t,
1325
+ class: e,
1330
1326
  model: this
1331
1327
  });
1332
1328
  }
1333
- dispatchUpdateEvent(r) {
1329
+ dispatchUpdateEvent(s) {
1334
1330
  this.emit("update", {
1335
- value: r
1331
+ value: s
1336
1332
  }), n.model.emit("update", {
1337
- class: t,
1333
+ class: e,
1338
1334
  model: this
1339
1335
  });
1340
1336
  }
@@ -1342,45 +1338,45 @@ function xt(n, t) {
1342
1338
  this.emit("save", {
1343
1339
  value: this.diff()
1344
1340
  }), n.model.emit("save", {
1345
- class: t,
1341
+ class: e,
1346
1342
  model: this
1347
1343
  });
1348
1344
  }
1349
- dispatchDeleteEvent(r = !1) {
1345
+ dispatchDeleteEvent(s = !1) {
1350
1346
  this.emit("delete", {
1351
- force: r,
1347
+ force: s,
1352
1348
  [this.getKeyName()]: this.getKey()
1353
1349
  }), n.model.emit("delete", {
1354
- class: t,
1350
+ class: e,
1355
1351
  model: this,
1356
- force: r
1352
+ force: s
1357
1353
  });
1358
1354
  }
1359
1355
  dispatchRestoreEvent() {
1360
1356
  this.emit("restore", {
1361
1357
  value: this.attributes
1362
1358
  }), n.model.emit("restore", {
1363
- class: t,
1359
+ class: e,
1364
1360
  model: this
1365
1361
  });
1366
1362
  }
1367
- dispatchErrorEvent(r, i) {
1363
+ dispatchErrorEvent(s, i) {
1368
1364
  this.emit("error", {
1369
- error: r,
1365
+ error: s,
1370
1366
  operation: i
1371
1367
  }), n.model.emit("error", {
1372
- class: t,
1368
+ class: e,
1373
1369
  model: this,
1374
- error: r,
1370
+ error: s,
1375
1371
  operation: i
1376
1372
  });
1377
1373
  }
1378
- updateChangedKeys(r) {
1379
- const i = (h, l) => typeof h == "object" && h !== null ? f.isEqual(h, l) : h == l;
1380
- !this._changedKeys.includes(r) && !i(this._original[r], this._attributes.get("key")) ? this._changedKeys.push(r) : this._changedKeys.includes(r) && i(this._original[r], this._attributes.get("key")) && this._changedKeys.splice(this._changedKeys.indexOf(r), 1);
1374
+ updateChangedKeys(s) {
1375
+ const i = (u, a) => typeof u == "object" && u !== null ? f.isEqual(u, a) : u == a;
1376
+ !this._changedKeys.includes(s) && !i(this._original[s], this._attributes.get("key")) ? this._changedKeys.push(s) : this._changedKeys.includes(s) && i(this._original[s], this._attributes.get("key")) && this._changedKeys.splice(this._changedKeys.indexOf(s), 1);
1381
1377
  }
1382
- validateJsonObject(r) {
1383
- return typeof r != "object" || r === null ? !1 : Object.entries(r).every(([, i]) => ["boolean", "number", "string"].includes(typeof i) || i === null || this.validateJsonObject(i) || Array.isArray(i) && i.every((h) => this.validateJsonObject(h)));
1378
+ validateJsonObject(s) {
1379
+ return typeof s != "object" || s === null ? !1 : Object.entries(s).every(([, i]) => ["boolean", "number", "string"].includes(typeof i) || i === null || this.validateJsonObject(i) || Array.isArray(i) && i.every((u) => this.validateJsonObject(u)));
1384
1380
  }
1385
1381
  get attributes() {
1386
1382
  return this._attributes.all();
@@ -1392,20 +1388,20 @@ function xt(n, t) {
1392
1388
  return this._relations;
1393
1389
  }
1394
1390
  get fillable() {
1395
- return n.model.schema(t).fillable;
1391
+ return n.model.schema(e).fillable;
1396
1392
  }
1397
1393
  get primaryKey() {
1398
- return n.model.schema(t).primaryKey;
1394
+ return n.model.schema(e).primaryKey;
1399
1395
  }
1400
1396
  get timestamps() {
1401
- return n.model.schema(t).timestamps;
1397
+ return n.model.schema(e).timestamps;
1402
1398
  }
1403
1399
  // get softDeletes() {
1404
1400
  // return facades.model.schema(abstract).softDeletes;
1405
1401
  // }
1406
1402
  get casts() {
1407
1403
  return {
1408
- ...n.model.schema(t).casts,
1404
+ ...n.model.schema(e).casts,
1409
1405
  ...this.timestamps ? { created_at: "datetime", updated_at: "datetime" } : {}
1410
1406
  // ...this.softDeletes ? { deleted_at: 'datetime' } : {},
1411
1407
  };
@@ -1413,43 +1409,43 @@ function xt(n, t) {
1413
1409
  get isDirty() {
1414
1410
  return this._changedKeys.length > 0;
1415
1411
  }
1416
- getAttribute(r) {
1417
- let i = this._attributes.get(r, null);
1418
- r in this.casts && (i = this.cast(i, this.casts[r]));
1419
- const h = n.model[`model${f.upperFirst(f.camelCase(t))}Get${f.upperFirst(f.camelCase(r))}Attribute`];
1420
- if (typeof h != "function")
1421
- throw new _("ModelFacade");
1422
- return h.bind(n.model)(i, this);
1412
+ getAttribute(s) {
1413
+ let i = this._attributes.get(s, null);
1414
+ s in this.casts && (i = this.cast(i, this.casts[s]));
1415
+ const u = n.model[`model${f.upperFirst(f.camelCase(e))}Get${f.upperFirst(f.camelCase(s))}Attribute`];
1416
+ if (typeof u != "function")
1417
+ throw new M("ModelFacade");
1418
+ return u.bind(n.model)(i, this);
1423
1419
  }
1424
- setAttribute(r, i) {
1425
- if (!this.fillable.includes(r)) {
1420
+ setAttribute(s, i) {
1421
+ if (!this.fillable.includes(s)) {
1426
1422
  if (n.config.get("app.env", "production") === "production")
1427
- throw new U(t, r);
1428
- n.log.warning(`[Luminix] Trying to set a non-fillable attribute "${r}" in model "${t}".
1423
+ throw new U(e, s);
1424
+ n.log.warning(`[Luminix] Trying to set a non-fillable attribute "${s}" in model "${e}".
1429
1425
  This will throw an error in production.`);
1430
1426
  return;
1431
1427
  }
1432
- const h = n.model[`model${f.upperFirst(f.camelCase(t))}Set${f.upperFirst(f.camelCase(r))}Attribute`];
1433
- if (typeof h != "function")
1434
- throw new _("ModelFacade");
1435
- const l = h.bind(n.model)(
1436
- this.mutate(i, this.casts[r]),
1428
+ const u = n.model[`model${f.upperFirst(f.camelCase(e))}Set${f.upperFirst(f.camelCase(s))}Attribute`];
1429
+ if (typeof u != "function")
1430
+ throw new M("ModelFacade");
1431
+ const a = u.bind(n.model)(
1432
+ this.mutate(i, this.casts[s]),
1437
1433
  this
1438
1434
  );
1439
- if (!this.validateJsonObject({ [r]: l })) {
1435
+ if (!this.validateJsonObject({ [s]: a })) {
1440
1436
  if (n.config.get("app.env", "production") === "production")
1441
- throw new TypeError(`[Luminix] Attribute "${r}" in model "${t}" must be a boolean, number, string or null`);
1442
- n.log.warning(`Invalid type for attribute "${r}" in model "${t}" after mutation.
1437
+ throw new TypeError(`[Luminix] Attribute "${s}" in model "${e}" must be a boolean, number, string or null`);
1438
+ n.log.warning(`Invalid type for attribute "${s}" in model "${e}" after mutation.
1443
1439
  This will throw an error in production.`, {
1444
- key: r,
1440
+ key: s,
1445
1441
  value: i,
1446
- mutated: l,
1447
- cast: this.casts[r],
1442
+ mutated: a,
1443
+ cast: this.casts[s],
1448
1444
  item: this.toJson()
1449
1445
  });
1450
1446
  return;
1451
1447
  }
1452
- this._attributes.set(r, l), this.updateChangedKeys(r), this.dispatchChangeEvent({ [r]: l });
1448
+ this._attributes.set(s, a), this.updateChangedKeys(s), this.dispatchChangeEvent({ [s]: a });
1453
1449
  }
1454
1450
  getKey() {
1455
1451
  return this.getAttribute(this.primaryKey);
@@ -1457,89 +1453,89 @@ function xt(n, t) {
1457
1453
  getKeyName() {
1458
1454
  return this.primaryKey;
1459
1455
  }
1460
- fill(r) {
1461
- const i = f.pick(r, this.fillable), h = Object.entries(i).reduce((l, [a, d]) => {
1462
- const g = n.model[`model${f.upperFirst(f.camelCase(t))}Set${f.upperFirst(f.camelCase(a))}Attribute`];
1456
+ fill(s) {
1457
+ const i = f.pick(s, this.fillable), u = Object.entries(i).reduce((a, [c, d]) => {
1458
+ const g = n.model[`model${f.upperFirst(f.camelCase(e))}Set${f.upperFirst(f.camelCase(c))}Attribute`];
1463
1459
  if (typeof g != "function")
1464
- throw new _("ModelFacade");
1465
- return l[a] = g.bind(n.model)(
1466
- this.mutate(d, this.casts[a]),
1460
+ throw new M("ModelFacade");
1461
+ return a[c] = g.bind(n.model)(
1462
+ this.mutate(d, this.casts[c]),
1467
1463
  this
1468
- ), l;
1464
+ ), a;
1469
1465
  }, {});
1470
- if (!this.validateJsonObject(h)) {
1466
+ if (!this.validateJsonObject(u)) {
1471
1467
  if (n.config.get("app.env", "production") === "production")
1472
- throw new TypeError(`[Luminix] Invalid attributes for model "${t}"`);
1473
- n.log.warning(`Invalid attributes for model "${t}" after mutation.
1468
+ throw new TypeError(`[Luminix] Invalid attributes for model "${e}"`);
1469
+ n.log.warning(`Invalid attributes for model "${e}" after mutation.
1474
1470
  This will throw an error in production.`, {
1475
- attributes: r,
1476
- mutatedAttributes: h,
1471
+ attributes: s,
1472
+ mutatedAttributes: u,
1477
1473
  item: this.toJson(),
1478
1474
  casts: this.casts
1479
1475
  });
1480
1476
  return;
1481
1477
  }
1482
- this._attributes.merge(".", h), Object.keys(h).forEach((l) => this.updateChangedKeys(l)), this.dispatchChangeEvent(h);
1478
+ this._attributes.merge(".", u), Object.keys(u).forEach((a) => this.updateChangedKeys(a)), this.dispatchChangeEvent(u);
1483
1479
  }
1484
1480
  dump() {
1485
1481
  n.log.info({
1486
1482
  ...this.toJson(),
1487
- [Symbol.toStringTag]: f.upperFirst(f.camelCase(t))
1483
+ [Symbol.toStringTag]: f.upperFirst(f.camelCase(e))
1488
1484
  });
1489
1485
  }
1490
1486
  toJson() {
1491
- const r = Object.entries(this.relations).reduce((h, [l, a]) => (a.isLoaded() && (a.isSingle() ? h[f.snakeCase(l)] = a.getLoadedItems().toJson() : a.isMultiple() && (h[f.snakeCase(l)] = a.getLoadedItems().map((d) => d.toJson()).all())), h), {}), i = n.model[`model${f.upperFirst(f.camelCase(t))}Json`];
1487
+ const s = Object.entries(this.relations).reduce((u, [a, c]) => (c.isLoaded() && (c.isSingle() ? u[f.snakeCase(a)] = c.getLoadedItems().toJson() : c.isMultiple() && (u[f.snakeCase(a)] = c.getLoadedItems().map((d) => d.toJson()).all())), u), {}), i = n.model[`model${f.upperFirst(f.camelCase(e))}Json`];
1492
1488
  if (typeof i != "function")
1493
- throw new _("ModelFacade");
1489
+ throw new M("ModelFacade");
1494
1490
  return i.bind(n.model)({
1495
1491
  ...this.attributes,
1496
- ...r
1492
+ ...s
1497
1493
  }, this);
1498
1494
  }
1499
1495
  diff() {
1500
- return this._changedKeys.reduce((r, i) => (r[i] = this._attributes.get(i), r), {});
1496
+ return this._changedKeys.reduce((s, i) => (s[i] = this._attributes.get(i), s), {});
1501
1497
  }
1502
1498
  getType() {
1503
- return t;
1499
+ return e;
1504
1500
  }
1505
- relation(r) {
1506
- if (r === f.camelCase(r))
1507
- return this.relations[f.snakeCase(r)];
1501
+ relation(s) {
1502
+ if (s === f.camelCase(s))
1503
+ return this.relations[f.snakeCase(s)];
1508
1504
  }
1509
1505
  async refresh() {
1510
1506
  if (!this.exists)
1511
- throw new D(t, "refresh");
1512
- const { data: r } = await n.route.call([
1513
- `luminix.${t}.show`,
1507
+ throw new D(e, "refresh");
1508
+ const { data: s } = await n.route.call([
1509
+ `luminix.${e}.show`,
1514
1510
  this.makePrimaryKeyReplacer()
1515
1511
  ], {
1516
- errorBag: `${t}[${this.getKey()}].fetch`
1512
+ errorBag: `${e}[${this.getKey()}].fetch`
1517
1513
  });
1518
- this.makeAttributes(r);
1514
+ this.makeAttributes(s);
1519
1515
  }
1520
- async save(r = {}) {
1516
+ async save(s = {}) {
1521
1517
  try {
1522
1518
  const {
1523
1519
  additionalPayload: i = {},
1524
- sendsOnlyModifiedFields: h = !0
1525
- } = r, l = this.exists, a = l ? [
1526
- `luminix.${t}.update`,
1520
+ sendsOnlyModifiedFields: u = !0
1521
+ } = s, a = this.exists, c = a ? [
1522
+ `luminix.${e}.update`,
1527
1523
  this.makePrimaryKeyReplacer()
1528
- ] : `luminix.${t}.store`, d = await n.route.call(
1529
- a,
1524
+ ] : `luminix.${e}.store`, d = await n.route.call(
1525
+ c,
1530
1526
  {
1531
1527
  data: {
1532
1528
  ...f.pick(
1533
- h && l ? this.diff() : this.attributes,
1529
+ u && a ? this.diff() : this.attributes,
1534
1530
  this.fillable
1535
1531
  ),
1536
1532
  ...i
1537
1533
  },
1538
- errorBag: l ? `${t}[${this.getKey()}].update` : `${t}.store`
1534
+ errorBag: a ? `${e}[${this.getKey()}].update` : `${e}.store`
1539
1535
  }
1540
1536
  );
1541
1537
  if ([200, 201].includes(d.status))
1542
- return this.makeAttributes(d.data), this.exists = !0, this.dispatchSaveEvent(), l ? this.dispatchUpdateEvent(d.data) : this.dispatchCreateEvent(d.data), d;
1538
+ return this.makeAttributes(d.data), this.exists = !0, this.dispatchSaveEvent(), a ? this.dispatchUpdateEvent(d.data) : this.dispatchCreateEvent(d.data), d;
1543
1539
  throw d;
1544
1540
  } catch (i) {
1545
1541
  throw n.log.error(i), this.dispatchErrorEvent(i, "save"), i;
@@ -1550,27 +1546,27 @@ function xt(n, t) {
1550
1546
  }
1551
1547
  async delete() {
1552
1548
  try {
1553
- const r = await n.route.call([
1554
- `luminix.${t}.destroy`,
1549
+ const s = await n.route.call([
1550
+ `luminix.${e}.destroy`,
1555
1551
  this.makePrimaryKeyReplacer()
1556
1552
  ], {
1557
- errorBag: `${t}[${this.getKey()}].delete`
1553
+ errorBag: `${e}[${this.getKey()}].delete`
1558
1554
  });
1559
- if (r.status === 204)
1560
- return this.dispatchDeleteEvent(), r;
1561
- throw r;
1562
- } catch (r) {
1563
- throw n.log.error(r), this.dispatchErrorEvent(r, "delete"), r;
1555
+ if (s.status === 204)
1556
+ return this.dispatchDeleteEvent(), s;
1557
+ throw s;
1558
+ } catch (s) {
1559
+ throw n.log.error(s), this.dispatchErrorEvent(s, "delete"), s;
1564
1560
  }
1565
1561
  }
1566
- async update(r) {
1562
+ async update(s) {
1567
1563
  try {
1568
1564
  const i = await n.route.call([
1569
- `luminix.${t}.update`,
1565
+ `luminix.${e}.update`,
1570
1566
  this.makePrimaryKeyReplacer()
1571
1567
  ], {
1572
- data: r,
1573
- errorBag: `${t}[${this.getKey()}].update`
1568
+ data: s,
1569
+ errorBag: `${e}[${this.getKey()}].update`
1574
1570
  });
1575
1571
  if (i.status === 200) {
1576
1572
  this.makeAttributes(i.data), this.dispatchUpdateEvent(i.data);
@@ -1583,246 +1579,246 @@ function xt(n, t) {
1583
1579
  }
1584
1580
  async forceDelete() {
1585
1581
  try {
1586
- const r = await n.route.call(
1582
+ const s = await n.route.call(
1587
1583
  [
1588
- `luminix.${t}.destroy`,
1584
+ `luminix.${e}.destroy`,
1589
1585
  this.makePrimaryKeyReplacer()
1590
1586
  ],
1591
1587
  {
1592
1588
  params: { force: !0 },
1593
- errorBag: `${t}[${this.getKey()}].forceDelete`
1589
+ errorBag: `${e}[${this.getKey()}].forceDelete`
1594
1590
  }
1595
1591
  );
1596
- if (r.status === 204)
1597
- return this.dispatchDeleteEvent(!0), r;
1598
- throw r;
1599
- } catch (r) {
1600
- throw n.log.error(r), this.dispatchErrorEvent(r, "forceDelete"), r;
1592
+ if (s.status === 204)
1593
+ return this.dispatchDeleteEvent(!0), s;
1594
+ throw s;
1595
+ } catch (s) {
1596
+ throw n.log.error(s), this.dispatchErrorEvent(s, "forceDelete"), s;
1601
1597
  }
1602
1598
  }
1603
1599
  async restore() {
1604
1600
  try {
1605
- const r = await n.route.call(
1601
+ const s = await n.route.call(
1606
1602
  [
1607
- `luminix.${t}.update`,
1603
+ `luminix.${e}.update`,
1608
1604
  this.makePrimaryKeyReplacer()
1609
1605
  ],
1610
1606
  {
1611
1607
  params: { restore: !0 },
1612
- errorBag: `${t}[${this.getKey()}].restore`
1608
+ errorBag: `${e}[${this.getKey()}].restore`
1613
1609
  }
1614
1610
  );
1615
- if (r.status === 200)
1616
- return this.dispatchRestoreEvent(), r;
1617
- throw r;
1618
- } catch (r) {
1619
- throw n.log.error(r), this.dispatchErrorEvent(r, "restore"), r;
1611
+ if (s.status === 200)
1612
+ return this.dispatchRestoreEvent(), s;
1613
+ throw s;
1614
+ } catch (s) {
1615
+ throw n.log.error(s), this.dispatchErrorEvent(s, "restore"), s;
1620
1616
  }
1621
1617
  }
1622
1618
  static getSchemaName() {
1623
- return t;
1619
+ return e;
1624
1620
  }
1625
1621
  static getSchema() {
1626
- return n.model.schema(t);
1622
+ return n.model.schema(e);
1627
1623
  }
1628
1624
  static query() {
1629
- return new Et(n, t);
1625
+ return new Me(n, e);
1630
1626
  }
1631
- static where(...r) {
1632
- return this.query().where(...r);
1627
+ static where(...s) {
1628
+ return this.query().where(...s);
1633
1629
  }
1634
- static whereNull(r) {
1635
- return this.query().whereNull(r);
1630
+ static whereNull(s) {
1631
+ return this.query().whereNull(s);
1636
1632
  }
1637
- static whereNotNull(r) {
1638
- return this.query().whereNotNull(r);
1633
+ static whereNotNull(s) {
1634
+ return this.query().whereNotNull(s);
1639
1635
  }
1640
- static whereBetween(r, i) {
1641
- return this.query().whereBetween(r, i);
1636
+ static whereBetween(s, i) {
1637
+ return this.query().whereBetween(s, i);
1642
1638
  }
1643
- static whereNotBetween(r, i) {
1644
- return this.query().whereNotBetween(r, i);
1639
+ static whereNotBetween(s, i) {
1640
+ return this.query().whereNotBetween(s, i);
1645
1641
  }
1646
- static orderBy(r, i = "asc") {
1647
- return this.query().orderBy(r, i);
1642
+ static orderBy(s, i = "asc") {
1643
+ return this.query().orderBy(s, i);
1648
1644
  }
1649
- static searchBy(r) {
1650
- return this.query().searchBy(r);
1645
+ static searchBy(s) {
1646
+ return this.query().searchBy(s);
1651
1647
  }
1652
1648
  static minified() {
1653
1649
  return this.query().minified();
1654
1650
  }
1655
- static limit(r) {
1656
- return this.query().limit(r);
1651
+ static limit(s) {
1652
+ return this.query().limit(s);
1657
1653
  }
1658
- static get(r = 1, i) {
1659
- return this.query().get(r, i);
1654
+ static get(s = 1, i) {
1655
+ return this.query().get(s, i);
1660
1656
  }
1661
- static find(r) {
1662
- return this.query().find(r);
1657
+ static find(s) {
1658
+ return this.query().find(s);
1663
1659
  }
1664
1660
  static first() {
1665
1661
  return this.query().first();
1666
1662
  }
1667
- static async create(r) {
1668
- const i = n.model.make(t), h = new i();
1669
- return h.fill(r), await h.save(), h;
1663
+ static async create(s) {
1664
+ const i = n.model.make(e), u = new i();
1665
+ return u.fill(s), await u.save(), u;
1670
1666
  }
1671
- static async update(r, i) {
1672
- const h = n.model.make(t), l = new h({ id: r });
1673
- return l.fill(i), l.exists = !0, await l.save(), l;
1667
+ static async update(s, i) {
1668
+ const u = n.model.make(e), a = new u({ id: s });
1669
+ return a.fill(i), a.exists = !0, await a.save(), a;
1674
1670
  }
1675
- static delete(r) {
1676
- if (Array.isArray(r))
1677
- return n.route.call(`luminix.${t}.destroyMany`, {
1678
- params: { ids: r },
1679
- errorBag: `${t}.deleteMany`
1671
+ static delete(s) {
1672
+ if (Array.isArray(s))
1673
+ return n.route.call(`luminix.${e}.destroyMany`, {
1674
+ params: { ids: s },
1675
+ errorBag: `${e}.deleteMany`
1680
1676
  });
1681
- const i = n.model.make(t);
1682
- return new i({ id: r }).delete();
1683
- }
1684
- static async restore(r) {
1685
- if (Array.isArray(r))
1686
- return n.route.call(`luminix.${t}.restoreMany`, {
1687
- data: { ids: r },
1688
- errorBag: `${t}.restoreMany`
1677
+ const i = n.model.make(e);
1678
+ return new i({ id: s }).delete();
1679
+ }
1680
+ static async restore(s) {
1681
+ if (Array.isArray(s))
1682
+ return n.route.call(`luminix.${e}.restoreMany`, {
1683
+ data: { ids: s },
1684
+ errorBag: `${e}.restoreMany`
1689
1685
  });
1690
- const i = n.model.make(t);
1691
- return new i({ id: r }).restore();
1692
- }
1693
- static forceDelete(r) {
1694
- if (Array.isArray(r))
1695
- return n.route.call(`luminix.${t}.destroyMany`, {
1696
- params: { ids: r, force: !0 },
1697
- errorBag: `${t}.forceDeleteMany`
1686
+ const i = n.model.make(e);
1687
+ return new i({ id: s }).restore();
1688
+ }
1689
+ static forceDelete(s) {
1690
+ if (Array.isArray(s))
1691
+ return n.route.call(`luminix.${e}.destroyMany`, {
1692
+ params: { ids: s, force: !0 },
1693
+ errorBag: `${e}.forceDeleteMany`
1698
1694
  });
1699
- const i = n.model.make(t);
1700
- return new i({ id: r }).forceDelete();
1695
+ const i = n.model.make(e);
1696
+ return new i({ id: s }).forceDelete();
1701
1697
  }
1702
1698
  static singular() {
1703
- return n.model.schema(t).displayName.singular;
1699
+ return n.model.schema(e).displayName.singular;
1704
1700
  }
1705
1701
  static plural() {
1706
- return n.model.schema(t).displayName.plural;
1702
+ return n.model.schema(e).displayName.plural;
1707
1703
  }
1708
1704
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
1709
- on(r, i) {
1705
+ on(s, i) {
1710
1706
  throw new y();
1711
1707
  }
1712
1708
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
1713
- once(r, i) {
1709
+ once(s, i) {
1714
1710
  throw new y();
1715
1711
  }
1716
1712
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
1717
- emit(r, i) {
1713
+ emit(s, i) {
1718
1714
  throw new y();
1719
1715
  }
1720
1716
  }
1721
- return p(e, "name", f.upperFirst(f.camelCase(t))), A(e);
1717
+ return p(t, "name", f.upperFirst(f.camelCase(e))), A(t);
1722
1718
  }
1723
- function _t(n, t, e) {
1724
- var s;
1725
- return s = class extends e {
1726
- constructor(r = {}) {
1727
- return super(r), new Proxy(this, {
1728
- get: (i, h) => {
1729
- if (h === "__isModel")
1719
+ function Te(n, e, t) {
1720
+ var r;
1721
+ return r = class extends t {
1722
+ constructor(s = {}) {
1723
+ return super(s), new Proxy(this, {
1724
+ get: (i, u) => {
1725
+ if (u === "__isModel")
1730
1726
  return !0;
1731
- if (h in i) {
1732
- const a = i[h];
1733
- return typeof a == "function" ? a.bind(i) : a;
1727
+ if (u in i) {
1728
+ const c = i[u];
1729
+ return typeof c == "function" ? c.bind(i) : c;
1734
1730
  }
1735
- if (h !== f.camelCase(h))
1731
+ if (u !== f.camelCase(u))
1736
1732
  return;
1737
- const l = f.snakeCase(h);
1738
- if (Object.keys(i.relations).includes(l))
1739
- return i.relations[l].getLoadedItems();
1740
- if (h.endsWith("Relation") && Object.keys(i.relations).includes(f.snakeCase(h.slice(0, -8))))
1741
- return () => i.relation(h.slice(0, -8));
1742
- if (Object.keys(i.attributes).includes(l))
1743
- return i.getAttribute(l);
1744
- if (n.model.hasReducer(`model${i.constructor.name}Get${f.upperFirst(h)}Attribute`)) {
1745
- const a = n.model[`model${i.constructor.name}Get${f.upperFirst(h)}Attribute`];
1746
- if (typeof a != "function")
1747
- throw new _("ModelFacade");
1748
- return a.bind(n.model)(void 0, i);
1733
+ const a = f.snakeCase(u);
1734
+ if (Object.keys(i.relations).includes(a))
1735
+ return i.relations[a].getLoadedItems();
1736
+ if (u.endsWith("Relation") && Object.keys(i.relations).includes(f.snakeCase(u.slice(0, -8))))
1737
+ return () => i.relation(u.slice(0, -8));
1738
+ if (Object.keys(i.attributes).includes(a))
1739
+ return i.getAttribute(a);
1740
+ if (n.model.hasReducer(`model${i.constructor.name}Get${f.upperFirst(u)}Attribute`)) {
1741
+ const c = n.model[`model${i.constructor.name}Get${f.upperFirst(u)}Attribute`];
1742
+ if (typeof c != "function")
1743
+ throw new M("ModelFacade");
1744
+ return c.bind(n.model)(void 0, i);
1749
1745
  }
1750
- return Reflect.get(i, h);
1746
+ return Reflect.get(i, u);
1751
1747
  },
1752
- set: (i, h, l) => {
1753
- if (h in i && typeof i[h] != "function")
1754
- return Reflect.set(i, h, l);
1755
- if (i.fillable.includes(f.snakeCase(h)))
1748
+ set: (i, u, a) => {
1749
+ if (u in i && typeof i[u] != "function")
1750
+ return Reflect.set(i, u, a);
1751
+ if (i.fillable.includes(f.snakeCase(u)))
1756
1752
  return i.setAttribute(
1757
- f.snakeCase(h),
1758
- l
1753
+ f.snakeCase(u),
1754
+ a
1759
1755
  ), !0;
1760
- throw new U(t, f.snakeCase(h));
1756
+ throw new U(e, f.snakeCase(u));
1761
1757
  }
1762
1758
  });
1763
1759
  }
1764
- }, p(s, "name", f.upperFirst(f.camelCase(t))), s;
1760
+ }, p(r, "name", f.upperFirst(f.camelCase(e))), r;
1765
1761
  }
1766
- class tt extends Error {
1767
- constructor(t, e) {
1768
- super(`[Luminix] Cannot create reducer '${t}' on '${e}' as it is a reserved property`);
1762
+ class se extends Error {
1763
+ constructor(e, t) {
1764
+ super(`[Luminix] Cannot create reducer '${e}' on '${t}' as it is a reserved property`);
1769
1765
  }
1770
1766
  }
1771
- p(tt, "name", "ReducerOverrideException");
1772
- function et(n) {
1767
+ p(se, "name", "ReducerOverrideException");
1768
+ function ie(n) {
1773
1769
  return class extends n {
1774
- constructor(...e) {
1775
- super(...e);
1770
+ constructor(...t) {
1771
+ super(...t);
1776
1772
  p(this, "reducers", {});
1777
1773
  return new Proxy(this, {
1778
- get(s, r, i) {
1779
- return typeof r == "symbol" || r in s ? Reflect.get(s, r, i) : (h, ...l) => {
1780
- const { [r]: a = c() } = s.reducers;
1781
- return pt(h) ? B(h, (d) => a.sortBy("priority").reduce((g, b) => b.callback(g, ...l), d)) : a.sortBy("priority").reduce((d, g) => g.callback(d, ...l), h);
1774
+ get(r, s, i) {
1775
+ return typeof s == "symbol" || s in r ? Reflect.get(r, s, i) : (u, ...a) => {
1776
+ const { [s]: c = l() } = r.reducers;
1777
+ return ye(u) ? B(u, (d) => c.sortBy("priority").reduce((g, b) => b.callback(g, ...a), d)) : c.sortBy("priority").reduce((d, g) => g.callback(d, ...a), u);
1782
1778
  };
1783
1779
  }
1784
1780
  });
1785
1781
  }
1786
- reducer(e, s, r = 10) {
1787
- if (e in this)
1788
- throw new tt(e, this);
1789
- return this.reducers[e] || (this.reducers[e] = c()), this.reducers[e].push({ callback: s, priority: r }), () => this.removeReducer(e, s);
1782
+ reducer(t, r, s = 10) {
1783
+ if (t in this)
1784
+ throw new se(t, this);
1785
+ return this.reducers[t] || (this.reducers[t] = l()), this.reducers[t].push({ callback: r, priority: s }), () => this.removeReducer(t, r);
1790
1786
  }
1791
- removeReducer(e, s) {
1792
- const r = this.reducers[e].search((i) => i.callback === s);
1793
- r !== !1 && this.reducers[e].pull(r);
1787
+ removeReducer(t, r) {
1788
+ const s = this.reducers[t].search((i) => i.callback === r);
1789
+ s !== !1 && this.reducers[t].pull(s);
1794
1790
  }
1795
- getReducer(e) {
1796
- return this.reducers[e] || (this.reducers[e] = c()), this.reducers[e];
1791
+ getReducer(t) {
1792
+ return this.reducers[t] || (this.reducers[t] = l()), this.reducers[t];
1797
1793
  }
1798
- hasReducer(e) {
1799
- return !!this.reducers[e] && this.reducers[e].count() > 0;
1794
+ hasReducer(t) {
1795
+ return !!this.reducers[t] && this.reducers[t].count() > 0;
1800
1796
  }
1801
- clearReducer(e) {
1802
- this.reducers[e].splice(0, this.reducers[e].count());
1797
+ clearReducer(t) {
1798
+ this.reducers[t].splice(0, this.reducers[t].count());
1803
1799
  }
1804
1800
  flushReducers() {
1805
- Object.values(this.reducers).forEach((e) => e.splice(0, e.count()));
1801
+ Object.values(this.reducers).forEach((t) => t.splice(0, t.count()));
1806
1802
  }
1807
1803
  };
1808
1804
  }
1809
1805
  class C extends Error {
1810
- constructor(t) {
1811
- super(`[Luminix] Model "${t}" not found`);
1806
+ constructor(e) {
1807
+ super(`[Luminix] Model "${e}" not found`);
1812
1808
  }
1813
1809
  }
1814
1810
  p(C, "name", "ModelNotFoundException");
1815
1811
  class N extends TypeError {
1816
- constructor(t, e, s) {
1817
- super(`[Luminix] "${t}" expects a related model of type "${e}". Received "${s}" instead.`);
1812
+ constructor(e, t, r) {
1813
+ super(`[Luminix] "${e}" expects a related model of type "${t}". Received "${r}" instead.`);
1818
1814
  }
1819
1815
  }
1820
1816
  p(N, "name", "ModelInvalidRelatedTypeException");
1821
- class rt extends F {
1822
- constructor(t, e, s, r = null) {
1823
- if (!w(r) && r !== null)
1817
+ class ne extends j {
1818
+ constructor(e, t, r, s = null) {
1819
+ if (!w(s) && s !== null)
1824
1820
  throw new E("BelongsTo.constructor()", "Model or null");
1825
- super(t, e, s, r), this.meta = t, this.facades = e, this.parent = s, this.items = r;
1821
+ super(e, t, r, s), this.meta = e, this.facades = t, this.parent = r, this.items = s;
1826
1822
  }
1827
1823
  isSingle() {
1828
1824
  return !0;
@@ -1831,21 +1827,21 @@ class rt extends F {
1831
1827
  return !1;
1832
1828
  }
1833
1829
  query() {
1834
- const t = super.query(), e = this.guessInverseRelation();
1835
- return t.where(e, this.parent.getKey()), t.lock(`filters.${e}`), t;
1830
+ const e = super.query(), t = this.guessInverseRelation();
1831
+ return e.where(t, this.parent.getKey()), e.lock(`where.${t}`), e;
1836
1832
  }
1837
1833
  get() {
1838
1834
  return this.query().first();
1839
1835
  }
1840
- async associate(t) {
1841
- if (!w(t))
1836
+ async associate(e) {
1837
+ if (!w(e))
1842
1838
  throw new E("BelongsTo.associate()");
1843
- if (t.getType() !== this.getRelated().getSchemaName())
1844
- throw new N("BelongsTo.associate()", this.getRelated().getSchemaName(), t.getType());
1845
- if (!t.exists)
1839
+ if (e.getType() !== this.getRelated().getSchemaName())
1840
+ throw new N("BelongsTo.associate()", this.getRelated().getSchemaName(), e.getType());
1841
+ if (!e.exists)
1846
1842
  throw new D(this.getRelated().getSchemaName(), "save");
1847
1843
  return this.parent.update({
1848
- [this.getForeignKey()]: t.getKey()
1844
+ [this.getForeignKey()]: e.getKey()
1849
1845
  });
1850
1846
  }
1851
1847
  dissociate() {
@@ -1854,11 +1850,11 @@ class rt extends F {
1854
1850
  });
1855
1851
  }
1856
1852
  }
1857
- class st extends F {
1858
- constructor(t, e, s, r = null) {
1859
- if (r !== null && !(r instanceof J && r.every(w)))
1853
+ class oe extends j {
1854
+ constructor(e, t, r, s = null) {
1855
+ if (s !== null && !(s instanceof J && s.every(w)))
1860
1856
  throw new E("BelongsToMany.constructor()", "Collection<Model> or null");
1861
- super(t, e, s, r), this.meta = t, this.facades = e, this.parent = s, this.items = r;
1857
+ super(e, t, r, s), this.meta = e, this.facades = t, this.parent = r, this.items = s;
1862
1858
  }
1863
1859
  isSingle() {
1864
1860
  return !1;
@@ -1867,11 +1863,11 @@ class st extends F {
1867
1863
  return !0;
1868
1864
  }
1869
1865
  query() {
1870
- const t = super.query(), e = this.guessInverseRelation();
1871
- return t.where(e, this.parent.getKey()), t.lock(`filters.${e}`), t;
1866
+ const e = super.query(), t = this.guessInverseRelation();
1867
+ return e.where(t, this.parent.getKey()), e.lock(`where.${t}`), e;
1872
1868
  }
1873
- get(t = 1, e) {
1874
- return this.query().get(t, e);
1869
+ get(e = 1, t) {
1870
+ return this.query().get(e, t);
1875
1871
  }
1876
1872
  all() {
1877
1873
  return this.query().all();
@@ -1879,37 +1875,37 @@ class st extends F {
1879
1875
  first() {
1880
1876
  return this.query().first();
1881
1877
  }
1882
- find(t) {
1883
- return this.query().find(t);
1878
+ find(e) {
1879
+ return this.query().find(e);
1884
1880
  }
1885
- attachQuietly(t, e = {}) {
1881
+ attachQuietly(e, t = {}) {
1886
1882
  return this.facades.route.call([
1887
1883
  `luminix.${this.parent.getType()}.${this.getName()}:attach`,
1888
1884
  {
1889
1885
  [this.parent.getKeyName()]: this.parent.getKey(),
1890
- itemId: t
1886
+ itemId: e
1891
1887
  }
1892
1888
  ], {
1893
- data: e,
1889
+ data: t,
1894
1890
  errorBag: `${this.parent.getType()}[${this.parent.getKey()}].${this.getName()}:attach`
1895
1891
  });
1896
1892
  }
1897
- async attach(t, e = {}) {
1898
- if (await this.attachQuietly(t, e), this.items) {
1899
- const s = this.items.search((i) => i.getKey() === t), r = await this.getRelated().find(t);
1900
- if (!r)
1893
+ async attach(e, t = {}) {
1894
+ if (await this.attachQuietly(e, t), this.items) {
1895
+ const r = this.items.search((i) => i.getKey() === e), s = await this.getRelated().find(e);
1896
+ if (!s)
1901
1897
  return;
1902
- s !== !1 ? this.items.put(s, r) : this.items.push(r);
1898
+ r !== !1 ? this.items.put(r, s) : this.items.push(s);
1903
1899
  } else
1904
1900
  this.items = await this.all();
1905
1901
  }
1906
- async detachQuietly(t) {
1902
+ async detachQuietly(e) {
1907
1903
  await this.facades.route.call(
1908
1904
  [
1909
1905
  `luminix.${this.parent.getType()}.${this.getName()}:detach`,
1910
1906
  {
1911
1907
  [this.parent.getKeyName()]: this.parent.getKey(),
1912
- itemId: t
1908
+ itemId: e
1913
1909
  }
1914
1910
  ],
1915
1911
  {
@@ -1917,66 +1913,66 @@ class st extends F {
1917
1913
  }
1918
1914
  );
1919
1915
  }
1920
- async detach(t) {
1921
- if (await this.detachQuietly(t), this.items) {
1922
- const e = this.items.search((s) => s.getKey() === t);
1923
- e !== !1 && this.items.pull(e);
1916
+ async detach(e) {
1917
+ if (await this.detachQuietly(e), this.items) {
1918
+ const t = this.items.search((r) => r.getKey() === e);
1919
+ t !== !1 && this.items.pull(t);
1924
1920
  }
1925
1921
  }
1926
- async syncQuietly(t) {
1922
+ async syncQuietly(e) {
1927
1923
  await this.facades.route.call([
1928
1924
  `luminix.${this.parent.getType()}.${this.getName()}:sync`,
1929
1925
  {
1930
1926
  [this.parent.getKeyName()]: this.parent.getKey()
1931
1927
  }
1932
1928
  ], {
1933
- data: t,
1929
+ data: e,
1934
1930
  errorBag: `${this.parent.getType()}[${this.parent.getKey()}].${this.getName()}:sync`
1935
1931
  });
1936
1932
  }
1937
- async syncWithPivotValuesQuietly(t, e) {
1933
+ async syncWithPivotValuesQuietly(e, t) {
1938
1934
  await this.facades.route.call([
1939
1935
  `luminix.${this.parent.getType()}.${this.getName()}:sync`,
1940
1936
  {
1941
1937
  [this.parent.getKeyName()]: this.parent.getKey()
1942
1938
  }
1943
1939
  ], {
1944
- data: t.map((s) => ({
1945
- [this.getRelated().getSchema().primaryKey]: s,
1946
- ...e
1940
+ data: e.map((r) => ({
1941
+ [this.getRelated().getSchema().primaryKey]: r,
1942
+ ...t
1947
1943
  })),
1948
1944
  errorBag: `${this.parent.getType()}[${this.parent.getKey()}].${this.getName()}:sync`
1949
1945
  });
1950
1946
  }
1951
- async sync(t) {
1952
- await this.syncQuietly(t);
1953
- const e = await this.all();
1954
- this.items ? this.items.splice(0, this.items.count(), ...e) : this.items = e;
1947
+ async sync(e) {
1948
+ await this.syncQuietly(e);
1949
+ const t = await this.all();
1950
+ this.items ? this.items.splice(0, this.items.count(), ...t) : this.items = t;
1955
1951
  }
1956
- async syncWithPivotValues(t, e) {
1957
- await this.syncWithPivotValuesQuietly(t, e);
1958
- const s = await this.all();
1959
- this.items ? this.items.splice(0, this.items.count(), ...s) : this.items = s;
1952
+ async syncWithPivotValues(e, t) {
1953
+ await this.syncWithPivotValuesQuietly(e, t);
1954
+ const r = await this.all();
1955
+ this.items ? this.items.splice(0, this.items.count(), ...r) : this.items = r;
1960
1956
  }
1961
1957
  }
1962
- class H extends F {
1958
+ class H extends j {
1963
1959
  query() {
1964
- const t = super.query(), e = this.guessInverseRelation();
1965
- return t.where(e, this.parent.getKey()), t.lock(`filters.${e}`), t;
1960
+ const e = super.query(), t = this.guessInverseRelation();
1961
+ return e.where(t, this.parent.getKey()), e.lock(`where.${t}`), e;
1966
1962
  }
1967
- async saveQuietly(t) {
1968
- if (!w(t))
1963
+ async saveQuietly(e) {
1964
+ if (!w(e))
1969
1965
  throw new E("HasOneOrMany.saveQuietly()");
1970
- if (t.getType() !== this.getRelated().getSchemaName())
1971
- throw new N("HasOneOrMany.saveQuietly()", this.getRelated().getSchemaName(), t.getType());
1972
- t.setAttribute(this.getForeignKey(), this.parent.getKey()), await t.save();
1966
+ if (e.getType() !== this.getRelated().getSchemaName())
1967
+ throw new N("HasOneOrMany.saveQuietly()", this.getRelated().getSchemaName(), e.getType());
1968
+ e.setAttribute(this.getForeignKey(), this.parent.getKey()), await e.save();
1973
1969
  }
1974
1970
  }
1975
- class Mt extends H {
1976
- constructor(t, e, s, r = null) {
1977
- if (!w(r) && r !== null)
1971
+ class Ae extends H {
1972
+ constructor(e, t, r, s = null) {
1973
+ if (!w(s) && s !== null)
1978
1974
  throw new E("HasOne.constructor()", "Model or null");
1979
- super(t, e, s, r), this.meta = t, this.facades = e, this.parent = s, this.items = r;
1975
+ super(e, t, r, s), this.meta = e, this.facades = t, this.parent = r, this.items = s;
1980
1976
  }
1981
1977
  isSingle() {
1982
1978
  return !0;
@@ -1987,15 +1983,15 @@ class Mt extends H {
1987
1983
  get() {
1988
1984
  return this.query().first();
1989
1985
  }
1990
- async save(t) {
1991
- await this.saveQuietly(t), this.items = t;
1986
+ async save(e) {
1987
+ await this.saveQuietly(e), this.items = e;
1992
1988
  }
1993
1989
  }
1994
- class $t extends H {
1995
- constructor(t, e, s, r = null) {
1996
- if (r !== null && !(r instanceof J && r.every(w)))
1990
+ class ve extends H {
1991
+ constructor(e, t, r, s = null) {
1992
+ if (s !== null && !(s instanceof J && s.every(w)))
1997
1993
  throw new E("HasMany.constructor()", "Collection<Model> or null");
1998
- super(t, e, s, r), this.meta = t, this.facades = e, this.parent = s, this.items = r;
1994
+ super(e, t, r, s), this.meta = e, this.facades = t, this.parent = r, this.items = s;
1999
1995
  }
2000
1996
  isSingle() {
2001
1997
  return !1;
@@ -2003,8 +1999,8 @@ class $t extends H {
2003
1999
  isMultiple() {
2004
2000
  return !0;
2005
2001
  }
2006
- get(t = 1, e) {
2007
- return this.query().get(t, e);
2002
+ get(e = 1, t) {
2003
+ return this.query().get(e, t);
2008
2004
  }
2009
2005
  all() {
2010
2006
  return this.query().all();
@@ -2012,48 +2008,48 @@ class $t extends H {
2012
2008
  first() {
2013
2009
  return this.query().first();
2014
2010
  }
2015
- find(t) {
2016
- return this.query().find(t);
2011
+ find(e) {
2012
+ return this.query().find(e);
2017
2013
  }
2018
- async saveManyQuietly(t) {
2019
- if (!Array.isArray(t) || !t.every(w))
2014
+ async saveManyQuietly(e) {
2015
+ if (!Array.isArray(e) || !e.every(w))
2020
2016
  throw new E("HasMany.saveManyQuietly()", "Model[]");
2021
- if (!t.every((e) => e.getType() === this.getRelated().getSchemaName()))
2022
- throw new N("HasMany.saveManyQuietly()", this.getRelated().getSchemaName(), t.map((e) => e.getType()).join(", "));
2023
- await Promise.all(t.map((e) => (e.setAttribute(this.getForeignKey(), this.parent.getKey()), e.save())));
2017
+ if (!e.every((t) => t.getType() === this.getRelated().getSchemaName()))
2018
+ throw new N("HasMany.saveManyQuietly()", this.getRelated().getSchemaName(), e.map((t) => t.getType()).join(", "));
2019
+ await Promise.all(e.map((t) => (t.setAttribute(this.getForeignKey(), this.parent.getKey()), t.save())));
2024
2020
  }
2025
- async saveMany(t) {
2026
- await this.saveManyQuietly(t);
2027
- const e = await this.all();
2028
- this.items ? this.items.splice(0, this.items.count(), ...e) : this.items = e;
2021
+ async saveMany(e) {
2022
+ await this.saveManyQuietly(e);
2023
+ const t = await this.all();
2024
+ this.items ? this.items.splice(0, this.items.count(), ...t) : this.items = t;
2029
2025
  }
2030
- async save(t) {
2031
- await this.saveQuietly(t), this.items === null ? this.items = await this.all() : this.items.push(t);
2026
+ async save(e) {
2027
+ await this.saveQuietly(e), this.items === null ? this.items = await this.all() : this.items.push(e);
2032
2028
  }
2033
2029
  }
2034
- class it extends H {
2030
+ class he extends H {
2035
2031
  query() {
2036
- const t = this.getRelated().query();
2037
- t.once("success", (s) => {
2038
- this.items = s.items;
2032
+ const e = this.getRelated().query();
2033
+ e.once("success", (r) => {
2034
+ this.items = r.items;
2039
2035
  });
2040
- const e = this.guessInverseRelation();
2041
- return t.where(e + "_id", this.parent.getKey()), t.where(e + "_type", this.getRelated().getSchemaName()), t.lock(`filters.${e}_id`), t.lock(`filters.${e}_type`), t;
2036
+ const t = this.guessInverseRelation();
2037
+ return e.where(t + "_id", this.parent.getKey()), e.where(t + "_type", this.getRelated().getSchemaName()), e.lock(`where.${t}_id`), e.lock(`where.${t}_type`), e;
2042
2038
  }
2043
- async saveQuietly(t) {
2044
- if (!w(t))
2039
+ async saveQuietly(e) {
2040
+ if (!w(e))
2045
2041
  throw new E("MorphOneOrMany.saveQuietly()");
2046
- if (t.getType() !== this.getRelated().getSchemaName())
2047
- throw new N("MorphOneOrMany.saveQuietly()", this.getRelated().getSchemaName(), t.getType());
2048
- const e = this.guessInverseRelation();
2049
- t.setAttribute(e + "_id", this.parent.getKey()), t.setAttribute(e + "_type", this.parent.getType()), await t.save();
2042
+ if (e.getType() !== this.getRelated().getSchemaName())
2043
+ throw new N("MorphOneOrMany.saveQuietly()", this.getRelated().getSchemaName(), e.getType());
2044
+ const t = this.guessInverseRelation();
2045
+ e.setAttribute(t + "_id", this.parent.getKey()), e.setAttribute(t + "_type", this.parent.getType()), await e.save();
2050
2046
  }
2051
2047
  }
2052
- class Tt extends it {
2053
- constructor(t, e, s, r = null) {
2054
- if (r !== null && !(r instanceof J && r.every(w)))
2048
+ class Re extends he {
2049
+ constructor(e, t, r, s = null) {
2050
+ if (s !== null && !(s instanceof J && s.every(w)))
2055
2051
  throw new E("MorphMany.constructor()", "Collection<Model> or null");
2056
- super(t, e, s, r), this.meta = t, this.facades = e, this.parent = s, this.items = r;
2052
+ super(e, t, r, s), this.meta = e, this.facades = t, this.parent = r, this.items = s;
2057
2053
  }
2058
2054
  isSingle() {
2059
2055
  return !1;
@@ -2061,8 +2057,8 @@ class Tt extends it {
2061
2057
  isMultiple() {
2062
2058
  return !0;
2063
2059
  }
2064
- get(t = 1, e) {
2065
- return this.query().get(t, e);
2060
+ get(e = 1, t) {
2061
+ return this.query().get(e, t);
2066
2062
  }
2067
2063
  all() {
2068
2064
  return this.query().all();
@@ -2070,28 +2066,28 @@ class Tt extends it {
2070
2066
  first() {
2071
2067
  return this.query().first();
2072
2068
  }
2073
- find(t) {
2074
- return this.query().find(t);
2069
+ find(e) {
2070
+ return this.query().find(e);
2075
2071
  }
2076
- async saveManyQuietly(t) {
2077
- if (!Array.isArray(t) || !t.every(w))
2072
+ async saveManyQuietly(e) {
2073
+ if (!Array.isArray(e) || !e.every(w))
2078
2074
  throw new E("MorphMany.saveManyQuietly()");
2079
- if (!t.every((e) => e.getType() === this.getRelated().getSchemaName()))
2080
- throw new N("MorphMany.saveManyQuietly()", this.getRelated().getSchemaName(), t.map((e) => e.getType()).join(", "));
2081
- await Promise.all(t.map((e) => (e.setAttribute(this.getName() + "_id", this.parent.getKey()), e.setAttribute(this.getName() + "_type", this.parent.getType()), e.save())));
2075
+ if (!e.every((t) => t.getType() === this.getRelated().getSchemaName()))
2076
+ throw new N("MorphMany.saveManyQuietly()", this.getRelated().getSchemaName(), e.map((t) => t.getType()).join(", "));
2077
+ await Promise.all(e.map((t) => (t.setAttribute(this.getName() + "_id", this.parent.getKey()), t.setAttribute(this.getName() + "_type", this.parent.getType()), t.save())));
2082
2078
  }
2083
- async save(t) {
2084
- await this.saveQuietly(t), this.items ? this.items.push(t) : this.items = await this.all();
2079
+ async save(e) {
2080
+ await this.saveQuietly(e), this.items ? this.items.push(e) : this.items = await this.all();
2085
2081
  }
2086
- async saveMany(t) {
2087
- await this.saveManyQuietly(t);
2088
- const e = await this.all();
2089
- this.items ? this.items.splice(0, this.items.count(), ...e) : this.items = e;
2082
+ async saveMany(e) {
2083
+ await this.saveManyQuietly(e);
2084
+ const t = await this.all();
2085
+ this.items ? this.items.splice(0, this.items.count(), ...t) : this.items = t;
2090
2086
  }
2091
2087
  }
2092
- class At extends it {
2093
- constructor(t, e, s, r = null) {
2094
- if (super(t, e, s, r), this.meta = t, this.facades = e, this.parent = s, this.items = r, r !== null && !w(r))
2088
+ class Ne extends he {
2089
+ constructor(e, t, r, s = null) {
2090
+ if (super(e, t, r, s), this.meta = e, this.facades = t, this.parent = r, this.items = s, s !== null && !w(s))
2095
2091
  throw new E("MorphOne.constructor()", "Model or null");
2096
2092
  }
2097
2093
  isSingle() {
@@ -2103,11 +2099,11 @@ class At extends it {
2103
2099
  get() {
2104
2100
  return this.query().first();
2105
2101
  }
2106
- async save(t) {
2107
- await this.saveQuietly(t), this.items = t;
2102
+ async save(e) {
2103
+ await this.saveQuietly(e), this.items = e;
2108
2104
  }
2109
2105
  }
2110
- class vt extends rt {
2106
+ class Se extends ne {
2111
2107
  getRelated() {
2112
2108
  return this.facades.model.make(
2113
2109
  this.parent.getAttribute(this.getName() + "_type")
@@ -2121,12 +2117,12 @@ class vt extends rt {
2121
2117
  // this.of(this.parent.getAttribute(this.getName() + '_type') as string);
2122
2118
  // return super.query();
2123
2119
  // }
2124
- async associate(t) {
2125
- if (!w(t))
2120
+ async associate(e) {
2121
+ if (!w(e))
2126
2122
  throw new E("MorphTo.associate()");
2127
- return t.exists || await t.save(), this.parent.update({
2128
- [this.getName() + "_id"]: t.getKey(),
2129
- [this.getName() + "_type"]: t.getType()
2123
+ return e.exists || await e.save(), this.parent.update({
2124
+ [this.getName() + "_id"]: e.getKey(),
2125
+ [this.getName() + "_type"]: e.getType()
2130
2126
  });
2131
2127
  }
2132
2128
  dissociate() {
@@ -2136,84 +2132,84 @@ class vt extends rt {
2136
2132
  });
2137
2133
  }
2138
2134
  }
2139
- class Rt extends st {
2140
- constructor(t, e, s, r = null) {
2141
- super(t, e, s, r), this.meta = t, this.facades = e, this.parent = s, this.items = r;
2135
+ class Be extends oe {
2136
+ constructor(e, t, r, s = null) {
2137
+ super(e, t, r, s), this.meta = e, this.facades = t, this.parent = r, this.items = s;
2142
2138
  }
2143
2139
  query() {
2144
- const t = super.query(), e = this.guessInverseRelation();
2145
- return t.where(e + "_id", this.parent.getKey()), t.where(e + "_type", this.parent.getType()), t.lock(`filters.${e}_id`), t.lock(`filters.${e}_type`), t;
2140
+ const e = super.query(), t = this.guessInverseRelation();
2141
+ return e.where(t + "_id", this.parent.getKey()), e.where(t + "_type", this.parent.getType()), e.lock(`where.${t}_id`), e.lock(`where.${t}_type`), e;
2146
2142
  }
2147
2143
  }
2148
- class nt {
2149
- constructor(t) {
2144
+ class ue {
2145
+ constructor(e) {
2150
2146
  p(this, "_models", {});
2151
- this._schema = t;
2152
- }
2153
- boot(t) {
2154
- this._schema && (Object.keys(this._schema).forEach((e) => {
2155
- const s = this[`model${f.upperFirst(f.camelCase(e))}`];
2156
- if (typeof this.model != "function" || typeof s != "function")
2157
- throw new _("ModelFacade");
2158
- const r = this.model(
2159
- xt(t.make(), e),
2160
- e
2161
- ), i = s(r);
2162
- this._models[e] = _t(t.make(), e, i);
2147
+ this._schema = e;
2148
+ }
2149
+ boot(e) {
2150
+ this._schema && (Object.keys(this._schema).forEach((t) => {
2151
+ const r = this[`model${f.upperFirst(f.camelCase(t))}`];
2152
+ if (typeof this.model != "function" || typeof r != "function")
2153
+ throw new M("ModelFacade");
2154
+ const s = this.model(
2155
+ $e(e.make(), t),
2156
+ t
2157
+ ), i = r(s);
2158
+ this._models[t] = Te(e.make(), t, i);
2163
2159
  }), this.reducer("relationMap", () => ({
2164
- BelongsTo: rt,
2165
- BelongsToMany: st,
2166
- HasOne: Mt,
2167
- HasMany: $t,
2168
- MorphMany: Tt,
2169
- MorphOne: At,
2170
- MorphTo: vt,
2171
- MorphToMany: Rt
2160
+ BelongsTo: ne,
2161
+ BelongsToMany: oe,
2162
+ HasOne: Ae,
2163
+ HasMany: ve,
2164
+ MorphMany: Re,
2165
+ MorphOne: Ne,
2166
+ MorphTo: Se,
2167
+ MorphToMany: Be
2172
2168
  }), 0));
2173
2169
  }
2174
- schema(t) {
2175
- if (!this._schema || t && !this._schema[t])
2176
- throw new C(t || "undefined");
2177
- return t ? this._schema[t] : this._schema;
2170
+ schema(e) {
2171
+ if (!this._schema || e && !this._schema[e])
2172
+ throw new C(e || "undefined");
2173
+ return e ? this._schema[e] : this._schema;
2178
2174
  }
2179
- make(t) {
2180
- if (t && !this._models[t])
2181
- throw new C(t);
2182
- return t ? this._models[t] : this._models;
2175
+ make(e) {
2176
+ if (e && !this._models[e])
2177
+ throw new C(e);
2178
+ return e ? this._models[e] : this._models;
2183
2179
  }
2184
2180
  toString() {
2185
2181
  return "model";
2186
2182
  }
2187
2183
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2188
- on(t, e) {
2184
+ on(e, t) {
2189
2185
  throw new y();
2190
2186
  }
2191
2187
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2192
- once(t, e) {
2188
+ once(e, t) {
2193
2189
  throw new y();
2194
2190
  }
2195
2191
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2196
- emit(t, e) {
2192
+ emit(e, t) {
2197
2193
  throw new y();
2198
2194
  }
2199
2195
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2200
- reducer(t, e, s) {
2196
+ reducer(e, t, r) {
2201
2197
  throw new y();
2202
2198
  }
2203
2199
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2204
- removeReducer(t) {
2200
+ removeReducer(e) {
2205
2201
  throw new y();
2206
2202
  }
2207
2203
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2208
- getReducer(t) {
2204
+ getReducer(e) {
2209
2205
  throw new y();
2210
2206
  }
2211
2207
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2212
- hasReducer(t) {
2208
+ hasReducer(e) {
2213
2209
  throw new y();
2214
2210
  }
2215
2211
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2216
- clearReducer(t) {
2212
+ clearReducer(e) {
2217
2213
  throw new y();
2218
2214
  }
2219
2215
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -2221,262 +2217,261 @@ class nt {
2221
2217
  throw new y();
2222
2218
  }
2223
2219
  }
2224
- p(nt, "name", "ModelFacade");
2225
- const Nt = A(et(nt));
2226
- class ot extends Error {
2220
+ p(ue, "name", "ModelFacade");
2221
+ const qe = A(ie(ue));
2222
+ class ae extends Error {
2227
2223
  constructor() {
2228
2224
  super("[Luminix] Embed element not found. Make sure to include the `@luminixEmbed()` directive in your Blade template.");
2229
2225
  }
2230
2226
  }
2231
- p(ot, "name", "NoEmbedException");
2232
- const ut = (n, t = "data") => {
2227
+ p(ae, "name", "NoEmbedException");
2228
+ const le = (n, e = "data") => {
2233
2229
  if (!document.querySelector("#luminix-embed"))
2234
- throw new ot();
2235
- const e = document.getElementById(`luminix-${t}::` + n);
2236
- return e ? e.dataset.json && e.dataset.value ? JSON.parse(e.dataset.value) : e.dataset.value : null;
2237
- }, X = A(v), St = (n) => mt(n) && n.response !== void 0 && n.response.data !== null && "message" in n.response.data && typeof n.response.data.message == "string" && "errors" in n.response.data && typeof n.response.data.errors == "object" && n.response.data.errors !== null && Object.values(n.response.data.errors).every((t) => Array.isArray(t) && t.every((e) => typeof e == "string")) && n.response.status === 422;
2238
- let Bt = class {
2230
+ throw new ae();
2231
+ const t = document.getElementById(`luminix-${e}::` + n);
2232
+ return t ? t.dataset.json && t.dataset.value ? JSON.parse(t.dataset.value) : t.dataset.value : null;
2233
+ }, Y = A(v), Ie = (n) => we(n) && n.response !== void 0 && n.response.data !== null && "message" in n.response.data && typeof n.response.data.message == "string" && "errors" in n.response.data && typeof n.response.data.errors == "object" && n.response.data.errors !== null && Object.values(n.response.data.errors).every((e) => Array.isArray(e) && e.every((t) => typeof t == "string")) && n.response.status === 422;
2234
+ let Ke = class {
2239
2235
  constructor() {
2240
2236
  p(this, "bags");
2241
- const t = {};
2242
- document.querySelectorAll('#luminix-embed [id^="luminix-error"]').forEach((s) => {
2243
- const i = s.id.replace("luminix-error::", "");
2244
- t[i] = ut(i, "error");
2237
+ const e = {};
2238
+ document.querySelectorAll('#luminix-embed [id^="luminix-error"]').forEach((r) => {
2239
+ const i = r.id.replace("luminix-error::", "");
2240
+ e[i] = le(i, "error");
2245
2241
  }), this.bags = {
2246
- default: new X(t)
2242
+ default: new Y(e)
2247
2243
  };
2248
2244
  }
2249
- bag(t = "default") {
2250
- return this.bags[t] || (this.bags[t] = new X({})), this.bags[t];
2245
+ bag(e = "default") {
2246
+ return this.bags[e] || (this.bags[e] = new Y({})), this.bags[e];
2251
2247
  }
2252
- add(t, e, s = "default") {
2253
- this.bag(s).set(t, e);
2248
+ add(e, t, r = "default") {
2249
+ this.bag(r).set(e, t);
2254
2250
  }
2255
- set(t, e = "default") {
2256
- this.bag(e).set(".", t);
2251
+ set(e, t = "default") {
2252
+ this.bag(t).set(".", e);
2257
2253
  }
2258
- all(t = "default") {
2259
- return this.bag(t).all();
2254
+ all(e = "default") {
2255
+ return this.bag(e).all();
2260
2256
  }
2261
- get(t, e = "default") {
2262
- return this.bag(e).get(t, null);
2257
+ get(e, t = "default") {
2258
+ return this.bag(t).get(e, null);
2263
2259
  }
2264
- clear(t = "default") {
2265
- this.bag(t).set(".", {});
2260
+ clear(e = "default") {
2261
+ this.bag(e).set(".", {});
2266
2262
  }
2267
2263
  };
2268
- class ht extends Error {
2269
- constructor(t) {
2270
- super(`[Luminix] Route "${t}" not found`);
2264
+ class ce extends Error {
2265
+ constructor(e) {
2266
+ super(`[Luminix] Route "${e}" not found`);
2271
2267
  }
2272
2268
  }
2273
- p(ht, "name", "RouteNotFoundException");
2274
- class qt {
2275
- constructor(t, e, s = "") {
2276
- this.routes = t, this.error = e, this.appUrl = s;
2269
+ p(ce, "name", "RouteNotFoundException");
2270
+ class je {
2271
+ constructor(e, t, r = "") {
2272
+ this.routes = e, this.error = t, this.appUrl = r;
2277
2273
  }
2278
- isRouteTuple(t) {
2279
- if (!Array.isArray(t) || t.length < 2)
2274
+ isRouteTuple(e) {
2275
+ if (!Array.isArray(e) || e.length < 2)
2280
2276
  return !1;
2281
- const [e, ...s] = t;
2282
- if (typeof e != "string")
2277
+ const [t, ...r] = e;
2278
+ if (typeof t != "string")
2283
2279
  return !1;
2284
- const r = ["get", "post", "put", "patch", "delete"];
2285
- return !!s.every((i) => r.includes(i));
2280
+ const s = ["get", "post", "put", "patch", "delete"];
2281
+ return !!r.every((i) => s.includes(i));
2286
2282
  }
2287
- extractGenerator(t) {
2288
- let e, s = !1;
2289
- return Array.isArray(t) ? [e, s] = t : e = t, [e, s];
2283
+ extractGenerator(e) {
2284
+ let t, r = !1;
2285
+ return Array.isArray(e) ? [t, r] = e : t = e, [t, r];
2290
2286
  }
2291
- get(t) {
2292
- if (!this.exists(t))
2293
- throw new ht(t);
2294
- return f.get(this.routes, t);
2287
+ get(e) {
2288
+ if (!this.exists(e))
2289
+ throw new ce(e);
2290
+ return f.get(this.routes, e);
2295
2291
  }
2296
- url(t) {
2297
- const [e, s] = this.extractGenerator(t), r = this.get(e)[0].replace(/^\/|\/$/g, ""), i = /{([^}]+)}/g;
2298
- if (s === !1) {
2292
+ url(e) {
2293
+ const [t, r] = this.extractGenerator(e), s = this.get(t)[0].replace(/^\/|\/$/g, ""), i = /{([^}]+)}/g;
2294
+ if (r === !1) {
2299
2295
  if (typeof this.replaceRouteParams != "function")
2300
- throw new _("RouteFacade");
2301
- return this.appUrl + this.replaceRouteParams(`/${r}`);
2296
+ throw new M("RouteFacade");
2297
+ return this.appUrl + this.replaceRouteParams(`/${s}`);
2302
2298
  }
2303
- const h = r.match(i), l = h ? h.map((m) => m.slice(1, -1)) : [], a = Object.keys(s), d = l.filter((m) => !a.includes(m)), g = a.filter((m) => !l.includes(m));
2299
+ const u = s.match(i), a = u ? u.map((m) => m.slice(1, -1)) : [], c = Object.keys(r), d = a.filter((m) => !c.includes(m)), g = c.filter((m) => !a.includes(m));
2304
2300
  if (d.length > 0)
2305
2301
  throw new TypeError(`Missing values for parameter(s): ${d.join(", ")}`);
2306
2302
  if (g.length > 0)
2307
2303
  throw new TypeError(`Unexpected parameters: ${g.join(", ")}`);
2308
- const b = l.reduce((m, M) => m.replace(`{${M}}`, `${s[M]}`), r);
2304
+ const b = a.reduce((m, x) => m.replace(`{${x}}`, `${r[x]}`), s);
2309
2305
  return this.appUrl + `/${b}`;
2310
2306
  }
2311
- methods(t) {
2312
- const [e] = this.extractGenerator(t);
2313
- return this.get(e).slice(1);
2307
+ methods(e) {
2308
+ const [t] = this.extractGenerator(e);
2309
+ return this.get(t).slice(1);
2314
2310
  }
2315
- exists(t) {
2316
- return f.has(this.routes, t) && this.isRouteTuple(f.get(this.routes, t));
2311
+ exists(e) {
2312
+ return f.has(this.routes, e) && this.isRouteTuple(f.get(this.routes, e));
2317
2313
  }
2318
- async call(t, e = {}) {
2314
+ async call(e, t = {}) {
2319
2315
  if (typeof this.axiosOptions != "function" || typeof this.axiosError != "function")
2320
- throw new _("RouteFacade");
2321
- const [s, r] = this.extractGenerator(t), [, ...i] = this.get(s), h = this.url(r ? [s, r] : s), l = this.axiosOptions(e, s), { method: a = i[0], errorBag: d = "route.call", ...g } = l, { data: b, ...m } = g;
2316
+ throw new M("RouteFacade");
2317
+ const [r, s] = this.extractGenerator(e), [, ...i] = this.get(r), u = this.url(s ? [r, s] : r), a = this.axiosOptions(t, r), { method: c = i[0], errorBag: d = "route.call", ...g } = a, { data: b, ...m } = g;
2322
2318
  this.error.clear(d);
2323
2319
  try {
2324
- return ["get", "delete"].includes(a) ? await K[a](h, g) : await K[a](h, b, m);
2325
- } catch (M) {
2326
- if (St(M)) {
2327
- const { errors: at } = M.response.data;
2328
- this.error.set(Object.entries(at).reduce((W, [lt, ct]) => (W[lt] = ct.join(" "), W), {}));
2329
- } else
2330
- K.isAxiosError(M) && this.error.set(
2331
- this.axiosError({ axios: M.message }, {
2332
- error: M,
2333
- name: s,
2334
- replace: r,
2335
- config: e
2336
- }),
2337
- d
2338
- );
2339
- throw M;
2320
+ return ["get", "delete"].includes(c) ? await K[c](u, g) : await K[c](u, b, m);
2321
+ } catch (x) {
2322
+ if (Ie(x)) {
2323
+ const { errors: fe } = x.response.data;
2324
+ this.error.set(Object.entries(fe).reduce((W, [de, pe]) => (W[de] = pe.join(" "), W), {}));
2325
+ } else K.isAxiosError(x) && this.error.set(
2326
+ this.axiosError({ axios: x.message }, {
2327
+ error: x,
2328
+ name: r,
2329
+ replace: s,
2330
+ config: t
2331
+ }),
2332
+ d
2333
+ );
2334
+ throw x;
2340
2335
  }
2341
2336
  }
2342
2337
  toString() {
2343
2338
  return "route";
2344
2339
  }
2345
2340
  }
2346
- const It = et(qt);
2347
- class Kt {
2341
+ const Fe = ie(je);
2342
+ class Pe {
2348
2343
  constructor() {
2349
2344
  p(this, "facades", {});
2350
2345
  p(this, "booted", !1);
2351
2346
  p(this, "_plugins", []);
2352
2347
  }
2353
- make(t = void 0) {
2354
- if (!t)
2348
+ make(e = void 0) {
2349
+ if (!e)
2355
2350
  return this.facades;
2356
- if (t in this.facades)
2357
- return this.facades[t];
2351
+ if (e in this.facades)
2352
+ return this.facades[e];
2358
2353
  }
2359
- has(t) {
2360
- return !!this.facades[t];
2354
+ has(e) {
2355
+ return !!this.facades[e];
2361
2356
  }
2362
- bind(t, e) {
2363
- this.facades[t] || (this.facades[t] = e);
2357
+ bind(e, t) {
2358
+ this.facades[e] || (this.facades[e] = t);
2364
2359
  }
2365
2360
  plugins() {
2366
2361
  return this._plugins;
2367
2362
  }
2368
- async boot(t = {}) {
2369
- var l, a, d, g, b;
2363
+ async boot(e = {}) {
2364
+ var a, c, d, g, b;
2370
2365
  if (this.booted)
2371
2366
  throw new window.Error("[Luminix] App already booted");
2372
- this.booted = !0, (l = t.app) != null && l.debug && console.log("[Luminix] Booting started..."), this.emit("init", {
2367
+ this.booted = !0, (a = e.app) != null && a.debug && console.log("[Luminix] Booting started..."), this.emit("init", {
2373
2368
  register: (m) => {
2374
2369
  this._plugins.push(m), typeof m.register == "function" && m.register(this);
2375
2370
  }
2376
2371
  });
2377
- const e = (((a = t.app) == null ? void 0 : a.url) ?? "") + (((d = t.app) == null ? void 0 : d.bootUrl) ?? "/luminix-api/init");
2378
- if (typeof e == "string" && !document.getElementById("luminix-data::config")) {
2379
- const { data: m } = await K.get(e);
2380
- m && typeof m == "object" && f.merge(t, m);
2372
+ const t = (((c = e.app) == null ? void 0 : c.url) ?? "") + (((d = e.app) == null ? void 0 : d.bootUrl) ?? "/luminix-api/init");
2373
+ if (typeof t == "string" && !document.getElementById("luminix-data::config")) {
2374
+ const { data: m } = await K.get(t);
2375
+ m && typeof m == "object" && f.merge(e, m);
2381
2376
  } else if (document.getElementById("luminix-data::config")) {
2382
- const m = ut("config");
2383
- m && typeof m == "object" && f.merge(t, m);
2384
- }
2385
- this.bind("log", new yt(!!((g = t.app) != null && g.debug)));
2386
- const { log: s } = this.facades, {
2387
- manifest: { routes: r = {}, models: i = {} } = {},
2388
- ...h
2389
- } = t;
2390
- this.bind("config", new v(h)), this.facades.config.has("auth.user") || this.facades.config.set("auth.user", null), this.facades.config.lock("auth.user"), this.bind("error", new Bt()), this.bind("route", new It(r, this.facades.error, ((b = t.app) == null ? void 0 : b.url) ?? "")), this.bind("model", new Nt(i)), this.bind("auth", new gt(this)), this.emit("booting");
2377
+ const m = le("config");
2378
+ m && typeof m == "object" && f.merge(e, m);
2379
+ }
2380
+ this.bind("log", new Ee(!!((g = e.app) != null && g.debug)));
2381
+ const { log: r } = this.facades, {
2382
+ manifest: { routes: s = {}, models: i = {} } = {},
2383
+ ...u
2384
+ } = e;
2385
+ this.bind("config", new v(u)), this.facades.config.has("auth.user") || this.facades.config.set("auth.user", null), this.facades.config.lock("auth.user"), this.bind("error", new Ke()), this.bind("route", new Fe(s, this.facades.error, ((b = e.app) == null ? void 0 : b.url) ?? "")), this.bind("model", new qe(i)), this.bind("auth", new be(this)), this.emit("booting");
2391
2386
  for (const m of Object.values(this.facades))
2392
2387
  typeof m == "object" && m !== null && "boot" in m && typeof m.boot == "function" && m.boot(this);
2393
2388
  for (const m of this._plugins)
2394
2389
  typeof m.boot == "function" && m.boot(this.facades);
2395
- return s.info("[Luminix] App boot completed", {
2390
+ return r.info("[Luminix] App boot completed", {
2396
2391
  config: this.facades.config.all(),
2397
2392
  plugins: this._plugins,
2398
2393
  manifest: {
2399
- routes: r,
2394
+ routes: s,
2400
2395
  models: i
2401
2396
  }
2402
2397
  }), this.emit("booted"), this.facades;
2403
2398
  }
2404
2399
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2405
- on(t, e) {
2400
+ on(e, t) {
2406
2401
  throw new window.Error("Method not implemented.");
2407
2402
  }
2408
2403
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2409
- once(t, e) {
2404
+ once(e, t) {
2410
2405
  throw new window.Error("Method not implemented.");
2411
2406
  }
2412
2407
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2413
- emit(t, e) {
2408
+ emit(e, t) {
2414
2409
  throw new window.Error("Method not implemented.");
2415
2410
  }
2416
2411
  }
2417
- const jt = A(Kt);
2418
- let x;
2412
+ const Qe = A(Pe);
2413
+ let _;
2419
2414
  function R(n = void 0) {
2420
- if (x || (x = new jt()), typeof n != "string")
2415
+ if (_ || (_ = new Qe()), typeof n != "string")
2421
2416
  return {
2422
- boot: x.boot.bind(x),
2423
- make: x.make.bind(x),
2424
- plugins: x.plugins.bind(x),
2425
- on: x.once.bind(x)
2417
+ boot: _.boot.bind(_),
2418
+ make: _.make.bind(_),
2419
+ plugins: _.plugins.bind(_),
2420
+ on: _.once.bind(_)
2426
2421
  };
2427
- if (!x.has(n))
2428
- throw new Y(n);
2429
- return x.make(n);
2422
+ if (!_.has(n))
2423
+ throw new O(n);
2424
+ return _.make(n);
2430
2425
  }
2431
- function Dt() {
2426
+ function We() {
2432
2427
  return R("auth");
2433
2428
  }
2434
- function Ht(n) {
2435
- return c(n);
2429
+ function Ge(n) {
2430
+ return l(n);
2436
2431
  }
2437
- function Wt(n, t) {
2438
- const e = R("config");
2439
- return typeof n > "u" ? e : e.get(n, t);
2432
+ function Ve(n, e) {
2433
+ const t = R("config");
2434
+ return typeof n > "u" ? t : t.get(n, e);
2440
2435
  }
2441
- function Gt(n, t = "default") {
2442
- return n ? R().make("error").get(n, t) : R().make("error");
2436
+ function Xe(n, e = "default") {
2437
+ return n ? R().make("error").get(n, e) : R().make("error");
2443
2438
  }
2444
- function Vt(...n) {
2445
- const t = R("log");
2446
- return n.length ? t.debug(...n) : t;
2439
+ function Ye(...n) {
2440
+ const e = R("log");
2441
+ return n.length ? e.debug(...n) : e;
2447
2442
  }
2448
- function Xt(n) {
2449
- const t = R("model");
2450
- return n ? t.make(n) : t;
2443
+ function Ze(n) {
2444
+ const e = R("model");
2445
+ return n ? e.make(n) : e;
2451
2446
  }
2452
- function Yt(n, t = !1) {
2453
- const e = R("route");
2454
- return n ? t ? e.url([n, t]) : e.url(n) : e;
2447
+ function ze(n, e = !1) {
2448
+ const t = R("route");
2449
+ return n ? e ? t.url([n, e]) : t.url(n) : t;
2455
2450
  }
2456
- class Zt {
2451
+ class Oe {
2457
2452
  constructor() {
2458
2453
  p(this, "name");
2459
2454
  p(this, "version");
2460
2455
  }
2461
- register(t) {
2456
+ register(e) {
2462
2457
  }
2463
- boot(t) {
2458
+ boot(e) {
2464
2459
  }
2465
2460
  }
2466
2461
  export {
2467
2462
  A as HasEvents,
2468
- Zt as Plugin,
2463
+ Oe as Plugin,
2469
2464
  v as PropertyBag,
2470
- et as Reducible,
2465
+ ie as Reducible,
2471
2466
  R as app,
2472
- Dt as auth,
2473
- Ht as collect,
2474
- Wt as config,
2475
- Gt as error,
2467
+ We as auth,
2468
+ Ge as collect,
2469
+ Ve as config,
2470
+ Xe as error,
2476
2471
  T as isCollection,
2477
2472
  w as isModel,
2478
- St as isValidationError,
2479
- Vt as log,
2480
- Xt as model,
2481
- Yt as route
2473
+ Ie as isValidationError,
2474
+ Ye as log,
2475
+ Ze as model,
2476
+ ze as route
2482
2477
  };