@lmvz-ds/components 0.12.5-alpha.1 → 0.12.5-alpha.5

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 (123) hide show
  1. package/dist/manifest.json +1 -1
  2. package/package.json +4 -4
  3. package/dist/cjs/app-globals-V2Kpy_OQ.js.map +0 -1
  4. package/dist/cjs/assets-Cswkqk_c.js +0 -18971
  5. package/dist/cjs/assets-Cswkqk_c.js.map +0 -1
  6. package/dist/cjs/axe-C2rxi-K2.js +0 -32837
  7. package/dist/cjs/axe-C2rxi-K2.js.map +0 -1
  8. package/dist/cjs/header-integration.lmvz-button.lmvz-header.lmvz-icon.lmvz-input.lmvz-menuitem-BTL_B6qg.js +0 -3665
  9. package/dist/cjs/header-integration.lmvz-button.lmvz-header.lmvz-icon.lmvz-input.lmvz-menuitem-BTL_B6qg.js.map +0 -1
  10. package/dist/cjs/header-integration_6.cjs.entry.js +0 -18
  11. package/dist/cjs/header-integration_6.cjs.entry.js.map +0 -1
  12. package/dist/cjs/icons-jn_Uak9B.js +0 -1063
  13. package/dist/cjs/icons-jn_Uak9B.js.map +0 -1
  14. package/dist/cjs/index-DpBPf1cE.js +0 -2112
  15. package/dist/cjs/index-DpBPf1cE.js.map +0 -1
  16. package/dist/cjs/index.cjs.js.map +0 -1
  17. package/dist/cjs/lmvz-action.cjs.entry.js.map +0 -1
  18. package/dist/cjs/lmvz-card.cjs.entry.js.map +0 -1
  19. package/dist/cjs/lmvz-chip.cjs.entry.js.map +0 -1
  20. package/dist/cjs/lmvz-components.cjs.js.map +0 -1
  21. package/dist/cjs/loader.cjs.js.map +0 -1
  22. package/dist/collection/api/ds.constants.js.map +0 -1
  23. package/dist/collection/api/index.js.map +0 -1
  24. package/dist/collection/components/lmvz-action/lmvz-action.js.map +0 -1
  25. package/dist/collection/components/lmvz-button/lmvz-button.js.map +0 -1
  26. package/dist/collection/components/lmvz-card/lmvz-card.js.map +0 -1
  27. package/dist/collection/components/lmvz-chip/lmvz-chip.js.map +0 -1
  28. package/dist/collection/components/lmvz-header/lmvz-header.js.map +0 -1
  29. package/dist/collection/components/lmvz-icon/icons.js.map +0 -1
  30. package/dist/collection/components/lmvz-icon/lmvz-icon.js.map +0 -1
  31. package/dist/collection/components/lmvz-icon/public.js.map +0 -1
  32. package/dist/collection/components/lmvz-icon/test/icons.unit.js.map +0 -1
  33. package/dist/collection/components/lmvz-input/lmvz-input.js.map +0 -1
  34. package/dist/collection/components/lmvz-menuitem/lmvz-menuitem.js.map +0 -1
  35. package/dist/collection/index.js.map +0 -1
  36. package/dist/collection/integration/header-integration.js.map +0 -1
  37. package/dist/collection/utils/assets.js.map +0 -1
  38. package/dist/collection/utils/component.js.map +0 -1
  39. package/dist/collection/utils/effect.js.map +0 -1
  40. package/dist/collection/utils/element-activation-controller.js.map +0 -1
  41. package/dist/collection/utils/environment.js.map +0 -1
  42. package/dist/collection/utils/http.js.map +0 -1
  43. package/dist/collection/utils/http.test.js.map +0 -1
  44. package/dist/collection/utils/list-keyboard-controller.js.map +0 -1
  45. package/dist/collection/utils/public.js.map +0 -1
  46. package/dist/collection/utils/reactive-controller-host.js.map +0 -1
  47. package/dist/collection/utils/typing.js.map +0 -1
  48. package/dist/collection/utils/validation/aria-validation-controller.js.map +0 -1
  49. package/dist/collection/utils/validation/svg.js.map +0 -1
  50. package/dist/components/header-integration.d.ts +0 -11
  51. package/dist/components/header-integration.js +0 -2
  52. package/dist/components/header-integration.js.map +0 -1
  53. package/dist/components/index.js.map +0 -1
  54. package/dist/components/lmvz-action.js.map +0 -1
  55. package/dist/components/lmvz-button.js.map +0 -1
  56. package/dist/components/lmvz-card.js.map +0 -1
  57. package/dist/components/lmvz-chip.js.map +0 -1
  58. package/dist/components/lmvz-header.js.map +0 -1
  59. package/dist/components/lmvz-icon.js.map +0 -1
  60. package/dist/components/lmvz-input.js.map +0 -1
  61. package/dist/components/lmvz-menuitem.js.map +0 -1
  62. package/dist/components/p-B3JVFwO1.js.map +0 -1
  63. package/dist/components/p-B85MJLTf.js.map +0 -1
  64. package/dist/components/p-CN0JX9-m.js.map +0 -1
  65. package/dist/components/p-Cd4nH2vx.js +0 -2
  66. package/dist/components/p-Cd4nH2vx.js.map +0 -1
  67. package/dist/components/p-CdofjRtQ.js.map +0 -1
  68. package/dist/components/p-CkTUjPwD.js +0 -2
  69. package/dist/components/p-CkTUjPwD.js.map +0 -1
  70. package/dist/components/p-CpI4KFOu.js +0 -2
  71. package/dist/components/p-CpI4KFOu.js.map +0 -1
  72. package/dist/components/p-D1HbKFuh.js.map +0 -1
  73. package/dist/components/p-D7xthqTT.js +0 -2
  74. package/dist/components/p-D7xthqTT.js.map +0 -1
  75. package/dist/components/p-DBeynNeU.js +0 -2
  76. package/dist/components/p-DBeynNeU.js.map +0 -1
  77. package/dist/components/p-DMLRPGid.js.map +0 -1
  78. package/dist/components/p-UiqQVZhU.js +0 -2
  79. package/dist/components/p-UiqQVZhU.js.map +0 -1
  80. package/dist/components/p-Xq267cFM.js +0 -2
  81. package/dist/components/p-Xq267cFM.js.map +0 -1
  82. package/dist/components/p-glDDybgu.js +0 -2
  83. package/dist/components/p-glDDybgu.js.map +0 -1
  84. package/dist/esm/app-globals-DQuL1Twl.js.map +0 -1
  85. package/dist/esm/assets-K2FHD9qn.js +0 -18770
  86. package/dist/esm/assets-K2FHD9qn.js.map +0 -1
  87. package/dist/esm/axe-CZ0Rtkog.js +0 -32835
  88. package/dist/esm/axe-CZ0Rtkog.js.map +0 -1
  89. package/dist/esm/header-integration.lmvz-button.lmvz-header.lmvz-icon.lmvz-input.lmvz-menuitem-CW3FGLZC.js +0 -3657
  90. package/dist/esm/header-integration.lmvz-button.lmvz-header.lmvz-icon.lmvz-input.lmvz-menuitem-CW3FGLZC.js.map +0 -1
  91. package/dist/esm/header-integration_6.entry.js +0 -7
  92. package/dist/esm/header-integration_6.entry.js.map +0 -1
  93. package/dist/esm/icons-BITzEzmq.js +0 -1032
  94. package/dist/esm/icons-BITzEzmq.js.map +0 -1
  95. package/dist/esm/index-D2eyw7iv.js +0 -2101
  96. package/dist/esm/index-D2eyw7iv.js.map +0 -1
  97. package/dist/esm/index.js.map +0 -1
  98. package/dist/esm/lmvz-action.entry.js.map +0 -1
  99. package/dist/esm/lmvz-card.entry.js.map +0 -1
  100. package/dist/esm/lmvz-chip.entry.js.map +0 -1
  101. package/dist/esm/lmvz-components.js.map +0 -1
  102. package/dist/esm/loader.js.map +0 -1
  103. package/dist/lmvz-components/index.esm.js.map +0 -1
  104. package/dist/lmvz-components/lmvz-components.esm.js.map +0 -1
  105. package/dist/lmvz-components/p-366a01f8.entry.js +0 -2
  106. package/dist/lmvz-components/p-366a01f8.entry.js.map +0 -1
  107. package/dist/lmvz-components/p-84ee7919.entry.js +0 -2
  108. package/dist/lmvz-components/p-84ee7919.entry.js.map +0 -1
  109. package/dist/lmvz-components/p-BLwPC3DQ.js +0 -2
  110. package/dist/lmvz-components/p-BLwPC3DQ.js.map +0 -1
  111. package/dist/lmvz-components/p-D2eyw7iv.js +0 -3
  112. package/dist/lmvz-components/p-D2eyw7iv.js.map +0 -1
  113. package/dist/lmvz-components/p-DANVVVBd.js +0 -7
  114. package/dist/lmvz-components/p-DANVVVBd.js.map +0 -1
  115. package/dist/lmvz-components/p-DQuL1Twl.js.map +0 -1
  116. package/dist/lmvz-components/p-DlDurXvX.js +0 -2
  117. package/dist/lmvz-components/p-DlDurXvX.js.map +0 -1
  118. package/dist/lmvz-components/p-Hc4uxoTU.js +0 -13
  119. package/dist/lmvz-components/p-Hc4uxoTU.js.map +0 -1
  120. package/dist/lmvz-components/p-a4200b26.entry.js +0 -2
  121. package/dist/lmvz-components/p-a4200b26.entry.js.map +0 -1
  122. package/dist/lmvz-components/p-d3243bae.entry.js +0 -2
  123. package/dist/lmvz-components/p-d3243bae.entry.js.map +0 -1
