@chaos-maker/core 0.5.0 → 0.6.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.
@@ -1,6 +1,6 @@
1
- var Fn = Object.defineProperty;
2
- var Bn = (t, e, n) => e in t ? Fn(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var A = (t, e, n) => Bn(t, typeof e != "symbol" ? e + "" : e, n);
1
+ var Xn = Object.defineProperty;
2
+ var Jn = (t, e, n) => e in t ? Xn(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var M = (t, e, n) => Jn(t, typeof e != "symbol" ? e + "" : e, n);
4
4
  var O;
5
5
  (function(t) {
6
6
  t.assertEqual = (r) => {
@@ -12,40 +12,40 @@ var O;
12
12
  throw new Error();
13
13
  }
14
14
  t.assertNever = n, t.arrayToEnum = (r) => {
15
- const a = {};
16
- for (const o of r)
17
- a[o] = o;
18
- return a;
15
+ const o = {};
16
+ for (const a of r)
17
+ o[a] = a;
18
+ return o;
19
19
  }, t.getValidEnumValues = (r) => {
20
- const a = t.objectKeys(r).filter((i) => typeof r[r[i]] != "number"), o = {};
21
- for (const i of a)
22
- o[i] = r[i];
23
- return t.objectValues(o);
24
- }, t.objectValues = (r) => t.objectKeys(r).map(function(a) {
25
- return r[a];
20
+ const o = t.objectKeys(r).filter((i) => typeof r[r[i]] != "number"), a = {};
21
+ for (const i of o)
22
+ a[i] = r[i];
23
+ return t.objectValues(a);
24
+ }, t.objectValues = (r) => t.objectKeys(r).map(function(o) {
25
+ return r[o];
26
26
  }), t.objectKeys = typeof Object.keys == "function" ? (r) => Object.keys(r) : (r) => {
27
- const a = [];
28
- for (const o in r)
29
- Object.prototype.hasOwnProperty.call(r, o) && a.push(o);
30
- return a;
31
- }, t.find = (r, a) => {
32
- for (const o of r)
33
- if (a(o))
34
- return o;
27
+ const o = [];
28
+ for (const a in r)
29
+ Object.prototype.hasOwnProperty.call(r, a) && o.push(a);
30
+ return o;
31
+ }, t.find = (r, o) => {
32
+ for (const a of r)
33
+ if (o(a))
34
+ return a;
35
35
  }, t.isInteger = typeof Number.isInteger == "function" ? (r) => Number.isInteger(r) : (r) => typeof r == "number" && Number.isFinite(r) && Math.floor(r) === r;
36
- function s(r, a = " | ") {
37
- return r.map((o) => typeof o == "string" ? `'${o}'` : o).join(a);
36
+ function s(r, o = " | ") {
37
+ return r.map((a) => typeof a == "string" ? `'${a}'` : a).join(o);
38
38
  }
39
- t.joinValues = s, t.jsonStringifyReplacer = (r, a) => typeof a == "bigint" ? a.toString() : a;
39
+ t.joinValues = s, t.jsonStringifyReplacer = (r, o) => typeof o == "bigint" ? o.toString() : o;
40
40
  })(O || (O = {}));
41
- var Ct;
41
+ var Ot;
42
42
  (function(t) {
43
43
  t.mergeShapes = (e, n) => ({
44
44
  ...e,
45
45
  ...n
46
46
  // second overwrites first
47
47
  });
48
- })(Ct || (Ct = {}));
48
+ })(Ot || (Ot = {}));
49
49
  const m = O.arrayToEnum([
50
50
  "string",
51
51
  "nan",
@@ -120,23 +120,23 @@ class ce extends Error {
120
120
  Object.setPrototypeOf ? Object.setPrototypeOf(this, n) : this.__proto__ = n, this.name = "ZodError", this.issues = e;
121
121
  }
122
122
  format(e) {
123
- const n = e || function(a) {
124
- return a.message;
125
- }, s = { _errors: [] }, r = (a) => {
126
- for (const o of a.issues)
127
- if (o.code === "invalid_union")
128
- o.unionErrors.map(r);
129
- else if (o.code === "invalid_return_type")
130
- r(o.returnTypeError);
131
- else if (o.code === "invalid_arguments")
132
- r(o.argumentsError);
133
- else if (o.path.length === 0)
134
- s._errors.push(n(o));
123
+ const n = e || function(o) {
124
+ return o.message;
125
+ }, s = { _errors: [] }, r = (o) => {
126
+ for (const a of o.issues)
127
+ if (a.code === "invalid_union")
128
+ a.unionErrors.map(r);
129
+ else if (a.code === "invalid_return_type")
130
+ r(a.returnTypeError);
131
+ else if (a.code === "invalid_arguments")
132
+ r(a.argumentsError);
133
+ else if (a.path.length === 0)
134
+ s._errors.push(n(a));
135
135
  else {
136
136
  let i = s, c = 0;
137
- for (; c < o.path.length; ) {
138
- const u = o.path[c];
139
- c === o.path.length - 1 ? (i[u] = i[u] || { _errors: [] }, i[u]._errors.push(n(o))) : i[u] = i[u] || { _errors: [] }, i = i[u], c++;
137
+ for (; c < a.path.length; ) {
138
+ const u = a.path[c];
139
+ c === a.path.length - 1 ? (i[u] = i[u] || { _errors: [] }, i[u]._errors.push(n(a))) : i[u] = i[u] || { _errors: [] }, i = i[u], c++;
140
140
  }
141
141
  }
142
142
  };
@@ -159,8 +159,8 @@ class ce extends Error {
159
159
  const n = {}, s = [];
160
160
  for (const r of this.issues)
161
161
  if (r.path.length > 0) {
162
- const a = r.path[0];
163
- n[a] = n[a] || [], n[a].push(e(r));
162
+ const o = r.path[0];
163
+ n[o] = n[o] || [], n[o].push(e(r));
164
164
  } else
165
165
  s.push(e(r));
166
166
  return { formErrors: s, fieldErrors: n };
@@ -170,7 +170,7 @@ class ce extends Error {
170
170
  }
171
171
  }
172
172
  ce.create = (t) => new ce(t);
173
- const ot = (t, e) => {
173
+ const ft = (t, e) => {
174
174
  let n;
175
175
  switch (t.code) {
176
176
  case h.invalid_type:
@@ -226,33 +226,33 @@ const ot = (t, e) => {
226
226
  }
227
227
  return { message: n };
228
228
  };
229
- let Hn = ot;
230
- function Yn() {
231
- return Hn;
229
+ let Qn = ft;
230
+ function es() {
231
+ return Qn;
232
232
  }
233
- const Kn = (t) => {
234
- const { data: e, path: n, errorMaps: s, issueData: r } = t, a = [...n, ...r.path || []], o = {
233
+ const ts = (t) => {
234
+ const { data: e, path: n, errorMaps: s, issueData: r } = t, o = [...n, ...r.path || []], a = {
235
235
  ...r,
236
- path: a
236
+ path: o
237
237
  };
238
238
  if (r.message !== void 0)
239
239
  return {
240
240
  ...r,
241
- path: a,
241
+ path: o,
242
242
  message: r.message
243
243
  };
244
244
  let i = "";
245
245
  const c = s.filter((u) => !!u).slice().reverse();
246
246
  for (const u of c)
247
- i = u(o, { data: e, defaultError: i }).message;
247
+ i = u(a, { data: e, defaultError: i }).message;
248
248
  return {
249
249
  ...r,
250
- path: a,
250
+ path: o,
251
251
  message: i
252
252
  };
253
253
  };
254
254
  function g(t, e) {
255
- const n = Yn(), s = Kn({
255
+ const n = es(), s = ts({
256
256
  issueData: e,
257
257
  data: t.data,
258
258
  path: t.path,
@@ -263,7 +263,7 @@ function g(t, e) {
263
263
  // then schema-bound map if available
264
264
  n,
265
265
  // then global override map
266
- n === ot ? void 0 : ot
266
+ n === ft ? void 0 : ft
267
267
  // then global default map
268
268
  ].filter((r) => !!r)
269
269
  });
@@ -291,10 +291,10 @@ class z {
291
291
  static async mergeObjectAsync(e, n) {
292
292
  const s = [];
293
293
  for (const r of n) {
294
- const a = await r.key, o = await r.value;
294
+ const o = await r.key, a = await r.value;
295
295
  s.push({
296
- key: a,
297
- value: o
296
+ key: o,
297
+ value: a
298
298
  });
299
299
  }
300
300
  return z.mergeObjectSync(e, s);
@@ -302,17 +302,17 @@ class z {
302
302
  static mergeObjectSync(e, n) {
303
303
  const s = {};
304
304
  for (const r of n) {
305
- const { key: a, value: o } = r;
306
- if (a.status === "aborted" || o.status === "aborted")
305
+ const { key: o, value: a } = r;
306
+ if (o.status === "aborted" || a.status === "aborted")
307
307
  return x;
308
- a.status === "dirty" && e.dirty(), o.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof o.value < "u" || r.alwaysSet) && (s[a.value] = o.value);
308
+ o.status === "dirty" && e.dirty(), a.status === "dirty" && e.dirty(), o.value !== "__proto__" && (typeof a.value < "u" || r.alwaysSet) && (s[o.value] = a.value);
309
309
  }
310
310
  return { status: e.value, value: s };
311
311
  }
312
312
  }
313
313
  const x = Object.freeze({
314
314
  status: "aborted"
315
- }), Te = (t) => ({ status: "dirty", value: t }), J = (t) => ({ status: "valid", value: t }), Et = (t) => t.status === "aborted", Nt = (t) => t.status === "dirty", ke = (t) => t.status === "valid", qe = (t) => typeof Promise < "u" && t instanceof Promise;
315
+ }), Oe = (t) => ({ status: "dirty", value: t }), Q = (t) => ({ status: "valid", value: t }), Mt = (t) => t.status === "aborted", Rt = (t) => t.status === "dirty", ke = (t) => t.status === "valid", ze = (t) => typeof Promise < "u" && t instanceof Promise;
316
316
  var b;
317
317
  (function(t) {
318
318
  t.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, t.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
@@ -325,7 +325,7 @@ class re {
325
325
  return this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
326
326
  }
327
327
  }
328
- const Tt = (t, e) => {
328
+ const At = (t, e) => {
329
329
  if (ke(e))
330
330
  return { success: !0, data: e.value };
331
331
  if (!t.common.issues.length)
@@ -346,9 +346,9 @@ function E(t) {
346
346
  const { errorMap: e, invalid_type_error: n, required_error: s, description: r } = t;
347
347
  if (e && (n || s))
348
348
  throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
349
- return e ? { errorMap: e, description: r } : { errorMap: (o, i) => {
349
+ return e ? { errorMap: e, description: r } : { errorMap: (a, i) => {
350
350
  const { message: c } = t;
351
- return o.code === "invalid_enum_value" ? { message: c ?? i.defaultError } : typeof i.data > "u" ? { message: c ?? s ?? i.defaultError } : o.code !== "invalid_type" ? { message: i.defaultError } : { message: c ?? n ?? i.defaultError };
351
+ return a.code === "invalid_enum_value" ? { message: c ?? i.defaultError } : typeof i.data > "u" ? { message: c ?? s ?? i.defaultError } : a.code !== "invalid_type" ? { message: i.defaultError } : { message: c ?? n ?? i.defaultError };
352
352
  }, description: r };
353
353
  }
354
354
  class T {
@@ -383,7 +383,7 @@ class T {
383
383
  }
384
384
  _parseSync(e) {
385
385
  const n = this._parse(e);
386
- if (qe(n))
386
+ if (ze(n))
387
387
  throw new Error("Synchronous parse encountered promise.");
388
388
  return n;
389
389
  }
@@ -410,7 +410,7 @@ class T {
410
410
  data: e,
411
411
  parsedType: ue(e)
412
412
  }, r = this._parseSync({ data: e, path: s.path, parent: s });
413
- return Tt(s, r);
413
+ return At(s, r);
414
414
  }
415
415
  "~validate"(e) {
416
416
  var s, r;
@@ -427,20 +427,20 @@ class T {
427
427
  };
428
428
  if (!this["~standard"].async)
429
429
  try {
430
- const a = this._parseSync({ data: e, path: [], parent: n });
431
- return ke(a) ? {
432
- value: a.value
430
+ const o = this._parseSync({ data: e, path: [], parent: n });
431
+ return ke(o) ? {
432
+ value: o.value
433
433
  } : {
434
434
  issues: n.common.issues
435
435
  };
436
- } catch (a) {
437
- (r = (s = a == null ? void 0 : a.message) == null ? void 0 : s.toLowerCase()) != null && r.includes("encountered") && (this["~standard"].async = !0), n.common = {
436
+ } catch (o) {
437
+ (r = (s = o == null ? void 0 : o.message) == null ? void 0 : s.toLowerCase()) != null && r.includes("encountered") && (this["~standard"].async = !0), n.common = {
438
438
  issues: [],
439
439
  async: !0
440
440
  };
441
441
  }
442
- return this._parseAsync({ data: e, path: [], parent: n }).then((a) => ke(a) ? {
443
- value: a.value
442
+ return this._parseAsync({ data: e, path: [], parent: n }).then((o) => ke(o) ? {
443
+ value: o.value
444
444
  } : {
445
445
  issues: n.common.issues
446
446
  });
@@ -463,17 +463,17 @@ class T {
463
463
  parent: null,
464
464
  data: e,
465
465
  parsedType: ue(e)
466
- }, r = this._parse({ data: e, path: s.path, parent: s }), a = await (qe(r) ? r : Promise.resolve(r));
467
- return Tt(s, a);
466
+ }, r = this._parse({ data: e, path: s.path, parent: s }), o = await (ze(r) ? r : Promise.resolve(r));
467
+ return At(s, o);
468
468
  }
469
469
  refine(e, n) {
470
470
  const s = (r) => typeof n == "string" || typeof n > "u" ? { message: n } : typeof n == "function" ? n(r) : n;
471
- return this._refinement((r, a) => {
472
- const o = e(r), i = () => a.addIssue({
471
+ return this._refinement((r, o) => {
472
+ const a = e(r), i = () => o.addIssue({
473
473
  code: h.custom,
474
474
  ...s(r)
475
475
  });
476
- return typeof Promise < "u" && o instanceof Promise ? o.then((c) => c ? !0 : (i(), !1)) : o ? !0 : (i(), !1);
476
+ return typeof Promise < "u" && a instanceof Promise ? a.then((c) => c ? !0 : (i(), !1)) : a ? !0 : (i(), !1);
477
477
  });
478
478
  }
479
479
  refinement(e, n) {
@@ -506,16 +506,16 @@ class T {
506
506
  return this.nullable().optional();
507
507
  }
508
508
  array() {
509
- return ne.create(this);
509
+ return se.create(this);
510
510
  }
511
511
  promise() {
512
- return Be.create(this, this._def);
512
+ return Ye.create(this, this._def);
513
513
  }
514
514
  or(e) {
515
- return Ve.create([this, e], this._def);
515
+ return Be.create([this, e], this._def);
516
516
  }
517
517
  and(e) {
518
- return ze.create(this, e, this._def);
518
+ return He.create(this, e, this._def);
519
519
  }
520
520
  transform(e) {
521
521
  return new xe({
@@ -527,7 +527,7 @@ class T {
527
527
  }
528
528
  default(e) {
529
529
  const n = typeof e == "function" ? e : () => e;
530
- return new lt({
530
+ return new yt({
531
531
  ...E(this._def),
532
532
  innerType: this,
533
533
  defaultValue: n,
@@ -535,7 +535,7 @@ class T {
535
535
  });
536
536
  }
537
537
  brand() {
538
- return new vs({
538
+ return new Ss({
539
539
  typeName: w.ZodBranded,
540
540
  type: this,
541
541
  ...E(this._def)
@@ -543,7 +543,7 @@ class T {
543
543
  }
544
544
  catch(e) {
545
545
  const n = typeof e == "function" ? e : () => e;
546
- return new dt({
546
+ return new mt({
547
547
  ...E(this._def),
548
548
  innerType: this,
549
549
  catchValue: n,
@@ -558,10 +558,10 @@ class T {
558
558
  });
559
559
  }
560
560
  pipe(e) {
561
- return mt.create(this, e);
561
+ return xt.create(this, e);
562
562
  }
563
563
  readonly() {
564
- return ft.create(this);
564
+ return bt.create(this);
565
565
  }
566
566
  isOptional() {
567
567
  return this.safeParse(void 0).success;
@@ -570,28 +570,28 @@ class T {
570
570
  return this.safeParse(null).success;
571
571
  }
572
572
  }
573
- const Xn = /^c[^\s-]{8,}$/i, Jn = /^[0-9a-z]+$/, Qn = /^[0-9A-HJKMNP-TV-Z]{26}$/i, es = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, ts = /^[a-z0-9_-]{21}$/i, ns = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, ss = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, rs = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, as = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
574
- let nt;
575
- const os = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, is = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, cs = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, us = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, ls = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, ds = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, rn = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", fs = new RegExp(`^${rn}$`);
576
- function an(t) {
573
+ const ns = /^c[^\s-]{8,}$/i, ss = /^[0-9a-z]+$/, rs = /^[0-9A-HJKMNP-TV-Z]{26}$/i, os = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, as = /^[a-z0-9_-]{21}$/i, is = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, cs = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, us = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, ls = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
574
+ let ct;
575
+ const ds = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, fs = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, hs = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, ps = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, gs = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, ys = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, un = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", ms = new RegExp(`^${un}$`);
576
+ function ln(t) {
577
577
  let e = "[0-5]\\d";
578
578
  t.precision ? e = `${e}\\.\\d{${t.precision}}` : t.precision == null && (e = `${e}(\\.\\d+)?`);
579
579
  const n = t.precision ? "+" : "?";
580
580
  return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`;
581
581
  }
582
- function hs(t) {
583
- return new RegExp(`^${an(t)}$`);
582
+ function bs(t) {
583
+ return new RegExp(`^${ln(t)}$`);
584
584
  }
585
- function ps(t) {
586
- let e = `${rn}T${an(t)}`;
585
+ function vs(t) {
586
+ let e = `${un}T${ln(t)}`;
587
587
  const n = [];
588
588
  return n.push(t.local ? "Z?" : "Z"), t.offset && n.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${n.join("|")})`, new RegExp(`^${e}$`);
589
589
  }
590
- function gs(t, e) {
591
- return !!((e === "v4" || !e) && os.test(t) || (e === "v6" || !e) && cs.test(t));
590
+ function ks(t, e) {
591
+ return !!((e === "v4" || !e) && ds.test(t) || (e === "v6" || !e) && hs.test(t));
592
592
  }
593
- function ys(t, e) {
594
- if (!ns.test(t))
593
+ function _s(t, e) {
594
+ if (!is.test(t))
595
595
  return !1;
596
596
  try {
597
597
  const [n] = t.split(".");
@@ -603,162 +603,162 @@ function ys(t, e) {
603
603
  return !1;
604
604
  }
605
605
  }
606
- function ms(t, e) {
607
- return !!((e === "v4" || !e) && is.test(t) || (e === "v6" || !e) && us.test(t));
606
+ function ws(t, e) {
607
+ return !!((e === "v4" || !e) && fs.test(t) || (e === "v6" || !e) && ps.test(t));
608
608
  }
609
609
  class ie extends T {
610
610
  _parse(e) {
611
611
  if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== m.string) {
612
- const a = this._getOrReturnCtx(e);
613
- return g(a, {
612
+ const o = this._getOrReturnCtx(e);
613
+ return g(o, {
614
614
  code: h.invalid_type,
615
615
  expected: m.string,
616
- received: a.parsedType
616
+ received: o.parsedType
617
617
  }), x;
618
618
  }
619
619
  const s = new z();
620
620
  let r;
621
- for (const a of this._def.checks)
622
- if (a.kind === "min")
623
- e.data.length < a.value && (r = this._getOrReturnCtx(e, r), g(r, {
621
+ for (const o of this._def.checks)
622
+ if (o.kind === "min")
623
+ e.data.length < o.value && (r = this._getOrReturnCtx(e, r), g(r, {
624
624
  code: h.too_small,
625
- minimum: a.value,
625
+ minimum: o.value,
626
626
  type: "string",
627
627
  inclusive: !0,
628
628
  exact: !1,
629
- message: a.message
629
+ message: o.message
630
630
  }), s.dirty());
631
- else if (a.kind === "max")
632
- e.data.length > a.value && (r = this._getOrReturnCtx(e, r), g(r, {
631
+ else if (o.kind === "max")
632
+ e.data.length > o.value && (r = this._getOrReturnCtx(e, r), g(r, {
633
633
  code: h.too_big,
634
- maximum: a.value,
634
+ maximum: o.value,
635
635
  type: "string",
636
636
  inclusive: !0,
637
637
  exact: !1,
638
- message: a.message
638
+ message: o.message
639
639
  }), s.dirty());
640
- else if (a.kind === "length") {
641
- const o = e.data.length > a.value, i = e.data.length < a.value;
642
- (o || i) && (r = this._getOrReturnCtx(e, r), o ? g(r, {
640
+ else if (o.kind === "length") {
641
+ const a = e.data.length > o.value, i = e.data.length < o.value;
642
+ (a || i) && (r = this._getOrReturnCtx(e, r), a ? g(r, {
643
643
  code: h.too_big,
644
- maximum: a.value,
644
+ maximum: o.value,
645
645
  type: "string",
646
646
  inclusive: !0,
647
647
  exact: !0,
648
- message: a.message
648
+ message: o.message
649
649
  }) : i && g(r, {
650
650
  code: h.too_small,
651
- minimum: a.value,
651
+ minimum: o.value,
652
652
  type: "string",
653
653
  inclusive: !0,
654
654
  exact: !0,
655
- message: a.message
655
+ message: o.message
656
656
  }), s.dirty());
657
- } else if (a.kind === "email")
658
- rs.test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
657
+ } else if (o.kind === "email")
658
+ us.test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
659
659
  validation: "email",
660
660
  code: h.invalid_string,
661
- message: a.message
661
+ message: o.message
662
662
  }), s.dirty());
663
- else if (a.kind === "emoji")
664
- nt || (nt = new RegExp(as, "u")), nt.test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
663
+ else if (o.kind === "emoji")
664
+ ct || (ct = new RegExp(ls, "u")), ct.test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
665
665
  validation: "emoji",
666
666
  code: h.invalid_string,
667
- message: a.message
667
+ message: o.message
668
668
  }), s.dirty());
669
- else if (a.kind === "uuid")
670
- es.test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
669
+ else if (o.kind === "uuid")
670
+ os.test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
671
671
  validation: "uuid",
672
672
  code: h.invalid_string,
673
- message: a.message
673
+ message: o.message
674
674
  }), s.dirty());
675
- else if (a.kind === "nanoid")
676
- ts.test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
675
+ else if (o.kind === "nanoid")
676
+ as.test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
677
677
  validation: "nanoid",
678
678
  code: h.invalid_string,
679
- message: a.message
679
+ message: o.message
680
680
  }), s.dirty());
681
- else if (a.kind === "cuid")
682
- Xn.test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
681
+ else if (o.kind === "cuid")
682
+ ns.test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
683
683
  validation: "cuid",
684
684
  code: h.invalid_string,
685
- message: a.message
685
+ message: o.message
686
686
  }), s.dirty());
687
- else if (a.kind === "cuid2")
688
- Jn.test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
687
+ else if (o.kind === "cuid2")
688
+ ss.test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
689
689
  validation: "cuid2",
690
690
  code: h.invalid_string,
691
- message: a.message
691
+ message: o.message
692
692
  }), s.dirty());
693
- else if (a.kind === "ulid")
694
- Qn.test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
693
+ else if (o.kind === "ulid")
694
+ rs.test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
695
695
  validation: "ulid",
696
696
  code: h.invalid_string,
697
- message: a.message
697
+ message: o.message
698
698
  }), s.dirty());
699
- else if (a.kind === "url")
699
+ else if (o.kind === "url")
700
700
  try {
701
701
  new URL(e.data);
702
702
  } catch {
703
703
  r = this._getOrReturnCtx(e, r), g(r, {
704
704
  validation: "url",
705
705
  code: h.invalid_string,
706
- message: a.message
706
+ message: o.message
707
707
  }), s.dirty();
708
708
  }
709
- else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
709
+ else o.kind === "regex" ? (o.regex.lastIndex = 0, o.regex.test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
710
710
  validation: "regex",
711
711
  code: h.invalid_string,
712
- message: a.message
713
- }), s.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (r = this._getOrReturnCtx(e, r), g(r, {
712
+ message: o.message
713
+ }), s.dirty())) : o.kind === "trim" ? e.data = e.data.trim() : o.kind === "includes" ? e.data.includes(o.value, o.position) || (r = this._getOrReturnCtx(e, r), g(r, {
714
714
  code: h.invalid_string,
715
- validation: { includes: a.value, position: a.position },
716
- message: a.message
717
- }), s.dirty()) : a.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : a.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : a.kind === "startsWith" ? e.data.startsWith(a.value) || (r = this._getOrReturnCtx(e, r), g(r, {
715
+ validation: { includes: o.value, position: o.position },
716
+ message: o.message
717
+ }), s.dirty()) : o.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : o.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : o.kind === "startsWith" ? e.data.startsWith(o.value) || (r = this._getOrReturnCtx(e, r), g(r, {
718
718
  code: h.invalid_string,
719
- validation: { startsWith: a.value },
720
- message: a.message
721
- }), s.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (r = this._getOrReturnCtx(e, r), g(r, {
719
+ validation: { startsWith: o.value },
720
+ message: o.message
721
+ }), s.dirty()) : o.kind === "endsWith" ? e.data.endsWith(o.value) || (r = this._getOrReturnCtx(e, r), g(r, {
722
722
  code: h.invalid_string,
723
- validation: { endsWith: a.value },
724
- message: a.message
725
- }), s.dirty()) : a.kind === "datetime" ? ps(a).test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
723
+ validation: { endsWith: o.value },
724
+ message: o.message
725
+ }), s.dirty()) : o.kind === "datetime" ? vs(o).test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
726
726
  code: h.invalid_string,
727
727
  validation: "datetime",
728
- message: a.message
729
- }), s.dirty()) : a.kind === "date" ? fs.test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
728
+ message: o.message
729
+ }), s.dirty()) : o.kind === "date" ? ms.test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
730
730
  code: h.invalid_string,
731
731
  validation: "date",
732
- message: a.message
733
- }), s.dirty()) : a.kind === "time" ? hs(a).test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
732
+ message: o.message
733
+ }), s.dirty()) : o.kind === "time" ? bs(o).test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
734
734
  code: h.invalid_string,
735
735
  validation: "time",
736
- message: a.message
737
- }), s.dirty()) : a.kind === "duration" ? ss.test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
736
+ message: o.message
737
+ }), s.dirty()) : o.kind === "duration" ? cs.test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
738
738
  validation: "duration",
739
739
  code: h.invalid_string,
740
- message: a.message
741
- }), s.dirty()) : a.kind === "ip" ? gs(e.data, a.version) || (r = this._getOrReturnCtx(e, r), g(r, {
740
+ message: o.message
741
+ }), s.dirty()) : o.kind === "ip" ? ks(e.data, o.version) || (r = this._getOrReturnCtx(e, r), g(r, {
742
742
  validation: "ip",
743
743
  code: h.invalid_string,
744
- message: a.message
745
- }), s.dirty()) : a.kind === "jwt" ? ys(e.data, a.alg) || (r = this._getOrReturnCtx(e, r), g(r, {
744
+ message: o.message
745
+ }), s.dirty()) : o.kind === "jwt" ? _s(e.data, o.alg) || (r = this._getOrReturnCtx(e, r), g(r, {
746
746
  validation: "jwt",
747
747
  code: h.invalid_string,
748
- message: a.message
749
- }), s.dirty()) : a.kind === "cidr" ? ms(e.data, a.version) || (r = this._getOrReturnCtx(e, r), g(r, {
748
+ message: o.message
749
+ }), s.dirty()) : o.kind === "cidr" ? ws(e.data, o.version) || (r = this._getOrReturnCtx(e, r), g(r, {
750
750
  validation: "cidr",
751
751
  code: h.invalid_string,
752
- message: a.message
753
- }), s.dirty()) : a.kind === "base64" ? ls.test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
752
+ message: o.message
753
+ }), s.dirty()) : o.kind === "base64" ? gs.test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
754
754
  validation: "base64",
755
755
  code: h.invalid_string,
756
- message: a.message
757
- }), s.dirty()) : a.kind === "base64url" ? ds.test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
756
+ message: o.message
757
+ }), s.dirty()) : o.kind === "base64url" ? ys.test(e.data) || (r = this._getOrReturnCtx(e, r), g(r, {
758
758
  validation: "base64url",
759
759
  code: h.invalid_string,
760
- message: a.message
761
- }), s.dirty()) : O.assertNever(a);
760
+ message: o.message
761
+ }), s.dirty()) : O.assertNever(o);
762
762
  return { status: s.value, value: e.data };
763
763
  }
