@akterjs/cli 0.0.0-stage → 0.1.1

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 (109) 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-D8yb9xQP.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-D2amjsje.mjs +190 -0
  76. package/dist/docs.config-D3zzLzLR.mjs +190 -0
  77. package/dist/export/actor-export.service.mjs +267 -0
  78. package/dist/export/export-failed.errors.mjs +4 -0
  79. package/dist/export/export-failure.pure.mjs +18 -0
  80. package/dist/export/ordered-lines.pure.mjs +43 -0
  81. package/dist/export/ranged-download.pure.mjs +66 -0
  82. package/dist/export/snapshot-download.pure.mjs +86 -0
  83. package/dist/history-runner.pure.mjs +186 -0
  84. package/dist/history-since.pure.mjs +17 -0
  85. package/dist/hosted-runtime.layer-Cx3IPsEd.mjs +16358 -0
  86. package/dist/local/environment-cli.config.mjs +90 -0
  87. package/dist/local/environment-runner.pure.mjs +75 -0
  88. package/dist/local/local-cli.config.mjs +159 -0
  89. package/dist/logs/log-follow.config.mjs +21 -0
  90. package/dist/logs/log-follow.service.mjs +87 -0
  91. package/dist/logs/log-lines.pure.mjs +44 -0
  92. package/dist/migrate-runner.pure.mjs +28 -0
  93. package/dist/operation-input.pure-CS9iUhqK.mjs +1383 -0
  94. package/dist/operation-registry.pure-DVC8EDgj.mjs +283 -0
  95. package/dist/registry/actor-call.service.mjs +1 -0
  96. package/dist/registry/actor-commands.config.mjs +127 -0
  97. package/dist/registry/actor-refusal.pure.mjs +34 -0
  98. package/dist/registry/approval.service.mjs +80 -0
  99. package/dist/registry/cloud-commands.config.mjs +151 -0
  100. package/dist/registry/cloud-served.pure.mjs +31 -0
  101. package/dist/registry/operation-call.service.mjs +262 -0
  102. package/dist/registry/operation-input.pure.mjs +1 -0
  103. package/dist/registry/operation-output.pure.mjs +91 -0
  104. package/dist/registry/served-command.config.mjs +57 -0
  105. package/dist/runner-exited.errors.mjs +10 -0
  106. package/dist/terminal/cli-exit.errors.mjs +38 -0
  107. package/dist/terminal/cli-failure.pure.mjs +31 -0
  108. package/dist/terminal/confirm.adapter.mjs +27 -0
  109. package/package.json +61 -3
