octane 0.2.2 → 0.2.3

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 (50) hide show
  1. package/dist/cjs/compatibility.cjs +35 -0
  2. package/dist/cjs/component-flags.cjs +8 -1
  3. package/dist/cjs/dom-tables.cjs +2 -0
  4. package/dist/cjs/error-codes.client.generated.cjs +15 -2
  5. package/dist/cjs/error-codes.server.generated.cjs +5 -0
  6. package/dist/cjs/event-names.cjs +39 -0
  7. package/dist/cjs/index.cjs +13 -0
  8. package/dist/cjs/runtime.cjs +1223 -332
  9. package/dist/cjs/runtime.server.cjs +362 -120
  10. package/dist/cjs/server/index.cjs +22 -0
  11. package/dist/cjs/version.cjs +1 -1
  12. package/dist/compatibility.d.ts +7 -0
  13. package/dist/compatibility.js +10 -0
  14. package/dist/compiler/bundler.js +13 -30
  15. package/dist/compiler/compile-renderer-boundaries.js +1 -0
  16. package/dist/compiler/compile-universal.js +3 -0
  17. package/dist/compiler/compile.js +619 -99
  18. package/dist/compiler/hook-deps.js +100 -3
  19. package/dist/compiler/hook-names.js +1 -0
  20. package/dist/compiler/manual-hooks.js +171 -0
  21. package/dist/compiler/plain-hook-memo.js +54 -5
  22. package/dist/compiler/slot-hooks.d.ts +43 -0
  23. package/dist/compiler/slot-hooks.js +154 -35
  24. package/dist/component-flags.d.ts +1 -1
  25. package/dist/component-flags.js +8 -1
  26. package/dist/dom-tables.js +2 -0
  27. package/dist/error-codes.client.generated.d.ts +3 -1
  28. package/dist/error-codes.client.generated.js +15 -2
  29. package/dist/error-codes.server.generated.d.ts +1 -0
  30. package/dist/error-codes.server.generated.js +5 -0
  31. package/dist/event-names.d.ts +1 -0
  32. package/dist/event-names.js +15 -0
  33. package/dist/html-tree-validation.d.ts +17 -34
  34. package/dist/index.d.ts +3 -1
  35. package/dist/index.js +12 -1
  36. package/dist/jsx-runtime.d.ts +6 -1
  37. package/dist/public-types.d.ts +188 -0
  38. package/dist/public-types.js +0 -0
  39. package/dist/runtime.d.ts +109 -66
  40. package/dist/runtime.js +1220 -332
  41. package/dist/runtime.server.d.ts +39 -14
  42. package/dist/runtime.server.js +356 -120
  43. package/dist/server/index.d.ts +4 -2
  44. package/dist/server/index.js +19 -0
  45. package/dist/static/index.d.ts +2 -1
  46. package/dist/static/index.js +3 -1
  47. package/dist/universal-core.d.ts +8 -1
  48. package/dist/universal-core.js +95 -9
  49. package/dist/version.js +1 -1
  50. package/package.json +2 -1
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;
@@ -1877,9 +2106,27 @@ let actScopeDepth = 0;
1877
2106
  function setIsOctaneActEnvironment(value) {
1878
2107
  IS_OCTANE_ACT_ENVIRONMENT = value;
1879
2108
  }
2109
+ function isActEnvironment() {
2110
+ return IS_OCTANE_ACT_ENVIRONMENT || globalThis.IS_REACT_ACT_ENVIRONMENT === true;
2111
+ }
1880
2112
  const NESTED_UPDATE_LIMIT = 50;
1881
2113
  const ACT_DRAIN_LIMIT = NESTED_UPDATE_LIMIT + 50;
1882
2114
  let UPDATE_CHAIN_ID = 0;
2115
+ let PASSIVE_UPDATE_COUNTS = null;
2116
+ function countPassiveUpdate(block) {
2117
+ if (process.env.NODE_ENV === "production") return;
2118
+ const counts = PASSIVE_UPDATE_COUNTS ??= /* @__PURE__ */ new WeakMap();
2119
+ let state = counts.get(block);
2120
+ if (state === void 0 || state.chain !== UPDATE_CHAIN_ID) {
2121
+ state = { chain: UPDATE_CHAIN_ID, count: 0 };
2122
+ counts.set(block, state);
2123
+ }
2124
+ if (++state.count === NESTED_UPDATE_LIMIT + 1) {
2125
+ console.error(
2126
+ "Maximum update depth exceeded. Check the dependencies of effects that schedule state updates."
2127
+ );
2128
+ }
2129
+ }
1883
2130
  function inNestedUpdateCallback() {
1884
2131
  return EFFECT_BODY_DEPTH > 0 || REF_CALLBACK_DEPTH > 0 || STORE_SYNC_DEPTH > 0;
1885
2132
  }
@@ -1909,9 +2156,23 @@ function warnCrossComponentRenderUpdate(target, source) {
1909
2156
  }
1910
2157
  function scheduleRender(block) {
1911
2158
  if (block.disposed) return;
1912
- if (process.env.NODE_ENV !== "production" && IS_OCTANE_ACT_ENVIRONMENT && actScopeDepth === 0 && !syncFlush) {
2159
+ if (process.env.NODE_ENV !== "production" && CURRENT_EFFECT_PHASE === INSERTION) {
2160
+ console.error(
2161
+ "useInsertionEffect must not schedule state updates. Move this work to a layout or passive effect."
2162
+ );
2163
+ }
2164
+ if (process.env.NODE_ENV !== "production" && isActEnvironment() && actScopeDepth === 0 && !syncFlush) {
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
+ `An update to ${componentName(block)} was not wrapped in act(...).
2167
+
2168
+ When testing, code that causes state updates should be wrapped into act(...):
2169
+
2170
+ act(() => {
2171
+ /* fire events that update state */
2172
+ });
2173
+ /* assert on the output */
2174
+
2175
+ This ensures you're testing the behavior the user would see in the browser.`
1915
2176
  );
1916
2177
  }
1917
2178
  const renderPhaseSelf = CURRENT_BLOCK === block;
@@ -1929,7 +2190,9 @@ function scheduleRender(block) {
1929
2190
  }
1930
2191
  return;
1931
2192
  }
