@ztimson/momentum 0.32.0 → 0.34.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.mjs CHANGED
@@ -1,19 +1,19 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- var v = Object.defineProperty;
5
- var F = (n, e, t) => e in n ? v(n, e, { enumerable: true, configurable: true, writable: true, value: t }) : n[e] = t;
6
- var a = (n, e, t) => (F(n, typeof e != "symbol" ? e + "" : e, t), t);
7
- function W(n, e = false) {
4
+ var et = Object.defineProperty;
5
+ var nt = (n, t, e) => t in n ? et(n, t, { enumerable: true, configurable: true, writable: true, value: e }) : n[t] = e;
6
+ var i = (n, t, e) => (nt(n, typeof t != "symbol" ? t + "" : t, e), e);
7
+ function rt(n, t = false) {
8
8
  if (n == null)
9
9
  throw new Error("Cannot clean a NULL value");
10
- return Array.isArray(n) ? n = n.filter((t) => t != null) : Object.entries(n).forEach(([t, r]) => {
11
- (e && r === void 0 || !e && r == null) && delete n[t];
10
+ return Array.isArray(n) ? n = n.filter((e) => e != null) : Object.entries(n).forEach(([e, r]) => {
11
+ (t && r === void 0 || !t && r == null) && delete n[e];
12
12
  }), n;
13
13
  }
14
- function b(n, e) {
15
- const t = typeof n, r = typeof e;
16
- 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]));
14
+ function B(n, t) {
15
+ const e = typeof n, r = typeof t;
16
+ 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]));
17
17
  }
