octane 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/cjs/compatibility.cjs +35 -0
  2. package/dist/cjs/component-flags.cjs +8 -1
  3. package/dist/cjs/css.cjs +9 -0
  4. package/dist/cjs/dom-tables.cjs +8 -1
  5. package/dist/cjs/error-codes.client.generated.cjs +15 -2
  6. package/dist/cjs/error-codes.server.generated.cjs +5 -0
  7. package/dist/cjs/event-names.cjs +39 -0
  8. package/dist/cjs/index.cjs +13 -0
  9. package/dist/cjs/runtime.cjs +1345 -359
  10. package/dist/cjs/runtime.server.cjs +620 -183
  11. package/dist/cjs/server/index.cjs +26 -0
  12. package/dist/cjs/version.cjs +1 -1
  13. package/dist/compatibility.d.ts +7 -0
  14. package/dist/compatibility.js +10 -0
  15. package/dist/compiler/bundler.js +20 -30
  16. package/dist/compiler/compile-renderer-boundaries.js +1 -0
  17. package/dist/compiler/compile-universal.js +3 -0
  18. package/dist/compiler/compile.js +877 -627
  19. package/dist/compiler/hook-deps.js +100 -3
  20. package/dist/compiler/hook-names.js +1 -0
  21. package/dist/compiler/hydrate-boundaries.js +165 -15
  22. package/dist/compiler/manual-hooks.js +171 -0
  23. package/dist/compiler/parser.node.js +34 -8
  24. package/dist/compiler/plain-hook-memo.js +54 -5
  25. package/dist/compiler/slot-hooks.d.ts +43 -0
  26. package/dist/compiler/slot-hooks.js +154 -35
  27. package/dist/compiler/strong-mode.js +836 -3
  28. package/dist/compiler/style-scopes.js +1134 -0
  29. package/dist/compiler/volar.LICENSES.txt +1 -1
  30. package/dist/compiler/volar.js +4543 -2839
  31. package/dist/component-flags.d.ts +1 -1
  32. package/dist/component-flags.js +8 -1
  33. package/dist/css.d.ts +7 -0
  34. package/dist/css.js +8 -0
  35. package/dist/dom-tables.js +8 -1
  36. package/dist/error-codes.client.generated.d.ts +3 -1
  37. package/dist/error-codes.client.generated.js +15 -2
  38. package/dist/error-codes.server.generated.d.ts +1 -0
  39. package/dist/error-codes.server.generated.js +5 -0
  40. package/dist/event-names.d.ts +1 -0
  41. package/dist/event-names.js +15 -0
  42. package/dist/html-tree-validation.d.ts +17 -34
  43. package/dist/index.d.ts +3 -1
  44. package/dist/index.js +12 -1
  45. package/dist/jsx-runtime.d.ts +6 -1
  46. package/dist/public-types.d.ts +188 -0
  47. package/dist/public-types.js +0 -0
  48. package/dist/runtime.d.ts +128 -69
  49. package/dist/runtime.js +1349 -360
  50. package/dist/runtime.server.d.ts +67 -15
  51. package/dist/runtime.server.js +619 -184
  52. package/dist/server/index.d.ts +4 -2
  53. package/dist/server/index.js +23 -0
  54. package/dist/static/index.d.ts +2 -1
  55. package/dist/static/index.js +3 -1
  56. package/dist/universal-core.d.ts +8 -1
  57. package/dist/universal-core.js +95 -9
  58. package/dist/version.js +1 -1
  59. package/package.json +4 -3
package/dist/runtime.js CHANGED
@@ -27,6 +27,7 @@ import {
27
27
  SVG_ONLY_TAGS,
28
28
  VOID_ELEMENTS
29
29
  } from "./constants.js";
30
+ import { isDelegatedEventProp } from "./event-names.js";
30
31
  import { hasOwnProp } from "./has-own.js";
31
32
  import { headOwnershipKey } from "./head-ownership.js";
32
33
  import { resourceHintWarning } from "./resource-hint-diagnostics.js";
@@ -176,15 +177,22 @@ function beginActiveNativeReadScope(scope) {
176
177
  const block = CURRENT_BLOCK;
177
178
  return block === null ? -1 : NATIVE_READ_DRIVER.beginScope(scope, block);
178
179
  }