1932
- if (inNestedUpdateCallback()) {
2193
+ if (CURRENT_EFFECT_PHASE === PASSIVE && !syncFlush) {
2194
+ countPassiveUpdate(block);
2195
+ } else if (inNestedUpdateCallback()) {
1933
2196
  if (block.nestedUpdateChain !== UPDATE_CHAIN_ID) {
1934
2197
  block.nestedUpdateChain = UPDATE_CHAIN_ID;
1935
2198
  block.nestedUpdateCount = 0;
@@ -1971,14 +2234,19 @@ function drainHydrationRenderPhaseUpdates(root) {
1971
2234
  QUEUE[write++] = block;
1972
2235
  continue;
1973
2236
  }
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;
2237
+ if (!block.pending && !block.nestedUpdateError || block.disposed) continue;
1981
2238
  try {
2239
+ if (block.nestedUpdateError) {
2240
+ block.nestedUpdateError = false;
2241
+ throw maximumUpdateDepthError();
2242
+ }
2243
+ const seen = (renders ??= /* @__PURE__ */ new Map()).get(block) ?? 0;
2244
+ const crossRenderUpdate = block.crossRenderUpdate;
2245
+ if (seen >= (crossRenderUpdate ? NESTED_UPDATE_LIMIT : RENDER_PHASE_UPDATE_LIMIT)) {
2246
+ throw crossRenderUpdate ? maximumUpdateDepthError() : new Error(formatClientError(9));
2247
+ }
2248
+ renders.set(block, seen + 1);
2249
+ block.crossRenderUpdate = false;
1982
2250
  renderBlock(block);
1983
2251
  } catch (error) {
1984
2252
  handleRenderError(block, error);
@@ -2026,12 +2294,21 @@ let SCHEDULED_VISIBILITY_DRIVER = null;
2026
2294
  function ensureScheduledVisibilityDriver() {
2027
2295
  SCHEDULED_VISIBILITY_DRIVER ??= {
2028
2296
  find: findScheduledVisibilityOwner,
2297
+ holdsNativeRead,
2029
2298
  reveal: attemptHiddenReveal,
2030
2299
  visible: renderVisibleTry,
2031
2300
  rehide: rehideActivityAfterDescendantRender,
2032
2301
  retryActivity: renderHiddenActivity
2033
2302
  };
2034
2303
  }
2304
+ function holdsNativeRead(block) {
2305
+ for (const state of HELD_TRANSITIONS) {
2306
+ const primary = state.tryBlock;
2307
+ if (state.transitionHeld && state.hiddenDom === null && primary !== null && (primary === block || blockIsAncestorOf(primary, block) || blockIsAncestorOf(block, primary)))
2308
+ return true;
2309
+ }
2310
+ return false;
2311
+ }
2035
2312
  function drainQueue() {
2036
2313
  let pendingError = null;
2037
2314
  let activitiesToRehide = null;
@@ -2075,7 +2352,7 @@ function drainQueue() {
2075
2352
  throw maximumUpdateDepthError();
2076
2353
  }
2077
2354
  if (block.drainStamp === drainId) {
2078
- if (++block.drainRenders > RENDER_PHASE_UPDATE_LIMIT) {
2355
+ if (++block.drainRenders > (crossRenderUpdate ? NESTED_UPDATE_LIMIT : RENDER_PHASE_UPDATE_LIMIT)) {
2079
2356
  throw crossRenderUpdate ? maximumUpdateDepthError() : new Error(formatClientError(9));
2080
2357
  }
2081
2358
  } else {
@@ -2655,6 +2932,11 @@ function drainPassivesBeforeRender() {
2655
2932
  if (effectQueues[PASSIVE].length > 0 || pendingPassiveUnmounts.length > 0) drainPassiveEffects();
2656
2933
  }
2657
2934
  function flushSync(fn) {
2935
+ if (process.env.NODE_ENV !== "production" && (CURRENT_BLOCK !== null || EFFECT_BODY_DEPTH > 0 || REF_CALLBACK_DEPTH > 0)) {
2936
+ console.error(
2937
+ "flushSync was called while rendering or running a lifecycle callback. Move the call to an event or scheduled task."
2938
+ );
2939
+ }
2658
2940
  if (inFlush) return runNativeBatch(fn);
2659
2941
  VIEW_TRANSITION_DRIVER?.interrupt();
2660
2942
  const prevSync = syncFlush;
@@ -2867,6 +3149,7 @@ function commitEffects() {
2867
3149
  return;
2868
3150
  }
2869
3151
  const nativeFrame = NATIVE_READ_DRIVER?.pauseLifecycle() ?? -1;
3152
+ EFFECT_COMMIT_DEPTH++;
2870
3153
  try {
2871
3154
  drainEffectEventUpdates();
2872
3155
  const caughtReports = drainEffectEventCommitActions();
@@ -2884,6 +3167,7 @@ function commitEffects() {
2884
3167
  }
2885
3168
  } finally {
2886
3169
  if (nativeFrame >= 0) NATIVE_READ_DRIVER.resumeLifecycle(nativeFrame);
3170
+ finishEffectCommit();
2887
3171
  }
2888
3172
  }
2889
3173
  function schedulePassiveFlush() {
@@ -2988,15 +3272,25 @@ function compareEffectPostOrder(a, b) {
2988
3272
  if (a.scope === b.scope) return a.order - b.order || a.seq - b.seq;
2989
3273
  return comparePostOrder(a.scope.block, a.seq, b.scope.block, b.seq);
2990
3274
  }
2991
- function reportEffectError(block, error) {
2992
- const handler = findTryHandler(block);
3275
+ function finishEffectCommit() {
3276
+ if (--EFFECT_COMMIT_DEPTH !== 0 || COMMIT_PHASE_ERRORS === null) return;
3277
+ const errors = COMMIT_PHASE_ERRORS;
3278
+ COMMIT_PHASE_ERRORS = null;
3279
+ for (const { block, error, handler } of errors) reportEffectError(block, error, handler);
3280
+ }
3281
+ function reportEffectError(block, error, capturedHandler) {
3282
+ if (EFFECT_COMMIT_DEPTH > 0) {
3283
+ (COMMIT_PHASE_ERRORS ??= []).push({ block, error, handler: capturedHandler });
3284
+ return;
3285
+ }
3286
+ const handler = capturedHandler === void 0 ? findTryHandler(block) : capturedHandler;
2993
3287
  if (handler !== null) {
2994
3288
  reportCaughtError(block, error, handler(error));
2995
3289
  return;
2996
3290
  }
2997
3291
  let root = block;
2998
- while (root.parentBlock !== null) root = root.parentBlock;
2999
- if (root.kind === "root" && !root.disposed) {
3292
+ while (root !== null && root.parentBlock !== null) root = root.parentBlock;
3293
+ if (root !== null && root.kind === "root" && !root.disposed) {
3000
3294
  unmountBlock(root);
3001
3295
  drainRefDetaches();
3002
3296
  }
@@ -3016,7 +3310,7 @@ function fireEffectCleanup(e) {
3016
3310
  if (cleanup) {
3017
3311
  slot.cleanup = void 0;
3018
3312
  try {
3019
- runEffectCleanupCallback(cleanup);
3313
+ runEffectCleanupCallback(cleanup, e.phase);
3020
3314
  } catch (err) {
3021
3315
  if (err instanceof MaximumUpdateDepthError) throw err;
3022
3316
  reportEffectError(e.scope.block, err);
@@ -3033,17 +3327,27 @@ function runEffectBody(e) {
3033
3327
  slot.connectedArgs = e.args;
3034
3328
  slot.disconnected = false;
3035
3329
  try {
3330
+ const previousPhase = CURRENT_EFFECT_PHASE;
3331
+ CURRENT_EFFECT_PHASE = e.phase;
3036
3332
  EFFECT_BODY_DEPTH++;
3037
3333
  try {
3038
3334
  cleanup = e.fn.apply(null, e.args ?? []);
3039
3335
  } finally {
3040
3336
  EFFECT_BODY_DEPTH--;
3337
+ CURRENT_EFFECT_PHASE = previousPhase;
3041
3338
  }
3042
3339
  } catch (err) {
3043
3340
  if (err instanceof MaximumUpdateDepthError) throw err;
3044
3341
  reportEffectError(e.scope.block, err);
3045
3342
  return;
3046
3343
  }
3344
+ if (process.env.NODE_ENV !== "production" && cleanup !== void 0 && typeof cleanup !== "function") {
3345
+ const name = e.phase === PASSIVE ? "useEffect" : e.phase === LAYOUT ? "useLayoutEffect" : "useInsertionEffect";
3346
+ const thenable = cleanup !== null && typeof cleanup.then === "function";
3347
+ console.error(
3348
+ name + " must return a cleanup function or nothing." + (thenable ? " Start asynchronous work inside the effect and return its cleanup separately." : "")
3349
+ );
3350
+ }
3047
3351
  if (typeof cleanup === "function") {
3048
3352
  slot.cleanup = cleanup;
3049
3353
  }
@@ -3093,20 +3397,25 @@ function runLayoutEffects(q) {
3093
3397
  }
3094
3398
  }
3095
3399
  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);
3400
+ EFFECT_COMMIT_DEPTH++;
3401
+ try {
3402
+ drainDeferredPassiveUnmounts();
3403
+ const pending = effectQueues[PASSIVE];
3404
+ if (pending.length === 0) return;
3405
+ const q = pending.splice(0);
3406
+ q.sort(compareEffectPostOrder);
3407
+ for (let i = 0; i < q.length; i++) {
3408
+ const e = q[i];
3409
+ if (e.scope.block.disposed || e.fn !== null && inInactiveSubtree(e.scope.block)) continue;
3410
+ fireEffectCleanup(e);
3411
+ }
3412
+ for (let i = 0; i < q.length; i++) {
3413
+ const e = q[i];
3414
+ if (e.scope.block.disposed || inInactiveSubtree(e.scope.block)) continue;
3415
+ runEffectBody(e);
3416
+ }
3417
+ } finally {
3418
+ finishEffectCommit();
3110
3419
  }
3111
3420
  }
3112
3421
  function drainEffectEventCommitActions() {
@@ -3129,14 +3438,12 @@ function drainDeferredPassiveUnmounts() {
3129
3438
  const q = pendingPassiveUnmounts.splice(0);
3130
3439
  for (let i = 0; i < q.length; i += 3) {
3131
3440
  try {
3132
- runEffectCleanupCallback(q[i]);
3441
+ runEffectCleanupCallback(q[i], PASSIVE);
3133
3442
  } catch (err) {
3134
3443
  if (err instanceof MaximumUpdateDepthError) throw err;
3135
3444
  const handler = q[i + 1];
3136
3445
  const owner = q[i + 2];
3137
- if (handler !== null) {
3138
- reportCaughtError(owner, err, handler(err));
3139
- } else if (!reportUncaughtError(owner, err)) console.error(err);
3446
+ reportEffectError(owner, err, handler);
3140
3447
  }
3141
3448
  }
3142
3449
  }
@@ -3400,10 +3707,17 @@ function createBlock(kind, parentBlock, parentNode, startMarker, endMarker, body
3400
3707
  function renderBlock(block) {
3401
3708
  const hydration = activeHydration();
3402
3709
  if (hydration !== null && !hydration.owns(block)) {
3403
- hydration.suspend(() => renderBlockInner(block));
3710
+ hydration.suspend(() => renderBlock(block));
3404
3711
  return;
3405
3712
  }
3406
- renderBlockInner(block);
3713
+ let retries = 0;
3714
+ while (renderBlockInner(block)) {
3715
+ if (block.nestedUpdateError) {
3716
+ block.nestedUpdateError = false;
3717
+ throw maximumUpdateDepthError();
3718
+ }
3719
+ if (++retries > RENDER_PHASE_UPDATE_LIMIT) throw new Error(formatClientError(9));
3720
+ }
3407
3721
  }
3408
3722
  function enqueueEffectEventUpdate(entry) {
3409
3723
  EFFECT_EVENT_RENDER_TARGET.push(entry);
@@ -3428,6 +3742,45 @@ function recordCapturedRender(capture, block) {
3428
3742
  (capture.renderedBlocks ??= /* @__PURE__ */ new Set()).add(block);
3429
3743
  }
3430
3744
  }
3745
+ function beginUrgentTransitionRender(block, render) {
3746
+ const slots = /* @__PURE__ */ new Map();
3747
+ for (const entries of FLUSHED_TRANSITION_UPDATES) {
3748
+ for (const update of entries) {
3749
+ if (update.block !== block || update.superseded) continue;
3750
+ const previous = slots.get(update.slot);
3751
+ if (previous !== void 0) {
3752
+ render.cells[previous].update = update;
3753
+ } else {
3754
+ slots.set(update.slot, render.cells.length);
3755
+ render.cells.push({
3756
+ update,
3757
+ baseValue: update.baseValue,
3758
+ value: update.slot.value,
3759
+ hook: void 0
3760
+ });
3761
+ }
3762
+ }
3763
+ }
3764
+ for (const cell of render.cells) {
3765
+ cell.hook = beginUrgentTransitionCell(cell.update);
3766
+ if (cell.hook === null) cell.update.slot.value = cell.baseValue;
3767
+ }
3768
+ }
3769
+ function endUrgentTransitionRender(block, render) {
3770
+ for (let i = render.cells.length - 1; i >= 0; i--) {
3771
+ const cell = render.cells[i];
3772
+ if (cell.hook === void 0) continue;
3773
+ if (cell.hook !== null) endUrgentTransitionCell(cell.hook);
3774
+ else if (!block.disposed && !cell.update.superseded && Object.is(cell.update.slot.value, cell.baseValue))
3775
+ cell.update.slot.value = cell.value;
3776
+ }
3777
+ if (block.disposed || block.pending && block.pendingMode === "urgent") return;
3778
+ if (render.cells.length !== 0 && render.cells.every((cell) => cell.update.superseded)) return;
3779
+ block.pending = true;
3780
+ block.pendingMode = "transition";
3781
+ block.pendingDeferred = render.pendingDeferred;
3782
+ if (render.queueEpoch !== QUEUE_REINDEX_EPOCH && !QUEUE.includes(block)) QUEUE.push(block);
3783
+ }
3431
3784
  function renderBlockInner(block) {
3432
3785
  if (block.renderStatus === RENDER_INVALID) block.renderStatus = RENDER_RETRYING;
3433
3786
  if (WIP_CAPTURE !== null) recordCapturedRender(WIP_CAPTURE, block);
@@ -3451,6 +3804,8 @@ function renderBlockInner(block) {
3451
3804
  CURRENT_EFFECT_RENDER_VERSION = block.effectSlots === null ? 0 : NEXT_EFFECT_RENDER_VERSION++;
3452
3805
  CURRENT_EFFECT_REACHED = 0;
3453
3806
  const continuesParentTree = prevBlock !== null && blockIsAncestor(prevBlock, block);
3807
+ const urgentTransitionDriver = block.pending && block.pendingMode === "transition" && continuesParentTree && prevBlock.currentRenderMode === "urgent" ? TRANSITION_SWAP_DRIVER : null;
3808
+ const urgentTransitionRender = urgentTransitionDriver === null ? null : { pendingDeferred: block.pendingDeferred, queueEpoch: QUEUE_REINDEX_EPOCH, cells: [] };
3454
3809
  if (!continuesParentTree) {
3455
3810
  const replayEpisode = prevBlock === null && RESUME_REPLAY ? block.__warmEpisode : void 0;
3456
3811
  CURRENT_WARM_EPISODE = typeof replayEpisode === "number" ? replayEpisode : NEXT_WARM_EPISODE++;
@@ -3462,6 +3817,7 @@ function renderBlockInner(block) {
3462
3817
  EFFECT_EVENT_ACTION_TARGET = effectEventActionTarget;
3463
3818
  if (block.effectEventRenderVersion !== 0) block.effectEventRenderVersion++;
3464
3819
  block.pending = false;
3820
+ block.crossRenderUpdate = false;
3465
3821
  block.__thenableIdx = 0;
3466
3822
  {
3467
3823
  const tState = block.__thenables;
@@ -3472,22 +3828,29 @@ function renderBlockInner(block) {
3472
3828
  }
3473
3829
  if (block.$$ctxReads !== null) block.$$ctxReads.clear();
3474
3830
  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;
3831
+ block.currentRenderMode = urgentTransitionRender !== null ? "urgent" : block.pendingMode ?? prevBlock?.currentRenderMode ?? "urgent";
3832
+ block.currentRenderDeferred = urgentTransitionRender !== null ? false : block.pendingMode !== null ? block.pendingDeferred : prevBlock?.currentRenderDeferred ?? false;
3477
3833
  block.pendingMode = null;
3478
3834
  block.pendingDeferred = false;
3479
3835
  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
3836
  let profileDidThrow = false;
3481
3837
  let profileThrown;
3482
3838
  let renderCompleted = false;
3839
+ let renderRetry = false;
3483
3840
  NATIVE_READ_DRIVER?.beginRender(block);
3484
3841
  NATIVE_BLOCK_RETRIES?.get(block)?.clear();
3485
3842
  try {
3843
+ if (urgentTransitionRender !== null)
3844
+ urgentTransitionDriver.beginUrgent(block, urgentTransitionRender);
3486
3845
  const out = block.body(
3487
3846
  block.props,
3488
3847
  block,
3489
3848
  block.extra
3490
3849
  );
3850
+ if (block.pending && !block.crossRenderUpdate) {
3851
+ renderRetry = true;
3852
+ return true;
3853
+ }
3491
3854
  if (out !== void 0 && block.outputHandler !== null) block.outputHandler(block, out);
3492
3855
  finishEffectRender(block);
3493
3856
  if (!block.mounted) block.mounted = true;
@@ -3513,6 +3876,7 @@ function renderBlockInner(block) {
3513
3876
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__ && profileFrame !== null)
3514
3877
  __profileEndRender(profileFrame, profileDidThrow, profileThrown);
3515
3878
  if (!renderCompleted) {
3879
+ if (renderRetry) block.renderStatus = RENDER_INVALID;
3516
3880
  if (block.renderStatus !== RENDER_INVALID) {
3517
3881
  let owner = null;
3518
3882
  const suspension = isSuspenseException(profileThrown);
@@ -3538,7 +3902,12 @@ function renderBlockInner(block) {
3538
3902
  CURRENT_EFFECT_REACHED = prevEffectReached;
3539
3903
  CURRENT_SCOPE = prevScope;
3540
3904
  CURRENT_BLOCK = prevBlock;
3541
- NATIVE_READ_DRIVER?.endRender(block, renderCompleted, isSuspenseException(profileThrown));
3905
+ try {
3906
+ NATIVE_READ_DRIVER?.endRender(block, renderCompleted, isSuspenseException(profileThrown));
3907
+ } finally {
3908
+ if (urgentTransitionRender !== null)
3909
+ urgentTransitionDriver.endUrgent(block, urgentTransitionRender);
3910
+ }
3542
3911
  }
3543
3912
  }
3544
3913
  function returnSlotTail(block, state) {
@@ -3745,6 +4114,7 @@ class LiteBlockImpl {
3745
4114
  }
3746
4115
  }
3747
4116
  function componentSlotLite(parentScope, slotKey, host, comp, props, anchor) {
4117
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
3748
4118
  const hydration = activeHydration();
3749
4119
  let scope = parentScope.slots[slotKey];
3750
4120
  let adoptedOpen = null;
@@ -3908,7 +4278,7 @@ function unmountScope(scope, detachDom = true) {
3908
4278
  if (!passiveScheduled) schedulePassiveFlush();
3909
4279
  } else {
3910
4280
  try {
3911
- runEffectCleanupCallback(cleanup);
4281
+ runEffectCleanupCallback(cleanup, slot.phase);
3912
4282
  } catch (err) {
3913
4283
  reportTeardownError(err);
3914
4284
  }
@@ -3983,12 +4353,66 @@ function missingSlot(name) {
3983
4353
  throw new Error(formatClientError(15, name));
3984
4354
  }
3985
4355
  const slotStack = [];
4356
+ let MANUAL_HOOK_DRIVER = null;
4357
+ function invokeManualHook(fn, receiver, args) {
4358
+ const driver = MANUAL_HOOK_DRIVER ??= {
4359
+ pending: slotStack[slotStack.length - 1],
4360
+ active: false
4361
+ };
4362
+ const pending = driver.pending;
4363
+ const active = driver.active;
4364
+ driver.pending = void 0;
4365
+ driver.active = true;
4366
+ try {
4367
+ if (pending === void 0) return Reflect.apply(fn, receiver, args);
4368
+ switch (args.length) {
4369
+ case 0:
4370
+ return fn.call(receiver, pending);
4371
+ case 1:
4372
+ return fn.call(receiver, args[0], pending);
4373
+ case 2:
4374
+ return fn.call(receiver, args[0], args[1], pending);
4375
+ case 3:
4376
+ return fn.call(receiver, args[0], args[1], args[2], pending);
4377
+ case 4:
4378
+ return fn.call(receiver, args[0], args[1], args[2], args[3], pending);
4379
+ default: {
4380
+ const forwarded = new Array(args.length + 1);
4381
+ for (let index = 0; index < args.length; index++) forwarded[index] = args[index];
4382
+ forwarded[args.length] = pending;
4383
+ return fn.apply(receiver, forwarded);
4384
+ }
4385
+ }
4386
+ } finally {
4387
+ driver.pending = pending;
4388
+ driver.active = active;
4389
+ }
4390
+ }
4391
+ function manualHook(fn, name) {
4392
+ function provider() {
4393
+ return invokeManualHook(fn, this, arguments);
4394
+ }
4395
+ Object.defineProperty(provider, "name", { value: name ?? fn.name, configurable: true });
4396
+ Object.defineProperty(provider, "length", { value: fn.length, configurable: true });
4397
+ return provider;
4398
+ }
3986
4399
  function withSlot(sym, fn, ...args) {
4400
+ const driver = MANUAL_HOOK_DRIVER;
4401
+ const pending = driver?.pending;
4402
+ const active = driver?.active ?? false;
4403
+ if (driver !== null) {
4404
+ driver.pending = sym;
4405
+ driver.active = false;
4406
+ }
3987
4407
  slotStack.push(sym);
3988
4408
  try {
3989
4409
  return fn(...args);
3990
4410
  } finally {
3991
4411
  slotStack.pop();
4412
+ if (MANUAL_HOOK_DRIVER !== null) {
4413
+ MANUAL_HOOK_DRIVER.pending = driver === null ? slotStack[slotStack.length - 1] : pending;
4414
+ MANUAL_HOOK_DRIVER.active = active;
4415
+ }
3992
4416
  }
3993
4417
  }
3994
4418
  function appendSlotKey(key, slot) {
@@ -4019,7 +4443,7 @@ function nativeLocalHook(name, initialize, dispose, slot) {
4019
4443
  return cell.nativeValue;
4020
4444
  }
4021
4445
  function useState(initial, slot) {
4022
- if (slot === void 0 && typeof initial === "symbol") {
4446
+ if (slot === void 0 && typeof initial === "symbol" && arguments.length === 1 && (slotStack.length === 0 || MANUAL_HOOK_DRIVER?.active === true)) {
4023
4447
  slot = initial;
4024
4448
  initial = void 0;
4025
4449
  }
@@ -4033,16 +4457,44 @@ function useState(initial, slot) {
4033
4457
  s = {
4034
4458
  value: initVal,
4035
4459
  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)) {
4460
+ if (block.disposed) return;
4461
+ if (s.pendingActionBatch !== void 0 && transitionActionBatchForUpdate() === null)
4462
+ recordUrgentActionUpdate(s, next);
4463
+ 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) {
4464
+ (s.updates ??= []).push(next);
4465
+ scheduleRender(block);
4466
+ return;
4467
+ }
4468
+ const previous = stagedTransitionValue(s, block);
4469
+ let computed;
4470
+ let failed = false;
4471
+ try {
4472
+ computed = typeof next === "function" ? next(previous) : next;
4473
+ } catch {
4474
+ if (transitionActionBatchForUpdate() === null) {
4475
+ (s.updates ??= []).push(next);
4476
+ scheduleRender(block);
4477
+ return;
4478
+ }
4479
+ computed = previous;
4480
+ failed = true;
4481
+ }
4482
+ const forceRender = failed || s.updates !== void 0 || s.renderTransition !== void 0 || s.pendingActionBatch !== void 0 || block.pending && typeof next === "function";
4483
+ if (Object.is(computed, previous) && !forceRender) {
4484
+ if (typeof next !== "function" && TRANSITION_SWAP_DRIVER?.cancelEqual(s, block)) {
4485
+ scheduleRender(block);
4486
+ }
4487
+ return;
4488
+ }
4489
+ const update = stageTransitionValue(s, block, next, computed, forceRender);
4490
+ if (update !== null) {
4491
+ if (update.state === void 0) {
4492
+ update.state = s;
4493
+ captureTransitionHookQueue(update, s);
4494
+ }
4040
4495
  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
- }
4496
+ update.profileType = "state";
4497
+ update.profileSlot = slot;
4046
4498
  }
4047
4499
  return;
4048
4500
  }
@@ -4054,10 +4506,95 @@ function useState(initial, slot) {
4054
4506
  };
4055
4507
  ensureHooks(scope).set(slot, s);
4056
4508
  }
4509
+ if (s.renderTransition !== void 0 || s.updates !== void 0) {
4510
+ const value = readQueuedState(s);
4511
+ if (!s.urgentTransition && s.updates !== void 0 && Object.is(value, s.value))
4512
+ TRANSITION_SWAP_DRIVER?.rebaseHeld(s, block, s.updates);
4513
+ s.value = value;
4514
+ if (!s.urgentTransition) {
4515
+ if (s.renderTransition !== void 0) {
4516
+ finishQueuedTransition(s.renderTransition, s.value);
4517
+ s.renderTransition = void 0;
4518
+ }
4519
+ s.updates = void 0;
4520
+ }
4521
+ }
4057
4522
  return [s.value, s.setter];
4058
4523
  }
4524
+ function readQueuedState(state) {
4525
+ const transition = state.renderTransition;
4526
+ let value = transition === void 0 ? state.value : readQueuedTransition(transition, state.urgentTransition === true);
4527
+ if (state.updates !== void 0) {
4528
+ for (const update of state.updates)
4529
+ value = typeof update === "function" ? update(value) : update;
4530
+ }
4531
+ return value;
4532
+ }
4533
+ function readQueuedTransition(last, urgent, reducer) {
4534
+ let first = last;
4535
+ while (first.previous !== void 0) first = first.previous;
4536
+ let value = first.replayBaseValue;
4537
+ for (let entry = first; ; entry = entry.next) {
4538
+ if (entry.stateUpdates !== void 0) {
4539
+ for (const update of entry.stateUpdates)
4540
+ value = typeof update === "function" ? update(value) : update;
4541
+ }
4542
+ if (entry.reducerActions !== void 0) {
4543
+ for (const action of entry.reducerActions) value = reducer(value, action);
4544
+ }
4545
+ if ((urgent || entry.superseded) && entry.urgentOperations !== void 0) {
4546
+ for (const index of entry.urgentOperations) value = entry.operations[index](value);
4547
+ } else if (!urgent && !entry.superseded) {
4548
+ for (const operation of entry.operations) value = operation(value);
4549
+ }
4550
+ if (entry === last) return value;
4551
+ }
4552
+ }
4553
+ function captureTransitionHookQueue(update, cell) {
4554
+ update.replayBaseValue = cell.value;
4555
+ const previous = cell.renderTransition ?? TRANSITION_SWAP_DRIVER?.heldUpdate(cell, update.block);
4556
+ if (previous !== void 0) {
4557
+ update.previous = previous;
4558
+ previous.next = update;
4559
+ }
4560
+ if (update.state !== void 0) update.stateUpdates = update.state.updates?.slice();
4561
+ else update.reducerActions = update.reducer.renderPhaseActions?.slice();
4562
+ }
4563
+ function recordUrgentActionUpdate(cell, operation) {
4564
+ const update = cell.pendingActionBatch.updates.get(cell);
4565
+ if (update === void 0) return;
4566
+ (update.urgentOperations ??= []).push(update.operations.length);
4567
+ update.operations.push(
4568
+ typeof operation === "function" ? operation : () => operation
4569
+ );
4570
+ update.forceRender = true;
4571
+ }
4572
+ function finishQueuedTransition(last, value) {
4573
+ for (let entry = last; entry; entry = entry.previous) {
4574
+ entry.value = value;
4575
+ if (entry !== last && Object.is(value, entry.baseValue)) entry.superseded = true;
4576
+ }
4577
+ }
4578
+ function beginUrgentTransitionCell(update) {
4579
+ const cell = update.state ?? update.reducer;
4580
+ if (update.block.disposed || update.superseded || cell === void 0 || cell.renderTransition === void 0)
4581
+ return null;
4582
+ cell.urgentTransition = true;
4583
+ cell.value = update.baseValue;
4584
+ return { update, cell };
4585
+ }
4586
+ function endUrgentTransitionCell(snapshot) {
4587
+ const { update, cell } = snapshot;
4588
+ cell.urgentTransition = false;
4589
+ if (update.block.disposed || update.superseded) {
4590
+ cell.renderTransition = void 0;
4591
+ return;
4592
+ }
4593
+ for (let entry = update; entry; entry = entry.previous)
4594
+ entry.baseValue = cell.value;
4595
+ }
4059
4596
  function __useStateWithGetter(initial, slot) {
4060
- if (slot === void 0 && typeof initial === "symbol") {
4597
+ if (slot === void 0 && typeof initial === "symbol" && arguments.length === 1 && (slotStack.length === 0 || MANUAL_HOOK_DRIVER?.active === true)) {
4061
4598
  slot = initial;
4062
4599
  initial = void 0;
4063
4600
  }
@@ -4067,9 +4604,9 @@ function __useStateWithGetter(initial, slot) {
4067
4604
  const s = CURRENT_SCOPE.hooks.get(resolved);
4068
4605
  const getter = s.getter ?? (s.getter = () => {
4069
4606
  const batch = s.pendingActionBatch;
4070
- if (batch === void 0) return s.value;
4607
+ if (batch === void 0) return readQueuedState(s);
4071
4608
  const update = batch.updates.get(s);
4072
- return update === void 0 ? s.value : rebaseTransitionActionUpdate(update);
4609
+ return update === void 0 ? readQueuedState(s) : readQueuedTransition(update, false);
4073
4610
  });
4074
4611
  return [pair[0], pair[1], getter];
4075
4612
  }
@@ -4169,13 +4706,11 @@ function useLinkedState(source, reconcile, options, slot) {
4169
4706
  else scheduleRender(block);
4170
4707
  return;
4171
4708
  }
4172
- if (stageTransitionValue(state, block, operation, computed)) {
4709
+ const update = stageTransitionValue(state, block, operation, computed);
4710
+ if (update !== null) {
4173
4711
  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
- }
4712
+ update.profileType = "state";
4713
+ update.profileSlot = slot;
4179
4714
  }
4180
4715
  return;
4181
4716
  }
@@ -4293,26 +4828,31 @@ function useReducer(reducer, initialArg, initOrSlot, slot) {
4293
4828
  // the component once (children then bail as usual). Per
4294
4829
  // ReactHooksWithNoopRenderer-test.js:3889.
4295
4830
  dispatch: (action) => {
4296
- if (CURRENT_BLOCK === block) {
4831
+ if (block.disposed) return;
4832
+ if (CURRENT_BLOCK === block || transitionActionBatchForUpdate() === null) {
4833
+ if (s.pendingActionBatch !== void 0 && transitionActionBatchForUpdate() === null)
4834
+ recordUrgentActionUpdate(s, (value) => s.reducer(value, action));
4297
4835
  const actions = s.renderPhaseActions ??= [];
4298
- const previous2 = actions.length === 0 ? s.value : s.renderPhaseValue;
4299
4836
  actions.push(action);
4300
- if (s.getter !== void 0) {
4301
- s.renderPhaseValue = s.reducer(previous2, action);
4302
- }
4303
4837
  scheduleRender(block);
4304
4838
  return;
4305
4839
  }
4306
- const previous = stagedTransitionValue(s);
4840
+ const previous = stagedTransitionValue(s, block);
4307
4841
  const operation = (value) => s.reducer(value, action);
4308
- const computed = operation(previous);
4309
- if (stageTransitionValue(s, block, operation, computed, true)) {
4842
+ let computed = previous;
4843
+ try {
4844
+ computed = operation(previous);
4845
+ } catch {
4846
+ }
4847
+ const update = stageTransitionValue(s, block, operation, computed, true);
4848
+ if (update !== null) {
4849
+ if (update.reducer === void 0) {
4850
+ update.reducer = s;
4851
+ captureTransitionHookQueue(update, s);
4852
+ }
4310
4853
  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
- }
4854
+ update.profileType = "reducer";
4855
+ update.profileSlot = slot;
4316
4856
  }
4317
4857
  return;
4318
4858
  }
@@ -4325,17 +4865,32 @@ function useReducer(reducer, initialArg, initOrSlot, slot) {
4325
4865
  ensureHooks(scope).set(slot, s);
4326
4866
  } else {
4327
4867
  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]);
4868
+ if (s.renderTransition !== void 0 || s.renderPhaseActions !== void 0) {
4869
+ const value = readQueuedReducer(s);
4870
+ if (!s.urgentTransition && s.renderPhaseActions !== void 0 && Object.is(value, s.value))
4871
+ TRANSITION_SWAP_DRIVER?.rebaseHeld(s, block, s.renderPhaseActions, reducer);
4332
4872
  s.value = value;
4333
- s.renderPhaseActions = void 0;
4334
- s.renderPhaseValue = void 0;
4873
+ if (!s.urgentTransition) {
4874
+ if (s.renderTransition !== void 0) {
4875
+ finishQueuedTransition(s.renderTransition, s.value);
4876
+ s.renderTransition = void 0;
4877
+ }
4878
+ s.renderPhaseActions = void 0;
4879
+ }
4335
4880
  }
4336
4881
  }
4337
4882
  return [s.value, s.dispatch];
4338
4883
  }
4884
+ function readQueuedReducer(state) {
4885
+ let value = state.renderTransition === void 0 ? state.value : readQueuedTransition(
4886
+ state.renderTransition,
4887
+ state.urgentTransition === true,
4888
+ state.reducer
4889
+ );
4890
+ if (state.renderPhaseActions !== void 0)
4891
+ for (const action of state.renderPhaseActions) value = state.reducer(value, action);
4892
+ return value;
4893
+ }
4339
4894
  function __useReducerWithGetter(reducer, initialArg, initOrSlot, slot) {
4340
4895
  const resolvedInput = typeof initOrSlot === "symbol" ? initOrSlot : slot;
4341
4896
  const pair = useReducer(reducer, initialArg, initOrSlot, slot);
@@ -4343,18 +4898,26 @@ function __useReducerWithGetter(reducer, initialArg, initOrSlot, slot) {
4343
4898
  if (resolved === void 0) missingSlot("useReducer");
4344
4899
  const s = CURRENT_SCOPE.hooks.get(resolved);
4345
4900
  const getter = s.getter ?? (s.getter = () => {
4346
- if (s.renderPhaseActions !== void 0) return s.renderPhaseValue;
4347
4901
  const batch = s.pendingActionBatch;
4348
- if (batch === void 0) return s.value;
4902
+ if (batch === void 0) return readQueuedReducer(s);
4349
4903
  const update = batch.updates.get(s);
4350
- return update === void 0 ? s.value : rebaseTransitionActionUpdate(update);
4904
+ return update === void 0 ? readQueuedReducer(s) : readQueuedTransition(update, false, s.reducer);
4351
4905
  });
4352
4906
  return [pair[0], pair[1], getter];
4353
4907
  }
4354
- function depsChanged(prev, next) {
4908
+ function depsChanged(prev, next, hook = false) {
4355
4909
  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++) {
4910
+ let length = prev.length;
4911
+ if (length !== next.length) {
4912
+ if (!hook) return true;
4913
+ if (process.env.NODE_ENV !== "production") {
4914
+ console.error(
4915
+ `The dependency array must keep the same length between renders (previous: ${length}, next: ${next.length}).`
4916
+ );
4917
+ }
4918
+ length = Math.min(length, next.length);
4919
+ }
4920
+ for (let i = 0; i < length; i++) {
4358
4921
  if (!Object.is(prev[i], next[i])) return true;
4359
4922
  }
4360
4923
  return false;
@@ -4421,7 +4984,7 @@ function enqueueEffect(slot, fn, deps, phase) {
4421
4984
  return;
4422
4985
  }
4423
4986
  if (prev) {
4424
- const changed = depsChanged(prev.deps, deps);
4987
+ const changed = depsChanged(prev.deps, deps, true);
4425
4988
  if (prev.active && !changed) return;
4426
4989
  if (ROOT_RENDER_TRANSACTION !== null) journalObjectOnce(prev);
4427
4990
  let reactivated = false;
@@ -4525,7 +5088,7 @@ function adoptMemoEntry(scope, slot, deps) {
4525
5088
  }
4526
5089
  function readMemoEntry(scope, slot, deps) {
4527
5090
  const prev = scope.hooks?.get(slot);
4528
- if (prev && deps !== void 0 && !depsChanged(prev.deps, deps)) {
5091
+ if (prev && deps !== void 0 && !depsChanged(prev.deps, deps, true)) {
4529
5092
  return memoEntryHit(slot, prev);
4530
5093
  }
4531
5094
  return WARM_EVER && deps !== void 0 ? adoptMemoEntry(scope, slot, deps) : null;
@@ -4540,12 +5103,21 @@ function publishMemoEntry(scope, slot, deps, value, nativeWitness) {
4540
5103
  }
4541
5104
  return value;
4542
5105
  }
5106
+ let devMemoComputeDepth = 0;
5107
+ function computeMemoWithDiagnostics(compute, deps) {
5108
+ devMemoComputeDepth++;
5109
+ try {
5110
+ return compute.apply(null, deps ?? []);
5111
+ } finally {
5112
+ devMemoComputeDepth--;
5113
+ }
5114
+ }
4543
5115
  function useMemo(compute, deps, slot) {
4544
5116
  const [d, s] = resolveHookArgs("useMemo", deps, slot);
4545
5117
  const scope = CURRENT_SCOPE;
4546
5118
  const entry = readMemoEntry(scope, s, d);
4547
5119
  if (entry !== null) return entry.value;
4548
- const value = compute.apply(null, d ?? []);
5120
+ const value = process.env.NODE_ENV !== "production" ? computeMemoWithDiagnostics(compute, d) : compute.apply(null, d ?? []);
4549
5121
  return publishMemoEntry(scope, s, d, value);
4550
5122
  }
4551
5123
  function useCallback(fn, deps, slot) {
@@ -4617,7 +5189,7 @@ function hookMemoPublishInvariant(cells, base, value) {
4617
5189
  return value;
4618
5190
  }
4619
5191
  function useRef(initial, slot) {
4620
- if (slot === void 0 && typeof initial === "symbol") {
5192
+ if (slot === void 0 && typeof initial === "symbol" && arguments.length === 1 && (slotStack.length === 0 || MANUAL_HOOK_DRIVER?.active === true)) {
4621
5193
  slot = initial;
4622
5194
  initial = void 0;
4623
5195
  }
@@ -4731,13 +5303,33 @@ function subscribeToStore(inst, subscribe) {
4731
5303
  if (checkStoreChanged(inst)) inst.forceUpdate();
4732
5304
  return subscribe(inst.onStoreChange);
4733
5305
  }
5306
+ function scheduleStoreRender(block) {
5307
+ const depth = TRANSITION_DEPTH;
5308
+ const asyncCount = ASYNC_TRANSITION_COUNT;
5309
+ TRANSITION_DEPTH = 0;
5310
+ ASYNC_TRANSITION_COUNT = 0;
5311
+ try {
5312
+ scheduleRender(block);
5313
+ } finally {
5314
+ TRANSITION_DEPTH = depth;
5315
+ ASYNC_TRANSITION_COUNT = asyncCount;
5316
+ }
5317
+ }
5318
+ let DID_WARN_UNCACHED_SNAPSHOT = false;
4734
5319
  function useSyncExternalStore(subscribe, getSnapshot, ...rest) {
4735
5320
  let slot = rest[rest.length - 1];
4736
5321
  slot = resolveSlot(slot);
4737
5322
  if (slot === void 0) missingSlot("useSyncExternalStore");
4738
5323
  const getServerSnapshot = rest.length >= 2 ? rest[0] : void 0;
4739
5324
  const subs = usesSubslots(slot);
4740
- const value = activeHydration() !== null && getServerSnapshot !== void 0 ? getServerSnapshot() : getSnapshot();
5325
+ const readSnapshot = activeHydration() !== null && getServerSnapshot !== void 0 ? getServerSnapshot : getSnapshot;
5326
+ const value = readSnapshot();
5327
+ if (process.env.NODE_ENV !== "production" && !DID_WARN_UNCACHED_SNAPSHOT && !Object.is(value, readSnapshot())) {
5328
+ DID_WARN_UNCACHED_SNAPSHOT = true;
5329
+ console.error(
5330
+ "The " + (readSnapshot === getSnapshot ? "getSnapshot" : "getServerSnapshot") + " result must be cached to avoid an infinite update loop."
5331
+ );
5332
+ }
4741
5333
  const scope = CURRENT_SCOPE;
4742
5334
  let inst = scope.hooks?.get(subs.inst);
4743
5335
  if (inst === void 0) {
@@ -4749,11 +5341,11 @@ function useSyncExternalStore(subscribe, getSnapshot, ...rest) {
4749
5341
  subscribe,
4750
5342
  forceUpdate: typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__ ? () => {
4751
5343
  if (!block.disposed) __profileSchedule(block, "external-store", slot);
4752
- scheduleRender(block);
4753
- } : () => scheduleRender(block),
5344
+ scheduleStoreRender(block);
5345
+ } : () => scheduleStoreRender(block),
4754
5346
  onStoreChange: () => {
4755
5347
  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)) {
5348
+ 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
5349
  return;
4758
5350
  }
4759
5351
  if (checkStoreChanged(created)) created.forceUpdate();
@@ -5917,7 +6509,8 @@ const Suspense = /* @__PURE__ */ markComponentFlags(
5917
6509
  );
5918
6510
  },
5919
6511
  COMPONENT_FLAG_BOUNDARY,
5920
- "Suspense"
6512
+ "Suspense",
6513
+ /* @__PURE__ */ Symbol.for("octane.suspense")
5921
6514
  );
5922
6515
  function initializeViewTransitionComponent() {
5923
6516
  return markComponentFlags(
@@ -5964,6 +6557,11 @@ const ErrorBoundary = /* @__PURE__ */ markComponentFlags(
5964
6557
  );
5965
6558
  const TsrxErrorBoundary = ErrorBoundary;
5966
6559
  function use(usable) {
6560
+ if (process.env.NODE_ENV !== "production" && devMemoComputeDepth !== 0) {
6561
+ console.error(
6562
+ "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."
6563
+ );
6564
+ }
5967
6565
  if (usable && usable.$$kind === CONTEXT_TAG) {
5968
6566
  return useContextInternal(usable);
5969
6567
  }
@@ -6664,6 +7262,15 @@ function warmChild(comp, props) {
6664
7262
  WARM_DEPTH--;
6665
7263
  }
6666
7264
  }
7265
+ function markWarm(component, plan) {
7266
+ Object.defineProperty(component, "__warm", {
7267
+ configurable: true,
7268
+ get() {
7269
+ return this === component ? plan : void 0;
7270
+ }
7271
+ });
7272
+ return component;
7273
+ }
6667
7274
  function adoptWarmEntry(slot, deps, accept) {
6668
7275
  let b = CURRENT_BLOCK;
6669
7276
  while (b !== null) {
@@ -6962,6 +7569,8 @@ function lazy(load) {
6962
7569
  let thenable = null;
6963
7570
  let profiledComponent = null;
6964
7571
  let memoMetadataInstalled = false;
7572
+ let displayName;
7573
+ let resolvedName = "Lazy";
6965
7574
  let lazyWrapper;
6966
7575
  const initializeLazy = () => {
6967
7576
  if (status !== "uninitialized") return;
@@ -6994,16 +7603,23 @@ function lazy(load) {
6994
7603
  };
6995
7604
  const callResolvedComponent = (props, scope, extra) => {
6996
7605
  const comp = resolveLazyModule(result);
7606
+ resolvedName = comp.displayName || comp.name || "Lazy";
6997
7607
  if (comp.__memo === true) {
6998
7608
  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
- };
7609
+ Object.defineProperty(lazyWrapper, "__memo", {
7610
+ get() {
7611
+ return this === lazyWrapper;
7612
+ }
7613
+ });
7614
+ Object.defineProperty(lazyWrapper, "__compare", {
7615
+ value: (prev, next) => {
7616
+ const current = resolveLazyModule(result);
7617
+ const compare = current.__compare;
7618
+ const previous = lazyResolvedProps(current, prev);
7619
+ const incoming = lazyResolvedProps(current, next);
7620
+ return compare ? compare(previous, incoming) : shallowEqualProps(previous, incoming);
7621
+ }
7622
+ });
7007
7623
  memoMetadataInstalled = true;
7008
7624
  }
7009
7625
  scope.block.memoInChain = true;
@@ -7033,10 +7649,22 @@ function lazy(load) {
7033
7649
  }
7034
7650
  if (settledStatus === "rejected") throw result;
7035
7651
  }
7652
+ runActiveWarmPlans();
7036
7653
  throw new SuspenseException(thenable);
7037
7654
  };
7038
- lazyWrapper.__warm = initializeLazy;
7039
- Object.defineProperty(lazyWrapper, LAZY_COMPONENT, { value: true });
7655
+ markWarm(lazyWrapper, initializeLazy);
7656
+ Object.defineProperty(lazyWrapper, LAZY_COMPONENT, {
7657
+ get() {
7658
+ return this === lazyWrapper;
7659
+ }
7660
+ });
7661
+ Object.defineProperty(lazyWrapper, "displayName", {
7662
+ configurable: true,
7663
+ get: () => displayName ?? resolvedName,
7664
+ set: (value) => {
7665
+ displayName = value;
7666
+ }
7667
+ });
7040
7668
  return lazyWrapper;
7041
7669
  }
7042
7670
  function useId(slot) {
@@ -7248,6 +7876,7 @@ class HydrationCapability {
7248
7876
  warnHydrationStructuralMismatch(loc, expected, actual);
7249
7877
  }
7250
7878
  recordTextMismatch(node, loc, server) {
7879
+ if (process.env.NODE_ENV === "production" && ROOT_ERROR_HANDLERS === null) return;
7251
7880
  if (!this.textWarnings.has(node)) this.textWarnings.set(node, { loc, server });
7252
7881
  }
7253
7882
  flushTextWarnings() {
@@ -7255,7 +7884,9 @@ class HydrationCapability {
7255
7884
  if (!this.rootBlock.parentNode.contains(node)) continue;
7256
7885
  const client = node.nodeValue;
7257
7886
  if (pending.server !== client) {
7258
- warnHydrationValueMismatch(pending.loc, "text", pending.server, client);
7887
+ noteRecoverableHydrationError(() => new Error(formatClientError(61)), this.rootBlock);
7888
+ if (process.env.NODE_ENV !== "production")
7889
+ warnHydrationValueMismatch(pending.loc, "text", pending.server, client);
7259
7890
  }
7260
7891
  }
7261
7892
  this.textWarnings.clear();
@@ -7514,10 +8145,20 @@ class HydrationCapability {
7514
8145
  if (first !== null && first.nodeType === 3) {
7515
8146
  const server = first.nodeValue;
7516
8147
  if (server !== text && !isTextParserNormalizedMatch(server, text) && !isHydrationSuppressed(el)) {
7517
- if (process.env.NODE_ENV !== "production")
7518
- this.recordTextMismatch(first, loc || el.__oct_loc, server);
8148
+ this.recordTextMismatch(first, loc || el.__oct_loc, server);
7519
8149
  first.nodeValue = text;
7520
8150
  }
8151
+ if (first.nextSibling !== null) {
8152
+ noteRecoverableHydrationError(() => new Error(formatClientError(62)), this.rootBlock);
8153
+ if (process.env.NODE_ENV !== "production") {
8154
+ warnHydrationStructuralMismatch(
8155
+ loc || el.__oct_loc,
8156
+ "the end of the text element",
8157
+ describeHydrationNode(first.nextSibling)
8158
+ );
8159
+ }
8160
+ while (first.nextSibling !== null) el.removeChild(first.nextSibling);
8161
+ }
7521
8162
  return first;
7522
8163
  }
7523
8164
  if (this.isOpen(first)) {
@@ -7539,8 +8180,7 @@ class HydrationCapability {
7539
8180
  if (server !== text && !isTextParserNormalizedMatch(server, text)) {
7540
8181
  const host2 = posNode.parentNode;
7541
8182
  if (!isHydrationSuppressed(host2)) {
7542
- if (process.env.NODE_ENV !== "production")
7543
- this.recordTextMismatch(posNode, host2 && host2.__oct_loc, server);
8183
+ this.recordTextMismatch(posNode, host2 && host2.__oct_loc, server);
7544
8184
  posNode.nodeValue = text;
7545
8185
  }
7546
8186
  }
@@ -8727,6 +9367,7 @@ function attrNamespace(name) {
8727
9367
  return null;
8728
9368
  }
8729
9369
  function setAttribute(el, name, value) {
9370
+ if (name === "innerText" || name === "textContent") return;
8730
9371
  if (process.env.NODE_ENV !== "production" && el.__oct_loc !== void 0 && !isHtmlCustomElement(el) && typeof el.__oct_custom_is !== "string") {
8731
9372
  const warning = isAriaAttributeName(name) ? ariaAttributeWarning(name, el.localName) : hostPropertyWarning(name, value, el.localName, el.namespaceURI === SVG_NS);
8732
9373
  if (warning !== null) devWarnAttributeOnce(el, name, warning);
@@ -8764,6 +9405,10 @@ function setAttribute(el, name, value) {
8764
9405
  break;
8765
9406
  case 8:
8766
9407
  if ((name === "multiple" || name === "selected") && !isHtmlCustomElement(el)) {
9408
+ if (name === "selected") {
9409
+ const hydration2 = activeHydration();
9410
+ if (hydration2 !== null && !hydration2.isFresh(el)) return;
9411
+ }
8767
9412
  el[name] = value && typeof value !== "function" && typeof value !== "symbol";
8768
9413
  return;
8769
9414
  }
@@ -8947,7 +9592,7 @@ function setAriaAttribute(el, name, value) {
8947
9592
  const warning = ariaAttributeWarning(name, el.localName);
8948
9593
  if (warning !== null) devWarnAttributeOnce(el, name, warning);
8949
9594
  }
8950
- const next = value == null ? null : String(value);
9595
+ const next = value == null || typeof value === "function" || typeof value === "symbol" ? null : String(value);
8951
9596
  const hydration = activeHydration();
8952
9597
  if (hydration !== null && !hydration.allowAttribute(el, name, next)) return;
8953
9598
  if (TRANSITION_JOURNAL !== null) journalAttr(el, name);
@@ -8956,7 +9601,7 @@ function setAriaAttribute(el, name, value) {
8956
9601
  }
8957
9602
  function coerceAttrValue(el, name, value) {
8958
9603
  if (name.charCodeAt(0) === 97 && name.startsWith("aria-")) {
8959
- return value == null ? null : String(value);
9604
+ return value == null || typeof value === "function" || typeof value === "symbol" ? null : String(value);
8960
9605
  }
8961
9606
  const t = typeof value;
8962
9607
  if (t === "boolean" && isEnumeratedBooleanAttr(name)) return value ? "true" : "false";
@@ -9004,6 +9649,7 @@ function coerceAttrValue(el, name, value) {
9004
9649
  if (POSITIVE_NUMERIC_ATTR_PROPS.has(lower) && !(Number(value) >= 1)) {
9005
9650
  return null;
9006
9651
  }
9652
+ if ((lower === "rowspan" || lower === "start") && Number.isNaN(Number(value))) return null;
9007
9653
  if (name.length > 2 && name.charCodeAt(0) === 111 && name.charCodeAt(1) === 110) {
9008
9654
  return null;
9009
9655
  }
@@ -9097,7 +9743,9 @@ function setStyleProperty(el, name, value, staticCss, previous) {
9097
9743
  }
9098
9744
  function applyStyleValue(el, style, value, prev) {
9099
9745
  if (value == null || value === false || value === "") {
9100
- if (prev != null && prev !== false && prev !== "") style.cssText = "";
9746
+ if (prev && typeof prev === "object") {
9747
+ for (const key in prev) style.removeProperty(styleName(key));
9748
+ } else if (typeof prev === "string") style.cssText = "";
9101
9749
  return;
9102
9750
  }
9103
9751
  if (typeof value === "string") {
@@ -9154,10 +9802,13 @@ function isEventKey(k) {
9154
9802
  const CAPTURE_PREFIX = "$$capture:";
9155
9803
  function jsxEventName(rest) {
9156
9804
  if (rest === "DoubleClick") return "dblclick";
9805
+ if (rest === "Focus") return "focusin";
9806
+ if (rest === "Blur") return "focusout";
9157
9807
  return rest.toLowerCase();
9158
9808
  }
9159
- function eventSlot(name) {
9160
- if (!isEventKey(name)) return null;
9809
+ function eventSlot(name, el) {
9810
+ if (!isEventKey(name) || el !== void 0 && isHtmlCustomElement(el) && !isDelegatedEventProp(name))
9811
+ return null;
9161
9812
  let rest = name.slice(2);
9162
9813
  let capture = false;
9163
9814
  if (rest.length > 7 && rest.endsWith("Capture") && name !== "onGotPointerCapture" && name !== "onLostPointerCapture") {
@@ -9194,7 +9845,7 @@ function removeHostProp(el, name, prevValue) {
9194
9845
  );
9195
9846
  return;
9196
9847
  }
9197
- const ev = eventSlot(name);
9848
+ const ev = eventSlot(name, el);
9198
9849
  if (ev) setEventHandler(el, ev.key, null);
9199
9850
  else setAttribute(el, name, null);
9200
9851
  }
@@ -9211,8 +9862,8 @@ function snapshotSpread(value) {
9211
9862
  return snapshot;
9212
9863
  }
9213
9864
  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"))
9865
+ if (name === "action" && el.localName === "form") return "action";
9866
+ if ((name === "formAction" || name === "formaction") && (el.localName === "button" || el.localName === "input"))
9216
9867
  return "formaction";
9217
9868
  return null;
9218
9869
  }
@@ -9300,7 +9951,7 @@ function setSpread(el, value, prev, mountScope, skipDangerouslySetInnerHTML = fa
9300
9951
  devValidateHostProps(el, Object(value));
9301
9952
  }
9302
9953
  if (value != null && Object.prototype.propertyIsEnumerable.call(Object(value), "suppressHydrationWarning")) {
9303
- el.__oct_suppress = value.suppressHydrationWarning !== false;
9954
+ el.__oct_suppress = value.suppressHydrationWarning === true;
9304
9955
  }
9305
9956
  if (process.env.NODE_ENV !== "production" && value != null && Object.prototype.propertyIsEnumerable.call(Object(value), "suppressNativeChangeWarning")) {
9306
9957
  el.__oct_native_change_suppressed = value.suppressNativeChangeWarning === true;
@@ -9374,7 +10025,7 @@ function setSpread(el, value, prev, mountScope, skipDangerouslySetInnerHTML = fa
9374
10025
  );
9375
10026
  continue;
9376
10027
  }
9377
- const ev = eventSlot(k);
10028
+ const ev = eventSlot(k, el);
9378
10029
  if (ev) {
9379
10030
  if (v === pv) continue;
9380
10031
  if (ev.capture) {
@@ -9406,9 +10057,9 @@ function removeHeadEventListeners(state, attrs) {
9406
10057
  handlers.delete(name);
9407
10058
  }
9408
10059
  }
9409
- function adoptServerHeadEl(key, tag) {
10060
+ function adoptServerHeadEl(head, key, tag) {
9410
10061
  const closeKey = "/" + key;
9411
- for (let n = document.head.firstChild; n !== null; n = n.nextSibling) {
10062
+ for (let n = head.firstChild; n !== null; n = n.nextSibling) {
9412
10063
  if (n.nodeType === 8 && n.data === key) {
9413
10064
  let candidate = n.nextSibling;
9414
10065
  let match = null;
@@ -9444,10 +10095,13 @@ function headBlock(scope, slot, key, tag, attrs, text) {
9444
10095
  if (typeof document === "undefined") return;
9445
10096
  let state = scope.slots[slot];
9446
10097
  if (state === void 0) {
9447
- let el2 = adoptServerHeadEl(headOwnershipKey(key, rootIdentifierPrefix(scope.block)), tag);
10098
+ const parent = scope.block.parentNode;
10099
+ const ownerDocument = parent.nodeType === 9 ? parent : parent.ownerDocument;
10100
+ const head = ownerDocument.head;
10101
+ let el2 = adoptServerHeadEl(head, headOwnershipKey(key, rootIdentifierPrefix(scope.block)), tag);
9448
10102
  if (el2 === null) {
9449
- el2 = document.createElement(tag);
9450
- document.head.appendChild(el2);
10103
+ el2 = ownerDocument.createElement(tag);
10104
+ head.appendChild(el2);
9451
10105
  }
9452
10106
  state = { el: el2 };
9453
10107
  scope.slots[slot] = state;
@@ -9572,6 +10226,7 @@ function evt0(el, key, fn) {
9572
10226
  return d;
9573
10227
  }
9574
10228
  function evt0u(d, fn) {
10229
+ if (_dispatchDepth !== 0) preserveDispatchedBundle(d);
9575
10230
  if (TRANSITION_JOURNAL !== null) journalObjectOnce(d);
9576
10231
  d.fn = fn;
9577
10232
  }
@@ -9581,6 +10236,7 @@ function evt1(el, key, fn, a0) {
9581
10236
  return d;
9582
10237
  }
9583
10238
  function evt1u(d, fn, a0) {
10239
+ if (_dispatchDepth !== 0) preserveDispatchedBundle(d);
9584
10240
  if (TRANSITION_JOURNAL !== null) {
9585
10241
  journalObjectOnce(d);
9586
10242
  journalObjectOnce(d.args);
@@ -9594,6 +10250,7 @@ function evt2(el, key, fn, a0, a1) {
9594
10250
  return d;
9595
10251
  }
9596
10252
  function evt2u(d, fn, a0, a1) {
10253
+ if (_dispatchDepth !== 0) preserveDispatchedBundle(d);
9597
10254
  if (TRANSITION_JOURNAL !== null) {
9598
10255
  journalObjectOnce(d);
9599
10256
  journalObjectOnce(d.args);
@@ -9609,6 +10266,7 @@ function evtN(el, key, fn, args) {
9609
10266
  return d;
9610
10267
  }
9611
10268
  function evtNu(d, fn, args) {
10269
+ if (_dispatchDepth !== 0) preserveDispatchedBundle(d);
9612
10270
  if (TRANSITION_JOURNAL !== null) journalObjectOnce(d);
9613
10271
  d.fn = fn;
9614
10272
  d.args = args;
@@ -9949,6 +10607,28 @@ const CURRENT_TARGET_DESCRIPTOR = {
9949
10607
  }
9950
10608
  };
9951
10609
  const CAPTURE_PATH = [];
10610
+ const CAPTURE_SLOTS = [];
10611
+ function snapshotDelegatedSlots(base, key, event) {
10612
+ const type = event.type;
10613
+ const suppressDisabled = type === "click" || type === "dblclick" || type === "mousedown" || type === "mousemove" || type === "mouseup" || type === "mouseenter" && key[2] !== "c";
10614
+ for (let index = base; index < CAPTURE_PATH.length; index++) {
10615
+ const node = CAPTURE_PATH[index];
10616
+ const slot = node[key];
10617
+ CAPTURE_SLOTS[index] = slot != null && suppressDisabled && node.disabled && (node.localName === "button" || node.localName === "input" || node.localName === "select" || node.localName === "textarea") ? null : slot;
10618
+ }
10619
+ }
10620
+ function preserveDispatchedBundle(bundle) {
10621
+ let snapshot;
10622
+ for (let index = 0; index < CAPTURE_SLOTS.length; index++) {
10623
+ if (CAPTURE_SLOTS[index] === bundle) {
10624
+ CAPTURE_SLOTS[index] = snapshot ??= {
10625
+ [EVENT_SLOT_KIND]: HANDLER_BUNDLE_KIND,
10626
+ fn: bundle.fn,
10627
+ args: bundle.args.slice()
10628
+ };
10629
+ }
10630
+ }
10631
+ }
9952
10632
  function resolvePortalEventOwner(node) {
9953
10633
  if (node.$$portalParent != null || node.parentNode === null) return;
9954
10634
  const target = node.parentNode;
@@ -10166,13 +10846,7 @@ function dispatchDelegated(event) {
10166
10846
  _dispatchDepth++;
10167
10847
  const node = event.target;
10168
10848
  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;
10849
+ const submitRec = event.type === "submit" && node != null && node.nodeName === "FORM" ? snapshotSubmitDispatch(node, event) : null;
10176
10850
  if (submitRec !== null) ACTIVE_SUBMIT_DISPATCH = submitRec;
10177
10851
  const nativeBatch = beginNativeEventBatch(event);
10178
10852
  const pathBase = CAPTURE_PATH.length;
@@ -10182,14 +10856,17 @@ function dispatchDelegated(event) {
10182
10856
  if (delegatedCapture(event.type) && _delegatedCapture.has(event.type) && dispatchDelegatedCapture.call(this, event))
10183
10857
  return;
10184
10858
  if (!_delegated.has(event.type)) return;
10859
+ if (node?.nodeType === 1 && isHtmlCustomElement(node) && (event.type === "invalid" || EMULATED_BUBBLING_EVENTS.includes(event.type)))
10860
+ return;
10185
10861
  buildDelegatedPath(event, this);
10862
+ snapshotDelegatedSlots(pathBase, key, event);
10186
10863
  stop = Object.getOwnPropertyDescriptor(event, "stopPropagation");
10187
10864
  propagationStarted = true;
10188
10865
  beginDelegatedPropagation(event, stop, null);
10189
10866
  for (let i = pathBase; i < CAPTURE_PATH.length; i++) {
10190
10867
  const current = CAPTURE_PATH[i];
10191
10868
  if (targetOnly && current !== event.target) break;
10192
- const slot = current[key];
10869
+ const slot = CAPTURE_SLOTS[i];
10193
10870
  if (slot != null) {
10194
10871
  setCurrentTarget(event, current);
10195
10872
  fireEventSlot(slot, event);
@@ -10197,8 +10874,12 @@ function dispatchDelegated(event) {
10197
10874
  }
10198
10875
  if (targetOnly) break;
10199
10876
  }
10877
+ if (submitRec !== null && FORM_SUBMIT_DRIVER !== null && !event.defaultPrevented && CAPTURE_PATH.includes(submitRec.form, pathBase)) {
10878
+ FORM_SUBMIT_DRIVER(submitRec.form, event, submitRec.action, submitRec.submitter);
10879
+ }
10200
10880
  } finally {
10201
10881
  CAPTURE_PATH.length = pathBase;
10882
+ CAPTURE_SLOTS.length = pathBase;
10202
10883
  if (propagationStarted) endDelegatedPropagation(event, stop, null);
10203
10884
  if (submitRec !== null) {
10204
10885
  ACTIVE_SUBMIT_DISPATCH = prevSubmitRec;
@@ -10221,6 +10902,7 @@ function dispatchDelegatedCapture(event) {
10221
10902
  const key = CAPTURE_PREFIX + event.type;
10222
10903
  const pathBase = CAPTURE_PATH.length;
10223
10904
  buildDelegatedPath(event, this, path);
10905
+ snapshotDelegatedSlots(pathBase, key, event);
10224
10906
  const stop = Object.getOwnPropertyDescriptor(event, "stopPropagation");
10225
10907
  const immediate = delegatedCapture(event.type) ? Object.getOwnPropertyDescriptor(event, "stopImmediatePropagation") : null;
10226
10908
  const wasCancelled = event.cancelBubble;
@@ -10230,7 +10912,7 @@ function dispatchDelegatedCapture(event) {
10230
10912
  try {
10231
10913
  beginDelegatedPropagation(event, stop, immediate);
10232
10914
  for (let i = CAPTURE_PATH.length - 1; i >= pathBase; i--) {
10233
- const slot = CAPTURE_PATH[i][key];
10915
+ const slot = CAPTURE_SLOTS[i];
10234
10916
  if (slot != null) {
10235
10917
  setCurrentTarget(event, CAPTURE_PATH[i]);
10236
10918
  fireEventSlot(slot, event);
@@ -10240,6 +10922,7 @@ function dispatchDelegatedCapture(event) {
10240
10922
  } finally {
10241
10923
  stopped = event[PROPAGATION_FLAGS] !== 0 || !wasCancelled && event.cancelBubble;
10242
10924
  CAPTURE_PATH.length = pathBase;
10925
+ CAPTURE_SLOTS.length = pathBase;
10243
10926
  endDelegatedPropagation(event, stop, immediate);
10244
10927
  clearCurrentTarget(event);
10245
10928
  try {
@@ -10267,7 +10950,7 @@ function clearCurrentTarget(event) {
10267
10950
  delete event.currentTarget;
10268
10951
  delete event[CURRENT_TARGET_NODE];
10269
10952
  }
10270
- const IDLE_FORM_STATUS = { pending: false, data: null, method: "get", action: null };
10953
+ const IDLE_FORM_STATUS = { pending: false, data: null, method: null, action: null };
10271
10954
  const FORM_STATUS = /* @__PURE__ */ new WeakMap();
10272
10955
  const FORM_STATUS_LISTENERS = /* @__PURE__ */ new WeakMap();
10273
10956
  function setFormStatus(form, status) {
@@ -10275,7 +10958,28 @@ function setFormStatus(form, status) {
10275
10958
  const ls = FORM_STATUS_LISTENERS.get(form);
10276
10959
  if (ls) for (const l of ls) l();
10277
10960
  }
10961
+ function snapshotSubmitDispatch(form, event) {
10962
+ let submitter = event.submitter;
10963
+ let action = form.$$formAction;
10964
+ if (submitter !== null && submitter !== void 0) {
10965
+ const override = submitter.$$formAction ?? submitter.getAttribute("formaction");
10966
+ if (override != null) {
10967
+ action = override;
10968
+ submitter = null;
10969
+ }
10970
+ }
10971
+ return {
10972
+ form,
10973
+ event,
10974
+ action,
10975
+ submitter: submitter ?? null,
10976
+ transitions: 0,
10977
+ published: false,
10978
+ intercepted: false
10979
+ };
10980
+ }
10278
10981
  let ACTIVE_SUBMIT_DISPATCH = null;
10982
+ let FORM_SUBMIT_DRIVER = null;
10279
10983
  function publishManualFormPending(rec) {
10280
10984
  if (rec.intercepted || rec.transitions === 0 || !rec.event.defaultPrevented) return;
10281
10985
  const form = rec.form;
@@ -10331,30 +11035,22 @@ function flushFormResets() {
10331
11035
  PENDING_FORM_RESETS = null;
10332
11036
  for (const f of forms) resetFormNow(f);
10333
11037
  }
10334
- function setFormAction(el, name, value, prev) {
11038
+ function setFormAction(el, name, value, _prev) {
10335
11039
  if (typeof value === "function") {
10336
11040
  el.$$formAction = value;
10337
11041
  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
- }
11042
+ if (!el.$$formSubmitWired) {
11043
+ el.$$formSubmitWired = true;
11044
+ FORM_SUBMIT_DRIVER = handleFormSubmit;
11045
+ delegateEvents(["submit"]);
10344
11046
  }
10345
11047
  el.removeAttribute(name);
10346
11048
  return;
10347
11049
  }
10348
11050
  el.$$formAction = void 0;
10349
- if (typeof prev === "function" && el.nodeName === "FORM") {
10350
- el.$$submit = void 0;
10351
- el.$$formSubmitWired = false;
10352
- }
10353
11051
  setAttribute(el, name, value);
10354
11052
  }
10355
- function handleFormSubmit(form, event) {
10356
- const submitter = event.submitter;
10357
- const action = submitter && submitter.$$formAction || form.$$formAction;
11053
+ function handleFormSubmit(form, event, action, submitter) {
10358
11054
  if (typeof action !== "function") return;
10359
11055
  event.preventDefault();
10360
11056
  if (ACTIVE_SUBMIT_DISPATCH !== null && ACTIVE_SUBMIT_DISPATCH.form === form)
@@ -10530,7 +11226,7 @@ function armControlled(el) {
10530
11226
  return ctrl;
10531
11227
  }
10532
11228
  function toControlledString(v) {
10533
- return typeof v === "string" ? v : String(v);
11229
+ return typeof v === "string" ? v : typeof v === "function" || typeof v === "symbol" ? "" : String(v);
10534
11230
  }
10535
11231
  function valueNeedsWrite(el, raw) {
10536
11232
  if (el.type === "number") {
@@ -10791,35 +11487,77 @@ function projectSelectValue(sel, sv, setDefaultSelected) {
10791
11487
  }
10792
11488
  if (defaultOption !== null) defaultOption.selected = true;
10793
11489
  }
10794
- function setDefaultValue(el, value) {
11490
+ function setDefaultValue(el, value, initial) {
10795
11491
  const ctrl = armControlled(el);
10796
11492
  const hydration = activeHydration();
10797
- if (hydration !== null && !hydration.isFresh(el) || value == null) return;
10798
11493
  if (el.localName === "select") {
10799
- if (!Object.is(ctrl.dvv, value)) {
11494
+ const first2 = ctrl.dvv === UNCONTROLLED;
11495
+ const multiple = el.multiple;
11496
+ const changedMultiple = ctrl.formMultiple !== multiple;
11497
+ if (first2 || changedMultiple) {
10800
11498
  if (TRANSITION_JOURNAL !== null) {
10801
11499
  journalObjectOnce(ctrl);
10802
11500
  journalBag();
10803
11501
  }
10804
11502
  ctrl.dvv = value;
10805
- queueControlledCommit(SELECT_DEFAULT_SYNCS, { el, value });
11503
+ ctrl.formMultiple = multiple;
11504
+ if (hydration !== null && !hydration.isFresh(el)) return;
11505
+ if (value != null)
11506
+ queueControlledCommit(SELECT_DEFAULT_SYNCS, { el, value });
11507
+ else if (changedMultiple)
11508
+ projectSelectValue(el, multiple ? /* @__PURE__ */ new Set() : "", false);
10806
11509
  }
10807
11510
  return;
10808
11511
  }
11512
+ const first = initial ?? !ctrl.sawV;
11513
+ const previousDefault = ctrl.dvv;
11514
+ if (TRANSITION_JOURNAL !== null) journalObjectOnce(ctrl);
11515
+ ctrl.sawV = true;
11516
+ ctrl.dvv = value;
11517
+ const hydrating = hydration !== null && !hydration.isFresh(el);
10809
11518
  if (ctrl.v !== UNCONTROLLED) return;
10810
11519
  const input = el;
11520
+ if (value == null) {
11521
+ if (previousDefault !== UNCONTROLLED && previousDefault != null) {
11522
+ if (TRANSITION_JOURNAL !== null) journalDefaultValue(input);
11523
+ if (el.localName === "input") input.removeAttribute("value");
11524
+ else input.defaultValue = "";
11525
+ }
11526
+ return;
11527
+ }
10811
11528
  const s = toControlledString(value);
10812
- if (input.defaultValue !== s) {
11529
+ if (first && !hydrating && input.value !== s) {
11530
+ if (TRANSITION_JOURNAL !== null) journalControlled(el, "value", "defaultValue");
11531
+ input.value = s;
11532
+ }
11533
+ if (input.defaultValue !== s || s === "" && el.localName === "input" && !input.hasAttribute("value")) {
10813
11534
  if (TRANSITION_JOURNAL !== null) journalDefaultValue(input);
10814
11535
  input.defaultValue = s;
10815
11536
  }
10816
11537
  }
11538
+ const DEFAULT_VALUE_BASELINE = /* @__PURE__ */ Symbol("octane.defaultValue");
10817
11539
  function setDefaultValueUncontrolled(el, value) {
10818
11540
  const hydration = activeHydration();
10819
- if (hydration !== null && !hydration.isFresh(el) || value == null) return;
10820
11541
  const input = el;
10821
- const s = toControlledString(value);
10822
- if (input.defaultValue !== s) {
11542
+ const previous = input[DEFAULT_VALUE_BASELINE];
11543
+ const s = value == null ? null : toControlledString(value);
11544
+ if (TRANSITION_JOURNAL !== null)
11545
+ TRANSITION_JOURNAL.push(JOURNAL_PROP, input, DEFAULT_VALUE_BASELINE, previous);
11546
+ input[DEFAULT_VALUE_BASELINE] = s;
11547
+ const hydrating = hydration !== null && !hydration.isFresh(el);
11548
+ if (s === null) {
11549
+ if (previous != null) {
11550
+ if (TRANSITION_JOURNAL !== null) journalDefaultValue(input);
11551
+ if (el.localName === "input") input.removeAttribute("value");
11552
+ else input.defaultValue = "";
11553
+ }
11554
+ return;
11555
+ }
11556
+ if (previous === void 0 && !hydrating && input.value !== s) {
11557
+ if (TRANSITION_JOURNAL !== null) journalControlled(el, "value", "defaultValue");
11558
+ input.value = s;
11559
+ }
11560
+ if (input.defaultValue !== s || s === "" && el.localName === "input" && !input.hasAttribute("value")) {
10823
11561
  if (TRANSITION_JOURNAL !== null) journalDefaultValue(input);
10824
11562
  input.defaultValue = s;
10825
11563
  }
@@ -10888,7 +11626,6 @@ function setFormControlSources(el, sources) {
10888
11626
  }
10889
11627
  const ctrl = armControlled(el);
10890
11628
  const first = !ctrl.formSeen;
10891
- const previousDefaultValue = ctrl.formDefaultValue;
10892
11629
  const previousDefaultChecked = ctrl.formDefaultChecked;
10893
11630
  const previousMultiple = ctrl.formMultiple;
10894
11631
  if (TRANSITION_JOURNAL !== null) {
@@ -10910,9 +11647,7 @@ function setFormControlSources(el, sources) {
10910
11647
  const defaultString = defaultValue == null ? null : toControlledString(defaultValue);
10911
11648
  setValue(input, value);
10912
11649
  if (value == null) {
10913
- if (defaultString !== null) setDefaultValue(input, defaultString);
10914
- else if (!first && previousDefaultValue !== UNCONTROLLED && previousDefaultValue != null)
10915
- input.removeAttribute("value");
11650
+ setDefaultValue(input, defaultString, first);
10916
11651
  }
10917
11652
  setChecked(input, checked);
10918
11653
  if (checked == null && defaultChecked != null) setDefaultChecked(input, defaultChecked);
@@ -10925,7 +11660,7 @@ function setFormControlSources(el, sources) {
10925
11660
  const textarea = el;
10926
11661
  setValue(textarea, value);
10927
11662
  if (value == null) {
10928
- if (defaultValue != null) setDefaultValue(textarea, defaultValue);
11663
+ if (defaultValue != null) setDefaultValue(textarea, defaultValue, first);
10929
11664
  else if (!first && textarea.defaultValue !== "") textarea.defaultValue = "";
10930
11665
  }
10931
11666
  return;
@@ -10948,7 +11683,7 @@ function setFormControlSources(el, sources) {
10948
11683
  }
10949
11684
  setSelectValue(select, value);
10950
11685
  if (defaultValue != null) setDefaultValue(select, defaultValue);
10951
- else ctrl.dvv = UNCONTROLLED;
11686
+ else if (first) ctrl.dvv = void 0;
10952
11687
  }
10953
11688
  function nativeTextChangeMessage(el, hasBubbleChange, controlled) {
10954
11689
  const changeProp = hasBubbleChange ? "onChange" : "onChangeCapture";
@@ -11232,7 +11967,9 @@ function unregisterPortalEventRange(target, portal2) {
11232
11967
  }
11233
11968
  }
11234
11969
  function portal(parentScope, slotKey, target, body, props, host, env, fragmentOwners, fragmentAnchor) {
11970
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
11235
11971
  const prev = parentScope.slots[slotKey];
11972
+ const key = portalKey(props);
11236
11973
  if (fragmentAnchor !== void 0 && fragmentOwners === void 0 && prev !== void 0 && prev.target === target) {
11237
11974
  prepareFragmentPortalInterleaving(prev);
11238
11975
  }
@@ -11241,12 +11978,13 @@ function portal(parentScope, slotKey, target, body, props, host, env, fragmentOw
11241
11978
  parentScope.block,
11242
11979
  target,
11243
11980
  body,
11244
- props,
11981
+ key === null ? props : void 0,
11245
11982
  // `host` (passed by the compiler) is the JSX element that contains the
11246
11983
  // createPortal call — the natural "logical parent" for event bubbling. When
11247
11984
  // the portal is at top level the compiler passes the block's parentNode.
11248
11985
  host || parentScope.block.parentNode,
11249
- env
11986
+ env,
11987
+ key
11250
11988
  );
11251
11989
  if (prev !== state) {
11252
11990
  journalRootProperty(parentScope.slots, String(slotKey));
@@ -11407,16 +12145,16 @@ function registerValuePortalFragmentOwners(portal2, parentBlock, anchor) {
11407
12145
  registerFragmentPortalOwners(portal2, nestedOwners ?? firstOwner, anchor);
11408
12146
  }
11409
12147
  }
11410
- function renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, env) {
12148
+ function renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, env, key = null) {
11411
12149
  const hydration = activeHydration();
11412
12150
  if (hydration !== null) {
11413
12151
  return hydration.suspend(
11414
- () => renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, env)
12152
+ () => renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, env, key)
11415
12153
  );
11416
12154
  }
11417
12155
  const norm = normalizePortalBody(rawBody, rawProps);
11418
12156
  let state = prev;
11419
- if (state === null || state.target !== target) {
12157
+ if (state === null || state.target !== target || state.key !== key) {
11420
12158
  if (state !== null) teardownPortalState(state);
11421
12159
  const start = document.createComment("portal");
11422
12160
  const end = document.createComment("/portal");
@@ -11437,7 +12175,7 @@ function renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, e
11437
12175
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
11438
12176
  __profileTrackComponent(block, profilePortalComponent(rawBody));
11439
12177
  }
11440
- state = { __kind: "portalSlotSlot", block, target, host, start, end };
12178
+ state = { __kind: "portalSlotSlot", block, target, key, host, start, end };
11441
12179
  registerPortalEventRange(target, state);
11442
12180
  activityPortalCreated?.(block);
11443
12181
  registerDelegationTarget(target);
@@ -11519,9 +12257,13 @@ function genericPortalBody(value, scope) {
11519
12257
  childSlot(scope, 0, scope.parentNode, value, scope.endMarker);
11520
12258
  }
11521
12259
  const PORTAL_TAG = /* @__PURE__ */ Symbol.for("octane.portal");
12260
+ function portalKey(value) {
12261
+ return typeof value === "string" || typeof value === "number" ? String(value) : null;
12262
+ }
11522
12263
  // @__NO_SIDE_EFFECTS__
11523
12264
  function createPortal(body, target, props = void 0) {
11524
- return { $$kind: PORTAL_TAG, body, target, props };
12265
+ const key = portalKey(props);
12266
+ return { $$kind: PORTAL_TAG, body, target, key, props: key === null ? props : void 0 };
11525
12267
  }
11526
12268
  const ELEMENT_TAG = /* @__PURE__ */ Symbol.for("octane.element");
11527
12269
  const KEYED_ELEMENT_DESCRIPTORS = /* @__PURE__ */ new WeakSet();
@@ -11940,6 +12682,7 @@ function componentSlotVoid(parentScope, slotKey, domParent, comp, props, anchor,
11940
12682
  );
11941
12683
  }
11942
12684
  function componentSlotImpl(outputHandler, parentScope, slotKey, domParent, body, identity, props, renderProps, anchor, key, singleRoot, inherit, hasKey) {
12685
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
11943
12686
  const parentBlock = parentScope.block;
11944
12687
  const hydration = activeHydration();
11945
12688
  if (hydration !== null && (anchor != null && hydration.isFresh(anchor) || hydration.isFresh(domParent))) {
@@ -12049,8 +12792,8 @@ function componentSlotImpl(outputHandler, parentScope, slotKey, domParent, body,
12049
12792
  parentScope.slots[slotKey] = state;
12050
12793
  registerSlot(parentScope, state);
12051
12794
  }
12052
- const nextKey = key === void 0 ? NO_KEY : key;
12053
- const keyChanged = key !== void 0 && state.prevKey !== NO_KEY && !Object.is(key, state.prevKey);
12795
+ const nextKey = key === void 0 ? NO_KEY : "" + key;
12796
+ const keyChanged = key !== void 0 && state.prevKey !== NO_KEY && nextKey !== state.prevKey;
12054
12797
  const replacing = identity !== state.currentComp || keyChanged;
12055
12798
  const journaledSlot = ROOT_RENDER_TRANSACTION !== null && state.block !== null && replacing;
12056
12799
  if (journaledSlot) {
@@ -12505,25 +13248,28 @@ function clearReplacedChildBlock(state, oldBlock) {
12505
13248
  }
12506
13249
  const DEOPT_KEY_WARNED_BLOCKS = /* @__PURE__ */ new WeakSet();
12507
13250
  let DEOPT_KEY_WARNED_WITHOUT_BLOCK = false;
13251
+ function warnMissingListKey(owner) {
13252
+ const warned = owner === null ? DEOPT_KEY_WARNED_WITHOUT_BLOCK : DEOPT_KEY_WARNED_BLOCKS.has(owner);
13253
+ if (!warned) {
13254
+ if (owner === null) DEOPT_KEY_WARNED_WITHOUT_BLOCK = true;
13255
+ else DEOPT_KEY_WARNED_BLOCKS.add(owner);
13256
+ console.warn(
13257
+ '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 ...)`.'
13258
+ );
13259
+ }
13260
+ }
12508
13261
  function deoptKey(item, index) {
12509
13262
  const element = item != null && item.$$kind === ELEMENT_TAG;
13263
+ if (item?.$$kind === PORTAL_TAG && item.key != null) return item.key;
12510
13264
  if (element && item.key != null && !ELEMENTS_MISSING_LIST_KEY.has(item)) return item.key;
12511
13265
  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
- }
13266
+ warnMissingListKey(CURRENT_BLOCK);
12521
13267
  }
12522
13268
  return element && item.key != null ? item.key : index;
12523
13269
  }
12524
13270
  const POSITIONAL_CHILDREN = /* @__PURE__ */ new WeakSet();
12525
13271
  function deoptKeyPositional(item, index) {
12526
- return item != null && item.$$kind === ELEMENT_TAG && item.key != null ? item.key : index;
13272
+ return item != null && (item.$$kind === ELEMENT_TAG || item.$$kind === PORTAL_TAG) && item.key != null ? item.key : index;
12527
13273
  }
12528
13274
  function positionalChildren(children) {
12529
13275
  POSITIONAL_CHILDREN.add(children);
@@ -12539,6 +13285,11 @@ function noteDeoptRef(block) {
12539
13285
  }
12540
13286
  }
12541
13287
  function applyDeoptProp(el, name, v, ownerBlock) {
13288
+ const actionName = formActionAttributeName(el, name);
13289
+ if (actionName !== null) {
13290
+ setFormAction(el, actionName, v, void 0);
13291
+ return;
13292
+ }
12542
13293
  if (name === "ref") {
12543
13294
  if (v != null) {
12544
13295
  noteDeoptRef(ownerBlock);
@@ -12549,7 +13300,7 @@ function applyDeoptProp(el, name, v, ownerBlock) {
12549
13300
  } else if (name === "style") {
12550
13301
  setStyle(el, v, void 0);
12551
13302
  } else {
12552
- const ev = eventSlot(name);
13303
+ const ev = eventSlot(name, el);
12553
13304
  if (ev !== null) {
12554
13305
  setEventHandler(
12555
13306
  el,
@@ -12571,6 +13322,9 @@ function hasDangerHTML(props) {
12571
13322
  }
12572
13323
  return true;
12573
13324
  }
13325
+ function hasHostPropContent(descriptor) {
13326
+ return hasDangerHTML(descriptor.props) || descriptor.type === "textarea" && (descriptor.props?.value != null || descriptor.props?.defaultValue != null);
13327
+ }
12574
13328
  function applyDeoptProps(el, props, ownerBlock) {
12575
13329
  if (props == null) {
12576
13330
  if (process.env.NODE_ENV !== "production") queueDevFormDiagnostic(el, ownerBlock);
@@ -12579,7 +13333,7 @@ function applyDeoptProps(el, props, ownerBlock) {
12579
13333
  for (const name in props) {
12580
13334
  if (name === "key" || name === "children") continue;
12581
13335
  if (name === "suppressHydrationWarning") {
12582
- el.__oct_suppress = props[name] !== false;
13336
+ el.__oct_suppress = props[name] === true;
12583
13337
  continue;
12584
13338
  }
12585
13339
  applyDeoptProp(el, name, props[name], ownerBlock);
@@ -12600,7 +13354,7 @@ function patchDeoptProps(el, prevProps, nextProps, ownerBlock) {
12600
13354
  for (const name in nextProps) {
12601
13355
  if (name === "key" || name === "children") continue;
12602
13356
  if (name === "suppressHydrationWarning") {
12603
- el.__oct_suppress = nextProps[name] !== false;
13357
+ el.__oct_suppress = nextProps[name] === true;
12604
13358
  continue;
12605
13359
  }
12606
13360
  const nv = nextProps[name];
@@ -12667,8 +13421,13 @@ function applyHostProps(el, props, scope, state) {
12667
13421
  for (const name in props) {
12668
13422
  if (name === "key" || name === "children") continue;
12669
13423
  const v = props[name];
13424
+ const actionName = formActionAttributeName(el, name);
13425
+ if (actionName !== null) {
13426
+ setFormAction(el, actionName, v, prev?.[name]);
13427
+ continue;
13428
+ }
12670
13429
  if (name === "suppressHydrationWarning") {
12671
- el.__oct_suppress = v !== false;
13430
+ el.__oct_suppress = v === true;
12672
13431
  continue;
12673
13432
  }
12674
13433
  if (name === "ref") {
@@ -12682,7 +13441,7 @@ function applyHostProps(el, props, scope, state) {
12682
13441
  } else if (name === "style") {
12683
13442
  setStyle(el, v, prev != null ? prev.style : void 0);
12684
13443
  } else {
12685
- const ev = eventSlot(name);
13444
+ const ev = eventSlot(name, el);
12686
13445
  if (ev) {
12687
13446
  if (ev.capture) {
12688
13447
  if (!_delegatedCapture.has(ev.type)) delegateCaptureEvents([ev.type]);
@@ -12789,7 +13548,7 @@ function deoptWrapperKind(value) {
12789
13548
  return POSITIONAL_CHILDREN.has(value) ? "fragment" : "array";
12790
13549
  }
12791
13550
  function scopedDeoptKey(path, item, index, key) {
12792
- const explicit = isElementDescriptor(item) && item.key != null;
13551
+ const explicit = (isElementDescriptor(item) || item?.$$kind === PORTAL_TAG) && item.key != null;
12793
13552
  if (path.length === 0) return explicit ? "k" + String(key) : "i" + index;
12794
13553
  return JSON.stringify([path, explicit ? "key" : "index", explicit ? String(key) : index]);
12795
13554
  }
@@ -12902,6 +13661,10 @@ function reconcileDeoptNode(prev, value, ownerBlock, ns) {
12902
13661
  if (t === "string" || t === "number" || t === "bigint") {
12903
13662
  const s = String(value);
12904
13663
  if (prev !== null && prev.nodeType === 3) {
13664
+ const hydration = activeHydration();
13665
+ if (hydration !== null && !hydration.isFresh(prev.parentNode)) {
13666
+ return hydration.htextSwap(prev, s);
13667
+ }
12905
13668
  updateTextValue(prev, s);
12906
13669
  return prev;
12907
13670
  }
@@ -12919,7 +13682,7 @@ function reconcileDeoptNode(prev, value, ownerBlock, ns) {
12919
13682
  applyDeoptProps(el, value.props, ownerBlock);
12920
13683
  }
12921
13684
  setDeoptDesc(el, value);
12922
- if (!hasDangerHTML(value.props)) {
13685
+ if (!hasHostPropContent(value)) {
12923
13686
  reconcileDeoptChildren(el, value.children, ownerBlock);
12924
13687
  }
12925
13688
  return el;
@@ -12935,7 +13698,12 @@ function reconcileDeoptChildren(el, children, ownerBlock) {
12935
13698
  if (type === "string" && children !== "" || type === "number" || type === "bigint") {
12936
13699
  const first = getFirstChild(el);
12937
13700
  if (first !== null && first.nodeType === 3 && getNextSibling(first) === null && first.$$deoptKey === 0 && first.$$portalEnd == null) {
12938
- updateTextValue(first, String(children));
13701
+ const hydration = activeHydration();
13702
+ if (hydration !== null && !hydration.isFresh(el)) {
13703
+ hydration.htextSwap(first, String(children));
13704
+ } else {
13705
+ updateTextValue(first, String(children));
13706
+ }
12939
13707
  return;
12940
13708
  }
12941
13709
  }
@@ -13013,6 +13781,10 @@ function reconcileDeoptChildren(el, children, ownerBlock) {
13013
13781
  for (let i = owned.length - 1; i >= 0; i--) {
13014
13782
  const n = owned[i];
13015
13783
  if (keep === null || !keep.has(n)) {
13784
+ const hydration = activeHydration();
13785
+ if (hydration !== null && !hydration.isFresh(el)) {
13786
+ noteRecoverableHydrationError(() => new Error(formatClientError(62)), ownerBlock);
13787
+ }
13016
13788
  if (journal) {
13017
13789
  journalRootChildren(el);
13018
13790
  deferRootRange(el, n, n, () => detachDeoptTreeRefs(n, null));
@@ -13243,6 +14015,7 @@ function mappedDeoptItemBody(item, scope) {
13243
14015
  function descNeedsBlocks(value) {
13244
14016
  if (typeof value === "function") return true;
13245
14017
  if (value == null || typeof value !== "object") return false;
14018
+ if (typeof value.then === "function") return true;
13246
14019
  if (Array.isArray(value)) {
13247
14020
  for (let i = 0; i < value.length; i++) {
13248
14021
  if (descNeedsBlocks(value[i])) return true;
@@ -13268,7 +14041,7 @@ function hostElementBody(d, block) {
13268
14041
  applyDeoptProps(el, d.props, block);
13269
14042
  setDeoptDesc(el, d);
13270
14043
  const savedCursor = hydration.node.nextSibling;
13271
- if (!hasDangerHTML(d.props)) {
14044
+ if (!hasHostPropContent(d)) {
13272
14045
  hydration.node = el.firstChild;
13273
14046
  childSlot(block, 0, el, d.children, null, false, el);
13274
14047
  }
@@ -13296,7 +14069,7 @@ function hostElementBody(d, block) {
13296
14069
  block.parentNode.insertBefore(el, block.endMarker);
13297
14070
  applyDeoptProps(el, d.props, block);
13298
14071
  setDeoptDesc(el, d);
13299
- if (!hasDangerHTML(d.props)) {
14072
+ if (!hasHostPropContent(d)) {
13300
14073
  hydration.suspend(() => childSlot(block, 0, el, d.children, null, false, el));
13301
14074
  }
13302
14075
  return;
@@ -13332,7 +14105,7 @@ function hostElementBody(d, block) {
13332
14105
  patchDeoptProps(el, getDeoptDesc(el)?.props ?? null, d.props, block);
13333
14106
  }
13334
14107
  setDeoptDesc(el, d);
13335
- if (!hasDangerHTML(d.props)) childSlot(block, 0, el, d.children, null, false, el);
14108
+ if (!hasHostPropContent(d)) childSlot(block, 0, el, d.children, null, false, el);
13336
14109
  }
13337
14110
  function hostStringTagBody(d, block) {
13338
14111
  const tag = d.type;
@@ -13346,7 +14119,7 @@ function hostStringTagBody(d, block) {
13346
14119
  applyDeoptProps(el, d.props, block);
13347
14120
  setDeoptDesc(el, d);
13348
14121
  const savedCursor = hydration.node.nextSibling;
13349
- if (!hasDangerHTML(d.props)) {
14122
+ if (!hasHostPropContent(d)) {
13350
14123
  hydration.node = el.firstChild;
13351
14124
  renderHostTagChildren(d, block, el);
13352
14125
  }
@@ -13374,7 +14147,7 @@ function hostStringTagBody(d, block) {
13374
14147
  block.parentNode.insertBefore(el, block.endMarker);
13375
14148
  applyDeoptProps(el, d.props, block);
13376
14149
  setDeoptDesc(el, d);
13377
- if (!hasDangerHTML(d.props)) {
14150
+ if (!hasHostPropContent(d)) {
13378
14151
  hydration.suspend(() => renderHostTagChildren(d, block, el));
13379
14152
  }
13380
14153
  return;
@@ -13388,7 +14161,7 @@ function hostStringTagBody(d, block) {
13388
14161
  patchDeoptProps(el, getDeoptDesc(el)?.props ?? null, d.props, block);
13389
14162
  }
13390
14163
  setDeoptDesc(el, d);
13391
- if (!hasDangerHTML(d.props)) renderHostTagChildren(d, block, el);
14164
+ if (!hasHostPropContent(d)) renderHostTagChildren(d, block, el);
13392
14165
  }
13393
14166
  function renderHostTagChildren(d, block, el) {
13394
14167
  const kids = d.children;
@@ -13566,6 +14339,8 @@ function mapSlot(scopeOrItems, slotOrMethod, domParent, items, method, native, c
13566
14339
  callback = native;
13567
14340
  native = mapSlot(items, method);
13568
14341
  }
14342
+ if (process.env.NODE_ENV !== "production" && ((flags ?? 0) & 64) !== 0 && items?.length > 0)
14343
+ warnMissingListKey(scopeOrItems.block);
13569
14344
  if (ownEnd === 1) ownEnd = true;
13570
14345
  if (native === true) {
13571
14346
  const previous = scopeOrItems.slots[slotOrMethod]?.forSlot;
@@ -13835,6 +14610,7 @@ function renderPreparedChildList(state, parentBlock, domParent, preparedList, hy
13835
14610
  return;
13836
14611
  }
13837
14612
  function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsHost, compactable, includeKeyedSingle = true, compiledMapBody, compiledMapKey, compiledMapFlags, compiledMapDeps, mappedFallback) {
14613
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
13838
14614
  if (value != null && includeKeyedSingle && domParent.nodeType === 1 && VOID_ELEMENTS.has(domParent.localName) && !isPortalTarget(parentScope.block, domParent)) {
13839
14615
  throw new Error(formatClientError(26, domParent.localName));
13840
14616
  }
@@ -13909,7 +14685,7 @@ function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsH
13909
14685
  slotKey,
13910
14686
  domParent,
13911
14687
  value,
13912
- anchor,
14688
+ anchor?.parentNode === domParent ? anchor : null,
13913
14689
  ownEnd,
13914
14690
  ownsHost,
13915
14691
  compactable,
@@ -14030,7 +14806,9 @@ function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsH
14030
14806
  portalDesc.body,
14031
14807
  portalDesc.props,
14032
14808
  // The DOM element containing this hole is the portal's logical parent.
14033
- domParent
14809
+ domParent,
14810
+ void 0,
14811
+ portalDesc.key
14034
14812
  );
14035
14813
  if (activeFragments.size !== 0 && state.end !== null) {
14036
14814
  registerValuePortalFragmentOwners(state.portal, parentBlock, state.end);
@@ -14666,7 +15444,17 @@ function memo(component, arePropsEqual) {
14666
15444
  function memoWrapper(props, scope, extra) {
14667
15445
  return component(props, scope, extra);
14668
15446
  }
14669
- memoWrapper.__memo = true;
15447
+ Object.defineProperty(memoWrapper, "type", { value: component });
15448
+ Object.defineProperty(memoWrapper, "displayName", {
15449
+ configurable: true,
15450
+ writable: true,
15451
+ value: component.displayName || component.name || "Memo"
15452
+ });
15453
+ Object.defineProperty(memoWrapper, "__memo", {
15454
+ get() {
15455
+ return this === memoWrapper;
15456
+ }
15457
+ });
14670
15458
  Object.defineProperty(memoWrapper, "defaultProps", {
14671
15459
  configurable: true,
14672
15460
  get: () => component.defaultProps,
@@ -14676,7 +15464,7 @@ function memo(component, arePropsEqual) {
14676
15464
  });
14677
15465
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
14678
15466
  __profileComponentSource(memoWrapper, component);
14679
- if (arePropsEqual) memoWrapper.__compare = arePropsEqual;
15467
+ if (arePropsEqual) Object.defineProperty(memoWrapper, "__compare", { value: arePropsEqual });
14680
15468
  return memoWrapper;
14681
15469
  }
14682
15470
  const HMR = /* @__PURE__ */ Symbol.for("octane.hmr");
@@ -14701,7 +15489,7 @@ function hmr(fn) {
14701
15489
  meta.fn = nextFn;
14702
15490
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
14703
15491
  __profileComponentSource(wrapper, meta.fn);
14704
- wrapper.__warm = meta.fn.__warm;
15492
+ markWarm(wrapper, meta.fn.__warm);
14705
15493
  const it = meta.liveBlocks.values();
14706
15494
  for (let r = it.next(); !r.done; r = it.next()) {
14707
15495
  const b = r.value;
@@ -14723,10 +15511,14 @@ function hmr(fn) {
14723
15511
  if (scope !== void 0) meta.liveBlocks.add(scope.block);
14724
15512
  return meta.fn(props, scope, extra);
14725
15513
  }
14726
- wrapper[HMR] = meta;
15514
+ Object.defineProperty(wrapper, HMR, {
15515
+ get() {
15516
+ return this === wrapper ? meta : void 0;
15517
+ }
15518
+ });
14727
15519
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
14728
15520
  __profileComponentSource(wrapper, fn);
14729
- if (fn.__warm !== void 0) wrapper.__warm = fn.__warm;
15521
+ if (fn.__warm !== void 0) markWarm(wrapper, fn.__warm);
14730
15522
  return wrapper;
14731
15523
  }
14732
15524
  let TRANSITION_FALLBACK_TIMEOUT_MS = Infinity;
@@ -15519,7 +16311,7 @@ function renderVisibleTry(state, source) {
15519
16311
  throw renderError;
15520
16312
  if (isSuspenseException(renderError)) {
15521
16313
  if (state.propagateSuspense) throw renderError;
15522
- handleSuspense(state, renderError.thenable, block, journalCheckpoint);
16314
+ handleSuspense(state, renderError.thenable, block, journalCheckpoint, source ?? block);
15523
16315
  } else switchToCatch(state, renderError, true);
15524
16316
  } else {
15525
16317
  if (capture !== null) spliceOffscreenCapture(capture);
@@ -15804,6 +16596,7 @@ function releaseHeldTransition(state) {
15804
16596
  if (state.transitionHeld) {
15805
16597
  state.transitionHeld = false;
15806
16598
  tickTransitionCount(-1);
16599
+ releaseTransitionHookHolder(state);
15807
16600
  }
15808
16601
  abandonHeldTransition(state);
15809
16602
  if (state.transitionTimeoutId !== null) {
@@ -15811,14 +16604,15 @@ function releaseHeldTransition(state) {
15811
16604
  state.transitionTimeoutId = null;
15812
16605
  }
15813
16606
  }
15814
- function handleSuspense(state, thenable, sourceBlock, journalCheckpoint = -1) {
16607
+ function handleSuspense(state, thenable, sourceBlock, journalCheckpoint = -1, transitionOrigin = sourceBlock) {
15815
16608
  ensureScheduledVisibilityDriver();
15816
16609
  const isTransition = sourceBlock.currentRenderMode === "transition";
15817
- if ((isTransition || state.transitionHeld) && state.hasResolved && state.branch === 1 && state.hiddenDom === null) {
16610
+ if (isTransition && state.hasResolved && state.branch === 1 && state.hiddenDom === null) {
15818
16611
  rollbackTransitionJournal(journalCheckpoint, state.tryBlock ?? sourceBlock);
15819
16612
  if (ACTIVE_TRANSITION_ATTEMPT !== null) {
15820
16613
  (ACTIVE_TRANSITION_ATTEMPT.heldSlots ??= /* @__PURE__ */ new Set()).add(state);
15821
16614
  }
16615
+ holdTransitionHooksForBlock(state, transitionOrigin);
15822
16616
  if (!state.transitionHeld) {
15823
16617
  state.transitionHeld = true;
15824
16618
  tickTransitionCount(1);
@@ -15839,6 +16633,7 @@ function handleSuspense(state, thenable, sourceBlock, journalCheckpoint = -1) {
15839
16633
  attachResume(state, thenable);
15840
16634
  return;
15841
16635
  }
16636
+ if (!isTransition) releaseHeldTransition(state);
15842
16637
  hideTryContentAndMountPending(state, thenable);
15843
16638
  }
15844
16639
  function invalidatePendingSuspenseEffects(owner) {
@@ -16131,7 +16926,10 @@ function commitResumeInner(state) {
16131
16926
  if (!deferringStagedRevealEffects) commitEffects();
16132
16927
  } finally {
16133
16928
  if (hiddenActivity !== null) rehideActivityAfterDescendantRender(hiddenActivity);
16134
- if (releaseHeld) tickTransitionCount(-1);
16929
+ if (releaseHeld) {
16930
+ tickTransitionCount(-1);
16931
+ releaseTransitionHookHolder(state);
16932
+ }
16135
16933
  }
16136
16934
  }
16137
16935
  function findScheduledVisibilityOwner(block, includeActivity, visibleMode = null) {
@@ -16451,6 +17249,7 @@ function attemptHiddenRevealInner(state, scheduledMode, reason = "update") {
16451
17249
  if (state.transitionHeld) {
16452
17250
  state.transitionHeld = false;
16453
17251
  tickTransitionCount(-1);
17252
+ releaseTransitionHookHolder(state);
16454
17253
  }
16455
17254
  if (HELD_TRANSITIONS.has(state)) {
16456
17255
  HELD_TRANSITIONS.delete(state);
@@ -16505,6 +17304,7 @@ function flushStagedReveals() {
16505
17304
  break;
16506
17305
  }
16507
17306
  }
17307
+ if (allVisible && heldTransitionHasPendingAction(HELD_SYNC_TRANSITION.entries)) return;
16508
17308
  if (allVisible && promoteHeldSyncTransition()) {
16509
17309
  STAGED_REVEALS.clear();
16510
17310
  flush();
@@ -16584,6 +17384,9 @@ function attachResume(state, thenable) {
16584
17384
  thenable.then(retry, retry);
16585
17385
  }
16586
17386
  function startTransition(fn) {
17387
+ runTransition(fn);
17388
+ }
17389
+ function runTransition(fn, hook) {
16587
17390
  ensureTransitionSwapDriver();
16588
17391
  TRANSITION_DEPTH++;
16589
17392
  const parentActionBatch = ACTIVE_TRANSITION_ACTION_BATCH;
@@ -16591,6 +17394,10 @@ function startTransition(fn) {
16591
17394
  const actionBatch = parentActionBatch ?? pendingActionBatch ?? createTransitionActionBatch();
16592
17395
  const ownsActionBatch = parentActionBatch === null && pendingActionBatch === null;
16593
17396
  ACTIVE_TRANSITION_ACTION_BATCH = actionBatch;
17397
+ if (hook !== void 0) {
17398
+ addTransitionHookToBatch(actionBatch, hook);
17399
+ publishTransitionHookBatch(actionBatch);
17400
+ }
16594
17401
  const submitRec = ACTIVE_SUBMIT_DISPATCH;
16595
17402
  if (submitRec !== null) submitRec.transitions++;
16596
17403
  let result;
@@ -16620,7 +17427,10 @@ function startTransition(fn) {
16620
17427
  tickTransitionCount(-1);
16621
17428
  if (submitRec !== null) settleSubmitTransition(submitRec);
16622
17429
  flushFormResets();
16623
- throw err;
17430
+ actionBatch.workComplete = true;
17431
+ finishTransitionHookBatch(actionBatch);
17432
+ reportTransitionError(err, hook);
17433
+ return;
16624
17434
  }
16625
17435
  if (result != null && typeof result.then === "function") {
16626
17436
  ASYNC_TRANSITION_COUNT++;
@@ -16634,16 +17444,31 @@ function startTransition(fn) {
16634
17444
  ASYNC_TRANSITION_COUNT--;
16635
17445
  if (submitRec !== null) settleSubmitTransition(submitRec);
16636
17446
  flushFormResets();
17447
+ queueMicrotask(() => {
17448
+ actionBatch.workComplete = true;
17449
+ finishTransitionHookBatch(actionBatch);
17450
+ });
16637
17451
  };
16638
- result.then(settle, settle);
17452
+ result.then(settle, (error) => {
17453
+ settle();
17454
+ reportTransitionError(error, hook);
17455
+ });
16639
17456
  } else {
16640
17457
  queueMicrotask(() => {
16641
17458
  tickTransitionCount(-1);
16642
17459
  if (submitRec !== null) settleSubmitTransition(submitRec);
16643
17460
  flushFormResets();
17461
+ actionBatch.workComplete = true;
17462
+ finishTransitionHookBatch(actionBatch);
16644
17463
  });
16645
17464
  }
16646
17465
  }
17466
+ function reportTransitionError(error, hook) {
17467
+ if (hook !== void 0 && !hook.block.disposed) {
17468
+ hook.error = { value: error };
17469
+ scheduleRender(hook.block);
17470
+ } else reportListenerError(error);
17471
+ }
16647
17472
  function useTransition(slot) {
16648
17473
  slot = resolveSlot(slot);
16649
17474
  if (slot === void 0) missingSlot("useTransition");
@@ -16651,22 +17476,33 @@ function useTransition(slot) {
16651
17476
  const block = CURRENT_BLOCK;
16652
17477
  let s = scope.hooks?.get(slot);
16653
17478
  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) {
17479
+ const hook = {
17480
+ isPending: false,
17481
+ block,
17482
+ pendingBatches: 0,
17483
+ start: (fn) => {
17484
+ if (!block.disposed) runTransition(fn, hook);
17485
+ },
17486
+ publish: (pending) => {
17487
+ if (hook.isPending === pending || block.disposed) return;
17488
+ hook.isPending = pending;
17489
+ TRANSITION_LISTENER_PUBLISH_DEPTH++;
17490
+ try {
16662
17491
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
16663
17492
  __profileSchedule(block, "transition-pending", slot);
16664
17493
  scheduleRender(block);
17494
+ } finally {
17495
+ TRANSITION_LISTENER_PUBLISH_DEPTH--;
16665
17496
  }
16666
17497
  }
16667
17498
  };
16668
- TRANSITION_LISTENERS.add(listener);
16669
- registerHookCleanup(scope, () => TRANSITION_LISTENERS.delete(listener));
17499
+ s = hook;
17500
+ ensureHooks(scope).set(slot, hook);
17501
+ }
17502
+ if (s.error !== void 0) {
17503
+ const error = s.error.value;
17504
+ s.error = void 0;
17505
+ throw error;
16670
17506
  }
16671
17507
  return [s.isPending, s.start];
16672
17508
  }
@@ -16697,6 +17533,7 @@ function useActionState(action, initialState, permalinkOrSlot, slot) {
16697
17533
  }
16698
17534
  };
16699
17535
  const dispatch = ((payload) => {
17536
+ const outsideTransition = process.env.NODE_ENV !== "production" && transitionActionBatchForUpdate() === null && ACTIVE_SUBMIT_DISPATCH?.intercepted !== true;
16700
17537
  slotRef.pendingCount++;
16701
17538
  setPending(true);
16702
17539
  slotRef.chain = slotRef.chain.then(
@@ -16708,7 +17545,13 @@ function useActionState(action, initialState, permalinkOrSlot, slot) {
16708
17545
  startTransition(() => {
16709
17546
  let p;
16710
17547
  try {
16711
- p = Promise.resolve(slotRef.action(prevState, payload));
17548
+ const result = slotRef.action(prevState, payload);
17549
+ if (process.env.NODE_ENV !== "production" && outsideTransition && result != null && typeof result.then === "function") {
17550
+ console.error(
17551
+ "An async useActionState action was dispatched outside a transition or action. Use an action/formAction prop or wrap the dispatch in startTransition."
17552
+ );
17553
+ }
17554
+ p = Promise.resolve(result);
16712
17555
  } catch (err) {
16713
17556
  finish();
16714
17557
  const handler = findTryHandler(block);
@@ -16736,7 +17579,7 @@ function useActionState(action, initialState, permalinkOrSlot, slot) {
16736
17579
  resolveResult(prevState);
16737
17580
  }
16738
17581
  );
16739
- return p;
17582
+ return p.then(noop, noop);
16740
17583
  });
16741
17584
  })
16742
17585
  );
@@ -16824,6 +17667,11 @@ function useOptimistic(passthrough, updateFnOrSlot, slot) {
16824
17667
  updateFn,
16825
17668
  armed: false,
16826
17669
  add: (value) => {
17670
+ if (process.env.NODE_ENV !== "production" && TRANSITION_DEPTH === 0 && ASYNC_TRANSITION_COUNT === 0) {
17671
+ console.error(
17672
+ "An optimistic update was dispatched outside a transition or action. Wrap it in startTransition or call it from an action."
17673
+ );
17674
+ }
16827
17675
  slotRef.queue.push(value);
16828
17676
  if (TRANSITION_PENDING_COUNT > 0) {
16829
17677
  slotRef.armed = true;
@@ -16857,11 +17705,11 @@ function spawnDeferredSwap(s) {
16857
17705
  queueMicrotask(() => {
16858
17706
  if (!s.scheduled || s.block.disposed) return;
16859
17707
  s.scheduled = false;
16860
- if (Object.is(s.current, s.next)) return;
16861
- s.current = s.next;
17708
+ if (Object.is(s.value, s.next)) return;
16862
17709
  startTransition(() => {
16863
17710
  DEFERRED_SPAWN = true;
16864
17711
  try {
17712
+ stageTransitionValue(s, s.block, s.next, s.next, true);
16865
17713
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
16866
17714
  __profileSchedule(s.block, "deferred-value", s.profileSlot);
16867
17715
  scheduleRender(s.block);
@@ -16872,6 +17720,14 @@ function spawnDeferredSwap(s) {
16872
17720
  });
16873
17721
  });
16874
17722
  }
17723
+ function hasHeldDeferredSwap(slot) {
17724
+ const entries = HELD_SYNC_TRANSITION?.entries ?? slot.block.idState.renderOwner?.transition?.entries;
17725
+ if (entries === void 0) return false;
17726
+ for (const entry of entries) {
17727
+ if (entry.slot === slot && Object.is(entry.value, slot.next)) return true;
17728
+ }
17729
+ return false;
17730
+ }
16875
17731
  function useDeferredValue(value, ...rest) {
16876
17732
  let slot = rest[rest.length - 1];
16877
17733
  slot = resolveSlot(slot);
@@ -16885,7 +17741,7 @@ function useDeferredValue(value, ...rest) {
16885
17741
  if (s === void 0) {
16886
17742
  if (hasInitial && !block.currentRenderDeferred) {
16887
17743
  s = {
16888
- current: initialValue,
17744
+ value: initialValue,
16889
17745
  next: value,
16890
17746
  scheduled: false,
16891
17747
  block,
@@ -16897,31 +17753,32 @@ function useDeferredValue(value, ...rest) {
16897
17753
  if (!Object.is(initialValue, value)) spawnDeferredSwap(s);
16898
17754
  return initialValue;
16899
17755
  }
16900
- s = { current: value, next: value, scheduled: false, block, wasHidden: hidden };
17756
+ s = { value, next: value, scheduled: false, block, wasHidden: hidden };
16901
17757
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
16902
17758
  s.profileSlot = slot;
16903
17759
  ensureHooks(scope).set(slot, s);
16904
17760
  return value;
16905
17761
  }
17762
+ if (ACTIVE_TRANSITION_ATTEMPT !== null) journalObjectOnce(s);
16906
17763
  s.next = value;
16907
17764
  const wasHidden = s.wasHidden;
16908
17765
  s.wasHidden = hidden;
16909
- if (Object.is(s.current, value)) return s.current;
17766
+ if (Object.is(s.value, value)) return s.value;
16910
17767
  if (hidden || wasHidden) {
16911
17768
  if (hasInitial && !block.currentRenderDeferred && !Object.is(initialValue, value)) {
16912
- s.current = initialValue;
17769
+ s.value = initialValue;
16913
17770
  if (!s.scheduled) spawnDeferredSwap(s);
16914
17771
  return initialValue;
16915
17772
  }
16916
- s.current = value;
17773
+ s.value = value;
16917
17774
  return value;
16918
17775
  }
16919
17776
  if (block.currentRenderMode === "transition") {
16920
- s.current = value;
17777
+ s.value = value;
16921
17778
  return value;
16922
17779
  }
16923
- if (!s.scheduled) spawnDeferredSwap(s);
16924
- return s.current;
17780
+ if (!s.scheduled && !hasHeldDeferredSwap(s)) spawnDeferredSwap(s);
17781
+ return s.value;
16925
17782
  }
16926
17783
  function requestReset(state) {
16927
17784
  if (state.parentBlock.disposed || state.branch !== 0) return;
@@ -16995,6 +17852,7 @@ function switchToCatchInner(state, err, reportInline, adoptedStart, adoptedEnd)
16995
17852
  if (state.transitionHeld) {
16996
17853
  state.transitionHeld = false;
16997
17854
  tickTransitionCount(-1);
17855
+ releaseTransitionHookHolder(state);
16998
17856
  }
16999
17857
  abandonHeldTransition(state);
17000
17858
  if (state.catchBody === null) {
@@ -17156,6 +18014,7 @@ function sharesBlockBoundary(parent, start, end) {
17156
18014
  return parent !== null && start !== null && end !== null && parent.startMarker === start && parent.endMarker === end;
17157
18015
  }
17158
18016
  function renderBranchSlot(parentScope, slotKey, state, domParent, next, body, marker, env) {
18017
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
17159
18018
  const parentBlock = parentScope.block;
17160
18019
  const hydration = activeHydration();
17161
18020
  if (next !== state.branch) {
@@ -17820,6 +18679,7 @@ function queueActivityDeactivation(state, block, commitVersion) {
17820
18679
  });
17821
18680
  }
17822
18681
  function activityBlock(parentScope, slotKey, domParent, mode, body, anchor, env) {
18682
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
17823
18683
  if (mode === "hidden") ensureScheduledVisibilityDriver();
17824
18684
  const parentBlock = parentScope.block;
17825
18685
  const hydration = activeHydration();
@@ -18058,7 +18918,7 @@ function deactivateScope(scope, disconnectPassive = true) {
18058
18918
  const cleanup = e.cleanup;
18059
18919
  e.cleanup = void 0;
18060
18920
  try {
18061
- runEffectCleanupCallback(cleanup);
18921
+ runEffectCleanupCallback(cleanup, e.phase);
18062
18922
  } catch (err) {
18063
18923
  if (err instanceof MaximumUpdateDepthError) throw err;
18064
18924
  const handler = findTryHandler(scope.block);
@@ -18109,6 +18969,7 @@ function switchBlock(parentScope, slotKey, domParent, discriminant, cases, defau
18109
18969
  renderBranchSlot(parentScope, slotKey, state, domParent, nextIdx, body, "switch", env);
18110
18970
  }
18111
18971
  function forBlock(parentScope, slotKey, domParent, items, getKey, itemBody, flags, deps, emptyBody, anchor, ownEnd) {
18972
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
18112
18973
  const parentBlock = parentScope.block;
18113
18974
  const hydration = activeHydration();
18114
18975
  let state = parentScope.slots[slotKey];
@@ -18264,6 +19125,7 @@ function forBlock(parentScope, slotKey, domParent, items, getKey, itemBody, flag
18264
19125
  }
18265
19126
  }
18266
19127
  function keyedForBlock(parentScope, slotKey, domParent, items, getKey, itemBody, flags, deps, emptyBody, anchor, ownEnd, selectionBody) {
19128
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
18267
19129
  const state = parentScope.slots[slotKey];
18268
19130
  if (TRANSITION_JOURNAL !== null && ROOT_RENDER_TRANSACTION === null) {
18269
19131
  if (state !== void 0) {
@@ -18592,9 +19454,25 @@ function consumeAdoptQueuePrefix(adopt, count) {
18592
19454
  if (count < adopt.length) adopt.copyWithin(0, count);
18593
19455
  adopt.length -= count;
18594
19456
  }
19457
+ function checkedListKey(getKey) {
19458
+ const seen = /* @__PURE__ */ new Map();
19459
+ let warned = false;
19460
+ return (item, index) => {
19461
+ const key = getKey(item, index);
19462
+ if (!warned && seen.has(key) && seen.get(key) !== index) {
19463
+ warned = true;
19464
+ const label = typeof key === "object" || typeof key === "function" ? "[object identity]" : String(key);
19465
+ console.error(
19466
+ `Encountered two children with the same key, ${label}. Keys should be unique so that components maintain their identity across updates.`
19467
+ );
19468
+ } else seen.set(key, index);
19469
+ return key;
19470
+ };
19471
+ }
18595
19472
  function mountItemsLinear(parentBlock, state, items, getKey, itemBody, singleRoot, ssrMarkerless) {
18596
19473
  const newLen = items.length;
18597
19474
  if (newLen === 0) return;
19475
+ if (process.env.NODE_ENV !== "production") getKey = checkedListKey(getKey);
18598
19476
  if (TRANSITION_JOURNAL !== null) journalForSlot(state);
18599
19477
  const oldItems = state.items;
18600
19478
  const parentNode = state.end.parentNode;
@@ -18664,6 +19542,7 @@ function reconcileKeyed(parentBlock, state, items, getKey, itemBody, pure, singl
18664
19542
  mountItemsLinear(parentBlock, state, items, getKey, itemBody, singleRoot, ssrMarkerless);
18665
19543
  return;
18666
19544
  }
19545
+ if (process.env.NODE_ENV !== "production") getKey = checkedListKey(getKey);
18667
19546
  if (newLen === 0) {
18668
19547
  if (journalShape) journalForSlot(state);
18669
19548
  batchClearItems(state, oldItems);
@@ -18922,81 +19801,72 @@ function reconcileKeyed(parentBlock, state, items, getKey, itemBody, pure, singl
18922
19801
  }
18923
19802
  }
18924
19803
  const middleEndAnchor = afterMiddle ? afterMiddle.startMarker : state.end;
18925
- let nextBlock = afterMiddle;
18926
- let lastPlaced = null;
18927
- if (moved) {
19804
+ if (patched === newMidLen) {
18928
19805
  const seq = lis(sources, newMidLen);
18929
19806
  let seqIdx = seq.length - 1;
19807
+ let nextBlock = afterMiddle;
18930
19808
  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
- }
19809
+ const block = oldItems.get(newKeys[i]);
19810
+ if (seqIdx < 0 || i !== seq[seqIdx]) {
19811
+ moveBlockBefore(block, nextBlock ? nextBlock.startMarker : middleEndAnchor);
19812
+ } else seqIdx--;
18958
19813
  block.nextSibling = nextBlock;
18959
19814
  if (nextBlock) nextBlock.prevSibling = block;
18960
- if (lastPlaced === null) lastPlaced = block;
19815
+ else state.tail = block;
18961
19816
  nextBlock = block;
18962
19817
  }
18963
- } else {
19818
+ nextBlock.prevSibling = beforeMiddle;
19819
+ if (beforeMiddle) beforeMiddle.nextSibling = nextBlock;
19820
+ else state.head = nextBlock;
19821
+ return;
19822
+ }
19823
+ if (moved) {
19824
+ const seq = lis(sources, newMidLen);
19825
+ let seqIdx = seq.length - 1;
19826
+ let anchor = middleEndAnchor;
18964
19827
  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);
19828
+ if (sources[i] === -1) continue;
19829
+ const block = oldItems.get(newKeys[i]);
19830
+ if (seqIdx < 0 || i !== seq[seqIdx]) moveBlockBefore(block, anchor);
19831
+ else seqIdx--;
19832
+ anchor = block.startMarker;
19833
+ }
19834
+ }
19835
+ let previous = beforeMiddle;
19836
+ let nextSurvivor = 0;
19837
+ for (let i = 0; i < newMidLen; i++) {
19838
+ const key = newKeys[i];
19839
+ let block;
19840
+ if (sources[i] === -1) {
19841
+ if (nextSurvivor <= i) {
19842
+ nextSurvivor = i + 1;
19843
+ while (nextSurvivor < newMidLen && sources[nextSurvivor] === -1) nextSurvivor++;
18987
19844
  }
18988
- block.nextSibling = nextBlock;
18989
- if (nextBlock) nextBlock.prevSibling = block;
18990
- if (lastPlaced === null) lastPlaced = block;
18991
- nextBlock = block;
18992
- }
19845
+ const anchor = nextSurvivor < newMidLen ? oldItems.get(newKeys[nextSurvivor]).startMarker : middleEndAnchor;
19846
+ const targetIdx = i + prefixLen;
19847
+ block = mountItem(
19848
+ parentBlock,
19849
+ parentNode,
19850
+ anchor,
19851
+ items[targetIdx],
19852
+ targetIdx,
19853
+ itemBody,
19854
+ state,
19855
+ singleRoot,
19856
+ ssrMarkerless
19857
+ );
19858
+ oldItems.set(key, block);
19859
+ block.key = key;
19860
+ state.size++;
19861
+ } else block = oldItems.get(key);
19862
+ block.prevSibling = previous;
19863
+ if (previous) previous.nextSibling = block;
19864
+ else state.head = block;
19865
+ previous = block;
18993
19866
  }
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;
19867
+ previous.nextSibling = afterMiddle;
19868
+ if (afterMiddle) afterMiddle.prevSibling = previous;
19869
+ else state.tail = previous;
19000
19870
  } finally {
19001
19871
  if (sources.length <= MAX_KEYED_REORDER_SCRATCH && (keyedReorderSources === null || keyedReorderSources.length < sources.length)) {
19002
19872
  keyedReorderSources = sources;
@@ -19702,8 +20572,19 @@ let ROOT_CONTAINER_OWNERS = null;
19702
20572
  const ROOT_RENDERABLE_BODY = ((value) => value === void 0 ? null : value);
19703
20573
  const EMPTY_ROOT_BODY = (() => void 0);
19704
20574
  function assertValidRootContainer(container) {
19705
- if (container === null || typeof container !== "object" || container.nodeType !== 1) {
19706
- throw new Error(formatClientError(28));
20575
+ if (container === null || typeof container !== "object" || container.nodeType !== 1 && container.nodeType !== 9 && container.nodeType !== 11) {
20576
+ throw new Error(formatClientError(63));
20577
+ }
20578
+ }
20579
+ function clearRootContainer(container) {
20580
+ if (container.nodeType !== 9) {
20581
+ container.textContent = "";
20582
+ return;
20583
+ }
20584
+ for (let child2 = container.firstChild; child2 !== null; ) {
20585
+ const next = child2.nextSibling;
20586
+ if (child2.nodeType !== 10) container.removeChild(child2);
20587
+ child2 = next;
19707
20588
  }
19708
20589
  }
19709
20590
  function claimRootContainer(container) {
@@ -19812,17 +20693,19 @@ function devHtmlNesting(childTag, ancestors, childLocation, ancestorLocation) {
19812
20693
  }
19813
20694
  function validateRootHtmlNesting(container, body) {
19814
20695
  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("-")) {
20696
+ if (container.nodeType !== 1) return;
20697
+ const element = container;
20698
+ 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
20699
  return;
19817
20700
  }
19818
20701
  const root = container.firstElementChild;
19819
20702
  if (root === null) return;
19820
- if (invalidHtmlNestingWithParent(root.localName, container.localName) !== null) {
19821
- devHtmlNesting(root.localName, [container.localName]);
20703
+ if (invalidHtmlNestingWithParent(root.localName, element.localName) !== null) {
20704
+ devHtmlNesting(root.localName, [element.localName]);
19822
20705
  return;
19823
20706
  }
19824
20707
  let child2 = root.firstElementChild;
19825
- const ancestors = [root.localName, container.localName];
20708
+ const ancestors = [root.localName, element.localName];
19826
20709
  while (child2 !== null && child2.namespaceURI === "http://www.w3.org/1999/xhtml") {
19827
20710
  if (invalidHtmlNestingWithAncestor(child2.localName, ancestors) !== null) {
19828
20711
  devHtmlNesting(child2.localName, ancestors);
@@ -19887,7 +20770,7 @@ function makeRoot(container, rootBlock, currentBody, currentKey, idState, output
19887
20770
  const previousRoot = rootBlock;
19888
20771
  const previousBody = currentBody;
19889
20772
  const previousKey = currentKey;
19890
- const staged = previousRoot !== null && previousRoot.mounted && !previousRoot.disposed && !renderOwner.transaction.created?.has(previousRoot);
20773
+ const staged = container.nodeType !== 9 && previousRoot !== null && previousRoot.mounted && !previousRoot.disposed && !renderOwner.transaction.created?.has(previousRoot);
19891
20774
  const oldFirst = staged ? container.firstChild : null;
19892
20775
  const oldLast = staged ? container.lastChild : null;
19893
20776
  journalUndo(() => {
@@ -19912,7 +20795,7 @@ function makeRoot(container, rootBlock, currentBody, currentKey, idState, output
19912
20795
  end = document.createComment("/root");
19913
20796
  container.append(start, end);
19914
20797
  } else {
19915
- while (container.firstChild) container.removeChild(container.firstChild);
20798
+ clearRootContainer(container);
19916
20799
  }
19917
20800
  rootBlock = createBlock(
19918
20801
  "root",
@@ -19955,6 +20838,7 @@ function makeRoot(container, rootBlock, currentBody, currentKey, idState, output
19955
20838
  mountedRoot.pendingMode = mode ?? null;
19956
20839
  try {
19957
20840
  renderBlock(mountedRoot);
20841
+ if (QUEUE.length > 0) drainHydrationRenderPhaseUpdates(mountedRoot);
19958
20842
  if (process.env.NODE_ENV !== "production") {
19959
20843
  validateRootHtmlNesting(container, body);
19960
20844
  }
@@ -20073,7 +20957,8 @@ function makeRoot(container, rootBlock, currentBody, currentKey, idState, output
20073
20957
  false
20074
20958
  );
20075
20959
  drainRefDetaches();
20076
- container.textContent = "";
20960
+ clearRootContainer(container);
20961
+ drainDeferredPassiveUnmounts();
20077
20962
  rootBlock = null;
20078
20963
  currentBody = null;
20079
20964
  currentKey = null;
@@ -20232,7 +21117,7 @@ function hydrateRoot(container, bodyOrElement, propsOrOptions, rootOptions) {
20232
21117
  journalRootProperty(idState, "next");
20233
21118
  idState.next = 0;
20234
21119
  let firstNode = container.firstChild;
20235
- while (firstNode !== null && isRendererHydrationStyle(firstNode))
21120
+ while (firstNode !== null && (firstNode.nodeType === 10 || isRendererHydrationStyle(firstNode)))
20236
21121
  firstNode = firstNode.nextSibling;
20237
21122
  const hydration = new HydrationCapability(rootBlock, firstNode, seeds);
20238
21123
  if (nativeManifest !== void 0)
@@ -20265,7 +21150,7 @@ function hydrateRoot(container, bodyOrElement, propsOrOptions, rootOptions) {
20265
21150
  } catch (unhandled) {
20266
21151
  rollbackRootRender(owner.transaction);
20267
21152
  unmountBlock(rootBlock, false);
20268
- container.textContent = "";
21153
+ clearRootContainer(container);
20269
21154
  if (!reportUncaughtError(rootBlock, unhandled)) throw unhandled;
20270
21155
  return;
20271
21156
  }
@@ -20759,15 +21644,18 @@ export {
20759
21644
  hydrateRoot,
20760
21645
  ifBlock,
20761
21646
  injectStyle,
21647
+ invokeManualHook,
20762
21648
  isChildrenBlock,
20763
21649
  isValidElement,
20764
21650
  keyedForBlock,
20765
21651
  lazy,
21652
+ manualHook,
20766
21653
  mapSlot,
20767
21654
  markChildrenBlock,
20768
21655
  markDangerouslySetInnerHTMLChildren,
20769
21656
  markNativeChangeDiagnosticStatic,
20770
21657
  markSingleRoot,
21658
+ markWarm,
20771
21659
  memo,
20772
21660
  memoPublish,
20773
21661
  memoPublishAlways,