@kitman-sh/cli 0.14.8 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/{chunk-y0y2gg8d.js → chunk-0ws25xvg.js} +2 -2
  2. package/dist/{chunk-b009hdm0.js → chunk-39ykbhq8.js} +5 -5
  3. package/dist/{chunk-eytzmdna.js → chunk-3n99j4z0.js} +471 -234
  4. package/dist/{chunk-bbf0jzsc.js → chunk-3ns4sbfb.js} +1 -1
  5. package/dist/{chunk-q0x3c0dh.js → chunk-4x7a1qkj.js} +7 -7
  6. package/dist/{chunk-ya4z1n5p.js → chunk-4zc1g45m.js} +7 -7
  7. package/dist/{chunk-6dj39qtt.js → chunk-58hehm8d.js} +1133 -115
  8. package/dist/{chunk-9avbsbvk.js → chunk-5hkdgzh4.js} +1 -1
  9. package/dist/{chunk-xfs1nf75.js → chunk-8393zths.js} +1626 -388
  10. package/dist/{chunk-bpx2zjh7.js → chunk-8wpg3rph.js} +2 -2
  11. package/dist/{chunk-6x43ntsx.js → chunk-b16qxawc.js} +1 -1
  12. package/dist/chunk-cf1hxp43.js +3080 -0
  13. package/dist/chunk-csxxwscf.js +39 -0
  14. package/dist/{chunk-dq21ab8w.js → chunk-djp6t2g6.js} +21 -21
  15. package/dist/{chunk-zpp4jg4a.js → chunk-dx792s4w.js} +1455 -100
  16. package/dist/{chunk-5wrhj4cj.js → chunk-fv2zpgh0.js} +7 -7
  17. package/dist/{chunk-ctpgfdzf.js → chunk-fzaecdgv.js} +3 -3
  18. package/dist/{chunk-79g5zh2p.js → chunk-k2wd9r6t.js} +4 -4
  19. package/dist/chunk-mrkrt2hg.js +4345 -0
  20. package/dist/{chunk-721qyd1a.js → chunk-qkt77rtj.js} +6 -6
  21. package/dist/{chunk-drp4zdwq.js → chunk-rt0qfdtg.js} +15 -7
  22. package/dist/{chunk-cf723a2y.js → chunk-snwjv2sd.js} +678 -40
  23. package/dist/{chunk-bdd62njv.js → chunk-vg78dz3w.js} +259 -57
  24. package/dist/{chunk-wszvkzg8.js → chunk-vq7caqt2.js} +1828 -130
  25. package/dist/{chunk-63m3r0k4.js → chunk-wfz64h9p.js} +4 -4
  26. package/dist/{chunk-hz4t408c.js → chunk-xx711t5r.js} +4 -4
  27. package/dist/index.js +4 -4
  28. package/package.json +2 -1
  29. package/dist/chunk-1rwaetnm.js +0 -526
  30. package/dist/chunk-hrtr5wfq.js +0 -1166
@@ -1331,11 +1331,11 @@ var Prototype = (options) => makePrimitiveProto({
1331
1331
  });
1332
1332
 
1333
1333
  // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/Equivalence.js
1334
- var make13 = (isEquivalent) => (self, that) => self === that || isEquivalent(self, that);
1334
+ var make14 = (isEquivalent) => (self, that) => self === that || isEquivalent(self, that);
1335
1335
  var isStrictEquivalent = (x, y) => x === y;
1336
1336
  var strictEqual = () => isStrictEquivalent;
