@synnaxlabs/x 0.41.0 → 0.42.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/.turbo/turbo-build.log +23 -23
  2. package/dist/binary.cjs +1 -1
  3. package/dist/binary.js +2 -2
  4. package/dist/{bounds-M-SZ3X1Z.cjs → bounds-BQo7rvs9.cjs} +1 -1
  5. package/dist/{bounds-DQrjn60Q.js → bounds-Bn5_l4Z3.js} +10 -9
  6. package/dist/bounds.cjs +1 -1
  7. package/dist/bounds.js +1 -1
  8. package/dist/compare.cjs +1 -1
  9. package/dist/compare.js +1 -1
  10. package/dist/deep.cjs +1 -1
  11. package/dist/deep.js +84 -77
  12. package/dist/{dimensions-PWy5QZoM.cjs → dimensions-D2QGoNXO.cjs} +1 -1
  13. package/dist/dimensions.cjs +1 -1
  14. package/dist/{external-CvWr1nhS.cjs → external-DWQITF5_.cjs} +1 -1
  15. package/dist/index-BywOGO8U.js +1074 -0
  16. package/dist/index-CYYjI7Uf.cjs +1 -0
  17. package/dist/index-C_6NXBlg.cjs +3 -0
  18. package/dist/{index-BVC_8Cg9.js → index-QGplUHuy.js} +1 -1
  19. package/dist/index.cjs +3 -3
  20. package/dist/index.js +702 -243
  21. package/dist/record.js +3 -1
  22. package/dist/{scale-DL9VFGhL.cjs → scale-BtZINJ-A.cjs} +1 -1
  23. package/dist/{scale-DQwBWnwc.js → scale-DfJe9755.js} +1 -1
  24. package/dist/scale.cjs +1 -1
  25. package/dist/scale.js +1 -1
  26. package/dist/{series-D0zxMWxP.js → series-B9JERcqi.js} +571 -492
  27. package/dist/series-DqJ6f97G.cjs +11 -0
  28. package/dist/spatial.cjs +1 -1
  29. package/dist/spatial.js +2 -2
  30. package/dist/src/binary/{encoder.d.ts → codec.d.ts} +14 -8
  31. package/dist/src/binary/codec.d.ts.map +1 -0
  32. package/dist/src/binary/codec.spec.d.ts +2 -0
  33. package/dist/src/binary/codec.spec.d.ts.map +1 -0
  34. package/dist/src/binary/index.d.ts +1 -1
  35. package/dist/src/binary/index.d.ts.map +1 -1
  36. package/dist/src/breaker/breaker.d.ts +14 -21
  37. package/dist/src/breaker/breaker.d.ts.map +1 -1
  38. package/dist/src/change/change.d.ts +5 -18
  39. package/dist/src/change/change.d.ts.map +1 -1
  40. package/dist/src/color/color.d.ts +126 -0
  41. package/dist/src/color/color.d.ts.map +1 -0
  42. package/dist/src/color/color.spec.d.ts +2 -0
  43. package/dist/src/color/color.spec.d.ts.map +1 -0
  44. package/dist/src/color/external.d.ts +5 -0
  45. package/dist/src/color/external.d.ts.map +1 -0
  46. package/dist/src/color/gradient.d.ts +18 -0
  47. package/dist/src/color/gradient.d.ts.map +1 -0
  48. package/dist/src/color/index.d.ts +2 -0
  49. package/dist/src/color/index.d.ts.map +1 -0
  50. package/dist/src/color/palette.d.ts +19 -0
  51. package/dist/src/color/palette.d.ts.map +1 -0
  52. package/dist/src/color/transformColorsToHex.d.ts +6 -0
  53. package/dist/src/color/transformColorsToHex.d.ts.map +1 -0
  54. package/dist/src/control/control.d.ts +69 -74
  55. package/dist/src/control/control.d.ts.map +1 -1
  56. package/dist/src/deep/merge.d.ts +1 -1
  57. package/dist/src/deep/merge.d.ts.map +1 -1
  58. package/dist/src/errors/errors.d.ts +127 -7
  59. package/dist/src/errors/errors.d.ts.map +1 -1
  60. package/dist/src/errors/errors.spec.d.ts +2 -0
  61. package/dist/src/errors/errors.spec.d.ts.map +1 -0
  62. package/dist/src/index.d.ts +4 -0
  63. package/dist/src/index.d.ts.map +1 -1
  64. package/dist/src/jsonrpc/jsonrpc.d.ts +10 -7
  65. package/dist/src/jsonrpc/jsonrpc.d.ts.map +1 -1
  66. package/dist/src/kv/types.d.ts +1 -7
  67. package/dist/src/kv/types.d.ts.map +1 -1
  68. package/dist/src/migrate/migrate.d.ts +1 -1
  69. package/dist/src/notation/notation.d.ts +5 -1
  70. package/dist/src/notation/notation.d.ts.map +1 -1
  71. package/dist/src/record.d.ts +2 -1
  72. package/dist/src/record.d.ts.map +1 -1
  73. package/dist/src/replace.d.ts +2 -0
  74. package/dist/src/replace.d.ts.map +1 -0
  75. package/dist/src/runtime/os.d.ts +9 -1
  76. package/dist/src/runtime/os.d.ts.map +1 -1
  77. package/dist/src/singleton/define.d.ts +9 -0
  78. package/dist/src/singleton/define.d.ts.map +1 -0
  79. package/dist/src/singleton/define.spec.d.ts +2 -0
  80. package/dist/src/singleton/define.spec.d.ts.map +1 -0
  81. package/dist/src/singleton/index.d.ts +2 -0
  82. package/dist/src/singleton/index.d.ts.map +1 -0
  83. package/dist/src/spatial/base.d.ts +74 -70
  84. package/dist/src/spatial/base.d.ts.map +1 -1
  85. package/dist/src/spatial/box/box.d.ts +18 -76
  86. package/dist/src/spatial/box/box.d.ts.map +1 -1
  87. package/dist/src/spatial/dimensions/dimensions.d.ts +5 -29
  88. package/dist/src/spatial/dimensions/dimensions.d.ts.map +1 -1
  89. package/dist/src/spatial/direction/direction.d.ts +9 -1
  90. package/dist/src/spatial/direction/direction.d.ts.map +1 -1
  91. package/dist/src/spatial/location/location.d.ts +43 -22
  92. package/dist/src/spatial/location/location.d.ts.map +1 -1
  93. package/dist/src/spatial/scale/scale.d.ts +12 -120
  94. package/dist/src/spatial/scale/scale.d.ts.map +1 -1
  95. package/dist/src/spatial/xy/xy.d.ts +5 -29
  96. package/dist/src/spatial/xy/xy.d.ts.map +1 -1
  97. package/dist/src/sync/index.d.ts +2 -0
  98. package/dist/src/sync/index.d.ts.map +1 -0
  99. package/dist/src/sync/mutex.d.ts +8 -0
  100. package/dist/src/sync/mutex.d.ts.map +1 -0
  101. package/dist/src/telem/gl.d.ts +4 -1
  102. package/dist/src/telem/gl.d.ts.map +1 -1
  103. package/dist/src/telem/series.d.ts +46 -125
  104. package/dist/src/telem/series.d.ts.map +1 -1
  105. package/dist/src/telem/telem.d.ts +101 -86
  106. package/dist/src/telem/telem.d.ts.map +1 -1
  107. package/dist/src/toArray.d.ts +1 -1
  108. package/dist/src/toArray.d.ts.map +1 -1
  109. package/dist/src/zod/util.d.ts.map +1 -1
  110. package/dist/telem.cjs +1 -1
  111. package/dist/telem.js +1 -1
  112. package/dist/toArray.cjs +1 -1
  113. package/dist/toArray.js +1 -1
  114. package/dist/zod.cjs +1 -1
  115. package/package.json +5 -2
  116. package/src/binary/codec.spec.ts +370 -0
  117. package/src/binary/{encoder.ts → codec.ts} +55 -11
  118. package/src/binary/index.ts +1 -1
  119. package/src/breaker/breaker.spec.ts +16 -25
  120. package/src/breaker/breaker.ts +36 -19
  121. package/src/color/color.spec.ts +673 -0
  122. package/src/color/color.ts +317 -0
  123. package/src/color/external.ts +13 -0
  124. package/src/color/gradient.ts +78 -0
  125. package/src/color/index.ts +10 -0
  126. package/src/color/palette.ts +28 -0
  127. package/src/color/transformColorsToHex.ts +30 -0
  128. package/src/control/control.ts +30 -22
  129. package/src/deep/merge.spec.ts +60 -0
  130. package/src/deep/merge.ts +13 -8
  131. package/src/errors/errors.spec.ts +152 -0
  132. package/src/errors/errors.ts +225 -10
  133. package/src/index.ts +4 -0
  134. package/src/jsonrpc/jsonrpc.ts +12 -8
  135. package/src/migrate/migrate.ts +2 -2
  136. package/src/primitive.ts +1 -1
  137. package/src/record.ts +5 -1
  138. package/src/replace.ts +1 -0
  139. package/src/singleton/define.spec.ts +93 -0
  140. package/src/singleton/define.ts +27 -0
  141. package/src/singleton/index.ts +10 -0
  142. package/src/sync/index.ts +1 -0
  143. package/src/sync/mutex.ts +16 -0
  144. package/src/telem/series.spec.ts +32 -0
  145. package/src/telem/series.ts +54 -19
  146. package/src/telem/telem.spec.ts +151 -10
  147. package/src/telem/telem.ts +126 -73
  148. package/src/toArray.ts +2 -2
  149. package/src/zod/util.spec.ts +17 -1
  150. package/src/zod/util.ts +4 -2
  151. package/tsconfig.tsbuildinfo +1 -1
  152. package/dist/index-BG3Scw3G.cjs +0 -1
  153. package/dist/index-C3QzbIwt.js +0 -101
  154. package/dist/index-CnclyYpG.cjs +0 -3
  155. package/dist/series-BMma2b5q.cjs +0 -11
  156. package/dist/src/binary/encoder.d.ts.map +0 -1
  157. package/dist/src/binary/encoder.spec.d.ts +0 -2
  158. package/dist/src/binary/encoder.spec.d.ts.map +0 -1
  159. package/src/binary/encoder.spec.ts +0 -174