764
764
  _regex(e, n, s) {
@@ -989,9 +989,9 @@ ie.create = (t) => new ie({
989
989
  coerce: (t == null ? void 0 : t.coerce) ?? !1,
990
990
  ...E(t)
991
991
  });
992
- function bs(t, e) {
993
- const n = (t.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length, r = n > s ? n : s, a = Number.parseInt(t.toFixed(r).replace(".", "")), o = Number.parseInt(e.toFixed(r).replace(".", ""));
994
- return a % o / 10 ** r;
992
+ function xs(t, e) {
993
+ const n = (t.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length, r = n > s ? n : s, o = Number.parseInt(t.toFixed(r).replace(".", "")), a = Number.parseInt(e.toFixed(r).replace(".", ""));
994
+ return o % a / 10 ** r;
995
995
  }
996
996
  class _e extends T {
997
997
  constructor() {
@@ -999,43 +999,43 @@ class _e extends T {
999
999
  }
1000
1000
  _parse(e) {
1001
1001
  if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== m.number) {
1002
- const a = this._getOrReturnCtx(e);
1003
- return g(a, {
1002
+ const o = this._getOrReturnCtx(e);
1003
+ return g(o, {
1004
1004
  code: h.invalid_type,
1005
1005
  expected: m.number,
1006
- received: a.parsedType
1006
+ received: o.parsedType
1007
1007
  }), x;
1008
1008
  }
1009
1009
  let s;
1010
1010
  const r = new z();
1011
- for (const a of this._def.checks)
1012
- a.kind === "int" ? O.isInteger(e.data) || (s = this._getOrReturnCtx(e, s), g(s, {
1011
+ for (const o of this._def.checks)
1012
+ o.kind === "int" ? O.isInteger(e.data) || (s = this._getOrReturnCtx(e, s), g(s, {
1013
1013
  code: h.invalid_type,
1014
1014
  expected: "integer",
1015
1015
  received: "float",
1016
- message: a.message
1017
- }), r.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (s = this._getOrReturnCtx(e, s), g(s, {
1016
+ message: o.message
1017
+ }), r.dirty()) : o.kind === "min" ? (o.inclusive ? e.data < o.value : e.data <= o.value) && (s = this._getOrReturnCtx(e, s), g(s, {
1018
1018
  code: h.too_small,
1019
- minimum: a.value,
1019
+ minimum: o.value,
1020
1020
  type: "number",
1021
- inclusive: a.inclusive,
1021
+ inclusive: o.inclusive,
1022
1022
  exact: !1,
1023
- message: a.message
1024
- }), r.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (s = this._getOrReturnCtx(e, s), g(s, {
1023
+ message: o.message
1024
+ }), r.dirty()) : o.kind === "max" ? (o.inclusive ? e.data > o.value : e.data >= o.value) && (s = this._getOrReturnCtx(e, s), g(s, {
1025
1025
  code: h.too_big,
1026
- maximum: a.value,
1026
+ maximum: o.value,
1027
1027
  type: "number",
1028
- inclusive: a.inclusive,
1028
+ inclusive: o.inclusive,
1029
1029
  exact: !1,
1030
- message: a.message
1031
- }), r.dirty()) : a.kind === "multipleOf" ? bs(e.data, a.value) !== 0 && (s = this._getOrReturnCtx(e, s), g(s, {
1030
+ message: o.message
1031
+ }), r.dirty()) : o.kind === "multipleOf" ? xs(e.data, o.value) !== 0 && (s = this._getOrReturnCtx(e, s), g(s, {
1032
1032
  code: h.not_multiple_of,
1033
- multipleOf: a.value,
1034
- message: a.message
1035
- }), r.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (s = this._getOrReturnCtx(e, s), g(s, {
1033
+ multipleOf: o.value,
1034
+ message: o.message
1035
+ }), r.dirty()) : o.kind === "finite" ? Number.isFinite(e.data) || (s = this._getOrReturnCtx(e, s), g(s, {
1036
1036
  code: h.not_finite,
1037
- message: a.message
1038
- }), r.dirty()) : O.assertNever(a);
1037
+ message: o.message
1038
+ }), r.dirty()) : O.assertNever(o);
1039
1039
  return { status: r.value, value: e.data };
1040
1040
  }
1041
1041
  gte(e, n) {
@@ -1165,7 +1165,7 @@ _e.create = (t) => new _e({
1165
1165
  coerce: (t == null ? void 0 : t.coerce) || !1,
1166
1166
  ...E(t)
1167
1167
  });
1168
- class Me extends T {
1168
+ class $e extends T {
1169
1169
  constructor() {
1170
1170
  super(...arguments), this.min = this.gte, this.max = this.lte;
1171
1171
  }
@@ -1180,24 +1180,24 @@ class Me extends T {
1180
1180
  return this._getInvalidInput(e);
1181
1181
  let s;
1182
1182
  const r = new z();
1183
- for (const a of this._def.checks)
1184
- a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (s = this._getOrReturnCtx(e, s), g(s, {
1183
+ for (const o of this._def.checks)
1184
+ o.kind === "min" ? (o.inclusive ? e.data < o.value : e.data <= o.value) && (s = this._getOrReturnCtx(e, s), g(s, {
1185
1185
  code: h.too_small,
1186
1186
  type: "bigint",
1187
- minimum: a.value,
1188
- inclusive: a.inclusive,
1189
- message: a.message
1190
- }), r.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (s = this._getOrReturnCtx(e, s), g(s, {
1187
+ minimum: o.value,
1188
+ inclusive: o.inclusive,
1189
+ message: o.message
1190
+ }), r.dirty()) : o.kind === "max" ? (o.inclusive ? e.data > o.value : e.data >= o.value) && (s = this._getOrReturnCtx(e, s), g(s, {
1191
1191
  code: h.too_big,
1192
1192
  type: "bigint",
1193
- maximum: a.value,
1194
- inclusive: a.inclusive,
1195
- message: a.message
1196
- }), r.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (s = this._getOrReturnCtx(e, s), g(s, {
1193
+ maximum: o.value,
1194
+ inclusive: o.inclusive,
1195
+ message: o.message
1196
+ }), r.dirty()) : o.kind === "multipleOf" ? e.data % o.value !== BigInt(0) && (s = this._getOrReturnCtx(e, s), g(s, {
1197
1197
  code: h.not_multiple_of,
1198
- multipleOf: a.value,
1199
- message: a.message
1200
- }), r.dirty()) : O.assertNever(a);
1198
+ multipleOf: o.value,
1199
+ message: o.message
1200
+ }), r.dirty()) : O.assertNever(o);
1201
1201
  return { status: r.value, value: e.data };
1202
1202
  }
1203
1203
  _getInvalidInput(e) {
@@ -1221,7 +1221,7 @@ class Me extends T {
1221
1221
  return this.setLimit("max", e, !1, b.toString(n));
1222
1222
  }
1223
1223
  setLimit(e, n, s, r) {
1224
- return new Me({
1224
+ return new $e({
1225
1225
  ...this._def,
1226
1226
  checks: [
1227
1227
  ...this._def.checks,
@@ -1235,7 +1235,7 @@ class Me extends T {
1235
1235
  });
1236
1236
  }
1237
1237
  _addCheck(e) {
1238
- return new Me({
1238
+ return new $e({
1239
1239
  ...this._def,
1240
1240
  checks: [...this._def.checks, e]
1241
1241
  });
@@ -1292,13 +1292,13 @@ class Me extends T {
1292
1292
  return e;
1293
1293
  }
1294
1294
  }
1295
- Me.create = (t) => new Me({
1295
+ $e.create = (t) => new $e({
1296
1296
  checks: [],
1297
1297
  typeName: w.ZodBigInt,
1298
1298
  coerce: (t == null ? void 0 : t.coerce) ?? !1,
1299
1299
  ...E(t)
1300
1300
  });
1301
- class it extends T {
1301
+ class ht extends T {
1302
1302
  _parse(e) {
1303
1303
  if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== m.boolean) {
1304
1304
  const s = this._getOrReturnCtx(e);
@@ -1308,55 +1308,55 @@ class it extends T {
1308
1308
  received: s.parsedType
1309
1309
  }), x;
1310
1310
  }
1311
- return J(e.data);
1311
+ return Q(e.data);
1312
1312
  }
1313
1313
  }
1314
- it.create = (t) => new it({
1314
+ ht.create = (t) => new ht({
1315
1315
  typeName: w.ZodBoolean,
1316
1316
  coerce: (t == null ? void 0 : t.coerce) || !1,
1317
1317
  ...E(t)
1318
1318
  });
1319
- class Ue extends T {
1319
+ class Fe extends T {
1320
1320
  _parse(e) {
1321
1321
  if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== m.date) {
1322
- const a = this._getOrReturnCtx(e);
1323
- return g(a, {
1322
+ const o = this._getOrReturnCtx(e);
1323
+ return g(o, {
1324
1324
  code: h.invalid_type,
1325
1325
  expected: m.date,
1326
- received: a.parsedType
1326
+ received: o.parsedType
1327
1327
  }), x;
1328
1328
  }
1329
1329
  if (Number.isNaN(e.data.getTime())) {
1330
- const a = this._getOrReturnCtx(e);
1331
- return g(a, {
1330
+ const o = this._getOrReturnCtx(e);
1331
+ return g(o, {
1332
1332
  code: h.invalid_date
1333
1333
  }), x;
1334
1334
  }
1335
1335
  const s = new z();
1336
1336
  let r;
1337
- for (const a of this._def.checks)
1338
- a.kind === "min" ? e.data.getTime() < a.value && (r = this._getOrReturnCtx(e, r), g(r, {
1337
+ for (const o of this._def.checks)
1338
+ o.kind === "min" ? e.data.getTime() < o.value && (r = this._getOrReturnCtx(e, r), g(r, {
1339
1339
  code: h.too_small,
1340
- message: a.message,
1340
+ message: o.message,
1341
1341
  inclusive: !0,
1342
1342
  exact: !1,
1343
- minimum: a.value,
1343
+ minimum: o.value,
1344
1344
  type: "date"
1345
- }), s.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (r = this._getOrReturnCtx(e, r), g(r, {
1345
+ }), s.dirty()) : o.kind === "max" ? e.data.getTime() > o.value && (r = this._getOrReturnCtx(e, r), g(r, {
1346
1346
  code: h.too_big,
1347
- message: a.message,
1347
+ message: o.message,
1348
1348
  inclusive: !0,
1349
1349
  exact: !1,
1350
- maximum: a.value,
1350
+ maximum: o.value,
1351
1351
  type: "date"
1352
- }), s.dirty()) : O.assertNever(a);
1352
+ }), s.dirty()) : O.assertNever(o);
1353
1353
  return {
1354
1354
  status: s.value,
1355
1355
  value: new Date(e.data.getTime())
1356
1356
  };
1357
1357
  }
1358
1358
  _addCheck(e) {
1359
- return new Ue({
1359
+ return new Fe({
1360
1360
  ...this._def,
1361
1361
  checks: [...this._def.checks, e]
1362
1362
  });
@@ -1388,13 +1388,13 @@ class Ue extends T {
1388
1388
  return e != null ? new Date(e) : null;
1389
1389
  }
1390
1390
  }
1391
- Ue.create = (t) => new Ue({
1391
+ Fe.create = (t) => new Fe({
1392
1392
  checks: [],
1393
1393
  coerce: (t == null ? void 0 : t.coerce) || !1,
1394
1394
  typeName: w.ZodDate,
1395
1395
  ...E(t)
1396
1396
  });
1397
- class Ot extends T {
1397
+ class Pt extends T {
1398
1398
  _parse(e) {
1399
1399
  if (this._getType(e) !== m.symbol) {
1400
1400
  const s = this._getOrReturnCtx(e);
@@ -1404,14 +1404,14 @@ class Ot extends T {
1404
1404
  received: s.parsedType
1405
1405
  }), x;
1406
1406
  }
1407
- return J(e.data);
1407
+ return Q(e.data);
1408
1408
  }
1409
1409
  }
1410
- Ot.create = (t) => new Ot({
1410
+ Pt.create = (t) => new Pt({
1411
1411
  typeName: w.ZodSymbol,
1412
1412
  ...E(t)
1413
1413
  });
1414
- class At extends T {
1414
+ class $t extends T {
1415
1415
  _parse(e) {
1416
1416
  if (this._getType(e) !== m.undefined) {
1417
1417
  const s = this._getOrReturnCtx(e);
@@ -1421,14 +1421,14 @@ class At extends T {
1421
1421
  received: s.parsedType
1422
1422
  }), x;
1423
1423
  }
1424
- return J(e.data);
1424
+ return Q(e.data);
1425
1425
  }
1426
1426
  }
1427
- At.create = (t) => new At({
1427
+ $t.create = (t) => new $t({
1428
1428
  typeName: w.ZodUndefined,
1429
1429
  ...E(t)
1430
1430
  });
1431
- class Mt extends T {
1431
+ class jt extends T {
1432
1432
  _parse(e) {
1433
1433
  if (this._getType(e) !== m.null) {
1434
1434
  const s = this._getOrReturnCtx(e);
@@ -1438,34 +1438,34 @@ class Mt extends T {
1438
1438
  received: s.parsedType
1439
1439
  }), x;
1440
1440
  }
1441
- return J(e.data);
1441
+ return Q(e.data);
1442
1442
  }
1443
1443
  }
1444
- Mt.create = (t) => new Mt({
1444
+ jt.create = (t) => new jt({
1445
1445
  typeName: w.ZodNull,
1446
1446
  ...E(t)
1447
1447
  });
1448
- class Re extends T {
1448
+ class je extends T {
1449
1449
  constructor() {
1450
1450
  super(...arguments), this._any = !0;
1451
1451
  }
1452
1452
  _parse(e) {
1453
- return J(e.data);
1453
+ return Q(e.data);
1454
1454
  }
1455
1455
  }
1456
- Re.create = (t) => new Re({
1456
+ je.create = (t) => new je({
1457
1457
  typeName: w.ZodAny,
1458
1458
  ...E(t)
1459
1459
  });
1460
- class Rt extends T {
1460
+ class Lt extends T {
1461
1461
  constructor() {
1462
1462
  super(...arguments), this._unknown = !0;
1463
1463
  }
1464
1464
  _parse(e) {
1465
- return J(e.data);
1465
+ return Q(e.data);
1466
1466
  }
1467
1467
  }
1468
- Rt.create = (t) => new Rt({
1468
+ Lt.create = (t) => new Lt({
1469
1469
  typeName: w.ZodUnknown,
1470
1470
  ...E(t)
1471
1471
  });
@@ -1483,7 +1483,7 @@ de.create = (t) => new de({
1483
1483
  typeName: w.ZodNever,
1484
1484
  ...E(t)
1485
1485
  });
1486
- class jt extends T {
1486
+ class It extends T {
1487
1487
  _parse(e) {
1488
1488
  if (this._getType(e) !== m.undefined) {
1489
1489
  const s = this._getOrReturnCtx(e);
@@ -1493,14 +1493,14 @@ class jt extends T {
1493
1493
  received: s.parsedType
1494
1494
  }), x;
1495
1495
  }
1496
- return J(e.data);
1496
+ return Q(e.data);
1497
1497
  }
1498
1498
  }
1499
- jt.create = (t) => new jt({
1499
+ It.create = (t) => new It({
1500
1500
  typeName: w.ZodVoid,
1501
1501
  ...E(t)
1502
1502
  });
1503
- class ne extends T {
1503
+ class se extends T {
1504
1504
  _parse(e) {
1505
1505
  const { ctx: n, status: s } = this._processInputParams(e), r = this._def;
1506
1506
  if (n.parsedType !== m.array)
@@ -1510,11 +1510,11 @@ class ne extends T {
1510
1510
  received: n.parsedType
1511
1511
  }), x;
1512
1512
  if (r.exactLength !== null) {
1513
- const o = n.data.length > r.exactLength.value, i = n.data.length < r.exactLength.value;
1514
- (o || i) && (g(n, {
1515
- code: o ? h.too_big : h.too_small,
1513
+ const a = n.data.length > r.exactLength.value, i = n.data.length < r.exactLength.value;
1514
+ (a || i) && (g(n, {
1515
+ code: a ? h.too_big : h.too_small,
1516
1516
  minimum: i ? r.exactLength.value : void 0,
1517
- maximum: o ? r.exactLength.value : void 0,
1517
+ maximum: a ? r.exactLength.value : void 0,
1518
1518
  type: "array",
1519
1519
  inclusive: !0,
1520
1520
  exact: !0,
@@ -1536,27 +1536,27 @@ class ne extends T {
1536
1536
  exact: !1,
1537
1537
  message: r.maxLength.message
1538
1538
  }), s.dirty()), n.common.async)
1539
- return Promise.all([...n.data].map((o, i) => r.type._parseAsync(new re(n, o, n.path, i)))).then((o) => z.mergeArray(s, o));
1540
- const a = [...n.data].map((o, i) => r.type._parseSync(new re(n, o, n.path, i)));
1541
- return z.mergeArray(s, a);
1539
+ return Promise.all([...n.data].map((a, i) => r.type._parseAsync(new re(n, a, n.path, i)))).then((a) => z.mergeArray(s, a));
1540
+ const o = [...n.data].map((a, i) => r.type._parseSync(new re(n, a, n.path, i)));
1541
+ return z.mergeArray(s, o);
1542
1542
  }
1543
1543
  get element() {
1544
1544
  return this._def.type;
1545
1545
  }
1546
1546
  min(e, n) {
1547
- return new ne({
1547
+ return new se({
1548
1548
  ...this._def,
1549
1549
  minLength: { value: e, message: b.toString(n) }
1550
1550
  });
1551
1551
  }
1552
1552
  max(e, n) {
1553
- return new ne({
1553
+ return new se({
1554
1554
  ...this._def,
1555
1555
  maxLength: { value: e, message: b.toString(n) }
1556
1556
  });
1557
1557
  }
1558
1558
  length(e, n) {
1559
- return new ne({
1559
+ return new se({
1560
1560
  ...this._def,
1561
1561
  exactLength: { value: e, message: b.toString(n) }
1562
1562
  });
@@ -1565,7 +1565,7 @@ class ne extends T {
1565
1565
  return this.min(1, e);
1566
1566
  }
1567
1567
  }
1568
- ne.create = (t, e) => new ne({
1568
+ se.create = (t, e) => new se({
1569
1569
  type: t,
1570
1570
  minLength: null,
1571
1571
  maxLength: null,
@@ -1584,7 +1584,7 @@ function be(t) {
1584
1584
  ...t._def,
1585
1585
  shape: () => e
1586
1586
  });
1587
- } else return t instanceof ne ? new ne({
1587
+ } else return t instanceof se ? new se({
1588
1588
  ...t._def,
1589
1589
  type: be(t.element)
1590
1590
  }) : t instanceof le ? le.create(be(t.unwrap())) : t instanceof Se ? Se.create(be(t.unwrap())) : t instanceof he ? he.create(t.items.map((e) => be(e))) : t;
@@ -1608,16 +1608,16 @@ class I extends T {
1608
1608
  received: u.parsedType
1609
1609
  }), x;
1610
1610
  }
1611
- const { status: s, ctx: r } = this._processInputParams(e), { shape: a, keys: o } = this._getCached(), i = [];
1611
+ const { status: s, ctx: r } = this._processInputParams(e), { shape: o, keys: a } = this._getCached(), i = [];
1612
1612
  if (!(this._def.catchall instanceof de && this._def.unknownKeys === "strip"))
1613
1613
  for (const u in r.data)
1614
- o.includes(u) || i.push(u);
1614
+ a.includes(u) || i.push(u);
1615
1615
  const c = [];
1616
- for (const u of o) {
1617
- const v = a[u], R = r.data[u];
1616
+ for (const u of a) {
1617
+ const v = o[u], A = r.data[u];
1618
1618
  c.push({
1619
1619
  key: { status: "valid", value: u },
1620
- value: v._parse(new re(r, R, r.path, u)),
1620
+ value: v._parse(new re(r, A, r.path, u)),
1621
1621
  alwaysSet: u in r.data
1622
1622
  });
1623
1623
  }
@@ -1638,11 +1638,11 @@ class I extends T {
1638
1638
  } else {
1639
1639
  const u = this._def.catchall;
1640
1640
  for (const v of i) {
1641
- const R = r.data[v];
1641
+ const A = r.data[v];
1642
1642
  c.push({
1643
1643
  key: { status: "valid", value: v },
1644
1644
  value: u._parse(
1645
- new re(r, R, r.path, v)
1645
+ new re(r, A, r.path, v)
1646
1646
  //, ctx.child(key), value, getParsedType(value)
1647
1647
  ),
1648
1648
  alwaysSet: v in r.data
@@ -1652,9 +1652,9 @@ class I extends T {
1652
1652
  return r.common.async ? Promise.resolve().then(async () => {
1653
1653
  const u = [];
1654
1654
  for (const v of c) {
1655
- const R = await v.key, $ = await v.value;
1655
+ const A = await v.key, $ = await v.value;
1656
1656
  u.push({
1657
- key: R,
1657
+ key: A,
1658
1658
  value: $,
1659
1659
  alwaysSet: v.alwaysSet
1660
1660
  });
@@ -1671,8 +1671,8 @@ class I extends T {
1671
1671
  unknownKeys: "strict",
1672
1672
  ...e !== void 0 ? {
1673
1673
  errorMap: (n, s) => {
1674
- var a, o;
1675
- const r = ((o = (a = this._def).errorMap) == null ? void 0 : o.call(a, n, s).message) ?? s.defaultError;
1674
+ var o, a;
1675
+ const r = ((a = (o = this._def).errorMap) == null ? void 0 : a.call(o, n, s).message) ?? s.defaultError;
1676
1676
  return n.code === "unrecognized_keys" ? {
1677
1677
  message: b.errToObj(e).message ?? r
1678
1678
  } : {
@@ -1842,10 +1842,10 @@ class I extends T {
1842
1842
  if (e && !e[s])
1843
1843
  n[s] = this.shape[s];
1844
1844
  else {
1845
- let a = this.shape[s];
1846
- for (; a instanceof le; )
1847
- a = a._def.innerType;
1848
- n[s] = a;
1845
+ let o = this.shape[s];
1846
+ for (; o instanceof le; )
1847
+ o = o._def.innerType;
1848
+ n[s] = o;
1849
1849
  }
1850
1850
  return new I({
1851
1851
  ...this._def,
@@ -1853,7 +1853,7 @@ class I extends T {
1853
1853
  });
1854
1854
  }
1855
1855
  keyof() {
1856
- return on(O.objectKeys(this.shape));
1856
+ return dn(O.objectKeys(this.shape));
1857
1857
  }
1858
1858
  }
1859
1859
  I.create = (t, e) => new I({
@@ -1877,25 +1877,25 @@ I.lazycreate = (t, e) => new I({
1877
1877
  typeName: w.ZodObject,
1878
1878
  ...E(e)
1879
1879
  });
1880
- class Ve extends T {
1880
+ class Be extends T {
1881
1881
  _parse(e) {
1882
1882
  const { ctx: n } = this._processInputParams(e), s = this._def.options;
1883
- function r(a) {
1884
- for (const i of a)
1883
+ function r(o) {
1884
+ for (const i of o)
1885
1885
  if (i.result.status === "valid")
1886
1886
  return i.result;
1887
- for (const i of a)
1887
+ for (const i of o)
1888
1888
  if (i.result.status === "dirty")
1889
1889
  return n.common.issues.push(...i.ctx.common.issues), i.result;
1890
- const o = a.map((i) => new ce(i.ctx.common.issues));
1890
+ const a = o.map((i) => new ce(i.ctx.common.issues));
1891
1891
  return g(n, {
1892
1892
  code: h.invalid_union,
1893
- unionErrors: o
1893
+ unionErrors: a
1894
1894
  }), x;
1895
1895
  }
1896
1896
  if (n.common.async)
1897
- return Promise.all(s.map(async (a) => {
1898
- const o = {
1897
+ return Promise.all(s.map(async (o) => {
1898
+ const a = {
1899
1899
  ...n,
1900
1900
  common: {
1901
1901
  ...n.common,
@@ -1904,17 +1904,17 @@ class Ve extends T {
1904
1904
  parent: null
1905
1905
  };
1906
1906
  return {
1907
- result: await a._parseAsync({
1907
+ result: await o._parseAsync({
1908
1908
  data: n.data,
1909
1909
  path: n.path,
1910
- parent: o
1910
+ parent: a
1911
1911
  }),
1912
- ctx: o
1912
+ ctx: a
1913
1913
  };
1914
1914
  })).then(r);
1915
1915
  {
1916
- let a;
1917
- const o = [];
1916
+ let o;
1917
+ const a = [];
1918
1918
  for (const c of s) {
1919
1919
  const u = {
1920
1920
  ...n,
@@ -1930,11 +1930,11 @@ class Ve extends T {
1930
1930
  });
1931
1931
  if (v.status === "valid")
1932
1932
  return v;
1933
- v.status === "dirty" && !a && (a = { result: v, ctx: u }), u.common.issues.length && o.push(u.common.issues);
1933
+ v.status === "dirty" && !o && (o = { result: v, ctx: u }), u.common.issues.length && a.push(u.common.issues);
1934
1934
  }
1935
- if (a)
1936
- return n.common.issues.push(...a.ctx.common.issues), a.result;
1937
- const i = o.map((c) => new ce(c));
1935
+ if (o)
1936
+ return n.common.issues.push(...o.ctx.common.issues), o.result;
1937
+ const i = a.map((c) => new ce(c));
1938
1938
  return g(n, {
1939
1939
  code: h.invalid_union,
1940
1940
  unionErrors: i
@@ -1945,30 +1945,30 @@ class Ve extends T {
1945
1945
  return this._def.options;
1946
1946
  }
1947
1947
  }
1948
- Ve.create = (t, e) => new Ve({
1948
+ Be.create = (t, e) => new Be({
1949
1949
  options: t,
1950
1950
  typeName: w.ZodUnion,
1951
1951
  ...E(e)
1952
1952
  });
1953
- function ct(t, e) {
1953
+ function pt(t, e) {
1954
1954
  const n = ue(t), s = ue(e);
1955
1955
  if (t === e)
1956
1956
  return { valid: !0, data: t };
1957
1957
  if (n === m.object && s === m.object) {
1958
- const r = O.objectKeys(e), a = O.objectKeys(t).filter((i) => r.indexOf(i) !== -1), o = { ...t, ...e };
1959
- for (const i of a) {
1960
- const c = ct(t[i], e[i]);
1958
+ const r = O.objectKeys(e), o = O.objectKeys(t).filter((i) => r.indexOf(i) !== -1), a = { ...t, ...e };
1959
+ for (const i of o) {
1960
+ const c = pt(t[i], e[i]);
1961
1961
  if (!c.valid)
1962
1962
  return { valid: !1 };
1963
- o[i] = c.data;
1963
+ a[i] = c.data;
1964
1964
  }
1965
- return { valid: !0, data: o };
1965
+ return { valid: !0, data: a };
1966
1966
  } else if (n === m.array && s === m.array) {
1967
1967
  if (t.length !== e.length)
1968
1968
  return { valid: !1 };
1969
1969
  const r = [];
1970
- for (let a = 0; a < t.length; a++) {
1971
- const o = t[a], i = e[a], c = ct(o, i);
1970
+ for (let o = 0; o < t.length; o++) {
1971
+ const a = t[o], i = e[o], c = pt(a, i);
1972
1972
  if (!c.valid)
1973
1973
  return { valid: !1 };
1974
1974
  r.push(c.data);
@@ -1976,13 +1976,13 @@ function ct(t, e) {
1976
1976
  return { valid: !0, data: r };
1977
1977
  } else return n === m.date && s === m.date && +t == +e ? { valid: !0, data: t } : { valid: !1 };
1978
1978
  }
1979
- class ze extends T {
1979
+ class He extends T {
1980
1980
  _parse(e) {
1981
- const { status: n, ctx: s } = this._processInputParams(e), r = (a, o) => {
1982
- if (Et(a) || Et(o))
1981
+ const { status: n, ctx: s } = this._processInputParams(e), r = (o, a) => {
1982
+ if (Mt(o) || Mt(a))
1983
1983
  return x;
1984
- const i = ct(a.value, o.value);
1985
- return i.valid ? ((Nt(a) || Nt(o)) && n.dirty(), { status: n.value, value: i.data }) : (g(s, {
1984
+ const i = pt(o.value, a.value);
1985
+ return i.valid ? ((Rt(o) || Rt(a)) && n.dirty(), { status: n.value, value: i.data }) : (g(s, {
1986
1986
  code: h.invalid_intersection_types
1987
1987
  }), x);
1988
1988
  };
@@ -1997,7 +1997,7 @@ class ze extends T {
1997
1997
  path: s.path,
1998
1998
  parent: s
1999
1999
  })
2000
- ]).then(([a, o]) => r(a, o)) : r(this._def.left._parseSync({
2000
+ ]).then(([o, a]) => r(o, a)) : r(this._def.left._parseSync({
2001
2001
  data: s.data,
2002
2002
  path: s.path,
2003
2003
  parent: s
@@ -2008,7 +2008,7 @@ class ze extends T {
2008
2008
  }));
2009
2009
  }
2010
2010
  }
2011
- ze.create = (t, e, n) => new ze({
2011
+ He.create = (t, e, n) => new He({
2012
2012
  left: t,
2013
2013
  right: e,
2014
2014
  typeName: w.ZodIntersection,
@@ -2038,11 +2038,11 @@ class he extends T {
2038
2038
  exact: !1,
2039
2039
  type: "array"
2040
2040
  }), n.dirty());
2041
- const a = [...s.data].map((o, i) => {
2041
+ const o = [...s.data].map((a, i) => {
2042
2042
  const c = this._def.items[i] || this._def.rest;
2043
- return c ? c._parse(new re(s, o, s.path, i)) : null;
2044
- }).filter((o) => !!o);
2045
- return s.common.async ? Promise.all(a).then((o) => z.mergeArray(n, o)) : z.mergeArray(n, a);
2043
+ return c ? c._parse(new re(s, a, s.path, i)) : null;
2044
+ }).filter((a) => !!a);
2045
+ return s.common.async ? Promise.all(o).then((a) => z.mergeArray(n, a)) : z.mergeArray(n, o);
2046
2046
  }
2047
2047
  get items() {
2048
2048
  return this._def.items;
@@ -2064,7 +2064,7 @@ he.create = (t, e) => {
2064
2064
  ...E(e)
2065
2065
  });
2066
2066
  };
2067
- class Fe extends T {
2067
+ class Ke extends T {
2068
2068
  get keySchema() {
2069
2069
  return this._def.keyType;
2070
2070
  }
@@ -2079,11 +2079,11 @@ class Fe extends T {
2079
2079
  expected: m.object,
2080
2080
  received: s.parsedType
2081
2081
  }), x;
2082
- const r = [], a = this._def.keyType, o = this._def.valueType;
2082
+ const r = [], o = this._def.keyType, a = this._def.valueType;
2083
2083
  for (const i in s.data)
2084
2084
  r.push({
2085
- key: a._parse(new re(s, i, s.path, i)),
2086
- value: o._parse(new re(s, s.data[i], s.path, i)),
2085
+ key: o._parse(new re(s, i, s.path, i)),
2086
+ value: a._parse(new re(s, s.data[i], s.path, i)),
2087
2087
  alwaysSet: i in s.data
2088
2088
  });
2089
2089
  return s.common.async ? z.mergeObjectAsync(n, r) : z.mergeObjectSync(n, r);
@@ -2092,12 +2092,12 @@ class Fe extends T {
2092
2092
  return this._def.valueType;
2093
2093
  }
2094
2094
  static create(e, n, s) {
2095
- return n instanceof T ? new Fe({
2095
+ return n instanceof T ? new Ke({
2096
2096
  keyType: e,
2097
2097
  valueType: n,
2098
2098
  typeName: w.ZodRecord,
2099
2099
  ...E(s)
2100
- }) : new Fe({
2100
+ }) : new Ke({
2101
2101
  keyType: ie.create(),
2102
2102
  valueType: e,
2103
2103
  typeName: w.ZodRecord,
@@ -2105,7 +2105,7 @@ class Fe extends T {
2105
2105
  });
2106
2106
  }
2107
2107
  }
2108
- class $t extends T {
2108
+ class Dt extends T {
2109
2109
  get keySchema() {
2110
2110
  return this._def.keyType;
2111
2111
  }
@@ -2120,14 +2120,14 @@ class $t extends T {
2120
2120
  expected: m.map,
2121
2121
  received: s.parsedType
2122
2122
  }), x;
2123
- const r = this._def.keyType, a = this._def.valueType, o = [...s.data.entries()].map(([i, c], u) => ({
2123
+ const r = this._def.keyType, o = this._def.valueType, a = [...s.data.entries()].map(([i, c], u) => ({
2124
2124
  key: r._parse(new re(s, i, s.path, [u, "key"])),
2125
- value: a._parse(new re(s, c, s.path, [u, "value"]))
2125
+ value: o._parse(new re(s, c, s.path, [u, "value"]))
2126
2126
  }));
2127
2127
  if (s.common.async) {
2128
2128
  const i = /* @__PURE__ */ new Map();
2129
2129
  return Promise.resolve().then(async () => {
2130
- for (const c of o) {
2130
+ for (const c of a) {
2131
2131
  const u = await c.key, v = await c.value;
2132
2132
  if (u.status === "aborted" || v.status === "aborted")
2133
2133
  return x;
@@ -2137,7 +2137,7 @@ class $t extends T {
2137
2137
  });
2138
2138
  } else {
2139
2139
  const i = /* @__PURE__ */ new Map();
2140
- for (const c of o) {
2140
+ for (const c of a) {
2141
2141
  const u = c.key, v = c.value;
2142
2142
  if (u.status === "aborted" || v.status === "aborted")
2143
2143
  return x;
@@ -2147,13 +2147,13 @@ class $t extends T {
2147
2147
  }
2148
2148
  }
2149
2149
  }
2150
- $t.create = (t, e, n) => new $t({
2150
+ Dt.create = (t, e, n) => new Dt({
2151
2151
  valueType: e,
2152
2152
  keyType: t,
2153
2153
  typeName: w.ZodMap,
2154
2154
  ...E(n)
2155
2155
  });
2156
- class je extends T {
2156
+ class Le extends T {
2157
2157
  _parse(e) {
2158
2158
  const { status: n, ctx: s } = this._processInputParams(e);
2159
2159
  if (s.parsedType !== m.set)
@@ -2178,8 +2178,8 @@ class je extends T {
2178
2178
  exact: !1,
2179
2179
  message: r.maxSize.message
2180
2180
  }), n.dirty());
2181
- const a = this._def.valueType;
2182
- function o(c) {
2181
+ const o = this._def.valueType;
2182
+ function a(c) {
2183
2183
  const u = /* @__PURE__ */ new Set();
2184
2184
  for (const v of c) {
2185
2185
  if (v.status === "aborted")
@@ -2188,17 +2188,17 @@ class je extends T {
2188
2188
  }
2189
2189
  return { status: n.value, value: u };
2190
2190
  }
2191
- const i = [...s.data.values()].map((c, u) => a._parse(new re(s, c, s.path, u)));
2192
- return s.common.async ? Promise.all(i).then((c) => o(c)) : o(i);
2191
+ const i = [...s.data.values()].map((c, u) => o._parse(new re(s, c, s.path, u)));
2192
+ return s.common.async ? Promise.all(i).then((c) => a(c)) : a(i);
2193
2193
  }
2194
2194
  min(e, n) {
2195
- return new je({
2195
+ return new Le({
2196
2196
  ...this._def,
2197
2197
  minSize: { value: e, message: b.toString(n) }
2198
2198
  });
2199
2199
  }
2200
2200
  max(e, n) {
2201
- return new je({
2201
+ return new Le({
2202
2202
  ...this._def,
2203
2203
  maxSize: { value: e, message: b.toString(n) }
2204
2204
  });
@@ -2210,14 +2210,14 @@ class je extends T {
2210
2210
  return this.min(1, e);
2211
2211
  }
2212
2212
  }
2213
- je.create = (t, e) => new je({
2213
+ Le.create = (t, e) => new Le({
2214
2214
  valueType: t,
2215
2215
  minSize: null,
2216
2216
  maxSize: null,
2217
2217
  typeName: w.ZodSet,
2218
2218
  ...E(e)
2219
2219
  });
2220
- class Pt extends T {
2220
+ class Zt extends T {
2221
2221
  get schema() {
2222
2222
  return this._def.getter();
2223
2223
  }
@@ -2226,12 +2226,12 @@ class Pt extends T {
2226
2226
  return this._def.getter()._parse({ data: n.data, path: n.path, parent: n });
2227
2227
  }
2228
2228
  }
2229
- Pt.create = (t, e) => new Pt({
2229
+ Zt.create = (t, e) => new Zt({
2230
2230
  getter: t,
2231
2231
  typeName: w.ZodLazy,
2232
2232
  ...E(e)
2233
2233
  });
2234
- class ut extends T {
2234
+ class gt extends T {
2235
2235
  _parse(e) {
2236
2236
  if (e.data !== this._def.value) {
2237
2237
  const n = this._getOrReturnCtx(e);
@@ -2247,12 +2247,12 @@ class ut extends T {
2247
2247
  return this._def.value;
2248
2248
  }
2249
2249
  }
2250
- ut.create = (t, e) => new ut({
2250
+ gt.create = (t, e) => new gt({
2251
2251
  value: t,
2252
2252
  typeName: w.ZodLiteral,
2253
2253
  ...E(e)
2254
2254
  });
2255
- function on(t, e) {
2255
+ function dn(t, e) {
2256
2256
  return new we({
2257
2257
  values: t,
2258
2258
  typeName: w.ZodEnum,
@@ -2277,7 +2277,7 @@ class we extends T {
2277
2277
  options: s
2278
2278
  }), x;
2279
2279
  }
2280
- return J(e.data);
2280
+ return Q(e.data);
2281
2281
  }
2282
2282
  get options() {
2283
2283
  return this._def.values;
@@ -2313,8 +2313,8 @@ class we extends T {
2313
2313
  });
2314
2314
  }
2315
2315
  }
2316
- we.create = on;
2317
- class Lt extends T {
2316
+ we.create = dn;
2317
+ class Gt extends T {
2318
2318
  _parse(e) {
2319
2319
  const n = O.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
2320
2320
  if (s.parsedType !== m.string && s.parsedType !== m.number) {
@@ -2333,18 +2333,18 @@ class Lt extends T {
2333
2333
  options: r
2334
2334
  }), x;
2335
2335
  }
2336
- return J(e.data);
2336
+ return Q(e.data);
2337
2337
  }
2338
2338
  get enum() {
2339
2339
  return this._def.values;
2340
2340
  }
2341
2341
  }
2342
- Lt.create = (t, e) => new Lt({
2342
+ Gt.create = (t, e) => new Gt({
2343
2343
  values: t,
2344
2344
  typeName: w.ZodNativeEnum,
2345
2345
  ...E(e)
2346
2346
  });
2347
- class Be extends T {
2347
+ class Ye extends T {
2348
2348
  unwrap() {
2349
2349
  return this._def.type;
2350
2350
  }
@@ -2357,13 +2357,13 @@ class Be extends T {
2357
2357
  received: n.parsedType
2358
2358
  }), x;
2359
2359
  const s = n.parsedType === m.promise ? n.data : Promise.resolve(n.data);
2360
- return J(s.then((r) => this._def.type.parseAsync(r, {
2360
+ return Q(s.then((r) => this._def.type.parseAsync(r, {
2361
2361
  path: n.path,
2362
2362
  errorMap: n.common.contextualErrorMap
2363
2363
  })));
2364
2364
  }
2365
2365
  }
2366
- Be.create = (t, e) => new Be({
2366
+ Ye.create = (t, e) => new Ye({
2367
2367
  type: t,
2368
2368
  typeName: w.ZodPromise,
2369
2369
  ...E(e)
@@ -2376,18 +2376,18 @@ class xe extends T {
2376
2376
  return this._def.schema._def.typeName === w.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
2377
2377
  }
2378
2378
  _parse(e) {
2379
- const { status: n, ctx: s } = this._processInputParams(e), r = this._def.effect || null, a = {
2380
- addIssue: (o) => {
2381
- g(s, o), o.fatal ? n.abort() : n.dirty();
2379
+ const { status: n, ctx: s } = this._processInputParams(e), r = this._def.effect || null, o = {
2380
+ addIssue: (a) => {
2381
+ g(s, a), a.fatal ? n.abort() : n.dirty();
2382
2382
  },
2383
2383
  get path() {
2384
2384
  return s.path;
2385
2385
  }
2386
2386
  };
2387
- if (a.addIssue = a.addIssue.bind(a), r.type === "preprocess") {
2388
- const o = r.transform(s.data, a);
2387
+ if (o.addIssue = o.addIssue.bind(o), r.type === "preprocess") {
2388
+ const a = r.transform(s.data, o);
2389
2389
  if (s.common.async)
2390
- return Promise.resolve(o).then(async (i) => {
2390
+ return Promise.resolve(a).then(async (i) => {
2391
2391
  if (n.value === "aborted")
2392
2392
  return x;
2393
2393
  const c = await this._def.schema._parseAsync({
@@ -2395,22 +2395,22 @@ class xe extends T {
2395
2395
  path: s.path,
2396
2396
  parent: s
2397
2397
  });
2398
- return c.status === "aborted" ? x : c.status === "dirty" || n.value === "dirty" ? Te(c.value) : c;
2398
+ return c.status === "aborted" ? x : c.status === "dirty" || n.value === "dirty" ? Oe(c.value) : c;
2399
2399
  });
2400
2400
  {
2401
2401
  if (n.value === "aborted")
2402
2402
  return x;
2403
2403
  const i = this._def.schema._parseSync({
2404
- data: o,
2404
+ data: a,
2405
2405
  path: s.path,
2406
2406
  parent: s
2407
2407
  });
2408
- return i.status === "aborted" ? x : i.status === "dirty" || n.value === "dirty" ? Te(i.value) : i;
2408
+ return i.status === "aborted" ? x : i.status === "dirty" || n.value === "dirty" ? Oe(i.value) : i;
2409
2409
  }
2410
2410
  }
2411
2411
  if (r.type === "refinement") {
2412
- const o = (i) => {
2413
- const c = r.refinement(i, a);
2412
+ const a = (i) => {
2413
+ const c = r.refinement(i, o);
2414
2414
  if (s.common.async)
2415
2415
  return Promise.resolve(c);
2416
2416
  if (c instanceof Promise)
@@ -2423,25 +2423,25 @@ class xe extends T {
2423
2423
  path: s.path,
2424
2424
  parent: s
2425
2425
  });
2426
- return i.status === "aborted" ? x : (i.status === "dirty" && n.dirty(), o(i.value), { status: n.value, value: i.value });
2426
+ return i.status === "aborted" ? x : (i.status === "dirty" && n.dirty(), a(i.value), { status: n.value, value: i.value });
2427
2427
  } else
2428
- return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((i) => i.status === "aborted" ? x : (i.status === "dirty" && n.dirty(), o(i.value).then(() => ({ status: n.value, value: i.value }))));
2428
+ return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((i) => i.status === "aborted" ? x : (i.status === "dirty" && n.dirty(), a(i.value).then(() => ({ status: n.value, value: i.value }))));
2429
2429
  }
2430
2430
  if (r.type === "transform")
2431
2431
  if (s.common.async === !1) {
2432
- const o = this._def.schema._parseSync({
2432
+ const a = this._def.schema._parseSync({
2433
2433
  data: s.data,
2434
2434
  path: s.path,
2435
2435
  parent: s
2436
2436
  });
2437
- if (!ke(o))
2437
+ if (!ke(a))
2438
2438
  return x;
2439
- const i = r.transform(o.value, a);
2439
+ const i = r.transform(a.value, o);
2440
2440
  if (i instanceof Promise)
2441
2441
  throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
2442
2442
  return { status: n.value, value: i };
2443
2443
  } else
2444
- return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((o) => ke(o) ? Promise.resolve(r.transform(o.value, a)).then((i) => ({
2444
+ return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((a) => ke(a) ? Promise.resolve(r.transform(a.value, o)).then((i) => ({
2445
2445
  status: n.value,
2446
2446
  value: i
2447
2447
  })) : x);
@@ -2462,7 +2462,7 @@ xe.createWithPreprocess = (t, e, n) => new xe({
2462
2462
  });
2463
2463
  class le extends T {
2464
2464
  _parse(e) {
2465
- return this._getType(e) === m.undefined ? J(void 0) : this._def.innerType._parse(e);
2465
+ return this._getType(e) === m.undefined ? Q(void 0) : this._def.innerType._parse(e);
2466
2466
  }
2467
2467
  unwrap() {
2468
2468
  return this._def.innerType;
@@ -2475,7 +2475,7 @@ le.create = (t, e) => new le({
2475
2475
  });
2476
2476
  class Se extends T {
2477
2477
  _parse(e) {
2478
- return this._getType(e) === m.null ? J(null) : this._def.innerType._parse(e);
2478
+ return this._getType(e) === m.null ? Q(null) : this._def.innerType._parse(e);
2479
2479
  }
2480
2480
  unwrap() {
2481
2481
  return this._def.innerType;
@@ -2486,7 +2486,7 @@ Se.create = (t, e) => new Se({
2486
2486
  typeName: w.ZodNullable,
2487
2487
  ...E(e)
2488
2488
  });
2489
- class lt extends T {
2489
+ class yt extends T {
2490
2490
  _parse(e) {
2491
2491
  const { ctx: n } = this._processInputParams(e);
2492
2492
  let s = n.data;
@@ -2500,13 +2500,13 @@ class lt extends T {
2500
2500
  return this._def.innerType;
2501
2501
  }
2502
2502
  }
2503
- lt.create = (t, e) => new lt({
2503
+ yt.create = (t, e) => new yt({
2504
2504
  innerType: t,
2505
2505
  typeName: w.ZodDefault,
2506
2506
  defaultValue: typeof e.default == "function" ? e.default : () => e.default,
2507
2507
  ...E(e)
2508
2508
  });
2509
- class dt extends T {
2509
+ class mt extends T {
2510
2510
  _parse(e) {
2511
2511
  const { ctx: n } = this._processInputParams(e), s = {
2512
2512
  ...n,
@@ -2521,9 +2521,9 @@ class dt extends T {
2521
2521
  ...s
2522
2522
  }
2523
2523
  });
2524
- return qe(r) ? r.then((a) => ({
2524
+ return ze(r) ? r.then((o) => ({
2525
2525
  status: "valid",
2526
- value: a.status === "valid" ? a.value : this._def.catchValue({
2526
+ value: o.status === "valid" ? o.value : this._def.catchValue({
2527
2527
  get error() {
2528
2528
  return new ce(s.common.issues);
2529
2529
  },
@@ -2543,13 +2543,13 @@ class dt extends T {
2543
2543
  return this._def.innerType;
2544
2544
  }
2545
2545
  }
2546
- dt.create = (t, e) => new dt({
2546
+ mt.create = (t, e) => new mt({
2547
2547
  innerType: t,
2548
2548
  typeName: w.ZodCatch,
2549
2549
  catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
2550
2550
  ...E(e)
2551
2551
  });
2552
- class It extends T {
2552
+ class Wt extends T {
2553
2553
  _parse(e) {
2554
2554
  if (this._getType(e) !== m.nan) {
2555
2555
  const s = this._getOrReturnCtx(e);
@@ -2562,11 +2562,11 @@ class It extends T {
2562
2562
  return { status: "valid", value: e.data };
2563
2563
  }
2564
2564
  }
2565
- It.create = (t) => new It({
2565
+ Wt.create = (t) => new Wt({
2566
2566
  typeName: w.ZodNaN,
2567
2567
  ...E(t)
2568
2568
  });
2569
- class vs extends T {
2569
+ class Ss extends T {
2570
2570
  _parse(e) {
2571
2571
  const { ctx: n } = this._processInputParams(e), s = n.data;
2572
2572
  return this._def.type._parse({
@@ -2579,18 +2579,18 @@ class vs extends T {
2579
2579
  return this._def.type;
2580
2580
  }
2581
2581
  }
2582
- class mt extends T {
2582
+ class xt extends T {
2583
2583
  _parse(e) {
2584
2584
  const { status: n, ctx: s } = this._processInputParams(e);
2585
2585
  if (s.common.async)
2586
2586
  return (async () => {
2587
- const a = await this._def.in._parseAsync({
2587
+ const o = await this._def.in._parseAsync({
2588
2588
  data: s.data,
2589
2589
  path: s.path,
2590
2590
  parent: s
2591
2591
  });
2592
- return a.status === "aborted" ? x : a.status === "dirty" ? (n.dirty(), Te(a.value)) : this._def.out._parseAsync({
2593
- data: a.value,
2592
+ return o.status === "aborted" ? x : o.status === "dirty" ? (n.dirty(), Oe(o.value)) : this._def.out._parseAsync({
2593
+ data: o.value,
2594
2594
  path: s.path,
2595
2595
  parent: s
2596
2596
  });
@@ -2612,64 +2612,64 @@ class mt extends T {
2612
2612
  }
2613
2613
  }
2614
2614
  static create(e, n) {
2615
- return new mt({
2615
+ return new xt({
2616
2616
  in: e,
2617
2617
  out: n,
2618
2618
  typeName: w.ZodPipeline
2619
2619
  });
2620
2620
  }
2621
2621
  }
2622
- class ft extends T {
2622
+ class bt extends T {
2623
2623
  _parse(e) {
2624
2624
  const n = this._def.innerType._parse(e), s = (r) => (ke(r) && (r.value = Object.freeze(r.value)), r);
2625
- return qe(n) ? n.then((r) => s(r)) : s(n);
2625
+ return ze(n) ? n.then((r) => s(r)) : s(n);
2626
2626
  }
2627
2627
  unwrap() {
2628
2628
  return this._def.innerType;
2629
2629
  }
2630
2630
  }
2631
- ft.create = (t, e) => new ft({
2631
+ bt.create = (t, e) => new bt({
2632
2632
  innerType: t,
2633
2633
  typeName: w.ZodReadonly,
2634
2634
  ...E(e)
2635
2635
  });
2636
- function Dt(t, e) {
2636
+ function qt(t, e) {
2637
2637
  const n = typeof t == "function" ? t(e) : typeof t == "string" ? { message: t } : t;
2638
2638
  return typeof n == "string" ? { message: n } : n;
2639
2639
  }
2640
- function ks(t, e = {}, n) {
2641
- return t ? Re.create().superRefine((s, r) => {
2642
- const a = t(s);
2643
- if (a instanceof Promise)
2644
- return a.then((o) => {
2645
- if (!o) {
2646
- const i = Dt(e, s), c = i.fatal ?? n ?? !0;
2640
+ function Cs(t, e = {}, n) {
2641
+ return t ? je.create().superRefine((s, r) => {
2642
+ const o = t(s);
2643
+ if (o instanceof Promise)
2644
+ return o.then((a) => {
2645
+ if (!a) {
2646
+ const i = qt(e, s), c = i.fatal ?? n ?? !0;
2647
2647
  r.addIssue({ code: "custom", ...i, fatal: c });
2648
2648
  }
2649
2649
  });
2650
- if (!a) {
2651
- const o = Dt(e, s), i = o.fatal ?? n ?? !0;
2652
- r.addIssue({ code: "custom", ...o, fatal: i });
2650
+ if (!o) {
2651
+ const a = qt(e, s), i = a.fatal ?? n ?? !0;
2652
+ r.addIssue({ code: "custom", ...a, fatal: i });
2653
2653
  }
2654
- }) : Re.create();
2654
+ }) : je.create();
2655
2655
  }
2656
2656
  var w;
2657
2657
  (function(t) {
2658
2658
  t.ZodString = "ZodString", t.ZodNumber = "ZodNumber", t.ZodNaN = "ZodNaN", t.ZodBigInt = "ZodBigInt", t.ZodBoolean = "ZodBoolean", t.ZodDate = "ZodDate", t.ZodSymbol = "ZodSymbol", t.ZodUndefined = "ZodUndefined", t.ZodNull = "ZodNull", t.ZodAny = "ZodAny", t.ZodUnknown = "ZodUnknown", t.ZodNever = "ZodNever", t.ZodVoid = "ZodVoid", t.ZodArray = "ZodArray", t.ZodObject = "ZodObject", t.ZodUnion = "ZodUnion", t.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", t.ZodIntersection = "ZodIntersection", t.ZodTuple = "ZodTuple", t.ZodRecord = "ZodRecord", t.ZodMap = "ZodMap", t.ZodSet = "ZodSet", t.ZodFunction = "ZodFunction", t.ZodLazy = "ZodLazy", t.ZodLiteral = "ZodLiteral", t.ZodEnum = "ZodEnum", t.ZodEffects = "ZodEffects", t.ZodNativeEnum = "ZodNativeEnum", t.ZodOptional = "ZodOptional", t.ZodNullable = "ZodNullable", t.ZodDefault = "ZodDefault", t.ZodCatch = "ZodCatch", t.ZodPromise = "ZodPromise", t.ZodBranded = "ZodBranded", t.ZodPipeline = "ZodPipeline", t.ZodReadonly = "ZodReadonly";
2659
2659
  })(w || (w = {}));
2660
- const _s = (t, e = {
2660
+ const Es = (t, e = {
2661
2661
  message: `Input not instance of ${t.name}`
2662
- }) => ks((n) => n instanceof t, e), D = ie.create, Q = _e.create, ht = it.create;
2663
- Re.create;
2662
+ }) => Cs((n) => n instanceof t, e), D = ie.create, ee = _e.create, vt = ht.create;
2663
+ je.create;
2664
2664
  de.create;
2665
- const W = ne.create, L = I.create, cn = Ve.create;
2666
- ze.create;
2665
+ const W = se.create, L = I.create, fn = Be.create;
2666
+ He.create;
2667
2667
  he.create;
2668
- const un = Fe.create, ws = ut.create, Pe = we.create;
2669
- Be.create;
2668
+ const hn = Ke.create, Ns = gt.create, De = we.create;
2669
+ Ye.create;
2670
2670
  le.create;
2671
2671
  Se.create;
2672
- const xs = {
2672
+ const Ts = {
2673
2673
  network: {
2674
2674
  failures: "network.failure",
2675
2675
  latencies: "network.latency",
@@ -2693,13 +2693,13 @@ const xs = {
2693
2693
  closes: "sse.close"
2694
2694
  }
2695
2695
  };
2696
- function Ss(t) {
2696
+ function Os(t) {
2697
2697
  if (t.length === 0) return "top-level";
2698
2698
  const e = t[0];
2699
2699
  if (e === "groups") return "group";
2700
2700
  if (e === "presets" || e === "customPresets") return "preset";
2701
2701
  if (typeof e == "string") {
2702
- const n = xs[e];
2702
+ const n = Ts[e];
2703
2703
  if (n && typeof t[1] == "string") {
2704
2704
  const s = n[t[1]];
2705
2705
  if (s) return s;
@@ -2707,23 +2707,23 @@ function Ss(t) {
2707
2707
  }
2708
2708
  return "top-level";
2709
2709
  }
2710
- function Cs(t) {
2710
+ function Ms(t) {
2711
2711
  let e = "";
2712
2712
  for (const n of t)
2713
2713
  typeof n == "number" ? e += `[${n}]` : e += e.length === 0 ? n : `.${n}`;
2714
2714
  return e;
2715
2715
  }
2716
- function Zt(t, e = 80) {
2716
+ function Ut(t, e = 80) {
2717
2717
  return t.length <= e ? t : `${t.slice(0, e - 1)}…`;
2718
2718
  }
2719
- function Es(t) {
2719
+ function Rs(t) {
2720
2720
  try {
2721
2721
  return t === void 0 ? "undefined" : JSON.stringify(t) ?? String(t);
2722
2722
  } catch {
2723
2723
  return "<unserializable>";
2724
2724
  }
2725
2725
  }
2726
- function Ns(t) {
2726
+ function As(t) {
2727
2727
  switch (t.code) {
2728
2728
  case h.unrecognized_keys:
2729
2729
  return "unknown_field";
@@ -2748,7 +2748,7 @@ function Ns(t) {
2748
2748
  return "custom";
2749
2749
  }
2750
2750
  }
2751
- function Ts(t) {
2751
+ function Ps(t) {
2752
2752
  switch (t.code) {
2753
2753
  case h.invalid_type:
2754
2754
  return t.expected;
@@ -2764,46 +2764,46 @@ function Ts(t) {
2764
2764
  return;
2765
2765
  }
2766
2766
  }
2767
- function Os(t) {
2767
+ function $s(t) {
2768
2768
  if (t.code === h.invalid_type)
2769
2769
  return t.received;
2770
2770
  if (t.code === h.invalid_enum_value)
2771
- return Zt(Es(t.received));
2771
+ return Ut(Rs(t.received));
2772
2772
  if (t.code === h.unrecognized_keys)
2773
- return Zt(t.keys.map((e) => JSON.stringify(e)).join(", "));
2773
+ return Ut(t.keys.map((e) => JSON.stringify(e)).join(", "));
2774
2774
  }
2775
- function ln(t) {
2775
+ function pn(t) {
2776
2776
  return {
2777
- path: Cs(t.path),
2778
- code: Ns(t),
2779
- ruleType: Ss(t.path),
2777
+ path: Ms(t.path),
2778
+ code: As(t),
2779
+ ruleType: Os(t.path),
2780
2780
  message: t.message,
2781
- expected: Ts(t),
2782
- received: Os(t)
2781
+ expected: Ps(t),
2782
+ received: $s(t)
2783
2783
  };
2784
2784
  }
2785
- function As(t) {
2785
+ function js(t) {
2786
2786
  return [...t].sort((e, n) => e.path < n.path ? -1 : e.path > n.path ? 1 : e.code < n.code ? -1 : e.code > n.code ? 1 : 0);
2787
2787
  }
2788
- function Ms(t, e = {}) {
2789
- const n = e.maxIssues ?? 50, s = t.slice(0, n), r = Math.max(0, t.length - n), a = s.map((o) => {
2790
- let i = `[${o.ruleType}] ${o.path || "<root>"} (${o.code}): ${o.message}`;
2791
- return o.expected !== void 0 && (i += `, expected ${o.expected}`), o.received !== void 0 && (i += `, received ${o.received}`), i;
2788
+ function Ls(t, e = {}) {
2789
+ const n = e.maxIssues ?? 50, s = t.slice(0, n), r = Math.max(0, t.length - n), o = s.map((a) => {
2790
+ let i = `[${a.ruleType}] ${a.path || "<root>"} (${a.code}): ${a.message}`;
2791
+ return a.expected !== void 0 && (i += `, expected ${a.expected}`), a.received !== void 0 && (i += `, received ${a.received}`), i;
2792
2792
  });
2793
- return r > 0 && a.push(`... and ${r} more`), `Invalid ChaosConfig:
2794
- ${a.map((o) => ` - ${o}`).join(`
2793
+ return r > 0 && o.push(`... and ${r} more`), `Invalid ChaosConfig:
2794
+ ${o.map((a) => ` - ${a}`).join(`
2795
2795
  `)}`;
2796
2796
  }
2797
2797
  class ve extends Error {
2798
2798
  constructor(n) {
2799
- const s = Rs(n) ? n.map((a) => ({
2799
+ const s = Is(n) ? n.map((o) => ({
2800
2800
  path: "",
2801
2801
  code: "legacy",
2802
2802
  ruleType: "top-level",
2803
- message: a
2804
- })) : n, r = As(s);
2805
- super(Ms(r, { maxIssues: 50 }));
2806
- A(this, "issues");
2803
+ message: o
2804
+ })) : n, r = js(s);
2805
+ super(Ls(r, { maxIssues: 50 }));
2806
+ M(this, "issues");
2807
2807
  this.name = "ChaosConfigError", this.issues = r;
2808
2808
  }
2809
2809
  /** v0.4.x-shaped string array. Concatenates `path` + `message` per issue
@@ -2813,19 +2813,19 @@ class ve extends Error {
2813
2813
  return this.issues.map((n) => `${n.path || "<root>"}: ${n.message}`);
2814
2814
  }
2815
2815
  }
2816
- function Rs(t) {
2816
+ function Is(t) {
2817
2817
  return t.length > 0 && typeof t[0] == "string";
2818
2818
  }
2819
- const He = "default";
2820
- class js {
2819
+ const Xe = "default";
2820
+ class Ds {
2821
2821
  constructor() {
2822
- A(this, "groups", /* @__PURE__ */ new Map());
2822
+ M(this, "groups", /* @__PURE__ */ new Map());
2823
2823
  /**
2824
2824
  * Tracks groups that have already emitted a `rule-group:gated` event since
2825
2825
  * the last toggle. Cleared on every `setEnabled()` so the next toggle cycle
2826
2826
  * gets a fresh diagnostic event without flooding.
2827
2827
  */
2828
- A(this, "gatedEmitted", /* @__PURE__ */ new Set());
2828
+ M(this, "gatedEmitted", /* @__PURE__ */ new Set());
2829
2829
  }
2830
2830
  /**
2831
2831
  * Look up an existing group or create a new one.
@@ -2858,7 +2858,7 @@ class js {
2858
2858
  * backward compat.
2859
2859
  */
2860
2860
  isActive(e) {
2861
- return this.ensure(e ?? He).enabled;
2861
+ return this.ensure(e ?? Xe).enabled;
2862
2862
  }
2863
2863
  /** True when this group should emit a `rule-group:gated` event right now (first block since last toggle). */
2864
2864
  shouldEmitGated(e) {
@@ -2875,7 +2875,7 @@ class js {
2875
2875
  * calls auto-recreate the group (default-on).
2876
2876
  */
2877
2877
  remove(e, n, s) {
2878
- if (e === He) return !1;
2878
+ if (e === Xe) return !1;
2879
2879
  if (!(s != null && s.force) && n.has(e))
2880
2880
  throw new Error(
2881
2881
  `[chaos-maker] Cannot remove group '${e}': still referenced by one or more rules. Pass { force: true } to override.`
@@ -2894,31 +2894,31 @@ class js {
2894
2894
  return e;
2895
2895
  }
2896
2896
  }
2897
- function $e(t) {
2897
+ function Ie(t) {
2898
2898
  if (t === null || typeof t != "object") return t;
2899
2899
  if (t instanceof RegExp)
2900
2900
  return new RegExp(t.source, t.flags);
2901
2901
  if (Array.isArray(t))
2902
- return t.map((n) => $e(n));
2902
+ return t.map((n) => Ie(n));
2903
2903
  const e = {};
2904
2904
  for (const [n, s] of Object.entries(t))
2905
- e[n] = $e(s);
2905
+ e[n] = Ie(s);
2906
2906
  return e;
2907
2907
  }
2908
2908
  function U(t, e) {
2909
2909
  return e() < t;
2910
2910
  }
2911
- function ee(t, e) {
2911
+ function te(t, e) {
2912
2912
  const n = (e.get(t) ?? 0) + 1;
2913
2913
  return e.set(t, n), n;
2914
2914
  }
2915
- function te(t, e) {
2915
+ function ne(t, e) {
2916
2916
  return t.onNth !== void 0 ? e === t.onNth : t.everyNth !== void 0 ? e % t.everyNth === 0 : t.afterN !== void 0 ? e > t.afterN : !0;
2917
2917
  }
2918
2918
  function pe(t, e) {
2919
2919
  return e === "*" ? !0 : t.includes(e);
2920
2920
  }
2921
- function bt(t, e) {
2921
+ function St(t, e) {
2922
2922
  switch (e) {
2923
2923
  case "truncate":
2924
2924
  return t.slice(0, Math.max(0, Math.floor(t.length / 2)));
@@ -2932,7 +2932,7 @@ function bt(t, e) {
2932
2932
  }
2933
2933
  function V(t, e, n, s) {
2934
2934
  if (!e || e.isActive(t.group)) return !0;
2935
- const r = t.group ?? He;
2935
+ const r = t.group ?? Xe;
2936
2936
  return e.shouldEmitGated(r) && n && n.emit({
2937
2937
  type: "rule-group:gated",
2938
2938
  timestamp: Date.now(),
@@ -2940,87 +2940,107 @@ function V(t, e, n, s) {
2940
2940
  detail: { ...s, groupName: r }
2941
2941
  }), n == null || n.debug("rule-skip-group", { ...s, groupName: r }, t), !1;
2942
2942
  }
2943
- function Gt(t, e) {
2944
- var s, r, a, o, i, c, u, v, R, $, F, X, q, p;
2943
+ function Vt(t, e) {
2944
+ var s, r, o, a, i, c, u, v, A, $, F, X, q, p;
2945
2945
  const n = (l) => {
2946
2946
  if (l)
2947
2947
  for (const f of l) e(f);
2948
2948
  };
2949
- n((s = t.network) == null ? void 0 : s.failures), n((r = t.network) == null ? void 0 : r.latencies), n((a = t.network) == null ? void 0 : a.aborts), n((o = t.network) == null ? void 0 : o.corruptions), n((i = t.network) == null ? void 0 : i.cors), n((c = t.ui) == null ? void 0 : c.assaults), n((u = t.websocket) == null ? void 0 : u.drops), n((v = t.websocket) == null ? void 0 : v.delays), n((R = t.websocket) == null ? void 0 : R.corruptions), n(($ = t.websocket) == null ? void 0 : $.closes), n((F = t.sse) == null ? void 0 : F.drops), n((X = t.sse) == null ? void 0 : X.delays), n((q = t.sse) == null ? void 0 : q.corruptions), n((p = t.sse) == null ? void 0 : p.closes);
2949
+ n((s = t.network) == null ? void 0 : s.failures), n((r = t.network) == null ? void 0 : r.latencies), n((o = t.network) == null ? void 0 : o.aborts), n((a = t.network) == null ? void 0 : a.corruptions), n((i = t.network) == null ? void 0 : i.cors), n((c = t.ui) == null ? void 0 : c.assaults), n((u = t.websocket) == null ? void 0 : u.drops), n((v = t.websocket) == null ? void 0 : v.delays), n((A = t.websocket) == null ? void 0 : A.corruptions), n(($ = t.websocket) == null ? void 0 : $.closes), n((F = t.sse) == null ? void 0 : F.drops), n((X = t.sse) == null ? void 0 : X.delays), n((q = t.sse) == null ? void 0 : q.corruptions), n((p = t.sse) == null ? void 0 : p.closes);
2950
2950
  }
2951
- const se = "*", Ye = {
2951
+ const J = "*", Je = {
2952
2952
  network: {
2953
- latencies: [{ urlPattern: se, delayMs: 2e3, probability: 1 }]
2953
+ latencies: [{ urlPattern: J, delayMs: 2e3, probability: 1 }]
2954
2954
  }
2955
- }, Ke = {
2955
+ }, Me = {
2956
2956
  network: {
2957
- aborts: [{ urlPattern: se, probability: 0.05 }],
2958
- latencies: [{ urlPattern: se, delayMs: 3e3, probability: 0.1 }]
2957
+ aborts: [{ urlPattern: J, probability: 0.05 }],
2958
+ latencies: [{ urlPattern: J, delayMs: 3e3, probability: 0.1 }]
2959
2959
  }
2960
- }, Xe = {
2960
+ }, Qe = {
2961
2961
  network: {
2962
- cors: [{ urlPattern: se, probability: 1 }]
2962
+ cors: [{ urlPattern: J, probability: 1 }]
2963
2963
  }
2964
- }, Je = {
2964
+ }, et = {
2965
2965
  network: {
2966
2966
  failures: [{ urlPattern: "/api/", statusCode: 500, probability: 0.1 }],
2967
2967
  latencies: [{ urlPattern: "/api/", delayMs: 1e3, probability: 0.2 }]
2968
2968
  }
2969
- }, vt = {
2969
+ }, Ct = {
2970
2970
  ui: {
2971
2971
  assaults: [
2972
2972
  { selector: "button", action: "disable", probability: 0.2 },
2973
2973
  { selector: "a", action: "hide", probability: 0.1 }
2974
2974
  ]
2975
2975
  }
2976
- }, kt = {
2976
+ }, tt = {
2977
2977
  websocket: {
2978
- drops: [{ urlPattern: se, direction: "both", probability: 0.1 }],
2979
- delays: [{ urlPattern: se, direction: "inbound", delayMs: 500, probability: 1 }],
2980
- corruptions: [{ urlPattern: se, direction: "inbound", strategy: "truncate", probability: 0.05 }]
2978
+ drops: [{ urlPattern: J, direction: "both", probability: 0.1 }],
2979
+ delays: [{ urlPattern: J, direction: "inbound", delayMs: 500, probability: 1 }],
2980
+ corruptions: [{ urlPattern: J, direction: "inbound", strategy: "truncate", probability: 0.05 }]
2981
2981
  }
2982
- }, _t = {
2982
+ }, nt = {
2983
2983
  sse: {
2984
- drops: [{ urlPattern: se, probability: 0.05 }],
2985
- delays: [{ urlPattern: se, delayMs: 200, probability: 1 }],
2986
- closes: [{ urlPattern: se, probability: 0.02, afterMs: 2e3 }]
2984
+ drops: [{ urlPattern: J, probability: 0.05 }],
2985
+ delays: [{ urlPattern: J, delayMs: 200, probability: 1 }],
2986
+ closes: [{ urlPattern: J, probability: 0.02, afterMs: 2e3 }]
2987
+ }
2988
+ }, st = {
2989
+ network: {
2990
+ latencies: [{ urlPattern: J, delayMs: 1500, probability: 1 }],
2991
+ aborts: [{ urlPattern: J, probability: 0.02 }]
2992
+ }
2993
+ }, rt = {
2994
+ network: {
2995
+ latencies: [{ urlPattern: "/checkout", delayMs: 800, probability: 0.3 }],
2996
+ failures: [
2997
+ { urlPattern: "/checkout", statusCode: 503, probability: 0.05 },
2998
+ { urlPattern: "/api/payments", statusCode: 500, probability: 0.1 }
2999
+ ]
2987
3000
  }
2988
3001
  };
2989
- function dn(t) {
3002
+ function gn(t) {
2990
3003
  if (t && typeof t == "object" && !Object.isFrozen(t)) {
2991
3004
  Object.freeze(t);
2992
- for (const e of Object.values(t)) dn(e);
3005
+ for (const e of Object.values(t)) gn(e);
2993
3006
  }
2994
3007
  return t;
2995
3008
  }
2996
- [Ye, Ke, Xe, Je, vt, kt, _t].forEach(dn);
2997
- const $s = Object.freeze(
3009
+ [Je, Me, Qe, et, Ct, tt, nt, st, rt].forEach(gn);
3010
+ const Zs = Object.freeze(
2998
3011
  [
2999
- { name: "unstableApi", config: Je },
3000
- { name: "slowNetwork", config: Ye },
3001
- { name: "offlineMode", config: Xe },
3002
- { name: "flakyConnection", config: Ke },
3003
- { name: "degradedUi", config: vt },
3004
- { name: "unreliableWebSocket", config: kt },
3005
- { name: "unreliableEventStream", config: _t },
3006
- { name: "slow-api", config: Ye },
3007
- { name: "flaky-api", config: Ke },
3008
- { name: "offline-mode", config: Xe },
3009
- { name: "high-latency", config: Je }
3012
+ { name: "unstableApi", config: et },
3013
+ { name: "slowNetwork", config: Je },
3014
+ { name: "offlineMode", config: Qe },
3015
+ { name: "flakyConnection", config: Me },
3016
+ { name: "degradedUi", config: Ct },
3017
+ { name: "unreliableWebSocket", config: tt },
3018
+ { name: "unreliableEventStream", config: nt },
3019
+ { name: "mobileThreeG", config: st },
3020
+ { name: "checkoutDegraded", config: rt },
3021
+ { name: "slow-api", config: Je },
3022
+ { name: "flaky-api", config: Me },
3023
+ { name: "api-flaky", config: Me },
3024
+ { name: "offline-mode", config: Qe },
3025
+ { name: "high-latency", config: et },
3026
+ { name: "websocket-instability", config: tt },
3027
+ { name: "realtime-lag", config: nt },
3028
+ { name: "mobile-3g", config: st },
3029
+ { name: "checkout-degraded", config: rt }
3010
3030
  ].map((t) => Object.freeze(t))
3011
3031
  );
3012
- function st(t) {
3032
+ function ut(t) {
3013
3033
  const e = t.trim();
3014
3034
  if (!e) throw new Error("[chaos-maker] preset name cannot be empty");
3015
3035
  return e;
3016
3036
  }
3017
- class Ps {
3018
- constructor(e = $s) {
3019
- A(this, "map", /* @__PURE__ */ new Map());
3037
+ class Gs {
3038
+ constructor(e = Zs) {
3039
+ M(this, "map", /* @__PURE__ */ new Map());
3020
3040
  for (const n of e) this.register(n);
3021
3041
  }
3022
3042
  register(e) {
3023
- const n = st(e.name);
3043
+ const n = ut(e.name);
3024
3044
  if (this.map.has(n))
3025
3045
  throw new Error(`[chaos-maker] preset '${n}' already registered`);
3026
3046
  this.map.set(n, e.config);
@@ -3031,10 +3051,10 @@ class Ps {
3031
3051
  this.register({ name: n, config: s });
3032
3052
  }
3033
3053
  has(e) {
3034
- return this.map.has(st(e));
3054
+ return this.map.has(ut(e));
3035
3055
  }
3036
3056
  get(e) {
3037
- const n = st(e), s = this.map.get(n);
3057
+ const n = ut(e), s = this.map.get(n);
3038
3058
  if (!s)
3039
3059
  throw new Error(`[chaos-maker] preset '${n}' is not registered. Known: ${this.list().join(", ")}`);
3040
3060
  return s;
@@ -3043,23 +3063,23 @@ class Ps {
3043
3063
  return [...this.map.keys()];
3044
3064
  }
3045
3065
  }
3046
- function Wt(t, e) {
3066
+ function zt(t, e) {
3047
3067
  var n, s, r;
3048
- for (const a of ["network", "ui", "websocket", "sse"]) {
3049
- const o = e[a];
3050
- if (!o) continue;
3051
- const i = t[a] ?? (t[a] = {});
3052
- for (const [c, u] of Object.entries(o)) {
3068
+ for (const o of ["network", "ui", "websocket", "sse"]) {
3069
+ const a = e[o];
3070
+ if (!a) continue;
3071
+ const i = t[o] ?? (t[o] = {});
3072
+ for (const [c, u] of Object.entries(a)) {
3053
3073
  if (!Array.isArray(u)) {
3054
3074
  let v;
3055
3075
  try {
3056
- const R = u === null ? "null" : ((n = u == null ? void 0 : u.constructor) == null ? void 0 : n.name) ?? typeof u, $ = ((s = JSON.stringify(u)) == null ? void 0 : s.slice(0, 80)) ?? "<unserializable>";
3057
- v = `${R} ${$}`;
3076
+ const A = u === null ? "null" : ((n = u == null ? void 0 : u.constructor) == null ? void 0 : n.name) ?? typeof u, $ = ((s = JSON.stringify(u)) == null ? void 0 : s.slice(0, 80)) ?? "<unserializable>";
3077
+ v = `${A} ${$}`;
3058
3078
  } catch {
3059
3079
  v = `${typeof u} <unserializable>`;
3060
3080
  }
3061
3081
  throw new Error(
3062
- `[chaos-maker] internal: preset slice category '${a}.${c}' must be an array (got ${v}). Update appendSlice when adding non-array category fields.`
3082
+ `[chaos-maker] internal: preset slice category '${o}.${c}' must be an array (got ${v}). Update appendSlice when adding non-array category fields.`
3063
3083
  );
3064
3084
  }
3065
3085
  (i[c] ?? (i[c] = [])).push(...u);
@@ -3067,7 +3087,7 @@ function Wt(t, e) {
3067
3087
  }
3068
3088
  (r = e.groups) != null && r.length && (t.groups ?? (t.groups = [])).push(...e.groups);
3069
3089
  }
3070
- function Ls(t, e) {
3090
+ function Ws(t, e) {
3071
3091
  const n = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), r = [];
3072
3092
  for (const i of t.presets ?? []) {
3073
3093
  const c = i.trim();
@@ -3076,40 +3096,42 @@ function Ls(t, e) {
3076
3096
  const u = e.get(c);
3077
3097
  s.has(u) || (s.add(u), r.push(u));
3078
3098
  }
3079
- const a = {};
3099
+ const o = {};
3080
3100
  for (const i of r)
3081
- Wt(a, $e(i));
3082
- const o = $e(t);
3083
- return delete o.presets, delete o.customPresets, o.seed !== void 0 && (a.seed = o.seed), o.debug !== void 0 && (a.debug = o.debug), Wt(a, o), a;
3084
- }
3085
- const ia = Object.freeze({
3086
- unstableApi: Je,
3087
- slowNetwork: Ye,
3088
- offlineMode: Xe,
3089
- flakyConnection: Ke,
3090
- degradedUi: vt,
3091
- unreliableWebSocket: kt,
3092
- unreliableEventStream: _t
3093
- }), qt = /* @__PURE__ */ new Map();
3094
- function Is(t, e) {
3095
- if (qt.size === 0) return;
3101
+ zt(o, Ie(i));
3102
+ const a = Ie(t);
3103
+ return delete a.presets, delete a.customPresets, a.seed !== void 0 && (o.seed = a.seed), a.debug !== void 0 && (o.debug = a.debug), zt(o, a), o;
3104
+ }
3105
+ const wo = Object.freeze({
3106
+ unstableApi: et,
3107
+ slowNetwork: Je,
3108
+ offlineMode: Qe,
3109
+ flakyConnection: Me,
3110
+ degradedUi: Ct,
3111
+ unreliableWebSocket: tt,
3112
+ unreliableEventStream: nt,
3113
+ mobileThreeG: st,
3114
+ checkoutDegraded: rt
3115
+ }), Ft = /* @__PURE__ */ new Map();
3116
+ function qs(t, e) {
3117
+ if (Ft.size === 0) return;
3096
3118
  const n = t;
3097
- for (const [s, r] of qt) {
3119
+ for (const [s, r] of Ft) {
3098
3120
  if (n[s] === void 0) continue;
3099
- const a = {
3121
+ const o = {
3100
3122
  path: s,
3101
3123
  code: "deprecated",
3102
3124
  ruleType: "top-level",
3103
3125
  message: r.message
3104
3126
  };
3105
- e && e(a);
3127
+ e && e(o);
3106
3128
  try {
3107
3129
  console.warn(`[chaos-maker] deprecated: ${s} — ${r.message}`);
3108
3130
  } catch {
3109
3131
  }
3110
3132
  }
3111
3133
  }
3112
- const Le = [
3134
+ const Ze = [
3113
3135
  "urlPattern",
3114
3136
  "methods",
3115
3137
  "graphqlOperation",
@@ -3118,25 +3140,25 @@ const Le = [
3118
3140
  "everyNth",
3119
3141
  "afterN",
3120
3142
  "group"
3121
- ], Ds = /* @__PURE__ */ new Set([...Le, "statusCode", "body", "statusText", "headers"]), Zs = /* @__PURE__ */ new Set([...Le, "delayMs"]), Gs = /* @__PURE__ */ new Set([...Le, "timeout"]), Ws = /* @__PURE__ */ new Set([...Le, "strategy"]), qs = new Set(Le), Us = /* @__PURE__ */ new Set(["selector", "action", "probability", "group"]), Vs = /* @__PURE__ */ new Set(["urlPattern", "direction", "probability", "onNth", "everyNth", "afterN", "group"]), zs = /* @__PURE__ */ new Set(["urlPattern", "direction", "delayMs", "probability", "onNth", "everyNth", "afterN", "group"]), Fs = /* @__PURE__ */ new Set(["urlPattern", "direction", "strategy", "probability", "onNth", "everyNth", "afterN", "group"]), Bs = /* @__PURE__ */ new Set(["urlPattern", "code", "reason", "afterMs", "probability", "onNth", "everyNth", "afterN", "group"]), Hs = /* @__PURE__ */ new Set(["urlPattern", "eventType", "probability", "onNth", "everyNth", "afterN", "group"]), Ys = /* @__PURE__ */ new Set(["urlPattern", "eventType", "delayMs", "probability", "onNth", "everyNth", "afterN", "group"]), Ks = /* @__PURE__ */ new Set(["urlPattern", "eventType", "strategy", "probability", "onNth", "everyNth", "afterN", "group"]), Xs = /* @__PURE__ */ new Set(["urlPattern", "afterMs", "probability", "onNth", "everyNth", "afterN", "group"]), fn = /* @__PURE__ */ new Set(["name", "enabled"]), hn = {
3122
- failures: Ds,
3123
- latencies: Zs,
3124
- aborts: Gs,
3125
- corruptions: Ws,
3126
- cors: qs
3127
- }, pn = {
3128
- assaults: Us
3129
- }, gn = {
3130
- drops: Vs,
3131
- delays: zs,
3143
+ ], Us = /* @__PURE__ */ new Set([...Ze, "statusCode", "body", "statusText", "headers"]), Vs = /* @__PURE__ */ new Set([...Ze, "delayMs"]), zs = /* @__PURE__ */ new Set([...Ze, "timeout"]), Fs = /* @__PURE__ */ new Set([...Ze, "strategy"]), Bs = new Set(Ze), Hs = /* @__PURE__ */ new Set(["selector", "action", "probability", "group"]), Ks = /* @__PURE__ */ new Set(["urlPattern", "direction", "probability", "onNth", "everyNth", "afterN", "group"]), Ys = /* @__PURE__ */ new Set(["urlPattern", "direction", "delayMs", "probability", "onNth", "everyNth", "afterN", "group"]), Xs = /* @__PURE__ */ new Set(["urlPattern", "direction", "strategy", "probability", "onNth", "everyNth", "afterN", "group"]), Js = /* @__PURE__ */ new Set(["urlPattern", "code", "reason", "afterMs", "probability", "onNth", "everyNth", "afterN", "group"]), Qs = /* @__PURE__ */ new Set(["urlPattern", "eventType", "probability", "onNth", "everyNth", "afterN", "group"]), er = /* @__PURE__ */ new Set(["urlPattern", "eventType", "delayMs", "probability", "onNth", "everyNth", "afterN", "group"]), tr = /* @__PURE__ */ new Set(["urlPattern", "eventType", "strategy", "probability", "onNth", "everyNth", "afterN", "group"]), nr = /* @__PURE__ */ new Set(["urlPattern", "afterMs", "probability", "onNth", "everyNth", "afterN", "group"]), yn = /* @__PURE__ */ new Set(["name", "enabled"]), mn = {
3144
+ failures: Us,
3145
+ latencies: Vs,
3146
+ aborts: zs,
3132
3147
  corruptions: Fs,
3133
- closes: Bs
3134
- }, yn = {
3135
- drops: Hs,
3148
+ cors: Bs
3149
+ }, bn = {
3150
+ assaults: Hs
3151
+ }, vn = {
3152
+ drops: Ks,
3136
3153
  delays: Ys,
3137
- corruptions: Ks,
3138
- closes: Xs
3139
- }, mn = /* @__PURE__ */ new Set([
3154
+ corruptions: Xs,
3155
+ closes: Js
3156
+ }, kn = {
3157
+ drops: Qs,
3158
+ delays: er,
3159
+ corruptions: tr,
3160
+ closes: nr
3161
+ }, _n = /* @__PURE__ */ new Set([
3140
3162
  "network",
3141
3163
  "ui",
3142
3164
  "websocket",
@@ -3147,18 +3169,18 @@ const Le = [
3147
3169
  "seed",
3148
3170
  "debug",
3149
3171
  "schemaVersion"
3150
- ]), et = {
3151
- network: new Set(Object.keys(hn)),
3152
- ui: new Set(Object.keys(pn)),
3153
- websocket: new Set(Object.keys(gn)),
3154
- sse: new Set(Object.keys(yn))
3172
+ ]), at = {
3173
+ network: new Set(Object.keys(mn)),
3174
+ ui: new Set(Object.keys(bn)),
3175
+ websocket: new Set(Object.keys(vn)),
3176
+ sse: new Set(Object.keys(kn))
3155
3177
  }, fe = {
3156
- network: hn,
3157
- ui: pn,
3158
- websocket: gn,
3159
- sse: yn
3178
+ network: mn,
3179
+ ui: bn,
3180
+ websocket: vn,
3181
+ sse: kn
3160
3182
  };
3161
- function bn(t, e) {
3183
+ function wn(t, e) {
3162
3184
  const n = {};
3163
3185
  if (!t || typeof t != "object") return n;
3164
3186
  const s = t;
@@ -3166,315 +3188,315 @@ function bn(t, e) {
3166
3188
  e.has(r) && (n[r] = s[r]);
3167
3189
  return n;
3168
3190
  }
3169
- function Js(t, e) {
3170
- return Array.isArray(t) ? t.map((n) => bn(n, e)) : [];
3191
+ function sr(t, e) {
3192
+ return Array.isArray(t) ? t.map((n) => wn(n, e)) : [];
3171
3193
  }
3172
- function vn(t, e, n) {
3194
+ function xn(t, e, n) {
3173
3195
  const s = {};
3174
3196
  if (!t || typeof t != "object") return s;
3175
3197
  const r = t;
3176
- for (const a of Object.keys(r)) {
3177
- if (!n.has(a)) continue;
3178
- const o = e[a];
3179
- o && (s[a] = Js(r[a], o));
3198
+ for (const o of Object.keys(r)) {
3199
+ if (!n.has(o)) continue;
3200
+ const a = e[o];
3201
+ a && (s[o] = sr(r[o], a));
3180
3202
  }
3181
3203
  return s;
3182
3204
  }
3183
- function kn(t) {
3184
- return Array.isArray(t) ? t.map((e) => bn(e, fn)) : [];
3205
+ function Sn(t) {
3206
+ return Array.isArray(t) ? t.map((e) => wn(e, yn)) : [];
3185
3207
  }
3186
- function Qs(t) {
3208
+ function rr(t) {
3187
3209
  const e = {};
3188
3210
  if (!t || typeof t != "object") return e;
3189
3211
  const n = t;
3190
3212
  for (const s of Object.keys(fe))
3191
- n[s] !== void 0 && (e[s] = vn(n[s], fe[s], et[s]));
3192
- return n.groups !== void 0 && (e.groups = kn(n.groups)), e;
3213
+ n[s] !== void 0 && (e[s] = xn(n[s], fe[s], at[s]));
3214
+ return n.groups !== void 0 && (e.groups = Sn(n.groups)), e;
3193
3215
  }
3194
- function er(t) {
3216
+ function or(t) {
3195
3217
  const e = {};
3196
3218
  if (!t || typeof t != "object") return e;
3197
3219
  const n = t;
3198
3220
  for (const s of Object.keys(n))
3199
- if (mn.has(s))
3221
+ if (_n.has(s))
3200
3222
  if (s in fe)
3201
- e[s] = vn(n[s], fe[s], et[s]);
3223
+ e[s] = xn(n[s], fe[s], at[s]);
3202
3224
  else if (s === "groups")
3203
- e[s] = kn(n[s]);
3225
+ e[s] = Sn(n[s]);
3204
3226
  else if (s === "customPresets") {
3205
3227
  const r = n[s];
3206
3228
  if (r && typeof r == "object") {
3207
- const a = {};
3208
- for (const [o, i] of Object.entries(r))
3209
- a[o] = Qs(i);
3210
- e[s] = a;
3229
+ const o = {};
3230
+ for (const [a, i] of Object.entries(r))
3231
+ o[a] = rr(i);
3232
+ e[s] = o;
3211
3233
  }
3212
3234
  } else
3213
3235
  e[s] = n[s];
3214
3236
  return e;
3215
3237
  }
3216
- function tr(t) {
3238
+ function ar(t) {
3217
3239
  const e = [];
3218
- return nr(t, "", e), e.sort();
3240
+ return ir(t, "", e), e.sort();
3219
3241
  }
3220
- function nr(t, e, n) {
3242
+ function ir(t, e, n) {
3221
3243
  if (!(!t || typeof t != "object")) {
3222
3244
  const s = t;
3223
3245
  for (const r of Object.keys(s)) {
3224
- if (!mn.has(r)) {
3246
+ if (!_n.has(r)) {
3225
3247
  n.push(r);
3226
3248
  continue;
3227
3249
  }
3228
- r in fe ? _n(s[r], r, fe[r], et[r], n) : r === "groups" ? wn(s[r], "groups", n) : r === "customPresets" && sr(s[r], n);
3250
+ r in fe ? Cn(s[r], r, fe[r], at[r], n) : r === "groups" ? En(s[r], "groups", n) : r === "customPresets" && cr(s[r], n);
3229
3251
  }
3230
3252
  }
3231
3253
  }
3232
- function _n(t, e, n, s, r) {
3254
+ function Cn(t, e, n, s, r) {
3233
3255
  if (!t || typeof t != "object") return;
3234
- const a = t;
3235
- for (const o of Object.keys(a)) {
3236
- const i = `${e}.${o}`;
3237
- if (!s.has(o)) {
3256
+ const o = t;
3257
+ for (const a of Object.keys(o)) {
3258
+ const i = `${e}.${a}`;
3259
+ if (!s.has(a)) {
3238
3260
  r.push(i);
3239
3261
  continue;
3240
3262
  }
3241
- const c = n[o];
3242
- c && Array.isArray(a[o]) && a[o].forEach((u, v) => {
3263
+ const c = n[a];
3264
+ c && Array.isArray(o[a]) && o[a].forEach((u, v) => {
3243
3265
  if (!u || typeof u != "object") return;
3244
- const R = u;
3245
- for (const $ of Object.keys(R))
3266
+ const A = u;
3267
+ for (const $ of Object.keys(A))
3246
3268
  c.has($) || r.push(`${i}[${v}].${$}`);
3247
3269
  });
3248
3270
  }
3249
3271
  }
3250
- function wn(t, e, n) {
3272
+ function En(t, e, n) {
3251
3273
  Array.isArray(t) && t.forEach((s, r) => {
3252
3274
  if (!s || typeof s != "object") return;
3253
- const a = s;
3254
- for (const o of Object.keys(a))
3255
- fn.has(o) || n.push(`${e}[${r}].${o}`);
3275
+ const o = s;
3276
+ for (const a of Object.keys(o))
3277
+ yn.has(a) || n.push(`${e}[${r}].${a}`);
3256
3278
  });
3257
3279
  }
3258
- function sr(t, e) {
3280
+ function cr(t, e) {
3259
3281
  if (!(!t || typeof t != "object"))
3260
3282
  for (const [n, s] of Object.entries(t)) {
3261
3283
  if (!s || typeof s != "object") continue;
3262
3284
  const r = s;
3263
- for (const a of Object.keys(r)) {
3264
- if (a === "groups") {
3265
- wn(r[a], `customPresets.${n}.groups`, e);
3285
+ for (const o of Object.keys(r)) {
3286
+ if (o === "groups") {
3287
+ En(r[o], `customPresets.${n}.groups`, e);
3266
3288
  continue;
3267
3289
  }
3268
- if (!(a in fe)) {
3269
- e.push(`customPresets.${n}.${a}`);
3290
+ if (!(o in fe)) {
3291
+ e.push(`customPresets.${n}.${o}`);
3270
3292
  continue;
3271
3293
  }
3272
- _n(r[a], `customPresets.${n}.${a}`, fe[a], et[a], e);
3294
+ Cn(r[o], `customPresets.${n}.${o}`, fe[o], at[o], e);
3273
3295
  }
3274
3296
  }
3275
3297
  }
3276
- function P(t, e) {
3298
+ function j(t, e) {
3277
3299
  return e === "strict" ? t.strict() : t.passthrough();
3278
3300
  }
3279
- const B = Q().min(0, "Probability must be >= 0").max(1, "Probability must be <= 1"), Ut = Q().int().min(1), Y = {
3280
- onNth: Ut.optional(),
3281
- everyNth: Ut.optional(),
3282
- afterN: Q().int().min(0).optional()
3301
+ const B = ee().min(0, "Probability must be >= 0").max(1, "Probability must be <= 1"), Bt = ee().int().min(1), K = {
3302
+ onNth: Bt.optional(),
3303
+ everyNth: Bt.optional(),
3304
+ afterN: ee().int().min(0).optional()
3283
3305
  }, H = {
3284
3306
  group: D().trim().min(1, "group must not be empty").optional()
3285
- }, rr = (t) => [t.onNth, t.everyNth, t.afterN].filter((e) => e !== void 0).length <= 1, K = [
3286
- rr,
3307
+ }, ur = (t) => [t.onNth, t.everyNth, t.afterN].filter((e) => e !== void 0).length <= 1, Y = [
3308
+ ur,
3287
3309
  { message: "Only one of onNth, everyNth, or afterN may be set on a single rule" }
3288
- ], ar = cn([
3310
+ ], lr = fn([
3289
3311
  D().min(1, "graphqlOperation must not be empty"),
3290
- _s(RegExp).refine(
3312
+ Es(RegExp).refine(
3291
3313
  (t) => !t.global && !t.sticky,
3292
3314
  { message: "graphqlOperation RegExp must not use global (g) or sticky (y) flags due to lastIndex mutation" }
3293
3315
  )
3294
- ]), Ie = {
3316
+ ]), Ge = {
3295
3317
  urlPattern: D().min(1, "urlPattern must not be empty"),
3296
3318
  methods: W(D()).optional(),
3297
- graphqlOperation: ar.optional()
3298
- }, xn = (t) => P(
3319
+ graphqlOperation: lr.optional()
3320
+ }, Nn = (t) => j(
3299
3321
  L({
3300
- ...Ie,
3301
- statusCode: Q().int().min(100).max(599),
3322
+ ...Ge,
3323
+ statusCode: ee().int().min(100).max(599),
3302
3324
  probability: B,
3303
3325
  body: D().optional(),
3304
3326
  statusText: D().optional(),
3305
- headers: un(D()).optional(),
3306
- ...Y,
3327
+ headers: hn(D()).optional(),
3328
+ ...K,
3307
3329
  ...H
3308
3330
  }),
3309
3331
  t
3310
- ).refine(...K), Sn = (t) => P(
3332
+ ).refine(...Y), Tn = (t) => j(
3311
3333
  L({
3312
- ...Ie,
3313
- delayMs: Q().min(0, "delayMs must be >= 0"),
3334
+ ...Ge,
3335
+ delayMs: ee().min(0, "delayMs must be >= 0"),
3314
3336
  probability: B,
3315
- ...Y,
3337
+ ...K,
3316
3338
  ...H
3317
3339
  }),
3318
3340
  t
3319
- ).refine(...K), Cn = (t) => P(
3341
+ ).refine(...Y), On = (t) => j(
3320
3342
  L({
3321
- ...Ie,
3343
+ ...Ge,
3322
3344
  probability: B,
3323
- timeout: Q().min(0, "timeout must be >= 0").optional(),
3324
- ...Y,
3345
+ timeout: ee().min(0, "timeout must be >= 0").optional(),
3346
+ ...K,
3325
3347
  ...H
3326
3348
  }),
3327
3349
  t
3328
- ).refine(...K), En = (t) => P(
3350
+ ).refine(...Y), Mn = (t) => j(
3329
3351
  L({
3330
- ...Ie,
3352
+ ...Ge,
3331
3353
  probability: B,
3332
- strategy: Pe(["truncate", "malformed-json", "empty", "wrong-type"]),
3333
- ...Y,
3354
+ strategy: De(["truncate", "malformed-json", "empty", "wrong-type"]),
3355
+ ...K,
3334
3356
  ...H
3335
3357
  }),
3336
3358
  t
3337
- ).refine(...K), Nn = (t) => P(
3359
+ ).refine(...Y), Rn = (t) => j(
3338
3360
  L({
3339
- ...Ie,
3361
+ ...Ge,
3340
3362
  probability: B,
3341
- ...Y,
3363
+ ...K,
3342
3364
  ...H
3343
3365
  }),
3344
3366
  t
3345
- ).refine(...K), or = (t) => P(
3367
+ ).refine(...Y), dr = (t) => j(
3346
3368
  L({
3347
- failures: W(xn(t)).optional(),
3348
- latencies: W(Sn(t)).optional(),
3349
- aborts: W(Cn(t)).optional(),
3350
- corruptions: W(En(t)).optional(),
3351
- cors: W(Nn(t)).optional()
3369
+ failures: W(Nn(t)).optional(),
3370
+ latencies: W(Tn(t)).optional(),
3371
+ aborts: W(On(t)).optional(),
3372
+ corruptions: W(Mn(t)).optional(),
3373
+ cors: W(Rn(t)).optional()
3352
3374
  }),
3353
3375
  t
3354
- ), Tn = (t) => P(
3376
+ ), An = (t) => j(
3355
3377
  L({
3356
3378
  selector: D().min(1, "selector must not be empty"),
3357
- action: Pe(["disable", "hide", "remove"]),
3379
+ action: De(["disable", "hide", "remove"]),
3358
3380
  probability: B,
3359
3381
  ...H
3360
3382
  }),
3361
3383
  t
3362
- ), ir = (t) => P(
3384
+ ), fr = (t) => j(
3363
3385
  L({
3364
- assaults: W(Tn(t)).optional()
3386
+ assaults: W(An(t)).optional()
3365
3387
  }),
3366
3388
  t
3367
- ), wt = Pe(["inbound", "outbound", "both"]), On = (t) => P(
3389
+ ), Et = De(["inbound", "outbound", "both"]), Pn = (t) => j(
3368
3390
  L({
3369
3391
  urlPattern: D().min(1, "urlPattern must not be empty"),
3370
- direction: wt,
3392
+ direction: Et,
3371
3393
  probability: B,
3372
- ...Y,
3394
+ ...K,
3373
3395
  ...H
3374
3396
  }),
3375
3397
  t
3376
- ).refine(...K), An = (t) => P(
3398
+ ).refine(...Y), $n = (t) => j(
3377
3399
  L({
3378
3400
  urlPattern: D().min(1, "urlPattern must not be empty"),
3379
- direction: wt,
3380
- delayMs: Q().min(0, "delayMs must be >= 0"),
3401
+ direction: Et,
3402
+ delayMs: ee().min(0, "delayMs must be >= 0"),
3381
3403
  probability: B,
3382
- ...Y,
3404
+ ...K,
3383
3405
  ...H
3384
3406
  }),
3385
3407
  t
3386
- ).refine(...K), Mn = (t) => P(
3408
+ ).refine(...Y), jn = (t) => j(
3387
3409
  L({
3388
3410
  urlPattern: D().min(1, "urlPattern must not be empty"),
3389
- direction: wt,
3390
- strategy: Pe(["truncate", "malformed-json", "empty", "wrong-type"]),
3411
+ direction: Et,
3412
+ strategy: De(["truncate", "malformed-json", "empty", "wrong-type"]),
3391
3413
  probability: B,
3392
- ...Y,
3414
+ ...K,
3393
3415
  ...H
3394
3416
  }),
3395
3417
  t
3396
- ).refine(...K), cr = Q().int().refine(
3418
+ ).refine(...Y), hr = ee().int().refine(
3397
3419
  (t) => t === 1e3 || t >= 3e3 && t <= 4999,
3398
3420
  { message: "code must be 1000 or in the range 3000-4999" }
3399
- ), ur = D().refine(
3421
+ ), pr = D().refine(
3400
3422
  (t) => new TextEncoder().encode(t).length <= 123,
3401
3423
  { message: "reason must be <= 123 UTF-8 bytes" }
3402
- ), Rn = (t) => P(
3424
+ ), Ln = (t) => j(
3403
3425
  L({
3404
3426
  urlPattern: D().min(1, "urlPattern must not be empty"),
3405
- code: cr.optional(),
3406
- reason: ur.optional(),
3407
- afterMs: Q().min(0, "afterMs must be >= 0").optional(),
3427
+ code: hr.optional(),
3428
+ reason: pr.optional(),
3429
+ afterMs: ee().min(0, "afterMs must be >= 0").optional(),
3408
3430
  probability: B,
3409
- ...Y,
3431
+ ...K,
3410
3432
  ...H
3411
3433
  }),
3412
3434
  t
3413
- ).refine(...K), lr = (t) => P(
3435
+ ).refine(...Y), gr = (t) => j(
3414
3436
  L({
3415
- drops: W(On(t)).optional(),
3416
- delays: W(An(t)).optional(),
3417
- corruptions: W(Mn(t)).optional(),
3418
- closes: W(Rn(t)).optional()
3437
+ drops: W(Pn(t)).optional(),
3438
+ delays: W($n(t)).optional(),
3439
+ corruptions: W(jn(t)).optional(),
3440
+ closes: W(Ln(t)).optional()
3419
3441
  }),
3420
3442
  t
3421
- ), xt = D().min(1, "eventType must not be empty"), jn = (t) => P(
3443
+ ), Nt = D().min(1, "eventType must not be empty"), In = (t) => j(
3422
3444
  L({
3423
3445
  urlPattern: D().min(1, "urlPattern must not be empty"),
3424
- eventType: xt.optional(),
3446
+ eventType: Nt.optional(),
3425
3447
  probability: B,
3426
- ...Y,
3448
+ ...K,
3427
3449
  ...H
3428
3450
  }),
3429
3451
  t
3430
- ).refine(...K), $n = (t) => P(
3452
+ ).refine(...Y), Dn = (t) => j(
3431
3453
  L({
3432
3454
  urlPattern: D().min(1, "urlPattern must not be empty"),
3433
- eventType: xt.optional(),
3434
- delayMs: Q().min(0, "delayMs must be >= 0"),
3455
+ eventType: Nt.optional(),
3456
+ delayMs: ee().min(0, "delayMs must be >= 0"),
3435
3457
  probability: B,
3436
- ...Y,
3458
+ ...K,
3437
3459
  ...H
3438
3460
  }),
3439
3461
  t
3440
- ).refine(...K), Pn = (t) => P(
3462
+ ).refine(...Y), Zn = (t) => j(
3441
3463
  L({
3442
3464
  urlPattern: D().min(1, "urlPattern must not be empty"),
3443
- eventType: xt.optional(),
3444
- strategy: Pe(["truncate", "malformed-json", "empty", "wrong-type"]),
3465
+ eventType: Nt.optional(),
3466
+ strategy: De(["truncate", "malformed-json", "empty", "wrong-type"]),
3445
3467
  probability: B,
3446
- ...Y,
3468
+ ...K,
3447
3469
  ...H
3448
3470
  }),
3449
3471
  t
3450
- ).refine(...K), Ln = (t) => P(
3472
+ ).refine(...Y), Gn = (t) => j(
3451
3473
  L({
3452
3474
  urlPattern: D().min(1, "urlPattern must not be empty"),
3453
- afterMs: Q().min(0, "afterMs must be >= 0").optional(),
3475
+ afterMs: ee().min(0, "afterMs must be >= 0").optional(),
3454
3476
  probability: B,
3455
- ...Y,
3477
+ ...K,
3456
3478
  ...H
3457
3479
  }),
3458
3480
  t
3459
- ).refine(...K), dr = (t) => P(
3481
+ ).refine(...Y), yr = (t) => j(
3460
3482
  L({
3461
- drops: W(jn(t)).optional(),
3462
- delays: W($n(t)).optional(),
3463
- corruptions: W(Pn(t)).optional(),
3464
- closes: W(Ln(t)).optional()
3483
+ drops: W(In(t)).optional(),
3484
+ delays: W(Dn(t)).optional(),
3485
+ corruptions: W(Zn(t)).optional(),
3486
+ closes: W(Gn(t)).optional()
3465
3487
  }),
3466
3488
  t
3467
- ), In = (t) => P(
3489
+ ), Wn = (t) => j(
3468
3490
  L({
3469
3491
  name: D().trim().min(1, "group name must not be empty"),
3470
- enabled: ht().optional()
3492
+ enabled: vt().optional()
3471
3493
  }),
3472
3494
  t
3473
- ), fr = (t) => W(In(t)).superRefine((e, n) => {
3495
+ ), mr = (t) => W(Wn(t)).superRefine((e, n) => {
3474
3496
  const s = /* @__PURE__ */ new Set();
3475
- for (const [r, a] of e.entries()) {
3476
- const o = a.name.trim();
3477
- if (s.has(o)) {
3497
+ for (const [r, o] of e.entries()) {
3498
+ const a = o.name.trim();
3499
+ if (s.has(a)) {
3478
3500
  n.addIssue({
3479
3501
  code: h.custom,
3480
3502
  message: "duplicate group name after normalization",
@@ -3482,40 +3504,40 @@ const B = Q().min(0, "Probability must be >= 0").max(1, "Probability must be <=
3482
3504
  });
3483
3505
  continue;
3484
3506
  }
3485
- s.add(o);
3507
+ s.add(a);
3486
3508
  }
3487
- }), hr = (t) => cn([
3488
- ht(),
3489
- P(L({ enabled: ht() }), t)
3490
- ]), pt = (t) => P(
3509
+ }), br = (t) => fn([
3510
+ vt(),
3511
+ j(L({ enabled: vt() }), t)
3512
+ ]), kt = (t) => j(
3491
3513
  L({
3492
- network: or(t).optional(),
3493
- ui: ir(t).optional(),
3494
- websocket: lr(t).optional(),
3495
- sse: dr(t).optional(),
3496
- groups: fr(t).optional()
3514
+ network: dr(t).optional(),
3515
+ ui: fr(t).optional(),
3516
+ websocket: gr(t).optional(),
3517
+ sse: yr(t).optional(),
3518
+ groups: mr(t).optional()
3497
3519
  }),
3498
3520
  t
3499
- ), Dn = D().trim().min(1, "preset name must not be empty"), pr = W(Dn).transform((t) => {
3521
+ ), qn = D().trim().min(1, "preset name must not be empty"), vr = W(qn).transform((t) => {
3500
3522
  const e = /* @__PURE__ */ new Set(), n = [];
3501
3523
  for (const s of t) {
3502
3524
  const r = s.trim();
3503
3525
  e.has(r) || (e.add(r), n.push(r));
3504
3526
  }
3505
3527
  return n;
3506
- }), Zn = (t) => P(
3507
- pt(t).extend({
3508
- presets: pr.optional(),
3509
- customPresets: un(Dn, pt(t)).optional(),
3510
- seed: Q().int("Seed must be an integer").optional(),
3511
- debug: hr(t).optional(),
3512
- schemaVersion: ws(1).optional()
3528
+ }), Un = (t) => j(
3529
+ kt(t).extend({
3530
+ presets: vr.optional(),
3531
+ customPresets: hn(qn, kt(t)).optional(),
3532
+ seed: ee().int("Seed must be an integer").optional(),
3533
+ debug: br(t).optional(),
3534
+ schemaVersion: Ns(1).optional()
3513
3535
  }),
3514
3536
  t
3515
- ), Gn = Zn("strict"), gr = Zn("passthrough");
3516
- pt("strict");
3517
- xn("strict"), Sn("strict"), Cn("strict"), En("strict"), Nn("strict"), Tn("strict"), On("strict"), An("strict"), Mn("strict"), Rn("strict"), jn("strict"), $n("strict"), Pn("strict"), Ln("strict"), In("strict");
3518
- const yr = {
3537
+ ), Vn = Un("strict"), kr = Un("passthrough");
3538
+ kt("strict");
3539
+ Nn("strict"), Tn("strict"), On("strict"), Mn("strict"), Rn("strict"), An("strict"), Pn("strict"), $n("strict"), jn("strict"), Ln("strict"), In("strict"), Dn("strict"), Zn("strict"), Gn("strict"), Wn("strict");
3540
+ const _r = {
3519
3541
  network: {
3520
3542
  failures: "network.failure",
3521
3543
  latencies: "network.latency",
@@ -3536,32 +3558,32 @@ const yr = {
3536
3558
  corruptions: "sse.corrupt",
3537
3559
  closes: "sse.close"
3538
3560
  }
3539
- }, Wn = /* @__PURE__ */ Symbol.for("chaos-maker.validated"), Vt = 1;
3540
- function mr(t, e) {
3541
- return !t || typeof t != "object" ? !1 : t[Wn] === e;
3561
+ }, zn = /* @__PURE__ */ Symbol.for("chaos-maker.validated"), Ht = 1;
3562
+ function wr(t, e) {
3563
+ return !t || typeof t != "object" ? !1 : t[zn] === e;
3542
3564
  }
3543
- function br(t, e) {
3544
- return Object.defineProperty(t, Wn, {
3565
+ function xr(t, e) {
3566
+ return Object.defineProperty(t, zn, {
3545
3567
  value: e,
3546
3568
  enumerable: !1,
3547
3569
  writable: !1,
3548
3570
  configurable: !1
3549
3571
  }), t;
3550
3572
  }
3551
- function vr(t) {
3552
- const e = Gn.safeParse(t);
3573
+ function Sr(t) {
3574
+ const e = Vn.safeParse(t);
3553
3575
  if (!e.success)
3554
- throw new ve(e.error.issues.map(ln));
3576
+ throw new ve(e.error.issues.map(pn));
3555
3577
  return e.data;
3556
3578
  }
3557
- function kr(t, e = {}) {
3558
- const n = e.unknownFields ?? "reject", r = (n === "reject" ? Gn : gr).safeParse(t);
3579
+ function Cr(t, e = {}) {
3580
+ const n = e.unknownFields ?? "reject", r = (n === "reject" ? Vn : kr).safeParse(t);
3559
3581
  if (!r.success)
3560
- throw new ve(r.error.issues.map(ln));
3561
- let a = r.data;
3582
+ throw new ve(r.error.issues.map(pn));
3583
+ let o = r.data;
3562
3584
  if (n === "warn" || n === "ignore") {
3563
3585
  if (n === "warn") {
3564
- const i = tr(t);
3586
+ const i = ar(t);
3565
3587
  if (i.length > 0)
3566
3588
  try {
3567
3589
  console.warn(
@@ -3570,12 +3592,12 @@ function kr(t, e = {}) {
3570
3592
  } catch {
3571
3593
  }
3572
3594
  }
3573
- a = er(a);
3595
+ o = or(o);
3574
3596
  }
3575
- let o;
3597
+ let a;
3576
3598
  try {
3577
- const i = new Ps();
3578
- i.registerAll(a.customPresets), o = Ls(a, i);
3599
+ const i = new Gs();
3600
+ i.registerAll(o.customPresets), a = Ws(o, i);
3579
3601
  } catch (i) {
3580
3602
  if (i instanceof ve) throw i;
3581
3603
  const c = i.message;
@@ -3587,18 +3609,18 @@ function kr(t, e = {}) {
3587
3609
  message: c
3588
3610
  }]);
3589
3611
  }
3590
- return vr(o);
3612
+ return Sr(a);
3591
3613
  }
3592
- function _r(t, e) {
3593
- const n = [], s = (r, a, o) => {
3614
+ function Er(t, e) {
3615
+ const n = [], s = (r, o, a) => {
3594
3616
  const i = e[r];
3595
3617
  if (!i) return;
3596
3618
  let c;
3597
3619
  try {
3598
- c = i(a, { ruleType: r, path: o });
3620
+ c = i(o, { ruleType: r, path: a });
3599
3621
  } catch (u) {
3600
3622
  n.push({
3601
- path: o,
3623
+ path: a,
3602
3624
  code: "custom",
3603
3625
  ruleType: r,
3604
3626
  message: `customValidator threw: ${u.message}`
@@ -3607,22 +3629,22 @@ function _r(t, e) {
3607
3629
  }
3608
3630
  Array.isArray(c) && n.push(...c);
3609
3631
  };
3610
- for (const [r, a] of Object.entries(yr)) {
3611
- const o = t[r];
3612
- if (o)
3613
- for (const [i, c] of Object.entries(a)) {
3632
+ for (const [r, o] of Object.entries(_r)) {
3633
+ const a = t[r];
3634
+ if (a)
3635
+ for (const [i, c] of Object.entries(o)) {
3614
3636
  if (!c) continue;
3615
- const u = o[i];
3616
- Array.isArray(u) && u.forEach((v, R) => {
3617
- s(c, v, `${r}.${i}[${R}]`);
3637
+ const u = a[i];
3638
+ Array.isArray(u) && u.forEach((v, A) => {
3639
+ s(c, v, `${r}.${i}[${A}]`);
3618
3640
  });
3619
3641
  }
3620
3642
  }
3621
- return Array.isArray(t.groups) && t.groups.forEach((r, a) => {
3622
- s("group", r, `groups[${a}]`);
3643
+ return Array.isArray(t.groups) && t.groups.forEach((r, o) => {
3644
+ s("group", r, `groups[${o}]`);
3623
3645
  }), e["top-level"] && s("top-level", t, ""), n;
3624
3646
  }
3625
- function qn(t, e = {}) {
3647
+ function Fn(t, e = {}) {
3626
3648
  if (typeof t == "object" && t !== null) {
3627
3649
  const r = t.schemaVersion;
3628
3650
  if (r !== void 0 && r !== 1)
@@ -3635,16 +3657,16 @@ function qn(t, e = {}) {
3635
3657
  received: JSON.stringify(r)
3636
3658
  }]);
3637
3659
  }
3638
- if (!e.unknownFields && !e.onDeprecation && !e.customValidators && mr(t, Vt))
3660
+ if (!e.unknownFields && !e.onDeprecation && !e.customValidators && wr(t, Ht))
3639
3661
  return t;
3640
- const s = kr(t, { unknownFields: e.unknownFields });
3641
- if (Is(s, e.onDeprecation), e.customValidators) {
3642
- const r = _r(s, e.customValidators);
3662
+ const s = Cr(t, { unknownFields: e.unknownFields });
3663
+ if (qs(s, e.onDeprecation), e.customValidators) {
3664
+ const r = Er(s, e.customValidators);
3643
3665
  if (r.length > 0) throw new ve(r);
3644
3666
  }
3645
- return br(s, Vt);
3667
+ return xr(s, Ht);
3646
3668
  }
3647
- function wr(t) {
3669
+ function Nr(t) {
3648
3670
  let e = t | 0;
3649
3671
  return () => {
3650
3672
  e = e + 1831565813 | 0;
@@ -3652,22 +3674,22 @@ function wr(t) {
3652
3674
  return n = n + Math.imul(n ^ n >>> 7, 61 | n) ^ n, ((n ^ n >>> 14) >>> 0) / 4294967296;
3653
3675
  };
3654
3676
  }
3655
- function xr() {
3677
+ function Tr() {
3656
3678
  return Math.random() * 4294967296 >>> 0;
3657
3679
  }
3658
- function Sr(t) {
3659
- const e = t ?? xr();
3680
+ function Or(t) {
3681
+ const e = t ?? Tr();
3660
3682
  return {
3661
- random: wr(e),
3683
+ random: Nr(e),
3662
3684
  seed: e
3663
3685
  };
3664
3686
  }
3665
- class Cr {
3687
+ class Mr {
3666
3688
  constructor(e = 2e3) {
3667
- A(this, "listeners", /* @__PURE__ */ new Map());
3668
- A(this, "log", []);
3669
- A(this, "logger");
3670
- A(this, "ruleIds");
3689
+ M(this, "listeners", /* @__PURE__ */ new Map());
3690
+ M(this, "log", []);
3691
+ M(this, "logger");
3692
+ M(this, "ruleIds");
3671
3693
  this.maxLogEntries = e;
3672
3694
  }
3673
3695
  on(e, n) {
@@ -3698,8 +3720,8 @@ class Cr {
3698
3720
  debug(e, n, s) {
3699
3721
  var i;
3700
3722
  if (!this.logger) return;
3701
- const r = s ? (i = this.ruleIds) == null ? void 0 : i.get(s) : void 0, a = r ? { ...n, ruleType: r.ruleType, ruleId: r.ruleId } : n, o = this.logger.log(e, a);
3702
- o && this.emit(o);
3723
+ const r = s ? (i = this.ruleIds) == null ? void 0 : i.get(s) : void 0, o = r ? { ...n, ruleType: r.ruleType, ruleId: r.ruleId } : n, a = this.logger.log(e, o);
3724
+ a && this.emit(a);
3703
3725
  }
3704
3726
  getLog() {
3705
3727
  return [...this.log];
@@ -3716,25 +3738,25 @@ class Cr {
3716
3738
  }
3717
3739
  }
3718
3740
  }
3719
- function Un(t) {
3741
+ function Bn(t) {
3720
3742
  const e = t.replace(/#[^\r\n]*/g, " "), n = /\b(?:query|mutation|subscription)\s+([A-Za-z_][A-Za-z0-9_]*)/.exec(e);
3721
3743
  return (n == null ? void 0 : n[1]) ?? null;
3722
3744
  }
3723
- function Er(t) {
3745
+ function Rr(t) {
3724
3746
  try {
3725
3747
  return JSON.parse(t);
3726
3748
  } catch {
3727
3749
  return;
3728
3750
  }
3729
3751
  }
3730
- function Vn(t) {
3752
+ function Hn(t) {
3731
3753
  if (!t || typeof t != "object") return { isGraphQL: !1, operationName: null };
3732
3754
  if (Array.isArray(t))
3733
- return t.length === 0 ? { isGraphQL: !1, operationName: null } : Vn(t[0]);
3755
+ return t.length === 0 ? { isGraphQL: !1, operationName: null } : Hn(t[0]);
3734
3756
  const e = t, n = typeof e.query == "string", s = typeof e.operationName == "string";
3735
- return !n && !s ? { isGraphQL: !1, operationName: null } : s && e.operationName.length > 0 ? { isGraphQL: !0, operationName: e.operationName } : n ? { isGraphQL: !0, operationName: Un(e.query) } : { isGraphQL: !0, operationName: null };
3757
+ return !n && !s ? { isGraphQL: !1, operationName: null } : s && e.operationName.length > 0 ? { isGraphQL: !0, operationName: e.operationName } : n ? { isGraphQL: !0, operationName: Bn(e.query) } : { isGraphQL: !0, operationName: null };
3736
3758
  }
3737
- function Nr(t) {
3759
+ function Ar(t) {
3738
3760
  let e;
3739
3761
  try {
3740
3762
  e = new URL(t, "http://_chaos-maker.invalid");
@@ -3742,65 +3764,65 @@ function Nr(t) {
3742
3764
  return { kind: "not-graphql" };
3743
3765
  }
3744
3766
  const n = e.searchParams.get("operationName"), s = e.searchParams.get("query");
3745
- return n && n.length > 0 ? { kind: "extracted", operationName: n } : s && s.length > 0 ? { kind: "extracted", operationName: Un(s) } : { kind: "not-graphql" };
3767
+ return n && n.length > 0 ? { kind: "extracted", operationName: n } : s && s.length > 0 ? { kind: "extracted", operationName: Bn(s) } : { kind: "not-graphql" };
3746
3768
  }
3747
- function zn(t, e, n, s) {
3769
+ function Kn(t, e, n, s) {
3748
3770
  const r = t.toUpperCase();
3749
3771
  if (r === "POST") {
3750
3772
  if (n !== null) {
3751
- const a = Er(n);
3752
- if (a === void 0) return { kind: "not-graphql" };
3753
- const { isGraphQL: o, operationName: i } = Vn(a);
3754
- return o ? { kind: "extracted", operationName: i } : { kind: "not-graphql" };
3773
+ const o = Rr(n);
3774
+ if (o === void 0) return { kind: "not-graphql" };
3775
+ const { isGraphQL: a, operationName: i } = Hn(o);
3776
+ return a ? { kind: "extracted", operationName: i } : { kind: "not-graphql" };
3755
3777
  }
3756
3778
  return s ? { kind: "unparseable" } : { kind: "not-graphql" };
3757
3779
  }
3758
- return r === "GET" ? Nr(e) : { kind: "not-graphql" };
3780
+ return r === "GET" ? Ar(e) : { kind: "not-graphql" };
3759
3781
  }
3760
- function Tr(t, e) {
3782
+ function Pr(t, e) {
3761
3783
  return e === null ? !1 : typeof t == "string" ? t === e : ((t.global || t.sticky) && (t.lastIndex = 0), t.test(e));
3762
3784
  }
3763
- function St(t, e) {
3764
- return t ? e.kind === "not-graphql" ? { kind: "no-match" } : e.kind === "unparseable" ? { kind: "unparseable" } : Tr(t, e.operationName) ? { kind: "match", operationName: e.operationName } : { kind: "no-match" } : e.kind === "extracted" ? { kind: "skip-no-constraint", operationName: e.operationName } : { kind: "skip-no-constraint", operationName: null };
3785
+ function Tt(t, e) {
3786
+ return t ? e.kind === "not-graphql" ? { kind: "no-match" } : e.kind === "unparseable" ? { kind: "unparseable" } : Pr(t, e.operationName) ? { kind: "match", operationName: e.operationName } : { kind: "no-match" } : e.kind === "extracted" ? { kind: "skip-no-constraint", operationName: e.operationName } : { kind: "skip-no-constraint", operationName: null };
3765
3787
  }
3766
- function tt(t) {
3788
+ function it(t) {
3767
3789
  return typeof Request < "u" && t instanceof Request;
3768
3790
  }
3769
- function Or(t) {
3770
- return tt(t) ? t.url : t.toString();
3791
+ function $r(t) {
3792
+ return it(t) ? t.url : t.toString();
3771
3793
  }
3772
- function Ar(t, e) {
3773
- return e != null && e.method ? e.method.toUpperCase() : tt(t) ? t.method.toUpperCase() : "GET";
3794
+ function jr(t, e) {
3795
+ return e != null && e.method ? e.method.toUpperCase() : it(t) ? t.method.toUpperCase() : "GET";
3774
3796
  }
3775
- function Mr(t, e) {
3797
+ function Lr(t, e) {
3776
3798
  if (e != null && e.signal)
3777
3799
  return e.signal;
3778
- if (tt(t))
3800
+ if (it(t))
3779
3801
  return t.signal;
3780
3802
  }
3781
- function Rr() {
3803
+ function Ir() {
3782
3804
  if (typeof DOMException < "u")
3783
3805
  return new DOMException("The user aborted a request.", "AbortError");
3784
3806
  const t = new Error("The user aborted a request.");
3785
3807
  return t.name = "AbortError", t;
3786
3808
  }
3787
- function jr(t, e) {
3809
+ function Dr(t, e) {
3788
3810
  if (!e)
3789
3811
  return t;
3790
3812
  const n = new AbortController(), s = (i) => {
3791
- o(), n.signal.aborted || n.abort(i.reason);
3792
- }, r = () => s(t), a = () => s(e), o = () => {
3793
- t.removeEventListener("abort", r), e.removeEventListener("abort", a);
3813
+ a(), n.signal.aborted || n.abort(i.reason);
3814
+ }, r = () => s(t), o = () => s(e), a = () => {
3815
+ t.removeEventListener("abort", r), e.removeEventListener("abort", o);
3794
3816
  };
3795
- return t.aborted ? (s(t), n.signal) : e.aborted ? (s(e), n.signal) : (t.addEventListener("abort", r, { once: !0 }), e.addEventListener("abort", a, { once: !0 }), n.signal);
3817
+ return t.aborted ? (s(t), n.signal) : e.aborted ? (s(e), n.signal) : (t.addEventListener("abort", r, { once: !0 }), e.addEventListener("abort", o, { once: !0 }), n.signal);
3796
3818
  }
3797
- function $r(t, e) {
3819
+ function Zr(t, e) {
3798
3820
  return e ? {
3799
3821
  ...t ?? {},
3800
3822
  signal: e
3801
3823
  } : t;
3802
3824
  }
3803
- async function Pr(t, e) {
3825
+ async function Gr(t, e) {
3804
3826
  const n = e == null ? void 0 : e.body;
3805
3827
  if (n != null) {
3806
3828
  if (typeof n == "string") return { text: n, unparseable: !1 };
@@ -3816,7 +3838,7 @@ async function Pr(t, e) {
3816
3838
  }
3817
3839
  return { text: null, unparseable: !0 };
3818
3840
  }
3819
- if (tt(t)) {
3841
+ if (it(t)) {
3820
3842
  if (t.body === null) return { text: null, unparseable: !1 };
3821
3843
  try {
3822
3844
  return { text: await t.clone().text(), unparseable: !1 };
@@ -3837,62 +3859,62 @@ function Ce(t, e, n, s, r) {
3837
3859
  function Ee(t, e, n, s) {
3838
3860
  if (!pe(e, t.urlPattern)) return { proceed: !1, outcome: null };
3839
3861
  if (t.methods && !t.methods.includes(n)) return { proceed: !1, outcome: null };
3840
- const r = St(t.graphqlOperation, s);
3862
+ const r = Tt(t.graphqlOperation, s);
3841
3863
  return r.kind === "no-match" ? { proceed: !1, outcome: r } : { proceed: !0, outcome: r };
3842
3864
  }
3843
- function Oe(t) {
3865
+ function Re(t) {
3844
3866
  return t ? t.kind === "match" || t.kind === "skip-no-constraint" ? t.operationName ? { operationName: t.operationName } : {} : {} : {};
3845
3867
  }
3846
- function zt(t, e, n, s, r, a) {
3868
+ function Kt(t, e, n, s, r, o) {
3847
3869
  t == null || t.emit({
3848
3870
  type: "network:abort",
3849
3871
  timestamp: Date.now(),
3850
3872
  applied: r,
3851
- detail: { url: n, method: s, timeoutMs: e.timeout, ...Oe(a) }
3873
+ detail: { url: n, method: s, timeoutMs: e.timeout, ...Re(o) }
3852
3874
  });
3853
3875
  }
3854
- function Ze(t, e, n, s, r, a) {
3876
+ function qe(t, e, n, s, r, o) {
3855
3877
  t == null || t.emit({
3856
3878
  type: "network:corruption",
3857
3879
  timestamp: Date.now(),
3858
3880
  applied: r,
3859
- detail: { url: n, method: s, strategy: e.strategy, ...Oe(a) }
3881
+ detail: { url: n, method: s, strategy: e.strategy, ...Re(o) }
3860
3882
  });
3861
3883
  }
3862
- function Lr(t) {
3884
+ function Wr(t) {
3863
3885
  return t.graphqlOperation !== void 0;
3864
3886
  }
3865
- function Ir(t, e, n, s, r = /* @__PURE__ */ new Map(), a) {
3866
- return async (o, i) => {
3867
- var S, C, N, Z, j;
3868
- const c = Or(o), u = Ar(o, i), v = Mr(o, i), R = (() => {
3887
+ function qr(t, e, n, s, r = /* @__PURE__ */ new Map(), o) {
3888
+ return async (a, i) => {
3889
+ var S, C, N, Z, P;
3890
+ const c = $r(a), u = jr(a, i), v = Lr(a, i), A = (() => {
3869
3891
  const d = [e.failures, e.latencies, e.aborts, e.corruptions, e.cors];
3870
- for (const M of d)
3871
- if (M != null && M.some(Lr)) return !0;
3892
+ for (const R of d)
3893
+ if (R != null && R.some(Wr)) return !0;
3872
3894
  return !1;
3873
3895
  })();
3874
3896
  let $ = { kind: "not-graphql" };
3875
- if (R) {
3876
- const d = await Pr(o, i);
3877
- $ = zn(u, c, d.text, d.unparseable);
3897
+ if (A) {
3898
+ const d = await Gr(a, i);
3899
+ $ = Kn(u, c, d.text, d.unparseable);
3878
3900
  }
3879
3901
  if (e.cors)
3880
3902
  for (const d of e.cors) {
3881
3903
  s == null || s.debug("rule-evaluating", { url: c, method: u }, d);
3882
- const M = Ee(d, c, u, $);
3883
- if (!M.proceed) {
3904
+ const R = Ee(d, c, u, $);
3905
+ if (!R.proceed) {
3884
3906
  s == null || s.debug("rule-skip-match", { url: c, method: u }, d);
3885
3907
  continue;
3886
3908
  }
3887
3909
  s == null || s.debug("rule-matched", { url: c, method: u }, d);
3888
- const ae = ee(d, r);
3889
- if (!te(d, ae)) {
3910
+ const oe = te(d, r);
3911
+ if (!ne(d, oe)) {
3890
3912
  s == null || s.debug("rule-skip-counting", { url: c, method: u }, d);
3891
3913
  continue;
3892
3914
  }
3893
- if (!V(d, a, s, { url: c, method: u })) continue;
3915
+ if (!V(d, o, s, { url: c, method: u })) continue;
3894
3916
  const G = U(d.probability, n);
3895
- if (((S = M.outcome) == null ? void 0 : S.kind) === "unparseable") {
3917
+ if (((S = R.outcome) == null ? void 0 : S.kind) === "unparseable") {
3896
3918
  G && Ce(s, "network:cors", c, u, {});
3897
3919
  continue;
3898
3920
  }
@@ -3900,55 +3922,55 @@ function Ir(t, e, n, s, r = /* @__PURE__ */ new Map(), a) {
3900
3922
  type: "network:cors",
3901
3923
  timestamp: Date.now(),
3902
3924
  applied: G,
3903
- detail: { url: c, method: u, ...Oe(M.outcome) }
3925
+ detail: { url: c, method: u, ...Re(R.outcome) }
3904
3926
  }), !G) {
3905
3927
  s == null || s.debug("rule-skip-probability", { url: c, method: u }, d);
3906
3928
  continue;
3907
3929
  }
3908
3930
  s == null || s.debug("rule-applied", { url: c, method: u }, d);
3909
- const oe = new TypeError("Failed to fetch");
3910
- throw oe.stack = "", oe;
3931
+ const ae = new TypeError("Failed to fetch");
3932
+ throw ae.stack = "", ae;
3911
3933
  }
3912
3934
  let F = null, X = null, q, p, l = !1;
3913
3935
  const f = (d) => {
3914
- !F || l || (l = !0, p && (clearTimeout(p), p = void 0), zt(s, F, c, u, d, X));
3936
+ !F || l || (l = !0, p && (clearTimeout(p), p = void 0), Kt(s, F, c, u, d, X));
3915
3937
  };
3916
3938
  if (e.aborts)
3917
3939
  for (const d of e.aborts) {
3918
3940
  s == null || s.debug("rule-evaluating", { url: c, method: u, timeoutMs: d.timeout }, d);
3919
- const M = Ee(d, c, u, $);
3920
- if (!M.proceed) {
3941
+ const R = Ee(d, c, u, $);
3942
+ if (!R.proceed) {
3921
3943
  s == null || s.debug("rule-skip-match", { url: c, method: u, timeoutMs: d.timeout }, d);
3922
3944
  continue;
3923
3945
  }
3924
3946
  s == null || s.debug("rule-matched", { url: c, method: u, timeoutMs: d.timeout }, d);
3925
- const ae = ee(d, r);
3926
- if (!te(d, ae)) {
3947
+ const oe = te(d, r);
3948
+ if (!ne(d, oe)) {
3927
3949
  s == null || s.debug("rule-skip-counting", { url: c, method: u, timeoutMs: d.timeout }, d);
3928
3950
  continue;
3929
3951
  }
3930
- if (!V(d, a, s, { url: c, method: u, timeoutMs: d.timeout })) continue;
3952
+ if (!V(d, o, s, { url: c, method: u, timeoutMs: d.timeout })) continue;
3931
3953
  const G = U(d.probability, n);
3932
- if (((C = M.outcome) == null ? void 0 : C.kind) === "unparseable") {
3954
+ if (((C = R.outcome) == null ? void 0 : C.kind) === "unparseable") {
3933
3955
  G && Ce(s, "network:abort", c, u, { timeoutMs: d.timeout });
3934
3956
  continue;
3935
3957
  }
3936
3958
  if (!G) {
3937
- s == null || s.debug("rule-skip-probability", { url: c, method: u, timeoutMs: d.timeout }, d), zt(s, d, c, u, !1, M.outcome);
3959
+ s == null || s.debug("rule-skip-probability", { url: c, method: u, timeoutMs: d.timeout }, d), Kt(s, d, c, u, !1, R.outcome);
3938
3960
  continue;
3939
3961
  }
3940
- s == null || s.debug("rule-applied", { url: c, method: u, timeoutMs: d.timeout }, d), console.warn(`CHAOS: Aborting ${u} ${c} after ${d.timeout || 0}ms`), F = d, X = M.outcome;
3941
- const oe = new AbortController();
3942
- q = jr(oe.signal, v);
3943
- const De = () => {
3944
- l || (f(!0), oe.abort(Rr()));
3962
+ s == null || s.debug("rule-applied", { url: c, method: u, timeoutMs: d.timeout }, d), console.warn(`CHAOS: Aborting ${u} ${c} after ${d.timeout || 0}ms`), F = d, X = R.outcome;
3963
+ const ae = new AbortController();
3964
+ q = Dr(ae.signal, v);
3965
+ const We = () => {
3966
+ l || (f(!0), ae.abort(Ir()));
3945
3967
  };
3946
- d.timeout ? p = setTimeout(De, d.timeout) : De();
3968
+ d.timeout ? p = setTimeout(We, d.timeout) : We();
3947
3969
  break;
3948
3970
  }
3949
3971
  if (F)
3950
3972
  try {
3951
- const d = await t(o, $r(i, q));
3973
+ const d = await t(a, Zr(i, q));
3952
3974
  return f(!1), d;
3953
3975
  } catch (d) {
3954
3976
  throw f(!1), d;
@@ -3956,20 +3978,20 @@ function Ir(t, e, n, s, r = /* @__PURE__ */ new Map(), a) {
3956
3978
  if (e.failures)
3957
3979
  for (const d of e.failures) {
3958
3980
  s == null || s.debug("rule-evaluating", { url: c, method: u, statusCode: d.statusCode }, d);
3959
- const M = Ee(d, c, u, $);
3960
- if (!M.proceed) {
3981
+ const R = Ee(d, c, u, $);
3982
+ if (!R.proceed) {
3961
3983
  s == null || s.debug("rule-skip-match", { url: c, method: u, statusCode: d.statusCode }, d);
3962
3984
  continue;
3963
3985
  }
3964
3986
  s == null || s.debug("rule-matched", { url: c, method: u, statusCode: d.statusCode }, d);
3965
- const ae = ee(d, r);
3966
- if (!te(d, ae)) {
3987
+ const oe = te(d, r);
3988
+ if (!ne(d, oe)) {
3967
3989
  s == null || s.debug("rule-skip-counting", { url: c, method: u, statusCode: d.statusCode }, d);
3968
3990
  continue;
3969
3991
  }
3970
- if (!V(d, a, s, { url: c, method: u, statusCode: d.statusCode })) continue;
3992
+ if (!V(d, o, s, { url: c, method: u, statusCode: d.statusCode })) continue;
3971
3993
  const G = U(d.probability, n);
3972
- if (((N = M.outcome) == null ? void 0 : N.kind) === "unparseable") {
3994
+ if (((N = R.outcome) == null ? void 0 : N.kind) === "unparseable") {
3973
3995
  G && Ce(s, "network:failure", c, u, { statusCode: d.statusCode });
3974
3996
  continue;
3975
3997
  }
@@ -3977,36 +3999,36 @@ function Ir(t, e, n, s, r = /* @__PURE__ */ new Map(), a) {
3977
3999
  type: "network:failure",
3978
4000
  timestamp: Date.now(),
3979
4001
  applied: G,
3980
- detail: { url: c, method: u, statusCode: d.statusCode, ...Oe(M.outcome) }
4002
+ detail: { url: c, method: u, statusCode: d.statusCode, ...Re(R.outcome) }
3981
4003
  }), !G) {
3982
4004
  s == null || s.debug("rule-skip-probability", { url: c, method: u, statusCode: d.statusCode }, d);
3983
4005
  continue;
3984
4006
  }
3985
4007
  s == null || s.debug("rule-applied", { url: c, method: u, statusCode: d.statusCode }, d), console.warn(`CHAOS: Forcing ${d.statusCode} for ${u} ${c}`);
3986
- const oe = d.body ?? JSON.stringify({ error: "Chaos Maker Attack!" }), De = d.headers ?? {};
3987
- return new Response(oe, {
4008
+ const ae = d.body ?? JSON.stringify({ error: "Chaos Maker Attack!" }), We = d.headers ?? {};
4009
+ return new Response(ae, {
3988
4010
  status: d.statusCode,
3989
4011
  statusText: d.statusText ?? "Service Unavailable (Chaos)",
3990
- headers: De
4012
+ headers: We
3991
4013
  });
3992
4014
  }
3993
4015
  if (e.latencies)
3994
4016
  for (const d of e.latencies) {
3995
4017
  s == null || s.debug("rule-evaluating", { url: c, method: u, delayMs: d.delayMs }, d);
3996
- const M = Ee(d, c, u, $);
3997
- if (!M.proceed) {
4018
+ const R = Ee(d, c, u, $);
4019
+ if (!R.proceed) {
3998
4020
  s == null || s.debug("rule-skip-match", { url: c, method: u, delayMs: d.delayMs }, d);
3999
4021
  continue;
4000
4022
  }
4001
4023
  s == null || s.debug("rule-matched", { url: c, method: u, delayMs: d.delayMs }, d);
4002
- const ae = ee(d, r);
4003
- if (!te(d, ae)) {
4024
+ const oe = te(d, r);
4025
+ if (!ne(d, oe)) {
4004
4026
  s == null || s.debug("rule-skip-counting", { url: c, method: u, delayMs: d.delayMs }, d);
4005
4027
  continue;
4006
4028
  }
4007
- if (!V(d, a, s, { url: c, method: u, delayMs: d.delayMs })) continue;
4029
+ if (!V(d, o, s, { url: c, method: u, delayMs: d.delayMs })) continue;
4008
4030
  const G = U(d.probability, n);
4009
- if (((Z = M.outcome) == null ? void 0 : Z.kind) === "unparseable") {
4031
+ if (((Z = R.outcome) == null ? void 0 : Z.kind) === "unparseable") {
4010
4032
  G && Ce(s, "network:latency", c, u, { delayMs: d.delayMs });
4011
4033
  continue;
4012
4034
  }
@@ -4014,72 +4036,72 @@ function Ir(t, e, n, s, r = /* @__PURE__ */ new Map(), a) {
4014
4036
  type: "network:latency",
4015
4037
  timestamp: Date.now(),
4016
4038
  applied: G,
4017
- detail: { url: c, method: u, delayMs: d.delayMs, ...Oe(M.outcome) }
4039
+ detail: { url: c, method: u, delayMs: d.delayMs, ...Re(R.outcome) }
4018
4040
  }), !G) {
4019
4041
  s == null || s.debug("rule-skip-probability", { url: c, method: u, delayMs: d.delayMs }, d);
4020
4042
  continue;
4021
4043
  }
4022
- s == null || s.debug("rule-applied", { url: c, method: u, delayMs: d.delayMs }, d), console.warn(`CHAOS: Adding ${d.delayMs}ms latency to ${u} ${c}`), await new Promise((oe) => setTimeout(oe, d.delayMs));
4044
+ s == null || s.debug("rule-applied", { url: c, method: u, delayMs: d.delayMs }, d), console.warn(`CHAOS: Adding ${d.delayMs}ms latency to ${u} ${c}`), await new Promise((ae) => setTimeout(ae, d.delayMs));
4023
4045
  }
4024
4046
  let y = null, k = null;
4025
4047
  if (e.corruptions)
4026
4048
  for (const d of e.corruptions) {
4027
4049
  s == null || s.debug("rule-evaluating", { url: c, method: u, strategy: d.strategy }, d);
4028
- const M = Ee(d, c, u, $);
4029
- if (!M.proceed) {
4050
+ const R = Ee(d, c, u, $);
4051
+ if (!R.proceed) {
4030
4052
  s == null || s.debug("rule-skip-match", { url: c, method: u, strategy: d.strategy }, d);
4031
4053
  continue;
4032
4054
  }
4033
4055
  s == null || s.debug("rule-matched", { url: c, method: u, strategy: d.strategy }, d);
4034
- const ae = ee(d, r);
4035
- if (!te(d, ae)) {
4056
+ const oe = te(d, r);
4057
+ if (!ne(d, oe)) {
4036
4058
  s == null || s.debug("rule-skip-counting", { url: c, method: u, strategy: d.strategy }, d);
4037
4059
  continue;
4038
4060
  }
4039
- if (!V(d, a, s, { url: c, method: u, strategy: d.strategy })) continue;
4061
+ if (!V(d, o, s, { url: c, method: u, strategy: d.strategy })) continue;
4040
4062
  const G = U(d.probability, n);
4041
- if (((j = M.outcome) == null ? void 0 : j.kind) === "unparseable") {
4063
+ if (((P = R.outcome) == null ? void 0 : P.kind) === "unparseable") {
4042
4064
  G && Ce(s, "network:corruption", c, u, { strategy: d.strategy });
4043
4065
  continue;
4044
4066
  }
4045
4067
  if (!G) {
4046
- s == null || s.debug("rule-skip-probability", { url: c, method: u, strategy: d.strategy }, d), Ze(s, d, c, u, !1, M.outcome);
4068
+ s == null || s.debug("rule-skip-probability", { url: c, method: u, strategy: d.strategy }, d), qe(s, d, c, u, !1, R.outcome);
4047
4069
  continue;
4048
4070
  }
4049
- s == null || s.debug("rule-applied", { url: c, method: u, strategy: d.strategy }, d), y = d, k = M.outcome;
4071
+ s == null || s.debug("rule-applied", { url: c, method: u, strategy: d.strategy }, d), y = d, k = R.outcome;
4050
4072
  break;
4051
4073
  }
4052
4074
  let _;
4053
4075
  try {
4054
- _ = await t(o, i);
4076
+ _ = await t(a, i);
4055
4077
  } catch (d) {
4056
- throw y && Ze(s, y, c, u, !1, k), d;
4078
+ throw y && qe(s, y, c, u, !1, k), d;
4057
4079
  }
4058
4080
  if (!y)
4059
4081
  return _;
4060
4082
  try {
4061
4083
  console.warn(`CHAOS: Corrupting response for ${u} ${c} with strategy: ${y.strategy}`);
4062
- const d = await _.text(), M = bt(d, y.strategy);
4063
- return Ze(s, y, c, u, !0, k), new Response(M, {
4084
+ const d = await _.text(), R = St(d, y.strategy);
4085
+ return qe(s, y, c, u, !0, k), new Response(R, {
4064
4086
  status: _.status,
4065
4087
  statusText: _.statusText,
4066
4088
  headers: _.headers
4067
4089
  });
4068
4090
  } catch (d) {
4069
- throw Ze(s, y, c, u, !1, k), d;
4091
+ throw qe(s, y, c, u, !1, k), d;
4070
4092
  }
4071
4093
  };
4072
4094
  }
4073
- function Dr(t) {
4095
+ function Ur(t) {
4074
4096
  return t == null ? { text: null, unparseable: !1 } : typeof t == "string" ? { text: t, unparseable: !1 } : typeof URLSearchParams < "u" && t instanceof URLSearchParams ? { text: t.toString(), unparseable: !1 } : { text: null, unparseable: !0 };
4075
4097
  }
4076
- function Zr(t) {
4098
+ function Vr(t) {
4077
4099
  return t.graphqlOperation !== void 0;
4078
4100
  }
4079
- function Gr(t) {
4101
+ function zr(t) {
4080
4102
  const e = [t.failures, t.latencies, t.aborts, t.corruptions, t.cors];
4081
4103
  for (const n of e)
4082
- if (n != null && n.some(Zr)) return !0;
4104
+ if (n != null && n.some(Vr)) return !0;
4083
4105
  return !1;
4084
4106
  }
4085
4107
  function Ne(t, e, n, s, r) {
@@ -4090,43 +4112,43 @@ function Ne(t, e, n, s, r) {
4090
4112
  detail: { url: n, method: s, ...r, reason: "graphql-body-unparseable" }
4091
4113
  });
4092
4114
  }
4093
- function Ge(t, e, n, s, r) {
4115
+ function Ue(t, e, n, s, r) {
4094
4116
  if (!pe(e, t.urlPattern)) return { proceed: !1, outcome: null };
4095
4117
  if (t.methods && !t.methods.includes(n)) return { proceed: !1, outcome: null };
4096
- const a = St(t.graphqlOperation, s);
4097
- if (a.kind === "no-match" || a.kind === "unparseable")
4098
- return { proceed: !1, outcome: a };
4099
- const o = ee(t, r);
4100
- return te(t, o) ? { proceed: !0, outcome: a } : { proceed: !1, outcome: a };
4118
+ const o = Tt(t.graphqlOperation, s);
4119
+ if (o.kind === "no-match" || o.kind === "unparseable")
4120
+ return { proceed: !1, outcome: o };
4121
+ const a = te(t, r);
4122
+ return ne(t, a) ? { proceed: !0, outcome: o } : { proceed: !1, outcome: o };
4101
4123
  }
4102
4124
  function Ae(t) {
4103
4125
  return t ? t.kind === "match" || t.kind === "skip-no-constraint" ? t.operationName ? { operationName: t.operationName } : {} : {} : {};
4104
4126
  }
4105
- function Ft(t, e, n, s, r, a) {
4127
+ function Yt(t, e, n, s, r, o) {
4106
4128
  t == null || t.emit({
4107
4129
  type: "network:abort",
4108
4130
  timestamp: Date.now(),
4109
4131
  applied: r,
4110
- detail: { url: n, method: s, timeoutMs: e.timeout, ...Ae(a) }
4132
+ detail: { url: n, method: s, timeoutMs: e.timeout, ...Ae(o) }
4111
4133
  });
4112
4134
  }
4113
- function Bt(t, e, n, s, r, a) {
4135
+ function Xt(t, e, n, s, r, o) {
4114
4136
  t == null || t.emit({
4115
4137
  type: "network:corruption",
4116
4138
  timestamp: Date.now(),
4117
4139
  applied: r,
4118
- detail: { url: n, method: s, strategy: e.strategy, ...Ae(a) }
4140
+ detail: { url: n, method: s, strategy: e.strategy, ...Ae(o) }
4119
4141
  });
4120
4142
  }
4121
- function Wr(t, e, n, s, r = /* @__PURE__ */ new Map(), a) {
4122
- const o = Gr(e);
4143
+ function Fr(t, e, n, s, r = /* @__PURE__ */ new Map(), o) {
4144
+ const a = zr(e);
4123
4145
  return function(i) {
4124
4146
  var F, X, q, p;
4125
4147
  const c = this._chaos_url, u = this._chaos_method;
4126
4148
  let v = { kind: "not-graphql" };
4127
- if (o) {
4128
- const l = Dr(i);
4129
- v = zn(u, c, l.text, l.unparseable);
4149
+ if (a) {
4150
+ const l = Ur(i);
4151
+ v = Kn(u, c, l.text, l.unparseable);
4130
4152
  }
4131
4153
  if (e.cors)
4132
4154
  for (const l of e.cors) {
@@ -4138,7 +4160,7 @@ function Wr(t, e, n, s, r = /* @__PURE__ */ new Map(), a) {
4138
4160
  s == null || s.debug("rule-skip-match", { url: c, method: u }, l);
4139
4161
  continue;
4140
4162
  }
4141
- const f = St(l.graphqlOperation, v);
4163
+ const f = Tt(l.graphqlOperation, v);
4142
4164
  if (f.kind === "no-match") {
4143
4165
  s == null || s.debug("rule-skip-match", { url: c, method: u }, l);
4144
4166
  continue;
@@ -4148,12 +4170,12 @@ function Wr(t, e, n, s, r = /* @__PURE__ */ new Map(), a) {
4148
4170
  continue;
4149
4171
  }
4150
4172
  s == null || s.debug("rule-matched", { url: c, method: u }, l);
4151
- const y = ee(l, r);
4152
- if (!te(l, y)) {
4173
+ const y = te(l, r);
4174
+ if (!ne(l, y)) {
4153
4175
  s == null || s.debug("rule-skip-counting", { url: c, method: u }, l);
4154
4176
  continue;
4155
4177
  }
4156
- if (!V(l, a, s, { url: c, method: u })) continue;
4178
+ if (!V(l, o, s, { url: c, method: u })) continue;
4157
4179
  const k = U(l.probability, n);
4158
4180
  if (s == null || s.emit({
4159
4181
  type: "network:cors",
@@ -4170,22 +4192,22 @@ function Wr(t, e, n, s, r = /* @__PURE__ */ new Map(), a) {
4170
4192
  if (e.aborts)
4171
4193
  for (const l of e.aborts) {
4172
4194
  s == null || s.debug("rule-evaluating", { url: c, method: u, timeoutMs: l.timeout }, l);
4173
- const f = Ge(l, c, u, v, r);
4195
+ const f = Ue(l, c, u, v, r);
4174
4196
  if (!f.proceed) {
4175
4197
  ((F = f.outcome) == null ? void 0 : F.kind) === "unparseable" ? Ne(s, "network:abort", c, u, { timeoutMs: l.timeout }) : s == null || s.debug("rule-skip-match", { url: c, method: u, timeoutMs: l.timeout }, l);
4176
4198
  continue;
4177
4199
  }
4178
- if (s == null || s.debug("rule-matched", { url: c, method: u, timeoutMs: l.timeout }, l), !V(l, a, s, { url: c, method: u, timeoutMs: l.timeout })) continue;
4200
+ if (s == null || s.debug("rule-matched", { url: c, method: u, timeoutMs: l.timeout }, l), !V(l, o, s, { url: c, method: u, timeoutMs: l.timeout })) continue;
4179
4201
  if (!U(l.probability, n)) {
4180
- s == null || s.debug("rule-skip-probability", { url: c, method: u, timeoutMs: l.timeout }, l), Ft(s, l, c, u, !1, f.outcome);
4202
+ s == null || s.debug("rule-skip-probability", { url: c, method: u, timeoutMs: l.timeout }, l), Yt(s, l, c, u, !1, f.outcome);
4181
4203
  continue;
4182
4204
  }
4183
4205
  s == null || s.debug("rule-applied", { url: c, method: u, timeoutMs: l.timeout }, l), console.warn(`CHAOS: Aborting ${u} ${c} after ${l.timeout || 0}ms`);
4184
4206
  let k = !1, _;
4185
4207
  const S = () => {
4186
4208
  _ && (clearTimeout(_), _ = void 0), typeof this.removeEventListener == "function" && this.removeEventListener("loadend", N);
4187
- }, C = (j) => {
4188
- k || (k = !0, S(), Ft(s, l, c, u, j, f.outcome));
4209
+ }, C = (P) => {
4210
+ k || (k = !0, S(), Yt(s, l, c, u, P, f.outcome));
4189
4211
  }, N = () => {
4190
4212
  C(!1);
4191
4213
  }, Z = () => {
@@ -4194,8 +4216,8 @@ function Wr(t, e, n, s, r = /* @__PURE__ */ new Map(), a) {
4194
4216
  typeof this.addEventListener == "function" && this.addEventListener("loadend", N);
4195
4217
  try {
4196
4218
  t.call(this, i);
4197
- } catch (j) {
4198
- throw C(!1), j;
4219
+ } catch (P) {
4220
+ throw C(!1), P;
4199
4221
  }
4200
4222
  if (k)
4201
4223
  return;
@@ -4205,12 +4227,12 @@ function Wr(t, e, n, s, r = /* @__PURE__ */ new Map(), a) {
4205
4227
  if (e.failures)
4206
4228
  for (const l of e.failures) {
4207
4229
  s == null || s.debug("rule-evaluating", { url: c, method: u, statusCode: l.statusCode }, l);
4208
- const f = Ge(l, c, u, v, r);
4230
+ const f = Ue(l, c, u, v, r);
4209
4231
  if (!f.proceed) {
4210
4232
  ((X = f.outcome) == null ? void 0 : X.kind) === "unparseable" ? Ne(s, "network:failure", c, u, { statusCode: l.statusCode }) : s == null || s.debug("rule-skip-match", { url: c, method: u, statusCode: l.statusCode }, l);
4211
4233
  continue;
4212
4234
  }
4213
- if (s == null || s.debug("rule-matched", { url: c, method: u, statusCode: l.statusCode }, l), !V(l, a, s, { url: c, method: u, statusCode: l.statusCode })) continue;
4235
+ if (s == null || s.debug("rule-matched", { url: c, method: u, statusCode: l.statusCode }, l), !V(l, o, s, { url: c, method: u, statusCode: l.statusCode })) continue;
4214
4236
  const y = U(l.probability, n);
4215
4237
  if (s == null || s.emit({
4216
4238
  type: "network:failure",
@@ -4242,36 +4264,36 @@ function Wr(t, e, n, s, r = /* @__PURE__ */ new Map(), a) {
4242
4264
  }), this.dispatchEvent(new Event("load")), this.dispatchEvent(new Event("loadend"));
4243
4265
  return;
4244
4266
  }
4245
- let R = null, $ = null;
4267
+ let A = null, $ = null;
4246
4268
  if (e.corruptions)
4247
4269
  for (const l of e.corruptions) {
4248
4270
  s == null || s.debug("rule-evaluating", { url: c, method: u, strategy: l.strategy }, l);
4249
- const f = Ge(l, c, u, v, r);
4271
+ const f = Ue(l, c, u, v, r);
4250
4272
  if (!f.proceed) {
4251
4273
  ((q = f.outcome) == null ? void 0 : q.kind) === "unparseable" ? Ne(s, "network:corruption", c, u, { strategy: l.strategy }) : s == null || s.debug("rule-skip-match", { url: c, method: u, strategy: l.strategy }, l);
4252
4274
  continue;
4253
4275
  }
4254
- if (s == null || s.debug("rule-matched", { url: c, method: u, strategy: l.strategy }, l), !V(l, a, s, { url: c, method: u, strategy: l.strategy })) continue;
4276
+ if (s == null || s.debug("rule-matched", { url: c, method: u, strategy: l.strategy }, l), !V(l, o, s, { url: c, method: u, strategy: l.strategy })) continue;
4255
4277
  if (!U(l.probability, n)) {
4256
- s == null || s.debug("rule-skip-probability", { url: c, method: u, strategy: l.strategy }, l), Bt(s, l, c, u, !1, f.outcome);
4278
+ s == null || s.debug("rule-skip-probability", { url: c, method: u, strategy: l.strategy }, l), Xt(s, l, c, u, !1, f.outcome);
4257
4279
  continue;
4258
4280
  }
4259
- s == null || s.debug("rule-applied", { url: c, method: u, strategy: l.strategy }, l), R = l, $ = f.outcome;
4281
+ s == null || s.debug("rule-applied", { url: c, method: u, strategy: l.strategy }, l), A = l, $ = f.outcome;
4260
4282
  break;
4261
4283
  }
4262
- if (R) {
4284
+ if (A) {
4263
4285
  let l = !1, f = null;
4264
4286
  const y = () => {
4265
4287
  typeof this.removeEventListener == "function" && (this.removeEventListener("error", S), this.removeEventListener("abort", S), this.removeEventListener("loadend", C));
4266
4288
  }, k = (N) => {
4267
- l || (l = !0, Bt(s, R, c, u, N, $), y());
4289
+ l || (l = !0, Xt(s, A, c, u, N, $), y());
4268
4290
  }, _ = () => {
4269
4291
  if (f !== null)
4270
4292
  return f;
4271
4293
  delete this.responseText;
4272
4294
  try {
4273
4295
  const N = this.responseText;
4274
- return typeof N != "string" ? (Object.defineProperty(this, "responseText", { value: N, configurable: !0 }), k(!1), N) : (f = bt(N, R.strategy), Object.defineProperty(this, "responseText", { value: f, configurable: !0 }), k(!0), f);
4296
+ return typeof N != "string" ? (Object.defineProperty(this, "responseText", { value: N, configurable: !0 }), k(!1), N) : (f = St(N, A.strategy), Object.defineProperty(this, "responseText", { value: f, configurable: !0 }), k(!0), f);
4275
4297
  } catch (N) {
4276
4298
  throw k(!1), N;
4277
4299
  }
@@ -4294,12 +4316,12 @@ function Wr(t, e, n, s, r = /* @__PURE__ */ new Map(), a) {
4294
4316
  if (e.latencies)
4295
4317
  for (const l of e.latencies) {
4296
4318
  s == null || s.debug("rule-evaluating", { url: c, method: u, delayMs: l.delayMs }, l);
4297
- const f = Ge(l, c, u, v, r);
4319
+ const f = Ue(l, c, u, v, r);
4298
4320
  if (!f.proceed) {
4299
4321
  ((p = f.outcome) == null ? void 0 : p.kind) === "unparseable" ? Ne(s, "network:latency", c, u, { delayMs: l.delayMs }) : s == null || s.debug("rule-skip-match", { url: c, method: u, delayMs: l.delayMs }, l);
4300
4322
  continue;
4301
4323
  }
4302
- if (s == null || s.debug("rule-matched", { url: c, method: u, delayMs: l.delayMs }, l), !V(l, a, s, { url: c, method: u, delayMs: l.delayMs })) continue;
4324
+ if (s == null || s.debug("rule-matched", { url: c, method: u, delayMs: l.delayMs }, l), !V(l, o, s, { url: c, method: u, delayMs: l.delayMs })) continue;
4303
4325
  const y = U(l.probability, n);
4304
4326
  if (s == null || s.emit({
4305
4327
  type: "network:latency",
@@ -4318,20 +4340,20 @@ function Wr(t, e, n, s, r = /* @__PURE__ */ new Map(), a) {
4318
4340
  t.call(this, i);
4319
4341
  };
4320
4342
  }
4321
- function qr(t) {
4343
+ function Br(t) {
4322
4344
  return function(e, n) {
4323
4345
  this._chaos_url = n.toString(), this._chaos_method = e.toUpperCase(), t.call(this, e, n);
4324
4346
  };
4325
4347
  }
4326
- function gt(t, e, n, s, r) {
4348
+ function _t(t, e, n, s, r) {
4327
4349
  if (s == null || s.debug("rule-evaluating", { selector: e.selector, action: e.action }, e), s == null || s.debug("rule-matched", { selector: e.selector, action: e.action }, e), !V(e, r, s, { selector: e.selector, action: e.action })) return;
4328
- const a = U(e.probability, n);
4350
+ const o = U(e.probability, n);
4329
4351
  if (s == null || s.emit({
4330
4352
  type: "ui:assault",
4331
4353
  timestamp: Date.now(),
4332
- applied: a,
4354
+ applied: o,
4333
4355
  detail: { selector: e.selector, action: e.action }
4334
- }), !a) {
4356
+ }), !o) {
4335
4357
  s == null || s.debug("rule-skip-probability", { selector: e.selector, action: e.action }, e);
4336
4358
  return;
4337
4359
  }
@@ -4348,48 +4370,48 @@ function gt(t, e, n, s, r) {
4348
4370
  t.remove();
4349
4371
  break;
4350
4372
  }
4351
- } catch (o) {
4352
- console.error("Chaos Maker failed to assault element:", o, t);
4373
+ } catch (a) {
4374
+ console.error("Chaos Maker failed to assault element:", a, t);
4353
4375
  }
4354
4376
  }
4355
- function Ur(t, e, n, s, r) {
4377
+ function Hr(t, e, n, s, r) {
4356
4378
  if (t.nodeType !== Node.ELEMENT_NODE || !e.assaults)
4357
4379
  return;
4358
- const a = t;
4359
- for (const o of e.assaults)
4380
+ const o = t;
4381
+ for (const a of e.assaults)
4360
4382
  try {
4361
- a.matches(o.selector) && gt(a, o, n, s, r), a.querySelectorAll(o.selector).forEach((i) => {
4362
- gt(i, o, n, s, r);
4383
+ o.matches(a.selector) && _t(o, a, n, s, r), o.querySelectorAll(a.selector).forEach((i) => {
4384
+ _t(i, a, n, s, r);
4363
4385
  });
4364
4386
  } catch (i) {
4365
- console.error(`Chaos Maker: Invalid selector '${o.selector}'`, i);
4387
+ console.error(`Chaos Maker: Invalid selector '${a.selector}'`, i);
4366
4388
  }
4367
4389
  }
4368
- function Vr(t, e, n, s) {
4390
+ function Kr(t, e, n, s) {
4369
4391
  if (t.assaults) {
4370
4392
  console.log("CHAOS: Running initial DOM scan for existing elements...");
4371
- for (const a of t.assaults)
4393
+ for (const o of t.assaults)
4372
4394
  try {
4373
- document.querySelectorAll(a.selector).forEach((o) => {
4374
- gt(o, a, e, n, s);
4395
+ document.querySelectorAll(o.selector).forEach((a) => {
4396
+ _t(a, o, e, n, s);
4375
4397
  });
4376
- } catch (o) {
4377
- console.error(`Chaos Maker: Invalid selector in initial scan '${a.selector}'`, o);
4398
+ } catch (a) {
4399
+ console.error(`Chaos Maker: Invalid selector in initial scan '${o.selector}'`, a);
4378
4400
  }
4379
4401
  }
4380
- return new MutationObserver((a) => {
4381
- for (const o of a)
4382
- o.type === "childList" && o.addedNodes.forEach((i) => Ur(i, t, e, n, s));
4402
+ return new MutationObserver((o) => {
4403
+ for (const a of o)
4404
+ a.type === "childList" && a.addedNodes.forEach((i) => Hr(i, t, e, n, s));
4383
4405
  });
4384
4406
  }
4385
- const Ht = /* @__PURE__ */ Symbol.for("chaos-maker.websocket.intercepted");
4386
- function zr(t, e) {
4407
+ const Jt = /* @__PURE__ */ Symbol.for("chaos-maker.websocket.intercepted");
4408
+ function Yr(t, e) {
4387
4409
  return t === "both" ? !0 : t === e;
4388
4410
  }
4389
- function Yt(t) {
4411
+ function Qt(t) {
4390
4412
  return typeof t == "string" ? "text" : "binary";
4391
4413
  }
4392
- function Kt(t, e) {
4414
+ function en(t, e) {
4393
4415
  switch (e) {
4394
4416
  case "truncate":
4395
4417
  return t.slice(0, Math.max(0, Math.floor(t.length / 2)));
@@ -4401,7 +4423,7 @@ function Kt(t, e) {
4401
4423
  return "<html><body>Unexpected HTML</body></html>";
4402
4424
  }
4403
4425
  }
4404
- function Xt(t, e) {
4426
+ function tn(t, e) {
4405
4427
  if (e === "malformed-json" || e === "wrong-type") return null;
4406
4428
  if (e === "empty")
4407
4429
  return typeof Blob < "u" && t instanceof Blob ? new Blob([]) : t instanceof ArrayBuffer ? new ArrayBuffer(0) : new Uint8Array(0);
@@ -4412,34 +4434,34 @@ function Xt(t, e) {
4412
4434
  const n = t, s = Math.max(0, Math.floor(n.byteLength / 2));
4413
4435
  return new Uint8Array(n.buffer.slice(n.byteOffset, n.byteOffset + s));
4414
4436
  }
4415
- function ge(t, e, n, s, r, a, o) {
4437
+ function ge(t, e, n, s, r, o, a) {
4416
4438
  if (!t) return null;
4417
4439
  for (const i of t) {
4418
- if (o == null || o.debug("rule-evaluating", { url: e, direction: n }, i), !pe(e, i.urlPattern)) {
4419
- o == null || o.debug("rule-skip-match", { url: e, direction: n }, i);
4440
+ if (a == null || a.debug("rule-evaluating", { url: e, direction: n }, i), !pe(e, i.urlPattern)) {
4441
+ a == null || a.debug("rule-skip-match", { url: e, direction: n }, i);
4420
4442
  continue;
4421
4443
  }
4422
- if (!zr(i.direction, n)) {
4423
- o == null || o.debug("rule-skip-match", { url: e, direction: n }, i);
4444
+ if (!Yr(i.direction, n)) {
4445
+ a == null || a.debug("rule-skip-match", { url: e, direction: n }, i);
4424
4446
  continue;
4425
4447
  }
4426
- o == null || o.debug("rule-matched", { url: e, direction: n }, i);
4427
- const c = ee(i, r);
4428
- if (!te(i, c)) {
4429
- o == null || o.debug("rule-skip-counting", { url: e, direction: n }, i);
4448
+ a == null || a.debug("rule-matched", { url: e, direction: n }, i);
4449
+ const c = te(i, r);
4450
+ if (!ne(i, c)) {
4451
+ a == null || a.debug("rule-skip-counting", { url: e, direction: n }, i);
4430
4452
  continue;
4431
4453
  }
4432
- if (V(i, a, o, { url: e, direction: n })) {
4454
+ if (V(i, o, a, { url: e, direction: n })) {
4433
4455
  if (!U(i.probability, s)) {
4434
- o == null || o.debug("rule-skip-probability", { url: e, direction: n }, i);
4456
+ a == null || a.debug("rule-skip-probability", { url: e, direction: n }, i);
4435
4457
  continue;
4436
4458
  }
4437
- return o == null || o.debug("rule-applied", { url: e, direction: n }, i), i;
4459
+ return a == null || a.debug("rule-applied", { url: e, direction: n }, i), i;
4438
4460
  }
4439
4461
  }
4440
4462
  return null;
4441
4463
  }
4442
- function We(t, e, n, s, r) {
4464
+ function Ve(t, e, n, s, r) {
4443
4465
  t.emit({
4444
4466
  type: "websocket:drop",
4445
4467
  timestamp: Date.now(),
@@ -4447,7 +4469,7 @@ function We(t, e, n, s, r) {
4447
4469
  detail: { url: e, direction: n, payloadType: s, ...r ? { reason: r } : {} }
4448
4470
  });
4449
4471
  }
4450
- function Jt(t, e, n, s, r) {
4472
+ function nn(t, e, n, s, r) {
4451
4473
  t.emit({
4452
4474
  type: "websocket:delay",
4453
4475
  timestamp: Date.now(),
@@ -4455,15 +4477,15 @@ function Jt(t, e, n, s, r) {
4455
4477
  detail: { url: e, direction: n, payloadType: s, delayMs: r }
4456
4478
  });
4457
4479
  }
4458
- function ye(t, e, n, s, r, a, o) {
4480
+ function ye(t, e, n, s, r, o, a) {
4459
4481
  t.emit({
4460
4482
  type: "websocket:corrupt",
4461
4483
  timestamp: Date.now(),
4462
- applied: a,
4463
- detail: { url: e, direction: n, payloadType: s, strategy: r, ...o ? { reason: o } : {} }
4484
+ applied: o,
4485
+ detail: { url: e, direction: n, payloadType: s, strategy: r, ...a ? { reason: a } : {} }
4464
4486
  });
4465
4487
  }
4466
- function Fr(t, e, n, s) {
4488
+ function Xr(t, e, n, s) {
4467
4489
  t.emit({
4468
4490
  type: "websocket:close",
4469
4491
  timestamp: Date.now(),
@@ -4471,23 +4493,23 @@ function Fr(t, e, n, s) {
4471
4493
  detail: { url: e, closeCode: n, closeReason: s }
4472
4494
  });
4473
4495
  }
4474
- function Br(t, e, n, s, r, a) {
4475
- const o = /* @__PURE__ */ new Map();
4496
+ function Jr(t, e, n, s, r, o) {
4497
+ const a = /* @__PURE__ */ new Map();
4476
4498
  let i = !0;
4477
4499
  const c = (p, l) => {
4478
- let f = o.get(p);
4479
- f || (f = /* @__PURE__ */ new Set(), o.set(p, f)), f.add(l);
4500
+ let f = a.get(p);
4501
+ f || (f = /* @__PURE__ */ new Set(), a.set(p, f)), f.add(l);
4480
4502
  }, u = (p, l) => {
4481
4503
  var f;
4482
- (f = o.get(p)) == null || f.delete(l);
4504
+ (f = a.get(p)) == null || f.delete(l);
4483
4505
  }, v = (p, l) => {
4484
- const f = o.get(p);
4506
+ const f = a.get(p);
4485
4507
  if (f) {
4486
4508
  for (const y of f)
4487
- clearTimeout(y.handle), y.kind === "delay" && We(n, y.url, y.direction, y.payloadType, l);
4488
- o.delete(p);
4509
+ clearTimeout(y.handle), y.kind === "delay" && Ve(n, y.url, y.direction, y.payloadType, l);
4510
+ a.delete(p);
4489
4511
  }
4490
- }, R = (p, l, f) => {
4512
+ }, A = (p, l, f) => {
4491
4513
  const y = new MessageEvent("message", {
4492
4514
  data: f,
4493
4515
  origin: l.origin,
@@ -4495,32 +4517,32 @@ function Br(t, e, n, s, r, a) {
4495
4517
  source: l.source,
4496
4518
  ports: Array.from(l.ports ?? [])
4497
4519
  });
4498
- y[Ht] = !0, p.dispatchEvent(y);
4520
+ y[Jt] = !0, p.dispatchEvent(y);
4499
4521
  }, $ = (p, l, f, y) => {
4500
4522
  if (!i) return { handled: !1, data: f };
4501
- const k = "outbound", _ = Yt(f);
4502
- if (ge(e.drops, l, k, s, r, a, n))
4503
- return We(n, l, k, _), { handled: !0, data: f };
4523
+ const k = "outbound", _ = Qt(f);
4524
+ if (ge(e.drops, l, k, s, r, o, n))
4525
+ return Ve(n, l, k, _), { handled: !0, data: f };
4504
4526
  let S = f;
4505
- const C = ge(e.corruptions, l, k, s, r, a, n);
4527
+ const C = ge(e.corruptions, l, k, s, r, o, n);
4506
4528
  if (C)
4507
4529
  if (_ === "text")
4508
- S = Kt(S, C.strategy), ye(n, l, k, _, C.strategy, !0);
4530
+ S = en(S, C.strategy), ye(n, l, k, _, C.strategy, !0);
4509
4531
  else {
4510
- const Z = Xt(S, C.strategy);
4532
+ const Z = tn(S, C.strategy);
4511
4533
  Z === null ? ye(n, l, k, _, C.strategy, !1, "incompatible-payload-type") : (S = Z, ye(n, l, k, _, C.strategy, !0));
4512
4534
  }
4513
- const N = ge(e.delays, l, k, s, r, a, n);
4535
+ const N = ge(e.delays, l, k, s, r, o, n);
4514
4536
  if (N) {
4515
- Jt(n, l, k, _, N.delayMs);
4537
+ nn(n, l, k, _, N.delayMs);
4516
4538
  const Z = {
4517
4539
  kind: "delay",
4518
4540
  handle: setTimeout(() => {
4519
- u(p, Z);
4520
- try {
4521
- y(S);
4522
- } catch {
4523
- }
4541
+ if (u(p, Z), !!i)
4542
+ try {
4543
+ y(S);
4544
+ } catch {
4545
+ }
4524
4546
  }, N.delayMs),
4525
4547
  url: l,
4526
4548
  direction: k,
@@ -4532,37 +4554,37 @@ function Br(t, e, n, s, r, a) {
4532
4554
  }, F = (p, l) => {
4533
4555
  p.addEventListener("message", (f) => {
4534
4556
  const y = f;
4535
- if (y[Ht] || !i) return;
4536
- const k = "inbound", _ = Yt(y.data);
4537
- if (ge(e.drops, l, k, s, r, a, n)) {
4538
- y.stopImmediatePropagation(), We(n, l, k, _);
4557
+ if (y[Jt] || !i) return;
4558
+ const k = "inbound", _ = Qt(y.data);
4559
+ if (ge(e.drops, l, k, s, r, o, n)) {
4560
+ y.stopImmediatePropagation(), Ve(n, l, k, _);
4539
4561
  return;
4540
4562
  }
4541
4563
  let S = y.data, C = !1;
4542
- const N = ge(e.corruptions, l, k, s, r, a, n);
4564
+ const N = ge(e.corruptions, l, k, s, r, o, n);
4543
4565
  if (N)
4544
4566
  if (_ === "text")
4545
- S = Kt(S, N.strategy), C = !0, ye(n, l, k, _, N.strategy, !0);
4567
+ S = en(S, N.strategy), C = !0, ye(n, l, k, _, N.strategy, !0);
4546
4568
  else {
4547
- const j = Xt(S, N.strategy);
4548
- j === null ? ye(n, l, k, _, N.strategy, !1, "incompatible-payload-type") : (S = j, C = !0, ye(n, l, k, _, N.strategy, !0));
4569
+ const P = tn(S, N.strategy);
4570
+ P === null ? ye(n, l, k, _, N.strategy, !1, "incompatible-payload-type") : (S = P, C = !0, ye(n, l, k, _, N.strategy, !0));
4549
4571
  }
4550
- const Z = ge(e.delays, l, k, s, r, a, n);
4572
+ const Z = ge(e.delays, l, k, s, r, o, n);
4551
4573
  if (Z) {
4552
- y.stopImmediatePropagation(), Jt(n, l, k, _, Z.delayMs);
4553
- const j = {
4574
+ y.stopImmediatePropagation(), nn(n, l, k, _, Z.delayMs);
4575
+ const P = {
4554
4576
  kind: "delay",
4555
4577
  handle: setTimeout(() => {
4556
- u(p, j), R(p, y, S);
4578
+ u(p, P), i && A(p, y, S);
4557
4579
  }, Z.delayMs),
4558
4580
  url: l,
4559
4581
  direction: k,
4560
4582
  payloadType: _
4561
4583
  };
4562
- c(p, j);
4584
+ c(p, P);
4563
4585
  return;
4564
4586
  }
4565
- C && (y.stopImmediatePropagation(), R(p, y, S));
4587
+ C && (y.stopImmediatePropagation(), A(p, y, S));
4566
4588
  });
4567
4589
  }, X = (p, l) => {
4568
4590
  if (e.closes)
@@ -4572,12 +4594,12 @@ function Br(t, e, n, s, r, a) {
4572
4594
  continue;
4573
4595
  }
4574
4596
  n.debug("rule-matched", { url: l }, f);
4575
- const y = ee(f, r);
4576
- if (!te(f, y)) {
4597
+ const y = te(f, r);
4598
+ if (!ne(f, y)) {
4577
4599
  n.debug("rule-skip-counting", { url: l }, f);
4578
4600
  continue;
4579
4601
  }
4580
- if (!V(f, a, n, { url: l })) continue;
4602
+ if (!V(f, o, n, { url: l })) continue;
4581
4603
  if (!U(f.probability, s)) {
4582
4604
  n.debug("rule-skip-probability", { url: l }, f);
4583
4605
  continue;
@@ -4585,7 +4607,7 @@ function Br(t, e, n, s, r, a) {
4585
4607
  n.debug("rule-applied", { url: l }, f);
4586
4608
  const k = f.code ?? 1e3, _ = f.reason ?? "Chaos Maker close", S = f.afterMs ?? 0, C = () => {
4587
4609
  if (i) {
4588
- v(p, "close-interrupt"), Fr(n, l, k, _);
4610
+ v(p, "close-interrupt"), Xr(n, l, k, _);
4589
4611
  try {
4590
4612
  p.close(k, _);
4591
4613
  } catch {
@@ -4628,45 +4650,45 @@ function Br(t, e, n, s, r, a) {
4628
4650
  Wrapped: q,
4629
4651
  uninstall() {
4630
4652
  i = !1;
4631
- for (const [, p] of o)
4653
+ for (const [, p] of a)
4632
4654
  for (const l of p)
4633
- clearTimeout(l.handle), l.kind === "delay" && We(n, l.url, l.direction, l.payloadType, "stop-during-delay");
4634
- o.clear();
4655
+ clearTimeout(l.handle), l.kind === "delay" && Ve(n, l.url, l.direction, l.payloadType, "stop-during-delay");
4656
+ a.clear();
4635
4657
  }
4636
4658
  };
4637
4659
  }
4638
- const Qt = /* @__PURE__ */ Symbol.for("chaos-maker.eventsource.intercepted");
4639
- function Hr(t, e) {
4660
+ const sn = /* @__PURE__ */ Symbol.for("chaos-maker.eventsource.intercepted");
4661
+ function Qr(t, e) {
4640
4662
  return t === void 0 || t === "*" ? !0 : t === e;
4641
4663
  }
4642
- function rt(t, e, n, s, r, a, o) {
4664
+ function lt(t, e, n, s, r, o, a) {
4643
4665
  if (!t) return null;
4644
4666
  for (const i of t) {
4645
- if (o == null || o.debug("rule-evaluating", { url: e, eventType: n }, i), !pe(e, i.urlPattern)) {
4646
- o == null || o.debug("rule-skip-match", { url: e, eventType: n }, i);
4667
+ if (a == null || a.debug("rule-evaluating", { url: e, eventType: n }, i), !pe(e, i.urlPattern)) {
4668
+ a == null || a.debug("rule-skip-match", { url: e, eventType: n }, i);
4647
4669
  continue;
4648
4670
  }
4649
- if (!Hr(i.eventType, n)) {
4650
- o == null || o.debug("rule-skip-match", { url: e, eventType: n }, i);
4671
+ if (!Qr(i.eventType, n)) {
4672
+ a == null || a.debug("rule-skip-match", { url: e, eventType: n }, i);
4651
4673
  continue;
4652
4674
  }
4653
- o == null || o.debug("rule-matched", { url: e, eventType: n }, i);
4654
- const c = ee(i, r);
4655
- if (!te(i, c)) {
4656
- o == null || o.debug("rule-skip-counting", { url: e, eventType: n }, i);
4675
+ a == null || a.debug("rule-matched", { url: e, eventType: n }, i);
4676
+ const c = te(i, r);
4677
+ if (!ne(i, c)) {
4678
+ a == null || a.debug("rule-skip-counting", { url: e, eventType: n }, i);
4657
4679
  continue;
4658
4680
  }
4659
- if (V(i, a, o, { url: e, eventType: n })) {
4681
+ if (V(i, o, a, { url: e, eventType: n })) {
4660
4682
  if (!U(i.probability, s)) {
4661
- o == null || o.debug("rule-skip-probability", { url: e, eventType: n }, i);
4683
+ a == null || a.debug("rule-skip-probability", { url: e, eventType: n }, i);
4662
4684
  continue;
4663
4685
  }
4664
- return o == null || o.debug("rule-applied", { url: e, eventType: n }, i), i;
4686
+ return a == null || a.debug("rule-applied", { url: e, eventType: n }, i), i;
4665
4687
  }
4666
4688
  }
4667
4689
  return null;
4668
4690
  }
4669
- function at(t, e, n, s) {
4691
+ function dt(t, e, n, s) {
4670
4692
  t.emit({
4671
4693
  type: "sse:drop",
4672
4694
  timestamp: Date.now(),
@@ -4674,7 +4696,7 @@ function at(t, e, n, s) {
4674
4696
  detail: { url: e, eventType: n, ...s ? { reason: s } : {} }
4675
4697
  });
4676
4698
  }
4677
- function Yr(t, e, n, s) {
4699
+ function eo(t, e, n, s) {
4678
4700
  t.emit({
4679
4701
  type: "sse:delay",
4680
4702
  timestamp: Date.now(),
@@ -4682,7 +4704,7 @@ function Yr(t, e, n, s) {
4682
4704
  detail: { url: e, eventType: n, delayMs: s }
4683
4705
  });
4684
4706
  }
4685
- function Kr(t, e, n, s) {
4707
+ function to(t, e, n, s) {
4686
4708
  t.emit({
4687
4709
  type: "sse:corrupt",
4688
4710
  timestamp: Date.now(),
@@ -4690,7 +4712,7 @@ function Kr(t, e, n, s) {
4690
4712
  detail: { url: e, eventType: n, strategy: s }
4691
4713
  });
4692
4714
  }
4693
- function Xr(t, e, n) {
4715
+ function no(t, e, n) {
4694
4716
  t.emit({
4695
4717
  type: "sse:close",
4696
4718
  timestamp: Date.now(),
@@ -4698,46 +4720,46 @@ function Xr(t, e, n) {
4698
4720
  detail: { url: e, reason: n }
4699
4721
  });
4700
4722
  }
4701
- function Jr(t, e, n, s, r, a) {
4702
- const o = /* @__PURE__ */ new Map();
4723
+ function so(t, e, n, s, r, o) {
4724
+ const a = /* @__PURE__ */ new Map();
4703
4725
  let i = !0;
4704
4726
  const c = (p, l) => {
4705
- let f = o.get(p);
4706
- f || (f = /* @__PURE__ */ new Set(), o.set(p, f)), f.add(l);
4727
+ let f = a.get(p);
4728
+ f || (f = /* @__PURE__ */ new Set(), a.set(p, f)), f.add(l);
4707
4729
  }, u = (p, l) => {
4708
4730
  var f;
4709
- (f = o.get(p)) == null || f.delete(l);
4731
+ (f = a.get(p)) == null || f.delete(l);
4710
4732
  }, v = (p, l) => {
4711
- const f = o.get(p);
4733
+ const f = a.get(p);
4712
4734
  if (f) {
4713
4735
  for (const y of f)
4714
- clearTimeout(y.handle), y.kind === "delay" && at(n, y.url, y.eventType, l);
4715
- o.delete(p);
4736
+ clearTimeout(y.handle), y.kind === "delay" && dt(n, y.url, y.eventType, l);
4737
+ a.delete(p);
4716
4738
  }
4717
- }, R = (p, l, f) => {
4739
+ }, A = (p, l, f) => {
4718
4740
  const y = new MessageEvent(l.type || "message", {
4719
4741
  data: f,
4720
4742
  origin: l.origin,
4721
4743
  lastEventId: l.lastEventId
4722
4744
  });
4723
- y[Qt] = !0, p.dispatchEvent(y);
4745
+ y[sn] = !0, p.dispatchEvent(y);
4724
4746
  }, $ = (p, l, f) => {
4725
- if (f[Qt] || !i) return;
4747
+ if (f[sn] || !i) return;
4726
4748
  const y = f.type || "message";
4727
- if (rt(e.drops, l, y, s, r, a, n)) {
4728
- f.stopImmediatePropagation(), at(n, l, y);
4749
+ if (lt(e.drops, l, y, s, r, o, n)) {
4750
+ f.stopImmediatePropagation(), dt(n, l, y);
4729
4751
  return;
4730
4752
  }
4731
4753
  let k = typeof f.data == "string" ? f.data : String(f.data), _ = !1;
4732
- const S = rt(e.corruptions, l, y, s, r, a, n);
4733
- S && (k = bt(k, S.strategy), _ = !0, Kr(n, l, y, S.strategy));
4734
- const C = rt(e.delays, l, y, s, r, a, n);
4754
+ const S = lt(e.corruptions, l, y, s, r, o, n);
4755
+ S && (k = St(k, S.strategy), _ = !0, to(n, l, y, S.strategy));
4756
+ const C = lt(e.delays, l, y, s, r, o, n);
4735
4757
  if (C) {
4736
- f.stopImmediatePropagation(), Yr(n, l, y, C.delayMs);
4758
+ f.stopImmediatePropagation(), eo(n, l, y, C.delayMs);
4737
4759
  const N = {
4738
4760
  kind: "delay",
4739
4761
  handle: setTimeout(() => {
4740
- u(p, N), i && p.readyState !== p.CLOSED && R(p, f, k);
4762
+ u(p, N), i && p.readyState !== p.CLOSED && A(p, f, k);
4741
4763
  }, C.delayMs),
4742
4764
  url: l,
4743
4765
  eventType: y
@@ -4745,7 +4767,7 @@ function Jr(t, e, n, s, r, a) {
4745
4767
  c(p, N);
4746
4768
  return;
4747
4769
  }
4748
- _ && (f.stopImmediatePropagation(), R(p, f, k));
4770
+ _ && (f.stopImmediatePropagation(), A(p, f, k));
4749
4771
  }, F = (p) => {
4750
4772
  if (!e.closes) return null;
4751
4773
  for (const l of e.closes) {
@@ -4754,12 +4776,12 @@ function Jr(t, e, n, s, r, a) {
4754
4776
  continue;
4755
4777
  }
4756
4778
  n.debug("rule-matched", { url: p }, l);
4757
- const f = ee(l, r);
4758
- if (!te(l, f)) {
4779
+ const f = te(l, r);
4780
+ if (!ne(l, f)) {
4759
4781
  n.debug("rule-skip-counting", { url: p }, l);
4760
4782
  continue;
4761
4783
  }
4762
- if (V(l, a, n, { url: p })) {
4784
+ if (V(l, o, n, { url: p })) {
4763
4785
  if (!U(l.probability, s)) {
4764
4786
  n.debug("rule-skip-probability", { url: p }, l);
4765
4787
  continue;
@@ -4773,7 +4795,7 @@ function Jr(t, e, n, s, r, a) {
4773
4795
  if (!f) return;
4774
4796
  const y = f.afterMs ?? 0, k = () => {
4775
4797
  if (i) {
4776
- v(p, "close-interrupt"), Xr(n, l, "chaos-maker-close");
4798
+ v(p, "close-interrupt"), no(n, l, "chaos-maker-close");
4777
4799
  try {
4778
4800
  p.close();
4779
4801
  } catch {
@@ -4793,20 +4815,20 @@ function Jr(t, e, n, s, r, a) {
4793
4815
  }
4794
4816
  };
4795
4817
  function q(p, l) {
4796
- const f = new t(p, l), y = typeof p == "string" ? p : p.toString(), k = (j) => {
4797
- $(f, y, j);
4798
- }, _ = /* @__PURE__ */ new Set(), S = f.addEventListener.bind(f), C = (j) => {
4799
- _.has(j) || (_.add(j), S(j, k, { capture: !0 }));
4818
+ const f = new t(p, l), y = typeof p == "string" ? p : p.toString(), k = (P) => {
4819
+ $(f, y, P);
4820
+ }, _ = /* @__PURE__ */ new Set(), S = f.addEventListener.bind(f), C = (P) => {
4821
+ _.has(P) || (_.add(P), S(P, k, { capture: !0 }));
4800
4822
  };
4801
4823
  C("message");
4802
- const N = (j) => {
4803
- if (j)
4804
- for (const d of j)
4824
+ const N = (P) => {
4825
+ if (P)
4826
+ for (const d of P)
4805
4827
  d.eventType && d.eventType !== "*" && d.eventType !== "message" && C(d.eventType);
4806
4828
  };
4807
4829
  N(e.drops), N(e.delays), N(e.corruptions);
4808
- const Z = (j, d, M) => {
4809
- j !== "open" && j !== "error" && C(j), S(j, d, M);
4830
+ const Z = (P, d, R) => {
4831
+ P !== "open" && P !== "error" && C(P), S(P, d, R);
4810
4832
  };
4811
4833
  return f.addEventListener = Z, X(f, y), f;
4812
4834
  }
@@ -4820,17 +4842,17 @@ function Jr(t, e, n, s, r, a) {
4820
4842
  Wrapped: q,
4821
4843
  uninstall() {
4822
4844
  i = !1;
4823
- for (const [, p] of o)
4845
+ for (const [, p] of a)
4824
4846
  for (const l of p)
4825
- clearTimeout(l.handle), l.kind === "delay" && at(n, l.url, l.eventType, "stop-during-delay");
4826
- o.clear();
4847
+ clearTimeout(l.handle), l.kind === "delay" && dt(n, l.url, l.eventType, "stop-during-delay");
4848
+ a.clear();
4827
4849
  }
4828
4850
  };
4829
4851
  }
4830
- function Qr(t) {
4852
+ function ro(t) {
4831
4853
  return t === void 0 ? { enabled: !1 } : typeof t == "boolean" ? { enabled: t } : { enabled: t.enabled };
4832
4854
  }
4833
- const ea = [
4855
+ const oo = [
4834
4856
  { pick: (t) => {
4835
4857
  var e;
4836
4858
  return (e = t.network) == null ? void 0 : e.failures;
@@ -4888,21 +4910,21 @@ const ea = [
4888
4910
  return (e = t.sse) == null ? void 0 : e.closes;
4889
4911
  }, ruleType: "sse-close" }
4890
4912
  ];
4891
- function ta(t) {
4913
+ function ao(t) {
4892
4914
  const e = /* @__PURE__ */ new WeakMap();
4893
- for (const { pick: n, ruleType: s } of ea) {
4915
+ for (const { pick: n, ruleType: s } of oo) {
4894
4916
  const r = n(t);
4895
- r && r.forEach((a, o) => {
4896
- e.set(a, { ruleType: s, ruleId: `${s}#${o}` });
4917
+ r && r.forEach((o, a) => {
4918
+ e.set(o, { ruleType: s, ruleId: `${s}#${a}` });
4897
4919
  });
4898
4920
  }
4899
4921
  return e;
4900
4922
  }
4901
- function na(t, e) {
4923
+ function io(t, e) {
4902
4924
  const n = [];
4903
4925
  return e.ruleId && n.push(`rule=${e.ruleId}`), e.phase && n.push(e.phase), e.method && n.push(e.method), e.url && n.push(e.url), e.statusCode !== void 0 && n.push(`-> ${e.statusCode}`), e.delayMs !== void 0 && n.push(`+${e.delayMs}ms`), e.direction && n.push(e.direction), e.eventType && n.push(`event=${e.eventType}`), e.selector && n.push(`selector=${e.selector}`), e.action && n.push(`action=${e.action}`), e.strategy && n.push(`strategy=${e.strategy}`), e.groupName && n.push(`group=${e.groupName}`), e.reason && n.push(`reason=${e.reason}`), n.length === 0 ? t : `${t}: ${n.join(" ")}`;
4904
4926
  }
4905
- class sa {
4927
+ class co {
4906
4928
  constructor(e, n = "page") {
4907
4929
  this.opts = e, this.target = n;
4908
4930
  }
@@ -4930,66 +4952,161 @@ class sa {
4930
4952
  detail: s
4931
4953
  };
4932
4954
  if (typeof console < "u" && typeof console.debug == "function") {
4933
- const a = this.target === "sw" ? "[Chaos SW]" : "[Chaos]";
4955
+ const o = this.target === "sw" ? "[Chaos SW]" : "[Chaos]";
4934
4956
  try {
4935
- console.debug(`${a} ${na(e, s)}`);
4957
+ console.debug(`${o} ${io(e, s)}`);
4936
4958
  } catch {
4937
4959
  }
4938
4960
  }
4939
4961
  return r;
4940
4962
  }
4941
4963
  }
4964
+ const Yn = /* @__PURE__ */ Symbol.for("chaos-maker.runtime.patch-kind"), Pe = /* @__PURE__ */ Symbol.for("chaos-maker.runtime.active-instance");
4965
+ function uo(t) {
4966
+ return typeof t == "object" && t !== null || typeof t == "function";
4967
+ }
4968
+ function Te(t, e) {
4969
+ try {
4970
+ Object.defineProperty(t, Yn, {
4971
+ value: e,
4972
+ configurable: !0
4973
+ });
4974
+ } catch {
4975
+ }
4976
+ return t;
4977
+ }
4978
+ function lo(t) {
4979
+ if (uo(t))
4980
+ return t[Yn];
4981
+ }
4982
+ function fo(t) {
4983
+ return t[Pe];
4984
+ }
4985
+ function ho(t, e) {
4986
+ try {
4987
+ Object.defineProperty(t, Pe, {
4988
+ value: e,
4989
+ configurable: !0
4990
+ });
4991
+ } catch {
4992
+ }
4993
+ }
4994
+ function po(t, e) {
4995
+ const n = t;
4996
+ if (n[Pe] === e)
4997
+ try {
4998
+ delete n[Pe];
4999
+ } catch {
5000
+ try {
5001
+ n[Pe] = void 0;
5002
+ } catch {
5003
+ }
5004
+ }
5005
+ }
4942
5006
  function me(t) {
4943
5007
  const e = t.trim();
4944
5008
  if (!e)
4945
5009
  throw new Error("[chaos-maker] Group name cannot be empty");
4946
5010
  return e;
4947
5011
  }
4948
- class en {
5012
+ function go(t, e) {
5013
+ if (!(typeof console > "u" || typeof console.warn != "function"))
5014
+ try {
5015
+ console.warn(`[chaos-maker] cleanup step failed: ${t}`, e);
5016
+ } catch {
5017
+ }
5018
+ }
5019
+ class rn {
4949
5020
  constructor(e, n = {}) {
4950
- A(this, "config");
4951
- A(this, "emitter");
4952
- A(this, "random");
4953
- A(this, "seed");
4954
- A(this, "running", !1);
4955
- A(this, "target");
4956
- A(this, "originalFetch");
4957
- A(this, "originalXhrSend");
4958
- A(this, "originalXhrOpen");
4959
- A(this, "domObserver");
4960
- A(this, "originalWebSocket");
4961
- A(this, "webSocketHandle");
4962
- A(this, "originalEventSource");
4963
- A(this, "eventSourceHandle");
5021
+ M(this, "config");
5022
+ M(this, "emitter");
5023
+ M(this, "random");
5024
+ M(this, "seed");
5025
+ M(this, "running", !1);
5026
+ M(this, "target");
5027
+ M(this, "originalFetch");
5028
+ M(this, "originalXhrSend");
5029
+ M(this, "originalXhrOpen");
5030
+ M(this, "domObserver");
5031
+ M(this, "originalWebSocket");
5032
+ M(this, "webSocketHandle");
5033
+ M(this, "originalEventSource");
5034
+ M(this, "eventSourceHandle");
4964
5035
  /** Shared counters keyed by config rule object reference. Shared across fetch + XHR + WS. */
4965
- A(this, "requestCounters", /* @__PURE__ */ new Map());
5036
+ M(this, "requestCounters", /* @__PURE__ */ new Map());
4966
5037
  /** Rule-group registry. Default-on; default group always exists. */
4967
- A(this, "groups");
5038
+ M(this, "groups");
4968
5039
  /** Positional rule-id map shared across interceptors via emitter.
4969
5040
  * Built lazily — only when debug mode is enabled — so disabled instances
4970
5041
  * pay zero allocation cost. The emitter handles `undefined` ruleIds
4971
5042
  * internally via `?.get(rule)`. */
4972
- A(this, "ruleIds");
5043
+ M(this, "ruleIds");
4973
5044
  /** Logger fed into the emitter; absent ⇒ debug fast-path no-op. */
4974
- A(this, "logger");
4975
- this.config = qn(e, n.validation), this.emitter = new Cr();
4976
- const s = Sr(this.config.seed);
4977
- this.random = s.random, this.seed = s.seed, this.target = n.target ?? globalThis, this.groups = new js();
4978
- for (const a of this.config.groups ?? [])
4979
- this.groups.ensure(a.name, { enabled: a.enabled ?? !0, explicit: !0 });
4980
- this.seedGroupsFromRules(), this.groups.ensure(He, { enabled: !0 });
4981
- const r = Qr(this.config.debug);
4982
- r.enabled && (this.ruleIds = ta(this.config), this.emitter.setRuleIds(this.ruleIds), this.logger = new sa(r, "page"), this.emitter.setLogger(this.logger)), console.log(`Chaos Maker initialized (seed: ${this.seed})`);
5045
+ M(this, "logger");
5046
+ this.config = Fn(e, n.validation), this.emitter = new Mr();
5047
+ const s = Or(this.config.seed);
5048
+ this.random = s.random, this.seed = s.seed, this.target = n.target ?? globalThis, this.groups = new Ds();
5049
+ for (const o of this.config.groups ?? [])
5050
+ this.groups.ensure(o.name, { enabled: o.enabled ?? !0, explicit: !0 });
5051
+ this.seedGroupsFromRules(), this.groups.ensure(Xe, { enabled: !0 });
5052
+ const r = ro(this.config.debug);
5053
+ r.enabled && (this.ruleIds = ao(this.config), this.emitter.setRuleIds(this.ruleIds), this.logger = new co(r, "page"), this.emitter.setLogger(this.logger)), console.log(`Chaos Maker initialized (seed: ${this.seed})`);
4983
5054
  }
4984
5055
  seedGroupsFromRules() {
4985
- Gt(this.config, (e) => {
5056
+ Vt(this.config, (e) => {
4986
5057
  e.group && this.groups.ensure(e.group);
4987
5058
  });
4988
5059
  }
5060
+ emitInvariant(e, n, s = {}) {
5061
+ this.emitter.debug("lifecycle", {
5062
+ phase: e,
5063
+ reason: n,
5064
+ ...s
5065
+ });
5066
+ }
5067
+ // Engine `start()` already checked `getActiveRuntimeInstance` and bailed —
5068
+ // by the time this runs the target is owned by this instance, so the
5069
+ // active-instance probe lives at the call site and not here.
5070
+ emitStartInvariantDiagnostics(e) {
5071
+ this.emitPatchDiagnostic(e.fetch, "fetch", "target-fetch-already-patched", "engine:start"), typeof e.XMLHttpRequest == "function" && (this.emitPatchDiagnostic(
5072
+ e.XMLHttpRequest.prototype.open,
5073
+ "xhr-open",
5074
+ "target-xhr-open-already-patched",
5075
+ "engine:start"
5076
+ ), this.emitPatchDiagnostic(
5077
+ e.XMLHttpRequest.prototype.send,
5078
+ "xhr-send",
5079
+ "target-xhr-send-already-patched",
5080
+ "engine:start"
5081
+ )), typeof e.WebSocket < "u" && this.emitPatchDiagnostic(e.WebSocket, "websocket", "target-websocket-already-patched", "engine:start"), typeof e.EventSource < "u" && this.emitPatchDiagnostic(e.EventSource, "eventsource", "target-eventsource-already-patched", "engine:start"), this.domObserver && this.emitInvariant("engine:start", "orphaned-dom-observer"), this.webSocketHandle && this.emitInvariant("engine:start", "stale-websocket-handle"), this.eventSourceHandle && this.emitInvariant("engine:start", "stale-eventsource-handle");
5082
+ }
5083
+ emitStopInvariantDiagnostics(e) {
5084
+ this.emitPatchDiagnostic(e.fetch, "fetch", "target-fetch-still-patched", "engine:stop"), typeof e.XMLHttpRequest == "function" && (this.emitPatchDiagnostic(
5085
+ e.XMLHttpRequest.prototype.open,
5086
+ "xhr-open",
5087
+ "target-xhr-open-still-patched",
5088
+ "engine:stop"
5089
+ ), this.emitPatchDiagnostic(
5090
+ e.XMLHttpRequest.prototype.send,
5091
+ "xhr-send",
5092
+ "target-xhr-send-still-patched",
5093
+ "engine:stop"
5094
+ )), typeof e.WebSocket < "u" && this.emitPatchDiagnostic(e.WebSocket, "websocket", "target-websocket-still-patched", "engine:stop"), typeof e.EventSource < "u" && this.emitPatchDiagnostic(e.EventSource, "eventsource", "target-eventsource-still-patched", "engine:stop");
5095
+ }
5096
+ emitPatchDiagnostic(e, n, s, r) {
5097
+ lo(e) === n && this.emitInvariant(r, s);
5098
+ }
5099
+ runCleanupStep(e, n) {
5100
+ try {
5101
+ n();
5102
+ } catch (s) {
5103
+ this.emitInvariant("engine:stop", `cleanup-step-failed:${e}`), go(e, s);
5104
+ }
5105
+ }
4989
5106
  /** Compute the set of group names currently referenced by any rule. Used by `removeGroup`. */
4990
5107
  collectReferencedGroups() {
4991
5108
  const e = /* @__PURE__ */ new Set();
4992
- return Gt(this.config, (n) => {
5109
+ return Vt(this.config, (n) => {
4993
5110
  n.group && e.add(n.group);
4994
5111
  }), e;
4995
5112
  }
@@ -5063,70 +5180,101 @@ class en {
5063
5180
  console.warn("Chaos Maker is already running. Call stop() first.");
5064
5181
  return;
5065
5182
  }
5066
- this.requestCounters.clear(), this.running = !0, console.log("🛠️ Chaos Maker ENGAGED 🛠️"), this.emitter.debug("lifecycle", { phase: "engine:start" });
5067
- const e = this.target;
5068
- this.config.network && (typeof e.fetch == "function" && (this.originalFetch = e.fetch, e.fetch = Ir(this.originalFetch.bind(e), this.config.network, this.random, this.emitter, this.requestCounters, this.groups)), typeof e.XMLHttpRequest == "function" && (this.originalXhrOpen = e.XMLHttpRequest.prototype.open, e.XMLHttpRequest.prototype.open = qr(this.originalXhrOpen), this.originalXhrSend = e.XMLHttpRequest.prototype.send, e.XMLHttpRequest.prototype.send = Wr(this.originalXhrSend, this.config.network, this.random, this.emitter, this.requestCounters, this.groups))), this.config.ui && (typeof document > "u" || typeof MutationObserver > "u" ? console.warn("Chaos Maker: UI config ignored — no DOM available in current context.") : (this.domObserver = Vr(this.config.ui, this.random, this.emitter, this.groups), this.domObserver.observe(document.body, {
5069
- childList: !0,
5070
- subtree: !0
5071
- }), console.log("UI Assailant is now observing the DOM."))), this.config.websocket && typeof e.WebSocket < "u" && (this.originalWebSocket = e.WebSocket, this.webSocketHandle = Br(
5072
- this.originalWebSocket,
5073
- this.config.websocket,
5074
- this.emitter,
5075
- this.random,
5076
- this.requestCounters,
5077
- this.groups
5078
- ), e.WebSocket = this.webSocketHandle.Wrapped), this.config.sse && typeof e.EventSource < "u" && (this.originalEventSource = e.EventSource, this.eventSourceHandle = Jr(
5079
- this.originalEventSource,
5080
- this.config.sse,
5081
- this.emitter,
5082
- this.random,
5083
- this.requestCounters,
5084
- this.groups
5085
- ), e.EventSource = this.eventSourceHandle.Wrapped);
5183
+ const e = this.target, n = fo(e);
5184
+ if (n && n !== this)
5185
+ throw this.emitInvariant("engine:start", "active-instance-conflict"), new Error("[chaos-maker] target already has an active runtime instance");
5186
+ this.emitStartInvariantDiagnostics(e), this.requestCounters.clear(), this.running = !0, console.log("🛠️ Chaos Maker ENGAGED 🛠️"), this.emitter.debug("lifecycle", { phase: "engine:start" });
5187
+ try {
5188
+ this.config.network && (typeof e.fetch == "function" && (this.originalFetch = e.fetch, e.fetch = Te(
5189
+ qr(this.originalFetch.bind(e), this.config.network, this.random, this.emitter, this.requestCounters, this.groups),
5190
+ "fetch"
5191
+ )), typeof e.XMLHttpRequest == "function" && (this.originalXhrOpen = e.XMLHttpRequest.prototype.open, e.XMLHttpRequest.prototype.open = Te(
5192
+ Br(this.originalXhrOpen),
5193
+ "xhr-open"
5194
+ ), this.originalXhrSend = e.XMLHttpRequest.prototype.send, e.XMLHttpRequest.prototype.send = Te(
5195
+ Fr(this.originalXhrSend, this.config.network, this.random, this.emitter, this.requestCounters, this.groups),
5196
+ "xhr-send"
5197
+ ))), this.config.ui && (typeof document > "u" || typeof MutationObserver > "u" ? console.warn("Chaos Maker: UI config ignored - no DOM available in current context.") : (this.domObserver = Kr(this.config.ui, this.random, this.emitter, this.groups), this.domObserver.observe(document.body, {
5198
+ childList: !0,
5199
+ subtree: !0
5200
+ }), console.log("UI Assailant is now observing the DOM."))), this.config.websocket && typeof e.WebSocket < "u" && (this.originalWebSocket = e.WebSocket, this.webSocketHandle = Jr(
5201
+ this.originalWebSocket,
5202
+ this.config.websocket,
5203
+ this.emitter,
5204
+ this.random,
5205
+ this.requestCounters,
5206
+ this.groups
5207
+ ), e.WebSocket = Te(this.webSocketHandle.Wrapped, "websocket")), this.config.sse && typeof e.EventSource < "u" && (this.originalEventSource = e.EventSource, this.eventSourceHandle = so(
5208
+ this.originalEventSource,
5209
+ this.config.sse,
5210
+ this.emitter,
5211
+ this.random,
5212
+ this.requestCounters,
5213
+ this.groups
5214
+ ), e.EventSource = Te(this.eventSourceHandle.Wrapped, "eventsource")), ho(e, this);
5215
+ } catch (s) {
5216
+ throw this.stop(), s;
5217
+ }
5086
5218
  }
5087
5219
  stop() {
5088
5220
  this.running = !1, console.log("🛑 Chaos Maker DISENGAGED 🛑"), this.emitter.debug("lifecycle", { phase: "engine:stop" });
5089
- const e = this.target;
5090
- this.originalFetch && (e.fetch = this.originalFetch), this.originalXhrSend && typeof e.XMLHttpRequest == "function" && (e.XMLHttpRequest.prototype.send = this.originalXhrSend), this.originalXhrOpen && typeof e.XMLHttpRequest == "function" && (e.XMLHttpRequest.prototype.open = this.originalXhrOpen), this.domObserver && (this.domObserver.disconnect(), console.log("UI Assailant has stopped observing.")), this.originalWebSocket && (e.WebSocket = this.originalWebSocket, this.originalWebSocket = void 0), this.webSocketHandle && (this.webSocketHandle.uninstall(), this.webSocketHandle = void 0), this.originalEventSource && (e.EventSource = this.originalEventSource, this.originalEventSource = void 0), this.eventSourceHandle && (this.eventSourceHandle.uninstall(), this.eventSourceHandle = void 0);
5091
- }
5092
- }
5093
- function tn(t) {
5094
- return $e(t);
5221
+ const e = this.target, n = this.originalFetch, s = this.originalXhrOpen, r = this.originalXhrSend, o = this.domObserver, a = this.originalWebSocket, i = this.webSocketHandle, c = this.originalEventSource, u = this.eventSourceHandle;
5222
+ this.originalFetch = void 0, this.originalXhrOpen = void 0, this.originalXhrSend = void 0, this.domObserver = void 0, this.originalWebSocket = void 0, this.webSocketHandle = void 0, this.originalEventSource = void 0, this.eventSourceHandle = void 0, n && this.runCleanupStep("restore-fetch", () => {
5223
+ e.fetch = n;
5224
+ }), r && typeof e.XMLHttpRequest == "function" && this.runCleanupStep("restore-xhr-send", () => {
5225
+ e.XMLHttpRequest.prototype.send = r;
5226
+ }), s && typeof e.XMLHttpRequest == "function" && this.runCleanupStep("restore-xhr-open", () => {
5227
+ e.XMLHttpRequest.prototype.open = s;
5228
+ }), o && this.runCleanupStep("disconnect-dom-observer", () => {
5229
+ o.disconnect(), console.log("UI Assailant has stopped observing.");
5230
+ }), i && this.runCleanupStep("uninstall-websocket", () => {
5231
+ i.uninstall();
5232
+ }), a && this.runCleanupStep("restore-websocket", () => {
5233
+ e.WebSocket = a;
5234
+ }), u && this.runCleanupStep("uninstall-eventsource", () => {
5235
+ u.uninstall();
5236
+ }), c && this.runCleanupStep("restore-eventsource", () => {
5237
+ e.EventSource = c;
5238
+ }), this.requestCounters.clear(), po(e, this), this.emitStopInvariantDiagnostics(e);
5239
+ }
5240
+ }
5241
+ function on(t) {
5242
+ return Ie(t);
5095
5243
  }
5096
- function nn(t) {
5244
+ function an(t) {
5097
5245
  const e = t.trim();
5098
5246
  if (!e)
5099
5247
  throw new Error("[chaos-maker] Group name cannot be empty");
5100
5248
  return e;
5101
5249
  }
5102
- function ra(t) {
5250
+ function yo(t) {
5103
5251
  const e = t.trim();
5104
5252
  if (!e)
5105
5253
  throw new Error("[chaos-maker] preset name cannot be empty");
5106
5254
  return e;
5107
5255
  }
5108
- class ca {
5256
+ class xo {
5109
5257
  constructor(e) {
5110
- A(this, "config");
5258
+ M(this, "config");
5111
5259
  /** Single-shot group name applied to the next rule pushed and then cleared.
5112
5260
  * Sticky semantics intentionally rejected — silent capture of stale groups
5113
5261
  * is harder to debug than the explicit re-chain. */
5114
- A(this, "pendingGroup");
5262
+ M(this, "pendingGroup");
5115
5263
  /** Queued preset names for `.usePreset(...)`. Silently deduped on
5116
5264
  * push. Flushed onto `out.presets` in `.build()` when non-empty. */
5117
- A(this, "pendingPresets", []);
5118
- this.config = e ? tn(e) : { network: {}, ui: {}, websocket: {}, sse: {} }, this.config.network || (this.config.network = {}), this.config.ui || (this.config.ui = {}), this.config.websocket || (this.config.websocket = {}), this.config.sse || (this.config.sse = {});
5265
+ M(this, "pendingPresets", []);
5266
+ this.config = e ? on(e) : { network: {}, ui: {}, websocket: {}, sse: {} }, this.config.network || (this.config.network = {}), this.config.ui || (this.config.ui = {}), this.config.websocket || (this.config.websocket = {}), this.config.sse || (this.config.sse = {});
5119
5267
  }
5120
5268
  /** Tag the next rule pushed with this group name.
5121
5269
  * Single-shot: cleared after the next builder method that pushes a rule. */
5122
5270
  inGroup(e) {
5123
- return this.pendingGroup = nn(e), this;
5271
+ return this.pendingGroup = an(e), this;
5124
5272
  }
5125
5273
  /** Pre-register a group on the config (typically used to ship one as
5126
5274
  * initially disabled). Equivalent to setting `ChaosConfig.groups` directly. */
5127
5275
  defineGroup(e, n) {
5128
5276
  this.config.groups || (this.config.groups = []);
5129
- const s = { name: nn(e) };
5277
+ const s = { name: an(e) };
5130
5278
  return (n == null ? void 0 : n.enabled) !== void 0 && (s.enabled = n.enabled), this.config.groups.push(s), this;
5131
5279
  }
5132
5280
  /** Apply `pendingGroup` (single-shot) to a rule literal before it is pushed.
@@ -5135,17 +5283,17 @@ class ca {
5135
5283
  const n = this.pendingGroup;
5136
5284
  return this.pendingGroup = void 0, n ? { ...e, group: n } : e;
5137
5285
  }
5138
- failRequests(e, n, s, r, a, o, i) {
5139
- return this.config.network.failures || (this.config.network.failures = []), this.config.network.failures.push(this.withGroup({ urlPattern: e, statusCode: n, probability: s, methods: r, body: a, headers: o, ...i })), this;
5286
+ failRequests(e, n, s, r, o, a, i) {
5287
+ return this.config.network.failures || (this.config.network.failures = []), this.config.network.failures.push(this.withGroup({ urlPattern: e, statusCode: n, probability: s, methods: r, body: o, headers: a, ...i })), this;
5140
5288
  }
5141
- addLatency(e, n, s, r, a) {
5142
- return this.config.network.latencies || (this.config.network.latencies = []), this.config.network.latencies.push(this.withGroup({ urlPattern: e, delayMs: n, probability: s, methods: r, ...a })), this;
5289
+ addLatency(e, n, s, r, o) {
5290
+ return this.config.network.latencies || (this.config.network.latencies = []), this.config.network.latencies.push(this.withGroup({ urlPattern: e, delayMs: n, probability: s, methods: r, ...o })), this;
5143
5291
  }
5144
- abortRequests(e, n, s, r, a) {
5145
- return this.config.network.aborts || (this.config.network.aborts = []), this.config.network.aborts.push(this.withGroup({ urlPattern: e, probability: n, timeout: s, methods: r, ...a })), this;
5292
+ abortRequests(e, n, s, r, o) {
5293
+ return this.config.network.aborts || (this.config.network.aborts = []), this.config.network.aborts.push(this.withGroup({ urlPattern: e, probability: n, timeout: s, methods: r, ...o })), this;
5146
5294
  }
5147
- corruptResponses(e, n, s, r, a) {
5148
- return this.config.network.corruptions || (this.config.network.corruptions = []), this.config.network.corruptions.push(this.withGroup({ urlPattern: e, strategy: n, probability: s, methods: r, ...a })), this;
5295
+ corruptResponses(e, n, s, r, o) {
5296
+ return this.config.network.corruptions || (this.config.network.corruptions = []), this.config.network.corruptions.push(this.withGroup({ urlPattern: e, strategy: n, probability: s, methods: r, ...o })), this;
5149
5297
  }
5150
5298
  simulateCors(e, n, s, r) {
5151
5299
  return this.config.network.cors || (this.config.network.cors = []), this.config.network.cors.push(this.withGroup({ urlPattern: e, probability: n, methods: s, ...r })), this;
@@ -5205,11 +5353,11 @@ class ca {
5205
5353
  dropMessages(e, n, s, r) {
5206
5354
  return this.config.websocket.drops || (this.config.websocket.drops = []), this.config.websocket.drops.push(this.withGroup({ urlPattern: e, direction: n, probability: s, ...r })), this;
5207
5355
  }
5208
- delayMessages(e, n, s, r, a) {
5209
- return this.config.websocket.delays || (this.config.websocket.delays = []), this.config.websocket.delays.push(this.withGroup({ urlPattern: e, direction: n, delayMs: s, probability: r, ...a })), this;
5356
+ delayMessages(e, n, s, r, o) {
5357
+ return this.config.websocket.delays || (this.config.websocket.delays = []), this.config.websocket.delays.push(this.withGroup({ urlPattern: e, direction: n, delayMs: s, probability: r, ...o })), this;
5210
5358
  }
5211
- corruptMessages(e, n, s, r, a) {
5212
- return this.config.websocket.corruptions || (this.config.websocket.corruptions = []), this.config.websocket.corruptions.push(this.withGroup({ urlPattern: e, direction: n, strategy: s, probability: r, ...a })), this;
5359
+ corruptMessages(e, n, s, r, o) {
5360
+ return this.config.websocket.corruptions || (this.config.websocket.corruptions = []), this.config.websocket.corruptions.push(this.withGroup({ urlPattern: e, direction: n, strategy: s, probability: r, ...o })), this;
5213
5361
  }
5214
5362
  closeConnection(e, n, s, r) {
5215
5363
  return this.config.websocket.closes || (this.config.websocket.closes = []), this.config.websocket.closes.push(this.withGroup({ urlPattern: e, probability: n, ...s, ...r })), this;
@@ -5236,11 +5384,11 @@ class ca {
5236
5384
  dropSSE(e, n, s, r) {
5237
5385
  return this.config.sse.drops || (this.config.sse.drops = []), this.config.sse.drops.push(this.withGroup({ urlPattern: e, probability: n, ...s ? { eventType: s } : {}, ...r })), this;
5238
5386
  }
5239
- delaySSE(e, n, s, r, a) {
5240
- return this.config.sse.delays || (this.config.sse.delays = []), this.config.sse.delays.push(this.withGroup({ urlPattern: e, delayMs: n, probability: s, ...r ? { eventType: r } : {}, ...a })), this;
5387
+ delaySSE(e, n, s, r, o) {
5388
+ return this.config.sse.delays || (this.config.sse.delays = []), this.config.sse.delays.push(this.withGroup({ urlPattern: e, delayMs: n, probability: s, ...r ? { eventType: r } : {}, ...o })), this;
5241
5389
  }
5242
- corruptSSE(e, n, s, r, a) {
5243
- return this.config.sse.corruptions || (this.config.sse.corruptions = []), this.config.sse.corruptions.push(this.withGroup({ urlPattern: e, strategy: n, probability: s, ...r ? { eventType: r } : {}, ...a })), this;
5390
+ corruptSSE(e, n, s, r, o) {
5391
+ return this.config.sse.corruptions || (this.config.sse.corruptions = []), this.config.sse.corruptions.push(this.withGroup({ urlPattern: e, strategy: n, probability: s, ...r ? { eventType: r } : {}, ...o })), this;
5244
5392
  }
5245
5393
  closeSSE(e, n, s, r) {
5246
5394
  return this.config.sse.closes || (this.config.sse.closes = []), this.config.sse.closes.push(this.withGroup({ urlPattern: e, probability: n, ...s, ...r })), this;
@@ -5257,43 +5405,43 @@ class ca {
5257
5405
  * Silently dedups within the builder, preserving insertion order. Empty
5258
5406
  * / whitespace-only names throw, matching the schema and registry rules. */
5259
5407
  usePreset(e) {
5260
- const n = ra(e);
5408
+ const n = yo(e);
5261
5409
  return this.pendingPresets.includes(n) || this.pendingPresets.push(n), this;
5262
5410
  }
5263
5411
  build() {
5264
- const e = tn(this.config), n = [], s = /* @__PURE__ */ new Set();
5412
+ const e = on(this.config), n = [], s = /* @__PURE__ */ new Set();
5265
5413
  for (const r of [...e.presets ?? [], ...this.pendingPresets])
5266
5414
  s.has(r) || (s.add(r), n.push(r));
5267
5415
  return n.length ? e.presets = n : delete e.presets, e;
5268
5416
  }
5269
5417
  }
5270
- const Qe = "__chaosMakerRegExp";
5271
- function aa(t) {
5418
+ const ot = "__chaosMakerRegExp";
5419
+ function mo(t) {
5272
5420
  if (t === null || typeof t != "object") return !1;
5273
5421
  const e = t, n = Object.keys(e);
5274
- if (n.length !== 1 || n[0] !== Qe) return !1;
5275
- const s = e[Qe];
5422
+ if (n.length !== 1 || n[0] !== ot) return !1;
5423
+ const s = e[ot];
5276
5424
  if (!s || typeof s != "object") return !1;
5277
5425
  const r = s;
5278
- for (const a of Object.keys(r))
5279
- if (a !== "source" && a !== "flags") return !1;
5426
+ for (const o of Object.keys(r))
5427
+ if (o !== "source" && o !== "flags") return !1;
5280
5428
  return typeof r.source == "string" && typeof r.flags == "string";
5281
5429
  }
5282
- function sn(t) {
5430
+ function cn(t) {
5283
5431
  if (t === null || typeof t != "object") return t;
5284
5432
  if (t instanceof RegExp)
5285
- return { [Qe]: { source: t.source, flags: t.flags } };
5433
+ return { [ot]: { source: t.source, flags: t.flags } };
5286
5434
  if (Array.isArray(t))
5287
- return t.map((n) => sn(n));
5435
+ return t.map((n) => cn(n));
5288
5436
  const e = {};
5289
5437
  for (const [n, s] of Object.entries(t))
5290
- e[n] = sn(s);
5438
+ e[n] = cn(s);
5291
5439
  return e;
5292
5440
  }
5293
- function yt(t) {
5441
+ function wt(t) {
5294
5442
  if (t === null || typeof t != "object" || t instanceof RegExp) return t;
5295
- if (aa(t)) {
5296
- const { source: n, flags: s } = t[Qe];
5443
+ if (mo(t)) {
5444
+ const { source: n, flags: s } = t[ot];
5297
5445
  try {
5298
5446
  return new RegExp(n, s);
5299
5447
  } catch (r) {
@@ -5301,13 +5449,55 @@ function yt(t) {
5301
5449
  }
5302
5450
  }
5303
5451
  if (Array.isArray(t))
5304
- return t.map((n) => yt(n));
5452
+ return t.map((n) => wt(n));
5305
5453
  const e = {};
5306
5454
  for (const [n, s] of Object.entries(t))
5307
- e[n] = yt(s);
5455
+ e[n] = wt(s);
5308
5456
  return e;
5309
5457
  }
5310
- const ua = (
5458
+ function So(t) {
5459
+ const e = `chaos:${t.type}`, n = t.detail ?? {}, s = [], r = n.url ?? n.selector;
5460
+ r && s.push(vo(r, 48));
5461
+ const o = bo(t);
5462
+ return o && s.push(`→ ${o}`), t.applied || s.push("(skipped)"), s.length > 0 ? `${e} ${s.join(" ")}` : e;
5463
+ }
5464
+ function bo(t) {
5465
+ const e = t.detail ?? {};
5466
+ switch (t.type) {
5467
+ case "network:failure":
5468
+ return e.statusCode != null ? String(e.statusCode) : null;
5469
+ case "network:latency":
5470
+ return e.delayMs != null ? `+${e.delayMs}ms` : null;
5471
+ case "network:abort":
5472
+ return "abort";
5473
+ case "network:corruption":
5474
+ return e.strategy ?? "corrupted";
5475
+ case "network:cors":
5476
+ return "cors-block";
5477
+ case "ui:assault":
5478
+ return e.action ?? null;
5479
+ case "websocket:drop":
5480
+ return e.direction ? `drop ${e.direction}` : "drop";
5481
+ case "websocket:delay":
5482
+ return e.delayMs != null ? `delay ${e.direction ?? ""} +${e.delayMs}ms` : "delay";
5483
+ case "websocket:corrupt":
5484
+ return e.strategy ?? "corrupt";
5485
+ case "websocket:close":
5486
+ return e.closeCode != null ? `close ${e.closeCode}` : "close";
5487
+ default:
5488
+ return null;
5489
+ }
5490
+ }
5491
+ function vo(t, e) {
5492
+ return t.length <= e ? t : `…${t.slice(-47)}`;
5493
+ }
5494
+ function Co(t, e) {
5495
+ return t.type === "debug" ? !1 : t.applied ? !0 : e;
5496
+ }
5497
+ function Eo(t) {
5498
+ return t === null ? "chaos seed: <not injected>" : `chaos seed: ${t}`;
5499
+ }
5500
+ const No = (
5311
5501
  /* js */
5312
5502
  `
5313
5503
  (function installChaosMakerSWBridge() {
@@ -5429,20 +5619,41 @@ const ua = (
5429
5619
  return (reply && Array.isArray(reply.log)) ? reply.log : [];
5430
5620
  });
5431
5621
  },
5622
+ clearRemoteLog: function (timeoutMs) {
5623
+ if (!('serviceWorker' in navigator) || !navigator.serviceWorker.controller) {
5624
+ return Promise.resolve();
5625
+ }
5626
+ return postViaPort(navigator.serviceWorker.controller, { __chaosMakerClearLog: true }, timeoutMs)
5627
+ .then(function () { return undefined; });
5628
+ },
5432
5629
  };
5433
5630
 
5434
5631
  addSwListeners();
5435
5632
  })();
5436
5633
  `
5437
- );
5634
+ ), ko = [
5635
+ /invalid session id/i,
5636
+ /no such window/i,
5637
+ /session closed/i,
5638
+ /session not created/i,
5639
+ /browser has disconnected/i,
5640
+ /browser is closed/i,
5641
+ /target closed/i,
5642
+ /connection closed/i,
5643
+ /browsing context has been discarded/i
5644
+ ];
5645
+ function To(t) {
5646
+ const e = t instanceof Error ? `${t.name} ${t.message}` : String(t);
5647
+ return ko.some((n) => n.test(e));
5648
+ }
5438
5649
  if (typeof window < "u") {
5439
- window.ChaosMaker = en;
5650
+ window.ChaosMaker = rn;
5440
5651
  const t = {
5441
5652
  instance: null,
5442
5653
  start: (e) => {
5443
5654
  t.instance && (t.instance.stop(), t.instance = null);
5444
5655
  try {
5445
- const n = yt(e), s = new en(n);
5656
+ const n = wt(e), s = new rn(n);
5446
5657
  return s.start(), t.instance = s, { success: !0, message: "Chaos started" };
5447
5658
  } catch (n) {
5448
5659
  return console.error("Chaos Utils Error:", n), { success: !1, message: n.message };
@@ -5483,7 +5694,7 @@ if (typeof window < "u") {
5483
5694
  return null;
5484
5695
  }
5485
5696
  },
5486
- validate: (e, n) => qn(e, n)
5697
+ validate: (e, n) => Fn(e, n)
5487
5698
  };
5488
5699
  if (window.chaosUtils = t, window.__CHAOS_CONFIG__)
5489
5700
  try {
@@ -5494,32 +5705,37 @@ if (typeof window < "u") {
5494
5705
  }
5495
5706
  }
5496
5707
  export {
5497
- $s as BUILT_IN_PRESETS,
5498
- ca as ChaosConfigBuilder,
5708
+ Zs as BUILT_IN_PRESETS,
5709
+ xo as ChaosConfigBuilder,
5499
5710
  ve as ChaosConfigError,
5500
- Cr as ChaosEventEmitter,
5501
- en as ChaosMaker,
5502
- He as DEFAULT_GROUP_NAME,
5503
- sa as Logger,
5504
- Ps as PresetRegistry,
5505
- js as RuleGroupRegistry,
5506
- ua as SW_BRIDGE_SOURCE,
5507
- Vt as VALIDATOR_BRAND_VERSION,
5508
- ta as buildRuleIdMap,
5509
- gr as chaosConfigSchemaPassthrough,
5510
- Gn as chaosConfigSchemaStrict,
5511
- Sr as createPrng,
5512
- yt as deserializeForTransport,
5513
- Ls as expandPresets,
5514
- zn as extractGraphQLOperation,
5515
- na as formatDebugMessage,
5516
- xr as generateSeed,
5517
- Qr as normalizeDebugOption,
5518
- Tr as operationNameMatches,
5519
- Un as parseOperationFromQueryString,
5520
- kr as prepareChaosConfig,
5521
- ia as presets,
5522
- sn as serializeForTransport,
5523
- qn as validateChaosConfig,
5524
- vr as validateConfig
5711
+ Mr as ChaosEventEmitter,
5712
+ rn as ChaosMaker,
5713
+ Xe as DEFAULT_GROUP_NAME,
5714
+ co as Logger,
5715
+ Gs as PresetRegistry,
5716
+ Ds as RuleGroupRegistry,
5717
+ ko as SESSION_TEARDOWN_PATTERNS,
5718
+ No as SW_BRIDGE_SOURCE,
5719
+ Ht as VALIDATOR_BRAND_VERSION,
5720
+ ao as buildRuleIdMap,
5721
+ kr as chaosConfigSchemaPassthrough,
5722
+ Vn as chaosConfigSchemaStrict,
5723
+ Or as createPrng,
5724
+ wt as deserializeForTransport,
5725
+ Ws as expandPresets,
5726
+ Kn as extractGraphQLOperation,
5727
+ io as formatDebugMessage,
5728
+ Eo as formatSeedReproduction,
5729
+ So as formatStepTitle,
5730
+ Tr as generateSeed,
5731
+ To as isSessionTeardownError,
5732
+ ro as normalizeDebugOption,
5733
+ Pr as operationNameMatches,
5734
+ Bn as parseOperationFromQueryString,
5735
+ Cr as prepareChaosConfig,
5736
+ wo as presets,
5737
+ cn as serializeForTransport,
5738
+ Co as shouldEmitStep,
5739
+ Fn as validateChaosConfig,
5740
+ Sr as validateConfig
5525
5741
  };