@deslop/auth 0.1.1896 → 0.1.1983

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.
package/dist/server.js CHANGED
@@ -602,7 +602,7 @@ const mix = (h) => {
602
602
  *
603
603
  * @internal
604
604
  */
605
- const combine$4 = (self, b) => mix(Math.imul(self, 2654435761) + Math.imul(b, 2246822507));
605
+ const combine$5 = (self, b) => mix(Math.imul(self, 2654435761) + Math.imul(b, 2246822507));
606
606
  // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/internal/predicate.js
607
607
  /**
608
608
  * Data-first `Predicate.hasProperty`.
@@ -789,7 +789,7 @@ const random$1 = (self) => {
789
789
  * @category hashing
790
790
  * @since 2.0.0
791
791
  */
792
- const combine$3 = /*#__PURE__*/ dual(2, combine$4);
792
+ const combine$4 = /*#__PURE__*/ dual(2, combine$5);
793
793
  /**
794
794
  * Applies bit manipulation techniques to optimize a hash value.
795
795
  *
@@ -882,7 +882,7 @@ const number$2 = (n) => {
882
882
  const h = n | 0;
883
883
  if (h === n) return optimize(h);
884
884
  float64.setFloat64(0, n !== n ? NaN : n);
885
- return optimize(combine$4(float64.getInt32(0), float64.getInt32(4)));
885
+ return optimize(combine$5(float64.getInt32(0), float64.getInt32(4)));
886
886
  };
887
887
  /**
888
888
  * Computes a hash value for a string using the djb2 algorithm.
@@ -953,7 +953,7 @@ const string$2 = (str) => {
953
953
  * @category hashing
954
954
  * @since 2.0.0
955
955
  */
956
- const structureKeys = (o, keys) => hashUnordered(12289, keys, (key) => combine$4(hash(key), hash(o[key])));
956
+ const structureKeys = (o, keys) => hashUnordered(12289, keys, (key) => combine$5(hash(key), hash(o[key])));
957
957
  /**
958
958
  * Computes a structural hash for an object using Effect's object key collection.
959
959
  *
@@ -1028,18 +1028,18 @@ const hashUnordered = (seed, iter, f) => {
1028
1028
  */
1029
1029
  const array = (arr) => {
1030
1030
  let h = 6151;
1031
- for (const element of arr) h = combine$4(h, hash(element));
1031
+ for (const element of arr) h = combine$5(h, hash(element));
1032
1032
  return optimize(h);
1033
1033
  };
1034
1034
  const hashIndexed = (arr) => {
1035
1035
  let h = 6151;
1036
- for (let i = 0; i < arr.length; i++) h = combine$4(h, hash(arr[i]));
1036
+ for (let i = 0; i < arr.length; i++) h = combine$5(h, hash(arr[i]));
1037
1037
  return optimize(h);
1038
1038
  };
1039
1039
  const mapSeed = /*#__PURE__*/ string$2("Map");
1040
1040
  const setSeed = /*#__PURE__*/ string$2("Set");
1041
- const hashMapEntry = ([k, v]) => combine$4(hash(k), hash(v));
1042
- const hashSetElement = (element) => combine$4(setSeed, hash(element));
1041
+ const hashMapEntry = ([k, v]) => combine$5(hash(k), hash(v));
1042
+ const hashSetElement = (element) => combine$5(setSeed, hash(element));
1043
1043
  const randomHashCache = /*#__PURE__*/ new WeakMap();
1044
1044
  const visitedObjects = /*#__PURE__*/ new WeakSet();
1045
1045
  // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Equal.js
@@ -2088,6 +2088,35 @@ function isIterable(input) {
2088
2088
  return hasProperty(input, Symbol.iterator) || isString$1(input);
2089
2089
  }
2090
2090
  /**
2091
+ * Checks whether a value is a `RegExp`.
2092
+ *
2093
+ * **When to use**
2094
+ *
2095
+ * Use when you need a `Predicate` runtime guard for regular expressions.
2096
+ *
2097
+ * **Details**
2098
+ *
2099
+ * Uses `instanceof RegExp`.
2100
+ *
2101
+ * **Example** (Guarding RegExp values)
2102
+ *
2103
+ * ```ts import.meta.vitest
2104
+ * import { Predicate } from "effect"
2105
+ *
2106
+ * const data: unknown = /abc/
2107
+ *
2108
+ * Predicate.isRegExp(data) // => true
2109
+ * ```
2110
+ *
2111
+ * @see {@link isDate}
2112
+ * @stability stable
2113
+ * @category guards
2114
+ * @since 3.9.0
2115
+ */
2116
+ function isRegExp(input) {
2117
+ return input instanceof RegExp;
2118
+ }
2119
+ /**
2091
2120
  * Creates a predicate that returns `true` if either predicate is `true`.
2092
2121
  *
2093
2122
  * **When to use**
@@ -3010,7 +3039,7 @@ var Fail = class extends ReasonBase {
3010
3039
  }
3011
3040
  [symbol$3]() {
3012
3041
  const error = hash(this.error);
3013
- return combine$4(combine$4(hash(this.annotations), error), string$2(this._tag));
3042
+ return combine$5(combine$5(hash(this.annotations), error), string$2(this._tag));
3014
3043
  }
3015
3044
  };
3016
3045
  /** @internal */
@@ -3071,7 +3100,7 @@ var Die = class extends ReasonBase {
3071
3100
  }
3072
3101
  [symbol$3]() {
3073
3102
  const defect = hash(this.defect);
3074
- return combine$4(combine$4(hash(this.annotations), defect), string$2(this._tag));
3103
+ return combine$5(combine$5(hash(this.annotations), defect), string$2(this._tag));
3075
3104
  }
3076
3105
  };
3077
3106
  /** @internal */
@@ -3157,7 +3186,7 @@ const makeExit = (options) => {
3157
3186
  return isExit$1(that) && that._tag === this._tag && equals$1(this["~effect/Effect/args"], that["~effect/Effect/args"]);
3158
3187
  },
3159
3188
  [symbol$3]() {
3160
- return combine$4(opHash, hash(this[args]));
3189
+ return combine$5(opHash, hash(this[args]));
3161
3190
  }
3162
3191
  };
