@nswds/app 1.113.1 → 1.114.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -18835,7 +18835,7 @@ function FormatToggle({ format, setFormat }) {
18835
18835
 
18836
18836
  // package.json
18837
18837
  var package_default = {
18838
- version: "1.112.2"};
18838
+ version: "1.113.1"};
18839
18839
  var SluggerContext = React5__namespace.default.createContext(null);
18840
18840
  function flattenText(nodes) {
18841
18841
  if (nodes == null || typeof nodes === "boolean") return "";
@@ -21163,7 +21163,7 @@ var backIn = /* @__PURE__ */ reverseEasing(backOut);
21163
21163
  var backInOut = /* @__PURE__ */ mirrorEasing(backIn);
21164
21164
 
21165
21165
  // node_modules/motion-utils/dist/es/easing/anticipate.mjs
21166
- var anticipate = (p) => (p *= 2) < 1 ? 0.5 * backIn(p) : 0.5 * (2 - Math.pow(2, -10 * (p - 1)));
21166
+ var anticipate = (p) => p >= 1 ? 1 : (p *= 2) < 1 ? 0.5 * backIn(p) : 0.5 * (2 - Math.pow(2, -10 * (p - 1)));
21167
21167
 
21168
21168
  // node_modules/motion-utils/dist/es/easing/circ.mjs
21169
21169
  var circIn = (p) => 1 - Math.sin(Math.acos(p));
@@ -21260,8 +21260,7 @@ function createRenderStep(runNextFrame, stepName) {
21260
21260
  const queue = addToCurrentFrame ? thisFrame : nextFrame;
21261
21261
  if (keepAlive)
21262
21262
  toKeepAlive.add(callback);
21263
- if (!queue.has(callback))
21264
- queue.add(callback);
21263
+ queue.add(callback);
21265
21264
  return callback;
21266
21265
  },
21267
21266
  /**
@@ -21281,7 +21280,9 @@ function createRenderStep(runNextFrame, stepName) {
21281
21280
  return;
21282
21281
  }
21283
21282
  isProcessing = true;
21284
- [thisFrame, nextFrame] = [nextFrame, thisFrame];
21283
+ const prevFrame = thisFrame;
21284
+ thisFrame = nextFrame;
21285
+ nextFrame = prevFrame;
21285
21286
  thisFrame.forEach(triggerCallback);
21286
21287
  thisFrame.clear();
21287
21288
  isProcessing = false;
@@ -21311,9 +21312,10 @@ function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
21311
21312
  }, {});
21312
21313
  const { setup, read, resolveKeyframes, preUpdate, update, preRender, render, postRender } = steps;
21313
21314
  const processBatch = () => {
21314
- const timestamp = MotionGlobalConfig.useManualTiming ? state.timestamp : performance.now();
21315
+ const useManualTiming = MotionGlobalConfig.useManualTiming;
21316
+ const timestamp = useManualTiming ? state.timestamp : performance.now();
21315
21317
  runNextFrame = false;
21316
- if (!MotionGlobalConfig.useManualTiming) {
21318
+ if (!useManualTiming) {
21317
21319
  state.delta = useDefaultElapsed ? 1e3 / 60 : Math.max(Math.min(timestamp - state.timestamp, maxElapsed), 1);
21318
21320
  }
21319
21321
  state.timestamp = timestamp;
@@ -21579,8 +21581,7 @@ function analyseComplexValue(value) {
21579
21581
  function parseComplexValue(v) {
21580
21582
  return analyseComplexValue(v).values;
21581
21583
  }
21582
- function createTransformer(source) {
21583
- const { split, types } = analyseComplexValue(source);
21584
+ function buildTransformer({ split, types }) {
21584
21585
  const numSections = split.length;
21585
21586
  return (v) => {
21586
21587
  let output = "";
@@ -21600,11 +21601,20 @@ function createTransformer(source) {
21600
21601
  return output;
21601
21602
  };
21602
21603
  }
21604
+ function createTransformer(source) {
21605
+ return buildTransformer(analyseComplexValue(source));
21606
+ }
21603
21607
  var convertNumbersToZero = (v) => typeof v === "number" ? 0 : color.test(v) ? color.getAnimatableNone(v) : v;
21608
+ var convertToZero = (value, splitBefore) => {
21609
+ if (typeof value === "number") {
21610
+ return splitBefore?.trim().endsWith("/") ? value : 0;
21611
+ }
21612
+ return convertNumbersToZero(value);
21613
+ };
21604
21614
  function getAnimatableNone(v) {
21605
- const parsed = parseComplexValue(v);
21606
- const transformer = createTransformer(v);
21607
- return transformer(parsed.map(convertNumbersToZero));
21615
+ const info = analyseComplexValue(v);
21616
+ const transformer = buildTransformer(info);
21617
+ return transformer(info.values.map((value, i) => convertToZero(value, info.split[i])));
21608
21618
  }
21609
21619
  var complex = {
21610
21620
  test,
@@ -21835,14 +21845,7 @@ function createGeneratorEasing(options, scale2 = 100, createGenerator) {
21835
21845
  };
21836
21846
  }
21837
21847
 
21838
- // node_modules/motion-dom/dist/es/animation/generators/utils/velocity.mjs
21839
- var velocitySampleDuration = 5;
21840
- function calcGeneratorVelocity(resolveValue, t, current) {
21841
- const prevT = Math.max(t - velocitySampleDuration, 0);
21842
- return velocityPerSecond(current - resolveValue(prevT), t - prevT);
21843
- }
21844
-
21845
- // node_modules/motion-dom/dist/es/animation/generators/spring/defaults.mjs
21848
+ // node_modules/motion-dom/dist/es/animation/generators/spring.mjs
21846
21849
  var springDefaults = {
21847
21850
  // Default spring physics
21848
21851
  stiffness: 100,
@@ -21872,8 +21875,17 @@ var springDefaults = {
21872
21875
  minDamping: 0.05,
21873
21876
  maxDamping: 1
21874
21877
  };
21875
-
21876
- // node_modules/motion-dom/dist/es/animation/generators/spring/find.mjs
21878
+ function calcAngularFreq(undampedFreq, dampingRatio) {
21879
+ return undampedFreq * Math.sqrt(1 - dampingRatio * dampingRatio);
21880
+ }
21881
+ var rootIterations = 12;
21882
+ function approximateRoot(envelope, derivative, initialGuess) {
21883
+ let result = initialGuess;
21884
+ for (let i = 1; i < rootIterations; i++) {
21885
+ result = result - envelope(result) / derivative(result);
21886
+ }
21887
+ return result;
21888
+ }
21877
21889
  var safeMin = 1e-3;
21878
21890
  function findSpring({ duration = springDefaults.duration, bounce = springDefaults.bounce, velocity = springDefaults.velocity, mass = springDefaults.mass }) {
21879
21891
  let envelope;
@@ -21931,19 +21943,6 @@ function findSpring({ duration = springDefaults.duration, bounce = springDefault
21931
21943
  };
21932
21944
  }
21933
21945
  }
21934
- var rootIterations = 12;
21935
- function approximateRoot(envelope, derivative, initialGuess) {
21936
- let result = initialGuess;
21937
- for (let i = 1; i < rootIterations; i++) {
21938
- result = result - envelope(result) / derivative(result);
21939
- }
21940
- return result;
21941
- }
21942
- function calcAngularFreq(undampedFreq, dampingRatio) {
21943
- return undampedFreq * Math.sqrt(1 - dampingRatio * dampingRatio);
21944
- }
21945
-
21946
- // node_modules/motion-dom/dist/es/animation/generators/spring/index.mjs
21947
21946
  var durationKeys = ["duration", "bounce"];
21948
21947
  var physicsKeys = ["stiffness", "damping", "mass"];
21949
21948
  function isSpringType(options, keys) {
@@ -21959,6 +21958,7 @@ function getSpringOptions(options) {
21959
21958
  ...options
21960
21959
  };
21961
21960
  if (!isSpringType(options, physicsKeys) && isSpringType(options, durationKeys)) {
21961
+ springOptions.velocity = 0;
21962
21962
  if (options.visualDuration) {
21963
21963
  const visualDuration = options.visualDuration;
21964
21964
  const root = 2 * Math.PI / (visualDuration * 1.2);
@@ -21971,7 +21971,7 @@ function getSpringOptions(options) {
21971
21971
  damping
21972
21972
  };
21973
21973
  } else {
21974
- const derived = findSpring(options);
21974
+ const derived = findSpring({ ...options, velocity: 0 });
21975
21975
  springOptions = {
21976
21976
  ...springOptions,
21977
21977
  ...derived,
@@ -22004,14 +22004,28 @@ function spring(optionsOrVisualDuration = springDefaults.visualDuration, bounce
22004
22004
  restSpeed || (restSpeed = isGranularScale ? springDefaults.restSpeed.granular : springDefaults.restSpeed.default);
22005
22005
  restDelta || (restDelta = isGranularScale ? springDefaults.restDelta.granular : springDefaults.restDelta.default);
22006
22006
  let resolveSpring;
22007
+ let resolveVelocity;
22008
+ let angularFreq;
22009
+ let A;
22010
+ let sinCoeff;
22011
+ let cosCoeff;
22007
22012
  if (dampingRatio < 1) {
22008
- const angularFreq = calcAngularFreq(undampedAngularFreq, dampingRatio);
22013
+ angularFreq = calcAngularFreq(undampedAngularFreq, dampingRatio);
22014
+ A = (initialVelocity + dampingRatio * undampedAngularFreq * initialDelta) / angularFreq;
22009
22015
  resolveSpring = (t) => {
22010
22016
  const envelope = Math.exp(-dampingRatio * undampedAngularFreq * t);
22011
- return target - envelope * ((initialVelocity + dampingRatio * undampedAngularFreq * initialDelta) / angularFreq * Math.sin(angularFreq * t) + initialDelta * Math.cos(angularFreq * t));
22017
+ return target - envelope * (A * Math.sin(angularFreq * t) + initialDelta * Math.cos(angularFreq * t));
22018
+ };
22019
+ sinCoeff = dampingRatio * undampedAngularFreq * A + initialDelta * angularFreq;
22020
+ cosCoeff = dampingRatio * undampedAngularFreq * initialDelta - A * angularFreq;
22021
+ resolveVelocity = (t) => {
22022
+ const envelope = Math.exp(-dampingRatio * undampedAngularFreq * t);
22023
+ return envelope * (sinCoeff * Math.sin(angularFreq * t) + cosCoeff * Math.cos(angularFreq * t));
22012
22024
  };
22013
22025
  } else if (dampingRatio === 1) {
22014
22026
  resolveSpring = (t) => target - Math.exp(-undampedAngularFreq * t) * (initialDelta + (initialVelocity + undampedAngularFreq * initialDelta) * t);
22027
+ const C = initialVelocity + undampedAngularFreq * initialDelta;
22028
+ resolveVelocity = (t) => Math.exp(-undampedAngularFreq * t) * (undampedAngularFreq * C * t - initialVelocity);
22015
22029
  } else {
22016
22030
  const dampedAngularFreq = undampedAngularFreq * Math.sqrt(dampingRatio * dampingRatio - 1);
22017
22031
  resolveSpring = (t) => {
@@ -22019,19 +22033,33 @@ function spring(optionsOrVisualDuration = springDefaults.visualDuration, bounce
22019
22033
  const freqForT = Math.min(dampedAngularFreq * t, 300);
22020
22034
  return target - envelope * ((initialVelocity + dampingRatio * undampedAngularFreq * initialDelta) * Math.sinh(freqForT) + dampedAngularFreq * initialDelta * Math.cosh(freqForT)) / dampedAngularFreq;
22021
22035
  };
22036
+ const P = (initialVelocity + dampingRatio * undampedAngularFreq * initialDelta) / dampedAngularFreq;
22037
+ const sinhCoeff = dampingRatio * undampedAngularFreq * P - initialDelta * dampedAngularFreq;
22038
+ const coshCoeff = dampingRatio * undampedAngularFreq * initialDelta - P * dampedAngularFreq;
22039
+ resolveVelocity = (t) => {
22040
+ const envelope = Math.exp(-dampingRatio * undampedAngularFreq * t);
22041
+ const freqForT = Math.min(dampedAngularFreq * t, 300);
22042
+ return envelope * (sinhCoeff * Math.sinh(freqForT) + coshCoeff * Math.cosh(freqForT));
22043
+ };
22022
22044
  }
22023
22045
  const generator = {
22024
22046
  calculatedDuration: isResolvedFromDuration ? duration || null : null,
22047
+ velocity: (t) => secondsToMilliseconds(resolveVelocity(t)),
22025
22048
  next: (t) => {
22049
+ if (!isResolvedFromDuration && dampingRatio < 1) {
22050
+ const envelope = Math.exp(-dampingRatio * undampedAngularFreq * t);
22051
+ const sin = Math.sin(angularFreq * t);
22052
+ const cos = Math.cos(angularFreq * t);
22053
+ const current2 = target - envelope * (A * sin + initialDelta * cos);
22054
+ const currentVelocity = secondsToMilliseconds(envelope * (sinCoeff * sin + cosCoeff * cos));
22055
+ state.done = Math.abs(currentVelocity) <= restSpeed && Math.abs(target - current2) <= restDelta;
22056
+ state.value = state.done ? target : current2;
22057
+ return state;
22058
+ }
22026
22059
  const current = resolveSpring(t);
22027
22060
  if (!isResolvedFromDuration) {
22028
- let currentVelocity = t === 0 ? initialVelocity : 0;
22029
- if (dampingRatio < 1) {
22030
- currentVelocity = t === 0 ? secondsToMilliseconds(initialVelocity) : calcGeneratorVelocity(resolveSpring, t, current);
22031
- }
22032
- const isBelowVelocityThreshold = Math.abs(currentVelocity) <= restSpeed;
22033
- const isBelowDisplacementThreshold = Math.abs(target - current) <= restDelta;
22034
- state.done = isBelowVelocityThreshold && isBelowDisplacementThreshold;
22061
+ const currentVelocity = secondsToMilliseconds(resolveVelocity(t));
22062
+ state.done = Math.abs(currentVelocity) <= restSpeed && Math.abs(target - current) <= restDelta;
22035
22063
  } else {
22036
22064
  state.done = t >= duration;
22037
22065
  }
@@ -22056,6 +22084,13 @@ spring.applyToOptions = (options) => {
22056
22084
  return options;
22057
22085
  };
22058
22086
 
22087
+ // node_modules/motion-dom/dist/es/animation/generators/utils/velocity.mjs
22088
+ var velocitySampleDuration = 5;
22089
+ function getGeneratorVelocity(resolveValue, t, current) {
22090
+ const prevT = Math.max(t - velocitySampleDuration, 0);
22091
+ return velocityPerSecond(current - resolveValue(prevT), t - prevT);
22092
+ }
22093
+
22059
22094
  // node_modules/motion-dom/dist/es/animation/generators/inertia.mjs
22060
22095
  function inertia({ keyframes: keyframes2, velocity = 0, power = 0.8, timeConstant = 325, bounceDamping = 10, bounceStiffness = 500, modifyTarget, min, max, restDelta = 0.5, restSpeed }) {
22061
22096
  const origin = keyframes2[0];
@@ -22092,7 +22127,7 @@ function inertia({ keyframes: keyframes2, velocity = 0, power = 0.8, timeConstan
22092
22127
  timeReachedBoundary = t;
22093
22128
  spring$1 = spring({
22094
22129
  keyframes: [state.value, nearestBoundary(state.value)],
22095
- velocity: calcGeneratorVelocity(calcLatest, t, state.value),
22130
+ velocity: getGeneratorVelocity(calcLatest, t, state.value),
22096
22131
  // TODO: This should be passing * 1000
22097
22132
  damping: bounceDamping,
22098
22133
  stiffness: bounceStiffness,
@@ -22275,6 +22310,10 @@ var JSAnimation = class extends WithPromise {
22275
22310
  this.currentTime = 0;
22276
22311
  this.holdTime = null;
22277
22312
  this.playbackSpeed = 1;
22313
+ this.delayState = {
22314
+ done: false,
22315
+ value: void 0
22316
+ };
22278
22317
  this.stop = () => {
22279
22318
  const { motionValue: motionValue2 } = this.options;
22280
22319
  if (motionValue2 && motionValue2.updatedAt !== time.now()) {
@@ -22375,8 +22414,14 @@ var JSAnimation = class extends WithPromise {
22375
22414
  }
22376
22415
  elapsed = clamp(0, 1, iterationProgress) * resolvedDuration;
22377
22416
  }
22378
- const state = isInDelayPhase ? { done: false, value: keyframes2[0] } : frameGenerator.next(elapsed);
22379
- if (mixKeyframes) {
22417
+ let state;
22418
+ if (isInDelayPhase) {
22419
+ this.delayState.value = keyframes2[0];
22420
+ state = this.delayState;
22421
+ } else {
22422
+ state = frameGenerator.next(elapsed);
22423
+ }
22424
+ if (mixKeyframes && !isInDelayPhase) {
22380
22425
  state.value = mixKeyframes(state.value);
22381
22426
  }
22382
22427
  let { done } = state;
@@ -22421,16 +22466,40 @@ var JSAnimation = class extends WithPromise {
22421
22466
  } else if (this.driver) {
22422
22467
  this.startTime = this.driver.now() - newTime / this.playbackSpeed;
22423
22468
  }
22424
- this.driver?.start(false);
22469
+ if (this.driver) {
22470
+ this.driver.start(false);
22471
+ } else {
22472
+ this.startTime = 0;
22473
+ this.state = "paused";
22474
+ this.holdTime = newTime;
22475
+ this.tick(newTime);
22476
+ }
22477
+ }
22478
+ /**
22479
+ * Returns the generator's velocity at the current time in units/second.
22480
+ * Uses the analytical derivative when available (springs), avoiding
22481
+ * the MotionValue's frame-dependent velocity estimation.
22482
+ */
22483
+ getGeneratorVelocity() {
22484
+ const t = this.currentTime;
22485
+ if (t <= 0)
22486
+ return this.options.velocity || 0;
22487
+ if (this.generator.velocity) {
22488
+ return this.generator.velocity(t);
22489
+ }
22490
+ const current = this.generator.next(t).value;
22491
+ return getGeneratorVelocity((s) => this.generator.next(s).value, t, current);
22425
22492
  }
22426
22493
  get speed() {
22427
22494
  return this.playbackSpeed;
22428
22495
  }
22429
22496
  set speed(newSpeed) {
22430
- this.updateTime(time.now());
22431
22497
  const hasChanged = this.playbackSpeed !== newSpeed;
22498
+ if (hasChanged && this.driver) {
22499
+ this.updateTime(time.now());
22500
+ }
22432
22501
  this.playbackSpeed = newSpeed;
22433
- if (hasChanged) {
22502
+ if (hasChanged && this.driver) {
22434
22503
  this.time = millisecondsToSeconds(this.currentTime);
22435
22504
  }
22436
22505
  }
@@ -22635,8 +22704,14 @@ function removeNonTranslationalTransform(visualElement) {
22635
22704
  }
22636
22705
  var positionalValues = {
22637
22706
  // Dimensions
22638
- width: ({ x }, { paddingLeft = "0", paddingRight = "0" }) => x.max - x.min - parseFloat(paddingLeft) - parseFloat(paddingRight),
22639
- height: ({ y }, { paddingTop = "0", paddingBottom = "0" }) => y.max - y.min - parseFloat(paddingTop) - parseFloat(paddingBottom),
22707
+ width: ({ x }, { paddingLeft = "0", paddingRight = "0", boxSizing }) => {
22708
+ const width = x.max - x.min;
22709
+ return boxSizing === "border-box" ? width : width - parseFloat(paddingLeft) - parseFloat(paddingRight);
22710
+ },
22711
+ height: ({ y }, { paddingTop = "0", paddingBottom = "0", boxSizing }) => {
22712
+ const height = y.max - y.min;
22713
+ return boxSizing === "border-box" ? height : height - parseFloat(paddingTop) - parseFloat(paddingBottom);
22714
+ },
22640
22715
  top: (_bbox, { top }) => parseFloat(top),
22641
22716
  left: (_bbox, { left }) => parseFloat(left),
22642
22717
  bottom: ({ y }, { top }) => parseFloat(top) + (y.max - y.min),
@@ -22782,9 +22857,6 @@ function setStyle(element, name, value) {
22782
22857
  isCSSVar(name) ? element.style.setProperty(name, value) : element.style[name] = value;
22783
22858
  }
22784
22859
 
22785
- // node_modules/motion-dom/dist/es/utils/supports/scroll-timeline.mjs
22786
- var supportsScrollTimeline = /* @__PURE__ */ memo(() => window.ScrollTimeline !== void 0);
22787
-
22788
22860
  // node_modules/motion-dom/dist/es/utils/supports/flags.mjs
22789
22861
  var supportsFlags = {};
22790
22862
 
@@ -22794,6 +22866,9 @@ function memoSupports(callback, supportsFlag) {
22794
22866
  return () => supportsFlags[supportsFlag] ?? memoized();
22795
22867
  }
22796
22868
 
22869
+ // node_modules/motion-dom/dist/es/utils/supports/scroll-timeline.mjs
22870
+ var supportsScrollTimeline = /* @__PURE__ */ memoSupports(() => window.ScrollTimeline !== void 0, "scrollTimeline");
22871
+
22797
22872
  // node_modules/motion-dom/dist/es/utils/supports/linear-easing.mjs
22798
22873
  var supportsLinearEasing = /* @__PURE__ */ memoSupports(() => {
22799
22874
  try {
@@ -22900,9 +22975,8 @@ var NativeAnimation = class extends WithPromise {
22900
22975
  const keyframe = getFinalKeyframe(keyframes2, this.options, finalKeyframe, this.speed);
22901
22976
  if (this.updateMotionValue) {
22902
22977
  this.updateMotionValue(keyframe);
22903
- } else {
22904
- setStyle(element, name, keyframe);
22905
22978
  }
22979
+ setStyle(element, name, keyframe);
22906
22980
  this.animation.cancel();
22907
22981
  }
22908
22982
  onComplete?.();
@@ -22976,9 +23050,13 @@ var NativeAnimation = class extends WithPromise {
22976
23050
  return millisecondsToSeconds(Number(this.animation.currentTime) || 0);
22977
23051
  }
22978
23052
  set time(newTime) {
23053
+ const wasFinished = this.finishedTime !== null;
22979
23054
  this.manualStartTime = null;
22980
23055
  this.finishedTime = null;
22981
23056
  this.animation.currentTime = secondsToMilliseconds(newTime);
23057
+ if (wasFinished) {
23058
+ this.animation.pause();
23059
+ }
22982
23060
  }
22983
23061
  /**
22984
23062
  * The playback speed of the animation.
@@ -23004,13 +23082,17 @@ var NativeAnimation = class extends WithPromise {
23004
23082
  /**
23005
23083
  * Attaches a timeline to the animation, for instance the `ScrollTimeline`.
23006
23084
  */
23007
- attachTimeline({ timeline, observe }) {
23085
+ attachTimeline({ timeline, rangeStart, rangeEnd, observe }) {
23008
23086
  if (this.allowFlatten) {
23009
23087
  this.animation.effect?.updateTiming({ easing: "linear" });
23010
23088
  }
23011
23089
  this.animation.onfinish = null;
23012
23090
  if (timeline && supportsScrollTimeline()) {
23013
23091
  this.animation.timeline = timeline;
23092
+ if (rangeStart)
23093
+ this.animation.rangeStart = rangeStart;
23094
+ if (rangeEnd)
23095
+ this.animation.rangeEnd = rangeEnd;
23014
23096
  return noop;
23015
23097
  } else {
23016
23098
  return observe(this);
@@ -23040,7 +23122,7 @@ var NativeAnimationExtended = class extends NativeAnimation {
23040
23122
  replaceStringEasing(options);
23041
23123
  replaceTransitionType(options);
23042
23124
  super(options);
23043
- if (options.startTime !== void 0) {
23125
+ if (options.startTime !== void 0 && options.autoplay !== false) {
23044
23126
  this.startTime = options.startTime;
23045
23127
  }
23046
23128
  this.options = options;
@@ -23067,7 +23149,11 @@ var NativeAnimationExtended = class extends NativeAnimation {
23067
23149
  });
23068
23150
  const sampleTime = Math.max(sampleDelta, time.now() - this.startTime);
23069
23151
  const delta = clamp(0, sampleDelta, sampleTime - sampleDelta);
23070
- motionValue2.setWithVelocity(sampleAnimation.sample(Math.max(0, sampleTime - delta)).value, sampleAnimation.sample(sampleTime).value, delta);
23152
+ const current = sampleAnimation.sample(sampleTime).value;
23153
+ const { name } = this.options;
23154
+ if (element && name)
23155
+ setStyle(element, name, current);
23156
+ motionValue2.setWithVelocity(sampleAnimation.sample(Math.max(0, sampleTime - delta)).value, current, delta);
23071
23157
  sampleAnimation.stop();
23072
23158
  }
23073
23159
  };
@@ -23119,24 +23205,54 @@ function makeAnimationInstant(options) {
23119
23205
  options.type = "keyframes";
23120
23206
  }
23121
23207
 
23122
- // node_modules/motion-dom/dist/es/animation/waapi/supports/waapi.mjs
23208
+ // node_modules/motion-dom/dist/es/animation/waapi/utils/accelerated-values.mjs
23123
23209
  var acceleratedValues = /* @__PURE__ */ new Set([
23124
23210
  "opacity",
23125
23211
  "clipPath",
23126
23212
  "filter",
23127
23213
  "transform"
23128
- // TODO: Could be re-enabled now we have support for linear() easing
23214
+ // TODO: Can be accelerated but currently disabled until https://issues.chromium.org/issues/41491098 is resolved
23215
+ // or until we implement support for linear() easing.
23129
23216
  // "background-color"
23130
23217
  ]);
23218
+
23219
+ // node_modules/motion-dom/dist/es/animation/waapi/utils/is-browser-color.mjs
23220
+ var browserColorFunctions = /^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;
23221
+ function hasBrowserOnlyColors(keyframes2) {
23222
+ for (let i = 0; i < keyframes2.length; i++) {
23223
+ if (typeof keyframes2[i] === "string" && browserColorFunctions.test(keyframes2[i])) {
23224
+ return true;
23225
+ }
23226
+ }
23227
+ return false;
23228
+ }
23229
+
23230
+ // node_modules/motion-dom/dist/es/animation/waapi/supports/waapi.mjs
23231
+ var colorProperties = /* @__PURE__ */ new Set([
23232
+ "color",
23233
+ "backgroundColor",
23234
+ "outlineColor",
23235
+ "fill",
23236
+ "stroke",
23237
+ "borderColor",
23238
+ "borderTopColor",
23239
+ "borderRightColor",
23240
+ "borderBottomColor",
23241
+ "borderLeftColor"
23242
+ ]);
23131
23243
  var supportsWaapi = /* @__PURE__ */ memo(() => Object.hasOwnProperty.call(Element.prototype, "animate"));
23132
23244
  function supportsBrowserAnimation(options) {
23133
- const { motionValue: motionValue2, name, repeatDelay, repeatType, damping, type } = options;
23245
+ const { motionValue: motionValue2, name, repeatDelay, repeatType, damping, type, keyframes: keyframes2 } = options;
23134
23246
  const subject = motionValue2?.owner?.current;
23135
23247
  if (!(subject instanceof HTMLElement)) {
23136
23248
  return false;
23137
23249
  }
23138
23250
  const { onUpdate, transformTemplate } = motionValue2.owner.getProps();
23139
- return supportsWaapi() && name && acceleratedValues.has(name) && (name !== "transform" || !transformTemplate) && /**
23251
+ return supportsWaapi() && name && /**
23252
+ * Force WAAPI for color properties with browser-only color formats
23253
+ * (oklch, oklab, lab, lch, etc.) that the JS animation path can't parse.
23254
+ */
23255
+ (acceleratedValues.has(name) || colorProperties.has(name) && hasBrowserOnlyColors(keyframes2)) && (name !== "transform" || !transformTemplate) && /**
23140
23256
  * If we're outputting values to onUpdate then we can't use WAAPI as there's
23141
23257
  * no way to read the value from WAAPI every frame.
23142
23258
  */
@@ -23176,7 +23292,9 @@ var AsyncMotionValueAnimation = class extends WithPromise {
23176
23292
  this.keyframeResolver = void 0;
23177
23293
  const { name, type, velocity, delay: delay2, isHandoff, onUpdate } = options;
23178
23294
  this.resolvedAt = time.now();
23295
+ let canAnimateValue = true;
23179
23296
  if (!canAnimate(keyframes2, name, type, velocity)) {
23297
+ canAnimateValue = false;
23180
23298
  if (MotionGlobalConfig.instantAnimations || !delay2) {
23181
23299
  onUpdate?.(getFinalKeyframe(keyframes2, options, finalKeyframe));
23182
23300
  }
@@ -23191,12 +23309,21 @@ var AsyncMotionValueAnimation = class extends WithPromise {
23191
23309
  ...options,
23192
23310
  keyframes: keyframes2
23193
23311
  };
23194
- const useWaapi = !isHandoff && supportsBrowserAnimation(resolvedOptions);
23312
+ const useWaapi = canAnimateValue && !isHandoff && supportsBrowserAnimation(resolvedOptions);
23195
23313
  const element = resolvedOptions.motionValue?.owner?.current;
23196
- const animation = useWaapi ? new NativeAnimationExtended({
23197
- ...resolvedOptions,
23198
- element
23199
- }) : new JSAnimation(resolvedOptions);
23314
+ let animation;
23315
+ if (useWaapi) {
23316
+ try {
23317
+ animation = new NativeAnimationExtended({
23318
+ ...resolvedOptions,
23319
+ element
23320
+ });
23321
+ } catch {
23322
+ animation = new JSAnimation(resolvedOptions);
23323
+ }
23324
+ } else {
23325
+ animation = new JSAnimation(resolvedOptions);
23326
+ }
23200
23327
  animation.finished.then(() => {
23201
23328
  this.notifyFinished();
23202
23329
  }).catch(noop);
@@ -23339,22 +23466,43 @@ var getDefaultTransition = (valueKey, { keyframes: keyframes2 }) => {
23339
23466
  return ease;
23340
23467
  };
23341
23468
 
23342
- // node_modules/motion-dom/dist/es/animation/utils/get-final-keyframe.mjs
23343
- var isNotNull2 = (value) => value !== null;
23344
- function getFinalKeyframe2(keyframes2, { repeat, repeatType = "loop" }, finalKeyframe) {
23345
- const resolvedKeyframes = keyframes2.filter(isNotNull2);
23346
- const index = repeat && repeatType !== "loop" && repeat % 2 === 1 ? 0 : resolvedKeyframes.length - 1;
23347
- return !index || finalKeyframe === void 0 ? resolvedKeyframes[index] : finalKeyframe;
23469
+ // node_modules/motion-dom/dist/es/animation/utils/resolve-transition.mjs
23470
+ function resolveTransition(transition, parentTransition) {
23471
+ if (transition?.inherit && parentTransition) {
23472
+ const { inherit: _, ...rest } = transition;
23473
+ return { ...parentTransition, ...rest };
23474
+ }
23475
+ return transition;
23348
23476
  }
23349
23477
 
23350
23478
  // node_modules/motion-dom/dist/es/animation/utils/get-value-transition.mjs
23351
23479
  function getValueTransition(transition, key) {
23352
- return transition?.[key] ?? transition?.["default"] ?? transition;
23480
+ const valueTransition = transition?.[key] ?? transition?.["default"] ?? transition;
23481
+ if (valueTransition !== transition) {
23482
+ return resolveTransition(valueTransition, transition);
23483
+ }
23484
+ return valueTransition;
23353
23485
  }
23354
23486
 
23355
23487
  // node_modules/motion-dom/dist/es/animation/utils/is-transition-defined.mjs
23356
- function isTransitionDefined({ when, delay: _delay, delayChildren, staggerChildren, staggerDirection, repeat, repeatType, repeatDelay, from, elapsed, ...transition }) {
23357
- return !!Object.keys(transition).length;
23488
+ var orchestrationKeys = /* @__PURE__ */ new Set([
23489
+ "when",
23490
+ "delay",
23491
+ "delayChildren",
23492
+ "staggerChildren",
23493
+ "staggerDirection",
23494
+ "repeat",
23495
+ "repeatType",
23496
+ "repeatDelay",
23497
+ "from",
23498
+ "elapsed"
23499
+ ]);
23500
+ function isTransitionDefined(transition) {
23501
+ for (const key in transition) {
23502
+ if (!orchestrationKeys.has(key))
23503
+ return true;
23504
+ }
23505
+ return false;
23358
23506
  }
23359
23507
 
23360
23508
  // node_modules/motion-dom/dist/es/animation/interfaces/motion-value.mjs
@@ -23403,7 +23551,7 @@ var animateMotionValue = (name, value, target, transition = {}, element, isHando
23403
23551
  }
23404
23552
  options.allowFlatten = !valueTransition.type && !valueTransition.ease;
23405
23553
  if (shouldSkip && !isHandoff && value.get() !== void 0) {
23406
- const finalKeyframe = getFinalKeyframe2(options.keyframes, valueTransition);
23554
+ const finalKeyframe = getFinalKeyframe(options.keyframes, valueTransition);
23407
23555
  if (finalKeyframe !== void 0) {
23408
23556
  frame.update(() => {
23409
23557
  options.onUpdate(finalKeyframe);
@@ -23802,7 +23950,9 @@ function shouldBlockAnimation({ protectedKeys, needsAnimating }, key) {
23802
23950
  return shouldBlock;
23803
23951
  }
23804
23952
  function animateTarget(visualElement, targetAndTransition, { delay: delay2 = 0, transitionOverride, type } = {}) {
23805
- let { transition = visualElement.getDefaultTransition(), transitionEnd, ...target } = targetAndTransition;
23953
+ let { transition, transitionEnd, ...target } = targetAndTransition;
23954
+ const defaultTransition = visualElement.getDefaultTransition();
23955
+ transition = transition ? resolveTransition(transition, defaultTransition) : defaultTransition;
23806
23956
  const reduceMotion = transition?.reduceMotion;
23807
23957
  if (transitionOverride)
23808
23958
  transition = transitionOverride;
@@ -23819,7 +23969,8 @@ function animateTarget(visualElement, targetAndTransition, { delay: delay2 = 0,
23819
23969
  ...getValueTransition(transition || {}, key)
23820
23970
  };
23821
23971
  const currentValue = value.get();
23822
- if (currentValue !== void 0 && !value.isAnimating && !Array.isArray(valueTarget) && valueTarget === currentValue && !valueTransition.velocity) {
23972
+ if (currentValue !== void 0 && !value.isAnimating() && !Array.isArray(valueTarget) && valueTarget === currentValue && !valueTransition.velocity) {
23973
+ frame.update(() => value.set(valueTarget));
23823
23974
  continue;
23824
23975
  }
23825
23976
  let isHandoff = false;
@@ -23842,11 +23993,14 @@ function animateTarget(visualElement, targetAndTransition, { delay: delay2 = 0,
23842
23993
  }
23843
23994
  }
23844
23995
  if (transitionEnd) {
23845
- Promise.all(animations2).then(() => {
23846
- frame.update(() => {
23847
- transitionEnd && setTarget(visualElement, transitionEnd);
23848
- });
23996
+ const applyTransitionEnd = () => frame.update(() => {
23997
+ transitionEnd && setTarget(visualElement, transitionEnd);
23849
23998
  });
23999
+ if (animations2.length) {
24000
+ Promise.all(animations2).then(applyTransitionEnd);
24001
+ } else {
24002
+ applyTransitionEnd();
24003
+ }
23850
24004
  }
23851
24005
  return animations2;
23852
24006
  }
@@ -23949,6 +24103,16 @@ var filter = {
23949
24103
  }
23950
24104
  };
23951
24105
 
24106
+ // node_modules/motion-dom/dist/es/value/types/complex/mask.mjs
24107
+ var mask = {
24108
+ ...complex,
24109
+ getAnimatableNone: (v) => {
24110
+ const parsed = complex.parse(v);
24111
+ const transformer = complex.createTransformer(v);
24112
+ return transformer(parsed.map((v2) => typeof v2 === "number" ? 0 : typeof v2 === "object" ? { ...v2, alpha: 1 } : v2));
24113
+ }
24114
+ };
24115
+
23952
24116
  // node_modules/motion-dom/dist/es/value/types/int.mjs
23953
24117
  var int = {
23954
24118
  ...number,
@@ -24064,14 +24228,17 @@ var defaultValueTypes = {
24064
24228
  borderBottomColor: color,
24065
24229
  borderLeftColor: color,
24066
24230
  filter,
24067
- WebkitFilter: filter
24231
+ WebkitFilter: filter,
24232
+ mask,
24233
+ WebkitMask: mask
24068
24234
  };
24069
24235
  var getDefaultValueType = (key) => defaultValueTypes[key];
24070
24236
 
24071
24237
  // node_modules/motion-dom/dist/es/value/types/utils/animatable-none.mjs
24238
+ var customTypes = /* @__PURE__ */ new Set([filter, mask]);
24072
24239
  function getAnimatableNone2(key, value) {
24073
24240
  let defaultValueType = getDefaultValueType(key);
24074
- if (defaultValueType !== filter)
24241
+ if (!customTypes.has(defaultValueType))
24075
24242
  defaultValueType = complex;
24076
24243
  return defaultValueType.getAnimatableNone ? defaultValueType.getAnimatableNone(value) : void 0;
24077
24244
  }
@@ -24215,7 +24382,7 @@ var getValueAsType = (value, type) => {
24215
24382
 
24216
24383
  // node_modules/motion-dom/dist/es/utils/is-html-element.mjs
24217
24384
  function isHTMLElement(element) {
24218
- return isObject(element) && "offsetHeight" in element;
24385
+ return isObject(element) && "offsetHeight" in element && !("ownerSVGElement" in element);
24219
24386
  }
24220
24387
 
24221
24388
  // node_modules/motion-dom/dist/es/frameloop/microtask.mjs
@@ -24272,23 +24439,55 @@ function isValidHover(event) {
24272
24439
  }
24273
24440
  function hover(elementOrSelector, onHoverStart, options = {}) {
24274
24441
  const [elements, eventOptions, cancel] = setupGesture(elementOrSelector, options);
24275
- const onPointerEnter = (enterEvent) => {
24276
- if (!isValidHover(enterEvent))
24277
- return;
24278
- const { target } = enterEvent;
24279
- const onHoverEnd = onHoverStart(target, enterEvent);
24280
- if (typeof onHoverEnd !== "function" || !target)
24281
- return;
24442
+ elements.forEach((element) => {
24443
+ let isPressed = false;
24444
+ let deferredHoverEnd = false;
24445
+ let hoverEndCallback;
24446
+ const removePointerLeave = () => {
24447
+ element.removeEventListener("pointerleave", onPointerLeave);
24448
+ };
24449
+ const endHover = (event) => {
24450
+ if (hoverEndCallback) {
24451
+ hoverEndCallback(event);
24452
+ hoverEndCallback = void 0;
24453
+ }
24454
+ removePointerLeave();
24455
+ };
24456
+ const onPointerUp = (event) => {
24457
+ isPressed = false;
24458
+ window.removeEventListener("pointerup", onPointerUp);
24459
+ window.removeEventListener("pointercancel", onPointerUp);
24460
+ if (deferredHoverEnd) {
24461
+ deferredHoverEnd = false;
24462
+ endHover(event);
24463
+ }
24464
+ };
24465
+ const onPointerDown = () => {
24466
+ isPressed = true;
24467
+ window.addEventListener("pointerup", onPointerUp, eventOptions);
24468
+ window.addEventListener("pointercancel", onPointerUp, eventOptions);
24469
+ };
24282
24470
  const onPointerLeave = (leaveEvent) => {
24283
- if (!isValidHover(leaveEvent))
24471
+ if (leaveEvent.pointerType === "touch")
24284
24472
  return;
24285
- onHoverEnd(leaveEvent);
24286
- target.removeEventListener("pointerleave", onPointerLeave);
24473
+ if (isPressed) {
24474
+ deferredHoverEnd = true;
24475
+ return;
24476
+ }
24477
+ endHover(leaveEvent);
24478
+ };
24479
+ const onPointerEnter = (enterEvent) => {
24480
+ if (!isValidHover(enterEvent))
24481
+ return;
24482
+ deferredHoverEnd = false;
24483
+ const onHoverEnd = onHoverStart(element, enterEvent);
24484
+ if (typeof onHoverEnd !== "function")
24485
+ return;
24486
+ hoverEndCallback = onHoverEnd;
24487
+ element.addEventListener("pointerleave", onPointerLeave, eventOptions);
24287
24488
  };
24288
- target.addEventListener("pointerleave", onPointerLeave, eventOptions);
24289
- };
24290
- elements.forEach((element) => {
24291
24489
  element.addEventListener("pointerenter", onPointerEnter, eventOptions);
24490
+ element.addEventListener("pointerdown", onPointerDown, eventOptions);
24292
24491
  });
24293
24492
  return cancel;
24294
24493
  }
@@ -24366,13 +24565,19 @@ var enableKeyboardPress = (focusEvent, eventOptions) => {
24366
24565
  function isValidPressEvent(event) {
24367
24566
  return isPrimaryPointer(event) && !isDragActive();
24368
24567
  }
24568
+ var claimedPointerDownEvents = /* @__PURE__ */ new WeakSet();
24369
24569
  function press(targetOrSelector, onPressStart, options = {}) {
24370
24570
  const [targets, eventOptions, cancelEvents] = setupGesture(targetOrSelector, options);
24371
24571
  const startPress = (startEvent) => {
24372
24572
  const target = startEvent.currentTarget;
24373
24573
  if (!isValidPressEvent(startEvent))
24374
24574
  return;
24575
+ if (claimedPointerDownEvents.has(startEvent))
24576
+ return;
24375
24577
  isPressing.add(target);
24578
+ if (options.stopPropagation) {
24579
+ claimedPointerDownEvents.add(startEvent);
24580
+ }
24376
24581
  const onPressEnd = onPressStart(target, startEvent);
24377
24582
  const onPointerEnd = (endEvent, success) => {
24378
24583
  window.removeEventListener("pointerup", onPointerUp);
@@ -24414,6 +24619,99 @@ function isSVGElement(element) {
24414
24619
  return isObject(element) && "ownerSVGElement" in element;
24415
24620
  }
24416
24621
 
24622
+ // node_modules/motion-dom/dist/es/resize/handle-element.mjs
24623
+ var resizeHandlers = /* @__PURE__ */ new WeakMap();
24624
+ var observer;
24625
+ var getSize = (borderBoxAxis, svgAxis, htmlAxis) => (target, borderBoxSize) => {
24626
+ if (borderBoxSize && borderBoxSize[0]) {
24627
+ return borderBoxSize[0][borderBoxAxis + "Size"];
24628
+ } else if (isSVGElement(target) && "getBBox" in target) {
24629
+ return target.getBBox()[svgAxis];
24630
+ } else {
24631
+ return target[htmlAxis];
24632
+ }
24633
+ };
24634
+ var getWidth = /* @__PURE__ */ getSize("inline", "width", "offsetWidth");
24635
+ var getHeight = /* @__PURE__ */ getSize("block", "height", "offsetHeight");
24636
+ function notifyTarget({ target, borderBoxSize }) {
24637
+ resizeHandlers.get(target)?.forEach((handler) => {
24638
+ handler(target, {
24639
+ get width() {
24640
+ return getWidth(target, borderBoxSize);
24641
+ },
24642
+ get height() {
24643
+ return getHeight(target, borderBoxSize);
24644
+ }
24645
+ });
24646
+ });
24647
+ }
24648
+ function notifyAll(entries) {
24649
+ entries.forEach(notifyTarget);
24650
+ }
24651
+ function createResizeObserver() {
24652
+ if (typeof ResizeObserver === "undefined")
24653
+ return;
24654
+ observer = new ResizeObserver(notifyAll);
24655
+ }
24656
+ function resizeElement(target, handler) {
24657
+ if (!observer)
24658
+ createResizeObserver();
24659
+ const elements = resolveElements(target);
24660
+ elements.forEach((element) => {
24661
+ let elementHandlers = resizeHandlers.get(element);
24662
+ if (!elementHandlers) {
24663
+ elementHandlers = /* @__PURE__ */ new Set();
24664
+ resizeHandlers.set(element, elementHandlers);
24665
+ }
24666
+ elementHandlers.add(handler);
24667
+ observer?.observe(element);
24668
+ });
24669
+ return () => {
24670
+ elements.forEach((element) => {
24671
+ const elementHandlers = resizeHandlers.get(element);
24672
+ elementHandlers?.delete(handler);
24673
+ if (!elementHandlers?.size) {
24674
+ observer?.unobserve(element);
24675
+ }
24676
+ });
24677
+ };
24678
+ }
24679
+
24680
+ // node_modules/motion-dom/dist/es/resize/handle-window.mjs
24681
+ var windowCallbacks = /* @__PURE__ */ new Set();
24682
+ var windowResizeHandler;
24683
+ function createWindowResizeHandler() {
24684
+ windowResizeHandler = () => {
24685
+ const info = {
24686
+ get width() {
24687
+ return window.innerWidth;
24688
+ },
24689
+ get height() {
24690
+ return window.innerHeight;
24691
+ }
24692
+ };
24693
+ windowCallbacks.forEach((callback) => callback(info));
24694
+ };
24695
+ window.addEventListener("resize", windowResizeHandler);
24696
+ }
24697
+ function resizeWindow(callback) {
24698
+ windowCallbacks.add(callback);
24699
+ if (!windowResizeHandler)
24700
+ createWindowResizeHandler();
24701
+ return () => {
24702
+ windowCallbacks.delete(callback);
24703
+ if (!windowCallbacks.size && typeof windowResizeHandler === "function") {
24704
+ window.removeEventListener("resize", windowResizeHandler);
24705
+ windowResizeHandler = void 0;
24706
+ }
24707
+ };
24708
+ }
24709
+
24710
+ // node_modules/motion-dom/dist/es/resize/index.mjs
24711
+ function resize(a, b) {
24712
+ return typeof a === "function" ? resizeWindow(a) : resizeElement(a, b);
24713
+ }
24714
+
24417
24715
  // node_modules/motion-dom/dist/es/utils/is-svg-svg-element.mjs
24418
24716
  function isSVGSVGElement(element) {
24419
24717
  return isSVGElement(element) && element.tagName === "svg";
@@ -24440,26 +24738,6 @@ var createBox = () => ({
24440
24738
  y: createAxis()
24441
24739
  });
24442
24740
 
24443
- // node_modules/motion-dom/dist/es/render/utils/reduced-motion/state.mjs
24444
- var prefersReducedMotion = { current: null };
24445
- var hasReducedMotionListener = { current: false };
24446
-
24447
- // node_modules/motion-dom/dist/es/render/utils/reduced-motion/index.mjs
24448
- var isBrowser2 = typeof window !== "undefined";
24449
- function initPrefersReducedMotion() {
24450
- hasReducedMotionListener.current = true;
24451
- if (!isBrowser2)
24452
- return;
24453
- if (window.matchMedia) {
24454
- const motionMediaQuery = window.matchMedia("(prefers-reduced-motion)");
24455
- const setReducedMotionPreferences = () => prefersReducedMotion.current = motionMediaQuery.matches;
24456
- motionMediaQuery.addEventListener("change", setReducedMotionPreferences);
24457
- setReducedMotionPreferences();
24458
- } else {
24459
- prefersReducedMotion.current = false;
24460
- }
24461
- }
24462
-
24463
24741
  // node_modules/motion-dom/dist/es/render/store.mjs
24464
24742
  var visualElementStore = /* @__PURE__ */ new WeakMap();
24465
24743
 
@@ -24523,6 +24801,26 @@ function updateMotionValuesFromProps(element, next, prev) {
24523
24801
  return next;
24524
24802
  }
24525
24803
 
24804
+ // node_modules/motion-dom/dist/es/render/utils/reduced-motion/state.mjs
24805
+ var prefersReducedMotion = { current: null };
24806
+ var hasReducedMotionListener = { current: false };
24807
+
24808
+ // node_modules/motion-dom/dist/es/render/utils/reduced-motion/index.mjs
24809
+ var isBrowser2 = typeof window !== "undefined";
24810
+ function initPrefersReducedMotion() {
24811
+ hasReducedMotionListener.current = true;
24812
+ if (!isBrowser2)
24813
+ return;
24814
+ if (window.matchMedia) {
24815
+ const motionMediaQuery = window.matchMedia("(prefers-reduced-motion)");
24816
+ const setReducedMotionPreferences = () => prefersReducedMotion.current = motionMediaQuery.matches;
24817
+ motionMediaQuery.addEventListener("change", setReducedMotionPreferences);
24818
+ setReducedMotionPreferences();
24819
+ } else {
24820
+ prefersReducedMotion.current = false;
24821
+ }
24822
+ }
24823
+
24526
24824
  // node_modules/motion-dom/dist/es/render/VisualElement.mjs
24527
24825
  var propEventHandlers = [
24528
24826
  "AnimationStart",
@@ -24563,6 +24861,7 @@ var VisualElement = class {
24563
24861
  this.features = {};
24564
24862
  this.valueSubscriptions = /* @__PURE__ */ new Map();
24565
24863
  this.prevMotionValues = {};
24864
+ this.hasBeenMounted = false;
24566
24865
  this.events = {};
24567
24866
  this.propEventSubscriptions = {};
24568
24867
  this.notifyUpdate = () => this.notify("Update", this.latestValues);
@@ -24608,6 +24907,12 @@ var VisualElement = class {
24608
24907
  }
24609
24908
  }
24610
24909
  mount(instance) {
24910
+ if (this.hasBeenMounted) {
24911
+ for (const key in this.initialValues) {
24912
+ this.values.get(key)?.jump(this.initialValues[key]);
24913
+ this.latestValues[key] = this.initialValues[key];
24914
+ }
24915
+ }
24611
24916
  this.current = instance;
24612
24917
  visualElementStore.set(instance, this);
24613
24918
  if (this.projection && !this.projection.instance) {
@@ -24633,6 +24938,7 @@ var VisualElement = class {
24633
24938
  this.shouldSkipAnimations = this.skipAnimationsConfig ?? false;
24634
24939
  this.parent?.addChild(this);
24635
24940
  this.update(this.props, this.presenceContext);
24941
+ this.hasBeenMounted = true;
24636
24942
  }
24637
24943
  unmount() {
24638
24944
  this.projection && this.projection.unmount();
@@ -24667,6 +24973,23 @@ var VisualElement = class {
24667
24973
  if (this.valueSubscriptions.has(key)) {
24668
24974
  this.valueSubscriptions.get(key)();
24669
24975
  }
24976
+ if (value.accelerate && acceleratedValues.has(key) && this.current instanceof HTMLElement) {
24977
+ const { factory, keyframes: keyframes2, times, ease: ease2, duration } = value.accelerate;
24978
+ const animation = new NativeAnimation({
24979
+ element: this.current,
24980
+ name: key,
24981
+ keyframes: keyframes2,
24982
+ times,
24983
+ ease: ease2,
24984
+ duration: secondsToMilliseconds(duration)
24985
+ });
24986
+ const cleanup = factory(animation);
24987
+ this.valueSubscriptions.set(key, () => {
24988
+ cleanup();
24989
+ animation.cancel();
24990
+ });
24991
+ return;
24992
+ }
24670
24993
  const valueIsTransform = transformProps.has(key);
24671
24994
  if (valueIsTransform && this.onBindTransform) {
24672
24995
  this.onBindTransform();
@@ -25019,10 +25342,8 @@ function applyTreeDeltas(box, treeScale, treePath, isSharedTransition = false) {
25019
25342
  continue;
25020
25343
  }
25021
25344
  if (isSharedTransition && node.options.layoutScroll && node.scroll && node !== node.root) {
25022
- transformBox(box, {
25023
- x: -node.scroll.offset.x,
25024
- y: -node.scroll.offset.y
25025
- });
25345
+ translateAxis(box.x, -node.scroll.offset.x);
25346
+ translateAxis(box.y, -node.scroll.offset.y);
25026
25347
  }
25027
25348
  if (delta) {
25028
25349
  treeScale.x *= delta.x.scale;
@@ -25030,7 +25351,7 @@ function applyTreeDeltas(box, treeScale, treePath, isSharedTransition = false) {
25030
25351
  applyBoxDelta(box, delta);
25031
25352
  }
25032
25353
  if (isSharedTransition && hasTransform(node.latestValues)) {
25033
- transformBox(box, node.latestValues);
25354
+ transformBox(box, node.latestValues, node.layout?.layoutBox);
25034
25355
  }
25035
25356
  }
25036
25357
  if (treeScale.x < TREE_SCALE_SNAP_MAX && treeScale.x > TREE_SCALE_SNAP_MIN) {
@@ -25041,16 +25362,23 @@ function applyTreeDeltas(box, treeScale, treePath, isSharedTransition = false) {
25041
25362
  }
25042
25363
  }
25043
25364
  function translateAxis(axis, distance2) {
25044
- axis.min = axis.min + distance2;
25045
- axis.max = axis.max + distance2;
25365
+ axis.min += distance2;
25366
+ axis.max += distance2;
25046
25367
  }
25047
25368
  function transformAxis(axis, axisTranslate, axisScale, boxScale, axisOrigin = 0.5) {
25048
25369
  const originPoint = mixNumber(axis.min, axis.max, axisOrigin);
25049
25370
  applyAxisDelta(axis, axisTranslate, axisScale, originPoint, boxScale);
25050
25371
  }
25051
- function transformBox(box, transform) {
25052
- transformAxis(box.x, transform.x, transform.scaleX, transform.scale, transform.originX);
25053
- transformAxis(box.y, transform.y, transform.scaleY, transform.scale, transform.originY);
25372
+ function resolveAxisTranslate(value, axis) {
25373
+ if (typeof value === "string") {
25374
+ return parseFloat(value) / 100 * (axis.max - axis.min);
25375
+ }
25376
+ return value;
25377
+ }
25378
+ function transformBox(box, transform, sourceBox) {
25379
+ const resolveBox = sourceBox ?? box;
25380
+ transformAxis(box.x, resolveAxisTranslate(transform.x, resolveBox.x), transform.scaleX, transform.scale, transform.originX);
25381
+ transformAxis(box.y, resolveAxisTranslate(transform.y, resolveBox.y), transform.scaleY, transform.scale, transform.originY);
25054
25382
  }
25055
25383
 
25056
25384
  // node_modules/motion-dom/dist/es/projection/utils/measure.mjs
@@ -25478,6 +25806,7 @@ function createAnimationState(visualElement) {
25478
25806
  let animate = createAnimateFunction(visualElement);
25479
25807
  let state = createState();
25480
25808
  let isInitialRender = true;
25809
+ let wasReset = false;
25481
25810
  const buildResolvedTypeValues = (type) => (acc, definition) => {
25482
25811
  const resolved = resolveVariant(visualElement, definition, type === "exit" ? visualElement.presenceContext?.custom : void 0);
25483
25812
  if (resolved) {
@@ -25505,7 +25834,7 @@ function createAnimationState(visualElement) {
25505
25834
  if (activeDelta === false)
25506
25835
  removedVariantIndex = i;
25507
25836
  let isInherited = prop === context[type] && prop !== props[type] && propIsVariant;
25508
- if (isInherited && isInitialRender && visualElement.manuallyAnimateOnMount) {
25837
+ if (isInherited && (isInitialRender || wasReset) && visualElement.manuallyAnimateOnMount) {
25509
25838
  isInherited = false;
25510
25839
  }
25511
25840
  typeState.protectedKeys = { ...encounteredKeys };
@@ -25517,6 +25846,15 @@ function createAnimationState(visualElement) {
25517
25846
  ) {
25518
25847
  continue;
25519
25848
  }
25849
+ if (type === "exit" && typeState.isActive && activeDelta !== true) {
25850
+ if (typeState.prevResolvedValues) {
25851
+ encounteredKeys = {
25852
+ ...encounteredKeys,
25853
+ ...typeState.prevResolvedValues
25854
+ };
25855
+ }
25856
+ continue;
25857
+ }
25520
25858
  const variantDidChange = checkVariantsDidChange(typeState.prevProp, prop);
25521
25859
  let shouldAnimateType = variantDidChange || // If we're making this variant active, we want to always make it active
25522
25860
  type === changedActiveType && typeState.isActive && !isInherited && propIsVariant || // If we removed a higher-priority variant (i is in reverse order)
@@ -25570,7 +25908,7 @@ function createAnimationState(visualElement) {
25570
25908
  if (typeState.isActive) {
25571
25909
  encounteredKeys = { ...encounteredKeys, ...resolvedValues };
25572
25910
  }
25573
- if (isInitialRender && visualElement.blockInitialAnimation) {
25911
+ if ((isInitialRender || wasReset) && visualElement.blockInitialAnimation) {
25574
25912
  shouldAnimateType = false;
25575
25913
  }
25576
25914
  const willAnimateViaParent = isInherited && variantDidChange;
@@ -25578,7 +25916,7 @@ function createAnimationState(visualElement) {
25578
25916
  if (shouldAnimateType && needsAnimating) {
25579
25917
  animations2.push(...definitionList.map((animation) => {
25580
25918
  const options = { type };
25581
- if (typeof animation === "string" && isInitialRender && !willAnimateViaParent && visualElement.manuallyAnimateOnMount && visualElement.parent) {
25919
+ if (typeof animation === "string" && (isInitialRender || wasReset) && !willAnimateViaParent && visualElement.manuallyAnimateOnMount && visualElement.parent) {
25582
25920
  const { parent } = visualElement;
25583
25921
  const parentVariant = resolveVariant(parent, animation);
25584
25922
  if (parent.enteringChildren && parentVariant) {
@@ -25615,6 +25953,7 @@ function createAnimationState(visualElement) {
25615
25953
  shouldAnimate = false;
25616
25954
  }
25617
25955
  isInitialRender = false;
25956
+ wasReset = false;
25618
25957
  return shouldAnimate ? animate(animations2) : Promise.resolve();
25619
25958
  }
25620
25959
  function setActive(type, isActive) {
@@ -25635,6 +25974,7 @@ function createAnimationState(visualElement) {
25635
25974
  getState: () => state,
25636
25975
  reset: () => {
25637
25976
  state = createState();
25977
+ wasReset = true;
25638
25978
  }
25639
25979
  };
25640
25980
  }
@@ -25711,21 +26051,23 @@ function calcBoxDelta(delta, source, target, origin) {
25711
26051
  calcAxisDelta(delta.x, source.x, target.x, origin ? origin.originX : void 0);
25712
26052
  calcAxisDelta(delta.y, source.y, target.y, origin ? origin.originY : void 0);
25713
26053
  }
25714
- function calcRelativeAxis(target, relative, parent) {
25715
- target.min = parent.min + relative.min;
26054
+ function calcRelativeAxis(target, relative, parent, anchor = 0) {
26055
+ const anchorPoint = anchor ? mixNumber(parent.min, parent.max, anchor) : parent.min;
26056
+ target.min = anchorPoint + relative.min;
25716
26057
  target.max = target.min + calcLength(relative);
25717
26058
  }
25718
- function calcRelativeBox(target, relative, parent) {
25719
- calcRelativeAxis(target.x, relative.x, parent.x);
25720
- calcRelativeAxis(target.y, relative.y, parent.y);
26059
+ function calcRelativeBox(target, relative, parent, anchor) {
26060
+ calcRelativeAxis(target.x, relative.x, parent.x, anchor?.x);
26061
+ calcRelativeAxis(target.y, relative.y, parent.y, anchor?.y);
25721
26062
  }
25722
- function calcRelativeAxisPosition(target, layout2, parent) {
25723
- target.min = layout2.min - parent.min;
26063
+ function calcRelativeAxisPosition(target, layout2, parent, anchor = 0) {
26064
+ const anchorPoint = anchor ? mixNumber(parent.min, parent.max, anchor) : parent.min;
26065
+ target.min = layout2.min - anchorPoint;
25724
26066
  target.max = target.min + calcLength(layout2);
25725
26067
  }
25726
- function calcRelativePosition(target, layout2, parent) {
25727
- calcRelativeAxisPosition(target.x, layout2.x, parent.x);
25728
- calcRelativeAxisPosition(target.y, layout2.y, parent.y);
26068
+ function calcRelativePosition(target, layout2, parent, anchor) {
26069
+ calcRelativeAxisPosition(target.x, layout2.x, parent.x, anchor?.x);
26070
+ calcRelativeAxisPosition(target.y, layout2.y, parent.y, anchor?.y);
25729
26071
  }
25730
26072
 
25731
26073
  // node_modules/motion-dom/dist/es/projection/geometry/delta-remove.mjs
@@ -25828,8 +26170,13 @@ function buildProjectionTransform(delta, treeScale, latestTransform) {
25828
26170
  }
25829
26171
 
25830
26172
  // node_modules/motion-dom/dist/es/projection/animation/mix-values.mjs
25831
- var borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
25832
- var numBorders = borders.length;
26173
+ var borderLabels = [
26174
+ "borderTopLeftRadius",
26175
+ "borderTopRightRadius",
26176
+ "borderBottomLeftRadius",
26177
+ "borderBottomRightRadius"
26178
+ ];
26179
+ var numBorders = borderLabels.length;
25833
26180
  var asNumber = (value) => typeof value === "string" ? parseFloat(value) : value;
25834
26181
  var isPx = (value) => typeof value === "number" || px.test(value);
25835
26182
  function mixValues(target, follow, lead, progress2, shouldCrossfadeOpacity, isOnlyMember) {
@@ -25840,7 +26187,7 @@ function mixValues(target, follow, lead, progress2, shouldCrossfadeOpacity, isOn
25840
26187
  target.opacity = mixNumber(follow.opacity ?? 1, lead.opacity ?? 1, progress2);
25841
26188
  }
25842
26189
  for (let i = 0; i < numBorders; i++) {
25843
- const borderLabel = `border${borders[i]}Radius`;
26190
+ const borderLabel = borderLabels[i];
25844
26191
  let followRadius = getRadius(follow, borderLabel);
25845
26192
  let leadRadius = getRadius(lead, borderLabel);
25846
26193
  if (followRadius === void 0 && leadRadius === void 0)
@@ -25939,38 +26286,37 @@ var NodeStack = class {
25939
26286
  }
25940
26287
  add(node) {
25941
26288
  addUniqueItem(this.members, node);
26289
+ for (let i = this.members.length - 1; i >= 0; i--) {
26290
+ const member = this.members[i];
26291
+ if (member === node || member === this.lead || member === this.prevLead)
26292
+ continue;
26293
+ const inst = member.instance;
26294
+ if ((!inst || inst.isConnected === false) && !member.snapshot) {
26295
+ removeItem(this.members, member);
26296
+ member.unmount();
26297
+ }
26298
+ }
25942
26299
  node.scheduleRender();
25943
26300
  }
25944
26301
  remove(node) {
25945
26302
  removeItem(this.members, node);
25946
- if (node === this.prevLead) {
26303
+ if (node === this.prevLead)
25947
26304
  this.prevLead = void 0;
25948
- }
25949
26305
  if (node === this.lead) {
25950
26306
  const prevLead = this.members[this.members.length - 1];
25951
- if (prevLead) {
26307
+ if (prevLead)
25952
26308
  this.promote(prevLead);
25953
- }
25954
26309
  }
25955
26310
  }
25956
26311
  relegate(node) {
25957
- const indexOfNode = this.members.findIndex((member) => node === member);
25958
- if (indexOfNode === 0)
25959
- return false;
25960
- let prevLead;
25961
- for (let i = indexOfNode; i >= 0; i--) {
26312
+ for (let i = this.members.indexOf(node) - 1; i >= 0; i--) {
25962
26313
  const member = this.members[i];
25963
- if (member.isPresent !== false) {
25964
- prevLead = member;
25965
- break;
26314
+ if (member.isPresent !== false && member.instance?.isConnected !== false) {
26315
+ this.promote(member);
26316
+ return true;
25966
26317
  }
25967
26318
  }
25968
- if (prevLead) {
25969
- this.promote(prevLead);
25970
- return true;
25971
- } else {
25972
- return false;
25973
- }
26319
+ return false;
25974
26320
  }
25975
26321
  promote(node, preserveFollowOpacity) {
25976
26322
  const prevLead = this.lead;
@@ -25980,52 +26326,37 @@ var NodeStack = class {
25980
26326
  this.lead = node;
25981
26327
  node.show();
25982
26328
  if (prevLead) {
25983
- prevLead.instance && prevLead.scheduleRender();
26329
+ prevLead.updateSnapshot();
25984
26330
  node.scheduleRender();
25985
- const prevDep = prevLead.options.layoutDependency;
25986
- const nextDep = node.options.layoutDependency;
25987
- const dependencyMatches = prevDep !== void 0 && nextDep !== void 0 && prevDep === nextDep;
25988
- if (!dependencyMatches) {
26331
+ const { layoutDependency: prevDep } = prevLead.options;
26332
+ const { layoutDependency: nextDep } = node.options;
26333
+ if (prevDep === void 0 || prevDep !== nextDep) {
25989
26334
  node.resumeFrom = prevLead;
25990
- if (preserveFollowOpacity) {
25991
- node.resumeFrom.preserveOpacity = true;
25992
- }
26335
+ if (preserveFollowOpacity)
26336
+ prevLead.preserveOpacity = true;
25993
26337
  if (prevLead.snapshot) {
25994
26338
  node.snapshot = prevLead.snapshot;
25995
26339
  node.snapshot.latestValues = prevLead.animationValues || prevLead.latestValues;
25996
26340
  }
25997
- if (node.root && node.root.isUpdating) {
26341
+ if (node.root?.isUpdating)
25998
26342
  node.isLayoutDirty = true;
25999
- }
26000
26343
  }
26001
- const { crossfade } = node.options;
26002
- if (crossfade === false) {
26344
+ if (node.options.crossfade === false)
26003
26345
  prevLead.hide();
26004
- }
26005
26346
  }
26006
26347
  }
26007
26348
  exitAnimationComplete() {
26008
- this.members.forEach((node) => {
26009
- const { options, resumingFrom } = node;
26010
- options.onExitComplete && options.onExitComplete();
26011
- if (resumingFrom) {
26012
- resumingFrom.options.onExitComplete && resumingFrom.options.onExitComplete();
26013
- }
26349
+ this.members.forEach((member) => {
26350
+ member.options.onExitComplete?.();
26351
+ member.resumingFrom?.options.onExitComplete?.();
26014
26352
  });
26015
26353
  }
26016
26354
  scheduleRender() {
26017
- this.members.forEach((node) => {
26018
- node.instance && node.scheduleRender(false);
26019
- });
26355
+ this.members.forEach((member) => member.instance && member.scheduleRender(false));
26020
26356
  }
26021
- /**
26022
- * Clear any leads that have been removed this render to prevent them from being
26023
- * used in future animations and to prevent memory leaks
26024
- */
26025
26357
  removeLeadSnapshot() {
26026
- if (this.lead && this.lead.snapshot) {
26358
+ if (this.lead?.snapshot)
26027
26359
  this.lead.snapshot = void 0;
26028
- }
26029
26360
  }
26030
26361
  };
26031
26362
 
@@ -26274,6 +26605,9 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
26274
26605
  for (let i = 0; i < this.path.length; i++) {
26275
26606
  const node = this.path[i];
26276
26607
  node.shouldResetTransform = true;
26608
+ if (typeof node.latestValues.x === "string" || typeof node.latestValues.y === "string") {
26609
+ node.isLayoutDirty = true;
26610
+ }
26277
26611
  node.updateScroll("snapshot");
26278
26612
  if (node.options.layoutRoot) {
26279
26613
  node.willUpdate(false);
@@ -26291,8 +26625,13 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
26291
26625
  this.updateScheduled = false;
26292
26626
  const updateWasBlocked = this.isUpdateBlocked();
26293
26627
  if (updateWasBlocked) {
26628
+ const wasBlockedByResize = this.updateBlockedByResize;
26294
26629
  this.unblockUpdate();
26630
+ this.updateBlockedByResize = false;
26295
26631
  this.clearAllSnapshots();
26632
+ if (wasBlockedByResize) {
26633
+ this.nodes.forEach(forceLayoutMeasure);
26634
+ }
26296
26635
  this.nodes.forEach(clearMeasurements);
26297
26636
  return;
26298
26637
  }
@@ -26305,6 +26644,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
26305
26644
  this.nodes.forEach(clearIsLayoutDirty);
26306
26645
  } else {
26307
26646
  this.isUpdating = false;
26647
+ this.nodes.forEach(ensureDraggedNodesSnapshotted);
26308
26648
  this.nodes.forEach(resetTransformStyle);
26309
26649
  this.nodes.forEach(updateLayout);
26310
26650
  this.nodes.forEach(notifyLayoutUpdate);
@@ -26371,7 +26711,8 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
26371
26711
  const prevLayout = this.layout;
26372
26712
  this.layout = this.measure(false);
26373
26713
  this.layoutVersion++;
26374
- this.layoutCorrected = createBox();
26714
+ if (!this.layoutCorrected)
26715
+ this.layoutCorrected = createBox();
26375
26716
  this.isLayoutDirty = false;
26376
26717
  this.projectionDelta = void 0;
26377
26718
  this.notifyListeners("measure", this.layout.layoutBox);
@@ -26457,23 +26798,21 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
26457
26798
  }
26458
26799
  return boxWithoutScroll;
26459
26800
  }
26460
- applyTransform(box, transformOnly = false) {
26461
- const withTransforms = createBox();
26801
+ applyTransform(box, transformOnly = false, output) {
26802
+ const withTransforms = output || createBox();
26462
26803
  copyBoxInto(withTransforms, box);
26463
26804
  for (let i = 0; i < this.path.length; i++) {
26464
26805
  const node = this.path[i];
26465
26806
  if (!transformOnly && node.options.layoutScroll && node.scroll && node !== node.root) {
26466
- transformBox(withTransforms, {
26467
- x: -node.scroll.offset.x,
26468
- y: -node.scroll.offset.y
26469
- });
26807
+ translateAxis(withTransforms.x, -node.scroll.offset.x);
26808
+ translateAxis(withTransforms.y, -node.scroll.offset.y);
26470
26809
  }
26471
26810
  if (!hasTransform(node.latestValues))
26472
26811
  continue;
26473
- transformBox(withTransforms, node.latestValues);
26812
+ transformBox(withTransforms, node.latestValues, node.layout?.layoutBox);
26474
26813
  }
26475
26814
  if (hasTransform(this.latestValues)) {
26476
- transformBox(withTransforms, this.latestValues);
26815
+ transformBox(withTransforms, this.latestValues, this.layout?.layoutBox);
26477
26816
  }
26478
26817
  return withTransforms;
26479
26818
  }
@@ -26482,15 +26821,15 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
26482
26821
  copyBoxInto(boxWithoutTransform, box);
26483
26822
  for (let i = 0; i < this.path.length; i++) {
26484
26823
  const node = this.path[i];
26485
- if (!node.instance)
26486
- continue;
26487
26824
  if (!hasTransform(node.latestValues))
26488
26825
  continue;
26489
- hasScale(node.latestValues) && node.updateSnapshot();
26490
- const sourceBox = createBox();
26491
- const nodeBox = node.measurePageBox();
26492
- copyBoxInto(sourceBox, nodeBox);
26493
- removeBoxTransforms(boxWithoutTransform, node.latestValues, node.snapshot ? node.snapshot.layoutBox : void 0, sourceBox);
26826
+ let sourceBox;
26827
+ if (node.instance) {
26828
+ hasScale(node.latestValues) && node.updateSnapshot();
26829
+ sourceBox = createBox();
26830
+ copyBoxInto(sourceBox, node.measurePageBox());
26831
+ }
26832
+ removeBoxTransforms(boxWithoutTransform, node.latestValues, node.snapshot?.layoutBox, sourceBox);
26494
26833
  }
26495
26834
  if (hasTransform(this.latestValues)) {
26496
26835
  removeBoxTransforms(boxWithoutTransform, this.latestValues);
@@ -26543,7 +26882,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
26543
26882
  this.removeRelativeTarget();
26544
26883
  }
26545
26884
  if (!this.targetDelta && !this.relativeTarget) {
26546
- if (relativeParent && relativeParent.layout) {
26885
+ if (this.options.layoutAnchor !== false && relativeParent && relativeParent.layout) {
26547
26886
  this.createRelativeTarget(relativeParent, this.layout.layoutBox, relativeParent.layout.layoutBox);
26548
26887
  } else {
26549
26888
  this.removeRelativeTarget();
@@ -26557,10 +26896,10 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
26557
26896
  }
26558
26897
  if (this.relativeTarget && this.relativeTargetOrigin && this.relativeParent && this.relativeParent.target) {
26559
26898
  this.forceRelativeParentToResolveTarget();
26560
- calcRelativeBox(this.target, this.relativeTarget, this.relativeParent.target);
26899
+ calcRelativeBox(this.target, this.relativeTarget, this.relativeParent.target, this.options.layoutAnchor || void 0);
26561
26900
  } else if (this.targetDelta) {
26562
26901
  if (Boolean(this.resumingFrom)) {
26563
- this.target = this.applyTransform(this.layout.layoutBox);
26902
+ this.applyTransform(this.layout.layoutBox, false, this.target);
26564
26903
  } else {
26565
26904
  copyBoxInto(this.target, this.layout.layoutBox);
26566
26905
  }
@@ -26570,7 +26909,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
26570
26909
  }
26571
26910
  if (this.attemptToResolveRelativeTarget) {
26572
26911
  this.attemptToResolveRelativeTarget = false;
26573
- if (relativeParent && Boolean(relativeParent.resumingFrom) === Boolean(this.resumingFrom) && !relativeParent.options.layoutScroll && relativeParent.target && this.animationProgress !== 1) {
26912
+ if (this.options.layoutAnchor !== false && relativeParent && Boolean(relativeParent.resumingFrom) === Boolean(this.resumingFrom) && !relativeParent.options.layoutScroll && relativeParent.target && this.animationProgress !== 1) {
26574
26913
  this.createRelativeTarget(relativeParent, this.target, relativeParent.target);
26575
26914
  } else {
26576
26915
  this.relativeParent = this.relativeTarget = void 0;
@@ -26596,7 +26935,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
26596
26935
  this.forceRelativeParentToResolveTarget();
26597
26936
  this.relativeTarget = createBox();
26598
26937
  this.relativeTargetOrigin = createBox();
26599
- calcRelativePosition(this.relativeTargetOrigin, layout2, parentLayout);
26938
+ calcRelativePosition(this.relativeTargetOrigin, layout2, parentLayout, this.options.layoutAnchor || void 0);
26600
26939
  copyBoxInto(this.relativeTarget, this.relativeTargetOrigin);
26601
26940
  }
26602
26941
  removeRelativeTarget() {
@@ -26659,9 +26998,9 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
26659
26998
  show() {
26660
26999
  this.isVisible = true;
26661
27000
  }
26662
- scheduleRender(notifyAll = true) {
27001
+ scheduleRender(notifyAll2 = true) {
26663
27002
  this.options.visualElement?.scheduleRender();
26664
- if (notifyAll) {
27003
+ if (notifyAll2) {
26665
27004
  const stack = this.getStack();
26666
27005
  stack && stack.scheduleRender();
26667
27006
  }
@@ -26698,7 +27037,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
26698
27037
  mixAxisDelta(targetDelta.y, delta.y, progress2);
26699
27038
  this.setTargetDelta(targetDelta);
26700
27039
  if (this.relativeTarget && this.relativeTargetOrigin && this.layout && this.relativeParent && this.relativeParent.layout) {
26701
- calcRelativePosition(relativeLayout, this.layout.layoutBox, this.relativeParent.layout.layoutBox);
27040
+ calcRelativePosition(relativeLayout, this.layout.layoutBox, this.relativeParent.layout.layoutBox, this.options.layoutAnchor || void 0);
26702
27041
  mixBox(this.relativeTarget, this.relativeTargetOrigin, relativeLayout, progress2);
26703
27042
  if (prevRelativeTarget && boxEquals(this.relativeTarget, prevRelativeTarget)) {
26704
27043
  this.isProjectionDirty = false;
@@ -26728,6 +27067,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
26728
27067
  this.pendingAnimation = frame.update(() => {
26729
27068
  globalProjectionState.hasAnimatedSinceResize = true;
26730
27069
  this.motionValue || (this.motionValue = motionValue(0));
27070
+ this.motionValue.jump(0, false);
26731
27071
  this.currentAnimation = animateSingleValue(this.motionValue, [0, 1e3], {
26732
27072
  ...options,
26733
27073
  velocity: 0,
@@ -26952,6 +27292,9 @@ function notifyLayoutUpdate(node) {
26952
27292
  axisSnapshot.min = layout2[axis].min;
26953
27293
  axisSnapshot.max = axisSnapshot.min + length;
26954
27294
  });
27295
+ } else if (animationType === "x" || animationType === "y") {
27296
+ const snapAxis = animationType === "x" ? "y" : "x";
27297
+ copyAxisInto(isShared ? snapshot.measuredBox[snapAxis] : snapshot.layoutBox[snapAxis], layout2[snapAxis]);
26955
27298
  } else if (shouldAnimatePositionOnly(animationType, snapshot.layoutBox, layout2)) {
26956
27299
  eachAxis((axis) => {
26957
27300
  const axisSnapshot = isShared ? snapshot.measuredBox[axis] : snapshot.layoutBox[axis];
@@ -26978,10 +27321,11 @@ function notifyLayoutUpdate(node) {
26978
27321
  if (relativeParent && !relativeParent.resumeFrom) {
26979
27322
  const { snapshot: parentSnapshot, layout: parentLayout } = relativeParent;
26980
27323
  if (parentSnapshot && parentLayout) {
27324
+ const anchor = node.options.layoutAnchor || void 0;
26981
27325
  const relativeSnapshot = createBox();
26982
- calcRelativePosition(relativeSnapshot, snapshot.layoutBox, parentSnapshot.layoutBox);
27326
+ calcRelativePosition(relativeSnapshot, snapshot.layoutBox, parentSnapshot.layoutBox, anchor);
26983
27327
  const relativeLayout = createBox();
26984
- calcRelativePosition(relativeLayout, layout2, parentLayout.layoutBox);
27328
+ calcRelativePosition(relativeLayout, layout2, parentLayout.layoutBox, anchor);
26985
27329
  if (!boxEqualsRounded(relativeSnapshot, relativeLayout)) {
26986
27330
  hasRelativeLayoutChanged = true;
26987
27331
  }
@@ -27025,9 +27369,19 @@ function clearSnapshot(node) {
27025
27369
  function clearMeasurements(node) {
27026
27370
  node.clearMeasurements();
27027
27371
  }
27372
+ function forceLayoutMeasure(node) {
27373
+ node.isLayoutDirty = true;
27374
+ node.updateLayout();
27375
+ }
27028
27376
  function clearIsLayoutDirty(node) {
27029
27377
  node.isLayoutDirty = false;
27030
27378
  }
27379
+ function ensureDraggedNodesSnapshotted(node) {
27380
+ if (node.isAnimationBlocked && node.layout && !node.isLayoutDirty) {
27381
+ node.snapshot = node.layout;
27382
+ node.isLayoutDirty = true;
27383
+ }
27384
+ }
27031
27385
  function resetTransformStyle(node) {
27032
27386
  const { visualElement } = node.options;
27033
27387
  if (visualElement && visualElement.getProps().onBeforeLayoutMeasure) {
@@ -27293,6 +27647,7 @@ var validMotionProps = /* @__PURE__ */ new Set([
27293
27647
  "onViewportEnter",
27294
27648
  "onViewportLeave",
27295
27649
  "globalTapTarget",
27650
+ "propagate",
27296
27651
  "ignoreStrict",
27297
27652
  "viewport"
27298
27653
  ]);
@@ -27308,7 +27663,8 @@ function loadExternalIsValidProp(isValidProp) {
27308
27663
  shouldForward = (key) => key.startsWith("on") ? !isValidMotionProp(key) : isValidProp(key);
27309
27664
  }
27310
27665
  try {
27311
- loadExternalIsValidProp(__require("@emotion/is-prop-valid").default);
27666
+ const emotionPkg = "@emotion/is-prop-valid";
27667
+ loadExternalIsValidProp(__require(emotionPkg).default);
27312
27668
  } catch {
27313
27669
  }
27314
27670
  function filterProps(props, isDom, forwardMotionProps) {
@@ -27316,6 +27672,8 @@ function filterProps(props, isDom, forwardMotionProps) {
27316
27672
  for (const key in props) {
27317
27673
  if (key === "values" && typeof props.values === "object")
27318
27674
  continue;
27675
+ if (isMotionValue(props[key]))
27676
+ continue;
27319
27677
  if (shouldForward(key) || forwardMotionProps === true && isValidMotionProp(key) || !isDom && !isValidMotionProp(key) || // If trying to use native HTML drag events, forward drag listeners
27320
27678
  props["draggable"] && key.startsWith("onDrag")) {
27321
27679
  filteredProps[key] = props[key];
@@ -27564,9 +27922,6 @@ function useMotionRef(visualState, visualElement, externalRef) {
27564
27922
  if (instance) {
27565
27923
  visualState.onMount?.(instance);
27566
27924
  }
27567
- if (visualElement) {
27568
- instance ? visualElement.mount(instance) : visualElement.unmount();
27569
- }
27570
27925
  const ref = externalRefContainer.current;
27571
27926
  if (typeof ref === "function") {
27572
27927
  if (instance) {
@@ -27583,6 +27938,9 @@ function useMotionRef(visualState, visualElement, externalRef) {
27583
27938
  } else if (ref) {
27584
27939
  ref.current = instance;
27585
27940
  }
27941
+ if (visualElement) {
27942
+ instance ? visualElement.mount(instance) : visualElement.unmount();
27943
+ }
27586
27944
  }, [visualElement]);
27587
27945
  }
27588
27946
  var SwitchLayoutGroupContext = React5.createContext({});
@@ -27630,7 +27988,7 @@ function useVisualElement(Component2, visualState, props, createVisualElement, P
27630
27988
  }
27631
27989
  });
27632
27990
  const optimisedAppearId = props[optimizedAppearDataAttribute];
27633
- const wantsHandoff = React5.useRef(Boolean(optimisedAppearId) && !window.MotionHandoffIsComplete?.(optimisedAppearId) && window.MotionHasOptimisedAnimation?.(optimisedAppearId));
27991
+ const wantsHandoff = React5.useRef(Boolean(optimisedAppearId) && typeof window !== "undefined" && !window.MotionHandoffIsComplete?.(optimisedAppearId) && window.MotionHasOptimisedAnimation?.(optimisedAppearId));
27634
27992
  useIsomorphicLayoutEffect(() => {
27635
27993
  hasMountedOnce.current = true;
27636
27994
  if (!visualElement)
@@ -27660,7 +28018,7 @@ function useVisualElement(Component2, visualState, props, createVisualElement, P
27660
28018
  return visualElement;
27661
28019
  }
27662
28020
  function createProjectionNode2(visualElement, props, ProjectionNodeConstructor, initialPromotionConfig) {
27663
- const { layoutId, layout: layout2, drag: drag2, dragConstraints, layoutScroll, layoutRoot, layoutCrossfade } = props;
28021
+ const { layoutId, layout: layout2, drag: drag2, dragConstraints, layoutScroll, layoutRoot, layoutAnchor, layoutCrossfade } = props;
27664
28022
  visualElement.projection = new ProjectionNodeConstructor(visualElement.latestValues, props["data-framer-portal-id"] ? void 0 : getClosestProjectingNode(visualElement.parent));
27665
28023
  visualElement.projection.setOptions({
27666
28024
  layoutId,
@@ -27678,7 +28036,8 @@ function createProjectionNode2(visualElement, props, ProjectionNodeConstructor,
27678
28036
  initialPromotionConfig,
27679
28037
  crossfade: layoutCrossfade,
27680
28038
  layoutScroll,
27681
- layoutRoot
28039
+ layoutRoot,
28040
+ layoutAnchor
27682
28041
  });
27683
28042
  }
27684
28043
  function getClosestProjectingNode(visualElement) {
@@ -27702,7 +28061,7 @@ function createMotionComponent(Component2, { forwardMotionProps = false, type }
27702
28061
  const { isStatic } = configAndProps;
27703
28062
  const context = useCreateMotionContext(props);
27704
28063
  const visualState = useVisualState(props, isStatic);
27705
- if (!isStatic && isBrowser) {
28064
+ if (!isStatic && typeof window !== "undefined") {
27706
28065
  useStrictMode(configAndProps, preloadedFeatures);
27707
28066
  const layoutProjection = getProjectionFunctionality(configAndProps);
27708
28067
  MeasureLayout2 = layoutProjection.MeasureLayout;
@@ -27818,6 +28177,7 @@ var ExitAnimationFeature = class extends Feature {
27818
28177
  constructor() {
27819
28178
  super(...arguments);
27820
28179
  this.id = id2++;
28180
+ this.isExitComplete = false;
27821
28181
  }
27822
28182
  update() {
27823
28183
  if (!this.node.presenceContext)
@@ -27827,9 +28187,30 @@ var ExitAnimationFeature = class extends Feature {
27827
28187
  if (!this.node.animationState || isPresent === prevIsPresent) {
27828
28188
  return;
27829
28189
  }
28190
+ if (isPresent && prevIsPresent === false) {
28191
+ if (this.isExitComplete) {
28192
+ const { initial, custom } = this.node.getProps();
28193
+ if (typeof initial === "string") {
28194
+ const resolved = resolveVariant(this.node, initial, custom);
28195
+ if (resolved) {
28196
+ const { transition, transitionEnd, ...target } = resolved;
28197
+ for (const key in target) {
28198
+ this.node.getValue(key)?.jump(target[key]);
28199
+ }
28200
+ }
28201
+ }
28202
+ this.node.animationState.reset();
28203
+ this.node.animationState.animateChanges();
28204
+ } else {
28205
+ this.node.animationState.setActive("exit", false);
28206
+ }
28207
+ this.isExitComplete = false;
28208
+ return;
28209
+ }
27830
28210
  const exitAnimation = this.node.animationState.setActive("exit", !isPresent);
27831
28211
  if (onExitComplete && !isPresent) {
27832
28212
  exitAnimation.then(() => {
28213
+ this.isExitComplete = true;
27833
28214
  onExitComplete(this.id);
27834
28215
  });
27835
28216
  }
@@ -27866,9 +28247,7 @@ function extractEventInfo(event) {
27866
28247
  }
27867
28248
  };
27868
28249
  }
27869
- var addPointerInfo = (handler) => {
27870
- return (event) => isPrimaryPointer(event) && handler(event, extractEventInfo(event));
27871
- };
28250
+ var addPointerInfo = (handler) => (event) => isPrimaryPointer(event) && handler(event, extractEventInfo(event));
27872
28251
 
27873
28252
  // node_modules/framer-motion/dist/es/events/add-pointer-event.mjs
27874
28253
  function addPointerEvent(target, eventName, handler, options) {
@@ -27895,6 +28274,7 @@ var PanSession = class {
27895
28274
  this.startEvent = null;
27896
28275
  this.lastMoveEvent = null;
27897
28276
  this.lastMoveEventInfo = null;
28277
+ this.lastRawMoveEventInfo = null;
27898
28278
  this.handlers = {};
27899
28279
  this.contextWindow = window;
27900
28280
  this.scrollPositions = /* @__PURE__ */ new Map();
@@ -27908,6 +28288,9 @@ var PanSession = class {
27908
28288
  this.updatePoint = () => {
27909
28289
  if (!(this.lastMoveEvent && this.lastMoveEventInfo))
27910
28290
  return;
28291
+ if (this.lastRawMoveEventInfo) {
28292
+ this.lastMoveEventInfo = transformPoint(this.lastRawMoveEventInfo, this.transformPagePoint);
28293
+ }
27911
28294
  const info2 = getPanInfo(this.lastMoveEventInfo, this.history);
27912
28295
  const isPanStarted = this.startEvent !== null;
27913
28296
  const isDistancePastThreshold = distance2D(info2.offset, { x: 0, y: 0 }) >= this.distanceThreshold;
@@ -27925,6 +28308,7 @@ var PanSession = class {
27925
28308
  };
27926
28309
  this.handlePointerMove = (event2, info2) => {
27927
28310
  this.lastMoveEvent = event2;
28311
+ this.lastRawMoveEventInfo = info2;
27928
28312
  this.lastMoveEventInfo = transformPoint(info2, this.transformPagePoint);
27929
28313
  frame.update(this.updatePoint, true);
27930
28314
  };
@@ -27981,12 +28365,9 @@ var PanSession = class {
27981
28365
  y: window.scrollY
27982
28366
  });
27983
28367
  window.addEventListener("scroll", this.onElementScroll, {
27984
- capture: true,
27985
- passive: true
27986
- });
27987
- window.addEventListener("scroll", this.onWindowScroll, {
27988
- passive: true
28368
+ capture: true
27989
28369
  });
28370
+ window.addEventListener("scroll", this.onWindowScroll);
27990
28371
  this.removeScrollListeners = () => {
27991
28372
  window.removeEventListener("scroll", this.onElementScroll, {
27992
28373
  capture: true
@@ -28073,6 +28454,9 @@ function getVelocity(history, timeDelta) {
28073
28454
  if (!timestampedPoint) {
28074
28455
  return { x: 0, y: 0 };
28075
28456
  }
28457
+ if (timestampedPoint === history[0] && history.length > 2 && lastPoint.timestamp - timestampedPoint.timestamp > secondsToMilliseconds(timeDelta) * 2) {
28458
+ timestampedPoint = history[1];
28459
+ }
28076
28460
  const time2 = millisecondsToSeconds(lastPoint.timestamp - timestampedPoint.timestamp);
28077
28461
  if (time2 === 0) {
28078
28462
  return { x: 0, y: 0 };
@@ -28189,14 +28573,11 @@ var VisualElementDragControls = class {
28189
28573
  return;
28190
28574
  const onSessionStart = (event) => {
28191
28575
  if (snapToCursor) {
28192
- this.stopAnimation();
28193
28576
  this.snapToCursor(extractEventInfo(event).point);
28194
- } else {
28195
- this.pauseAnimation();
28196
28577
  }
28578
+ this.stopAnimation();
28197
28579
  };
28198
28580
  const onStart = (event, info) => {
28199
- this.stopAnimation();
28200
28581
  const { drag: drag2, dragPropagation, onDragStart } = this.getProps();
28201
28582
  if (drag2 && !dragPropagation) {
28202
28583
  if (this.openDragLock)
@@ -28263,7 +28644,12 @@ var VisualElementDragControls = class {
28263
28644
  this.latestPointerEvent = null;
28264
28645
  this.latestPanInfo = null;
28265
28646
  };
28266
- const resumeAnimation = () => eachAxis((axis) => this.getAnimationState(axis) === "paused" && this.getAxisMotionValue(axis).animation?.play());
28647
+ const resumeAnimation = () => {
28648
+ const { dragSnapToOrigin: snap } = this.getProps();
28649
+ if (snap || this.constraints) {
28650
+ this.startAnimation({ x: 0, y: 0 });
28651
+ }
28652
+ };
28267
28653
  const { dragSnapToOrigin } = this.getProps();
28268
28654
  this.panSession = new PanSession(originEvent, {
28269
28655
  onSessionStart,
@@ -28350,7 +28736,7 @@ var VisualElementDragControls = class {
28350
28736
  }
28351
28737
  }
28352
28738
  this.elastic = resolveDragElastic(dragElastic);
28353
- if (prevConstraints !== this.constraints && layout2 && this.constraints && !this.hasMutatedConstraints) {
28739
+ if (prevConstraints !== this.constraints && !isRefObject(dragConstraints) && layout2 && this.constraints && !this.hasMutatedConstraints) {
28354
28740
  eachAxis((axis) => {
28355
28741
  if (this.constraints !== false && this.getAxisMotionValue(axis)) {
28356
28742
  this.constraints[axis] = rebaseAxisConstraints(layout2.layoutBox[axis], this.constraints[axis]);
@@ -28386,7 +28772,7 @@ var VisualElementDragControls = class {
28386
28772
  return;
28387
28773
  }
28388
28774
  let transition = constraints && constraints[axis] || {};
28389
- if (dragSnapToOrigin)
28775
+ if (dragSnapToOrigin === true || dragSnapToOrigin === axis)
28390
28776
  transition = { min: 0, max: 0 };
28391
28777
  const bounceStiffness = dragElastic ? 200 : 1e6;
28392
28778
  const bounceDamping = dragElastic ? 40 : 1e7;
@@ -28413,12 +28799,6 @@ var VisualElementDragControls = class {
28413
28799
  stopAnimation() {
28414
28800
  eachAxis((axis) => this.getAxisMotionValue(axis).stop());
28415
28801
  }
28416
- pauseAnimation() {
28417
- eachAxis((axis) => this.getAxisMotionValue(axis).animation?.pause());
28418
- }
28419
- getAnimationState(axis) {
28420
- return this.getAxisMotionValue(axis).animation?.state;
28421
- }
28422
28802
  /**
28423
28803
  * Drag works differently depending on which props are provided.
28424
28804
  *
@@ -28470,6 +28850,7 @@ var VisualElementDragControls = class {
28470
28850
  this.visualElement.current.style.transform = transformTemplate ? transformTemplate({}, "") : "none";
28471
28851
  projection.root && projection.root.updateScroll();
28472
28852
  projection.updateLayout();
28853
+ this.constraints = false;
28473
28854
  this.resolveConstraints();
28474
28855
  eachAxis((axis) => {
28475
28856
  if (!shouldDrag(axis, drag2, null))
@@ -28478,6 +28859,7 @@ var VisualElementDragControls = class {
28478
28859
  const { min, max } = this.constraints[axis];
28479
28860
  axisValue.set(mixNumber(min, max, boxProgress[axis]));
28480
28861
  });
28862
+ this.visualElement.render();
28481
28863
  }
28482
28864
  addListeners() {
28483
28865
  if (!this.visualElement.current)
@@ -28492,10 +28874,14 @@ var VisualElementDragControls = class {
28492
28874
  this.start(event);
28493
28875
  }
28494
28876
  });
28877
+ let stopResizeObservers;
28495
28878
  const measureDragConstraints = () => {
28496
28879
  const { dragConstraints } = this.getProps();
28497
28880
  if (isRefObject(dragConstraints) && dragConstraints.current) {
28498
28881
  this.constraints = this.resolveRefConstraints();
28882
+ if (!stopResizeObservers) {
28883
+ stopResizeObservers = startResizeObservers(element, dragConstraints.current, () => this.scalePositionWithinConstraints());
28884
+ }
28499
28885
  }
28500
28886
  };
28501
28887
  const { projection } = this.visualElement;
@@ -28523,6 +28909,7 @@ var VisualElementDragControls = class {
28523
28909
  stopPointerListener();
28524
28910
  stopMeasureLayoutListener();
28525
28911
  stopLayoutUpdateListener && stopLayoutUpdateListener();
28912
+ stopResizeObservers && stopResizeObservers();
28526
28913
  };
28527
28914
  }
28528
28915
  getProps() {
@@ -28539,6 +28926,24 @@ var VisualElementDragControls = class {
28539
28926
  };
28540
28927
  }
28541
28928
  };
28929
+ function skipFirstCall(callback) {
28930
+ let isFirst = true;
28931
+ return () => {
28932
+ if (isFirst) {
28933
+ isFirst = false;
28934
+ return;
28935
+ }
28936
+ callback();
28937
+ };
28938
+ }
28939
+ function startResizeObservers(element, constraintsElement, onResize) {
28940
+ const stopElement = resize(element, skipFirstCall(onResize));
28941
+ const stopContainer = resize(constraintsElement, skipFirstCall(onResize));
28942
+ return () => {
28943
+ stopElement();
28944
+ stopContainer();
28945
+ };
28946
+ }
28542
28947
  function shouldDrag(direction, drag2, currentDirection) {
28543
28948
  return (drag2 === true || drag2 === direction) && (currentDirection === null || currentDirection === direction);
28544
28949
  }
@@ -28691,8 +29096,10 @@ var MeasureLayoutWithContext = class extends React5.Component {
28691
29096
  return null;
28692
29097
  }
28693
29098
  componentDidUpdate() {
28694
- const { projection } = this.props.visualElement;
29099
+ const { visualElement, layoutAnchor } = this.props;
29100
+ const { projection } = visualElement;
28695
29101
  if (projection) {
29102
+ projection.options.layoutAnchor = layoutAnchor;
28696
29103
  projection.root.didUpdate();
28697
29104
  microtask.postRender(() => {
28698
29105
  if (!projection.currentAnimation && projection.isLead()) {
@@ -28816,10 +29223,14 @@ var PressGesture = class extends Feature {
28816
29223
  const { current } = this.node;
28817
29224
  if (!current)
28818
29225
  return;
29226
+ const { globalTapTarget, propagate } = this.node.props;
28819
29227
  this.unmount = press(current, (_element, startEvent) => {
28820
29228
  handlePressEvent(this.node, startEvent, "Start");
28821
29229
  return (endEvent, { success }) => handlePressEvent(this.node, endEvent, success ? "End" : "Cancel");
28822
- }, { useGlobalTarget: this.node.props.globalTapTarget });
29230
+ }, {
29231
+ useGlobalTarget: globalTapTarget,
29232
+ stopPropagation: propagate?.tap === false
29233
+ });
28823
29234
  }
28824
29235
  unmount() {
28825
29236
  }
@@ -28869,7 +29280,7 @@ var InViewFeature = class extends Feature {
28869
29280
  this.isInView = false;
28870
29281
  }
28871
29282
  startObserver() {
28872
- this.unmount();
29283
+ this.stopObserver?.();
28873
29284
  const { viewport = {} } = this.node.getProps();
28874
29285
  const { root, margin: rootMargin, amount = "some", once } = viewport;
28875
29286
  const options = {
@@ -28894,7 +29305,7 @@ var InViewFeature = class extends Feature {
28894
29305
  const callback = isIntersecting ? onViewportEnter : onViewportLeave;
28895
29306
  callback && callback(entry);
28896
29307
  };
28897
- return observeIntersection(this.node.current, options, onIntersectionUpdate);
29308
+ this.stopObserver = observeIntersection(this.node.current, options, onIntersectionUpdate);
28898
29309
  }
28899
29310
  mount() {
28900
29311
  this.startObserver();
@@ -28909,6 +29320,9 @@ var InViewFeature = class extends Feature {
28909
29320
  }
28910
29321
  }
28911
29322
  unmount() {
29323
+ this.stopObserver?.();
29324
+ this.hasEnteredView = false;
29325
+ this.isInView = false;
28912
29326
  }
28913
29327
  };
28914
29328
  function hasViewportOptionChanged({ viewport = {} }, { viewport: prevViewport = {} } = {}) {
@@ -29216,13 +29630,148 @@ function NavigationMenuIndicator({
29216
29630
  }
29217
29631
  );
29218
29632
  }
29633
+ var navigationMenuMainNavigationSurfaceStyles = classVarianceAuthority.cva("", {
29634
+ variants: {
29635
+ variant: {
29636
+ primary: "bg-primary-800 dark:bg-primary-900",
29637
+ secondary: "bg-[#f5f2ff] dark:bg-[#261447]",
29638
+ tertiary: "bg-primary-600 dark:bg-primary-700",
29639
+ white: "bg-white dark:bg-grey-950",
29640
+ grey: "bg-grey-100 dark:bg-grey-900"
29641
+ }
29642
+ },
29643
+ defaultVariants: {
29644
+ variant: "grey"
29645
+ }
29646
+ });
29647
+ var navigationMenuMainNavigationBorderStyles = classVarianceAuthority.cva("", {
29648
+ variants: {
29649
+ variant: {
29650
+ primary: "border-primary-700 dark:border-primary-600",
29651
+ secondary: "border-[#d9ccff] dark:border-[#4e3a86]",
29652
+ tertiary: "border-primary-500 dark:border-primary-600",
29653
+ white: "border-grey-200 dark:border-grey-800",
29654
+ grey: "border-grey-200 dark:border-grey-800"
29655
+ }
29656
+ },
29657
+ defaultVariants: {
29658
+ variant: "grey"
29659
+ }
29660
+ });
29661
+ var navigationMenuMainNavigationTriggerToneStyles = classVarianceAuthority.cva("", {
29662
+ variants: {
29663
+ variant: {
29664
+ primary: "text-white dark:text-primary-50",
29665
+ secondary: "text-primary-800 dark:text-primary-100",
29666
+ tertiary: "text-white dark:text-primary-50",
29667
+ white: "text-grey-900 dark:text-white",
29668
+ grey: "text-grey-800 dark:text-grey-100"
29669
+ }
29670
+ },
29671
+ defaultVariants: {
29672
+ variant: "grey"
29673
+ }
29674
+ });
29675
+ var navigationMenuMainNavigationTriggerActiveStyles = classVarianceAuthority.cva("", {
29676
+ variants: {
29677
+ variant: {
29678
+ primary: "hover:bg-primary-700 hover:text-white focus:bg-primary-700 focus:text-white data-[state=open]:bg-primary-700 data-[state=open]:text-white dark:hover:bg-primary-800 dark:hover:text-white dark:focus:bg-primary-800 dark:focus:text-white dark:data-[state=open]:bg-primary-800 dark:data-[state=open]:text-white",
29679
+ secondary: "hover:bg-[#e8e2ff] hover:text-primary-800 focus:bg-[#e8e2ff] focus:text-primary-800 data-[state=open]:bg-[#e8e2ff] data-[state=open]:text-primary-800 dark:hover:bg-[#32205a] dark:hover:text-primary-200 dark:focus:bg-[#32205a] dark:focus:text-primary-200 dark:data-[state=open]:bg-[#32205a] dark:data-[state=open]:text-primary-200",
29680
+ tertiary: "hover:bg-primary-500 hover:text-white focus:bg-primary-500 focus:text-white data-[state=open]:bg-primary-500 data-[state=open]:text-white dark:hover:bg-primary-600 dark:hover:text-white dark:focus:bg-primary-600 dark:focus:text-white dark:data-[state=open]:bg-primary-600 dark:data-[state=open]:text-white",
29681
+ white: "hover:bg-grey-100 hover:text-primary-800 focus:bg-grey-100 focus:text-primary-800 data-[state=open]:bg-grey-100 data-[state=open]:text-primary-800 dark:hover:bg-grey-800 dark:hover:text-primary-200 dark:focus:bg-grey-800 dark:focus:text-primary-200 dark:data-[state=open]:bg-grey-800 dark:data-[state=open]:text-primary-200",
29682
+ grey: "hover:bg-grey-200 hover:text-primary-800 focus:bg-grey-200 focus:text-primary-800 data-[state=open]:bg-grey-200 data-[state=open]:text-primary-800 dark:hover:bg-grey-800 dark:hover:text-primary-200 dark:focus:bg-grey-800 dark:focus:text-primary-200 dark:data-[state=open]:bg-grey-800 dark:data-[state=open]:text-primary-200"
29683
+ }
29684
+ },
29685
+ defaultVariants: {
29686
+ variant: "grey"
29687
+ }
29688
+ });
29689
+ var navigationMenuMainNavigationTriggerEdgeStyles = classVarianceAuthority.cva("", {
29690
+ variants: {
29691
+ variant: {
29692
+ primary: "hover:before:bg-primary-700 hover:after:bg-primary-700 focus:before:bg-primary-700 focus:after:bg-primary-700 data-[state=open]:before:bg-primary-700 data-[state=open]:after:bg-primary-700 dark:hover:before:bg-primary-800 dark:hover:after:bg-primary-800 dark:focus:before:bg-primary-800 dark:focus:after:bg-primary-800 dark:data-[state=open]:before:bg-primary-800 dark:data-[state=open]:after:bg-primary-800",
29693
+ secondary: "hover:before:bg-[#e8e2ff] hover:after:bg-[#e8e2ff] focus:before:bg-[#e8e2ff] focus:after:bg-[#e8e2ff] data-[state=open]:before:bg-[#e8e2ff] data-[state=open]:after:bg-[#e8e2ff] dark:hover:before:bg-[#32205a] dark:hover:after:bg-[#32205a] dark:focus:before:bg-[#32205a] dark:focus:after:bg-[#32205a] dark:data-[state=open]:before:bg-[#32205a] dark:data-[state=open]:after:bg-[#32205a]",
29694
+ tertiary: "hover:before:bg-primary-500 hover:after:bg-primary-500 focus:before:bg-primary-500 focus:after:bg-primary-500 data-[state=open]:before:bg-primary-500 data-[state=open]:after:bg-primary-500 dark:hover:before:bg-primary-600 dark:hover:after:bg-primary-600 dark:focus:before:bg-primary-600 dark:focus:after:bg-primary-600 dark:data-[state=open]:before:bg-primary-600 dark:data-[state=open]:after:bg-primary-600",
29695
+ white: "hover:before:bg-grey-100 hover:after:bg-grey-100 focus:before:bg-grey-100 focus:after:bg-grey-100 data-[state=open]:before:bg-grey-100 data-[state=open]:after:bg-grey-100 dark:hover:before:bg-grey-800 dark:hover:after:bg-grey-800 dark:focus:before:bg-grey-800 dark:focus:after:bg-grey-800 dark:data-[state=open]:before:bg-grey-800 dark:data-[state=open]:after:bg-grey-800",
29696
+ grey: "hover:before:bg-grey-200 hover:after:bg-grey-200 focus:before:bg-grey-200 focus:after:bg-grey-200 data-[state=open]:before:bg-grey-200 data-[state=open]:after:bg-grey-200 dark:hover:before:bg-grey-800 dark:hover:after:bg-grey-800 dark:focus:before:bg-grey-800 dark:focus:after:bg-grey-800 dark:data-[state=open]:before:bg-grey-800 dark:data-[state=open]:after:bg-grey-800"
29697
+ }
29698
+ },
29699
+ defaultVariants: {
29700
+ variant: "grey"
29701
+ }
29702
+ });
29703
+ var navigationMenuMainNavigationDropdownSurfaceStyles = classVarianceAuthority.cva(
29704
+ "w-full shadow dark:shadow-black/40",
29705
+ {
29706
+ variants: {
29707
+ variant: {
29708
+ primary: "bg-white dark:bg-grey-950",
29709
+ secondary: "bg-white dark:bg-grey-900",
29710
+ tertiary: "bg-white dark:bg-grey-950",
29711
+ white: "bg-white dark:bg-grey-950",
29712
+ grey: "bg-white dark:bg-grey-950"
29713
+ }
29714
+ },
29715
+ defaultVariants: {
29716
+ variant: "grey"
29717
+ }
29718
+ }
29719
+ );
29720
+ var navigationMenuMainNavigationFeaturedLinkStyles = classVarianceAuthority.cva(
29721
+ "group relative flex items-center px-8 py-8 text-xl font-bold whitespace-normal",
29722
+ {
29723
+ variants: {
29724
+ variant: {
29725
+ primary: "text-primary-800 hover:bg-primary-800/8 dark:text-primary-200 dark:hover:bg-primary-900/80",
29726
+ secondary: "text-primary-800 hover:bg-[#f5f2ff] dark:text-primary-200 dark:hover:bg-[#32205a]/70",
29727
+ tertiary: "text-primary-700 hover:bg-primary-100 dark:text-primary-200 dark:hover:bg-primary-900/70",
29728
+ white: "text-primary-800 hover:bg-grey-100 dark:text-primary-200 dark:hover:bg-grey-800/80",
29729
+ grey: "text-primary-800 hover:bg-grey-100 dark:text-primary-200 dark:hover:bg-grey-800/80"
29730
+ }
29731
+ },
29732
+ defaultVariants: {
29733
+ variant: "grey"
29734
+ }
29735
+ }
29736
+ );
29737
+ var navigationMenuMainNavigationSectionLinkStyles = classVarianceAuthority.cva(
29738
+ "relative mx-2 rounded-none border-t p-4 whitespace-normal focus-within:rounded-sm focus-within:outline focus-within:outline-inherit [&:nth-last-child(-n+3)]:border-b",
29739
+ {
29740
+ variants: {
29741
+ variant: {
29742
+ primary: "border-primary-100 bg-white hover:bg-primary-50 hover:font-bold hover:text-primary-800 dark:border-primary-900 dark:bg-grey-950 dark:hover:bg-primary-900/60 dark:hover:text-primary-200",
29743
+ secondary: "border-[#ece3ff] bg-white hover:bg-[#f8f4ff] hover:font-bold hover:text-primary-800 dark:border-[#45356e] dark:bg-grey-900 dark:hover:bg-[#32205a]/60 dark:hover:text-primary-200",
29744
+ tertiary: "border-primary-100 bg-white hover:bg-primary-50 hover:font-bold hover:text-primary-700 dark:border-primary-900 dark:bg-grey-950 dark:hover:bg-primary-900/60 dark:hover:text-primary-200",
29745
+ white: "border-grey-200 bg-white hover:bg-grey-50 hover:font-bold hover:text-primary-800 dark:border-grey-800 dark:bg-grey-950 dark:hover:bg-grey-800/80 dark:hover:text-primary-200",
29746
+ grey: "border-grey-200 bg-white hover:bg-grey-50 hover:font-bold hover:text-primary-800 dark:border-grey-800 dark:bg-grey-950 dark:hover:bg-grey-800/80 dark:hover:text-primary-200"
29747
+ }
29748
+ },
29749
+ defaultVariants: {
29750
+ variant: "grey"
29751
+ }
29752
+ }
29753
+ );
29754
+ var navigationMenuMainNavigationSectionLinkTitleStyles = classVarianceAuthority.cva("text-base font-semibold", {
29755
+ variants: {
29756
+ variant: {
29757
+ primary: "text-grey-900 dark:text-primary-50",
29758
+ secondary: "text-grey-900 dark:text-grey-100",
29759
+ tertiary: "text-grey-900 dark:text-primary-50",
29760
+ white: "text-grey-900 dark:text-white",
29761
+ grey: "text-grey-900 dark:text-grey-100"
29762
+ }
29763
+ },
29764
+ defaultVariants: {
29765
+ variant: "grey"
29766
+ }
29767
+ });
29219
29768
  var PANEL_CLOSE_DELAY_MS = 220;
29220
- var DEFAULT_TRIGGER_ACTIVE_CLASS_NAME = "hover:bg-primary-800/10 hover:text-primary-800 focus:bg-primary-800/10 focus:text-primary-800 data-[state=open]:bg-primary-800/10 data-[state=open]:text-primary-800 dark:hover:bg-primary-200/10 dark:hover:text-primary-200 dark:focus:bg-primary-200/10 dark:focus:text-primary-200 dark:data-[state=open]:bg-primary-200/10 dark:data-[state=open]:text-primary-200";
29221
- var DEFAULT_TRIGGER_ACTIVE_BORDER_CLASS_NAME = "hover:before:bg-primary-800/10 hover:after:bg-primary-800/10 focus:before:bg-primary-800/10 focus:after:bg-primary-800/10 data-[state=open]:before:bg-primary-800/10 dark:hover:before:bg-primary-200/10 dark:hover:after:bg-primary-200/10 dark:focus:before:bg-primary-200/10 dark:focus:after:bg-primary-200/10 dark:data-[state=open]:before:bg-primary-200/10";
29222
29769
  function TopLevelItem({
29223
29770
  href = "#",
29224
29771
  title,
29772
+ variant,
29225
29773
  syncBorderToSurface,
29774
+ triggerClassName,
29226
29775
  triggerActiveClassName,
29227
29776
  triggerActiveBorderClassName
29228
29777
  }) {
@@ -29231,21 +29780,30 @@ function TopLevelItem({
29231
29780
  {
29232
29781
  asChild: true,
29233
29782
  className: cn(
29234
- "relative inline-flex min-h-14 h-auto w-auto flex-row items-center justify-start gap-x-1 rounded-none bg-transparent p-4 text-base leading-6 font-bold text-grey-800 transition dark:text-grey-100 lg:px-8",
29235
- triggerActiveClassName ?? DEFAULT_TRIGGER_ACTIVE_CLASS_NAME,
29783
+ "relative inline-flex h-auto min-h-14 w-auto flex-row items-center justify-start gap-x-1 rounded-none bg-transparent p-4 text-base leading-6 font-bold transition lg:px-8",
29784
+ navigationMenuMainNavigationTriggerToneStyles({ variant }),
29785
+ navigationMenuMainNavigationTriggerActiveStyles({ variant }),
29786
+ triggerClassName,
29787
+ triggerActiveClassName,
29236
29788
  syncBorderToSurface && "before:absolute before:inset-x-0 before:top-0 before:h-px before:bg-transparent after:absolute after:inset-x-0 after:bottom-0 after:h-px after:bg-transparent",
29237
- syncBorderToSurface && (triggerActiveBorderClassName ?? DEFAULT_TRIGGER_ACTIVE_BORDER_CLASS_NAME)
29789
+ syncBorderToSurface && navigationMenuMainNavigationTriggerEdgeStyles({ variant }),
29790
+ syncBorderToSurface && triggerActiveBorderClassName
29238
29791
  ),
29239
29792
  children: /* @__PURE__ */ jsxRuntime.jsx(Link14__default.default, { href, children: title })
29240
29793
  }
29241
29794
  ) });
29242
29795
  }
29243
- function FeaturedSectionLink({ href = "#", title }) {
29796
+ function FeaturedSectionLink({
29797
+ href = "#",
29798
+ title,
29799
+ variant,
29800
+ className
29801
+ }) {
29244
29802
  return /* @__PURE__ */ jsxRuntime.jsxs(
29245
29803
  Link14__default.default,
29246
29804
  {
29247
29805
  href,
29248
- className: "group relative flex items-center px-8 py-8 text-xl font-bold whitespace-normal text-primary-800 hover:bg-primary-800/10 dark:text-primary-200 dark:hover:bg-primary-200/10",
29806
+ className: cn(navigationMenuMainNavigationFeaturedLinkStyles({ variant }), className),
29249
29807
  children: [
29250
29808
  /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", className: "absolute inset-0" }),
29251
29809
  title,
@@ -29254,33 +29812,47 @@ function FeaturedSectionLink({ href = "#", title }) {
29254
29812
  }
29255
29813
  );
29256
29814
  }
29257
- function SectionLink({ link }) {
29815
+ function SectionLink({
29816
+ link,
29817
+ variant,
29818
+ className,
29819
+ titleClassName
29820
+ }) {
29258
29821
  return /* @__PURE__ */ jsxRuntime.jsx(
29259
29822
  NavigationMenuLink,
29260
29823
  {
29261
29824
  asChild: true,
29262
- className: cn(
29263
- "relative mx-2 rounded-none border-t border-grey-200 bg-white p-4 hover:bg-primary-800/10 hover:font-bold hover:text-primary-800 dark:border-grey-700 dark:bg-grey-900 dark:hover:bg-primary-200/10 dark:hover:text-primary-200",
29264
- "[&:nth-last-child(-n+3)]:border-b",
29265
- "whitespace-normal",
29266
- "focus-within:rounded-sm focus-within:outline focus-within:outline-inherit"
29267
- ),
29825
+ className: cn(navigationMenuMainNavigationSectionLinkStyles({ variant }), className),
29268
29826
  children: /* @__PURE__ */ jsxRuntime.jsxs(Link14__default.default, { href: link.href, className: "outline-none", children: [
29269
29827
  /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", className: "absolute inset-0" }),
29270
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-base font-semibold text-grey-900 dark:text-grey-100", children: link.title })
29828
+ /* @__PURE__ */ jsxRuntime.jsx(
29829
+ "span",
29830
+ {
29831
+ className: cn(
29832
+ navigationMenuMainNavigationSectionLinkTitleStyles({ variant }),
29833
+ titleClassName
29834
+ ),
29835
+ children: link.title
29836
+ }
29837
+ )
29271
29838
  ] })
29272
29839
  }
29273
29840
  );
29274
29841
  }
29275
29842
  function MegaNavigationItem({
29276
29843
  section,
29844
+ variant,
29277
29845
  fullBleed,
29278
29846
  panelMetrics,
29279
29847
  onOpenIntent,
29280
29848
  dropdownBackgroundClassName,
29281
29849
  syncBorderToSurface,
29850
+ triggerClassName,
29282
29851
  triggerActiveClassName,
29283
- triggerActiveBorderClassName
29852
+ triggerActiveBorderClassName,
29853
+ featuredLinkClassName,
29854
+ sectionLinkClassName,
29855
+ sectionLinkTitleClassName
29284
29856
  }) {
29285
29857
  if (!section.links?.length) {
29286
29858
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -29288,7 +29860,9 @@ function MegaNavigationItem({
29288
29860
  {
29289
29861
  href: section.href,
29290
29862
  title: section.title,
29863
+ variant,
29291
29864
  syncBorderToSurface,
29865
+ triggerClassName,
29292
29866
  triggerActiveClassName,
29293
29867
  triggerActiveBorderClassName
29294
29868
  }
@@ -29299,11 +29873,15 @@ function MegaNavigationItem({
29299
29873
  NavigationMenuTrigger,
29300
29874
  {
29301
29875
  className: cn(
29302
- "relative mb-0 min-h-14 h-auto w-auto justify-start rounded-none bg-transparent p-4 text-base leading-6 font-bold text-grey-800 lg:px-8 dark:text-grey-100 [&_svg]:h-6 [&_svg]:w-6",
29303
- triggerActiveClassName ?? DEFAULT_TRIGGER_ACTIVE_CLASS_NAME,
29876
+ "relative mb-0 h-auto min-h-14 w-auto justify-start rounded-none bg-transparent p-4 text-base leading-6 font-bold lg:px-8 [&_svg]:h-6 [&_svg]:w-6",
29877
+ navigationMenuMainNavigationTriggerToneStyles({ variant }),
29878
+ navigationMenuMainNavigationTriggerActiveStyles({ variant }),
29879
+ triggerClassName,
29880
+ triggerActiveClassName,
29304
29881
  "data-[state=open]:shadow-[inset_0_-2px_0_0_currentColor]",
29305
29882
  syncBorderToSurface && "before:absolute before:inset-x-0 before:top-0 before:h-px before:bg-transparent after:absolute after:inset-x-0 after:bottom-0 after:h-px after:bg-transparent",
29306
- syncBorderToSurface && (triggerActiveBorderClassName ?? DEFAULT_TRIGGER_ACTIVE_BORDER_CLASS_NAME)
29883
+ syncBorderToSurface && navigationMenuMainNavigationTriggerEdgeStyles({ variant }),
29884
+ syncBorderToSurface && triggerActiveBorderClassName
29307
29885
  ),
29308
29886
  onPointerEnter: onOpenIntent,
29309
29887
  children: section.title
@@ -29313,7 +29891,7 @@ function MegaNavigationItem({
29313
29891
  NavigationMenuContent,
29314
29892
  {
29315
29893
  className: cn(
29316
- "left-0 w-full p-0 pr-0 whitespace-normal md:w-full group-data-[viewport=false]/navigation-menu:mt-0 group-data-[viewport=false]/navigation-menu:rounded-none group-data-[viewport=false]/navigation-menu:border-0 group-data-[viewport=false]/navigation-menu:bg-transparent group-data-[viewport=false]/navigation-menu:shadow-none"
29894
+ "left-0 w-full p-0 pr-0 whitespace-normal group-data-[viewport=false]/navigation-menu:mt-0 group-data-[viewport=false]/navigation-menu:rounded-none group-data-[viewport=false]/navigation-menu:border-0 group-data-[viewport=false]/navigation-menu:bg-transparent group-data-[viewport=false]/navigation-menu:shadow-none md:w-full"
29317
29895
  ),
29318
29896
  style: fullBleed && panelMetrics ? {
29319
29897
  left: `${-panelMetrics.left}px`,
@@ -29324,8 +29902,8 @@ function MegaNavigationItem({
29324
29902
  "div",
29325
29903
  {
29326
29904
  className: cn(
29327
- "w-full shadow dark:shadow-black/40",
29328
- dropdownBackgroundClassName ?? "bg-white dark:bg-grey-900"
29905
+ navigationMenuMainNavigationDropdownSurfaceStyles({ variant }),
29906
+ dropdownBackgroundClassName
29329
29907
  ),
29330
29908
  children: /* @__PURE__ */ jsxRuntime.jsxs(
29331
29909
  "div",
@@ -29337,8 +29915,25 @@ function MegaNavigationItem({
29337
29915
  marginRight: "auto"
29338
29916
  } : void 0,
29339
29917
  children: [
29340
- /* @__PURE__ */ jsxRuntime.jsx(FeaturedSectionLink, { href: section.href, title: section.title }),
29341
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-1 overflow-hidden px-4 pb-12 sm:grid-cols-2 lg:grid-cols-3", children: section.links.map((link, index) => /* @__PURE__ */ jsxRuntime.jsx(SectionLink, { link }, `${link.title}-${link.href}-${index}`)) })
29918
+ /* @__PURE__ */ jsxRuntime.jsx(
29919
+ FeaturedSectionLink,
29920
+ {
29921
+ href: section.href,
29922
+ title: section.title,
29923
+ variant,
29924
+ className: featuredLinkClassName
29925
+ }
29926
+ ),
29927
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-1 overflow-hidden px-4 pb-12 sm:grid-cols-2 lg:grid-cols-3", children: section.links.map((link, index) => /* @__PURE__ */ jsxRuntime.jsx(
29928
+ SectionLink,
29929
+ {
29930
+ link,
29931
+ variant,
29932
+ className: sectionLinkClassName,
29933
+ titleClassName: sectionLinkTitleClassName
29934
+ },
29935
+ `${link.title}-${link.href}-${index}`
29936
+ )) })
29342
29937
  ]
29343
29938
  }
29344
29939
  )
@@ -29351,6 +29946,8 @@ function MegaNavigationItem({
29351
29946
  function NavigationMenuMainNavigation({
29352
29947
  navigation,
29353
29948
  id: id3 = "nsw-main-navigation",
29949
+ variant = "grey",
29950
+ borderPosition = "none",
29354
29951
  className,
29355
29952
  responsive = true,
29356
29953
  sticky = true,
@@ -29358,8 +29955,12 @@ function NavigationMenuMainNavigation({
29358
29955
  backgroundClassName,
29359
29956
  dropdownBackgroundClassName,
29360
29957
  borderClassName,
29958
+ triggerClassName,
29361
29959
  triggerActiveClassName,
29362
29960
  triggerActiveBorderClassName,
29961
+ featuredLinkClassName,
29962
+ sectionLinkClassName,
29963
+ sectionLinkTitleClassName,
29363
29964
  showTopBorder = false,
29364
29965
  showBottomBorder = false
29365
29966
  }) {
@@ -29367,14 +29968,19 @@ function NavigationMenuMainNavigation({
29367
29968
  const containerRef = React5__namespace.useRef(null);
29368
29969
  const closeTimerRef = React5__namespace.useRef(null);
29369
29970
  const [value, setValue] = React5__namespace.useState("");
29370
- const syncBorderToSurface = showTopBorder || showBottomBorder;
29971
+ const hasLegacyBorderProps = showTopBorder || showBottomBorder;
29972
+ const resolvedBorderPosition = borderPosition !== "none" ? borderPosition : showTopBorder && showBottomBorder ? "both" : showTopBorder ? "top" : showBottomBorder ? "bottom" : "none";
29973
+ const hasTopBorder = resolvedBorderPosition === "top" || resolvedBorderPosition === "both";
29974
+ const hasBottomBorder = resolvedBorderPosition === "bottom" || resolvedBorderPosition === "both";
29975
+ const hasBorder = hasTopBorder || hasBottomBorder;
29976
+ const syncBorderToSurface = hasBorder;
29371
29977
  const [panelMetrics, setPanelMetrics] = React5__namespace.useState({
29372
29978
  left: 0,
29373
29979
  width: 0,
29374
29980
  viewportWidth: 0
29375
29981
  });
29376
29982
  const cancelCloseTimer = React5__namespace.useCallback(() => {
29377
- if (closeTimerRef.current) {
29983
+ if (closeTimerRef.current !== null) {
29378
29984
  window.clearTimeout(closeTimerRef.current);
29379
29985
  closeTimerRef.current = null;
29380
29986
  }
@@ -29406,17 +30012,27 @@ function NavigationMenuMainNavigation({
29406
30012
  cancelCloseTimer();
29407
30013
  };
29408
30014
  }, [cancelCloseTimer]);
29409
- const handleValueChange = React5__namespace.useCallback((nextValue) => {
29410
- cancelCloseTimer();
29411
- if (nextValue) {
29412
- setValue(nextValue);
29413
- return;
30015
+ React5__namespace.useEffect(() => {
30016
+ if (process.env.NODE_ENV !== "production" && borderPosition !== "none" && hasLegacyBorderProps) {
30017
+ console.warn(
30018
+ "NavigationMenuMainNavigation: `borderPosition` overrides deprecated `showTopBorder` / `showBottomBorder` props."
30019
+ );
29414
30020
  }
29415
- closeTimerRef.current = window.setTimeout(() => {
29416
- setValue("");
29417
- closeTimerRef.current = null;
29418
- }, PANEL_CLOSE_DELAY_MS);
29419
- }, [cancelCloseTimer]);
30021
+ }, [borderPosition, hasLegacyBorderProps]);
30022
+ const handleValueChange = React5__namespace.useCallback(
30023
+ (nextValue) => {
30024
+ cancelCloseTimer();
30025
+ if (nextValue) {
30026
+ setValue(nextValue);
30027
+ return;
30028
+ }
30029
+ closeTimerRef.current = window.setTimeout(() => {
30030
+ setValue("");
30031
+ closeTimerRef.current = null;
30032
+ }, PANEL_CLOSE_DELAY_MS);
30033
+ },
30034
+ [cancelCloseTimer]
30035
+ );
29420
30036
  return /* @__PURE__ */ jsxRuntime.jsx(
29421
30037
  "nav",
29422
30038
  {
@@ -29425,10 +30041,12 @@ function NavigationMenuMainNavigation({
29425
30041
  id: id3,
29426
30042
  className: cn(
29427
30043
  "z-40 shadow-md shadow-grey-900/5 dark:shadow-none",
29428
- backgroundClassName ?? "bg-grey-100 dark:bg-grey-900",
29429
- (showTopBorder || showBottomBorder) && (borderClassName ?? "border-grey-200 dark:border-grey-800"),
29430
- showTopBorder && "border-t",
29431
- showBottomBorder && "border-b",
30044
+ navigationMenuMainNavigationSurfaceStyles({ variant }),
30045
+ backgroundClassName,
30046
+ hasBorder && navigationMenuMainNavigationBorderStyles({ variant }),
30047
+ hasBorder && borderClassName,
30048
+ hasTopBorder && "border-t",
30049
+ hasBottomBorder && "border-b",
29432
30050
  responsive ? "hidden sm:px-6 lg:block lg:px-4" : "block",
29433
30051
  sticky && "sticky",
29434
30052
  className
@@ -29451,13 +30069,18 @@ function NavigationMenuMainNavigation({
29451
30069
  MegaNavigationItem,
29452
30070
  {
29453
30071
  section,
30072
+ variant,
29454
30073
  fullBleed,
29455
30074
  panelMetrics,
29456
30075
  onOpenIntent: cancelCloseTimer,
29457
30076
  dropdownBackgroundClassName,
29458
30077
  syncBorderToSurface,
30078
+ triggerClassName,
29459
30079
  triggerActiveClassName,
29460
- triggerActiveBorderClassName
30080
+ triggerActiveBorderClassName,
30081
+ featuredLinkClassName,
30082
+ sectionLinkClassName,
30083
+ sectionLinkTitleClassName
29461
30084
  },
29462
30085
  `${section.title}-${section.href ?? "section"}`
29463
30086
  )) })
@@ -31848,7 +32471,7 @@ function useActiveSectionObserver(tableOfContents) {
31848
32471
  if (tableOfContents.length === 0) return;
31849
32472
  if (!headerHeight) return;
31850
32473
  const totalHeight = headerHeight + mastheadHeight + navigationHeight;
31851
- let observer = null;
32474
+ let observer2 = null;
31852
32475
  const initializeObserver = () => {
31853
32476
  const ids = tableOfContents.flatMap((node) => [
31854
32477
  node.id,
@@ -31860,7 +32483,7 @@ function useActiveSectionObserver(tableOfContents) {
31860
32483
  el.style.scrollMarginTop = `${totalHeight + 16}px`;
31861
32484
  }
31862
32485
  });
31863
- observer = new IntersectionObserver(
32486
+ observer2 = new IntersectionObserver(
31864
32487
  (entries) => {
31865
32488
  const visible = entries.filter((entry) => entry.isIntersecting).sort((a, b) => a.boundingClientRect.top - b.boundingClientRect.top);
31866
32489
  if (visible.length > 0) {
@@ -31874,14 +32497,14 @@ function useActiveSectionObserver(tableOfContents) {
31874
32497
  );
31875
32498
  ids.forEach((id3) => {
31876
32499
  const el = document.getElementById(id3);
31877
- if (el) observer.observe(el);
32500
+ if (el) observer2.observe(el);
31878
32501
  });
31879
32502
  };
31880
32503
  const raf = requestAnimationFrame(() => {
31881
32504
  initializeObserver();
31882
32505
  });
31883
32506
  return () => {
31884
- if (observer) observer.disconnect();
32507
+ if (observer2) observer2.disconnect();
31885
32508
  cancelAnimationFrame(raf);
31886
32509
  };
31887
32510
  }, [tableOfContents, headerHeight, mastheadHeight, navigationHeight]);