octane 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/cjs/compatibility.cjs +35 -0
  2. package/dist/cjs/component-flags.cjs +8 -1
  3. package/dist/cjs/css.cjs +9 -0
  4. package/dist/cjs/dom-tables.cjs +8 -1
  5. package/dist/cjs/error-codes.client.generated.cjs +15 -2
  6. package/dist/cjs/error-codes.server.generated.cjs +5 -0
  7. package/dist/cjs/event-names.cjs +39 -0
  8. package/dist/cjs/index.cjs +13 -0
  9. package/dist/cjs/runtime.cjs +1345 -359
  10. package/dist/cjs/runtime.server.cjs +620 -183
  11. package/dist/cjs/server/index.cjs +26 -0
  12. package/dist/cjs/version.cjs +1 -1
  13. package/dist/compatibility.d.ts +7 -0
  14. package/dist/compatibility.js +10 -0
  15. package/dist/compiler/bundler.js +20 -30
  16. package/dist/compiler/compile-renderer-boundaries.js +1 -0
  17. package/dist/compiler/compile-universal.js +3 -0
  18. package/dist/compiler/compile.js +877 -627
  19. package/dist/compiler/hook-deps.js +100 -3
  20. package/dist/compiler/hook-names.js +1 -0
  21. package/dist/compiler/hydrate-boundaries.js +165 -15
  22. package/dist/compiler/manual-hooks.js +171 -0
  23. package/dist/compiler/parser.node.js +34 -8
  24. package/dist/compiler/plain-hook-memo.js +54 -5
  25. package/dist/compiler/slot-hooks.d.ts +43 -0
  26. package/dist/compiler/slot-hooks.js +154 -35
  27. package/dist/compiler/strong-mode.js +836 -3
  28. package/dist/compiler/style-scopes.js +1134 -0
  29. package/dist/compiler/volar.LICENSES.txt +1 -1
  30. package/dist/compiler/volar.js +4543 -2839
  31. package/dist/component-flags.d.ts +1 -1
  32. package/dist/component-flags.js +8 -1
  33. package/dist/css.d.ts +7 -0
  34. package/dist/css.js +8 -0
  35. package/dist/dom-tables.js +8 -1
  36. package/dist/error-codes.client.generated.d.ts +3 -1
  37. package/dist/error-codes.client.generated.js +15 -2
  38. package/dist/error-codes.server.generated.d.ts +1 -0
  39. package/dist/error-codes.server.generated.js +5 -0
  40. package/dist/event-names.d.ts +1 -0
  41. package/dist/event-names.js +15 -0
  42. package/dist/html-tree-validation.d.ts +17 -34
  43. package/dist/index.d.ts +3 -1
  44. package/dist/index.js +12 -1
  45. package/dist/jsx-runtime.d.ts +6 -1
  46. package/dist/public-types.d.ts +188 -0
  47. package/dist/public-types.js +0 -0
  48. package/dist/runtime.d.ts +128 -69
  49. package/dist/runtime.js +1349 -360
  50. package/dist/runtime.server.d.ts +67 -15
  51. package/dist/runtime.server.js +619 -184
  52. package/dist/server/index.d.ts +4 -2
  53. package/dist/server/index.js +23 -0
  54. package/dist/static/index.d.ts +2 -1
  55. package/dist/static/index.js +3 -1
  56. package/dist/universal-core.d.ts +8 -1
  57. package/dist/universal-core.js +95 -9
  58. package/dist/version.js +1 -1
  59. package/package.json +4 -3
