@bgub/fig-reconciler 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,3719 @@
1
+ import { devtoolsTypeName } from "./devtools.js";
2
+ import { Fragment } from "@bgub/fig";
3
+ import { collectChildren, dataResourceKeysForError, invalidChildError, isActivity, isAssets, isContext, isErrorBoundary, isPortal, isSuspense, isThenable, isValidElement, isViewTransition, readThenable, setCurrentDataStore, setCurrentDispatcher, setTransitionHandler } from "@bgub/fig/internal";
4
+ //#region src/fiber-work.ts
5
+ const StoreConsistencyFlag = 2048;
6
+ const ContextPropagationFlag = 1024;
7
+ const NotHoistedFlag = 8192;
8
+ const ViewTransitionStaticFlag = 4096;
9
+ const StaticFlagsMask = ViewTransitionStaticFlag;
10
+ function childSubtreeFlags(node) {
11
+ return node.flags & -8459 | node.subtreeFlags;
12
+ }
13
+ function clearTransientFlags(node) {
14
+ node.flags &= StaticFlagsMask;
15
+ node.subtreeFlags &= StaticFlagsMask;
16
+ }
17
+ //#endregion
18
+ //#region src/commit-index.ts
19
+ function createCommitIndex() {
20
+ return [];
21
+ }
22
+ function commitIndexCheckpoint(index) {
23
+ return index.length;
24
+ }
25
+ function recordCommitWork(index, node, flags = 0) {
26
+ node.flags |= flags;
27
+ if ((node.flags & 256) !== 0) return;
28
+ node.flags |= 256;
29
+ index.push(node);
30
+ }
31
+ function rollbackCommitIndex(index, checkpoint) {
32
+ if (checkpoint === void 0 || checkpoint >= index.length) return;
33
+ const start = checkpoint;
34
+ for (let offset = start; offset < index.length; offset += 1) index[offset].flags &= -257;
35
+ index.length = checkpoint;
36
+ }
37
+ function clearCommitIndex(index) {
38
+ for (const node of index) node.flags &= -257;
39
+ index.length = 0;
40
+ }
41
+ function tagFor(element) {
42
+ if (typeof element.type === "string") return 1;
43
+ if (element.type === Fragment) return 4;
44
+ if (isAssets(element.type)) return 9;
45
+ if (isContext(element.type)) return 5;
46
+ if (isSuspense(element.type)) return 6;
47
+ if (isActivity(element.type)) return 10;
48
+ if (isErrorBoundary(element.type)) return 7;
49
+ if (isViewTransition(element.type)) return 11;
50
+ return 3;
51
+ }
52
+ function isEffectHook(kind) {
53
+ return kind <= 2;
54
+ }
55
+ const priorityTimeouts = {
56
+ [1]: -1,
57
+ [2]: 250,
58
+ [3]: 5e3,
59
+ [4]: 1e4,
60
+ [5]: 1073741823
61
+ };
62
+ const frameInterval = 5;
63
+ function compare(a, b) {
64
+ return a.expirationTime - b.expirationTime || a.id - b.id;
65
+ }
66
+ var MinHeap = class {
67
+ items = [];
68
+ push(value) {
69
+ this.items.push(value);
70
+ this.siftUp(this.items.length - 1);
71
+ }
72
+ peek() {
73
+ return this.items[0] ?? null;
74
+ }
75
+ pop() {
76
+ const first = this.items[0];
77
+ const last = this.items.pop();
78
+ if (first === void 0 || last === void 0) return null;
79
+ if (first !== last) {
80
+ this.items[0] = last;
81
+ this.siftDown(0);
82
+ }
83
+ return first;
84
+ }
85
+ siftUp(index) {
86
+ const value = this.items[index];
87
+ while (index > 0) {
88
+ const parentIndex = index - 1 >>> 1;
89
+ const parent = this.items[parentIndex];
90
+ if (compare(parent, value) <= 0) return;
91
+ this.items[parentIndex] = value;
92
+ this.items[index] = parent;
93
+ index = parentIndex;
94
+ }
95
+ }
96
+ siftDown(index) {
97
+ const length = this.items.length;
98
+ const value = this.items[index];
99
+ while (index < length) {
100
+ const leftIndex = index * 2 + 1;
101
+ const rightIndex = leftIndex + 1;
102
+ let smallest = index;
103
+ if (leftIndex < length && compare(this.items[leftIndex], this.items[smallest]) < 0) smallest = leftIndex;
104
+ if (rightIndex < length && compare(this.items[rightIndex], this.items[smallest]) < 0) smallest = rightIndex;
105
+ if (smallest === index) return;
106
+ this.items[index] = this.items[smallest];
107
+ this.items[smallest] = value;
108
+ index = smallest;
109
+ }
110
+ }
111
+ };
112
+ const taskQueue = new MinHeap();
113
+ let taskId = 1;
114
+ let messageLoopRunning = false;
115
+ let needsPaint = false;
116
+ let startTime = -1;
117
+ let actQueue = null;
118
+ let actScopeDepth = 0;
119
+ let flushingActQueue = false;
120
+ const actFlushLimit = 1e3;
121
+ function now() {
122
+ return globalThis.performance?.now?.() ?? Date.now();
123
+ }
124
+ function shouldYieldToHost() {
125
+ return needsPaint || now() - startTime >= frameInterval;
126
+ }
127
+ function requestPaint() {
128
+ needsPaint = true;
129
+ }
130
+ function scheduleCallback(priority, callback) {
131
+ const task = {
132
+ id: taskId++,
133
+ callback,
134
+ expirationTime: now() + priorityTimeouts[priority]
135
+ };
136
+ if (actQueue !== null) {
137
+ actQueue.push(task);
138
+ return { cancel() {
139
+ task.callback = null;
140
+ } };
141
+ }
142
+ taskQueue.push(task);
143
+ requestHostCallback();
144
+ return { cancel() {
145
+ task.callback = null;
146
+ } };
147
+ }
148
+ async function act(callback) {
149
+ const previousActQueue = actQueue;
150
+ const previousActScopeDepth = actScopeDepth;
151
+ const queue = previousActQueue ?? [];
152
+ actQueue = queue;
153
+ actScopeDepth = previousActScopeDepth + 1;
154
+ try {
155
+ const result = await callback();
156
+ actScopeDepth = previousActScopeDepth;
157
+ if (previousActScopeDepth === 0) try {
158
+ await flushActQueueUntilSettled(queue);
159
+ } finally {
160
+ actQueue = previousActQueue;
161
+ }
162
+ else actQueue = previousActQueue;
163
+ return result;
164
+ } catch (error) {
165
+ actScopeDepth = previousActScopeDepth;
166
+ actQueue = previousActQueue;
167
+ throw error;
168
+ }
169
+ }
170
+ async function flushActQueueUntilSettled(queue) {
171
+ for (let flushes = 0; flushes < actFlushLimit; flushes += 1) {
172
+ flushActQueue(queue);
173
+ await Promise.resolve();
174
+ if (hasActWork(queue)) continue;
175
+ await waitForActMacrotask();
176
+ if (!hasActWork(queue)) {
177
+ queue.length = 0;
178
+ return;
179
+ }
180
+ }
181
+ throw new Error("act() exceeded the scheduled work flush limit.");
182
+ }
183
+ function flushActQueue(queue) {
184
+ if (flushingActQueue) return;
185
+ flushingActQueue = true;
186
+ try {
187
+ let task = takeNextActTask(queue);
188
+ while (task !== null) {
189
+ const callback = task.callback;
190
+ if (callback !== null) {
191
+ task.callback = null;
192
+ needsPaint = false;
193
+ startTime = now();
194
+ const continuation = callback();
195
+ if (typeof continuation === "function") {
196
+ task.callback = continuation;
197
+ queue.push(task);
198
+ }
199
+ }
200
+ task = takeNextActTask(queue);
201
+ }
202
+ } finally {
203
+ flushingActQueue = false;
204
+ }
205
+ }
206
+ function hasActWork(queue) {
207
+ return queue.some((task) => task.callback !== null);
208
+ }
209
+ function takeNextActTask(queue) {
210
+ let nextIndex = -1;
211
+ for (let index = 0; index < queue.length; index += 1) {
212
+ const task = queue[index];
213
+ if (task.callback === null) continue;
214
+ if (nextIndex === -1 || compare(task, queue[nextIndex]) < 0) nextIndex = index;
215
+ }
216
+ if (nextIndex === -1) {
217
+ queue.length = 0;
218
+ return null;
219
+ }
220
+ const [task] = queue.splice(nextIndex, 1);
221
+ return task;
222
+ }
223
+ function waitForActMacrotask() {
224
+ return new Promise((resolve) => {
225
+ if (typeof setImmediate === "function") setImmediate(resolve);
226
+ else setTimeout(resolve, 0);
227
+ });
228
+ }
229
+ function requestHostCallback() {
230
+ if (messageLoopRunning) return;
231
+ messageLoopRunning = true;
232
+ scheduleHostCallback();
233
+ }
234
+ function performWorkUntilDeadline() {
235
+ needsPaint = false;
236
+ startTime = now();
237
+ let hasMoreWork = false;
238
+ try {
239
+ hasMoreWork = flushWork(startTime);
240
+ } finally {
241
+ if (hasMoreWork) scheduleHostCallback();
242
+ else messageLoopRunning = false;
243
+ }
244
+ }
245
+ let channel = null;
246
+ const scheduleHostCallback = typeof setImmediate === "function" ? () => void setImmediate(performWorkUntilDeadline) : typeof MessageChannel === "function" ? () => {
247
+ if (channel === null) {
248
+ channel = new MessageChannel();
249
+ channel.port1.onmessage = () => performWorkUntilDeadline();
250
+ }
251
+ channel.port2.postMessage(null);
252
+ } : () => void setTimeout(performWorkUntilDeadline, 0);
253
+ function flushWork(currentTime) {
254
+ let task = taskQueue.peek();
255
+ while (task !== null) {
256
+ if (task.expirationTime > currentTime && shouldYieldToHost()) break;
257
+ const callback = task.callback;
258
+ if (callback === null) taskQueue.pop();
259
+ else {
260
+ task.callback = null;
261
+ const continuation = callback();
262
+ if (typeof continuation === "function") task.callback = continuation;
263
+ else if (task === taskQueue.peek()) taskQueue.pop();
264
+ }
265
+ task = taskQueue.peek();
266
+ }
267
+ return task !== null;
268
+ }
269
+ const RetryLane1 = 1 << 22;
270
+ const SelectiveHydrationLane = 1 << 26;
271
+ const OffscreenLane = 1 << 29;
272
+ const DeferredLane = 1 << 30;
273
+ const AllTransitionLanes = 4194048;
274
+ const RetryLanes = 62914560;
275
+ const syncLaneExpirationMs = 250;
276
+ const transitionLaneExpirationMs = 5e3;
277
+ let currentUpdateLane = 32;
278
+ let nextTransitionLane = 256;
279
+ let nextRetryLane = RetryLane1;
280
+ let asyncTransitionLanes = 0;
281
+ const asyncTransitionLaneCounts = createLaneMap(0);
282
+ function createLaneMap(initial) {
283
+ return Array.from({ length: 31 }, () => initial);
284
+ }
285
+ function mergeLanes(a, b) {
286
+ return a | b;
287
+ }
288
+ function includesSomeLane(set, subset) {
289
+ return (set & subset) !== 0;
290
+ }
291
+ function getHighestPriorityLane(lanes) {
292
+ return lanes & -lanes;
293
+ }
294
+ function getHighestPriorityLanes(lanes) {
295
+ const lane = getHighestPriorityLane(lanes);
296
+ if (includesSomeLane(4194048, lane)) return lanes & AllTransitionLanes;
297
+ if (includesSomeLane(62914560, lane)) return lanes & RetryLanes;
298
+ return lane;
299
+ }
300
+ function getNextLanes(root, wipLanes = 0) {
301
+ const pending = root.pendingLanes;
302
+ if (pending === 0) return 0;
303
+ const unblocked = pending & ~root.suspendedLanes;
304
+ const pinged = pending & root.pingedLanes;
305
+ let next = root.expiredLanes & unblocked;
306
+ if (next === 0) {
307
+ next = getHighestPriorityLanes(unblocked);
308
+ if (next === 0) {
309
+ const expiredPinged = root.expiredLanes & pinged;
310
+ next = expiredPinged !== 0 ? expiredPinged : getHighestPriorityLanes(pinged);
311
+ }
312
+ }
313
+ if (next === 0) return 0;
314
+ if (wipLanes !== 0 && wipLanes !== next && !includesSomeLane(root.expiredLanes, wipLanes) && getHighestPriorityLane(next) >= getHighestPriorityLane(wipLanes)) return wipLanes;
315
+ return getEntangledLanes(root, next);
316
+ }
317
+ function getEntangledLanes(root, lanes) {
318
+ let entangled = lanes;
319
+ let visited = 0;
320
+ let laneSet = entangled & root.entangledLanes;
321
+ while (laneSet !== 0) {
322
+ const index = laneToIndex(laneSet);
323
+ const lane = 1 << index;
324
+ entangled |= root.entanglements[index];
325
+ visited |= lane;
326
+ laneSet = entangled & root.entangledLanes & ~visited;
327
+ }
328
+ return entangled;
329
+ }
330
+ function markRootUpdated(root, lane) {
331
+ root.pendingLanes |= lane;
332
+ if (lane !== 268435456) {
333
+ root.suspendedLanes = 0;
334
+ root.pingedLanes = 0;
335
+ }
336
+ }
337
+ function markRootFinished(root, remainingLanes) {
338
+ const noLongerPending = root.pendingLanes & ~remainingLanes;
339
+ root.pendingLanes = remainingLanes;
340
+ root.suspendedLanes = 0;
341
+ root.pingedLanes = 0;
342
+ root.expiredLanes &= remainingLanes;
343
+ root.entangledLanes &= remainingLanes;
344
+ let lanes = noLongerPending;
345
+ while (lanes !== 0) {
346
+ const index = laneToIndex(lanes);
347
+ const lane = 1 << index;
348
+ root.entanglements[index] = 0;
349
+ root.expirationTimes[index] = -1;
350
+ lanes &= ~lane;
351
+ }
352
+ }
353
+ function markRootSuspended(root, lanes) {
354
+ root.suspendedLanes |= lanes;
355
+ root.pingedLanes &= ~lanes;
356
+ let laneSet = lanes;
357
+ while (laneSet !== 0) {
358
+ const index = laneToIndex(laneSet);
359
+ const lane = 1 << index;
360
+ root.expirationTimes[index] = -1;
361
+ laneSet &= ~lane;
362
+ }
363
+ }
364
+ function markRootPinged(root, lanes) {
365
+ root.pingedLanes |= root.suspendedLanes & lanes;
366
+ }
367
+ function markRootEntangled(root, lanes) {
368
+ root.entangledLanes |= lanes;
369
+ let laneSet = lanes;
370
+ while (laneSet !== 0) {
371
+ const index = laneToIndex(laneSet);
372
+ const lane = 1 << index;
373
+ root.entanglements[index] |= lanes;
374
+ laneSet &= ~lane;
375
+ }
376
+ }
377
+ function markStarvedLanesAsExpired(root, currentTime) {
378
+ let lanes = root.pendingLanes & -62914561;
379
+ while (lanes !== 0) {
380
+ const index = laneToIndex(lanes);
381
+ const lane = 1 << index;
382
+ const expiration = root.expirationTimes[index];
383
+ if (expiration === -1) {
384
+ if (!includesSomeLane(root.suspendedLanes, lane) || includesSomeLane(root.pingedLanes, lane)) root.expirationTimes[index] = computeExpirationTime(lane, currentTime);
385
+ } else if (expiration <= currentTime) root.expiredLanes |= lane;
386
+ lanes &= ~lane;
387
+ }
388
+ }
389
+ function claimNextTransitionLane() {
390
+ const lane = nextTransitionLane;
391
+ nextTransitionLane <<= 1;
392
+ if (!includesSomeLane(261888, nextTransitionLane)) nextTransitionLane = 256;
393
+ return lane;
394
+ }
395
+ function claimNextRetryLane() {
396
+ const lane = nextRetryLane;
397
+ nextRetryLane <<= 1;
398
+ if (!includesSomeLane(62914560, nextRetryLane)) nextRetryLane = RetryLane1;
399
+ return lane;
400
+ }
401
+ function isSyncLane(lane) {
402
+ return includesSomeLane(3, lane);
403
+ }
404
+ function includesOnlyTransitions(lanes) {
405
+ return (lanes & AllTransitionLanes) === lanes;
406
+ }
407
+ function getLaneSchedulerPriority(lane) {
408
+ if (includesSomeLane(3, lane)) return 1;
409
+ if (includesSomeLane(76, lane)) return 2;
410
+ if (includesSomeLane(71303088, lane)) return 3;
411
+ if (includesSomeLane(62914560, lane)) return 4;
412
+ return 5;
413
+ }
414
+ function requestUpdateLane() {
415
+ if (currentUpdateLane === 32 && asyncTransitionLanes !== 0) return getHighestPriorityLane(asyncTransitionLanes);
416
+ return currentUpdateLane;
417
+ }
418
+ function runWithPriority(lane, callback) {
419
+ const previousLane = currentUpdateLane;
420
+ currentUpdateLane = lane;
421
+ try {
422
+ return callback();
423
+ } finally {
424
+ currentUpdateLane = previousLane;
425
+ }
426
+ }
427
+ function runWithTransition(callback) {
428
+ return runWithTransitionLane(includesSomeLane(4194048, currentUpdateLane) ? currentUpdateLane : claimNextTransitionLane(), callback);
429
+ }
430
+ function runWithTransitionLane(lane, callback) {
431
+ const result = runWithPriority(lane, callback);
432
+ if (isThenable(result)) {
433
+ const release = trackAsyncTransitionLane(lane);
434
+ result.then(release, release);
435
+ }
436
+ return result;
437
+ }
438
+ function trackAsyncTransitionLane(lane) {
439
+ const index = laneToIndex(lane);
440
+ asyncTransitionLaneCounts[index] += 1;
441
+ asyncTransitionLanes |= lane;
442
+ return () => releaseAsyncTransitionLane(lane, index);
443
+ }
444
+ function releaseAsyncTransitionLane(lane, index) {
445
+ asyncTransitionLaneCounts[index] = Math.max(0, asyncTransitionLaneCounts[index] - 1);
446
+ if (asyncTransitionLaneCounts[index] === 0) asyncTransitionLanes &= ~lane;
447
+ }
448
+ function computeExpirationTime(lane, currentTime) {
449
+ if (includesSomeLane(79, lane)) return currentTime + syncLaneExpirationMs;
450
+ if (includesSomeLane(4194224, lane)) return currentTime + transitionLaneExpirationMs;
451
+ return -1;
452
+ }
453
+ function laneToIndex(lanes) {
454
+ return 31 - Math.clz32(lanes);
455
+ }
456
+ //#endregion
457
+ //#region src/fiber-traversal.ts
458
+ function walkFiberForest(node, visitor) {
459
+ walkFiberTree(node, true, visitor);
460
+ }
461
+ function walkFiberSubtree(node, visitor) {
462
+ walkFiberTree(node, false, visitor);
463
+ }
464
+ function walkFiberTree(node, includeRootSiblings, visitor) {
465
+ const stack = [];
466
+ let cursor = node;
467
+ while (cursor !== null) {
468
+ const shouldDescend = visitor(cursor) !== false && cursor.child !== null;
469
+ if ((includeRootSiblings || cursor !== node) && cursor.sibling !== null) stack.push(cursor.sibling);
470
+ cursor = shouldDescend ? cursor.child : stack.pop() ?? null;
471
+ }
472
+ }
473
+ //#endregion
474
+ //#region src/hook-queue.ts
475
+ function mergeQueues(baseQueue, pendingQueue) {
476
+ if (baseQueue === null) return pendingQueue;
477
+ const baseFirst = baseQueue.next;
478
+ baseQueue.next = pendingQueue.next;
479
+ pendingQueue.next = baseFirst;
480
+ return pendingQueue;
481
+ }
482
+ function cloneUpdateNode(update) {
483
+ const clone = {
484
+ action: update.action,
485
+ lane: update.lane,
486
+ next: null
487
+ };
488
+ clone.next = clone;
489
+ return clone;
490
+ }
491
+ function cloneQueue(queue) {
492
+ return queue === null ? null : cloneQueueNodes(queue);
493
+ }
494
+ function cloneQueueNodes(queue) {
495
+ let clone = null;
496
+ let update = queue.next;
497
+ do {
498
+ clone = mergeQueues(clone, cloneUpdateNode(update));
499
+ update = update.next;
500
+ } while (update !== queue.next);
501
+ return clone;
502
+ }
503
+ function clearQueueLanes(queue) {
504
+ let update = queue.next;
505
+ do {
506
+ update.lane = 0;
507
+ update = update.next;
508
+ } while (update !== queue.next);
509
+ }
510
+ //#endregion
511
+ //#region src/host-content.ts
512
+ const EmptyHostTextContent = Symbol("fig.empty-host-text-content");
513
+ const NonTextHostContent = Symbol("fig.non-text-host-content");
514
+ function hostTextContent(children) {
515
+ const text = hostTextContentPart(children);
516
+ return typeof text === "string" ? text : null;
517
+ }
518
+ function hostChildren(props) {
519
+ if (!hasUnsafeHTML(props)) return props.children;
520
+ if (hasRenderableChild(props.children)) throw new Error("Host elements cannot have both unsafeHTML and children.");
521
+ return null;
522
+ }
523
+ function hasUnsafeHTML(props) {
524
+ return !emptyValue(props.unsafeHTML);
525
+ }
526
+ function hasRenderableChild(node) {
527
+ if (Array.isArray(node)) return node.some(hasRenderableChild);
528
+ return !emptyChild(node);
529
+ }
530
+ function emptyValue(value) {
531
+ return value === null || value === void 0 || value === false;
532
+ }
533
+ function emptyChild(value) {
534
+ return value === null || value === void 0 || typeof value === "boolean";
535
+ }
536
+ function hostTextContentPart(node) {
537
+ if (Array.isArray(node)) {
538
+ let hasText = false;
539
+ let text = "";
540
+ for (const child of node) {
541
+ const childText = hostTextContentPart(child);
542
+ if (childText === NonTextHostContent) return NonTextHostContent;
543
+ if (childText === EmptyHostTextContent) continue;
544
+ hasText = true;
545
+ text += childText;
546
+ }
547
+ return hasText ? text : EmptyHostTextContent;
548
+ }
549
+ if (node === null || node === void 0 || typeof node === "boolean") return EmptyHostTextContent;
550
+ if (typeof node === "string" || typeof node === "number") return String(node);
551
+ if (isValidElement(node) || isPortal(node)) return NonTextHostContent;
552
+ throw invalidChildError(node);
553
+ }
554
+ //#endregion
555
+ //#region src/root-data-store.ts
556
+ const DataStoreFactorySymbol = Symbol.for("fig.data-store-factory");
557
+ function createRootDataStore(host) {
558
+ let inner = null;
559
+ let buffered = null;
560
+ let disposed = false;
561
+ function installStore(resource) {
562
+ if (inner !== null) return inner;
563
+ if (disposed) throw new Error("Data resource APIs require a live Fig root.");
564
+ const factory = resource[DataStoreFactorySymbol];
565
+ if (factory === void 0) throw new Error("Data resource APIs require @bgub/fig.");
566
+ inner = factory(host);
567
+ if (buffered !== null) inner.hydrate(buffered);
568
+ buffered = null;
569
+ return inner;
570
+ }
571
+ const store = {
572
+ hydrate(entries) {
573
+ if (inner !== null) {
574
+ inner.hydrate(entries);
575
+ return;
576
+ }
577
+ (buffered ??= []).push(...entries);
578
+ },
579
+ run(callback) {
580
+ if (inner !== null) return inner.run(callback);
581
+ const previousStore = setCurrentDataStore(store);
582
+ try {
583
+ return callback();
584
+ } finally {
585
+ setCurrentDataStore(previousStore);
586
+ }
587
+ },
588
+ readData(resource, args, owner) {
589
+ return installStore(resource).readData(resource, args, owner);
590
+ },
591
+ preloadData(resource, ...args) {
592
+ installStore(resource).preloadData(resource, ...args);
593
+ },
594
+ invalidateData(resource, ...args) {
595
+ installStore(resource).invalidateData(resource, ...args);
596
+ },
597
+ invalidateDataError(error) {
598
+ return inner?.invalidateDataError(error) ?? false;
599
+ },
600
+ invalidateDataKey(key) {
601
+ inner?.invalidateDataKey(key);
602
+ },
603
+ invalidateDataPrefix(prefix) {
604
+ inner?.invalidateDataPrefix(prefix);
605
+ },
606
+ refreshData(resource, ...args) {
607
+ return installStore(resource).refreshData(resource, ...args);
608
+ },
609
+ commitDataDependencies(owner, previousOwner) {
610
+ inner?.commitDataDependencies(owner, previousOwner);
611
+ },
612
+ deleteDataOwner(owner) {
613
+ inner?.deleteDataOwner(owner);
614
+ },
615
+ releaseDataOwner(owner) {
616
+ inner?.releaseDataOwner(owner);
617
+ },
618
+ resetDataDependencies(owner) {
619
+ inner?.resetDataDependencies(owner);
620
+ },
621
+ dispose() {
622
+ disposed = true;
623
+ inner?.dispose();
624
+ inner = null;
625
+ buffered = null;
626
+ },
627
+ inspectDataEntries() {
628
+ return inner?.inspectDataEntries() ?? [];
629
+ },
630
+ snapshot() {
631
+ return inner?.snapshot() ?? buffered?.slice() ?? [];
632
+ }
633
+ };
634
+ return store;
635
+ }
636
+ //#endregion
637
+ //#region src/index.ts
638
+ function runWithEventPriority(priority, callback) {
639
+ return runWithPriority(eventPriorityLane(priority), callback);
640
+ }
641
+ function eventPriorityLane(priority) {
642
+ switch (priority) {
643
+ case "discrete": return 2;
644
+ case "continuous": return 8;
645
+ case "default": return 32;
646
+ }
647
+ }
648
+ function hydrationLaneForPriority(priority) {
649
+ return priority === "discrete" ? 2 : SelectiveHydrationLane;
650
+ }
651
+ const __DEV__ = false;
652
+ setTransitionHandler(runWithTransition);
653
+ const NoActionStateError = Symbol();
654
+ const PreservedSuspense = Symbol("fig.preserved-suspense");
655
+ const NoHydrationInitialElement = Symbol("fig.no-hydration-initial-element");
656
+ var HydrationMismatchError = class extends Error {};
657
+ function createRenderer(host) {
658
+ const noSuspenseRetries = [];
659
+ const roots = /* @__PURE__ */ new WeakMap();
660
+ const mountedRoots = /* @__PURE__ */ new Set();
661
+ const pendingRoots = /* @__PURE__ */ new Set();
662
+ const batchedRoots = /* @__PURE__ */ new Set();
663
+ const abandonedHydrationBoundaries = /* @__PURE__ */ new WeakSet();
664
+ let batchDepth = 0;
665
+ let flushingSyncWork = false;
666
+ let commitDepth = 0;
667
+ let needsPostCommitSyncFlush = false;
668
+ let flushingPostCommitSyncWork = false;
669
+ let nestedPostCommitSyncFlushes = 0;
670
+ const nestedPostCommitSyncFlushLimit = 50;
671
+ let currentCommitEffectPhase = null;
672
+ let hasHiddenBoundaries = false;
673
+ const hiddenStates = /* @__PURE__ */ new Set();
674
+ let activityHostConfig = null;
675
+ let activityHydrationHostConfig = null;
676
+ let hoistedAssetHostConfig = null;
677
+ const viewTransitionHost = host.viewTransition ?? null;
678
+ let renderingFiber = null;
679
+ let currentHook = null;
680
+ let workInProgressHook = null;
681
+ let localIdCounter = 0;
682
+ let viewTransitionAutoNameCounter = 0;
683
+ const dispatcher = {
684
+ useState: updateStateHook,
685
+ useActionState: updateActionStateHook,
686
+ useId: updateIdHook,
687
+ useDeferredValue: updateDeferredValueHook,
688
+ useMemo: updateMemoHook,
689
+ useTransition: updateTransitionHook,
690
+ useReactive(effect, deps) {
691
+ updateEffectHook(0, effect, deps);
692
+ },
693
+ useBeforePaint(effect, deps) {
694
+ updateEffectHook(1, effect, deps);
695
+ },
696
+ useBeforeLayout(effect, deps) {
697
+ updateEffectHook(2, effect, deps);
698
+ },
699
+ useSyncExternalStore: updateExternalStoreHook,
700
+ useStableEvent: updateStableEventHook,
701
+ readContext: readContextValue,
702
+ readData(resource, args) {
703
+ const fiber = requireRenderingFiber();
704
+ return rootOf(fiber).dataStore.readData(resource, args, fiber);
705
+ },
706
+ preloadData(resource, args) {
707
+ rootOf(requireRenderingFiber()).dataStore.preloadData(resource, ...args);
708
+ },
709
+ readPromise(promise) {
710
+ return readThenable(promise);
711
+ }
712
+ };
713
+ function createRoot(container, options = {}) {
714
+ return rootHandle(rootForContainer(container, {
715
+ kind: "client",
716
+ options
717
+ }));
718
+ }
719
+ function hydrateRoot(container, children, options = {}) {
720
+ const root = rootForContainer(container, {
721
+ kind: "hydration",
722
+ options
723
+ });
724
+ root.hydrationInitialElement = children;
725
+ updateRoot(root, children);
726
+ return rootHandle(root);
727
+ }
728
+ function rootForContainer(container, request) {
729
+ if (roots.has(container)) throw duplicateRootError(request.kind);
730
+ if (request.kind === "hydration") requireHydrationHostConfig();
731
+ const root = createFiberRoot(container, request.options ?? {});
732
+ roots.set(container, root);
733
+ if (request.kind === "hydration") {
734
+ root.isHydrating = true;
735
+ root.isHydrationRoot = true;
736
+ root.needsRootHydrationCompletion = true;
737
+ }
738
+ return root;
739
+ }
740
+ function createFiberRoot(container, options) {
741
+ const current = fiber(0, null, null, { children: null }, null);
742
+ const dataStore = createRootDataStore({
743
+ getLane: requestUpdateLane,
744
+ partition: options.dataPartition,
745
+ schedule(owner, lane) {
746
+ scheduleFiber(owner, hiddenSubtreeLane(owner, lane));
747
+ }
748
+ });
749
+ const root = {
750
+ container,
751
+ current,
752
+ element: null,
753
+ identifierPrefix: options.identifierPrefix ?? "",
754
+ devtools: options.devtools ?? true,
755
+ pendingLanes: 0,
756
+ suspendedLanes: 0,
757
+ pingedLanes: 0,
758
+ expiredLanes: 0,
759
+ entangledLanes: 0,
760
+ entanglements: createLaneMap(0),
761
+ expirationTimes: createLaneMap(-1),
762
+ callback: null,
763
+ callbackPriority: 0,
764
+ wip: null,
765
+ finishedWork: null,
766
+ renderLanes: 0,
767
+ pendingViewTransitionCommit: false,
768
+ parkedViewTransitionCommit: false,
769
+ dataStore,
770
+ contextValues: /* @__PURE__ */ new Map(),
771
+ contextStack: [],
772
+ externalStores: /* @__PURE__ */ new Set(),
773
+ pendingReactiveEffects: [],
774
+ reactiveCallback: null,
775
+ suspendedThenables: /* @__PURE__ */ new WeakMap(),
776
+ pendingSuspenseRetries: [],
777
+ attachedSuspenseRetries: /* @__PURE__ */ new WeakMap(),
778
+ consumedPendingQueues: [],
779
+ onRecoverableError: options.onRecoverableError ?? noop,
780
+ onUncaughtError: options.onUncaughtError ?? null,
781
+ recoverableErrors: [],
782
+ uncaughtErrorInfo: null,
783
+ commitEffectPhases: 0,
784
+ needsCommitDeletions: false,
785
+ commitIndex: createCommitIndex(),
786
+ committedCaughtErrors: [],
787
+ isHydrating: false,
788
+ isHydrationRoot: false,
789
+ hydrationParent: null,
790
+ hydratingSuspenseBoundary: null,
791
+ hydratingActivityBoundary: null,
792
+ dehydratedSuspenseCount: 0,
793
+ dehydratedBoundaries: /* @__PURE__ */ new Map(),
794
+ needsRootHydrationCompletion: false,
795
+ nextHydratableInstance: null,
796
+ clearContainerBeforeCommit: false,
797
+ hydrationInitialElement: NoHydrationInitialElement
798
+ };
799
+ if (options.initialData !== void 0) dataStore.hydrate(options.initialData);
800
+ current.stateNode = root;
801
+ return root;
802
+ }
803
+ function duplicateRootError(kind) {
804
+ return /* @__PURE__ */ new Error(`Cannot call ${kind === "hydration" ? "hydrateRoot" : "createRoot"} on a container that already has a Fig root. Use the existing root.render(...) to update it instead.`);
805
+ }
806
+ function noop() {}
807
+ function rootHandle(root) {
808
+ let unmounted = false;
809
+ return {
810
+ data: root.dataStore,
811
+ render: (children) => {
812
+ if (unmounted) throw new Error("Cannot update an unmounted root.");
813
+ updateRoot(root, children);
814
+ },
815
+ unmount: () => {
816
+ if (unmounted) return;
817
+ unmounted = true;
818
+ flushSync(() => updateRoot(root, null));
819
+ root.dataStore.dispose();
820
+ if (roots.get(root.container) === root) roots.delete(root.container);
821
+ mountedRoots.delete(root);
822
+ }
823
+ };
824
+ }
825
+ function hydrateTarget(container, target, priority = "default") {
826
+ const lane = hydrationLaneForPriority(priority);
827
+ const root = roots.get(container);
828
+ if (root === void 0) return "none";
829
+ if (rootShellPendingHydration(root)) {
830
+ if (isSyncLane(lane)) performRoot(root, true);
831
+ if (rootShellPendingHydration(root)) return "blocked";
832
+ }
833
+ if (root.dehydratedSuspenseCount === 0) return "none";
834
+ const boundary = dehydratedBoundaryForTarget(root, target);
835
+ if (boundary === null) return "none";
836
+ scheduleFiber(boundary, lane);
837
+ if (isSyncLane(lane)) performRoot(root, true);
838
+ return dehydratedBoundaryForTarget(root, target) === null ? "hydrated" : "blocked";
839
+ }
840
+ function rootShellPendingHydration(root) {
841
+ return root.needsRootHydrationCompletion && root.current.child === null;
842
+ }
843
+ function dehydratedBoundaryForTarget(root, target) {
844
+ if (host.getEnclosingSuspenseBoundaryStart === void 0) return findDehydratedSuspenseBoundaryForTarget(root.current.child, target);
845
+ let start = host.getEnclosingSuspenseBoundaryStart(target);
846
+ while (start !== null) {
847
+ const fiber = root.dehydratedBoundaries.get(start) ?? null;
848
+ if (fiberSuspenseState(fiber)?.kind === "dehydrated") return fiber;
849
+ start = host.getEnclosingSuspenseBoundaryStart(start);
850
+ }
851
+ return null;
852
+ }
853
+ function flushSync(callback) {
854
+ if (renderingFiber !== null) throw new Error("flushSync cannot be called while rendering a component.");
855
+ try {
856
+ return runWithPriority(2, callback);
857
+ } finally {
858
+ flushSyncWork();
859
+ }
860
+ }
861
+ function flushSyncWork() {
862
+ if (commitDepth > 0) {
863
+ needsPostCommitSyncFlush = true;
864
+ return;
865
+ }
866
+ const previousFlushingSyncWork = flushingSyncWork;
867
+ flushingSyncWork = true;
868
+ try {
869
+ for (const root of pendingRoots) if (root.pendingLanes !== 0) {
870
+ root.callback?.cancel();
871
+ root.callback = null;
872
+ root.callbackPriority = 0;
873
+ performRoot(root, true);
874
+ } else pendingRoots.delete(root);
875
+ } finally {
876
+ flushingSyncWork = previousFlushingSyncWork;
877
+ }
878
+ }
879
+ function flushPostCommitSyncWork() {
880
+ if (commitDepth > 0 || !needsPostCommitSyncFlush || flushingPostCommitSyncWork) return;
881
+ flushingPostCommitSyncWork = true;
882
+ try {
883
+ do {
884
+ nestedPostCommitSyncFlushes += 1;
885
+ if (nestedPostCommitSyncFlushes > nestedPostCommitSyncFlushLimit) throw new Error("Maximum update depth exceeded.");
886
+ needsPostCommitSyncFlush = false;
887
+ flushSyncWork();
888
+ } while (needsPostCommitSyncFlush);
889
+ } finally {
890
+ nestedPostCommitSyncFlushes = 0;
891
+ flushingPostCommitSyncWork = false;
892
+ }
893
+ }
894
+ function batchedUpdates(callback) {
895
+ batchDepth += 1;
896
+ try {
897
+ return callback();
898
+ } finally {
899
+ batchDepth -= 1;
900
+ if (batchDepth === 0) {
901
+ for (const root of batchedRoots) scheduleRoot(root);
902
+ batchedRoots.clear();
903
+ }
904
+ }
905
+ }
906
+ function updateRoot(root, children) {
907
+ if (shouldClientRenderEarlyHydrationUpdate(root, children)) forceClientRender(root);
908
+ const lane = requestUpdateLane();
909
+ root.element = children;
910
+ markRootPending(root, lane);
911
+ scheduleOrBatchRoot(root);
912
+ }
913
+ function markRootPending(root, lane) {
914
+ markRootUpdated(root, lane);
915
+ pendingRoots.add(root);
916
+ if (currentCommitEffectPhase === 1 && isSyncLane(lane)) needsPostCommitSyncFlush = true;
917
+ }
918
+ function markCommitEffectPhase(root, phase) {
919
+ root.commitEffectPhases |= 1 << phase;
920
+ }
921
+ function scheduleOrBatchRoot(root) {
922
+ if (batchDepth > 0) batchedRoots.add(root);
923
+ else scheduleRoot(root);
924
+ }
925
+ function scheduleRoot(root) {
926
+ if (root.pendingViewTransitionCommit) return;
927
+ markStarvedLanesAsExpired(root, now());
928
+ const nextLanes = getNextLanes(root, root.renderLanes);
929
+ if (nextLanes === 0) {
930
+ if (root.pendingLanes === 0) pendingRoots.delete(root);
931
+ return;
932
+ }
933
+ const priorityLane = getHighestPriorityLane(nextLanes);
934
+ if (root.callback !== null && root.callbackPriority === priorityLane) return;
935
+ root.callback?.cancel();
936
+ root.callbackPriority = priorityLane;
937
+ root.callback = scheduleCallback(getLaneSchedulerPriority(priorityLane), () => {
938
+ performRoot(root, isSyncLane(priorityLane));
939
+ });
940
+ }
941
+ function performRoot(root, forceSync) {
942
+ try {
943
+ performRootWork(root, forceSync);
944
+ } catch (error) {
945
+ if (error === PreservedSuspense) {
946
+ restartRootWork(root);
947
+ scheduleRoot(root);
948
+ return;
949
+ }
950
+ if (error instanceof HydrationMismatchError) {
951
+ recoverFromHydrationMismatch(root);
952
+ return;
953
+ }
954
+ if (isThenable(error)) {
955
+ const suspendedLanes = root.renderLanes;
956
+ restartRootWork(root);
957
+ markRootSuspended(root, suspendedLanes);
958
+ attachPing(root, error, suspendedLanes);
959
+ scheduleRoot(root);
960
+ return;
961
+ }
962
+ const info = root.uncaughtErrorInfo ?? errorInfoFor(root.current, error);
963
+ restartRootWork(root);
964
+ clearRootAfterUncaughtError(root);
965
+ reportUncaughtError(root, error, info);
966
+ if (flushingSyncWork) throw error;
967
+ if (root.onUncaughtError === null) setTimeout(() => {
968
+ throw error;
969
+ });
970
+ }
971
+ }
972
+ function recoverFromHydrationMismatch(root) {
973
+ if (root.hydratingSuspenseBoundary !== null) {
974
+ recoverFromSuspenseHydrationMismatch(root, root.hydratingSuspenseBoundary);
975
+ return;
976
+ }
977
+ markHydrationRecovery(root, "root");
978
+ restartRootWork(root);
979
+ forceClientRender(root);
980
+ performRoot(root, true);
981
+ }
982
+ function recoverFromSuspenseHydrationMismatch(root, boundary) {
983
+ const current = boundary.alternate ?? boundary;
984
+ const state = fiberSuspenseState(current);
985
+ restartRootWork(root);
986
+ if (state?.kind !== "dehydrated") {
987
+ markHydrationRecovery(root, "root");
988
+ forceClientRender(root);
989
+ performRoot(root, true);
990
+ return;
991
+ }
992
+ markHydrationRecovery(root, "suspense");
993
+ state.boundary.forceClientRender = true;
994
+ deactivateHydration(root);
995
+ scheduleFiber(current, SelectiveHydrationLane);
996
+ performRoot(root, true);
997
+ }
998
+ function markHydrationRecovery(root, recovery) {
999
+ for (const record of root.recoverableErrors) if (record.info.source === "hydration") record.info.recovery = recovery;
1000
+ }
1001
+ function shouldClientRenderEarlyHydrationUpdate(root, children) {
1002
+ return root.isHydrating && root.current.child === null && root.hydrationInitialElement !== NoHydrationInitialElement && root.hydrationInitialElement !== children;
1003
+ }
1004
+ function forceClientRender(root) {
1005
+ deactivateHydration(root);
1006
+ root.clearContainerBeforeCommit = true;
1007
+ root.hydrationInitialElement = NoHydrationInitialElement;
1008
+ }
1009
+ function performRootWork(root, forceSync) {
1010
+ if (root.pendingViewTransitionCommit) return;
1011
+ if (root.pendingLanes === 0 && root.wip === null) {
1012
+ pendingRoots.delete(root);
1013
+ return;
1014
+ }
1015
+ flushPendingReactiveEffects(root);
1016
+ if (root.parkedViewTransitionCommit) {
1017
+ root.parkedViewTransitionCommit = false;
1018
+ if (!((root.pendingLanes & ~root.renderLanes) !== 0) && root.wip === null && root.finishedWork !== null) {
1019
+ if (commitRoot(root, root.finishedWork)) return;
1020
+ finishRootWork(root);
1021
+ flushPostCommitSyncWork();
1022
+ return;
1023
+ }
1024
+ restartRootWork(root);
1025
+ }
1026
+ const nextLanes = getNextLanes(root, root.renderLanes);
1027
+ if (nextLanes === 0 && root.wip === null) {
1028
+ root.callback = null;
1029
+ root.callbackPriority = 0;
1030
+ return;
1031
+ }
1032
+ if (root.wip !== null && nextLanes !== 0 && nextLanes !== root.renderLanes) restartRootWork(root);
1033
+ if (root.wip === null) {
1034
+ root.renderLanes = nextLanes;
1035
+ root.consumedPendingQueues = [];
1036
+ resetContextStack(root);
1037
+ root.finishedWork = createWorkInProgress(root.current, { children: root.element });
1038
+ root.wip = root.finishedWork;
1039
+ prepareToHydrateRoot(root);
1040
+ }
1041
+ while (root.wip !== null && (forceSync || isSyncLane(getHighestPriorityLane(root.renderLanes)) || !shouldYieldToHost())) root.wip = performUnit(root.wip);
1042
+ if (root.wip !== null) {
1043
+ root.callback = null;
1044
+ root.callbackPriority = 0;
1045
+ scheduleRoot(root);
1046
+ return;
1047
+ }
1048
+ if (root.finishedWork !== null && commitRoot(root, root.finishedWork)) return;
1049
+ finishRootWork(root);
1050
+ flushPostCommitSyncWork();
1051
+ }
1052
+ function finishRootWork(root) {
1053
+ resetRootWork(root);
1054
+ if (root.pendingLanes !== 0) scheduleRoot(root);
1055
+ else pendingRoots.delete(root);
1056
+ }
1057
+ function restartRootWork(root) {
1058
+ restoreConsumedPendingQueues(root);
1059
+ resetRootWork(root);
1060
+ }
1061
+ function resetRootWork(root) {
1062
+ const wasHydratingCompletedBoundary = root.hydrationInitialElement === NoHydrationInitialElement && (root.hydratingSuspenseBoundary !== null || root.hydratingActivityBoundary !== null);
1063
+ root.wip = null;
1064
+ root.finishedWork = null;
1065
+ root.renderLanes = 0;
1066
+ root.callback = null;
1067
+ root.callbackPriority = 0;
1068
+ if (root.pendingSuspenseRetries.length > 0) root.pendingSuspenseRetries = [];
1069
+ clearCommitIndex(root.commitIndex);
1070
+ resetHydrationPointers(root);
1071
+ resetContextStack(root);
1072
+ if (wasHydratingCompletedBoundary) root.isHydrating = false;
1073
+ root.uncaughtErrorInfo = null;
1074
+ }
1075
+ function resetHydrationPointers(root) {
1076
+ root.hydrationParent = null;
1077
+ root.hydratingSuspenseBoundary = null;
1078
+ root.hydratingActivityBoundary = null;
1079
+ root.nextHydratableInstance = null;
1080
+ }
1081
+ function deactivateHydration(root) {
1082
+ root.isHydrating = false;
1083
+ resetHydrationPointers(root);
1084
+ }
1085
+ function performUnit(node) {
1086
+ try {
1087
+ begin(node);
1088
+ } catch (error) {
1089
+ return handleThrownValue(node, error);
1090
+ }
1091
+ if ((node.flags & 16) === 0 && node.child !== null) return node.child;
1092
+ return completeUnit(node);
1093
+ }
1094
+ function handleThrownValue(node, error) {
1095
+ const root = rootOf(node);
1096
+ if (root.hydratingActivityBoundary !== null) abandonActivityHydration(root, error instanceof HydrationMismatchError);
1097
+ if (isThenable(error)) {
1098
+ const boundary = findSuspenseBoundary(node);
1099
+ if (boundary !== null) {
1100
+ unwindContextTo(root, boundary);
1101
+ return captureSuspenseBoundary(boundary, error);
1102
+ }
1103
+ unwindContextTo(root, null);
1104
+ throw error;
1105
+ }
1106
+ if (error instanceof HydrationMismatchError) {
1107
+ unwindContextTo(root, null);
1108
+ throw error;
1109
+ }
1110
+ const boundary = findErrorBoundary(node);
1111
+ if (boundary !== null) {
1112
+ unwindContextTo(root, boundary);
1113
+ return captureErrorBoundary(boundary, error, node);
1114
+ }
1115
+ unwindContextTo(root, null);
1116
+ rootOf(node).uncaughtErrorInfo = errorInfoFor(node, error);
1117
+ throw error;
1118
+ }
1119
+ function completeUnit(node) {
1120
+ let next = node;
1121
+ while (next !== null) {
1122
+ complete(next);
1123
+ if (next.sibling !== null) return next.sibling;
1124
+ next = next.return;
1125
+ }
1126
+ return null;
1127
+ }
1128
+ function begin(node) {
1129
+ const root = rootOf(node);
1130
+ if (node.tag === 6 || node.tag === 7) node.commitIndexCheckpoint = commitIndexCheckpoint(root.commitIndex);
1131
+ if (canBailout(node, root)) {
1132
+ let hasChildWork = includesSomeLane(node.childLanes, root.renderLanes);
1133
+ if (!hasChildWork) hasChildWork = lazilyPropagateParentContextChanges(node, root);
1134
+ if (!hasChildWork) {
1135
+ node.flags |= 16;
1136
+ node.child = node.alternate?.child ?? null;
1137
+ return;
1138
+ }
1139
+ if (node.tag !== 6) {
1140
+ if (node.tag === 5) pushContextProvider(node, root);
1141
+ cloneChildFibers(node);
1142
+ return;
1143
+ }
1144
+ }
1145
+ if (node.tag === 5) pushContextProvider(node, root);
1146
+ const hasOwnWork = includesSomeLane(node.lanes, root.renderLanes);
1147
+ node.lanes &= ~root.renderLanes;
1148
+ if (node.tag === 3) {
1149
+ renderFunction(node, root);
1150
+ return;
1151
+ }
1152
+ if (node.tag === 2) {
1153
+ if (tryHydrateText(node, root)) return;
1154
+ node.stateNode ??= host.createTextInstance(String(node.props.nodeValue));
1155
+ return;
1156
+ }
1157
+ if (node.tag === 1) {
1158
+ const type = String(node.type);
1159
+ const children = hostChildren(node.props);
1160
+ if (tryHydrateInstance(node, root)) {
1161
+ reconcileCurrentChildren(node, children, root);
1162
+ return;
1163
+ }
1164
+ node.stateNode ??= host.createInstance(type, node.props, hostParent(node));
1165
+ reconcileCurrentChildren(node, children === null || shouldUseHostTextContent(node, root) ? null : children, root);
1166
+ return;
1167
+ }
1168
+ if (node.tag === 6) {
1169
+ beginSuspense(node, hasOwnWork);
1170
+ return;
1171
+ }
1172
+ if (node.tag === 7) {
1173
+ beginErrorBoundary(node);
1174
+ return;
1175
+ }
1176
+ if (node.tag === 10 && node.type === null) {
1177
+ beginHiddenBoundary(root, node);
1178
+ return;
1179
+ }
1180
+ if (node.tag === 10) {
1181
+ beginActivity(root, node);
1182
+ return;
1183
+ }
1184
+ if (node.tag === 11) {
1185
+ beginViewTransition(node);
1186
+ return;
1187
+ }
1188
+ if (node.tag === 8) {
1189
+ beginPortal(node);
1190
+ return;
1191
+ }
1192
+ reconcileCurrentChildren(node, node.props.children, root);
1193
+ }
1194
+ function beginViewTransition(node) {
1195
+ node.stateNode ??= { autoName: null };
1196
+ reconcileCurrentChildren(node, node.props.children);
1197
+ }
1198
+ function beginActivity(root, node) {
1199
+ const hidden = activityHidden(node.props);
1200
+ if (hidden) hasHiddenBoundaries = true;
1201
+ const state = ensureFiberActivityState(node);
1202
+ if (state.dehydrated === null && tryDehydrateActivityBoundary(root, node, state)) {
1203
+ if (!hidden) scheduleFiber(node, 32);
1204
+ return;
1205
+ }
1206
+ if (state.dehydrated !== null) {
1207
+ if (hidden) return;
1208
+ hydrateDehydratedActivityBoundary(root, node);
1209
+ return;
1210
+ }
1211
+ beginHiddenBoundary(root, node);
1212
+ }
1213
+ function beginHiddenBoundary(root, node) {
1214
+ const hidden = activityHidden(node.props);
1215
+ if (hidden) hasHiddenBoundaries = true;
1216
+ const hiddenState = node.hiddenState;
1217
+ const previousHidden = node.alternate === null ? false : activityHidden(node.alternate.memoizedProps ?? {});
1218
+ ensureFiberActivityState(node);
1219
+ if (hidden !== previousHidden) node.flags |= 32;
1220
+ if (!hidden && hiddenState?.currentFirstChild != null) node.flags |= 32;
1221
+ if (!hidden && previousHidden) {
1222
+ markSubtreeLanes(node.alternate?.child ?? null, root.renderLanes);
1223
+ if (includesSomeLane(node.childLanes, 536870912) && !includesSomeLane(root.renderLanes, 536870912)) root.renderLanes = mergeLanes(root.renderLanes, OffscreenLane);
1224
+ }
1225
+ reconcile(node, node.props.children, hiddenState?.currentFirstChild ?? node.alternate?.child ?? null, hiddenState?.currentFirstChild != null && node.alternate === null);
1226
+ node.hiddenState = null;
1227
+ }
1228
+ function prepareToHydrateRoot(root) {
1229
+ if (!root.isHydrating) return;
1230
+ const hydrationHost = requireHydrationHostConfig();
1231
+ root.hydrationParent = root.finishedWork;
1232
+ root.nextHydratableInstance = hydrationHost.getFirstHydratableChild(root.container);
1233
+ }
1234
+ function tryHydrateInstance(node, root) {
1235
+ if (!shouldHydrateFiber(root, node)) return false;
1236
+ const hydrationHost = requireHydrationHostConfig();
1237
+ const hydratable = root.nextHydratableInstance;
1238
+ const type = String(node.type);
1239
+ if (isHoistedFiber(node)) {
1240
+ node.flags |= 1;
1241
+ return false;
1242
+ }
1243
+ if (hydratable === null || !hydrationHost.canHydrateInstance(hydratable, type, node.props)) throwHydrationMismatch(root, node, `<${type}>`);
1244
+ node.stateNode = hydratable;
1245
+ recordCommitWork(root.commitIndex, node, 6);
1246
+ root.hydrationParent = node;
1247
+ root.nextHydratableInstance = hydrationHost.getFirstHydratableChild(hydratable, node.props);
1248
+ return true;
1249
+ }
1250
+ function tryHydrateText(node, root) {
1251
+ if (!shouldHydrateFiber(root, node)) return false;
1252
+ const hydrationHost = requireHydrationHostConfig();
1253
+ const hydratable = root.nextHydratableInstance;
1254
+ const text = String(node.props.nodeValue);
1255
+ const suppressHydrationWarning = node.return?.tag === 1 && node.return.props.suppressHydrationWarning === true || canHydratePendingSuspenseTextMismatch(root);
1256
+ if (hydratable === null || !hydrationHost.canHydrateTextInstance(hydratable, text, suppressHydrationWarning)) throwHydrationMismatch(root, node, "text");
1257
+ node.stateNode = hydratable;
1258
+ recordCommitWork(root.commitIndex, node, 2);
1259
+ root.nextHydratableInstance = hydrationHost.getNextHydratableSibling(hydratable);
1260
+ return true;
1261
+ }
1262
+ function shouldHydrateFiber(root, node) {
1263
+ return root.isHydrating && node.alternate === null && node.stateNode === null && !insideHydrationExemptHost(node);
1264
+ }
1265
+ function insideHydrationExemptHost(node) {
1266
+ for (let parent = node.return; parent !== null && parent.alternate === null; parent = parent.return) {
1267
+ if (parent.tag !== 1) continue;
1268
+ return hydrationBypassedHost(parent);
1269
+ }
1270
+ return false;
1271
+ }
1272
+ function completeHydration(node) {
1273
+ const root = rootOf(node);
1274
+ if (node.tag === 6 && (node.flags & 4) !== 0 && root.hydratingSuspenseBoundary === node) {
1275
+ completeDehydratedSuspenseHydration(root, node);
1276
+ return;
1277
+ }
1278
+ if (node.tag === 10 && (node.flags & 4) !== 0 && root.hydratingActivityBoundary === node) {
1279
+ if (root.nextHydratableInstance !== null) throwHydrationMismatch(root, node, void 0, " in Activity");
1280
+ leaveActivityHydration(root, node);
1281
+ return;
1282
+ }
1283
+ if (!root.isHydrating || root.hydrationParent !== node) return;
1284
+ if (root.nextHydratableInstance !== null) throwHydrationMismatch(root, node);
1285
+ const hydrationHost = requireHydrationHostConfig();
1286
+ root.hydrationParent = nextHydrationParent(node.return);
1287
+ root.nextHydratableInstance = node.tag === 1 ? hydrationHost.getNextHydratableSibling(node.stateNode) : null;
1288
+ }
1289
+ function completeDehydratedSuspenseHydration(root, node) {
1290
+ const boundary = dehydratedSuspenseBoundary(node.alternate);
1291
+ if (boundary === null) return;
1292
+ if (boundary.status === "completed" && !boundary.forceClientRender && root.nextHydratableInstance !== boundary.end) throwHydrationMismatch(root, node, void 0, " in Suspense", boundary.id ?? void 0);
1293
+ leaveSuspenseHydration(root, node, boundary);
1294
+ }
1295
+ function nextHydrationParent(node) {
1296
+ for (let parent = node; parent !== null; parent = parent.return) if (parent.tag === 0 || parent.tag === 1 || parent.tag === 6 && (parent.flags & 4) !== 0 && dehydratedSuspenseBoundary(parent.alternate) !== null || parent.tag === 10 && (parent.flags & 4) !== 0 && fiberActivityState(parent)?.dehydrated != null) return parent;
1297
+ return null;
1298
+ }
1299
+ function firstWithinSuspenseBoundary(boundary) {
1300
+ const first = requireHydrationHostConfig().getNextHydratableSibling(boundary.start);
1301
+ return first === boundary.end ? null : first;
1302
+ }
1303
+ function nextAfterSuspenseBoundary(boundary) {
1304
+ return requireHydrationHostConfig().getNextHydratableSibling(boundary.end);
1305
+ }
1306
+ function requireHydrationHostConfig() {
1307
+ if (host.getFirstHydratableChild === void 0 || host.getNextHydratableSibling === void 0 || host.canHydrateInstance === void 0 || host.canHydrateTextInstance === void 0 || host.clearContainer === void 0) throw new Error("Hydration is not supported by this renderer.");
1308
+ return host;
1309
+ }
1310
+ function throwHydrationMismatch(root, node, expected, where = "", boundaryId) {
1311
+ const nothing = root.nextHydratableInstance === null;
1312
+ const message = expected === void 0 ? `found an extra DOM node${where}` : nothing ? `expected ${expected}, but found no DOM node` : `expected ${expected}`;
1313
+ const error = /* @__PURE__ */ new Error(`Hydration mismatch: ${message}.`);
1314
+ queueRecoverableError(root, node, error, {
1315
+ actual: expected === void 0 ? "extra DOM node" : nothing ? "nothing" : "different DOM node",
1316
+ boundaryId,
1317
+ expected,
1318
+ recovery: "root",
1319
+ source: "hydration"
1320
+ });
1321
+ throw new HydrationMismatchError(error.message);
1322
+ }
1323
+ function canBailout(node, root) {
1324
+ return node.alternate !== null && (node.flags & 1) === 0 && node.props === node.alternate.memoizedProps && !includesSomeLane(node.lanes, root.renderLanes) && !contextDependenciesChanged(node, root);
1325
+ }
1326
+ function contextDependenciesChanged(node, root) {
1327
+ const dependencies = node.contextDependencies;
1328
+ if (dependencies === null) return false;
1329
+ for (const dependency of dependencies) if (!Object.is(currentContextValue(root, dependency.context), dependency.memoizedValue)) return true;
1330
+ return false;
1331
+ }
1332
+ function currentContextValue(root, context) {
1333
+ return root.contextValues.has(context) ? root.contextValues.get(context) : context.defaultValue;
1334
+ }
1335
+ function shouldUseHostTextContent(node, root = rootOf(node)) {
1336
+ return host.setTextContent !== void 0 && (!root.isHydrating || hydrationBypassedHost(node)) && !adoptedSingleTextChild(node) && hostTextContent(node.props.children) !== null;
1337
+ }
1338
+ function adoptedSingleTextChild(node) {
1339
+ const child = node.alternate?.child ?? node.child;
1340
+ return child !== null && child.tag === 2 && child.sibling === null;
1341
+ }
1342
+ function hydrationBypassedHost(node) {
1343
+ return node.alternate === null && node.stateNode !== null && (node.flags & 4) === 0;
1344
+ }
1345
+ function isHoistedFiber(node) {
1346
+ if (node.tag !== 1 || host.isHoistedInstance === void 0) return false;
1347
+ if ((node.flags & 8192) !== 0) return false;
1348
+ if (!host.isHoistedInstance(String(node.type), node.props)) {
1349
+ node.flags |= NotHoistedFlag;
1350
+ return false;
1351
+ }
1352
+ requireHoistedAssetHostConfig();
1353
+ return true;
1354
+ }
1355
+ function requireHoistedAssetHostConfig() {
1356
+ if (hoistedAssetHostConfig !== null) return hoistedAssetHostConfig;
1357
+ if (host.isHoistedInstance === void 0 || host.commitHoistedInstance === void 0 || host.removeHoistedInstance === void 0 || host.updateHoistedInstance === void 0) throw new Error("Hoisted assets are not supported by this renderer.");
1358
+ hoistedAssetHostConfig = host;
1359
+ return hoistedAssetHostConfig;
1360
+ }
1361
+ function renderFunction(node, root) {
1362
+ prepareHookRender(node, root);
1363
+ const previousDispatcher = setCurrentDispatcher(dispatcher);
1364
+ const previousDataStore = setCurrentDataStore(root.dataStore);
1365
+ try {
1366
+ reconcileCurrentChildren(node, node.type(node.props), root);
1367
+ if (currentHook !== null) throw hookOrderError("fewer");
1368
+ } finally {
1369
+ setCurrentDataStore(previousDataStore);
1370
+ setCurrentDispatcher(previousDispatcher);
1371
+ renderingFiber = null;
1372
+ currentHook = null;
1373
+ workInProgressHook = null;
1374
+ localIdCounter = 0;
1375
+ }
1376
+ }
1377
+ function prepareHookRender(node, root) {
1378
+ renderingFiber = node;
1379
+ currentHook = node.alternate?.memoizedState ?? null;
1380
+ workInProgressHook = null;
1381
+ localIdCounter = 0;
1382
+ node.memoizedState = null;
1383
+ node.contextDependencies = null;
1384
+ root.dataStore.resetDataDependencies(node);
1385
+ node.dataDependenciesDirty = true;
1386
+ recordCommitWork(root.commitIndex, node);
1387
+ }
1388
+ function beginSuspense(node, hasOwnWork) {
1389
+ const root = rootOf(node);
1390
+ const previousSuspenseState = fiberSuspenseState(node.alternate);
1391
+ node.boundaryState = null;
1392
+ if (previousSuspenseState?.kind === "dehydrated") {
1393
+ if (!hasOwnWork) {
1394
+ node.boundaryState = previousSuspenseState;
1395
+ return;
1396
+ }
1397
+ hydrateDehydratedSuspenseBoundary(node, previousSuspenseState.boundary);
1398
+ return;
1399
+ }
1400
+ if (tryDehydrateSuspenseBoundary(node)) return;
1401
+ node.suspenseQueueStart = root.consumedPendingQueues.length;
1402
+ if (previousSuspenseState === null) {
1403
+ beginSuspensePrimary(node, suspensePrimaryFiber(node.alternate));
1404
+ return;
1405
+ }
1406
+ const currentPrimary = suspensePrimaryFiber(node.alternate);
1407
+ if (currentPrimary !== null) markSubtreeLanes(currentPrimary.child, root.renderLanes);
1408
+ beginSuspensePrimary(node, currentPrimary, previousSuspenseState.primaryChild);
1409
+ appendDeletions(node, suspenseFallbackFiber(node.alternate));
1410
+ }
1411
+ function markSubtreeLanes(node, lanes) {
1412
+ for (let child = node; child !== null; child = child.sibling) {
1413
+ child.lanes = mergeLanes(child.lanes, lanes);
1414
+ child.childLanes = mergeLanes(child.childLanes, lanes);
1415
+ markSubtreeLanes(child.child, lanes);
1416
+ }
1417
+ }
1418
+ function beginSuspensePrimary(boundary, currentPrimary, capturedPrimary = null) {
1419
+ if (capturedPrimary !== null) hasHiddenBoundaries = true;
1420
+ boundary.child = suspensePrimaryWorkInProgress(boundary, currentPrimary, "visible", capturedPrimary);
1421
+ }
1422
+ function suspensePrimaryWorkInProgress(boundary, currentPrimary, mode, capturedPrimary = null) {
1423
+ const props = {
1424
+ mode,
1425
+ children: boundary.props.children
1426
+ };
1427
+ const primary = currentPrimary === null ? fiber(10, null, null, props, null) : createWorkInProgress(currentPrimary, props);
1428
+ primary.hiddenState = { currentFirstChild: capturedPrimary };
1429
+ primary.index = 0;
1430
+ primary.return = boundary;
1431
+ primary.sibling = null;
1432
+ return primary;
1433
+ }
1434
+ function suspenseFallbackWorkInProgress(boundary, currentFallback, index) {
1435
+ const props = { children: boundary.props.fallback };
1436
+ const fallback = currentFallback?.tag === 4 ? createWorkInProgress(currentFallback, props) : fiber(4, null, null, props, null);
1437
+ fallback.index = index;
1438
+ fallback.return = boundary;
1439
+ fallback.sibling = null;
1440
+ if (currentFallback === null) fallback.flags |= 1;
1441
+ return fallback;
1442
+ }
1443
+ function suspensePrimaryFiber(node) {
1444
+ const child = node?.child ?? null;
1445
+ return child?.tag === 10 && child.type === null ? child : null;
1446
+ }
1447
+ function suspenseFallbackFiber(node) {
1448
+ const primary = suspensePrimaryFiber(node);
1449
+ return primary === null ? node?.child ?? null : primary.sibling;
1450
+ }
1451
+ function cloneSuspendedPrimary(node, parent) {
1452
+ let first = null;
1453
+ let previous = null;
1454
+ for (let current = node; current !== null; current = current.sibling) {
1455
+ const clone = createWorkInProgress(current, current.props);
1456
+ clone.return = parent;
1457
+ clone.child = cloneSuspendedPrimary(current.child, clone);
1458
+ clone.sibling = null;
1459
+ clone.lanes = 0;
1460
+ clone.childLanes = 0;
1461
+ if (previous === null) first = clone;
1462
+ else previous.sibling = clone;
1463
+ previous = clone;
1464
+ }
1465
+ return first;
1466
+ }
1467
+ function tryDehydrateSuspenseBoundary(node) {
1468
+ const root = rootOf(node);
1469
+ if (!shouldHydrateFiber(root, node)) return false;
1470
+ if (host.getSuspenseBoundary === void 0) return false;
1471
+ const hydratable = root.nextHydratableInstance;
1472
+ if (hydratable === null) return false;
1473
+ const boundary = host.getSuspenseBoundary(hydratable);
1474
+ if (boundary === null) return false;
1475
+ node.boundaryState = {
1476
+ boundary,
1477
+ kind: "dehydrated",
1478
+ wasPending: boundary.status === "pending"
1479
+ };
1480
+ host.registerSuspenseBoundaryRetry?.(boundary, () => scheduleFiber(node, 32));
1481
+ root.nextHydratableInstance = nextAfterSuspenseBoundary(boundary);
1482
+ return true;
1483
+ }
1484
+ function hydrateDehydratedSuspenseBoundary(node, boundary) {
1485
+ abandonedHydrationBoundaries.delete(node);
1486
+ if (node.alternate !== null) abandonedHydrationBoundaries.delete(node.alternate);
1487
+ if (!boundary.forceClientRender) {
1488
+ if (boundary.status === "completed") {
1489
+ enterSuspenseHydration(node, boundary);
1490
+ node.boundaryState = null;
1491
+ node.flags |= 4;
1492
+ beginSuspensePrimary(node, suspensePrimaryFiber(node.alternate));
1493
+ return;
1494
+ }
1495
+ if (boundary.status === "pending") {
1496
+ node.boundaryState = {
1497
+ boundary,
1498
+ kind: "dehydrated",
1499
+ wasPending: true
1500
+ };
1501
+ return;
1502
+ }
1503
+ }
1504
+ if (boundary.status === "client-rendered") queueClientRenderedSuspenseError(rootOf(node), node, boundary);
1505
+ node.boundaryState = null;
1506
+ node.flags |= 4;
1507
+ beginSuspensePrimary(node, suspensePrimaryFiber(node.alternate));
1508
+ }
1509
+ function queueClientRenderedSuspenseError(root, node, boundary) {
1510
+ const boundaryError = boundary.error;
1511
+ const error = new Error(boundaryError?.message ?? "The server could not finish this Suspense boundary. Switched to client rendering.");
1512
+ if (boundaryError?.digest !== void 0) error.digest = boundaryError.digest;
1513
+ queueRecoverableError(root, node, error, {
1514
+ boundaryId: boundary.id ?? void 0,
1515
+ digest: boundaryError?.digest,
1516
+ recovery: "suspense",
1517
+ source: "server"
1518
+ });
1519
+ }
1520
+ function canHydratePendingSuspenseTextMismatch(root) {
1521
+ const boundary = root.hydratingSuspenseBoundary;
1522
+ const state = fiberSuspenseState(boundary?.alternate);
1523
+ return state?.kind === "dehydrated" && state.wasPending;
1524
+ }
1525
+ function requireActivityHydrationHostConfig() {
1526
+ if (activityHydrationHostConfig !== null) return activityHydrationHostConfig;
1527
+ if (host.getActivityBoundary === void 0 || host.getFirstActivityHydratable === void 0 || host.commitHydratedActivityBoundary === void 0) throw new Error("Activity hydration requires getActivityBoundary, getFirstActivityHydratable, and commitHydratedActivityBoundary.");
1528
+ activityHydrationHostConfig = host;
1529
+ return activityHydrationHostConfig;
1530
+ }
1531
+ function tryDehydrateActivityBoundary(root, node, state) {
1532
+ if (!shouldHydrateFiber(root, node)) return false;
1533
+ if (host.getActivityBoundary === void 0) return false;
1534
+ const hydratable = root.nextHydratableInstance;
1535
+ if (hydratable === null) return false;
1536
+ const boundary = host.getActivityBoundary(hydratable);
1537
+ if (boundary === null) return false;
1538
+ requireActivityHydrationHostConfig();
1539
+ hasHiddenBoundaries = true;
1540
+ state.dehydrated = boundary;
1541
+ root.nextHydratableInstance = requireHydrationHostConfig().getNextHydratableSibling(boundary);
1542
+ return true;
1543
+ }
1544
+ function hydrateDehydratedActivityBoundary(root, node) {
1545
+ enterActivityHydration(root, node);
1546
+ node.flags |= 36;
1547
+ reconcile(node, node.props.children, null, false);
1548
+ }
1549
+ function enterActivityHydration(root, node) {
1550
+ const boundary = dehydratedActivityBoundary(node);
1551
+ if (boundary === null) throw new Error("Expected a dehydrated Activity boundary.");
1552
+ root.isHydrating = true;
1553
+ root.hydrationParent = node;
1554
+ root.hydratingActivityBoundary = node;
1555
+ root.nextHydratableInstance = requireActivityHydrationHostConfig().getFirstActivityHydratable(boundary);
1556
+ }
1557
+ function leaveActivityHydration(root, node) {
1558
+ root.hydrationParent = nextHydrationParent(node.return);
1559
+ root.nextHydratableInstance = null;
1560
+ root.hydratingActivityBoundary = null;
1561
+ root.isHydrating = false;
1562
+ }
1563
+ function abandonActivityHydration(root, forceClientRender = false) {
1564
+ if (forceClientRender) {
1565
+ const state = fiberActivityState(root.hydratingActivityBoundary);
1566
+ if (state !== null) state.dehydrated = null;
1567
+ }
1568
+ deactivateHydration(root);
1569
+ }
1570
+ function enterSuspenseHydration(node, boundary) {
1571
+ const root = rootOf(node);
1572
+ root.isHydrating = true;
1573
+ root.hydrationParent = node;
1574
+ root.hydratingSuspenseBoundary = node;
1575
+ root.nextHydratableInstance = firstWithinSuspenseBoundary(boundary);
1576
+ }
1577
+ function leaveSuspenseHydration(root, node, boundary) {
1578
+ root.hydrationParent = nextHydrationParent(node.return);
1579
+ root.nextHydratableInstance = nextAfterSuspenseBoundary(boundary);
1580
+ root.hydratingSuspenseBoundary = null;
1581
+ root.isHydrating = false;
1582
+ }
1583
+ function beginErrorBoundary(node) {
1584
+ const previousErrorState = fiberErrorBoundaryState(node.alternate);
1585
+ node.boundaryState = previousErrorState;
1586
+ reconcileCurrentChildren(node, previousErrorState === null ? node.props.children : errorBoundaryFallback(node, previousErrorState));
1587
+ }
1588
+ function errorBoundaryFallback(node, state) {
1589
+ const fallback = node.props.fallback;
1590
+ return typeof fallback === "function" ? fallback(state.error, state.info) : fallback;
1591
+ }
1592
+ function beginPortal(node) {
1593
+ reconcileCurrentChildren(node, node.props.children);
1594
+ }
1595
+ function updateStateHook(initialState) {
1596
+ const hook = updateQueuedHook(3, initialState);
1597
+ const queue = hook.queue;
1598
+ const fiber = requireRenderingFiber();
1599
+ queue.dispatch ??= (action) => {
1600
+ if (renderingFiber !== null) throw new Error("State updates are not allowed while rendering a component.");
1601
+ scheduleHookUpdate(fiber, queue, action, requestUpdateLane());
1602
+ };
1603
+ return [hook.memoizedState, queue.dispatch];
1604
+ }
1605
+ function updateActionStateHook(action, initialState) {
1606
+ const hook = updateQueuedHook(4, () => createActionState(action, initialState));
1607
+ const queue = hook.queue;
1608
+ const fiber = requireRenderingFiber();
1609
+ const instance = hook.memoizedState.instance;
1610
+ const nextState = {
1611
+ ...hook.memoizedState,
1612
+ action
1613
+ };
1614
+ hook.memoizedState = nextState;
1615
+ if (hook.baseQueue === null) hook.baseState = nextState;
1616
+ else hook.baseState = {
1617
+ ...hook.baseState,
1618
+ action
1619
+ };
1620
+ if (queue.dispatch === null) {
1621
+ const updatePending = (delta, lane) => {
1622
+ scheduleHookUpdate(fiber, queue, (state) => ({
1623
+ ...state,
1624
+ pending: Math.max(0, state.pending + delta)
1625
+ }), lane);
1626
+ };
1627
+ const finish = (lane, error, ...value) => {
1628
+ scheduleHookUpdate(fiber, queue, (state) => ({
1629
+ ...state,
1630
+ error,
1631
+ pending: Math.max(0, state.pending - 1),
1632
+ value: value.length === 0 ? state.value : value[0]
1633
+ }), lane);
1634
+ };
1635
+ queue.dispatch = ((...args) => {
1636
+ if (renderingFiber !== null) throw new Error("Action state updates are not allowed during render.");
1637
+ runLatest(instance, fiber, (signal) => instance.action(instance.value, ...args, signal), updatePending, (lane, value, failed) => {
1638
+ if (failed) finish(lane, value);
1639
+ else finish(lane, NoActionStateError, value);
1640
+ });
1641
+ });
1642
+ }
1643
+ if (hook.memoizedState.error !== NoActionStateError) throw hook.memoizedState.error;
1644
+ return [
1645
+ hook.memoizedState.value,
1646
+ queue.dispatch,
1647
+ hook.memoizedState.pending > 0
1648
+ ];
1649
+ }
1650
+ function updateIdHook() {
1651
+ const fiber = requireRenderingFiber();
1652
+ const oldHook = updateHook(5);
1653
+ const id = oldHook === null ? createFiberId(rootOf(fiber), fiber, localIdCounter) : oldHook.memoizedState;
1654
+ localIdCounter += 1;
1655
+ appendHook(createHook(5, id));
1656
+ return id;
1657
+ }
1658
+ function updateMemoHook(calculate, deps) {
1659
+ requireRenderingFiber();
1660
+ const previous = updateHook(8)?.memoizedState;
1661
+ const state = previous !== void 0 && areHookInputsEqual(deps, previous.deps) ? previous : {
1662
+ deps,
1663
+ value: calculate()
1664
+ };
1665
+ appendHook(createHook(8, state));
1666
+ return state.value;
1667
+ }
1668
+ function updateDeferredValueHook(value, initialValue, hasInitialValue) {
1669
+ const fiber = requireRenderingFiber();
1670
+ const oldHook = updateHook(6);
1671
+ let next = oldHook === null ? initialDeferredValue(value, initialValue, hasInitialValue) : oldHook.memoizedState;
1672
+ if (!Object.is(next, value)) if (isTransitionOrDeferredRender(rootOf(fiber))) next = value;
1673
+ else scheduleFiber(fiber, DeferredLane);
1674
+ appendHook(createHook(6, next));
1675
+ return next;
1676
+ }
1677
+ function initialDeferredValue(value, initialValue, hasInitialValue) {
1678
+ return hasInitialValue ? initialValue : value;
1679
+ }
1680
+ function isTransitionOrDeferredRender(root) {
1681
+ return includesOnlyTransitions(root.renderLanes) || includesSomeLane(root.renderLanes, 1073741824);
1682
+ }
1683
+ function updateTransitionHook() {
1684
+ const hook = updateQueuedHook(9, {
1685
+ instance: {
1686
+ controller: null,
1687
+ generation: 0
1688
+ },
1689
+ pendingCount: 0,
1690
+ start: null
1691
+ });
1692
+ const queue = hook.queue;
1693
+ if (hook.memoizedState.start === null) {
1694
+ const fiber = requireRenderingFiber();
1695
+ const updatePending = (delta, lane) => {
1696
+ scheduleHookUpdate(fiber, queue, (state) => ({
1697
+ ...state,
1698
+ pendingCount: Math.max(0, state.pendingCount + delta)
1699
+ }), lane);
1700
+ };
1701
+ const instance = hook.memoizedState.instance;
1702
+ hook.memoizedState.start = (callback) => {
1703
+ if (renderingFiber !== null) throw new Error("Transitions cannot be started while rendering a component.");
1704
+ runLatest(instance, fiber, callback, updatePending, (lane, value, failed, asynchronous) => {
1705
+ updatePending(-1, lane);
1706
+ if (failed) {
1707
+ if (!asynchronous) throw value;
1708
+ queueMicrotask(() => {
1709
+ throw value;
1710
+ });
1711
+ }
1712
+ });
1713
+ };
1714
+ }
1715
+ return [hook.memoizedState.pendingCount > 0, hook.memoizedState.start];
1716
+ }
1717
+ function runLatest(instance, fiber, run, updatePending, settled) {
1718
+ if (retireRun(instance)) updatePending(-1, 32);
1719
+ const lane = claimNextTransitionLane();
1720
+ const controller = new AbortController();
1721
+ const generation = instance.generation += 1;
1722
+ instance.controller = controller;
1723
+ updatePending(1, 2);
1724
+ const settle = (value, failed, asynchronous) => {
1725
+ if (generation !== instance.generation) return;
1726
+ instance.controller = null;
1727
+ settled(lane, value, failed, asynchronous);
1728
+ };
1729
+ const store = rootOfOrNull(fiber)?.dataStore;
1730
+ let result;
1731
+ try {
1732
+ const invoke = () => runWithTransitionLane(lane, () => run(controller.signal));
1733
+ result = store === void 0 ? invoke() : store.run(invoke);
1734
+ } catch (error) {
1735
+ settle(error, true, false);
1736
+ return;
1737
+ }
1738
+ if (!isThenable(result)) {
1739
+ settle(result, false, false);
1740
+ return;
1741
+ }
1742
+ result.then((value) => settle(value, false, true), (error) => settle(error, true, true));
1743
+ }
1744
+ function requireRenderingFiber() {
1745
+ if (renderingFiber === null) throw new Error("Hooks can only be called while rendering a component.");
1746
+ return renderingFiber;
1747
+ }
1748
+ function updateQueuedHook(kind, initialState) {
1749
+ const fiber = requireRenderingFiber();
1750
+ const oldHook = updateHook(kind);
1751
+ const hook = oldHook === null ? createHook(kind, resolveInitialState(initialState)) : {
1752
+ ...oldHook,
1753
+ next: null
1754
+ };
1755
+ appendHook(hook);
1756
+ const root = rootOf(fiber);
1757
+ const pending = hook.queue.pending;
1758
+ if (pending !== null) hook.baseQueue = consumePendingHookQueue(root, hook, pending);
1759
+ if (hook.baseQueue !== null) processHookQueue(hook, root.renderLanes);
1760
+ return hook;
1761
+ }
1762
+ function updateExternalStoreHook(subscribe, getSnapshot, getServerSnapshot) {
1763
+ const fiber = requireRenderingFiber();
1764
+ const oldHook = updateHook(7);
1765
+ const root = rootOf(fiber);
1766
+ const value = readExternalStoreSnapshot(root, getSnapshot, getServerSnapshot);
1767
+ const state = {
1768
+ getSnapshot,
1769
+ instance: oldHook?.memoizedState.instance ?? {
1770
+ committedSubscribe: null,
1771
+ getSnapshot,
1772
+ owner: null,
1773
+ unsubscribe: null,
1774
+ value
1775
+ },
1776
+ subscribe,
1777
+ value
1778
+ };
1779
+ recordCommitWork(root.commitIndex, fiber, StoreConsistencyFlag);
1780
+ appendHook(createHook(7, state));
1781
+ return value;
1782
+ }
1783
+ function updateStableEventHook(handler) {
1784
+ requireRenderingFiber();
1785
+ const instance = updateHook(10)?.memoizedState.instance ?? createStableEventInstance();
1786
+ appendHook(createHook(10, {
1787
+ instance,
1788
+ next: handler
1789
+ }));
1790
+ return instance.stable;
1791
+ }
1792
+ function createStableEventInstance() {
1793
+ const instance = {
1794
+ controller: null,
1795
+ handler: null,
1796
+ live: false,
1797
+ stable: (...args) => {
1798
+ if (renderingFiber !== null) throw new Error("Stable events cannot be called while rendering a component.");
1799
+ const handler = instance.handler;
1800
+ if (handler === null) throw new Error("Stable events cannot be called before their first commit.");
1801
+ instance.controller?.abort();
1802
+ instance.controller = new AbortController();
1803
+ if (!instance.live) instance.controller.abort();
1804
+ return handler(...args, instance.controller.signal);
1805
+ }
1806
+ };
1807
+ return instance;
1808
+ }
1809
+ function readExternalStoreSnapshot(root, getSnapshot, getServerSnapshot) {
1810
+ if (!root.isHydrating) return getSnapshot();
1811
+ if (getServerSnapshot === void 0) throw new Error("useSyncExternalStore requires getServerSnapshot during hydration.");
1812
+ return getServerSnapshot();
1813
+ }
1814
+ function processHookQueue(hook, renderLanes) {
1815
+ const baseQueue = hook.baseQueue;
1816
+ if (baseQueue === null) return;
1817
+ let state = hook.baseState;
1818
+ let newBaseState = state;
1819
+ let newBaseQueue = null;
1820
+ let update = baseQueue.next;
1821
+ do {
1822
+ if (update.lane !== 0 && !includesSomeLane(renderLanes, update.lane)) {
1823
+ const cloneUpdate = cloneUpdateNode(update);
1824
+ if (newBaseQueue === null) newBaseState = state;
1825
+ newBaseQueue = mergeQueues(newBaseQueue, cloneUpdate);
1826
+ } else {
1827
+ state = typeof update.action === "function" ? update.action(state) : update.action;
1828
+ if (newBaseQueue !== null) {
1829
+ const cloneUpdate = cloneUpdateNode(update);
1830
+ cloneUpdate.lane = 0;
1831
+ newBaseQueue = mergeQueues(newBaseQueue, cloneUpdate);
1832
+ }
1833
+ }
1834
+ update = update.next;
1835
+ } while (update !== baseQueue.next);
1836
+ hook.memoizedState = state;
1837
+ hook.baseState = newBaseQueue === null ? state : newBaseState;
1838
+ hook.baseQueue = newBaseQueue;
1839
+ }
1840
+ function scheduleHookUpdate(fiber, queue, action, lane) {
1841
+ lane = hiddenSubtreeLane(fiber, lane);
1842
+ const update = {
1843
+ action,
1844
+ lane,
1845
+ next: null
1846
+ };
1847
+ update.next = update;
1848
+ queue.pending = mergeQueues(queue.pending, update);
1849
+ scheduleFiber(fiber, lane);
1850
+ }
1851
+ function hiddenSubtreeLane(node, lane) {
1852
+ if (!hasHiddenBoundaries || lane === 536870912) return lane;
1853
+ for (let parent = node.return; parent !== null; parent = parent.return) if (isHiddenBoundaryTag(parent) && fiberActivityState(parent)?.hidden === true) return OffscreenLane;
1854
+ return lane;
1855
+ }
1856
+ function createFiberId(root, fiber, localId) {
1857
+ return `${root.identifierPrefix}fig-${fiberPath(fiber)}-${localId.toString(32)}`;
1858
+ }
1859
+ function fiberPath(fiber) {
1860
+ const parts = [];
1861
+ for (let node = fiber; node !== null && node.tag !== 0; node = node.return) parts.push(node.index.toString(32));
1862
+ return parts.reverse().join("-");
1863
+ }
1864
+ function consumePendingHookQueue(root, hook, pending) {
1865
+ const queue = hook.queue;
1866
+ queue.pending = null;
1867
+ root.consumedPendingQueues.push({
1868
+ queue,
1869
+ pending
1870
+ });
1871
+ return mergeQueues(cloneQueue(hook.baseQueue), cloneQueueNodes(pending));
1872
+ }
1873
+ function appendHook(hook) {
1874
+ if (renderingFiber === null) return;
1875
+ if (workInProgressHook === null) renderingFiber.memoizedState = hook;
1876
+ else workInProgressHook.next = hook;
1877
+ workInProgressHook = hook;
1878
+ }
1879
+ function updateEffectHook(phase, create, deps) {
1880
+ const fiber = requireRenderingFiber();
1881
+ const oldHook = updateHook(phase);
1882
+ const nextDeps = deps ?? null;
1883
+ const previousEffect = oldHook?.memoizedState ?? null;
1884
+ const hasChanged = previousEffect === null || previousEffect.controller === null || previousEffect.controller.signal.aborted || !areHookInputsEqual(nextDeps, previousEffect.deps);
1885
+ const effect = {
1886
+ phase,
1887
+ create,
1888
+ controller: previousEffect?.controller ?? null,
1889
+ deps: nextDeps,
1890
+ owner: fiber,
1891
+ strictRan: __DEV__
1892
+ };
1893
+ appendHook(createHook(phase, effect));
1894
+ if (hasChanged) {
1895
+ fiber.effects ??= [];
1896
+ fiber.effects.push(effect);
1897
+ const root = rootOf(fiber);
1898
+ recordCommitWork(root.commitIndex, fiber, 512);
1899
+ markCommitEffectPhase(root, phase);
1900
+ }
1901
+ }
1902
+ function readContextValue(context) {
1903
+ if (renderingFiber === null) throw new Error("readContext can only be called while rendering a component.");
1904
+ const root = rootOf(renderingFiber);
1905
+ const contextKey = context;
1906
+ const value = currentContextValue(root, contextKey);
1907
+ addContextDependency(renderingFiber, contextKey, value);
1908
+ return value;
1909
+ }
1910
+ function pushContextProvider(node, root = rootOf(node)) {
1911
+ const context = node.type;
1912
+ const values = root.contextValues;
1913
+ const hadPrevious = values.has(context);
1914
+ const previous = values.get(context);
1915
+ values.set(context, node.props.value);
1916
+ root.contextStack.push({
1917
+ context,
1918
+ hadPrevious,
1919
+ previous,
1920
+ provider: node
1921
+ });
1922
+ }
1923
+ function popContextProvider(node) {
1924
+ const root = rootOf(node);
1925
+ const entry = root.contextStack.pop();
1926
+ if (entry === void 0 || entry.provider !== node) {
1927
+ resetContextStack(root);
1928
+ return;
1929
+ }
1930
+ restoreContextEntry(root, entry);
1931
+ }
1932
+ function unwindContextTo(root, node) {
1933
+ while (root.contextStack.length > 0) {
1934
+ const entry = root.contextStack[root.contextStack.length - 1];
1935
+ if (node !== null && isAncestorOf(entry.provider, node)) return;
1936
+ restoreContextEntry(root, root.contextStack.pop());
1937
+ }
1938
+ }
1939
+ function restoreContextEntry(root, entry) {
1940
+ if (entry.hadPrevious) root.contextValues.set(entry.context, entry.previous);
1941
+ else root.contextValues.delete(entry.context);
1942
+ }
1943
+ function resetContextStack(root) {
1944
+ root.contextValues = /* @__PURE__ */ new Map();
1945
+ root.contextStack = [];
1946
+ }
1947
+ function isAncestorOf(ancestor, node) {
1948
+ for (let parent = node; parent !== null; parent = parent.return) if (parent === ancestor) return true;
1949
+ return false;
1950
+ }
1951
+ function addContextDependency(node, context, memoizedValue) {
1952
+ node.contextDependencies ??= [];
1953
+ const dependency = contextDependency(node, context);
1954
+ if (dependency === null) node.contextDependencies.push({
1955
+ context,
1956
+ memoizedValue
1957
+ });
1958
+ else dependency.memoizedValue = memoizedValue;
1959
+ }
1960
+ function contextDependency(node, context) {
1961
+ return node.contextDependencies?.find((dependency) => dependency.context === context) ?? null;
1962
+ }
1963
+ function appendContextDependencies(list, dependencies) {
1964
+ if (dependencies === null) return list;
1965
+ let next = list;
1966
+ for (const dependency of dependencies) next = appendContext(next, dependency.context);
1967
+ return next;
1968
+ }
1969
+ function appendContextList(list, contexts) {
1970
+ if (contexts === null) return list;
1971
+ let next = list;
1972
+ for (const context of contexts) next = appendContext(next, context);
1973
+ return next;
1974
+ }
1975
+ function appendContext(list, context) {
1976
+ if (list === null) return [context];
1977
+ if (!list.includes(context)) list.push(context);
1978
+ return list;
1979
+ }
1980
+ function contextListIncludes(list, context) {
1981
+ return list?.includes(context) === true;
1982
+ }
1983
+ function updateHook(kind) {
1984
+ const hook = currentHook;
1985
+ if (hook === null) {
1986
+ if (didRenderBefore(renderingFiber)) throw hookOrderError("more");
1987
+ return null;
1988
+ }
1989
+ if (hook.kind !== kind) throw new Error(`Hook order changed: expected ${hookKindName(hook.kind)}, received ${hookKindName(kind)}.`);
1990
+ currentHook = hook.next;
1991
+ return hook;
1992
+ }
1993
+ function didRenderBefore(node) {
1994
+ const previous = node?.alternate ?? null;
1995
+ return previous !== null && previous.memoizedProps !== null;
1996
+ }
1997
+ function hookOrderError(direction) {
1998
+ return /* @__PURE__ */ new Error(`Rendered ${direction} hooks than during the previous render.`);
1999
+ }
2000
+ function complete(node) {
2001
+ completeHydration(node);
2002
+ let child = node.child;
2003
+ let childLanes = 0;
2004
+ let subtreeFlags = 0;
2005
+ let contextSubtreeDependencies = null;
2006
+ while (child !== null) {
2007
+ childLanes = mergeLanes(childLanes, child.lanes);
2008
+ childLanes = mergeLanes(childLanes, child.childLanes);
2009
+ subtreeFlags |= childSubtreeFlags(child);
2010
+ contextSubtreeDependencies = appendContextDependencies(contextSubtreeDependencies, child.contextDependencies);
2011
+ contextSubtreeDependencies = appendContextList(contextSubtreeDependencies, child.contextSubtreeDependencies);
2012
+ child = child.sibling;
2013
+ }
2014
+ if (isNewHostInstance(node)) {
2015
+ host.finalizeInitialInstance?.(node.stateNode, node.props);
2016
+ if (!setInitialHostTextContent(node)) {
2017
+ if (node.alternate !== null && node.child !== null) host.setTextContent?.(node.stateNode, "");
2018
+ appendAllHostChildren(node.stateNode, node.child);
2019
+ }
2020
+ if (host.appendInitialChild !== void 0) node.flags |= 64;
2021
+ }
2022
+ if (node.tag === 11) node.flags |= ViewTransitionStaticFlag;
2023
+ node.childLanes = childLanes;
2024
+ node.subtreeFlags = subtreeFlags;
2025
+ node.contextSubtreeDependencies = contextSubtreeDependencies;
2026
+ node.memoizedProps = node.props;
2027
+ if (node.tag === 5 && (node.flags & 16) === 0) popContextProvider(node);
2028
+ }
2029
+ function isNewHostInstance(node) {
2030
+ return node.tag === 1 && node.committedProps === null && (node.flags & 4) === 0;
2031
+ }
2032
+ function setInitialHostTextContent(node) {
2033
+ const text = hostTextContent(node.props.children);
2034
+ if (text === null || host.setTextContent === void 0) return false;
2035
+ host.setTextContent(node.stateNode, text);
2036
+ return true;
2037
+ }
2038
+ function appendAllHostChildren(parent, child) {
2039
+ if (host.appendInitialChild === void 0) return;
2040
+ for (let node = child; node !== null; node = node.sibling) {
2041
+ if (node.tag === 8) continue;
2042
+ if (isHoistedFiber(node)) continue;
2043
+ if (node.tag === 1 || node.tag === 2) host.appendInitialChild(parent, hostNode(node));
2044
+ else appendAllHostChildren(parent, node.child);
2045
+ }
2046
+ }
2047
+ function reconcileCurrentChildren(parent, children, root = rootOf(parent)) {
2048
+ reconcile(parent, children, parent.alternate?.child ?? null, false, root);
2049
+ }
2050
+ function reconcile(parent, children, currentFirstChild, forcePlacement, root = rootOf(parent)) {
2051
+ const nextChildren = collectChildren(children);
2052
+ const seenKeys = null;
2053
+ parent.child = null;
2054
+ parent.deletions = null;
2055
+ let previous = null;
2056
+ let old = currentFirstChild;
2057
+ let index = 0;
2058
+ let lastPlacedIndex = 0;
2059
+ const isHydratingNewTree = parent.tag !== 8 && root.isHydrating && currentFirstChild === null;
2060
+ for (; old !== null && index < nextChildren.length; index += 1) {
2061
+ const child = nextChildren[index];
2062
+ if (!sameChildKey(old, child, index) || !sameType(old, child)) break;
2063
+ validateChildKey(child, seenKeys);
2064
+ const next = createWorkInProgress(old, propsFor(child));
2065
+ next.index = index;
2066
+ next.return = parent;
2067
+ const updateFlags = hostUpdateFlags(old, next.props);
2068
+ if (updateFlags !== 0) recordCommitWork(root.commitIndex, next, updateFlags);
2069
+ if (forcePlacement) next.flags |= 1;
2070
+ else lastPlacedIndex = old.index;
2071
+ previous = appendChild(parent, previous, next);
2072
+ old = old.sibling;
2073
+ }
2074
+ if (index === nextChildren.length) {
2075
+ appendDeletions(parent, old);
2076
+ return;
2077
+ }
2078
+ if (old === null) {
2079
+ for (; index < nextChildren.length; index += 1) {
2080
+ validateChildKey(nextChildren[index], seenKeys);
2081
+ const next = fiberFrom(nextChildren[index]);
2082
+ if (next === null) continue;
2083
+ next.index = index;
2084
+ next.return = parent;
2085
+ if (!isHydratingNewTree) next.flags |= 1;
2086
+ previous = appendChild(parent, previous, next);
2087
+ }
2088
+ return;
2089
+ }
2090
+ let existingByKey = null;
2091
+ let existingByIndex = null;
2092
+ for (; old !== null; old = old.sibling) if (old.key === null) (existingByIndex ??= /* @__PURE__ */ new Map()).set(old.index, old);
2093
+ else (existingByKey ??= /* @__PURE__ */ new Map()).set(String(old.key), old);
2094
+ for (; index < nextChildren.length; index += 1) {
2095
+ const child = nextChildren[index];
2096
+ validateChildKey(child, seenKeys);
2097
+ const key = childExplicitKey(child);
2098
+ const matched = key === null ? existingByIndex?.get(index) : existingByKey?.get(key);
2099
+ const canReuse = matched !== void 0 && sameType(matched, child);
2100
+ const next = canReuse ? createWorkInProgress(matched, propsFor(child)) : fiberFrom(child);
2101
+ if (next === null) continue;
2102
+ next.index = index;
2103
+ next.return = parent;
2104
+ if (canReuse) {
2105
+ if (key === null) existingByIndex?.delete(index);
2106
+ else existingByKey?.delete(key);
2107
+ const updateFlags = hostUpdateFlags(matched, next.props);
2108
+ if (updateFlags !== 0) recordCommitWork(root.commitIndex, next, updateFlags);
2109
+ if (forcePlacement || matched.index < lastPlacedIndex) next.flags |= 1;
2110
+ else lastPlacedIndex = matched.index;
2111
+ } else if (!isHydratingNewTree) next.flags |= 1;
2112
+ previous = appendChild(parent, previous, next);
2113
+ }
2114
+ if (existingByKey !== null) for (const child of existingByKey.values()) appendDeletion(parent, child);
2115
+ if (existingByIndex !== null) for (const child of existingByIndex.values()) appendDeletion(parent, child);
2116
+ }
2117
+ function appendDeletions(parent, firstChild) {
2118
+ for (let child = firstChild; child !== null; child = child.sibling) appendDeletion(parent, child);
2119
+ }
2120
+ function appendDeletion(parent, child) {
2121
+ const root = rootOf(parent);
2122
+ parent.deletions ??= [];
2123
+ parent.deletions.push(child);
2124
+ root.needsCommitDeletions = true;
2125
+ recordCommitWork(root.commitIndex, parent, 128);
2126
+ }
2127
+ function hostUpdateFlags(current, nextProps) {
2128
+ if (current.tag === 2) return current.committedProps?.nodeValue !== nextProps.nodeValue ? 2 : 0;
2129
+ if (current.tag !== 1) return 0;
2130
+ const previousProps = current.committedProps ?? {};
2131
+ let flags = 0;
2132
+ if (hostPropsChanged(previousProps, nextProps)) flags |= 2;
2133
+ if (host.shouldCommitUpdate?.(String(current.type), previousProps, nextProps)) flags |= 2;
2134
+ if (hostTextContentChanged(current, previousProps, nextProps)) flags |= 8;
2135
+ return flags;
2136
+ }
2137
+ function hostTextContentChanged(current, previous, next) {
2138
+ if (host.setTextContent === void 0) return false;
2139
+ if (hasUnsafeHTML(next)) return false;
2140
+ if (adoptedSingleTextChild(current)) return false;
2141
+ const previousText = hostTextContent(previous.children);
2142
+ const nextText = hostTextContent(next.children);
2143
+ return previousText !== nextText || nextText !== null && current.child !== null;
2144
+ }
2145
+ function hostPropsChanged(previous, next) {
2146
+ let previousCount = 0;
2147
+ for (const key in previous) {
2148
+ if (!Object.hasOwn(previous, key)) continue;
2149
+ if (!committedHostProp(key)) continue;
2150
+ previousCount += 1;
2151
+ if (!(key in next) || previous[key] !== next[key]) return true;
2152
+ }
2153
+ let nextCount = 0;
2154
+ for (const key in next) {
2155
+ if (!Object.hasOwn(next, key)) continue;
2156
+ if (committedHostProp(key)) nextCount += 1;
2157
+ }
2158
+ return previousCount !== nextCount;
2159
+ }
2160
+ function committedHostProp(name) {
2161
+ return name !== "children";
2162
+ }
2163
+ function isViewTransitionEligibleCommit(root) {
2164
+ return !root.clearContainerBeforeCommit && root.renderLanes !== 0 && (root.renderLanes & -1409285889) === 0 && viewTransitionHost !== null;
2165
+ }
2166
+ function prepareViewTransitionPlan(root, finishedWork) {
2167
+ if (!isViewTransitionEligibleCommit(root)) return null;
2168
+ if ((finishedWork.subtreeFlags & 4096) === 0 && !root.needsCommitDeletions) return null;
2169
+ const plan = {
2170
+ newSurfaces: [],
2171
+ oldSurfaces: [],
2172
+ rootAffected: false
2173
+ };
2174
+ const exitsByName = /* @__PURE__ */ new Map();
2175
+ if (root.needsCommitDeletions) collectDeletedViewTransitions(root, finishedWork, plan, exitsByName);
2176
+ const changedBoundaries = attributeQueuedHostUpdates(root, plan);
2177
+ collectFinishedViewTransitions(finishedWork.child, false, false, false, changedBoundaries, plan, exitsByName);
2178
+ if (plan.oldSurfaces.length === 0 && plan.newSurfaces.length === 0) return null;
2179
+ return plan;
2180
+ }
2181
+ function collectDeletedViewTransitions(root, node, plan, exitsByName) {
2182
+ for (const cursor of root.commitIndex) {
2183
+ if (cursor.deletions === null) continue;
2184
+ for (const deletion of cursor.deletions) collectDeletedViewTransitionFiber(deletion, plan, exitsByName, true);
2185
+ }
2186
+ }
2187
+ function collectDeletedViewTransitionFiber(cursor, plan, exitsByName, collectExit) {
2188
+ if (cursor.tag === 8 || isHiddenBoundary(cursor)) return;
2189
+ if (cursor.tag === 11) {
2190
+ if (explicitViewTransitionName(cursor) !== null) exitsByName.set(viewTransitionName(cursor), cursor);
2191
+ if (collectExit) collectViewTransitionSurfaces(cursor, "exit", plan.oldSurfaces, "committed");
2192
+ for (let child = cursor.child; child !== null; child = child.sibling) collectDeletedViewTransitionFiber(child, plan, exitsByName, false);
2193
+ return;
2194
+ }
2195
+ if ((cursor.subtreeFlags & 4096) === 0) return;
2196
+ for (let child = cursor.child; child !== null; child = child.sibling) collectDeletedViewTransitionFiber(child, plan, exitsByName, collectExit);
2197
+ }
2198
+ function attributeQueuedHostUpdates(root, plan) {
2199
+ let changed = null;
2200
+ for (const entry of root.commitIndex) {
2201
+ if ((entry.flags & 10) === 0) continue;
2202
+ let sawPortal = false;
2203
+ let boundary = null;
2204
+ for (let parent = entry.return; parent !== null; parent = parent.return) {
2205
+ if (parent.tag === 11) {
2206
+ boundary = parent;
2207
+ break;
2208
+ }
2209
+ if (parent.tag === 8) sawPortal = true;
2210
+ }
2211
+ if (boundary === null) plan.rootAffected = true;
2212
+ else if (!sawPortal) (changed ??= /* @__PURE__ */ new Set()).add(boundary);
2213
+ }
2214
+ return changed;
2215
+ }
2216
+ function collectFinishedViewTransitions(node, placed, insideBoundary, ancestorLayoutChanged, changedBoundaries, plan, exitsByName) {
2217
+ let layoutChanged = ancestorLayoutChanged;
2218
+ for (let cursor = node; !layoutChanged && cursor !== null; cursor = cursor.sibling) if ((cursor.flags & 1) !== 0 && (cursor.alternate !== null || (cursor.flags & 16) !== 0)) layoutChanged = true;
2219
+ for (let cursor = node; cursor !== null; cursor = cursor.sibling) {
2220
+ const cursorPlaced = placed || (cursor.flags & 1) !== 0;
2221
+ if (!(cursor.tag === 11 || (cursor.subtreeFlags & 4096) !== 0)) {
2222
+ if (!insideBoundary && ((cursor.flags | cursor.subtreeFlags) & 175) !== 0) plan.rootAffected = true;
2223
+ continue;
2224
+ }
2225
+ if (isStablyHiddenBoundary(cursor)) continue;
2226
+ if (cursor.tag === 11) {
2227
+ if (!cursorPlaced && ((cursor.flags | cursor.subtreeFlags) & 4) !== 0) continue;
2228
+ if (cursorPlaced) {
2229
+ const pairedExit = exitsByName.get(viewTransitionName(cursor));
2230
+ if (pairedExit !== void 0) {
2231
+ if (!insideBoundary) plan.rootAffected = true;
2232
+ collectViewTransitionPair(plan, pairedExit, cursor);
2233
+ exitsByName.delete(viewTransitionName(cursor));
2234
+ } else if (cursor.alternate !== null) {
2235
+ collectViewTransitionSurfaces(cursor.alternate, "update", plan.oldSurfaces, "committed", false);
2236
+ collectViewTransitionSurfaces(cursor, "update", plan.newSurfaces, "finished", false);
2237
+ } else {
2238
+ if (!insideBoundary) plan.rootAffected = true;
2239
+ collectViewTransitionSurfaces(cursor, "enter", plan.newSurfaces, "finished");
2240
+ }
2241
+ collectAppearingPairViewTransitions(cursor.child, plan, exitsByName);
2242
+ continue;
2243
+ }
2244
+ const current = cursor.alternate ?? cursor;
2245
+ const contentChanged = viewTransitionChangedOutsideNested(cursor, changedBoundaries);
2246
+ if (contentChanged || layoutChanged) {
2247
+ collectViewTransitionSurfaces(current, "update", plan.oldSurfaces, "committed", contentChanged);
2248
+ collectViewTransitionSurfaces(cursor, "update", plan.newSurfaces, "finished", contentChanged);
2249
+ }
2250
+ collectFinishedViewTransitions(cursor.child, cursorPlaced, true, contentChanged || layoutChanged, changedBoundaries, plan, exitsByName);
2251
+ continue;
2252
+ }
2253
+ if (cursor.tag !== 8) {
2254
+ if (!insideBoundary && (cursor.flags & 175) !== 0) plan.rootAffected = true;
2255
+ collectFinishedViewTransitions(cursor.child, cursorPlaced, insideBoundary, layoutChanged || (cursor.flags & 175) !== 0, changedBoundaries, plan, exitsByName);
2256
+ }
2257
+ }
2258
+ }
2259
+ function collectAppearingPairViewTransitions(node, plan, exitsByName) {
2260
+ if (exitsByName.size === 0) return;
2261
+ for (let cursor = node; cursor !== null; cursor = cursor.sibling) {
2262
+ if (cursor.tag === 8 || isStablyHiddenBoundary(cursor)) continue;
2263
+ if (cursor.tag === 11) {
2264
+ const pairedExit = explicitViewTransitionName(cursor) !== null ? exitsByName.get(viewTransitionName(cursor)) : void 0;
2265
+ if (pairedExit !== void 0) {
2266
+ collectViewTransitionPair(plan, pairedExit, cursor);
2267
+ exitsByName.delete(viewTransitionName(cursor));
2268
+ }
2269
+ }
2270
+ collectAppearingPairViewTransitions(cursor.child, plan, exitsByName);
2271
+ }
2272
+ }
2273
+ function collectViewTransitionPair(plan, oldBoundary, newBoundary) {
2274
+ removeViewTransitionSurfaces(plan.oldSurfaces, oldBoundary);
2275
+ collectViewTransitionSurfaces(oldBoundary, "share", plan.oldSurfaces, "committed");
2276
+ collectViewTransitionSurfaces(newBoundary, "share", plan.newSurfaces, "finished");
2277
+ }
2278
+ function isStablyHiddenBoundary(node) {
2279
+ if (!isHiddenBoundary(node)) return false;
2280
+ const current = node.alternate;
2281
+ return current === null || activityHidden(current.memoizedProps ?? current.props);
2282
+ }
2283
+ function viewTransitionChangedOutsideNested(boundary, changedBoundaries) {
2284
+ if ((boundary.flags & 175) !== 0) return true;
2285
+ if (changedBoundaries !== null && changedBoundaries.has(boundary)) return true;
2286
+ return subtreeChangedOutsideNested(boundary.child);
2287
+ }
2288
+ function subtreeChangedOutsideNested(node) {
2289
+ for (let cursor = node; cursor !== null; cursor = cursor.sibling) {
2290
+ if (cursor.tag === 8) continue;
2291
+ if (cursor.tag === 11) continue;
2292
+ if ((cursor.flags & 175) !== 0) return true;
2293
+ if ((cursor.subtreeFlags & 175) === 0) continue;
2294
+ if (subtreeChangedOutsideNested(cursor.child)) return true;
2295
+ }
2296
+ return false;
2297
+ }
2298
+ function removeViewTransitionSurfaces(surfaces, boundary) {
2299
+ for (let index = surfaces.length - 1; index >= 0; index -= 1) if (surfaces[index].boundary === boundary) surfaces.splice(index, 1);
2300
+ }
2301
+ function collectViewTransitionSurfaces(boundary, phase, surfaces, propsSource, mustAnimate = true) {
2302
+ const className = viewTransitionClass(boundary.props, phase);
2303
+ if (className === "none") return;
2304
+ const name = viewTransitionName(boundary);
2305
+ let index = 0;
2306
+ const collect = (node) => {
2307
+ for (let cursor = node; cursor !== null; cursor = cursor.sibling) {
2308
+ if (cursor.tag === 8) continue;
2309
+ if (cursor.tag === 11) continue;
2310
+ if (cursor.tag === 1) {
2311
+ if (!isHoistedFiber(cursor)) {
2312
+ surfaces.push({
2313
+ boundary,
2314
+ className,
2315
+ instance: cursor.stateNode,
2316
+ measurement: null,
2317
+ mustAnimate,
2318
+ name: index === 0 ? name : `${name}_${index}`,
2319
+ phase,
2320
+ props: viewTransitionSurfaceProps(cursor, propsSource),
2321
+ skipped: false
2322
+ });
2323
+ index += 1;
2324
+ }
2325
+ continue;
2326
+ }
2327
+ collect(cursor.child);
2328
+ }
2329
+ };
2330
+ collect(boundary.child);
2331
+ }
2332
+ function viewTransitionSurfaceProps(node, source) {
2333
+ if (source === "committed") return node.committedProps ?? node.memoizedProps ?? node.props;
2334
+ return node.memoizedProps ?? node.props;
2335
+ }
2336
+ function viewTransitionName(node) {
2337
+ const props = node.props;
2338
+ if (props.name !== void 0 && props.name !== "auto") return props.name;
2339
+ const state = node.stateNode;
2340
+ state.autoName ??= `fig-vt-${viewTransitionAutoNameCounter++}`;
2341
+ return state.autoName;
2342
+ }
2343
+ function explicitViewTransitionName(node) {
2344
+ const name = node.props.name;
2345
+ return name === void 0 || name === "auto" ? null : name;
2346
+ }
2347
+ function viewTransitionClass(props, phase) {
2348
+ const viewTransitionProps = props;
2349
+ const phaseClass = viewTransitionProps[phase];
2350
+ const className = phaseClass === void 0 ? viewTransitionProps.default : phaseClass;
2351
+ if (className === void 0 || className === "auto") return null;
2352
+ if (className === "none") return "none";
2353
+ return className;
2354
+ }
2355
+ function applyOldViewTransitionSurfaces(plan) {
2356
+ if (viewTransitionHost === null) return;
2357
+ const measure = viewTransitionHost.measure;
2358
+ for (const surface of plan.oldSurfaces) {
2359
+ surface.measurement = measure?.(surface.instance) ?? null;
2360
+ if (surface.phase === "exit" && surface.measurement !== null && !surface.measurement.inViewport) {
2361
+ surface.skipped = true;
2362
+ continue;
2363
+ }
2364
+ viewTransitionHost.apply(surface.instance, surface.name, surface.className);
2365
+ }
2366
+ }
2367
+ function resolveViewTransitionPlan(plan) {
2368
+ const result = {
2369
+ canceledNames: [],
2370
+ cancelRootSnapshot: false
2371
+ };
2372
+ if (viewTransitionHost === null || plan === null) return result;
2373
+ const measure = viewTransitionHost.measure;
2374
+ const oldByName = /* @__PURE__ */ new Map();
2375
+ for (const surface of plan.oldSurfaces) if (!surface.skipped) oldByName.set(surface.name, surface);
2376
+ let rootAffected = plan.rootAffected;
2377
+ const newNames = /* @__PURE__ */ new Set();
2378
+ for (const surface of plan.newSurfaces) {
2379
+ newNames.add(surface.name);
2380
+ const measurement = measure?.(surface.instance) ?? null;
2381
+ if (surface.phase === "enter") {
2382
+ if (measurement !== null && !measurement.inViewport) {
2383
+ surface.skipped = true;
2384
+ continue;
2385
+ }
2386
+ applyViewTransitionSurface(viewTransitionHost, surface);
2387
+ continue;
2388
+ }
2389
+ if (surface.phase === "update") {
2390
+ const before = oldByName.get(surface.name)?.measurement ?? null;
2391
+ if (before !== null && measurement !== null) {
2392
+ const moved = before.x !== measurement.x || before.y !== measurement.y || before.width !== measurement.width || before.height !== measurement.height;
2393
+ if (!before.inViewport && !measurement.inViewport || !surface.mustAnimate && !moved) {
2394
+ surface.skipped = true;
2395
+ viewTransitionHost.restore(surface.instance, surface.props);
2396
+ if (oldByName.has(surface.name)) result.canceledNames.push(surface.name);
2397
+ continue;
2398
+ }
2399
+ if ((before.width !== measurement.width || before.height !== measurement.height) && !measurement.absolutelyPositioned) rootAffected = true;
2400
+ }
2401
+ }
2402
+ applyViewTransitionSurface(viewTransitionHost, surface);
2403
+ }
2404
+ for (const [name, surface] of oldByName) if (surface.phase === "update" && !newNames.has(name)) rootAffected = true;
2405
+ result.cancelRootSnapshot = !rootAffected;
2406
+ return result;
2407
+ }
2408
+ function applyViewTransitionSurface(viewTransitionHost, surface) {
2409
+ viewTransitionHost.apply(surface.instance, surface.name, surface.className);
2410
+ }
2411
+ function restoreViewTransitionSurfaces(plan) {
2412
+ if (viewTransitionHost === null) return;
2413
+ const propsByInstance = /* @__PURE__ */ new Map();
2414
+ for (const surface of plan.oldSurfaces) propsByInstance.set(surface.instance, surface.props);
2415
+ for (const surface of plan.newSurfaces) propsByInstance.set(surface.instance, surface.props);
2416
+ for (const [instance, props] of propsByInstance) viewTransitionHost.restore(instance, props);
2417
+ }
2418
+ function commitRoot(root, finishedWork) {
2419
+ if (!root.pendingViewTransitionCommit && isViewTransitionEligibleCommit(root) && viewTransitionHost?.suspend?.(root.container, () => scheduleRoot(root)) === true) {
2420
+ root.parkedViewTransitionCommit = true;
2421
+ root.callback = null;
2422
+ root.callbackPriority = 0;
2423
+ return true;
2424
+ }
2425
+ commitDepth += 1;
2426
+ try {
2427
+ let suspenseRetries = noSuspenseRetries;
2428
+ if (root.pendingSuspenseRetries.length > 0) {
2429
+ suspenseRetries = root.pendingSuspenseRetries;
2430
+ root.pendingSuspenseRetries = [];
2431
+ }
2432
+ commitLiveHookInstances(root);
2433
+ if (hasHiddenBoundaries) armRevealedHiddenBoundaries(finishedWork.child);
2434
+ commitEffects(root, finishedWork.child, 2);
2435
+ const viewTransitionPlan = prepareViewTransitionPlan(root, finishedWork);
2436
+ const commitHostChanges = () => {
2437
+ if (root.clearContainerBeforeCommit) {
2438
+ requireHydrationHostConfig().clearContainer(root.container);
2439
+ root.clearContainerBeforeCommit = false;
2440
+ }
2441
+ if (root.needsCommitDeletions) {
2442
+ commitDeletions(root);
2443
+ root.needsCommitDeletions = false;
2444
+ }
2445
+ commitDataDependencies(root);
2446
+ commitHostUpdates(root);
2447
+ commitMutationEffects(finishedWork.child);
2448
+ if (hasHiddenBoundaries) commitHiddenBoundaryVisibility(finishedWork.child);
2449
+ };
2450
+ const completeCommit = () => {
2451
+ hasHiddenBoundaries = hiddenStates.size > 0;
2452
+ root.current = finishedWork;
2453
+ deactivateHydration(root);
2454
+ root.hydrationInitialElement = NoHydrationInitialElement;
2455
+ root.consumedPendingQueues = [];
2456
+ markRootFinished(root, root.pendingLanes & ~root.renderLanes | finishedWork.lanes | finishedWork.childLanes);
2457
+ if (includesSomeLane(finishedWork.childLanes, 536870912)) {
2458
+ markRootPending(root, OffscreenLane);
2459
+ root.suspendedLanes &= -536870913;
2460
+ }
2461
+ try {
2462
+ commitExternalStores(root);
2463
+ attachCommittedSuspenseRetries(root, suspenseRetries);
2464
+ scheduleDehydratedSuspenseRetries(root);
2465
+ commitEffects(root, finishedWork.child, 1);
2466
+ flushCaughtBoundaryErrors(root);
2467
+ } finally {
2468
+ collectReactiveEffects(root, finishedWork.child);
2469
+ clearTransientFlags(finishedWork);
2470
+ scheduleReactiveEffects(root);
2471
+ clearCommitIndex(root.commitIndex);
2472
+ }
2473
+ flushRecoverableErrors(root);
2474
+ requestPaint();
2475
+ };
2476
+ const commitWithoutViewTransition = () => {
2477
+ commitHostChanges();
2478
+ completeCommit();
2479
+ };
2480
+ const commitWithViewTransition = () => {
2481
+ const isDeferredCommit = root.pendingViewTransitionCommit;
2482
+ if (isDeferredCommit) commitDepth += 1;
2483
+ try {
2484
+ commitHostChanges();
2485
+ const resolution = resolveViewTransitionPlan(viewTransitionPlan);
2486
+ completeCommit();
2487
+ return resolution;
2488
+ } catch (error) {
2489
+ if (!isDeferredCommit) throw error;
2490
+ const info = root.uncaughtErrorInfo ?? errorInfoFor(root.current, error);
2491
+ restartRootWork(root);
2492
+ clearRootAfterUncaughtError(root);
2493
+ reportUncaughtError(root, error, info);
2494
+ if (root.onUncaughtError === null) setTimeout(() => {
2495
+ throw error;
2496
+ });
2497
+ return {
2498
+ canceledNames: [],
2499
+ cancelRootSnapshot: false
2500
+ };
2501
+ } finally {
2502
+ if (isDeferredCommit) {
2503
+ root.pendingViewTransitionCommit = false;
2504
+ commitDepth -= 1;
2505
+ finishRootWork(root);
2506
+ flushPostCommitSyncWork();
2507
+ }
2508
+ }
2509
+ };
2510
+ if (viewTransitionPlan !== null && viewTransitionHost !== null) {
2511
+ const viewTransitionResult = viewTransitionHost.commit(root.container, () => applyOldViewTransitionSurfaces(viewTransitionPlan), commitWithViewTransition, () => restoreViewTransitionSurfaces(viewTransitionPlan));
2512
+ if (viewTransitionResult === "deferred") {
2513
+ root.pendingViewTransitionCommit = true;
2514
+ root.callback = null;
2515
+ root.callbackPriority = 0;
2516
+ return true;
2517
+ }
2518
+ if (viewTransitionResult === "committed") return false;
2519
+ }
2520
+ commitWithoutViewTransition();
2521
+ return false;
2522
+ } finally {
2523
+ commitDepth -= 1;
2524
+ }
2525
+ }
2526
+ function scheduleDehydratedSuspenseRetries(root) {
2527
+ if (!root.isHydrationRoot && root.dehydratedSuspenseCount === 0 && !root.needsRootHydrationCompletion) {
2528
+ root.dehydratedBoundaries = /* @__PURE__ */ new Map();
2529
+ return;
2530
+ }
2531
+ const boundaries = [];
2532
+ root.dehydratedBoundaries = /* @__PURE__ */ new Map();
2533
+ updateDehydratedSuspenseCount(root, collectDehydratedSuspense(root.current.child, boundaries, root.dehydratedBoundaries));
2534
+ if (boundaries.length === 0) return;
2535
+ queueMicrotask(() => {
2536
+ for (const boundary of boundaries) {
2537
+ const state = fiberSuspenseState(boundary);
2538
+ if (state?.kind !== "dehydrated") continue;
2539
+ const lane = dehydratedSuspenseRetryLane(state.boundary);
2540
+ if (lane !== 0) scheduleFiber(boundary, lane);
2541
+ }
2542
+ });
2543
+ }
2544
+ function collectDehydratedSuspense(node, boundaries, byStartMarker) {
2545
+ let count = 0;
2546
+ walkFiberForest(node, (cursor) => {
2547
+ const state = fiberSuspenseState(cursor);
2548
+ if (state?.kind === "dehydrated") {
2549
+ count += 1;
2550
+ byStartMarker.set(state.boundary.start, cursor);
2551
+ if (!abandonedHydrationBoundaries.has(cursor) && dehydratedSuspenseRetryLane(state.boundary) !== 0) boundaries.push(cursor);
2552
+ return false;
2553
+ }
2554
+ return true;
2555
+ });
2556
+ return count;
2557
+ }
2558
+ function updateDehydratedSuspenseCount(root, count) {
2559
+ const previous = root.dehydratedSuspenseCount;
2560
+ root.dehydratedSuspenseCount = count;
2561
+ if ((previous > 0 || root.needsRootHydrationCompletion) && count === 0) {
2562
+ root.needsRootHydrationCompletion = false;
2563
+ host.completeRootHydration?.(root.container);
2564
+ }
2565
+ }
2566
+ function dehydratedSuspenseRetryLane(boundary) {
2567
+ if (boundary.forceClientRender) return 32;
2568
+ if (boundary.status === "completed") return 16;
2569
+ if (boundary.status === "client-rendered") return 32;
2570
+ return 0;
2571
+ }
2572
+ function flushRecoverableErrors(root) {
2573
+ const errors = root.recoverableErrors;
2574
+ if (errors.length === 0) return;
2575
+ root.recoverableErrors = [];
2576
+ for (const { error, info } of errors) try {
2577
+ root.onRecoverableError(error, info);
2578
+ } catch {}
2579
+ }
2580
+ function flushCaughtBoundaryErrors(root) {
2581
+ if (root.committedCaughtErrors.length > 0) {
2582
+ const boundaries = root.committedCaughtErrors;
2583
+ root.committedCaughtErrors = [];
2584
+ for (const boundary of boundaries) flushCaughtBoundaryError(root, boundary);
2585
+ }
2586
+ for (const boundary of root.commitIndex) flushCaughtBoundaryError(root, boundary);
2587
+ }
2588
+ function flushCaughtBoundaryError(root, node) {
2589
+ const state = fiberErrorBoundaryState(node);
2590
+ if (state === null || state.didReport) return;
2591
+ state.didReport = true;
2592
+ if (node.alternate !== null) node.alternate.boundaryState = state;
2593
+ const onError = node.props.onError;
2594
+ if (typeof onError !== "function") return;
2595
+ try {
2596
+ onError(state.error, state.info);
2597
+ } catch (error) {
2598
+ reportUncaughtError(root, error, errorInfoFor(node, error));
2599
+ }
2600
+ }
2601
+ function reportUncaughtError(root, error, info) {
2602
+ try {
2603
+ root.onUncaughtError?.(error, info);
2604
+ } catch {}
2605
+ }
2606
+ function clearRootAfterUncaughtError(root) {
2607
+ root.reactiveCallback?.cancel();
2608
+ root.reactiveCallback = null;
2609
+ root.pendingReactiveEffects = [];
2610
+ root.element = null;
2611
+ if (root.current.child !== null) {
2612
+ deleteFiberDataTree(root.current.child);
2613
+ abortFiberEffects(root.current);
2614
+ }
2615
+ if (host.clearContainer !== void 0) {
2616
+ removePortalDescendants(root.current.child);
2617
+ host.clearContainer(root.container);
2618
+ } else if (root.current.child !== null) {
2619
+ let child = root.current.child;
2620
+ while (child !== null) {
2621
+ const next = child.sibling;
2622
+ remove(child, root.container);
2623
+ child = next;
2624
+ }
2625
+ }
2626
+ const current = fiber(0, null, null, { children: null }, root);
2627
+ current.memoizedProps = current.props;
2628
+ current.committedProps = current.props;
2629
+ root.current = current;
2630
+ resetRootWork(root);
2631
+ root.clearContainerBeforeCommit = false;
2632
+ root.hydrationInitialElement = NoHydrationInitialElement;
2633
+ root.consumedPendingQueues = [];
2634
+ root.commitEffectPhases = 0;
2635
+ root.needsCommitDeletions = false;
2636
+ root.committedCaughtErrors.length = 0;
2637
+ markRootFinished(root, 0);
2638
+ pendingRoots.delete(root);
2639
+ }
2640
+ function commitMutationEffects(node, hidden = false) {
2641
+ let cursor = node;
2642
+ while (cursor !== null) {
2643
+ const subtreeMutation = (cursor.subtreeFlags & 47) !== 0;
2644
+ if ((cursor.flags & 47) === 0 && !subtreeMutation) {
2645
+ cursor = cursor.sibling;
2646
+ continue;
2647
+ }
2648
+ if ((cursor.flags & 1) !== 0) {
2649
+ cursor = commitPlacementRun(cursor, hidden);
2650
+ continue;
2651
+ }
2652
+ if (cursor.tag === 8) commitPortal(cursor);
2653
+ if (cursor.tag === 10 && (cursor.flags & 4) !== 0) commitHydratedActivityBoundary(cursor);
2654
+ if ((cursor.flags & 4) !== 0 && (cursor.flags & 10) !== 0 && isHost(cursor)) {
2655
+ const hostFiber = cursor;
2656
+ commitHostMutation(hostFiber, () => commitUpdate(hostFiber));
2657
+ if (hidden) hideHostFiber(hostFiber);
2658
+ }
2659
+ if ((cursor.flags & 16) === 0 && subtreeMutation) commitMutationEffects(cursor.child, hidden || isHiddenBoundary(cursor));
2660
+ if (cursor.tag === 6 && (cursor.flags & 4) !== 0) commitHydratedSuspenseBoundary(cursor);
2661
+ cursor = cursor.sibling;
2662
+ }
2663
+ }
2664
+ function commitPlacementRun(firstPlaced, hidden) {
2665
+ const lastPlaced = placementRunTail(firstPlaced);
2666
+ const afterPlaced = lastPlaced.sibling;
2667
+ const before = hostSibling(lastPlaced);
2668
+ for (let placed = firstPlaced; placed !== afterPlaced;) {
2669
+ if (placed === null) break;
2670
+ const current = placed;
2671
+ const next = current.sibling;
2672
+ const placedHidden = hidden || isHiddenBoundary(current);
2673
+ if (placedHidden) hidePlacedNode(current);
2674
+ if (hasHiddenBoundaries && isPreassembledHostSubtree(current)) hideNestedBoundaryContent(current.child);
2675
+ commitHostMutation(current, () => commitPlacement(current, before));
2676
+ if (placedHidden) hidePlacedNode(current);
2677
+ if (!isPreassembledHostSubtree(current)) commitMutationEffects(current.child, placedHidden);
2678
+ else commitPortalsInPreassembledSubtree(current.child, placedHidden);
2679
+ placed = next;
2680
+ }
2681
+ return afterPlaced;
2682
+ }
2683
+ function hidePlacedNode(node) {
2684
+ if (isHiddenBoundary(node)) setSubtreeVisibility(node.child, true);
2685
+ else setNodeVisibility(node, true);
2686
+ }
2687
+ function hideNestedBoundaryContent(node) {
2688
+ for (let cursor = node; cursor !== null; cursor = cursor.sibling) {
2689
+ if (isHiddenBoundary(cursor)) setSubtreeVisibility(cursor.child, true);
2690
+ hideNestedBoundaryContent(cursor.child);
2691
+ }
2692
+ }
2693
+ function commitPortalsInPreassembledSubtree(node, hidden) {
2694
+ for (let cursor = node; cursor !== null; cursor = cursor.sibling) {
2695
+ const cursorHidden = hidden || isHiddenBoundary(cursor);
2696
+ if (cursor.tag === 8) {
2697
+ if (cursorHidden) setSubtreeVisibility(cursor.child, true);
2698
+ if (hasHiddenBoundaries) hideNestedBoundaryContent(cursor.child);
2699
+ commitHostMutation(cursor, () => commitPlacement(cursor));
2700
+ if (cursorHidden) setNodeVisibility(cursor, true);
2701
+ commitMutationEffects(cursor.child, cursorHidden);
2702
+ } else commitPortalsInPreassembledSubtree(cursor.child, cursorHidden);
2703
+ }
2704
+ }
2705
+ function commitHostMutation(source, mutation) {
2706
+ try {
2707
+ mutation();
2708
+ } catch (error) {
2709
+ rootOf(source).uncaughtErrorInfo = errorInfoFor(source, error);
2710
+ throw error;
2711
+ }
2712
+ }
2713
+ function isPreassembledHostSubtree(node) {
2714
+ return (node.flags & 64) !== 0;
2715
+ }
2716
+ function placementRunTail(node) {
2717
+ let tail = node;
2718
+ while (tail.sibling !== null && (tail.sibling.flags & 1) !== 0) tail = tail.sibling;
2719
+ return tail;
2720
+ }
2721
+ function commitPlacement(node, before = hostSibling(node)) {
2722
+ if (isHost(node)) {
2723
+ if (node.tag === 1 && isHoistedFiber(node)) {
2724
+ if (node.committedProps === null) acquireHoistedInstance(node);
2725
+ markHostCommitted(node);
2726
+ markHostSubtreeCommitted(node.child);
2727
+ return;
2728
+ }
2729
+ if (shouldCommitPlacementUpdate(node)) commitUpdate(node);
2730
+ host.insertBefore(hostParent(node), hostNode(node), before);
2731
+ markHostCommitted(node);
2732
+ if (isPreassembledHostSubtree(node)) markHostSubtreeCommitted(node.child);
2733
+ } else if (node.tag === 8) {
2734
+ commitPortal(node);
2735
+ if (node.alternate !== null) insertPortalChildren(node);
2736
+ } else if (node.alternate !== null) insertHostSubtree(node, hostParent(node), before);
2737
+ }
2738
+ function commitPortal(node) {
2739
+ host.preparePortalContainer?.(portalTarget(node), rootOf(node).container, hostParent(node));
2740
+ }
2741
+ function shouldCommitPlacementUpdate(node) {
2742
+ if ((node.flags & 10) !== 0) return true;
2743
+ if (node.alternate !== null || node.tag === 2) return false;
2744
+ return host.finalizeInitialInstance === void 0;
2745
+ }
2746
+ function insertHostSubtree(node, parent, before) {
2747
+ visitHostNodes(node, (child) => host.insertBefore(parent, child, before));
2748
+ }
2749
+ function insertPortalChildren(node) {
2750
+ const parent = portalTarget(node);
2751
+ for (let child = node.child; child !== null; child = child.sibling) visitHostNodes(child, (hostChild) => host.insertBefore(parent, hostChild, null));
2752
+ }
2753
+ function commitUpdate(node) {
2754
+ if (node.tag === 2) host.commitTextUpdate(node.stateNode, String(node.props.nodeValue));
2755
+ else if (node.tag === 1 && isHoistedFiber(node)) commitHoistedUpdate(node);
2756
+ else if ((node.flags & 4) !== 0 && host.commitHydratedInstance !== void 0) host.commitHydratedInstance(node.stateNode, node.props);
2757
+ else {
2758
+ const previousProps = previousCommittedProps(node);
2759
+ if ((node.flags & 2) !== 0) host.commitUpdate(node.stateNode, previousProps, node.props);
2760
+ if ((node.flags & 8) !== 0) commitHostTextContent(node, previousProps);
2761
+ }
2762
+ markHostCommitted(node);
2763
+ }
2764
+ function commitHoistedUpdate(node) {
2765
+ const hoistedHost = requireHoistedAssetHostConfig();
2766
+ const previousProps = previousCommittedProps(node);
2767
+ const instance = node.stateNode;
2768
+ const next = hoistedHost.updateHoistedInstance(instance, previousProps, node.props) ?? instance;
2769
+ if (next !== instance) {
2770
+ adoptSwappedHoistedInstance(node, next);
2771
+ return;
2772
+ }
2773
+ if ((node.flags & 8) !== 0) commitHostTextContent(node, previousProps);
2774
+ }
2775
+ function adoptSwappedHoistedInstance(node, next) {
2776
+ node.stateNode = next;
2777
+ if (node.alternate !== null) node.alternate.stateNode = next;
2778
+ const text = hostTextContent(node.props.children);
2779
+ if (text !== null) host.setTextContent?.(next, text);
2780
+ }
2781
+ function commitHydratedSuspenseBoundary(node) {
2782
+ const boundary = dehydratedSuspenseBoundary(node.alternate);
2783
+ if (boundary === null) return;
2784
+ host.commitHydratedSuspenseBoundary?.(boundary);
2785
+ }
2786
+ function commitHydratedActivityBoundary(node) {
2787
+ const state = fiberActivityState(node);
2788
+ if (state?.dehydrated == null) return;
2789
+ requireActivityHydrationHostConfig().commitHydratedActivityBoundary(state.dehydrated);
2790
+ state.dehydrated = null;
2791
+ }
2792
+ function commitHostTextContent(node, previousProps) {
2793
+ if (host.setTextContent === void 0 || node.tag !== 1) return;
2794
+ const nextText = hostTextContent(node.props.children);
2795
+ if (nextText !== null) host.setTextContent(node.stateNode, nextText);
2796
+ else if (hostTextContent(previousProps.children) !== null) host.setTextContent(node.stateNode, "");
2797
+ }
2798
+ function previousCommittedProps(node) {
2799
+ return node.committedProps ?? node.alternate?.committedProps ?? node.alternate?.memoizedProps ?? {};
2800
+ }
2801
+ function markHostCommitted(node) {
2802
+ if (!isHost(node)) return;
2803
+ node.committedProps = node.props;
2804
+ if (node.alternate !== null) node.alternate.committedProps = node.props;
2805
+ }
2806
+ function markHostSubtreeCommitted(node) {
2807
+ walkFiberForest(node, (child) => {
2808
+ if (child.committedProps === null && isHoistedFiber(child)) acquireHoistedInstance(child);
2809
+ markHostCommitted(child);
2810
+ });
2811
+ }
2812
+ function acquireHoistedInstance(node) {
2813
+ const hoistedHost = requireHoistedAssetHostConfig();
2814
+ const instance = node.stateNode;
2815
+ const resolved = hoistedHost.commitHoistedInstance(instance) ?? instance;
2816
+ if (resolved === instance) return;
2817
+ adoptSwappedHoistedInstance(node, resolved);
2818
+ }
2819
+ function commitHostUpdates(root) {
2820
+ for (const cursor of root.commitIndex) {
2821
+ if ((cursor.flags & 10) === 0 || !isHost(cursor)) continue;
2822
+ if ((cursor.flags & 5) !== 0) continue;
2823
+ if (cursor.committedProps === null && cursor.tag !== 2) continue;
2824
+ commitHostMutation(cursor, () => commitUpdate(cursor));
2825
+ if (hasHiddenBoundaries && isInsideHiddenBoundary(cursor)) hideHostFiber(cursor);
2826
+ cursor.flags &= -11;
2827
+ }
2828
+ }
2829
+ function commitDeletions(root) {
2830
+ const store = root.dataStore;
2831
+ for (const cursor of root.commitIndex) {
2832
+ if (cursor.deletions === null) continue;
2833
+ const parent = isHostParent(cursor) ? hostParentFor(cursor) : hostParent(cursor);
2834
+ for (const child of cursor.deletions) {
2835
+ walkFiberSubtree(child, (deleted) => {
2836
+ deleteFiberDataOwner(deleted, store);
2837
+ abortFiberHooks(deleted, false);
2838
+ });
2839
+ child.return = null;
2840
+ if (child.alternate !== null) child.alternate.return = null;
2841
+ remove(child, parent);
2842
+ }
2843
+ cursor.deletions = null;
2844
+ }
2845
+ }
2846
+ function commitDataDependencies(root) {
2847
+ for (const cursor of root.commitIndex) {
2848
+ if (!cursor.dataDependenciesDirty) continue;
2849
+ root.dataStore.commitDataDependencies(cursor, cursor.alternate);
2850
+ cursor.dataDependenciesDirty = false;
2851
+ if (cursor.alternate !== null) cursor.alternate.dataDependenciesDirty = false;
2852
+ }
2853
+ }
2854
+ function deleteFiberDataTree(node) {
2855
+ const store = rootOf(node).dataStore;
2856
+ walkFiberForest(node, (cursor) => {
2857
+ deleteFiberDataOwner(cursor, store);
2858
+ });
2859
+ }
2860
+ function deleteFiberDataOwner(node, store) {
2861
+ store.releaseDataOwner(node);
2862
+ if (node.alternate !== null) store.releaseDataOwner(node.alternate);
2863
+ const state = fiberActivityState(node);
2864
+ if (state !== null) hiddenStates.delete(state);
2865
+ }
2866
+ function dehydratedActivityBoundary(node) {
2867
+ return node.tag === 10 ? fiberActivityState(node)?.dehydrated ?? null : null;
2868
+ }
2869
+ function remove(node, parent) {
2870
+ const dehydratedActivity = dehydratedActivityBoundary(node);
2871
+ if (dehydratedActivity !== null) {
2872
+ host.removeChild(parent, dehydratedActivity);
2873
+ return;
2874
+ }
2875
+ const boundary = dehydratedSuspenseBoundary(node);
2876
+ if (boundary !== null && host.removeDehydratedSuspenseBoundary !== void 0) {
2877
+ host.removeDehydratedSuspenseBoundary(boundary);
2878
+ return;
2879
+ }
2880
+ if (node.tag === 8) {
2881
+ removePortalChildren(node);
2882
+ host.removePortalContainer?.(portalTarget(node));
2883
+ return;
2884
+ }
2885
+ if (node.tag === 1 && isHoistedFiber(node)) {
2886
+ if (node.committedProps !== null) requireHoistedAssetHostConfig().removeHoistedInstance(node.stateNode);
2887
+ return;
2888
+ }
2889
+ if (isHost(node)) {
2890
+ removePortalDescendants(node.child);
2891
+ removeHoistedDescendants(node.child);
2892
+ host.removeChild(parent, hostNode(node));
2893
+ return;
2894
+ }
2895
+ for (let child = node.child; child !== null; child = child.sibling) remove(child, parent);
2896
+ }
2897
+ function removeHoistedDescendants(node) {
2898
+ if (host.isHoistedInstance === void 0) return;
2899
+ for (let child = node; child !== null; child = child.sibling) {
2900
+ if (child.tag === 8) continue;
2901
+ if (child.tag === 1 && isHoistedFiber(child)) {
2902
+ if (child.committedProps !== null && child.stateNode !== null) requireHoistedAssetHostConfig().removeHoistedInstance(child.stateNode);
2903
+ continue;
2904
+ }
2905
+ removeHoistedDescendants(child.child);
2906
+ }
2907
+ }
2908
+ function removePortalChildren(node) {
2909
+ const parent = portalTarget(node);
2910
+ for (let child = node.child; child !== null; child = child.sibling) remove(child, parent);
2911
+ }
2912
+ function removePortalDescendants(node) {
2913
+ for (let child = node; child !== null; child = child.sibling) if (child.tag === 8) {
2914
+ removePortalChildren(child);
2915
+ host.removePortalContainer?.(portalTarget(child));
2916
+ } else removePortalDescendants(child.child);
2917
+ }
2918
+ function visitHostNodes(node, visitor) {
2919
+ if (isHost(node)) {
2920
+ if (node.tag === 1 && isHoistedFiber(node)) return;
2921
+ visitor(hostNode(node));
2922
+ return;
2923
+ }
2924
+ if (node.tag === 8) return;
2925
+ for (let child = node.child; child !== null; child = child.sibling) visitHostNodes(child, visitor);
2926
+ }
2927
+ function hostParent(node) {
2928
+ for (let parent = node.return; parent !== null; parent = parent.return) if (isHostParent(parent)) return hostParentFor(parent);
2929
+ throw new Error("Could not find a host parent for fiber.");
2930
+ }
2931
+ function hostSibling(node) {
2932
+ const dehydratedBoundary = dehydratedSuspenseParent(node);
2933
+ if (dehydratedBoundary !== null) return dehydratedBoundary.start;
2934
+ let cursor = node;
2935
+ search: while (true) {
2936
+ while (cursor.sibling === null) {
2937
+ if (cursor.return === null || isHostParent(cursor.return)) return null;
2938
+ cursor = cursor.return;
2939
+ }
2940
+ cursor = cursor.sibling;
2941
+ while (!isHost(cursor)) {
2942
+ const dehydratedActivity = dehydratedActivityBoundary(cursor);
2943
+ if (dehydratedActivity !== null) return dehydratedActivity;
2944
+ if (cursor.tag === 8 || (cursor.flags & 1) !== 0 || cursor.child === null) continue search;
2945
+ cursor = cursor.child;
2946
+ }
2947
+ if ((cursor.flags & 1) === 0 && !isHoistedFiber(cursor)) return hostNode(cursor);
2948
+ }
2949
+ }
2950
+ function dehydratedSuspenseParent(node) {
2951
+ for (let parent = node.return; parent !== null; parent = parent.return) {
2952
+ if ((parent.flags & 4) !== 0) {
2953
+ const boundary = dehydratedSuspenseBoundary(parent.alternate);
2954
+ if (boundary !== null && (boundary.status !== "completed" || boundary.forceClientRender)) return boundary;
2955
+ }
2956
+ if (isHostParent(parent)) return null;
2957
+ }
2958
+ return null;
2959
+ }
2960
+ function isHostParent(node) {
2961
+ return node.tag === 0 || node.tag === 1 || node.tag === 8;
2962
+ }
2963
+ function hostParentFor(node) {
2964
+ if (node.tag === 0) return node.stateNode.container;
2965
+ if (node.tag === 1) return node.stateNode;
2966
+ return portalTarget(node);
2967
+ }
2968
+ function dehydratedSuspenseBoundary(node) {
2969
+ const state = fiberSuspenseState(node);
2970
+ return state?.kind === "dehydrated" ? state.boundary : null;
2971
+ }
2972
+ function fiberSuspenseState(node) {
2973
+ return node?.tag === 6 ? node.boundaryState : null;
2974
+ }
2975
+ function fiberErrorBoundaryState(node) {
2976
+ return node?.tag === 7 ? node.boundaryState : null;
2977
+ }
2978
+ function fiberActivityState(node) {
2979
+ return node?.tag === 10 ? node.boundaryState : null;
2980
+ }
2981
+ function ensureFiberActivityState(node) {
2982
+ const current = fiberActivityState(node);
2983
+ if (current !== null) return current;
2984
+ const state = {
2985
+ hidden: false,
2986
+ dehydrated: null
2987
+ };
2988
+ node.boundaryState = state;
2989
+ return state;
2990
+ }
2991
+ function scheduleFiber(node, lane) {
2992
+ markLanes(node, lane);
2993
+ const root = scheduleParentPath(node.return, lane);
2994
+ const alternateRoot = scheduleParentPath(node.alternate?.return ?? null, lane);
2995
+ const scheduledRoot = root ?? alternateRoot;
2996
+ if (scheduledRoot === null) return;
2997
+ markRootPending(scheduledRoot, lane);
2998
+ scheduleOrBatchRoot(scheduledRoot);
2999
+ }
3000
+ function scheduleParentPath(parent, lane) {
3001
+ for (; parent !== null; parent = parent.return) {
3002
+ markChildLanes(parent, lane);
3003
+ if (parent.tag === 0) return parent.stateNode;
3004
+ }
3005
+ return null;
3006
+ }
3007
+ function attachPing(root, thenable, lanes) {
3008
+ if (lanes === 0) return;
3009
+ const previousLanes = root.suspendedThenables.get(thenable) ?? 0;
3010
+ root.suspendedThenables.set(thenable, mergeLanes(previousLanes, lanes));
3011
+ if (previousLanes !== 0) return;
3012
+ thenable.then(() => ping(root, thenable), () => ping(root, thenable));
3013
+ }
3014
+ function ping(root, thenable) {
3015
+ const lanes = root.suspendedThenables.get(thenable) ?? 0;
3016
+ if (lanes === 0) return;
3017
+ root.suspendedThenables.delete(thenable);
3018
+ markRootPinged(root, lanes);
3019
+ pendingRoots.add(root);
3020
+ scheduleRoot(root);
3021
+ }
3022
+ function findSuspenseBoundary(node) {
3023
+ for (let parent = node.return; parent !== null; parent = parent.return) if (parent.tag === 6 && fiberSuspenseState(parent) === null) return parent;
3024
+ return null;
3025
+ }
3026
+ function findErrorBoundary(node) {
3027
+ for (let parent = node.return; parent !== null; parent = parent.return) if (parent.tag === 7 && fiberErrorBoundaryState(parent) === null) return parent;
3028
+ return null;
3029
+ }
3030
+ function captureSuspenseBoundary(boundary, thenable) {
3031
+ const root = rootOf(boundary);
3032
+ const lanes = root.renderLanes;
3033
+ attachPing(root, thenable, lanes);
3034
+ root.pendingSuspenseRetries.push({
3035
+ boundary,
3036
+ thenable,
3037
+ lanes
3038
+ });
3039
+ rollbackCommitIndex(root.commitIndex, boundary.commitIndexCheckpoint);
3040
+ if (boundary.deletions !== null) recordCommitWork(root.commitIndex, boundary);
3041
+ const dehydrated = fiberSuspenseState(boundary.alternate);
3042
+ if (root.hydratingSuspenseBoundary === boundary && dehydrated?.kind === "dehydrated") {
3043
+ leaveSuspenseHydration(root, boundary, dehydrated.boundary);
3044
+ boundary.boundaryState = dehydrated;
3045
+ boundary.flags &= -5;
3046
+ boundary.child = null;
3047
+ abandonedHydrationBoundaries.add(boundary);
3048
+ if (boundary.alternate !== null) abandonedHydrationBoundaries.add(boundary.alternate);
3049
+ return completeUnit(boundary);
3050
+ }
3051
+ if (shouldPreserveSuspenseBoundary(root, boundary)) {
3052
+ markRootSuspended(root, lanes);
3053
+ throw PreservedSuspense;
3054
+ }
3055
+ const currentPrimary = suspensePrimaryFiber(boundary.alternate);
3056
+ if (currentPrimary !== null) {
3057
+ boundary.boundaryState = {
3058
+ kind: "fallback",
3059
+ primaryChild: null
3060
+ };
3061
+ boundary.deletions = null;
3062
+ restoreConsumedPendingQueuesForRetry(root, boundary.suspenseQueueStart ?? root.consumedPendingQueues.length);
3063
+ hasHiddenBoundaries = true;
3064
+ const primary = suspensePrimaryWorkInProgress(boundary, currentPrimary, "hidden");
3065
+ primary.child = cloneSuspendedPrimary(currentPrimary.child, primary);
3066
+ primary.flags |= 32;
3067
+ primary.memoizedProps = primary.props;
3068
+ primary.lanes = 0;
3069
+ primary.childLanes = 0;
3070
+ boundary.child = primary;
3071
+ const fallback = suspenseFallbackWorkInProgress(boundary, currentPrimary.sibling, 1);
3072
+ primary.sibling = fallback;
3073
+ return fallback;
3074
+ }
3075
+ boundary.boundaryState = {
3076
+ kind: "fallback",
3077
+ primaryChild: boundary.child?.tag === 10 && boundary.child.type === null ? boundary.child.child : boundary.child
3078
+ };
3079
+ const fallback = suspenseFallbackWorkInProgress(boundary, null, 0);
3080
+ boundary.child = fallback;
3081
+ return fallback;
3082
+ }
3083
+ function captureErrorBoundary(boundary, error, source) {
3084
+ const root = rootOf(boundary);
3085
+ rollbackCommitIndex(root.commitIndex, boundary.commitIndexCheckpoint);
3086
+ recordCommitWork(root.commitIndex, boundary);
3087
+ const state = createErrorBoundaryState(error, source);
3088
+ boundary.boundaryState = state;
3089
+ reconcileCurrentChildren(boundary, errorBoundaryFallback(boundary, state));
3090
+ return boundary.child ?? completeUnit(boundary);
3091
+ }
3092
+ function captureCommittedErrorBoundary(boundary, error, source) {
3093
+ rootOf(boundary).committedCaughtErrors.push(boundary);
3094
+ const state = createErrorBoundaryState(error, source);
3095
+ boundary.boundaryState = state;
3096
+ if (boundary.alternate !== null) boundary.alternate.boundaryState = state;
3097
+ }
3098
+ function createErrorBoundaryState(error, source) {
3099
+ return {
3100
+ error,
3101
+ info: errorInfoFor(source, error),
3102
+ didReport: false
3103
+ };
3104
+ }
3105
+ function shouldPreserveSuspenseBoundary(root, boundary) {
3106
+ return boundary.alternate !== null && fiberSuspenseState(boundary.alternate) === null && isTransitionOrDeferredRender(root);
3107
+ }
3108
+ function attachCommittedSuspenseRetries(root, retries) {
3109
+ for (const { boundary, thenable, lanes } of retries) {
3110
+ let attached = root.attachedSuspenseRetries.get(thenable);
3111
+ if (attached === void 0) {
3112
+ attached = /* @__PURE__ */ new WeakSet();
3113
+ root.attachedSuspenseRetries.set(thenable, attached);
3114
+ }
3115
+ if (attached.has(boundary) || boundary.alternate !== null && attached.has(boundary.alternate)) continue;
3116
+ attached.add(boundary);
3117
+ const retry = () => scheduleFiber(boundary, suspenseRetryLane(lanes));
3118
+ thenable.then(retry, retry);
3119
+ }
3120
+ }
3121
+ function lazilyPropagateParentContextChanges(node, root) {
3122
+ if ((node.flags & 1024) !== 0) return false;
3123
+ const contexts = changedParentContexts(node);
3124
+ node.flags |= ContextPropagationFlag;
3125
+ if (contexts === null) return false;
3126
+ const current = node.alternate;
3127
+ if (current === null) return false;
3128
+ for (const context of contexts) {
3129
+ if (!contextListIncludes(current.contextSubtreeDependencies, context)) continue;
3130
+ for (let child = current.child; child !== null; child = child.sibling) markContextConsumers(child, current, context, root.renderLanes);
3131
+ }
3132
+ return includesSomeLane(node.childLanes, root.renderLanes);
3133
+ }
3134
+ function changedParentContexts(node) {
3135
+ let seen = node.tag === 5 ? [node.type] : null;
3136
+ let changed = null;
3137
+ for (let parent = node.return; parent !== null; parent = parent.return) {
3138
+ if ((parent.flags & 1024) !== 0) break;
3139
+ if (parent.tag !== 5) continue;
3140
+ const context = parent.type;
3141
+ if (contextListIncludes(seen, context)) continue;
3142
+ seen = appendContext(seen, context);
3143
+ if (changedContextProvider(parent)) changed = appendContext(changed, context);
3144
+ }
3145
+ return changed;
3146
+ }
3147
+ function markContextConsumers(node, propagationRoot, context, lanes) {
3148
+ if (node.tag === 5 && node.type === context) return;
3149
+ if (contextDependency(node, context) !== null) {
3150
+ markLanes(node, lanes);
3151
+ markParentPath(node, propagationRoot, lanes);
3152
+ }
3153
+ if (!contextListIncludes(node.contextSubtreeDependencies, context)) return;
3154
+ for (let child = node.child; child !== null; child = child.sibling) markContextConsumers(child, propagationRoot, context, lanes);
3155
+ }
3156
+ function markParentPath(node, stopAt, lanes) {
3157
+ for (let parent = node.return; parent !== null && parent !== stopAt; parent = parent.return) markChildLanes(parent, lanes);
3158
+ markChildLanes(stopAt, lanes);
3159
+ }
3160
+ function markLanes(node, lane) {
3161
+ node.lanes = mergeLanes(node.lanes, lane);
3162
+ if (node.alternate !== null) node.alternate.lanes = mergeLanes(node.alternate.lanes, lane);
3163
+ }
3164
+ function markChildLanes(node, lane) {
3165
+ node.childLanes = mergeLanes(node.childLanes, lane);
3166
+ if (node.alternate !== null) node.alternate.childLanes = mergeLanes(node.alternate.childLanes, lane);
3167
+ }
3168
+ function markSubtreeFlag(node, flag) {
3169
+ for (let parent = node.return; parent !== null; parent = parent.return) parent.subtreeFlags |= flag;
3170
+ }
3171
+ function createWorkInProgress(current, props) {
3172
+ const next = current.alternate ?? fiber(current.tag, current.type, current.key, props, current.stateNode);
3173
+ next.props = props;
3174
+ next.memoizedProps = current.memoizedProps;
3175
+ next.committedProps = current.committedProps;
3176
+ next.memoizedState = current.memoizedState;
3177
+ next.stateNode = current.stateNode;
3178
+ next.return = current.return;
3179
+ next.child = null;
3180
+ next.sibling = null;
3181
+ next.index = current.index;
3182
+ next.flags = 0;
3183
+ next.subtreeFlags = 0;
3184
+ next.deletions = null;
3185
+ next.lanes = current.lanes;
3186
+ next.childLanes = current.childLanes;
3187
+ next.effects = null;
3188
+ next.contextDependencies = current.contextDependencies;
3189
+ next.contextSubtreeDependencies = current.contextSubtreeDependencies;
3190
+ next.dataDependenciesDirty = false;
3191
+ next.boundaryState = current.boundaryState;
3192
+ next.hiddenState = null;
3193
+ next.alternate = current;
3194
+ current.alternate = next;
3195
+ return next;
3196
+ }
3197
+ function cloneChildFibers(parent) {
3198
+ let current = parent.alternate?.child ?? null;
3199
+ let previous = null;
3200
+ parent.child = null;
3201
+ parent.deletions = null;
3202
+ while (current !== null) {
3203
+ const next = createWorkInProgress(current, current.props);
3204
+ next.return = parent;
3205
+ previous = appendChild(parent, previous, next);
3206
+ current = current.sibling;
3207
+ }
3208
+ }
3209
+ function appendChild(parent, previous, child) {
3210
+ if (previous === null) parent.child = child;
3211
+ else previous.sibling = child;
3212
+ return child;
3213
+ }
3214
+ function fiberFrom(child) {
3215
+ if (typeof child === "string") return fiber(2, null, null, { nodeValue: child }, null);
3216
+ if (isPortal(child)) return fiber(8, null, child.key, portalProps(child), null);
3217
+ if (!isValidElement(child)) return null;
3218
+ return fiber(tagFor(child), child.type, child.key, child.props, null);
3219
+ }
3220
+ function portalTarget(node) {
3221
+ return node.props.target;
3222
+ }
3223
+ function fiber(tag, type, key, props, stateNode) {
3224
+ return {
3225
+ tag,
3226
+ type,
3227
+ key,
3228
+ props,
3229
+ memoizedProps: null,
3230
+ committedProps: null,
3231
+ memoizedState: null,
3232
+ stateNode,
3233
+ return: null,
3234
+ child: null,
3235
+ sibling: null,
3236
+ index: 0,
3237
+ alternate: null,
3238
+ flags: 0,
3239
+ subtreeFlags: 0,
3240
+ deletions: null,
3241
+ lanes: 0,
3242
+ childLanes: 0,
3243
+ effects: null,
3244
+ contextDependencies: null,
3245
+ contextSubtreeDependencies: null,
3246
+ dataDependenciesDirty: false,
3247
+ boundaryState: null,
3248
+ hiddenState: null
3249
+ };
3250
+ }
3251
+ function rootOf(node) {
3252
+ const root = rootOfOrNull(node);
3253
+ if (root === null) throw new Error("Could not find a root for fiber.");
3254
+ return root;
3255
+ }
3256
+ function rootOfOrNull(node) {
3257
+ for (let parent = node; parent !== null; parent = parent.return) if (parent.tag === 0) return parent.stateNode;
3258
+ return null;
3259
+ }
3260
+ function errorInfoFor(node, error) {
3261
+ const dataResourceKeys = error === void 0 ? void 0 : dataResourceKeysForError(error);
3262
+ return dataResourceKeys === void 0 ? { componentStack: componentStackFor(node) } : {
3263
+ componentStack: componentStackFor(node),
3264
+ dataResourceKeys
3265
+ };
3266
+ }
3267
+ function queueRecoverableError(root, node, error, details) {
3268
+ root.recoverableErrors.push({
3269
+ error,
3270
+ info: {
3271
+ ...details,
3272
+ componentStack: componentStackFor(node)
3273
+ }
3274
+ });
3275
+ }
3276
+ function componentStackFor(node) {
3277
+ const frames = [];
3278
+ for (let fiber = node; fiber !== null; fiber = fiber.return) {
3279
+ const name = componentStackName(fiber);
3280
+ if (name !== null) frames.push(` at ${name}`);
3281
+ }
3282
+ return frames.length === 0 ? "" : `\n${frames.join("\n")}`;
3283
+ }
3284
+ function componentStackName(node) {
3285
+ switch (node.tag) {
3286
+ case 3: return devtoolsTypeName(node.type, "Anonymous");
3287
+ case 5: return `${devtoolsTypeName(node.type, "Context")}.Provider`;
3288
+ case 6: return "Suspense";
3289
+ case 7: return "ErrorBoundary";
3290
+ case 11: return "ViewTransition";
3291
+ case 8: return "Portal";
3292
+ case 9: return "Assets";
3293
+ default: return null;
3294
+ }
3295
+ }
3296
+ return {
3297
+ batchedUpdates,
3298
+ createRoot,
3299
+ hydrateRoot,
3300
+ hydrateTarget,
3301
+ flushSync,
3302
+ scheduleRefresh
3303
+ };
3304
+ function scheduleRefresh(update) {}
3305
+ function findDehydratedSuspenseBoundaryForTarget(node, target) {
3306
+ if (node === null || host.isTargetWithinSuspenseBoundary === void 0) return null;
3307
+ const state = fiberSuspenseState(node);
3308
+ if (state?.kind === "dehydrated" && host.isTargetWithinSuspenseBoundary(target, state.boundary)) return node;
3309
+ return findDehydratedSuspenseBoundaryForTarget(node.child, target) ?? findDehydratedSuspenseBoundaryForTarget(node.sibling, target);
3310
+ }
3311
+ function isHiddenBoundary(node) {
3312
+ return isHiddenBoundaryTag(node) && activityHidden(node.props);
3313
+ }
3314
+ function isHiddenBoundaryTag(node) {
3315
+ return node.tag === 10;
3316
+ }
3317
+ function requireActivityHostConfig() {
3318
+ if (activityHostConfig !== null) return activityHostConfig;
3319
+ if (host.hideInstance === void 0 || host.unhideInstance === void 0 || host.hideTextInstance === void 0 || host.unhideTextInstance === void 0) throw new Error("Activity is not supported by this renderer.");
3320
+ activityHostConfig = host;
3321
+ return activityHostConfig;
3322
+ }
3323
+ function commitHiddenBoundaryVisibility(node, hidden = false) {
3324
+ for (let cursor = node; cursor !== null; cursor = cursor.sibling) {
3325
+ if ((cursor.flags & 16) !== 0) continue;
3326
+ const subtreeVisibility = (cursor.subtreeFlags & 32) !== 0;
3327
+ if ((cursor.flags & 32) === 0 && !subtreeVisibility) continue;
3328
+ const boundary = isHiddenBoundaryTag(cursor);
3329
+ const boundaryHidden = boundary && activityHidden(cursor.props);
3330
+ if (boundary && (cursor.flags & 32) !== 0) {
3331
+ const effectiveHidden = hidden || boundaryHidden;
3332
+ const state = fiberActivityState(cursor);
3333
+ if (state !== null) {
3334
+ state.hidden = effectiveHidden;
3335
+ if (effectiveHidden) hiddenStates.add(state);
3336
+ else hiddenStates.delete(state);
3337
+ }
3338
+ setSubtreeVisibility(cursor.child, effectiveHidden);
3339
+ if (effectiveHidden && cursor.child !== null) abortFiberEffects(cursor.child, true);
3340
+ if (!effectiveHidden && includesSomeLane(cursor.childLanes, 536870912)) {
3341
+ const root = rootOf(cursor);
3342
+ markRootPending(root, 32);
3343
+ markRootEntangled(root, 536870944);
3344
+ scheduleOrBatchRoot(root);
3345
+ }
3346
+ }
3347
+ if (subtreeVisibility) commitHiddenBoundaryVisibility(cursor.child, hidden || boundaryHidden);
3348
+ }
3349
+ }
3350
+ function setSubtreeVisibility(node, hidden) {
3351
+ for (let cursor = node; cursor !== null; cursor = cursor.sibling) setNodeVisibility(cursor, hidden);
3352
+ }
3353
+ function setNodeVisibility(cursor, hidden) {
3354
+ if (isHiddenBoundary(cursor)) return;
3355
+ if (cursor.tag === 1) {
3356
+ const activityHost = requireActivityHostConfig();
3357
+ if (hidden) activityHost.hideInstance(cursor.stateNode);
3358
+ else activityHost.unhideInstance(cursor.stateNode, cursor.props);
3359
+ } else if (cursor.tag === 2) {
3360
+ const activityHost = requireActivityHostConfig();
3361
+ if (hidden) activityHost.hideTextInstance(cursor.stateNode);
3362
+ else activityHost.unhideTextInstance(cursor.stateNode, String(cursor.props.nodeValue));
3363
+ }
3364
+ setSubtreeVisibility(cursor.child, hidden);
3365
+ }
3366
+ function hideHostFiber(node) {
3367
+ const activityHost = requireActivityHostConfig();
3368
+ if (node.tag === 1) activityHost.hideInstance(node.stateNode);
3369
+ else activityHost.hideTextInstance(node.stateNode);
3370
+ }
3371
+ function armRevealedHiddenBoundaries(node) {
3372
+ for (let cursor = node; cursor !== null; cursor = cursor.sibling) {
3373
+ if ((cursor.flags & 16) !== 0) continue;
3374
+ const subtreeVisibility = (cursor.subtreeFlags & 32) !== 0;
3375
+ if ((cursor.flags & 32) === 0 && !subtreeVisibility) continue;
3376
+ if (isHiddenBoundaryTag(cursor) && (cursor.flags & 32) !== 0 && !activityHidden(cursor.props) && cursor.child !== null) armDeferredEffects(cursor.child);
3377
+ if (subtreeVisibility) armRevealedHiddenBoundaries(cursor.child);
3378
+ }
3379
+ }
3380
+ function armDeferredEffects(node) {
3381
+ visitFiberHooks(node, (owner, hook) => {
3382
+ if (hook.kind === 10) {
3383
+ const state = hook.memoizedState;
3384
+ const instance = state.instance;
3385
+ instance.handler = state.next;
3386
+ instance.live = true;
3387
+ return;
3388
+ }
3389
+ if (!isEffectHook(hook.kind)) return;
3390
+ const effect = hook.memoizedState;
3391
+ if (effect.controller !== null) return;
3392
+ const effects = owner.effects ??= [];
3393
+ if (!effects.includes(effect)) effects.push(effect);
3394
+ const root = rootOf(owner);
3395
+ recordCommitWork(root.commitIndex, owner, 512);
3396
+ markSubtreeFlag(owner, 512);
3397
+ markCommitEffectPhase(root, effect.phase);
3398
+ });
3399
+ }
3400
+ function commitLiveHookInstances(root) {
3401
+ for (const owner of root.commitIndex) for (let hook = owner.memoizedState; hook !== null; hook = hook.next) commitLiveHookInstance(owner, hook);
3402
+ }
3403
+ function commitLiveHookInstance(owner, hook) {
3404
+ if (isStableEventHook(hook)) {
3405
+ const instance = hook.memoizedState.instance;
3406
+ instance.handler = hook.memoizedState.next;
3407
+ instance.live = !hasHiddenBoundaries || !isInsideHiddenBoundary(owner);
3408
+ }
3409
+ if (hook.kind === 4) {
3410
+ const state = hook.memoizedState;
3411
+ state.instance.action = state.action;
3412
+ state.instance.value = state.value;
3413
+ }
3414
+ }
3415
+ function isInsideHiddenBoundary(node) {
3416
+ for (let parent = node.return; parent !== null; parent = parent.return) if (isHiddenBoundary(parent)) return true;
3417
+ return false;
3418
+ }
3419
+ function isStableEventHook(hook) {
3420
+ return hook.kind === 10;
3421
+ }
3422
+ function commitExternalStores(root) {
3423
+ for (const cursor of root.commitIndex) {
3424
+ if ((cursor.flags & 2048) === 0) continue;
3425
+ if (hasHiddenBoundaries && isInsideHiddenBoundary(cursor)) continue;
3426
+ for (let hook = cursor.memoizedState; hook !== null; hook = hook.next) if (isExternalStoreHook(hook)) commitExternalStore(root, cursor, hook.memoizedState);
3427
+ }
3428
+ }
3429
+ function commitExternalStore(root, owner, state) {
3430
+ const instance = state.instance;
3431
+ if (instance.committedSubscribe !== state.subscribe) {
3432
+ instance.unsubscribe?.();
3433
+ instance.unsubscribe = null;
3434
+ instance.committedSubscribe = state.subscribe;
3435
+ }
3436
+ instance.getSnapshot = state.getSnapshot;
3437
+ instance.owner = owner;
3438
+ instance.value = state.value;
3439
+ root.externalStores.add(instance);
3440
+ instance.unsubscribe ??= state.subscribe(() => {
3441
+ scheduleExternalStoreIfChanged(instance.owner, instance, requestExternalStoreUpdateLane());
3442
+ });
3443
+ scheduleExternalStoreIfChanged(instance.owner, instance, 2);
3444
+ }
3445
+ function scheduleExternalStoreIfChanged(owner, instance, lane) {
3446
+ if (owner === null) return;
3447
+ const latestValue = instance.getSnapshot();
3448
+ if (!Object.is(latestValue, instance.value)) scheduleFiber(owner, lane);
3449
+ }
3450
+ function requestExternalStoreUpdateLane() {
3451
+ const lane = requestUpdateLane();
3452
+ return lane === 32 ? 2 : lane;
3453
+ }
3454
+ function commitEffects(root, node, phase) {
3455
+ const mask = 1 << phase;
3456
+ if ((root.commitEffectPhases & mask) === 0) return;
3457
+ const runEffects = () => {
3458
+ for (const owner of root.commitIndex) {
3459
+ const effects = owner.effects;
3460
+ if (effects === null) continue;
3461
+ if (hasHiddenBoundaries && isInsideHiddenBoundary(owner)) continue;
3462
+ for (const effect of effects) {
3463
+ if (effect.phase !== phase) continue;
3464
+ runCommitEffect(effect, phase);
3465
+ }
3466
+ }
3467
+ };
3468
+ if (phase === 1) runWithPriority(2, runEffects);
3469
+ else runEffects();
3470
+ root.commitEffectPhases &= ~mask;
3471
+ }
3472
+ function runCommitEffect(effect, phase) {
3473
+ const previousPhase = currentCommitEffectPhase;
3474
+ currentCommitEffectPhase = phase;
3475
+ try {
3476
+ runEffect(effect);
3477
+ } finally {
3478
+ currentCommitEffectPhase = previousPhase;
3479
+ }
3480
+ }
3481
+ function collectReactiveEffects(root, node) {
3482
+ walkFiberForest(node, (cursor) => {
3483
+ for (const effect of cursor.effects ?? []) if (effect.phase === 0) root.pendingReactiveEffects.push(effect);
3484
+ cursor.effects = null;
3485
+ const adopted = (cursor.flags & 16) !== 0;
3486
+ const subtreeFlags = cursor.subtreeFlags;
3487
+ clearTransientFlags(cursor);
3488
+ if (adopted) return false;
3489
+ if (isHiddenBoundary(cursor)) {
3490
+ if (subtreeFlags !== 0) clearHiddenSubtreeFlags(cursor.child);
3491
+ return false;
3492
+ }
3493
+ return (subtreeFlags & -4097) !== 0;
3494
+ });
3495
+ }
3496
+ function clearHiddenSubtreeFlags(node) {
3497
+ walkFiberForest(node, (cursor) => {
3498
+ const adopted = (cursor.flags & 16) !== 0;
3499
+ const subtreeFlags = cursor.subtreeFlags;
3500
+ clearTransientFlags(cursor);
3501
+ return !adopted && (subtreeFlags & -4097) !== 0;
3502
+ });
3503
+ }
3504
+ function scheduleReactiveEffects(root) {
3505
+ if (root.pendingReactiveEffects.length === 0 || root.reactiveCallback !== null) return;
3506
+ root.reactiveCallback = scheduleCallback(3, () => {
3507
+ performReactiveEffects(root);
3508
+ });
3509
+ }
3510
+ function performReactiveEffects(root) {
3511
+ try {
3512
+ flushReactiveEffects(root);
3513
+ } catch (error) {
3514
+ const info = root.uncaughtErrorInfo ?? errorInfoFor(root.current, error);
3515
+ clearRootAfterUncaughtError(root);
3516
+ reportUncaughtError(root, error, info);
3517
+ if (root.onUncaughtError === null) setTimeout(() => {
3518
+ throw error;
3519
+ });
3520
+ }
3521
+ }
3522
+ function flushPendingReactiveEffects(root) {
3523
+ root.reactiveCallback?.cancel();
3524
+ flushReactiveEffects(root);
3525
+ }
3526
+ function flushReactiveEffects(root) {
3527
+ root.reactiveCallback = null;
3528
+ const effects = root.pendingReactiveEffects;
3529
+ root.pendingReactiveEffects = [];
3530
+ for (const effect of effects) runEffect(effect);
3531
+ }
3532
+ function visitFiberHooks(node, visitor) {
3533
+ walkFiberForest(node, (cursor) => {
3534
+ for (let hook = cursor.memoizedState; hook !== null; hook = hook.next) visitor(cursor, hook);
3535
+ });
3536
+ }
3537
+ function isExternalStoreHook(hook) {
3538
+ return hook.kind === 7;
3539
+ }
3540
+ function runEffect(effect) {
3541
+ abortEffect(effect);
3542
+ let controller = new AbortController();
3543
+ effect.controller = controller;
3544
+ const dataStore = rootOf(effect.owner).dataStore;
3545
+ try {
3546
+ dataStore.run(() => effect.create(controller.signal));
3547
+ } catch (error) {
3548
+ abortEffect(effect);
3549
+ handleEffectError(effect, error);
3550
+ }
3551
+ }
3552
+ function handleEffectError(effect, error) {
3553
+ const owner = effect.owner;
3554
+ const boundary = findErrorBoundary(owner);
3555
+ if (boundary !== null) {
3556
+ captureCommittedErrorBoundary(boundary, error, owner);
3557
+ scheduleFiber(boundary, 32);
3558
+ return;
3559
+ }
3560
+ rootOf(owner).uncaughtErrorInfo = errorInfoFor(owner, error);
3561
+ throw error;
3562
+ }
3563
+ function abortFiberEffects(node, retirePending = false) {
3564
+ walkFiberForest(node, (cursor) => {
3565
+ abortFiberHooks(cursor, retirePending);
3566
+ });
3567
+ }
3568
+ function abortFiberHooks(owner, retirePending) {
3569
+ for (let hook = owner.memoizedState; hook !== null; hook = hook.next) {
3570
+ if (isEffectHook(hook.kind)) abortEffect(hook.memoizedState);
3571
+ if (isExternalStoreHook(hook)) unsubscribeExternalStore(hook.memoizedState);
3572
+ if (isStableEventHook(hook)) {
3573
+ const instance = hook.memoizedState.instance;
3574
+ instance.controller?.abort();
3575
+ instance.controller = null;
3576
+ instance.live = false;
3577
+ }
3578
+ if (hook.kind === 9) {
3579
+ const state = hook.memoizedState;
3580
+ if (retireRun(state.instance) && retirePending) scheduleHookUpdate(owner, hook.queue, (previous) => ({
3581
+ ...previous,
3582
+ pendingCount: Math.max(0, previous.pendingCount - 1)
3583
+ }), 32);
3584
+ }
3585
+ if (hook.kind === 4) {
3586
+ const state = hook.memoizedState;
3587
+ if (retireRun(state.instance) && retirePending) scheduleHookUpdate(owner, hook.queue, (previous) => ({
3588
+ ...previous,
3589
+ pending: Math.max(0, previous.pending - 1)
3590
+ }), 32);
3591
+ }
3592
+ }
3593
+ }
3594
+ function abortEffect(effect) {
3595
+ effect.controller?.abort();
3596
+ effect.controller = null;
3597
+ }
3598
+ function unsubscribeExternalStore(state) {
3599
+ if (state.instance.owner !== null) rootOf(state.instance.owner).externalStores.delete(state.instance);
3600
+ state.instance.unsubscribe?.();
3601
+ state.instance.unsubscribe = null;
3602
+ state.instance.committedSubscribe = null;
3603
+ state.instance.owner = null;
3604
+ }
3605
+ function restoreConsumedPendingQueues(root, from = 0) {
3606
+ for (const consumed of root.consumedPendingQueues.splice(from)) restoreConsumedPendingQueue(consumed);
3607
+ }
3608
+ function restoreConsumedPendingQueuesForRetry(root, from) {
3609
+ for (const consumed of root.consumedPendingQueues.splice(from)) {
3610
+ clearQueueLanes(consumed.pending);
3611
+ restoreConsumedPendingQueue(consumed);
3612
+ }
3613
+ }
3614
+ function restoreConsumedPendingQueue({ queue, pending }) {
3615
+ queue.pending = queue.pending === null ? pending : mergeQueues(pending, queue.pending);
3616
+ }
3617
+ }
3618
+ function activityHidden(props) {
3619
+ return props.mode === "hidden";
3620
+ }
3621
+ function hookKindName(kind) {
3622
+ return kind;
3623
+ }
3624
+ function createHook(kind, state) {
3625
+ return {
3626
+ kind,
3627
+ memoizedState: state,
3628
+ baseState: state,
3629
+ baseQueue: null,
3630
+ queue: {
3631
+ pending: null,
3632
+ dispatch: null
3633
+ },
3634
+ next: null
3635
+ };
3636
+ }
3637
+ function retireRun(instance) {
3638
+ const controller = instance.controller;
3639
+ if (controller === null) return false;
3640
+ instance.controller = null;
3641
+ instance.generation += 1;
3642
+ controller.abort();
3643
+ return true;
3644
+ }
3645
+ function createActionState(action, value) {
3646
+ return {
3647
+ action,
3648
+ error: NoActionStateError,
3649
+ instance: {
3650
+ action,
3651
+ controller: null,
3652
+ generation: 0,
3653
+ value
3654
+ },
3655
+ pending: 0,
3656
+ value
3657
+ };
3658
+ }
3659
+ function resolveInitialState(initialState) {
3660
+ return typeof initialState === "function" ? initialState() : initialState;
3661
+ }
3662
+ function sameType(fiber, child) {
3663
+ if (typeof child === "string") return fiber.tag === 2;
3664
+ if (isPortal(child)) return fiber.tag === 8 && fiber.props.target === child.target;
3665
+ if (!isValidElement(child)) return false;
3666
+ return fiber.type === child.type;
3667
+ }
3668
+ function propsFor(child) {
3669
+ if (typeof child === "string") return { nodeValue: child };
3670
+ if (isPortal(child)) return portalProps(child);
3671
+ if (isValidElement(child)) return child.props;
3672
+ throw invalidChildError(child);
3673
+ }
3674
+ function portalProps(child) {
3675
+ return {
3676
+ children: child.children,
3677
+ target: child.target
3678
+ };
3679
+ }
3680
+ function validateChildKey(child, seenKeys) {
3681
+ if (seenKeys === null) return;
3682
+ const key = childExplicitKey(child);
3683
+ if (key === null) return;
3684
+ if (seenKeys.has(key)) throw duplicateKeyError(key);
3685
+ seenKeys.add(key);
3686
+ }
3687
+ function sameChildKey(fiber, child, index) {
3688
+ const key = childExplicitKey(child);
3689
+ return key === null ? fiber.key === null && fiber.index === index : fiber.key !== null && String(fiber.key) === key;
3690
+ }
3691
+ function childExplicitKey(child) {
3692
+ return (isValidElement(child) || isPortal(child)) && child.key !== null ? String(child.key) : null;
3693
+ }
3694
+ function duplicateKeyError(key) {
3695
+ return /* @__PURE__ */ new Error(`Duplicate key "${String(key)}" found among siblings.`);
3696
+ }
3697
+ function isHost(fiber) {
3698
+ return fiber.tag === 1 || fiber.tag === 2;
3699
+ }
3700
+ function hostNode(fiber) {
3701
+ return fiber.stateNode;
3702
+ }
3703
+ function areHookInputsEqual(nextDeps, previousDeps) {
3704
+ if (nextDeps === null || previousDeps === null) return false;
3705
+ if (nextDeps.length !== previousDeps.length) return false;
3706
+ for (let index = 0; index < nextDeps.length; index += 1) if (!Object.is(nextDeps[index], previousDeps[index])) return false;
3707
+ return true;
3708
+ }
3709
+ function changedContextProvider(fiber) {
3710
+ return fiber.tag === 5 && fiber.alternate !== null && !Object.is(fiber.props.value, fiber.alternate.memoizedProps?.value);
3711
+ }
3712
+ function suspenseRetryLane(lanes) {
3713
+ const retryLanes = lanes & RetryLanes;
3714
+ return retryLanes === 0 ? claimNextRetryLane() : getHighestPriorityLane(retryLanes);
3715
+ }
3716
+ //#endregion
3717
+ export { act, createRenderer, runWithEventPriority };
3718
+
3719
+ //# sourceMappingURL=index.js.map