package/dist/index.js CHANGED
@@ -1,165 +1,437 @@
1
- var j = Object.defineProperty;
2
- var A = (e, t, r) => t in e ? j(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var g = (e, t, r) => A(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { J as N } from "./index-C3QzbIwt.js";
5
- import { e as Oe } from "./index-C3QzbIwt.js";
6
- import { z as l } from "zod";
7
- import { a as b } from "./series-D0zxMWxP.js";
8
- import { c as ve, D as Pe, M as ke, R as Ce, S as Ie, d as Re, b as ze, T as De, g as Ue, f as Be, h as Ge, i as Ze, e as Fe, s as Ve, t as qe } from "./series-D0zxMWxP.js";
9
- import { a as We } from "./index-DizUWH6z.js";
10
- import { c as Qe } from "./change-DLl6DccR.js";
11
- import { c as Xe, s as Ye } from "./scale-DQwBWnwc.js";
12
- import { i as O, a as L, b as v, L as y, G as M, E as P } from "./index-BVC_8Cg9.js";
13
- import { c as rr, d as tr, p as nr } from "./index-BVC_8Cg9.js";
14
- import { debounce as sr, throttle as ar } from "./debounce.js";
15
- import { deep as cr } from "./deep.js";
16
- import { isObject as fr } from "./identity.js";
17
- import { e as mr } from "./external-DqPrWKvU.js";
18
- import { link as gr } from "./link.js";
19
- import { s as k, f as C, g as I, h as R, i as z, j as D, k as U, l as B, m as G, r as Z, n as F } from "./bounds-DQrjn60Q.js";
20
- import { b as hr } from "./bounds-DQrjn60Q.js";
21
- import { observe as Sr } from "./observe.js";
22
- import { getEntries as yr, mapValues as Mr, unknownRecordZ as Er } from "./record.js";
23
- import { e as Tr } from "./external-BPgtxa8d.js";
24
- import { Search as wr } from "./search.js";
25
- import { b as Ar } from "./box-Cc8IzcNo.js";
26
- import { d as Or } from "./dimensions-CRgergMS.js";
27
- import { d as vr } from "./direction-BL0PhD1k.js";
28
- import { l as kr } from "./location-C3aeu046.js";
29
- import { p as Ir } from "./position-DIglP1l2.js";
30
- import { s as zr } from "./spatial-BSWPzMkK.js";
31
- import { x as Ur } from "./xy-D_LqxaGt.js";
32
- import { nullToArr as Gr, toArray as Zr } from "./toArray.js";
33
- import { u as Vr } from "./index-D4NCYiQB.js";
34
- import { URL as Jr, buildQueryString as Wr } from "./url.js";
35
- import { RoutedWorker as Qr, TypedWorker as Kr, createMockWorkers as Xr } from "./worker.js";
36
- import { e as et } from "./external-C8TFju8Q.js";
37
- const V = 2, q = 3, J = 2, W = (e, t) => {
1
+ var ue = Object.defineProperty;
2
+ var fe = (e, t, r) => t in e ? ue(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var m = (e, t, r) => fe(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { J as de } from "./index-BywOGO8U.js";
5
+ import { c as tr } from "./index-BywOGO8U.js";
6
+ import p, { z as c } from "zod";
7
+ import { a as y } from "./series-B9JERcqi.js";
8
+ import { c as nr, D as sr, M as or, R as ir, S as ar, d as cr, b as lr, T as ur, g as fr, f as dr, h as hr, i as mr, e as pr, s as gr, t as br } from "./series-B9JERcqi.js";
9
+ import { a as _r } from "./index-DizUWH6z.js";
10
+ import { c as vr } from "./change-DLl6DccR.js";
11
+ import { c as Sr, s as $r } from "./scale-DfJe9755.js";
12
+ import { i as he, a as me, b as pe, L as C, G as I, E as ge } from "./index-QGplUHuy.js";
13
+ import { c as Mr, d as Tr, p as jr } from "./index-QGplUHuy.js";
14
+ import { debounce as Or, throttle as Ar } from "./debounce.js";
15
+ import { deep as Ir } from "./deep.js";
16
+ import { isObject as Nr } from "./identity.js";
17
+ import { e as Rr } from "./external-DqPrWKvU.js";
18
+ import { link as qr } from "./link.js";
19
+ import { s as be, g as ye, h as _e, i as we, j as ve, k as xe, l as Se, n as $e, m as Ee, r as Me, o as Te } from "./bounds-Bn5_l4Z3.js";
20
+ import { b as Ur } from "./bounds-Bn5_l4Z3.js";
21
+ import { observe as Dr } from "./observe.js";
22
+ import { getEntries as Br, mapValues as Vr, unknownRecordZ as Hr } from "./record.js";
23
+ import { e as Yr } from "./external-BPgtxa8d.js";
24
+ import { Search as Qr } from "./search.js";
25
+ import { b as Xr } from "./box-Cc8IzcNo.js";
26
+ import { d as tn } from "./dimensions-CRgergMS.js";
27
+ import { d as nn } from "./direction-BL0PhD1k.js";
28
+ import { l as on } from "./location-C3aeu046.js";
29
+ import { p as cn } from "./position-DIglP1l2.js";
30
+ import { s as un } from "./spatial-BSWPzMkK.js";
31
+ import { x as dn } from "./xy-D_LqxaGt.js";
32
+ import { nullToArr as mn, toArray as pn } from "./toArray.js";
33
+ import { u as bn } from "./index-D4NCYiQB.js";
34
+ import { URL as _n, buildQueryString as wn } from "./url.js";
35
+ import { RoutedWorker as xn, TypedWorker as Sn, createMockWorkers as $n } from "./worker.js";
36
+ import { e as Mn } from "./external-C8TFju8Q.js";
37
+ const je = 2, ke = 3, Oe = 2, Ae = (e, t) => {
38
38
  if (Number.isNaN(e) || !Number.isFinite(e)) return e;
39
- const r = k(t);
39
+ const r = be(t);
40
40
  if (r == 0) return e;
41
41
  let n;
42
- r >= 1e3 ? n = V : r >= 1 ? n = q : n = Math.ceil(-Math.log10(r)) + J;
42
+ r >= 1e3 ? n = je : r >= 1 ? n = ke : n = Math.ceil(-Math.log10(r)) + Oe;
43
43
  const s = 10 ** n;
44
44
  return Math.round(e * s) / s;
45
- }, be = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
45
+ }, qt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
46
46
  __proto__: null,
47
- abs: C,
48
- add: I,
49
- closeTo: R,
50
- div: z,
51
- equal: D,
52
- max: U,
53
- min: B,
54
- mult: G,
55
- roundBySpan: W,
56
- roundToNearestMagnitude: Z,
57
- sub: F
58
- }, Symbol.toStringTag, { value: "Module" })), H = async (e) => await new Promise(
59
- (t) => setTimeout(t, b.fromMilliseconds(e).milliseconds)
60
- ), Q = l.object({
61
- interval: b.z.optional(),
62
- maxRetries: l.number().optional(),
63
- scale: l.number().optional()
64
- }), K = (e = {}) => {
65
- const t = e.sleepFn || H, r = e.maxRetries ?? 5, n = e.scale ?? 1;
66
- let s = 0, i = new b(e.interval ?? b.milliseconds(1));
67
- return async () => s >= r ? !1 : (await t(i), i = i.mult(n), s++, !0);
68
- }, Se = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
47
+ abs: ye,
48
+ add: _e,
49
+ closeTo: we,
50
+ div: ve,
51
+ equal: xe,
52
+ max: Se,
53
+ min: $e,
54
+ mult: Ee,
55
+ roundBySpan: Ae,
56
+ roundToNearestMagnitude: Me,
57
+ sub: Te
58
+ }, Symbol.toStringTag, { value: "Module" })), F = async (e) => await new Promise(
59
+ (t) => setTimeout(t, y.fromMilliseconds(e).milliseconds)
60
+ ), Wt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
69
61
  __proto__: null,