3163
3192
  const ExitPrimitive = function(value) {
@@ -3433,7 +3462,7 @@ const fiberCachedKeys = /*#__PURE__*/ new Set([
3433
3462
  * @category constructors
3434
3463
  * @since 2.0.0
3435
3464
  */
3436
- const make$91 = (isEquivalent) => (self, that) => self === that || isEquivalent(self, that);
3465
+ const make$92 = (isEquivalent) => (self, that) => self === that || isEquivalent(self, that);
3437
3466
  const isStrictEquivalent = (x, y) => x === y;
3438
3467
  /**
3439
3468
  * Creates an equivalence relation that uses strict equality (`===`) to compare values.
@@ -3543,7 +3572,7 @@ const strictEqual = () => isStrictEquivalent;
3543
3572
  * @since 4.0.0
3544
3573
  */
3545
3574
  function Tuple$1(elements) {
3546
- return make$91((self, that) => {
3575
+ return make$92((self, that) => {
3547
3576
  if (self.length !== that.length) return false;
3548
3577
  for (let i = 0; i < self.length; i++) if (!elements[i](self[i], that[i])) return false;
3549
3578
  return true;
@@ -3553,7 +3582,7 @@ function Tuple$1(elements) {
3553
3582
  * @since 4.0.0
3554
3583
  */
3555
3584
  function Array_(item) {
3556
- return make$91((self, that) => {
3585
+ return make$92((self, that) => {
3557
3586
  if (self.length !== that.length) return false;
3558
3587
  for (let i = 0; i < self.length; i++) if (!item(self[i], that[i])) return false;
3559
3588
  return true;
@@ -3578,7 +3607,7 @@ const SomeProto = /*#__PURE__*/ Object.defineProperty(/*#__PURE__*/ Object.assig
3578
3607
  return isOption$1(that) && isSome$1(that) && equals$1(this.value, that.value);
3579
3608
  },
3580
3609
  [symbol$3]() {
3581
- return combine$3(hash(this._tag))(hash(this.value));
3610
+ return combine$4(hash(this._tag))(hash(this.value));
3582
3611
  },
3583
3612
  toString() {
3584
3613
  return `some(${format$5(this.value)})`;
@@ -3649,7 +3678,7 @@ const SuccessProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(Com
3649
3678
  return isResult$1(that) && isSuccess$3(that) && equals$1(this.success, that.success);
3650
3679
  },
3651
3680
  [symbol$3]() {
3652
- return combine$3(hash(this._tag))(hash(this.success));
3681
+ return combine$4(hash(this._tag))(hash(this.success));
3653
3682
  },
3654
3683
  toString() {
3655
3684
  return `success(${format$5(this.success)})`;
@@ -3669,7 +3698,7 @@ const FailureProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(Com
3669
3698
  return isResult$1(that) && isFailure$2(that) && equals$1(this.failure, that.failure);
3670
3699
  },
3671
3700
  [symbol$3]() {
3672
- return combine$3(hash(this._tag))(hash(this.failure));
3701
+ return combine$4(hash(this._tag))(hash(this.failure));
3673
3702
  },
3674
3703
  toString() {
3675
3704
  return `failure(${format$5(this.failure)})`;
@@ -3754,7 +3783,7 @@ const getSuccess$1 = (self) => isFailure$2(self) ? none$1 : some$2(self.success)
3754
3783
  * @category constructors
3755
3784
  * @since 2.0.0
3756
3785
  */
3757
- function make$90(compare) {
3786
+ function make$91(compare) {
3758
3787
  return (self, that) => self === that ? 0 : compare(self, that);
3759
3788
  }
3760
3789
  /**
@@ -3785,7 +3814,7 @@ function make$90(compare) {
3785
3814
  * @category instances
3786
3815
  * @since 4.0.0
3787
3816
  */
3788
- const String$10 = /*#__PURE__*/ make$90((self, that) => self < that ? -1 : 1);
3817
+ const String$10 = /*#__PURE__*/ make$91((self, that) => self < that ? -1 : 1);
3789
3818
  /**
3790
3819
  * Order instance for numbers that compares them numerically.
3791
3820
  *
@@ -3818,7 +3847,7 @@ const String$10 = /*#__PURE__*/ make$90((self, that) => self < that ? -1 : 1);
3818
3847
  * @category instances
3819
3848
  * @since 4.0.0
3820
3849
  */
3821
- const Number$6 = /*#__PURE__*/ make$90((self, that) => {
3850
+ const Number$6 = /*#__PURE__*/ make$91((self, that) => {
3822
3851
  if (globalThis.Number.isNaN(self) && globalThis.Number.isNaN(that)) return 0;
3823
3852
  if (globalThis.Number.isNaN(self)) return -1;
3824
3853
  if (globalThis.Number.isNaN(that)) return 1;
@@ -3852,7 +3881,88 @@ const Number$6 = /*#__PURE__*/ make$90((self, that) => {
3852
3881
  * @category instances
3853
3882
  * @since 4.0.0
3854
3883
  */
3855
- const BigInt$5 = /*#__PURE__*/ make$90((self, that) => self < that ? -1 : 1);
3884
+ const BigInt$5 = /*#__PURE__*/ make$91((self, that) => self < that ? -1 : 1);
3885
+ /**
3886
+ * Creates a new `Order` that reverses the comparison order of the input `Order`.
3887
+ *
3888
+ * **When to use**
3889
+ *
3890
+ * Use when you need the reverse of an existing order.
3891
+ *
3892
+ * **Details**
3893
+ *
3894
+ * Returns a new order that swaps the arguments before comparison. If the
3895
+ * original order returns `-1`, the flipped order returns `1`, and vice versa.
3896
+ * Equal comparisons remain `0`.
3897
+ *
3898
+ * **Example** (Reversing an Order)
3899
+ *
3900
+ * ```ts import.meta.vitest
3901
+ * import { Order } from "effect"
3902
+ *
3903
+ * const flip = Order.flip(Order.Number)
3904
+ *
3905
+ * flip(1, 2) // => 1
3906
+ * flip(2, 1) // => -1
3907
+ * flip(1, 1) // => 0
3908
+ * ```
3909
+ *
3910
+ * @see {@link combine} to combine orders for multi-criteria comparison
3911
+ * @stability stable
3912
+ * @category combinators
3913
+ * @since 4.0.0
3914
+ */
3915
+ function flip$1(O) {
3916
+ return make$91((self, that) => O(that, self));
3917
+ }
3918
+ /**
3919
+ * Combines two `Order` instances to create a new `Order` that first compares using the first `Order`,
3920
+ * and if the values are equal, then compares using the second `Order`.
3921
+ *
3922
+ * **When to use**
3923
+ *
3924
+ * Use when you need tie-breaking with exactly two orders.
3925
+ *
3926
+ * **Details**
3927
+ *
3928
+ * First applies the first order. If the result is non-zero, that result is
3929
+ * returned; otherwise, the second order is applied. The result is the first
3930
+ * non-zero comparison result, or `0` if both orders return `0`.
3931
+ *
3932
+ * **Example** (Combining two Orders)
3933
+ *
3934
+ * ```ts import.meta.vitest
3935
+ * import { Order } from "effect"
3936
+ *
3937
+ * const byAge = Order.mapInput(
3938
+ * Order.Number,
3939
+ * (person: { name: string; age: number }) => person.age
3940
+ * )
3941
+ * const byName = Order.mapInput(
3942
+ * Order.String,
3943
+ * (person: { name: string; age: number }) => person.name
3944
+ * )
3945
+ * const byAgeAndName = Order.combine(byAge, byName)
3946
+ *
3947
+ * const person1 = { name: "Alice", age: 30 }
3948
+ * const person2 = { name: "Bob", age: 30 }
3949
+ * const person3 = { name: "Charlie", age: 25 }
3950
+ *
3951
+ * byAgeAndName(person1, person2) // => -1
3952
+ * byAgeAndName(person1, person3) // => 1
3953
+ * ```
3954
+ *
3955
+ * @see {@link combineAll} to combine multiple orders from a collection
3956
+ * @see {@link mapInput} to transform orders to work with different types
3957
+ * @stability stable
3958
+ * @category combining
3959
+ * @since 2.0.0
3960
+ */
3961
+ const combine$3 = /*#__PURE__*/ dual(2, (self, that) => make$91((a1, a2) => {
3962
+ const out = self(a1, a2);
3963
+ if (out !== 0) return out;
3964
+ return that(a1, a2);
3965
+ }));
3856
3966
  /**
3857
3967
  * Transforms an `Order` on type `A` into an `Order` on type `B` by providing a function that
3858
3968
  * maps values of type `B` to values of type `A`.
@@ -3886,7 +3996,7 @@ const BigInt$5 = /*#__PURE__*/ make$90((self, that) => self < that ? -1 : 1);
3886
3996
  * @category mapping
3887
3997
  * @since 2.0.0
3888
3998
  */
3889
- const mapInput = /*#__PURE__*/ dual(2, (self, f) => make$90((b1, b2) => self(f(b1), f(b2))));
3999
+ const mapInput = /*#__PURE__*/ dual(2, (self, f) => make$91((b1, b2) => self(f(b1), f(b2))));
3890
4000
  /**
3891
4001
  * Checks whether one value is strictly less than another according to the given order.
3892
4002
  *
@@ -4043,7 +4153,7 @@ const isGreaterThanOrEqualTo$2 = (O) => dual(2, (self, that) => O(self, that) !=
4043
4153
  * @category comparisons
4044
4154
  * @since 2.0.0
4045
4155
  */
4046
- const min$2 = (O) => dual(2, (self, that) => self === that || O(self, that) < 1 ? self : that);
4156
+ const min$3 = (O) => dual(2, (self, that) => self === that || O(self, that) < 1 ? self : that);
4047
4157
  /**
4048
4158
  * Returns the maximum of two values according to the given order. If they are equal, returns the first argument.
4049
4159
  *
@@ -4075,7 +4185,7 @@ const min$2 = (O) => dual(2, (self, that) => self === that || O(self, that) < 1
4075
4185
  * @category comparisons
4076
4186
  * @since 2.0.0
4077
4187
  */
4078
- const max$1 = (O) => dual(2, (self, that) => self === that || O(self, that) > -1 ? self : that);
4188
+ const max$2 = (O) => dual(2, (self, that) => self === that || O(self, that) > -1 ? self : that);
4079
4189
  // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Option.js
4080
4190
  /**
4081
4191
  * Creates an `Option` representing the absence of a value.
@@ -4958,7 +5068,7 @@ const Service$1 = function() {
4958
5068
  const ServiceProto = /*#__PURE__*/ Object.assign({ [ServiceTypeId]: ServiceTypeId }, /*#__PURE__*/ Prototype({
4959
5069
  label: "Service",
4960
5070
  evaluate(fiber) {
4961
- return exitSucceed(get$12(fiber.context, this));
5071
+ return exitSucceed(get$13(fiber.context, this));
4962
5072
  }
4963
5073
  }), {
4964
5074
  toJSON() {
@@ -4971,13 +5081,13 @@ const ServiceProto = /*#__PURE__*/ Object.assign({ [ServiceTypeId]: ServiceTypeI
4971
5081
  return self;
4972
5082
  },
4973
5083
  context(self) {
4974
- return make$89(this, self);
5084
+ return make$90(this, self);
4975
5085
  },
4976
5086
  use(f) {
4977
- return withFiber$1((fiber) => f(get$12(fiber.context, this)));
5087
+ return withFiber$1((fiber) => f(get$13(fiber.context, this)));
4978
5088
  },
4979
5089
  useSync(f) {
4980
- return withFiber$1((fiber) => exitSucceed(f(get$12(fiber.context, this))));
5090
+ return withFiber$1((fiber) => exitSucceed(f(get$13(fiber.context, this))));
4981
5091
  }
4982
5092
  });
4983
5093
  const ReferenceTypeId = "~effect/Context/Reference";
@@ -5214,7 +5324,7 @@ const emptyContext = /*#__PURE__*/ makeUnsafe$9(/*#__PURE__*/ new Map());
5214
5324
  * @category constructors
5215
5325
  * @since 2.0.0
5216
5326
  */
5217
- const make$89 = (key, service) => makeUnsafe$9(/* @__PURE__ */ new Map([[key.key, service]]));
5327
+ const make$90 = (key, service) => makeUnsafe$9(/* @__PURE__ */ new Map([[key.key, service]]));
5218
5328
  /**
5219
5329
  * Adds a service to a given `Context`.
5220
5330
  *
@@ -5376,7 +5486,7 @@ const getUnsafe$1 = /*#__PURE__*/ dual(2, (self, service) => {
5376
5486
  * @category getters
5377
5487
  * @since 2.0.0
5378
5488
  */
5379
- const get$12 = getUnsafe$1;
5489
+ const get$13 = getUnsafe$1;
5380
5490
  const defaultValueCacheKey = "~effect/Context/defaultValue";
5381
5491
  const getDefaultValue = (ref) => {
5382
5492
  if (defaultValueCacheKey in ref) return ref[defaultValueCacheKey];
@@ -5633,7 +5743,7 @@ const bigintNanosPerDay = /*#__PURE__*/ BigInt(864e11);
5633
5743
  const bigintNanosPerWeek = /*#__PURE__*/ BigInt(6048e11);
5634
5744
  const roundTiesAwayFromZero = (input) => BigInt(Math.sign(input) * Math.round(Math.abs(input)));
5635
5745
  const roundMillisToNanos = (millis) => Number.isInteger(millis) ? BigInt(millis) * bigint1e6 : roundTiesAwayFromZero(millis * 1e6);
5636
- const fromNanosNumber = (nanos) => make$88(Number.isFinite(nanos) ? roundTiesAwayFromZero(nanos) : nanos);
5746
+ const fromNanosNumber = (nanos) => make$89(Number.isFinite(nanos) ? roundTiesAwayFromZero(nanos) : nanos);
5637
5747
  const nanosToUnit = (nanos, divisor) => {
5638
5748
  const value = Number(nanos);
5639
5749
  if (Number.isFinite(value)) return value / divisor;
@@ -5656,9 +5766,9 @@ const divideTiesAwayFromZero = (numerator, denominator) => {
5656
5766
  };
5657
5767
  const fromMillisString = (input, scale) => {
5658
5768
  const millis = Number(input) * scale;
5659
- if (!Number.isFinite(millis)) return make$88(millis);
5769
+ if (!Number.isFinite(millis)) return make$89(millis);
5660
5770
  const nanos = parseNanos(input, BigInt(scale) * bigint1e6);
5661
- return make$88(Number.isInteger(millis) && BigInt(millis) * bigint1e6 === nanos ? millis : nanos);
5771
+ return make$89(Number.isInteger(millis) && BigInt(millis) * bigint1e6 === nanos ? millis : nanos);
5662
5772
  };
5663
5773
  const DURATION_REGEXP = /^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/;
5664
5774
  /**
@@ -5725,7 +5835,7 @@ const fromInputUnsafe$1 = (input) => {
5725
5835
  if (input[0] === -Infinity || input[1] === -Infinity) return negativeInfinity;
5726
5836
  if (input[0] === Infinity || input[1] === Infinity) return infinity$1;
5727
5837
  const nanos = input[0] * 1e9 + input[1];
5728
- return Number.isFinite(nanos) && Number.isInteger(input[0]) && Number.isInteger(input[1]) ? make$88(BigInt(input[0]) * bigint1e9 + BigInt(input[1])) : fromNanosNumber(nanos);
5838
+ return Number.isFinite(nanos) && Number.isInteger(input[0]) && Number.isInteger(input[1]) ? make$89(BigInt(input[0]) * bigint1e9 + BigInt(input[1])) : fromNanosNumber(nanos);
5729
5839
  }
5730
5840
  const obj = input;
5731
5841
  let millis = 0;
@@ -5736,13 +5846,13 @@ const fromInputUnsafe$1 = (input) => {
5736
5846
  if (obj.seconds) millis += obj.seconds * 1e3;
5737
5847
  if (obj.milliseconds) millis += obj.milliseconds;
5738
5848
  if (!obj.microseconds && !obj.nanoseconds) {
5739
- if (!Number.isFinite(millis)) return make$88(millis);
5849
+ if (!Number.isFinite(millis)) return make$89(millis);
5740
5850
  const exact = sumObjectNanos(obj);
5741
- return exact === void 0 || BigInt(millis) * bigint1e6 === exact ? make$88(millis) : make$88(exact);
5851
+ return exact === void 0 || BigInt(millis) * bigint1e6 === exact ? make$89(millis) : make$89(exact);
5742
5852
  }
5743
5853
  const nanos = millis * 1e6 + (obj.microseconds ?? 0) * 1e3 + (obj.nanoseconds ?? 0);
5744
5854
  const exact = Number.isFinite(nanos) ? sumObjectNanos(obj) : void 0;
5745
- return exact === void 0 ? fromNanosNumber(nanos) : make$88(exact);
5855
+ return exact === void 0 ? fromNanosNumber(nanos) : make$89(exact);
5746
5856
  }
5747
5857
  }
5748
5858
  return invalid$3(input);
@@ -5837,7 +5947,7 @@ const DurationProto = {
5837
5947
  return pipeArguments(this, arguments);
5838
5948
  }
5839
5949
  };
5840
- const make$88 = (input) => {
5950
+ const make$89 = (input) => {
5841
5951
  const duration = Object.create(DurationProto);
5842
5952
  if (typeof input === "number") {
5843
5953
  if (isNaN(input) || input === 0 || Object.is(input, -0)) duration.value = zeroDurationValue;
@@ -5960,8 +6070,8 @@ const abs = (self) => {
5960
6070
  switch (self.value._tag) {
5961
6071
  case "Infinity":
5962
6072
  case "NegativeInfinity": return infinity$1;
5963
- case "Millis": return self.value.millis < 0 ? make$88(-self.value.millis) : self;
5964
- case "Nanos": return self.value.nanos < bigint0$5 ? make$88(-self.value.nanos) : self;
6073
+ case "Millis": return self.value.millis < 0 ? make$89(-self.value.millis) : self;
6074
+ case "Nanos": return self.value.nanos < bigint0$5 ? make$89(-self.value.nanos) : self;
5965
6075
  }
5966
6076
  };
5967
6077
  /**
@@ -5979,7 +6089,7 @@ const abs = (self) => {
5979
6089
  * @category constructors
5980
6090
  * @since 2.0.0
5981
6091
  */
5982
- const zero$2 = /*#__PURE__*/ make$88(0);
6092
+ const zero$2 = /*#__PURE__*/ make$89(0);
5983
6093
  /**
5984
6094
  * A Duration representing infinite time.
5985
6095
  *
@@ -5995,7 +6105,7 @@ const zero$2 = /*#__PURE__*/ make$88(0);
5995
6105
  * @category constructors
5996
6106
  * @since 2.0.0
5997
6107
  */
5998
- const infinity$1 = /*#__PURE__*/ make$88(Infinity);
6108
+ const infinity$1 = /*#__PURE__*/ make$89(Infinity);
5999
6109
  /**
6000
6110
  * A Duration representing negative infinite time.
6001
6111
  *
@@ -6011,7 +6121,7 @@ const infinity$1 = /*#__PURE__*/ make$88(Infinity);
6011
6121
  * @category constructors
6012
6122
  * @since 4.0.0
6013
6123
  */
6014
- const negativeInfinity = /*#__PURE__*/ make$88(-Infinity);
6124
+ const negativeInfinity = /*#__PURE__*/ make$89(-Infinity);
6015
6125
  /**
6016
6126
  * Creates a Duration from nanoseconds.
6017
6127
  *
@@ -6027,7 +6137,7 @@ const negativeInfinity = /*#__PURE__*/ make$88(-Infinity);
6027
6137
  * @category constructors
6028
6138
  * @since 2.0.0
6029
6139
  */
6030
- const nanos = (nanos) => make$88(nanos);
6140
+ const nanos = (nanos) => make$89(nanos);
6031
6141
  /**
6032
6142
  * Creates a Duration from milliseconds.
6033
6143
  *
@@ -6043,7 +6153,7 @@ const nanos = (nanos) => make$88(nanos);
6043
6153
  * @category constructors
6044
6154
  * @since 2.0.0
6045
6155
  */
6046
- const millis = (millis) => make$88(millis);
6156
+ const millis = (millis) => make$89(millis);
6047
6157
  /**
6048
6158
  * Creates a Duration from seconds.
6049
6159
  *
@@ -6059,7 +6169,7 @@ const millis = (millis) => make$88(millis);
6059
6169
  * @category constructors
6060
6170
  * @since 2.0.0
6061
6171
  */
6062
- const seconds = (seconds) => make$88(seconds * 1e3);
6172
+ const seconds = (seconds) => make$89(seconds * 1e3);
6063
6173
  /**
6064
6174
  * Creates a Duration from minutes.
6065
6175
  *
@@ -6075,7 +6185,7 @@ const seconds = (seconds) => make$88(seconds * 1e3);
6075
6185
  * @category constructors
6076
6186
  * @since 2.0.0
6077
6187
  */
6078
- const minutes = (minutes) => make$88(minutes * 6e4);
6188
+ const minutes = (minutes) => make$89(minutes * 6e4);
6079
6189
  /**
6080
6190
  * Creates a Duration from hours.
6081
6191
  *
@@ -6091,7 +6201,7 @@ const minutes = (minutes) => make$88(minutes * 6e4);
6091
6201
  * @category constructors
6092
6202
  * @since 2.0.0
6093
6203
  */
6094
- const hours = (hours) => make$88(hours * 36e5);
6204
+ const hours = (hours) => make$89(hours * 36e5);
6095
6205
  /**
6096
6206
  * Converts a Duration to milliseconds.
6097
6207
  *
@@ -6258,7 +6368,7 @@ const matchPair = /*#__PURE__*/ dual(3, (self, that, options) => {
6258
6368
  * @category instances
6259
6369
  * @since 2.0.0
6260
6370
  */
6261
- const Order$6 = /*#__PURE__*/ make$90((self, that) => matchPair(self, that, {
6371
+ const Order$6 = /*#__PURE__*/ make$91((self, that) => matchPair(self, that, {
6262
6372
  onMillis: (self, that) => self < that ? -1 : self > that ? 1 : 0,
6263
6373
  onNanos: (self, that) => self < that ? -1 : self > that ? 1 : 0,
6264
6374
  onInfinity: (self, that) => {
@@ -6304,7 +6414,7 @@ const Equivalence$3 = (self, that) => matchPair(self, that, {
6304
6414
  * @category ordering
6305
6415
  * @since 2.0.0
6306
6416
  */
6307
- const min$1 = /*#__PURE__*/ min$2(Order$6);
6417
+ const min$2 = /*#__PURE__*/ min$3(Order$6);
6308
6418
  /**
6309
6419
  * Returns the larger of two Durations.
6310
6420
  *
@@ -6320,7 +6430,7 @@ const min$1 = /*#__PURE__*/ min$2(Order$6);
6320
6430
  * @category ordering
6321
6431
  * @since 2.0.0
6322
6432
  */
6323
- const max = /*#__PURE__*/ max$1(Order$6);
6433
+ const max$1 = /*#__PURE__*/ max$2(Order$6);
6324
6434
  /**
6325
6435
  * Adds two Durations together.
6326
6436
  *
@@ -6347,8 +6457,8 @@ const max = /*#__PURE__*/ max$1(Order$6);
6347
6457
  * @since 2.0.0
6348
6458
  */
6349
6459
  const sum = /*#__PURE__*/ dual(2, (self, that) => matchPair(self, that, {
6350
- onMillis: (self, that) => make$88(self + that),
6351
- onNanos: (self, that) => make$88(self + that),
6460
+ onMillis: (self, that) => make$89(self + that),
6461
+ onNanos: (self, that) => make$89(self + that),
6352
6462
  onInfinity: (self, that) => {
6353
6463
  const s = self.value._tag;
6354
6464
  const t = that.value._tag;
@@ -6968,6 +7078,34 @@ const all$4 = (input) => {
6968
7078
  };
6969
7079
  // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Tuple.js
6970
7080
  /**
7081
+ * Creates a tuple from the provided arguments.
7082
+ *
7083
+ * **When to use**
7084
+ *
7085
+ * Use when you need a properly typed tuple without writing `[a, b, c] as const`
7086
+ * or another manual cast.
7087
+ *
7088
+ * **Details**
7089
+ *
7090
+ * The returned value has the exact tuple type, with each element's literal type
7091
+ * preserved.
7092
+ *
7093
+ * **Example** (Creating a tuple)
7094
+ *
7095
+ * ```ts import.meta.vitest
7096
+ * import { Tuple } from "effect"
7097
+ *
7098
+ * Tuple.make(10, 20, "red") // => [10, 20, "red"]
7099
+ * ```
7100
+ *
7101
+ * @see {@link get} – access a single element by index
7102
+ * @see {@link appendElement} – append an element to a tuple
7103
+ * @stability stable
7104
+ * @category constructors
7105
+ * @since 2.0.0
7106
+ */
7107
+ const make$88 = (...elements) => elements;
7108
+ /**
6971
7109
  * Creates an `Equivalence` for tuples by comparing corresponding elements
6972
7110
  * using the provided per-position `Equivalence`s. Two tuples are equivalent
6973
7111
  * when all their corresponding elements are equivalent.
@@ -7209,7 +7347,37 @@ const has$3 = /*#__PURE__*/ dual(2, (self, key) => Object.hasOwn(self, key));
7209
7347
  * @category getters
7210
7348
  * @since 2.0.0
7211
7349
  */
7212
- const get$11 = /*#__PURE__*/ dual(2, (self, key) => Object.hasOwn(self, key) ? some$1(self[key]) : none());
7350
+ const get$12 = /*#__PURE__*/ dual(2, (self, key) => Object.hasOwn(self, key) ? some$1(self[key]) : none());
7351
+ /**
7352
+ * Removes a key from a record.
7353
+ *
7354
+ * **When to use**
7355
+ *
7356
+ * Use to create a shallow copy of a record without one property.
7357
+ *
7358
+ * **Details**
7359
+ *
7360
+ * If the key is not present, the result is still a shallow copy of the original
7361
+ * record.
7362
+ *
7363
+ * **Example** (Removing a key)
7364
+ *
7365
+ * ```ts import.meta.vitest
7366
+ * import { Record } from "effect"
7367
+ *
7368
+ * Record.remove({ a: 1, b: 2 }, "a") // => { b: 2 }
7369
+ * ```
7370
+ *
7371
+ * @stability stable
7372
+ * @category mutations
7373
+ * @since 2.0.0
7374
+ */
7375
+ const remove$5 = /*#__PURE__*/ dual(2, (self, key) => {
7376
+ if (!has$3(self, key)) return { ...self };
7377
+ const out = { ...self };
7378
+ delete out[key];
7379
+ return out;
7380
+ });
7213
7381
  /**
7214
7382
  * Maps a record into another record by applying a transformation function to each of its values.
7215
7383
  *
@@ -7710,7 +7878,7 @@ function isOutOfBounds(i, as) {
7710
7878
  * @category getters
7711
7879
  * @since 2.0.0
7712
7880
  */
7713
- const get$10 = /*#__PURE__*/ dual(2, (self, index) => {
7881
+ const get$11 = /*#__PURE__*/ dual(2, (self, index) => {
7714
7882
  const i = Math.floor(index);
7715
7883
  return isOutOfBounds(i, self) ? none() : some$1(self[i]);
7716
7884
  });
@@ -7771,7 +7939,7 @@ const getUnsafe = /*#__PURE__*/ dual(2, (self, index) => {
7771
7939
  * @category getters
7772
7940
  * @since 2.0.0
7773
7941
  */
7774
- const head = /*#__PURE__*/ get$10(0);
7942
+ const head = /*#__PURE__*/ get$11(0);
7775
7943
  /**
7776
7944
  * Returns the first element of a `NonEmptyReadonlyArray` directly (no `Option`
7777
7945
  * wrapper).
@@ -8444,6 +8612,26 @@ const flatMapNullishOr = /*#__PURE__*/ dual(2, (self, f) => flatMap$6(self, (a)
8444
8612
  */
8445
8613
  const some = /*#__PURE__*/ dual(2, (self, predicate) => self.some(predicate));
8446
8614
  /**
8615
+ * Returns the minimum element of a non-empty array according to the given
8616
+ * `Order`.
8617
+ *
8618
+ * **Example** (Finding the minimum)
8619
+ *
8620
+ * ```ts import.meta.vitest
8621
+ * import { Array, Order } from "effect"
8622
+ *
8623
+ * Array.min([3, 1, 2], Order.Number) // => 1
8624
+ * ```
8625
+ *
8626
+ * @see {@link max} — find the maximum
8627
+ * @see {@link sort} — sort the entire array
8628
+ *
8629
+ * @stability stable
8630
+ * @category getters
8631
+ * @since 2.0.0
8632
+ */
8633
+ const min$1 = /*#__PURE__*/ dual(2, (self, O) => self.reduce(min$3(O)));
8634
+ /**
8447
8635
  * Creates an `Equivalence` for arrays based on an element `Equivalence`. Two
8448
8636
  * arrays are equivalent when they have the same length and all elements are
8449
8637
  * pairwise equivalent.
@@ -11441,6 +11629,8 @@ const makeLatchUnsafe = (open) => new Latch(open ?? false);
11441
11629
  /** @internal */
11442
11630
  const makeLatch = (open) => sync$2(() => makeLatchUnsafe(open));
11443
11631
  /** @internal */
11632
+ const tracer$2 = /*#__PURE__*/ withFiber$1((fiber) => succeed$9(fiber.getRef(Tracer)));
11633
+ /** @internal */
11444
11634
  const withTracerEnabled$1 = /*#__PURE__*/ provideService$3(TracerEnabled$1);
11445
11635
  const bigint0$4 = /*#__PURE__*/ BigInt(0);
11446
11636
  const NoopSpanProto = {
@@ -11467,11 +11657,11 @@ const noopSpan = (options) => Object.assign(Object.create(NoopSpanProto), option
11467
11657
  /** @internal */
11468
11658
  const filterDisablePropagation = (span) => {
11469
11659
  if (!span) return none();
11470
- return get$12(span.annotations, DisablePropagation) ? span._tag === "Span" ? filterDisablePropagation(getOrUndefined$2(span.parent)) : none() : some$1(span);
11660
+ return get$13(span.annotations, DisablePropagation) ? span._tag === "Span" ? filterDisablePropagation(getOrUndefined$2(span.parent)) : none() : some$1(span);
11471
11661
  };
11472
11662
  /** @internal */
11473
11663
  const makeSpanUnsafe = (fiber, name, options) => {
11474
- const disablePropagation = !fiber.cache.tracerEnabled || options?.annotations && get$12(options.annotations, DisablePropagation);
11664
+ const disablePropagation = !fiber.cache.tracerEnabled || options?.annotations && get$13(options.annotations, DisablePropagation);
11475
11665
  const parent = options?.parent !== void 0 ? some$1(options.parent) : options?.root ? none() : filterDisablePropagation(fiber.cache.span);
11476
11666
  let span;
11477
11667
  if (disablePropagation) span = noopSpan({
@@ -11775,7 +11965,7 @@ const logWithLevel = (level) => (...message) => {
11775
11965
  return void_$4;
11776
11966
  });
11777
11967
  };
11778
- const colors = {
11968
+ const colors$1 = {
11779
11969
  bold: "1",
11780
11970
  red: "31",
11781
11971
  green: "32",
@@ -11787,7 +11977,7 @@ const colors = {
11787
11977
  black: "30",
11788
11978
  bgBrightRed: "101"
11789
11979
  };
11790
- colors.gray, colors.blue, colors.green, colors.yellow, colors.red, colors.bgBrightRed, colors.black;
11980
+ colors$1.gray, colors$1.blue, colors$1.green, colors$1.yellow, colors$1.red, colors$1.bgBrightRed, colors$1.black;
11791
11981
  const defaultDateFormat = (date) => `${date.getHours().toString().padStart(2, "0")}:${date.getMinutes().toString().padStart(2, "0")}:${date.getSeconds().toString().padStart(2, "0")}.${date.getMilliseconds().toString().padStart(3, "0")}`;
11792
11982
  /** @internal */
11793
11983
  const defaultLogger = /*#__PURE__*/ loggerMake(({ cause, date, fiber, logLevel, message }) => {
@@ -13534,8 +13724,8 @@ const buildWithScope = /*#__PURE__*/ dual(2, (self, scope) => withFiber$1((fiber
13534
13724
  * @since 2.0.0
13535
13725
  */
13536
13726
  const succeed$6 = function() {
13537
- if (arguments.length === 1) return (resource) => succeedContext(make$89(arguments[0], resource));
13538
- return succeedContext(make$89(arguments[0], arguments[1]));
13727
+ if (arguments.length === 1) return (resource) => succeedContext(make$90(arguments[0], resource));
13728
+ return succeedContext(make$90(arguments[0], arguments[1]));
13539
13729
  };
13540
13730
  /**
13541
13731
  * Constructs a layer that provides all services in an already available
@@ -13647,8 +13837,8 @@ const empty$11 = /*#__PURE__*/ succeedContext(/*#__PURE__*/ empty$14());
13647
13837
  * @since 2.0.0
13648
13838
  */
13649
13839
  const sync$1 = function() {
13650
- if (arguments.length === 1) return (evaluate) => syncContext(() => make$89(arguments[0], evaluate()));
13651
- return syncContext(() => make$89(arguments[0], arguments[1]()));
13840
+ if (arguments.length === 1) return (evaluate) => syncContext(() => make$90(arguments[0], evaluate()));
13841
+ return syncContext(() => make$90(arguments[0], arguments[1]()));
13652
13842
  };
13653
13843
  /**
13654
13844
  * Constructs a layer lazily that provides all services in a `Context`.
@@ -13732,7 +13922,7 @@ const effect = function() {
13732
13922
  if (arguments.length === 1) return (effect) => effectImpl(arguments[0], effect);
13733
13923
  return effectImpl(arguments[0], arguments[1]);
13734
13924
  };
13735
- const effectImpl = (service, effect) => effectContext(map$9(effect, (value) => make$89(service, value)));
13925
+ const effectImpl = (service, effect) => effectContext(map$9(effect, (value) => make$90(service, value)));
13736
13926
  /**
13737
13927
  * Constructs a layer from an effect that produces all services in a `Context`.
13738
13928
  *
@@ -13840,7 +14030,7 @@ const unwrapKey = /*#__PURE__*/ Service$1("effect/Layer/unwrap");
13840
14030
  * @category converting
13841
14031
  * @since 4.0.0
13842
14032
  */
13843
- const unwrap$7 = (self) => flatMap$4(effect(unwrapKey)(self), get$12(unwrapKey));
14033
+ const unwrap$7 = (self) => flatMap$4(effect(unwrapKey)(self), get$13(unwrapKey));
13844
14034
  const mergeAllEffect = (layers, memoMap, scope) => {
13845
14035
  const parentScope = forkUnsafe(scope, "parallel");
13846
14036
  return forEach$2(layers, (layer) => layer.build(memoMap, forkUnsafe(parentScope, "sequential")), { concurrency: layers.length }).pipe(map$9((context) => mergeAll$2(...context)));
@@ -15359,7 +15549,7 @@ const ProtoZoned = {
15359
15549
  ...Proto$19,
15360
15550
  _tag: "Zoned",
15361
15551
  [symbol$3]() {
15362
- return combine$3(number$2(this.epochMilliseconds))(hash(this.zone));
15552
+ return combine$4(number$2(this.epochMilliseconds))(hash(this.zone));
15363
15553
  },
15364
15554
  [symbol$2](that) {
15365
15555
  return isDateTime$1(that) && that._tag === "Zoned" && this.epochMilliseconds === that.epochMilliseconds && equals$1(this.zone, that.zone);
@@ -15467,7 +15657,7 @@ const isUtc$1 = (self) => self._tag === "Utc";
15467
15657
  /** @internal */
15468
15658
  const isZoned = (self) => self._tag === "Zoned";
15469
15659
  /** @internal */
15470
- const Order$5 = /*#__PURE__*/ make$90((self, that) => self.epochMilliseconds < that.epochMilliseconds ? -1 : self.epochMilliseconds > that.epochMilliseconds ? 1 : 0);
15660
+ const Order$5 = /*#__PURE__*/ make$91((self, that) => self.epochMilliseconds < that.epochMilliseconds ? -1 : self.epochMilliseconds > that.epochMilliseconds ? 1 : 0);
15471
15661
  const makeUtc = (epochMillis) => {
15472
15662
  const self = Object.create(ProtoUtc);
15473
15663
  self.epochMilliseconds = epochMillis;
@@ -15823,6 +16013,52 @@ const Number$5 = globalThis.Number;
15823
16013
  */
15824
16014
  const Order$4 = Number$6;
15825
16015
  /**
16016
+ * Returns the maximum between two `number`s.
16017
+ *
16018
+ * **When to use**
16019
+ *
16020
+ * Use to select the larger of two numbers.
16021
+ *
16022
+ * **Example** (Finding the maximum)
16023
+ *
16024
+ * ```ts import.meta.vitest
16025
+ * import { Number } from "effect"
16026
+ *
16027
+ * Number.max(2, 3) // => 3
16028
+ * ```
16029
+ *
16030
+ * @see {@link min} for selecting the smaller value
16031
+ *
16032
+ * @stability stable
16033
+ * @category math
16034
+ * @since 2.0.0
16035
+ */
16036
+ const max = /*#__PURE__*/ max$2(Order$4);
16037
+ /**
16038
+ * Returns the next power of 2 from the given number.
16039
+ *
16040
+ * **When to use**
16041
+ *
16042
+ * Use to round a number up to the next power of two.
16043
+ *
16044
+ * **Example** (Finding the next power of two)
16045
+ *
16046
+ * ```ts import.meta.vitest
16047
+ * import { Number } from "effect"
16048
+ *
16049
+ * Number.nextPow2(5) // => 8
16050
+ * Number.nextPow2(17) // => 32
16051
+ * ```
16052
+ *
16053
+ * @stability stable
16054
+ * @category math
16055
+ * @since 2.0.0
16056
+ */
16057
+ const nextPow2 = (n) => {
16058
+ const nextPow = Math.pow(2, Math.ceil(Math.log2(n)));
16059
+ return Math.max(nextPow < n ? nextPow * 2 : nextPow, 2);
16060
+ };
16061
+ /**
15826
16062
  * Parses a `number` from a `string` safely using the `Number()` function.
15827
16063
  * The following special string values are supported: "NaN", "Infinity", "-Infinity".
15828
16064
  *
@@ -16168,6 +16404,71 @@ const match$2 = (regExp) => (self) => fromNullOr(self.match(regExp));
16168
16404
  * @since 2.0.0
16169
16405
  */
16170
16406
  const replaceAll = (searchValue, replaceValue) => (self) => self.replaceAll(searchValue, replaceValue);
16407
+ /**
16408
+ * Normalizes a string by splitting it into word parts, transforming each part,
16409
+ * and joining the parts with a configurable delimiter. By default, words contain
16410
+ * Unicode letters, combining marks, and numbers; no Unicode normalization is applied.
16411
+ *
16412
+ * **When to use**
16413
+ *
16414
+ * Use when you need custom word-case output with a delimiter or part transform
16415
+ * that the fixed case helpers do not provide.
16416
+ *
16417
+ * @see {@link pascalCase} for fixed PascalCase output
16418
+ * @see {@link camelCase} for fixed lower-initial camelCase output
16419
+ * @see {@link constantCase} for fixed uppercase underscore-separated output
16420
+ * @see {@link kebabCase} for fixed lowercase hyphen-separated output
16421
+ * @see {@link snakeCase} for fixed lowercase underscore-separated output
16422
+ *
16423
+ * @stability stable
16424
+ * @category transforming
16425
+ * @since 4.0.0
16426
+ */
16427
+ const noCase = /*#__PURE__*/ dual((args) => typeof args[0] === "string", (input, options) => {
16428
+ const splitRegExp = toRegExpArray(options?.splitRegExp ?? SPLIT_REGEXP);
16429
+ const stripRegExp = toRegExpArray(options?.stripRegExp ?? STRIP_REGEXP);
16430
+ const delimiter = options?.delimiter ?? " ";
16431
+ const transform = options?.transform ?? toLowerCase;
16432
+ return normalizeCase(input, splitRegExp, stripRegExp, delimiter, transform);
16433
+ });
16434
+ const toRegExpArray = (regexp) => isRegExp(regexp) ? [regexp] : regexp;
16435
+ const normalizeCase = (input, splitRegExp, stripRegExp, delimiter, transform) => {
16436
+ let result = input;
16437
+ for (const regexp of splitRegExp) result = result.replace(regexp, "$1\0$2");
16438
+ for (const regexp of stripRegExp) result = result.replace(regexp, "\0");
16439
+ let start = 0;
16440
+ let end = result.length;
16441
+ while (result.charAt(start) === "\0") start++;
16442
+ while (result.charAt(end - 1) === "\0") end--;
16443
+ if (start >= end) return "";
16444
+ return result.slice(start, end).split("\0").map(transform).join(delimiter);
16445
+ };
16446
+ const SPLIT_REGEXP = [
16447
+ /([\p{Ll}\p{N}]\p{M}*)(\p{Lu})/gu,
16448
+ /(\p{Lu}\p{M}*)(\p{Lu}\p{M}*\p{Ll})/gu,
16449
+ /(\p{L}\p{M}*)(\p{N})/gu,
16450
+ /(\p{N}\p{M}*)(\p{L})/gu
16451
+ ];
16452
+ const STRIP_REGEXP = /[^\p{L}\p{M}\p{N}]+/gu;
16453
+ /**
16454
+ * Converts a string to kebab-case (lowercase with hyphens).
16455
+ *
16456
+ * **When to use**
16457
+ *
16458
+ * Use to normalize free-form labels, identifiers, or keys into lowercase
16459
+ * hyphen-separated text.
16460
+ *
16461
+ * @see {@link noCase} for configurable delimiters and part transforms
16462
+ * @see {@link snakeCase} for lowercase underscore-separated output
16463
+ * @see {@link constantCase} for uppercase underscore-separated output
16464
+ * @see {@link camelCase} for lower-initial camelCase output
16465
+ * @see {@link pascalCase} for upper-initial PascalCase output
16466
+ *
16467
+ * @stability stable
16468
+ * @category transforming
16469
+ * @since 4.0.0
16470
+ */
16471
+ const kebabCase = /*#__PURE__*/ noCase({ delimiter: "-" });
16171
16472
  // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/internal/random.js
16172
16473
  /** @internal */
16173
16474
  const Random$1 = /*#__PURE__*/ Reference("effect/Random", { defaultValue: () => ({
@@ -16628,7 +16929,7 @@ const minDuration = (results) => {
16628
16929
  let min = void 0;
16629
16930
  for (let i = 0; i < results.length; i++) {
16630
16931
  const duration = results[i];
16631
- if (duration !== void 0) min = min === void 0 ? duration : min$1(min, duration);
16932
+ if (duration !== void 0) min = min === void 0 ? duration : min$2(min, duration);
16632
16933
  }
16633
16934
  return min;
16634
16935
  };
@@ -17069,7 +17370,7 @@ const fromIterable$5 = (entries) => {
17069
17370
  * @category getters
17070
17371
  * @since 2.0.0
17071
17372
  */
17072
- const get$9 = /*#__PURE__*/ dual(2, (self, key) => {
17373
+ const get$10 = /*#__PURE__*/ dual(2, (self, key) => {
17073
17374
  if (self.backing.has(key)) return some$1(self.backing.get(key));
17074
17375
  else if (isSimpleKey(key)) return none();
17075
17376
  const hash$4 = hash(key);
@@ -21499,6 +21800,27 @@ const schedule = /*#__PURE__*/ dual(2, (self, schedule) => scheduleFrom(self, vo
21499
21800
  */
21500
21801
  const scheduleFrom = scheduleFrom$1;
21501
21802
  /**
21803
+ * Returns the current tracer from the context.
21804
+ *
21805
+ * **Example** (Accessing the current tracer)
21806
+ *
21807
+ * ```ts import.meta.vitest
21808
+ * import { Effect } from "effect"
21809
+ *
21810
+ * const program = Effect.gen(function*() {
21811
+ * const currentTracer = yield* Effect.tracer
21812
+ * return typeof currentTracer.span
21813
+ * })
21814
+ *
21815
+ * Effect.runSync(program) // => "function"
21816
+ * ```
21817
+ *
21818
+ * @stability stable
21819
+ * @category tracing
21820
+ * @since 2.0.0
21821
+ */
21822
+ const tracer$1 = tracer$2;
21823
+ /**
21502
21824
  * Enables or disables tracing for spans created by the given effect.
21503
21825
  *
21504
21826
  * **Details**
@@ -22993,7 +23315,7 @@ const concat$3 = (chunks) => {
22993
23315
  * @category instances
22994
23316
  * @since 4.0.6
22995
23317
  */
22996
- const Order$2 = /*#__PURE__*/ make$90((self, that) => {
23318
+ const Order$2 = /*#__PURE__*/ make$91((self, that) => {
22997
23319
  const length = Math.min(self.length, that.length);
22998
23320
  for (let i = 0; i < length; i++) if (self[i] !== that[i]) return self[i] < that[i] ? -1 : 1;
22999
23321
  return self.length < that.length ? -1 : self.length > that.length ? 1 : 0;
@@ -23082,7 +23404,7 @@ const Ipv4Proto = {
23082
23404
  return isIpv4Address(that) && ipv4Value(this) === ipv4Value(that);
23083
23405
  },
23084
23406
  [symbol$3]() {
23085
- return optimize(combine$3(ipv4HashSeed, ipv4Value(this) | 0));
23407
+ return optimize(combine$4(ipv4HashSeed, ipv4Value(this) | 0));
23086
23408
  },
23087
23409
  toString() {
23088
23410
  return formatIp(this);
@@ -23103,10 +23425,10 @@ const Ipv6Proto = {
23103
23425
  },
23104
23426
  [symbol$3]() {
23105
23427
  const self = ipv6Words(this);
23106
- let h = combine$3(ipv6HashSeed, self.w0 | 0);
23107
- h = combine$3(h, self.w1 | 0);
23108
- h = combine$3(h, self.w2 | 0);
23109
- return optimize(combine$3(h, self.w3 | 0));
23428
+ let h = combine$4(ipv6HashSeed, self.w0 | 0);
23429
+ h = combine$4(h, self.w1 | 0);
23430
+ h = combine$4(h, self.w2 | 0);
23431
+ return optimize(combine$4(h, self.w3 | 0));
23110
23432
  },
23111
23433
  toString() {
23112
23434
  return formatIp(this);
@@ -23367,7 +23689,7 @@ const InetV4Proto = {
23367
23689
  return isInetAddressV4(that) && this.port === that.port && equals$1(this.address, that.address);
23368
23690
  },
23369
23691
  [symbol$3]() {
23370
- return combine$3(hash(this.address), number$2(this.port));
23692
+ return combine$4(hash(this.address), number$2(this.port));
23371
23693
  },
23372
23694
  toString() {
23373
23695
  return formatInet(this);
@@ -23384,7 +23706,7 @@ const InetV6Proto = {
23384
23706
  return isInetAddressV6(that) && this.port === that.port && this.scopeId === that.scopeId && equals$1(this.address, that.address);
23385
23707
  },
23386
23708
  [symbol$3]() {
23387
- return combine$3(combine$3(hash(this.address), number$2(this.port)), number$2(this.scopeId));
23709
+ return combine$4(combine$4(hash(this.address), number$2(this.port)), number$2(this.scopeId));
23388
23710
  },
23389
23711
  toString() {
23390
23712
  return formatInet(this);
@@ -23598,7 +23920,7 @@ const UnixPathProto = {
23598
23920
  return isUnixPathAddress(that) && this.path === that.path;
23599
23921
  },
23600
23922
  [symbol$3]() {
23601
- return combine$3(string$2("UnixPathAddress"), string$2(this.path));
23923
+ return combine$4(string$2("UnixPathAddress"), string$2(this.path));
23602
23924
  },
23603
23925
  toString() {
23604
23926
  return this.path;
@@ -24889,7 +25211,7 @@ const emptyArray = [];
24889
25211
  * @category instances
24890
25212
  * @since 4.0.0
24891
25213
  */
24892
- const makeEquivalence$1 = (isEquivalent) => make$91((self, that) => {
25214
+ const makeEquivalence$1 = (isEquivalent) => make$92((self, that) => {
24893
25215
  if (self.length !== that.length) return false;
24894
25216
  const as = toReadonlyArray(self);
24895
25217
  const bs = toReadonlyArray(that);
@@ -25168,6 +25490,44 @@ const make$79 = (value) => {
25168
25490
  return ref;
25169
25491
  };
25170
25492
  /**
25493
+ * Gets the current value of the MutableRef.
25494
+ *
25495
+ * **When to use**
25496
+ *
25497
+ * Use to read the current `MutableRef` value without mutating it.
25498
+ *
25499
+ * **Example** (Reading current values)
25500
+ *
25501
+ * ```ts import.meta.vitest
25502
+ * import { MutableRef } from "effect"
25503
+ *
25504
+ * const ref = MutableRef.make("hello")
25505
+ *
25506
+ * MutableRef.get(ref) // => "hello"
25507
+ *
25508
+ * MutableRef.set(ref, "world")
25509
+ *
25510
+ * MutableRef.get(ref) // => "world"
25511
+ *
25512
+ * // Reading complex objects
25513
+ * const config = MutableRef.make({ port: 3000, host: "localhost" })
25514
+ * const currentConfig = MutableRef.get(config)
25515
+ *
25516
+ * currentConfig // => { port: 3000, host: "localhost" }
25517
+ *
25518
+ * // Multiple reads return the same value
25519
+ * const value1 = MutableRef.get(ref)
25520
+ * const value2 = MutableRef.get(ref)
25521
+ *
25522
+ * value1 === value2 // => true
25523
+ * ```
25524
+ *
25525
+ * @stability stable
25526
+ * @category getters
25527
+ * @since 2.0.0
25528
+ */
25529
+ const get$9 = (self) => self.current;
25530
+ /**
25171
25531
  * Sets the MutableRef to a new value and returns the reference.
25172
25532
  *
25173
25533
  * **When to use**
@@ -25696,6 +26056,19 @@ const filter = (self, f) => {
25696
26056
  */
25697
26057
  const remove$3 = (self, value) => filter(self, (v) => v !== value);
25698
26058
  // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/PubSub.js
26059
+ /**
26060
+ * Broadcasts values from publishers to many subscribers.
26061
+ *
26062
+ * Publishers add messages with `publish` or `publishAll`, and each active
26063
+ * `Subscription` receives its own copy of every accepted message. Unlike a
26064
+ * queue, subscribers do not compete for messages. This module includes bounded,
26065
+ * dropping, sliding, and unbounded hubs, optional replay buffers for late
26066
+ * subscribers, message-taking helpers, capacity and shutdown operations, a
26067
+ * type guard, and low-level types for custom hub strategies.
26068
+ *
26069
+ * @stability stable
26070
+ * @since 2.0.0
26071
+ */
25699
26072
  const TypeId$59 = "~effect/PubSub";
25700
26073
  const SubscriptionTypeId = "~effect/PubSub/Subscription";
25701
26074
  /**
@@ -25729,6 +26102,137 @@ const SubscriptionTypeId = "~effect/PubSub/Subscription";
25729
26102
  */
25730
26103
  const make$77 = (options) => sync(() => makePubSubUnsafe(options.atomicPubSub(), /* @__PURE__ */ new Map(), makeUnsafe$7(), makeUnsafe$5(false), make$79(false), options.strategy(), make$79(none())));
25731
26104
  /**
26105
+ * Creates a bounded `PubSub` that applies backpressure when it reaches
26106
+ * capacity.
26107
+ *
26108
+ * **Details**
26109
+ *
26110
+ * Published messages are retained until all current subscribers have taken
26111
+ * them. When the capacity is full, publishers suspend until space is available.
26112
+ * Pass an options object to configure both `capacity` and an optional replay
26113
+ * buffer for late subscribers.
26114
+ * The capacity must be a positive integer or `Infinity` for unbounded storage.
26115
+ * Invalid capacities cause the effect to die.
26116
+ *
26117
+ * **Example** (Creating a bounded PubSub)
26118
+ *
26119
+ * ```ts import.meta.vitest
26120
+ * import { Effect, PubSub } from "effect"
26121
+ *
26122
+ * const program = Effect.gen(function*() {
26123
+ * // Create bounded PubSub with capacity 100
26124
+ * const pubsub = yield* PubSub.bounded<string>(100)
26125
+ *
26126
+ * // Create with replay buffer for late subscribers
26127
+ * const pubsubWithReplay = yield* PubSub.bounded<string>({
26128
+ * capacity: 100,
26129
+ * replay: 10 // Last 10 messages replayed to new subscribers
26130
+ * })
26131
+ *
26132
+ * const capacities = [PubSub.capacity(pubsub), PubSub.capacity(pubsubWithReplay)]
26133
+ * yield* PubSub.shutdown(pubsub)
26134
+ * yield* PubSub.shutdown(pubsubWithReplay)
26135
+ * return capacities
26136
+ * })
26137
+ *
26138
+ * const actual = await Effect.runPromise(program)
26139
+ * actual // => [100, 100]
26140
+ * ```
26141
+ *
26142
+ * @stability stable
26143
+ * @category constructors
26144
+ * @since 2.0.0
26145
+ */
26146
+ const bounded$1 = (capacity) => make$77({
26147
+ atomicPubSub: () => makeAtomicBounded(capacity),
26148
+ strategy: () => new BackPressureStrategy()
26149
+ });
26150
+ /**
26151
+ * Creates a bounded `PubSub` with the dropping strategy. The `PubSub` will drop new
26152
+ * messages if the `PubSub` is at capacity.
26153
+ *
26154
+ * **Details**
26155
+ *
26156
+ * The capacity must be a positive integer or `Infinity` for unbounded storage.
26157
+ * Invalid capacities cause the effect to die.
26158
+ * For best performance use capacities that are powers of two.
26159
+ *
26160
+ * **Example** (Dropping messages when full)
26161
+ *
26162
+ * ```ts import.meta.vitest
26163
+ * import { Effect, PubSub } from "effect"
26164
+ *
26165
+ * const program = Effect.scoped(Effect.gen(function*() {
26166
+ * // Create dropping PubSub that drops new messages when full
26167
+ * const pubsub = yield* PubSub.dropping<string>(3)
26168
+ *
26169
+ * const subscription = yield* PubSub.subscribe(pubsub)
26170
+ *
26171
+ * // Fill the PubSub and see dropping behavior
26172
+ * yield* PubSub.publish(pubsub, "msg1") // succeeds
26173
+ * yield* PubSub.publish(pubsub, "msg2") // succeeds
26174
+ * yield* PubSub.publish(pubsub, "msg3") // succeeds
26175
+ * const dropped = yield* PubSub.publish(pubsub, "msg4") // returns false (dropped)
26176
+ *
26177
+ * const messages = yield* PubSub.takeAll(subscription)
26178
+ * return { dropped: !dropped, messages }
26179
+ * }))
26180
+ *
26181
+ * const actual = await Effect.runPromise(program)
26182
+ * actual // => { dropped: true, messages: ["msg1", "msg2", "msg3"] }
26183
+ * ```
26184
+ *
26185
+ * @stability stable
26186
+ * @category constructors
26187
+ * @since 2.0.0
26188
+ */
26189
+ const dropping$1 = (capacity) => make$77({
26190
+ atomicPubSub: () => makeAtomicBounded(capacity),
26191
+ strategy: () => new DroppingStrategy()
26192
+ });
26193
+ /**
26194
+ * Creates a bounded `PubSub` with the sliding strategy. The `PubSub` will add new
26195
+ * messages and drop old messages if the `PubSub` is at capacity.
26196
+ *
26197
+ * **Details**
26198
+ *
26199
+ * The capacity must be a positive integer or `Infinity` for unbounded storage.
26200
+ * Invalid capacities cause the effect to die.
26201
+ * For best performance use capacities that are powers of two.
26202
+ *
26203
+ * **Example** (Sliding old messages when full)
26204
+ *
26205
+ * ```ts import.meta.vitest
26206
+ * import { Effect, PubSub } from "effect"
26207
+ *
26208
+ * const program = Effect.scoped(Effect.gen(function*() {
26209
+ * // Create sliding PubSub that evicts old messages when full
26210
+ * const pubsub = yield* PubSub.sliding<string>(3)
26211
+ *
26212
+ * const subscription = yield* PubSub.subscribe(pubsub)
26213
+ *
26214
+ * // Fill and overflow the PubSub
26215
+ * yield* PubSub.publish(pubsub, "msg1")
26216
+ * yield* PubSub.publish(pubsub, "msg2")
26217
+ * yield* PubSub.publish(pubsub, "msg3")
26218
+ * yield* PubSub.publish(pubsub, "msg4") // "msg1" is evicted
26219
+ *
26220
+ * return yield* PubSub.takeAll(subscription)
26221
+ * }))
26222
+ *
26223
+ * const actual = await Effect.runPromise(program)
26224
+ * actual // => ["msg2", "msg3", "msg4"]
26225
+ * ```
26226
+ *
26227
+ * @stability stable
26228
+ * @category constructors
26229
+ * @since 2.0.0
26230
+ */
26231
+ const sliding$1 = (capacity) => make$77({
26232
+ atomicPubSub: () => makeAtomicBounded(capacity),
26233
+ strategy: () => new SlidingStrategy()
26234
+ });
26235
+ /**
25732
26236
  * Creates an unbounded `PubSub`.
25733
26237
  *
25734
26238
  * **Example** (Creating an unbounded PubSub)
@@ -25763,6 +26267,45 @@ const unbounded = (options) => make$77({
25763
26267
  strategy: () => new DroppingStrategy()
25764
26268
  });
25765
26269
  /**
26270
+ * Creates a bounded atomic PubSub implementation with optional replay buffer.
26271
+ *
26272
+ * **When to use**
26273
+ *
26274
+ * Use to provide bounded message storage when building a custom `PubSub` with
26275
+ * `make` and an explicit delivery strategy.
26276
+ *
26277
+ * **Details**
26278
+ *
26279
+ * Pass either a capacity number or an options object with `capacity` and
26280
+ * optional `replay`. A positive `replay` value enables a replay buffer for late
26281
+ * subscribers, and fractional replay sizes are rounded up.
26282
+ *
26283
+ * **Gotchas**
26284
+ *
26285
+ * The capacity must be a positive integer or `Infinity` for unbounded storage;
26286
+ * invalid capacities throw synchronously before an atomic implementation is
26287
+ * created.
26288
+ *
26289
+ * @see {@link make} for constructing a `PubSub` from an atomic implementation and delivery strategy
26290
+ * @see {@link makeAtomicUnbounded} for an atomic implementation without a bounded capacity
26291
+ * @see {@link bounded} for the higher-level backpressure constructor
26292
+ * @see {@link dropping} for the higher-level dropping constructor
26293
+ * @see {@link sliding} for the higher-level sliding constructor
26294
+ *
26295
+ * @stability stable
26296
+ * @category constructors
26297
+ * @since 4.0.0
26298
+ */
26299
+ const makeAtomicBounded = (capacity) => {
26300
+ const options = typeof capacity === "number" ? { capacity } : capacity;
26301
+ ensureCapacity(options.capacity);
26302
+ if (options.capacity === Infinity) return makeAtomicUnbounded(options);
26303
+ const replayBuffer = options.replay && options.replay > 0 ? new ReplayBuffer(Math.ceil(options.replay)) : void 0;
26304
+ if (options.capacity === 1) return new BoundedPubSubSingle(replayBuffer);
26305
+ else if (nextPow2(options.capacity) === options.capacity) return new BoundedPubSubPow2(options.capacity, replayBuffer);
26306
+ else return new BoundedPubSubArb(options.capacity, replayBuffer);
26307
+ };
26308
+ /**
25766
26309
  * Creates an unbounded atomic PubSub implementation with optional replay buffer.
25767
26310
  *
25768
26311
  * **When to use**
@@ -25788,6 +26331,133 @@ const makeAtomicUnbounded = (options) => {
25788
26331
  return new UnboundedPubSub(replay && replay > 0 ? new ReplayBuffer(Math.ceil(replay)) : void 0);
25789
26332
  };
25790
26333
  /**
26334
+ * Shuts down the `PubSub`, interrupting suspended publishers and subscribers
26335
+ * and finalizing active subscriptions.
26336
+ *
26337
+ * **Details**
26338
+ *
26339
+ * After shutdown, `publish` and `publishAll` succeed with `false`,
26340
+ * `publishUnsafe` returns `false`, and subscription operations such as `take`
26341
+ * interrupt.
26342
+ *
26343
+ * **Example** (Shutting down a PubSub)
26344
+ *
26345
+ * ```ts import.meta.vitest
26346
+ * import { Effect, PubSub } from "effect"
26347
+ *
26348
+ * const program = Effect.gen(function*() {
26349
+ * const pubsub = yield* PubSub.bounded<string>(1)
26350
+ *
26351
+ * // Shutdown the PubSub
26352
+ * yield* PubSub.shutdown(pubsub)
26353
+ *
26354
+ * const isShutdown = yield* PubSub.isShutdown(pubsub)
26355
+ *
26356
+ * // Publishing after shutdown returns false
26357
+ * const published = yield* PubSub.publish(pubsub, "msg1")
26358
+ * return { isShutdown, published }
26359
+ * })
26360
+ *
26361
+ * const actual = await Effect.runPromise(program)
26362
+ * actual // => { isShutdown: true, published: false }
26363
+ * ```
26364
+ *
26365
+ * @stability stable
26366
+ * @category lifecycle
26367
+ * @since 2.0.0
26368
+ */
26369
+ const shutdown$1 = (self) => uninterruptible(withFiber((fiber) => {
26370
+ set$2(self.shutdownFlag, true);
26371
+ return close(self.scope, interrupt$2(fiber.id)).pipe(andThen(self.strategy.shutdown), when$2(self.shutdownHook.open), asVoid);
26372
+ }));
26373
+ /**
26374
+ * Ends the `PubSub` with a final message.
26375
+ *
26376
+ * **When to use**
26377
+ *
26378
+ * Use to tell every subscriber that no more messages will follow, without
26379
+ * losing the messages they have not consumed yet.
26380
+ *
26381
+ * **Details**
26382
+ *
26383
+ * Later publishes return `false`, as do publishers waiting for capacity when
26384
+ * `end` is called. Each subscriber receives the messages already buffered
26385
+ * for it, then the final message. Subscribers that arrive
26386
+ * after the end receive the replayed messages, if any, and then the final
26387
+ * message. The final message never occupies capacity, so a bounded `PubSub`
26388
+ * cannot drop it. Returns `false` if the `PubSub` was already ended or shut
26389
+ * down.
26390
+ *
26391
+ * `take`, `takeAll`, and `takeBetween` deliver the final message;
26392
+ * non-suspending `takeUpTo` does not.
26393
+ *
26394
+ * **Gotchas**
26395
+ *
26396
+ * The final message is sticky: subsequent takes return it again. Consumers
26397
+ * must treat it as terminal rather than continuing to take messages.
26398
+ *
26399
+ * **Example** (Ending a PubSub)
26400
+ *
26401
+ * ```ts import.meta.vitest
26402
+ * import { Effect, PubSub } from "effect"
26403
+ *
26404
+ * const program = Effect.scoped(Effect.gen(function*() {
26405
+ * const pubsub = yield* PubSub.bounded<string>(2)
26406
+ * const subscription = yield* PubSub.subscribe(pubsub)
26407
+ *
26408
+ * yield* PubSub.publish(pubsub, "Hello")
26409
+ * const ended = yield* PubSub.end(pubsub, "Bye")
26410
+ *
26411
+ * // Later publishes are rejected
26412
+ * const published = yield* PubSub.publish(pubsub, "World")
26413
+ *
26414
+ * // Buffered messages are delivered before the final message
26415
+ * const first = yield* PubSub.take(subscription)
26416
+ * const last = yield* PubSub.take(subscription)
26417
+ *
26418
+ * // Late subscribers receive the final message too
26419
+ * const late = yield* PubSub.subscribe(pubsub)
26420
+ * const lateMessage = yield* PubSub.take(late)
26421
+ * return [ended, published, first, last, lateMessage]
26422
+ * }))
26423
+ *
26424
+ * const actual = await Effect.runPromise(program)
26425
+ * actual // => [true, false, "Hello", "Bye", "Bye"]
26426
+ * ```
26427
+ *
26428
+ * @see {@link shutdown} for interrupting subscribers instead of delivering a final message
26429
+ *
26430
+ * @stability stable
26431
+ * @category lifecycle
26432
+ * @since 4.0.0
26433
+ */
26434
+ const end$2 = /*#__PURE__*/ dual(2, (self, value) => sync(() => endUnsafe$1(self, value)));
26435
+ /**
26436
+ * Ends the `PubSub` with a final message synchronously.
26437
+ *
26438
+ * **Details**
26439
+ *
26440
+ * See {@link end} for the semantics.
26441
+ *
26442
+ * @stability stable
26443
+ * @category lifecycle
26444
+ * @since 4.0.0
26445
+ */
26446
+ const endUnsafe$1 = /*#__PURE__*/ dual(2, (self, value) => {
26447
+ if (self.shutdownFlag.current || isSome(self.ended.current)) return false;
26448
+ set$2(self.ended, some$1(value));
26449
+ if (self.strategy instanceof BackPressureStrategy) {
26450
+ for (const [_, deferred, last] of takeAll$1(self.strategy.publishers)) if (last) doneUnsafe(deferred, succeed$8(false));
26451
+ }
26452
+ const exit = succeed$8(value);
26453
+ for (const pollersSet of self.subscribers.values()) for (const pollers of pollersSet) {
26454
+ let poller;
26455
+ while ((poller = take$2(pollers)) !== Empty$2) doneUnsafe(poller, exit);
26456
+ }
26457
+ self.subscribers.clear();
26458
+ return true;
26459
+ });
26460
+ /**
25791
26461
  * Publishes a message to the `PubSub` as an `Effect`, returning whether the
25792
26462
  * message was accepted.
25793
26463
  *
@@ -25891,7 +26561,7 @@ const publish = /*#__PURE__*/ dual(2, (self, value) => suspend$3(() => {
25891
26561
  * @since 2.0.0
25892
26562
  */
25893
26563
  const subscribe = (self) => uninterruptible(contextWith((services) => {
25894
- const localScope = get$12(services, Scope);
26564
+ const localScope = get$13(services, Scope);
25895
26565
  const scope = forkUnsafe(self.scope);
25896
26566
  const subscription = makeSubscriptionUnsafe(self.pubsub, self.subscribers, self.strategy, self.ended);
25897
26567
  return addFinalizer$1(scope, unsubscribe(subscription)).pipe(andThen(addFinalizerExit(localScope, (exit) => close(scope, exit))), as(subscription));
@@ -25988,6 +26658,406 @@ const removeSubscribers = (subscribers, subscription, pollers) => {
25988
26658
  if (set.size === 0) subscribers.delete(subscription);
25989
26659
  };
25990
26660
  const makeSubscriptionUnsafe = (pubsub, subscribers, strategy, ended) => new SubscriptionImpl(pubsub, subscribers, pubsub.subscribe(), make$78(), makeUnsafe$5(false), make$79(false), strategy, pubsub.replayWindow(), ended);
26661
+ var BoundedPubSubArb = class {
26662
+ array;
26663
+ replayIndices;
26664
+ publisherIndex = 0;
26665
+ subscribers;
26666
+ subscriberCount = 0;
26667
+ subscribersIndex = 0;
26668
+ capacity;
26669
+ replayBuffer;
26670
+ constructor(capacity, replayBuffer) {
26671
+ this.capacity = capacity;
26672
+ this.replayBuffer = replayBuffer;
26673
+ this.array = Array.from({ length: capacity });
26674
+ this.replayIndices = replayBuffer ? Array.from({ length: capacity }) : [];
26675
+ this.subscribers = Array.from({ length: capacity });
26676
+ }
26677
+ replayWindow() {
26678
+ return this.replayBuffer ? new ReplayWindowImpl(this.replayBuffer) : emptyReplayWindow;
26679
+ }
26680
+ isEmpty() {
26681
+ return this.publisherIndex === this.subscribersIndex;
26682
+ }
26683
+ isFull() {
26684
+ return this.publisherIndex === this.subscribersIndex + this.capacity;
26685
+ }
26686
+ size() {
26687
+ return this.publisherIndex - this.subscribersIndex;
26688
+ }
26689
+ publish(value) {
26690
+ if (this.isFull()) return false;
26691
+ const replayIndex = this.replayBuffer?.offer(value);
26692
+ if (this.subscriberCount !== 0) {
26693
+ const index = this.publisherIndex % this.capacity;
26694
+ this.array[index] = value;
26695
+ if (replayIndex !== void 0) this.replayIndices[index] = replayIndex;
26696
+ this.subscribers[index] = this.subscriberCount;
26697
+ this.publisherIndex += 1;
26698
+ }
26699
+ return true;
26700
+ }
26701
+ publishAll(elements) {
26702
+ if (this.subscriberCount === 0) {
26703
+ if (this.replayBuffer) this.replayBuffer.offerAll(elements);
26704
+ return [];
26705
+ }
26706
+ const chunk = fromIterable$6(elements);
26707
+ const n = chunk.length;
26708
+ const size = this.publisherIndex - this.subscribersIndex;
26709
+ const available = this.capacity - size;
26710
+ const forPubSub = Math.min(n, available);
26711
+ if (forPubSub === 0) return chunk;
26712
+ let iteratorIndex = 0;
26713
+ const publishAllIndex = this.publisherIndex + forPubSub;
26714
+ while (this.publisherIndex !== publishAllIndex) {
26715
+ const a = chunk[iteratorIndex++];
26716
+ const index = this.publisherIndex % this.capacity;
26717
+ this.array[index] = a;
26718
+ const replayIndex = this.replayBuffer?.offer(a);
26719
+ if (replayIndex !== void 0) this.replayIndices[index] = replayIndex;
26720
+ this.subscribers[index] = this.subscriberCount;
26721
+ this.publisherIndex += 1;
26722
+ }
26723
+ return chunk.slice(iteratorIndex);
26724
+ }
26725
+ slide() {
26726
+ if (this.subscribersIndex !== this.publisherIndex) {
26727
+ const index = this.subscribersIndex % this.capacity;
26728
+ const value = this.array[index];
26729
+ this.array[index] = AbsentValue;
26730
+ this.subscribers[index] = 0;
26731
+ this.subscribersIndex += 1;
26732
+ this.replayBuffer?.slide(value, this.replayIndices[index]);
26733
+ }
26734
+ }
26735
+ subscribe() {
26736
+ this.subscriberCount += 1;
26737
+ return new BoundedPubSubArbSubscription(this, this.publisherIndex, false);
26738
+ }
26739
+ };
26740
+ var BoundedPubSubArbSubscription = class {
26741
+ self;
26742
+ subscriberIndex;
26743
+ unsubscribed;
26744
+ constructor(self, subscriberIndex, unsubscribed) {
26745
+ this.self = self;
26746
+ this.subscriberIndex = subscriberIndex;
26747
+ this.unsubscribed = unsubscribed;
26748
+ }
26749
+ isEmpty() {
26750
+ return this.unsubscribed || this.self.publisherIndex === this.subscriberIndex || this.self.publisherIndex === this.self.subscribersIndex;
26751
+ }
26752
+ size() {
26753
+ if (this.unsubscribed) return 0;
26754
+ return this.self.publisherIndex - Math.max(this.subscriberIndex, this.self.subscribersIndex);
26755
+ }
26756
+ poll() {
26757
+ if (this.unsubscribed) return Empty$2;
26758
+ this.subscriberIndex = Math.max(this.subscriberIndex, this.self.subscribersIndex);
26759
+ if (this.subscriberIndex !== this.self.publisherIndex) {
26760
+ const index = this.subscriberIndex % this.self.capacity;
26761
+ const elem = this.self.array[index];
26762
+ this.self.subscribers[index] -= 1;
26763
+ if (this.self.subscribers[index] === 0) {
26764
+ this.self.array[index] = AbsentValue;
26765
+ this.self.subscribersIndex += 1;
26766
+ }
26767
+ this.subscriberIndex += 1;
26768
+ return elem;
26769
+ }
26770
+ return Empty$2;
26771
+ }
26772
+ pollUpTo(n) {
26773
+ n = normalize$2(n);
26774
+ if (this.unsubscribed) return [];
26775
+ this.subscriberIndex = Math.max(this.subscriberIndex, this.self.subscribersIndex);
26776
+ const size = this.self.publisherIndex - this.subscriberIndex;
26777
+ const toPoll = Math.min(n, size);
26778
+ if (toPoll <= 0) return [];
26779
+ const builder = [];
26780
+ const pollUpToIndex = this.subscriberIndex + toPoll;
26781
+ while (this.subscriberIndex !== pollUpToIndex) {
26782
+ const index = this.subscriberIndex % this.self.capacity;
26783
+ const a = this.self.array[index];
26784
+ this.self.subscribers[index] -= 1;
26785
+ if (this.self.subscribers[index] === 0) {
26786
+ this.self.array[index] = AbsentValue;
26787
+ this.self.subscribersIndex += 1;
26788
+ }
26789
+ builder.push(a);
26790
+ this.subscriberIndex += 1;
26791
+ }
26792
+ return builder;
26793
+ }
26794
+ unsubscribe() {
26795
+ if (!this.unsubscribed) {
26796
+ this.unsubscribed = true;
26797
+ this.self.subscriberCount -= 1;
26798
+ this.subscriberIndex = Math.max(this.subscriberIndex, this.self.subscribersIndex);
26799
+ while (this.subscriberIndex !== this.self.publisherIndex) {
26800
+ const index = this.subscriberIndex % this.self.capacity;
26801
+ this.self.subscribers[index] -= 1;
26802
+ if (this.self.subscribers[index] === 0) {
26803
+ this.self.array[index] = AbsentValue;
26804
+ this.self.subscribersIndex += 1;
26805
+ }
26806
+ this.subscriberIndex += 1;
26807
+ }
26808
+ }
26809
+ }
26810
+ };
26811
+ var BoundedPubSubPow2 = class {
26812
+ array;
26813
+ replayIndices;
26814
+ mask;
26815
+ publisherIndex = 0;
26816
+ subscribers;
26817
+ subscriberCount = 0;
26818
+ subscribersIndex = 0;
26819
+ capacity;
26820
+ replayBuffer;
26821
+ constructor(capacity, replayBuffer) {
26822
+ this.capacity = capacity;
26823
+ this.replayBuffer = replayBuffer;
26824
+ this.array = Array.from({ length: capacity });
26825
+ this.replayIndices = replayBuffer ? Array.from({ length: capacity }) : [];
26826
+ this.mask = capacity - 1;
26827
+ this.subscribers = Array.from({ length: capacity });
26828
+ }
26829
+ replayWindow() {
26830
+ return this.replayBuffer ? new ReplayWindowImpl(this.replayBuffer) : emptyReplayWindow;
26831
+ }
26832
+ isEmpty() {
26833
+ return this.publisherIndex === this.subscribersIndex;
26834
+ }
26835
+ isFull() {
26836
+ return this.publisherIndex === this.subscribersIndex + this.capacity;
26837
+ }
26838
+ size() {
26839
+ return this.publisherIndex - this.subscribersIndex;
26840
+ }
26841
+ publish(value) {
26842
+ if (this.isFull()) return false;
26843
+ const replayIndex = this.replayBuffer?.offer(value);
26844
+ if (this.subscriberCount !== 0) {
26845
+ const index = this.publisherIndex & this.mask;
26846
+ this.array[index] = value;
26847
+ if (replayIndex !== void 0) this.replayIndices[index] = replayIndex;
26848
+ this.subscribers[index] = this.subscriberCount;
26849
+ this.publisherIndex += 1;
26850
+ }
26851
+ return true;
26852
+ }
26853
+ publishAll(elements) {
26854
+ if (this.subscriberCount === 0) {
26855
+ if (this.replayBuffer) this.replayBuffer.offerAll(elements);
26856
+ return [];
26857
+ }
26858
+ const chunk = fromIterable$6(elements);
26859
+ const n = chunk.length;
26860
+ const size = this.publisherIndex - this.subscribersIndex;
26861
+ const available = this.capacity - size;
26862
+ const forPubSub = Math.min(n, available);
26863
+ if (forPubSub === 0) return chunk;
26864
+ let iteratorIndex = 0;
26865
+ const publishAllIndex = this.publisherIndex + forPubSub;
26866
+ while (this.publisherIndex !== publishAllIndex) {
26867
+ const elem = chunk[iteratorIndex++];
26868
+ const index = this.publisherIndex & this.mask;
26869
+ this.array[index] = elem;
26870
+ const replayIndex = this.replayBuffer?.offer(elem);
26871
+ if (replayIndex !== void 0) this.replayIndices[index] = replayIndex;
26872
+ this.subscribers[index] = this.subscriberCount;
26873
+ this.publisherIndex += 1;
26874
+ }
26875
+ return chunk.slice(iteratorIndex);
26876
+ }
26877
+ slide() {
26878
+ if (this.subscribersIndex !== this.publisherIndex) {
26879
+ const index = this.subscribersIndex & this.mask;
26880
+ const value = this.array[index];
26881
+ this.array[index] = AbsentValue;
26882
+ this.subscribers[index] = 0;
26883
+ this.subscribersIndex += 1;
26884
+ this.replayBuffer?.slide(value, this.replayIndices[index]);
26885
+ }
26886
+ }
26887
+ subscribe() {
26888
+ this.subscriberCount += 1;
26889
+ return new BoundedPubSubPow2Subscription(this, this.publisherIndex, false);
26890
+ }
26891
+ };
26892
+ var BoundedPubSubPow2Subscription = class {
26893
+ self;
26894
+ subscriberIndex;
26895
+ unsubscribed;
26896
+ constructor(self, subscriberIndex, unsubscribed) {
26897
+ this.self = self;
26898
+ this.subscriberIndex = subscriberIndex;
26899
+ this.unsubscribed = unsubscribed;
26900
+ }
26901
+ isEmpty() {
26902
+ return this.unsubscribed || this.self.publisherIndex === this.subscriberIndex || this.self.publisherIndex === this.self.subscribersIndex;
26903
+ }
26904
+ size() {
26905
+ if (this.unsubscribed) return 0;
26906
+ return this.self.publisherIndex - Math.max(this.subscriberIndex, this.self.subscribersIndex);
26907
+ }
26908
+ poll() {
26909
+ if (this.unsubscribed) return Empty$2;
26910
+ this.subscriberIndex = Math.max(this.subscriberIndex, this.self.subscribersIndex);
26911
+ if (this.subscriberIndex !== this.self.publisherIndex) {
26912
+ const index = this.subscriberIndex & this.self.mask;
26913
+ const elem = this.self.array[index];
26914
+ this.self.subscribers[index] -= 1;
26915
+ if (this.self.subscribers[index] === 0) {
26916
+ this.self.array[index] = AbsentValue;
26917
+ this.self.subscribersIndex += 1;
26918
+ }
26919
+ this.subscriberIndex += 1;
26920
+ return elem;
26921
+ }
26922
+ return Empty$2;
26923
+ }
26924
+ pollUpTo(n) {
26925
+ n = normalize$2(n);
26926
+ if (this.unsubscribed) return [];
26927
+ this.subscriberIndex = Math.max(this.subscriberIndex, this.self.subscribersIndex);
26928
+ const size = this.self.publisherIndex - this.subscriberIndex;
26929
+ const toPoll = Math.min(n, size);
26930
+ if (toPoll <= 0) return [];
26931
+ const builder = [];
26932
+ const pollUpToIndex = this.subscriberIndex + toPoll;
26933
+ while (this.subscriberIndex !== pollUpToIndex) {
26934
+ const index = this.subscriberIndex & this.self.mask;
26935
+ const elem = this.self.array[index];
26936
+ this.self.subscribers[index] -= 1;
26937
+ if (this.self.subscribers[index] === 0) {
26938
+ this.self.array[index] = AbsentValue;
26939
+ this.self.subscribersIndex += 1;
26940
+ }
26941
+ builder.push(elem);
26942
+ this.subscriberIndex += 1;
26943
+ }
26944
+ return builder;
26945
+ }
26946
+ unsubscribe() {
26947
+ if (!this.unsubscribed) {
26948
+ this.unsubscribed = true;
26949
+ this.self.subscriberCount -= 1;
26950
+ this.subscriberIndex = Math.max(this.subscriberIndex, this.self.subscribersIndex);
26951
+ while (this.subscriberIndex !== this.self.publisherIndex) {
26952
+ const index = this.subscriberIndex & this.self.mask;
26953
+ this.self.subscribers[index] -= 1;
26954
+ if (this.self.subscribers[index] === 0) {
26955
+ this.self.array[index] = AbsentValue;
26956
+ this.self.subscribersIndex += 1;
26957
+ }
26958
+ this.subscriberIndex += 1;
26959
+ }
26960
+ }
26961
+ }
26962
+ };
26963
+ var BoundedPubSubSingle = class {
26964
+ publisherIndex = 0;
26965
+ subscriberCount = 0;
26966
+ subscribers = 0;
26967
+ value = AbsentValue;
26968
+ replayIndex = 0;
26969
+ capacity = 1;
26970
+ replayBuffer;
26971
+ constructor(replayBuffer) {
26972
+ this.replayBuffer = replayBuffer;
26973
+ }
26974
+ replayWindow() {
26975
+ return this.replayBuffer ? new ReplayWindowImpl(this.replayBuffer) : emptyReplayWindow;
26976
+ }
26977
+ pipe() {
26978
+ return pipeArguments(this, arguments);
26979
+ }
26980
+ isEmpty() {
26981
+ return this.subscribers === 0;
26982
+ }
26983
+ isFull() {
26984
+ return !this.isEmpty();
26985
+ }
26986
+ size() {
26987
+ return this.isEmpty() ? 0 : 1;
26988
+ }
26989
+ publish(value) {
26990
+ if (this.isFull()) return false;
26991
+ const replayIndex = this.replayBuffer?.offer(value);
26992
+ if (this.subscriberCount !== 0) {
26993
+ this.value = value;
26994
+ if (replayIndex !== void 0) this.replayIndex = replayIndex;
26995
+ this.subscribers = this.subscriberCount;
26996
+ this.publisherIndex += 1;
26997
+ }
26998
+ return true;
26999
+ }
27000
+ publishAll(elements) {
27001
+ if (this.subscriberCount === 0) {
27002
+ if (this.replayBuffer) this.replayBuffer.offerAll(elements);
27003
+ return [];
27004
+ }
27005
+ const chunk = fromIterable$6(elements);
27006
+ if (chunk.length === 0) return chunk;
27007
+ if (this.publish(chunk[0])) return chunk.slice(1);
27008
+ else return chunk;
27009
+ }
27010
+ slide() {
27011
+ if (this.isFull()) {
27012
+ const value = this.value;
27013
+ this.subscribers = 0;
27014
+ this.value = AbsentValue;
27015
+ this.replayBuffer?.slide(value, this.replayIndex);
27016
+ }
27017
+ }
27018
+ subscribe() {
27019
+ this.subscriberCount += 1;
27020
+ return new BoundedPubSubSingleSubscription(this, this.publisherIndex, false);
27021
+ }
27022
+ };
27023
+ var BoundedPubSubSingleSubscription = class {
27024
+ self;
27025
+ subscriberIndex;
27026
+ unsubscribed;
27027
+ constructor(self, subscriberIndex, unsubscribed) {
27028
+ this.self = self;
27029
+ this.subscriberIndex = subscriberIndex;
27030
+ this.unsubscribed = unsubscribed;
27031
+ }
27032
+ isEmpty() {
27033
+ return this.unsubscribed || this.self.subscribers === 0 || this.subscriberIndex === this.self.publisherIndex;
27034
+ }
27035
+ size() {
27036
+ return this.isEmpty() ? 0 : 1;
27037
+ }
27038
+ poll() {
27039
+ if (this.isEmpty()) return Empty$2;
27040
+ const elem = this.self.value;
27041
+ this.self.subscribers -= 1;
27042
+ if (this.self.subscribers === 0) this.self.value = AbsentValue;
27043
+ this.subscriberIndex = this.self.publisherIndex;
27044
+ return elem;
27045
+ }
27046
+ pollUpTo(n) {
27047
+ if (normalize$2(n) < 1 || this.isEmpty()) return [];
27048
+ return [this.poll()];
27049
+ }
27050
+ unsubscribe() {
27051
+ if (!this.unsubscribed) {
27052
+ this.unsubscribed = true;
27053
+ this.self.subscriberCount -= 1;
27054
+ if (this.self.subscribers !== 0 && this.subscriberIndex !== this.self.publisherIndex) {
27055
+ this.self.subscribers -= 1;
27056
+ if (this.self.subscribers === 0) this.self.value = AbsentValue;
27057
+ }
27058
+ }
27059
+ }
27060
+ };
25991
27061
  var UnboundedPubSub = class {
25992
27062
  publisherHead = {
25993
27063
  value: AbsentValue,
@@ -26183,6 +27253,104 @@ var PubSubImpl = class {
26183
27253
  }
26184
27254
  };
26185
27255
  const makePubSubUnsafe = (pubsub, subscribers, scope, shutdownHook, shutdownFlag, strategy, ended) => new PubSubImpl(pubsub, subscribers, scope, shutdownHook, shutdownFlag, strategy, ended);
27256
+ const ensureCapacity = (capacity) => {
27257
+ if (capacity <= 0 || capacity !== Infinity && !Number.isInteger(capacity)) throw new Error(`Cannot construct PubSub with capacity of ${capacity}`);
27258
+ };
27259
+ /**
27260
+ * Represents the back-pressure strategy for bounded `PubSub` values.
27261
+ *
27262
+ * **When to use**
27263
+ *
27264
+ * Use to preserve every message for current subscribers when a bounded custom
27265
+ * `PubSub` should make publishers wait for capacity instead of dropping or
27266
+ * evicting messages.
27267
+ *
27268
+ * **Details**
27269
+ *
27270
+ * Publishers wait when the `PubSub` is at capacity, so all current subscribers
27271
+ * can receive every published message.
27272
+ *
27273
+ * **Gotchas**
27274
+ *
27275
+ * A slow subscriber can slow down publishers and other subscribers.
27276
+ *
27277
+ * @see {@link bounded} for creating bounded PubSubs with back pressure by default
27278
+ * @see {@link DroppingStrategy} for dropping new messages when capacity is full
27279
+ * @see {@link SlidingStrategy} for evicting old messages when capacity is full
27280
+ *
27281
+ * @stability stable
27282
+ * @category models
27283
+ * @since 4.0.0
27284
+ */
27285
+ var BackPressureStrategy = class {
27286
+ publishers = /*#__PURE__*/ make$78();
27287
+ get shutdown() {
27288
+ return withFiber((fiber) => forEach$1(takeAll$1(this.publishers), ([_, deferred, last]) => last ? interruptWith(deferred, fiber.id) : void_$2, {
27289
+ concurrency: "unbounded",
27290
+ discard: true
27291
+ }));
27292
+ }
27293
+ handleSurplus(pubsub, subscribers, elements, isShutdown, ended) {
27294
+ return callback$1((resume) => {
27295
+ if (isSome(ended.current)) return resume(succeed$5(false));
27296
+ const deferred = makeUnsafe$8();
27297
+ this.offerUnsafe(elements, deferred);
27298
+ this.onPubSubEmptySpaceUnsafe(pubsub, subscribers);
27299
+ this.completeSubscribersUnsafe(pubsub, subscribers);
27300
+ if (get$9(isShutdown)) {
27301
+ this.removeUnsafe(deferred);
27302
+ return resume(interrupt$1);
27303
+ }
27304
+ if (deferred.effect) return resume(deferred.effect);
27305
+ deferred.resumes = [resume];
27306
+ return sync(() => this.removeUnsafe(deferred));
27307
+ });
27308
+ }
27309
+ onPubSubEmptySpaceUnsafe(pubsub, subscribers) {
27310
+ let keepPolling = true;
27311
+ while (keepPolling && !pubsub.isFull()) {
27312
+ const publisher = take$2(this.publishers);
27313
+ if (publisher === Empty$2) keepPolling = false;
27314
+ else {
27315
+ const [value, deferred, last] = publisher;
27316
+ const published = pubsub.publish(value);
27317
+ if (!published) prepend(this.publishers, publisher);
27318
+ this.completeSubscribersUnsafe(pubsub, subscribers);
27319
+ if (published && last) doneUnsafe(deferred, succeed$8(true));
27320
+ }
27321
+ }
27322
+ }
27323
+ completePollersUnsafe(pubsub, subscribers, subscription, pollers) {
27324
+ return strategyCompletePollersUnsafe(this, pubsub, subscribers, subscription, pollers);
27325
+ }
27326
+ completeSubscribersUnsafe(pubsub, subscribers) {
27327
+ return strategyCompleteSubscribersUnsafe(this, pubsub, subscribers);
27328
+ }
27329
+ offerUnsafe(elements, deferred) {
27330
+ const iterator = elements[Symbol.iterator]();
27331
+ let next = iterator.next();
27332
+ if (!next.done) while (1) {
27333
+ const value = next.value;
27334
+ next = iterator.next();
27335
+ if (next.done) {
27336
+ append(this.publishers, [
27337
+ value,
27338
+ deferred,
27339
+ true
27340
+ ]);
27341
+ break;
27342
+ }
27343
+ append(this.publishers, [
27344
+ value,
27345
+ deferred,
27346
+ false
27347
+ ]);
27348
+ }
27349
+ }
27350
+ removeUnsafe(deferred) {
27351
+ filter(this.publishers, ([_, d]) => d !== deferred);
27352
+ }
27353
+ };
26186
27354
  /**
26187
27355
  * Represents the dropping strategy for bounded `PubSub` values.
26188
27356
  *
@@ -26247,6 +27415,89 @@ var DroppingStrategy = class {
26247
27415
  return strategyCompleteSubscribersUnsafe(this, pubsub, subscribers);
26248
27416
  }
26249
27417
  };
27418
+ /**
27419
+ * Represents the sliding strategy for bounded `PubSub` values.
27420
+ *
27421
+ * **When to use**
27422
+ *
27423
+ * Use to keep the most recent messages when the `PubSub` is at capacity.
27424
+ *
27425
+ * **Details**
27426
+ *
27427
+ * New messages are accepted by evicting older messages from the bounded
27428
+ * `PubSub`.
27429
+ *
27430
+ * **Gotchas**
27431
+ *
27432
+ * Slow subscribers may miss older messages that are evicted before they are
27433
+ * consumed.
27434
+ *
27435
+ * **Example** (Applying a sliding strategy)
27436
+ *
27437
+ * ```ts import.meta.vitest
27438
+ * import { Effect, PubSub } from "effect"
27439
+ *
27440
+ * const program = Effect.scoped(Effect.gen(function*() {
27441
+ * // Explicitly create a PubSub with a sliding strategy
27442
+ * const pubsub = yield* PubSub.make<string>({
27443
+ * atomicPubSub: () => PubSub.makeAtomicBounded(2),
27444
+ * strategy: () => new PubSub.SlidingStrategy()
27445
+ * })
27446
+ *
27447
+ * const subscription = yield* PubSub.subscribe(pubsub)
27448
+ *
27449
+ * // Publish messages that exceed capacity
27450
+ * yield* PubSub.publish(pubsub, "msg1") // stored
27451
+ * yield* PubSub.publish(pubsub, "msg2") // stored
27452
+ * yield* PubSub.publish(pubsub, "msg3") // "msg1" evicted, "msg3" stored
27453
+ * yield* PubSub.publish(pubsub, "msg4") // "msg2" evicted, "msg4" stored
27454
+ *
27455
+ * // Subscribers will see the most recent messages
27456
+ * return yield* PubSub.takeAll(subscription)
27457
+ * }))
27458
+ *
27459
+ * const actual = await Effect.runPromise(program)
27460
+ * actual // => ["msg3", "msg4"]
27461
+ * ```
27462
+ *
27463
+ * @stability stable
27464
+ * @category models
27465
+ * @since 4.0.0
27466
+ */
27467
+ var SlidingStrategy = class {
27468
+ get shutdown() {
27469
+ return void_$2;
27470
+ }
27471
+ handleSurplus(pubsub, subscribers, elements, _isShutdown, ended) {
27472
+ return sync(() => {
27473
+ if (isSome(ended.current)) return false;
27474
+ this.slidingPublishUnsafe(pubsub, elements);
27475
+ this.completeSubscribersUnsafe(pubsub, subscribers);
27476
+ return true;
27477
+ });
27478
+ }
27479
+ onPubSubEmptySpaceUnsafe(_pubsub, _subscribers) {}
27480
+ completePollersUnsafe(pubsub, subscribers, subscription, pollers) {
27481
+ return strategyCompletePollersUnsafe(this, pubsub, subscribers, subscription, pollers);
27482
+ }
27483
+ completeSubscribersUnsafe(pubsub, subscribers) {
27484
+ return strategyCompleteSubscribersUnsafe(this, pubsub, subscribers);
27485
+ }
27486
+ slidingPublishUnsafe(pubsub, elements) {
27487
+ const it = elements[Symbol.iterator]();
27488
+ let next = it.next();
27489
+ if (!next.done && pubsub.capacity > 0) {
27490
+ let a = next.value;
27491
+ let loop = true;
27492
+ while (loop) {
27493
+ pubsub.slide();
27494
+ const pub = pubsub.publish(a);
27495
+ if (pub && (next = it.next()) && !next.done) a = next.value;
27496
+ else if (pub) loop = false;
27497
+ }
27498
+ }
27499
+ }
27500
+ };
26250
27501
  const strategyCompletePollersUnsafe = (strategy, pubsub, subscribers, subscription, pollers) => {
26251
27502
  let keepPolling = true;
26252
27503
  while (keepPolling && !subscription.isEmpty()) {
@@ -27760,6 +29011,21 @@ const withPermit = (self, effect) => {
27760
29011
  if (!effect) return self.withPermit;
27761
29012
  return self.withPermit(effect);
27762
29013
  };
29014
+ // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Take.js
29015
+ /**
29016
+ * Converts a `Take` into a `Pull`, succeeding with value batches, failing with
29017
+ * failure exits, and translating successful exits into pull completion.
29018
+ *
29019
+ * **When to use**
29020
+ *
29021
+ * Use to interpret a stored or transferred `Take` as a `Pull` step while
29022
+ * preserving emitted batches, ordinary failures, and completion values.
29023
+ *
29024
+ * @stability stable
29025
+ * @category converting
29026
+ * @since 4.0.0
29027
+ */
29028
+ const toPull = (take) => isExit(take) ? isSuccess$1(take) ? done(take.value) : take : succeed$5(take);
27763
29029
  // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/Channel.js
27764
29030
  /**
27765
29031
  * Provides low-level building blocks for streaming data through Effect.
@@ -28152,6 +29418,20 @@ const fromEffect$1 = (effect) => fromPull$1(sync(() => {
28152
29418
  */
28153
29419
  const fromEffectDrain = (effect) => fromPull$1(flatMap$3(effect, () => done()));
28154
29420
  /**
29421
+ * Creates a channel from an effect that produces a `Take`.
29422
+ *
29423
+ * **Details**
29424
+ *
29425
+ * A successful `Take` emits a non-empty array of output elements. A failed
29426
+ * `Take` fails the channel. A done `Take` completes the channel with its done
29427
+ * value.
29428
+ *
29429
+ * @stability stable
29430
+ * @category constructors
29431
+ * @since 4.0.0
29432
+ */
29433
+ const fromEffectTake = (effect) => fromPull$1(succeed$5(flatMap$3(effect, toPull)));
29434
+ /**
28155
29435
  * Creates a channel from a queue that emits arrays of elements.
28156
29436
  *
28157
29437
  * **Example** (Creating batched channels from queues)
@@ -28175,6 +29455,19 @@ const fromEffectDrain = (effect) => fromPull$1(flatMap$3(effect, () => done()));
28175
29455
  */
28176
29456
  const fromQueueArray = (queue) => fromPull$1(succeed$5(takeAll(queue)));
28177
29457
  /**
29458
+ * Subscribes to a `PubSub` of `Take` values and exposes them as a channel.
29459
+ *
29460
+ * **Details**
29461
+ *
29462
+ * Output `Take` values are emitted as non-empty arrays. Failed `Take` values
29463
+ * fail the channel. Done `Take` values complete the channel.
29464
+ *
29465
+ * @stability stable
29466
+ * @category constructors
29467
+ * @since 4.0.0
29468
+ */
29469
+ const fromPubSubTake$1 = (pubsub) => unwrap$6(map$7(subscribe(pubsub), (sub) => fromEffectTake(take$1(sub))));
29470
+ /**
28178
29471
  * Creates a channel from a lazily supplied Web `ReadableStream`.
28179
29472
  *
28180
29473
  * **Details**
@@ -29440,6 +30733,26 @@ const runFold = /*#__PURE__*/ dual(3, (self, initial, f) => suspend$3(() => {
29440
30733
  * @since 4.0.0
29441
30734
  */
29442
30735
  const toPullScoped = (self, scope) => toTransform(self)(done(), scope);
30736
+ const makePubSub = (options) => acquireRelease(options.capacity === "unbounded" ? unbounded(options) : options.strategy === "dropping" ? dropping$1(options) : options.strategy === "sliding" ? sliding$1(options) : bounded$1(options), shutdown$1);
30737
+ /**
30738
+ * Converts a channel to a scoped `PubSub` of `Take` values.
30739
+ *
30740
+ * **Details**
30741
+ *
30742
+ * Emitted non-empty arrays are published as output `Take` values. When the
30743
+ * channel ends, the `PubSub` is ended with its final `Exit`, so every
30744
+ * subscriber, including one that subscribes later, observes completion or
30745
+ * failure once it has consumed its buffered values.
30746
+ *
30747
+ * @stability stable
30748
+ * @category destructors
30749
+ * @since 4.0.0
30750
+ */
30751
+ const toPubSubTake$1 = /*#__PURE__*/ dual(2, /*#__PURE__*/ fnUntraced(function* (self, options) {
30752
+ const pubsub = yield* makePubSub(options);
30753
+ yield* runForEach$1(self, (value) => publish(pubsub, value)).pipe(onExit$1((exit) => end$2(pubsub, exit)), forkScoped);
30754
+ return pubsub;
30755
+ }));
29443
30756
  // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/internal/stream.js
29444
30757
  const TypeId$56 = "~effect/Stream";
29445
30758
  const streamVariance = {
@@ -29737,7 +31050,7 @@ const makeUnsafe$3 = (options) => ({
29737
31050
  */
29738
31051
  const make$74 = (options) => withFiber((fiber) => {
29739
31052
  const context = fiber.context;
29740
- const scope = get$12(context, Scope);
31053
+ const scope = get$13(context, Scope);
29741
31054
  const self = makeUnsafe$3({
29742
31055
  lookup: options.lookup,
29743
31056
  context,
@@ -29804,7 +31117,7 @@ const get$8 = /*#__PURE__*/ dual(2, (self, key) => uninterruptibleMask((restore)
29804
31117
  if (self.state._tag === "Closed") return interrupt$1;
29805
31118
  const state = self.state;
29806
31119
  const parent = getCurrent();
29807
- const o = get$9(state.map, key);
31120
+ const o = get$10(state.map, key);
29808
31121
  let entry;
29809
31122
  if (o._tag === "Some") {
29810
31123
  entry = o.value;
@@ -29838,7 +31151,7 @@ const get$8 = /*#__PURE__*/ dual(2, (self, key) => uninterruptibleMask((restore)
29838
31151
  }));
29839
31152
  const removeInterrupted = (self, key, entry, context) => {
29840
31153
  if (self.state._tag === "Closed") return;
29841
- const o = get$9(self.state.map, key);
31154
+ const o = get$10(self.state.map, key);
29842
31155
  if (o._tag === "None" || o.value !== entry) return;
29843
31156
  remove$4(self.state.map, key);
29844
31157
  if (entry.refCount > 0) return;
@@ -29855,13 +31168,13 @@ const release$1 = (self, key, entry) => suspend$3(() => {
29855
31168
  entry.refCount--;
29856
31169
  if (entry.refCount > 0) return void_$2;
29857
31170
  else if (self.state._tag === "Closed") return closeEntry(entry);
29858
- const o = get$9(self.state.map, key);
31171
+ const o = get$10(self.state.map, key);
29859
31172
  if (o._tag === "None" || o.value !== entry) return closeEntry(entry);
29860
31173
  else if (isZero$1(entry.idleTimeToLive)) {
29861
31174
  remove$4(self.state.map, key);
29862
31175
  return closeEntry(entry);
29863
31176
  } else if (!isFinite$1(entry.idleTimeToLive)) return void_$2;
29864
- const clock = get$12(self.context, Clock);
31177
+ const clock = get$13(self.context, Clock);
29865
31178
  resetExpiresAt(entry, clock);
29866
31179
  if (entry.fiber) return void_$2;
29867
31180
  entry.fiber = uninterruptibleMask(function loop(restore) {
@@ -29869,7 +31182,7 @@ const release$1 = (self, key, entry) => suspend$3(() => {
29869
31182
  const remaining = entry.expiresAt - now;
29870
31183
  if (remaining <= 0) {
29871
31184
  if (self.state._tag === "Closed" || entry.refCount > 0) return void_$2;
29872
- const o = get$9(self.state.map, key);
31185
+ const o = get$10(self.state.map, key);
29873
31186
  if (o._tag === "None" || o.value !== entry) return void_$2;
29874
31187
  remove$4(self.state.map, key);
29875
31188
  return ignoreCause(close(entry.scope, void_$3), {
@@ -29911,7 +31224,7 @@ var RcRefImpl = class {
29911
31224
  /** @internal */
29912
31225
  const make$73 = (options) => withFiber((fiber) => {
29913
31226
  const context = fiber.context;
29914
- const scope = get$12(context, Scope);
31227
+ const scope = get$13(context, Scope);
29915
31228
  const ref = new RcRefImpl(options.acquire, context, scope, options.idleTimeToLive !== void 0 ? fromInputUnsafe$1(options.idleTimeToLive) : void 0);
29916
31229
  return as(addFinalizerExit(scope, () => {
29917
31230
  const state = ref.state;
@@ -30544,6 +31857,39 @@ const fromArray = (array) => isReadonlyArrayNonEmpty(array) ? fromChannel(succee
30544
31857
  */
30545
31858
  const fromQueue = (queue) => fromChannel(fromQueueArray(queue));
30546
31859
  /**
31860
+ * Creates a stream from a PubSub of `Take` values.
31861
+ *
31862
+ * **Details**
31863
+ *
31864
+ * `Take` values include end and failure signals.
31865
+ *
31866
+ * **Example** (Creating a stream from PubSub takes)
31867
+ *
31868
+ * ```ts import.meta.vitest
31869
+ * import { Effect, Exit, PubSub, Stream, Take } from "effect"
31870
+ *
31871
+ * const program = Effect.gen(function*() {
31872
+ * const pubsub = yield* PubSub.unbounded<Take.Take<number, string>>({
31873
+ * replay: 3
31874
+ * })
31875
+ *
31876
+ * yield* PubSub.publish(pubsub, [1])
31877
+ * yield* PubSub.publish(pubsub, [2])
31878
+ * yield* PubSub.publish(pubsub, Exit.succeed<void>(undefined))
31879
+ *
31880
+ * const values = yield* Stream.fromPubSubTake(pubsub).pipe(Stream.runCollect)
31881
+ * values // => [1, 2]
31882
+ * })
31883
+ *
31884
+ * await Effect.runPromise(program)
31885
+ * ```
31886
+ *
31887
+ * @stability stable
31888
+ * @category constructors
31889
+ * @since 4.0.0
31890
+ */
31891
+ const fromPubSubTake = (pubsub) => fromChannel(fromPubSubTake$1(pubsub));
31892
+ /**
30547
31893
  * Creates a stream from a lazily supplied Web `ReadableStream`.
30548
31894
  *
30549
31895
  * **Details**
@@ -30587,6 +31933,41 @@ const fromQueue = (queue) => fromChannel(fromQueueArray(queue));
30587
31933
  */
30588
31934
  const fromReadableStream = (options) => fromChannel(fromReadableStream$1(options));
30589
31935
  /**
31936
+ * Creates a stream by repeatedly applying an effectful step function to a
31937
+ * state.
31938
+ *
31939
+ * **Details**
31940
+ *
31941
+ * Each `readonly [value, nextState]` result emits `value` and continues with
31942
+ * `nextState`; returning `undefined` ends the stream.
31943
+ *
31944
+ * **Example** (Unfolding stream state)
31945
+ *
31946
+ * ```ts import.meta.vitest
31947
+ * import { Effect, Stream } from "effect"
31948
+ *
31949
+ * const program = Effect.gen(function*() {
31950
+ * const stream = Stream.unfold(1, (n) => Effect.succeed([n, n + 1] as const))
31951
+ * const values = yield* Stream.runCollect(stream.pipe(Stream.take(5)))
31952
+ * values // => [ 1, 2, 3, 4, 5 ]
31953
+ * })
31954
+ *
31955
+ * await Effect.runPromise(program)
31956
+ * ```
31957
+ *
31958
+ * @stability stable
31959
+ * @category constructors
31960
+ * @since 2.0.0
31961
+ */
31962
+ const unfold = (s, f) => fromPull(sync(() => {
31963
+ let state = s;
31964
+ return flatMap$3(suspend$3(() => f(state)), (next) => {
31965
+ if (next === void 0) return done();
31966
+ state = next[1];
31967
+ return succeed$5(of(next[0]));
31968
+ });
31969
+ }));
31970
+ /**
30590
31971
  * Creates a stream produced from an `Effect`.
30591
31972
  *
30592
31973
  * **Details**
@@ -31248,6 +32629,94 @@ const transduce = /*#__PURE__*/ dual(2, (self, sink) => transformPull(self, (ups
31248
32629
  return suspend$3(() => done$8 ? done$8 : pull);
31249
32630
  })));
31250
32631
  /**
32632
+ * Creates a PubSub-backed stream that multicasts the source to all subscribers.
32633
+ *
32634
+ * **Details**
32635
+ *
32636
+ * The returned stream is scoped and uses the provided PubSub capacity and replay settings.
32637
+ *
32638
+ * **Example** (Broadcasting a stream)
32639
+ *
32640
+ * ```ts import.meta.vitest
32641
+ * import { Effect, Stream } from "effect"
32642
+ *
32643
+ * const program = Effect.scoped(
32644
+ * Effect.gen(function* () {
32645
+ * const broadcasted = yield* Stream.broadcast(Stream.fromArray([1, 2, 3]), {
32646
+ * capacity: 8,
32647
+ * replay: 3
32648
+ * })
32649
+ *
32650
+ * const [left, right] = yield* Effect.all([
32651
+ * Stream.runCollect(broadcasted),
32652
+ * Stream.runCollect(broadcasted)
32653
+ * ], { concurrency: "unbounded" })
32654
+ *
32655
+ * const result = [left, right] // => [[1, 2, 3], [1, 2, 3]]
32656
+ * })
32657
+ * )
32658
+ *
32659
+ * await Effect.runPromise(program)
32660
+ * ```
32661
+ *
32662
+ * @stability stable
32663
+ * @category broadcasting
32664
+ * @since 2.0.0
32665
+ */
32666
+ const broadcast = /*#__PURE__*/ dual(2, (self, options) => map$7(toPubSubTake(self, options), fromPubSubTake));
32667
+ /**
32668
+ * Returns a new Stream that multicasts the original stream, subscribing when the first consumer starts.
32669
+ *
32670
+ * **Details**
32671
+ *
32672
+ * The upstream continues running while there is at least one consumer and is finalized after the last one exits.
32673
+ * If `idleTimeToLive` is set, the upstream is kept alive for that duration so a later subscriber can continue from
32674
+ * the next element instead of restarting.
32675
+ *
32676
+ * **Example** (Sharing a stream)
32677
+ *
32678
+ * ```ts import.meta.vitest
32679
+ * import { Deferred, Effect, Ref, Stream } from "effect"
32680
+ *
32681
+ * const result = await Effect.runPromise(
32682
+ * Effect.scoped(
32683
+ * Effect.gen(function*() {
32684
+ * const firstReady = yield* Deferred.make<void>()
32685
+ * const secondReady = yield* Deferred.make<void>()
32686
+ * const acquisitions = yield* Ref.make(0)
32687
+ * const source = Stream.fromEffect(Ref.update(acquisitions, (n) => n + 1)).pipe(
32688
+ * Stream.drain,
32689
+ * Stream.concat(Stream.make(0)),
32690
+ * Stream.concat(
32691
+ * Stream.fromEffect(Effect.all([Deferred.await(firstReady), Deferred.await(secondReady)])).pipe(Stream.drain)
32692
+ * ),
32693
+ * Stream.concat(Stream.make(1, 2, 3))
32694
+ * )
32695
+ * const shared = yield* Stream.share(source, { capacity: 16, replay: 1 })
32696
+ * const consume = (ready: Deferred.Deferred<void>) =>
32697
+ * shared.pipe(
32698
+ * Stream.tap((value) => value === 0 ? Deferred.succeed(ready, void 0) : Effect.void),
32699
+ * Stream.filter((value) => value !== 0),
32700
+ * Stream.runCollect
32701
+ * )
32702
+ *
32703
+ * const values = yield* Effect.all([consume(firstReady), consume(secondReady)], { concurrency: "unbounded" })
32704
+ * return { values, acquisitions: yield* Ref.get(acquisitions) }
32705
+ * })
32706
+ * )
32707
+ * )
32708
+ * result // => { values: [[1, 2, 3], [1, 2, 3]], acquisitions: 1 }
32709
+ * ```
32710
+ *
32711
+ * @stability stable
32712
+ * @category broadcasting
32713
+ * @since 3.8.0
32714
+ */
32715
+ const share = /*#__PURE__*/ dual(2, (self, options) => map$7(make$72({
32716
+ acquire: broadcast(self, options),
32717
+ idleTimeToLive: options.idleTimeToLive
32718
+ }), (ref) => unwrap$4(get$6(ref))));
32719
+ /**
31251
32720
  * Pipes values through the provided channel while preserving this stream's
31252
32721
  * failures alongside any channel failures.
31253
32722
  *
@@ -31878,6 +33347,39 @@ const toReadableStream = /*#__PURE__*/ dual((args) => isStream(args[0]), (self,
31878
33347
  * @since 2.0.0
31879
33348
  */
31880
33349
  const toReadableStreamEffect = /*#__PURE__*/ dual((args) => isStream(args[0]), (self, options) => map$7(context(), (context) => toReadableStreamWith(self, context, options)));
33350
+ /**
33351
+ * Converts a stream to a PubSub of `Take` values for concurrent consumption.
33352
+ *
33353
+ * **Details**
33354
+ *
33355
+ * Chunks are published as `Take` values. When the stream ends, the PubSub is
33356
+ * ended with the stream's `Exit`, so every subscriber, including one that
33357
+ * subscribes later, observes completion or failure after its buffered chunks.
33358
+ *
33359
+ * **Example** (Converting to a PubSub of takes)
33360
+ *
33361
+ * ```ts import.meta.vitest
33362
+ * import { Effect, PubSub, Stream } from "effect"
33363
+ *
33364
+ * const program = Effect.gen(function* () {
33365
+ * const pubsub = yield* Stream.fromArray([1, 2, 3]).pipe(
33366
+ * Stream.toPubSubTake({ capacity: 8 })
33367
+ * )
33368
+ * const subscription = yield* PubSub.subscribe(pubsub)
33369
+ * const take = yield* PubSub.take(subscription)
33370
+ *
33371
+ * if (Array.isArray(take)) {
33372
+ * take // => [ 1, 2, 3 ]
33373
+ * }
33374
+ * })
33375
+ * await Effect.runPromise(Effect.scoped(program))
33376
+ * ```
33377
+ *
33378
+ * @stability stable
33379
+ * @category destructors
33380
+ * @since 4.0.0
33381
+ */
33382
+ const toPubSubTake = /*#__PURE__*/ dual(2, (self, options) => toPubSubTake$1(self.channel, options));
31881
33383
  // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/FileSystem.js
31882
33384
  /**
31883
33385
  * Defines the portable file system service for Effect programs.
@@ -34383,7 +35885,7 @@ const BigDecimalProto = {
34383
35885
  [TypeId$48]: TypeId$48,
34384
35886
  [symbol$3]() {
34385
35887
  const normalized = normalize(this);
34386
- return combine$3(string$2(String(normalized.value)), number$2(normalized.scale));
35888
+ return combine$4(string$2(String(normalized.value)), number$2(normalized.scale));
34387
35889
  },
34388
35890
  [symbol$2](that) {
34389
35891
  return isBigDecimal(that) && compare$1(this, that) === 0;
@@ -34568,7 +36070,7 @@ const compare$1 = (self, that) => {
34568
36070
  * @category instances
34569
36071
  * @since 2.0.0
34570
36072
  */
34571
- const Order$1 = /*#__PURE__*/ make$90(compare$1);
36073
+ const Order$1 = /*#__PURE__*/ make$91(compare$1);
34572
36074
  /**
34573
36075
  * Determines the sign of a given `BigDecimal`.
34574
36076
  *
@@ -37996,7 +39498,7 @@ const value$2 = value$3;
37996
39498
  * @category instances
37997
39499
  * @since 4.0.0
37998
39500
  */
37999
- const makeEquivalence = (isEquivalent) => make$91((x, y) => isEquivalent(value$2(x), value$2(y)));
39501
+ const makeEquivalence = (isEquivalent) => make$92((x, y) => isEquivalent(value$2(x), value$2(y)));
38000
39502
  // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/process/CommandLine.js
38001
39503
  /**
38002
39504
  * Builds command lines, the single strings that a shell or a Windows program
@@ -40127,7 +41629,7 @@ const TypeId$42 = /*#__PURE__*/ Symbol.for("~effect/http/Headers");
40127
41629
  const Proto$15 = /*#__PURE__*/ Object.defineProperties(/*#__PURE__*/ Object.create(null), {
40128
41630
  [TypeId$42]: { value: TypeId$42 },
40129
41631
  [symbolRedactable]: { value(context) {
40130
- return redact$1(this, get$12(context, CurrentRedactedNames$1));
41632
+ return redact$1(this, get$13(context, CurrentRedactedNames$1));
40131
41633
  } },
40132
41634
  toJSON: { value() {
40133
41635
  return redact$2(this);
@@ -43616,7 +45118,7 @@ function mergeLeaves(edit, shift, hash1, node1, hash2, node2) {
43616
45118
  return new IndexedNode(edit, bit1 | bit2, bit1 >>> 0 < bit2 >>> 0 ? [node1, node2] : [node2, node1]);
43617
45119
  }
43618
45120
  const hashMapSeed = /*#__PURE__*/ string$2("HashMap");
43619
- const entryHash = (key, value) => combine$3(hash(key), hash(value));
45121
+ const entryHash = (key, value) => combine$4(hash(key), hash(value));
43620
45122
  const childrenHash = (children) => {
43621
45123
  let h = 0;
43622
45124
  for (let i = 0; i < children.length; i++) {
@@ -44277,7 +45779,7 @@ const HashSetTypeId = "~effect/HashSet";
44277
45779
  const hashSetSeed = /*#__PURE__*/ string$2(HashSetTypeId);
44278
45780
  const HashSetProto = {
44279
45781
  [symbol$3]() {
44280
- return optimize(combine$3(hashSetSeed, hash(keyMap(this))));
45782
+ return optimize(combine$4(hashSetSeed, hash(keyMap(this))));
44281
45783
  },
44282
45784
  [symbol$2](that) {
44283
45785
  return isHashSet$1(that) && size(this) === size(that) && every(this, (value) => has$1(that, value));
@@ -44470,7 +45972,7 @@ const Proto$14 = {
44470
45972
  [symbolRedactable](context) {
44471
45973
  return {
44472
45974
  _id: "UrlParams",
44473
- params: Object.fromEntries(redact(this, get$12(context, CurrentRedactedNames)))
45975
+ params: Object.fromEntries(redact(this, get$13(context, CurrentRedactedNames)))
44474
45976
  };
44475
45977
  },
44476
45978
  toJSON() {
@@ -44546,7 +46048,7 @@ const coerce = (value) => isRedacted(value) ? value : String(value);
44546
46048
  * @category instances
44547
46049
  * @since 4.0.0
44548
46050
  */
44549
- const Equivalence = /*#__PURE__*/ make$91((a, b) => arrayEquivalence(a.params, b.params));
46051
+ const Equivalence = /*#__PURE__*/ make$92((a, b) => arrayEquivalence(a.params, b.params));
44550
46052
  const arrayEquivalence = /*#__PURE__*/ makeEquivalence$2(/*#__PURE__*/ makeEquivalence$4([/*#__PURE__*/ strictEqual(), /*#__PURE__*/ asEquivalence()]));
44551
46053
  /**
44552
46054
  * An empty `UrlParams` value.
@@ -44683,7 +46185,7 @@ const decodeQueryKey = (key) => {
44683
46185
  return key;
44684
46186
  }
44685
46187
  };
44686
- const currentRedactedNames = () => get$12(globalThis["~effect/Fiber/currentFiber"]?.context ?? empty$14(), CurrentRedactedNames);
46188
+ const currentRedactedNames = () => get$13(globalThis["~effect/Fiber/currentFiber"]?.context ?? empty$14(), CurrentRedactedNames);
44687
46189
  /**
44688
46190
  * Query parameter names or patterns to redact in inspection, spans and errors.
44689
46191
  *
@@ -46588,7 +48090,7 @@ const recur = /*#__PURE__*/ memoize((ast) => {
46588
48090
  const rest = ast.rest.map(recur);
46589
48091
  const [head, ...tail] = rest;
46590
48092
  const tailLength = tail.length;
46591
- return make$91((a, b) => {
48093
+ return make$92((a, b) => {
46592
48094
  if (!Array.isArray(a) || !Array.isArray(b)) return false;
46593
48095
  const len = a.length;
46594
48096
  if (len !== b.length) return false;
@@ -46605,7 +48107,7 @@ const recur = /*#__PURE__*/ memoize((ast) => {
46605
48107
  if (ast.propertySignatures.length === 0 && ast.indexSignatures.length === 0) return equals$1;
46606
48108
  const propertySignatures = ast.propertySignatures.map((ps) => recur(ps.type));
46607
48109
  const indexSignatures = ast.indexSignatures.map((is) => recur(is.type));
46608
- return make$91((a, b) => {
48110
+ return make$92((a, b) => {
46609
48111
  if (!isObject$2(a) || !isObject$2(b)) return false;
46610
48112
  for (let i = 0; i < propertySignatures.length; i++) {
46611
48113
  const ps = ast.propertySignatures[i];
@@ -46634,7 +48136,7 @@ const recur = /*#__PURE__*/ memoize((ast) => {
46634
48136
  const types = ast.types;
46635
48137
  const index = getCandidateIndex(types);
46636
48138
  const compiled = types.map((candidate) => [_is(candidate), recur(candidate)]);
46637
- return make$91((a, b) => {
48139
+ return make$92((a, b) => {
46638
48140
  const candidates = index(a, false);
46639
48141
  for (let i = 0; i < candidates.length; i++) {
46640
48142
  const [is, equivalence] = compiled[candidates[i]];
@@ -46645,7 +48147,7 @@ const recur = /*#__PURE__*/ memoize((ast) => {
46645
48147
  }
46646
48148
  case "Suspend": {
46647
48149
  let equivalence;
46648
- return make$91((a, b) => (equivalence ??= toEquivalence$1(ast.thunk()))(a, b));
48150
+ return make$92((a, b) => (equivalence ??= toEquivalence$1(ast.thunk()))(a, b));
46649
48151
  }
46650
48152
  }
46651
48153
  });
@@ -46900,7 +48402,7 @@ const IpInterfaceProto = {
46900
48402
  return isIpInterface(that) && this.prefixLength === that.prefixLength && equals$1(this.address, that.address);
46901
48403
  },
46902
48404
  [symbol$3]() {
46903
- return combine$3(hash(this.address), number$2(this.prefixLength));
48405
+ return combine$4(hash(this.address), number$2(this.prefixLength));
46904
48406
  },
46905
48407
  toString() {
46906
48408
  return format$2(this);
@@ -46988,7 +48490,7 @@ const IpNetworkProto = {
46988
48490
  return isIpNetwork(that) && this.prefixLength === that.prefixLength && equals$1(this.address, that.address);
46989
48491
  },
46990
48492
  [symbol$3]() {
46991
- return combine$3(hash(this.address), number$2(this.prefixLength));
48493
+ return combine$4(hash(this.address), number$2(this.prefixLength));
46992
48494
  },
46993
48495
  toString() {
46994
48496
  return format$1(this);
@@ -50842,7 +52344,7 @@ const stream$2 = (body, contentType, contentLength) => new Stream$1(body, conten
50842
52344
  /** @internal */
50843
52345
  const CurrentClientPath = /*#__PURE__*/ Reference("effect/http/internal/clientPath/CurrentClientPath", { defaultValue: () => void 0 });
50844
52346
  /** @internal */
50845
- const currentClientPath = () => get$12(globalThis["~effect/Fiber/currentFiber"]?.context ?? empty$14(), CurrentClientPath);
52347
+ const currentClientPath = () => get$13(globalThis["~effect/Fiber/currentFiber"]?.context ?? empty$14(), CurrentClientPath);
50846
52348
  /**
50847
52349
  * Replaces the path of a URL with its redacted form. A pathname that does not
50848
52350
  * match the expected sent pathname is replaced by `/REDACTED`.
@@ -52221,7 +53723,7 @@ const retryTransient = /*#__PURE__*/ dual(2, (self, options) => {
52221
53723
  const parseRetryAfter = (nowMillis, value) => {
52222
53724
  if (value === void 0) return;
52223
53725
  const retryAfter = parseRetryAfter$1(value);
52224
- return isSuccess$2(retryAfter) ? max(retryAfterDelay$1(retryAfter.success, nowMillis), millis(1)) : void 0;
53726
+ return isSuccess$2(retryAfter) ? max$1(retryAfterDelay$1(retryAfter.success, nowMillis), millis(1)) : void 0;
52225
53727
  };
52226
53728
  /**
52227
53729
  * Performs an additional effect after a successful request.
@@ -52457,7 +53959,7 @@ const retryAfterOf = (input, nowMillis) => {
52457
53959
  const withRetryAfter = (schedule) => fromStep(map$7(toStep(schedule), (step) => (now, input) => {
52458
53960
  const retryAfter = retryAfterOf(input, now);
52459
53961
  if (retryAfter === void 0) return step(now, input);
52460
- return map$7(step(now, input), ([output, delay]) => [output, max(delay, retryAfter)]);
53962
+ return map$7(step(now, input), ([output, delay]) => [output, max$1(delay, retryAfter)]);
52461
53963
  }));
52462
53964
  /**
52463
53965
  * Returns `true` for a response whose status `retryTransient` retries by
@@ -55959,7 +57461,7 @@ const isMultipartError = (u) => hasProperty(u, MultipartErrorTypeId);
55959
57461
  * @since 4.0.0
55960
57462
  */
55961
57463
  const makeConfig = (headers) => withFiber((fiber) => {
55962
- const mimeTypes = get$12(fiber.context, FieldMimeTypes);
57464
+ const mimeTypes = get$13(fiber.context, FieldMimeTypes);
55963
57465
  return succeed$5({
55964
57466
  headers,
55965
57467
  maxParts: fiber.getRef(MaxParts),
@@ -57352,7 +58854,7 @@ var MiddlewareImpl = class MiddlewareImpl {
57352
58854
  const stack = [getOrUndefinedUnsafe(context$4, fnContextKey)];
57353
58855
  if (this.dependencies) {
57354
58856
  const memoMap = yield* CurrentMemoMap;
57355
- const scope = get$12(context$4, Scope);
58857
+ const scope = get$13(context$4, Scope);
57356
58858
  const depsContext = yield* buildWithMemoMap(this.dependencies, memoMap, scope);
57357
58859
  stack.push(...getMiddleware$1(depsContext));
57358
58860
  }
@@ -57407,9 +58909,9 @@ const serve = (appLayer, options) => {
57407
58909
  const layerWithRouter = provideMerge(appLayer, options?.routerConfig ? provide$2(layer$21, succeed$6(RouterConfig)(options.routerConfig)) : layer$21);
57408
58910
  return contextWith((context) => {
57409
58911
  const memoMap = CurrentMemoMap.forkOrCreate(context);
57410
- return buildWithMemoMap(layerWithRouter, memoMap, get$12(context, Scope));
58912
+ return buildWithMemoMap(layerWithRouter, memoMap, get$13(context, Scope));
57411
58913
  }).pipe(map$7((context) => {
57412
- const handler = get$12(context, HttpRouter).asHttpEffect();
58914
+ const handler = get$13(context, HttpRouter).asHttpEffect();
57413
58915
  return provideMerge(middleware ? serve$1(handler, middleware) : serve$1(handler), succeedContext(context));
57414
58916
  }), unwrap$7, options?.disableListenLog ? identity : withLogAddress);
57415
58917
  };
@@ -62311,7 +63813,7 @@ const makeNoSerialization$1 = /*#__PURE__*/ fnUntraced(function* (group, options
62311
63813
  const disableTracing = options?.disableTracing ?? false;
62312
63814
  const generateRequestId = options?.generateRequestId ?? (() => requestIdCounter++);
62313
63815
  const services = yield* context();
62314
- const scope = get$12(services, Scope);
63816
+ const scope = get$13(services, Scope);
62315
63817
  const entries = /* @__PURE__ */ new Map();
62316
63818
  let isShutdown = false;
62317
63819
  yield* addFinalizer$1(scope, withFiber((parent) => {
@@ -62327,7 +63829,7 @@ const makeNoSerialization$1 = /*#__PURE__*/ fnUntraced(function* (group, options
62327
63829
  const traceFields = (fiber, clientSpan) => {
62328
63830
  if (disableTracing || !fiber.cache.tracerEnabled || fiber.getRef(DisablePropagation)) return void 0;
62329
63831
  const span = clientSpan ?? fiber.cache.span;
62330
- if (!span || get$12(span.annotations, DisablePropagation)) return void 0;
63832
+ if (!span || get$13(span.annotations, DisablePropagation)) return void 0;
62331
63833
  return {
62332
63834
  traceId: span.traceId,
62333
63835
  spanId: span.spanId,
@@ -62337,7 +63839,7 @@ const makeNoSerialization$1 = /*#__PURE__*/ fnUntraced(function* (group, options
62337
63839
  const onRequest = (rpc) => {
62338
63840
  const isStream = isStreamSchema(rpc.successSchema);
62339
63841
  const middleware = getRpcClientMiddleware(rpc);
62340
- const tracing = get$12(rpc.annotations, TracingEnabled);
63842
+ const tracing = get$13(rpc.annotations, TracingEnabled);
62341
63843
  const createSpan = !disableTracing && (tracing === "both" || tracing === "client");
62342
63844
  return (payload, opts) => {
62343
63845
  const headers = opts?.headers ? fromInput$1(opts.headers) : empty$6;
@@ -62667,7 +64169,7 @@ const makeRpcSchemas = (codecFor) => {
62667
64169
  let entry = cache.get(rpc);
62668
64170
  if (entry !== void 0) return entry;
62669
64171
  const streamSchemas = getStreamSchemas(rpc.successSchema);
62670
- const parseOptions = get$12(rpc.annotations, ParseOptions);
64172
+ const parseOptions = get$13(rpc.annotations, ParseOptions);
62671
64173
  const exitSchema$2 = exitSchema(rpc);
62672
64174
  let decodeDiscardExit;
62673
64175
  entry = {
@@ -63379,7 +64881,7 @@ const makeNoSerialization = /*#__PURE__*/ fnUntraced(function* (group, options)
63379
64881
  const concurrency = options.concurrency ?? "unbounded";
63380
64882
  const disableFatalDefects = options.disableFatalDefects ?? false;
63381
64883
  const services = yield* context();
63382
- const scope = get$12(services, Scope);
64884
+ const scope = get$13(services, Scope);
63383
64885
  const trackFiber = runIn(forkUnsafe(scope, "parallel"));
63384
64886
  const concurrencySemaphore = concurrency === "unbounded" ? void 0 : yield* make$75(concurrency);
63385
64887
  const clients = /* @__PURE__ */ new Map();
@@ -63526,7 +65028,7 @@ const makeNoSerialization = /*#__PURE__*/ fnUntraced(function* (group, options)
63526
65028
  return close ? ensuring$2(write, close) : write;
63527
65029
  });
63528
65030
  if (opts?.onRequest) effect = opts.onRequest(effect, request);
63529
- const tracing = get$12(rpc.annotations, TracingEnabled);
65031
+ const tracing = get$13(rpc.annotations, TracingEnabled);
63530
65032
  if (enableTracing && (tracing === "both" || tracing === "server")) {
63531
65033
  const parentSpan = getOrUndefined$1(requestFiber.context, ParentSpan);
63532
65034
  effect = withSpan(effect, spanName$1(spanPrefix, request.tag), {
@@ -63622,7 +65124,7 @@ const rpcCodecs = (codecFor, rpc) => {
63622
65124
  let codecs = shared ? sharedRpcCodecs.get(rpc) : void 0;
63623
65125
  if (codecs === void 0) {
63624
65126
  const streamSchemas = getStreamSchemas(rpc.successSchema);
63625
- const parseOptions = get$12(rpc.annotations, ParseOptions);
65127
+ const parseOptions = get$13(rpc.annotations, ParseOptions);
63626
65128
  codecs = {
63627
65129
  decode: decodeUnknownEffect(codecFor(rpc.payloadSchema), parseOptions),
63628
65130
  encodeChunk: encodeUnknownEffect(codecFor(NonEmptyArray(isSome(streamSchemas) ? streamSchemas.value.success : Any)), parseOptions),
@@ -63760,7 +65262,7 @@ const make$33 = /*#__PURE__*/ fnUntraced(function* (group, options) {
63760
65262
  const exitSchema$1 = exitSchema(rpc);
63761
65263
  discardSchemas = {
63762
65264
  ...schemas,
63763
- encodeExit: encodeUnknownEffect(codecFor(Exit(Void, exitSchema$1.error, exitSchema$1.defect)), get$12(rpc.annotations, ParseOptions))
65265
+ encodeExit: encodeUnknownEffect(codecFor(Exit(Void, exitSchema$1.error, exitSchema$1.defect)), get$13(rpc.annotations, ParseOptions))
63764
65266
  };
63765
65267
  discardSchemasCache.set(rpc, discardSchemas);
63766
65268
  }
@@ -64225,7 +65727,7 @@ const RpcGroupProto = {
64225
65727
  });
64226
65728
  },
64227
65729
  annotateRpcs(service, value) {
64228
- return this.annotateRpcsMerge(make$89(service, value));
65730
+ return this.annotateRpcsMerge(make$90(service, value));
64229
65731
  },
64230
65732
  annotateMerge(context) {
64231
65733
  return makeProto$1({
@@ -65500,7 +67002,7 @@ const make$29 = /*#__PURE__*/ sync(() => {
65500
67002
  };
65501
67003
  const query = (keys, effect) => gen(function* () {
65502
67004
  const services = yield* context();
65503
- const scope = get$12(services, Scope);
67005
+ const scope = get$13(services, Scope);
65504
67006
  const results = yield* make$76();
65505
67007
  const runFork = flow(runForkWith(services), runIn(scope));
65506
67008
  let running = false;
@@ -67293,7 +68795,7 @@ const migrationsTableExists = (sql, table) => {
67293
68795
  const quotedTable = sql`${sql(table)}`.compile(true)[0];
67294
68796
  return map$7(sql`SELECT 1 AS found WHERE to_regclass(${quotedTable}) IS NOT NULL`.withoutTransform, (rows) => rows.length > 0);
67295
68797
  };
67296
- const migrationOrder = /*#__PURE__*/ make$90(([a], [b]) => Number$6(a, b));
68798
+ const migrationOrder = /*#__PURE__*/ make$91(([a], [b]) => Number$6(a, b));
67297
68799
  const isConstraintConflict = (error) => error.reason._tag === "ConstraintError" || error.reason._tag === "UniqueViolation";
67298
68800
  /**
67299
68801
  * Creates a migration loader from a record of migration effects keyed by
@@ -74418,7 +75920,7 @@ const defaultTimeToLive = (_, _key) => infinity$1;
74418
75920
  * @since 4.0.0
74419
75921
  */
74420
75922
  const get = /*#__PURE__*/ dual(2, (self, key) => withFiber$1((fiber) => {
74421
- const oentry = get$9(self.map, key);
75923
+ const oentry = get$10(self.map, key);
74422
75924
  if (isSome(oentry)) {
74423
75925
  remove$4(self.map, key);
74424
75926
  if (!hasExpired(oentry.value, fiber)) {
@@ -74472,7 +75974,7 @@ var EntryImpl = class {
74472
75974
  }
74473
75975
  };
74474
75976
  const removeEntry = (self, key, entry) => {
74475
- const current = get$9(self.map, key);
75977
+ const current = get$10(self.map, key);
74476
75978
  if (isSome(current) && current.value === entry) remove$4(self.map, key);
74477
75979
  };
74478
75980
  const hasExpired = (entry, fiber) => {
@@ -80393,7 +81895,7 @@ const Strict = /*#__PURE__*/ Reference("effect/ai/Tool/Strict", { defaultValue:
80393
81895
  * @category getters
80394
81896
  * @since 4.0.0
80395
81897
  */
80396
- const getStrictMode = (tool) => get$12(tool.annotations, Strict);
81898
+ const getStrictMode = (tool) => get$13(tool.annotations, Strict);
80397
81899
  /**
80398
81900
  * Schema for denied or interrupted tool calls.
80399
81901
  *
@@ -80614,7 +82116,7 @@ const stringifyToolArguments = (params) => {
80614
82116
  return String(params);
80615
82117
  }
80616
82118
  };
80617
- const failureCause = (error, origin) => annotate$2(fail$8(error), make$89(FailureOrigin, origin));
82119
+ const failureCause = (error, origin) => annotate$2(fail$8(error), make$90(FailureOrigin, origin));
80618
82120
  const failureOrigin = (error) => isSchemaError(error) ? "result" : "handler";
80619
82121
  const Proto$3 = {
80620
82122
  .../*#__PURE__*/ Prototype({
@@ -80721,7 +82223,7 @@ const Proto$3 = {
80721
82223
  reason: error
80722
82224
  }) : error;
80723
82225
  };
80724
- return fromQueue(queue).pipe(tool.failureMode === "error" ? catchCause((cause) => failCause(map$8(fromReasons(cause.reasons.map((reason) => isFailReason(reason) ? reason.annotate(make$89(FailureOrigin, failureOrigin(reason.error)), { overwrite: true }) : reason)), normalizeError))) : catch_((error) => succeed$3({
82226
+ return fromQueue(queue).pipe(tool.failureMode === "error" ? catchCause((cause) => failCause(map$8(fromReasons(cause.reasons.map((reason) => isFailReason(reason) ? reason.annotate(make$90(FailureOrigin, failureOrigin(reason.error)), { overwrite: true }) : reason)), normalizeError))) : catch_((error) => succeed$3({
80725
82227
  result: normalizeError(error),
80726
82228
  isFailure: true,
80727
82229
  failureOrigin: failureOrigin(error),
@@ -81099,7 +82601,7 @@ var PaginatedResultMeta = class extends (/*#__PURE__*/ Opaque()(/*#__PURE__*/ St
81099
82601
  * @category schemas
81100
82602
  * @since 4.0.0
81101
82603
  */
81102
- const Role$3 = /*#__PURE__*/ Literals(["user", "assistant"]);
82604
+ const Role$4 = /*#__PURE__*/ Literals(["user", "assistant"]);
81103
82605
  /**
81104
82606
  * Schema for optional client-facing annotations on MCP objects.
81105
82607
  *
@@ -81119,7 +82621,7 @@ var Annotations$3 = class extends (/*#__PURE__*/ Opaque()(/*#__PURE__*/ Struct$2
81119
82621
  * It can include multiple entries to indicate content useful for multiple
81120
82622
  * audiences (e.g., `["user", "assistant"]`).
81121
82623
  */
81122
- audience: /*#__PURE__*/ optional$7(/*#__PURE__*/ ArraySchema(Role$3)),
82624
+ audience: /*#__PURE__*/ optional$7(/*#__PURE__*/ ArraySchema(Role$4)),
81123
82625
  /**
81124
82626
  * Describes how important this data is for operating the server.
81125
82627
  *
@@ -82313,7 +83815,7 @@ const SamplingMessageContentBlock$2 = /*#__PURE__*/ Union$2([
82313
83815
  * @since 4.0.0
82314
83816
  */
82315
83817
  var SamplingMessage$5 = class extends (/*#__PURE__*/ Opaque()(/*#__PURE__*/ Struct$2({
82316
- role: Role$3,
83818
+ role: Role$4,
82317
83819
  content: /*#__PURE__*/ Union$2([SamplingMessageContentBlock$2, /*#__PURE__*/ ArraySchema(SamplingMessageContentBlock$2)]),
82318
83820
  _meta: /*#__PURE__*/ optional$7(UnknownObject$5)
82319
83821
  }))) {};
@@ -82437,7 +83939,7 @@ var ModelPreferences$2 = class extends (/*#__PURE__*/ Class$1("@effect/ai/McpSch
82437
83939
  * @since 4.0.0
82438
83940
  */
82439
83941
  var CreateMessageResult$5 = class extends (/*#__PURE__*/ Class$1("@effect/ai/McpSchema/CreateMessageResult")({
82440
- role: Role$3,
83942
+ role: Role$4,
82441
83943
  content: /*#__PURE__*/ Union$2([SamplingMessageContentBlock$2, /*#__PURE__*/ ArraySchema(SamplingMessageContentBlock$2)]),
82442
83944
  _meta: /*#__PURE__*/ optional$7(UnknownObject$5),
82443
83945
  /**
@@ -83464,7 +84966,7 @@ const ProgressToken$1 = /*#__PURE__*/ Union$2([String$6, Finite]);
83464
84966
  /**
83465
84967
  * @internal
83466
84968
  */
83467
- const Role$2 = /*#__PURE__*/ Literals(["user", "assistant"]);
84969
+ const Role$3 = /*#__PURE__*/ Literals(["user", "assistant"]);
83468
84970
  /**
83469
84971
  * @internal
83470
84972
  */
@@ -83547,7 +85049,7 @@ const McpError$1 = /*#__PURE__*/ Struct$2({
83547
85049
  * @internal
83548
85050
  */
83549
85051
  const Annotation = /*#__PURE__*/ Struct$2({
83550
- audience: /*#__PURE__*/ optional$6(/*#__PURE__*/ ArraySchema(Role$2)),
85052
+ audience: /*#__PURE__*/ optional$6(/*#__PURE__*/ ArraySchema(Role$3)),
83551
85053
  priority: /*#__PURE__*/ optional$6(/*#__PURE__*/ Finite.check(/*#__PURE__*/ isBetween({
83552
85054
  minimum: 0,
83553
85055
  maximum: 1
@@ -83887,7 +85389,7 @@ const ClientCapabilities$2 = /*#__PURE__*/ Struct$2({
83887
85389
  * @internal
83888
85390
  */
83889
85391
  const Annotations$2 = /*#__PURE__*/ Struct$2({
83890
- audience: /*#__PURE__*/ optional$4(/*#__PURE__*/ ArraySchema(Role$2)),
85392
+ audience: /*#__PURE__*/ optional$4(/*#__PURE__*/ ArraySchema(Role$3)),
83891
85393
  priority: /*#__PURE__*/ optional$4(/*#__PURE__*/ Finite.check(/*#__PURE__*/ isBetween({
83892
85394
  minimum: 0,
83893
85395
  maximum: 1
@@ -83999,14 +85501,14 @@ const SamplingContent = /*#__PURE__*/ Union$2([
83999
85501
  * @internal
84000
85502
  */
84001
85503
  const PromptMessage$2 = /*#__PURE__*/ Struct$2({
84002
- role: Role$2,
85504
+ role: Role$3,
84003
85505
  content: ContentBlock$2
84004
85506
  });
84005
85507
  /**
84006
85508
  * @internal
84007
85509
  */
84008
85510
  const SamplingMessage$2 = /*#__PURE__*/ Struct$2({
84009
- role: Role$2,
85511
+ role: Role$3,
84010
85512
  content: SamplingContent
84011
85513
  });
84012
85514
  /**
@@ -84067,7 +85569,7 @@ const CallToolResult$2 = /*#__PURE__*/ Struct$2({
84067
85569
  */
84068
85570
  const CreateMessageResult$2 = /*#__PURE__*/ Struct$2({
84069
85571
  ...ResultMeta$1.fields,
84070
- role: Role$2,
85572
+ role: Role$3,
84071
85573
  content: SamplingContent,
84072
85574
  model: String$6,
84073
85575
  stopReason: /*#__PURE__*/ optional$4(String$6)
@@ -84435,7 +85937,7 @@ const ContentBlock$1 = /*#__PURE__*/ Union$2([
84435
85937
  * @internal
84436
85938
  */
84437
85939
  const PromptMessage$1 = /*#__PURE__*/ Struct$2({
84438
- role: Role$2,
85940
+ role: Role$3,
84439
85941
  content: ContentBlock$1
84440
85942
  });
84441
85943
  /**
@@ -84491,7 +85993,7 @@ const SamplingMessageContentBlock$1 = /*#__PURE__*/ Union$2([
84491
85993
  * @internal
84492
85994
  */
84493
85995
  const SamplingMessage$1 = /*#__PURE__*/ Struct$2({
84494
- role: Role$2,
85996
+ role: Role$3,
84495
85997
  content: /*#__PURE__*/ Union$2([SamplingMessageContentBlock$1, /*#__PURE__*/ ArraySchema(SamplingMessageContentBlock$1)]),
84496
85998
  _meta: Meta$1
84497
85999
  });
@@ -84830,7 +86332,7 @@ const ProgressToken = RequestId;
84830
86332
  /**
84831
86333
  * @internal
84832
86334
  */
84833
- const Role$1 = Role$2;
86335
+ const Role$2 = Role$3;
84834
86336
  /**
84835
86337
  * @internal
84836
86338
  */
@@ -84972,7 +86474,7 @@ const Prompt = Prompt$1;
84972
86474
  * @internal
84973
86475
  */
84974
86476
  const PromptMessage = /*#__PURE__*/ Struct$2({
84975
- role: Role$1,
86477
+ role: Role$2,
84976
86478
  content: ContentBlock
84977
86479
  });
84978
86480
  const ToolInputSchema = /*#__PURE__*/ StructWithRest(/*#__PURE__*/ Struct$2({
@@ -85014,7 +86516,7 @@ const SamplingMessageContentBlock = /*#__PURE__*/ Union$2([
85014
86516
  * @internal
85015
86517
  */
85016
86518
  const SamplingMessage = /*#__PURE__*/ Struct$2({
85017
- role: Role$1,
86519
+ role: Role$2,
85018
86520
  content: /*#__PURE__*/ Union$2([SamplingMessageContentBlock, /*#__PURE__*/ ArraySchema(SamplingMessageContentBlock)]),
85019
86521
  _meta: Meta
85020
86522
  });
@@ -87260,7 +88762,7 @@ const getMiddleware = (context) => {
87260
88762
  };
87261
88763
  const isMcpError = (error) => hasProperty(error, "code") && typeof error.code === "number" && hasProperty(error, "message") && typeof error.message === "string";
87262
88764
  const HandlerFailure = /*#__PURE__*/ Reference("effect/ai/McpServer/HandlerFailure", { defaultValue: () => false });
87263
- const handlerFailure = /*#__PURE__*/ make$89(HandlerFailure, true);
88765
+ const handlerFailure = /*#__PURE__*/ make$90(HandlerFailure, true);
87264
88766
  const internalError = /*#__PURE__*/ new InternalError({ message: "Internal error" });
87265
88767
  const rejectWith = (error) => fail$7(new RequestRejected({
87266
88768
  code: error.code,
@@ -87306,7 +88808,7 @@ const runMiddleware = (handler, middleware, invocation, request) => {
87306
88808
  if (isSuccess$2(failure) && !hasDies(cause)) {
87307
88809
  const error = failure.success.error;
87308
88810
  if (isHidden(error)) return fail$7(error);
87309
- if (middleware.length === 0 || get$12(reasonAnnotations(failure.success), HandlerFailure)) return failCause$3(cause);
88811
+ if (middleware.length === 0 || get$13(reasonAnnotations(failure.success), HandlerFailure)) return failCause$3(cause);
87310
88812
  if (isMcpError(error)) return rejectWith(error);
87311
88813
  }
87312
88814
  return logError(cause).pipe(andThen(report(cause)), andThen(rejectWith(internalError)));
@@ -87389,7 +88891,7 @@ var McpServer = class McpServer extends (/*#__PURE__*/ Service$1()("effect/ai/Mc
87389
88891
  const queued = {
87390
88892
  notification,
87391
88893
  delivered,
87392
- requestLiveness: get$12(fiber.context, RequestLiveness),
88894
+ requestLiveness: get$13(fiber.context, RequestLiveness),
87393
88895
  requestContext: getOrUndefined$1(fiber.context, McpRequestContext),
87394
88896
  requestHeaders: getOrUndefined$1(fiber.context, HttpServerRequest)?.headers
87395
88897
  };
@@ -87399,7 +88901,7 @@ var McpServer = class McpServer extends (/*#__PURE__*/ Service$1()("effect/ai/Mc
87399
88901
  _tag: "Exit",
87400
88902
  exit: void_$3
87401
88903
  }));
87402
- const requestQueue = get$12(fiber.context, RequestNotificationQueue);
88904
+ const requestQueue = get$13(fiber.context, RequestNotificationQueue);
87403
88905
  if (requestQueue !== void 0 && queued.requestContext !== void 0 && isRequestNotification(notification)) {
87404
88906
  offerUnsafe(requestQueue, queued);
87405
88907
  return andThen(_await(delivered), acknowledge);
@@ -88526,7 +90028,7 @@ const registerToolkit = /*#__PURE__*/ fnUntraced(function* (toolkit, options) {
88526
90028
  const failure = findFail(cause);
88527
90029
  if (isSuccess$2(failure)) {
88528
90030
  const error = failure.success.error;
88529
- const origin = get$12(reasonAnnotations(failure.success), FailureOrigin);
90031
+ const origin = get$13(reasonAnnotations(failure.success), FailureOrigin);
88530
90032
  if (origin === "parameters" && isParameterValidationError(error)) return fail$7(new InvalidParams({ message: error.reason.message }));
88531
90033
  if (origin === "handler" && isInvalidParams(error)) return fail$7(error);
88532
90034
  if (origin === "handler" && isDeclaredFailure(error)) return catchCause$2(declaredFailureResult(error), internalToolError);
@@ -88537,7 +90039,7 @@ const registerToolkit = /*#__PURE__*/ fnUntraced(function* (toolkit, options) {
88537
90039
  const mapper = content && Object.hasOwn(content, tool.name) ? content[tool.name] : void 0;
88538
90040
  const inputSchema = rawJsonSchema === void 0 ? toolJsonSchema(tool.parametersSchema, strict) : yield* catch_$2(decodeUnknownEffect(ToolJson)(rawJsonSchema), (cause) => die$2(`McpServer cannot register tool '${tool.name}': its raw JSON Schema must have an object root (type: "object").\n\n${cause.message}`));
88539
90041
  const title = getOrUndefined$1(tool.annotations, Title);
88540
- const readOnlyHint = get$12(tool.annotations, Readonly);
90042
+ const readOnlyHint = get$13(tool.annotations, Readonly);
88541
90043
  const fields = {
88542
90044
  name: tool.name,
88543
90045
  title,
@@ -88548,8 +90050,8 @@ const registerToolkit = /*#__PURE__*/ fnUntraced(function* (toolkit, options) {
88548
90050
  ...title !== void 0 ? { title } : void 0,
88549
90051
  readOnlyHint,
88550
90052
  destructiveHint: getOrUndefined$1(tool.annotations, Destructive) ?? !readOnlyHint,
88551
- idempotentHint: get$12(tool.annotations, Idempotent),
88552
- openWorldHint: get$12(tool.annotations, OpenWorld)
90053
+ idempotentHint: get$13(tool.annotations, Idempotent),
90054
+ openWorldHint: get$13(tool.annotations, OpenWorld)
88553
90055
  },
88554
90056
  _meta: isReadonlyObject(toolMeta) ? { ...toolMeta } : toolMeta
88555
90057
  };
@@ -88584,7 +90086,7 @@ const registerToolkit = /*#__PURE__*/ fnUntraced(function* (toolkit, options) {
88584
90086
  content: []
88585
90087
  }) : successResult(result.encodedResult));
88586
90088
  }
88587
- return result.failureOrigin === "handler" ? succeed$5(failureResult(result.encodedResult)) : failCause$3(annotate$2(fail$8(result.result), make$89(FailureOrigin, result.failureOrigin ?? "result")));
90089
+ return result.failureOrigin === "handler" ? succeed$5(failureResult(result.encodedResult)) : failCause$3(annotate$2(fail$8(result.result), make$90(FailureOrigin, result.failureOrigin ?? "result")));
88588
90090
  }), catchCause$2(handleCause));
88589
90091
  },
88590
90092
  services
@@ -89040,9 +90542,11 @@ function upgradeOnlyHeaders(headers) {
89040
90542
  ], toLowerCase(entry[0])));
89041
90543
  }
89042
90544
  const IDENTIFY_PATH = "/api/identify";
90545
+ const IdentifyPurpose = Literals(["use", "verify"]);
89043
90546
  const IdentifyRequest = Struct$2({
89044
90547
  address: OptionFromOptionalKey(NonEmptyString),
89045
90548
  onBehalfOf: OptionFromOptionalKey(UserId),
90549
+ purpose: IdentifyPurpose,
89046
90550
  session: OptionFromOptionalKey(NonEmptyString)
89047
90551
  });
89048
90552
  const DEVELOPER = {
@@ -89143,10 +90647,11 @@ function requireAdmin(user, message) {
89143
90647
  message
89144
90648
  }));
89145
90649
  }
89146
- function identifyRequestOf(headers) {
90650
+ function identifyRequestOf(headers, purpose) {
89147
90651
  return IdentifyRequest.make({
89148
90652
  address: fromNullishOr$1(headers[CLIENT_HEADER]),
89149
90653
  onBehalfOf: flatMap$8(fromNullishOr$1(headers[ON_BEHALF_HEADER]), decodeOption(UserId)),
90654
+ purpose,
89150
90655
  session: fromNullishOr$1(parseHeader(headers["cookie"] ?? "")[SESSION_COOKIE])
89151
90656
  });
89152
90657
  }
@@ -89166,21 +90671,29 @@ function refusalOf(status, message) {
89166
90671
  });
89167
90672
  return AuthError.make({ message });
89168
90673
  }
90674
+ function purposeOf(success) {
90675
+ if (isStreamSchema(success)) return "verify";
90676
+ return "use";
90677
+ }
89169
90678
  var Auth = class Auth extends Service$1()("@deslop/runtime/server/auth") {
89170
- static makeContext = (account, recheck = account) => {
89171
- function user(headers, options) {
89172
- return pipe(suspend$3(() => account(headers)), map$7((found) => ({
90679
+ static makeContext = (identify, refresh = identify) => {
90680
+ function user(headers, purpose, options) {
90681
+ return pipe(suspend$3(() => identify(headers, purpose)), map$7((found) => ({
89173
90682
  admin: found.admin,
89174
90683
  id: found.id,
89175
90684
  name: found.name
89176
90685
  })), withSpan("Auth.user", options));
89177
90686
  }
89178
- return pipe(make$89(Auth, Auth.of({
89179
- account,
89180
- recheck,
89181
- user
89182
- })), add$3(RpcAuth, RpcAuth.of((effect, request) => flatMap$3(user(request.headers), (found) => pipe(effect, provideService$2(CurrentUser, found), raceFirst(recheckUser(user(request.headers, { root: true }), found)))))), add$3(RpcAdmin, RpcAdmin.of((effect, request) => gen(function* () {
89183
- return yield* provideService$2(effect, CurrentAdmin, yield* requireAdmin(yield* user(request.headers), "Only an admin may perform this action"));
90687
+ return pipe(make$90(Auth, Auth.of({
90688
+ account: (headers) => identify(headers, "verify"),
90689
+ recheck: (headers) => refresh(headers, "verify"),
90690
+ user: (headers) => user(headers, "use")
90691
+ })), add$3(RpcAuth, RpcAuth.of((effect, request) => flatMap$3(user(request.headers, purposeOf(request.rpc.successSchema)), (found) => pipe(effect, provideService$2(CurrentUser, found), raceFirst(recheckUser(user(request.headers, "verify", { root: true }), found)))))), add$3(RpcAdmin, RpcAdmin.of((effect, request) => gen(function* () {
90692
+ const caller = yield* match$8(yield* serviceOption(CurrentUser), {
90693
+ onNone: () => user(request.headers, purposeOf(request.rpc.successSchema)),
90694
+ onSome: succeed$5
90695
+ });
90696
+ return yield* provideService$2(effect, CurrentAdmin, yield* requireAdmin(caller, "Only an admin may perform this action"));
89184
90697
  }))));
89185
90698
  };
89186
90699
  static layer = unwrap$7(gen(function* () {
@@ -89191,11 +90704,12 @@ var Auth = class Auth extends Service$1()("@deslop/runtime/server/auth") {
89191
90704
  return effectContext(gen(function* () {
89192
90705
  const issuer = yield* String$5("AUTH_URL");
89193
90706
  const client = yield* HttpClient;
89194
- const answers = yield* makeWith(fnUntraced(function* (body) {
90707
+ const identify = fnUntraced(function* (body) {
89195
90708
  const response = yield* pipe(post(new URL(IDENTIFY_PATH, issuer).href), bodyText(body, "application/json"), client.execute);
89196
90709
  if (response.status === 401 || response.status === 403) return yield* refusalOf(response.status, getOrElse$1(yield* option$1(response.text), constant$1("Sign in first")));
89197
90710
  return yield* schemaBodyJson$1(Account$1)(yield* filterStatusOk$1(response));
89198
- }, outageUnlessRefused("The authorization service is temporarily unavailable")), {
90711
+ }, outageUnlessRefused("The authorization service is temporarily unavailable"));
90712
+ const answers = yield* makeWith(identify, {
89199
90713
  capacity: 1024,
89200
90714
  timeToLive: match$3({
89201
90715
  onFailure: constant$1(0),
@@ -89203,8 +90717,10 @@ var Auth = class Auth extends Service$1()("@deslop/runtime/server/auth") {
89203
90717
  })
89204
90718
  });
89205
90719
  function lookup(refresh) {
89206
- return fn("Auth.account")(function* (headers) {
89207
- const key = yield* encodeEffect(fromJsonString(IdentifyRequest))(identifyRequestOf(headers));
90720
+ return fn("Auth.account")(function* (headers, purpose) {
90721
+ const request = identifyRequestOf(headers, purpose);
90722
+ const key = yield* encodeEffect(fromJsonString(IdentifyRequest))(request);
90723
+ if (purpose === "use" && isSome(request.session)) return yield* identify(key);
89208
90724
  if (refresh) yield* invalidate(answers, key);
89209
90725
  return yield* get(answers, key);
89210
90726
  }, asAuthError("The request could not be read"));
@@ -92576,7 +94092,7 @@ const Formatter = /*#__PURE__*/ Reference("effect/cli/CliOutput", { defaultValue
92576
94092
  */
92577
94093
  const defaultPresenter = { present: /*#__PURE__*/ fnUntraced(function* (event) {
92578
94094
  const context$2 = yield* context();
92579
- const formatter = getOrUndefined$1(context$2, Formatter) ?? defaultFormatter({ colors: get$12(context$2, TerminalCapabilities).canColor });
94095
+ const formatter = getOrUndefined$1(context$2, Formatter) ?? defaultFormatter({ colors: get$13(context$2, TerminalCapabilities).canColor });
92580
94096
  switch (event._tag) {
92581
94097
  case "Help": return yield* log(formatter.formatHelpDoc(event.helpDoc));
92582
94098
  case "InvalidInvocation":
@@ -94995,7 +96511,7 @@ const defaults = { builtIns: BuiltIns };
94995
96511
  *
94996
96512
  * @internal
94997
96513
  */
94998
- const resolveFormatter = /*#__PURE__*/ contextWith((context) => succeed$5(getOrUndefined$1(context, Formatter) ?? defaultFormatter({ colors: get$12(context, TerminalCapabilities).canColor })));
96514
+ const resolveFormatter = /*#__PURE__*/ contextWith((context) => succeed$5(getOrUndefined$1(context, Formatter) ?? defaultFormatter({ colors: get$13(context, TerminalCapabilities).canColor })));
94999
96515
  // ../../node_modules/.pnpm/effect@4.1.7/node_modules/effect/dist/cli/internal/lexer.js
95000
96516
  /**
95001
96517
  * @internal
@@ -96498,7 +98014,7 @@ const runWith = (command, config) => {
96498
98014
  }
96499
98015
  const services = match$8(logLevel, {
96500
98016
  onNone: () => empty$14(),
96501
- onSome: (level) => make$89(MinimumLogLevel, level)
98017
+ onSome: (level) => make$90(MinimumLogLevel, level)
96502
98018
  });
96503
98019
  yield* provideContext$2(program, services);
96504
98020
  }, catchFilter((error) => isCliError(error) && error._tag === "ShowHelp" ? succeed$10(error) : fail$12(error), (error) => andThen(showHelp(command, error, config.renderErrors !== false), fail$7(error))), catchFilter((error) => {
@@ -96802,6 +98318,8 @@ const publicAccess = [
96802
98318
  },
96803
98319
  ...map$10([
96804
98320
  "chapters.events",
98321
+ "chapters.manifest",
98322
+ "chapters.progress",
96805
98323
  "push.register",
96806
98324
  "chapters.write"
96807
98325
  ], (name) => ({
@@ -96836,7 +98354,11 @@ const publicAccess = [
96836
98354
  }),
96837
98355
  surface: "http POST /v1/github"
96838
98356
  },
96839
- ...map$10(["telemetry.watch", "telemetry.trace"], (name) => ({
98357
+ ...map$10([
98358
+ "telemetry.watch",
98359
+ "telemetry.trace",
98360
+ "telemetry.diagnostic"
98361
+ ], (name) => ({
96840
98362
  app: "scope",
96841
98363
  callers: ["member"],
96842
98364
  surface: `rpc ${name}`
@@ -96857,8 +98379,8 @@ const publicAccess = [
96857
98379
  "POST /api/capture",
96858
98380
  "POST /api/capture/:id/activity",
96859
98381
  "POST /api/files/:id",
96860
- "GET /api/images/:id",
96861
- "GET /api/notes/:id/media/:index"
98382
+ "GET /api/images/:id/:revision",
98383
+ "GET /api/notes/:id/media/:revision/:index"
96862
98384
  ], (surface) => ({
96863
98385
  app: "stash",
96864
98386
  callers: ["member"],
@@ -96866,8 +98388,8 @@ const publicAccess = [
96866
98388
  })),
96867
98389
  ...map$10([
96868
98390
  "notes.events",
96869
- "notes.body",
96870
- "notes.media",
98391
+ "notes.detail",
98392
+ "notes.gallery",
96871
98393
  "notes.capture",
96872
98394
  "notes.regenerate"
96873
98395
  ], (name) => ({
@@ -96894,7 +98416,6 @@ const publicAccess = [
96894
98416
  "flights.events",
96895
98417
  "flights.save",
96896
98418
  "flights.remove",
96897
- "travel.list",
96898
98419
  "travel.set",
96899
98420
  "push.register"
96900
98421
  ], (name) => ({
@@ -97011,8 +98532,8 @@ const HTTP_DOMAINS = {
97011
98532
  "POST /mcp": 406,
97012
98533
  "PUT /mcp": 405,
97013
98534
  "gateway * /ai/*": 402,
97014
- "stash GET /api/images/:id": 400,
97015
- "stash GET /api/notes/:id/media/:index": 400,
98535
+ "stash GET /api/images/:id/:revision": 400,
98536
+ "stash GET /api/notes/:id/media/:revision/:index": 400,
97016
98537
  "stash POST /api/capture": 422,
97017
98538
  "stash POST /api/capture/:id/activity": 422,
97018
98539
  "stash POST /api/files/:id": 422,
@@ -97031,7 +98552,7 @@ function okJson(body) {
97031
98552
  }
97032
98553
  const Icon = replyWith(200, String$6.check(isPattern(/^<svg\b[^>]*>.+<\/svg>\s*$/su)));
97033
98554
  const Manifest = okJson(Struct$2({
97034
- background_color: NonEmptyString,
98555
+ background_color: optionalKey(NonEmptyString),
97035
98556
  display: Literal("standalone"),
97036
98557
  icons: NonEmptyArray(Struct$2({
97037
98558
  purpose: NonEmptyString,
@@ -97043,7 +98564,7 @@ const Manifest = okJson(Struct$2({
97043
98564
  scope: NonEmptyString,
97044
98565
  short_name: NonEmptyString,
97045
98566
  start_url: NonEmptyString,
97046
- theme_color: NonEmptyString
98567
+ theme_color: optionalKey(NonEmptyString)
97047
98568
  }));
97048
98569
  const ClientMetadata = okJson(Struct$2({
97049
98570
  client_id: HttpUrl,
@@ -97244,7 +98765,7 @@ function recordToolContracts(contracts) {
97244
98765
  }
97245
98766
  function sample(schema$4, name) {
97246
98767
  return mapError$2(gen(function* () {
97247
- const input = yield* pipe(FIXED_INPUTS, get$11(name), match$8({
98768
+ const input = yield* pipe(FIXED_INPUTS, get$12(name), match$8({
97248
98769
  onNone: () => flatMap$3(sampleEffect(schema(toEncoded(schema$4)), {
97249
98770
  count: 1,
97250
98771
  seed: 1,
@@ -97328,7 +98849,7 @@ function probeServer(start) {
97328
98849
  HOME: probe.directory,
97329
98850
  HOST: "127.0.0.1"
97330
98851
  }))), build);
97331
- const origin = formatAddress(get$12(context, HttpServer).address);
98852
+ const origin = formatAddress(get$13(context, HttpServer).address);
97332
98853
  for (const identity of ["member", "admin"]) {
97333
98854
  const response = yield* pipe(get$2(`${origin}/api/account`), setHeader$1("x-probe-caller", identity), execute);
97334
98855
  const account = yield* schemaBodyJson$1(Account$1)(response);
@@ -97441,11 +98962,13 @@ function probeServer(start) {
97441
98962
  }
97442
98963
  // ../../packages/runtime/src/shared/rpc.ts
97443
98964
  var RpcStream = class extends Service()("@deslop/runtime/shared/rpc/RpcStream") {};
98965
+ const ReadMethod = Reference("@deslop/runtime/shared/rpc/ReadMethod", { defaultValue: none });
97444
98966
  const layerRpcStream = succeed$6(RpcStream, RpcStream.of((effect, options) => {
97445
98967
  if (!isStreamSchema(options.rpc.successSchema)) return effect;
97446
98968
  return andThen(annotateCurrentSpan("rpc.stream", true), effect);
97447
98969
  }));
97448
98970
  layerClient(RpcStream, (options) => gen(function* () {
98971
+ map$13(yield* ReadMethod, (note) => note(options.rpc._tag));
97449
98972
  if (isStreamSchema(options.rpc.successSchema)) yield* annotateCurrentSpan("rpc.stream", true);
97450
98973
  return yield* options.next(options.request);
97451
98974
  }));
@@ -97559,13 +99082,13 @@ const layerFlusher = /*#__PURE__*/ sync$1(Flusher, () => {
97559
99082
  */
97560
99083
  const make$5 = /*#__PURE__*/ fnUntraced(function* (options) {
97561
99084
  const services = yield* context();
97562
- const clock = get$12(services, Clock);
97563
- const scope = get$12(services, Scope);
97564
- const exportInterval = max(fromInputUnsafe$1(options.exportInterval), zero$2);
99085
+ const clock = get$13(services, Clock);
99086
+ const scope = get$13(services, Scope);
99087
+ const exportInterval = max$1(fromInputUnsafe$1(options.exportInterval), zero$2);
97565
99088
  const batchLimit = options.maxBatchSize === "disabled" ? Infinity : normalizeNonEmpty(options.maxBatchSize);
97566
99089
  const maxQueueSize = options.maxQueueSize === void 0 || Number.isNaN(options.maxQueueSize) ? Number.isFinite(batchLimit) ? Math.max(2048, batchLimit) : 2048 : normalize$2(options.maxQueueSize);
97567
99090
  const concurrency = options.concurrency === "unbounded" ? Infinity : options.concurrency === void 0 || Number.isNaN(options.concurrency) ? 4 : normalizeNonEmpty(options.concurrency);
97568
- const client = get$12(services, HttpClient).pipe(tap((response) => ignore$1(response.arrayBuffer)), tapError((error) => error.response ? ignore$1(error.response.arrayBuffer) : void_$2), filterStatusOk, transformResponse(provideService$2(TracerPropagationEnabled, false)), retryTransient({
99091
+ const client = get$13(services, HttpClient).pipe(tap((response) => ignore$1(response.arrayBuffer)), tapError((error) => error.response ? ignore$1(error.response.arrayBuffer) : void_$2), filterStatusOk, transformResponse(provideService$2(TracerPropagationEnabled, false)), retryTransient({
97569
99092
  schedule: policy,
97570
99093
  times: 3
97571
99094
  }));
@@ -98200,10 +99723,40 @@ Literals([
98200
99723
  "mobile",
98201
99724
  "server"
98202
99725
  ]);
98203
- function layerOtlp(serviceName, url, runtime, version) {
98204
- return catchCause$3(unwrap$7(gen(function* () {
98205
- const start = `${yield* currentTimeNanos}`;
98206
- const redacted = yield* CurrentRedactedNames;
99726
+ function emitFirstValue(tracer, value) {
99727
+ const span = tracer.span({
99728
+ annotations: empty$14(),
99729
+ kind: "client",
99730
+ links: [],
99731
+ name: "Read.firstValue",
99732
+ parent: none(),
99733
+ root: true,
99734
+ sampled: true,
99735
+ startTime: value.start
99736
+ });
99737
+ map$13(value.method, (method) => span.attribute("rpc.method", method));
99738
+ span.end(value.end, void_$3);
99739
+ }
99740
+ Reference("@deslop/runtime/shared/telemetry/FirstValueSink", { defaultValue: () => (value) => map$7(tracer$1, (tracer) => emitFirstValue(tracer, value)) });
99741
+ const layerTelemetryRedaction = effect(CurrentRedactedNames, map$7(CurrentRedactedNames, (redacted) => dedupe([
99742
+ ...redacted,
99743
+ "code",
99744
+ "state",
99745
+ "request",
99746
+ "access_token",
99747
+ "refresh_token",
99748
+ "id_token",
99749
+ "client_secret",
99750
+ "client_assertion",
99751
+ "code_verifier",
99752
+ "session",
99753
+ "token",
99754
+ "api_key",
99755
+ "key"
99756
+ ])));
99757
+ function layerOtlp(serviceName, url, runtime, version, started) {
99758
+ return pipe(unwrap$7(gen(function* () {
99759
+ const start = `${started ?? (yield* currentTimeNanos)}`;
98207
99760
  const resource = {
98208
99761
  attributes: {
98209
99762
  "scope.run.started_unix_nano": start,
@@ -98219,26 +99772,11 @@ function layerOtlp(serviceName, url, runtime, version) {
98219
99772
  }), layer$2({
98220
99773
  resource,
98221
99774
  url: new URL("/v1/logs", url).href
98222
- }), succeed$6(CurrentRedactedNames, [
98223
- ...redacted,
98224
- "code",
98225
- "state",
98226
- "request",
98227
- "access_token",
98228
- "refresh_token",
98229
- "id_token",
98230
- "client_secret",
98231
- "client_assertion",
98232
- "code_verifier",
98233
- "session",
98234
- "token",
98235
- "api_key",
98236
- "key"
98237
- ])), [layerJson, layer$15]);
98238
- })), (cause) => {
99775
+ })), [layerJson, layer$15]);
99776
+ })), catchCause$3((cause) => {
98239
99777
  if (hasInterrupts(cause)) return effectDiscard(interrupt$1);
98240
99778
  return effectDiscard(logWarning("Telemetry is unavailable"));
98241
- });
99779
+ }), provideMerge(layerTelemetryRedaction));
98242
99780
  }
98243
99781
  // ../../packages/runtime/src/server/http.ts
98244
99782
  const LOOPBACK = /^(?:localhost|\d{1,3}(?:\.\d{1,3}){3}|\[[\da-f:.]+\])$/iu;
@@ -98325,7 +99863,10 @@ const layerWeb = unwrap$7(gen(function* () {
98325
99863
  if (!(yield* (yield* FileSystem).exists((yield* Path$1).join(client, "index.html")))) return empty$11;
98326
99864
  const name = capitalize(yield* appName);
98327
99865
  return mergeAll$1(add("GET", MANIFEST_PATH, succeed$5(jsonUnsafe({
98328
- background_color: "#0d0c0c",
99866
+ ...name === "Portfolio" && {
99867
+ background_color: "#0d0c0c",
99868
+ theme_color: "#0d0c0c"
99869
+ },
98329
99870
  display: "standalone",
98330
99871
  icons: [{
98331
99872
  purpose: "any",
@@ -98336,8 +99877,7 @@ const layerWeb = unwrap$7(gen(function* () {
98336
99877
  name,
98337
99878
  scope: "/",
98338
99879
  short_name: name,
98339
- start_url: "/",
98340
- theme_color: "#0d0c0c"
99880
+ start_url: "/"
98341
99881
  }, {
98342
99882
  contentType: "application/manifest+json",
98343
99883
  headers: { "cache-control": "no-cache" }
@@ -98489,7 +100029,7 @@ const make$1 = (options) => gen(function* () {
98489
100029
  timeToLive: (exit) => isSuccess$1(exit) ? prepareCacheTTL : zero$2
98490
100030
  });
98491
100031
  const runStatement = (statement, params, raw) => withFiber((fiber) => {
98492
- const useSafeIntegers = get$12(fiber.context, SafeIntegers);
100032
+ const useSafeIntegers = get$13(fiber.context, SafeIntegers);
98493
100033
  return try_({
98494
100034
  try: () => {
98495
100035
  statement.setReadBigInts(useSafeIntegers);
@@ -98504,7 +100044,7 @@ const make$1 = (options) => gen(function* () {
98504
100044
  });
98505
100045
  });
98506
100046
  const runStatementValues = (statement, params) => withFiber((fiber) => {
98507
- const useSafeIntegers = get$12(fiber.context, SafeIntegers);
100047
+ const useSafeIntegers = get$13(fiber.context, SafeIntegers);
98508
100048
  return try_({
98509
100049
  try: () => {
98510
100050
  statement.setReadBigInts(useSafeIntegers);
@@ -98514,7 +100054,7 @@ const make$1 = (options) => gen(function* () {
98514
100054
  });
98515
100055
  });
98516
100056
  const runStatementValuesUnprepared = (statement, params) => withFiber((fiber) => {
98517
- const useSafeIntegers = get$12(fiber.context, SafeIntegers);
100057
+ const useSafeIntegers = get$13(fiber.context, SafeIntegers);
98518
100058
  return try_({
98519
100059
  try: () => {
98520
100060
  statement.setReadBigInts(useSafeIntegers);
@@ -98604,7 +100144,7 @@ const make$1 = (options) => gen(function* () {
98604
100144
  * @category layers
98605
100145
  * @since 4.0.0
98606
100146
  */
98607
- const layer = (config) => effectContext(map$7(make$1(config), (client) => make$89(SqliteClient, client).pipe(add$3(SqlClient, client)))).pipe(provide$2(layer$19));
100147
+ const layer = (config) => effectContext(map$7(make$1(config), (client) => make$90(SqliteClient, client).pipe(add$3(SqlClient, client)))).pipe(provide$2(layer$19));
98608
100148
  const classifyError = (cause, message, operation) => classifySqliteError(sqliteCauseWithErrno(cause), {
98609
100149
  message,
98610
100150
  operation
@@ -99475,7 +101015,7 @@ const StatusJson = fromJsonString(Struct$2({
99475
101015
  User: Record$1(TailnetUserId, Profile)
99476
101016
  }), { reviver: exactNumbers });
99477
101017
  // src/people/contract.ts
99478
- const Role = Literals([
101018
+ const Role$1 = Literals([
99479
101019
  "Admin",
99480
101020
  "Member",
99481
101021
  "Waiting"
@@ -99483,7 +101023,7 @@ const Role = Literals([
99483
101023
  const Account = Struct$2({
99484
101024
  ...User.fields,
99485
101025
  fullName: OptionFromOptionalKey(String$6),
99486
- role: Role
101026
+ role: Role$1
99487
101027
  });
99488
101028
  const Person = Struct$2({
99489
101029
  ...Account.fields,
@@ -99494,8 +101034,12 @@ const AdmitParams = Struct$2({
99494
101034
  allow: Boolean$5,
99495
101035
  id: UserId
99496
101036
  });
101037
+ var PeopleReadError = class extends TaggedError()("PeopleReadError", {
101038
+ cause: optional$8(Defect()),
101039
+ message: String$6
101040
+ }) {};
99497
101041
  const PeopleRpcs = make$32(make$36("people.watch", {
99498
- error: AuthError,
101042
+ error: PeopleReadError,
99499
101043
  stream: true,
99500
101044
  success: ArraySchema(Person)
99501
101045
  }).middleware(RpcAdmin), make$36("people.admit", {
@@ -99533,8 +101077,9 @@ const IdentityRpcs = make$32(make$36("people.account", {
99533
101077
  var ListedSession = class extends Class("ListedSession")({
99534
101078
  address: FieldOption(String$6),
99535
101079
  browser: String$6,
101080
+ expiresAt: DateTimeUtcFromMillis,
99536
101081
  id: String$6,
99537
- lastSeenAt: DateTimeUtcFromMillis,
101082
+ lastActivityAt: FieldOption(DateTimeUtcFromMillis),
99538
101083
  current: Boolean$5
99539
101084
  }) {};
99540
101085
  const SessionsRpcs = make$32(make$36("sessions.watch", {
@@ -99547,6 +101092,7 @@ var CookieSession = class extends Class("CookieSession")({
99547
101092
  browser: String$6,
99548
101093
  createdAt: DateTimeUtcFromMillis,
99549
101094
  id: String$6,
101095
+ lastActivityAt: FieldOption(DateTimeUtcFromMillis),
99550
101096
  lastSeenAt: DateTimeUtcFromMillis,
99551
101097
  userId: UserId
99552
101098
  }) {
@@ -99803,11 +101349,22 @@ const peopleMigrations = effectDiscard(make$26({})({
99803
101349
  const sessionsMigrations = effectDiscard(make$26({})({
99804
101350
  loader: fromRecord({
99805
101351
  "0001_cookie_sessions": flatMap$3(SqlClient, (sql) => sql`CREATE TABLE cookie_sessions (id TEXT PRIMARY KEY, userId TEXT NOT NULL, address TEXT, browser TEXT NOT NULL, createdAt INTEGER NOT NULL, lastSeenAt INTEGER NOT NULL) STRICT`),
99806
- "0002_user_sessions": flatMap$3(SqlClient, (sql) => sql`CREATE INDEX cookie_sessions_user ON cookie_sessions (userId, lastSeenAt)`)
101352
+ "0002_user_sessions": flatMap$3(SqlClient, (sql) => sql`CREATE INDEX cookie_sessions_user ON cookie_sessions (userId, lastSeenAt)`),
101353
+ "0003_meaningful_session_activity": flatMap$3(SqlClient, (sql) => sql`ALTER TABLE cookie_sessions ADD COLUMN lastActivityAt INTEGER`)
99807
101354
  }),
99808
101355
  table: "cookie_sessions_migrations"
99809
101356
  }));
99810
101357
  // src/sessions/server.ts
101358
+ const IDLE_DAYS = 30;
101359
+ function cutoff(now) {
101360
+ return toEpochMillis(subtract(now, { days: IDLE_DAYS }));
101361
+ }
101362
+ function expiresAt(row) {
101363
+ return add$1(row.lastSeenAt, { days: IDLE_DAYS });
101364
+ }
101365
+ function sessionRows(user) {
101366
+ return `sessionRows:${user}`;
101367
+ }
99811
101368
  var Sessions = class Sessions extends Service$1()("@deslop/auth/sessions/server/Sessions") {
99812
101369
  static migrations = sessionsMigrations;
99813
101370
  static layer = provide$2(effect(Sessions, gen(function* () {
@@ -99819,37 +101376,75 @@ var Sessions = class Sessions extends Service$1()("@deslop/auth/sessions/server/
99819
101376
  return map$7(digest.digest(sha256, new TextEncoder().encode(secret)), encode$1);
99820
101377
  }
99821
101378
  const table = sql(CookieSession.table);
99822
- function mutate(effect) {
99823
- return pipe(effect, mutation(["sessions"]), provideService$2(Reactivity, reactivity));
101379
+ function changed(user, identity) {
101380
+ const keys = match(identity, {
101381
+ onFalse: () => [sessionRows(user)],
101382
+ onTrue: () => ["sessions", sessionRows(user)]
101383
+ });
101384
+ return sql.afterCommit(sync(() => reactivity.invalidateUnsafe(keys)));
99824
101385
  }
99825
- const cutoff = map$7(now, (now) => subtract(now, { days: 30 }));
99826
101386
  const insert = void_({
99827
101387
  Request: CookieSession.insert,
99828
101388
  execute: (row) => sql`INSERT INTO ${table} ${sql.insert(row)}`
99829
101389
  });
99830
- yield* pipe(cutoff, flatMap$3((since) => sql`DELETE FROM ${table} WHERE lastSeenAt <= ${toEpochMillis(since)}`), withSpan("Sessions.sweep"), ignore$1({
101390
+ yield* pipe(now, flatMap$3((now) => sql`DELETE FROM ${table} WHERE lastSeenAt <= ${cutoff(now)}`), withSpan("Sessions.sweep"), ignore$1({
99831
101391
  log: "Warn",
99832
101392
  message: "Expired sessions could not be deleted"
99833
101393
  }), repeat(spaced(hours(1))), forkScoped);
99834
- const current = fn("Sessions.current")(function* (secret) {
101394
+ const current = fn("Sessions.current")(function* (secret, purpose) {
99835
101395
  const id = yield* hash(secret);
99836
- const now$3 = toEpochMillis(yield* now);
99837
- const since = toEpochMillis(yield* cutoff);
99838
- return yield* findOneOption({
101396
+ const at = yield* now;
101397
+ const now$3 = toEpochMillis(at);
101398
+ const since = cutoff(at);
101399
+ const use = purpose === "use";
101400
+ const touched = yield* findOneOption({
99839
101401
  Request: Void,
99840
101402
  Result: CookieSession,
99841
- execute: () => sql`UPDATE ${table} SET lastSeenAt = ${now$3} WHERE id = ${id} AND lastSeenAt > ${since} RETURNING *`
101403
+ execute: () => sql`UPDATE ${table}
101404
+ SET lastSeenAt = ${now$3},
101405
+ lastActivityAt = CASE WHEN ${use} THEN max(coalesce(lastActivityAt, ${now$3}), ${now$3}) ELSE lastActivityAt END
101406
+ WHERE id = ${id} AND lastSeenAt > ${since}
101407
+ AND (lastSeenAt <> ${now$3} OR (${use} AND (lastActivityAt IS NULL OR lastActivityAt < ${now$3})))
101408
+ RETURNING *`
99842
101409
  })();
99843
- }, asAuthError("Cannot read the session"));
101410
+ return yield* match$8(touched, {
101411
+ onNone: () => findOneOption({
101412
+ Request: Void,
101413
+ Result: CookieSession,
101414
+ execute: () => sql`SELECT * FROM ${table} WHERE id = ${id} AND lastSeenAt > ${since}`
101415
+ })(),
101416
+ onSome: (row) => as(changed(row.userId, false), touched)
101417
+ });
101418
+ }, sql.withTransaction, asAuthError("Cannot read the session"));
99844
101419
  const list = fn("Sessions.list")(function* (user) {
99845
- const since = toEpochMillis(yield* cutoff);
101420
+ const since = cutoff(yield* now);
99846
101421
  return yield* findAll({
99847
101422
  Request: Void,
99848
101423
  Result: CookieSession,
99849
- execute: () => sql`SELECT * FROM ${table} WHERE userId = ${user} AND lastSeenAt > ${since} ORDER BY lastSeenAt DESC`
101424
+ execute: () => sql`SELECT * FROM ${table} WHERE userId = ${user} AND lastSeenAt > ${since}
101425
+ ORDER BY lastActivityAt DESC, createdAt DESC`
99850
101426
  })();
99851
101427
  }, asAuthError("Cannot list sessions"));
101428
+ const liveRows = yield* make$74({ lookup: (user) => pipe(sql.reactive([sessionRows(user)], list(user)), switchMap((rows) => concat$2(succeed$3(rows), unfold(rows, fnUntraced(function* (live) {
101429
+ if (!isReadonlyArrayNonEmpty(live)) return void 0;
101430
+ const due = pipe(live, map$10((row) => toEpochMillis(expiresAt(row))), min$1(Order$4));
101431
+ yield* sleep(max(0, due - toEpochMillis(yield* now)));
101432
+ return yield* map$7(list(user), (next) => make$88(next, next));
101433
+ })))), share({
101434
+ capacity: 1,
101435
+ replay: 1,
101436
+ strategy: "sliding"
101437
+ })) });
99852
101438
  return Sessions.of({
101439
+ active: fn("Sessions.active")(function* (ids) {
101440
+ const since = cutoff(yield* now);
101441
+ const rows = yield* findAll({
101442
+ Request: Void,
101443
+ Result: Struct$2({ id: String$6 }),
101444
+ execute: () => sql`SELECT id FROM ${table} WHERE id IN ${sql.in(ids)} AND lastSeenAt > ${since}`
101445
+ })();
101446
+ return map$10(rows, (row) => row.id);
101447
+ }, asAuthError("Cannot read active sessions")),
99853
101448
  create: fn("Sessions.create")(function* (user, address, browser) {
99854
101449
  const secret = encode$1(yield* random.randomBytes(32));
99855
101450
  const now$4 = yield* now;
@@ -99858,35 +101453,48 @@ var Sessions = class Sessions extends Service$1()("@deslop/auth/sessions/server/
99858
101453
  browser,
99859
101454
  createdAt: now$4,
99860
101455
  id: yield* hash(secret),
101456
+ lastActivityAt: some$1(now$4),
99861
101457
  lastSeenAt: now$4,
99862
101458
  userId: user
99863
101459
  });
101460
+ yield* changed(user, true);
99864
101461
  return secret;
99865
- }, mutate, asAuthError("Cannot create the session")),
101462
+ }, asAuthError("Cannot create the session")),
99866
101463
  current,
99867
101464
  forget: fn("Sessions.forget")(function* (secret) {
99868
- yield* sql`DELETE FROM ${table} WHERE id = ${yield* hash(secret)}`;
99869
- }, mutate, asAuthError("Cannot sign out; no changes committed")),
101465
+ const id = yield* hash(secret);
101466
+ const deleted = yield* findOneOption({
101467
+ Request: Void,
101468
+ Result: Struct$2({ userId: UserId }),
101469
+ execute: () => sql`DELETE FROM ${table} WHERE id = ${id} RETURNING userId`
101470
+ })();
101471
+ yield* match$8(deleted, {
101472
+ onNone: () => void_$2,
101473
+ onSome: (row) => changed(row.userId, true)
101474
+ });
101475
+ }, asAuthError("Cannot sign out; no changes committed")),
99870
101476
  forgetPerson: fn("Sessions.forgetPerson")(function* (user) {
99871
101477
  yield* sql`DELETE FROM ${table} WHERE userId = ${user}`;
99872
- }, mutate, asAuthError("Cannot sign out the person; no changes committed")),
101478
+ yield* changed(user, true);
101479
+ }, asAuthError("Cannot sign out the person; no changes committed")),
99873
101480
  list,
99874
101481
  remove: fn("Sessions.remove")(function* (id, user) {
99875
101482
  yield* sql`DELETE FROM ${table} WHERE id = ${id} AND userId = ${user}`;
99876
- }, mutate, asAuthError("Cannot sign out the session; no changes committed")),
101483
+ yield* changed(user, true);
101484
+ }, asAuthError("Cannot sign out the session; no changes committed")),
99877
101485
  watch: (user, secret) => unwrap$4(gen(function* () {
99878
101486
  const own = yield* match$8(secret, {
99879
101487
  onNone: () => succeedNone,
99880
- onSome: current
101488
+ onSome: (value) => asSome(hash(value))
99881
101489
  });
99882
- const listed = map$7(list(user), map$10((row) => ListedSession.make({
101490
+ return pipe(yield* get$8(liveRows, user), map$5(map$10((row) => ListedSession.make({
99883
101491
  address: row.address,
99884
101492
  browser: row.browser,
99885
- current: exists(own, (found) => found.id === row.id),
101493
+ current: contains$2(own, row.id),
101494
+ expiresAt: expiresAt(row),
99886
101495
  id: row.id,
99887
- lastSeenAt: row.lastSeenAt
99888
- })));
99889
- return pipe(tick("1 minute"), switchMap(() => sql.reactive(["sessions"], listed)), changesWith(toEquivalence(ArraySchema(ListedSession))), buffer$1({
101496
+ lastActivityAt: row.lastActivityAt
101497
+ }))), changesWith(toEquivalence(ArraySchema(ListedSession))), buffer$1({
99890
101498
  capacity: 1,
99891
101499
  strategy: "sliding"
99892
101500
  }));
@@ -99952,6 +101560,8 @@ function personOf(admins, row) {
99952
101560
  since: row.since
99953
101561
  });
99954
101562
  }
101563
+ const roleOrder = mapInput(Order$4, (person) => ROLE_ORDER[person.role]);
101564
+ const newestRequest = mapInput(flip$1(Order$4), (person) => pipe(person.requestedAt, orElse$3(() => person.since), map$13(toEpochMillis), getOrElse$1(() => -Infinity)));
99955
101565
  function listPeople(rows, admins) {
99956
101566
  const known = map$10(rows, (row) => personOf(admins, row));
99957
101567
  const knownIds = fromIterable(map$10(known, (person) => person.id));
@@ -99963,7 +101573,10 @@ function listPeople(rows, admins) {
99963
101573
  requestedAt: none(),
99964
101574
  role: "Admin",
99965
101575
  since: none()
99966
- }))), ...known], mapInput(Order$4, (person) => ROLE_ORDER[person.role]));
101576
+ }))), ...known], combine$3(roleOrder, (a, b) => {
101577
+ if (a.role !== "Waiting") return 0;
101578
+ return newestRequest(a, b);
101579
+ }));
99967
101580
  }
99968
101581
  var People = class People extends Service$1()("@deslop/auth/people/server/People") {
99969
101582
  static migrations = peopleMigrations;
@@ -100007,7 +101620,10 @@ var People = class People extends Service$1()("@deslop/auth/people/server/People
100007
101620
  });
100008
101621
  const list = fn("People.list")(function* (_admin) {
100009
101622
  return listPeople(yield* all(), admins);
100010
- }, asAuthError("Cannot read people"));
101623
+ }, mapError$2((cause) => PeopleReadError.make({
101624
+ cause,
101625
+ message: "Cannot read people"
101626
+ })));
100011
101627
  return People.of({
100012
101628
  admit: fn("People.admit")(function* (params) {
100013
101629
  const row = yield* existing(params.id);
@@ -100094,8 +101710,7 @@ function unavailable(message) {
100094
101710
  }
100095
101711
  var Tailnet = class Tailnet extends Service$1()("@deslop/auth/tailnet/server/Tailnet") {
100096
101712
  static layer = effect(Tailnet, gen(function* () {
100097
- const spawner = yield* ChildProcessSpawner;
100098
- const status = yield* makeWith(() => pipe(executeProcess("tailscale", ["status", "--json"], { timeout: "10 seconds" }), flatMap$3(decodeUnknownEffect(StatusJson)), provideService$2(ChildProcessSpawner, spawner), unavailable("Cannot read the tailnet owner")), {
101713
+ const status = yield* makeWith(() => pipe(executeProcess("tailscale", ["status", "--json"], { timeout: "10 seconds" }), flatMap$3((text) => withSpan(decodeEffect(StatusJson)(text), "Tailnet.decodeStatus")), unavailable("Cannot read the tailnet owner"), withSpan("Tailnet.status")), {
100099
101714
  capacity: 1,
100100
101715
  timeToLive: match$3({
100101
101716
  onFailure: constant$1(0),
@@ -100106,7 +101721,7 @@ var Tailnet = class Tailnet extends Service$1()("@deslop/auth/tailnet/server/Tai
100106
101721
  "whois",
100107
101722
  "--json",
100108
101723
  address
100109
- ], { timeout: "10 seconds" }), flatMap$3(decodeUnknownEffect(WhoisJson)), provideService$2(ChildProcessSpawner, spawner), unavailable("Cannot identify the tailnet caller")), {
101724
+ ], { timeout: "10 seconds" }), flatMap$3((text) => withSpan(decodeEffect(WhoisJson)(text), "Tailnet.decodeWhois")), unavailable("Cannot identify the tailnet caller"), withSpan("Tailnet.whois")), {
100110
101725
  capacity: 1024,
100111
101726
  timeToLive: match$3({
100112
101727
  onFailure: constant$1(0),
@@ -100167,7 +101782,7 @@ var Identity = class Identity extends Service$1()("@deslop/auth/identity/server/
100167
101782
  };
100168
101783
  const identified = yield* match$8(yield* match$8(request.session, {
100169
101784
  onNone: () => succeedNone,
100170
- onSome: sessions.current
101785
+ onSome: (secret) => sessions.current(secret, request.purpose)
100171
101786
  }), {
100172
101787
  onNone: () => pipe(request.address, match$8({
100173
101788
  onNone: () => fail$7(AuthError.make({ message: "Sign in first" })),
@@ -100176,7 +101791,7 @@ var Identity = class Identity extends Service$1()("@deslop/auth/identity/server/
100176
101791
  onNone: () => gen(function* () {
100177
101792
  const found = yield* owners.status;
100178
101793
  if ((found.Self.Tags?.length ?? 0) > 0) return yield* AuthError.make({ message: "Sign in first" });
100179
- return yield* pipe(found.User, get$11(found.Self.UserID), match$8({
101794
+ return yield* pipe(found.User, get$12(found.Self.UserID), match$8({
100180
101795
  onNone: () => fail$7(AuthError.make({ message: "Sign in first" })),
100181
101796
  onSome: tailnet
100182
101797
  }));
@@ -100231,7 +101846,7 @@ const watchIdentity = gen(function* () {
100231
101846
  function authResponse(effect) {
100232
101847
  return pipe(effect, catchIf(is$2(AuthError), (error) => succeed$5(text(error.message, failureOptions(error, 401)))), map$7(setHeader("cache-control", "no-store")));
100233
101848
  }
100234
- const identityHandlers = IdentityRpcs.toLayer(map$7(watchIdentity, (watch) => ({ "people.account": (_, options) => watch(identifyRequestOf(options.headers)) })));
101849
+ const identityHandlers = IdentityRpcs.toLayer(map$7(watchIdentity, (watch) => ({ "people.account": (_, options) => watch(identifyRequestOf(options.headers, "verify")) })));
100235
101850
  const identityHttp = use((router) => gen(function* () {
100236
101851
  const identity = yield* Identity;
100237
101852
  yield* router.add("POST", IDENTIFY_PATH, authResponse(gen(function* () {
@@ -100247,7 +101862,7 @@ const identityHttp = use((router) => gen(function* () {
100247
101862
  const peopleTools = make$13(make$14("list_people", {
100248
101863
  dependencies: [CurrentUser],
100249
101864
  description: "List people and access requests. Only admins may list people.",
100250
- failure: AuthError,
101865
+ failure: Union$2([AuthError, PeopleReadError]),
100251
101866
  parameters: EmptyParams,
100252
101867
  success: Struct$2({ people: ArraySchema(Person) })
100253
101868
  }).annotate(Readonly, true).annotate(Destructive, false).annotate(Strict, true), make$14("remove_person", {
@@ -100275,6 +101890,15 @@ const peopleHandlers = PeopleRpcs.toLayer(gen(function* () {
100275
101890
  };
100276
101891
  }));
100277
101892
  // src/sessions/handlers.ts
101893
+ const SessionIds = ArraySchema(String$6);
101894
+ const sessionsHttp = use((router) => gen(function* () {
101895
+ const sessions = yield* Sessions;
101896
+ yield* router.add("POST", "/api/sessions/active", authResponse(gen(function* () {
101897
+ if (!isMachine((yield* HttpServerRequest).headers["x-deslop-client"] ?? "")) return text("Only this machine may verify sessions", { status: 403 });
101898
+ const requested = yield* schemaBodyJson(SessionIds);
101899
+ return yield* schemaJson(SessionIds)(yield* sessions.active(requested));
101900
+ })));
101901
+ }));
100278
101902
  const sessionsTools = make$13(make$14("list_sessions", {
100279
101903
  dependencies: [CurrentUser],
100280
101904
  description: "List your browser sessions, newest activity first.",
@@ -100297,31 +101921,120 @@ const sessionsToolHandlers = sessionsTools.toLayer(map$7(Sessions, (sessions) =>
100297
101921
  return { id: input.id };
100298
101922
  })
100299
101923
  })));
100300
- const sessionsHandlers = SessionsRpcs.toLayer(map$7(Sessions, (sessions) => ({ "sessions.watch": (_, options) => unwrap$4(map$7(CurrentUser, (user) => sessions.watch(user.id, identifyRequestOf(options.headers).session))) })));
100301
- // ../../packages/components/src/shared/styles.ts
100302
- const black = "#000";
100303
- const ink = "#f4f4f4";
100304
- const muted = "#a1a1a1";
100305
- const card = "#1c1c1e";
100306
- const chipFill = "#2c2c2e";
101924
+ const sessionsHandlers = SessionsRpcs.toLayer(map$7(Sessions, (sessions) => ({ "sessions.watch": (_, options) => unwrap$4(map$7(CurrentUser, (user) => sessions.watch(user.id, identifyRequestOf(options.headers, "verify").session))) })));
101925
+ Literals(["light", "dark"]);
101926
+ const hues = {
101927
+ auth: "auth",
101928
+ deploy: "deploy",
101929
+ gateway: "gateway",
101930
+ opm: "opm",
101931
+ scope: "scope",
101932
+ stash: "stash",
101933
+ trips: "trips"
101934
+ };
101935
+ Literals(keys$1(hues));
101936
+ Literals([
101937
+ "success",
101938
+ "warning",
101939
+ "error",
101940
+ "info"
101941
+ ]);
101942
+ Literals([
101943
+ "canvas",
101944
+ "surface",
101945
+ "raised",
101946
+ "control",
101947
+ "ink",
101948
+ "secondary",
101949
+ "quiet",
101950
+ "rule",
101951
+ "outline",
101952
+ "glass",
101953
+ "glassEdge",
101954
+ "glassHighlight"
101955
+ ]);
101956
+ const palettes = {
101957
+ dark: {
101958
+ accent: {
101959
+ auth: "#93a6cc",
101960
+ deploy: "#86a6ef",
101961
+ gateway: "#ec87ae",
101962
+ opm: "#e6c4a0",
101963
+ scope: "#5cc9c0",
101964
+ stash: "#f2c46b",
101965
+ trips: "#f39a4b"
101966
+ },
101967
+ canvas: "#000000",
101968
+ control: "#303035",
101969
+ error: "#ff817a",
101970
+ glass: "rgba(44,44,47,.90)",
101971
+ glassEdge: "rgba(255,255,255,.20)",
101972
+ glassHighlight: "rgba(255,255,255,.07)",
101973
+ info: "#9cbaff",
101974
+ ink: "#f4f4f4",
101975
+ outline: "#72727d",
101976
+ quiet: "#a6a6af",
101977
+ raised: "#252527",
101978
+ rule: "#3c3c41",
101979
+ secondary: "#aaaab1",
101980
+ success: "#5bd879",
101981
+ surface: "#1c1c1e",
101982
+ warning: "#ffd20a"
101983
+ },
101984
+ light: {
101985
+ accent: {
101986
+ auth: "#415a89",
101987
+ deploy: "#2c55a0",
101988
+ gateway: "#8c315a",
101989
+ opm: "#725333",
101990
+ scope: "#126962",
101991
+ stash: "#75520e",
101992
+ trips: "#8b4617"
101993
+ },
101994
+ canvas: "#f2f2f7",
101995
+ control: "#e7e7ed",
101996
+ error: "#a62132",
101997
+ glass: "rgba(255,255,255,.92)",
101998
+ glassEdge: "rgba(0,0,0,.13)",
101999
+ glassHighlight: "#ffffff",
102000
+ info: "#365e9f",
102001
+ ink: "#17171b",
102002
+ outline: "#85858f",
102003
+ quiet: "#5e5e6a",
102004
+ raised: "#f7f7fa",
102005
+ rule: "#d8d8df",
102006
+ secondary: "#575761",
102007
+ success: "#1d6b3b",
102008
+ surface: "#ffffff",
102009
+ warning: "#7f5200"
102010
+ }
102011
+ };
102012
+ function variable(role) {
102013
+ return `--design-${kebabCase(role)}`;
102014
+ }
102015
+ const roles = remove$5(palettes.light, "accent");
102016
+ const colors = {
102017
+ accent: map$11(hues, (hue) => `var(${variable(`accent-${hue}`)})`),
102018
+ ...map$11(roles, (_value, role) => `var(${variable(role)})`)
102019
+ };
100307
102020
  const styles = {
100308
102021
  body: {
100309
- color: ink,
102022
+ color: colors.ink,
100310
102023
  fontSize: 15,
100311
102024
  lineHeight: 22
100312
102025
  },
100313
102026
  bone: {
100314
- backgroundColor: chipFill,
102027
+ backgroundColor: colors.control,
100315
102028
  borderRadius: 6
100316
102029
  },
100317
102030
  card: {
100318
- backgroundColor: card,
100319
- borderRadius: 22,
102031
+ backgroundColor: colors.surface,
102032
+ borderRadius: 24,
100320
102033
  overflow: "hidden"
100321
102034
  },
100322
102035
  chip: {
100323
102036
  alignItems: "center",
100324
- backgroundColor: chipFill,
102037
+ backgroundColor: colors.raised,
100325
102038
  display: "flex",
100326
102039
  flexShrink: 0,
100327
102040
  justifyContent: "center",
@@ -100329,12 +102042,12 @@ const styles = {
100329
102042
  },
100330
102043
  control: {
100331
102044
  alignItems: "center",
100332
- backgroundColor: "#202020",
102045
+ backgroundColor: colors.raised,
100333
102046
  borderRadius: 8,
100334
102047
  display: "flex",
100335
102048
  justifyContent: "center",
100336
- minHeight: 40,
100337
- minWidth: 40,
102049
+ minHeight: 44,
102050
+ minWidth: 44,
100338
102051
  paddingInline: 10
100339
102052
  },
100340
102053
  detail: {
@@ -100344,30 +102057,44 @@ const styles = {
100344
102057
  padding: 20
100345
102058
  },
100346
102059
  dot: {
100347
- borderRadius: 3,
102060
+ borderRadius: 3.5,
100348
102061
  flexShrink: 0,
100349
- height: 6,
100350
- width: 6
102062
+ height: 7,
102063
+ width: 7
100351
102064
  },
100352
102065
  emptyLine: {
100353
- color: muted,
102066
+ color: colors.secondary,
100354
102067
  fontSize: 17,
100355
102068
  lineHeight: 22,
100356
102069
  textAlign: "center"
100357
102070
  },
102071
+ field: {
102072
+ borderColor: colors.outline,
102073
+ borderRadius: 12,
102074
+ borderWidth: 1,
102075
+ minHeight: 44,
102076
+ padding: 8
102077
+ },
100358
102078
  figure: {
100359
- color: muted,
100360
- fontSize: 15,
100361
- lineHeight: 20
102079
+ color: colors.secondary,
102080
+ fontSize: 13,
102081
+ lineHeight: 18
100362
102082
  },
100363
102083
  frame: {
100364
- backgroundColor: black,
102084
+ backgroundColor: colors.canvas,
100365
102085
  display: "flex",
100366
102086
  flex: 1,
100367
102087
  minHeight: 0
100368
102088
  },
102089
+ glass: {
102090
+ backgroundColor: colors.glass,
102091
+ borderColor: colors.glassEdge,
102092
+ borderRadius: 22,
102093
+ borderWidth: 1,
102094
+ minHeight: 44
102095
+ },
100369
102096
  groupHeading: {
100370
- color: ink,
102097
+ color: colors.ink,
100371
102098
  fontSize: 15,
100372
102099
  fontWeight: "600",
100373
102100
  lineHeight: 20,
@@ -100376,14 +102103,14 @@ const styles = {
100376
102103
  paddingTop: 18
100377
102104
  },
100378
102105
  heading: {
100379
- color: ink,
102106
+ color: colors.ink,
100380
102107
  fontSize: 20,
100381
102108
  fontWeight: "600",
100382
102109
  lineHeight: 26
100383
102110
  },
100384
102111
  headline: {
100385
- color: ink,
100386
- fontSize: 26,
102112
+ color: colors.ink,
102113
+ fontSize: 28,
100387
102114
  fontWeight: "700",
100388
102115
  lineHeight: 32
100389
102116
  },
@@ -100394,12 +102121,12 @@ const styles = {
100394
102121
  minWidth: 0
100395
102122
  },
100396
102123
  line: {
100397
- color: muted,
102124
+ color: colors.secondary,
100398
102125
  fontSize: 13,
100399
102126
  lineHeight: 18
100400
102127
  },
100401
102128
  overline: {
100402
- color: ink,
102129
+ color: colors.ink,
100403
102130
  flexShrink: 1,
100404
102131
  fontSize: 14,
100405
102132
  fontWeight: "600",
@@ -100424,12 +102151,22 @@ const styles = {
100424
102151
  flexDirection: "row",
100425
102152
  minHeight: 0
100426
102153
  },
102154
+ pill: {
102155
+ borderRadius: 12,
102156
+ minHeight: 24,
102157
+ paddingInline: 8
102158
+ },
102159
+ reader: {
102160
+ color: colors.ink,
102161
+ fontSize: 16,
102162
+ lineHeight: 25
102163
+ },
100427
102164
  row: {
100428
102165
  alignItems: "center",
100429
102166
  display: "flex",
100430
102167
  flexDirection: "row",
100431
102168
  gap: 12,
100432
- minHeight: 52,
102169
+ minHeight: 54,
100433
102170
  paddingInline: 16
100434
102171
  },
100435
102172
  rowBody: {
@@ -100447,12 +102184,13 @@ const styles = {
100447
102184
  paddingInline: 16
100448
102185
  },
100449
102186
  scale: {
100450
- color: "rgba(235,235,245,.6)",
102187
+ color: colors.quiet,
100451
102188
  fontSize: 11,
100452
- lineHeight: 14
102189
+ lineHeight: 15
100453
102190
  },
100454
102191
  sheet: {
100455
- backgroundColor: "#151515",
102192
+ backgroundColor: colors.surface,
102193
+ borderRadius: 26,
100456
102194
  display: "flex",
100457
102195
  flexDirection: "column",
100458
102196
  gap: 16,
@@ -100465,14 +102203,32 @@ const styles = {
100465
102203
  justifyContent: "flex-end"
100466
102204
  },
100467
102205
  summary: {
100468
- color: muted,
102206
+ color: colors.secondary,
100469
102207
  fontSize: 14,
100470
102208
  lineHeight: 19
100471
102209
  },
102210
+ tile: {
102211
+ backgroundColor: colors.surface,
102212
+ borderRadius: 24,
102213
+ gap: 8,
102214
+ padding: 16
102215
+ },
102216
+ tileLabel: {
102217
+ color: colors.secondary,
102218
+ fontSize: 13,
102219
+ lineHeight: 18
102220
+ },
102221
+ tileValue: {
102222
+ color: colors.ink,
102223
+ fontSize: 28,
102224
+ fontWeight: "600",
102225
+ lineHeight: 32
102226
+ },
100472
102227
  title: {
100473
- color: ink,
102228
+ color: colors.ink,
100474
102229
  flexShrink: 1,
100475
102230
  fontSize: 16,
102231
+ fontWeight: "500",
100476
102232
  lineHeight: 21
100477
102233
  },
100478
102234
  titleLine: {
@@ -100481,6 +102237,12 @@ const styles = {
100481
102237
  flexDirection: "row",
100482
102238
  gap: 6,
100483
102239
  minWidth: 0
102240
+ },
102241
+ workspaceTitle: {
102242
+ color: colors.ink,
102243
+ fontSize: 34,
102244
+ fontWeight: "700",
102245
+ lineHeight: 39
100484
102246
  }
100485
102247
  };
100486
102248
  // src/sign-ins/shared.ts
@@ -100517,10 +102279,11 @@ var SignIns = class SignIns extends Service$1()("@deslop/auth/sign-ins/server/Si
100517
102279
  function nativeCallback(app, answer) {
100518
102280
  return new URL(`/signed-in/${app}?${answer}`, canonical).href;
100519
102281
  }
100520
- function accountFor(session) {
102282
+ function accountFor(session, purpose) {
100521
102283
  return identity.resolve(IdentifyRequest.make({
100522
102284
  address: none(),
100523
102285
  onBehalfOf: none(),
102286
+ purpose,
100524
102287
  session: some$1(session)
100525
102288
  }), true);
100526
102289
  }
@@ -100551,7 +102314,7 @@ var SignIns = class SignIns extends Service$1()("@deslop/auth/sign-ins/server/Si
100551
102314
  name: profile.login
100552
102315
  }, profile.name, false)).id, fromNullishOr$1(headers[CLIENT_HEADER]), headers["user-agent"] ?? "Browser");
100553
102316
  return {
100554
- role: (yield* accountFor(secret)).role,
102317
+ role: (yield* accountFor(secret, "use")).role,
100555
102318
  secret
100556
102319
  };
100557
102320
  }))), asAuthError("Cannot finish the sign-in"), flatMap$3(fnUntraced(function* (signed) {
@@ -100640,7 +102403,7 @@ var SignIns = class SignIns extends Service$1()("@deslop/auth/sign-ins/server/Si
100640
102403
  message: "Invalid waiting sign-in"
100641
102404
  });
100642
102405
  return yield* pipe(sql.withTransaction(gen(function* () {
100643
- const account = yield* accountFor(pending.session);
102406
+ const account = yield* accountFor(pending.session, "verify");
100644
102407
  if (!isGreaterThan$1(pending.expires, yield* now)) {
100645
102408
  if (account.role === "Waiting") yield* sessions.forget(pending.session);
100646
102409
  return ended("The sign-in expired; sign in again");
@@ -100669,8 +102432,12 @@ function waitingPage(unavailable) {
100669
102432
  });
100670
102433
  return html(`<!doctype html>
100671
102434
  <html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
100672
- <meta name="color-scheme" content="dark"><meta http-equiv="refresh" content="5"><title>Auth</title></head>
100673
- <body style="display:grid;place-items:center;min-height:100dvh;margin:0;background:${black};color:${styles.line.color};
102435
+ <meta name="color-scheme" content="light dark">
102436
+ <meta name="theme-color" media="(prefers-color-scheme: light)" content="${palettes.light.canvas}">
102437
+ <meta name="theme-color" media="(prefers-color-scheme: dark)" content="${palettes.dark.canvas}">
102438
+ <meta http-equiv="refresh" content="5"><title>Auth</title></head>
102439
+ <body style="display:grid;place-items:center;min-height:100dvh;margin:0;
102440
+ background:light-dark(${palettes.light.canvas},${palettes.dark.canvas});color:light-dark(${palettes.light.secondary},${palettes.dark.secondary});
100674
102441
  font:${styles.line.fontSize}px/${styles.line.lineHeight}px system-ui"><p role="status">${text}</p></body></html>`);
100675
102442
  }
100676
102443
  const association = { webcredentials: { apps: flatMap$6(AppSignIn.fields.app.literals, (slug) => map$10(["", ".dev"], (suffix) => `99K7MQUK7F.xyz.mp281x.${slug}${suffix}`)) } };
@@ -100724,10 +102491,10 @@ var icon_default = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 64 6
100724
102491
  const layerServices = pipe(SignIns.layer, provideMerge(Identity.layer), provide$2(Tailnet.layer), provideMerge(People.layer), provideMerge(mergeAll$1(Sessions.layer, GitHub.layer)), provide$2(succeed$6(RequestInit, { redirect: "error" })));
100725
102492
  const toolkit = merge(peopleTools, sessionsTools);
100726
102493
  runApp({
100727
- auth: provide$2(effectContext(map$7(Identity, (identity) => Auth.makeContext((headers) => withSpan(identity.resolve(identifyRequestOf(headers)), "Identity.account")))), layerServices),
102494
+ auth: provide$2(effectContext(map$7(Identity, (identity) => Auth.makeContext((headers, purpose) => withSpan(identity.resolve(identifyRequestOf(headers, purpose)), "Identity.account")))), layerServices),
100728
102495
  icon: icon_default,
100729
102496
  middleware: (app) => map$7(app, setHeader("content-security-policy", "frame-ancestors 'none'")),
100730
- routes: provide$2(mergeAll$1(identityHttp, signInsHttp, layerRpc({
102497
+ routes: provide$2(mergeAll$1(identityHttp, sessionsHttp, signInsHttp, layerRpc({
100731
102498
  group: RpcContracts,
100732
102499
  handlers: mergeAll$1(identityHandlers, peopleHandlers, sessionsHandlers)
100733
102500
  }), layerMcp({