react-server-dom-parcel 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2558 @@
1
+ /**
2
+ * @license React
3
+ * react-server-dom-parcel-server.browser.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+
11
+ "use strict";
12
+ var ReactDOM = require("react-dom"),
13
+ React = require("react");
14
+ function resolveServerReference(bundlerConfig, ref) {
15
+ var idx = ref.lastIndexOf("#"),
16
+ id = ref.slice(0, idx);
17
+ idx = ref.slice(idx + 1);
18
+ bundlerConfig = bundlerConfig[id];
19
+ if (!bundlerConfig) throw Error("Invalid server action: " + ref);
20
+ return { id: id, name: idx, bundles: bundlerConfig };
21
+ }
22
+ function preloadModule$1(metadata) {
23
+ return Promise.all(
24
+ metadata.bundles.map(function (bundlePath) {
25
+ return import(parcelRequire.meta.distDir + "/" + bundlePath);
26
+ })
27
+ );
28
+ }
29
+ function requireModule(metadata) {
30
+ return parcelRequire(metadata.id)[metadata.name];
31
+ }
32
+ var channel = new MessageChannel(),
33
+ taskQueue = [];
34
+ channel.port1.onmessage = function () {
35
+ var task = taskQueue.shift();
36
+ task && task();
37
+ };
38
+ function scheduleWork(callback) {
39
+ taskQueue.push(callback);
40
+ channel.port2.postMessage(null);
41
+ }
42
+ function handleErrorInNextTick(error) {
43
+ setTimeout(function () {
44
+ throw error;
45
+ });
46
+ }
47
+ var LocalPromise = Promise,
48
+ scheduleMicrotask =
49
+ "function" === typeof queueMicrotask
50
+ ? queueMicrotask
51
+ : function (callback) {
52
+ LocalPromise.resolve(null)
53
+ .then(callback)
54
+ .catch(handleErrorInNextTick);
55
+ },
56
+ currentView = null,
57
+ writtenBytes = 0;
58
+ function writeChunkAndReturn(destination, chunk) {
59
+ if (0 !== chunk.byteLength)
60
+ if (2048 < chunk.byteLength)
61
+ 0 < writtenBytes &&
62
+ (destination.enqueue(
63
+ new Uint8Array(currentView.buffer, 0, writtenBytes)
64
+ ),
65
+ (currentView = new Uint8Array(2048)),
66
+ (writtenBytes = 0)),
67
+ destination.enqueue(chunk);
68
+ else {
69
+ var allowableBytes = currentView.length - writtenBytes;
70
+ allowableBytes < chunk.byteLength &&
71
+ (0 === allowableBytes
72
+ ? destination.enqueue(currentView)
73
+ : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
74
+ destination.enqueue(currentView),
75
+ (chunk = chunk.subarray(allowableBytes))),
76
+ (currentView = new Uint8Array(2048)),
77
+ (writtenBytes = 0));
78
+ currentView.set(chunk, writtenBytes);
79
+ writtenBytes += chunk.byteLength;
80
+ }
81
+ return !0;
82
+ }
83
+ var textEncoder = new TextEncoder();
84
+ function stringToChunk(content) {
85
+ return textEncoder.encode(content);
86
+ }
87
+ function byteLengthOfChunk(chunk) {
88
+ return chunk.byteLength;
89
+ }
90
+ function closeWithError(destination, error) {
91
+ "function" === typeof destination.error
92
+ ? destination.error(error)
93
+ : destination.close();
94
+ }
95
+ var CLIENT_REFERENCE_TAG$1 = Symbol.for("react.client.reference"),
96
+ SERVER_REFERENCE_TAG = Symbol.for("react.server.reference"),
97
+ FunctionBind = Function.prototype.bind,
98
+ ArraySlice = Array.prototype.slice;
99
+ function bind() {
100
+ var newFn = FunctionBind.apply(this, arguments);
101
+ if (this.$$typeof === SERVER_REFERENCE_TAG) {
102
+ var args = ArraySlice.call(arguments, 1),
103
+ $$typeof = { value: SERVER_REFERENCE_TAG },
104
+ $$id = { value: this.$$id };
105
+ args = { value: this.$$bound ? this.$$bound.concat(args) : args };
106
+ return Object.defineProperties(newFn, {
107
+ $$typeof: $$typeof,
108
+ $$id: $$id,
109
+ $$bound: args,
110
+ bind: { value: bind, configurable: !0 }
111
+ });
112
+ }
113
+ return newFn;
114
+ }
115
+ var ReactDOMSharedInternals =
116
+ ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
117
+ previousDispatcher = ReactDOMSharedInternals.d;
118
+ ReactDOMSharedInternals.d = {
119
+ f: previousDispatcher.f,
120
+ r: previousDispatcher.r,
121
+ D: prefetchDNS,
122
+ C: preconnect,
123
+ L: preload,
124
+ m: preloadModule,
125
+ X: preinitScript,
126
+ S: preinitStyle,
127
+ M: preinitModuleScript
128
+ };
129
+ function prefetchDNS(href) {
130
+ if ("string" === typeof href && href) {
131
+ var request = currentRequest ? currentRequest : null;
132
+ if (request) {
133
+ var hints = request.hints,
134
+ key = "D|" + href;
135
+ hints.has(key) || (hints.add(key), emitHint(request, "D", href));
136
+ } else previousDispatcher.D(href);
137
+ }
138
+ }
139
+ function preconnect(href, crossOrigin) {
140
+ if ("string" === typeof href) {
141
+ var request = currentRequest ? currentRequest : null;
142
+ if (request) {
143
+ var hints = request.hints,
144
+ key = "C|" + (null == crossOrigin ? "null" : crossOrigin) + "|" + href;
145
+ hints.has(key) ||
146
+ (hints.add(key),
147
+ "string" === typeof crossOrigin
148
+ ? emitHint(request, "C", [href, crossOrigin])
149
+ : emitHint(request, "C", href));
150
+ } else previousDispatcher.C(href, crossOrigin);
151
+ }
152
+ }
153
+ function preload(href, as, options) {
154
+ if ("string" === typeof href) {
155
+ var request = currentRequest ? currentRequest : null;
156
+ if (request) {
157
+ var hints = request.hints,
158
+ key = "L";
159
+ if ("image" === as && options) {
160
+ var imageSrcSet = options.imageSrcSet,
161
+ imageSizes = options.imageSizes,
162
+ uniquePart = "";
163
+ "string" === typeof imageSrcSet && "" !== imageSrcSet
164
+ ? ((uniquePart += "[" + imageSrcSet + "]"),
165
+ "string" === typeof imageSizes &&
166
+ (uniquePart += "[" + imageSizes + "]"))
167
+ : (uniquePart += "[][]" + href);
168
+ key += "[image]" + uniquePart;
169
+ } else key += "[" + as + "]" + href;
170
+ hints.has(key) ||
171
+ (hints.add(key),
172
+ (options = trimOptions(options))
173
+ ? emitHint(request, "L", [href, as, options])
174
+ : emitHint(request, "L", [href, as]));
175
+ } else previousDispatcher.L(href, as, options);
176
+ }
177
+ }
178
+ function preloadModule(href, options) {
179
+ if ("string" === typeof href) {
180
+ var request = currentRequest ? currentRequest : null;
181
+ if (request) {
182
+ var hints = request.hints,
183
+ key = "m|" + href;
184
+ if (hints.has(key)) return;
185
+ hints.add(key);
186
+ return (options = trimOptions(options))
187
+ ? emitHint(request, "m", [href, options])
188
+ : emitHint(request, "m", href);
189
+ }
190
+ previousDispatcher.m(href, options);
191
+ }
192
+ }
193
+ function preinitStyle(href, precedence, options) {
194
+ if ("string" === typeof href) {
195
+ var request = currentRequest ? currentRequest : null;
196
+ if (request) {
197
+ var hints = request.hints,
198
+ key = "S|" + href;
199
+ if (hints.has(key)) return;
200
+ hints.add(key);
201
+ return (options = trimOptions(options))
202
+ ? emitHint(request, "S", [
203
+ href,
204
+ "string" === typeof precedence ? precedence : 0,
205
+ options
206
+ ])
207
+ : "string" === typeof precedence
208
+ ? emitHint(request, "S", [href, precedence])
209
+ : emitHint(request, "S", href);
210
+ }
211
+ previousDispatcher.S(href, precedence, options);
212
+ }
213
+ }
214
+ function preinitScript(src, options) {
215
+ if ("string" === typeof src) {
216
+ var request = currentRequest ? currentRequest : null;
217
+ if (request) {
218
+ var hints = request.hints,
219
+ key = "X|" + src;
220
+ if (hints.has(key)) return;
221
+ hints.add(key);
222
+ return (options = trimOptions(options))
223
+ ? emitHint(request, "X", [src, options])
224
+ : emitHint(request, "X", src);
225
+ }
226
+ previousDispatcher.X(src, options);
227
+ }
228
+ }
229
+ function preinitModuleScript(src, options) {
230
+ if ("string" === typeof src) {
231
+ var request = currentRequest ? currentRequest : null;
232
+ if (request) {
233
+ var hints = request.hints,
234
+ key = "M|" + src;
235
+ if (hints.has(key)) return;
236
+ hints.add(key);
237
+ return (options = trimOptions(options))
238
+ ? emitHint(request, "M", [src, options])
239
+ : emitHint(request, "M", src);
240
+ }
241
+ previousDispatcher.M(src, options);
242
+ }
243
+ }
244
+ function trimOptions(options) {
245
+ if (null == options) return null;
246
+ var hasProperties = !1,
247
+ trimmed = {},
248
+ key;
249
+ for (key in options)
250
+ null != options[key] &&
251
+ ((hasProperties = !0), (trimmed[key] = options[key]));
252
+ return hasProperties ? trimmed : null;
253
+ }
254
+ var TEMPORARY_REFERENCE_TAG = Symbol.for("react.temporary.reference"),
255
+ proxyHandlers = {
256
+ get: function (target, name) {
257
+ switch (name) {
258
+ case "$$typeof":
259
+ return target.$$typeof;
260
+ case "name":
261
+ return;
262
+ case "displayName":
263
+ return;
264
+ case "defaultProps":
265
+ return;
266
+ case "toJSON":
267
+ return;
268
+ case Symbol.toPrimitive:
269
+ return Object.prototype[Symbol.toPrimitive];
270
+ case Symbol.toStringTag:
271
+ return Object.prototype[Symbol.toStringTag];
272
+ case "Provider":
273
+ throw Error(
274
+ "Cannot render a Client Context Provider on the Server. Instead, you can export a Client Component wrapper that itself renders a Client Context Provider."
275
+ );
276
+ }
277
+ throw Error(
278
+ "Cannot access " +
279
+ String(name) +
280
+ " on the server. You cannot dot into a temporary client reference from a server component. You can only pass the value through to the client."
281
+ );
282
+ },
283
+ set: function () {
284
+ throw Error(
285
+ "Cannot assign to a temporary client reference from a server module."
286
+ );
287
+ }
288
+ };
289
+ function createTemporaryReference(temporaryReferences, id) {
290
+ var reference = Object.defineProperties(
291
+ function () {
292
+ throw Error(
293
+ "Attempted to call a temporary Client Reference from the server but it is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component."
294
+ );
295
+ },
296
+ { $$typeof: { value: TEMPORARY_REFERENCE_TAG } }
297
+ );
298
+ reference = new Proxy(reference, proxyHandlers);
299
+ temporaryReferences.set(reference, id);
300
+ return reference;
301
+ }
302
+ var REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"),
303
+ REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
304
+ REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
305
+ REACT_CONTEXT_TYPE = Symbol.for("react.context"),
306
+ REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
307
+ REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
308
+ REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
309
+ REACT_MEMO_TYPE = Symbol.for("react.memo"),
310
+ REACT_LAZY_TYPE = Symbol.for("react.lazy"),
311
+ REACT_MEMO_CACHE_SENTINEL = Symbol.for("react.memo_cache_sentinel");
312
+ Symbol.for("react.postpone");
313
+ var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
314
+ function getIteratorFn(maybeIterable) {
315
+ if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
316
+ maybeIterable =
317
+ (MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) ||
318
+ maybeIterable["@@iterator"];
319
+ return "function" === typeof maybeIterable ? maybeIterable : null;
320
+ }
321
+ var ASYNC_ITERATOR = Symbol.asyncIterator,
322
+ SuspenseException = Error(
323
+ "Suspense Exception: This is not a real error! It's an implementation detail of `use` to interrupt the current render. You must either rethrow it immediately, or move the `use` call outside of the `try/catch` block. Capturing without rethrowing will lead to unexpected behavior.\n\nTo handle async errors, wrap your component in an error boundary, or call the promise's `.catch` method and pass the result to `use`."
324
+ );
325
+ function noop$1() {}
326
+ function trackUsedThenable(thenableState, thenable, index) {
327
+ index = thenableState[index];
328
+ void 0 === index
329
+ ? thenableState.push(thenable)
330
+ : index !== thenable && (thenable.then(noop$1, noop$1), (thenable = index));
331
+ switch (thenable.status) {
332
+ case "fulfilled":
333
+ return thenable.value;
334
+ case "rejected":
335
+ throw thenable.reason;
336
+ default:
337
+ "string" === typeof thenable.status
338
+ ? thenable.then(noop$1, noop$1)
339
+ : ((thenableState = thenable),
340
+ (thenableState.status = "pending"),
341
+ thenableState.then(
342
+ function (fulfilledValue) {
343
+ if ("pending" === thenable.status) {
344
+ var fulfilledThenable = thenable;
345
+ fulfilledThenable.status = "fulfilled";
346
+ fulfilledThenable.value = fulfilledValue;
347
+ }
348
+ },
349
+ function (error) {
350
+ if ("pending" === thenable.status) {
351
+ var rejectedThenable = thenable;
352
+ rejectedThenable.status = "rejected";
353
+ rejectedThenable.reason = error;
354
+ }
355
+ }
356
+ ));
357
+ switch (thenable.status) {
358
+ case "fulfilled":
359
+ return thenable.value;
360
+ case "rejected":
361
+ throw thenable.reason;
362
+ }
363
+ suspendedThenable = thenable;
364
+ throw SuspenseException;
365
+ }
366
+ }
367
+ var suspendedThenable = null;
368
+ function getSuspendedThenable() {
369
+ if (null === suspendedThenable)
370
+ throw Error(
371
+ "Expected a suspended thenable. This is a bug in React. Please file an issue."
372
+ );
373
+ var thenable = suspendedThenable;
374
+ suspendedThenable = null;
375
+ return thenable;
376
+ }
377
+ var currentRequest$1 = null,
378
+ thenableIndexCounter = 0,
379
+ thenableState = null;
380
+ function getThenableStateAfterSuspending() {
381
+ var state = thenableState || [];
382
+ thenableState = null;
383
+ return state;
384
+ }
385
+ var HooksDispatcher = {
386
+ useMemo: function (nextCreate) {
387
+ return nextCreate();
388
+ },
389
+ useCallback: function (callback) {
390
+ return callback;
391
+ },
392
+ useDebugValue: function () {},
393
+ useDeferredValue: unsupportedHook,
394
+ useTransition: unsupportedHook,
395
+ readContext: unsupportedContext,
396
+ useContext: unsupportedContext,
397
+ useReducer: unsupportedHook,
398
+ useRef: unsupportedHook,
399
+ useState: unsupportedHook,
400
+ useInsertionEffect: unsupportedHook,
401
+ useLayoutEffect: unsupportedHook,
402
+ useImperativeHandle: unsupportedHook,
403
+ useEffect: unsupportedHook,
404
+ useId: useId,
405
+ useSyncExternalStore: unsupportedHook,
406
+ useCacheRefresh: function () {
407
+ return unsupportedRefresh;
408
+ },
409
+ useMemoCache: function (size) {
410
+ for (var data = Array(size), i = 0; i < size; i++)
411
+ data[i] = REACT_MEMO_CACHE_SENTINEL;
412
+ return data;
413
+ },
414
+ use: use
415
+ };
416
+ function unsupportedHook() {
417
+ throw Error("This Hook is not supported in Server Components.");
418
+ }
419
+ function unsupportedRefresh() {
420
+ throw Error("Refreshing the cache is not supported in Server Components.");
421
+ }
422
+ function unsupportedContext() {
423
+ throw Error("Cannot read a Client Context from a Server Component.");
424
+ }
425
+ function useId() {
426
+ if (null === currentRequest$1)
427
+ throw Error("useId can only be used while React is rendering");
428
+ var id = currentRequest$1.identifierCount++;
429
+ return ":" + currentRequest$1.identifierPrefix + "S" + id.toString(32) + ":";
430
+ }
431
+ function use(usable) {
432
+ if (
433
+ (null !== usable && "object" === typeof usable) ||
434
+ "function" === typeof usable
435
+ ) {
436
+ if ("function" === typeof usable.then) {
437
+ var index = thenableIndexCounter;
438
+ thenableIndexCounter += 1;
439
+ null === thenableState && (thenableState = []);
440
+ return trackUsedThenable(thenableState, usable, index);
441
+ }
442
+ usable.$$typeof === REACT_CONTEXT_TYPE && unsupportedContext();
443
+ }
444
+ if (usable.$$typeof === CLIENT_REFERENCE_TAG$1) {
445
+ if (null != usable.value && usable.value.$$typeof === REACT_CONTEXT_TYPE)
446
+ throw Error("Cannot read a Client Context from a Server Component.");
447
+ throw Error("Cannot use() an already resolved Client Reference.");
448
+ }
449
+ throw Error("An unsupported type was passed to use(): " + String(usable));
450
+ }
451
+ var DefaultAsyncDispatcher = {
452
+ getCacheForType: function (resourceType) {
453
+ var JSCompiler_inline_result = (JSCompiler_inline_result = currentRequest
454
+ ? currentRequest
455
+ : null)
456
+ ? JSCompiler_inline_result.cache
457
+ : new Map();
458
+ var entry = JSCompiler_inline_result.get(resourceType);
459
+ void 0 === entry &&
460
+ ((entry = resourceType()),
461
+ JSCompiler_inline_result.set(resourceType, entry));
462
+ return entry;
463
+ }
464
+ },
465
+ ReactSharedInternalsServer =
466
+ React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
467
+ if (!ReactSharedInternalsServer)
468
+ throw Error(
469
+ 'The "react" package in this environment is not configured correctly. The "react-server" condition must be enabled in any environment that runs React Server Components.'
470
+ );
471
+ var isArrayImpl = Array.isArray,
472
+ getPrototypeOf = Object.getPrototypeOf;
473
+ function objectName(object) {
474
+ return Object.prototype.toString
475
+ .call(object)
476
+ .replace(/^\[object (.*)\]$/, function (m, p0) {
477
+ return p0;
478
+ });
479
+ }
480
+ function describeValueForErrorMessage(value) {
481
+ switch (typeof value) {
482
+ case "string":
483
+ return JSON.stringify(
484
+ 10 >= value.length ? value : value.slice(0, 10) + "..."
485
+ );
486
+ case "object":
487
+ if (isArrayImpl(value)) return "[...]";
488
+ if (null !== value && value.$$typeof === CLIENT_REFERENCE_TAG)
489
+ return "client";
490
+ value = objectName(value);
491
+ return "Object" === value ? "{...}" : value;
492
+ case "function":
493
+ return value.$$typeof === CLIENT_REFERENCE_TAG
494
+ ? "client"
495
+ : (value = value.displayName || value.name)
496
+ ? "function " + value
497
+ : "function";
498
+ default:
499
+ return String(value);
500
+ }
501
+ }
502
+ function describeElementType(type) {
503
+ if ("string" === typeof type) return type;
504
+ switch (type) {
505
+ case REACT_SUSPENSE_TYPE:
506
+ return "Suspense";
507
+ case REACT_SUSPENSE_LIST_TYPE:
508
+ return "SuspenseList";
509
+ }
510
+ if ("object" === typeof type)
511
+ switch (type.$$typeof) {
512
+ case REACT_FORWARD_REF_TYPE:
513
+ return describeElementType(type.render);
514
+ case REACT_MEMO_TYPE:
515
+ return describeElementType(type.type);
516
+ case REACT_LAZY_TYPE:
517
+ var payload = type._payload;
518
+ type = type._init;
519
+ try {
520
+ return describeElementType(type(payload));
521
+ } catch (x) {}
522
+ }
523
+ return "";
524
+ }
525
+ var CLIENT_REFERENCE_TAG = Symbol.for("react.client.reference");
526
+ function describeObjectForErrorMessage(objectOrArray, expandedName) {
527
+ var objKind = objectName(objectOrArray);
528
+ if ("Object" !== objKind && "Array" !== objKind) return objKind;
529
+ objKind = -1;
530
+ var length = 0;
531
+ if (isArrayImpl(objectOrArray)) {
532
+ var str = "[";
533
+ for (var i = 0; i < objectOrArray.length; i++) {
534
+ 0 < i && (str += ", ");
535
+ var value = objectOrArray[i];
536
+ value =
537
+ "object" === typeof value && null !== value
538
+ ? describeObjectForErrorMessage(value)
539
+ : describeValueForErrorMessage(value);
540
+ "" + i === expandedName
541
+ ? ((objKind = str.length), (length = value.length), (str += value))
542
+ : (str =
543
+ 10 > value.length && 40 > str.length + value.length
544
+ ? str + value
545
+ : str + "...");
546
+ }
547
+ str += "]";
548
+ } else if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE)
549
+ str = "<" + describeElementType(objectOrArray.type) + "/>";
550
+ else {
551
+ if (objectOrArray.$$typeof === CLIENT_REFERENCE_TAG) return "client";
552
+ str = "{";
553
+ i = Object.keys(objectOrArray);
554
+ for (value = 0; value < i.length; value++) {
555
+ 0 < value && (str += ", ");
556
+ var name = i[value],
557
+ encodedKey = JSON.stringify(name);
558
+ str += ('"' + name + '"' === encodedKey ? name : encodedKey) + ": ";
559
+ encodedKey = objectOrArray[name];
560
+ encodedKey =
561
+ "object" === typeof encodedKey && null !== encodedKey
562
+ ? describeObjectForErrorMessage(encodedKey)
563
+ : describeValueForErrorMessage(encodedKey);
564
+ name === expandedName
565
+ ? ((objKind = str.length),
566
+ (length = encodedKey.length),
567
+ (str += encodedKey))
568
+ : (str =
569
+ 10 > encodedKey.length && 40 > str.length + encodedKey.length
570
+ ? str + encodedKey
571
+ : str + "...");
572
+ }
573
+ str += "}";
574
+ }
575
+ return void 0 === expandedName
576
+ ? str
577
+ : -1 < objKind && 0 < length
578
+ ? ((objectOrArray = " ".repeat(objKind) + "^".repeat(length)),
579
+ "\n " + str + "\n " + objectOrArray)
580
+ : "\n " + str;
581
+ }
582
+ var ObjectPrototype = Object.prototype,
583
+ stringify = JSON.stringify;
584
+ function defaultErrorHandler(error) {
585
+ console.error(error);
586
+ }
587
+ function defaultPostponeHandler() {}
588
+ function RequestInstance(
589
+ type,
590
+ model,
591
+ bundlerConfig,
592
+ onError,
593
+ identifierPrefix,
594
+ onPostpone,
595
+ temporaryReferences,
596
+ environmentName,
597
+ filterStackFrame,
598
+ onAllReady,
599
+ onFatalError
600
+ ) {
601
+ if (
602
+ null !== ReactSharedInternalsServer.A &&
603
+ ReactSharedInternalsServer.A !== DefaultAsyncDispatcher
604
+ )
605
+ throw Error("Currently React only supports one RSC renderer at a time.");
606
+ ReactSharedInternalsServer.A = DefaultAsyncDispatcher;
607
+ filterStackFrame = new Set();
608
+ environmentName = [];
609
+ var hints = new Set();
610
+ this.type = type;
611
+ this.status = 10;
612
+ this.flushScheduled = !1;
613
+ this.destination = this.fatalError = null;
614
+ this.bundlerConfig = bundlerConfig;
615
+ this.cache = new Map();
616
+ this.pendingChunks = this.nextChunkId = 0;
617
+ this.hints = hints;
618
+ this.abortListeners = new Set();
619
+ this.abortableTasks = filterStackFrame;
620
+ this.pingedTasks = environmentName;
621
+ this.completedImportChunks = [];
622
+ this.completedHintChunks = [];
623
+ this.completedRegularChunks = [];
624
+ this.completedErrorChunks = [];
625
+ this.writtenSymbols = new Map();
626
+ this.writtenClientReferences = new Map();
627
+ this.writtenServerReferences = new Map();
628
+ this.writtenObjects = new WeakMap();
629
+ this.temporaryReferences = temporaryReferences;
630
+ this.identifierPrefix = identifierPrefix || "";
631
+ this.identifierCount = 1;
632
+ this.taintCleanupQueue = [];
633
+ this.onError = void 0 === onError ? defaultErrorHandler : onError;
634
+ this.onPostpone = void 0 === onPostpone ? defaultPostponeHandler : onPostpone;
635
+ this.onAllReady = onAllReady;
636
+ this.onFatalError = onFatalError;
637
+ type = createTask(this, model, null, !1, filterStackFrame);
638
+ environmentName.push(type);
639
+ }
640
+ function noop() {}
641
+ var currentRequest = null;
642
+ function serializeThenable(request, task, thenable) {
643
+ var newTask = createTask(
644
+ request,
645
+ null,
646
+ task.keyPath,
647
+ task.implicitSlot,
648
+ request.abortableTasks
649
+ );
650
+ switch (thenable.status) {
651
+ case "fulfilled":
652
+ return (
653
+ (newTask.model = thenable.value), pingTask(request, newTask), newTask.id
654
+ );
655
+ case "rejected":
656
+ return (
657
+ (task = logRecoverableError(request, thenable.reason, null)),
658
+ emitErrorChunk(request, newTask.id, task),
659
+ (newTask.status = 4),
660
+ request.abortableTasks.delete(newTask),
661
+ newTask.id
662
+ );
663
+ default:
664
+ if (12 === request.status)
665
+ return (
666
+ request.abortableTasks.delete(newTask),
667
+ (newTask.status = 3),
668
+ (task = stringify(serializeByValueID(request.fatalError))),
669
+ emitModelChunk(request, newTask.id, task),
670
+ newTask.id
671
+ );
672
+ "string" !== typeof thenable.status &&
673
+ ((thenable.status = "pending"),
674
+ thenable.then(
675
+ function (fulfilledValue) {
676
+ "pending" === thenable.status &&
677
+ ((thenable.status = "fulfilled"),
678
+ (thenable.value = fulfilledValue));
679
+ },
680
+ function (error) {
681
+ "pending" === thenable.status &&
682
+ ((thenable.status = "rejected"), (thenable.reason = error));
683
+ }
684
+ ));
685
+ }
686
+ thenable.then(
687
+ function (value) {
688
+ newTask.model = value;
689
+ pingTask(request, newTask);
690
+ },
691
+ function (reason) {
692
+ 0 === newTask.status &&
693
+ ((reason = logRecoverableError(request, reason, newTask)),
694
+ emitErrorChunk(request, newTask.id, reason),
695
+ (newTask.status = 4),
696
+ request.abortableTasks.delete(newTask),
697
+ enqueueFlush(request));
698
+ }
699
+ );
700
+ return newTask.id;
701
+ }
702
+ function serializeReadableStream(request, task, stream) {
703
+ function progress(entry) {
704
+ if (!aborted)
705
+ if (entry.done)
706
+ request.abortListeners.delete(abortStream),
707
+ (entry = streamTask.id.toString(16) + ":C\n"),
708
+ request.completedRegularChunks.push(stringToChunk(entry)),
709
+ enqueueFlush(request),
710
+ (aborted = !0);
711
+ else
712
+ try {
713
+ (streamTask.model = entry.value),
714
+ request.pendingChunks++,
715
+ emitChunk(request, streamTask, streamTask.model),
716
+ enqueueFlush(request),
717
+ reader.read().then(progress, error);
718
+ } catch (x$8) {
719
+ error(x$8);
720
+ }
721
+ }
722
+ function error(reason) {
723
+ if (!aborted) {
724
+ aborted = !0;
725
+ request.abortListeners.delete(abortStream);
726
+ var digest = logRecoverableError(request, reason, streamTask);
727
+ emitErrorChunk(request, streamTask.id, digest);
728
+ enqueueFlush(request);
729
+ reader.cancel(reason).then(error, error);
730
+ }
731
+ }
732
+ function abortStream(reason) {
733
+ if (!aborted) {
734
+ aborted = !0;
735
+ request.abortListeners.delete(abortStream);
736
+ var digest = logRecoverableError(request, reason, streamTask);
737
+ emitErrorChunk(request, streamTask.id, digest);
738
+ enqueueFlush(request);
739
+ reader.cancel(reason).then(error, error);
740
+ }
741
+ }
742
+ var supportsBYOB = stream.supportsBYOB;
743
+ if (void 0 === supportsBYOB)
744
+ try {
745
+ stream.getReader({ mode: "byob" }).releaseLock(), (supportsBYOB = !0);
746
+ } catch (x) {
747
+ supportsBYOB = !1;
748
+ }
749
+ var reader = stream.getReader(),
750
+ streamTask = createTask(
751
+ request,
752
+ task.model,
753
+ task.keyPath,
754
+ task.implicitSlot,
755
+ request.abortableTasks
756
+ );
757
+ request.abortableTasks.delete(streamTask);
758
+ request.pendingChunks++;
759
+ task = streamTask.id.toString(16) + ":" + (supportsBYOB ? "r" : "R") + "\n";
760
+ request.completedRegularChunks.push(stringToChunk(task));
761
+ var aborted = !1;
762
+ request.abortListeners.add(abortStream);
763
+ reader.read().then(progress, error);
764
+ return serializeByValueID(streamTask.id);
765
+ }
766
+ function serializeAsyncIterable(request, task, iterable, iterator) {
767
+ function progress(entry) {
768
+ if (!aborted)
769
+ if (entry.done) {
770
+ request.abortListeners.delete(abortIterable);
771
+ if (void 0 === entry.value)
772
+ var endStreamRow = streamTask.id.toString(16) + ":C\n";
773
+ else
774
+ try {
775
+ var chunkId = outlineModel(request, entry.value);
776
+ endStreamRow =
777
+ streamTask.id.toString(16) +
778
+ ":C" +
779
+ stringify(serializeByValueID(chunkId)) +
780
+ "\n";
781
+ } catch (x) {
782
+ error(x);
783
+ return;
784
+ }
785
+ request.completedRegularChunks.push(stringToChunk(endStreamRow));
786
+ enqueueFlush(request);
787
+ aborted = !0;
788
+ } else
789
+ try {
790
+ (streamTask.model = entry.value),
791
+ request.pendingChunks++,
792
+ emitChunk(request, streamTask, streamTask.model),
793
+ enqueueFlush(request),
794
+ iterator.next().then(progress, error);
795
+ } catch (x$9) {
796
+ error(x$9);
797
+ }
798
+ }
799
+ function error(reason) {
800
+ if (!aborted) {
801
+ aborted = !0;
802
+ request.abortListeners.delete(abortIterable);
803
+ var digest = logRecoverableError(request, reason, streamTask);
804
+ emitErrorChunk(request, streamTask.id, digest);
805
+ enqueueFlush(request);
806
+ "function" === typeof iterator.throw &&
807
+ iterator.throw(reason).then(error, error);
808
+ }
809
+ }
810
+ function abortIterable(reason) {
811
+ if (!aborted) {
812
+ aborted = !0;
813
+ request.abortListeners.delete(abortIterable);
814
+ var digest = logRecoverableError(request, reason, streamTask);
815
+ emitErrorChunk(request, streamTask.id, digest);
816
+ enqueueFlush(request);
817
+ "function" === typeof iterator.throw &&
818
+ iterator.throw(reason).then(error, error);
819
+ }
820
+ }
821
+ iterable = iterable === iterator;
822
+ var streamTask = createTask(
823
+ request,
824
+ task.model,
825
+ task.keyPath,
826
+ task.implicitSlot,
827
+ request.abortableTasks
828
+ );
829
+ request.abortableTasks.delete(streamTask);
830
+ request.pendingChunks++;
831
+ task = streamTask.id.toString(16) + ":" + (iterable ? "x" : "X") + "\n";
832
+ request.completedRegularChunks.push(stringToChunk(task));
833
+ var aborted = !1;
834
+ request.abortListeners.add(abortIterable);
835
+ iterator.next().then(progress, error);
836
+ return serializeByValueID(streamTask.id);
837
+ }
838
+ function emitHint(request, code, model) {
839
+ model = stringify(model);
840
+ var id = request.nextChunkId++;
841
+ code = "H" + code;
842
+ code = id.toString(16) + ":" + code;
843
+ model = stringToChunk(code + model + "\n");
844
+ request.completedHintChunks.push(model);
845
+ enqueueFlush(request);
846
+ }
847
+ function readThenable(thenable) {
848
+ if ("fulfilled" === thenable.status) return thenable.value;
849
+ if ("rejected" === thenable.status) throw thenable.reason;
850
+ throw thenable;
851
+ }
852
+ function createLazyWrapperAroundWakeable(wakeable) {
853
+ switch (wakeable.status) {
854
+ case "fulfilled":
855
+ case "rejected":
856
+ break;
857
+ default:
858
+ "string" !== typeof wakeable.status &&
859
+ ((wakeable.status = "pending"),
860
+ wakeable.then(
861
+ function (fulfilledValue) {
862
+ "pending" === wakeable.status &&
863
+ ((wakeable.status = "fulfilled"),
864
+ (wakeable.value = fulfilledValue));
865
+ },
866
+ function (error) {
867
+ "pending" === wakeable.status &&
868
+ ((wakeable.status = "rejected"), (wakeable.reason = error));
869
+ }
870
+ ));
871
+ }
872
+ return { $$typeof: REACT_LAZY_TYPE, _payload: wakeable, _init: readThenable };
873
+ }
874
+ function voidHandler() {}
875
+ function renderFunctionComponent(request, task, key, Component, props) {
876
+ var prevThenableState = task.thenableState;
877
+ task.thenableState = null;
878
+ thenableIndexCounter = 0;
879
+ thenableState = prevThenableState;
880
+ Component = Component(props, void 0);
881
+ if (12 === request.status)
882
+ throw (
883
+ ("object" === typeof Component &&
884
+ null !== Component &&
885
+ "function" === typeof Component.then &&
886
+ Component.$$typeof !== CLIENT_REFERENCE_TAG$1 &&
887
+ Component.then(voidHandler, voidHandler),
888
+ null)
889
+ );
890
+ if (
891
+ "object" === typeof Component &&
892
+ null !== Component &&
893
+ Component.$$typeof !== CLIENT_REFERENCE_TAG$1
894
+ ) {
895
+ if ("function" === typeof Component.then) {
896
+ props = Component;
897
+ if ("fulfilled" === props.status) return props.value;
898
+ Component = createLazyWrapperAroundWakeable(Component);
899
+ }
900
+ var iteratorFn = getIteratorFn(Component);
901
+ if (iteratorFn) {
902
+ var iterableChild = Component;
903
+ Component = {};
904
+ Component =
905
+ ((Component[Symbol.iterator] = function () {
906
+ return iteratorFn.call(iterableChild);
907
+ }),
908
+ Component);
909
+ } else if (
910
+ !(
911
+ "function" !== typeof Component[ASYNC_ITERATOR] ||
912
+ ("function" === typeof ReadableStream &&
913
+ Component instanceof ReadableStream)
914
+ )
915
+ ) {
916
+ var iterableChild$10 = Component;
917
+ Component = {};
918
+ Component =
919
+ ((Component[ASYNC_ITERATOR] = function () {
920
+ return iterableChild$10[ASYNC_ITERATOR]();
921
+ }),
922
+ Component);
923
+ }
924
+ }
925
+ props = task.keyPath;
926
+ prevThenableState = task.implicitSlot;
927
+ null !== key
928
+ ? (task.keyPath = null === props ? key : props + "," + key)
929
+ : null === props && (task.implicitSlot = !0);
930
+ request = renderModelDestructive(request, task, emptyRoot, "", Component);
931
+ task.keyPath = props;
932
+ task.implicitSlot = prevThenableState;
933
+ return request;
934
+ }
935
+ function renderFragment(request, task, children) {
936
+ return null !== task.keyPath
937
+ ? ((request = [
938
+ REACT_ELEMENT_TYPE,
939
+ REACT_FRAGMENT_TYPE,
940
+ task.keyPath,
941
+ { children: children }
942
+ ]),
943
+ task.implicitSlot ? [request] : request)
944
+ : children;
945
+ }
946
+ function renderElement(request, task, type, key, ref, props) {
947
+ if (null !== ref && void 0 !== ref)
948
+ throw Error(
949
+ "Refs cannot be used in Server Components, nor passed to Client Components."
950
+ );
951
+ if (
952
+ "function" === typeof type &&
953
+ type.$$typeof !== CLIENT_REFERENCE_TAG$1 &&
954
+ type.$$typeof !== TEMPORARY_REFERENCE_TAG
955
+ )
956
+ return renderFunctionComponent(request, task, key, type, props);
957
+ if (type === REACT_FRAGMENT_TYPE && null === key)
958
+ return (
959
+ (type = task.implicitSlot),
960
+ null === task.keyPath && (task.implicitSlot = !0),
961
+ (props = renderModelDestructive(
962
+ request,
963
+ task,
964
+ emptyRoot,
965
+ "",
966
+ props.children
967
+ )),
968
+ (task.implicitSlot = type),
969
+ props
970
+ );
971
+ if (
972
+ null != type &&
973
+ "object" === typeof type &&
974
+ type.$$typeof !== CLIENT_REFERENCE_TAG$1
975
+ )
976
+ switch (type.$$typeof) {
977
+ case REACT_LAZY_TYPE:
978
+ var init = type._init;
979
+ type = init(type._payload);
980
+ if (12 === request.status) throw null;
981
+ return renderElement(request, task, type, key, ref, props);
982
+ case REACT_FORWARD_REF_TYPE:
983
+ return renderFunctionComponent(request, task, key, type.render, props);
984
+ case REACT_MEMO_TYPE:
985
+ return renderElement(request, task, type.type, key, ref, props);
986
+ }
987
+ request = key;
988
+ key = task.keyPath;
989
+ null === request
990
+ ? (request = key)
991
+ : null !== key && (request = key + "," + request);
992
+ props = [REACT_ELEMENT_TYPE, type, request, props];
993
+ task = task.implicitSlot && null !== request ? [props] : props;
994
+ return task;
995
+ }
996
+ function pingTask(request, task) {
997
+ var pingedTasks = request.pingedTasks;
998
+ pingedTasks.push(task);
999
+ 1 === pingedTasks.length &&
1000
+ ((request.flushScheduled = null !== request.destination),
1001
+ 21 === request.type || 10 === request.status
1002
+ ? scheduleMicrotask(function () {
1003
+ return performWork(request);
1004
+ })
1005
+ : scheduleWork(function () {
1006
+ return performWork(request);
1007
+ }));
1008
+ }
1009
+ function createTask(request, model, keyPath, implicitSlot, abortSet) {
1010
+ request.pendingChunks++;
1011
+ var id = request.nextChunkId++;
1012
+ "object" !== typeof model ||
1013
+ null === model ||
1014
+ null !== keyPath ||
1015
+ implicitSlot ||
1016
+ request.writtenObjects.set(model, serializeByValueID(id));
1017
+ var task = {
1018
+ id: id,
1019
+ status: 0,
1020
+ model: model,
1021
+ keyPath: keyPath,
1022
+ implicitSlot: implicitSlot,
1023
+ ping: function () {
1024
+ return pingTask(request, task);
1025
+ },
1026
+ toJSON: function (parentPropertyName, value) {
1027
+ var prevKeyPath = task.keyPath,
1028
+ prevImplicitSlot = task.implicitSlot;
1029
+ try {
1030
+ var JSCompiler_inline_result = renderModelDestructive(
1031
+ request,
1032
+ task,
1033
+ this,
1034
+ parentPropertyName,
1035
+ value
1036
+ );
1037
+ } catch (thrownValue) {
1038
+ if (
1039
+ ((parentPropertyName = task.model),
1040
+ (parentPropertyName =
1041
+ "object" === typeof parentPropertyName &&
1042
+ null !== parentPropertyName &&
1043
+ (parentPropertyName.$$typeof === REACT_ELEMENT_TYPE ||
1044
+ parentPropertyName.$$typeof === REACT_LAZY_TYPE)),
1045
+ 12 === request.status)
1046
+ )
1047
+ (task.status = 3),
1048
+ (prevKeyPath = request.fatalError),
1049
+ (JSCompiler_inline_result = parentPropertyName
1050
+ ? "$L" + prevKeyPath.toString(16)
1051
+ : serializeByValueID(prevKeyPath));
1052
+ else if (
1053
+ ((value =
1054
+ thrownValue === SuspenseException
1055
+ ? getSuspendedThenable()
1056
+ : thrownValue),
1057
+ "object" === typeof value &&
1058
+ null !== value &&
1059
+ "function" === typeof value.then)
1060
+ ) {
1061
+ JSCompiler_inline_result = createTask(
1062
+ request,
1063
+ task.model,
1064
+ task.keyPath,
1065
+ task.implicitSlot,
1066
+ request.abortableTasks
1067
+ );
1068
+ var ping = JSCompiler_inline_result.ping;
1069
+ value.then(ping, ping);
1070
+ JSCompiler_inline_result.thenableState =
1071
+ getThenableStateAfterSuspending();
1072
+ task.keyPath = prevKeyPath;
1073
+ task.implicitSlot = prevImplicitSlot;
1074
+ JSCompiler_inline_result = parentPropertyName
1075
+ ? "$L" + JSCompiler_inline_result.id.toString(16)
1076
+ : serializeByValueID(JSCompiler_inline_result.id);
1077
+ } else
1078
+ (task.keyPath = prevKeyPath),
1079
+ (task.implicitSlot = prevImplicitSlot),
1080
+ request.pendingChunks++,
1081
+ (prevKeyPath = request.nextChunkId++),
1082
+ (prevImplicitSlot = logRecoverableError(request, value, task)),
1083
+ emitErrorChunk(request, prevKeyPath, prevImplicitSlot),
1084
+ (JSCompiler_inline_result = parentPropertyName
1085
+ ? "$L" + prevKeyPath.toString(16)
1086
+ : serializeByValueID(prevKeyPath));
1087
+ }
1088
+ return JSCompiler_inline_result;
1089
+ },
1090
+ thenableState: null
1091
+ };
1092
+ abortSet.add(task);
1093
+ return task;
1094
+ }
1095
+ function serializeByValueID(id) {
1096
+ return "$" + id.toString(16);
1097
+ }
1098
+ function encodeReferenceChunk(request, id, reference) {
1099
+ request = stringify(reference);
1100
+ id = id.toString(16) + ":" + request + "\n";
1101
+ return stringToChunk(id);
1102
+ }
1103
+ function serializeClientReference(
1104
+ request,
1105
+ parent,
1106
+ parentPropertyName,
1107
+ clientReference
1108
+ ) {
1109
+ var clientReferenceKey = clientReference.$$id + "#" + clientReference.$$name,
1110
+ writtenClientReferences = request.writtenClientReferences,
1111
+ existingId = writtenClientReferences.get(clientReferenceKey);
1112
+ if (void 0 !== existingId)
1113
+ return parent[0] === REACT_ELEMENT_TYPE && "1" === parentPropertyName
1114
+ ? "$L" + existingId.toString(16)
1115
+ : serializeByValueID(existingId);
1116
+ try {
1117
+ var clientReferenceMetadata = [
1118
+ clientReference.$$id,
1119
+ clientReference.$$name,
1120
+ clientReference.$$bundles
1121
+ ];
1122
+ request.pendingChunks++;
1123
+ var importId = request.nextChunkId++,
1124
+ json = stringify(clientReferenceMetadata),
1125
+ row = importId.toString(16) + ":I" + json + "\n",
1126
+ processedChunk = stringToChunk(row);
1127
+ request.completedImportChunks.push(processedChunk);
1128
+ writtenClientReferences.set(clientReferenceKey, importId);
1129
+ return parent[0] === REACT_ELEMENT_TYPE && "1" === parentPropertyName
1130
+ ? "$L" + importId.toString(16)
1131
+ : serializeByValueID(importId);
1132
+ } catch (x) {
1133
+ return (
1134
+ request.pendingChunks++,
1135
+ (parent = request.nextChunkId++),
1136
+ (parentPropertyName = logRecoverableError(request, x, null)),
1137
+ emitErrorChunk(request, parent, parentPropertyName),
1138
+ serializeByValueID(parent)
1139
+ );
1140
+ }
1141
+ }
1142
+ function outlineModel(request, value) {
1143
+ value = createTask(request, value, null, !1, request.abortableTasks);
1144
+ retryTask(request, value);
1145
+ return value.id;
1146
+ }
1147
+ function serializeTypedArray(request, tag, typedArray) {
1148
+ request.pendingChunks++;
1149
+ var bufferId = request.nextChunkId++;
1150
+ emitTypedArrayChunk(request, bufferId, tag, typedArray);
1151
+ return serializeByValueID(bufferId);
1152
+ }
1153
+ function serializeBlob(request, blob) {
1154
+ function progress(entry) {
1155
+ if (!aborted)
1156
+ if (entry.done)
1157
+ request.abortListeners.delete(abortBlob),
1158
+ (aborted = !0),
1159
+ pingTask(request, newTask);
1160
+ else
1161
+ return (
1162
+ model.push(entry.value), reader.read().then(progress).catch(error)
1163
+ );
1164
+ }
1165
+ function error(reason) {
1166
+ if (!aborted) {
1167
+ aborted = !0;
1168
+ request.abortListeners.delete(abortBlob);
1169
+ var digest = logRecoverableError(request, reason, newTask);
1170
+ emitErrorChunk(request, newTask.id, digest);
1171
+ enqueueFlush(request);
1172
+ reader.cancel(reason).then(error, error);
1173
+ }
1174
+ }
1175
+ function abortBlob(reason) {
1176
+ if (!aborted) {
1177
+ aborted = !0;
1178
+ request.abortListeners.delete(abortBlob);
1179
+ var digest = logRecoverableError(request, reason, newTask);
1180
+ emitErrorChunk(request, newTask.id, digest);
1181
+ enqueueFlush(request);
1182
+ reader.cancel(reason).then(error, error);
1183
+ }
1184
+ }
1185
+ var model = [blob.type],
1186
+ newTask = createTask(request, model, null, !1, request.abortableTasks),
1187
+ reader = blob.stream().getReader(),
1188
+ aborted = !1;
1189
+ request.abortListeners.add(abortBlob);
1190
+ reader.read().then(progress).catch(error);
1191
+ return "$B" + newTask.id.toString(16);
1192
+ }
1193
+ var modelRoot = !1;
1194
+ function renderModelDestructive(
1195
+ request,
1196
+ task,
1197
+ parent,
1198
+ parentPropertyName,
1199
+ value
1200
+ ) {
1201
+ task.model = value;
1202
+ if (value === REACT_ELEMENT_TYPE) return "$";
1203
+ if (null === value) return null;
1204
+ if ("object" === typeof value) {
1205
+ switch (value.$$typeof) {
1206
+ case REACT_ELEMENT_TYPE:
1207
+ var elementReference = null,
1208
+ writtenObjects = request.writtenObjects;
1209
+ if (null === task.keyPath && !task.implicitSlot) {
1210
+ var existingReference = writtenObjects.get(value);
1211
+ if (void 0 !== existingReference)
1212
+ if (modelRoot === value) modelRoot = null;
1213
+ else return existingReference;
1214
+ else
1215
+ -1 === parentPropertyName.indexOf(":") &&
1216
+ ((parent = writtenObjects.get(parent)),
1217
+ void 0 !== parent &&
1218
+ ((elementReference = parent + ":" + parentPropertyName),
1219
+ writtenObjects.set(value, elementReference)));
1220
+ }
1221
+ parentPropertyName = value.props;
1222
+ parent = parentPropertyName.ref;
1223
+ request = renderElement(
1224
+ request,
1225
+ task,
1226
+ value.type,
1227
+ value.key,
1228
+ void 0 !== parent ? parent : null,
1229
+ parentPropertyName
1230
+ );
1231
+ "object" === typeof request &&
1232
+ null !== request &&
1233
+ null !== elementReference &&
1234
+ (writtenObjects.has(request) ||
1235
+ writtenObjects.set(request, elementReference));
1236
+ return request;
1237
+ case REACT_LAZY_TYPE:
1238
+ task.thenableState = null;
1239
+ parentPropertyName = value._init;
1240
+ value = parentPropertyName(value._payload);
1241
+ if (12 === request.status) throw null;
1242
+ return renderModelDestructive(request, task, emptyRoot, "", value);
1243
+ case REACT_LEGACY_ELEMENT_TYPE:
1244
+ throw Error(
1245
+ 'A React Element from an older version of React was rendered. This is not supported. It can happen if:\n- Multiple copies of the "react" package is used.\n- A library pre-bundled an old copy of "react" or "react/jsx-runtime".\n- A compiler tries to "inline" JSX instead of using the runtime.'
1246
+ );
1247
+ }
1248
+ if (value.$$typeof === CLIENT_REFERENCE_TAG$1)
1249
+ return serializeClientReference(
1250
+ request,
1251
+ parent,
1252
+ parentPropertyName,
1253
+ value
1254
+ );
1255
+ if (
1256
+ void 0 !== request.temporaryReferences &&
1257
+ ((elementReference = request.temporaryReferences.get(value)),
1258
+ void 0 !== elementReference)
1259
+ )
1260
+ return "$T" + elementReference;
1261
+ elementReference = request.writtenObjects;
1262
+ writtenObjects = elementReference.get(value);
1263
+ if ("function" === typeof value.then) {
1264
+ if (void 0 !== writtenObjects) {
1265
+ if (null !== task.keyPath || task.implicitSlot)
1266
+ return "$@" + serializeThenable(request, task, value).toString(16);
1267
+ if (modelRoot === value) modelRoot = null;
1268
+ else return writtenObjects;
1269
+ }
1270
+ request = "$@" + serializeThenable(request, task, value).toString(16);
1271
+ elementReference.set(value, request);
1272
+ return request;
1273
+ }
1274
+ if (void 0 !== writtenObjects)
1275
+ if (modelRoot === value) modelRoot = null;
1276
+ else return writtenObjects;
1277
+ else if (
1278
+ -1 === parentPropertyName.indexOf(":") &&
1279
+ ((writtenObjects = elementReference.get(parent)),
1280
+ void 0 !== writtenObjects)
1281
+ ) {
1282
+ existingReference = parentPropertyName;
1283
+ if (isArrayImpl(parent) && parent[0] === REACT_ELEMENT_TYPE)
1284
+ switch (parentPropertyName) {
1285
+ case "1":
1286
+ existingReference = "type";
1287
+ break;
1288
+ case "2":
1289
+ existingReference = "key";
1290
+ break;
1291
+ case "3":
1292
+ existingReference = "props";
1293
+ break;
1294
+ case "4":
1295
+ existingReference = "_owner";
1296
+ }
1297
+ elementReference.set(value, writtenObjects + ":" + existingReference);
1298
+ }
1299
+ if (isArrayImpl(value)) return renderFragment(request, task, value);
1300
+ if (value instanceof Map)
1301
+ return (
1302
+ (value = Array.from(value)),
1303
+ "$Q" + outlineModel(request, value).toString(16)
1304
+ );
1305
+ if (value instanceof Set)
1306
+ return (
1307
+ (value = Array.from(value)),
1308
+ "$W" + outlineModel(request, value).toString(16)
1309
+ );
1310
+ if ("function" === typeof FormData && value instanceof FormData)
1311
+ return (
1312
+ (value = Array.from(value.entries())),
1313
+ "$K" + outlineModel(request, value).toString(16)
1314
+ );
1315
+ if (value instanceof Error) return "$Z";
1316
+ if (value instanceof ArrayBuffer)
1317
+ return serializeTypedArray(request, "A", new Uint8Array(value));
1318
+ if (value instanceof Int8Array)
1319
+ return serializeTypedArray(request, "O", value);
1320
+ if (value instanceof Uint8Array)
1321
+ return serializeTypedArray(request, "o", value);
1322
+ if (value instanceof Uint8ClampedArray)
1323
+ return serializeTypedArray(request, "U", value);
1324
+ if (value instanceof Int16Array)
1325
+ return serializeTypedArray(request, "S", value);
1326
+ if (value instanceof Uint16Array)
1327
+ return serializeTypedArray(request, "s", value);
1328
+ if (value instanceof Int32Array)
1329
+ return serializeTypedArray(request, "L", value);
1330
+ if (value instanceof Uint32Array)
1331
+ return serializeTypedArray(request, "l", value);
1332
+ if (value instanceof Float32Array)
1333
+ return serializeTypedArray(request, "G", value);
1334
+ if (value instanceof Float64Array)
1335
+ return serializeTypedArray(request, "g", value);
1336
+ if (value instanceof BigInt64Array)
1337
+ return serializeTypedArray(request, "M", value);
1338
+ if (value instanceof BigUint64Array)
1339
+ return serializeTypedArray(request, "m", value);
1340
+ if (value instanceof DataView)
1341
+ return serializeTypedArray(request, "V", value);
1342
+ if ("function" === typeof Blob && value instanceof Blob)
1343
+ return serializeBlob(request, value);
1344
+ if ((elementReference = getIteratorFn(value)))
1345
+ return (
1346
+ (parentPropertyName = elementReference.call(value)),
1347
+ parentPropertyName === value
1348
+ ? "$i" +
1349
+ outlineModel(request, Array.from(parentPropertyName)).toString(16)
1350
+ : renderFragment(request, task, Array.from(parentPropertyName))
1351
+ );
1352
+ if ("function" === typeof ReadableStream && value instanceof ReadableStream)
1353
+ return serializeReadableStream(request, task, value);
1354
+ elementReference = value[ASYNC_ITERATOR];
1355
+ if ("function" === typeof elementReference)
1356
+ return (
1357
+ null !== task.keyPath
1358
+ ? ((request = [
1359
+ REACT_ELEMENT_TYPE,
1360
+ REACT_FRAGMENT_TYPE,
1361
+ task.keyPath,
1362
+ { children: value }
1363
+ ]),
1364
+ (request = task.implicitSlot ? [request] : request))
1365
+ : ((parentPropertyName = elementReference.call(value)),
1366
+ (request = serializeAsyncIterable(
1367
+ request,
1368
+ task,
1369
+ value,
1370
+ parentPropertyName
1371
+ ))),
1372
+ request
1373
+ );
1374
+ if (value instanceof Date) return "$D" + value.toJSON();
1375
+ request = getPrototypeOf(value);
1376
+ if (
1377
+ request !== ObjectPrototype &&
1378
+ (null === request || null !== getPrototypeOf(request))
1379
+ )
1380
+ throw Error(
1381
+ "Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported." +
1382
+ describeObjectForErrorMessage(parent, parentPropertyName)
1383
+ );
1384
+ return value;
1385
+ }
1386
+ if ("string" === typeof value) {
1387
+ if (
1388
+ "Z" === value[value.length - 1] &&
1389
+ parent[parentPropertyName] instanceof Date
1390
+ )
1391
+ return "$D" + value;
1392
+ if (1024 <= value.length && null !== byteLengthOfChunk)
1393
+ return (
1394
+ request.pendingChunks++,
1395
+ (task = request.nextChunkId++),
1396
+ emitTextChunk(request, task, value),
1397
+ serializeByValueID(task)
1398
+ );
1399
+ request = "$" === value[0] ? "$" + value : value;
1400
+ return request;
1401
+ }
1402
+ if ("boolean" === typeof value) return value;
1403
+ if ("number" === typeof value)
1404
+ return Number.isFinite(value)
1405
+ ? 0 === value && -Infinity === 1 / value
1406
+ ? "$-0"
1407
+ : value
1408
+ : Infinity === value
1409
+ ? "$Infinity"
1410
+ : -Infinity === value
1411
+ ? "$-Infinity"
1412
+ : "$NaN";
1413
+ if ("undefined" === typeof value) return "$undefined";
1414
+ if ("function" === typeof value) {
1415
+ if (value.$$typeof === CLIENT_REFERENCE_TAG$1)
1416
+ return serializeClientReference(
1417
+ request,
1418
+ parent,
1419
+ parentPropertyName,
1420
+ value
1421
+ );
1422
+ if (value.$$typeof === SERVER_REFERENCE_TAG)
1423
+ return (
1424
+ (task = request.writtenServerReferences),
1425
+ (parentPropertyName = task.get(value)),
1426
+ void 0 !== parentPropertyName
1427
+ ? (request = "$F" + parentPropertyName.toString(16))
1428
+ : ((parentPropertyName = value.$$bound),
1429
+ (parentPropertyName =
1430
+ null === parentPropertyName
1431
+ ? null
1432
+ : Promise.resolve(parentPropertyName)),
1433
+ (request = outlineModel(request, {
1434
+ id: value.$$id,
1435
+ bound: parentPropertyName
1436
+ })),
1437
+ task.set(value, request),
1438
+ (request = "$F" + request.toString(16))),
1439
+ request
1440
+ );
1441
+ if (
1442
+ void 0 !== request.temporaryReferences &&
1443
+ ((request = request.temporaryReferences.get(value)), void 0 !== request)
1444
+ )
1445
+ return "$T" + request;
1446
+ if (value.$$typeof === TEMPORARY_REFERENCE_TAG)
1447
+ throw Error(
1448
+ "Could not reference an opaque temporary reference. This is likely due to misconfiguring the temporaryReferences options on the server."
1449
+ );
1450
+ if (/^on[A-Z]/.test(parentPropertyName))
1451
+ throw Error(
1452
+ "Event handlers cannot be passed to Client Component props." +
1453
+ describeObjectForErrorMessage(parent, parentPropertyName) +
1454
+ "\nIf you need interactivity, consider converting part of this to a Client Component."
1455
+ );
1456
+ throw Error(
1457
+ 'Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server". Or maybe you meant to call this function rather than return it.' +
1458
+ describeObjectForErrorMessage(parent, parentPropertyName)
1459
+ );
1460
+ }
1461
+ if ("symbol" === typeof value) {
1462
+ task = request.writtenSymbols;
1463
+ elementReference = task.get(value);
1464
+ if (void 0 !== elementReference)
1465
+ return serializeByValueID(elementReference);
1466
+ elementReference = value.description;
1467
+ if (Symbol.for(elementReference) !== value)
1468
+ throw Error(
1469
+ "Only global symbols received from Symbol.for(...) can be passed to Client Components. The symbol Symbol.for(" +
1470
+ (value.description + ") cannot be found among global symbols.") +
1471
+ describeObjectForErrorMessage(parent, parentPropertyName)
1472
+ );
1473
+ request.pendingChunks++;
1474
+ parentPropertyName = request.nextChunkId++;
1475
+ parent = encodeReferenceChunk(
1476
+ request,
1477
+ parentPropertyName,
1478
+ "$S" + elementReference
1479
+ );
1480
+ request.completedImportChunks.push(parent);
1481
+ task.set(value, parentPropertyName);
1482
+ return serializeByValueID(parentPropertyName);
1483
+ }
1484
+ if ("bigint" === typeof value) return "$n" + value.toString(10);
1485
+ throw Error(
1486
+ "Type " +
1487
+ typeof value +
1488
+ " is not supported in Client Component props." +
1489
+ describeObjectForErrorMessage(parent, parentPropertyName)
1490
+ );
1491
+ }
1492
+ function logRecoverableError(request, error) {
1493
+ var prevRequest = currentRequest;
1494
+ currentRequest = null;
1495
+ try {
1496
+ var onError = request.onError;
1497
+ var errorDigest = onError(error);
1498
+ } finally {
1499
+ currentRequest = prevRequest;
1500
+ }
1501
+ if (null != errorDigest && "string" !== typeof errorDigest)
1502
+ throw Error(
1503
+ 'onError returned something with a type other than "string". onError should return a string and may return null or undefined but must not return anything else. It received something of type "' +
1504
+ typeof errorDigest +
1505
+ '" instead'
1506
+ );
1507
+ return errorDigest || "";
1508
+ }
1509
+ function fatalError(request, error) {
1510
+ var onFatalError = request.onFatalError;
1511
+ onFatalError(error);
1512
+ null !== request.destination
1513
+ ? ((request.status = 14), closeWithError(request.destination, error))
1514
+ : ((request.status = 13), (request.fatalError = error));
1515
+ }
1516
+ function emitErrorChunk(request, id, digest) {
1517
+ digest = { digest: digest };
1518
+ id = id.toString(16) + ":E" + stringify(digest) + "\n";
1519
+ id = stringToChunk(id);
1520
+ request.completedErrorChunks.push(id);
1521
+ }
1522
+ function emitModelChunk(request, id, json) {
1523
+ id = id.toString(16) + ":" + json + "\n";
1524
+ id = stringToChunk(id);
1525
+ request.completedRegularChunks.push(id);
1526
+ }
1527
+ function emitTypedArrayChunk(request, id, tag, typedArray) {
1528
+ request.pendingChunks++;
1529
+ var buffer = new Uint8Array(
1530
+ typedArray.buffer,
1531
+ typedArray.byteOffset,
1532
+ typedArray.byteLength
1533
+ );
1534
+ typedArray = 2048 < typedArray.byteLength ? buffer.slice() : buffer;
1535
+ buffer = typedArray.byteLength;
1536
+ id = id.toString(16) + ":" + tag + buffer.toString(16) + ",";
1537
+ id = stringToChunk(id);
1538
+ request.completedRegularChunks.push(id, typedArray);
1539
+ }
1540
+ function emitTextChunk(request, id, text) {
1541
+ if (null === byteLengthOfChunk)
1542
+ throw Error(
1543
+ "Existence of byteLengthOfChunk should have already been checked. This is a bug in React."
1544
+ );
1545
+ request.pendingChunks++;
1546
+ text = stringToChunk(text);
1547
+ var binaryLength = text.byteLength;
1548
+ id = id.toString(16) + ":T" + binaryLength.toString(16) + ",";
1549
+ id = stringToChunk(id);
1550
+ request.completedRegularChunks.push(id, text);
1551
+ }
1552
+ function emitChunk(request, task, value) {
1553
+ var id = task.id;
1554
+ "string" === typeof value && null !== byteLengthOfChunk
1555
+ ? emitTextChunk(request, id, value)
1556
+ : value instanceof ArrayBuffer
1557
+ ? emitTypedArrayChunk(request, id, "A", new Uint8Array(value))
1558
+ : value instanceof Int8Array
1559
+ ? emitTypedArrayChunk(request, id, "O", value)
1560
+ : value instanceof Uint8Array
1561
+ ? emitTypedArrayChunk(request, id, "o", value)
1562
+ : value instanceof Uint8ClampedArray
1563
+ ? emitTypedArrayChunk(request, id, "U", value)
1564
+ : value instanceof Int16Array
1565
+ ? emitTypedArrayChunk(request, id, "S", value)
1566
+ : value instanceof Uint16Array
1567
+ ? emitTypedArrayChunk(request, id, "s", value)
1568
+ : value instanceof Int32Array
1569
+ ? emitTypedArrayChunk(request, id, "L", value)
1570
+ : value instanceof Uint32Array
1571
+ ? emitTypedArrayChunk(request, id, "l", value)
1572
+ : value instanceof Float32Array
1573
+ ? emitTypedArrayChunk(request, id, "G", value)
1574
+ : value instanceof Float64Array
1575
+ ? emitTypedArrayChunk(request, id, "g", value)
1576
+ : value instanceof BigInt64Array
1577
+ ? emitTypedArrayChunk(request, id, "M", value)
1578
+ : value instanceof BigUint64Array
1579
+ ? emitTypedArrayChunk(request, id, "m", value)
1580
+ : value instanceof DataView
1581
+ ? emitTypedArrayChunk(request, id, "V", value)
1582
+ : ((value = stringify(value, task.toJSON)),
1583
+ emitModelChunk(request, task.id, value));
1584
+ }
1585
+ var emptyRoot = {};
1586
+ function retryTask(request, task) {
1587
+ if (0 === task.status) {
1588
+ task.status = 5;
1589
+ try {
1590
+ modelRoot = task.model;
1591
+ var resolvedModel = renderModelDestructive(
1592
+ request,
1593
+ task,
1594
+ emptyRoot,
1595
+ "",
1596
+ task.model
1597
+ );
1598
+ modelRoot = resolvedModel;
1599
+ task.keyPath = null;
1600
+ task.implicitSlot = !1;
1601
+ if ("object" === typeof resolvedModel && null !== resolvedModel)
1602
+ request.writtenObjects.set(resolvedModel, serializeByValueID(task.id)),
1603
+ emitChunk(request, task, resolvedModel);
1604
+ else {
1605
+ var json = stringify(resolvedModel);
1606
+ emitModelChunk(request, task.id, json);
1607
+ }
1608
+ request.abortableTasks.delete(task);
1609
+ task.status = 1;
1610
+ } catch (thrownValue) {
1611
+ if (12 === request.status) {
1612
+ request.abortableTasks.delete(task);
1613
+ task.status = 3;
1614
+ var model = stringify(serializeByValueID(request.fatalError));
1615
+ emitModelChunk(request, task.id, model);
1616
+ } else {
1617
+ var x =
1618
+ thrownValue === SuspenseException
1619
+ ? getSuspendedThenable()
1620
+ : thrownValue;
1621
+ if (
1622
+ "object" === typeof x &&
1623
+ null !== x &&
1624
+ "function" === typeof x.then
1625
+ ) {
1626
+ task.status = 0;
1627
+ task.thenableState = getThenableStateAfterSuspending();
1628
+ var ping = task.ping;
1629
+ x.then(ping, ping);
1630
+ } else {
1631
+ request.abortableTasks.delete(task);
1632
+ task.status = 4;
1633
+ var digest = logRecoverableError(request, x, task);
1634
+ emitErrorChunk(request, task.id, digest);
1635
+ }
1636
+ }
1637
+ } finally {
1638
+ }
1639
+ }
1640
+ }
1641
+ function performWork(request) {
1642
+ var prevDispatcher = ReactSharedInternalsServer.H;
1643
+ ReactSharedInternalsServer.H = HooksDispatcher;
1644
+ var prevRequest = currentRequest;
1645
+ currentRequest$1 = currentRequest = request;
1646
+ var hadAbortableTasks = 0 < request.abortableTasks.size;
1647
+ try {
1648
+ var pingedTasks = request.pingedTasks;
1649
+ request.pingedTasks = [];
1650
+ for (var i = 0; i < pingedTasks.length; i++)
1651
+ retryTask(request, pingedTasks[i]);
1652
+ null !== request.destination &&
1653
+ flushCompletedChunks(request, request.destination);
1654
+ if (hadAbortableTasks && 0 === request.abortableTasks.size) {
1655
+ var onAllReady = request.onAllReady;
1656
+ onAllReady();
1657
+ }
1658
+ } catch (error) {
1659
+ logRecoverableError(request, error, null), fatalError(request, error);
1660
+ } finally {
1661
+ (ReactSharedInternalsServer.H = prevDispatcher),
1662
+ (currentRequest$1 = null),
1663
+ (currentRequest = prevRequest);
1664
+ }
1665
+ }
1666
+ function flushCompletedChunks(request, destination) {
1667
+ currentView = new Uint8Array(2048);
1668
+ writtenBytes = 0;
1669
+ try {
1670
+ for (
1671
+ var importsChunks = request.completedImportChunks, i = 0;
1672
+ i < importsChunks.length;
1673
+ i++
1674
+ )
1675
+ request.pendingChunks--,
1676
+ writeChunkAndReturn(destination, importsChunks[i]);
1677
+ importsChunks.splice(0, i);
1678
+ var hintChunks = request.completedHintChunks;
1679
+ for (i = 0; i < hintChunks.length; i++)
1680
+ writeChunkAndReturn(destination, hintChunks[i]);
1681
+ hintChunks.splice(0, i);
1682
+ var regularChunks = request.completedRegularChunks;
1683
+ for (i = 0; i < regularChunks.length; i++)
1684
+ request.pendingChunks--,
1685
+ writeChunkAndReturn(destination, regularChunks[i]);
1686
+ regularChunks.splice(0, i);
1687
+ var errorChunks = request.completedErrorChunks;
1688
+ for (i = 0; i < errorChunks.length; i++)
1689
+ request.pendingChunks--, writeChunkAndReturn(destination, errorChunks[i]);
1690
+ errorChunks.splice(0, i);
1691
+ } finally {
1692
+ (request.flushScheduled = !1),
1693
+ currentView &&
1694
+ 0 < writtenBytes &&
1695
+ (destination.enqueue(
1696
+ new Uint8Array(currentView.buffer, 0, writtenBytes)
1697
+ ),
1698
+ (currentView = null),
1699
+ (writtenBytes = 0));
1700
+ }
1701
+ 0 === request.pendingChunks &&
1702
+ ((request.status = 14), destination.close(), (request.destination = null));
1703
+ }
1704
+ function startWork(request) {
1705
+ request.flushScheduled = null !== request.destination;
1706
+ scheduleMicrotask(function () {
1707
+ return performWork(request);
1708
+ });
1709
+ scheduleWork(function () {
1710
+ 10 === request.status && (request.status = 11);
1711
+ });
1712
+ }
1713
+ function enqueueFlush(request) {
1714
+ !1 === request.flushScheduled &&
1715
+ 0 === request.pingedTasks.length &&
1716
+ null !== request.destination &&
1717
+ ((request.flushScheduled = !0),
1718
+ scheduleWork(function () {
1719
+ request.flushScheduled = !1;
1720
+ var destination = request.destination;
1721
+ destination && flushCompletedChunks(request, destination);
1722
+ }));
1723
+ }
1724
+ function abort(request, reason) {
1725
+ try {
1726
+ 11 >= request.status && (request.status = 12);
1727
+ var abortableTasks = request.abortableTasks;
1728
+ if (0 < abortableTasks.size) {
1729
+ var error =
1730
+ void 0 === reason
1731
+ ? Error("The render was aborted by the server without a reason.")
1732
+ : "object" === typeof reason &&
1733
+ null !== reason &&
1734
+ "function" === typeof reason.then
1735
+ ? Error("The render was aborted by the server with a promise.")
1736
+ : reason,
1737
+ digest = logRecoverableError(request, error, null),
1738
+ errorId = request.nextChunkId++;
1739
+ request.fatalError = errorId;
1740
+ request.pendingChunks++;
1741
+ emitErrorChunk(request, errorId, digest, error);
1742
+ abortableTasks.forEach(function (task) {
1743
+ if (5 !== task.status) {
1744
+ task.status = 3;
1745
+ var ref = serializeByValueID(errorId);
1746
+ task = encodeReferenceChunk(request, task.id, ref);
1747
+ request.completedErrorChunks.push(task);
1748
+ }
1749
+ });
1750
+ abortableTasks.clear();
1751
+ var onAllReady = request.onAllReady;
1752
+ onAllReady();
1753
+ }
1754
+ var abortListeners = request.abortListeners;
1755
+ if (0 < abortListeners.size) {
1756
+ var error$23 =
1757
+ void 0 === reason
1758
+ ? Error("The render was aborted by the server without a reason.")
1759
+ : "object" === typeof reason &&
1760
+ null !== reason &&
1761
+ "function" === typeof reason.then
1762
+ ? Error("The render was aborted by the server with a promise.")
1763
+ : reason;
1764
+ abortListeners.forEach(function (callback) {
1765
+ return callback(error$23);
1766
+ });
1767
+ abortListeners.clear();
1768
+ }
1769
+ null !== request.destination &&
1770
+ flushCompletedChunks(request, request.destination);
1771
+ } catch (error$24) {
1772
+ logRecoverableError(request, error$24, null), fatalError(request, error$24);
1773
+ }
1774
+ }
1775
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
1776
+ function Chunk(status, value, reason, response) {
1777
+ this.status = status;
1778
+ this.value = value;
1779
+ this.reason = reason;
1780
+ this._response = response;
1781
+ }
1782
+ Chunk.prototype = Object.create(Promise.prototype);
1783
+ Chunk.prototype.then = function (resolve, reject) {
1784
+ switch (this.status) {
1785
+ case "resolved_model":
1786
+ initializeModelChunk(this);
1787
+ }
1788
+ switch (this.status) {
1789
+ case "fulfilled":
1790
+ resolve(this.value);
1791
+ break;
1792
+ case "pending":
1793
+ case "blocked":
1794
+ case "cyclic":
1795
+ resolve &&
1796
+ (null === this.value && (this.value = []), this.value.push(resolve));
1797
+ reject &&
1798
+ (null === this.reason && (this.reason = []), this.reason.push(reject));
1799
+ break;
1800
+ default:
1801
+ reject(this.reason);
1802
+ }
1803
+ };
1804
+ function createPendingChunk(response) {
1805
+ return new Chunk("pending", null, null, response);
1806
+ }
1807
+ function wakeChunk(listeners, value) {
1808
+ for (var i = 0; i < listeners.length; i++) (0, listeners[i])(value);
1809
+ }
1810
+ function triggerErrorOnChunk(chunk, error) {
1811
+ if ("pending" !== chunk.status && "blocked" !== chunk.status)
1812
+ chunk.reason.error(error);
1813
+ else {
1814
+ var listeners = chunk.reason;
1815
+ chunk.status = "rejected";
1816
+ chunk.reason = error;
1817
+ null !== listeners && wakeChunk(listeners, error);
1818
+ }
1819
+ }
1820
+ function resolveModelChunk(chunk, value, id) {
1821
+ if ("pending" !== chunk.status)
1822
+ (chunk = chunk.reason),
1823
+ "C" === value[0]
1824
+ ? chunk.close("C" === value ? '"$undefined"' : value.slice(1))
1825
+ : chunk.enqueueModel(value);
1826
+ else {
1827
+ var resolveListeners = chunk.value,
1828
+ rejectListeners = chunk.reason;
1829
+ chunk.status = "resolved_model";
1830
+ chunk.value = value;
1831
+ chunk.reason = id;
1832
+ if (null !== resolveListeners)
1833
+ switch ((initializeModelChunk(chunk), chunk.status)) {
1834
+ case "fulfilled":
1835
+ wakeChunk(resolveListeners, chunk.value);
1836
+ break;
1837
+ case "pending":
1838
+ case "blocked":
1839
+ case "cyclic":
1840
+ if (chunk.value)
1841
+ for (value = 0; value < resolveListeners.length; value++)
1842
+ chunk.value.push(resolveListeners[value]);
1843
+ else chunk.value = resolveListeners;
1844
+ if (chunk.reason) {
1845
+ if (rejectListeners)
1846
+ for (value = 0; value < rejectListeners.length; value++)
1847
+ chunk.reason.push(rejectListeners[value]);
1848
+ } else chunk.reason = rejectListeners;
1849
+ break;
1850
+ case "rejected":
1851
+ rejectListeners && wakeChunk(rejectListeners, chunk.reason);
1852
+ }
1853
+ }
1854
+ }
1855
+ function createResolvedIteratorResultChunk(response, value, done) {
1856
+ return new Chunk(
1857
+ "resolved_model",
1858
+ (done ? '{"done":true,"value":' : '{"done":false,"value":') + value + "}",
1859
+ -1,
1860
+ response
1861
+ );
1862
+ }
1863
+ function resolveIteratorResultChunk(chunk, value, done) {
1864
+ resolveModelChunk(
1865
+ chunk,
1866
+ (done ? '{"done":true,"value":' : '{"done":false,"value":') + value + "}",
1867
+ -1
1868
+ );
1869
+ }
1870
+ function loadServerReference$1(
1871
+ response,
1872
+ id,
1873
+ bound,
1874
+ parentChunk,
1875
+ parentObject,
1876
+ key
1877
+ ) {
1878
+ var serverReference = resolveServerReference(response._bundlerConfig, id);
1879
+ id = preloadModule$1(serverReference);
1880
+ if (bound)
1881
+ bound = Promise.all([bound, id]).then(function (_ref) {
1882
+ _ref = _ref[0];
1883
+ var fn = requireModule(serverReference);
1884
+ return fn.bind.apply(fn, [null].concat(_ref));
1885
+ });
1886
+ else if (id)
1887
+ bound = Promise.resolve(id).then(function () {
1888
+ return requireModule(serverReference);
1889
+ });
1890
+ else return requireModule(serverReference);
1891
+ bound.then(
1892
+ createModelResolver(
1893
+ parentChunk,
1894
+ parentObject,
1895
+ key,
1896
+ !1,
1897
+ response,
1898
+ createModel,
1899
+ []
1900
+ ),
1901
+ createModelReject(parentChunk)
1902
+ );
1903
+ return null;
1904
+ }
1905
+ function reviveModel(response, parentObj, parentKey, value, reference) {
1906
+ if ("string" === typeof value)
1907
+ return parseModelString(response, parentObj, parentKey, value, reference);
1908
+ if ("object" === typeof value && null !== value)
1909
+ if (
1910
+ (void 0 !== reference &&
1911
+ void 0 !== response._temporaryReferences &&
1912
+ response._temporaryReferences.set(value, reference),
1913
+ Array.isArray(value))
1914
+ )
1915
+ for (var i = 0; i < value.length; i++)
1916
+ value[i] = reviveModel(
1917
+ response,
1918
+ value,
1919
+ "" + i,
1920
+ value[i],
1921
+ void 0 !== reference ? reference + ":" + i : void 0
1922
+ );
1923
+ else
1924
+ for (i in value)
1925
+ hasOwnProperty.call(value, i) &&
1926
+ ((parentObj =
1927
+ void 0 !== reference && -1 === i.indexOf(":")
1928
+ ? reference + ":" + i
1929
+ : void 0),
1930
+ (parentObj = reviveModel(response, value, i, value[i], parentObj)),
1931
+ void 0 !== parentObj ? (value[i] = parentObj) : delete value[i]);
1932
+ return value;
1933
+ }
1934
+ var initializingChunk = null,
1935
+ initializingChunkBlockedModel = null;
1936
+ function initializeModelChunk(chunk) {
1937
+ var prevChunk = initializingChunk,
1938
+ prevBlocked = initializingChunkBlockedModel;
1939
+ initializingChunk = chunk;
1940
+ initializingChunkBlockedModel = null;
1941
+ var rootReference = -1 === chunk.reason ? void 0 : chunk.reason.toString(16),
1942
+ resolvedModel = chunk.value;
1943
+ chunk.status = "cyclic";
1944
+ chunk.value = null;
1945
+ chunk.reason = null;
1946
+ try {
1947
+ var rawModel = JSON.parse(resolvedModel),
1948
+ value = reviveModel(
1949
+ chunk._response,
1950
+ { "": rawModel },
1951
+ "",
1952
+ rawModel,
1953
+ rootReference
1954
+ );
1955
+ if (
1956
+ null !== initializingChunkBlockedModel &&
1957
+ 0 < initializingChunkBlockedModel.deps
1958
+ )
1959
+ (initializingChunkBlockedModel.value = value), (chunk.status = "blocked");
1960
+ else {
1961
+ var resolveListeners = chunk.value;
1962
+ chunk.status = "fulfilled";
1963
+ chunk.value = value;
1964
+ null !== resolveListeners && wakeChunk(resolveListeners, value);
1965
+ }
1966
+ } catch (error) {
1967
+ (chunk.status = "rejected"), (chunk.reason = error);
1968
+ } finally {
1969
+ (initializingChunk = prevChunk),
1970
+ (initializingChunkBlockedModel = prevBlocked);
1971
+ }
1972
+ }
1973
+ function reportGlobalError(response, error) {
1974
+ response._chunks.forEach(function (chunk) {
1975
+ "pending" === chunk.status && triggerErrorOnChunk(chunk, error);
1976
+ });
1977
+ }
1978
+ function getChunk(response, id) {
1979
+ var chunks = response._chunks,
1980
+ chunk = chunks.get(id);
1981
+ chunk ||
1982
+ ((chunk = response._formData.get(response._prefix + id)),
1983
+ (chunk =
1984
+ null != chunk
1985
+ ? new Chunk("resolved_model", chunk, id, response)
1986
+ : createPendingChunk(response)),
1987
+ chunks.set(id, chunk));
1988
+ return chunk;
1989
+ }
1990
+ function createModelResolver(
1991
+ chunk,
1992
+ parentObject,
1993
+ key,
1994
+ cyclic,
1995
+ response,
1996
+ map,
1997
+ path
1998
+ ) {
1999
+ if (initializingChunkBlockedModel) {
2000
+ var blocked = initializingChunkBlockedModel;
2001
+ cyclic || blocked.deps++;
2002
+ } else
2003
+ blocked = initializingChunkBlockedModel = {
2004
+ deps: cyclic ? 0 : 1,
2005
+ value: null
2006
+ };
2007
+ return function (value) {
2008
+ for (var i = 1; i < path.length; i++) value = value[path[i]];
2009
+ parentObject[key] = map(response, value);
2010
+ "" === key && null === blocked.value && (blocked.value = parentObject[key]);
2011
+ blocked.deps--;
2012
+ 0 === blocked.deps &&
2013
+ "blocked" === chunk.status &&
2014
+ ((value = chunk.value),
2015
+ (chunk.status = "fulfilled"),
2016
+ (chunk.value = blocked.value),
2017
+ null !== value && wakeChunk(value, blocked.value));
2018
+ };
2019
+ }
2020
+ function createModelReject(chunk) {
2021
+ return function (error) {
2022
+ return triggerErrorOnChunk(chunk, error);
2023
+ };
2024
+ }
2025
+ function getOutlinedModel(response, reference, parentObject, key, map) {
2026
+ reference = reference.split(":");
2027
+ var id = parseInt(reference[0], 16);
2028
+ id = getChunk(response, id);
2029
+ switch (id.status) {
2030
+ case "resolved_model":
2031
+ initializeModelChunk(id);
2032
+ }
2033
+ switch (id.status) {
2034
+ case "fulfilled":
2035
+ parentObject = id.value;
2036
+ for (key = 1; key < reference.length; key++)
2037
+ parentObject = parentObject[reference[key]];
2038
+ return map(response, parentObject);
2039
+ case "pending":
2040
+ case "blocked":
2041
+ case "cyclic":
2042
+ var parentChunk = initializingChunk;
2043
+ id.then(
2044
+ createModelResolver(
2045
+ parentChunk,
2046
+ parentObject,
2047
+ key,
2048
+ "cyclic" === id.status,
2049
+ response,
2050
+ map,
2051
+ reference
2052
+ ),
2053
+ createModelReject(parentChunk)
2054
+ );
2055
+ return null;
2056
+ default:
2057
+ throw id.reason;
2058
+ }
2059
+ }
2060
+ function createMap(response, model) {
2061
+ return new Map(model);
2062
+ }
2063
+ function createSet(response, model) {
2064
+ return new Set(model);
2065
+ }
2066
+ function extractIterator(response, model) {
2067
+ return model[Symbol.iterator]();
2068
+ }
2069
+ function createModel(response, model) {
2070
+ return model;
2071
+ }
2072
+ function parseTypedArray(
2073
+ response,
2074
+ reference,
2075
+ constructor,
2076
+ bytesPerElement,
2077
+ parentObject,
2078
+ parentKey
2079
+ ) {
2080
+ reference = parseInt(reference.slice(2), 16);
2081
+ reference = response._formData.get(response._prefix + reference);
2082
+ reference =
2083
+ constructor === ArrayBuffer
2084
+ ? reference.arrayBuffer()
2085
+ : reference.arrayBuffer().then(function (buffer) {
2086
+ return new constructor(buffer);
2087
+ });
2088
+ bytesPerElement = initializingChunk;
2089
+ reference.then(
2090
+ createModelResolver(
2091
+ bytesPerElement,
2092
+ parentObject,
2093
+ parentKey,
2094
+ !1,
2095
+ response,
2096
+ createModel,
2097
+ []
2098
+ ),
2099
+ createModelReject(bytesPerElement)
2100
+ );
2101
+ return null;
2102
+ }
2103
+ function resolveStream(response, id, stream, controller) {
2104
+ var chunks = response._chunks;
2105
+ stream = new Chunk("fulfilled", stream, controller, response);
2106
+ chunks.set(id, stream);
2107
+ response = response._formData.getAll(response._prefix + id);
2108
+ for (id = 0; id < response.length; id++)
2109
+ (chunks = response[id]),
2110
+ "C" === chunks[0]
2111
+ ? controller.close("C" === chunks ? '"$undefined"' : chunks.slice(1))
2112
+ : controller.enqueueModel(chunks);
2113
+ }
2114
+ function parseReadableStream(response, reference, type) {
2115
+ reference = parseInt(reference.slice(2), 16);
2116
+ var controller = null;
2117
+ type = new ReadableStream({
2118
+ type: type,
2119
+ start: function (c) {
2120
+ controller = c;
2121
+ }
2122
+ });
2123
+ var previousBlockedChunk = null;
2124
+ resolveStream(response, reference, type, {
2125
+ enqueueModel: function (json) {
2126
+ if (null === previousBlockedChunk) {
2127
+ var chunk = new Chunk("resolved_model", json, -1, response);
2128
+ initializeModelChunk(chunk);
2129
+ "fulfilled" === chunk.status
2130
+ ? controller.enqueue(chunk.value)
2131
+ : (chunk.then(
2132
+ function (v) {
2133
+ return controller.enqueue(v);
2134
+ },
2135
+ function (e) {
2136
+ return controller.error(e);
2137
+ }
2138
+ ),
2139
+ (previousBlockedChunk = chunk));
2140
+ } else {
2141
+ chunk = previousBlockedChunk;
2142
+ var chunk$27 = createPendingChunk(response);
2143
+ chunk$27.then(
2144
+ function (v) {
2145
+ return controller.enqueue(v);
2146
+ },
2147
+ function (e) {
2148
+ return controller.error(e);
2149
+ }
2150
+ );
2151
+ previousBlockedChunk = chunk$27;
2152
+ chunk.then(function () {
2153
+ previousBlockedChunk === chunk$27 && (previousBlockedChunk = null);
2154
+ resolveModelChunk(chunk$27, json, -1);
2155
+ });
2156
+ }
2157
+ },
2158
+ close: function () {
2159
+ if (null === previousBlockedChunk) controller.close();
2160
+ else {
2161
+ var blockedChunk = previousBlockedChunk;
2162
+ previousBlockedChunk = null;
2163
+ blockedChunk.then(function () {
2164
+ return controller.close();
2165
+ });
2166
+ }
2167
+ },
2168
+ error: function (error) {
2169
+ if (null === previousBlockedChunk) controller.error(error);
2170
+ else {
2171
+ var blockedChunk = previousBlockedChunk;
2172
+ previousBlockedChunk = null;
2173
+ blockedChunk.then(function () {
2174
+ return controller.error(error);
2175
+ });
2176
+ }
2177
+ }
2178
+ });
2179
+ return type;
2180
+ }
2181
+ function asyncIterator() {
2182
+ return this;
2183
+ }
2184
+ function createIterator(next) {
2185
+ next = { next: next };
2186
+ next[ASYNC_ITERATOR] = asyncIterator;
2187
+ return next;
2188
+ }
2189
+ function parseAsyncIterable(response, reference, iterator) {
2190
+ reference = parseInt(reference.slice(2), 16);
2191
+ var buffer = [],
2192
+ closed = !1,
2193
+ nextWriteIndex = 0,
2194
+ $jscomp$compprop2 = {};
2195
+ $jscomp$compprop2 =
2196
+ (($jscomp$compprop2[ASYNC_ITERATOR] = function () {
2197
+ var nextReadIndex = 0;
2198
+ return createIterator(function (arg) {
2199
+ if (void 0 !== arg)
2200
+ throw Error(
2201
+ "Values cannot be passed to next() of AsyncIterables passed to Client Components."
2202
+ );
2203
+ if (nextReadIndex === buffer.length) {
2204
+ if (closed)
2205
+ return new Chunk(
2206
+ "fulfilled",
2207
+ { done: !0, value: void 0 },
2208
+ null,
2209
+ response
2210
+ );
2211
+ buffer[nextReadIndex] = createPendingChunk(response);
2212
+ }
2213
+ return buffer[nextReadIndex++];
2214
+ });
2215
+ }),
2216
+ $jscomp$compprop2);
2217
+ iterator = iterator ? $jscomp$compprop2[ASYNC_ITERATOR]() : $jscomp$compprop2;
2218
+ resolveStream(response, reference, iterator, {
2219
+ enqueueModel: function (value) {
2220
+ nextWriteIndex === buffer.length
2221
+ ? (buffer[nextWriteIndex] = createResolvedIteratorResultChunk(
2222
+ response,
2223
+ value,
2224
+ !1
2225
+ ))
2226
+ : resolveIteratorResultChunk(buffer[nextWriteIndex], value, !1);
2227
+ nextWriteIndex++;
2228
+ },
2229
+ close: function (value) {
2230
+ closed = !0;
2231
+ nextWriteIndex === buffer.length
2232
+ ? (buffer[nextWriteIndex] = createResolvedIteratorResultChunk(
2233
+ response,
2234
+ value,
2235
+ !0
2236
+ ))
2237
+ : resolveIteratorResultChunk(buffer[nextWriteIndex], value, !0);
2238
+ for (nextWriteIndex++; nextWriteIndex < buffer.length; )
2239
+ resolveIteratorResultChunk(
2240
+ buffer[nextWriteIndex++],
2241
+ '"$undefined"',
2242
+ !0
2243
+ );
2244
+ },
2245
+ error: function (error) {
2246
+ closed = !0;
2247
+ for (
2248
+ nextWriteIndex === buffer.length &&
2249
+ (buffer[nextWriteIndex] = createPendingChunk(response));
2250
+ nextWriteIndex < buffer.length;
2251
+
2252
+ )
2253
+ triggerErrorOnChunk(buffer[nextWriteIndex++], error);
2254
+ }
2255
+ });
2256
+ return iterator;
2257
+ }
2258
+ function parseModelString(response, obj, key, value, reference) {
2259
+ if ("$" === value[0]) {
2260
+ switch (value[1]) {
2261
+ case "$":
2262
+ return value.slice(1);
2263
+ case "@":
2264
+ return (obj = parseInt(value.slice(2), 16)), getChunk(response, obj);
2265
+ case "F":
2266
+ return (
2267
+ (value = value.slice(2)),
2268
+ (value = getOutlinedModel(response, value, obj, key, createModel)),
2269
+ loadServerReference$1(
2270
+ response,
2271
+ value.id,
2272
+ value.bound,
2273
+ initializingChunk,
2274
+ obj,
2275
+ key
2276
+ )
2277
+ );
2278
+ case "T":
2279
+ if (void 0 === reference || void 0 === response._temporaryReferences)
2280
+ throw Error(
2281
+ "Could not reference an opaque temporary reference. This is likely due to misconfiguring the temporaryReferences options on the server."
2282
+ );
2283
+ return createTemporaryReference(
2284
+ response._temporaryReferences,
2285
+ reference
2286
+ );
2287
+ case "Q":
2288
+ return (
2289
+ (value = value.slice(2)),
2290
+ getOutlinedModel(response, value, obj, key, createMap)
2291
+ );
2292
+ case "W":
2293
+ return (
2294
+ (value = value.slice(2)),
2295
+ getOutlinedModel(response, value, obj, key, createSet)
2296
+ );
2297
+ case "K":
2298
+ obj = value.slice(2);
2299
+ var formPrefix = response._prefix + obj + "_",
2300
+ data = new FormData();
2301
+ response._formData.forEach(function (entry, entryKey) {
2302
+ entryKey.startsWith(formPrefix) &&
2303
+ data.append(entryKey.slice(formPrefix.length), entry);
2304
+ });
2305
+ return data;
2306
+ case "i":
2307
+ return (
2308
+ (value = value.slice(2)),
2309
+ getOutlinedModel(response, value, obj, key, extractIterator)
2310
+ );
2311
+ case "I":
2312
+ return Infinity;
2313
+ case "-":
2314
+ return "$-0" === value ? -0 : -Infinity;
2315
+ case "N":
2316
+ return NaN;
2317
+ case "u":
2318
+ return;
2319
+ case "D":
2320
+ return new Date(Date.parse(value.slice(2)));
2321
+ case "n":
2322
+ return BigInt(value.slice(2));
2323
+ }
2324
+ switch (value[1]) {
2325
+ case "A":
2326
+ return parseTypedArray(response, value, ArrayBuffer, 1, obj, key);
2327
+ case "O":
2328
+ return parseTypedArray(response, value, Int8Array, 1, obj, key);
2329
+ case "o":
2330
+ return parseTypedArray(response, value, Uint8Array, 1, obj, key);
2331
+ case "U":
2332
+ return parseTypedArray(response, value, Uint8ClampedArray, 1, obj, key);
2333
+ case "S":
2334
+ return parseTypedArray(response, value, Int16Array, 2, obj, key);
2335
+ case "s":
2336
+ return parseTypedArray(response, value, Uint16Array, 2, obj, key);
2337
+ case "L":
2338
+ return parseTypedArray(response, value, Int32Array, 4, obj, key);
2339
+ case "l":
2340
+ return parseTypedArray(response, value, Uint32Array, 4, obj, key);
2341
+ case "G":
2342
+ return parseTypedArray(response, value, Float32Array, 4, obj, key);
2343
+ case "g":
2344
+ return parseTypedArray(response, value, Float64Array, 8, obj, key);
2345
+ case "M":
2346
+ return parseTypedArray(response, value, BigInt64Array, 8, obj, key);
2347
+ case "m":
2348
+ return parseTypedArray(response, value, BigUint64Array, 8, obj, key);
2349
+ case "V":
2350
+ return parseTypedArray(response, value, DataView, 1, obj, key);
2351
+ case "B":
2352
+ return (
2353
+ (obj = parseInt(value.slice(2), 16)),
2354
+ response._formData.get(response._prefix + obj)
2355
+ );
2356
+ }
2357
+ switch (value[1]) {
2358
+ case "R":
2359
+ return parseReadableStream(response, value, void 0);
2360
+ case "r":
2361
+ return parseReadableStream(response, value, "bytes");
2362
+ case "X":
2363
+ return parseAsyncIterable(response, value, !1);
2364
+ case "x":
2365
+ return parseAsyncIterable(response, value, !0);
2366
+ }
2367
+ value = value.slice(1);
2368
+ return getOutlinedModel(response, value, obj, key, createModel);
2369
+ }
2370
+ return value;
2371
+ }
2372
+ function createResponse(bundlerConfig, formFieldPrefix, temporaryReferences) {
2373
+ var backingFormData =
2374
+ 3 < arguments.length && void 0 !== arguments[3]
2375
+ ? arguments[3]
2376
+ : new FormData(),
2377
+ chunks = new Map();
2378
+ return {
2379
+ _bundlerConfig: bundlerConfig,
2380
+ _prefix: formFieldPrefix,
2381
+ _formData: backingFormData,
2382
+ _chunks: chunks,
2383
+ _temporaryReferences: temporaryReferences
2384
+ };
2385
+ }
2386
+ function close(response) {
2387
+ reportGlobalError(response, Error("Connection closed."));
2388
+ }
2389
+ function loadServerReference(bundlerConfig, id, bound) {
2390
+ var serverReference = resolveServerReference(bundlerConfig, id);
2391
+ bundlerConfig = preloadModule$1(serverReference);
2392
+ return bound
2393
+ ? Promise.all([bound, bundlerConfig]).then(function (_ref) {
2394
+ _ref = _ref[0];
2395
+ var fn = requireModule(serverReference);
2396
+ return fn.bind.apply(fn, [null].concat(_ref));
2397
+ })
2398
+ : bundlerConfig
2399
+ ? Promise.resolve(bundlerConfig).then(function () {
2400
+ return requireModule(serverReference);
2401
+ })
2402
+ : Promise.resolve(requireModule(serverReference));
2403
+ }
2404
+ function decodeBoundActionMetaData(body, serverManifest, formFieldPrefix) {
2405
+ body = createResponse(serverManifest, formFieldPrefix, void 0, body);
2406
+ close(body);
2407
+ body = getChunk(body, 0);
2408
+ body.then(function () {});
2409
+ if ("fulfilled" !== body.status) throw body.reason;
2410
+ return body.value;
2411
+ }
2412
+ function decodeAction$1(body, serverManifest) {
2413
+ var formData = new FormData(),
2414
+ action = null;
2415
+ body.forEach(function (value, key) {
2416
+ key.startsWith("$ACTION_")
2417
+ ? key.startsWith("$ACTION_REF_")
2418
+ ? ((value = "$ACTION_" + key.slice(12) + ":"),
2419
+ (value = decodeBoundActionMetaData(body, serverManifest, value)),
2420
+ (action = loadServerReference(serverManifest, value.id, value.bound)))
2421
+ : key.startsWith("$ACTION_ID_") &&
2422
+ ((value = key.slice(11)),
2423
+ (action = loadServerReference(serverManifest, value, null)))
2424
+ : formData.append(key, value);
2425
+ });
2426
+ return null === action
2427
+ ? null
2428
+ : action.then(function (fn) {
2429
+ return fn.bind(null, formData);
2430
+ });
2431
+ }
2432
+ function decodeFormState$1(actionResult, body, serverManifest) {
2433
+ var keyPath = body.get("$ACTION_KEY");
2434
+ if ("string" !== typeof keyPath) return Promise.resolve(null);
2435
+ var metaData = null;
2436
+ body.forEach(function (value, key) {
2437
+ key.startsWith("$ACTION_REF_") &&
2438
+ ((value = "$ACTION_" + key.slice(12) + ":"),
2439
+ (metaData = decodeBoundActionMetaData(body, serverManifest, value)));
2440
+ });
2441
+ if (null === metaData) return Promise.resolve(null);
2442
+ var referenceId = metaData.id;
2443
+ return Promise.resolve(metaData.bound).then(function (bound) {
2444
+ return null === bound
2445
+ ? null
2446
+ : [actionResult, keyPath, referenceId, bound.length - 1];
2447
+ });
2448
+ }
2449
+ var serverManifest = {};
2450
+ exports.createClientReference = function (id, exportName, bundles) {
2451
+ return {
2452
+ $$typeof: CLIENT_REFERENCE_TAG$1,
2453
+ $$id: id,
2454
+ $$name: exportName,
2455
+ $$bundles: bundles
2456
+ };
2457
+ };
2458
+ exports.createTemporaryReferenceSet = function () {
2459
+ return new WeakMap();
2460
+ };
2461
+ exports.decodeAction = function (body) {
2462
+ return decodeAction$1(body, serverManifest);
2463
+ };
2464
+ exports.decodeFormState = function (actionResult, body) {
2465
+ return decodeFormState$1(actionResult, body, serverManifest);
2466
+ };
2467
+ exports.decodeReply = function (body, options) {
2468
+ if ("string" === typeof body) {
2469
+ var form = new FormData();
2470
+ form.append("0", body);
2471
+ body = form;
2472
+ }
2473
+ body = createResponse(
2474
+ serverManifest,
2475
+ "",
2476
+ options ? options.temporaryReferences : void 0,
2477
+ body
2478
+ );
2479
+ options = getChunk(body, 0);
2480
+ close(body);
2481
+ return options;
2482
+ };
2483
+ exports.loadServerAction = function (id) {
2484
+ var reference = resolveServerReference(serverManifest, id);
2485
+ return Promise.resolve(reference)
2486
+ .then(function () {
2487
+ return preloadModule$1(reference);
2488
+ })
2489
+ .then(function () {
2490
+ var fn = requireModule(reference);
2491
+ if ("function" !== typeof fn)
2492
+ throw Error("Server actions must be functions");
2493
+ return fn;
2494
+ });
2495
+ };
2496
+ exports.registerServerActions = function (manifest) {
2497
+ serverManifest = manifest;
2498
+ };
2499
+ exports.registerServerReference = function (reference, id, exportName) {
2500
+ return Object.defineProperties(reference, {
2501
+ $$typeof: { value: SERVER_REFERENCE_TAG },
2502
+ $$id: { value: id + "#" + exportName, configurable: !0 },
2503
+ $$bound: { value: null, configurable: !0 },
2504
+ bind: { value: bind, configurable: !0 }
2505
+ });
2506
+ };
2507
+ exports.renderToReadableStream = function (model, options) {
2508
+ var request = new RequestInstance(
2509
+ 20,
2510
+ model,
2511
+ null,
2512
+ options ? options.onError : void 0,
2513
+ options ? options.identifierPrefix : void 0,
2514
+ options ? options.onPostpone : void 0,
2515
+ options ? options.temporaryReferences : void 0,
2516
+ void 0,
2517
+ void 0,
2518
+ noop,
2519
+ noop
2520
+ );
2521
+ if (options && options.signal) {
2522
+ var signal = options.signal;
2523
+ if (signal.aborted) abort(request, signal.reason);
2524
+ else {
2525
+ var listener = function () {
2526
+ abort(request, signal.reason);
2527
+ signal.removeEventListener("abort", listener);
2528
+ };
2529
+ signal.addEventListener("abort", listener);
2530
+ }
2531
+ }
2532
+ return new ReadableStream(
2533
+ {
2534
+ type: "bytes",
2535
+ start: function () {
2536
+ startWork(request);
2537
+ },
2538
+ pull: function (controller) {
2539
+ if (13 === request.status)
2540
+ (request.status = 14), closeWithError(controller, request.fatalError);
2541
+ else if (14 !== request.status && null === request.destination) {
2542
+ request.destination = controller;
2543
+ try {
2544
+ flushCompletedChunks(request, controller);
2545
+ } catch (error) {
2546
+ logRecoverableError(request, error, null),
2547
+ fatalError(request, error);
2548
+ }
2549
+ }
2550
+ },
2551
+ cancel: function (reason) {
2552
+ request.destination = null;
2553
+ abort(request, reason);
2554
+ }
2555
+ },
2556
+ { highWaterMark: 0 }
2557
+ );
2558
+ };