@@ -128,15 +128,18 @@ __export(runtime_exports, {
128
128
  hydrateRoot: () => hydrateRoot,
129
129
  ifBlock: () => ifBlock,
130
130
  injectStyle: () => injectStyle,
131
+ invokeManualHook: () => invokeManualHook,
131
132
  isChildrenBlock: () => isChildrenBlock,
132
133
  isValidElement: () => isValidElement,
133
134
  keyedForBlock: () => keyedForBlock,
134
135
  lazy: () => lazy,
136
+ manualHook: () => manualHook,
135
137
  mapSlot: () => mapSlot,
136
138
  markChildrenBlock: () => markChildrenBlock,
137
139
  markDangerouslySetInnerHTMLChildren: () => markDangerouslySetInnerHTMLChildren,
138
140
  markNativeChangeDiagnosticStatic: () => markNativeChangeDiagnosticStatic,
139
141
  markSingleRoot: () => markSingleRoot,
142
+ markWarm: () => markWarm,
140
143
  memo: () => memo,
141
144
  memoPublish: () => memoPublish,
142
145
  memoPublishAlways: () => memoPublishAlways,
@@ -268,6 +271,7 @@ __export(runtime_exports, {
268
271
  });
269
272
  module.exports = __toCommonJS(runtime_exports);
270
273
  var import_constants = require("./constants.cjs");
274
+ var import_event_names = require("./event-names.cjs");
271
275
  var import_has_own = require("./has-own.cjs");
272
276
  var import_head_ownership = require("./head-ownership.cjs");
273
277
  var import_resource_hint_diagnostics = require("./resource-hint-diagnostics.cjs");
@@ -343,15 +347,22 @@ function beginActiveNativeReadScope(scope) {
343
347
  const block = CURRENT_BLOCK;
344
348
  return block === null ? -1 : NATIVE_READ_DRIVER.beginScope(scope, block);
345
349
  }
350
+ function scheduleNativeRead(target) {
351
+ invalidateRender(target, target);
352
+ const retainPriority = SCHEDULED_VISIBILITY_DRIVER?.holdsNativeRead(target) === true;
353
+ if (retainPriority) TRANSITION_DEPTH++;
354
+ try {
355
+ scheduleRender(target);
356
+ } finally {
357
+ if (retainPriority) TRANSITION_DEPTH--;
358
+ }
359
+ }
346
360
  function ensureNativeReadDriver() {
347
361
  if (NATIVE_READ_DRIVER !== null) return NATIVE_READ_DRIVER;
348
362
  NATIVE_READ_DRIVER = (0, import_native_read_client.createNativeReadDriver)({
349
363
  capture: () => WIP_CAPTURE,
350
364
  cleanup: registerHookCleanup,
351
- schedule: (target) => {
352
- invalidateRender(target, target);
353
- scheduleRender(target);
354
- },
365
+ schedule: scheduleNativeRead,
355
366
  suspended: retainNativeRetryReads,
356
367
  replayRefs: (capture, owner) => replayNativeUnpublishedRefs(capture, owner),
357
368
  refDisposed: (entry) => blockSubtreeDisposed(entry.block)
@@ -440,10 +451,7 @@ function retainNativeRetryReads(block, reads) {
440
451
  if (retry2 === void 0) {
441
452
  const owner2 = current;
442
453
  retry2 = (0, import_native_read_retry.createNativeReadRetry)(() => {
443
- if (!owner2.disposed) {
444
- invalidateRender(owner2, owner2);
445
- scheduleRender(owner2);
446
- }
454
+ if (!owner2.disposed) scheduleNativeRead(owner2);
447
455
  });
448
456
  retries.set(owner2, retry2);
449
457
  const owned = retry2;
@@ -640,6 +648,9 @@ const RENDERER_REGION_DOM_OWNERS = /* @__PURE__ */ new WeakMap();
640
648
  const RENDERER_REGION_DOM_BINDINGS = /* @__PURE__ */ new WeakMap();
641
649
  const DOM_ROOT_DISPOSERS = /* @__PURE__ */ new WeakMap();
642
650
  let EFFECT_BODY_DEPTH = 0;
651
+ let CURRENT_EFFECT_PHASE = -1;
652
+ let EFFECT_COMMIT_DEPTH = 0;
653
+ let COMMIT_PHASE_ERRORS = null;
643
654
  let REF_CALLBACK_DEPTH = 0;
644
655
  let STORE_SYNC_DEPTH = 0;
645
656
  let EFFECT_EVENT_LIFECYCLE_DEPTH = 0;
@@ -653,12 +664,15 @@ function runEffectLifecycleCallback(callback) {
653
664
  EFFECT_EVENT_LIFECYCLE_DEPTH--;
654
665
  }
655
666
  }
656
- function runEffectCleanupCallback(callback) {
667
+ function runEffectCleanupCallback(callback, phase = -1) {
668
+ const previousPhase = CURRENT_EFFECT_PHASE;
669
+ CURRENT_EFFECT_PHASE = phase;
657
670
  EFFECT_BODY_DEPTH++;
658
671
  try {
659
672
  runEffectLifecycleCallback(callback);
660
673
  } finally {
661
674
  EFFECT_BODY_DEPTH--;
675
+ CURRENT_EFFECT_PHASE = previousPhase;
662
676
  }
663
677
  }
664
678
  const QUEUE = [];
@@ -677,17 +691,31 @@ function ensureTransitionSwapDriver() {
677
691
  splice: spliceWipCapture,
678
692
  begin: beginTransitionAttempt,
679
693
  end: endTransitionAttempt,
694
+ beginUrgent: beginUrgentTransitionRender,
695
+ endUrgent: endUrgentTransitionRender,
680
696
  holdRoot: holdRootTransition,
681
697
  retryRoot: retryRootTransition,
682
698
  commitRoot: commitRootTransition,
683
699
  discardRoot: discardRootTransition,
684
- keepsRoot: keepsRootTransition
700
+ keepsRoot: keepsRootTransition,
701
+ cancelEqual: cancelHeldTransitionUpdate,
702
+ hasHeld: hasHeldTransitionUpdate,
703
+ heldUpdate: getHeldTransitionUpdate,
704
+ rebaseHeld: rebaseHeldTransitionUpdate
685
705
  };
686
706
  }
687
707
  let ACTIVE_TRANSITION_ACTION_BATCH = null;
688
708
  let IN_FLIGHT_TRANSITION_ACTION_BATCH = null;
689
709
  function createTransitionActionBatch() {
690
- return { updates: /* @__PURE__ */ new Map(), pendingActions: 0, closed: false, flushed: false };
710
+ return {
711
+ updates: /* @__PURE__ */ new Map(),
712
+ pendingActions: 0,
713
+ closed: false,
714
+ flushed: false,
715
+ hook: null,
716
+ hooks: null,
717
+ hooksPending: false
718
+ };
691
719
  }
692
720
  function transitionActionBatchForUpdate() {
693
721
  if (ACTIVE_TRANSITION_ACTION_BATCH !== null) return ACTIVE_TRANSITION_ACTION_BATCH;
@@ -695,6 +723,7 @@ function transitionActionBatchForUpdate() {
695
723
  return IN_FLIGHT_TRANSITION_ACTION_BATCH;
696
724
  }
697
725
  function rebaseTransitionActionUpdate(update) {
726
+ if (update.state !== void 0 || update.reducer !== void 0) return update.value;
698
727
  if (Object.is(update.baseValue, update.slot.value)) return update.value;
699
728
  let value = update.slot.value;
700
729
  for (const operation of update.operations) value = operation(value);
@@ -703,26 +732,31 @@ function rebaseTransitionActionUpdate(update) {
703
732
  if (update.slot.pendingActionBatch !== void 0) update.slot.pendingActionValue = value;
704
733
  return value;
705
734
  }
706
- function stagedTransitionValue(slot) {
735
+ function stagedTransitionValue(slot, block) {
707
736
  const batch = transitionActionBatchForUpdate();
708
737
  if (batch === null) return slot.value;
709
738
  const update = batch.updates.get(slot);
710
- return update === void 0 ? slot.value : rebaseTransitionActionUpdate(update);
739
+ if (update !== void 0) return rebaseTransitionActionUpdate(update);
740
+ if (slot.renderTransition !== void 0) return slot.renderTransition.value;
741
+ const held = block === void 0 ? void 0 : TRANSITION_SWAP_DRIVER?.heldUpdate(slot, block);
742
+ return held === void 0 ? slot.value : held.value;
711
743
  }
712
744
  function stageTransitionValue(slot, block, operation, value, forceRender = false) {
713
745
  const batch = transitionActionBatchForUpdate();
714
- if (batch === null) return false;
746
+ if (batch === null) return null;
715
747
  const replay = typeof operation === "function" ? operation : () => operation;
716
- const current = batch.updates.get(slot);
748
+ let current = batch.updates.get(slot);
717
749
  if (current === void 0) {
718
- batch.updates.set(slot, {
750
+ current = {
751
+ batch,
719
752
  slot,
720
753
  block,
721
754
  operations: [replay],
722
755
  baseValue: slot.value,
723
756
  value,
724
757
  forceRender
725
- });
758
+ };
759
+ batch.updates.set(slot, current);
726
760
  } else {
727
761
  current.operations.push(replay);
728
762
  current.value = value;
@@ -730,23 +764,36 @@ function stageTransitionValue(slot, block, operation, value, forceRender = false
730
764
  }
731
765
  slot.pendingActionBatch = batch;
732
766
  slot.pendingActionValue = value;
733
- return true;
767
+ return current;
734
768
  }
735
769
  function flushTransitionActionBatch(batch) {
736
770
  if (batch.flushed) return;
737
771
  batch.flushed = true;
738
772
  for (const update of batch.updates.values()) {
739
773
  const { slot, block, forceRender } = update;
740
- const value = rebaseTransitionActionUpdate(update);
774
+ const value = update.state === void 0 && update.reducer === void 0 ? rebaseTransitionActionUpdate(update) : update.value;
741
775
  if (slot.pendingActionBatch === batch) {
742
776
  slot.pendingActionBatch = void 0;
743
777
  slot.pendingActionValue = void 0;
744
778
  }
745
779
  if (block.disposed) continue;
780
+ const state = update.state;
781
+ const reducer = update.reducer;
782
+ const previous = state?.renderTransition ?? reducer?.renderTransition;
783
+ if (state !== void 0 || reducer !== void 0) {
784
+ update.baseValue = previous === void 0 ? slot.value : previous.baseValue;
785
+ if (state !== void 0) {
786
+ state.updates = void 0;
787
+ } else if (reducer !== void 0) {
788
+ reducer.renderPhaseActions = void 0;
789
+ }
790
+ }
746
791
  const changed = !Object.is(slot.value, value);
747
- if (!changed && !forceRender) continue;
792
+ if (!changed && !forceRender && update.previous === void 0) continue;
748
793
  if (changed) slot.value = value;
749
- if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
794
+ if (update.reducer !== void 0) update.reducer.renderTransition = update;
795
+ if (update.state !== void 0) update.state.renderTransition = update;
796
+ if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__ && (changed || update.profileType !== "state"))
750
797
  (0, import_profiling.__profileSchedule)(
751
798
  block,
752
799
  update.profileType ?? (forceRender ? "reducer" : "state"),
@@ -772,6 +819,74 @@ function flushTransitionActionBatchIfReady(batch) {
772
819
  let DEFERRED_SPAWN = false;
773
820
  let TRANSITION_PENDING_COUNT = 0;
774
821
  const TRANSITION_LISTENERS = /* @__PURE__ */ new Set();
822
+ let TRANSITION_HOOK_HOLDERS = null;
823
+ function addTransitionHookToBatch(batch, hook) {
824
+ if (batch.hook === null) batch.hook = hook;
825
+ else if (batch.hook !== hook) {
826
+ const hooks = batch.hooks;
827
+ if (hooks === null) batch.hooks = [hook];
828
+ else if (hooks.includes(hook)) return;
829
+ else hooks.push(hook);
830
+ } else return;
831
+ if (batch.hooksPending) {
832
+ hook.pendingBatches++;
833
+ hook.publish(true);
834
+ }
835
+ }
836
+ function publishTransitionHookBatch(batch) {
837
+ const hook = batch.hook;
838
+ if (hook === null || batch.hooksPending) return;
839
+ batch.hooksPending = true;
840
+ hook.pendingBatches++;
841
+ hook.publish(true);
842
+ const hooks = batch.hooks;
843
+ if (hooks !== null) {
844
+ for (let i = 0; i < hooks.length; i++) {
845
+ hooks[i].pendingBatches++;
846
+ hooks[i].publish(true);
847
+ }
848
+ }
849
+ }
850
+ function finishTransitionHookBatch(batch) {
851
+ if (!batch.workComplete || batch.pendingActions !== 0 || (batch.pendingHolds ?? 0) !== 0) return;
852
+ if (!batch.hooksPending) return;
853
+ batch.hooksPending = false;
854
+ const hook = batch.hook;
855
+ if (--hook.pendingBatches === 0) hook.publish(false);
856
+ const hooks = batch.hooks;
857
+ if (hooks !== null) {
858
+ for (let i = 0; i < hooks.length; i++) {
859
+ if (--hooks[i].pendingBatches === 0) hooks[i].publish(false);
860
+ }
861
+ }
862
+ }
863
+ function holdTransitionHookBatch(holder, batch) {
864
+ if (batch.hook === null) return;
865
+ const holders = TRANSITION_HOOK_HOLDERS ??= /* @__PURE__ */ new WeakMap();
866
+ let batches = holders.get(holder);
867
+ if (batches === void 0) holders.set(holder, batches = /* @__PURE__ */ new Set());
868
+ if (batches.has(batch)) return;
869
+ batches.add(batch);
870
+ batch.pendingHolds = (batch.pendingHolds ?? 0) + 1;
871
+ publishTransitionHookBatch(batch);
872
+ }
873
+ function releaseTransitionHookHolder(holder) {
874
+ const batches = TRANSITION_HOOK_HOLDERS?.get(holder);
875
+ if (batches === void 0) return;
876
+ TRANSITION_HOOK_HOLDERS.delete(holder);
877
+ for (const batch of batches) {
878
+ batch.pendingHolds--;
879
+ finishTransitionHookBatch(batch);
880
+ }
881
+ }
882
+ function holdTransitionHooksForBlock(holder, block) {
883
+ for (const entries of FLUSHED_TRANSITION_UPDATES) {
884
+ for (const entry of entries) {
885
+ if (entry.batch !== void 0 && blockIsAncestor(entry.block, block))
886
+ holdTransitionHookBatch(holder, entry.batch);
887
+ }
888
+ }
889
+ }
775
890
  let TRANSITION_LISTENER_PUBLISH_DEPTH = 0;
776
891
  const HELD_TRANSITIONS = /* @__PURE__ */ new Set();
777
892
  const STAGED_REVEALS = /* @__PURE__ */ new Set();
@@ -780,6 +895,111 @@ let deferringStagedRevealEffects = false;
780
895
  let ACTIVE_TRANSITION_ATTEMPT = null;
781
896
  let FLUSHED_TRANSITION_UPDATES = [];
782
897
  let HELD_SYNC_TRANSITION = null;
898
+ function urgentTransitionCellUpdate(block) {
899
+ return TRANSITION_DEPTH === 0 && !(CURRENT_BLOCK === block && block.currentRenderMode === "transition") && (syncFlush || _dispatchDepth > 0 || ASYNC_TRANSITION_COUNT === 0);
900
+ }
901
+ function latestHeldTransitionUpdate(entry) {
902
+ while (entry.next?.batch?.flushed === true && !entry.next.superseded) entry = entry.next;
903
+ return entry;
904
+ }
905
+ function findHeldTransitionUpdate(slot, block) {
906
+ if (!urgentTransitionCellUpdate(block)) return;
907
+ return getHeldTransitionUpdate(slot, block);
908
+ }
909
+ function getHeldTransitionUpdate(slot, block) {
910
+ if (block.disposed) return;
911
+ const rootHeld = block.idState.renderOwner?.transition;
912
+ if (HELD_SYNC_TRANSITION === null && rootHeld === void 0 && FLUSHED_TRANSITION_UPDATES.length === 0)
913
+ return;
914
+ const groups = [HELD_SYNC_TRANSITION?.entries, rootHeld?.entries];
915
+ for (const entries of groups) {
916
+ if (entries === void 0) continue;
917
+ for (let i = entries.length - 1; i >= 0; i--) {
918
+ const entry = entries[i];
919
+ if (entry.slot === slot && !entry.superseded && Object.is(slot.value, entry.baseValue))
920
+ return latestHeldTransitionUpdate(entry);
921
+ }
922
+ }
923
+ for (let i = FLUSHED_TRANSITION_UPDATES.length - 1; i >= 0; i--) {
924
+ const entries = FLUSHED_TRANSITION_UPDATES[i];
925
+ for (let j = entries.length - 1; j >= 0; j--) {
926
+ const entry = entries[j];
927
+ if (entry.slot === slot && !entry.superseded && Object.is(slot.value, entry.baseValue) && // A completed hook render clears this pointer before the flush's
928
+ // retained-entry list is released. Returning to an old base value
929
+ // must not turn that completed update into pending work again.
930
+ (entry.state === void 0 && entry.reducer === void 0 || slot.renderTransition !== void 0))
931
+ return latestHeldTransitionUpdate(entry);
932
+ }
933
+ }
934
+ }
935
+ function hasHeldTransitionUpdate(slot, block) {
936
+ return findHeldTransitionUpdate(slot, block) !== void 0;
937
+ }
938
+ function cancelHeldTransitionUpdate(slot, block) {
939
+ if (!urgentTransitionCellUpdate(block)) return false;
940
+ const rootHeld = block.idState.renderOwner?.transition;
941
+ if (HELD_SYNC_TRANSITION === null && rootHeld === void 0 && FLUSHED_TRANSITION_UPDATES.length === 0)
942
+ return false;
943
+ let cancelled = false;
944
+ const cancel = (entries) => {
945
+ if (entries === void 0) return;
946
+ for (const entry of entries) {
947
+ if (entry.slot === slot && !entry.superseded) {
948
+ entry.superseded = true;
949
+ cancelled = true;
950
+ }
951
+ }
952
+ };
953
+ cancel(HELD_SYNC_TRANSITION?.entries);
954
+ cancel(rootHeld?.entries);
955
+ for (const entries of FLUSHED_TRANSITION_UPDATES) cancel(entries);
956
+ return cancelled;
957
+ }
958
+ function rebaseHeldTransitionUpdate(slot, block, actions, reducer) {
959
+ const entry = findHeldTransitionUpdate(slot, block);
960
+ if (entry === void 0) return;
961
+ if (slot.pendingActionBatch?.flushed === false) return;
962
+ let value = entry.value;
963
+ for (const action of actions) {
964
+ value = reducer ? reducer(value, action) : typeof action === "function" ? action(value) : action;
965
+ }
966
+ if (Object.is(value, entry.baseValue)) {
967
+ cancelHeldTransitionUpdate(slot, block);
968
+ return;
969
+ }
970
+ const changed = !Object.is(value, entry.value);
971
+ for (let current = entry; current; current = current.previous)
972
+ current.value = value;
973
+ for (const action of actions) {
974
+ entry.operations.push(
975
+ reducer ? (previous) => reducer(previous, action) : typeof action === "function" ? action : () => action
976
+ );
977
+ }
978
+ if (changed) scheduleHeldTransitionReplay(entry, block);
979
+ }
980
+ function scheduleHeldTransitionReplay(entry, block) {
981
+ const held = HELD_SYNC_TRANSITION;
982
+ if (held !== null && held.entries.includes(entry)) {
983
+ if (held.replayScheduled) return;
984
+ held.replayScheduled = true;
985
+ queueMicrotask(() => {
986
+ if (HELD_SYNC_TRANSITION !== held) return;
987
+ held.replayScheduled = false;
988
+ promoteHeldSyncTransition();
989
+ });
990
+ return;
991
+ }
992
+ const owner = block.idState.renderOwner;
993
+ const rootHeld = owner?.transition;
994
+ if (rootHeld === void 0 || !rootHeld.entries.includes(entry) || rootHeld.replayScheduled)
995
+ return;
996
+ rootHeld.replayScheduled = true;
997
+ queueMicrotask(() => {
998
+ if (owner.transition !== rootHeld) return;
999
+ rootHeld.replayScheduled = false;
1000
+ retryRootTransition(owner);
1001
+ });
1002
+ }
783
1003
  let PROMOTED_MEMO_SWAPS = null;
784
1004
  let PROMOTED_WARM_HARVEST = null;
785
1005
  function takeSingleOriginTransitionUpdates(origin) {
@@ -943,18 +1163,24 @@ function heldSyncCellsIntact(state) {
943
1163
  if (held === null || !held.holders.has(state)) return false;
944
1164
  for (let i = 0; i < held.entries.length; i++) {
945
1165
  const entry = held.entries[i];
946
- if (!Object.is(entry.slot.value, entry.baseValue)) return false;
1166
+ if (entry.superseded || !Object.is(entry.slot.value, entry.baseValue)) return false;
947
1167
  }
948
1168
  return true;
949
1169
  }
1170
+ function heldTransitionHasPendingAction(entries) {
1171
+ for (const entry of entries) {
1172
+ if (!entry.superseded && entry.slot.pendingActionBatch?.flushed === false) return true;
1173
+ }
1174
+ return false;
1175
+ }
950
1176
  function promoteHeldSyncTransition() {
951
1177
  const held = HELD_SYNC_TRANSITION;
952
- if (held === null) return false;
1178
+ if (held === null || heldTransitionHasPendingAction(held.entries)) return false;
953
1179
  HELD_SYNC_TRANSITION = null;
954
1180
  const promoted = [];
955
1181
  for (let i = 0; i < held.entries.length; i++) {
956
1182
  const entry = held.entries[i];
957
- if (!Object.is(entry.slot.value, entry.baseValue)) continue;
1183
+ if (entry.superseded || !Object.is(entry.slot.value, entry.baseValue)) continue;
958
1184
  entry.slot.value = entry.value;
959
1185
  if (!entry.block.disposed) promoted.push(entry);
960
1186
  }
@@ -990,7 +1216,7 @@ function discardHeldSyncTransition(state) {
990
1216
  function rootTransitionCellsIntact(held) {
991
1217
  for (let i = 0; i < held.entries.length; i++) {
992
1218
  const entry = held.entries[i];
993
- if (!Object.is(entry.slot.value, entry.baseValue)) return false;
1219
+ if (entry.superseded || !Object.is(entry.slot.value, entry.baseValue)) return false;
994
1220
  }
995
1221
  return true;
996
1222
  }
@@ -1037,6 +1263,9 @@ function holdRootTransition(owner, transaction, attempt) {
1037
1263
  promoted: false,
1038
1264
  cue: !continuing
1039
1265
  };
1266
+ for (const entry of entries) {
1267
+ if (entry.batch !== void 0) holdTransitionHookBatch(owner, entry.batch);
1268
+ }
1040
1269
  if (previous === void 0 || previous.promoted) tickTransitionCount(1);
1041
1270
  return true;
1042
1271
  }
@@ -1047,6 +1276,7 @@ function retryRootTransition(owner) {
1047
1276
  discardRootTransition(owner);
1048
1277
  return false;
1049
1278
  }
1279
+ if (heldTransitionHasPendingAction(held.entries)) return true;
1050
1280
  held.promoted = true;
1051
1281
  held.cue = false;
1052
1282
  if (held.memoSwaps !== null) {
@@ -1056,6 +1286,7 @@ function retryRootTransition(owner) {
1056
1286
  TRANSITION_DEPTH++;
1057
1287
  try {
1058
1288
  tickTransitionCount(-1);
1289
+ releaseTransitionHookHolder(owner);
1059
1290
  for (let i = 0; i < held.entries.length; i++) {
1060
1291
  const entry = held.entries[i];
1061
1292
  entry.slot.value = entry.value;
@@ -1091,6 +1322,7 @@ function discardRootTransition(owner) {
1091
1322
  owner.wakeable = null;
1092
1323
  owner.generation++;
1093
1324
  if (!held.promoted) tickTransitionCount(-1);
1325
+ releaseTransitionHookHolder(owner);
1094
1326
  }
1095
1327
  const JOURNAL_TEXT = 0;
1096
1328
  const JOURNAL_ATTR = 1;
@@ -1492,12 +1724,17 @@ function journalDefaultValue(input) {
1492
1724
  journalAttr(input, "value");
1493
1725
  }
1494
1726
  }
1727
+ function radioCousins(input) {
1728
+ if (input.form !== null) return input.form.elements;
1729
+ const root = input.getRootNode();
1730
+ return root.nodeType === 9 ? root.getElementsByName(input.name) : root.querySelectorAll('input[type="radio"]');
1731
+ }
1495
1732
  function journalRadioCousins(input) {
1496
1733
  const name = input.name;
1497
- const group = input.form !== null ? input.form.elements : typeof document !== "undefined" ? document.getElementsByName(name) : [];
1734
+ const group = radioCousins(input);
1498
1735
  for (let i = 0; i < group.length; i++) {
1499
1736
  const other = group[i];
1500
- if (other === input || !other.checked || other.localName !== "input" || other.type !== "radio" || other.name !== name) {
1737
+ if (other === input || !other.checked || other.localName !== "input" || other.type !== "radio" || other.name !== name || other.form !== input.form) {
1501
1738
  continue;
1502
1739
  }
1503
1740
  TRANSITION_JOURNAL.push(JOURNAL_PROP, other, "checked", true);
@@ -2044,9 +2281,27 @@ let actScopeDepth = 0;
2044
2281
  function setIsOctaneActEnvironment(value) {
2045
2282
  IS_OCTANE_ACT_ENVIRONMENT = value;
2046
2283
  }
2284
+ function isActEnvironment() {
2285
+ return IS_OCTANE_ACT_ENVIRONMENT || globalThis.IS_REACT_ACT_ENVIRONMENT === true;
2286
+ }
2047
2287
  const NESTED_UPDATE_LIMIT = 50;
2048
2288
  const ACT_DRAIN_LIMIT = NESTED_UPDATE_LIMIT + 50;
2049
2289
  let UPDATE_CHAIN_ID = 0;
2290
+ let PASSIVE_UPDATE_COUNTS = null;
2291
+ function countPassiveUpdate(block) {
2292
+ if (process.env.NODE_ENV === "production") return;
2293
+ const counts = PASSIVE_UPDATE_COUNTS ??= /* @__PURE__ */ new WeakMap();
2294
+ let state = counts.get(block);
2295
+ if (state === void 0 || state.chain !== UPDATE_CHAIN_ID) {
2296
+ state = { chain: UPDATE_CHAIN_ID, count: 0 };
2297
+ counts.set(block, state);
2298
+ }
2299
+ if (++state.count === NESTED_UPDATE_LIMIT + 1) {
2300
+ console.error(
2301
+ "Maximum update depth exceeded. Check the dependencies of effects that schedule state updates."
2302
+ );
2303
+ }
2304
+ }
2050
2305
  function inNestedUpdateCallback() {
2051
2306
  return EFFECT_BODY_DEPTH > 0 || REF_CALLBACK_DEPTH > 0 || STORE_SYNC_DEPTH > 0;
2052
2307
  }
@@ -2076,9 +2331,23 @@ function warnCrossComponentRenderUpdate(target, source) {
2076
2331
  }
2077
2332
  function scheduleRender(block) {
2078
2333
  if (block.disposed) return;
2079
- if (process.env.NODE_ENV !== "production" && IS_OCTANE_ACT_ENVIRONMENT && actScopeDepth === 0 && !syncFlush) {
2334
+ if (process.env.NODE_ENV !== "production" && CURRENT_EFFECT_PHASE === INSERTION) {
2335
+ console.error(
2336
+ "useInsertionEffect must not schedule state updates. Move this work to a layout or passive effect."
2337
+ );
2338
+ }
2339
+ if (process.env.NODE_ENV !== "production" && isActEnvironment() && actScopeDepth === 0 && !syncFlush) {
2080
2340
  console.error(
2081
- "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."
2341
+ `An update to ${componentName(block)} was not wrapped in act(...).
2342
+
2343
+ When testing, code that causes state updates should be wrapped into act(...):
2344
+
2345
+ act(() => {
2346
+ /* fire events that update state */
2347
+ });
2348
+ /* assert on the output */
2349
+
2350
+ This ensures you're testing the behavior the user would see in the browser.`
2082
2351
  );
2083
2352
  }
2084
2353
  const renderPhaseSelf = CURRENT_BLOCK === block;
@@ -2096,7 +2365,9 @@ function scheduleRender(block) {
2096
2365
  }
2097
2366
  return;
2098
2367
  }
2099
- if (inNestedUpdateCallback()) {
2368
+ if (CURRENT_EFFECT_PHASE === PASSIVE && !syncFlush) {
2369
+ countPassiveUpdate(block);
2370
+ } else if (inNestedUpdateCallback()) {
2100
2371
  if (block.nestedUpdateChain !== UPDATE_CHAIN_ID) {
2101
2372
  block.nestedUpdateChain = UPDATE_CHAIN_ID;
2102
2373
  block.nestedUpdateCount = 0;
@@ -2138,14 +2409,19 @@ function drainHydrationRenderPhaseUpdates(root) {
2138
2409
  QUEUE[write++] = block;
2139
2410
  continue;
2140
2411
  }
2141
- if (!block.pending || block.disposed) continue;
2142
- const seen = (renders ??= /* @__PURE__ */ new Map()).get(block) ?? 0;
2143
- if (seen >= RENDER_PHASE_UPDATE_LIMIT) {
2144
- throw new Error((0, import_error_codes_client_generated.formatClientError)(9));
2145
- }
2146
- renders.set(block, seen + 1);
2147
- block.crossRenderUpdate = false;
2412
+ if (!block.pending && !block.nestedUpdateError || block.disposed) continue;
2148
2413
  try {
2414
+ if (block.nestedUpdateError) {
2415
+ block.nestedUpdateError = false;
2416
+ throw maximumUpdateDepthError();
2417
+ }
2418
+ const seen = (renders ??= /* @__PURE__ */ new Map()).get(block) ?? 0;
2419
+ const crossRenderUpdate = block.crossRenderUpdate;
2420
+ if (seen >= (crossRenderUpdate ? NESTED_UPDATE_LIMIT : RENDER_PHASE_UPDATE_LIMIT)) {
2421
+ throw crossRenderUpdate ? maximumUpdateDepthError() : new Error((0, import_error_codes_client_generated.formatClientError)(9));
2422
+ }
2423
+ renders.set(block, seen + 1);
2424
+ block.crossRenderUpdate = false;
2149
2425
  renderBlock(block);
2150
2426
  } catch (error) {
2151
2427
  handleRenderError(block, error);
@@ -2193,12 +2469,21 @@ let SCHEDULED_VISIBILITY_DRIVER = null;
2193
2469
  function ensureScheduledVisibilityDriver() {
2194
2470
  SCHEDULED_VISIBILITY_DRIVER ??= {
2195
2471
  find: findScheduledVisibilityOwner,
2472
+ holdsNativeRead,
2196
2473
  reveal: attemptHiddenReveal,
2197
2474
  visible: renderVisibleTry,
2198
2475
  rehide: rehideActivityAfterDescendantRender,
2199
2476
  retryActivity: renderHiddenActivity
2200
2477
  };
2201
2478
  }
2479
+ function holdsNativeRead(block) {
2480
+ for (const state of HELD_TRANSITIONS) {
2481
+ const primary = state.tryBlock;
2482
+ if (state.transitionHeld && state.hiddenDom === null && primary !== null && (primary === block || blockIsAncestorOf(primary, block) || blockIsAncestorOf(block, primary)))
2483
+ return true;
2484
+ }
2485
+ return false;
2486
+ }
2202
2487
  function drainQueue() {
2203
2488
  let pendingError = null;
2204
2489
  let activitiesToRehide = null;
@@ -2242,7 +2527,7 @@ function drainQueue() {
2242
2527
  throw maximumUpdateDepthError();
2243
2528
  }
2244
2529
  if (block.drainStamp === drainId) {
2245
- if (++block.drainRenders > RENDER_PHASE_UPDATE_LIMIT) {
2530
+ if (++block.drainRenders > (crossRenderUpdate ? NESTED_UPDATE_LIMIT : RENDER_PHASE_UPDATE_LIMIT)) {
2246
2531
  throw crossRenderUpdate ? maximumUpdateDepthError() : new Error((0, import_error_codes_client_generated.formatClientError)(9));
2247
2532
  }
2248
2533
  } else {
@@ -2822,6 +3107,11 @@ function drainPassivesBeforeRender() {
2822
3107
  if (effectQueues[PASSIVE].length > 0 || pendingPassiveUnmounts.length > 0) drainPassiveEffects();
2823
3108
  }
2824
3109
  function flushSync(fn) {
3110
+ if (process.env.NODE_ENV !== "production" && (CURRENT_BLOCK !== null || EFFECT_BODY_DEPTH > 0 || REF_CALLBACK_DEPTH > 0)) {
3111
+ console.error(
3112
+ "flushSync was called while rendering or running a lifecycle callback. Move the call to an event or scheduled task."
3113
+ );
3114
+ }
2825
3115
  if (inFlush) return (0, import_read_protocol.runNativeBatch)(fn);
2826
3116
  VIEW_TRANSITION_DRIVER?.interrupt();
2827
3117
  const prevSync = syncFlush;
@@ -3034,6 +3324,7 @@ function commitEffects() {
3034
3324
  return;
3035
3325
  }
3036
3326
  const nativeFrame = NATIVE_READ_DRIVER?.pauseLifecycle() ?? -1;
3327
+ EFFECT_COMMIT_DEPTH++;
3037
3328
  try {
3038
3329
  drainEffectEventUpdates();
3039
3330
  const caughtReports = drainEffectEventCommitActions();
@@ -3051,6 +3342,7 @@ function commitEffects() {
3051
3342
  }
3052
3343
  } finally {
3053
3344
  if (nativeFrame >= 0) NATIVE_READ_DRIVER.resumeLifecycle(nativeFrame);
3345
+ finishEffectCommit();
3054
3346
  }
3055
3347
  }
3056
3348
  function schedulePassiveFlush() {
@@ -3155,15 +3447,25 @@ function compareEffectPostOrder(a, b) {
3155
3447
  if (a.scope === b.scope) return a.order - b.order || a.seq - b.seq;
3156
3448
  return comparePostOrder(a.scope.block, a.seq, b.scope.block, b.seq);
3157
3449
  }
3158
- function reportEffectError(block, error) {
3159
- const handler = findTryHandler(block);
3450
+ function finishEffectCommit() {
3451
+ if (--EFFECT_COMMIT_DEPTH !== 0 || COMMIT_PHASE_ERRORS === null) return;
3452
+ const errors = COMMIT_PHASE_ERRORS;
3453
+ COMMIT_PHASE_ERRORS = null;
3454
+ for (const { block, error, handler } of errors) reportEffectError(block, error, handler);
3455
+ }
3456
+ function reportEffectError(block, error, capturedHandler) {
3457
+ if (EFFECT_COMMIT_DEPTH > 0) {
3458
+ (COMMIT_PHASE_ERRORS ??= []).push({ block, error, handler: capturedHandler });
3459
+ return;
3460
+ }
3461
+ const handler = capturedHandler === void 0 ? findTryHandler(block) : capturedHandler;
3160
3462
  if (handler !== null) {
3161
3463
  reportCaughtError(block, error, handler(error));
3162
3464
  return;
3163
3465
  }
3164
3466
  let root = block;
3165
- while (root.parentBlock !== null) root = root.parentBlock;
3166
- if (root.kind === "root" && !root.disposed) {
3467
+ while (root !== null && root.parentBlock !== null) root = root.parentBlock;
3468
+ if (root !== null && root.kind === "root" && !root.disposed) {
3167
3469
  unmountBlock(root);
3168
3470
  drainRefDetaches();
3169
3471
  }
@@ -3183,7 +3485,7 @@ function fireEffectCleanup(e) {
3183
3485
  if (cleanup) {
3184
3486
  slot.cleanup = void 0;
3185
3487
  try {
3186
- runEffectCleanupCallback(cleanup);
3488
+ runEffectCleanupCallback(cleanup, e.phase);
3187
3489
  } catch (err) {
3188
3490
  if (err instanceof MaximumUpdateDepthError) throw err;
3189
3491
  reportEffectError(e.scope.block, err);
@@ -3200,17 +3502,27 @@ function runEffectBody(e) {
3200
3502
  slot.connectedArgs = e.args;
3201
3503
  slot.disconnected = false;
3202
3504
  try {
3505
+ const previousPhase = CURRENT_EFFECT_PHASE;
3506
+ CURRENT_EFFECT_PHASE = e.phase;
3203
3507
  EFFECT_BODY_DEPTH++;
3204
3508
  try {
3205
3509
  cleanup = e.fn.apply(null, e.args ?? []);
3206
3510
  } finally {
3207
3511
  EFFECT_BODY_DEPTH--;
3512
+ CURRENT_EFFECT_PHASE = previousPhase;
3208
3513
  }
3209
3514
  } catch (err) {
3210
3515
  if (err instanceof MaximumUpdateDepthError) throw err;
3211
3516
  reportEffectError(e.scope.block, err);
3212
3517
  return;
3213
3518
  }
3519
+ if (process.env.NODE_ENV !== "production" && cleanup !== void 0 && typeof cleanup !== "function") {
3520
+ const name = e.phase === PASSIVE ? "useEffect" : e.phase === LAYOUT ? "useLayoutEffect" : "useInsertionEffect";
3521
+ const thenable = cleanup !== null && typeof cleanup.then === "function";
3522
+ console.error(
3523
+ name + " must return a cleanup function or nothing." + (thenable ? " Start asynchronous work inside the effect and return its cleanup separately." : "")
3524
+ );
3525
+ }
3214
3526
  if (typeof cleanup === "function") {
3215
3527
  slot.cleanup = cleanup;
3216
3528
  }
@@ -3260,20 +3572,25 @@ function runLayoutEffects(q) {
3260
3572
  }
3261
3573
  }
3262
3574
  function drainPassivePhase() {
3263
- drainDeferredPassiveUnmounts();
3264
- const pending = effectQueues[PASSIVE];
3265
- if (pending.length === 0) return;
3266
- const q = pending.splice(0);
3267
- q.sort(compareEffectPostOrder);
3268
- for (let i = 0; i < q.length; i++) {
3269
- const e = q[i];
3270
- if (e.scope.block.disposed || e.fn !== null && inInactiveSubtree(e.scope.block)) continue;
3271
- fireEffectCleanup(e);
3272
- }
3273
- for (let i = 0; i < q.length; i++) {
3274
- const e = q[i];
3275
- if (e.scope.block.disposed || inInactiveSubtree(e.scope.block)) continue;
3276
- runEffectBody(e);
3575
+ EFFECT_COMMIT_DEPTH++;
3576
+ try {
3577
+ drainDeferredPassiveUnmounts();
3578
+ const pending = effectQueues[PASSIVE];
3579
+ if (pending.length === 0) return;
3580
+ const q = pending.splice(0);
3581
+ q.sort(compareEffectPostOrder);
3582
+ for (let i = 0; i < q.length; i++) {
3583
+ const e = q[i];
3584
+ if (e.scope.block.disposed || e.fn !== null && inInactiveSubtree(e.scope.block)) continue;
3585
+ fireEffectCleanup(e);
3586
+ }
3587
+ for (let i = 0; i < q.length; i++) {
3588
+ const e = q[i];
3589
+ if (e.scope.block.disposed || inInactiveSubtree(e.scope.block)) continue;
3590
+ runEffectBody(e);
3591
+ }
3592
+ } finally {
3593
+ finishEffectCommit();
3277
3594
  }
3278
3595
  }
3279
3596
  function drainEffectEventCommitActions() {
@@ -3296,14 +3613,12 @@ function drainDeferredPassiveUnmounts() {
3296
3613
  const q = pendingPassiveUnmounts.splice(0);
3297
3614
  for (let i = 0; i < q.length; i += 3) {
3298
3615
  try {
3299
- runEffectCleanupCallback(q[i]);
3616
+ runEffectCleanupCallback(q[i], PASSIVE);
3300
3617
  } catch (err) {
3301
3618
  if (err instanceof MaximumUpdateDepthError) throw err;
3302
3619
  const handler = q[i + 1];
3303
3620
  const owner = q[i + 2];
3304
- if (handler !== null) {
3305
- reportCaughtError(owner, err, handler(err));
3306
- } else if (!reportUncaughtError(owner, err)) console.error(err);
3621
+ reportEffectError(owner, err, handler);
3307
3622
  }
3308
3623
  }
3309
3624
  }
@@ -3567,10 +3882,17 @@ function createBlock(kind, parentBlock, parentNode, startMarker, endMarker, body
3567
3882
  function renderBlock(block) {
3568
3883
  const hydration = activeHydration();
3569
3884
  if (hydration !== null && !hydration.owns(block)) {
3570
- hydration.suspend(() => renderBlockInner(block));
3885
+ hydration.suspend(() => renderBlock(block));
3571
3886
  return;
3572
3887
  }
3573
- renderBlockInner(block);
3888
+ let retries = 0;
3889
+ while (renderBlockInner(block)) {
3890
+ if (block.nestedUpdateError) {
3891
+ block.nestedUpdateError = false;
3892
+ throw maximumUpdateDepthError();
3893
+ }
3894
+ if (++retries > RENDER_PHASE_UPDATE_LIMIT) throw new Error((0, import_error_codes_client_generated.formatClientError)(9));
3895
+ }
3574
3896
  }
3575
3897
  function enqueueEffectEventUpdate(entry) {
3576
3898
  EFFECT_EVENT_RENDER_TARGET.push(entry);
@@ -3595,6 +3917,45 @@ function recordCapturedRender(capture, block) {
3595
3917
  (capture.renderedBlocks ??= /* @__PURE__ */ new Set()).add(block);
3596
3918
  }
3597
3919
  }
3920
+ function beginUrgentTransitionRender(block, render) {
3921
+ const slots = /* @__PURE__ */ new Map();
3922
+ for (const entries of FLUSHED_TRANSITION_UPDATES) {
3923
+ for (const update of entries) {
3924
+ if (update.block !== block || update.superseded) continue;
3925
+ const previous = slots.get(update.slot);
3926
+ if (previous !== void 0) {
3927
+ render.cells[previous].update = update;
3928
+ } else {
3929
+ slots.set(update.slot, render.cells.length);
3930
+ render.cells.push({
3931
+ update,
3932
+ baseValue: update.baseValue,
3933
+ value: update.slot.value,
3934
+ hook: void 0
3935
+ });
3936
+ }
3937
+ }
3938
+ }
3939
+ for (const cell of render.cells) {
3940
+ cell.hook = beginUrgentTransitionCell(cell.update);
3941
+ if (cell.hook === null) cell.update.slot.value = cell.baseValue;
3942
+ }
3943
+ }
3944
+ function endUrgentTransitionRender(block, render) {
3945
+ for (let i = render.cells.length - 1; i >= 0; i--) {
3946
+ const cell = render.cells[i];
3947
+ if (cell.hook === void 0) continue;
3948
+ if (cell.hook !== null) endUrgentTransitionCell(cell.hook);
3949
+ else if (!block.disposed && !cell.update.superseded && Object.is(cell.update.slot.value, cell.baseValue))
3950
+ cell.update.slot.value = cell.value;
3951
+ }
3952
+ if (block.disposed || block.pending && block.pendingMode === "urgent") return;
3953
+ if (render.cells.length !== 0 && render.cells.every((cell) => cell.update.superseded)) return;
3954
+ block.pending = true;
3955
+ block.pendingMode = "transition";
3956
+ block.pendingDeferred = render.pendingDeferred;
3957
+ if (render.queueEpoch !== QUEUE_REINDEX_EPOCH && !QUEUE.includes(block)) QUEUE.push(block);
3958
+ }
3598
3959
  function renderBlockInner(block) {
3599
3960
  if (block.renderStatus === RENDER_INVALID) block.renderStatus = RENDER_RETRYING;
3600
3961
  if (WIP_CAPTURE !== null) recordCapturedRender(WIP_CAPTURE, block);
@@ -3618,6 +3979,8 @@ function renderBlockInner(block) {
3618
3979
  CURRENT_EFFECT_RENDER_VERSION = block.effectSlots === null ? 0 : NEXT_EFFECT_RENDER_VERSION++;
3619
3980
  CURRENT_EFFECT_REACHED = 0;
3620
3981
  const continuesParentTree = prevBlock !== null && blockIsAncestor(prevBlock, block);
3982
+ const urgentTransitionDriver = block.pending && block.pendingMode === "transition" && continuesParentTree && prevBlock.currentRenderMode === "urgent" ? TRANSITION_SWAP_DRIVER : null;
3983
+ const urgentTransitionRender = urgentTransitionDriver === null ? null : { pendingDeferred: block.pendingDeferred, queueEpoch: QUEUE_REINDEX_EPOCH, cells: [] };
3621
3984
  if (!continuesParentTree) {
3622
3985
  const replayEpisode = prevBlock === null && RESUME_REPLAY ? block.__warmEpisode : void 0;
3623
3986
  CURRENT_WARM_EPISODE = typeof replayEpisode === "number" ? replayEpisode : NEXT_WARM_EPISODE++;
@@ -3629,6 +3992,7 @@ function renderBlockInner(block) {
3629
3992
  EFFECT_EVENT_ACTION_TARGET = effectEventActionTarget;
3630
3993
  if (block.effectEventRenderVersion !== 0) block.effectEventRenderVersion++;
3631
3994
  block.pending = false;
3995
+ block.crossRenderUpdate = false;
3632
3996
  block.__thenableIdx = 0;
3633
3997
  {
3634
3998
  const tState = block.__thenables;
@@ -3639,22 +4003,29 @@ function renderBlockInner(block) {
3639
4003
  }
3640
4004
  if (block.$$ctxReads !== null) block.$$ctxReads.clear();
3641
4005
  if (block.$$ctxDirect !== null) block.$$ctxDirect.clear();
3642
- block.currentRenderMode = block.pendingMode ?? prevBlock?.currentRenderMode ?? "urgent";
3643
- block.currentRenderDeferred = block.pendingMode !== null ? block.pendingDeferred : prevBlock?.currentRenderDeferred ?? false;
4006
+ block.currentRenderMode = urgentTransitionRender !== null ? "urgent" : block.pendingMode ?? prevBlock?.currentRenderMode ?? "urgent";
4007
+ block.currentRenderDeferred = urgentTransitionRender !== null ? false : block.pendingMode !== null ? block.pendingDeferred : prevBlock?.currentRenderDeferred ?? false;
3644
4008
  block.pendingMode = null;
3645
4009
  block.pendingDeferred = false;
3646
4010
  const profileFrame = typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__ && (block.kind === "root" || block.kind === "dynamic" || block.kind === "portal") ? (0, import_profiling.__profileBeginRender)(block, block.body, block.mounted) : null;
3647
4011
  let profileDidThrow = false;
3648
4012
  let profileThrown;
3649
4013
  let renderCompleted = false;
4014
+ let renderRetry = false;
3650
4015
  NATIVE_READ_DRIVER?.beginRender(block);
3651
4016
  NATIVE_BLOCK_RETRIES?.get(block)?.clear();
3652
4017
  try {
4018
+ if (urgentTransitionRender !== null)
4019
+ urgentTransitionDriver.beginUrgent(block, urgentTransitionRender);
3653
4020
  const out = block.body(
3654
4021
  block.props,
3655
4022
  block,
3656
4023
  block.extra
3657
4024
  );
4025
+ if (block.pending && !block.crossRenderUpdate) {
4026
+ renderRetry = true;
4027
+ return true;
4028
+ }
3658
4029
  if (out !== void 0 && block.outputHandler !== null) block.outputHandler(block, out);
3659
4030
  finishEffectRender(block);
3660
4031
  if (!block.mounted) block.mounted = true;
@@ -3680,6 +4051,7 @@ function renderBlockInner(block) {
3680
4051
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__ && profileFrame !== null)
3681
4052
  (0, import_profiling.__profileEndRender)(profileFrame, profileDidThrow, profileThrown);
3682
4053
  if (!renderCompleted) {
4054
+ if (renderRetry) block.renderStatus = RENDER_INVALID;
3683
4055
  if (block.renderStatus !== RENDER_INVALID) {
3684
4056
  let owner = null;
3685
4057
  const suspension = isSuspenseException(profileThrown);
@@ -3705,7 +4077,12 @@ function renderBlockInner(block) {
3705
4077
  CURRENT_EFFECT_REACHED = prevEffectReached;
3706
4078
  CURRENT_SCOPE = prevScope;
3707
4079
  CURRENT_BLOCK = prevBlock;
3708
- NATIVE_READ_DRIVER?.endRender(block, renderCompleted, isSuspenseException(profileThrown));
4080
+ try {
4081
+ NATIVE_READ_DRIVER?.endRender(block, renderCompleted, isSuspenseException(profileThrown));
4082
+ } finally {
4083
+ if (urgentTransitionRender !== null)
4084
+ urgentTransitionDriver.endUrgent(block, urgentTransitionRender);
4085
+ }
3709
4086
  }
3710
4087
  }
3711
4088
  function returnSlotTail(block, state) {
@@ -3912,6 +4289,7 @@ class LiteBlockImpl {
3912
4289
  }
3913
4290
  }
3914
4291
  function componentSlotLite(parentScope, slotKey, host, comp, props, anchor) {
4292
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
3915
4293
  const hydration = activeHydration();
3916
4294
  let scope = parentScope.slots[slotKey];
3917
4295
  let adoptedOpen = null;
@@ -4075,7 +4453,7 @@ function unmountScope(scope, detachDom = true) {
4075
4453
  if (!passiveScheduled) schedulePassiveFlush();
4076
4454
  } else {
4077
4455
  try {
4078
- runEffectCleanupCallback(cleanup);
4456
+ runEffectCleanupCallback(cleanup, slot.phase);
4079
4457
  } catch (err) {
4080
4458
  reportTeardownError(err);
4081
4459
  }
@@ -4150,12 +4528,66 @@ function missingSlot(name) {
4150
4528
  throw new Error((0, import_error_codes_client_generated.formatClientError)(15, name));
4151
4529
  }
4152
4530
  const slotStack = [];
4531
+ let MANUAL_HOOK_DRIVER = null;
4532
+ function invokeManualHook(fn, receiver, args) {
4533
+ const driver = MANUAL_HOOK_DRIVER ??= {
4534
+ pending: slotStack[slotStack.length - 1],
4535
+ active: false
4536
+ };
4537
+ const pending = driver.pending;
4538
+ const active = driver.active;
4539
+ driver.pending = void 0;
4540
+ driver.active = true;
4541
+ try {
4542
+ if (pending === void 0) return Reflect.apply(fn, receiver, args);
4543
+ switch (args.length) {
4544
+ case 0:
4545
+ return fn.call(receiver, pending);
4546
+ case 1:
4547
+ return fn.call(receiver, args[0], pending);
4548
+ case 2:
4549
+ return fn.call(receiver, args[0], args[1], pending);
4550
+ case 3:
4551
+ return fn.call(receiver, args[0], args[1], args[2], pending);
4552
+ case 4:
4553
+ return fn.call(receiver, args[0], args[1], args[2], args[3], pending);
4554
+ default: {
4555
+ const forwarded = new Array(args.length + 1);
4556
+ for (let index = 0; index < args.length; index++) forwarded[index] = args[index];
4557
+ forwarded[args.length] = pending;
4558
+ return fn.apply(receiver, forwarded);
4559
+ }
4560
+ }
4561
+ } finally {
4562
+ driver.pending = pending;
4563
+ driver.active = active;
4564
+ }
4565
+ }
4566
+ function manualHook(fn, name) {
4567
+ function provider() {
4568
+ return invokeManualHook(fn, this, arguments);
4569
+ }
4570
+ Object.defineProperty(provider, "name", { value: name ?? fn.name, configurable: true });
4571
+ Object.defineProperty(provider, "length", { value: fn.length, configurable: true });
4572
+ return provider;
4573
+ }
4153
4574
  function withSlot(sym, fn, ...args) {
4575
+ const driver = MANUAL_HOOK_DRIVER;
4576
+ const pending = driver?.pending;
4577
+ const active = driver?.active ?? false;
4578
+ if (driver !== null) {
4579
+ driver.pending = sym;
4580
+ driver.active = false;
4581
+ }
4154
4582
  slotStack.push(sym);
4155
4583
  try {
4156
4584
  return fn(...args);
4157
4585
  } finally {
4158
4586
  slotStack.pop();
4587
+ if (MANUAL_HOOK_DRIVER !== null) {
4588
+ MANUAL_HOOK_DRIVER.pending = driver === null ? slotStack[slotStack.length - 1] : pending;
4589
+ MANUAL_HOOK_DRIVER.active = active;
4590
+ }
4159
4591
  }
4160
4592
  }
4161
4593
  function appendSlotKey(key, slot) {
@@ -4186,7 +4618,7 @@ function nativeLocalHook(name, initialize, dispose, slot) {
4186
4618
  return cell.nativeValue;
4187
4619
  }
4188
4620
  function useState(initial, slot) {
4189
- if (slot === void 0 && typeof initial === "symbol") {
4621
+ if (slot === void 0 && typeof initial === "symbol" && arguments.length === 1 && (slotStack.length === 0 || MANUAL_HOOK_DRIVER?.active === true)) {
4190
4622
  slot = initial;
4191
4623
  initial = void 0;
4192
4624
  }
@@ -4200,16 +4632,44 @@ function useState(initial, slot) {
4200
4632
  s = {
4201
4633
  value: initVal,
4202
4634
  setter: (next) => {
4203
- const previous = stagedTransitionValue(s);
4204
- const computed = typeof next === "function" ? next(previous) : next;
4205
- if (Object.is(computed, previous)) return;
4206
- if (stageTransitionValue(s, block, next, computed)) {
4635
+ if (block.disposed) return;
4636
+ if (s.pendingActionBatch !== void 0 && transitionActionBatchForUpdate() === null)
4637
+ recordUrgentActionUpdate(s, next);
4638
+ 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) {
4639
+ (s.updates ??= []).push(next);
4640
+ scheduleRender(block);
4641
+ return;
4642
+ }
4643
+ const previous = stagedTransitionValue(s, block);
4644
+ let computed;
4645
+ let failed = false;
4646
+ try {
4647
+ computed = typeof next === "function" ? next(previous) : next;
4648
+ } catch {
4649
+ if (transitionActionBatchForUpdate() === null) {
4650
+ (s.updates ??= []).push(next);
4651
+ scheduleRender(block);
4652
+ return;
4653
+ }
4654
+ computed = previous;
4655
+ failed = true;
4656
+ }
4657
+ const forceRender = failed || s.updates !== void 0 || s.renderTransition !== void 0 || s.pendingActionBatch !== void 0 || block.pending && typeof next === "function";
4658
+ if (Object.is(computed, previous) && !forceRender) {
4659
+ if (typeof next !== "function" && TRANSITION_SWAP_DRIVER?.cancelEqual(s, block)) {
4660
+ scheduleRender(block);
4661
+ }
4662
+ return;
4663
+ }
4664
+ const update = stageTransitionValue(s, block, next, computed, forceRender);
4665
+ if (update !== null) {
4666
+ if (update.state === void 0) {
4667
+ update.state = s;
4668
+ captureTransitionHookQueue(update, s);
4669
+ }
4207
4670
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
4208
- const update = s.pendingActionBatch?.updates.get(s);
4209
- if (update !== void 0) {
4210
- update.profileType = "state";
4211
- update.profileSlot = slot;
4212
- }
4671
+ update.profileType = "state";
4672
+ update.profileSlot = slot;
4213
4673
  }
4214
4674
  return;
4215
4675
  }
@@ -4221,10 +4681,95 @@ function useState(initial, slot) {
4221
4681
  };
4222
4682
  ensureHooks(scope).set(slot, s);
4223
4683
  }
4684
+ if (s.renderTransition !== void 0 || s.updates !== void 0) {
4685
+ const value = readQueuedState(s);
4686
+ if (!s.urgentTransition && s.updates !== void 0 && Object.is(value, s.value))
4687
+ TRANSITION_SWAP_DRIVER?.rebaseHeld(s, block, s.updates);
4688
+ s.value = value;
4689
+ if (!s.urgentTransition) {
4690
+ if (s.renderTransition !== void 0) {
4691
+ finishQueuedTransition(s.renderTransition, s.value);
4692
+ s.renderTransition = void 0;
4693
+ }
4694
+ s.updates = void 0;
4695
+ }
4696
+ }
4224
4697
  return [s.value, s.setter];
4225
4698
  }
4699
+ function readQueuedState(state) {
4700
+ const transition = state.renderTransition;
4701
+ let value = transition === void 0 ? state.value : readQueuedTransition(transition, state.urgentTransition === true);
4702
+ if (state.updates !== void 0) {
4703
+ for (const update of state.updates)
4704
+ value = typeof update === "function" ? update(value) : update;
4705
+ }
4706
+ return value;
4707
+ }
4708
+ function readQueuedTransition(last, urgent, reducer) {
4709
+ let first = last;
4710
+ while (first.previous !== void 0) first = first.previous;
4711
+ let value = first.replayBaseValue;
4712
+ for (let entry = first; ; entry = entry.next) {
4713
+ if (entry.stateUpdates !== void 0) {
4714
+ for (const update of entry.stateUpdates)
4715
+ value = typeof update === "function" ? update(value) : update;
4716
+ }
4717
+ if (entry.reducerActions !== void 0) {
4718
+ for (const action of entry.reducerActions) value = reducer(value, action);
4719
+ }
4720
+ if ((urgent || entry.superseded) && entry.urgentOperations !== void 0) {
4721
+ for (const index of entry.urgentOperations) value = entry.operations[index](value);
4722
+ } else if (!urgent && !entry.superseded) {
4723
+ for (const operation of entry.operations) value = operation(value);
4724
+ }
4725
+ if (entry === last) return value;
4726
+ }
4727
+ }
4728
+ function captureTransitionHookQueue(update, cell) {
4729
+ update.replayBaseValue = cell.value;
4730
+ const previous = cell.renderTransition ?? TRANSITION_SWAP_DRIVER?.heldUpdate(cell, update.block);
4731
+ if (previous !== void 0) {
4732
+ update.previous = previous;
4733
+ previous.next = update;
4734
+ }
4735
+ if (update.state !== void 0) update.stateUpdates = update.state.updates?.slice();
4736
+ else update.reducerActions = update.reducer.renderPhaseActions?.slice();
4737
+ }
4738
+ function recordUrgentActionUpdate(cell, operation) {
4739
+ const update = cell.pendingActionBatch.updates.get(cell);
4740
+ if (update === void 0) return;
4741
+ (update.urgentOperations ??= []).push(update.operations.length);
4742
+ update.operations.push(
4743
+ typeof operation === "function" ? operation : () => operation
4744
+ );
4745
+ update.forceRender = true;
4746
+ }
4747
+ function finishQueuedTransition(last, value) {
4748
+ for (let entry = last; entry; entry = entry.previous) {
4749
+ entry.value = value;
4750
+ if (entry !== last && Object.is(value, entry.baseValue)) entry.superseded = true;
4751
+ }
4752
+ }
4753
+ function beginUrgentTransitionCell(update) {
4754
+ const cell = update.state ?? update.reducer;
4755
+ if (update.block.disposed || update.superseded || cell === void 0 || cell.renderTransition === void 0)
4756
+ return null;
4757
+ cell.urgentTransition = true;
4758
+ cell.value = update.baseValue;
4759
+ return { update, cell };
4760
+ }
4761
+ function endUrgentTransitionCell(snapshot) {
4762
+ const { update, cell } = snapshot;
4763
+ cell.urgentTransition = false;
4764
+ if (update.block.disposed || update.superseded) {
4765
+ cell.renderTransition = void 0;
4766
+ return;
4767
+ }
4768
+ for (let entry = update; entry; entry = entry.previous)
4769
+ entry.baseValue = cell.value;
4770
+ }
4226
4771
  function __useStateWithGetter(initial, slot) {
4227
- if (slot === void 0 && typeof initial === "symbol") {
4772
+ if (slot === void 0 && typeof initial === "symbol" && arguments.length === 1 && (slotStack.length === 0 || MANUAL_HOOK_DRIVER?.active === true)) {
4228
4773
  slot = initial;
4229
4774
  initial = void 0;
4230
4775
  }
@@ -4234,9 +4779,9 @@ function __useStateWithGetter(initial, slot) {
4234
4779
  const s = CURRENT_SCOPE.hooks.get(resolved);
4235
4780
  const getter = s.getter ?? (s.getter = () => {
4236
4781
  const batch = s.pendingActionBatch;
4237
- if (batch === void 0) return s.value;
4782
+ if (batch === void 0) return readQueuedState(s);
4238
4783
  const update = batch.updates.get(s);
4239
- return update === void 0 ? s.value : rebaseTransitionActionUpdate(update);
4784
+ return update === void 0 ? readQueuedState(s) : readQueuedTransition(update, false);
4240
4785
  });
4241
4786
  return [pair[0], pair[1], getter];
4242
4787
  }
@@ -4336,13 +4881,11 @@ function useLinkedState(source, reconcile, options, slot) {
4336
4881
  else scheduleRender(block);
4337
4882
  return;
4338
4883
  }
4339
- if (stageTransitionValue(state, block, operation, computed)) {
4884
+ const update = stageTransitionValue(state, block, operation, computed);
4885
+ if (update !== null) {
4340
4886
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
4341
- const update = state.pendingActionBatch?.updates.get(state);
4342
- if (update !== void 0) {
4343
- update.profileType = "state";
4344
- update.profileSlot = slot;
4345
- }
4887
+ update.profileType = "state";
4888
+ update.profileSlot = slot;
4346
4889
  }
4347
4890
  return;
4348
4891
  }
@@ -4460,26 +5003,31 @@ function useReducer(reducer, initialArg, initOrSlot, slot) {
4460
5003
  // the component once (children then bail as usual). Per
4461
5004
  // ReactHooksWithNoopRenderer-test.js:3889.
4462
5005
  dispatch: (action) => {
4463
- if (CURRENT_BLOCK === block) {
5006
+ if (block.disposed) return;
5007
+ if (CURRENT_BLOCK === block || transitionActionBatchForUpdate() === null) {
5008
+ if (s.pendingActionBatch !== void 0 && transitionActionBatchForUpdate() === null)
5009
+ recordUrgentActionUpdate(s, (value) => s.reducer(value, action));
4464
5010
  const actions = s.renderPhaseActions ??= [];
4465
- const previous2 = actions.length === 0 ? s.value : s.renderPhaseValue;
4466
5011
  actions.push(action);
4467
- if (s.getter !== void 0) {
4468
- s.renderPhaseValue = s.reducer(previous2, action);
4469
- }
4470
5012
  scheduleRender(block);
4471
5013
  return;
4472
5014
  }
4473
- const previous = stagedTransitionValue(s);
5015
+ const previous = stagedTransitionValue(s, block);
4474
5016
  const operation = (value) => s.reducer(value, action);
4475
- const computed = operation(previous);
4476
- if (stageTransitionValue(s, block, operation, computed, true)) {
5017
+ let computed = previous;
5018
+ try {
5019
+ computed = operation(previous);
5020
+ } catch {
5021
+ }
5022
+ const update = stageTransitionValue(s, block, operation, computed, true);
5023
+ if (update !== null) {
5024
+ if (update.reducer === void 0) {
5025
+ update.reducer = s;
5026
+ captureTransitionHookQueue(update, s);
5027
+ }
4477
5028
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
4478
- const update = s.pendingActionBatch?.updates.get(s);
4479
- if (update !== void 0) {
4480
- update.profileType = "reducer";
4481
- update.profileSlot = slot;
4482
- }
5029
+ update.profileType = "reducer";
5030
+ update.profileSlot = slot;
4483
5031
  }
4484
5032
  return;
4485
5033
  }
@@ -4492,17 +5040,32 @@ function useReducer(reducer, initialArg, initOrSlot, slot) {
4492
5040
  ensureHooks(scope).set(slot, s);
4493
5041
  } else {
4494
5042
  s.reducer = reducer;
4495
- const actions = s.renderPhaseActions;
4496
- if (actions !== void 0) {
4497
- let value = s.value;
4498
- for (let i = 0; i < actions.length; i++) value = reducer(value, actions[i]);
5043
+ if (s.renderTransition !== void 0 || s.renderPhaseActions !== void 0) {
5044
+ const value = readQueuedReducer(s);
5045
+ if (!s.urgentTransition && s.renderPhaseActions !== void 0 && Object.is(value, s.value))
5046
+ TRANSITION_SWAP_DRIVER?.rebaseHeld(s, block, s.renderPhaseActions, reducer);
4499
5047
  s.value = value;
4500
- s.renderPhaseActions = void 0;
4501
- s.renderPhaseValue = void 0;
5048
+ if (!s.urgentTransition) {
5049
+ if (s.renderTransition !== void 0) {
5050
+ finishQueuedTransition(s.renderTransition, s.value);
5051
+ s.renderTransition = void 0;
5052
+ }
5053
+ s.renderPhaseActions = void 0;
5054
+ }
4502
5055
  }
4503
5056
  }
4504
5057
  return [s.value, s.dispatch];
4505
5058
  }
5059
+ function readQueuedReducer(state) {
5060
+ let value = state.renderTransition === void 0 ? state.value : readQueuedTransition(
5061
+ state.renderTransition,
5062
+ state.urgentTransition === true,
5063
+ state.reducer
5064
+ );
5065
+ if (state.renderPhaseActions !== void 0)
5066
+ for (const action of state.renderPhaseActions) value = state.reducer(value, action);
5067
+ return value;
5068
+ }
4506
5069
  function __useReducerWithGetter(reducer, initialArg, initOrSlot, slot) {
4507
5070
  const resolvedInput = typeof initOrSlot === "symbol" ? initOrSlot : slot;
4508
5071
  const pair = useReducer(reducer, initialArg, initOrSlot, slot);
@@ -4510,18 +5073,26 @@ function __useReducerWithGetter(reducer, initialArg, initOrSlot, slot) {
4510
5073
  if (resolved === void 0) missingSlot("useReducer");
4511
5074
  const s = CURRENT_SCOPE.hooks.get(resolved);
4512
5075
  const getter = s.getter ?? (s.getter = () => {
4513
- if (s.renderPhaseActions !== void 0) return s.renderPhaseValue;
4514
5076
  const batch = s.pendingActionBatch;
4515
- if (batch === void 0) return s.value;
5077
+ if (batch === void 0) return readQueuedReducer(s);
4516
5078
  const update = batch.updates.get(s);
4517
- return update === void 0 ? s.value : rebaseTransitionActionUpdate(update);
5079
+ return update === void 0 ? readQueuedReducer(s) : readQueuedTransition(update, false, s.reducer);
4518
5080
  });
4519
5081
  return [pair[0], pair[1], getter];
4520
5082
  }
4521
- function depsChanged(prev, next) {
5083
+ function depsChanged(prev, next, hook = false) {
4522
5084
  if (prev === void 0 || next === void 0) return true;
4523
- if (prev.length !== next.length) return true;
4524
- for (let i = 0; i < prev.length; i++) {
5085
+ let length = prev.length;
5086
+ if (length !== next.length) {
5087
+ if (!hook) return true;
5088
+ if (process.env.NODE_ENV !== "production") {
5089
+ console.error(
5090
+ `The dependency array must keep the same length between renders (previous: ${length}, next: ${next.length}).`
5091
+ );
5092
+ }
5093
+ length = Math.min(length, next.length);
5094
+ }
5095
+ for (let i = 0; i < length; i++) {
4525
5096
  if (!Object.is(prev[i], next[i])) return true;
4526
5097
  }
4527
5098
  return false;
@@ -4588,7 +5159,7 @@ function enqueueEffect(slot, fn, deps, phase) {
4588
5159
  return;
4589
5160
  }
4590
5161
  if (prev) {
4591
- const changed = depsChanged(prev.deps, deps);
5162
+ const changed = depsChanged(prev.deps, deps, true);
4592
5163
  if (prev.active && !changed) return;
4593
5164
  if (ROOT_RENDER_TRANSACTION !== null) journalObjectOnce(prev);
4594
5165
  let reactivated = false;
@@ -4692,7 +5263,7 @@ function adoptMemoEntry(scope, slot, deps) {
4692
5263
  }
4693
5264
  function readMemoEntry(scope, slot, deps) {
4694
5265
  const prev = scope.hooks?.get(slot);
4695
- if (prev && deps !== void 0 && !depsChanged(prev.deps, deps)) {
5266
+ if (prev && deps !== void 0 && !depsChanged(prev.deps, deps, true)) {
4696
5267
  return memoEntryHit(slot, prev);
4697
5268
  }
4698
5269
  return WARM_EVER && deps !== void 0 ? adoptMemoEntry(scope, slot, deps) : null;
@@ -4707,12 +5278,21 @@ function publishMemoEntry(scope, slot, deps, value, nativeWitness) {
4707
5278
  }
4708
5279
  return value;
4709
5280
  }
5281
+ let devMemoComputeDepth = 0;
5282
+ function computeMemoWithDiagnostics(compute, deps) {
5283
+ devMemoComputeDepth++;
5284
+ try {
5285
+ return compute.apply(null, deps ?? []);
5286
+ } finally {
5287
+ devMemoComputeDepth--;
5288
+ }
5289
+ }
4710
5290
  function useMemo(compute, deps, slot) {
4711
5291
  const [d, s] = resolveHookArgs("useMemo", deps, slot);
4712
5292
  const scope = CURRENT_SCOPE;
4713
5293
  const entry = readMemoEntry(scope, s, d);
4714
5294
  if (entry !== null) return entry.value;
4715
- const value = compute.apply(null, d ?? []);
5295
+ const value = process.env.NODE_ENV !== "production" ? computeMemoWithDiagnostics(compute, d) : compute.apply(null, d ?? []);
4716
5296
  return publishMemoEntry(scope, s, d, value);
4717
5297
  }
4718
5298
  function useCallback(fn, deps, slot) {
@@ -4784,7 +5364,7 @@ function hookMemoPublishInvariant(cells, base, value) {
4784
5364
  return value;
4785
5365
  }
4786
5366
  function useRef(initial, slot) {
4787
- if (slot === void 0 && typeof initial === "symbol") {
5367
+ if (slot === void 0 && typeof initial === "symbol" && arguments.length === 1 && (slotStack.length === 0 || MANUAL_HOOK_DRIVER?.active === true)) {
4788
5368
  slot = initial;
4789
5369
  initial = void 0;
4790
5370
  }
@@ -4898,13 +5478,33 @@ function subscribeToStore(inst, subscribe) {
4898
5478
  if (checkStoreChanged(inst)) inst.forceUpdate();
4899
5479
  return subscribe(inst.onStoreChange);
4900
5480
  }
5481
+ function scheduleStoreRender(block) {
5482
+ const depth = TRANSITION_DEPTH;
5483
+ const asyncCount = ASYNC_TRANSITION_COUNT;
5484
+ TRANSITION_DEPTH = 0;
5485
+ ASYNC_TRANSITION_COUNT = 0;
5486
+ try {
5487
+ scheduleRender(block);
5488
+ } finally {
5489
+ TRANSITION_DEPTH = depth;
5490
+ ASYNC_TRANSITION_COUNT = asyncCount;
5491
+ }
5492
+ }
5493
+ let DID_WARN_UNCACHED_SNAPSHOT = false;
4901
5494
  function useSyncExternalStore(subscribe, getSnapshot, ...rest) {
4902
5495
  let slot = rest[rest.length - 1];
4903
5496
  slot = resolveSlot(slot);
4904
5497
  if (slot === void 0) missingSlot("useSyncExternalStore");
4905
5498
  const getServerSnapshot = rest.length >= 2 ? rest[0] : void 0;
4906
5499
  const subs = usesSubslots(slot);
4907
- const value = activeHydration() !== null && getServerSnapshot !== void 0 ? getServerSnapshot() : getSnapshot();
5500
+ const readSnapshot = activeHydration() !== null && getServerSnapshot !== void 0 ? getServerSnapshot : getSnapshot;
5501
+ const value = readSnapshot();
5502
+ if (process.env.NODE_ENV !== "production" && !DID_WARN_UNCACHED_SNAPSHOT && !Object.is(value, readSnapshot())) {
5503
+ DID_WARN_UNCACHED_SNAPSHOT = true;
5504
+ console.error(
5505
+ "The " + (readSnapshot === getSnapshot ? "getSnapshot" : "getServerSnapshot") + " result must be cached to avoid an infinite update loop."
5506
+ );
5507
+ }
4908
5508
  const scope = CURRENT_SCOPE;
4909
5509
  let inst = scope.hooks?.get(subs.inst);
4910
5510
  if (inst === void 0) {
@@ -4916,11 +5516,11 @@ function useSyncExternalStore(subscribe, getSnapshot, ...rest) {
4916
5516
  subscribe,
4917
5517
  forceUpdate: typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__ ? () => {
4918
5518
  if (!block.disposed) (0, import_profiling.__profileSchedule)(block, "external-store", slot);
4919
- scheduleRender(block);
4920
- } : () => scheduleRender(block),
5519
+ scheduleStoreRender(block);
5520
+ } : () => scheduleStoreRender(block),
4921
5521
  onStoreChange: () => {
4922
5522
  if (block.disposed) return;
4923
- 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)) {
5523
+ 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)) {
4924
5524
  return;
4925
5525
  }
4926
5526
  if (checkStoreChanged(created)) created.forceUpdate();
@@ -6084,7 +6684,8 @@ const Suspense = /* @__PURE__ */ (0, import_component_flags.markComponentFlags)(
6084
6684
  );
6085
6685
  },
6086
6686
  import_component_flags.COMPONENT_FLAG_BOUNDARY,
6087
- "Suspense"
6687
+ "Suspense",
6688
+ /* @__PURE__ */ Symbol.for("octane.suspense")
6088
6689
  );
6089
6690
  function initializeViewTransitionComponent() {
6090
6691
  return (0, import_component_flags.markComponentFlags)(
@@ -6131,6 +6732,11 @@ const ErrorBoundary = /* @__PURE__ */ (0, import_component_flags.markComponentFl
6131
6732
  );
6132
6733
  const TsrxErrorBoundary = ErrorBoundary;
6133
6734
  function use(usable) {
6735
+ if (process.env.NODE_ENV !== "production" && devMemoComputeDepth !== 0) {
6736
+ console.error(
6737
+ "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."
6738
+ );
6739
+ }
6134
6740
  if (usable && usable.$$kind === CONTEXT_TAG) {
6135
6741
  return useContextInternal(usable);
6136
6742
  }
@@ -6831,6 +7437,15 @@ function warmChild(comp, props) {
6831
7437
  WARM_DEPTH--;
6832
7438
  }
6833
7439
  }
7440
+ function markWarm(component, plan) {
7441
+ Object.defineProperty(component, "__warm", {
7442
+ configurable: true,
7443
+ get() {
7444
+ return this === component ? plan : void 0;
7445
+ }
7446
+ });
7447
+ return component;
7448
+ }
6834
7449
  function adoptWarmEntry(slot, deps, accept) {
6835
7450
  let b = CURRENT_BLOCK;
6836
7451
  while (b !== null) {
@@ -7129,6 +7744,8 @@ function lazy(load) {
7129
7744
  let thenable = null;
7130
7745
  let profiledComponent = null;
7131
7746
  let memoMetadataInstalled = false;
7747
+ let displayName;
7748
+ let resolvedName = "Lazy";
7132
7749
  let lazyWrapper;
7133
7750
  const initializeLazy = () => {
7134
7751
  if (status !== "uninitialized") return;
@@ -7161,16 +7778,23 @@ function lazy(load) {
7161
7778
  };
7162
7779
  const callResolvedComponent = (props, scope, extra) => {
7163
7780
  const comp = resolveLazyModule(result);
7781
+ resolvedName = comp.displayName || comp.name || "Lazy";
7164
7782
  if (comp.__memo === true) {
7165
7783
  if (!memoMetadataInstalled) {
7166
- lazyWrapper.__memo = true;
7167
- lazyWrapper.__compare = (prev, next) => {
7168
- const current = resolveLazyModule(result);
7169
- const compare = current.__compare;
7170
- const previous = (0, import_shared_value_helpers.resolveLazyDefaultProps)(current, prev);
7171
- const incoming = (0, import_shared_value_helpers.resolveLazyDefaultProps)(current, next);
7172
- return compare ? compare(previous, incoming) : shallowEqualProps(previous, incoming);
7173
- };
7784
+ Object.defineProperty(lazyWrapper, "__memo", {
7785
+ get() {
7786
+ return this === lazyWrapper;
7787
+ }
7788
+ });
7789
+ Object.defineProperty(lazyWrapper, "__compare", {
7790
+ value: (prev, next) => {
7791
+ const current = resolveLazyModule(result);
7792
+ const compare = current.__compare;
7793
+ const previous = (0, import_shared_value_helpers.resolveLazyDefaultProps)(current, prev);
7794
+ const incoming = (0, import_shared_value_helpers.resolveLazyDefaultProps)(current, next);
7795
+ return compare ? compare(previous, incoming) : shallowEqualProps(previous, incoming);
7796
+ }
7797
+ });
7174
7798
  memoMetadataInstalled = true;
7175
7799
  }
7176
7800
  scope.block.memoInChain = true;
@@ -7200,10 +7824,22 @@ function lazy(load) {
7200
7824
  }
7201
7825
  if (settledStatus === "rejected") throw result;
7202
7826
  }
7827
+ runActiveWarmPlans();
7203
7828
  throw new SuspenseException(thenable);
7204
7829
  };
7205
- lazyWrapper.__warm = initializeLazy;
7206
- Object.defineProperty(lazyWrapper, LAZY_COMPONENT, { value: true });
7830
+ markWarm(lazyWrapper, initializeLazy);
7831
+ Object.defineProperty(lazyWrapper, LAZY_COMPONENT, {
7832
+ get() {
7833
+ return this === lazyWrapper;
7834
+ }
7835
+ });
7836
+ Object.defineProperty(lazyWrapper, "displayName", {
7837
+ configurable: true,
7838
+ get: () => displayName ?? resolvedName,
7839
+ set: (value) => {
7840
+ displayName = value;
7841
+ }
7842
+ });
7207
7843
  return lazyWrapper;
7208
7844
  }
7209
7845
  function useId(slot) {
@@ -7415,6 +8051,7 @@ class HydrationCapability {
7415
8051
  warnHydrationStructuralMismatch(loc, expected, actual);
7416
8052
  }
7417
8053
  recordTextMismatch(node, loc, server) {
8054
+ if (process.env.NODE_ENV === "production" && ROOT_ERROR_HANDLERS === null) return;
7418
8055
  if (!this.textWarnings.has(node)) this.textWarnings.set(node, { loc, server });
7419
8056
  }
7420
8057
  flushTextWarnings() {
@@ -7422,7 +8059,9 @@ class HydrationCapability {
7422
8059
  if (!this.rootBlock.parentNode.contains(node)) continue;
7423
8060
  const client = node.nodeValue;
7424
8061
  if (pending.server !== client) {
7425
- warnHydrationValueMismatch(pending.loc, "text", pending.server, client);
8062
+ noteRecoverableHydrationError(() => new Error((0, import_error_codes_client_generated.formatClientError)(61)), this.rootBlock);
8063
+ if (process.env.NODE_ENV !== "production")
8064
+ warnHydrationValueMismatch(pending.loc, "text", pending.server, client);
7426
8065
  }
7427
8066
  }
7428
8067
  this.textWarnings.clear();
@@ -7681,10 +8320,20 @@ class HydrationCapability {
7681
8320
  if (first !== null && first.nodeType === 3) {
7682
8321
  const server = first.nodeValue;
7683
8322
  if (server !== text && !isTextParserNormalizedMatch(server, text) && !isHydrationSuppressed(el)) {
7684
- if (process.env.NODE_ENV !== "production")
7685
- this.recordTextMismatch(first, loc || el.__oct_loc, server);
8323
+ this.recordTextMismatch(first, loc || el.__oct_loc, server);
7686
8324
  first.nodeValue = text;
7687
8325
  }
8326
+ if (first.nextSibling !== null) {
8327
+ noteRecoverableHydrationError(() => new Error((0, import_error_codes_client_generated.formatClientError)(62)), this.rootBlock);
8328
+ if (process.env.NODE_ENV !== "production") {
8329
+ warnHydrationStructuralMismatch(
8330
+ loc || el.__oct_loc,
8331
+ "the end of the text element",
8332
+ describeHydrationNode(first.nextSibling)
8333
+ );
8334
+ }
8335
+ while (first.nextSibling !== null) el.removeChild(first.nextSibling);
8336
+ }
7688
8337
  return first;
7689
8338
  }
7690
8339
  if (this.isOpen(first)) {
@@ -7706,8 +8355,7 @@ class HydrationCapability {
7706
8355
  if (server !== text && !isTextParserNormalizedMatch(server, text)) {
7707
8356
  const host2 = posNode.parentNode;
7708
8357
  if (!isHydrationSuppressed(host2)) {
7709
- if (process.env.NODE_ENV !== "production")
7710
- this.recordTextMismatch(posNode, host2 && host2.__oct_loc, server);
8358
+ this.recordTextMismatch(posNode, host2 && host2.__oct_loc, server);
7711
8359
  posNode.nodeValue = text;
7712
8360
  }
7713
8361
  }
@@ -8894,6 +9542,7 @@ function attrNamespace(name) {
8894
9542
  return null;
8895
9543
  }
8896
9544
  function setAttribute(el, name, value) {
9545
+ if (name === "innerText" || name === "textContent") return;
8897
9546
  if (process.env.NODE_ENV !== "production" && el.__oct_loc !== void 0 && !isHtmlCustomElement(el) && typeof el.__oct_custom_is !== "string") {
8898
9547
  const warning = (0, import_aria_diagnostics.isAriaAttributeName)(name) ? (0, import_aria_diagnostics.ariaAttributeWarning)(name, el.localName) : (0, import_host_property_diagnostics.hostPropertyWarning)(name, value, el.localName, el.namespaceURI === SVG_NS);
8899
9548
  if (warning !== null) devWarnAttributeOnce(el, name, warning);
@@ -8931,6 +9580,10 @@ function setAttribute(el, name, value) {
8931
9580
  break;
8932
9581
  case 8:
8933
9582
  if ((name === "multiple" || name === "selected") && !isHtmlCustomElement(el)) {
9583
+ if (name === "selected") {
9584
+ const hydration2 = activeHydration();
9585
+ if (hydration2 !== null && !hydration2.isFresh(el)) return;
9586
+ }
8934
9587
  el[name] = value && typeof value !== "function" && typeof value !== "symbol";
8935
9588
  return;
8936
9589
  }
@@ -9114,7 +9767,7 @@ function setAriaAttribute(el, name, value) {
9114
9767
  const warning = (0, import_aria_diagnostics.ariaAttributeWarning)(name, el.localName);
9115
9768
  if (warning !== null) devWarnAttributeOnce(el, name, warning);
9116
9769
  }
9117
- const next = value == null ? null : String(value);
9770
+ const next = value == null || typeof value === "function" || typeof value === "symbol" ? null : String(value);
9118
9771
  const hydration = activeHydration();
9119
9772
  if (hydration !== null && !hydration.allowAttribute(el, name, next)) return;
9120
9773
  if (TRANSITION_JOURNAL !== null) journalAttr(el, name);
@@ -9123,7 +9776,7 @@ function setAriaAttribute(el, name, value) {
9123
9776
  }
9124
9777
  function coerceAttrValue(el, name, value) {
9125
9778
  if (name.charCodeAt(0) === 97 && name.startsWith("aria-")) {
9126
- return value == null ? null : String(value);
9779
+ return value == null || typeof value === "function" || typeof value === "symbol" ? null : String(value);
9127
9780
  }
9128
9781
  const t = typeof value;
9129
9782
  if (t === "boolean" && (0, import_constants.isEnumeratedBooleanAttr)(name)) return value ? "true" : "false";
@@ -9171,6 +9824,7 @@ function coerceAttrValue(el, name, value) {
9171
9824
  if (import_constants.POSITIVE_NUMERIC_ATTR_PROPS.has(lower) && !(Number(value) >= 1)) {
9172
9825
  return null;
9173
9826
  }
9827
+ if ((lower === "rowspan" || lower === "start") && Number.isNaN(Number(value))) return null;
9174
9828
  if (name.length > 2 && name.charCodeAt(0) === 111 && name.charCodeAt(1) === 110) {
9175
9829
  return null;
9176
9830
  }
@@ -9263,7 +9917,9 @@ function setStyleProperty(el, name, value, staticCss, previous) {
9263
9917
  }
9264
9918
  function applyStyleValue(el, style, value, prev) {
9265
9919
  if (value == null || value === false || value === "") {
9266
- if (prev != null && prev !== false && prev !== "") style.cssText = "";
9920
+ if (prev && typeof prev === "object") {
9921
+ for (const key in prev) style.removeProperty((0, import_css.styleName)(key));
9922
+ } else if (typeof prev === "string") style.cssText = "";
9267
9923
  return;
9268
9924
  }
9269
9925
  if (typeof value === "string") {
@@ -9320,10 +9976,13 @@ function isEventKey(k) {
9320
9976
  const CAPTURE_PREFIX = "$$capture:";
9321
9977
  function jsxEventName(rest) {
9322
9978
  if (rest === "DoubleClick") return "dblclick";
9979
+ if (rest === "Focus") return "focusin";
9980
+ if (rest === "Blur") return "focusout";
9323
9981
  return rest.toLowerCase();
9324
9982
  }
9325
- function eventSlot(name) {
9326
- if (!isEventKey(name)) return null;
9983
+ function eventSlot(name, el) {
9984
+ if (!isEventKey(name) || el !== void 0 && isHtmlCustomElement(el) && !(0, import_event_names.isDelegatedEventProp)(name))
9985
+ return null;
9327
9986
  let rest = name.slice(2);
9328
9987
  let capture = false;
9329
9988
  if (rest.length > 7 && rest.endsWith("Capture") && name !== "onGotPointerCapture" && name !== "onLostPointerCapture") {
@@ -9360,7 +10019,7 @@ function removeHostProp(el, name, prevValue) {
9360
10019
  );
9361
10020
  return;
9362
10021
  }
9363
- const ev = eventSlot(name);
10022
+ const ev = eventSlot(name, el);
9364
10023
  if (ev) setEventHandler(el, ev.key, null);
9365
10024
  else setAttribute(el, name, null);
9366
10025
  }
@@ -9377,8 +10036,8 @@ function snapshotSpread(value) {
9377
10036
  return snapshot;
9378
10037
  }
9379
10038
  function formActionAttributeName(el, name) {
9380
- if (el.localName === "form" && name === "action") return "action";
9381
- if ((el.localName === "button" || el.localName === "input") && (name === "formAction" || name === "formaction"))
10039
+ if (name === "action" && el.localName === "form") return "action";
10040
+ if ((name === "formAction" || name === "formaction") && (el.localName === "button" || el.localName === "input"))
9382
10041
  return "formaction";
9383
10042
  return null;
9384
10043
  }
@@ -9399,8 +10058,9 @@ function normalizedHostProp(el, rawName) {
9399
10058
  }
9400
10059
  function setHostPropSources(el, sources, prev, scope, hasNestedChildren = false) {
9401
10060
  const props = /* @__PURE__ */ new Map();
10061
+ let classMerges = null;
9402
10062
  let sourceOrder = 0;
9403
- const record = (rawName, value) => {
10063
+ function record(rawName, value) {
9404
10064
  if (typeof rawName !== "string") return;
9405
10065
  const order = sourceOrder++;
9406
10066
  const previous = props.get(rawName);
@@ -9410,10 +10070,15 @@ function setHostPropSources(el, sources, prev, scope, hasNestedChildren = false)
9410
10070
  firstOrder: previous?.firstOrder ?? order,
9411
10071
  lastOrder: order
9412
10072
  });
9413
- };
10073
+ }
9414
10074
  for (const source of sources) {
9415
10075
  if (!source[0]) {
9416
- record(source[1], source[2]);
10076
+ const rawName = source[1];
10077
+ if (source[3] === true && typeof rawName === "string" && (rawName === "class" || rawName === "className")) {
10078
+ (classMerges ??= []).push({ rawName, value: source[2], order: sourceOrder++ });
10079
+ continue;
10080
+ }
10081
+ record(rawName, source[2]);
9417
10082
  continue;
9418
10083
  }
9419
10084
  const spread = source[1];
@@ -9439,6 +10104,22 @@ function setHostPropSources(el, sources, prev, scope, hasNestedChildren = false)
9439
10104
  writer.lastOrder
9440
10105
  ]);
9441
10106
  }
10107
+ if (classMerges !== null) {
10108
+ for (const extra of classMerges) {
10109
+ const [identity, name] = normalizedHostProp(el, extra.rawName);
10110
+ const previous = values.get(identity);
10111
+ if (previous !== void 0) {
10112
+ values.set(identity, [
10113
+ previous[0],
10114
+ (0, import_css.mergeClass)(previous[1], extra.value),
10115
+ previous[2],
10116
+ extra.order
10117
+ ]);
10118
+ continue;
10119
+ }
10120
+ values.set(identity, [name, extra.value, extra.order, extra.order]);
10121
+ }
10122
+ }
9442
10123
  const resolved = /* @__PURE__ */ Object.create(null);
9443
10124
  const ordered = [...values.values()];
9444
10125
  if (needsWinningOrderSort) ordered.sort((a, b) => a[2] - b[2]);
@@ -9466,7 +10147,7 @@ function setSpread(el, value, prev, mountScope, skipDangerouslySetInnerHTML = fa
9466
10147
  devValidateHostProps(el, Object(value));
9467
10148
  }
9468
10149
  if (value != null && Object.prototype.propertyIsEnumerable.call(Object(value), "suppressHydrationWarning")) {
9469
- el.__oct_suppress = value.suppressHydrationWarning !== false;
10150
+ el.__oct_suppress = value.suppressHydrationWarning === true;
9470
10151
  }
9471
10152
  if (process.env.NODE_ENV !== "production" && value != null && Object.prototype.propertyIsEnumerable.call(Object(value), "suppressNativeChangeWarning")) {
9472
10153
  el.__oct_native_change_suppressed = value.suppressNativeChangeWarning === true;
@@ -9540,7 +10221,7 @@ function setSpread(el, value, prev, mountScope, skipDangerouslySetInnerHTML = fa
9540
10221
  );
9541
10222
  continue;
9542
10223
  }
9543
- const ev = eventSlot(k);
10224
+ const ev = eventSlot(k, el);
9544
10225
  if (ev) {
9545
10226
  if (v === pv) continue;
9546
10227
  if (ev.capture) {
@@ -9572,9 +10253,9 @@ function removeHeadEventListeners(state, attrs) {
9572
10253
  handlers.delete(name);
9573
10254
  }
9574
10255
  }
9575
- function adoptServerHeadEl(key, tag) {
10256
+ function adoptServerHeadEl(head, key, tag) {
9576
10257
  const closeKey = "/" + key;
9577
- for (let n = document.head.firstChild; n !== null; n = n.nextSibling) {
10258
+ for (let n = head.firstChild; n !== null; n = n.nextSibling) {
9578
10259
  if (n.nodeType === 8 && n.data === key) {
9579
10260
  let candidate = n.nextSibling;
9580
10261
  let match = null;
@@ -9610,12 +10291,16 @@ function headBlock(scope, slot, key, tag, attrs, text) {
9610
10291
  if (typeof document === "undefined") return;
9611
10292
  let state = scope.slots[slot];
9612
10293
  if (state === void 0) {
9613
- let el2 = adoptServerHeadEl((0, import_head_ownership.headOwnershipKey)(key, rootIdentifierPrefix(scope.block)), tag);
10294
+ const parent = scope.block.parentNode;
10295
+ const ownerDocument = parent.nodeType === 9 ? parent : parent.ownerDocument;
10296
+ const head = ownerDocument.head;
10297
+ let el2 = adoptServerHeadEl(head, (0, import_head_ownership.headOwnershipKey)(key, rootIdentifierPrefix(scope.block)), tag);
10298
+ const adopted = el2 !== null;
9614
10299
  if (el2 === null) {
9615
- el2 = document.createElement(tag);
9616
- document.head.appendChild(el2);
10300
+ el2 = ownerDocument.createElement(tag);
10301
+ head.appendChild(el2);
9617
10302
  }
9618
- state = { el: el2 };
10303
+ state = { el: el2, attrNames: adopted ? el2.getAttributeNames() : void 0 };
9619
10304
  scope.slots[slot] = state;
9620
10305
  (scope.cleanups ??= []).push(() => {
9621
10306
  removeHeadEventListeners(state, null);
@@ -9624,8 +10309,20 @@ function headBlock(scope, slot, key, tag, attrs, text) {
9624
10309
  });
9625
10310
  }
9626
10311
  const el = state.el;
10312
+ if (TRANSITION_JOURNAL !== null) {
10313
+ journalObjectOnce(state);
10314
+ journalBag();
10315
+ }
9627
10316
  if (state.handlers !== void 0) removeHeadEventListeners(state, attrs);
10317
+ const previousNames = state.attrNames;
10318
+ if (previousNames !== void 0) {
10319
+ for (let i = 0; i < previousNames.length; i++) {
10320
+ const name = previousNames[i];
10321
+ if (attrs === null || !(name in attrs)) setAttribute(el, name, null);
10322
+ }
10323
+ }
9628
10324
  if (attrs !== null) {
10325
+ const names = [];
9629
10326
  for (const k in attrs) {
9630
10327
  const ev = k.length > 2 && k[0] === "o" && k[1] === "n" ? eventSlot(k) : null;
9631
10328
  if (ev !== null) {
@@ -9646,12 +10343,19 @@ function headBlock(scope, slot, key, tag, attrs, text) {
9646
10343
  }
9647
10344
  continue;
9648
10345
  }
10346
+ names.push(k);
9649
10347
  setAttribute(el, k, attrs[k]);
9650
10348
  }
10349
+ state.attrNames = names;
10350
+ } else {
10351
+ state.attrNames = void 0;
9651
10352
  }
9652
- if (text != null) {
9653
- const t = String(text);
9654
- if (el.textContent !== t) el.textContent = t;
10353
+ if (text != null || tag === "title") {
10354
+ const t = text == null ? "" : String(text);
10355
+ if (el.textContent !== t) {
10356
+ if (TRANSITION_JOURNAL !== null) journalRootRange(el, null, null);
10357
+ el.textContent = t;
10358
+ }
9655
10359
  }
9656
10360
  }
9657
10361
  function namespaceHead(props, scope) {
@@ -9684,8 +10388,21 @@ function namespaceHeadElement(headKey, tag, attrs, text, authoredKey) {
9684
10388
  return createElement(namespaceHead, config);
9685
10389
  }
9686
10390
  function injectStyle(id, css, nonce) {
10391
+ if (typeof document === "undefined") {
10392
+ _injectedStyles.add(id);
10393
+ return;
10394
+ }
10395
+ const existing = document.querySelector(`style[data-octane="${id}"]`);
10396
+ if (existing !== null) {
10397
+ if (_injectedStyles.has(id)) {
10398
+ if (existing.textContent !== css) existing.textContent = css;
10399
+ } else {
10400
+ _injectedStyles.add(id);
10401
+ }
10402
+ return;
10403
+ }
9687
10404
  if (_injectedStyles.has(id)) return;
9688
- if (typeof document !== "undefined" && document.querySelector(`style[data-octane="${id}"], style[data-href="octane-${id}"]`)) {
10405
+ if (document.querySelector(`style[data-href~="octane-${id}"]`)) {
9689
10406
  _injectedStyles.add(id);
9690
10407
  return;
9691
10408
  }
@@ -9738,6 +10455,7 @@ function evt0(el, key, fn) {
9738
10455
  return d;
9739
10456
  }
9740
10457
  function evt0u(d, fn) {
10458
+ if (_dispatchDepth !== 0) preserveDispatchedBundle(d);
9741
10459
  if (TRANSITION_JOURNAL !== null) journalObjectOnce(d);
9742
10460
  d.fn = fn;
9743
10461
  }
@@ -9747,6 +10465,7 @@ function evt1(el, key, fn, a0) {
9747
10465
  return d;
9748
10466
  }
9749
10467
  function evt1u(d, fn, a0) {
10468
+ if (_dispatchDepth !== 0) preserveDispatchedBundle(d);
9750
10469
  if (TRANSITION_JOURNAL !== null) {
9751
10470
  journalObjectOnce(d);
9752
10471
  journalObjectOnce(d.args);
@@ -9760,6 +10479,7 @@ function evt2(el, key, fn, a0, a1) {
9760
10479
  return d;
9761
10480
  }
9762
10481
  function evt2u(d, fn, a0, a1) {
10482
+ if (_dispatchDepth !== 0) preserveDispatchedBundle(d);
9763
10483
  if (TRANSITION_JOURNAL !== null) {
9764
10484
  journalObjectOnce(d);
9765
10485
  journalObjectOnce(d.args);
@@ -9775,6 +10495,7 @@ function evtN(el, key, fn, args) {
9775
10495
  return d;
9776
10496
  }
9777
10497
  function evtNu(d, fn, args) {
10498
+ if (_dispatchDepth !== 0) preserveDispatchedBundle(d);
9778
10499
  if (TRANSITION_JOURNAL !== null) journalObjectOnce(d);
9779
10500
  d.fn = fn;
9780
10501
  d.args = args;
@@ -10115,6 +10836,28 @@ const CURRENT_TARGET_DESCRIPTOR = {
10115
10836
  }
10116
10837
  };
10117
10838
  const CAPTURE_PATH = [];
10839
+ const CAPTURE_SLOTS = [];
10840
+ function snapshotDelegatedSlots(base, key, event) {
10841
+ const type = event.type;
10842
+ const suppressDisabled = type === "click" || type === "dblclick" || type === "mousedown" || type === "mousemove" || type === "mouseup" || type === "mouseenter" && key[2] !== "c";
10843
+ for (let index = base; index < CAPTURE_PATH.length; index++) {
10844
+ const node = CAPTURE_PATH[index];
10845
+ const slot = node[key];
10846
+ CAPTURE_SLOTS[index] = slot != null && suppressDisabled && node.disabled && (node.localName === "button" || node.localName === "input" || node.localName === "select" || node.localName === "textarea") ? null : slot;
10847
+ }
10848
+ }
10849
+ function preserveDispatchedBundle(bundle) {
10850
+ let snapshot;
10851
+ for (let index = 0; index < CAPTURE_SLOTS.length; index++) {
10852
+ if (CAPTURE_SLOTS[index] === bundle) {
10853
+ CAPTURE_SLOTS[index] = snapshot ??= {
10854
+ [EVENT_SLOT_KIND]: HANDLER_BUNDLE_KIND,
10855
+ fn: bundle.fn,
10856
+ args: bundle.args.slice()
10857
+ };
10858
+ }
10859
+ }
10860
+ }
10118
10861
  function resolvePortalEventOwner(node) {
10119
10862
  if (node.$$portalParent != null || node.parentNode === null) return;
10120
10863
  const target = node.parentNode;
@@ -10332,13 +11075,7 @@ function dispatchDelegated(event) {
10332
11075
  _dispatchDepth++;
10333
11076
  const node = event.target;
10334
11077
  const prevSubmitRec = ACTIVE_SUBMIT_DISPATCH;
10335
- const submitRec = event.type === "submit" && node != null && node.nodeName === "FORM" ? {
10336
- form: node,
10337
- event,
10338
- transitions: 0,
10339
- published: false,
10340
- intercepted: false
10341
- } : null;
11078
+ const submitRec = event.type === "submit" && node != null && node.nodeName === "FORM" ? snapshotSubmitDispatch(node, event) : null;
10342
11079
  if (submitRec !== null) ACTIVE_SUBMIT_DISPATCH = submitRec;
10343
11080
  const nativeBatch = (0, import_native_read_events.beginNativeEventBatch)(event);
10344
11081
  const pathBase = CAPTURE_PATH.length;
@@ -10348,14 +11085,17 @@ function dispatchDelegated(event) {
10348
11085
  if (delegatedCapture(event.type) && _delegatedCapture.has(event.type) && dispatchDelegatedCapture.call(this, event))
10349
11086
  return;
10350
11087
  if (!_delegated.has(event.type)) return;
11088
+ if (node?.nodeType === 1 && isHtmlCustomElement(node) && (event.type === "invalid" || EMULATED_BUBBLING_EVENTS.includes(event.type)))
11089
+ return;
10351
11090
  buildDelegatedPath(event, this);
11091
+ snapshotDelegatedSlots(pathBase, key, event);
10352
11092
  stop = Object.getOwnPropertyDescriptor(event, "stopPropagation");
10353
11093
  propagationStarted = true;
10354
11094
  beginDelegatedPropagation(event, stop, null);
10355
11095
  for (let i = pathBase; i < CAPTURE_PATH.length; i++) {
10356
11096
  const current = CAPTURE_PATH[i];
10357
11097
  if (targetOnly && current !== event.target) break;
10358
- const slot = current[key];
11098
+ const slot = CAPTURE_SLOTS[i];
10359
11099
  if (slot != null) {
10360
11100
  setCurrentTarget(event, current);
10361
11101
  fireEventSlot(slot, event);
@@ -10363,8 +11103,12 @@ function dispatchDelegated(event) {
10363
11103
  }
10364
11104
  if (targetOnly) break;
10365
11105
  }
11106
+ if (submitRec !== null && FORM_SUBMIT_DRIVER !== null && !event.defaultPrevented && CAPTURE_PATH.includes(submitRec.form, pathBase)) {
11107
+ FORM_SUBMIT_DRIVER(submitRec.form, event, submitRec.action, submitRec.submitter);
11108
+ }
10366
11109
  } finally {
10367
11110
  CAPTURE_PATH.length = pathBase;
11111
+ CAPTURE_SLOTS.length = pathBase;
10368
11112
  if (propagationStarted) endDelegatedPropagation(event, stop, null);
10369
11113
  if (submitRec !== null) {
10370
11114
  ACTIVE_SUBMIT_DISPATCH = prevSubmitRec;
@@ -10387,6 +11131,7 @@ function dispatchDelegatedCapture(event) {
10387
11131
  const key = CAPTURE_PREFIX + event.type;
10388
11132
  const pathBase = CAPTURE_PATH.length;
10389
11133
  buildDelegatedPath(event, this, path);
11134
+ snapshotDelegatedSlots(pathBase, key, event);
10390
11135
  const stop = Object.getOwnPropertyDescriptor(event, "stopPropagation");
10391
11136
  const immediate = delegatedCapture(event.type) ? Object.getOwnPropertyDescriptor(event, "stopImmediatePropagation") : null;
10392
11137
  const wasCancelled = event.cancelBubble;
@@ -10396,7 +11141,7 @@ function dispatchDelegatedCapture(event) {
10396
11141
  try {
10397
11142
  beginDelegatedPropagation(event, stop, immediate);
10398
11143
  for (let i = CAPTURE_PATH.length - 1; i >= pathBase; i--) {
10399
- const slot = CAPTURE_PATH[i][key];
11144
+ const slot = CAPTURE_SLOTS[i];
10400
11145
  if (slot != null) {
10401
11146
  setCurrentTarget(event, CAPTURE_PATH[i]);
10402
11147
  fireEventSlot(slot, event);
@@ -10406,6 +11151,7 @@ function dispatchDelegatedCapture(event) {
10406
11151
  } finally {
10407
11152
  stopped = event[PROPAGATION_FLAGS] !== 0 || !wasCancelled && event.cancelBubble;
10408
11153
  CAPTURE_PATH.length = pathBase;
11154
+ CAPTURE_SLOTS.length = pathBase;
10409
11155
  endDelegatedPropagation(event, stop, immediate);
10410
11156
  clearCurrentTarget(event);
10411
11157
  try {
@@ -10433,7 +11179,7 @@ function clearCurrentTarget(event) {
10433
11179
  delete event.currentTarget;
10434
11180
  delete event[CURRENT_TARGET_NODE];
10435
11181
  }
10436
- const IDLE_FORM_STATUS = { pending: false, data: null, method: "get", action: null };
11182
+ const IDLE_FORM_STATUS = { pending: false, data: null, method: null, action: null };
10437
11183
  const FORM_STATUS = /* @__PURE__ */ new WeakMap();
10438
11184
  const FORM_STATUS_LISTENERS = /* @__PURE__ */ new WeakMap();
10439
11185
  function setFormStatus(form, status) {
@@ -10441,7 +11187,28 @@ function setFormStatus(form, status) {
10441
11187
  const ls = FORM_STATUS_LISTENERS.get(form);
10442
11188
  if (ls) for (const l of ls) l();
10443
11189
  }
11190
+ function snapshotSubmitDispatch(form, event) {
11191
+ let submitter = event.submitter;
11192
+ let action = form.$$formAction;
11193
+ if (submitter !== null && submitter !== void 0) {
11194
+ const override = submitter.$$formAction ?? submitter.getAttribute("formaction");
11195
+ if (override != null) {
11196
+ action = override;
11197
+ submitter = null;
11198
+ }
11199
+ }
11200
+ return {
11201
+ form,
11202
+ event,
11203
+ action,
11204
+ submitter: submitter ?? null,
11205
+ transitions: 0,
11206
+ published: false,
11207
+ intercepted: false
11208
+ };
11209
+ }
10444
11210
  let ACTIVE_SUBMIT_DISPATCH = null;
11211
+ let FORM_SUBMIT_DRIVER = null;
10445
11212
  function publishManualFormPending(rec) {
10446
11213
  if (rec.intercepted || rec.transitions === 0 || !rec.event.defaultPrevented) return;
10447
11214
  const form = rec.form;
@@ -10497,30 +11264,22 @@ function flushFormResets() {
10497
11264
  PENDING_FORM_RESETS = null;
10498
11265
  for (const f of forms) resetFormNow(f);
10499
11266
  }
10500
- function setFormAction(el, name, value, prev) {
11267
+ function setFormAction(el, name, value, _prev) {
10501
11268
  if (typeof value === "function") {
10502
11269
  el.$$formAction = value;
10503
11270
  if (process.env.NODE_ENV !== "production") queueFormActionAuthoringDiagnostic(el);
10504
- if (el.nodeName === "FORM") {
10505
- if (!el.$$formSubmitWired) {
10506
- el.$$formSubmitWired = true;
10507
- el.$$submit = (event) => handleFormSubmit(el, event);
10508
- delegateEvents(["submit"]);
10509
- }
11271
+ if (!el.$$formSubmitWired) {
11272
+ el.$$formSubmitWired = true;
11273
+ FORM_SUBMIT_DRIVER = handleFormSubmit;
11274
+ delegateEvents(["submit"]);
10510
11275
  }
10511
11276
  el.removeAttribute(name);
10512
11277
  return;
10513
11278
  }
10514
11279
  el.$$formAction = void 0;
10515
- if (typeof prev === "function" && el.nodeName === "FORM") {
10516
- el.$$submit = void 0;
10517
- el.$$formSubmitWired = false;
10518
- }
10519
11280
  setAttribute(el, name, value);
10520
11281
  }
10521
- function handleFormSubmit(form, event) {
10522
- const submitter = event.submitter;
10523
- const action = submitter && submitter.$$formAction || form.$$formAction;
11282
+ function handleFormSubmit(form, event, action, submitter) {
10524
11283
  if (typeof action !== "function") return;
10525
11284
  event.preventDefault();
10526
11285
  if (ACTIVE_SUBMIT_DISPATCH !== null && ACTIVE_SUBMIT_DISPATCH.form === form)
@@ -10671,13 +11430,12 @@ function armControlledBase(el) {
10671
11430
  sv: null,
10672
11431
  sawV: false,
10673
11432
  sawC: false,
11433
+ sawDC: false,
10674
11434
  dvv: UNCONTROLLED,
10675
11435
  composing: false,
10676
11436
  compositionEndTask: void 0,
10677
11437
  queued: false,
10678
11438
  formSeen: false,
10679
- formDefaultValue: UNCONTROLLED,
10680
- formDefaultChecked: UNCONTROLLED,
10681
11439
  formMultiple: false
10682
11440
  };
10683
11441
  el.$$ctrl = ctrl;
@@ -10696,7 +11454,7 @@ function armControlled(el) {
10696
11454
  return ctrl;
10697
11455
  }
10698
11456
  function toControlledString(v) {
10699
- return typeof v === "string" ? v : String(v);
11457
+ return typeof v === "string" ? v : typeof v === "function" || typeof v === "symbol" ? "" : String(v);
10700
11458
  }
10701
11459
  function valueNeedsWrite(el, raw) {
10702
11460
  if (el.type === "number") {
@@ -10852,9 +11610,14 @@ function setCheckedState(input, value, ctrl) {
10852
11610
  if (process.env.NODE_ENV !== "production")
10853
11611
  queueDevFormDiagnostic(input, CURRENT_SCOPE ?? void 0);
10854
11612
  const hydration = activeHydration();
10855
- if (hydration !== null && !hydration.isFresh(input)) return;
10856
- if (input.checked !== b) input.checked = b;
11613
+ if (hydration !== null && !hydration.isFresh(input)) {
11614
+ input.checked = input.checked;
11615
+ ctrl.sawDC = true;
11616
+ return;
11617
+ }
11618
+ input.checked = b;
10857
11619
  input.defaultChecked = b;
11620
+ ctrl.sawDC = true;
10858
11621
  return;
10859
11622
  }
10860
11623
  if (process.env.NODE_ENV !== "production" && ctrl.c === -1) devWarnControlledFlip(input, true);
@@ -10868,7 +11631,7 @@ function inActivationWindow(input) {
10868
11631
  const target = activationCheckable;
10869
11632
  if (target === null) return false;
10870
11633
  if (input === target) return true;
10871
- return input.type === "radio" && target.type === "radio" && input.name !== "" && input.name === target.name && input.form === target.form;
11634
+ return input.type === "radio" && target.type === "radio" && input.name !== "" && input.name === target.name && input.form === target.form && (input.form !== null || input.getRootNode() === target.getRootNode());
10872
11635
  }
10873
11636
  function setChecked(el, value) {
10874
11637
  const ctrl = armControlled(el);
@@ -10957,45 +11720,108 @@ function projectSelectValue(sel, sv, setDefaultSelected) {
10957
11720
  }
10958
11721
  if (defaultOption !== null) defaultOption.selected = true;
10959
11722
  }
10960
- function setDefaultValue(el, value) {
11723
+ function setDefaultValue(el, value, initial) {
10961
11724
  const ctrl = armControlled(el);
10962
11725
  const hydration = activeHydration();
10963
- if (hydration !== null && !hydration.isFresh(el) || value == null) return;
10964
11726
  if (el.localName === "select") {
10965
- if (!Object.is(ctrl.dvv, value)) {
11727
+ const first2 = ctrl.dvv === UNCONTROLLED;
11728
+ const multiple = el.multiple;
11729
+ const changedMultiple = ctrl.formMultiple !== multiple;
11730
+ if (first2 || changedMultiple) {
10966
11731
  if (TRANSITION_JOURNAL !== null) {
10967
11732
  journalObjectOnce(ctrl);
10968
11733
  journalBag();
10969
11734
  }
10970
11735
  ctrl.dvv = value;
10971
- queueControlledCommit(SELECT_DEFAULT_SYNCS, { el, value });
11736
+ ctrl.formMultiple = multiple;
11737
+ if (hydration !== null && !hydration.isFresh(el)) return;
11738
+ if (value != null)
11739
+ queueControlledCommit(SELECT_DEFAULT_SYNCS, { el, value });
11740
+ else if (changedMultiple)
11741
+ projectSelectValue(el, multiple ? /* @__PURE__ */ new Set() : "", false);
10972
11742
  }
10973
11743
  return;
10974
11744
  }
11745
+ const first = initial ?? !ctrl.sawV;
11746
+ const previousDefault = ctrl.dvv;
11747
+ if (TRANSITION_JOURNAL !== null) journalObjectOnce(ctrl);
11748
+ ctrl.sawV = true;
11749
+ ctrl.dvv = value;
11750
+ const hydrating = hydration !== null && !hydration.isFresh(el);
10975
11751
  if (ctrl.v !== UNCONTROLLED) return;
10976
11752
  const input = el;
11753
+ if (value == null) {
11754
+ if (previousDefault !== UNCONTROLLED && previousDefault != null) {
11755
+ if (TRANSITION_JOURNAL !== null) journalDefaultValue(input);
11756
+ if (el.localName === "input") input.removeAttribute("value");
11757
+ else input.defaultValue = "";
11758
+ }
11759
+ return;
11760
+ }
10977
11761
  const s = toControlledString(value);
10978
- if (input.defaultValue !== s) {
11762
+ if (first && !hydrating && input.value !== s) {
11763
+ if (TRANSITION_JOURNAL !== null) journalControlled(el, "value", "defaultValue");
11764
+ input.value = s;
11765
+ }
11766
+ if (input.defaultValue !== s || s === "" && el.localName === "input" && !input.hasAttribute("value")) {
10979
11767
  if (TRANSITION_JOURNAL !== null) journalDefaultValue(input);
10980
11768
  input.defaultValue = s;
10981
11769
  }
10982
11770
  }
11771
+ const DEFAULT_VALUE_BASELINE = /* @__PURE__ */ Symbol("octane.defaultValue");
11772
+ const DEFAULT_CHECKED_INITIALIZED = /* @__PURE__ */ Symbol("octane.defaultCheckedInitialized");
10983
11773
  function setDefaultValueUncontrolled(el, value) {
10984
11774
  const hydration = activeHydration();
10985
- if (hydration !== null && !hydration.isFresh(el) || value == null) return;
10986
11775
  const input = el;
10987
- const s = toControlledString(value);
10988
- if (input.defaultValue !== s) {
11776
+ const previous = input[DEFAULT_VALUE_BASELINE];
11777
+ const s = value == null ? null : toControlledString(value);
11778
+ if (TRANSITION_JOURNAL !== null)
11779
+ TRANSITION_JOURNAL.push(JOURNAL_PROP, input, DEFAULT_VALUE_BASELINE, previous);
11780
+ input[DEFAULT_VALUE_BASELINE] = s;
11781
+ const hydrating = hydration !== null && !hydration.isFresh(el);
11782
+ if (s === null) {
11783
+ if (previous != null) {
11784
+ if (TRANSITION_JOURNAL !== null) journalDefaultValue(input);
11785
+ if (el.localName === "input") input.removeAttribute("value");
11786
+ else input.defaultValue = "";
11787
+ }
11788
+ return;
11789
+ }
11790
+ if (previous === void 0 && !hydrating && input.value !== s) {
11791
+ if (TRANSITION_JOURNAL !== null) journalControlled(el, "value", "defaultValue");
11792
+ input.value = s;
11793
+ }
11794
+ if (input.defaultValue !== s || s === "" && el.localName === "input" && !input.hasAttribute("value")) {
10989
11795
  if (TRANSITION_JOURNAL !== null) journalDefaultValue(input);
10990
11796
  input.defaultValue = s;
10991
11797
  }
10992
11798
  }
10993
11799
  function setDefaultChecked(el, value) {
10994
11800
  const ctrl = armControlled(el);
11801
+ const input = el;
10995
11802
  const hydration = activeHydration();
10996
- if (hydration !== null && !hydration.isFresh(el) || value == null) return;
11803
+ const hydrating = hydration !== null && !hydration.isFresh(el);
11804
+ const first = !ctrl.sawDC;
11805
+ if (first) {
11806
+ if (TRANSITION_JOURNAL !== null) {
11807
+ journalObjectOnce(ctrl);
11808
+ journalBag();
11809
+ }
11810
+ ctrl.sawDC = true;
11811
+ }
11812
+ if (hydrating) {
11813
+ if (first) input.checked = input.checked;
11814
+ return;
11815
+ }
10997
11816
  if (ctrl.c !== -1) return;
10998
- const input = el;
11817
+ if (first && !(DEFAULT_CHECKED_INITIALIZED in input)) {
11818
+ if (TRANSITION_JOURNAL !== null) {
11819
+ TRANSITION_JOURNAL.push(JOURNAL_PROP, input, "checked", input.checked);
11820
+ if (input.type === "radio" && input.name !== "" && !!value) journalRadioCousins(input);
11821
+ }
11822
+ input.checked = value == null ? input.checked : !!value;
11823
+ }
11824
+ if (value == null) return;
10999
11825
  const b = !!value;
11000
11826
  if (input.defaultChecked !== b) {
11001
11827
  if (TRANSITION_JOURNAL !== null) {
@@ -11054,16 +11880,12 @@ function setFormControlSources(el, sources) {
11054
11880
  }
11055
11881
  const ctrl = armControlled(el);
11056
11882
  const first = !ctrl.formSeen;
11057
- const previousDefaultValue = ctrl.formDefaultValue;
11058
- const previousDefaultChecked = ctrl.formDefaultChecked;
11059
11883
  const previousMultiple = ctrl.formMultiple;
11060
11884
  if (TRANSITION_JOURNAL !== null) {
11061
11885
  journalObjectOnce(ctrl);
11062
11886
  journalBag();
11063
11887
  }
11064
11888
  ctrl.formSeen = true;
11065
- ctrl.formDefaultValue = defaultValue;
11066
- ctrl.formDefaultChecked = defaultChecked;
11067
11889
  if (process.env.NODE_ENV !== "production" && hasDevFormDiagnosticContext(el, CURRENT_SCOPE ?? void 0)) {
11068
11890
  const diagnostic = ensureDevFormDiagnosticState(el);
11069
11891
  diagnostic.authoringProps = { value, defaultValue, checked, defaultChecked, multiple };
@@ -11076,22 +11898,18 @@ function setFormControlSources(el, sources) {
11076
11898
  const defaultString = defaultValue == null ? null : toControlledString(defaultValue);
11077
11899
  setValue(input, value);
11078
11900
  if (value == null) {
11079
- if (defaultString !== null) setDefaultValue(input, defaultString);
11080
- else if (!first && previousDefaultValue !== UNCONTROLLED && previousDefaultValue != null)
11081
- input.removeAttribute("value");
11901
+ setDefaultValue(input, defaultString, first);
11082
11902
  }
11083
11903
  setChecked(input, checked);
11084
- if (checked == null && defaultChecked != null) setDefaultChecked(input, defaultChecked);
11085
- if (!first && defaultChecked == null && previousDefaultChecked !== UNCONTROLLED && previousDefaultChecked != null) {
11086
- input.defaultChecked = false;
11087
- }
11904
+ if (checked == null && (defaultChecked != null || first))
11905
+ setDefaultChecked(input, defaultChecked);
11088
11906
  return;
11089
11907
  }
11090
11908
  if (tag === "textarea") {
11091
11909
  const textarea = el;
11092
11910
  setValue(textarea, value);
11093
11911
  if (value == null) {
11094
- if (defaultValue != null) setDefaultValue(textarea, defaultValue);
11912
+ if (defaultValue != null) setDefaultValue(textarea, defaultValue, first);
11095
11913
  else if (!first && textarea.defaultValue !== "") textarea.defaultValue = "";
11096
11914
  }
11097
11915
  return;
@@ -11114,7 +11932,7 @@ function setFormControlSources(el, sources) {
11114
11932
  }
11115
11933
  setSelectValue(select, value);
11116
11934
  if (defaultValue != null) setDefaultValue(select, defaultValue);
11117
- else ctrl.dvv = UNCONTROLLED;
11935
+ else if (first) ctrl.dvv = void 0;
11118
11936
  }
11119
11937
  function nativeTextChangeMessage(el, hasBubbleChange, controlled) {
11120
11938
  const changeProp = hasBubbleChange ? "onChange" : "onChangeCapture";
@@ -11277,10 +12095,10 @@ function restoreCheckedState(input, ctrl) {
11277
12095
  }
11278
12096
  function restoreRadioCousins(input) {
11279
12097
  const name = input.name;
11280
- const group = input.form !== null ? input.form.elements : typeof document !== "undefined" ? document.getElementsByName(name) : [];
12098
+ const group = radioCousins(input);
11281
12099
  for (let i = 0; i < group.length; i++) {
11282
12100
  const other = group[i];
11283
- if (other === input || other.localName !== "input" || other.type !== "radio" || other.name !== name) {
12101
+ if (other === input || other.localName !== "input" || other.type !== "radio" || other.name !== name || other.form !== input.form) {
11284
12102
  continue;
11285
12103
  }
11286
12104
  const octrl = other.$$ctrl;
@@ -11398,7 +12216,9 @@ function unregisterPortalEventRange(target, portal2) {
11398
12216
  }
11399
12217
  }
11400
12218
  function portal(parentScope, slotKey, target, body, props, host, env, fragmentOwners, fragmentAnchor) {
12219
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
11401
12220
  const prev = parentScope.slots[slotKey];
12221
+ const key = portalKey(props);
11402
12222
  if (fragmentAnchor !== void 0 && fragmentOwners === void 0 && prev !== void 0 && prev.target === target) {
11403
12223
  prepareFragmentPortalInterleaving(prev);
11404
12224
  }
@@ -11407,12 +12227,13 @@ function portal(parentScope, slotKey, target, body, props, host, env, fragmentOw
11407
12227
  parentScope.block,
11408
12228
  target,
11409
12229
  body,
11410
- props,
12230
+ key === null ? props : void 0,
11411
12231
  // `host` (passed by the compiler) is the JSX element that contains the
11412
12232
  // createPortal call — the natural "logical parent" for event bubbling. When
11413
12233
  // the portal is at top level the compiler passes the block's parentNode.
11414
12234
  host || parentScope.block.parentNode,
11415
- env
12235
+ env,
12236
+ key
11416
12237
  );
11417
12238
  if (prev !== state) {
11418
12239
  journalRootProperty(parentScope.slots, String(slotKey));
@@ -11573,16 +12394,16 @@ function registerValuePortalFragmentOwners(portal2, parentBlock, anchor) {
11573
12394
  registerFragmentPortalOwners(portal2, nestedOwners ?? firstOwner, anchor);
11574
12395
  }
11575
12396
  }
11576
- function renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, env) {
12397
+ function renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, env, key = null) {
11577
12398
  const hydration = activeHydration();
11578
12399
  if (hydration !== null) {
11579
12400
  return hydration.suspend(
11580
- () => renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, env)
12401
+ () => renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, env, key)
11581
12402
  );
11582
12403
  }
11583
12404
  const norm = normalizePortalBody(rawBody, rawProps);
11584
12405
  let state = prev;
11585
- if (state === null || state.target !== target) {
12406
+ if (state === null || state.target !== target || state.key !== key) {
11586
12407
  if (state !== null) teardownPortalState(state);
11587
12408
  const start = document.createComment("portal");
11588
12409
  const end = document.createComment("/portal");
@@ -11603,7 +12424,7 @@ function renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, e
11603
12424
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
11604
12425
  (0, import_profiling.__profileTrackComponent)(block, profilePortalComponent(rawBody));
11605
12426
  }
11606
- state = { __kind: "portalSlotSlot", block, target, host, start, end };
12427
+ state = { __kind: "portalSlotSlot", block, target, key, host, start, end };
11607
12428
  registerPortalEventRange(target, state);
11608
12429
  activityPortalCreated?.(block);
11609
12430
  registerDelegationTarget(target);
@@ -11685,9 +12506,13 @@ function genericPortalBody(value, scope) {
11685
12506
  childSlot(scope, 0, scope.parentNode, value, scope.endMarker);
11686
12507
  }
11687
12508
  const PORTAL_TAG = /* @__PURE__ */ Symbol.for("octane.portal");
12509
+ function portalKey(value) {
12510
+ return typeof value === "string" || typeof value === "number" ? String(value) : null;
12511
+ }
11688
12512
  // @__NO_SIDE_EFFECTS__
11689
12513
  function createPortal(body, target, props = void 0) {
11690
- return { $$kind: PORTAL_TAG, body, target, props };
12514
+ const key = portalKey(props);
12515
+ return { $$kind: PORTAL_TAG, body, target, key, props: key === null ? props : void 0 };
11691
12516
  }
11692
12517
  const ELEMENT_TAG = /* @__PURE__ */ Symbol.for("octane.element");
11693
12518
  const KEYED_ELEMENT_DESCRIPTORS = /* @__PURE__ */ new WeakSet();
@@ -12106,6 +12931,7 @@ function componentSlotVoid(parentScope, slotKey, domParent, comp, props, anchor,
12106
12931
  );
12107
12932
  }
12108
12933
  function componentSlotImpl(outputHandler, parentScope, slotKey, domParent, body, identity, props, renderProps, anchor, key, singleRoot, inherit, hasKey) {
12934
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
12109
12935
  const parentBlock = parentScope.block;
12110
12936
  const hydration = activeHydration();
12111
12937
  if (hydration !== null && (anchor != null && hydration.isFresh(anchor) || hydration.isFresh(domParent))) {
@@ -12215,8 +13041,8 @@ function componentSlotImpl(outputHandler, parentScope, slotKey, domParent, body,
12215
13041
  parentScope.slots[slotKey] = state;
12216
13042
  registerSlot(parentScope, state);
12217
13043
  }
12218
- const nextKey = key === void 0 ? NO_KEY : key;
12219
- const keyChanged = key !== void 0 && state.prevKey !== NO_KEY && !Object.is(key, state.prevKey);
13044
+ const nextKey = key === void 0 ? NO_KEY : "" + key;
13045
+ const keyChanged = key !== void 0 && state.prevKey !== NO_KEY && nextKey !== state.prevKey;
12220
13046
  const replacing = identity !== state.currentComp || keyChanged;
12221
13047
  const journaledSlot = ROOT_RENDER_TRANSACTION !== null && state.block !== null && replacing;
12222
13048
  if (journaledSlot) {
@@ -12671,25 +13497,28 @@ function clearReplacedChildBlock(state, oldBlock) {
12671
13497
  }
12672
13498
  const DEOPT_KEY_WARNED_BLOCKS = /* @__PURE__ */ new WeakSet();
12673
13499
  let DEOPT_KEY_WARNED_WITHOUT_BLOCK = false;
13500
+ function warnMissingListKey(owner) {
13501
+ const warned = owner === null ? DEOPT_KEY_WARNED_WITHOUT_BLOCK : DEOPT_KEY_WARNED_BLOCKS.has(owner);
13502
+ if (!warned) {
13503
+ if (owner === null) DEOPT_KEY_WARNED_WITHOUT_BLOCK = true;
13504
+ else DEOPT_KEY_WARNED_BLOCKS.add(owner);
13505
+ console.warn(
13506
+ '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 ...)`.'
13507
+ );
13508
+ }
13509
+ }
12674
13510
  function deoptKey(item, index) {
12675
13511
  const element = item != null && item.$$kind === ELEMENT_TAG;
13512
+ if (item?.$$kind === PORTAL_TAG && item.key != null) return item.key;
12676
13513
  if (element && item.key != null && !ELEMENTS_MISSING_LIST_KEY.has(item)) return item.key;
12677
13514
  if (element && process.env.NODE_ENV !== "production" && activeHydration() === null) {
12678
- const owner = CURRENT_BLOCK;
12679
- const warned = owner === null ? DEOPT_KEY_WARNED_WITHOUT_BLOCK : DEOPT_KEY_WARNED_BLOCKS.has(owner);
12680
- if (!warned) {
12681
- if (owner === null) DEOPT_KEY_WARNED_WITHOUT_BLOCK = true;
12682
- else DEOPT_KEY_WARNED_BLOCKS.add(owner);
12683
- console.warn(
12684
- '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 ...)`.'
12685
- );
12686
- }
13515
+ warnMissingListKey(CURRENT_BLOCK);
12687
13516
  }
12688
13517
  return element && item.key != null ? item.key : index;
12689
13518
  }
12690
13519
  const POSITIONAL_CHILDREN = /* @__PURE__ */ new WeakSet();
12691
13520
  function deoptKeyPositional(item, index) {
12692
- return item != null && item.$$kind === ELEMENT_TAG && item.key != null ? item.key : index;
13521
+ return item != null && (item.$$kind === ELEMENT_TAG || item.$$kind === PORTAL_TAG) && item.key != null ? item.key : index;
12693
13522
  }
12694
13523
  function positionalChildren(children) {
12695
13524
  POSITIONAL_CHILDREN.add(children);
@@ -12705,6 +13534,11 @@ function noteDeoptRef(block) {
12705
13534
  }
12706
13535
  }
12707
13536
  function applyDeoptProp(el, name, v, ownerBlock) {
13537
+ const actionName = formActionAttributeName(el, name);
13538
+ if (actionName !== null) {
13539
+ setFormAction(el, actionName, v, void 0);
13540
+ return;
13541
+ }
12708
13542
  if (name === "ref") {
12709
13543
  if (v != null) {
12710
13544
  noteDeoptRef(ownerBlock);
@@ -12715,7 +13549,7 @@ function applyDeoptProp(el, name, v, ownerBlock) {
12715
13549
  } else if (name === "style") {
12716
13550
  setStyle(el, v, void 0);
12717
13551
  } else {
12718
- const ev = eventSlot(name);
13552
+ const ev = eventSlot(name, el);
12719
13553
  if (ev !== null) {
12720
13554
  setEventHandler(
12721
13555
  el,
@@ -12737,19 +13571,32 @@ function hasDangerHTML(props) {
12737
13571
  }
12738
13572
  return true;
12739
13573
  }
13574
+ function hasHostPropContent(descriptor) {
13575
+ return hasDangerHTML(descriptor.props) || descriptor.type === "textarea" && (descriptor.props?.value != null || descriptor.props?.defaultValue != null);
13576
+ }
13577
+ function markInputCheckedness(input) {
13578
+ input.checked = input.checked;
13579
+ input[DEFAULT_CHECKED_INITIALIZED] = true;
13580
+ }
12740
13581
  function applyDeoptProps(el, props, ownerBlock) {
12741
13582
  if (props == null) {
13583
+ if (el.localName === "input") markInputCheckedness(el);
12742
13584
  if (process.env.NODE_ENV !== "production") queueDevFormDiagnostic(el, ownerBlock);
12743
13585
  return;
12744
13586
  }
13587
+ let needsCheckedInitialization = el.localName === "input";
12745
13588
  for (const name in props) {
12746
13589
  if (name === "key" || name === "children") continue;
12747
13590
  if (name === "suppressHydrationWarning") {
12748
- el.__oct_suppress = props[name] !== false;
13591
+ el.__oct_suppress = props[name] === true;
12749
13592
  continue;
12750
13593
  }
12751
- applyDeoptProp(el, name, props[name], ownerBlock);
13594
+ const value = props[name];
13595
+ if (needsCheckedInitialization && (name === "defaultChecked" || name === "checked" && value != null))
13596
+ needsCheckedInitialization = false;
13597
+ applyDeoptProp(el, name, value, ownerBlock);
12752
13598
  }
13599
+ if (needsCheckedInitialization) markInputCheckedness(el);
12753
13600
  if (process.env.NODE_ENV !== "production") queueDevFormDiagnostic(el, ownerBlock);
12754
13601
  }
12755
13602
  function patchDeoptProps(el, prevProps, nextProps, ownerBlock) {
@@ -12766,7 +13613,7 @@ function patchDeoptProps(el, prevProps, nextProps, ownerBlock) {
12766
13613
  for (const name in nextProps) {
12767
13614
  if (name === "key" || name === "children") continue;
12768
13615
  if (name === "suppressHydrationWarning") {
12769
- el.__oct_suppress = nextProps[name] !== false;
13616
+ el.__oct_suppress = nextProps[name] === true;
12770
13617
  continue;
12771
13618
  }
12772
13619
  const nv = nextProps[name];
@@ -12810,6 +13657,7 @@ function hostComponent(scope, slot, tag, props, childrenBody, anchor) {
12810
13657
  }
12811
13658
  function applyHostProps(el, props, scope, state) {
12812
13659
  const prev = state.props;
13660
+ let needsCheckedInitialization = prev === void 0 && el.localName === "input";
12813
13661
  if (ROOT_RENDER_TRANSACTION !== null && prev !== props) journalObjectOnce(state);
12814
13662
  if (prev != null) {
12815
13663
  for (const k in prev) {
@@ -12827,14 +13675,22 @@ function applyHostProps(el, props, scope, state) {
12827
13675
  }
12828
13676
  state.props = props;
12829
13677
  if (props == null) {
13678
+ if (needsCheckedInitialization) markInputCheckedness(el);
12830
13679
  if (process.env.NODE_ENV !== "production") queueDevFormDiagnostic(el, scope);
12831
13680
  return;
12832
13681
  }
12833
13682
  for (const name in props) {
12834
13683
  if (name === "key" || name === "children") continue;
12835
13684
  const v = props[name];
13685
+ if (needsCheckedInitialization && (name === "defaultChecked" || name === "checked" && v != null))
13686
+ needsCheckedInitialization = false;
13687
+ const actionName = formActionAttributeName(el, name);
13688
+ if (actionName !== null) {
13689
+ setFormAction(el, actionName, v, prev?.[name]);
13690
+ continue;
13691
+ }
12836
13692
  if (name === "suppressHydrationWarning") {
12837
- el.__oct_suppress = v !== false;
13693
+ el.__oct_suppress = v === true;
12838
13694
  continue;
12839
13695
  }
12840
13696
  if (name === "ref") {
@@ -12848,7 +13704,7 @@ function applyHostProps(el, props, scope, state) {
12848
13704
  } else if (name === "style") {
12849
13705
  setStyle(el, v, prev != null ? prev.style : void 0);
12850
13706
  } else {
12851
- const ev = eventSlot(name);
13707
+ const ev = eventSlot(name, el);
12852
13708
  if (ev) {
12853
13709
  if (ev.capture) {
12854
13710
  if (!_delegatedCapture.has(ev.type)) delegateCaptureEvents([ev.type]);
@@ -12865,6 +13721,7 @@ function applyHostProps(el, props, scope, state) {
12865
13721
  }
12866
13722
  }
12867
13723
  }
13724
+ if (needsCheckedInitialization) markInputCheckedness(el);
12868
13725
  if (process.env.NODE_ENV !== "production") queueDevFormDiagnostic(el, scope);
12869
13726
  }
12870
13727
  const DEOPT_DESC = /* @__PURE__ */ Symbol("octane.deoptDesc");
@@ -12955,7 +13812,7 @@ function deoptWrapperKind(value) {
12955
13812
  return POSITIONAL_CHILDREN.has(value) ? "fragment" : "array";
12956
13813
  }
12957
13814
  function scopedDeoptKey(path, item, index, key) {
12958
- const explicit = isElementDescriptor(item) && item.key != null;
13815
+ const explicit = (isElementDescriptor(item) || item?.$$kind === PORTAL_TAG) && item.key != null;
12959
13816
  if (path.length === 0) return explicit ? "k" + String(key) : "i" + index;
12960
13817
  return JSON.stringify([path, explicit ? "key" : "index", explicit ? String(key) : index]);
12961
13818
  }
@@ -13068,6 +13925,10 @@ function reconcileDeoptNode(prev, value, ownerBlock, ns) {
13068
13925
  if (t === "string" || t === "number" || t === "bigint") {
13069
13926
  const s = String(value);
13070
13927
  if (prev !== null && prev.nodeType === 3) {
13928
+ const hydration = activeHydration();
13929
+ if (hydration !== null && !hydration.isFresh(prev.parentNode)) {
13930
+ return hydration.htextSwap(prev, s);
13931
+ }
13071
13932
  updateTextValue(prev, s);
13072
13933
  return prev;
13073
13934
  }
@@ -13085,7 +13946,7 @@ function reconcileDeoptNode(prev, value, ownerBlock, ns) {
13085
13946
  applyDeoptProps(el, value.props, ownerBlock);
13086
13947
  }
13087
13948
  setDeoptDesc(el, value);
13088
- if (!hasDangerHTML(value.props)) {
13949
+ if (!hasHostPropContent(value)) {
13089
13950
  reconcileDeoptChildren(el, value.children, ownerBlock);
13090
13951
  }
13091
13952
  return el;
@@ -13101,7 +13962,12 @@ function reconcileDeoptChildren(el, children, ownerBlock) {
13101
13962
  if (type === "string" && children !== "" || type === "number" || type === "bigint") {
13102
13963
  const first = getFirstChild(el);
13103
13964
  if (first !== null && first.nodeType === 3 && getNextSibling(first) === null && first.$$deoptKey === 0 && first.$$portalEnd == null) {
13104
- updateTextValue(first, String(children));
13965
+ const hydration = activeHydration();
13966
+ if (hydration !== null && !hydration.isFresh(el)) {
13967
+ hydration.htextSwap(first, String(children));
13968
+ } else {
13969
+ updateTextValue(first, String(children));
13970
+ }
13105
13971
  return;
13106
13972
  }
13107
13973
  }
@@ -13179,6 +14045,10 @@ function reconcileDeoptChildren(el, children, ownerBlock) {
13179
14045
  for (let i = owned.length - 1; i >= 0; i--) {
13180
14046
  const n = owned[i];
13181
14047
  if (keep === null || !keep.has(n)) {
14048
+ const hydration = activeHydration();
14049
+ if (hydration !== null && !hydration.isFresh(el)) {
14050
+ noteRecoverableHydrationError(() => new Error((0, import_error_codes_client_generated.formatClientError)(62)), ownerBlock);
14051
+ }
13182
14052
  if (journal) {
13183
14053
  journalRootChildren(el);
13184
14054
  deferRootRange(el, n, n, () => detachDeoptTreeRefs(n, null));
@@ -13409,6 +14279,7 @@ function mappedDeoptItemBody(item, scope) {
13409
14279
  function descNeedsBlocks(value) {
13410
14280
  if (typeof value === "function") return true;
13411
14281
  if (value == null || typeof value !== "object") return false;
14282
+ if (typeof value.then === "function") return true;
13412
14283
  if (Array.isArray(value)) {
13413
14284
  for (let i = 0; i < value.length; i++) {
13414
14285
  if (descNeedsBlocks(value[i])) return true;
@@ -13434,7 +14305,7 @@ function hostElementBody(d, block) {
13434
14305
  applyDeoptProps(el, d.props, block);
13435
14306
  setDeoptDesc(el, d);
13436
14307
  const savedCursor = hydration.node.nextSibling;
13437
- if (!hasDangerHTML(d.props)) {
14308
+ if (!hasHostPropContent(d)) {
13438
14309
  hydration.node = el.firstChild;
13439
14310
  childSlot(block, 0, el, d.children, null, false, el);
13440
14311
  }
@@ -13462,7 +14333,7 @@ function hostElementBody(d, block) {
13462
14333
  block.parentNode.insertBefore(el, block.endMarker);
13463
14334
  applyDeoptProps(el, d.props, block);
13464
14335
  setDeoptDesc(el, d);
13465
- if (!hasDangerHTML(d.props)) {
14336
+ if (!hasHostPropContent(d)) {
13466
14337
  hydration.suspend(() => childSlot(block, 0, el, d.children, null, false, el));
13467
14338
  }
13468
14339
  return;
@@ -13498,7 +14369,7 @@ function hostElementBody(d, block) {
13498
14369
  patchDeoptProps(el, getDeoptDesc(el)?.props ?? null, d.props, block);
13499
14370
  }
13500
14371
  setDeoptDesc(el, d);
13501
- if (!hasDangerHTML(d.props)) childSlot(block, 0, el, d.children, null, false, el);
14372
+ if (!hasHostPropContent(d)) childSlot(block, 0, el, d.children, null, false, el);
13502
14373
  }
13503
14374
  function hostStringTagBody(d, block) {
13504
14375
  const tag = d.type;
@@ -13512,7 +14383,7 @@ function hostStringTagBody(d, block) {
13512
14383
  applyDeoptProps(el, d.props, block);
13513
14384
  setDeoptDesc(el, d);
13514
14385
  const savedCursor = hydration.node.nextSibling;
13515
- if (!hasDangerHTML(d.props)) {
14386
+ if (!hasHostPropContent(d)) {
13516
14387
  hydration.node = el.firstChild;
13517
14388
  renderHostTagChildren(d, block, el);
13518
14389
  }
@@ -13540,7 +14411,7 @@ function hostStringTagBody(d, block) {
13540
14411
  block.parentNode.insertBefore(el, block.endMarker);
13541
14412
  applyDeoptProps(el, d.props, block);
13542
14413
  setDeoptDesc(el, d);
13543
- if (!hasDangerHTML(d.props)) {
14414
+ if (!hasHostPropContent(d)) {
13544
14415
  hydration.suspend(() => renderHostTagChildren(d, block, el));
13545
14416
  }
13546
14417
  return;
@@ -13554,7 +14425,7 @@ function hostStringTagBody(d, block) {
13554
14425
  patchDeoptProps(el, getDeoptDesc(el)?.props ?? null, d.props, block);
13555
14426
  }
13556
14427
  setDeoptDesc(el, d);
13557
- if (!hasDangerHTML(d.props)) renderHostTagChildren(d, block, el);
14428
+ if (!hasHostPropContent(d)) renderHostTagChildren(d, block, el);
13558
14429
  }
13559
14430
  function renderHostTagChildren(d, block, el) {
13560
14431
  const kids = d.children;
@@ -13732,6 +14603,8 @@ function mapSlot(scopeOrItems, slotOrMethod, domParent, items, method, native, c
13732
14603
  callback = native;
13733
14604
  native = mapSlot(items, method);
13734
14605
  }
14606
+ if (process.env.NODE_ENV !== "production" && ((flags ?? 0) & 64) !== 0 && items?.length > 0)
14607
+ warnMissingListKey(scopeOrItems.block);
13735
14608
  if (ownEnd === 1) ownEnd = true;
13736
14609
  if (native === true) {
13737
14610
  const previous = scopeOrItems.slots[slotOrMethod]?.forSlot;
@@ -14001,6 +14874,7 @@ function renderPreparedChildList(state, parentBlock, domParent, preparedList, hy
14001
14874
  return;
14002
14875
  }
14003
14876
  function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsHost, compactable, includeKeyedSingle = true, compiledMapBody, compiledMapKey, compiledMapFlags, compiledMapDeps, mappedFallback) {
14877
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
14004
14878
  if (value != null && includeKeyedSingle && domParent.nodeType === 1 && import_constants.VOID_ELEMENTS.has(domParent.localName) && !isPortalTarget(parentScope.block, domParent)) {
14005
14879
  throw new Error((0, import_error_codes_client_generated.formatClientError)(26, domParent.localName));
14006
14880
  }
@@ -14075,7 +14949,7 @@ function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsH
14075
14949
  slotKey,
14076
14950
  domParent,
14077
14951
  value,
14078
- anchor,
14952
+ anchor?.parentNode === domParent ? anchor : null,
14079
14953
  ownEnd,
14080
14954
  ownsHost,
14081
14955
  compactable,
@@ -14196,7 +15070,9 @@ function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsH
14196
15070
  portalDesc.body,
14197
15071
  portalDesc.props,
14198
15072
  // The DOM element containing this hole is the portal's logical parent.
14199
- domParent
15073
+ domParent,
15074
+ void 0,
15075
+ portalDesc.key
14200
15076
  );
14201
15077
  if (activeFragments.size !== 0 && state.end !== null) {
14202
15078
  registerValuePortalFragmentOwners(state.portal, parentBlock, state.end);
@@ -14832,7 +15708,17 @@ function memo(component, arePropsEqual) {
14832
15708
  function memoWrapper(props, scope, extra) {
14833
15709
  return component(props, scope, extra);
14834
15710
  }
14835
- memoWrapper.__memo = true;
15711
+ Object.defineProperty(memoWrapper, "type", { value: component });
15712
+ Object.defineProperty(memoWrapper, "displayName", {
15713
+ configurable: true,
15714
+ writable: true,
15715
+ value: component.displayName || component.name || "Memo"
15716
+ });
15717
+ Object.defineProperty(memoWrapper, "__memo", {
15718
+ get() {
15719
+ return this === memoWrapper;
15720
+ }
15721
+ });
14836
15722
  Object.defineProperty(memoWrapper, "defaultProps", {
14837
15723
  configurable: true,
14838
15724
  get: () => component.defaultProps,
@@ -14842,7 +15728,7 @@ function memo(component, arePropsEqual) {
14842
15728
  });
14843
15729
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
14844
15730
  (0, import_profiling.__profileComponentSource)(memoWrapper, component);
14845
- if (arePropsEqual) memoWrapper.__compare = arePropsEqual;
15731
+ if (arePropsEqual) Object.defineProperty(memoWrapper, "__compare", { value: arePropsEqual });
14846
15732
  return memoWrapper;
14847
15733
  }
14848
15734
  const HMR = /* @__PURE__ */ Symbol.for("octane.hmr");
@@ -14867,7 +15753,7 @@ function hmr(fn) {
14867
15753
  meta.fn = nextFn;
14868
15754
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
14869
15755
  (0, import_profiling.__profileComponentSource)(wrapper, meta.fn);
14870
- wrapper.__warm = meta.fn.__warm;
15756
+ markWarm(wrapper, meta.fn.__warm);
14871
15757
  const it = meta.liveBlocks.values();
14872
15758
  for (let r = it.next(); !r.done; r = it.next()) {
14873
15759
  const b = r.value;
@@ -14889,10 +15775,14 @@ function hmr(fn) {
14889
15775
  if (scope !== void 0) meta.liveBlocks.add(scope.block);
14890
15776
  return meta.fn(props, scope, extra);
14891
15777
  }
14892
- wrapper[HMR] = meta;
15778
+ Object.defineProperty(wrapper, HMR, {
15779
+ get() {
15780
+ return this === wrapper ? meta : void 0;
15781
+ }
15782
+ });
14893
15783
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
14894
15784
  (0, import_profiling.__profileComponentSource)(wrapper, fn);
14895
- if (fn.__warm !== void 0) wrapper.__warm = fn.__warm;
15785
+ if (fn.__warm !== void 0) markWarm(wrapper, fn.__warm);
14896
15786
  return wrapper;
14897
15787
  }
14898
15788
  let TRANSITION_FALLBACK_TIMEOUT_MS = Infinity;
@@ -15685,7 +16575,7 @@ function renderVisibleTry(state, source) {
15685
16575
  throw renderError;
15686
16576
  if (isSuspenseException(renderError)) {
15687
16577
  if (state.propagateSuspense) throw renderError;
15688
- handleSuspense(state, renderError.thenable, block, journalCheckpoint);
16578
+ handleSuspense(state, renderError.thenable, block, journalCheckpoint, source ?? block);
15689
16579
  } else switchToCatch(state, renderError, true);
15690
16580
  } else {
15691
16581
  if (capture !== null) spliceOffscreenCapture(capture);
@@ -15970,6 +16860,7 @@ function releaseHeldTransition(state) {
15970
16860
  if (state.transitionHeld) {
15971
16861
  state.transitionHeld = false;
15972
16862
  tickTransitionCount(-1);
16863
+ releaseTransitionHookHolder(state);
15973
16864
  }
15974
16865
  abandonHeldTransition(state);
15975
16866
  if (state.transitionTimeoutId !== null) {
@@ -15977,14 +16868,15 @@ function releaseHeldTransition(state) {
15977
16868
  state.transitionTimeoutId = null;
15978
16869
  }
15979
16870
  }
15980
- function handleSuspense(state, thenable, sourceBlock, journalCheckpoint = -1) {
16871
+ function handleSuspense(state, thenable, sourceBlock, journalCheckpoint = -1, transitionOrigin = sourceBlock) {
15981
16872
  ensureScheduledVisibilityDriver();
15982
16873
  const isTransition = sourceBlock.currentRenderMode === "transition";
15983
- if ((isTransition || state.transitionHeld) && state.hasResolved && state.branch === 1 && state.hiddenDom === null) {
16874
+ if (isTransition && state.hasResolved && state.branch === 1 && state.hiddenDom === null) {
15984
16875
  rollbackTransitionJournal(journalCheckpoint, state.tryBlock ?? sourceBlock);
15985
16876
  if (ACTIVE_TRANSITION_ATTEMPT !== null) {
15986
16877
  (ACTIVE_TRANSITION_ATTEMPT.heldSlots ??= /* @__PURE__ */ new Set()).add(state);
15987
16878
  }
16879
+ holdTransitionHooksForBlock(state, transitionOrigin);
15988
16880
  if (!state.transitionHeld) {
15989
16881
  state.transitionHeld = true;
15990
16882
  tickTransitionCount(1);
@@ -16005,6 +16897,7 @@ function handleSuspense(state, thenable, sourceBlock, journalCheckpoint = -1) {
16005
16897
  attachResume(state, thenable);
16006
16898
  return;
16007
16899
  }
16900
+ if (!isTransition) releaseHeldTransition(state);
16008
16901
  hideTryContentAndMountPending(state, thenable);
16009
16902
  }
16010
16903
  function invalidatePendingSuspenseEffects(owner) {
@@ -16297,7 +17190,10 @@ function commitResumeInner(state) {
16297
17190
  if (!deferringStagedRevealEffects) commitEffects();
16298
17191
  } finally {
16299
17192
  if (hiddenActivity !== null) rehideActivityAfterDescendantRender(hiddenActivity);
16300
- if (releaseHeld) tickTransitionCount(-1);
17193
+ if (releaseHeld) {
17194
+ tickTransitionCount(-1);
17195
+ releaseTransitionHookHolder(state);
17196
+ }
16301
17197
  }
16302
17198
  }
16303
17199
  function findScheduledVisibilityOwner(block, includeActivity, visibleMode = null) {
@@ -16617,6 +17513,7 @@ function attemptHiddenRevealInner(state, scheduledMode, reason = "update") {
16617
17513
  if (state.transitionHeld) {
16618
17514
  state.transitionHeld = false;
16619
17515
  tickTransitionCount(-1);
17516
+ releaseTransitionHookHolder(state);
16620
17517
  }
16621
17518
  if (HELD_TRANSITIONS.has(state)) {
16622
17519
  HELD_TRANSITIONS.delete(state);
@@ -16671,6 +17568,7 @@ function flushStagedReveals() {
16671
17568
  break;
16672
17569
  }
16673
17570
  }
17571
+ if (allVisible && heldTransitionHasPendingAction(HELD_SYNC_TRANSITION.entries)) return;
16674
17572
  if (allVisible && promoteHeldSyncTransition()) {
16675
17573
  STAGED_REVEALS.clear();
16676
17574
  flush();
@@ -16750,6 +17648,9 @@ function attachResume(state, thenable) {
16750
17648
  thenable.then(retry, retry);
16751
17649
  }
16752
17650
  function startTransition(fn) {
17651
+ runTransition(fn);
17652
+ }
17653
+ function runTransition(fn, hook) {
16753
17654
  ensureTransitionSwapDriver();
16754
17655
  TRANSITION_DEPTH++;
16755
17656
  const parentActionBatch = ACTIVE_TRANSITION_ACTION_BATCH;
@@ -16757,6 +17658,10 @@ function startTransition(fn) {
16757
17658
  const actionBatch = parentActionBatch ?? pendingActionBatch ?? createTransitionActionBatch();
16758
17659
  const ownsActionBatch = parentActionBatch === null && pendingActionBatch === null;
16759
17660
  ACTIVE_TRANSITION_ACTION_BATCH = actionBatch;
17661
+ if (hook !== void 0) {
17662
+ addTransitionHookToBatch(actionBatch, hook);
17663
+ publishTransitionHookBatch(actionBatch);
17664
+ }
16760
17665
  const submitRec = ACTIVE_SUBMIT_DISPATCH;
16761
17666
  if (submitRec !== null) submitRec.transitions++;
16762
17667
  let result;
@@ -16786,7 +17691,10 @@ function startTransition(fn) {
16786
17691
  tickTransitionCount(-1);
16787
17692
  if (submitRec !== null) settleSubmitTransition(submitRec);
16788
17693
  flushFormResets();
16789
- throw err;
17694
+ actionBatch.workComplete = true;
17695
+ finishTransitionHookBatch(actionBatch);
17696
+ reportTransitionError(err, hook);
17697
+ return;
16790
17698
  }
16791
17699
  if (result != null && typeof result.then === "function") {
16792
17700
  ASYNC_TRANSITION_COUNT++;
@@ -16800,16 +17708,31 @@ function startTransition(fn) {
16800
17708
  ASYNC_TRANSITION_COUNT--;
16801
17709
  if (submitRec !== null) settleSubmitTransition(submitRec);
16802
17710
  flushFormResets();
17711
+ queueMicrotask(() => {
17712
+ actionBatch.workComplete = true;
17713
+ finishTransitionHookBatch(actionBatch);
17714
+ });
16803
17715
  };
16804
- result.then(settle, settle);
17716
+ result.then(settle, (error) => {
17717
+ settle();
17718
+ reportTransitionError(error, hook);
17719
+ });
16805
17720
  } else {
16806
17721
  queueMicrotask(() => {
16807
17722
  tickTransitionCount(-1);
16808
17723
  if (submitRec !== null) settleSubmitTransition(submitRec);
16809
17724
  flushFormResets();
17725
+ actionBatch.workComplete = true;
17726
+ finishTransitionHookBatch(actionBatch);
16810
17727
  });
16811
17728
  }
16812
17729
  }
17730
+ function reportTransitionError(error, hook) {
17731
+ if (hook !== void 0 && !hook.block.disposed) {
17732
+ hook.error = { value: error };
17733
+ scheduleRender(hook.block);
17734
+ } else reportListenerError(error);
17735
+ }
16813
17736
  function useTransition(slot) {
16814
17737
  slot = resolveSlot(slot);
16815
17738
  if (slot === void 0) missingSlot("useTransition");
@@ -16817,22 +17740,33 @@ function useTransition(slot) {
16817
17740
  const block = CURRENT_BLOCK;
16818
17741
  let s = scope.hooks?.get(slot);
16819
17742
  if (s === void 0) {
16820
- const slotRef = { isPending: false, start: startTransition };
16821
- s = slotRef;
16822
- ensureHooks(scope).set(slot, slotRef);
16823
- const listener = () => {
16824
- const next = TRANSITION_PENDING_COUNT > 0;
16825
- if (slotRef.isPending !== next) {
16826
- slotRef.isPending = next;
16827
- if (!block.disposed) {
17743
+ const hook = {
17744
+ isPending: false,
17745
+ block,
17746
+ pendingBatches: 0,
17747
+ start: (fn) => {
17748
+ if (!block.disposed) runTransition(fn, hook);
17749
+ },
17750
+ publish: (pending) => {
17751
+ if (hook.isPending === pending || block.disposed) return;
17752
+ hook.isPending = pending;
17753
+ TRANSITION_LISTENER_PUBLISH_DEPTH++;
17754
+ try {
16828
17755
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
16829
17756
  (0, import_profiling.__profileSchedule)(block, "transition-pending", slot);
16830
17757
  scheduleRender(block);
17758
+ } finally {
17759
+ TRANSITION_LISTENER_PUBLISH_DEPTH--;
16831
17760
  }
16832
17761
  }
16833
17762
  };
16834
- TRANSITION_LISTENERS.add(listener);
16835
- registerHookCleanup(scope, () => TRANSITION_LISTENERS.delete(listener));
17763
+ s = hook;
17764
+ ensureHooks(scope).set(slot, hook);
17765
+ }
17766
+ if (s.error !== void 0) {
17767
+ const error = s.error.value;
17768
+ s.error = void 0;
17769
+ throw error;
16836
17770
  }
16837
17771
  return [s.isPending, s.start];
16838
17772
  }
@@ -16863,6 +17797,7 @@ function useActionState(action, initialState, permalinkOrSlot, slot) {
16863
17797
  }
16864
17798
  };
16865
17799
  const dispatch = ((payload) => {
17800
+ const outsideTransition = process.env.NODE_ENV !== "production" && transitionActionBatchForUpdate() === null && ACTIVE_SUBMIT_DISPATCH?.intercepted !== true;
16866
17801
  slotRef.pendingCount++;
16867
17802
  setPending(true);
16868
17803
  slotRef.chain = slotRef.chain.then(
@@ -16874,7 +17809,13 @@ function useActionState(action, initialState, permalinkOrSlot, slot) {
16874
17809
  startTransition(() => {
16875
17810
  let p;
16876
17811
  try {
16877
- p = Promise.resolve(slotRef.action(prevState, payload));
17812
+ const result = slotRef.action(prevState, payload);
17813
+ if (process.env.NODE_ENV !== "production" && outsideTransition && result != null && typeof result.then === "function") {
17814
+ console.error(
17815
+ "An async useActionState action was dispatched outside a transition or action. Use an action/formAction prop or wrap the dispatch in startTransition."
17816
+ );
17817
+ }
17818
+ p = Promise.resolve(result);
16878
17819
  } catch (err) {
16879
17820
  finish();
16880
17821
  const handler = findTryHandler(block);
@@ -16902,7 +17843,7 @@ function useActionState(action, initialState, permalinkOrSlot, slot) {
16902
17843
  resolveResult(prevState);
16903
17844
  }
16904
17845
  );
16905
- return p;
17846
+ return p.then(noop, noop);
16906
17847
  });
16907
17848
  })
16908
17849
  );
@@ -16990,6 +17931,11 @@ function useOptimistic(passthrough, updateFnOrSlot, slot) {
16990
17931
  updateFn,
16991
17932
  armed: false,
16992
17933
  add: (value) => {
17934
+ if (process.env.NODE_ENV !== "production" && TRANSITION_DEPTH === 0 && ASYNC_TRANSITION_COUNT === 0) {
17935
+ console.error(
17936
+ "An optimistic update was dispatched outside a transition or action. Wrap it in startTransition or call it from an action."
17937
+ );
17938
+ }
16993
17939
  slotRef.queue.push(value);
16994
17940
  if (TRANSITION_PENDING_COUNT > 0) {
16995
17941
  slotRef.armed = true;
@@ -17023,11 +17969,11 @@ function spawnDeferredSwap(s) {
17023
17969
  queueMicrotask(() => {
17024
17970
  if (!s.scheduled || s.block.disposed) return;
17025
17971
  s.scheduled = false;
17026
- if (Object.is(s.current, s.next)) return;
17027
- s.current = s.next;
17972
+ if (Object.is(s.value, s.next)) return;
17028
17973
  startTransition(() => {
17029
17974
  DEFERRED_SPAWN = true;
17030
17975
  try {
17976
+ stageTransitionValue(s, s.block, s.next, s.next, true);
17031
17977
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
17032
17978
  (0, import_profiling.__profileSchedule)(s.block, "deferred-value", s.profileSlot);
17033
17979
  scheduleRender(s.block);
@@ -17038,6 +17984,14 @@ function spawnDeferredSwap(s) {
17038
17984
  });
17039
17985
  });
17040
17986
  }
17987
+ function hasHeldDeferredSwap(slot) {
17988
+ const entries = HELD_SYNC_TRANSITION?.entries ?? slot.block.idState.renderOwner?.transition?.entries;
17989
+ if (entries === void 0) return false;
17990
+ for (const entry of entries) {
17991
+ if (entry.slot === slot && Object.is(entry.value, slot.next)) return true;
17992
+ }
17993
+ return false;
17994
+ }
17041
17995
  function useDeferredValue(value, ...rest) {
17042
17996
  let slot = rest[rest.length - 1];
17043
17997
  slot = resolveSlot(slot);
@@ -17051,7 +18005,7 @@ function useDeferredValue(value, ...rest) {
17051
18005
  if (s === void 0) {
17052
18006
  if (hasInitial && !block.currentRenderDeferred) {
17053
18007
  s = {
17054
- current: initialValue,
18008
+ value: initialValue,
17055
18009
  next: value,
17056
18010
  scheduled: false,
17057
18011
  block,
@@ -17063,31 +18017,32 @@ function useDeferredValue(value, ...rest) {
17063
18017
  if (!Object.is(initialValue, value)) spawnDeferredSwap(s);
17064
18018
  return initialValue;
17065
18019
  }
17066
- s = { current: value, next: value, scheduled: false, block, wasHidden: hidden };
18020
+ s = { value, next: value, scheduled: false, block, wasHidden: hidden };
17067
18021
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
17068
18022
  s.profileSlot = slot;
17069
18023
  ensureHooks(scope).set(slot, s);
17070
18024
  return value;
17071
18025
  }
18026
+ if (ACTIVE_TRANSITION_ATTEMPT !== null) journalObjectOnce(s);
17072
18027
  s.next = value;
17073
18028
  const wasHidden = s.wasHidden;
17074
18029
  s.wasHidden = hidden;
17075
- if (Object.is(s.current, value)) return s.current;
18030
+ if (Object.is(s.value, value)) return s.value;
17076
18031
  if (hidden || wasHidden) {
17077
18032
  if (hasInitial && !block.currentRenderDeferred && !Object.is(initialValue, value)) {
17078
- s.current = initialValue;
18033
+ s.value = initialValue;
17079
18034
  if (!s.scheduled) spawnDeferredSwap(s);
17080
18035
  return initialValue;
17081
18036
  }
17082
- s.current = value;
18037
+ s.value = value;
17083
18038
  return value;
17084
18039
  }
17085
18040
  if (block.currentRenderMode === "transition") {
17086
- s.current = value;
18041
+ s.value = value;
17087
18042
  return value;
17088
18043
  }
17089
- if (!s.scheduled) spawnDeferredSwap(s);
17090
- return s.current;
18044
+ if (!s.scheduled && !hasHeldDeferredSwap(s)) spawnDeferredSwap(s);
18045
+ return s.value;
17091
18046
  }
17092
18047
  function requestReset(state) {
17093
18048
  if (state.parentBlock.disposed || state.branch !== 0) return;
@@ -17161,6 +18116,7 @@ function switchToCatchInner(state, err, reportInline, adoptedStart, adoptedEnd)
17161
18116
  if (state.transitionHeld) {
17162
18117
  state.transitionHeld = false;
17163
18118
  tickTransitionCount(-1);
18119
+ releaseTransitionHookHolder(state);
17164
18120
  }
17165
18121
  abandonHeldTransition(state);
17166
18122
  if (state.catchBody === null) {
@@ -17322,6 +18278,7 @@ function sharesBlockBoundary(parent, start, end) {
17322
18278
  return parent !== null && start !== null && end !== null && parent.startMarker === start && parent.endMarker === end;
17323
18279
  }
17324
18280
  function renderBranchSlot(parentScope, slotKey, state, domParent, next, body, marker, env) {
18281
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
17325
18282
  const parentBlock = parentScope.block;
17326
18283
  const hydration = activeHydration();
17327
18284
  if (next !== state.branch) {
@@ -17986,6 +18943,7 @@ function queueActivityDeactivation(state, block, commitVersion) {
17986
18943
  });
17987
18944
  }
17988
18945
  function activityBlock(parentScope, slotKey, domParent, mode, body, anchor, env) {
18946
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
17989
18947
  if (mode === "hidden") ensureScheduledVisibilityDriver();
17990
18948
  const parentBlock = parentScope.block;
17991
18949
  const hydration = activeHydration();
@@ -18224,7 +19182,7 @@ function deactivateScope(scope, disconnectPassive = true) {
18224
19182
  const cleanup = e.cleanup;
18225
19183
  e.cleanup = void 0;
18226
19184
  try {
18227
- runEffectCleanupCallback(cleanup);
19185
+ runEffectCleanupCallback(cleanup, e.phase);
18228
19186
  } catch (err) {
18229
19187
  if (err instanceof MaximumUpdateDepthError) throw err;
18230
19188
  const handler = findTryHandler(scope.block);
@@ -18275,6 +19233,7 @@ function switchBlock(parentScope, slotKey, domParent, discriminant, cases, defau
18275
19233
  renderBranchSlot(parentScope, slotKey, state, domParent, nextIdx, body, "switch", env);
18276
19234
  }
18277
19235
  function forBlock(parentScope, slotKey, domParent, items, getKey, itemBody, flags, deps, emptyBody, anchor, ownEnd) {
19236
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
18278
19237
  const parentBlock = parentScope.block;
18279
19238
  const hydration = activeHydration();
18280
19239
  let state = parentScope.slots[slotKey];
@@ -18430,6 +19389,7 @@ function forBlock(parentScope, slotKey, domParent, items, getKey, itemBody, flag
18430
19389
  }
18431
19390
  }
18432
19391
  function keyedForBlock(parentScope, slotKey, domParent, items, getKey, itemBody, flags, deps, emptyBody, anchor, ownEnd, selectionBody) {
19392
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
18433
19393
  const state = parentScope.slots[slotKey];
18434
19394
  if (TRANSITION_JOURNAL !== null && ROOT_RENDER_TRANSACTION === null) {
18435
19395
  if (state !== void 0) {
@@ -18758,9 +19718,25 @@ function consumeAdoptQueuePrefix(adopt, count) {
18758
19718
  if (count < adopt.length) adopt.copyWithin(0, count);
18759
19719
  adopt.length -= count;
18760
19720
  }
19721
+ function checkedListKey(getKey) {
19722
+ const seen = /* @__PURE__ */ new Map();
19723
+ let warned = false;
19724
+ return (item, index) => {
19725
+ const key = getKey(item, index);
19726
+ if (!warned && seen.has(key) && seen.get(key) !== index) {
19727
+ warned = true;
19728
+ const label = typeof key === "object" || typeof key === "function" ? "[object identity]" : String(key);
19729
+ console.error(
19730
+ `Encountered two children with the same key, ${label}. Keys should be unique so that components maintain their identity across updates.`
19731
+ );
19732
+ } else seen.set(key, index);
19733
+ return key;
19734
+ };
19735
+ }
18761
19736
  function mountItemsLinear(parentBlock, state, items, getKey, itemBody, singleRoot, ssrMarkerless) {
18762
19737
  const newLen = items.length;
18763
19738
  if (newLen === 0) return;
19739
+ if (process.env.NODE_ENV !== "production") getKey = checkedListKey(getKey);
18764
19740
  if (TRANSITION_JOURNAL !== null) journalForSlot(state);
18765
19741
  const oldItems = state.items;
18766
19742
  const parentNode = state.end.parentNode;
@@ -18830,6 +19806,7 @@ function reconcileKeyed(parentBlock, state, items, getKey, itemBody, pure, singl
18830
19806
  mountItemsLinear(parentBlock, state, items, getKey, itemBody, singleRoot, ssrMarkerless);
18831
19807
  return;
18832
19808
  }
19809
+ if (process.env.NODE_ENV !== "production") getKey = checkedListKey(getKey);
18833
19810
  if (newLen === 0) {
18834
19811
  if (journalShape) journalForSlot(state);
18835
19812
  batchClearItems(state, oldItems);
@@ -19088,81 +20065,72 @@ function reconcileKeyed(parentBlock, state, items, getKey, itemBody, pure, singl
19088
20065
  }
19089
20066
  }
19090
20067
  const middleEndAnchor = afterMiddle ? afterMiddle.startMarker : state.end;
19091
- let nextBlock = afterMiddle;
19092
- let lastPlaced = null;
19093
- if (moved) {
20068
+ if (patched === newMidLen) {
19094
20069
  const seq = lis(sources, newMidLen);
19095
20070
  let seqIdx = seq.length - 1;
20071
+ let nextBlock = afterMiddle;
19096
20072
  for (let i = newMidLen - 1; i >= 0; i--) {
19097
- const targetIdx = i + prefixLen;
19098
- const key = newKeys[i];
19099
- const anchor = nextBlock ? nextBlock.startMarker : middleEndAnchor;
19100
- let block;
19101
- if (sources[i] === -1) {
19102
- const item = items[targetIdx];
19103
- block = mountItem(
19104
- parentBlock,
19105
- parentNode,
19106
- anchor,
19107
- item,
19108
- targetIdx,
19109
- itemBody,
19110
- state,
19111
- singleRoot,
19112
- ssrMarkerless
19113
- );
19114
- oldItems.set(key, block);
19115
- block.key = key;
19116
- state.size++;
19117
- } else if (seqIdx < 0 || i !== seq[seqIdx]) {
19118
- block = oldItems.get(key);
19119
- moveBlockBefore(block, anchor);
19120
- } else {
19121
- block = oldItems.get(key);
19122
- seqIdx--;
19123
- }
20073
+ const block = oldItems.get(newKeys[i]);
20074
+ if (seqIdx < 0 || i !== seq[seqIdx]) {
20075
+ moveBlockBefore(block, nextBlock ? nextBlock.startMarker : middleEndAnchor);
20076
+ } else seqIdx--;
19124
20077
  block.nextSibling = nextBlock;
19125
20078
  if (nextBlock) nextBlock.prevSibling = block;
19126
- if (lastPlaced === null) lastPlaced = block;
20079
+ else state.tail = block;
19127
20080
  nextBlock = block;
19128
20081
  }
19129
- } else {
20082
+ nextBlock.prevSibling = beforeMiddle;
20083
+ if (beforeMiddle) beforeMiddle.nextSibling = nextBlock;
20084
+ else state.head = nextBlock;
20085
+ return;
20086
+ }
20087
+ if (moved) {
20088
+ const seq = lis(sources, newMidLen);
20089
+ let seqIdx = seq.length - 1;
20090
+ let anchor = middleEndAnchor;
19130
20091
  for (let i = newMidLen - 1; i >= 0; i--) {
19131
- const targetIdx = i + prefixLen;
19132
- const key = newKeys[i];
19133
- const anchor = nextBlock ? nextBlock.startMarker : middleEndAnchor;
19134
- let block;
19135
- if (sources[i] === -1) {
19136
- const item = items[targetIdx];
19137
- block = mountItem(
19138
- parentBlock,
19139
- parentNode,
19140
- anchor,
19141
- item,
19142
- targetIdx,
19143
- itemBody,
19144
- state,
19145
- singleRoot,
19146
- ssrMarkerless
19147
- );
19148
- oldItems.set(key, block);
19149
- block.key = key;
19150
- state.size++;
19151
- } else {
19152
- block = oldItems.get(key);
20092
+ if (sources[i] === -1) continue;
20093
+ const block = oldItems.get(newKeys[i]);
20094
+ if (seqIdx < 0 || i !== seq[seqIdx]) moveBlockBefore(block, anchor);
20095
+ else seqIdx--;
20096
+ anchor = block.startMarker;
20097
+ }
20098
+ }
20099
+ let previous = beforeMiddle;
20100
+ let nextSurvivor = 0;
20101
+ for (let i = 0; i < newMidLen; i++) {
20102
+ const key = newKeys[i];
20103
+ let block;
20104
+ if (sources[i] === -1) {
20105
+ if (nextSurvivor <= i) {
20106
+ nextSurvivor = i + 1;
20107
+ while (nextSurvivor < newMidLen && sources[nextSurvivor] === -1) nextSurvivor++;
19153
20108
  }
19154
- block.nextSibling = nextBlock;
19155
- if (nextBlock) nextBlock.prevSibling = block;
19156
- if (lastPlaced === null) lastPlaced = block;
19157
- nextBlock = block;
19158
- }
20109
+ const anchor = nextSurvivor < newMidLen ? oldItems.get(newKeys[nextSurvivor]).startMarker : middleEndAnchor;
20110
+ const targetIdx = i + prefixLen;
20111
+ block = mountItem(
20112
+ parentBlock,
20113
+ parentNode,
20114
+ anchor,
20115
+ items[targetIdx],
20116
+ targetIdx,
20117
+ itemBody,
20118
+ state,
20119
+ singleRoot,
20120
+ ssrMarkerless
20121
+ );
20122
+ oldItems.set(key, block);
20123
+ block.key = key;
20124
+ state.size++;
20125
+ } else block = oldItems.get(key);
20126
+ block.prevSibling = previous;
20127
+ if (previous) previous.nextSibling = block;
20128
+ else state.head = block;
20129
+ previous = block;
19159
20130
  }
19160
- const newMiddleHead = nextBlock;
19161
- const newMiddleTail = lastPlaced;
19162
- newMiddleHead.prevSibling = beforeMiddle;
19163
- if (beforeMiddle) beforeMiddle.nextSibling = newMiddleHead;
19164
- else state.head = newMiddleHead;
19165
- if (!afterMiddle) state.tail = newMiddleTail;
20131
+ previous.nextSibling = afterMiddle;
20132
+ if (afterMiddle) afterMiddle.prevSibling = previous;
20133
+ else state.tail = previous;
19166
20134
  } finally {
19167
20135
  if (sources.length <= MAX_KEYED_REORDER_SCRATCH && (keyedReorderSources === null || keyedReorderSources.length < sources.length)) {
19168
20136
  keyedReorderSources = sources;
@@ -19868,8 +20836,19 @@ let ROOT_CONTAINER_OWNERS = null;
19868
20836
  const ROOT_RENDERABLE_BODY = ((value) => value === void 0 ? null : value);
19869
20837
  const EMPTY_ROOT_BODY = (() => void 0);
19870
20838
  function assertValidRootContainer(container) {
19871
- if (container === null || typeof container !== "object" || container.nodeType !== 1) {
19872
- throw new Error((0, import_error_codes_client_generated.formatClientError)(28));
20839
+ if (container === null || typeof container !== "object" || container.nodeType !== 1 && container.nodeType !== 9 && container.nodeType !== 11) {
20840
+ throw new Error((0, import_error_codes_client_generated.formatClientError)(63));
20841
+ }
20842
+ }
20843
+ function clearRootContainer(container) {
20844
+ if (container.nodeType !== 9) {
20845
+ container.textContent = "";
20846
+ return;
20847
+ }
20848
+ for (let child2 = container.firstChild; child2 !== null; ) {
20849
+ const next = child2.nextSibling;
20850
+ if (child2.nodeType !== 10) container.removeChild(child2);
20851
+ child2 = next;
19873
20852
  }
19874
20853
  }
19875
20854
  function claimRootContainer(container) {
@@ -19978,17 +20957,19 @@ function devHtmlNesting(childTag, ancestors, childLocation, ancestorLocation) {
19978
20957
  }
19979
20958
  function validateRootHtmlNesting(container, body) {
19980
20959
  if (process.env.NODE_ENV !== "production") {
19981
- 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("-")) {
20960
+ if (container.nodeType !== 1) return;
20961
+ const element = container;
20962
+ 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("-")) {
19982
20963
  return;
19983
20964
  }
19984
20965
  const root = container.firstElementChild;
19985
20966
  if (root === null) return;
19986
- if ((0, import_html_tree_validation.invalidHtmlNestingWithParent)(root.localName, container.localName) !== null) {
19987
- devHtmlNesting(root.localName, [container.localName]);
20967
+ if ((0, import_html_tree_validation.invalidHtmlNestingWithParent)(root.localName, element.localName) !== null) {
20968
+ devHtmlNesting(root.localName, [element.localName]);
19988
20969
  return;
19989
20970
  }
19990
20971
  let child2 = root.firstElementChild;
19991
- const ancestors = [root.localName, container.localName];
20972
+ const ancestors = [root.localName, element.localName];
19992
20973
  while (child2 !== null && child2.namespaceURI === "http://www.w3.org/1999/xhtml") {
19993
20974
  if ((0, import_html_tree_validation.invalidHtmlNestingWithAncestor)(child2.localName, ancestors) !== null) {
19994
20975
  devHtmlNesting(child2.localName, ancestors);
@@ -20053,7 +21034,7 @@ function makeRoot(container, rootBlock, currentBody, currentKey, idState, output
20053
21034
  const previousRoot = rootBlock;
20054
21035
  const previousBody = currentBody;
20055
21036
  const previousKey = currentKey;
20056
- const staged = previousRoot !== null && previousRoot.mounted && !previousRoot.disposed && !renderOwner.transaction.created?.has(previousRoot);
21037
+ const staged = container.nodeType !== 9 && previousRoot !== null && previousRoot.mounted && !previousRoot.disposed && !renderOwner.transaction.created?.has(previousRoot);
20057
21038
  const oldFirst = staged ? container.firstChild : null;
20058
21039
  const oldLast = staged ? container.lastChild : null;
20059
21040
  journalUndo(() => {
@@ -20078,7 +21059,7 @@ function makeRoot(container, rootBlock, currentBody, currentKey, idState, output
20078
21059
  end = document.createComment("/root");
20079
21060
  container.append(start, end);
20080
21061
  } else {
20081
- while (container.firstChild) container.removeChild(container.firstChild);
21062
+ clearRootContainer(container);
20082
21063
  }
20083
21064
  rootBlock = createBlock(
20084
21065
  "root",
@@ -20121,6 +21102,7 @@ function makeRoot(container, rootBlock, currentBody, currentKey, idState, output
20121
21102
  mountedRoot.pendingMode = mode ?? null;
20122
21103
  try {
20123
21104
  renderBlock(mountedRoot);
21105
+ if (QUEUE.length > 0) drainHydrationRenderPhaseUpdates(mountedRoot);
20124
21106
  if (process.env.NODE_ENV !== "production") {
20125
21107
  validateRootHtmlNesting(container, body);
20126
21108
  }
@@ -20239,7 +21221,8 @@ function makeRoot(container, rootBlock, currentBody, currentKey, idState, output
20239
21221
  false
20240
21222
  );
20241
21223
  drainRefDetaches();
20242
- container.textContent = "";
21224
+ clearRootContainer(container);
21225
+ drainDeferredPassiveUnmounts();
20243
21226
  rootBlock = null;
20244
21227
  currentBody = null;
20245
21228
  currentKey = null;
@@ -20398,7 +21381,7 @@ function hydrateRoot(container, bodyOrElement, propsOrOptions, rootOptions) {
20398
21381
  journalRootProperty(idState, "next");
20399
21382
  idState.next = 0;
20400
21383
  let firstNode = container.firstChild;
20401
- while (firstNode !== null && isRendererHydrationStyle(firstNode))
21384
+ while (firstNode !== null && (firstNode.nodeType === 10 || isRendererHydrationStyle(firstNode)))
20402
21385
  firstNode = firstNode.nextSibling;
20403
21386
  const hydration = new HydrationCapability(rootBlock, firstNode, seeds);
20404
21387
  if (nativeManifest !== void 0)
@@ -20431,7 +21414,7 @@ function hydrateRoot(container, bodyOrElement, propsOrOptions, rootOptions) {
20431
21414
  } catch (unhandled) {
20432
21415
  rollbackRootRender(owner.transaction);
20433
21416
  unmountBlock(rootBlock, false);
20434
- container.textContent = "";
21417
+ clearRootContainer(container);
20435
21418
  if (!reportUncaughtError(rootBlock, unhandled)) throw unhandled;
20436
21419
  return;
20437
21420
  }
@@ -20926,15 +21909,18 @@ function scriptResource(attrs) {
20926
21909
  hydrateRoot,
20927
21910
  ifBlock,
20928
21911
  injectStyle,
21912
+ invokeManualHook,
20929
21913
  isChildrenBlock,
20930
21914
  isValidElement,
20931
21915
  keyedForBlock,
20932
21916
  lazy,
21917
+ manualHook,
20933
21918
  mapSlot,
20934
21919
  markChildrenBlock,
20935
21920
  markDangerouslySetInnerHTMLChildren,
20936
21921
  markNativeChangeDiagnosticStatic,
20937
21922
  markSingleRoot,
21923
+ markWarm,
20938
21924
  memo,
20939
21925
  memoPublish,
20940
21926
  memoPublishAlways,