@luminix/core 0.0.1-beta.1 → 0.0.1-beta.11

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