70
- breakerConfig: Q,
71
- create: K
72
- }, Symbol.toStringTag, { value: "Module" })), u = class u extends Number {
73
- };
74
- g(u, "ABSOLUTE", 255), g(u, "MINIMUM", 0), g(u, "BOUNDS", {
75
- lower: u.MINIMUM,
76
- // upper bound is exclusive, so we add 1
77
- upper: u.ABSOLUTE + 1
78
- }), g(u, "z", l.union([
79
- l.instanceof(u),
80
- l.number().int().min(0).max(255).transform((t) => new u(t)),
81
- l.instanceof(Number).transform((t) => new u(t))
82
- ]));
83
- let S = u;
84
- const T = l.object({
85
- name: l.string(),
86
- key: l.string()
87
- }), X = (e) => l.object({
88
- subject: T,
62
+ sleep: F
63
+ }, Symbol.toStringTag, { value: "Module" }));
64
+ class Ce {
65
+ constructor(t) {
66
+ m(this, "config");
67
+ m(this, "retries");
68
+ m(this, "interval");
69
+ this.config = {
70
+ baseInterval: new y((t == null ? void 0 : t.baseInterval) ?? y.seconds(1)),
71
+ maxRetries: (t == null ? void 0 : t.maxRetries) ?? 5,
72
+ scale: (t == null ? void 0 : t.scale) ?? 1,
73
+ sleepFn: (t == null ? void 0 : t.sleepFn) ?? F
74
+ }, this.retries = 0, this.interval = new y(this.config.baseInterval);
75
+ }
76
+ async wait() {
77
+ const { maxRetries: t, scale: r, sleepFn: n } = this.config;
78
+ return this.retries >= t ? !1 : (await n(this.interval), this.interval = this.interval.mult(r), this.retries++, !0);
79
+ }
80
+ reset() {
81
+ this.retries = 0, this.interval = this.config.baseInterval;
82
+ }
83
+ }
84
+ const Ie = c.object({
85
+ baseInterval: y.z.optional(),
86
+ maxRetries: c.number().optional(),
87
+ scale: c.number().optional()
88
+ }), Ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
89
+ __proto__: null,
90
+ Breaker: Ce,
91
+ breakerConfig: Ie
92
+ }, Symbol.toStringTag, { value: "Module" })), Le = /^#?([0-9a-f]{6}|[0-9a-f]{8})$/i, q = c.string().regex(Le), b = c.number().min(0).max(255), Ne = c.number().min(0).max(1), W = c.tuple([b, b, b, Ne]), B = c.tuple([b, b, b]), Pe = (e) => $.safeParse(e).success, Re = (e) => W.safeParse(e).success, Ze = (e) => {
93
+ if (e == null) return;
94
+ const t = $.safeParse(e);
95
+ if (t.success) return J(t.data);
96
+ if (typeof e == "string") return e;
97
+ throw t.error;
98
+ }, d = (e, t = 1) => {
99
+ if (typeof e == "string") return He(e, t);
100
+ if (Array.isArray(e)) {
101
+ if (e.length < 3 || e.length > 4)
102
+ throw new Error(`Invalid color: [${e.join(", ")}]`);
103
+ return e.length === 3 ? [...e, t] : e;
104
+ }
105
+ throw new Error(`Invalid color: ${JSON.stringify(e)}`);
106
+ }, V = (e, t) => {
107
+ if (e == null || t == null) return !1;
108
+ const r = d(e), n = d(t);
109
+ return r.every((s, o) => s === n[o]);
110
+ }, H = (e) => {
111
+ if (e == null) return;
112
+ const [t, r, n, s] = d(e);
113
+ return `#${M(t)}${M(r)}${M(n)}${s === 1 ? "" : M(s * 255)}`;
114
+ }, J = (e) => {
115
+ const [t, r, n, s] = d(e);
116
+ return `rgba(${t}, ${r}, ${n}, ${s})`;
117
+ }, qe = (e) => `rgb(${Y(e)})`, Y = (e) => {
118
+ const [t, r, n] = d(e);
119
+ return `${t}, ${r}, ${n}`;
120
+ }, We = (e) => [...U(e), x(e)], U = (e) => [
121
+ _(e) / 255,
122
+ w(e) / 255,
123
+ v(e) / 255
124
+ ], _ = (e) => d(e)[0], w = (e) => d(e)[1], v = (e) => d(e)[2], x = (e) => d(e)[3], Ue = (e) => V(z, e), ze = (e) => Ge(d(e)), De = (e, t) => {
125
+ const [r, n, s] = d(e);
126
+ if (t > 100)
127
+ throw new Error(`Color opacity must be between 0 and 100, got ${t}`);
128
+ return t > 1 && (t /= 100), [r, n, s, t];
129
+ }, j = (e) => {
130
+ const [t, r, n] = U(e).map(
131
+ (s) => s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4
132
+ );
133
+ return Number((0.2126 * t + 0.7152 * r + 0.0722 * n).toFixed(3));
134
+ }, Fe = (e) => {
135
+ const [t, r, n] = U(e);
136
+ return 1 - (Math.max(t, r, n) - Math.min(t, r, n));
137
+ }, N = (e, t) => {
138
+ const r = d(e), n = d(t), s = j(r), o = j(n);
139
+ return (Math.max(s, o) + 0.5) / (Math.min(s, o) + 0.5);
140
+ }, Be = (e, ...t) => {
141
+ if (t.length === 0)
142
+ throw new Error("[Color.pickByContrast] - must provide at least one color");
143
+ const r = d(e), [n] = t.map((s) => d(s)).sort((s, o) => N(r, o) - N(r, s));
144
+ return n;
145
+ }, G = (e) => j(e) < 0.5, Ve = (e) => !G(e), $ = c.union([q, W, B]).transform((e) => d(e)), He = (e, t = 1) => {
146
+ if (!q.safeParse(e).success) throw new Error(`Invalid hex color: ${e}`);
147
+ return e = Je(e), [
148
+ T(e, 0),
149
+ T(e, 2),
150
+ T(e, 4),
151
+ e.length === 8 ? T(e, 6) / 255 : t
152
+ ];
153
+ }, z = [0, 0, 0, 0], M = (e) => Math.floor(e).toString(16).padStart(2, "0"), T = (e, t) => parseInt(e.slice(t, t + 2), 16), Je = (e) => e.startsWith("#") ? e.slice(1) : e, Ye = (e) => {
154
+ let [t, r, n] = e;
155
+ const s = e[3];
156
+ t /= 360, r /= 100, n /= 100;
157
+ let o, a, f;
158
+ if (r === 0)
159
+ o = a = f = n;
160
+ else {
161
+ const l = n < 0.5 ? n * (1 + r) : n + r - n * r, i = 2 * n - l;
162
+ o = L(i, l, t + 1 / 3), a = L(i, l, t), f = L(i, l, t - 1 / 3);
163
+ }
164
+ return [Math.round(o * 255), Math.round(a * 255), Math.round(f * 255), s];
165
+ }, L = (e, t, r) => (r < 0 && (r += 1), r > 1 && (r -= 1), r < 1 / 6 ? e + (t - e) * 6 * r : r < 1 / 2 ? t : r < 2 / 3 ? e + (t - e) * (2 / 3 - r) * 6 : e), Ge = (e) => {
166
+ let [t, r, n] = e;
167
+ const s = e[3];
168
+ t /= 255, r /= 255, n /= 255;
169
+ const o = Math.max(t, r, n), a = Math.min(t, r, n);
170
+ let f, l, i = (o + a) / 2;
171
+ if (o === a)
172
+ f = l = 0;
173
+ else {
174
+ const u = o - a;
175
+ l = i > 0.5 ? u / (2 - o - a) : u / (o + a), o === t ? f = (r - n) / u + (r < n ? 6 : 0) : o === r ? f = (n - t) / u + 2 : f = (t - r) / u + 4, f /= 6;
176
+ }
177
+ return f *= 360, l *= 100, i *= 100, [Math.round(f), Math.round(l), Math.round(i), s];
178
+ }, Q = c.union([q, W, c.string(), B]), Qe = d("#000000"), Ke = d("#ffffff"), K = c.object({
179
+ key: c.string(),
180
+ color: Q,
181
+ position: c.number(),
182
+ switched: c.boolean().optional()
183
+ }), Xe = c.array(K), et = (e, t) => {
184
+ if (e.length === 0) return z;
185
+ if (e = e.slice().sort((r, n) => r.position - n.position), t <= e[0].position) return d(e[0].color);
186
+ if (t >= e[e.length - 1].position)
187
+ return d(e[e.length - 1].color);
188
+ for (let r = 0; r < e.length - 1; r++) {
189
+ const n = e[r], s = e[r + 1];
190
+ if (t >= n.position && t <= s.position) {
191
+ if (t === n.position) return d(n.color);
192
+ if (t === s.position) return d(s.color);
193
+ const o = (t - n.position) / (s.position - n.position), a = d(n.color), f = d(s.color), l = Math.round(
194
+ _(a) + o * (_(f) - _(a))
195
+ ), i = Math.round(
196
+ w(a) + o * (w(f) - w(a))
197
+ ), u = Math.round(
198
+ v(a) + o * (v(f) - v(a))
199
+ ), h = x(a) + o * (x(f) - x(a));
200
+ return d([l, i, u, h]);
201
+ }
202
+ }
203
+ return d(e[e.length - 1].color);
204
+ }, tt = c.object({
205
+ key: c.string(),
206
+ name: c.string(),
207
+ color: $
208
+ }), rt = c.object({
209
+ key: c.string(),
210
+ name: c.string(),
211
+ swatches: c.array(tt)
212
+ }), X = (e) => {
213
+ const t = $.safeParse(e);
214
+ if (t.success) return H(t.data);
215
+ if (typeof e == "object" && e != null) {
216
+ const r = Array.isArray(e) ? [] : {};
217
+ for (const n of Object.keys(e))
218
+ r[n] = X(e[n]);
219
+ return r;
220
+ }
221
+ return e;
222
+ }, zt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
223
+ __proto__: null,
224
+ BLACK: Qe,
225
+ WHITE: Ke,
226
+ ZERO: z,
227
+ aValue: x,
228
+ bValue: v,
229
+ colorZ: $,
230
+ construct: d,
231
+ contrast: N,
232
+ crudeZ: Q,
233
+ cssString: Ze,
234
+ equals: V,
235
+ fromGradient: et,
236
+ fromHSLA: Ye,
237
+ gValue: w,
238
+ gradientZ: Xe,
239
+ grayness: Fe,
240
+ hex: H,
241
+ hsla: ze,
242
+ isColor: Re,
243
+ isCrude: Pe,
244
+ isDark: G,
245
+ isLight: Ve,
246
+ isZero: Ue,
247
+ luminance: j,
248
+ paletteZ: rt,
249
+ pickByContrast: Be,
250
+ rValue: _,
251
+ rgbCSS: qe,
252
+ rgbString: Y,
253
+ rgba1: We,
254
+ rgbaCSS: J,
255
+ setAlpha: De,
256
+ stopZ: K,
257
+ transformColorsToHex: X
258
+ }, Symbol.toStringTag, { value: "Module" })), ee = c.number().int().min(0).max(255), te = 255, re = 0, nt = {
259
+ lower: re,
260
+ upper: te + 1
261
+ }, ne = c.object({
262
+ name: c.string(),
263
+ key: c.string()
264
+ }), S = (e) => c.object({
265
+ subject: ne,
89
266
  resource: e,
90
- authority: S.z
91
- }), Y = (...e) => (t) => t.filter((r) => {
267
+ authority: ee
268
+ }), st = (...e) => (t) => t.filter((r) => {
92
269
  let n = !1;
93
270
  return r.to != null && (n = e.includes(r.to.resource)), r.from != null && !n && (n = e.includes(r.from.resource)), n;
94
- }), xe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
271
+ }), se = c.object({
272
+ from: S(c.any()),
273
+ to: c.null()
274
+ }), oe = c.object({
275
+ from: c.null(),
276
+ to: S(c.any())
277
+ }), ot = c.union([
278
+ se,
279
+ oe,
280
+ c.object({
281
+ from: S(c.any()),
282
+ to: S(c.any())
283
+ })
284
+ ]), Dt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
95
285
  __proto__: null,
