@moontra/moonui-pro 2.34.0 → 2.34.2

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.mjs CHANGED
@@ -16874,7 +16874,10 @@ var splashCursorVariants = cva(
16874
16874
  }
16875
16875
  }
16876
16876
  );
16877
- var SplashCursor = ({
16877
+ var calculateDistance = (x1, y1, x2, y2) => {
16878
+ return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
16879
+ };
16880
+ var SplashCursorComponent = ({
16878
16881
  size: size4 = "md",
16879
16882
  variant = "default",
16880
16883
  duration = 600,
@@ -16890,46 +16893,63 @@ var SplashCursor = ({
16890
16893
  containerRef
16891
16894
  }) => {
16892
16895
  const [splashes, setSplashes] = useState([]);
16893
- const [cursorPos, setCursorPos] = useState({ x: 0, y: 0 });
16894
- const lastMoveTime = useRef(Date.now());
16895
- const lastPos = useRef({ x: 0, y: 0 });
16896
+ const lastMoveTimeRef = useRef(Date.now());
16897
+ const lastPosRef = useRef({ x: 0, y: 0 });
16896
16898
  const audioRef = useRef(null);
16899
+ const rafIdRef = useRef(null);
16900
+ const lastSplashTimeRef = useRef(0);
16901
+ const splashTimersRef = useRef(/* @__PURE__ */ new Set());
16897
16902
  useEffect(() => {
16898
- if (soundUrl) {
16899
- audioRef.current = new Audio(soundUrl);
16900
- audioRef.current.volume = 0.3;
16903
+ if (soundUrl && !audioRef.current) {
16904
+ const audio = new Audio(soundUrl);
16905
+ audio.volume = 0.3;
16906
+ audioRef.current = audio;
16901
16907
  }
16908
+ return () => {
16909
+ if (audioRef.current) {
16910
+ audioRef.current = null;
16911
+ }
16912
+ };
16902
16913
  }, [soundUrl]);
16903
- const calculateDistance = (x1, y1, x2, y2) => {
16904
- return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
16905
- };
16906
- const createSplash = (x, y) => {
16914
+ const cleanupSplash = useCallback((splashId) => {
16915
+ setSplashes((prev) => prev.filter((splash) => splash.id !== splashId));
16916
+ }, []);
16917
+ const createSplash = useCallback((x, y) => {
16918
+ const now = Date.now();
16919
+ if (now - lastSplashTimeRef.current < 16) {
16920
+ return;
16921
+ }
16922
+ lastSplashTimeRef.current = now;
16907
16923
  const newSplash = {
16908
- id: Date.now() + Math.random(),
16924
+ id: now + Math.random(),
16909
16925
  x,
16910
16926
  y,
16911
- timestamp: Date.now()
16927
+ timestamp: now
16912
16928
  };
16913
16929
  setSplashes((prev) => {
16914
- const updated = [...prev, newSplash];
16915
- if (updated.length > maxSplashes) {
16916
- return updated.slice(-maxSplashes);
16917
- }
16930
+ const updated = prev.length >= maxSplashes ? [...prev.slice(1), newSplash] : [...prev, newSplash];
16918
16931
  return updated;
16919
16932
  });
16920
16933
  if (audioRef.current) {
16921
- audioRef.current.currentTime = 0;
16922
- audioRef.current.play().catch(() => {
16923
- });
16934
+ try {
16935
+ const audioClone = audioRef.current.cloneNode();
16936
+ audioClone.volume = 0.3;
16937
+ audioClone.play().catch(() => {
16938
+ });
16939
+ setTimeout(() => audioClone.remove(), 1e3);
16940
+ } catch {
16941
+ }
16924
16942
  }
16925
- setTimeout(() => {
16926
- setSplashes((prev) => prev.filter((splash) => splash.id !== newSplash.id));
16943
+ const timer = setTimeout(() => {
16944
+ cleanupSplash(newSplash.id);
16945
+ splashTimersRef.current.delete(timer);
16927
16946
  }, duration);
16928
- };
16929
- useEffect(() => {
16930
- if (!enabled)
16947
+ splashTimersRef.current.add(timer);
16948
+ }, [maxSplashes, duration, cleanupSplash]);
16949
+ const handleMouseMoveThrottled = useCallback((e) => {
16950
+ if (rafIdRef.current)
16931
16951
  return;
16932
- const handleMouseMove2 = (e) => {
16952
+ rafIdRef.current = requestAnimationFrame(() => {
16933
16953
  const container = containerRef?.current;
16934
16954
  let x = e.clientX;
16935
16955
  let y = e.clientY;
@@ -16938,24 +16958,24 @@ var SplashCursor = ({
16938
16958
  x = e.clientX - rect.left;
16939
16959
  y = e.clientY - rect.top;
16940
16960
  if (x < 0 || y < 0 || x > rect.width || y > rect.height) {
16961
+ rafIdRef.current = null;
16941
16962
  return;
16942
16963
  }
16943
16964
  }
16944
16965
  const now = Date.now();
16945
- const timeDiff = now - lastMoveTime.current;
16946
- const distance = calculateDistance(
16947
- lastPos.current.x,
16948
- lastPos.current.y,
16949
- x,
16950
- y
16951
- );
16952
- setCursorPos({ x, y });
16966
+ const timeDiff = now - lastMoveTimeRef.current;
16953
16967
  if (timeDiff > 0) {
16968
+ const distance = calculateDistance(
16969
+ lastPosRef.current.x,
16970
+ lastPosRef.current.y,
16971
+ x,
16972
+ y
16973
+ );
16954
16974
  const speed = distance / timeDiff;
16955
16975
  if (speed > threshold) {
16956
16976
  if (targetSelector) {
16957
16977
  const target = e.target;
16958
- if (target && target.closest(targetSelector)) {
16978
+ if (target?.closest(targetSelector)) {
16959
16979
  createSplash(x, y);
16960
16980
  }
16961
16981
  } else {
@@ -16963,39 +16983,52 @@ var SplashCursor = ({
16963
16983
  }
16964
16984
  }
16965
16985
  }
16966
- lastPos.current = { x, y };
16967
- lastMoveTime.current = now;
16968
- };
16969
- const handleClick2 = (e) => {
16970
- const container = containerRef?.current;
16971
- let x = e.clientX;
16972
- let y = e.clientY;
16973
- if (container) {
16974
- const rect = container.getBoundingClientRect();
16975
- x = e.clientX - rect.left;
16976
- y = e.clientY - rect.top;
16977
- if (x < 0 || y < 0 || x > rect.width || y > rect.height) {
16978
- return;
16979
- }
16986
+ lastPosRef.current = { x, y };
16987
+ lastMoveTimeRef.current = now;
16988
+ rafIdRef.current = null;
16989
+ });
16990
+ }, [threshold, targetSelector, createSplash, containerRef]);
16991
+ const handleClick2 = useCallback((e) => {
16992
+ const container = containerRef?.current;
16993
+ let x = e.clientX;
16994
+ let y = e.clientY;
16995
+ if (container) {
16996
+ const rect = container.getBoundingClientRect();
16997
+ x = e.clientX - rect.left;
16998
+ y = e.clientY - rect.top;
16999
+ if (x < 0 || y < 0 || x > rect.width || y > rect.height) {
17000
+ return;
16980
17001
  }
16981
- if (targetSelector) {
16982
- const target = e.target;
16983
- if (target && target.closest(targetSelector)) {
16984
- createSplash(x, y);
16985
- }
16986
- } else {
17002
+ }
17003
+ if (targetSelector) {
17004
+ const target = e.target;
17005
+ if (target?.closest(targetSelector)) {
16987
17006
  createSplash(x, y);
16988
17007
  }
16989
- };
17008
+ } else {
17009
+ createSplash(x, y);
17010
+ }
17011
+ }, [targetSelector, createSplash, containerRef]);
17012
+ useEffect(() => {
17013
+ if (!enabled)
17014
+ return;
16990
17015
  const targetElement = containerRef?.current || document;
16991
- targetElement.addEventListener("mousemove", handleMouseMove2);
16992
- targetElement.addEventListener("click", handleClick2);
17016
+ const moveHandler = handleMouseMoveThrottled;
17017
+ const clickHandler2 = handleClick2;
17018
+ targetElement.addEventListener("mousemove", moveHandler);
17019
+ targetElement.addEventListener("click", clickHandler2);
16993
17020
  return () => {
16994
- targetElement.removeEventListener("mousemove", handleMouseMove2);
16995
- targetElement.removeEventListener("click", handleClick2);
17021
+ targetElement.removeEventListener("mousemove", moveHandler);
17022
+ targetElement.removeEventListener("click", clickHandler2);
17023
+ if (rafIdRef.current) {
17024
+ cancelAnimationFrame(rafIdRef.current);
17025
+ rafIdRef.current = null;
17026
+ }
17027
+ splashTimersRef.current.forEach((timer) => clearTimeout(timer));
17028
+ splashTimersRef.current.clear();
16996
17029
  };
16997
- }, [enabled, threshold, targetSelector, duration, maxSplashes, containerRef]);
16998
- const getAnimationVariants = () => {
17030
+ }, [enabled, handleMouseMoveThrottled, handleClick2, containerRef]);
17031
+ const animationVariants2 = useMemo(() => {
16999
17032
  switch (animationType) {
17000
17033
  case "ripple":
17001
17034
  return {
@@ -17022,14 +17055,25 @@ var SplashCursor = ({
17022
17055
  exit: { scale: 3, opacity: 0 }
17023
17056
  };
17024
17057
  }
17025
- };
17026
- const animationVariants2 = getAnimationVariants();
17027
- const getColor = (index2) => {
17058
+ }, [animationType]);
17059
+ const getColor = useCallback((index2) => {
17028
17060
  if (colors && colors.length > 0) {
17029
17061
  return colors[index2 % colors.length];
17030
17062
  }
17031
17063
  return "";
17032
- };
17064
+ }, [colors]);
17065
+ const particleAngles = useMemo(() => {
17066
+ if (!showParticles)
17067
+ return [];
17068
+ return Array.from({ length: particleCount }).map((_, i) => {
17069
+ const angle = 360 / particleCount * i;
17070
+ const radian = angle * Math.PI / 180;
17071
+ return {
17072
+ x: Math.cos(radian) * 30,
17073
+ y: Math.sin(radian) * 30
17074
+ };
17075
+ });
17076
+ }, [showParticles, particleCount]);
17033
17077
  const { hasProAccess, isLoading } = useSubscription();
17034
17078
  if (!isLoading && !hasProAccess) {
17035
17079
  return /* @__PURE__ */ jsx(
@@ -17046,7 +17090,8 @@ var SplashCursor = ({
17046
17090
  return /* @__PURE__ */ jsx("div", { className: cn(
17047
17091
  "pointer-events-none z-[9999]",
17048
17092
  containerRef ? "absolute inset-0" : "fixed inset-0"
17049
- ), children: /* @__PURE__ */ jsx(AnimatePresence, { children: splashes.map((splash, index2) => /* @__PURE__ */ jsxs(React68__default.Fragment, { children: [
17093
+ ), children: /* @__PURE__ */ jsx(AnimatePresence, { mode: "popLayout", children: splashes.map((splash, index2) => [
17094
+ /* Ana splash efekti */
17050
17095
  /* @__PURE__ */ jsx(
17051
17096
  motion.div,
17052
17097
  {
@@ -17057,9 +17102,9 @@ var SplashCursor = ({
17057
17102
  style: {
17058
17103
  position: "absolute",
17059
17104
  left: splash.x - 12,
17060
- // Merkeze hizala
17061
17105
  top: splash.y - 12,
17062
- backgroundColor: getColor(index2) || void 0
17106
+ backgroundColor: getColor(index2) || void 0,
17107
+ willChange: "transform, opacity"
17063
17108
  },
17064
17109
  variants: animationVariants2,
17065
17110
  initial: "initial",
@@ -17069,43 +17114,37 @@ var SplashCursor = ({
17069
17114
  duration: duration / 1e3,
17070
17115
  ease: "easeOut"
17071
17116
  }
17072
- }
17117
+ },
17118
+ splash.id
17073
17119
  ),
17074
- showParticles && Array.from({ length: particleCount }).map((_, particleIndex) => {
17075
- const angle = 360 / particleCount * particleIndex;
17076
- const radian = angle * Math.PI / 180;
17077
- const distance = 30;
17078
- return /* @__PURE__ */ jsx(
17079
- motion.div,
17080
- {
17081
- className: "absolute w-1 h-1 bg-current rounded-full",
17082
- style: {
17083
- left: splash.x,
17084
- top: splash.y,
17085
- color: getColor(index2 + particleIndex) || "currentColor"
17086
- },
17087
- initial: {
17088
- x: 0,
17089
- y: 0,
17090
- opacity: 1,
17091
- scale: 1
17092
- },
17093
- animate: {
17094
- x: Math.cos(radian) * distance,
17095
- y: Math.sin(radian) * distance,
17096
- opacity: 0,
17097
- scale: 0
17098
- },
17099
- transition: {
17100
- duration: duration / 1e3,
17101
- ease: "easeOut"
17102
- }
17120
+ /* Optimized particle rendering */
17121
+ ...showParticles ? particleAngles.map((angle, particleIndex) => /* @__PURE__ */ jsx(
17122
+ motion.div,
17123
+ {
17124
+ className: "absolute w-1 h-1 bg-current rounded-full",
17125
+ style: {
17126
+ left: splash.x,
17127
+ top: splash.y,
17128
+ color: getColor(index2 + particleIndex) || "currentColor",
17129
+ willChange: "transform, opacity"
17103
17130
  },
17104
- `${splash.id}-particle-${particleIndex}`
17105
- );
17106
- })
17107
- ] }, splash.id)) }) });
17131
+ initial: { x: 0, y: 0, opacity: 1, scale: 1 },
17132
+ animate: {
17133
+ x: angle.x,
17134
+ y: angle.y,
17135
+ opacity: 0,
17136
+ scale: 0
17137
+ },
17138
+ transition: {
17139
+ duration: duration / 1e3,
17140
+ ease: "easeOut"
17141
+ }
17142
+ },
17143
+ `${splash.id}-p${particleIndex}`
17144
+ )) : []
17145
+ ]).flat() }) });
17108
17146
  };
17147
+ var SplashCursor = React68__default.memo(SplashCursorComponent);
17109
17148
  SplashCursor.displayName = "SplashCursor";
17110
17149
  var SplashCursorContainer = ({
17111
17150
  className,
@@ -29103,7 +29142,7 @@ var ViewDesc = class {
29103
29142
  if (!(force || brKludge && safari) && isEquivalentPosition(anchorDOM.node, anchorDOM.offset, selRange.anchorNode, selRange.anchorOffset) && isEquivalentPosition(headDOM.node, headDOM.offset, selRange.focusNode, selRange.focusOffset))
29104
29143
  return;
29105
29144
  let domSelExtended = false;
29106
- if ((domSel.extend || anchor == head) && !(brKludge && gecko)) {
29145
+ if ((domSel.extend || anchor == head) && !brKludge) {
29107
29146
  domSel.collapse(anchorDOM.node, anchorDOM.offset);
29108
29147
  try {
29109
29148
  if (anchor != head)
@@ -29486,18 +29525,17 @@ var NodeViewDesc = class extends ViewDesc {
29486
29525
  }
29487
29526
  // Mark this node as being the selected node.
29488
29527
  selectNode() {
29489
- if (this.nodeDOM.nodeType == 1) {
29528
+ if (this.nodeDOM.nodeType == 1)
29490
29529
  this.nodeDOM.classList.add("ProseMirror-selectednode");
29491
- if (this.contentDOM || !this.node.type.spec.draggable)
29492
- this.nodeDOM.draggable = true;
29493
- }
29530
+ if (this.contentDOM || !this.node.type.spec.draggable)
29531
+ this.dom.draggable = true;
29494
29532
  }
29495
29533
  // Remove selected node marking from this node.
29496
29534
  deselectNode() {
29497
29535
  if (this.nodeDOM.nodeType == 1) {
29498
29536
  this.nodeDOM.classList.remove("ProseMirror-selectednode");
29499
29537
  if (this.contentDOM || !this.node.type.spec.draggable)
29500
- this.nodeDOM.removeAttribute("draggable");
29538
+ this.dom.removeAttribute("draggable");
29501
29539
  }
29502
29540
  }
29503
29541
  get domAtom() {
@@ -30262,14 +30300,17 @@ function removeClassOnSelectionChange(view) {
30262
30300
  });
30263
30301
  }
30264
30302
  function selectCursorWrapper(view) {
30265
- let domSel = view.domSelection();
30303
+ let domSel = view.domSelection(), range = document.createRange();
30266
30304
  if (!domSel)
30267
30305
  return;
30268
30306
  let node = view.cursorWrapper.dom, img = node.nodeName == "IMG";
30269
30307
  if (img)
30270
- domSel.collapse(node.parentNode, domIndex(node) + 1);
30308
+ range.setStart(node.parentNode, domIndex(node) + 1);
30271
30309
  else
30272
- domSel.collapse(node, 0);
30310
+ range.setStart(node, 0);
30311
+ range.collapse(true);
30312
+ domSel.removeAllRanges();
30313
+ domSel.addRange(range);
30273
30314
  if (!img && !view.state.selection.visible && ie && ie_version <= 11) {
30274
30315
  node.disabled = true;
30275
30316
  node.disabled = false;
@@ -30679,18 +30720,13 @@ function parseFromClipboard(view, text, html, plainText, $context) {
30679
30720
  let dom, slice2;
30680
30721
  if (!html && !text)
30681
30722
  return null;
30682
- let asText = !!text && (plainText || inCode || !html);
30723
+ let asText = text && (plainText || inCode || !html);
30683
30724
  if (asText) {
30684
30725
  view.someProp("transformPastedText", (f) => {
30685
30726
  text = f(text, inCode || plainText, view);
30686
30727
  });
30687
- if (inCode) {
30688
- slice2 = new Slice(Fragment17.from(view.state.schema.text(text.replace(/\r\n?/g, "\n"))), 0, 0);
30689
- view.someProp("transformPasted", (f) => {
30690
- slice2 = f(slice2, view, true);
30691
- });
30692
- return slice2;
30693
- }
30728
+ if (inCode)
30729
+ return text ? new Slice(Fragment17.from(view.state.schema.text(text.replace(/\r\n?/g, "\n"))), 0, 0) : Slice.empty;
30694
30730
  let parsed = view.someProp("clipboardTextParser", (f) => f(text, $context, plainText, view));
30695
30731
  if (parsed) {
30696
30732
  slice2 = parsed;
@@ -30749,7 +30785,7 @@ function parseFromClipboard(view, text, html, plainText, $context) {
30749
30785
  }
30750
30786
  }
30751
30787
  view.someProp("transformPasted", (f) => {
30752
- slice2 = f(slice2, view, asText);
30788
+ slice2 = f(slice2, view);
30753
30789
  });
30754
30790
  return slice2;
30755
30791
  }
@@ -31159,7 +31195,7 @@ var MouseDown = class {
31159
31195
  }
31160
31196
  const target = flushed ? null : event.target;
31161
31197
  const targetDesc = target ? view.docView.nearestDesc(target, true) : null;
31162
- this.target = targetDesc && targetDesc.nodeDOM.nodeType == 1 ? targetDesc.nodeDOM : null;
31198
+ this.target = targetDesc && targetDesc.dom.nodeType == 1 ? targetDesc.dom : null;
31163
31199
  let { selection } = view.state;
31164
31200
  if (event.button == 0 && targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false || selection instanceof NodeSelection && selection.from <= targetPos && selection.to > targetPos)
31165
31201
  this.mightDrag = {
@@ -31505,7 +31541,7 @@ editHandlers.drop = (view, _event) => {
31505
31541
  let slice2 = dragging && dragging.slice;
31506
31542
  if (slice2) {
31507
31543
  view.someProp("transformPasted", (f) => {
31508
- slice2 = f(slice2, view, false);
31544
+ slice2 = f(slice2, view);
31509
31545
  });
31510
31546
  } else {
31511
31547
  slice2 = parseFromClipboard(view, getText(event.dataTransfer), brokenClipboardAPI ? null : event.dataTransfer.getData("text/html"), false, $mouse);
@@ -35336,8 +35372,10 @@ function selectionToInsertionEnd2(tr2, startLen, bias) {
35336
35372
  }
35337
35373
  var InputRule = class {
35338
35374
  constructor(config) {
35375
+ var _a2;
35339
35376
  this.find = config.find;
35340
35377
  this.handler = config.handler;
35378
+ this.undoable = (_a2 = config.undoable) != null ? _a2 : true;
35341
35379
  }
35342
35380
  };
35343
35381
  var inputRuleMatcherHandler = (text, find2) => {
@@ -35409,12 +35447,14 @@ function run(config) {
35409
35447
  if (handler === null || !tr2.steps.length) {
35410
35448
  return;
35411
35449
  }
35412
- tr2.setMeta(plugin, {
35413
- transform: tr2,
35414
- from: from2,
35415
- to,
35416
- text
35417
- });
35450
+ if (rule.undoable) {
35451
+ tr2.setMeta(plugin, {
35452
+ transform: tr2,
35453
+ from: from2,
35454
+ to,
35455
+ text
35456
+ });
35457
+ }
35418
35458
  view.dispatch(tr2);
35419
35459
  matched = true;
35420
35460
  });
@@ -35891,7 +35931,7 @@ var ExtensionManager = class {
35891
35931
  get plugins() {
35892
35932
  const { editor } = this;
35893
35933
  const extensions = sortExtensions([...this.extensions].reverse());
35894
- const allPlugins = extensions.map((extension) => {
35934
+ const allPlugins = extensions.flatMap((extension) => {
35895
35935
  const context = {
35896
35936
  name: extension.name,
35897
35937
  options: extension.options,
@@ -35949,7 +35989,7 @@ var ExtensionManager = class {
35949
35989
  plugins.push(...proseMirrorPlugins);
35950
35990
  }
35951
35991
  return plugins;
35952
- }).flat();
35992
+ });
35953
35993
  return allPlugins;
35954
35994
  }
35955
35995
  /**
@@ -37912,6 +37952,9 @@ var Editor = class extends EventEmitter {
37912
37952
  }
37913
37953
  this.createView(el);
37914
37954
  this.emit("mount", { editor: this });
37955
+ if (this.css && !document.head.contains(this.css)) {
37956
+ document.head.appendChild(this.css);
37957
+ }
37915
37958
  window.setTimeout(() => {
37916
37959
  if (this.isDestroyed) {
37917
37960
  return;
@@ -38027,7 +38070,7 @@ var Editor = class extends EventEmitter {
38027
38070
  this.editorState = state;
38028
38071
  },
38029
38072
  dispatch: (tr2) => {
38030
- this.editorState = this.state.apply(tr2);
38073
+ this.dispatchTransaction(tr2);
38031
38074
  },
38032
38075
  // Stub some commonly accessed properties to prevent errors
38033
38076
  composing: false,
@@ -38398,7 +38441,8 @@ function markInputRule(config) {
38398
38441
  tr2.addMark(range.from + startSpaces, markEnd, config.type.create(attributes || {}));
38399
38442
  tr2.removeStoredMark(config.type);
38400
38443
  }
38401
- }
38444
+ },
38445
+ undoable: config.undoable
38402
38446
  });
38403
38447
  }
38404
38448
  function nodeInputRule(config) {
@@ -38426,7 +38470,8 @@ function nodeInputRule(config) {
38426
38470
  tr2.insert(insertionStart, config.type.create(attributes)).delete(tr2.mapping.map(start), tr2.mapping.map(end));
38427
38471
  }
38428
38472
  tr2.scrollIntoView();
38429
- }
38473
+ },
38474
+ undoable: config.undoable
38430
38475
  });
38431
38476
  }
38432
38477
  function textblockTypeInputRule(config) {
@@ -38439,7 +38484,8 @@ function textblockTypeInputRule(config) {
38439
38484
  return null;
38440
38485
  }
38441
38486
  state.tr.delete(range.from, range.to).setBlockType(range.from, range.from, config.type, attributes);
38442
- }
38487
+ },
38488
+ undoable: config.undoable
38443
38489
  });
38444
38490
  }
38445
38491
  function textInputRule(config) {
@@ -38460,7 +38506,8 @@ function textInputRule(config) {
38460
38506
  }
38461
38507
  }
38462
38508
  state.tr.insertText(insert, start, end);
38463
- }
38509
+ },
38510
+ undoable: config.undoable
38464
38511
  });
38465
38512
  }
38466
38513
  function wrappingInputRule(config) {
@@ -38493,7 +38540,8 @@ function wrappingInputRule(config) {
38493
38540
  if (before && before.type === config.type && canJoin(tr2.doc, range.from - 1) && (!config.joinPredicate || config.joinPredicate(match, before))) {
38494
38541
  tr2.join(range.from - 1);
38495
38542
  }
38496
- }
38543
+ },
38544
+ undoable: config.undoable
38497
38545
  });
38498
38546
  }
38499
38547
  function canInsertNode(state, nodeType) {
@@ -78087,6 +78135,74 @@ function Sidebar(props) {
78087
78135
  return /* @__PURE__ */ jsx(SidebarInternal, { ...props });
78088
78136
  }
78089
78137
  init_use_subscription();
78138
+ function useNavbarScroll({
78139
+ sticky = true,
78140
+ hideOnScroll = false,
78141
+ showScrollProgress = false,
78142
+ scrollBehavior = "static",
78143
+ minimalConfig = {}
78144
+ } = {}) {
78145
+ const [scrolled, setScrolled] = useState(false);
78146
+ const [hidden, setHidden] = useState(false);
78147
+ const [scrollProgress, setScrollProgress] = useState(0);
78148
+ const [isMinimal, setIsMinimal] = useState(false);
78149
+ const [scrollY, setScrollY] = useState(0);
78150
+ const lastScrollY = useRef(0);
78151
+ const ticking = useRef(false);
78152
+ const {
78153
+ scrollThreshold = 50,
78154
+ animationDuration = 300
78155
+ } = minimalConfig;
78156
+ const updateScrollState = useCallback(() => {
78157
+ const currentScrollY = window.scrollY;
78158
+ setScrollY(currentScrollY);
78159
+ const isScrolled = currentScrollY > 10;
78160
+ setScrolled(isScrolled);
78161
+ if (scrollBehavior === "hide" || hideOnScroll) {
78162
+ if (currentScrollY > lastScrollY.current && currentScrollY > 100) {
78163
+ setHidden(true);
78164
+ } else {
78165
+ setHidden(false);
78166
+ }
78167
+ } else if (scrollBehavior === "minimal") {
78168
+ const shouldBeMinimal = currentScrollY > scrollThreshold;
78169
+ if (shouldBeMinimal !== isMinimal) {
78170
+ setIsMinimal(shouldBeMinimal);
78171
+ }
78172
+ }
78173
+ if (showScrollProgress) {
78174
+ const winScroll = window.scrollY;
78175
+ const height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
78176
+ const progress = height > 0 ? winScroll / height * 100 : 0;
78177
+ setScrollProgress(Math.min(100, Math.max(0, progress)));
78178
+ }
78179
+ lastScrollY.current = currentScrollY;
78180
+ ticking.current = false;
78181
+ }, [hideOnScroll, scrollBehavior, showScrollProgress, scrollThreshold, isMinimal]);
78182
+ const requestTick = useCallback(() => {
78183
+ if (!ticking.current) {
78184
+ requestAnimationFrame(updateScrollState);
78185
+ ticking.current = true;
78186
+ }
78187
+ }, [updateScrollState]);
78188
+ useEffect(() => {
78189
+ if (!sticky && scrollBehavior === "static" && !showScrollProgress) {
78190
+ return;
78191
+ }
78192
+ updateScrollState();
78193
+ window.addEventListener("scroll", requestTick, { passive: true });
78194
+ return () => {
78195
+ window.removeEventListener("scroll", requestTick);
78196
+ };
78197
+ }, [sticky, scrollBehavior, showScrollProgress, requestTick, updateScrollState]);
78198
+ return {
78199
+ scrolled,
78200
+ hidden,
78201
+ scrollProgress,
78202
+ isMinimal,
78203
+ scrollY
78204
+ };
78205
+ }
78090
78206
  function NavbarInternal({
78091
78207
  sections = [],
78092
78208
  branding,
@@ -78102,6 +78218,7 @@ function NavbarInternal({
78102
78218
  showThemeToggle = false,
78103
78219
  theme = "system",
78104
78220
  onThemeChange,
78221
+ themeToggleVariant = "dropdown",
78105
78222
  userMenu,
78106
78223
  notifications,
78107
78224
  cta,
@@ -78118,9 +78235,12 @@ function NavbarInternal({
78118
78235
  shadow = false,
78119
78236
  rounded = false,
78120
78237
  logoPosition = "left",
78238
+ navItemsPosition = "left",
78121
78239
  mobileMenuPosition = "left",
78122
78240
  hideOnScroll = false,
78123
78241
  showScrollProgress = false,
78242
+ scrollBehavior = "static",
78243
+ minimalConfig = {},
78124
78244
  maxWidth = "2xl",
78125
78245
  fullWidth = false,
78126
78246
  enableNProgress = true,
@@ -78133,11 +78253,15 @@ function NavbarInternal({
78133
78253
  const [isSearchOpen, setIsSearchOpen] = useState(false);
78134
78254
  const [isCommandOpen, setIsCommandOpen] = useState(false);
78135
78255
  const [searchValue, setSearchValue] = useState("");
78136
- const [scrolled, setScrolled] = useState(false);
78137
- const [hidden, setHidden] = useState(false);
78138
- const [scrollProgress, setScrollProgress] = useState(0);
78139
- const lastScrollY = useRef(0);
78256
+ const [currentTheme, setCurrentTheme] = useState(theme);
78140
78257
  const navRef = useRef(null);
78258
+ const { scrolled, hidden, scrollProgress, isMinimal } = useNavbarScroll({
78259
+ sticky,
78260
+ hideOnScroll,
78261
+ showScrollProgress,
78262
+ scrollBehavior,
78263
+ minimalConfig
78264
+ });
78141
78265
  useEffect(() => {
78142
78266
  if (enableNProgress) {
78143
78267
  NProgress.configure({
@@ -78158,29 +78282,8 @@ function NavbarInternal({
78158
78282
  return () => window.removeEventListener("resize", checkMobile);
78159
78283
  }, [mobileBreakpoint]);
78160
78284
  useEffect(() => {
78161
- if (!sticky && !hideOnScroll && !showScrollProgress)
78162
- return;
78163
- const handleScroll = () => {
78164
- const currentScrollY = window.scrollY;
78165
- setScrolled(currentScrollY > 10);
78166
- if (hideOnScroll) {
78167
- if (currentScrollY > lastScrollY.current && currentScrollY > 100) {
78168
- setHidden(true);
78169
- } else {
78170
- setHidden(false);
78171
- }
78172
- lastScrollY.current = currentScrollY;
78173
- }
78174
- if (showScrollProgress) {
78175
- const winScroll = window.scrollY;
78176
- const height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
78177
- const scrolled2 = winScroll / height * 100;
78178
- setScrollProgress(scrolled2);
78179
- }
78180
- };
78181
- window.addEventListener("scroll", handleScroll, { passive: true });
78182
- return () => window.removeEventListener("scroll", handleScroll);
78183
- }, [sticky, hideOnScroll, showScrollProgress]);
78285
+ setCurrentTheme(theme);
78286
+ }, [theme]);
78184
78287
  useEffect(() => {
78185
78288
  if (!keyboardShortcuts && !enableCommandAI)
78186
78289
  return;
@@ -78363,6 +78466,9 @@ function NavbarInternal({
78363
78466
  ] }) })
78364
78467
  ] });
78365
78468
  const getHeight = () => {
78469
+ if (isMinimal && minimalConfig?.heightOnScroll) {
78470
+ return minimalConfig.heightOnScroll;
78471
+ }
78366
78472
  switch (size4) {
78367
78473
  case "sm":
78368
78474
  return "h-14";
@@ -78372,8 +78478,12 @@ function NavbarInternal({
78372
78478
  return "h-16";
78373
78479
  }
78374
78480
  };
78481
+ const shouldHideInMinimal = (element) => {
78482
+ return isMinimal && minimalConfig?.hideElements?.includes(element);
78483
+ };
78375
78484
  const navClasses = cn(
78376
- "moonui-pro w-full transition-all duration-300",
78485
+ "moonui-pro w-full transition-all",
78486
+ `duration-${minimalConfig?.animationDuration || 300}`,
78377
78487
  // Base variant styles
78378
78488
  variant === "default" && "border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",
78379
78489
  variant === "floating" && "mx-4 mt-4 rounded-lg border bg-background/95 backdrop-blur shadow-lg",
@@ -78384,7 +78494,10 @@ function NavbarInternal({
78384
78494
  // Scroll states
78385
78495
  scrolled && sticky && variant !== "transparent" && "shadow-sm",
78386
78496
  scrolled && variant === "transparent" && "bg-background/95 backdrop-blur border-b",
78387
- hidden && "-translate-y-full",
78497
+ scrollBehavior === "hide" && hidden && "-translate-y-full",
78498
+ // Minimal mode styles
78499
+ scrollBehavior === "minimal" && isMinimal && "shadow-md border-b",
78500
+ scrollBehavior === "minimal" && isMinimal && minimalConfig?.centerOnScroll && "px-8",
78388
78501
  // Glass effect
78389
78502
  glassmorphism && "bg-background/80 backdrop-blur-xl border-white/10",
78390
78503
  blur2 && "backdrop-blur-md",
@@ -78407,12 +78520,17 @@ function NavbarInternal({
78407
78520
  ),
78408
78521
  children: [
78409
78522
  branding && /* @__PURE__ */ jsxs(
78410
- "div",
78523
+ motion.div,
78411
78524
  {
78412
78525
  className: cn(
78413
78526
  "flex items-center gap-2",
78414
78527
  logoPosition === "center" && !isMobile ? "absolute left-1/2 -translate-x-1/2" : "mr-4"
78415
78528
  ),
78529
+ animate: {
78530
+ scale: isMinimal ? 0.9 : 1,
78531
+ opacity: shouldHideInMinimal("logo-text") ? 0.8 : 1
78532
+ },
78533
+ transition: { duration: minimalConfig?.animationDuration ? minimalConfig.animationDuration / 1e3 : 0.3 },
78416
78534
  children: [
78417
78535
  logoPosition === "left" && mobileMenuPosition === "left" && /* @__PURE__ */ jsx(MobileMenu, {}),
78418
78536
  /* @__PURE__ */ jsxs(
@@ -78428,79 +78546,102 @@ function NavbarInternal({
78428
78546
  className: "flex items-center gap-2",
78429
78547
  children: [
78430
78548
  branding.logo,
78431
- branding.title && !isMobile && /* @__PURE__ */ jsx("span", { className: "font-semibold text-lg", children: branding.title })
78549
+ branding.title && !isMobile && !shouldHideInMinimal("logo-text") && /* @__PURE__ */ jsx(
78550
+ motion.span,
78551
+ {
78552
+ className: "font-semibold text-lg",
78553
+ animate: {
78554
+ opacity: shouldHideInMinimal("logo-text") ? 0 : 1,
78555
+ width: shouldHideInMinimal("logo-text") ? 0 : "auto"
78556
+ },
78557
+ transition: { duration: 0.3 },
78558
+ children: branding.title
78559
+ }
78560
+ )
78432
78561
  ]
78433
78562
  }
78434
78563
  )
78435
78564
  ]
78436
78565
  }
78437
78566
  ),
78438
- !isMobile && !hideNavItems && /* @__PURE__ */ jsx(NavigationMenu2, { className: "hidden md:flex", children: /* @__PURE__ */ jsx(NavigationMenuList2, { children: sections.map((section) => /* @__PURE__ */ jsx(React68__default.Fragment, { children: section.items.map((item) => {
78439
- const hasChildren = item.items && item.items.length > 0;
78440
- const isActive2 = item.href === activePath;
78441
- if (hasChildren) {
78442
- return /* @__PURE__ */ jsxs(
78443
- NavigationMenuItem2,
78444
- {
78445
- children: [
78446
- /* @__PURE__ */ jsx(
78447
- NavigationMenuTrigger2,
78567
+ !isMobile && !hideNavItems && /* @__PURE__ */ jsx(
78568
+ NavigationMenu2,
78569
+ {
78570
+ className: cn(
78571
+ "hidden md:flex",
78572
+ navItemsPosition === "center" && "flex-1 justify-center",
78573
+ navItemsPosition === "right" && "ml-auto",
78574
+ isMinimal && minimalConfig?.centerOnScroll && "justify-center",
78575
+ isMinimal && minimalConfig?.hideElements?.includes("search") && "flex-1"
78576
+ ),
78577
+ children: /* @__PURE__ */ jsx(NavigationMenuList2, { children: sections.map((section) => /* @__PURE__ */ jsx(React68__default.Fragment, { children: section.items.map((item) => {
78578
+ const hasChildren = item.items && item.items.length > 0;
78579
+ const isActive2 = item.href === activePath;
78580
+ if (hasChildren) {
78581
+ return /* @__PURE__ */ jsxs(
78582
+ NavigationMenuItem2,
78583
+ {
78584
+ children: [
78585
+ /* @__PURE__ */ jsx(
78586
+ NavigationMenuTrigger2,
78587
+ {
78588
+ className: cn(
78589
+ isActive2 && "bg-accent text-accent-foreground",
78590
+ item.disabled && "opacity-50 cursor-not-allowed"
78591
+ ),
78592
+ disabled: item.disabled,
78593
+ children: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
78594
+ item.icon && /* @__PURE__ */ jsx("span", { children: item.icon }),
78595
+ item.title
78596
+ ] })
78597
+ }
78598
+ ),
78599
+ /* @__PURE__ */ jsx(NavigationMenuContent2, { children: item.items && renderMegaMenuContent(
78600
+ item.items
78601
+ ) })
78602
+ ]
78603
+ },
78604
+ item.id
78605
+ );
78606
+ }
78607
+ return /* @__PURE__ */ jsx(
78608
+ NavigationMenuItem2,
78609
+ {
78610
+ children: /* @__PURE__ */ jsxs(
78611
+ NavigationMenuLink2,
78448
78612
  {
78449
78613
  className: cn(
78614
+ navigationMenuTriggerStyle(),
78450
78615
  isActive2 && "bg-accent text-accent-foreground",
78451
78616
  item.disabled && "opacity-50 cursor-not-allowed"
78452
78617
  ),
78453
- disabled: item.disabled,
78454
- children: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
78455
- item.icon && /* @__PURE__ */ jsx("span", { children: item.icon }),
78456
- item.title
78457
- ] })
78618
+ onClick: () => !item.disabled && handleItemClick(
78619
+ item
78620
+ ),
78621
+ children: [
78622
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
78623
+ item.icon && /* @__PURE__ */ jsx("span", { children: item.icon }),
78624
+ item.title
78625
+ ] }),
78626
+ item.badge && /* @__PURE__ */ jsx(
78627
+ MoonUIBadgePro,
78628
+ {
78629
+ variant: item.badgeVariant || "secondary",
78630
+ className: "ml-2",
78631
+ children: item.badge
78632
+ }
78633
+ )
78634
+ ]
78458
78635
  }
78459
- ),
78460
- /* @__PURE__ */ jsx(NavigationMenuContent2, { children: item.items && renderMegaMenuContent(
78461
- item.items
78462
- ) })
78463
- ]
78464
- },
78465
- item.id
78466
- );
78636
+ )
78637
+ },
78638
+ item.id
78639
+ );
78640
+ }) }, section.id)) })
78467
78641
  }
78468
- return /* @__PURE__ */ jsx(
78469
- NavigationMenuItem2,
78470
- {
78471
- children: /* @__PURE__ */ jsxs(
78472
- NavigationMenuLink2,
78473
- {
78474
- className: cn(
78475
- navigationMenuTriggerStyle(),
78476
- isActive2 && "bg-accent text-accent-foreground",
78477
- item.disabled && "opacity-50 cursor-not-allowed"
78478
- ),
78479
- onClick: () => !item.disabled && handleItemClick(
78480
- item
78481
- ),
78482
- children: [
78483
- /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
78484
- item.icon && /* @__PURE__ */ jsx("span", { children: item.icon }),
78485
- item.title
78486
- ] }),
78487
- item.badge && /* @__PURE__ */ jsx(
78488
- MoonUIBadgePro,
78489
- {
78490
- variant: item.badgeVariant || "secondary",
78491
- className: "ml-2",
78492
- children: item.badge
78493
- }
78494
- )
78495
- ]
78496
- }
78497
- )
78498
- },
78499
- item.id
78500
- );
78501
- }) }, section.id)) }) }),
78642
+ ),
78502
78643
  /* @__PURE__ */ jsxs("div", { className: "ml-auto flex items-center gap-2", children: [
78503
- showSearch && /* @__PURE__ */ jsx(Fragment, { children: isMobile ? /* @__PURE__ */ jsx(
78644
+ showSearch && !shouldHideInMinimal("search") && /* @__PURE__ */ jsx(Fragment, { children: isMobile ? /* @__PURE__ */ jsx(
78504
78645
  MoonUIButtonPro,
78505
78646
  {
78506
78647
  variant: "ghost",
@@ -78532,17 +78673,60 @@ function NavbarInternal({
78532
78673
  "K"
78533
78674
  ] }) })
78534
78675
  ] }) }),
78535
- showThemeToggle && /* @__PURE__ */ jsxs(MoonUIDropdownMenuPro, { children: [
78676
+ showThemeToggle && (themeToggleVariant === "button" ? /* @__PURE__ */ jsx(
78677
+ motion.div,
78678
+ {
78679
+ whileTap: { scale: 0.95 },
78680
+ className: "relative",
78681
+ children: /* @__PURE__ */ jsx(
78682
+ MoonUIButtonPro,
78683
+ {
78684
+ variant: "ghost",
78685
+ size: "icon",
78686
+ onClick: () => {
78687
+ const newTheme = currentTheme === "dark" ? "light" : "dark";
78688
+ setCurrentTheme(newTheme);
78689
+ onThemeChange?.(newTheme);
78690
+ },
78691
+ className: "relative overflow-hidden",
78692
+ children: /* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", children: currentTheme === "dark" ? /* @__PURE__ */ jsx(
78693
+ motion.div,
78694
+ {
78695
+ initial: { y: -20, opacity: 0 },
78696
+ animate: { y: 0, opacity: 1 },
78697
+ exit: { y: 20, opacity: 0 },
78698
+ transition: { duration: 0.2 },
78699
+ children: /* @__PURE__ */ jsx(Moon, { className: "h-5 w-5" })
78700
+ },
78701
+ "moon"
78702
+ ) : /* @__PURE__ */ jsx(
78703
+ motion.div,
78704
+ {
78705
+ initial: { y: -20, opacity: 0, rotate: -90 },
78706
+ animate: { y: 0, opacity: 1, rotate: 0 },
78707
+ exit: { y: 20, opacity: 0, rotate: 90 },
78708
+ transition: { duration: 0.2 },
78709
+ children: /* @__PURE__ */ jsx(Sun, { className: "h-5 w-5" })
78710
+ },
78711
+ "sun"
78712
+ ) })
78713
+ }
78714
+ )
78715
+ }
78716
+ ) : /* @__PURE__ */ jsxs(MoonUIDropdownMenuPro, { children: [
78536
78717
  /* @__PURE__ */ jsx(MoonUIDropdownMenuTriggerPro, { asChild: true, children: /* @__PURE__ */ jsxs(MoonUIButtonPro, { variant: "ghost", size: "icon", children: [
78537
- theme === "light" && /* @__PURE__ */ jsx(Sun, { className: "h-5 w-5" }),
78538
- theme === "dark" && /* @__PURE__ */ jsx(Moon, { className: "h-5 w-5" }),
78539
- theme === "system" && /* @__PURE__ */ jsx(Monitor, { className: "h-5 w-5" })
78718
+ currentTheme === "light" && /* @__PURE__ */ jsx(Sun, { className: "h-5 w-5" }),
78719
+ currentTheme === "dark" && /* @__PURE__ */ jsx(Moon, { className: "h-5 w-5" }),
78720
+ currentTheme === "system" && /* @__PURE__ */ jsx(Monitor, { className: "h-5 w-5" })
78540
78721
  ] }) }),
78541
78722
  /* @__PURE__ */ jsxs(MoonUIDropdownMenuContentPro, { align: "end", children: [
78542
78723
  /* @__PURE__ */ jsxs(
78543
78724
  MoonUIDropdownMenuItemPro,
78544
78725
  {
78545
- onClick: () => onThemeChange?.("light"),
78726
+ onClick: () => {
78727
+ setCurrentTheme("light");
78728
+ onThemeChange?.("light");
78729
+ },
78546
78730
  children: [
78547
78731
  /* @__PURE__ */ jsx(Sun, { className: "mr-2 h-4 w-4" }),
78548
78732
  "Light"
@@ -78552,7 +78736,10 @@ function NavbarInternal({
78552
78736
  /* @__PURE__ */ jsxs(
78553
78737
  MoonUIDropdownMenuItemPro,
78554
78738
  {
78555
- onClick: () => onThemeChange?.("dark"),
78739
+ onClick: () => {
78740
+ setCurrentTheme("dark");
78741
+ onThemeChange?.("dark");
78742
+ },
78556
78743
  children: [
78557
78744
  /* @__PURE__ */ jsx(Moon, { className: "mr-2 h-4 w-4" }),
78558
78745
  "Dark"
@@ -78562,7 +78749,10 @@ function NavbarInternal({
78562
78749
  /* @__PURE__ */ jsxs(
78563
78750
  MoonUIDropdownMenuItemPro,
78564
78751
  {
78565
- onClick: () => onThemeChange?.("system"),
78752
+ onClick: () => {
78753
+ setCurrentTheme("system");
78754
+ onThemeChange?.("system");
78755
+ },
78566
78756
  children: [
78567
78757
  /* @__PURE__ */ jsx(Monitor, { className: "mr-2 h-4 w-4" }),
78568
78758
  "System"
@@ -78570,7 +78760,7 @@ function NavbarInternal({
78570
78760
  }
78571
78761
  )
78572
78762
  ] })
78573
- ] }),
78763
+ ] })),
78574
78764
  notifications && /* @__PURE__ */ jsxs(MoonUIDropdownMenuPro, { children: [
78575
78765
  /* @__PURE__ */ jsx(MoonUIDropdownMenuTriggerPro, { asChild: true, children: /* @__PURE__ */ jsxs(
78576
78766
  MoonUIButtonPro,
@@ -78694,7 +78884,7 @@ function NavbarInternal({
78694
78884
  }
78695
78885
  )
78696
78886
  ] }),
78697
- cta && /* @__PURE__ */ jsx(
78887
+ cta && !shouldHideInMinimal("cta") && /* @__PURE__ */ jsx(
78698
78888
  MoonUIButtonPro,
78699
78889
  {
78700
78890
  variant: cta.variant || "primary",
@@ -89515,13 +89705,16 @@ var BubbleBackgroundInternal = ({
89515
89705
  const createBubble = useCallback((canvas) => {
89516
89706
  const [minSize, maxSize] = sizeRange;
89517
89707
  const size4 = minSize + Math.random() * (maxSize - minSize);
89518
- let startY = canvas.height + size4;
89519
- let startX = Math.random() * canvas.width;
89708
+ const rect = canvas.getBoundingClientRect();
89709
+ const actualWidth = rect.width;
89710
+ const actualHeight = rect.height;
89711
+ let startY = actualHeight + size4;
89712
+ let startX = -size4 + Math.random() * (actualWidth + size4 * 2);
89520
89713
  if (animationStyle === "champagne") {
89521
- const sourcePoints = [canvas.width * 0.3, canvas.width * 0.5, canvas.width * 0.7];
89714
+ const sourcePoints = [actualWidth * 0.3, actualWidth * 0.5, actualWidth * 0.7];
89522
89715
  startX = sourcePoints[Math.floor(Math.random() * sourcePoints.length)] + (Math.random() - 0.5) * 50;
89523
89716
  } else if (animationStyle === "lava") {
89524
- startX = canvas.width / 2 + (Math.random() - 0.5) * canvas.width * 0.3;
89717
+ startX = actualWidth / 2 + (Math.random() - 0.5) * actualWidth * 0.3;
89525
89718
  }
89526
89719
  return {
89527
89720
  x: startX,
@@ -89544,10 +89737,14 @@ var BubbleBackgroundInternal = ({
89544
89737
  const canvas = canvasRef.current;
89545
89738
  if (!canvas)
89546
89739
  return;
89740
+ const rect = canvas.getBoundingClientRect();
89741
+ const actualWidth = rect.width;
89742
+ const actualHeight = rect.height;
89547
89743
  const bubbles = [];
89548
89744
  for (let i = 0; i < count3; i++) {
89549
89745
  const bubble = createBubble(canvas);
89550
- bubble.y = Math.random() * canvas.height;
89746
+ bubble.y = Math.random() * (actualHeight + 100);
89747
+ bubble.x = -50 + Math.random() * (actualWidth + 100);
89551
89748
  bubbles.push(bubble);
89552
89749
  }
89553
89750
  bubblesRef.current = bubbles;
@@ -89682,9 +89879,11 @@ var BubbleBackgroundInternal = ({
89682
89879
  bubble.vy += dy / distance * force;
89683
89880
  }
89684
89881
  }
89685
- if (bubble.x < -bubble.size)
89686
- bubble.x = canvas.width + bubble.size;
89687
- if (bubble.x > canvas.width + bubble.size)
89882
+ const rect = canvas.getBoundingClientRect();
89883
+ const actualWidth = rect.width;
89884
+ if (bubble.x < -bubble.size * 2)
89885
+ bubble.x = actualWidth + bubble.size;
89886
+ if (bubble.x > actualWidth + bubble.size * 2)
89688
89887
  bubble.x = -bubble.size;
89689
89888
  if (bubble.y < -bubble.size && !bubble.popping) {
89690
89889
  const newBubble = createBubble(canvas);
@@ -89779,10 +89978,13 @@ var BubbleBackgroundInternal = ({
89779
89978
  const canvas = canvasRef.current;
89780
89979
  if (!canvas)
89781
89980
  return;
89782
- const rect = canvas.getBoundingClientRect();
89783
- const dpr = window.devicePixelRatio || 1;
89784
- canvas.style.width = rect.width + "px";
89785
- canvas.style.height = rect.height + "px";
89981
+ const container = canvas.parentElement;
89982
+ if (!container)
89983
+ return;
89984
+ const rect = container.getBoundingClientRect();
89985
+ const dpr = Math.min(window.devicePixelRatio || 1, 2);
89986
+ canvas.style.width = "100%";
89987
+ canvas.style.height = "100%";
89786
89988
  canvas.width = rect.width * dpr;
89787
89989
  canvas.height = rect.height * dpr;
89788
89990
  const ctx = canvas.getContext("2d");
@@ -89809,10 +90011,13 @@ var BubbleBackgroundInternal = ({
89809
90011
  if (!canvas)
89810
90012
  return;
89811
90013
  detectPerformance();
89812
- const rect = canvas.getBoundingClientRect();
89813
- const dpr = window.devicePixelRatio || 1;
89814
- canvas.style.width = rect.width + "px";
89815
- canvas.style.height = rect.height + "px";
90014
+ const container = canvas.parentElement;
90015
+ if (!container)
90016
+ return;
90017
+ const rect = container.getBoundingClientRect();
90018
+ const dpr = Math.min(window.devicePixelRatio || 1, 2);
90019
+ canvas.style.width = "100%";
90020
+ canvas.style.height = "100%";
89816
90021
  canvas.width = rect.width * dpr;
89817
90022
  canvas.height = rect.height * dpr;
89818
90023
  const ctx = canvas.getContext("2d");
@@ -93913,6 +94118,14 @@ function DocsProProvider({ children, componentName = "Pro Component" }) {
93913
94118
  return /* @__PURE__ */ jsx(Fragment, { children });
93914
94119
  }
93915
94120
  init_use_subscription();
94121
+ var debounce = (func, wait) => {
94122
+ let timeout = null;
94123
+ return (...args) => {
94124
+ if (timeout)
94125
+ clearTimeout(timeout);
94126
+ timeout = setTimeout(() => func(...args), wait);
94127
+ };
94128
+ };
93916
94129
  var MouseTrailInternal = ({
93917
94130
  children,
93918
94131
  style: style2 = "dots",
@@ -93950,10 +94163,12 @@ var MouseTrailInternal = ({
93950
94163
  const canvasRef = useRef(null);
93951
94164
  const animationRef = useRef(void 0);
93952
94165
  const particlesRef = useRef([]);
93953
- const mouseRef = useRef({ x: 0, y: 0 });
94166
+ const mouseRef = useRef({ x: 0, y: 0, active: false });
93954
94167
  const lastMouseRef = useRef({ x: 0, y: 0 });
93955
94168
  const frameCountRef = useRef(0);
93956
94169
  const rainbowPhaseRef = useRef(0);
94170
+ const lastFrameTime = useRef(0);
94171
+ const [isActive2, setIsActive] = useState(false);
93957
94172
  const initializeParticles = useCallback(() => {
93958
94173
  const particles = [];
93959
94174
  for (let i = 0; i < length; i++) {
@@ -94119,12 +94334,12 @@ var MouseTrailInternal = ({
94119
94334
  newParticle.opacity = 1;
94120
94335
  newParticle.rotation = 0;
94121
94336
  newParticle.scale = scaleRange[1];
94122
- newParticle.sparkle = sparkle && Math.random() < sparkleFrequency;
94337
+ newParticle.sparkle = sparkle && frameCountRef.current * 7 % 100 / 100 < sparkleFrequency;
94123
94338
  if (rainbow) {
94124
94339
  const hue = rainbowPhaseRef.current * 360 % 360;
94125
94340
  newParticle.color = `hsl(${hue}, 70%, 50%)`;
94126
94341
  } else {
94127
- newParticle.color = colors[Math.floor(Math.random() * colors.length)];
94342
+ newParticle.color = colors[frameCountRef.current % colors.length];
94128
94343
  }
94129
94344
  lastMouseRef.current = { ...mouse };
94130
94345
  }
@@ -94180,6 +94395,14 @@ var MouseTrailInternal = ({
94180
94395
  const canvas = canvasRef.current;
94181
94396
  if (!canvas)
94182
94397
  return;
94398
+ const targetFPS = 60;
94399
+ const frameInterval = 1e3 / targetFPS;
94400
+ const deltaTime = currentTime - lastFrameTime.current;
94401
+ if (deltaTime < frameInterval) {
94402
+ animationRef.current = requestAnimationFrame(animate4);
94403
+ return;
94404
+ }
94405
+ lastFrameTime.current = currentTime - deltaTime % frameInterval;
94183
94406
  const ctx = canvas.getContext("2d", {
94184
94407
  alpha: true,
94185
94408
  desynchronized: true
@@ -94187,14 +94410,17 @@ var MouseTrailInternal = ({
94187
94410
  if (!ctx)
94188
94411
  return;
94189
94412
  ctx.clearRect(0, 0, canvas.width, canvas.height);
94190
- updateParticles(16);
94191
- drawLines(ctx, particlesRef.current);
94192
- const particles = particlesRef.current;
94193
- particles.forEach((particle) => {
94194
- if (particle.opacity > 0) {
94195
- drawShape(ctx, particle, particle.x, particle.y);
94196
- }
94197
- });
94413
+ const hasActiveParticles = particlesRef.current.some((p) => p.opacity > 0.01);
94414
+ if (mouseRef.current.active || hasActiveParticles) {
94415
+ updateParticles(deltaTime);
94416
+ drawLines(ctx, particlesRef.current);
94417
+ const particles = particlesRef.current;
94418
+ particles.forEach((particle) => {
94419
+ if (particle.opacity > 0.01) {
94420
+ drawShape(ctx, particle, particle.x, particle.y);
94421
+ }
94422
+ });
94423
+ }
94198
94424
  frameCountRef.current++;
94199
94425
  animationRef.current = requestAnimationFrame(animate4);
94200
94426
  }, [updateParticles, drawLines, drawShape]);
@@ -94203,11 +94429,17 @@ var MouseTrailInternal = ({
94203
94429
  if (!canvas)
94204
94430
  return;
94205
94431
  const rect = canvas.getBoundingClientRect();
94206
- mouseRef.current = {
94207
- x: e.clientX - rect.left,
94208
- y: e.clientY - rect.top
94209
- };
94210
- }, []);
94432
+ const x = e.clientX - rect.left;
94433
+ const y = e.clientY - rect.top;
94434
+ if (x >= 0 && x <= rect.width && y >= 0 && y <= rect.height) {
94435
+ mouseRef.current = { x, y, active: true };
94436
+ if (!isActive2) {
94437
+ setIsActive(true);
94438
+ }
94439
+ } else {
94440
+ mouseRef.current.active = false;
94441
+ }
94442
+ }, [isActive2]);
94211
94443
  const handleTouchMove = useCallback((e) => {
94212
94444
  if (!enableTouch)
94213
94445
  return;
@@ -94216,37 +94448,67 @@ var MouseTrailInternal = ({
94216
94448
  return;
94217
94449
  const rect = canvas.getBoundingClientRect();
94218
94450
  const touch = e.touches[0];
94219
- mouseRef.current = {
94220
- x: touch.clientX - rect.left,
94221
- y: touch.clientY - rect.top
94222
- };
94223
- }, [enableTouch]);
94451
+ const x = touch.clientX - rect.left;
94452
+ const y = touch.clientY - rect.top;
94453
+ if (x >= 0 && x <= rect.width && y >= 0 && y <= rect.height) {
94454
+ mouseRef.current = { x, y, active: true };
94455
+ if (!isActive2) {
94456
+ setIsActive(true);
94457
+ }
94458
+ } else {
94459
+ mouseRef.current.active = false;
94460
+ }
94461
+ }, [enableTouch, isActive2]);
94224
94462
  const handleResize = useCallback(() => {
94225
94463
  const canvas = canvasRef.current;
94226
94464
  if (!canvas)
94227
94465
  return;
94228
94466
  const rect = canvas.getBoundingClientRect();
94229
- canvas.width = rect.width;
94230
- canvas.height = rect.height;
94467
+ const dpr = window.devicePixelRatio || 1;
94468
+ canvas.width = rect.width * dpr;
94469
+ canvas.height = rect.height * dpr;
94470
+ const ctx = canvas.getContext("2d");
94471
+ if (ctx) {
94472
+ ctx.scale(dpr, dpr);
94473
+ }
94474
+ canvas.style.width = `${rect.width}px`;
94475
+ canvas.style.height = `${rect.height}px`;
94231
94476
  }, []);
94232
94477
  useEffect(() => {
94233
94478
  const canvas = canvasRef.current;
94234
94479
  if (!canvas)
94235
94480
  return;
94236
- const rect = canvas.getBoundingClientRect();
94237
- canvas.width = rect.width;
94238
- canvas.height = rect.height;
94481
+ handleResize();
94239
94482
  initializeParticles();
94240
- window.addEventListener("resize", handleResize);
94241
- window.addEventListener("mousemove", handleMouseMove2);
94483
+ const debouncedResize = debounce(handleResize, 100);
94484
+ window.addEventListener("resize", debouncedResize);
94485
+ canvas.addEventListener("mousemove", handleMouseMove2);
94486
+ canvas.addEventListener("mouseenter", () => {
94487
+ mouseRef.current.active = true;
94488
+ setIsActive(true);
94489
+ });
94490
+ canvas.addEventListener("mouseleave", () => {
94491
+ mouseRef.current.active = false;
94492
+ setIsActive(false);
94493
+ });
94242
94494
  if (enableTouch) {
94243
94495
  window.addEventListener("touchmove", handleTouchMove);
94244
94496
  }
94245
94497
  animationRef.current = requestAnimationFrame(animate4);
94246
94498
  return () => {
94247
- window.removeEventListener("resize", handleResize);
94248
- window.removeEventListener("mousemove", handleMouseMove2);
94249
- window.removeEventListener("touchmove", handleTouchMove);
94499
+ window.removeEventListener("resize", debouncedResize);
94500
+ canvas.removeEventListener("mousemove", handleMouseMove2);
94501
+ canvas.removeEventListener("mouseenter", () => {
94502
+ mouseRef.current.active = true;
94503
+ setIsActive(true);
94504
+ });
94505
+ canvas.removeEventListener("mouseleave", () => {
94506
+ mouseRef.current.active = false;
94507
+ setIsActive(false);
94508
+ });
94509
+ if (enableTouch) {
94510
+ canvas.removeEventListener("touchmove", handleTouchMove);
94511
+ }
94250
94512
  if (animationRef.current) {
94251
94513
  cancelAnimationFrame(animationRef.current);
94252
94514
  }
@@ -94272,10 +94534,13 @@ var MouseTrailInternal = ({
94272
94534
  {
94273
94535
  ref: canvasRef,
94274
94536
  className: cn(
94275
- "absolute inset-0 w-full h-full pointer-events-none",
94537
+ "absolute inset-0 w-full h-full",
94276
94538
  className
94277
94539
  ),
94278
- style: { zIndex }
94540
+ style: {
94541
+ zIndex,
94542
+ pointerEvents: "auto"
94543
+ }
94279
94544
  }
94280
94545
  ),
94281
94546
  children && /* @__PURE__ */ jsx("div", { className: "relative z-0", children })
@@ -94299,44 +94564,46 @@ var MouseTrail = (props) => {
94299
94564
  };
94300
94565
  MouseTrail.displayName = "MouseTrail";
94301
94566
  init_use_subscription();
94567
+ var lerp = (start, end, factor) => {
94568
+ return start + (end - start) * factor;
94569
+ };
94570
+ var clamp2 = (value, min2, max2) => {
94571
+ return Math.max(min2, Math.min(max2, value));
94572
+ };
94302
94573
  var MagneticElementsInternal = ({
94303
94574
  children,
94304
- strength = 0.5,
94305
- radius = 200,
94575
+ strength = 0.3,
94576
+ radius = 150,
94306
94577
  type = "attract",
94307
94578
  enableTouch = false,
94308
- damping = 0.1,
94309
- stiffness = 0.2,
94310
- mass = 1,
94579
+ damping = 0.2,
94580
+ stiffness = 0.3,
94311
94581
  rotate = true,
94312
- rotationStrength = 15,
94582
+ rotationStrength = 10,
94313
94583
  scale = true,
94314
- scaleFactor = 1.1,
94315
- tilt = true,
94316
- tiltAngle = 15,
94317
- transitionDuration = 0,
94318
- easing = "cubic-bezier(0.25, 0.46, 0.45, 0.94)",
94584
+ scaleFactor = 1.05,
94585
+ tilt = false,
94586
+ tiltAngle = 10,
94319
94587
  constrain = true,
94320
- maxDisplacement = 100,
94321
- hoverOnly = false,
94588
+ maxDisplacement = 50,
94322
94589
  returnSpeed = 0.1,
94323
- overshoot = true,
94324
- overshootAmount = 1.2,
94325
- inertia = true,
94326
- inertiaDecay = 0.95,
94327
- enable3D = false,
94328
- perspective = 1e3,
94590
+ smooth = true,
94591
+ smoothing = 0.15,
94592
+ performance: performance2 = "balanced",
94329
94593
  glow = false,
94330
- glowColor = "#667eea",
94594
+ glowColor = "rgba(59, 130, 246, 0.5)",
94331
94595
  containerClassName,
94332
94596
  elementClassName,
94333
94597
  debug = false
94334
94598
  }) => {
94335
94599
  const containerRef = useRef(null);
94336
94600
  const elementsRef = useRef([]);
94337
- const mouseRef = useRef({ x: 0, y: 0 });
94601
+ const mouseRef = useRef({ x: 0, y: 0, active: false });
94338
94602
  const animationRef = useRef(void 0);
94339
- const isActiveRef = useRef(false);
94603
+ const [isReady, setIsReady] = useState(false);
94604
+ const fps = performance2 === "high" ? 60 : performance2 === "balanced" ? 30 : 15;
94605
+ const frameInterval = 1e3 / fps;
94606
+ const lastFrameTime = useRef(0);
94340
94607
  const initializeElements = useCallback(() => {
94341
94608
  const container = containerRef.current;
94342
94609
  if (!container)
@@ -94347,35 +94614,39 @@ var MagneticElementsInternal = ({
94347
94614
  const element = el;
94348
94615
  const rect = element.getBoundingClientRect();
94349
94616
  const containerRect = container.getBoundingClientRect();
94617
+ const centerX = rect.left - containerRect.left + rect.width / 2;
94618
+ const centerY = rect.top - containerRect.top + rect.height / 2;
94350
94619
  elements.push({
94351
94620
  element,
94352
- originalX: rect.left - containerRect.left + rect.width / 2,
94353
- originalY: rect.top - containerRect.top + rect.height / 2,
94621
+ originalX: centerX,
94622
+ originalY: centerY,
94354
94623
  currentX: 0,
94355
94624
  currentY: 0,
94356
- velocityX: 0,
94357
- velocityY: 0,
94358
94625
  targetX: 0,
94359
94626
  targetY: 0,
94360
94627
  rotation: 0,
94361
94628
  scale: 1,
94362
- isHovered: false
94629
+ opacity: 1
94363
94630
  });
94364
- element.style.willChange = "transform";
94365
- if (transitionDuration > 0) {
94366
- element.style.transition = `transform ${transitionDuration}ms ${easing}`;
94631
+ element.style.willChange = "transform, opacity";
94632
+ element.style.transformOrigin = "center center";
94633
+ if (smooth) {
94634
+ element.style.transition = "none";
94367
94635
  }
94368
94636
  });
94369
94637
  elementsRef.current = elements;
94370
- }, [transitionDuration, easing]);
94638
+ setIsReady(true);
94639
+ }, [smooth]);
94371
94640
  const calculateForce = useCallback((element, mouseX, mouseY) => {
94372
94641
  const dx = mouseX - element.originalX;
94373
94642
  const dy = mouseY - element.originalY;
94374
94643
  const distance = Math.sqrt(dx * dx + dy * dy);
94644
+ const normalizedDistance = Math.min(distance / radius, 1);
94375
94645
  if (distance > radius) {
94376
- return { fx: 0, fy: 0, distance };
94646
+ return { fx: 0, fy: 0, distance, normalizedDistance: 1 };
94377
94647
  }
94378
- const force = (1 - distance / radius) * strength;
94648
+ const easedForce = 1 - Math.pow(normalizedDistance, 2);
94649
+ const force = easedForce * strength;
94379
94650
  let fx = 0;
94380
94651
  let fy = 0;
94381
94652
  switch (type) {
@@ -94384,67 +94655,70 @@ var MagneticElementsInternal = ({
94384
94655
  fy = dy * force;
94385
94656
  break;
94386
94657
  case "repel":
94387
- fx = -dx * force;
94388
- fy = -dy * force;
94658
+ const repelForce = force * 2;
94659
+ fx = -dx * repelForce / (normalizedDistance + 0.1);
94660
+ fy = -dy * repelForce / (normalizedDistance + 0.1);
94389
94661
  break;
94390
94662
  case "elastic":
94391
- const elasticForce = Math.sin(distance / radius * Math.PI) * strength;
94663
+ const elasticForce = Math.sin(normalizedDistance * Math.PI) * strength;
94392
94664
  fx = dx * elasticForce;
94393
94665
  fy = dy * elasticForce;
94394
94666
  break;
94395
94667
  case "orbit":
94396
94668
  const angle = Math.atan2(dy, dx) + Math.PI / 2;
94397
- const orbitForce = force * 50;
94669
+ const orbitForce = force * 30;
94398
94670
  fx = Math.cos(angle) * orbitForce;
94399
94671
  fy = Math.sin(angle) * orbitForce;
94400
94672
  break;
94401
94673
  }
94402
- return { fx, fy, distance };
94674
+ return { fx, fy, distance, normalizedDistance };
94403
94675
  }, [radius, strength, type]);
94404
- const updateElements = useCallback(() => {
94676
+ const updateElements = useCallback((currentTime) => {
94677
+ if (performance2 !== "high") {
94678
+ const elapsed = currentTime - lastFrameTime.current;
94679
+ if (elapsed < frameInterval)
94680
+ return;
94681
+ lastFrameTime.current = currentTime - elapsed % frameInterval;
94682
+ }
94405
94683
  const elements = elementsRef.current;
94406
94684
  const mouse = mouseRef.current;
94407
94685
  elements.forEach((element) => {
94408
- const { fx, fy, distance } = calculateForce(element, mouse.x, mouse.y);
94409
- const isInRange = distance <= radius;
94410
- if (isInRange && (!hoverOnly || element.isHovered)) {
94686
+ const { fx, fy, distance, normalizedDistance } = calculateForce(
94687
+ element,
94688
+ mouse.x,
94689
+ mouse.y
94690
+ );
94691
+ const isInRange = distance <= radius && mouse.active;
94692
+ if (isInRange) {
94411
94693
  element.targetX = fx;
94412
94694
  element.targetY = fy;
94695
+ element.opacity = 1;
94413
94696
  } else {
94414
94697
  element.targetX = 0;
94415
94698
  element.targetY = 0;
94699
+ element.opacity = 1;
94416
94700
  }
94417
94701
  if (constrain) {
94418
- element.targetX = Math.max(-maxDisplacement, Math.min(maxDisplacement, element.targetX));
94419
- element.targetY = Math.max(-maxDisplacement, Math.min(maxDisplacement, element.targetY));
94420
- }
94421
- if (inertia) {
94422
- const ax = (element.targetX - element.currentX) * stiffness - element.velocityX * damping;
94423
- const ay = (element.targetY - element.currentY) * stiffness - element.velocityY * damping;
94424
- element.velocityX += ax / mass;
94425
- element.velocityY += ay / mass;
94426
- element.velocityX *= inertiaDecay;
94427
- element.velocityY *= inertiaDecay;
94428
- element.currentX += element.velocityX;
94429
- element.currentY += element.velocityY;
94702
+ element.targetX = clamp2(element.targetX, -maxDisplacement, maxDisplacement);
94703
+ element.targetY = clamp2(element.targetY, -maxDisplacement, maxDisplacement);
94704
+ }
94705
+ const lerpFactor = smooth ? smoothing : 1;
94706
+ element.currentX = lerp(element.currentX, element.targetX, lerpFactor);
94707
+ element.currentY = lerp(element.currentY, element.targetY, lerpFactor);
94708
+ if (rotate && isInRange) {
94709
+ const targetRotation = element.currentX / maxDisplacement * rotationStrength;
94710
+ element.rotation = lerp(element.rotation, targetRotation, lerpFactor);
94430
94711
  } else {
94431
- element.currentX += (element.targetX - element.currentX) * returnSpeed;
94432
- element.currentY += (element.targetY - element.currentY) * returnSpeed;
94433
- }
94434
- if (overshoot && isInRange) {
94435
- element.currentX *= overshootAmount;
94436
- element.currentY *= overshootAmount;
94437
- }
94438
- if (rotate) {
94439
- element.rotation = element.currentX / maxDisplacement * rotationStrength;
94712
+ element.rotation = lerp(element.rotation, 0, lerpFactor);
94440
94713
  }
94441
94714
  if (scale && isInRange) {
94442
- const scaleProgress = 1 - distance / radius;
94443
- element.scale = 1 + (scaleFactor - 1) * scaleProgress;
94715
+ const scaleProgress = 1 - normalizedDistance;
94716
+ const targetScale = 1 + (scaleFactor - 1) * scaleProgress;
94717
+ element.scale = lerp(element.scale, targetScale, lerpFactor);
94444
94718
  } else {
94445
- element.scale += (1 - element.scale) * returnSpeed;
94719
+ element.scale = lerp(element.scale, 1, lerpFactor);
94446
94720
  }
94447
- let transform = `translate(${element.currentX}px, ${element.currentY}px)`;
94721
+ let transform = `translate3d(${element.currentX}px, ${element.currentY}px, 0)`;
94448
94722
  if (rotate) {
94449
94723
  transform += ` rotate(${element.rotation}deg)`;
94450
94724
  }
@@ -94454,53 +94728,39 @@ var MagneticElementsInternal = ({
94454
94728
  if (tilt && isInRange) {
94455
94729
  const tiltX = element.currentY / maxDisplacement * tiltAngle;
94456
94730
  const tiltY = -(element.currentX / maxDisplacement) * tiltAngle;
94457
- if (enable3D) {
94458
- transform += ` rotateX(${tiltX}deg) rotateY(${tiltY}deg)`;
94459
- element.element.style.transformStyle = "preserve-3d";
94460
- element.element.style.perspective = `${perspective}px`;
94461
- }
94731
+ transform += ` rotateX(${tiltX}deg) rotateY(${tiltY}deg)`;
94462
94732
  }
94463
94733
  if (glow && isInRange) {
94464
- const glowIntensity = (1 - distance / radius) * 20;
94734
+ const glowIntensity = (1 - normalizedDistance) * 20;
94465
94735
  element.element.style.boxShadow = `0 0 ${glowIntensity}px ${glowColor}`;
94736
+ element.element.style.filter = `brightness(${1 + (1 - normalizedDistance) * 0.2})`;
94466
94737
  } else if (glow) {
94467
- element.element.style.boxShadow = "none";
94738
+ element.element.style.boxShadow = "";
94739
+ element.element.style.filter = "";
94468
94740
  }
94469
94741
  element.element.style.transform = transform;
94470
- if (debug) {
94471
- element.element.style.border = isInRange ? "2px solid red" : "1px solid blue";
94472
- }
94742
+ element.element.style.opacity = element.opacity.toString();
94473
94743
  });
94474
94744
  }, [
94475
94745
  calculateForce,
94476
94746
  radius,
94477
- hoverOnly,
94478
94747
  constrain,
94479
94748
  maxDisplacement,
94480
- inertia,
94481
- stiffness,
94482
- damping,
94483
- mass,
94484
- inertiaDecay,
94485
- returnSpeed,
94486
- overshoot,
94487
- overshootAmount,
94749
+ smooth,
94750
+ smoothing,
94488
94751
  rotate,
94489
94752
  rotationStrength,
94490
94753
  scale,
94491
94754
  scaleFactor,
94492
94755
  tilt,
94493
94756
  tiltAngle,
94494
- enable3D,
94495
- perspective,
94496
94757
  glow,
94497
94758
  glowColor,
94498
- debug
94759
+ performance2,
94760
+ frameInterval
94499
94761
  ]);
94500
- const animate4 = useCallback(() => {
94501
- if (!isActiveRef.current)
94502
- return;
94503
- updateElements();
94762
+ const animate4 = useCallback((currentTime) => {
94763
+ updateElements(currentTime);
94504
94764
  animationRef.current = requestAnimationFrame(animate4);
94505
94765
  }, [updateElements]);
94506
94766
  const handleMouseMove2 = useCallback((e) => {
@@ -94510,13 +94770,10 @@ var MagneticElementsInternal = ({
94510
94770
  const rect = container.getBoundingClientRect();
94511
94771
  mouseRef.current = {
94512
94772
  x: e.clientX - rect.left,
94513
- y: e.clientY - rect.top
94773
+ y: e.clientY - rect.top,
94774
+ active: true
94514
94775
  };
94515
- if (!isActiveRef.current) {
94516
- isActiveRef.current = true;
94517
- animate4();
94518
- }
94519
- }, [animate4]);
94776
+ }, []);
94520
94777
  const handleTouchMove = useCallback((e) => {
94521
94778
  if (!enableTouch)
94522
94779
  return;
@@ -94527,69 +94784,31 @@ var MagneticElementsInternal = ({
94527
94784
  const touch = e.touches[0];
94528
94785
  mouseRef.current = {
94529
94786
  x: touch.clientX - rect.left,
94530
- y: touch.clientY - rect.top
94787
+ y: touch.clientY - rect.top,
94788
+ active: true
94531
94789
  };
94532
- if (!isActiveRef.current) {
94533
- isActiveRef.current = true;
94534
- animate4();
94790
+ }, [enableTouch]);
94791
+ const handleMouseEnter = useCallback(() => {
94792
+ mouseRef.current.active = true;
94793
+ if (!animationRef.current) {
94794
+ animationRef.current = requestAnimationFrame(animate4);
94535
94795
  }
94536
- }, [enableTouch, animate4]);
94537
- const handleMouseLeave2 = useCallback(() => {
94538
- isActiveRef.current = false;
94539
- elementsRef.current.forEach((element) => {
94540
- element.targetX = 0;
94541
- element.targetY = 0;
94542
- });
94543
- animate4();
94544
- setTimeout(() => {
94545
- if (animationRef.current) {
94546
- cancelAnimationFrame(animationRef.current);
94547
- }
94548
- }, 1e3);
94549
94796
  }, [animate4]);
94550
- const handleElementHover = useCallback((element, isHovered) => {
94551
- const magneticElement = elementsRef.current.find((el) => el.element === element);
94552
- if (magneticElement) {
94553
- magneticElement.isHovered = isHovered;
94554
- }
94797
+ const handleMouseLeave2 = useCallback(() => {
94798
+ mouseRef.current.active = false;
94555
94799
  }, []);
94556
94800
  useEffect(() => {
94557
94801
  initializeElements();
94558
94802
  const container = containerRef.current;
94559
94803
  if (!container)
94560
94804
  return;
94561
- container.addEventListener("mousemove", handleMouseMove2);
94562
- container.addEventListener("mouseleave", handleMouseLeave2);
94563
- if (enableTouch) {
94564
- container.addEventListener("touchmove", handleTouchMove);
94565
- container.addEventListener("touchend", handleMouseLeave2);
94566
- }
94567
- if (hoverOnly) {
94568
- const elements = container.querySelectorAll("[data-magnetic]");
94569
- elements.forEach((el) => {
94570
- const element = el;
94571
- element.addEventListener("mouseenter", () => handleElementHover(element, true));
94572
- element.addEventListener("mouseleave", () => handleElementHover(element, false));
94573
- });
94574
- }
94805
+ animationRef.current = requestAnimationFrame(animate4);
94575
94806
  return () => {
94576
- container.removeEventListener("mousemove", handleMouseMove2);
94577
- container.removeEventListener("mouseleave", handleMouseLeave2);
94578
- container.removeEventListener("touchmove", handleTouchMove);
94579
- container.removeEventListener("touchend", handleMouseLeave2);
94580
94807
  if (animationRef.current) {
94581
94808
  cancelAnimationFrame(animationRef.current);
94582
94809
  }
94583
94810
  };
94584
- }, [
94585
- initializeElements,
94586
- handleMouseMove2,
94587
- handleMouseLeave2,
94588
- handleTouchMove,
94589
- handleElementHover,
94590
- enableTouch,
94591
- hoverOnly
94592
- ]);
94811
+ }, [initializeElements, animate4]);
94593
94812
  const processedChildren = Children.map(children, (child, index2) => {
94594
94813
  if (isValidElement(child)) {
94595
94814
  return cloneElement(child, {
@@ -94597,7 +94816,7 @@ var MagneticElementsInternal = ({
94597
94816
  className: cn(
94598
94817
  child.props.className,
94599
94818
  elementClassName,
94600
- "magnetic-element"
94819
+ "magnetic-element cursor-pointer"
94601
94820
  ),
94602
94821
  key: index2
94603
94822
  });
@@ -94610,29 +94829,34 @@ var MagneticElementsInternal = ({
94610
94829
  ref: containerRef,
94611
94830
  className: cn(
94612
94831
  "relative",
94613
- enable3D && "transform-gpu",
94614
94832
  containerClassName
94615
94833
  ),
94834
+ onMouseMove: handleMouseMove2,
94835
+ onMouseEnter: handleMouseEnter,
94836
+ onMouseLeave: handleMouseLeave2,
94837
+ onTouchMove: enableTouch ? handleTouchMove : void 0,
94838
+ onTouchEnd: enableTouch ? handleMouseLeave2 : void 0,
94616
94839
  style: {
94617
- perspective: enable3D ? perspective : void 0
94840
+ perspective: tilt ? "1000px" : void 0
94618
94841
  },
94619
94842
  children: [
94620
94843
  processedChildren,
94621
- debug && /* @__PURE__ */ jsxs("div", { className: "absolute inset-0 pointer-events-none border-2 border-dashed border-gray-400 opacity-50", children: [
94844
+ debug && isReady && /* @__PURE__ */ jsxs("div", { className: "absolute inset-0 pointer-events-none", children: [
94622
94845
  /* @__PURE__ */ jsx(
94623
94846
  "div",
94624
94847
  {
94625
- className: "absolute w-4 h-4 bg-red-500 rounded-full -translate-x-1/2 -translate-y-1/2",
94848
+ className: "absolute w-2 h-2 bg-red-500 rounded-full -translate-x-1/2 -translate-y-1/2 z-50",
94626
94849
  style: {
94627
94850
  left: mouseRef.current.x,
94628
- top: mouseRef.current.y
94851
+ top: mouseRef.current.y,
94852
+ opacity: mouseRef.current.active ? 1 : 0.3
94629
94853
  }
94630
94854
  }
94631
94855
  ),
94632
94856
  /* @__PURE__ */ jsx(
94633
94857
  "div",
94634
94858
  {
94635
- className: "absolute border-2 border-red-500 rounded-full -translate-x-1/2 -translate-y-1/2 opacity-30",
94859
+ className: "absolute border-2 border-red-500 rounded-full -translate-x-1/2 -translate-y-1/2 opacity-20",
94636
94860
  style: {
94637
94861
  left: mouseRef.current.x,
94638
94862
  top: mouseRef.current.y,
@@ -95292,7 +95516,7 @@ var SpringPhysicsInternal = ({
95292
95516
  mouseRadius = 200,
95293
95517
  preset = "default",
95294
95518
  overshoot = true,
95295
- clamp: clamp2 = false,
95519
+ clamp: clamp3 = false,
95296
95520
  precision = 0.01,
95297
95521
  transform3d = false,
95298
95522
  rotate = false,
@@ -95391,7 +95615,7 @@ var SpringPhysicsInternal = ({
95391
95615
  x: (velocity.x || 0) + force.x / mass * deltaTime,
95392
95616
  y: (velocity.y || 0) + force.y / mass * deltaTime
95393
95617
  };
95394
- if (clamp2 && !overshoot) {
95618
+ if (clamp3 && !overshoot) {
95395
95619
  const distX = Math.abs((targetPos.x || 0) - position.x);
95396
95620
  const distY = Math.abs((targetPos.y || 0) - position.y);
95397
95621
  if (distX < 1)
@@ -95454,7 +95678,7 @@ var SpringPhysicsInternal = ({
95454
95678
  mass,
95455
95679
  precision,
95456
95680
  overshoot,
95457
- clamp2,
95681
+ clamp3,
95458
95682
  trail,
95459
95683
  trailCount,
95460
95684
  trailDecay,
@@ -103263,24 +103487,20 @@ export default function Component() {
103263
103487
  /**
103264
103488
  * MouseTrail Component
103265
103489
  *
103266
- * Creates interactive trail effects following mouse movement
103267
- * Derived from React Bits (https://github.com/DavidHDev/react-bits)
103268
- * Adapted for MoonUI Pro with TypeScript and enhanced features
103490
+ * High-performance interactive particle trail following mouse movement
103491
+ * Optimized with frame rate limiting, object pooling, and efficient rendering
103269
103492
  *
103270
103493
  * @author MoonUI Team
103271
- * @license MIT
103272
- * @credits React Bits by David H
103494
+ * @license Commercial
103273
103495
  */
103274
103496
  /**
103275
103497
  * MagneticElements Component
103276
103498
  *
103277
- * Creates magnetic effect where elements are attracted to or repelled from cursor
103278
- * Derived from React Bits (https://github.com/DavidHDev/react-bits)
103279
- * Adapted for MoonUI Pro with TypeScript and enhanced features
103499
+ * High-performance magnetic effect where elements are attracted to or repelled from cursor
103500
+ * Optimized for smooth animations and professional interactions
103280
103501
  *
103281
103502
  * @author MoonUI Team
103282
- * @license MIT
103283
- * @credits React Bits by David H
103503
+ * @license Commercial
103284
103504
  */
103285
103505
  /**
103286
103506
  * ScrollReveal Component