@@ -0,0 +1,2323 @@
1
+ import { Bt as hash, E as isNone, Et as format, F as PipeInspectableProto, It as equals, Kt as symbol$1, Lt as symbol, Pt as asEquivalence, S as none, Sn as identity, Yt as isBoolean, Zt as isFunction, _ as isSome, _t as SingleShotGen, bn as dual, gt as assignProperty, h as isNone$1, qt as hasProperty, w as some$1, wt as toJson, zt as combine } from "./Option-DkxSnBhp.mjs";
2
+ import { m as min$1 } from "./Order-C1JC991I.mjs";
3
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/Equivalence.js
4
+ /**
5
+ * Creates a custom equivalence relation with an optimized reference equality check.
6
+ *
7
+ * **When to use**
8
+ *
9
+ * Use when you need an equality rule that the built-in instances and input
10
+ * mapping helpers cannot express, and you can provide a law-abiding comparison.
11
+ *
12
+ * **Details**
13
+ *
14
+ * The returned equivalence first checks reference equality (`===`) for
15
+ * performance. If the values are not the same reference, it falls back to the
16
+ * provided equivalence function, which must satisfy reflexive, symmetric, and
17
+ * transitive properties.
18
+ *
19
+ * **Example** (Case-insensitive string equivalence)
20
+ *
21
+ * ```ts import.meta.vitest
22
+ * import { Equivalence } from "effect"
23
+ *
24
+ * const caseInsensitive = Equivalence.make<string>((a, b) =>
25
+ * a.toLowerCase() === b.toLowerCase()
26
+ * )
27
+ *
28
+ * caseInsensitive("Hello", "HELLO") // => true
29
+ * caseInsensitive("foo", "bar") // => false
30
+ *
31
+ * // Same reference optimization
32
+ * const str = "test"
33
+ * caseInsensitive(str, str) // => true
34
+ * ```
35
+ *
36
+ * **Example** (Comparing numbers with tolerance)
37
+ *
38
+ * ```ts import.meta.vitest
39
+ * import { Equivalence } from "effect"
40
+ *
41
+ * const tolerance = Equivalence.make<number>((a, b) => Math.abs(a - b) < 0.0001)
42
+ *
43
+ * tolerance(1.0, 1.001) // => false
44
+ * tolerance(1.0, 1.00001) // => true
45
+ * ```
46
+ *
47
+ * @see {@link strictEqual}
48
+ * @see {@link mapInput}
49
+ * @stability stable
50
+ * @category constructors
51
+ * @since 2.0.0
52
+ */
53
+ const make$1 = (isEquivalent) => (self, that) => self === that || isEquivalent(self, that);
54
+ const isStrictEquivalent = (x, y) => x === y;
55
+ /**
56
+ * Creates an equivalence relation that uses strict equality (`===`) to compare values.
57
+ *
58
+ * **When to use**
59
+ *
60
+ * Use when you need strict equality (`===`) as the comparison.
61
+ *
62
+ * **Details**
63
+ *
64
+ * Uses JavaScript's strict equality operator (`===`). Primitives compare by
65
+ * value. Objects compare by reference, so only the same object instance is
66
+ * equivalent. Use this as a building block for more complex equivalences via
67
+ * `mapInput` or `combine`.
68
+ *
69
+ * **Gotchas**
70
+ *
71
+ * `NaN !== NaN`, so `NaN` values are never considered equivalent.
72
+ *
73
+ * **Example** (Comparing primitive types)
74
+ *
75
+ * ```ts import.meta.vitest
76
+ * import { Equivalence } from "effect"
77
+ *
78
+ * const strictEq = Equivalence.strictEqual<number>()
79
+ *
80
+ * strictEq(1, 1) // => true
81
+ * strictEq(1, 2) // => false
82
+ * strictEq(NaN, NaN) // => false
83
+ * ```
84
+ *
85
+ * **Example** (Comparing objects by reference)
86
+ *
87
+ * ```ts import.meta.vitest
88
+ * import { Equivalence } from "effect"
89
+ *
90
+ * const obj = { value: 42 }
91
+ * const strictObjEq = Equivalence.strictEqual<typeof obj>()
92
+ *
93
+ * strictObjEq(obj, obj) // => true
94
+ * strictObjEq(obj, { value: 42 }) // => false
95
+ * ```
96
+ *
97
+ * @see {@link make}
98
+ * @see `Equal` for structural equality
99
+ * @stability stable
100
+ * @category constructors
101
+ * @since 4.0.0
102
+ */
103
+ const strictEqual = () => isStrictEquivalent;
104
+ /**
105
+ * Creates an equivalence for tuples with heterogeneous element types.
106
+ *
107
+ * **When to use**
108
+ *
109
+ * Use when you need an `Equivalence` for fixed-length tuples with per-position
110
+ * equivalences.
111
+ *
112
+ * **Details**
113
+ *
114
+ * Tuples must have the same length; different lengths are never equivalent.
115
+ * Each equivalence is applied to the corresponding element position. The result
116
+ * returns `true` only if all elements are equivalent according to their
117
+ * respective equivalences, and it also satisfies reflexive, symmetric, and
118
+ * transitive properties.
119
+ *
120
+ * **Example** (Comparing homogeneous tuples)
121
+ *
122
+ * ```ts import.meta.vitest
123
+ * import { Equivalence } from "effect"
124
+ *
125
+ * const stringTupleEq = Equivalence.Tuple([
126
+ * Equivalence.strictEqual<string>(),
127
+ * Equivalence.strictEqual<string>(),
128
+ * Equivalence.strictEqual<string>()
129
+ * ])
130
+ *
131
+ * const tuple1 = ["hello", "world", "test"] as const
132
+ * const tuple2 = ["hello", "world", "test"] as const
133
+ * const tuple3 = ["hello", "world", "different"] as const
134
+ *
135
+ * stringTupleEq(tuple1, tuple2) // => true
136
+ * stringTupleEq(tuple1, tuple3) // => false
137
+ * ```
138
+ *
139
+ * **Example** (Comparing tuples with custom equivalences)
140
+ *
141
+ * ```ts import.meta.vitest
142
+ * import { Equivalence } from "effect"
143
+ *
144
+ * const caseInsensitive = Equivalence.mapInput(
145
+ * Equivalence.strictEqual<string>(),
146
+ * (s: string) => s.toLowerCase()
147
+ * )
148
+ *
149
+ * const customTupleEq = Equivalence.Tuple([
150
+ * caseInsensitive,
151
+ * caseInsensitive,
152
+ * caseInsensitive
153
+ * ])
154
+ *
155
+ * customTupleEq(["Hello", "World", "Test"], ["HELLO", "WORLD", "TEST"]) // => true
156
+ * ```
157
+ *
158
+ * @stability stable
159
+ * @category combinators
160
+ * @since 4.0.0
161
+ */
162
+ function Tuple(elements) {
163
+ return make$1((self, that) => {
164
+ if (self.length !== that.length) return false;
165
+ for (let i = 0; i < self.length; i++) if (!elements[i](self[i], that[i])) return false;
166
+ return true;
167
+ });
168
+ }
169
+ /**
170
+ * @since 4.0.0
171
+ */
172
+ function Array_(item) {
173
+ return make$1((self, that) => {
174
+ if (self.length !== that.length) return false;
175
+ for (let i = 0; i < self.length; i++) if (!item(self[i], that[i])) return false;
176
+ return true;
177
+ });
178
+ }
179
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/internal/result.js
180
+ const TypeId = "~effect/Result";
181
+ const CommonProto = {
182
+ [TypeId]: {
183
+ /* v8 ignore next 2 */
184
+ _A: (_) => _,
185
+ _E: (_) => _
186
+ },
187
+ ...PipeInspectableProto,
188
+ [Symbol.iterator]() {
189
+ return new SingleShotGen(this);
190
+ }
191
+ };
192
+ const SuccessProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(CommonProto), {
193
+ _tag: "Success",
194
+ _op: "Success",
195
+ [symbol](that) {
196
+ return isResult$1(that) && isSuccess$1(that) && equals(this.success, that.success);
197
+ },
198
+ [symbol$1]() {
199
+ return combine(hash(this._tag))(hash(this.success));
200
+ },
201
+ toString() {
202
+ return `success(${format(this.success)})`;
203
+ },
204
+ toJSON() {
205
+ return {
206
+ _id: "Result",
207
+ _tag: this._tag,
208
+ value: toJson(this.success)
209
+ };
210
+ }
211
+ });
212
+ const FailureProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(CommonProto), {
213
+ _tag: "Failure",
214
+ _op: "Failure",
215
+ [symbol](that) {
216
+ return isResult$1(that) && isFailure$1(that) && equals(this.failure, that.failure);
217
+ },
218
+ [symbol$1]() {
219
+ return combine(hash(this._tag))(hash(this.failure));
220
+ },
221
+ toString() {
222
+ return `failure(${format(this.failure)})`;
223
+ },
224
+ toJSON() {
225
+ return {
226
+ _id: "Result",
227
+ _tag: this._tag,
228
+ failure: toJson(this.failure)
229
+ };
230
+ }
231
+ });
232
+ /** @internal */
233
+ const isResult$1 = (input) => hasProperty(input, TypeId);
234
+ /** @internal */
235
+ const isFailure$1 = (result) => result._tag === "Failure";
236
+ /** @internal */
237
+ const isSuccess$1 = (result) => result._tag === "Success";
238
+ /** @internal */
239
+ const FailureImpl = function(failure) {
240
+ this.failure = failure;
241
+ };
242
+ FailureImpl.prototype = FailureProto;
243
+ /** @internal */
244
+ const fail$1 = (failure) => new FailureImpl(failure);
245
+ /** @internal */
246
+ const SuccessImpl = function(success) {
247
+ this.success = success;
248
+ };
249
+ SuccessImpl.prototype = SuccessProto;
250
+ /** @internal */
251
+ const succeed$1 = (success) => new SuccessImpl(success);
252
+ /** @internal */
253
+ const fromOption$1 = /*#__PURE__*/ dual(2, (self, onNone) => isNone(self) ? fail$1(onNone()) : succeed$1(self.value));
254
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/internal/array.js
255
+ /**
256
+ * @since 2.0.0
257
+ */
258
+ /** @internal */
259
+ const isArrayNonEmpty$1 = (self) => self.length > 0;
260
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/internal/count.js
261
+ /**
262
+ * Normalizes a collection count to a non-negative integer. `NaN` and
263
+ * non-positive values become `0`; positive infinity is preserved.
264
+ *
265
+ * @internal
266
+ */
267
+ const normalize = (n) => n > 0 ? Math.floor(n) : 0;
268
+ /**
269
+ * Normalizes a collection count to an integer greater than or equal to `1`.
270
+ *
271
+ * @internal
272
+ */
273
+ const normalizeNonEmpty = (n) => Math.max(1, normalize(n));
274
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/Result.js
275
+ /**
276
+ * Creates a `Result` holding a `Success` value.
277
+ *
278
+ * **Details**
279
+ *
280
+ * - Use when you have a value and want to lift it into the `Result` type
281
+ * - The error type `E` defaults to `never`
282
+ *
283
+ * **Example** (Wrapping a value)
284
+ *
285
+ * ```ts import.meta.vitest
286
+ * import { Result } from "effect"
287
+ *
288
+ * Result.succeed(42) // => Result.succeed(42)
289
+ * ```
290
+ *
291
+ * @see {@link fail} to create a Failure
292
+ * @see {@link void_ void} for a pre-built `Success<void>`
293
+ *
294
+ * @stability stable
295
+ * @category constructors
296
+ * @since 4.0.0
297
+ */
298
+ const succeed = succeed$1;
299
+ /**
300
+ * Creates a `Result` holding a `Failure` value.
301
+ *
302
+ * **When to use**
303
+ *
304
+ * Use to represent a failed `Result` with a typed failure value.
305
+ *
306
+ * **Details**
307
+ *
308
+ * - The success type `A` defaults to `never`
309
+ *
310
+ * **Example** (Creating a failure)
311
+ *
312
+ * ```ts import.meta.vitest
313
+ * import { Result } from "effect"
314
+ *
315
+ * Result.fail("Something went wrong") // => Result.fail("Something went wrong")
316
+ * ```
317
+ *
318
+ * @see {@link succeed} to create a Success
319
+ * @see {@link mapError} to transform the error
320
+ *
321
+ * @stability stable
322
+ * @category constructors
323
+ * @since 4.0.0
324
+ */
325
+ const fail = fail$1;
326
+ /**
327
+ * Converts an `Option<A>` into a `Result<A, E>`.
328
+ *
329
+ * **When to use**
330
+ *
331
+ * Use when an existing `Option` should become a `Result`, preserving `Some` as
332
+ * success and turning `None` into a caller-provided failure.
333
+ *
334
+ * **Details**
335
+ *
336
+ * - `Some<A>` becomes `Success<A>`
337
+ * - `None` becomes `Failure<E>` using the provided function
338
+ * - Supports both data-first and data-last (piped) usage
339
+ *
340
+ * **Example** (Converting an Option to a Result)
341
+ *
342
+ * ```ts import.meta.vitest
343
+ * import { Option, Result } from "effect"
344
+ *
345
+ * Result.fromOption(Option.some(1), () => "missing") // => Result.succeed(1)
346
+ *
347
+ * Result.fromOption(Option.none(), () => "missing") // => Result.fail("missing")
348
+ * ```
349
+ *
350
+ * @see {@link getSuccess} to extract the success value as an Option
351
+ * @see {@link getFailure} to extract the failure value as an Option
352
+ * @see {@link fromNullishOr} to build a Result from nullable values
353
+ *
354
+ * @stability stable
355
+ * @category constructors
356
+ * @since 2.0.0
357
+ */
358
+ const fromOption = fromOption$1;
359
+ const try_ = (evaluate) => {
360
+ if (isFunction(evaluate)) try {
361
+ return succeed(evaluate());
362
+ } catch (e) {
363
+ return fail(e);
364
+ }
365
+ else try {
366
+ return succeed(evaluate.try());
367
+ } catch (e) {
368
+ return fail(evaluate.catch(e));
369
+ }
370
+ };
371
+ /**
372
+ * Checks whether a value is a `Result` (either `Success` or `Failure`).
373
+ *
374
+ * **When to use**
375
+ *
376
+ * Use to validate unknown input before operating on it as a `Result`.
377
+ *
378
+ * **Details**
379
+ *
380
+ * - Returns `true` for both `Success` and `Failure` variants
381
+ * - Acts as a TypeScript type guard, narrowing to `Result<unknown, unknown>`
382
+ *
383
+ * **Example** (Checking if a value is a Result)
384
+ *
385
+ * ```ts import.meta.vitest
386
+ * import { Result } from "effect"
387
+ *
388
+ * Result.isResult(Result.succeed(1)) // => true
389
+ *
390
+ * Result.isResult({ value: 1 }) // => false
391
+ * ```
392
+ *
393
+ * @see {@link isSuccess} / {@link isFailure} to narrow to a specific variant
394
+ *
395
+ * @stability stable
396
+ * @category guards
397
+ * @since 4.0.0
398
+ */
399
+ const isResult = isResult$1;
400
+ /**
401
+ * Checks whether a `Result` is a `Failure`.
402
+ *
403
+ * **When to use**
404
+ *
405
+ * Use to narrow a known `Result` to the `Failure` variant.
406
+ *
407
+ * **Details**
408
+ *
409
+ * - Acts as a TypeScript type guard, narrowing to `Failure<A, E>`
410
+ * - After narrowing, you can access `.failure` to read the error value
411
+ *
412
+ * **Example** (Narrowing to failure)
413
+ *
414
+ * ```ts import.meta.vitest
415
+ * import { Result } from "effect"
416
+ *
417
+ * const result = Result.fail("oops")
418
+ *
419
+ * if (Result.isFailure(result)) {
420
+ * result.failure // => "oops"
421
+ * }
422
+ * ```
423
+ *
424
+ * @see {@link isSuccess} for the opposite check
425
+ * @see {@link isResult} to check if a value is any Result
426
+ *
427
+ * @stability stable
428
+ * @category guards
429
+ * @since 4.0.0
430
+ */
431
+ const isFailure = isFailure$1;
432
+ /**
433
+ * Checks whether a `Result` is a `Success`.
434
+ *
435
+ * **When to use**
436
+ *
437
+ * Use to narrow a known `Result` to the `Success` variant.
438
+ *
439
+ * **Details**
440
+ *
441
+ * - Acts as a TypeScript type guard, narrowing to `Success<A, E>`
442
+ * - After narrowing, you can access `.success` to read the value
443
+ *
444
+ * **Example** (Narrowing to success)
445
+ *
446
+ * ```ts import.meta.vitest
447
+ * import { Result } from "effect"
448
+ *
449
+ * const result = Result.succeed(42)
450
+ *
451
+ * if (Result.isSuccess(result)) {
452
+ * result.success // => 42
453
+ * }
454
+ * ```
455
+ *
456
+ * @see {@link isFailure} for the opposite check
457
+ * @see {@link isResult} to check if a value is any Result
458
+ *
459
+ * @stability stable
460
+ * @category guards
461
+ * @since 4.0.0
462
+ */
463
+ const isSuccess = isSuccess$1;
464
+ /**
465
+ * Transforms the failure channel of a `Result`, leaving the success channel unchanged.
466
+ *
467
+ * **When to use**
468
+ *
469
+ * Use to transform only the failure channel while preserving success values.
470
+ *
471
+ * **Details**
472
+ *
473
+ * - If the result is a `Failure`, applies `f` to the error and returns a new `Failure`
474
+ * - If the result is a `Success`, returns it as-is
475
+ *
476
+ * **Example** (Adding context to an error)
477
+ *
478
+ * ```ts import.meta.vitest
479
+ * import { pipe, Result } from "effect"
480
+ *
481
+ * pipe(
482
+ * Result.fail("not found"),
483
+ * Result.mapError((e) => `Error: ${e}`)
484
+ * ) // => Result.fail("Error: not found")
485
+ * ```
486
+ *
487
+ * @see {@link map} to transform only the success value
488
+ * @see {@link mapBoth} to transform both channels
489
+ *
490
+ * @stability stable
491
+ * @category mapping
492
+ * @since 4.0.0
493
+ */
494
+ const mapError = /*#__PURE__*/ dual(2, (self, f) => isFailure(self) ? fail(f(self.failure)) : self);
495
+ /**
496
+ * Transforms the success channel of a `Result`, leaving the failure channel unchanged.
497
+ *
498
+ * **When to use**
499
+ *
500
+ * Use to apply a transformation to the success value of a `Result` while
501
+ * preserving any existing failure.
502
+ *
503
+ * **Details**
504
+ *
505
+ * - If the result is a `Success`, applies `f` to the value and returns a new `Success`
506
+ * - If the result is a `Failure`, returns it as-is
507
+ * - Use {@link flatMap} if `f` returns a `Result` (to avoid nested Results)
508
+ *
509
+ * **Example** (Doubling the success value)
510
+ *
511
+ * ```ts import.meta.vitest
512
+ * import { pipe, Result } from "effect"
513
+ *
514
+ * pipe(
515
+ * Result.succeed(3),
516
+ * Result.map((n) => n * 2)
517
+ * ) // => Result.succeed(6)
518
+ * ```
519
+ *
520
+ * @see {@link mapError} to transform only the error value
521
+ * @see {@link mapBoth} to transform both channels
522
+ * @see {@link flatMap} when `f` returns a `Result`
523
+ *
524
+ * @stability stable
525
+ * @category mapping
526
+ * @since 2.0.0
527
+ */
528
+ const map$1 = /*#__PURE__*/ dual(2, (self, f) => isSuccess(self) ? succeed(f(self.success)) : self);
529
+ /**
530
+ * Folds a `Result` into a single value by applying one of two functions.
531
+ *
532
+ * **When to use**
533
+ *
534
+ * Use when a `Result`'s success and failure branches should be collapsed into
535
+ * one plain output type.
536
+ *
537
+ * **Details**
538
+ *
539
+ * - Applies `onSuccess` if the result is a `Success`
540
+ * - Applies `onFailure` if the result is a `Failure`
541
+ * - Both branches must return the same type (or a common supertype)
542
+ *
543
+ * **Example** (Folding to a string)
544
+ *
545
+ * ```ts import.meta.vitest
546
+ * import { pipe, Result } from "effect"
547
+ *
548
+ * const format = Result.match({
549
+ * onSuccess: (n: number) => `Got ${n}`,
550
+ * onFailure: (e: string) => `Err: ${e}`
551
+ * })
552
+ *
553
+ * format(Result.succeed(42)) // => "Got 42"
554
+ *
555
+ * format(Result.fail("timeout")) // => "Err: timeout"
556
+ * ```
557
+ *
558
+ * @see {@link merge} to extract `A | E` without mapping
559
+ * @see {@link getOrElse} to unwrap only the success with a fallback
560
+ *
561
+ * @stability stable
562
+ * @category pattern matching
563
+ * @since 2.0.0
564
+ */
565
+ const match$1 = /*#__PURE__*/ dual(2, (self, { onFailure, onSuccess }) => isFailure(self) ? onFailure(self.failure) : onSuccess(self.success));
566
+ /**
567
+ * Extracts the success value or throws the raw failure value `E`.
568
+ *
569
+ * **When to use**
570
+ *
571
+ * Use when unchecked boundaries should turn failures into thrown exceptions.
572
+ *
573
+ * **Details**
574
+ *
575
+ * - `Success<A>` returns `A`
576
+ * - `Failure<E>` throws `E` directly
577
+ * - Use {@link getOrThrowWith} for a custom error object
578
+ *
579
+ * **Example** (Unwrapping or throwing)
580
+ *
581
+ * ```ts import.meta.vitest
582
+ * import { Result } from "effect"
583
+ *
584
+ * Result.getOrThrow(Result.succeed(1)) // => 1
585
+ *
586
+ * const failure = Result.try(() => Result.getOrThrow(Result.fail("error")))
587
+ * Result.merge(failure) // => "error"
588
+ * ```
589
+ *
590
+ * @see {@link getOrThrowWith} for custom error mapping
591
+ * @see {@link getOrElse} for a non-throwing alternative
592
+ *
593
+ * @stability stable
594
+ * @category getters
595
+ * @since 2.0.0
596
+ */
597
+ const getOrThrow = /*#__PURE__*/ (/* @__PURE__ */ dual(2, (self, onFailure) => {
598
+ if (isSuccess(self)) return self.success;
599
+ throw onFailure(self.failure);
600
+ }))(identity);
601
+ /**
602
+ * Chains a function that returns a `Result` onto a successful value.
603
+ *
604
+ * **When to use**
605
+ *
606
+ * Use to sequence `Result`-returning computations that should short-circuit on
607
+ * failure.
608
+ *
609
+ * **Details**
610
+ *
611
+ * - If `self` is a `Success`, applies `f` to the value and returns the resulting `Result`
612
+ * - If `self` is a `Failure`, short-circuits and returns it unchanged
613
+ * - The error types are merged into a union (`E | E2`)
614
+ * - This is the monadic `bind` / `>>=` for `Result`
615
+ *
616
+ * **Example** (Validating sequentially)
617
+ *
618
+ * ```ts import.meta.vitest
619
+ * import { pipe, Result } from "effect"
620
+ *
621
+ * pipe(
622
+ * Result.succeed(5),
623
+ * Result.flatMap((n) =>
624
+ * n > 0 ? Result.succeed(n * 2) : Result.fail("not positive")
625
+ * )
626
+ * ) // => Result.succeed(10)
627
+ * ```
628
+ *
629
+ * @see {@link andThen} for a more flexible variant that also accepts plain values
630
+ * @see {@link map} when `f` does not return a `Result`
631
+ *
632
+ * @stability stable
633
+ * @category sequencing
634
+ * @since 2.0.0
635
+ */
636
+ const flatMap$1 = /*#__PURE__*/ dual(2, (self, f) => isFailure(self) ? fail(self.failure) : f(self.success));
637
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/Tuple.js
638
+ /**
639
+ * Creates a tuple from the provided arguments.
640
+ *
641
+ * **When to use**
642
+ *
643
+ * Use when you need a properly typed tuple without writing `[a, b, c] as const`
644
+ * or another manual cast.
645
+ *
646
+ * **Details**
647
+ *
648
+ * The returned value has the exact tuple type, with each element's literal type
649
+ * preserved.
650
+ *
651
+ * **Example** (Creating a tuple)
652
+ *
653
+ * ```ts import.meta.vitest
654
+ * import { Tuple } from "effect"
655
+ *
656
+ * Tuple.make(10, 20, "red") // => [10, 20, "red"]
657
+ * ```
658
+ *
659
+ * @see {@link get} – access a single element by index
660
+ * @see {@link appendElement} – append an element to a tuple
661
+ * @stability stable
662
+ * @category constructors
663
+ * @since 2.0.0
664
+ */
665
+ const make = (...elements) => elements;
666
+ /**
667
+ * Creates an `Equivalence` for tuples by comparing corresponding elements
668
+ * using the provided per-position `Equivalence`s. Two tuples are equivalent
669
+ * when all their corresponding elements are equivalent.
670
+ *
671
+ * **When to use**
672
+ *
673
+ * Use when you need an `Equivalence` to compare tuples element-by-element.
674
+ *
675
+ * **Details**
676
+ *
677
+ * This is an alias of `Equivalence.Tuple`.
678
+ *
679
+ * **Example** (Comparing tuples for equivalence)
680
+ *
681
+ * ```ts import.meta.vitest
682
+ * import { Equivalence, Tuple } from "effect"
683
+ *
684
+ * const eq = Tuple.makeEquivalence([
685
+ * Equivalence.strictEqual<string>(),
686
+ * Equivalence.strictEqual<number>()
687
+ * ])
688
+ *
689
+ * eq(["Alice", 30], ["Alice", 30]) // => true
690
+ * eq(["Alice", 30], ["Bob", 30]) // => false
691
+ * ```
692
+ *
693
+ * @see {@link makeOrder} – create an `Order` for tuples
694
+ * @stability stable
695
+ * @category instances
696
+ * @since 4.0.0
697
+ */
698
+ const makeEquivalence$1 = Tuple;
699
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/Iterable.js
700
+ /**
701
+ * Gets the first element of an `Iterable` without returning an `Option`.
702
+ *
703
+ * **When to use**
704
+ *
705
+ * Use when the `Iterable` is known to be non-empty and direct access to the
706
+ * first element is preferred over handling `Option.none`.
707
+ *
708
+ * **Gotchas**
709
+ *
710
+ * Throws if the `Iterable` is empty.
711
+ *
712
+ * **Example** (Getting the first element unsafely)
713
+ *
714
+ * ```ts import.meta.vitest
715
+ * import { Iterable } from "effect"
716
+ *
717
+ * const numbers = [1, 2, 3]
718
+ * Iterable.headUnsafe(numbers) // => 1
719
+ *
720
+ * const letters = "hello"
721
+ * Iterable.headUnsafe(letters) // => "h"
722
+ *
723
+ * // Iterable.headUnsafe(Iterable.empty<number>())
724
+ * // throws Error: "headUnsafe: empty iterable"
725
+ *
726
+ * // Use only when you're certain the iterable is non-empty
727
+ * const nonEmpty = Iterable.range(1, 10)
728
+ * Iterable.headUnsafe(nonEmpty) // => 1
729
+ * ```
730
+ *
731
+ * @stability stable
732
+ * @category getters
733
+ * @since 4.0.0
734
+ */
735
+ const headUnsafe = (self) => {
736
+ const result = self[Symbol.iterator]().next();
737
+ if (result.done) throw new Error("headUnsafe: empty iterable");
738
+ return result.value;
739
+ };
740
+ /**
741
+ * Returns the first element that satisfies the specified
742
+ * predicate, or `None` if no such element exists.
743
+ *
744
+ * **Example** (Finding the first match)
745
+ *
746
+ * ```ts import.meta.vitest
747
+ * import { Iterable, Option } from "effect"
748
+ *
749
+ * const numbers = [1, 3, 4, 6, 8]
750
+ * const firstEven = Iterable.findFirst(numbers, (x) => x % 2 === 0)
751
+ * firstEven // => Option.some(4)
752
+ *
753
+ * const firstGreaterThan10 = Iterable.findFirst(numbers, (x) => x > 10)
754
+ * firstGreaterThan10 // => Option.none()
755
+ *
756
+ * // With index
757
+ * const letters = ["a", "b", "c", "d"]
758
+ * const atEvenIndex = Iterable.findFirst(letters, (_, i) => i % 2 === 0)
759
+ * atEvenIndex // => Option.some("a")
760
+ *
761
+ * // Type refinement
762
+ * const mixed: Array<string | number> = [1, "hello", 2, "world"]
763
+ * const firstString = Iterable.findFirst(
764
+ * mixed,
765
+ * (x): x is string => typeof x === "string"
766
+ * )
767
+ * firstString // => Option.some("hello")
768
+ *
769
+ * // Transform during search
770
+ * const findSquareRoot = Iterable.findFirst([1, 4, 9, 16], (x) => {
771
+ * const sqrt = Math.sqrt(x)
772
+ * return Number.isInteger(sqrt) ? Option.some(sqrt) : Option.none()
773
+ * })
774
+ * findSquareRoot // => Option.some(1)
775
+ * ```
776
+ *
777
+ * @stability stable
778
+ * @category searching
779
+ * @since 2.0.0
780
+ */
781
+ const findFirst$1 = /*#__PURE__*/ dual(2, (self, f) => {
782
+ let i = 0;
783
+ for (const a of self) {
784
+ const o = f(a, i);
785
+ if (isBoolean(o)) {
786
+ if (o) return some$1(a);
787
+ } else if (isSome(o)) return o;
788
+ i++;
789
+ }
790
+ return none();
791
+ });
792
+ const constEmpty = { [Symbol.iterator]() {
793
+ return constEmptyIterator;
794
+ } };
795
+ const constEmptyIterator = { next() {
796
+ return {
797
+ done: true,
798
+ value: void 0
799
+ };
800
+ } };
801
+ /**
802
+ * Creates an empty iterable that yields no elements.
803
+ *
804
+ * **When to use**
805
+ *
806
+ * Use when you need an empty iterable as a typed "no data" value or a base
807
+ * case for iterable operations.
808
+ *
809
+ * **Example** (Creating an empty iterable)
810
+ *
811
+ * ```ts import.meta.vitest
812
+ * import { Iterable } from "effect"
813
+ *
814
+ * Array.from(Iterable.empty<string>()) // => []
815
+ * ```
816
+ *
817
+ * @stability stable
818
+ * @category constructors
819
+ * @since 2.0.0
820
+ */
821
+ const empty$1 = () => constEmpty;
822
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/Array.js
823
+ /**
824
+ * Works with JavaScript arrays, readonly arrays, and non-empty arrays.
825
+ *
826
+ * The helpers cover common collection work such as creating arrays, reading
827
+ * elements, transforming values, sorting, grouping, splitting, combining, and
828
+ * reducing many values to one result. Helpers that change contents return new
829
+ * arrays and preserve non-empty array types when the result is guaranteed to
830
+ * contain values.
831
+ *
832
+ * @stability stable
833
+ * @since 2.0.0
834
+ */
835
+ /**
836
+ * Exposes the global array constructor.
837
+ *
838
+ * **When to use**
839
+ *
840
+ * Use to access native JavaScript array constructor methods such as `isArray`
841
+ * or `from` from the Effect module namespace.
842
+ *
843
+ * **Example** (Accessing the Array constructor)
844
+ *
845
+ * ```ts import.meta.vitest
846
+ * import { Array } from "effect"
847
+ *
848
+ * Array.Array === globalThis.Array // => true
849
+ * ```
850
+ *
851
+ * @stability stable
852
+ * @category constructors
853
+ * @since 4.0.0
854
+ */
855
+ const Array$1 = globalThis.Array;
856
+ /**
857
+ * Creates a `NonEmptyArray` of length `n` where element `i` is computed by `f(i)`.
858
+ *
859
+ * **When to use**
860
+ *
861
+ * Use when you need to compute each array element from its index.
862
+ *
863
+ * **Details**
864
+ *
865
+ * `n` is rounded down and normalized to an integer greater than or equal to 1.
866
+ * `NaN` is treated as `1`, so this function always returns at least one
867
+ * element. Supports both data-first and data-last usage.
868
+ *
869
+ * **Example** (Generating values from indices)
870
+ *
871
+ * ```ts import.meta.vitest
872
+ * import { Array } from "effect"
873
+ *
874
+ * Array.makeBy(5, (n) => n * 2) // => [0, 2, 4, 6, 8]
875
+ * ```
876
+ *
877
+ * @see {@link range} — create a range of integers
878
+ * @see {@link replicate} — repeat a single value
879
+ *
880
+ * @stability stable
881
+ * @category constructors
882
+ * @since 2.0.0
883
+ */
884
+ const makeBy = /*#__PURE__*/ dual(2, (n, f) => {
885
+ const max = normalizeNonEmpty(n);
886
+ const out = new Array$1(max);
887
+ for (let i = 0; i < max; i++) out[i] = f(i);
888
+ return out;
889
+ });
890
+ /**
891
+ * Converts an `Iterable` to an `Array`.
892
+ *
893
+ * **When to use**
894
+ *
895
+ * Use to convert any `Iterable` (Set, Generator, etc.) into an array.
896
+ *
897
+ * **Details**
898
+ *
899
+ * If the input is already an array, this returns it by reference without
900
+ * copying. Otherwise, it creates a new array from the iterable. Use `copy` if
901
+ * you need a fresh array even when the input is already an array.
902
+ *
903
+ * **Example** (Converting a Set to an array)
904
+ *
905
+ * ```ts import.meta.vitest
906
+ * import { Array } from "effect"
907
+ *
908
+ * Array.fromIterable(new Set([1, 2, 3])) // => [1, 2, 3]
909
+ * ```
910
+ *
911
+ * @see {@link ensure} — wrap a single value or return an existing array
912
+ * @see {@link copy} — create a shallow copy of an array
913
+ *
914
+ * @stability stable
915
+ * @category constructors
916
+ * @since 2.0.0
917
+ */
918
+ const fromIterable = (collection) => Array$1.isArray(collection) ? collection : Array$1.from(collection);
919
+ /**
920
+ * Normalizes a value that is either a single element or an array into an array.
921
+ *
922
+ * **When to use**
923
+ *
924
+ * Use to normalize input that may be a single value or an array into a consistent
925
+ * array.
926
+ *
927
+ * **Details**
928
+ *
929
+ * If the input is already an array, this returns it by reference. If the input
930
+ * is a single value, this wraps it in a one-element array. This is useful for
931
+ * APIs that accept `A | Array<A>`.
932
+ *
933
+ * **Example** (Normalizing input)
934
+ *
935
+ * ```ts import.meta.vitest
936
+ * import { Array } from "effect"
937
+ *
938
+ * Array.ensure("a") // => ["a"]
939
+ * Array.ensure(["a", "b", "c"]) // => ["a", "b", "c"]
940
+ * ```
941
+ *
942
+ * @see {@link of} — always wrap in a single-element array
943
+ * @see {@link fromIterable} — convert any iterable
944
+ *
945
+ * @stability stable
946
+ * @category constructors
947
+ * @since 3.3.0
948
+ */
949
+ const ensure = (self) => Array$1.isArray(self) ? self : [self];
950
+ /**
951
+ * Pattern-matches on an array, handling empty and non-empty cases separately.
952
+ *
953
+ * **When to use**
954
+ *
955
+ * Use when you need to branch on whether an array is empty.
956
+ *
957
+ * **Details**
958
+ *
959
+ * `onNonEmpty` receives a `NonEmptyArray` for mutable arrays and a
960
+ * `NonEmptyReadonlyArray` otherwise. Data-last calls default to the readonly
961
+ * callback, so the returned function still accepts `ReadonlyArray`. Supports
962
+ * both data-first and data-last usage.
963
+ *
964
+ * **Example** (Branching on emptiness)
965
+ *
966
+ * ```ts import.meta.vitest
967
+ * import { Array } from "effect"
968
+ *
969
+ * const describe = Array.match({
970
+ * onEmpty: () => "empty",
971
+ * onNonEmpty: ([head, ...tail]) => `head: ${head}, tail: ${tail.length}`
972
+ * })
973
+ *
974
+ * describe([]) // => "empty"
975
+ * describe([1, 2, 3]) // => "head: 1, tail: 2"
976
+ * ```
977
+ *
978
+ * @see {@link matchLeft} — destructures into head + tail
979
+ * @see {@link matchRight} — destructures into init + last
980
+ *
981
+ * @stability stable
982
+ * @category pattern matching
983
+ * @since 2.0.0
984
+ */
985
+ const match = /*#__PURE__*/ dual(2, (self, { onEmpty, onNonEmpty }) => isReadonlyArrayNonEmpty(self) ? onNonEmpty(self) : onEmpty());
986
+ /**
987
+ * Pattern-matches on an array from the left, providing the first element and
988
+ * the remaining elements separately.
989
+ *
990
+ * **When to use**
991
+ *
992
+ * Use when you need to branch on an array and handle the non-empty case as the
993
+ * first element plus the remaining elements.
994
+ *
995
+ * **Details**
996
+ *
997
+ * `onNonEmpty` receives `(head, tail)` where `tail` is the rest of the array.
998
+ *
999
+ * **Example** (Destructuring head and tail)
1000
+ *
1001
+ * ```ts import.meta.vitest
1002
+ * import { Array } from "effect"
1003
+ *
1004
+ * const matchLeft = Array.matchLeft({
1005
+ * onEmpty: () => "empty",
1006
+ * onNonEmpty: (head, tail) => `head: ${head}, tail: ${tail.length}`
1007
+ * })
1008
+ *
1009
+ * matchLeft([]) // => "empty"
1010
+ * matchLeft([1, 2, 3]) // => "head: 1, tail: 2"
1011
+ * ```
1012
+ *
1013
+ * @see {@link match} — receives the full non-empty array
1014
+ * @see {@link matchRight} — destructures into init + last
1015
+ *
1016
+ * @stability stable
1017
+ * @category pattern matching
1018
+ * @since 2.0.0
1019
+ */
1020
+ const matchLeft = /*#__PURE__*/ dual(2, (self, { onEmpty, onNonEmpty }) => isReadonlyArrayNonEmpty(self) ? onNonEmpty(headNonEmpty(self), tailNonEmpty(self)) : onEmpty());
1021
+ /**
1022
+ * Adds a single element to the end of an iterable, returning a `NonEmptyArray`.
1023
+ *
1024
+ * **When to use**
1025
+ *
1026
+ * Use when you need to guarantee a non-empty result after adding a required
1027
+ * trailing value.
1028
+ *
1029
+ * **Example** (Appending an element)
1030
+ *
1031
+ * ```ts import.meta.vitest
1032
+ * import { Array } from "effect"
1033
+ *
1034
+ * Array.append([1, 2, 3], 4) // => [1, 2, 3, 4]
1035
+ * ```
1036
+ *
1037
+ * @see {@link prepend} — add to the front
1038
+ * @see {@link appendAll} — append multiple elements
1039
+ *
1040
+ * @stability stable
1041
+ * @category combining
1042
+ * @since 2.0.0
1043
+ */
1044
+ const append = /*#__PURE__*/ dual(2, (self, last) => [...self, last]);
1045
+ /**
1046
+ * Concatenates two iterables into a single array.
1047
+ *
1048
+ * **When to use**
1049
+ *
1050
+ * Use to combine two iterable inputs into a new array with the second input's
1051
+ * elements after the first.
1052
+ *
1053
+ * **Details**
1054
+ *
1055
+ * If either input is non-empty, the result is a `NonEmptyArray`.
1056
+ *
1057
+ * **Example** (Concatenating arrays)
1058
+ *
1059
+ * ```ts import.meta.vitest
1060
+ * import { Array } from "effect"
1061
+ *
1062
+ * Array.appendAll([1, 2], [3, 4]) // => [1, 2, 3, 4]
1063
+ * ```
1064
+ *
1065
+ * @see {@link append} — add a single element to the end
1066
+ * @see {@link prependAll} — add elements to the front
1067
+ *
1068
+ * @stability stable
1069
+ * @category combining
1070
+ * @since 2.0.0
1071
+ */
1072
+ const appendAll = /*#__PURE__*/ dual(2, (self, that) => fromIterable(self).concat(fromIterable(that)));
1073
+ /**
1074
+ * Checks whether a value is an `Array`.
1075
+ *
1076
+ * **When to use**
1077
+ *
1078
+ * Use to verify a value is a mutable array, narrowing its type to `Array<unknown>`.
1079
+ *
1080
+ * **Details**
1081
+ *
1082
+ * Acts as a type guard narrowing the input to `Array<unknown>` and delegates to
1083
+ * `globalThis.Array.isArray`.
1084
+ *
1085
+ * **Example** (Type-guarding an unknown value)
1086
+ *
1087
+ * ```ts import.meta.vitest
1088
+ * import { Array } from "effect"
1089
+ *
1090
+ * Array.isArray(null) // => false
1091
+ * Array.isArray([1, 2, 3]) // => true
1092
+ * ```
1093
+ *
1094
+ * @see {@link isArrayEmpty} — check for an empty array
1095
+ * @see {@link isArrayNonEmpty} — check for a non-empty array
1096
+ *
1097
+ * @stability stable
1098
+ * @category guards
1099
+ * @since 2.0.0
1100
+ */
1101
+ const isArray = Array$1.isArray;
1102
+ /**
1103
+ * Checks whether a mutable `Array` is empty, narrowing the type to `[]`.
1104
+ *
1105
+ * **Example** (Checking for an empty array)
1106
+ *
1107
+ * ```ts import.meta.vitest
1108
+ * import { Array } from "effect"
1109
+ *
1110
+ * Array.isArrayEmpty([]) // => true
1111
+ * Array.isArrayEmpty([1, 2, 3]) // => false
1112
+ * ```
1113
+ *
1114
+ * @see {@link isReadonlyArrayEmpty} — readonly variant
1115
+ * @see {@link isArrayNonEmpty} — opposite check
1116
+ *
1117
+ * @stability stable
1118
+ * @category guards
1119
+ * @since 4.0.0
1120
+ */
1121
+ const isArrayEmpty = (self) => self.length === 0;
1122
+ /**
1123
+ * Checks whether a `ReadonlyArray` is empty, narrowing the type to `readonly []`.
1124
+ *
1125
+ * **Example** (Checking for an empty readonly array)
1126
+ *
1127
+ * ```ts import.meta.vitest
1128
+ * import { Array } from "effect"
1129
+ *
1130
+ * Array.isReadonlyArrayEmpty([]) // => true
1131
+ * Array.isReadonlyArrayEmpty([1, 2, 3]) // => false
1132
+ * ```
1133
+ *
1134
+ * @see {@link isArrayEmpty} — mutable variant
1135
+ * @see {@link isReadonlyArrayNonEmpty} — opposite check
1136
+ *
1137
+ * @stability stable
1138
+ * @category guards
1139
+ * @since 4.0.0
1140
+ */
1141
+ const isReadonlyArrayEmpty = isArrayEmpty;
1142
+ /**
1143
+ * Checks whether a mutable `Array` is non-empty, narrowing the type to
1144
+ * `NonEmptyArray`.
1145
+ *
1146
+ * **When to use**
1147
+ *
1148
+ * Use when you need the narrowed value to remain a mutable `Array` after proving
1149
+ * it has at least one element.
1150
+ *
1151
+ * **Example** (Checking for a non-empty array)
1152
+ *
1153
+ * ```ts import.meta.vitest
1154
+ * import { Array } from "effect"
1155
+ *
1156
+ * Array.isArrayNonEmpty([]) // => false
1157
+ * Array.isArrayNonEmpty([1, 2, 3]) // => true
1158
+ * ```
1159
+ *
1160
+ * @see {@link isReadonlyArrayNonEmpty} — readonly variant
1161
+ * @see {@link isArrayEmpty} — opposite check
1162
+ *
1163
+ * @stability stable
1164
+ * @category guards
1165
+ * @since 4.0.0
1166
+ */
1167
+ const isArrayNonEmpty = isArrayNonEmpty$1;
1168
+ /**
1169
+ * Checks whether a `ReadonlyArray` is non-empty, narrowing the type to
1170
+ * `NonEmptyReadonlyArray`.
1171
+ *
1172
+ * **When to use**
1173
+ *
1174
+ * Use when you need to prove a readonly array has at least one element without
1175
+ * requiring mutable array methods afterward.
1176
+ *
1177
+ * **Example** (Checking for a non-empty readonly array)
1178
+ *
1179
+ * ```ts import.meta.vitest
1180
+ * import { Array } from "effect"
1181
+ *
1182
+ * Array.isReadonlyArrayNonEmpty([]) // => false
1183
+ * Array.isReadonlyArrayNonEmpty([1, 2, 3]) // => true
1184
+ * ```
1185
+ *
1186
+ * @see {@link isArrayNonEmpty} — mutable variant
1187
+ * @see {@link isReadonlyArrayEmpty} — opposite check
1188
+ *
1189
+ * @stability stable
1190
+ * @category guards
1191
+ * @since 4.0.0
1192
+ */
1193
+ const isReadonlyArrayNonEmpty = isArrayNonEmpty$1;
1194
+ /**
1195
+ * Returns the number of elements in a `ReadonlyArray`.
1196
+ *
1197
+ * **When to use**
1198
+ *
1199
+ * Use when you need length as a composable function rather than a property access.
1200
+ *
1201
+ * **Example** (Getting the length)
1202
+ *
1203
+ * ```ts import.meta.vitest
1204
+ * import { Array } from "effect"
1205
+ *
1206
+ * Array.length([1, 2, 3]) // => 3
1207
+ * ```
1208
+ *
1209
+ * @stability stable
1210
+ * @category getters
1211
+ * @since 2.0.0
1212
+ */
1213
+ const length = (self) => self.length;
1214
+ /**
1215
+ * Checks whether a string represents a JavaScript array index: a non-negative
1216
+ * integer below `2 ** 32 - 1`, written without leading zeroes, a sign, or
1217
+ * exponent notation.
1218
+ *
1219
+ * @internal
1220
+ */
1221
+ function isCanonicalArrayIndex(key) {
1222
+ const index = Number(key);
1223
+ return String(index) === key && Number.isInteger(index) && index >= 0 && index < 2 ** 32 - 1;
1224
+ }
1225
+ /** @internal */
1226
+ function isOutOfBounds(i, as) {
1227
+ return !Number.isFinite(i) || i < 0 || i >= as.length;
1228
+ }
1229
+ /**
1230
+ * Reads an element at the given index safely, returning `Option.some` or
1231
+ * `Option.none` if the index is out of bounds.
1232
+ *
1233
+ * **When to use**
1234
+ *
1235
+ * Use when you need to read an array element by index and handle an
1236
+ * out-of-bounds index as `Option.none`.
1237
+ *
1238
+ * **Details**
1239
+ *
1240
+ * The index is floored to an integer. This never throws.
1241
+ *
1242
+ * **Example** (Accessing indexes safely)
1243
+ *
1244
+ * ```ts import.meta.vitest
1245
+ * import { Array, Option } from "effect"
1246
+ *
1247
+ * Array.get([1, 2, 3], 1) // => Option.some(2)
1248
+ * Array.get([1, 2, 3], 10) // => Option.none()
1249
+ * ```
1250
+ *
1251
+ * @see {@link getUnsafe} for indexed access that throws when the index is out of bounds
1252
+ * @see {@link head} for reading the first element as an `Option`
1253
+ * @see {@link last} for reading the last element as an `Option`
1254
+ *
1255
+ * @stability stable
1256
+ * @category getters
1257
+ * @since 2.0.0
1258
+ */
1259
+ const get = /*#__PURE__*/ dual(2, (self, index) => {
1260
+ const i = Math.floor(index);
1261
+ return isOutOfBounds(i, self) ? none() : some$1(self[i]);
1262
+ });
1263
+ /**
1264
+ * Reads an element at the given index, throwing if the index is out of bounds.
1265
+ *
1266
+ * **When to use**
1267
+ *
1268
+ * Use to read an array element at a known valid index when out-of-bounds would
1269
+ * be a programming error.
1270
+ *
1271
+ * **Details**
1272
+ *
1273
+ * Throws an `Error` with the message `"Index out of bounds: <i>"`. Prefer
1274
+ * `get` for safe access.
1275
+ *
1276
+ * **Example** (Accessing indexes unsafely)
1277
+ *
1278
+ * ```ts import.meta.vitest
1279
+ * import { Array } from "effect"
1280
+ *
1281
+ * Array.getUnsafe([1, 2, 3], 1) // => 2
1282
+ * // Array.getUnsafe([1, 2, 3], 10) // throws Error
1283
+ * ```
1284
+ *
1285
+ * @see {@link get} — safe version returning `Option`
1286
+ *
1287
+ * @stability stable
1288
+ * @category unsafe
1289
+ * @since 4.0.0
1290
+ */
1291
+ const getUnsafe = /*#__PURE__*/ dual(2, (self, index) => {
1292
+ const i = Math.floor(index);
1293
+ if (isOutOfBounds(i, self)) throw new Error(`Index out of bounds: ${i}`);
1294
+ return self[i];
1295
+ });
1296
+ /**
1297
+ * Returns the first element of an array safely wrapped in `Option.some`, or
1298
+ * `Option.none` if the array is empty.
1299
+ *
1300
+ * **When to use**
1301
+ *
1302
+ * Use to safely get the first element of an array that may be empty.
1303
+ *
1304
+ * **Example** (Getting the first element)
1305
+ *
1306
+ * ```ts import.meta.vitest
1307
+ * import { Array, Option } from "effect"
1308
+ *
1309
+ * Array.head([1, 2, 3]) // => Option.some(1)
1310
+ * Array.head([]) // => Option.none()
1311
+ * ```
1312
+ *
1313
+ * @see {@link headNonEmpty} — direct access when array is known non-empty
1314
+ * @see {@link last} — get the last element
1315
+ *
1316
+ * @stability stable
1317
+ * @category getters
1318
+ * @since 2.0.0
1319
+ */
1320
+ const head = /*#__PURE__*/ get(0);
1321
+ /**
1322
+ * Returns the first element of a `NonEmptyReadonlyArray` directly (no `Option`
1323
+ * wrapper).
1324
+ *
1325
+ * **When to use**
1326
+ *
1327
+ * Use to get the first element without `Option` wrapping when the array is known
1328
+ * to be non-empty.
1329
+ *
1330
+ * **Example** (Getting the head of a non-empty array)
1331
+ *
1332
+ * ```ts import.meta.vitest
1333
+ * import { Array } from "effect"
1334
+ *
1335
+ * Array.headNonEmpty([1, 2, 3, 4]) // => 1
1336
+ * ```
1337
+ *
1338
+ * @see {@link head} — safe version for possibly-empty arrays
1339
+ *
1340
+ * @stability stable
1341
+ * @category getters
1342
+ * @since 2.0.0
1343
+ */
1344
+ const headNonEmpty = /*#__PURE__*/ getUnsafe(0);
1345
+ /**
1346
+ * Returns the last element of an array safely wrapped in `Option.some`, or
1347
+ * `Option.none` if the array is empty.
1348
+ *
1349
+ * **When to use**
1350
+ *
1351
+ * Use to safely get the last element of an array that may be empty.
1352
+ *
1353
+ * **Example** (Getting the last element)
1354
+ *
1355
+ * ```ts import.meta.vitest
1356
+ * import { Array, Option } from "effect"
1357
+ *
1358
+ * Array.last([1, 2, 3]) // => Option.some(3)
1359
+ * Array.last([]) // => Option.none()
1360
+ * ```
1361
+ *
1362
+ * @see {@link lastNonEmpty} — direct access when array is known non-empty
1363
+ * @see {@link head} — get the first element
1364
+ *
1365
+ * @stability stable
1366
+ * @category getters
1367
+ * @since 2.0.0
1368
+ */
1369
+ const last = (self) => isReadonlyArrayNonEmpty(self) ? some$1(lastNonEmpty(self)) : none();
1370
+ /**
1371
+ * Returns the last element of a `NonEmptyReadonlyArray` directly (no `Option`
1372
+ * wrapper).
1373
+ *
1374
+ * **When to use**
1375
+ *
1376
+ * Use to get the last element without `Option` wrapping when the array is known
1377
+ * to be non-empty.
1378
+ *
1379
+ * **Example** (Getting the last of a non-empty array)
1380
+ *
1381
+ * ```ts import.meta.vitest
1382
+ * import { Array } from "effect"
1383
+ *
1384
+ * Array.lastNonEmpty([1, 2, 3, 4]) // => 4
1385
+ * ```
1386
+ *
1387
+ * @see {@link last} — safe version for possibly-empty arrays
1388
+ *
1389
+ * @stability stable
1390
+ * @category getters
1391
+ * @since 2.0.0
1392
+ */
1393
+ const lastNonEmpty = (self) => self[self.length - 1];
1394
+ /**
1395
+ * Returns all elements except the first of a `NonEmptyReadonlyArray`.
1396
+ *
1397
+ * **When to use**
1398
+ *
1399
+ * Use to get all elements after the first when the array is known to be non-empty.
1400
+ *
1401
+ * **Example** (Getting the tail of a non-empty array)
1402
+ *
1403
+ * ```ts import.meta.vitest
1404
+ * import { Array } from "effect"
1405
+ *
1406
+ * Array.tailNonEmpty([1, 2, 3, 4]) // => [2, 3, 4]
1407
+ * ```
1408
+ *
1409
+ * @see {@link tail} — safe version for possibly-empty arrays
1410
+ * @see {@link initNonEmpty} — all elements except the last
1411
+ *
1412
+ * @stability stable
1413
+ * @category getters
1414
+ * @since 2.0.0
1415
+ */
1416
+ const tailNonEmpty = (self) => self.slice(1);
1417
+ const clampCount = (n, length) => Math.min(normalize(n), length);
1418
+ /**
1419
+ * Keeps the first `n` elements, creating a new array.
1420
+ *
1421
+ * **When to use**
1422
+ *
1423
+ * Use to keep up to the first `n` elements from an iterable as a new array.
1424
+ *
1425
+ * **Details**
1426
+ *
1427
+ * `n` is rounded down and clamped to `[0, length]`. `NaN` is treated as `0`.
1428
+ * Returns an empty array when `n <= 0`.
1429
+ *
1430
+ * **Example** (Taking from the start)
1431
+ *
1432
+ * ```ts import.meta.vitest
1433
+ * import { Array } from "effect"
1434
+ *
1435
+ * Array.take([1, 2, 3, 4, 5], 3) // => [1, 2, 3]
1436
+ * ```
1437
+ *
1438
+ * @see {@link takeRight} for keeping elements from the end
1439
+ * @see {@link takeWhile} for keeping an initial prefix while a predicate holds
1440
+ * @see {@link drop} for removing elements from the start
1441
+ *
1442
+ * @stability stable
1443
+ * @category getters
1444
+ * @since 2.0.0
1445
+ */
1446
+ const take = /*#__PURE__*/ dual(2, (self, n) => {
1447
+ const input = fromIterable(self);
1448
+ return input.slice(0, clampCount(n, input.length));
1449
+ });
1450
+ /**
1451
+ * Keeps the last `n` elements, creating a new array.
1452
+ *
1453
+ * **When to use**
1454
+ *
1455
+ * Use to keep the last `n` elements of an iterable.
1456
+ *
1457
+ * **Details**
1458
+ *
1459
+ * `n` is rounded down and clamped to `[0, length]`. `NaN` is treated as `0`.
1460
+ * Returns an empty array when `n <= 0`.
1461
+ *
1462
+ * **Example** (Taking from the end)
1463
+ *
1464
+ * ```ts import.meta.vitest
1465
+ * import { Array } from "effect"
1466
+ *
1467
+ * Array.takeRight([1, 2, 3, 4, 5], 3) // => [3, 4, 5]
1468
+ * ```
1469
+ *
1470
+ * @see {@link take} — keep from the start
1471
+ * @see {@link dropRight} — remove from the end
1472
+ *
1473
+ * @stability stable
1474
+ * @category getters
1475
+ * @since 2.0.0
1476
+ */
1477
+ const takeRight = /*#__PURE__*/ dual(2, (self, n) => {
1478
+ const input = fromIterable(self);
1479
+ const i = clampCount(n, input.length);
1480
+ return i === 0 ? [] : input.slice(-i);
1481
+ });
1482
+ /**
1483
+ * Takes elements from the start while the predicate holds, stopping at the
1484
+ * first element that fails.
1485
+ *
1486
+ * **When to use**
1487
+ *
1488
+ * Use to keep the leading elements of an iterable while each element satisfies
1489
+ * a predicate, returning the retained prefix as an array.
1490
+ *
1491
+ * **Details**
1492
+ *
1493
+ * Supports refinements for type narrowing. The predicate receives
1494
+ * `(element, index)`.
1495
+ *
1496
+ * **Example** (Taking while condition holds)
1497
+ *
1498
+ * ```ts import.meta.vitest
1499
+ * import { Array } from "effect"
1500
+ *
1501
+ * Array.takeWhile([1, 3, 2, 4, 1, 2], (x) => x < 4) // => [1, 3, 2]
1502
+ * ```
1503
+ *
1504
+ * @see {@link take} for keeping a fixed number of leading elements
1505
+ * @see {@link dropWhile} for removing the matching prefix and keeping the rest
1506
+ * @see {@link span} for splitting the matching prefix from the remaining elements
1507
+ *
1508
+ * @stability stable
1509
+ * @category getters
1510
+ * @since 2.0.0
1511
+ */
1512
+ const takeWhile = /*#__PURE__*/ dual(2, (self, predicate) => {
1513
+ let i = 0;
1514
+ const out = [];
1515
+ for (const a of self) {
1516
+ if (!predicate(a, i)) break;
1517
+ out.push(a);
1518
+ i++;
1519
+ }
1520
+ return out;
1521
+ });
1522
+ /**
1523
+ * Removes the first `n` elements, creating a new array.
1524
+ *
1525
+ * **When to use**
1526
+ *
1527
+ * Use to keep the suffix of an iterable after skipping a fixed number of
1528
+ * leading elements.
1529
+ *
1530
+ * **Details**
1531
+ *
1532
+ * `n` is rounded down and clamped to `[0, length]`. `NaN` is treated as `0`.
1533
+ * When `n <= 0`, this returns a copy of the full array.
1534
+ *
1535
+ * **Example** (Dropping from the start)
1536
+ *
1537
+ * ```ts import.meta.vitest
1538
+ * import { Array } from "effect"
1539
+ *
1540
+ * Array.drop([1, 2, 3, 4, 5], 2) // => [3, 4, 5]
1541
+ * ```
1542
+ *
1543
+ * @see {@link dropRight} for removing a fixed number of elements from the end
1544
+ * @see {@link dropWhile} for removing a prefix based on a predicate instead of a fixed count
1545
+ * @see {@link take} for keeping a fixed number of elements from the start
1546
+ *
1547
+ * @stability stable
1548
+ * @category getters
1549
+ * @since 2.0.0
1550
+ */
1551
+ const drop = /*#__PURE__*/ dual(2, (self, n) => {
1552
+ const input = fromIterable(self);
1553
+ return input.slice(clampCount(n, input.length), input.length);
1554
+ });
1555
+ /**
1556
+ * Returns the index of the first element matching the predicate, wrapped in an
1557
+ * `Option`.
1558
+ *
1559
+ * **When to use**
1560
+ *
1561
+ * Use to find the index of the first matching element from the start of an
1562
+ * iterable.
1563
+ *
1564
+ * **Example** (Finding an index)
1565
+ *
1566
+ * ```ts import.meta.vitest
1567
+ * import { Array, Option } from "effect"
1568
+ *
1569
+ * Array.findFirstIndex([5, 3, 8, 9], (x) => x > 5) // => Option.some(2)
1570
+ * ```
1571
+ *
1572
+ * @see {@link findLastIndex} — search from the end
1573
+ * @see {@link findFirst} — get the element itself
1574
+ *
1575
+ * @stability stable
1576
+ * @category searching
1577
+ * @since 2.0.0
1578
+ */
1579
+ const findFirstIndex = /*#__PURE__*/ dual(2, (self, predicate) => {
1580
+ let i = 0;
1581
+ for (const a of self) {
1582
+ if (predicate(a, i)) return some$1(i);
1583
+ i++;
1584
+ }
1585
+ return none();
1586
+ });
1587
+ /**
1588
+ * Returns the first element matching a predicate, refinement, or mapping
1589
+ * function, wrapped in `Option`.
1590
+ *
1591
+ * **When to use**
1592
+ *
1593
+ * Use to scan an iterable in iteration order and return the first selected
1594
+ * element or mapped value as an `Option`.
1595
+ *
1596
+ * **Details**
1597
+ *
1598
+ * Accepts a predicate `(a, i) => boolean`, a refinement, or a function
1599
+ * `(a, i) => Option<B>` for simultaneous find-and-transform. If no element
1600
+ * matches, this returns `Option.none()`.
1601
+ *
1602
+ * **Example** (Finding the first match)
1603
+ *
1604
+ * ```ts import.meta.vitest
1605
+ * import { Array, Option } from "effect"
1606
+ *
1607
+ * Array.findFirst([1, 2, 3, 4, 5], (x) => x > 3) // => Option.some(4)
1608
+ * ```
1609
+ *
1610
+ * @see {@link findLast} — search from the end
1611
+ * @see {@link findFirstIndex} — get the index instead
1612
+ * @see {@link findFirstWithIndex} — get both element and index
1613
+ *
1614
+ * @stability stable
1615
+ * @category searching
1616
+ * @since 2.0.0
1617
+ */
1618
+ const findFirst = findFirst$1;
1619
+ /**
1620
+ * Returns the last element matching a predicate, refinement, or mapping
1621
+ * function, wrapped in `Option`.
1622
+ *
1623
+ * **When to use**
1624
+ *
1625
+ * Use to find the last matching element from the end of an array.
1626
+ *
1627
+ * **Details**
1628
+ *
1629
+ * Searches from the end of the array. If no element matches, this returns
1630
+ * `Option.none()`.
1631
+ *
1632
+ * **Example** (Finding the last match)
1633
+ *
1634
+ * ```ts import.meta.vitest
1635
+ * import { Array, Option } from "effect"
1636
+ *
1637
+ * Array.findLast([1, 2, 3, 4, 5], (n) => n % 2 === 0) // => Option.some(4)
1638
+ * ```
1639
+ *
1640
+ * @see {@link findFirst} — search from the start
1641
+ * @see {@link findLastIndex} — get the index instead
1642
+ *
1643
+ * @stability stable
1644
+ * @category searching
1645
+ * @since 2.0.0
1646
+ */
1647
+ const findLast = /*#__PURE__*/ dual(2, (self, f) => {
1648
+ const input = fromIterable(self);
1649
+ for (let i = input.length - 1; i >= 0; i--) {
1650
+ const a = input[i];
1651
+ const o = f(a, i);
1652
+ if (typeof o === "boolean") {
1653
+ if (o) return some$1(a);
1654
+ } else if (isSome(o)) return o;
1655
+ }
1656
+ return none();
1657
+ });
1658
+ /**
1659
+ * Sorts an array by the given `Order`, returning a new array.
1660
+ *
1661
+ * **When to use**
1662
+ *
1663
+ * Use to sort an array using a single `Order` comparator.
1664
+ *
1665
+ * **Details**
1666
+ *
1667
+ * Preserves `NonEmptyArray` in the return type. Use `sortWith` to sort by a
1668
+ * derived key, or `sortBy` for multi-key sorting.
1669
+ *
1670
+ * **Example** (Sorting numbers)
1671
+ *
1672
+ * ```ts import.meta.vitest
1673
+ * import { Array, Order } from "effect"
1674
+ *
1675
+ * Array.sort([3, 1, 4, 1, 5], Order.Number) // => [1, 1, 3, 4, 5]
1676
+ * ```
1677
+ *
1678
+ * @see {@link sortWith} — sort by a mapping function
1679
+ * @see {@link sortBy} — sort by multiple orders
1680
+ *
1681
+ * @stability stable
1682
+ * @category sorting
1683
+ * @since 2.0.0
1684
+ */
1685
+ const sort = /*#__PURE__*/ dual(2, (self, O) => {
1686
+ const out = Array$1.from(self);
1687
+ out.sort(O);
1688
+ return out;
1689
+ });
1690
+ /**
1691
+ * Sorts an array by a derived key using a mapping function and an `Order` for
1692
+ * that key.
1693
+ *
1694
+ * **When to use**
1695
+ *
1696
+ * Use when you need to sort values by a derived key, such as a string length or
1697
+ * object field, while keeping the original values.
1698
+ *
1699
+ * **Details**
1700
+ *
1701
+ * Equivalent to `sort(Order.mapInput(order, f))`, but more convenient.
1702
+ *
1703
+ * **Example** (Sorting strings by length)
1704
+ *
1705
+ * ```ts import.meta.vitest
1706
+ * import { Array, Order } from "effect"
1707
+ *
1708
+ * Array.sortWith(["aaa", "b", "cc"], (s) => s.length, Order.Number) // => ["b", "cc", "aaa"]
1709
+ * ```
1710
+ *
1711
+ * @see {@link sort} for sorting with an `Order` that compares the elements directly
1712
+ * @see {@link sortBy} for sorting with multiple `Order`s applied in sequence
1713
+ *
1714
+ * @stability stable
1715
+ * @category sorting
1716
+ * @since 2.0.0
1717
+ */
1718
+ const sortWith = /*#__PURE__*/ dual(3, (self, f, order) => Array$1.from(self).map((a) => [a, f(a)]).sort(([, a], [, b]) => order(a, b)).map(([_]) => _));
1719
+ /**
1720
+ * Pairs elements from two iterables by position. If the iterables differ in
1721
+ * length, the extra elements from the longer one are discarded.
1722
+ *
1723
+ * **When to use**
1724
+ *
1725
+ * Use when you need simple pairs of corresponding elements from two iterables.
1726
+ *
1727
+ * **Details**
1728
+ *
1729
+ * Returns `NonEmptyArray` when both inputs are non-empty.
1730
+ *
1731
+ * **Example** (Zipping two arrays)
1732
+ *
1733
+ * ```ts import.meta.vitest
1734
+ * import { Array } from "effect"
1735
+ *
1736
+ * Array.zip([1, 2, 3], ["a", "b"]) // => [[1, "a"], [2, "b"]]
1737
+ * ```
1738
+ *
1739
+ * @see {@link zipWith} — zip with a combiner function
1740
+ * @see {@link unzip} — inverse operation
1741
+ *
1742
+ * @stability stable
1743
+ * @category zipping
1744
+ * @since 2.0.0
1745
+ */
1746
+ const zip = /*#__PURE__*/ dual(2, (self, that) => zipWith(self, that, make));
1747
+ /**
1748
+ * Combines elements from two iterables pairwise using a function. If the
1749
+ * iterables differ in length, extra elements are discarded.
1750
+ *
1751
+ * **When to use**
1752
+ *
1753
+ * Use when zipping two iterables in an array pipeline and each pair should
1754
+ * become a computed array element instead of a tuple.
1755
+ *
1756
+ * **Example** (Zipping with addition)
1757
+ *
1758
+ * ```ts import.meta.vitest
1759
+ * import { Array } from "effect"
1760
+ *
1761
+ * Array.zipWith([1, 2, 3], [4, 5, 6], (a, b) => a + b) // => [5, 7, 9]
1762
+ * ```
1763
+ *
1764
+ * @see {@link zip} — zip into tuples
1765
+ *
1766
+ * @stability stable
1767
+ * @category zipping
1768
+ * @since 2.0.0
1769
+ */
1770
+ const zipWith = /*#__PURE__*/ dual(3, (self, that, f) => {
1771
+ const as = fromIterable(self);
1772
+ const bs = fromIterable(that);
1773
+ if (isReadonlyArrayNonEmpty(as) && isReadonlyArrayNonEmpty(bs)) {
1774
+ const out = [f(headNonEmpty(as), headNonEmpty(bs))];
1775
+ const len = Math.min(as.length, bs.length);
1776
+ for (let i = 1; i < len; i++) out[i] = f(as[i], bs[i]);
1777
+ return out;
1778
+ }
1779
+ return [];
1780
+ });
1781
+ /**
1782
+ * Returns a membership-test function using a custom equivalence.
1783
+ *
1784
+ * **When to use**
1785
+ *
1786
+ * Use when checking membership with caller-provided equality instead of
1787
+ * `Equal.asEquivalence()`.
1788
+ *
1789
+ * **Example** (Checking with custom equality)
1790
+ *
1791
+ * ```ts import.meta.vitest
1792
+ * import { Array, pipe } from "effect"
1793
+ *
1794
+ * const containsNumber = Array.containsWith((a: number, b: number) => a === b)
1795
+ *
1796
+ * pipe([1, 2, 3, 4], containsNumber(3)) // => true
1797
+ * ```
1798
+ *
1799
+ * @see {@link contains} for the `Equal.asEquivalence()` variant
1800
+ *
1801
+ * @stability stable
1802
+ * @category predicates
1803
+ * @since 2.0.0
1804
+ */
1805
+ const containsWith = (isEquivalent) => dual(2, (self, a) => {
1806
+ for (const i of self) if (isEquivalent(a, i)) return true;
1807
+ return false;
1808
+ });
1809
+ /**
1810
+ * Checks whether an array contains a value, using `Equal.asEquivalence()` for
1811
+ * comparison.
1812
+ *
1813
+ * **When to use**
1814
+ *
1815
+ * Use to check whether an iterable contains a value using Effect's default
1816
+ * equality instead of providing a comparison function.
1817
+ *
1818
+ * **Example** (Checking membership)
1819
+ *
1820
+ * ```ts import.meta.vitest
1821
+ * import { Array, pipe } from "effect"
1822
+ *
1823
+ * pipe(["a", "b", "c", "d"], Array.contains("c")) // => true
1824
+ * ```
1825
+ *
1826
+ * @see {@link containsWith} — use custom equality
1827
+ *
1828
+ * @stability stable
1829
+ * @category predicates
1830
+ * @since 2.0.0
1831
+ */
1832
+ const contains = /*#__PURE__*/ containsWith(/*#__PURE__*/ asEquivalence());
1833
+ /**
1834
+ * Groups elements into a record by a key-returning function. Each key maps
1835
+ * to a `NonEmptyArray` of elements that produced that key.
1836
+ *
1837
+ * **When to use**
1838
+ *
1839
+ * Use to build buckets of elements indexed by a computed string or symbol key.
1840
+ *
1841
+ * **Details**
1842
+ *
1843
+ * Unlike `group` and `groupWith`, elements do not need to be adjacent to be
1844
+ * grouped together. The key function must return a `string` or `symbol`.
1845
+ *
1846
+ * **Gotchas**
1847
+ *
1848
+ * When the key function returns a finite union of string literals or unique
1849
+ * symbols, the result preserves those keys as optional properties because the
1850
+ * input may not produce every key. Open `string` and `symbol` key types retain
1851
+ * their record index signatures.
1852
+ *
1853
+ * **Example** (Grouping by a property)
1854
+ *
1855
+ * ```ts import.meta.vitest
1856
+ * import { Array } from "effect"
1857
+ *
1858
+ * const people = [
1859
+ * { name: "Alice", group: "A" },
1860
+ * { name: "Bob", group: "B" },
1861
+ * { name: "Charlie", group: "A" }
1862
+ * ]
1863
+ *
1864
+ * Object.keys(Array.groupBy(people, (person) => person.group)).join(",") // => "A,B"
1865
+ * ```
1866
+ *
1867
+ * @see {@link group} — group adjacent equal elements
1868
+ * @see {@link groupWith} — group adjacent elements by custom equality
1869
+ *
1870
+ * @stability stable
1871
+ * @category grouping
1872
+ * @since 2.0.0
1873
+ */
1874
+ const groupBy = /*#__PURE__*/ dual(2, (self, f) => {
1875
+ const out = {};
1876
+ for (const a of self) {
1877
+ const k = f(a);
1878
+ if (Object.hasOwn(out, k)) out[k].push(a);
1879
+ else assignProperty(out, k, [a]);
1880
+ }
1881
+ return out;
1882
+ });
1883
+ const hashBucketsAdd = (buckets, value) => {
1884
+ const hash$1 = hash(value);
1885
+ const bucket = buckets.get(hash$1);
1886
+ if (bucket === void 0) {
1887
+ buckets.set(hash$1, [value]);
1888
+ return true;
1889
+ }
1890
+ for (const previous of bucket) if (equals(previous, value)) return false;
1891
+ bucket.push(value);
1892
+ return true;
1893
+ };
1894
+ /**
1895
+ * Creates an empty array.
1896
+ *
1897
+ * **When to use**
1898
+ *
1899
+ * Use to create a typed empty array without allocating placeholder elements.
1900
+ *
1901
+ * **Example** (Creating an empty array)
1902
+ *
1903
+ * ```ts import.meta.vitest
1904
+ * import { Array } from "effect"
1905
+ *
1906
+ * Array.empty<number>() // => []
1907
+ * ```
1908
+ *
1909
+ * @see {@link of} — create a single-element array
1910
+ * @see {@link make} — create from multiple values
1911
+ *
1912
+ * @stability stable
1913
+ * @category constructors
1914
+ * @since 2.0.0
1915
+ */
1916
+ const empty = () => [];
1917
+ /**
1918
+ * Wraps a single value in a `NonEmptyArray`.
1919
+ *
1920
+ * **Example** (Creating a single-element array)
1921
+ *
1922
+ * ```ts import.meta.vitest
1923
+ * import { Array } from "effect"
1924
+ *
1925
+ * Array.of(1) // => [1]
1926
+ * ```
1927
+ *
1928
+ * @see {@link make} — create from multiple values
1929
+ * @see {@link empty} — create an empty array
1930
+ *
1931
+ * @stability stable
1932
+ * @category constructors
1933
+ * @since 2.0.0
1934
+ */
1935
+ const of = (a) => [a];
1936
+ /**
1937
+ * Transforms each element using a function, returning a new array.
1938
+ *
1939
+ * **When to use**
1940
+ *
1941
+ * Use to transform each element independently while preserving the array shape.
1942
+ *
1943
+ * **Details**
1944
+ *
1945
+ * The function receives `(element, index)`. The return type preserves
1946
+ * `NonEmptyArray`.
1947
+ *
1948
+ * **Example** (Doubling values)
1949
+ *
1950
+ * ```ts import.meta.vitest
1951
+ * import { Array } from "effect"
1952
+ *
1953
+ * Array.map([1, 2, 3], (x) => x * 2) // => [2, 4, 6]
1954
+ * ```
1955
+ *
1956
+ * @see {@link flatMap} — map and flatten
1957
+ *
1958
+ * @stability stable
1959
+ * @category mapping
1960
+ * @since 2.0.0
1961
+ */
1962
+ const map = /*#__PURE__*/ dual(2, (self, f) => self.map(f));
1963
+ /**
1964
+ * Maps each element to an array and flattens the results into a single array.
1965
+ *
1966
+ * **When to use**
1967
+ *
1968
+ * Use to map each array element to zero or more values and concatenate the
1969
+ * results in one pass.
1970
+ *
1971
+ * **Details**
1972
+ *
1973
+ * The function receives `(element, index)`. This returns `NonEmptyArray` when
1974
+ * both the input and mapped arrays are non-empty.
1975
+ *
1976
+ * **Example** (Flat mapping an array)
1977
+ *
1978
+ * ```ts import.meta.vitest
1979
+ * import { Array } from "effect"
1980
+ *
1981
+ * Array.flatMap([1, 2, 3], (x) => [x, x * 2]) // => [1, 2, 2, 4, 3, 6]
1982
+ * ```
1983
+ *
1984
+ * @see {@link map} — transform without flattening
1985
+ * @see {@link flatten} — flatten without mapping
1986
+ *
1987
+ * @stability stable
1988
+ * @category sequencing
1989
+ * @since 2.0.0
1990
+ */
1991
+ const flatMap = /*#__PURE__*/ dual(2, (self, f) => {
1992
+ if (isReadonlyArrayEmpty(self)) return [];
1993
+ const out = [];
1994
+ for (let i = 0; i < self.length; i++) {
1995
+ const inner = f(self[i], i);
1996
+ for (let j = 0; j < inner.length; j++) out.push(inner[j]);
1997
+ }
1998
+ return out;
1999
+ });
2000
+ /**
2001
+ * Flattens a nested array of arrays into a single array.
2002
+ *
2003
+ * **When to use**
2004
+ *
2005
+ * Use to collapse one level of nested arrays when no per-element mapping is
2006
+ * needed.
2007
+ *
2008
+ * **Example** (Flattening nested arrays)
2009
+ *
2010
+ * ```ts import.meta.vitest
2011
+ * import { Array } from "effect"
2012
+ *
2013
+ * Array.flatten([[1, 2], [], [3, 4], [], [5, 6]]) // => [1, 2, 3, 4, 5, 6]
2014
+ * ```
2015
+ *
2016
+ * @see {@link flatMap} — map then flatten in one step
2017
+ *
2018
+ * @stability stable
2019
+ * @category sequencing
2020
+ * @since 2.0.0
2021
+ */
2022
+ const flatten = /*#__PURE__*/ flatMap(identity);
2023
+ /**
2024
+ * Extracts all `Some` values from an iterable of `Option`s, discarding `None`s.
2025
+ *
2026
+ * **When to use**
2027
+ *
2028
+ * Use to collect only present values from an iterable of `Option` values while
2029
+ * discarding `None` values.
2030
+ *
2031
+ * **Example** (Extracting Some values)
2032
+ *
2033
+ * ```ts import.meta.vitest
2034
+ * import { Array, Option } from "effect"
2035
+ *
2036
+ * Array.getSomes([Option.some(1), Option.none(), Option.some(2)]) // => [1, 2]
2037
+ * ```
2038
+ *
2039
+ * @see {@link fromOption} — convert a single Option
2040
+ * @see {@link getSuccesses} — extract successes from Results
2041
+ *
2042
+ * @stability stable
2043
+ * @category filtering
2044
+ * @since 2.0.0
2045
+ */
2046
+ const getSomes = (self) => {
2047
+ const out = [];
2048
+ for (const a of self) if (isSome(a)) out.push(a.value);
2049
+ return out;
2050
+ };
2051
+ /**
2052
+ * Keeps only elements satisfying a predicate (or refinement).
2053
+ *
2054
+ * **When to use**
2055
+ *
2056
+ * Use to filter an iterable into a new array of original elements that satisfy
2057
+ * a boolean predicate or refinement.
2058
+ *
2059
+ * **Details**
2060
+ *
2061
+ * The predicate receives `(element, index)`. Refinements are supported for type
2062
+ * narrowing.
2063
+ *
2064
+ * **Example** (Filtering even numbers)
2065
+ *
2066
+ * ```ts import.meta.vitest
2067
+ * import { Array } from "effect"
2068
+ *
2069
+ * Array.filter([1, 2, 3, 4], (x) => x % 2 === 0) // => [2, 4]
2070
+ * ```
2071
+ *
2072
+ * @see {@link partition} — split into matching and non-matching
2073
+ * @see {@link filterMap} for transforming while filtering
2074
+ *
2075
+ * @stability stable
2076
+ * @category filtering
2077
+ * @since 2.0.0
2078
+ */
2079
+ const filter = /*#__PURE__*/ dual(2, (self, predicate) => {
2080
+ const as = fromIterable(self);
2081
+ const out = [];
2082
+ for (let i = 0; i < as.length; i++) if (predicate(as[i], i)) out.push(as[i]);
2083
+ return out;
2084
+ });
2085
+ /**
2086
+ * Splits an iterable using a `Filter` into successes and failures.
2087
+ *
2088
+ * **When to use**
2089
+ *
2090
+ * Use to partition an iterable by evaluating each element with a
2091
+ * `Result`-returning filter and keeping both success and failure values.
2092
+ *
2093
+ * **Details**
2094
+ *
2095
+ * Returns `[passes, fails]`. The filter receives `(element, index)`.
2096
+ *
2097
+ * **Example** (Partitioning with a filter)
2098
+ *
2099
+ * ```ts import.meta.vitest
2100
+ * import { Array, Result } from "effect"
2101
+ *
2102
+ * Array.partition([1, -2, 3], (n, i) =>
2103
+ * n > 0 ? Result.succeed(n + i) : Result.fail(`negative:${n}`)
2104
+ * ) // => [[1, 5], ["negative:-2"]]
2105
+ * ```
2106
+ *
2107
+ * @see {@link filter} — keep only matching elements
2108
+ * @see {@link filterMap} for discarding failures
2109
+ * @see {@link separate} — split an iterable of `Result` values
2110
+ *
2111
+ * @stability stable
2112
+ * @category filtering
2113
+ * @since 2.0.0
2114
+ */
2115
+ const partition = /*#__PURE__*/ dual(2, (self, f) => {
2116
+ const passes = [];
2117
+ const fails = [];
2118
+ let i = 0;
2119
+ for (const a of self) {
2120
+ const result = f(a, i++);
2121
+ if (isSuccess(result)) passes.push(result.success);
2122
+ else fails.push(result.failure);
2123
+ }
2124
+ return [passes, fails];
2125
+ });
2126
+ /**
2127
+ * Folds an iterable from left to right into a single value.
2128
+ *
2129
+ * **When to use**
2130
+ *
2131
+ * Use to combine all elements into one accumulated value from left to right.
2132
+ *
2133
+ * **Details**
2134
+ *
2135
+ * The function receives `(accumulator, element, index)`.
2136
+ *
2137
+ * **Example** (Summing an array)
2138
+ *
2139
+ * ```ts import.meta.vitest
2140
+ * import { Array } from "effect"
2141
+ *
2142
+ * Array.reduce([1, 2, 3], 0, (acc, n) => acc + n) // => 6
2143
+ * ```
2144
+ *
2145
+ * @see {@link reduceRight} — fold from right to left
2146
+ * @see {@link scan} — fold keeping intermediate values
2147
+ *
2148
+ * @stability stable
2149
+ * @category folding
2150
+ * @since 2.0.0
2151
+ */
2152
+ const reduce = /*#__PURE__*/ dual(3, (self, b, f) => fromIterable(self).reduce((b, a, i) => f(b, a, i), b));
2153
+ /**
2154
+ * Checks whether all elements satisfy the predicate. Supports refinements for
2155
+ * type narrowing.
2156
+ *
2157
+ * **When to use**
2158
+ *
2159
+ * Use to check whether every array element satisfies a predicate, including
2160
+ * refinement-based type narrowing.
2161
+ *
2162
+ * **Example** (Testing all elements)
2163
+ *
2164
+ * ```ts import.meta.vitest
2165
+ * import { Array } from "effect"
2166
+ *
2167
+ * Array.every([2, 4, 6], (x) => x % 2 === 0) // => true
2168
+ * Array.every([2, 3, 6], (x) => x % 2 === 0) // => false
2169
+ * ```
2170
+ *
2171
+ * @see {@link some} — test if any element matches
2172
+ *
2173
+ * @stability stable
2174
+ * @category guards
2175
+ * @since 2.0.0
2176
+ */
2177
+ const every = /*#__PURE__*/ dual(2, (self, refinement) => self.every(refinement));
2178
+ /**
2179
+ * Checks whether at least one element satisfies the predicate. Narrows the type
2180
+ * to `NonEmptyReadonlyArray` on success.
2181
+ *
2182
+ * **Example** (Testing for any match)
2183
+ *
2184
+ * ```ts import.meta.vitest
2185
+ * import { Array } from "effect"
2186
+ *
2187
+ * Array.some([1, 3, 4], (x) => x % 2 === 0) // => true
2188
+ * Array.some([1, 3, 5], (x) => x % 2 === 0) // => false
2189
+ * ```
2190
+ *
2191
+ * @see {@link every} — test if all elements match
2192
+ * @see {@link contains} — test for a specific value
2193
+ *
2194
+ * @stability stable
2195
+ * @category guards
2196
+ * @since 2.0.0
2197
+ */
2198
+ const some = /*#__PURE__*/ dual(2, (self, predicate) => self.some(predicate));
2199
+ /**
2200
+ * Returns the minimum element of a non-empty array according to the given
2201
+ * `Order`.
2202
+ *
2203
+ * **Example** (Finding the minimum)
2204
+ *
2205
+ * ```ts import.meta.vitest
2206
+ * import { Array, Order } from "effect"
2207
+ *
2208
+ * Array.min([3, 1, 2], Order.Number) // => 1
2209
+ * ```
2210
+ *
2211
+ * @see {@link max} — find the maximum
2212
+ * @see {@link sort} — sort the entire array
2213
+ *
2214
+ * @stability stable
2215
+ * @category getters
2216
+ * @since 2.0.0
2217
+ */
2218
+ const min = /*#__PURE__*/ dual(2, (self, O) => self.reduce(min$1(O)));
2219
+ /**
2220
+ * Builds an array by repeatedly applying a function to a seed value. The
2221
+ * function returns `Option.some([element, nextSeed])` to continue, or
2222
+ * `Option.none()` to stop.
2223
+ *
2224
+ * **Example** (Generating a sequence)
2225
+ *
2226
+ * ```ts import.meta.vitest
2227
+ * import { Array, Option } from "effect"
2228
+ *
2229
+ * Array.unfold(1, (n) => n <= 5 ? Option.some([n, n + 1]) : Option.none()) // => [1, 2, 3, 4, 5]
2230
+ * ```
2231
+ *
2232
+ * @see {@link makeBy} — generate from index
2233
+ * @see {@link range} — generate a numeric range
2234
+ *
2235
+ * @stability stable
2236
+ * @category constructors
2237
+ * @since 2.0.0
2238
+ */
2239
+ const unfold = (b, f) => {
2240
+ const out = [];
2241
+ let next = b;
2242
+ while (true) {
2243
+ const o = f(next);
2244
+ if (isNone$1(o)) break;
2245
+ const [a, b] = o.value;
2246
+ out.push(a);
2247
+ next = b;
2248
+ }
2249
+ return out;
2250
+ };
2251
+ /**
2252
+ * Creates an `Equivalence` for arrays based on an element `Equivalence`. Two
2253
+ * arrays are equivalent when they have the same length and all elements are
2254
+ * pairwise equivalent.
2255
+ *
2256
+ * **Example** (Comparing arrays for equality)
2257
+ *
2258
+ * ```ts import.meta.vitest
2259
+ * import { Array } from "effect"
2260
+ *
2261
+ * const eq = Array.makeEquivalence<number>((a, b) => a === b)
2262
+ *
2263
+ * eq([1, 2, 3], [1, 2, 3]) // => true
2264
+ * ```
2265
+ *
2266
+ * @see {@link makeOrder} — create an ordering for arrays
2267
+ *
2268
+ * @stability stable
2269
+ * @category instances
2270
+ * @since 4.0.0
2271
+ */
2272
+ const makeEquivalence = Array_;
2273
+ /**
2274
+ * Removes duplicates using `Equal.asEquivalence()`, preserving the order of the
2275
+ * first occurrence.
2276
+ *
2277
+ * **When to use**
2278
+ *
2279
+ * Use to remove repeated values from an iterable when Effect's default equality
2280
+ * is the right comparison, preserving the first occurrence.
2281
+ *
2282
+ * **Example** (Removing duplicates)
2283
+ *
2284
+ * ```ts import.meta.vitest
2285
+ * import { Array } from "effect"
2286
+ *
2287
+ * Array.dedupe([1, 2, 1, 3, 2, 4]) // => [1, 2, 3, 4]
2288
+ * ```
2289
+ *
2290
+ * @see {@link dedupeWith} — use custom equality
2291
+ * @see {@link dedupeAdjacent} — only dedupes consecutive elements
2292
+ *
2293
+ * @stability stable
2294
+ * @category deduplication
2295
+ * @since 2.0.0
2296
+ */
2297
+ const dedupe = (self) => {
2298
+ const input = fromIterable(self);
2299
+ if (input.length < 2) return [...input];
2300
+ const buckets = /* @__PURE__ */ new Map();
2301
+ const out = [];
2302
+ for (const value of input) if (hashBucketsAdd(buckets, value)) out.push(value);
2303
+ return out;
2304
+ };
2305
+ /**
2306
+ * Joins string elements with a separator.
2307
+ *
2308
+ * **Example** (Joining strings)
2309
+ *
2310
+ * ```ts import.meta.vitest
2311
+ * import { Array } from "effect"
2312
+ *
2313
+ * Array.join(["a", "b", "c"], "-") // => "a-b-c"
2314
+ * ```
2315
+ *
2316
+ * @see {@link intersperse} — insert separator elements without joining
2317
+ *
2318
+ * @stability stable
2319
+ * @category folding
2320
+ * @since 2.0.0
2321
+ */
2322
+ const join = /*#__PURE__*/ dual(2, (self, sep) => fromIterable(self).join(sep));
2323
+ export { isFailure as $, makeEquivalence as A, sortWith as B, isReadonlyArrayEmpty as C, lastNonEmpty as D, last as E, of as F, zip as G, takeRight as H, partition as I, makeEquivalence$1 as J, empty$1 as K, reduce as L, match as M, matchLeft as N, length as O, min as P, getOrThrow as Q, some as R, isCanonicalArrayIndex as S, join as T, takeWhile as U, take as V, unfold as W, flatMap$1 as X, fail as Y, fromOption as Z, getSomes as _, drop as a, succeed as at, isArray as b, every as c, normalizeNonEmpty as ct, findFirstIndex as d, strictEqual as dt, isResult as et, findLast as f, get as g, fromIterable as h, dedupe as i, match$1 as it, map as j, makeBy as k, filter as l, isArrayNonEmpty$1 as lt, flatten as m, appendAll as n, map$1 as nt, empty as o, try_ as ot, flatMap as p, headUnsafe as q, contains as r, mapError as rt, ensure as s, normalize as st, append as t, isSuccess as tt, findFirst as u, make$1 as ut, groupBy as v, isReadonlyArrayNonEmpty as w, isArrayNonEmpty as x, head as y, sort as z };