@ztimson/momentum 0.31.0 → 0.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -5,19 +5,19 @@
5
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
6
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
7
 
8
- var v = Object.defineProperty;
9
- var F = (n, e, t) => e in n ? v(n, e, { enumerable: true, configurable: true, writable: true, value: t }) : n[e] = t;
10
- var a = (n, e, t) => (F(n, typeof e != "symbol" ? e + "" : e, t), t);
11
- function W(n, e = false) {
8
+ var et = Object.defineProperty;
9
+ var nt = (n, t, e) => t in n ? et(n, t, { enumerable: true, configurable: true, writable: true, value: e }) : n[t] = e;
10
+ var i = (n, t, e) => (nt(n, typeof t != "symbol" ? t + "" : t, e), e);
11
+ function rt(n, t = false) {
12
12
  if (n == null)
13
13
  throw new Error("Cannot clean a NULL value");
14
- return Array.isArray(n) ? n = n.filter((t) => t != null) : Object.entries(n).forEach(([t, r]) => {
15
- (e && r === void 0 || !e && r == null) && delete n[t];
14
+ return Array.isArray(n) ? n = n.filter((e) => e != null) : Object.entries(n).forEach(([e, r]) => {
15
+ (t && r === void 0 || !t && r == null) && delete n[e];
16
16
  }), n;
17
17
  }
18
- function b(n, e) {
19
- const t = typeof n, r = typeof e;
20
- return t != "object" || n == null || r != "object" || e == null ? t == "function" && r == "function" ? n.toString() == e.toString() : n === e : Object.keys(n).length != Object.keys(e).length ? false : Object.keys(n).every((s) => b(n[s], e[s]));
18
+ function B(n, t) {
19
+ const e = typeof n, r = typeof t;
20
+ return e != "object" || n == null || r != "object" || t == null ? e == "function" && r == "function" ? n.toString() == t.toString() : n === t : Object.keys(n).length != Object.keys(t).length ? false : Object.keys(n).every((s) => B(n[s], t[s]));
21
21
  }
22
22
  function q(n) {
23
23
  try {
@@ -26,248 +26,311 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
26
26
  return n;
27
27
  }
28
28
  }
29
- class E extends Promise {
30
- constructor(t) {
31
- super((r, o) => t(
29
+ class m extends Promise {
30
+ constructor(e) {
31
+ super((r, o) => e(
32
32
  (s) => r(s),
33
33
  (s) => o(s),
34
34
  (s) => this.progress = s
35
35
  ));
36
- a(this, "listeners", []);
37
- a(this, "_progress", 0);
36
+ i(this, "listeners", []);
37
+ i(this, "_progress", 0);
38
38
  }
39
39
  get progress() {
40
40
  return this._progress;
41
41
  }
42
- set progress(t) {
43
- t != this._progress && (this._progress = t, this.listeners.forEach((r) => r(t)));
42
+ set progress(e) {
43
+ e != this._progress && (this._progress = e, this.listeners.forEach((r) => r(e)));
44
44
  }
45
- static from(t) {
46
- return t instanceof E ? t : new E((r, o) => t.then((...s) => r(...s)).catch((...s) => o(...s)));
45
+ static from(e) {
46
+ return e instanceof m ? e : new m((r, o) => e.then((...s) => r(...s)).catch((...s) => o(...s)));
47
47
  }
48
- from(t) {
49
- const r = E.from(t);
48
+ from(e) {
49
+ const r = m.from(e);
50
50
  return this.onProgress((o) => r.progress = o), r;
51
51
  }
52
- onProgress(t) {
53
- return this.listeners.push(t), this;
52
+ onProgress(e) {
53
+ return this.listeners.push(e), this;
54
54
  }
55
- then(t, r) {
56
- const o = super.then(t, r);
55
+ then(e, r) {
56
+ const o = super.then(e, r);
57
57
  return this.from(o);
58
58
  }
59
- catch(t) {
60
- return this.from(super.catch(t));
59
+ catch(e) {
60
+ return this.from(super.catch(e));
61
61
  }
62
- finally(t) {
63
- return this.from(super.finally(t));
62
+ finally(e) {
63
+ return this.from(super.finally(e));
64
64
  }
65
65
  }
66
- function Z(n, e) {
67
- const t = document.createElement("a");
68
- t.href = n, t.download = e, document.body.appendChild(t), t.click(), document.body.removeChild(t);
66
+ function ut(n, t) {
67
+ const e = document.createElement("a");
68
+ e.href = n, e.download = t, document.body.appendChild(e), e.click(), document.body.removeChild(e);
69
69
  }
70
- function Bt(n, e) {
71
- const t = URL.createObjectURL(n);
72
- Z(t, e), URL.revokeObjectURL(t);
70
+ function Tt(n, t) {
71
+ const e = URL.createObjectURL(n);
72
+ ut(e, t), URL.revokeObjectURL(e);
73
73
  }
74
- function bt(n = {}) {
75
- return new Promise((e) => {
76
- const t = document.createElement("input");
77
- t.type = "file", t.accept = n.accept || "*", t.style.display = "none", t.multiple = !!n.multiple, t.onblur = t.onchange = async () => {
78
- e(Array.from(t.files)), t.remove();
79
- }, document.body.appendChild(t), t.click();
74
+ function It(n = {}) {
75
+ return new Promise((t) => {
76
+ const e = document.createElement("input");
77
+ e.type = "file", e.accept = n.accept || "*", e.style.display = "none", e.multiple = !!n.multiple, e.onblur = e.onchange = async () => {
78
+ t(Array.from(e.files)), e.remove();
79
+ }, document.body.appendChild(e), e.click();
80
80
  });
81
81
  }
82
- function Rt(n) {
83
- return new E((e, t, r) => {
82
+ function $t(n) {
83
+ return new m((t, e, r) => {
84
84
  const o = new XMLHttpRequest(), s = new FormData();
85
- n.files.forEach((i) => s.append("file", i)), o.withCredentials = !!n.withCredentials, o.upload.addEventListener("progress", (i) => i.lengthComputable ? r(i.loaded / i.total) : null), o.addEventListener("loadend", () => e(q(o.responseText))), o.addEventListener("error", () => t(q(o.responseText))), o.addEventListener("timeout", () => t({ error: "Request timed out" })), o.open("POST", n.url), Object.entries(n.headers || {}).forEach(([i, p]) => o.setRequestHeader(i, p)), o.send(s);
85
+ n.files.forEach((c) => s.append("file", c)), o.withCredentials = !!n.withCredentials, o.upload.addEventListener("progress", (c) => c.lengthComputable ? r(c.loaded / c.total) : null), o.addEventListener("loadend", () => t(q(o.responseText))), o.addEventListener("error", () => e(q(o.responseText))), o.addEventListener("timeout", () => e({ error: "Request timed out" })), o.open("POST", n.url), Object.entries(n.headers || {}).forEach(([c, y]) => o.setRequestHeader(c, y)), o.send(s);
86
86
  });
87
87
  }
88
- class H {
88
+ class v {
89
89
  constructor() {
90
- a(this, "listeners", {});
90
+ i(this, "listeners", {});
91
91
  }
92
- static emit(e, ...t) {
93
- (this.listeners["*"] || []).forEach((r) => r(e, ...t)), (this.listeners[e.toString()] || []).forEach((r) => r(...t));
92
+ static emit(t, ...e) {
93
+ (this.listeners["*"] || []).forEach((r) => r(t, ...e)), (this.listeners[t.toString()] || []).forEach((r) => r(...e));
94
94
  }
95
- static off(e, t) {
96
- const r = e.toString();
97
- this.listeners[r] = (this.listeners[r] || []).filter((o) => o === t);
95
+ static off(t, e) {
96
+ const r = t.toString();
97
+ this.listeners[r] = (this.listeners[r] || []).filter((o) => o === e);
98
98
  }
99
- static on(e, t) {
99
+ static on(t, e) {
100
100
  var o;
101
- const r = e.toString();
102
- return this.listeners[r] || (this.listeners[r] = []), (o = this.listeners[r]) == null || o.push(t), () => this.off(e, t);
101
+ const r = t.toString();
102
+ return this.listeners[r] || (this.listeners[r] = []), (o = this.listeners[r]) == null || o.push(e), () => this.off(t, e);
103
103
  }
104
- static once(e, t) {
104
+ static once(t, e) {
105
105
  return new Promise((r) => {
106
- const o = this.on(e, (...s) => {
107
- r(s.length == 1 ? s[0] : s), t && t(...s), o();
106
+ const o = this.on(t, (...s) => {
107
+ r(s.length == 1 ? s[0] : s), e && e(...s), o();
108
108
  });
109
109
  });
110
110
  }
111
- emit(e, ...t) {
112
- (this.listeners["*"] || []).forEach((r) => r(e, ...t)), (this.listeners[e] || []).forEach((r) => r(...t));
111
+ emit(t, ...e) {
112
+ (this.listeners["*"] || []).forEach((r) => r(t, ...e)), (this.listeners[t] || []).forEach((r) => r(...e));
113
113
  }
114
- off(e, t) {
115
- this.listeners[e] = (this.listeners[e] || []).filter((r) => r === t);
114
+ off(t, e) {
115
+ this.listeners[t] = (this.listeners[t] || []).filter((r) => r === e);
116
116
  }
117
- on(e, t) {
117
+ on(t, e) {
118
118
  var r;
119
- return this.listeners[e] || (this.listeners[e] = []), (r = this.listeners[e]) == null || r.push(t), () => this.off(e, t);
119
+ return this.listeners[t] || (this.listeners[t] = []), (r = this.listeners[t]) == null || r.push(e), () => this.off(t, e);
120
120
  }
121
- once(e, t) {
121
+ once(t, e) {
122
122
  return new Promise((r) => {
123
- const o = this.on(e, (...s) => {
124
- r(s.length == 1 ? s[0] : s), t && t(...s), o();
123
+ const o = this.on(t, (...s) => {
124
+ r(s.length == 1 ? s[0] : s), e && e(...s), o();
125
125
  });
126
126
  });
127
127
  }
128
128
  }
129
- a(H, "listeners", {});
130
- class w extends Error {
131
- constructor(t, r) {
132
- super(t);
133
- a(this, "_code");
129
+ i(v, "listeners", {});
130
+ class p extends Error {
131
+ constructor(e, r) {
132
+ super(e);
133
+ i(this, "_code");
134
134
  r != null && (this._code = r);
135
135
  }
136
136
  get code() {
137
137
  return this._code || this.constructor.code;
138
138
  }
139
- set code(t) {
140
- this._code = t;
139
+ set code(e) {
140
+ this._code = e;
141
141
  }
142
- static from(t) {
143
- const r = Number(t.statusCode) ?? Number(t.code), o = new this(t.message || t.toString());
142
+ static from(e) {
143
+ const r = Number(e.statusCode) ?? Number(e.code), o = new this(e.message || e.toString());
144
144
  return Object.assign(o, {
145
- stack: t.stack,
146
- ...t,
145
+ stack: e.stack,
146
+ ...e,
147
147
  code: r ?? void 0
148
148
  });
149
149
  }
150
- static instanceof(t) {
151
- return t.constructor.code != null;
150
+ static instanceof(e) {
151
+ return e.constructor.code != null;
152
152
  }
153
153
  toString() {
154
154
  return this.message || super.toString();
155
155
  }
156
156
  }
157
- a(w, "code", 500);
158
- class X extends w {
159
- constructor(e = "Bad Request") {
160
- super(e);
157
+ i(p, "code", 500);
158
+ class F extends p {
159
+ constructor(t = "Bad Request") {
160
+ super(t);
161
161
  }
162
- static instanceof(e) {
163
- return e.constructor.code == this.code;
162
+ static instanceof(t) {
163
+ return t.constructor.code == this.code;
164
164
  }
165
165
  }
166
- a(X, "code", 400);
167
- class Q extends w {
168
- constructor(e = "Unauthorized") {
169
- super(e);
166
+ i(F, "code", 400);
167
+ class H extends p {
168
+ constructor(t = "Unauthorized") {
169
+ super(t);
170
170
  }
171
- static instanceof(e) {
172
- return e.constructor.code == this.code;
171
+ static instanceof(t) {
172
+ return t.constructor.code == this.code;
173
173
  }
174
174
  }
175
- a(Q, "code", 401);
176
- class _ extends w {
177
- constructor(e = "Forbidden") {
178
- super(e);
175
+ i(H, "code", 401);
176
+ class Y extends p {
177
+ constructor(t = "Payment Required") {
178
+ super(t);
179
179
  }
180
- static instanceof(e) {
181
- return e.constructor.code == this.code;
180
+ static instanceof(t) {
181
+ return t.constructor.code == this.code;
182
182
  }
183
183
  }
184
- a(_, "code", 403);
185
- class tt extends w {
186
- constructor(e = "Not Found") {
187
- super(e);
184
+ i(Y, "code", 402);
185
+ class W extends p {
186
+ constructor(t = "Forbidden") {
187
+ super(t);
188
188
  }
189
- static instanceof(e) {
190
- return e.constructor.code == this.code;
189
+ static instanceof(t) {
190
+ return t.constructor.code == this.code;
191
191
  }
192
192
  }
193
- a(tt, "code", 404);
194
- class et extends w {
195
- constructor(e = "Internal Server Error") {
196
- super(e);
193
+ i(W, "code", 403);
194
+ class J extends p {
195
+ constructor(t = "Not Found") {
196
+ super(t);
197
197
  }
198
- static instanceof(e) {
199
- return e.constructor.code == this.code;
198
+ static instanceof(t) {
199
+ return t.constructor.code == this.code;
200
+ }
201
+ }
202
+ i(J, "code", 404);
203
+ class z extends p {
204
+ constructor(t = "Method Not Allowed") {
205
+ super(t);
206
+ }
207
+ static instanceof(t) {
208
+ return t.constructor.code == this.code;
200
209
  }
201
210
  }
202
- a(et, "code", 500);
203
- const g = class g2 {
204
- constructor(e = {}) {
205
- a(this, "interceptors", {});
206
- a(this, "headers", {});
207
- a(this, "url");
208
- this.url = e.url ?? null, this.headers = e.headers || {}, e.interceptors && e.interceptors.forEach((t) => g2.addInterceptor(t));
209
- }
210
- static addInterceptor(e) {
211
- const t = Object.keys(g2.interceptors).length.toString();
212
- return g2.interceptors[t] = e, () => {
213
- g2.interceptors[t] = null;
211
+ i(z, "code", 405);
212
+ class K extends p {
213
+ constructor(t = "Not Acceptable") {
214
+ super(t);
215
+ }
216
+ static instanceof(t) {
217
+ return t.constructor.code == this.code;
218
+ }
219
+ }
220
+ i(K, "code", 406);
221
+ class V extends p {
222
+ constructor(t = "Internal Server Error") {
223
+ super(t);
224
+ }
225
+ static instanceof(t) {
226
+ return t.constructor.code == this.code;
227
+ }
228
+ }
229
+ i(V, "code", 500);
230
+ class Z extends p {
231
+ constructor(t = "Not Implemented") {
232
+ super(t);
233
+ }
234
+ static instanceof(t) {
235
+ return t.constructor.code == this.code;
236
+ }
237
+ }
238
+ i(Z, "code", 501);
239
+ class X extends p {
240
+ constructor(t = "Bad Gateway") {
241
+ super(t);
242
+ }
243
+ static instanceof(t) {
244
+ return t.constructor.code == this.code;
245
+ }
246
+ }
247
+ i(X, "code", 502);
248
+ class Q extends p {
249
+ constructor(t = "Service Unavailable") {
250
+ super(t);
251
+ }
252
+ static instanceof(t) {
253
+ return t.constructor.code == this.code;
254
+ }
255
+ }
256
+ i(Q, "code", 503);
257
+ class _ extends p {
258
+ constructor(t = "Gateway Timeout") {
259
+ super(t);
260
+ }
261
+ static instanceof(t) {
262
+ return t.constructor.code == this.code;
263
+ }
264
+ }
265
+ i(_, "code", 504);
266
+ const w = class w2 {
267
+ constructor(t = {}) {
268
+ i(this, "interceptors", {});
269
+ i(this, "headers", {});
270
+ i(this, "url");
271
+ this.url = t.url ?? null, this.headers = t.headers || {}, t.interceptors && t.interceptors.forEach((e) => w2.addInterceptor(e));
272
+ }
273
+ static addInterceptor(t) {
274
+ const e = Object.keys(w2.interceptors).length.toString();
275
+ return w2.interceptors[e] = t, () => {
276
+ w2.interceptors[e] = null;
214
277
  };
215
278
  }
216
- addInterceptor(e) {
217
- const t = Object.keys(this.interceptors).length.toString();
218
- return this.interceptors[t] = e, () => {
219
- this.interceptors[t] = null;
279
+ addInterceptor(t) {
280
+ const e = Object.keys(this.interceptors).length.toString();
281
+ return this.interceptors[e] = t, () => {
282
+ this.interceptors[e] = null;
220
283
  };
221
284
  }
222
- request(e = {}) {
285
+ request(t = {}) {
223
286
  var o;
224
- if (!this.url && !e.url)
287
+ if (!this.url && !t.url)
225
288
  throw new Error("URL needs to be set");
226
- let t = ((o = e.url) != null && o.startsWith("http") ? e.url : (this.url || "") + (e.url || "")).replace(/([^:]\/)\/+/g, "$1");
227
- if (e.fragment && (t.includes("#") ? t.replace(/#.*(\?|\n)/g, (s, i) => `#${e.fragment}${i}`) : t += "#" + e.fragment), e.query) {
228
- const s = Array.isArray(e.query) ? e.query : Object.keys(e.query).map((i) => ({ key: i, value: e.query[i] }));
229
- t += (t.includes("?") ? "&" : "?") + s.map((i) => `${i.key}=${i.value}`).join("&");
289
+ let e = ((o = t.url) != null && o.startsWith("http") ? t.url : (this.url || "") + (t.url || "")).replace(/([^:]\/)\/+/g, "$1");
290
+ if (t.fragment && (e.includes("#") ? e.replace(/#.*(\?|\n)/g, (s, c) => `#${t.fragment}${c}`) : e += "#" + t.fragment), t.query) {
291
+ const s = Array.isArray(t.query) ? t.query : Object.keys(t.query).map((c) => ({ key: c, value: t.query[c] }));
292
+ e += (e.includes("?") ? "&" : "?") + s.map((c) => `${c.key}=${c.value}`).join("&");
230
293
  }
231
- const r = W({
232
- "Content-Type": e.body ? e.body instanceof FormData ? "multipart/form-data" : "application/json" : void 0,
233
- ...g2.headers,
294
+ const r = rt({
295
+ "Content-Type": t.body ? t.body instanceof FormData ? "multipart/form-data" : "application/json" : void 0,
296
+ ...w2.headers,
234
297
  ...this.headers,
235
- ...e.headers
298
+ ...t.headers
236
299
  });
237
- return typeof e.body == "object" && e.body != null && r["Content-Type"] == "application/json" && (e.body = JSON.stringify(e.body)), new E((s, i, p) => {
238
- fetch(t, {
300
+ return typeof t.body == "object" && t.body != null && r["Content-Type"] == "application/json" && (t.body = JSON.stringify(t.body)), new m((s, c, y) => {
301
+ fetch(e, {
239
302
  headers: r,
240
- method: e.method || (e.body ? "POST" : "GET"),
241
- body: e.body
242
- }).then(async (c) => {
303
+ method: t.method || (t.body ? "POST" : "GET"),
304
+ body: t.body
305
+ }).then(async (u) => {
243
306
  var j, G;
244
- for (let u of [...Object.values(g2.interceptors), ...Object.values(this.interceptors)])
245
- await new Promise((O) => u(c, () => O()));
246
- const R = c.headers.get("Content-Length"), N = R ? parseInt(R, 10) : 0;
307
+ for (let a of [...Object.values(w2.interceptors), ...Object.values(this.interceptors)])
308
+ await new Promise((O) => a(u, () => O()));
309
+ const R = u.headers.get("Content-Length"), N = R ? parseInt(R, 10) : 0;
247
310
  let k = 0;
248
- const T = (j = c.body) == null ? void 0 : j.getReader(), Y = new ReadableStream({
249
- start(u) {
311
+ const T = (j = u.body) == null ? void 0 : j.getReader(), tt = new ReadableStream({
312
+ start(a) {
250
313
  function O() {
251
314
  T == null || T.read().then((x) => {
252
315
  if (x.done)
253
- return u.close();
254
- k += x.value.byteLength, p(k / N), u.enqueue(x.value), O();
255
- }).catch((x) => u.error(x));
316
+ return a.close();
317
+ k += x.value.byteLength, y(k / N), a.enqueue(x.value), O();
318
+ }).catch((x) => a.error(x));
256
319
  }
257
320
  O();
258
321
  }
259
322
  });
260
- if (c.data = new Response(Y), e.decode == null || e.decode) {
261
- const u = (G = c.headers.get("Content-Type")) == null ? void 0 : G.toLowerCase();
262
- u != null && u.includes("form") ? c.data = await c.data.formData() : u != null && u.includes("json") ? c.data = await c.data.json() : u != null && u.includes("text") ? c.data = await c.data.text() : u != null && u.includes("application") && (c.data = await c.data.blob());
323
+ if (u.data = new Response(tt), t.decode == null || t.decode) {
324
+ const a = (G = u.headers.get("Content-Type")) == null ? void 0 : G.toLowerCase();
325
+ a != null && a.includes("form") ? u.data = await u.data.formData() : a != null && a.includes("json") ? u.data = await u.data.json() : a != null && a.includes("text") ? u.data = await u.data.text() : a != null && a.includes("application") && (u.data = await u.data.blob());
263
326
  }
264
- c.ok ? s(c) : i(c);
327
+ u.ok ? s(u) : c(u);
265
328
  });
266
329
  });
267
330
  }
268
331
  };
269
- a(g, "interceptors", {}), a(g, "headers", {});
270
- let M = g;
332
+ i(w, "interceptors", {}), i(w, "headers", {});
333
+ let M = w;
271
334
  const A = {
272
335
  CLEAR: "\x1B[0m",
273
336
  BRIGHT: "\x1B[1m",
@@ -294,59 +357,59 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
294
357
  LIGHT_CYAN: "\x1B[96m",
295
358
  WHITE: "\x1B[97m"
296
359
  };
297
- var nt = /* @__PURE__ */ ((n) => (n[n.ERROR = 0] = "ERROR", n[n.WARN = 1] = "WARN", n[n.INFO = 2] = "INFO", n[n.LOG = 3] = "LOG", n[n.DEBUG = 4] = "DEBUG", n))(nt || {});
298
- const y = class y2 extends H {
299
- constructor(e) {
300
- super(), this.namespace = e;
360
+ var at = /* @__PURE__ */ ((n) => (n[n.ERROR = 0] = "ERROR", n[n.WARN = 1] = "WARN", n[n.INFO = 2] = "INFO", n[n.LOG = 3] = "LOG", n[n.DEBUG = 4] = "DEBUG", n))(at || {});
361
+ const g = class g2 extends v {
362
+ constructor(t) {
363
+ super(), this.namespace = t;
301
364
  }
302
- pad(e, t, r, o = false) {
303
- const s = e.toString(), i = t - s.length;
304
- if (i <= 0)
365
+ pad(t, e, r, o = false) {
366
+ const s = t.toString(), c = e - s.length;
367
+ if (c <= 0)
305
368
  return s;
306
- const p = Array(~~(i / r.length)).fill(r).join("");
307
- return o ? s + p : p + s;
369
+ const y = Array(~~(c / r.length)).fill(r).join("");
370
+ return o ? s + y : y + s;
308
371
  }
309
- format(...e) {
310
- const t = /* @__PURE__ */ new Date();
311
- return `${`${t.getFullYear()}-${t.getMonth() + 1}-${t.getDate()} ${this.pad(t.getHours().toString(), 2, "0")}:${this.pad(t.getMinutes().toString(), 2, "0")}:${this.pad(t.getSeconds().toString(), 2, "0")}.${this.pad(t.getMilliseconds().toString(), 3, "0", true)}`}${this.namespace ? ` [${this.namespace}]` : ""} ${e.join(" ")}`;
372
+ format(...t) {
373
+ const e = /* @__PURE__ */ new Date();
374
+ return `${`${e.getFullYear()}-${e.getMonth() + 1}-${e.getDate()} ${this.pad(e.getHours().toString(), 2, "0")}:${this.pad(e.getMinutes().toString(), 2, "0")}:${this.pad(e.getSeconds().toString(), 2, "0")}.${this.pad(e.getMilliseconds().toString(), 3, "0", true)}`}${this.namespace ? ` [${this.namespace}]` : ""} ${t.join(" ")}`;
312
375
  }
313
- debug(...e) {
314
- if (y2.LOG_LEVEL < 4)
376
+ debug(...t) {
377
+ if (g2.LOG_LEVEL < 4)
315
378
  return;
316
- const t = this.format(...e);
317
- y2.emit(4, t), console.debug(L.LIGHT_GREY + t + A.CLEAR);
379
+ const e = this.format(...t);
380
+ g2.emit(4, e), console.debug(L.LIGHT_GREY + e + A.CLEAR);
318
381
  }
319
- log(...e) {
320
- if (y2.LOG_LEVEL < 3)
382
+ log(...t) {
383
+ if (g2.LOG_LEVEL < 3)
321
384
  return;
322
- const t = this.format(...e);
323
- y2.emit(3, t), console.log(A.CLEAR + t);
385
+ const e = this.format(...t);
386
+ g2.emit(3, e), console.log(A.CLEAR + e);
324
387
  }
325
- info(...e) {
326
- if (y2.LOG_LEVEL < 2)
388
+ info(...t) {
389
+ if (g2.LOG_LEVEL < 2)
327
390
  return;
328
- const t = this.format(...e);
329
- y2.emit(2, t), console.info(L.BLUE + t + A.CLEAR);
391
+ const e = this.format(...t);
392
+ g2.emit(2, e), console.info(L.BLUE + e + A.CLEAR);
330
393
  }
331
- warn(...e) {
332
- if (y2.LOG_LEVEL < 1)
394
+ warn(...t) {
395
+ if (g2.LOG_LEVEL < 1)
333
396
  return;
334
- const t = this.format(...e);
335
- y2.emit(1, t), console.warn(L.YELLOW + t + A.CLEAR);
397
+ const e = this.format(...t);
398
+ g2.emit(1, e), console.warn(L.YELLOW + e + A.CLEAR);
336
399
  }
337
- error(...e) {
338
- if (y2.LOG_LEVEL < 0)
400
+ error(...t) {
401
+ if (g2.LOG_LEVEL < 0)
339
402
  return;
340
- const t = this.format(...e);
341
- y2.emit(0, t), console.error(L.RED + t + A.CLEAR);
403
+ const e = this.format(...t);
404
+ g2.emit(0, e), console.error(L.RED + e + A.CLEAR);
342
405
  }
343
406
  };
344
- a(y, "LOG_LEVEL", 4);
407
+ i(g, "LOG_LEVEL", 4);
345
408
  class Api extends M {
346
409
  constructor(url = location.origin, opts = {}) {
347
410
  opts.url = url;
348
411
  super(opts);
349
- __publicField(this, "emitter", new H());
412
+ __publicField(this, "emitter", new v());
350
413
  __publicField(this, "_token", null);
351
414
  __publicField(this, "emit", this.emitter.emit.bind(this.emitter));
352
415
  __publicField(this, "off", this.emitter.off.bind(this.emitter));
@@ -380,45 +443,45 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
380
443
  return req;
381
444
  }
382
445
  }
383
- var extendStatics = function(d, b2) {
384
- extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b3) {
385
- d2.__proto__ = b3;
386
- } || function(d2, b3) {
387
- for (var p in b3) if (Object.prototype.hasOwnProperty.call(b3, p)) d2[p] = b3[p];
446
+ var extendStatics = function(d, b) {
447
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
448
+ d2.__proto__ = b2;
449
+ } || function(d2, b2) {
450
+ for (var p2 in b2) if (Object.prototype.hasOwnProperty.call(b2, p2)) d2[p2] = b2[p2];
388
451
  };
389
- return extendStatics(d, b2);
452
+ return extendStatics(d, b);
390
453
  };
391
- function __extends(d, b2) {
392
- if (typeof b2 !== "function" && b2 !== null)
393
- throw new TypeError("Class extends value " + String(b2) + " is not a constructor or null");
394
- extendStatics(d, b2);
454
+ function __extends(d, b) {
455
+ if (typeof b !== "function" && b !== null)
456
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
457
+ extendStatics(d, b);
395
458
  function __() {
396
459
  this.constructor = d;
397
460
  }
398
- d.prototype = b2 === null ? Object.create(b2) : (__.prototype = b2.prototype, new __());
461
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
399
462
  }
400
463
  function __values(o) {
401
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
402
- if (m) return m.call(o);
464
+ var s = typeof Symbol === "function" && Symbol.iterator, m2 = s && o[s], i2 = 0;
465
+ if (m2) return m2.call(o);
403
466
  if (o && typeof o.length === "number") return {
404
467
  next: function() {
405
- if (o && i >= o.length) o = void 0;
406
- return { value: o && o[i++], done: !o };
468
+ if (o && i2 >= o.length) o = void 0;
469
+ return { value: o && o[i2++], done: !o };
407
470
  }
408
471
  };
409
472
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
410
473
  }
411
474
  function __read(o, n) {
412
- var m = typeof Symbol === "function" && o[Symbol.iterator];
413
- if (!m) return o;
414
- var i = m.call(o), r, ar = [], e;
475
+ var m2 = typeof Symbol === "function" && o[Symbol.iterator];
476
+ if (!m2) return o;
477
+ var i2 = m2.call(o), r, ar = [], e;
415
478
  try {
416
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
479
+ while ((n === void 0 || n-- > 0) && !(r = i2.next()).done) ar.push(r.value);
417
480
  } catch (error) {
418
481
  e = { error };
419
482
  } finally {
420
483
  try {
421
- if (r && !r.done && (m = i["return"])) m.call(i);
484
+ if (r && !r.done && (m2 = i2["return"])) m2.call(i2);
422
485
  } finally {
423
486
  if (e) throw e.error;
424
487
  }
@@ -426,10 +489,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
426
489
  return ar;
427
490
  }
428
491
  function __spreadArray(to, from, pack) {
429
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
430
- if (ar || !(i in from)) {
431
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
432
- ar[i] = from[i];
492
+ if (pack || arguments.length === 2) for (var i2 = 0, l = from.length, ar; i2 < l; i2++) {
493
+ if (ar || !(i2 in from)) {
494
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i2);
495
+ ar[i2] = from[i2];
433
496
  }
434
497
  }
435
498
  return to.concat(ar || Array.prototype.slice.call(from));
@@ -454,8 +517,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
454
517
  var UnsubscriptionError = createErrorClass(function(_super) {
455
518
  return function UnsubscriptionErrorImpl(errors) {
456
519
  _super(this);
457
- this.message = errors ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function(err, i) {
458
- return i + 1 + ") " + err.toString();
520
+ this.message = errors ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function(err, i2) {
521
+ return i2 + 1 + ") " + err.toString();
459
522
  }).join("\n ") : "";
460
523
  this.name = "UnsubscriptionError";
461
524
  this.errors = errors;
@@ -1096,7 +1159,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1096
1159
  ActionType2[ActionType2["PUT"] = 6] = "PUT";
1097
1160
  return ActionType2;
1098
1161
  })(ActionType || {});
1099
- class Actions extends H {
1162
+ class Actions extends v {
1100
1163
  constructor(api) {
1101
1164
  super();
1102
1165
  __publicField(this, "api");
@@ -1111,7 +1174,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1111
1174
  }
1112
1175
  delete(id) {
1113
1176
  return this.api.request({ url: `/api/actions/${id}`, method: "DELETE" }).then(() => {
1114
- this.cache = this.cache.filter((a2) => a2._id != id);
1177
+ this.cache = this.cache.filter((a) => a._id != id);
1115
1178
  this.emit("DELETE", id);
1116
1179
  });
1117
1180
  }
@@ -1123,10 +1186,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1123
1186
  });
1124
1187
  }
1125
1188
  read(id, reload = false) {
1126
- const cached = this.cache.find((a2) => a2._id == id);
1189
+ const cached = this.cache.find((a) => a._id == id);
1127
1190
  if (!reload && cached) return Promise.resolve(cached);
1128
1191
  return this.api.request({ url: `/api/actions/${id}` }).then((action) => {
1129
- if (action) this.cache = this.cache.filter((a2) => a2._id != id).concat([action]);
1192
+ if (action) this.cache = this.cache.filter((a) => a._id != id).concat([action]);
1130
1193
  this.emit("READ", action);
1131
1194
  return action;
1132
1195
  });
@@ -1144,13 +1207,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1144
1207
  method: "POST",
1145
1208
  body: action
1146
1209
  }).then((action2) => {
1147
- if (action2) this.cache = this.cache.filter((a2) => a2._id != (action2 == null ? void 0 : action2._id)).concat([action2]);
1210
+ if (action2) this.cache = this.cache.filter((a) => a._id != (action2 == null ? void 0 : action2._id)).concat([action2]);
1148
1211
  this.emit("UPDATE", action2);
1149
1212
  return action2;
1150
1213
  });
1151
1214
  }
1152
1215
  }
1153
- class Ai extends H {
1216
+ class Ai extends v {
1154
1217
  constructor(api) {
1155
1218
  super();
1156
1219
  __publicField(this, "api");
@@ -1166,7 +1229,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1166
1229
  });
1167
1230
  }
1168
1231
  }
1169
- class Analytics extends H {
1232
+ class Analytics extends v {
1170
1233
  constructor(api) {
1171
1234
  super();
1172
1235
  __publicField(this, "api");
@@ -1191,13 +1254,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1191
1254
  return this.api.request({ url: `/api/auth/totp/${username}`, method: "POST" });
1192
1255
  }
1193
1256
  setup(username, method = "app", totp) {
1194
- return this.api.request({ url: `/api/auth/totp/${username}`, body: W({
1257
+ return this.api.request({ url: `/api/auth/totp/${username}`, body: rt({
1195
1258
  method,
1196
1259
  totp
1197
1260
  }) });
1198
1261
  }
1199
1262
  }
1200
- class Auth extends H {
1263
+ class Auth extends v {
1201
1264
  constructor(api, opts) {
1202
1265
  var _a;
1203
1266
  super();
@@ -1242,7 +1305,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1242
1305
  return this.$user.value;
1243
1306
  }
1244
1307
  set user(user) {
1245
- if (!b(this.user, user)) {
1308
+ if (!B(this.user, user)) {
1246
1309
  const u = user ? user : null;
1247
1310
  this.$user.next(u);
1248
1311
  this.emit("USER", u);
@@ -1328,7 +1391,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1328
1391
  });
1329
1392
  }
1330
1393
  }
1331
- class Data extends H {
1394
+ class Data extends v {
1332
1395
  constructor(api) {
1333
1396
  super();
1334
1397
  __publicField(this, "api");
@@ -1373,7 +1436,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1373
1436
  });
1374
1437
  }
1375
1438
  }
1376
- class Email extends H {
1439
+ class Email extends v {
1377
1440
  constructor(api) {
1378
1441
  super();
1379
1442
  __publicField(this, "api");
@@ -1388,7 +1451,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1388
1451
  });
1389
1452
  }
1390
1453
  }
1391
- class Groups extends H {
1454
+ class Groups extends v {
1392
1455
  constructor(api) {
1393
1456
  super();
1394
1457
  __publicField(this, "api");
@@ -1470,32 +1533,32 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1470
1533
  return this.api.request({ url: `/api/logs/server${query ? `?${query}` : ""}` }).then((resp) => resp);
1471
1534
  }
1472
1535
  debug(...logs) {
1473
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(nt.DEBUG, logs) }).then(() => {
1536
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.DEBUG, logs) }).then(() => {
1474
1537
  }).catch(() => {
1475
1538
  });
1476
1539
  }
1477
1540
  log(...logs) {
1478
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(nt.LOG, logs) }).then(() => {
1541
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.LOG, logs) }).then(() => {
1479
1542
  }).catch(() => {
1480
1543
  });
1481
1544
  }
1482
1545
  info(...logs) {
1483
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(nt.INFO, logs) }).then(() => {
1546
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.INFO, logs) }).then(() => {
1484
1547
  }).catch(() => {
1485
1548
  });
1486
1549
  }
1487
1550
  warn(...logs) {
1488
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(nt.WARN, logs) }).then(() => {
1551
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.WARN, logs) }).then(() => {
1489
1552
  }).catch(() => {
1490
1553
  });
1491
1554
  }
1492
1555
  error(...logs) {
1493
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(nt.ERROR, logs) }).then(() => {
1556
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.ERROR, logs) }).then(() => {
1494
1557
  }).catch(() => {
1495
1558
  });
1496
1559
  }
1497
1560
  }
1498
- class Payments extends H {
1561
+ class Payments extends v {
1499
1562
  constructor(api, secret) {
1500
1563
  super();
1501
1564
  __publicField(this, "api");
@@ -1536,7 +1599,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1536
1599
  return history;
1537
1600
  }
1538
1601
  }
1539
- class Pdf extends H {
1602
+ class Pdf extends v {
1540
1603
  constructor(api) {
1541
1604
  super();
1542
1605
  __publicField(this, "api");
@@ -1546,20 +1609,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1546
1609
  const blob = await resp.blob();
1547
1610
  if (fileName) {
1548
1611
  const url = URL.createObjectURL(blob);
1549
- Z(url, fileName.endsWith(".pdf") ? fileName : fileName + ".pdf");
1612
+ ut(url, fileName.endsWith(".pdf") ? fileName : fileName + ".pdf");
1550
1613
  URL.revokeObjectURL(url);
1551
1614
  }
1552
1615
  this.emit("CREATE", blob);
1553
1616
  return blob;
1554
1617
  }
1555
1618
  fromHtml(content, opts = {}) {
1556
- return this.api.request({ url: `/api/pdf`, body: { html: content } }).then((resp) => this.handleResponse(resp, opts.download ? opts.fileName || (/* @__PURE__ */ new Date()).toISOString() : void 0));
1619
+ return this.api.request({ url: `/api/pdf`, body: { html: content }, decode: false }).then((resp) => this.handleResponse(resp, opts.download ? opts.fileName || (/* @__PURE__ */ new Date()).toISOString() : void 0));
1557
1620
  }
1558
1621
  fromTemplate(template, data, opts = {}) {
1559
- return this.api.request({ url: `/api/pdf${template}`, body: data }).then((resp) => this.handleResponse(resp, opts.download ? opts.fileName || (/* @__PURE__ */ new Date()).toISOString() : void 0));
1622
+ return this.api.request({ url: `/api/pdf${template}`, body: data, decode: false }).then((resp) => this.handleResponse(resp, opts.download ? opts.fileName || (/* @__PURE__ */ new Date()).toISOString() : void 0));
1560
1623
  }
1561
1624
  fromUrl(url, opts = {}) {
1562
- return this.api.request({ url: `/api/pdf?url=${url}` }).then((resp) => this.handleResponse(resp, opts.download ? opts.fileName || (/* @__PURE__ */ new Date()).toISOString() : void 0));
1625
+ return this.api.request({ url: `/api/pdf`, body: { url }, decode: false }).then((resp) => this.handleResponse(resp, opts.download ? opts.fileName || (/* @__PURE__ */ new Date()).toISOString() : void 0));
1563
1626
  }
1564
1627
  }
1565
1628
  const _Socket = class _Socket {
@@ -1609,7 +1672,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1609
1672
  };
1610
1673
  __publicField(_Socket, "timeout", 1e4);
1611
1674
  let Socket = _Socket;
1612
- class Storage extends H {
1675
+ class Storage extends v {
1613
1676
  constructor(api) {
1614
1677
  super();
1615
1678
  __publicField(this, "api");
@@ -1629,37 +1692,37 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1629
1692
  });
1630
1693
  }
1631
1694
  open(path, target = "_blank") {
1632
- const p = (path.startsWith("/api/storage/") ? path : "/api/storage/" + path).replaceAll(/\/{2,}/g, "/");
1633
- const link = `${this.api.url}${p}${this.api.token ? `?token=${this.api.token}` : ""}`;
1695
+ const p2 = (path.startsWith("/api/storage/") ? path : "/api/storage/" + path).replaceAll(/\/{2,}/g, "/");
1696
+ const link = `${this.api.url}${p2}${this.api.token ? `?token=${this.api.token}` : ""}`;
1634
1697
  if (!target) return link;
1635
1698
  this.emit("OPEN", path);
1636
1699
  return window.open(link, target);
1637
1700
  }
1638
1701
  mkdir(path) {
1639
- const p = (path.startsWith("/api/storage/") ? path : "/api/storage/" + path).replaceAll(/\/{2,}/g, "/");
1640
- return this.api.request({ url: p + "?directory", method: "POST" });
1702
+ const p2 = (path.startsWith("/api/storage/") ? path : "/api/storage/" + path).replaceAll(/\/{2,}/g, "/");
1703
+ return this.api.request({ url: p2 + "?directory", method: "POST" });
1641
1704
  }
1642
1705
  download(path, opts = {}) {
1643
- const p = ("/api/storage/" + path).replaceAll("//", "/");
1644
- return this.api.request({ ...opts, url: p, decode: false }).then(async (response) => {
1706
+ const p2 = ("/api/storage/" + path).replaceAll("//", "/");
1707
+ return this.api.request({ ...opts, url: p2, decode: false }).then(async (response) => {
1645
1708
  const blob = await response.blob();
1646
- const name = opts.downloadAs || new URL(path).pathname.split("/").pop();
1709
+ const name = opts.downloadAs || path.split("/").pop();
1647
1710
  this.emit("DOWNLOAD", path, blob);
1648
- Bt(blob, name);
1711
+ Tt(blob, name);
1649
1712
  return response;
1650
1713
  });
1651
1714
  }
1652
1715
  upload(files, opts = "") {
1653
- return new E(async (res, rej, prog) => {
1654
- if (!files) files = await bt();
1716
+ return new m(async (res, rej, prog) => {
1717
+ if (!files) files = await It();
1655
1718
  if (!files || Array.isArray(files) && !files.length) return [];
1656
1719
  const url = this.api.url + ("/api/storage/" + (typeof opts == "string" ? opts : opts == null ? void 0 : opts.path)).replaceAll("//", "/");
1657
- return Rt({
1720
+ return $t({
1658
1721
  url,
1659
1722
  files: Array.isArray(files) ? files : [files],
1660
1723
  headers: this.api.headers
1661
- }).onProgress((p) => {
1662
- prog(p);
1724
+ }).onProgress((p2) => {
1725
+ prog(p2);
1663
1726
  }).then((resp) => {
1664
1727
  this.emit("UPLOAD", resp);
1665
1728
  res(resp);
@@ -1871,7 +1934,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1871
1934
  }, 1e3);
1872
1935
  }
1873
1936
  }
1874
- class Users extends H {
1937
+ class Users extends v {
1875
1938
  constructor(api) {
1876
1939
  super();
1877
1940
  __publicField(this, "api");
@@ -1936,7 +1999,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1936
1999
  });
1937
2000
  }
1938
2001
  uploadImage(username, file) {
1939
- return Rt({
2002
+ return $t({
1940
2003
  url: this.api.url + `/api/users/${username}/image`,
1941
2004
  files: [file],
1942
2005
  headers: this.api.headers
@@ -1946,7 +2009,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1946
2009
  });
1947
2010
  }
1948
2011
  }
1949
- class Settings extends H {
2012
+ class Settings extends v {
1950
2013
  constructor(api) {
1951
2014
  super();
1952
2015
  __publicField(this, "api");
@@ -1988,7 +2051,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1988
2051
  });
1989
2052
  }
1990
2053
  }
1991
- class Static extends H {
2054
+ class Static extends v {
1992
2055
  constructor(api) {
1993
2056
  super();
1994
2057
  __publicField(this, "api");
@@ -2007,13 +2070,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2007
2070
  });
2008
2071
  }
2009
2072
  upload(files, path = "/") {
2010
- return new E(async (res, rej, prog) => {
2011
- return Rt({
2073
+ return new m(async (res, rej, prog) => {
2074
+ return $t({
2012
2075
  url: this.api.url + ("/api/static/" + path).replaceAll("//", "/"),
2013
2076
  files: Array.isArray(files) ? files : [files],
2014
2077
  headers: this.api.headers
2015
- }).onProgress((p) => {
2016
- prog(p);
2078
+ }).onProgress((p2) => {
2079
+ prog(p2);
2017
2080
  }).then((resp) => {
2018
2081
  this.emit("UPLOAD", resp);
2019
2082
  res(resp);
@@ -2021,7 +2084,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2021
2084
  });
2022
2085
  }
2023
2086
  }
2024
- class Momentum extends H {
2087
+ class Momentum extends v {
2025
2088
  constructor(url, opts) {
2026
2089
  super();
2027
2090
  __publicField(this, "api");