@r_masseater/masseater-utils 0.1.9 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Pipeable.js
1
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/Pipeable.js
2
2
  /**
3
3
  * The `Pipeable` module defines the shared interface and implementation helpers
4
4
  * for values that support Effect-style method chaining with `.pipe(...)`.
@@ -52,23 +52,9 @@
52
52
  * @since 2.0.0
53
53
  */
54
54
  const pipeArguments = (self, args) => {
55
- switch (args.length) {
56
- case 0: return self;
57
- case 1: return args[0](self);
58
- case 2: return args[1](args[0](self));
59
- case 3: return args[2](args[1](args[0](self)));
60
- case 4: return args[3](args[2](args[1](args[0](self))));
61
- case 5: return args[4](args[3](args[2](args[1](args[0](self)))));
62
- case 6: return args[5](args[4](args[3](args[2](args[1](args[0](self))))));
63
- case 7: return args[6](args[5](args[4](args[3](args[2](args[1](args[0](self)))))));
64
- case 8: return args[7](args[6](args[5](args[4](args[3](args[2](args[1](args[0](self))))))));
65
- case 9: return args[8](args[7](args[6](args[5](args[4](args[3](args[2](args[1](args[0](self)))))))));
66
- default: {
67
- let ret = self;
68
- for (let i = 0, len = args.length; i < len; i++) ret = args[i](ret);
69
- return ret;
70
- }
71
- }
55
+ let ret = self;
56
+ for (let i = 0; i < args.length; i++) ret = args[i](ret);
57
+ return ret;
72
58
  };
73
59
  /**
74
60
  * Reusable prototype that implements `Pipeable.pipe`.
@@ -103,7 +89,7 @@ const Class$1 = /*#__PURE__*/ function() {
103
89
  PipeableBase.prototype = Prototype$1;
104
90
  return PipeableBase;
105
91
  }();
106
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Function.js
92
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/Function.js
107
93
  /**
108
94
  * Creates a function that can be called in data-first style or data-last
109
95
  * (`pipe`-friendly) style.
@@ -169,9 +155,6 @@ const Class$1 = /*#__PURE__*/ function() {
169
155
  * @since 2.0.0
170
156
  */
171
157
  const dual = function(arity, body) {
172
- if (typeof arity === "function") return function() {
173
- return arity(arguments) ? body.apply(this, arguments) : (self) => body(self, ...arguments);
174
- };
175
158
  switch (arity) {
176
159
  case 0:
177
160
  case 1: throw new RangeError(`Invalid arity ${arity}`);
@@ -187,14 +170,12 @@ const dual = function(arity, body) {
187
170
  return body(self, a, b);
188
171
  };
189
172
  };
190
- default: return function() {
191
- if (arguments.length >= arity) return body.apply(this, arguments);
192
- const args = arguments;
193
- return function(self) {
194
- return body(self, ...args);
195
- };
196
- };
197
173
  }
174
+ return function() {
175
+ if (typeof arity === "function" ? arity(arguments) : arguments.length >= arity) return body.apply(this, arguments);
176
+ const args = Array.prototype.slice.call(arguments);
177
+ return (self) => body(self, ...args);
178
+ };
198
179
  };
199
180
  /**
200
181
  * Returns its input argument unchanged.
@@ -337,7 +318,7 @@ function memoizeIdempotent(f) {
337
318
  return result;
338
319
  };
339
320
  }
340
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/internal/equal.js
321
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/internal/equal.js
341
322
  const errorSiteKeys = [
342
323
  "line",
343
324
  "column",
@@ -412,7 +393,7 @@ const mix = (h) => {
412
393
  * @internal
413
394
  */
414
395
  const combine$1 = (self, b) => mix(Math.imul(self, 2654435761) + Math.imul(b, 2246822507));
415
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/internal/predicate.js
396
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/internal/predicate.js
416
397
  /**
417
398
  * Data-first `Predicate.hasProperty`.
418
399
  *
@@ -422,7 +403,7 @@ const combine$1 = (self, b) => mix(Math.imul(self, 2654435761) + Math.imul(b, 22
422
403
  * @internal
423
404
  */
424
405
  const hasProperty$1 = (self, property) => (typeof self === "object" && self !== null || typeof self === "function") && property in self;
425
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Hash.js
406
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/Hash.js
426
407
  /**
427
408
  * Computes Effect hash values and defines the interface for objects that want
428
409
  * to provide their own hash implementation. Hashes are small numeric
@@ -851,7 +832,7 @@ const hashMapEntry = ([k, v]) => combine$1(hash(k), hash(v));
851
832
  const hashSetElement = (element) => combine$1(setSeed, hash(element));
852
833
  const randomHashCache = /*#__PURE__*/ new WeakMap();
853
834
  const visitedObjects = /*#__PURE__*/ new WeakSet();
854
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Equal.js
835
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/Equal.js
855
836
  /**
856
837
  * Defines the unique string identifier for the `Equal` interface.
857
838
  *
@@ -1064,7 +1045,7 @@ const equalEntries = (self, that) => compareBoth(self[0], that[0]) && compareBot
1064
1045
  * @since 2.0.0
1065
1046
  */
1066
1047
  const isEqual = (u) => hasProperty$1(u, "~effect/Equal") && typeof u["~effect/Equal"] === "function";
1067
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/internal/record.js
1048
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/internal/record.js
1068
1049
  /**
1069
1050
  * Lists own enumerable string and symbol keys without reading property values.
1070
1051
  * Use this when discovering struct fields; explicitly selected fields are read
@@ -1095,7 +1076,7 @@ function assignProperties(self, source) {
1095
1076
  }
1096
1077
  for (const key of ownEnumerableKeys(source)) assignProperty(self, key, source[key]);
1097
1078
  }
1098
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Predicate.js
1079
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/Predicate.js
1099
1080
  /**
1100
1081
  * Defines runtime checks for values.
1101
1082
  *
@@ -1419,7 +1400,7 @@ const hasProperty = /*#__PURE__*/ dual(2, hasProperty$1);
1419
1400
  * @since 2.0.0
1420
1401
  */
1421
1402
  const isTagged = /*#__PURE__*/ dual(2, (self, tag) => hasProperty(self, "_tag") && self["_tag"] === tag);
1422
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Redactable.js
1403
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/Redactable.js
1423
1404
  /**
1424
1405
  * Defines the symbol used to identify objects that implement the {@link Redactable}
1425
1406
  * protocol.
@@ -1541,7 +1522,7 @@ const emptyContext$1 = {
1541
1522
  return pipeArguments(this, arguments);
1542
1523
  }
1543
1524
  };
1544
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Formatter.js
1525
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/Formatter.js
1545
1526
  /**
1546
1527
  * Formats JavaScript values into readable strings.
1547
1528
  *
@@ -1719,7 +1700,7 @@ function safeGet(input, key) {
1719
1700
  return "[property access threw]";
1720
1701
  }
1721
1702
  }
1722
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Inspectable.js
1703
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/Inspectable.js
1723
1704
  /**
1724
1705
  * Controls how values appear in logs and debugging output.
1725
1706
  *
@@ -1847,7 +1828,7 @@ const BaseProto = {
1847
1828
  return format$1(this.toJSON());
1848
1829
  }
1849
1830
  };
1850
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/internal/stackTraceLimit.js
1831
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/internal/stackTraceLimit.js
1851
1832
  /**
1852
1833
  * Check if `Error.stackTraceLimit` is writable.
1853
1834
  * Returns `false` if the property is frozen, non-writable, or `Error` is non-extensible.
@@ -1878,7 +1859,7 @@ const getStackTraceLimit = () => Error.stackTraceLimit;
1878
1859
  const setStackTraceLimit = (value) => {
1879
1860
  if (canWriteStackTraceLimit) Error.stackTraceLimit = value;
1880
1861
  };
1881
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Utils.js
1862
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/Utils.js
1882
1863
  /**
1883
1864
  * Yields its wrapped value exactly once, then completes with the value sent
1884
1865
  * back in.
@@ -1960,7 +1941,7 @@ const pickInternalCall = () => {
1960
1941
  };
1961
1942
  /** @internal */
1962
1943
  const internalCall = /*#__PURE__*/ pickInternalCall();
1963
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/internal/core.js
1944
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/internal/core.js
1964
1945
  /** @internal */
1965
1946
  const EffectTypeId = `~effect/Effect`;
1966
1947
  /** @internal */