180
+ function scheduleNativeRead(target) {
181
+ invalidateRender(target, target);
182
+ const retainPriority = SCHEDULED_VISIBILITY_DRIVER?.holdsNativeRead(target) === true;
183
+ if (retainPriority) TRANSITION_DEPTH++;
184
+ try {
185
+ scheduleRender(target);
186
+ } finally {
187
+ if (retainPriority) TRANSITION_DEPTH--;
188
+ }
189
+ }
179
190
  function ensureNativeReadDriver() {
180
191
  if (NATIVE_READ_DRIVER !== null) return NATIVE_READ_DRIVER;
181
192
  NATIVE_READ_DRIVER = createNativeReadDriver({
182
193
  capture: () => WIP_CAPTURE,
183
194
  cleanup: registerHookCleanup,
184
- schedule: (target) => {
185
- invalidateRender(target, target);
186
- scheduleRender(target);
187
- },
195
+ schedule: scheduleNativeRead,
188
196
  suspended: retainNativeRetryReads,
189
197
  replayRefs: (capture, owner) => replayNativeUnpublishedRefs(capture, owner),
190
198
  refDisposed: (entry) => blockSubtreeDisposed(entry.block)
@@ -273,10 +281,7 @@ function retainNativeRetryReads(block, reads) {
273
281
  if (retry2 === void 0) {
274
282
  const owner2 = current;
275
283
  retry2 = createNativeReadRetry(() => {
276
- if (!owner2.disposed) {
277
- invalidateRender(owner2, owner2);
278
- scheduleRender(owner2);
279
- }
284
+ if (!owner2.disposed) scheduleNativeRead(owner2);
280
285
  });
281
286
  retries.set(owner2, retry2);
282
287
  const owned = retry2;
@@ -473,6 +478,9 @@ const RENDERER_REGION_DOM_OWNERS = /* @__PURE__ */ new WeakMap();
473
478
  const RENDERER_REGION_DOM_BINDINGS = /* @__PURE__ */ new WeakMap();
474
479
  const DOM_ROOT_DISPOSERS = /* @__PURE__ */ new WeakMap();
475
480
  let EFFECT_BODY_DEPTH = 0;
481
+ let CURRENT_EFFECT_PHASE = -1;
482
+ let EFFECT_COMMIT_DEPTH = 0;
483
+ let COMMIT_PHASE_ERRORS = null;
476
484
  let REF_CALLBACK_DEPTH = 0;
477
485
  let STORE_SYNC_DEPTH = 0;
478
486
  let EFFECT_EVENT_LIFECYCLE_DEPTH = 0;
@@ -486,12 +494,15 @@ function runEffectLifecycleCallback(callback) {
486
494
  EFFECT_EVENT_LIFECYCLE_DEPTH--;
487
495
  }
488
496
  }
489
- function runEffectCleanupCallback(callback) {
497
+ function runEffectCleanupCallback(callback, phase = -1) {
498
+ const previousPhase = CURRENT_EFFECT_PHASE;
499
+ CURRENT_EFFECT_PHASE = phase;
490
500
  EFFECT_BODY_DEPTH++;
491
501
  try {
492
502
  runEffectLifecycleCallback(callback);
493
503
  } finally {
494
504
  EFFECT_BODY_DEPTH--;
505
+ CURRENT_EFFECT_PHASE = previousPhase;
495
506
  }
496
507
  }
497
508
  const QUEUE = [];
@@ -510,17 +521,31 @@ function ensureTransitionSwapDriver() {
510
521
  splice: spliceWipCapture,
511
522
  begin: beginTransitionAttempt,
512
523
  end: endTransitionAttempt,
524
+ beginUrgent: beginUrgentTransitionRender,
525
+ endUrgent: endUrgentTransitionRender,
513
526
  holdRoot: holdRootTransition,
514
527
  retryRoot: retryRootTransition,
515
528
  commitRoot: commitRootTransition,
516
529
  discardRoot: discardRootTransition,
517
- keepsRoot: keepsRootTransition
530
+ keepsRoot: keepsRootTransition,
531
+ cancelEqual: cancelHeldTransitionUpdate,
532
+ hasHeld: hasHeldTransitionUpdate,
533
+ heldUpdate: getHeldTransitionUpdate,
534
+ rebaseHeld: rebaseHeldTransitionUpdate
518
535
  };
519
536
  }
520
537
  let ACTIVE_TRANSITION_ACTION_BATCH = null;
521
538
  let IN_FLIGHT_TRANSITION_ACTION_BATCH = null;
522
539
  function createTransitionActionBatch() {
523
- return { updates: /* @__PURE__ */ new Map(), pendingActions: 0, closed: false, flushed: false };
540
+ return {
541
+ updates: /* @__PURE__ */ new Map(),
542
+ pendingActions: 0,
543
+ closed: false,
544
+ flushed: false,
545
+ hook: null,
546
+ hooks: null,
547
+ hooksPending: false
548
+ };
524
549
  }
525
550
  function transitionActionBatchForUpdate() {
526
551
  if (ACTIVE_TRANSITION_ACTION_BATCH !== null) return ACTIVE_TRANSITION_ACTION_BATCH;
@@ -528,6 +553,7 @@ function transitionActionBatchForUpdate() {
528
553
  return IN_FLIGHT_TRANSITION_ACTION_BATCH;
529
554
  }
530
555
  function rebaseTransitionActionUpdate(update) {
556
+ if (update.state !== void 0 || update.reducer !== void 0) return update.value;
531
557
  if (Object.is(update.baseValue, update.slot.value)) return update.value;
532
558
  let value = update.slot.value;
533
559
  for (const operation of update.operations) value = operation(value);
@@ -536,26 +562,31 @@ function rebaseTransitionActionUpdate(update) {
536
562
  if (update.slot.pendingActionBatch !== void 0) update.slot.pendingActionValue = value;
537
563
  return value;
538
564
  }
539
- function stagedTransitionValue(slot) {
565
+ function stagedTransitionValue(slot, block) {
540
566
  const batch = transitionActionBatchForUpdate();
541
567
  if (batch === null) return slot.value;
542
568
  const update = batch.updates.get(slot);
543
- return update === void 0 ? slot.value : rebaseTransitionActionUpdate(update);
569
+ if (update !== void 0) return rebaseTransitionActionUpdate(update);
570
+ if (slot.renderTransition !== void 0) return slot.renderTransition.value;
571
+ const held = block === void 0 ? void 0 : TRANSITION_SWAP_DRIVER?.heldUpdate(slot, block);
572
+ return held === void 0 ? slot.value : held.value;
544
573
  }
545
574
  function stageTransitionValue(slot, block, operation, value, forceRender = false) {
546
575
  const batch = transitionActionBatchForUpdate();
547
- if (batch === null) return false;
576
+ if (batch === null) return null;
548
577
  const replay = typeof operation === "function" ? operation : () => operation;
549
- const current = batch.updates.get(slot);
578
+ let current = batch.updates.get(slot);
550
579
  if (current === void 0) {
551
- batch.updates.set(slot, {
580
+ current = {
581
+ batch,
552
582
  slot,
553
583
  block,
554
584
  operations: [replay],
555
585
  baseValue: slot.value,
556
586
  value,
557
587
  forceRender
558
- });
588
+ };
589
+ batch.updates.set(slot, current);
559
590
  } else {
560
591
  current.operations.push(replay);
561
592
  current.value = value;
@@ -563,23 +594,36 @@ function stageTransitionValue(slot, block, operation, value, forceRender = false
563
594
  }
564
595
  slot.pendingActionBatch = batch;
565
596
  slot.pendingActionValue = value;
566
- return true;
597
+ return current;
567
598
  }
568
599
  function flushTransitionActionBatch(batch) {
569
600
  if (batch.flushed) return;
570
601
  batch.flushed = true;
571
602
  for (const update of batch.updates.values()) {
572
603
  const { slot, block, forceRender } = update;
573
- const value = rebaseTransitionActionUpdate(update);
604
+ const value = update.state === void 0 && update.reducer === void 0 ? rebaseTransitionActionUpdate(update) : update.value;
574
605
  if (slot.pendingActionBatch === batch) {
575
606
  slot.pendingActionBatch = void 0;
576
607
  slot.pendingActionValue = void 0;
577
608
  }
578
609
  if (block.disposed) continue;
610
+ const state = update.state;
611
+ const reducer = update.reducer;
612
+ const previous = state?.renderTransition ?? reducer?.renderTransition;
613
+ if (state !== void 0 || reducer !== void 0) {
614
+ update.baseValue = previous === void 0 ? slot.value : previous.baseValue;
615
+ if (state !== void 0) {
616
+ state.updates = void 0;
617
+ } else if (reducer !== void 0) {
618
+ reducer.renderPhaseActions = void 0;
619
+ }
620
+ }
579
621
  const changed = !Object.is(slot.value, value);
580
- if (!changed && !forceRender) continue;
622
+ if (!changed && !forceRender && update.previous === void 0) continue;
581
623
  if (changed) slot.value = value;
582
- if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
624
+ if (update.reducer !== void 0) update.reducer.renderTransition = update;
625
+ if (update.state !== void 0) update.state.renderTransition = update;
626
+ if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__ && (changed || update.profileType !== "state"))
583
627
  __profileSchedule(
584
628
  block,
585
629
  update.profileType ?? (forceRender ? "reducer" : "state"),
@@ -605,6 +649,74 @@ function flushTransitionActionBatchIfReady(batch) {
605
649
  let DEFERRED_SPAWN = false;
606
650
  let TRANSITION_PENDING_COUNT = 0;
607
651
  const TRANSITION_LISTENERS = /* @__PURE__ */ new Set();
652
+ let TRANSITION_HOOK_HOLDERS = null;
653
+ function addTransitionHookToBatch(batch, hook) {
654
+ if (batch.hook === null) batch.hook = hook;
655
+ else if (batch.hook !== hook) {
656
+ const hooks = batch.hooks;
657
+ if (hooks === null) batch.hooks = [hook];
658
+ else if (hooks.includes(hook)) return;
659
+ else hooks.push(hook);
660
+ } else return;
661
+ if (batch.hooksPending) {
662
+ hook.pendingBatches++;
663
+ hook.publish(true);
664
+ }
665
+ }
666
+ function publishTransitionHookBatch(batch) {
667
+ const hook = batch.hook;
668
+ if (hook === null || batch.hooksPending) return;
669
+ batch.hooksPending = true;
670
+ hook.pendingBatches++;
671
+ hook.publish(true);
672
+ const hooks = batch.hooks;
673
+ if (hooks !== null) {
674
+ for (let i = 0; i < hooks.length; i++) {
675
+ hooks[i].pendingBatches++;
676
+ hooks[i].publish(true);
677
+ }
678
+ }
679
+ }
680
+ function finishTransitionHookBatch(batch) {
681
+ if (!batch.workComplete || batch.pendingActions !== 0 || (batch.pendingHolds ?? 0) !== 0) return;
682
+ if (!batch.hooksPending) return;
683
+ batch.hooksPending = false;
684
+ const hook = batch.hook;
685
+ if (--hook.pendingBatches === 0) hook.publish(false);
686
+ const hooks = batch.hooks;
687
+ if (hooks !== null) {
688
+ for (let i = 0; i < hooks.length; i++) {
689
+ if (--hooks[i].pendingBatches === 0) hooks[i].publish(false);
690
+ }
691
+ }
692
+ }
693
+ function holdTransitionHookBatch(holder, batch) {
694
+ if (batch.hook === null) return;
695
+ const holders = TRANSITION_HOOK_HOLDERS ??= /* @__PURE__ */ new WeakMap();
696
+ let batches = holders.get(holder);
697
+ if (batches === void 0) holders.set(holder, batches = /* @__PURE__ */ new Set());
698
+ if (batches.has(batch)) return;
699
+ batches.add(batch);
700
+ batch.pendingHolds = (batch.pendingHolds ?? 0) + 1;
701
+ publishTransitionHookBatch(batch);
702
+ }
703
+ function releaseTransitionHookHolder(holder) {
704
+ const batches = TRANSITION_HOOK_HOLDERS?.get(holder);
705
+ if (batches === void 0) return;
706
+ TRANSITION_HOOK_HOLDERS.delete(holder);
707
+ for (const batch of batches) {
708
+ batch.pendingHolds--;
709
+ finishTransitionHookBatch(batch);
710
+ }
711
+ }
712
+ function holdTransitionHooksForBlock(holder, block) {
713
+ for (const entries of FLUSHED_TRANSITION_UPDATES) {
714
+ for (const entry of entries) {
715
+ if (entry.batch !== void 0 && blockIsAncestor(entry.block, block))
716
+ holdTransitionHookBatch(holder, entry.batch);
717
+ }
718
+ }
719
+ }
608
720
  let TRANSITION_LISTENER_PUBLISH_DEPTH = 0;
609
721
  const HELD_TRANSITIONS = /* @__PURE__ */ new Set();
610
722
  const STAGED_REVEALS = /* @__PURE__ */ new Set();
@@ -613,6 +725,111 @@ let deferringStagedRevealEffects = false;
613
725
  let ACTIVE_TRANSITION_ATTEMPT = null;
614
726
  let FLUSHED_TRANSITION_UPDATES = [];
615
727
  let HELD_SYNC_TRANSITION = null;
728
+ function urgentTransitionCellUpdate(block) {
729
+ return TRANSITION_DEPTH === 0 && !(CURRENT_BLOCK === block && block.currentRenderMode === "transition") && (syncFlush || _dispatchDepth > 0 || ASYNC_TRANSITION_COUNT === 0);
730
+ }
731
+ function latestHeldTransitionUpdate(entry) {
732
+ while (entry.next?.batch?.flushed === true && !entry.next.superseded) entry = entry.next;
733
+ return entry;
734
+ }
735
+ function findHeldTransitionUpdate(slot, block) {
736
+ if (!urgentTransitionCellUpdate(block)) return;
737
+ return getHeldTransitionUpdate(slot, block);
738
+ }
739
+ function getHeldTransitionUpdate(slot, block) {
740
+ if (block.disposed) return;
741
+ const rootHeld = block.idState.renderOwner?.transition;
742
+ if (HELD_SYNC_TRANSITION === null && rootHeld === void 0 && FLUSHED_TRANSITION_UPDATES.length === 0)
743
+ return;
744
+ const groups = [HELD_SYNC_TRANSITION?.entries, rootHeld?.entries];
745
+ for (const entries of groups) {
746
+ if (entries === void 0) continue;
747
+ for (let i = entries.length - 1; i >= 0; i--) {
748
+ const entry = entries[i];
749
+ if (entry.slot === slot && !entry.superseded && Object.is(slot.value, entry.baseValue))
750
+ return latestHeldTransitionUpdate(entry);
751
+ }
752
+ }
753
+ for (let i = FLUSHED_TRANSITION_UPDATES.length - 1; i >= 0; i--) {
754
+ const entries = FLUSHED_TRANSITION_UPDATES[i];
755
+ for (let j = entries.length - 1; j >= 0; j--) {
756
+ const entry = entries[j];
757
+ if (entry.slot === slot && !entry.superseded && Object.is(slot.value, entry.baseValue) && // A completed hook render clears this pointer before the flush's
758
+ // retained-entry list is released. Returning to an old base value
759
+ // must not turn that completed update into pending work again.
760
+ (entry.state === void 0 && entry.reducer === void 0 || slot.renderTransition !== void 0))
761
+ return latestHeldTransitionUpdate(entry);
762
+ }
763
+ }
764
+ }
765
+ function hasHeldTransitionUpdate(slot, block) {
766
+ return findHeldTransitionUpdate(slot, block) !== void 0;
767
+ }
768
+ function cancelHeldTransitionUpdate(slot, block) {
769
+ if (!urgentTransitionCellUpdate(block)) return false;
770
+ const rootHeld = block.idState.renderOwner?.transition;
771
+ if (HELD_SYNC_TRANSITION === null && rootHeld === void 0 && FLUSHED_TRANSITION_UPDATES.length === 0)
772
+ return false;
773
+ let cancelled = false;
774
+ const cancel = (entries) => {
775
+ if (entries === void 0) return;
776
+ for (const entry of entries) {
777
+ if (entry.slot === slot && !entry.superseded) {
778
+ entry.superseded = true;
779
+ cancelled = true;
780
+ }
781
+ }
782
+ };
783
+ cancel(HELD_SYNC_TRANSITION?.entries);
784
+ cancel(rootHeld?.entries);
785
+ for (const entries of FLUSHED_TRANSITION_UPDATES) cancel(entries);
786
+ return cancelled;
787
+ }
788
+ function rebaseHeldTransitionUpdate(slot, block, actions, reducer) {
789
+ const entry = findHeldTransitionUpdate(slot, block);
790
+ if (entry === void 0) return;
791
+ if (slot.pendingActionBatch?.flushed === false) return;
792
+ let value = entry.value;
793
+ for (const action of actions) {
794
+ value = reducer ? reducer(value, action) : typeof action === "function" ? action(value) : action;
795
+ }
796
+ if (Object.is(value, entry.baseValue)) {
797
+ cancelHeldTransitionUpdate(slot, block);
798
+ return;
799
+ }
800
+ const changed = !Object.is(value, entry.value);
801
+ for (let current = entry; current; current = current.previous)
802
+ current.value = value;
803
+ for (const action of actions) {
804
+ entry.operations.push(
805
+ reducer ? (previous) => reducer(previous, action) : typeof action === "function" ? action : () => action
806
+ );
807
+ }
808
+ if (changed) scheduleHeldTransitionReplay(entry, block);
809
+ }
810
+ function scheduleHeldTransitionReplay(entry, block) {
811
+ const held = HELD_SYNC_TRANSITION;
812
+ if (held !== null && held.entries.includes(entry)) {
813
+ if (held.replayScheduled) return;
814
+ held.replayScheduled = true;
815
+ queueMicrotask(() => {
816
+ if (HELD_SYNC_TRANSITION !== held) return;
817
+ held.replayScheduled = false;
818
+ promoteHeldSyncTransition();
819
+ });
820
+ return;
821
+ }
822
+ const owner = block.idState.renderOwner;
823
+ const rootHeld = owner?.transition;
824
+ if (rootHeld === void 0 || !rootHeld.entries.includes(entry) || rootHeld.replayScheduled)
825
+ return;
826
+ rootHeld.replayScheduled = true;
827
+ queueMicrotask(() => {
828
+ if (owner.transition !== rootHeld) return;
829
+ rootHeld.replayScheduled = false;
830
+ retryRootTransition(owner);
831
+ });
832
+ }
616
833
  let PROMOTED_MEMO_SWAPS = null;
617
834
  let PROMOTED_WARM_HARVEST = null;
618
835
  function takeSingleOriginTransitionUpdates(origin) {
@@ -776,18 +993,24 @@ function heldSyncCellsIntact(state) {
776
993
  if (held === null || !held.holders.has(state)) return false;
777
994
  for (let i = 0; i < held.entries.length; i++) {
778
995
  const entry = held.entries[i];
779
- if (!Object.is(entry.slot.value, entry.baseValue)) return false;
996
+ if (entry.superseded || !Object.is(entry.slot.value, entry.baseValue)) return false;
780
997
  }
781
998
  return true;
782
999
  }
1000
+ function heldTransitionHasPendingAction(entries) {
1001
+ for (const entry of entries) {
1002
+ if (!entry.superseded && entry.slot.pendingActionBatch?.flushed === false) return true;
1003
+ }
1004
+ return false;
1005
+ }
783
1006
  function promoteHeldSyncTransition() {
784
1007
  const held = HELD_SYNC_TRANSITION;
785
- if (held === null) return false;
1008
+ if (held === null || heldTransitionHasPendingAction(held.entries)) return false;
786
1009
  HELD_SYNC_TRANSITION = null;
787
1010
  const promoted = [];
788
1011
  for (let i = 0; i < held.entries.length; i++) {
789
1012
  const entry = held.entries[i];
790
- if (!Object.is(entry.slot.value, entry.baseValue)) continue;
1013
+ if (entry.superseded || !Object.is(entry.slot.value, entry.baseValue)) continue;
791
1014
  entry.slot.value = entry.value;
792
1015
  if (!entry.block.disposed) promoted.push(entry);
793
1016
  }
@@ -823,7 +1046,7 @@ function discardHeldSyncTransition(state) {
823
1046
  function rootTransitionCellsIntact(held) {
824
1047
  for (let i = 0; i < held.entries.length; i++) {
825
1048
  const entry = held.entries[i];
826
- if (!Object.is(entry.slot.value, entry.baseValue)) return false;
1049
+ if (entry.superseded || !Object.is(entry.slot.value, entry.baseValue)) return false;
827
1050
  }
828
1051
  return true;
829
1052
  }
@@ -870,6 +1093,9 @@ function holdRootTransition(owner, transaction, attempt) {
870
1093
  promoted: false,
871
1094
  cue: !continuing
872
1095
  };
1096
+ for (const entry of entries) {
1097
+ if (entry.batch !== void 0) holdTransitionHookBatch(owner, entry.batch);
1098
+ }
873
1099
  if (previous === void 0 || previous.promoted) tickTransitionCount(1);
874
1100
  return true;
875
1101
  }
@@ -880,6 +1106,7 @@ function retryRootTransition(owner) {
880
1106
  discardRootTransition(owner);
881
1107
  return false;
882
1108
  }
1109
+ if (heldTransitionHasPendingAction(held.entries)) return true;
883
1110
  held.promoted = true;
884
1111
  held.cue = false;
885
1112
  if (held.memoSwaps !== null) {
@@ -889,6 +1116,7 @@ function retryRootTransition(owner) {
889
1116
  TRANSITION_DEPTH++;
890
1117
  try {
891
1118
  tickTransitionCount(-1);
1119
+ releaseTransitionHookHolder(owner);
892
1120
  for (let i = 0; i < held.entries.length; i++) {
893
1121
  const entry = held.entries[i];
894
1122
  entry.slot.value = entry.value;
@@ -924,6 +1152,7 @@ function discardRootTransition(owner) {
924
1152
  owner.wakeable = null;
925
1153
  owner.generation++;
926
1154
  if (!held.promoted) tickTransitionCount(-1);
1155
+ releaseTransitionHookHolder(owner);
927
1156
  }
928
1157
  const JOURNAL_TEXT = 0;
929
1158
  const JOURNAL_ATTR = 1;
@@ -1325,12 +1554,17 @@ function journalDefaultValue(input) {
1325
1554
  journalAttr(input, "value");
1326
1555
  }
1327
1556
  }
1557
+ function radioCousins(input) {
1558
+ if (input.form !== null) return input.form.elements;
1559
+ const root = input.getRootNode();
1560
+ return root.nodeType === 9 ? root.getElementsByName(input.name) : root.querySelectorAll('input[type="radio"]');
1561
+ }
1328
1562
  function journalRadioCousins(input) {
1329
1563
  const name = input.name;
1330
- const group = input.form !== null ? input.form.elements : typeof document !== "undefined" ? document.getElementsByName(name) : [];
1564
+ const group = radioCousins(input);
1331
1565
  for (let i = 0; i < group.length; i++) {
1332
1566
  const other = group[i];
1333
- if (other === input || !other.checked || other.localName !== "input" || other.type !== "radio" || other.name !== name) {
1567
+ if (other === input || !other.checked || other.localName !== "input" || other.type !== "radio" || other.name !== name || other.form !== input.form) {
1334
1568
  continue;
1335
1569
  }
1336
1570
  TRANSITION_JOURNAL.push(JOURNAL_PROP, other, "checked", true);
@@ -1877,9 +2111,27 @@ let actScopeDepth = 0;
1877
2111
  function setIsOctaneActEnvironment(value) {
1878
2112
  IS_OCTANE_ACT_ENVIRONMENT = value;
1879
2113
  }
2114
+ function isActEnvironment() {
2115
+ return IS_OCTANE_ACT_ENVIRONMENT || globalThis.IS_REACT_ACT_ENVIRONMENT === true;
2116
+ }
1880
2117
  const NESTED_UPDATE_LIMIT = 50;
1881
2118
  const ACT_DRAIN_LIMIT = NESTED_UPDATE_LIMIT + 50;
1882
2119
  let UPDATE_CHAIN_ID = 0;
2120
+ let PASSIVE_UPDATE_COUNTS = null;
2121
+ function countPassiveUpdate(block) {
2122
+ if (process.env.NODE_ENV === "production") return;
2123
+ const counts = PASSIVE_UPDATE_COUNTS ??= /* @__PURE__ */ new WeakMap();
2124
+ let state = counts.get(block);
2125
+ if (state === void 0 || state.chain !== UPDATE_CHAIN_ID) {
2126
+ state = { chain: UPDATE_CHAIN_ID, count: 0 };
2127
+ counts.set(block, state);
2128
+ }
2129
+ if (++state.count === NESTED_UPDATE_LIMIT + 1) {
2130
+ console.error(
2131
+ "Maximum update depth exceeded. Check the dependencies of effects that schedule state updates."
2132
+ );
2133
+ }
2134
+ }
1883
2135
  function inNestedUpdateCallback() {
1884
2136
  return EFFECT_BODY_DEPTH > 0 || REF_CALLBACK_DEPTH > 0 || STORE_SYNC_DEPTH > 0;
1885
2137
  }
@@ -1909,9 +2161,23 @@ function warnCrossComponentRenderUpdate(target, source) {
1909
2161
  }
1910
2162
  function scheduleRender(block) {
1911
2163
  if (block.disposed) return;
1912
- if (process.env.NODE_ENV !== "production" && IS_OCTANE_ACT_ENVIRONMENT && actScopeDepth === 0 && !syncFlush) {
2164
+ if (process.env.NODE_ENV !== "production" && CURRENT_EFFECT_PHASE === INSERTION) {
1913
2165
  console.error(
1914
- "An update to a component was not wrapped in act(...).\n\nWhen testing, code that causes state updates should be wrapped into act(...):\n\n act(() => {\n /* fire events that update state */\n });\n /* assert on the output */\n\nThis ensures you're testing the behavior the user would see in the browser."
2166
+ "useInsertionEffect must not schedule state updates. Move this work to a layout or passive effect."
2167
+ );
2168
+ }
2169
+ if (process.env.NODE_ENV !== "production" && isActEnvironment() && actScopeDepth === 0 && !syncFlush) {
2170
+ console.error(
2171
+ `An update to ${componentName(block)} was not wrapped in act(...).
2172
+
2173
+ When testing, code that causes state updates should be wrapped into act(...):
2174
+
2175
+ act(() => {
2176
+ /* fire events that update state */
2177
+ });
2178
+ /* assert on the output */
2179
+
2180
+ This ensures you're testing the behavior the user would see in the browser.`
1915
2181
  );
1916
2182
  }
1917
2183
  const renderPhaseSelf = CURRENT_BLOCK === block;
@@ -1929,7 +2195,9 @@ function scheduleRender(block) {
1929
2195
  }
1930
2196
  return;
1931
2197
  }
1932
- if (inNestedUpdateCallback()) {
2198
+ if (CURRENT_EFFECT_PHASE === PASSIVE && !syncFlush) {
2199
+ countPassiveUpdate(block);
2200
+ } else if (inNestedUpdateCallback()) {
1933
2201
  if (block.nestedUpdateChain !== UPDATE_CHAIN_ID) {
1934
2202
  block.nestedUpdateChain = UPDATE_CHAIN_ID;
1935
2203
  block.nestedUpdateCount = 0;
@@ -1971,14 +2239,19 @@ function drainHydrationRenderPhaseUpdates(root) {
1971
2239
  QUEUE[write++] = block;
1972
2240
  continue;
1973
2241
  }
1974
- if (!block.pending || block.disposed) continue;
1975
- const seen = (renders ??= /* @__PURE__ */ new Map()).get(block) ?? 0;
1976
- if (seen >= RENDER_PHASE_UPDATE_LIMIT) {
1977
- throw new Error(formatClientError(9));
1978
- }
1979
- renders.set(block, seen + 1);
1980
- block.crossRenderUpdate = false;
2242
+ if (!block.pending && !block.nestedUpdateError || block.disposed) continue;
1981
2243
  try {
2244
+ if (block.nestedUpdateError) {
2245
+ block.nestedUpdateError = false;
2246
+ throw maximumUpdateDepthError();
2247
+ }
2248
+ const seen = (renders ??= /* @__PURE__ */ new Map()).get(block) ?? 0;
2249
+ const crossRenderUpdate = block.crossRenderUpdate;
2250
+ if (seen >= (crossRenderUpdate ? NESTED_UPDATE_LIMIT : RENDER_PHASE_UPDATE_LIMIT)) {
2251
+ throw crossRenderUpdate ? maximumUpdateDepthError() : new Error(formatClientError(9));
2252
+ }
2253
+ renders.set(block, seen + 1);
2254
+ block.crossRenderUpdate = false;
1982
2255
  renderBlock(block);
1983
2256
  } catch (error) {
1984
2257
  handleRenderError(block, error);
@@ -2026,12 +2299,21 @@ let SCHEDULED_VISIBILITY_DRIVER = null;
2026
2299
  function ensureScheduledVisibilityDriver() {
2027
2300
  SCHEDULED_VISIBILITY_DRIVER ??= {
2028
2301
  find: findScheduledVisibilityOwner,
2302
+ holdsNativeRead,
2029
2303
  reveal: attemptHiddenReveal,
2030
2304
  visible: renderVisibleTry,
2031
2305
  rehide: rehideActivityAfterDescendantRender,
2032
2306
  retryActivity: renderHiddenActivity
2033
2307
  };
2034
2308
  }
2309
+ function holdsNativeRead(block) {
2310
+ for (const state of HELD_TRANSITIONS) {
2311
+ const primary = state.tryBlock;
2312
+ if (state.transitionHeld && state.hiddenDom === null && primary !== null && (primary === block || blockIsAncestorOf(primary, block) || blockIsAncestorOf(block, primary)))
2313
+ return true;
2314
+ }
2315
+ return false;
2316
+ }
2035
2317
  function drainQueue() {
2036
2318
  let pendingError = null;
2037
2319
  let activitiesToRehide = null;
@@ -2075,7 +2357,7 @@ function drainQueue() {
2075
2357
  throw maximumUpdateDepthError();
2076
2358
  }
2077
2359
  if (block.drainStamp === drainId) {
2078
- if (++block.drainRenders > RENDER_PHASE_UPDATE_LIMIT) {
2360
+ if (++block.drainRenders > (crossRenderUpdate ? NESTED_UPDATE_LIMIT : RENDER_PHASE_UPDATE_LIMIT)) {
2079
2361
  throw crossRenderUpdate ? maximumUpdateDepthError() : new Error(formatClientError(9));
2080
2362
  }
2081
2363
  } else {
@@ -2655,6 +2937,11 @@ function drainPassivesBeforeRender() {
2655
2937
  if (effectQueues[PASSIVE].length > 0 || pendingPassiveUnmounts.length > 0) drainPassiveEffects();
2656
2938
  }
2657
2939
  function flushSync(fn) {
2940
+ if (process.env.NODE_ENV !== "production" && (CURRENT_BLOCK !== null || EFFECT_BODY_DEPTH > 0 || REF_CALLBACK_DEPTH > 0)) {
2941
+ console.error(
2942
+ "flushSync was called while rendering or running a lifecycle callback. Move the call to an event or scheduled task."
2943
+ );
2944
+ }
2658
2945
  if (inFlush) return runNativeBatch(fn);
2659
2946
  VIEW_TRANSITION_DRIVER?.interrupt();
2660
2947
  const prevSync = syncFlush;
@@ -2867,6 +3154,7 @@ function commitEffects() {
2867
3154
  return;
2868
3155
  }
2869
3156
  const nativeFrame = NATIVE_READ_DRIVER?.pauseLifecycle() ?? -1;
3157
+ EFFECT_COMMIT_DEPTH++;
2870
3158
  try {
2871
3159
  drainEffectEventUpdates();
2872
3160
  const caughtReports = drainEffectEventCommitActions();
@@ -2884,6 +3172,7 @@ function commitEffects() {
2884
3172
  }
2885
3173
  } finally {
2886
3174
  if (nativeFrame >= 0) NATIVE_READ_DRIVER.resumeLifecycle(nativeFrame);
3175
+ finishEffectCommit();
2887
3176
  }
2888
3177
  }
2889
3178
  function schedulePassiveFlush() {
@@ -2988,15 +3277,25 @@ function compareEffectPostOrder(a, b) {
2988
3277
  if (a.scope === b.scope) return a.order - b.order || a.seq - b.seq;
2989
3278
  return comparePostOrder(a.scope.block, a.seq, b.scope.block, b.seq);
2990
3279
  }
2991
- function reportEffectError(block, error) {
2992
- const handler = findTryHandler(block);
3280
+ function finishEffectCommit() {
3281
+ if (--EFFECT_COMMIT_DEPTH !== 0 || COMMIT_PHASE_ERRORS === null) return;
3282
+ const errors = COMMIT_PHASE_ERRORS;
3283
+ COMMIT_PHASE_ERRORS = null;
3284
+ for (const { block, error, handler } of errors) reportEffectError(block, error, handler);
3285
+ }
3286
+ function reportEffectError(block, error, capturedHandler) {
3287
+ if (EFFECT_COMMIT_DEPTH > 0) {
3288
+ (COMMIT_PHASE_ERRORS ??= []).push({ block, error, handler: capturedHandler });
3289
+ return;
3290
+ }
3291
+ const handler = capturedHandler === void 0 ? findTryHandler(block) : capturedHandler;
2993
3292
  if (handler !== null) {
2994
3293
  reportCaughtError(block, error, handler(error));
2995
3294
  return;
2996
3295
  }
2997
3296
  let root = block;
2998
- while (root.parentBlock !== null) root = root.parentBlock;
2999
- if (root.kind === "root" && !root.disposed) {
3297
+ while (root !== null && root.parentBlock !== null) root = root.parentBlock;
3298
+ if (root !== null && root.kind === "root" && !root.disposed) {
3000
3299
  unmountBlock(root);
3001
3300
  drainRefDetaches();
3002
3301
  }
@@ -3016,7 +3315,7 @@ function fireEffectCleanup(e) {
3016
3315
  if (cleanup) {
3017
3316
  slot.cleanup = void 0;
3018
3317
  try {
3019
- runEffectCleanupCallback(cleanup);
3318
+ runEffectCleanupCallback(cleanup, e.phase);
3020
3319
  } catch (err) {
3021
3320
  if (err instanceof MaximumUpdateDepthError) throw err;
3022
3321
  reportEffectError(e.scope.block, err);
@@ -3033,17 +3332,27 @@ function runEffectBody(e) {
3033
3332
  slot.connectedArgs = e.args;
3034
3333
  slot.disconnected = false;
3035
3334
  try {
3335
+ const previousPhase = CURRENT_EFFECT_PHASE;
3336
+ CURRENT_EFFECT_PHASE = e.phase;
3036
3337
  EFFECT_BODY_DEPTH++;
3037
3338
  try {
3038
3339
  cleanup = e.fn.apply(null, e.args ?? []);
3039
3340
  } finally {
3040
3341
  EFFECT_BODY_DEPTH--;
3342
+ CURRENT_EFFECT_PHASE = previousPhase;
3041
3343
  }
3042
3344
  } catch (err) {
3043
3345
  if (err instanceof MaximumUpdateDepthError) throw err;
3044
3346
  reportEffectError(e.scope.block, err);
3045
3347
  return;
3046
3348
  }
3349
+ if (process.env.NODE_ENV !== "production" && cleanup !== void 0 && typeof cleanup !== "function") {
3350
+ const name = e.phase === PASSIVE ? "useEffect" : e.phase === LAYOUT ? "useLayoutEffect" : "useInsertionEffect";
3351
+ const thenable = cleanup !== null && typeof cleanup.then === "function";
3352
+ console.error(
3353
+ name + " must return a cleanup function or nothing." + (thenable ? " Start asynchronous work inside the effect and return its cleanup separately." : "")
3354
+ );
3355
+ }
3047
3356
  if (typeof cleanup === "function") {
3048
3357
  slot.cleanup = cleanup;
3049
3358
  }
@@ -3093,20 +3402,25 @@ function runLayoutEffects(q) {
3093
3402
  }
3094
3403
  }
3095
3404
  function drainPassivePhase() {
3096
- drainDeferredPassiveUnmounts();
3097
- const pending = effectQueues[PASSIVE];
3098
- if (pending.length === 0) return;
3099
- const q = pending.splice(0);
3100
- q.sort(compareEffectPostOrder);
3101
- for (let i = 0; i < q.length; i++) {
3102
- const e = q[i];
3103
- if (e.scope.block.disposed || e.fn !== null && inInactiveSubtree(e.scope.block)) continue;
3104
- fireEffectCleanup(e);
3105
- }
3106
- for (let i = 0; i < q.length; i++) {
3107
- const e = q[i];
3108
- if (e.scope.block.disposed || inInactiveSubtree(e.scope.block)) continue;
3109
- runEffectBody(e);
3405
+ EFFECT_COMMIT_DEPTH++;
3406
+ try {
3407
+ drainDeferredPassiveUnmounts();
3408
+ const pending = effectQueues[PASSIVE];
3409
+ if (pending.length === 0) return;
3410
+ const q = pending.splice(0);
3411
+ q.sort(compareEffectPostOrder);
3412
+ for (let i = 0; i < q.length; i++) {
3413
+ const e = q[i];
3414
+ if (e.scope.block.disposed || e.fn !== null && inInactiveSubtree(e.scope.block)) continue;
3415
+ fireEffectCleanup(e);
3416
+ }
3417
+ for (let i = 0; i < q.length; i++) {
3418
+ const e = q[i];
3419
+ if (e.scope.block.disposed || inInactiveSubtree(e.scope.block)) continue;
3420
+ runEffectBody(e);
3421
+ }
3422
+ } finally {
3423
+ finishEffectCommit();
3110
3424
  }
3111
3425
  }
3112
3426
  function drainEffectEventCommitActions() {
@@ -3129,14 +3443,12 @@ function drainDeferredPassiveUnmounts() {
3129
3443
  const q = pendingPassiveUnmounts.splice(0);
3130
3444
  for (let i = 0; i < q.length; i += 3) {
3131
3445
  try {
3132
- runEffectCleanupCallback(q[i]);
3446
+ runEffectCleanupCallback(q[i], PASSIVE);
3133
3447
  } catch (err) {
3134
3448
  if (err instanceof MaximumUpdateDepthError) throw err;
3135
3449
  const handler = q[i + 1];
3136
3450
  const owner = q[i + 2];
3137
- if (handler !== null) {
3138
- reportCaughtError(owner, err, handler(err));
3139
- } else if (!reportUncaughtError(owner, err)) console.error(err);
3451
+ reportEffectError(owner, err, handler);
3140
3452
  }
3141
3453
  }
3142
3454
  }
@@ -3400,10 +3712,17 @@ function createBlock(kind, parentBlock, parentNode, startMarker, endMarker, body
3400
3712
  function renderBlock(block) {
3401
3713
  const hydration = activeHydration();
3402
3714
  if (hydration !== null && !hydration.owns(block)) {
3403
- hydration.suspend(() => renderBlockInner(block));
3715
+ hydration.suspend(() => renderBlock(block));
3404
3716
  return;
3405
3717
  }
3406
- renderBlockInner(block);
3718
+ let retries = 0;
3719
+ while (renderBlockInner(block)) {
3720
+ if (block.nestedUpdateError) {
3721
+ block.nestedUpdateError = false;
3722
+ throw maximumUpdateDepthError();
3723
+ }
3724
+ if (++retries > RENDER_PHASE_UPDATE_LIMIT) throw new Error(formatClientError(9));
3725
+ }
3407
3726
  }
3408
3727
  function enqueueEffectEventUpdate(entry) {
3409
3728
  EFFECT_EVENT_RENDER_TARGET.push(entry);
@@ -3428,6 +3747,45 @@ function recordCapturedRender(capture, block) {
3428
3747
  (capture.renderedBlocks ??= /* @__PURE__ */ new Set()).add(block);
3429
3748
  }
3430
3749
  }
3750
+ function beginUrgentTransitionRender(block, render) {
3751
+ const slots = /* @__PURE__ */ new Map();
3752
+ for (const entries of FLUSHED_TRANSITION_UPDATES) {
3753
+ for (const update of entries) {
3754
+ if (update.block !== block || update.superseded) continue;
3755
+ const previous = slots.get(update.slot);
3756
+ if (previous !== void 0) {
3757
+ render.cells[previous].update = update;
3758
+ } else {
3759
+ slots.set(update.slot, render.cells.length);
3760
+ render.cells.push({
3761
+ update,
3762
+ baseValue: update.baseValue,
3763
+ value: update.slot.value,
3764
+ hook: void 0
3765
+ });
3766
+ }
3767
+ }
3768
+ }
3769
+ for (const cell of render.cells) {
3770
+ cell.hook = beginUrgentTransitionCell(cell.update);
3771
+ if (cell.hook === null) cell.update.slot.value = cell.baseValue;
3772
+ }
3773
+ }
3774
+ function endUrgentTransitionRender(block, render) {
3775
+ for (let i = render.cells.length - 1; i >= 0; i--) {
3776
+ const cell = render.cells[i];
3777
+ if (cell.hook === void 0) continue;
3778
+ if (cell.hook !== null) endUrgentTransitionCell(cell.hook);
3779
+ else if (!block.disposed && !cell.update.superseded && Object.is(cell.update.slot.value, cell.baseValue))
3780
+ cell.update.slot.value = cell.value;
3781
+ }
3782
+ if (block.disposed || block.pending && block.pendingMode === "urgent") return;
3783
+ if (render.cells.length !== 0 && render.cells.every((cell) => cell.update.superseded)) return;
3784
+ block.pending = true;
3785
+ block.pendingMode = "transition";
3786
+ block.pendingDeferred = render.pendingDeferred;
3787
+ if (render.queueEpoch !== QUEUE_REINDEX_EPOCH && !QUEUE.includes(block)) QUEUE.push(block);
3788
+ }
3431
3789
  function renderBlockInner(block) {
3432
3790
  if (block.renderStatus === RENDER_INVALID) block.renderStatus = RENDER_RETRYING;
3433
3791
  if (WIP_CAPTURE !== null) recordCapturedRender(WIP_CAPTURE, block);
@@ -3451,6 +3809,8 @@ function renderBlockInner(block) {
3451
3809
  CURRENT_EFFECT_RENDER_VERSION = block.effectSlots === null ? 0 : NEXT_EFFECT_RENDER_VERSION++;
3452
3810
  CURRENT_EFFECT_REACHED = 0;
3453
3811
  const continuesParentTree = prevBlock !== null && blockIsAncestor(prevBlock, block);
3812
+ const urgentTransitionDriver = block.pending && block.pendingMode === "transition" && continuesParentTree && prevBlock.currentRenderMode === "urgent" ? TRANSITION_SWAP_DRIVER : null;
3813
+ const urgentTransitionRender = urgentTransitionDriver === null ? null : { pendingDeferred: block.pendingDeferred, queueEpoch: QUEUE_REINDEX_EPOCH, cells: [] };
3454
3814
  if (!continuesParentTree) {
3455
3815
  const replayEpisode = prevBlock === null && RESUME_REPLAY ? block.__warmEpisode : void 0;
3456
3816
  CURRENT_WARM_EPISODE = typeof replayEpisode === "number" ? replayEpisode : NEXT_WARM_EPISODE++;
@@ -3462,6 +3822,7 @@ function renderBlockInner(block) {
3462
3822
  EFFECT_EVENT_ACTION_TARGET = effectEventActionTarget;
3463
3823
  if (block.effectEventRenderVersion !== 0) block.effectEventRenderVersion++;
3464
3824
  block.pending = false;
3825
+ block.crossRenderUpdate = false;
3465
3826
  block.__thenableIdx = 0;
3466
3827
  {
3467
3828
  const tState = block.__thenables;
@@ -3472,22 +3833,29 @@ function renderBlockInner(block) {
3472
3833
  }
3473
3834
  if (block.$$ctxReads !== null) block.$$ctxReads.clear();
3474
3835
  if (block.$$ctxDirect !== null) block.$$ctxDirect.clear();
3475
- block.currentRenderMode = block.pendingMode ?? prevBlock?.currentRenderMode ?? "urgent";
3476
- block.currentRenderDeferred = block.pendingMode !== null ? block.pendingDeferred : prevBlock?.currentRenderDeferred ?? false;
3836
+ block.currentRenderMode = urgentTransitionRender !== null ? "urgent" : block.pendingMode ?? prevBlock?.currentRenderMode ?? "urgent";
3837
+ block.currentRenderDeferred = urgentTransitionRender !== null ? false : block.pendingMode !== null ? block.pendingDeferred : prevBlock?.currentRenderDeferred ?? false;
3477
3838
  block.pendingMode = null;
3478
3839
  block.pendingDeferred = false;
3479
3840
  const profileFrame = typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__ && (block.kind === "root" || block.kind === "dynamic" || block.kind === "portal") ? __profileBeginRender(block, block.body, block.mounted) : null;
3480
3841
  let profileDidThrow = false;
3481
3842
  let profileThrown;
3482
3843
  let renderCompleted = false;
3844
+ let renderRetry = false;
3483
3845
  NATIVE_READ_DRIVER?.beginRender(block);
3484
3846
  NATIVE_BLOCK_RETRIES?.get(block)?.clear();
3485
3847
  try {
3848
+ if (urgentTransitionRender !== null)
3849
+ urgentTransitionDriver.beginUrgent(block, urgentTransitionRender);
3486
3850
  const out = block.body(
3487
3851
  block.props,
3488
3852
  block,
3489
3853
  block.extra
3490
3854
  );
3855
+ if (block.pending && !block.crossRenderUpdate) {
3856
+ renderRetry = true;
3857
+ return true;
3858
+ }
3491
3859
  if (out !== void 0 && block.outputHandler !== null) block.outputHandler(block, out);
3492
3860
  finishEffectRender(block);
3493
3861
  if (!block.mounted) block.mounted = true;
@@ -3513,6 +3881,7 @@ function renderBlockInner(block) {
3513
3881
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__ && profileFrame !== null)
3514
3882
  __profileEndRender(profileFrame, profileDidThrow, profileThrown);
3515
3883
  if (!renderCompleted) {
3884
+ if (renderRetry) block.renderStatus = RENDER_INVALID;
3516
3885
  if (block.renderStatus !== RENDER_INVALID) {
3517
3886
  let owner = null;
3518
3887
  const suspension = isSuspenseException(profileThrown);
@@ -3538,7 +3907,12 @@ function renderBlockInner(block) {
3538
3907
  CURRENT_EFFECT_REACHED = prevEffectReached;
3539
3908
  CURRENT_SCOPE = prevScope;
3540
3909
  CURRENT_BLOCK = prevBlock;
3541
- NATIVE_READ_DRIVER?.endRender(block, renderCompleted, isSuspenseException(profileThrown));
3910
+ try {
3911
+ NATIVE_READ_DRIVER?.endRender(block, renderCompleted, isSuspenseException(profileThrown));
3912
+ } finally {
3913
+ if (urgentTransitionRender !== null)
3914
+ urgentTransitionDriver.endUrgent(block, urgentTransitionRender);
3915
+ }
3542
3916
  }
3543
3917
  }
3544
3918
  function returnSlotTail(block, state) {
@@ -3745,6 +4119,7 @@ class LiteBlockImpl {
3745
4119
  }
3746
4120
  }
3747
4121
  function componentSlotLite(parentScope, slotKey, host, comp, props, anchor) {
4122
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
3748
4123
  const hydration = activeHydration();
3749
4124
  let scope = parentScope.slots[slotKey];
3750
4125
  let adoptedOpen = null;
@@ -3908,7 +4283,7 @@ function unmountScope(scope, detachDom = true) {
3908
4283
  if (!passiveScheduled) schedulePassiveFlush();
3909
4284
  } else {
3910
4285
  try {
3911
- runEffectCleanupCallback(cleanup);
4286
+ runEffectCleanupCallback(cleanup, slot.phase);
3912
4287
  } catch (err) {
3913
4288
  reportTeardownError(err);
3914
4289
  }
@@ -3983,12 +4358,66 @@ function missingSlot(name) {
3983
4358
  throw new Error(formatClientError(15, name));
3984
4359
  }
3985
4360
  const slotStack = [];
4361
+ let MANUAL_HOOK_DRIVER = null;
4362
+ function invokeManualHook(fn, receiver, args) {
4363
+ const driver = MANUAL_HOOK_DRIVER ??= {
4364
+ pending: slotStack[slotStack.length - 1],
4365
+ active: false
4366
+ };
4367
+ const pending = driver.pending;
4368
+ const active = driver.active;
4369
+ driver.pending = void 0;
4370
+ driver.active = true;
4371
+ try {
4372
+ if (pending === void 0) return Reflect.apply(fn, receiver, args);
4373
+ switch (args.length) {
4374
+ case 0:
4375
+ return fn.call(receiver, pending);
4376
+ case 1:
4377
+ return fn.call(receiver, args[0], pending);
4378
+ case 2:
4379
+ return fn.call(receiver, args[0], args[1], pending);
4380
+ case 3:
4381
+ return fn.call(receiver, args[0], args[1], args[2], pending);
4382
+ case 4:
4383
+ return fn.call(receiver, args[0], args[1], args[2], args[3], pending);
4384
+ default: {
4385
+ const forwarded = new Array(args.length + 1);
4386
+ for (let index = 0; index < args.length; index++) forwarded[index] = args[index];
4387
+ forwarded[args.length] = pending;
4388
+ return fn.apply(receiver, forwarded);
4389
+ }
4390
+ }
4391
+ } finally {
4392
+ driver.pending = pending;
4393
+ driver.active = active;
4394
+ }
4395
+ }
4396
+ function manualHook(fn, name) {
4397
+ function provider() {
4398
+ return invokeManualHook(fn, this, arguments);
4399
+ }
4400
+ Object.defineProperty(provider, "name", { value: name ?? fn.name, configurable: true });
4401
+ Object.defineProperty(provider, "length", { value: fn.length, configurable: true });
4402
+ return provider;
4403
+ }
3986
4404
  function withSlot(sym, fn, ...args) {
4405
+ const driver = MANUAL_HOOK_DRIVER;
4406
+ const pending = driver?.pending;
4407
+ const active = driver?.active ?? false;
4408
+ if (driver !== null) {
4409
+ driver.pending = sym;
4410
+ driver.active = false;
4411
+ }
3987
4412
  slotStack.push(sym);
3988
4413
  try {
3989
4414
  return fn(...args);
3990
4415
  } finally {
3991
4416
  slotStack.pop();
4417
+ if (MANUAL_HOOK_DRIVER !== null) {
4418
+ MANUAL_HOOK_DRIVER.pending = driver === null ? slotStack[slotStack.length - 1] : pending;
4419
+ MANUAL_HOOK_DRIVER.active = active;
4420
+ }
3992
4421
  }
3993
4422
  }
3994
4423
  function appendSlotKey(key, slot) {
@@ -4019,7 +4448,7 @@ function nativeLocalHook(name, initialize, dispose, slot) {
4019
4448
  return cell.nativeValue;
4020
4449
  }
4021
4450
  function useState(initial, slot) {
4022
- if (slot === void 0 && typeof initial === "symbol") {
4451
+ if (slot === void 0 && typeof initial === "symbol" && arguments.length === 1 && (slotStack.length === 0 || MANUAL_HOOK_DRIVER?.active === true)) {
4023
4452
  slot = initial;
4024
4453
  initial = void 0;
4025
4454
  }
@@ -4033,16 +4462,44 @@ function useState(initial, slot) {
4033
4462
  s = {
4034
4463
  value: initVal,
4035
4464
  setter: (next) => {
4036
- const previous = stagedTransitionValue(s);
4037
- const computed = typeof next === "function" ? next(previous) : next;
4038
- if (Object.is(computed, previous)) return;
4039
- if (stageTransitionValue(s, block, next, computed)) {
4465
+ if (block.disposed) return;
4466
+ if (s.pendingActionBatch !== void 0 && transitionActionBatchForUpdate() === null)
4467
+ recordUrgentActionUpdate(s, next);
4468
+ if ((s.updates !== void 0 || s.renderTransition !== void 0 || typeof next === "function" && TRANSITION_PENDING_COUNT > 0 && TRANSITION_SWAP_DRIVER?.hasHeld(s, block) || block.pending && typeof next === "function") && transitionActionBatchForUpdate() === null) {
4469
+ (s.updates ??= []).push(next);
4470
+ scheduleRender(block);
4471
+ return;
4472
+ }
4473
+ const previous = stagedTransitionValue(s, block);
4474
+ let computed;
4475
+ let failed = false;
4476
+ try {
4477
+ computed = typeof next === "function" ? next(previous) : next;
4478
+ } catch {
4479
+ if (transitionActionBatchForUpdate() === null) {
4480
+ (s.updates ??= []).push(next);
4481
+ scheduleRender(block);
4482
+ return;
4483
+ }
4484
+ computed = previous;
4485
+ failed = true;
4486
+ }
4487
+ const forceRender = failed || s.updates !== void 0 || s.renderTransition !== void 0 || s.pendingActionBatch !== void 0 || block.pending && typeof next === "function";
4488
+ if (Object.is(computed, previous) && !forceRender) {
4489
+ if (typeof next !== "function" && TRANSITION_SWAP_DRIVER?.cancelEqual(s, block)) {
4490
+ scheduleRender(block);
4491
+ }
4492
+ return;
4493
+ }
4494
+ const update = stageTransitionValue(s, block, next, computed, forceRender);
4495
+ if (update !== null) {
4496
+ if (update.state === void 0) {
4497
+ update.state = s;
4498
+ captureTransitionHookQueue(update, s);
4499
+ }
4040
4500
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
4041
- const update = s.pendingActionBatch?.updates.get(s);
4042
- if (update !== void 0) {
4043
- update.profileType = "state";
4044
- update.profileSlot = slot;
4045
- }
4501
+ update.profileType = "state";
4502
+ update.profileSlot = slot;
4046
4503
  }
4047
4504
  return;
4048
4505
  }
@@ -4054,10 +4511,95 @@ function useState(initial, slot) {
4054
4511
  };
4055
4512
  ensureHooks(scope).set(slot, s);
4056
4513
  }
4514
+ if (s.renderTransition !== void 0 || s.updates !== void 0) {
4515
+ const value = readQueuedState(s);
4516
+ if (!s.urgentTransition && s.updates !== void 0 && Object.is(value, s.value))
4517
+ TRANSITION_SWAP_DRIVER?.rebaseHeld(s, block, s.updates);
4518
+ s.value = value;
4519
+ if (!s.urgentTransition) {
4520
+ if (s.renderTransition !== void 0) {
4521
+ finishQueuedTransition(s.renderTransition, s.value);
4522
+ s.renderTransition = void 0;
4523
+ }
4524
+ s.updates = void 0;
4525
+ }
4526
+ }
4057
4527
  return [s.value, s.setter];
4058
4528
  }
4529
+ function readQueuedState(state) {
4530
+ const transition = state.renderTransition;
4531
+ let value = transition === void 0 ? state.value : readQueuedTransition(transition, state.urgentTransition === true);
4532
+ if (state.updates !== void 0) {
4533
+ for (const update of state.updates)
4534
+ value = typeof update === "function" ? update(value) : update;
4535
+ }
4536
+ return value;
4537
+ }
4538
+ function readQueuedTransition(last, urgent, reducer) {
4539
+ let first = last;
4540
+ while (first.previous !== void 0) first = first.previous;
4541
+ let value = first.replayBaseValue;
4542
+ for (let entry = first; ; entry = entry.next) {
4543
+ if (entry.stateUpdates !== void 0) {
4544
+ for (const update of entry.stateUpdates)
4545
+ value = typeof update === "function" ? update(value) : update;
4546
+ }
4547
+ if (entry.reducerActions !== void 0) {
4548
+ for (const action of entry.reducerActions) value = reducer(value, action);
4549
+ }
4550
+ if ((urgent || entry.superseded) && entry.urgentOperations !== void 0) {
4551
+ for (const index of entry.urgentOperations) value = entry.operations[index](value);
4552
+ } else if (!urgent && !entry.superseded) {
4553
+ for (const operation of entry.operations) value = operation(value);
4554
+ }
4555
+ if (entry === last) return value;
4556
+ }
4557
+ }
4558
+ function captureTransitionHookQueue(update, cell) {
4559
+ update.replayBaseValue = cell.value;
4560
+ const previous = cell.renderTransition ?? TRANSITION_SWAP_DRIVER?.heldUpdate(cell, update.block);
4561
+ if (previous !== void 0) {
4562
+ update.previous = previous;
4563
+ previous.next = update;
4564
+ }
4565
+ if (update.state !== void 0) update.stateUpdates = update.state.updates?.slice();
4566
+ else update.reducerActions = update.reducer.renderPhaseActions?.slice();
4567
+ }
4568
+ function recordUrgentActionUpdate(cell, operation) {
4569
+ const update = cell.pendingActionBatch.updates.get(cell);
4570
+ if (update === void 0) return;
4571
+ (update.urgentOperations ??= []).push(update.operations.length);
4572
+ update.operations.push(
4573
+ typeof operation === "function" ? operation : () => operation
4574
+ );
4575
+ update.forceRender = true;
4576
+ }
4577
+ function finishQueuedTransition(last, value) {
4578
+ for (let entry = last; entry; entry = entry.previous) {
4579
+ entry.value = value;
4580
+ if (entry !== last && Object.is(value, entry.baseValue)) entry.superseded = true;
4581
+ }
4582
+ }
4583
+ function beginUrgentTransitionCell(update) {
4584
+ const cell = update.state ?? update.reducer;
4585
+ if (update.block.disposed || update.superseded || cell === void 0 || cell.renderTransition === void 0)
4586
+ return null;
4587
+ cell.urgentTransition = true;
4588
+ cell.value = update.baseValue;
4589
+ return { update, cell };
4590
+ }
4591
+ function endUrgentTransitionCell(snapshot) {
4592
+ const { update, cell } = snapshot;
4593
+ cell.urgentTransition = false;
4594
+ if (update.block.disposed || update.superseded) {
4595
+ cell.renderTransition = void 0;
4596
+ return;
4597
+ }
4598
+ for (let entry = update; entry; entry = entry.previous)
4599
+ entry.baseValue = cell.value;
4600
+ }
4059
4601
  function __useStateWithGetter(initial, slot) {
4060
- if (slot === void 0 && typeof initial === "symbol") {
4602
+ if (slot === void 0 && typeof initial === "symbol" && arguments.length === 1 && (slotStack.length === 0 || MANUAL_HOOK_DRIVER?.active === true)) {
4061
4603
  slot = initial;
4062
4604
  initial = void 0;
4063
4605
  }
@@ -4067,9 +4609,9 @@ function __useStateWithGetter(initial, slot) {
4067
4609
  const s = CURRENT_SCOPE.hooks.get(resolved);
4068
4610
  const getter = s.getter ?? (s.getter = () => {
4069
4611
  const batch = s.pendingActionBatch;
4070
- if (batch === void 0) return s.value;
4612
+ if (batch === void 0) return readQueuedState(s);
4071
4613
  const update = batch.updates.get(s);
4072
- return update === void 0 ? s.value : rebaseTransitionActionUpdate(update);
4614
+ return update === void 0 ? readQueuedState(s) : readQueuedTransition(update, false);
4073
4615
  });
4074
4616
  return [pair[0], pair[1], getter];
4075
4617
  }
@@ -4169,13 +4711,11 @@ function useLinkedState(source, reconcile, options, slot) {
4169
4711
  else scheduleRender(block);
4170
4712
  return;
4171
4713
  }
4172
- if (stageTransitionValue(state, block, operation, computed)) {
4714
+ const update = stageTransitionValue(state, block, operation, computed);
4715
+ if (update !== null) {
4173
4716
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
4174
- const update = state.pendingActionBatch?.updates.get(state);
4175
- if (update !== void 0) {
4176
- update.profileType = "state";
4177
- update.profileSlot = slot;
4178
- }
4717
+ update.profileType = "state";
4718
+ update.profileSlot = slot;
4179
4719
  }
4180
4720
  return;
4181
4721
  }
@@ -4293,26 +4833,31 @@ function useReducer(reducer, initialArg, initOrSlot, slot) {
4293
4833
  // the component once (children then bail as usual). Per
4294
4834
  // ReactHooksWithNoopRenderer-test.js:3889.
4295
4835
  dispatch: (action) => {
4296
- if (CURRENT_BLOCK === block) {
4836
+ if (block.disposed) return;
4837
+ if (CURRENT_BLOCK === block || transitionActionBatchForUpdate() === null) {
4838
+ if (s.pendingActionBatch !== void 0 && transitionActionBatchForUpdate() === null)
4839
+ recordUrgentActionUpdate(s, (value) => s.reducer(value, action));
4297
4840
  const actions = s.renderPhaseActions ??= [];
4298
- const previous2 = actions.length === 0 ? s.value : s.renderPhaseValue;
4299
4841
  actions.push(action);
4300
- if (s.getter !== void 0) {
4301
- s.renderPhaseValue = s.reducer(previous2, action);
4302
- }
4303
4842
  scheduleRender(block);
4304
4843
  return;
4305
4844
  }
4306
- const previous = stagedTransitionValue(s);
4845
+ const previous = stagedTransitionValue(s, block);
4307
4846
  const operation = (value) => s.reducer(value, action);
4308
- const computed = operation(previous);
4309
- if (stageTransitionValue(s, block, operation, computed, true)) {
4847
+ let computed = previous;
4848
+ try {
4849
+ computed = operation(previous);
4850
+ } catch {
4851
+ }
4852
+ const update = stageTransitionValue(s, block, operation, computed, true);
4853
+ if (update !== null) {
4854
+ if (update.reducer === void 0) {
4855
+ update.reducer = s;
4856
+ captureTransitionHookQueue(update, s);
4857
+ }
4310
4858
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
4311
- const update = s.pendingActionBatch?.updates.get(s);
4312
- if (update !== void 0) {
4313
- update.profileType = "reducer";
4314
- update.profileSlot = slot;
4315
- }
4859
+ update.profileType = "reducer";
4860
+ update.profileSlot = slot;
4316
4861
  }
4317
4862
  return;
4318
4863
  }
@@ -4325,17 +4870,32 @@ function useReducer(reducer, initialArg, initOrSlot, slot) {
4325
4870
  ensureHooks(scope).set(slot, s);
4326
4871
  } else {
4327
4872
  s.reducer = reducer;
4328
- const actions = s.renderPhaseActions;
4329
- if (actions !== void 0) {
4330
- let value = s.value;
4331
- for (let i = 0; i < actions.length; i++) value = reducer(value, actions[i]);
4873
+ if (s.renderTransition !== void 0 || s.renderPhaseActions !== void 0) {
4874
+ const value = readQueuedReducer(s);
4875
+ if (!s.urgentTransition && s.renderPhaseActions !== void 0 && Object.is(value, s.value))
4876
+ TRANSITION_SWAP_DRIVER?.rebaseHeld(s, block, s.renderPhaseActions, reducer);
4332
4877
  s.value = value;
4333
- s.renderPhaseActions = void 0;
4334
- s.renderPhaseValue = void 0;
4878
+ if (!s.urgentTransition) {
4879
+ if (s.renderTransition !== void 0) {
4880
+ finishQueuedTransition(s.renderTransition, s.value);
4881
+ s.renderTransition = void 0;
4882
+ }
4883
+ s.renderPhaseActions = void 0;
4884
+ }
4335
4885
  }
4336
4886
  }
4337
4887
  return [s.value, s.dispatch];
4338
4888
  }
4889
+ function readQueuedReducer(state) {
4890
+ let value = state.renderTransition === void 0 ? state.value : readQueuedTransition(
4891
+ state.renderTransition,
4892
+ state.urgentTransition === true,
4893
+ state.reducer
4894
+ );
4895
+ if (state.renderPhaseActions !== void 0)
4896
+ for (const action of state.renderPhaseActions) value = state.reducer(value, action);
4897
+ return value;
4898
+ }
4339
4899
  function __useReducerWithGetter(reducer, initialArg, initOrSlot, slot) {
4340
4900
  const resolvedInput = typeof initOrSlot === "symbol" ? initOrSlot : slot;
4341
4901
  const pair = useReducer(reducer, initialArg, initOrSlot, slot);
@@ -4343,18 +4903,26 @@ function __useReducerWithGetter(reducer, initialArg, initOrSlot, slot) {
4343
4903
  if (resolved === void 0) missingSlot("useReducer");
4344
4904
  const s = CURRENT_SCOPE.hooks.get(resolved);
4345
4905
  const getter = s.getter ?? (s.getter = () => {
4346
- if (s.renderPhaseActions !== void 0) return s.renderPhaseValue;
4347
4906
  const batch = s.pendingActionBatch;
4348
- if (batch === void 0) return s.value;
4907
+ if (batch === void 0) return readQueuedReducer(s);
4349
4908
  const update = batch.updates.get(s);
4350
- return update === void 0 ? s.value : rebaseTransitionActionUpdate(update);
4909
+ return update === void 0 ? readQueuedReducer(s) : readQueuedTransition(update, false, s.reducer);
4351
4910
  });
4352
4911
  return [pair[0], pair[1], getter];
4353
4912
  }
4354
- function depsChanged(prev, next) {
4913
+ function depsChanged(prev, next, hook = false) {
4355
4914
  if (prev === void 0 || next === void 0) return true;
4356
- if (prev.length !== next.length) return true;
4357
- for (let i = 0; i < prev.length; i++) {
4915
+ let length = prev.length;
4916
+ if (length !== next.length) {
4917
+ if (!hook) return true;
4918
+ if (process.env.NODE_ENV !== "production") {
4919
+ console.error(
4920
+ `The dependency array must keep the same length between renders (previous: ${length}, next: ${next.length}).`
4921
+ );
4922
+ }
4923
+ length = Math.min(length, next.length);
4924
+ }
4925
+ for (let i = 0; i < length; i++) {
4358
4926
  if (!Object.is(prev[i], next[i])) return true;
4359
4927
  }
4360
4928
  return false;
@@ -4421,7 +4989,7 @@ function enqueueEffect(slot, fn, deps, phase) {
4421
4989
  return;
4422
4990
  }
4423
4991
  if (prev) {
4424
- const changed = depsChanged(prev.deps, deps);
4992
+ const changed = depsChanged(prev.deps, deps, true);
4425
4993
  if (prev.active && !changed) return;
4426
4994
  if (ROOT_RENDER_TRANSACTION !== null) journalObjectOnce(prev);
4427
4995
  let reactivated = false;
@@ -4525,7 +5093,7 @@ function adoptMemoEntry(scope, slot, deps) {
4525
5093
  }
4526
5094
  function readMemoEntry(scope, slot, deps) {
4527
5095
  const prev = scope.hooks?.get(slot);
4528
- if (prev && deps !== void 0 && !depsChanged(prev.deps, deps)) {
5096
+ if (prev && deps !== void 0 && !depsChanged(prev.deps, deps, true)) {
4529
5097
  return memoEntryHit(slot, prev);
4530
5098
  }
4531
5099
  return WARM_EVER && deps !== void 0 ? adoptMemoEntry(scope, slot, deps) : null;
@@ -4540,12 +5108,21 @@ function publishMemoEntry(scope, slot, deps, value, nativeWitness) {
4540
5108
  }
4541
5109
  return value;
4542
5110
  }
5111
+ let devMemoComputeDepth = 0;
5112
+ function computeMemoWithDiagnostics(compute, deps) {
5113
+ devMemoComputeDepth++;
5114
+ try {
5115
+ return compute.apply(null, deps ?? []);
5116
+ } finally {
5117
+ devMemoComputeDepth--;
5118
+ }
5119
+ }
4543
5120
  function useMemo(compute, deps, slot) {
4544
5121
  const [d, s] = resolveHookArgs("useMemo", deps, slot);
4545
5122
  const scope = CURRENT_SCOPE;
4546
5123
  const entry = readMemoEntry(scope, s, d);
4547
5124
  if (entry !== null) return entry.value;
4548
- const value = compute.apply(null, d ?? []);
5125
+ const value = process.env.NODE_ENV !== "production" ? computeMemoWithDiagnostics(compute, d) : compute.apply(null, d ?? []);
4549
5126
  return publishMemoEntry(scope, s, d, value);
4550
5127
  }
4551
5128
  function useCallback(fn, deps, slot) {
@@ -4617,7 +5194,7 @@ function hookMemoPublishInvariant(cells, base, value) {
4617
5194
  return value;
4618
5195
  }
4619
5196
  function useRef(initial, slot) {
4620
- if (slot === void 0 && typeof initial === "symbol") {
5197
+ if (slot === void 0 && typeof initial === "symbol" && arguments.length === 1 && (slotStack.length === 0 || MANUAL_HOOK_DRIVER?.active === true)) {
4621
5198
  slot = initial;
4622
5199
  initial = void 0;
4623
5200
  }
@@ -4731,13 +5308,33 @@ function subscribeToStore(inst, subscribe) {
4731
5308
  if (checkStoreChanged(inst)) inst.forceUpdate();
4732
5309
  return subscribe(inst.onStoreChange);
4733
5310
  }
5311
+ function scheduleStoreRender(block) {
5312
+ const depth = TRANSITION_DEPTH;
5313
+ const asyncCount = ASYNC_TRANSITION_COUNT;
5314
+ TRANSITION_DEPTH = 0;
5315
+ ASYNC_TRANSITION_COUNT = 0;
5316
+ try {
5317
+ scheduleRender(block);
5318
+ } finally {
5319
+ TRANSITION_DEPTH = depth;
5320
+ ASYNC_TRANSITION_COUNT = asyncCount;
5321
+ }
5322
+ }
5323
+ let DID_WARN_UNCACHED_SNAPSHOT = false;
4734
5324
  function useSyncExternalStore(subscribe, getSnapshot, ...rest) {
4735
5325
  let slot = rest[rest.length - 1];
4736
5326
  slot = resolveSlot(slot);
4737
5327
  if (slot === void 0) missingSlot("useSyncExternalStore");
4738
5328
  const getServerSnapshot = rest.length >= 2 ? rest[0] : void 0;
4739
5329
  const subs = usesSubslots(slot);
4740
- const value = activeHydration() !== null && getServerSnapshot !== void 0 ? getServerSnapshot() : getSnapshot();
5330
+ const readSnapshot = activeHydration() !== null && getServerSnapshot !== void 0 ? getServerSnapshot : getSnapshot;
5331
+ const value = readSnapshot();
5332
+ if (process.env.NODE_ENV !== "production" && !DID_WARN_UNCACHED_SNAPSHOT && !Object.is(value, readSnapshot())) {
5333
+ DID_WARN_UNCACHED_SNAPSHOT = true;
5334
+ console.error(
5335
+ "The " + (readSnapshot === getSnapshot ? "getSnapshot" : "getServerSnapshot") + " result must be cached to avoid an infinite update loop."
5336
+ );
5337
+ }
4741
5338
  const scope = CURRENT_SCOPE;
4742
5339
  let inst = scope.hooks?.get(subs.inst);
4743
5340
  if (inst === void 0) {
@@ -4749,11 +5346,11 @@ function useSyncExternalStore(subscribe, getSnapshot, ...rest) {
4749
5346
  subscribe,
4750
5347
  forceUpdate: typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__ ? () => {
4751
5348
  if (!block.disposed) __profileSchedule(block, "external-store", slot);
4752
- scheduleRender(block);
4753
- } : () => scheduleRender(block),
5349
+ scheduleStoreRender(block);
5350
+ } : () => scheduleStoreRender(block),
4754
5351
  onStoreChange: () => {
4755
5352
  if (block.disposed) return;
4756
- if (CURRENT_BLOCK === null && block.pending && block.pendingMode === "urgent" && !block.pendingDeferred && !(typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) && (process.env.NODE_ENV === "production" || !IS_OCTANE_ACT_ENVIRONMENT || actScopeDepth !== 0 || syncFlush)) {
5353
+ if (CURRENT_BLOCK === null && block.pending && block.pendingMode === "urgent" && !block.pendingDeferred && !(typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) && (process.env.NODE_ENV === "production" || !isActEnvironment() || actScopeDepth !== 0 || syncFlush)) {
4757
5354
  return;
4758
5355
  }
4759
5356
  if (checkStoreChanged(created)) created.forceUpdate();
@@ -5917,7 +6514,8 @@ const Suspense = /* @__PURE__ */ markComponentFlags(
5917
6514
  );
5918
6515
  },
5919
6516
  COMPONENT_FLAG_BOUNDARY,
5920
- "Suspense"
6517
+ "Suspense",
6518
+ /* @__PURE__ */ Symbol.for("octane.suspense")
5921
6519
  );
5922
6520
  function initializeViewTransitionComponent() {
5923
6521
  return markComponentFlags(
@@ -5964,6 +6562,11 @@ const ErrorBoundary = /* @__PURE__ */ markComponentFlags(
5964
6562
  );
5965
6563
  const TsrxErrorBoundary = ErrorBoundary;
5966
6564
  function use(usable) {
6565
+ if (process.env.NODE_ENV !== "production" && devMemoComputeDepth !== 0) {
6566
+ console.error(
6567
+ "Do not call use() inside a useMemo() factory. Cached factories can skip context or promise reads; call use() before useMemo() and memoize the returned value instead."
6568
+ );
6569
+ }
5967
6570
  if (usable && usable.$$kind === CONTEXT_TAG) {
5968
6571
  return useContextInternal(usable);
5969
6572
  }
@@ -6664,6 +7267,15 @@ function warmChild(comp, props) {
6664
7267
  WARM_DEPTH--;
6665
7268
  }
6666
7269
  }
7270
+ function markWarm(component, plan) {
7271
+ Object.defineProperty(component, "__warm", {
7272
+ configurable: true,
7273
+ get() {
7274
+ return this === component ? plan : void 0;
7275
+ }
7276
+ });
7277
+ return component;
7278
+ }
6667
7279
  function adoptWarmEntry(slot, deps, accept) {
6668
7280
  let b = CURRENT_BLOCK;
6669
7281
  while (b !== null) {
@@ -6962,6 +7574,8 @@ function lazy(load) {
6962
7574
  let thenable = null;
6963
7575
  let profiledComponent = null;
6964
7576
  let memoMetadataInstalled = false;
7577
+ let displayName;
7578
+ let resolvedName = "Lazy";
6965
7579
  let lazyWrapper;
6966
7580
  const initializeLazy = () => {
6967
7581
  if (status !== "uninitialized") return;
@@ -6994,16 +7608,23 @@ function lazy(load) {
6994
7608
  };
6995
7609
  const callResolvedComponent = (props, scope, extra) => {
6996
7610
  const comp = resolveLazyModule(result);
7611
+ resolvedName = comp.displayName || comp.name || "Lazy";
6997
7612
  if (comp.__memo === true) {
6998
7613
  if (!memoMetadataInstalled) {
6999
- lazyWrapper.__memo = true;
7000
- lazyWrapper.__compare = (prev, next) => {
7001
- const current = resolveLazyModule(result);
7002
- const compare = current.__compare;
7003
- const previous = lazyResolvedProps(current, prev);
7004
- const incoming = lazyResolvedProps(current, next);
7005
- return compare ? compare(previous, incoming) : shallowEqualProps(previous, incoming);
7006
- };
7614
+ Object.defineProperty(lazyWrapper, "__memo", {
7615
+ get() {
7616
+ return this === lazyWrapper;
7617
+ }
7618
+ });
7619
+ Object.defineProperty(lazyWrapper, "__compare", {
7620
+ value: (prev, next) => {
7621
+ const current = resolveLazyModule(result);
7622
+ const compare = current.__compare;
7623
+ const previous = lazyResolvedProps(current, prev);
7624
+ const incoming = lazyResolvedProps(current, next);
7625
+ return compare ? compare(previous, incoming) : shallowEqualProps(previous, incoming);
7626
+ }
7627
+ });
7007
7628
  memoMetadataInstalled = true;
7008
7629
  }
7009
7630
  scope.block.memoInChain = true;
@@ -7033,10 +7654,22 @@ function lazy(load) {
7033
7654
  }
7034
7655
  if (settledStatus === "rejected") throw result;
7035
7656
  }
7657
+ runActiveWarmPlans();
7036
7658
  throw new SuspenseException(thenable);
7037
7659
  };
7038
- lazyWrapper.__warm = initializeLazy;
7039
- Object.defineProperty(lazyWrapper, LAZY_COMPONENT, { value: true });
7660
+ markWarm(lazyWrapper, initializeLazy);
7661
+ Object.defineProperty(lazyWrapper, LAZY_COMPONENT, {
7662
+ get() {
7663
+ return this === lazyWrapper;
7664
+ }
7665
+ });
7666
+ Object.defineProperty(lazyWrapper, "displayName", {
7667
+ configurable: true,
7668
+ get: () => displayName ?? resolvedName,
7669
+ set: (value) => {
7670
+ displayName = value;
7671
+ }
7672
+ });
7040
7673
  return lazyWrapper;
7041
7674
  }
7042
7675
  function useId(slot) {
@@ -7248,6 +7881,7 @@ class HydrationCapability {
7248
7881
  warnHydrationStructuralMismatch(loc, expected, actual);
7249
7882
  }
7250
7883
  recordTextMismatch(node, loc, server) {
7884
+ if (process.env.NODE_ENV === "production" && ROOT_ERROR_HANDLERS === null) return;
7251
7885
  if (!this.textWarnings.has(node)) this.textWarnings.set(node, { loc, server });
7252
7886
  }
7253
7887
  flushTextWarnings() {
@@ -7255,7 +7889,9 @@ class HydrationCapability {
7255
7889
  if (!this.rootBlock.parentNode.contains(node)) continue;
7256
7890
  const client = node.nodeValue;
7257
7891
  if (pending.server !== client) {
7258
- warnHydrationValueMismatch(pending.loc, "text", pending.server, client);
7892
+ noteRecoverableHydrationError(() => new Error(formatClientError(61)), this.rootBlock);
7893
+ if (process.env.NODE_ENV !== "production")
7894
+ warnHydrationValueMismatch(pending.loc, "text", pending.server, client);
7259
7895
  }
7260
7896
  }
7261
7897
  this.textWarnings.clear();
@@ -7514,10 +8150,20 @@ class HydrationCapability {
7514
8150
  if (first !== null && first.nodeType === 3) {
7515
8151
  const server = first.nodeValue;
7516
8152
  if (server !== text && !isTextParserNormalizedMatch(server, text) && !isHydrationSuppressed(el)) {
7517
- if (process.env.NODE_ENV !== "production")
7518
- this.recordTextMismatch(first, loc || el.__oct_loc, server);
8153
+ this.recordTextMismatch(first, loc || el.__oct_loc, server);
7519
8154
  first.nodeValue = text;
7520
8155
  }
8156
+ if (first.nextSibling !== null) {
8157
+ noteRecoverableHydrationError(() => new Error(formatClientError(62)), this.rootBlock);
8158
+ if (process.env.NODE_ENV !== "production") {
8159
+ warnHydrationStructuralMismatch(
8160
+ loc || el.__oct_loc,
8161
+ "the end of the text element",
8162
+ describeHydrationNode(first.nextSibling)
8163
+ );
8164
+ }
8165
+ while (first.nextSibling !== null) el.removeChild(first.nextSibling);
8166
+ }
7521
8167
  return first;
7522
8168
  }
7523
8169
  if (this.isOpen(first)) {
@@ -7539,8 +8185,7 @@ class HydrationCapability {
7539
8185
  if (server !== text && !isTextParserNormalizedMatch(server, text)) {
7540
8186
  const host2 = posNode.parentNode;
7541
8187
  if (!isHydrationSuppressed(host2)) {
7542
- if (process.env.NODE_ENV !== "production")
7543
- this.recordTextMismatch(posNode, host2 && host2.__oct_loc, server);
8188
+ this.recordTextMismatch(posNode, host2 && host2.__oct_loc, server);
7544
8189
  posNode.nodeValue = text;
7545
8190
  }
7546
8191
  }
@@ -8727,6 +9372,7 @@ function attrNamespace(name) {
8727
9372
  return null;
8728
9373
  }
8729
9374
  function setAttribute(el, name, value) {
9375
+ if (name === "innerText" || name === "textContent") return;
8730
9376
  if (process.env.NODE_ENV !== "production" && el.__oct_loc !== void 0 && !isHtmlCustomElement(el) && typeof el.__oct_custom_is !== "string") {
8731
9377
  const warning = isAriaAttributeName(name) ? ariaAttributeWarning(name, el.localName) : hostPropertyWarning(name, value, el.localName, el.namespaceURI === SVG_NS);
8732
9378
  if (warning !== null) devWarnAttributeOnce(el, name, warning);
@@ -8764,6 +9410,10 @@ function setAttribute(el, name, value) {
8764
9410
  break;
8765
9411
  case 8:
8766
9412
  if ((name === "multiple" || name === "selected") && !isHtmlCustomElement(el)) {
9413
+ if (name === "selected") {
9414
+ const hydration2 = activeHydration();
9415
+ if (hydration2 !== null && !hydration2.isFresh(el)) return;
9416
+ }
8767
9417
  el[name] = value && typeof value !== "function" && typeof value !== "symbol";
8768
9418
  return;
8769
9419
  }
@@ -8947,7 +9597,7 @@ function setAriaAttribute(el, name, value) {
8947
9597
  const warning = ariaAttributeWarning(name, el.localName);
8948
9598
  if (warning !== null) devWarnAttributeOnce(el, name, warning);
8949
9599
  }
8950
- const next = value == null ? null : String(value);
9600
+ const next = value == null || typeof value === "function" || typeof value === "symbol" ? null : String(value);
8951
9601
  const hydration = activeHydration();
8952
9602
  if (hydration !== null && !hydration.allowAttribute(el, name, next)) return;
8953
9603
  if (TRANSITION_JOURNAL !== null) journalAttr(el, name);
@@ -8956,7 +9606,7 @@ function setAriaAttribute(el, name, value) {
8956
9606
  }
8957
9607
  function coerceAttrValue(el, name, value) {
8958
9608
  if (name.charCodeAt(0) === 97 && name.startsWith("aria-")) {
8959
- return value == null ? null : String(value);
9609
+ return value == null || typeof value === "function" || typeof value === "symbol" ? null : String(value);
8960
9610
  }
8961
9611
  const t = typeof value;
8962
9612
  if (t === "boolean" && isEnumeratedBooleanAttr(name)) return value ? "true" : "false";
@@ -9004,6 +9654,7 @@ function coerceAttrValue(el, name, value) {
9004
9654
  if (POSITIVE_NUMERIC_ATTR_PROPS.has(lower) && !(Number(value) >= 1)) {
9005
9655
  return null;
9006
9656
  }
9657
+ if ((lower === "rowspan" || lower === "start") && Number.isNaN(Number(value))) return null;
9007
9658
  if (name.length > 2 && name.charCodeAt(0) === 111 && name.charCodeAt(1) === 110) {
9008
9659
  return null;
9009
9660
  }
@@ -9042,7 +9693,13 @@ function coerceAttrValue(el, name, value) {
9042
9693
  }
9043
9694
  return v;
9044
9695
  }
9045
- import { devWarnStyleCoercion, devWarnStyleProperty, normalizeClass, styleName } from "./css.js";
9696
+ import {
9697
+ devWarnStyleCoercion,
9698
+ devWarnStyleProperty,
9699
+ mergeClass,
9700
+ normalizeClass,
9701
+ styleName
9702
+ } from "./css.js";
9046
9703
  function setClassName(el, value) {
9047
9704
  const cls = normalizeClass(value);
9048
9705
  const hydration = activeHydration();
@@ -9097,7 +9754,9 @@ function setStyleProperty(el, name, value, staticCss, previous) {
9097
9754
  }
9098
9755
  function applyStyleValue(el, style, value, prev) {
9099
9756
  if (value == null || value === false || value === "") {
9100
- if (prev != null && prev !== false && prev !== "") style.cssText = "";
9757
+ if (prev && typeof prev === "object") {
9758
+ for (const key in prev) style.removeProperty(styleName(key));
9759
+ } else if (typeof prev === "string") style.cssText = "";
9101
9760
  return;
9102
9761
  }
9103
9762
  if (typeof value === "string") {
@@ -9154,10 +9813,13 @@ function isEventKey(k) {
9154
9813
  const CAPTURE_PREFIX = "$$capture:";
9155
9814
  function jsxEventName(rest) {
9156
9815
  if (rest === "DoubleClick") return "dblclick";
9816
+ if (rest === "Focus") return "focusin";
9817
+ if (rest === "Blur") return "focusout";
9157
9818
  return rest.toLowerCase();
9158
9819
  }
9159
- function eventSlot(name) {
9160
- if (!isEventKey(name)) return null;
9820
+ function eventSlot(name, el) {
9821
+ if (!isEventKey(name) || el !== void 0 && isHtmlCustomElement(el) && !isDelegatedEventProp(name))
9822
+ return null;
9161
9823
  let rest = name.slice(2);
9162
9824
  let capture = false;
9163
9825
  if (rest.length > 7 && rest.endsWith("Capture") && name !== "onGotPointerCapture" && name !== "onLostPointerCapture") {
@@ -9194,7 +9856,7 @@ function removeHostProp(el, name, prevValue) {
9194
9856
  );
9195
9857
  return;
9196
9858
  }
9197
- const ev = eventSlot(name);
9859
+ const ev = eventSlot(name, el);
9198
9860
  if (ev) setEventHandler(el, ev.key, null);
9199
9861
  else setAttribute(el, name, null);
9200
9862
  }
@@ -9211,8 +9873,8 @@ function snapshotSpread(value) {
9211
9873
  return snapshot;
9212
9874
  }
9213
9875
  function formActionAttributeName(el, name) {
9214
- if (el.localName === "form" && name === "action") return "action";
9215
- if ((el.localName === "button" || el.localName === "input") && (name === "formAction" || name === "formaction"))
9876
+ if (name === "action" && el.localName === "form") return "action";
9877
+ if ((name === "formAction" || name === "formaction") && (el.localName === "button" || el.localName === "input"))
9216
9878
  return "formaction";
9217
9879
  return null;
9218
9880
  }
@@ -9233,8 +9895,9 @@ function normalizedHostProp(el, rawName) {
9233
9895
  }
9234
9896
  function setHostPropSources(el, sources, prev, scope, hasNestedChildren = false) {
9235
9897
  const props = /* @__PURE__ */ new Map();
9898
+ let classMerges = null;
9236
9899
  let sourceOrder = 0;
9237
- const record = (rawName, value) => {
9900
+ function record(rawName, value) {
9238
9901
  if (typeof rawName !== "string") return;
9239
9902
  const order = sourceOrder++;
9240
9903
  const previous = props.get(rawName);
@@ -9244,10 +9907,15 @@ function setHostPropSources(el, sources, prev, scope, hasNestedChildren = false)
9244
9907
  firstOrder: previous?.firstOrder ?? order,
9245
9908
  lastOrder: order
9246
9909
  });
9247
- };
9910
+ }
9248
9911
  for (const source of sources) {
9249
9912
  if (!source[0]) {
9250
- record(source[1], source[2]);
9913
+ const rawName = source[1];
9914
+ if (source[3] === true && typeof rawName === "string" && (rawName === "class" || rawName === "className")) {
9915
+ (classMerges ??= []).push({ rawName, value: source[2], order: sourceOrder++ });
9916
+ continue;
9917
+ }
9918
+ record(rawName, source[2]);
9251
9919
  continue;
9252
9920
  }
9253
9921
  const spread = source[1];
@@ -9273,6 +9941,22 @@ function setHostPropSources(el, sources, prev, scope, hasNestedChildren = false)
9273
9941
  writer.lastOrder
9274
9942
  ]);
9275
9943
  }
9944
+ if (classMerges !== null) {
9945
+ for (const extra of classMerges) {
9946
+ const [identity, name] = normalizedHostProp(el, extra.rawName);
9947
+ const previous = values.get(identity);
9948
+ if (previous !== void 0) {
9949
+ values.set(identity, [
9950
+ previous[0],
9951
+ mergeClass(previous[1], extra.value),
9952
+ previous[2],
9953
+ extra.order
9954
+ ]);
9955
+ continue;
9956
+ }
9957
+ values.set(identity, [name, extra.value, extra.order, extra.order]);
9958
+ }
9959
+ }
9276
9960
  const resolved = /* @__PURE__ */ Object.create(null);
9277
9961
  const ordered = [...values.values()];
9278
9962
  if (needsWinningOrderSort) ordered.sort((a, b) => a[2] - b[2]);
@@ -9300,7 +9984,7 @@ function setSpread(el, value, prev, mountScope, skipDangerouslySetInnerHTML = fa
9300
9984
  devValidateHostProps(el, Object(value));
9301
9985
  }
9302
9986
  if (value != null && Object.prototype.propertyIsEnumerable.call(Object(value), "suppressHydrationWarning")) {
9303
- el.__oct_suppress = value.suppressHydrationWarning !== false;
9987
+ el.__oct_suppress = value.suppressHydrationWarning === true;
9304
9988
  }
9305
9989
  if (process.env.NODE_ENV !== "production" && value != null && Object.prototype.propertyIsEnumerable.call(Object(value), "suppressNativeChangeWarning")) {
9306
9990
  el.__oct_native_change_suppressed = value.suppressNativeChangeWarning === true;
@@ -9374,7 +10058,7 @@ function setSpread(el, value, prev, mountScope, skipDangerouslySetInnerHTML = fa
9374
10058
  );
9375
10059
  continue;
9376
10060
  }
9377
- const ev = eventSlot(k);
10061
+ const ev = eventSlot(k, el);
9378
10062
  if (ev) {
9379
10063
  if (v === pv) continue;
9380
10064
  if (ev.capture) {
@@ -9406,9 +10090,9 @@ function removeHeadEventListeners(state, attrs) {
9406
10090
  handlers.delete(name);
9407
10091
  }
9408
10092
  }
9409
- function adoptServerHeadEl(key, tag) {
10093
+ function adoptServerHeadEl(head, key, tag) {
9410
10094
  const closeKey = "/" + key;
9411
- for (let n = document.head.firstChild; n !== null; n = n.nextSibling) {
10095
+ for (let n = head.firstChild; n !== null; n = n.nextSibling) {
9412
10096
  if (n.nodeType === 8 && n.data === key) {
9413
10097
  let candidate = n.nextSibling;
9414
10098
  let match = null;
@@ -9444,12 +10128,16 @@ function headBlock(scope, slot, key, tag, attrs, text) {
9444
10128
  if (typeof document === "undefined") return;
9445
10129
  let state = scope.slots[slot];
9446
10130
  if (state === void 0) {
9447
- let el2 = adoptServerHeadEl(headOwnershipKey(key, rootIdentifierPrefix(scope.block)), tag);
10131
+ const parent = scope.block.parentNode;
10132
+ const ownerDocument = parent.nodeType === 9 ? parent : parent.ownerDocument;
10133
+ const head = ownerDocument.head;
10134
+ let el2 = adoptServerHeadEl(head, headOwnershipKey(key, rootIdentifierPrefix(scope.block)), tag);
10135
+ const adopted = el2 !== null;
9448
10136
  if (el2 === null) {
9449
- el2 = document.createElement(tag);
9450
- document.head.appendChild(el2);
10137
+ el2 = ownerDocument.createElement(tag);
10138
+ head.appendChild(el2);
9451
10139
  }
9452
- state = { el: el2 };
10140
+ state = { el: el2, attrNames: adopted ? el2.getAttributeNames() : void 0 };
9453
10141
  scope.slots[slot] = state;
9454
10142
  (scope.cleanups ??= []).push(() => {
9455
10143
  removeHeadEventListeners(state, null);
@@ -9458,8 +10146,20 @@ function headBlock(scope, slot, key, tag, attrs, text) {
9458
10146
  });
9459
10147
  }
9460
10148
  const el = state.el;
10149
+ if (TRANSITION_JOURNAL !== null) {
10150
+ journalObjectOnce(state);
10151
+ journalBag();
10152
+ }
9461
10153
  if (state.handlers !== void 0) removeHeadEventListeners(state, attrs);
10154
+ const previousNames = state.attrNames;
10155
+ if (previousNames !== void 0) {
10156
+ for (let i = 0; i < previousNames.length; i++) {
10157
+ const name = previousNames[i];
10158
+ if (attrs === null || !(name in attrs)) setAttribute(el, name, null);
10159
+ }
10160
+ }
9462
10161
  if (attrs !== null) {
10162
+ const names = [];
9463
10163
  for (const k in attrs) {
9464
10164
  const ev = k.length > 2 && k[0] === "o" && k[1] === "n" ? eventSlot(k) : null;
9465
10165
  if (ev !== null) {
@@ -9480,12 +10180,19 @@ function headBlock(scope, slot, key, tag, attrs, text) {
9480
10180
  }
9481
10181
  continue;
9482
10182
  }
10183
+ names.push(k);
9483
10184
  setAttribute(el, k, attrs[k]);
9484
10185
  }
10186
+ state.attrNames = names;
10187
+ } else {
10188
+ state.attrNames = void 0;
9485
10189
  }
9486
- if (text != null) {
9487
- const t = String(text);
9488
- if (el.textContent !== t) el.textContent = t;
10190
+ if (text != null || tag === "title") {
10191
+ const t = text == null ? "" : String(text);
10192
+ if (el.textContent !== t) {
10193
+ if (TRANSITION_JOURNAL !== null) journalRootRange(el, null, null);
10194
+ el.textContent = t;
10195
+ }
9489
10196
  }
9490
10197
  }
9491
10198
  function namespaceHead(props, scope) {
@@ -9518,8 +10225,21 @@ function namespaceHeadElement(headKey, tag, attrs, text, authoredKey) {
9518
10225
  return createElement(namespaceHead, config);
9519
10226
  }
9520
10227
  function injectStyle(id, css, nonce) {
10228
+ if (typeof document === "undefined") {
10229
+ _injectedStyles.add(id);
10230
+ return;
10231
+ }
10232
+ const existing = document.querySelector(`style[data-octane="${id}"]`);
10233
+ if (existing !== null) {
10234
+ if (_injectedStyles.has(id)) {
10235
+ if (existing.textContent !== css) existing.textContent = css;
10236
+ } else {
10237
+ _injectedStyles.add(id);
10238
+ }
10239
+ return;
10240
+ }
9521
10241
  if (_injectedStyles.has(id)) return;
9522
- if (typeof document !== "undefined" && document.querySelector(`style[data-octane="${id}"], style[data-href="octane-${id}"]`)) {
10242
+ if (document.querySelector(`style[data-href~="octane-${id}"]`)) {
9523
10243
  _injectedStyles.add(id);
9524
10244
  return;
9525
10245
  }
@@ -9572,6 +10292,7 @@ function evt0(el, key, fn) {
9572
10292
  return d;
9573
10293
  }
9574
10294
  function evt0u(d, fn) {
10295
+ if (_dispatchDepth !== 0) preserveDispatchedBundle(d);
9575
10296
  if (TRANSITION_JOURNAL !== null) journalObjectOnce(d);
9576
10297
  d.fn = fn;
9577
10298
  }
@@ -9581,6 +10302,7 @@ function evt1(el, key, fn, a0) {
9581
10302
  return d;
9582
10303
  }
9583
10304
  function evt1u(d, fn, a0) {
10305
+ if (_dispatchDepth !== 0) preserveDispatchedBundle(d);
9584
10306
  if (TRANSITION_JOURNAL !== null) {
9585
10307
  journalObjectOnce(d);
9586
10308
  journalObjectOnce(d.args);
@@ -9594,6 +10316,7 @@ function evt2(el, key, fn, a0, a1) {
9594
10316
  return d;
9595
10317
  }
9596
10318
  function evt2u(d, fn, a0, a1) {
10319
+ if (_dispatchDepth !== 0) preserveDispatchedBundle(d);
9597
10320
  if (TRANSITION_JOURNAL !== null) {
9598
10321
  journalObjectOnce(d);
9599
10322
  journalObjectOnce(d.args);
@@ -9609,6 +10332,7 @@ function evtN(el, key, fn, args) {
9609
10332
  return d;
9610
10333
  }
9611
10334
  function evtNu(d, fn, args) {
10335
+ if (_dispatchDepth !== 0) preserveDispatchedBundle(d);
9612
10336
  if (TRANSITION_JOURNAL !== null) journalObjectOnce(d);
9613
10337
  d.fn = fn;
9614
10338
  d.args = args;
@@ -9949,6 +10673,28 @@ const CURRENT_TARGET_DESCRIPTOR = {
9949
10673
  }
9950
10674
  };
9951
10675
  const CAPTURE_PATH = [];
10676
+ const CAPTURE_SLOTS = [];
10677
+ function snapshotDelegatedSlots(base, key, event) {
10678
+ const type = event.type;
10679
+ const suppressDisabled = type === "click" || type === "dblclick" || type === "mousedown" || type === "mousemove" || type === "mouseup" || type === "mouseenter" && key[2] !== "c";
10680
+ for (let index = base; index < CAPTURE_PATH.length; index++) {
10681
+ const node = CAPTURE_PATH[index];
10682
+ const slot = node[key];
10683
+ CAPTURE_SLOTS[index] = slot != null && suppressDisabled && node.disabled && (node.localName === "button" || node.localName === "input" || node.localName === "select" || node.localName === "textarea") ? null : slot;
10684
+ }
10685
+ }
10686
+ function preserveDispatchedBundle(bundle) {
10687
+ let snapshot;
10688
+ for (let index = 0; index < CAPTURE_SLOTS.length; index++) {
10689
+ if (CAPTURE_SLOTS[index] === bundle) {
10690
+ CAPTURE_SLOTS[index] = snapshot ??= {
10691
+ [EVENT_SLOT_KIND]: HANDLER_BUNDLE_KIND,
10692
+ fn: bundle.fn,
10693
+ args: bundle.args.slice()
10694
+ };
10695
+ }
10696
+ }
10697
+ }
9952
10698
  function resolvePortalEventOwner(node) {
9953
10699
  if (node.$$portalParent != null || node.parentNode === null) return;
9954
10700
  const target = node.parentNode;
@@ -10166,13 +10912,7 @@ function dispatchDelegated(event) {
10166
10912
  _dispatchDepth++;
10167
10913
  const node = event.target;
10168
10914
  const prevSubmitRec = ACTIVE_SUBMIT_DISPATCH;
10169
- const submitRec = event.type === "submit" && node != null && node.nodeName === "FORM" ? {
10170
- form: node,
10171
- event,
10172
- transitions: 0,
10173
- published: false,
10174
- intercepted: false
10175
- } : null;
10915
+ const submitRec = event.type === "submit" && node != null && node.nodeName === "FORM" ? snapshotSubmitDispatch(node, event) : null;
10176
10916
  if (submitRec !== null) ACTIVE_SUBMIT_DISPATCH = submitRec;
10177
10917
  const nativeBatch = beginNativeEventBatch(event);
10178
10918
  const pathBase = CAPTURE_PATH.length;
@@ -10182,14 +10922,17 @@ function dispatchDelegated(event) {
10182
10922
  if (delegatedCapture(event.type) && _delegatedCapture.has(event.type) && dispatchDelegatedCapture.call(this, event))
10183
10923
  return;
10184
10924
  if (!_delegated.has(event.type)) return;
10925
+ if (node?.nodeType === 1 && isHtmlCustomElement(node) && (event.type === "invalid" || EMULATED_BUBBLING_EVENTS.includes(event.type)))
10926
+ return;
10185
10927
  buildDelegatedPath(event, this);
10928
+ snapshotDelegatedSlots(pathBase, key, event);
10186
10929
  stop = Object.getOwnPropertyDescriptor(event, "stopPropagation");
10187
10930
  propagationStarted = true;
10188
10931
  beginDelegatedPropagation(event, stop, null);
10189
10932
  for (let i = pathBase; i < CAPTURE_PATH.length; i++) {
10190
10933
  const current = CAPTURE_PATH[i];
10191
10934
  if (targetOnly && current !== event.target) break;
10192
- const slot = current[key];
10935
+ const slot = CAPTURE_SLOTS[i];
10193
10936
  if (slot != null) {
10194
10937
  setCurrentTarget(event, current);
10195
10938
  fireEventSlot(slot, event);
@@ -10197,8 +10940,12 @@ function dispatchDelegated(event) {
10197
10940
  }
10198
10941
  if (targetOnly) break;
10199
10942
  }
10943
+ if (submitRec !== null && FORM_SUBMIT_DRIVER !== null && !event.defaultPrevented && CAPTURE_PATH.includes(submitRec.form, pathBase)) {
10944
+ FORM_SUBMIT_DRIVER(submitRec.form, event, submitRec.action, submitRec.submitter);
10945
+ }
10200
10946
  } finally {
10201
10947
  CAPTURE_PATH.length = pathBase;
10948
+ CAPTURE_SLOTS.length = pathBase;
10202
10949
  if (propagationStarted) endDelegatedPropagation(event, stop, null);
10203
10950
  if (submitRec !== null) {
10204
10951
  ACTIVE_SUBMIT_DISPATCH = prevSubmitRec;
@@ -10221,6 +10968,7 @@ function dispatchDelegatedCapture(event) {
10221
10968
  const key = CAPTURE_PREFIX + event.type;
10222
10969
  const pathBase = CAPTURE_PATH.length;
10223
10970
  buildDelegatedPath(event, this, path);
10971
+ snapshotDelegatedSlots(pathBase, key, event);
10224
10972
  const stop = Object.getOwnPropertyDescriptor(event, "stopPropagation");
10225
10973
  const immediate = delegatedCapture(event.type) ? Object.getOwnPropertyDescriptor(event, "stopImmediatePropagation") : null;
10226
10974
  const wasCancelled = event.cancelBubble;
@@ -10230,7 +10978,7 @@ function dispatchDelegatedCapture(event) {
10230
10978
  try {
10231
10979
  beginDelegatedPropagation(event, stop, immediate);
10232
10980
  for (let i = CAPTURE_PATH.length - 1; i >= pathBase; i--) {
10233
- const slot = CAPTURE_PATH[i][key];
10981
+ const slot = CAPTURE_SLOTS[i];
10234
10982
  if (slot != null) {
10235
10983
  setCurrentTarget(event, CAPTURE_PATH[i]);
10236
10984
  fireEventSlot(slot, event);
@@ -10240,6 +10988,7 @@ function dispatchDelegatedCapture(event) {
10240
10988
  } finally {
10241
10989
  stopped = event[PROPAGATION_FLAGS] !== 0 || !wasCancelled && event.cancelBubble;
10242
10990
  CAPTURE_PATH.length = pathBase;
10991
+ CAPTURE_SLOTS.length = pathBase;
10243
10992
  endDelegatedPropagation(event, stop, immediate);
10244
10993
  clearCurrentTarget(event);
10245
10994
  try {
@@ -10267,7 +11016,7 @@ function clearCurrentTarget(event) {
10267
11016
  delete event.currentTarget;
10268
11017
  delete event[CURRENT_TARGET_NODE];
10269
11018
  }
10270
- const IDLE_FORM_STATUS = { pending: false, data: null, method: "get", action: null };
11019
+ const IDLE_FORM_STATUS = { pending: false, data: null, method: null, action: null };
10271
11020
  const FORM_STATUS = /* @__PURE__ */ new WeakMap();
10272
11021
  const FORM_STATUS_LISTENERS = /* @__PURE__ */ new WeakMap();
10273
11022
  function setFormStatus(form, status) {
@@ -10275,7 +11024,28 @@ function setFormStatus(form, status) {
10275
11024
  const ls = FORM_STATUS_LISTENERS.get(form);
10276
11025
  if (ls) for (const l of ls) l();
10277
11026
  }
11027
+ function snapshotSubmitDispatch(form, event) {
11028
+ let submitter = event.submitter;
11029
+ let action = form.$$formAction;
11030
+ if (submitter !== null && submitter !== void 0) {
11031
+ const override = submitter.$$formAction ?? submitter.getAttribute("formaction");
11032
+ if (override != null) {
11033
+ action = override;
11034
+ submitter = null;
11035
+ }
11036
+ }
11037
+ return {
11038
+ form,
11039
+ event,
11040
+ action,
11041
+ submitter: submitter ?? null,
11042
+ transitions: 0,
11043
+ published: false,
11044
+ intercepted: false
11045
+ };
11046
+ }
10278
11047
  let ACTIVE_SUBMIT_DISPATCH = null;
11048
+ let FORM_SUBMIT_DRIVER = null;
10279
11049
  function publishManualFormPending(rec) {
10280
11050
  if (rec.intercepted || rec.transitions === 0 || !rec.event.defaultPrevented) return;
10281
11051
  const form = rec.form;
@@ -10331,30 +11101,22 @@ function flushFormResets() {
10331
11101
  PENDING_FORM_RESETS = null;
10332
11102
  for (const f of forms) resetFormNow(f);
10333
11103
  }
10334
- function setFormAction(el, name, value, prev) {
11104
+ function setFormAction(el, name, value, _prev) {
10335
11105
  if (typeof value === "function") {
10336
11106
  el.$$formAction = value;
10337
11107
  if (process.env.NODE_ENV !== "production") queueFormActionAuthoringDiagnostic(el);
10338
- if (el.nodeName === "FORM") {
10339
- if (!el.$$formSubmitWired) {
10340
- el.$$formSubmitWired = true;
10341
- el.$$submit = (event) => handleFormSubmit(el, event);
10342
- delegateEvents(["submit"]);
10343
- }
11108
+ if (!el.$$formSubmitWired) {
11109
+ el.$$formSubmitWired = true;
11110
+ FORM_SUBMIT_DRIVER = handleFormSubmit;
11111
+ delegateEvents(["submit"]);
10344
11112
  }
10345
11113
  el.removeAttribute(name);
10346
11114
  return;
10347
11115
  }
10348
11116
  el.$$formAction = void 0;
10349
- if (typeof prev === "function" && el.nodeName === "FORM") {
10350
- el.$$submit = void 0;
10351
- el.$$formSubmitWired = false;
10352
- }
10353
11117
  setAttribute(el, name, value);
10354
11118
  }
10355
- function handleFormSubmit(form, event) {
10356
- const submitter = event.submitter;
10357
- const action = submitter && submitter.$$formAction || form.$$formAction;
11119
+ function handleFormSubmit(form, event, action, submitter) {
10358
11120
  if (typeof action !== "function") return;
10359
11121
  event.preventDefault();
10360
11122
  if (ACTIVE_SUBMIT_DISPATCH !== null && ACTIVE_SUBMIT_DISPATCH.form === form)
@@ -10505,13 +11267,12 @@ function armControlledBase(el) {
10505
11267
  sv: null,
10506
11268
  sawV: false,
10507
11269
  sawC: false,
11270
+ sawDC: false,
10508
11271
  dvv: UNCONTROLLED,
10509
11272
  composing: false,
10510
11273
  compositionEndTask: void 0,
10511
11274
  queued: false,
10512
11275
  formSeen: false,
10513
- formDefaultValue: UNCONTROLLED,
10514
- formDefaultChecked: UNCONTROLLED,
10515
11276
  formMultiple: false
10516
11277
  };
10517
11278
  el.$$ctrl = ctrl;
@@ -10530,7 +11291,7 @@ function armControlled(el) {
10530
11291
  return ctrl;
10531
11292
  }
10532
11293
  function toControlledString(v) {
10533
- return typeof v === "string" ? v : String(v);
11294
+ return typeof v === "string" ? v : typeof v === "function" || typeof v === "symbol" ? "" : String(v);
10534
11295
  }
10535
11296
  function valueNeedsWrite(el, raw) {
10536
11297
  if (el.type === "number") {
@@ -10686,9 +11447,14 @@ function setCheckedState(input, value, ctrl) {
10686
11447
  if (process.env.NODE_ENV !== "production")
10687
11448
  queueDevFormDiagnostic(input, CURRENT_SCOPE ?? void 0);
10688
11449
  const hydration = activeHydration();
10689
- if (hydration !== null && !hydration.isFresh(input)) return;
10690
- if (input.checked !== b) input.checked = b;
11450
+ if (hydration !== null && !hydration.isFresh(input)) {
11451
+ input.checked = input.checked;
11452
+ ctrl.sawDC = true;
11453
+ return;
11454
+ }
11455
+ input.checked = b;
10691
11456
  input.defaultChecked = b;
11457
+ ctrl.sawDC = true;
10692
11458
  return;
10693
11459
  }
10694
11460
  if (process.env.NODE_ENV !== "production" && ctrl.c === -1) devWarnControlledFlip(input, true);
@@ -10702,7 +11468,7 @@ function inActivationWindow(input) {
10702
11468
  const target = activationCheckable;
10703
11469
  if (target === null) return false;
10704
11470
  if (input === target) return true;
10705
- return input.type === "radio" && target.type === "radio" && input.name !== "" && input.name === target.name && input.form === target.form;
11471
+ return input.type === "radio" && target.type === "radio" && input.name !== "" && input.name === target.name && input.form === target.form && (input.form !== null || input.getRootNode() === target.getRootNode());
10706
11472
  }
10707
11473
  function setChecked(el, value) {
10708
11474
  const ctrl = armControlled(el);
@@ -10791,45 +11557,108 @@ function projectSelectValue(sel, sv, setDefaultSelected) {
10791
11557
  }
10792
11558
  if (defaultOption !== null) defaultOption.selected = true;
10793
11559
  }
10794
- function setDefaultValue(el, value) {
11560
+ function setDefaultValue(el, value, initial) {
10795
11561
  const ctrl = armControlled(el);
10796
11562
  const hydration = activeHydration();
10797
- if (hydration !== null && !hydration.isFresh(el) || value == null) return;
10798
11563
  if (el.localName === "select") {
10799
- if (!Object.is(ctrl.dvv, value)) {
11564
+ const first2 = ctrl.dvv === UNCONTROLLED;
11565
+ const multiple = el.multiple;
11566
+ const changedMultiple = ctrl.formMultiple !== multiple;
11567
+ if (first2 || changedMultiple) {
10800
11568
  if (TRANSITION_JOURNAL !== null) {
10801
11569
  journalObjectOnce(ctrl);
10802
11570
  journalBag();
10803
11571
  }
10804
11572
  ctrl.dvv = value;
10805
- queueControlledCommit(SELECT_DEFAULT_SYNCS, { el, value });
11573
+ ctrl.formMultiple = multiple;
11574
+ if (hydration !== null && !hydration.isFresh(el)) return;
11575
+ if (value != null)
11576
+ queueControlledCommit(SELECT_DEFAULT_SYNCS, { el, value });
11577
+ else if (changedMultiple)
11578
+ projectSelectValue(el, multiple ? /* @__PURE__ */ new Set() : "", false);
10806
11579
  }
10807
11580
  return;
10808
11581
  }
11582
+ const first = initial ?? !ctrl.sawV;
11583
+ const previousDefault = ctrl.dvv;
11584
+ if (TRANSITION_JOURNAL !== null) journalObjectOnce(ctrl);
11585
+ ctrl.sawV = true;
11586
+ ctrl.dvv = value;
11587
+ const hydrating = hydration !== null && !hydration.isFresh(el);
10809
11588
  if (ctrl.v !== UNCONTROLLED) return;
10810
11589
  const input = el;
11590
+ if (value == null) {
11591
+ if (previousDefault !== UNCONTROLLED && previousDefault != null) {
11592
+ if (TRANSITION_JOURNAL !== null) journalDefaultValue(input);
11593
+ if (el.localName === "input") input.removeAttribute("value");
11594
+ else input.defaultValue = "";
11595
+ }
11596
+ return;
11597
+ }
10811
11598
  const s = toControlledString(value);
10812
- if (input.defaultValue !== s) {
11599
+ if (first && !hydrating && input.value !== s) {
11600
+ if (TRANSITION_JOURNAL !== null) journalControlled(el, "value", "defaultValue");
11601
+ input.value = s;
11602
+ }
11603
+ if (input.defaultValue !== s || s === "" && el.localName === "input" && !input.hasAttribute("value")) {
10813
11604
  if (TRANSITION_JOURNAL !== null) journalDefaultValue(input);
10814
11605
  input.defaultValue = s;
10815
11606
  }
10816
11607
  }
11608
+ const DEFAULT_VALUE_BASELINE = /* @__PURE__ */ Symbol("octane.defaultValue");
11609
+ const DEFAULT_CHECKED_INITIALIZED = /* @__PURE__ */ Symbol("octane.defaultCheckedInitialized");
10817
11610
  function setDefaultValueUncontrolled(el, value) {
10818
11611
  const hydration = activeHydration();
10819
- if (hydration !== null && !hydration.isFresh(el) || value == null) return;
10820
11612
  const input = el;
10821
- const s = toControlledString(value);
10822
- if (input.defaultValue !== s) {
11613
+ const previous = input[DEFAULT_VALUE_BASELINE];
11614
+ const s = value == null ? null : toControlledString(value);
11615
+ if (TRANSITION_JOURNAL !== null)
11616
+ TRANSITION_JOURNAL.push(JOURNAL_PROP, input, DEFAULT_VALUE_BASELINE, previous);
11617
+ input[DEFAULT_VALUE_BASELINE] = s;
11618
+ const hydrating = hydration !== null && !hydration.isFresh(el);
11619
+ if (s === null) {
11620
+ if (previous != null) {
11621
+ if (TRANSITION_JOURNAL !== null) journalDefaultValue(input);
11622
+ if (el.localName === "input") input.removeAttribute("value");
11623
+ else input.defaultValue = "";
11624
+ }
11625
+ return;
11626
+ }
11627
+ if (previous === void 0 && !hydrating && input.value !== s) {
11628
+ if (TRANSITION_JOURNAL !== null) journalControlled(el, "value", "defaultValue");
11629
+ input.value = s;
11630
+ }
11631
+ if (input.defaultValue !== s || s === "" && el.localName === "input" && !input.hasAttribute("value")) {
10823
11632
  if (TRANSITION_JOURNAL !== null) journalDefaultValue(input);
10824
11633
  input.defaultValue = s;
10825
11634
  }
10826
11635
  }
10827
11636
  function setDefaultChecked(el, value) {
10828
11637
  const ctrl = armControlled(el);
11638
+ const input = el;
10829
11639
  const hydration = activeHydration();
10830
- if (hydration !== null && !hydration.isFresh(el) || value == null) return;
11640
+ const hydrating = hydration !== null && !hydration.isFresh(el);
11641
+ const first = !ctrl.sawDC;
11642
+ if (first) {
11643
+ if (TRANSITION_JOURNAL !== null) {
11644
+ journalObjectOnce(ctrl);
11645
+ journalBag();
11646
+ }
11647
+ ctrl.sawDC = true;
11648
+ }
11649
+ if (hydrating) {
11650
+ if (first) input.checked = input.checked;
11651
+ return;
11652
+ }
10831
11653
  if (ctrl.c !== -1) return;
10832
- const input = el;
11654
+ if (first && !(DEFAULT_CHECKED_INITIALIZED in input)) {
11655
+ if (TRANSITION_JOURNAL !== null) {
11656
+ TRANSITION_JOURNAL.push(JOURNAL_PROP, input, "checked", input.checked);
11657
+ if (input.type === "radio" && input.name !== "" && !!value) journalRadioCousins(input);
11658
+ }
11659
+ input.checked = value == null ? input.checked : !!value;
11660
+ }
11661
+ if (value == null) return;
10833
11662
  const b = !!value;
10834
11663
  if (input.defaultChecked !== b) {
10835
11664
  if (TRANSITION_JOURNAL !== null) {
@@ -10888,16 +11717,12 @@ function setFormControlSources(el, sources) {
10888
11717
  }
10889
11718
  const ctrl = armControlled(el);
10890
11719
  const first = !ctrl.formSeen;
10891
- const previousDefaultValue = ctrl.formDefaultValue;
10892
- const previousDefaultChecked = ctrl.formDefaultChecked;
10893
11720
  const previousMultiple = ctrl.formMultiple;
10894
11721
  if (TRANSITION_JOURNAL !== null) {
10895
11722
  journalObjectOnce(ctrl);
10896
11723
  journalBag();
10897
11724
  }
10898
11725
  ctrl.formSeen = true;
10899
- ctrl.formDefaultValue = defaultValue;
10900
- ctrl.formDefaultChecked = defaultChecked;
10901
11726
  if (process.env.NODE_ENV !== "production" && hasDevFormDiagnosticContext(el, CURRENT_SCOPE ?? void 0)) {
10902
11727
  const diagnostic = ensureDevFormDiagnosticState(el);
10903
11728
  diagnostic.authoringProps = { value, defaultValue, checked, defaultChecked, multiple };
@@ -10910,22 +11735,18 @@ function setFormControlSources(el, sources) {
10910
11735
  const defaultString = defaultValue == null ? null : toControlledString(defaultValue);
10911
11736
  setValue(input, value);
10912
11737
  if (value == null) {
10913
- if (defaultString !== null) setDefaultValue(input, defaultString);
10914
- else if (!first && previousDefaultValue !== UNCONTROLLED && previousDefaultValue != null)
10915
- input.removeAttribute("value");
11738
+ setDefaultValue(input, defaultString, first);
10916
11739
  }
10917
11740
  setChecked(input, checked);
10918
- if (checked == null && defaultChecked != null) setDefaultChecked(input, defaultChecked);
10919
- if (!first && defaultChecked == null && previousDefaultChecked !== UNCONTROLLED && previousDefaultChecked != null) {
10920
- input.defaultChecked = false;
10921
- }
11741
+ if (checked == null && (defaultChecked != null || first))
11742
+ setDefaultChecked(input, defaultChecked);
10922
11743
  return;
10923
11744
  }
10924
11745
  if (tag === "textarea") {
10925
11746
  const textarea = el;
10926
11747
  setValue(textarea, value);
10927
11748
  if (value == null) {
10928
- if (defaultValue != null) setDefaultValue(textarea, defaultValue);
11749
+ if (defaultValue != null) setDefaultValue(textarea, defaultValue, first);
10929
11750
  else if (!first && textarea.defaultValue !== "") textarea.defaultValue = "";
10930
11751
  }
10931
11752
  return;
@@ -10948,7 +11769,7 @@ function setFormControlSources(el, sources) {
10948
11769
  }
10949
11770
  setSelectValue(select, value);
10950
11771
  if (defaultValue != null) setDefaultValue(select, defaultValue);
10951
- else ctrl.dvv = UNCONTROLLED;
11772
+ else if (first) ctrl.dvv = void 0;
10952
11773
  }
10953
11774
  function nativeTextChangeMessage(el, hasBubbleChange, controlled) {
10954
11775
  const changeProp = hasBubbleChange ? "onChange" : "onChangeCapture";
@@ -11111,10 +11932,10 @@ function restoreCheckedState(input, ctrl) {
11111
11932
  }
11112
11933
  function restoreRadioCousins(input) {
11113
11934
  const name = input.name;
11114
- const group = input.form !== null ? input.form.elements : typeof document !== "undefined" ? document.getElementsByName(name) : [];
11935
+ const group = radioCousins(input);
11115
11936
  for (let i = 0; i < group.length; i++) {
11116
11937
  const other = group[i];
11117
- if (other === input || other.localName !== "input" || other.type !== "radio" || other.name !== name) {
11938
+ if (other === input || other.localName !== "input" || other.type !== "radio" || other.name !== name || other.form !== input.form) {
11118
11939
  continue;
11119
11940
  }
11120
11941
  const octrl = other.$$ctrl;
@@ -11232,7 +12053,9 @@ function unregisterPortalEventRange(target, portal2) {
11232
12053
  }
11233
12054
  }
11234
12055
  function portal(parentScope, slotKey, target, body, props, host, env, fragmentOwners, fragmentAnchor) {
12056
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
11235
12057
  const prev = parentScope.slots[slotKey];
12058
+ const key = portalKey(props);
11236
12059
  if (fragmentAnchor !== void 0 && fragmentOwners === void 0 && prev !== void 0 && prev.target === target) {
11237
12060
  prepareFragmentPortalInterleaving(prev);
11238
12061
  }
@@ -11241,12 +12064,13 @@ function portal(parentScope, slotKey, target, body, props, host, env, fragmentOw
11241
12064
  parentScope.block,
11242
12065
  target,
11243
12066
  body,
11244
- props,
12067
+ key === null ? props : void 0,
11245
12068
  // `host` (passed by the compiler) is the JSX element that contains the
11246
12069
  // createPortal call — the natural "logical parent" for event bubbling. When
11247
12070
  // the portal is at top level the compiler passes the block's parentNode.
11248
12071
  host || parentScope.block.parentNode,
11249
- env
12072
+ env,
12073
+ key
11250
12074
  );
11251
12075
  if (prev !== state) {
11252
12076
  journalRootProperty(parentScope.slots, String(slotKey));
@@ -11407,16 +12231,16 @@ function registerValuePortalFragmentOwners(portal2, parentBlock, anchor) {
11407
12231
  registerFragmentPortalOwners(portal2, nestedOwners ?? firstOwner, anchor);
11408
12232
  }
11409
12233
  }
11410
- function renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, env) {
12234
+ function renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, env, key = null) {
11411
12235
  const hydration = activeHydration();
11412
12236
  if (hydration !== null) {
11413
12237
  return hydration.suspend(
11414
- () => renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, env)
12238
+ () => renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, env, key)
11415
12239
  );
11416
12240
  }
11417
12241
  const norm = normalizePortalBody(rawBody, rawProps);
11418
12242
  let state = prev;
11419
- if (state === null || state.target !== target) {
12243
+ if (state === null || state.target !== target || state.key !== key) {
11420
12244
  if (state !== null) teardownPortalState(state);
11421
12245
  const start = document.createComment("portal");
11422
12246
  const end = document.createComment("/portal");
@@ -11437,7 +12261,7 @@ function renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, e
11437
12261
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
11438
12262
  __profileTrackComponent(block, profilePortalComponent(rawBody));
11439
12263
  }
11440
- state = { __kind: "portalSlotSlot", block, target, host, start, end };
12264
+ state = { __kind: "portalSlotSlot", block, target, key, host, start, end };
11441
12265
  registerPortalEventRange(target, state);
11442
12266
  activityPortalCreated?.(block);
11443
12267
  registerDelegationTarget(target);
@@ -11519,9 +12343,13 @@ function genericPortalBody(value, scope) {
11519
12343
  childSlot(scope, 0, scope.parentNode, value, scope.endMarker);
11520
12344
  }
11521
12345
  const PORTAL_TAG = /* @__PURE__ */ Symbol.for("octane.portal");
12346
+ function portalKey(value) {
12347
+ return typeof value === "string" || typeof value === "number" ? String(value) : null;
12348
+ }
11522
12349
  // @__NO_SIDE_EFFECTS__
11523
12350
  function createPortal(body, target, props = void 0) {
11524
- return { $$kind: PORTAL_TAG, body, target, props };
12351
+ const key = portalKey(props);
12352
+ return { $$kind: PORTAL_TAG, body, target, key, props: key === null ? props : void 0 };
11525
12353
  }
11526
12354
  const ELEMENT_TAG = /* @__PURE__ */ Symbol.for("octane.element");
11527
12355
  const KEYED_ELEMENT_DESCRIPTORS = /* @__PURE__ */ new WeakSet();
@@ -11940,6 +12768,7 @@ function componentSlotVoid(parentScope, slotKey, domParent, comp, props, anchor,
11940
12768
  );
11941
12769
  }
11942
12770
  function componentSlotImpl(outputHandler, parentScope, slotKey, domParent, body, identity, props, renderProps, anchor, key, singleRoot, inherit, hasKey) {
12771
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
11943
12772
  const parentBlock = parentScope.block;
11944
12773
  const hydration = activeHydration();
11945
12774
  if (hydration !== null && (anchor != null && hydration.isFresh(anchor) || hydration.isFresh(domParent))) {
@@ -12049,8 +12878,8 @@ function componentSlotImpl(outputHandler, parentScope, slotKey, domParent, body,
12049
12878
  parentScope.slots[slotKey] = state;
12050
12879
  registerSlot(parentScope, state);
12051
12880
  }
12052
- const nextKey = key === void 0 ? NO_KEY : key;
12053
- const keyChanged = key !== void 0 && state.prevKey !== NO_KEY && !Object.is(key, state.prevKey);
12881
+ const nextKey = key === void 0 ? NO_KEY : "" + key;
12882
+ const keyChanged = key !== void 0 && state.prevKey !== NO_KEY && nextKey !== state.prevKey;
12054
12883
  const replacing = identity !== state.currentComp || keyChanged;
12055
12884
  const journaledSlot = ROOT_RENDER_TRANSACTION !== null && state.block !== null && replacing;
12056
12885
  if (journaledSlot) {
@@ -12505,25 +13334,28 @@ function clearReplacedChildBlock(state, oldBlock) {
12505
13334
  }
12506
13335
  const DEOPT_KEY_WARNED_BLOCKS = /* @__PURE__ */ new WeakSet();
12507
13336
  let DEOPT_KEY_WARNED_WITHOUT_BLOCK = false;
13337
+ function warnMissingListKey(owner) {
13338
+ const warned = owner === null ? DEOPT_KEY_WARNED_WITHOUT_BLOCK : DEOPT_KEY_WARNED_BLOCKS.has(owner);
13339
+ if (!warned) {
13340
+ if (owner === null) DEOPT_KEY_WARNED_WITHOUT_BLOCK = true;
13341
+ else DEOPT_KEY_WARNED_BLOCKS.add(owner);
13342
+ console.warn(
13343
+ 'Octane: each element in an array child should have a unique "key" prop (e.g. `items.map((x) => <li key={x.id}>\u2026</li>)`). Missing keys can reconcile incorrectly on reorder \u2014 for keyed lists prefer `@for (...; key ...)`.'
13344
+ );
13345
+ }
13346
+ }
12508
13347
  function deoptKey(item, index) {
12509
13348
  const element = item != null && item.$$kind === ELEMENT_TAG;
13349
+ if (item?.$$kind === PORTAL_TAG && item.key != null) return item.key;
12510
13350
  if (element && item.key != null && !ELEMENTS_MISSING_LIST_KEY.has(item)) return item.key;
12511
13351
  if (element && process.env.NODE_ENV !== "production" && activeHydration() === null) {
12512
- const owner = CURRENT_BLOCK;
12513
- const warned = owner === null ? DEOPT_KEY_WARNED_WITHOUT_BLOCK : DEOPT_KEY_WARNED_BLOCKS.has(owner);
12514
- if (!warned) {
12515
- if (owner === null) DEOPT_KEY_WARNED_WITHOUT_BLOCK = true;
12516
- else DEOPT_KEY_WARNED_BLOCKS.add(owner);
12517
- console.warn(
12518
- 'Octane: each element in an array child should have a unique "key" prop (e.g. `items.map((x) => <li key={x.id}>\u2026</li>)`). Missing keys can reconcile incorrectly on reorder \u2014 for keyed lists prefer `@for (...; key ...)`.'
12519
- );
12520
- }
13352
+ warnMissingListKey(CURRENT_BLOCK);
12521
13353
  }
12522
13354
  return element && item.key != null ? item.key : index;
12523
13355
  }
12524
13356
  const POSITIONAL_CHILDREN = /* @__PURE__ */ new WeakSet();
12525
13357
  function deoptKeyPositional(item, index) {
12526
- return item != null && item.$$kind === ELEMENT_TAG && item.key != null ? item.key : index;
13358
+ return item != null && (item.$$kind === ELEMENT_TAG || item.$$kind === PORTAL_TAG) && item.key != null ? item.key : index;
12527
13359
  }
12528
13360
  function positionalChildren(children) {
12529
13361
  POSITIONAL_CHILDREN.add(children);
@@ -12539,6 +13371,11 @@ function noteDeoptRef(block) {
12539
13371
  }
12540
13372
  }
12541
13373
  function applyDeoptProp(el, name, v, ownerBlock) {
13374
+ const actionName = formActionAttributeName(el, name);
13375
+ if (actionName !== null) {
13376
+ setFormAction(el, actionName, v, void 0);
13377
+ return;
13378
+ }
12542
13379
  if (name === "ref") {
12543
13380
  if (v != null) {
12544
13381
  noteDeoptRef(ownerBlock);
@@ -12549,7 +13386,7 @@ function applyDeoptProp(el, name, v, ownerBlock) {
12549
13386
  } else if (name === "style") {
12550
13387
  setStyle(el, v, void 0);
12551
13388
  } else {
12552
- const ev = eventSlot(name);
13389
+ const ev = eventSlot(name, el);
12553
13390
  if (ev !== null) {
12554
13391
  setEventHandler(
12555
13392
  el,
@@ -12571,19 +13408,32 @@ function hasDangerHTML(props) {
12571
13408
  }
12572
13409
  return true;
12573
13410
  }
13411
+ function hasHostPropContent(descriptor) {
13412
+ return hasDangerHTML(descriptor.props) || descriptor.type === "textarea" && (descriptor.props?.value != null || descriptor.props?.defaultValue != null);
13413
+ }
13414
+ function markInputCheckedness(input) {
13415
+ input.checked = input.checked;
13416
+ input[DEFAULT_CHECKED_INITIALIZED] = true;
13417
+ }
12574
13418
  function applyDeoptProps(el, props, ownerBlock) {
12575
13419
  if (props == null) {
13420
+ if (el.localName === "input") markInputCheckedness(el);
12576
13421
  if (process.env.NODE_ENV !== "production") queueDevFormDiagnostic(el, ownerBlock);
12577
13422
  return;
12578
13423
  }
13424
+ let needsCheckedInitialization = el.localName === "input";
12579
13425
  for (const name in props) {
12580
13426
  if (name === "key" || name === "children") continue;
12581
13427
  if (name === "suppressHydrationWarning") {
12582
- el.__oct_suppress = props[name] !== false;
13428
+ el.__oct_suppress = props[name] === true;
12583
13429
  continue;
12584
13430
  }
12585
- applyDeoptProp(el, name, props[name], ownerBlock);
13431
+ const value = props[name];
13432
+ if (needsCheckedInitialization && (name === "defaultChecked" || name === "checked" && value != null))
13433
+ needsCheckedInitialization = false;
13434
+ applyDeoptProp(el, name, value, ownerBlock);
12586
13435
  }
13436
+ if (needsCheckedInitialization) markInputCheckedness(el);
12587
13437
  if (process.env.NODE_ENV !== "production") queueDevFormDiagnostic(el, ownerBlock);
12588
13438
  }
12589
13439
  function patchDeoptProps(el, prevProps, nextProps, ownerBlock) {
@@ -12600,7 +13450,7 @@ function patchDeoptProps(el, prevProps, nextProps, ownerBlock) {
12600
13450
  for (const name in nextProps) {
12601
13451
  if (name === "key" || name === "children") continue;
12602
13452
  if (name === "suppressHydrationWarning") {
12603
- el.__oct_suppress = nextProps[name] !== false;
13453
+ el.__oct_suppress = nextProps[name] === true;
12604
13454
  continue;
12605
13455
  }
12606
13456
  const nv = nextProps[name];
@@ -12644,6 +13494,7 @@ function hostComponent(scope, slot, tag, props, childrenBody, anchor) {
12644
13494
  }
12645
13495
  function applyHostProps(el, props, scope, state) {
12646
13496
  const prev = state.props;
13497
+ let needsCheckedInitialization = prev === void 0 && el.localName === "input";
12647
13498
  if (ROOT_RENDER_TRANSACTION !== null && prev !== props) journalObjectOnce(state);
12648
13499
  if (prev != null) {
12649
13500
  for (const k in prev) {
@@ -12661,14 +13512,22 @@ function applyHostProps(el, props, scope, state) {
12661
13512
  }
12662
13513
  state.props = props;
12663
13514
  if (props == null) {
13515
+ if (needsCheckedInitialization) markInputCheckedness(el);
12664
13516
  if (process.env.NODE_ENV !== "production") queueDevFormDiagnostic(el, scope);
12665
13517
  return;
12666
13518
  }
12667
13519
  for (const name in props) {
12668
13520
  if (name === "key" || name === "children") continue;
12669
13521
  const v = props[name];
13522
+ if (needsCheckedInitialization && (name === "defaultChecked" || name === "checked" && v != null))
13523
+ needsCheckedInitialization = false;
13524
+ const actionName = formActionAttributeName(el, name);
13525
+ if (actionName !== null) {
13526
+ setFormAction(el, actionName, v, prev?.[name]);
13527
+ continue;
13528
+ }
12670
13529
  if (name === "suppressHydrationWarning") {
12671
- el.__oct_suppress = v !== false;
13530
+ el.__oct_suppress = v === true;
12672
13531
  continue;
12673
13532
  }
12674
13533
  if (name === "ref") {
@@ -12682,7 +13541,7 @@ function applyHostProps(el, props, scope, state) {
12682
13541
  } else if (name === "style") {
12683
13542
  setStyle(el, v, prev != null ? prev.style : void 0);
12684
13543
  } else {
12685
- const ev = eventSlot(name);
13544
+ const ev = eventSlot(name, el);
12686
13545
  if (ev) {
12687
13546
  if (ev.capture) {
12688
13547
  if (!_delegatedCapture.has(ev.type)) delegateCaptureEvents([ev.type]);
@@ -12699,6 +13558,7 @@ function applyHostProps(el, props, scope, state) {
12699
13558
  }
12700
13559
  }
12701
13560
  }
13561
+ if (needsCheckedInitialization) markInputCheckedness(el);
12702
13562
  if (process.env.NODE_ENV !== "production") queueDevFormDiagnostic(el, scope);
12703
13563
  }
12704
13564
  const DEOPT_DESC = /* @__PURE__ */ Symbol("octane.deoptDesc");
@@ -12789,7 +13649,7 @@ function deoptWrapperKind(value) {
12789
13649
  return POSITIONAL_CHILDREN.has(value) ? "fragment" : "array";
12790
13650
  }
12791
13651
  function scopedDeoptKey(path, item, index, key) {
12792
- const explicit = isElementDescriptor(item) && item.key != null;
13652
+ const explicit = (isElementDescriptor(item) || item?.$$kind === PORTAL_TAG) && item.key != null;
12793
13653
  if (path.length === 0) return explicit ? "k" + String(key) : "i" + index;
12794
13654
  return JSON.stringify([path, explicit ? "key" : "index", explicit ? String(key) : index]);
12795
13655
  }
@@ -12902,6 +13762,10 @@ function reconcileDeoptNode(prev, value, ownerBlock, ns) {
12902
13762
  if (t === "string" || t === "number" || t === "bigint") {
12903
13763
  const s = String(value);
12904
13764
  if (prev !== null && prev.nodeType === 3) {
13765
+ const hydration = activeHydration();
13766
+ if (hydration !== null && !hydration.isFresh(prev.parentNode)) {
13767
+ return hydration.htextSwap(prev, s);
13768
+ }
12905
13769
  updateTextValue(prev, s);
12906
13770
  return prev;
12907
13771
  }
@@ -12919,7 +13783,7 @@ function reconcileDeoptNode(prev, value, ownerBlock, ns) {
12919
13783
  applyDeoptProps(el, value.props, ownerBlock);
12920
13784
  }
12921
13785
  setDeoptDesc(el, value);
12922
- if (!hasDangerHTML(value.props)) {
13786
+ if (!hasHostPropContent(value)) {
12923
13787
  reconcileDeoptChildren(el, value.children, ownerBlock);
12924
13788
  }
12925
13789
  return el;
@@ -12935,7 +13799,12 @@ function reconcileDeoptChildren(el, children, ownerBlock) {
12935
13799
  if (type === "string" && children !== "" || type === "number" || type === "bigint") {
12936
13800
  const first = getFirstChild(el);
12937
13801
  if (first !== null && first.nodeType === 3 && getNextSibling(first) === null && first.$$deoptKey === 0 && first.$$portalEnd == null) {
12938
- updateTextValue(first, String(children));
13802
+ const hydration = activeHydration();
13803
+ if (hydration !== null && !hydration.isFresh(el)) {
13804
+ hydration.htextSwap(first, String(children));
13805
+ } else {
13806
+ updateTextValue(first, String(children));
13807
+ }
12939
13808
  return;
12940
13809
  }
12941
13810
  }
@@ -13013,6 +13882,10 @@ function reconcileDeoptChildren(el, children, ownerBlock) {
13013
13882
  for (let i = owned.length - 1; i >= 0; i--) {
13014
13883
  const n = owned[i];
13015
13884
  if (keep === null || !keep.has(n)) {
13885
+ const hydration = activeHydration();
13886
+ if (hydration !== null && !hydration.isFresh(el)) {
13887
+ noteRecoverableHydrationError(() => new Error(formatClientError(62)), ownerBlock);
13888
+ }
13016
13889
  if (journal) {
13017
13890
  journalRootChildren(el);
13018
13891
  deferRootRange(el, n, n, () => detachDeoptTreeRefs(n, null));
@@ -13243,6 +14116,7 @@ function mappedDeoptItemBody(item, scope) {
13243
14116
  function descNeedsBlocks(value) {
13244
14117
  if (typeof value === "function") return true;
13245
14118
  if (value == null || typeof value !== "object") return false;
14119
+ if (typeof value.then === "function") return true;
13246
14120
  if (Array.isArray(value)) {
13247
14121
  for (let i = 0; i < value.length; i++) {
13248
14122
  if (descNeedsBlocks(value[i])) return true;
@@ -13268,7 +14142,7 @@ function hostElementBody(d, block) {
13268
14142
  applyDeoptProps(el, d.props, block);
13269
14143
  setDeoptDesc(el, d);
13270
14144
  const savedCursor = hydration.node.nextSibling;
13271
- if (!hasDangerHTML(d.props)) {
14145
+ if (!hasHostPropContent(d)) {
13272
14146
  hydration.node = el.firstChild;
13273
14147
  childSlot(block, 0, el, d.children, null, false, el);
13274
14148
  }
@@ -13296,7 +14170,7 @@ function hostElementBody(d, block) {
13296
14170
  block.parentNode.insertBefore(el, block.endMarker);
13297
14171
  applyDeoptProps(el, d.props, block);
13298
14172
  setDeoptDesc(el, d);
13299
- if (!hasDangerHTML(d.props)) {
14173
+ if (!hasHostPropContent(d)) {
13300
14174
  hydration.suspend(() => childSlot(block, 0, el, d.children, null, false, el));
13301
14175
  }
13302
14176
  return;
@@ -13332,7 +14206,7 @@ function hostElementBody(d, block) {
13332
14206
  patchDeoptProps(el, getDeoptDesc(el)?.props ?? null, d.props, block);
13333
14207
  }
13334
14208
  setDeoptDesc(el, d);
13335
- if (!hasDangerHTML(d.props)) childSlot(block, 0, el, d.children, null, false, el);
14209
+ if (!hasHostPropContent(d)) childSlot(block, 0, el, d.children, null, false, el);
13336
14210
  }
13337
14211
  function hostStringTagBody(d, block) {
13338
14212
  const tag = d.type;
@@ -13346,7 +14220,7 @@ function hostStringTagBody(d, block) {
13346
14220
  applyDeoptProps(el, d.props, block);
13347
14221
  setDeoptDesc(el, d);
13348
14222
  const savedCursor = hydration.node.nextSibling;
13349
- if (!hasDangerHTML(d.props)) {
14223
+ if (!hasHostPropContent(d)) {
13350
14224
  hydration.node = el.firstChild;
13351
14225
  renderHostTagChildren(d, block, el);
13352
14226
  }
@@ -13374,7 +14248,7 @@ function hostStringTagBody(d, block) {
13374
14248
  block.parentNode.insertBefore(el, block.endMarker);
13375
14249
  applyDeoptProps(el, d.props, block);
13376
14250
  setDeoptDesc(el, d);
13377
- if (!hasDangerHTML(d.props)) {
14251
+ if (!hasHostPropContent(d)) {
13378
14252
  hydration.suspend(() => renderHostTagChildren(d, block, el));
13379
14253
  }
13380
14254
  return;
@@ -13388,7 +14262,7 @@ function hostStringTagBody(d, block) {
13388
14262
  patchDeoptProps(el, getDeoptDesc(el)?.props ?? null, d.props, block);
13389
14263
  }
13390
14264
  setDeoptDesc(el, d);
13391
- if (!hasDangerHTML(d.props)) renderHostTagChildren(d, block, el);
14265
+ if (!hasHostPropContent(d)) renderHostTagChildren(d, block, el);
13392
14266
  }
13393
14267
  function renderHostTagChildren(d, block, el) {
13394
14268
  const kids = d.children;
@@ -13566,6 +14440,8 @@ function mapSlot(scopeOrItems, slotOrMethod, domParent, items, method, native, c
13566
14440
  callback = native;
13567
14441
  native = mapSlot(items, method);
13568
14442
  }
14443
+ if (process.env.NODE_ENV !== "production" && ((flags ?? 0) & 64) !== 0 && items?.length > 0)
14444
+ warnMissingListKey(scopeOrItems.block);
13569
14445
  if (ownEnd === 1) ownEnd = true;
13570
14446
  if (native === true) {
13571
14447
  const previous = scopeOrItems.slots[slotOrMethod]?.forSlot;
@@ -13835,6 +14711,7 @@ function renderPreparedChildList(state, parentBlock, domParent, preparedList, hy
13835
14711
  return;
13836
14712
  }
13837
14713
  function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsHost, compactable, includeKeyedSingle = true, compiledMapBody, compiledMapKey, compiledMapFlags, compiledMapDeps, mappedFallback) {
14714
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
13838
14715
  if (value != null && includeKeyedSingle && domParent.nodeType === 1 && VOID_ELEMENTS.has(domParent.localName) && !isPortalTarget(parentScope.block, domParent)) {
13839
14716
  throw new Error(formatClientError(26, domParent.localName));
13840
14717
  }
@@ -13909,7 +14786,7 @@ function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsH
13909
14786
  slotKey,
13910
14787
  domParent,
13911
14788
  value,
13912
- anchor,
14789
+ anchor?.parentNode === domParent ? anchor : null,
13913
14790
  ownEnd,
13914
14791
  ownsHost,
13915
14792
  compactable,
@@ -14030,7 +14907,9 @@ function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsH
14030
14907
  portalDesc.body,
14031
14908
  portalDesc.props,
14032
14909
  // The DOM element containing this hole is the portal's logical parent.
14033
- domParent
14910
+ domParent,
14911
+ void 0,
14912
+ portalDesc.key
14034
14913
  );
14035
14914
  if (activeFragments.size !== 0 && state.end !== null) {
14036
14915
  registerValuePortalFragmentOwners(state.portal, parentBlock, state.end);
@@ -14666,7 +15545,17 @@ function memo(component, arePropsEqual) {
14666
15545
  function memoWrapper(props, scope, extra) {
14667
15546
  return component(props, scope, extra);
14668
15547
  }
14669
- memoWrapper.__memo = true;
15548
+ Object.defineProperty(memoWrapper, "type", { value: component });
15549
+ Object.defineProperty(memoWrapper, "displayName", {
15550
+ configurable: true,
15551
+ writable: true,
15552
+ value: component.displayName || component.name || "Memo"
15553
+ });
15554
+ Object.defineProperty(memoWrapper, "__memo", {
15555
+ get() {
15556
+ return this === memoWrapper;
15557
+ }
15558
+ });
14670
15559
  Object.defineProperty(memoWrapper, "defaultProps", {
14671
15560
  configurable: true,
14672
15561
  get: () => component.defaultProps,
@@ -14676,7 +15565,7 @@ function memo(component, arePropsEqual) {
14676
15565
  });
14677
15566
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
14678
15567
  __profileComponentSource(memoWrapper, component);
14679
- if (arePropsEqual) memoWrapper.__compare = arePropsEqual;
15568
+ if (arePropsEqual) Object.defineProperty(memoWrapper, "__compare", { value: arePropsEqual });
14680
15569
  return memoWrapper;
14681
15570
  }
14682
15571
  const HMR = /* @__PURE__ */ Symbol.for("octane.hmr");
@@ -14701,7 +15590,7 @@ function hmr(fn) {
14701
15590
  meta.fn = nextFn;
14702
15591
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
14703
15592
  __profileComponentSource(wrapper, meta.fn);
14704
- wrapper.__warm = meta.fn.__warm;
15593
+ markWarm(wrapper, meta.fn.__warm);
14705
15594
  const it = meta.liveBlocks.values();
14706
15595
  for (let r = it.next(); !r.done; r = it.next()) {
14707
15596
  const b = r.value;
@@ -14723,10 +15612,14 @@ function hmr(fn) {
14723
15612
  if (scope !== void 0) meta.liveBlocks.add(scope.block);
14724
15613
  return meta.fn(props, scope, extra);
14725
15614
  }
14726
- wrapper[HMR] = meta;
15615
+ Object.defineProperty(wrapper, HMR, {
15616
+ get() {
15617
+ return this === wrapper ? meta : void 0;
15618
+ }
15619
+ });
14727
15620
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
14728
15621
  __profileComponentSource(wrapper, fn);
14729
- if (fn.__warm !== void 0) wrapper.__warm = fn.__warm;
15622
+ if (fn.__warm !== void 0) markWarm(wrapper, fn.__warm);
14730
15623
  return wrapper;
14731
15624
  }
14732
15625
  let TRANSITION_FALLBACK_TIMEOUT_MS = Infinity;
@@ -15519,7 +16412,7 @@ function renderVisibleTry(state, source) {
15519
16412
  throw renderError;
15520
16413
  if (isSuspenseException(renderError)) {
15521
16414
  if (state.propagateSuspense) throw renderError;
15522
- handleSuspense(state, renderError.thenable, block, journalCheckpoint);
16415
+ handleSuspense(state, renderError.thenable, block, journalCheckpoint, source ?? block);
15523
16416
  } else switchToCatch(state, renderError, true);
15524
16417
  } else {
15525
16418
  if (capture !== null) spliceOffscreenCapture(capture);
@@ -15804,6 +16697,7 @@ function releaseHeldTransition(state) {
15804
16697
  if (state.transitionHeld) {
15805
16698
  state.transitionHeld = false;
15806
16699
  tickTransitionCount(-1);
16700
+ releaseTransitionHookHolder(state);
15807
16701
  }
15808
16702
  abandonHeldTransition(state);
15809
16703
  if (state.transitionTimeoutId !== null) {
@@ -15811,14 +16705,15 @@ function releaseHeldTransition(state) {
15811
16705
  state.transitionTimeoutId = null;
15812
16706
  }
15813
16707
  }
15814
- function handleSuspense(state, thenable, sourceBlock, journalCheckpoint = -1) {
16708
+ function handleSuspense(state, thenable, sourceBlock, journalCheckpoint = -1, transitionOrigin = sourceBlock) {
15815
16709
  ensureScheduledVisibilityDriver();
15816
16710
  const isTransition = sourceBlock.currentRenderMode === "transition";
15817
- if ((isTransition || state.transitionHeld) && state.hasResolved && state.branch === 1 && state.hiddenDom === null) {
16711
+ if (isTransition && state.hasResolved && state.branch === 1 && state.hiddenDom === null) {
15818
16712
  rollbackTransitionJournal(journalCheckpoint, state.tryBlock ?? sourceBlock);
15819
16713
  if (ACTIVE_TRANSITION_ATTEMPT !== null) {
15820
16714
  (ACTIVE_TRANSITION_ATTEMPT.heldSlots ??= /* @__PURE__ */ new Set()).add(state);
15821
16715
  }
16716
+ holdTransitionHooksForBlock(state, transitionOrigin);
15822
16717
  if (!state.transitionHeld) {
15823
16718
  state.transitionHeld = true;
15824
16719
  tickTransitionCount(1);
@@ -15839,6 +16734,7 @@ function handleSuspense(state, thenable, sourceBlock, journalCheckpoint = -1) {
15839
16734
  attachResume(state, thenable);
15840
16735
  return;
15841
16736
  }
16737
+ if (!isTransition) releaseHeldTransition(state);
15842
16738
  hideTryContentAndMountPending(state, thenable);
15843
16739
  }
15844
16740
  function invalidatePendingSuspenseEffects(owner) {
@@ -16131,7 +17027,10 @@ function commitResumeInner(state) {
16131
17027
  if (!deferringStagedRevealEffects) commitEffects();
16132
17028
  } finally {
16133
17029
  if (hiddenActivity !== null) rehideActivityAfterDescendantRender(hiddenActivity);
16134
- if (releaseHeld) tickTransitionCount(-1);
17030
+ if (releaseHeld) {
17031
+ tickTransitionCount(-1);
17032
+ releaseTransitionHookHolder(state);
17033
+ }
16135
17034
  }
16136
17035
  }
16137
17036
  function findScheduledVisibilityOwner(block, includeActivity, visibleMode = null) {
@@ -16451,6 +17350,7 @@ function attemptHiddenRevealInner(state, scheduledMode, reason = "update") {
16451
17350
  if (state.transitionHeld) {
16452
17351
  state.transitionHeld = false;
16453
17352
  tickTransitionCount(-1);
17353
+ releaseTransitionHookHolder(state);
16454
17354
  }
16455
17355
  if (HELD_TRANSITIONS.has(state)) {
16456
17356
  HELD_TRANSITIONS.delete(state);
@@ -16505,6 +17405,7 @@ function flushStagedReveals() {
16505
17405
  break;
16506
17406
  }
16507
17407
  }
17408
+ if (allVisible && heldTransitionHasPendingAction(HELD_SYNC_TRANSITION.entries)) return;
16508
17409
  if (allVisible && promoteHeldSyncTransition()) {
16509
17410
  STAGED_REVEALS.clear();
16510
17411
  flush();
@@ -16584,6 +17485,9 @@ function attachResume(state, thenable) {
16584
17485
  thenable.then(retry, retry);
16585
17486
  }
16586
17487
  function startTransition(fn) {
17488
+ runTransition(fn);
17489
+ }
17490
+ function runTransition(fn, hook) {
16587
17491
  ensureTransitionSwapDriver();
16588
17492
  TRANSITION_DEPTH++;
16589
17493
  const parentActionBatch = ACTIVE_TRANSITION_ACTION_BATCH;
@@ -16591,6 +17495,10 @@ function startTransition(fn) {
16591
17495
  const actionBatch = parentActionBatch ?? pendingActionBatch ?? createTransitionActionBatch();
16592
17496
  const ownsActionBatch = parentActionBatch === null && pendingActionBatch === null;
16593
17497
  ACTIVE_TRANSITION_ACTION_BATCH = actionBatch;
17498
+ if (hook !== void 0) {
17499
+ addTransitionHookToBatch(actionBatch, hook);
17500
+ publishTransitionHookBatch(actionBatch);
17501
+ }
16594
17502
  const submitRec = ACTIVE_SUBMIT_DISPATCH;
16595
17503
  if (submitRec !== null) submitRec.transitions++;
16596
17504
  let result;
@@ -16620,7 +17528,10 @@ function startTransition(fn) {
16620
17528
  tickTransitionCount(-1);
16621
17529
  if (submitRec !== null) settleSubmitTransition(submitRec);
16622
17530
  flushFormResets();
16623
- throw err;
17531
+ actionBatch.workComplete = true;
17532
+ finishTransitionHookBatch(actionBatch);
17533
+ reportTransitionError(err, hook);
17534
+ return;
16624
17535
  }
16625
17536
  if (result != null && typeof result.then === "function") {
16626
17537
  ASYNC_TRANSITION_COUNT++;
@@ -16634,16 +17545,31 @@ function startTransition(fn) {
16634
17545
  ASYNC_TRANSITION_COUNT--;
16635
17546
  if (submitRec !== null) settleSubmitTransition(submitRec);
16636
17547
  flushFormResets();
17548
+ queueMicrotask(() => {
17549
+ actionBatch.workComplete = true;
17550
+ finishTransitionHookBatch(actionBatch);
17551
+ });
16637
17552
  };
16638
- result.then(settle, settle);
17553
+ result.then(settle, (error) => {
17554
+ settle();
17555
+ reportTransitionError(error, hook);
17556
+ });
16639
17557
  } else {
16640
17558
  queueMicrotask(() => {
16641
17559
  tickTransitionCount(-1);
16642
17560
  if (submitRec !== null) settleSubmitTransition(submitRec);
16643
17561
  flushFormResets();
17562
+ actionBatch.workComplete = true;
17563
+ finishTransitionHookBatch(actionBatch);
16644
17564
  });
16645
17565
  }
16646
17566
  }
17567
+ function reportTransitionError(error, hook) {
17568
+ if (hook !== void 0 && !hook.block.disposed) {
17569
+ hook.error = { value: error };
17570
+ scheduleRender(hook.block);
17571
+ } else reportListenerError(error);
17572
+ }
16647
17573
  function useTransition(slot) {
16648
17574
  slot = resolveSlot(slot);
16649
17575
  if (slot === void 0) missingSlot("useTransition");
@@ -16651,22 +17577,33 @@ function useTransition(slot) {
16651
17577
  const block = CURRENT_BLOCK;
16652
17578
  let s = scope.hooks?.get(slot);
16653
17579
  if (s === void 0) {
16654
- const slotRef = { isPending: false, start: startTransition };
16655
- s = slotRef;
16656
- ensureHooks(scope).set(slot, slotRef);
16657
- const listener = () => {
16658
- const next = TRANSITION_PENDING_COUNT > 0;
16659
- if (slotRef.isPending !== next) {
16660
- slotRef.isPending = next;
16661
- if (!block.disposed) {
17580
+ const hook = {
17581
+ isPending: false,
17582
+ block,
17583
+ pendingBatches: 0,
17584
+ start: (fn) => {
17585
+ if (!block.disposed) runTransition(fn, hook);
17586
+ },
17587
+ publish: (pending) => {
17588
+ if (hook.isPending === pending || block.disposed) return;
17589
+ hook.isPending = pending;
17590
+ TRANSITION_LISTENER_PUBLISH_DEPTH++;
17591
+ try {
16662
17592
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
16663
17593
  __profileSchedule(block, "transition-pending", slot);
16664
17594
  scheduleRender(block);
17595
+ } finally {
17596
+ TRANSITION_LISTENER_PUBLISH_DEPTH--;
16665
17597
  }
16666
17598
  }
16667
17599
  };
16668
- TRANSITION_LISTENERS.add(listener);
16669
- registerHookCleanup(scope, () => TRANSITION_LISTENERS.delete(listener));
17600
+ s = hook;
17601
+ ensureHooks(scope).set(slot, hook);
17602
+ }
17603
+ if (s.error !== void 0) {
17604
+ const error = s.error.value;
17605
+ s.error = void 0;
17606
+ throw error;
16670
17607
  }
16671
17608
  return [s.isPending, s.start];
16672
17609
  }
@@ -16697,6 +17634,7 @@ function useActionState(action, initialState, permalinkOrSlot, slot) {
16697
17634
  }
16698
17635
  };
16699
17636
  const dispatch = ((payload) => {
17637
+ const outsideTransition = process.env.NODE_ENV !== "production" && transitionActionBatchForUpdate() === null && ACTIVE_SUBMIT_DISPATCH?.intercepted !== true;
16700
17638
  slotRef.pendingCount++;
16701
17639
  setPending(true);
16702
17640
  slotRef.chain = slotRef.chain.then(
@@ -16708,7 +17646,13 @@ function useActionState(action, initialState, permalinkOrSlot, slot) {
16708
17646
  startTransition(() => {
16709
17647
  let p;
16710
17648
  try {
16711
- p = Promise.resolve(slotRef.action(prevState, payload));
17649
+ const result = slotRef.action(prevState, payload);
17650
+ if (process.env.NODE_ENV !== "production" && outsideTransition && result != null && typeof result.then === "function") {
17651
+ console.error(
17652
+ "An async useActionState action was dispatched outside a transition or action. Use an action/formAction prop or wrap the dispatch in startTransition."
17653
+ );
17654
+ }
17655
+ p = Promise.resolve(result);
16712
17656
  } catch (err) {
16713
17657
  finish();
16714
17658
  const handler = findTryHandler(block);
@@ -16736,7 +17680,7 @@ function useActionState(action, initialState, permalinkOrSlot, slot) {
16736
17680
  resolveResult(prevState);
16737
17681
  }
16738
17682
  );
16739
- return p;
17683
+ return p.then(noop, noop);
16740
17684
  });
16741
17685
  })
16742
17686
  );
@@ -16824,6 +17768,11 @@ function useOptimistic(passthrough, updateFnOrSlot, slot) {
16824
17768
  updateFn,
16825
17769
  armed: false,
16826
17770
  add: (value) => {
17771
+ if (process.env.NODE_ENV !== "production" && TRANSITION_DEPTH === 0 && ASYNC_TRANSITION_COUNT === 0) {
17772
+ console.error(
17773
+ "An optimistic update was dispatched outside a transition or action. Wrap it in startTransition or call it from an action."
17774
+ );
17775
+ }
16827
17776
  slotRef.queue.push(value);
16828
17777
  if (TRANSITION_PENDING_COUNT > 0) {
16829
17778
  slotRef.armed = true;
@@ -16857,11 +17806,11 @@ function spawnDeferredSwap(s) {
16857
17806
  queueMicrotask(() => {
16858
17807
  if (!s.scheduled || s.block.disposed) return;
16859
17808
  s.scheduled = false;
16860
- if (Object.is(s.current, s.next)) return;
16861
- s.current = s.next;
17809
+ if (Object.is(s.value, s.next)) return;
16862
17810
  startTransition(() => {
16863
17811
  DEFERRED_SPAWN = true;
16864
17812
  try {
17813
+ stageTransitionValue(s, s.block, s.next, s.next, true);
16865
17814
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
16866
17815
  __profileSchedule(s.block, "deferred-value", s.profileSlot);
16867
17816
  scheduleRender(s.block);
@@ -16872,6 +17821,14 @@ function spawnDeferredSwap(s) {
16872
17821
  });
16873
17822
  });
16874
17823
  }
17824
+ function hasHeldDeferredSwap(slot) {
17825
+ const entries = HELD_SYNC_TRANSITION?.entries ?? slot.block.idState.renderOwner?.transition?.entries;
17826
+ if (entries === void 0) return false;
17827
+ for (const entry of entries) {
17828
+ if (entry.slot === slot && Object.is(entry.value, slot.next)) return true;
17829
+ }
17830
+ return false;
17831
+ }
16875
17832
  function useDeferredValue(value, ...rest) {
16876
17833
  let slot = rest[rest.length - 1];
16877
17834
  slot = resolveSlot(slot);
@@ -16885,7 +17842,7 @@ function useDeferredValue(value, ...rest) {
16885
17842
  if (s === void 0) {
16886
17843
  if (hasInitial && !block.currentRenderDeferred) {
16887
17844
  s = {
16888
- current: initialValue,
17845
+ value: initialValue,
16889
17846
  next: value,
16890
17847
  scheduled: false,
16891
17848
  block,
@@ -16897,31 +17854,32 @@ function useDeferredValue(value, ...rest) {
16897
17854
  if (!Object.is(initialValue, value)) spawnDeferredSwap(s);
16898
17855
  return initialValue;
16899
17856
  }
16900
- s = { current: value, next: value, scheduled: false, block, wasHidden: hidden };
17857
+ s = { value, next: value, scheduled: false, block, wasHidden: hidden };
16901
17858
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
16902
17859
  s.profileSlot = slot;
16903
17860
  ensureHooks(scope).set(slot, s);
16904
17861
  return value;
16905
17862
  }
17863
+ if (ACTIVE_TRANSITION_ATTEMPT !== null) journalObjectOnce(s);
16906
17864
  s.next = value;
16907
17865
  const wasHidden = s.wasHidden;
16908
17866
  s.wasHidden = hidden;
16909
- if (Object.is(s.current, value)) return s.current;
17867
+ if (Object.is(s.value, value)) return s.value;
16910
17868
  if (hidden || wasHidden) {
16911
17869
  if (hasInitial && !block.currentRenderDeferred && !Object.is(initialValue, value)) {
16912
- s.current = initialValue;
17870
+ s.value = initialValue;
16913
17871
  if (!s.scheduled) spawnDeferredSwap(s);
16914
17872
  return initialValue;
16915
17873
  }
16916
- s.current = value;
17874
+ s.value = value;
16917
17875
  return value;
16918
17876
  }
16919
17877
  if (block.currentRenderMode === "transition") {
16920
- s.current = value;
17878
+ s.value = value;
16921
17879
  return value;
16922
17880
  }
16923
- if (!s.scheduled) spawnDeferredSwap(s);
16924
- return s.current;
17881
+ if (!s.scheduled && !hasHeldDeferredSwap(s)) spawnDeferredSwap(s);
17882
+ return s.value;
16925
17883
  }
16926
17884
  function requestReset(state) {
16927
17885
  if (state.parentBlock.disposed || state.branch !== 0) return;
@@ -16995,6 +17953,7 @@ function switchToCatchInner(state, err, reportInline, adoptedStart, adoptedEnd)
16995
17953
  if (state.transitionHeld) {
16996
17954
  state.transitionHeld = false;
16997
17955
  tickTransitionCount(-1);
17956
+ releaseTransitionHookHolder(state);
16998
17957
  }
16999
17958
  abandonHeldTransition(state);
17000
17959
  if (state.catchBody === null) {
@@ -17156,6 +18115,7 @@ function sharesBlockBoundary(parent, start, end) {
17156
18115
  return parent !== null && start !== null && end !== null && parent.startMarker === start && parent.endMarker === end;
17157
18116
  }
17158
18117
  function renderBranchSlot(parentScope, slotKey, state, domParent, next, body, marker, env) {
18118
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
17159
18119
  const parentBlock = parentScope.block;
17160
18120
  const hydration = activeHydration();
17161
18121
  if (next !== state.branch) {
@@ -17820,6 +18780,7 @@ function queueActivityDeactivation(state, block, commitVersion) {
17820
18780
  });
17821
18781
  }
17822
18782
  function activityBlock(parentScope, slotKey, domParent, mode, body, anchor, env) {
18783
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
17823
18784
  if (mode === "hidden") ensureScheduledVisibilityDriver();
17824
18785
  const parentBlock = parentScope.block;
17825
18786
  const hydration = activeHydration();
@@ -18058,7 +19019,7 @@ function deactivateScope(scope, disconnectPassive = true) {
18058
19019
  const cleanup = e.cleanup;
18059
19020
  e.cleanup = void 0;
18060
19021
  try {
18061
- runEffectCleanupCallback(cleanup);
19022
+ runEffectCleanupCallback(cleanup, e.phase);
18062
19023
  } catch (err) {
18063
19024
  if (err instanceof MaximumUpdateDepthError) throw err;
18064
19025
  const handler = findTryHandler(scope.block);
@@ -18109,6 +19070,7 @@ function switchBlock(parentScope, slotKey, domParent, discriminant, cases, defau
18109
19070
  renderBranchSlot(parentScope, slotKey, state, domParent, nextIdx, body, "switch", env);
18110
19071
  }
18111
19072
  function forBlock(parentScope, slotKey, domParent, items, getKey, itemBody, flags, deps, emptyBody, anchor, ownEnd) {
19073
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
18112
19074
  const parentBlock = parentScope.block;
18113
19075
  const hydration = activeHydration();
18114
19076
  let state = parentScope.slots[slotKey];
@@ -18264,6 +19226,7 @@ function forBlock(parentScope, slotKey, domParent, items, getKey, itemBody, flag
18264
19226
  }
18265
19227
  }
18266
19228
  function keyedForBlock(parentScope, slotKey, domParent, items, getKey, itemBody, flags, deps, emptyBody, anchor, ownEnd, selectionBody) {
19229
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
18267
19230
  const state = parentScope.slots[slotKey];
18268
19231
  if (TRANSITION_JOURNAL !== null && ROOT_RENDER_TRANSACTION === null) {
18269
19232
  if (state !== void 0) {
@@ -18592,9 +19555,25 @@ function consumeAdoptQueuePrefix(adopt, count) {
18592
19555
  if (count < adopt.length) adopt.copyWithin(0, count);
18593
19556
  adopt.length -= count;
18594
19557
  }
19558
+ function checkedListKey(getKey) {
19559
+ const seen = /* @__PURE__ */ new Map();
19560
+ let warned = false;
19561
+ return (item, index) => {
19562
+ const key = getKey(item, index);
19563
+ if (!warned && seen.has(key) && seen.get(key) !== index) {
19564
+ warned = true;
19565
+ const label = typeof key === "object" || typeof key === "function" ? "[object identity]" : String(key);
19566
+ console.error(
19567
+ `Encountered two children with the same key, ${label}. Keys should be unique so that components maintain their identity across updates.`
19568
+ );
19569
+ } else seen.set(key, index);
19570
+ return key;
19571
+ };
19572
+ }
18595
19573
  function mountItemsLinear(parentBlock, state, items, getKey, itemBody, singleRoot, ssrMarkerless) {
18596
19574
  const newLen = items.length;
18597
19575
  if (newLen === 0) return;
19576
+ if (process.env.NODE_ENV !== "production") getKey = checkedListKey(getKey);
18598
19577
  if (TRANSITION_JOURNAL !== null) journalForSlot(state);
18599
19578
  const oldItems = state.items;
18600
19579
  const parentNode = state.end.parentNode;
@@ -18664,6 +19643,7 @@ function reconcileKeyed(parentBlock, state, items, getKey, itemBody, pure, singl
18664
19643
  mountItemsLinear(parentBlock, state, items, getKey, itemBody, singleRoot, ssrMarkerless);
18665
19644
  return;
18666
19645
  }
19646
+ if (process.env.NODE_ENV !== "production") getKey = checkedListKey(getKey);
18667
19647
  if (newLen === 0) {
18668
19648
  if (journalShape) journalForSlot(state);
18669
19649
  batchClearItems(state, oldItems);
@@ -18922,81 +19902,72 @@ function reconcileKeyed(parentBlock, state, items, getKey, itemBody, pure, singl
18922
19902
  }
18923
19903
  }
18924
19904
  const middleEndAnchor = afterMiddle ? afterMiddle.startMarker : state.end;
18925
- let nextBlock = afterMiddle;
18926
- let lastPlaced = null;
18927
- if (moved) {
19905
+ if (patched === newMidLen) {
18928
19906
  const seq = lis(sources, newMidLen);
18929
19907
  let seqIdx = seq.length - 1;
19908
+ let nextBlock = afterMiddle;
18930
19909
  for (let i = newMidLen - 1; i >= 0; i--) {
18931
- const targetIdx = i + prefixLen;
18932
- const key = newKeys[i];
18933
- const anchor = nextBlock ? nextBlock.startMarker : middleEndAnchor;
18934
- let block;
18935
- if (sources[i] === -1) {
18936
- const item = items[targetIdx];
18937
- block = mountItem(
18938
- parentBlock,
18939
- parentNode,
18940
- anchor,
18941
- item,
18942
- targetIdx,
18943
- itemBody,
18944
- state,
18945
- singleRoot,
18946
- ssrMarkerless
18947
- );
18948
- oldItems.set(key, block);
18949
- block.key = key;
18950
- state.size++;
18951
- } else if (seqIdx < 0 || i !== seq[seqIdx]) {
18952
- block = oldItems.get(key);
18953
- moveBlockBefore(block, anchor);
18954
- } else {
18955
- block = oldItems.get(key);
18956
- seqIdx--;
18957
- }
19910
+ const block = oldItems.get(newKeys[i]);
19911
+ if (seqIdx < 0 || i !== seq[seqIdx]) {
19912
+ moveBlockBefore(block, nextBlock ? nextBlock.startMarker : middleEndAnchor);
19913
+ } else seqIdx--;
18958
19914
  block.nextSibling = nextBlock;
18959
19915
  if (nextBlock) nextBlock.prevSibling = block;
18960
- if (lastPlaced === null) lastPlaced = block;
19916
+ else state.tail = block;
18961
19917
  nextBlock = block;
18962
19918
  }
18963
- } else {
19919
+ nextBlock.prevSibling = beforeMiddle;
19920
+ if (beforeMiddle) beforeMiddle.nextSibling = nextBlock;
19921
+ else state.head = nextBlock;
19922
+ return;
19923
+ }
19924
+ if (moved) {
19925
+ const seq = lis(sources, newMidLen);
19926
+ let seqIdx = seq.length - 1;
19927
+ let anchor = middleEndAnchor;
18964
19928
  for (let i = newMidLen - 1; i >= 0; i--) {
18965
- const targetIdx = i + prefixLen;
18966
- const key = newKeys[i];
18967
- const anchor = nextBlock ? nextBlock.startMarker : middleEndAnchor;
18968
- let block;
18969
- if (sources[i] === -1) {
18970
- const item = items[targetIdx];
18971
- block = mountItem(
18972
- parentBlock,
18973
- parentNode,
18974
- anchor,
18975
- item,
18976
- targetIdx,
18977
- itemBody,
18978
- state,
18979
- singleRoot,
18980
- ssrMarkerless
18981
- );
18982
- oldItems.set(key, block);
18983
- block.key = key;
18984
- state.size++;
18985
- } else {
18986
- block = oldItems.get(key);
19929
+ if (sources[i] === -1) continue;
19930
+ const block = oldItems.get(newKeys[i]);
19931
+ if (seqIdx < 0 || i !== seq[seqIdx]) moveBlockBefore(block, anchor);
19932
+ else seqIdx--;
19933
+ anchor = block.startMarker;
19934
+ }
19935
+ }
19936
+ let previous = beforeMiddle;
19937
+ let nextSurvivor = 0;
19938
+ for (let i = 0; i < newMidLen; i++) {
19939
+ const key = newKeys[i];
19940
+ let block;
19941
+ if (sources[i] === -1) {
19942
+ if (nextSurvivor <= i) {
19943
+ nextSurvivor = i + 1;
19944
+ while (nextSurvivor < newMidLen && sources[nextSurvivor] === -1) nextSurvivor++;
18987
19945
  }
18988
- block.nextSibling = nextBlock;
18989
- if (nextBlock) nextBlock.prevSibling = block;
18990
- if (lastPlaced === null) lastPlaced = block;
18991
- nextBlock = block;
18992
- }
19946
+ const anchor = nextSurvivor < newMidLen ? oldItems.get(newKeys[nextSurvivor]).startMarker : middleEndAnchor;
19947
+ const targetIdx = i + prefixLen;
19948
+ block = mountItem(
19949
+ parentBlock,
19950
+ parentNode,
19951
+ anchor,
19952
+ items[targetIdx],
19953
+ targetIdx,
19954
+ itemBody,
19955
+ state,
19956
+ singleRoot,
19957
+ ssrMarkerless
19958
+ );
19959
+ oldItems.set(key, block);
19960
+ block.key = key;
19961
+ state.size++;
19962
+ } else block = oldItems.get(key);
19963
+ block.prevSibling = previous;
19964
+ if (previous) previous.nextSibling = block;
19965
+ else state.head = block;
19966
+ previous = block;
18993
19967
  }
18994
- const newMiddleHead = nextBlock;
18995
- const newMiddleTail = lastPlaced;
18996
- newMiddleHead.prevSibling = beforeMiddle;
18997
- if (beforeMiddle) beforeMiddle.nextSibling = newMiddleHead;
18998
- else state.head = newMiddleHead;
18999
- if (!afterMiddle) state.tail = newMiddleTail;
19968
+ previous.nextSibling = afterMiddle;
19969
+ if (afterMiddle) afterMiddle.prevSibling = previous;
19970
+ else state.tail = previous;
19000
19971
  } finally {
19001
19972
  if (sources.length <= MAX_KEYED_REORDER_SCRATCH && (keyedReorderSources === null || keyedReorderSources.length < sources.length)) {
19002
19973
  keyedReorderSources = sources;
@@ -19702,8 +20673,19 @@ let ROOT_CONTAINER_OWNERS = null;
19702
20673
  const ROOT_RENDERABLE_BODY = ((value) => value === void 0 ? null : value);
19703
20674
  const EMPTY_ROOT_BODY = (() => void 0);
19704
20675
  function assertValidRootContainer(container) {
19705
- if (container === null || typeof container !== "object" || container.nodeType !== 1) {
19706
- throw new Error(formatClientError(28));
20676
+ if (container === null || typeof container !== "object" || container.nodeType !== 1 && container.nodeType !== 9 && container.nodeType !== 11) {
20677
+ throw new Error(formatClientError(63));
20678
+ }
20679
+ }
20680
+ function clearRootContainer(container) {
20681
+ if (container.nodeType !== 9) {
20682
+ container.textContent = "";
20683
+ return;
20684
+ }
20685
+ for (let child2 = container.firstChild; child2 !== null; ) {
20686
+ const next = child2.nextSibling;
20687
+ if (child2.nodeType !== 10) container.removeChild(child2);
20688
+ child2 = next;
19707
20689
  }
19708
20690
  }
19709
20691
  function claimRootContainer(container) {
@@ -19812,17 +20794,19 @@ function devHtmlNesting(childTag, ancestors, childLocation, ancestorLocation) {
19812
20794
  }
19813
20795
  function validateRootHtmlNesting(container, body) {
19814
20796
  if (process.env.NODE_ENV !== "production") {
19815
- if (componentSourceLoc(body) === void 0 || container.namespaceURI !== "http://www.w3.org/1999/xhtml" || container.localName === "div" || container.localName === "body" || container.localName === "html" || container.localName.includes("-")) {
20797
+ if (container.nodeType !== 1) return;
20798
+ const element = container;
20799
+ if (componentSourceLoc(body) === void 0 || element.namespaceURI !== "http://www.w3.org/1999/xhtml" || element.localName === "div" || element.localName === "body" || element.localName === "html" || element.localName.includes("-")) {
19816
20800
  return;
19817
20801
  }
19818
20802
  const root = container.firstElementChild;
19819
20803
  if (root === null) return;
19820
- if (invalidHtmlNestingWithParent(root.localName, container.localName) !== null) {
19821
- devHtmlNesting(root.localName, [container.localName]);
20804
+ if (invalidHtmlNestingWithParent(root.localName, element.localName) !== null) {
20805
+ devHtmlNesting(root.localName, [element.localName]);
19822
20806
  return;
19823
20807
  }
19824
20808
  let child2 = root.firstElementChild;
19825
- const ancestors = [root.localName, container.localName];
20809
+ const ancestors = [root.localName, element.localName];
19826
20810
  while (child2 !== null && child2.namespaceURI === "http://www.w3.org/1999/xhtml") {
19827
20811
  if (invalidHtmlNestingWithAncestor(child2.localName, ancestors) !== null) {
19828
20812
  devHtmlNesting(child2.localName, ancestors);
@@ -19887,7 +20871,7 @@ function makeRoot(container, rootBlock, currentBody, currentKey, idState, output
19887
20871
  const previousRoot = rootBlock;
19888
20872
  const previousBody = currentBody;
19889
20873
  const previousKey = currentKey;
19890
- const staged = previousRoot !== null && previousRoot.mounted && !previousRoot.disposed && !renderOwner.transaction.created?.has(previousRoot);
20874
+ const staged = container.nodeType !== 9 && previousRoot !== null && previousRoot.mounted && !previousRoot.disposed && !renderOwner.transaction.created?.has(previousRoot);
19891
20875
  const oldFirst = staged ? container.firstChild : null;
19892
20876
  const oldLast = staged ? container.lastChild : null;
19893
20877
  journalUndo(() => {
@@ -19912,7 +20896,7 @@ function makeRoot(container, rootBlock, currentBody, currentKey, idState, output
19912
20896
  end = document.createComment("/root");
19913
20897
  container.append(start, end);
19914
20898
  } else {
19915
- while (container.firstChild) container.removeChild(container.firstChild);
20899
+ clearRootContainer(container);
19916
20900
  }
19917
20901
  rootBlock = createBlock(
19918
20902
  "root",
@@ -19955,6 +20939,7 @@ function makeRoot(container, rootBlock, currentBody, currentKey, idState, output
19955
20939
  mountedRoot.pendingMode = mode ?? null;
19956
20940
  try {
19957
20941
  renderBlock(mountedRoot);
20942
+ if (QUEUE.length > 0) drainHydrationRenderPhaseUpdates(mountedRoot);
19958
20943
  if (process.env.NODE_ENV !== "production") {
19959
20944
  validateRootHtmlNesting(container, body);
19960
20945
  }
@@ -20073,7 +21058,8 @@ function makeRoot(container, rootBlock, currentBody, currentKey, idState, output
20073
21058
  false
20074
21059
  );
20075
21060
  drainRefDetaches();
20076
- container.textContent = "";
21061
+ clearRootContainer(container);
21062
+ drainDeferredPassiveUnmounts();
20077
21063
  rootBlock = null;
20078
21064
  currentBody = null;
20079
21065
  currentKey = null;
@@ -20232,7 +21218,7 @@ function hydrateRoot(container, bodyOrElement, propsOrOptions, rootOptions) {
20232
21218
  journalRootProperty(idState, "next");
20233
21219
  idState.next = 0;
20234
21220
  let firstNode = container.firstChild;
20235
- while (firstNode !== null && isRendererHydrationStyle(firstNode))
21221
+ while (firstNode !== null && (firstNode.nodeType === 10 || isRendererHydrationStyle(firstNode)))
20236
21222
  firstNode = firstNode.nextSibling;
20237
21223
  const hydration = new HydrationCapability(rootBlock, firstNode, seeds);
20238
21224
  if (nativeManifest !== void 0)
@@ -20265,7 +21251,7 @@ function hydrateRoot(container, bodyOrElement, propsOrOptions, rootOptions) {
20265
21251
  } catch (unhandled) {
20266
21252
  rollbackRootRender(owner.transaction);
20267
21253
  unmountBlock(rootBlock, false);
20268
- container.textContent = "";
21254
+ clearRootContainer(container);
20269
21255
  if (!reportUncaughtError(rootBlock, unhandled)) throw unhandled;
20270
21256
  return;
20271
21257
  }
@@ -20759,15 +21745,18 @@ export {
20759
21745
  hydrateRoot,
20760
21746
  ifBlock,
20761
21747
  injectStyle,
21748
+ invokeManualHook,
20762
21749
  isChildrenBlock,
20763
21750
  isValidElement,
20764
21751
  keyedForBlock,
20765
21752
  lazy,
21753
+ manualHook,
20766
21754
  mapSlot,
20767
21755
  markChildrenBlock,
20768
21756
  markDangerouslySetInnerHTMLChildren,
20769
21757
  markNativeChangeDiagnosticStatic,
20770
21758
  markSingleRoot,
21759
+ markWarm,
20771
21760
  memo,
20772
21761
  memoPublish,
20773
21762
  memoPublishAlways,