1337
1337
  function Tuple(elements) {
1338
- return make13((self, that) => {
1338
+ return make14((self, that) => {
1339
1339
  if (self.length !== that.length) {
1340
1340
  return false;
1341
1341
  }
@@ -1348,7 +1348,7 @@ function Tuple(elements) {
1348
1348
  });
1349
1349
  }
1350
1350
  function Array_(item) {
1351
- return make13((self, that) => {
1351
+ return make14((self, that) => {
1352
1352
  if (self.length !== that.length)
1353
1353
  return false;
1354
1354
  for (let i = 0;i < self.length; i++) {
@@ -1567,7 +1567,7 @@ var ServiceProto = {
1567
1567
  .../* @__PURE__ */ Prototype({
1568
1568
  label: "Service",
1569
1569
  evaluate(fiber) {
1570
- return exitSucceed(get3(fiber.context, this));
1570
+ return exitSucceed(get4(fiber.context, this));
1571
1571
  }
1572
1572
  }),
1573
1573
  toJSON() {
@@ -1580,13 +1580,13 @@ var ServiceProto = {
1580
1580
  return self;
1581
1581
  },
1582
1582
  context(self) {
1583
- return make14(this, self);
1583
+ return make15(this, self);
1584
1584
  },
1585
1585
  use(f) {
1586
- return withFiber((fiber) => f(get3(fiber.context, this)));
1586
+ return withFiber((fiber) => f(get4(fiber.context, this)));
1587
1587
  },
1588
1588
  useSync(f) {
1589
- return withFiber((fiber) => exitSucceed(f(get3(fiber.context, this))));
1589
+ return withFiber((fiber) => exitSucceed(f(get4(fiber.context, this))));
1590
1590
  }
1591
1591
  };
1592
1592
  var cacheKeys = /* @__PURE__ */ new Set;
@@ -1684,7 +1684,7 @@ var isContext = (u) => hasProperty(u, TypeId3);
1684
1684
  var isReference = (u) => !!u[ReferenceTypeId];
1685
1685
  var empty3 = () => emptyContext2;
1686
1686
  var emptyContext2 = /* @__PURE__ */ makeUnsafe4(/* @__PURE__ */ new Map);
1687
- var make14 = (key, service) => makeUnsafe4(new Map([[key.key, service]]));
1687
+ var make15 = (key, service) => makeUnsafe4(new Map([[key.key, service]]));
1688
1688
  var add = /* @__PURE__ */ dual(3, (self, key, service) => addUnsafe(self, key.key, service));
1689
1689
  var addUnsafe = (self, key, service) => {
1690
1690
  const impl = self;
@@ -1716,7 +1716,7 @@ var getUnsafe = /* @__PURE__ */ dual(2, (self, service) => {
1716
1716
  }
1717
1717
  return value;
1718
1718
  });
1719
- var get3 = getUnsafe;
1719
+ var get4 = getUnsafe;
1720
1720
  var defaultValueCacheKey = "~effect/Context/defaultValue";
1721
1721
  var getDefaultValue = (ref) => {
1722
1722
  if (defaultValueCacheKey in ref) {
@@ -2228,6 +2228,7 @@ var isArrayNonEmpty2 = (self) => self.length > 0;
2228
2228
 
2229
2229
  // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/internal/count.js
2230
2230
  var normalize = (n) => n > 0 ? Math.floor(n) : 0;
2231
+ var normalizeNonEmpty = (n) => Math.max(1, normalize(n));
2231
2232
 
2232
2233
  // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/Result.js
2233
2234
  var succeed = succeed7;
@@ -2289,6 +2290,7 @@ var all2 = (input) => {
2289
2290
  var Array2 = globalThis.Array;
2290
2291
  var allocate = (n) => new Array2(normalize(n));
2291
2292
  var fromIterable = (collection) => Array2.isArray(collection) ? collection : Array2.from(collection);
2293
+ var prepend = /* @__PURE__ */ dual(2, (self, head) => [head, ...self]);
2292
2294
  var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]);
2293
2295
  var isArray = Array2.isArray;
2294
2296
  var isArrayNonEmpty = isArrayNonEmpty2;
@@ -2307,11 +2309,39 @@ var getUnsafe2 = /* @__PURE__ */ dual(2, (self, index) => {
2307
2309
  }
2308
2310
  return self[i];
2309
2311
  });
2312
+ var headNonEmpty = /* @__PURE__ */ getUnsafe2(0);
2310
2313
  var sort = /* @__PURE__ */ dual(2, (self, O) => {
2311
2314
  const out = Array2.from(self);
2312
2315
  out.sort(O);
2313
2316
  return out;
2314
2317
  });
2318
+ var chop = /* @__PURE__ */ dual(2, (self, f) => {
2319
+ const input = fromIterable(self);
2320
+ if (isReadonlyArrayNonEmpty(input)) {
2321
+ const [b, rest] = f(input);
2322
+ const out = [b];
2323
+ let next = rest;
2324
+ while (isArrayNonEmpty2(next)) {
2325
+ const [b, rest] = f(next);
2326
+ out.push(b);
2327
+ next = rest;
2328
+ }
2329
+ return out;
2330
+ }
2331
+ return [];
2332
+ });
2333
+ var splitAtNonEmpty = /* @__PURE__ */ dual(2, (self, n) => {
2334
+ const _n = normalizeNonEmpty(n);
2335
+ return _n >= self.length ? [copy(self), []] : [prepend(self.slice(1, _n), headNonEmpty(self)), self.slice(_n)];
2336
+ });
2337
+ var copy = (self) => self.slice();
2338
+ var chunksOf = /* @__PURE__ */ dual(2, (self, n) => {
2339
+ const input = fromIterable(self);
2340
+ if (isReadonlyArrayNonEmpty(input)) {
2341
+ return chop(input, splitAtNonEmpty(n));
2342
+ }
2343
+ return [];
2344
+ });
2315
2345
  var hashBucketsAdd = (buckets, value) => {
2316
2346
  const hash2 = hash(value);
2317
2347
  const bucket = buckets.get(hash2);
@@ -2327,7 +2357,7 @@ var hashBucketsAdd = (buckets, value) => {
2327
2357
  bucket.push(value);
2328
2358
  return true;
2329
2359
  };
2330
- var empty = () => [];
2360
+ var empty4 = () => [];
2331
2361
  var of = (a) => [a];
2332
2362
  var map6 = /* @__PURE__ */ dual(2, (self, f) => self.map(f));
2333
2363
  var getSomes = (self) => {
@@ -3002,7 +3032,7 @@ class FiberImpl {
3002
3032
  return this._dispatcher ??= this.cache.scheduler.makeDispatcher();
3003
3033
  }
3004
3034
  getRef(ref) {
3005
- return get3(this.context, ref);
3035
+ return get4(this.context, ref);
3006
3036
  }
3007
3037
  addObserver(cb) {
3008
3038
  if (this._exit) {
@@ -3030,7 +3060,7 @@ class FiberImpl {
3030
3060
  }
3031
3061
  let cause = causeInterrupt(fiberId);
3032
3062
  if (this.cache.stackFrame) {
3033
- cause = causeAnnotate(cause, make14(StackTraceKey, this.cache.stackFrame));
3063
+ cause = causeAnnotate(cause, make15(StackTraceKey, this.cache.stackFrame));
3034
3064
  }
3035
3065
  if (annotations) {
3036
3066
  cause = causeAnnotate(cause, annotations);
@@ -3203,17 +3233,17 @@ class FiberImpl {
3203
3233
  var makeFiberContextCache = (context) => {
3204
3234
  const currentTracer = getOrUndefinedUnsafe(context, TracerKey);
3205
3235
  return {
3206
- scheduler: get3(context, Scheduler),
3236
+ scheduler: get4(context, Scheduler),
3207
3237
  tracer: currentTracer,
3208
3238
  tracerContext: currentTracer ? currentTracer["context"] : undefined,
3209
- tracerEnabled: get3(context, TracerEnabled),
3239
+ tracerEnabled: get4(context, TracerEnabled),
3210
3240
  span: getOrUndefinedUnsafe(context, ParentSpanKey),
3211
- logLevel: get3(context, CurrentLogLevel),
3212
- minimumLogLevel: get3(context, MinimumLogLevel),
3213
- stackFrame: get3(context, CurrentStackFrame),
3241
+ logLevel: get4(context, CurrentLogLevel),
3242
+ minimumLogLevel: get4(context, MinimumLogLevel),
3243
+ stackFrame: get4(context, CurrentStackFrame),
3214
3244
  runtimeMetrics: getOrUndefinedUnsafe(context, FiberRuntimeMetricsKey),
3215
- maxOpsBeforeYield: get3(context, MaxOpsBeforeYield),
3216
- preventYield: get3(context, PreventSchedulerYield)
3245
+ maxOpsBeforeYield: get4(context, MaxOpsBeforeYield),
3246
+ preventYield: get4(context, PreventSchedulerYield)
3217
3247
  };
3218
3248
  };
3219
3249
  var deferredInterruptCont = {
@@ -3293,7 +3323,7 @@ var fiberInterruptAs = /* @__PURE__ */ dual((args) => hasProperty(args[0], Fiber
3293
3323
  }));
3294
3324
  var fiberInterruptAll = (fibers) => withFiber((parent) => {
3295
3325
  const annotations = fiberStackAnnotations(parent);
3296
- let fiberArr = empty();
3326
+ let fiberArr = empty4();
3297
3327
  for (const fiber of fibers) {
3298
3328
  fiber.interruptUnsafe(parent.id, annotations);
3299
3329
  fiberArr.push(fiber);
@@ -3639,6 +3669,7 @@ var asSome = (self) => map7(self, some);
3639
3669
  var andThen = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, isEffect2(f) ? returnPayload : andThenCont, f));
3640
3670
  var tap = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, isEffect2(f) ? tapEffectCont : tapCont, f));
3641
3671
  var asVoid2 = (self) => new ContImpl(self, returnPayload, exitVoid);
3672
+ var sandbox2 = (self) => catchCause(self, fail2);
3642
3673
  var raceAllFirst2 = (all, options) => withFiber((parent) => {
3643
3674
  const fibers = new Set;
3644
3675
  onExitUnsafe(parent, () => fibers.size === 0 ? undefined : fiberInterruptAll(fibers));
@@ -4710,10 +4741,10 @@ var noopSpan = (options) => Object.assign(Object.create(NoopSpanProto), options)
4710
4741
  var filterDisablePropagation = (span) => {
4711
4742
  if (!span)
4712
4743
  return none();
4713
- return get3(span.annotations, DisablePropagation) ? span._tag === "Span" ? filterDisablePropagation(getOrUndefined(span.parent)) : none() : some(span);
4744
+ return get4(span.annotations, DisablePropagation) ? span._tag === "Span" ? filterDisablePropagation(getOrUndefined(span.parent)) : none() : some(span);
4714
4745
  };
4715
4746
  var makeSpanUnsafe = (fiber, name, options) => {
4716
- const disablePropagation = !fiber.cache.tracerEnabled || options?.annotations && get3(options.annotations, DisablePropagation);
4747
+ const disablePropagation = !fiber.cache.tracerEnabled || options?.annotations && get4(options.annotations, DisablePropagation);
4717
4748
  const parent = options?.parent !== undefined ? some(options.parent) : options?.root ? none() : filterDisablePropagation(fiber.cache.span);
4718
4749
  let span;
4719
4750
  if (disablePropagation) {
@@ -5108,6 +5139,7 @@ var void_2 = exitVoid;
5108
5139
  var isSuccess2 = exitIsSuccess;
5109
5140
  var isFailure2 = exitIsFailure;
5110
5141
  var hasInterrupts = exitHasInterrupts;
5142
+ var map8 = exitMap;
5111
5143
  var asVoidAll = exitAsVoidAll;
5112
5144
 
5113
5145
  // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/Deferred.js
@@ -5127,7 +5159,7 @@ var DeferredImpl = function() {
5127
5159
  };
5128
5160
  DeferredImpl.prototype = DeferredProto;
5129
5161
  var makeUnsafe5 = () => new DeferredImpl;
5130
- var make15 = () => sync(() => makeUnsafe5());
5162
+ var make16 = () => sync(() => makeUnsafe5());
5131
5163
  var _await = (self) => callback2((resume) => {
5132
5164
  if (self.effect)
5133
5165
  return resume(self.effect);
@@ -5275,9 +5307,9 @@ var build = (self) => withFiber((fiber) => buildWithMemoMap(self, CurrentMemoMap
5275
5307
  var buildWithScope = /* @__PURE__ */ dual(2, (self, scope) => withFiber((fiber) => buildWithMemoMap(self, CurrentMemoMap.forkOrCreate(fiber.context), scope)));
5276
5308
  var succeed5 = function() {
5277
5309
  if (arguments.length === 1) {
5278
- return (resource) => succeedContext(make14(arguments[0], resource));
5310
+ return (resource) => succeedContext(make15(arguments[0], resource));
5279
5311
  }
5280
- return succeedContext(make14(arguments[0], arguments[1]));
5312
+ return succeedContext(make15(arguments[0], arguments[1]));
5281
5313
  };
5282
5314
  var succeedContext = (context) => fromBuildUnsafe(constant(succeed2(context)));
5283
5315
  var effect = function() {
@@ -5286,7 +5318,7 @@ var effect = function() {
5286
5318
  }
5287
5319
  return effectImpl(arguments[0], arguments[1]);
5288
5320
  };
5289
- var effectImpl = (service, effect) => effectContext(map7(effect, (value) => make14(service, value)));
5321
+ var effectImpl = (service, effect) => effectContext(map7(effect, (value) => make15(service, value)));
5290
5322
  var effectContext = (effect) => fromBuildMemo((_, scope) => provide(effect, scope));
5291
5323
  var effectDiscard = (effect) => effectContext(as2(effect, empty3()));
5292
5324
  var mergeAllEffect = (layers, memoMap, scope) => {
@@ -5313,6 +5345,7 @@ var makeDieReason = (defect) => new Die(defect);
5313
5345
  var makeInterruptReason2 = makeInterruptReason;
5314
5346
  var hasInterruptsOnly = hasInterruptsOnly2;
5315
5347
  var map = causeMap;
5348
+ var combine2 = causeCombine;
5316
5349
  var squash = causeSquash;
5317
5350
  var findError = findError2;
5318
5351
  var findErrorOption = findErrorOption2;
@@ -5531,6 +5564,7 @@ var while_ = /* @__PURE__ */ dual(2, (self, predicate) => fromStep(map7(toStep(s
5531
5564
  });
5532
5565
  })));
5533
5566
  var forever3 = /* @__PURE__ */ spaced(zero);
5567
+ var setInputType = () => (self) => self;
5534
5568
 
5535
5569
  // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/internal/layer.js
5536
5570
  var provideLayer = (self, layer, options) => scopedWith2((scope) => flatMap2(options?.local ? buildWithMemoMap(layer, makeMemoMapUnsafe(), scope) : buildWithScope(layer, scope), (context) => provideContext(self, context)));
@@ -5629,7 +5663,7 @@ var tap2 = tap;
5629
5663
  var result = result2;
5630
5664
  var option2 = option;
5631
5665
  var exit = exit2;
5632
- var map8 = map7;
5666
+ var map9 = map7;
5633
5667
  var as = as2;
5634
5668
  var asSome2 = asSome;
5635
5669
  var asVoid = asVoid2;
@@ -5648,6 +5682,7 @@ var tapError2 = tapError;
5648
5682
  var tapCause = tapCause2;
5649
5683
  var retry = retry2;
5650
5684
  var retryOrElse = retryOrElse2;
5685
+ var sandbox = sandbox2;
5651
5686
  var ignore = ignore2;
5652
5687
  var ignoreCause = ignoreCause2;
5653
5688
  var orElseSucceed = orElseSucceed2;
@@ -5866,19 +5901,79 @@ var getCode = (charCode) => {
5866
5901
  return codes[charCode];
5867
5902
  };
5868
5903
 
5904
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/encoding/Base64Url.js
5905
+ var encode3 = (input) => encode2(input).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
5906
+ var encodePadded = (input) => encode2(input).replace(/\+/g, "-").replace(/\//g, "_");
5907
+ var decode2 = (str) => {
5908
+ const stripped = str.replace(/[\n\r]/g, "");
5909
+ const length = stripped.length;
5910
+ const padded = stripped.endsWith("=");
5911
+ if (padded ? length % 4 !== 0 : length % 4 === 1) {
5912
+ return fail3(new EncodingError({
5913
+ module: "Base64Url",
5914
+ kind: "Decode",
5915
+ input: stripped,
5916
+ message: padded ? `Padded length should be a multiple of 4, but is ${length}` : `Unpadded length should not be 1 more than a multiple of 4, but is ${length}`
5917
+ }));
5918
+ }
5919
+ if (!/^[-_A-Z0-9]*?={0,2}$/i.test(stripped)) {
5920
+ return fail3(new EncodingError({
5921
+ module: "Base64Url",
5922
+ kind: "Decode",
5923
+ input: stripped,
5924
+ message: "Invalid input"
5925
+ }));
5926
+ }
5927
+ const end = !padded ? length : stripped.charCodeAt(length - 2) === 61 ? length - 2 : length - 1;
5928
+ const fullEnd = end & ~3;
5929
+ const result = new Uint8Array(Math.floor(end * 3 / 4));
5930
+ let j = 0;
5931
+ for (let i = 0;i < fullEnd; i += 4) {
5932
+ const a = codes2[stripped.charCodeAt(i)];
5933
+ const b = codes2[stripped.charCodeAt(i + 1)];
5934
+ const c = codes2[stripped.charCodeAt(i + 2)];
5935
+ const d = codes2[stripped.charCodeAt(i + 3)];
5936
+ result[j++] = a << 2 | b >> 4;
5937
+ result[j++] = b << 4 | c >> 2;
5938
+ result[j++] = c << 6 | d;
5939
+ }
5940
+ if (end > fullEnd) {
5941
+ const a = codes2[stripped.charCodeAt(fullEnd)];
5942
+ const b = codes2[stripped.charCodeAt(fullEnd + 1)];
5943
+ result[j++] = a << 2 | b >> 4;
5944
+ if (end - fullEnd === 3)
5945
+ result[j] = b << 4 | codes2[stripped.charCodeAt(fullEnd + 2)] >> 2;
5946
+ }
5947
+ return succeed(result);
5948
+ };
5949
+ var alphabet2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
5950
+ var codes2 = /* @__PURE__ */ new Uint8Array(128);
5951
+ for (let i = 0;i < alphabet2.length; i++)
5952
+ codes2[/* @__PURE__ */ alphabet2.charCodeAt(i)] = i;
5953
+ var decodeString = (str) => map5(decode2(str), (_) => decoder2.decode(_));
5954
+ var decoder2 = /* @__PURE__ */ new TextDecoder;
5955
+
5869
5956
  // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/internal/schema/annotations.js
5870
5957
  function resolve(ast) {
5871
5958
  return ast.checks ? ast.checks[ast.checks.length - 1].annotations : ast.annotations;
5872
5959
  }
5960
+ function resolveAt(key) {
5961
+ return (ast) => resolve(ast)?.[key];
5962
+ }
5873
5963
  var STRUCTURAL_ANNOTATION_KEY = "~structural";
5964
+ var IDENTIFIER_FALLBACK_KEY = "~identifier";
5874
5965
  var SENTINELS_ANNOTATION_KEY = "~sentinels";
5875
5966
  var CONSTRUCTOR_ANNOTATION_KEY = "~constructor";
5967
+ var jsonSchemaAnnotationKeys = ["title", "description", "default", "examples", "readOnly", "writeOnly", "format", "contentEncoding", "contentMediaType", "contentSchema"];
5968
+ var resolveIdentifier = /* @__PURE__ */ resolveAt("identifier");
5969
+ var resolveIdentifierFallback = /* @__PURE__ */ resolveAt(IDENTIFIER_FALLBACK_KEY);
5876
5970
  var getExpected = /* @__PURE__ */ memoize((ast) => {
5877
5971
  const identifier = resolve(ast)?.identifier;
5878
5972
  if (typeof identifier === "string")
5879
5973
  return identifier;
5880
5974
  return ast.getExpected(getExpected);
5881
5975
  });
5976
+ var annotationExcludedKeys = /* @__PURE__ */ new Set([SENTINELS_ANNOTATION_KEY, STRUCTURAL_ANNOTATION_KEY, "representation", "arbitraryConstraint", "toJsonSchema", "toCode", "toEquivalence", "toFormatter", "toCodec", "toCodecJson", "toCodecStringTree", "toCodecIso", "toCodecArbitrary"]);
5882
5977
 
5883
5978
  // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/internal/schema/parser.js
5884
5979
  var missing = /* @__PURE__ */ Symbol();
@@ -6189,7 +6284,7 @@ var passthrough_ = /* @__PURE__ */ makeGetter({
6189
6284
  function passthrough() {
6190
6285
  return passthrough_;
6191
6286
  }
6192
- function transform2(f) {
6287
+ function transform(f) {
6193
6288
  return makeGetter({
6194
6289
  _tag: "Transform",
6195
6290
  transform: f
@@ -6223,13 +6318,13 @@ function withDefault(defaultValue) {
6223
6318
  });
6224
6319
  }
6225
6320
  function String2() {
6226
- return transform2(globalThis.String);
6321
+ return transform(globalThis.String);
6227
6322
  }
6228
6323
  function Number3() {
6229
- return transform2(globalThis.Number);
6324
+ return transform(globalThis.Number);
6230
6325
  }
6231
6326
  function Date3() {
6232
- return transform2((u) => new globalThis.Date(u));
6327
+ return transform((u) => new globalThis.Date(u));
6233
6328
  }
6234
6329
  function parseJson(options) {
6235
6330
  return transformEffect((input, parseOptions) => try_2({
@@ -6254,13 +6349,24 @@ function stringifyJson(options) {
6254
6349
  }));
6255
6350
  }
6256
6351
  function encodeBase64() {
6257
- return transform2(encode2);
6352
+ return transform(encode2);
6353
+ }
6354
+ function encodeBase64Url(options) {
6355
+ return transform(options?.padding ? encodePadded : encode3);
6258
6356
  }
6259
6357
  function decodeBase64() {
6260
6358
  return transformEffect((input, options) => mapErrorEager2(fromResult(decode(input)), () => new InvalidValue({
6261
6359
  expected: "a valid Base64 string"
6262
6360
  }, input, options)));
6263
6361
  }
6362
+ function decodeBase64UrlString() {
6363
+ return transformEffect((input, options) => match3(decodeString(input), {
6364
+ onFailure: () => fail7(new InvalidValue({
6365
+ expected: "a valid Base64Url string"
6366
+ }, input, options)),
6367
+ onSuccess: succeed6
6368
+ }));
6369
+ }
6264
6370
 
6265
6371
  // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/internal/schema/content.js
6266
6372
  var ContentTypeId = /* @__PURE__ */ Symbol.for("~effect/Schema/content");
@@ -6270,6 +6376,9 @@ function setContent(operation, content) {
6270
6376
  });
6271
6377
  return operation;
6272
6378
  }
6379
+ function getContent(operation) {
6380
+ return operation[ContentTypeId];
6381
+ }
6273
6382
 
6274
6383
  // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/SchemaTransformation.js
6275
6384
  var TypeId9 = "~effect/SchemaTransformation/Transformation";
@@ -6299,15 +6408,15 @@ var makeTransformation = (options) => {
6299
6408
  function transformEffect2(options) {
6300
6409
  return new Transformation(transformEffect(options.decode), transformEffect(options.encode));
6301
6410
  }
6302
- function transform(options) {
6303
- return new Transformation(transform2(options.decode), transform2(options.encode));
6411
+ function transform2(options) {
6412
+ return new Transformation(transform(options.decode), transform(options.encode));
6304
6413
  }
6305
6414
  var passthrough_2 = /* @__PURE__ */ new Transformation(/* @__PURE__ */ passthrough(), /* @__PURE__ */ passthrough());
6306
6415
  function passthrough3() {
6307
6416
  return passthrough_2;
6308
6417
  }
6309
6418
  var numberFromString = /* @__PURE__ */ new Transformation(/* @__PURE__ */ Number3(), /* @__PURE__ */ String2());
6310
- var dateFromString = /* @__PURE__ */ new Transformation(/* @__PURE__ */ Date3(), /* @__PURE__ */ transform2(formatDate));
6419
+ var dateFromString = /* @__PURE__ */ new Transformation(/* @__PURE__ */ Date3(), /* @__PURE__ */ transform(formatDate));
6311
6420
  var isJsonError = (input) => isObject(input) && typeof input["message"] === "string";
6312
6421
  var decodeJsonError = (input) => {
6313
6422
  const hasCause = Object.hasOwn(input, "cause");
@@ -6358,7 +6467,7 @@ var makeEncodeDefect = (options) => {
6358
6467
  return encode;
6359
6468
  };
6360
6469
  var decodeDefect = (input) => isJsonError(input) ? decodeJsonError(input) : input;
6361
- var defectFromJson = (options) => transform({
6470
+ var defectFromJson = (options) => transform2({
6362
6471
  decode: decodeDefect,
6363
6472
  encode: makeEncodeDefect(options)
6364
6473
  });
@@ -6491,9 +6600,9 @@ var Undefined = class extends ASTNodeImpl {
6491
6600
  return "undefined";
6492
6601
  }
6493
6602
  };
6494
- var undefinedToNull = /* @__PURE__ */ new Link(null_, /* @__PURE__ */ new Transformation(/* @__PURE__ */ transform2(() => {
6603
+ var undefinedToNull = /* @__PURE__ */ new Link(null_, /* @__PURE__ */ new Transformation(/* @__PURE__ */ transform(() => {
6495
6604
  return;
6496
- }), /* @__PURE__ */ transform2(() => null)));
6605
+ }), /* @__PURE__ */ transform(() => null)));
6497
6606
  var undefined_3 = /* @__PURE__ */ new Undefined;
6498
6607
  var Void2 = class extends ASTNodeImpl {
6499
6608
  _tag = "Void";
@@ -6557,7 +6666,7 @@ var Literal2 = class extends ASTNodeImpl {
6557
6666
  };
6558
6667
  function literalToString(ast) {
6559
6668
  const literalAsString = globalThis.String(ast.literal);
6560
- return replaceEncoding(ast, [new Link(new Literal2(literalAsString), new Transformation(transform2(() => ast.literal), transform2(() => literalAsString)))]);
6669
+ return replaceEncoding(ast, [new Link(new Literal2(literalAsString), new Transformation(transform(() => ast.literal), transform(() => literalAsString)))]);
6561
6670
  }
6562
6671
  var String5 = class extends ASTNodeImpl {
6563
6672
  _tag = "String";
@@ -7023,7 +7132,7 @@ var Objects = class extends ASTNodeImpl {
7023
7132
  }
7024
7133
  }
7025
7134
  } else if (parseIndexes) {
7026
- const keyPairs = empty();
7135
+ const keyPairs = empty4();
7027
7136
  for (let i = 0;i < indexCount; i++) {
7028
7137
  const index = indexes[i];
7029
7138
  const keys = indexKeys?.[i] ?? (index.is.parameter === string2 ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options));
@@ -7184,6 +7293,9 @@ function struct(fields, checks, annotations) {
7184
7293
  function getAST(self) {
7185
7294
  return self.ast;
7186
7295
  }
7296
+ function tuple(elements, checks = undefined) {
7297
+ return new Arrays(false, elements.map((e) => e.ast), [], undefined, checks);
7298
+ }
7187
7299
  function union(members, options, checks) {
7188
7300
  return new Union2(members.map(getAST), options, undefined, checks);
7189
7301
  }
@@ -7698,7 +7810,7 @@ function isFinite2(annotations) {
7698
7810
  });
7699
7811
  }
7700
7812
  var finite = /* @__PURE__ */ appendChecks(number2, [/* @__PURE__ */ isFinite2()]);
7701
- var numberToJson = /* @__PURE__ */ new Link(/* @__PURE__ */ new Union2([finite, nonFiniteLiterals]), /* @__PURE__ */ new Transformation(/* @__PURE__ */ Number3(), /* @__PURE__ */ transform2((n) => globalThis.Number.isFinite(n) ? n : globalThis.String(n))));
7813
+ var numberToJson = /* @__PURE__ */ new Link(/* @__PURE__ */ new Union2([finite, nonFiniteLiterals]), /* @__PURE__ */ new Transformation(/* @__PURE__ */ Number3(), /* @__PURE__ */ transform((n) => globalThis.Number.isFinite(n) ? n : globalThis.String(n))));
7702
7814
  function isPattern2(regExp, annotations) {
7703
7815
  const copy = new globalThis.RegExp(regExp);
7704
7816
  const payload = {
@@ -7722,7 +7834,7 @@ function isPattern2(regExp, annotations) {
7722
7834
  });
7723
7835
  }
7724
7836
  var bodyOwners = /* @__PURE__ */ new WeakMap;
7725
- function copy(ast, changes) {
7837
+ function copy2(ast, changes) {
7726
7838
  const out = Object.assign(Object.create(Object.getPrototypeOf(ast)), ast, changes);
7727
7839
  if (Reflect.ownKeys(changes).every((key) => key === "context" || key === "encoding")) {
7728
7840
  bodyOwners.set(out, getContextOwner(ast));
@@ -7742,7 +7854,7 @@ function getContextOwner(ast) {
7742
7854
  return owner;
7743
7855
  }
7744
7856
  function replaceEncoding(ast, encoding) {
7745
- return ast.encoding === encoding ? ast : copy(ast, {
7857
+ return ast.encoding === encoding ? ast : copy2(ast, {
7746
7858
  encoding
7747
7859
  });
7748
7860
  }
@@ -7754,7 +7866,7 @@ function replaceContext(ast, context) {
7754
7866
  if (owner.context === context && owner.encoding === ast.encoding) {
7755
7867
  return owner;
7756
7868
  }
7757
- return copy(ast, {
7869
+ return copy2(ast, {
7758
7870
  context
7759
7871
  });
7760
7872
  }
@@ -7766,7 +7878,7 @@ function annotate(ast, annotations) {
7766
7878
  const last = ast.checks[ast.checks.length - 1];
7767
7879
  return replaceChecks(ast, append(ast.checks.slice(0, -1), last.annotate(annotations)));
7768
7880
  }
7769
- return copy(ast, {
7881
+ return copy2(ast, {
7770
7882
  annotations: {
7771
7883
  ...ast.annotations,
7772
7884
  ...annotations
@@ -7780,7 +7892,7 @@ function replaceChecks(ast, checks) {
7780
7892
  if (ast.checks === checks) {
7781
7893
  return ast;
7782
7894
  }
7783
- return copy(ast, {
7895
+ return copy2(ast, {
7784
7896
  checks
7785
7897
  });
7786
7898
  }
@@ -7910,6 +8022,9 @@ function record(key, value) {
7910
8022
  function isOptional(ast) {
7911
8023
  return ast.context?.isOptional ?? false;
7912
8024
  }
8025
+ function isMutable(ast) {
8026
+ return ast.context?.isMutable ?? false;
8027
+ }
7913
8028
  function isStructuralCheck(check) {
7914
8029
  return check.annotations?.[STRUCTURAL_ANNOTATION_KEY] === true || check._tag === "FilterGroup" && check.checks.every(isStructuralCheck);
7915
8030
  }
@@ -7943,7 +8058,7 @@ var toType2 = /* @__PURE__ */ memoizeIdempotent((ast) => {
7943
8058
  const type = "recur" in ast ? ast.recur(toType2) : ast;
7944
8059
  if ("encodingChecks" in type && type.encodingChecks) {
7945
8060
  const checks = canPreserveEncodingChecks(ast) ? type.encodingChecks : isArrays(type) || isObjects(type) || isDeclaration(type) && type.typeParameters.length > 0 ? extractStructuralChecks(type.encodingChecks) : undefined;
7946
- return copy(type, {
8061
+ return copy2(type, {
7947
8062
  encodingChecks: undefined,
7948
8063
  checks: combineChecks(type.checks, checks)
7949
8064
  });
@@ -8019,6 +8134,7 @@ var parameterFromString = /* @__PURE__ */ applyToSelfOrLastLinkEncodingIdempoten
8019
8134
  return ast.recur(parameterFromString);
8020
8135
  }
8021
8136
  });
8137
+ var STRING_PATTERN = "[\\s\\S]*?";
8022
8138
  var isStringFiniteRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${FINITE_PATTERN}$`);
8023
8139
  var isStringNumberRegExp = /* @__PURE__ */ new globalThis.RegExp(`^(?:${FINITE_PATTERN}|Infinity|-Infinity|NaN)$`);
8024
8140
  function isStringFinite(annotations) {
@@ -8514,7 +8630,7 @@ function decodeUnknownOption2(schema, options) {
8514
8630
  return asOption(decodeUnknownEffect(schema, options));
8515
8631
  }
8516
8632
  var decodeOption2 = decodeUnknownOption2;
8517
- function encodeUnknownEffect(schema, options) {
8633
+ function encodeUnknownEffect2(schema, options) {
8518
8634
  const parser = run(flip2(schema.ast));
8519
8635
  return options === undefined ? parser : (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions));
8520
8636
  }
@@ -8685,6 +8801,116 @@ function make5(ast, options) {
8685
8801
  return self;
8686
8802
  }
8687
8803
 
8804
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/internal/jsonSchema.js
8805
+ function getSubschemaKind(keyword) {
8806
+ switch (keyword) {
8807
+ case "$defs":
8808
+ case "properties":
8809
+ case "patternProperties":
8810
+ case "dependentSchemas":
8811
+ return "map";
8812
+ case "allOf":
8813
+ case "anyOf":
8814
+ case "oneOf":
8815
+ case "prefixItems":
8816
+ return "array";
8817
+ case "not":
8818
+ case "additionalProperties":
8819
+ case "propertyNames":
8820
+ case "unevaluatedProperties":
8821
+ case "items":
8822
+ case "contains":
8823
+ case "unevaluatedItems":
8824
+ case "if":
8825
+ case "then":
8826
+ case "else":
8827
+ case "contentSchema":
8828
+ return "schema";
8829
+ }
8830
+ }
8831
+
8832
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/JsonPointer.js
8833
+ function escapeToken(token) {
8834
+ return token.replace(/~/g, "~0").replace(/\//g, "~1");
8835
+ }
8836
+ function unescapeToken(token) {
8837
+ return token.replace(/~1/g, "/").replace(/~0/g, "~");
8838
+ }
8839
+ function formatUriFragmentToken(token) {
8840
+ return encodeURI(escapeToken(token)).replace(/#/g, "%23");
8841
+ }
8842
+ function decodeUriFragment(fragment) {
8843
+ if (fragment.length === 0 || fragment === "#")
8844
+ return "";
8845
+ if (!fragment.startsWith("#"))
8846
+ return;
8847
+ const encoded = fragment.slice(1);
8848
+ try {
8849
+ if (encodeURI(encoded).replace(/%25/g, "%").replace(/#/g, "%23") !== encoded)
8850
+ return;
8851
+ const pointer = decodeURIComponent(encoded);
8852
+ return pointer.startsWith("/") && !/~(?:[^01]|$)/.test(pointer) ? pointer : undefined;
8853
+ } catch {
8854
+ return;
8855
+ }
8856
+ }
8857
+
8858
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/JsonSchema.js
8859
+ function transformSchema(node, transform) {
8860
+ return walk(node, false, true);
8861
+ function walk(node, inheritedResource, isRoot = false) {
8862
+ if (!isObject(node))
8863
+ return node;
8864
+ const inEmbeddedResource = inheritedResource || !isRoot && createsResource(node.$id);
8865
+ const out = {};
8866
+ for (const key of Object.keys(node)) {
8867
+ const value = node[key];
8868
+ let transformed = value;
8869
+ switch (getSubschemaKind(key)) {
8870
+ case "map":
8871
+ transformed = mapObject(value, (value) => walk(value, inEmbeddedResource)) ?? value;
8872
+ break;
8873
+ case "array":
8874
+ transformed = Array.isArray(value) ? value.map((value) => walk(value, inEmbeddedResource)) : value;
8875
+ break;
8876
+ case "schema":
8877
+ transformed = walk(value, inEmbeddedResource);
8878
+ }
8879
+ assignProperty(out, key, transformed);
8880
+ }
8881
+ transform(out, inEmbeddedResource);
8882
+ return out;
8883
+ }
8884
+ }
8885
+ function rewriteRefs(schema, rewrite) {
8886
+ return transformSchema(schema, (schema) => {
8887
+ rewriteSchemaRef(schema, rewrite);
8888
+ });
8889
+ }
8890
+ function rewriteSchemaRef(schema, rewrite) {
8891
+ if (typeof schema.$ref === "string") {
8892
+ assignProperty(schema, "$ref", rewrite(schema.$ref, "$ref"));
8893
+ }
8894
+ if (typeof schema.$dynamicRef === "string") {
8895
+ assignProperty(schema, "$dynamicRef", rewrite(schema.$dynamicRef, "$dynamicRef"));
8896
+ }
8897
+ }
8898
+ function mapObject(value, f) {
8899
+ if (!isObject(value))
8900
+ return;
8901
+ const out = {};
8902
+ for (const key of Object.keys(value)) {
8903
+ assignProperty(out, key, f(value[key], key));
8904
+ }
8905
+ return out;
8906
+ }
8907
+ function createsResource(id) {
8908
+ return typeof id === "string" && id.length > 0 && id[0] !== "#";
8909
+ }
8910
+ var PRE_2020_TO_2020_COLLISIONS = ["$anchor", "$defs", "$dynamicAnchor", "$dynamicRef", "$vocabulary", "contentSchema", "dependentRequired", "dependentSchemas", "maxContains", "minContains", "prefixItems", "unevaluatedItems", "unevaluatedProperties"];
8911
+ var DRAFT_07_TO_2020_COLLISIONS = [...PRE_2020_TO_2020_COLLISIONS, "deprecated"];
8912
+ var OPEN_API_30_TO_2020_COLLISIONS = [...PRE_2020_TO_2020_COLLISIONS, "$comment", "$id", "$schema", "const", "contains", "contentEncoding", "contentMediaType", "else", "examples", "if", "patternProperties", "propertyNames", "then"];
8913
+
8688
8914
  // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/internal/schema/toCodec.js
8689
8915
  function toCodecJson2(schema) {
8690
8916
  return make5(toCodecJsonAST(schema.ast), {
@@ -8843,9 +9069,9 @@ function toCodecStringTreeASTStep(ast, recur, onMissingAnnotation) {
8843
9069
  }
8844
9070
  return ast;
8845
9071
  }
8846
- var nullToString = /* @__PURE__ */ new Link(/* @__PURE__ */ new Literal2("null"), /* @__PURE__ */ new Transformation(/* @__PURE__ */ transform2(() => null), /* @__PURE__ */ transform2(() => "null")));
8847
- var booleanToString = /* @__PURE__ */ new Link(/* @__PURE__ */ new Union2([/* @__PURE__ */ new Literal2("true"), /* @__PURE__ */ new Literal2("false")]), /* @__PURE__ */ new Transformation(/* @__PURE__ */ transform2((s) => s === "true"), /* @__PURE__ */ String2()));
8848
- var arrayFromSingleTransformation = /* @__PURE__ */ new Transformation(/* @__PURE__ */ transform2((input) => typeof input === "string" ? [input] : input), /* @__PURE__ */ passthrough());
9072
+ var nullToString = /* @__PURE__ */ new Link(/* @__PURE__ */ new Literal2("null"), /* @__PURE__ */ new Transformation(/* @__PURE__ */ transform(() => null), /* @__PURE__ */ transform(() => "null")));
9073
+ var booleanToString = /* @__PURE__ */ new Link(/* @__PURE__ */ new Union2([/* @__PURE__ */ new Literal2("true"), /* @__PURE__ */ new Literal2("false")]), /* @__PURE__ */ new Transformation(/* @__PURE__ */ transform((s) => s === "true"), /* @__PURE__ */ String2()));
9074
+ var arrayFromSingleTransformation = /* @__PURE__ */ new Transformation(/* @__PURE__ */ transform((input) => typeof input === "string" ? [input] : input), /* @__PURE__ */ passthrough());
8849
9075
  var isCodecArrayFromSingleLink = (link) => link.transformation === arrayFromSingleTransformation;
8850
9076
  var toCodecStringTreeAST = /* @__PURE__ */ makeCodecDerivation((ast, recur) => toCodecStringTreeASTStep(ast, recur, (ast) => {
8851
9077
  throw new globalThis.Error("Missing structural codec for StringTree", {
@@ -8855,6 +9081,1108 @@ var toCodecStringTreeAST = /* @__PURE__ */ makeCodecDerivation((ast, recur) => t
8855
9081
  stopAt: isCodecArrayFromSingleLink
8856
9082
  });
8857
9083
 
9084
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/RegExp.js
9085
+ var RegExp2 = globalThis.RegExp;
9086
+ var escape = (string) => string.replace(/[/\\^$*+?.()|[\]{}]/g, "\\$&");
9087
+
9088
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/internal/errors.js
9089
+ function errorWithPath(message, path) {
9090
+ if (path.length > 0) {
9091
+ message += `
9092
+ at ${formatPath(path)}`;
9093
+ }
9094
+ return new Error(message);
9095
+ }
9096
+
9097
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/internal/schema/toJsonSchemaDocument.js
9098
+ function formatDefinitionReference(key) {
9099
+ return `#/$defs/${formatUriFragmentToken(key)}`;
9100
+ }
9101
+ var jsonSchemaAnnotationExcludedKeys = /* @__PURE__ */ new Set([...annotationExcludedKeys, IDENTIFIER_FALLBACK_KEY, ...jsonSchemaAnnotationKeys]);
9102
+ function collectJsonSchemaAnnotations(annotations, options) {
9103
+ if (annotations === undefined)
9104
+ return;
9105
+ const out = {};
9106
+ for (const key of ["title", "description", "format", "contentEncoding", "contentMediaType"]) {
9107
+ const value = annotations[key];
9108
+ if (typeof value === "string")
9109
+ out[key] = value;
9110
+ }
9111
+ for (const key of ["readOnly", "writeOnly"]) {
9112
+ const value = annotations[key];
9113
+ if (typeof value === "boolean")
9114
+ out[key] = value;
9115
+ }
9116
+ const expected = annotations.expected;
9117
+ if (out.description === undefined && options?.generateDescriptions === true && typeof expected === "string") {
9118
+ out.description = expected;
9119
+ }
9120
+ const defaultValue = annotations.default;
9121
+ if (isJson(defaultValue))
9122
+ out.default = defaultValue;
9123
+ const examples = annotations.examples;
9124
+ if (Array.isArray(examples) && isJson(examples))
9125
+ out.examples = examples;
9126
+ const contentSchema = annotations.contentSchema;
9127
+ if (isJson(contentSchema))
9128
+ out.contentSchema = contentSchema;
9129
+ if (options?.includeAnnotationKey !== undefined) {
9130
+ for (const [key, value] of Object.entries(annotations)) {
9131
+ if (jsonSchemaAnnotationExcludedKeys.has(key) || !options.includeAnnotationKey(key)) {
9132
+ continue;
9133
+ }
9134
+ if (isJson(value))
9135
+ assignProperty(out, key, value);
9136
+ }
9137
+ }
9138
+ return Object.keys(out).length === 0 ? undefined : out;
9139
+ }
9140
+ function extractJsonSchemaNumberType(schema) {
9141
+ let type = schema.type === "number" || schema.type === "integer" ? schema.type : undefined;
9142
+ let out = schema;
9143
+ if (type !== undefined) {
9144
+ out = {
9145
+ ...schema
9146
+ };
9147
+ delete out.type;
9148
+ }
9149
+ if (Array.isArray(out.allOf)) {
9150
+ const members = [];
9151
+ let changed = false;
9152
+ for (const member of out.allOf) {
9153
+ const extracted = extractJsonSchemaNumberType(member);
9154
+ if (extracted.type !== undefined) {
9155
+ changed = true;
9156
+ if (type === undefined || extracted.type === "integer")
9157
+ type = extracted.type;
9158
+ }
9159
+ if (Object.keys(extracted.schema).length > 0)
9160
+ members.push(extracted.schema);
9161
+ }
9162
+ if (changed) {
9163
+ const {
9164
+ allOf: _,
9165
+ ...rest
9166
+ } = out;
9167
+ out = members.length === 0 ? rest : {
9168
+ ...rest,
9169
+ allOf: members
9170
+ };
9171
+ }
9172
+ }
9173
+ return {
9174
+ type,
9175
+ schema: out
9176
+ };
9177
+ }
9178
+ function isJsonSchemaNumberEncoding(schema) {
9179
+ if (!Array.isArray(schema.anyOf) || schema.anyOf.length !== 2 || schema.anyOf[0]?.type !== "number")
9180
+ return false;
9181
+ const special = schema.anyOf[1];
9182
+ return special?.type === "string" && Array.isArray(special.enum) && special.enum.length === 3 && special.enum.includes("NaN") && special.enum.includes("Infinity") && special.enum.includes("-Infinity");
9183
+ }
9184
+ var inlineableCheckKeywords = "|type|format|pattern|multipleOf|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength|minItems|maxItems|uniqueItems|minProperties|maxProperties|propertyNames|";
9185
+ function hasOnlyKeywords(schema, allowed) {
9186
+ return Object.keys(schema).every((key) => allowed.includes(`|${key}|`));
9187
+ }
9188
+ function hasNoCollisions(left, rightKeys) {
9189
+ return typeof left.$ref !== "string" && rightKeys.every((key) => !Object.hasOwn(left, key));
9190
+ }
9191
+ var lowerBoundKeywords = "|minimum|exclusiveMinimum|minLength|minItems|minProperties|";
9192
+ var upperBoundKeywords = "|maximum|exclusiveMaximum|maxLength|maxItems|maxProperties|";
9193
+ function mergeInlineCheck(left, right, rightKeys) {
9194
+ if (typeof left.$ref === "string")
9195
+ return;
9196
+ const out = {
9197
+ ...left,
9198
+ ...right
9199
+ };
9200
+ for (const key of rightKeys) {
9201
+ if (!Object.hasOwn(left, key))
9202
+ continue;
9203
+ const a = left[key];
9204
+ const b = right[key];
9205
+ if (typeof a !== "number" || typeof b !== "number")
9206
+ return;
9207
+ if (lowerBoundKeywords.includes(`|${key}|`))
9208
+ out[key] = Math.max(a, b);
9209
+ else if (upperBoundKeywords.includes(`|${key}|`))
9210
+ out[key] = Math.min(a, b);
9211
+ else
9212
+ return;
9213
+ }
9214
+ if (typeof out.minimum === "number" && typeof out.exclusiveMinimum === "number") {
9215
+ delete out[out.exclusiveMinimum >= out.minimum ? "minimum" : "exclusiveMinimum"];
9216
+ }
9217
+ if (typeof out.maximum === "number" && typeof out.exclusiveMaximum === "number") {
9218
+ delete out[out.exclusiveMaximum <= out.maximum ? "maximum" : "exclusiveMaximum"];
9219
+ }
9220
+ return out;
9221
+ }
9222
+ var promotableAnnotationKeywords = "|title|description|default|examples|readOnly|writeOnly|";
9223
+ var inlineableAnnotatedCheckKeywords = inlineableCheckKeywords + promotableAnnotationKeywords;
9224
+ function appendJsonSchema(left, right, inlineCheck) {
9225
+ if (Object.keys(left).length === 0)
9226
+ return right;
9227
+ const rightKeys = Object.keys(right);
9228
+ if (rightKeys.length === 0)
9229
+ return left;
9230
+ const leftType = left.type === "number" || left.type === "integer" ? left.type : undefined;
9231
+ const isNumberEncoding = isJsonSchemaNumberEncoding(left);
9232
+ if (leftType !== undefined || isNumberEncoding) {
9233
+ const extracted = extractJsonSchemaNumberType(right);
9234
+ if (extracted.type !== undefined) {
9235
+ const type = leftType === "integer" || extracted.type === "integer" ? "integer" : "number";
9236
+ const base = {
9237
+ ...left,
9238
+ type
9239
+ };
9240
+ if (isNumberEncoding)
9241
+ delete base.anyOf;
9242
+ const extractedKeys = Object.keys(extracted.schema);
9243
+ if (extractedKeys.length === 0)
9244
+ return base;
9245
+ return hasOnlyKeywords(extracted.schema, promotableAnnotationKeywords) && hasNoCollisions(base, extractedKeys) ? {
9246
+ ...base,
9247
+ ...extracted.schema
9248
+ } : appendJsonSchema(base, extracted.schema, inlineCheck);
9249
+ }
9250
+ }
9251
+ if (inlineCheck) {
9252
+ const merged = mergeInlineCheck(left, right, rightKeys);
9253
+ if (merged !== undefined)
9254
+ return merged;
9255
+ }
9256
+ const members = Array.isArray(right.allOf) && rightKeys.length === 1 ? right.allOf : [right];
9257
+ if (Array.isArray(left.allOf)) {
9258
+ return {
9259
+ ...left,
9260
+ allOf: [...left.allOf, ...members]
9261
+ };
9262
+ }
9263
+ if (typeof left.$ref === "string") {
9264
+ return {
9265
+ allOf: [left, ...members]
9266
+ };
9267
+ }
9268
+ return {
9269
+ ...left,
9270
+ allOf: members
9271
+ };
9272
+ }
9273
+ function isExact(exactness, seen = new Set) {
9274
+ if (typeof exactness === "boolean")
9275
+ return exactness;
9276
+ if (seen.has(exactness))
9277
+ return true;
9278
+ seen.add(exactness);
9279
+ return exactness.every((dependency) => isExact(dependency, seen));
9280
+ }
9281
+ function isApproximateCheckOutput(output) {
9282
+ return Array.isArray(output);
9283
+ }
9284
+ function compileJsonSchema(representations, rootPaths, references, options) {
9285
+ const numberKeyPattern = `^(?:${FINITE_PATTERN}|Infinity|-Infinity|NaN)$`;
9286
+ const compiledDefinitions = new Map;
9287
+ const definitionAliases = new Map;
9288
+ const compiledRepresentations = new WeakMap;
9289
+ const pendingOneOf = new Map;
9290
+ const fallbackDefinitions = new Map;
9291
+ const referenceKeys = Object.keys(references);
9292
+ for (const key of referenceKeys) {
9293
+ compileDefinition(key, ["references", key]);
9294
+ }
9295
+ const compiledSchemas = map6(representations, (representation, index) => recur(representation, rootPaths[index], []));
9296
+ for (const {
9297
+ branches,
9298
+ schemas
9299
+ } of pendingOneOf.values()) {
9300
+ if (!isExact(branches)) {
9301
+ for (const schema of schemas) {
9302
+ if (Array.isArray(schema.oneOf)) {
9303
+ schema.anyOf = schema.oneOf;
9304
+ delete schema.oneOf;
9305
+ }
9306
+ }
9307
+ }
9308
+ }
9309
+ for (const key of referenceKeys) {
9310
+ const representation = references[key];
9311
+ const fallback = getIdentifierFallback(representation);
9312
+ if (fallback === undefined)
9313
+ continue;
9314
+ const schema = compiledDefinitions.get(key).schema;
9315
+ const candidates = fallbackDefinitions.get(fallback);
9316
+ const match = candidates?.find((candidate) => equals(compiledDefinitions.get(candidate).schema, schema));
9317
+ if (match === undefined) {
9318
+ if (candidates === undefined)
9319
+ fallbackDefinitions.set(fallback, [key]);
9320
+ else
9321
+ candidates.push(key);
9322
+ } else {
9323
+ definitionAliases.set(key, match);
9324
+ }
9325
+ }
9326
+ const schemas = map6(compiledSchemas, finalizeJsonSchema);
9327
+ const definitions = {};
9328
+ for (const key of referenceKeys) {
9329
+ if (!definitionAliases.has(key)) {
9330
+ assignProperty(definitions, key, finalizeJsonSchema(compiledDefinitions.get(key).schema));
9331
+ }
9332
+ }
9333
+ return {
9334
+ dialect: "draft-2020-12",
9335
+ schemas,
9336
+ definitions
9337
+ };
9338
+ function registerPendingOneOf(schema) {
9339
+ if (Array.isArray(schema.oneOf))
9340
+ pendingOneOf.get(schema.oneOf)?.schemas.push(schema);
9341
+ return schema;
9342
+ }
9343
+ function compileAnnotatedMember(member, path, dependencies) {
9344
+ const schema = recur(member.type, [...path, "type"], dependencies);
9345
+ const annotations = collectJsonSchemaAnnotations(member.annotations, options);
9346
+ return annotations === undefined ? schema : registerPendingOneOf(appendJsonSchema(schema, annotations));
9347
+ }
9348
+ function compileDefinition(key, path) {
9349
+ if (!Object.hasOwn(references, key)) {
9350
+ throw errorWithPath(`Invalid reference ${key}`, [...path, "$ref"]);
9351
+ }
9352
+ const cached = compiledDefinitions.get(key);
9353
+ if (cached !== undefined)
9354
+ return cached;
9355
+ const result = {
9356
+ schema: {},
9357
+ dependencies: []
9358
+ };
9359
+ compiledDefinitions.set(key, result);
9360
+ result.schema = recur(references[key], ["references", key], result.dependencies);
9361
+ return result;
9362
+ }
9363
+ function finalizeJsonSchema(schema) {
9364
+ return rewriteRefs(schema, ($ref) => {
9365
+ const pointer = decodeUriFragment($ref);
9366
+ if (pointer === undefined) {
9367
+ if (/^#(?:\/|%2f)/i.test($ref)) {
9368
+ throw new Error(`Invalid JSON Pointer URI fragment ${JSON.stringify($ref)}`);
9369
+ }
9370
+ return $ref;
9371
+ }
9372
+ if (!pointer.startsWith("/$defs/"))
9373
+ return $ref;
9374
+ const separator = pointer.indexOf("/", 7);
9375
+ const canonical = definitionAliases.get(unescapeToken(pointer.slice(7, separator < 0 ? undefined : separator)));
9376
+ if (canonical === undefined)
9377
+ return $ref;
9378
+ return $ref.replace(/^#(?:\/|%2f).*?(?:\/|%2f).*?(?=\/|%2f|$)/i, formatDefinitionReference(canonical));
9379
+ });
9380
+ }
9381
+ function getIdentifierFallback(representation) {
9382
+ if (representation._tag === "Reference")
9383
+ return;
9384
+ const annotations = representation.checks.length === 0 ? representation.annotations : representation.checks[representation.checks.length - 1].annotations;
9385
+ return typeof annotations?.identifier !== "string" && typeof annotations?.[IDENTIFIER_FALLBACK_KEY] === "string" ? annotations[IDENTIFIER_FALLBACK_KEY] : undefined;
9386
+ }
9387
+ function compileCheck(check, type, path, dependencies) {
9388
+ const annotations = check.annotations;
9389
+ const callback = annotations?.toJsonSchema;
9390
+ if (callback !== undefined) {
9391
+ const schemas = check.representation?.schemas?.map((schema, index) => recur(schema, [...path, "representation", "schemas", index], dependencies)) ?? [];
9392
+ const result = callback({
9393
+ type,
9394
+ schemas
9395
+ });
9396
+ const approximate = isApproximateCheckOutput(result);
9397
+ if (approximate) {
9398
+ dependencies.push(false);
9399
+ }
9400
+ const fragment = approximate ? result[0] : result;
9401
+ const ordinary = collectJsonSchemaAnnotations(annotations, options);
9402
+ const schema = ordinary === undefined ? fragment : {
9403
+ ...fragment,
9404
+ ...ordinary
9405
+ };
9406
+ const allowed = ordinary === undefined ? inlineableCheckKeywords : inlineableAnnotatedCheckKeywords;
9407
+ return [schema, check._tag === "Filter" && hasOnlyKeywords(schema, allowed) && (ordinary === undefined || hasOnlyKeywords(ordinary, promotableAnnotationKeywords)) ? true : undefined];
9408
+ }
9409
+ if (check._tag === "Filter") {
9410
+ dependencies.push(false);
9411
+ return;
9412
+ }
9413
+ const schemas = check.checks.flatMap((child, index) => {
9414
+ const result = compileCheck(child, type, [...path, "checks", index], dependencies);
9415
+ return result === undefined ? [] : [result[0]];
9416
+ });
9417
+ if (schemas.length === 0)
9418
+ return;
9419
+ const ordinary = collectJsonSchemaAnnotations(annotations, options);
9420
+ const schema = {
9421
+ allOf: schemas
9422
+ };
9423
+ return [ordinary === undefined ? schema : {
9424
+ ...schema,
9425
+ ...ordinary
9426
+ }];
9427
+ }
9428
+ function recur(representation, path, dependencies) {
9429
+ if (representation._tag === "Reference") {
9430
+ dependencies.push(compileDefinition(representation.$ref, path).dependencies);
9431
+ return {
9432
+ $ref: formatDefinitionReference(representation.$ref)
9433
+ };
9434
+ }
9435
+ const cached = compiledRepresentations.get(representation);
9436
+ if (cached !== undefined) {
9437
+ dependencies.push(cached.dependencies);
9438
+ return cached.schema;
9439
+ }
9440
+ const local = [];
9441
+ dependencies.push(local);
9442
+ let output = {
9443
+ ...on(representation, path, local),
9444
+ ...collectJsonSchemaAnnotations(representation.annotations, options)
9445
+ };
9446
+ if (representation._tag === "String" && representation.content !== undefined) {
9447
+ const content = representation.content;
9448
+ output.contentMediaType = content.mediaType;
9449
+ delete output.contentSchema;
9450
+ if (content.schema !== undefined) {
9451
+ output.contentSchema = recur(content.schema, [...path, "content", "schema"], []);
9452
+ }
9453
+ }
9454
+ for (let index = 0;index < representation.checks.length; index++) {
9455
+ const type = typeof output.type === "string" && isJsonSchemaType(output.type) ? output.type : undefined;
9456
+ const check = compileCheck(representation.checks[index], type, [...path, "checks", index], local);
9457
+ if (check !== undefined)
9458
+ output = appendJsonSchema(output, ...check);
9459
+ }
9460
+ compiledRepresentations.set(representation, {
9461
+ schema: output,
9462
+ dependencies: local
9463
+ });
9464
+ return registerPendingOneOf(output);
9465
+ }
9466
+ function on(representation, path, dependencies) {
9467
+ switch (representation._tag) {
9468
+ case "Any":
9469
+ case "Unknown":
9470
+ return {};
9471
+ case "ObjectKeyword":
9472
+ return {
9473
+ anyOf: [{
9474
+ type: "object"
9475
+ }, {
9476
+ type: "array"
9477
+ }]
9478
+ };
9479
+ case "Void":
9480
+ case "Undefined":
9481
+ case "Null":
9482
+ return {
9483
+ type: "null"
9484
+ };
9485
+ case "BigInt":
9486
+ return {
9487
+ type: "string",
9488
+ allOf: [{
9489
+ pattern: "^-?\\d+$"
9490
+ }]
9491
+ };
9492
+ case "Symbol":
9493
+ return {
9494
+ type: "string",
9495
+ allOf: [{
9496
+ pattern: "^Symbol\\(([\\s\\S]*)\\)$"
9497
+ }]
9498
+ };
9499
+ case "UniqueSymbol":
9500
+ return globalThis.Symbol.keyFor(representation.symbol) === undefined ? {
9501
+ not: {}
9502
+ } : {
9503
+ type: "string",
9504
+ enum: [globalThis.String(representation.symbol)]
9505
+ };
9506
+ case "Declaration":
9507
+ dependencies.push(false);
9508
+ return {};
9509
+ case "Suspend":
9510
+ return recur(representation.thunk, [...path, "thunk"], dependencies);
9511
+ case "Never":
9512
+ return {
9513
+ not: {}
9514
+ };
9515
+ case "String":
9516
+ return {
9517
+ type: "string"
9518
+ };
9519
+ case "Number":
9520
+ return {
9521
+ anyOf: [{
9522
+ type: "number"
9523
+ }, {
9524
+ type: "string",
9525
+ enum: ["NaN", "Infinity", "-Infinity"]
9526
+ }]
9527
+ };
9528
+ case "Boolean":
9529
+ return {
9530
+ type: "boolean"
9531
+ };
9532
+ case "Literal": {
9533
+ const literal = representation.literal;
9534
+ return typeof literal === "bigint" ? {
9535
+ type: "string",
9536
+ enum: [globalThis.String(literal)]
9537
+ } : {
9538
+ type: typeof literal,
9539
+ enum: [literal]
9540
+ };
9541
+ }
9542
+ case "Enum": {
9543
+ const types = representation.enums.map(([title, literal]) => ({
9544
+ type: typeof literal,
9545
+ enum: [literal],
9546
+ title
9547
+ }));
9548
+ return types.length === 0 ? {
9549
+ not: {}
9550
+ } : {
9551
+ anyOf: types
9552
+ };
9553
+ }
9554
+ case "TemplateLiteral": {
9555
+ const {
9556
+ exact,
9557
+ pattern
9558
+ } = getTemplateLiteralPattern(representation.parts);
9559
+ if (!exact)
9560
+ dependencies.push(false);
9561
+ return {
9562
+ type: "string",
9563
+ pattern
9564
+ };
9565
+ }
9566
+ case "Arrays": {
9567
+ const out = {
9568
+ type: "array"
9569
+ };
9570
+ let minItems = representation.elements.length;
9571
+ const prefixItems = representation.elements.map((element, index) => {
9572
+ if (element.isOptional)
9573
+ minItems--;
9574
+ return compileAnnotatedMember(element, [...path, "elements", index], dependencies);
9575
+ });
9576
+ if (prefixItems.length > 0) {
9577
+ out.prefixItems = prefixItems;
9578
+ out.maxItems = representation.elements.length;
9579
+ if (minItems > 0)
9580
+ out.minItems = minItems;
9581
+ } else {
9582
+ out.items = false;
9583
+ }
9584
+ if (representation.rest.length === 1) {
9585
+ delete out.maxItems;
9586
+ const rest = recur(representation.rest[0], [...path, "rest", 0], dependencies);
9587
+ if (Object.keys(rest).length > 0)
9588
+ out.items = rest;
9589
+ else
9590
+ delete out.items;
9591
+ } else if (representation.rest.length > 1) {
9592
+ delete out.maxItems;
9593
+ delete out.items;
9594
+ out.minItems = minItems + representation.rest.length - 1;
9595
+ dependencies.push(false);
9596
+ }
9597
+ return out;
9598
+ }
9599
+ case "Objects":
9600
+ return compileObjects(representation, path, dependencies);
9601
+ case "Union": {
9602
+ const branches = [];
9603
+ const types = representation.types.map((type, index) => recur(type, [...path, "types", index], branches));
9604
+ dependencies.push(branches);
9605
+ if (types.length === 0)
9606
+ return {
9607
+ not: {}
9608
+ };
9609
+ if (representation.options?.mode === "oneOf") {
9610
+ pendingOneOf.set(types, {
9611
+ branches,
9612
+ schemas: []
9613
+ });
9614
+ return {
9615
+ oneOf: types
9616
+ };
9617
+ }
9618
+ if (types.length > 1) {
9619
+ const compacted = compactEnums(types);
9620
+ if (compacted !== undefined)
9621
+ return compacted;
9622
+ }
9623
+ return {
9624
+ anyOf: types.flatMap((type) => Array.isArray(type.anyOf) && Object.keys(type).length === 1 ? type.anyOf : [type])
9625
+ };
9626
+ }
9627
+ }
9628
+ }
9629
+ function compileObjects(representation, path, dependencies) {
9630
+ const {
9631
+ indexSignatures,
9632
+ propertySignatures
9633
+ } = representation;
9634
+ if (propertySignatures.length === 0 && indexSignatures.length === 0)
9635
+ return {
9636
+ not: {
9637
+ type: "null"
9638
+ }
9639
+ };
9640
+ const out = {
9641
+ type: "object"
9642
+ };
9643
+ const properties = {};
9644
+ const required = [];
9645
+ for (const [index, property] of propertySignatures.entries()) {
9646
+ const propertyPath = [...path, "propertySignatures", index];
9647
+ if (typeof property.name !== "string") {
9648
+ throw errorWithPath("Objects property names must be strings", [...propertyPath, "name"]);
9649
+ }
9650
+ assignProperty(properties, property.name, compileAnnotatedMember(property, propertyPath, dependencies));
9651
+ if (!property.isOptional)
9652
+ required.push(property.name);
9653
+ }
9654
+ if (propertySignatures.length > 0)
9655
+ out.properties = properties;
9656
+ if (required.length > 0)
9657
+ out.required = required;
9658
+ const indexes = indexSignatures.map((signature, index) => {
9659
+ const indexPath = [...path, "indexSignatures", index];
9660
+ const schema = recur(signature.type, [...indexPath, "type"], dependencies);
9661
+ const type = equals(schema, {
9662
+ not: {}
9663
+ }) ? false : schema;
9664
+ const patterns = getParameterPatterns(signature.parameter, [...indexPath, "parameter"], new Set);
9665
+ if (patterns === undefined)
9666
+ dependencies.push(false);
9667
+ return {
9668
+ type,
9669
+ patterns
9670
+ };
9671
+ });
9672
+ const patternProperties = {};
9673
+ for (const {
9674
+ patterns,
9675
+ type
9676
+ } of indexes) {
9677
+ for (const pattern of patterns ?? []) {
9678
+ const previous = patternProperties[pattern];
9679
+ assignProperty(patternProperties, pattern, previous === undefined ? type : previous === false || type === false ? false : registerPendingOneOf(appendJsonSchema(previous, type)));
9680
+ }
9681
+ }
9682
+ const hasPatternProperties = Object.keys(patternProperties).length > 0;
9683
+ if (hasPatternProperties)
9684
+ out.patternProperties = patternProperties;
9685
+ const additionalPropertySchemas = indexes.filter(({
9686
+ patterns
9687
+ }) => patterns?.length === 0).map(({
9688
+ type
9689
+ }) => type);
9690
+ const hasUnrepresentableIndexPattern = indexes.some(({
9691
+ patterns
9692
+ }) => patterns === undefined);
9693
+ if (hasUnrepresentableIndexPattern && options?.onExcessProperty === "error") {
9694
+ const propertyNames = [];
9695
+ if (propertySignatures.length > 0)
9696
+ propertyNames.push({
9697
+ enum: Object.keys(properties)
9698
+ });
9699
+ for (const [index, signature] of indexSignatures.entries()) {
9700
+ propertyNames.push(getPropertyNameSchema(signature.parameter, [...path, "indexSignatures", index, "parameter"], dependencies, new Set));
9701
+ }
9702
+ out.propertyNames = propertyNames.length === 1 ? propertyNames[0] : {
9703
+ anyOf: propertyNames
9704
+ };
9705
+ const values = indexes.map(({
9706
+ type
9707
+ }) => type);
9708
+ out.additionalProperties = values.length === 1 ? values[0] : {
9709
+ anyOf: values
9710
+ };
9711
+ if (additionalPropertySchemas.length > 0) {
9712
+ out.allOf = additionalPropertySchemas.map((type) => ({
9713
+ type: "object",
9714
+ additionalProperties: type
9715
+ }));
9716
+ }
9717
+ } else if (additionalPropertySchemas.length === 0) {
9718
+ out.additionalProperties = hasUnrepresentableIndexPattern || options?.onExcessProperty !== "error";
9719
+ } else if (additionalPropertySchemas.length === 1 && propertySignatures.length === 0 && !hasPatternProperties) {
9720
+ out.additionalProperties = additionalPropertySchemas[0];
9721
+ } else {
9722
+ out.allOf = additionalPropertySchemas.map((type) => ({
9723
+ type: "object",
9724
+ additionalProperties: type
9725
+ }));
9726
+ }
9727
+ if (typeof out.additionalProperties === "object" && out.additionalProperties !== null && Object.keys(out.additionalProperties).length === 0) {
9728
+ delete out.additionalProperties;
9729
+ }
9730
+ return out;
9731
+ }
9732
+ function getPropertyNameSchema(parameter, path, dependencies, seenReferences) {
9733
+ switch (parameter._tag) {
9734
+ case "Number":
9735
+ return {
9736
+ type: "string",
9737
+ pattern: numberKeyPattern
9738
+ };
9739
+ case "Reference": {
9740
+ if (seenReferences.has(parameter.$ref))
9741
+ return {
9742
+ type: "string"
9743
+ };
9744
+ return getPropertyNameSchema(references[parameter.$ref], ["references", parameter.$ref], dependencies, new Set(seenReferences).add(parameter.$ref));
9745
+ }
9746
+ case "Union":
9747
+ return {
9748
+ anyOf: parameter.types.map((type) => getPropertyNameSchema(type, path, dependencies, seenReferences))
9749
+ };
9750
+ default:
9751
+ return recur(parameter, path, dependencies);
9752
+ }
9753
+ }
9754
+ function getParameterPatterns(parameter, path, seenReferences) {
9755
+ switch (parameter._tag) {
9756
+ case "Reference": {
9757
+ compileDefinition(parameter.$ref, path);
9758
+ if (seenReferences.has(parameter.$ref))
9759
+ return;
9760
+ const next = new Set(seenReferences).add(parameter.$ref);
9761
+ return getParameterPatterns(references[parameter.$ref], ["references", parameter.$ref], next);
9762
+ }
9763
+ case "String": {
9764
+ if (parameter.checks.length === 0)
9765
+ return [];
9766
+ if (parameter.checks.length !== 1 || parameter.checks[0]._tag !== "Filter" || parameter.checks[0].annotations?.toJsonSchema === undefined) {
9767
+ return;
9768
+ }
9769
+ const dependencies = [];
9770
+ const schema = recur(parameter, path, dependencies);
9771
+ if (!isExact(dependencies))
9772
+ return;
9773
+ return schema.type === "string" && typeof schema.pattern === "string" && hasOnlyKeywords(schema, "|type|pattern|title|description|default|examples|readOnly|writeOnly|") ? [schema.pattern] : undefined;
9774
+ }
9775
+ case "TemplateLiteral": {
9776
+ if (parameter.checks.length > 0)
9777
+ return;
9778
+ const {
9779
+ exact,
9780
+ pattern
9781
+ } = getTemplateLiteralPattern(parameter.parts);
9782
+ return exact ? [pattern] : undefined;
9783
+ }
9784
+ case "Union": {
9785
+ if (parameter.types.length === 0 || parameter.checks.length > 0 || parameter.options?.mode === "oneOf") {
9786
+ return;
9787
+ }
9788
+ const patterns = [];
9789
+ for (let index = 0;index < parameter.types.length; index++) {
9790
+ const memberPatterns = getParameterPatterns(parameter.types[index], [...path, "types", index], seenReferences);
9791
+ if (memberPatterns === undefined)
9792
+ return;
9793
+ if (memberPatterns.length === 0)
9794
+ return [];
9795
+ patterns.push(...memberPatterns);
9796
+ }
9797
+ return patterns;
9798
+ }
9799
+ case "Number":
9800
+ return parameter.checks.length === 0 ? [numberKeyPattern] : undefined;
9801
+ default:
9802
+ throw errorWithPath(`Invalid index signature parameter ${parameter._tag}`, path);
9803
+ }
9804
+ }
9805
+ function getTemplateLiteralPattern(parts) {
9806
+ const activeReferences = new Set;
9807
+ let exact = true;
9808
+ const pattern = `^${parts.map(getPartPattern).join("")}$`;
9809
+ return {
9810
+ pattern,
9811
+ exact
9812
+ };
9813
+ function getPartPattern(part) {
9814
+ if (part._tag !== "Reference" && part.checks.length > 0)
9815
+ exact = false;
9816
+ switch (part._tag) {
9817
+ case "Reference": {
9818
+ if (!Object.hasOwn(references, part.$ref)) {
9819
+ throw errorWithPath(`Invalid reference ${part.$ref}`, []);
9820
+ }
9821
+ if (activeReferences.has(part.$ref)) {
9822
+ throw errorWithPath(`Invalid recursive TemplateLiteral part ${part.$ref}`, []);
9823
+ }
9824
+ activeReferences.add(part.$ref);
9825
+ const pattern = getPartPattern(references[part.$ref]);
9826
+ activeReferences.delete(part.$ref);
9827
+ return pattern;
9828
+ }
9829
+ case "Literal":
9830
+ return escape(globalThis.String(part.literal));
9831
+ case "String":
9832
+ return STRING_PATTERN;
9833
+ case "Number":
9834
+ return FINITE_PATTERN;
9835
+ case "BigInt":
9836
+ return "-?\\d+";
9837
+ case "TemplateLiteral":
9838
+ return part.parts.map(getPartPattern).join("");
9839
+ case "Union":
9840
+ if (part.types.length === 0)
9841
+ return "(?!)";
9842
+ if (part.options?.mode === "oneOf")
9843
+ exact = false;
9844
+ return `(?:${part.types.map(getPartPattern).join("|")})`;
9845
+ default:
9846
+ throw errorWithPath(`Invalid TemplateLiteral part ${part._tag}`, []);
9847
+ }
9848
+ }
9849
+ }
9850
+ }
9851
+ function isJsonSchemaType(input) {
9852
+ return input === "string" || input === "number" || input === "boolean" || input === "array" || input === "object" || input === "null" || input === "integer";
9853
+ }
9854
+ function compactEnums(schemas) {
9855
+ let sharedType = undefined;
9856
+ const values = [];
9857
+ for (const schema of schemas) {
9858
+ const keys = Object.keys(schema);
9859
+ if (keys.length !== 2 || schema.type === undefined || !Array.isArray(schema.enum) || schema.enum.length === 0) {
9860
+ return;
9861
+ }
9862
+ if (sharedType === undefined)
9863
+ sharedType = schema.type;
9864
+ else if (schema.type !== sharedType)
9865
+ return;
9866
+ for (const value of schema.enum) {
9867
+ if (values.includes(value))
9868
+ return;
9869
+ values.push(value);
9870
+ }
9871
+ }
9872
+ return {
9873
+ type: sharedType,
9874
+ enum: values
9875
+ };
9876
+ }
9877
+ function toJsonSchemaDocument2(document, options) {
9878
+ const output = compileJsonSchema([document.representation], [["representation"]], document.references, options);
9879
+ return {
9880
+ dialect: output.dialect,
9881
+ schema: output.schemas[0],
9882
+ definitions: output.definitions
9883
+ };
9884
+ }
9885
+
9886
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/internal/schema/toRepresentation.js
9887
+ var defaultReferencePolicy = ({
9888
+ identifier
9889
+ }) => identifier;
9890
+ function annotationsField(annotations) {
9891
+ return annotations === undefined ? undefined : {
9892
+ annotations
9893
+ };
9894
+ }
9895
+ function toRepresentation(ast, options) {
9896
+ const {
9897
+ references,
9898
+ representations
9899
+ } = toRepresentations([ast], options);
9900
+ return {
9901
+ representation: representations[0],
9902
+ references
9903
+ };
9904
+ }
9905
+ function toRepresentations(asts, options) {
9906
+ const references = {};
9907
+ const usedReferences = new Set;
9908
+ const candidates = new Map;
9909
+ for (const ast of asts)
9910
+ visit(ast);
9911
+ const referencePolicy = options?.referencePolicy ?? defaultReferencePolicy;
9912
+ for (const variants of candidates.values()) {
9913
+ for (const candidate of variants) {
9914
+ const requestedReference = referencePolicy({
9915
+ ast: candidate.ast,
9916
+ occurrences: candidate.occurrences,
9917
+ identifier: candidate.identifier
9918
+ });
9919
+ if (requestedReference !== undefined) {
9920
+ const separator = requestedReference === candidate.identifier || !requestedReference.endsWith("_") ? "_" : "";
9921
+ candidate.reference = getReference(requestedReference, separator);
9922
+ } else if (candidate.isRecursive) {
9923
+ candidate.reference = getReference(`${candidate.ast._tag}_`, "");
9924
+ }
9925
+ }
9926
+ }
9927
+ const representations = map6(asts, recur);
9928
+ return {
9929
+ representations,
9930
+ references
9931
+ };
9932
+ function getReference(prefix, separator) {
9933
+ let candidate = prefix;
9934
+ let suffix = 0;
9935
+ while (usedReferences.has(candidate)) {
9936
+ candidate = `${prefix}${separator}${++suffix}`;
9937
+ }
9938
+ usedReferences.add(candidate);
9939
+ return candidate;
9940
+ }
9941
+ function annotateReference(ast, candidate, reference) {
9942
+ const fallback = candidate.fallback;
9943
+ if (fallback !== undefined) {
9944
+ return resolveIdentifierFallback(ast) === fallback ? ast : annotate(ast, {
9945
+ [IDENTIFIER_FALLBACK_KEY]: fallback
9946
+ });
9947
+ }
9948
+ return reference === candidate.identifier ? ast : annotate(ast, {
9949
+ identifier: reference
9950
+ });
9951
+ }
9952
+ function getCandidate(input, encodingLength = input.encoding?.length ?? 0) {
9953
+ let ast = input;
9954
+ let content;
9955
+ while (ast.encoding !== undefined && encodingLength > 0) {
9956
+ const last = ast.encoding[encodingLength - 1];
9957
+ if (last.to.encoding === undefined && last.to._tag === "String") {
9958
+ const metadata = getContent(last.transformation.encode);
9959
+ if (metadata !== undefined) {
9960
+ content = {
9961
+ mediaType: metadata.mediaType,
9962
+ schema: metadata.preserveSchema ? getCandidate(ast, encodingLength - 1) : undefined
9963
+ };
9964
+ }
9965
+ }
9966
+ ast = last.to;
9967
+ encodingLength = ast.encoding?.length ?? 0;
9968
+ }
9969
+ const owner = getContextOwner(ast);
9970
+ let identifier = resolveIdentifier(ast);
9971
+ const fallback = identifier === undefined ? (ast !== input ? resolveIdentifier(input) : undefined) ?? resolveIdentifierFallback(ast) : undefined;
9972
+ if (fallback !== undefined)
9973
+ identifier = `${fallback}Encoded`;
9974
+ let variants = candidates.get(owner);
9975
+ if (variants === undefined) {
9976
+ variants = [];
9977
+ candidates.set(owner, variants);
9978
+ }
9979
+ let candidate = variants.find((candidate) => candidate.identifier === identifier && candidate.content?.mediaType === content?.mediaType && candidate.content?.schema === content?.schema);
9980
+ if (candidate === undefined) {
9981
+ candidate = {
9982
+ ast: owner,
9983
+ identifier,
9984
+ fallback,
9985
+ content,
9986
+ occurrences: 0
9987
+ };
9988
+ variants.push(candidate);
9989
+ }
9990
+ return candidate;
9991
+ }
9992
+ function visit(input) {
9993
+ visitCandidate(getCandidate(input));
9994
+ return input;
9995
+ }
9996
+ function visitCandidate(candidate) {
9997
+ const ast = candidate.ast;
9998
+ candidate.occurrences++;
9999
+ if (candidate.visiting) {
10000
+ candidate.isRecursive = true;
10001
+ return;
10002
+ }
10003
+ if (candidate.occurrences > 1)
10004
+ return;
10005
+ candidate.visiting = true;
10006
+ if (candidate.content?.schema !== undefined)
10007
+ visitCandidate(candidate.content.schema);
10008
+ visitChecks(ast.checks);
10009
+ switch (ast._tag) {
10010
+ default:
10011
+ if ("recur" in ast)
10012
+ ast.recur(visit);
10013
+ break;
10014
+ case "TemplateLiteral":
10015
+ ast.parts.forEach(visit);
10016
+ break;
10017
+ case "Suspend":
10018
+ visit(ast.thunk());
10019
+ break;
10020
+ }
10021
+ candidate.visiting = false;
10022
+ }
10023
+ function visitChecks(checks) {
10024
+ checks?.forEach((check) => {
10025
+ check.annotations?.representation?.schemas?.forEach((schema) => visit(toType2(schema)));
10026
+ if (check._tag === "FilterGroup")
10027
+ visitChecks(check.checks);
10028
+ });
10029
+ }
10030
+ function recur(input) {
10031
+ return recurCandidate(getCandidate(input));
10032
+ }
10033
+ function recurCandidate(candidate) {
10034
+ const ast = candidate.ast;
10035
+ const reference = candidate.reference;
10036
+ if (reference !== undefined) {
10037
+ if (!candidate.emitted) {
10038
+ candidate.emitted = true;
10039
+ const annotated = candidate.identifier === undefined ? ast : annotateReference(ast, candidate, reference);
10040
+ const representation = on(annotated, candidate.content);
10041
+ assignProperty(references, reference, representation);
10042
+ }
10043
+ return {
10044
+ _tag: "Reference",
10045
+ $ref: reference
10046
+ };
10047
+ }
10048
+ return on(ast, candidate.content);
10049
+ }
10050
+ function on(ast, content) {
10051
+ const common = {
10052
+ checks: ast.checks?.map(fromCheck) ?? [],
10053
+ ...ast._tag === "Declaration" ? fromAnnotations(ast.annotations) : annotationsField(ast.annotations)
10054
+ };
10055
+ switch (ast._tag) {
10056
+ case "Declaration":
10057
+ return {
10058
+ _tag: ast._tag,
10059
+ typeParameters: ast.typeParameters.map(recur),
10060
+ ...common
10061
+ };
10062
+ default:
10063
+ return {
10064
+ _tag: ast._tag,
10065
+ ...content === undefined ? undefined : {
10066
+ content: {
10067
+ mediaType: content.mediaType,
10068
+ ...content.schema === undefined ? undefined : {
10069
+ schema: recurCandidate(content.schema)
10070
+ }
10071
+ }
10072
+ },
10073
+ ...common
10074
+ };
10075
+ case "Literal":
10076
+ return {
10077
+ _tag: ast._tag,
10078
+ literal: ast.literal,
10079
+ ...common
10080
+ };
10081
+ case "UniqueSymbol":
10082
+ return {
10083
+ _tag: ast._tag,
10084
+ symbol: ast.symbol,
10085
+ ...common
10086
+ };
10087
+ case "Enum":
10088
+ return {
10089
+ _tag: ast._tag,
10090
+ enums: ast.enums,
10091
+ ...common
10092
+ };
10093
+ case "TemplateLiteral":
10094
+ return {
10095
+ _tag: ast._tag,
10096
+ parts: ast.parts.map(recur),
10097
+ ...common
10098
+ };
10099
+ case "Arrays":
10100
+ return {
10101
+ _tag: ast._tag,
10102
+ elements: ast.elements.map((element) => {
10103
+ const projected = getLastEncoding(element);
10104
+ const annotations = projected.context?.annotations;
10105
+ return {
10106
+ isOptional: isOptional(projected),
10107
+ type: recur(element),
10108
+ ...annotationsField(annotations)
10109
+ };
10110
+ }),
10111
+ rest: ast.rest.map(recur),
10112
+ ...common
10113
+ };
10114
+ case "Objects":
10115
+ return {
10116
+ _tag: ast._tag,
10117
+ propertySignatures: ast.propertySignatures.map((property) => {
10118
+ const projected = getLastEncoding(property.type);
10119
+ const annotations = projected.context?.annotations;
10120
+ return {
10121
+ name: property.name,
10122
+ type: recur(property.type),
10123
+ isOptional: isOptional(projected),
10124
+ isMutable: isMutable(projected),
10125
+ ...annotationsField(annotations)
10126
+ };
10127
+ }),
10128
+ indexSignatures: ast.indexSignatures.map((index) => ({
10129
+ parameter: recur(index.parameter),
10130
+ type: recur(index.type)
10131
+ })),
10132
+ ...common
10133
+ };
10134
+ case "Union":
10135
+ return {
10136
+ _tag: ast._tag,
10137
+ types: ast.types.map(recur),
10138
+ ...ast.options === undefined ? {} : {
10139
+ options: ast.options
10140
+ },
10141
+ ...common
10142
+ };
10143
+ case "Suspend":
10144
+ return {
10145
+ _tag: ast._tag,
10146
+ ...common,
10147
+ checks: [],
10148
+ thunk: recur(ast.thunk())
10149
+ };
10150
+ }
10151
+ }
10152
+ function fromCheck(check) {
10153
+ return {
10154
+ ...check._tag === "Filter" ? {
10155
+ _tag: check._tag,
10156
+ aborted: check.aborted
10157
+ } : {
10158
+ _tag: check._tag,
10159
+ checks: map6(check.checks, fromCheck)
10160
+ },
10161
+ ...fromAnnotations(check.annotations, true)
10162
+ };
10163
+ }
10164
+ function fromAnnotations(annotations, projectSchemas = false) {
10165
+ if (annotations === undefined)
10166
+ return;
10167
+ const {
10168
+ representation,
10169
+ ...ordinary
10170
+ } = annotations;
10171
+ const projected = projectSchemas && representation?.schemas !== undefined ? {
10172
+ ...representation,
10173
+ schemas: representation.schemas.map((schema) => recur(toType2(schema)))
10174
+ } : representation;
10175
+ return {
10176
+ ...projected === undefined ? undefined : {
10177
+ representation: projected
10178
+ },
10179
+ ...Object.keys(ordinary).length === 0 ? undefined : {
10180
+ annotations: ordinary
10181
+ }
10182
+ };
10183
+ }
10184
+ }
10185
+
8858
10186
  // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/internal/schema/toEquivalence.js
8859
10187
  var toEquivalence2 = /* @__PURE__ */ memoize((ast) => {
8860
10188
  return recur(ast);
@@ -8890,7 +10218,7 @@ function recur(ast) {
8890
10218
  const rest = ast.rest.map(recur);
8891
10219
  const [head, ...tail] = rest;
8892
10220
  const tailLength = tail.length;
8893
- return make13((a, b) => {
10221
+ return make14((a, b) => {
8894
10222
  if (!Array.isArray(a) || !Array.isArray(b)) {
8895
10223
  return false;
8896
10224
  }
@@ -8925,7 +10253,7 @@ function recur(ast) {
8925
10253
  }
8926
10254
  const propertySignatures = ast.propertySignatures.map((ps) => recur(ps.type));
8927
10255
  const indexSignatures = ast.indexSignatures.map((is) => recur(is.type));
8928
- return make13((a, b) => {
10256
+ return make14((a, b) => {
8929
10257
  if (!isObject(a) || !isObject(b)) {
8930
10258
  return false;
8931
10259
  }
@@ -8963,7 +10291,7 @@ function recur(ast) {
8963
10291
  const types = toType2(ast).types;
8964
10292
  const index = getCandidateIndex(types);
8965
10293
  const compiled = types.map((candidate, i) => [_is(candidate), recur(ast.types[i])]);
8966
- return make13((a, b) => {
10294
+ return make14((a, b) => {
8967
10295
  const candidates = index(a, false);
8968
10296
  for (let i = 0;i < candidates.length; i++) {
8969
10297
  const [is, equivalence] = compiled[candidates[i]];
@@ -8976,7 +10304,7 @@ function recur(ast) {
8976
10304
  }
8977
10305
  case "Suspend": {
8978
10306
  let equivalence;
8979
- return make13((a, b) => (equivalence ??= toEquivalence2(ast.thunk()))(a, b));
10307
+ return make14((a, b) => (equivalence ??= toEquivalence2(ast.thunk()))(a, b));
8980
10308
  }
8981
10309
  }
8982
10310
  }
@@ -9047,7 +10375,7 @@ var omit = /* @__PURE__ */ dual(2, (self, keys) => {
9047
10375
  return buildStruct(self, (k, v) => !hasPropertyKey(keys, k) ? [k, v] : undefined);
9048
10376
  });
9049
10377
  var lambda = (f) => f;
9050
- var map9 = /* @__PURE__ */ dual(2, (self, lambda) => {
10378
+ var map10 = /* @__PURE__ */ dual(2, (self, lambda) => {
9051
10379
  return buildStruct(self, (k, v) => [k, lambda(v)]);
9052
10380
  });
9053
10381
  function hasPropertyKey(keys, key) {
@@ -9077,7 +10405,7 @@ function isSchemaError(u) {
9077
10405
  var TypeId12 = TypeId11;
9078
10406
  function declareConstructor() {
9079
10407
  return (typeParameters, run, annotations) => {
9080
- return make16(new Declaration(typeParameters.map(getAST), (typeParameters) => run(typeParameters.map((ast) => make16(ast))), annotations));
10408
+ return make17(new Declaration(typeParameters.map(getAST), (typeParameters) => run(typeParameters.map((ast) => make17(ast))), annotations));
9081
10409
  };
9082
10410
  }
9083
10411
  function declare(is, annotations) {
@@ -9171,61 +10499,61 @@ function decodeUnknownSync(schema, options) {
9171
10499
  };
9172
10500
  }
9173
10501
  var decodeSync = decodeUnknownSync;
9174
- function encodeUnknownEffect2(schema, options) {
9175
- const parser = encodeUnknownEffect(schema, options);
10502
+ function encodeUnknownEffect(schema, options) {
10503
+ const parser = encodeUnknownEffect2(schema, options);
9176
10504
  return (input, options) => {
9177
10505
  return fromIssueEffect(parser(input, options));
9178
10506
  };
9179
10507
  }
9180
- var encodeEffect = encodeUnknownEffect2;
10508
+ var encodeEffect = encodeUnknownEffect;
9181
10509
  function encodeUnknownSync(schema, options) {
9182
- const parser = encodeUnknownEffect2(schema, options);
10510
+ const parser = encodeUnknownEffect(schema, options);
9183
10511
  return (input, options) => {
9184
10512
  return runSchemaErrorSync(parser(input, options));
9185
10513
  };
9186
10514
  }
9187
10515
  var encodeSync = encodeUnknownSync;
9188
- var make16 = make5;
10516
+ var make17 = make5;
9189
10517
  function isSchema(u) {
9190
10518
  return hasProperty(u, TypeId12) && u[TypeId12] === TypeId12;
9191
10519
  }
9192
- var optionalKey = /* @__PURE__ */ lambda((schema) => make16(optionalKey2(schema.ast), {
10520
+ var optionalKey = /* @__PURE__ */ lambda((schema) => make17(optionalKey2(schema.ast), {
9193
10521
  schema
9194
10522
  }));
9195
10523
  var optional = /* @__PURE__ */ lambda((self) => {
9196
10524
  const schema = UndefinedOr(self);
9197
- return make16(optional2(self.ast), {
10525
+ return make17(optional2(self.ast), {
9198
10526
  schema
9199
10527
  });
9200
10528
  });
9201
- var toType = /* @__PURE__ */ lambda((schema) => make16(toType2(schema.ast), {
10529
+ var toType = /* @__PURE__ */ lambda((schema) => make17(toType2(schema.ast), {
9202
10530
  schema
9203
10531
  }));
9204
- var toEncoded2 = /* @__PURE__ */ lambda((schema) => make16(toEncoded(schema.ast), {
10532
+ var toEncoded2 = /* @__PURE__ */ lambda((schema) => make17(toEncoded(schema.ast), {
9205
10533
  schema
9206
10534
  }));
9207
10535
  function Literal(literal) {
9208
- const out = make16(new Literal2(literal), {
10536
+ const out = make17(new Literal2(literal), {
9209
10537
  literal,
9210
10538
  transform(to) {
9211
10539
  return out.pipe(decodeTo2(Literal(to), {
9212
- decode: transform2(() => to),
9213
- encode: transform2(() => literal)
10540
+ decode: transform(() => to),
10541
+ encode: transform(() => literal)
9214
10542
  }));
9215
10543
  }
9216
10544
  });
9217
10545
  return out;
9218
10546
  }
9219
- var Never = /* @__PURE__ */ make16(never3);
9220
- var Unknown = /* @__PURE__ */ make16(unknown);
9221
- var Null = /* @__PURE__ */ make16(null_);
9222
- var Undefined2 = /* @__PURE__ */ make16(undefined_3);
9223
- var String4 = /* @__PURE__ */ make16(string2);
9224
- var Number5 = /* @__PURE__ */ make16(number2);
9225
- var Boolean2 = /* @__PURE__ */ make16(boolean);
9226
- var Void = /* @__PURE__ */ make16(void_4);
10547
+ var Never = /* @__PURE__ */ make17(never3);
10548
+ var Unknown = /* @__PURE__ */ make17(unknown);
10549
+ var Null = /* @__PURE__ */ make17(null_);
10550
+ var Undefined2 = /* @__PURE__ */ make17(undefined_3);
10551
+ var String4 = /* @__PURE__ */ make17(string2);
10552
+ var Number5 = /* @__PURE__ */ make17(number2);
10553
+ var Boolean2 = /* @__PURE__ */ make17(boolean);
10554
+ var Void = /* @__PURE__ */ make17(void_4);
9227
10555
  function makeStruct(ast, fields) {
9228
- return make16(ast, {
10556
+ return make17(ast, {
9229
10557
  fields,
9230
10558
  mapFields(f, options) {
9231
10559
  const fields = f(this.fields);
@@ -9237,25 +10565,37 @@ function Struct(fields) {
9237
10565
  return makeStruct(struct(fields, undefined), fields);
9238
10566
  }
9239
10567
  function Record(key, value) {
9240
- return make16(record(key.ast, value.ast), {
10568
+ return make17(record(key.ast, value.ast), {
9241
10569
  key,
9242
10570
  value
9243
10571
  });
9244
10572
  }
9245
10573
  function StructWithRest(schema, records) {
9246
- return make16(structWithRest(schema.ast, records.map(getAST)), {
10574
+ return make17(structWithRest(schema.ast, records.map(getAST)), {
9247
10575
  schema,
9248
10576
  records
9249
10577
  });
9250
10578
  }
9251
- var ArraySchema = /* @__PURE__ */ lambda((schema) => make16(new Arrays(false, [], [schema.ast]), {
10579
+ function makeTuple(ast, elements) {
10580
+ return make17(ast, {
10581
+ elements,
10582
+ mapElements(f, options) {
10583
+ const elements = f(this.elements);
10584
+ return makeTuple(tuple(elements, options?.unsafePreserveChecks ? this.ast.checks : undefined), elements);
10585
+ }
10586
+ });
10587
+ }
10588
+ function Tuple2(elements) {
10589
+ return makeTuple(tuple(elements), elements);
10590
+ }
10591
+ var ArraySchema = /* @__PURE__ */ lambda((schema) => make17(new Arrays(false, [], [schema.ast]), {
9252
10592
  value: schema
9253
10593
  }));
9254
- var NonEmptyArray = /* @__PURE__ */ lambda((schema) => make16(new Arrays(false, [schema.ast], [schema.ast]), {
10594
+ var NonEmptyArray = /* @__PURE__ */ lambda((schema) => make17(new Arrays(false, [schema.ast], [schema.ast]), {
9255
10595
  value: schema
9256
10596
  }));
9257
10597
  function makeUnion(ast, members) {
9258
- return make16(ast, {
10598
+ return make17(ast, {
9259
10599
  members,
9260
10600
  mapMembers(f, options) {
9261
10601
  const members = f(this.members);
@@ -9268,7 +10608,7 @@ function Union(members, options) {
9268
10608
  }
9269
10609
  function Literals(literals) {
9270
10610
  const members = literals.map(Literal);
9271
- return make16(union(members, undefined, undefined), {
10611
+ return make17(union(members, undefined, undefined), {
9272
10612
  literals,
9273
10613
  members,
9274
10614
  mapMembers(f) {
@@ -9285,18 +10625,18 @@ function Literals(literals) {
9285
10625
  var NullOr = /* @__PURE__ */ lambda((self) => Union([self, Null]));
9286
10626
  var UndefinedOr = /* @__PURE__ */ lambda((self) => Union([self, Undefined2]));
9287
10627
  function suspend4(f) {
9288
- return make16(new Suspend(() => f().ast));
10628
+ return make17(new Suspend(() => f().ast));
9289
10629
  }
9290
10630
  function decodeTo2(to, transformation) {
9291
10631
  return (from) => {
9292
- return make16(decodeTo(from.ast, to.ast, transformation ? makeTransformation(transformation) : passthrough3()), {
10632
+ return make17(decodeTo(from.ast, to.ast, transformation ? makeTransformation(transformation) : passthrough3()), {
9293
10633
  from,
9294
10634
  to
9295
10635
  });
9296
10636
  };
9297
10637
  }
9298
10638
  function withConstructorDefault2(defaultValue) {
9299
- return (schema) => make16(withConstructorDefault(schema.ast, defaultValue), {
10639
+ return (schema) => make17(withConstructorDefault(schema.ast, defaultValue), {
9300
10640
  schema
9301
10641
  });
9302
10642
  }
@@ -9372,7 +10712,7 @@ function isBase64(annotations) {
9372
10712
  ...annotations
9373
10713
  });
9374
10714
  }
9375
- var Finite = /* @__PURE__ */ make16(finite);
10715
+ var Finite = /* @__PURE__ */ make17(finite);
9376
10716
  function makeIsGreaterThan(options) {
9377
10717
  const gt = isGreaterThan2(options.order);
9378
10718
  const formatter = options.formatter ?? format;
@@ -9736,7 +11076,7 @@ function Defect(options) {
9736
11076
  defectSchemaCache[key] = schema;
9737
11077
  return schema;
9738
11078
  }
9739
- var RegExp2 = /* @__PURE__ */ instanceOf(globalThis.RegExp, {
11079
+ var RegExp3 = /* @__PURE__ */ instanceOf(globalThis.RegExp, {
9740
11080
  representation: {
9741
11081
  id: "effect/schema/RegExp",
9742
11082
  payload: null
@@ -9854,7 +11194,7 @@ var URLSearchParams2 = /* @__PURE__ */ instanceOf(globalThis.URLSearchParams, {
9854
11194
  expected: "URLSearchParams",
9855
11195
  toCodecJson: () => link()(String4.annotate({
9856
11196
  expected: "a query string that will be decoded as URLSearchParams"
9857
- }), transform({
11197
+ }), transform2({
9858
11198
  decode: (e) => new globalThis.URLSearchParams(e),
9859
11199
  encode: (params) => params.toString()
9860
11200
  }))
@@ -9920,7 +11260,7 @@ function CauseReason(error, defect) {
9920
11260
  }), Struct({
9921
11261
  _tag: Literal("Interrupt"),
9922
11262
  fiberId: UndefinedOr(Finite)
9923
- })]), transform({
11263
+ })]), transform2({
9924
11264
  decode: (e) => {
9925
11265
  switch (e._tag) {
9926
11266
  case "Fail":
@@ -9952,7 +11292,7 @@ function CauseReason(error, defect) {
9952
11292
  }
9953
11293
  }))
9954
11294
  });
9955
- return make16(schema.ast, {
11295
+ return make17(schema.ast, {
9956
11296
  error,
9957
11297
  defect
9958
11298
  });
@@ -9982,14 +11322,14 @@ function Cause(error, defect) {
9982
11322
  importDeclarations: [`import * as Cause from "effect/Cause"`]
9983
11323
  }),
9984
11324
  expected: "Cause",
9985
- toCodec: ([error, defect]) => link()(ArraySchema(CauseReason(error, defect)), transform({
11325
+ toCodec: ([error, defect]) => link()(ArraySchema(CauseReason(error, defect)), transform2({
9986
11326
  decode: fromReasons,
9987
11327
  encode: ({
9988
11328
  reasons: failures
9989
11329
  }) => failures
9990
11330
  }))
9991
11331
  });
9992
- return make16(schema.ast, {
11332
+ return make17(schema.ast, {
9993
11333
  error,
9994
11334
  defect
9995
11335
  });
@@ -10039,7 +11379,7 @@ function Exit(value, error, defect) {
10039
11379
  }), Struct({
10040
11380
  _tag: Literal("Failure"),
10041
11381
  cause: Cause(error, defect)
10042
- })]), transform({
11382
+ })]), transform2({
10043
11383
  decode: (e) => e._tag === "Success" ? succeed3(e.value) : failCause2(e.cause),
10044
11384
  encode: (exit) => isSuccess2(exit) ? {
10045
11385
  _tag: "Success",
@@ -10050,7 +11390,7 @@ function Exit(value, error, defect) {
10050
11390
  }
10051
11391
  }))
10052
11392
  });
10053
- return make16(schema.ast, {
11393
+ return make17(schema.ast, {
10054
11394
  value,
10055
11395
  error,
10056
11396
  defect
@@ -10140,7 +11480,7 @@ function makeClassTrusted(self, fields) {
10140
11480
  });
10141
11481
  }
10142
11482
  function getClassTransformation(self) {
10143
- return new Transformation(transform2((input) => makeClassTrusted(self, input)), passthrough());
11483
+ return new Transformation(transform((input) => makeClassTrusted(self, input)), passthrough());
10144
11484
  }
10145
11485
  function getClassTypeId(identifier) {
10146
11486
  return `~effect/Schema/Class/${identifier}`;
@@ -10154,7 +11494,7 @@ function getClassSchemaFactory(from, identifier, annotations) {
10154
11494
  const ClassTypeId = getClassTypeId(identifier);
10155
11495
  const isClassValue = (input) => input instanceof self || hasProperty(input, ClassTypeId);
10156
11496
  const transformation = getClassTransformation(self);
10157
- const to = make16(new Declaration([from.ast], () => (input, ast, options) => {
11497
+ const to = make17(new Declaration([from.ast], () => (input, ast, options) => {
10158
11498
  return isClassValue(input) ? succeed6(input) : fail7(new InvalidType(ast, input, options));
10159
11499
  }, {
10160
11500
  identifier,
@@ -10184,6 +11524,17 @@ var Class2 = (identifier) => (schema, annotations) => {
10184
11524
  }
10185
11525
  }));
10186
11526
  };
11527
+ var TaggedClass2 = (identifier) => {
11528
+ return (tagValue, schema, annotations) => {
11529
+ const struct = isStruct(schema) ? schema.mapFields((fields) => ({
11530
+ _tag: tag(tagValue),
11531
+ ...fields
11532
+ }), {
11533
+ unsafePreserveChecks: true
11534
+ }) : TaggedStruct(tagValue, schema);
11535
+ return Class2(identifier ?? tagValue)(struct, annotations);
11536
+ };
11537
+ };
10187
11538
  var Error3 = (identifier) => (schema, annotations) => {
10188
11539
  const struct = isStruct(schema) ? schema : Struct(schema);
10189
11540
  const self = makeClass(Error4, identifier, struct, annotations, (identifier) => ({
@@ -10205,9 +11556,13 @@ var TaggedError2 = (identifier) => {
10205
11556
  function toEquivalence(schema) {
10206
11557
  return toEquivalence2(schema.ast);
10207
11558
  }
11559
+ function toJsonSchemaDocument(schema, options) {
11560
+ const document = toRepresentation(toCodecJsonAST(schema.ast), options);
11561
+ return toJsonSchemaDocument2(document, options);
11562
+ }
10208
11563
  var toCodecJson = toCodecJson2;
10209
11564
  var toCodecStringTree = toCodecStringTree2;
10210
- var Json = /* @__PURE__ */ make16(/* @__PURE__ */ annotate(Json2, {
11565
+ var Json = /* @__PURE__ */ make17(/* @__PURE__ */ annotate(Json2, {
10211
11566
  toCode: () => ({
10212
11567
  runtime: "Schema.Json",
10213
11568
  Type: "Schema.Json"
@@ -10354,4 +11709,4 @@ var encodeUnknownJsonStringSync = encodeSync(fromJsonString(Unknown));
10354
11709
  var storableText = (text) => text.replaceAll("\x00", "").replaceAll(/\p{Cs}/gu, "");
10355
11710
  var storable = (value) => isString2(value) ? storableText(value) : Array.isArray(value) ? value.map(storable) : isJsonObject(value) ? Object.fromEntries(Object.entries(value).map(([key, field]) => [storableText(key), storable(field)])) : value;
10356
11711
 
10357
- export { pipeArguments, dual, identity, constant, constTrue, constFalse, constVoid, pipe, flow, memoize, isString, isNumber, isBoolean, isFunction, isUndefined, isNotUndefined, isNotNull, isNullish, isObject, hasProperty, isTagged, isUint8Array, symbol, hash, combine, number, string, structure, array, symbol2, equals, asEquivalence, symbolRedactable, redact, currentFiberTypeId, format, NodeInspectSymbol, toJson, BaseProto, Class, getStackTraceLimit, setStackTraceLimit, assignProperty, args, evaluate, PipeInspectableProto, isExit, causeFail, makePrimitive, exitSucceed, exitFailCause, exitFail, withFiber, Done, Prototype, make13, strictEqual, Tuple, String3, Number2, mapInput, none, some, isNone, isSome, match, getOrElse, orElse, fromNullishOr, fromUndefinedOr, getOrUndefined, liftThrowable, map4, flatMap, toArray, filter2, exists, Service2, makeUnsafe4, empty3, make14, add, getOrUndefined2, getOrUndefinedUnsafe, getUnsafe, get3, merge3, Reference, fromInputUnsafe, isFinite, zero, infinity, millis, seconds, minutes, toMillis, toMinutes, min, max, subtract, format2, normalize, succeed, fail3, try_, isResult, isFailure, isSuccess, map5, getOrElse2, getOrThrow, all2, allocate, fromIterable, isArrayNonEmpty, isReadonlyArrayNonEmpty, isCanonicalArrayIndex, getUnsafe2, sort, of, map6, makeEquivalence2, TaggedClass, Error2, TaggedError, encode, DisablePropagation, getCurrentFiber, fiberJoin, fiberInterrupt, succeed2, sync, suspend2, succeedNone, void_, callback2, asSome, andThen, flatMap2, map7, exitInterrupt, exitVoid, exitZipRight, scopeAddFinalizer, scope, onExitPrimitive, onExitUnsafe, uninterruptibleMask, fiberRunIn, makeLatchUnsafe, makeLatch, ClockRef, currentTimeMillis2, ConsoleRef, succeed3, failCause2, fail4, die, interrupt2, void_2, isSuccess2, isFailure2, hasInterrupts, asVoidAll, makeUnsafe5, make15, _await, fail5, interruptWith, isDone, isDoneUnsafe, succeed4, doneUnsafe, TracerTimingEnabled, Scope, makeUnsafe6, provide, addFinalizerExit, addFinalizer, forkUnsafe, close, build, buildWithScope, succeed5, effect, effectContext, effectDiscard, mergeAll, provide2, provideMerge, isCause, isFailReason, isDieReason, fromReasons, fail6, die2, makeFailReason, makeDieReason, hasInterruptsOnly, squash, findError, findErrorOption, hasInterrupts2, interruptors, pretty, isDone2, Done2, done, IllegalArgumentError, UnknownError, reasonAnnotations, Random, catchDone, isDoneCause, filterDone, doneExitFromCause, matchEffect, max2, during, min2, exponential, jittered, spaced, isEffect, all3, findFirst, forEach, whileLoop, promise, tryPromise, succeed6, suspend3, sync2, void_3, undefined_, callback3, never, gen, fail7, failSync, failCause3, die3, try_2, yieldNow, withFiber2, fromResult, fromNullishOr2, flatMap3, flatten, andThen2, tap2, result, option2, exit, map8, as, asSome2, asVoid, zipWith, catch_, catchTag, catchTags, catchReason, catchCause2, catchDefect, catchIf, catchCauseIf, mapError2, orDie, tapError2, tapCause, retry, retryOrElse, ignore, ignoreCause, orElseSucceed, timeout, timeoutOption, timeoutOrElse, delay, sleep, raceAllFirst, raceFirst, filter3, filterOrFail, when, matchCauseEffect, matchEffect2, context, contextWith, provide3, provideContext2, service, serviceOption, updateContext, updateService, provideService, scope2, scoped, scopedWith, acquireRelease, acquireUseRelease, addFinalizer2, ensuring2, onError, onExitPrimitive2, onExit, cached, interrupt3, interruptible, onInterrupt, uninterruptible, uninterruptibleMask2, forever, repeat, annotateCurrentSpan, makeSpanScoped, useSpan, withSpan, withParentSpan, forkChild, forkIn, forkScoped, forkDetach, runFork, runForkWith, runPromise, runPromiseWith, runSync, runSyncExitWith, fnUntraced, fn, clockWith, logWarning, logError, logInfo, annotateLogs, effectify, mapEager, flatMapEager, catchEager, encode2, decode, Pointer, makeFormatterStandardSchemaV1, passthrough, transformEffect, Transformation, transform, defaultParseOptions, unknown, getIndexSignatureKeys, applyToSelfOrLastLinkEncoding, decodeTo, toEncoded, decodeUnknownEffect, omit, map9, declare, SchemaError, is, decodeUnknownEffect2, decodeEffect, decodeUnknownExit, decodeUnknownOption, decodeOption, decodeSync, encodeEffect, make16, isSchema, optionalKey, optional, toType, Literal, Never, Unknown, Null, String4, Boolean2, Void, Struct, Record, StructWithRest, ArraySchema, NonEmptyArray, Union, Literals, NullOr, UndefinedOr, suspend4, decodeTo2, withDecodingDefaultKey, tag, TaggedStruct, makeFilter, isPattern, Finite, isGreaterThan, isGreaterThanOrEqualTo, isLessThanOrEqualTo, isBetween, Int, isMinLength, isMaxLength, isMinProperties, isMaxProperties, isUnique, NonEmptyString, Defect, Date2, fromJsonString, FiniteFromString, Cause, Exit, Class2, Error3, TaggedError2, toEquivalence, toCodecJson, toCodecStringTree, Json, JsonObject, toJsonValue, isOneOf, isKeyOf, toJsonObject, isBigInt, isBoolean2, isFunction2, isNumber2, isObject2, isJsonObject, isString2, isSymbol, isUndefined2, kindOf, decodeJsonString, decodeJsonStringOption, encodeJsonStringSync, encodePrettyJsonString, decodeJsonStringSync, encodeUnknownJsonStringSync, storable };
11712
+ export { pipeArguments, dual, identity, constant, constTrue, constFalse, constVoid, pipe, flow, memoize, isString, isNumber, isBoolean, isFunction, isUndefined, isNotUndefined, isNotNull, isNullish, isObject, hasProperty, isTagged, isUint8Array, symbol, hash, combine, number, string, structure, array, symbol2, equals, asEquivalence, symbolRedactable, redact, currentFiberTypeId, format, NodeInspectSymbol, toJson, BaseProto, Class, getStackTraceLimit, setStackTraceLimit, assignProperty, args, evaluate, PipeInspectableProto, isExit, causeFail, makePrimitive, exitSucceed, exitFailCause, exitFail, withFiber, Done, Prototype, make14, strictEqual, Tuple, String3, Number2, mapInput, none, some, isNone, isSome, match, getOrElse, orElse, fromNullishOr, fromUndefinedOr, getOrUndefined, liftThrowable, map4, flatMap, toArray, filter2, exists, Service2, makeUnsafe4, empty3, make15, add, getOrUndefined2, getOrUndefinedUnsafe, getUnsafe, get4, merge3, Reference, fromInputUnsafe, isFinite, zero, infinity, millis, seconds, minutes, toMillis, toMinutes, min, max, subtract, format2, normalize, succeed, fail3, try_, isResult, isFailure, isSuccess, map5, getOrElse2, getOrThrow, all2, allocate, fromIterable, isArray, isArrayNonEmpty, isReadonlyArrayNonEmpty, isCanonicalArrayIndex, getUnsafe2, sort, chunksOf, empty4, of, map6, makeEquivalence2, TaggedClass, Error2, TaggedError, encode, DisablePropagation, getCurrentFiber, fiberJoin, fiberInterrupt, succeed2, sync, suspend2, succeedNone, void_, callback2, asSome, andThen, flatMap2, map7, exitInterrupt, exitVoid, exitZipRight, scopeAddFinalizer, scope, onExitPrimitive, onExitUnsafe, uninterruptibleMask, fiberRunIn, makeLatchUnsafe, makeLatch, ClockRef, currentTimeMillis2, ConsoleRef, succeed3, failCause2, fail4, die, interrupt2, void_2, isSuccess2, isFailure2, hasInterrupts, map8, asVoidAll, makeUnsafe5, make16, _await, fail5, interruptWith, isDone, isDoneUnsafe, succeed4, doneUnsafe, TracerTimingEnabled, Scope, makeUnsafe6, provide, addFinalizerExit, addFinalizer, forkUnsafe, close, build, buildWithScope, succeed5, effect, effectContext, effectDiscard, mergeAll, provide2, provideMerge, isCause, isFailReason, isDieReason, fromReasons, fail6, die2, makeFailReason, makeDieReason, hasInterruptsOnly, combine2, squash, findError, findErrorOption, hasInterrupts2, interruptors, pretty, isDone2, Done2, done, IllegalArgumentError, UnknownError, reasonAnnotations, Random, catchDone, isDoneCause, filterDone, doneExitFromCause, matchEffect, max2, during, min2, exponential, jittered, spaced, while_, setInputType, isEffect, all3, findFirst, forEach, whileLoop, promise, tryPromise, succeed6, suspend3, sync2, void_3, undefined_, callback3, never, gen, fail7, failSync, failCause3, die3, try_2, yieldNow, withFiber2, fromResult, fromNullishOr2, flatMap3, flatten, andThen2, tap2, result, option2, exit, map9, as, asSome2, asVoid, zipWith, catch_, catchTag, catchTags, catchReason, catchCause2, catchDefect, catchIf, catchCauseIf, mapError2, orDie, tapError2, tapCause, retry, retryOrElse, sandbox, ignore, ignoreCause, orElseSucceed, timeout, timeoutOption, timeoutOrElse, delay, sleep, raceAllFirst, raceFirst, filter3, filterOrFail, when, matchCauseEffect, matchEffect2, context, contextWith, provide3, provideContext2, service, serviceOption, updateContext, updateService, provideService, scope2, scoped, scopedWith, acquireRelease, acquireUseRelease, addFinalizer2, ensuring2, onError, onExitPrimitive2, onExit, cached, interrupt3, interruptible, onInterrupt, uninterruptible, uninterruptibleMask2, forever, repeat, annotateCurrentSpan, makeSpanScoped, useSpan, withSpan, withParentSpan, forkChild, forkIn, forkScoped, forkDetach, runFork, runForkWith, runPromise, runPromiseWith, runSync, runSyncExitWith, fnUntraced, fn, clockWith, logWarning, logError, logInfo, annotateLogs, effectify, mapEager, flatMapEager, catchEager, encode2, decode, encode3, Pointer, makeFormatterStandardSchemaV1, passthrough, transform, transformEffect, encodeBase64Url, decodeBase64UrlString, Transformation, transform2, defaultParseOptions, unknown, getIndexSignatureKeys, applyToSelfOrLastLinkEncoding, decodeTo, toEncoded, decodeUnknownEffect, omit, map10, declare, SchemaError, is, decodeUnknownEffect2, decodeEffect, decodeUnknownExit, decodeUnknownOption, decodeOption, decodeSync, encodeUnknownEffect, encodeEffect, encodeSync, make17, isSchema, optionalKey, optional, toType, Literal, Never, Unknown, Null, String4, Boolean2, Void, Struct, Record, StructWithRest, Tuple2, ArraySchema, NonEmptyArray, Union, Literals, NullOr, UndefinedOr, suspend4, decodeTo2, withDecodingDefaultKey, tag, TaggedStruct, link, makeFilter, isPattern, Finite, isGreaterThan, isGreaterThanOrEqualTo, isLessThanOrEqualTo, isBetween, Int, isMinLength, isMaxLength, isMinProperties, isMaxProperties, isUnique, NonEmptyString, Defect, Date2, fromJsonString, FiniteFromString, Cause, Exit, Class2, TaggedClass2, Error3, TaggedError2, toEquivalence, toJsonSchemaDocument, toCodecJson, toCodecStringTree, Json, JsonObject, toJsonValue, isOneOf, isKeyOf, toJsonObject, isBigInt, isBoolean2, isFunction2, isNumber2, isObject2, isJsonObject, isString2, isSymbol, isUndefined2, kindOf, decodeJsonString, decodeJsonStringOption, encodeJsonStringSync, encodePrettyJsonString, decodeJsonStringSync, encodeUnknownJsonStringSync, storable };