@prozilla-os/shared 1.3.0 → 1.5.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/main.js CHANGED
@@ -1,738 +1,364 @@
1
- const h = {
2
- /**
3
- * Foreground colors.
4
- */
5
- fg: {
6
- black: "\x1B[30m",
7
- red: "\x1B[31m",
8
- green: "\x1B[32m",
9
- yellow: "\x1B[33m",
10
- blue: "\x1B[34m",
11
- magenta: "\x1B[35m",
12
- cyan: "\x1B[36m",
13
- white: "\x1B[37m"
14
- },
15
- /**
16
- * Background colors.
17
- */
18
- bg: {
19
- black: "\x1B[40m",
20
- red: "\x1B[41m",
21
- green: "\x1B[42m",
22
- yellow: "\x1B[43m",
23
- blue: "\x1B[44m",
24
- magenta: "\x1B[45m",
25
- cyan: "\x1B[46m",
26
- white: "\x1B[47m"
27
- },
28
- /**
29
- * Screen buffer and clearing controls.
30
- */
31
- screen: {
32
- enterAltBuffer: "\x1B[?1049h",
33
- exitAltBuffer: "\x1B[?1049l",
34
- clear: "\x1B[2J",
35
- home: "\x1B[H"
36
- },
37
- /**
38
- * Decorations.
39
- */
40
- decoration: {
41
- dim: "\x1B[2m",
42
- bold: "\x1B[1m",
43
- underline: "\x1B[4m"
44
- },
45
- reset: "\x1B[0m"
46
- };
47
- function x(r, t) {
48
- const e = t.indexOf(r);
49
- e !== -1 && t.splice(e, 1);
50
- }
51
- function A(r) {
52
- return r[Math.floor(Math.random() * r.length)];
1
+ import { A as _, a as j, L as P, b as V, i as X, c as Y, d as Z, e as G, f as H, g as J, h as K, j as Q, k as W, l as R } from "./chunks/index-PU_xBoDn.js";
2
+ import { EventEmitter as tr, capitalize as er, clamp as nr, fillTemplate as ir, formatRelativeTime as sr, formatTime as or, getLongestCommonPrefix as ar, interleave as ur, isValidInteger as cr, isValidNumber as lr, isValidUrl as hr, isolateSubstring as fr, kebabToCamelCase as pr, parseBool as dr, parseOptionalFloat as mr, parseOptionalInteger as gr, randomFromArray as yr, randomIndex as vr, randomInt as xr, randomRange as Er, removeBaseUrl as kr, removeDuplicatesFromArray as Or, removeFromArray as $r, removeUrlProtocol as br, replaceAll as wr, resolveUrl as Sr, round as Ar, splitAt as Fr } from "./utils.js";
3
+ import { i as qr, m as Dr } from "./chunks/object.utils-xiWGUq8N.js";
4
+ const I = "https://os.prozilla.dev/";
5
+ function O(n) {
6
+ return `# ${n}`;
53
7
  }
54
- function F(r) {
55
- return r.filter((t, e) => r.indexOf(t) === e);
8
+ function $(n) {
9
+ return `## ${n}`;
56
10
  }
57
- const m = {
58
- s: 1e3,
59
- m: 1e3 * 60,
60
- h: 1e3 * 60 * 60,
61
- d: 1e3 * 60 * 60 * 24,
62
- w: 1e3 * 60 * 60 * 24 * 7,
63
- n: 1e3 * 60 * 60 * 24 * 31,
64
- y: 1e3 * 60 * 60 * 24 * 365,
65
- c: 1e3 * 60 * 60 * 24 * 365 * 100
66
- };
67
- function y(r, t = 3, e = !1) {
68
- const i = [], s = (o, l) => {
69
- if (!e)
70
- return o.join(", ");
71
- let f = "", g = "";
72
- return l ? g = "ago" : f = "in", [f, o.join(", "), g].join(" ").trim();
73
- };
74
- let u = !1;
75
- if (r < 0 && (r = -r, u = !0), Math.abs(r) < m.s)
76
- return s(["less than a second"], u);
77
- const c = [], d = {
78
- s: "second",
79
- m: "minute",
80
- h: "hour",
81
- d: "day",
82
- n: "month",
83
- y: "year"
84
- };
85
- for (const [o, l] of Object.entries(m).reverse()) {
86
- if (o === "w" || o === "c")
87
- continue;
88
- const f = Math.floor(r / l);
89
- r -= f * l, f > 0 && c.push({ amount: f, label: f != 1 ? d[o] + "s" : d[o] });
90
- }
91
- for (let o = 0; o < t; o++)
92
- if (o < c.length) {
93
- const l = c[o];
94
- i.push(`${l.amount} ${l.label}`);
95
- }
96
- return i.length === 0 ? s(["less than a second"], u) : s(i, u);
11
+ function b(n) {
12
+ return `### ${n}`;
97
13
  }
98
- function C(r, t = 3, e = !1) {
99
- const i = r.valueOf() - Date.now();
100
- return y(i, t, e);
14
+ function w(n) {
15
+ return `#### ${n}`;
101
16
  }
102
- class R {
103
- #t = {};
104
- /**
105
- * Starts listening to an event.
106
- * @param event - The event to listen to.
107
- * @param listener - The function to call when the event is emitted.
108
- * @returns The listener.
109
- */
110
- on(t, e) {
111
- return this.#t[t] === void 0 ? this.#t[t] = [e] : this.#t[t].push(e), e;
112
- }
113
- /**
114
- * Registers an event listener that is automatically removed when called.
115
- * @param event - The event to listen to.
116
- * @param listener - The function to call once the event is emitted.
117
- * @returns The wrapped listener.
118
- */
119
- once(t, e) {
120
- const i = this.on(t, (...s) => {
121
- this.off(t, i), e(...s);
122
- });
123
- return i;
124
- }
125
- /**
126
- * Starts listening to an event.
127
- * @param event - The event to listen to.
128
- * @param listener - The function to call when the event is emitted.
129
- * @returns The wrapped listener.
130
- */
131
- onAsync(t, e, i) {
132
- return this.on(t, (...s) => {
133
- e(...s).catch((u) => {
134
- i ? i(u) : console.error(u);
135
- });
136
- });
137
- }
138
- /**
139
- * Removes an event listener.
140
- * @param event - The event to remove the listener from.
141
- * @param listener - The listener to remove.
142
- */
143
- off(t, e) {
144
- this.#t[t] !== void 0 && x(e, this.#t[t]);
145
- }
146
- /**
147
- * Emits an event to all its listeners.
148
- * @param event - The event to emit.
149
- * @param args - The arguments to pass to the listeners.
150
- */
151
- emit(t, ...e) {
152
- if (this.#t[t] !== void 0)
153
- for (const i of this.#t[t])
154
- i(...e);
155
- }
17
+ function S(n) {
18
+ return `##### ${n}`;
156
19
  }
157
- function q(r, t, e) {
158
- return r < t ? t : r > e ? e : r;
20
+ function A(n) {
21
+ return `###### ${n}`;
159
22
  }
160
- function O(r, t) {
161
- return Math.random() * (t - r) + r;
23
+ function F(n) {
24
+ return `**${n}**`;
162
25
  }
163
- function W(r, t) {
164
- const e = Math.pow(10, t ?? 0);
165
- return Math.round(r * e) / e;
26
+ function z(n) {
27
+ return `*${n}*`;
166
28
  }
167
- function p(r) {
168
- return typeof r == "number" ? !0 : r.trim() === "" ? !1 : Number.isInteger(Number(r));
29
+ function q(n) {
30
+ return `\`${n}\``;
169
31
  }
170
- function b(r) {
171
- return typeof r == "number" ? !0 : r.trim() === "" ? !1 : !isNaN(Number(r));
32
+ function D(n) {
33
+ return `\`\`\`${n}\`\`\``;
172
34
  }
173
- function X(r, t = 0) {
174
- return r !== void 0 && p(r) ? Number(r) : t;
35
+ function L(n) {
36
+ return `~~${n}~~`;
175
37
  }
176
- function Y(r, t = 0) {
177
- return r !== void 0 && b(r) ? parseFloat(r) : t;
38
+ function M(n, r) {
39
+ return `[${n}](${r})`;
178
40
  }
179
- function Z(r) {
180
- return r.trim().toLowerCase() === "true";
41
+ function N(n) {
42
+ return `> ${n}`;
181
43
  }
182
- function H(r) {
183
- if (!r.length) return "";
184
- let t = r[0];
185
- for (let e = 1; e < r.length; e++)
186
- for (; r[e].indexOf(t) !== 0; )
187
- if (t = t.substring(0, t.length - 1), t === "") return "";
188
- return t;
44
+ function B() {
45
+ return "---";
189
46
  }
190
- class n {
191
- /**
192
- * Makes text black using {@link ANSI.fg.black}.
193
- */
194
- static black(t) {
195
- return n.#t(t, h.fg.black);
47
+ const T = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
48
+ __proto__: null,
49
+ bold: F,
50
+ code: q,
51
+ codeBlock: D,
52
+ heading1: O,
53
+ heading2: $,
54
+ heading3: b,
55
+ heading4: w,
56
+ heading5: S,
57
+ heading6: A,
58
+ horizontalRule: B,
59
+ italic: z,
60
+ link: M,
61
+ quote: N,
62
+ strikethrough: L
63
+ }, Symbol.toStringTag, { value: "Module" }));
64
+ class c {
65
+ x;
66
+ y;
67
+ constructor(r, e) {
68
+ this.x = r ?? 0, this.y = e ?? this.x;
196
69
  }
197
- /**
198
- * Makes text red using {@link ANSI.fg.red}.
199
- */
200
- static red(t) {
201
- return n.#t(t, h.fg.red);
70
+ static get ZERO() {
71
+ return new c(0, 0);
202
72
  }
203
- /**
204
- * Makes text green using {@link ANSI.fg.green}.
205
- */
206
- static green(t) {
207
- return n.#t(t, h.fg.green);
73
+ get clone() {
74
+ return new c(this.x, this.y);
208
75
  }
209
- /**
210
- * Makes text yellow using {@link ANSI.fg.yellow}.
211
- */
212
- static yellow(t) {
213
- return n.#t(t, h.fg.yellow);
76
+ get magnitude() {
77
+ return this.getDistance(this);
214
78
  }
215
- /**
216
- * Makes text blue using {@link ANSI.fg.blue}.
217
- */
218
- static blue(t) {
219
- return n.#t(t, h.fg.blue);
79
+ setX(r) {
80
+ return this.x = r, this;
220
81
  }
221
- /**
222
- * Makes text magenta using {@link ANSI.fg.magenta}.
223
- */
224
- static magenta(t) {
225
- return n.#t(t, h.fg.magenta);
82
+ setY(r) {
83
+ return this.y = r, this;
226
84
  }
227
- /**
228
- * Makes text cyan using {@link ANSI.fg.cyan}.
229
- */
230
- static cyan(t) {
231
- return n.#t(t, h.fg.cyan);
85
+ set(r, e) {
86
+ return this.x = r, this.y = e, this;
232
87
  }
233
- /**
234
- * Makes text white using {@link ANSI.fg.white}.
235
- */
236
- static white(t) {
237
- return n.#t(t, h.fg.white);
88
+ round() {
89
+ return this.x = Math.round(this.x), this.y = Math.round(this.y), this;
238
90
  }
239
- /**
240
- * Makes text bold using {@link ANSI.decoration.bold}.
241
- */
242
- static bold(t) {
243
- return n.#t(t, h.decoration.bold);
91
+ normalize() {
92
+ const r = this.magnitude;
93
+ return this.scale(r === 0 ? 0 : 1 / r);
244
94
  }
245
- /**
246
- * Makes text dim using {@link ANSI.decoration.dim}.
247
- */
248
- static dim(t) {
249
- return n.#t(t, h.decoration.dim);
95
+ scale(r) {
96
+ return this.multiply(r);
250
97
  }
251
- static #t(t, e) {
252
- return t = t.replaceAll(h.reset, h.reset + e), e + t + h.reset;
98
+ getDistanceSquared(r, e) {
99
+ const i = c.parseVector(r, e), a = this.x - i.x, h = this.y - i.y;
100
+ return a * a + h * h;
253
101
  }
254
- /**
255
- * Removes all ANSI escape sequences.
256
- */
257
- static strip(t) {
258
- return t.replace(/\u001b\[[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, "");
102
+ getDistance(r, e) {
103
+ const i = c.parseVector(r, e);
104
+ return Math.sqrt(this.getDistanceSquared(i.x, i.y));
259
105
  }
260
- /**
261
- * Removes ANSI escape sequences for colors and background colors (SGR).
262
- */
263
- static stripColors(t) {
264
- return t.replace(/\u001b\[[0-9;]*m/g, "");
106
+ add(r, e) {
107
+ const i = c.parseVector(r, e);
108
+ return this.x += i.x, this.y += i.y, this;
265
109
  }
266
- }
267
- var w = /* @__PURE__ */ ((r) => (r[r.Debug = 0] = "Debug", r[r.Info = 1] = "Info", r[r.Success = 2] = "Success", r[r.Warning = 3] = "Warning", r[r.Error = 4] = "Error", r))(w || {});
268
- class J {
269
- /**
270
- * The minimum log level or an array of log levels to enable.
271
- *
272
- * `undefined` enables all log levels. An array enables all log levels in that array. A single level enables that log level and the ones above.
273
- * @default LogLevel.Debug
274
- */
275
- level;
276
- /**
277
- * The current level of indentation.
278
- * @default 0
279
- */
280
- indent = 0;
281
- /**
282
- * The string to use for indentation.
283
- * @default "\t"
284
- */
285
- indentString;
286
- /**
287
- * The function to use when highlighting text.
288
- * @default Ansi.cyan
289
- * @see {@link Ansi.cyan}
290
- */
291
- highlight = n.cyan;
292
- /**
293
- * The function to use when emphasizing text.
294
- * @default Ansi.bold
295
- * @see {@link Ansi.bold}
296
- */
297
- emphasize = n.bold;
298
- /**
299
- * The prefixes to prepend to logs.
300
- * @default {
301
- [LogLevel.Info]: Ansi.cyan("[info]"),
302
- [LogLevel.Success]: Ansi.green("[success]"),
303
- [LogLevel.Warning]: Ansi.yellow("[warning]"),
304
- [LogLevel.Error]: Ansi.red("[error]"),
305
- }
306
- */
307
- prefix = {};
308
- #t = 0;
309
- #e = 0;
310
- constructor(t) {
311
- this.reset(), t !== void 0 && (Array.isArray(t) || typeof t == "number" ? this.level = t : (t.level !== void 0 && (this.level = t.level), t.prefix && (typeof t.prefix == "string" ? this.prefix.global = t.prefix : this.prefix = {
312
- ...this.prefix,
313
- ...t.prefix
314
- })));
315
- }
316
- // ===== Modifying state =====
317
- /**
318
- * Resets all properties to their default values.
319
- */
320
- reset() {
321
- return this.level = 0, this.indent = 0, this.indentString = " ", this.highlight = n.cyan, this.emphasize = n.bold, this.prefix = {
322
- 1: n.cyan("[info]"),
323
- 2: n.green("[success]"),
324
- 3: n.yellow("[warning]"),
325
- 4: n.red("[error]")
326
- }, this.#t = 0, this.#e = 0, this;
110
+ subtract(r, e) {
111
+ const i = c.parseVector(r, e);
112
+ return this.x -= i.x, this.y -= i.y, this;
327
113
  }
328
- indented(t, e = 1, i) {
329
- return i !== void 0 && !this.isLevelEnabled(i) ? this : (this.indent + e < 0 && (e = -this.indent), this.tab(e), typeof t == "function" ? t() : Array.isArray(t) ? this.lines(t, i) : this.log(t, i), this.shiftTab(e), this);
114
+ multiply(r, e) {
115
+ const i = c.parseVector(r, e);
116
+ return this.x *= i.x, this.y *= i.y, this;
330
117
  }
331
- /**
332
- * Increases the level of indentation.
333
- * @param amount - The amount to increase the level of indentation with.
334
- */
335
- tab(t = 1) {
336
- return this.indent += t, this.indent < 0 && (this.indent = 0), this;
118
+ divide(r, e) {
119
+ const i = c.parseVector(r, e);
120
+ return this.x /= i.x, this.y /= i.y, this;
337
121
  }
338
- /**
339
- * Decreases the level of indentation.
340
- * @param amount - The amount to decrease the level of indentation with.
341
- */
342
- shiftTab(t = 1) {
343
- return this.indent -= t, this.indent < 0 && (this.indent = 0), this;
122
+ lerp(r, e) {
123
+ return this.x += (r.x - this.x) * e, this.y += (r.y - this.y) * e, this;
344
124
  }
345
- setPrefix(t, e) {
346
- return typeof t == "string" ? this.prefix = {
347
- global: t
348
- } : typeof t == "object" ? this.prefix = t : this.prefix[t] = e, this;
125
+ static sum(r, e) {
126
+ return r.clone.add(e);
349
127
  }
350
- // ===== Logging status messages =====
351
- /**
352
- * Logs an info message about a URL being fetched.
353
- * @param url - The URL being fetched.
354
- */
355
- fetching(t) {
356
- return this.pending(`Fetching: ${this.highlight(t)}`);
128
+ static difference(r, e) {
129
+ return r.clone.subtract(e);
357
130
  }
358
- /**
359
- * Logs an info message that implies a pending state.
360
- * @param message - The status message.
361
- */
362
- pending(t) {
363
- return this.info(n.yellow(t));
131
+ static product(r, e) {
132
+ return r.clone.multiply(e);
364
133
  }
365
- /**
366
- * Logs an error message.
367
- * @param message - The error message or reason.
368
- * @param details - The details of the error message.
369
- */
370
- error(t, ...e) {
371
- return this.#t++, this.isLevelEnabled(
372
- 4
373
- /* Error */
374
- ) ? (typeof t == "string" ? this.statusMessage(
375
- n.red(t),
376
- e,
377
- 4
378
- /* Error */
379
- ) : console.error(t, ...e), this) : this;
134
+ static division(r, e) {
135
+ return r.clone.divide(e);
380
136
  }
381
- /**
382
- * Logs a warning message.
383
- * @param message - The warning message.
384
- * @param details - The details of the warning message.
385
- */
386
- warn(t, ...e) {
387
- return this.#e++, this.statusMessage(
388
- n.yellow(t),
389
- e,
390
- 3
391
- /* Warning */
392
- );
137
+ static scale(r, e) {
138
+ return r.clone.scale(e);
393
139
  }
394
- /**
395
- * Logs a success message.
396
- * @param message - The success message.
397
- * @param details - The details of the success message.
398
- */
399
- success(t, ...e) {
400
- return this.statusMessage(
401
- n.green(t),
402
- e,
403
- 2
404
- /* Success */
405
- );
140
+ static normalize(r) {
141
+ return r.clone.normalize();
406
142
  }
407
- /**
408
- * Logs an info message.
409
- * @param message - The info message.
410
- * @param details - The details of the info message.
411
- */
412
- info(t, ...e) {
413
- return this.statusMessage(
414
- t,
415
- e,
416
- 1
417
- /* Info */
418
- );
143
+ static lerp(r, e, i) {
144
+ return r.clone.lerp(e, i);
419
145
  }
420
- /**
421
- * Logs a status message.
422
- * @param message - The status message.
423
- * @param details - The details of the status message.
424
- * @param level - The log level.
425
- */
426
- statusMessage(t, e, i) {
427
- let s = t;
428
- if (e.length) {
429
- const u = this.indentString ? this.indentString.repeat(this.indent + 1) : " ";
430
- s += `
431
- ` + e.map((c) => u + String(c)).join(`
432
- `);
433
- }
434
- return this.text(s, i);
146
+ static from({ x: r, y: e }) {
147
+ return new c(r, e);
435
148
  }
436
- /**
437
- * Logs the amount of errors and warnings that have been logged since the previous call to this function or the creation of this logger.
438
- */
439
- summary() {
440
- const t = `${this.#t} error${this.#t != 1 ? "s" : ""}`, e = `${this.#e} warning${this.#e != 1 ? "s" : ""}`;
441
- let i = `Found ${t} and ${e}`;
442
- return this.#t > 0 ? i = n.red(i) : this.#e > 0 ? i = n.yellow(i) : i = n.green(i), this.text(i), this.#t = 0, this.#e = 0, this;
443
- }
444
- // ===== Logging text =====
445
- /**
446
- * Logs a labeled parameter.
447
- *
448
- * The value is emphasized using {@link emphasize}.
449
- * @param label - The label of the parameter.
450
- * @param value - The value of the parameter.
451
- * @param level - The log level.
452
- */
453
- parameter(t, e, i) {
454
- return this.text(`${t}: ${this.emphasize(String(e))}`, i);
455
- }
456
- /**
457
- * Logs properties as a list of key-value pairs.
458
- * @param properties - The properties to log.
459
- * @param level - The log level.
460
- * @see {@link value()}
461
- */
462
- properties(t, e) {
463
- for (const [i, s] of Object.entries(t))
464
- this.value(`- ${i}`, s, e);
465
- return this;
466
- }
467
- /**
468
- * Logs a labeled value.
469
- *
470
- * The value is highlighted using {@link highlight}.
471
- * @param label - The label of the value.
472
- * @param value - The value.
473
- * @param level - The log level.
474
- */
475
- value(t, e, i) {
476
- return this.text(`${t}: ${this.highlight(String(e))}`, i);
149
+ static parseVector(r, e) {
150
+ return r instanceof c ? (e = r.y, r = r.x) : e === void 0 && (e = r), { x: r, y: e };
477
151
  }
152
+ }
153
+ class p {
478
154
  /**
479
- * Logs emphasized text.
480
- * @param text - The text to log.
481
- * @param level - The log level.
155
+ * Returns `true` if this result is a {@link Result.Success}.
482
156
  */
483
- emphasized(t, e) {
484
- return this.text(this.emphasize(t), e);
157
+ isOk() {
158
+ return !1;
485
159
  }
486
160
  /**
487
- * Logs highlighted text.
488
- * @param text - The text to log.
489
- * @param level - The log level.
161
+ * Returns `true` if this result is a {@link Result.Failure}.
490
162
  */
491
- highlighted(t, e) {
492
- return this.text(this.highlight(t), e);
163
+ isError() {
164
+ return !1;
493
165
  }
494
166
  /**
495
- * Logs each item on a new line.
496
- * @param lines - The items to log.
497
- * @param level - The log level.
167
+ * Executes a callback for side effects if this result is a {@link Result.Success}.
498
168
  */
499
- lines(t, e) {
500
- return t.map(String).forEach((i) => this.text(i, e)), this;
169
+ ifOk(r) {
170
+ return this.isOk() && r(this.value), this;
501
171
  }
502
172
  /**
503
- * Logs a message.
504
- * @param message - The message to log.
505
- * @param level - The log level.
173
+ * Executes a callback for side effects if this result is a {@link Result.Failure}.
506
174
  */
507
- log(t, e) {
508
- return this.text(String(t), e);
175
+ ifError(r) {
176
+ return this.isError() && r(this.error), this;
509
177
  }
510
- /**
511
- * Logs text using this logger's format.
512
- * @param text - The text to log.
513
- * @param level - The log level.
514
- */
515
- text(t, e = 0) {
516
- if (!this.isLevelEnabled(e))
178
+ }
179
+ var d;
180
+ ((n) => {
181
+ class r extends p {
182
+ constructor(t) {
183
+ super(), this.value = t;
184
+ }
185
+ value;
186
+ isOk() {
187
+ return !0;
188
+ }
189
+ map(t) {
190
+ return i(t(this.value));
191
+ }
192
+ mapError(t) {
193
+ return i(this.value);
194
+ }
195
+ next(t) {
196
+ return t(this.value);
197
+ }
198
+ orElse(t) {
517
199
  return this;
518
- const i = this.format(this.applyPrefix(t, e));
519
- switch (e) {
520
- case 1:
521
- console.info(i);
522
- break;
523
- case 3:
524
- console.warn(i);
525
- break;
526
- case 4:
527
- console.error(i);
528
- break;
529
- default:
530
- console.log(i);
531
- break;
532
200
  }
533
- return this;
534
- }
535
- /**
536
- * Logs an newline character.
537
- */
538
- newLine() {
539
- return console.log(`
540
- `), this;
541
- }
542
- /**
543
- * Checks if the given log level is enabled.
544
- * @param level - The log level to check.
545
- */
546
- isLevelEnabled(t) {
547
- return this.level === void 0 ? !0 : Array.isArray(this.level) ? this.level.includes(t) : this.level <= t;
548
- }
549
- // ===== Formatting strings =====
550
- /**
551
- * Formats text using this logger's formatting properties.
552
- * @param text - The text to format.
553
- */
554
- format(t) {
555
- return this.indentString ? this.applyPrefix(this.indentString.repeat(this.indent) + t) : this.applyPrefix(t);
556
- }
557
- /**
558
- * Prepends a prefix to text.
559
- * @param text - The text to apply the prefix to.
560
- * @param level - The log level.
561
- */
562
- applyPrefix(t, e) {
563
- const i = e ? this.prefix[e] : this.prefix.global;
564
- return i ? `${i} ${t}` : t;
565
- }
566
- }
567
- function $(r) {
568
- return `# ${r}`;
569
- }
570
- function B(r) {
571
- return `## ${r}`;
572
- }
573
- function S(r) {
574
- return `### ${r}`;
575
- }
576
- function M(r) {
577
- return `#### ${r}`;
578
- }
579
- function v(r) {
580
- return `##### ${r}`;
581
- }
582
- function k(r) {
583
- return `###### ${r}`;
584
- }
585
- function E(r) {
586
- return `**${r}**`;
587
- }
588
- function z(r) {
589
- return `*${r}*`;
590
- }
591
- function D(r) {
592
- return `\`${r}\``;
593
- }
594
- function I(r) {
595
- return `\`\`\`${r}\`\`\``;
596
- }
597
- function N(r) {
598
- return `~~${r}~~`;
599
- }
600
- function P(r, t) {
601
- return `[${r}](${t})`;
602
- }
603
- function T(r) {
604
- return `> ${r}`;
605
- }
606
- function j() {
607
- return "---";
608
- }
609
- const G = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
610
- __proto__: null,
611
- bold: E,
612
- code: D,
613
- codeBlock: I,
614
- heading1: $,
615
- heading2: B,
616
- heading3: S,
617
- heading4: M,
618
- heading5: v,
619
- heading6: k,
620
- horizontalRule: j,
621
- italic: z,
622
- link: P,
623
- quote: T,
624
- strikethrough: N
625
- }, Symbol.toStringTag, { value: "Module" }));
626
- class a {
627
- x;
628
- y;
629
- constructor(t, e) {
630
- this.x = t, this.y = e ?? t;
631
- }
632
- static get ZERO() {
633
- return new a(0, 0);
634
- }
635
- get clone() {
636
- return new a(this.x, this.y);
637
- }
638
- get magnitude() {
639
- return this.getDistance(this);
640
- }
641
- setX(t) {
642
- return this.x = t, this;
643
- }
644
- setY(t) {
645
- return this.y = t, this;
646
- }
647
- set(t, e) {
648
- return this.x = t, this.y = e, this;
649
- }
650
- round() {
651
- return this.x = Math.round(this.x), this.y = Math.round(this.y), this;
652
- }
653
- normalize() {
654
- const t = this.magnitude;
655
- return this.scale(t === 0 ? 0 : 1 / t);
656
- }
657
- scale(t) {
658
- return this.multiply(t);
659
- }
660
- getDistanceSquared(t, e) {
661
- const i = a.parseVector(t, e), s = this.x - i.x, u = this.y - i.y;
662
- return s * s + u * u;
663
- }
664
- getDistance(t, e) {
665
- const i = a.parseVector(t, e);
666
- return Math.sqrt(this.getDistanceSquared(i.x, i.y));
667
- }
668
- add(t, e) {
669
- const i = a.parseVector(t, e);
670
- return this.x += i.x, this.y += i.y, this;
671
- }
672
- subtract(t, e) {
673
- const i = a.parseVector(t, e);
674
- return this.x -= i.x, this.y -= i.y, this;
675
- }
676
- multiply(t, e) {
677
- const i = a.parseVector(t, e);
678
- return this.x *= i.x, this.y *= i.y, this;
679
- }
680
- divide(t, e) {
681
- const i = a.parseVector(t, e);
682
- return this.x /= i.x, this.y /= i.y, this;
683
- }
684
- lerp(t, e) {
685
- return this.x += (t.x - this.x) * e, this.y += (t.y - this.y) * e, this;
686
- }
687
- static sum(t, e) {
688
- return t.clone.add(e);
689
- }
690
- static difference(t, e) {
691
- return t.clone.subtract(e);
692
- }
693
- static product(t, e) {
694
- return t.clone.multiply(e);
201
+ unwrapOr(t) {
202
+ return this.value;
203
+ }
204
+ match(t, o) {
205
+ return t(this.value);
206
+ }
207
+ filter(t, o) {
208
+ return t(this.value) ? i(this.value) : a(o(this.value));
209
+ }
695
210
  }
696
- static division(t, e) {
697
- return t.clone.divide(e);
211
+ n.Success = r;
212
+ class e extends p {
213
+ constructor(t) {
214
+ super(), this.error = t;
215
+ }
216
+ error;
217
+ isError() {
218
+ return !0;
219
+ }
220
+ map(t) {
221
+ return a(this.error);
222
+ }
223
+ mapError(t) {
224
+ return a(t(this.error));
225
+ }
226
+ next(t) {
227
+ return a(this.error);
228
+ }
229
+ orElse(t) {
230
+ return t(this.error);
231
+ }
232
+ unwrapOr(t) {
233
+ return t;
234
+ }
235
+ match(t, o) {
236
+ return o(this.error);
237
+ }
238
+ filter(t, o) {
239
+ return a(this.error);
240
+ }
698
241
  }
699
- static scale(t, e) {
700
- return t.clone.scale(e);
242
+ n.Failure = e;
243
+ function i(s) {
244
+ return new r(s);
701
245
  }
702
- static normalize(t) {
703
- return t.clone.normalize();
246
+ n.ok = i;
247
+ function a(s) {
248
+ return new e(s);
704
249
  }
705
- static lerp(t, e, i) {
706
- return t.clone.lerp(e, i);
250
+ n.error = a;
251
+ function h(s, t) {
252
+ try {
253
+ return i(s());
254
+ } catch (o) {
255
+ return a(t ? t(o) : o);
256
+ }
707
257
  }
708
- static from({ x: t, y: e }) {
709
- return new a(t, e);
258
+ n.wrap = h;
259
+ function m(s, t) {
260
+ return s != null ? i(s) : a(t);
261
+ }
262
+ n.nonNullOr = m;
263
+ function g(s, t) {
264
+ return s != null ? i(s) : t();
265
+ }
266
+ n.nonNullOrElse = g;
267
+ function y(s, t, o) {
268
+ let u = s;
269
+ for (; t(u); ) {
270
+ const l = o(u);
271
+ if (l.isError())
272
+ return l;
273
+ u = l.value;
274
+ }
275
+ return i(u);
276
+ }
277
+ n.repeat = y;
278
+ function v(s, t, o) {
279
+ let u = o;
280
+ for (const l of s) {
281
+ const f = t(u, l);
282
+ if (f.isError())
283
+ return f;
284
+ u = f.value;
285
+ }
286
+ return i(u);
287
+ }
288
+ n.reduce = v;
289
+ function x(s) {
290
+ const t = [];
291
+ for (const o of s) {
292
+ if (o.isError())
293
+ return a(o.error);
294
+ t.push(o.value);
295
+ }
296
+ return i(t);
297
+ }
298
+ n.all = x;
299
+ function E(s, t, o) {
300
+ for (const u of s) {
301
+ const l = t(u);
302
+ if (l.isOk())
303
+ return l;
304
+ }
305
+ return o;
710
306
  }
711
- static parseVector(t, e) {
712
- return t instanceof a ? (e = t.y, t = t.x) : e === void 0 && (e = t), { x: t, y: e };
307
+ n.any = E;
308
+ function k(s, t, o, u) {
309
+ return t(s) ? i(o(s)) : a(u(s));
713
310
  }
714
- }
311
+ n.require = k;
312
+ })(d || (d = {}));
715
313
  export {
716
- h as ANSI,
717
- n as Ansi,
718
- R as EventEmitter,
719
- w as LogLevel,
720
- J as Logger,
721
- G as Markdown,
722
- a as Vector2,
723
- q as clamp,
724
- C as formatRelativeTime,
725
- y as formatTime,
726
- H as getLongestCommonPrefix,
727
- p as isValidInteger,
728
- b as isValidNumber,
729
- Z as parseBool,
730
- Y as parseOptionalFloat,
731
- X as parseOptionalInteger,
732
- A as randomFromArray,
733
- O as randomRange,
734
- F as removeDuplicatesFromArray,
735
- x as removeFromArray,
736
- W as round
314
+ _ as ANSI,
315
+ j as Ansi,
316
+ I as BASE_URL,
317
+ p as BaseResult,
318
+ tr as EventEmitter,
319
+ P as LogLevel,
320
+ V as Logger,
321
+ T as Markdown,
322
+ d as Result,
323
+ c as Vector2,
324
+ er as capitalize,
325
+ nr as clamp,
326
+ ir as fillTemplate,
327
+ sr as formatRelativeTime,
328
+ or as formatTime,
329
+ ar as getLongestCommonPrefix,
330
+ X as inspect,
331
+ Y as inspectArray,
332
+ Z as inspectError,
333
+ G as inspectFunction,
334
+ H as inspectFunctionCall,
335
+ J as inspectMap,
336
+ K as inspectObject,
337
+ Q as inspectReactElement,
338
+ W as inspectSet,
339
+ R as inspectString,
340
+ ur as interleave,
341
+ qr as isObject,
342
+ cr as isValidInteger,
343
+ lr as isValidNumber,
344
+ hr as isValidUrl,
345
+ fr as isolateSubstring,
346
+ pr as kebabToCamelCase,
347
+ Dr as mergeDeep,
348
+ dr as parseBool,
349
+ mr as parseOptionalFloat,
350
+ gr as parseOptionalInteger,
351
+ yr as randomFromArray,
352
+ vr as randomIndex,
353
+ xr as randomInt,
354
+ Er as randomRange,
355
+ kr as removeBaseUrl,
356
+ Or as removeDuplicatesFromArray,
357
+ $r as removeFromArray,
358
+ br as removeUrlProtocol,
359
+ wr as replaceAll,
360
+ Sr as resolveUrl,
361
+ Ar as round,
362
+ Fr as splitAt
737
363
  };
738
364
  //# sourceMappingURL=main.js.map