@akterjs/cli 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +47 -2
  3. package/dist/Argument-D81dqizB.mjs +57 -0
  4. package/dist/Array-B4kuTQeW.mjs +2323 -0
  5. package/dist/Boolean-kILIvmhE.mjs +26 -0
  6. package/dist/ChildProcess-BCIwxPGc.mjs +577 -0
  7. package/dist/CliError-Cf5xqkkj.mjs +633 -0
  8. package/dist/Command-Dzq9KM-h.mjs +5135 -0
  9. package/dist/Config-B6OND9WR.mjs +854 -0
  10. package/dist/Console-BKHUkH6a.mjs +141 -0
  11. package/dist/Data-CeCULr0-.mjs +251 -0
  12. package/dist/Digest-CBd3uv5B.mjs +348 -0
  13. package/dist/Duration-EH9Vy4U6.mjs +791 -0
  14. package/dist/Effect-CKFpqbmw.mjs +12911 -0
  15. package/dist/FileSystem-4pPcEb_i.mjs +1366 -0
  16. package/dist/HttpClientError-BUeMWx70.mjs +303 -0
  17. package/dist/HttpClientResponse-D5ZKICVV.mjs +855 -0
  18. package/dist/Match-CGPLZYrV.mjs +434 -0
  19. package/dist/MutableHashMap-f8nW8AJR.mjs +376 -0
  20. package/dist/MutableHashSet-_HI572Ya.mjs +155 -0
  21. package/dist/MutableRef-D4Qv592C.mjs +107 -0
  22. package/dist/Number-BvkRkfc-.mjs +137 -0
  23. package/dist/Option-DkxSnBhp.mjs +3967 -0
  24. package/dist/Order-C1JC991I.mjs +481 -0
  25. package/dist/Path-Djdv_eF5.mjs +130 -0
  26. package/dist/Queue-CO5UQ6os.mjs +1394 -0
  27. package/dist/Redacted-RkJrG5Me.mjs +160 -0
  28. package/dist/Ref-BIPOxJNH.mjs +267 -0
  29. package/dist/Runtime-BInIAwK3.mjs +297 -0
  30. package/dist/Schema-MiKt5K1v.mjs +10999 -0
  31. package/dist/SecureRandom-B_U4ysO3.mjs +279 -0
  32. package/dist/Semaphore-DOVJ4ZGS.mjs +177 -0
  33. package/dist/Stdio-KylmOBX_.mjs +74 -0
  34. package/dist/Stream-bK9QIETN.mjs +4012 -0
  35. package/dist/String-q5dcsVe4.mjs +351 -0
  36. package/dist/TerminalCapabilities-w_44MAca.mjs +1769 -0
  37. package/dist/WebCrypto-ZI_GNVlw.mjs +33 -0
  38. package/dist/actor-call.service-CGM_vD9u.mjs +1269 -0
  39. package/dist/actor-client.adapter-Coem7gF1.mjs +3691 -0
  40. package/dist/akter-program.config-C4cXx4Fr.mjs +7034 -0
  41. package/dist/akter.cli.mjs +5 -0
  42. package/dist/app-cli.config.mjs +49 -0
  43. package/dist/app-entry.pure.mjs +31 -0
  44. package/dist/archive/akter-archive.schema.mjs +65 -0
  45. package/dist/archive/akter-archive.service.mjs +309 -0
  46. package/dist/archive/archive-cli.config.mjs +45 -0
  47. package/dist/archive/archive-invalid.errors.mjs +5 -0
  48. package/dist/archive/archived-lineage.pure.mjs +13 -0
  49. package/dist/archive/tar.pure.mjs +291 -0
  50. package/dist/archive/zstd.adapter.mjs +46 -0
  51. package/dist/bench/bench-report.pure.mjs +120 -0
  52. package/dist/bench/bench-runner.pure.mjs +89 -0
  53. package/dist/bench/bench.service.mjs +301 -0
  54. package/dist/cli-runtime.layer-BqK2mmVL.mjs +1191 -0
  55. package/dist/cli-runtime.layer.mjs +1 -0
  56. package/dist/cloud-client.adapter-Cy1BjDbG.mjs +3186 -0
  57. package/dist/cloud-client.adapter-DOVMoYAj.mjs +304 -0
  58. package/dist/command/akter-commands.config.mjs +32 -0
  59. package/dist/command/akter-program.config.mjs +1 -0
  60. package/dist/credentials/credentials.service.mjs +226 -0
  61. package/dist/credentials/keychain.adapter.mjs +92 -0
  62. package/dist/credentials/login.config.mjs +251 -0
  63. package/dist/deploy/auth/api-attempt.service.mjs +30 -0
  64. package/dist/deploy/auth/token-refresh.errors.mjs +4 -0
  65. package/dist/deploy/build-bundle.adapter.mjs +133 -0
  66. package/dist/deploy/build-manifest.pure.mjs +44 -0
  67. package/dist/deploy/cloud-client.adapter.mjs +1 -0
  68. package/dist/deploy/cloud-url.pure.mjs +17 -0
  69. package/dist/deploy/deploy-failed.errors.mjs +17 -0
  70. package/dist/deploy/deploy.service.mjs +156 -0
  71. package/dist/deploy/request-failure.pure.mjs +87 -0
  72. package/dist/dev-runner.pure.mjs +30 -0
  73. package/dist/docs/doc-topics.pure.mjs +21 -0
  74. package/dist/docs/docs.config.mjs +1 -0
  75. package/dist/docs.config-_21Xi6HU.mjs +190 -0
  76. package/dist/export/actor-export.service.mjs +267 -0
  77. package/dist/export/export-failed.errors.mjs +4 -0
  78. package/dist/export/export-failure.pure.mjs +18 -0
  79. package/dist/export/ordered-lines.pure.mjs +43 -0
  80. package/dist/export/ranged-download.pure.mjs +66 -0
  81. package/dist/export/snapshot-download.pure.mjs +86 -0
  82. package/dist/history-runner.pure.mjs +186 -0
  83. package/dist/history-since.pure.mjs +17 -0
  84. package/dist/hosted-runtime.layer-Cx3IPsEd.mjs +16358 -0
  85. package/dist/local/environment-cli.config.mjs +90 -0
  86. package/dist/local/environment-runner.pure.mjs +75 -0
  87. package/dist/local/local-cli.config.mjs +159 -0
  88. package/dist/logs/log-follow.config.mjs +21 -0
  89. package/dist/logs/log-follow.service.mjs +87 -0
  90. package/dist/logs/log-lines.pure.mjs +44 -0
  91. package/dist/migrate-runner.pure.mjs +28 -0
  92. package/dist/operation-input.pure-CS9iUhqK.mjs +1383 -0
  93. package/dist/operation-registry.pure-DVC8EDgj.mjs +283 -0
  94. package/dist/registry/actor-call.service.mjs +1 -0
  95. package/dist/registry/actor-commands.config.mjs +127 -0
  96. package/dist/registry/actor-refusal.pure.mjs +34 -0
  97. package/dist/registry/approval.service.mjs +80 -0
  98. package/dist/registry/cloud-commands.config.mjs +151 -0
  99. package/dist/registry/cloud-served.pure.mjs +31 -0
  100. package/dist/registry/operation-call.service.mjs +262 -0
  101. package/dist/registry/operation-input.pure.mjs +1 -0
  102. package/dist/registry/operation-output.pure.mjs +91 -0
  103. package/dist/registry/served-command.config.mjs +57 -0
  104. package/dist/runner-exited.errors.mjs +10 -0
  105. package/dist/terminal/cli-exit.errors.mjs +38 -0
  106. package/dist/terminal/cli-failure.pure.mjs +31 -0
  107. package/dist/terminal/confirm.adapter.mjs +27 -0
  108. package/package.json +61 -3
