fetta 1.5.0 → 1.5.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/motion.js CHANGED
@@ -1,10 +1,8 @@
1
- import { waitForFontsReady, reapplyInitialStyles, reapplyInitialClasses } from './chunk-FP4I6OR2.js';
2
- import { splitTextData, normalizeToPromise, resolveAutoSplitTargets, getObservedWidth, recordWidthChange, buildKerningStyleKey, resolveAutoSplitWidth, querySplitWords, clearKerningCompensation, applyKerningCompensation } from './chunk-UPF3IYHC.js';
3
- import { __objRest, __spreadValues, __spreadProps } from './chunk-ORMEWXMH.js';
1
+ import { waitForFontsReady, reapplyInitialStyles, reapplyInitialClasses } from './chunk-V7FJXNWJ.js';
2
+ import { splitTextData, buildLineFingerprintFromData, normalizeToPromise, buildKerningStyleKey, resolveAutoSplitTargets, getObservedWidth, recordWidthChange, resolveAutoSplitWidth, querySplitWords, clearKerningCompensation, applyKerningCompensation } from './chunk-OUXSJF3P.js';
4
3
  import { scroll, animate } from 'motion';
5
4
  import { usePresence, useReducedMotion, MotionConfig, motion } from 'motion/react';
6
- import { flushSync } from 'react-dom';
7
- import { forwardRef, useRef, useState, useId, useCallback, useMemo, useLayoutEffect, useEffect, isValidElement, createElement, cloneElement } from 'react';
5
+ import { forwardRef, useRef, useState, useCallback, useMemo, useLayoutEffect, isValidElement, useEffect, createElement, cloneElement } from 'react';
8
6
 
9
7
  var ELEMENT_TYPE_KEYS = ["chars", "words", "lines"];
10
8
  var VOID_HTML_TAGS = /* @__PURE__ */ new Set(["br", "hr", "img", "input", "meta", "link"]);
@@ -54,7 +52,7 @@ function getVariantTransition(def) {
54
52
  }