@@ -2123,8 +2104,8 @@ const dedupeReasons = (self, that) => {
2123
2104
  const causeCombine = /*#__PURE__*/ dual(2, (self, that) => {
2124
2105
  if (self.reasons.length === 0) return that;
2125
2106
  else if (that.reasons.length === 0) return self;
2126
- const newCause = new CauseImpl(dedupeReasons(self.reasons, that.reasons));
2127
- return equals$1(self, newCause) ? self : newCause;
2107
+ const reasons = dedupeReasons(self.reasons, that.reasons);
2108
+ return reasons.length === self.reasons.length && reasons.every((reason, i) => reason === self.reasons[i]) ? self : new CauseImpl(reasons);
2128
2109
  });
2129
2110
  /**
2130
2111
  * Appends the interrupts from `interrupts` that `self` does not contain yet.
@@ -2166,21 +2147,14 @@ var Die = class extends ReasonBase {
2166
2147
  /** @internal */
2167
2148
  const causeDie = (defect) => new CauseImpl([new Die(defect)]);
2168
2149
  /**
2169
- * Context.ts imports this module, so it registers `makeUnsafe` here instead.
2170
- *
2171
- * @internal
2172
- */
2173
- const contextMaker = {};
2174
- /**
2175
2150
  * Data-first `causeAnnotate` taking a plain annotation map, so the fiber
2176
2151
  * runtime does not pull in `Function.dual` or wrap maps in a `Context`.
2177
- * Only reasons with their own `annotate` method receive a `Context`.
2178
2152
  *
2179
2153
  * @internal
2180
2154
  */
2181
- const causeAnnotateMap = (self, annotations, options, context) => {
2155
+ const causeAnnotateMap = (self, annotations, options) => {
2182
2156
  if (annotations.size === 0) return self;
2183
- return new CauseImpl(self.reasons.map((f) => f.annotate === ReasonBase.prototype.annotate ? annotateReasonMap(f, annotations, options) : f.annotate(context ?? contextMaker.makeUnsafe(annotations), options)));
2157
+ return new CauseImpl(self.reasons.map((f) => annotateReasonMap(f, annotations, options)));
2184
2158
  };
2185
2159
  /** @internal */
2186
2160
  const isFailReason$1 = (self) => self._tag === "Fail";
@@ -2268,6 +2242,10 @@ const exitSucceed = /*#__PURE__*/ makeExit({
2268
2242
  const StackTraceKey = "effect/Cause/StackTrace";
2269
2243
  /** @internal */
2270
2244
  const InterruptorStackTrace = { key: "effect/Cause/InterruptorStackTrace" };
2245
+ const needsStackFrame = (cause) => {
2246
+ for (let i = 0; i < cause.reasons.length; i++) if (!cause.reasons[i].annotations.has("effect/Cause/StackTrace")) return true;
2247
+ return false;
2248
+ };
2271
2249
  /** @internal */
2272
2250
  const exitFailCause = /*#__PURE__*/ makeExit({
2273
2251
  op: "Failure",
@@ -2275,7 +2253,7 @@ const exitFailCause = /*#__PURE__*/ makeExit({
2275
2253
  [evaluate](fiber) {
2276
2254
  let cause = this[args];
2277
2255
  let annotated = false;
2278
- if (fiber.cache.stackFrame) {
2256
+ if (fiber.cache.stackFrame && needsStackFrame(cause)) {
2279
2257
  cause = causeAnnotateMap(cause, /* @__PURE__ */ new Map([[StackTraceKey, fiber.cache.stackFrame]]));
2280
2258
  annotated = true;
2281
2259
  }
@@ -2352,7 +2330,7 @@ const TaggedError$2 = (tag) => {
2352
2330
  const DoneTypeId = "~effect/Cause/Done";
2353
2331
  /** @internal */
2354
2332
  const isDone = (u) => hasProperty$1(u, DoneTypeId);
2355
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Effectable.js
2333
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/Effectable.js
2356
2334
  /**
2357
2335
  * Create a low-level `Effect` prototype.
2358
2336
  *
@@ -2377,7 +2355,7 @@ const Prototype = (options) => makePrimitiveProto({
2377
2355
  op: options.label,
2378
2356
  [evaluate]: options.evaluate
2379
2357
  });
2380
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/internal/fiberCachedKeys.js
2358
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/internal/fiberCachedKeys.js
2381
2359
  /**
2382
2360
  * Reading cached services by key lets bundlers drop unused service constructors.
2383
2361
  */
@@ -2401,6 +2379,8 @@ const CurrentLogLevelKey = "effect/References/CurrentLogLevel";
2401
2379
  const MinimumLogLevelKey = "effect/References/MinimumLogLevel";
2402
2380
  /** @internal */
2403
2381
  const FiberRuntimeMetricsKey = "effect/Metric/FiberRuntimeMetrics";
2382
+ /** @internal */
2383
+ const SupervisorKey = "effect/Supervisor";
2404
2384
  /**
2405
2385
  * Pre-register runtime keys so cache invalidation survives tree-shaking of
2406
2386
  * their service constructors. `fiberCached: true` registers additional keys.
@@ -2416,10 +2396,11 @@ const fiberCachedKeys = /*#__PURE__*/ new Set([
2416
2396
  MinimumLogLevelKey,
2417
2397
  CurrentStackFrameKey,
2418
2398
  FiberRuntimeMetricsKey,
2399
+ SupervisorKey,
2419
2400
  MaxOpsBeforeYieldKey,
2420
2401
  PreventSchedulerYieldKey
2421
2402
  ]);
2422
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/internal/option.js
2403
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/internal/option.js
2423
2404
  /**
2424
2405
  * @since 2.0.0
2425
2406
  */
@@ -2489,7 +2470,7 @@ const SomeImpl = function(value) {
2489
2470
  SomeImpl.prototype = SomeProto;
2490
2471
  /** @internal */
2491
2472
  const some$1 = (value) => new SomeImpl(value);
2492
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/internal/result.js
2473
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/internal/result.js
2493
2474
  const TypeId$16 = "~effect/Result";
2494
2475
  const CommonProto = {
2495
2476
  [TypeId$16]: {
@@ -2562,7 +2543,7 @@ const SuccessImpl = function(success) {
2562
2543
  SuccessImpl.prototype = SuccessProto;
2563
2544
  /** @internal */
2564
2545
  const succeed$5 = (success) => new SuccessImpl(success);
2565
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Order.js
2546
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/Order.js
2566
2547
  /**
2567
2548
  * Defines comparison functions for ordered values.
2568
2549
  *
@@ -2612,7 +2593,7 @@ const succeed$5 = (success) => new SuccessImpl(success);
2612
2593
  * @category constructors
2613
2594
  * @since 2.0.0
2614
2595
  */
2615
- function make$12(compare) {
2596
+ function make$13(compare) {
2616
2597
  return (self, that) => self === that ? 0 : compare(self, that);
2617
2598
  }
2618
2599
  /**
@@ -2643,8 +2624,8 @@ function make$12(compare) {
2643
2624
  * @category instances
2644
2625
  * @since 4.0.0
2645
2626
  */
2646
- const String$5 = /*#__PURE__*/ make$12((self, that) => self < that ? -1 : 1);
2647
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Option.js
2627
+ const String$5 = /*#__PURE__*/ make$13((self, that) => self < that ? -1 : 1);
2628
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/Option.js
2648
2629
  /**
2649
2630
  * Creates an `Option` representing the absence of a value.
2650
2631
  *
@@ -2825,8 +2806,8 @@ const orElse = /*#__PURE__*/ dual(2, (self, that) => isNone(self) ? that() : sel
2825
2806
  * @category mapping
2826
2807
  * @since 2.0.0
2827
2808
  */
2828
- const map$7 = /*#__PURE__*/ dual(2, (self, f) => isNone(self) ? none() : some(f(self.value)));
2829
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Context.js
2809
+ const map$6 = /*#__PURE__*/ dual(2, (self, f) => isNone(self) ? none() : some(f(self.value)));
2810
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/Context.js
2830
2811
  /**
2831
2812
  * Runtime type identifier attached to `Context` service keys and used by
2832
2813
  * `isKey` to recognize them.
@@ -2919,7 +2900,7 @@ const ServiceProto = /*#__PURE__*/ Object.assign({ [ServiceTypeId]: ServiceTypeI
2919
2900
  return self;
2920
2901
  },
2921
2902
  context(self) {
2922
- return make$11(this, self);
2903
+ return make$12(this, self);
2923
2904
  },
2924
2905
  use(f) {
2925
2906
  return withFiber((fiber) => f(get(fiber.context, this)));
@@ -2933,7 +2914,7 @@ const TypeId$15 = "~effect/Context";
2933
2914
  const FlattenAfterBaseHits = 8;
2934
2915
  const makeFlat = (cacheRoot, base, maxDepth) => {
2935
2916
  const self = Object.create(Proto$7);
2936
- self.cacheRoot = cacheRoot ?? self;
2917
+ self.cacheRoot = cacheRoot ?? {};
2937
2918
  self.base = base;
2938
2919
  self.depth = 0;
2939
2920
  self.maxDepth = maxDepth;
@@ -2941,7 +2922,7 @@ const makeFlat = (cacheRoot, base, maxDepth) => {
2941
2922
  };
2942
2923
  const makeOverlay = (cacheRoot, base, overlay, depth, maxDepth) => {
2943
2924
  const self = Object.create(OverlayProto);
2944
- self.cacheRoot = cacheRoot ?? self;
2925
+ self.cacheRoot = cacheRoot ?? {};
2945
2926
  self.base = base;
2946
2927
  self.overlay = overlay;
2947
2928
  self.depth = depth;
@@ -2955,6 +2936,29 @@ const applyOverlays = (map, overlay) => {
2955
2936
  applyOverlays(map, overlay.parent);
2956
2937
  map.set(overlay.key, overlay.value);
2957
2938
  };
2939
+ const replaceOverlay = (overlay, key, value) => {
2940
+ let target = overlay;
2941
+ while (target !== void 0 && target.key !== key) target = target.parent;
2942
+ if (target === void 0) return void 0;
2943
+ const replaced = {
2944
+ key,
2945
+ value,
2946
+ parent: target.parent
2947
+ };
2948
+ let head;
2949
+ let tail;
2950
+ for (let node = overlay; node !== target; node = node.parent) {
2951
+ const copy = {
2952
+ key: node.key,
2953
+ value: node.value,
2954
+ parent: replaced
2955
+ };
2956
+ if (tail === void 0) head = copy;
2957
+ else tail.parent = copy;
2958
+ tail = copy;
2959
+ }
2960
+ return head ?? replaced;
2961
+ };
2958
2962
  const flatten = (self) => {
2959
2963
  if (self._flat) return self._flat;
2960
2964
  if (!self.overlay) return self._flat = self.base;
@@ -2962,6 +2966,11 @@ const flatten = (self) => {
2962
2966
  applyOverlays(map, self.overlay);
2963
2967
  return self._flat = map;
2964
2968
  };
2969
+ const copyMap = (self) => {
2970
+ const map = new Map(self._flat ?? self.base);
2971
+ if (!self._flat) applyOverlays(map, self.overlay);
2972
+ return map;
2973
+ };
2965
2974
  const notFound = /*#__PURE__*/ Symbol();
2966
2975
  const lookup = (self, key) => {
2967
2976
  const impl = self;
@@ -2990,10 +2999,11 @@ const overlayLookup = (self, key) => {
2990
2999
  *
2991
3000
  * **Details**
2992
3001
  *
2993
- * `options.maxDepth` sets how many `add` calls are kept as overlays before the
2994
- * context is rebased into a flat map (default `8`). Lower values make lookups
2995
- * cheaper, higher values make additions to a large base cheaper. Invalid
2996
- * values fall back to the default.
3002
+ * `options.maxDepth` sets how many distinct services `add` or `merge` keep as
3003
+ * overlays before the context is rebased into a flat map (default `8`).
3004
+ * Re-adding an overlaid service replaces it and does not count toward the
3005
+ * limit. Lower values make lookups cheaper, higher values make additions to a
3006
+ * large base cheaper. Invalid values fall back to the default.
2997
3007
  *
2998
3008
  * Contexts derived with `add`, `pick`, `omit`, and `merge` keep the setting
2999
3009
  * (`merge` from its first non-empty argument). `make`, `empty`, and `mergeAll`
@@ -3031,7 +3041,6 @@ const makeUnsafe$2 = (mapUnsafe, options) => {
3031
3041
  const maxDepth = options?.maxDepth;
3032
3042
  return makeFlat(void 0, mapUnsafe, Number.isInteger(maxDepth) && maxDepth >= 0 ? maxDepth : 8);
3033
3043
  };
3034
- contextMaker.makeUnsafe = (mapUnsafe) => makeFlat(void 0, mapUnsafe, 8);
3035
3044
  const Proto$7 = {
3036
3045
  get mapUnsafe() {
3037
3046
  return this.base;
@@ -3136,7 +3145,7 @@ const isReference = (u) => !!u[ReferenceTypeId];
3136
3145
  * @category constructors
3137
3146
  * @since 2.0.0
3138
3147
  */
3139
- const empty$1 = () => emptyContext;
3148
+ const empty$2 = () => emptyContext;
3140
3149
  const emptyContext = /*#__PURE__*/ makeUnsafe$2(/*#__PURE__*/ new Map());
3141
3150
  /**
3142
3151
  * Creates a new `Context` with a single service associated to the key.
@@ -3157,7 +3166,7 @@ const emptyContext = /*#__PURE__*/ makeUnsafe$2(/*#__PURE__*/ new Map());
3157
3166
  * @category constructors
3158
3167
  * @since 2.0.0
3159
3168
  */
3160
- const make$11 = (key, service) => makeUnsafe$2(/* @__PURE__ */ new Map([[key.key, service]]));
3169
+ const make$12 = (key, service) => makeUnsafe$2(/* @__PURE__ */ new Map([[key.key, service]]));
3161
3170
  /**
3162
3171
  * Adds a service by key to a given `Context` using a string key.
3163
3172
  *
@@ -3168,9 +3177,10 @@ const make$11 = (key, service) => makeUnsafe$2(/* @__PURE__ */ new Map([[key.key
3168
3177
  const addUnsafe = (self, key, service) => {
3169
3178
  const impl = self;
3170
3179
  const cacheRoot = fiberCachedKeys.has(key) ? void 0 : impl.cacheRoot;
3180
+ const overlay = replaceOverlay(impl.overlay, key, service);
3181
+ if (overlay !== void 0) return makeOverlay(cacheRoot, impl.base, overlay, impl.depth, impl.maxDepth);
3171
3182
  if (impl.depth >= impl.maxDepth) {
3172
- const map = new Map(impl._flat ?? impl.base);
3173
- if (!impl._flat) applyOverlays(map, impl.overlay);
3183
+ const map = copyMap(impl);
3174
3184
  map.set(key, service);
3175
3185
  return makeFlat(cacheRoot, map, impl.maxDepth);
3176
3186
  }
@@ -3238,8 +3248,10 @@ const getReferenceUnsafe = (self, ref) => {
3238
3248
  const value = lookup(self, ref.key);
3239
3249
  return value === notFound ? getDefaultValue(ref) : value;
3240
3250
  };
3251
+ const ServiceNotFoundErrorTypeId = "~effect/Context/ServiceNotFoundError";
3241
3252
  const serviceNotFoundError = (service) => {
3242
- const error = /* @__PURE__ */ new Error(`Service not found${service.key ? `: ${String(service.key)}` : ""}`);
3253
+ const error = Object.assign(/* @__PURE__ */ new Error(`Service not found${service.key ? `: ${service.key}` : ""}`), { key: service.key });
3254
+ Object.defineProperty(error, ServiceNotFoundErrorTypeId, { value: ServiceNotFoundErrorTypeId });
3243
3255
  if (error.stack) {
3244
3256
  const lines = error.stack.split("\n");
3245
3257
  lines.splice(1, 3);
@@ -3295,13 +3307,13 @@ const serviceNotFoundError = (service) => {
3295
3307
  * @since 3.11.0
3296
3308
  */
3297
3309
  const Reference = Service;
3298
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/internal/array.js
3310
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/internal/array.js
3299
3311
  /**
3300
3312
  * @since 2.0.0
3301
3313
  */
3302
3314
  /** @internal */
3303
3315
  const isArrayNonEmpty$1 = (self) => self.length > 0;
3304
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Result.js
3316
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/Result.js
3305
3317
  /**
3306
3318
  * Creates a `Result` holding a `Success` value.
3307
3319
  *
@@ -3450,7 +3462,7 @@ const isSuccess$1 = isSuccess$2;
3450
3462
  * @category mapping
3451
3463
  * @since 2.0.0
3452
3464
  */
3453
- const map$6 = /*#__PURE__*/ dual(2, (self, f) => isSuccess$1(self) ? succeed$4(f(self.success)) : self);
3465
+ const map$5 = /*#__PURE__*/ dual(2, (self, f) => isSuccess$1(self) ? succeed$4(f(self.success)) : self);
3454
3466
  /**
3455
3467
  * Folds a `Result` into a single value by applying one of two functions.
3456
3468
  *
@@ -3488,7 +3500,7 @@ const map$6 = /*#__PURE__*/ dual(2, (self, f) => isSuccess$1(self) ? succeed$4(f
3488
3500
  * @since 2.0.0
3489
3501
  */
3490
3502
  const match$1 = /*#__PURE__*/ dual(2, (self, { onFailure, onSuccess }) => isFailure(self) ? onFailure(self.failure) : onSuccess(self.success));
3491
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Array.js
3503
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/Array.js
3492
3504
  /**
3493
3505
  * Exposes the global array constructor.
3494
3506
  *
@@ -3625,7 +3637,7 @@ function isCanonicalArrayIndex(key) {
3625
3637
  * @category constructors
3626
3638
  * @since 2.0.0
3627
3639
  */
3628
- const empty = () => [];
3640
+ const empty$1 = () => [];
3629
3641
  /**
3630
3642
  * Transforms each element using a function, returning a new array.
3631
3643
  *
@@ -3671,7 +3683,7 @@ const map$4 = /*#__PURE__*/ dual(2, (self, f) => self.map(f));
3671
3683
  * @since 2.0.0
3672
3684
  */
3673
3685
  const join = /*#__PURE__*/ dual(2, (self, sep) => fromIterable$1(self).join(sep));
3674
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Duration.js
3686
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/Duration.js
3675
3687
  const TypeId$14 = "~effect/Duration";
3676
3688
  const bigint0$1 = /*#__PURE__*/ BigInt(0);
3677
3689
  const bigint1$1 = /*#__PURE__*/ BigInt(1);
@@ -3686,7 +3698,7 @@ const bigintNanosPerDay = /*#__PURE__*/ BigInt(864e11);
3686
3698
  const bigintNanosPerWeek = /*#__PURE__*/ BigInt(6048e11);
3687
3699
  const roundTiesAwayFromZero = (input) => BigInt(Math.sign(input) * Math.round(Math.abs(input)));
3688
3700
  const roundMillisToNanos = (millis) => Number.isInteger(millis) ? BigInt(millis) * bigint1e6 : roundTiesAwayFromZero(millis * 1e6);
3689
- const fromNanosNumber = (nanos) => make$10(Number.isFinite(nanos) ? roundTiesAwayFromZero(nanos) : nanos);
3701
+ const fromNanosNumber = (nanos) => make$11(Number.isFinite(nanos) ? roundTiesAwayFromZero(nanos) : nanos);
3690
3702
  const parseNanos = (input, scale) => {
3691
3703
  const decimalIndex = input.indexOf(".");
3692
3704
  if (decimalIndex === -1) return BigInt(input) * scale;
@@ -3703,9 +3715,9 @@ const divideTiesAwayFromZero = (numerator, denominator) => {
3703
3715
  };
3704
3716
  const fromMillisString = (input, scale) => {
3705
3717
  const millis = Number(input) * scale;
3706
- if (!Number.isFinite(millis)) return make$10(millis);
3718
+ if (!Number.isFinite(millis)) return make$11(millis);
3707
3719
  const nanos = parseNanos(input, BigInt(scale) * bigint1e6);
3708
- return make$10(Number.isInteger(millis) && BigInt(millis) * bigint1e6 === nanos ? millis : nanos);
3720
+ return make$11(Number.isInteger(millis) && BigInt(millis) * bigint1e6 === nanos ? millis : nanos);
3709
3721
  };
3710
3722
  const DURATION_REGEXP = /^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/;
3711
3723
  /**
@@ -3772,7 +3784,7 @@ const fromInputUnsafe = (input) => {
3772
3784
  if (input[0] === -Infinity || input[1] === -Infinity) return negativeInfinity;
3773
3785
  if (input[0] === Infinity || input[1] === Infinity) return infinity;
3774
3786
  const nanos = input[0] * 1e9 + input[1];
3775
- return Number.isFinite(nanos) && Number.isInteger(input[0]) && Number.isInteger(input[1]) ? make$10(BigInt(input[0]) * bigint1e9 + BigInt(input[1])) : fromNanosNumber(nanos);
3787
+ return Number.isFinite(nanos) && Number.isInteger(input[0]) && Number.isInteger(input[1]) ? make$11(BigInt(input[0]) * bigint1e9 + BigInt(input[1])) : fromNanosNumber(nanos);
3776
3788
  }
3777
3789
  const obj = input;
3778
3790
  let millis = 0;
@@ -3783,13 +3795,13 @@ const fromInputUnsafe = (input) => {
3783
3795
  if (obj.seconds) millis += obj.seconds * 1e3;
3784
3796
  if (obj.milliseconds) millis += obj.milliseconds;
3785
3797
  if (!obj.microseconds && !obj.nanoseconds) {
3786
- if (!Number.isFinite(millis)) return make$10(millis);
3798
+ if (!Number.isFinite(millis)) return make$11(millis);
3787
3799
  const exact = sumObjectNanos(obj);
3788
- return exact === void 0 || BigInt(millis) * bigint1e6 === exact ? make$10(millis) : make$10(exact);
3800
+ return exact === void 0 || BigInt(millis) * bigint1e6 === exact ? make$11(millis) : make$11(exact);
3789
3801
  }
3790
3802
  const nanos = millis * 1e6 + (obj.microseconds ?? 0) * 1e3 + (obj.nanoseconds ?? 0);
3791
3803
  const exact = Number.isFinite(nanos) ? sumObjectNanos(obj) : void 0;
3792
- return exact === void 0 ? fromNanosNumber(nanos) : make$10(exact);
3804
+ return exact === void 0 ? fromNanosNumber(nanos) : make$11(exact);
3793
3805
  }
3794
3806
  }
3795
3807
  return invalid$1(input);
@@ -3866,7 +3878,7 @@ const DurationProto = {
3866
3878
  return pipeArguments(this, arguments);
3867
3879
  }
3868
3880
  };
3869
- const make$10 = (input) => {
3881
+ const make$11 = (input) => {
3870
3882
  const duration = Object.create(DurationProto);
3871
3883
  if (typeof input === "number") {
3872
3884
  if (isNaN(input) || input === 0 || Object.is(input, -0)) duration.value = zeroDurationValue;
@@ -3918,7 +3930,7 @@ const isDuration = (u) => hasProperty(u, TypeId$14);
3918
3930
  * @category constructors
3919
3931
  * @since 2.0.0
3920
3932
  */
3921
- const zero$1 = /*#__PURE__*/ make$10(0);
3933
+ const zero$1 = /*#__PURE__*/ make$11(0);
3922
3934
  /**
3923
3935
  * A Duration representing infinite time.
3924
3936
  *
@@ -3934,7 +3946,7 @@ const zero$1 = /*#__PURE__*/ make$10(0);
3934
3946
  * @category constructors
3935
3947
  * @since 2.0.0
3936
3948
  */
3937
- const infinity = /*#__PURE__*/ make$10(Infinity);
3949
+ const infinity = /*#__PURE__*/ make$11(Infinity);
3938
3950
  /**
3939
3951
  * A Duration representing negative infinite time.
3940
3952
  *
@@ -3950,7 +3962,7 @@ const infinity = /*#__PURE__*/ make$10(Infinity);
3950
3962
  * @category constructors
3951
3963
  * @since 4.0.0
3952
3964
  */
3953
- const negativeInfinity = /*#__PURE__*/ make$10(-Infinity);
3965
+ const negativeInfinity = /*#__PURE__*/ make$11(-Infinity);
3954
3966
  /**
3955
3967
  * Creates a Duration from nanoseconds.
3956
3968
  *
@@ -3966,7 +3978,7 @@ const negativeInfinity = /*#__PURE__*/ make$10(-Infinity);
3966
3978
  * @category constructors
3967
3979
  * @since 2.0.0
3968
3980
  */
3969
- const nanos = (nanos) => make$10(nanos);
3981
+ const nanos = (nanos) => make$11(nanos);
3970
3982
  /**
3971
3983
  * Creates a Duration from milliseconds.
3972
3984
  *
@@ -3982,7 +3994,7 @@ const nanos = (nanos) => make$10(nanos);
3982
3994
  * @category constructors
3983
3995
  * @since 2.0.0
3984
3996
  */
3985
- const millis = (millis) => make$10(millis);
3997
+ const millis = (millis) => make$11(millis);
3986
3998
  /**
3987
3999
  * Gets the duration in nanoseconds as a bigint.
3988
4000
  *
@@ -4084,7 +4096,7 @@ const Equivalence$3 = (self, that) => matchPair(self, that, {
4084
4096
  * @since 2.0.0
4085
4097
  */
4086
4098
  const equals = /*#__PURE__*/ dual(2, (self, that) => Equivalence$3(self, that));
4087
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Scheduler.js
4099
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/Scheduler.js
4088
4100
  let defaultScheduler;
4089
4101
  /**
4090
4102
  * The scheduler of fibers whose context provides none. `Scheduler` resolves to
@@ -4102,10 +4114,28 @@ const setMicrotask = (f) => {
4102
4114
  cancelled = true;
4103
4115
  };
4104
4116
  };
4105
- const setTimer = "setImmediate" in globalThis ? (f) => {
4117
+ const postTask = (scheduler, f) => {
4118
+ let cancelled = false;
4119
+ scheduler.postTask(() => {
4120
+ if (cancelled) return;
4121
+ try {
4122
+ f();
4123
+ } catch (error) {
4124
+ setTimeout(() => {
4125
+ throw error;
4126
+ }, 0);
4127
+ }
4128
+ });
4129
+ return () => {
4130
+ cancelled = true;
4131
+ };
4132
+ };
4133
+ const setTimer = typeof globalThis.setImmediate === "function" ? (f) => {
4106
4134
  const timer = globalThis.setImmediate(f);
4107
4135
  return () => globalThis.clearImmediate(timer);
4108
4136
  } : (f) => {
4137
+ const scheduler = globalThis.scheduler;
4138
+ if (typeof scheduler?.postTask === "function") return postTask(scheduler, f);
4109
4139
  const timer = setTimeout(f, 0);
4110
4140
  return () => clearTimeout(timer);
4111
4141
  };
@@ -4116,27 +4146,6 @@ const setImmediate = (f) => {
4116
4146
  return setMicrotask(f);
4117
4147
  }
4118
4148
  };
4119
- var PriorityBuckets = class {
4120
- buckets = [];
4121
- scheduleTask(task, priority) {
4122
- const buckets = this.buckets;
4123
- const len = buckets.length;
4124
- let bucket;
4125
- let index = 0;
4126
- for (; index < len; index++) {
4127
- if (buckets[index][0] > priority) break;
4128
- bucket = buckets[index];
4129
- }
4130
- if (bucket && bucket[0] === priority) bucket[1].push(task);
4131
- else if (index === len) buckets.push([priority, [task]]);
4132
- else buckets.splice(index, 0, [priority, [task]]);
4133
- }
4134
- drain() {
4135
- const buckets = this.buckets;
4136
- this.buckets = [];
4137
- return buckets;
4138
- }
4139
- };
4140
4149
  /**
4141
4150
  * Provides a scheduler implementation that batches queued tasks and dispatches them by
4142
4151
  * priority.
@@ -4201,18 +4210,23 @@ var MixedScheduler = class {
4201
4210
  }
4202
4211
  };
4203
4212
  var MixedSchedulerDispatcher = class {
4204
- tasks = /*#__PURE__*/ new PriorityBuckets();
4213
+ buckets = [];
4205
4214
  running = void 0;
4206
4215
  setImmediate;
4207
- constructor(setImmediateFn = setImmediate) {
4216
+ constructor(setImmediateFn) {
4208
4217
  this.setImmediate = setImmediateFn;
4209
4218
  }
4210
4219
  /**
4211
4220
  * @since 2.0.0
4212
4221
  */
4213
4222
  scheduleTask(task, priority) {
4214
- this.tasks.scheduleTask(task, priority);
4215
- if (this.running === void 0) this.running = this.setImmediate(this.afterScheduled);
4223
+ const buckets = this.buckets;
4224
+ let index = 0;
4225
+ while (index < buckets.length && buckets[index][0] < priority) index++;
4226
+ if (index === buckets.length) buckets.push([priority, [task]]);
4227
+ else if (buckets[index][0] === priority) buckets[index][1].push(task);
4228
+ else buckets.splice(index, 0, [priority, [task]]);
4229
+ this.running ??= this.setImmediate(this.afterScheduled);
4216
4230
  }
4217
4231
  /**
4218
4232
  * @since 2.0.0
@@ -4225,7 +4239,8 @@ var MixedSchedulerDispatcher = class {
4225
4239
  * @since 2.0.0
4226
4240
  */
4227
4241
  runTasks() {
4228
- const buckets = this.tasks.drain();
4242
+ const buckets = this.buckets;
4243
+ this.buckets = [];
4229
4244
  for (let i = 0; i < buckets.length; i++) {
4230
4245
  const toRun = buckets[i][1];
4231
4246
  for (let j = 0; j < toRun.length; j++) toRun[j]();
@@ -4235,11 +4250,9 @@ var MixedSchedulerDispatcher = class {
4235
4250
  * @since 2.0.0
4236
4251
  */
4237
4252
  flush() {
4238
- while (this.tasks.buckets.length > 0) {
4239
- if (this.running !== void 0) {
4240
- this.running();
4241
- this.running = void 0;
4242
- }
4253
+ while (this.buckets.length > 0) {
4254
+ this.running?.();
4255
+ this.running = void 0;
4243
4256
  this.runTasks();
4244
4257
  }
4245
4258
  }
@@ -4291,7 +4304,7 @@ var MixedSchedulerDispatcher = class {
4291
4304
  * @since 2.0.0
4292
4305
  */
4293
4306
  const TaggedError$1 = TaggedError$2;
4294
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/internal/effect.js
4307
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/internal/effect.js
4295
4308
  /** @internal */
4296
4309
  var Interrupt = class extends ReasonBase {
4297
4310
  constructor(fiberId, annotations = constEmptyAnnotations) {
@@ -4389,7 +4402,7 @@ const captureAsyncContext = () => AsyncResource === void 0 ? void 0 : new AsyncR
4389
4402
  const getCurrentFiber = () => globalThis[currentFiberTypeId];
4390
4403
  /** @internal */
4391
4404
  var FiberImpl = class {
4392
- constructor(context, interruptible = true) {
4405
+ constructor(context, interruptible = true, parent) {
4393
4406
  this.setContext(context);
4394
4407
  this.id = ++nextFiberId;
4395
4408
  this.currentOpCount = 0;
@@ -4406,6 +4419,8 @@ var FiberImpl = class {
4406
4419
  this._parent = void 0;
4407
4420
  this._asyncContext = void 0;
4408
4421
  this.cache.runtimeMetrics?.recordFiberStart(this.context);
4422
+ this.supervisor = this.cache.supervisor;
4423
+ this.supervisor?.onStart(this, parent);
4409
4424
  }
4410
4425
  get [FiberTypeId]() {
4411
4426
  return fiberVariance;
@@ -4448,11 +4463,18 @@ var FiberImpl = class {
4448
4463
  else if (this._asyncContext !== void 0) {
4449
4464
  const asyncContext = this._asyncContext;
4450
4465
  this._asyncContext = void 0;
4466
+ let entered = false;
4451
4467
  try {
4452
- return asyncContext.runInAsyncScope(this.evaluate, this, effect);
4468
+ return asyncContext.runInAsyncScope(() => {
4469
+ entered = true;
4470
+ return this.evaluate(effect);
4471
+ });
4472
+ } catch (error) {
4473
+ if (entered) throw error;
4453
4474
  } finally {
4454
4475
  asyncContext.emitDestroy();
4455
4476
  }
4477
+ return this.evaluate(effect);
4456
4478
  } else if (this._yielded !== void 0) {
4457
4479
  const yielded = this._yielded;
4458
4480
  this._yielded = void 0;
@@ -4469,19 +4491,19 @@ var FiberImpl = class {
4469
4491
  return this.evaluate(interruptChildren);
4470
4492
  }
4471
4493
  this._exit = exit;
4472
- this.cache.runtimeMetrics?.recordFiberEnd(this.context, this._exit);
4494
+ this.cache.runtimeMetrics?.recordFiberEnd(this.context, exit);
4473
4495
  if (this._parent) {
4474
4496
  this._parent._children?.delete(this);
4475
4497
  this._parent = void 0;
4476
4498
  }
4499
+ this.supervisor?.onEnd(this, exit);
4477
4500
  if (this._observers !== void 0) {
4478
4501
  const observers = this._observers;
4479
4502
  this._observers = void 0;
4480
4503
  for (let i = 0; i < observers.length; i++) observers[i](exit);
4481
4504
  }
4482
- this._stack.length = 0;
4483
4505
  this._children = void 0;
4484
- this.context = empty$1();
4506
+ this.context = empty$2();
4485
4507
  const cache = this.cache;
4486
4508
  if (cache.span !== void 0 || cache.stackFrame !== void 0) this.cache = {
4487
4509
  ...cache,
@@ -4528,7 +4550,10 @@ var FiberImpl = class {
4528
4550
  return Yield;
4529
4551
  }
4530
4552
  } catch (error) {
4531
- if (!hasProperty$1(current, "~effect/Effect/evaluate")) return exitDie(`Fiber.runLoop: Not a valid effect: ${String(current)}`);
4553
+ if (!hasProperty$1(current, "~effect/Effect/evaluate")) {
4554
+ this._stack.length = 0;
4555
+ return exitDie(`Fiber.runLoop: Not a valid effect: ${String(current)}`);
4556
+ }
4532
4557
  current = exitDie(error);
4533
4558
  }
4534
4559
  } finally {
@@ -4564,9 +4589,9 @@ var FiberImpl = class {
4564
4589
  this._yielded = value;
4565
4590
  return Yield;
4566
4591
  }
4567
- yieldNow(effect, priority = 0, automatic = false) {
4592
+ yieldNow(effect, priority = 0, automatic = false, dispatcher = this.currentDispatcher) {
4568
4593
  let resumed = false;
4569
- this.currentDispatcher.scheduleTask(() => {
4594
+ dispatcher.scheduleTask(() => {
4570
4595
  if (resumed) return;
4571
4596
  this._autoYielded = automatic;
4572
4597
  this.evaluate(effect);
@@ -4586,7 +4611,7 @@ var FiberImpl = class {
4586
4611
  this.context = context;
4587
4612
  if (previous !== void 0 && hasSameCache(previous, context)) return;
4588
4613
  const root = context.cacheRoot;
4589
- const cache = root._fiberCache ??= makeFiberContextCache(context);
4614
+ const cache = root._fiberCache ??= deriveFiberContextCache(previous, context) ?? makeFiberContextCache(context);
4590
4615
  if (this.cache?.scheduler !== cache.scheduler) this._dispatcher = void 0;
4591
4616
  this.cache = cache;
4592
4617
  }
@@ -4595,6 +4620,19 @@ var FiberImpl = class {
4595
4620
  return span?._tag === "Span" ? span : void 0;
4596
4621
  }
4597
4622
  };
4623
+ const deriveFiberContextCache = (previous, context) => {
4624
+ const overlay = context.overlay;
4625
+ const cache = previous?.cacheRoot._fiberCache;
4626
+ if (cache === void 0 || overlay === void 0 || overlay.parent !== previous.overlay || context.base !== previous.base) return;
4627
+ if (overlay.key === "effect/Tracer/ParentSpan") return {
4628
+ ...cache,
4629
+ span: overlay.value
4630
+ };
4631
+ if (overlay.key === "effect/References/CurrentStackFrame") return {
4632
+ ...cache,
4633
+ stackFrame: overlay.value
4634
+ };
4635
+ };
4598
4636
  const makeFiberContextCache = (context) => {
4599
4637
  const get = (key) => getOrUndefinedUnsafe(context, key);
4600
4638
  const currentTracer = get(TracerKey);
@@ -4608,6 +4646,7 @@ const makeFiberContextCache = (context) => {
4608
4646
  minimumLogLevel: get("effect/References/MinimumLogLevel") ?? "Info",
4609
4647
  stackFrame: get(CurrentStackFrameKey),
4610
4648
  runtimeMetrics: get(FiberRuntimeMetricsKey),
4649
+ supervisor: get(SupervisorKey),
4611
4650
  maxOpsBeforeYield: get("effect/Scheduler/MaxOpsBeforeYield") ?? 2048,
4612
4651
  preventYield: get("effect/Scheduler/PreventSchedulerYield") ?? false
4613
4652
  };
@@ -4629,33 +4668,34 @@ const fiberStackAnnotations = (fiber) => {
4629
4668
  return makeUnsafe$2(annotations);
4630
4669
  };
4631
4670
  /** @internal */
4632
- const fiberAwaitAll = (self) => callback((resume) => {
4633
- const iter = self[Symbol.iterator]();
4634
- const exits = [];
4635
- let cancel = void 0;
4636
- function loop() {
4637
- let result = iter.next();
4638
- while (!result.done) {
4639
- if (result.value._exit) {
4640
- exits.push(result.value._exit);
4641
- result = iter.next();
4642
- continue;
4671
+ const fiberAwaitAll = (self) => suspend$1(() => {
4672
+ const fibers = Array.from(self);
4673
+ return callbackNoSignal((resume) => {
4674
+ const exits = [];
4675
+ let cancel = void 0;
4676
+ function loop() {
4677
+ while (exits.length < fibers.length) {
4678
+ const fiber = fibers[exits.length];
4679
+ if (fiber._exit) {
4680
+ exits.push(fiber._exit);
4681
+ continue;
4682
+ }
4683
+ cancel = fiber.addObserver((exit) => {
4684
+ exits.push(exit);
4685
+ loop();
4686
+ });
4687
+ return;
4643
4688
  }
4644
- cancel = result.value.addObserver((exit) => {
4645
- exits.push(exit);
4646
- loop();
4647
- });
4648
- return;
4689
+ resume(succeed$3(exits));
4649
4690
  }
4650
- resume(succeed$3(exits));
4651
- }
4652
- loop();
4653
- return sync(() => cancel?.());
4691
+ loop();
4692
+ return sync(() => cancel?.());
4693
+ }, fibers);
4654
4694
  });
4655
4695
  /** @internal */
4656
4696
  const fiberInterruptAll = (fibers) => withFiber((parent) => {
4657
4697
  const annotations = fiberStackAnnotations(parent);
4658
- let fiberArr = empty();
4698
+ let fiberArr = empty$1();
4659
4699
  for (const fiber of fibers) {
4660
4700
  fiber.interruptUnsafe(parent.id, annotations);
4661
4701
  fiberArr.push(fiber);
@@ -4724,25 +4764,27 @@ const callbackOptions = /*#__PURE__*/ function() {
4724
4764
  }, controller?.signal);
4725
4765
  if (yielded !== false) return yielded;
4726
4766
  yielded = true;
4767
+ fiber.supervisor?.onBlock(fiber, this.blockedOn);
4727
4768
  fiber.yieldWith(() => {
4728
4769
  resumed = true;
4770
+ fiber.supervisor?.onUnblock(fiber);
4729
4771
  });
4730
- if (controller === void 0 && onCancel === void 0) return Yield;
4731
- fiber._stack.push(asyncFinalizer(() => {
4732
- resumed = true;
4733
- controller?.abort();
4772
+ const cancel = controller === void 0 ? onCancel : suspend$1(() => {
4773
+ controller.abort();
4734
4774
  return onCancel ?? exitVoid;
4735
- }));
4775
+ });
4776
+ if (cancel !== void 0) fiber._stack.push(asyncFinalizer(cancel));
4736
4777
  return Yield;
4737
4778
  }
4738
4779
  });
4739
- const AsyncImpl = function(register, withSignal) {
4780
+ const AsyncImpl = function(register, withSignal, blockedOn) {
4740
4781
  this.register = register;
4741
4782
  this.withSignal = withSignal;
4783
+ this.blockedOn = blockedOn;
4742
4784
  };
4743
4785
  AsyncImpl.prototype = Proto;
4744
- return function(register, withSignal) {
4745
- return new AsyncImpl(register, withSignal);
4786
+ return function(register, withSignal, blockedOn) {
4787
+ return new AsyncImpl(register, withSignal, blockedOn);
4746
4788
  };
4747
4789
  }();
4748
4790
  const asyncFinalizer = /*#__PURE__*/ makePrimitive({
@@ -4754,11 +4796,17 @@ const asyncFinalizer = /*#__PURE__*/ makePrimitive({
4754
4796
  }
4755
4797
  },
4756
4798
  [contE](cause, _fiber) {
4757
- return hasInterrupts(cause) ? flatMap$1(combineFinalizerCause(exitFailCause(cause), this[args]()), () => failCause$2(cause)) : failCause$2(cause);
4799
+ return hasInterrupts(cause) ? new ContImpl(combineFinalizerCause(exitFailCause(cause), this[args]), returnPayload, failCause$2(cause)) : failCause$2(cause);
4758
4800
  }
4759
4801
  });
4760
- /** @internal */
4761
- const callback = (register) => callbackOptions(register, register.length >= 2);
4802
+ /**
4803
+ * `callback` for a register that never reads the AbortSignal. Internal waits
4804
+ * use it because reading `length` from a fresh closure, as `callback` does to
4805
+ * decide whether to create a signal, is slow in JavaScriptCore.
4806
+ *
4807
+ * @internal
4808
+ */
4809
+ const callbackNoSignal = (register, blockedOn) => callbackOptions(register, false, blockedOn);
4762
4810
  /** @internal */
4763
4811
  const gen$1 = (...args) => {
4764
4812
  if (args.length === 1) {
@@ -4774,9 +4822,9 @@ const fnUntraced$1 = (bodyOrOptions, ...pipeables) => {
4774
4822
  const body = fnBody(bodyOrOptions, pipeables);
4775
4823
  const fn = pipeables.length === 0 ? function() {
4776
4824
  return suspend$1(() => fromIteratorUnsafe(body.apply(this, arguments)));
4777
- } : function() {
4778
- let effect = suspend$1(() => fromIteratorUnsafe(body.apply(this, arguments)));
4779
- for (let i = 0; i < pipeables.length; i++) effect = pipeables[i](effect, ...arguments);
4825
+ } : function(...args) {
4826
+ let effect = suspend$1(() => fromIteratorUnsafe(body.apply(this, args)));
4827
+ for (let i = 0; i < pipeables.length; i++) effect = pipeables[i](effect, ...args);
4780
4828
  return effect;
4781
4829
  };
4782
4830
  return defineFunctionLength(body.length, fn);
@@ -4790,9 +4838,9 @@ const fnUntracedEager$1 = (bodyOrOptions, ...pipeables) => {
4790
4838
  const body = fnBody(bodyOrOptions, pipeables);
4791
4839
  return defineFunctionLength(body.length, pipeables.length === 0 ? function() {
4792
4840
  return fromIteratorEagerUnsafe(() => body.apply(this, arguments));
4793
- } : function() {
4794
- let effect = fromIteratorEagerUnsafe(() => body.apply(this, arguments));
4795
- for (const pipeable of pipeables) effect = pipeable(effect, ...arguments);
4841
+ } : function(...args) {
4842
+ let effect = fromIteratorEagerUnsafe(() => body.apply(this, args));
4843
+ for (const pipeable of pipeables) effect = pipeable(effect, ...args);
4796
4844
  return effect;
4797
4845
  });
4798
4846
  };
@@ -4829,7 +4877,7 @@ const fromIteratorUnsafe = /*#__PURE__*/ function() {
4829
4877
  const iter = this.iterator;
4830
4878
  while (true) {
4831
4879
  const state = iter.next(value);
4832
- if (state.done) return succeed$3(state.value);
4880
+ if (state.done) return fiber.succeedWith(state.value);
4833
4881
  if (!effectIsExit(state.value)) {
4834
4882
  fiber._stack.push(this);
4835
4883
  return state.value;
@@ -4919,7 +4967,8 @@ const exitVoid = /*#__PURE__*/ exitSucceed(void 0);
4919
4967
  /** @internal */
4920
4968
  const exitMap = /*#__PURE__*/ dual(2, (self, f) => self._tag === "Success" ? exitSucceed(f(self.value)) : self);
4921
4969
  /** @internal */
4922
- const catchCause$1 = /*#__PURE__*/ dual(2, (self, f) => new OnFailureImpl(self, f.length !== 1 ? (cause) => f(cause) : f));
4970
+ const catchCause$1 = /*#__PURE__*/ dual(2, (self, f) => catchCauseUnary(self, f.length !== 1 ? (cause) => f(cause) : f));
4971
+ const catchCauseUnary = (self, f) => new OnFailureImpl(self, f);
4923
4972
  const OnFailureProto = /*#__PURE__*/ makePrimitiveProto({
4924
4973
  op: "OnFailure",
4925
4974
  [evaluate]: evaluateCont
@@ -4930,7 +4979,7 @@ const OnFailureImpl = function(self, f) {
4930
4979
  };
4931
4980
  OnFailureImpl.prototype = OnFailureProto;
4932
4981
  /** @internal */
4933
- const catchCauseFilter = /*#__PURE__*/ dual(3, (self, filter, f) => catchCause$1(self, (cause) => {
4982
+ const catchCauseFilter = /*#__PURE__*/ dual(3, (self, filter, f) => catchCauseUnary(self, (cause) => {
4934
4983
  const eb = filter(cause);
4935
4984
  return isFailure(eb) ? failCause$2(eb.failure) : f(eb.success, cause);
4936
4985
  }));
@@ -4963,7 +5012,7 @@ const exitPrimitive = /*#__PURE__*/ makePrimitive({
4963
5012
  return fiber.succeedWith(exit ?? exitFailCause(cause));
4964
5013
  }
4965
5014
  });
4966
- const combineFinalizerCause = (exit_, finalizer) => exitIsSuccess(exit_) ? finalizer : catchCause$1(finalizer, (cause) => failCause$2(causeElectDefects(causeCombine(exit_.cause, cause))));
5015
+ const combineFinalizerCause = (exit_, finalizer) => exitIsSuccess(exit_) ? finalizer : catchCauseUnary(finalizer, (cause) => failCause$2(causeElectDefects(causeCombine(exit_.cause, cause))));
4967
5016
  /** @internal */
4968
5017
  const uninterruptible = (self) => withFiber((fiber) => {
4969
5018
  if (!fiber.interruptible) return self;
@@ -4978,6 +5027,7 @@ const setInterruptibleTrue = /*#__PURE__*/ (/* @__PURE__ */ makePrimitive({
4978
5027
  if (fiber._interruptedCause && fiber.interruptible) return () => failCause$2(fiber._interruptedCause);
4979
5028
  }
4980
5029
  }))(true);
5030
+ Array.prototype[Symbol.iterator];
4981
5031
  /** @internal */
4982
5032
  const resolveConcurrency = (concurrency) => concurrency === "unbounded" ? Number.POSITIVE_INFINITY : Math.max(1, concurrency ?? 1);
4983
5033
  /** @internal */
@@ -5023,24 +5073,25 @@ const iterateConcurrentImpl = (options) => {
5023
5073
  if (effectIsExit(eff)) {
5024
5074
  terminal = step(state, item, eff, index);
5025
5075
  if (terminal) break;
5026
- } else if (!parentFiber) return callback((cb) => {
5027
- parentFiber = getCurrentFiber();
5076
+ } else if (!parentFiber) {
5028
5077
  fibers = /* @__PURE__ */ new Set();
5029
- effect = eff;
5030
- resume = cb;
5031
- let result;
5032
- try {
5033
- result = go();
5034
- } catch (error) {
5035
- return cb(failDefect(error));
5036
- }
5037
- if (result) return cb(result);
5038
- return suspend$1(() => {
5039
- terminal ??= exitVoid;
5040
- return flatMap$1(fibers ? fiberInterruptAll(fibers) : void_$1, () => terminal?._tag === "Failure" ? terminal : void_$1);
5041
- });
5042
- });
5043
- else {
5078
+ return callbackNoSignal((cb) => {
5079
+ parentFiber = getCurrentFiber();
5080
+ effect = eff;
5081
+ resume = cb;
5082
+ let result;
5083
+ try {
5084
+ result = go();
5085
+ } catch (error) {
5086
+ return cb(failDefect(error));
5087
+ }
5088
+ if (result) return cb(result);
5089
+ return suspend$1(() => {
5090
+ terminal ??= exitVoid;
5091
+ return flatMap$1(fibers ? fiberInterruptAll(fibers) : void_$1, () => terminal?._tag === "Failure" ? terminal : void_$1);
5092
+ });
5093
+ }, fibers);
5094
+ } else {
5044
5095
  effect = void 0;
5045
5096
  const fiber = forkUnsafe(parentFiber, eff, true, true, "inherit");
5046
5097
  if (fiber._exit) {
@@ -5104,7 +5155,7 @@ const iterateConcurrent = () => (options) => iterateConcurrentImpl(options);
5104
5155
  const forkUnsafe = (parent, effect, immediate = false, daemon = false, uninterruptible = false) => {
5105
5156
  const parentRuntime = parent;
5106
5157
  const interruptible = uninterruptible === "inherit" ? parentRuntime.interruptible : !uninterruptible;
5107
- const child = new FiberImpl(parentRuntime.context, interruptible);
5158
+ const child = new FiberImpl(parentRuntime.context, interruptible, parentRuntime);
5108
5159
  if (!daemon) {
5109
5160
  parentRuntime.children().add(child);
5110
5161
  child._parent = parentRuntime;
@@ -5112,14 +5163,7 @@ const forkUnsafe = (parent, effect, immediate = false, daemon = false, uninterru
5112
5163
  if (immediate) child.evaluate(effect);
5113
5164
  else {
5114
5165
  child._asyncContext = captureAsyncContext();
5115
- let resumed = false;
5116
- child.yieldWith(() => {
5117
- resumed = true;
5118
- });
5119
- parentRuntime.currentDispatcher.scheduleTask(() => {
5120
- if (resumed) return;
5121
- child.evaluate(effect);
5122
- }, 0);
5166
+ child.yieldNow(effect, 0, false, parentRuntime.currentDispatcher);
5123
5167
  }
5124
5168
  return child;
5125
5169
  };
@@ -5161,7 +5205,7 @@ const runPromiseWith = (context) => {
5161
5205
  });
5162
5206
  };
5163
5207
  /** @internal */
5164
- const runPromise$1 = /*#__PURE__*/ runPromiseWith(/*#__PURE__*/ empty$1());
5208
+ const runPromise$1 = /*#__PURE__*/ runPromiseWith(/*#__PURE__*/ empty$2());
5165
5209
  /** @internal */
5166
5210
  const runSyncExitWith = (context) => {
5167
5211
  const runFork = runForkWith(context);
@@ -5174,7 +5218,7 @@ const runSyncExitWith = (context) => {
5174
5218
  };
5175
5219
  };
5176
5220
  /** @internal */
5177
- const runSyncExit$1 = /*#__PURE__*/ runSyncExitWith(/*#__PURE__*/ empty$1());
5221
+ const runSyncExit$1 = /*#__PURE__*/ runSyncExitWith(/*#__PURE__*/ empty$2());
5178
5222
  /** @internal */
5179
5223
  const AsyncFiberErrorTypeId = "~effect/Cause/AsyncFiberError";
5180
5224
  /** @internal */
@@ -5212,7 +5256,7 @@ const colors = {
5212
5256
  bgBrightRed: "101"
5213
5257
  };
5214
5258
  colors.gray, colors.blue, colors.green, colors.yellow, colors.red, colors.bgBrightRed, colors.black;
5215
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Cause.js
5259
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/Cause.js
5216
5260
  /**
5217
5261
  * Narrows a `Reason` to `Fail`.
5218
5262
  *
@@ -5437,7 +5481,7 @@ const map$2 = causeMap;
5437
5481
  * @since 4.0.0
5438
5482
  */
5439
5483
  const reasonAnnotations = reasonAnnotations$1;
5440
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Exit.js
5484
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/Exit.js
5441
5485
  /**
5442
5486
  * Creates a successful Exit containing the given value.
5443
5487
  *
@@ -5555,7 +5599,7 @@ const void_ = exitVoid;
5555
5599
  * @since 2.0.0
5556
5600
  */
5557
5601
  const isSuccess = exitIsSuccess;
5558
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/internal/dateTime.js
5602
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/internal/dateTime.js
5559
5603
  /** @internal */
5560
5604
  const TypeId$13 = "~effect/DateTime";
5561
5605
  /** @internal */
@@ -6651,7 +6695,7 @@ const catchEager = catchEager$1;
6651
6695
  * @since 4.0.0
6652
6696
  */
6653
6697
  const fnUntracedEager = fnUntracedEager$1;
6654
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/BigDecimal.js
6698
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/BigDecimal.js
6655
6699
  /**
6656
6700
  * Decimal numbers and arithmetic for cases where JavaScript `number` rounding
6657
6701
  * is not precise enough. A `BigDecimal` stores digits as a `bigint` plus a
@@ -6748,7 +6792,7 @@ const isBigDecimal = (u) => hasProperty(u, TypeId$12);
6748
6792
  * @category constructors
6749
6793
  * @since 2.0.0
6750
6794
  */
6751
- const make$8 = (value, scale) => {
6795
+ const make$9 = (value, scale) => {
6752
6796
  if (!Number.isSafeInteger(scale)) throw new RangeError(`Scale must be a safe integer, got ${scale}`);
6753
6797
  const o = Object.create(BigDecimalProto);
6754
6798
  o.value = value;
@@ -6756,7 +6800,7 @@ const make$8 = (value, scale) => {
6756
6800
  return o;
6757
6801
  };
6758
6802
  const makeNormalized = (value, scale) => {
6759
- const o = make$8(value, scale);
6803
+ const o = make$9(value, scale);
6760
6804
  o.normalized = o;
6761
6805
  return o;
6762
6806
  };
@@ -6955,7 +6999,7 @@ codes[/*#__PURE__*/ "=".charCodeAt(0)] = 0;
6955
6999
  ({ ...PipeInspectableProto });
6956
7000
  BaseProto.toString, BaseProto[NodeInspectSymbol];
6957
7001
  ({ ...PipeInspectableProto });
6958
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/internal/schema/annotations.js
7002
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/internal/schema/annotations.js
6959
7003
  /** @internal */
6960
7004
  function resolve$1(ast) {
6961
7005
  return ast.checks ? ast.checks[ast.checks.length - 1].annotations : ast.annotations;
@@ -6972,7 +7016,7 @@ const getExpected = /*#__PURE__*/ memoize((ast) => {
6972
7016
  if (typeof identifier === "string") return identifier;
6973
7017
  return ast.getExpected(getExpected);
6974
7018
  });
6975
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/internal/schema/parser.js
7019
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/internal/schema/parser.js
6976
7020
  /** @internal */
6977
7021
  const missing = /*#__PURE__*/ Symbol.for("effect/schema/parser/missing");
6978
7022
  /** @internal */
@@ -6987,7 +7031,7 @@ const isSameExit = (result) => result[missing] === true;
6987
7031
  const toOption = (value) => value === missing ? none() : some(value);
6988
7032
  /** @internal */
6989
7033
  const fromOptionExit = (option) => option._tag === "None" ? missingExit : succeed(option.value);
6990
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/SchemaIssue.js
7034
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/SchemaIssue.js
6991
7035
  /**
6992
7036
  * Describes problems found while decoding, encoding, or checking data with
6993
7037
  * schemas.
@@ -7480,7 +7524,7 @@ function findMessage(issue) {
7480
7524
  const message = (issue._tag === "Filter" ? issue.filter.annotations : "annotations" in issue ? issue.annotations : issue.ast.annotations)?.[issue._tag === "MissingKey" ? "messageMissingKey" : issue._tag === "UnexpectedKey" ? "messageUnexpectedKey" : "message"];
7481
7525
  if (typeof message === "string") return message;
7482
7526
  }
7483
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/internal/schema/cause.js
7527
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/internal/schema/cause.js
7484
7528
  /** @internal */
7485
7529
  function getSchemaIssue(cause) {
7486
7530
  let issue;
@@ -7496,7 +7540,7 @@ function getSchemaIssueOrThrow(cause, message) {
7496
7540
  if (issue === void 0) throw new Error(message, { cause });
7497
7541
  return issue;
7498
7542
  }
7499
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/SchemaGetter.js
7543
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/SchemaGetter.js
7500
7544
  const makeGetter = (fields) => Object.assign(Object.create(Prototype$1), fields);
7501
7545
  const passthrough_$1 = /*#__PURE__*/ makeGetter({ _tag: "Passthrough" });
7502
7546
  function passthrough$1() {
@@ -7698,14 +7742,14 @@ function stringifyJson(options) {
7698
7742
  catch: () => new InvalidValue({ expected: "a JSON-serializable value" }, input, parseOptions)
7699
7743
  }));
7700
7744
  }
7701
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/internal/schema/content.js
7745
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/internal/schema/content.js
7702
7746
  const ContentTypeId = /*#__PURE__*/ Symbol.for("~effect/Schema/content");
7703
7747
  /** @internal */
7704
7748
  function setContent(operation, content) {
7705
7749
  Object.defineProperty(operation, ContentTypeId, { value: content });
7706
7750
  return operation;
7707
7751
  }
7708
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/SchemaTransformation.js
7752
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/SchemaTransformation.js
7709
7753
  /**
7710
7754
  * Constructs schema middleware from its decode and encode functions.
7711
7755
  *
@@ -7898,7 +7942,7 @@ function fromJsonString$1(options) {
7898
7942
  preserveSchema: options?.reviver === void 0 && options?.replacer === void 0
7899
7943
  }));
7900
7944
  }
7901
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/SchemaAST.js
7945
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/SchemaAST.js
7902
7946
  /**
7903
7947
  * Represents Effect schemas as runtime trees.
7904
7948
  *
@@ -8324,6 +8368,7 @@ const Arrays = class extends ASTNodeImpl {
8324
8368
  const ast = this;
8325
8369
  let elements;
8326
8370
  let rest;
8371
+ let itemRefinement;
8327
8372
  const elementLen = ast.elements.length;
8328
8373
  const tailLen = Math.max(0, ast.rest.length - 1);
8329
8374
  function getParser(tailThreshold, index) {
@@ -8335,30 +8380,40 @@ const Arrays = class extends ASTNodeImpl {
8335
8380
  const { input, len, options } = state;
8336
8381
  if (ast.rest.length === 0 && len > elementLen) for (let i = elementLen; i < len; i++) {
8337
8382
  const unexpected = new UnexpectedKey(ast, input[i], options);
8338
- const issue = new Pointer([i], unexpected);
8339
- if (options.errors === "all") {
8340
- if (state.issues) state.issues.push(issue);
8341
- else state.issues = [issue];
8342
- } else return fail$1(new Composite(ast, [issue], input, options));
8383
+ const failure = addIssue(state, ast, new Pointer([i], unexpected));
8384
+ if (failure) return failure;
8343
8385
  }
8344
8386
  if (state.issues) return fail$1(new Composite(ast, state.issues, input, options));
8345
8387
  return succeed(state.output);
8346
8388
  };
8347
8389
  const parse = (input, options) => {
8348
8390
  const len = input.length;
8391
+ const concurrency = options.concurrency === void 0 ? 1 : resolveConcurrency(options.concurrency);
8392
+ const output = [];
8393
+ const refinement = concurrency === 1 ? itemRefinement : void 0;
8394
+ let start = 0;
8395
+ let item;
8396
+ if (refinement !== void 0) {
8397
+ while (start < len && refinement(item = input[start])) output[start++] = item;
8398
+ if (start === len) return succeed(output);
8399
+ }
8349
8400
  const state = {
8350
8401
  ast,
8351
8402
  getParser,
8352
8403
  input,
8353
8404
  len,
8354
8405
  tailThreshold: Math.max(elementLen, len - tailLen),
8355
- output: [],
8406
+ output,
8356
8407
  issues: void 0,
8357
8408
  options
8358
8409
  };
8410
+ if (refinement !== void 0) {
8411
+ const exit = rest[0].parser(item, options);
8412
+ const terminal = stepArray(state, item, exit, start++);
8413
+ if (terminal) return terminal;
8414
+ }
8359
8415
  const end = ast.rest.length === 0 ? elementLen : Math.max(len, elementLen + tailLen);
8360
- const concurrency = options.concurrency === void 0 ? 1 : resolveConcurrency(options.concurrency);
8361
- const eff = concurrency === 1 ? parseArray(state, input, 0, end) : parseArrayConcurrent(state, input, {
8416
+ const eff = concurrency === 1 ? parseArray(state, input, start, end) : parseArrayConcurrent(state, input, {
8362
8417
  concurrency,
8363
8418
  end
8364
8419
  });
@@ -8384,6 +8439,7 @@ const Arrays = class extends ASTNodeImpl {
8384
8439
  ast,
8385
8440
  parser: compileField(ast)
8386
8441
  }));
8442
+ if (elementLen === 0 && rest.length === 1) itemRefinement = refinements.get(rest[0].parser);
8387
8443
  }
8388
8444
  return parse(input, options);
8389
8445
  } catch (error) {
@@ -8414,11 +8470,7 @@ function stepArray(s, item, exit, i) {
8414
8470
  else {
8415
8471
  const p = s.getParser(s.tailThreshold, i);
8416
8472
  if (isOptional(p.ast)) return;
8417
- const issue = new Pointer([i], new MissingKey(p.ast.context?.annotations));
8418
- if (s.options.errors === "all") {
8419
- if (s.issues) s.issues.push(issue);
8420
- else s.issues = [issue];
8421
- } else return fail$2(new Composite(s.ast, [issue], s.input, s.options));
8473
+ return addIssue(s, s.ast, new Pointer([i], new MissingKey(p.ast.context?.annotations)));
8422
8474
  }
8423
8475
  }
8424
8476
  const parseArrayOptions = {
@@ -8435,11 +8487,12 @@ const wrapPropertyKeyIssue = (s, ast, key, exit) => {
8435
8487
  if (exit.cause.reasons.length === 0) return exit;
8436
8488
  const issue = getSchemaIssue(exit.cause);
8437
8489
  if (issue === void 0) return failCause$1(map$2(exit.cause, (issue) => new Composite(ast, [new Pointer([key], issue)], s.input, s.options)));
8438
- const pointer = new Pointer([key], issue);
8439
- if (s.options.errors === "all") {
8440
- if (s.issues) s.issues.push(pointer);
8441
- else s.issues = [pointer];
8442
- } else return fail$2(new Composite(ast, [pointer], s.input, s.options));
8490
+ return addIssue(s, ast, new Pointer([key], issue));
8491
+ };
8492
+ const addIssue = (s, ast, issue) => {
8493
+ if (s.options.errors !== "all") return fail$2(new Composite(ast, [issue], s.input, s.options));
8494
+ if (s.issues) s.issues.push(issue);
8495
+ else s.issues = [issue];
8443
8496
  };
8444
8497
  /**
8445
8498
  * floating point or integer, with optional exponent
@@ -8611,7 +8664,6 @@ const Objects = class extends ASTNodeImpl {
8611
8664
  issues: void 0,
8612
8665
  options
8613
8666
  };
8614
- const errorsAllOption = options.errors === "all";
8615
8667
  const onExcessPropertyError = options.onExcessProperty === "error";
8616
8668
  const concurrency = options.concurrency === void 0 ? 1 : resolveConcurrency(options.concurrency);
8617
8669
  const indexKeys = indexCount && onExcessPropertyError ? ast.indexSignatures.map((index) => getIndexSignatureKeys(record, index.parameter, options)) : void 0;
@@ -8623,12 +8675,8 @@ const Objects = class extends ASTNodeImpl {
8623
8675
  const key = inputKeys[i];
8624
8676
  if (!coveredKeys.has(key)) {
8625
8677
  const unexpected = new UnexpectedKey(ast, record[key], options);
8626
- const issue = new Pointer([key], unexpected);
8627
- if (errorsAllOption) {
8628
- if (state.issues) state.issues.push(issue);
8629
- else state.issues = [issue];
8630
- continue;
8631
- } else return yield* fail$1(new Composite(ast, [issue], input, options));
8678
+ const failure = addIssue(state, ast, new Pointer([key], unexpected));
8679
+ if (failure) return yield* failure;
8632
8680
  }
8633
8681
  }
8634
8682
  }
@@ -8647,7 +8695,7 @@ const Objects = class extends ASTNodeImpl {
8647
8695
  }
8648
8696
  }
8649
8697
  else if (parseIndexes) {
8650
- const keyPairs = empty();
8698
+ const keyPairs = empty$1();
8651
8699
  for (let i = 0; i < indexCount; i++) {
8652
8700
  const index = indexes[i];
8653
8701
  const keys = indexKeys?.[i] ?? (index.is.parameter === string ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options));
@@ -8748,14 +8796,7 @@ function stepProperty(s, p, exit) {
8748
8796
  return;
8749
8797
  }
8750
8798
  delete s.out[p.name];
8751
- if (!isOptional(p.type)) {
8752
- const issue = new Pointer([p.name], new MissingKey(p.type.context?.annotations));
8753
- if (s.options.errors === "all") {
8754
- if (s.issues) s.issues.push(issue);
8755
- else s.issues = [issue];
8756
- return;
8757
- } else return fail$2(new Composite(s.ast, [issue], s.input, s.options));
8758
- }
8799
+ if (!isOptional(p.type)) return addIssue(s, s.ast, new Pointer([p.name], new MissingKey(p.type.context?.annotations)));
8759
8800
  }
8760
8801
  const parsePropertiesOptions = {
8761
8802
  onItem(s, p) {
@@ -9696,12 +9737,15 @@ function fromConst(ast, value) {
9696
9737
  return fail$1(new InvalidType(ast, input, options));
9697
9738
  };
9698
9739
  }
9740
+ const refinements = /*#__PURE__*/ new WeakMap();
9699
9741
  function fromRefinement(ast, refinement) {
9700
- return (input, options) => {
9742
+ const parser = (input, options) => {
9701
9743
  if (input === missing) return missingExit;
9702
9744
  if (refinement(input)) return sameExit;
9703
9745
  return fail$1(new InvalidType(ast, input, options));
9704
9746
  };
9747
+ refinements.set(parser, refinement);
9748
+ return parser;
9705
9749
  }
9706
9750
  /** @internal */
9707
9751
  const parameterFromPropertyKey = /*#__PURE__*/ applyToSelfOrLastLinkEncodingIdempotent((ast) => {
@@ -9822,7 +9866,7 @@ const unknownToStringTree = /*#__PURE__*/ new Link(/* @__PURE__ */ new Declarati
9822
9866
  expected: "StringTree",
9823
9867
  toCodecStringTree: () => void 0
9824
9868
  }), /*#__PURE__*/ passthrough());
9825
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/internal/schema/interpreter.js
9869
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/internal/schema/interpreter.js
9826
9870
  const flatMapTransformation = (result, current, f) => isSameExit(result) ? f(current) : flatMapEager(result, f);
9827
9871
  function compileTransformation(transformation) {
9828
9872
  const apply = compileTransformationUnsafe(transformation);
@@ -9997,7 +10041,7 @@ function resolve(ast) {
9997
10041
  cache.set(ast, entry);
9998
10042
  return entry;
9999
10043
  }
10000
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/SchemaParser.js
10044
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/SchemaParser.js
10001
10045
  /**
10002
10046
  * Runs schemas against real values.
10003
10047
  *
@@ -10257,7 +10301,7 @@ function makeClassSync(ast, input, options, construct) {
10257
10301
  }
10258
10302
  }
10259
10303
  const normalCompiler = (ast) => resolve(ast).parser;
10260
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/internal/schema/make.js
10304
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/internal/schema/make.js
10261
10305
  /** @internal */
10262
10306
  const TypeId$4 = "~effect/Schema/Schema";
10263
10307
  const RebuildOptions = /*#__PURE__*/ Symbol();
@@ -10313,7 +10357,7 @@ function make$3(ast, options) {
10313
10357
  self.ast = ast;
10314
10358
  return self;
10315
10359
  }
10316
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/internal/schema/toCodec.js
10360
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/internal/schema/toCodec.js
10317
10361
  function makeCodecDerivation(step, options) {
10318
10362
  const deriveBody = memoize((owner) => {
10319
10363
  const body = replaceContext(owner, void 0);
@@ -10402,7 +10446,7 @@ const isCodecArrayFromSingleLink = (link) => link.transformation === arrayFromSi
10402
10446
  const toCodecStringTreeAST = /*#__PURE__*/ makeCodecDerivation((ast, recur) => toCodecStringTreeASTStep(ast, recur, (ast) => {
10403
10447
  throw new globalThis.Error("Missing structural codec for StringTree", { cause: ast });
10404
10448
  }), { stopAt: isCodecArrayFromSingleLink });
10405
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/internal/schemaError.js
10449
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/internal/schemaError.js
10406
10450
  const SchemaErrorTypeId = "~effect/Schema/SchemaError";
10407
10451
  ({ ...BaseProto });
10408
10452
  ({ ...BaseProto });
@@ -10412,7 +10456,7 @@ const SchemaErrorTypeId = "~effect/Schema/SchemaError";
10412
10456
  ({ ...BaseProto });
10413
10457
  ({ ...BaseProto });
10414
10458
  ({ ...BaseProto });
10415
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Schema.js
10459
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/Schema.js
10416
10460
  const TypeId$1 = TypeId$4;
10417
10461
  /**
10418
10462
  * Error thrown or returned when schema decoding or encoding fails.
@@ -11191,7 +11235,7 @@ const TaggedError = (identifier) => {
11191
11235
  * @since 4.0.0
11192
11236
  */
11193
11237
  const toCodecStringTree = toCodecStringTree$1;
11194
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/ConfigProvider.js
11238
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/ConfigProvider.js
11195
11239
  /**
11196
11240
  * Data sources used by `Config` to load raw configuration values. A
11197
11241
  * `ConfigProvider` reads paths from places such as environment variables,
@@ -11556,7 +11600,7 @@ function trieNodeAt(root, path) {
11556
11600
  }
11557
11601
  return node;
11558
11602
  }
11559
- // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Config.js
11603
+ // ../../node_modules/.pnpm/effect@4.2.0/node_modules/effect/dist/Config.js
11560
11604
  /**
11561
11605
  * Descriptions of configuration values that can be read from a
11562
11606
  * `ConfigProvider`. A `Config<T>` explains which keys to read, how to decode
@@ -11661,7 +11705,7 @@ const evaluateAt = (self, provider, pathPrefix) => self.evaluator(provider, path
11661
11705
  * @since 2.0.0
11662
11706
  */
11663
11707
  const map = /*#__PURE__*/ dual(2, (self, f) => {
11664
- return make((provider, pathPrefix) => map$1(evaluateAt(self, provider, pathPrefix), map$6(f)));
11708
+ return make((provider, pathPrefix) => map$1(evaluateAt(self, provider, pathPrefix), map$5(f)));
11665
11709
  });
11666
11710
  /**
11667
11711
  * Provides a fallback value when the config is absent.
@@ -11942,7 +11986,7 @@ const baseDirectory = gen(function* baseDirectory() {
11942
11986
  const cacheHome = yield* variable("XDG_CACHE_HOME");
11943
11987
  const home = yield* variable("HOME");
11944
11988
  const profile = yield* variable("USERPROFILE");
11945
- return pipe(cacheHome, orElse(() => pipe(orElse(home, () => profile), map$7((directory) => `${directory}${SEPARATOR}${CACHE_DIRECTORY_NAME}`))));
11989
+ return pipe(cacheHome, orElse(() => pipe(orElse(home, () => profile), map$6((directory) => `${directory}${SEPARATOR}${CACHE_DIRECTORY_NAME}`))));
11946
11990
  });
11947
11991
  const cacheRootEffect = (segments) => baseDirectory.pipe(flatMap(match$2({
11948
11992
  onNone: () => fail$1(CacheRootError.make({ message: "set XDG_CACHE_HOME or HOME" })),