96
- Authority: S,
97
- filterTransfersByChannelKey: Y,
98
- stateZ: X,
99
- subjectZ: T
100
- }, Symbol.toStringTag, { value: "Module" })), d = class d extends Error {
286
+ ABSOLUTE_AUTHORITY: te,
287
+ AUTHORITY_BOUNDS: nt,
288
+ ZERO_AUTHORITY: re,
289
+ acquireZ: oe,
290
+ authorityZ: ee,
291
+ filterTransfersByChannelKey: st,
292
+ releaseZ: se,
293
+ stateZ: S,
294
+ subjectZ: ne,
295
+ transferZ: ot
296
+ }, Symbol.toStringTag, { value: "Module" })), it = (e) => Object.getOwnPropertySymbols(globalThis).includes(e), at = (e, t) => {
297
+ const r = Symbol.for(e);
298
+ if (!it(r)) {
299
+ const n = t();
300
+ Object.defineProperty(globalThis, r, { value: n });
301
+ }
302
+ return () => globalThis[r];
303
+ }, ct = (e) => (t) => t != null && typeof t == "object" && "type" in t && typeof t.type == "string" ? t.type.startsWith(e) : t instanceof Error ? t.message.startsWith(e) : typeof t != "string" ? !1 : t.startsWith(e), k = (e) => {
304
+ var t;
305
+ return t = class extends Error {
306
+ constructor(s, o) {
307
+ super(s, o);
308
+ m(this, "discriminator", t.discriminator);
309
+ m(this, "type", t.TYPE);
310
+ m(this, "matches", t.matches);
311
+ this.name = t.TYPE;
312
+ }
313
+ static sub(s) {
314
+ return k(`${e}.${s}`);
315
+ }
316
+ }, m(t, "discriminator", "FreighterError"), m(t, "TYPE", e), m(t, "matches", ct(e)), t;
317
+ }, ie = (e) => {
318
+ if (e == null || typeof e != "object") return !1;
319
+ const t = e;
320
+ if (t.discriminator !== "FreighterError") return !1;
321
+ if (!("type" in t))
322
+ throw new Error(
323
+ `Freighter error is missing its type property: ${JSON.stringify(t)}`
324
+ );
325
+ return !0;
326
+ }, g = "unknown", P = "nil";
327
+ class lt {
101
328
  constructor() {
102
- super(d.MESSAGE);
329
+ m(this, "providers", []);
103
330
  }
104
- /** Returns true if the error or message is a cancellation error" */
105
- matches(t) {
106
- return typeof t == "string" ? t.includes(d.MESSAGE) : t instanceof d || t.message.includes(d.MESSAGE);
331
+ register(t) {
332
+ this.providers.push(t);
107
333
  }
108
- };
109
- g(d, "MESSAGE", "canceled");
110
- let E = d;
111
- const ee = new E(), ye = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
334
+ encode(t) {
335
+ if (t == null) return { type: P, data: "" };
336
+ if (ie(t))
337
+ for (const r of this.providers) {
338
+ const n = r.encode(t);
339
+ if (n != null) return n;
340
+ }
341
+ if (t instanceof Error) return { type: g, data: t.message };
342
+ if (typeof t == "string") return { type: g, data: t };
343
+ try {
344
+ return { type: g, data: JSON.stringify(t) };
345
+ } catch {
346
+ return { type: g, data: "unable to encode error information" };
347
+ }
348
+ }
349
+ decode(t) {
350
+ if (t == null || t.type === P) return null;
351
+ if (t.type === g) return new R(t.data);
352
+ for (const r of this.providers) {
353
+ const n = r.decode(t);
354
+ if (n != null) return n;
355
+ }
356
+ return new R(t.data);
357
+ }
358
+ }
359
+ const D = at("synnax-error-registry", () => new lt()), ut = ({
360
+ encode: e,
361
+ decode: t
362
+ }) => D().register({ encode: e, decode: t }), ft = (e) => D().encode(e), dt = (e) => e == null ? null : D().decode(e);
363
+ class R extends k("unknown") {
364
+ }
365
+ const ht = c.object({ type: c.string(), data: c.string() });
366
+ class mt extends k("canceled") {
367
+ }
368
+ const Ft = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
112
369
  __proto__: null,
