@chobantonov/jsonforms-react-shadcn-webcomponent 0.0.0-stage → 0.1.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.
Files changed (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +91 -2
  3. package/dist/JsonFormsShadcnElement.d.ts +29 -0
  4. package/dist/index.d.ts +3 -0
  5. package/dist/jsonforms-react-shadcn.js +1 -0
  6. package/dist/register.d.ts +2 -0
  7. package/dist/register.js +6 -0
  8. package/dist/register.js.map +1 -0
  9. package/dist/renderers.d.ts +2 -0
  10. package/dist/src-CLRAt7jc.mjs +9482 -0
  11. package/dist/src-CLRAt7jc.mjs.map +1 -0
  12. package/dist/standalone/AgGridControlRenderer.impl-BZS8_ocu-Dp2429lF.mjs +39184 -0
  13. package/dist/standalone/AgGridControlRenderer.impl-BZS8_ocu-Dp2429lF.mjs.map +1 -0
  14. package/dist/standalone/DynamicJSXRenderer-DyB3ZpZV-Dr83kPeb.mjs +14893 -0
  15. package/dist/standalone/DynamicJSXRenderer-DyB3ZpZV-Dr83kPeb.mjs.map +1 -0
  16. package/dist/standalone/FileArrayInput.esm-BG196JYM.mjs +760 -0
  17. package/dist/standalone/FileArrayInput.esm-BG196JYM.mjs.map +1 -0
  18. package/dist/standalone/MarkupLabelRenderer.impl-CWfdcUuH-BgJ-v1Ei.mjs +12 -0
  19. package/dist/standalone/MarkupLabelRenderer.impl-CWfdcUuH-BgJ-v1Ei.mjs.map +1 -0
  20. package/dist/standalone/MonacoControlRenderer.impl-CyjMHbOd-BP-CDX3S.mjs +773 -0
  21. package/dist/standalone/MonacoControlRenderer.impl-CyjMHbOd-BP-CDX3S.mjs.map +1 -0
  22. package/dist/standalone/RactiveTemplate-Cat7CxUp-BnyPMY_h.mjs +8028 -0
  23. package/dist/standalone/RactiveTemplate-Cat7CxUp-BnyPMY_h.mjs.map +1 -0
  24. package/dist/standalone/celTemplate-D_AGhaIL-ryXLzhcw.mjs +137 -0
  25. package/dist/standalone/celTemplate-D_AGhaIL-ryXLzhcw.mjs.map +1 -0
  26. package/dist/standalone/classPrivateFieldGet2-CAMXi-8L.mjs +22 -0
  27. package/dist/standalone/dynamicCel.esm-DrqwYtar.mjs +43 -0
  28. package/dist/standalone/dynamicCel.esm-DrqwYtar.mjs.map +1 -0
  29. package/dist/standalone/index.js +24493 -0
  30. package/dist/standalone/index.js.map +1 -0
  31. package/dist/standalone/jsonforms-react-extended.esm-CFwqhFcu.mjs +13760 -0
  32. package/dist/standalone/jsonforms-react-extended.esm-CFwqhFcu.mjs.map +1 -0
  33. package/dist/standalone/lib-DHN5bkVZ.mjs +3149 -0
  34. package/dist/standalone/lib-DHN5bkVZ.mjs.map +1 -0
  35. package/dist/standalone/markdown-C_y73Q0w-DE-0r4-5.mjs +3060 -0
  36. package/dist/standalone/markdown-C_y73Q0w-DE-0r4-5.mjs.map +1 -0
  37. package/dist/standalone/plainRecord.esm-D_l3rehZ.mjs +123 -0
  38. package/dist/standalone/plainRecord.esm-D_l3rehZ.mjs.map +1 -0
  39. package/dist/standalone/react-dom-DUZYP7tL.mjs +5644 -0
  40. package/dist/standalone/react-dom-DUZYP7tL.mjs.map +1 -0
  41. package/package.json +82 -3
  42. package/src/JsonFormsShadcnElement.tsx +208 -0
  43. package/src/components/ui/alert.tsx +65 -0
  44. package/src/components/ui/avatar.tsx +108 -0
  45. package/src/components/ui/breadcrumb.tsx +111 -0
  46. package/src/components/ui/button.tsx +64 -0
  47. package/src/components/ui/calendar.tsx +223 -0
  48. package/src/components/ui/card.tsx +91 -0
  49. package/src/components/ui/checkbox.tsx +31 -0
  50. package/src/components/ui/collapsible.tsx +21 -0
  51. package/src/components/ui/dialog.tsx +175 -0
  52. package/src/components/ui/index.ts +12 -0
  53. package/src/components/ui/input.tsx +22 -0
  54. package/src/components/ui/item.tsx +193 -0
  55. package/src/components/ui/pagination.tsx +132 -0
  56. package/src/components/ui/popover.tsx +88 -0
  57. package/src/components/ui/radio-group.tsx +44 -0
  58. package/src/components/ui/resizable.tsx +52 -0
  59. package/src/components/ui/scroll-area.tsx +57 -0
  60. package/src/components/ui/select.tsx +189 -0
  61. package/src/components/ui/separator.tsx +27 -0
  62. package/src/components/ui/slider.tsx +62 -0
  63. package/src/components/ui/switch.tsx +34 -0
  64. package/src/components/ui/tabs.tsx +90 -0
  65. package/src/components/ui/textarea.tsx +17 -0
  66. package/src/components/ui/tooltip.tsx +56 -0
  67. package/src/components/ui/utils.ts +5 -0
  68. package/src/index.tsx +4 -0
  69. package/src/register.ts +13 -0
  70. package/src/renderers.ts +14 -0
  71. package/src/styles.css +29 -0
  72. package/src/vite-env.d.ts +4 -0
@@ -0,0 +1,3149 @@
1
+ import { a as e, i as t, n, r, t as i } from "./classPrivateFieldGet2-CAMXi-8L.mjs";
2
+ import { a, i as o, n as s, o as c, r as l, s as u } from "./plainRecord.esm-D_l3rehZ.mjs";
3
+ // ../../node_modules/.pnpm/@marcbachmann+cel-js@8.0.0/node_modules/@marcbachmann/cel-js/lib/errors.js
4
+ var d = /* @__PURE__ */ new WeakMap(), f = /* @__PURE__ */ new WeakMap(), p = /* @__PURE__ */ new WeakMap(), ee = /* @__PURE__ */ new WeakMap(), te = class extends Error {
5
+ constructor({ name: e, code: r, message: a, node: o, cause: s, range: c }) {
6
+ super(a, s ? { cause: s } : void 0), t(this, d, void 0), t(this, f, void 0), t(this, p, void 0), t(this, ee, void 0), this.name = e, n(f, this, r), n(ee, this, a), n(d, this, o), n(p, this, c && se(c) || se(o)), o != null && o.input && (this.message = ce(i(ee, this), o, i(p, this)));
7
+ }
8
+ get node() {
9
+ return i(d, this);
10
+ }
11
+ get code() {
12
+ return i(f, this);
13
+ }
14
+ get range() {
15
+ return i(p, this);
16
+ }
17
+ get summary() {
18
+ return i(ee, this);
19
+ }
20
+ withAst(e) {
21
+ return i(d, this) || !(e != null && e.input) || (n(d, this, e), i(p, this) != null || n(p, this, se(e)), this.message = ce(i(ee, this), e, i(p, this))), this;
22
+ }
23
+ };
24
+ function ne(e, t, n, r, i) {
25
+ if (typeof n == "string") return {
26
+ name: e,
27
+ code: t,
28
+ message: n,
29
+ node: r,
30
+ cause: i
31
+ };
32
+ let a = n;
33
+ if (typeof a != "object") throw Error("First param to error must be a string or object");
34
+ return {
35
+ name: e,
36
+ code: a.code || t,
37
+ message: a.message,
38
+ node: a.node,
39
+ cause: a.cause,
40
+ range: a.range
41
+ };
42
+ }
43
+ var re = class extends te {
44
+ constructor(e, t, n) {
45
+ super(ne("ParseError", "parse_error", e, t, n));
46
+ }
47
+ }, ie = class extends te {
48
+ constructor(e, t, n) {
49
+ super(ne("EvaluationError", "evaluation_error", e, t, n));
50
+ }
51
+ }, ae = class extends te {
52
+ constructor(e, t, n) {
53
+ super(ne("TypeError", "type_error", e, t, n));
54
+ }
55
+ };
56
+ function m(e, t, n) {
57
+ return typeof e == "object" ? new re(e) : new re({
58
+ code: e,
59
+ message: t,
60
+ node: n
61
+ });
62
+ }
63
+ function h(e, t, n) {
64
+ return typeof e == "object" ? new ie(e) : new ie({
65
+ code: e,
66
+ message: t,
67
+ node: n
68
+ });
69
+ }
70
+ function oe(e, t, n) {
71
+ return typeof e == "object" ? new ae(e) : new ae({
72
+ code: e,
73
+ message: t,
74
+ node: n
75
+ });
76
+ }
77
+ function se(e) {
78
+ var t;
79
+ let n = (t = e == null ? void 0 : e.pos) == null ? e == null ? void 0 : e.start : t;
80
+ if (typeof n == "number") return {
81
+ start: n,
82
+ end: typeof e.end == "number" ? e.end : n
83
+ };
84
+ }
85
+ function ce(e, t, n) {
86
+ var r;
87
+ let i = (r = t.pos) == null ? n == null ? void 0 : n.start : r;
88
+ if (typeof i != "number") return e;
89
+ let a = t.input, o = 1, s = 0, c = 0;
90
+ for (; s < i;) a[s] === "\n" ? (o++, c = 0) : c++, s++;
91
+ let l = i, u = i;
92
+ for (; l > 0 && a[l - 1] !== "\n";) l--;
93
+ for (; u < a.length && a[u] !== "\n";) u++;
94
+ let d = a.slice(l, u);
95
+ return `${e}\n\n${`> ${`${o}`.padStart(4, " ")} | ${d}\n${" ".repeat(9 + c)}^`}`;
96
+ }
97
+ function le(e, t) {
98
+ return e instanceof te ? e.withAst(t) : e;
99
+ }
100
+ // ../../node_modules/.pnpm/@marcbachmann+cel-js@8.0.0/node_modules/@marcbachmann/cel-js/lib/optional.js
101
+ var ue, de, g = /* @__PURE__ */ new WeakMap();
102
+ ue = Symbol.toStringTag, de = Symbol.for("nodejs.util.inspect.custom");
103
+ var _ = class e {
104
+ constructor(e) {
105
+ t(this, g, void 0), n(g, this, e);
106
+ }
107
+ static of(t) {
108
+ return t === void 0 ? fe : new e(t);
109
+ }
110
+ static none() {
111
+ return fe;
112
+ }
113
+ hasValue() {
114
+ return i(g, this) !== void 0;
115
+ }
116
+ value() {
117
+ if (i(g, this) === void 0) throw h("optional_value_missing", "Optional value is not present");
118
+ return i(g, this);
119
+ }
120
+ or(t) {
121
+ if (i(g, this) !== void 0) return this;
122
+ if (t instanceof e) return t;
123
+ throw h("invalid_optional_argument", "Optional.or must be called with an Optional argument");
124
+ }
125
+ orValue(e) {
126
+ return i(g, this) === void 0 ? e : i(g, this);
127
+ }
128
+ get [ue]() {
129
+ return "optional";
130
+ }
131
+ [de]() {
132
+ return i(g, this) === void 0 ? "Optional { none }" : `Optional { value: ${JSON.stringify(i(g, this))} }`;
133
+ }
134
+ }, fe = Object.freeze(new _()), pe = class {}, me = new pe();
135
+ function he(e, t) {
136
+ let n = t ? me : void 0;
137
+ e.deleteVariable("optional"), e.registerConstant("optional", "OptionalNamespace", n);
138
+ }
139
+ function ge(e) {
140
+ let t = { async: !1 }, n = (n, r) => e.registerFunctionOverload(n, r, t), r = e.enableOptionalTypes ? me : void 0;
141
+ e.registerType("OptionalNamespace", pe), e.registerConstant("optional", "OptionalNamespace", r), n("optional.hasValue(): bool", (e) => e.hasValue()), n("optional<A>.value(): A", (e) => e.value()), e.registerFunctionOverload("OptionalNamespace.none(): optional<T>", () => _.none()), n("OptionalNamespace.of(A): optional<A>", (e, t) => _.of(t));
142
+ function i(e, t, n) {
143
+ if (e instanceof _) return e;
144
+ throw h("optional_expected", `${n} must be optional`, t);
145
+ }
146
+ function a(e, t, n) {
147
+ let r = e.run(t.receiver, n);
148
+ return r instanceof Promise ? r.then((r) => o(r, e, t, n)) : o(r, e, t, n);
149
+ }
150
+ function o(e, t, n, r) {
151
+ let a = i(e, n.receiver, `${n.functionDesc} receiver`);
152
+ return a.hasValue() ? n.onHasValue(a) : n.onEmpty(t, n, r);
153
+ }
154
+ function s(e, t, n, r) {
155
+ let i = e.check(t, n);
156
+ if (i.kind === "optional") return i;
157
+ if (i.kind === "dyn") return e.getType("optional");
158
+ throw e.createError("optional_expected", `${r} must be optional, got '${i}'`, t);
159
+ }
160
+ function c({ functionDesc: e, evaluate: t, typeCheck: n, onHasValue: r, onEmpty: i }) {
161
+ return ({ ast: a, args: o, receiver: s }) => ({
162
+ ast: a,
163
+ functionDesc: e,
164
+ receiver: s,
165
+ arg: o[0],
166
+ evaluate: t,
167
+ typeCheck: n,
168
+ onHasValue: r,
169
+ onEmpty: i
170
+ });
171
+ }
172
+ let l = "optional.or(optional) argument";
173
+ e.registerFunctionOverload("optional.or(ast): optional<dyn>", c({
174
+ functionDesc: "optional.or(optional)",
175
+ evaluate: a,
176
+ typeCheck(e, t, n) {
177
+ let r = s(e, t.receiver, n, "optional.or(optional) receiver"), i = s(e, t.arg, n, l);
178
+ t.receiver.maybeAsync || t.arg.maybeAsync || t.ast.setMeta("async", !1);
179
+ let a = r.unify(e.registry, i);
180
+ if (a) return a;
181
+ throw e.createError("incompatible_argument_type", `${t.functionDesc} argument must be compatible type, got '${r}' and '${i}'`, t.arg);
182
+ },
183
+ onHasValue: (e) => e,
184
+ onEmpty(e, t, n) {
185
+ let r = t.arg, a = e.run(r, n);
186
+ return a instanceof Promise ? a.then((e) => i(e, r, l)) : i(a, r, l);
187
+ }
188
+ })), e.registerFunctionOverload("optional.orValue(ast): dyn", c({
189
+ functionDesc: "optional.orValue(value)",
190
+ onHasValue: (e) => e.value(),
191
+ onEmpty(e, t, n) {
192
+ return e.run(t.arg, n);
193
+ },
194
+ evaluate: a,
195
+ typeCheck(e, t, n) {
196
+ let r = s(e, t.receiver, n, "optional.orValue() receiver").valueType, i = e.check(t.arg, n);
197
+ t.receiver.maybeAsync || t.arg.maybeAsync || t.ast.setMeta("async", !1);
198
+ let a = r.unify(e.registry, i);
199
+ if (a) return a;
200
+ throw e.createError("incompatible_argument_type", `${t.functionDesc} argument must be compatible type, got '${r}' and '${i}'`, t.arg);
201
+ }
202
+ }));
203
+ }
204
+ // ../../node_modules/.pnpm/@marcbachmann+cel-js@8.0.0/node_modules/@marcbachmann/cel-js/lib/globals.js
205
+ var _e = Object.hasOwn, v = Object.keys, y = Object.freeze, ve = Object.entries, ye = Array.isArray, be = Array.from;
206
+ function xe(e, t) {
207
+ return (e == null ? void 0 : e[Symbol.toStringTag]) === "AsyncFunction" || typeof t != "boolean" || t;
208
+ }
209
+ var Se = /* @__PURE__ */ new Set([
210
+ "as",
211
+ "break",
212
+ "const",
213
+ "continue",
214
+ "else",
215
+ "for",
216
+ "function",
217
+ "if",
218
+ "import",
219
+ "let",
220
+ "loop",
221
+ "package",
222
+ "namespace",
223
+ "return",
224
+ "var",
225
+ "void",
226
+ "while",
227
+ "__proto__",
228
+ "prototype"
229
+ ]), Ce, we, Te, Ee, b = /* @__PURE__ */ new WeakMap();
230
+ Ce = Symbol.toStringTag, we = Symbol.for("nodejs.util.inspect.custom");
231
+ var x = class {
232
+ constructor(e) {
233
+ t(this, b, void 0), this.verify(typeof e == "bigint" ? e : BigInt(e));
234
+ }
235
+ get value() {
236
+ return i(b, this);
237
+ }
238
+ valueOf() {
239
+ return i(b, this);
240
+ }
241
+ toString() {
242
+ return `${i(b, this)}`;
243
+ }
244
+ verify(e) {
245
+ if (e < 0n || e > 18446744073709551615n) throw h("numeric_overflow", "Unsigned integer overflow");
246
+ n(b, this, e);
247
+ }
248
+ get [Ce]() {
249
+ return `value = ${i(b, this)}`;
250
+ }
251
+ [we]() {
252
+ return `UnsignedInteger { value: ${i(b, this)} }`;
253
+ }
254
+ }, De = 1e9, Oe = 1000000000n, ke = {
255
+ h: 3600000000000n,
256
+ m: 60000000000n,
257
+ s: Oe,
258
+ ms: 1000000n,
259
+ us: 1000n,
260
+ µs: 1000n,
261
+ ns: 1n
262
+ }, S = /* @__PURE__ */ new WeakMap(), C = /* @__PURE__ */ new WeakMap();
263
+ Te = Symbol.toStringTag, Ee = Symbol.for("nodejs.util.inspect.custom");
264
+ var Ae = class e {
265
+ constructor(e, r = 0) {
266
+ t(this, S, void 0), t(this, C, void 0), n(S, this, BigInt(e)), n(C, this, r);
267
+ }
268
+ get seconds() {
269
+ return i(S, this);
270
+ }
271
+ get nanos() {
272
+ return i(C, this);
273
+ }
274
+ valueOf() {
275
+ return Number(i(S, this)) * 1e3 + i(C, this) / 1e6;
276
+ }
277
+ static fromMilliseconds(t) {
278
+ let n = BigInt(Math.trunc(t * 1e6)), r = n / Oe, i = Number(n % Oe);
279
+ return new e(r, i);
280
+ }
281
+ addDuration(t) {
282
+ let n = i(C, this) + t.nanos;
283
+ return new e(i(S, this) + t.seconds + BigInt(Math.floor(n / De)), n % De);
284
+ }
285
+ subtractDuration(t) {
286
+ let n = i(C, this) - t.nanos;
287
+ return new e(i(S, this) - t.seconds + BigInt(Math.floor(n / De)), (n + De) % De);
288
+ }
289
+ extendTimestamp(e) {
290
+ return new Date(e.getTime() + Number(i(S, this)) * 1e3 + Math.floor(i(C, this) / 1e6));
291
+ }
292
+ subtractTimestamp(e) {
293
+ return /* @__PURE__ */ new Date(e.getTime() - Number(i(S, this)) * 1e3 - Math.floor(i(C, this) / 1e6));
294
+ }
295
+ toString() {
296
+ let e = i(C, this) ? (i(C, this) / De).toLocaleString("en-US", {
297
+ useGrouping: !1,
298
+ maximumFractionDigits: 9
299
+ }).slice(1) : "";
300
+ return `${i(S, this)}${e}s`;
301
+ }
302
+ getHours() {
303
+ return i(S, this) / 3600n;
304
+ }
305
+ getMinutes() {
306
+ return i(S, this) / 60n;
307
+ }
308
+ getSeconds() {
309
+ return i(S, this);
310
+ }
311
+ getMilliseconds() {
312
+ return i(S, this) * 1000n + BigInt(Math.floor(i(C, this) / 1e6));
313
+ }
314
+ get [Te]() {
315
+ return "google.protobuf.Duration";
316
+ }
317
+ [Ee]() {
318
+ return `google.protobuf.Duration { seconds: ${i(S, this)}, nanos: ${i(C, this)} }`;
319
+ }
320
+ };
321
+ function je(e) {
322
+ let t = { async: !1 }, n = (n, r) => e.registerFunctionOverload(n, r, t), r = (e) => e;
323
+ n("dyn(dyn): dyn", r);
324
+ for (let e in E) {
325
+ let t = E[e];
326
+ t instanceof T && n(`type(${t.name}): type`, () => t);
327
+ }
328
+ n("bool(bool): bool", r), n("bool(string): bool", (e) => {
329
+ switch (e) {
330
+ case "1":
331
+ case "t":
332
+ case "true":
333
+ case "TRUE":
334
+ case "True": return !0;
335
+ case "0":
336
+ case "f":
337
+ case "false":
338
+ case "FALSE":
339
+ case "False": return !1;
340
+ default: throw h("bool_conversion_error", `bool() conversion error: invalid string value "${e}"`);
341
+ }
342
+ }), n("size(string): int", (e) => BigInt(Me(e))), n("size(bytes): int", (e) => BigInt(e.length)), n("size(list): int", (e) => {
343
+ var t;
344
+ return BigInt((t = e.length) == null ? e.size : t);
345
+ }), n("size(map): int", (e) => BigInt(e instanceof Map ? e.size : v(e).length)), n("string.size(): int", (e) => BigInt(Me(e))), n("bytes.size(): int", (e) => BigInt(e.length)), n("list.size(): int", (e) => {
346
+ var t;
347
+ return BigInt((t = e.length) == null ? e.size : t);
348
+ }), n("map.size(): int", (e) => BigInt(e instanceof Map ? e.size : v(e).length)), n("bytes(string): bytes", (e) => o.fromString(e)), n("bytes(bytes): bytes", r), n("double(double): double", r), n("double(int): double", (e) => Number(e)), n("double(uint): double", (e) => Number(e)), n("double(string): double", (e) => {
349
+ if (!e || e !== e.trim()) throw h("double_conversion_error", "double() type error: cannot convert to double");
350
+ switch (e.toLowerCase()) {
351
+ case "inf":
352
+ case "+inf":
353
+ case "infinity":
354
+ case "+infinity": return Infinity;
355
+ case "-inf":
356
+ case "-infinity": return -Infinity;
357
+ case "nan": return NaN;
358
+ default: {
359
+ let t = Number(e);
360
+ if (!Number.isNaN(t)) return t;
361
+ throw h("double_conversion_error", "double() type error: cannot convert to double");
362
+ }
363
+ }
364
+ }), n("int(int): int", r), n("int(double): int", (e) => {
365
+ if (Number.isFinite(e)) return BigInt(Math.trunc(e));
366
+ throw h("numeric_overflow", "int() type error: integer overflow");
367
+ }), n("int(string): int", (e) => {
368
+ if (e !== e.trim() || e.length > 20 || e.includes("0x")) throw h("int_conversion_error", "int() type error: cannot convert to int");
369
+ try {
370
+ let t = BigInt(e);
371
+ if (t <= 9223372036854775807n && t >= -9223372036854775808n) return t;
372
+ } catch (e) {}
373
+ throw h("int_conversion_error", "int() type error: cannot convert to int");
374
+ }), n("uint(uint): uint", r), n("uint(int): uint", (e) => {
375
+ try {
376
+ return new x(e);
377
+ } catch (e) {
378
+ throw h("uint_conversion_error", "uint() type error: cannot convert to uint");
379
+ }
380
+ }), n("uint(double): uint", (e) => {
381
+ try {
382
+ return new x(Math.trunc(e));
383
+ } catch (e) {
384
+ throw h("numeric_overflow", "uint() type error: unsigned integer overflow");
385
+ }
386
+ }), n("uint(string): uint", (e) => {
387
+ if (e !== e.trim() || e.length > 20 || e.includes("0x")) throw h("uint_conversion_error", "uint() type error: cannot convert to uint");
388
+ try {
389
+ return new x(e);
390
+ } catch (e) {
391
+ throw h("uint_conversion_error", "uint() type error: cannot convert to uint");
392
+ }
393
+ }), n("string(string): string", r), n("string(bool): string", (e) => `${e}`), n("string(int): string", (e) => `${e}`), n("string(uint): string", (e) => `${e}`), n("string(bytes): string", (e) => o.toUtf8(e)), n("string(double): string", (e) => e === Infinity ? "+Inf" : e === -Infinity ? "-Inf" : `${e}`), n("string.startsWith(string): bool", (e, t) => e.startsWith(t)), n("string.endsWith(string): bool", (e, t) => e.endsWith(t)), n("string.contains(string): bool", (e, t) => e.includes(t)), n("string.lowerAscii(): string", (e) => e.toLowerCase()), n("string.upperAscii(): string", (e) => e.toUpperCase()), n("string.trim(): string", (e) => e.trim()), n("string.indexOf(string): int", (e, t) => BigInt(e.indexOf(t))), n("string.indexOf(string, int): int", (e, t, n) => {
394
+ if (t === "") return n;
395
+ if (n = Number(n), n < 0 || n >= e.length) throw h("index_out_of_range", "string.indexOf(search, fromIndex): fromIndex out of range");
396
+ return BigInt(e.indexOf(t, n));
397
+ }), n("string.lastIndexOf(string): int", (e, t) => BigInt(e.lastIndexOf(t))), n("string.lastIndexOf(string, int): int", (e, t, n) => {
398
+ if (t === "") return n;
399
+ if (n = Number(n), n < 0 || n >= e.length) throw h("index_out_of_range", "string.lastIndexOf(search, fromIndex): fromIndex out of range");
400
+ return BigInt(e.lastIndexOf(t, n));
401
+ }), n("string.substring(int): string", (e, t) => {
402
+ if (t = Number(t), t < 0 || t > e.length) throw h("index_out_of_range", "string.substring(start, end): start index out of range");
403
+ return e.substring(t);
404
+ }), n("string.substring(int, int): string", (e, t, n) => {
405
+ if (t = Number(t), t < 0 || t > e.length) throw h("index_out_of_range", "string.substring(start, end): start index out of range");
406
+ if (n = Number(n), n < t || n > e.length) throw h("index_out_of_range", "string.substring(start, end): end index out of range");
407
+ return e.substring(t, n);
408
+ }), n("string.matches(string): bool", (e, t) => {
409
+ try {
410
+ return new RegExp(t).test(e);
411
+ } catch (e) {
412
+ throw h("invalid_regular_expression", `Invalid regular expression: ${t}`);
413
+ }
414
+ }), n("string.split(string): list<string>", (e, t) => e.split(t)), n("string.split(string, int): list<string>", (e, t, n) => {
415
+ if (n = Number(n), n === 0) return [];
416
+ let r = e.split(t);
417
+ if (n < 0 || r.length <= n) return r;
418
+ let i = r.slice(0, n - 1);
419
+ return i.push(r.slice(n - 1).join(t)), i;
420
+ }), n("list<string>.join(): string", (e) => {
421
+ for (let t = 0; t < e.length; t++) if (typeof e[t] != "string") throw h("invalid_list_element_type", "string.join(): list must contain only strings");
422
+ return e.join("");
423
+ }), n("list<string>.join(string): string", (e, t) => {
424
+ for (let t = 0; t < e.length; t++) if (typeof e[t] != "string") throw h("invalid_list_element_type", "string.join(separator): list must contain only strings");
425
+ return e.join(t);
426
+ });
427
+ let i = new TextEncoder("utf8"), a = new TextDecoder("utf8"), o = typeof Buffer < "u" ? {
428
+ byteLength: (e) => Buffer.byteLength(e),
429
+ fromString: (e) => Buffer.from(e, "utf8"),
430
+ toHex: (e) => Buffer.prototype.hexSlice.call(e, 0, e.length),
431
+ toBase64: (e) => Buffer.prototype.base64Slice.call(e, 0, e.length),
432
+ toUtf8: (e) => Buffer.prototype.utf8Slice.call(e, 0, e.length),
433
+ jsonParse: (e) => JSON.parse(e)
434
+ } : {
435
+ textEncoder: new TextEncoder("utf8"),
436
+ byteLength: (e) => i.encode(e).length,
437
+ fromString: (e) => i.encode(e),
438
+ toHex: Uint8Array.prototype.toHex ? (e) => e.toHex() : (e) => be(e, (e) => e.toString(16).padStart(2, "0")).join(""),
439
+ toBase64: Uint8Array.prototype.toBase64 ? (e) => e.toBase64() : (e) => btoa(be(e, (e) => String.fromCodePoint(e)).join("")),
440
+ toUtf8: (e) => a.decode(e),
441
+ jsonParse: (e) => JSON.parse(i.decode(e))
442
+ };
443
+ n("bytes.json(): map", o.jsonParse), n("bytes.hex(): string", o.toHex), n("bytes.string(): string", o.toUtf8), n("bytes.base64(): string", o.toBase64), n("bytes.at(int): int", (e, t) => {
444
+ if (t < 0 || t >= e.length) throw h("index_out_of_range", "Bytes index out of range");
445
+ return BigInt(e[t]);
446
+ });
447
+ let s = "google.protobuf.Timestamp", c = e.registerType(s, Date).typeType, l = e.registerType("google.protobuf.Duration", Ae).typeType;
448
+ e.registerConstant("google", "map<string, map<string, type>>", { protobuf: {
449
+ Duration: l,
450
+ Timestamp: c
451
+ } });
452
+ function u(e, t) {
453
+ return new Date(e.toLocaleString("en-US", { timeZone: t }));
454
+ }
455
+ function d(e, t) {
456
+ let n = t ? u(e, t) : new Date(e.getUTCFullYear(), e.getUTCMonth(), e.getUTCDate()), r = new Date(n.getFullYear(), 0, 0);
457
+ return BigInt(Math.floor((n - r) / 864e5) - 1);
458
+ }
459
+ n(`timestamp(string): ${s}`, (e) => {
460
+ if (e.length < 20 || e.length > 30) throw h("invalid_timestamp", "timestamp() requires a string in ISO 8601 format");
461
+ let t = new Date(e);
462
+ if (t <= 0xe677d21fdbff && t >= -621355968e5) return t;
463
+ throw h("invalid_timestamp", "timestamp() requires a string in ISO 8601 format");
464
+ }), n(`timestamp(int): ${s}`, (e) => {
465
+ if (e = Number(e) * 1e3, e <= 0xe677d21fdbff && e >= -621355968e5) return new Date(e);
466
+ throw h("invalid_timestamp", "timestamp() requires a valid integer unix timestamp");
467
+ }), n(`${s}.getDate(): int`, (e) => BigInt(e.getUTCDate())), n(`${s}.getDate(string): int`, (e, t) => BigInt(u(e, t).getDate())), n(`${s}.getDayOfMonth(): int`, (e) => BigInt(e.getUTCDate() - 1)), n(`${s}.getDayOfMonth(string): int`, (e, t) => BigInt(u(e, t).getDate() - 1)), n(`${s}.getDayOfWeek(): int`, (e) => BigInt(e.getUTCDay())), n(`${s}.getDayOfWeek(string): int`, (e, t) => BigInt(u(e, t).getDay())), n(`${s}.getDayOfYear(): int`, d), n(`${s}.getDayOfYear(string): int`, d), n(`${s}.getFullYear(): int`, (e) => BigInt(e.getUTCFullYear())), n(`${s}.getFullYear(string): int`, (e, t) => BigInt(u(e, t).getFullYear())), n(`${s}.getHours(): int`, (e) => BigInt(e.getUTCHours())), n(`${s}.getHours(string): int`, (e, t) => BigInt(u(e, t).getHours())), n(`${s}.getMilliseconds(): int`, (e) => BigInt(e.getUTCMilliseconds())), n(`${s}.getMilliseconds(string): int`, (e) => BigInt(e.getUTCMilliseconds())), n(`${s}.getMinutes(): int`, (e) => BigInt(e.getUTCMinutes())), n(`${s}.getMinutes(string): int`, (e, t) => BigInt(u(e, t).getMinutes())), n(`${s}.getMonth(): int`, (e) => BigInt(e.getUTCMonth())), n(`${s}.getMonth(string): int`, (e, t) => BigInt(u(e, t).getMonth())), n(`${s}.getSeconds(): int`, (e) => BigInt(e.getUTCSeconds())), n(`${s}.getSeconds(string): int`, (e, t) => BigInt(u(e, t).getSeconds()));
468
+ let f = /(\d*\.?\d*)(ns|us|µs|ms|s|m|h)/;
469
+ function p(e) {
470
+ if (!e) throw h("invalid_duration", "Invalid duration string: ''");
471
+ let t = e[0] === "-";
472
+ (e[0] === "-" || e[0] === "+") && (e = e.slice(1));
473
+ let n = BigInt(0);
474
+ for (;;) {
475
+ let t = f.exec(e);
476
+ if (!t || t.index !== 0) throw h("invalid_duration", `Invalid duration string: ${e}`);
477
+ e = e.slice(t[0].length);
478
+ let r = ke[t[2]], [i = "0", a = ""] = t[1].split("."), o = BigInt(i) * r, s = a ? BigInt(a.slice(0, 13).padEnd(13, "0")) * r / 10000000000000n : 0n;
479
+ if (n += o + s, e === "") break;
480
+ }
481
+ let r = n >= Oe ? n / Oe : 0n, i = Number(n % Oe);
482
+ return t ? new Ae(-r, -i) : new Ae(r, i);
483
+ }
484
+ n("duration(string): google.protobuf.Duration", (e) => p(e)), n("google.protobuf.Duration.getHours(): int", (e) => e.getHours()), n("google.protobuf.Duration.getMinutes(): int", (e) => e.getMinutes()), n("google.protobuf.Duration.getSeconds(): int", (e) => e.getSeconds()), n("google.protobuf.Duration.getMilliseconds(): int", (e) => e.getMilliseconds()), ge(e);
485
+ }
486
+ function Me(e) {
487
+ let t = 0;
488
+ for (let n of e) t++;
489
+ return t;
490
+ }
491
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/classPrivateMethodInitSpec.js
492
+ function w(t, n) {
493
+ e(t, n), n.add(t);
494
+ }
495
+ // ../../node_modules/.pnpm/@marcbachmann+cel-js@8.0.0/node_modules/@marcbachmann/cel-js/lib/registry.js
496
+ u();
497
+ var Ne, Pe, Fe = /* @__PURE__ */ new WeakMap();
498
+ Ne = Symbol.toStringTag;
499
+ var T = class {
500
+ constructor(e) {
501
+ t(this, Fe, void 0), n(Fe, this, e), y(this);
502
+ }
503
+ get name() {
504
+ return i(Fe, this);
505
+ }
506
+ get [Ne]() {
507
+ return `Type<${i(Fe, this)}>`;
508
+ }
509
+ toString() {
510
+ return `Type<${i(Fe, this)}>`;
511
+ }
512
+ }, E = {
513
+ string: new T("string"),
514
+ bool: new T("bool"),
515
+ int: new T("int"),
516
+ uint: new T("uint"),
517
+ double: new T("double"),
518
+ map: new T("map"),
519
+ list: new T("list"),
520
+ bytes: new T("bytes"),
521
+ null_type: new T("null"),
522
+ type: new T("type")
523
+ }, Ie = new T("optional"), Le = {
524
+ dyn(e, t) {
525
+ switch (typeof e) {
526
+ case "string":
527
+ case "bigint":
528
+ case "number":
529
+ case "boolean": return !0;
530
+ case "object": switch (e && e.constructor) {
531
+ case null:
532
+ case void 0:
533
+ case Object:
534
+ case Map:
535
+ case Array:
536
+ case Set: return !0;
537
+ default: if (t.objectTypesByConstructor.get(e.constructor)) return !0;
538
+ }
539
+ }
540
+ return !!t.debugType(e);
541
+ },
542
+ string(e) {
543
+ return typeof e == "string";
544
+ },
545
+ int(e) {
546
+ return typeof e == "bigint";
547
+ },
548
+ double(e) {
549
+ return typeof e == "number";
550
+ },
551
+ bool(e) {
552
+ return typeof e == "boolean";
553
+ },
554
+ null(e) {
555
+ return e === null;
556
+ },
557
+ bytes(e) {
558
+ return e instanceof Uint8Array;
559
+ },
560
+ uint(e) {
561
+ return e instanceof x;
562
+ },
563
+ type(e) {
564
+ return e instanceof T;
565
+ },
566
+ list(e) {
567
+ switch (e == null ? void 0 : e.constructor) {
568
+ case Array:
569
+ case Set: return !0;
570
+ default: return !1;
571
+ }
572
+ },
573
+ map(e) {
574
+ switch (typeof e == "object" && e ? e.constructor : null) {
575
+ case void 0:
576
+ case Object:
577
+ case Map: return !0;
578
+ default: return !1;
579
+ }
580
+ },
581
+ optional(e) {
582
+ return e instanceof _;
583
+ },
584
+ message(e, t) {
585
+ return this === t.debugType(e);
586
+ }
587
+ };
588
+ Le.param = Le.dyn;
589
+ var Re = /* @__PURE__ */ new WeakMap(), D = /* @__PURE__ */ new WeakSet(), O = class {
590
+ constructor({ kind: e, type: n, name: i, keyType: a, valueType: o }) {
591
+ var s, c, l, u;
592
+ w(this, D), t(this, Re, /* @__PURE__ */ new WeakMap()), this.kind = e, this.type = n, this.name = i, this.keyType = a, this.valueType = o, this.unwrappedType = e === "dyn" && o ? o.unwrappedType : this, this.wrappedType = e === "dyn" ? this : $e(this.unwrappedType), this.hasDynType = this.kind === "dyn" || ((s = this.valueType) == null ? void 0 : s.hasDynType) || ((c = this.keyType) == null ? void 0 : c.hasDynType) || !1, this.hasPlaceholderType = this.kind === "param" || ((l = this.keyType) == null ? void 0 : l.hasPlaceholderType) || ((u = this.valueType) == null ? void 0 : u.hasPlaceholderType) || !1, e === "list" ? this.fieldLazy = r(D, this, Ue) : e === "map" ? this.fieldLazy = r(D, this, Ve) : e === "message" ? this.fieldLazy = r(D, this, Be) : e === "optional" && (this.fieldLazy = r(D, this, ze)), this.matchesValueType = Le[i] || Le[e], y(this);
593
+ }
594
+ isDynOrBool() {
595
+ return this.type === "bool" || this.kind === "dyn";
596
+ }
597
+ isEmpty() {
598
+ return this.valueType && this.valueType.kind === "param";
599
+ }
600
+ unify(e, t) {
601
+ let n = this;
602
+ if (n === t || n.kind === "dyn" || t.kind === "param") return n;
603
+ if (t.kind === "dyn" || n.kind === "param") return t;
604
+ if (n.kind !== t.kind || !(n.hasPlaceholderType || t.hasPlaceholderType || n.hasDynType || t.hasDynType)) return null;
605
+ let r = n.valueType.unify(e, t.valueType);
606
+ if (!r) return null;
607
+ switch (n.kind) {
608
+ case "optional": return e.getOptionalType(r);
609
+ case "list": return e.getListType(r);
610
+ case "map":
611
+ let i = n.keyType.unify(e, t.keyType);
612
+ return i ? e.getMapType(i, r) : null;
613
+ }
614
+ }
615
+ templated(e, t) {
616
+ if (!this.hasPlaceholderType) return this;
617
+ switch (this.kind) {
618
+ case "dyn": return this.valueType.templated(e, t);
619
+ case "param": return (t == null ? void 0 : t.get(this.name)) || this;
620
+ case "map": return e.getMapType(this.keyType.templated(e, t), this.valueType.templated(e, t));
621
+ case "list": return e.getListType(this.valueType.templated(e, t));
622
+ case "optional": return e.getOptionalType(this.valueType.templated(e, t));
623
+ default: return this;
624
+ }
625
+ }
626
+ toString() {
627
+ return this.name;
628
+ }
629
+ fieldLazy() {}
630
+ field(e, t, n, r) {
631
+ let i = this.fieldLazy(e, t, n, r);
632
+ if (i !== void 0) return i;
633
+ throw h("no_such_key", `No such key: ${t}`, n);
634
+ }
635
+ matchesBoth(e) {
636
+ return this.matches(e) && e.matches(this);
637
+ }
638
+ matches(e) {
639
+ var t;
640
+ let n = this.unwrappedType;
641
+ return e = e.unwrappedType, n === e || n.kind === "dyn" || e.kind === "dyn" || e.kind === "param" ? !0 : (t = i(Re, this).get(e)) == null ? i(Re, this).set(e, r(D, this, We).call(this, n, e)).get(e) : t;
642
+ }
643
+ };
644
+ function ze(e, t, n, r) {
645
+ if (e = e instanceof _ ? e.orValue() : e, e === void 0) return fe;
646
+ let i = r.debugType(e);
647
+ try {
648
+ return _.of(i.fieldLazy(e, t, n, r));
649
+ } catch (e) {
650
+ if (e instanceof ie) return fe;
651
+ throw e;
652
+ }
653
+ }
654
+ function Be(e, t, n, r) {
655
+ let i = e ? r.objectTypesByConstructor.get(e.constructor) : void 0;
656
+ if (!i) return;
657
+ let a = i.fields ? i.fields[t] : A;
658
+ if (!a) return;
659
+ let o = e instanceof Map ? e.get(t) : e[t];
660
+ if (o !== void 0) {
661
+ if (a.matchesValueType(o, r)) return o;
662
+ throw h("field_type_mismatch", `Field '${t}' is not of type '${a}', got '${r.debugType(o)}'`, n);
663
+ }
664
+ }
665
+ function Ve(e, t, n, r) {
666
+ let i = e instanceof Map ? e.get(t) : e && _e(e, t) ? e[t] : void 0;
667
+ if (i !== void 0) {
668
+ if (this.valueType.matchesValueType(i, r)) return i;
669
+ throw h("field_type_mismatch", `Field '${t}' is not of type '${this.valueType}', got '${r.debugType(i)}'`, n);
670
+ }
671
+ }
672
+ function He(e, t) {
673
+ switch (e == null ? void 0 : e.constructor) {
674
+ case Array: return e[t];
675
+ case Set: {
676
+ let n = 0;
677
+ for (let r of e) if (n++ === t) return r;
678
+ }
679
+ }
680
+ }
681
+ function Ue(e, t, n, i) {
682
+ if (typeof t == "bigint") t = Number(t);
683
+ else if (typeof t != "number") return;
684
+ let a = r(D, this, He).call(this, e, t);
685
+ if (a === void 0) {
686
+ if (!e) return;
687
+ throw h("index_out_of_bounds", `No such key: index out of bounds, index ${t} ${t < 0 ? "< 0" : `>= size ${e.length || e.size}`}`, n);
688
+ }
689
+ if (this.valueType.matchesValueType(a, i)) return a;
690
+ throw h("list_item_type_mismatch", `List item with index '${t}' is not of type '${this.valueType}', got '${i.debugType(a)}'`, n);
691
+ }
692
+ function We(e, t) {
693
+ switch (e.kind) {
694
+ case "dyn":
695
+ case "param": return !0;
696
+ case "list": return t.kind === "list" && e.valueType.matches(t.valueType);
697
+ case "map": return t.kind === "map" && e.keyType.matches(t.keyType) && e.valueType.matches(t.valueType);
698
+ case "optional": return t.kind === "optional" && e.valueType.matches(t.valueType);
699
+ default: return e.name === t.name;
700
+ }
701
+ }
702
+ var Ge = "have a .callAst property or .evaluate(checker, macro, ctx) method.", Ke = "have a .callAst property or .typeCheck(checker, macro, ctx) method.";
703
+ function qe(e, t) {
704
+ let n = `Macro '${e}' must`;
705
+ return function(e) {
706
+ let r = t(e);
707
+ if (!r || typeof r != "object") throw Error(`${n} return an object.`);
708
+ if (r.callAst) return r;
709
+ if (!r.evaluate) throw Error(`${n} ${Ge}`);
710
+ if (!r.typeCheck) throw Error(`${n} ${Ke}`);
711
+ return r;
712
+ };
713
+ }
714
+ var Je = class {
715
+ constructor(e, t, n, r) {
716
+ this.name = e, this.type = t, this.description = n == null ? null : n, this.constant = r !== void 0, this.value = r, y(this);
717
+ }
718
+ }, Ye = class {
719
+ constructor({ name: e, receiverType: t, returnType: n, handler: r, description: i, params: a, async: o }) {
720
+ var s;
721
+ if (typeof e != "string") throw Error("name must be a string");
722
+ if (typeof r != "function") throw Error("handler must be a function");
723
+ this.name = e, this.async = xe(r, o), this.receiverType = t == null ? null : t, this.returnType = n, this.description = i == null ? null : i, this.params = a, this.argTypes = a.map((e) => e.type), this.macro = this.argTypes.includes(rt);
724
+ let c = t ? `${t}.` : "";
725
+ this.signature = `${c}${e}(${this.argTypes.join(", ")}): ${n}`, this.handler = this.macro ? qe(this.signature, r) : r, this.partitionKey = `${t ? "rcall" : "call"}:${e}:${a.length}`, this.hasPlaceholderType = this.returnType.hasPlaceholderType || ((s = this.receiverType) == null ? void 0 : s.hasPlaceholderType) || this.argTypes.some((e) => e.hasPlaceholderType) || !1, y(this);
726
+ }
727
+ matchesArgs(e) {
728
+ return e.length === this.argTypes.length && this.argTypes.every((t, n) => t.matches(e[n])) ? this : null;
729
+ }
730
+ }, Xe = class {
731
+ constructor({ op: e, leftType: t, rightType: n, handler: r, returnType: i, async: a }) {
732
+ var o;
733
+ this.operator = e, this.leftType = t, this.rightType = n || null, this.handler = r, this.async = xe(r, a), this.returnType = i, this.signature = n ? `${t} ${e} ${n}: ${i}` : `${e}${t}: ${i}`, this.hasPlaceholderType = this.leftType.hasPlaceholderType || ((o = this.rightType) == null ? void 0 : o.hasPlaceholderType) || !1, y(this);
734
+ }
735
+ equals(e) {
736
+ return this.operator === e.operator && this.leftType === e.leftType && this.rightType === e.rightType;
737
+ }
738
+ };
739
+ function Ze(e) {
740
+ return new O({
741
+ kind: "list",
742
+ name: `list<${e}>`,
743
+ type: "list",
744
+ valueType: e
745
+ });
746
+ }
747
+ function k(e) {
748
+ return new O({
749
+ kind: "primitive",
750
+ name: e,
751
+ type: e
752
+ });
753
+ }
754
+ function Qe(e) {
755
+ return new O({
756
+ kind: "message",
757
+ name: e,
758
+ type: e
759
+ });
760
+ }
761
+ function $e(e) {
762
+ let t = e ? `dyn<${e}>` : "dyn";
763
+ return new O({
764
+ kind: "dyn",
765
+ name: t,
766
+ type: t,
767
+ valueType: e
768
+ });
769
+ }
770
+ function et(e) {
771
+ return new O({
772
+ kind: "optional",
773
+ name: `optional<${e}>`,
774
+ type: "optional",
775
+ valueType: e
776
+ });
777
+ }
778
+ function tt(e, t) {
779
+ return new O({
780
+ kind: "map",
781
+ name: `map<${e}, ${t}>`,
782
+ type: "map",
783
+ keyType: e,
784
+ valueType: t
785
+ });
786
+ }
787
+ function nt(e) {
788
+ return new O({
789
+ kind: "param",
790
+ name: e,
791
+ type: e
792
+ });
793
+ }
794
+ var A = $e(), rt = k("ast"), it = Ze(A), at = tt(A, A), j = {
795
+ string: k("string"),
796
+ bool: k("bool"),
797
+ int: k("int"),
798
+ uint: k("uint"),
799
+ double: k("double"),
800
+ bytes: k("bytes"),
801
+ dyn: A,
802
+ null: k("null"),
803
+ type: k("type"),
804
+ optional: et(A),
805
+ list: it,
806
+ "list<dyn>": it,
807
+ map: at,
808
+ "map<dyn, dyn>": at
809
+ };
810
+ for (let e of [
811
+ j.string,
812
+ j.double,
813
+ j.int
814
+ ]) {
815
+ let t = Ze(e), n = tt(j.string, e);
816
+ j[t.name] = t, j[n.name] = n;
817
+ }
818
+ Object.freeze(j);
819
+ var M = /* @__PURE__ */ new WeakMap(), ot = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new WeakSet();
820
+ Pe = Symbol.iterator;
821
+ var st = class {
822
+ constructor(e) {
823
+ w(this, N), c(this, "returnType", null), c(this, "async", !1), c(this, "macro", !1), t(this, M, null), t(this, ot, null), c(this, "declarations", []), this.registry = e;
824
+ }
825
+ [Pe]() {
826
+ return this.declarations[Symbol.iterator]();
827
+ }
828
+ add(e) {
829
+ var t, n;
830
+ this.returnType = (this.returnType || e.returnType).unify(this.registry, e.returnType) || A, e.macro && (this.macro = e), e.async && !this.async && (this.async = !0), this.declarations.push(e), (t = i(M, this)) == null || t.clear(), (n = i(ot, this)) == null || n.clear();
831
+ }
832
+ findFunction(e, t = null) {
833
+ for (let n = 0; n < this.declarations.length; n++) {
834
+ let i = r(N, this, pt).call(this, this.declarations[n], e, t);
835
+ if (i) return i;
836
+ }
837
+ return null;
838
+ }
839
+ findUnaryOverload(e) {
840
+ var t;
841
+ let r = ((t = i(M, this)) == null ? n(M, this, /* @__PURE__ */ new Map()) : t).get(e);
842
+ if (r !== void 0) return r;
843
+ let a = !1;
844
+ for (let t of this.declarations) if (t.leftType === e) {
845
+ a = t;
846
+ break;
847
+ }
848
+ return i(M, this).set(e, a), a;
849
+ }
850
+ findBinaryOverload(e, t) {
851
+ var a, o, s;
852
+ return e.kind === "dyn" && e.valueType ? t = t.wrappedType : t.kind === "dyn" && t.valueType && (e = e.wrappedType), (a = (o = ((s = i(M, this)) == null ? n(M, this, /* @__PURE__ */ new Map()) : s).get(e)) == null ? void 0 : o.get(t)) == null ? r(N, this, ct).call(this, i(M, this), e, t, r(N, this, lt).call(this, e, t)) : a;
853
+ }
854
+ checkBinaryOverload(e, t) {
855
+ var a, o, s;
856
+ return (a = (o = ((s = i(ot, this)) == null ? n(ot, this, /* @__PURE__ */ new Map()) : s).get(e)) == null ? void 0 : o.get(t)) == null ? r(N, this, ct).call(this, i(ot, this), e, t, r(N, this, ut).call(this, e, t)) : a;
857
+ }
858
+ };
859
+ function ct(e, t, n, r) {
860
+ return (e.get(t) || e.set(t, /* @__PURE__ */ new Map()).get(t)).set(n, r), r;
861
+ }
862
+ function lt(e, t) {
863
+ let n = r(N, this, dt).call(this, e, t);
864
+ if (n.length === 0) return !1;
865
+ if (n.length === 1) return n[0];
866
+ throw Error(`Operator overload '${n[0].signature}' overlaps with '${n[1].signature}'.`);
867
+ }
868
+ function ut(e, t) {
869
+ let n = r(N, this, dt).call(this, e, t);
870
+ if (n.length === 0) return !1;
871
+ let i = n[0].returnType;
872
+ for (let e = 1; e < n.length; e++) i = i.unify(this.registry, n[e].returnType) || A;
873
+ return i;
874
+ }
875
+ function dt(e, t) {
876
+ let n = [];
877
+ for (let i of this.declarations) {
878
+ if (i.leftType === e && i.rightType === t) return [i];
879
+ let a = r(N, this, ft).call(this, i, e, t);
880
+ a && n.push(a);
881
+ }
882
+ if (n.length === 0) {
883
+ var i;
884
+ let t = (i = this.declarations[0]) == null ? void 0 : i.operator;
885
+ if ((t === "==" || t === "!=") && e.kind === "dyn") return Ct[t];
886
+ }
887
+ return n;
888
+ }
889
+ function ft(e, t, n) {
890
+ let i = e.hasPlaceholderType ? /* @__PURE__ */ new Map() : null, a = r(N, this, ht).call(this, e.leftType, t, i);
891
+ if (!a) return;
892
+ let o = r(N, this, ht).call(this, e.rightType, n, i);
893
+ if (o) return (e.operator === "==" || e.operator === "!=") && e.leftType.kind === "dyn" && e.leftType.valueType && t.kind !== "dyn" && n.kind !== "dyn" ? !1 : e.hasPlaceholderType ? {
894
+ async: e.async,
895
+ signature: e.signature,
896
+ handler: e.handler,
897
+ leftType: a,
898
+ rightType: o,
899
+ returnType: e.returnType.templated(this.registry, i)
900
+ } : e;
901
+ }
902
+ function pt(e, t, n) {
903
+ if (e.hasPlaceholderType) return r(N, this, mt).call(this, e, t, n);
904
+ if (!(n && e.receiverType && !n.matches(e.receiverType))) return e.matchesArgs(t);
905
+ }
906
+ function mt(e, t, n) {
907
+ let i = /* @__PURE__ */ new Map();
908
+ if (n && e.receiverType && !r(N, this, ht).call(this, e.receiverType, n, i)) return null;
909
+ for (let n = 0; n < t.length; n++) if (!r(N, this, ht).call(this, e.argTypes[n], t[n], i)) return null;
910
+ return {
911
+ async: e.async,
912
+ handler: e.handler,
913
+ signature: e.signature,
914
+ returnType: e.returnType.templated(this.registry, i)
915
+ };
916
+ }
917
+ function ht(e, t, n) {
918
+ if (!e.hasPlaceholderType) return t.matches(e) ? t : null;
919
+ let i = t.kind === "dyn";
920
+ return r(N, this, gt).call(this, e, t, n, i) && (i || t.matches(e.templated(this.registry, n))) ? t : null;
921
+ }
922
+ function gt(e, t, n, i = !1) {
923
+ if (!e.hasPlaceholderType) return !0;
924
+ if (!t) return !1;
925
+ let a = i || t.kind === "dyn";
926
+ switch (t = t.unwrappedType, e.kind) {
927
+ case "param": {
928
+ let r = a ? A : t, i = n.get(e.name);
929
+ return i ? i.kind === "dyn" || r.kind === "dyn" || i.matchesBoth(r) : n.set(e.name, r) && !0;
930
+ }
931
+ case "list": return t.name === "dyn" && (t = e), t.kind === "list" && r(N, this, gt).call(this, e.valueType, t.valueType, n, a);
932
+ case "map": return t.name === "dyn" && (t = e), t.kind === "map" && r(N, this, gt).call(this, e.keyType, t.keyType, n, a) && r(N, this, gt).call(this, e.valueType, t.valueType, n, a);
933
+ case "optional": return t.name === "dyn" && (t = e), t.kind === "optional" && r(N, this, gt).call(this, e.valueType, t.valueType, n, a);
934
+ }
935
+ return !0;
936
+ }
937
+ function _t(e) {
938
+ let t = [], n = "", r = 0;
939
+ for (let i of e) {
940
+ if (i === "<") r++;
941
+ else if (i === ">") r--;
942
+ else if (i === "," && r === 0) {
943
+ t.push(n.trim()), n = "";
944
+ continue;
945
+ }
946
+ n += i;
947
+ }
948
+ return n && t.push(n.trim()), t;
949
+ }
950
+ var vt = [
951
+ [
952
+ x,
953
+ "uint",
954
+ E.uint,
955
+ j.uint
956
+ ],
957
+ [
958
+ T,
959
+ "type",
960
+ E.type,
961
+ j.type
962
+ ],
963
+ [
964
+ _,
965
+ "optional",
966
+ Ie,
967
+ j.optional
968
+ ],
969
+ [
970
+ Uint8Array,
971
+ "bytes",
972
+ E.bytes,
973
+ j.bytes
974
+ ],
975
+ ...typeof Buffer < "u" ? [[
976
+ Buffer,
977
+ "bytes",
978
+ E.bytes,
979
+ j.bytes
980
+ ]] : []
981
+ ].map(([e, t, n, r]) => Object.freeze({
982
+ name: t,
983
+ typeType: n,
984
+ type: r,
985
+ ctor: e
986
+ })), yt = vt.map((e) => [e.name, e]), bt = vt.map((e) => [e.ctor, e]), xt = (e) => /* @__PURE__ */ Error(`Invalid variable declaration: ${e}`), St = (e) => /* @__PURE__ */ Error(`Invalid type declaration: ${e}`), Ct = {
987
+ "==": [{
988
+ handler: (e, t) => e === t,
989
+ returnType: j.bool
990
+ }],
991
+ "!=": [{
992
+ handler: (e, t) => e !== t,
993
+ returnType: j.bool
994
+ }]
995
+ }, wt = /* @__PURE__ */ new WeakMap(), P = /* @__PURE__ */ new WeakMap(), Tt = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap(), L = /* @__PURE__ */ new WeakMap(), R = /* @__PURE__ */ new WeakMap(), Et = /* @__PURE__ */ new WeakMap(), z = /* @__PURE__ */ new WeakMap(), Dt = /* @__PURE__ */ new WeakMap(), Ot = /* @__PURE__ */ new WeakMap(), B = /* @__PURE__ */ new WeakMap(), V = /* @__PURE__ */ new WeakSet(), kt = class e {
996
+ constructor(r = {}) {
997
+ var a, o;
998
+ w(this, V), t(this, wt, null), t(this, P, void 0), t(this, Tt, !0), t(this, F, null), t(this, I, null), t(this, L, null), t(this, R, null), t(this, Et, null), t(this, z, null), t(this, Dt, null), t(this, Ot, null), t(this, B, !1), this.enableOptionalTypes = (a = r.enableOptionalTypes) != null && a, this.unlistedVariablesAreDyn = (o = r.unlistedVariablesAreDyn) != null && o;
999
+ let s = r.parent instanceof e ? r.parent : null;
1000
+ if (s) {
1001
+ n(wt, this, s);
1002
+ let e = s;
1003
+ for (; e && !i(F, e);) e = i(wt, e);
1004
+ let t = s;
1005
+ for (; t && !i(I, t);) t = i(wt, t);
1006
+ n(L, this, i(L, s)), n(R, this, i(R, s)), n(Ot, this, {
1007
+ operators: i(F, e),
1008
+ functions: i(I, t)
1009
+ }), this.objectTypes = new Map(s.objectTypes), this.objectTypesByConstructor = new Map(s.objectTypesByConstructor), this.variables = s.variables, n(Tt, this, !1), n(P, this, i(P, s)), n(Et, this, i(Et, s)), n(z, this, i(z, s)), n(Dt, this, i(Dt, s)), (this.enableOptionalTypes !== s.enableOptionalTypes || this.unlistedVariablesAreDyn !== s.unlistedVariablesAreDyn) && he(this, this.enableOptionalTypes);
1010
+ } else {
1011
+ n(F, this, []), n(I, this, []), this.objectTypes = new Map(yt), this.objectTypesByConstructor = new Map(bt), n(P, this, new Map(ve(j))), n(Et, this, /* @__PURE__ */ new Map()), n(z, this, /* @__PURE__ */ new Map()), n(Dt, this, /* @__PURE__ */ new Map()), this.variables = /* @__PURE__ */ new Map(), this.variables.dyn = this.unlistedVariablesAreDyn;
1012
+ for (let e in E) this.registerConstant(e, "type", E[e]);
1013
+ }
1014
+ }
1015
+ deleteVariable(e) {
1016
+ r(V, this, At).call(this), this.variables.delete(e);
1017
+ }
1018
+ operatorCandidates(e) {
1019
+ if (i(L, this)) return r(V, this, Nt).call(this, i(L, this), e);
1020
+ let t = n(L, this, /* @__PURE__ */ new Map());
1021
+ for (let e of r(V, this, Pt).call(this)) r(V, this, Nt).call(this, t, e.operator).add(e);
1022
+ return r(V, this, Nt).call(this, t, e);
1023
+ }
1024
+ functionCandidates(e, t, n) {
1025
+ return r(V, this, It).call(this, `${e ? "rcall" : "call"}:${t}:${n}`);
1026
+ }
1027
+ registerVariable(e, t, n) {
1028
+ if (i(B, this)) throw Error("Cannot modify frozen registry");
1029
+ let a = n == null ? void 0 : n.description, o;
1030
+ if (typeof e == "string" && typeof t == "object" && !(t instanceof O) ? (a = t.description, o = t.value, t = t.schema ? this.registerType({
1031
+ name: `$${e}`,
1032
+ schema: t.schema
1033
+ }).type : t.type) : typeof e == "object" && (t = e.schema ? this.registerType({
1034
+ name: `$${e.name}`,
1035
+ schema: e.schema
1036
+ }).type : e.type, a = e.description, o = e.value, e = e.name), typeof e != "string" || !e) throw xt("name must be a string");
1037
+ if (Se.has(e)) throw xt(`'${e}' is a reserved name`);
1038
+ if (this.variables.get(e) !== void 0) throw xt(`'${e}' is already registered`);
1039
+ if (typeof t == "string") t = this.getType(t);
1040
+ else if (!(t instanceof O)) throw xt("type is required");
1041
+ return r(V, this, At).call(this), this.variables.set(e, new Je(e, t, a, o)), this;
1042
+ }
1043
+ registerConstant(e, t, n) {
1044
+ return typeof e == "object" ? this.registerVariable(e) : this.registerVariable({
1045
+ name: e,
1046
+ type: t,
1047
+ value: n
1048
+ }), this;
1049
+ }
1050
+ getType(e) {
1051
+ return r(V, this, H).call(this, e, !0);
1052
+ }
1053
+ getListType(e) {
1054
+ return i(Et, this).get(e) || i(Et, this).set(e, r(V, this, H).call(this, `list<${e}>`, !0)).get(e);
1055
+ }
1056
+ getMapType(e, t) {
1057
+ var n;
1058
+ return ((n = i(z, this).get(e)) == null ? void 0 : n.get(t)) || (i(z, this).get(e) || i(z, this).set(e, /* @__PURE__ */ new Map()).get(e)).set(t, r(V, this, H).call(this, `map<${e}, ${t}>`, !0)).get(t);
1059
+ }
1060
+ getOptionalType(e) {
1061
+ return i(Dt, this).get(e) || i(Dt, this).set(e, r(V, this, H).call(this, `optional<${e}>`, !0)).get(e);
1062
+ }
1063
+ assertType(e, t, n) {
1064
+ try {
1065
+ return r(V, this, H).call(this, e, !0);
1066
+ } catch (r) {
1067
+ throw r.message = `Invalid ${t} '${r.unknownType || e}' in '${n}'`, r;
1068
+ }
1069
+ }
1070
+ getFunctionType(e) {
1071
+ if (e === "ast") return rt;
1072
+ let t = r(V, this, H).call(this, e, !0);
1073
+ if (t.kind === "dyn" && t.valueType) throw Error(`type '${t.name}' is not supported`);
1074
+ return t;
1075
+ }
1076
+ registerType(e, t) {
1077
+ var n;
1078
+ if (i(B, this)) throw Error("Cannot modify frozen registry");
1079
+ if (typeof e == "object" && (t = e, e = t.fullName || t.name || ((n = t.ctor) == null ? void 0 : n.name)), typeof e == "string" && e[0] === "." && (e = e.slice(1)), typeof e != "string" || e.length < 2 || Se.has(e)) throw St(`name '${e}' is not valid`);
1080
+ if (this.objectTypes.has(e)) throw St(`type '${e}' already registered`);
1081
+ let a = r(V, this, H).call(this, e, !1);
1082
+ if (a.kind !== "message") throw St(`type '${e}' is not valid`);
1083
+ let o = {
1084
+ name: e,
1085
+ typeType: new T(e),
1086
+ type: a,
1087
+ ctor: typeof t == "function" ? t : t == null ? void 0 : t.ctor,
1088
+ convert: typeof t == "function" || t == null ? void 0 : t.convert,
1089
+ fields: typeof (t == null ? void 0 : t.schema) == "object" ? r(V, this, Vt).call(this, e, r(V, this, Lt).call(this, e, t.schema)) : r(V, this, Vt).call(this, e, typeof t == "function" || t == null ? void 0 : t.fields)
1090
+ };
1091
+ if (typeof o.ctor != "function") {
1092
+ if (!o.fields) throw St(`type '${e}' requires a constructor or fields`);
1093
+ Object.assign(o, r(V, this, Ht).call(this, e, o.fields));
1094
+ }
1095
+ return this.objectTypes.set(e, Object.freeze(o)), this.objectTypesByConstructor.set(o.ctor, o), this.registerFunctionOverload(`type(${e}): type`, () => o.typeType, { async: !1 }), o;
1096
+ }
1097
+ findMacro(e, t, n) {
1098
+ return this.functionCandidates(t, e, n).macro;
1099
+ }
1100
+ findUnaryOverload(e, t) {
1101
+ return this.operatorCandidates(e).findUnaryOverload(t);
1102
+ }
1103
+ findBinaryOverload(e, t, n) {
1104
+ return this.operatorCandidates(e).findBinaryOverload(t, n);
1105
+ }
1106
+ clone(t) {
1107
+ return n(B, this, !0), new e({
1108
+ parent: this,
1109
+ unlistedVariablesAreDyn: t.unlistedVariablesAreDyn,
1110
+ enableOptionalTypes: t.enableOptionalTypes
1111
+ });
1112
+ }
1113
+ getDefinitions() {
1114
+ let e = [], t = [];
1115
+ for (let [, t] of this.variables) t && e.push({
1116
+ name: t.name,
1117
+ description: t.description || null,
1118
+ type: t.type.name
1119
+ });
1120
+ for (let e of r(V, this, Ft).call(this)) t.push({
1121
+ signature: e.signature,
1122
+ name: e.name,
1123
+ description: e.description,
1124
+ receiverType: e.receiverType ? e.receiverType.name : null,
1125
+ returnType: e.returnType.name,
1126
+ params: e.params.map((e) => ({
1127
+ name: e.name,
1128
+ type: e.type.name,
1129
+ description: e.description
1130
+ }))
1131
+ });
1132
+ return {
1133
+ variables: e,
1134
+ functions: t
1135
+ };
1136
+ }
1137
+ registerFunctionOverload(e, t, n) {
1138
+ var a;
1139
+ if (i(B, this)) throw Error("Cannot modify frozen registry");
1140
+ typeof e == "object" ? n = e : typeof t == "object" ? n = t : n || (n = {});
1141
+ let o = typeof e == "string" ? e : (a = n.signature) == null ? void 0 : a, s = o === void 0 ? void 0 : r(V, this, Ut).call(this, o), c = (s == null ? void 0 : s.name) || n.name, l = (s == null ? void 0 : s.receiverType) || n.receiverType, u = s == null ? void 0 : s.argTypes, d = (s == null ? void 0 : s.returnType) || n.returnType, f = n.params;
1142
+ t = typeof t == "function" ? t : n.handler;
1143
+ let p;
1144
+ try {
1145
+ if (!c) throw Error("signature or name are required");
1146
+ if (!d) throw Error("must have a returnType");
1147
+ if (f) {
1148
+ if (u && f.length !== u.length) throw Error("mismatched length in params and args in signature");
1149
+ } else if (!u) throw Error("signature or params are required");
1150
+ p = new Ye({
1151
+ name: c,
1152
+ async: n == null ? void 0 : n.async,
1153
+ receiverType: l ? this.getType(l) : null,
1154
+ returnType: this.getType(d),
1155
+ handler: t,
1156
+ description: n.description,
1157
+ params: (u || f).map((e, t) => r(V, this, Kt).call(this, t, u == null ? void 0 : u[t], f == null ? void 0 : f[t]))
1158
+ });
1159
+ } catch (e) {
1160
+ throw e.message = typeof o == "string" ? `Invalid function declaration '${o}': ${e.message}` : c ? `Invalid function declaration '${c}': ${e.message}` : `Invalid function declaration: ${e.message}`, e;
1161
+ }
1162
+ r(V, this, Gt).call(this, p), r(V, this, Mt).call(this, p);
1163
+ }
1164
+ registerOperatorOverload(e, t, n) {
1165
+ let r = e.match(/^([-!])([\w.<>]+)(?::\s*([\w.<>]+))?$/);
1166
+ if (r) {
1167
+ let [, e, i, a] = r;
1168
+ return this.unaryOverload(e, i, t, a, n == null ? void 0 : n.async);
1169
+ }
1170
+ let i = e.match(/^([\w.<>]+) ([-+*%/]|==|!=|<|<=|>|>=|in) ([\w.<>]+)(?::\s*([\w.<>]+))?$/);
1171
+ if (!i) throw Error(`Operator overload invalid: ${e}`);
1172
+ let [, a, o, s, c] = i;
1173
+ return this.binaryOverload(a, o, s, t, c);
1174
+ }
1175
+ unaryOverload(e, t, n, a, o) {
1176
+ if (i(B, this)) throw Error("Cannot modify frozen registry");
1177
+ let s = this.assertType(t, "type", `${e}${t}`), c = this.assertType(a || t, "return type", `${e}${t}: ${a || t}`), l = new Xe({
1178
+ op: `${e}_`,
1179
+ leftType: s,
1180
+ returnType: c,
1181
+ handler: n,
1182
+ async: o
1183
+ });
1184
+ r(V, this, jt).call(this, r(V, this, Jt).call(this, l));
1185
+ }
1186
+ binaryOverload(e, t, n, a, o, s) {
1187
+ if (i(B, this)) throw Error("Cannot modify frozen registry");
1188
+ o != null || (o = Yt.has(t) ? "bool" : e);
1189
+ let c = `${e} ${t} ${n}: ${o}`, l = this.assertType(e, "left type", c), u = this.assertType(n, "right type", c), d = this.assertType(o, "return type", c);
1190
+ if (l.kind === "dyn" && l.valueType ? u = u.wrappedType : u.kind === "dyn" && u.valueType && (l = l.wrappedType), Yt.has(t) && d.type !== "bool") throw Error(`Comparison operator '${t}' must return 'bool', got '${d.type}'`);
1191
+ let f = new Xe({
1192
+ op: t,
1193
+ leftType: l,
1194
+ rightType: u,
1195
+ returnType: d,
1196
+ handler: a,
1197
+ async: s
1198
+ });
1199
+ if (f.hasPlaceholderType && !(u.hasPlaceholderType && l.hasPlaceholderType)) throw Error(`Operator overload with placeholders must use them in both left and right types: ${c}`);
1200
+ if (r(V, this, Jt).call(this, f), t === "==") {
1201
+ let e = [new Xe({
1202
+ op: "!=",
1203
+ leftType: l,
1204
+ rightType: u,
1205
+ handler(e, t, n, r) {
1206
+ return !a(e, t, n, r);
1207
+ },
1208
+ returnType: d,
1209
+ async: s
1210
+ })];
1211
+ l !== u && e.push(new Xe({
1212
+ op: "==",
1213
+ leftType: u,
1214
+ rightType: l,
1215
+ handler(e, t, n, r) {
1216
+ return a(t, e, n, r);
1217
+ },
1218
+ returnType: d,
1219
+ async: s
1220
+ }), new Xe({
1221
+ op: "!=",
1222
+ leftType: u,
1223
+ rightType: l,
1224
+ handler(e, t, n, r) {
1225
+ return !a(t, e, n, r);
1226
+ },
1227
+ returnType: d,
1228
+ async: s
1229
+ }));
1230
+ for (let t of e) r(V, this, Jt).call(this, t);
1231
+ for (let t of e) r(V, this, jt).call(this, t);
1232
+ }
1233
+ r(V, this, jt).call(this, f);
1234
+ }
1235
+ };
1236
+ function At() {
1237
+ i(Tt, this) || (this.variables = new Map(this.variables), this.variables.dyn = this.unlistedVariablesAreDyn, n(Tt, this, !0));
1238
+ }
1239
+ function jt(e) {
1240
+ i(F, this) || n(L, this, null), this.operatorCandidates(e.operator).add(e), i(F, this).push(e);
1241
+ }
1242
+ function Mt(e) {
1243
+ i(I, this) || n(R, this, null), r(V, this, It).call(this, e.partitionKey).add(e), i(I, this).push(e);
1244
+ }
1245
+ function Nt(e, t) {
1246
+ return e.get(t) || e.set(t, new st(this)).get(t);
1247
+ }
1248
+ function Pt() {
1249
+ return i(F, this) ? i(F, this) : n(F, this, [...i(Ot, this).operators]);
1250
+ }
1251
+ function Ft() {
1252
+ return i(I, this) ? i(I, this) : n(I, this, [...i(Ot, this).functions]);
1253
+ }
1254
+ function It(e) {
1255
+ if (i(R, this)) return r(V, this, Nt).call(this, i(R, this), e);
1256
+ let t = n(R, this, /* @__PURE__ */ new Map());
1257
+ for (let e of r(V, this, Ft).call(this)) r(V, this, Nt).call(this, t, e.partitionKey).add(e);
1258
+ return r(V, this, Nt).call(this, t, e);
1259
+ }
1260
+ function Lt(e, t) {
1261
+ let n = Object.create(null);
1262
+ for (let r of v(t)) {
1263
+ let i = t[r];
1264
+ if (typeof i == "object" && i) n[r] = this.registerType({
1265
+ name: `${e}.${r}`,
1266
+ schema: i
1267
+ }).type.name;
1268
+ else if (typeof i == "string") n[r] = i;
1269
+ else throw Error(`Invalid field definition for '${e}.${r}'`);
1270
+ }
1271
+ return n;
1272
+ }
1273
+ function H(e, t = !0) {
1274
+ let n = i(P, this).get(e);
1275
+ if (n) return n;
1276
+ if (typeof e != "string" || !e.length) throw Error("Invalid type: must be a string");
1277
+ if (n = e.match(/^[A-Z]$/), n) return r(V, this, Rt).call(this, nt, e, e);
1278
+ if (n = e.match(/^(dyn|list|map|optional)<(.+)>$/), !n) {
1279
+ if (t) {
1280
+ let t = /* @__PURE__ */ Error(`Unknown type: ${e}`);
1281
+ throw t.unknownType = e, t;
1282
+ }
1283
+ return r(V, this, Rt).call(this, Qe, e, e);
1284
+ }
1285
+ let a = n[1], o = n[2].trim();
1286
+ switch (a) {
1287
+ case "dyn": {
1288
+ let e = r(V, this, H).call(this, o, t).wrappedType;
1289
+ return i(P, this).set(e.name, e), e;
1290
+ }
1291
+ case "list": {
1292
+ let e = r(V, this, H).call(this, o, t);
1293
+ return r(V, this, Rt).call(this, Ze, `list<${e}>`, e);
1294
+ }
1295
+ case "map": {
1296
+ let n = _t(o);
1297
+ if (n.length !== 2) throw Error(`Invalid map type: ${e}`);
1298
+ let i = r(V, this, H).call(this, n[0], t), a = r(V, this, H).call(this, n[1], t);
1299
+ return r(V, this, Rt).call(this, tt, `map<${i}, ${a}>`, i, a);
1300
+ }
1301
+ case "optional": {
1302
+ let e = r(V, this, H).call(this, o, t);
1303
+ return r(V, this, Rt).call(this, et, `optional<${e}>`, e);
1304
+ }
1305
+ }
1306
+ }
1307
+ function Rt(e, t, ...n) {
1308
+ return i(P, this).get(t) || i(P, this).set(t, e(...n)).get(t);
1309
+ }
1310
+ function zt(e) {
1311
+ return typeof e == "string" ? { type: e } : e.id ? an(e) : e;
1312
+ }
1313
+ function Bt(e, t, n, i = !1) {
1314
+ try {
1315
+ let e = r(V, this, zt).call(this, t[n]);
1316
+ if (typeof (e == null ? void 0 : e.type) != "string") throw Error("unsupported declaration");
1317
+ return r(V, this, H).call(this, e.type, i);
1318
+ } catch (r) {
1319
+ throw r.message = `Field '${n}' in type '${e}' has unsupported declaration: ${JSON.stringify(t[n])}`, r;
1320
+ }
1321
+ }
1322
+ function Vt(e, t) {
1323
+ if (!t) return;
1324
+ let n = Object.create(null);
1325
+ for (let i of v(t)) n[i] = r(V, this, Bt).call(this, e, t, i);
1326
+ return n;
1327
+ }
1328
+ function Ht(e, r) {
1329
+ var a;
1330
+ let o, s = v(r), c = Object.create(null);
1331
+ for (let e of s) {
1332
+ let t = r[e], n = t.kind === "message" && this.objectTypes.get(t.name);
1333
+ c[e] = n === !1 ? !1 : n.convert ? n : !1;
1334
+ }
1335
+ let l = { [e]: (a = /* @__PURE__ */ new WeakMap(), o = Symbol.iterator, class extends Map {
1336
+ constructor(e) {
1337
+ super(), t(this, a, void 0), n(a, this, e);
1338
+ }
1339
+ [o]() {
1340
+ if (this.size !== s.length) for (let e of s) this.get(e);
1341
+ return super[Symbol.iterator]();
1342
+ }
1343
+ get(e) {
1344
+ var t;
1345
+ let n = super.get(e);
1346
+ if (n !== void 0 || this.has(e)) return n;
1347
+ let r = c[e];
1348
+ if (r !== void 0) {
1349
+ if (n = i(a, this) instanceof Map ? i(a, this).get(e) : (t = i(a, this)) == null ? void 0 : t[e], r && n && typeof n == "object") switch (n.constructor) {
1350
+ case void 0:
1351
+ case Object:
1352
+ case Map: n = r.convert(n);
1353
+ }
1354
+ return super.set(e, n), n;
1355
+ }
1356
+ }
1357
+ }) }[e];
1358
+ return {
1359
+ ctor: l,
1360
+ convert(e) {
1361
+ if (e) return e.constructor === l ? e : new l(e);
1362
+ }
1363
+ };
1364
+ }
1365
+ function Ut(e) {
1366
+ if (typeof e != "string") throw Error("Invalid signature: must be a string");
1367
+ let t = e.match(/^(?:([a-zA-Z0-9.<>]+)\.)?(\w+)\(([^)]*)\):(.*)$/);
1368
+ if (!t) throw Error(`Invalid signature: ${e}`);
1369
+ let n = t[4].trim();
1370
+ if (!n) throw Error(`Invalid signature: ${e}`);
1371
+ return {
1372
+ receiverType: t[1] || null,
1373
+ name: t[2],
1374
+ argTypes: _t(t[3]),
1375
+ returnType: n
1376
+ };
1377
+ }
1378
+ function Wt(e, t) {
1379
+ return e.name !== t.name || e.argTypes.length !== t.argTypes.length || (e.receiverType || t.receiverType) && (!e.receiverType || !t.receiverType) ? !1 : (e.receiverType === t.receiverType || e.receiverType === A || t.receiverType === A) && (t.macro || e.macro || t.argTypes.every((t, n) => {
1380
+ let r = e.argTypes[n];
1381
+ return t === r || t === A || r === A;
1382
+ }));
1383
+ }
1384
+ function Gt(e) {
1385
+ for (let t of r(V, this, It).call(this, e.partitionKey)) if (r(V, this, Wt).call(this, t, e)) throw Error(`Function signature '${e.signature}' overlaps with existing overload '${t.signature}'.`);
1386
+ }
1387
+ function Kt(e, t, n) {
1388
+ var r;
1389
+ if (!n) return {
1390
+ type: this.getFunctionType(t),
1391
+ name: `arg${e}`,
1392
+ description: null
1393
+ };
1394
+ let i = n.type || t;
1395
+ if (!i) throw Error(`params[${e}].type is required`);
1396
+ if (t && i !== t) throw Error(`params[${e}].type not equal to signature type`);
1397
+ return {
1398
+ name: n.name || `arg${e}`,
1399
+ type: this.getFunctionType(i),
1400
+ description: (r = n.description) == null ? null : r
1401
+ };
1402
+ }
1403
+ function qt(e) {
1404
+ for (let t of this.operatorCandidates(e.operator)) if (e.equals(t)) return !0;
1405
+ return !1;
1406
+ }
1407
+ function Jt(e) {
1408
+ if (!r(V, this, qt).call(this, e)) return e;
1409
+ throw Error(`Operator overload already registered: ${e.signature}`);
1410
+ }
1411
+ var Yt = /* @__PURE__ */ new Set([
1412
+ "<",
1413
+ "<=",
1414
+ ">",
1415
+ ">=",
1416
+ "==",
1417
+ "!=",
1418
+ "in"
1419
+ ]);
1420
+ function Xt(e) {
1421
+ return new kt(e);
1422
+ }
1423
+ var Zt = /* @__PURE__ */ new WeakMap(), Qt = /* @__PURE__ */ new WeakMap(), $t = /* @__PURE__ */ new WeakMap(), en = /* @__PURE__ */ new WeakMap(), tn = class {
1424
+ constructor(e, r) {
1425
+ if (t(this, Zt, void 0), t(this, Qt, void 0), t(this, $t, void 0), t(this, en, void 0), n(Zt, this, e.variables), r != null) {
1426
+ if (typeof r != "object") throw h("invalid_context", "Context must be an object");
1427
+ r instanceof Map ? n($t, this, r) : n(Qt, this, r);
1428
+ }
1429
+ }
1430
+ getValue(e) {
1431
+ var t, n;
1432
+ return ((t = i(en, this)) == null ? void 0 : t.get(e)) || (i(Qt, this) ? i(Qt, this)[e] : (n = i($t, this)) == null ? void 0 : n.get(e));
1433
+ }
1434
+ getVariable(e) {
1435
+ var t;
1436
+ return (t = i(Zt, this).get(e)) == null ? i(Zt, this).dyn && !Se.has(e) ? new Je(e, A) : void 0 : t;
1437
+ }
1438
+ getCheckedValue(e, t) {
1439
+ let r = this.getValue(t.args);
1440
+ if (r === void 0) throw e.createError("unknown_variable", `Unknown variable: ${t.args}`, t);
1441
+ if (t.checkedType.matchesValueType(r, e)) return r;
1442
+ let a = t.checkedType, o = e.debugType(r);
1443
+ if (a.kind === "message" && o.kind === "map") {
1444
+ var s, c, l;
1445
+ let o = (s = e.objectTypes.get(a.name)) == null || (c = s.convert) == null ? void 0 : c.call(s, r);
1446
+ if (o) return ((l = i(en, this)) == null ? n(en, this, /* @__PURE__ */ new Map()) : l).set(t.args, o), o;
1447
+ }
1448
+ throw e.createError("variable_type_mismatch", `Variable '${t.args}' is not of type '${a}', got '${o}'`, t);
1449
+ }
1450
+ forkWithVariable(e, t) {
1451
+ return new rn(this, e, t);
1452
+ }
1453
+ }, nn = /* @__PURE__ */ new WeakMap(), rn = class e {
1454
+ constructor(e, r, i) {
1455
+ t(this, nn, void 0), c(this, "accuType", void 0), c(this, "accuValue", void 0), c(this, "iterValue", void 0), n(nn, this, e), this.iterVar = r, this.iterType = i;
1456
+ }
1457
+ forkWithVariable(t, n) {
1458
+ return new e(this, t, n);
1459
+ }
1460
+ reuse(t) {
1461
+ if (!this.async) return n(nn, this, t), this;
1462
+ let r = new e(t, this.iterVar, this.iterType);
1463
+ return r.accuType = this.accuType, r;
1464
+ }
1465
+ setIterValue(e, t) {
1466
+ if (this.iterType.matchesValueType(e, t)) return this.iterValue = e, this;
1467
+ let n = this.iterType, r = t.debugType(e);
1468
+ if (n.kind === "message" && r.kind === "map") {
1469
+ var i, a;
1470
+ let r = (i = t.objectTypes.get(n.name)) == null || (a = i.convert) == null ? void 0 : a.call(i, e);
1471
+ if (r) return this.iterValue = r, this;
1472
+ }
1473
+ throw t.createError("variable_type_mismatch", `Variable '${this.iterVar}' is not of type '${n}', got '${r}'`);
1474
+ }
1475
+ setAccuType(e) {
1476
+ return this.accuType = e, this;
1477
+ }
1478
+ setAccuValue(e) {
1479
+ return this.accuValue = e, this;
1480
+ }
1481
+ getValue(e) {
1482
+ return this.iterVar === e ? this.iterValue : i(nn, this).getValue(e);
1483
+ }
1484
+ getCheckedValue(e, t) {
1485
+ return this.iterVar === t.args ? this.iterValue : i(nn, this).getCheckedValue(e, t);
1486
+ }
1487
+ getVariable(e) {
1488
+ return this.iterVar === e ? new Je(e, this.iterType) : i(nn, this).getVariable(e);
1489
+ }
1490
+ };
1491
+ function an(e) {
1492
+ let t;
1493
+ return t = e.map ? `map<${on(e.keyType, e.resolvedKeyType)}, ${on(e.type, e.resolvedType)}>` : on(e.type, e.resolvedType), { type: e.repeated ? `list<${t}>` : t };
1494
+ }
1495
+ function on(e, t) {
1496
+ switch (e) {
1497
+ case "string": return "string";
1498
+ case "bytes": return "bytes";
1499
+ case "bool": return "bool";
1500
+ case "double":
1501
+ case "float":
1502
+ case "int32":
1503
+ case "int64":
1504
+ case "sint32":
1505
+ case "sint64":
1506
+ case "sfixed32":
1507
+ case "sfixed64":
1508
+ case "uint32":
1509
+ case "uint64":
1510
+ case "fixed32":
1511
+ case "fixed64": return "double";
1512
+ default:
1513
+ switch (t == null ? void 0 : t.constructor.name) {
1514
+ case "Type": return t.fullName.slice(1);
1515
+ case "Enum": return "int";
1516
+ }
1517
+ return e != null && e.includes(".") ? e : "dyn";
1518
+ }
1519
+ }
1520
+ u(), l();
1521
+ var sn = j.dyn, cn = class {
1522
+ constructor(e) {
1523
+ c(this, "dynType", j.dyn), c(this, "optionalType", j.optional), c(this, "stringType", j.string), c(this, "intType", j.int), c(this, "doubleType", j.double), c(this, "boolType", j.bool), c(this, "nullType", j.null), c(this, "listType", j.list), c(this, "mapType", j.map), this.opts = e.opts, this.registry = e.registry, this.objectTypes = this.registry.objectTypes, this.objectTypesByConstructor = this.registry.objectTypesByConstructor;
1524
+ }
1525
+ getType(e) {
1526
+ return this.registry.getType(e);
1527
+ }
1528
+ debugType(e) {
1529
+ switch (typeof e) {
1530
+ case "string": return this.stringType;
1531
+ case "bigint": return this.intType;
1532
+ case "number": return this.doubleType;
1533
+ case "boolean": return this.boolType;
1534
+ case "object":
1535
+ if (e === null) return this.nullType;
1536
+ switch (e.constructor) {
1537
+ case void 0:
1538
+ case Object:
1539
+ case Map: return this.mapType;
1540
+ case Array:
1541
+ case Set: return this.listType;
1542
+ default:
1543
+ var t, n;
1544
+ return ((t = this.objectTypesByConstructor.get(e.constructor)) == null ? void 0 : t.type) || ln(this, ((n = e.constructor) == null ? void 0 : n.name) || typeof e);
1545
+ }
1546
+ default: ln(this, typeof e);
1547
+ }
1548
+ }
1549
+ };
1550
+ function ln(e, t) {
1551
+ throw e.createError("unsupported_type", `Unsupported type: ${t}`);
1552
+ }
1553
+ var un = (e) => Array.isArray(e) ? e.some((e) => e.maybeAsync) : !1;
1554
+ function U(e, t, n) {
1555
+ return t === !0 || t && (t != null && t.maybeAsync || un(t)) ? dn(n) : e === !0 || e && (e != null && e.maybeAsync || un(e)) ? fn(n) : n;
1556
+ }
1557
+ function dn(e) {
1558
+ var t;
1559
+ return (t = e.__asyncBoth) == null ? e.__asyncBoth = function(t, n, r, i) {
1560
+ return t instanceof Promise || n instanceof Promise ? n instanceof Promise ? t instanceof Promise ? Promise.all([t, n]).then((t) => e(t[0], t[1], r, i)) : n.then((n) => e(t, n, r, i)) : t.then((t) => e(t, n, r, i)) : e(t, n, r, i);
1561
+ } : t;
1562
+ }
1563
+ function fn(e) {
1564
+ var t;
1565
+ return (t = e.__asyncFirst) == null ? e.__asyncFirst = function(t, n, r, i) {
1566
+ return t instanceof Promise ? t.then((t) => e(t, n, r, i)) : e(t, n, r, i);
1567
+ } : t;
1568
+ }
1569
+ function pn(e, t, n) {
1570
+ t.right = t.args[1];
1571
+ let r = e.check(t.left = t.args[0], n);
1572
+ return t.op === "[]" && e.check(t.right, n), t.handle = U(t.left, t.op === "[]" && t.right, r === sn ? Xn : Jn), r.kind === "optional" ? e.registry.getOptionalType(e.checkAccessOnType(t, n, r.valueType, !0)) : e.checkAccessOnType(t, n, r);
1573
+ }
1574
+ function mn(e, t, n) {
1575
+ t.right = t.args[1];
1576
+ let r = e.check(t.left = t.args[0], n);
1577
+ t.op === "[?]" && e.check(t.right, n), t.handle = U(t.left, t.op === "[?]" && t.right, qn);
1578
+ let i = r.kind === "optional" ? r.valueType : r;
1579
+ return e.registry.getOptionalType(e.checkAccessOnType(t, n, i, !0));
1580
+ }
1581
+ var hn = {
1582
+ heterogeneous_list_element: "List elements must have the same type,",
1583
+ heterogeneous_map_key: "Map key uses wrong type,",
1584
+ heterogeneous_map_value: "Map value uses wrong type,"
1585
+ };
1586
+ function gn(e, t, n, r, i) {
1587
+ let a = e.check(r, t);
1588
+ if (a === n || n.isEmpty()) return a;
1589
+ if (a.isEmpty()) return n;
1590
+ throw e.createError(i, `${hn[i]} expected type '${e.formatType(n)}' but found '${e.formatType(a)}'`, r);
1591
+ }
1592
+ function _n(e, t, n, r) {
1593
+ return n.unify(e.registry, e.check(r, t)) || sn;
1594
+ }
1595
+ function vn(e, t, n) {
1596
+ let r = e.debugRuntimeType(t);
1597
+ return e.createError("invalid_condition_type", `${n.meta.label || "Ternary condition must be bool"}, got '${r}'`, n);
1598
+ }
1599
+ function yn(e, t, n, r) {
1600
+ if (e === !0) return t.run(n.left, r);
1601
+ if (e === !1) return t.run(n.right, r);
1602
+ throw vn(t, e, n.condition);
1603
+ }
1604
+ function bn(e, t, n) {
1605
+ let r = e.debugRuntimeType(t);
1606
+ return e.createError("invalid_logical_operand", `Logical operator requires bool operands, got '${r}'`, n);
1607
+ }
1608
+ function xn(e, t, n) {
1609
+ return t instanceof Error ? t : bn(e, t, n);
1610
+ }
1611
+ function Sn(e, t, n, r, i) {
1612
+ if (i === e) return e;
1613
+ if (i === !e) {
1614
+ if (r === i) return i;
1615
+ throw xn(t, r, n.left);
1616
+ }
1617
+ if (i instanceof Promise) return i.then((i) => Cn(e, t, n, r, i));
1618
+ throw bn(t, i, n.left);
1619
+ }
1620
+ function Cn(e, t, n, r, i) {
1621
+ if (i === e) return e;
1622
+ if (typeof i != "boolean") throw bn(t, i, n.right);
1623
+ if (typeof r != "boolean") throw xn(t, r, n.left);
1624
+ return !e;
1625
+ }
1626
+ function wn(e, t, n) {
1627
+ let r = e.check(t.left = t.args[0], n), i = e.check(t.right = t.args[1], n);
1628
+ if (!r.isDynOrBool()) throw e.createError("invalid_logical_operand", `Logical operator requires bool operands, got '${e.formatType(r)}'`, t);
1629
+ if (!i.isDynOrBool()) throw e.createError("invalid_logical_operand", `Logical operator requires bool operands, got '${e.formatType(i)}'`, t);
1630
+ return e.boolType;
1631
+ }
1632
+ function Tn(e, t, n) {
1633
+ let r = t.op, i = e.check(t.args, n);
1634
+ if (t.candidates = e.registry.operatorCandidates(r), i.kind === "dyn") return t.handle = U(t.args, !1, En), t.candidates.returnType;
1635
+ let a = t.candidates.findUnaryOverload(i);
1636
+ if (!a) throw e.createError("no_such_overload", `no such overload: ${r[0]}${e.formatType(i)}`, t);
1637
+ return t.handle = U(t.args, !1, a.handler), a.returnType;
1638
+ }
1639
+ function En(e, t, n) {
1640
+ let r = n.debugRuntimeType(e, t.args.checkedType), i = t.candidates.findUnaryOverload(r);
1641
+ if (i) return i.handler(e);
1642
+ throw n.createError("no_such_overload", `no such overload: ${t.op[0]}${r}`, t);
1643
+ }
1644
+ function Dn(e, t, n) {
1645
+ return t.handle(e.run(t.args, n), t, e);
1646
+ }
1647
+ function On(e, t, n) {
1648
+ let r = t.op, i = e.check(t.left = t.args[0], n), a = e.check(t.right = t.args[1], n);
1649
+ t.candidates = e.registry.operatorCandidates(r);
1650
+ let o = i.hasDynType || a.hasDynType ? void 0 : t.candidates.findBinaryOverload(i, a);
1651
+ if (t.handle = U(t.left, t.right, (o == null ? void 0 : o.handler) || jn), o) return o.returnType;
1652
+ let s = t.candidates.checkBinaryOverload(i, a);
1653
+ if (i.hasDynType || (t.leftStaticType = i), a.hasDynType || (t.rightStaticType = a), s) return s;
1654
+ throw e.createError("no_such_overload", `no such overload: ${e.formatType(i)} ${r} ${e.formatType(a)}`, t);
1655
+ }
1656
+ function kn(e, t, n) {
1657
+ return t.handle(e.run(t.left, n), e.run(t.right, n), t, e);
1658
+ }
1659
+ function An(e, t, n) {
1660
+ return t.handle(e.run(t.left, n), t.right, t, e);
1661
+ }
1662
+ function jn(e, t, n, r) {
1663
+ let i = n.leftStaticType || r.debugTypeDeep(e).wrappedType, a = n.rightStaticType || r.debugTypeDeep(t).wrappedType, o = n.candidates.findBinaryOverload(i, a);
1664
+ if (o) return o.handler(e, t, n, r);
1665
+ throw r.createError("no_such_overload", `no such overload: ${i} ${n.op} ${a}`, n);
1666
+ }
1667
+ function Mn(e, t, n, r) {
1668
+ try {
1669
+ let i = e.apply(t, n);
1670
+ return i instanceof Promise ? i.catch((e) => {
1671
+ throw le(e, r);
1672
+ }) : i;
1673
+ } catch (e) {
1674
+ throw le(e, r);
1675
+ }
1676
+ }
1677
+ function Nn(e, t, n) {
1678
+ let r = t.args[1], i = t.argTypes, a = r.length;
1679
+ for (; a--;) i[a] = n.debugRuntimeType(e[a], r[a].checkedType);
1680
+ let o = t.candidates.findFunction(i);
1681
+ if (o) return Mn(o.handler, n, e, t);
1682
+ throw n.createError("no_matching_overload", `found no matching overload for '${t.args[0]}(${i.map((e) => e.unwrappedType).join(", ")})'`, t);
1683
+ }
1684
+ function Pn(e, t, n) {
1685
+ let [, r, i] = n.args, a = n.argTypes;
1686
+ for (let n = 0; n < a.length; n++) a[n] = t.debugRuntimeType(e[n + 1], i[n].checkedType);
1687
+ let o = t.debugRuntimeType(e[0], r.checkedType), s = n.candidates.findFunction(a, o);
1688
+ if (s) return Mn(s.handler, t, e, n);
1689
+ throw t.createError("no_matching_overload", `found no matching overload for '${o.type}.${n.args[0]}(${a.map((e) => e.unwrappedType).join(", ")})'`, n);
1690
+ }
1691
+ function Fn(e, t, n, r = t.length) {
1692
+ if (r === 0) return [];
1693
+ let i, a = Array(r);
1694
+ for (; r--;) (a[r] = e.run(t[r], n)) instanceof Promise && (i != null || (i = !0));
1695
+ return i ? Promise.all(a) : a;
1696
+ }
1697
+ function In(e) {
1698
+ let t = {};
1699
+ for (let n = 0; n < e.length; n++) {
1700
+ let [r, i] = e[n];
1701
+ r !== "__proto__" && r !== "constructor" && r !== "prototype" && (t[r] = i);
1702
+ }
1703
+ return t;
1704
+ }
1705
+ function Ln(e, t, n) {
1706
+ let r = e.check(t, n);
1707
+ if (r.kind === "dyn") return r;
1708
+ if (r.kind === "list") return r.valueType;
1709
+ if (r.kind === "map") return r.keyType;
1710
+ throw e.createError("invalid_comprehension_range", `Expression of type '${e.formatType(r)}' cannot be range of a comprehension (must be list, map, or dynamic).`, t);
1711
+ }
1712
+ function Rn(e, t, n) {
1713
+ if (n instanceof Set) return [...n];
1714
+ if (n instanceof Map) return [...n.keys()];
1715
+ if (n && typeof n == "object") return v(n);
1716
+ throw e.createError("invalid_comprehension_range", `Expression of type '${e.debugType(n)}' cannot be range of a comprehension (must be list, map, or dynamic).`, t.iterable);
1717
+ }
1718
+ function zn(e, t, n, r) {
1719
+ ye(e) || (e = Rn(n, t, e));
1720
+ let i = n.run(t.init, r = t.iterCtx.reuse(r));
1721
+ return r.accuValue = i, r === t.iterCtx ? Wn(n, r, t, e, i, 0) : Gn(n, r, t, e, i, 0);
1722
+ }
1723
+ function Bn(e, t, n, r) {
1724
+ ye(e) || (e = Rn(n, t, e));
1725
+ let i = n.run(t.init, r = t.iterCtx.reuse(r));
1726
+ return r.accuValue = i, r === t.iterCtx ? Vn(n, r, t, e, i, 0) : Hn(n, r, t, e, i, 0);
1727
+ }
1728
+ function Vn(e, t, n, r, i, a) {
1729
+ let o = n.condition, s = n.step, c = r.length;
1730
+ for (; a < c && (!o || o(i));) if (i = e.run(s, t.setIterValue(r[a++], e)), i instanceof Promise) return Hn(e, t, n, r, i, a);
1731
+ return n.result(i);
1732
+ }
1733
+ function Hn(e, t, n, r, i, a) {
1734
+ return Un.apply(this, arguments);
1735
+ }
1736
+ function Un() {
1737
+ return Un = s(function* (e, t, n, r, i, a) {
1738
+ t === n.iterCtx && (t.async = !0);
1739
+ let o = n.condition, s = n.step, c = r.length;
1740
+ for (i = yield i; a < c;) {
1741
+ if (o && !o(i)) return n.result(i);
1742
+ i = e.run(s, t.setIterValue(r[a++], e)), i instanceof Promise && (i = yield i);
1743
+ }
1744
+ return n.result(i);
1745
+ }), Un.apply(this, arguments);
1746
+ }
1747
+ function Wn(e, t, n, r, i, a, o, s) {
1748
+ let c = n.condition, l = n.step, u = r.length;
1749
+ for (; a < u;) {
1750
+ var d;
1751
+ if (!c(i)) return n.result(i);
1752
+ if (s = e.tryEval(l, t.setIterValue(r[a++], e)), s instanceof Promise) return Gn(e, t, n, r, i, a, o, s);
1753
+ s instanceof Error && ((d = o) == null ? o = s : d) || (i = s);
1754
+ }
1755
+ if (o && c(i)) throw o;
1756
+ return n.result(i);
1757
+ }
1758
+ function Gn(e, t, n, r, i, a, o, s) {
1759
+ return Kn.apply(this, arguments);
1760
+ }
1761
+ function Kn() {
1762
+ return Kn = s(function* (e, t, n, r, i, a, o, s) {
1763
+ t === n.iterCtx && (t.async = !0);
1764
+ let c = n.condition, l = n.step, u = r.length;
1765
+ for (s = yield s, s instanceof Error ? o != null || (o = s) : i = s; a < u;) {
1766
+ var d;
1767
+ if (!c(i)) return n.result(i);
1768
+ s = e.tryEval(l, t.setIterValue(r[a++], e)), s instanceof Promise && (s = yield s), s instanceof Error && ((d = o) == null ? o = s : d) || (i = s);
1769
+ }
1770
+ if (o && c(i)) throw o;
1771
+ return n.result(i);
1772
+ }), Kn.apply(this, arguments);
1773
+ }
1774
+ function qn(e, t, n, r) {
1775
+ return r.optionalType.field(e, t, n, r);
1776
+ }
1777
+ function Jn(e, t, n, r) {
1778
+ return n.left.checkedType.field(e, t, n, r);
1779
+ }
1780
+ var Yn = Object.create(null);
1781
+ function Xn(e, t, n, r) {
1782
+ switch (e == null ? void 0 : e.constructor) {
1783
+ case void 0:
1784
+ case Object: {
1785
+ let n = _e(e || Yn, t) ? e[t] : void 0;
1786
+ if (n !== void 0) return r.debugType(n), n;
1787
+ break;
1788
+ }
1789
+ case Map: {
1790
+ let n = e.get(t);
1791
+ if (n !== void 0) return r.debugType(n), n;
1792
+ break;
1793
+ }
1794
+ case Array:
1795
+ case Set: return r.listType.field(e, t, n, r);
1796
+ default:
1797
+ let i = r.objectTypesByConstructor.get(e.constructor);
1798
+ if (i) return i.type.field(e, t, n, r);
1799
+ typeof e == "object" && ln(r, e.constructor.name);
1800
+ }
1801
+ throw r.createError("no_such_key", `No such key: ${t}`, n);
1802
+ }
1803
+ var Zn = () => [], Qn = () => ({}), W = {
1804
+ value: {
1805
+ check(e, t) {
1806
+ return e.debugType(t.args);
1807
+ },
1808
+ evaluate(e, t) {
1809
+ return t.args;
1810
+ }
1811
+ },
1812
+ id: {
1813
+ check(e, t, n) {
1814
+ let r = n.getVariable(t.args);
1815
+ if (!r) throw e.createError("unknown_variable", `Unknown variable: ${t.args}`, t);
1816
+ if (r.constant) {
1817
+ let i = t.clone(W.value, r.value);
1818
+ return t.setMeta("alternate", i), e.check(i, n);
1819
+ }
1820
+ return r.type;
1821
+ },
1822
+ evaluate(e, t, n) {
1823
+ return n.getCheckedValue(e, t);
1824
+ }
1825
+ },
1826
+ ".": {
1827
+ alias: "fieldAccess",
1828
+ check: pn,
1829
+ evaluate: An
1830
+ },
1831
+ ".?": {
1832
+ alias: "optionalFieldAccess",
1833
+ check: mn,
1834
+ evaluate: An
1835
+ },
1836
+ "[]": {
1837
+ alias: "bracketAccess",
1838
+ check: pn,
1839
+ evaluate: kn
1840
+ },
1841
+ "[?]": {
1842
+ alias: "optionalBracketAccess",
1843
+ check: mn,
1844
+ evaluate: kn
1845
+ },
1846
+ call: {
1847
+ check(e, t, n) {
1848
+ var r, i;
1849
+ let [a, o] = t.args, s = t.candidates = e.registry.functionCandidates(!1, a, o.length), c = t.argTypes = o.map((t) => e.check(t, n)), l = s.findFunction(c);
1850
+ if (!l) throw e.createError("no_matching_overload", `found no matching overload for '${a}(${e.formatTypeList(c)})'`, t);
1851
+ return t.handle = U(o, !1, c.some((e) => e.hasDynType) ? Nn : (i = (r = l.handler).__handle) == null ? r.__handle = (e, t, n) => Mn(l.handler, n, e, t) : i), l.returnType;
1852
+ },
1853
+ evaluate(e, t, n) {
1854
+ return t.handle(Fn(e, t.args[1], n), t, e);
1855
+ }
1856
+ },
1857
+ rcall: {
1858
+ check(e, t, n) {
1859
+ let [r, i, a] = t.args, o = e.check(i, n), s = t.candidates = e.registry.functionCandidates(!0, r, a.length), c = t.argTypes = a.map((t) => e.check(t, n));
1860
+ if (t.receiverWithArgs = [i, ...a], t.handle = U(t.receiverWithArgs, !1, Pn), o.kind === "dyn" && s.returnType) return s.returnType;
1861
+ let l = s.findFunction(c, o);
1862
+ if (!l) throw e.createError("no_matching_overload", `found no matching overload for '${o.type}.${r}(${e.formatTypeList(c)})'`, t);
1863
+ if (!o.hasPlaceholderType && !c.some((e) => e.hasDynType)) {
1864
+ var u;
1865
+ let e = l.handler, n = (u = e.__handle) == null ? e.__handle = (t, n, r) => Mn(e, n, t, r) : u;
1866
+ t.handle = U(t.receiverWithArgs, !1, n);
1867
+ }
1868
+ return l.returnType;
1869
+ },
1870
+ evaluate(e, t, n) {
1871
+ return t.handle(Fn(e, t.receiverWithArgs, n), e, t);
1872
+ }
1873
+ },
1874
+ list: {
1875
+ check(e, t, n) {
1876
+ let r = t.args, i = r.length;
1877
+ if (i === 0) return t.setMeta("evaluate", Zn) && e.getType("list<T>");
1878
+ let a = e.check(r[0], n), o = e.opts.homogeneousAggregateLiterals ? gn : _n;
1879
+ for (let t = 1; t < i; t++) a = o(e, n, a, r[t], "heterogeneous_list_element");
1880
+ return e.registry.getListType(a);
1881
+ },
1882
+ evaluate(e, t, n) {
1883
+ return Fn(e, t.args, n);
1884
+ }
1885
+ },
1886
+ map: {
1887
+ check(e, t, n) {
1888
+ let r = t.args, i = r.length;
1889
+ if (i === 0) return t.setMeta("evaluate", Qn) && e.getType("map<K, V>");
1890
+ let a = e.opts.homogeneousAggregateLiterals ? gn : _n, o = e.check(r[0][0], n), s = e.check(r[0][1], n);
1891
+ for (let t = 1; t < i; t++) {
1892
+ let i = r[t];
1893
+ o = a(e, n, o, i[0], "heterogeneous_map_key"), s = a(e, n, s, i[1], "heterogeneous_map_value");
1894
+ }
1895
+ return e.registry.getMapType(o, s);
1896
+ },
1897
+ evaluate(e, t, n) {
1898
+ let r = t.args, i = r.length, a = Array(i), o;
1899
+ for (let t = 0; t < i; t++) {
1900
+ let i = r[t], s = e.run(i[0], n), c = e.run(i[1], n);
1901
+ s instanceof Promise || c instanceof Promise ? (a[t] = Promise.all([s, c]), o != null || (o = !0)) : a[t] = [s, c];
1902
+ }
1903
+ return o ? Promise.all(a).then(In) : In(a);
1904
+ }
1905
+ },
1906
+ comprehension: {
1907
+ check(e, t, n) {
1908
+ let r = t.args;
1909
+ r.iterCtx = n.forkWithVariable(r.iterVarName, Ln(e, r.iterable, n)).setAccuType(e.check(r.init, n));
1910
+ let i = e.check(r.step, r.iterCtx), a = r.errorsAreFatal ? Bn : zn;
1911
+ return t.handle = U(r.iterable, !1, a), r.kind === "quantifier" ? e.boolType : i;
1912
+ },
1913
+ evaluate(e, t, n) {
1914
+ return t.handle(e.run(t.args.iterable, n), t.args, e, n);
1915
+ }
1916
+ },
1917
+ accuValue: {
1918
+ check(e, t, n) {
1919
+ return n.accuType;
1920
+ },
1921
+ evaluate(e, t, n) {
1922
+ return n.accuValue;
1923
+ }
1924
+ },
1925
+ accuInc: {
1926
+ check(e, t, n) {
1927
+ return n.accuType;
1928
+ },
1929
+ evaluate(e, t, n) {
1930
+ return n.accuValue += 1;
1931
+ }
1932
+ },
1933
+ accuPush: {
1934
+ check(e, t, n) {
1935
+ let r = n.accuType, i = e.check(t.args, n);
1936
+ return t.args.maybeAsync || t.setMeta("evaluate", W.accuPush.evaluateSync), r.kind === "list" && r.valueType.kind !== "param" ? r : e.registry.getListType(i);
1937
+ },
1938
+ evaluateSync(e, t, n) {
1939
+ return n.accuValue.push(e.run(t.args, n)), n.accuValue;
1940
+ },
1941
+ evaluate(e, t, n) {
1942
+ let r = n.accuValue, i = e.run(t.args, n);
1943
+ return i instanceof Promise ? i.then((e) => r.push(e) && r) : (r.push(i), r);
1944
+ }
1945
+ },
1946
+ "?:": {
1947
+ alias: "ternary",
1948
+ check(e, t, n) {
1949
+ let r = t.condition = t.args[0], i = t.left = t.args[1], a = t.right = t.args[2], o = e.check(r, n);
1950
+ if (!o.isDynOrBool()) throw e.createError("invalid_condition_type", `${r.meta.label || "Ternary condition must be bool"}, got '${e.formatType(o)}'`, r);
1951
+ let s = e.check(i, n), c = e.check(a, n), l = s.unify(e.registry, c);
1952
+ if (t.handle = U(r, !1, yn), l) return l;
1953
+ throw e.createError("incompatible_ternary_branches", `Ternary branches must have the same type, got '${e.formatType(s)}' and '${e.formatType(c)}'`, t);
1954
+ },
1955
+ evaluate(e, t, n) {
1956
+ return t.handle(e.run(t.condition, n), e, t, n);
1957
+ }
1958
+ },
1959
+ "||": {
1960
+ check: wn,
1961
+ evaluate(e, t, n) {
1962
+ let r = e.tryEval(t.left, n);
1963
+ if (r === !0) return !0;
1964
+ if (r === !1) {
1965
+ let i = e.run(t.right, n);
1966
+ return typeof i == "boolean" ? i : Sn(!0, e, t, r, i);
1967
+ }
1968
+ return r instanceof Promise ? r.then((r) => r === !0 ? r : Sn(!0, e, t, r, e.run(t.right, n))) : Sn(!0, e, t, r, e.run(t.right, n));
1969
+ }
1970
+ },
1971
+ "&&": {
1972
+ check: wn,
1973
+ evaluate(e, t, n) {
1974
+ let r = e.tryEval(t.left, n);
1975
+ if (r === !1) return !1;
1976
+ if (r === !0) {
1977
+ let i = e.run(t.right, n);
1978
+ return typeof i == "boolean" ? i : Sn(!1, e, t, r, i);
1979
+ }
1980
+ return r instanceof Promise ? r.then((r) => r === !1 ? r : Sn(!1, e, t, r, e.run(t.right, n))) : Sn(!1, e, t, r, e.run(t.right, n));
1981
+ }
1982
+ },
1983
+ "!_": {
1984
+ alias: "unaryNot",
1985
+ check: Tn,
1986
+ evaluate: Dn
1987
+ },
1988
+ "-_": {
1989
+ alias: "unaryMinus",
1990
+ check: Tn,
1991
+ evaluate: Dn
1992
+ }
1993
+ };
1994
+ for (let e of [
1995
+ "!=",
1996
+ "==",
1997
+ "in",
1998
+ "+",
1999
+ "-",
2000
+ "*",
2001
+ "/",
2002
+ "%",
2003
+ "<",
2004
+ "<=",
2005
+ ">",
2006
+ ">="
2007
+ ]) W[e] = {
2008
+ check: On,
2009
+ evaluate: kn
2010
+ };
2011
+ for (let e of v(W)) {
2012
+ let t = W[e];
2013
+ t.name = e, t.alias && (W[t.alias] = t);
2014
+ }
2015
+ // ../../node_modules/.pnpm/@marcbachmann+cel-js@8.0.0/node_modules/@marcbachmann/cel-js/lib/macros.js
2016
+ var $n = (e) => e;
2017
+ function er(e, t) {
2018
+ if (e.op === "id") return e.args;
2019
+ throw m("invalid_macro_argument", t, e);
2020
+ }
2021
+ function tr(e) {
2022
+ let t = e ? "map(var, filter, transform)" : "map(var, transform)", n = `${t} invalid predicate iteration variable`, r = `${t} filter predicate must return bool`;
2023
+ return ({ args: t, receiver: i, ast: a }) => {
2024
+ let [o, s, c] = e ? t : [
2025
+ t[0],
2026
+ null,
2027
+ t[1]
2028
+ ], l = c.clone(W.accuPush, c);
2029
+ if (s) {
2030
+ let e = s.clone(W.accuValue);
2031
+ l = s.clone(W.ternary, [
2032
+ s.setMeta("label", r),
2033
+ l,
2034
+ e
2035
+ ]);
2036
+ }
2037
+ return { callAst: a.clone(W.comprehension, {
2038
+ errorsAreFatal: !0,
2039
+ iterable: i,
2040
+ iterVarName: er(o, n),
2041
+ init: a.clone(W.list, []),
2042
+ step: l,
2043
+ result: $n
2044
+ }) };
2045
+ };
2046
+ }
2047
+ function nr() {
2048
+ let e = "filter(var, predicate)", t = `${e} invalid predicate iteration variable`, n = `${e} predicate must return bool`;
2049
+ return ({ args: e, receiver: r, ast: i }) => {
2050
+ let a = er(e[0], t), o = i.clone(W.accuValue), s = e[1].setMeta("label", n), c = i.clone(W.accuPush, i.clone(W.id, a)), l = s.clone(W.ternary, [
2051
+ s,
2052
+ c,
2053
+ o
2054
+ ]);
2055
+ return { callAst: i.clone(W.comprehension, {
2056
+ errorsAreFatal: !0,
2057
+ iterable: r,
2058
+ iterVarName: a,
2059
+ init: i.clone(W.list, []),
2060
+ step: l,
2061
+ result: $n
2062
+ }) };
2063
+ };
2064
+ }
2065
+ function rr(e) {
2066
+ let t = `${e.name}(var, predicate) invalid predicate iteration variable`, n = `${e.name}(var, predicate) predicate must return bool`;
2067
+ return ({ args: r, receiver: i, ast: a }) => {
2068
+ let o = r[1].setMeta("label", n), s = e.transform({
2069
+ args: r,
2070
+ ast: a,
2071
+ predicate: o,
2072
+ opts: e
2073
+ });
2074
+ return { callAst: a.clone(W.comprehension, {
2075
+ kind: "quantifier",
2076
+ errorsAreFatal: e.errorsAreFatal || !1,
2077
+ iterable: i,
2078
+ iterVarName: er(r[0], t),
2079
+ init: s.init,
2080
+ condition: s.condition,
2081
+ step: s.step,
2082
+ result: s.result || $n
2083
+ }) };
2084
+ };
2085
+ }
2086
+ function ir() {
2087
+ let e = "has() invalid argument";
2088
+ function t(e, t, n) {
2089
+ let r = t.macroHasProps, i = r.length, a = e.run(r[--i], n), o;
2090
+ for (; i--;) {
2091
+ let t = r[i];
2092
+ if (t.op === ".?" && (o != null || (o = !0)), a = e.debugType(a).fieldLazy(a, t.args[1], t, e), a === void 0) {
2093
+ if (o || !i || t.op !== ".") break;
2094
+ throw h("no_such_key", `No such key: ${t.args[1]}`, t);
2095
+ }
2096
+ }
2097
+ return a !== void 0;
2098
+ }
2099
+ function n(t, n, r) {
2100
+ let i = n.args[0];
2101
+ if (i.op !== ".") throw t.createError("invalid_macro_argument", e, i);
2102
+ if (!n.macroHasProps) {
2103
+ let a = [];
2104
+ for (; i.op === "." || i.op === ".?";) i = a.push(i) && i.args[0];
2105
+ if (i.op !== "id") throw t.createError("invalid_macro_argument", e, i);
2106
+ t.check(i, r), a.push(i), n.macroHasProps = a;
2107
+ }
2108
+ return t.getType("bool");
2109
+ }
2110
+ return function({ args: e }) {
2111
+ return {
2112
+ args: e,
2113
+ evaluate: t,
2114
+ typeCheck: n,
2115
+ async: !1
2116
+ };
2117
+ };
2118
+ }
2119
+ function ar(e) {
2120
+ let t = (t, n) => e.registerFunctionOverload(t, n);
2121
+ t("has(ast): bool", ir()), t("list.all(ast, ast): bool", rr({
2122
+ name: "all",
2123
+ transform({ ast: e, predicate: t, opts: n }) {
2124
+ return {
2125
+ init: e.clone(W.value, !0),
2126
+ condition: $n,
2127
+ step: t.clone(W.ternary, [
2128
+ t,
2129
+ t.clone(W.value, !0),
2130
+ t.clone(W.value, !1)
2131
+ ])
2132
+ };
2133
+ }
2134
+ })), t("list.exists(ast, ast): bool", rr({
2135
+ name: "exists",
2136
+ condition(e) {
2137
+ return !e;
2138
+ },
2139
+ transform({ ast: e, predicate: t, opts: n }) {
2140
+ return {
2141
+ init: e.clone(W.value, !1),
2142
+ condition: n.condition,
2143
+ step: t.clone(W.ternary, [
2144
+ t,
2145
+ t.clone(W.value, !0),
2146
+ t.clone(W.value, !1)
2147
+ ])
2148
+ };
2149
+ }
2150
+ })), t("list.exists_one(ast, ast): bool", rr({
2151
+ name: "exists_one",
2152
+ errorsAreFatal: !0,
2153
+ result(e) {
2154
+ return e === 1;
2155
+ },
2156
+ transform({ ast: e, predicate: t, opts: n }) {
2157
+ let r = e.clone(W.accuValue);
2158
+ return {
2159
+ init: e.clone(W.value, 0),
2160
+ step: t.clone(W.ternary, [
2161
+ t,
2162
+ e.clone(W.accuInc),
2163
+ r
2164
+ ]),
2165
+ result: n.result
2166
+ };
2167
+ }
2168
+ })), t("list.map(ast, ast): list<dyn>", tr(!1)), t("list.map(ast, ast, ast): list<dyn>", tr(!0)), t("list.filter(ast, ast): list<dyn>", nr());
2169
+ class n {}
2170
+ let r = new n();
2171
+ e.registerType("CelNamespace", n), e.registerConstant("cel", "CelNamespace", r);
2172
+ function i(e, t, n) {
2173
+ t.bindCtx = n.forkWithVariable(t.var, e.check(t.val, n));
2174
+ let r = e.check(t.exp, t.bindCtx);
2175
+ return t.val.maybeAsync || t.exp.maybeAsync || (t.ast.setMeta("async", !1), t.evaluate = s), r;
2176
+ }
2177
+ function a(e, t, n, r, i) {
2178
+ let a = e.run(t, r = n.reuse(r).setIterValue(i, e));
2179
+ return a instanceof Promise && r === n && (r.async = !0), a;
2180
+ }
2181
+ function o(e, { val: t, exp: n, bindCtx: r }, i) {
2182
+ let o = e.run(t, i);
2183
+ return o instanceof Promise ? o.then((t) => a(e, n, r, i, t)) : a(e, n, r, i, o);
2184
+ }
2185
+ function s(e, { val: t, exp: n, bindCtx: r }, i) {
2186
+ return e.run(n, r.reuse(i).setIterValue(e.run(t, i), e));
2187
+ }
2188
+ t("CelNamespace.bind(ast, dyn, ast): dyn", ({ ast: e, args: t }) => ({
2189
+ ast: e,
2190
+ var: er(t[0], "invalid variable argument"),
2191
+ val: t[1],
2192
+ exp: t[2],
2193
+ bindCtx: void 0,
2194
+ typeCheck: i,
2195
+ evaluate: o
2196
+ }));
2197
+ }
2198
+ // ../../node_modules/.pnpm/@marcbachmann+cel-js@8.0.0/node_modules/@marcbachmann/cel-js/lib/overloads.js
2199
+ function or(e) {
2200
+ let t = (t, n, r, i) => e.unaryOverload(t, n, r, i, !1), n = (t, n, r, i, a) => e.binaryOverload(t, n, r, i, a, !1);
2201
+ function r(e, t) {
2202
+ if (e <= 9223372036854775807n && e >= -9223372036854775808n) return e;
2203
+ throw h("numeric_overflow", `integer overflow: ${e}`, t);
2204
+ }
2205
+ function i(e) {
2206
+ throw h("division_by_zero", "division by zero", e);
2207
+ }
2208
+ function a(e) {
2209
+ throw h("modulo_by_zero", "modulo by zero", e);
2210
+ }
2211
+ t("!", "bool", (e) => !e), t("-", "int", (e) => -e), n("dyn<int>", "==", "double", (e, t) => e == t), n("dyn<int>", "==", "uint", (e, t) => e == t.valueOf()), n("int", "*", "int", (e, t, n) => r(e * t, n)), n("int", "+", "int", (e, t, n) => r(e + t, n)), n("int", "-", "int", (e, t, n) => r(e - t, n)), n("int", "/", "int", (e, t, n) => t === 0n ? i(n) : e / t), n("int", "%", "int", (e, t, n) => t === 0n ? a(n) : e % t), t("-", "double", (e) => -e), n("double", "*", "double", (e, t) => e * t), n("double", "+", "double", (e, t) => e + t), n("double", "-", "double", (e, t) => e - t), n("double", "/", "double", (e, t) => e / t), n("string", "+", "string", (e, t) => e + t), n("list<V>", "+", "list<V>", (e, t) => [...e, ...t]), n("bytes", "+", "bytes", (e, t) => {
2212
+ if (!e.length) return t;
2213
+ if (!t.length) return e;
2214
+ let n = new Uint8Array(e.length + t.length);
2215
+ return n.set(e, 0), n.set(t, e.length), n;
2216
+ });
2217
+ let o = "google.protobuf.Duration";
2218
+ n(o, "+", o, (e, t) => e.addDuration(t)), n(o, "-", o, (e, t) => e.subtractDuration(t)), n(o, "==", o, (e, t) => e.seconds === t.seconds && e.nanos === t.nanos);
2219
+ let s = "google.protobuf.Timestamp";
2220
+ n(s, "==", s, (e, t) => e.getTime() === t.getTime()), n(s, "-", s, (e, t) => Ae.fromMilliseconds(e.getTime() - t.getTime()), o), n(s, "-", o, (e, t) => t.subtractTimestamp(e)), n(s, "+", o, (e, t) => t.extendTimestamp(e)), n(o, "+", s, (e, t) => e.extendTimestamp(t));
2221
+ function c(e, t, n, r) {
2222
+ if (t instanceof Set && t.has(e)) return !0;
2223
+ for (let i of t) if (sr(e, i, n, r)) return !0;
2224
+ return !1;
2225
+ }
2226
+ function l(e, t) {
2227
+ return t instanceof Map ? t.get(e) !== void 0 : _e(t, e) ? t[e] !== void 0 : !1;
2228
+ }
2229
+ function u(e, t, n, r) {
2230
+ return c(e, t, n, r);
2231
+ }
2232
+ n("V", "in", "list<V>", u), n("K", "in", "map<K, V>", l);
2233
+ for (let e of [
2234
+ "type",
2235
+ "null",
2236
+ "bool",
2237
+ "string",
2238
+ "int",
2239
+ "double"
2240
+ ]) n(e, "==", e, (e, t) => e === t);
2241
+ n("bytes", "==", "bytes", (e, t) => {
2242
+ if (e === t) return !0;
2243
+ let n = e.length;
2244
+ if (n !== t.length) return !1;
2245
+ for (; n--;) if (e[n] !== t[n]) return !1;
2246
+ return !0;
2247
+ }), n("list<V>", "==", "list<V>", (e, t, n, r) => {
2248
+ if (e === t) return !0;
2249
+ if (ye(e) && ye(t)) {
2250
+ let i = e.length;
2251
+ if (i !== t.length) return !1;
2252
+ for (let a = 0; a < i; a++) if (!sr(e[a], t[a], n, r)) return !1;
2253
+ return !0;
2254
+ }
2255
+ if (e instanceof Set && t instanceof Set) {
2256
+ if (e.size !== t.size) return !1;
2257
+ for (let n of e) if (!t.has(n)) return !1;
2258
+ return !0;
2259
+ }
2260
+ let i = e instanceof Set ? t : e, a = e instanceof Set ? e : t;
2261
+ if (!ye(i) || i.length !== (a == null ? void 0 : a.size)) return !1;
2262
+ for (let e = 0; e < i.length; e++) if (!a.has(i[e])) return !1;
2263
+ return !0;
2264
+ }), n("map<K, V>", "==", "map<K, V>", (e, t, n, r) => {
2265
+ if (e === t) return !0;
2266
+ if (e instanceof Map && t instanceof Map) {
2267
+ if (e.size !== t.size) return !1;
2268
+ for (let [i, a] of e) if (!(t.has(i) && sr(a, t.get(i), n, r))) return !1;
2269
+ return !0;
2270
+ }
2271
+ if (e instanceof Map || t instanceof Map) {
2272
+ let i = e instanceof Map ? t : e, a = e instanceof Map ? e : t, o = v(i);
2273
+ if (a.size !== o.length) return !1;
2274
+ for (let [e, t] of a) if (!(e in i && sr(t, i[e], n, r))) return !1;
2275
+ return !0;
2276
+ }
2277
+ let i = v(e), a = v(t);
2278
+ if (i.length !== a.length) return !1;
2279
+ for (let a = 0; a < i.length; a++) {
2280
+ let o = i[a];
2281
+ if (!(o in t && sr(e[o], t[o], n, r))) return !1;
2282
+ }
2283
+ return !0;
2284
+ }), n("uint", "==", "uint", (e, t) => e.valueOf() === t.valueOf()), n("dyn<uint>", "==", "double", (e, t) => e.valueOf() == t), n("uint", "+", "uint", (e, t) => new x(e.valueOf() + t.valueOf())), n("uint", "-", "uint", (e, t) => new x(e.valueOf() - t.valueOf())), n("uint", "*", "uint", (e, t) => new x(e.valueOf() * t.valueOf())), n("uint", "/", "uint", (e, t, n) => t.valueOf() === 0n ? i(n) : new x(e.valueOf() / t.valueOf())), n("uint", "%", "uint", (e, t, n) => t.valueOf() === 0n ? a(n) : new x(e.valueOf() % t.valueOf()));
2285
+ for (let [e, t] of [
2286
+ ["bool", "bool"],
2287
+ ["int", "int"],
2288
+ ["uint", "uint"],
2289
+ ["double", "double"],
2290
+ ["string", "string"],
2291
+ ["google.protobuf.Timestamp", "google.protobuf.Timestamp"],
2292
+ ["google.protobuf.Duration", "google.protobuf.Duration"],
2293
+ ["int", "uint"],
2294
+ ["int", "double"],
2295
+ ["double", "int"],
2296
+ ["double", "uint"],
2297
+ ["uint", "int"],
2298
+ ["uint", "double"]
2299
+ ]) n(e, "<", t, (e, t) => e < t), n(e, "<=", t, (e, t) => e <= t), n(e, ">", t, (e, t) => e > t), n(e, ">=", t, (e, t) => e >= t);
2300
+ }
2301
+ function sr(e, t, n, r) {
2302
+ if (e === t) return !0;
2303
+ switch (typeof e) {
2304
+ case "undefined":
2305
+ case "string":
2306
+ case "boolean": return !1;
2307
+ case "bigint": return typeof t == "number" && e == t;
2308
+ case "number": return typeof t == "bigint" && e == t;
2309
+ case "object":
2310
+ if (typeof t != "object") return !1;
2311
+ let i = r.debugType(e), a = r.debugType(t);
2312
+ if (i !== a) return !1;
2313
+ let o = r.registry.findBinaryOverload("==", i, a);
2314
+ return o ? o.handler(e, t, n, r) : !1;
2315
+ }
2316
+ throw h("invalid_comparison_type", `Cannot compare values of type ${typeof e}`, n);
2317
+ }
2318
+ // ../../node_modules/.pnpm/@marcbachmann+cel-js@8.0.0/node_modules/@marcbachmann/cel-js/lib/type-checker.js
2319
+ var cr = (/* @__PURE__ */ new Map()).set("A", "dyn").set("T", "dyn").set("K", "dyn").set("V", "dyn"), lr = class extends cn {
2320
+ constructor(e, t) {
2321
+ super(e), this.createError = t ? h : oe;
2322
+ }
2323
+ check(e, t) {
2324
+ try {
2325
+ var n;
2326
+ return (n = e.checkedType) == null ? e.checkedType = e.check(this, e, t) : n;
2327
+ } catch (t) {
2328
+ throw le(t, e);
2329
+ }
2330
+ }
2331
+ checkAccessOnType(e, t, n, r = !1) {
2332
+ if (n === this.dynType) return n;
2333
+ let i = (e.op === "[]" || e.op === "[?]" ? this.check(e.args[1], t) : this.stringType).type;
2334
+ if (n.kind === "list") {
2335
+ if (i === "int" || i === "dyn") return n.valueType;
2336
+ throw this.createError("invalid_index_type", `List index must be int, got '${i}'`, e);
2337
+ }
2338
+ if (n.kind === "map") return n.valueType;
2339
+ let a = this.objectTypes.get(n.name);
2340
+ if (a) {
2341
+ if (i !== "string" && i !== "dyn") throw this.createError("invalid_index_type", `Cannot index type '${n.name}' with type '${i}'`, e);
2342
+ if (a.fields) {
2343
+ let t;
2344
+ if (e.op === "." || e.op === ".?" ? t = e.args[1] : e.args[1].op === "value" && (t = e.args[1].args), typeof t == "string") {
2345
+ let n = a.fields[t];
2346
+ if (n) return n;
2347
+ if (r) return this.dynType;
2348
+ throw this.createError("no_such_key", `No such key: ${t}`, e);
2349
+ }
2350
+ }
2351
+ return this.dynType;
2352
+ }
2353
+ throw this.createError("cannot_index_type", `Cannot index type '${this.formatType(n)}'`, e);
2354
+ }
2355
+ formatType(e) {
2356
+ return e.hasPlaceholderType ? e.templated(this.registry, cr).name : e.name;
2357
+ }
2358
+ formatTypeList(e) {
2359
+ return e.map((e) => this.formatType(e)).join(", ");
2360
+ }
2361
+ };
2362
+ // ../../node_modules/.pnpm/@marcbachmann+cel-js@8.0.0/node_modules/@marcbachmann/cel-js/lib/parser.js
2363
+ u();
2364
+ var G = {
2365
+ EOF: 0,
2366
+ NUMBER: 1,
2367
+ STRING: 2,
2368
+ BOOLEAN: 3,
2369
+ NULL: 4,
2370
+ IDENTIFIER: 5,
2371
+ PLUS: 6,
2372
+ MINUS: 7,
2373
+ MULTIPLY: 8,
2374
+ DIVIDE: 9,
2375
+ MODULO: 10,
2376
+ EQ: 11,
2377
+ NE: 12,
2378
+ LT: 13,
2379
+ LE: 14,
2380
+ GT: 15,
2381
+ GE: 16,
2382
+ AND: 17,
2383
+ OR: 18,
2384
+ NOT: 19,
2385
+ IN: 20,
2386
+ LPAREN: 21,
2387
+ RPAREN: 22,
2388
+ LBRACKET: 23,
2389
+ RBRACKET: 24,
2390
+ LBRACE: 25,
2391
+ RBRACE: 26,
2392
+ DOT: 27,
2393
+ COMMA: 28,
2394
+ COLON: 29,
2395
+ QUESTION: 30,
2396
+ BYTES: 31
2397
+ }, ur = {
2398
+ [G.EQ]: W["=="],
2399
+ [G.PLUS]: W["+"],
2400
+ [G.MINUS]: W["-"],
2401
+ [G.MULTIPLY]: W["*"],
2402
+ [G.DIVIDE]: W["/"],
2403
+ [G.MODULO]: W["%"],
2404
+ [G.LE]: W["<="],
2405
+ [G.LT]: W["<"],
2406
+ [G.GE]: W[">="],
2407
+ [G.GT]: W[">"],
2408
+ [G.NE]: W["!="],
2409
+ [G.IN]: W.in
2410
+ }, dr = {};
2411
+ for (let e in G) dr[G[e]] = e;
2412
+ var fr = /* @__PURE__ */ new Uint8Array(128);
2413
+ for (let e of "0123456789abcdefABCDEF") fr[e.charCodeAt(0)] = 1;
2414
+ var pr = {
2415
+ bytes_unicode_escape: (e) => `\\${e} not allowed in bytes literals`,
2416
+ invalid_unicode_escape: (e) => `Invalid Unicode escape: \\${e}`,
2417
+ invalid_unicode_surrogate: (e) => `Invalid Unicode surrogate: \\${e}`,
2418
+ invalid_hex_escape: (e) => `Invalid hex escape: \\${e}`,
2419
+ invalid_octal_escape: () => "Octal escape must be 3 digits",
2420
+ octal_escape_out_of_range: (e) => `Octal escape out of range: \\${e}`,
2421
+ invalid_escape_sequence: (e) => `Invalid escape sequence: \\${e}`
2422
+ }, mr = {
2423
+ "\\": "\\",
2424
+ "?": "?",
2425
+ "\"": "\"",
2426
+ "'": "'",
2427
+ "`": "`",
2428
+ a: "\x07",
2429
+ b: "\b",
2430
+ f: "\f",
2431
+ n: "\n",
2432
+ r: "\r",
2433
+ t: " ",
2434
+ v: "\v"
2435
+ }, K = /* @__PURE__ */ new WeakMap(), hr = /* @__PURE__ */ new WeakMap(), gr = /* @__PURE__ */ new WeakSet(), _r = class e {
2436
+ constructor(e, r, i, a, o, s) {
2437
+ w(this, gr), t(this, K, void 0), t(this, hr, void 0), n(K, this, {
2438
+ check: o.check,
2439
+ evaluate: o.evaluate
2440
+ }), n(hr, this, e), this.op = o.name, this.args = s, this.pos = r, this.start = i, this.end = a;
2441
+ }
2442
+ clone(t, n) {
2443
+ return new e(i(hr, this), this.pos, this.start, this.end, t, n);
2444
+ }
2445
+ get meta() {
2446
+ return i(K, this);
2447
+ }
2448
+ get input() {
2449
+ return i(hr, this);
2450
+ }
2451
+ get maybeAsync() {
2452
+ var e, t;
2453
+ return (t = (e = i(K, this)).async) == null ? e.async = r(gr, this, vr).call(this) : t;
2454
+ }
2455
+ check(e, t, n) {
2456
+ let r = i(K, this);
2457
+ return r.alternate ? e.check(r.alternate, n) : r.macro ? r.macro.typeCheck(e, r.macro, n) : r.check(e, t, n);
2458
+ }
2459
+ evaluate(e, t, n) {
2460
+ let a = i(K, this);
2461
+ return this.evaluate = a.alternate ? r(gr, this, yr) : a.macro ? r(gr, this, br) : a.evaluate, this.evaluate(e, t, n);
2462
+ }
2463
+ setMeta(e, t) {
2464
+ return i(K, this)[e] = t, this;
2465
+ }
2466
+ get range() {
2467
+ return {
2468
+ start: this.start,
2469
+ end: this.end
2470
+ };
2471
+ }
2472
+ toOldStructure() {
2473
+ let t = Array.isArray(this.args) ? this.args : [this.args];
2474
+ return [this.op, ...t.map((t) => t instanceof e ? t.toOldStructure() : t)];
2475
+ }
2476
+ };
2477
+ function vr() {
2478
+ var e;
2479
+ let t = (e = i(K, this).alternate) == null ? this : e;
2480
+ switch (t.op) {
2481
+ case "value":
2482
+ case "id":
2483
+ case "accuValue":
2484
+ case "accuInc": return !1;
2485
+ case "accuPush": return t.args.maybeAsync;
2486
+ case "!_":
2487
+ case "-_":
2488
+ var n;
2489
+ return ((n = t.candidates) == null ? void 0 : n.async) !== !1 || t.args.maybeAsync;
2490
+ case "!=":
2491
+ case "==":
2492
+ case "in":
2493
+ case "+":
2494
+ case "-":
2495
+ case "*":
2496
+ case "/":
2497
+ case "%":
2498
+ case "<":
2499
+ case "<=":
2500
+ case ">":
2501
+ case ">=":
2502
+ var r;
2503
+ return ((r = t.candidates) == null ? void 0 : r.async) !== !1 || t.args.some((e) => e.maybeAsync);
2504
+ case "call":
2505
+ case "rcall":
2506
+ var a;
2507
+ return ((a = t.candidates) == null ? void 0 : a.async) !== !1 || (t.receiverWithArgs || t.args[1]).some((e) => e.maybeAsync);
2508
+ case "comprehension": return t.args.iterable.maybeAsync || t.args.step.maybeAsync;
2509
+ case ".":
2510
+ case ".?": return t.args[0].maybeAsync;
2511
+ case "?:":
2512
+ case "list":
2513
+ case "[]":
2514
+ case "[?]": return t.args.some((e) => e.maybeAsync);
2515
+ case "||":
2516
+ case "&&": return t.args.some((e) => e.maybeAsync);
2517
+ case "map": return t.args.some((e) => e[0].maybeAsync || e[1].maybeAsync);
2518
+ default: return !0;
2519
+ }
2520
+ }
2521
+ function yr(e, t, n) {
2522
+ return (t = i(K, this).alternate).evaluate(e, t, n);
2523
+ }
2524
+ function br(e, t, n) {
2525
+ return (t = i(K, this).macro).evaluate(e, t, n);
2526
+ }
2527
+ var q = /* @__PURE__ */ new WeakSet(), xr = class {
2528
+ constructor() {
2529
+ w(this, q), c(this, "input", void 0), c(this, "pos", void 0), c(this, "length", void 0), c(this, "tokenPos", void 0), c(this, "tokenType", void 0), c(this, "tokenValue", void 0);
2530
+ }
2531
+ reset(e) {
2532
+ return this.pos = 0, this.input = e, this.length = e.length, e;
2533
+ }
2534
+ token(e, t, n) {
2535
+ return this.tokenPos = e, this.tokenType = t, this.tokenValue = n, this;
2536
+ }
2537
+ nextToken() {
2538
+ for (;;) {
2539
+ let { pos: e, input: t, length: n } = this;
2540
+ if (e >= n) return this.token(e, G.EOF);
2541
+ let r = t[e];
2542
+ switch (r) {
2543
+ case " ":
2544
+ case " ":
2545
+ case "\n":
2546
+ case "\r":
2547
+ this.pos++;
2548
+ continue;
2549
+ case "=":
2550
+ if (t[e + 1] !== "=") break;
2551
+ return this.token((this.pos += 2) - 2, G.EQ);
2552
+ case "&":
2553
+ if (t[e + 1] !== "&") break;
2554
+ return this.token((this.pos += 2) - 2, G.AND);
2555
+ case "|":
2556
+ if (t[e + 1] !== "|") break;
2557
+ return this.token((this.pos += 2) - 2, G.OR);
2558
+ case "+": return this.token(this.pos++, G.PLUS);
2559
+ case "-": return this.token(this.pos++, G.MINUS);
2560
+ case "*": return this.token(this.pos++, G.MULTIPLY);
2561
+ case "/":
2562
+ if (t[e + 1] === "/") {
2563
+ for (; this.pos < n && this.input[this.pos] !== "\n";) this.pos++;
2564
+ continue;
2565
+ }
2566
+ return this.token(this.pos++, G.DIVIDE);
2567
+ case "%": return this.token(this.pos++, G.MODULO);
2568
+ case "<": return t[e + 1] === "=" ? this.token((this.pos += 2) - 2, G.LE) : this.token(this.pos++, G.LT);
2569
+ case ">": return t[e + 1] === "=" ? this.token((this.pos += 2) - 2, G.GE) : this.token(this.pos++, G.GT);
2570
+ case "!": return t[e + 1] === "=" ? this.token((this.pos += 2) - 2, G.NE) : this.token(this.pos++, G.NOT);
2571
+ case "(": return this.token(this.pos++, G.LPAREN);
2572
+ case ")": return this.token(this.pos++, G.RPAREN);
2573
+ case "[": return this.token(this.pos++, G.LBRACKET);
2574
+ case "]": return this.token(this.pos++, G.RBRACKET);
2575
+ case "{": return this.token(this.pos++, G.LBRACE);
2576
+ case "}": return this.token(this.pos++, G.RBRACE);
2577
+ case ".": return this.token(this.pos++, G.DOT);
2578
+ case ",": return this.token(this.pos++, G.COMMA);
2579
+ case ":": return this.token(this.pos++, G.COLON);
2580
+ case "?": return this.token(this.pos++, G.QUESTION);
2581
+ case "\"":
2582
+ case "'": return this.readString(r);
2583
+ case "b":
2584
+ case "B":
2585
+ case "r":
2586
+ case "R": {
2587
+ let n = t[e + 1];
2588
+ return n === "\"" || n === "'" ? ++this.pos && this.readString(n, r) : this.readIdentifier();
2589
+ }
2590
+ default: {
2591
+ let e = r.charCodeAt(0);
2592
+ if (e <= 57 && e >= 48) return this.readNumber();
2593
+ if (this._isIdentifierCharCode(e)) return this.readIdentifier();
2594
+ }
2595
+ }
2596
+ throw m("unexpected_character", `Unexpected character: ${r}`, {
2597
+ pos: e,
2598
+ start: e,
2599
+ end: e + 1,
2600
+ input: t
2601
+ });
2602
+ }
2603
+ }
2604
+ _isIdentifierCharCode(e) {
2605
+ return e < 48 || e > 122 ? !1 : e >= 97 || e >= 65 && e <= 90 || e <= 57 || e === 95;
2606
+ }
2607
+ _parseAsDouble(e, t) {
2608
+ let n = Number(this.input.substring(e, t));
2609
+ if (Number.isFinite(n)) return this.token(e, G.NUMBER, n);
2610
+ throw m("invalid_number", `Invalid number: ${n}`, {
2611
+ pos: e,
2612
+ start: e,
2613
+ end: t,
2614
+ input: this.input
2615
+ });
2616
+ }
2617
+ _parseAsBigInt(e, t, n, r) {
2618
+ let i = this.input.substring(e, t);
2619
+ if (r === "u" || r === "U") {
2620
+ this.pos++;
2621
+ try {
2622
+ return this.token(e, G.NUMBER, new x(i));
2623
+ } catch (e) {}
2624
+ } else try {
2625
+ return this.token(e, G.NUMBER, BigInt(i));
2626
+ } catch (e) {}
2627
+ throw m(n ? "invalid_hex_integer" : "invalid_integer", n ? `Invalid hex integer: ${i}` : `Invalid integer: ${i}`, {
2628
+ pos: e,
2629
+ start: e,
2630
+ end: this.pos,
2631
+ input: this.input
2632
+ });
2633
+ }
2634
+ _readDigits(e, t, n, r) {
2635
+ for (; n < t && (r = e.charCodeAt(n)) && !(r > 57 || r < 48);) n++;
2636
+ return n;
2637
+ }
2638
+ _readExponent(e, t, n) {
2639
+ let r = n < t && e[n];
2640
+ if (r === "e" || r === "E") {
2641
+ r = ++n < t && e[n], (r === "-" || r === "+") && n++;
2642
+ let i = n;
2643
+ if (n = this._readDigits(e, t, n), i === n) throw m("invalid_exponent", "Invalid exponent", {
2644
+ pos: n,
2645
+ start: n,
2646
+ end: Math.min(n + 1, e.length),
2647
+ input: e
2648
+ });
2649
+ }
2650
+ return n;
2651
+ }
2652
+ readNumber() {
2653
+ let { input: e, length: t, pos: n } = this, r = n;
2654
+ if (e[r] === "0" && (e[r + 1] === "x" || e[r + 1] === "X")) {
2655
+ for (r += 2; r < t && fr[e[r].charCodeAt(0)];) r++;
2656
+ return this._parseAsBigInt(n, this.pos = r, !0, e[r]);
2657
+ }
2658
+ if (r = this._readDigits(e, t, r), r + 1 < t) {
2659
+ let i = !1, a = e[r] === "." ? this._readDigits(e, t, r + 1) : r + 1;
2660
+ if (a !== r + 1 && (i = !0) && (r = a), a = this._readExponent(e, t, r), a !== r && (i = !0) && (r = a), i) return this._parseAsDouble(n, this.pos = r);
2661
+ }
2662
+ return this._parseAsBigInt(n, this.pos = r, !1, e[r]);
2663
+ }
2664
+ readString(e, t) {
2665
+ let { input: n, pos: r } = this;
2666
+ return n[r + 1] === e && n[r + 2] === e ? this.readTripleQuotedString(e, t) : this.readSingleQuotedString(e, t);
2667
+ }
2668
+ _closeQuotedString(e, t, n, r) {
2669
+ switch (n) {
2670
+ case "b":
2671
+ case "B": {
2672
+ let n = this.processEscapes(e, t, !0), i = new Uint8Array(n.length);
2673
+ for (let e = 0; e < n.length; e++) i[e] = n.charCodeAt(e) & 255;
2674
+ return this.token(r - 1, G.BYTES, i);
2675
+ }
2676
+ case "r":
2677
+ case "R": return this.token(r - 1, G.STRING, t);
2678
+ default: {
2679
+ let n = this.processEscapes(e, t, !1);
2680
+ return this.token(r, G.STRING, n);
2681
+ }
2682
+ }
2683
+ }
2684
+ readSingleQuotedString(e, t) {
2685
+ let { input: n, length: r, pos: i } = this, a, o = this.pos + 1;
2686
+ for (; o < r && (a = n[o]);) {
2687
+ switch (a) {
2688
+ case e:
2689
+ let r = i + 1, a = n.slice(r, o);
2690
+ return this.pos = ++o, this._closeQuotedString(r, a, t, i);
2691
+ case "\n":
2692
+ case "\r": throw m("newline_in_string", "Newlines not allowed in single-quoted strings", {
2693
+ pos: o,
2694
+ start: o,
2695
+ end: o + 1,
2696
+ input: n
2697
+ });
2698
+ case "\\": o++;
2699
+ }
2700
+ o++;
2701
+ }
2702
+ throw m("unterminated_string", "Unterminated string", {
2703
+ pos: i,
2704
+ start: i,
2705
+ end: n.length,
2706
+ input: n
2707
+ });
2708
+ }
2709
+ readTripleQuotedString(e, t) {
2710
+ let { input: n, length: r, pos: i } = this, a, o = this.pos + 3;
2711
+ for (; o < r && (a = n[o]);) {
2712
+ switch (a) {
2713
+ case e:
2714
+ if (n[o + 1] === e && n[o + 2] === e) {
2715
+ let e = i + 3, r = n.slice(e, o);
2716
+ return this.pos = o + 3, this._closeQuotedString(e, r, t, i);
2717
+ }
2718
+ break;
2719
+ case "\\": o++;
2720
+ }
2721
+ o++;
2722
+ }
2723
+ throw m("unterminated_triple_quoted_string", "Unterminated triple-quoted string", {
2724
+ pos: i,
2725
+ start: i,
2726
+ end: n.length,
2727
+ input: n
2728
+ });
2729
+ }
2730
+ processEscapes(e, t, n) {
2731
+ if (!t.includes("\\")) return t;
2732
+ let i = t.length, a = "", o = 0;
2733
+ for (; o < i;) {
2734
+ if (t[o] !== "\\" || o + 1 >= i) {
2735
+ a += t[o++];
2736
+ continue;
2737
+ }
2738
+ let s = t[o + 1];
2739
+ if (mr[s]) a += mr[s], o += 2;
2740
+ else if (s === "u" || s === "U") {
2741
+ if (n) throw r(q, this, J).call(this, "bytes_unicode_escape", e, i, o, 2, s);
2742
+ let c = s === "u" ? 4 : 8, l = t.substring(o + 2, o + 2 + c), u = Number.parseInt(l, 16);
2743
+ if (l.length !== c || !/^[0-9a-fA-F]+$/.test(l) || u > 1114111) throw r(q, this, J).call(this, "invalid_unicode_escape", e, i, o, 2 + c, s + l);
2744
+ if (u >= 55296 && u <= 57343) throw r(q, this, J).call(this, "invalid_unicode_surrogate", e, i, o, 2 + c, s + l);
2745
+ a += String.fromCodePoint(u), o += 2 + c;
2746
+ } else if (s === "x" || s === "X") {
2747
+ let n = t.substring(o + 2, o + 4);
2748
+ if (!/^[0-9a-fA-F]{2}$/.test(n)) throw r(q, this, J).call(this, "invalid_hex_escape", e, i, o, 4, s + n);
2749
+ a += String.fromCharCode(Number.parseInt(n, 16)), o += 4;
2750
+ } else if (s >= "0" && s <= "7") {
2751
+ let n = t.substring(o + 1, o + 4);
2752
+ if (!/^[0-7]{3}$/.test(n)) throw r(q, this, J).call(this, "invalid_octal_escape", e, i, o, 4);
2753
+ let s = Number.parseInt(n, 8);
2754
+ if (s > 255) throw r(q, this, J).call(this, "octal_escape_out_of_range", e, i, o, 4, n);
2755
+ a += String.fromCharCode(s), o += 4;
2756
+ } else throw r(q, this, J).call(this, "invalid_escape_sequence", e, i, o, 2, s);
2757
+ }
2758
+ return a;
2759
+ }
2760
+ readIdentifier() {
2761
+ let { pos: e, input: t, length: n } = this, r = e;
2762
+ for (; r < n && this._isIdentifierCharCode(t[r].charCodeAt(0));) r++;
2763
+ let i = t.substring(e, this.pos = r);
2764
+ switch (i) {
2765
+ case "true": return this.token(e, G.BOOLEAN, !0);
2766
+ case "false": return this.token(e, G.BOOLEAN, !1);
2767
+ case "null": return this.token(e, G.NULL, null);
2768
+ case "in": return this.token(e, G.IN);
2769
+ default: return this.token(e, G.IDENTIFIER, i);
2770
+ }
2771
+ }
2772
+ };
2773
+ function J(e, t, n, r, i, a) {
2774
+ let o = t + r;
2775
+ return m(e, pr[e](a), {
2776
+ input: this.input,
2777
+ pos: o,
2778
+ start: o,
2779
+ end: Math.min(o + i, t + n)
2780
+ });
2781
+ }
2782
+ var Sr = new xr(), Y = /* @__PURE__ */ new WeakSet(), Cr = class {
2783
+ constructor(e, t) {
2784
+ w(this, Y), c(this, "lexer", Sr), c(this, "input", null), c(this, "maxDepthRemaining", null), c(this, "astNodesRemaining", null), c(this, "type", null), c(this, "pos", null), this.limits = e, this.registry = t;
2785
+ }
2786
+ get value() {
2787
+ return this.lexer.tokenValue;
2788
+ }
2789
+ consume(e) {
2790
+ if (this.type === e) return r(Y, this, Q).call(this);
2791
+ throw m("expected_token", `Expected ${dr[e]}, got ${dr[this.type]}`, {
2792
+ pos: this.pos,
2793
+ start: this.pos,
2794
+ end: this.lexer.pos,
2795
+ input: this.input
2796
+ });
2797
+ }
2798
+ match(e) {
2799
+ return this.type === e;
2800
+ }
2801
+ parse(e) {
2802
+ if (typeof e != "string") throw m("expression_must_be_string", "Expression must be a string");
2803
+ this.input = this.lexer.reset(e), r(Y, this, Q).call(this), this.maxDepthRemaining = this.limits.maxDepth, this.astNodesRemaining = this.limits.maxAstNodes;
2804
+ let t = this.parseExpression();
2805
+ if (this.match(G.EOF)) return t;
2806
+ throw m("unexpected_character", `Unexpected character: '${this.input[this.lexer.pos - 1]}'`, {
2807
+ pos: this.pos,
2808
+ start: this.pos,
2809
+ end: this.lexer.pos,
2810
+ input: this.input
2811
+ });
2812
+ }
2813
+ parseExpression() {
2814
+ this.maxDepthRemaining-- || r(Y, this, X).call(this, "maxDepth");
2815
+ let e = this.parseLogicalOr();
2816
+ if (!this.match(G.QUESTION)) return ++this.maxDepthRemaining && e;
2817
+ r(Y, this, Q).call(this);
2818
+ let t = this.parseExpression();
2819
+ this.consume(G.COLON);
2820
+ let n = this.parseExpression();
2821
+ return this.maxDepthRemaining++, r(Y, this, Tr).call(this, e, t, n);
2822
+ }
2823
+ parseLogicalOr() {
2824
+ let e = this.parseLogicalAnd();
2825
+ for (; this.match(G.OR);) r(Y, this, Q).call(this), e = r(Y, this, wr).call(this, W["||"], e, this.parseLogicalAnd());
2826
+ return e;
2827
+ }
2828
+ parseLogicalAnd() {
2829
+ let e = this.parseEquality();
2830
+ for (; this.match(G.AND);) r(Y, this, Q).call(this), e = r(Y, this, wr).call(this, W["&&"], e, this.parseEquality());
2831
+ return e;
2832
+ }
2833
+ parseEquality() {
2834
+ let e = this.parseRelational();
2835
+ for (; this.match(G.EQ) || this.match(G.NE);) {
2836
+ let t = ur[this.type];
2837
+ r(Y, this, Q).call(this), e = r(Y, this, wr).call(this, t, e, this.parseRelational());
2838
+ }
2839
+ return e;
2840
+ }
2841
+ parseRelational() {
2842
+ let e = this.parseAdditive();
2843
+ for (; this.match(G.LT) || this.match(G.LE) || this.match(G.GT) || this.match(G.GE) || this.match(G.IN);) {
2844
+ let t = ur[this.type];
2845
+ r(Y, this, Q).call(this), e = r(Y, this, wr).call(this, t, e, this.parseAdditive());
2846
+ }
2847
+ return e;
2848
+ }
2849
+ parseAdditive() {
2850
+ let e = this.parseMultiplicative();
2851
+ for (; this.match(G.PLUS) || this.match(G.MINUS);) {
2852
+ let t = ur[this.type];
2853
+ r(Y, this, Q).call(this), e = r(Y, this, wr).call(this, t, e, this.parseMultiplicative());
2854
+ }
2855
+ return e;
2856
+ }
2857
+ parseMultiplicative() {
2858
+ let e = this.parseUnary();
2859
+ for (; this.match(G.MULTIPLY) || this.match(G.DIVIDE) || this.match(G.MODULO);) {
2860
+ let t = ur[this.type];
2861
+ r(Y, this, Q).call(this), e = r(Y, this, wr).call(this, t, e, this.parseUnary());
2862
+ }
2863
+ return e;
2864
+ }
2865
+ parseUnary() {
2866
+ return this.type === G.NOT ? r(Y, this, Er).call(this, r(Y, this, Q).call(this), W.unaryNot, this.parseUnary()) : this.type === G.MINUS ? r(Y, this, Er).call(this, r(Y, this, Q).call(this), W.unaryMinus, this.parseUnary()) : this.parsePostfix();
2867
+ }
2868
+ parsePostfix() {
2869
+ let e = this.parsePrimary(), t = this.maxDepthRemaining;
2870
+ for (;;) if (this.match(G.DOT)) {
2871
+ let t = r(Y, this, Q).call(this);
2872
+ this.maxDepthRemaining-- || r(Y, this, X).call(this, "maxDepth", t);
2873
+ let n = this.match(G.QUESTION) && this.registry.enableOptionalTypes && r(Y, this, Q).call(this) ? W.optionalFieldAccess : W.fieldAccess, i = this.value, a = this.pos, o = this.lexer.pos;
2874
+ if (this.consume(G.IDENTIFIER), n === W.fieldAccess && this.match(G.LPAREN) && r(Y, this, Q).call(this)) {
2875
+ let t = this.parseArgumentList(), n = this.lexer.pos;
2876
+ this.consume(G.RPAREN), e = r(Y, this, Or).call(this, e.start, n, W.rcall, [
2877
+ i,
2878
+ e,
2879
+ t
2880
+ ]);
2881
+ } else e = r(Y, this, Dr).call(this, n, e, i, o, a);
2882
+ } else if (this.match(G.LBRACKET)) {
2883
+ let t = r(Y, this, Q).call(this);
2884
+ this.maxDepthRemaining-- || r(Y, this, X).call(this, "maxDepth", t);
2885
+ let n = this.match(G.QUESTION) && this.registry.enableOptionalTypes && r(Y, this, Q).call(this) ? W.optionalBracketAccess : W.bracketAccess, i = this.parseExpression(), a = this.lexer.pos;
2886
+ this.consume(G.RBRACKET), e = r(Y, this, Dr).call(this, n, e, i, a);
2887
+ } else break;
2888
+ return this.maxDepthRemaining = t, e;
2889
+ }
2890
+ parsePrimary() {
2891
+ switch (this.type) {
2892
+ case G.NUMBER:
2893
+ case G.STRING:
2894
+ case G.BYTES:
2895
+ case G.BOOLEAN:
2896
+ case G.NULL: return r(Y, this, kr).call(this);
2897
+ case G.IDENTIFIER: return r(Y, this, Ar).call(this);
2898
+ case G.LPAREN: return r(Y, this, jr).call(this);
2899
+ case G.LBRACKET: return this.parseList();
2900
+ case G.LBRACE: return this.parseMap();
2901
+ }
2902
+ throw m("unexpected_token", `Unexpected token: ${dr[this.type]}`, {
2903
+ pos: this.pos,
2904
+ start: this.pos,
2905
+ end: this.lexer.pos,
2906
+ input: this.input
2907
+ });
2908
+ }
2909
+ parseList() {
2910
+ let e = this.consume(G.LBRACKET), t = [], n = this.limits.maxListElements;
2911
+ if (!this.match(G.RBRACKET)) for (t.push(this.parseExpression()), n-- || r(Y, this, X).call(this, "maxListElements", t.at(-1).pos); this.match(G.COMMA) && (r(Y, this, Q).call(this), !this.match(G.RBRACKET));) t.push(this.parseExpression()), n-- || r(Y, this, X).call(this, "maxListElements", t.at(-1).pos);
2912
+ let i = this.lexer.pos;
2913
+ return this.consume(G.RBRACKET), r(Y, this, Z).call(this, e, i, W.list, t);
2914
+ }
2915
+ parseMap() {
2916
+ let e = this.consume(G.LBRACE), t = [], n = this.limits.maxMapEntries;
2917
+ if (!this.match(G.RBRACE)) for (t.push(this.parseProperty()), n-- || r(Y, this, X).call(this, "maxMapEntries", t.at(-1)[0].pos); this.match(G.COMMA) && (r(Y, this, Q).call(this), !this.match(G.RBRACE));) t.push(this.parseProperty()), n-- || r(Y, this, X).call(this, "maxMapEntries", t.at(-1)[0].pos);
2918
+ let i = this.lexer.pos;
2919
+ return this.consume(G.RBRACE), r(Y, this, Z).call(this, e, i, W.map, t);
2920
+ }
2921
+ parseProperty() {
2922
+ return [this.parseExpression(), (this.consume(G.COLON), this.parseExpression())];
2923
+ }
2924
+ parseArgumentList() {
2925
+ let e = [], t = this.limits.maxCallArguments;
2926
+ if (!this.match(G.RPAREN)) for (e.push(this.parseExpression()), t-- || r(Y, this, X).call(this, "maxCallArguments", e.at(-1).pos); this.match(G.COMMA) && (r(Y, this, Q).call(this), !this.match(G.RPAREN));) e.push(this.parseExpression()), t-- || r(Y, this, X).call(this, "maxCallArguments", e.at(-1).pos);
2927
+ return e;
2928
+ }
2929
+ };
2930
+ function X(e, t = this.pos) {
2931
+ throw m("limit_exceeded", `Exceeded ${e} (${this.limits[e]})`, {
2932
+ pos: t,
2933
+ start: t,
2934
+ end: t,
2935
+ input: this.input
2936
+ });
2937
+ }
2938
+ function Z(e, t, n, i, a = e) {
2939
+ let o = new _r(this.input, a, e, t, n, i);
2940
+ return this.astNodesRemaining-- || r(Y, this, X).call(this, "maxAstNodes", a), o;
2941
+ }
2942
+ function wr(e, t, n) {
2943
+ return r(Y, this, Z).call(this, t.start, n.end, e, [t, n]);
2944
+ }
2945
+ function Tr(e, t, n) {
2946
+ return r(Y, this, Z).call(this, e.start, n.end, W.ternary, [
2947
+ e,
2948
+ t,
2949
+ n
2950
+ ]);
2951
+ }
2952
+ function Er(e, t, n) {
2953
+ return r(Y, this, Z).call(this, e, n.end, t, n);
2954
+ }
2955
+ function Dr(e, t, n, i, a = t.start) {
2956
+ return r(Y, this, Z).call(this, t.start, i, e, [t, n], a);
2957
+ }
2958
+ function Q(e = this.pos) {
2959
+ let t = this.lexer.nextToken();
2960
+ return this.pos = t.tokenPos, this.type = t.tokenType, e;
2961
+ }
2962
+ function Or(e, t, n, i) {
2963
+ let a = i[0], o = n === W.rcall ? i[1] : null, s = n === W.rcall ? i[2] : i[1], c = this.registry.findMacro(a, !!o, s.length), l = r(Y, this, Z).call(this, e, t, n, i);
2964
+ if (!c) return l;
2965
+ let u = c.handler({
2966
+ ast: l,
2967
+ args: s,
2968
+ receiver: o,
2969
+ methodName: a,
2970
+ parser: this
2971
+ });
2972
+ return u.callAst ? l.setMeta("alternate", u.callAst) : l.setMeta("macro", u).setMeta("async", xe(u.evaluate, u.async));
2973
+ }
2974
+ function kr() {
2975
+ return r(Y, this, Q).call(this, r(Y, this, Z).call(this, this.pos, this.lexer.pos, W.value, this.value));
2976
+ }
2977
+ function Ar() {
2978
+ let e = this.value, t = this.lexer.pos, n = this.consume(G.IDENTIFIER);
2979
+ if (Se.has(e)) throw m("reserved_identifier", `Reserved identifier: ${e}`, {
2980
+ pos: n,
2981
+ start: n,
2982
+ end: t,
2983
+ input: this.input
2984
+ });
2985
+ if (!this.match(G.LPAREN)) return r(Y, this, Z).call(this, n, t, W.id, e);
2986
+ r(Y, this, Q).call(this);
2987
+ let i = this.parseArgumentList(), a = this.lexer.pos;
2988
+ return this.consume(G.RPAREN), r(Y, this, Or).call(this, n, a, W.call, [e, i]);
2989
+ }
2990
+ function jr() {
2991
+ this.consume(G.LPAREN);
2992
+ let e = this.parseExpression();
2993
+ return this.consume(G.RPAREN), e;
2994
+ }
2995
+ // ../../node_modules/.pnpm/@marcbachmann+cel-js@8.0.0/node_modules/@marcbachmann/cel-js/lib/options.js
2996
+ a();
2997
+ var Mr = y({
2998
+ maxAstNodes: 1e5,
2999
+ maxDepth: 250,
3000
+ maxListElements: 1e3,
3001
+ maxMapEntries: 1e3,
3002
+ maxCallArguments: 32
3003
+ }), Nr = new Set(v(Mr));
3004
+ function Pr(e, t = Mr) {
3005
+ let n = e ? v(e) : void 0;
3006
+ if (!(n != null && n.length)) return t;
3007
+ let r = o({}, t);
3008
+ for (let t of n) {
3009
+ if (!Nr.has(t)) throw TypeError(`Unknown limits option: ${t}`);
3010
+ let n = e[t];
3011
+ typeof n == "number" && (r[t] = n);
3012
+ }
3013
+ return y(r);
3014
+ }
3015
+ var Fr = y({
3016
+ unlistedVariablesAreDyn: !1,
3017
+ homogeneousAggregateLiterals: !0,
3018
+ enableOptionalTypes: !1,
3019
+ limits: Mr
3020
+ });
3021
+ function Ir(e, t, n) {
3022
+ var r;
3023
+ let i = (r = e == null ? void 0 : e[n]) == null ? t == null ? void 0 : t[n] : r;
3024
+ if (typeof i != "boolean") throw TypeError(`Invalid option: ${n}`);
3025
+ return i;
3026
+ }
3027
+ function Lr(e, t = Fr) {
3028
+ return e ? y({
3029
+ unlistedVariablesAreDyn: Ir(e, t, "unlistedVariablesAreDyn"),
3030
+ homogeneousAggregateLiterals: Ir(e, t, "homogeneousAggregateLiterals"),
3031
+ enableOptionalTypes: Ir(e, t, "enableOptionalTypes"),
3032
+ limits: Pr(e.limits, t.limits)
3033
+ }) : t;
3034
+ }
3035
+ // ../../node_modules/.pnpm/@marcbachmann+cel-js@8.0.0/node_modules/@marcbachmann/cel-js/lib/evaluator.js
3036
+ var Rr = Xt({ enableOptionalTypes: !1 });
3037
+ je(Rr), or(Rr), ar(Rr);
3038
+ var $ = /* @__PURE__ */ new WeakMap(), zr = /* @__PURE__ */ new WeakMap(), Br = /* @__PURE__ */ new WeakMap(), Vr = /* @__PURE__ */ new WeakMap(), Hr = /* @__PURE__ */ new WeakMap(), Ur = /* @__PURE__ */ new WeakSet(), Wr = class e {
3039
+ constructor(r, a) {
3040
+ w(this, Ur), t(this, $, void 0), t(this, zr, void 0), t(this, Br, void 0), t(this, Vr, void 0), t(this, Hr, void 0), this.opts = Lr(r, a == null ? void 0 : a.opts), n($, this, (a instanceof e ? i($, a) : Rr).clone(this.opts));
3041
+ let o = {
3042
+ registry: i($, this),
3043
+ opts: this.opts
3044
+ };
3045
+ n(Br, this, new lr(o)), n(Vr, this, new lr(o, !0)), n(zr, this, new Yr(o)), n(Hr, this, new Cr(this.opts.limits, i($, this))), Object.freeze(this);
3046
+ }
3047
+ clone(t) {
3048
+ return new e(t, this);
3049
+ }
3050
+ registerFunction(e, t, n) {
3051
+ return i($, this).registerFunctionOverload(e, t, n), this;
3052
+ }
3053
+ registerOperator(e, t, n) {
3054
+ return i($, this).registerOperatorOverload(e, t, n), this;
3055
+ }
3056
+ registerType(e, t) {
3057
+ return i($, this).registerType(e, t), this;
3058
+ }
3059
+ registerVariable(e, t, n) {
3060
+ return i($, this).registerVariable(e, t, n), this;
3061
+ }
3062
+ registerConstant(e, t, n) {
3063
+ return i($, this).registerConstant(e, t, n), this;
3064
+ }
3065
+ hasVariable(e) {
3066
+ return i($, this).variables.has(e);
3067
+ }
3068
+ getDefinitions() {
3069
+ return i($, this).getDefinitions();
3070
+ }
3071
+ check(e) {
3072
+ try {
3073
+ return r(Ur, this, Gr).call(this, i(Hr, this).parse(e));
3074
+ } catch (e) {
3075
+ return {
3076
+ valid: !1,
3077
+ error: e
3078
+ };
3079
+ }
3080
+ }
3081
+ parse(e) {
3082
+ let t = i(Hr, this).parse(e), n = r(Ur, this, qr).bind(this, t);
3083
+ return n.check = r(Ur, this, Gr).bind(this, t), n.ast = t, n;
3084
+ }
3085
+ evaluate(e, t) {
3086
+ return r(Ur, this, qr).call(this, i(Hr, this).parse(e), t);
3087
+ }
3088
+ };
3089
+ function Gr(e) {
3090
+ try {
3091
+ let t = i(Br, this).check(e, new tn(i($, this)));
3092
+ return {
3093
+ valid: !0,
3094
+ type: r(Ur, this, Kr).call(this, t)
3095
+ };
3096
+ } catch (e) {
3097
+ return {
3098
+ valid: !1,
3099
+ error: e
3100
+ };
3101
+ }
3102
+ }
3103
+ function Kr(e) {
3104
+ return e.name === "list<dyn>" ? "list" : e.name === "map<dyn, dyn>" ? "map" : e.name;
3105
+ }
3106
+ function qr(e, t) {
3107
+ return e.checkedType ? e.evaluate(i(zr, this), e, new tn(i($, this), t)) : (i(Vr, this).check(e, t = new tn(i($, this), t)), e.evaluate(i(zr, this), e, t));
3108
+ }
3109
+ var Jr = /* @__PURE__ */ new WeakSet(), Yr = class extends cn {
3110
+ constructor(e) {
3111
+ super(e), w(this, Jr), this.createError = h;
3112
+ }
3113
+ debugRuntimeType(e, t) {
3114
+ return (t == null ? void 0 : t.hasDynType) === !1 ? t : this.debugTypeDeep(e);
3115
+ }
3116
+ debugTypeDeep(e) {
3117
+ let t = this.debugType(e);
3118
+ switch (t.kind) {
3119
+ case "list": {
3120
+ let n = e instanceof Array ? e[0] : e.values().next().value;
3121
+ return n === void 0 ? t : this.registry.getListType(this.debugTypeDeep(n));
3122
+ }
3123
+ case "map": {
3124
+ let n = r(Jr, this, Xr).call(this, e);
3125
+ return n ? this.registry.getMapType(t.keyType.hasDynType ? this.debugTypeDeep(n[0]) : t.keyType, t.valueType.hasDynType ? this.debugTypeDeep(n[1]) : t.valueType) : t;
3126
+ }
3127
+ default: return t;
3128
+ }
3129
+ }
3130
+ tryEval(e, t) {
3131
+ try {
3132
+ let n = this.run(e, t);
3133
+ return n instanceof Promise ? n.catch((e) => e) : n;
3134
+ } catch (e) {
3135
+ return e;
3136
+ }
3137
+ }
3138
+ run(e, t) {
3139
+ return e.evaluate(this, e, t);
3140
+ }
3141
+ };
3142
+ function Xr(e) {
3143
+ if (e instanceof Map) return e.entries().next().value;
3144
+ for (let t in e) return [t, e[t]];
3145
+ }
3146
+ new Wr({ unlistedVariablesAreDyn: !0 });
3147
+ export { Wr as t };
3148
+
3149
+ //# sourceMappingURL=lib-DHN5bkVZ.mjs.map