@@ -1,3657 +0,0 @@
1
- import { r as registerInstance, h, H as Host, B as Build, g as getElement, c as createEvent } from './index-D2eyw7iv.js';
2
- import { m as make$4, a as modify$1, g as get$1, u as update$1, i as isInterrupted$1, f as fail$2, b as failureOrCause$1, c as flipCauseOption$1, d as map$3, e as die$1, h as interrupt$2, j as isDieType$1, k as interruptors$1, l as isInterruptedOnly$1, n as join$1, o as interruptFiber, _ as _await$1, p as inheritAll$1, q as interruptAsFiber, s as pipe, t as flatMap$2, v as sync$1, w as dual, x as map$4, y as make$5, z as deferredMake, C as Class, A as pipeArguments, B as suspend$2, D as catchAll, E as interrupt$3, F as get$2, G as none, H as some, I as uninterruptible, J as withFiberRuntime, K as set, L as asVoid, M as whenEffect, N as deferredSucceed, O as zipRight$1, P as forEachConcurrentDiscard, Q as deferredAwait, R as succeed$1, S as fromIterable, T as empty, U as splitAt, V as isEmpty, W as deferredUnsafeMake, X as onInterrupt, Y as fromIterable$1, Z as deferredUnsafeDone, $ as prepend, a0 as filter, a1 as appendAll, a2 as append, a3 as deferredInterruptWith, a4 as empty$1, a5 as void_$1, a6 as fiberId, a7 as hasProperty, a8 as isEffect, a9 as identity, aa as match$1, ab as _void, ac as ignore, ad as zipWith, ae as exit, af as sync$2, ag as provide, ah as matchCauseEffect, ai as zipRight$3, aj as flatMap$3, ak as forkDaemon, al as interruptible, am as suspend$3, an as ensuring$2, ao as uninterruptible$1, ap as map$5, aq as zip$1, ar as forEach, as as succeed$3, at as isSome, au as getOrElse, av as dieMessage, aw as catchAllCause, ax as uninterruptibleMask, ay as all$1, az as fork, aA as sequential, aB as acquireUseRelease, aC as forkIn, aD as size$2, aE as combineAll, aF as intoDeferred, aG as zipLeft, aH as tapErrorCause, aI as addFinalizer, aJ as failCause$4, aK as flatten$2, aL as fiberIdWith, aM as interrupt$4, aN as left, aO as right, aP as matchCause, aQ as scopedWith$2, aR as unsafeGet, aS as constVoid, aT as scope, aU as gen, aV as withFiberRuntime$1, aW as make$7, aX as extend, aY as close, aZ as raceWith, a_ as runtime, a$ as tap, b0 as addFinalizerExit, b1 as makeSemaphore, b2 as when, b3 as race, b4 as as, b5 as match$3, b6 as repeat, b7 as asVoid$1, b8 as equals, b9 as raceFirst, ba as forever, bb as of$1, bc as fail$4, bd as mapError, be as reduce, bf as map$7, bg as match$4, bh as splitWhere, bi as head, bj as filterMap, bk as catchAll$1, bl as catchSomeCause, bm as unsafeFromArray, bn as runFork, bo as promise, bp as async, r as runPromise, bq as tapError, br as logError } from './assets-K2FHD9qn.js';
3
- import { u as unbounded$2, l as length, p as poll, E as EmptyMutableQueue, o as offer$2, a as pollUpTo, i as isEmpty$1, b as offerAll, d as bounded$2, e as capacity, f as isFailure, z as zipRight$2, s as succeed$2, g as failCause$3, m as match$2, h as all, v as void_$2, j as die$2, k as map$6, n as make$6, q as isDone, r as succeed$4, _ as _await$2, t as failCause$5, w as fail$3, x as zip$2, y as isSuccess, A as fetchIconSvg, B as emptyDefaultSvg } from './icons-BITzEzmq.js';
4
-
5
- function getDefaultExportFromCjs (x) {
6
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
7
- }
8
-
9
- /**
10
- * @since 2.0.0
11
- * @category constructors
12
- */
13
- const make$3 = make$4;
14
- /**
15
- * @since 2.0.0
16
- * @category getters
17
- */
18
- const get = get$1;
19
- /**
20
- * @since 2.0.0
21
- * @category utils
22
- */
23
- const modify = modify$1;
24
- /**
25
- * @since 2.0.0
26
- * @category utils
27
- */
28
- const update = update$1;
29
-
30
- /**
31
- * Creates a `Fail` cause from an expected error.
32
- *
33
- * **Details**
34
- *
35
- * This function constructs a `Cause` carrying an error of type `E`. It's used
36
- * when you want to represent a known or anticipated failure in your effectful
37
- * computations.
38
- *
39
- * @see {@link isFailure} Check if a `Cause` contains a failure
40
- *
41
- * @since 2.0.0
42
- * @category Constructors
43
- */
44
- const fail$1 = fail$2;
45
- /**
46
- * Creates a `Die` cause from an unexpected error.
47
- *
48
- * **Details**
49
- *
50
- * This function wraps an unhandled or unknown defect (like a runtime crash)
51
- * into a `Cause`. It's useful for capturing unforeseen issues in a structured
52
- * way.
53
- *
54
- * @see {@link isDie} Check if a `Cause` contains a defect
55
- *
56
- * @since 2.0.0
57
- * @category Constructors
58
- */
59
- const die = die$1;
60
- /**
61
- * Creates an `Interrupt` cause from a `FiberId`.
62
- *
63
- * **Details**
64
- *
65
- * This function represents a fiber that has been interrupted. It stores the
66
- * identifier of the interrupted fiber, enabling precise tracking of concurrent
67
- * cancellations.
68
- *
69
- * @see {@link isInterrupted} Check if a `Cause` contains an interruption
70
- *
71
- * @since 2.0.0
72
- * @category Constructors
73
- */
74
- const interrupt$1 = interrupt$2;
75
- /**
76
- * Checks if a `Cause` is a `Die` type.
77
- *
78
- * @see {@link die} Create a new `Die` cause
79
- *
80
- * @since 2.0.0
81
- * @category Guards
82
- */
83
- const isDieType = isDieType$1;
84
- /**
85
- * Checks if a `Cause` contains an interruption.
86
- *
87
- * **Details**
88
- *
89
- * This function returns `true` if the `Cause` includes any fiber interruptions.
90
- *
91
- * @since 2.0.0
92
- * @category Getters
93
- */
94
- const isInterrupted = isInterrupted$1;
95
- /**
96
- * Checks if a `Cause` contains only interruptions.
97
- *
98
- * **Details**
99
- *
100
- * This function returns `true` if the `Cause` has been interrupted but does not
101
- * contain any other failures, such as `Fail` or `Die`. It's helpful for
102
- * verifying purely "cancellation" scenarios.
103
- *
104
- * @since 2.0.0
105
- * @category Getters
106
- */
107
- const isInterruptedOnly = isInterruptedOnly$1;
108
- /**
109
- * Collects all `FiberId`s responsible for interrupting a fiber.
110
- *
111
- * **Details**
112
- *
113
- * This function returns a set of IDs indicating which fibers caused
114
- * interruptions within this `Cause`. It's useful for debugging concurrency
115
- * issues or tracing cancellations.
116
- *
117
- * @since 2.0.0
118
- * @category Getters
119
- */
120
- const interruptors = interruptors$1;
121
- /**
122
- * Splits a `Cause` into either its first `Fail` error or the rest of the cause
123
- * (which might only contain `Die` or `Interrupt`).
124
- *
125
- * **Details**
126
- *
127
- * This function either returns the checked error (`E`) or the remaining
128
- * `Cause<never>` with defects/interruptions. It helps you decide if there's a
129
- * recoverable path or if only unhandled issues remain.
130
- *
131
- * @since 2.0.0
132
- * @category Getters
133
- */
134
- const failureOrCause = failureOrCause$1;
135
- /**
136
- * Strips out failures with an error of `None` from a `Cause<Option<E>>`.
137
- *
138
- * **Details**
139
- *
140
- * This function turns a `Cause<Option<E>>` into an `Option<Cause<E>>`. If the
141
- * cause only contains failures of `None`, it becomes `None`; otherwise, it
142
- * returns a `Cause` of the remaining errors. It's helpful when working with
143
- * optional errors and filtering out certain error paths.
144
- *
145
- * @since 2.0.0
146
- * @category Getters
147
- */
148
- const flipCauseOption = flipCauseOption$1;
149
- /**
150
- * Transforms the errors in a `Cause` using a user-provided function.
151
- *
152
- * **Details**
153
- *
154
- * This function applies `f` to each `Fail` error while leaving defects (`Die`)
155
- * and interruptions untouched. It's useful for changing or simplifying error
156
- * types in your effectful workflows.
157
- *
158
- * @see {@link as} Replace errors with a single constant
159
- *
160
- * @since 2.0.0
161
- * @category Mapping
162
- */
163
- const map$2 = map$3;
164
-
165
- const _await = _await$1;
166
- /**
167
- * Inherits values from all `FiberRef` instances into current fiber. This
168
- * will resume immediately.
169
- *
170
- * @since 2.0.0
171
- * @category destructors
172
- */
173
- const inheritAll = inheritAll$1;
174
- /**
175
- * Interrupts the fiber from whichever fiber is calling this method. If the
176
- * fiber has already exited, the returned effect will resume immediately.
177
- * Otherwise, the effect will resume when the fiber exits.
178
- *
179
- * @since 2.0.0
180
- * @category interruption
181
- */
182
- const interrupt = interruptFiber;
183
- /**
184
- * Interrupts the fiber as if interrupted from the specified fiber. If the
185
- * fiber has already exited, the returned effect will resume immediately.
186
- * Otherwise, the effect will resume when the fiber exits.
187
- *
188
- * @since 2.0.0
189
- * @category interruption
190
- */
191
- const interruptAs = interruptAsFiber;
192
- /**
193
- * Joins the fiber, which suspends the joining fiber until the result of the
194
- * fiber has been determined. Attempting to join a fiber that has erred will
195
- * result in a catchable error. Joining an interrupted fiber will result in an
196
- * "inner interruption" of this fiber, unlike interruption triggered by
197
- * another fiber, "inner interruption" can be caught and recovered.
198
- *
199
- * @since 2.0.0
200
- * @category destructors
201
- */
202
- const join = join$1;
203
-
204
- /** @internal */
205
- const EnqueueSymbolKey = "effect/QueueEnqueue";
206
- /** @internal */
207
- const EnqueueTypeId = /*#__PURE__*/Symbol.for(EnqueueSymbolKey);
208
- /** @internal */
209
- const DequeueSymbolKey = "effect/QueueDequeue";
210
- /** @internal */
211
- const DequeueTypeId = /*#__PURE__*/Symbol.for(DequeueSymbolKey);
212
- /** @internal */
213
- const QueueStrategySymbolKey = "effect/QueueStrategy";
214
- /** @internal */
215
- const QueueStrategyTypeId = /*#__PURE__*/Symbol.for(QueueStrategySymbolKey);
216
- /** @internal */
217
- const BackingQueueSymbolKey = "effect/BackingQueue";
218
- /** @internal */
219
- const BackingQueueTypeId = /*#__PURE__*/Symbol.for(BackingQueueSymbolKey);
220
- const queueStrategyVariance = {
221
- /* c8 ignore next */
222
- _A: _ => _
223
- };
224
- const backingQueueVariance = {
225
- /* c8 ignore next */
226
- _A: _ => _
227
- };
228
- /** @internal */
229
- const enqueueVariance = {
230
- /* c8 ignore next */
231
- _In: _ => _
232
- };
233
- /** @internal */
234
- const dequeueVariance = {
235
- /* c8 ignore next */
236
- _Out: _ => _
237
- };
238
- /** @internal */
239
- class QueueImpl extends Class {
240
- queue;
241
- takers;
242
- shutdownHook;
243
- shutdownFlag;
244
- strategy;
245
- [EnqueueTypeId] = enqueueVariance;
246
- [DequeueTypeId] = dequeueVariance;
247
- constructor(/** @internal */
248
- queue, /** @internal */
249
- takers, /** @internal */
250
- shutdownHook, /** @internal */
251
- shutdownFlag, /** @internal */
252
- strategy) {
253
- super();
254
- this.queue = queue;
255
- this.takers = takers;
256
- this.shutdownHook = shutdownHook;
257
- this.shutdownFlag = shutdownFlag;
258
- this.strategy = strategy;
259
- }
260
- pipe() {
261
- return pipeArguments(this, arguments);
262
- }
263
- commit() {
264
- return this.take;
265
- }
266
- capacity() {
267
- return this.queue.capacity();
268
- }
269
- get size() {
270
- return suspend$2(() => catchAll(this.unsafeSize(), () => interrupt$3));
271
- }
272
- unsafeSize() {
273
- if (get$2(this.shutdownFlag)) {
274
- return none();
275
- }
276
- return some(this.queue.length() - length(this.takers) + this.strategy.surplusSize());
277
- }
278
- get isEmpty() {
279
- return map$4(this.size, size => size <= 0);
280
- }
281
- get isFull() {
282
- return map$4(this.size, size => size >= this.capacity());
283
- }
284
- get shutdown() {
285
- return uninterruptible(withFiberRuntime(state => {
286
- pipe(this.shutdownFlag, set(true));
287
- return pipe(forEachConcurrentDiscard(unsafePollAll(this.takers), d => deferredInterruptWith(d, state.id()), false, false), zipRight$1(this.strategy.shutdown), whenEffect(deferredSucceed(this.shutdownHook, void 0)), asVoid);
288
- }));
289
- }
290
- get isShutdown() {
291
- return sync$1(() => get$2(this.shutdownFlag));
292
- }
293
- get awaitShutdown() {
294
- return deferredAwait(this.shutdownHook);
295
- }
296
- isActive() {
297
- return !get$2(this.shutdownFlag);
298
- }
299
- unsafeOffer(value) {
300
- if (get$2(this.shutdownFlag)) {
301
- return false;
302
- }
303
- let noRemaining;
304
- if (this.queue.length() === 0) {
305
- const taker = pipe(this.takers, poll(EmptyMutableQueue));
306
- if (taker !== EmptyMutableQueue) {
307
- unsafeCompleteDeferred(taker, value);
308
- noRemaining = true;
309
- } else {
310
- noRemaining = false;
311
- }
312
- } else {
313
- noRemaining = false;
314
- }
315
- if (noRemaining) {
316
- return true;
317
- }
318
- // Not enough takers, offer to the queue
319
- const succeeded = this.queue.offer(value);
320
- unsafeCompleteTakers(this.strategy, this.queue, this.takers);
321
- return succeeded;
322
- }
323
- offer(value) {
324
- return suspend$2(() => {
325
- if (get$2(this.shutdownFlag)) {
326
- return interrupt$3;
327
- }
328
- let noRemaining;
329
- if (this.queue.length() === 0) {
330
- const taker = pipe(this.takers, poll(EmptyMutableQueue));
331
- if (taker !== EmptyMutableQueue) {
332
- unsafeCompleteDeferred(taker, value);
333
- noRemaining = true;
334
- } else {
335
- noRemaining = false;
336
- }
337
- } else {
338
- noRemaining = false;
339
- }
340
- if (noRemaining) {
341
- return succeed$1(true);
342
- }
343
- // Not enough takers, offer to the queue
344
- const succeeded = this.queue.offer(value);
345
- unsafeCompleteTakers(this.strategy, this.queue, this.takers);
346
- return succeeded ? succeed$1(true) : this.strategy.handleSurplus([value], this.queue, this.takers, this.shutdownFlag);
347
- });
348
- }
349
- offerAll(iterable) {
350
- return suspend$2(() => {
351
- if (get$2(this.shutdownFlag)) {
352
- return interrupt$3;
353
- }
354
- const values = fromIterable(iterable);
355
- const pTakers = this.queue.length() === 0 ? fromIterable(unsafePollN(this.takers, values.length)) : empty;
356
- const [forTakers, remaining] = pipe(values, splitAt(pTakers.length));
357
- for (let i = 0; i < pTakers.length; i++) {
358
- const taker = pTakers[i];
359
- const item = forTakers[i];
360
- unsafeCompleteDeferred(taker, item);
361
- }
362
- if (remaining.length === 0) {
363
- return succeed$1(true);
364
- }
365
- // Not enough takers, offer to the queue
366
- const surplus = this.queue.offerAll(remaining);
367
- unsafeCompleteTakers(this.strategy, this.queue, this.takers);
368
- return isEmpty(surplus) ? succeed$1(true) : this.strategy.handleSurplus(surplus, this.queue, this.takers, this.shutdownFlag);
369
- });
370
- }
371
- get take() {
372
- return withFiberRuntime(state => {
373
- if (get$2(this.shutdownFlag)) {
374
- return interrupt$3;
375
- }
376
- const item = this.queue.poll(EmptyMutableQueue);
377
- if (item !== EmptyMutableQueue) {
378
- this.strategy.unsafeOnQueueEmptySpace(this.queue, this.takers);
379
- return succeed$1(item);
380
- } else {
381
- // Add the deferred to takers, then:
382
- // - Try to take again in case a value was added since
383
- // - Wait for the deferred to be completed
384
- // - Clean up resources in case of interruption
385
- const deferred = deferredUnsafeMake(state.id());
386
- return pipe(suspend$2(() => {
387
- pipe(this.takers, offer$2(deferred));
388
- unsafeCompleteTakers(this.strategy, this.queue, this.takers);
389
- return get$2(this.shutdownFlag) ? interrupt$3 : deferredAwait(deferred);
390
- }), onInterrupt(() => {
391
- return sync$1(() => unsafeRemove(this.takers, deferred));
392
- }));
393
- }
394
- });
395
- }
396
- get takeAll() {
397
- return suspend$2(() => {
398
- return get$2(this.shutdownFlag) ? interrupt$3 : sync$1(() => {
399
- const values = this.queue.pollUpTo(Number.POSITIVE_INFINITY);
400
- this.strategy.unsafeOnQueueEmptySpace(this.queue, this.takers);
401
- return fromIterable$1(values);
402
- });
403
- });
404
- }
405
- takeUpTo(max) {
406
- return suspend$2(() => get$2(this.shutdownFlag) ? interrupt$3 : sync$1(() => {
407
- const values = this.queue.pollUpTo(max);
408
- this.strategy.unsafeOnQueueEmptySpace(this.queue, this.takers);
409
- return fromIterable$1(values);
410
- }));
411
- }
412
- takeBetween(min, max) {
413
- return suspend$2(() => takeRemainderLoop(this, min, max, empty$1()));
414
- }
415
- }
416
- /** @internal */
417
- const takeRemainderLoop = (self, min, max, acc) => {
418
- if (max < min) {
419
- return succeed$1(acc);
420
- }
421
- return pipe(takeUpTo(self, max), flatMap$2(bs => {
422
- const remaining = min - bs.length;
423
- if (remaining === 1) {
424
- return pipe(take$1(self), map$4(b => pipe(acc, appendAll(bs), append(b))));
425
- }
426
- if (remaining > 1) {
427
- return pipe(take$1(self), flatMap$2(b => takeRemainderLoop(self, remaining - 1, max - bs.length - 1, pipe(acc, appendAll(bs), append(b)))));
428
- }
429
- return succeed$1(pipe(acc, appendAll(bs)));
430
- }));
431
- };
432
- /** @internal */
433
- const bounded$1 = requestedCapacity => pipe(sync$1(() => bounded$2(requestedCapacity)), flatMap$2(queue => make$2(backingQueueFromMutableQueue(queue), backPressureStrategy())));
434
- /** @internal */
435
- const unbounded$1 = () => pipe(sync$1(() => unbounded$2()), flatMap$2(queue => make$2(backingQueueFromMutableQueue(queue), droppingStrategy())));
436
- /** @internal */
437
- const unsafeMake = (queue, takers, shutdownHook, shutdownFlag, strategy) => {
438
- return new QueueImpl(queue, takers, shutdownHook, shutdownFlag, strategy);
439
- };
440
- /** @internal */
441
- const make$2 = (queue, strategy) => pipe(deferredMake(), map$4(deferred => unsafeMake(queue, unbounded$2(), deferred, make$5(false), strategy)));
442
- /** @internal */
443
- class BackingQueueFromMutableQueue {
444
- mutable;
445
- [BackingQueueTypeId] = backingQueueVariance;
446
- constructor(mutable) {
447
- this.mutable = mutable;
448
- }
449
- poll(def) {
450
- return poll(this.mutable, def);
451
- }
452
- pollUpTo(limit) {
453
- return pollUpTo(this.mutable, limit);
454
- }
455
- offerAll(elements) {
456
- return offerAll(this.mutable, elements);
457
- }
458
- offer(element) {
459
- return offer$2(this.mutable, element);
460
- }
461
- capacity() {
462
- return capacity(this.mutable);
463
- }
464
- length() {
465
- return length(this.mutable);
466
- }
467
- }
468
- /** @internal */
469
- const backingQueueFromMutableQueue = mutable => new BackingQueueFromMutableQueue(mutable);
470
- /** @internal */
471
- const size$1 = self => self.size;
472
- /** @internal */
473
- const isShutdown$1 = self => self.isShutdown;
474
- /** @internal */
475
- const shutdown$1 = self => self.shutdown;
476
- /** @internal */
477
- const offer$1 = /*#__PURE__*/dual(2, (self, value) => self.offer(value));
478
- /** @internal */
479
- const take$1 = self => self.take;
480
- /** @internal */
481
- const takeUpTo = /*#__PURE__*/dual(2, (self, max) => self.takeUpTo(max));
482
- /** @internal */
483
- const takeBetween$1 = /*#__PURE__*/dual(3, (self, min, max) => self.takeBetween(min, max));
484
- // -----------------------------------------------------------------------------
485
- // Strategy
486
- // -----------------------------------------------------------------------------
487
- /** @internal */
488
- const backPressureStrategy = () => new BackPressureStrategy();
489
- /** @internal */
490
- const droppingStrategy = () => new DroppingStrategy();
491
- /** @internal */
492
- class BackPressureStrategy {
493
- [QueueStrategyTypeId] = queueStrategyVariance;
494
- putters = /*#__PURE__*/unbounded$2();
495
- surplusSize() {
496
- return length(this.putters);
497
- }
498
- onCompleteTakersWithEmptyQueue(takers) {
499
- while (!isEmpty$1(this.putters) && !isEmpty$1(takers)) {
500
- const taker = poll(takers, void 0);
501
- const putter = poll(this.putters, void 0);
502
- if (putter[2]) {
503
- unsafeCompleteDeferred(putter[1], true);
504
- }
505
- unsafeCompleteDeferred(taker, putter[0]);
506
- }
507
- }
508
- get shutdown() {
509
- return pipe(fiberId, flatMap$2(fiberId => pipe(sync$1(() => unsafePollAll(this.putters)), flatMap$2(putters => forEachConcurrentDiscard(putters, ([_, deferred, isLastItem]) => isLastItem ? pipe(deferredInterruptWith(deferred, fiberId), asVoid) : void_$1, false, false)))));
510
- }
511
- handleSurplus(iterable, queue, takers, isShutdown) {
512
- return withFiberRuntime(state => {
513
- const deferred = deferredUnsafeMake(state.id());
514
- return pipe(suspend$2(() => {
515
- this.unsafeOffer(iterable, deferred);
516
- this.unsafeOnQueueEmptySpace(queue, takers);
517
- unsafeCompleteTakers(this, queue, takers);
518
- return get$2(isShutdown) ? interrupt$3 : deferredAwait(deferred);
519
- }), onInterrupt(() => sync$1(() => this.unsafeRemove(deferred))));
520
- });
521
- }
522
- unsafeOnQueueEmptySpace(queue, takers) {
523
- let keepPolling = true;
524
- while (keepPolling && (queue.capacity() === Number.POSITIVE_INFINITY || queue.length() < queue.capacity())) {
525
- const putter = pipe(this.putters, poll(EmptyMutableQueue));
526
- if (putter === EmptyMutableQueue) {
527
- keepPolling = false;
528
- } else {
529
- const offered = queue.offer(putter[0]);
530
- if (offered && putter[2]) {
531
- unsafeCompleteDeferred(putter[1], true);
532
- } else if (!offered) {
533
- unsafeOfferAll(this.putters, pipe(unsafePollAll(this.putters), prepend(putter)));
534
- }
535
- unsafeCompleteTakers(this, queue, takers);
536
- }
537
- }
538
- }
539
- unsafeOffer(iterable, deferred) {
540
- const stuff = fromIterable(iterable);
541
- for (let i = 0; i < stuff.length; i++) {
542
- const value = stuff[i];
543
- if (i === stuff.length - 1) {
544
- pipe(this.putters, offer$2([value, deferred, true]));
545
- } else {
546
- pipe(this.putters, offer$2([value, deferred, false]));
547
- }
548
- }
549
- }
550
- unsafeRemove(deferred) {
551
- unsafeOfferAll(this.putters, pipe(unsafePollAll(this.putters), filter(([, _]) => _ !== deferred)));
552
- }
553
- }
554
- /** @internal */
555
- class DroppingStrategy {
556
- [QueueStrategyTypeId] = queueStrategyVariance;
557
- surplusSize() {
558
- return 0;
559
- }
560
- get shutdown() {
561
- return void_$1;
562
- }
563
- onCompleteTakersWithEmptyQueue() {}
564
- handleSurplus(_iterable, _queue, _takers, _isShutdown) {
565
- return succeed$1(false);
566
- }
567
- unsafeOnQueueEmptySpace(_queue, _takers) {
568
- //
569
- }
570
- }
571
- /** @internal */
572
- const unsafeCompleteDeferred = (deferred, a) => {
573
- return deferredUnsafeDone(deferred, succeed$1(a));
574
- };
575
- /** @internal */
576
- const unsafeOfferAll = (queue, as) => {
577
- return pipe(queue, offerAll(as));
578
- };
579
- /** @internal */
580
- const unsafePollAll = queue => {
581
- return pipe(queue, pollUpTo(Number.POSITIVE_INFINITY));
582
- };
583
- /** @internal */
584
- const unsafePollN = (queue, max) => {
585
- return pipe(queue, pollUpTo(max));
586
- };
587
- /** @internal */
588
- const unsafeRemove = (queue, a) => {
589
- unsafeOfferAll(queue, pipe(unsafePollAll(queue), filter(b => a !== b)));
590
- };
591
- /** @internal */
592
- const unsafeCompleteTakers = (strategy, queue, takers) => {
593
- // Check both a taker and an item are in the queue, starting with the taker
594
- let keepPolling = true;
595
- while (keepPolling && queue.length() !== 0) {
596
- const taker = pipe(takers, poll(EmptyMutableQueue));
597
- if (taker !== EmptyMutableQueue) {
598
- const element = queue.poll(EmptyMutableQueue);
599
- if (element !== EmptyMutableQueue) {
600
- unsafeCompleteDeferred(taker, element);
601
- strategy.unsafeOnQueueEmptySpace(queue, takers);
602
- } else {
603
- unsafeOfferAll(takers, pipe(unsafePollAll(takers), prepend(taker)));
604
- }
605
- keepPolling = true;
606
- } else {
607
- keepPolling = false;
608
- }
609
- }
610
- if (keepPolling && queue.length() === 0 && !isEmpty$1(takers)) {
611
- strategy.onCompleteTakersWithEmptyQueue(takers);
612
- }
613
- };
614
-
615
- /**
616
- * Makes a new bounded `Queue`. When the capacity of the queue is reached, any
617
- * additional calls to `offer` will be suspended until there is more room in
618
- * the queue.
619
- *
620
- * **Note**: When possible use only power of 2 capacities; this will provide
621
- * better performance by utilising an optimised version of the underlying
622
- * `RingBuffer`.
623
- *
624
- * @since 2.0.0
625
- * @category constructors
626
- */
627
- const bounded = bounded$1;
628
- /**
629
- * Creates a new unbounded `Queue`.
630
- *
631
- * @since 2.0.0
632
- * @category constructors
633
- */
634
- const unbounded = unbounded$1;
635
- /**
636
- * Retrieves the size of the queue, which is equal to the number of elements
637
- * in the queue. This may be negative if fibers are suspended waiting for
638
- * elements to be added to the queue.
639
- *
640
- * @since 2.0.0
641
- * @category getters
642
- */
643
- const size = size$1;
644
- /**
645
- * Returns `true` if `shutdown` has been called, otherwise returns `false`.
646
- *
647
- * @since 2.0.0
648
- * @category getters
649
- */
650
- const isShutdown = isShutdown$1;
651
- /**
652
- * Interrupts any fibers that are suspended on `offer` or `take`. Future calls
653
- * to `offer*` and `take*` will be interrupted immediately.
654
- *
655
- * @since 2.0.0
656
- * @category utils
657
- */
658
- const shutdown = shutdown$1;
659
- /**
660
- * Places one value in the queue.
661
- *
662
- * @since 2.0.0
663
- * @category utils
664
- */
665
- const offer = offer$1;
666
- /**
667
- * Takes the oldest value in the queue. If the queue is empty, this will return
668
- * a computation that resumes when an item has been added to the queue.
669
- *
670
- * @since 2.0.0
671
- * @category utils
672
- */
673
- const take = take$1;
674
- /**
675
- * Takes a number of elements from the queue between the specified minimum and
676
- * maximum. If there are fewer than the minimum number of elements available,
677
- * suspends until at least the minimum number of elements have been collected.
678
- *
679
- * @since 2.0.0
680
- * @category utils
681
- */
682
- const takeBetween = takeBetween$1;
683
-
684
- /** @internal */
685
- const OP_CONTINUE = "Continue";
686
- /** @internal */
687
- const OP_CLOSE = "Close";
688
- /** @internal */
689
- const OP_YIELD = "Yield";
690
-
691
- /** @internal */
692
- const ChildExecutorDecisionSymbolKey = "effect/ChannelChildExecutorDecision";
693
- /** @internal */
694
- const ChildExecutorDecisionTypeId = /*#__PURE__*/Symbol.for(ChildExecutorDecisionSymbolKey);
695
- /** @internal */
696
- const proto$7 = {
697
- [ChildExecutorDecisionTypeId]: ChildExecutorDecisionTypeId
698
- };
699
- /** @internal */
700
- const Continue = _ => {
701
- const op = Object.create(proto$7);
702
- op._tag = OP_CONTINUE;
703
- return op;
704
- };
705
-
706
- /** @internal */
707
- const OP_CONTINUATION_K = "ContinuationK";
708
- /** @internal */
709
- const OP_CONTINUATION_FINALIZER = "ContinuationFinalizer";
710
-
711
- /** @internal */
712
- const ContinuationTypeId = /*#__PURE__*/Symbol.for("effect/ChannelContinuation");
713
- const continuationVariance = {
714
- /* c8 ignore next */
715
- _Env: _ => _,
716
- /* c8 ignore next */
717
- _InErr: _ => _,
718
- /* c8 ignore next */
719
- _InElem: _ => _,
720
- /* c8 ignore next */
721
- _InDone: _ => _,
722
- /* c8 ignore next */
723
- _OutErr: _ => _,
724
- /* c8 ignore next */
725
- _OutDone: _ => _,
726
- /* c8 ignore next */
727
- _OutErr2: _ => _,
728
- /* c8 ignore next */
729
- _OutElem: _ => _,
730
- /* c8 ignore next */
731
- _OutDone2: _ => _
732
- };
733
- /** @internal */
734
- class ContinuationKImpl {
735
- onSuccess;
736
- onHalt;
737
- _tag = OP_CONTINUATION_K;
738
- [ContinuationTypeId] = continuationVariance;
739
- constructor(onSuccess, onHalt) {
740
- this.onSuccess = onSuccess;
741
- this.onHalt = onHalt;
742
- }
743
- onExit(exit) {
744
- return isFailure(exit) ? this.onHalt(exit.cause) : this.onSuccess(exit.value);
745
- }
746
- }
747
- /** @internal */
748
- class ContinuationFinalizerImpl {
749
- finalizer;
750
- _tag = OP_CONTINUATION_FINALIZER;
751
- [ContinuationTypeId] = continuationVariance;
752
- constructor(finalizer) {
753
- this.finalizer = finalizer;
754
- }
755
- }
756
-
757
- /** @internal */
758
- const OP_PULL_AFTER_NEXT = "PullAfterNext";
759
- /** @internal */
760
- const OP_PULL_AFTER_ALL_ENQUEUED = "PullAfterAllEnqueued";
761
-
762
- /** @internal */
763
- const UpstreamPullStrategySymbolKey = "effect/ChannelUpstreamPullStrategy";
764
- /** @internal */
765
- const UpstreamPullStrategyTypeId = /*#__PURE__*/Symbol.for(UpstreamPullStrategySymbolKey);
766
- const upstreamPullStrategyVariance = {
767
- /* c8 ignore next */
768
- _A: _ => _
769
- };
770
- /** @internal */
771
- const proto$6 = {
772
- [UpstreamPullStrategyTypeId]: upstreamPullStrategyVariance
773
- };
774
- /** @internal */
775
- const PullAfterNext = emitSeparator => {
776
- const op = Object.create(proto$6);
777
- op._tag = OP_PULL_AFTER_NEXT;
778
- op.emitSeparator = emitSeparator;
779
- return op;
780
- };
781
-
782
- /** @internal */
783
- const OP_BRACKET_OUT = "BracketOut";
784
- /** @internal */
785
- const OP_BRIDGE = "Bridge";
786
- /** @internal */
787
- const OP_CONCAT_ALL = "ConcatAll";
788
- /** @internal */
789
- const OP_EMIT$2 = "Emit";
790
- /** @internal */
791
- const OP_ENSURING = "Ensuring";
792
- /** @internal */
793
- const OP_FAIL = "Fail";
794
- /** @internal */
795
- const OP_FOLD = "Fold";
796
- /** @internal */
797
- const OP_FROM_EFFECT$1 = "FromEffect";
798
- /** @internal */
799
- const OP_PIPE_TO = "PipeTo";
800
- /** @internal */
801
- const OP_PROVIDE = "Provide";
802
- /** @internal */
803
- const OP_READ$1 = "Read";
804
- /** @internal */
805
- const OP_SUCCEED = "Succeed";
806
- /** @internal */
807
- const OP_SUCCEED_NOW = "SucceedNow";
808
- /** @internal */
809
- const OP_SUSPEND = "Suspend";
810
-
811
- /** @internal */
812
- const ChannelSymbolKey = "effect/Channel";
813
- /** @internal */
814
- const ChannelTypeId = /*#__PURE__*/Symbol.for(ChannelSymbolKey);
815
- const channelVariance = {
816
- /* c8 ignore next */
817
- _Env: _ => _,
818
- /* c8 ignore next */
819
- _InErr: _ => _,
820
- /* c8 ignore next */
821
- _InElem: _ => _,
822
- /* c8 ignore next */
823
- _InDone: _ => _,
824
- /* c8 ignore next */
825
- _OutErr: _ => _,
826
- /* c8 ignore next */
827
- _OutElem: _ => _,
828
- /* c8 ignore next */
829
- _OutDone: _ => _
830
- };
831
- /** @internal */
832
- const proto$5 = {
833
- [ChannelTypeId]: channelVariance,
834
- pipe() {
835
- return pipeArguments(this, arguments);
836
- }
837
- };
838
- /** @internal */
839
- const isChannel = u => hasProperty(u, ChannelTypeId) || isEffect(u);
840
- /** @internal */
841
- const acquireReleaseOut = /*#__PURE__*/dual(2, (self, release) => {
842
- const op = Object.create(proto$5);
843
- op._tag = OP_BRACKET_OUT;
844
- op.acquire = () => self;
845
- op.finalizer = release;
846
- return op;
847
- });
848
- /** @internal */
849
- const concatAllWith = (channels, f, g) => {
850
- const op = Object.create(proto$5);
851
- op._tag = OP_CONCAT_ALL;
852
- op.combineInners = f;
853
- op.combineAll = g;
854
- op.onPull = () => PullAfterNext(none());
855
- op.onEmit = () => Continue;
856
- op.value = () => channels;
857
- op.k = identity;
858
- return op;
859
- };
860
- /** @internal */
861
- const concatMapWith = /*#__PURE__*/dual(4, (self, f, g, h) => {
862
- const op = Object.create(proto$5);
863
- op._tag = OP_CONCAT_ALL;
864
- op.combineInners = g;
865
- op.combineAll = h;
866
- op.onPull = () => PullAfterNext(none());
867
- op.onEmit = () => Continue;
868
- op.value = () => self;
869
- op.k = f;
870
- return op;
871
- });
872
- /** @internal */
873
- const embedInput = /*#__PURE__*/dual(2, (self, input) => {
874
- const op = Object.create(proto$5);
875
- op._tag = OP_BRIDGE;
876
- op.input = input;
877
- op.channel = self;
878
- return op;
879
- });
880
- /** @internal */
881
- const ensuringWith = /*#__PURE__*/dual(2, (self, finalizer) => {
882
- const op = Object.create(proto$5);
883
- op._tag = OP_ENSURING;
884
- op.channel = self;
885
- op.finalizer = finalizer;
886
- return op;
887
- });
888
- /** @internal */
889
- const fail = error => failCause$2(fail$1(error));
890
- /** @internal */
891
- const failCause$2 = cause => failCauseSync(() => cause);
892
- /** @internal */
893
- const failCauseSync = evaluate => {
894
- const op = Object.create(proto$5);
895
- op._tag = OP_FAIL;
896
- op.error = evaluate;
897
- return op;
898
- };
899
- /** @internal */
900
- const flatMap$1 = /*#__PURE__*/dual(2, (self, f) => {
901
- const op = Object.create(proto$5);
902
- op._tag = OP_FOLD;
903
- op.channel = self;
904
- op.k = new ContinuationKImpl(f, failCause$2);
905
- return op;
906
- });
907
- /** @internal */
908
- const fromEffect$3 = effect => {
909
- const op = Object.create(proto$5);
910
- op._tag = OP_FROM_EFFECT$1;
911
- op.effect = () => effect;
912
- return op;
913
- };
914
- /** @internal */
915
- const pipeTo = /*#__PURE__*/dual(2, (self, that) => {
916
- const op = Object.create(proto$5);
917
- op._tag = OP_PIPE_TO;
918
- op.left = () => self;
919
- op.right = () => that;
920
- return op;
921
- });
922
- /** @internal */
923
- const readWith = options => readWithCause({
924
- onInput: options.onInput,
925
- onFailure: cause => match$1(failureOrCause(cause), {
926
- onLeft: options.onFailure,
927
- onRight: failCause$2
928
- }),
929
- onDone: options.onDone
930
- });
931
- /** @internal */
932
- const readWithCause = options => {
933
- const op = Object.create(proto$5);
934
- op._tag = OP_READ$1;
935
- op.more = options.onInput;
936
- op.done = new ContinuationKImpl(options.onDone, options.onFailure);
937
- return op;
938
- };
939
- /** @internal */
940
- const succeed = value => sync(() => value);
941
- /** @internal */
942
- const succeedNow = result => {
943
- const op = Object.create(proto$5);
944
- op._tag = OP_SUCCEED_NOW;
945
- op.terminal = result;
946
- return op;
947
- };
948
- /** @internal */
949
- const suspend$1 = evaluate => {
950
- const op = Object.create(proto$5);
951
- op._tag = OP_SUSPEND;
952
- op.channel = evaluate;
953
- return op;
954
- };
955
- const sync = evaluate => {
956
- const op = Object.create(proto$5);
957
- op._tag = OP_SUCCEED;
958
- op.evaluate = evaluate;
959
- return op;
960
- };
961
- const void_ = /*#__PURE__*/succeedNow(void 0);
962
- /** @internal */
963
- const write = out => {
964
- const op = Object.create(proto$5);
965
- op._tag = OP_EMIT$2;
966
- op.out = out;
967
- return op;
968
- };
969
-
970
- /** @internal */
971
- const OP_DONE$1 = "Done";
972
- /** @internal */
973
- const OP_EMIT$1 = "Emit";
974
- /** @internal */
975
- const OP_FROM_EFFECT = "FromEffect";
976
- /** @internal */
977
- const OP_READ = "Read";
978
-
979
- /** @internal */
980
- const ChannelStateTypeId = /*#__PURE__*/Symbol.for("effect/ChannelState");
981
- const channelStateVariance = {
982
- /* c8 ignore next */
983
- _E: _ => _,
984
- /* c8 ignore next */
985
- _R: _ => _
986
- };
987
- /** @internal */
988
- const proto$4 = {
989
- [ChannelStateTypeId]: channelStateVariance
990
- };
991
- /** @internal */
992
- const Done = () => {
993
- const op = Object.create(proto$4);
994
- op._tag = OP_DONE$1;
995
- return op;
996
- };
997
- /** @internal */
998
- const Emit$1 = () => {
999
- const op = Object.create(proto$4);
1000
- op._tag = OP_EMIT$1;
1001
- return op;
1002
- };
1003
- /** @internal */
1004
- const fromEffect$2 = effect => {
1005
- const op = Object.create(proto$4);
1006
- op._tag = OP_FROM_EFFECT;
1007
- op.effect = effect;
1008
- return op;
1009
- };
1010
- /** @internal */
1011
- const Read = (upstream, onEffect, onEmit, onDone) => {
1012
- const op = Object.create(proto$4);
1013
- op._tag = OP_READ;
1014
- op.upstream = upstream;
1015
- op.onEffect = onEffect;
1016
- op.onEmit = onEmit;
1017
- op.onDone = onDone;
1018
- return op;
1019
- };
1020
- /** @internal */
1021
- const isFromEffect = self => self._tag === OP_FROM_EFFECT;
1022
- /** @internal */
1023
- const effect = self => isFromEffect(self) ? self.effect : _void;
1024
- /** @internal */
1025
- const effectOrUndefinedIgnored = self => isFromEffect(self) ? ignore(self.effect) : undefined;
1026
-
1027
- /** @internal */
1028
- const OP_PULL_FROM_CHILD = "PullFromChild";
1029
- /** @internal */
1030
- const OP_PULL_FROM_UPSTREAM = "PullFromUpstream";
1031
- /** @internal */
1032
- const OP_DRAIN_CHILD_EXECUTORS = "DrainChildExecutors";
1033
- /** @internal */
1034
- const OP_EMIT = "Emit";
1035
- /**
1036
- * Execute the `childExecutor` and on each emitted value, decide what to do by
1037
- * `onEmit`.
1038
- *
1039
- * @internal
1040
- */
1041
- class PullFromChild {
1042
- childExecutor;
1043
- parentSubexecutor;
1044
- onEmit;
1045
- _tag = OP_PULL_FROM_CHILD;
1046
- constructor(childExecutor, parentSubexecutor, onEmit) {
1047
- this.childExecutor = childExecutor;
1048
- this.parentSubexecutor = parentSubexecutor;
1049
- this.onEmit = onEmit;
1050
- }
1051
- close(exit$1) {
1052
- const fin1 = this.childExecutor.close(exit$1);
1053
- const fin2 = this.parentSubexecutor.close(exit$1);
1054
- if (fin1 !== undefined && fin2 !== undefined) {
1055
- return zipWith(exit(fin1), exit(fin2), (exit1, exit2) => pipe(exit1, zipRight$2(exit2)));
1056
- } else if (fin1 !== undefined) {
1057
- return fin1;
1058
- } else if (fin2 !== undefined) {
1059
- return fin2;
1060
- } else {
1061
- return undefined;
1062
- }
1063
- }
1064
- enqueuePullFromChild(_child) {
1065
- return this;
1066
- }
1067
- }
1068
- /**
1069
- * Execute `upstreamExecutor` and for each emitted element, spawn a child
1070
- * channel and continue with processing it by `PullFromChild`.
1071
- *
1072
- * @internal
1073
- */
1074
- class PullFromUpstream {
1075
- upstreamExecutor;
1076
- createChild;
1077
- lastDone;
1078
- activeChildExecutors;
1079
- combineChildResults;
1080
- combineWithChildResult;
1081
- onPull;
1082
- onEmit;
1083
- _tag = OP_PULL_FROM_UPSTREAM;
1084
- constructor(upstreamExecutor, createChild, lastDone, activeChildExecutors, combineChildResults, combineWithChildResult, onPull, onEmit) {
1085
- this.upstreamExecutor = upstreamExecutor;
1086
- this.createChild = createChild;
1087
- this.lastDone = lastDone;
1088
- this.activeChildExecutors = activeChildExecutors;
1089
- this.combineChildResults = combineChildResults;
1090
- this.combineWithChildResult = combineWithChildResult;
1091
- this.onPull = onPull;
1092
- this.onEmit = onEmit;
1093
- }
1094
- close(exit$1) {
1095
- const fin1 = this.upstreamExecutor.close(exit$1);
1096
- const fins = [...this.activeChildExecutors.map(child => child !== undefined ? child.childExecutor.close(exit$1) : undefined), fin1];
1097
- const result = fins.reduce((acc, next) => {
1098
- if (acc !== undefined && next !== undefined) {
1099
- return zipWith(acc, exit(next), (exit1, exit2) => zipRight$2(exit1, exit2));
1100
- } else if (acc !== undefined) {
1101
- return acc;
1102
- } else if (next !== undefined) {
1103
- return exit(next);
1104
- } else {
1105
- return undefined;
1106
- }
1107
- }, undefined);
1108
- return result === undefined ? result : result;
1109
- }
1110
- enqueuePullFromChild(child) {
1111
- return new PullFromUpstream(this.upstreamExecutor, this.createChild, this.lastDone, [...this.activeChildExecutors, child], this.combineChildResults, this.combineWithChildResult, this.onPull, this.onEmit);
1112
- }
1113
- }
1114
- /**
1115
- * Transformed from `PullFromUpstream` when upstream has finished but there
1116
- * are still active child executors.
1117
- *
1118
- * @internal
1119
- */
1120
- class DrainChildExecutors {
1121
- upstreamExecutor;
1122
- lastDone;
1123
- activeChildExecutors;
1124
- upstreamDone;
1125
- combineChildResults;
1126
- combineWithChildResult;
1127
- onPull;
1128
- _tag = OP_DRAIN_CHILD_EXECUTORS;
1129
- constructor(upstreamExecutor, lastDone, activeChildExecutors, upstreamDone, combineChildResults, combineWithChildResult, onPull) {
1130
- this.upstreamExecutor = upstreamExecutor;
1131
- this.lastDone = lastDone;
1132
- this.activeChildExecutors = activeChildExecutors;
1133
- this.upstreamDone = upstreamDone;
1134
- this.combineChildResults = combineChildResults;
1135
- this.combineWithChildResult = combineWithChildResult;
1136
- this.onPull = onPull;
1137
- }
1138
- close(exit$1) {
1139
- const fin1 = this.upstreamExecutor.close(exit$1);
1140
- const fins = [...this.activeChildExecutors.map(child => child !== undefined ? child.childExecutor.close(exit$1) : undefined), fin1];
1141
- const result = fins.reduce((acc, next) => {
1142
- if (acc !== undefined && next !== undefined) {
1143
- return zipWith(acc, exit(next), (exit1, exit2) => zipRight$2(exit1, exit2));
1144
- } else if (acc !== undefined) {
1145
- return acc;
1146
- } else if (next !== undefined) {
1147
- return exit(next);
1148
- } else {
1149
- return undefined;
1150
- }
1151
- }, undefined);
1152
- return result === undefined ? result : result;
1153
- }
1154
- enqueuePullFromChild(child) {
1155
- return new DrainChildExecutors(this.upstreamExecutor, this.lastDone, [...this.activeChildExecutors, child], this.upstreamDone, this.combineChildResults, this.combineWithChildResult, this.onPull);
1156
- }
1157
- }
1158
- /** @internal */
1159
- class Emit {
1160
- value;
1161
- next;
1162
- _tag = OP_EMIT;
1163
- constructor(value, next) {
1164
- this.value = value;
1165
- this.next = next;
1166
- }
1167
- close(exit) {
1168
- const result = this.next.close(exit);
1169
- return result === undefined ? result : result;
1170
- }
1171
- enqueuePullFromChild(_child) {
1172
- return this;
1173
- }
1174
- }
1175
-
1176
- /** @internal */
1177
- const OP_PULLED = "Pulled";
1178
- /** @internal */
1179
- const OP_NO_UPSTREAM = "NoUpstream";
1180
-
1181
- /** @internal */
1182
- const UpstreamPullRequestSymbolKey = "effect/ChannelUpstreamPullRequest";
1183
- /** @internal */
1184
- const UpstreamPullRequestTypeId = /*#__PURE__*/Symbol.for(UpstreamPullRequestSymbolKey);
1185
- const upstreamPullRequestVariance = {
1186
- /* c8 ignore next */
1187
- _A: _ => _
1188
- };
1189
- /** @internal */
1190
- const proto$3 = {
1191
- [UpstreamPullRequestTypeId]: upstreamPullRequestVariance
1192
- };
1193
- /** @internal */
1194
- const Pulled = value => {
1195
- const op = Object.create(proto$3);
1196
- op._tag = OP_PULLED;
1197
- op.value = value;
1198
- return op;
1199
- };
1200
- /** @internal */
1201
- const NoUpstream = activeDownstreamCount => {
1202
- const op = Object.create(proto$3);
1203
- op._tag = OP_NO_UPSTREAM;
1204
- op.activeDownstreamCount = activeDownstreamCount;
1205
- return op;
1206
- };
1207
-
1208
- /** @internal */
1209
- class ChannelExecutor {
1210
- _activeSubexecutor = undefined;
1211
- _cancelled = undefined;
1212
- _closeLastSubstream = undefined;
1213
- _currentChannel;
1214
- _done = undefined;
1215
- _doneStack = [];
1216
- _emitted = undefined;
1217
- _executeCloseLastSubstream;
1218
- _input = undefined;
1219
- _inProgressFinalizer = undefined;
1220
- _providedEnv;
1221
- constructor(initialChannel, providedEnv, executeCloseLastSubstream) {
1222
- this._currentChannel = initialChannel;
1223
- this._executeCloseLastSubstream = executeCloseLastSubstream;
1224
- this._providedEnv = providedEnv;
1225
- }
1226
- run() {
1227
- let result = undefined;
1228
- while (result === undefined) {
1229
- if (this._cancelled !== undefined) {
1230
- result = this.processCancellation();
1231
- } else if (this._activeSubexecutor !== undefined) {
1232
- result = this.runSubexecutor();
1233
- } else {
1234
- try {
1235
- if (this._currentChannel === undefined) {
1236
- result = Done();
1237
- } else {
1238
- if (isEffect(this._currentChannel)) {
1239
- this._currentChannel = fromEffect$3(this._currentChannel);
1240
- }
1241
- switch (this._currentChannel._tag) {
1242
- case OP_BRACKET_OUT:
1243
- {
1244
- result = this.runBracketOut(this._currentChannel);
1245
- break;
1246
- }
1247
- case OP_BRIDGE:
1248
- {
1249
- const bridgeInput = this._currentChannel.input;
1250
- // PipeTo(left, Bridge(queue, channel))
1251
- // In a fiber: repeatedly run left and push its outputs to the queue
1252
- // Add a finalizer to interrupt the fiber and close the executor
1253
- this._currentChannel = this._currentChannel.channel;
1254
- if (this._input !== undefined) {
1255
- const inputExecutor = this._input;
1256
- this._input = undefined;
1257
- const drainer = () => flatMap$3(bridgeInput.awaitRead(), () => suspend$3(() => {
1258
- const state = inputExecutor.run();
1259
- switch (state._tag) {
1260
- case OP_DONE$1:
1261
- {
1262
- return match$2(inputExecutor.getDone(), {
1263
- onFailure: cause => bridgeInput.error(cause),
1264
- onSuccess: value => bridgeInput.done(value)
1265
- });
1266
- }
1267
- case OP_EMIT$1:
1268
- {
1269
- return flatMap$3(bridgeInput.emit(inputExecutor.getEmit()), () => drainer());
1270
- }
1271
- case OP_FROM_EFFECT:
1272
- {
1273
- return matchCauseEffect(state.effect, {
1274
- onFailure: cause => bridgeInput.error(cause),
1275
- onSuccess: () => drainer()
1276
- });
1277
- }
1278
- case OP_READ:
1279
- {
1280
- return readUpstream(state, () => drainer(), cause => bridgeInput.error(cause));
1281
- }
1282
- }
1283
- }));
1284
- result = fromEffect$2(flatMap$3(forkDaemon(interruptible(drainer())), fiber => sync$2(() => this.addFinalizer(exit => flatMap$3(interrupt(fiber), () => suspend$3(() => {
1285
- const effect = this.restorePipe(exit, inputExecutor);
1286
- return effect !== undefined ? effect : _void;
1287
- }))))));
1288
- }
1289
- break;
1290
- }
1291
- case OP_CONCAT_ALL:
1292
- {
1293
- const executor = new ChannelExecutor(this._currentChannel.value(), this._providedEnv, effect => sync$2(() => {
1294
- const prevLastClose = this._closeLastSubstream === undefined ? _void : this._closeLastSubstream;
1295
- this._closeLastSubstream = pipe(prevLastClose, zipRight$3(effect));
1296
- }));
1297
- executor._input = this._input;
1298
- const channel = this._currentChannel;
1299
- this._activeSubexecutor = new PullFromUpstream(executor, value => channel.k(value), undefined, [], (x, y) => channel.combineInners(x, y), (x, y) => channel.combineAll(x, y), request => channel.onPull(request), value => channel.onEmit(value));
1300
- this._closeLastSubstream = undefined;
1301
- this._currentChannel = undefined;
1302
- break;
1303
- }
1304
- case OP_EMIT$2:
1305
- {
1306
- this._emitted = this._currentChannel.out;
1307
- this._currentChannel = this._activeSubexecutor !== undefined ? undefined : void_;
1308
- result = Emit$1();
1309
- break;
1310
- }
1311
- case OP_ENSURING:
1312
- {
1313
- this.runEnsuring(this._currentChannel);
1314
- break;
1315
- }
1316
- case OP_FAIL:
1317
- {
1318
- result = this.doneHalt(this._currentChannel.error());
1319
- break;
1320
- }
1321
- case OP_FOLD:
1322
- {
1323
- this._doneStack.push(this._currentChannel.k);
1324
- this._currentChannel = this._currentChannel.channel;
1325
- break;
1326
- }
1327
- case OP_FROM_EFFECT$1:
1328
- {
1329
- const effect = this._providedEnv === undefined ? this._currentChannel.effect() : pipe(this._currentChannel.effect(), provide(this._providedEnv));
1330
- result = fromEffect$2(matchCauseEffect(effect, {
1331
- onFailure: cause => {
1332
- const state = this.doneHalt(cause);
1333
- return state !== undefined && isFromEffect(state) ? state.effect : _void;
1334
- },
1335
- onSuccess: value => {
1336
- const state = this.doneSucceed(value);
1337
- return state !== undefined && isFromEffect(state) ? state.effect : _void;
1338
- }
1339
- }));
1340
- break;
1341
- }
1342
- case OP_PIPE_TO:
1343
- {
1344
- const previousInput = this._input;
1345
- const leftExec = new ChannelExecutor(this._currentChannel.left(), this._providedEnv, effect => this._executeCloseLastSubstream(effect));
1346
- leftExec._input = previousInput;
1347
- this._input = leftExec;
1348
- this.addFinalizer(exit => {
1349
- const effect = this.restorePipe(exit, previousInput);
1350
- return effect !== undefined ? effect : _void;
1351
- });
1352
- this._currentChannel = this._currentChannel.right();
1353
- break;
1354
- }
1355
- case OP_PROVIDE:
1356
- {
1357
- const previousEnv = this._providedEnv;
1358
- this._providedEnv = this._currentChannel.context();
1359
- this._currentChannel = this._currentChannel.inner;
1360
- this.addFinalizer(() => sync$2(() => {
1361
- this._providedEnv = previousEnv;
1362
- }));
1363
- break;
1364
- }
1365
- case OP_READ$1:
1366
- {
1367
- const read = this._currentChannel;
1368
- result = Read(this._input, identity, emitted => {
1369
- try {
1370
- this._currentChannel = read.more(emitted);
1371
- } catch (error) {
1372
- this._currentChannel = read.done.onExit(die$2(error));
1373
- }
1374
- return undefined;
1375
- }, exit => {
1376
- const onExit = exit => {
1377
- return read.done.onExit(exit);
1378
- };
1379
- this._currentChannel = onExit(exit);
1380
- return undefined;
1381
- });
1382
- break;
1383
- }
1384
- case OP_SUCCEED:
1385
- {
1386
- result = this.doneSucceed(this._currentChannel.evaluate());
1387
- break;
1388
- }
1389
- case OP_SUCCEED_NOW:
1390
- {
1391
- result = this.doneSucceed(this._currentChannel.terminal);
1392
- break;
1393
- }
1394
- case OP_SUSPEND:
1395
- {
1396
- this._currentChannel = this._currentChannel.channel();
1397
- break;
1398
- }
1399
- }
1400
- }
1401
- } catch (error) {
1402
- this._currentChannel = failCause$2(die(error));
1403
- }
1404
- }
1405
- }
1406
- return result;
1407
- }
1408
- getDone() {
1409
- return this._done;
1410
- }
1411
- getEmit() {
1412
- return this._emitted;
1413
- }
1414
- cancelWith(exit) {
1415
- this._cancelled = exit;
1416
- }
1417
- clearInProgressFinalizer() {
1418
- this._inProgressFinalizer = undefined;
1419
- }
1420
- storeInProgressFinalizer(finalizer) {
1421
- this._inProgressFinalizer = finalizer;
1422
- }
1423
- popAllFinalizers(exit) {
1424
- const finalizers = [];
1425
- let next = this._doneStack.pop();
1426
- while (next) {
1427
- if (next._tag === "ContinuationFinalizer") {
1428
- finalizers.push(next.finalizer);
1429
- }
1430
- next = this._doneStack.pop();
1431
- }
1432
- const effect = finalizers.length === 0 ? _void : runFinalizers(finalizers, exit);
1433
- this.storeInProgressFinalizer(effect);
1434
- return effect;
1435
- }
1436
- popNextFinalizers() {
1437
- const builder = [];
1438
- while (this._doneStack.length !== 0) {
1439
- const cont = this._doneStack[this._doneStack.length - 1];
1440
- if (cont._tag === OP_CONTINUATION_K) {
1441
- return builder;
1442
- }
1443
- builder.push(cont);
1444
- this._doneStack.pop();
1445
- }
1446
- return builder;
1447
- }
1448
- restorePipe(exit, prev) {
1449
- const currInput = this._input;
1450
- this._input = prev;
1451
- if (currInput !== undefined) {
1452
- const effect = currInput.close(exit);
1453
- return effect;
1454
- }
1455
- return _void;
1456
- }
1457
- close(exit$1) {
1458
- let runInProgressFinalizers = undefined;
1459
- const finalizer = this._inProgressFinalizer;
1460
- if (finalizer !== undefined) {
1461
- runInProgressFinalizers = pipe(finalizer, ensuring$2(sync$2(() => this.clearInProgressFinalizer())));
1462
- }
1463
- let closeSelf = undefined;
1464
- const selfFinalizers = this.popAllFinalizers(exit$1);
1465
- if (selfFinalizers !== undefined) {
1466
- closeSelf = pipe(selfFinalizers, ensuring$2(sync$2(() => this.clearInProgressFinalizer())));
1467
- }
1468
- const closeSubexecutors = this._activeSubexecutor === undefined ? undefined : this._activeSubexecutor.close(exit$1);
1469
- if (closeSubexecutors === undefined && runInProgressFinalizers === undefined && closeSelf === undefined) {
1470
- return undefined;
1471
- }
1472
- return pipe(exit(ifNotNull(closeSubexecutors)), zip$1(exit(ifNotNull(runInProgressFinalizers))), zip$1(exit(ifNotNull(closeSelf))), map$5(([[exit1, exit2], exit3]) => pipe(exit1, zipRight$2(exit2), zipRight$2(exit3))), uninterruptible$1,
1473
- // TODO: remove
1474
- flatMap$3(exit => suspend$3(() => exit)));
1475
- }
1476
- doneSucceed(value) {
1477
- if (this._doneStack.length === 0) {
1478
- this._done = succeed$2(value);
1479
- this._currentChannel = undefined;
1480
- return Done();
1481
- }
1482
- const head = this._doneStack[this._doneStack.length - 1];
1483
- if (head._tag === OP_CONTINUATION_K) {
1484
- this._doneStack.pop();
1485
- this._currentChannel = head.onSuccess(value);
1486
- return undefined;
1487
- }
1488
- const finalizers = this.popNextFinalizers();
1489
- if (this._doneStack.length === 0) {
1490
- this._doneStack = finalizers.reverse();
1491
- this._done = succeed$2(value);
1492
- this._currentChannel = undefined;
1493
- return Done();
1494
- }
1495
- const finalizerEffect = runFinalizers(finalizers.map(f => f.finalizer), succeed$2(value));
1496
- this.storeInProgressFinalizer(finalizerEffect);
1497
- const effect = pipe(finalizerEffect, ensuring$2(sync$2(() => this.clearInProgressFinalizer())), uninterruptible$1, flatMap$3(() => sync$2(() => this.doneSucceed(value))));
1498
- return fromEffect$2(effect);
1499
- }
1500
- doneHalt(cause) {
1501
- if (this._doneStack.length === 0) {
1502
- this._done = failCause$3(cause);
1503
- this._currentChannel = undefined;
1504
- return Done();
1505
- }
1506
- const head = this._doneStack[this._doneStack.length - 1];
1507
- if (head._tag === OP_CONTINUATION_K) {
1508
- this._doneStack.pop();
1509
- try {
1510
- this._currentChannel = head.onHalt(cause);
1511
- } catch (error) {
1512
- this._currentChannel = failCause$2(die(error));
1513
- }
1514
- return undefined;
1515
- }
1516
- const finalizers = this.popNextFinalizers();
1517
- if (this._doneStack.length === 0) {
1518
- this._doneStack = finalizers.reverse();
1519
- this._done = failCause$3(cause);
1520
- this._currentChannel = undefined;
1521
- return Done();
1522
- }
1523
- const finalizerEffect = runFinalizers(finalizers.map(f => f.finalizer), failCause$3(cause));
1524
- this.storeInProgressFinalizer(finalizerEffect);
1525
- const effect = pipe(finalizerEffect, ensuring$2(sync$2(() => this.clearInProgressFinalizer())), uninterruptible$1, flatMap$3(() => sync$2(() => this.doneHalt(cause))));
1526
- return fromEffect$2(effect);
1527
- }
1528
- processCancellation() {
1529
- this._currentChannel = undefined;
1530
- this._done = this._cancelled;
1531
- this._cancelled = undefined;
1532
- return Done();
1533
- }
1534
- runBracketOut(bracketOut) {
1535
- const effect = uninterruptible$1(matchCauseEffect(this.provide(bracketOut.acquire()), {
1536
- onFailure: cause => sync$2(() => {
1537
- this._currentChannel = failCause$2(cause);
1538
- }),
1539
- onSuccess: out => sync$2(() => {
1540
- this.addFinalizer(exit => this.provide(bracketOut.finalizer(out, exit)));
1541
- this._currentChannel = write(out);
1542
- })
1543
- }));
1544
- return fromEffect$2(effect);
1545
- }
1546
- provide(effect) {
1547
- if (this._providedEnv === undefined) {
1548
- return effect;
1549
- }
1550
- return pipe(effect, provide(this._providedEnv));
1551
- }
1552
- runEnsuring(ensuring) {
1553
- this.addFinalizer(ensuring.finalizer);
1554
- this._currentChannel = ensuring.channel;
1555
- }
1556
- addFinalizer(f) {
1557
- this._doneStack.push(new ContinuationFinalizerImpl(f));
1558
- }
1559
- runSubexecutor() {
1560
- const subexecutor = this._activeSubexecutor;
1561
- switch (subexecutor._tag) {
1562
- case OP_PULL_FROM_CHILD:
1563
- {
1564
- return this.pullFromChild(subexecutor.childExecutor, subexecutor.parentSubexecutor, subexecutor.onEmit, subexecutor);
1565
- }
1566
- case OP_PULL_FROM_UPSTREAM:
1567
- {
1568
- return this.pullFromUpstream(subexecutor);
1569
- }
1570
- case OP_DRAIN_CHILD_EXECUTORS:
1571
- {
1572
- return this.drainChildExecutors(subexecutor);
1573
- }
1574
- case OP_EMIT:
1575
- {
1576
- this._emitted = subexecutor.value;
1577
- this._activeSubexecutor = subexecutor.next;
1578
- return Emit$1();
1579
- }
1580
- }
1581
- }
1582
- replaceSubexecutor(nextSubExec) {
1583
- this._currentChannel = undefined;
1584
- this._activeSubexecutor = nextSubExec;
1585
- }
1586
- finishWithExit(exit) {
1587
- const state = match$2(exit, {
1588
- onFailure: cause => this.doneHalt(cause),
1589
- onSuccess: value => this.doneSucceed(value)
1590
- });
1591
- this._activeSubexecutor = undefined;
1592
- return state === undefined ? _void : effect(state);
1593
- }
1594
- finishSubexecutorWithCloseEffect(subexecutorDone, ...closeFuncs) {
1595
- this.addFinalizer(() => pipe(closeFuncs, forEach(closeFunc => pipe(sync$2(() => closeFunc(subexecutorDone)), flatMap$3(closeEffect => closeEffect !== undefined ? closeEffect : _void)), {
1596
- discard: true
1597
- })));
1598
- const state = pipe(subexecutorDone, match$2({
1599
- onFailure: cause => this.doneHalt(cause),
1600
- onSuccess: value => this.doneSucceed(value)
1601
- }));
1602
- this._activeSubexecutor = undefined;
1603
- return state;
1604
- }
1605
- applyUpstreamPullStrategy(upstreamFinished, queue, strategy) {
1606
- switch (strategy._tag) {
1607
- case OP_PULL_AFTER_NEXT:
1608
- {
1609
- const shouldPrepend = !upstreamFinished || queue.some(subexecutor => subexecutor !== undefined);
1610
- return [strategy.emitSeparator, shouldPrepend ? [undefined, ...queue] : queue];
1611
- }
1612
- case OP_PULL_AFTER_ALL_ENQUEUED:
1613
- {
1614
- const shouldEnqueue = !upstreamFinished || queue.some(subexecutor => subexecutor !== undefined);
1615
- return [strategy.emitSeparator, shouldEnqueue ? [...queue, undefined] : queue];
1616
- }
1617
- }
1618
- }
1619
- pullFromChild(childExecutor, parentSubexecutor, onEmitted, subexecutor) {
1620
- return Read(childExecutor, identity, emitted => {
1621
- const childExecutorDecision = onEmitted(emitted);
1622
- switch (childExecutorDecision._tag) {
1623
- case OP_CONTINUE:
1624
- {
1625
- break;
1626
- }
1627
- case OP_CLOSE:
1628
- {
1629
- this.finishWithDoneValue(childExecutor, parentSubexecutor, childExecutorDecision.value);
1630
- break;
1631
- }
1632
- case OP_YIELD:
1633
- {
1634
- const modifiedParent = parentSubexecutor.enqueuePullFromChild(subexecutor);
1635
- this.replaceSubexecutor(modifiedParent);
1636
- break;
1637
- }
1638
- }
1639
- this._activeSubexecutor = new Emit(emitted, this._activeSubexecutor);
1640
- return undefined;
1641
- }, match$2({
1642
- onFailure: cause => {
1643
- const state = this.handleSubexecutorFailure(childExecutor, parentSubexecutor, cause);
1644
- return state === undefined ? undefined : effectOrUndefinedIgnored(state);
1645
- },
1646
- onSuccess: doneValue => {
1647
- this.finishWithDoneValue(childExecutor, parentSubexecutor, doneValue);
1648
- return undefined;
1649
- }
1650
- }));
1651
- }
1652
- finishWithDoneValue(childExecutor, parentSubexecutor, doneValue) {
1653
- const subexecutor = parentSubexecutor;
1654
- switch (subexecutor._tag) {
1655
- case OP_PULL_FROM_UPSTREAM:
1656
- {
1657
- const modifiedParent = new PullFromUpstream(subexecutor.upstreamExecutor, subexecutor.createChild, subexecutor.lastDone !== undefined ? subexecutor.combineChildResults(subexecutor.lastDone, doneValue) : doneValue, subexecutor.activeChildExecutors, subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull, subexecutor.onEmit);
1658
- this._closeLastSubstream = childExecutor.close(succeed$2(doneValue));
1659
- this.replaceSubexecutor(modifiedParent);
1660
- break;
1661
- }
1662
- case OP_DRAIN_CHILD_EXECUTORS:
1663
- {
1664
- const modifiedParent = new DrainChildExecutors(subexecutor.upstreamExecutor, subexecutor.lastDone !== undefined ? subexecutor.combineChildResults(subexecutor.lastDone, doneValue) : doneValue, subexecutor.activeChildExecutors, subexecutor.upstreamDone, subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull);
1665
- this._closeLastSubstream = childExecutor.close(succeed$2(doneValue));
1666
- this.replaceSubexecutor(modifiedParent);
1667
- break;
1668
- }
1669
- }
1670
- }
1671
- handleSubexecutorFailure(childExecutor, parentSubexecutor, cause) {
1672
- return this.finishSubexecutorWithCloseEffect(failCause$3(cause), exit => parentSubexecutor.close(exit), exit => childExecutor.close(exit));
1673
- }
1674
- pullFromUpstream(subexecutor) {
1675
- if (subexecutor.activeChildExecutors.length === 0) {
1676
- return this.performPullFromUpstream(subexecutor);
1677
- }
1678
- const activeChild = subexecutor.activeChildExecutors[0];
1679
- const parentSubexecutor = new PullFromUpstream(subexecutor.upstreamExecutor, subexecutor.createChild, subexecutor.lastDone, subexecutor.activeChildExecutors.slice(1), subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull, subexecutor.onEmit);
1680
- if (activeChild === undefined) {
1681
- return this.performPullFromUpstream(parentSubexecutor);
1682
- }
1683
- this.replaceSubexecutor(new PullFromChild(activeChild.childExecutor, parentSubexecutor, activeChild.onEmit));
1684
- return undefined;
1685
- }
1686
- performPullFromUpstream(subexecutor) {
1687
- return Read(subexecutor.upstreamExecutor, effect => {
1688
- const closeLastSubstream = this._closeLastSubstream === undefined ? _void : this._closeLastSubstream;
1689
- this._closeLastSubstream = undefined;
1690
- return pipe(this._executeCloseLastSubstream(closeLastSubstream), zipRight$3(effect));
1691
- }, emitted => {
1692
- if (this._closeLastSubstream !== undefined) {
1693
- const closeLastSubstream = this._closeLastSubstream;
1694
- this._closeLastSubstream = undefined;
1695
- return pipe(this._executeCloseLastSubstream(closeLastSubstream), map$5(() => {
1696
- const childExecutor = new ChannelExecutor(subexecutor.createChild(emitted), this._providedEnv, this._executeCloseLastSubstream);
1697
- childExecutor._input = this._input;
1698
- const [emitSeparator, updatedChildExecutors] = this.applyUpstreamPullStrategy(false, subexecutor.activeChildExecutors, subexecutor.onPull(Pulled(emitted)));
1699
- this._activeSubexecutor = new PullFromChild(childExecutor, new PullFromUpstream(subexecutor.upstreamExecutor, subexecutor.createChild, subexecutor.lastDone, updatedChildExecutors, subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull, subexecutor.onEmit), subexecutor.onEmit);
1700
- if (isSome(emitSeparator)) {
1701
- this._activeSubexecutor = new Emit(emitSeparator.value, this._activeSubexecutor);
1702
- }
1703
- return undefined;
1704
- }));
1705
- }
1706
- const childExecutor = new ChannelExecutor(subexecutor.createChild(emitted), this._providedEnv, this._executeCloseLastSubstream);
1707
- childExecutor._input = this._input;
1708
- const [emitSeparator, updatedChildExecutors] = this.applyUpstreamPullStrategy(false, subexecutor.activeChildExecutors, subexecutor.onPull(Pulled(emitted)));
1709
- this._activeSubexecutor = new PullFromChild(childExecutor, new PullFromUpstream(subexecutor.upstreamExecutor, subexecutor.createChild, subexecutor.lastDone, updatedChildExecutors, subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull, subexecutor.onEmit), subexecutor.onEmit);
1710
- if (isSome(emitSeparator)) {
1711
- this._activeSubexecutor = new Emit(emitSeparator.value, this._activeSubexecutor);
1712
- }
1713
- return undefined;
1714
- }, exit => {
1715
- if (subexecutor.activeChildExecutors.some(subexecutor => subexecutor !== undefined)) {
1716
- const drain = new DrainChildExecutors(subexecutor.upstreamExecutor, subexecutor.lastDone, [undefined, ...subexecutor.activeChildExecutors], subexecutor.upstreamExecutor.getDone(), subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull);
1717
- if (this._closeLastSubstream !== undefined) {
1718
- const closeLastSubstream = this._closeLastSubstream;
1719
- this._closeLastSubstream = undefined;
1720
- return pipe(this._executeCloseLastSubstream(closeLastSubstream), map$5(() => this.replaceSubexecutor(drain)));
1721
- }
1722
- this.replaceSubexecutor(drain);
1723
- return undefined;
1724
- }
1725
- const closeLastSubstream = this._closeLastSubstream;
1726
- const state = this.finishSubexecutorWithCloseEffect(pipe(exit, map$6(a => subexecutor.combineWithChildResult(subexecutor.lastDone, a))), () => closeLastSubstream, exit => subexecutor.upstreamExecutor.close(exit));
1727
- return state === undefined ? undefined :
1728
- // NOTE: assuming finalizers cannot fail
1729
- effectOrUndefinedIgnored(state);
1730
- });
1731
- }
1732
- drainChildExecutors(subexecutor) {
1733
- if (subexecutor.activeChildExecutors.length === 0) {
1734
- const lastClose = this._closeLastSubstream;
1735
- if (lastClose !== undefined) {
1736
- this.addFinalizer(() => succeed$3(lastClose));
1737
- }
1738
- return this.finishSubexecutorWithCloseEffect(subexecutor.upstreamDone, () => lastClose, exit => subexecutor.upstreamExecutor.close(exit));
1739
- }
1740
- const activeChild = subexecutor.activeChildExecutors[0];
1741
- const rest = subexecutor.activeChildExecutors.slice(1);
1742
- if (activeChild === undefined) {
1743
- const [emitSeparator, remainingExecutors] = this.applyUpstreamPullStrategy(true, rest, subexecutor.onPull(NoUpstream(rest.reduce((n, curr) => curr !== undefined ? n + 1 : n, 0))));
1744
- this.replaceSubexecutor(new DrainChildExecutors(subexecutor.upstreamExecutor, subexecutor.lastDone, remainingExecutors, subexecutor.upstreamDone, subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull));
1745
- if (isSome(emitSeparator)) {
1746
- this._emitted = emitSeparator.value;
1747
- return Emit$1();
1748
- }
1749
- return undefined;
1750
- }
1751
- const parentSubexecutor = new DrainChildExecutors(subexecutor.upstreamExecutor, subexecutor.lastDone, rest, subexecutor.upstreamDone, subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull);
1752
- this.replaceSubexecutor(new PullFromChild(activeChild.childExecutor, parentSubexecutor, activeChild.onEmit));
1753
- return undefined;
1754
- }
1755
- }
1756
- const ifNotNull = effect => effect !== undefined ? effect : _void;
1757
- const runFinalizers = (finalizers, exit$1) => {
1758
- return pipe(forEach(finalizers, fin => exit(fin(exit$1))), map$5(exits => pipe(all(exits), getOrElse(() => void_$2))), flatMap$3(exit => suspend$3(() => exit)));
1759
- };
1760
- /**
1761
- * @internal
1762
- */
1763
- const readUpstream = (r, onSuccess, onFailure) => {
1764
- const readStack = [r];
1765
- const read = () => {
1766
- const current = readStack.pop();
1767
- if (current === undefined || current.upstream === undefined) {
1768
- return dieMessage("Unexpected end of input for channel execution");
1769
- }
1770
- const state = current.upstream.run();
1771
- switch (state._tag) {
1772
- case OP_EMIT$1:
1773
- {
1774
- const emitEffect = current.onEmit(current.upstream.getEmit());
1775
- if (readStack.length === 0) {
1776
- if (emitEffect === undefined) {
1777
- return suspend$3(onSuccess);
1778
- }
1779
- return pipe(emitEffect, matchCauseEffect({
1780
- onFailure,
1781
- onSuccess
1782
- }));
1783
- }
1784
- if (emitEffect === undefined) {
1785
- return suspend$3(() => read());
1786
- }
1787
- return pipe(emitEffect, matchCauseEffect({
1788
- onFailure,
1789
- onSuccess: () => read()
1790
- }));
1791
- }
1792
- case OP_DONE$1:
1793
- {
1794
- const doneEffect = current.onDone(current.upstream.getDone());
1795
- if (readStack.length === 0) {
1796
- if (doneEffect === undefined) {
1797
- return suspend$3(onSuccess);
1798
- }
1799
- return pipe(doneEffect, matchCauseEffect({
1800
- onFailure,
1801
- onSuccess
1802
- }));
1803
- }
1804
- if (doneEffect === undefined) {
1805
- return suspend$3(() => read());
1806
- }
1807
- return pipe(doneEffect, matchCauseEffect({
1808
- onFailure,
1809
- onSuccess: () => read()
1810
- }));
1811
- }
1812
- case OP_FROM_EFFECT:
1813
- {
1814
- readStack.push(current);
1815
- return pipe(current.onEffect(state.effect), catchAllCause(cause => suspend$3(() => {
1816
- const doneEffect = current.onDone(failCause$3(cause));
1817
- return doneEffect === undefined ? _void : doneEffect;
1818
- })), matchCauseEffect({
1819
- onFailure,
1820
- onSuccess: () => read()
1821
- }));
1822
- }
1823
- case OP_READ:
1824
- {
1825
- readStack.push(current);
1826
- readStack.push(state);
1827
- return suspend$3(() => read());
1828
- }
1829
- }
1830
- };
1831
- return read();
1832
- };
1833
- /** @internal */
1834
- const runIn = /*#__PURE__*/dual(2, (self, scope) => {
1835
- const run = (channelDeferred, scopeDeferred, scope) => acquireUseRelease(sync$2(() => new ChannelExecutor(self, void 0, identity)), exec => suspend$3(() => runScopedInterpret(exec.run(), exec).pipe(intoDeferred(channelDeferred), zipRight$3(_await$2(channelDeferred)), zipLeft(_await$2(scopeDeferred)))), (exec, exit) => {
1836
- const finalize = exec.close(exit);
1837
- if (finalize === undefined) {
1838
- return _void;
1839
- }
1840
- return tapErrorCause(finalize, cause => addFinalizer(scope, failCause$4(cause)));
1841
- });
1842
- return uninterruptibleMask(restore => all$1([fork(scope, sequential), make$6(), make$6()]).pipe(flatMap$3(([child, channelDeferred, scopeDeferred]) => restore(run(channelDeferred, scopeDeferred, child)).pipe(forkIn(scope), flatMap$3(fiber => scope.addFinalizer(exit => {
1843
- const interruptors$1 = isFailure(exit) ? interruptors(exit.cause) : undefined;
1844
- return isDone(channelDeferred).pipe(flatMap$3(isDone => isDone ? succeed$4(scopeDeferred, void 0).pipe(zipRight$3(_await(fiber)), zipRight$3(inheritAll(fiber))) : succeed$4(scopeDeferred, void 0).pipe(zipRight$3(interruptors$1 && size$2(interruptors$1) > 0 ? interruptAs(fiber, combineAll(interruptors$1)) : interrupt(fiber)), zipRight$3(inheritAll(fiber)))));
1845
- }).pipe(zipRight$3(restore(_await$2(channelDeferred)))))))));
1846
- });
1847
- /** @internal */
1848
- const runScopedInterpret = (channelState, exec) => {
1849
- const op = channelState;
1850
- switch (op._tag) {
1851
- case OP_FROM_EFFECT:
1852
- {
1853
- return pipe(op.effect, flatMap$3(() => runScopedInterpret(exec.run(), exec)));
1854
- }
1855
- case OP_EMIT$1:
1856
- {
1857
- // Can't really happen because Out <:< Nothing. So just skip ahead.
1858
- return runScopedInterpret(exec.run(), exec);
1859
- }
1860
- case OP_DONE$1:
1861
- {
1862
- return suspend$3(() => exec.getDone());
1863
- }
1864
- case OP_READ:
1865
- {
1866
- return readUpstream(op, () => runScopedInterpret(exec.run(), exec), failCause$4);
1867
- }
1868
- }
1869
- };
1870
-
1871
- /** @internal */
1872
- const OP_DONE = "Done";
1873
- /** @internal */
1874
- const OP_AWAIT = "Await";
1875
-
1876
- /** @internal */
1877
- const MergeDecisionSymbolKey = "effect/ChannelMergeDecision";
1878
- /** @internal */
1879
- const MergeDecisionTypeId = /*#__PURE__*/Symbol.for(MergeDecisionSymbolKey);
1880
- /** @internal */
1881
- const proto$2 = {
1882
- [MergeDecisionTypeId]: {
1883
- _R: _ => _,
1884
- _E0: _ => _,
1885
- _Z0: _ => _,
1886
- _E: _ => _,
1887
- _Z: _ => _
1888
- }
1889
- };
1890
- /** @internal */
1891
- const Await = f => {
1892
- const op = Object.create(proto$2);
1893
- op._tag = OP_AWAIT;
1894
- op.f = f;
1895
- return op;
1896
- };
1897
-
1898
- /** @internal */
1899
- const OP_BOTH_RUNNING = "BothRunning";
1900
- /** @internal */
1901
- const OP_LEFT_DONE = "LeftDone";
1902
- /** @internal */
1903
- const OP_RIGHT_DONE = "RightDone";
1904
-
1905
- /** @internal */
1906
- const MergeStateSymbolKey = "effect/ChannelMergeState";
1907
- /** @internal */
1908
- const MergeStateTypeId = /*#__PURE__*/Symbol.for(MergeStateSymbolKey);
1909
- /** @internal */
1910
- const proto$1 = {
1911
- [MergeStateTypeId]: MergeStateTypeId
1912
- };
1913
- /** @internal */
1914
- const BothRunning = (left, right) => {
1915
- const op = Object.create(proto$1);
1916
- op._tag = OP_BOTH_RUNNING;
1917
- op.left = left;
1918
- op.right = right;
1919
- return op;
1920
- };
1921
- /** @internal */
1922
- const LeftDone = f => {
1923
- const op = Object.create(proto$1);
1924
- op._tag = OP_LEFT_DONE;
1925
- op.f = f;
1926
- return op;
1927
- };
1928
- /** @internal */
1929
- const RightDone = f => {
1930
- const op = Object.create(proto$1);
1931
- op._tag = OP_RIGHT_DONE;
1932
- op.f = f;
1933
- return op;
1934
- };
1935
-
1936
- /** @internal */
1937
- const OP_BACK_PRESSURE = "BackPressure";
1938
- /** @internal */
1939
- const OP_BUFFER_SLIDING = "BufferSliding";
1940
-
1941
- /** @internal */
1942
- const MergeStrategySymbolKey = "effect/ChannelMergeStrategy";
1943
- /** @internal */
1944
- const MergeStrategyTypeId = /*#__PURE__*/Symbol.for(MergeStrategySymbolKey);
1945
- /** @internal */
1946
- const proto = {
1947
- [MergeStrategyTypeId]: MergeStrategyTypeId
1948
- };
1949
- /** @internal */
1950
- const BackPressure = _ => {
1951
- const op = Object.create(proto);
1952
- op._tag = OP_BACK_PRESSURE;
1953
- return op;
1954
- };
1955
- /** @internal */
1956
- const BufferSliding = _ => {
1957
- const op = Object.create(proto);
1958
- op._tag = OP_BUFFER_SLIDING;
1959
- return op;
1960
- };
1961
- /** @internal */
1962
- const match = /*#__PURE__*/dual(2, (self, {
1963
- onBackPressure,
1964
- onBufferSliding
1965
- }) => {
1966
- switch (self._tag) {
1967
- case OP_BACK_PRESSURE:
1968
- {
1969
- return onBackPressure();
1970
- }
1971
- case OP_BUFFER_SLIDING:
1972
- {
1973
- return onBufferSliding();
1974
- }
1975
- }
1976
- });
1977
-
1978
- /** @internal */
1979
- const OP_STATE_EMPTY = "Empty";
1980
- /** @internal */
1981
- const OP_STATE_EMIT = "Emit";
1982
- /** @internal */
1983
- const OP_STATE_ERROR = "Error";
1984
- /** @internal */
1985
- const OP_STATE_DONE = "Done";
1986
- /** @internal */
1987
- const stateEmpty = notifyProducer => ({
1988
- _tag: OP_STATE_EMPTY,
1989
- notifyProducer
1990
- });
1991
- /** @internal */
1992
- const stateEmit = notifyConsumers => ({
1993
- _tag: OP_STATE_EMIT,
1994
- notifyConsumers
1995
- });
1996
- /** @internal */
1997
- const stateError = cause => ({
1998
- _tag: OP_STATE_ERROR,
1999
- cause
2000
- });
2001
- /** @internal */
2002
- const stateDone = done => ({
2003
- _tag: OP_STATE_DONE,
2004
- done
2005
- });
2006
- /** @internal */
2007
- class SingleProducerAsyncInputImpl {
2008
- ref;
2009
- constructor(ref) {
2010
- this.ref = ref;
2011
- }
2012
- awaitRead() {
2013
- return flatten$2(modify(this.ref, state => state._tag === OP_STATE_EMPTY ? [_await$2(state.notifyProducer), state] : [_void, state]));
2014
- }
2015
- get close() {
2016
- return fiberIdWith(fiberId => this.error(interrupt$1(fiberId)));
2017
- }
2018
- done(value) {
2019
- return flatten$2(modify(this.ref, state => {
2020
- switch (state._tag) {
2021
- case OP_STATE_EMPTY:
2022
- {
2023
- return [_await$2(state.notifyProducer), state];
2024
- }
2025
- case OP_STATE_EMIT:
2026
- {
2027
- return [forEach(state.notifyConsumers, deferred => succeed$4(deferred, left(value)), {
2028
- discard: true
2029
- }), stateDone(value)];
2030
- }
2031
- case OP_STATE_ERROR:
2032
- {
2033
- return [interrupt$4, state];
2034
- }
2035
- case OP_STATE_DONE:
2036
- {
2037
- return [interrupt$4, state];
2038
- }
2039
- }
2040
- }));
2041
- }
2042
- emit(element) {
2043
- return flatMap$3(make$6(), deferred => flatten$2(modify(this.ref, state => {
2044
- switch (state._tag) {
2045
- case OP_STATE_EMPTY:
2046
- {
2047
- return [_await$2(state.notifyProducer), state];
2048
- }
2049
- case OP_STATE_EMIT:
2050
- {
2051
- const notifyConsumer = state.notifyConsumers[0];
2052
- const notifyConsumers = state.notifyConsumers.slice(1);
2053
- if (notifyConsumer !== undefined) {
2054
- return [succeed$4(notifyConsumer, right(element)), notifyConsumers.length === 0 ? stateEmpty(deferred) : stateEmit(notifyConsumers)];
2055
- }
2056
- throw new Error("Bug: Channel.SingleProducerAsyncInput.emit - Queue was empty! please report an issue at https://github.com/Effect-TS/effect/issues");
2057
- }
2058
- case OP_STATE_ERROR:
2059
- {
2060
- return [interrupt$4, state];
2061
- }
2062
- case OP_STATE_DONE:
2063
- {
2064
- return [interrupt$4, state];
2065
- }
2066
- }
2067
- })));
2068
- }
2069
- error(cause) {
2070
- return flatten$2(modify(this.ref, state => {
2071
- switch (state._tag) {
2072
- case OP_STATE_EMPTY:
2073
- {
2074
- return [_await$2(state.notifyProducer), state];
2075
- }
2076
- case OP_STATE_EMIT:
2077
- {
2078
- return [forEach(state.notifyConsumers, deferred => failCause$5(deferred, cause), {
2079
- discard: true
2080
- }), stateError(cause)];
2081
- }
2082
- case OP_STATE_ERROR:
2083
- {
2084
- return [interrupt$4, state];
2085
- }
2086
- case OP_STATE_DONE:
2087
- {
2088
- return [interrupt$4, state];
2089
- }
2090
- }
2091
- }));
2092
- }
2093
- get take() {
2094
- return this.takeWith(cause => failCause$3(map$2(cause, left)), elem => succeed$2(elem), done => fail$3(right(done)));
2095
- }
2096
- takeWith(onError, onElement, onDone) {
2097
- return flatMap$3(make$6(), deferred => flatten$2(modify(this.ref, state => {
2098
- switch (state._tag) {
2099
- case OP_STATE_EMPTY:
2100
- {
2101
- return [zipRight$3(succeed$4(state.notifyProducer, void 0), matchCause(_await$2(deferred), {
2102
- onFailure: onError,
2103
- onSuccess: match$1({
2104
- onLeft: onDone,
2105
- onRight: onElement
2106
- })
2107
- })), stateEmit([deferred])];
2108
- }
2109
- case OP_STATE_EMIT:
2110
- {
2111
- return [matchCause(_await$2(deferred), {
2112
- onFailure: onError,
2113
- onSuccess: match$1({
2114
- onLeft: onDone,
2115
- onRight: onElement
2116
- })
2117
- }), stateEmit([...state.notifyConsumers, deferred])];
2118
- }
2119
- case OP_STATE_ERROR:
2120
- {
2121
- return [succeed$3(onError(state.cause)), state];
2122
- }
2123
- case OP_STATE_DONE:
2124
- {
2125
- return [succeed$3(onDone(state.done)), state];
2126
- }
2127
- }
2128
- })));
2129
- }
2130
- }
2131
- /** @internal */
2132
- const make$1 = () => pipe(make$6(), flatMap$3(deferred => make$3(stateEmpty(deferred))), map$5(ref => new SingleProducerAsyncInputImpl(ref)));
2133
-
2134
- /** @internal */
2135
- const concatMap = /*#__PURE__*/dual(2, (self, f) => concatMapWith(self, f, () => void 0, () => void 0));
2136
- /** @internal */
2137
- const drain$1 = self => {
2138
- const drainer = readWithCause({
2139
- onInput: () => drainer,
2140
- onFailure: failCause$2,
2141
- onDone: succeed
2142
- });
2143
- return pipeTo(self, drainer);
2144
- };
2145
- /** @internal */
2146
- const ensuring$1 = /*#__PURE__*/dual(2, (self, finalizer) => ensuringWith(self, () => finalizer));
2147
- /** @internal */
2148
- const flatten$1 = self => flatMap$1(self, identity);
2149
- /** @internal */
2150
- const fromInput = input => unwrap(input.takeWith(failCause$2, elem => flatMap$1(write(elem), () => fromInput(input)), succeed));
2151
- /** @internal */
2152
- const identityChannel = () => readWith({
2153
- onInput: input => flatMap$1(write(input), () => identityChannel()),
2154
- onFailure: fail,
2155
- onDone: succeedNow
2156
- });
2157
- /** @internal */
2158
- const map$1 = /*#__PURE__*/dual(2, (self, f) => flatMap$1(self, a => sync(() => f(a))));
2159
- /** @internal */
2160
- const mapOut = /*#__PURE__*/dual(2, (self, f) => {
2161
- const reader = readWith({
2162
- onInput: outElem => flatMap$1(write(f(outElem)), () => reader),
2163
- onFailure: fail,
2164
- onDone: succeedNow
2165
- });
2166
- return pipeTo(self, reader);
2167
- });
2168
- /** @internal */
2169
- const mapOutEffectPar = /*#__PURE__*/dual(3, (self, f, n) => unwrapScopedWith$1(scope => gen(function* () {
2170
- const input = yield* make$1();
2171
- const queueReader = fromInput(input);
2172
- const queue = yield* bounded(n);
2173
- yield* addFinalizer(scope, shutdown(queue));
2174
- const errorSignal = yield* make$6();
2175
- const withPermits = n === Number.POSITIVE_INFINITY ? _ => identity : (yield* makeSemaphore(n)).withPermits;
2176
- const pull = yield* queueReader.pipe(pipeTo(self), toPullIn(scope));
2177
- yield* pull.pipe(matchCauseEffect({
2178
- onFailure: cause => offer(queue, failCause$4(cause)),
2179
- onSuccess: match$1({
2180
- onLeft: outDone => zipRight$3(interruptible(withPermits(n)(_void)), asVoid$1(offer(queue, succeed$3(left(outDone))))),
2181
- onRight: outElem => gen(function* () {
2182
- const deferred = yield* make$6();
2183
- const latch = yield* make$6();
2184
- yield* offer(queue, map$5(_await$2(deferred), right));
2185
- yield* succeed$4(latch, void 0).pipe(zipRight$3(uninterruptibleMask(restore => exit(restore(_await$2(errorSignal))).pipe(raceFirst(exit(restore(f(outElem)))), flatMap$3(identity))).pipe(tapErrorCause(cause => failCause$5(errorSignal, cause)), intoDeferred(deferred))), withPermits(1), forkIn(scope));
2186
- yield* _await$2(latch);
2187
- })
2188
- })
2189
- }), forever, interruptible, forkIn(scope));
2190
- const consumer = unwrap(matchCause(flatten$2(take(queue)), {
2191
- onFailure: failCause$2,
2192
- onSuccess: match$1({
2193
- onLeft: succeedNow,
2194
- onRight: outElem => flatMap$1(write(outElem), () => consumer)
2195
- })
2196
- }));
2197
- return embedInput(consumer, input);
2198
- })));
2199
- /** @internal */
2200
- const mergeAll = options => {
2201
- return channels => mergeAllWith(options)(channels, constVoid);
2202
- };
2203
- /** @internal */
2204
- const mergeAllWith = ({
2205
- bufferSize = 16,
2206
- concurrency,
2207
- mergeStrategy = BackPressure()
2208
- }) => (channels, f) => unwrapScopedWith$1(scope => gen(function* () {
2209
- const concurrencyN = concurrency === "unbounded" ? Number.MAX_SAFE_INTEGER : concurrency;
2210
- const input = yield* make$1();
2211
- const queueReader = fromInput(input);
2212
- const queue = yield* bounded(bufferSize);
2213
- yield* addFinalizer(scope, shutdown(queue));
2214
- const cancelers = yield* unbounded();
2215
- yield* addFinalizer(scope, shutdown(cancelers));
2216
- const lastDone = yield* make$3(none());
2217
- const errorSignal = yield* make$6();
2218
- const withPermits = (yield* makeSemaphore(concurrencyN)).withPermits;
2219
- const pull = yield* toPullIn(pipeTo(queueReader, channels), scope);
2220
- function evaluatePull(pull) {
2221
- return pull.pipe(flatMap$3(match$1({
2222
- onLeft: done => succeed$3(some(done)),
2223
- onRight: outElem => as(offer(queue, succeed$3(right(outElem))), none())
2224
- })), repeat({
2225
- until: _ => isSome(_)
2226
- }), flatMap$3(outDone => update(lastDone, match$3({
2227
- onNone: () => some(outDone.value),
2228
- onSome: lastDone => some(f(lastDone, outDone.value))
2229
- }))), catchAllCause(cause => isInterrupted(cause) ? failCause$4(cause) : offer(queue, failCause$4(cause)).pipe(zipRight$3(succeed$4(errorSignal, void 0)), asVoid$1)));
2230
- }
2231
- yield* pull.pipe(matchCauseEffect({
2232
- onFailure: cause => offer(queue, failCause$4(cause)).pipe(zipRight$3(succeed$3(false))),
2233
- onSuccess: match$1({
2234
- onLeft: outDone => raceWith(interruptible(_await$2(errorSignal)), interruptible(withPermits(concurrencyN)(_void)), {
2235
- onSelfDone: (_, permitAcquisition) => as(interrupt(permitAcquisition), false),
2236
- onOtherDone: (_, failureAwait) => zipRight$3(interrupt(failureAwait), get(lastDone).pipe(flatMap$3(match$3({
2237
- onNone: () => offer(queue, succeed$3(left(outDone))),
2238
- onSome: lastDone => offer(queue, succeed$3(left(f(lastDone, outDone))))
2239
- })), as(false)))
2240
- }),
2241
- onRight: channel => match(mergeStrategy, {
2242
- onBackPressure: () => gen(function* () {
2243
- const latch = yield* make$6();
2244
- const raceEffects = scopedWith$2(scope => toPullIn(pipeTo(queueReader, channel), scope).pipe(flatMap$3(pull => race(exit(evaluatePull(pull)), exit(interruptible(_await$2(errorSignal))))), flatMap$3(identity)));
2245
- yield* succeed$4(latch, void 0).pipe(zipRight$3(raceEffects), withPermits(1), forkIn(scope));
2246
- yield* _await$2(latch);
2247
- const errored = yield* isDone(errorSignal);
2248
- return !errored;
2249
- }),
2250
- onBufferSliding: () => gen(function* () {
2251
- const canceler = yield* make$6();
2252
- const latch = yield* make$6();
2253
- const size$1 = yield* size(cancelers);
2254
- yield* take(cancelers).pipe(flatMap$3(canceler => succeed$4(canceler, void 0)), when(() => size$1 >= concurrencyN));
2255
- yield* offer(cancelers, canceler);
2256
- const raceEffects = scopedWith$2(scope => toPullIn(pipeTo(queueReader, channel), scope).pipe(flatMap$3(pull => exit(evaluatePull(pull)).pipe(race(exit(interruptible(_await$2(errorSignal)))), race(exit(interruptible(_await$2(canceler)))))), flatMap$3(identity)));
2257
- yield* succeed$4(latch, void 0).pipe(zipRight$3(raceEffects), withPermits(1), forkIn(scope));
2258
- yield* _await$2(latch);
2259
- const errored = yield* isDone(errorSignal);
2260
- return !errored;
2261
- })
2262
- })
2263
- })
2264
- }), repeat({
2265
- while: _ => _
2266
- }), forkIn(scope));
2267
- const consumer = pipe(take(queue), flatten$2, matchCause({
2268
- onFailure: failCause$2,
2269
- onSuccess: match$1({
2270
- onLeft: succeedNow,
2271
- onRight: outElem => flatMap$1(write(outElem), () => consumer)
2272
- })
2273
- }), unwrap);
2274
- return embedInput(consumer, input);
2275
- }));
2276
- /** @internal */
2277
- const mergeMap = /*#__PURE__*/dual(3, (self, f, options) => mergeAll(options)(mapOut(self, f)));
2278
- /** @internal */
2279
- const mergeWith = /*#__PURE__*/dual(2, (self, options) => {
2280
- function merge(scope) {
2281
- return gen(function* () {
2282
- const input = yield* make$1();
2283
- const queueReader = fromInput(input);
2284
- const pullL = yield* toPullIn(pipeTo(queueReader, self), scope);
2285
- const pullR = yield* toPullIn(pipeTo(queueReader, options.other), scope);
2286
- function handleSide(exit, fiber, pull) {
2287
- return (done, both, single) => {
2288
- function onDecision(decision) {
2289
- const op = decision;
2290
- if (op._tag === OP_DONE) {
2291
- return succeed$3(fromEffect$3(zipRight$3(interrupt(fiber), op.effect)));
2292
- }
2293
- return map$5(_await(fiber), match$2({
2294
- onFailure: cause => fromEffect$3(op.f(failCause$3(cause))),
2295
- onSuccess: match$1({
2296
- onLeft: done => fromEffect$3(op.f(succeed$2(done))),
2297
- onRight: elem => zipRight(write(elem), go(single(op.f)))
2298
- })
2299
- }));
2300
- }
2301
- return match$2(exit, {
2302
- onFailure: cause => onDecision(done(failCause$3(cause))),
2303
- onSuccess: match$1({
2304
- onLeft: z => onDecision(done(succeed$2(z))),
2305
- onRight: elem => succeed$3(flatMap$1(write(elem), () => flatMap$1(fromEffect$3(forkIn(interruptible(pull), scope)), leftFiber => go(both(leftFiber, fiber)))))
2306
- })
2307
- });
2308
- };
2309
- }
2310
- function go(state) {
2311
- switch (state._tag) {
2312
- case OP_BOTH_RUNNING:
2313
- {
2314
- const leftJoin = interruptible(join(state.left));
2315
- const rightJoin = interruptible(join(state.right));
2316
- return unwrap(raceWith(leftJoin, rightJoin, {
2317
- onSelfDone: (leftExit, rf) => zipRight$3(interrupt(rf), handleSide(leftExit, state.right, pullL)(options.onSelfDone, BothRunning, f => LeftDone(f))),
2318
- onOtherDone: (rightExit, lf) => zipRight$3(interrupt(lf), handleSide(rightExit, state.left, pullR)(options.onOtherDone, (left, right) => BothRunning(right, left), f => RightDone(f)))
2319
- }));
2320
- }
2321
- case OP_LEFT_DONE:
2322
- {
2323
- return unwrap(map$5(exit(pullR), match$2({
2324
- onFailure: cause => fromEffect$3(state.f(failCause$3(cause))),
2325
- onSuccess: match$1({
2326
- onLeft: done => fromEffect$3(state.f(succeed$2(done))),
2327
- onRight: elem => flatMap$1(write(elem), () => go(LeftDone(state.f)))
2328
- })
2329
- })));
2330
- }
2331
- case OP_RIGHT_DONE:
2332
- {
2333
- return unwrap(map$5(exit(pullL), match$2({
2334
- onFailure: cause => fromEffect$3(state.f(failCause$3(cause))),
2335
- onSuccess: match$1({
2336
- onLeft: done => fromEffect$3(state.f(succeed$2(done))),
2337
- onRight: elem => flatMap$1(write(elem), () => go(RightDone(state.f)))
2338
- })
2339
- })));
2340
- }
2341
- }
2342
- }
2343
- return fromEffect$3(withFiberRuntime$1(parent => {
2344
- const inherit = withFiberRuntime$1(state => {
2345
- state.transferChildren(parent.scope());
2346
- return _void;
2347
- });
2348
- const leftFiber = interruptible(pullL).pipe(ensuring$2(inherit), forkIn(scope));
2349
- const rightFiber = interruptible(pullR).pipe(ensuring$2(inherit), forkIn(scope));
2350
- return zipWith(leftFiber, rightFiber, (left, right) => BothRunning(left, right));
2351
- })).pipe(flatMap$1(go), embedInput(input));
2352
- });
2353
- }
2354
- return unwrapScopedWith$1(merge);
2355
- });
2356
- /** @internal */
2357
- const pipeToOrFail = /*#__PURE__*/dual(2, (self, that) => suspend$1(() => {
2358
- let channelException = undefined;
2359
- const reader = readWith({
2360
- onInput: outElem => flatMap$1(write(outElem), () => reader),
2361
- onFailure: outErr => {
2362
- channelException = ChannelException(outErr);
2363
- return failCause$2(die(channelException));
2364
- },
2365
- onDone: succeedNow
2366
- });
2367
- const writer = readWithCause({
2368
- onInput: outElem => pipe(write(outElem), flatMap$1(() => writer)),
2369
- onFailure: cause => isDieType(cause) && isChannelException(cause.defect) && equals(cause.defect, channelException) ? fail(cause.defect.error) : failCause$2(cause),
2370
- onDone: succeedNow
2371
- });
2372
- return pipeTo(pipeTo(pipeTo(self, reader), that), writer);
2373
- }));
2374
- /** @internal */
2375
- const run$1 = self => scopedWith$2(scope => runIn(self, scope));
2376
- /** @internal */
2377
- const runDrain$2 = self => run$1(drain$1(self));
2378
- /** @internal */
2379
- const scoped = effect => unwrap(uninterruptibleMask(restore => map$5(make$7(), scope => acquireReleaseOut(tapErrorCause(restore(extend(effect, scope)), cause => close(scope, failCause$3(cause))), (_, exit) => close(scope, exit)))));
2380
- /** @internal */
2381
- const scopedWith$1 = f => unwrapScoped(map$5(scope, scope => flatMap$1(fromEffect$3(f(scope)), write)));
2382
- /** @internal */
2383
- const toPullIn = /*#__PURE__*/dual(2, (self, scope) => zip$1(sync$2(() => new ChannelExecutor(self, void 0, identity)), runtime()).pipe(tap(([executor, runtime]) => addFinalizerExit(scope, exit => {
2384
- const finalizer = executor.close(exit);
2385
- return finalizer !== undefined ? provide(finalizer, runtime) : _void;
2386
- })), uninterruptible$1, map$5(([executor]) => suspend$3(() => interpretToPull(executor.run(), executor)))));
2387
- /** @internal */
2388
- const interpretToPull = (channelState, exec) => {
2389
- const state = channelState;
2390
- switch (state._tag) {
2391
- case OP_DONE$1:
2392
- {
2393
- return match$2(exec.getDone(), {
2394
- onFailure: failCause$4,
2395
- onSuccess: done => succeed$3(left(done))
2396
- });
2397
- }
2398
- case OP_EMIT$1:
2399
- {
2400
- return succeed$3(right(exec.getEmit()));
2401
- }
2402
- case OP_FROM_EFFECT:
2403
- {
2404
- return pipe(state.effect, flatMap$3(() => interpretToPull(exec.run(), exec)));
2405
- }
2406
- case OP_READ:
2407
- {
2408
- return readUpstream(state, () => interpretToPull(exec.run(), exec), cause => failCause$4(cause));
2409
- }
2410
- }
2411
- };
2412
- /** @internal */
2413
- const unwrap = channel => flatten$1(fromEffect$3(channel));
2414
- /** @internal */
2415
- const unwrapScoped = self => concatAllWith(scoped(self), (d, _) => d, (d, _) => d);
2416
- /** @internal */
2417
- const unwrapScopedWith$1 = f => concatAllWith(scopedWith$1(f), (d, _) => d, (d, _) => d);
2418
- /** @internal */
2419
- const writeChunk = outs => writeChunkWriter(0, outs.length, outs);
2420
- /** @internal */
2421
- const writeChunkWriter = (idx, len, chunk) => {
2422
- return idx === len ? void_ : pipe(write(pipe(chunk, unsafeGet(idx))), flatMap$1(() => writeChunkWriter(idx + 1, len, chunk)));
2423
- };
2424
- /** @internal */
2425
- const zip = /*#__PURE__*/dual(args => isChannel(args[1]), (self, that, options) => options?.concurrent ? mergeWith(self, {
2426
- other: that,
2427
- onSelfDone: exit1 => Await(exit2 => suspend$3(() => zip$2(exit1, exit2))),
2428
- onOtherDone: exit2 => Await(exit1 => suspend$3(() => zip$2(exit1, exit2)))
2429
- }) : flatMap$1(self, a => map$1(that, b => [a, b])));
2430
- /** @internal */
2431
- const zipRight = /*#__PURE__*/dual(args => isChannel(args[1]), (self, that, options) => options?.concurrent ? map$1(zip(self, that, {
2432
- concurrent: true
2433
- }), tuple => tuple[1]) : flatMap$1(self, () => that));
2434
- /** @internal */
2435
- const ChannelExceptionTypeId = /*#__PURE__*/Symbol.for("effect/Channel/ChannelException");
2436
- /** @internal */
2437
- const ChannelException = error => ({
2438
- _tag: "ChannelException",
2439
- [ChannelExceptionTypeId]: ChannelExceptionTypeId,
2440
- error
2441
- });
2442
- /** @internal */
2443
- const isChannelException = u => hasProperty(u, ChannelExceptionTypeId);
2444
-
2445
- /** @internal */
2446
- const SinkTypeId = /*#__PURE__*/Symbol.for("effect/Sink");
2447
- const sinkVariance = {
2448
- /* c8 ignore next */
2449
- _A: _ => _,
2450
- /* c8 ignore next */
2451
- _In: _ => _,
2452
- /* c8 ignore next */
2453
- _L: _ => _,
2454
- /* c8 ignore next */
2455
- _E: _ => _,
2456
- /* c8 ignore next */
2457
- _R: _ => _
2458
- };
2459
- /** @internal */
2460
- class SinkImpl {
2461
- channel;
2462
- [SinkTypeId] = sinkVariance;
2463
- constructor(channel) {
2464
- this.channel = channel;
2465
- }
2466
- pipe() {
2467
- return pipeArguments(this, arguments);
2468
- }
2469
- }
2470
- /** @internal */
2471
- const drain = /*#__PURE__*/new SinkImpl(/*#__PURE__*/drain$1(/*#__PURE__*/identityChannel()));
2472
- /** @internal */
2473
- const fromEffect$1 = effect => new SinkImpl(fromEffect$3(effect));
2474
- /** @internal */
2475
- const toChannel$1 = self => isEffect(self) ? toChannel$1(fromEffect$1(self)) : self.channel;
2476
-
2477
- /** @internal */
2478
- const TakeSymbolKey = "effect/Take";
2479
- /** @internal */
2480
- const TakeTypeId = /*#__PURE__*/Symbol.for(TakeSymbolKey);
2481
- const takeVariance = {
2482
- /* c8 ignore next */
2483
- _A: _ => _,
2484
- /* c8 ignore next */
2485
- _E: _ => _
2486
- };
2487
- /** @internal */
2488
- class TakeImpl {
2489
- exit;
2490
- [TakeTypeId] = takeVariance;
2491
- constructor(exit) {
2492
- this.exit = exit;
2493
- }
2494
- pipe() {
2495
- return pipeArguments(this, arguments);
2496
- }
2497
- }
2498
- /** @internal */
2499
- const chunk = chunk => new TakeImpl(succeed$2(chunk));
2500
- /** @internal */
2501
- const end$1 = /*#__PURE__*/new TakeImpl(/*#__PURE__*/fail$3(/*#__PURE__*/none()));
2502
- /** @internal */
2503
- const failCause$1 = cause => new TakeImpl(failCause$3(pipe(cause, map$2(some))));
2504
- /** @internal */
2505
- const of = value => new TakeImpl(succeed$2(of$1(value)));
2506
-
2507
- /** @internal */
2508
- const end = () => fail$4(none());
2509
- /** @internal */
2510
- const failCause = cause => mapError(failCause$4(cause), some);
2511
-
2512
- /** @internal */
2513
- const StreamSymbolKey = "effect/Stream";
2514
- /** @internal */
2515
- const StreamTypeId = /*#__PURE__*/Symbol.for(StreamSymbolKey);
2516
- /** @internal */
2517
- const streamVariance = {
2518
- _R: _ => _,
2519
- _E: _ => _,
2520
- _A: _ => _
2521
- };
2522
- /** @internal */
2523
- class StreamImpl {
2524
- channel;
2525
- [StreamTypeId] = streamVariance;
2526
- constructor(channel) {
2527
- this.channel = channel;
2528
- }
2529
- pipe() {
2530
- return pipeArguments(this, arguments);
2531
- }
2532
- }
2533
- /** @internal */
2534
- const isStream = u => hasProperty(u, StreamTypeId) || isEffect(u);
2535
- /** @internal */
2536
- const DefaultChunkSize = 4096;
2537
- /** @internal */
2538
- const ensuring = /*#__PURE__*/dual(2, (self, finalizer) => new StreamImpl(pipe(toChannel(self), ensuring$1(finalizer))));
2539
- /** @internal */
2540
- const flatMap = /*#__PURE__*/dual(args => isStream(args[0]), (self, f, options) => {
2541
- const bufferSize = options?.bufferSize ?? 16;
2542
- if (options?.switch) {
2543
- return matchConcurrency(options?.concurrency, () => flatMapParSwitchBuffer(self, 1, bufferSize, f), n => flatMapParSwitchBuffer(self, n, bufferSize, f));
2544
- }
2545
- return matchConcurrency(options?.concurrency, () => new StreamImpl(concatMap(toChannel(self), as => pipe(as, map$7(a => toChannel(f(a))), reduce(void_, (left, right) => pipe(left, zipRight(right)))))), _ => new StreamImpl(pipe(toChannel(self), concatMap(writeChunk), mergeMap(out => toChannel(f(out)), options))));
2546
- });
2547
- /** @internal */
2548
- const matchConcurrency = (concurrency, sequential, bounded) => {
2549
- switch (concurrency) {
2550
- case undefined:
2551
- return sequential();
2552
- case "unbounded":
2553
- return bounded(Number.MAX_SAFE_INTEGER);
2554
- default:
2555
- return concurrency > 1 ? bounded(concurrency) : sequential();
2556
- }
2557
- };
2558
- const flatMapParSwitchBuffer = /*#__PURE__*/dual(4, (self, n, bufferSize, f) => new StreamImpl(pipe(toChannel(self), concatMap(writeChunk), mergeMap(out => toChannel(f(out)), {
2559
- concurrency: n,
2560
- mergeStrategy: BufferSliding(),
2561
- bufferSize
2562
- }))));
2563
- /** @internal */
2564
- const flatten = /*#__PURE__*/dual(args => isStream(args[0]), (self, options) => flatMap(self, identity, options));
2565
- /** @internal */
2566
- const flattenChunks = self => {
2567
- const flatten = readWithCause({
2568
- onInput: chunks => flatMap$1(writeChunk(chunks), () => flatten),
2569
- onFailure: failCause$2,
2570
- onDone: () => void_
2571
- });
2572
- return new StreamImpl(pipe(toChannel(self), pipeTo(flatten)));
2573
- };
2574
- /** @internal */
2575
- const flattenExitOption = self => {
2576
- const processChunk = (chunk, cont) => {
2577
- const [toEmit, rest] = pipe(chunk, splitWhere(exit => !isSuccess(exit)));
2578
- const next = pipe(head(rest), match$3({
2579
- onNone: () => cont,
2580
- onSome: match$2({
2581
- onFailure: cause => match$3(flipCauseOption(cause), {
2582
- onNone: () => void_,
2583
- onSome: failCause$2
2584
- }),
2585
- onSuccess: () => void_
2586
- })
2587
- }));
2588
- return pipe(write(pipe(toEmit, filterMap(exit => isSuccess(exit) ? some(exit.value) : none()))), flatMap$1(() => next));
2589
- };
2590
- const process = readWithCause({
2591
- onInput: chunk => processChunk(chunk, process),
2592
- onFailure: cause => failCause$2(cause),
2593
- onDone: () => void_
2594
- });
2595
- return new StreamImpl(pipe(toChannel(self), pipeTo(process)));
2596
- };
2597
- /** @internal */
2598
- const flattenTake = self => flattenChunks(flattenExitOption(pipe(self, map(take => take.exit))));
2599
- /** @internal */
2600
- const toChannel = stream => {
2601
- if ("channel" in stream) {
2602
- return stream.channel;
2603
- } else if (isEffect(stream)) {
2604
- return toChannel(fromEffect(stream));
2605
- } else {
2606
- throw new TypeError(`Expected a Stream.`);
2607
- }
2608
- };
2609
- /** @internal */
2610
- const fromEffect = effect => pipe(effect, mapError(some), fromEffectOption);
2611
- /** @internal */
2612
- const fromEffectOption = effect => new StreamImpl(unwrap(match$4(effect, {
2613
- onFailure: match$3({
2614
- onNone: () => void_,
2615
- onSome: fail
2616
- }),
2617
- onSuccess: a => write(of$1(a))
2618
- })));
2619
- /** @internal */
2620
- const fromQueue$1 = (queue, options) => pipe(takeBetween(queue, 1, options?.maxChunkSize ?? DefaultChunkSize), catchAllCause(cause => pipe(isShutdown(queue), flatMap$3(isShutdown => isShutdown && isInterrupted(cause) ? end() : failCause(cause)))), repeatEffectChunkOption, options?.shutdown ? ensuring(shutdown(queue)) : identity);
2621
- /** @internal */
2622
- const map = /*#__PURE__*/dual(2, (self, f) => new StreamImpl(pipe(toChannel(self), mapOut(map$7(f)))));
2623
- /** @internal */
2624
- const mapEffectSequential = /*#__PURE__*/dual(2, (self, f) => {
2625
- const loop = iterator => {
2626
- const next = iterator.next();
2627
- if (next.done) {
2628
- return readWithCause({
2629
- onInput: elem => loop(elem[Symbol.iterator]()),
2630
- onFailure: failCause$2,
2631
- onDone: succeed
2632
- });
2633
- } else {
2634
- const value = next.value;
2635
- return unwrap(map$5(f(value), a2 => flatMap$1(write(of$1(a2)), () => loop(iterator))));
2636
- }
2637
- };
2638
- return new StreamImpl(pipe(toChannel(self), pipeTo(suspend$1(() => loop(empty$1()[Symbol.iterator]())))));
2639
- });
2640
- /** @internal */
2641
- const mapEffectPar = /*#__PURE__*/dual(3, (self, n, f) => new StreamImpl(pipe(toChannel(self), concatMap(writeChunk), mapOutEffectPar(f, n), mapOut(of$1))));
2642
- /** @internal */
2643
- const repeatEffectChunkOption = effect => unfoldChunkEffect(effect, effect => pipe(map$5(effect, chunk => some([chunk, effect])), catchAll$1(match$3({
2644
- onNone: () => succeed$3(none()),
2645
- onSome: fail$4
2646
- }))));
2647
- /** @internal */
2648
- const run = /*#__PURE__*/dual(2, (self, sink) => toChannel(self).pipe(pipeToOrFail(toChannel$1(sink)), runDrain$2));
2649
- /** @internal */
2650
- const runDrain$1 = self => run(self, drain);
2651
- /** @internal */
2652
- const scopedWith = f => new StreamImpl(scopedWith$1(scope => f(scope).pipe(map$5(of$1))));
2653
- /** @internal */
2654
- const suspend = stream => new StreamImpl(suspend$1(() => toChannel(stream())));
2655
- /** @internal */
2656
- const unfoldChunkEffect = (s, f) => suspend(() => {
2657
- const loop = s => unwrap(map$5(f(s), match$3({
2658
- onNone: () => void_,
2659
- onSome: ([chunk, s]) => flatMap$1(write(chunk), () => loop(s))
2660
- })));
2661
- return new StreamImpl(loop(s));
2662
- });
2663
- /** @internal */
2664
- const unwrapScopedWith = f => flatten(scopedWith(scope => f(scope)));
2665
-
2666
- /** @internal */
2667
- const GroupBySymbolKey = "effect/GroupBy";
2668
- /** @internal */
2669
- const GroupByTypeId = /*#__PURE__*/Symbol.for(GroupBySymbolKey);
2670
- const groupByVariance = {
2671
- /* c8 ignore next */
2672
- _R: _ => _,
2673
- /* c8 ignore next */
2674
- _E: _ => _,
2675
- /* c8 ignore next */
2676
- _K: _ => _,
2677
- /* c8 ignore next */
2678
- _V: _ => _
2679
- };
2680
- /** @internal */
2681
- const isGroupBy = u => hasProperty(u, GroupByTypeId);
2682
- /** @internal */
2683
- const evaluate = /*#__PURE__*/dual(args => isGroupBy(args[0]), (self, f, options) => flatMap(self.grouped, ([key, queue]) => f(key, flattenTake(fromQueue$1(queue, {
2684
- shutdown: true
2685
- }))), {
2686
- concurrency: "unbounded",
2687
- bufferSize: options?.bufferSize ?? 16
2688
- }));
2689
- /** @internal */
2690
- const make = grouped => ({
2691
- [GroupByTypeId]: groupByVariance,
2692
- pipe() {
2693
- return pipeArguments(this, arguments);
2694
- },
2695
- grouped
2696
- });
2697
- /** @internal */
2698
- const mapEffectOptions = /*#__PURE__*/dual(args => typeof args[0] !== "function", (self, f, options) => {
2699
- if (options?.key) {
2700
- return evaluate(groupByKey(self, options.key, {
2701
- bufferSize: options.bufferSize
2702
- }), (_, s) => mapEffectSequential(s, f));
2703
- }
2704
- return matchConcurrency(options?.concurrency, () => mapEffectSequential(self, f), n => options?.unordered ? flatMap(self, a => fromEffect(f(a)), {
2705
- concurrency: n
2706
- }) : mapEffectPar(self, n, f));
2707
- });
2708
- /** @internal */
2709
- const groupByKey = /*#__PURE__*/dual(args => typeof args[0] !== "function", (self, f, options) => {
2710
- const loop = (map, outerQueue) => readWithCause({
2711
- onInput: input => flatMap$1(fromEffect$3(forEach(groupByIterable(input, f), ([key, values]) => {
2712
- const innerQueue = map.get(key);
2713
- if (innerQueue === undefined) {
2714
- return pipe(bounded(options?.bufferSize ?? 16), flatMap$3(innerQueue => pipe(sync$2(() => {
2715
- map.set(key, innerQueue);
2716
- }), zipRight$3(offer(outerQueue, of([key, innerQueue]))), zipRight$3(pipe(offer(innerQueue, chunk(values)), catchSomeCause(cause => isInterruptedOnly(cause) ? some(_void) : none()))))));
2717
- }
2718
- return catchSomeCause(offer(innerQueue, chunk(values)), cause => isInterruptedOnly(cause) ? some(_void) : none());
2719
- }, {
2720
- discard: true
2721
- })), () => loop(map, outerQueue)),
2722
- onFailure: cause => fromEffect$3(offer(outerQueue, failCause$1(cause))),
2723
- onDone: () => fromEffect$3(pipe(forEach(map.entries(), ([_, innerQueue]) => pipe(offer(innerQueue, end$1), catchSomeCause(cause => isInterruptedOnly(cause) ? some(_void) : none())), {
2724
- discard: true
2725
- }), zipRight$3(offer(outerQueue, end$1))))
2726
- });
2727
- return make(unwrapScopedWith(scope => gen(function* () {
2728
- const map = new Map();
2729
- const queue = yield* unbounded();
2730
- yield* addFinalizer(scope, shutdown(queue));
2731
- return yield* toChannel(self).pipe(pipeTo(loop(map, queue)), drain$1, runIn(scope), forkIn(scope), as(flattenTake(fromQueue$1(queue, {
2732
- shutdown: true
2733
- }))));
2734
- })));
2735
- });
2736
- /**
2737
- * A variant of `groupBy` that retains the insertion order of keys.
2738
- *
2739
- * @internal
2740
- */
2741
- const groupByIterable = /*#__PURE__*/dual(2, (iterable, f) => {
2742
- const builder = [];
2743
- const iterator = iterable[Symbol.iterator]();
2744
- const map = new Map();
2745
- let next;
2746
- while ((next = iterator.next()) && !next.done) {
2747
- const value = next.value;
2748
- const key = f(value);
2749
- if (map.has(key)) {
2750
- const innerBuilder = map.get(key);
2751
- innerBuilder.push(value);
2752
- } else {
2753
- const innerBuilder = [value];
2754
- builder.push([key, innerBuilder]);
2755
- map.set(key, innerBuilder);
2756
- }
2757
- }
2758
- return unsafeFromArray(builder.map(tuple => [tuple[0], unsafeFromArray(tuple[1])]));
2759
- });
2760
-
2761
- /**
2762
- * Creates a stream from a queue of values
2763
- *
2764
- * **Options**
2765
- *
2766
- * - `maxChunkSize`: The maximum number of queued elements to put in one chunk in the stream
2767
- * - `shutdown`: If `true`, the queue will be shutdown after the stream is evaluated (defaults to `false`)
2768
- *
2769
- * @since 2.0.0
2770
- * @category constructors
2771
- */
2772
- const fromQueue = fromQueue$1;
2773
- /**
2774
- * Maps over elements of the stream with the specified effectful function.
2775
- *
2776
- * @example
2777
- * ```ts
2778
- * import { Effect, Random, Stream } from "effect"
2779
- *
2780
- * const stream = Stream.make(10, 20, 30).pipe(
2781
- * Stream.mapEffect((n) => Random.nextIntBetween(0, n))
2782
- * )
2783
- *
2784
- * Effect.runPromise(Stream.runCollect(stream)).then(console.log)
2785
- * // Example Output: { _id: 'Chunk', values: [ 7, 19, 8 ] }
2786
- * ```
2787
- *
2788
- * @since 2.0.0
2789
- * @category mapping
2790
- */
2791
- const mapEffect = mapEffectOptions;
2792
- /**
2793
- * Runs the stream only for its effects. The emitted elements are discarded.
2794
- *
2795
- * @since 2.0.0
2796
- * @category destructors
2797
- */
2798
- const runDrain = runDrain$1;
2799
-
2800
- const HeaderIntegration = class {
2801
- constructor(hostRef) {
2802
- registerInstance(this, hostRef);
2803
- }
2804
- activeNav;
2805
- activate(event) {
2806
- const target = event.currentTarget;
2807
- const navItem = target.closest('[slot="nav-primary"]');
2808
- if (!navItem)
2809
- return;
2810
- const navId = navItem.id;
2811
- if (!navId) {
2812
- console.warn('Nav item does not have an id:', navItem);
2813
- return;
2814
- }
2815
- console.log('Activating nav item:', navId);
2816
- this.activeNav = navId;
2817
- }
2818
- render() {
2819
- return (h(Host, { key: 'd36cd9202cfdea4bc684f2b17ba625fd37397616' }, h("lmvz-header", { key: '681f8b9fe603d98bad55bbbc7b4dbd43a3d7aff1', lmvzActiveNav: this.activeNav }, h("lmvz-menuitem", { key: '54a1b1d394c69e98e742e2dd53f000de028a8626', slot: "nav-primary", id: "lehrmittel", onLmvzActivation: this.activate.bind(this) }, "Lehrmittel"), h("lmvz-menuitem", { key: '1aa874d07f7e444433c818c97e300d0e1693fa06', slot: "nav-primary", id: "verwaltung", onLmvzActivation: this.activate.bind(this) }, "Verwaltung"), h("lmvz-menuitem", { key: 'd462954ef05c4d70252febfd184b363c4a2a3cde', slot: "connect-nav-lehrmittel" }, h("lmvz-icon", { key: '72e9bb03e05463b876bbf23e2e3e12838b15c76c', icon: "book" }), "Deutsch 7"), h("lmvz-menuitem", { key: '3f065f96ecd9ec59ae9ebd7885173e706f156a94', slot: "connect-nav-lehrmittel" }, h("lmvz-icon", { key: 'cb8039ffb7e590c201e7dc31ba55741c2dbe1181', icon: "book" }), "Mathe 2"), h("lmvz-menuitem", { key: '90eff45f7a773665a71eddceb4841e89fe54e5cb', slot: "connect-nav-verwaltung" }, h("lmvz-icon", { key: '1a9a36baab23233209649e65a5a25d0d1e9b455e', icon: "cog" }), "iwas mit Verwaltung"), h("lmvz-menuitem", { key: '14149a8355373308ff6a531fc6e796b0a67e44a3', slot: "connect-nav-verwaltung", "aria-label": "Einstellungen" }, h("lmvz-icon", { key: '0e713b2f6740e004c8897e986de0756c9392459e', icon: "cog" })), h("lmvz-button", { key: 'ee75293a9e256b5d3edf90a77a817aa1b60aea9e', slot: "actions", "aria-label": "Benutzerkonto" }, h("lmvz-icon", { key: '483e613ab4f5c32be0f942714fe649019b001f3f', icon: "user" }))), h("lmvz-input", { key: '63ec977b40a39ecd9bc37309ee2d917916cf3256', label: "test" })));
2820
- }
2821
- };
2822
- HeaderIntegration.style = `:host {
2823
- display: block;
2824
- min-height: 100vh;
2825
- background: var(--lmvz-color-spec-bg-outer-view);
2826
- }
2827
-
2828
- .active button {
2829
- background-color: var(--lmvz-semantic-color-status-selected);
2830
- }`;
2831
-
2832
- var classnames = {exports: {}};
2833
-
2834
- /*!
2835
- Copyright (c) 2018 Jed Watson.
2836
- Licensed under the MIT License (MIT), see
2837
- http://jedwatson.github.io/classnames
2838
- */
2839
-
2840
- var hasRequiredClassnames;
2841
-
2842
- function requireClassnames () {
2843
- if (hasRequiredClassnames) return classnames.exports;
2844
- hasRequiredClassnames = 1;
2845
- (function (module) {
2846
- /* global define */
2847
-
2848
- (function () {
2849
-
2850
- var hasOwn = {}.hasOwnProperty;
2851
-
2852
- function classNames () {
2853
- var classes = '';
2854
-
2855
- for (var i = 0; i < arguments.length; i++) {
2856
- var arg = arguments[i];
2857
- if (arg) {
2858
- classes = appendClass(classes, parseValue(arg));
2859
- }
2860
- }
2861
-
2862
- return classes;
2863
- }
2864
-
2865
- function parseValue (arg) {
2866
- if (typeof arg === 'string' || typeof arg === 'number') {
2867
- return arg;
2868
- }
2869
-
2870
- if (typeof arg !== 'object') {
2871
- return '';
2872
- }
2873
-
2874
- if (Array.isArray(arg)) {
2875
- return classNames.apply(null, arg);
2876
- }
2877
-
2878
- if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
2879
- return arg.toString();
2880
- }
2881
-
2882
- var classes = '';
2883
-
2884
- for (var key in arg) {
2885
- if (hasOwn.call(arg, key) && arg[key]) {
2886
- classes = appendClass(classes, key);
2887
- }
2888
- }
2889
-
2890
- return classes;
2891
- }
2892
-
2893
- function appendClass (value, newClass) {
2894
- if (!newClass) {
2895
- return value;
2896
- }
2897
-
2898
- if (value) {
2899
- return value + ' ' + newClass;
2900
- }
2901
-
2902
- return value + newClass;
2903
- }
2904
-
2905
- if (module.exports) {
2906
- classNames.default = classNames;
2907
- module.exports = classNames;
2908
- } else {
2909
- window.classNames = classNames;
2910
- }
2911
- }());
2912
- } (classnames));
2913
- return classnames.exports;
2914
- }
2915
-
2916
- var classnamesExports = requireClassnames();
2917
- var classNames = /*@__PURE__*/getDefaultExportFromCjs(classnamesExports);
2918
-
2919
- const componentOnReady = (el, callback) => {
2920
- if (el.componentOnReady) {
2921
- el.componentOnReady().then((resolvedEl) => callback(resolvedEl));
2922
- }
2923
- else {
2924
- raf(() => callback(el));
2925
- }
2926
- };
2927
- const inheritAttributes = (el, attributes = []) => {
2928
- const attributeObject = {};
2929
- attributes.forEach(attr => {
2930
- if (el.hasAttribute(attr)) {
2931
- const value = el.getAttribute(attr);
2932
- if (value !== null) {
2933
- attributeObject[attr] = el.getAttribute(attr);
2934
- }
2935
- el.removeAttribute(attr);
2936
- }
2937
- });
2938
- return attributeObject;
2939
- };
2940
- const ariaAttributes = [
2941
- 'role',
2942
- 'aria-activedescendant',
2943
- 'aria-atomic',
2944
- 'aria-autocomplete',
2945
- 'aria-braillelabel',
2946
- 'aria-brailleroledescription',
2947
- 'aria-busy',
2948
- 'aria-checked',
2949
- 'aria-colcount',
2950
- 'aria-colindex',
2951
- 'aria-colindextext',
2952
- 'aria-colspan',
2953
- 'aria-controls',
2954
- 'aria-current',
2955
- 'aria-describedby',
2956
- 'aria-description',
2957
- 'aria-details',
2958
- 'aria-disabled',
2959
- 'aria-errormessage',
2960
- 'aria-expanded',
2961
- 'aria-flowto',
2962
- 'aria-haspopup',
2963
- 'aria-hidden',
2964
- 'aria-invalid',
2965
- 'aria-keyshortcuts',
2966
- 'aria-label',
2967
- 'aria-labelledby',
2968
- 'aria-level',
2969
- 'aria-live',
2970
- 'aria-multiline',
2971
- 'aria-multiselectable',
2972
- 'aria-orientation',
2973
- 'aria-owns',
2974
- 'aria-placeholder',
2975
- 'aria-posinset',
2976
- 'aria-pressed',
2977
- 'aria-readonly',
2978
- 'aria-relevant',
2979
- 'aria-required',
2980
- 'aria-roledescription',
2981
- 'aria-rowcount',
2982
- 'aria-rowindex',
2983
- 'aria-rowindextext',
2984
- 'aria-rowspan',
2985
- 'aria-selected',
2986
- 'aria-setsize',
2987
- 'aria-sort',
2988
- 'aria-valuemax',
2989
- 'aria-valuemin',
2990
- 'aria-valuenow',
2991
- 'aria-valuetext',
2992
- ];
2993
- const inheritAriaAttributes = (el, ignoreList) => {
2994
- let attributesToInherit = ariaAttributes;
2995
- return inheritAttributes(el, attributesToInherit);
2996
- };
2997
- const raf = (h) => {
2998
- if (typeof __zone_symbol__requestAnimationFrame === 'function') {
2999
- return __zone_symbol__requestAnimationFrame(h);
3000
- }
3001
- if (typeof requestAnimationFrame === 'function') {
3002
- return requestAnimationFrame(h);
3003
- }
3004
- return setTimeout(h);
3005
- };
3006
- function getDeepActiveElement(root = document) {
3007
- let activeElement = root.activeElement;
3008
- if (!activeElement) {
3009
- return null;
3010
- }
3011
- while (activeElement && activeElement.shadowRoot) {
3012
- const next = activeElement.shadowRoot.activeElement;
3013
- if (!next) {
3014
- break;
3015
- }
3016
- activeElement = next;
3017
- }
3018
- return activeElement;
3019
- }
3020
- function canReceiveFocus(el) {
3021
- return (el instanceof HTMLElement && el.tabIndex >= 0 && !el.hasAttribute('disabled') && el.getAttribute('aria-hidden') !== 'true' && el.checkVisibility() && el.offsetParent !== null);
3022
- }
3023
- function findFormByRef(form, el) {
3024
- if (form instanceof HTMLFormElement) {
3025
- return form;
3026
- }
3027
- if (typeof form === 'string') {
3028
- const el = document.getElementById(form);
3029
- if (el) {
3030
- if (el instanceof HTMLFormElement) {
3031
- return el;
3032
- }
3033
- else {
3034
- console.warn(`No Form found with selector: "#${form}". Verify that the element with id exists and is actually a <form> element.`, el);
3035
- return null;
3036
- }
3037
- }
3038
- else {
3039
- console.warn(`No Form found with selector: "#${form}". Verify that the id is correct and the form is rendered in the DOM.`, el);
3040
- return null;
3041
- }
3042
- }
3043
- if (form !== undefined) {
3044
- console.warn(`The provided "form" element is invalid. Verify that the form is a HTMLFormElement and rendered in the DOM.`, el);
3045
- return null;
3046
- }
3047
- return el.closest('form');
3048
- }
3049
-
3050
- class ElementActivationController {
3051
- host;
3052
- config;
3053
- constructor(host, config) {
3054
- this.host = host;
3055
- this.config = config;
3056
- }
3057
- hostDidLoad() {
3058
- if (!this.host.el.hasAttribute('tabindex')) {
3059
- console.warn('Interactive element does not have a tabindex attribute!', this.host.el);
3060
- }
3061
- this.host.el.addEventListener('keydown', this.handleKeyDown.bind(this));
3062
- this.host.el.addEventListener('click', this.handleActivation.bind(this));
3063
- }
3064
- handleKeyDown = (event) => {
3065
- if ((this.config?.keys ?? ['Enter', ' ']).includes(event.key)) {
3066
- event.preventDefault();
3067
- this.handleActivation(event);
3068
- }
3069
- };
3070
- handleActivation = (event) => {
3071
- this.host.lmvzActivation.emit();
3072
- if (this.config?.localHandler) {
3073
- this.config.localHandler(event);
3074
- }
3075
- };
3076
- }
3077
-
3078
- class ReactiveControllerHost {
3079
- controllers = new Set();
3080
- addController(controller) {
3081
- this.controllers.add(controller);
3082
- }
3083
- removeController(controller) {
3084
- this.controllers.delete(controller);
3085
- }
3086
- get activeControllers() {
3087
- return Array.from(this.controllers).filter(controller => !controller.disabled);
3088
- }
3089
- connectedCallback() {
3090
- if (!this.controllers.size) {
3091
- console.warn('ReactiveControllerHost connected with no controllers registered.', this);
3092
- }
3093
- this.activeControllers.forEach(controller => controller.hostConnected?.());
3094
- }
3095
- disconnectedCallback() {
3096
- this.activeControllers.forEach(controller => controller.hostDisconnected?.());
3097
- }
3098
- componentWillLoad() {
3099
- this.activeControllers.forEach(controller => controller.hostWillLoad?.());
3100
- }
3101
- componentDidLoad() {
3102
- this.activeControllers.forEach(controller => controller.hostDidLoad?.());
3103
- }
3104
- componentWillRender() {
3105
- this.activeControllers.forEach(controller => controller.hostWillRender?.());
3106
- }
3107
- componentDidRender() {
3108
- this.activeControllers.forEach(controller => controller.hostDidRender?.());
3109
- }
3110
- componentWillUpdate() {
3111
- this.activeControllers.forEach(controller => controller.hostWillUpdate?.());
3112
- }
3113
- componentDidUpdate() {
3114
- this.activeControllers.forEach(controller => controller.hostDidUpdate?.());
3115
- }
3116
- }
3117
-
3118
- class AriaValidationController {
3119
- host;
3120
- config;
3121
- static get globalValidationEnabled() {
3122
- return Build.isDev;
3123
- }
3124
- static axe = this.globalValidationEnabled ? import('./axe-CZ0Rtkog.js').then(function (n) { return n.a; }) : null;
3125
- static axeQueue = null;
3126
- static axeStreamFiber = null;
3127
- visibilityObserver;
3128
- elementQueued = false;
3129
- elementValidated = false;
3130
- knownValidationErrors = [];
3131
- get disabled() {
3132
- return true;
3133
- }
3134
- constructor(host, config) {
3135
- this.host = host;
3136
- this.config = config;
3137
- AriaValidationController.initializeAxeStream();
3138
- }
3139
- static initializeAxeStream() {
3140
- if (!this.globalValidationEnabled)
3141
- return;
3142
- if (this.axeStreamFiber)
3143
- return;
3144
- const program = gen(function* () {
3145
- const queue = (AriaValidationController.axeQueue = yield* bounded(100));
3146
- const axeLib = yield* promise(() => AriaValidationController.axe);
3147
- if (!axeLib) {
3148
- console.error('Axe library not available, ARIA validation will not run.');
3149
- return;
3150
- }
3151
- const stream = fromQueue(queue).pipe(mapEffect(({ context, onComplete }) => async(resume => {
3152
- axeLib.run(context, {}, (error, results) => {
3153
- onComplete(error, results);
3154
- resume(_void);
3155
- });
3156
- })));
3157
- yield* runDrain(stream);
3158
- });
3159
- this.axeStreamFiber = runFork(program);
3160
- }
3161
- hostDidLoad() {
3162
- if (this.elementQueued || this.elementValidated)
3163
- return;
3164
- if (!this.host.el.checkVisibility()) {
3165
- this.observeVisibilityOnce();
3166
- return;
3167
- }
3168
- this.enqueueValidation();
3169
- }
3170
- hostDidUpdate() {
3171
- this.checkLazyValidation();
3172
- }
3173
- hostDisconnected() {
3174
- this.discardVisibilityObserver();
3175
- }
3176
- observeVisibilityOnce() {
3177
- this.visibilityObserver = new IntersectionObserver(entries => {
3178
- for (const entry of entries) {
3179
- if (entry.target !== this.host.el)
3180
- continue;
3181
- if (!entry.isIntersecting)
3182
- continue;
3183
- this.checkLazyValidation();
3184
- this.discardVisibilityObserver();
3185
- }
3186
- }, {
3187
- root: this.host.el.parentElement,
3188
- rootMargin: '0px',
3189
- threshold: 0.01,
3190
- });
3191
- this.visibilityObserver.observe(this.host.el);
3192
- }
3193
- checkLazyValidation() {
3194
- if (!this.config?.reValidateOnPropChanges && (this.elementQueued || this.elementValidated))
3195
- return;
3196
- this.enqueueValidation();
3197
- }
3198
- enqueueValidation() {
3199
- return;
3200
- }
3201
- discardVisibilityObserver() {
3202
- if (!this.visibilityObserver)
3203
- return;
3204
- this.visibilityObserver.disconnect();
3205
- this.visibilityObserver = undefined;
3206
- }
3207
- }
3208
-
3209
- const lmvzButtonCss = () => ` @layer lmvz-ds.reset, lmvz-ds.theme, lmvz-ds.components, lmvz-ds.overrides; @layer lmvz-ds.theme { @font-face { font-family: Router; src: local('Router-Book'), url('/assets/fonts/Router-Book.woff') format('woff'), local('Router'); font-weight: 400 normal; } @font-face { font-family: Router; src: local('Router-Medium'), url('/assets/fonts/Router-Medium.woff') format('woff'), local('Router'); font-weight: 500; } @font-face { font-family: Router; src: local('Router-Bold'), url('/assets/fonts/Router-Bold.woff') format('woff'), local('Router'); font-weight: 700 bold; } } @layer lmvz-ds.reset { h1, h2, h3, h4, h5, h6 { margin: 0; } } :host { button { --lmvz-button-color: var(--lmvz-component-color, var(--lmvz-semantic-color-int-on-primary, #ffffff)); --lmvz-button-padding-inline: var(--lmvz-button-padding, var(--lmvz-component-input-md-padding-x, clamp(0.75rem, 0.69rem + 0.26vw, 1rem))); --lmvz-button-padding-block: var(--lmvz-button-padding, var(--lmvz-component-input-md-padding-y, clamp(0.75rem, 0.69rem + 0.26vw, 1rem))); --lmvz-button-gap: var(--lmvz-component-input-md-gap-x, clamp(0.25rem, 0.16rem + 0.39vw, 0.63rem)); --lmvz-button-font: var(--lmvz-typography-body-lg, 400 clamp(1rem, 0.97rem + 0.13vw, 1.13rem) / 1.4 Router); --lmvz-button-radius: var(--lmvz-component-input-radius-default, 999px); --lmvz-button-border-width: 0; --lmvz-button-border-color: transparent; --lmvz-button-background: var(--lmvz-semantic-color-int-primary, #000000); display: inline-flex; align-items: center; justify-content: center; gap: var(--lmvz-button-gap); padding-block: var(--lmvz-button-padding-block); padding-inline: var(--lmvz-button-padding-inline); border-radius: var(--lmvz-button-radius); border: var(--lmvz-button-border-width) solid var(--lmvz-button-border-color); background-color: var(--lmvz-button-background); color: var(--lmvz-button-color); cursor: pointer; font: var(--lmvz-button-font); text-align: center; text-decoration: none; white-space: nowrap; transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease; } button > * { font: inherit; color: inherit; } button:focus-visible { outline: var(--lmvz-semantic-border-width-default, 1px) solid var(--lmvz-semantic-color-status-selected, #f1f9fe); outline-offset: var(--lmvz-component-input-sm-padding-x, clamp(0.5rem, 0.44rem + 0.26vw, 0.75rem)); } button:is([disabled], .disabled) { cursor: not-allowed; pointer-events: none; opacity: var(--lmvz-component-input-disabled-opacity, 40%); } button:not([disabled]):hover { --lmvz-button-background: var(--lmvz-semantic-color-int-primary-hover, #2e2e2e); } button:not([disabled]):active { --lmvz-button-background: var(--lmvz-semantic-color-int-primary-active, #545454); } button.secondary { --lmvz-button-background: var(--lmvz-semantic-color-int-secondary, #f0f0f0); --lmvz-button-color: var(--lmvz-semantic-color-int-on-secondary, #000000); --lmvz-button-border-width: var(--lmvz-semantic-border-width-default, 1px); --lmvz-button-border-color: var(--lmvz-semantic-color-border-default, #e0e0e0); } button.secondary:not([disabled], .disabled):hover { --lmvz-button-background: var(--lmvz-semantic-color-int-secondary-hover, #e0e0e0); --lmvz-button-border-color: var(--lmvz-semantic-color-border-hover, #c7c7c7); } button.secondary:not([disabled], .disabled):active { --lmvz-button-background: var(--lmvz-semantic-color-int-secondary-active, #d4d4d4); --lmvz-button-border-color: var(--lmvz-semantic-color-border-active, #d4d4d4); } button.tertiary { --lmvz-button-background: var(--lmvz-semantic-color-int-tertiary, #ffffff); --lmvz-button-color: var(--lmvz-semantic-color-int-on-tertiary, #545454); } button.tertiary:not([disabled], .disabled):hover { --lmvz-button-background: var(--lmvz-semantic-color-int-tertiary-hover, #f0f0f0); } button.tertiary:not([disabled], .disabled):active { --lmvz-button-background: var(--lmvz-semantic-color-int-tertiary-active, #e0e0e0); } button.small { --lmvz-button-padding-inline: var(--lmvz-component-input-sm-padding-x, clamp(0.5rem, 0.44rem + 0.26vw, 0.75rem)); --lmvz-button-padding-block: var(--lmvz-component-input-sm-padding-y, clamp(0.5rem, 0.44rem + 0.26vw, 0.75rem)); --lmvz-button-gap: var(--lmvz-component-input-sm-gap-x, clamp(0.25rem, 0.16rem + 0.39vw, 0.63rem)); --lmvz-button-font: var(--lmvz-typography-body-md, 400 clamp(0.88rem, 0.84rem + 0.13vw, 1rem) / 1.4 Router); } button.large { --lmvz-button-padding-inline: var(--lmvz-component-input-lg-padding-x, clamp(0.88rem, 0.78rem + 0.39vw, 1.25rem)); --lmvz-button-padding-block: var(--lmvz-component-input-lg-padding-y, clamp(0.88rem, 0.78rem + 0.39vw, 1.25rem)); --lmvz-button-gap: var(--lmvz-component-input-lg-gap-x, clamp(0.25rem, 0.16rem + 0.39vw, 0.63rem)); --lmvz-button-font: var(--lmvz-typography-body-lg, 400 clamp(1rem, 0.97rem + 0.13vw, 1.13rem) / 1.4 Router); } display: contents; } ::slotted(*) { --lmvz-component-color: var(--lmvz-button-color); } `;
3210
-
3211
- const LmvzButton = class extends ReactiveControllerHost {
3212
- get el() { return getElement(this); }
3213
- inheritedAttributes = {};
3214
- formEl = null;
3215
- formButtonEl = null;
3216
- lmvzActivation;
3217
- get ti() {
3218
- return 0;
3219
- }
3220
- scale = 'default';
3221
- variant = 'secondary';
3222
- disabled = false;
3223
- type = 'button';
3224
- form;
3225
- constructor(hostRef) {
3226
- super();
3227
- registerInstance(this, hostRef);
3228
- this.lmvzActivation = createEvent(this, "lmvzActivation");
3229
- this.addController(new AriaValidationController(this));
3230
- this.addController(new ElementActivationController(this, {
3231
- localHandler: this.handleClick.bind(this),
3232
- keys: ['Enter'],
3233
- }));
3234
- }
3235
- connectedCallback() {
3236
- this.inheritedAttributes = inheritAriaAttributes(this.el);
3237
- }
3238
- renderHiddenButton() {
3239
- const formEl = (this.formEl = findFormByRef(this.form, this.el));
3240
- if (!formEl)
3241
- return;
3242
- const { formButtonEl } = this;
3243
- if (formButtonEl !== null && formEl.contains(formButtonEl))
3244
- return;
3245
- const newFormButtonEl = (this.formButtonEl = document.createElement('button'));
3246
- newFormButtonEl.type = 'submit';
3247
- newFormButtonEl.style.display = 'none';
3248
- newFormButtonEl.disabled = this.disabled;
3249
- formEl.appendChild(newFormButtonEl);
3250
- }
3251
- submitForm(ev) {
3252
- if (this.formEl && this.formButtonEl) {
3253
- ev.preventDefault();
3254
- this.formButtonEl.click();
3255
- }
3256
- }
3257
- handleClick = (ev) => {
3258
- if (this.type === 'submit') {
3259
- this.submitForm(ev);
3260
- }
3261
- };
3262
- render() {
3263
- this.renderHiddenButton();
3264
- return (h(Host, { key: '1c96281344dd604e2e4c919ea72907a9e934e5c6', "aria-disabled": this.disabled ? 'true' : null }, h("button", { key: '16728ce6fee7d121e7120aa993031777f6d8570e', disabled: this.disabled, class: classNames(this.variant, { [this.scale ?? '']: !!this.scale, disabled: this.disabled }), ...this.inheritedAttributes }, h("slot", { key: 'e1b0d95953bdbd42885eecdeef8b457070e7e247' }))));
3265
- }
3266
- static get delegatesFocus() { return true; }
3267
- };
3268
- LmvzButton.style = lmvzButtonCss();
3269
-
3270
- class ListKeyboardNavigationController {
3271
- host;
3272
- elements = [];
3273
- constructor(host) {
3274
- this.host = host;
3275
- }
3276
- hostDidRender() {
3277
- this.host.el.addEventListener('keydown', this.handleKeydown);
3278
- }
3279
- updateElements(elements) {
3280
- this.elements = elements;
3281
- }
3282
- handleKeydown = (event) => {
3283
- const { key } = event;
3284
- if (!['ArrowDown', 'ArrowRight', 'ArrowUp', 'ArrowLeft'].includes(key))
3285
- return;
3286
- const activeElement = getDeepActiveElement(document);
3287
- const nextElement = this.getNextFocusableElement(activeElement, ['ArrowDown', 'ArrowRight'].includes(key) ? 'down' : 'up');
3288
- if (nextElement) {
3289
- event.preventDefault();
3290
- nextElement.focus?.();
3291
- }
3292
- };
3293
- getNextFocusableElement(current, direction) {
3294
- const { elements } = this;
3295
- const currentIndex = elements.indexOf(current);
3296
- if (currentIndex === -1)
3297
- return null;
3298
- let nextIndex = null;
3299
- if (direction === 'down') {
3300
- nextIndex = (currentIndex + 1) % elements.length;
3301
- }
3302
- else if (direction === 'up') {
3303
- nextIndex = (currentIndex - 1 + elements.length) % elements.length;
3304
- }
3305
- if (nextIndex == null)
3306
- return null;
3307
- const candidate = elements[nextIndex];
3308
- if (!canReceiveFocus(candidate))
3309
- return this.getNextFocusableElement(candidate, direction);
3310
- return candidate;
3311
- }
3312
- }
3313
-
3314
- const lmvzHeaderCss = () => `:host{display:flex;width:100vw;flex-direction:row;align-items:center;box-sizing:border-box;background-color:var(--lmvz-semantic-color-surface-primary, #ffffff);--lmvz-header-x-spacing-level-1:var(--lmvz-dimension-8-28, clamp(0.5rem, 0.2rem + 1.29vw, 1.75rem));--lmvz-header-x-spacing-level-2:var(--lmvz-component-buttongroup-wrapper-gap-x, clamp(0.25rem, 0.16rem + 0.39vw, 0.63rem));padding:var(--lmvz-dimension-8-16, clamp(0.5rem, 0.38rem + 0.52vw, 1rem)) var(--lmvz-header-x-spacing-level-1);gap:var(--lmvz-header-x-spacing-level-1);.brand{display:inline-flex;justify-content:center;align-items:center}#fallback-logo-lmvz{height:34px;width:auto}nav{flex-grow:1}.primary-menubar{display:flex;flex-direction:row;align-items:center}.secondary-menubar{display:flex;flex-direction:row;align-items:center;margin-left:var(--lmvz-header-x-spacing-level-2);padding-left:var(--lmvz-header-x-spacing-level-2);border-left:1px solid var(--lmvz-semantic-color-border-default, #e0e0e0)}}`;
3315
-
3316
- const LmvzHeader = class extends ReactiveControllerHost {
3317
- get el() { return getElement(this); }
3318
- primarySlot;
3319
- secondarySlot;
3320
- secondaryNav;
3321
- keyboardNavigationController = new ListKeyboardNavigationController(this);
3322
- get primaryMenuitems() {
3323
- return this.primarySlot.assignedElements({ flatten: false });
3324
- }
3325
- get secondaryMenuitems() {
3326
- return this.secondarySlot.assignedElements({ flatten: true });
3327
- }
3328
- get role() {
3329
- return 'banner';
3330
- }
3331
- lmvzActiveNav;
3332
- get secondarySlotName() {
3333
- return `connect-nav-${this.lmvzActiveNav}`;
3334
- }
3335
- constructor(hostRef) {
3336
- super();
3337
- registerInstance(this, hostRef);
3338
- this.addController(new AriaValidationController(this, { reValidateOnPropChanges: true }));
3339
- this.addController(this.keyboardNavigationController);
3340
- }
3341
- handleActiveNavChange() {
3342
- this.updateElementsActive();
3343
- }
3344
- componentDidLoad() {
3345
- this.primarySlot.addEventListener('slotchange', this.handlePrimaryNavChange.bind(this));
3346
- this.handlePrimaryNavChange();
3347
- this.secondarySlot.addEventListener('slotchange', this.handleSecondaryNavChange.bind(this));
3348
- }
3349
- handlePrimaryNavChange() {
3350
- const items = this.primaryMenuitems;
3351
- if (!items.length) {
3352
- console.warn('Primary slot has no assigned elements. Please add navigation items to the primary slot.');
3353
- return;
3354
- }
3355
- items.forEach(el => {
3356
- el.setAttribute('aria-haspopup', 'true');
3357
- el.setAttribute('aria-controls', `nav-secondary`);
3358
- });
3359
- this.updateElementsActive();
3360
- }
3361
- handleSecondaryNavChange() {
3362
- const items = this.secondaryMenuitems;
3363
- if (!items.length) {
3364
- return;
3365
- }
3366
- this.keyboardNavigationController.updateElements([...this.primaryMenuitems, ...this.secondaryMenuitems]);
3367
- }
3368
- updateElementsActive() {
3369
- const items = this.primaryMenuitems;
3370
- let label;
3371
- items.forEach(el => {
3372
- const isActive = el.id === this.lmvzActiveNav;
3373
- if (isActive)
3374
- label = el.textContent || el.id;
3375
- el.setAttribute('aria-expanded', isActive ? 'true' : 'false');
3376
- });
3377
- this.secondaryNav.setAttribute('aria-label', `Untermenü für ${label}`);
3378
- }
3379
- delegateFocus() {
3380
- const firstFocusable = this.primaryMenuitems[0];
3381
- if (firstFocusable) {
3382
- firstFocusable.focus();
3383
- }
3384
- }
3385
- render() {
3386
- return (h(Host, { key: '58934683ff442801eb34f025ac809631f93a27e8', onFocus: this.delegateFocus.bind(this) }, h("div", { key: '35d3eadfabb70f83b313f946c8d31f9c223e8344', class: "brand" }, h("slot", { key: '5ce98314d980d63e1c87f508d96119aca2e702a9', name: "brand" }, h("lmvz-icon", { key: 'b24e61a9071d81948d506a8c545e012d3f0e5dd2', id: "fallback-logo-lmvz", icon: "Logo", size: "inherit", "aria-label": "Lehrmittelverlag Z\u00FCrich" }))), h("nav", { key: '1d5cc9010ef90e6cebc8a7b054db595f35f9e040', "aria-label": "Hauptnavigation" }, h("div", { key: '488a1b1544242562b57d76169f1988d84c611de4', role: "menubar", class: "primary-menubar" }, h("slot", { key: '59c6dd1442290931ed9a55f7bacc65ea4bb9ff6d', name: "nav-primary", ref: el => (this.primarySlot = el) }), h("separator", { key: '2729f0e8b115614c50c4a16b6684a3bdb21856b8' }), h("div", { key: '6b5bed5951bad9173fefdc78039e71c4ccc120b2', role: "menu", id: "nav-secondary", class: "secondary-menubar", hidden: !this.lmvzActiveNav, ref: el => (this.secondaryNav = el) }, h("slot", { key: '02f5a13e8851372c1698e3f786a8757a0a09c32f', name: this.secondarySlotName, ref: el => (this.secondarySlot = el) })))), h("div", { key: '53aafe8139bcea27d3039f64a48974cdb5aac5f9', class: "actions" }, h("slot", { key: 'f12ee19831073253e6ba8e251ba31ec403c21035', name: "actions" }))));
3387
- }
3388
- static get watchers() { return {
3389
- "lmvzActiveNav": [{
3390
- "handleActiveNavChange": 0
3391
- }]
3392
- }; }
3393
- };
3394
- LmvzHeader.style = lmvzHeaderCss();
3395
-
3396
- const lmvzIconCss = () => `.sc-lmvz-icon-h{--lmvz-icon-color:var(--lmvz-component-color, var(--lmvz-semantic-color-on-surface-input-primary, #000000));display:inline-block;line-height:0;svg{display:block}svg>path{stroke:var(--lmvz-icon-color);fill:none}}[size='xs'].sc-lmvz-icon-h{svg{width:var(--lmvz-component-icon-size-xs, clamp(0.75rem, 0.69rem + 0.26vw, 1rem));height:var(--lmvz-component-icon-size-xs, clamp(0.75rem, 0.69rem + 0.26vw, 1rem))}}[size='sm'].sc-lmvz-icon-h{svg{width:var(--lmvz-component-icon-size-sm, clamp(0.88rem, 0.81rem + 0.26vw, 1.13rem));height:var(--lmvz-component-icon-size-sm, clamp(0.88rem, 0.81rem + 0.26vw, 1.13rem))}}[size='md'].sc-lmvz-icon-h{svg{width:var(--lmvz-component-icon-size-md, clamp(1rem, 0.88rem + 0.52vw, 1.5rem));height:var(--lmvz-component-icon-size-md, clamp(1rem, 0.88rem + 0.52vw, 1.5rem))}}[size='lg'].sc-lmvz-icon-h{svg{width:var(--lmvz-component-icon-size-lg, clamp(1.5rem, 1.38rem + 0.52vw, 2rem));height:var(--lmvz-component-icon-size-lg, clamp(1.5rem, 1.38rem + 0.52vw, 2rem))}}[size='inherit'].sc-lmvz-icon-h{svg{width:inherit;height:inherit}}[weight='light'].sc-lmvz-icon-h{svg>path{stroke-width:1}}[weight='medium'].sc-lmvz-icon-h{svg>path{stroke-width:1.5}}[weight='bold'].sc-lmvz-icon-h{svg>path{stroke-width:2}}[weight='filled'].sc-lmvz-icon-h{svg>path{stroke-width:2;fill:var(--lmvz-icon-color)}}`;
3397
-
3398
- const LmvzIcon = class extends ReactiveControllerHost {
3399
- intersectionObserver;
3400
- get el() { return getElement(this); }
3401
- icon;
3402
- weight = 'medium';
3403
- size = 'md';
3404
- iconData;
3405
- visible = false;
3406
- ariaLabel;
3407
- get ariaHidden() {
3408
- return !this.ariaLabel;
3409
- }
3410
- constructor(hostRef) {
3411
- super();
3412
- registerInstance(this, hostRef);
3413
- this.addController(new AriaValidationController(this));
3414
- }
3415
- connectedCallback() {
3416
- this.waitUntilVisible(() => {
3417
- this.visible = true;
3418
- this.loadIconPathData();
3419
- });
3420
- }
3421
- disconnectedCallback() {
3422
- if (this.intersectionObserver) {
3423
- this.intersectionObserver.disconnect();
3424
- this.intersectionObserver = null;
3425
- }
3426
- }
3427
- async loadIconPathData() {
3428
- const { icon, visible } = this;
3429
- if (!icon || !visible) {
3430
- return;
3431
- }
3432
- this.iconData = await runPromise(fetchIconSvg(this.icon).pipe(tapError(error => logError(`Error loading icon "${icon}":`, error.message, error.cause, error.stack)), catchAll$1(() => succeed$3(emptyDefaultSvg()))));
3433
- }
3434
- render() {
3435
- return h(Host, { key: '50d0f96ec5085a47ca7783e5232dfb503fa32d29', role: "img", "aria-hidden": `${this.ariaHidden}`, innerHTML: this.iconData });
3436
- }
3437
- waitUntilVisible(callback, rootMargin = 50) {
3438
- if (typeof window === 'undefined' || !window.IntersectionObserver) {
3439
- callback();
3440
- return;
3441
- }
3442
- this.intersectionObserver = new IntersectionObserver(entries => {
3443
- entries.some(entry => {
3444
- if (entry.isIntersecting) {
3445
- this.intersectionObserver.disconnect();
3446
- this.intersectionObserver = null;
3447
- callback();
3448
- return true;
3449
- }
3450
- return false;
3451
- });
3452
- }, { rootMargin: `${rootMargin}px` });
3453
- this.intersectionObserver.observe(this.el);
3454
- }
3455
- static get assetsDirs() { return ["../../assets/icons"]; }
3456
- static get watchers() { return {
3457
- "icon": [{
3458
- "loadIconPathData": 0
3459
- }]
3460
- }; }
3461
- };
3462
- LmvzIcon.style = lmvzIconCss();
3463
-
3464
- const lmvzInputCss = () => `@layer lmvz-ds.reset, lmvz-ds.theme, lmvz-ds.components, lmvz-ds.overrides; @layer lmvz-ds.theme { @font-face { font-family: Router; src: local('Router-Book'), url('/assets/fonts/Router-Book.woff') format('woff'), local('Router'); font-weight: 400 normal; } @font-face { font-family: Router; src: local('Router-Medium'), url('/assets/fonts/Router-Medium.woff') format('woff'), local('Router'); font-weight: 500; } @font-face { font-family: Router; src: local('Router-Bold'), url('/assets/fonts/Router-Bold.woff') format('woff'), local('Router'); font-weight: 700 bold; } } .sc-lmvz-input-h { display: block; font-family: var(--lmvz-global-font-family-default, Router); --input-radius: var(--lmvz-component-input-radius-default, 999px); --input-bg: var(--lmvz-semantic-color-surface-input-primary, #ffffff); --input-border-color: var(--lmvz-semantic-color-border-default, #e0e0e0); --input-border-color-hover: var(--lmvz-semantic-color-border-hover, #c7c7c7); --input-border-color-focus: var(--lmvz-semantic-color-status-on-selected, #0e7ab4); --input-border-width: var(--lmvz-semantic-border-width-default, 1px); --input-height: 48px; --input-padding-x: 16px; --label-color: var(--lmvz-semantic-color-on-surface-input-secondary, #7a7a7a); --input-text-color: var(--lmvz-semantic-color-on-surface-input-primary, #000000); --helper-text-color: var(--lmvz-semantic-color-on-surface-input-secondary, #7a7a7a); --error-text-color: var(--lmvz-semantic-color-status-on-danger, #e52a31); --label-floating-scale: 0.85; --label-minimized-top: -6px; --label-minimized-bg: var(--input-bg); --label-minimized-padding-x: 4px; --input-disabled-opacity: var(--lmvz-component-input-disabled-opacity, 40%); } .input-container.sc-lmvz-input { display: flex; flex-direction: column; position: relative; width: 100%; } .input-wrapper.sc-lmvz-input { background-color: var(--input-bg); border: var(--input-border-width) solid var(--input-border-color); border-radius: var(--input-radius); display: flex; align-items: center; height: var(--input-height); padding: 0 var(--input-padding-x); position: relative; transition: border-color 0.2s ease; gap: 8px; } [disabled].sc-lmvz-input-h .input-wrapper.sc-lmvz-input { opacity: var(--input-disabled-opacity); cursor: not-allowed; pointer-events: none; } .input-container.sc-lmvz-input:focus-within .input-wrapper.sc-lmvz-input { border-color: var(--input-border-color-focus); outline: 2px solid var(--input-border-color-focus); outline-offset: 2px; } .input-container.sc-lmvz-input:has(input:focus-visible) .input-wrapper.sc-lmvz-input { box-shadow: 0 0 0 3px rgb(0 86 214 / 20%); } [error].sc-lmvz-input-h .input-wrapper.sc-lmvz-input { border-color: var(--error-text-color); } [error].sc-lmvz-input-h:focus-within .input-wrapper.sc-lmvz-input { border-color: var(--error-text-color); outline-color: var(--error-text-color); } .sc-lmvz-input-h:not([disabled]) .input-wrapper.sc-lmvz-input:hover { border-color: var(--input-border-color-hover); } .label-input-group.sc-lmvz-input { position: relative; flex-grow: 1; display: flex; align-items: center; height: 100%; } label.sc-lmvz-input { position: absolute; left: 0; top: 50%; transform: translateY(-50%); color: var(--label-color); font-size: 14px; font-family: Router, sans-serif; font-weight: 400; pointer-events: none; transition: all 0.2s ease-out; background-color: transparent; padding: 0; margin: 0; line-height: normal; white-space: nowrap; } label.floating.sc-lmvz-input { top: 0; transform: translateY(-50%) scale(0.85); transform-origin: left top; background-color: var(--label-minimized-bg); padding: 0 var(--label-minimized-padding-x); left: -2px; color: var(--input-text-color); font-weight: 500; } .required-indicator.sc-lmvz-input { color: var(--error-text-color); margin-left: 2px; } input.sc-lmvz-input { border: none; background: transparent; width: 100%; height: 100%; color: var(--input-text-color); font-family: inherit; font-size: 14px; outline: none; padding: 0; margin: 0; font-weight: 400; } input.sc-lmvz-input::placeholder { color: var(--label-color); } .helper-text.sc-lmvz-input { padding-top: 8px; padding-left: 12px; font-size: 12px; color: var(--helper-text-color); font-family: Router, sans-serif; font-weight: 500; } .error-message.sc-lmvz-input { padding-top: 8px; padding-left: 12px; font-size: 12px; color: var(--error-text-color); font-family: Router, sans-serif; font-weight: 500; } .sc-lmvz-input-s > lmvz-button { --lmvz-button-padding: 4px; }`;
3465
-
3466
- let inputIdCounter = 0;
3467
- const LmvzInput = class extends ReactiveControllerHost {
3468
- get el() { return getElement(this); }
3469
- lmvzInput;
3470
- internals;
3471
- nativeInputElement;
3472
- inputId = `lmvz-input-${inputIdCounter++}`;
3473
- initialValue = '';
3474
- nativeError = false;
3475
- errorFromProp = false;
3476
- get helperId() {
3477
- return this.helperText ? `${this.inputId}-helper` : undefined;
3478
- }
3479
- get showErrorMessage() {
3480
- return this.error && Boolean(this.errorMessage);
3481
- }
3482
- get errorId() {
3483
- return `${this.inputId}-error`;
3484
- }
3485
- get describedBy() {
3486
- const ids = [];
3487
- if (this.helperId)
3488
- ids.push(this.helperId);
3489
- if (this.showErrorMessage)
3490
- ids.push(this.errorId);
3491
- return ids.length > 0 ? ids.join(' ') : undefined;
3492
- }
3493
- value;
3494
- label;
3495
- helperText;
3496
- placeholder;
3497
- disabled = false;
3498
- readonly = false;
3499
- required = false;
3500
- name;
3501
- type = 'text';
3502
- errorMessage;
3503
- autocomplete;
3504
- inputmode;
3505
- autocorrect;
3506
- autocapitalize;
3507
- spellcheck;
3508
- autofocus = false;
3509
- minlength;
3510
- maxlength;
3511
- pattern;
3512
- min;
3513
- max;
3514
- step;
3515
- form;
3516
- get error() {
3517
- return this.errorFromProp || this.nativeError;
3518
- }
3519
- set error(value) {
3520
- this.errorFromProp = value;
3521
- }
3522
- async setValue(newValue) {
3523
- const input = this.nativeInputElement;
3524
- this.value = input.value = newValue ?? '';
3525
- this.internals.setFormValue?.(newValue);
3526
- this.lmvzInput.emit(newValue);
3527
- }
3528
- async focusInput() {
3529
- this.nativeInputElement?.focus();
3530
- }
3531
- async blurInput() {
3532
- this.nativeInputElement?.blur();
3533
- }
3534
- async select() {
3535
- this.nativeInputElement?.select();
3536
- }
3537
- async checkValidity() {
3538
- return this.nativeInputElement?.checkValidity?.() ?? false;
3539
- }
3540
- async reportValidity() {
3541
- return this.nativeInputElement?.reportValidity?.() ?? false;
3542
- }
3543
- async getInputElement() {
3544
- if (!this.nativeInputElement) {
3545
- await new Promise(resolve => componentOnReady(this.el, resolve));
3546
- }
3547
- return Promise.resolve(this.nativeInputElement);
3548
- }
3549
- constructor(hostRef) {
3550
- super();
3551
- registerInstance(this, hostRef);
3552
- this.lmvzInput = createEvent(this, "lmvzInput");
3553
- if (hostRef.$hostElement$["s-ei"]) {
3554
- this.internals = hostRef.$hostElement$["s-ei"];
3555
- }
3556
- else {
3557
- this.internals = hostRef.$hostElement$.attachInternals();
3558
- hostRef.$hostElement$["s-ei"] = this.internals;
3559
- }
3560
- this.addController(new AriaValidationController(this, {
3561
- reValidateOnPropChanges: true,
3562
- }));
3563
- }
3564
- componentWillLoad() {
3565
- this.initialValue = this.value;
3566
- }
3567
- formAssociatedCallback(form) {
3568
- if (!form)
3569
- return;
3570
- this.internals.setFormValue?.(this.value);
3571
- }
3572
- formResetCallback() {
3573
- this.internals.setValidity({});
3574
- this.setValue(this.initialValue);
3575
- }
3576
- formStateRestoreCallback(state) {
3577
- this.setValue(state);
3578
- }
3579
- handleValueChange(newValue) {
3580
- if (!this.nativeInputElement)
3581
- return;
3582
- const isInternalChange = this.nativeInputElement.value === newValue;
3583
- if (isInternalChange)
3584
- return;
3585
- this.setValue(newValue);
3586
- }
3587
- handleDisabledChange(disabled) {
3588
- if (disabled && this.nativeInputElement) {
3589
- this.nativeInputElement.blur();
3590
- }
3591
- }
3592
- handleInput = (event) => {
3593
- const input = event.target;
3594
- this.setValue(input.value);
3595
- };
3596
- handleChange = (event) => {
3597
- const input = event.target ?? this.nativeInputElement;
3598
- this.updateNativeError(input);
3599
- };
3600
- handleFocus = () => { };
3601
- handleBlur = (event) => {
3602
- const input = event.target;
3603
- input.reportValidity?.();
3604
- };
3605
- updateNativeError(fromEvent) {
3606
- const input = fromEvent ?? this.nativeInputElement;
3607
- if (!input)
3608
- return;
3609
- this.nativeError = !(input.checkValidity?.() ?? true);
3610
- }
3611
- render() {
3612
- const hasValue = Boolean(this.value);
3613
- const shouldFloatLabel = hasValue || Boolean(this.placeholder);
3614
- return (h("div", { key: '402189a211eec970a9f5b8fcc551c6c3508bec05', class: classNames('input-container', {
3615
- 'interaction-filled': hasValue,
3616
- }) }, h("div", { key: '1cbe6011f14774e1226406ef4fe301fd94338444', class: "input-wrapper" }, h("slot", { key: 'ea0f30124315c88e9721bb4457126bd6cf18110a', name: "before-input" }), h("div", { key: 'f630b5f3a33a961f94b5a782b0ce6b4d49d1958c', class: "label-input-group" }, h("label", { key: 'dbb3fe066ebf93f7fcbe6973a1e37685d7206888', htmlFor: this.inputId, class: classNames({ floating: shouldFloatLabel }) }, this.label, this.required && (h("span", { key: '7c1a2458b66becb45c730bfe3ff0c570293f702f', class: "required-indicator", "aria-hidden": "true" }, ' ', "*"))), h("input", { key: '14b14457e200d20faf9053848662743dfe1cf417', id: this.inputId, ref: el => (this.nativeInputElement = el), type: this.type, min: this.min, max: this.max, step: this.step, value: this.value, name: this.name, placeholder: this.placeholder, disabled: this.disabled, readOnly: this.readonly, required: this.required, form: this.form, autocomplete: this.autocomplete, inputmode: this.inputmode, autocorrect: this.autocorrect, autocapitalize: this.autocapitalize, spellcheck: this.spellcheck, autofocus: this.autofocus, minlength: this.minlength, maxlength: this.maxlength, pattern: this.pattern, "aria-invalid": this.error ? 'true' : 'false', "aria-required": this.required ? 'true' : 'false', "aria-describedby": this.describedBy, "aria-errormessage": this.errorId, onInput: this.handleInput, onChange: this.handleChange, onFocus: this.handleFocus, onBlur: this.handleBlur })), h("slot", { key: '4b530738ff7404eb1bcecc10a0388570e2243cf3', name: "after-input" })), this.helperText && (h("div", { key: 'f1a287047e9b4d58aa90af157d50b3d564555e9b', id: this.helperId, class: "helper-text" }, this.helperText)), this.showErrorMessage && (h("div", { key: '2a25c4a88a63363cdd814f1d4fead5e8a238621b', id: this.errorId, class: "error-message", role: "alert" }, this.errorMessage))));
3617
- }
3618
- static get formAssociated() { return true; }
3619
- static get watchers() { return {
3620
- "value": [{
3621
- "handleValueChange": 0
3622
- }],
3623
- "disabled": [{
3624
- "handleDisabledChange": 0
3625
- }]
3626
- }; }
3627
- };
3628
- LmvzInput.style = lmvzInputCss();
3629
-
3630
- const lmvzMenuitemCss = () => `@layer lmvz-ds.reset, lmvz-ds.theme, lmvz-ds.components, lmvz-ds.overrides; @layer lmvz-ds.theme { @font-face { font-family: Router; src: local('Router-Book'), url('/assets/fonts/Router-Book.woff') format('woff'), local('Router'); font-weight: 400 normal; } @font-face { font-family: Router; src: local('Router-Medium'), url('/assets/fonts/Router-Medium.woff') format('woff'), local('Router'); font-weight: 500; } @font-face { font-family: Router; src: local('Router-Bold'), url('/assets/fonts/Router-Bold.woff') format('woff'), local('Router'); font-weight: 700 bold; } } .sc-lmvz-menuitem-h { display: inline-flex; flex-direction: row; align-items: center; justify-content: center; gap: var(--lmvz-component-input-md-gap-x, clamp(0.25rem, 0.16rem + 0.39vw, 0.63rem)); border-radius: var(--lmvz-semantic-border-radius-lg, 14px); font: var(--lmvz-typography-body-md, 400 clamp(0.88rem, 0.84rem + 0.13vw, 1rem) / 1.4 Router); padding: var(--lmvz-component-input-md-padding-y, clamp(0.75rem, 0.69rem + 0.26vw, 1rem)) var(--lmvz-component-input-md-padding-x, clamp(0.75rem, 0.69rem + 0.26vw, 1rem)); cursor: pointer; --lmvz-menuitem-color: var(--lmvz-semantic-color-int-on-tertiary, #545454); --lmvz-menuitem-background: var(--lmvz-semantic-color-int-tertiary, #ffffff); background: var(--lmvz-menuitem-background); color: var(--lmvz-menuitem-color); } .sc-lmvz-menuitem-h:hover { --lmvz-menuitem-background: var(--lmvz-semantic-color-int-tertiary-hover, #f0f0f0); } .sc-lmvz-menuitem-h:active { --lmvz-menuitem-background: var(--lmvz-semantic-color-int-tertiary-active, #e0e0e0); } .sc-lmvz-menuitem-h:focus-visible { z-index: 1; } [aria-expanded='true'].sc-lmvz-menuitem-h { --lmvz-menuitem-background: var(--lmvz-semantic-color-status-selected, #f1f9fe); --lmvz-menuitem-color: var(--lmvz-semantic-color-status-on-selected, #0e7ab4); }`;
3631
-
3632
- const LmvzMenuItem = class extends ReactiveControllerHost {
3633
- get el() { return getElement(this); }
3634
- get role() {
3635
- return 'menuitem';
3636
- }
3637
- get ti() {
3638
- return 0;
3639
- }
3640
- lmvzActivation;
3641
- constructor(hostRef) {
3642
- super();
3643
- registerInstance(this, hostRef);
3644
- this.lmvzActivation = createEvent(this, "lmvzActivation");
3645
- this.addController(new AriaValidationController(this));
3646
- this.addController(new ElementActivationController(this));
3647
- }
3648
- render() {
3649
- return (h(Host, { key: '44399be11122af25d05e5b3b5f05dd90a89fddc4' }, h("slot", { key: '2809f9e89a0c38af4d3f1f17ad78397487370134' })));
3650
- }
3651
- };
3652
- LmvzMenuItem.style = lmvzMenuitemCss();
3653
-
3654
- export { HeaderIntegration as H, LmvzButton as L, LmvzHeader as a, LmvzIcon as b, LmvzInput as c, LmvzMenuItem as d, getDefaultExportFromCjs as g };
3655
- //# sourceMappingURL=header-integration.lmvz-button.lmvz-header.lmvz-icon.lmvz-input.lmvz-menuitem-CW3FGLZC.js.map
3656
-
3657
- //# sourceMappingURL=header-integration.lmvz-button.lmvz-header.lmvz-icon.lmvz-input.lmvz-menuitem-CW3FGLZC.js.map