113
- CANCELED: ee
114
- }, Symbol.toStringTag, { value: "Module" })), Me = (e) => e ? -1 : 1, re = (e) => {
370
+ Canceled: mt,
371
+ NONE: P,
372
+ UNKNOWN: g,
373
+ Unknown: R,
374
+ createTyped: k,
375
+ decode: dt,
376
+ encode: ft,
377
+ isTyped: ie,
378
+ payloadZ: ht,
379
+ register: ut
380
+ }, Symbol.toStringTag, { value: "Module" })), Bt = (e) => e ? -1 : 1, pt = p.object({
381
+ jsonrpc: p.string(),
382
+ id: p.number().optional(),
383
+ method: p.string().optional(),
384
+ params: p.unknown().optional(),
385
+ result: p.unknown().optional()
386
+ }), gt = (e) => {
115
387
  const t = new TextDecoder();
116
388
  let r = new Uint8Array(0), n = null;
117
389
  return (s) => {
118
- let i;
119
- typeof s == "string" ? i = new TextEncoder().encode(s) : s instanceof ArrayBuffer ? i = new Uint8Array(s) : i = s;
120
- const f = new Uint8Array(r.length + i.length);
121
- for (f.set(r), f.set(i, r.length), r = f; r.length > 0; ) {
390
+ let o;
391
+ typeof s == "string" ? o = new TextEncoder().encode(s) : s instanceof ArrayBuffer ? o = new Uint8Array(s) : o = s;
392
+ const a = new Uint8Array(r.length + o.length);
393
+ for (a.set(r), a.set(o, r.length), r = a; r.length > 0; ) {
122
394
  if (n === null) {
123
- const a = t.decode(r).match(/^Content-Length: (\d+)\r?\n\r?\n/);
124
- if (!a) break;
125
- n = parseInt(a[1]);
126
- const o = new TextEncoder().encode(a[0]).length;
127
- r = r.slice(o);
395
+ const l = t.decode(r).match(/^Content-Length: (\d+)\r?\n\r?\n/);
396
+ if (!l) break;
397
+ n = parseInt(l[1]);
398
+ const i = new TextEncoder().encode(l[0]).length;
399
+ r = r.slice(i);
128
400
  }
129
401
  if (n !== null && r.length >= n) {
130
- const m = r.slice(0, n);
402
+ const f = r.slice(0, n);
131
403
  r = r.slice(n), n = null;
132
- const a = t.decode(m), o = N.decodeString(a);
133
- e(o);
404
+ const l = t.decode(f), i = de.decodeString(l, pt);
405
+ e(i);
134
406
  } else break;
135
407
  }
136
408
  };
137
- }, te = (e) => {
409
+ }, bt = (e) => {
138
410
  const t = JSON.stringify(e);
139
411
  return `Content-Length: ${new TextEncoder().encode(t).length}\r
140
412
  \r
141
413
  ` + t;
142
- }, Ee = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
414
+ }, Vt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
143
415
  __proto__: null,