@@ -0,0 +1,3967 @@
1
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/Pipeable.js
2
+ /**
3
+ * The `Pipeable` module defines the shared interface and implementation helpers
4
+ * for values that support Effect-style method chaining with `.pipe(...)`.
5
+ *
6
+ * A `Pipeable` value can pass itself through a sequence of unary functions from
7
+ * left to right, so code can be written as `value.pipe(f, g, h)` instead of
8
+ * deeply nesting calls. This is the method form used by many Effect data types
9
+ * to compose transformations, validations, and effectful operations while
10
+ * keeping the original value as the starting point of the pipeline.
11
+ *
12
+ * @stability stable
13
+ * @since 2.0.0
14
+ */
15
+ /**
16
+ * Applies a `pipe` method's variadic arguments to an initial value from left
17
+ * to right.
18
+ *
19
+ * **When to use**
20
+ *
21
+ * Use to implement a custom `.pipe(...)` method from JavaScript's `arguments`
22
+ * object.
23
+ *
24
+ * **Details**
25
+ *
26
+ * This helper is intended for implementing `Pipeable.pipe` methods that
27
+ * receive JavaScript's `arguments` object. With no functions it returns the
28
+ * original value; otherwise it feeds each result into the next function.
29
+ *
30
+ * **Example** (Implementing a pipe method)
31
+ *
32
+ * ```ts import.meta.vitest
33
+ * import { Pipeable } from "effect"
34
+ *
35
+ * class NumberBox {
36
+ * constructor(readonly value: number) {}
37
+ *
38
+ * pipe(..._fns: ReadonlyArray<(value: number) => number>): number {
39
+ * return Pipeable.pipeArguments(this.value, arguments) as number
40
+ * }
41
+ * }
42
+ *
43
+ * const result = new NumberBox(5).pipe(
44
+ * (n) => n + 2,
45
+ * (n) => n * 3
46
+ * )
47
+ * result // => 21
48
+ * ```
49
+ *
50
+ * @stability stable
51
+ * @category combinators
52
+ * @since 2.0.0
53
+ */
54
+ const pipeArguments = (self, args) => {
55
+ switch (args.length) {
56
+ case 0: return self;
57
+ case 1: return args[0](self);
58
+ case 2: return args[1](args[0](self));
59
+ case 3: return args[2](args[1](args[0](self)));
60
+ case 4: return args[3](args[2](args[1](args[0](self))));
61
+ case 5: return args[4](args[3](args[2](args[1](args[0](self)))));
62
+ case 6: return args[5](args[4](args[3](args[2](args[1](args[0](self))))));
63
+ case 7: return args[6](args[5](args[4](args[3](args[2](args[1](args[0](self)))))));
64
+ case 8: return args[7](args[6](args[5](args[4](args[3](args[2](args[1](args[0](self))))))));
65
+ case 9: return args[8](args[7](args[6](args[5](args[4](args[3](args[2](args[1](args[0](self)))))))));
66
+ default: {
67
+ let ret = self;
68
+ for (let i = 0, len = args.length; i < len; i++) ret = args[i](ret);
69
+ return ret;
70
+ }
71
+ }
72
+ };
73
+ /**
74
+ * Reusable prototype that implements `Pipeable.pipe`.
75
+ *
76
+ * **When to use**
77
+ *
78
+ * Use when classes or object prototypes can reuse this value when they need the
79
+ * standard pipe implementation backed by `pipeArguments`.
80
+ *
81
+ * @stability stable
82
+ * @category prototypes
83
+ * @since 3.15.0
84
+ */
85
+ const Prototype = { pipe() {
86
+ return pipeArguments(this, arguments);
87
+ } };
88
+ /**
89
+ * Provides a base constructor whose instances implement the standard `Pipeable.pipe`
90
+ * method.
91
+ *
92
+ * **When to use**
93
+ *
94
+ * Use when you need to define a class that supports Effect-style method
95
+ * chaining through `.pipe(...)`.
96
+ *
97
+ * @stability stable
98
+ * @category constructors
99
+ * @since 3.15.0
100
+ */
101
+ const Class$1 = /*#__PURE__*/ function() {
102
+ function PipeableBase() {}
103
+ PipeableBase.prototype = Prototype;
104
+ return PipeableBase;
105
+ }();
106
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/Function.js
107
+ /**
108
+ * Creates a function that can be called in data-first style or data-last
109
+ * (`pipe`-friendly) style.
110
+ *
111
+ * **When to use**
112
+ *
113
+ * Use to expose one implementation through both direct and `pipe`-friendly
114
+ * call styles.
115
+ *
116
+ * **Details**
117
+ *
118
+ * Pass either the arity of the uncurried function or a predicate that decides
119
+ * whether the current call is data-first. Arity is the common case. Use a
120
+ * predicate when optional arguments make arity ambiguous.
121
+ *
122
+ * **Example** (Selecting data-first or data-last style by arity)
123
+ *
124
+ * ```ts import.meta.vitest
125
+ * import { Function, pipe } from "effect"
126
+ *
127
+ * const sum = Function.dual<
128
+ * (that: number) => (self: number) => number,
129
+ * (self: number, that: number) => number
130
+ * >(2, (self, that) => self + that)
131
+ *
132
+ * sum(2, 3) // => 5
133
+ * pipe(2, sum(3)) // => 5
134
+ * ```
135
+ *
136
+ * **Example** (Defining overloads with call signatures)
137
+ *
138
+ * ```ts import.meta.vitest
139
+ * import { Function, pipe } from "effect"
140
+ *
141
+ * const sum: {
142
+ * (that: number): (self: number) => number
143
+ * (self: number, that: number): number
144
+ * } = Function.dual(2, (self: number, that: number): number => self + that)
145
+ *
146
+ * sum(2, 3) // => 5
147
+ * pipe(2, sum(3)) // => 5
148
+ * ```
149
+ *
150
+ * **Example** (Selecting data-first or data-last style with a predicate)
151
+ *
152
+ * ```ts import.meta.vitest
153
+ * import { Function, pipe } from "effect"
154
+ *
155
+ * const sum = Function.dual<
156
+ * (that: number) => (self: number) => number,
157
+ * (self: number, that: number) => number
158
+ * >(
159
+ * (args) => args.length === 2,
160
+ * (self, that) => self + that
161
+ * )
162
+ *
163
+ * sum(2, 3) // => 5
164
+ * pipe(2, sum(3)) // => 5
165
+ * ```
166
+ *
167
+ * @stability stable
168
+ * @category combinators
169
+ * @since 2.0.0
170
+ */
171
+ const dual = function(arity, body) {
172
+ if (typeof arity === "function") return function() {
173
+ return arity(arguments) ? body.apply(this, arguments) : (self) => body(self, ...arguments);
174
+ };
175
+ switch (arity) {
176
+ case 0:
177
+ case 1: throw new RangeError(`Invalid arity ${arity}`);
178
+ case 2: return function(a, b) {
179
+ if (arguments.length >= 2) return body(a, b);
180
+ return function(self) {
181
+ return body(self, a);
182
+ };
183
+ };
184
+ case 3: return function(a, b, c) {
185
+ if (arguments.length >= 3) return body(a, b, c);
186
+ return function(self) {
187
+ return body(self, a, b);
188
+ };
189
+ };
190
+ default: return function() {
191
+ if (arguments.length >= arity) return body.apply(this, arguments);
192
+ const args = arguments;
193
+ return function(self) {
194
+ return body(self, ...args);
195
+ };
196
+ };
197
+ }
198
+ };
199
+ /**
200
+ * Returns its input argument unchanged.
201
+ *
202
+ * **When to use**
203
+ *
204
+ * Use to return a value unchanged where a function is required.
205
+ *
206
+ * **Example** (Returning the same value)
207
+ *
208
+ * ```ts import.meta.vitest
209
+ * import { identity } from "effect"
210
+ *
211
+ * identity(5) // => 5
212
+ * ```
213
+ *
214
+ * @stability stable
215
+ * @category combinators
216
+ * @since 2.0.0
217
+ */
218
+ const identity = (a) => a;
219
+ /**
220
+ * Creates a zero-argument function that always returns the provided value.
221
+ *
222
+ * **When to use**
223
+ *
224
+ * Use when you need a thunk or callback that returns the same value on every
225
+ * invocation.
226
+ *
227
+ * **Example** (Creating a constant thunk)
228
+ *
229
+ * ```ts import.meta.vitest
230
+ * import { Function } from "effect"
231
+ *
232
+ * const constNull = Function.constant(null)
233
+ *
234
+ * constNull() // => null
235
+ * constNull() // => null
236
+ * ```
237
+ *
238
+ * @stability stable
239
+ * @category constructors
240
+ * @since 2.0.0
241
+ */
242
+ const constant = (value) => () => value;
243
+ /**
244
+ * Returns `true` when called.
245
+ *
246
+ * **When to use**
247
+ *
248
+ * Use when you need a thunk that returns `true` on every invocation.
249
+ *
250
+ * **Example** (Returning true from a thunk)
251
+ *
252
+ * ```ts import.meta.vitest
253
+ * import { Function } from "effect"
254
+ *
255
+ * Function.constTrue() // => true
256
+ * ```
257
+ *
258
+ * @stability stable
259
+ * @category constants
260
+ * @since 2.0.0
261
+ */
262
+ const constTrue = /*#__PURE__*/ constant(true);
263
+ /**
264
+ * Returns `false` when called.
265
+ *
266
+ * **When to use**
267
+ *
268
+ * Use when you need a thunk that returns `false` on every invocation.
269
+ *
270
+ * **Example** (Returning false from a thunk)
271
+ *
272
+ * ```ts import.meta.vitest
273
+ * import { Function } from "effect"
274
+ *
275
+ * Function.constFalse() // => false
276
+ * ```
277
+ *
278
+ * @stability stable
279
+ * @category constants
280
+ * @since 2.0.0
281
+ */
282
+ const constFalse = /*#__PURE__*/ constant(false);
283
+ /**
284
+ * Returns `null` when called.
285
+ *
286
+ * **When to use**
287
+ *
288
+ * Use when you need a thunk that returns `null` on every invocation.
289
+ *
290
+ * **Example** (Returning null from a thunk)
291
+ *
292
+ * ```ts import.meta.vitest
293
+ * import { Function } from "effect"
294
+ *
295
+ * Function.constNull() // => null
296
+ * ```
297
+ *
298
+ * @stability stable
299
+ * @category constants
300
+ * @since 2.0.0
301
+ */
302
+ const constNull = /*#__PURE__*/ constant(null);
303
+ /**
304
+ * Returns `undefined` when called.
305
+ *
306
+ * **When to use**
307
+ *
308
+ * Use when you need a thunk that returns `undefined` on every invocation.
309
+ *
310
+ * **Example** (Returning undefined from a thunk)
311
+ *
312
+ * ```ts import.meta.vitest
313
+ * import { Function } from "effect"
314
+ *
315
+ * Function.constUndefined() // => undefined
316
+ * ```
317
+ *
318
+ * @stability stable
319
+ * @category constants
320
+ * @since 2.0.0
321
+ */
322
+ const constUndefined = /*#__PURE__*/ constant(void 0);
323
+ /**
324
+ * Returns no meaningful value when called.
325
+ *
326
+ * **When to use**
327
+ *
328
+ * Use when you need a thunk that is called only for its effect and has no
329
+ * meaningful return value.
330
+ *
331
+ * **Example** (Returning void from a thunk)
332
+ *
333
+ * ```ts import.meta.vitest
334
+ * import { Function } from "effect"
335
+ *
336
+ * Function.constVoid() // => undefined
337
+ * ```
338
+ *
339
+ * @stability stable
340
+ * @category constants
341
+ * @since 2.0.0
342
+ */
343
+ const constVoid = constUndefined;
344
+ function pipe(a, ...args) {
345
+ return pipeArguments(a, args);
346
+ }
347
+ function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) {
348
+ switch (arguments.length) {
349
+ case 1: return ab;
350
+ case 2: return function() {
351
+ return bc(ab.apply(this, arguments));
352
+ };
353
+ case 3: return function() {
354
+ return cd(bc(ab.apply(this, arguments)));
355
+ };
356
+ case 4: return function() {
357
+ return de(cd(bc(ab.apply(this, arguments))));
358
+ };
359
+ case 5: return function() {
360
+ return ef(de(cd(bc(ab.apply(this, arguments)))));
361
+ };
362
+ case 6: return function() {
363
+ return fg(ef(de(cd(bc(ab.apply(this, arguments))))));
364
+ };
365
+ case 7: return function() {
366
+ return gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))));
367
+ };
368
+ case 8: return function() {
369
+ return hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))));
370
+ };
371
+ case 9: return function() {
372
+ return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))));
373
+ };
374
+ }
375
+ }
376
+ /**
377
+ * Creates a memoized function whose input is an object, caching results by
378
+ * object identity.
379
+ *
380
+ * **When to use**
381
+ *
382
+ * Use to reuse the result of a synchronous computation whose output is stable
383
+ * for a given object reference.
384
+ *
385
+ * **Details**
386
+ *
387
+ * Each memoized wrapper owns a private `WeakMap` keyed by object identity.
388
+ *
389
+ * **Gotchas**
390
+ *
391
+ * `undefined` is reserved to represent a cache miss and is therefore not
392
+ * supported as a return value.
393
+ *
394
+ * Structurally equal objects do not share cache entries. If the same object is
395
+ * mutated after its first call, later calls still return the cached result for
396
+ * that reference.
397
+ *
398
+ * @stability stable
399
+ * @category caching
400
+ * @since 4.0.0
401
+ */
402
+ function memoize(f) {
403
+ const cache = /* @__PURE__ */ new WeakMap();
404
+ return (a) => {
405
+ const cached = cache.get(a);
406
+ if (cached !== void 0) return cached;
407
+ const result = f(a);
408
+ cache.set(a, result);
409
+ return result;
410
+ };
411
+ }
412
+ /**
413
+ * Creates a memoized idempotent object transformation that caches both inputs
414
+ * and their outputs by object identity.
415
+ *
416
+ * **When to use**
417
+ *
418
+ * Use when an object transformation is idempotent and its output can be safely
419
+ * reused as a fixed point.
420
+ *
421
+ * **Details**
422
+ *
423
+ * After computing an input, the returned function caches both the input and
424
+ * the output. Calling it with either reference returns the output without
425
+ * invoking the supplied function again.
426
+ *
427
+ * **Gotchas**
428
+ *
429
+ * The returned function treats each computed output as a fixed point. If
430
+ * applying the supplied function to an output would produce an observably
431
+ * different value, this memoization changes that behavior.
432
+ *
433
+ * @see {@link memoize} for memoizing functions without an idempotence requirement
434
+ * @stability stable
435
+ * @category caching
436
+ * @since 4.0.0
437
+ */
438
+ function memoizeIdempotent(f) {
439
+ const cache = /* @__PURE__ */ new WeakMap();
440
+ return (a) => {
441
+ const cached = cache.get(a);
442
+ if (cached !== void 0) return cached;
443
+ const result = f(a);
444
+ cache.set(a, result);
445
+ if (result !== a) cache.set(result, result);
446
+ return result;
447
+ };
448
+ }
449
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/internal/equal.js
450
+ /** @internal */
451
+ const getAllObjectKeys = (obj) => {
452
+ const keys = new Set(Reflect.ownKeys(obj));
453
+ if (obj.constructor === Object) return keys;
454
+ if (obj instanceof Error) keys.delete("stack");
455
+ const proto = Object.getPrototypeOf(obj);
456
+ let current = proto;
457
+ while (current !== null && current !== Object.prototype) {
458
+ const ownKeys = Reflect.ownKeys(current);
459
+ for (let i = 0; i < ownKeys.length; i++) keys.add(ownKeys[i]);
460
+ current = Object.getPrototypeOf(current);
461
+ }
462
+ if (keys.has("constructor") && typeof obj.constructor === "function" && proto === obj.constructor.prototype) keys.delete("constructor");
463
+ return keys;
464
+ };
465
+ /** @internal */
466
+ const byReferenceInstances = /*#__PURE__*/ new WeakSet();
467
+ /** @internal */
468
+ const viewBytes = (view) => new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
469
+ /** @internal */
470
+ const isArrayBufferLike = (u) => u instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && u instanceof SharedArrayBuffer;
471
+ /**
472
+ * Returns `undefined` for detached buffers, which can no longer be read.
473
+ *
474
+ * @internal
475
+ */
476
+ const bufferBytes = (buffer) => {
477
+ try {
478
+ return new Uint8Array(buffer);
479
+ } catch {
480
+ return;
481
+ }
482
+ };
483
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/internal/hash.js
484
+ /**
485
+ * Back-edge count used to avoid caching entry-point-dependent hashes.
486
+ *
487
+ * @internal
488
+ */
489
+ let backEdges = 0;
490
+ /** @internal */
491
+ const addBackEdge = () => {
492
+ backEdges++;
493
+ };
494
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/Predicate.js
495
+ /**
496
+ * Defines runtime checks for values.
497
+ *
498
+ * A `Predicate<A>` returns `true` or `false` for an `A`. A
499
+ * `Refinement<A, B>` is a predicate that also narrows the TypeScript type when
500
+ * it succeeds. This module includes guards for common JavaScript values,
501
+ * property and tag checks, tuple and struct checks, boolean combinators, and
502
+ * helpers for composing predicates and refinements.
503
+ *
504
+ * @stability stable
505
+ * @since 2.0.0
506
+ */
507
+ /**
508
+ * Checks whether a value is a `string`.
509
+ *
510
+ * **When to use**
511
+ *
512
+ * Use when you need a `Predicate` guard to narrow an `unknown` value to a
513
+ * string.
514
+ *
515
+ * **Details**
516
+ *
517
+ * Uses `typeof input === "string"`.
518
+ *
519
+ * **Example** (Guarding strings)
520
+ *
521
+ * ```ts import.meta.vitest
522
+ * import { Predicate } from "effect"
523
+ *
524
+ * const data: unknown = "hi"
525
+ *
526
+ * if (Predicate.isString(data)) {
527
+ * data.toUpperCase() // => "HI"
528
+ * }
529
+ * ```
530
+ *
531
+ * @see {@link isNumber}
532
+ * @see {@link isBoolean}
533
+ * @see {@link Refinement}
534
+ * @stability stable
535
+ * @category guards
536
+ * @since 2.0.0
537
+ */
538
+ function isString(input) {
539
+ return typeof input === "string";
540
+ }
541
+ /**
542
+ * Checks whether a value is a `number`.
543
+ *
544
+ * **When to use**
545
+ *
546
+ * Use when you need a `Predicate` guard to narrow an `unknown` value to a
547
+ * number.
548
+ *
549
+ * **Details**
550
+ *
551
+ * Uses `typeof input === "number"` and does not exclude `NaN` or `Infinity`.
552
+ *
553
+ * **Example** (Guarding numbers)
554
+ *
555
+ * ```ts import.meta.vitest
556
+ * import { Predicate } from "effect"
557
+ *
558
+ * const data: unknown = 42
559
+ *
560
+ * if (Predicate.isNumber(data)) {
561
+ * data + 1 // => 43
562
+ * }
563
+ * ```
564
+ *
565
+ * @see {@link isBigInt}
566
+ * @see {@link isString}
567
+ * @stability stable
568
+ * @category guards
569
+ * @since 2.0.0
570
+ */
571
+ function isNumber(input) {
572
+ return typeof input === "number";
573
+ }
574
+ /**
575
+ * Checks whether a value is a `boolean`.
576
+ *
577
+ * **When to use**
578
+ *
579
+ * Use when you need a `Predicate` guard to narrow an `unknown` value to a
580
+ * boolean.
581
+ *
582
+ * **Details**
583
+ *
584
+ * Uses `typeof input === "boolean"`.
585
+ *
586
+ * **Example** (Guarding booleans)
587
+ *
588
+ * ```ts import.meta.vitest
589
+ * import { Predicate } from "effect"
590
+ *
591
+ * const data: unknown = true
592
+ *
593
+ * if (Predicate.isBoolean(data)) {
594
+ * data ? "yes" : "no" // => "yes"
595
+ * }
596
+ * ```
597
+ *
598
+ * @see {@link isString}
599
+ * @see {@link isNumber}
600
+ * @stability stable
601
+ * @category guards
602
+ * @since 2.0.0
603
+ */
604
+ function isBoolean(input) {
605
+ return typeof input === "boolean";
606
+ }
607
+ /**
608
+ * Checks whether a value is a `bigint`.
609
+ *
610
+ * **When to use**
611
+ *
612
+ * Use when you need a `Predicate` guard to narrow an `unknown` value to a
613
+ * bigint.
614
+ *
615
+ * **Details**
616
+ *
617
+ * Uses `typeof input === "bigint"`.
618
+ *
619
+ * **Example** (Guarding bigints)
620
+ *
621
+ * ```ts import.meta.vitest
622
+ * import { Predicate } from "effect"
623
+ *
624
+ * const data: unknown = 1n
625
+ *
626
+ * if (Predicate.isBigInt(data)) {
627
+ * data + 2n // => 3n
628
+ * }
629
+ * ```
630
+ *
631
+ * @see {@link isNumber}
632
+ * @stability stable
633
+ * @category guards
634
+ * @since 2.0.0
635
+ */
636
+ function isBigInt(input) {
637
+ return typeof input === "bigint";
638
+ }
639
+ /**
640
+ * Checks whether a value is a `symbol`.
641
+ *
642
+ * **When to use**
643
+ *
644
+ * Use when you need a `Predicate` guard to narrow an `unknown` value to a
645
+ * symbol.
646
+ *
647
+ * **Details**
648
+ *
649
+ * Uses `typeof input === "symbol"`.
650
+ *
651
+ * **Example** (Guarding symbols)
652
+ *
653
+ * ```ts import.meta.vitest
654
+ * import { Predicate } from "effect"
655
+ *
656
+ * const data: unknown = Symbol.for("id")
657
+ *
658
+ * if (Predicate.isSymbol(data)) {
659
+ * data.description // => "id"
660
+ * }
661
+ * ```
662
+ *
663
+ * @see {@link isPropertyKey}
664
+ * @stability stable
665
+ * @category guards
666
+ * @since 2.0.0
667
+ */
668
+ function isSymbol(input) {
669
+ return typeof input === "symbol";
670
+ }
671
+ /**
672
+ * Checks whether a value is a valid `PropertyKey` (string, number, or symbol).
673
+ *
674
+ * **When to use**
675
+ *
676
+ * Use when you need a `Predicate` guard for unknown property keys before
677
+ * indexing.
678
+ *
679
+ * **Details**
680
+ *
681
+ * Uses `isString`, `isNumber`, and `isSymbol`.
682
+ *
683
+ * **Example** (Guarding property keys)
684
+ *
685
+ * ```ts import.meta.vitest
686
+ * import { Predicate } from "effect"
687
+ *
688
+ * const key: unknown = "name"
689
+ * const obj: Record<PropertyKey, unknown> = { name: "Ada" }
690
+ *
691
+ * if (Predicate.isPropertyKey(key) && key in obj) {
692
+ * obj[key] // => "Ada"
693
+ * }
694
+ * ```
695
+ *
696
+ * @see {@link isString}
697
+ * @see {@link isNumber}
698
+ * @see {@link isSymbol}
699
+ * @stability stable
700
+ * @category guards
701
+ * @since 4.0.0
702
+ */
703
+ function isPropertyKey(u) {
704
+ return isString(u) || isNumber(u) || isSymbol(u);
705
+ }
706
+ /**
707
+ * Checks whether a value is a `function`.
708
+ *
709
+ * **When to use**
710
+ *
711
+ * Use when you need a `Predicate` guard to narrow an `unknown` value to a
712
+ * callable function.
713
+ *
714
+ * **Details**
715
+ *
716
+ * Uses `typeof input === "function"`.
717
+ *
718
+ * **Example** (Guarding functions)
719
+ *
720
+ * ```ts import.meta.vitest
721
+ * import { Predicate } from "effect"
722
+ *
723
+ * const data: unknown = () => 1
724
+ *
725
+ * if (Predicate.isFunction(data)) {
726
+ * data() // => 1
727
+ * }
728
+ * ```
729
+ *
730
+ * @see {@link isObjectKeyword}
731
+ * @stability stable
732
+ * @category guards
733
+ * @since 2.0.0
734
+ */
735
+ function isFunction(input) {
736
+ return typeof input === "function";
737
+ }
738
+ /**
739
+ * Checks whether a value is `undefined`.
740
+ *
741
+ * **When to use**
742
+ *
743
+ * Use when you need a `Predicate` guard for values that are exactly
744
+ * `undefined`.
745
+ *
746
+ * **Details**
747
+ *
748
+ * Uses `input === undefined`.
749
+ *
750
+ * **Example** (Guarding undefined values)
751
+ *
752
+ * ```ts import.meta.vitest
753
+ * import { Predicate } from "effect"
754
+ *
755
+ * const data: unknown = undefined
756
+ *
757
+ * Predicate.isUndefined(data) // => true
758
+ * ```
759
+ *
760
+ * @see {@link isNotUndefined}
761
+ * @see {@link isNullish}
762
+ * @stability stable
763
+ * @category guards
764
+ * @since 2.0.0
765
+ */
766
+ function isUndefined(input) {
767
+ return input === void 0;
768
+ }
769
+ /**
770
+ * Checks whether a value is not `undefined`.
771
+ *
772
+ * **When to use**
773
+ *
774
+ * Use when you need a `Predicate` refinement that filters out `undefined`
775
+ * while preserving other falsy values.
776
+ *
777
+ * **Details**
778
+ *
779
+ * Returns a refinement that excludes `undefined`.
780
+ *
781
+ * **Example** (Filtering undefined values)
782
+ *
783
+ * ```ts import.meta.vitest
784
+ * import { Predicate } from "effect"
785
+ *
786
+ * const values = [1, undefined, 2]
787
+ * const defined = values.filter(Predicate.isNotUndefined) // => [1, 2]
788
+ * ```
789
+ *
790
+ * @see {@link isUndefined}
791
+ * @see {@link isNotNullish}
792
+ * @stability stable
793
+ * @category guards
794
+ * @since 2.0.0
795
+ */
796
+ function isNotUndefined(input) {
797
+ return input !== void 0;
798
+ }
799
+ /**
800
+ * Checks whether a value is not `null`.
801
+ *
802
+ * **When to use**
803
+ *
804
+ * Use when you need a `Predicate` refinement that filters out `null` while
805
+ * preserving other falsy values.
806
+ *
807
+ * **Details**
808
+ *
809
+ * Returns a refinement that excludes `null`.
810
+ *
811
+ * **Example** (Filtering null values)
812
+ *
813
+ * ```ts import.meta.vitest
814
+ * import { Predicate } from "effect"
815
+ *
816
+ * const values = [1, null, 2]
817
+ * const nonNull = values.filter(Predicate.isNotNull) // => [1, 2]
818
+ * ```
819
+ *
820
+ * @see {@link isNull}
821
+ * @see {@link isNotNullish}
822
+ * @stability stable
823
+ * @category guards
824
+ * @since 2.0.0
825
+ */
826
+ function isNotNull(input) {
827
+ return input !== null;
828
+ }
829
+ /**
830
+ * Checks whether a value is `null` or `undefined`.
831
+ *
832
+ * **When to use**
833
+ *
834
+ * Use when you need a `Predicate` guard for nullish values.
835
+ *
836
+ * **Details**
837
+ *
838
+ * Uses `input === null || input === undefined`.
839
+ *
840
+ * **Example** (Guarding nullish values)
841
+ *
842
+ * ```ts import.meta.vitest
843
+ * import { Predicate } from "effect"
844
+ *
845
+ * const values = [0, null, "", undefined]
846
+ * const nullish = values.filter(Predicate.isNullish) // => [null, undefined]
847
+ * ```
848
+ *
849
+ * @see {@link isNotNullish}
850
+ * @see {@link isUndefined}
851
+ * @see {@link isNull}
852
+ * @stability stable
853
+ * @category guards
854
+ * @since 4.0.0
855
+ */
856
+ function isNullish(input) {
857
+ return input === null || input === void 0;
858
+ }
859
+ /**
860
+ * Checks whether a value is not `null` and not `undefined`.
861
+ *
862
+ * **When to use**
863
+ *
864
+ * Use when you need a `Predicate` refinement that filters out nullish values
865
+ * but keeps other falsy ones.
866
+ *
867
+ * **Details**
868
+ *
869
+ * Uses `input != null`.
870
+ *
871
+ * **Example** (Filtering non-nullish values)
872
+ *
873
+ * ```ts import.meta.vitest
874
+ * import { Predicate } from "effect"
875
+ *
876
+ * const values = [0, null, "", undefined]
877
+ * const present = values.filter(Predicate.isNotNullish) // => [0, ""]
878
+ * ```
879
+ *
880
+ * @see {@link isNullish}
881
+ * @see {@link isNotNull}
882
+ * @see {@link isNotUndefined}
883
+ * @stability stable
884
+ * @category guards
885
+ * @since 4.0.0
886
+ */
887
+ function isNotNullish(input) {
888
+ return input != null;
889
+ }
890
+ /**
891
+ * Type guard that always returns `false`.
892
+ *
893
+ * **When to use**
894
+ *
895
+ * Use when you need a `Predicate` that never accepts, e.g. in default branches.
896
+ *
897
+ * **Example** (Matching no values)
898
+ *
899
+ * ```ts import.meta.vitest
900
+ * import { Predicate } from "effect"
901
+ *
902
+ * Predicate.isNever("anything") // => false
903
+ * ```
904
+ *
905
+ * @see {@link isUnknown}
906
+ * @stability stable
907
+ * @category guards
908
+ * @since 2.0.0
909
+ */
910
+ function isNever(_) {
911
+ return false;
912
+ }
913
+ /**
914
+ * Type guard that always returns `true`.
915
+ *
916
+ * **When to use**
917
+ *
918
+ * Use when you need a `Predicate` that always accepts, e.g. as a placeholder.
919
+ *
920
+ * **Example** (Matching every value)
921
+ *
922
+ * ```ts import.meta.vitest
923
+ * import { Predicate } from "effect"
924
+ *
925
+ * Predicate.isUnknown(123) // => true
926
+ * ```
927
+ *
928
+ * @see {@link isNever}
929
+ * @stability stable
930
+ * @category guards
931
+ * @since 2.0.0
932
+ */
933
+ function isUnknown(_) {
934
+ return true;
935
+ }
936
+ /**
937
+ * Checks whether a value is a non-null object value that is not an array.
938
+ *
939
+ * **When to use**
940
+ *
941
+ * Use to narrow unknown input to a non-null, non-array object with a
942
+ * `Predicate` guard.
943
+ *
944
+ * **Details**
945
+ *
946
+ * This is a structural runtime check using `typeof input === "object"`, so it
947
+ * also accepts object instances such as `Date`, `Map`, class instances, and
948
+ * typed arrays. It excludes `null` and arrays.
949
+ *
950
+ * **Example** (Guarding objects)
951
+ *
952
+ * ```ts import.meta.vitest
953
+ * import { Predicate } from "effect"
954
+ *
955
+ * Predicate.isObject({ a: 1 }) // => true
956
+ * Predicate.isObject([1, 2]) // => false
957
+ * ```
958
+ *
959
+ * @see {@link isObjectOrArray}
960
+ * @see {@link isReadonlyObject}
961
+ * @stability stable
962
+ * @category guards
963
+ * @since 2.0.0
964
+ */
965
+ function isObject(input) {
966
+ return typeof input === "object" && input !== null && !Array.isArray(input);
967
+ }
968
+ /**
969
+ * Checks whether a value is an `object` in the JavaScript sense (objects, arrays, functions).
970
+ *
971
+ * **When to use**
972
+ *
973
+ * Use when you need a `Predicate` guard that accepts arrays and functions as
974
+ * well as objects.
975
+ *
976
+ * **Details**
977
+ *
978
+ * Returns `true` for arrays and functions, and `false` for `null`.
979
+ *
980
+ * **Example** (Checking object keywords)
981
+ *
982
+ * ```ts import.meta.vitest
983
+ * import { Predicate } from "effect"
984
+ *
985
+ * Predicate.isObjectKeyword(() => 1) // => true
986
+ * Predicate.isObjectKeyword(null) // => false
987
+ * ```
988
+ *
989
+ * @see {@link isObject}
990
+ * @see {@link isObjectOrArray}
991
+ * @stability stable
992
+ * @category guards
993
+ * @since 4.0.0
994
+ */
995
+ function isObjectKeyword(input) {
996
+ return typeof input === "object" && input !== null || isFunction(input);
997
+ }
998
+ /**
999
+ * Checks whether a value has a given property key.
1000
+ *
1001
+ * **When to use**
1002
+ *
1003
+ * Use when you need a `Predicate` guard for property access on `unknown`
1004
+ * values with a simple structural object check.
1005
+ *
1006
+ * **Details**
1007
+ *
1008
+ * Uses the `in` operator and `isObjectKeyword`. This does not check property
1009
+ * value types.
1010
+ *
1011
+ * **Example** (Guarding object properties)
1012
+ *
1013
+ * ```ts import.meta.vitest
1014
+ * import { Predicate } from "effect"
1015
+ *
1016
+ * const hasName = Predicate.hasProperty("name")
1017
+ * const data: unknown = { name: "Ada" }
1018
+ *
1019
+ * if (hasName(data)) {
1020
+ * data.name // => "Ada"
1021
+ * }
1022
+ * ```
1023
+ *
1024
+ * @see {@link isTagged}
1025
+ * @see {@link isObjectKeyword}
1026
+ * @stability stable
1027
+ * @category guards
1028
+ * @since 2.0.0
1029
+ */
1030
+ const hasProperty = /*#__PURE__*/ dual(2, (self, property) => isObjectKeyword(self) && property in self);
1031
+ /**
1032
+ * Checks whether a value has a `_tag` property equal to the given tag.
1033
+ *
1034
+ * **When to use**
1035
+ *
1036
+ * Use when you model tagged unions with a `_tag` field and want a quick
1037
+ * `Predicate` guard for tagged values.
1038
+ *
1039
+ * **Details**
1040
+ *
1041
+ * Uses `hasProperty` and strict equality on `_tag`.
1042
+ *
1043
+ * **Example** (Guarding tagged values)
1044
+ *
1045
+ * ```ts import.meta.vitest
1046
+ * import { Predicate } from "effect"
1047
+ *
1048
+ * const isOk = Predicate.isTagged("Ok")
1049
+ *
1050
+ * isOk({ _tag: "Ok", value: 1 }) // => true
1051
+ * ```
1052
+ *
1053
+ * @see {@link hasProperty}
1054
+ * @stability stable
1055
+ * @category guards
1056
+ * @since 2.0.0
1057
+ */
1058
+ const isTagged = /*#__PURE__*/ dual(2, (self, tag) => hasProperty(self, "_tag") && self["_tag"] === tag);
1059
+ /**
1060
+ * Checks whether a value is an `Error`.
1061
+ *
1062
+ * **When to use**
1063
+ *
1064
+ * Use when you need a `Predicate` guard for errors caught from unknown sources.
1065
+ *
1066
+ * **Details**
1067
+ *
1068
+ * Uses `instanceof Error`.
1069
+ *
1070
+ * **Example** (Guarding errors)
1071
+ *
1072
+ * ```ts import.meta.vitest
1073
+ * import { Predicate } from "effect"
1074
+ *
1075
+ * const data: unknown = new Error("boom")
1076
+ *
1077
+ * Predicate.isError(data) // => true
1078
+ * ```
1079
+ *
1080
+ * @see {@link isUnknown}
1081
+ * @stability stable
1082
+ * @category guards
1083
+ * @since 2.0.0
1084
+ */
1085
+ function isError(input) {
1086
+ return input instanceof Error;
1087
+ }
1088
+ /**
1089
+ * Checks whether a value is iterable.
1090
+ *
1091
+ * **When to use**
1092
+ *
1093
+ * Use when you need a `Predicate` guard before iterating an unknown value.
1094
+ *
1095
+ * **Details**
1096
+ *
1097
+ * Accepts strings as iterable and uses `hasProperty` for `Symbol.iterator`.
1098
+ *
1099
+ * **Example** (Guarding iterables)
1100
+ *
1101
+ * ```ts import.meta.vitest
1102
+ * import { Predicate } from "effect"
1103
+ *
1104
+ * const data: unknown = [1, 2, 3]
1105
+ *
1106
+ * Predicate.isIterable(data) // => true
1107
+ * ```
1108
+ *
1109
+ * @see {@link isSet}
1110
+ * @see {@link isMap}
1111
+ * @stability stable
1112
+ * @category guards
1113
+ * @since 2.0.0
1114
+ */
1115
+ function isIterable(input) {
1116
+ return hasProperty(input, Symbol.iterator) || isString(input);
1117
+ }
1118
+ /**
1119
+ * Creates a predicate that returns `true` if either predicate is `true`.
1120
+ *
1121
+ * **When to use**
1122
+ *
1123
+ * Use when you want to combine `Predicate`s with OR, accepting values that
1124
+ * satisfy at least one condition, including refinements that narrow to a union.
1125
+ *
1126
+ * **Details**
1127
+ *
1128
+ * Evaluation short-circuits on the first `true`. For refinements, the output
1129
+ * type is a union.
1130
+ *
1131
+ * **Example** (Checking either condition)
1132
+ *
1133
+ * ```ts import.meta.vitest
1134
+ * import { Predicate } from "effect"
1135
+ *
1136
+ * const isStringOrNumber = Predicate.or(Predicate.isString, Predicate.isNumber)
1137
+ *
1138
+ * isStringOrNumber("a") // => true
1139
+ * ```
1140
+ *
1141
+ * @see {@link and}
1142
+ * @see {@link xor}
1143
+ * @stability stable
1144
+ * @category combinators
1145
+ * @since 2.0.0
1146
+ */
1147
+ const or = /*#__PURE__*/ dual(2, (self, that) => (a) => self(a) || that(a));
1148
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/Hash.js
1149
+ /**
1150
+ * Computes Effect hash values and defines the interface for objects that want
1151
+ * to provide their own hash implementation. Hashes are small numeric
1152
+ * fingerprints used by Effect data structures to bucket values quickly; they
1153
+ * are not cryptographic digests and they are not proof that two values are
1154
+ * equal. The module also includes helpers for primitive, structure, array, and
1155
+ * reference-based hashes, plus functions for combining and optimizing numeric
1156
+ * hash values.
1157
+ *
1158
+ * @stability stable
1159
+ * @since 2.0.0
1160
+ */
1161
+ /**
1162
+ * Defines the unique identifier used to identify objects that implement the Hash interface.
1163
+ *
1164
+ * **When to use**
1165
+ *
1166
+ * Use as the computed property key for the method that supplies a custom hash
1167
+ * value on a `Hash` implementor.
1168
+ *
1169
+ * @see {@link Hash} for the interface implemented with this symbol
1170
+ * @see {@link isHash} for checking whether a value implements `Hash`
1171
+ * @see {@link hash} for computing hash values
1172
+ *
1173
+ * @stability stable
1174
+ * @category symbols
1175
+ * @since 2.0.0
1176
+ */
1177
+ const symbol$1 = "~effect/Hash";
1178
+ /**
1179
+ * Computes a hash value for any given value.
1180
+ *
1181
+ * **When to use**
1182
+ *
1183
+ * Use to compute an Effect hash for primitives, collections, and hashable
1184
+ * objects.
1185
+ *
1186
+ * **Details**
1187
+ *
1188
+ * This function can hash primitives (numbers, strings, booleans, etc.) as well as
1189
+ * objects, arrays, and other complex data structures. It automatically handles
1190
+ * different types and provides a consistent hash value for equivalent inputs.
1191
+ *
1192
+ * **Gotchas**
1193
+ *
1194
+ * Objects being hashed must be treated as immutable after their first hash
1195
+ * computation. Hash results are cached, so mutating an object after hashing will
1196
+ * lead to stale cached values and broken hash-based operations. For mutable
1197
+ * objects, implement a custom `Hash` interface that hashes the object reference
1198
+ * rather than its content.
1199
+ *
1200
+ * **Example** (Hashing different values)
1201
+ *
1202
+ * ```ts import.meta.vitest
1203
+ * import { Hash } from "effect"
1204
+ *
1205
+ * Hash.hash(42) === Hash.hash(42) // => true
1206
+ * Hash.hash("hello") === Hash.hash("hello") // => true
1207
+ * Hash.hash([1, 2, 3]) === Hash.hash([1, 2, 3]) // => true
1208
+ * ```
1209
+ *
1210
+ * @stability stable
1211
+ * @category hashing
1212
+ * @since 2.0.0
1213
+ */
1214
+ const hash = (self) => {
1215
+ switch (typeof self) {
1216
+ case "number": return number(self);
1217
+ case "bigint": return string(self.toString(10));
1218
+ case "string": return string(self);
1219
+ case "function":
1220
+ case "object": if (self === null) break;
1221
+ else if (self instanceof Date) {
1222
+ if (Number.isNaN(self.getTime())) return string("Invalid Date");
1223
+ return string(self.toISOString());
1224
+ } else if (self instanceof RegExp) return string(self.toString());
1225
+ else {
1226
+ if (byReferenceInstances.has(self)) return random(self);
1227
+ const cached = hashCache.get(self);
1228
+ if (cached !== void 0) return cached;
1229
+ if (visitedObjects.has(self)) {
1230
+ addBackEdge();
1231
+ return string("[Circular]");
1232
+ }
1233
+ visitedObjects.add(self);
1234
+ const seen = backEdges;
1235
+ let h;
1236
+ try {
1237
+ if (isHash(self)) h = self[symbol$1]();
1238
+ else if (typeof self === "function") h = random(self);
1239
+ else if (isArrayBufferLike(self)) {
1240
+ const bytes = bufferBytes(self);
1241
+ h = bytes === void 0 ? random(self) : array(bytes);
1242
+ } else if (self instanceof DataView) h = array(viewBytes(self));
1243
+ else if (Array.isArray(self) || ArrayBuffer.isView(self)) h = array(self);
1244
+ else if (self instanceof Map) h = hashMap(self);
1245
+ else if (self instanceof Set) h = hashSet(self);
1246
+ else h = structure(self);
1247
+ } finally {
1248
+ visitedObjects.delete(self);
1249
+ }
1250
+ if (seen === backEdges) hashCache.set(self, h);
1251
+ return h;
1252
+ }
1253
+ }
1254
+ return optimize(mix(string(String(self))));
1255
+ };
1256
+ /**
1257
+ * Generates a random hash value for an object and caches it.
1258
+ *
1259
+ * **When to use**
1260
+ *
1261
+ * Use to hash an object by reference identity instead of structural content.
1262
+ *
1263
+ * **Details**
1264
+ *
1265
+ * This function creates a random hash value for objects that don't have their own
1266
+ * hash implementation. The hash value is cached using a WeakMap, so the same object
1267
+ * will always return the same hash value during its lifetime.
1268
+ *
1269
+ * **Example** (Hashing objects by reference)
1270
+ *
1271
+ * ```ts import.meta.vitest
1272
+ * import { Hash } from "effect"
1273
+ *
1274
+ * const obj1 = { a: 1 }
1275
+ * const obj2 = { a: 1 }
1276
+ *
1277
+ * Hash.random(obj1) === Hash.random(obj1) // => true
1278
+ *
1279
+ * typeof Hash.random(obj2) // => "number"
1280
+ * ```
1281
+ *
1282
+ * @stability stable
1283
+ * @category hashing
1284
+ * @since 2.0.0
1285
+ */
1286
+ const random = (self) => {
1287
+ if (!randomHashCache.has(self)) randomHashCache.set(self, optimize(Math.random() * 4294967296 | 0));
1288
+ return randomHashCache.get(self);
1289
+ };
1290
+ const mix = (h) => {
1291
+ h ^= h >>> 16;
1292
+ h = Math.imul(h, 2246822507);
1293
+ h ^= h >>> 13;
1294
+ h = Math.imul(h, 3266489909);
1295
+ return h ^ h >>> 16;
1296
+ };
1297
+ /**
1298
+ * Combines two hash values into a single hash value.
1299
+ *
1300
+ * **When to use**
1301
+ *
1302
+ * Use to build a hash for a composite value by folding together hash values for
1303
+ * its parts.
1304
+ *
1305
+ * **Details**
1306
+ *
1307
+ * Supports direct and pipeable usage. Argument order affects the result.
1308
+ *
1309
+ * **Example** (Combining hash values)
1310
+ *
1311
+ * ```ts import.meta.vitest
1312
+ * import { Hash, pipe } from "effect"
1313
+ *
1314
+ * const hash1 = Hash.hash("hello")
1315
+ * const hash2 = Hash.hash("world")
1316
+ *
1317
+ * const combined = Hash.combine(hash2)(hash1)
1318
+ * combined === pipe(hash1, Hash.combine(hash2)) // => true
1319
+ * ```
1320
+ *
1321
+ * @see {@link hash} for computing hash values from arbitrary inputs
1322
+ * @see {@link structureKeys} for hashing selected object fields without manual combination
1323
+ *
1324
+ * @stability stable
1325
+ * @category hashing
1326
+ * @since 2.0.0
1327
+ */
1328
+ const combine = /*#__PURE__*/ dual(2, (self, b) => mix(Math.imul(self, 2654435761) + Math.imul(b, 2246822507)));
1329
+ /**
1330
+ * Applies bit manipulation techniques to optimize a hash value.
1331
+ *
1332
+ * **When to use**
1333
+ *
1334
+ * Use to improve the bit distribution of a raw numeric hash value.
1335
+ *
1336
+ * **Details**
1337
+ *
1338
+ * This function takes a hash value and applies bitwise operations to improve
1339
+ * the distribution of hash values, reducing the likelihood of collisions.
1340
+ *
1341
+ * **Example** (Optimizing a hash value)
1342
+ *
1343
+ * ```ts import.meta.vitest
1344
+ * import { Hash } from "effect"
1345
+ *
1346
+ * Hash.optimize(1234567890) // => 160826066
1347
+ * ```
1348
+ *
1349
+ * @stability stable
1350
+ * @category hashing
1351
+ * @since 2.0.0
1352
+ */
1353
+ const optimize = (n) => n & 3221225471 | n >>> 1 & 1073741824;
1354
+ /**
1355
+ * Checks whether a value implements the Hash interface.
1356
+ *
1357
+ * **When to use**
1358
+ *
1359
+ * Use to detect whether an unknown value provides a custom hash implementation.
1360
+ *
1361
+ * **Details**
1362
+ *
1363
+ * This function determines whether a given value has a function under the Hash
1364
+ * symbol, indicating that it can provide its own hash value implementation.
1365
+ * Data that merely carries the key, such as parsed JSON, is hashed as data.
1366
+ *
1367
+ * **Example** (Checking for Hash support)
1368
+ *
1369
+ * ```ts import.meta.vitest
1370
+ * import { Hash } from "effect"
1371
+ *
1372
+ * class MyHashable implements Hash.Hash {
1373
+ * [Hash.symbol]() {
1374
+ * return 42
1375
+ * }
1376
+ * }
1377
+ *
1378
+ * Hash.isHash(new MyHashable()) // => true
1379
+ * Hash.isHash({}) // => false
1380
+ * Hash.isHash("string") // => false
1381
+ * ```
1382
+ *
1383
+ * @stability stable
1384
+ * @category guards
1385
+ * @since 2.0.0
1386
+ */
1387
+ const isHash = (u) => hasProperty(u, "~effect/Hash") && typeof u["~effect/Hash"] === "function";
1388
+ const float64 = /*#__PURE__*/ new DataView(/*#__PURE__*/ new ArrayBuffer(8));
1389
+ /**
1390
+ * Computes a hash value for a number.
1391
+ *
1392
+ * **When to use**
1393
+ *
1394
+ * Use to hash a JavaScript number with Effect's numeric hash semantics.
1395
+ *
1396
+ * **Details**
1397
+ *
1398
+ * Int32 values hash to themselves. Other numbers hash from their IEEE-754 bits,
1399
+ * with a canonical representation for `NaN`.
1400
+ *
1401
+ * **Example** (Hashing numbers)
1402
+ *
1403
+ * ```ts import.meta.vitest
1404
+ * import { Hash } from "effect"
1405
+ *
1406
+ * Number.isInteger(Hash.number(42)) // => true
1407
+ * Number.isInteger(Hash.number(3.14)) // => true
1408
+ * Hash.number(NaN) === Hash.number(NaN) // => true
1409
+ * Hash.number(Infinity) === Hash.number(Infinity) // => true
1410
+ * Hash.number(100) === Hash.number(100) // => true
1411
+ * ```
1412
+ *
1413
+ * @stability stable
1414
+ * @category hashing
1415
+ * @since 2.0.0
1416
+ */
1417
+ const number = (n) => {
1418
+ const h = n | 0;
1419
+ if (h === n) return optimize(h);
1420
+ float64.setFloat64(0, n !== n ? NaN : n);
1421
+ return optimize(combine(float64.getInt32(0), float64.getInt32(4)));
1422
+ };
1423
+ /**
1424
+ * Computes a hash value for a string using the djb2 algorithm.
1425
+ *
1426
+ * **When to use**
1427
+ *
1428
+ * Use when you need a string field to contribute to a custom structural hash
1429
+ * implementation.
1430
+ *
1431
+ * **Details**
1432
+ *
1433
+ * This function implements a variation of the djb2 hash algorithm, which is
1434
+ * known for its good distribution properties and speed. It processes each
1435
+ * character of the string to produce a consistent hash value.
1436
+ *
1437
+ * **Example** (Hashing strings)
1438
+ *
1439
+ * ```ts import.meta.vitest
1440
+ * import { Hash } from "effect"
1441
+ *
1442
+ * Hash.string("hello") // => 181380007
1443
+ * Hash.string("world") // => 164394279
1444
+ * Hash.string("") // => 5381
1445
+ * Hash.string("test") === Hash.string("test") // => true
1446
+ * ```
1447
+ *
1448
+ * @stability stable
1449
+ * @category hashing
1450
+ * @since 2.0.0
1451
+ */
1452
+ const string = (str) => {
1453
+ let h = 5381, i = str.length;
1454
+ while (i) h = h * 33 ^ str.charCodeAt(--i);
1455
+ return optimize(h);
1456
+ };
1457
+ /**
1458
+ * Computes a hash value for an object using only the specified keys.
1459
+ *
1460
+ * **When to use**
1461
+ *
1462
+ * Use to hash an object by a selected set of property keys.
1463
+ *
1464
+ * **Details**
1465
+ *
1466
+ * This function allows you to hash an object by considering only specific keys,
1467
+ * which is useful when you want to create a hash based on a subset of an object's
1468
+ * properties.
1469
+ *
1470
+ * **Example** (Hashing selected object keys)
1471
+ *
1472
+ * ```ts import.meta.vitest
1473
+ * import { Hash } from "effect"
1474
+ *
1475
+ * const person = { name: "John", age: 30, city: "New York" }
1476
+ *
1477
+ * const hash1 = Hash.structureKeys(person, ["name", "age"])
1478
+ * const hash2 = Hash.structureKeys(person, ["name", "city"])
1479
+ *
1480
+ * hash1 // => -731887653
1481
+ * hash2 // => 148523102
1482
+ *
1483
+ * const person2 = { name: "John", age: 30, city: "Boston" }
1484
+ * const hash3 = Hash.structureKeys(person2, ["name", "age"])
1485
+ * hash1 === hash3 // => true
1486
+ * ```
1487
+ *
1488
+ * @stability stable
1489
+ * @category hashing
1490
+ * @since 2.0.0
1491
+ */
1492
+ const structureKeys = (o, keys) => {
1493
+ let h = 12289;
1494
+ for (const key of keys) h ^= combine(hash(key), hash(o[key]));
1495
+ return optimize(h);
1496
+ };
1497
+ /**
1498
+ * Computes a structural hash for an object using Effect's object key collection.
1499
+ *
1500
+ * **When to use**
1501
+ *
1502
+ * Use to hash an object from all structural keys collected by Effect.
1503
+ *
1504
+ * **Details**
1505
+ *
1506
+ * The hash is based on the object's structural keys and their values, including
1507
+ * symbol keys and relevant prototype keys for non-plain objects.
1508
+ *
1509
+ * **Example** (Hashing object structures)
1510
+ *
1511
+ * ```ts import.meta.vitest
1512
+ * import { Hash } from "effect"
1513
+ *
1514
+ * const obj1 = { name: "John", age: 30 }
1515
+ * const obj2 = { name: "Jane", age: 25 }
1516
+ * const obj3 = { name: "John", age: 30 }
1517
+ *
1518
+ * Hash.structure(obj1) // => -731887653
1519
+ * Hash.structure(obj2) // => -222100417
1520
+ * Hash.structure(obj3) // => -731887653
1521
+ * Hash.structure(obj1) === Hash.structure(obj3) // => true
1522
+ * ```
1523
+ *
1524
+ * @stability stable
1525
+ * @category hashing
1526
+ * @since 2.0.0
1527
+ */
1528
+ const structure = (o) => structureKeys(o, getAllObjectKeys(o));
1529
+ const unordered = (seed, f) => (iter) => {
1530
+ let h = seed;
1531
+ for (const element of iter) h ^= f(element);
1532
+ return optimize(h);
1533
+ };
1534
+ /**
1535
+ * Computes a hash value for an iterable by hashing all of its elements.
1536
+ *
1537
+ * **When to use**
1538
+ *
1539
+ * Use to hash the values yielded by an iterable with Effect hash semantics.
1540
+ *
1541
+ * **Details**
1542
+ *
1543
+ * Folds element hashes with {@link combine}, so order and length affect the
1544
+ * result.
1545
+ *
1546
+ * **Gotchas**
1547
+ *
1548
+ * A hash is not an equality proof. Distinct inputs can still share a hash.
1549
+ *
1550
+ * **Example** (Hashing arrays)
1551
+ *
1552
+ * ```ts import.meta.vitest
1553
+ * import { Hash } from "effect"
1554
+ *
1555
+ * const arr1 = [1, 2, 3]
1556
+ * const arr2 = [1, 2, 3]
1557
+ * const arr3 = [3, 2, 1]
1558
+ *
1559
+ * Hash.array(arr1) === Hash.array(arr2) // => true
1560
+ * Hash.array(arr1) === Hash.array(arr3) // => false
1561
+ * ```
1562
+ *
1563
+ * @see {@link hash} for the general-purpose hash dispatcher
1564
+ *
1565
+ * @stability stable
1566
+ * @category hashing
1567
+ * @since 2.0.0
1568
+ */
1569
+ const array = (arr) => {
1570
+ let h = 6151;
1571
+ for (const element of arr) h = combine(h, hash(element));
1572
+ return optimize(h);
1573
+ };
1574
+ const hashMap = /*#__PURE__*/ unordered(/*#__PURE__*/ string("Map"), ([k, v]) => combine(hash(k), hash(v)));
1575
+ const setSeed = /*#__PURE__*/ string("Set");
1576
+ const hashSet = /*#__PURE__*/ unordered(setSeed, (element) => combine(setSeed, hash(element)));
1577
+ const randomHashCache = /*#__PURE__*/ new WeakMap();
1578
+ const hashCache = /*#__PURE__*/ new WeakMap();
1579
+ const visitedObjects = /*#__PURE__*/ new WeakSet();
1580
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/Equal.js
1581
+ /**
1582
+ * Defines the unique string identifier for the `Equal` interface.
1583
+ *
1584
+ * **When to use**
1585
+ *
1586
+ * Use when you implement custom equality and need the computed property key for
1587
+ * the equality method.
1588
+ *
1589
+ * **Details**
1590
+ *
1591
+ * This is a pure constant with no allocation or side effects.
1592
+ *
1593
+ * **Example** (Implementing Equal on a class)
1594
+ *
1595
+ * ```ts import.meta.vitest
1596
+ * import { Equal, Hash } from "effect"
1597
+ *
1598
+ * class UserId implements Equal.Equal {
1599
+ * constructor(readonly id: string) {}
1600
+ *
1601
+ * [Equal.symbol](that: Equal.Equal): boolean {
1602
+ * return that instanceof UserId && this.id === that.id
1603
+ * }
1604
+ *
1605
+ * [Hash.symbol](): number {
1606
+ * return Hash.string(this.id)
1607
+ * }
1608
+ * }
1609
+ *
1610
+ * Equal.equals(new UserId("1"), new UserId("1")) // => true
1611
+ * Equal.equals(new UserId("1"), new UserId("2")) // => false
1612
+ * ```
1613
+ *
1614
+ * @see {@link Equal} — the interface that uses this symbol
1615
+ * @see {@link isEqual} — type guard for `Equal` implementors
1616
+ * @stability stable
1617
+ * @category symbols
1618
+ * @since 2.0.0
1619
+ */
1620
+ const symbol = "~effect/Equal";
1621
+ function equals() {
1622
+ if (arguments.length === 1) return (self) => compareBoth(self, arguments[0]);
1623
+ return compareBoth(arguments[0], arguments[1]);
1624
+ }
1625
+ function compareBoth(self, that) {
1626
+ if (self === that) return true;
1627
+ if (self == null || that == null) return false;
1628
+ const selfType = typeof self;
1629
+ if (selfType !== typeof that) return false;
1630
+ if (selfType === "number" && self !== self && that !== that) return true;
1631
+ if (selfType !== "object" && selfType !== "function") return false;
1632
+ if (byReferenceInstances.has(self) || byReferenceInstances.has(that)) return false;
1633
+ return compareObjects(self, that);
1634
+ }
1635
+ function compareObjects(self, that) {
1636
+ const depth = pathLeft.length;
1637
+ for (let i = depth; i-- > 0;) if (pathLeft[i] === self && pathRight[i] === that) return true;
1638
+ if (depth) return compareOnPath(self, that);
1639
+ let known = results.get(self);
1640
+ if (!known) results.set(self, known = /* @__PURE__ */ new WeakMap());
1641
+ let result = known.get(that);
1642
+ if (result === void 0) known.set(that, result = compareOnPath(self, that));
1643
+ return result;
1644
+ }
1645
+ function compareOnPath(self, that) {
1646
+ pathLeft.push(self);
1647
+ pathRight.push(that);
1648
+ try {
1649
+ return compareStructure(self, that);
1650
+ } finally {
1651
+ pathLeft.pop();
1652
+ pathRight.pop();
1653
+ }
1654
+ }
1655
+ const pathLeft = [];
1656
+ const pathRight = [];
1657
+ const results = /*#__PURE__*/ new WeakMap();
1658
+ function compareStructure(self, that) {
1659
+ if (hash(self) !== hash(that)) return false;
1660
+ else if (self instanceof Date) {
1661
+ if (!(that instanceof Date)) return false;
1662
+ const selfTime = self.getTime();
1663
+ const thatTime = that.getTime();
1664
+ return selfTime === thatTime || Number.isNaN(selfTime) && Number.isNaN(thatTime);
1665
+ } else if (self instanceof RegExp) return that instanceof RegExp && self.toString() === that.toString();
1666
+ const bothEquals = isEqual(self);
1667
+ if (bothEquals !== isEqual(that) || typeof self === "function" && !bothEquals) return false;
1668
+ else if (bothEquals) return self[symbol](that);
1669
+ else if (Array.isArray(self)) {
1670
+ if (!Array.isArray(that) || self.length !== that.length) return false;
1671
+ return compareArrays(self, that);
1672
+ } else if (isArrayBufferLike(self)) {
1673
+ if (!isArrayBufferLike(that) || self instanceof ArrayBuffer !== that instanceof ArrayBuffer) return false;
1674
+ const selfBytes = bufferBytes(self);
1675
+ const thatBytes = bufferBytes(that);
1676
+ return selfBytes !== void 0 && thatBytes !== void 0 && compareTypedArrays(selfBytes, thatBytes);
1677
+ } else if (ArrayBuffer.isView(self)) {
1678
+ const selfIsDataView = self instanceof DataView;
1679
+ if (!ArrayBuffer.isView(that) || self.byteLength !== that.byteLength || selfIsDataView !== that instanceof DataView) return false;
1680
+ if (selfIsDataView) return compareTypedArrays(viewBytes(self), viewBytes(that));
1681
+ return compareTypedArrays(self, that);
1682
+ } else if (self instanceof Map) {
1683
+ if (!(that instanceof Map) || self.size !== that.size) return false;
1684
+ return compareHashed(self, that, entryHash, equalEntries);
1685
+ } else if (self instanceof Set) {
1686
+ if (!(that instanceof Set) || self.size !== that.size) return false;
1687
+ return compareHashed(self, that, hash, compareBoth);
1688
+ }
1689
+ return compareRecords(self, that);
1690
+ }
1691
+ function compareArrays(self, that) {
1692
+ for (let i = 0; i < self.length; i++) if (!compareBoth(self[i], that[i])) return false;
1693
+ return true;
1694
+ }
1695
+ function compareTypedArrays(self, that) {
1696
+ if (self.length !== that.length) return false;
1697
+ for (let i = 0; i < self.length; i++) if (self[i] !== that[i]) return false;
1698
+ return true;
1699
+ }
1700
+ function compareRecords(self, that) {
1701
+ const selfKeys = getAllObjectKeys(self);
1702
+ const thatKeys = getAllObjectKeys(that);
1703
+ if (selfKeys.size !== thatKeys.size) return false;
1704
+ for (const key of selfKeys) if (!thatKeys.has(key) || !compareBoth(self[key], that[key])) return false;
1705
+ return true;
1706
+ }
1707
+ function compareHashed(self, that, hashOf, equivalent) {
1708
+ const groups = /* @__PURE__ */ new Map();
1709
+ let remaining = 0;
1710
+ for (const item of that) {
1711
+ const h = hashOf(item);
1712
+ const group = groups.get(h);
1713
+ if (group) group.push(item);
1714
+ else groups.set(h, [item]);
1715
+ remaining++;
1716
+ }
1717
+ outer: for (const item of self) {
1718
+ const group = groups.get(hashOf(item));
1719
+ if (group) {
1720
+ for (let i = 0; i < group.length; i++) if (equivalent(item, group[i])) {
1721
+ group[i] = group[group.length - 1];
1722
+ group.pop();
1723
+ remaining--;
1724
+ continue outer;
1725
+ }
1726
+ }
1727
+ return false;
1728
+ }
1729
+ return remaining === 0;
1730
+ }
1731
+ const entryHash = (entry) => hash(entry[0]);
1732
+ const equalEntries = (self, that) => compareBoth(self[0], that[0]) && compareBoth(self[1], that[1]);
1733
+ /**
1734
+ * Checks whether a value implements the {@link Equal} interface.
1735
+ *
1736
+ * **When to use**
1737
+ *
1738
+ * Use when you need generic utility code to distinguish `Equal` implementors
1739
+ * from plain values before calling `[Equal.symbol]` directly.
1740
+ *
1741
+ * **Details**
1742
+ *
1743
+ * - Pure function, no side effects.
1744
+ * - Returns `true` if and only if `u` has a function keyed by {@link symbol}.
1745
+ * Data that merely carries the key, such as parsed JSON, is not `Equal`.
1746
+ * - Acts as a TypeScript type guard, narrowing the input to {@link Equal}.
1747
+ *
1748
+ * **Example** (Checking Equal values)
1749
+ *
1750
+ * ```ts import.meta.vitest
1751
+ * import { Equal, Hash } from "effect"
1752
+ *
1753
+ * class Token implements Equal.Equal {
1754
+ * constructor(readonly value: string) {}
1755
+ * [Equal.symbol](that: Equal.Equal): boolean {
1756
+ * return that instanceof Token && this.value === that.value
1757
+ * }
1758
+ * [Hash.symbol](): number {
1759
+ * return Hash.string(this.value)
1760
+ * }
1761
+ * }
1762
+ *
1763
+ * Equal.isEqual(new Token("abc")) // => true
1764
+ * Equal.isEqual({ x: 1 }) // => false
1765
+ * Equal.isEqual(42) // => false
1766
+ * ```
1767
+ *
1768
+ * @see {@link Equal} — the interface being checked
1769
+ * @see {@link symbol} — the property key that signals `Equal` support
1770
+ * @stability stable
1771
+ * @category guards
1772
+ * @since 2.0.0
1773
+ */
1774
+ const isEqual = (u) => hasProperty(u, "~effect/Equal") && typeof u["~effect/Equal"] === "function";
1775
+ /**
1776
+ * Wraps {@link equals} as an `Equivalence<A>`.
1777
+ *
1778
+ * **When to use**
1779
+ *
1780
+ * Use when you want to pass `Equal.equals` to APIs that require an
1781
+ * `Equivalence`.
1782
+ *
1783
+ * **Details**
1784
+ *
1785
+ * - Returns a function `(a: A, b: A) => boolean` that delegates to
1786
+ * {@link equals}.
1787
+ * - Pure; allocates a thin wrapper on each call.
1788
+ *
1789
+ * **Example** (Deduplicating with Equal semantics)
1790
+ *
1791
+ * ```ts import.meta.vitest
1792
+ * import { Array, Equal } from "effect"
1793
+ *
1794
+ * Array.dedupeWith([1, 2, 2, 3, 1], Equal.asEquivalence<number>()) // => [1, 2, 3]
1795
+ * ```
1796
+ *
1797
+ * @see {@link equals} — the underlying comparison function
1798
+ * @stability stable
1799
+ * @category instances
1800
+ * @since 4.0.0
1801
+ */
1802
+ const asEquivalence = () => equals;
1803
+ /**
1804
+ * Marks an object permanently to use reference equality, without creating a proxy.
1805
+ *
1806
+ * **When to use**
1807
+ *
1808
+ * Use when you need reference equality without proxy allocation and accept
1809
+ * permanently marking the original object for reference-only equality.
1810
+ *
1811
+ * **Details**
1812
+ *
1813
+ * - Adds `obj` to an internal WeakSet. From that point on, {@link equals}
1814
+ * treats it as reference-only.
1815
+ * - Returns the **same** object (not a copy or proxy), so
1816
+ * `byReferenceUnsafe(x) === x`.
1817
+ * - Does **not** affect the object's prototype, properties, or behavior
1818
+ * beyond equality checks.
1819
+ *
1820
+ * **Gotchas**
1821
+ *
1822
+ * The marking is irreversible for the lifetime of the object.
1823
+ *
1824
+ * **Example** (Marking an object for reference equality)
1825
+ *
1826
+ * ```ts import.meta.vitest
1827
+ * import { Equal } from "effect"
1828
+ *
1829
+ * const obj1 = { a: 1, b: 2 }
1830
+ * const obj2 = { a: 1, b: 2 }
1831
+ *
1832
+ * const marked = Equal.byReferenceUnsafe(obj1)
1833
+ *
1834
+ * Equal.equals(obj1, obj2) // => false
1835
+ * Equal.equals(obj1, obj1) // => true
1836
+ * marked === obj1 // => true
1837
+ * ```
1838
+ *
1839
+ * @see {@link byReference} — safer alternative that creates a proxy
1840
+ * @see {@link equals} — the comparison function affected by this opt-out
1841
+ * @stability stable
1842
+ * @category unsafe
1843
+ * @since 4.0.0
1844
+ */
1845
+ const byReferenceUnsafe = (obj) => {
1846
+ byReferenceInstances.add(obj);
1847
+ return obj;
1848
+ };
1849
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/Redactable.js
1850
+ /**
1851
+ * Defines the symbol used to identify objects that implement the {@link Redactable}
1852
+ * protocol.
1853
+ *
1854
+ * **When to use**
1855
+ *
1856
+ * Use as the property key when implementing the `Redactable` protocol.
1857
+ *
1858
+ * **Details**
1859
+ *
1860
+ * Add a method under this key to make an object redactable. The method receives
1861
+ * the current `Context` and must return the replacement value. The symbol is
1862
+ * registered globally via `Symbol.for("~effect/Redactable")`, so it is
1863
+ * identical across multiple copies of the library at runtime.
1864
+ *
1865
+ * **Example** (Masking an API key)
1866
+ *
1867
+ * ```ts import.meta.vitest
1868
+ * import { Context, Redactable } from "effect"
1869
+ *
1870
+ * class ApiKey {
1871
+ * constructor(readonly raw: string) {}
1872
+ *
1873
+ * [Redactable.symbolRedactable](_ctx: Context.Context<never>) {
1874
+ * return this.raw.slice(0, 4) + "..."
1875
+ * }
1876
+ * }
1877
+ *
1878
+ * Redactable.redact(new ApiKey("secret-key")) // => "secr..."
1879
+ * ```
1880
+ *
1881
+ * @see {@link Redactable} for the interface this symbol belongs to
1882
+ * @see {@link isRedactable} to check whether a value has this symbol
1883
+ * @stability stable
1884
+ * @category symbols
1885
+ * @since 3.10.0
1886
+ */
1887
+ const symbolRedactable = /*#__PURE__*/ Symbol.for("~effect/Redactable");
1888
+ /**
1889
+ * Type guard that checks whether a value implements the {@link Redactable}
1890
+ * interface.
1891
+ *
1892
+ * **When to use**
1893
+ *
1894
+ * Use to narrow an unknown value before calling redaction-specific helpers.
1895
+ *
1896
+ * @see {@link Redactable} for the interface being checked
1897
+ * @see {@link redact} to apply redaction if the value is redactable
1898
+ * @stability stable
1899
+ * @category guards
1900
+ * @since 3.10.0
1901
+ */
1902
+ const isRedactable = (u) => hasProperty(u, symbolRedactable);
1903
+ /**
1904
+ * Returns a redacted value if it implements {@link Redactable}, otherwise returns it
1905
+ * unchanged.
1906
+ *
1907
+ * **When to use**
1908
+ *
1909
+ * Use as the general-purpose entry point for redaction when the input may
1910
+ * or may not implement the redaction protocol.
1911
+ *
1912
+ * **Details**
1913
+ *
1914
+ * This function calls {@link isRedactable} and, when it returns `true`,
1915
+ * delegates to {@link getRedacted}.
1916
+ *
1917
+ * **Gotchas**
1918
+ *
1919
+ * Redaction is not recursive. Nested redactable values inside the returned
1920
+ * object are not automatically redacted.
1921
+ *
1922
+ * @see {@link isRedactable} to check before redacting
1923
+ * @see {@link getRedacted} for the lower-level variant for known redactables
1924
+ * @stability stable
1925
+ * @category destructors
1926
+ * @since 3.10.0
1927
+ */
1928
+ function redact(u) {
1929
+ if (isRedactable(u)) return getRedacted(u);
1930
+ return u;
1931
+ }
1932
+ /**
1933
+ * Returns the result of calling `[symbolRedactable]` on a value that is
1934
+ * already known to be {@link Redactable}.
1935
+ *
1936
+ * **When to use**
1937
+ *
1938
+ * Use when you need to read the redacted representation from a value already
1939
+ * verified as `Redactable`.
1940
+ *
1941
+ * **Details**
1942
+ *
1943
+ * This function reads the current fiber's `Context` from the global fiber
1944
+ * reference and passes it to the redaction method.
1945
+ *
1946
+ * **Gotchas**
1947
+ *
1948
+ * If no fiber is active, an empty `Context` is passed to the redaction method.
1949
+ *
1950
+ * @see {@link redact} for the higher-level variant that handles non-redactable values
1951
+ * @see {@link isRedactable} for the type guard to verify before calling this
1952
+ * @stability stable
1953
+ * @category destructors
1954
+ * @since 4.0.0
1955
+ */
1956
+ function getRedacted(redactable) {
1957
+ return redactable[symbolRedactable](globalThis["~effect/Fiber/currentFiber"]?.context ?? emptyContext);
1958
+ }
1959
+ /** @internal */
1960
+ const currentFiberTypeId = "~effect/Fiber/currentFiber";
1961
+ const emptyMap = /*#__PURE__*/ new Map();
1962
+ const emptyContext = {
1963
+ "~effect/Context": {},
1964
+ base: emptyMap,
1965
+ depth: 0,
1966
+ mapUnsafe: emptyMap,
1967
+ pipe() {
1968
+ return pipeArguments(this, arguments);
1969
+ }
1970
+ };
1971
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/Formatter.js
1972
+ /**
1973
+ * Formats JavaScript values into readable strings.
1974
+ *
1975
+ * `format` is intended for logs, diagnostics, and error messages. It handles
1976
+ * primitives, objects, arrays, dates, regular expressions, maps, sets, class
1977
+ * instances, errors, circular references, and redactable values. `formatJson`
1978
+ * wraps JSON formatting with redaction and circular-reference handling, and the
1979
+ * module also includes helpers for property keys, paths, and dates.
1980
+ *
1981
+ * @stability stable
1982
+ * @since 4.0.0
1983
+ */
1984
+ /**
1985
+ * Converts any JavaScript value into a human-readable string.
1986
+ *
1987
+ * **When to use**
1988
+ *
1989
+ * Use when you need to format arbitrary JavaScript values for debugging,
1990
+ * logging, or error messages.
1991
+ *
1992
+ * **Details**
1993
+ *
1994
+ * - Output is **not** valid JSON; use {@link formatJson} when you need
1995
+ * parseable JSON.
1996
+ * - Handles `BigInt`, `Symbol`, `Set`, `Map`, `Date`, `RegExp`, and class
1997
+ * instances that `JSON.stringify` cannot represent.
1998
+ * - Circular references are shown as `"[Circular]"` instead of throwing.
1999
+ * - Failures while inspecting a value are rendered as diagnostic placeholders instead of throwing.
2000
+ * - Primitives: stringified naturally (`null`, `undefined`, `123`, `true`).
2001
+ * Strings are JSON-quoted.
2002
+ * - Objects with a custom `toString` (not `Object.prototype.toString`):
2003
+ * `toString()` is called unless `ignoreToString` is `true`.
2004
+ * - Errors with a `cause`: formatted as `"<message> (cause: <cause>)"`.
2005
+ * - Iterables (`Set`, `Map`, etc.): formatted as
2006
+ * `ClassName([...elements])`.
2007
+ * - Class instances: wrapped as `ClassName({...})`.
2008
+ * - `Redactable` values are automatically redacted.
2009
+ * - Arrays/objects with 0–1 entries are inline; larger ones are
2010
+ * pretty-printed when `space` is set.
2011
+ * - `space` — indentation unit (number of spaces, or a string like
2012
+ * `"\t"`). Defaults to `0` (compact).
2013
+ * - `ignoreToString` — skip calling `toString()`. Defaults to `false`.
2014
+ *
2015
+ * **Example** (Formatting compact output)
2016
+ *
2017
+ * ```ts import.meta.vitest
2018
+ * import { Formatter } from "effect"
2019
+ *
2020
+ * Formatter.format({ a: 1, b: [2, 3] }) // => "{\"a\":1,\"b\":[2,3]}"
2021
+ * ```
2022
+ *
2023
+ * **Example** (Pretty-printed output)
2024
+ *
2025
+ * ```ts import.meta.vitest
2026
+ * import { Formatter } from "effect"
2027
+ *
2028
+ * const output = Formatter.format({ a: 1, b: [2, 3] }, { space: 2 })
2029
+ * output // => "{\n \"a\": 1,\n \"b\": [\n 2,\n 3\n ]\n}"
2030
+ * ```
2031
+ *
2032
+ * **Example** (Handling circular references)
2033
+ *
2034
+ * ```ts import.meta.vitest
2035
+ * import { Formatter } from "effect"
2036
+ *
2037
+ * const obj: any = { name: "loop" }
2038
+ * obj.self = obj
2039
+ * Formatter.format(obj) // => "{\"name\":\"loop\",\"self\":[Circular]}"
2040
+ * ```
2041
+ *
2042
+ * @see {@link formatJson}
2043
+ * @see {@link Formatter}
2044
+ * @stability stable
2045
+ * @category formatting
2046
+ * @since 2.0.0
2047
+ */
2048
+ function format(input, options) {
2049
+ const space = options?.space ?? 0;
2050
+ const ancestors = /* @__PURE__ */ new WeakSet();
2051
+ const gap = !space ? "" : typeof space === "number" ? " ".repeat(space) : space;
2052
+ const ind = (d) => gap.repeat(d);
2053
+ const wrap = (v, body) => {
2054
+ const ctor = v?.constructor;
2055
+ return ctor && ctor !== Object.prototype.constructor && ctor.name ? `${ctor.name}(${body})` : body;
2056
+ };
2057
+ const ownKeys = (o) => {
2058
+ try {
2059
+ return Reflect.ownKeys(o);
2060
+ } catch {
2061
+ return ["[ownKeys threw]"];
2062
+ }
2063
+ };
2064
+ function recur(v, d = 0) {
2065
+ try {
2066
+ return recurUnsafe(v, d);
2067
+ } catch {
2068
+ if (typeof v === "object" && v !== null || typeof v === "function") ancestors.delete(v);
2069
+ return "[inspection threw]";
2070
+ }
2071
+ }
2072
+ function recurUnsafe(v, d = 0) {
2073
+ if (typeof v === "string") return JSON.stringify(v);
2074
+ if (typeof v === "number" || v == null || typeof v === "boolean" || typeof v === "symbol") return String(v);
2075
+ if (typeof v === "bigint") return String(v) + "n";
2076
+ if (typeof v === "object" || typeof v === "function") {
2077
+ if (ancestors.has(v)) return CIRCULAR;
2078
+ ancestors.add(v);
2079
+ let output;
2080
+ if (symbolRedactable in v) output = recur(getRedacted(v), d);
2081
+ else if (Array.isArray(v)) output = !gap || v.length <= 1 ? `[${v.map((x) => recur(x, d)).join(",")}]` : `[\n${ind(d + 1)}${v.map((x) => recur(x, d + 1)).join(",\n" + ind(d + 1))}\n${ind(d)}]`;
2082
+ else if (v instanceof Date) output = formatDate(v);
2083
+ else if (!options?.ignoreToString && hasProperty(v, "toString") && typeof v["toString"] === "function" && v["toString"] !== Object.prototype.toString && v["toString"] !== Array.prototype.toString) {
2084
+ const s = safeToString(v);
2085
+ output = v instanceof Error && v.cause !== void 0 ? `${s} (cause: ${recur(v.cause, d)})` : s;
2086
+ } else if (Symbol.iterator in v) output = `${v.constructor.name}(${recur(Array.from(v), d)})`;
2087
+ else {
2088
+ const keys = ownKeys(v);
2089
+ if (!gap || keys.length <= 1) {
2090
+ const body = `{${keys.map((k) => `${formatPropertyKey(k)}:${recur(safeGet(v, k), d)}`).join(",")}}`;
2091
+ output = wrap(v, body);
2092
+ } else {
2093
+ const body = `{\n${keys.map((k) => `${ind(d + 1)}${formatPropertyKey(k)}: ${recur(safeGet(v, k), d + 1)}`).join(",\n")}\n${ind(d)}}`;
2094
+ output = wrap(v, body);
2095
+ }
2096
+ }
2097
+ ancestors.delete(v);
2098
+ return output;
2099
+ }
2100
+ return String(v);
2101
+ }
2102
+ return recur(input, 0);
2103
+ }
2104
+ const CIRCULAR = "[Circular]";
2105
+ /**
2106
+ * @internal
2107
+ */
2108
+ function formatPropertyKey(name) {
2109
+ return typeof name === "string" ? JSON.stringify(name) : String(name);
2110
+ }
2111
+ /**
2112
+ * Formats an array of property keys as a bracket-notation path string.
2113
+ *
2114
+ * @internal
2115
+ */
2116
+ function formatPath(path) {
2117
+ return path.map((key) => `[${formatPropertyKey(key)}]`).join("");
2118
+ }
2119
+ /**
2120
+ * Formats a `Date` as an ISO 8601 string, returning `"Invalid Date"` for
2121
+ * invalid dates instead of throwing.
2122
+ *
2123
+ * @internal
2124
+ */
2125
+ function formatDate(date) {
2126
+ try {
2127
+ return date.toISOString();
2128
+ } catch {
2129
+ return "Invalid Date";
2130
+ }
2131
+ }
2132
+ function safeToString(input) {
2133
+ try {
2134
+ const s = input.toString();
2135
+ return typeof s === "string" ? s : String(s);
2136
+ } catch {
2137
+ return "[toString threw]";
2138
+ }
2139
+ }
2140
+ function safeGet(input, key) {
2141
+ try {
2142
+ return input[key];
2143
+ } catch {
2144
+ return "[property access threw]";
2145
+ }
2146
+ }
2147
+ /**
2148
+ * Stringifies a value to JSON safely, silently dropping circular references.
2149
+ *
2150
+ * **When to use**
2151
+ *
2152
+ * Use when you need valid JSON output, unlike `format`, and the input may
2153
+ * contain circular references that should be silently omitted rather than
2154
+ * throwing a `TypeError`.
2155
+ *
2156
+ * **Details**
2157
+ *
2158
+ * Uses `JSON.stringify` internally with a replacer that tracks the current
2159
+ * object ancestry. Circular references are replaced with `undefined`, which
2160
+ * omits them from object output. `Redactable` values are automatically redacted
2161
+ * before serialization. `BigInt` values are stringified with an `n` suffix.
2162
+ * `Error` instances without a `toJSON` property include their enumerable
2163
+ * properties plus `name` and `message`. Errors with `toJSON` keep their custom
2164
+ * representation. Other values follow standard `JSON.stringify` behavior. The
2165
+ * `space` parameter controls indentation and defaults to `0`.
2166
+ *
2167
+ * **Gotchas**
2168
+ *
2169
+ * When the root input is `undefined`, a symbol, or a function, `formatJson`
2170
+ * returns `"null"` instead of the `undefined` returned by `JSON.stringify`.
2171
+ * Nested values retain standard `JSON.stringify` behavior.
2172
+ *
2173
+ * **Example** (Formatting compact JSON)
2174
+ *
2175
+ * ```ts import.meta.vitest
2176
+ * import { Formatter } from "effect"
2177
+ *
2178
+ * Formatter.formatJson({ name: "Alice", age: 30 }) // => "{\"name\":\"Alice\",\"age\":30}"
2179
+ * ```
2180
+ *
2181
+ * **Example** (Handling circular references)
2182
+ *
2183
+ * ```ts import.meta.vitest
2184
+ * import { Formatter } from "effect"
2185
+ *
2186
+ * const obj: any = { name: "test" }
2187
+ * obj.self = obj
2188
+ * Formatter.formatJson(obj) // => "{\"name\":\"test\"}"
2189
+ * ```
2190
+ *
2191
+ * **Example** (Pretty-printed JSON)
2192
+ *
2193
+ * ```ts import.meta.vitest
2194
+ * import { Formatter } from "effect"
2195
+ *
2196
+ * const output = Formatter.formatJson({ name: "Alice", age: 30 }, { space: 2 })
2197
+ * output // => "{\n \"name\": \"Alice\",\n \"age\": 30\n}"
2198
+ * ```
2199
+ *
2200
+ * @see {@link format}
2201
+ * @see {@link Formatter}
2202
+ * @stability stable
2203
+ * @category serialization
2204
+ * @since 4.0.0
2205
+ */
2206
+ function formatJson(input, options) {
2207
+ const ancestors = [];
2208
+ const sources = /* @__PURE__ */ new WeakMap();
2209
+ return JSON.stringify(input, function(key, value) {
2210
+ const original = Object.getOwnPropertyDescriptor(sources.get(this) ?? this, key)?.value;
2211
+ const redacted = hasProperty(original, symbolRedactable) ? redact(original) : redact(value);
2212
+ if (typeof redacted === "bigint") return format(redacted);
2213
+ if (typeof redacted !== "object" || redacted === null) return redacted;
2214
+ const current = redacted instanceof Error && !hasProperty(redacted, "toJSON") ? {
2215
+ ...redacted,
2216
+ name: redacted.name,
2217
+ message: redacted.message
2218
+ } : redacted;
2219
+ while (ancestors.length > 0 && ancestors[ancestors.length - 1] !== this) ancestors.pop();
2220
+ if (ancestors.includes(redacted)) return;
2221
+ ancestors.push(redacted);
2222
+ if (current !== redacted) ancestors.push(current);
2223
+ if (!hasGetter(current) || isJsonPrimitiveWrapper(current)) return current;
2224
+ const view = redactingView(current);
2225
+ sources.set(view, current);
2226
+ ancestors.push(view);
2227
+ return view;
2228
+ }, options?.space) ?? "null";
2229
+ }
2230
+ function hasGetter(object) {
2231
+ for (const key of Object.getOwnPropertyNames(object)) if (Object.getOwnPropertyDescriptor(object, key)?.get !== void 0) return true;
2232
+ return false;
2233
+ }
2234
+ function redactingView(object) {
2235
+ const view = Array.isArray(object) ? [] : {};
2236
+ const keys = Array.isArray(object) ? Array.from({ length: object.length }, (_, i) => String(i)) : Object.keys(object);
2237
+ for (const key of keys) Object.defineProperty(view, key, {
2238
+ enumerable: true,
2239
+ get: () => {
2240
+ const value = Reflect.get(object, key);
2241
+ return Object.getOwnPropertyDescriptor(object, key)?.get !== void 0 ? redact(value) : value;
2242
+ }
2243
+ });
2244
+ return view;
2245
+ }
2246
+ function isJsonPrimitiveWrapper(object) {
2247
+ for (const valueOf of [
2248
+ Number.prototype.valueOf,
2249
+ Boolean.prototype.valueOf,
2250
+ String.prototype.valueOf
2251
+ ]) try {
2252
+ Reflect.apply(valueOf, object, []);
2253
+ return true;
2254
+ } catch {}
2255
+ return false;
2256
+ }
2257
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/Inspectable.js
2258
+ /**
2259
+ * Controls how values appear in logs and debugging output.
2260
+ *
2261
+ * Effect data types use `Inspectable` to provide stable string, JSON, and
2262
+ * Node.js inspection output. This keeps custom values readable in logs, REPLs,
2263
+ * test failures, and diagnostics. This module defines the Node inspect symbol,
2264
+ * the `Inspectable` interface, safe conversion helpers, and shared prototype or
2265
+ * class implementations for custom values.
2266
+ *
2267
+ * @stability stable
2268
+ * @since 2.0.0
2269
+ */
2270
+ /**
2271
+ * Defines the symbol used by Node.js for custom object inspection.
2272
+ *
2273
+ * **When to use**
2274
+ *
2275
+ * Use to implement Node.js custom inspection for a value.
2276
+ *
2277
+ * **Details**
2278
+ *
2279
+ * This symbol is recognized by Node.js's `util.inspect()` function and the REPL
2280
+ * for custom object representation. When an object has a method with this symbol,
2281
+ * it will be called to determine how the object should be displayed.
2282
+ *
2283
+ * **Example** (Defining custom Node inspection)
2284
+ *
2285
+ * ```ts import.meta.vitest
2286
+ * import { Inspectable } from "effect"
2287
+ *
2288
+ * class CustomObject {
2289
+ * constructor(private value: string) {}
2290
+ *
2291
+ * [Inspectable.NodeInspectSymbol]() {
2292
+ * return `CustomObject(${this.value})`
2293
+ * }
2294
+ * }
2295
+ *
2296
+ * const obj = new CustomObject("hello")
2297
+ * obj[Inspectable.NodeInspectSymbol]() // => "CustomObject(hello)"
2298
+ * ```
2299
+ *
2300
+ * @stability stable
2301
+ * @category symbols
2302
+ * @since 2.0.0
2303
+ */
2304
+ const NodeInspectSymbol = /*#__PURE__*/ Symbol.for("nodejs.util.inspect.custom");
2305
+ /**
2306
+ * Converts a value to its structured inspection representation.
2307
+ *
2308
+ * **When to use**
2309
+ *
2310
+ * Use when you need the structured representation of an inspectable value
2311
+ * without risking unhandled errors.
2312
+ *
2313
+ * **Details**
2314
+ *
2315
+ * This function applies redaction before extracting data from objects that
2316
+ * implement `toJSON`, recursively processes arrays, and handles errors
2317
+ * gracefully. Plain objects are returned unchanged, so the result is not
2318
+ * guaranteed to be accepted by `JSON.stringify`; it may still contain values
2319
+ * such as `BigInt`, functions, or circular references.
2320
+ *
2321
+ * @see {@link toStringUnknown} for converting unknown values to strings
2322
+ *
2323
+ * @stability stable
2324
+ * @category converting
2325
+ * @since 4.0.0
2326
+ */
2327
+ const toJson = (input) => {
2328
+ try {
2329
+ input = redact(input);
2330
+ if (hasProperty(input, "toJSON") && isFunction(input["toJSON"]) && input["toJSON"].length === 0) return input.toJSON();
2331
+ else if (Array.isArray(input)) return input.map(toJson);
2332
+ return input;
2333
+ } catch {
2334
+ return "[toJSON threw]";
2335
+ }
2336
+ };
2337
+ /**
2338
+ * Converts an unknown value to a string for diagnostics.
2339
+ *
2340
+ * **When to use**
2341
+ *
2342
+ * Use to produce a diagnostic string from a value whose runtime type is unknown.
2343
+ *
2344
+ * **Details**
2345
+ *
2346
+ * Strings are returned unchanged. Objects are formatted as JSON using the
2347
+ * provided whitespace setting when possible, and values that cannot be
2348
+ * formatted are converted with `String`.
2349
+ *
2350
+ * @stability stable
2351
+ * @category converting
2352
+ * @since 2.0.0
2353
+ */
2354
+ const toStringUnknown = (u, whitespace = 2) => {
2355
+ if (typeof u === "string") return u;
2356
+ try {
2357
+ return typeof u === "object" ? formatJson(u, { space: whitespace }) : format(u, { space: whitespace });
2358
+ } catch {
2359
+ return String(u);
2360
+ }
2361
+ };
2362
+ /**
2363
+ * A base prototype object that implements the {@link Inspectable} interface.
2364
+ *
2365
+ * **When to use**
2366
+ *
2367
+ * Use as a prototype for plain objects that should share standard inspectable behavior.
2368
+ *
2369
+ * **Details**
2370
+ *
2371
+ * This object provides default implementations for the {@link Inspectable} methods.
2372
+ * It can be used as a prototype for objects that want to be inspectable,
2373
+ * or as a mixin to add inspection capabilities to existing objects.
2374
+ *
2375
+ * **Example** (Using the base inspectable prototype)
2376
+ *
2377
+ * ```ts import.meta.vitest
2378
+ * import { Inspectable } from "effect"
2379
+ *
2380
+ * // Use as prototype
2381
+ * const myObject = Object.create(Inspectable.BaseProto)
2382
+ * myObject.name = "example"
2383
+ * myObject.value = 42
2384
+ *
2385
+ * myObject.toString() // => "\"[toJSON threw]\""
2386
+ *
2387
+ * // Or extend in a constructor
2388
+ * function MyClass(this: any, name: string) {
2389
+ * this.name = name
2390
+ * }
2391
+ * MyClass.prototype = Object.create(Inspectable.BaseProto)
2392
+ * MyClass.prototype.constructor = MyClass
2393
+ * ```
2394
+ *
2395
+ * @stability stable
2396
+ * @category prototypes
2397
+ * @since 2.0.0
2398
+ */
2399
+ const BaseProto = {
2400
+ toJSON() {
2401
+ return toJson(this);
2402
+ },
2403
+ [NodeInspectSymbol]() {
2404
+ return this.toJSON();
2405
+ },
2406
+ toString() {
2407
+ return format(this.toJSON());
2408
+ }
2409
+ };
2410
+ /**
2411
+ * Provides an abstract base class that implements the Inspectable interface.
2412
+ *
2413
+ * **When to use**
2414
+ *
2415
+ * Use as a base class for inspectable objects that define their own JSON representation.
2416
+ *
2417
+ * **Details**
2418
+ *
2419
+ * This class provides a convenient way to create inspectable objects by extending it.
2420
+ * Subclasses only need to implement the `toJSON()` method, and they automatically
2421
+ * get proper `toString()` and Node.js inspection support.
2422
+ *
2423
+ * **Example** (Extending the inspectable base class)
2424
+ *
2425
+ * ```ts import.meta.vitest
2426
+ * import { Inspectable } from "effect"
2427
+ *
2428
+ * class User extends Inspectable.Class {
2429
+ * constructor(
2430
+ * public readonly id: number,
2431
+ * public readonly name: string,
2432
+ * public readonly email: string
2433
+ * ) {
2434
+ * super()
2435
+ * }
2436
+ *
2437
+ * toJSON() {
2438
+ * return {
2439
+ * _tag: "User",
2440
+ * id: this.id,
2441
+ * name: this.name,
2442
+ * email: this.email
2443
+ * }
2444
+ * }
2445
+ * }
2446
+ *
2447
+ * const user = new User(1, "Alice", "alice@example.com")
2448
+ * user.toString() // => "{\"_tag\":\"User\",\"id\":1,\"name\":\"Alice\",\"email\":\"alice@example.com\"}"
2449
+ * user[Inspectable.NodeInspectSymbol]() // => { _tag: "User", id: 1, name: "Alice", email: "alice@example.com" }
2450
+ * ```
2451
+ *
2452
+ * @stability stable
2453
+ * @category models
2454
+ * @since 2.0.0
2455
+ */
2456
+ var Class = class {
2457
+ /**
2458
+ * Node.js custom inspection method.
2459
+ *
2460
+ * **When to use**
2461
+ *
2462
+ * Use to expose the class JSON representation to Node.js inspection.
2463
+ *
2464
+ * @since 2.0.0
2465
+ */
2466
+ [NodeInspectSymbol]() {
2467
+ return this.toJSON();
2468
+ }
2469
+ /**
2470
+ * Returns a formatted string representation of this object.
2471
+ *
2472
+ * **When to use**
2473
+ *
2474
+ * Use to format the class JSON representation as a string.
2475
+ *
2476
+ * @since 2.0.0
2477
+ */
2478
+ toString() {
2479
+ return format(this.toJSON());
2480
+ }
2481
+ };
2482
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/internal/stackTraceLimit.js
2483
+ /**
2484
+ * Check if `Error.stackTraceLimit` is writable.
2485
+ * Returns `false` if the property is frozen, non-writable, or `Error` is non-extensible.
2486
+ *
2487
+ * @internal
2488
+ */
2489
+ const isStackTraceLimitWritable = () => {
2490
+ const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
2491
+ if (desc === void 0) return Object.isExtensible(Error);
2492
+ return Object.hasOwn(desc, "writable") ? desc.writable === true : desc.set !== void 0;
2493
+ };
2494
+ const canWriteStackTraceLimit = /*#__PURE__*/ isStackTraceLimitWritable();
2495
+ /**
2496
+ * Get the current `Error.stackTraceLimit` value.
2497
+ * Returns `undefined` if the property doesn't exist.
2498
+ *
2499
+ * @internal
2500
+ */
2501
+ const getStackTraceLimit = () => Error.stackTraceLimit;
2502
+ /**
2503
+ * Safely set `Error.stackTraceLimit` if possible, otherwise no-op.
2504
+ *
2505
+ * Accepts `undefined` so a value read via {@link getStackTraceLimit} can be
2506
+ * restored faithfully.
2507
+ *
2508
+ * @internal
2509
+ */
2510
+ const setStackTraceLimit = (value) => {
2511
+ if (canWriteStackTraceLimit) Error.stackTraceLimit = value;
2512
+ };
2513
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/Utils.js
2514
+ /**
2515
+ * Yields its wrapped value exactly once, then completes with the value sent
2516
+ * back in.
2517
+ *
2518
+ * **When to use**
2519
+ *
2520
+ * Use to implement `[Symbol.iterator]()` on Effect-like types so they can be
2521
+ * `yield*`-ed inside generator functions, such as `Effect.gen` and
2522
+ * `Option.gen`.
2523
+ *
2524
+ * **Details**
2525
+ *
2526
+ * The first call to `next()` returns a fresh `{ value: self, done: false }`.
2527
+ * Every subsequent call returns `{ value: a, done: true }` where `a` is the
2528
+ * argument passed to `next()`. To keep `yield*` cheap, the completion result
2529
+ * is the iterator itself rather than a new object, so only the iterator and
2530
+ * the single yielded result are allocated per `yield*`.
2531
+ *
2532
+ * **Example** (Yielding a wrapped value in a generator)
2533
+ *
2534
+ * ```ts import.meta.vitest
2535
+ * import { Utils } from "effect"
2536
+ *
2537
+ * const gen = new Utils.SingleShotGen<string, number>("hello")
2538
+ *
2539
+ * gen.next(0).value // => "hello"
2540
+ *
2541
+ * gen.next(42).value // => 42
2542
+ * ```
2543
+ *
2544
+ * @see {@link Gen} for the type-level signature that relies on `SingleShotGen`
2545
+ * @stability stable
2546
+ * @category constructors
2547
+ * @since 2.0.0
2548
+ */
2549
+ var SingleShotGen = class {
2550
+ constructor(self) {
2551
+ this.value = self;
2552
+ this.done = false;
2553
+ }
2554
+ /**
2555
+ * Yields the stored value once, then completes with the value sent back in.
2556
+ *
2557
+ * **When to use**
2558
+ *
2559
+ * Use to advance a `SingleShotGen` through its single yield and completion
2560
+ * step.
2561
+ *
2562
+ * @since 2.0.0
2563
+ */
2564
+ next(a) {
2565
+ if (this.done) {
2566
+ this.value = a;
2567
+ return this;
2568
+ }
2569
+ this.done = true;
2570
+ return {
2571
+ value: this.value,
2572
+ done: false
2573
+ };
2574
+ }
2575
+ };
2576
+ const pickInternalCall = () => {
2577
+ const InternalTypeId = "~effect/Utils/internal";
2578
+ const standard = { [InternalTypeId]: (body) => {
2579
+ return body();
2580
+ } };
2581
+ const forced = { [InternalTypeId]: (body) => {
2582
+ try {
2583
+ return body();
2584
+ } finally {}
2585
+ } };
2586
+ const limit = getStackTraceLimit();
2587
+ if (limit === 0) return forced[InternalTypeId];
2588
+ setStackTraceLimit(2);
2589
+ const error = standard[InternalTypeId](() => /* @__PURE__ */ new Error());
2590
+ setStackTraceLimit(limit);
2591
+ return error.stack?.includes(InternalTypeId) === true ? standard[InternalTypeId] : forced[InternalTypeId];
2592
+ };
2593
+ /** @internal */
2594
+ const internalCall = /*#__PURE__*/ pickInternalCall();
2595
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/internal/record.js
2596
+ /** @internal */
2597
+ function assignProperty(self, key, value) {
2598
+ if (key === "__proto__") Object.defineProperty(self, key, {
2599
+ value,
2600
+ writable: true,
2601
+ enumerable: true,
2602
+ configurable: true
2603
+ });
2604
+ else self[key] = value;
2605
+ }
2606
+ /** @internal */
2607
+ function assignProperties(self, source) {
2608
+ if (!Object.hasOwn(source, "__proto__")) {
2609
+ Object.assign(self, source);
2610
+ return;
2611
+ }
2612
+ for (const key of Reflect.ownKeys(source)) if (Object.prototype.propertyIsEnumerable.call(source, key)) assignProperty(self, key, source[key]);
2613
+ }
2614
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/internal/core.js
2615
+ /** @internal */
2616
+ const EffectTypeId = `~effect/Effect`;
2617
+ /** @internal */
2618
+ const ExitTypeId = `~effect/Exit`;
2619
+ const effectVariance = {
2620
+ _A: identity,
2621
+ _E: identity,
2622
+ _R: identity
2623
+ };
2624
+ /** @internal */
2625
+ const identifier = `${EffectTypeId}/identifier`;
2626
+ /** @internal */
2627
+ const args = `${EffectTypeId}/args`;
2628
+ /** @internal */
2629
+ const evaluate = `${EffectTypeId}/evaluate`;
2630
+ /** @internal */
2631
+ const contA = `${EffectTypeId}/successCont`;
2632
+ /** @internal */
2633
+ const contE = `${EffectTypeId}/failureCont`;
2634
+ /** @internal */
2635
+ const contAll = `${EffectTypeId}/ensureCont`;
2636
+ /** @internal */
2637
+ const Yield = /*#__PURE__*/ Symbol.for("effect/Effect/Yield");
2638
+ /** @internal */
2639
+ const PipeInspectableProto = {
2640
+ pipe() {
2641
+ return pipeArguments(this, arguments);
2642
+ },
2643
+ toJSON() {
2644
+ return { ...this };
2645
+ },
2646
+ toString() {
2647
+ return format(this.toJSON(), {
2648
+ ignoreToString: true,
2649
+ space: 2
2650
+ });
2651
+ },
2652
+ [NodeInspectSymbol]() {
2653
+ return this.toJSON();
2654
+ }
2655
+ };
2656
+ /** @internal */
2657
+ const EffectProto = {
2658
+ [EffectTypeId]: effectVariance,
2659
+ ...PipeInspectableProto,
2660
+ [Symbol.iterator]() {
2661
+ return new SingleShotGen(this);
2662
+ },
2663
+ toJSON() {
2664
+ return {
2665
+ _id: "Effect",
2666
+ op: this[identifier],
2667
+ ..."~effect/Effect/args" in this ? { args: this[args] } : void 0
2668
+ };
2669
+ }
2670
+ };
2671
+ /** @internal */
2672
+ const isEffect = (u) => hasProperty(u, EffectTypeId);
2673
+ /** @internal */
2674
+ const isExit = (u) => hasProperty(u, ExitTypeId);
2675
+ /** @internal */
2676
+ const CauseTypeId = "~effect/Cause";
2677
+ /** @internal */
2678
+ const CauseReasonTypeId = "~effect/Cause/Reason";
2679
+ /** @internal */
2680
+ const isCause = (self) => hasProperty(self, CauseTypeId);
2681
+ /** @internal */
2682
+ const isCauseReason = (self) => hasProperty(self, CauseReasonTypeId);
2683
+ /** @internal */
2684
+ var CauseImpl = class {
2685
+ constructor(failures) {
2686
+ this[CauseTypeId] = CauseTypeId;
2687
+ this.reasons = failures;
2688
+ }
2689
+ pipe() {
2690
+ return pipeArguments(this, arguments);
2691
+ }
2692
+ toJSON() {
2693
+ return {
2694
+ _id: "Cause",
2695
+ reasons: this.reasons.map((f) => f.toJSON())
2696
+ };
2697
+ }
2698
+ toString() {
2699
+ return `Cause(${format(this.reasons)})`;
2700
+ }
2701
+ [NodeInspectSymbol]() {
2702
+ return this.toJSON();
2703
+ }
2704
+ [symbol](that) {
2705
+ return isCause(that) && this.reasons.length === that.reasons.length && this.reasons.every((e, i) => equals(e, that.reasons[i]));
2706
+ }
2707
+ [symbol$1]() {
2708
+ return array(this.reasons);
2709
+ }
2710
+ };
2711
+ const annotationsMap = /*#__PURE__*/ new WeakMap();
2712
+ /** @internal */
2713
+ var ReasonBase = class {
2714
+ [CauseReasonTypeId];
2715
+ annotations;
2716
+ _tag;
2717
+ constructor(_tag, annotations, originalError) {
2718
+ this[CauseReasonTypeId] = CauseReasonTypeId;
2719
+ this._tag = _tag;
2720
+ if (annotations !== constEmptyAnnotations && typeof originalError === "object" && originalError !== null && annotations.size > 0) {
2721
+ const prevAnnotations = annotationsMap.get(originalError);
2722
+ if (prevAnnotations) annotations = new Map([...prevAnnotations, ...annotations]);
2723
+ annotationsMap.set(originalError, annotations);
2724
+ }
2725
+ this.annotations = annotations;
2726
+ }
2727
+ annotate(annotations, options) {
2728
+ if (annotations.mapUnsafe.size === 0) return this;
2729
+ const newAnnotations = new Map(this.annotations);
2730
+ annotations.mapUnsafe.forEach((value, key) => {
2731
+ if (options?.overwrite !== true && newAnnotations.has(key)) return;
2732
+ newAnnotations.set(key, value);
2733
+ });
2734
+ if (options?.overwrite !== true && newAnnotations.size === this.annotations.size) return this;
2735
+ const self = Object.assign(Object.create(Object.getPrototypeOf(this)), this);
2736
+ self.annotations = newAnnotations;
2737
+ return self;
2738
+ }
2739
+ pipe() {
2740
+ return pipeArguments(this, arguments);
2741
+ }
2742
+ toString() {
2743
+ return format(this);
2744
+ }
2745
+ [NodeInspectSymbol]() {
2746
+ return this.toString();
2747
+ }
2748
+ };
2749
+ /** @internal */
2750
+ const constEmptyAnnotations = /*#__PURE__*/ new Map();
2751
+ /** @internal */
2752
+ var Fail = class extends ReasonBase {
2753
+ constructor(error, annotations = constEmptyAnnotations) {
2754
+ super("Fail", annotations, error);
2755
+ this.error = error;
2756
+ }
2757
+ toString() {
2758
+ return `Fail(${format(this.error)})`;
2759
+ }
2760
+ toJSON() {
2761
+ return {
2762
+ _tag: "Fail",
2763
+ error: this.error
2764
+ };
2765
+ }
2766
+ [symbol](that) {
2767
+ return isFailReason(that) && equals(this.error, that.error) && equals(this.annotations, that.annotations);
2768
+ }
2769
+ [symbol$1]() {
2770
+ return combine(string(this._tag))(combine(hash(this.error))(hash(this.annotations)));
2771
+ }
2772
+ };
2773
+ /** @internal */
2774
+ const causeFromReasons = (reasons) => new CauseImpl(reasons);
2775
+ const dedupeReasons = (self, that) => {
2776
+ const buckets = /* @__PURE__ */ new Map();
2777
+ const out = [];
2778
+ for (const reason of self.concat(that)) {
2779
+ const hash$1 = hash(reason);
2780
+ const bucket = buckets.get(hash$1);
2781
+ if (bucket === void 0) buckets.set(hash$1, [reason]);
2782
+ else if (bucket.some((previous) => equals(previous, reason))) continue;
2783
+ else bucket.push(reason);
2784
+ out.push(reason);
2785
+ }
2786
+ return out;
2787
+ };
2788
+ /** @internal */
2789
+ const causeCombine = /*#__PURE__*/ dual(2, (self, that) => {
2790
+ if (self.reasons.length === 0) return that;
2791
+ else if (that.reasons.length === 0) return self;
2792
+ const newCause = new CauseImpl(dedupeReasons(self.reasons, that.reasons));
2793
+ return equals(self, newCause) ? self : newCause;
2794
+ });
2795
+ /**
2796
+ * Appends the interrupts from `interrupts` that `self` does not contain yet.
2797
+ * Unlike `causeCombine`, it never calls hash or equality methods, which can be
2798
+ * user-defined, random, or throwing.
2799
+ *
2800
+ * @internal
2801
+ */
2802
+ const causeAddInterrupts = (self, interrupts) => {
2803
+ const reasons = self.reasons.slice();
2804
+ for (const reason of interrupts.reasons) if (isInterruptReason(reason) && !reasons.some((r) => isInterruptReason(r) && r.fiberId === reason.fiberId && r.annotations === reason.annotations)) reasons.push(reason);
2805
+ return reasons.length === self.reasons.length ? self : new CauseImpl(reasons);
2806
+ };
2807
+ /** @internal */
2808
+ const causeEmpty = /*#__PURE__*/ new CauseImpl([]);
2809
+ /** @internal */
2810
+ const causeFail = (error) => new CauseImpl([new Fail(error)]);
2811
+ /** @internal */
2812
+ var Die = class extends ReasonBase {
2813
+ constructor(defect, annotations = constEmptyAnnotations) {
2814
+ super("Die", annotations, defect);
2815
+ this.defect = defect;
2816
+ }
2817
+ toString() {
2818
+ return `Die(${format(this.defect)})`;
2819
+ }
2820
+ toJSON() {
2821
+ return {
2822
+ _tag: "Die",
2823
+ defect: this.defect
2824
+ };
2825
+ }
2826
+ [symbol](that) {
2827
+ return isDieReason(that) && equals(this.defect, that.defect) && equals(this.annotations, that.annotations);
2828
+ }
2829
+ [symbol$1]() {
2830
+ return combine(string(this._tag))(combine(hash(this.defect))(hash(this.annotations)));
2831
+ }
2832
+ };
2833
+ /** @internal */
2834
+ const causeDie = (defect) => new CauseImpl([new Die(defect)]);
2835
+ /** @internal */
2836
+ const causeAnnotate = /*#__PURE__*/ dual((args) => isCause(args[0]), (self, annotations, options) => {
2837
+ if (annotations.mapUnsafe.size === 0) return self;
2838
+ return new CauseImpl(self.reasons.map((f) => f.annotate(annotations, options)));
2839
+ });
2840
+ /** @internal */
2841
+ const isFailReason = (self) => self._tag === "Fail";
2842
+ /** @internal */
2843
+ const isDieReason = (self) => self._tag === "Die";
2844
+ /** @internal */
2845
+ const isInterruptReason = (self) => self._tag === "Interrupt";
2846
+ function defaultEvaluate(_fiber) {
2847
+ return exitDie(`Effect.evaluate: Not implemented`);
2848
+ }
2849
+ /** @internal */
2850
+ const makePrimitiveProto = (options) => ({
2851
+ ...EffectProto,
2852
+ [identifier]: options.op,
2853
+ [evaluate]: options["~effect/Effect/evaluate"] ?? defaultEvaluate,
2854
+ [contA]: options[contA],
2855
+ [contE]: options[contE],
2856
+ [contAll]: options[contAll]
2857
+ });
2858
+ /** @internal */
2859
+ const makePrimitive = (options) => {
2860
+ const Proto = makePrimitiveProto(options);
2861
+ const PrimitiveImpl = function(value) {
2862
+ this[args] = value;
2863
+ };
2864
+ PrimitiveImpl.prototype = Proto;
2865
+ return function(value) {
2866
+ return new PrimitiveImpl(value);
2867
+ };
2868
+ };
2869
+ /** @internal */
2870
+ const makeExit = (options) => {
2871
+ const Proto = {
2872
+ [ExitTypeId]: ExitTypeId,
2873
+ _tag: options.op,
2874
+ get [options.prop]() {
2875
+ return this[args];
2876
+ },
2877
+ ...makePrimitiveProto(options),
2878
+ toString() {
2879
+ return `${options.op}(${format(this[args])})`;
2880
+ },
2881
+ toJSON() {
2882
+ return {
2883
+ _id: "Exit",
2884
+ _tag: options.op,
2885
+ [options.prop]: this[args]
2886
+ };
2887
+ },
2888
+ [symbol](that) {
2889
+ return isExit(that) && that._tag === this._tag && equals(this["~effect/Effect/args"], that["~effect/Effect/args"]);
2890
+ },
2891
+ [symbol$1]() {
2892
+ return combine(string(options.op), hash(this[args]));
2893
+ }
2894
+ };
2895
+ const ExitPrimitive = function(value) {
2896
+ this[args] = value;
2897
+ };
2898
+ ExitPrimitive.prototype = Proto;
2899
+ return function(value) {
2900
+ return new ExitPrimitive(value);
2901
+ };
2902
+ };
2903
+ /** @internal */
2904
+ const exitSucceed = /*#__PURE__*/ makeExit({
2905
+ op: "Success",
2906
+ prop: "value",
2907
+ [evaluate](fiber) {
2908
+ const cont = fiber.getCont(contA);
2909
+ return cont ? cont[contA](this[args], fiber, this) : fiber.yieldWith(this);
2910
+ }
2911
+ });
2912
+ /** @internal */
2913
+ const StackTraceKey = { key: "effect/Cause/StackTrace" };
2914
+ /** @internal */
2915
+ const InterruptorStackTrace = { key: "effect/Cause/InterruptorStackTrace" };
2916
+ /** @internal */
2917
+ const exitFailCause = /*#__PURE__*/ makeExit({
2918
+ op: "Failure",
2919
+ prop: "cause",
2920
+ [evaluate](fiber) {
2921
+ let cause = this[args];
2922
+ let annotated = false;
2923
+ if (fiber.cache.stackFrame) {
2924
+ cause = causeAnnotate(cause, { mapUnsafe: /* @__PURE__ */ new Map([[StackTraceKey.key, fiber.cache.stackFrame]]) });
2925
+ annotated = true;
2926
+ }
2927
+ let cont = fiber.getCont(contE);
2928
+ const interruptedCause = fiber._interruptedCause;
2929
+ if (interruptedCause && fiber.interruptible) {
2930
+ let skippedHandler = false;
2931
+ while (cont && fiber.interruptible) {
2932
+ skippedHandler ||= identifier in cont;
2933
+ cont = fiber.getCont(contE);
2934
+ }
2935
+ if (skippedHandler) cause = causeFromReasons(cause.reasons.filter((reason) => reason._tag !== "Fail"));
2936
+ cause = causeAddInterrupts(cause, interruptedCause);
2937
+ annotated = true;
2938
+ }
2939
+ return cont ? cont[contE](cause, fiber, annotated ? void 0 : this) : fiber.yieldWith(annotated ? exitFailCause(cause) : this);
2940
+ }
2941
+ });
2942
+ /** @internal */
2943
+ const exitFail = (e) => exitFailCause(causeFail(e));
2944
+ /** @internal */
2945
+ const exitDie = (defect) => exitFailCause(causeDie(defect));
2946
+ /** @internal */
2947
+ const withFiber = /*#__PURE__*/ makePrimitive({
2948
+ op: "WithFiber",
2949
+ [evaluate](fiber) {
2950
+ return this[args](fiber);
2951
+ }
2952
+ });
2953
+ /** @internal */
2954
+ const YieldableError = /*#__PURE__*/ function() {
2955
+ class YieldableError extends globalThis.Error {}
2956
+ const proto = /*#__PURE__*/ makePrimitiveProto({
2957
+ op: "YieldableError",
2958
+ [evaluate]() {
2959
+ return exitFail(this);
2960
+ }
2961
+ });
2962
+ delete proto.toString;
2963
+ Object.assign(YieldableError.prototype, proto);
2964
+ return YieldableError;
2965
+ }();
2966
+ /** @internal */
2967
+ const Error$1 = /*#__PURE__*/ function() {
2968
+ const plainArgsSymbol = /*#__PURE__*/ Symbol.for("effect/Data/Error/plainArgs");
2969
+ return class Base extends YieldableError {
2970
+ constructor(args) {
2971
+ super(args?.message, args?.cause ? { cause: args.cause } : void 0);
2972
+ if (args) {
2973
+ assignProperties(this, args);
2974
+ Object.defineProperty(this, plainArgsSymbol, {
2975
+ value: args,
2976
+ enumerable: false
2977
+ });
2978
+ }
2979
+ }
2980
+ toJSON() {
2981
+ return {
2982
+ ...this[plainArgsSymbol],
2983
+ ...this
2984
+ };
2985
+ }
2986
+ };
2987
+ }();
2988
+ /** @internal */
2989
+ const TaggedError = (tag) => {
2990
+ class Base extends Error$1 {
2991
+ _tag = tag;
2992
+ }
2993
+ Base.prototype.name = tag;
2994
+ return Base;
2995
+ };
2996
+ /** @internal */
2997
+ const NoSuchElementErrorTypeId = "~effect/Cause/NoSuchElementError";
2998
+ /** @internal */
2999
+ var NoSuchElementError = class extends (/*#__PURE__*/ TaggedError("NoSuchElementError")) {
3000
+ [NoSuchElementErrorTypeId] = NoSuchElementErrorTypeId;
3001
+ constructor(message) {
3002
+ super({ message });
3003
+ }
3004
+ };
3005
+ /** @internal */
3006
+ const DoneTypeId = "~effect/Cause/Done";
3007
+ /** @internal */
3008
+ const isDone = (u) => hasProperty(u, DoneTypeId);
3009
+ const DoneVoid = {
3010
+ [DoneTypeId]: DoneTypeId,
3011
+ _tag: "Done",
3012
+ value: void 0
3013
+ };
3014
+ /** @internal */
3015
+ const Done = (value) => {
3016
+ if (value === void 0) return DoneVoid;
3017
+ return {
3018
+ [DoneTypeId]: DoneTypeId,
3019
+ _tag: "Done",
3020
+ value
3021
+ };
3022
+ };
3023
+ const doneVoid = /*#__PURE__*/ exitFail(DoneVoid);
3024
+ /** @internal */
3025
+ const done = (value) => {
3026
+ if (value === void 0) return doneVoid;
3027
+ return exitFail(Done(value));
3028
+ };
3029
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/internal/option.js
3030
+ /**
3031
+ * @since 2.0.0
3032
+ */
3033
+ const TypeId = "~effect/Option";
3034
+ const CommonProto = {
3035
+ [TypeId]: { _A: (_) => _ },
3036
+ ...PipeInspectableProto,
3037
+ [Symbol.iterator]() {
3038
+ return new SingleShotGen(this);
3039
+ }
3040
+ };
3041
+ const SomeProto = /*#__PURE__*/ Object.defineProperty(/*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(CommonProto), {
3042
+ _tag: "Some",
3043
+ _op: "Some",
3044
+ [symbol](that) {
3045
+ return isOption$1(that) && isSome$1(that) && equals(this.value, that.value);
3046
+ },
3047
+ [symbol$1]() {
3048
+ return combine(hash(this._tag))(hash(this.value));
3049
+ },
3050
+ toString() {
3051
+ return `some(${format(this.value)})`;
3052
+ },
3053
+ toJSON() {
3054
+ return {
3055
+ _id: "Option",
3056
+ _tag: this._tag,
3057
+ value: toJson(this.value)
3058
+ };
3059
+ }
3060
+ }), "valueOrUndefined", { get() {
3061
+ return this.value;
3062
+ } });
3063
+ const NoneHash = /*#__PURE__*/ hash("None");
3064
+ const NoneProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(CommonProto), {
3065
+ _tag: "None",
3066
+ _op: "None",
3067
+ valueOrUndefined: void 0,
3068
+ [symbol](that) {
3069
+ return isOption$1(that) && isNone$1(that);
3070
+ },
3071
+ [symbol$1]() {
3072
+ return NoneHash;
3073
+ },
3074
+ toString() {
3075
+ return `none()`;
3076
+ },
3077
+ toJSON() {
3078
+ return {
3079
+ _id: "Option",
3080
+ _tag: this._tag
3081
+ };
3082
+ }
3083
+ });
3084
+ /** @internal */
3085
+ const isOption$1 = (input) => hasProperty(input, TypeId);
3086
+ /** @internal */
3087
+ const isNone$1 = (fa) => fa._tag === "None";
3088
+ /** @internal */
3089
+ const isSome$1 = (fa) => fa._tag === "Some";
3090
+ /** @internal */
3091
+ const none$1 = /*#__PURE__*/ Object.create(NoneProto);
3092
+ /** @internal */
3093
+ const SomeImpl = function(value) {
3094
+ this.value = value;
3095
+ };
3096
+ SomeImpl.prototype = SomeProto;
3097
+ /** @internal */
3098
+ const some$1 = (value) => new SomeImpl(value);
3099
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/Option.js
3100
+ /**
3101
+ * Creates an `Option` representing the absence of a value.
3102
+ *
3103
+ * **When to use**
3104
+ *
3105
+ * Use to represent a missing or uninitialized value, such as returning "no
3106
+ * result" from a function.
3107
+ *
3108
+ * **Details**
3109
+ *
3110
+ * - Returns `Option<never>`, which is a subtype of `Option<A>` for any `A`
3111
+ * - Always returns the same singleton instance
3112
+ *
3113
+ * **Example** (Creating an empty Option)
3114
+ *
3115
+ * ```ts import.meta.vitest
3116
+ * import { Option } from "effect"
3117
+ *
3118
+ * // ┌─── Option<never>
3119
+ * // ▼
3120
+ * const noValue = Option.none() // => Option.none()
3121
+ * ```
3122
+ *
3123
+ * @see {@link some} for the opposite operation.
3124
+ *
3125
+ * @stability stable
3126
+ * @category constructors
3127
+ * @since 2.0.0
3128
+ */
3129
+ const none = () => none$1;
3130
+ /**
3131
+ * Wraps the given value into an `Option` to represent its presence.
3132
+ *
3133
+ * **When to use**
3134
+ *
3135
+ * Use to wrap a known present value as `Option`
3136
+ * - Returning a successful result from a partial function
3137
+ *
3138
+ * **Details**
3139
+ *
3140
+ * - Always returns `Some<A>`
3141
+ * - Does not filter `null` or `undefined`; use {@link fromNullishOr} for that
3142
+ *
3143
+ * **Example** (Wrapping a value)
3144
+ *
3145
+ * ```ts import.meta.vitest
3146
+ * import { Option } from "effect"
3147
+ *
3148
+ * // ┌─── Option<number>
3149
+ * // ▼
3150
+ * const value = Option.some(1) // => Option.some(1)
3151
+ * ```
3152
+ *
3153
+ * @see {@link none} for the opposite operation.
3154
+ *
3155
+ * @stability stable
3156
+ * @category constructors
3157
+ * @since 2.0.0
3158
+ */
3159
+ const some = some$1;
3160
+ /**
3161
+ * Determines whether the given value is an `Option`.
3162
+ *
3163
+ * **When to use**
3164
+ *
3165
+ * Use to validate unknown values at runtime boundaries, such as type-narrowing
3166
+ * in union types.
3167
+ *
3168
+ * **Details**
3169
+ *
3170
+ * - Returns `true` for both `Some` and `None` instances
3171
+ * - Acts as a type guard, narrowing the input to `Option<unknown>`
3172
+ *
3173
+ * **Example** (Checking if a value is an Option)
3174
+ *
3175
+ * ```ts import.meta.vitest
3176
+ * import { Option } from "effect"
3177
+ *
3178
+ * Option.isOption(Option.some(1)) // => true
3179
+ * Option.isOption(Option.none()) // => true
3180
+ * Option.isOption({}) // => false
3181
+ * ```
3182
+ *
3183
+ * @see {@link isNone} to check for `None` specifically
3184
+ * @see {@link isSome} to check for `Some` specifically
3185
+ *
3186
+ * @stability stable
3187
+ * @category guards
3188
+ * @since 2.0.0
3189
+ */
3190
+ const isOption = isOption$1;
3191
+ /**
3192
+ * Checks whether an `Option` is `None` (absent).
3193
+ *
3194
+ * **When to use**
3195
+ *
3196
+ * Use when you need to branch on an absent `Option` before accessing `.value`.
3197
+ *
3198
+ * **Details**
3199
+ *
3200
+ * - Acts as a type guard, narrowing to `None<A>`
3201
+ *
3202
+ * **Example** (Checking for None)
3203
+ *
3204
+ * ```ts import.meta.vitest
3205
+ * import { Option } from "effect"
3206
+ *
3207
+ * Option.isNone(Option.some(1)) // => false
3208
+ * Option.isNone(Option.none()) // => true
3209
+ * ```
3210
+ *
3211
+ * @see {@link isSome} for the opposite check.
3212
+ *
3213
+ * @stability stable
3214
+ * @category guards
3215
+ * @since 2.0.0
3216
+ */
3217
+ const isNone = isNone$1;
3218
+ /**
3219
+ * Checks whether an `Option` contains a value (`Some`).
3220
+ *
3221
+ * **When to use**
3222
+ *
3223
+ * Use when you need to branch on a present `Option` before accessing `.value`.
3224
+ *
3225
+ * **Details**
3226
+ *
3227
+ * - Acts as a type guard, narrowing to `Some<A>`
3228
+ *
3229
+ * **Example** (Checking for Some)
3230
+ *
3231
+ * ```ts import.meta.vitest
3232
+ * import { Option } from "effect"
3233
+ *
3234
+ * Option.isSome(Option.some(1)) // => true
3235
+ * Option.isSome(Option.none()) // => false
3236
+ * ```
3237
+ *
3238
+ * @see {@link isNone} for the opposite check.
3239
+ *
3240
+ * @stability stable
3241
+ * @category guards
3242
+ * @since 2.0.0
3243
+ */
3244
+ const isSome = isSome$1;
3245
+ /**
3246
+ * Pattern-matches on an `Option`, handling both `None` and `Some` cases.
3247
+ *
3248
+ * **When to use**
3249
+ *
3250
+ * Use when you need to handle both `Some` and `None` in one expression and
3251
+ * transform an `Option` into a plain value.
3252
+ *
3253
+ * **Details**
3254
+ *
3255
+ * - If `None`, calls `onNone` and returns its result
3256
+ * - If `Some`, calls `onSome` with the value and returns its result
3257
+ * - Supports the `dual` API (data-last and data-first)
3258
+ *
3259
+ * **Example** (Matching on an Option)
3260
+ *
3261
+ * ```ts import.meta.vitest
3262
+ * import { Option } from "effect"
3263
+ *
3264
+ * Option.match(Option.some(1), {
3265
+ * onNone: () => "Option is empty",
3266
+ * onSome: (value) => `Option has a value: ${value}`
3267
+ * }) // => "Option has a value: 1"
3268
+ * ```
3269
+ *
3270
+ * @see {@link getOrElse} for unwrapping with a default
3271
+ *
3272
+ * @stability stable
3273
+ * @category pattern matching
3274
+ * @since 2.0.0
3275
+ */
3276
+ const match = /*#__PURE__*/ dual(2, (self, { onNone, onSome }) => isNone(self) ? onNone() : onSome(self.value));
3277
+ /**
3278
+ * Extracts the value from a `Some`, or evaluates a fallback thunk on `None`.
3279
+ *
3280
+ * **When to use**
3281
+ *
3282
+ * Use when providing a default value for an absent `Option`
3283
+ * - Unwrapping with lazy evaluation of the fallback
3284
+ *
3285
+ * **Details**
3286
+ *
3287
+ * - `Some` → returns the inner value
3288
+ * - `None` → calls `onNone()` and returns its result
3289
+ * - `onNone` is only called when needed (lazy)
3290
+ *
3291
+ * **Example** (Unwrapping with a fallback)
3292
+ *
3293
+ * ```ts import.meta.vitest
3294
+ * import { Option } from "effect"
3295
+ *
3296
+ * Option.some(1).pipe(Option.getOrElse(() => 0)) // => 1
3297
+ * Option.none().pipe(Option.getOrElse(() => 0)) // => 0
3298
+ * ```
3299
+ *
3300
+ * @see {@link getOrNull} to fall back to `null`
3301
+ * @see {@link getOrUndefined} to fall back to `undefined`
3302
+ * @see {@link getOrThrow} to throw on `None`
3303
+ *
3304
+ * @stability stable
3305
+ * @category getters
3306
+ * @since 2.0.0
3307
+ */
3308
+ const getOrElse = /*#__PURE__*/ dual(2, (self, onNone) => isNone(self) ? onNone() : self.value);
3309
+ /**
3310
+ * Returns the fallback `Option` if `self` is `None`; otherwise returns `self`.
3311
+ *
3312
+ * **When to use**
3313
+ *
3314
+ * Use when you need a lazy fallback `Option`, such as when building priority
3315
+ * chains of optional values.
3316
+ *
3317
+ * **Details**
3318
+ *
3319
+ * - `Some` → returns `self` unchanged
3320
+ * - `None` → evaluates and returns `that()`
3321
+ * - `that` is lazily evaluated
3322
+ *
3323
+ * **Example** (Providing a fallback Option)
3324
+ *
3325
+ * ```ts import.meta.vitest
3326
+ * import { Option } from "effect"
3327
+ *
3328
+ * Option.none().pipe(Option.orElse(() => Option.some("b"))) // => Option.some("b")
3329
+ * Option.some("a").pipe(Option.orElse(() => Option.some("b"))) // => Option.some("a")
3330
+ * ```
3331
+ *
3332
+ * @see {@link orElseSome} to wrap the fallback value in `Some` automatically
3333
+ * @see {@link firstSomeOf} to pick the first `Some` from a collection
3334
+ *
3335
+ * @stability stable
3336
+ * @category error handling
3337
+ * @since 2.0.0
3338
+ */
3339
+ const orElse = /*#__PURE__*/ dual(2, (self, that) => isNone(self) ? that() : self);
3340
+ /**
3341
+ * Returns the first `Some` found in an iterable of `Option`s, or `None` if
3342
+ * all are `None`.
3343
+ *
3344
+ * **When to use**
3345
+ *
3346
+ * Use when you need the first available `Some` value from a priority list.
3347
+ *
3348
+ * **Details**
3349
+ *
3350
+ * - Short-circuits on the first `Some`
3351
+ * - Returns `None` only when every element is `None`
3352
+ *
3353
+ * **Example** (Finding the first Some)
3354
+ *
3355
+ * ```ts import.meta.vitest
3356
+ * import { Option } from "effect"
3357
+ *
3358
+ * Option.firstSomeOf([
3359
+ * Option.none(),
3360
+ * Option.some(1),
3361
+ * Option.some(2)
3362
+ * ]) // => Option.some(1)
3363
+ * ```
3364
+ *
3365
+ * @see {@link orElse} for a two-option fallback
3366
+ *
3367
+ * @stability stable
3368
+ * @category error handling
3369
+ * @since 2.0.0
3370
+ */
3371
+ const firstSomeOf = (collection) => {
3372
+ let out = none();
3373
+ for (out of collection) if (isSome(out)) return out;
3374
+ return out;
3375
+ };
3376
+ /**
3377
+ * Converts a nullable value (`null` or `undefined`) into an `Option`.
3378
+ *
3379
+ * **When to use**
3380
+ *
3381
+ * Use when you need JavaScript nullish values to become absence at an API
3382
+ * boundary while all other values, including falsy ones, remain present.
3383
+ *
3384
+ * **Details**
3385
+ *
3386
+ * - `null` or `undefined` → `None`
3387
+ * - Any other value → `Some` (typed as `NonNullable<A>`)
3388
+ *
3389
+ * **Example** (Converting nullable values to an Option)
3390
+ *
3391
+ * ```ts import.meta.vitest
3392
+ * import { Option } from "effect"
3393
+ *
3394
+ * Option.fromNullishOr(undefined) // => Option.none()
3395
+ * Option.fromNullishOr(null) // => Option.none()
3396
+ * Option.fromNullishOr(1) // => Option.some(1)
3397
+ * ```
3398
+ *
3399
+ * @see {@link fromNullOr} to only treat `null` as absent
3400
+ * @see {@link fromUndefinedOr} to only treat `undefined` as absent
3401
+ * @see {@link liftNullishOr} to lift a nullable-returning function
3402
+ *
3403
+ * @stability stable
3404
+ * @category converting
3405
+ * @since 4.0.0
3406
+ */
3407
+ const fromNullishOr = (a) => a == null ? none() : some(a);
3408
+ /**
3409
+ * Converts a possibly `undefined` value into an `Option`, leaving `null`
3410
+ * as a valid `Some`.
3411
+ *
3412
+ * **When to use**
3413
+ *
3414
+ * Use when you want to treat only `undefined` as absent while preserving `null`
3415
+ * as a meaningful value.
3416
+ *
3417
+ * **Details**
3418
+ *
3419
+ * - `undefined` → `None`
3420
+ * - Any other value (including `null`) → `Some`
3421
+ *
3422
+ * **Example** (Converting possibly undefined values to an Option)
3423
+ *
3424
+ * ```ts import.meta.vitest
3425
+ * import { Option } from "effect"
3426
+ *
3427
+ * Option.fromUndefinedOr(undefined) // => Option.none()
3428
+ * Option.fromUndefinedOr(null) // => Option.some(null)
3429
+ * Option.fromUndefinedOr(42) // => Option.some(42)
3430
+ * ```
3431
+ *
3432
+ * @see {@link fromNullishOr} to treat both `null` and `undefined` as absent
3433
+ * @see {@link fromNullOr} to only treat `null` as absent
3434
+ *
3435
+ * @stability stable
3436
+ * @category converting
3437
+ * @since 4.0.0
3438
+ */
3439
+ const fromUndefinedOr = (a) => a === void 0 ? none() : some(a);
3440
+ /**
3441
+ * Converts a possibly `null` value into an `Option`, leaving `undefined`
3442
+ * as a valid `Some`.
3443
+ *
3444
+ * **When to use**
3445
+ *
3446
+ * Use when you want to treat only `null` as absent while preserving
3447
+ * `undefined` as a meaningful value.
3448
+ *
3449
+ * **Details**
3450
+ *
3451
+ * - `null` → `None`
3452
+ * - Any other value (including `undefined`) → `Some`
3453
+ *
3454
+ * **Example** (Converting possibly null values to an Option)
3455
+ *
3456
+ * ```ts import.meta.vitest
3457
+ * import { Option } from "effect"
3458
+ *
3459
+ * Option.fromNullOr(null) // => Option.none()
3460
+ * Option.fromNullOr(undefined) // => Option.some(undefined)
3461
+ * Option.fromNullOr(42) // => Option.some(42)
3462
+ * ```
3463
+ *
3464
+ * @see {@link fromNullishOr} to treat both `null` and `undefined` as absent
3465
+ * @see {@link fromUndefinedOr} to only treat `undefined` as absent
3466
+ *
3467
+ * @stability stable
3468
+ * @category converting
3469
+ * @since 4.0.0
3470
+ */
3471
+ const fromNullOr = (a) => a === null ? none() : some(a);
3472
+ /**
3473
+ * Extracts the value from a `Some`, or returns `null` for `None`.
3474
+ *
3475
+ * **When to use**
3476
+ *
3477
+ * Use when you need to pass absent `Option` values to APIs that expect `null`.
3478
+ *
3479
+ * **Details**
3480
+ *
3481
+ * - `Some` → the inner value
3482
+ * - `None` → `null`
3483
+ *
3484
+ * **Example** (Unwrapping to null)
3485
+ *
3486
+ * ```ts import.meta.vitest
3487
+ * import { Option } from "effect"
3488
+ *
3489
+ * Option.getOrNull(Option.some(1)) // => 1
3490
+ * Option.getOrNull(Option.none()) // => null
3491
+ * ```
3492
+ *
3493
+ * @see {@link getOrUndefined} to return `undefined` instead
3494
+ * @see {@link getOrElse} for a custom fallback
3495
+ *
3496
+ * @stability stable
3497
+ * @category getters
3498
+ * @since 2.0.0
3499
+ */
3500
+ const getOrNull = /*#__PURE__*/ getOrElse(constNull);
3501
+ /**
3502
+ * Extracts the value from a `Some`, or returns `undefined` for `None`.
3503
+ *
3504
+ * **When to use**
3505
+ *
3506
+ * Use when you need to pass absent `Option` values to APIs that expect
3507
+ * `undefined`.
3508
+ *
3509
+ * **Details**
3510
+ *
3511
+ * - `Some` → the inner value
3512
+ * - `None` → `undefined`
3513
+ *
3514
+ * **Example** (Unwrapping to undefined)
3515
+ *
3516
+ * ```ts import.meta.vitest
3517
+ * import { Option } from "effect"
3518
+ *
3519
+ * Option.getOrUndefined(Option.some(1)) // => 1
3520
+ * Option.getOrUndefined(Option.none()) // => undefined
3521
+ * ```
3522
+ *
3523
+ * @see {@link getOrNull} to return `null` instead
3524
+ * @see {@link getOrElse} for a custom fallback
3525
+ *
3526
+ * @stability stable
3527
+ * @category getters
3528
+ * @since 2.0.0
3529
+ */
3530
+ const getOrUndefined = /*#__PURE__*/ getOrElse(constUndefined);
3531
+ /**
3532
+ * Lifts a function that may throw into one that returns an `Option`.
3533
+ *
3534
+ * **When to use**
3535
+ *
3536
+ * Use to wrap exception-throwing APIs (e.g. `JSON.parse`) for safe usage
3537
+ *
3538
+ * **Details**
3539
+ *
3540
+ * - If the function returns normally → `Some` with the result
3541
+ * - If the function throws → `None` (exception is swallowed)
3542
+ *
3543
+ * **Example** (Lifting JSON.parse)
3544
+ *
3545
+ * ```ts import.meta.vitest
3546
+ * import { Option } from "effect"
3547
+ *
3548
+ * const parse = Option.liftThrowable(JSON.parse)
3549
+ *
3550
+ * parse("1") // => Option.some(1)
3551
+ * parse("") // => Option.none()
3552
+ * ```
3553
+ *
3554
+ * @see {@link liftNullishOr} for nullable-returning functions
3555
+ *
3556
+ * @stability stable
3557
+ * @category converting
3558
+ * @since 2.0.0
3559
+ */
3560
+ const liftThrowable = (f) => (...a) => {
3561
+ try {
3562
+ return some(f(...a));
3563
+ } catch {
3564
+ return none();
3565
+ }
3566
+ };
3567
+ /**
3568
+ * Transforms the value inside a `Some` using the provided function, leaving
3569
+ * `None` unchanged.
3570
+ *
3571
+ * **When to use**
3572
+ *
3573
+ * Use to apply a pure transformation to an `Option`'s present value, especially
3574
+ * when chaining transformations in a pipeline.
3575
+ *
3576
+ * **Details**
3577
+ *
3578
+ * - `Some` → applies `f` and wraps the result in a new `Some`
3579
+ * - `None` → returns `None` unchanged
3580
+ *
3581
+ * **Example** (Mapping over an Option)
3582
+ *
3583
+ * ```ts import.meta.vitest
3584
+ * import { Option } from "effect"
3585
+ *
3586
+ * Option.map(Option.some(2), (n) => n * 2) // => Option.some(4)
3587
+ * Option.map(Option.none(), (n: number) => n * 2) // => Option.none()
3588
+ * ```
3589
+ *
3590
+ * @see {@link flatMap} when `f` returns an `Option`
3591
+ * @see {@link as} to replace the value with a constant
3592
+ *
3593
+ * @stability stable
3594
+ * @category mapping
3595
+ * @since 2.0.0
3596
+ */
3597
+ const map = /*#__PURE__*/ dual(2, (self, f) => isNone(self) ? none() : some(f(self.value)));
3598
+ /**
3599
+ * Applies a function that returns an `Option` to the value of a `Some`,
3600
+ * flattening the result. Returns `None` if the input is `None`.
3601
+ *
3602
+ * **When to use**
3603
+ *
3604
+ * Use when you need to chain dependent `Option` computations where each step
3605
+ * may return `None`.
3606
+ *
3607
+ * **Details**
3608
+ *
3609
+ * - `Some` → applies `f` to the value and returns its `Option` result
3610
+ * - `None` → returns `None` without calling `f`
3611
+ * - Equivalent to `map` followed by {@link flatten}
3612
+ *
3613
+ * **Example** (Chaining optional lookups)
3614
+ *
3615
+ * ```ts import.meta.vitest
3616
+ * import { Option } from "effect"
3617
+ *
3618
+ * interface User {
3619
+ * readonly name: string
3620
+ * readonly address: Option.Option<{ readonly street: Option.Option<string> }>
3621
+ * }
3622
+ *
3623
+ * const user: User = {
3624
+ * name: "John",
3625
+ * address: Option.some({ street: Option.some("123 Main St") })
3626
+ * }
3627
+ *
3628
+ * user.address.pipe(
3629
+ * Option.flatMap((addr) => addr.street)
3630
+ * ) // => Option.some("123 Main St")
3631
+ * ```
3632
+ *
3633
+ * @see {@link map} when `f` returns a plain value
3634
+ * @see {@link andThen} for a more flexible variant
3635
+ * @see {@link flatten} to unwrap a nested `Option<Option<A>>`
3636
+ *
3637
+ * @stability stable
3638
+ * @category sequencing
3639
+ * @since 2.0.0
3640
+ */
3641
+ const flatMap = /*#__PURE__*/ dual(2, (self, f) => isNone(self) ? none() : f(self.value));
3642
+ /**
3643
+ * Combines {@link flatMap} with {@link fromNullishOr}: applies a function that
3644
+ * may return `null`/`undefined` to the value of a `Some`.
3645
+ *
3646
+ * **When to use**
3647
+ *
3648
+ * Use when you need to chain optional computations that use `null` or
3649
+ * `undefined` instead of `Option`, such as nested property access.
3650
+ *
3651
+ * **Details**
3652
+ *
3653
+ * - `None` → `None`
3654
+ * - `Some` → applies `f`, then wraps via {@link fromNullishOr}
3655
+ *
3656
+ * **Example** (Navigating optional properties)
3657
+ *
3658
+ * ```ts import.meta.vitest
3659
+ * import { Option } from "effect"
3660
+ *
3661
+ * interface Employee {
3662
+ * company?: { address?: { street?: { name?: string } } }
3663
+ * }
3664
+ *
3665
+ * const emp: Employee = {
3666
+ * company: { address: { street: { name: "high street" } } }
3667
+ * }
3668
+ *
3669
+ * Option.some(emp).pipe(
3670
+ * Option.flatMapNullishOr((e) => e.company?.address?.street?.name)
3671
+ * ) // => Option.some("high street")
3672
+ * ```
3673
+ *
3674
+ * @see {@link flatMap} when the function already returns `Option`
3675
+ * @see {@link fromNullishOr} for single-value conversion
3676
+ *
3677
+ * @stability stable
3678
+ * @category sequencing
3679
+ * @since 4.0.0
3680
+ */
3681
+ const flatMapNullishOr = /*#__PURE__*/ dual(2, (self, f) => isNone(self) ? none() : fromNullishOr(f(self.value)));
3682
+ /**
3683
+ * Flattens a nested `Option<Option<A>>` into `Option<A>`.
3684
+ *
3685
+ * **When to use**
3686
+ *
3687
+ * Use when you need to remove one layer of nested `Option`.
3688
+ *
3689
+ * **Details**
3690
+ *
3691
+ * - `Some(Some(value))` → `Some(value)`
3692
+ * - `Some(None)` → `None`
3693
+ * - `None` → `None`
3694
+ *
3695
+ * **Example** (Flattening nested Options)
3696
+ *
3697
+ * ```ts import.meta.vitest
3698
+ * import { Option } from "effect"
3699
+ *
3700
+ * Option.flatten(Option.some(Option.some("value"))) // => Option.some("value")
3701
+ * Option.flatten(Option.some(Option.none())) // => Option.none()
3702
+ * ```
3703
+ *
3704
+ * @see {@link flatMap} which is `map` + `flatten`
3705
+ *
3706
+ * @stability stable
3707
+ * @category sequencing
3708
+ * @since 2.0.0
3709
+ */
3710
+ const flatten = /*#__PURE__*/ flatMap(identity);
3711
+ /**
3712
+ * Combines a structure of `Option`s (tuple, struct, or iterable) into a single
3713
+ * `Option` containing the unwrapped structure.
3714
+ *
3715
+ * **When to use**
3716
+ *
3717
+ * Use when you need to combine multiple `Option` values into one while
3718
+ * preserving the input shape, with any `None` making the result `None`.
3719
+ *
3720
+ * **Details**
3721
+ *
3722
+ * - Tuple input → `Option` of a tuple with the same length
3723
+ * - Struct input → `Option` of a struct with the same keys
3724
+ * - Iterable input → `Option` of an `Array`
3725
+ * - Any `None` in the input → entire result is `None`
3726
+ *
3727
+ * **Example** (Combining a tuple and a struct)
3728
+ *
3729
+ * ```ts import.meta.vitest
3730
+ * import { Option } from "effect"
3731
+ *
3732
+ * const maybeName: Option.Option<string> = Option.some("John")
3733
+ * const maybeAge: Option.Option<number> = Option.some(25)
3734
+ *
3735
+ * // ┌─── Option<[string, number]>
3736
+ * // ▼
3737
+ * const tuple = Option.all([maybeName, maybeAge]) // => Option.some(["John", 25])
3738
+ *
3739
+ * // ┌─── Option<{ name: string; age: number; }>
3740
+ * // ▼
3741
+ * const struct = Option.all({ name: maybeName, age: maybeAge }) // => Option.some({ name: "John", age: 25 })
3742
+ * ```
3743
+ *
3744
+ * @see {@link product} for combining exactly two
3745
+ * @see {@link productMany} for a homogeneous collection
3746
+ *
3747
+ * @stability stable
3748
+ * @category combining
3749
+ * @since 2.0.0
3750
+ */
3751
+ const all = (input) => {
3752
+ if (Symbol.iterator in input) {
3753
+ const out = [];
3754
+ for (const o of input) {
3755
+ if (isNone(o)) return none();
3756
+ out.push(o.value);
3757
+ }
3758
+ return some(out);
3759
+ }
3760
+ const out = {};
3761
+ for (const key of Object.keys(input)) {
3762
+ const o = input[key];
3763
+ if (isNone(o)) return none();
3764
+ assignProperty(out, key, o.value);
3765
+ }
3766
+ return some(out);
3767
+ };
3768
+ /**
3769
+ * Converts an `Option` into an `Array`.
3770
+ *
3771
+ * **When to use**
3772
+ *
3773
+ * Use when you need to pass an `Option` to array-based APIs or spread optional
3774
+ * values into collections.
3775
+ *
3776
+ * **Details**
3777
+ *
3778
+ * - `Some` → single-element array `[value]`
3779
+ * - `None` → empty array `[]`
3780
+ *
3781
+ * **Example** (Converting to an array)
3782
+ *
3783
+ * ```ts import.meta.vitest
3784
+ * import { Option } from "effect"
3785
+ *
3786
+ * Option.toArray(Option.some(1)) // => [1]
3787
+ * Option.toArray(Option.none()) // => []
3788
+ * ```
3789
+ *
3790
+ * @see {@link fromIterable} for the inverse direction
3791
+ *
3792
+ * @stability stable
3793
+ * @category converting
3794
+ * @since 2.0.0
3795
+ */
3796
+ const toArray = (self) => isNone(self) ? [] : [self.value];
3797
+ /**
3798
+ * Filters an `Option` using a predicate. Returns `None` if the predicate is
3799
+ * not satisfied or the input is `None`.
3800
+ *
3801
+ * **When to use**
3802
+ *
3803
+ * Use when you need to discard an `Option`'s present value when it does not
3804
+ * meet a condition, while narrowing the type via a refinement predicate.
3805
+ *
3806
+ * **Details**
3807
+ *
3808
+ * - `None` → `None`
3809
+ * - `Some` where `predicate(value)` is `true` → `Some(value)`
3810
+ * - `Some` where `predicate(value)` is `false` → `None`
3811
+ * - Supports refinements for type narrowing
3812
+ *
3813
+ * **Example** (Filtering with a predicate)
3814
+ *
3815
+ * ```ts import.meta.vitest
3816
+ * import { Option } from "effect"
3817
+ *
3818
+ * const removeEmpty = (input: Option.Option<string>) =>
3819
+ * Option.filter(input, (value) => value !== "")
3820
+ *
3821
+ * removeEmpty(Option.some("hello")) // => Option.some("hello")
3822
+ * removeEmpty(Option.some("")) // => Option.none()
3823
+ * removeEmpty(Option.none()) // => Option.none()
3824
+ * ```
3825
+ *
3826
+ * @see {@link filterMap} to transform and filter simultaneously
3827
+ * @see {@link exists} to test without filtering
3828
+ *
3829
+ * @stability stable
3830
+ * @category filtering
3831
+ * @since 2.0.0
3832
+ */
3833
+ const filter = /*#__PURE__*/ dual(2, (self, predicate) => isNone(self) ? none() : predicate(self.value) ? some(self.value) : none());
3834
+ /**
3835
+ * Lifts a `Predicate` or `Refinement` into the `Option` context: returns
3836
+ * `Some(value)` when the predicate holds, `None` otherwise.
3837
+ *
3838
+ * **When to use**
3839
+ *
3840
+ * Use to convert a boolean check into an `Option`-returning function
3841
+ * - Validating input and wrapping it in `Option`
3842
+ *
3843
+ * **Details**
3844
+ *
3845
+ * - `predicate(value)` is `true` → `Some(value)`
3846
+ * - `predicate(value)` is `false` → `None`
3847
+ * - Supports refinements for type narrowing
3848
+ *
3849
+ * **Example** (Validating positive numbers)
3850
+ *
3851
+ * ```ts import.meta.vitest
3852
+ * import { Option } from "effect"
3853
+ *
3854
+ * const parsePositive = Option.liftPredicate((n: number) => n > 0)
3855
+ *
3856
+ * parsePositive(1) // => Option.some(1)
3857
+ * parsePositive(-1) // => Option.none()
3858
+ * ```
3859
+ *
3860
+ * @see {@link filter} to apply a predicate to an existing `Option`
3861
+ * @see {@link toRefinement} for the inverse direction
3862
+ *
3863
+ * @stability stable
3864
+ * @category lifting
3865
+ * @since 2.0.0
3866
+ */
3867
+ const liftPredicate = /*#__PURE__*/ dual(2, (b, predicate) => predicate(b) ? some(b) : none());
3868
+ /**
3869
+ * Checks whether an `Option` contains a value equivalent to the given one, using a
3870
+ * custom `Equivalence`.
3871
+ *
3872
+ * **When to use**
3873
+ *
3874
+ * Use when you need to test whether an `Option` contains a value using a
3875
+ * custom equality check.
3876
+ *
3877
+ * **Details**
3878
+ *
3879
+ * - `Some` where `isEquivalent(value, a)` is `true` → `true`
3880
+ * - `Some` where not equivalent, or `None` → `false`
3881
+ *
3882
+ * **Example** (Checking with custom equivalence)
3883
+ *
3884
+ * ```ts import.meta.vitest
3885
+ * import { Equivalence, Option } from "effect"
3886
+ *
3887
+ * const check = Option.containsWith(Equivalence.strictEqual<number>())
3888
+ *
3889
+ * Option.some(2).pipe(check(2)) // => true
3890
+ * Option.some(1).pipe(check(2)) // => false
3891
+ * Option.none().pipe(check(2)) // => false
3892
+ * ```
3893
+ *
3894
+ * @see {@link contains} for a version using default equality
3895
+ *
3896
+ * @stability stable
3897
+ * @category predicates
3898
+ * @since 2.0.0
3899
+ */
3900
+ const containsWith = (isEquivalent) => dual(2, (self, a) => isNone(self) ? false : isEquivalent(self.value, a));
3901
+ /**
3902
+ * Checks whether an `Option` contains a value equal to the given one, using default
3903
+ * structural equality.
3904
+ *
3905
+ * **When to use**
3906
+ *
3907
+ * Use when you need a quick membership test for an `Option` value using
3908
+ * standard equality.
3909
+ *
3910
+ * **Details**
3911
+ *
3912
+ * - `Some` where `Equal.equals(value, a)` is `true` → `true`
3913
+ * - `Some` where not equal, or `None` → `false`
3914
+ *
3915
+ * **Example** (Checking containment)
3916
+ *
3917
+ * ```ts import.meta.vitest
3918
+ * import { Option } from "effect"
3919
+ *
3920
+ * Option.some(2).pipe(Option.contains(2)) // => true
3921
+ * Option.some(1).pipe(Option.contains(2)) // => false
3922
+ * Option.none().pipe(Option.contains(2)) // => false
3923
+ * ```
3924
+ *
3925
+ * @see {@link containsWith} for custom equality
3926
+ * @see {@link exists} to test with a predicate
3927
+ *
3928
+ * @stability stable
3929
+ * @category predicates
3930
+ * @since 2.0.0
3931
+ */
3932
+ const contains = /*#__PURE__*/ containsWith(/*#__PURE__*/ asEquivalence());
3933
+ /**
3934
+ * Checks whether the value in a `Some` satisfies a predicate or refinement.
3935
+ *
3936
+ * **When to use**
3937
+ *
3938
+ * Use to check a condition on an optional value without unwrapping
3939
+ *
3940
+ * **Details**
3941
+ *
3942
+ * - `None` → `false`
3943
+ * - `Some` where `predicate(value)` is `true` → `true`
3944
+ * - `Some` where `predicate(value)` is `false` → `false`
3945
+ * - With a refinement, narrows the `Option` type on `true`
3946
+ *
3947
+ * **Example** (Testing a condition)
3948
+ *
3949
+ * ```ts import.meta.vitest
3950
+ * import { Option } from "effect"
3951
+ *
3952
+ * const isEven = (n: number) => n % 2 === 0
3953
+ *
3954
+ * Option.some(2).pipe(Option.exists(isEven)) // => true
3955
+ * Option.some(1).pipe(Option.exists(isEven)) // => false
3956
+ * Option.none().pipe(Option.exists(isEven)) // => false
3957
+ * ```
3958
+ *
3959
+ * @see {@link filter} to keep or discard based on a predicate
3960
+ * @see {@link contains} to test for a specific value
3961
+ *
3962
+ * @stability stable
3963
+ * @category predicates
3964
+ * @since 2.0.0
3965
+ */
3966
+ const exists = /*#__PURE__*/ dual(2, (self, refinement) => isNone(self) ? false : refinement(self.value));
3967
+ export { evaluate as $, isNever as $t, Error$1 as A, formatPropertyKey as At, args as B, hash as Bt, orElse as C, memoize as Cn, NodeInspectSymbol as Ct, CauseImpl as D, Prototype as Dn, formatDate as Dt, isNone$1 as E, Class$1 as En, format as Et, PipeInspectableProto as F, byReferenceUnsafe as Ft, causeEmpty as G, structureKeys as Gt, causeAnnotate as H, optimize as Ht, ReasonBase as I, equals as It, constEmptyAnnotations as J, isBigInt as Jt, causeFail as K, symbol$1 as Kt, StackTraceKey as L, symbol as Lt, Fail as M, redact as Mt, InterruptorStackTrace as N, symbolRedactable as Nt, Die as O, pipeArguments as On, formatJson as Ot, NoSuchElementError as P, asEquivalence as Pt, done as Q, isIterable as Qt, TaggedError as R, array as Rt, none as S, identity as Sn, Class as St, toArray as T, pipe as Tn, toStringUnknown as Tt, causeCombine as U, string as Ut, causeAddInterrupts as V, number as Vt, causeDie as W, structure as Wt, contAll as X, isError as Xt, contA as Y, isBoolean as Yt, contE as Z, isFunction as Zt, isSome as _, constUndefined as _n, SingleShotGen as _t, firstSomeOf as a, isObject as an, isCauseReason as at, map as b, dual as bn, setStackTraceLimit as bt, flatten as c, isString as cn, isEffect as ct, fromUndefinedOr as d, isUndefined as dn, isInterruptReason as dt, isNotNull as en, exitDie as et, getOrElse as f, isUnknown as fn, makePrimitive as ft, isOption as g, constTrue as gn, assignProperty as gt, isNone as h, constFalse as hn, assignProperties as ht, filter as i, isNumber as in, isCause as it, ExitTypeId as j, currentFiberTypeId as jt, Done as k, formatPath as kt, fromNullOr as l, isSymbol as ln, isExit as lt, getOrUndefined as m, backEdges as mn, withFiber as mt, contains as n, isNotUndefined as nn, exitFailCause as nt, flatMap as o, isObjectKeyword as on, isDieReason as ot, getOrNull as p, or as pn, makePrimitiveProto as pt, causeFromReasons as q, hasProperty as qt, exists as r, isNullish as rn, exitSucceed as rt, flatMapNullishOr as s, isPropertyKey as sn, isDone as st, all as t, isNotNullish as tn, exitFail as tt, fromNullishOr as u, isTagged as un, isFailReason as ut, liftPredicate as v, constVoid as vn, internalCall as vt, some as w, memoizeIdempotent as wn, toJson as wt, match as x, flow as xn, BaseProto as xt, liftThrowable as y, constant as yn, getStackTraceLimit as yt, Yield as z, combine as zt };