18
18
  function q(n) {
19
19
  try {
@@ -22,248 +22,311 @@ function q(n) {
22
22
  return n;
23
23
  }
24
24
  }
25
- class E extends Promise {
26
- constructor(t) {
27
- super((r, o) => t(
25
+ class m extends Promise {
26
+ constructor(e) {
27
+ super((r, o) => e(
28
28
  (s) => r(s),
29
29
  (s) => o(s),
30
30
  (s) => this.progress = s
31
31
  ));
32
- a(this, "listeners", []);
33
- a(this, "_progress", 0);
32
+ i(this, "listeners", []);
33
+ i(this, "_progress", 0);
34
34
  }
35
35
  get progress() {
36
36
  return this._progress;
37
37
  }
38
- set progress(t) {
39
- t != this._progress && (this._progress = t, this.listeners.forEach((r) => r(t)));
38
+ set progress(e) {
39
+ e != this._progress && (this._progress = e, this.listeners.forEach((r) => r(e)));
40
40
  }
41
- static from(t) {
42
- return t instanceof E ? t : new E((r, o) => t.then((...s) => r(...s)).catch((...s) => o(...s)));
41
+ static from(e) {
42
+ return e instanceof m ? e : new m((r, o) => e.then((...s) => r(...s)).catch((...s) => o(...s)));
43
43
  }
44
- from(t) {
45
- const r = E.from(t);
44
+ from(e) {
45
+ const r = m.from(e);
46
46
  return this.onProgress((o) => r.progress = o), r;
47
47
  }
48
- onProgress(t) {
49
- return this.listeners.push(t), this;
48
+ onProgress(e) {
49
+ return this.listeners.push(e), this;
50
50
  }
51
- then(t, r) {
52
- const o = super.then(t, r);
51
+ then(e, r) {
52
+ const o = super.then(e, r);
53
53
  return this.from(o);
54
54
  }
55
- catch(t) {
56
- return this.from(super.catch(t));
55
+ catch(e) {
56
+ return this.from(super.catch(e));
57
57
  }
58
- finally(t) {
59
- return this.from(super.finally(t));
58
+ finally(e) {
59
+ return this.from(super.finally(e));
60
60
  }
61
61
  }
62
- function Z(n, e) {
63
- const t = document.createElement("a");
64
- t.href = n, t.download = e, document.body.appendChild(t), t.click(), document.body.removeChild(t);
62
+ function ut(n, t) {
63
+ const e = document.createElement("a");
64
+ e.href = n, e.download = t, document.body.appendChild(e), e.click(), document.body.removeChild(e);
65
65
  }
66
- function Bt(n, e) {
67
- const t = URL.createObjectURL(n);
68
- Z(t, e), URL.revokeObjectURL(t);
66
+ function Tt(n, t) {
67
+ const e = URL.createObjectURL(n);
68
+ ut(e, t), URL.revokeObjectURL(e);
69
69
  }
70
- function bt(n = {}) {
71
- return new Promise((e) => {
72
- const t = document.createElement("input");
73
- t.type = "file", t.accept = n.accept || "*", t.style.display = "none", t.multiple = !!n.multiple, t.onblur = t.onchange = async () => {
74
- e(Array.from(t.files)), t.remove();
75
- }, document.body.appendChild(t), t.click();
70
+ function It(n = {}) {
71
+ return new Promise((t) => {
72
+ const e = document.createElement("input");
73
+ e.type = "file", e.accept = n.accept || "*", e.style.display = "none", e.multiple = !!n.multiple, e.onblur = e.onchange = async () => {
74
+ t(Array.from(e.files)), e.remove();
75
+ }, document.body.appendChild(e), e.click();
76
76
  });
77
77
  }
78
- function Rt(n) {
79
- return new E((e, t, r) => {
78
+ function $t(n) {
79
+ return new m((t, e, r) => {
80
80
  const o = new XMLHttpRequest(), s = new FormData();
81
- 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);
81
+ 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);
82
82
  });
83
83
  }
84
- class H {
84
+ class v {
85
85
  constructor() {
86
- a(this, "listeners", {});
86
+ i(this, "listeners", {});
87
87
  }
88
- static emit(e, ...t) {
89
- (this.listeners["*"] || []).forEach((r) => r(e, ...t)), (this.listeners[e.toString()] || []).forEach((r) => r(...t));
88
+ static emit(t, ...e) {
89
+ (this.listeners["*"] || []).forEach((r) => r(t, ...e)), (this.listeners[t.toString()] || []).forEach((r) => r(...e));
90
90
  }
91
- static off(e, t) {
92
- const r = e.toString();
93
- this.listeners[r] = (this.listeners[r] || []).filter((o) => o === t);
91
+ static off(t, e) {
92
+ const r = t.toString();
93
+ this.listeners[r] = (this.listeners[r] || []).filter((o) => o === e);
94
94
  }
95
- static on(e, t) {
95
+ static on(t, e) {
96
96
  var o;
97
- const r = e.toString();
98
- return this.listeners[r] || (this.listeners[r] = []), (o = this.listeners[r]) == null || o.push(t), () => this.off(e, t);
97
+ const r = t.toString();
98
+ return this.listeners[r] || (this.listeners[r] = []), (o = this.listeners[r]) == null || o.push(e), () => this.off(t, e);
99
99
  }
100
- static once(e, t) {
100
+ static once(t, e) {
101
101
  return new Promise((r) => {
102
- const o = this.on(e, (...s) => {
103
- r(s.length == 1 ? s[0] : s), t && t(...s), o();
102
+ const o = this.on(t, (...s) => {
103
+ r(s.length == 1 ? s[0] : s), e && e(...s), o();
104
104
  });
105
105
  });
106
106
  }
107
- emit(e, ...t) {
108
- (this.listeners["*"] || []).forEach((r) => r(e, ...t)), (this.listeners[e] || []).forEach((r) => r(...t));
107
+ emit(t, ...e) {
108
+ (this.listeners["*"] || []).forEach((r) => r(t, ...e)), (this.listeners[t] || []).forEach((r) => r(...e));
109
109
  }
110
- off(e, t) {
111
- this.listeners[e] = (this.listeners[e] || []).filter((r) => r === t);
110
+ off(t, e) {
111
+ this.listeners[t] = (this.listeners[t] || []).filter((r) => r === e);
112
112
  }
113
- on(e, t) {
113
+ on(t, e) {
114
114
  var r;
115
- return this.listeners[e] || (this.listeners[e] = []), (r = this.listeners[e]) == null || r.push(t), () => this.off(e, t);
115
+ return this.listeners[t] || (this.listeners[t] = []), (r = this.listeners[t]) == null || r.push(e), () => this.off(t, e);
116
116
  }
117
- once(e, t) {
117
+ once(t, e) {
118
118
  return new Promise((r) => {
119
- const o = this.on(e, (...s) => {
120
- r(s.length == 1 ? s[0] : s), t && t(...s), o();
119
+ const o = this.on(t, (...s) => {
120
+ r(s.length == 1 ? s[0] : s), e && e(...s), o();
121
121
  });
122
122
  });
123
123
  }
124
124
  }
125
- a(H, "listeners", {});
126
- class w extends Error {
127
- constructor(t, r) {
128
- super(t);
129
- a(this, "_code");
125
+ i(v, "listeners", {});
126
+ class p extends Error {
127
+ constructor(e, r) {
128
+ super(e);
129
+ i(this, "_code");
130
130
  r != null && (this._code = r);
131
131
  }
132
132
  get code() {
133
133
  return this._code || this.constructor.code;
134
134
  }
135
- set code(t) {
136
- this._code = t;
135
+ set code(e) {
136
+ this._code = e;
137
137
  }
138
- static from(t) {
139
- const r = Number(t.statusCode) ?? Number(t.code), o = new this(t.message || t.toString());
138
+ static from(e) {
139
+ const r = Number(e.statusCode) ?? Number(e.code), o = new this(e.message || e.toString());
140
140
  return Object.assign(o, {
141
- stack: t.stack,
142
- ...t,
141
+ stack: e.stack,
142
+ ...e,
143
143
  code: r ?? void 0
144
144
  });
145
145
  }
146
- static instanceof(t) {
147
- return t.constructor.code != null;
146
+ static instanceof(e) {
147
+ return e.constructor.code != null;
148
148
  }
149
149
  toString() {
150
150
  return this.message || super.toString();
151
151
  }
152
152
  }
153
- a(w, "code", 500);
154
- class X extends w {
155
- constructor(e = "Bad Request") {
156
- super(e);
153
+ i(p, "code", 500);
154
+ class F extends p {
155
+ constructor(t = "Bad Request") {
156
+ super(t);
157
157
  }
158
- static instanceof(e) {
159
- return e.constructor.code == this.code;
158
+ static instanceof(t) {
159
+ return t.constructor.code == this.code;
160
160
  }
161
161
  }
162
- a(X, "code", 400);
163
- class Q extends w {
164
- constructor(e = "Unauthorized") {
165
- super(e);
162
+ i(F, "code", 400);
163
+ class H extends p {
164
+ constructor(t = "Unauthorized") {
165
+ super(t);
166
166
  }
167
- static instanceof(e) {
168
- return e.constructor.code == this.code;
167
+ static instanceof(t) {
168
+ return t.constructor.code == this.code;
169
169
  }
170
170
  }
171
- a(Q, "code", 401);
172
- class _ extends w {
173
- constructor(e = "Forbidden") {
174
- super(e);
171
+ i(H, "code", 401);
172
+ class Y extends p {
173
+ constructor(t = "Payment Required") {
174
+ super(t);
175
175
  }
176
- static instanceof(e) {
177
- return e.constructor.code == this.code;
176
+ static instanceof(t) {
177
+ return t.constructor.code == this.code;
178
178
  }
179
179
  }
180
- a(_, "code", 403);
181
- class tt extends w {
182
- constructor(e = "Not Found") {
183
- super(e);
180
+ i(Y, "code", 402);
181
+ class W extends p {
182
+ constructor(t = "Forbidden") {
183
+ super(t);
184
184
  }
185
- static instanceof(e) {
186
- return e.constructor.code == this.code;
185
+ static instanceof(t) {
186
+ return t.constructor.code == this.code;
187
187
  }
188
188
  }
189
- a(tt, "code", 404);
190
- class et extends w {
191
- constructor(e = "Internal Server Error") {
192
- super(e);
189
+ i(W, "code", 403);
190
+ class J extends p {
191
+ constructor(t = "Not Found") {
192
+ super(t);
193
193
  }
194
- static instanceof(e) {
195
- return e.constructor.code == this.code;
194
+ static instanceof(t) {
195
+ return t.constructor.code == this.code;
196
+ }
197
+ }
198
+ i(J, "code", 404);
199
+ class z extends p {
200
+ constructor(t = "Method Not Allowed") {
201
+ super(t);
202
+ }
203
+ static instanceof(t) {
204
+ return t.constructor.code == this.code;
196
205
  }
197
206
  }
198
- a(et, "code", 500);
199
- const g = class g2 {
200
- constructor(e = {}) {
201
- a(this, "interceptors", {});
202
- a(this, "headers", {});
203
- a(this, "url");
204
- this.url = e.url ?? null, this.headers = e.headers || {}, e.interceptors && e.interceptors.forEach((t) => g2.addInterceptor(t));
205
- }
206
- static addInterceptor(e) {
207
- const t = Object.keys(g2.interceptors).length.toString();
208
- return g2.interceptors[t] = e, () => {
209
- g2.interceptors[t] = null;
207
+ i(z, "code", 405);
208
+ class K extends p {
209
+ constructor(t = "Not Acceptable") {
210
+ super(t);
211
+ }
212
+ static instanceof(t) {
213
+ return t.constructor.code == this.code;
214
+ }
215
+ }
216
+ i(K, "code", 406);
217
+ class V extends p {
218
+ constructor(t = "Internal Server Error") {
219
+ super(t);
220
+ }
221
+ static instanceof(t) {
222
+ return t.constructor.code == this.code;
223
+ }
224
+ }
225
+ i(V, "code", 500);
226
+ class Z extends p {
227
+ constructor(t = "Not Implemented") {
228
+ super(t);
229
+ }
230
+ static instanceof(t) {
231
+ return t.constructor.code == this.code;
232
+ }
233
+ }
234
+ i(Z, "code", 501);
235
+ class X extends p {
236
+ constructor(t = "Bad Gateway") {
237
+ super(t);
238
+ }
239
+ static instanceof(t) {
240
+ return t.constructor.code == this.code;
241
+ }
242
+ }
243
+ i(X, "code", 502);
244
+ class Q extends p {
245
+ constructor(t = "Service Unavailable") {
246
+ super(t);
247
+ }
248
+ static instanceof(t) {
249
+ return t.constructor.code == this.code;
250
+ }
251
+ }
252
+ i(Q, "code", 503);
253
+ class _ extends p {
254
+ constructor(t = "Gateway Timeout") {
255
+ super(t);
256
+ }
257
+ static instanceof(t) {
258
+ return t.constructor.code == this.code;
259
+ }
260
+ }
261
+ i(_, "code", 504);
262
+ const w = class w2 {
263
+ constructor(t = {}) {
264
+ i(this, "interceptors", {});
265
+ i(this, "headers", {});
266
+ i(this, "url");
267
+ this.url = t.url ?? null, this.headers = t.headers || {}, t.interceptors && t.interceptors.forEach((e) => w2.addInterceptor(e));
268
+ }
269
+ static addInterceptor(t) {
270
+ const e = Object.keys(w2.interceptors).length.toString();
271
+ return w2.interceptors[e] = t, () => {
272
+ w2.interceptors[e] = null;
210
273
  };
211
274
  }
212
- addInterceptor(e) {
213
- const t = Object.keys(this.interceptors).length.toString();
214
- return this.interceptors[t] = e, () => {
215
- this.interceptors[t] = null;
275
+ addInterceptor(t) {
276
+ const e = Object.keys(this.interceptors).length.toString();
277
+ return this.interceptors[e] = t, () => {
278
+ this.interceptors[e] = null;
216
279
  };
217
280
  }
218
- request(e = {}) {
281
+ request(t = {}) {
219
282
  var o;
220
- if (!this.url && !e.url)
283
+ if (!this.url && !t.url)
221
284
  throw new Error("URL needs to be set");
222
- let t = ((o = e.url) != null && o.startsWith("http") ? e.url : (this.url || "") + (e.url || "")).replace(/([^:]\/)\/+/g, "$1");
223
- if (e.fragment && (t.includes("#") ? t.replace(/#.*(\?|\n)/g, (s, i) => `#${e.fragment}${i}`) : t += "#" + e.fragment), e.query) {
224
- const s = Array.isArray(e.query) ? e.query : Object.keys(e.query).map((i) => ({ key: i, value: e.query[i] }));
225
- t += (t.includes("?") ? "&" : "?") + s.map((i) => `${i.key}=${i.value}`).join("&");
285
+ let e = ((o = t.url) != null && o.startsWith("http") ? t.url : (this.url || "") + (t.url || "")).replace(/([^:]\/)\/+/g, "$1");
286
+ if (t.fragment && (e.includes("#") ? e.replace(/#.*(\?|\n)/g, (s, c) => `#${t.fragment}${c}`) : e += "#" + t.fragment), t.query) {
287
+ const s = Array.isArray(t.query) ? t.query : Object.keys(t.query).map((c) => ({ key: c, value: t.query[c] }));
288
+ e += (e.includes("?") ? "&" : "?") + s.map((c) => `${c.key}=${c.value}`).join("&");
226
289
  }
227
- const r = W({
228
- "Content-Type": e.body ? e.body instanceof FormData ? "multipart/form-data" : "application/json" : void 0,
229
- ...g2.headers,
290
+ const r = rt({
291
+ "Content-Type": t.body ? t.body instanceof FormData ? "multipart/form-data" : "application/json" : void 0,
292
+ ...w2.headers,
230
293
  ...this.headers,
231
- ...e.headers
294
+ ...t.headers
232
295
  });
233
- return typeof e.body == "object" && e.body != null && r["Content-Type"] == "application/json" && (e.body = JSON.stringify(e.body)), new E((s, i, p) => {
234
- fetch(t, {
296
+ return typeof t.body == "object" && t.body != null && r["Content-Type"] == "application/json" && (t.body = JSON.stringify(t.body)), new m((s, c, y) => {
297
+ fetch(e, {
235
298
  headers: r,
236
- method: e.method || (e.body ? "POST" : "GET"),
237
- body: e.body
238
- }).then(async (c) => {
299
+ method: t.method || (t.body ? "POST" : "GET"),
300
+ body: t.body
301
+ }).then(async (u) => {
239
302
  var j, G;
240
- for (let u of [...Object.values(g2.interceptors), ...Object.values(this.interceptors)])
241
- await new Promise((O) => u(c, () => O()));
242
- const R = c.headers.get("Content-Length"), N = R ? parseInt(R, 10) : 0;
303
+ for (let a of [...Object.values(w2.interceptors), ...Object.values(this.interceptors)])
304
+ await new Promise((O) => a(u, () => O()));
305
+ const R = u.headers.get("Content-Length"), N = R ? parseInt(R, 10) : 0;
243
306
  let k = 0;
244
- const T = (j = c.body) == null ? void 0 : j.getReader(), Y = new ReadableStream({
245
- start(u) {
307
+ const T = (j = u.body) == null ? void 0 : j.getReader(), tt = new ReadableStream({
308
+ start(a) {
246
309
  function O() {
247
310
  T == null || T.read().then((x) => {
248
311
  if (x.done)
249
- return u.close();
250
- k += x.value.byteLength, p(k / N), u.enqueue(x.value), O();
251
- }).catch((x) => u.error(x));
312
+ return a.close();
313
+ k += x.value.byteLength, y(k / N), a.enqueue(x.value), O();
314
+ }).catch((x) => a.error(x));
252
315
  }
253
316
  O();
254
317
  }
255
318
  });
256
- if (c.data = new Response(Y), e.decode == null || e.decode) {
257
- const u = (G = c.headers.get("Content-Type")) == null ? void 0 : G.toLowerCase();
258
- 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());
319
+ if (u.data = new Response(tt), t.decode == null || t.decode) {
320
+ const a = (G = u.headers.get("Content-Type")) == null ? void 0 : G.toLowerCase();
321
+ 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());
259
322
  }
260
- c.ok ? s(c) : i(c);
323
+ u.ok ? s(u) : c(u);
261
324
  });
262
325
  });
263
326
  }
264
327
  };
265
- a(g, "interceptors", {}), a(g, "headers", {});
266
- let M = g;
328
+ i(w, "interceptors", {}), i(w, "headers", {});
329
+ let M = w;
267
330
  const A = {
268
331
  CLEAR: "\x1B[0m",
269
332
  BRIGHT: "\x1B[1m",
@@ -290,59 +353,59 @@ const A = {
290
353
  LIGHT_CYAN: "\x1B[96m",
291
354
  WHITE: "\x1B[97m"
292
355
  };
293
- 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 || {});
294
- const y = class y2 extends H {
295
- constructor(e) {
296
- super(), this.namespace = e;
356
+ 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 || {});
357
+ const g = class g2 extends v {
358
+ constructor(t) {
359
+ super(), this.namespace = t;
297
360
  }
298
- pad(e, t, r, o = false) {
299
- const s = e.toString(), i = t - s.length;
300
- if (i <= 0)
361
+ pad(t, e, r, o = false) {
362
+ const s = t.toString(), c = e - s.length;
363
+ if (c <= 0)
301
364
  return s;
302
- const p = Array(~~(i / r.length)).fill(r).join("");
303
- return o ? s + p : p + s;
365
+ const y = Array(~~(c / r.length)).fill(r).join("");
366
+ return o ? s + y : y + s;
304
367
  }
305
- format(...e) {
306
- const t = /* @__PURE__ */ new Date();
307
- 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(" ")}`;
368
+ format(...t) {
369
+ const e = /* @__PURE__ */ new Date();
370
+ 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(" ")}`;
308
371
  }
309
- debug(...e) {
310
- if (y2.LOG_LEVEL < 4)
372
+ debug(...t) {
373
+ if (g2.LOG_LEVEL < 4)
311
374
  return;
312
- const t = this.format(...e);
313
- y2.emit(4, t), console.debug(L.LIGHT_GREY + t + A.CLEAR);
375
+ const e = this.format(...t);
376
+ g2.emit(4, e), console.debug(L.LIGHT_GREY + e + A.CLEAR);
314
377
  }
315
- log(...e) {
316
- if (y2.LOG_LEVEL < 3)
378
+ log(...t) {
379
+ if (g2.LOG_LEVEL < 3)
317
380
  return;
318
- const t = this.format(...e);
319
- y2.emit(3, t), console.log(A.CLEAR + t);
381
+ const e = this.format(...t);
382
+ g2.emit(3, e), console.log(A.CLEAR + e);
320
383
  }
321
- info(...e) {
322
- if (y2.LOG_LEVEL < 2)
384
+ info(...t) {
385
+ if (g2.LOG_LEVEL < 2)
323
386
  return;
324
- const t = this.format(...e);
325
- y2.emit(2, t), console.info(L.BLUE + t + A.CLEAR);
387
+ const e = this.format(...t);
388
+ g2.emit(2, e), console.info(L.BLUE + e + A.CLEAR);
326
389
  }
327
- warn(...e) {
328
- if (y2.LOG_LEVEL < 1)
390
+ warn(...t) {
391
+ if (g2.LOG_LEVEL < 1)
329
392
  return;
330
- const t = this.format(...e);
331
- y2.emit(1, t), console.warn(L.YELLOW + t + A.CLEAR);
393
+ const e = this.format(...t);
394
+ g2.emit(1, e), console.warn(L.YELLOW + e + A.CLEAR);
332
395
  }
333
- error(...e) {
334
- if (y2.LOG_LEVEL < 0)
396
+ error(...t) {
397
+ if (g2.LOG_LEVEL < 0)
335
398
  return;
336
- const t = this.format(...e);
337
- y2.emit(0, t), console.error(L.RED + t + A.CLEAR);
399
+ const e = this.format(...t);
400
+ g2.emit(0, e), console.error(L.RED + e + A.CLEAR);
338
401
  }
339
402
  };
340
- a(y, "LOG_LEVEL", 4);
403
+ i(g, "LOG_LEVEL", 4);
341
404
  class Api extends M {
342
405
  constructor(url = location.origin, opts = {}) {
343
406
  opts.url = url;
344
407
  super(opts);
345
- __publicField(this, "emitter", new H());
408
+ __publicField(this, "emitter", new v());
346
409
  __publicField(this, "_token", null);
347
410
  __publicField(this, "emit", this.emitter.emit.bind(this.emitter));
348
411
  __publicField(this, "off", this.emitter.off.bind(this.emitter));
@@ -376,45 +439,45 @@ class Api extends M {
376
439
  return req;
377
440
  }
378
441
  }
379
- var extendStatics = function(d, b2) {
380
- extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b3) {
381
- d2.__proto__ = b3;
382
- } || function(d2, b3) {
383
- for (var p in b3) if (Object.prototype.hasOwnProperty.call(b3, p)) d2[p] = b3[p];
442
+ var extendStatics = function(d, b) {
443
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
444
+ d2.__proto__ = b2;
445
+ } || function(d2, b2) {
446
+ for (var p2 in b2) if (Object.prototype.hasOwnProperty.call(b2, p2)) d2[p2] = b2[p2];
384
447
  };
385
- return extendStatics(d, b2);
448
+ return extendStatics(d, b);
386
449
  };
387
- function __extends(d, b2) {
388
- if (typeof b2 !== "function" && b2 !== null)
389
- throw new TypeError("Class extends value " + String(b2) + " is not a constructor or null");
390
- extendStatics(d, b2);
450
+ function __extends(d, b) {
451
+ if (typeof b !== "function" && b !== null)
452
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
453
+ extendStatics(d, b);
391
454
  function __() {
392
455
  this.constructor = d;
393
456
  }
394
- d.prototype = b2 === null ? Object.create(b2) : (__.prototype = b2.prototype, new __());
457
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
395
458
  }
396
459
  function __values(o) {
397
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
398
- if (m) return m.call(o);
460
+ var s = typeof Symbol === "function" && Symbol.iterator, m2 = s && o[s], i2 = 0;
461
+ if (m2) return m2.call(o);
399
462
  if (o && typeof o.length === "number") return {
400
463
  next: function() {
401
- if (o && i >= o.length) o = void 0;
402
- return { value: o && o[i++], done: !o };
464
+ if (o && i2 >= o.length) o = void 0;
465
+ return { value: o && o[i2++], done: !o };
403
466
  }
404
467
  };
405
468
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
406
469
  }
407
470
  function __read(o, n) {
408
- var m = typeof Symbol === "function" && o[Symbol.iterator];
409
- if (!m) return o;
410
- var i = m.call(o), r, ar = [], e;
471
+ var m2 = typeof Symbol === "function" && o[Symbol.iterator];
472
+ if (!m2) return o;
473
+ var i2 = m2.call(o), r, ar = [], e;
411
474
  try {
412
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
475
+ while ((n === void 0 || n-- > 0) && !(r = i2.next()).done) ar.push(r.value);
413
476
  } catch (error) {
414
477
  e = { error };
415
478
  } finally {
416
479
  try {
417
- if (r && !r.done && (m = i["return"])) m.call(i);
480
+ if (r && !r.done && (m2 = i2["return"])) m2.call(i2);
418
481
  } finally {
419
482
  if (e) throw e.error;
420
483
  }
@@ -422,10 +485,10 @@ function __read(o, n) {
422
485
  return ar;
423
486
  }
424
487
  function __spreadArray(to, from, pack) {
425
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
426
- if (ar || !(i in from)) {
427
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
428
- ar[i] = from[i];
488
+ if (pack || arguments.length === 2) for (var i2 = 0, l = from.length, ar; i2 < l; i2++) {
489
+ if (ar || !(i2 in from)) {
490
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i2);
491
+ ar[i2] = from[i2];
429
492
  }
430
493
  }
431
494
  return to.concat(ar || Array.prototype.slice.call(from));
@@ -450,8 +513,8 @@ function createErrorClass(createImpl) {
450
513
  var UnsubscriptionError = createErrorClass(function(_super) {
451
514
  return function UnsubscriptionErrorImpl(errors) {
452
515
  _super(this);
453
- this.message = errors ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function(err, i) {
454
- return i + 1 + ") " + err.toString();
516
+ this.message = errors ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function(err, i2) {
517
+ return i2 + 1 + ") " + err.toString();
455
518
  }).join("\n ") : "";
456
519
  this.name = "UnsubscriptionError";
457
520
  this.errors = errors;
@@ -1092,7 +1155,7 @@ var ActionType = /* @__PURE__ */ ((ActionType2) => {
1092
1155
  ActionType2[ActionType2["PUT"] = 6] = "PUT";
1093
1156
  return ActionType2;
1094
1157
  })(ActionType || {});
1095
- class Actions extends H {
1158
+ class Actions extends v {
1096
1159
  constructor(api) {
1097
1160
  super();
1098
1161
  __publicField(this, "api");
@@ -1107,7 +1170,7 @@ class Actions extends H {
1107
1170
  }
1108
1171
  delete(id) {
1109
1172
  return this.api.request({ url: `/api/actions/${id}`, method: "DELETE" }).then(() => {
1110
- this.cache = this.cache.filter((a2) => a2._id != id);
1173
+ this.cache = this.cache.filter((a) => a._id != id);
1111
1174
  this.emit("DELETE", id);
1112
1175
  });
1113
1176
  }
@@ -1119,10 +1182,10 @@ class Actions extends H {
1119
1182
  });
1120
1183
  }
1121
1184
  read(id, reload = false) {
1122
- const cached = this.cache.find((a2) => a2._id == id);
1185
+ const cached = this.cache.find((a) => a._id == id);
1123
1186
  if (!reload && cached) return Promise.resolve(cached);
1124
1187
  return this.api.request({ url: `/api/actions/${id}` }).then((action) => {
1125
- if (action) this.cache = this.cache.filter((a2) => a2._id != id).concat([action]);
1188
+ if (action) this.cache = this.cache.filter((a) => a._id != id).concat([action]);
1126
1189
  this.emit("READ", action);
1127
1190
  return action;
1128
1191
  });
@@ -1140,13 +1203,13 @@ class Actions extends H {
1140
1203
  method: "POST",
1141
1204
  body: action
1142
1205
  }).then((action2) => {
1143
- if (action2) this.cache = this.cache.filter((a2) => a2._id != (action2 == null ? void 0 : action2._id)).concat([action2]);
1206
+ if (action2) this.cache = this.cache.filter((a) => a._id != (action2 == null ? void 0 : action2._id)).concat([action2]);
1144
1207
  this.emit("UPDATE", action2);
1145
1208
  return action2;
1146
1209
  });
1147
1210
  }
1148
1211
  }
1149
- class Ai extends H {
1212
+ class Ai extends v {
1150
1213
  constructor(api) {
1151
1214
  super();
1152
1215
  __publicField(this, "api");
@@ -1162,7 +1225,7 @@ class Ai extends H {
1162
1225
  });
1163
1226
  }
1164
1227
  }
1165
- class Analytics extends H {
1228
+ class Analytics extends v {
1166
1229
  constructor(api) {
1167
1230
  super();
1168
1231
  __publicField(this, "api");
@@ -1187,13 +1250,13 @@ class Totp {
1187
1250
  return this.api.request({ url: `/api/auth/totp/${username}`, method: "POST" });
1188
1251
  }
1189
1252
  setup(username, method = "app", totp) {
1190
- return this.api.request({ url: `/api/auth/totp/${username}`, body: W({
1253
+ return this.api.request({ url: `/api/auth/totp/${username}`, body: rt({
1191
1254
  method,
1192
1255
  totp
1193
1256
  }) });
1194
1257
  }
1195
1258
  }
1196
- class Auth extends H {
1259
+ class Auth extends v {
1197
1260
  constructor(api, opts) {
1198
1261
  var _a;
1199
1262
  super();
@@ -1238,7 +1301,7 @@ class Auth extends H {
1238
1301
  return this.$user.value;
1239
1302
  }
1240
1303
  set user(user) {
1241
- if (!b(this.user, user)) {
1304
+ if (!B(this.user, user)) {
1242
1305
  const u = user ? user : null;
1243
1306
  this.$user.next(u);
1244
1307
  this.emit("USER", u);
@@ -1324,7 +1387,7 @@ class Auth extends H {
1324
1387
  });
1325
1388
  }
1326
1389
  }
1327
- class Data extends H {
1390
+ class Data extends v {
1328
1391
  constructor(api) {
1329
1392
  super();
1330
1393
  __publicField(this, "api");
@@ -1369,7 +1432,7 @@ class Data extends H {
1369
1432
  });
1370
1433
  }
1371
1434
  }
1372
- class Email extends H {
1435
+ class Email extends v {
1373
1436
  constructor(api) {
1374
1437
  super();
1375
1438
  __publicField(this, "api");
@@ -1384,7 +1447,7 @@ class Email extends H {
1384
1447
  });
1385
1448
  }
1386
1449
  }
1387
- class Groups extends H {
1450
+ class Groups extends v {
1388
1451
  constructor(api) {
1389
1452
  super();
1390
1453
  __publicField(this, "api");
@@ -1466,32 +1529,32 @@ class Logger {
1466
1529
  return this.api.request({ url: `/api/logs/server${query ? `?${query}` : ""}` }).then((resp) => resp);
1467
1530
  }
1468
1531
  debug(...logs) {
1469
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(nt.DEBUG, logs) }).then(() => {
1532
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.DEBUG, logs) }).then(() => {
1470
1533
  }).catch(() => {
1471
1534
  });
1472
1535
  }
1473
1536
  log(...logs) {
1474
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(nt.LOG, logs) }).then(() => {
1537
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.LOG, logs) }).then(() => {
1475
1538
  }).catch(() => {
1476
1539
  });
1477
1540
  }
1478
1541
  info(...logs) {
1479
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(nt.INFO, logs) }).then(() => {
1542
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.INFO, logs) }).then(() => {
1480
1543
  }).catch(() => {
1481
1544
  });
1482
1545
  }
1483
1546
  warn(...logs) {
1484
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(nt.WARN, logs) }).then(() => {
1547
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.WARN, logs) }).then(() => {
1485
1548
  }).catch(() => {
1486
1549
  });
1487
1550
  }
1488
1551
  error(...logs) {
1489
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(nt.ERROR, logs) }).then(() => {
1552
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.ERROR, logs) }).then(() => {
1490
1553
  }).catch(() => {
1491
1554
  });
1492
1555
  }
1493
1556
  }
1494
- class Payments extends H {
1557
+ class Payments extends v {
1495
1558
  constructor(api, secret) {
1496
1559
  super();
1497
1560
  __publicField(this, "api");
@@ -1532,7 +1595,7 @@ class Payments extends H {
1532
1595
  return history;
1533
1596
  }
1534
1597
  }
1535
- class Pdf extends H {
1598
+ class Pdf extends v {
1536
1599
  constructor(api) {
1537
1600
  super();
1538
1601
  __publicField(this, "api");
@@ -1542,20 +1605,20 @@ class Pdf extends H {
1542
1605
  const blob = await resp.blob();
1543
1606
  if (fileName) {
1544
1607
  const url = URL.createObjectURL(blob);
1545
- Z(url, fileName.endsWith(".pdf") ? fileName : fileName + ".pdf");
1608
+ ut(url, fileName.endsWith(".pdf") ? fileName : fileName + ".pdf");
1546
1609
  URL.revokeObjectURL(url);
1547
1610
  }
1548
1611
  this.emit("CREATE", blob);
1549
1612
  return blob;
1550
1613
  }
1551
1614
  fromHtml(content, opts = {}) {
1552
- 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));
1615
+ 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));
1553
1616
  }
1554
1617
  fromTemplate(template, data, opts = {}) {
1555
- 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));
1618
+ 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));
1556
1619
  }
1557
1620
  fromUrl(url, opts = {}) {
1558
- return this.api.request({ url: `/api/pdf?url=${url}` }).then((resp) => this.handleResponse(resp, opts.download ? opts.fileName || (/* @__PURE__ */ new Date()).toISOString() : void 0));
1621
+ 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));
1559
1622
  }
1560
1623
  }
1561
1624
  const _Socket = class _Socket {
@@ -1605,7 +1668,7 @@ const _Socket = class _Socket {
1605
1668
  };
1606
1669
  __publicField(_Socket, "timeout", 1e4);
1607
1670
  let Socket = _Socket;
1608
- class Storage extends H {
1671
+ class Storage extends v {
1609
1672
  constructor(api) {
1610
1673
  super();
1611
1674
  __publicField(this, "api");
@@ -1625,37 +1688,37 @@ class Storage extends H {
1625
1688
  });
1626
1689
  }
1627
1690
  open(path, target = "_blank") {
1628
- const p = (path.startsWith("/api/storage/") ? path : "/api/storage/" + path).replaceAll(/\/{2,}/g, "/");
1629
- const link = `${this.api.url}${p}${this.api.token ? `?token=${this.api.token}` : ""}`;
1691
+ const p2 = (path.startsWith("/api/storage/") ? path : "/api/storage/" + path).replaceAll(/\/{2,}/g, "/");
1692
+ const link = `${this.api.url}${p2}${this.api.token ? `?token=${this.api.token}` : ""}`;
1630
1693
  if (!target) return link;
1631
1694
  this.emit("OPEN", path);
1632
1695
  return window.open(link, target);
1633
1696
  }
1634
1697
  mkdir(path) {
1635
- const p = (path.startsWith("/api/storage/") ? path : "/api/storage/" + path).replaceAll(/\/{2,}/g, "/");
1636
- return this.api.request({ url: p + "?directory", method: "POST" });
1698
+ const p2 = (path.startsWith("/api/storage/") ? path : "/api/storage/" + path).replaceAll(/\/{2,}/g, "/");
1699
+ return this.api.request({ url: p2 + "?directory", method: "POST" });
1637
1700
  }
1638
1701
  download(path, opts = {}) {
1639
- const p = ("/api/storage/" + path).replaceAll("//", "/");
1640
- return this.api.request({ ...opts, url: p, decode: false }).then(async (response) => {
1702
+ const p2 = ("/api/storage/" + path).replaceAll("//", "/");
1703
+ return this.api.request({ ...opts, url: p2, decode: false }).then(async (response) => {
1641
1704
  const blob = await response.blob();
1642
1705
  const name = opts.downloadAs || path.split("/").pop();
1643
1706
  this.emit("DOWNLOAD", path, blob);
1644
- Bt(blob, name);
1707
+ Tt(blob, name);
1645
1708
  return response;
1646
1709
  });
1647
1710
  }
1648
1711
  upload(files, opts = "") {
1649
- return new E(async (res, rej, prog) => {
1650
- if (!files) files = await bt();
1712
+ return new m(async (res, rej, prog) => {
1713
+ if (!files) files = await It();
1651
1714
  if (!files || Array.isArray(files) && !files.length) return [];
1652
1715
  const url = this.api.url + ("/api/storage/" + (typeof opts == "string" ? opts : opts == null ? void 0 : opts.path)).replaceAll("//", "/");
1653
- return Rt({
1716
+ return $t({
1654
1717
  url,
1655
1718
  files: Array.isArray(files) ? files : [files],
1656
1719
  headers: this.api.headers
1657
- }).onProgress((p) => {
1658
- prog(p);
1720
+ }).onProgress((p2) => {
1721
+ prog(p2);
1659
1722
  }).then((resp) => {
1660
1723
  this.emit("UPLOAD", resp);
1661
1724
  res(resp);
@@ -1867,7 +1930,7 @@ class UI {
1867
1930
  }, 1e3);
1868
1931
  }
1869
1932
  }
1870
- class Users extends H {
1933
+ class Users extends v {
1871
1934
  constructor(api) {
1872
1935
  super();
1873
1936
  __publicField(this, "api");
@@ -1932,7 +1995,7 @@ class Users extends H {
1932
1995
  });
1933
1996
  }
1934
1997
  uploadImage(username, file) {
1935
- return Rt({
1998
+ return $t({
1936
1999
  url: this.api.url + `/api/users/${username}/image`,
1937
2000
  files: [file],
1938
2001
  headers: this.api.headers
@@ -1942,7 +2005,7 @@ class Users extends H {
1942
2005
  });
1943
2006
  }
1944
2007
  }
1945
- class Settings extends H {
2008
+ class Settings extends v {
1946
2009
  constructor(api) {
1947
2010
  super();
1948
2011
  __publicField(this, "api");
@@ -1984,7 +2047,7 @@ class Settings extends H {
1984
2047
  });
1985
2048
  }
1986
2049
  }
1987
- class Static extends H {
2050
+ class Static extends v {
1988
2051
  constructor(api) {
1989
2052
  super();
1990
2053
  __publicField(this, "api");
@@ -2003,13 +2066,13 @@ class Static extends H {
2003
2066
  });
2004
2067
  }
2005
2068
  upload(files, path = "/") {
2006
- return new E(async (res, rej, prog) => {
2007
- return Rt({
2069
+ return new m(async (res, rej, prog) => {
2070
+ return $t({
2008
2071
  url: this.api.url + ("/api/static/" + path).replaceAll("//", "/"),
2009
2072
  files: Array.isArray(files) ? files : [files],
2010
2073
  headers: this.api.headers
2011
- }).onProgress((p) => {
2012
- prog(p);
2074
+ }).onProgress((p2) => {
2075
+ prog(p2);
2013
2076
  }).then((resp) => {
2014
2077
  this.emit("UPLOAD", resp);
2015
2078
  res(resp);
@@ -2017,7 +2080,7 @@ class Static extends H {
2017
2080
  });
2018
2081
  }
2019
2082
  }
2020
- class Momentum extends H {
2083
+ class Momentum extends v {
2021
2084
  constructor(url, opts) {
2022
2085
  super();
2023
2086
  __publicField(this, "api");