144
- encodeMessage: te,
145
- streamDecodeChunks: re
146
- }, Symbol.toStringTag, { value: "Module" })), _ = l.string().regex(/^\d+\.\d+\.\d+$/), p = (e, t, r = {}) => {
416
+ encodeMessage: bt,
417
+ streamDecodeChunks: gt
418
+ }, Symbol.toStringTag, { value: "Module" })), Z = c.string().regex(/^\d+\.\d+\.\d+$/), E = (e, t, r = {}) => {
147
419
  r.checkMajor ?? (r.checkMajor = !0), r.checkMinor ?? (r.checkMinor = !0), r.checkPatch ?? (r.checkPatch = !0);
148
- const n = _.parse(e), s = _.parse(t), [i, f, m] = n.split(".").map(Number), [a, o, c] = s.split(".").map(Number);
420
+ const n = Z.parse(e), s = Z.parse(t), [o, a, f] = n.split(".").map(Number), [l, i, u] = s.split(".").map(Number);
149
421
  if (r.checkMajor) {
150
- if (i < a) return y;
151
- if (i > a) return M;
422
+ if (o < l) return C;
423
+ if (o > l) return I;
152
424
  }
153
425
  if (r.checkMinor) {
154
- if (f < o) return y;
155
- if (f > o) return M;
426
+ if (a < i) return C;
427
+ if (a > i) return I;
156
428
  }
157
429
  if (r.checkPatch) {
158
- if (m < c) return y;
159
- if (m > c) return M;
430
+ if (f < u) return C;
431
+ if (f > u) return I;
160
432
  }
161
- return P;
162
- }, ne = (e, t, r = {}) => O(p(e, t, r)), $ = (e, t, r = {}) => L(p(e, t, r)), oe = (e, t, r = {}) => v(p(e, t, r)), se = ({
433
+ return ge;
434
+ }, yt = (e, t, r = {}) => he(E(e, t, r)), ae = (e, t, r = {}) => me(E(e, t, r)), _t = (e, t, r = {}) => pe(E(e, t, r)), wt = ({
163
435
  name: e,
164
436
  migrate: t
165
437
  }) => (r) => {
@@ -169,68 +441,68 @@ const ee = new E(), ye = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.de
169
441
  } catch (n) {
170
442
  throw console.log(`${e} failed to migrate from ${r.version}`), console.error(n), n;
171
443
  }
172
- }, ae = ({
444
+ }, vt = ({
173
445
  name: e,
174
446
  migrations: t,
175
447
  targetSchema: r,
176
448
  defaultVersion: n,
177
449
  def: s
178
450
  }) => {
179
- const i = Object.keys(t).sort(p).pop();
180
- if (i == null)
181
- return (o) => {
182
- if (o.version ?? (o.version = n), o.version !== s.version)
451
+ const o = Object.keys(t).sort(E).pop();
452
+ if (o == null)
453
+ return (i) => {
454
+ if (i.version ?? (i.version = n), i.version !== s.version)
183
455
  return console.log(
184
- `${e} version ${o.version} is newer than latest version of ${s.version}.
456
+ `${e} version ${i.version} is newer than latest version of ${s.version}.
185
457
  Returning default instead.
186
458
  `
187
459
  ), s;
188
460
  try {
189
- return r != null ? r.parse(o) : o;
190
- } catch (c) {
191
- return console.log(`${e} failed to parse default. Exiting with default`), console.error(c), s;
461
+ return r != null ? r.parse(i) : i;
462
+ } catch (u) {
463
+ return console.log(`${e} failed to parse default. Exiting with default`), console.error(u), s;
192
464
  }
193
465
  };
194
- const f = Object.keys(t).length;
195
- let m = !1;
196
- const a = (o) => {
466
+ const a = Object.keys(t).length;
467
+ let f = !1;
468
+ const l = (i) => {
197
469
  try {
198
- if (f === 0 || $(o.version, i))
199
- return console.log(m ? `${e} ${o.version} now up to date` : `${e} version ${o.version} is up to date with target version ${s.version}`), o;
200
- const c = o.version, h = t[c], x = h(o);
201
- return m = !0, a(x);
202
- } catch (c) {
470
+ if (a === 0 || ae(i.version, o))
471
+ return console.log(f ? `${e} ${i.version} now up to date` : `${e} version ${i.version} is up to date with target version ${s.version}`), i;
472
+ const u = i.version, h = t[u], A = h(i);
473
+ return f = !0, l(A);
474
+ } catch (u) {
203
475
  return console.log(
204
- `${e} failed to migrate from ${o.version} to ${i}`
205
- ), console.error(c), s;
476
+ `${e} failed to migrate from ${i.version} to ${o}`
477
+ ), console.error(u), s;
206
478
  }
207
479
  };
208
- return (o) => {
480
+ return (i) => {
209
481
  try {
210
- if (o.version == null)
482
+ if (i.version == null)
211
483
  if (n != null)
212
484
  console.log(
213
485
  `${e} version is null. Setting version to default of ${n}`
214
- ), o.version = n;
486
+ ), i.version = n;
215
487
  else
216
488
  return console.log(
217
489
  `${e} version is null and no default version set. Exiting with default`
218
490
  ), s;
219
- return a(o);
220
- } catch (c) {
221
- return console.log(`${e} failed to parse final result. Exiting with default`), console.error(c), s;
491
+ return l(i);
492
+ } catch (u) {
493
+ return console.log(`${e} failed to parse final result. Exiting with default`), console.error(u), s;
222
494
  }
223
495
  };
224
- }, _e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
496
+ }, Ht = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
225
497
  __proto__: null,
226
- compareSemVer: p,
227
- createMigration: se,
228
- migrator: ae,
229
- semVerNewer: $,
230
- semVerOlder: oe,
231
- semVerZ: _,
232
- versionsEqual: ne
233
- }, Symbol.toStringTag, { value: "Module" })), w = ["standard", "scientific", "engineering"], ie = l.enum(w), ce = (e, t, r) => {
498
+ compareSemVer: E,
499
+ createMigration: wt,
500
+ migrator: vt,
501
+ semVerNewer: ae,
502
+ semVerOlder: _t,
503
+ semVerZ: Z,
504
+ versionsEqual: yt
505
+ }, Symbol.toStringTag, { value: "Module" })), ce = ["standard", "scientific", "engineering"], xt = c.enum(ce), St = (e, t, r) => {
234
506
  if (Number.isNaN(e)) return "NaN";
235
507
  if (e === 1 / 0) return "∞";
236
508
  if (e === -1 / 0) return "-∞";
@@ -239,105 +511,292 @@ const ee = new E(), ye = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.de
239
511
  return t === 0 ? "0ᴇ0" : `0.${"0".repeat(t)}ᴇ0`;
240
512
  let n;
241
513
  return r === "scientific" ? n = Math.floor(Math.log10(Math.abs(e))) : n = Math.floor(Math.log10(Math.abs(e)) / 3) * 3, `${(e / 10 ** n).toFixed(t)}ᴇ${n}`;
242
- }, Te = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
514
+ }, Jt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
243
515
  __proto__: null,
244
- NOTATIONS: w,
245
- notationZ: ie,
246
- stringifyNumber: ce
247
- }, Symbol.toStringTag, { value: "Module" })), $e = (e) => {
516
+ NOTATIONS: ce,
517
+ notationZ: xt,
518
+ stringifyNumber: St
519
+ }, Symbol.toStringTag, { value: "Module" })), Yt = (e) => {
248
520
  if (e === void 0 || typeof e == "string" || typeof e == "number")
249
521
  return e;
250
522
  if (e.toString === void 0) throw new Error("invalid renderer");
251
523
  return e.toString();
252
- }, we = (e) => Array.isArray(e) ? [...e] : typeof e == "object" && e !== null ? { ...e } : e, le = (e, t = "") => {
524
+ }, Gt = (e) => Array.isArray(e) ? [...e] : typeof e == "object" && e !== null ? { ...e } : e, $t = (e, t = "") => {
253
525
  const r = e.length;
254
526
  return r === 0 ? t : r === 1 ? e[0] : r === 2 ? `${e[0]} and ${e[1]}` : `${e.slice(0, -1).join(", ")}, and ${e[r - 1]}`;
255
- }, fe = (e) => {
256
- const t = e.split(" "), r = /* @__PURE__ */ new Set(), n = t.map((a) => a.charAt(0).toLowerCase()).join("");
527
+ }, Et = (e) => {
528
+ const t = e.split(" "), r = /* @__PURE__ */ new Set(), n = t.map((l) => l.charAt(0).toLowerCase()).join("");
257
529
  r.add(n.replace(/-/g, "_")), r.add(n.replace(/(.)(.)/g, "$1_$2").replace(/-/g, "_"));
258
530
  const s = /\d+/g;
259
- e.match(s) && t.forEach((a, o) => {
260
- if (s.test(a)) {
261
- const c = t.map((h, x) => x !== o ? h.charAt(0).toLowerCase() : h).join("");
262
- r.add(c.replace(/-/g, "_")), r.add(
263
- c.replace(/(.)(.)/g, "$1_$2").replace(/-/g, "_")
531
+ e.match(s) && t.forEach((l, i) => {
532
+ if (s.test(l)) {
533
+ const u = t.map((h, A) => A !== i ? h.charAt(0).toLowerCase() : h).join("");
534
+ r.add(u.replace(/-/g, "_")), r.add(
535
+ u.replace(/(.)(.)/g, "$1_$2").replace(/-/g, "_")
264
536
  );
265
537
  }
266
538
  });
267
- const f = t.map(
268
- (a) => (a.length > 3 ? a.substring(0, 3) : a).toLowerCase()
539
+ const a = t.map(
540
+ (l) => (l.length > 3 ? l.substring(0, 3) : l).toLowerCase()
269
541
  );
270
- return r.add(f.join("").replace(/-/g, "_")), r.add(f.join("_").replace(/-/g, "_")), Array.from(r).filter(
271
- (a) => a.length >= 2 && a.length <= 12 && !/^\d/.test(a)
542
+ return r.add(a.join("").replace(/-/g, "_")), r.add(a.join("_").replace(/-/g, "_")), Array.from(r).filter(
543
+ (l) => l.length >= 2 && l.length <= 12 && !/^\d/.test(l)
272
544
  );
273
- }, je = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
545
+ }, Qt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
546
+ __proto__: null,
547
+ createShortIdentifiers: Et,
548
+ naturalLanguageJoin: $t
549
+ }, Symbol.toStringTag, { value: "Module" })), Mt = new Error("request for lock canceled");
550
+ var Tt = function(e, t, r, n) {
551
+ function s(o) {
552
+ return o instanceof r ? o : new r(function(a) {
553
+ a(o);
554
+ });
555
+ }
556
+ return new (r || (r = Promise))(function(o, a) {
557
+ function f(u) {
558
+ try {
559
+ i(n.next(u));
560
+ } catch (h) {
561
+ a(h);
562
+ }
563
+ }
564
+ function l(u) {
565
+ try {
566
+ i(n.throw(u));
567
+ } catch (h) {
568
+ a(h);
569
+ }
570
+ }
571
+ function i(u) {
572
+ u.done ? o(u.value) : s(u.value).then(f, l);
573
+ }
574
+ i((n = n.apply(e, t || [])).next());
575
+ });
576
+ };
577
+ class jt {
578
+ constructor(t, r = Mt) {
579
+ this._value = t, this._cancelError = r, this._queue = [], this._weightedWaiters = [];
580
+ }
581
+ acquire(t = 1, r = 0) {
582
+ if (t <= 0)
583
+ throw new Error(`invalid weight ${t}: must be positive`);
584
+ return new Promise((n, s) => {
585
+ const o = { resolve: n, reject: s, weight: t, priority: r }, a = le(this._queue, (f) => r <= f.priority);
586
+ a === -1 && t <= this._value ? this._dispatchItem(o) : this._queue.splice(a + 1, 0, o);
587
+ });
588
+ }
589
+ runExclusive(t) {
590
+ return Tt(this, arguments, void 0, function* (r, n = 1, s = 0) {
591
+ const [o, a] = yield this.acquire(n, s);
592
+ try {
593
+ return yield r(o);
594
+ } finally {
595
+ a();
596
+ }
597
+ });
598
+ }
599
+ waitForUnlock(t = 1, r = 0) {
600
+ if (t <= 0)
601
+ throw new Error(`invalid weight ${t}: must be positive`);
602
+ return this._couldLockImmediately(t, r) ? Promise.resolve() : new Promise((n) => {
603
+ this._weightedWaiters[t - 1] || (this._weightedWaiters[t - 1] = []), kt(this._weightedWaiters[t - 1], { resolve: n, priority: r });
604
+ });
605
+ }
606
+ isLocked() {
607
+ return this._value <= 0;
608
+ }
609
+ getValue() {
610
+ return this._value;
611
+ }
612
+ setValue(t) {
613
+ this._value = t, this._dispatchQueue();
614
+ }
615
+ release(t = 1) {
616
+ if (t <= 0)
617
+ throw new Error(`invalid weight ${t}: must be positive`);
618
+ this._value += t, this._dispatchQueue();
619
+ }
620
+ cancel() {
621
+ this._queue.forEach((t) => t.reject(this._cancelError)), this._queue = [];
622
+ }
623
+ _dispatchQueue() {
624
+ for (this._drainUnlockWaiters(); this._queue.length > 0 && this._queue[0].weight <= this._value; )
625
+ this._dispatchItem(this._queue.shift()), this._drainUnlockWaiters();
626
+ }
627
+ _dispatchItem(t) {
628
+ const r = this._value;
629
+ this._value -= t.weight, t.resolve([r, this._newReleaser(t.weight)]);
630
+ }
631
+ _newReleaser(t) {
632
+ let r = !1;
633
+ return () => {
634
+ r || (r = !0, this.release(t));
635
+ };
636
+ }
637
+ _drainUnlockWaiters() {
638
+ if (this._queue.length === 0)
639
+ for (let t = this._value; t > 0; t--) {
640
+ const r = this._weightedWaiters[t - 1];
641
+ r && (r.forEach((n) => n.resolve()), this._weightedWaiters[t - 1] = []);
642
+ }
643
+ else {
644
+ const t = this._queue[0].priority;
645
+ for (let r = this._value; r > 0; r--) {
646
+ const n = this._weightedWaiters[r - 1];
647
+ if (!n)
648
+ continue;
649
+ const s = n.findIndex((o) => o.priority <= t);
650
+ (s === -1 ? n : n.splice(0, s)).forEach((o) => o.resolve());
651
+ }
652
+ }
653
+ }
654
+ _couldLockImmediately(t, r) {
655
+ return (this._queue.length === 0 || this._queue[0].priority < r) && t <= this._value;
656
+ }
657
+ }
658
+ function kt(e, t) {
659
+ const r = le(e, (n) => t.priority <= n.priority);
660
+ e.splice(r + 1, 0, t);
661
+ }
662
+ function le(e, t) {
663
+ for (let r = e.length - 1; r >= 0; r--)
664
+ if (t(e[r]))
665
+ return r;
666
+ return -1;
667
+ }
668
+ var Ot = function(e, t, r, n) {
669
+ function s(o) {
670
+ return o instanceof r ? o : new r(function(a) {
671
+ a(o);
672
+ });
673
+ }
674
+ return new (r || (r = Promise))(function(o, a) {
675
+ function f(u) {
676
+ try {
677
+ i(n.next(u));
678
+ } catch (h) {
679
+ a(h);
680
+ }
681
+ }
682
+ function l(u) {
683
+ try {
684
+ i(n.throw(u));
685
+ } catch (h) {
686
+ a(h);
687
+ }
688
+ }
689
+ function i(u) {
690
+ u.done ? o(u.value) : s(u.value).then(f, l);
691
+ }
692
+ i((n = n.apply(e, t || [])).next());
693
+ });
694
+ };
695
+ class At {
696
+ constructor(t) {
697
+ this._semaphore = new jt(1, t);
698
+ }
699
+ acquire() {
700
+ return Ot(this, arguments, void 0, function* (t = 0) {
701
+ const [, r] = yield this._semaphore.acquire(1, t);
702
+ return r;
703
+ });
704
+ }
705
+ runExclusive(t, r = 0) {
706
+ return this._semaphore.runExclusive(() => t(), 1, r);
707
+ }
708
+ isLocked() {
709
+ return this._semaphore.isLocked();
710
+ }
711
+ waitForUnlock(t = 0) {
712
+ return this._semaphore.waitForUnlock(1, t);
713
+ }
714
+ release() {
715
+ this._semaphore.isLocked() && this._semaphore.release();
716
+ }
717
+ cancel() {
718
+ return this._semaphore.cancel();
719
+ }
720
+ }
721
+ class O extends At {
722
+ static new(t) {
723
+ return new O(t);
724
+ }
725
+ constructor(t) {
726
+ super(), Object.assign(this, t);
727
+ }
728
+ }
729
+ const Ct = (e) => new O(e), Kt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
274
730
  __proto__: null,
275
- createShortIdentifiers: fe,
276
- naturalLanguageJoin: le
731
+ mutex: O,
732
+ newMutex: Ct
277
733
  }, Symbol.toStringTag, { value: "Module" }));
278
734
  export {
279
- ve as DataType,
280
- Pe as Density,
281
- ke as MultiSeries,
282
- Ce as Rate,
283
- Qr as RoutedWorker,
284
- wr as Search,
285
- Ie as Series,
286
- Re as Size,
287
- ze as TimeRange,
288
- b as TimeSpan,
289
- De as TimeStamp,
290
- Kr as TypedWorker,
291
- Jr as URL,
292
- Ue as addSamples,
293
- Oe as binary,
294
- hr as bounds,
295
- Ar as box,
296
- Se as breaker,
297
- Wr as buildQueryString,
298
- We as caseconv,
299
- Qe as change,
300
- Xe as clamp,
301
- rr as compare,
302
- xe as control,
303
- Be as convertDataType,
304
- $e as convertRenderV,
305
- Xr as createMockWorkers,
306
- sr as debounce,
307
- cr as deep,
308
- Or as dimensions,
309
- vr as direction,
310
- ye as errors,
311
- yr as getEntries,
312
- Ge as id,
313
- Me as invert,
314
- Ze as isCrudeSeries,
315
- fr as isObject,
316
- tr as isStringer,
317
- Fe as isTelemValue,
318
- Ee as jsonRPC,
319
- mr as kv,
320
- gr as link,
321
- kr as location,
322
- Mr as mapValues,
323
- be as math,
324
- _e as migrate,
325
- Te as notation,
326
- Gr as nullToArr,
327
- Sr as observe,
328
- Ir as position,
329
- nr as primitiveIsZero,
330
- Tr as runtime,
331
- Ye as scale,
332
- we as shallowCopy,
333
- Ve as sortTimeRange,
334
- zr as spatial,
335
- je as strings,
336
- ar as throttle,
337
- Zr as toArray,
338
- qe as typedArrayZ,
339
- Vr as unique,
340
- Er as unknownRecordZ,
341
- Ur as xy,
342
- et as zod
735
+ nr as DataType,
736
+ sr as Density,
737
+ or as MultiSeries,
738
+ ir as Rate,
739
+ xn as RoutedWorker,
740
+ Qr as Search,
741
+ ar as Series,
742
+ cr as Size,
743
+ lr as TimeRange,
744
+ y as TimeSpan,
745
+ ur as TimeStamp,
746
+ Sn as TypedWorker,
747
+ _n as URL,
748
+ fr as addSamples,
749
+ tr as binary,
750
+ Ur as bounds,
751
+ Xr as box,
752
+ Ut as breaker,
753
+ wn as buildQueryString,
754
+ _r as caseconv,
755
+ vr as change,
756
+ Sr as clamp,
757
+ zt as color,
758
+ Mr as compare,
759
+ Dt as control,
760
+ dr as convertDataType,
761
+ Yt as convertRenderV,
762
+ $n as createMockWorkers,
763
+ Or as debounce,
764
+ Ir as deep,
765
+ tn as dimensions,
766
+ nn as direction,
767
+ Ft as errors,
768
+ Br as getEntries,
769
+ hr as id,
770
+ Bt as invert,
771
+ mr as isCrudeSeries,
772
+ Nr as isObject,
773
+ Tr as isStringer,
774
+ pr as isTelemValue,
775
+ Vt as jsonRPC,
776
+ Rr as kv,
777
+ qr as link,
778
+ on as location,
779
+ Vr as mapValues,
780
+ qt as math,
781
+ Ht as migrate,
782
+ Jt as notation,
783
+ mn as nullToArr,
784
+ Dr as observe,
785
+ cn as position,
786
+ jr as primitiveIsZero,
787
+ Yr as runtime,
788
+ $r as scale,
789
+ Gt as shallowCopy,
790
+ Wt as sleep,
791
+ gr as sortTimeRange,
792
+ un as spatial,
793
+ Qt as strings,
794
+ Kt as sync,
795
+ Ar as throttle,
796
+ pn as toArray,
797
+ br as typedArrayZ,
798
+ bn as unique,
799
+ Hr as unknownRecordZ,
800
+ dn as xy,
801
+ Mn as zod
343
802
  };