55
53
  function withDefaultTransition(target, defaultTransition, delayScope) {
56
54
  const needsDelayResolution = (transition) => {
57
- const delay = transition == null ? void 0 : transition.delay;
55
+ const delay = transition?.delay;
58
56
  if (typeof delay === "function") return true;
59
57
  if (typeof delay === "number") return !Number.isFinite(delay);
60
58
  return false;
@@ -74,7 +72,10 @@ function withDefaultTransition(target, defaultTransition, delayScope) {
74
72
  return void 0;
75
73
  };
76
74
  const mergeTransitions = (base, override, info) => {
77
- const merged = __spreadValues(__spreadValues({}, base != null ? base : {}), override != null ? override : {});
75
+ const merged = {
76
+ ...base ?? {},
77
+ ...override ?? {}
78
+ };
78
79
  if ("delay" in merged) {
79
80
  const resolved = resolveDelay(merged.delay, info);
80
81
  if (resolved == null) {
@@ -93,9 +94,9 @@ function withDefaultTransition(target, defaultTransition, delayScope) {
93
94
  resolved.transition,
94
95
  info
95
96
  );
96
- if (transition) return __spreadProps(__spreadValues({}, resolved), { transition });
97
+ if (transition) return { ...resolved, transition };
97
98
  if (resolved.transition) {
98
- const _a = resolved, { transition: _removed } = _a, rest = __objRest(_a, ["transition"]);
99
+ const { transition: _removed, ...rest } = resolved;
99
100
  return rest;
100
101
  }
101
102
  return resolved;
@@ -108,31 +109,30 @@ function withDefaultTransition(target, defaultTransition, delayScope) {
108
109
  target.transition,
109
110
  info
110
111
  );
111
- return transition ? __spreadProps(__spreadValues({}, target), { transition }) : target;
112
+ return transition ? { ...target, transition } : target;
112
113
  };
113
114
  }
114
115
  if (!defaultTransition) return target;
115
116
  if (!target.transition) {
116
- return __spreadProps(__spreadValues({}, target), { transition: defaultTransition });
117
+ return { ...target, transition: defaultTransition };
117
118
  }
118
- return __spreadProps(__spreadValues({}, target), {
119
- transition: __spreadValues(__spreadValues({}, defaultTransition), target.transition)
120
- });
119
+ return {
120
+ ...target,
121
+ transition: { ...defaultTransition, ...target.transition }
122
+ };
121
123
  }
122
124
  function getTargetType(data, type) {
123
- var _a, _b, _c;
124
- const hasChars = (_a = data.meta.type) == null ? void 0 : _a.includes("chars");
125
- const hasWords = (_b = data.meta.type) == null ? void 0 : _b.includes("words");
126
- const hasLines = (_c = data.meta.type) == null ? void 0 : _c.includes("lines");
127
- if ((type == null ? void 0 : type.includes("chars")) && hasChars) return "chars";
128
- if ((type == null ? void 0 : type.includes("words")) && hasWords) return "words";
129
- if ((type == null ? void 0 : type.includes("lines")) && hasLines) return "lines";
125
+ const hasChars = data.meta.type?.includes("chars");
126
+ const hasWords = data.meta.type?.includes("words");
127
+ const hasLines = data.meta.type?.includes("lines");
128
+ if (type?.includes("chars") && hasChars) return "chars";
129
+ if (type?.includes("words") && hasWords) return "words";
130
+ if (type?.includes("lines") && hasLines) return "lines";
130
131
  if (hasChars) return "chars";
131
132
  if (hasWords) return "words";
132
133
  return "lines";
133
134
  }
134
135
  function buildVariantsByType(variants, targetType, childDefaultTransition, delayScope, forceInstant = false) {
135
- var _a;
136
136
  if (!variants) return { types: {}, wrapper: {} };
137
137
  const result = {};
138
138
  const wrapperVariants = {};
@@ -141,22 +141,22 @@ function buildVariantsByType(variants, targetType, childDefaultTransition, delay
141
141
  if (typeof target === "function") {
142
142
  return (info) => {
143
143
  const resolved = target(info);
144
- return __spreadProps(__spreadValues({}, resolved), { transition: instantTransition });
144
+ return { ...resolved, transition: instantTransition };
145
145
  };
146
146
  }
147
- return __spreadProps(__spreadValues({}, target), { transition: instantTransition });
147
+ return { ...target, transition: instantTransition };
148
148
  };
149
149
  const applyInstantWrapper = (target) => {
150
150
  if (typeof target === "function") {
151
151
  return ({ custom }) => {
152
152
  const resolved = target({ custom });
153
- return __spreadProps(__spreadValues({}, resolved), { transition: instantTransition });
153
+ return { ...resolved, transition: instantTransition };
154
154
  };
155
155
  }
156
- return __spreadProps(__spreadValues({}, target), { transition: instantTransition });
156
+ return { ...target, transition: instantTransition };
157
157
  };
158
158
  for (const [name, def] of Object.entries(variants)) {
159
- const defaultTransition = isPerTypeVariant(def) ? (_a = def.transition) != null ? _a : childDefaultTransition : childDefaultTransition;
159
+ const defaultTransition = isPerTypeVariant(def) ? def.transition ?? childDefaultTransition : childDefaultTransition;
160
160
  const resolvedDefault = forceInstant ? instantTransition : defaultTransition;
161
161
  if (isPerTypeVariant(def)) {
162
162
  if (def.wrapper) {
@@ -190,14 +190,14 @@ function collectRelations(nodes) {
190
190
  let nextContext = context;
191
191
  if (node.split === "line") {
192
192
  const lineIndex = counts.lines++;
193
- nextContext = __spreadProps(__spreadValues({}, context), { lineIndex });
193
+ nextContext = { ...context, lineIndex };
194
194
  }
195
195
  if (node.split === "word") {
196
196
  const wordIndex = counts.words++;
197
197
  if (nextContext.lineIndex != null) {
198
198
  wordToLine[wordIndex] = nextContext.lineIndex;
199
199
  }
200
- nextContext = __spreadProps(__spreadValues({}, nextContext), { wordIndex });
200
+ nextContext = { ...nextContext, wordIndex };
201
201
  }
202
202
  if (node.split === "char") {
203
203
  const charIndex = counts.chars++;
@@ -313,24 +313,24 @@ function buildVariantInfo(elementType, globalIndex, total, maps, isPresent, cust
313
313
  };
314
314
  }
315
315
  function getTargetElements(result, type) {
316
- if (type == null ? void 0 : type.includes("chars")) return result.chars;
317
- if (type == null ? void 0 : type.includes("words")) return result.words;
318
- if (type == null ? void 0 : type.includes("lines")) return result.lines;
316
+ if (type?.includes("chars")) return result.chars;
317
+ if (type?.includes("words")) return result.words;
318
+ if (type?.includes("lines")) return result.lines;
319
319
  if (result.chars.length) return result.chars;
320
320
  if (result.words.length) return result.words;
321
321
  if (result.lines.length) return result.lines;
322
322
  return [];
323
323
  }
324
324
  function getTargetTypeForElements(result, type) {
325
- if (type == null ? void 0 : type.includes("chars")) return "chars";
326
- if (type == null ? void 0 : type.includes("words")) return "words";
327
- if (type == null ? void 0 : type.includes("lines")) return "lines";
325
+ if (type?.includes("chars")) return "chars";
326
+ if (type?.includes("words")) return "words";
327
+ if (type?.includes("lines")) return "lines";
328
328
  if (result.chars.length) return "chars";
329
329
  if (result.words.length) return "words";
330
330
  return "lines";
331
331
  }
332
332
  function extractTransition(variant) {
333
- const _a = variant, { transition } = _a, props = __objRest(_a, ["transition"]);
333
+ const { transition, ...props } = variant;
334
334
  return { props, transition };
335
335
  }
336
336
  function buildIndexMapsDom(result) {
@@ -394,7 +394,7 @@ function buildStaticItems(elements, elementType, props, transition, maps, isPres
394
394
  isPresent,
395
395
  custom
396
396
  );
397
- let merged = transition ? __spreadValues({}, transition) : void 0;
397
+ let merged = transition ? { ...transition } : void 0;
398
398
  if (merged && "delay" in merged) {
399
399
  const rawDelay = merged.delay;
400
400
  const resolvedDelay = typeof rawDelay === "function" ? rawDelay(
@@ -404,7 +404,7 @@ function buildStaticItems(elements, elementType, props, transition, maps, isPres
404
404
  if (resolvedDelay != null && Number.isFinite(resolvedDelay)) {
405
405
  merged.delay = resolvedDelay;
406
406
  } else {
407
- const _a = merged, { delay: _removed } = _a, restNoDelay = __objRest(_a, ["delay"]);
407
+ const { delay: _removed, ...restNoDelay } = merged;
408
408
  merged = restNoDelay;
409
409
  }
410
410
  }
@@ -418,7 +418,7 @@ function buildStaticItems(elements, elementType, props, transition, maps, isPres
418
418
  }
419
419
  function buildSequenceFromItems(items) {
420
420
  return items.map((item) => {
421
- const sequenceTransition = item.transition ? __spreadValues({}, item.transition) : {};
421
+ const sequenceTransition = item.transition ? { ...item.transition } : {};
422
422
  const delay = sequenceTransition.delay;
423
423
  const hasExplicitAt = sequenceTransition.at != null;
424
424
  const at = hasExplicitAt ? sequenceTransition.at : typeof delay === "number" && Number.isFinite(delay) ? delay : 0;
@@ -430,9 +430,8 @@ function buildSequenceFromItems(items) {
430
430
  });
431
431
  }
432
432
  function buildFnItems(elements, elementType, fn, maps, transition, isPresent, delayScope, custom, forceInstant = false) {
433
- var _c;
434
433
  const t = transition;
435
- const _a = t || {}, { delay: outerDelay, duration } = _a, rest = __objRest(_a, ["delay", "duration"]);
434
+ const { delay: outerDelay, duration, ...rest } = t || {};
436
435
  const items = [];
437
436
  const total = elements.length;
438
437
  const instantTransition = { duration: 0, delay: 0 };
@@ -445,24 +444,24 @@ function buildFnItems(elements, elementType, fn, maps, transition, isPresent, de
445
444
  isPresent,
446
445
  custom
447
446
  );
448
- const _b = fn(info), { transition: localT } = _b, props = __objRest(_b, ["transition"]);
447
+ const { transition: localT, ...props } = fn(info);
449
448
  let merged;
450
449
  if (forceInstant) {
451
450
  merged = instantTransition;
452
451
  } else {
453
- merged = localT ? __spreadValues(__spreadValues({}, rest), localT) : __spreadValues({}, rest);
452
+ merged = localT ? { ...rest, ...localT } : { ...rest };
454
453
  if (duration != null && merged.duration == null) {
455
- merged = __spreadProps(__spreadValues({}, merged), { duration });
454
+ merged = { ...merged, duration };
456
455
  }
457
- const rawDelay = (_c = merged.delay) != null ? _c : outerDelay;
456
+ const rawDelay = merged.delay ?? outerDelay;
458
457
  const resolvedDelay = typeof rawDelay === "function" ? rawDelay(
459
458
  delayScope === "local" ? info.index : info.globalIndex,
460
459
  delayScope === "local" ? info.count : info.globalCount
461
460
  ) : rawDelay;
462
461
  if (resolvedDelay != null && Number.isFinite(resolvedDelay)) {
463
- merged = __spreadProps(__spreadValues({}, merged), { delay: resolvedDelay });
462
+ merged = { ...merged, delay: resolvedDelay };
464
463
  } else if ("delay" in merged) {
465
- const _d = merged, { delay: _removed } = _d, restNoDelay = __objRest(_d, ["delay"]);
464
+ const { delay: _removed, ...restNoDelay } = merged;
466
465
  merged = restNoDelay;
467
466
  }
468
467
  }
@@ -683,7 +682,7 @@ function serializeInitial(value) {
683
682
  if (typeof value === "string") return value;
684
683
  try {
685
684
  return JSON.stringify(value);
686
- } catch (e) {
685
+ } catch {
687
686
  return String(value);
688
687
  }
689
688
  }
@@ -699,22 +698,21 @@ function serializeNode(node) {
699
698
  const elementType = node.type;
700
699
  const type = typeof elementType === "string" ? elementType : elementType.displayName || elementType.name || "Component";
701
700
  const props = node.props;
702
- const className = typeof (props == null ? void 0 : props.className) === "string" ? props.className : "";
701
+ const className = typeof props?.className === "string" ? props.className : "";
703
702
  return `<${type}${className ? `.${className}` : ""}>${serializeNode(
704
- props == null ? void 0 : props.children
703
+ props?.children
705
704
  )}</${type}>`;
706
705
  }
707
706
  return "";
708
707
  }
709
708
  function buildSplitSignature(child, options, initialStyles, initialClasses) {
710
- var _a, _b, _c, _d, _e;
711
- const opt = options != null ? options : {};
709
+ const opt = options ?? {};
712
710
  const signature = {
713
- type: (_a = opt.type) != null ? _a : "",
714
- charClass: (_b = opt.charClass) != null ? _b : "",
715
- wordClass: (_c = opt.wordClass) != null ? _c : "",
716
- lineClass: (_d = opt.lineClass) != null ? _d : "",
717
- mask: (_e = opt.mask) != null ? _e : "",
711
+ type: opt.type ?? "",
712
+ charClass: opt.charClass ?? "",
713
+ wordClass: opt.wordClass ?? "",
714
+ lineClass: opt.lineClass ?? "",
715
+ mask: opt.mask ?? "",
718
716
  propIndex: !!opt.propIndex,
719
717
  disableKerning: !!opt.disableKerning,
720
718
  isolateKerningMeasurement: opt.isolateKerningMeasurement !== false,
@@ -724,25 +722,23 @@ function buildSplitSignature(child, options, initialStyles, initialClasses) {
724
722
  };
725
723
  try {
726
724
  return JSON.stringify(signature);
727
- } catch (e) {
725
+ } catch {
728
726
  return String(signature);
729
727
  }
730
728
  }
731
729
  function getMotionComponent(tag) {
732
- var _a;
733
730
  const registry = motion;
734
- return (_a = registry[tag]) != null ? _a : motion.span;
731
+ return registry[tag] ?? motion.span;
735
732
  }
736
733
  function collectSplitElements(element, options) {
737
- var _a, _b, _c;
738
734
  const normalizeSelector = (value) => {
739
735
  const tokens = value.split(/\s+/).filter(Boolean);
740
736
  if (tokens.length === 0) return "";
741
737
  return `.${tokens.join(".")}`;
742
738
  };
743
- const charClass = normalizeSelector((_a = options == null ? void 0 : options.charClass) != null ? _a : "split-char");
744
- const wordClass = normalizeSelector((_b = options == null ? void 0 : options.wordClass) != null ? _b : "split-word");
745
- const lineClass = normalizeSelector((_c = options == null ? void 0 : options.lineClass) != null ? _c : "split-line");
739
+ const charClass = normalizeSelector(options?.charClass ?? "split-char");
740
+ const wordClass = normalizeSelector(options?.wordClass ?? "split-word");
741
+ const lineClass = normalizeSelector(options?.lineClass ?? "split-line");
746
742
  const chars = Array.from(
747
743
  element.querySelectorAll(charClass)
748
744
  );
@@ -756,7 +752,7 @@ function collectSplitElements(element, options) {
756
752
  } };
757
753
  }
758
754
  function resolveSplitFlags(type) {
759
- const resolvedType = type != null ? type : "chars,words,lines";
755
+ const resolvedType = type ?? "chars,words,lines";
760
756
  let splitChars = resolvedType.includes("chars");
761
757
  let splitWords = resolvedType.includes("words");
762
758
  let splitLines = resolvedType.includes("lines");
@@ -767,28 +763,6 @@ function resolveSplitFlags(type) {
767
763
  }
768
764
  return { splitChars, splitWords, splitLines };
769
765
  }
770
- function normalizeLineFingerprintText(value) {
771
- return value.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
772
- }
773
- function collectNodeText(node) {
774
- if (node.type === "text") return node.text;
775
- return node.children.map((child) => collectNodeText(child)).join("");
776
- }
777
- function collectLineTextsFromData(nodes, lineTexts) {
778
- for (const node of nodes) {
779
- if (node.type !== "element") continue;
780
- if (node.split === "line") {
781
- lineTexts.push(normalizeLineFingerprintText(collectNodeText(node)));
782
- continue;
783
- }
784
- collectLineTextsFromData(node.children, lineTexts);
785
- }
786
- }
787
- function buildLineFingerprintFromData(data) {
788
- const lineTexts = [];
789
- collectLineTextsFromData(data.nodes, lineTexts);
790
- return lineTexts.join("\n");
791
- }
792
766
  function buildSplitDataLayout(data) {
793
767
  const relations = collectRelations(data.nodes);
794
768
  const maps = buildIndexMaps(relations);
@@ -822,81 +796,44 @@ function buildVariantInfos(splitDataLayout, isPresent, custom) {
822
796
  counts: relations.counts
823
797
  };
824
798
  }
825
- var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
826
- var _b = _a, {
827
- children,
828
- as: Component = "div",
829
- className,
830
- style: userStyle,
831
- onSplit,
832
- onResplit,
833
- options,
834
- autoSplit = false,
835
- animateOnResplit = false,
836
- revertOnComplete = false,
837
- viewport,
838
- onViewportEnter,
839
- onViewportLeave,
840
- onRevert,
841
- initialStyles,
842
- initialClasses,
843
- resetOnViewportLeave = false,
844
- waitForFonts = true,
845
- variants,
846
- initial: initialVariant,
847
- animate: animateVariantName,
848
- whileInView,
849
- whileOutOfView,
850
- whileScroll,
851
- exit,
852
- scroll: scrollProp,
853
- whileHover,
854
- whileTap,
855
- whileFocus,
856
- reducedMotion,
857
- custom,
858
- onHoverStart,
859
- onHoverEnd,
860
- transition,
861
- delayScope = "global"
862
- } = _b, wrapperProps = __objRest(_b, [
863
- "children",
864
- "as",
865
- "className",
866
- "style",
867
- "onSplit",
868
- "onResplit",
869
- "options",
870
- "autoSplit",
871
- "animateOnResplit",
872
- "revertOnComplete",
873
- "viewport",
874
- "onViewportEnter",
875
- "onViewportLeave",
876
- "onRevert",
877
- "initialStyles",
878
- "initialClasses",
879
- "resetOnViewportLeave",
880
- "waitForFonts",
881
- "variants",
882
- "initial",
883
- "animate",
884
- "whileInView",
885
- "whileOutOfView",
886
- "whileScroll",
887
- "exit",
888
- "scroll",
889
- "whileHover",
890
- "whileTap",
891
- "whileFocus",
892
- "reducedMotion",
893
- "custom",
894
- "onHoverStart",
895
- "onHoverEnd",
896
- "transition",
897
- "delayScope"
898
- ]);
899
- var _a2, _b2, _c, _d, _e, _f;
799
+ var SplitText = forwardRef(function SplitText2({
800
+ children,
801
+ as: Component = "div",
802
+ className,
803
+ style: userStyle,
804
+ onSplit,
805
+ onResplit,
806
+ options,
807
+ autoSplit = false,
808
+ animateOnResplit = false,
809
+ revertOnComplete = false,
810
+ viewport,
811
+ onViewportEnter,
812
+ onViewportLeave,
813
+ onRevert,
814
+ initialStyles,
815
+ initialClasses,
816
+ resetOnViewportLeave = false,
817
+ waitForFonts = true,
818
+ variants,
819
+ initial: initialVariant,
820
+ animate: animateVariantName,
821
+ whileInView,
822
+ whileOutOfView,
823
+ whileScroll,
824
+ exit,
825
+ scroll: scrollProp,
826
+ whileHover,
827
+ whileTap,
828
+ whileFocus,
829
+ reducedMotion,
830
+ custom,
831
+ onHoverStart,
832
+ onHoverEnd,
833
+ transition,
834
+ delayScope = "global",
835
+ ...wrapperProps
836
+ }, forwardedRef) {
900
837
  const containerRef = useRef(null);
901
838
  const [childElement, setChildElement] = useState(null);
902
839
  const [data, setData] = useState(null);
@@ -905,7 +842,6 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
905
842
  const [isInView, setIsInView] = useState(false);
906
843
  const [isPresent, safeToRemove] = usePresence();
907
844
  const presenceEnabled = typeof safeToRemove === "function";
908
- const instanceId = useId();
909
845
  const prefersReducedMotion = useReducedMotion();
910
846
  const reduceMotionActive = reducedMotion === "always" || reducedMotion === "user" && !!prefersReducedMotion;
911
847
  const [isHovered, setIsHovered] = useState(false);
@@ -938,16 +874,18 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
938
874
  const whileTapLabel = inlineWhileTapVariant ? "__fetta_whileTap__" : whileTap;
939
875
  const whileFocusLabel = inlineWhileFocusVariant ? "__fetta_whileFocus__" : whileFocus;
940
876
  const needsViewport = !!(whileInViewLabel || whileOutOfViewLabel || onViewportEnter || onViewportLeave || resetOnViewportLeave || viewport);
941
- const viewportAmount = (_a2 = viewport == null ? void 0 : viewport.amount) != null ? _a2 : 0;
942
- const viewportLeave = (_b2 = viewport == null ? void 0 : viewport.leave) != null ? _b2 : 0;
943
- const viewportMargin = (_c = viewport == null ? void 0 : viewport.margin) != null ? _c : "0px";
944
- const viewportOnce = (_d = viewport == null ? void 0 : viewport.once) != null ? _d : false;
945
- const viewportRoot = (_f = (_e = viewport == null ? void 0 : viewport.root) == null ? void 0 : _e.current) != null ? _f : null;
877
+ const viewportAmount = viewport?.amount ?? 0;
878
+ const viewportLeave = viewport?.leave ?? 0;
879
+ const viewportMargin = viewport?.margin ?? "0px";
880
+ const viewportOnce = viewport?.once ?? false;
881
+ const viewportRoot = viewport?.root?.current ?? null;
946
882
  const resolvedVariants = useMemo(() => {
947
883
  if (!variants && !inlineInitialVariant && !inlineAnimateVariant && !inlineExitVariant && !inlineWhileInViewVariant && !inlineWhileOutOfViewVariant && !inlineWhileScrollVariant && !inlineWhileHoverVariant && !inlineWhileTapVariant && !inlineWhileFocusVariant) {
948
884
  return variants;
949
885
  }
950
- const merged = __spreadValues({}, variants != null ? variants : {});
886
+ const merged = {
887
+ ...variants ?? {}
888
+ };
951
889
  if (inlineInitialVariant) {
952
890
  merged.__fetta_initial__ = initialVariant;
953
891
  }
@@ -1016,7 +954,6 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1016
954
  const initialVariantRef = useRef(initialLabel);
1017
955
  const whileInViewRef = useRef(whileInViewLabel);
1018
956
  const whileOutOfViewRef = useRef(whileOutOfViewLabel);
1019
- const debugPresence = (options == null ? void 0 : options.__debugPresence) === true;
1020
957
  useLayoutEffect(() => {
1021
958
  onSplitRef.current = onSplit;
1022
959
  onResplitRef.current = onResplit;
@@ -1033,26 +970,6 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1033
970
  whileInViewRef.current = whileInViewLabel;
1034
971
  whileOutOfViewRef.current = whileOutOfViewLabel;
1035
972
  });
1036
- useEffect(() => {
1037
- if (!debugPresence) return;
1038
- console.log(
1039
- "[fetta][SplitText]",
1040
- instanceId,
1041
- "present",
1042
- isPresent,
1043
- "ready",
1044
- isReady,
1045
- "data",
1046
- !!data
1047
- );
1048
- }, [debugPresence, instanceId, isPresent, isReady, data]);
1049
- useEffect(() => {
1050
- if (!debugPresence) return;
1051
- console.log("[fetta][SplitText]", instanceId, "mount");
1052
- return () => {
1053
- console.log("[fetta][SplitText]", instanceId, "unmount");
1054
- };
1055
- }, [debugPresence, instanceId]);
1056
973
  const hasSplitRef = useRef(false);
1057
974
  const hasRevertedRef = useRef(false);
1058
975
  const splitResultRef = useRef(null);
@@ -1072,8 +989,7 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1072
989
  const hasRunOnSplitForCycleRef = useRef(false);
1073
990
  const originalHTMLRef = useRef(null);
1074
991
  useLayoutEffect(() => {
1075
- var _a3;
1076
- const element = (_a3 = containerRef.current) == null ? void 0 : _a3.firstElementChild;
992
+ const element = containerRef.current?.firstElementChild;
1077
993
  setChildElement(element instanceof HTMLElement ? element : null);
1078
994
  }, [children, data]);
1079
995
  const splitSignature = useMemo(() => {
@@ -1120,14 +1036,13 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1120
1036
  resetSplitState(next);
1121
1037
  }, [isPresent, resetSplitState]);
1122
1038
  function setupViewportObserver(container) {
1123
- var _a3, _b3, _c2, _d2, _e2;
1124
1039
  const vpOptions = viewportRef.current || {};
1125
- const amount = (_a3 = vpOptions.amount) != null ? _a3 : 0;
1126
- const leave = (_b3 = vpOptions.leave) != null ? _b3 : 0;
1040
+ const amount = vpOptions.amount ?? 0;
1041
+ const leave = vpOptions.leave ?? 0;
1127
1042
  const threshold = amount === "some" ? 0 : amount === "all" ? 1 : amount;
1128
1043
  const leaveThreshold = leave === "some" ? 0 : leave === "all" ? 1 : leave;
1129
- const rootMargin = (_c2 = vpOptions.margin) != null ? _c2 : "0px";
1130
- const root = (_e2 = (_d2 = vpOptions.root) == null ? void 0 : _d2.current) != null ? _e2 : void 0;
1044
+ const rootMargin = vpOptions.margin ?? "0px";
1045
+ const root = vpOptions.root?.current ?? void 0;
1131
1046
  const thresholdValues = Array.from(
1132
1047
  /* @__PURE__ */ new Set([0, threshold, leaveThreshold])
1133
1048
  ).sort((a, b) => a - b);
@@ -1154,15 +1069,13 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1154
1069
  observerRef.current.observe(container);
1155
1070
  }
1156
1071
  const buildSplitDataFromProbe = useCallback((width) => {
1157
- var _a3;
1158
1072
  const currentChild = childElement && childElement.isConnected ? childElement : (() => {
1159
- var _a4;
1160
- const element = (_a4 = containerRef.current) == null ? void 0 : _a4.firstElementChild;
1073
+ const element = containerRef.current?.firstElementChild;
1161
1074
  return element instanceof HTMLElement ? element : null;
1162
1075
  })();
1163
1076
  if (!currentChild) return null;
1164
1077
  if (!currentChild.parentElement) return null;
1165
- const originalHTML = (_a3 = originalHTMLRef.current) != null ? _a3 : currentChild.innerHTML;
1078
+ const originalHTML = originalHTMLRef.current ?? currentChild.innerHTML;
1166
1079
  originalHTMLRef.current = originalHTML;
1167
1080
  const probeHost = currentChild.ownerDocument.createElement("div");
1168
1081
  probeHost.setAttribute("data-fetta-auto-split-probe", "true");
@@ -1172,17 +1085,18 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1172
1085
  probeHost.style.visibility = "hidden";
1173
1086
  probeHost.style.pointerEvents = "none";
1174
1087
  probeHost.style.contain = "layout style paint";
1175
- const measuredWidth = width != null ? width : currentChild.getBoundingClientRect().width;
1088
+ const measuredWidth = width ?? currentChild.getBoundingClientRect().width;
1176
1089
  probeHost.style.width = `${Math.max(1, measuredWidth)}px`;
1177
1090
  const probeElement = currentChild.cloneNode(false);
1178
1091
  probeElement.innerHTML = originalHTML;
1179
1092
  probeHost.appendChild(probeElement);
1180
1093
  currentChild.parentElement.appendChild(probeHost);
1181
1094
  try {
1182
- const probeData = splitTextData(probeElement, __spreadProps(__spreadValues({}, optionsRef.current), {
1095
+ const probeData = splitTextData(probeElement, {
1096
+ ...optionsRef.current,
1183
1097
  initialStyles: initialStylesRef.current,
1184
1098
  initialClasses: initialClassesRef.current
1185
- }));
1099
+ });
1186
1100
  return probeData;
1187
1101
  } finally {
1188
1102
  probeHost.remove();
@@ -1192,13 +1106,11 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1192
1106
  (isResize = false, width) => {
1193
1107
  const nextData = buildSplitDataFromProbe(width);
1194
1108
  if (!nextData) return;
1195
- flushSync(() => {
1196
- setChildTreeVersion((current) => current + 1);
1197
- if (!isResize) {
1198
- setIsReady(false);
1199
- }
1200
- setData(nextData);
1201
- });
1109
+ setChildTreeVersion((current) => current + 1);
1110
+ if (!isResize) {
1111
+ setIsReady(false);
1112
+ }
1113
+ setData(nextData);
1202
1114
  },
1203
1115
  [buildSplitDataFromProbe]
1204
1116
  );
@@ -1208,9 +1120,8 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1208
1120
  return buildLineFingerprintFromData(probeData);
1209
1121
  }, [buildSplitDataFromProbe]);
1210
1122
  const resolveLineMeasureWidth = useCallback((fallbackWidth) => {
1211
- var _a3;
1212
1123
  const safeFallbackWidth = Number.isFinite(fallbackWidth) && fallbackWidth > 0 ? fallbackWidth : 1;
1213
- const observedChild = (_a3 = containerRef.current) == null ? void 0 : _a3.firstElementChild;
1124
+ const observedChild = containerRef.current?.firstElementChild;
1214
1125
  if (observedChild instanceof HTMLElement) {
1215
1126
  const childWidth = observedChild.getBoundingClientRect().width;
1216
1127
  if (Number.isFinite(childWidth) && childWidth > 0) {
@@ -1238,12 +1149,11 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1238
1149
  [data]
1239
1150
  );
1240
1151
  useEffect(() => {
1241
- var _a3;
1242
1152
  if (!data) {
1243
1153
  currentLineFingerprintRef.current = null;
1244
1154
  return;
1245
1155
  }
1246
- const { splitLines } = resolveSplitFlags((_a3 = optionsRef.current) == null ? void 0 : _a3.type);
1156
+ const { splitLines } = resolveSplitFlags(optionsRef.current?.type);
1247
1157
  currentLineFingerprintRef.current = splitLines ? buildLineFingerprintFromData(data) : null;
1248
1158
  }, [data]);
1249
1159
  const variantInfo = useMemo(
@@ -1252,7 +1162,7 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1252
1162
  );
1253
1163
  const targetType = useMemo(() => {
1254
1164
  if (!data) return "words";
1255
- return getTargetType(data, options == null ? void 0 : options.type);
1165
+ return getTargetType(data, options?.type);
1256
1166
  }, [data, options]);
1257
1167
  const orchestrationTransition = useMemo(
1258
1168
  () => pickOrchestration(transition),
@@ -1288,7 +1198,7 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1288
1198
  reduceMotionActive
1289
1199
  ]
1290
1200
  );
1291
- const nodePropsMap = splitDataLayout == null ? void 0 : splitDataLayout.propsByNode;
1201
+ const nodePropsMap = splitDataLayout?.propsByNode;
1292
1202
  const exitTypes = useMemo(() => {
1293
1203
  const exitKey = typeof exitLabel === "string" ? exitLabel : null;
1294
1204
  if (!exitKey) return [];
@@ -1315,15 +1225,13 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1315
1225
  }, [variantsByType, animateLabel]);
1316
1226
  const exitTotalCount = useMemo(() => {
1317
1227
  return exitTypes.reduce((sum, type) => {
1318
- var _a3;
1319
- const count = (_a3 = variantInfo.counts[type]) != null ? _a3 : 0;
1228
+ const count = variantInfo.counts[type] ?? 0;
1320
1229
  return sum + count;
1321
1230
  }, 0);
1322
1231
  }, [exitTypes, variantInfo.counts]);
1323
1232
  const revertTotalCount = useMemo(() => {
1324
1233
  return revertTypes.reduce((sum, type) => {
1325
- var _a3;
1326
- const count = (_a3 = variantInfo.counts[type]) != null ? _a3 : 0;
1234
+ const count = variantInfo.counts[type] ?? 0;
1327
1235
  return sum + count;
1328
1236
  }, 0);
1329
1237
  }, [revertTypes, variantInfo.counts]);
@@ -1342,23 +1250,27 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1342
1250
  const applyWrapperTransition = (target) => {
1343
1251
  if (!wrapperBaseTransition) return target;
1344
1252
  if (target.transition) {
1345
- return __spreadProps(__spreadValues({}, target), {
1346
- transition: __spreadValues(__spreadValues({}, wrapperBaseTransition), target.transition)
1347
- });
1253
+ return {
1254
+ ...target,
1255
+ transition: { ...wrapperBaseTransition, ...target.transition }
1256
+ };
1348
1257
  }
1349
- return __spreadProps(__spreadValues({}, target), { transition: wrapperBaseTransition });
1258
+ return { ...target, transition: wrapperBaseTransition };
1350
1259
  };
1351
1260
  if (wrapperVariant) {
1352
1261
  if (typeof wrapperVariant === "function") {
1353
1262
  const resolved = wrapperVariant({ custom });
1354
- result[key] = reduceMotionActive ? __spreadProps(__spreadValues({}, resolved), { transition: { duration: 0, delay: 0 } }) : applyWrapperTransition(resolved);
1263
+ result[key] = reduceMotionActive ? { ...resolved, transition: { duration: 0, delay: 0 } } : applyWrapperTransition(resolved);
1355
1264
  } else {
1356
- const resolved = reduceMotionActive ? __spreadProps(__spreadValues({}, wrapperVariant), { transition: { duration: 0, delay: 0 } }) : wrapperVariant;
1265
+ const resolved = reduceMotionActive ? { ...wrapperVariant, transition: { duration: 0, delay: 0 } } : wrapperVariant;
1357
1266
  result[key] = applyWrapperTransition(resolved);
1358
1267
  }
1359
1268
  continue;
1360
1269
  }
1361
- const transitionValue = reduceMotionActive ? { duration: 0, delay: 0 } : orchestrationTransition || localOrchestration ? __spreadValues(__spreadValues({}, orchestrationTransition != null ? orchestrationTransition : {}), localOrchestration != null ? localOrchestration : {}) : void 0;
1270
+ const transitionValue = reduceMotionActive ? { duration: 0, delay: 0 } : orchestrationTransition || localOrchestration ? {
1271
+ ...orchestrationTransition ?? {},
1272
+ ...localOrchestration ?? {}
1273
+ } : void 0;
1362
1274
  result[key] = transitionValue ? { transition: transitionValue } : {};
1363
1275
  }
1364
1276
  return result;
@@ -1382,21 +1294,15 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1382
1294
  }, [hasHover]);
1383
1295
  const hasTap = !!(whileTapLabel && hasVariants);
1384
1296
  const hasFocus = !!(whileFocusLabel && hasVariants);
1385
- const _g = wrapperProps, {
1297
+ const {
1386
1298
  onTapStart: userOnTapStart,
1387
1299
  onTapCancel: userOnTapCancel,
1388
1300
  onTap: userOnTap,
1389
1301
  onFocus: userOnFocus,
1390
1302
  onBlur: userOnBlur,
1391
- onAnimationComplete: userOnAnimationComplete
1392
- } = _g, passthroughWrapperProps = __objRest(_g, [
1393
- "onTapStart",
1394
- "onTapCancel",
1395
- "onTap",
1396
- "onFocus",
1397
- "onBlur",
1398
- "onAnimationComplete"
1399
- ]);
1303
+ onAnimationComplete: userOnAnimationComplete,
1304
+ ...passthroughWrapperProps
1305
+ } = wrapperProps;
1400
1306
  useEffect(() => {
1401
1307
  if (!hasTap) {
1402
1308
  setIsTapped(false);
@@ -1428,7 +1334,7 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1428
1334
  tracker.total = trackedExitCount;
1429
1335
  if (isPresent) return;
1430
1336
  if (!exitLabel || trackedExitCount === 0) {
1431
- safeToRemove == null ? void 0 : safeToRemove();
1337
+ safeToRemove?.();
1432
1338
  }
1433
1339
  }, [
1434
1340
  presenceEnabled,
@@ -1446,7 +1352,7 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1446
1352
  if (definition !== exitLabel) return;
1447
1353
  tracker.completed += 1;
1448
1354
  if (tracker.completed >= tracker.total) {
1449
- safeToRemove == null ? void 0 : safeToRemove();
1355
+ safeToRemove?.();
1450
1356
  }
1451
1357
  },
1452
1358
  [presenceEnabled, exitLabel, safeToRemove]
@@ -1455,13 +1361,13 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1455
1361
  if (hasHover) {
1456
1362
  setIsHovered(true);
1457
1363
  }
1458
- onHoverStart == null ? void 0 : onHoverStart();
1364
+ onHoverStart?.();
1459
1365
  }, [hasHover, onHoverStart]);
1460
1366
  const handleHoverEnd = useCallback(() => {
1461
1367
  if (hasHover) {
1462
1368
  setIsHovered(false);
1463
1369
  }
1464
- onHoverEnd == null ? void 0 : onHoverEnd();
1370
+ onHoverEnd?.();
1465
1371
  }, [hasHover, onHoverEnd]);
1466
1372
  const handleTapStart = useCallback((...args) => {
1467
1373
  if (hasTap) {
@@ -1516,7 +1422,6 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1516
1422
  [hasWrapperExitVariant, handleExitComplete, userOnAnimationComplete]
1517
1423
  );
1518
1424
  useEffect(() => {
1519
- var _a3;
1520
1425
  if (!hasVariants) return;
1521
1426
  if (!resolvedVariants) return;
1522
1427
  if (!isPresent) return;
@@ -1534,7 +1439,7 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1534
1439
  setActiveVariant(outName);
1535
1440
  return;
1536
1441
  }
1537
- if (!((_a3 = viewportRef.current) == null ? void 0 : _a3.once) && resetOnViewportLeaveRef.current) {
1442
+ if (!viewportRef.current?.once && resetOnViewportLeaveRef.current) {
1538
1443
  const initName = initialVariantRef.current;
1539
1444
  if (initName && typeof initName === "string" && vDefs[initName]) {
1540
1445
  setActiveVariant(initName);
@@ -1555,12 +1460,11 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1555
1460
  isPresent
1556
1461
  ]);
1557
1462
  useEffect(() => {
1558
- var _a3, _b3;
1559
1463
  if (!data || !childElement) return;
1560
- const liveChildElement = (_a3 = containerRef.current) == null ? void 0 : _a3.firstElementChild;
1464
+ const liveChildElement = containerRef.current?.firstElementChild;
1561
1465
  if (!(liveChildElement instanceof HTMLElement)) return;
1562
1466
  const splitElements = collectSplitElements(liveChildElement, optionsRef.current);
1563
- const expectedCounts = (_b3 = splitDataLayout == null ? void 0 : splitDataLayout.relations.counts) != null ? _b3 : {
1467
+ const expectedCounts = splitDataLayout?.relations.counts ?? {
1564
1468
  chars: 0,
1565
1469
  words: 0,
1566
1470
  lines: 0
@@ -1570,25 +1474,32 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1570
1474
  return;
1571
1475
  }
1572
1476
  const revert = () => {
1573
- var _a4;
1574
1477
  if (hasRevertedRef.current) return;
1575
1478
  hasRevertedRef.current = true;
1576
1479
  try {
1577
- (_a4 = onRevertRef.current) == null ? void 0 : _a4.call(onRevertRef);
1480
+ onRevertRef.current?.();
1578
1481
  } finally {
1579
1482
  setData(null);
1580
1483
  setIsReady(true);
1581
1484
  }
1582
1485
  };
1583
- splitResultRef.current = __spreadProps(__spreadValues({}, splitElements), { revert });
1486
+ splitResultRef.current = { ...splitElements, revert };
1584
1487
  splitResultVersionRef.current = childTreeVersion;
1585
1488
  if (pendingFullResplitRef.current) {
1586
1489
  if (onResplitRef.current) {
1587
- onResplitRef.current({
1588
- chars: splitElements.chars,
1589
- words: splitElements.words,
1590
- lines: splitElements.lines,
1591
- revert
1490
+ queueMicrotask(() => {
1491
+ const currentChild = containerRef.current?.firstElementChild;
1492
+ if (!(currentChild instanceof HTMLElement)) return;
1493
+ const currentSplitElements = collectSplitElements(
1494
+ currentChild,
1495
+ optionsRef.current
1496
+ );
1497
+ onResplitRef.current?.({
1498
+ chars: currentSplitElements.chars,
1499
+ words: currentSplitElements.words,
1500
+ lines: currentSplitElements.lines,
1501
+ revert
1502
+ });
1592
1503
  });
1593
1504
  }
1594
1505
  pendingFullResplitRef.current = false;
@@ -1605,9 +1516,8 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1605
1516
  const promise = normalizeToPromise(callbackResult);
1606
1517
  if (promise) {
1607
1518
  promise.then(() => {
1608
- var _a4;
1609
1519
  if (hasRevertedRef.current) return;
1610
- (_a4 = splitResultRef.current) == null ? void 0 : _a4.revert();
1520
+ splitResultRef.current?.revert();
1611
1521
  }).catch(() => {
1612
1522
  console.warn("[fetta] Animation rejected, text not reverted");
1613
1523
  });
@@ -1621,28 +1531,23 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1621
1531
  return void 0;
1622
1532
  }, [data, childElement, needsViewport, hasVariants, splitDataLayout, childTreeVersion]);
1623
1533
  useEffect(() => {
1624
- var _a3, _b3, _c2, _d2, _e2, _f2, _g2, _h, _i;
1625
1534
  if (!data) return;
1626
- const observedElement = (_a3 = containerRef.current) == null ? void 0 : _a3.firstElementChild;
1535
+ const observedElement = containerRef.current?.firstElementChild;
1627
1536
  if (!(observedElement instanceof HTMLElement)) return;
1628
1537
  const { splitChars, splitWords, splitLines } = resolveSplitFlags(
1629
- (_b3 = optionsRef.current) == null ? void 0 : _b3.type
1538
+ optionsRef.current?.type
1630
1539
  );
1631
- const supportsKerningUpkeep = !((_c2 = optionsRef.current) == null ? void 0 : _c2.disableKerning) && (splitChars || splitWords);
1540
+ const supportsKerningUpkeep = !optionsRef.current?.disableKerning && (splitChars || splitWords);
1632
1541
  if (!supportsKerningUpkeep) return;
1633
1542
  const ownerWindow = observedElement.ownerDocument.defaultView;
1634
- const wordClass = (_e2 = (_d2 = optionsRef.current) == null ? void 0 : _d2.wordClass) != null ? _e2 : "split-word";
1635
- const charClass = (_g2 = (_f2 = optionsRef.current) == null ? void 0 : _f2.charClass) != null ? _g2 : "split-char";
1636
- const mask = (_h = optionsRef.current) == null ? void 0 : _h.mask;
1637
- const isolateKerningMeasurement = (_i = optionsRef.current) == null ? void 0 : _i.isolateKerningMeasurement;
1638
- const readKerningStyleSnapshot = (element) => {
1639
- var _a4;
1640
- return `${buildKerningStyleKey(getComputedStyle(element))}|${(_a4 = element.getAttribute("style")) != null ? _a4 : ""}`;
1641
- };
1543
+ const wordClass = optionsRef.current?.wordClass ?? "split-word";
1544
+ const charClass = optionsRef.current?.charClass ?? "split-char";
1545
+ const mask = optionsRef.current?.mask;
1546
+ const isolateKerningMeasurement = optionsRef.current?.isolateKerningMeasurement;
1547
+ const readKerningStyleSnapshot = (element) => `${buildKerningStyleKey(getComputedStyle(element))}|${element.getAttribute("style") ?? ""}`;
1642
1548
  lastKerningStyleKeyRef.current = readKerningStyleSnapshot(observedElement);
1643
1549
  const runKerningUpkeep = () => {
1644
- var _a4, _b4;
1645
- const currentElement = (_a4 = containerRef.current) == null ? void 0 : _a4.firstElementChild;
1550
+ const currentElement = containerRef.current?.firstElementChild;
1646
1551
  if (!(currentElement instanceof HTMLElement)) return;
1647
1552
  if (!currentElement.isConnected) return;
1648
1553
  const nextKerningStyleKey = readKerningStyleSnapshot(currentElement);
@@ -1684,7 +1589,7 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1684
1589
  splitChars,
1685
1590
  splitWords,
1686
1591
  {
1687
- disableKerning: (_b4 = optionsRef.current) == null ? void 0 : _b4.disableKerning,
1592
+ disableKerning: optionsRef.current?.disableKerning,
1688
1593
  isolateKerningMeasurement,
1689
1594
  mask
1690
1595
  }
@@ -1771,25 +1676,23 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1771
1676
  const shouldRevertOnComplete = hasVariants && !!animateLabel && !whileInViewLabel && !needsViewport && !whileScrollLabel && revertOnComplete;
1772
1677
  const pendingRevertRef = useRef(null);
1773
1678
  useEffect(() => {
1774
- var _a3;
1775
1679
  if (!shouldRevertOnComplete) {
1776
1680
  pendingRevertRef.current = null;
1777
1681
  revertTrackerRef.current.total = 0;
1778
1682
  revertTrackerRef.current.completed = 0;
1779
1683
  return;
1780
1684
  }
1781
- pendingRevertRef.current = animateLabel != null ? animateLabel : null;
1685
+ pendingRevertRef.current = animateLabel ?? null;
1782
1686
  const tracker = revertTrackerRef.current;
1783
1687
  tracker.total = revertTotalCount;
1784
1688
  tracker.completed = 0;
1785
1689
  if (revertTotalCount === 0) {
1786
- (_a3 = splitResultRef.current) == null ? void 0 : _a3.revert();
1690
+ splitResultRef.current?.revert();
1787
1691
  pendingRevertRef.current = null;
1788
1692
  }
1789
1693
  }, [shouldRevertOnComplete, animateLabel, revertTotalCount]);
1790
1694
  const handleRevertComplete = useCallback(
1791
1695
  (definition) => {
1792
- var _a3;
1793
1696
  const label = pendingRevertRef.current;
1794
1697
  if (!label) return;
1795
1698
  if (typeof definition === "string" && definition !== label) {
@@ -1798,14 +1701,13 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1798
1701
  const tracker = revertTrackerRef.current;
1799
1702
  tracker.completed += 1;
1800
1703
  if (tracker.completed >= tracker.total) {
1801
- (_a3 = splitResultRef.current) == null ? void 0 : _a3.revert();
1704
+ splitResultRef.current?.revert();
1802
1705
  pendingRevertRef.current = null;
1803
1706
  }
1804
1707
  },
1805
1708
  []
1806
1709
  );
1807
1710
  useEffect(() => {
1808
- var _a3;
1809
1711
  if (!autoSplit || !containerRef.current) return;
1810
1712
  if (!data) return;
1811
1713
  const child2 = containerRef.current.firstElementChild;
@@ -1813,7 +1715,7 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1813
1715
  const targets = resolveAutoSplitTargets(child2);
1814
1716
  if (targets.length === 0) return;
1815
1717
  autoSplitWidthByTargetRef.current = /* @__PURE__ */ new Map();
1816
- const { splitLines } = resolveSplitFlags((_a3 = optionsRef.current) == null ? void 0 : _a3.type);
1718
+ const { splitLines } = resolveSplitFlags(optionsRef.current?.type);
1817
1719
  const handleResize = () => {
1818
1720
  const currentWidth = resolveAutoSplitWidth(
1819
1721
  targets,
@@ -1894,8 +1796,7 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1894
1796
  const promise = normalizeToPromise(callbackResult);
1895
1797
  if (revertOnCompleteRef.current && promise) {
1896
1798
  promise.then(() => {
1897
- var _a3;
1898
- (_a3 = splitResultRef.current) == null ? void 0 : _a3.revert();
1799
+ splitResultRef.current?.revert();
1899
1800
  }).catch(() => {
1900
1801
  console.warn("[fetta] Animation rejected, text not reverted");
1901
1802
  });
@@ -1924,12 +1825,11 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1924
1825
  }
1925
1826
  }, [isInView, needsViewport, hasVariants]);
1926
1827
  useEffect(() => {
1927
- var _a3, _b3, _c2, _d2, _e2, _f2;
1928
1828
  if (!whileScrollLabel) return;
1929
1829
  if (!resolvedVariants) return;
1930
1830
  if (!splitResultRef.current) return;
1931
1831
  if (splitResultVersionRef.current !== childTreeVersion) return;
1932
- const liveChildElement = (_a3 = containerRef.current) == null ? void 0 : _a3.firstElementChild;
1832
+ const liveChildElement = containerRef.current?.firstElementChild;
1933
1833
  if (!(liveChildElement instanceof HTMLElement)) return;
1934
1834
  const variantName = whileScrollLabel;
1935
1835
  const def = resolvedVariants[variantName];
@@ -1939,7 +1839,7 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1939
1839
  splitResultRef.current,
1940
1840
  def,
1941
1841
  { duration: 0, delay: 0 },
1942
- (_b3 = optionsRef.current) == null ? void 0 : _b3.type,
1842
+ optionsRef.current?.type,
1943
1843
  isPresent,
1944
1844
  delayScope,
1945
1845
  custom,
@@ -1951,7 +1851,7 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1951
1851
  splitResultRef.current,
1952
1852
  def,
1953
1853
  transition,
1954
- (_c2 = optionsRef.current) == null ? void 0 : _c2.type,
1854
+ optionsRef.current?.type,
1955
1855
  isPresent,
1956
1856
  delayScope,
1957
1857
  custom
@@ -1959,10 +1859,10 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1959
1859
  if (!scrollAnimation) return;
1960
1860
  const scrollOpts = scrollProp;
1961
1861
  const cleanup = scroll(scrollAnimation, {
1962
- target: (_d2 = containerRef.current) != null ? _d2 : void 0,
1963
- offset: scrollOpts == null ? void 0 : scrollOpts.offset,
1964
- axis: scrollOpts == null ? void 0 : scrollOpts.axis,
1965
- container: (_f2 = (_e2 = scrollOpts == null ? void 0 : scrollOpts.container) == null ? void 0 : _e2.current) != null ? _f2 : void 0
1862
+ target: containerRef.current ?? void 0,
1863
+ offset: scrollOpts?.offset,
1864
+ axis: scrollOpts?.axis,
1865
+ container: scrollOpts?.container?.current ?? void 0
1966
1866
  });
1967
1867
  return () => {
1968
1868
  cleanup();
@@ -1991,7 +1891,7 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
1991
1891
  const focusVariant = hasFocus ? whileFocusLabel : void 0;
1992
1892
  const hasWrapperVariants = Object.keys(wrapperVariantsByName).length > 0;
1993
1893
  const interactionVariant = isTapped && tapVariant || isFocused && focusVariant || isHovered && hoverVariant || void 0;
1994
- const displayVariant = interactionVariant != null ? interactionVariant : activeVariant;
1894
+ const displayVariant = interactionVariant ?? activeVariant;
1995
1895
  const shouldInheritVariants = hasOrchestrationVariants || !!whileScrollLabel || hasHover || hasTap || hasFocus || hasWrapperVariants;
1996
1896
  const suppressInitialOnResplit = !animateOnResplit && pendingFullResplitRef.current;
1997
1897
  const childInitial = suppressInitialOnResplit ? false : shouldInheritVariants || initialLabel === void 0 ? void 0 : initialLabel;
@@ -2002,11 +1902,10 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
2002
1902
  const wrapperExit = shouldInheritVariants ? exitProp : void 0;
2003
1903
  const wrapperTransition = shouldInheritVariants && hasVariants ? reduceMotionActive ? { duration: 0, delay: 0 } : orchestrationTransition : void 0;
2004
1904
  function renderNode(node, key) {
2005
- var _a3;
2006
1905
  if (node.type === "text") {
2007
1906
  return node.text;
2008
1907
  }
2009
- const props = (_a3 = nodePropsMap == null ? void 0 : nodePropsMap.get(node)) != null ? _a3 : attrsToProps(node.attrs);
1908
+ const props = nodePropsMap?.get(node) ?? attrsToProps(node.attrs);
2010
1909
  const renderedChildren = renderNodes(node.children, key);
2011
1910
  const isVoidTag = VOID_HTML_TAGS.has(node.tag);
2012
1911
  if (node.split) {
@@ -2018,9 +1917,9 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
2018
1917
  const renderAsMotionSplitNode = hasVariants;
2019
1918
  if (!renderAsMotionSplitNode) {
2020
1919
  if (isVoidTag) {
2021
- return createElement(node.tag, __spreadValues({ key }, props));
1920
+ return createElement(node.tag, { key, ...props });
2022
1921
  }
2023
- return createElement(node.tag, __spreadValues({ key }, props), renderedChildren);
1922
+ return createElement(node.tag, { key, ...props }, renderedChildren);
2024
1923
  }
2025
1924
  const MotionTag = getMotionComponent(node.tag);
2026
1925
  const variantsForType = variantsByType[splitType];
@@ -2037,23 +1936,23 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
2037
1936
  } : void 0;
2038
1937
  return createElement(
2039
1938
  MotionTag,
2040
- __spreadProps(__spreadValues({
2041
- key
2042
- }, props), {
1939
+ {
1940
+ key,
1941
+ ...props,
2043
1942
  custom: info,
2044
1943
  variants: variantsForType,
2045
1944
  initial: childInitial,
2046
1945
  animate: childAnimate,
2047
1946
  exit: exitProp,
2048
1947
  onAnimationComplete: onCompleteHandler
2049
- }),
1948
+ },
2050
1949
  renderedChildren
2051
1950
  );
2052
1951
  }
2053
1952
  if (isVoidTag) {
2054
- return createElement(node.tag, __spreadValues({ key }, props));
1953
+ return createElement(node.tag, { key, ...props });
2055
1954
  }
2056
- return createElement(node.tag, __spreadValues({ key }, props), renderedChildren);
1955
+ return createElement(node.tag, { key, ...props }, renderedChildren);
2057
1956
  }
2058
1957
  function renderNodes(nodes, keyPrefix) {
2059
1958
  return nodes.map(
@@ -2061,7 +1960,9 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
2061
1960
  );
2062
1961
  }
2063
1962
  const child = data ? (() => {
2064
- const childProps = __spreadValues({}, children.props);
1963
+ const childProps = {
1964
+ ...children.props
1965
+ };
2065
1966
  if ("dangerouslySetInnerHTML" in childProps) {
2066
1967
  delete childProps.dangerouslySetInnerHTML;
2067
1968
  }
@@ -2070,9 +1971,10 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
2070
1971
  }
2071
1972
  return createElement(
2072
1973
  children.type,
2073
- __spreadProps(__spreadValues({}, childProps), {
1974
+ {
1975
+ ...childProps,
2074
1976
  key: `split-${childTreeVersion}`
2075
- }),
1977
+ },
2076
1978
  renderNodes(data.nodes, "split")
2077
1979
  );
2078
1980
  })() : cloneElement(children, {
@@ -2081,15 +1983,16 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
2081
1983
  const Wrapper = getMotionComponent(Component);
2082
1984
  const content = createElement(
2083
1985
  Wrapper,
2084
- __spreadProps(__spreadValues({
1986
+ {
2085
1987
  ref: mergedRef,
2086
- "data-fetta-auto-split-wrapper": "true"
2087
- }, passthroughWrapperProps), {
1988
+ "data-fetta-auto-split-wrapper": "true",
1989
+ ...passthroughWrapperProps,
2088
1990
  className,
2089
- style: __spreadValues({
1991
+ style: {
2090
1992
  visibility: isReady || !waitForFonts ? "visible" : "hidden",
2091
- position: "relative"
2092
- }, userStyle),
1993
+ position: "relative",
1994
+ ...userStyle
1995
+ },
2093
1996
  variants: wrapperVariants,
2094
1997
  initial: wrapperInitial,
2095
1998
  animate: wrapperAnimate,
@@ -2104,7 +2007,7 @@ var SplitText = forwardRef(function SplitText2(_a, forwardedRef) {
2104
2007
  onFocus: handleFocus,
2105
2008
  onBlur: handleBlur,
2106
2009
  onAnimationComplete: handleWrapperAnimationComplete
2107
- }),
2010
+ },
2108
2011
  child
2109
2012
  );
2110
2013
  if (reducedMotion) {